diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / drivers / ruby2 / play . rb <nl> ppp b / drivers / ruby2 / play . rb <nl> def r ( a = ' 8d19cb41 - ddb8 - 44ab - 92f3 - f48ca607ab7b ' ) <nl> # r . div ( 1 , 6 ) . run <nl> # r . div ( 0 . 2 ) . run <nl> # r . div ( 1 , 0 ) . run <nl> - r . db ( ' test ' ) . table ( ' test2 ' ) . run <nl> - r . db ( ' test ' ) . table ( ' test ' ) . run <nl> + # r . db ( ' test ' ) . table ( ' test2 ' ) . run <nl> + # r . db ( ' test ' ) . table ( ' test ' ) . run <nl> mmm a / src / activity_logger . cc <nl> ppp b / src / activity_logger . cc <nl> std : : string activity_logger_t : : print_range ( size_t start , size_t end , bool print_ <nl> } <nl> return s ; <nl> } <nl> + <nl> + bool alprng ( activity_logger_t * l , size_t start , size_t end , bool print_bt ) { <nl> + std : : string s = l - > print_range ( start , end , print_bt ) ; <nl> + debugf ( " % s " , s . c_str ( ) ) ; <nl> + return true ; <nl> + } <nl> mmm a / src / activity_logger . hpp <nl> ppp b / src / activity_logger . hpp <nl> struct fake_activity_logger_t : private home_thread_mixin_t { <nl> # define debugf_log ( log , args . . . ) { \ <nl> std : : string _debugf_log = strprintf ( args ) ; \ <nl> ( log ) . add ( _debugf_log ) ; \ <nl> - debugf ( " % s \ n " , _debugf_log . c_str ( ) ) ; \ <nl> + debugf ( " % p [ % d ] : % s \ n " , & ( log ) , ( int ) ( log ) . size ( ) , _debugf_log . c_str ( ) ) ; \ <nl> } <nl> # define debugf_log_bt ( log , args . . . ) { \ <nl> std : : string _debugf_log = strprintf ( args ) ; \ <nl> ( log ) . add ( _debugf_log , true ) ; \ <nl> - debugf ( " % s \ n " , _debugf_log . c_str ( ) ) ; \ <nl> + debugf ( " % p [ % d ] : % s \ n " , & ( log ) , ( int ) ( log ) . size ( ) , _debugf_log . c_str ( ) ) ; \ <nl> } <nl> <nl> + bool alprng ( activity_logger_t * l , size_t start , size_t end , bool print_bt = true ) ; <nl> <nl> # endif / * ACTIVITY_LOGGER_HPP_ * / <nl> mmm a / src / containers / ptr_bag . hpp <nl> ppp b / src / containers / ptr_bag . hpp <nl> <nl> <nl> # include < set > <nl> <nl> - # include " errors . hpp " <nl> + / / # define PTR_BAG_LOG 1 <nl> + # ifdef PTR_BAG_LOG <nl> + # include " activity_logger . hpp " <nl> + static activity_logger_t ptr_bag_log ; <nl> + # define pblog ( . . . ) debugf_log ( ptr_bag_log , __VA_ARGS__ ) <nl> + # else <nl> + # define pblog ( . . . ) <nl> + # endif / / PTR_BAG_LOG <nl> <nl> + # include " utils . hpp " <nl> + <nl> + / / Classes that can be put into a pointer bag should inherit from this . <nl> class ptr_baggable_t { <nl> public : <nl> virtual ~ ptr_baggable_t ( ) { } <nl> } ; <nl> <nl> - class ptr_bag_t : public ptr_baggable_t { <nl> + / / A pointer bag holds a bunch of pointers and deletes them when it ' s freed . <nl> + class ptr_bag_t : public ptr_baggable_t , private home_thread_mixin_t { <nl> public : <nl> - ptr_bag_t ( ) { } <nl> + ptr_bag_t ( ) : parent ( 0 ) { <nl> + pblog ( " % p created " , this ) ; <nl> + } <nl> ~ ptr_bag_t ( ) { <nl> + assert_thread ( ) ; <nl> + guarantee ( ! parent | | ptrs . size ( ) = = 0 ) ; <nl> for ( std : : set < ptr_baggable_t * > : : iterator <nl> it = ptrs . begin ( ) ; it ! = ptrs . end ( ) ; + + it ) { <nl> + pblog ( " deleting % p from % p " , * it , this ) ; <nl> delete * it ; <nl> } <nl> } <nl> <nl> / / We want to be able to add const pointers to the bag too . <nl> template < class T > <nl> - const T * add ( const T * ptr ) { <nl> - return add ( const_cast < T * > ( ptr ) ) ; <nl> - } <nl> + const T * add ( const T * ptr ) { return add ( const_cast < T * > ( ptr ) ) ; } <nl> <nl> + / / Add a pointer to the bag ; it will be deleted when the bag is destroyed . <nl> template < class T > <nl> T * add ( T * ptr ) { <nl> - ptrs . insert ( static_cast < ptr_baggable_t * > ( ptr ) ) ; <nl> + real_add ( static_cast < ptr_baggable_t * > ( ptr ) ) ; <nl> return ptr ; <nl> } <nl> + <nl> + / / We want to make sure that if people add ` p ` to ptr_bag ` A ` , then add ` A ` <nl> + / / to ptr_bag ` B ` , then add ` p ` to ` B ` , that ` p ` doesn ' t get double - freed . <nl> + ptr_bag_t * add ( ptr_bag_t * sub_bag ) { <nl> + sub_bag - > shadow ( this ) ; <nl> + real_add ( static_cast < ptr_baggable_t * > ( sub_bag ) ) ; <nl> + return sub_bag ; <nl> + } <nl> + <nl> + bool has ( const ptr_baggable_t * ptr ) { <nl> + return ptrs . count ( const_cast < ptr_baggable_t * > ( ptr ) ) > 0 ; <nl> + } <nl> private : <nl> - / / This * MUST * be a set , because it ' s legal to bag the same pointer twice . <nl> + void real_add ( ptr_baggable_t * ptr ) { <nl> + pblog ( " adding % p to % p " , ptr , this ) ; <nl> + assert_thread ( ) ; <nl> + if ( parent ) { <nl> + parent - > real_add ( ptr ) ; <nl> + } else { <nl> + guarantee ( ptrs . count ( ptr ) = = 0 ) ; <nl> + ptrs . insert ( static_cast < ptr_baggable_t * > ( ptr ) ) ; <nl> + } <nl> + } <nl> + <nl> + / / When a ptr_bag shadows another ptr_bag , any pointers inserted into it in <nl> + / / the past or future are inserted into the parent ptr_bag . <nl> + void shadow ( ptr_bag_t * _parent ) { <nl> + parent = _parent ; <nl> + for ( std : : set < ptr_baggable_t * > : : iterator <nl> + it = ptrs . begin ( ) ; it ! = ptrs . end ( ) ; + + it ) { <nl> + parent - > real_add ( * it ) ; <nl> + } <nl> + ptrs = std : : set < ptr_baggable_t * > ( ) ; <nl> + guarantee ( ptrs . size ( ) = = 0 ) ; <nl> + } <nl> + <nl> + ptr_bag_t * parent ; / / See ` shadow ` . <nl> std : : set < ptr_baggable_t * > ptrs ; <nl> DISABLE_COPYING ( ptr_bag_t ) ; <nl> } ; <nl> mmm a / src / rdb_protocol / datum . cc <nl> ppp b / src / rdb_protocol / datum . cc <nl> datum_t : : datum_t ( datum_t : : type_t _type ) : type ( _type ) { <nl> r_sanity_check ( type = = R_ARRAY | | type = = R_OBJECT | | type = = R_NULL ) ; <nl> } <nl> <nl> - void datum_t : : init_json ( cJSON * json , ptr_bag_t * alloc ) { <nl> + void datum_t : : init_json ( cJSON * json , env_t * env ) { <nl> switch ( json - > type ) { <nl> case cJSON_False : { <nl> type = R_BOOL ; r_bool = false ; <nl> void datum_t : : init_json ( cJSON * json , ptr_bag_t * alloc ) { <nl> case cJSON_Array : { <nl> type = R_ARRAY ; <nl> for ( int i = 0 ; i < cJSON_GetArraySize ( json ) ; + + i ) { <nl> - add ( alloc - > add ( new datum_t ( cJSON_GetArrayItem ( json , i ) , alloc ) ) ) ; <nl> + add ( env - > add_ptr ( new datum_t ( cJSON_GetArrayItem ( json , i ) , env ) ) ) ; <nl> } <nl> } ; break ; <nl> case cJSON_Object : { <nl> type = R_OBJECT ; <nl> for ( int i = 0 ; i < cJSON_GetArraySize ( json ) ; + + i ) { <nl> cJSON * el = cJSON_GetArrayItem ( json , i ) ; <nl> - bool b = add ( el - > string , alloc - > add ( new datum_t ( el , alloc ) ) ) ; <nl> + bool b = add ( el - > string , env - > add_ptr ( new datum_t ( el , env ) ) ) ; <nl> rcheck ( ! b , strprintf ( " Duplicate key : % s " , el - > string ) ) ; <nl> } <nl> } ; break ; <nl> void datum_t : : init_json ( cJSON * json , ptr_bag_t * alloc ) { <nl> } <nl> } <nl> <nl> - datum_t : : datum_t ( cJSON * json , ptr_bag_t * alloc ) { init_json ( json , alloc ) ; } <nl> - datum_t : : datum_t ( boost : : shared_ptr < scoped_cJSON_t > json , ptr_bag_t * alloc ) { <nl> - init_json ( json - > get ( ) , alloc ) ; <nl> + datum_t : : datum_t ( cJSON * json , env_t * env ) { init_json ( json , env ) ; } <nl> + datum_t : : datum_t ( boost : : shared_ptr < scoped_cJSON_t > json , env_t * env ) { <nl> + init_json ( json - > get ( ) , env ) ; <nl> } <nl> <nl> datum_t : : type_t datum_t : : get_type ( ) const { return type ; } <nl> double datum_t : : as_num ( ) const { <nl> check_type ( R_NUM ) ; <nl> return r_num ; <nl> } <nl> + int datum_t : : as_int ( ) const { <nl> + double d = as_num ( ) ; <nl> + int i = d ; <nl> + rcheck ( static_cast < double > ( i ) = = d , strprintf ( " Number not an integer : % lf " , d ) ) ; <nl> + return i ; <nl> + } <nl> const std : : string & datum_t : : as_str ( ) const { <nl> check_type ( R_STR ) ; <nl> return r_str ; <nl> bool datum_t : : operator < = ( const datum_t & rhs ) const { return cmp ( rhs ) ! = 1 ; } <nl> bool datum_t : : operator > ( const datum_t & rhs ) const { return cmp ( rhs ) = = 1 ; } <nl> bool datum_t : : operator > = ( const datum_t & rhs ) const { return cmp ( rhs ) ! = - 1 ; } <nl> <nl> - datum_t : : datum_t ( const Datum * d , ptr_bag_t * alloc ) { <nl> + datum_t : : datum_t ( const Datum * d , env_t * env ) { <nl> switch ( d - > type ( ) ) { <nl> case Datum_DatumType_R_NULL : { <nl> type = R_NULL ; <nl> datum_t : : datum_t ( const Datum * d , ptr_bag_t * alloc ) { <nl> case Datum_DatumType_R_ARRAY : { <nl> type = R_ARRAY ; <nl> for ( int i = 0 ; i < d - > r_array_size ( ) ; + + i ) { <nl> - r_array . push_back ( alloc - > add ( new datum_t ( & d - > r_array ( i ) , alloc ) ) ) ; <nl> + r_array . push_back ( env - > add_ptr ( new datum_t ( & d - > r_array ( i ) , env ) ) ) ; <nl> } <nl> } ; break ; <nl> case Datum_DatumType_R_OBJECT : { <nl> datum_t : : datum_t ( const Datum * d , ptr_bag_t * alloc ) { <nl> const std : : string & key = ap - > key ( ) ; <nl> rcheck ( r_object . count ( key ) = = 0 , <nl> strprintf ( " Duplicate key % s in object . " , key . c_str ( ) ) ) ; <nl> - r_object [ key ] = alloc - > add ( new datum_t ( & ap - > val ( ) , alloc ) ) ; <nl> + r_object [ key ] = env - > add_ptr ( new datum_t ( & ap - > val ( ) , env ) ) ; <nl> } <nl> } ; break ; <nl> default : unreachable ( ) ; <nl> mmm a / src / rdb_protocol / datum . hpp <nl> ppp b / src / rdb_protocol / datum . hpp <nl> class datum_t : public ptr_baggable_t { <nl> explicit datum_t ( const std : : map < const std : : string , const datum_t * > & _object ) ; <nl> <nl> explicit datum_t ( const Datum * d ) ; <nl> - explicit datum_t ( const Datum * d , ptr_bag_t * alloc ) ; <nl> + explicit datum_t ( const Datum * d , env_t * env ) ; <nl> explicit datum_t ( cJSON * json ) ; <nl> - explicit datum_t ( cJSON * json , ptr_bag_t * alloc ) ; <nl> + explicit datum_t ( cJSON * json , env_t * env ) ; <nl> explicit datum_t ( boost : : shared_ptr < scoped_cJSON_t > json ) ; <nl> - explicit datum_t ( boost : : shared_ptr < scoped_cJSON_t > json , ptr_bag_t * alloc ) ; <nl> + explicit datum_t ( boost : : shared_ptr < scoped_cJSON_t > json , env_t * env ) ; <nl> void write_to_protobuf ( Datum * out ) const ; <nl> <nl> enum type_t { <nl> class datum_t : public ptr_baggable_t { <nl> <nl> bool as_bool ( ) const ; <nl> double as_num ( ) const ; <nl> + int as_int ( ) const ; <nl> const std : : string & as_str ( ) const ; <nl> const std : : vector < const datum_t * > & as_array ( ) const ; <nl> const std : : map < const std : : string , const datum_t * > & as_object ( ) const ; <nl> class datum_t : public ptr_baggable_t { <nl> / / Returns whether or not ` key ` was already present in object . <nl> MUST_USE bool add ( const std : : string & key , const datum_t * val , bool clobber = false ) ; <nl> private : <nl> - void init_json ( cJSON * json , ptr_bag_t * alloc ) ; <nl> + void init_json ( cJSON * json , env_t * env ) ; <nl> <nl> / / Listing everything is more debugging - friendly than a boost : : variant , <nl> / / but less efficient . TODO : fix later . <nl> mmm a / src / rdb_protocol / env . hpp <nl> ppp b / src / rdb_protocol / env . hpp <nl> <nl> <nl> namespace ql { <nl> class term_t ; <nl> + <nl> class env_t { <nl> public : <nl> template < class T > <nl> - T * add_ptr ( T * p ) { return ptrs . add ( p ) ; } <nl> + T * add_ptr ( T * p ) { <nl> + r_sanity_check ( bags . size ( ) > 0 ) ; <nl> + for ( size_t i = 0 ; i < bags . size ( ) ; + + i ) { <nl> + if ( bags [ i ] - > has ( p ) ) return p ; <nl> + } <nl> + bags [ bags . size ( ) - 1 ] - > add ( p ) ; <nl> + return p ; <nl> + } <nl> func_t * new_func ( const Term2 * term ) { <nl> return add_ptr ( new func_t ( this , term ) ) ; <nl> } <nl> class env_t { <nl> return add_ptr ( compile_term ( this , source ) ) ; <nl> } <nl> <nl> - ptr_bag_t * get_bag ( ) { return & ptrs ; } <nl> + size_t num_checkpoints ( ) { <nl> + return bags . size ( ) - 1 ; <nl> + } <nl> + void checkpoint ( ) { <nl> + bags . push_back ( new ptr_bag_t ( ) ) ; <nl> + } <nl> + void merge_checkpoint ( ) { <nl> + r_sanity_check ( bags . size ( ) > = 2 ) ; <nl> + bags [ bags . size ( ) - 2 ] - > add ( bags [ bags . size ( ) - 1 ] ) ; <nl> + bags . pop_back ( ) ; <nl> + } <nl> + void discard_checkpoint ( ) { <nl> + r_sanity_check ( bags . size ( ) > = 2 ) ; <nl> + delete bags [ bags . size ( ) - 1 ] ; <nl> + bags . pop_back ( ) ; <nl> + } <nl> + ~ env_t ( ) { <nl> + for ( size_t i = 0 ; i < bags . size ( ) ; + + i ) { <nl> + delete bags [ i ] ; <nl> + } <nl> + } <nl> private : <nl> - ptr_bag_t ptrs ; <nl> + ptr_bag_t * get_bag ( ) { <nl> + r_sanity_check ( bags . size ( ) > 0 ) ; <nl> + return bags [ bags . size ( ) - 1 ] ; <nl> + } <nl> + std : : vector < ptr_bag_t * > bags ; <nl> <nl> public : <nl> void push_var ( int var , const datum_t * * val ) { vars [ var ] . push ( val ) ; } <nl> + const datum_t * * top_var ( int var ) { <nl> + rcheck ( ! vars [ var ] . empty ( ) , strprintf ( " Unrecognized variabled % d " , var ) ) ; <nl> + return vars [ var ] . top ( ) ; <nl> + } <nl> void pop_var ( int var ) { vars [ var ] . pop ( ) ; } <nl> const datum_t * * get_var ( int var ) { return vars [ var ] . top ( ) ; } <nl> void dump_scope ( std : : map < int , Datum > * out ) { <nl> class env_t { <nl> interruptor ( _interruptor ) , <nl> this_machine ( _this_machine ) { <nl> guarantee ( js_runner ) ; <nl> + bags . push_back ( new ptr_bag_t ( ) ) ; <nl> } <nl> <nl> extproc : : pool_t * pool ; / / for running external JS jobs <nl> class env_t { <nl> DISABLE_COPYING ( env_t ) ; <nl> } ; <nl> <nl> + class env_checkpointer_t { <nl> + public : <nl> + env_checkpointer_t ( env_t * _env , void ( env_t : : * _f ) ( ) ) : env ( _env ) , f ( _f ) { <nl> + env - > checkpoint ( ) ; <nl> + } <nl> + ~ env_checkpointer_t ( ) { <nl> + ( env - > * f ) ( ) ; <nl> + } <nl> + private : <nl> + env_t * env ; <nl> + void ( env_t : : * f ) ( ) ; <nl> + } ; <nl> + <nl> } / / namespace query_language <nl> <nl> # endif / / RDB_PROTOCOL_ENV_HPP_ <nl> mmm a / src / rdb_protocol / func . cc <nl> ppp b / src / rdb_protocol / func . cc <nl> func_t : : func_t ( env_t * env , const Term2 * _source ) : body ( 0 ) , source ( _source ) { <nl> guarantee ( argptrs . size ( ) = = 0 ) ; <nl> for ( size_t i = 0 ; i < args . size ( ) ; + + i ) { <nl> argptrs . push_back ( 0 ) ; <nl> + / / debugf ( " pushing % d - > % p \ n " , args [ i ] , & argptrs [ i ] ) ; <nl> env - > push_var ( args [ i ] , & argptrs [ i ] ) ; <nl> } <nl> <nl> const Term2 * body_source = & t - > args ( 1 ) ; <nl> body = env - > new_term ( body_source ) ; <nl> <nl> - for ( size_t i = 0 ; i < args . size ( ) ; + + i ) env - > pop_var ( args [ i ] ) ; <nl> + for ( size_t i = 0 ; i < args . size ( ) ; + + i ) { <nl> + / / debugf ( " popping % d \ n " , args [ i ] ) ; <nl> + env - > pop_var ( args [ i ] ) ; <nl> + } <nl> } <nl> <nl> val_t * func_t : : call ( const std : : vector < datum_t * > & args ) { <nl> rcheck ( args . size ( ) = = argptrs . size ( ) , <nl> strprintf ( " Passed % lu arguments to function of arity % lu . " , <nl> args . size ( ) , argptrs . size ( ) ) ) ; <nl> - for ( size_t i = 0 ; i < args . size ( ) ; + + i ) argptrs [ i ] = args [ i ] ; <nl> + for ( size_t i = 0 ; i < args . size ( ) ; + + i ) { <nl> + / / debugf ( " Setting % p to % p \ n " , & argptrs [ i ] , args [ i ] ) ; <nl> + argptrs [ i ] = args [ i ] ; <nl> + } <nl> return body - > eval ( false ) ; <nl> / / ^ ^ ^ ^ ^ don ' t use cached value <nl> } <nl> <nl> - wire_func_t : : wire_func_t ( ) : func ( 0 ) { } <nl> - wire_func_t : : wire_func_t ( env_t * env , func_t * _func ) : func ( _func ) { <nl> + wire_func_t : : wire_func_t ( ) { } <nl> + wire_func_t : : wire_func_t ( env_t * env , func_t * func ) { <nl> + cached_funcs [ env ] = func ; <nl> source = * func - > source ; <nl> env - > dump_scope ( & scope ) ; <nl> } <nl> func_t * wire_func_t : : compile ( env_t * env ) { <nl> - if ( ! func ) func = env - > new_func ( & source ) ; <nl> - r_sanity_check ( func ) ; <nl> - return func ; <nl> + if ( cached_funcs . count ( env ) > 0 ) return cached_funcs [ env ] ; <nl> + return ( cached_funcs [ env ] = env - > new_func ( & source ) ) ; <nl> } <nl> <nl> func_term_t : : func_term_t ( env_t * env , const Term2 * term ) <nl> mmm a / src / rdb_protocol / func . hpp <nl> ppp b / src / rdb_protocol / func . hpp <nl> class wire_func_t { <nl> wire_func_t ( ) ; <nl> wire_func_t ( env_t * env , func_t * _func ) ; <nl> func_t * compile ( env_t * env ) ; <nl> - private : <nl> - func_t * func ; <nl> + protected : <nl> + std : : map < env_t * , func_t * > cached_funcs ; <nl> <nl> Term2 source ; <nl> std : : map < int , Datum > scope ; <nl> public : <nl> + / / RDB_MAKE_ME_SERIALIZABLE_2 ( source , scope ) ; <nl> + } ; <nl> + <nl> + class map_wire_func_t : public wire_func_t { <nl> + public : <nl> + map_wire_func_t ( ) : wire_func_t ( ) { } <nl> + map_wire_func_t ( env_t * env , func_t * func ) : wire_func_t ( env , func ) { } <nl> RDB_MAKE_ME_SERIALIZABLE_2 ( source , scope ) ; <nl> } ; <nl> <nl> mmm a / src / rdb_protocol / protocol . hpp <nl> ppp b / src / rdb_protocol / protocol . hpp <nl> struct backfill_atom_t { <nl> RDB_MAKE_ME_SERIALIZABLE_3 ( key , value , recency ) ; <nl> } ; <nl> <nl> - typedef boost : : variant < Builtin_Filter , Mapping , Builtin_ConcatMap , Builtin_Range , ql : : wire_func_t > transform_variant_t ; <nl> + typedef boost : : variant < Builtin_Filter , Mapping , Builtin_ConcatMap , Builtin_Range , ql : : map_wire_func_t > transform_variant_t ; <nl> <nl> struct transform_atom_t { <nl> transform_atom_t ( ) { } <nl> mmm a / src / rdb_protocol / stream . cc <nl> ppp b / src / rdb_protocol / stream . cc <nl> void batched_rget_stream_t : : read_more ( ) { <nl> <nl> / * Re throw an exception if we got one . * / <nl> if ( runtime_exc_t * e = boost : : get < runtime_exc_t > ( & p_res - > result ) ) { <nl> + / / BREAKPOINT ; <nl> throw * e ; <nl> } <nl> <nl> mmm a / src / rdb_protocol / term . cc <nl> ppp b / src / rdb_protocol / term . cc <nl> <nl> # include " rdb_protocol / terms / db_table . hpp " <nl> # include " rdb_protocol / terms / map . hpp " <nl> # include " rdb_protocol / terms / pred . hpp " <nl> + # include " rdb_protocol / terms / var . hpp " <nl> <nl> namespace ql { <nl> <nl> term_t * compile_term ( env_t * env , const Term2 * t ) { <nl> case Term2_TermType_DATUM : return new datum_term_t ( env , & t - > datum ( ) ) ; <nl> case Term2_TermType_MAKE_ARRAY : return new make_array_term_t ( env , t ) ; <nl> case Term2_TermType_MAKE_OBJ : return new make_obj_term_t ( env , t ) ; <nl> - case Term2_TermType_VAR : <nl> + case Term2_TermType_VAR : return new var_term_t ( env , t ) ; <nl> case Term2_TermType_JAVASCRIPT : <nl> case Term2_TermType_ERROR : <nl> case Term2_TermType_IMPLICIT_VAR : <nl> val_t * term_t : : eval ( bool _use_cached_val ) { <nl> } <nl> <nl> val_t * term_t : : new_val ( datum_t * d ) { return env - > new_val ( d , this ) ; } <nl> + val_t * term_t : : new_val ( const datum_t * d ) { return env - > new_val ( d , this ) ; } <nl> val_t * term_t : : new_val ( datum_stream_t * s ) { return env - > new_val ( s , this ) ; } <nl> val_t * term_t : : new_val ( uuid_t db ) { return env - > new_val ( db , this ) ; } <nl> val_t * term_t : : new_val ( table_t * t ) { return env - > new_val ( t , this ) ; } <nl> mmm a / src / rdb_protocol / term . hpp <nl> ppp b / src / rdb_protocol / term . hpp <nl> class term_t : public ptr_baggable_t { <nl> val_t * eval ( bool _use_cached_val ) ; <nl> <nl> val_t * new_val ( datum_t * d ) ; <nl> + val_t * new_val ( const datum_t * d ) ; <nl> val_t * new_val ( datum_stream_t * s ) ; <nl> val_t * new_val ( uuid_t db ) ; <nl> val_t * new_val ( table_t * t ) ; <nl> mmm a / src / rdb_protocol / terms / datum_terms . hpp <nl> ppp b / src / rdb_protocol / terms / datum_terms . hpp <nl> namespace ql { <nl> class datum_term_t : public term_t { <nl> public : <nl> datum_term_t ( env_t * env , const Datum * datum ) <nl> - : term_t ( env ) , raw_val ( new_val ( new datum_t ( datum , env - > get_bag ( ) ) ) ) { <nl> + : term_t ( env ) , raw_val ( new_val ( new datum_t ( datum , env ) ) ) { <nl> guarantee ( raw_val ) ; <nl> } <nl> private : <nl> mmm a / src / rdb_protocol / terms / map . hpp <nl> ppp b / src / rdb_protocol / terms / map . hpp <nl> class map_term_t : public op_term_t { <nl> virtual val_t * eval_impl ( ) { <nl> datum_stream_t * seq = arg ( 0 ) - > as_seq ( ) ; <nl> func_t * f = arg ( 1 ) - > as_func ( ) ; <nl> - return new_val ( new datum_stream_t ( seq , f ) ) ; <nl> + return new_val ( seq - > map ( f ) ) ; <nl> + / / return new_val ( new datum_stream_t ( seq , f ) ) ; <nl> } <nl> RDB_NAME ( " map " ) ; <nl> } ; <nl> new file mode 100644 <nl> index 00000000000 . . 7d832ee6ae6 <nl> mmm / dev / null <nl> ppp b / src / rdb_protocol / terms / var . hpp <nl> <nl> + # include " rdb_protocol / op . hpp " <nl> + # include " rdb_protocol / err . hpp " <nl> + <nl> + namespace ql { <nl> + <nl> + class var_term_t : public op_term_t { <nl> + public : <nl> + var_term_t ( env_t * env , const Term2 * term ) : op_term_t ( env , term , argspec_t ( 1 ) ) { <nl> + int var = arg ( 0 ) - > as_datum ( ) - > as_int ( ) ; <nl> + datum_val = env - > top_var ( var ) ; <nl> + } <nl> + private : <nl> + const datum_t * * datum_val ; <nl> + virtual val_t * eval_impl ( ) { <nl> + return new_val ( * datum_val ) ; <nl> + } <nl> + RDB_NAME ( " var " ) ; <nl> + } ; <nl> + <nl> + } / / namespace ql <nl> mmm a / src / rdb_protocol / transform_visitors . cc <nl> ppp b / src / rdb_protocol / transform_visitors . cc <nl> void transform_visitor_t : : operator ( ) ( Builtin_Range range ) const { <nl> } <nl> } <nl> <nl> - void transform_visitor_t : : operator ( ) ( ql : : wire_func_t & func ) const { <nl> + void transform_visitor_t : : operator ( ) ( ql : : map_wire_func_t & func ) const { <nl> + debugf ( " setting up checkpoint . . . \ n " ) ; <nl> + ql : : env_checkpointer_t ( ql_env , & ql : : env_t : : discard_checkpoint ) ; <nl> + <nl> + debugf ( " compiling . . . \ n " ) ; <nl> ql : : func_t * f = func . compile ( ql_env ) ; <nl> - ql : : datum_t arg ( json , ql_env - > get_bag ( ) ) ; <nl> + debugf ( " parsing json . . . \ n " ) ; <nl> + ql : : datum_t * arg = ql_env - > add_ptr ( new ql : : datum_t ( json , ql_env ) ) ; <nl> std : : vector < ql : : datum_t * > args ; <nl> - args . push_back ( & arg ) ; <nl> + args . push_back ( arg ) ; <nl> + debugf ( " evaluating . . . \ n " ) ; <nl> ql : : val_t * v = f - > call ( args ) ; <nl> + debugf ( " re - encoding . . . \ n " ) ; <nl> out - > push_back ( v - > as_datum ( ) - > as_json ( ) ) ; <nl> } <nl> <nl> mmm a / src / rdb_protocol / transform_visitors . hpp <nl> ppp b / src / rdb_protocol / transform_visitors . hpp <nl> class transform_visitor_t : public boost : : static_visitor < void > { <nl> <nl> / / This is a non - const reference because it caches the compiled function for <nl> / / performance . <nl> - void operator ( ) ( ql : : wire_func_t & func ) const ; <nl> + void operator ( ) ( ql : : map_wire_func_t & func ) const ; <nl> <nl> private : <nl> boost : : shared_ptr < scoped_cJSON_t > json ; <nl> mmm a / src / rdb_protocol / val . cc <nl> ppp b / src / rdb_protocol / val . cc <nl> datum_stream_t : : datum_stream_t ( env_t * _env , bool use_outdated , <nl> * ns_access , _env - > interruptor , key_range_t : : universe ( ) , <nl> 100 , use_outdated ) ) <nl> { } <nl> + datum_stream_t : : datum_stream_t ( datum_stream_t * src ) { <nl> + * this = * src ; <nl> + } <nl> + datum_stream_t : : ~ datum_stream_t ( ) { } <nl> <nl> - datum_stream_t : : datum_stream_t ( datum_stream_t * src , func_t * f ) <nl> - : env ( src - > env ) , trans ( wire_func_t ( env , f ) ) { <nl> - json_stream = src - > json_stream - > add_transformation ( trans , 0 , env , _s , _b ) ; <nl> + datum_stream_t * datum_stream_t : : map ( func_t * f ) { <nl> + datum_stream_t * out = env - > add_ptr ( new datum_stream_t ( this ) ) ; <nl> + out - > trans = rdb_protocol_details : : transform_variant_t ( map_wire_func_t ( env , f ) ) ; <nl> + out - > json_stream = json_stream - > add_transformation ( out - > trans , 0 , env , _s , _b ) ; <nl> + return out ; <nl> } <nl> <nl> const datum_t * datum_stream_t : : next ( ) { <nl> - if ( last_bag . has ( ) ) env - > add_ptr ( last_bag . release ( ) ) ; <nl> boost : : shared_ptr < scoped_cJSON_t > json = json_stream - > next ( ) ; <nl> if ( ! json . get ( ) ) return 0 ; <nl> - last_bag . init ( new ptr_bag_t ( ) ) ; <nl> - return last_bag - > add ( new datum_t ( json , last_bag . get ( ) ) ) ; <nl> - } <nl> - <nl> - void datum_stream_t : : free_last_datum ( ) { <nl> - r_sanity_check ( last_bag . has ( ) ) ; <nl> - delete last_bag . release ( ) ; <nl> + return env - > add_ptr ( new datum_t ( json , env ) ) ; <nl> } <nl> <nl> - <nl> static void meta_check ( metadata_search_status_t status , metadata_search_status_t want , <nl> const std : : string & operation ) { <nl> if ( status ! = want ) { <nl> mmm a / src / rdb_protocol / val . hpp <nl> ppp b / src / rdb_protocol / val . hpp <nl> class datum_stream_t : public ptr_baggable_t { <nl> public : <nl> datum_stream_t ( env_t * env , bool use_outdated , <nl> namespace_repo_t < rdb_protocol_t > : : access_t * ns_access ) ; <nl> - datum_stream_t ( datum_stream_t * src , func_t * f ) ; <nl> + / / datum_stream_t ( datum_stream_t * src , func_t * f ) ; <nl> + virtual ~ datum_stream_t ( ) ; <nl> + datum_stream_t * map ( func_t * f ) ; <nl> const datum_t * next ( ) ; <nl> - void free_last_datum ( ) ; <nl> private : <nl> + datum_stream_t ( datum_stream_t * src ) ; <nl> env_t * env ; <nl> boost : : shared_ptr < query_language : : json_stream_t > json_stream ; <nl> - scoped_ptr_t < ptr_bag_t > last_bag ; <nl> <nl> rdb_protocol_details : : transform_variant_t trans ; <nl> query_language : : scopes_t _s ; <nl>
|
minor refactor
|
rethinkdb/rethinkdb
|
759734f4197344b06274958a048f5ade1209941d
|
2013-01-05T01:13:14Z
|
mmm a / hphp / compiler / analysis / emitter . cpp <nl> ppp b / hphp / compiler / analysis / emitter . cpp <nl> void commitGlobalData ( std : : unique_ptr < ArrayTypeTable : : Builder > arrTable ) { <nl> gd . HackArrCompatNotices = RuntimeOption : : EvalHackArrCompatNotices ; <nl> gd . EnableIntrinsicsExtension = RuntimeOption : : EnableIntrinsicsExtension ; <nl> gd . ReffinessInvariance = RuntimeOption : : EvalReffinessInvariance ; <nl> - gd . AllowObjectDestructors = RuntimeOption : : EvalAllowObjectDestructors ; <nl> gd . ForbidDynamicCalls = RuntimeOption : : EvalForbidDynamicCalls ; <nl> gd . UndefinedConstFallback = RuntimeOption : : UndefinedConstFallback ; <nl> gd . NoticeOnBuiltinDynamicCalls = <nl> mmm a / hphp / compiler / option . cpp <nl> ppp b / hphp / compiler / option . cpp <nl> void Option : : Load ( const IniSetting : : Map & ini , Hdf & config ) { <nl> Config : : Bind ( RuntimeOption : : EvalNoticeOnBuiltinDynamicCalls , <nl> ini , config , " NoticeOnBuiltinDynamicCalls " , <nl> RuntimeOption : : EvalNoticeOnBuiltinDynamicCalls ) ; <nl> - Config : : Bind ( RuntimeOption : : EvalAllowObjectDestructors , <nl> - ini , config , " AllowObjectDestructors " , <nl> - RuntimeOption : : EvalAllowObjectDestructors ) ; <nl> Config : : Bind ( RuntimeOption : : EvalAbortBuildOnVerifyError , <nl> ini , config , " AbortBuildOnVerifyError " , <nl> RuntimeOption : : EvalAbortBuildOnVerifyError ) ; <nl> mmm a / hphp / doc / ir . specification <nl> ppp b / hphp / doc / ir . specification <nl> To string conversions : <nl> Allocates a new object of class S1 and sets S2 as the reified generics of this <nl> class . If this class is not reified , this instruction raises an error . <nl> <nl> - | RegisterLiveObj , ND , S ( Obj ) , NF <nl> - <nl> - When EnableObjDestructCall is on , we need to keep track of objects to be able <nl> - to call their destructors when a request exists . This instruction is <nl> - conditionally emitted to implement that . <nl> - <nl> | InitProps < class > , ND , NA , NF <nl> <nl> Calls the property initializer function ( 86pinit ) for class . May throw . <nl> mmm a / hphp / hack / hhi / reflection . hhi <nl> ppp b / hphp / hack / hhi / reflection . hhi <nl> class ReflectionMethod extends ReflectionFunctionAbstract implements Reflector { <nl> public function isFinal ( ) ; <nl> public function isStatic ( ) ; <nl> public function isConstructor ( ) ; <nl> - public function isDestructor ( ) ; <nl> public function getClosure ( $ object ) ; <nl> public function getModifiers ( ) ; <nl> public function invoke ( $ object , . . . ) ; <nl> mmm a / hphp / hhbbc / dce . cpp <nl> ppp b / hphp / hhbbc / dce . cpp <nl> uint32_t numPush ( const Bytecode & bc ) { <nl> / / side - effects ( running destuctors , or modifying arbitrary things via <nl> / / a Ref ) . <nl> bool setCouldHaveSideEffects ( const Type & t ) { <nl> - return <nl> - t . couldBe ( BRef ) | | <nl> - could_run_destructor ( t ) ; <nl> + return t . couldBe ( BRef ) ; <nl> } <nl> <nl> / / Some reads could raise warnings and run arbitrary code . <nl> enum class Use { <nl> / / Indicates that the cell is ( unconditionally ) not used . <nl> Not = 1 , <nl> <nl> - / * <nl> - * Indicates that the cell is only used if it was the last reference alive . <nl> - * For instance , a PopC will call the destructor of the top - of - stack object <nl> - * if it was the last reference alive , and this counts as an example of <nl> - * ' UsedIfLastRef ' . <nl> - * <nl> - * If the producer of the cell knows that it is not the last reference , then <nl> - * it can treat Use : : UsedIfLastRef as being equivalent to Use : : Not . <nl> - * / <nl> - UsedIfLastRef = 2 , <nl> - <nl> / * <nl> * Indicates that the stack slot contains an array - like being <nl> * constructed by AddElemCs , which looks like it can be optimized to <nl> std : : string show ( InstrId id ) { <nl> } <nl> <nl> inline void validate ( Use u ) { <nl> - assert ( ! any ( u & Use : : Linked ) | | <nl> - mask_use ( u ) = = Use : : Not | | <nl> - mask_use ( u ) = = Use : : UsedIfLastRef ) ; <nl> + assert ( ! any ( u & Use : : Linked ) | | mask_use ( u ) = = Use : : Not ) ; <nl> } <nl> <nl> const char * show ( Use u ) { <nl> const char * show ( Use u ) { <nl> switch ( mask_use ( u ) ) { <nl> case Use : : Used : return " * U " ; <nl> case Use : : Not : return " * 0 " ; <nl> - case Use : : UsedIfLastRef : return " * UL " ; <nl> case Use : : AddElemC : return " * AE " ; <nl> case Use : : Linked : not_reached ( ) ; <nl> } <nl> bool allUnusedIfNotLastRef ( ) { return true ; } <nl> template < class . . . Args > <nl> bool allUnusedIfNotLastRef ( const UseInfo & ui , const Args & . . . args ) { <nl> auto u = mask_use ( ui . usage ) ; <nl> - return ( u = = Use : : Not | | u = = Use : : UsedIfLastRef ) & & <nl> - allUnusedIfNotLastRef ( args . . . ) ; <nl> + return u = = Use : : Not & & allUnusedIfNotLastRef ( args . . . ) ; <nl> } <nl> <nl> bool alwaysPop ( const UseInfo & ui ) { <nl> Type topC ( Env & env , uint32_t idx = 0 ) { <nl> return t ; <nl> } <nl> <nl> - bool popCouldRunDestructor ( Env & env , uint32_t i = 0 ) { <nl> - / / If there ' s an equivLoc , we know that it ' s not the last <nl> - / / reference , so popping the stack won ' t run any destructors . <nl> - auto const & s = env . stateBefore . stack ; <nl> - auto const & e = s [ s . size ( ) - i - 1 ] ; <nl> - / / Either StackDupId or StackThisId will guard the popped value <nl> - return e . equivLoc = = NoLocalId & & could_run_destructor ( e . type ) ; <nl> - } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / locals <nl> <nl> void discard ( Env & env ) { <nl> pop ( env , Use : : Not , env . id ) ; <nl> } <nl> <nl> - / * <nl> - * It may be ok to remove pops on objects with destructors in some scenarios <nl> - * ( where it won ' t change the observable point at which a destructor runs ) . We <nl> - * could also look at the object type and see if it is known that it can ' t have <nl> - * a user - defined destructor . <nl> - * <nl> - * For now , we mark the cell popped with a Use : : UsedIfLastRef . This indicates <nl> - * to the producer of the cell that the it is considered used if it could be <nl> - * the last reference alive ( in which case the destructor would be run on <nl> - * Pop ) . If the producer knows that the cell is not the last reference ( e . g . if <nl> - * it is a Dup ) , then Use : UsedIfLastRef is equivalent to Use : : Not . <nl> - * / <nl> - void discardNonDtors ( Env & env ) { <nl> - if ( popCouldRunDestructor ( env ) ) { <nl> - return pop ( env , Use : : UsedIfLastRef , env . id ) ; <nl> - } <nl> - discard ( env ) ; <nl> - } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> / * <nl> UseInfo & combineUis ( UseInfo & accum , const UseInfo & ui , const Args & . . . args ) { <nl> <nl> / * <nl> * The current instruction is going to be replaced with PopCs . Perform <nl> - * appropriate pops ( either Use : : Not or Use : : UsedIfLastRef ) . <nl> + * appropriate pops ( Use : : Not ) <nl> * / <nl> void ignoreInputs ( Env & env , bool linked , DceActionMap & & actions ) { <nl> auto const np = numPop ( env . op ) ; <nl> if ( ! np ) return ; <nl> <nl> auto usage = [ & ] ( uint32_t i ) { <nl> - auto ret = popCouldRunDestructor ( env , i ) ? Use : : UsedIfLastRef : Use : : Not ; <nl> + auto ret = Use : : Not ; <nl> if ( linked ) ret = ret | Use : : Linked ; <nl> return ret ; <nl> } ; <nl> DceActionMap & commitUis ( Env & env , bool linked , <nl> * <nl> * $ a ? f ( ) : 42 <nl> * <nl> - * If f ( ) is known to return a non - counted type , we have FCall - > PopC on <nl> - * one path , and Int 42 - > PopC on another , and the PopC marks <nl> - * its value Use : : Not . When we get to the Int 42 it thinks both <nl> - * instructions can be killed ; but when we get to the FCall it <nl> - * does nothing . So any time we decide to ignore a Use : : Not or <nl> - * Use : : UsedIfLastRef , we have to record that fact so we can prevent <nl> - * the other paths from trying to use that information . We communicate <nl> - * this via the ui . location field , and the forcedLiveLocations set . <nl> + * If f ( ) is known to return a non - counted type , we have FCall - > PopC on one <nl> + * path , and Int 42 - > PopC on another , and the PopC marks its value Use : : Not . <nl> + * When we get to the Int 42 it thinks both instructions can be killed ; but when <nl> + * we get to the FCall it does nothing . So any time we decide to ignore a <nl> + * Use : : Not , we have to record that fact so we can prevent the other paths from <nl> + * trying to use that information . We communicate this via the ui . location <nl> + * field , and the forcedLiveLocations set . <nl> * <nl> * [ We deal with this case now by inserting a PopC after the <nl> * FCall , which allows the 42 / PopC to be removed - but there are <nl> void pushRemovable ( Env & env ) { <nl> * eliminating the CGetL . <nl> * / <nl> <nl> - void dce ( Env & env , const bc : : PopC & ) { discardNonDtors ( env ) ; } <nl> - void dce ( Env & env , const bc : : PopV & ) { discardNonDtors ( env ) ; } <nl> + void dce ( Env & env , const bc : : PopC & ) { discard ( env ) ; } <nl> + void dce ( Env & env , const bc : : PopV & ) { discard ( env ) ; } <nl> void dce ( Env & env , const bc : : PopU & ) { discard ( env ) ; } <nl> void dce ( Env & env , const bc : : Int & ) { pushRemovable ( env ) ; } <nl> void dce ( Env & env , const bc : : String & ) { pushRemovable ( env ) ; } <nl> void dce ( Env & env , const bc : : ClsRefGetC & op ) { <nl> writeSlot ( env , op . slot ) ; <nl> return pop ( <nl> env , <nl> - popCouldRunDestructor ( env ) ? Use : : UsedIfLastRef : Use : : Not , <nl> + Use : : Not , <nl> std : : move ( ui . actions ) <nl> ) ; <nl> } <nl> void dce ( Env & env , const bc : : Dup & ) { <nl> / / and all dependent instructions . <nl> stack_ops ( env , [ & ] ( UseInfo & dup , UseInfo & orig ) { <nl> / / Dup pushes a cell that is guaranteed to be not the last reference . <nl> - / / So , it can be eliminated if the cell it pushes is used as either <nl> - / / Use : : Not or Use : : UsedIfLastRef . <nl> + / / So , it can be eliminated if the cell it pushes is used as Use : : Not . <nl> auto const dup_unused = allUnusedIfNotLastRef ( dup ) ; <nl> auto const orig_unused = allUnused ( orig ) & & <nl> ( ! isLinked ( dup ) | | dup_unused ) ; <nl> void dce ( Env & env , const bc : : PushL & op ) { <nl> stack_ops ( env , [ & ] ( UseInfo & ui ) { <nl> scheduleGenLoc ( env , op . loc1 ) ; <nl> if ( allUnused ( ui ) ) { <nl> - if ( isLocLive ( env , op . loc1 ) | | <nl> - could_run_destructor ( locRaw ( env , op . loc1 ) ) ) { <nl> + if ( isLocLive ( env , op . loc1 ) ) { <nl> env . dceState . replaceMap . insert ( <nl> { env . id , { bc : : UnsetL { op . loc1 } } } ) ; <nl> ui . actions . emplace ( env . id , DceAction : : Replace ) ; <nl> void dce ( Env & env , const bc : : PopL & op ) { <nl> assert ( ! locRaw ( env , op . loc1 ) . couldBe ( BRef ) | | <nl> env . stateBefore . localStaticBindings [ op . loc1 ] = = <nl> LocalStaticBinding : : Bound ) ; <nl> - discardNonDtors ( env ) ; <nl> + discard ( env ) ; <nl> env . dceState . actionMap [ env . id ] = DceAction : : PopInputs ; <nl> return ; <nl> } <nl> mmm a / hphp / hhbbc / interp - internal . h <nl> ppp b / hphp / hhbbc / interp - internal . h <nl> void doRet ( ISS & env , Type t , bool hasEffects ) { <nl> assert ( env . state . stack . empty ( ) ) ; <nl> env . flags . retParam = NoLocalId ; <nl> env . flags . returned = t ; <nl> - if ( hasEffects ) return ; <nl> - nothrow ( env ) ; <nl> - <nl> - / / If we ' re doing EffectFreeOnly analysis , we don ' t care about <nl> - / / params that might have side effects when they ' re destroyed , <nl> - / / because those params will just get popped if we drop the call , <nl> - / / with exactly the same results . <nl> - auto i = any ( env . collect . opts & CollectionOpts : : EffectFreeOnly ) ? <nl> - env . ctx . func - > params . size ( ) : 0 ; <nl> - <nl> - while ( i < env . state . locals . size ( ) ) { <nl> - auto const & l = env . state . locals [ i + + ] ; <nl> - if ( could_run_destructor ( l ) ) { <nl> - return ; <nl> - } <nl> + if ( ! hasEffects ) { <nl> + effect_free ( env ) ; <nl> } <nl> - <nl> - effect_free ( env ) ; <nl> } <nl> <nl> void mayUseVV ( ISS & env ) { <nl> mmm a / hphp / hhbbc / interp . cpp <nl> ppp b / hphp / hhbbc / interp . cpp <nl> void in ( ISS & env , const bc : : DiscardClsRef & op ) { <nl> takeClsRefSlot ( env , op . slot ) ; <nl> } <nl> void in ( ISS & env , const bc : : PopC & ) { <nl> - auto const guarded = topStkEquiv ( env ) ! = NoLocalId ; <nl> - if ( ! could_run_destructor ( popC ( env ) ) | | guarded ) return effect_free ( env ) ; <nl> - nothrow ( env ) ; <nl> + effect_free ( env ) ; <nl> + popC ( env ) ; <nl> } <nl> void in ( ISS & env , const bc : : PopU & ) { effect_free ( env ) ; popU ( env ) ; } <nl> void in ( ISS & env , const bc : : PopV & ) { nothrow ( env ) ; popV ( env ) ; } <nl> folly : : Optional < std : : pair < Type , LocalId > > moveToLocImpl ( ISS & env , <nl> } else if ( equivLoc = = NoLocalId ) { <nl> equivLoc = op . loc1 ; <nl> } <nl> - if ( any ( env . collect . opts & CollectionOpts : : Inlining ) & & <nl> - ! could_run_destructor ( peekLocRaw ( env , op . loc1 ) ) ) { <nl> + if ( any ( env . collect . opts & CollectionOpts : : Inlining ) ) { <nl> effect_free ( env ) ; <nl> } <nl> } else { <nl> mmm a / hphp / hhbbc / main . cpp <nl> ppp b / hphp / hhbbc / main . cpp <nl> std : : pair < std : : vector < std : : unique_ptr < UnitEmitter > > , <nl> RuntimeOption : : EvalHackArrCompatCheckArrayPlus = <nl> RuntimeOption : : EvalHackArrCompatCheckArrayKeyCast = <nl> gd . HackArrCompatNotices ; <nl> - RuntimeOption : : EvalAllowObjectDestructors = gd . AllowObjectDestructors ; <nl> RuntimeOption : : EvalForbidDynamicCalls = gd . ForbidDynamicCalls ; <nl> RuntimeOption : : EvalNoticeOnBuiltinDynamicCalls = <nl> gd . NoticeOnBuiltinDynamicCalls ; <nl> void write_global_data ( <nl> gd . EnableIntrinsicsExtension = RuntimeOption : : EnableIntrinsicsExtension ; <nl> gd . APCProfile = std : : move ( apcProfile ) ; <nl> gd . ReffinessInvariance = RuntimeOption : : EvalReffinessInvariance ; <nl> - gd . AllowObjectDestructors = RuntimeOption : : EvalAllowObjectDestructors ; <nl> gd . ForbidDynamicCalls = RuntimeOption : : EvalForbidDynamicCalls ; <nl> gd . AbortBuildOnVerifyError = RuntimeOption : : EvalAbortBuildOnVerifyError ; <nl> gd . UndefinedConstFallback = RuntimeOption : : UndefinedConstFallback ; <nl> mmm a / hphp / hhbbc / type - system . cpp <nl> ppp b / hphp / hhbbc / type - system . cpp <nl> bool could_contain_objects ( const Type & t ) { <nl> not_reached ( ) ; <nl> } <nl> <nl> - bool could_run_destructor ( const Type & t ) { <nl> - if ( ! RuntimeOption : : EvalAllowObjectDestructors ) return false ; <nl> - return could_contain_objects ( t ) ; <nl> - } <nl> - <nl> bool could_copy_on_write ( const Type & t ) { <nl> return t . m_bits & ( BCStr | BCArrN | BCVecN | BCDictN | BCKeysetN ) ; <nl> } <nl> mmm a / hphp / hhbbc / type - system . h <nl> ppp b / hphp / hhbbc / type - system . h <nl> IterTypes iter_types ( const Type & ) ; <nl> * / <nl> RepoAuthType make_repo_type ( ArrayTypeTable : : Builder & , const Type & t ) ; <nl> <nl> - / * <nl> - * True iff t could be an object or a type which contains objects and <nl> - * Eval . AllowObjectDestructors is enbaled . <nl> - * / <nl> - bool could_run_destructor ( const Type & t ) ; <nl> - <nl> / * <nl> * Returns true iff an IsType testing for testTy on valTy might raise . <nl> * / <nl> mmm a / hphp / hhvm / process - init . cpp <nl> ppp b / hphp / hhvm / process - init . cpp <nl> const StaticString s_ParseError ( " ParseError " ) ; <nl> const StaticString s_TypeError ( " TypeError " ) ; <nl> } <nl> <nl> - void tweak_variant_dtors ( ) ; <nl> void ProcessInit ( ) { <nl> / / Save the current options , and set things up so that <nl> / / systemlib . php can be read from and stored in the <nl> void ProcessInit ( ) { <nl> RuntimeOption : : EvalDumpBytecode = db ; <nl> RuntimeOption : : EvalAllowHhas = ah ; <nl> Option : : WholeProgram = wp ; <nl> - <nl> - tweak_variant_dtors ( ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / hphp / runtime / base / execution - context . cpp <nl> ppp b / hphp / runtime / base / execution - context . cpp <nl> void ExecutionContext : : sweep ( ) { <nl> } <nl> <nl> ExecutionContext : : ~ ExecutionContext ( ) { <nl> - / / When we destroy the execution context will call destructors on any objects <nl> - / / in the userErrorHandlers and userExceptionHandlers vectors . If these <nl> - / / destructors call restore_ * _handler ( ) they can trigger a pop_back ( ) on the <nl> - / / vector resulting in double destruction . There ' s no reason for code to do <nl> - / / this but we should still avoid crashing . <nl> - / / N . B . : This is already taken care of for us if EnableObjDestructCall is on <nl> - if ( ! RuntimeOption : : EnableObjDestructCall ) { <nl> - while ( ! m_userErrorHandlers . empty ( ) ) m_userErrorHandlers . pop_back ( ) ; <nl> - while ( ! m_userExceptionHandlers . empty ( ) ) m_userExceptionHandlers . pop_back ( ) ; <nl> - } <nl> cleanup ( ) ; <nl> } <nl> <nl> void ExecutionContext : : manageAPCHandle ( ) { <nl> } <nl> } <nl> <nl> - void ExecutionContext : : destructObjects ( ) { <nl> - if ( UNLIKELY ( RuntimeOption : : EnableObjDestructCall ) ) { <nl> - while ( ! m_liveBCObjs . empty ( ) ) { <nl> - ObjectData * obj = * m_liveBCObjs . begin ( ) ; <nl> - obj - > destructForExit ( ) ; / / Let the instance remove the node . <nl> - } <nl> - m_liveBCObjs . clear ( ) ; <nl> - } <nl> - } <nl> - <nl> / / Evaled units have a footprint in the TC and translation metadata . The <nl> / / applications we care about tend to have few , short , stereotyped evals , <nl> / / where the same code keeps getting eval ' ed over and over again ; so we <nl> mmm a / hphp / runtime / base / execution - context . h <nl> ppp b / hphp / runtime / base / execution - context . h <nl> struct ExecutionContext { <nl> <nl> void enterDebuggerDummyEnv ( ) ; <nl> void exitDebuggerDummyEnv ( ) ; <nl> - void destructObjects ( ) ; <nl> void debuggerExecutePsps ( ) ; <nl> <nl> bool isNested ( ) { return m_nesting ! = 0 ; } <nl> struct ExecutionContext { <nl> const VirtualHost * m_vhost ; <nl> public : <nl> DebuggerSettings debuggerSettings ; <nl> - req : : vector_set < ObjectData * > m_liveBCObjs ; / / objects with destructors <nl> private : <nl> size_t m_apcMemSize { 0 } ; <nl> std : : vector < APCHandle * > m_apcHandles ; / / gets moved to treadmill <nl> mmm a / hphp / runtime / base / object - data - inl . h <nl> ppp b / hphp / runtime / base / object - data - inl . h <nl> inline void ObjectData : : resetMaxId ( ) { <nl> inline ObjectData : : ObjectData ( Class * cls , uint8_t flags , HeaderKind kind ) <nl> : m_cls ( cls ) <nl> { <nl> - flags | = cls - > getDtor ( ) ? 0 : ObjectData : : NoDestructor ; <nl> initHeader_16 ( kind , OneReference , flags ) ; <nl> assertx ( isObjectKind ( m_kind ) ) ; <nl> assertx ( ! cls - > needInitialization ( ) | | cls - > initialized ( ) ) ; <nl> inline ObjectData : : ObjectData ( Class * cls , InitRaw , uint8_t flags , <nl> initHeader_16 ( kind , OneReference , flags ) ; <nl> assertx ( isObjectKind ( m_kind ) ) ; <nl> assertx ( ! cls - > needInitialization ( ) | | cls - > initialized ( ) ) ; <nl> - assertx ( ( flags & ObjectData : : NoDestructor ) | | cls - > getDtor ( ) ) ; <nl> o_id = + + os_max_id ; <nl> } <nl> <nl> inline ObjectData * ObjectData : : newInstanceNoPropInit ( Class * cls ) { <nl> objOff - sizeof ( MemoNode ) <nl> ) ; <nl> obj = new ( NotNull { } , reinterpret_cast < char * > ( mem ) + objOff ) <nl> - ObjectData ( cls , InitRaw { } , cls - > getDtor ( ) ? 0 : ObjectData : : NoDestructor ) ; <nl> + ObjectData ( cls , InitRaw { } , ObjectData : : NoAttrs ) ; <nl> } else { <nl> obj = new ( NotNull { } , tl_heap - > objMalloc ( size ) ) <nl> - ObjectData ( cls , InitRaw { } , cls - > getDtor ( ) ? 0 : ObjectData : : NoDestructor ) ; <nl> + ObjectData ( cls , InitRaw { } , ObjectData : : NoAttrs ) ; <nl> } <nl> assertx ( obj - > hasExactlyOneRef ( ) ) ; <nl> return obj ; <nl> inline void ObjectData : : setAttribute ( Attribute attr ) { <nl> m_aux16 | = attr ; <nl> } <nl> <nl> - inline bool ObjectData : : noDestruct ( ) const { <nl> - return getAttribute ( NoDestructor ) ; <nl> - } <nl> - <nl> - inline void ObjectData : : setNoDestruct ( ) { <nl> - setAttribute ( NoDestructor ) ; <nl> - } <nl> - <nl> - inline void ObjectData : : clearNoDestruct ( ) { <nl> - m_aux16 & = ~ NoDestructor ; <nl> - } <nl> - <nl> inline bool ObjectData : : hasInstanceDtor ( ) const { <nl> return HPHP : : hasInstanceDtor ( m_kind ) ; <nl> } <nl> mmm a / hphp / runtime / base / object - data . cpp <nl> ppp b / hphp / runtime / base / object - data . cpp <nl> bool ObjectData : : assertTypeHint ( tv_rval prop , Slot propIdx ) const { <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - NEVER_INLINE bool ObjectData : : destructImpl ( ) { <nl> - setNoDestruct ( ) ; <nl> - auto const dtor = m_cls - > getDtor ( ) ; <nl> - if ( ! dtor ) return true ; <nl> - <nl> - / / We don ' t run PHP destructors while we ' re unwinding for a C + + <nl> - / / exception . We want to minimize the PHP code we run while propagating <nl> - / / fatals , so we do this check here on a very common path , in the <nl> - / / relatively slower case . <nl> - if ( g_context - > m_unwindingCppException ) return true ; <nl> - <nl> - / / Some decref paths call release ( ) when - - count = = 0 and some call it when <nl> - / / count = = 1 . This difference only matters for objects that resurrect <nl> - / / themselves in their destructors , so make sure count is consistent here . <nl> - assertx ( m_count = = 0 | | m_count = = 1 ) ; <nl> - m_count = static_cast < RefCount > ( 0 ) ; <nl> - <nl> - / / We raise the refcount around the call to __destruct ( ) . This is to prevent <nl> - / / the refcount from going to zero when the destructor returns . <nl> - CountableHelper h ( this ) ; <nl> - invoke_destructor ( this , dtor ) ; <nl> - return hasExactlyOneRef ( ) ; <nl> - } <nl> - <nl> - void ObjectData : : destructForExit ( ) { <nl> - assertx ( RuntimeOption : : EnableObjDestructCall ) ; <nl> - auto const dtor = m_cls - > getDtor ( ) ; <nl> - if ( dtor ) { <nl> - g_context - > m_liveBCObjs . erase ( this ) ; <nl> - } <nl> - <nl> - if ( noDestruct ( ) ) return ; <nl> - setNoDestruct ( ) ; <nl> - <nl> - / / We ' re exiting , so there should not be any live faults . <nl> - assertx ( g_context - > m_faults . empty ( ) ) ; <nl> - assertx ( ! g_context - > m_unwindingCppException ) ; <nl> - <nl> - CountableHelper h ( this ) ; <nl> - invoke_destructor ( this , dtor ) ; <nl> - } <nl> - <nl> NEVER_INLINE <nl> static void freeDynPropArray ( ObjectData * inst ) { <nl> auto & table = g_context - > dynPropTable ; <nl> inline bool ObjectData : : slowDestroyCheck ( ) const { <nl> } <nl> <nl> NEVER_INLINE <nl> - void ObjectData : : releaseNoObjDestructCheck ( ) noexcept { <nl> + void ObjectData : : release ( ) noexcept { <nl> assertx ( kindIsValid ( ) ) ; <nl> <nl> - / / Destructors are unsupported in one - bit reference counting mode . <nl> - if ( ! one_bit_refcount & & UNLIKELY ( ! getAttribute ( NoDestructor ) ) ) { <nl> - if ( UNLIKELY ( ! destructImpl ( ) ) ) return ; <nl> - } <nl> - <nl> auto const cls = getVMClass ( ) ; <nl> <nl> / / Note : Don ' t put any cleanup code above this hasInstanceDtor short - circuit <nl> void ObjectData : : releaseNoObjDestructCheck ( ) noexcept { <nl> AARCH64_WALKABLE_FRAME ( ) ; <nl> } <nl> <nl> - NEVER_INLINE <nl> - static void tail_call_remove_live_bc_obj ( ObjectData * obj ) { <nl> - g_context - > m_liveBCObjs . erase ( obj ) ; <nl> - return obj - > releaseNoObjDestructCheck ( ) ; <nl> - } <nl> - <nl> - void ObjectData : : release ( ) noexcept { <nl> - assertx ( kindIsValid ( ) ) ; <nl> - if ( UNLIKELY ( RuntimeOption : : EnableObjDestructCall & & m_cls - > getDtor ( ) ) ) { <nl> - tail_call_remove_live_bc_obj ( this ) ; <nl> - AARCH64_WALKABLE_FRAME ( ) ; <nl> - return ; <nl> - } <nl> - releaseNoObjDestructCheck ( ) ; <nl> - AARCH64_WALKABLE_FRAME ( ) ; <nl> - } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / class info <nl> <nl> ObjectData * ObjectData : : clone ( ) { <nl> 0 , <nl> objOff - sizeof ( MemoNode ) <nl> ) ; <nl> - auto const flags = m_cls - > getDtor ( ) ? 0 : ObjectData : : NoDestructor ; <nl> auto const obj = new ( NotNull { } , reinterpret_cast < char * > ( mem ) + objOff ) <nl> - ObjectData ( m_cls , InitRaw { } , flags ) ; <nl> + ObjectData ( m_cls , InitRaw { } , ObjectData : : NoAttrs ) ; <nl> clone = Object : : attach ( obj ) ; <nl> assertx ( clone - > hasExactlyOneRef ( ) ) ; <nl> assertx ( ! clone - > hasInstanceDtor ( ) ) ; <nl> } else { <nl> auto const size = sizeForNProps ( nProps ) ; <nl> - auto const flags = m_cls - > getDtor ( ) ? 0 : ObjectData : : NoDestructor ; <nl> auto const obj = new ( NotNull { } , tl_heap - > objMalloc ( size ) ) <nl> - ObjectData ( m_cls , InitRaw { } , flags ) ; <nl> + ObjectData ( m_cls , InitRaw { } , ObjectData : : NoAttrs ) ; <nl> clone = Object : : attach ( obj ) ; <nl> assertx ( clone - > hasExactlyOneRef ( ) ) ; <nl> assertx ( ! clone - > hasInstanceDtor ( ) ) ; <nl> void deepInitHelper ( TypedValue * propVec , const TypedValueAux * propData , <nl> / / called from jit code <nl> ObjectData * ObjectData : : newInstanceRawSmall ( Class * cls , size_t size , <nl> size_t index ) { <nl> - assertx ( ! cls - > getDtor ( ) ) ; <nl> assertx ( size < = kMaxSmallSize ) ; <nl> assertx ( ! cls - > hasMemoSlots ( ) ) ; <nl> auto mem = tl_heap - > mallocSmallIndexSize ( index , size ) ; <nl> ObjectData * ObjectData : : newInstanceRawSmall ( Class * cls , size_t size , <nl> } <nl> <nl> ObjectData * ObjectData : : newInstanceRawBig ( Class * cls , size_t size ) { <nl> - assertx ( ! cls - > getDtor ( ) ) ; <nl> assertx ( ! cls - > hasMemoSlots ( ) ) ; <nl> auto mem = tl_heap - > mallocBigSize ( size ) ; <nl> return new ( NotNull { } , mem ) ObjectData ( cls , InitRaw { } , DefaultAttrs ) ; <nl> } <nl> <nl> / / called from jit code <nl> - ObjectData * ObjectData : : newInstanceRawAttrsSmall ( Class * cls , size_t size , <nl> - size_t index , <nl> - uint8_t attrs ) { <nl> - assertx ( size < = kMaxSmallSize ) ; <nl> - assertx ( ! cls - > hasMemoSlots ( ) ) ; <nl> - auto mem = tl_heap - > mallocSmallIndexSize ( index , size ) ; <nl> - return new ( NotNull { } , mem ) ObjectData ( cls , InitRaw { } , attrs ) ; <nl> - } <nl> - <nl> - ObjectData * ObjectData : : newInstanceRawAttrsBig ( Class * cls , size_t size , <nl> - uint8_t attrs ) { <nl> - assertx ( ! cls - > hasMemoSlots ( ) ) ; <nl> - auto mem = tl_heap - > mallocBigSize ( size ) ; <nl> - return new ( NotNull { } , mem ) ObjectData ( cls , InitRaw { } , attrs ) ; <nl> - } <nl> - <nl> ObjectData * ObjectData : : newInstanceRawMemoSmall ( Class * cls , <nl> size_t size , <nl> size_t index , <nl> size_t objoff ) { <nl> - assertx ( ! cls - > getDtor ( ) ) ; <nl> assertx ( size < = kMaxSmallSize ) ; <nl> assertx ( cls - > hasMemoSlots ( ) ) ; <nl> assertx ( ! cls - > getNativeDataInfo ( ) ) ; <nl> ObjectData * ObjectData : : newInstanceRawMemoSmall ( Class * cls , <nl> ObjectData * ObjectData : : newInstanceRawMemoBig ( Class * cls , <nl> size_t size , <nl> size_t objoff ) { <nl> - assertx ( ! cls - > getDtor ( ) ) ; <nl> assertx ( cls - > hasMemoSlots ( ) ) ; <nl> assertx ( ! cls - > getNativeDataInfo ( ) ) ; <nl> assertx ( objoff = = ObjectData : : objOffFromMemoNode ( cls ) ) ; <nl> ObjectData * ObjectData : : newInstanceRawMemoBig ( Class * cls , <nl> ObjectData ( cls , InitRaw { } , DefaultAttrs ) ; <nl> } <nl> <nl> - ObjectData * ObjectData : : newInstanceRawMemoAttrsSmall ( Class * cls , <nl> - size_t size , <nl> - size_t index , <nl> - size_t objoff , <nl> - uint8_t attrs ) { <nl> - assertx ( size < = kMaxSmallSize ) ; <nl> - assertx ( cls - > hasMemoSlots ( ) ) ; <nl> - assertx ( ! cls - > getNativeDataInfo ( ) ) ; <nl> - assertx ( objoff = = ObjectData : : objOffFromMemoNode ( cls ) ) ; <nl> - auto mem = tl_heap - > mallocSmallIndexSize ( index , size ) ; <nl> - new ( NotNull { } , mem ) MemoNode ( objoff ) ; <nl> - return new ( NotNull { } , reinterpret_cast < char * > ( mem ) + objoff ) <nl> - ObjectData ( cls , InitRaw { } , attrs ) ; <nl> - } <nl> - <nl> - ObjectData * ObjectData : : newInstanceRawMemoAttrsBig ( Class * cls , <nl> - size_t size , <nl> - size_t objoff , <nl> - uint8_t attrs ) { <nl> - assertx ( cls - > hasMemoSlots ( ) ) ; <nl> - assertx ( ! cls - > getNativeDataInfo ( ) ) ; <nl> - assertx ( objoff = = ObjectData : : objOffFromMemoNode ( cls ) ) ; <nl> - auto mem = tl_heap - > mallocBigSize ( size ) ; <nl> - new ( NotNull { } , mem ) MemoNode ( objoff ) ; <nl> - return new ( NotNull { } , reinterpret_cast < char * > ( mem ) + objoff ) <nl> - ObjectData ( cls , InitRaw { } , attrs ) ; <nl> - } <nl> - <nl> / / Note : the normal object destruction path does not actually call this <nl> / / destructor . See ObjectData : : release . <nl> ObjectData : : ~ ObjectData ( ) { <nl> mmm a / hphp / runtime / base / object - data . h <nl> ppp b / hphp / runtime / base / object - data . h <nl> struct InvokeResult { <nl> extern DECLARE_RDS_LOCAL_HOTVALUE ( uint32_t , os_max_id ) ; <nl> struct ObjectData : Countable , type_scan : : MarkCollectable < ObjectData > { <nl> enum Attribute : uint8_t { <nl> - NoDestructor = 0x01 , / / __destruct ( ) <nl> + NoAttrs = 0x00 , <nl> IsWeakRefed = 0x02 , / / Is pointed to by at least one WeakRef <nl> HasDynPropArr = 0x04 , / / has a dynamic properties array <nl> IsBeingConstructed = 0x08 , / / Constructor for most derived class has not <nl> struct ObjectData : Countable , type_scan : : MarkCollectable < ObjectData > { <nl> * uninitialized object of that class . These are meant to be called from the <nl> * JIT , where the cls , size , and attributes are constants at JIT time . <nl> * <nl> - * newInstanceRaw < > should be called only when ! cls - > getDtor ( ) ; otherwise , <nl> - * use newInstanceRawAttrs . The big = true versions should be called when <nl> - * size > kMaxSmallSize . <nl> + * The big = true versions should be called when size > kMaxSmallSize . <nl> * <nl> * The memo versions should be used if the object has memo slots . <nl> * <nl> * The initial ref - count will be set to one . <nl> * / <nl> - static const uint8_t DefaultAttrs = NoDestructor ; <nl> + static const uint8_t DefaultAttrs = NoAttrs ; <nl> <nl> static ObjectData * newInstanceRawSmall ( Class * , size_t size , size_t index ) ; <nl> static ObjectData * newInstanceRawBig ( Class * , size_t size ) ; <nl> - static ObjectData * newInstanceRawAttrsSmall ( Class * , size_t size , size_t index , <nl> - uint8_t attrs ) ; <nl> - static ObjectData * newInstanceRawAttrsBig ( Class * , size_t size , <nl> - uint8_t attrs ) ; <nl> <nl> static ObjectData * newInstanceRawMemoSmall ( Class * , size_t size , <nl> size_t index , size_t objoff ) ; <nl> static ObjectData * newInstanceRawMemoBig ( Class * , size_t size , size_t objoff ) ; <nl> - static ObjectData * newInstanceRawMemoAttrsSmall ( Class * , size_t size , <nl> - size_t index , size_t objoff , <nl> - uint8_t attrs ) ; <nl> - static ObjectData * newInstanceRawMemoAttrsBig ( Class * , size_t size , <nl> - size_t objoff , uint8_t attrs ) ; <nl> <nl> void release ( ) noexcept ; <nl> - void releaseNoObjDestructCheck ( ) noexcept ; <nl> <nl> Class * getVMClass ( ) const ; <nl> void setVMClass ( Class * cls ) ; <nl> struct ObjectData : Countable , type_scan : : MarkCollectable < ObjectData > { <nl> void setAttribute ( Attribute ) ; <nl> bool hasInstanceDtor ( ) const ; <nl> bool hasNativeData ( ) const ; <nl> - bool noDestruct ( ) const ; <nl> - void setNoDestruct ( ) ; <nl> - void clearNoDestruct ( ) ; <nl> <nl> Object iterableObject ( bool & isIterable , bool mayImplementIterator = true ) ; <nl> <nl> struct ObjectData : Countable , type_scan : : MarkCollectable < ObjectData > { <nl> bool moreEqual ( const ObjectData & ) const ; <nl> int64_t compare ( const ObjectData & ) const ; <nl> <nl> - / * <nl> - * Call this object ' s destructor , if it has one . No restrictions are placed <nl> - * on the object ' s refcount , since this is used on objects still alive at <nl> - * request shutdown . <nl> - * / <nl> - void destructForExit ( ) ; <nl> - <nl> private : <nl> void instanceInit ( Class * ) ; <nl> - bool destructImpl ( ) ; <nl> <nl> public : <nl> <nl> struct ObjectData : Countable , type_scan : : MarkCollectable < ObjectData > { <nl> # pragma pack ( pop ) <nl> # endif <nl> <nl> - struct CountableHelper { <nl> - explicit CountableHelper ( ObjectData * object ) : m_object ( object ) { <nl> - object - > incRefCount ( ) ; <nl> - } <nl> - ~ CountableHelper ( ) { <nl> - m_object - > decRefCount ( ) ; <nl> - } <nl> - <nl> - CountableHelper ( const CountableHelper & ) = delete ; <nl> - CountableHelper & operator = ( const CountableHelper & ) = delete ; <nl> - <nl> - private : <nl> - ObjectData * m_object ; <nl> - } ; <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> ALWAYS_INLINE void decRefObj ( ObjectData * obj ) { <nl> mmm a / hphp / runtime / base / program - functions . cpp <nl> ppp b / hphp / runtime / base / program - functions . cpp <nl> void hphp_context_shutdown ( ) { <nl> g_thread_safe_locale_handler - > reset ( ) ; <nl> <nl> auto const context = g_context . getNoCheck ( ) ; <nl> - context - > destructObjects ( ) ; <nl> context - > onRequestShutdown ( ) ; <nl> <nl> try { <nl> mmm a / hphp / runtime / base / runtime - option . cpp <nl> ppp b / hphp / runtime / base / runtime - option . cpp <nl> bool RuntimeOption : : EnableHipHopSyntax = false ; <nl> bool RuntimeOption : : EnableShortTags = true ; <nl> bool RuntimeOption : : EnablePHP = true ; <nl> bool RuntimeOption : : EnableXHP = false ; <nl> - bool RuntimeOption : : EnableObjDestructCall = true ; <nl> bool RuntimeOption : : EnableIntrinsicsExtension = false ; <nl> bool RuntimeOption : : CheckSymLink = true ; <nl> bool RuntimeOption : : EnableArgsInBacktraces = true ; <nl> void RuntimeOption : : Load ( <nl> EnableXHP = true ; <nl> } <nl> <nl> - Config : : Bind ( EnableObjDestructCall , ini , config , <nl> - " Eval . EnableObjDestructCall " , true ) ; <nl> Config : : Bind ( CheckSymLink , ini , config , " Eval . CheckSymLink " , true ) ; <nl> <nl> # define F ( type , name , defaultVal ) \ <nl> mmm a / hphp / runtime / base / runtime - option . h <nl> ppp b / hphp / runtime / base / runtime - option . h <nl> struct RuntimeOption { <nl> return EvalJit & & EvalJitSampleRate > 0 ; <nl> } <nl> <nl> - static bool AllowObjectDestructors ( ) { <nl> - / / When one_bit_refcount = = true , skip the runtime check since destructors <nl> - / / are never allowed . <nl> - return ! one_bit_refcount & & EvalAllowObjectDestructors ; <nl> - } <nl> - <nl> static void ReadSatelliteInfo ( <nl> const IniSettingMap & ini , <nl> const Hdf & hdf , <nl> struct RuntimeOption { <nl> static bool EnableXHP ; <nl> static bool EnablePHP ; <nl> static bool CheckParamTypeInvariance ; <nl> - static bool EnableObjDestructCall ; <nl> static bool EnableIntrinsicsExtension ; <nl> static bool CheckSymLink ; <nl> static bool EnableArgsInBacktraces ; <nl> struct RuntimeOption { <nl> * / \ <nl> F ( bool , HardTypeHints , RepoAuthoritative ) \ <nl> F ( bool , PromoteEmptyObject , ! EnableHipHopSyntax ) \ <nl> - F ( bool , AllowObjectDestructors , ! one_bit_refcount ) \ <nl> F ( bool , LibXMLUseSafeSubtrees , true ) \ <nl> F ( bool , AllDestructorsOptional , false ) \ <nl> F ( bool , AllowScopeBinding , false ) \ <nl> mmm a / hphp / runtime / base / type - variant . cpp <nl> ppp b / hphp / runtime / base / type - variant . cpp <nl> RawDestructor g_destructors [ ] = { <nl> ( RawDestructor ) getMethodPtr ( & RefData : : release ) , / / KindOfRef <nl> } ; <nl> <nl> - void tweak_variant_dtors ( ) { <nl> - if ( RuntimeOption : : EnableObjDestructCall ) return ; <nl> - destructorForType ( KindOfObject ) = <nl> - ( RawDestructor ) getMethodPtr ( & ObjectData : : releaseNoObjDestructCheck ) ; <nl> - } <nl> - <nl> # define IMPLEMENT_SET ( argType , setOp ) \ <nl> void Variant : : set ( argType v ) noexcept { \ <nl> if ( isPrimitive ( ) ) { \ <nl> mmm a / hphp / runtime / base / unit - cache . cpp <nl> ppp b / hphp / runtime / base / unit - cache . cpp <nl> std : : string mangleUnitMd5 ( const std : : string & fileMd5 , const RepoOptions & opts ) { <nl> + ( RuntimeOption : : EvalHackArrDVArrs ? ' 1 ' : ' 0 ' ) <nl> + ( RuntimeOption : : EvalEnableIntishCast ? ' 1 ' : ' 0 ' ) <nl> + ( RuntimeOption : : EvalDisableHphpcOpts ? ' 1 ' : ' 0 ' ) <nl> - + ( RuntimeOption : : EvalAllowObjectDestructors ? ' 1 ' : ' 0 ' ) <nl> + ( RuntimeOption : : EvalAssemblerFoldDefaultValues ? ' 1 ' : ' 0 ' ) <nl> + RuntimeOption : : EvalHackCompilerCommand + ' \ 0 ' <nl> + RuntimeOption : : EvalHackCompilerArgs + ' \ 0 ' <nl> mmm a / hphp / runtime / base / variable - unserializer . cpp <nl> ppp b / hphp / runtime / base / variable - unserializer . cpp <nl> void VariableUnserializer : : unserializeVariant ( <nl> / / it . Otherwise , we risk creating a CPP object without having it <nl> / / initialized completely . <nl> if ( cls - > instanceCtor ( ) & & ! cls - > isCppSerializable ( ) & & <nl> - ! cls - > isCollectionClass ( ) & & ! cls - > hasDisabledCtor ( ) ) { <nl> + ! cls - > isCollectionClass ( ) ) { <nl> assertx ( obj . isNull ( ) ) ; <nl> throw_null_pointer_exception ( ) ; <nl> } else { <nl> void VariableUnserializer : : unserializeVariant ( <nl> obj - > getClassName ( ) . data ( ) ) ; <nl> } else { <nl> obj - > o_invoke_few_args ( s_unserialize , 1 , serialized ) ; <nl> - obj . get ( ) - > clearNoDestruct ( ) ; <nl> } <nl> <nl> tvMove ( make_tv < KindOfObject > ( obj . detach ( ) ) , self ) ; <nl> mmm a / hphp / runtime / ext / asio / ext_async - function - wait - handle . cpp <nl> ppp b / hphp / runtime / ext / asio / ext_async - function - wait - handle . cpp <nl> c_AsyncFunctionWaitHandle : : Create ( const ActRec * fp , <nl> auto const waitHandle = new ( resumable + 1 ) c_AsyncFunctionWaitHandle ( ) ; <nl> assertx ( waitHandle - > hasExactlyOneRef ( ) ) ; <nl> waitHandle - > actRec ( ) - > setReturnVMExit ( ) ; <nl> - assertx ( waitHandle - > noDestruct ( ) ) ; <nl> waitHandle - > initialize ( child ) ; <nl> return waitHandle ; <nl> } <nl> mmm a / hphp / runtime / ext / asio / ext_wait - handle . h <nl> ppp b / hphp / runtime / ext / asio / ext_wait - handle . h <nl> struct c_Awaitable : ObjectData { <nl> <nl> explicit c_Awaitable ( Class * cls , HeaderKind kind , <nl> type_scan : : Index tyindex ) noexcept <nl> - : ObjectData ( cls , NoInit { } , ObjectData : : NoDestructor , kind ) , <nl> + : ObjectData ( cls , NoInit { } , ObjectData : : NoAttrs , kind ) , <nl> m_tyindex ( tyindex ) <nl> { <nl> assertx ( type_scan : : isKnownType ( tyindex ) ) ; <nl> mmm a / hphp / runtime / ext / collections / ext_collections . h <nl> ppp b / hphp / runtime / ext / collections / ext_collections . h <nl> extern const StaticString <nl> return req : : make < c_ # # name > ( ) . detach ( ) ; \ <nl> } <nl> <nl> - constexpr ObjectData : : Attribute objectFlags = ObjectData : : NoDestructor ; <nl> + constexpr ObjectData : : Attribute objectFlags = ObjectData : : NoAttrs ; <nl> <nl> / * * <nl> * The " materialization " methods have the form " to [ CollectionName ] ( ) " and <nl> mmm a / hphp / runtime / ext / fileinfo / ext_fileinfo . php <nl> ppp b / hphp / runtime / ext / fileinfo / ext_fileinfo . php <nl> public function __construct ( int $ options = FILEINFO_NONE , <nl> $ this - > magic_file = $ magic_file ; <nl> } <nl> <nl> - < < __OptionalDestruct > > <nl> - public function __destruct ( ) { <nl> - } <nl> - <nl> public function __sleep ( ) { <nl> return array ( ' options ' , ' magic_file ' ) ; <nl> } <nl> mmm a / hphp / runtime / ext / generator / ext_generator . h <nl> ppp b / hphp / runtime / ext / generator / ext_generator . h <nl> struct BaseGenerator { <nl> auto const obj = new ( objmem ) ObjectData ( cls , 0 , HeaderKind : : NativeObject ) ; <nl> assertx ( ( void * ) obj = = ( void * ) objmem ) ; <nl> assertx ( obj - > hasExactlyOneRef ( ) ) ; <nl> - assertx ( obj - > noDestruct ( ) ) ; <nl> return obj ; <nl> } <nl> <nl> mmm a / hphp / runtime / ext / icu / ext_icu_uconverter . cpp <nl> ppp b / hphp / runtime / ext / icu / ext_icu_uconverter . cpp <nl> static void HHVM_METHOD ( UConverter , __construct , const String & toEncoding , <nl> } <nl> } <nl> <nl> - / / TODO ( 4017519 ) <nl> - static void HHVM_METHOD ( UConverter , __destruct ) { <nl> + static void HHVM_METHOD ( UConverter , __dispose ) { <nl> FETCH_CNV ( data , this_ , ) ; <nl> if ( data - > src ( ) ) ucnv_close ( data - > src ( ) ) ; <nl> if ( data - > dest ( ) ) ucnv_close ( data - > dest ( ) ) ; <nl> static Variant HHVM_STATIC_METHOD ( UConverter , getStandardName , <nl> <nl> void IntlExtension : : initUConverter ( ) { <nl> HHVM_ME ( UConverter , __construct ) ; <nl> - / / TODO ( 4017519 ) <nl> - HHVM_ME ( UConverter , __destruct ) ; <nl> + HHVM_ME ( UConverter , __dispose ) ; <nl> HHVM_ME ( UConverter , convert ) ; <nl> HHVM_ME ( UConverter , getDestinationEncoding ) ; <nl> HHVM_ME ( UConverter , getSourceEncoding ) ; <nl> mmm a / hphp / runtime / ext / icu / ext_icu_uconverter . php <nl> ppp b / hphp / runtime / ext / icu / ext_icu_uconverter . php <nl> <nl> < ? hh <nl> <nl> < < __NativeData ( " UConverter " ) > > <nl> - class UConverter { <nl> + class UConverter implements IDisposable { <nl> / * * <nl> * Create UConverter object <nl> * <nl> public function __construct ( string $ destination_encoding = ' utf - 8 ' , <nl> / / TODO ( 4017519 ) PHP5 doesn ' t have this destructor , we have it to prevent a <nl> / / nasty issue with destructing IntlUConverter . <nl> < < __Native > > <nl> - public function __destruct ( ) : void ; <nl> + public function __dispose ( ) : void ; <nl> <nl> / * * <nl> * Convert string from one charset to another <nl> mmm a / hphp / runtime / ext / memcache / ext_memcache . php <nl> ppp b / hphp / runtime / ext / memcache / ext_memcache . php <nl> function addserver ( string $ host , <nl> bool $ status = true , <nl> mixed $ failure_callback = null , <nl> int $ timeoutms = 0 ) : bool ; <nl> - <nl> - < < __OptionalDestruct > > <nl> - function __destruct ( ) : void { <nl> - } <nl> } <nl> <nl> / * Memcache : : connect ( ) establishes a connection to the memcached server . The <nl> mmm a / hphp / runtime / ext / pdo / ext_pdo . cpp <nl> ppp b / hphp / runtime / ext / pdo / ext_pdo . cpp <nl> static bool do_fetch ( sp_PDOStatement stmt , <nl> ( flags & PDO_FETCH_PROPS_LATE ) ) { <nl> ret . asCObjRef ( ) - > o_invoke ( stmt - > fetch . constructor , <nl> stmt - > fetch . ctor_args . toArray ( ) ) ; <nl> - ret . asCObjRef ( ) - > clearNoDestruct ( ) ; <nl> } <nl> } <nl> break ; <nl> static bool do_fetch ( sp_PDOStatement stmt , <nl> ! ( flags & ( PDO_FETCH_PROPS_LATE | PDO_FETCH_SERIALIZE ) ) ) { <nl> ret . toObject ( ) - > o_invoke ( stmt - > fetch . constructor , <nl> stmt - > fetch . ctor_args . toArray ( ) ) ; <nl> - ret . toObject ( ) - > clearNoDestruct ( ) ; <nl> } <nl> if ( flags & PDO_FETCH_CLASSTYPE ) { <nl> stmt - > fetch . clsname = old_clsname ; <nl> mmm a / hphp / runtime / ext / reflection / ext_reflection_hni . php <nl> ppp b / hphp / runtime / ext / reflection / ext_reflection_hni . php <nl> public function __toString ( ) : string { <nl> if ( $ this - > isConstructor ( ) ) { <nl> $ preAttrs [ ] = ' ctor ' ; <nl> } <nl> - if ( $ this - > isDestructor ( ) ) { <nl> - $ preAttrs [ ] = ' dtor ' ; <nl> - } <nl> <nl> $ funcAttrs = [ ] ; <nl> if ( $ this - > isAbstract ( ) ) { <nl> public function isStatic ( ) : bool ; <nl> < < __Native > > <nl> public function isConstructor ( ) : bool ; <nl> <nl> - / * * <nl> - * ( excerpt from <nl> - * http : / / php . net / manual / en / reflectionmethod . isdestructor . php ) <nl> - * <nl> - * Checks if the method is a destructor . <nl> - * <nl> - * @ return bool TRUE if the method is a destructor , otherwise FALSE <nl> - * / <nl> - public function isDestructor ( ) : bool { <nl> - return $ this - > getName ( ) = = ' __destruct ' ; <nl> - } <nl> - <nl> / * * <nl> * ( excerpt from <nl> * http : / / php . net / manual / en / reflectionmethod . getmodifiers . php ) <nl> mmm a / hphp / runtime / ext / xhprof / ext_xhprof . php <nl> ppp b / hphp / runtime / ext / xhprof / ext_xhprof . php <nl> function xhprof_network_disable ( ) : mixed ; <nl> <nl> / * Starts an artificial frame . Together with xhprof_frame_end ( ) , this times <nl> * one block of code execution as if it were a function call , allowing people <nl> - * to define arbitrary function boundaries . Prefer to use XhprofFrame <nl> - * classobjects instead of calling this function directly . <nl> + * to define arbitrary function boundaries . <nl> * @ param string $ name - The " virtual " function ' s name . <nl> * / <nl> < < __HipHopSpecific , __Native ( " NoInjection " ) > > <nl> function xhprof_frame_begin ( string $ name ) : void ; <nl> * sure there are no exceptions in between these two calls , as otherwise , it <nl> * may report incorrect timings . Also , xhprof_frame_begin ( ) and <nl> * xhprof_frame_end ( ) have to be paired up really well , so not to interfere <nl> - * with regular function ' s profiling , unless that ' s the intention . Prefer to <nl> - * use XhprofFrame classobjects instead of calling this function directly . <nl> + * with regular function ' s profiling , unless that ' s the intention . <nl> * / <nl> < < __HipHopSpecific , __Native ( " NoInjection " ) > > <nl> function xhprof_frame_end ( ) : void ; <nl> mmm a / hphp / runtime / vm / class - inl . h <nl> ppp b / hphp / runtime / vm / class - inl . h <nl> inline const Func * Class : : getCtor ( ) const { <nl> return m_ctor ; <nl> } <nl> <nl> - inline const Func * Class : : getDtor ( ) const { <nl> - return m_dtor ; <nl> - } <nl> - <nl> inline const Func * Class : : getToString ( ) const { <nl> return m_toString ; <nl> } <nl> mmm a / hphp / runtime / vm / class . cpp <nl> ppp b / hphp / runtime / vm / class . cpp <nl> const StaticString s_86sinit ( " 86sinit " ) ; <nl> const StaticString s_86linit ( " 86linit " ) ; <nl> const StaticString s_86reified_prop ( " 86reified_prop " ) ; <nl> const StaticString s_86reifiedinit ( " 86reifiedinit " ) ; <nl> - const StaticString s___destruct ( " __destruct " ) ; <nl> const StaticString s___OptionalDestruct ( " __OptionalDestruct " ) ; <nl> const StaticString s___MockClass ( " __MockClass " ) ; <nl> const StaticString s___Reified ( " __Reified " ) ; <nl> struct assert_sizeof_class { <nl> / / If this static_assert fails , the compiler error will have the real value <nl> / / of sizeof_Class in it since it ' s in this struct ' s type . <nl> # ifndef NDEBUG <nl> - static_assert ( sz = = ( use_lowptr ? 268 : 312 ) , " Change this only on purpose " ) ; <nl> + static_assert ( sz = = ( use_lowptr ? 268 : 304 ) , " Change this only on purpose " ) ; <nl> # else <nl> - static_assert ( sz = = ( use_lowptr ? 260 : 304 ) , " Change this only on purpose " ) ; <nl> + static_assert ( sz = = ( use_lowptr ? 260 : 296 ) , " Change this only on purpose " ) ; <nl> # endif <nl> } ; <nl> template struct assert_sizeof_class < sizeof_Class > ; <nl> template struct assert_sizeof_class < sizeof_Class > ; <nl> * / <nl> ReadWriteMutex s_scope_cache_mutex ; <nl> <nl> - [ [ noreturn ] ] ObjectData * destructorFatalInstanceCtor ( Class * cls ) { <nl> - auto err = folly : : sformat ( <nl> - " Class { } has a __destruct ( ) method and cannot be instantiated when " , <nl> - cls - > name ( ) - > data ( ) <nl> - ) ; <nl> - <nl> - if ( one_bit_refcount ) { <nl> - err + = " one - bit reference counting is enabled " ; <nl> - } else { <nl> - err + = " Eval . DisallowObjectDestructors is set " ; <nl> - } <nl> - raise_error ( " % s " , err . c_str ( ) ) ; <nl> - } <nl> - <nl> - } <nl> - <nl> - bool Class : : hasDisabledCtor ( ) const { <nl> - return m_extra - > m_instanceCtor = = destructorFatalInstanceCtor ; <nl> } <nl> <nl> Class * Class : : newClass ( PreClass * preClass , Class * parent ) { <nl> static Func * findSpecialMethod ( Class * cls , const StringData * name ) { <nl> const StaticString <nl> s_toString ( " __toString " ) , <nl> s_construct ( " __construct " ) , <nl> - s_destruct ( " __destruct " ) , <nl> s_invoke ( " __invoke " ) , <nl> s_sleep ( " __sleep " ) , <nl> s_get ( " __get " ) , <nl> static Func * markNonStatic ( Func * meth ) { <nl> / / Do not use isStaticInPrologue here , since that uses the <nl> / / AttrRequiresThis flag . <nl> if ( meth & & ( ! meth - > isStatic ( ) | | meth - > isClosureBody ( ) | | <nl> - s_construct . equal ( meth - > name ( ) ) | | <nl> - s_destruct . equal ( meth - > name ( ) ) ) ) { <nl> + s_construct . equal ( meth - > name ( ) ) ) ) { <nl> meth - > setAttrs ( meth - > attrs ( ) | AttrRequiresThis ) ; <nl> } <nl> return meth ; <nl> static Func * markNonStatic ( const Class * thiz , const String & meth ) { <nl> <nl> void Class : : setSpecial ( ) { <nl> m_toString = markNonStatic ( this , s_toString ) ; <nl> - m_dtor = markNonStatic ( this , s_destruct ) ; <nl> <nl> / * <nl> * The invoke method is only cached in the Class for a fast path JIT <nl> void Class : : setNativeDataInfo ( ) { <nl> break ; <nl> } <nl> } <nl> - <nl> - / / If destructors aren ' t supported by the current configuration , this class <nl> - / / has one , and the destructor doesn ' t have the __OptionalDestruct attribute , <nl> - / / prevent instantiation of the class with an instanceCtor . <nl> - if ( ! RuntimeOption : : AllowObjectDestructors ( ) & & getDtor ( ) ) { <nl> - if ( getDtor ( ) - > userAttributes ( ) . count ( s___OptionalDestruct . get ( ) ) = = 0 & & <nl> - ! RuntimeOption : : EvalAllDestructorsOptional ) { <nl> - allocExtraData ( ) ; <nl> - m_extra . raw ( ) - > m_instanceCtor = destructorFatalInstanceCtor ; <nl> - } else { <nl> - m_dtor = nullptr ; <nl> - } <nl> - } <nl> } <nl> <nl> bool Class : : hasNativePropHandler ( ) const { <nl> mmm a / hphp / runtime / vm / class . h <nl> ppp b / hphp / runtime / vm / class . h <nl> struct Class : AtomicCountable { <nl> * / <nl> const Func * getCtor ( ) const ; <nl> const Func * getDeclaredCtor ( ) const ; <nl> - const Func * getDtor ( ) const ; <nl> const Func * getToString ( ) const ; <nl> const Func * get86pinit ( ) const ; <nl> const Func * get86sinit ( ) const ; <nl> struct Class : AtomicCountable { <nl> * / <nl> bool hasCall ( ) const ; <nl> <nl> - / * <nl> - * Has this class ' s constructor been replaced with one that always fatals , to <nl> - * prevent constructing instances of it ? <nl> - * / <nl> - bool hasDisabledCtor ( ) const ; <nl> - <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / Builtin classes . [ const ] <nl> struct Class : AtomicCountable { <nl> VMFixedVector < const Func * > m_sinitVec ; <nl> VMFixedVector < const Func * > m_linitVec ; <nl> LowPtr < Func > m_ctor ; <nl> - LowPtr < Func > m_dtor ; <nl> PropInitVec m_declPropInit ; <nl> VMFixedVector < const Func * > m_pinitVec ; <nl> <nl> mmm a / hphp / runtime / vm / func - inl . h <nl> ppp b / hphp / runtime / vm / func - inl . h <nl> inline bool Func : : isGenerated ( ) const { <nl> return shared ( ) - > m_isGenerated ; <nl> } <nl> <nl> - inline bool Func : : isDestructor ( ) const { <nl> - return ! strcmp ( m_name - > data ( ) , " __destruct " ) ; <nl> - } <nl> - <nl> inline bool Func : : isMagic ( ) const { <nl> return isMagicCallMethod ( ) | | isMagicCallStaticMethod ( ) ; <nl> } <nl> mmm a / hphp / runtime / vm / jit / dce . cpp <nl> ppp b / hphp / runtime / vm / jit / dce . cpp <nl> bool canDCE ( IRInstruction * inst ) { <nl> case AllocObj : <nl> case AllocObjReified : <nl> case NewClsMeth : <nl> - case RegisterLiveObj : <nl> case InitProps : <nl> case PropTypeRedefineCheck : <nl> case InitSProps : <nl> mmm a / hphp / runtime / vm / jit / ir - opcode . cpp <nl> ppp b / hphp / runtime / vm / jit / ir - opcode . cpp <nl> bool opcodeMayRaise ( Opcode opc ) { <nl> case ProfileType : <nl> case RBTraceEntry : <nl> case RBTraceMsg : <nl> - case RegisterLiveObj : <nl> case ReleaseVVAndSkip : <nl> case ReqBindJmp : <nl> case ReqRetranslate : <nl> mmm a / hphp / runtime / vm / jit / irgen - create . cpp <nl> ppp b / hphp / runtime / vm / jit / irgen - create . cpp <nl> SSATmp * allocObjFast ( IRGS & env , const Class * cls ) { <nl> initThrowable ( env , cls , obj ) ; <nl> } <nl> <nl> - if ( RuntimeOption : : EnableObjDestructCall & & cls - > getDtor ( ) ) { <nl> - gen ( env , RegisterLiveObj , obj ) ; <nl> - } <nl> - <nl> return obj ; <nl> } <nl> <nl> mmm a / hphp / runtime / vm / jit / irlower - object . cpp <nl> ppp b / hphp / runtime / vm / jit / irlower - object . cpp <nl> void cgNewInstanceRaw ( IRLS & env , const IRInstruction * inst ) { <nl> auto const index = MemoryManager : : size2Index ( size ) ; <nl> auto const size_class = MemoryManager : : sizeIndex2Size ( index ) ; <nl> <nl> - auto const attrs = cls - > getDtor ( ) ? 0 : ObjectData : : NoDestructor ; <nl> - <nl> auto const target = [ & ] { <nl> - if ( attrs ! = ObjectData : : DefaultAttrs ) { <nl> - if ( memoSize > 0 ) { <nl> - return size < = kMaxSmallSize <nl> - ? CallSpec : : direct ( & ObjectData : : newInstanceRawMemoAttrsSmall ) <nl> - : CallSpec : : direct ( & ObjectData : : newInstanceRawMemoAttrsBig ) ; <nl> - } else { <nl> - return size < = kMaxSmallSize <nl> - ? CallSpec : : direct ( & ObjectData : : newInstanceRawAttrsSmall ) <nl> - : CallSpec : : direct ( & ObjectData : : newInstanceRawAttrsBig ) ; <nl> - } <nl> - } <nl> - <nl> if ( memoSize > 0 ) { <nl> return size < = kMaxSmallSize <nl> ? CallSpec : : direct ( & ObjectData : : newInstanceRawMemoSmall ) <nl> void cgNewInstanceRaw ( IRLS & env , const IRInstruction * inst ) { <nl> ? args . imm ( size_class ) . imm ( index ) <nl> : args . imm ( size ) ; <nl> if ( memoSize > 0 ) args . imm ( memoSize ) ; <nl> - if ( attrs ! = ObjectData : : DefaultAttrs ) args . imm ( attrs ) ; <nl> <nl> cgCallHelper ( <nl> vmain ( env ) , <nl> void cgConstructInstance ( IRLS & env , const IRInstruction * inst ) { <nl> } <nl> <nl> IMPL_OPCODE_CALL ( Clone ) <nl> - IMPL_OPCODE_CALL ( RegisterLiveObj ) <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> mmm a / hphp / runtime / vm / jit / irlower - refcount . cpp <nl> ppp b / hphp / runtime / vm / jit / irlower - refcount . cpp <nl> CallSpec getDtorCallSpec ( DataType type ) { <nl> case KindOfKeyset : <nl> return CallSpec : : direct ( SetArray : : Release ) ; <nl> case KindOfObject : <nl> - return CallSpec : : method ( <nl> - RuntimeOption : : EnableObjDestructCall <nl> - ? & ObjectData : : release <nl> - : & ObjectData : : releaseNoObjDestructCheck <nl> - ) ; <nl> + return CallSpec : : method ( & ObjectData : : release ) ; <nl> case KindOfResource : <nl> return CallSpec : : method ( & ResourceHdr : : release ) ; <nl> case KindOfRef : <nl> CallSpec makeDtorCall ( Type ty , Vloc loc , ArgGroup & args ) { <nl> <nl> / / These conditions must match the ones which cause us to call <nl> / / cls - > instanceDtor ( ) in ObjectData : : release ( ) . <nl> - if ( ( cls - > attrs ( ) & AttrNoOverride ) & & <nl> - ! cls - > getDtor ( ) & & <nl> - cls - > instanceDtor ( ) ) { <nl> + if ( ( cls - > attrs ( ) & AttrNoOverride ) & & cls - > instanceDtor ( ) ) { <nl> args . immPtr ( cls ) ; <nl> return CallSpec : : direct ( cls - > instanceDtor ( ) . get ( ) ) ; <nl> } <nl> mmm a / hphp / runtime / vm / jit / memory - effects . cpp <nl> ppp b / hphp / runtime / vm / jit / memory - effects . cpp <nl> MemEffects memory_effects_impl ( const IRInstruction & inst ) { <nl> case CheckType : <nl> case CheckVArray : <nl> case CheckDArray : <nl> - case RegisterLiveObj : <nl> case StArResumeAddr : <nl> case StContArState : <nl> case ZeroErrorLevel : <nl> mmm a / hphp / runtime / vm / jit / native - calls . cpp <nl> ppp b / hphp / runtime / vm / jit / native - calls . cpp <nl> static CallMap s_callMap { <nl> { InitThrowableFileAndLine , <nl> throwable_init_file_and_line_from_builtin , <nl> DNone , debug ? SSync : SNone , { { SSA , 0 } } } , <nl> - { RegisterLiveObj , registerLiveObj , DNone , SNone , { { SSA , 0 } } } , <nl> { LdClsCtor , loadClassCtor , DSSA , SSync , <nl> { { SSA , 0 } , { SSA , 1 } } } , <nl> { LookupClsRDS , lookupClsRDS , DSSA , SNone , { { SSA , 0 } } } , <nl> mmm a / hphp / runtime / vm / jit / opt . cpp <nl> ppp b / hphp / runtime / vm / jit / opt . cpp <nl> void optimize ( IRUnit & unit , TransKind kind ) { <nl> } <nl> doPass ( unit , fixBlockHints , DCE : : None ) ; <nl> <nl> - if ( kind = = TransKind : : Optimize & & ! RuntimeOption : : AllowObjectDestructors ( ) ) { <nl> + if ( kind = = TransKind : : Optimize ) { <nl> doPass ( unit , selectiveDecRefNZ , DCE : : None ) ; <nl> } <nl> printUnit ( 6 , unit , " after optimize " ) ; <nl> mmm a / hphp / runtime / vm / jit / translator - runtime . cpp <nl> ppp b / hphp / runtime / vm / jit / translator - runtime . cpp <nl> Class * lookupClsRDS ( const StringData * name ) { <nl> return NamedEntity : : get ( name ) - > getCachedClass ( ) ; <nl> } <nl> <nl> - void registerLiveObj ( ObjectData * obj ) { <nl> - assertx ( RuntimeOption : : EnableObjDestructCall & & obj - > getVMClass ( ) - > getDtor ( ) ) ; <nl> - g_context - > m_liveBCObjs . insert ( obj ) ; <nl> - } <nl> - <nl> void throwSwitchMode ( ) { <nl> / / This is only called right after dispatchBB , so the VM regs really are <nl> / / clean . <nl> mmm a / hphp / runtime / vm / jit / translator - runtime . h <nl> ppp b / hphp / runtime / vm / jit / translator - runtime . h <nl> void raiseMissingArgument ( const Func * func , int got ) ; <nl> <nl> Class * lookupClsRDS ( const StringData * name ) ; <nl> <nl> - / * <nl> - * Insert obj into the set of live objects to be destructed at the end of the <nl> - * request . <nl> - * / <nl> - void registerLiveObj ( ObjectData * obj ) ; <nl> - <nl> / * Check if a method of the given name exists on the class . * / <nl> bool methodExistsHelper ( Class * , StringData * ) ; <nl> <nl> mmm a / hphp / runtime / vm / native - data . cpp <nl> ppp b / hphp / runtime / vm / native - data . cpp <nl> ObjectData * nativeDataInstanceCopyCtor ( ObjectData * src , Class * cls , <nl> node - > obj_offset = nativeDataSize ; <nl> assertx ( type_scan : : isKnownType ( ndi - > tyindex ) ) ; <nl> node - > initHeader_32_16 ( HeaderKind : : NativeData , 0 , ndi - > tyindex ) ; <nl> - auto const flags = cls - > getDtor ( ) ? 0 : ObjectData : : NoDestructor ; <nl> auto obj = new ( reinterpret_cast < char * > ( node ) + nativeDataSize ) <nl> - ObjectData ( cls , ObjectData : : InitRaw { } , flags , HeaderKind : : NativeObject ) ; <nl> + ObjectData ( cls , ObjectData : : InitRaw { } , ObjectData : : NoAttrs , <nl> + HeaderKind : : NativeObject ) ; <nl> assertx ( obj - > hasExactlyOneRef ( ) ) ; <nl> <nl> if ( UNLIKELY ( cls - > hasMemoSlots ( ) ) ) { <nl> mmm a / hphp / runtime / vm / repo - global - data . cpp <nl> ppp b / hphp / runtime / vm / repo - global - data . cpp <nl> std : : string show ( const Repo : : GlobalData & gd ) { <nl> SHOW ( ForbidDynamicCalls ) ; <nl> SHOW ( NoticeOnBuiltinDynamicCalls ) ; <nl> SHOW ( ReffinessInvariance ) ; <nl> - SHOW ( AllowObjectDestructors ) ; <nl> SHOW ( AbortBuildOnVerifyError ) ; <nl> SHOW ( UndefinedConstFallback ) ; <nl> SHOW ( Signature ) ; <nl> mmm a / hphp / runtime / vm / repo - global - data . h <nl> ppp b / hphp / runtime / vm / repo - global - data . h <nl> struct Repo : : GlobalData { <nl> * / <nl> bool ReffinessInvariance = false ; <nl> <nl> - / * <nl> - * Are objects allowed to run destructors ? <nl> - * / <nl> - bool AllowObjectDestructors = false ; <nl> - <nl> / * <nl> * Should HHBBC do build time verification ? <nl> * / <nl> struct Repo : : GlobalData { <nl> ( ReffinessInvariance ) <nl> ( ForbidDynamicCalls ) <nl> ( NoticeOnBuiltinDynamicCalls ) <nl> - ( AllowObjectDestructors ) <nl> ( Signature ) <nl> ( AbortBuildOnVerifyError ) <nl> ( UndefinedConstFallback ) <nl> mmm a / hphp / runtime / vm / repo . cpp <nl> ppp b / hphp / runtime / vm / repo . cpp <nl> void Repo : : loadGlobalData ( bool readArrayTable / * = true * / ) { <nl> s_globalData . AbortBuildOnVerifyError ; <nl> RuntimeOption : : DisallowDynamicVarEnvFuncs = <nl> s_globalData . DisallowDynamicVarEnvFuncs ; <nl> - RuntimeOption : : EvalAllowObjectDestructors = <nl> - s_globalData . AllowObjectDestructors ; <nl> if ( s_globalData . HardReturnTypeHints ) { <nl> RuntimeOption : : EvalCheckReturnTypeHints = 3 ; <nl> } <nl> mmm a / hphp / runtime / vm / runtime . h <nl> ppp b / hphp / runtime / vm / runtime . h <nl> inline ObjectData * newInstanceImpl ( Class * cls ) { <nl> assertx ( cls ) ; <nl> auto * inst = ObjectData : : newInstance ( cls ) ; <nl> assertx ( inst - > checkCount ( ) ) ; <nl> - Stats : : inc ( cls - > getDtor ( ) ? Stats : : ObjectData_new_dtor_yes <nl> - : Stats : : ObjectData_new_dtor_no ) ; <nl> - <nl> - if ( UNLIKELY ( RuntimeOption : : EnableObjDestructCall & & cls - > getDtor ( ) ) ) { <nl> - g_context - > m_liveBCObjs . insert ( inst ) ; <nl> - } <nl> return inst ; <nl> } <nl> <nl> mmm a / hphp / runtime / vm / unwind . cpp <nl> ppp b / hphp / runtime / vm / unwind . cpp <nl> void discardStackTemps ( const ActRec * const fp , <nl> <nl> visitStackElems ( <nl> fp , stack . top ( ) , bcOffset , <nl> - [ & ] ( ActRec * ar , Offset pushOff ) { <nl> + [ & ] ( ActRec * ar , Offset ) { <nl> assertx ( ar = = reinterpret_cast < ActRec * > ( stack . top ( ) ) ) ; <nl> - / / ar is a pre - live ActRec in fp ' s scope , and pushOff <nl> - / / is the offset of the corresponding FPush * opcode . <nl> - if ( fp - > func ( ) - > unit ( ) - > getOp ( pushOff ) = = Op : : FPushCtor ) { <nl> - assertx ( ar - > hasThis ( ) ) ; <nl> - ar - > getThis ( ) - > setNoDestruct ( ) ; <nl> - } <nl> ITRACE ( 2 , " unwind pop AR : { } \ n " , <nl> implicit_cast < void * > ( stack . top ( ) ) ) ; <nl> stack . popAR ( ) ; <nl> UnwindAction checkHandlers ( const EHEnt * eh , <nl> ObjectData * tearDownFrame ( ActRec * & fp , Stack & stack , PC & pc , <nl> ObjectData * phpException ) { <nl> auto const func = fp - > func ( ) ; <nl> - auto const curOp = peek_op ( pc ) ; <nl> auto const prevFp = fp - > sfp ( ) ; <nl> auto const callOff = fp - > m_callOff ; <nl> <nl> ObjectData * tearDownFrame ( ActRec * & fp , Stack & stack , PC & pc , <nl> implicit_cast < void * > ( fp ) , <nl> implicit_cast < void * > ( prevFp ) ) ; <nl> <nl> - / / When throwing from a constructor , we normally want to avoid running the <nl> - / / destructor on an object that hasn ' t been fully constructed yet . But if <nl> - / / we ' re unwinding through the constructor ' s RetC , the constructor has <nl> - / / logically finished and we ' re unwinding for some internal reason ( timeout <nl> - / / or user profiler , most likely ) . More importantly , fp - > m_this may have <nl> - / / already been destructed and / or overwritten due to sharing space with <nl> - / / the return value via fp - > retSlot ( ) . <nl> - if ( curOp ! = OpRetC & & <nl> - ! fp - > localsDecRefd ( ) & & <nl> - fp - > m_func - > cls ( ) & & <nl> - fp - > hasThis ( ) & & <nl> - fp - > getThis ( ) - > getVMClass ( ) - > getCtor ( ) = = func & & <nl> - fp - > getThis ( ) - > getVMClass ( ) - > getDtor ( ) ) { <nl> - / * <nl> - * Looks like an FPushCtor call , but it could still have been called <nl> - * directly . Check the fpi region to be sure . <nl> - * / <nl> - Offset prevPc ; <nl> - auto outer = g_context - > getPrevVMState ( fp , & prevPc ) ; <nl> - if ( outer ) { <nl> - auto fe = outer - > func ( ) - > findFPI ( prevPc ) ; <nl> - if ( fe & & outer - > func ( ) - > unit ( ) - > getOp ( fe - > m_fpushOff ) = = Op : : FPushCtor ) { <nl> - fp - > getThis ( ) - > setNoDestruct ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> auto const decRefLocals = [ & ] { <nl> / * <nl> * It is possible that locals have already been decref ' d . <nl> mmm a / hphp / system / php . txt <nl> ppp b / hphp / system / php . txt <nl> hphp / system / php / spl / iterators / RecursiveIteratorIterator . php <nl> hphp / system / php / spl / iterators / RecursiveTreeIterator . php <nl> hphp / system / php / spl / miscellaneous / ArrayObject . php <nl> hphp / system / php / spl / miscellaneous / autoload . php <nl> - hphp / system / php / XhprofFrame . php <nl> hphp / system / php / experimental_parser_utils . php <nl> <nl> # This provides a temporary workaround for renamed lz4 methods <nl> deleted file mode 100644 <nl> index 957a9187d45 . . 00000000000 <nl> mmm a / hphp / system / php / XhprofFrame . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - / * * <nl> - * Helps application inserting an artificial frame in xhprof ' s reporting . <nl> - * / <nl> - class XhprofFrame { <nl> - public function __construct ( $ name ) { <nl> - xhprof_frame_begin ( $ name ) ; <nl> - } <nl> - public function __destruct ( ) { <nl> - xhprof_frame_end ( ) ; <nl> - } <nl> - } <nl> mmm a / hphp / system / php / lang / Serializeable . php <nl> ppp b / hphp / system / php / lang / Serializeable . php <nl> <nl> * <nl> * Classes that implement this interface no longer support __sleep ( ) and <nl> * __wakeup ( ) . The method serialize is called whenever an instance needs to <nl> - * be serialized . This does not invoke __destruct ( ) or has any other side <nl> - * effect unless programmed inside the method . When the data is <nl> - * unserialized the class is known and the appropriate unserialize ( ) method <nl> - * is called as a constructor instead of calling __construct ( ) . If you need <nl> - * to execute the standard constructor you may do so in the method . <nl> + * be serialized . This does not have any side effects unless programmed inside <nl> + * the method . When the data is unserialized the class is known and the <nl> + * appropriate unserialize ( ) method is called as a constructor instead of <nl> + * calling __construct ( ) . If you need to execute the standard constructor you <nl> + * may do so in the method . <nl> * <nl> * / <nl> interface Serializable { <nl> interface Serializable { <nl> * <nl> * Should return the string representation of the object . <nl> * <nl> - * This method acts as the destructor of the object . The __destruct ( ) <nl> - * method will not be called after this method . <nl> + * This method acts as the destructor of the object . <nl> * <nl> * @ return mixed Returns the string representation of the object or <nl> * NULL <nl> mmm a / hphp / system / php / phar / PharFileInfo . php <nl> ppp b / hphp / system / php / phar / PharFileInfo . php <nl> public function getPathName ( ) { <nl> return $ this - > name ; <nl> } <nl> <nl> - < < __OptionalDestruct > > <nl> - public function __destruct ( ) { <nl> - } <nl> - <nl> / / This doc comment block generated by idl / sysdoc . php <nl> / * * <nl> * ( excerpt from http : / / php . net / manual / en / pharfileinfo . chmod . php ) <nl> mmm a / hphp / system / php / redis / Redis . php <nl> ppp b / hphp / system / php / redis / Redis . php <nl> protected function sortClause ( array $ arr , & $ using_store ) { <nl> <nl> return $ ret ; <nl> } <nl> - <nl> - < < __OptionalDestruct > > <nl> - public function __destruct ( ) { <nl> - <nl> - } <nl> } <nl> similarity index 100 % <nl> rename from hphp / test / quick / exception_destructor_3 . php . norepo <nl> rename to hphp / test / quick / BindM . php . norepo <nl> mmm a / hphp / test / quick / access_modifier . hhas <nl> ppp b / hphp / test / quick / access_modifier . hhas <nl> <nl> Null <nl> RetC <nl> } <nl> - . method [ public ] < " " N > __destruct ( ) { <nl> - String " " <nl> - BaseH <nl> - SetM 0 PT : " attre " <nl> - PopC <nl> - Null <nl> - RetC <nl> - } <nl> } <nl> deleted file mode 100644 <nl> index d1670ae5d71 . . 00000000000 <nl> mmm a / hphp / test / quick / actrec . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class X { <nl> - private $ bar = 1 ; <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - global $ e ; <nl> - $ e = debug_backtrace ( DEBUG_BACKTRACE_PROVIDE_OBJECT ) ; <nl> - } <nl> - function foo ( $ ids ) { <nl> - return array ( $ this - > bar , <nl> - $ ids , <nl> - $ this - > bar , <nl> - $ this - > bar , <nl> - $ this - > bar , <nl> - $ this - > bar ) ; <nl> - } <nl> - } <nl> - <nl> - function test ( ) { <nl> - $ a = new X ; <nl> - yield 1 ; <nl> - yield $ a ; <nl> - global $ g ; <nl> - $ g = null ; <nl> - yield 2 ; <nl> - } <nl> - <nl> - function main ( ) { <nl> - global $ g ; <nl> - $ g = test ( ) ; <nl> - for ( $ g - > rewind ( ) ; $ g & & $ g - > valid ( ) ; $ g - > next ( ) ) <nl> - var_dump ( $ g - > current ( ) ) ; <nl> - var_dump ( $ g ) ; <nl> - global $ e ; <nl> - $ e = null ; <nl> - } <nl> - <nl> - main ( ) ; <nl> - $ a = new X ; <nl> - var_dump ( $ a - > foo ( 1 ) ) ; <nl> - $ a = null ; <nl> deleted file mode 100644 <nl> index 4401992a180 . . 00000000000 <nl> mmm a / hphp / test / quick / actrec . php . expect <nl> ppp / dev / null <nl> <nl> - int ( 1 ) <nl> - object ( X ) # 2 ( 1 ) { <nl> - [ " bar " : " X " : private ] = > <nl> - int ( 1 ) <nl> - } <nl> - string ( 13 ) " X : : __destruct " <nl> - NULL <nl> - array ( 6 ) { <nl> - [ 0 ] = > <nl> - int ( 1 ) <nl> - [ 1 ] = > <nl> - int ( 1 ) <nl> - [ 2 ] = > <nl> - int ( 1 ) <nl> - [ 3 ] = > <nl> - int ( 1 ) <nl> - [ 4 ] = > <nl> - int ( 1 ) <nl> - [ 5 ] = > <nl> - int ( 1 ) <nl> - } <nl> - string ( 13 ) " X : : __destruct " <nl> mmm a / hphp / test / quick / alias_torture . php <nl> ppp b / hphp / test / quick / alias_torture . php <nl> function main1 ( ) { <nl> var_dump ( $ b ) ; <nl> } <nl> main1 ( ) ; <nl> - <nl> - class A { <nl> - function __destruct ( ) { <nl> - global $ x , $ y , $ z ; <nl> - $ x = " foo " ; <nl> - $ y = " bar " ; <nl> - $ z = " baz " ; <nl> - } <nl> - } <nl> - <nl> - function main2 ( ) { <nl> - / / SetH calling __destruct ( ) <nl> - global $ a , $ b , $ c ; <nl> - global $ x , $ y , $ z ; <nl> - $ x = 123 ; <nl> - $ a = new A ; <nl> - $ a = null ; <nl> - var_dump ( $ x ) ; <nl> - <nl> - $ y = 123 ; <nl> - $ b = new A ; <nl> - $ c = & $ b ; <nl> - $ b = null ; <nl> - var_dump ( $ y ) ; <nl> - <nl> - $ z = 123 ; <nl> - $ d = array ( ) ; <nl> - $ d [ ] = new A ; <nl> - $ d = null ; <nl> - var_dump ( $ z ) ; <nl> - } <nl> - <nl> - main2 ( ) ; <nl> - <nl> - class B { <nl> - function __construct ( & $ x ) { <nl> - $ this - > y = & $ x ; <nl> - } <nl> - function __destruct ( ) { <nl> - $ this - > y = " foo " ; <nl> - } <nl> - } <nl> - <nl> - function bar ( ) { <nl> - $ x = 123 ; <nl> - $ a = new B ( & $ x ) ; <nl> - $ a = null ; <nl> - var_dump ( $ x ) ; <nl> - <nl> - $ y = 123 ; <nl> - $ b = new B ( & $ y ) ; <nl> - $ c = & $ b ; <nl> - $ b = null ; <nl> - var_dump ( $ y ) ; <nl> - <nl> - $ z = 123 ; <nl> - $ d = array ( ) ; <nl> - $ d [ ] = new B ( & $ z ) ; <nl> - $ d = null ; <nl> - var_dump ( $ z ) ; <nl> - } <nl> - <nl> - bar ( ) ; <nl> - <nl> - / / Exercise aliasing across re - entry . <nl> - mt_srand ( 0 ) ; <nl> - function randphpwork ( $ r ) { <nl> - $ a = array ( ) ; <nl> - switch ( $ r % 4 ) { <nl> - case 0 : / * int * / return mt_rand ( 0 , 256 ) ; <nl> - case 1 : / * str * / return randstr ( ) ; <nl> - case 2 : / * obj * / return new C ( $ a = randarr ( ) ) ; <nl> - case 3 : / * arr * / return randarr ( ) ; <nl> - } <nl> - return null ; / / not reached <nl> - } <nl> - <nl> - function randphp ( ) { <nl> - static $ depth ; <nl> - $ r = mt_rand ( 0 , 4 ) ; <nl> - if ( $ depth > 2 ) $ r = $ r & 1 ; / / scalars <nl> - $ depth + + ; <nl> - $ r = $ r % 4 ; <nl> - $ ret = randphpwork ( $ r ) ; <nl> - $ depth - - ; <nl> - return $ ret ; <nl> - } <nl> - <nl> - function randchar ( ) { <nl> - return chr ( ord ( ' A ' ) + ( mt_rand ( 0 , 26 ) ) ) ; <nl> - } <nl> - <nl> - function randstr ( ) { <nl> - $ ret = " " ; <nl> - $ ret [ 0 ] = randchar ( ) ; <nl> - $ ret [ 1 ] = randchar ( ) ; <nl> - $ ret [ 2 ] = randchar ( ) ; <nl> - $ ret [ 3 ] = randchar ( ) ; <nl> - return $ ret ; <nl> - } <nl> - <nl> - function randarr ( ) { <nl> - $ ret = array ( ) ; <nl> - $ ret [ ] = randstr ( ) ; <nl> - $ ret [ ] = randstr ( ) ; <nl> - $ ret [ ] = randstr ( ) ; <nl> - $ ret [ ] = randstr ( ) ; <nl> - return $ ret ; <nl> - } <nl> - <nl> - class C { <nl> - public $ aliases ; <nl> - public function __construct ( $ aliases ) { <nl> - $ this - > aliases = $ aliases ; <nl> - } <nl> - public function __destruct ( ) { <nl> - foreach ( $ this - > aliases as $ k = > $ _ ) { <nl> - $ this - > aliases [ $ k ] = randphp ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - function tmpobj ( & $ aliases ) { <nl> - return new C ( $ aliases ) ; <nl> - } <nl> - <nl> - function main3 ( ) { <nl> - / / Get some locals . <nl> - $ a = mt_rand ( 0 , 10 ) ; <nl> - $ b = randstr ( ) ; <nl> - $ c = randarr ( ) ; <nl> - $ str = randstr ( ) ; <nl> - <nl> - / / Alias them in $ aliases . <nl> - $ aliases = array ( ) ; <nl> - $ aliases [ ] = & $ a ; <nl> - $ aliases [ ] = & $ b ; <nl> - $ aliases [ ] = & $ c ; <nl> - <nl> - / / Wrap them up in an array and leak them into C ( ) . <nl> - for ( $ i = 0 ; $ i < 10 ; $ i + + ) { <nl> - echo " $ i < \ n " ; <nl> - / / Get some locals . <nl> - $ a = $ i ; <nl> - $ b = randstr ( ) ; <nl> - $ c = randarr ( ) ; <nl> - / / Read / write them while implicitly mutating them through the temporary <nl> - / / object ' s destructor . <nl> - $ unused = <nl> - ( tmpobj ( & $ aliases ) = = = tmpobj ( & $ aliases ) ) = = = ( ( $ a = = = $ b ) = = = $ c ) ; <nl> - echo " mmmmmm - - > \ n " ; <nl> - / / . . . and use them again . <nl> - var_dump ( $ a , $ b , $ c ) ; <nl> - echo " > \ n " ; <nl> - } <nl> - } <nl> - <nl> - main3 ( ) ; <nl> mmm a / hphp / test / quick / alias_torture . php . expect <nl> ppp b / hphp / test / quick / alias_torture . php . expect <nl> string ( 2 ) " of " <nl> int ( 123 ) <nl> string ( 7 ) " 123moot " <nl> string ( 4 ) " hoof " <nl> - string ( 3 ) " foo " <nl> - string ( 3 ) " bar " <nl> - string ( 3 ) " baz " <nl> - string ( 3 ) " foo " <nl> - string ( 3 ) " foo " <nl> - string ( 3 ) " foo " <nl> - 0 < <nl> - mmmmmm - - > <nl> - string ( 4 ) " KJSL " <nl> - string ( 4 ) " SDGF " <nl> - int ( 94 ) <nl> - > <nl> - 1 < <nl> - mmmmmm - - > <nl> - string ( 4 ) " XULI " <nl> - int ( 248 ) <nl> - string ( 4 ) " KTJN " <nl> - > <nl> - 2 < <nl> - mmmmmm - - > <nl> - int ( 24 ) <nl> - object ( C ) # 22 ( 1 ) { <nl> - [ " aliases " ] = > <nl> - array ( 4 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " DATR " <nl> - [ 1 ] = > <nl> - string ( 4 ) " ATSW " <nl> - [ 2 ] = > <nl> - string ( 4 ) " VQGB " <nl> - [ 3 ] = > <nl> - string ( 4 ) " OTYQ " <nl> - } <nl> - } <nl> - array ( 4 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " SWMJ " <nl> - [ 1 ] = > <nl> - string ( 4 ) " ZXRX " <nl> - [ 2 ] = > <nl> - string ( 4 ) " CQSY " <nl> - [ 3 ] = > <nl> - string ( 4 ) " BFNB " <nl> - } <nl> - > <nl> - 3 < <nl> - mmmmmm - - > <nl> - object ( C ) # 44 ( 1 ) { <nl> - [ " aliases " ] = > <nl> - array ( 4 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " OGKF " <nl> - [ 1 ] = > <nl> - string ( 4 ) " JNPF " <nl> - [ 2 ] = > <nl> - string ( 4 ) " WVPI " <nl> - [ 3 ] = > <nl> - string ( 4 ) " ARHV " <nl> - } <nl> - } <nl> - int ( 108 ) <nl> - string ( 4 ) " MYAC " <nl> - > <nl> - 4 < <nl> - mmmmmm - - > <nl> - int ( 29 ) <nl> - int ( 20 ) <nl> - object ( C ) # 52 ( 1 ) { <nl> - [ " aliases " ] = > <nl> - array ( 4 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " CQXW " <nl> - [ 1 ] = > <nl> - string ( 4 ) " IAZD " <nl> - [ 2 ] = > <nl> - string ( 4 ) " WUZL " <nl> - [ 3 ] = > <nl> - string ( 4 ) " GOEO " <nl> - } <nl> - } <nl> - > <nl> - 5 < <nl> - mmmmmm - - > <nl> - int ( 115 ) <nl> - array ( 4 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " LGHM " <nl> - [ 1 ] = > <nl> - string ( 4 ) " XIAR " <nl> - [ 2 ] = > <nl> - string ( 4 ) " PIVS " <nl> - [ 3 ] = > <nl> - string ( 4 ) " QHHI " <nl> - } <nl> - string ( 4 ) " LYYE " <nl> - > <nl> - 6 < <nl> - mmmmmm - - > <nl> - int ( 27 ) <nl> - int ( 193 ) <nl> - int ( 98 ) <nl> - > <nl> - 7 < <nl> - mmmmmm - - > <nl> - string ( 4 ) " BDQB " <nl> - object ( C ) # 59 ( 1 ) { <nl> - [ " aliases " ] = > <nl> - array ( 4 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " QZZE " <nl> - [ 1 ] = > <nl> - string ( 4 ) " ZHYN " <nl> - [ 2 ] = > <nl> - string ( 4 ) " LCWO " <nl> - [ 3 ] = > <nl> - string ( 4 ) " ABKF " <nl> - } <nl> - } <nl> - int ( 34 ) <nl> - > <nl> - 8 < <nl> - mmmmmm - - > <nl> - object ( C ) # 67 ( 1 ) { <nl> - [ " aliases " ] = > <nl> - array ( 4 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " OVZY " <nl> - [ 1 ] = > <nl> - string ( 4 ) " ZRQJ " <nl> - [ 2 ] = > <nl> - string ( 4 ) " RMBD " <nl> - [ 3 ] = > <nl> - string ( 4 ) " TEAH " <nl> - } <nl> - } <nl> - int ( 75 ) <nl> - object ( C ) # 68 ( 1 ) { <nl> - [ " aliases " ] = > <nl> - array ( 4 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " IHJN " <nl> - [ 1 ] = > <nl> - string ( 4 ) " FX [ B " <nl> - [ 2 ] = > <nl> - string ( 4 ) " UCJK " <nl> - [ 3 ] = > <nl> - string ( 4 ) " XXEU " <nl> - } <nl> - } <nl> - > <nl> - 9 < <nl> - mmmmmm - - > <nl> - int ( 216 ) <nl> - array ( 4 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " YHUX " <nl> - [ 1 ] = > <nl> - string ( 4 ) " WUSF " <nl> - [ 2 ] = > <nl> - string ( 4 ) " OTMT " <nl> - [ 3 ] = > <nl> - string ( 4 ) " RUPX " <nl> - } <nl> - object ( C ) # 70 ( 1 ) { <nl> - [ " aliases " ] = > <nl> - array ( 4 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " QYHW " <nl> - [ 1 ] = > <nl> - string ( 4 ) " VWQU " <nl> - [ 2 ] = > <nl> - string ( 4 ) " MNAB " <nl> - [ 3 ] = > <nl> - string ( 4 ) " FBVJ " <nl> - } <nl> - } <nl> - > <nl> mmm a / hphp / test / quick / apc - sleep . php <nl> ppp b / hphp / test / quick / apc - sleep . php <nl> public function __construct ( $ f , $ b ) { <nl> $ this - > foo = $ f ; <nl> $ this - > bar = $ b ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " Destructing a Foo \ n " ; <nl> - } <nl> public function __sleep ( ) { <nl> echo " I ' m going to sleep \ n " ; <nl> return array ( ' foo ' ) ; <nl> mmm a / hphp / test / quick / apc - sleep . php . expect <nl> ppp b / hphp / test / quick / apc - sleep . php . expect <nl> object ( Foo ) # 1 ( 2 ) { <nl> int ( 2 ) <nl> } <nl> I ' m going to sleep <nl> - Destructing a Foo <nl> I ' m waking up <nl> object ( Foo ) # 1 ( 2 ) { <nl> [ " foo " ] = > <nl> object ( Foo ) # 1 ( 2 ) { <nl> [ " bar " ] = > <nl> NULL <nl> } <nl> - Destructing a Foo <nl> mmm a / hphp / test / quick / array_access . php <nl> ppp b / hphp / test / quick / array_access . php <nl> class E implements ArrayAccess { <nl> public function __construct ( ) { <nl> $ this - > i = + + self : : $ count ; <nl> } <nl> - public function __destruct ( ) { <nl> - printf ( " In E : : __destruct ( ) % d \ n " , $ this - > i ) ; ; <nl> - } <nl> public function offsetGet ( $ offset ) { <nl> print " In E : : offsetGet ( ) \ n " ; <nl> $ a = array ( ) ; <nl> public function offsetUnset ( $ offset ) { } <nl> } <nl> <nl> class D implements ArrayAccess { <nl> - public function __destruct ( ) { <nl> - print " In D : : __destruct ( ) \ n " ; <nl> - } <nl> public function offsetGet ( $ offset ) { <nl> print " In D : : offsetGet ( ) \ n " ; <nl> # Generate a new object that has no references besides the one being <nl> mmm a / hphp / test / quick / array_access . php . expect <nl> ppp b / hphp / test / quick / array_access . php . expect <nl> <nl> Test begin <nl> In C : : offsetGet ( ) <nl> In D : : offsetGet ( ) <nl> - In D : : __destruct ( ) <nl> In E : : offsetGet ( ) <nl> - In E : : __destruct ( ) 1 <nl> - In E : : __destruct ( ) 2 <nl> string ( 5 ) " hello " <nl> In C : : offsetGet ( ) <nl> In D : : offsetGet ( ) <nl> - In D : : __destruct ( ) <nl> In E : : offsetGet ( ) <nl> - In E : : __destruct ( ) 3 <nl> - In E : : __destruct ( ) 4 <nl> In cls : : offsetExists ( two ) <nl> bool ( true ) <nl> In cls : : offsetGet ( two ) <nl> cls Object <nl> <nl> ) <nl> Test end <nl> - string ( 10 ) " hellohello " <nl> \ No newline at end of file <nl> + string ( 10 ) " hellohello " <nl> mmm a / hphp / test / quick / array_misc . php <nl> ppp b / hphp / test / quick / array_misc . php <nl> <nl> < ? php <nl> <nl> class X { <nl> - function __destruct ( ) { var_dump ( __METHOD__ ) ; } <nl> } <nl> <nl> function test ( $ a ) { <nl> mmm a / hphp / test / quick / array_misc . php . expect <nl> ppp b / hphp / test / quick / array_misc . php . expect <nl> array ( 1 ) { <nl> [ 1 ] = > <nl> string ( 3 ) " bar " <nl> } <nl> - string ( 13 ) " X : : __destruct " <nl> int ( 42 ) <nl> int ( 42 ) <nl> string ( 3 ) " bar " <nl> deleted file mode 100644 <nl> index 0e03866a1da . . 00000000000 <nl> mmm a / hphp / test / quick / array_plus_eq_dtor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class dtor { public function __destruct ( ) { echo " dtor \ n " ; } } <nl> - <nl> - function main ( ) { <nl> - $ a = array ( new dtor ) ; <nl> - var_dump ( $ a + array ( 4 , 5 , 6 ) ) ; <nl> - } <nl> - <nl> - main ( ) ; <nl> - echo " done \ n " ; <nl> deleted file mode 100644 <nl> index fa90ff9d06a . . 00000000000 <nl> mmm a / hphp / test / quick / array_plus_eq_dtor . php . expect <nl> ppp / dev / null <nl> <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - object ( dtor ) # 1 ( 0 ) { <nl> - } <nl> - [ 1 ] = > <nl> - int ( 5 ) <nl> - [ 2 ] = > <nl> - int ( 6 ) <nl> - } <nl> - dtor <nl> - done <nl> mmm a / hphp / test / quick / builtin_extension_Memcache . php . expectf <nl> ppp b / hphp / test / quick / builtin_extension_Memcache . php . expectf <nl> object ( Memcache ) # 1 ( 0 ) { <nl> Warning : Attempted to serialize unserializable builtin class Memcache in % s / builtin_extensions . inc on line 8 <nl> string ( 2 ) " N ; " <nl> NULL <nl> - array ( 21 ) { <nl> + array ( 20 ) { <nl> [ 0 ] = > <nl> string ( 11 ) " __construct " <nl> [ 1 ] = > <nl> array ( 21 ) { <nl> string ( 15 ) " setserverparams " <nl> [ 19 ] = > <nl> string ( 9 ) " addserver " <nl> - [ 20 ] = > <nl> - string ( 10 ) " __destruct " <nl> } <nl> = = = = = = = = = = = = = = = = <nl> A_Memcache <nl> object ( A_Memcache ) # 2 ( 1 ) { <nl> Warning : Attempted to serialize unserializable builtin class A_Memcache in % s / builtin_extensions . inc on line 26 <nl> string ( 2 ) " N ; " <nl> NULL <nl> - array ( 21 ) { <nl> + array ( 20 ) { <nl> [ 0 ] = > <nl> string ( 11 ) " __construct " <nl> [ 1 ] = > <nl> array ( 21 ) { <nl> string ( 15 ) " setserverparams " <nl> [ 19 ] = > <nl> string ( 9 ) " addserver " <nl> - [ 20 ] = > <nl> - string ( 10 ) " __destruct " <nl> - } <nl> \ No newline at end of file <nl> + } <nl> mmm a / hphp / test / quick / call_callable . php <nl> ppp b / hphp / test / quick / call_callable . php <nl> public static function __callStatic ( $ name , $ args ) { <nl> } <nl> } <nl> <nl> - class Dtor { <nl> - public function __destruct ( ) { echo __METHOD__ , " \ n " ; } <nl> - public function f ( ) { echo __METHOD__ , " \ n " ; } <nl> - } <nl> - <nl> <nl> class Foo extends Base { <nl> public function get ( ) { return array ( $ this , ' blah ' ) ; } <nl> function invoker ( $ x ) { <nl> $ x ( ) ; <nl> } <nl> <nl> - function test_destructor ( ) { <nl> - echo ' = ' , __FUNCTION__ , " = \ n " ; <nl> - <nl> - invoker ( array ( new Dtor ( ) , ' f ' ) ) ; <nl> - echo " done : test_destructor \ n " ; <nl> - } <nl> - <nl> function test_inheritance ( ) { <nl> echo ' = ' , __FUNCTION__ , " = \ n " ; <nl> <nl> function test_invocation_syntaxes ( ) { <nl> } <nl> <nl> function main ( ) { <nl> - test_destructor ( ) ; <nl> test_inheritance ( ) ; <nl> test_invocation_syntaxes ( ) ; <nl> } <nl> mmm a / hphp / test / quick / call_callable . php . expectf <nl> ppp b / hphp / test / quick / call_callable . php . expectf <nl> <nl> - = test_destructor = <nl> - Dtor : : f <nl> - Dtor : : f <nl> - Dtor : : __destruct <nl> - done : test_destructor <nl> = test_inheritance = <nl> Base : : blah <nl> Base : : blah <nl> mmm a / hphp / test / quick / cgetm_hee . php <nl> ppp b / hphp / test / quick / cgetm_hee . php <nl> class ary implements ArrayAccess { <nl> public function __construct ( ) { <nl> echo " Constructing \ n " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " Destructing \ n " ; <nl> - } <nl> public function offsetExists ( $ i ) { <nl> return true ; <nl> } <nl> mmm a / hphp / test / quick / cgetm_hee . php . expectf <nl> ppp b / hphp / test / quick / cgetm_hee . php . expectf <nl> NULL <nl> string ( 8 ) " ticktick " <nl> string ( 4 ) " woof " <nl> <nl> - Notice : Undefined index : 3 in % s on line 27 <nl> + Notice : Undefined index : 3 in % s on line 24 <nl> NULL <nl> - Destructing <nl> NULL <nl> string ( 8 ) " tocktock " <nl> string ( 4 ) " meow " <nl> <nl> - Notice : Undefined index : 3 in % s on line 35 <nl> + Notice : Undefined index : 3 in % s on line 32 <nl> NULL <nl> - Destructing <nl> mmm a / hphp / test / quick / class_exists_throw . php <nl> ppp b / hphp / test / quick / class_exists_throw . php <nl> <nl> < ? php <nl> <nl> function __autoload ( ) { throw new Exception ( ' sup ' ) ; class nothing { } } <nl> - class dtor { public function __destruct ( ) { echo " dtor \ n " ; } } <nl> <nl> function main ( ) { <nl> - $ x = new dtor ; <nl> - echo $ x + class_exists ( ' nothing ' ) ; <nl> + echo class_exists ( ' nothing ' ) ; <nl> echo " \ n " ; <nl> } <nl> try { main ( ) ; } catch ( Exception $ x ) { echo $ x - > getMessage ( ) ; echo " \ n " ; } <nl> echo " done \ n " ; <nl> - <nl> mmm a / hphp / test / quick / class_exists_throw . php . expect <nl> ppp b / hphp / test / quick / class_exists_throw . php . expect <nl> <nl> - dtor <nl> sup <nl> done <nl> mmm a / hphp / test / quick / closure_lifetime . php <nl> ppp b / hphp / test / quick / closure_lifetime . php <nl> <nl> < ? php <nl> <nl> class blah { <nl> - public function __destruct ( ) { echo " ~ blah ( ) \ n " ; } <nl> - public function foo ( ) { return function ( ) { return " hi " ; } ; } <nl> + private string $ t = " " ; <nl> + public function __construct ( ) { $ this - > t = " hi \ n " ; } <nl> + public function foo ( ) { return function ( ) { return $ this - > t ; } ; } <nl> } <nl> <nl> function main ( ) { <nl> $ k = ( new blah ) - > foo ( ) ; / / only reference to obj is in the closure <nl> - $ k ( ) ; <nl> + echo $ k ( ) ; <nl> unset ( $ k ) ; <nl> echo " done \ n " ; <nl> } <nl> mmm a / hphp / test / quick / closure_lifetime . php . expect <nl> ppp b / hphp / test / quick / closure_lifetime . php . expect <nl> <nl> - ~ blah ( ) <nl> + hi <nl> done <nl> mmm a / hphp / test / quick / debugger / flow2 . php <nl> ppp b / hphp / test / quick / debugger / flow2 . php <nl> public function __construct ( $ a ) { <nl> error_log ( ' Constructor ' ) ; <nl> } <nl> <nl> - public function __destruct ( ) { <nl> - error_log ( ' Destructor ' ) ; <nl> - } <nl> + <nl> + <nl> + <nl> } ; <nl> <nl> / / Test the following : <nl> mmm a / hphp / test / quick / debugger / flow2 . php . expectf <nl> ppp b / hphp / test / quick / debugger / flow2 . php . expectf <nl> Break at foo ( ) on line 44 of % s / flow2 . php <nl> <nl> next <nl> Constructor <nl> - Destructor <nl> Break at foo ( ) on line 45 of % s / flow2 . php <nl> 44 $ c = new C1 ( 6 ) ; / / Runs a destructor <nl> 45 * $ d = $ c ; <nl> Break at foo ( ) on line 50 of % s / flow2 . php <nl> 51 <nl> <nl> next <nl> - Destructor <nl> - Destructor <nl> Break at test ( ) on line 53 of % s / flow2 . php <nl> 52 function test ( $ a ) { <nl> 53 * foo ( $ a ) ; <nl> All breakpoints are cleared . <nl> continue <nl> Finished in genFoo <nl> Constructor <nl> - Destructor <nl> Constructor <nl> - Destructor <nl> - Destructor <nl> int ( 9 ) <nl> int ( 1 ) <nl> object ( C1 ) # 3 ( 1 ) { <nl> object ( C1 ) # 3 ( 1 ) { <nl> int ( 0 ) <nl> } <nl> <nl> - break flow2 . php : 26 <nl> - Breakpoint 1 set on line 26 of flow2 . php <nl> - @ test ( 3 ) <nl> - Constructor <nl> - Finished in genFoo <nl> - Constructor <nl> - Breakpoint 1 reached at C1 : : __destruct ( ) on line 26 of % s / flow2 . php <nl> - 25 public function __destruct ( ) { <nl> - 26 * error_log ( ' Destructor ' ) ; <nl> - 27 } <nl> - <nl> - out <nl> - Destructor <nl> - Break at foo ( ) on line 45 of % s / flow2 . php <nl> - 44 $ c = new C1 ( 6 ) ; / / Runs a destructor <nl> - 45 * $ d = $ c ; <nl> - 46 $ e = new C1 ( 7 ) ; <nl> - <nl> - continue <nl> - Constructor <nl> - Breakpoint 1 reached at C1 : : __destruct ( ) on line 26 of % s / flow2 . php <nl> - 25 public function __destruct ( ) { <nl> - 26 * error_log ( ' Destructor ' ) ; <nl> - 27 } <nl> - <nl> - out <nl> - Destructor <nl> - Breakpoint 1 reached at C1 : : __destruct ( ) on line 26 of % s / flow2 . php <nl> - 25 public function __destruct ( ) { <nl> - 26 * error_log ( ' Destructor ' ) ; <nl> - 27 } <nl> - <nl> - out <nl> - Destructor <nl> - Break at test ( ) on line 54 of % s / flow2 . php <nl> - 53 foo ( $ a ) ; <nl> - 54 * } <nl> - 55 <nl> - <nl> - break clear all <nl> - All breakpoints are cleared . <nl> - continue <nl> - int ( 10 ) <nl> - int ( 1 ) <nl> - object ( C1 ) # 4 ( 1 ) { <nl> - [ " x " : " C1 " : private ] = > <nl> - int ( 0 ) <nl> - } <nl> - <nl> quit <nl> mmm a / hphp / test / quick / debugger / flow2 . php . in <nl> ppp b / hphp / test / quick / debugger / flow2 . php . in <nl> continue <nl> out <nl> break clear all <nl> continue <nl> - break flow2 . php : 26 <nl> - @ test ( 3 ) <nl> - out <nl> - continue <nl> - out <nl> - out <nl> - break clear all <nl> - continue <nl> quit <nl> mmm a / hphp / test / quick / debugger / flow_multistep . php <nl> ppp b / hphp / test / quick / debugger / flow_multistep . php <nl> public function __construct ( $ a ) { <nl> $ x = $ a ; <nl> } <nl> <nl> - public function __destruct ( ) { <nl> - echo " C1 destructor ! \ n " ; <nl> - } <nl> + <nl> + <nl> + <nl> } ; <nl> <nl> class C2 { <nl> public function __construct ( $ a ) { <nl> $ x = $ a ; <nl> } <nl> <nl> - public function __destruct ( ) { <nl> - echo " C2 destructor \ n " ; <nl> - $ c = new C1 ( 42 ) ; <nl> - $ c = null ; <nl> - echo " C2 destructor done \ n " ; <nl> - } <nl> + <nl> + <nl> + <nl> + <nl> + <nl> + <nl> } ; <nl> <nl> function main ( ) { <nl> function main ( ) { <nl> } <nl> <nl> main ( ) ; <nl> - <nl> - <nl> mmm a / hphp / test / quick / debugger / flow_multistep . php . expectf <nl> ppp b / hphp / test / quick / debugger / flow_multistep . php . expectf <nl> run <nl> C1 oh hai <nl> C2 oh hai <nl> C2 oh hai <nl> - C2 destructor <nl> - C1 oh hai <nl> - C1 destructor ! <nl> - C2 destructor done <nl> object ( C1 ) # 1 ( 1 ) { <nl> [ " x " : " C1 " : private ] = > <nl> int ( 0 ) <nl> Break at main ( ) on line 58 of % s / flow_multistep . php <nl> <nl> continue <nl> int ( 46 ) <nl> - C1 destructor ! <nl> - C2 destructor <nl> - C1 oh hai <nl> - C1 destructor ! <nl> - C2 destructor done <nl> Program % s / flow_multistep . php exited normally . <nl> run <nl> C1 oh hai <nl> C2 oh hai <nl> C2 oh hai <nl> - C2 destructor <nl> - C1 oh hai <nl> - C1 destructor ! <nl> - C2 destructor done <nl> object ( C1 ) # 1 ( 1 ) { <nl> [ " x " : " C1 " : private ] = > <nl> int ( 0 ) <nl> Break at main ( ) on line 58 of % s / flow_multistep . php <nl> <nl> continue <nl> int ( 46 ) <nl> - C1 destructor ! <nl> - C2 destructor <nl> - C1 oh hai <nl> - C1 destructor ! <nl> - C2 destructor done <nl> Program % s / flow_multistep . php exited normally . <nl> run <nl> C1 oh hai <nl> C2 oh hai <nl> C2 oh hai <nl> - C2 destructor <nl> - C1 oh hai <nl> - C1 destructor ! <nl> - C2 destructor done <nl> object ( C1 ) # 1 ( 1 ) { <nl> [ " x " : " C1 " : private ] = > <nl> int ( 0 ) <nl> Break at main ( ) on line 58 of % s / flow_multistep . php <nl> <nl> continue <nl> int ( 46 ) <nl> - C1 destructor ! <nl> - C2 destructor <nl> - C1 oh hai <nl> - C1 destructor ! <nl> - C2 destructor done <nl> Program % s / flow_multistep . php exited normally . <nl> run <nl> C1 oh hai <nl> C2 oh hai <nl> C2 oh hai <nl> - C2 destructor <nl> - C1 oh hai <nl> - C1 destructor ! <nl> - C2 destructor done <nl> object ( C1 ) # 1 ( 1 ) { <nl> [ " x " : " C1 " : private ] = > <nl> int ( 0 ) <nl> Break at main ( ) on line 58 of % s / flow_multistep . php <nl> <nl> continue <nl> int ( 46 ) <nl> - C1 destructor ! <nl> - C2 destructor <nl> - C1 oh hai <nl> - C1 destructor ! <nl> - C2 destructor done <nl> Program % s / flow_multistep . php exited normally . <nl> break clear all <nl> All breakpoints are cleared . <nl> break clear all <nl> All breakpoints are cleared . <nl> step 12 <nl> C2 oh hai <nl> - C2 destructor <nl> - C1 oh hai <nl> - Break at C1 : : __destruct ( ) on line 30 of % s / flow_multistep . php <nl> - 29 public function __destruct ( ) { <nl> - 30 * echo " C1 destructor ! \ n " ; <nl> - 31 } <nl> - <nl> - out 2 <nl> - C1 destructor ! <nl> - C2 destructor done <nl> - Break at main ( ) on line 55 of % s / flow_multistep . php <nl> - 54 $ c2 = new C2 ( 6 ) ; <nl> - 55 * $ d = $ c1 ; <nl> - 56 $ c1 = null ; <nl> - <nl> - out <nl> object ( C1 ) # 1 ( 1 ) { <nl> [ " x " : " C1 " : private ] = > <nl> int ( 0 ) <nl> } <nl> - int ( 46 ) <nl> - C1 destructor ! <nl> - C2 destructor <nl> - C1 oh hai <nl> - C1 destructor ! <nl> - C2 destructor done <nl> - Break on line 61 of % s / flow_multistep . php <nl> - 60 <nl> - 61 * main ( ) ; <nl> - 62 <nl> + Break at d ( ) on line 17 of % s / flow_multistep . php <nl> + 16 function d ( $ a ) { <nl> + 17 * return $ a + 1 ; <nl> + 18 } <nl> + <nl> + out 2 <nl> + Break at b ( ) on line 9 of % s / flow_multistep . php <nl> + 8 function b ( $ a ) { <nl> + 9 * return c ( $ a ) + 1 ; <nl> + 10 } <nl> + <nl> + out <nl> + Break at a ( ) on line 5 of % s / flow_multistep . php <nl> + 4 function a ( $ a ) { <nl> + 5 * return b ( $ a ) + 1 ; <nl> + 6 } <nl> <nl> continue <nl> + int ( 46 ) <nl> Program % s / flow_multistep . php exited normally . <nl> break flow_multistep . php : 54 <nl> Breakpoint 1 set on line 54 of flow_multistep . php <nl> break clear all <nl> All breakpoints are cleared . <nl> step 12 <nl> C2 oh hai <nl> - C2 destructor <nl> - C1 oh hai <nl> - Break at C1 : : __destruct ( ) on line 30 of % s / flow_multistep . php <nl> - 29 public function __destruct ( ) { <nl> - 30 * echo " C1 destructor ! \ n " ; <nl> - 31 } <nl> + object ( C1 ) # 1 ( 1 ) { <nl> + [ " x " : " C1 " : private ] = > <nl> + int ( 0 ) <nl> + } <nl> + Break at d ( ) on line 17 of % s / flow_multistep . php <nl> + 16 function d ( $ a ) { <nl> + 17 * return $ a + 1 ; <nl> + 18 } <nl> <nl> next 5 <nl> - C1 destructor ! <nl> - C2 destructor done <nl> - Break at main ( ) on line 54 of % s / flow_multistep . php <nl> - 53 $ c2 = new C2 ( 5 ) ; <nl> - 54 * $ c2 = new C2 ( 6 ) ; <nl> - 55 $ d = $ c1 ; <nl> + int ( 46 ) <nl> + Break at main ( ) on line 59 of % s / flow_multistep . php <nl> + 58 var_dump ( a ( 42 ) ) ; <nl> + 59 * } <nl> + 60 <nl> <nl> next <nl> - Break at main ( ) on line 55 of % s / flow_multistep . php <nl> - 54 $ c2 = new C2 ( 6 ) ; <nl> - 55 * $ d = $ c1 ; <nl> - 56 $ c1 = null ; <nl> + Break on line 61 of % s / flow_multistep . php <nl> + 60 <nl> + 61 * main ( ) ; <nl> + 62 ( END ) <nl> <nl> continue <nl> - object ( C1 ) # 1 ( 1 ) { <nl> - [ " x " : " C1 " : private ] = > <nl> - int ( 0 ) <nl> - } <nl> - int ( 46 ) <nl> - C1 destructor ! <nl> - C2 destructor <nl> - C1 oh hai <nl> - C1 destructor ! <nl> - C2 destructor done <nl> Program % s / flow_multistep . php exited normally . <nl> quit <nl> deleted file mode 100644 <nl> index 49ab5322889 . . 00000000000 <nl> mmm a / hphp / test / quick / decrefstack1 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class MyDerivedClass { <nl> - public function __construct ( ) { <nl> - echo " __construct \ n " ; <nl> - } <nl> - public function __destruct ( ) { <nl> - echo " __destruct \ n " ; <nl> - } <nl> - <nl> - public static function callNew ( ) { <nl> - echo " before \ n " ; <nl> - new self ( " called via PARENT " ) ; <nl> - echo " after \ n " ; <nl> - } <nl> - <nl> - } <nl> - $ o = MyDerivedClass : : callNew ( ) ; <nl> - <nl> - echo " Done \ n " ; <nl> deleted file mode 100644 <nl> index 8ac7afd1f2a . . 00000000000 <nl> mmm a / hphp / test / quick / decrefstack1 . php . expect <nl> ppp / dev / null <nl> <nl> - before <nl> - __construct <nl> - __destruct <nl> - after <nl> - Done <nl> deleted file mode 100644 <nl> index db8f37e087f . . 00000000000 <nl> mmm a / hphp / test / quick / destruct . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class C { <nl> - <nl> - public function bluh ( ) { <nl> - global $ x ; <nl> - $ x = null ; <nl> - } <nl> - <nl> - public function __destruct ( ) { <nl> - print " In C : : __destruct ( ) \ n " ; <nl> - } <nl> - } <nl> - <nl> - function foo ( ) { <nl> - $ c = new C ; <nl> - } <nl> - <nl> - function main ( ) { <nl> - print " Test begin \ n " ; <nl> - <nl> - foo ( ) ; <nl> - <nl> - / / Tricky case : $ this is the last reference <nl> - $ x = new C ; <nl> - $ x - > bluh ( ) ; <nl> - <nl> - print " Test end \ n " ; <nl> - } <nl> - main ( ) ; <nl> deleted file mode 100644 <nl> index 9a843fde384 . . 00000000000 <nl> mmm a / hphp / test / quick / destruct . php . expect <nl> ppp / dev / null <nl> <nl> - Test begin <nl> - In C : : __destruct ( ) <nl> - Test end <nl> - In C : : __destruct ( ) <nl> deleted file mode 100644 <nl> index 8e1e799b585 . . 00000000000 <nl> mmm a / hphp / test / quick / destruct_segfault . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class A { <nl> - <nl> - public static function factory ( ) { <nl> - return new A ; <nl> - } <nl> - <nl> - public static function b ( ) { <nl> - return ' no segfault ' ; <nl> - } <nl> - <nl> - public function __destruct ( ) { <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - echo A : : factory ( ) - > b ( ) ; <nl> - } <nl> - main ( ) ; <nl> deleted file mode 100644 <nl> index d115e2bbe9f . . 00000000000 <nl> mmm a / hphp / test / quick / destruct_segfault . php . expect <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - no segfault <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 7a672e53d81 . . 00000000000 <nl> mmm a / hphp / test / quick / destructed_this . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - function id ( $ x ) { return $ x ; } <nl> - <nl> - class Foo { <nl> - public function hi ( ) { <nl> - $ bad = new Tracer ( ) ; <nl> - return $ bad ! = = null ; <nl> - } <nl> - } <nl> - <nl> - class Tracer { <nl> - public function __destruct ( ) { <nl> - var_dump ( debug_backtrace ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - id ( new Foo ( ) ) - > hi ( ) ; <nl> - } <nl> - main ( ) ; <nl> deleted file mode 100644 <nl> index 3507f5b1966 . . 00000000000 <nl> mmm a / hphp / test / quick / destructed_this . php . expectf <nl> ppp / dev / null <nl> <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - array ( 7 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 8 ) <nl> - [ " function " ] = > <nl> - string ( 10 ) " __destruct " <nl> - [ " class " ] = > <nl> - string ( 6 ) " Tracer " <nl> - [ " object " ] = > <nl> - object ( Tracer ) # 2 ( 0 ) { <nl> - } <nl> - [ " type " ] = > <nl> - string ( 2 ) " - > " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - [ 1 ] = > <nl> - array ( 6 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 19 ) <nl> - [ " function " ] = > <nl> - string ( 2 ) " hi " <nl> - [ " class " ] = > <nl> - string ( 3 ) " Foo " <nl> - [ " type " ] = > <nl> - string ( 2 ) " : : " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - [ 2 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 21 ) <nl> - [ " function " ] = > <nl> - string ( 4 ) " main " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 6b5c0cdfa46 . . 00000000000 <nl> mmm a / hphp / test / quick / destructed_this . php . opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vEval . HHIREnableGenTimeInlining = 0 <nl> mmm a / hphp / test / quick / dict / apc . php <nl> ppp b / hphp / test / quick / dict / apc . php <nl> function __wakeup ( ) { <nl> } <nl> } <nl> <nl> - class Dtor { <nl> - public $ val ; <nl> - <nl> - function __construct ( $ val ) { <nl> - $ this - > val = $ val ; <nl> - } <nl> - <nl> - function __destruct ( ) { <nl> - echo " Dtor . . . " . $ this - > val . " \ n " ; <nl> - } <nl> - } <nl> - <nl> function get_count ( ) { <nl> $ count = apc_fetch ( " count " ) ; <nl> if ( ! $ count ) { <nl> function read ( ) { <nl> var_dump ( $ e - > getMessage ( ) ) ; <nl> } <nl> <nl> - try { <nl> - var_dump ( apc_fetch ( " val10 " ) ) ; <nl> - } catch ( Exception $ e ) { <nl> - var_dump ( $ e - > getMessage ( ) ) ; <nl> - } <nl> - <nl> var_dump ( apc_fetch ( " val11 " ) ) ; <nl> } <nl> <nl> function write ( $ count ) { <nl> <nl> apc_store ( " val8 " , dict [ 123 = > new Wakeup ] ) ; <nl> apc_store ( " val9 " , dict [ " 456 " = > new WakeupThrow ] ) ; <nl> - apc_store ( " val10 " , dict [ 1 = > new Dtor ( 1 ) , 2 = > new WakeupThrow , 3 = > new Dtor ( 2 ) ] ) ; <nl> apc_store ( " val11 " , dict [ ' abc ' = > new Sleep ( 123 ) ] ) ; <nl> } <nl> <nl> mmm a / hphp / test / quick / dict / apc . php . expectf <nl> ppp b / hphp / test / quick / dict / apc . php . expectf <nl> bool ( false ) <nl> bool ( false ) <nl> bool ( false ) <nl> bool ( false ) <nl> - bool ( false ) <nl> - Dtor . . . 1 <nl> - Dtor . . . 2 <nl> Sleep . . . <nl> dict ( 0 ) { <nl> } <nl> dict ( 1 ) { <nl> } <nl> } <nl> string ( 16 ) " Wakeup exception " <nl> - Dtor . . . 1 <nl> - string ( 16 ) " Wakeup exception " <nl> dict ( 1 ) { <nl> [ " abc " ] = > <nl> - object ( Sleep ) # 13 ( 1 ) { <nl> + object ( Sleep ) # 8 ( 1 ) { <nl> [ " val " ] = > <nl> NULL <nl> } <nl> dict ( 1 ) { <nl> } <nl> } <nl> string ( 16 ) " Wakeup exception " <nl> - Dtor . . . 1 <nl> - string ( 16 ) " Wakeup exception " <nl> dict ( 1 ) { <nl> [ " abc " ] = > <nl> - object ( Sleep ) # 8 ( 1 ) { <nl> + object ( Sleep ) # 5 ( 1 ) { <nl> [ " val " ] = > <nl> NULL <nl> } <nl> } <nl> - Dtor . . . 1 <nl> - Dtor . . . 2 <nl> Sleep . . . <nl> dict ( 0 ) { <nl> } <nl> dict ( 1 ) { <nl> } <nl> } <nl> string ( 16 ) " Wakeup exception " <nl> - Dtor . . . 1 <nl> - string ( 16 ) " Wakeup exception " <nl> dict ( 1 ) { <nl> [ " abc " ] = > <nl> - object ( Sleep ) # 19 ( 1 ) { <nl> + object ( Sleep ) # 11 ( 1 ) { <nl> [ " val " ] = > <nl> NULL <nl> } <nl> mmm a / hphp / test / quick / dict / basic - init . php <nl> ppp b / hphp / test / quick / dict / basic - init . php <nl> function __toString ( ) { <nl> } <nl> } <nl> <nl> - class Noisy { <nl> - public $ id ; <nl> - function __construct ( $ id ) { <nl> - $ this - > id = $ id ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo $ this - > id . " Noisy : : __destruct ( ) \ n " ; <nl> - } <nl> - } <nl> - <nl> function create ( $ a , $ b , $ c , $ d ) { <nl> try { <nl> var_dump ( dict [ $ a = > $ b , $ c = > $ d ] ) ; <nl> function create ( $ a , $ b , $ c , $ d ) { <nl> } <nl> } <nl> <nl> - function create_noisy ( $ a , $ b , $ c , $ d ) { <nl> - try { <nl> - var_dump ( dict [ $ a = > new Noisy ( $ c ) , $ b = > new Noisy ( $ d ) ] ) ; <nl> - } catch ( Exception $ e ) { <nl> - echo " Exception : " . $ e - > getMessage ( ) . " \ n " ; <nl> - } <nl> - } <nl> - <nl> function main ( ) { <nl> / / These should succeed : <nl> var_dump ( dict [ ] ) ; <nl> function main ( ) { <nl> create ( ' abc ' , new stdclass , ' def ' , new stdclass ) ; <nl> create ( 100 , vec [ 1 , 2 , 3 ] , 200 , vec [ 4 , 5 , 6 ] ) ; <nl> create ( ' abc ' , null , ' def ' , 4 . 56 ) ; <nl> - create_noisy ( ' abc ' , ' abc ' , 1 , 2 ) ; <nl> <nl> / / These should fail : <nl> create ( null , ' a ' , null , ' b ' ) ; <nl> function main ( ) { <nl> create ( Vector { 1 , 2 , 3 } , 123 , Vector { 4 , 5 , 6 } , 456 ) ; <nl> create ( false , ' first ' , null , ' second ' ) ; <nl> create ( vec [ ] , ' first ' , dict [ ] , ' second ' ) ; <nl> - create_noisy ( 1 , [ ] , 3 , 4 ) ; <nl> - create_noisy ( false , true , 5 , 6 ) ; <nl> } <nl> <nl> main ( ) ; <nl> mmm a / hphp / test / quick / dict / basic - init . php . expect <nl> ppp b / hphp / test / quick / dict / basic - init . php . expect <nl> dict ( 2 ) { <nl> [ " def " ] = > <nl> float ( 4 . 56 ) <nl> } <nl> - 1 Noisy : : __destruct ( ) <nl> - dict ( 1 ) { <nl> - [ " abc " ] = > <nl> - object ( Noisy ) # 2 ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 2 ) <nl> - } <nl> - } <nl> - 2 Noisy : : __destruct ( ) <nl> Exception : Invalid dict key : expected a key of type int or string , null given <nl> Exception : Invalid dict key : expected a key of type int or string , bool given <nl> Exception : Invalid dict key : expected a key of type int or string , double given <nl> Exception : Invalid dict key : expected a key of type int or string , ToString give <nl> Exception : Invalid dict key : expected a key of type int or string , HH \ Vector given <nl> Exception : Invalid dict key : expected a key of type int or string , bool given <nl> Exception : Invalid dict key : expected a key of type int or string , vec given <nl> - 4 Noisy : : __destruct ( ) <nl> - 3 Noisy : : __destruct ( ) <nl> - Exception : Invalid dict key : expected a key of type int or string , array given <nl> - 5 Noisy : : __destruct ( ) <nl> - Exception : Invalid dict key : expected a key of type int or string , bool given <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . 4977cc25517 <nl> mmm / dev / null <nl> ppp b / hphp / test / quick / dict / convert . php . opts <nl> @ @ - 0 , 0 + 1 @ @ <nl> + - vEval . JitPGODecRefNZReleasePercentCOW = 0 - vEval . JitPGODecRefNZReleasePercent = 0 <nl> deleted file mode 100644 <nl> index 83cab4f8dd9 . . 00000000000 <nl> mmm a / hphp / test / quick / dict / dtor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> - <nl> - class Dtor { <nl> - public $ id ; <nl> - function __construct ( $ id ) { <nl> - $ this - > id = $ id ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo " Dtor : : __destruct ( " . $ this - > id . " ) \ n " ; <nl> - } <nl> - } <nl> - <nl> - function main ( $ a , $ b , $ c ) { <nl> - $ d = dict [ 1 = > new Dtor ( $ a ) , 2 = > new Dtor ( $ b ) , 3 = > new Dtor ( $ c ) ] ; <nl> - var_dump ( $ d ) ; <nl> - } <nl> - main ( 1 , 2 , 3 ) ; <nl> deleted file mode 100644 <nl> index 8749c2afcd6 . . 00000000000 <nl> mmm a / hphp / test / quick / dict / dtor . php . expect <nl> ppp / dev / null <nl> <nl> - dict ( 3 ) { <nl> - [ 1 ] = > <nl> - object ( Dtor ) # 1 ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 1 ) <nl> - } <nl> - [ 2 ] = > <nl> - object ( Dtor ) # 2 ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 2 ) <nl> - } <nl> - [ 3 ] = > <nl> - object ( Dtor ) # 3 ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 3 ) <nl> - } <nl> - } <nl> - Dtor : : __destruct ( 1 ) <nl> - Dtor : : __destruct ( 2 ) <nl> - Dtor : : __destruct ( 3 ) <nl> mmm a / hphp / test / quick / dict / serialize . php <nl> ppp b / hphp / test / quick / dict / serialize . php <nl> function __wakeup ( ) { <nl> } <nl> } <nl> <nl> - class Dtor { <nl> - public $ id ; <nl> - function __construct ( $ id ) { <nl> - $ this - > id = $ id ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo " Dtor : : __destruct ( ) : " . $ this - > id . " \ n " ; <nl> - } <nl> - } <nl> - <nl> function roundtrip ( $ d ) { <nl> echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> var_dump ( $ d ) ; <nl> function main ( ) { <nl> <nl> / / Duplicate keys <nl> try_unserialize ( " D : 2 : { i : 1 ; i : 123 ; i : 1 ; i : 456 ; } " ) ; <nl> - try_unserialize ( " D : 2 : { i : 1 ; O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 1 ; } i : 1 ; i : 456 ; } " ) ; <nl> <nl> / / Recursive data structures <nl> try_unserialize ( " D : 1 : { i : 1 ; O : 8 : \ " stdClass \ " : 1 : { s : 3 : \ " val \ " ; a : 1 : { i : 1 ; r : 2 ; } } } " ) ; <nl> function main ( ) { <nl> <nl> try_serialize ( dict [ 1 = > new SleepThrow ] ) ; <nl> try_unserialize ( " D : 1 : { i : 123 ; O : 11 : \ " WakeupThrow \ " : 0 : { } } " ) ; <nl> - <nl> - / / Ensure propert dtors run <nl> - try_unserialize ( " D : 3 : { i : 1 ; O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 1 ; } i : 2 ; O : 11 : \ " WakeupThrow \ " : 0 : { } i : 3 ; O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 2 ; } } " ) ; <nl> - try_unserialize ( " D : 3 : { i : 1 ; O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 1 ; } b : 0 ; s : 3 : \ " abc \ " ; i : 3 ; O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 2 ; } } " ) ; <nl> } <nl> <nl> main ( ) ; <nl> mmm a / hphp / test / quick / dict / serialize . php . expectf <nl> ppp b / hphp / test / quick / dict / serialize . php . expectf <nl> dict ( 1 ) { <nl> int ( 456 ) <nl> } <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - string ( 48 ) " D : 2 : { i : 1 ; O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } i : 1 ; i : 456 ; } " <nl> - Dtor : : __destruct ( ) : 1 <nl> - dict ( 1 ) { <nl> - [ 1 ] = > <nl> - int ( 456 ) <nl> - } <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> string ( 53 ) " D : 1 : { i : 1 ; O : 8 : " stdClass " : 1 : { s : 3 : " val " ; a : 1 : { i : 1 ; r : 2 ; } } } " <nl> dict ( 1 ) { <nl> [ 1 ] = > <nl> Serialize exception : Sleep exception <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> string ( 35 ) " D : 1 : { i : 123 ; O : 11 : " WakeupThrow " : 0 : { } } " <nl> Unserialize exception : Wakeup exception <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - string ( 97 ) " D : 3 : { i : 1 ; O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } i : 2 ; O : 11 : " WakeupThrow " : 0 : { } i : 3 ; O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 2 ; } } " <nl> - Dtor : : __destruct ( ) : 1 <nl> - Dtor : : __destruct ( ) : 2 <nl> - Unserialize exception : Wakeup exception <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - string ( 84 ) " D : 3 : { i : 1 ; O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } b : 0 ; s : 3 : " abc " ; i : 3 ; O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 2 ; } } " <nl> - Dtor : : __destruct ( ) : 1 <nl> - <nl> - Notice : Unable to unserialize : [ D : 3 : { i : 1 ; O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } b : 0 ; s : 3 : " abc " ; i : 3 ; O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 2 ; } } ] . Invalid key . in % s on line % d <nl> - bool ( false ) <nl> \ No newline at end of file <nl> mmm a / hphp / test / quick / dict / unset . php <nl> ppp b / hphp / test / quick / dict / unset . php <nl> <nl> < ? hh <nl> <nl> - class Dtor { <nl> - function __destruct ( ) { <nl> - echo " Dtor : : __destruct \ n " ; <nl> - } <nl> - } <nl> - <nl> function main ( ) { <nl> $ e = dict [ ] ; <nl> $ one = dict [ 1 = > " bar " ] ; <nl> function main ( ) { <nl> unset ( $ two [ " 1 " ] ) ; <nl> unset ( $ three [ ' not - there ' ] ) ; <nl> var_dump ( $ e , $ one , $ two , $ three ) ; <nl> - <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - $ four = dict [ 1 = > ' a ' , ' 2 ' = > new Dtor , 3 = > false ] ; <nl> - unset ( $ four [ ' 2 ' ] ) ; <nl> - var_dump ( $ four ) ; <nl> } <nl> <nl> main ( ) ; <nl> mmm a / hphp / test / quick / dict / unset . php . expect <nl> ppp b / hphp / test / quick / dict / unset . php . expect <nl> dict ( 2 ) { <nl> [ " c " ] = > <nl> string ( 1 ) " d " <nl> } <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Dtor : : __destruct <nl> - dict ( 2 ) { <nl> - [ 1 ] = > <nl> - string ( 1 ) " a " <nl> - [ 3 ] = > <nl> - bool ( false ) <nl> - } <nl> \ No newline at end of file <nl> mmm a / hphp / test / quick / dtor - on - arr . php <nl> ppp b / hphp / test / quick / dtor - on - arr . php <nl> <nl> < ? php <nl> <nl> class C { <nl> - function __destruct ( ) { <nl> - echo " woot - cakes \ n " ; <nl> - } <nl> } <nl> <nl> function f ( ) { <nl> function f ( ) { <nl> } <nl> <nl> f ( ) ; <nl> - <nl> mmm a / hphp / test / quick / dtor - on - arr . php . expect <nl> ppp b / hphp / test / quick / dtor - on - arr . php . expect <nl> @ @ - 1 , 2 + 1 @ @ <nl> - woot - cakes <nl> branch works <nl> mmm a / hphp / test / quick / exception_bug_2080454 . php <nl> ppp b / hphp / test / quick / exception_bug_2080454 . php <nl> <nl> < ? php <nl> <nl> - class Dtor { <nl> - public function __destruct ( ) { <nl> - echo " dtor \ n " ; <nl> - } <nl> - } <nl> - <nl> $ ar = array ( 1 , 3 , 2 ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> function case1 ( ) { foo ( ) ; } <nl> function foo2 ( ) { <nl> global $ ar ; <nl> foreach ( $ ar as $ y ) { <nl> - func ( 12 , new Dtor ( ) , mt_rand ( ) , blar ( $ y ) ? 1024 : - 1 ) ; <nl> + func ( 12 , new stdclass ( ) , mt_rand ( ) , blar ( $ y ) ? 1024 : - 1 ) ; <nl> } <nl> try { } catch ( Exception $ x ) { echo " Bad \ n " ; } <nl> } <nl> function case2 ( ) { foo2 ( ) ; } <nl> function foo3 ( ) { <nl> global $ ar ; <nl> foreach ( $ ar as $ y ) { <nl> - func ( 12 , new Dtor ( ) , mt_rand ( ) , func ( blar ( $ y ) ) ) ; <nl> + func ( 12 , new stdclass ( ) , mt_rand ( ) , func ( blar ( $ y ) ) ) ; <nl> } <nl> try { } catch ( Exception $ x ) { echo " Bad \ n " ; } <nl> } <nl> function case3 ( ) { foo3 ( ) ; } <nl> function foo4 ( ) { <nl> global $ ar ; <nl> foreach ( $ ar as $ y ) { <nl> - func ( 12 , new Dtor ( ) , mt_rand ( ) , func ( mt_rand ( ) , blar ( $ y ) ) ) ; <nl> + func ( 12 , new stdclass ( ) , mt_rand ( ) , func ( mt_rand ( ) , blar ( $ y ) ) ) ; <nl> } <nl> try { } catch ( Exception $ x ) { echo " Bad \ n " ; } <nl> } <nl> function case4 ( ) { foo3 ( ) ; } <nl> try { case2 ( ) ; } catch ( Exception $ x ) { echo " Good2 \ n " ; } <nl> try { case3 ( ) ; } catch ( Exception $ x ) { echo " Good3 \ n " ; } <nl> try { case4 ( ) ; } catch ( Exception $ x ) { echo " Good4 \ n " ; } <nl> - echo " Done \ n " ; <nl> \ No newline at end of file <nl> + echo " Done \ n " ; <nl> mmm a / hphp / test / quick / exception_bug_2080454 . php . expect <nl> ppp b / hphp / test / quick / exception_bug_2080454 . php . expect <nl> <nl> Good1 <nl> - dtor <nl> Good2 <nl> - dtor <nl> Good3 <nl> - dtor <nl> Good4 <nl> Done <nl> deleted file mode 100644 <nl> index 1222681ac73 . . 00000000000 <nl> mmm a / hphp / test / quick / exception_destructor_1 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - / / Copyright 2004 - 2015 Facebook . All Rights Reserved . <nl> - <nl> - / / Test behavior around exceptions leaking out of destructors . <nl> - / / Specifically , fatals vs . user exceptions . <nl> - <nl> - class Ex1 extends Exception { <nl> - } <nl> - <nl> - class Ex2 extends Exception { <nl> - } <nl> - <nl> - class ThrowDestruct1 { <nl> - public function __destruct ( ) { <nl> - printf ( " In ThrowDestruct1 : : __destruct ( ) \ n " ) ; <nl> - throw new Ex1 ( ' Exception leaked out of ThrowDestruct1 : : __destruct ( ) ' ) ; <nl> - } <nl> - } <nl> - <nl> - class ThrowDestruct2 { <nl> - public function __destruct ( ) { <nl> - printf ( " In ThrowDestruct2 : : __destruct ( ) \ n " ) ; <nl> - throw new Ex2 ( ' Exception leaked out of ThrowDestruct2 : : __destruct ( ) ' ) ; <nl> - } <nl> - } <nl> - <nl> - class ExitDestruct { <nl> - public function __destruct ( ) { <nl> - printf ( " In ExitDestruct : : __destruct ( ) \ n " ) ; <nl> - exit ( ) ; <nl> - } <nl> - } <nl> - <nl> - function bar ( ) { <nl> - $ td2 = new ThrowDestruct2 ; <nl> - <nl> - / / The exit ( ) in ExitDestruct : : __destruct ( ) should prevent the destructor <nl> - / / for $ td2 from running , as well as any up - stack destructors . <nl> - $ ed = new ExitDestruct ; <nl> - } <nl> - <nl> - function foo ( ) { <nl> - $ td1 = new ThrowDestruct1 ; <nl> - printf ( " Calling bar ( ) \ n " ) ; <nl> - bar ( ) ; <nl> - printf ( " After bar ( ) \ n " ) ; <nl> - } <nl> - <nl> - function printPreviousExceptions ( $ e ) { <nl> - $ i = 0 ; <nl> - <nl> - while ( $ e = $ e - > getPrevious ( ) ) { <nl> - printf ( " \ tPrevious # % d : % s \ n " , + + $ i , $ e - > getMessage ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - printf ( " main ( ) starting \ n " ) ; <nl> - <nl> - try { <nl> - printf ( " Calling foo ( ) \ n " ) ; <nl> - foo ( ) ; <nl> - printf ( " After foo ( ) \ n " ) ; <nl> - } <nl> - catch ( Exception $ e ) { <nl> - printf ( " Caught % s in main ( ) \ n " , $ e - > getMessage ( ) ) ; <nl> - printPreviousExceptions ( $ e ) ; <nl> - } <nl> - <nl> - printf ( " main ( ) ending \ n " ) ; <nl> - } <nl> - <nl> - printf ( " Calling main ( ) \ n " ) ; <nl> - main ( ) ; <nl> - printf ( " Returned from main ( ) , exiting \ n " ) ; <nl> deleted file mode 100644 <nl> index e7a6d41306c . . 00000000000 <nl> mmm a / hphp / test / quick / exception_destructor_1 . php . expect <nl> ppp / dev / null <nl> <nl> - Calling main ( ) <nl> - main ( ) starting <nl> - Calling foo ( ) <nl> - Calling bar ( ) <nl> - In ExitDestruct : : __destruct ( ) <nl> deleted file mode 100644 <nl> index 4ca8fbb4fd8 . . 00000000000 <nl> mmm a / hphp / test / quick / exception_destructor_2 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - / / Copyright 2004 - 2015 Facebook . All Rights Reserved . <nl> - <nl> - / / Test behavior around exceptions leaking out of destructors . <nl> - / / Specifically , fatals vs . user exceptions . <nl> - <nl> - class Ex1 extends Exception { <nl> - } <nl> - <nl> - class Ex2 extends Exception { <nl> - } <nl> - <nl> - class ThrowDestruct1 { <nl> - public function __destruct ( ) { <nl> - printf ( " In ThrowDestruct1 : : __destruct ( ) \ n " ) ; <nl> - throw new Ex1 ( ' Exception leaked out of ThrowDestruct1 : : __destruct ( ) ' ) ; <nl> - } <nl> - } <nl> - <nl> - class ThrowDestruct2 { <nl> - public function __destruct ( ) { <nl> - printf ( " In ThrowDestruct2 : : __destruct ( ) \ n " ) ; <nl> - throw new Ex2 ( ' Exception leaked out of ThrowDestruct2 : : __destruct ( ) ' ) ; <nl> - } <nl> - } <nl> - <nl> - class ExitDestruct { <nl> - public function __destruct ( ) { <nl> - printf ( " In ExitDestruct : : __destruct ( ) \ n " ) ; <nl> - exit ( ) ; <nl> - } <nl> - } <nl> - <nl> - function bar ( ) { <nl> - $ td2 = new ThrowDestruct2 ; <nl> - <nl> - / / This exit ( ) should prevent the destructor <nl> - / / for $ td2 from running , as well as any up - stack destructors . <nl> - exit ( ) ; <nl> - } <nl> - <nl> - function foo ( ) { <nl> - $ td1 = new ThrowDestruct1 ; <nl> - printf ( " Calling bar ( ) \ n " ) ; <nl> - bar ( ) ; <nl> - printf ( " After bar ( ) \ n " ) ; <nl> - } <nl> - <nl> - function printPreviousExceptions ( $ e ) { <nl> - $ i = 0 ; <nl> - <nl> - while ( $ e = $ e - > getPrevious ( ) ) { <nl> - printf ( " \ tPrevious # % d : % s \ n " , + + $ i , $ e - > getMessage ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - printf ( " main ( ) starting \ n " ) ; <nl> - <nl> - try { <nl> - printf ( " Calling foo ( ) \ n " ) ; <nl> - foo ( ) ; <nl> - printf ( " After foo ( ) \ n " ) ; <nl> - } <nl> - catch ( Exception $ e ) { <nl> - printf ( " Caught % s in main ( ) \ n " , $ e - > getMessage ( ) ) ; <nl> - printPreviousExceptions ( $ e ) ; <nl> - } <nl> - <nl> - printf ( " main ( ) ending \ n " ) ; <nl> - } <nl> - <nl> - printf ( " Calling main ( ) \ n " ) ; <nl> - main ( ) ; <nl> - printf ( " Returned from main ( ) , exiting \ n " ) ; <nl> deleted file mode 100644 <nl> index 56eb6d4715f . . 00000000000 <nl> mmm a / hphp / test / quick / exception_destructor_2 . php . expect <nl> ppp / dev / null <nl> <nl> - Calling main ( ) <nl> - main ( ) starting <nl> - Calling foo ( ) <nl> - Calling bar ( ) <nl> deleted file mode 100644 <nl> index 9f7f52d7ccc . . 00000000000 <nl> mmm a / hphp / test / quick / exception_destructor_3 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - / / Copyright 2004 - 2015 Facebook . All Rights Reserved . <nl> - <nl> - / / Test behavior around exceptions leaking out of destructors . <nl> - / / Specifically , fatals vs . user exceptions . <nl> - <nl> - class Ex1 extends Exception { <nl> - } <nl> - <nl> - class Ex2 extends Exception { <nl> - } <nl> - <nl> - class ThrowDestruct1 { <nl> - public function __destruct ( ) { <nl> - printf ( " In ThrowDestruct1 : : __destruct ( ) \ n " ) ; <nl> - throw new Ex1 ( ' Exception leaked out of ThrowDestruct1 : : __destruct ( ) ' ) ; <nl> - } <nl> - } <nl> - <nl> - class ThrowDestruct2 { <nl> - public function __destruct ( ) { <nl> - printf ( " In ThrowDestruct2 : : __destruct ( ) \ n " ) ; <nl> - throw new Ex2 ( ' Exception leaked out of ThrowDestruct2 : : __destruct ( ) ' ) ; <nl> - } <nl> - } <nl> - <nl> - class ExitDestruct { <nl> - public function __destruct ( ) { <nl> - printf ( " In ExitDestruct : : __destruct ( ) \ n " ) ; <nl> - exit ( ) ; <nl> - } <nl> - } <nl> - <nl> - function bar ( ) { <nl> - $ td2 = new ThrowDestruct2 ; <nl> - <nl> - } <nl> - <nl> - function foo ( ) { <nl> - $ td1 = new ThrowDestruct1 ; <nl> - <nl> - printf ( " Calling bar ( ) \ n " ) ; <nl> - bar ( ) ; <nl> - printf ( " After bar ( ) \ n " ) ; <nl> - <nl> - / / This exit ( ) should prevent the destructor <nl> - / / for $ td1 from running , as well as any up - stack destructors . <nl> - exit ( ) ; <nl> - } <nl> - <nl> - function printPreviousExceptions ( $ e ) { <nl> - $ i = 0 ; <nl> - <nl> - while ( $ e = $ e - > getPrevious ( ) ) { <nl> - printf ( " \ tPrevious # % d : % s \ n " , + + $ i , $ e - > getMessage ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - printf ( " main ( ) starting \ n " ) ; <nl> - <nl> - try { <nl> - printf ( " Calling foo ( ) \ n " ) ; <nl> - foo ( ) ; <nl> - printf ( " After foo ( ) \ n " ) ; <nl> - } <nl> - catch ( Exception $ e ) { <nl> - printf ( " Caught % s in main ( ) \ n " , $ e - > getMessage ( ) ) ; <nl> - printPreviousExceptions ( $ e ) ; <nl> - } <nl> - <nl> - printf ( " main ( ) ending \ n " ) ; <nl> - } <nl> - <nl> - printf ( " Calling main ( ) \ n " ) ; <nl> - main ( ) ; <nl> - printf ( " Returned from main ( ) , exiting \ n " ) ; <nl> deleted file mode 100644 <nl> index e4c26fc582d . . 00000000000 <nl> mmm a / hphp / test / quick / exception_destructor_3 . php . expectf <nl> ppp / dev / null <nl> <nl> - Calling main ( ) <nl> - main ( ) starting <nl> - Calling foo ( ) <nl> - Calling bar ( ) <nl> - In ThrowDestruct2 : : __destruct ( ) <nl> - <nl> - Warning : Destructor threw an object exception : exception ' Ex2 ' with message ' Exception leaked out of ThrowDestruct2 : : __destruct ( ) ' in % s / test / quick / exception_destructor_3 . php : 23 <nl> - Stack trace : <nl> - # 0 % s / test / quick / exception_destructor_3 . php ( % d ) : ThrowDestruct2 - > __destruct ( ) <nl> - # 1 % s / test / quick / exception_destructor_3 . php ( 43 ) : bar ( ) <nl> - # 2 % s / test / quick / exception_destructor_3 . php ( 64 ) : foo ( ) <nl> - # 3 % s / test / quick / exception_destructor_3 . php ( 76 ) : main ( ) <nl> - # 4 { main } in % s / test / quick / exception_destructor_3 . php on line % d <nl> - After bar ( ) <nl> deleted file mode 100644 <nl> index ee246340375 . . 00000000000 <nl> mmm a / hphp / test / quick / exception_destructor_4 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - / / Copyright 2004 - 2015 Facebook . All Rights Reserved . <nl> - <nl> - / / Test behavior around exceptions leaking out of destructors . <nl> - / / Specifically , fatals vs . user exceptions . <nl> - <nl> - class Ex1 extends Exception { <nl> - } <nl> - <nl> - class Ex2 extends Exception { <nl> - } <nl> - <nl> - class ThrowDestruct1 { <nl> - public function __destruct ( ) { <nl> - printf ( " In ThrowDestruct1 : : __destruct ( ) \ n " ) ; <nl> - throw new Ex1 ( ' Exception leaked out of ThrowDestruct1 : : __destruct ( ) ' ) ; <nl> - } <nl> - } <nl> - <nl> - class ThrowDestruct2 { <nl> - public function __destruct ( ) { <nl> - printf ( " In ThrowDestruct2 : : __destruct ( ) \ n " ) ; <nl> - throw new Ex2 ( ' Exception leaked out of ThrowDestruct2 : : __destruct ( ) ' ) ; <nl> - } <nl> - } <nl> - <nl> - class ExitDestruct { <nl> - public function __destruct ( ) { <nl> - printf ( " In ExitDestruct : : __destruct ( ) \ n " ) ; <nl> - exit ( ) ; <nl> - } <nl> - } <nl> - <nl> - function bar ( ) { <nl> - $ td2 = new ThrowDestruct2 ; <nl> - / / The exit ( ) in ExitDestruct : : __destruct ( ) should prevent the destructor <nl> - / / for $ td2 from running , as well as any up - stack destructors . <nl> - $ ed = new ExitDestruct ; <nl> - printf ( " Throwing in bar ( ) \ n " ) ; <nl> - throw new Exception ( ' Exception from bar ( ) ' ) ; <nl> - } <nl> - <nl> - function foo ( ) { <nl> - $ td1 = new ThrowDestruct1 ; <nl> - printf ( " Calling bar ( ) \ n " ) ; <nl> - bar ( ) ; <nl> - printf ( " After bar ( ) \ n " ) ; <nl> - } <nl> - <nl> - function printPreviousExceptions ( $ e ) { <nl> - $ i = 0 ; <nl> - <nl> - while ( $ e = $ e - > getPrevious ( ) ) { <nl> - printf ( " \ tPrevious # % d : % s \ n " , + + $ i , $ e - > getMessage ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - printf ( " main ( ) starting \ n " ) ; <nl> - <nl> - try { <nl> - printf ( " Calling foo ( ) \ n " ) ; <nl> - foo ( ) ; <nl> - printf ( " After foo ( ) \ n " ) ; <nl> - } <nl> - catch ( Exception $ e ) { <nl> - printf ( " Caught % s in main ( ) \ n " , $ e - > getMessage ( ) ) ; <nl> - printPreviousExceptions ( $ e ) ; <nl> - } <nl> - <nl> - printf ( " main ( ) ending \ n " ) ; <nl> - } <nl> - <nl> - printf ( " Calling main ( ) \ n " ) ; <nl> - main ( ) ; <nl> - printf ( " Returned from main ( ) , exiting \ n " ) ; <nl> deleted file mode 100644 <nl> index 4e53f2677f2 . . 00000000000 <nl> mmm a / hphp / test / quick / exception_destructor_4 . php . expectf <nl> ppp / dev / null <nl> <nl> - Calling main ( ) <nl> - main ( ) starting <nl> - Calling foo ( ) <nl> - Calling bar ( ) <nl> - Throwing in bar ( ) <nl> - In ExitDestruct : : __destruct ( ) <nl> - <nl> - Fatal error : Uncaught exception ' Exception ' with message ' Exception from bar ( ) ' in % s / test / quick / exception_destructor_4 . php : 40 <nl> - Stack trace : <nl> - # 0 % s / test / quick / exception_destructor_4 . php ( 46 ) : bar ( ) <nl> - # 1 % s / test / quick / exception_destructor_4 . php ( 63 ) : foo ( ) <nl> - # 2 % s / test / quick / exception_destructor_4 . php ( 75 ) : main ( ) <nl> - # 3 { main } <nl> deleted file mode 100644 <nl> index 580da024de3 . . 00000000000 <nl> mmm a / hphp / test / quick / exception_destructor_5 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - / / Copyright 2004 - 2015 Facebook . All Rights Reserved . <nl> - <nl> - / / Test behavior around exceptions leaking out of destructors . <nl> - / / Specifically , fatals vs . user exceptions . <nl> - <nl> - class Ex1 extends Exception { <nl> - } <nl> - <nl> - class Ex2 extends Exception { <nl> - } <nl> - <nl> - class ThrowDestruct1 { <nl> - public function __destruct ( ) { <nl> - printf ( " In ThrowDestruct1 : : __destruct ( ) \ n " ) ; <nl> - throw new Ex1 ( ' Exception leaked out of ThrowDestruct1 : : __destruct ( ) ' ) ; <nl> - } <nl> - } <nl> - <nl> - class ThrowDestruct2 { <nl> - public function __destruct ( ) { <nl> - printf ( " In ThrowDestruct2 : : __destruct ( ) \ n " ) ; <nl> - throw new Ex2 ( ' Exception leaked out of ThrowDestruct2 : : __destruct ( ) ' ) ; <nl> - } <nl> - } <nl> - <nl> - class ExitDestruct { <nl> - public function __destruct ( ) { <nl> - printf ( " In ExitDestruct : : __destruct ( ) \ n " ) ; <nl> - exit ( ) ; <nl> - } <nl> - } <nl> - <nl> - class Exiter { <nl> - public function __destruct ( ) { <nl> - printf ( " In Exiter : : __destruct ( ) \ n " ) ; <nl> - } <nl> - <nl> - public function doExit ( ) { <nl> - / / This exit ( ) should prevent the destructor for this clas from running , <nl> - / / as well as any up - stack destructors . <nl> - exit ( ) ; <nl> - } <nl> - } <nl> - <nl> - function bar ( ) { <nl> - $ td2 = new ThrowDestruct2 ; <nl> - ( new Exiter ( ) ) - > doExit ( ) ; <nl> - } <nl> - <nl> - function foo ( ) { <nl> - $ td1 = new ThrowDestruct1 ; <nl> - printf ( " Calling bar ( ) \ n " ) ; <nl> - bar ( ) ; <nl> - printf ( " After bar ( ) \ n " ) ; <nl> - } <nl> - <nl> - function printPreviousExceptions ( $ e ) { <nl> - $ i = 0 ; <nl> - <nl> - while ( $ e = $ e - > getPrevious ( ) ) { <nl> - printf ( " \ tPrevious # % d : % s \ n " , + + $ i , $ e - > getMessage ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - printf ( " main ( ) starting \ n " ) ; <nl> - <nl> - try { <nl> - printf ( " Calling foo ( ) \ n " ) ; <nl> - foo ( ) ; <nl> - printf ( " After foo ( ) \ n " ) ; <nl> - } <nl> - catch ( Exception $ e ) { <nl> - printf ( " Caught % s in main ( ) \ n " , $ e - > getMessage ( ) ) ; <nl> - printPreviousExceptions ( $ e ) ; <nl> - } <nl> - <nl> - printf ( " main ( ) ending \ n " ) ; <nl> - } <nl> - <nl> - printf ( " Calling main ( ) \ n " ) ; <nl> - main ( ) ; <nl> - printf ( " Returned from main ( ) , exiting \ n " ) ; <nl> deleted file mode 100644 <nl> index 56eb6d4715f . . 00000000000 <nl> mmm a / hphp / test / quick / exception_destructor_5 . php . expect <nl> ppp / dev / null <nl> <nl> - Calling main ( ) <nl> - main ( ) starting <nl> - Calling foo ( ) <nl> - Calling bar ( ) <nl> mmm a / hphp / test / quick / exception_many_locals . php <nl> ppp b / hphp / test / quick / exception_many_locals . php <nl> <nl> < ? php <nl> <nl> class c { <nl> - private static $ x = 0 ; <nl> - public function __destruct ( ) { <nl> - printf ( " c % d destructing \ n " , self : : $ x + + ) ; <nl> - } <nl> } <nl> <nl> function my_handler ( ) { <nl> mmm a / hphp / test / quick / exception_many_locals . php . expect <nl> ppp b / hphp / test / quick / exception_many_locals . php . expect <nl> Calling main ( ) <nl> Entering try <nl> Creating first c <nl> Creating second c <nl> - c 0 destructing <nl> Caught : whoops <nl> Returning from main <nl> - c 1 destructing <nl> Back from main ( ) <nl> deleted file mode 100644 <nl> index 7567bf9e671 . . 00000000000 <nl> mmm a / hphp / test / quick / exceptions2 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - function newobj ( ) { <nl> - return new C ; <nl> - } <nl> - global $ constructCount ; <nl> - global $ destructCount ; <nl> - class C { <nl> - public function __destruct ( ) { <nl> - global $ y ; <nl> - $ y = false ; <nl> - global $ destructCount ; <nl> - + + $ destructCount ; <nl> - } <nl> - public function g ( $ x , $ y , $ z ) { <nl> - return $ y ; <nl> - } <nl> - public function foo ( $ z ) { <nl> - global $ constructCount ; <nl> - + + $ constructCount ; <nl> - $ w1 = 1 ; <nl> - $ w2 = 2 ; <nl> - newobj ( ) - > g ( " hi " , $ w1 , 7 , 8 , $ w2 = $ this - > foo ( newobj ( ) ) ) ; <nl> - } <nl> - } <nl> - function bar ( ) { <nl> - $ obj = new C ; <nl> - newobj ( ) - > foo ( 123 ) ; <nl> - } <nl> - function onShutdown ( ) { <nl> - / / What we really want to know is that there were a reasonable <nl> - / / number of calls to the destructor . We count the objects we leave <nl> - / / on the stack , and expect the destruct count to be quite close to <nl> - / / that . <nl> - global $ constructCount ; <nl> - global $ destructCount ; <nl> - if ( abs ( $ destructCount - $ constructCount ) < 2 ) { <nl> - echo " Saw a reasonable number of calls to C : : __destruct ( ) \ n " ; <nl> - } else { <nl> - echo " Unexpected number of calls to C : : __destruct ( ) : $ destructCount \ n " ; <nl> - } <nl> - } <nl> - register_shutdown_function ( ' onShutdown ' ) ; <nl> - bar ( ) ; <nl> deleted file mode 100644 <nl> index 741310970d5 . . 00000000000 <nl> mmm a / hphp / test / quick / exceptions2 . php . expectf <nl> ppp / dev / null <nl> <nl> - <nl> - Fatal error : Stack overflow in % s / test / quick / exceptions2 . php on line % d <nl> - Saw a reasonable number of calls to C : : __destruct ( ) <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> deleted file mode 100644 <nl> index 04b92ad0ffc . . 00000000000 <nl> mmm a / hphp / test / quick / exceptions3 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - function newobj ( ) { <nl> - return new C ; <nl> - } <nl> - global $ constructCount ; <nl> - global $ destructCount ; <nl> - class C { <nl> - public function __destruct ( ) { <nl> - global $ destructCount ; <nl> - + + $ destructCount ; <nl> - } <nl> - public function g ( $ x , $ y , $ z ) { <nl> - return $ y ; <nl> - } <nl> - public function foo ( $ z ) { <nl> - global $ constructCount ; <nl> - + + $ constructCount ; <nl> - $ w2 = 2 ; <nl> - newobj ( ) - > g ( newobj ( ) , 7 , 8 , $ w2 = $ this - > foo ( newobj ( ) ) ) ; <nl> - } <nl> - } <nl> - function bar ( ) { <nl> - $ obj = new C ; <nl> - newobj ( ) - > foo ( 123 ) ; <nl> - } <nl> - function onShutdown ( ) { <nl> - / / What we really want to know is that there were a reasonable <nl> - / / number of calls to the destructor . We count the objects we leave <nl> - / / on the stack , and expect the destruct count to be quite close to <nl> - / / that . <nl> - global $ constructCount ; <nl> - global $ destructCount ; <nl> - if ( abs ( $ destructCount - $ constructCount ) < 2 ) { <nl> - echo " Saw a reasonable number of calls to C : : __destruct ( ) \ n " ; <nl> - } else { <nl> - echo " Unexpected number of calls to C : : __destruct ( ) : $ destructCount \ n " ; <nl> - } <nl> - } <nl> - register_shutdown_function ( ' onShutdown ' ) ; <nl> - bar ( ) ; <nl> deleted file mode 100644 <nl> index 61ebc708c98 . . 00000000000 <nl> mmm a / hphp / test / quick / exceptions3 . php . expectf <nl> ppp / dev / null <nl> <nl> - <nl> - Fatal error : Stack overflow in % s / test / quick / exceptions3 . php on line % d <nl> - Saw a reasonable number of calls to C : : __destruct ( ) <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> mmm a / hphp / test / quick / exceptions4 . php <nl> ppp b / hphp / test / quick / exceptions4 . php <nl> function __construct ( ) { <nl> } <nl> <nl> class B { <nl> - function __destruct ( ) { <nl> - throw new Exception ( ) ; <nl> - } <nl> } <nl> <nl> function foo ( $ a , $ b ) { <nl> mmm a / hphp / test / quick / exceptions4 . php . expectf <nl> ppp b / hphp / test / quick / exceptions4 . php . expectf <nl> <nl> <nl> - Warning : Destructor threw an object exception : exception ' Exception ' with message ' ' in % s / test / quick / exceptions4 . php : 11 <nl> - Stack trace : <nl> - # 0 % s / test / quick / exceptions4 . php ( 21 ) : B - > __destruct ( ) <nl> - # 1 { main } in % s / test / quick / exceptions4 . php on line 21 <nl> - <nl> Fatal error : Uncaught exception ' Exception ' with message ' ' in % s / test / quick / exceptions4 . php : 5 <nl> Stack trace : <nl> - # 0 % s / test / quick / exceptions4 . php ( 21 ) : A - > __construct ( ) <nl> + # 0 % s / test / quick / exceptions4 . php ( 18 ) : A - > __construct ( ) <nl> # 1 { main } <nl> mmm a / hphp / test / quick / exceptions5 . php <nl> ppp b / hphp / test / quick / exceptions5 . php <nl> <nl> < ? php <nl> - function g ( $ obj ) { <nl> - echo " g \ n " ; <nl> - $ obj - > yar ( 123 ) ; <nl> - } <nl> - class D { <nl> - public function yar ( $ y ) { <nl> - $ x = $ y ; <nl> - } <nl> - / / C + + exceptions , like stack overflow , now prevent further php code from <nl> - / / running . So this destructor should not run . <nl> - public function __destruct ( ) { <nl> - g ( $ this ) ; <nl> - } <nl> - } <nl> class C { <nl> public function baz ( $ z ) { <nl> return $ z = call_user_func ( array ( $ this , ' foo ' ) , $ z ) ; <nl> public function bar ( $ z ) { <nl> return $ z = call_user_func ( array ( $ this , ' baz ' ) , $ z ) ; <nl> } <nl> public function foo ( $ z ) { <nl> - $ guard = new D ; <nl> return $ z = call_user_func ( array ( $ this , ' bar ' ) , $ z ) ; <nl> } <nl> } <nl> mmm a / hphp / test / quick / exceptions6 . php <nl> ppp b / hphp / test / quick / exceptions6 . php <nl> <nl> < ? php <nl> - function g ( $ obj ) { <nl> - echo " g \ n " ; <nl> - $ obj - > yar ( 123 ) ; <nl> - } <nl> - class D { <nl> - public function yar ( $ y ) { <nl> - $ x = $ y ; <nl> - } <nl> - / / C + + exceptions , like stack overflow , now prevent further php code from <nl> - / / running . So this destructor should not run . <nl> - public function __destruct ( ) { <nl> - $ x = 1 ; <nl> - call_user_func ( ' g ' , $ this ) ; <nl> - } <nl> - } <nl> class C { <nl> public function baz ( $ z ) { <nl> - $ guard = new D ; <nl> $ x = 1 ; <nl> return $ z = call_user_func ( array ( $ this , ' foo ' ) , $ z ) ; <nl> } <nl> public function bar ( $ z ) { <nl> - $ guard = new D ; <nl> $ x = 1 ; <nl> return $ z = call_user_func ( array ( $ this , ' baz ' ) , $ z ) ; <nl> } <nl> public function foo ( $ z ) { <nl> - $ guard = new D ; <nl> $ x = 1 ; <nl> return $ z = call_user_func ( array ( $ this , ' bar ' ) , $ z ) ; <nl> } <nl> mmm a / hphp / test / quick / generator_vars . php <nl> ppp b / hphp / test / quick / generator_vars . php <nl> function __construct ( ) { <nl> $ this - > idx = self : : $ x + + ; <nl> printf ( " logger % d constructing \ n " , $ this - > idx ) ; <nl> } <nl> - function __destruct ( ) { <nl> - printf ( " logger % d destructing \ n " , $ this - > idx ) ; <nl> - } <nl> } <nl> <nl> function create ( ) { <nl> mmm a / hphp / test / quick / generator_vars . php . expectf <nl> ppp b / hphp / test / quick / generator_vars . php . expectf <nl> array ( 4 ) { <nl> [ " z " ] = > <nl> int ( 5 ) <nl> } <nl> - logger 0 destructing <nl> int ( 3735928559 ) <nl> array ( 5 ) { <nl> [ 0 ] = > <nl> deleted file mode 100644 <nl> index f03ec496194 . . 00000000000 <nl> mmm a / hphp / test / quick / global - obj - dtor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class C { <nl> - public function __destruct ( ) { <nl> - echo " C : : __destruct \ n " ; <nl> - global $ obj ; <nl> - var_dump ( $ obj ) ; <nl> - $ obj = 1 ; <nl> - echo " Leaving C : : __destruct \ n " ; <nl> - } <nl> - } <nl> - <nl> - class D { <nl> - public function __destruct ( ) { <nl> - echo " D : : __destruct \ n " ; <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - global $ obj ; <nl> - $ obj = new C ; <nl> - $ obj = new D ; <nl> - echo " * * * * \ n " ; <nl> - var_dump ( $ obj ) ; <nl> - } <nl> - <nl> - main ( ) ; <nl> deleted file mode 100644 <nl> index 42e18d61624 . . 00000000000 <nl> mmm a / hphp / test / quick / global - obj - dtor . php . expect <nl> ppp / dev / null <nl> <nl> - C : : __destruct <nl> - object ( D ) # 2 ( 0 ) { <nl> - } <nl> - Leaving C : : __destruct <nl> - D : : __destruct <nl> - * * * * <nl> - int ( 1 ) <nl> mmm a / hphp / test / quick / hhir_cgetm_exceptions . php <nl> ppp b / hphp / test / quick / hhir_cgetm_exceptions . php <nl> <nl> <nl> class Dtor { <nl> public function __construct ( ) { echo " hi \ n " ; } <nl> - public function __destruct ( ) { echo " ah \ n " ; } <nl> } <nl> <nl> class Something { <nl> function main ( ) { <nl> main ( ) ; <nl> } catch ( Exception $ x ) { <nl> echo " out \ n " ; <nl> - } <nl> \ No newline at end of file <nl> + } <nl> mmm a / hphp / test / quick / hhir_cgetm_exceptions . php . expect <nl> ppp b / hphp / test / quick / hhir_cgetm_exceptions . php . expect <nl> <nl> hi <nl> sup <nl> out <nl> - ah <nl> mmm a / hphp / test / quick / hopt - exit - ref1 . php <nl> ppp b / hphp / test / quick / hopt - exit - ref1 . php <nl> <nl> < ? php <nl> <nl> class C { <nl> - function __destruct ( ) { <nl> - echo " __destruct ! \ n " ; <nl> - } <nl> } <nl> <nl> function foo ( ) { <nl> mmm a / hphp / test / quick / hopt - exit - ref1 . php . expect <nl> ppp b / hphp / test / quick / hopt - exit - ref1 . php . expect <nl> @ @ - 1 , 2 + 1 @ @ <nl> not null <nl> - __destruct ! <nl> mmm a / hphp / test / quick / hopt - ret6 . php <nl> ppp b / hphp / test / quick / hopt - ret6 . php <nl> <nl> < ? php <nl> <nl> class C { <nl> - function __destruct ( ) { <nl> - echo " in __destruct \ n " ; <nl> - } <nl> function simpleRet ( ) { <nl> return 1 ; <nl> } <nl> mmm a / hphp / test / quick / hopt - ret6 . php . expect <nl> ppp b / hphp / test / quick / hopt - ret6 . php . expect <nl> <nl> object ( C ) # 1 ( 0 ) { <nl> } <nl> int ( 1 ) <nl> - in __destruct <nl> End <nl> mmm a / hphp / test / quick / hopt - ret7 . php <nl> ppp b / hphp / test / quick / hopt - ret7 . php <nl> <nl> < ? php <nl> <nl> class C { <nl> - function __destruct ( ) { <nl> - echo " in __destruct \ n " ; <nl> - } <nl> function simpleRet ( $ x ) { <nl> return 1 ; <nl> } <nl> mmm a / hphp / test / quick / hopt - ret7 . php . expect <nl> ppp b / hphp / test / quick / hopt - ret7 . php . expect <nl> <nl> object ( C ) # 1 ( 0 ) { <nl> } <nl> int ( 1 ) <nl> - in __destruct <nl> End <nl> mmm a / hphp / test / quick / hopt - ret8 . php <nl> ppp b / hphp / test / quick / hopt - ret8 . php <nl> <nl> < ? php <nl> <nl> class C { <nl> - function __destruct ( ) { <nl> - echo " in __destruct \ n " ; <nl> - } <nl> } <nl> <nl> function foo ( ) { <nl> mmm a / hphp / test / quick / hopt - ret8 . php . expect <nl> ppp b / hphp / test / quick / hopt - ret8 . php . expect <nl> @ @ - 1 , 2 + 1 @ @ <nl> - in __destruct <nl> End <nl> mmm a / hphp / test / quick / hopt - ret9 . php <nl> ppp b / hphp / test / quick / hopt - ret9 . php <nl> <nl> < ? php <nl> <nl> class C { <nl> - function __destruct ( ) { <nl> - echo " in __destruct \ n " ; <nl> - } <nl> } <nl> <nl> function foo ( ) { <nl> mmm a / hphp / test / quick / hopt - ret9 . php . expect <nl> ppp b / hphp / test / quick / hopt - ret9 . php . expect <nl> @ @ - 1 , 2 + 1 @ @ <nl> - in __destruct <nl> End <nl> mmm a / hphp / test / quick / hopt - translator_unwind . hhas <nl> ppp b / hphp / test / quick / hopt - translator_unwind . hhas <nl> <nl> RetC <nl> } <nl> <nl> - . method [ public ] __destruct ( ) { <nl> - String " dtor : " <nl> - This <nl> - BaseC 0 Warn <nl> - QueryM 1 CGet PT : " x " <nl> - Concat <nl> - String " \ n " <nl> - Concat <nl> - Print <nl> - RetC <nl> - } <nl> - <nl> . property [ private ] x ; <nl> } <nl> <nl> mmm a / hphp / test / quick / hopt - translator_unwind . hhas . expect <nl> ppp b / hphp / test / quick / hopt - translator_unwind . hhas . expect <nl> <nl> ctor : 0 <nl> ctor : 1 <nl> ctor : 2 <nl> - dtor : 2 <nl> - dtor : 1 <nl> - dtor : 0 <nl> Received exception : hi <nl> mmm a / hphp / test / quick / incdec - magic3 . php <nl> ppp b / hphp / test / quick / incdec - magic3 . php <nl> <nl> < ? php <nl> <nl> - class Dtor { public function __destruct ( ) { echo " Dtor \ n " ; } } <nl> - <nl> class Foo { <nl> public function __get ( $ x ) { <nl> var_dump ( " getter : " . $ x ) ; <nl> if ( $ x = = ' foo ' ) return 42 ; <nl> $ this - > foo + + ; <nl> - $ this - > asd = new Dtor ; <nl> + $ this - > asd = new stdclass ; <nl> } <nl> } <nl> <nl> mmm a / hphp / test / quick / incdec - magic3 . php . expect <nl> ppp b / hphp / test / quick / incdec - magic3 . php . expect <nl> <nl> string ( 11 ) " getter : asd " <nl> string ( 11 ) " getter : foo " <nl> - Dtor <nl> object ( Foo ) # 1 ( 2 ) { <nl> [ " foo " ] = > <nl> int ( 43 ) <nl> [ " asd " ] = > <nl> int ( 1 ) <nl> } <nl> - Done <nl> \ No newline at end of file <nl> + Done <nl> mmm a / hphp / test / quick / invoke . php <nl> ppp b / hphp / test / quick / invoke . php <nl> <nl> < ? php <nl> <nl> class Normal { <nl> - public function __destruct ( ) { echo " ~ Normal \ n " ; } <nl> - <nl> public function __invoke ( ) { <nl> echo " This is Normal \ n " ; <nl> var_dump ( $ this ) ; <nl> public function __invoke ( ) { <nl> } ; <nl> <nl> class Weird { <nl> - public function __destruct ( ) { echo " ~ Weird \ n " ; } <nl> - <nl> public static function __invoke ( ) { <nl> echo " This is Weird \ n " ; <nl> var_dump ( $ this ) ; <nl> public static function __invoke ( ) { <nl> } ; <nl> <nl> class Weird2 { <nl> - public function __destruct ( ) { echo " ~ Weird2 \ n " ; } <nl> - <nl> private function __invoke ( ) { <nl> echo " This is Weird2 \ n " ; <nl> var_dump ( $ this ) ; <nl> private function __invoke ( ) { <nl> } ; <nl> <nl> class Weird3 { <nl> - public function __destruct ( ) { echo " ~ Weird3 \ n " ; } <nl> - <nl> private function __invoke ( ) { <nl> echo " This is Weird3 \ n " ; <nl> var_dump ( $ this ) ; <nl> mmm a / hphp / test / quick / invoke . php . expectf <nl> ppp b / hphp / test / quick / invoke . php . expectf <nl> <nl> This is Normal <nl> object ( Normal ) # 1 ( 0 ) { <nl> } <nl> - ~ Normal <nl> This is Weird <nl> % ANULL <nl> - ~ Weird <nl> This is Weird2 <nl> object ( Weird2 ) # 1 ( 0 ) { <nl> } <nl> - ~ Weird2 <nl> This is Weird3 <nl> object ( Weird3 ) # 1 ( 0 ) { <nl> } <nl> - ~ Weird3 <nl> closure <nl> % ANULL <nl> static closure <nl> % ANULL <nl> About to fail : <nl> <nl> - Fatal error : Function name must be a string in % s on line 41 <nl> + Fatal error : Function name must be a string in % s on line 33 <nl> mmm a / hphp / test / quick / keyset / basic - init . php <nl> ppp b / hphp / test / quick / keyset / basic - init . php <nl> function __toString ( ) { <nl> } <nl> <nl> class Noisy { <nl> - public $ id ; <nl> - function __construct ( $ id ) { <nl> - $ this - > id = $ id ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo $ this - > id . " Noisy : : __destruct ( ) \ n " ; <nl> - } <nl> } <nl> <nl> function create ( $ a , $ b , $ c ) { <nl> function main ( ) { <nl> create ( ' a ' , new ToString , ' c ' ) ; <nl> <nl> try { <nl> - var_dump ( keyset [ ' a ' , 1 , ' b ' , 2 , new Noisy ( 1 ) , new Noisy ( 2 ) ] ) ; <nl> + var_dump ( keyset [ ' a ' , 1 , ' b ' , 2 , new Noisy , new Noisy ] ) ; <nl> } catch ( Exception $ e ) { <nl> echo " Exception : " . $ e - > getMessage ( ) . " \ n " ; <nl> } <nl> mmm a / hphp / test / quick / keyset / basic - init . php . expect <nl> ppp b / hphp / test / quick / keyset / basic - init . php . expect <nl> Exception : Invalid keyset key : expected a key of type int or string , keyset give <nl> Exception : Invalid keyset key : expected a key of type int or string , stdClass given <nl> Exception : Invalid keyset key : expected a key of type int or string , HH \ Vector given <nl> Exception : Invalid keyset key : expected a key of type int or string , ToString given <nl> - 2 Noisy : : __destruct ( ) <nl> - 1 Noisy : : __destruct ( ) <nl> Exception : Invalid keyset key : expected a key of type int or string , Noisy given <nl> mmm a / hphp / test / quick / keyset / serialize . php <nl> ppp b / hphp / test / quick / keyset / serialize . php <nl> <nl> < ? hh <nl> / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> <nl> - class Dtor { <nl> - public $ id ; <nl> - function __construct ( $ id ) { <nl> - $ this - > id = $ id ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo " Dtor : : __destruct ( ) : " . $ this - > id . " \ n " ; <nl> - } <nl> - } <nl> - <nl> function roundtrip ( $ ks ) { <nl> echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> var_dump ( $ ks ) ; <nl> function main ( ) { <nl> try_unserialize ( " k : 1 : { R : 1 ; } " ) ; <nl> try_unserialize ( " a : 2 : { i : 123 ; s : 3 : \ " abc \ " ; i : 456 ; k : 1 : { R : 2 ; } } " ) ; <nl> try_unserialize ( " a : 2 : { i : 123 ; k : 1 : { i : 731 ; } i : 456 ; R : 3 ; } " ) ; <nl> - <nl> - / / Ensure dtors run <nl> - try_unserialize ( " k : 2 : { O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 1 ; } O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 2 ; } } " ) ; <nl> } <nl> <nl> main ( ) ; <nl> mmm a / hphp / test / quick / keyset / serialize . php . expectf <nl> ppp b / hphp / test / quick / keyset / serialize . php . expectf <nl> string ( 34 ) " a : 2 : { i : 123 ; k : 1 : { i : 731 ; } i : 456 ; R : 3 ; } " <nl> <nl> Notice : Unable to unserialize : [ a : 2 : { i : 123 ; k : 1 : { i : 731 ; } i : 456 ; R : 3 ; } ] . Id 3 out of range . in % s on line % d <nl> bool ( false ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - string ( 62 ) " k : 2 : { O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 2 ; } } " <nl> - Dtor : : __destruct ( ) : 1 <nl> - <nl> - Notice : Unable to unserialize : [ k : 2 : { O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 2 ; } } ] . Keysets can only contain integers and strings . in % s on line % d <nl> - bool ( false ) <nl> \ No newline at end of file <nl> mmm a / hphp / test / quick / lambda2 . php <nl> ppp b / hphp / test / quick / lambda2 . php <nl> <nl> class bar { <nl> private $ x = " asd " ; <nl> <nl> - public function __destruct ( ) { <nl> - echo " ~ bar ( ) \ n " ; <nl> - } <nl> - <nl> public function foo ( ) { <nl> return array_map ( <nl> $ y = = > $ this - > x , <nl> mmm a / hphp / test / quick / lambda2 . php . expect <nl> ppp b / hphp / test / quick / lambda2 . php . expect <nl> <nl> - ~ bar ( ) <nl> array ( 4 ) { <nl> [ 0 ] = > <nl> string ( 3 ) " asd " <nl> array ( 4 ) { <nl> [ 3 ] = > <nl> string ( 3 ) " asd " <nl> } <nl> - ~ bar ( ) <nl> sup <nl> holding this : <nl> asd <nl> - ~ bar ( ) <nl> Done <nl> mmm a / hphp / test / quick / magic - get - dtors . php <nl> ppp b / hphp / test / quick / magic - get - dtors . php <nl> public function __construct ( ) { <nl> $ this - > x = self : : $ idx + + ; <nl> printf ( " c % d constructing \ n " , $ this - > x ) ; <nl> } <nl> - public function __destruct ( ) { <nl> - printf ( " c % d destructing \ n " , $ this - > x ) ; <nl> - } <nl> public function __get ( $ name ) { <nl> return new C ( ) ; <nl> } <nl> mmm a / hphp / test / quick / magic - get - dtors . php . expect <nl> ppp b / hphp / test / quick / magic - get - dtors . php . expect <nl> Starting <nl> c 0 constructing <nl> c 1 constructing <nl> c 2 constructing <nl> - c 1 destructing <nl> c 3 constructing <nl> - c 2 destructing <nl> c 4 constructing <nl> - c 3 destructing <nl> c 5 constructing <nl> - c 4 destructing <nl> c 6 constructing <nl> Returning from main <nl> - c 6 destructing <nl> - c 5 destructing <nl> - c 0 destructing <nl> Done <nl> deleted file mode 100644 <nl> index faaf4de9acc . . 00000000000 <nl> mmm a / hphp / test / quick / nested__destruct . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - print " Test begin \ n " ; <nl> - <nl> - class C { <nl> - public $ c ; <nl> - function __construct ( $ c = null , $ d = null ) { <nl> - $ this - > c = $ c ; <nl> - $ this - > d = $ d ; <nl> - } <nl> - function __destruct ( ) { <nl> - print " In C : : __destruct ( ) \ n " ; <nl> - } <nl> - } <nl> - <nl> - $ c = new C ( new C ( ) , new C ( ) ) ; <nl> - $ c = null ; <nl> - <nl> - print " Test end \ n " ; <nl> deleted file mode 100644 <nl> index 6e1e07a1866 . . 00000000000 <nl> mmm a / hphp / test / quick / nested__destruct . php . expect <nl> ppp / dev / null <nl> <nl> - Test begin <nl> - In C : : __destruct ( ) <nl> - In C : : __destruct ( ) <nl> - In C : : __destruct ( ) <nl> - Test end <nl> mmm a / hphp / test / quick / obj - string - throw . php <nl> ppp b / hphp / test / quick / obj - string - throw . php <nl> <nl> < ? php <nl> <nl> class foo { <nl> - public function __destruct ( ) { echo " dtor \ n " ; } <nl> public function __toString ( ) { throw new Exception ( " asd " ) ; } <nl> } <nl> <nl> function main ( ) { <nl> } <nl> <nl> try { main ( ) ; } catch ( Exception $ x ) { } <nl> + echo " done . \ n " ; <nl> mmm a / hphp / test / quick / obj - string - throw . php . expect <nl> ppp b / hphp / test / quick / obj - string - throw . php . expect <nl> @ @ - 1 + 1 @ @ <nl> - dtor <nl> + done . <nl> deleted file mode 100644 <nl> index c6479c483be . . 00000000000 <nl> mmm a / hphp / test / quick / obj - sweep . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class DTor { <nl> - public function __destruct ( ) { <nl> - echo " van sweepster \ n " ; <nl> - } <nl> - } <nl> - <nl> - $ d = new DTor ( ) ; <nl> - <nl> deleted file mode 100644 <nl> index 015771f9024 . . 00000000000 <nl> mmm a / hphp / test / quick / obj - sweep . php . expect <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - van sweepster <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> mmm a / hphp / test / quick / profile / Setprofile_generic . php <nl> ppp b / hphp / test / quick / profile / Setprofile_generic . php <nl> <nl> < ? php <nl> <nl> class Foo { <nl> - public function __destruct ( ) { echo " heh \ n " ; } <nl> } <nl> <nl> function pure_function_many_locals ( $ a ) { <nl> mmm a / hphp / test / quick / profile / Setprofile_generic . php . expect <nl> ppp b / hphp / test / quick / profile / Setprofile_generic . php . expect <nl> <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> yep <nl> array ( 3 ) { <nl> [ 0 ] = > <nl> array ( 3 ) { <nl> } <nl> } <nl> yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> array ( 3 ) { <nl> [ 0 ] = > <nl> string ( 4 ) " exit " <nl> array ( 3 ) { <nl> } <nl> } <nl> yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " enter " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - heh <nl> - yep <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - string ( 4 ) " exit " <nl> - [ 1 ] = > <nl> - string ( 15 ) " Foo : : __destruct " <nl> - [ 2 ] = > <nl> - array ( 1 ) { <nl> - [ " return " ] = > <nl> - NULL <nl> - } <nl> - } <nl> - yep <nl> array ( 3 ) { <nl> [ 0 ] = > <nl> string ( 4 ) " exit " <nl> array ( 3 ) { <nl> } <nl> } <nl> } <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> mmm a / hphp / test / quick / profile / setprofile - this . php <nl> ppp b / hphp / test / quick / profile / setprofile - this . php <nl> trait logger { <nl> public function __construct ( ) { <nl> echo " \ n " . __CLASS__ . " constructing \ n " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " \ n " . __CLASS__ . " destructing \ n " ; <nl> - } <nl> } <nl> <nl> class A { <nl> mmm a / hphp / test / quick / profile / setprofile - this . php . expectf <nl> ppp b / hphp / test / quick / profile / setprofile - this . php . expectf <nl> C constructing <nl> <nl> exit C : : __construct : a : 1 : { s : 6 : " return " ; N ; } <nl> <nl> - enter C : : __destruct : a : 1 : { s : 4 : " args " ; a : 0 : { } } <nl> - <nl> - C destructing <nl> - <nl> - exit C : : __destruct : a : 1 : { s : 6 : " return " ; N ; } <nl> - <nl> enter Exception : : getMessage : a : 1 : { s : 4 : " args " ; a : 0 : { } } <nl> <nl> exit Exception : : getMessage : a : 1 : { s : 6 : " return " ; s : 14 : " C : : __construct " ; } <nl> A constructing <nl> <nl> exit A : : __construct : a : 1 : { s : 6 : " return " ; N ; } <nl> <nl> - enter C : : __destruct : a : 1 : { s : 4 : " args " ; a : 0 : { } } <nl> - <nl> - C destructing <nl> - <nl> - exit C : : __destruct : a : 1 : { s : 6 : " return " ; N ; } <nl> - <nl> exit C : : method : a : 1 : { s : 6 : " return " ; O : 1 : " A " : 0 : { } } <nl> <nl> enter Exception : : getMessage : a : 1 : { s : 4 : " args " ; a : 0 : { } } <nl> C destructing <nl> <nl> Caught C : : method <nl> <nl> - enter A : : __destruct : a : 1 : { s : 4 : " args " ; a : 0 : { } } <nl> - <nl> - A destructing <nl> - <nl> - exit A : : __destruct : a : 1 : { s : 6 : " return " ; N ; } <nl> - <nl> exit main : a : 1 : { s : 6 : " return " ; N ; } <nl> <nl> exit : a : 1 : { s : 6 : " return " ; i : 1 ; } <nl> mmm a / hphp / test / quick / profile / setprofile_throw . php <nl> ppp b / hphp / test / quick / profile / setprofile_throw . php <nl> function func_to_enter ( ) { } <nl> <nl> class DtorObj { <nl> public function __construct ( $ x ) { $ this - > x = $ x ; echo " __ctor $ x \ n " ; } <nl> - public function __destruct ( ) { echo " __dtor " . $ this - > x . " \ n " ; } <nl> } <nl> <nl> / / During function exit <nl> mmm a / hphp / test / quick / profile / setprofile_throw . php . expectf <nl> ppp b / hphp / test / quick / profile / setprofile_throw . php . expectf <nl> signal throwing <nl> Warning : signal handler ' signal_thrower ' threw exception ' Exception ' with message ' Sig exception ' in % s / hphp / test / quick / profile / setprofile_throw . php : 19 <nl> Stack trace : <nl> # 0 ( ) : signal_thrower ( ) <nl> - # 1 % s / hphp / test / quick / profile / setprofile_throw . php ( 49 ) : posix_kill ( ) <nl> - # 2 % s / hphp / test / quick / profile / setprofile_throw . php ( 93 ) : func_entry ( ) <nl> - # 3 % s / hphp / test / quick / profile / setprofile_throw . php ( 97 ) : main ( ) <nl> - # 4 { main } in % s / hphp / test / quick / profile / setprofile_throw . php on line 49 <nl> - __dtor 15 <nl> - __dtor 14 <nl> - __dtor 13 <nl> - __dtor 12 <nl> - __dtor 11 <nl> - __dtor 10 <nl> - __dtor 9 <nl> - __dtor 8 <nl> - __dtor 7 <nl> - __dtor 6 <nl> - __dtor 5 <nl> - __dtor 4 <nl> - __dtor 3 <nl> - __dtor 2 <nl> - __dtor 1 <nl> + # 1 % s / hphp / test / quick / profile / setprofile_throw . php ( 48 ) : posix_kill ( ) <nl> + # 2 % s / hphp / test / quick / profile / setprofile_throw . php ( 92 ) : func_entry ( ) <nl> + # 3 % s / hphp / test / quick / profile / setprofile_throw . php ( 96 ) : main ( ) <nl> + # 4 { main } in % s / hphp / test / quick / profile / setprofile_throw . php on line 48 <nl> __ctor 1 <nl> __ctor 2 <nl> __ctor 3 <nl> signal throwing <nl> Warning : signal handler ' signal_thrower ' threw exception ' Exception ' with message ' Sig exception ' in % s / hphp / test / quick / profile / setprofile_throw . php : 19 <nl> Stack trace : <nl> # 0 ( ) : signal_thrower ( ) <nl> - # 1 % s / hphp / test / quick / profile / setprofile_throw . php ( 75 ) : posix_kill ( ) <nl> - # 2 % s / hphp / test / quick / profile / setprofile_throw . php ( 94 ) : func_backward ( ) <nl> - # 3 % s / hphp / test / quick / profile / setprofile_throw . php ( 97 ) : main ( ) <nl> - # 4 { main } in % s / hphp / test / quick / profile / setprofile_throw . php on line 75 <nl> - __dtor 15 <nl> - __dtor 14 <nl> - __dtor 13 <nl> - __dtor 12 <nl> - __dtor 11 <nl> - __dtor 10 <nl> - __dtor 9 <nl> - __dtor 8 <nl> - __dtor 7 <nl> - __dtor 6 <nl> - __dtor 5 <nl> - __dtor 4 <nl> - __dtor 3 <nl> - __dtor 2 <nl> - __dtor 1 <nl> + # 1 % s / hphp / test / quick / profile / setprofile_throw . php ( 74 ) : posix_kill ( ) <nl> + # 2 % s / hphp / test / quick / profile / setprofile_throw . php ( 93 ) : func_backward ( ) <nl> + # 3 % s / hphp / test / quick / profile / setprofile_throw . php ( 96 ) : main ( ) <nl> + # 4 { main } in % s / hphp / test / quick / profile / setprofile_throw . php on line 74 <nl> deleted file mode 100644 <nl> index 59316bce542 . . 00000000000 <nl> mmm a / hphp / test / quick / pseudomain1 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class C { <nl> - public function __destruct ( ) { <nl> - echo " C : : __destruct \ n " ; <nl> - global $ obj ; <nl> - var_dump ( $ obj ) ; <nl> - echo " = = = = = = = = = = \ n " ; <nl> - $ obj = 1 ; <nl> - echo " C : : __destruct done \ n " ; <nl> - } <nl> - } <nl> - <nl> - class D { <nl> - public function __destruct ( ) { <nl> - echo " D : : __destruct \ n " ; <nl> - } <nl> - } <nl> - <nl> - $ obj = new C ; <nl> - $ obj = new D ; <nl> - echo " * * * * \ n " ; <nl> - var_dump ( $ obj ) ; <nl> deleted file mode 100644 <nl> index 8a3fff4c7be . . 00000000000 <nl> mmm a / hphp / test / quick / pseudomain1 . php . expect <nl> ppp / dev / null <nl> <nl> - C : : __destruct <nl> - object ( D ) # 2 ( 0 ) { <nl> - } <nl> - = = = = = = = = = = <nl> - C : : __destruct done <nl> - D : : __destruct <nl> - * * * * <nl> - int ( 1 ) <nl> mmm a / hphp / test / quick / regpressure_bug . php <nl> ppp b / hphp / test / quick / regpressure_bug . php <nl> public function __construct ( $ id ) { <nl> $ this - > binary = " asdasd " ; <nl> } <nl> <nl> - public function __destruct ( ) { <nl> - echo " dtor " . $ this - > id . " \ n " ; <nl> - } <nl> - <nl> public function toBinary ( ) { <nl> return $ this - > binary ; <nl> } <nl> mmm a / hphp / test / quick / regpressure_bug . php . expect <nl> ppp b / hphp / test / quick / regpressure_bug . php . expect <nl> asdasd <nl> after2 <nl> asdasd <nl> after3 <nl> - dtory <nl> - dtorx <nl> deleted file mode 100644 <nl> index 443fa947397 . . 00000000000 <nl> mmm a / hphp / test / quick / resurrect . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - print " Test begin \ n " ; <nl> - <nl> - $ x = null ; <nl> - <nl> - class C { <nl> - public $ p = " C : : \ $ p " ; <nl> - function __destruct ( ) { <nl> - global $ x ; <nl> - print " In C : : __destruct ( ) \ n " ; <nl> - $ this - > p = " changed " ; <nl> - $ x = $ this ; <nl> - } <nl> - } <nl> - <nl> - $ c = new C ( ) ; <nl> - var_dump ( $ c ) ; <nl> - $ c = null ; <nl> - # XXX The translator fails to notice that $ x has changed , so break the basic <nl> - # block here to force the translator to re - read $ x . <nl> - if ( isset ( $ g ) ) { } <nl> - var_dump ( $ x ) ; <nl> - $ x = null ; <nl> - <nl> - print " Test end \ n " ; <nl> deleted file mode 100644 <nl> index fccf90b9ed1 . . 00000000000 <nl> mmm a / hphp / test / quick / resurrect . php . expect <nl> ppp / dev / null <nl> <nl> - Test begin <nl> - object ( C ) # 1 ( 1 ) { <nl> - [ " p " ] = > <nl> - string ( 5 ) " C : : $ p " <nl> - } <nl> - In C : : __destruct ( ) <nl> - object ( C ) # 1 ( 1 ) { <nl> - [ " p " ] = > <nl> - string ( 7 ) " changed " <nl> - } <nl> - Test end <nl> deleted file mode 100644 <nl> index ec413d82713 . . 00000000000 <nl> mmm a / hphp / test / quick / retc - destruct . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - function bt ( ) { <nl> - global $ g ; <nl> - $ g = debug_backtrace ( ) ; <nl> - } <nl> - <nl> - class X { <nl> - function __destruct ( ) { bt ( ) ; } <nl> - } <nl> - <nl> - function test ( $ x ) { } <nl> - <nl> - test ( array ( new X ) ) ; <nl> - var_dump ( $ g [ 2 ] [ ' args ' ] ) ; <nl> deleted file mode 100644 <nl> index 63a30c0d89f . . 00000000000 <nl> mmm a / hphp / test / quick / retc - destruct . php . expect <nl> ppp / dev / null <nl> <nl> - array ( 0 ) { <nl> - } <nl> deleted file mode 100644 <nl> index aecd70afc60 . . 00000000000 <nl> mmm a / hphp / test / quick / retval_backtrace . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Bro { } <nl> - <nl> - class Thing1 { <nl> - public function __destruct ( ) { <nl> - $ z = debug_backtrace ( ) ; <nl> - / / var_dump ( $ z ) ; <nl> - } <nl> - } <nl> - <nl> - class Thing2 { <nl> - public function foo ( ) { <nl> - $ a = new Bro ( ) ; <nl> - $ ab = new Bro ( ) ; <nl> - $ abc = new Bro ( ) ; <nl> - $ abcd = new Bro ( ) ; <nl> - $ abcde = new Bro ( ) ; <nl> - $ abcdef = new Bro ( ) ; <nl> - $ z = new Thing1 ( ) ; <nl> - return 12 ; <nl> - } <nl> - } <nl> - <nl> - function foo ( ) { <nl> - echo " go \ n " ; <nl> - $ z = new Thing2 ( ) ; <nl> - return $ z - > foo ( ) ; <nl> - } <nl> - <nl> - echo " Returned : " . foo ( ) . " \ n " ; <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 79019f1f3fd . . 00000000000 <nl> mmm a / hphp / test / quick / retval_backtrace . php . expect <nl> ppp / dev / null <nl> <nl> - go <nl> - Returned : 12 <nl> mmm a / hphp / test / quick / serialize . php <nl> ppp b / hphp / test / quick / serialize . php <nl> function __construct ( ) { <nl> $ this - > c = log ( 0 ) ; <nl> echo " C has a safe constructor . \ n " ; <nl> } <nl> - function __destruct ( ) { <nl> - echo " C has a safe destructor . \ n " ; <nl> - } <nl> function __wakeup ( ) { <nl> echo " C wakes up safely . \ n " ; <nl> } <nl> class DangerousClass { <nl> function __construct ( ) { <nl> echo " I have dangerous constructor . \ n " ; <nl> } <nl> - function __destruct ( ) { <nl> - echo " I have dangerous destructor . \ n " ; <nl> - } <nl> function __wakeup ( ) { <nl> echo " I wake up dangerously . \ n " ; <nl> } <nl> mmm a / hphp / test / quick / serialize . php . expectf <nl> ppp b / hphp / test / quick / serialize . php . expectf <nl> object ( C ) # 4 ( 3 ) { <nl> [ " c " ] = > <nl> float ( - INF ) <nl> } <nl> - C has a safe destructor . <nl> - C has a safe destructor . <nl> = = = = = = = = = = = = = = = = = = = = = = = = <nl> I have dangerous constructor . <nl> I sleep dangerously . <nl> object ( DangerousClass ) # 5 ( 1 ) { <nl> [ " danger " ] = > <nl> string ( 15 ) " DangerousString " <nl> } <nl> - I have dangerous destructor . <nl> - I have dangerous destructor . <nl> = = = = = = = = = = = = = = = = = = = = = = = = <nl> I have dangerous constructor . <nl> I sleep dangerously . <nl> object ( E ) # 7 ( 1 ) { <nl> string ( 15 ) " DangerousString " <nl> } <nl> } <nl> - I have dangerous destructor . <nl> - I have dangerous destructor . <nl> = = = = = = = = = = = = = = = = = = = = = = = = <nl> string ( 27 ) " C : 1 : " F " : 14 : { SerializedData } " <nl> unserialize : SerializedData <nl> object ( G ) # 9 ( 1 ) { <nl> [ " danger " ] = > <nl> string ( 15 ) " DangerousString " <nl> } <nl> - I have dangerous destructor . <nl> - I have dangerous destructor . <nl> = = = = = = = = = = = = = = = = = = = = = = = = <nl> string ( 63 ) " a : 4 : { i : 0 ; s : 15 : " Hello World < > $ % " ; i : 1 ; d : NAN ; i : 2 ; d : - INF ; i : 3 ; i : 50 ; } " <nl> array ( 4 ) { <nl> array ( 2 ) { <nl> } <nl> } <nl> } <nl> - C has a safe destructor . <nl> - I have dangerous destructor . <nl> - C has a safe destructor . <nl> - I have dangerous destructor . <nl> = = = = = = = = = = = = = = = = = = = = = = = = <nl> deleted file mode 100644 <nl> index 28c3de971e6 . . 00000000000 <nl> mmm a / hphp / test / quick / setg - dtor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - / / Test destruction order for SetG . <nl> - class d { <nl> - public function __destruct ( ) { <nl> - $ GLOBALS [ ' x ' ] = " destructor " ; <nl> - } <nl> - } <nl> - <nl> - function foo ( ) { <nl> - $ GLOBALS [ ' x ' ] = new d ( ) ; <nl> - echo " Foo : " ; <nl> - echo ( $ GLOBALS [ ' x ' ] = " main " ) ; <nl> - echo " \ n " ; <nl> - var_dump ( $ GLOBALS [ ' x ' ] ) ; <nl> - } <nl> - <nl> - foo ( ) ; <nl> deleted file mode 100644 <nl> index 515fa16d474 . . 00000000000 <nl> mmm a / hphp / test / quick / setg - dtor . php . expect <nl> ppp / dev / null <nl> <nl> - Foo : main <nl> - string ( 10 ) " destructor " <nl> deleted file mode 100644 <nl> index e2e5400b20b . . 00000000000 <nl> mmm a / hphp / test / quick / seth - dtor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Bar { <nl> - public $ x = null ; <nl> - public function __destruct ( ) { <nl> - $ this - > x = " dtor " ; <nl> - } <nl> - } ; <nl> - <nl> - function foo ( ) { <nl> - $ a = new Bar ( ) ; <nl> - $ a - > x = & $ a ; <nl> - echo " First : " ; <nl> - echo ( $ a = " something " ) ; <nl> - echo " \ n " ; <nl> - echo $ a . " \ n " ; <nl> - } <nl> - foo ( ) ; <nl> deleted file mode 100644 <nl> index 5548d2cbdc2 . . 00000000000 <nl> mmm a / hphp / test / quick / seth - dtor . php . expect <nl> ppp / dev / null <nl> <nl> - First : something <nl> - dtor <nl> deleted file mode 100644 <nl> index a8529239270 . . 00000000000 <nl> mmm a / hphp / test / quick / seth - dtor3 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Bar { <nl> - public $ x = null ; <nl> - public function __destruct ( ) { <nl> - $ this - > x = " dtor " ; <nl> - } <nl> - } ; <nl> - function foo ( ) { <nl> - $ a = new Bar ( ) ; <nl> - $ a - > x = & $ a ; <nl> - if ( $ a ) { <nl> - echo " Value : " ; <nl> - } <nl> - $ a = " something " ; <nl> - echo $ a . " \ n " ; <nl> - } <nl> - foo ( ) ; <nl> deleted file mode 100644 <nl> index 2a1e4324793 . . 00000000000 <nl> mmm a / hphp / test / quick / seth - dtor3 . php . expect <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - Value : dtor <nl> mmm a / hphp / test / quick / setop - magic3 . php <nl> ppp b / hphp / test / quick / setop - magic3 . php <nl> <nl> < ? php <nl> <nl> - class Dtor { public function __destruct ( ) { echo " Dtor \ n " ; } } <nl> - <nl> class Foo { <nl> public function __get ( $ x ) { <nl> var_dump ( " getter : " . $ x ) ; <nl> if ( $ x = = ' foo ' ) return 12 ; <nl> $ this - > foo + = 12 ; <nl> - $ this - > asd = new Dtor ; <nl> + $ this - > asd = new stdclass ; <nl> } <nl> } <nl> <nl> function main ( ) { <nl> <nl> main ( ) ; <nl> echo " Done \ n " ; <nl> - <nl> mmm a / hphp / test / quick / setop - magic3 . php . expect <nl> ppp b / hphp / test / quick / setop - magic3 . php . expect <nl> <nl> string ( 11 ) " getter : asd " <nl> string ( 11 ) " getter : foo " <nl> - Dtor <nl> object ( Foo ) # 1 ( 2 ) { <nl> [ " foo " ] = > <nl> int ( 24 ) <nl> [ " asd " ] = > <nl> int ( 12 ) <nl> } <nl> - Done <nl> \ No newline at end of file <nl> + Done <nl> mmm a / hphp / test / quick / setop - refleak . php <nl> ppp b / hphp / test / quick / setop - refleak . php <nl> <nl> < ? php <nl> <nl> class Dtor { <nl> - public function __destruct ( ) { echo " dtor \ n " ; } <nl> } <nl> <nl> class Foo { public $ bug ; } ; <nl> mmm a / hphp / test / quick / setop - refleak . php . expectf <nl> ppp b / hphp / test / quick / setop - refleak . php . expectf <nl> <nl> <nl> - Notice : Object of class Dtor could not be converted to int in % s / test / quick / setop - refleak . php on line 12 <nl> - dtor <nl> + Notice : Object of class Dtor could not be converted to int in % s / test / quick / setop - refleak . php on line 11 <nl> object ( Foo ) # 1 ( 1 ) { <nl> [ " bug " ] = > <nl> int ( 13 ) <nl> deleted file mode 100644 <nl> index 8807d8bea12 . . 00000000000 <nl> mmm a / hphp / test / quick / sets - dtor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - / / Test destruction order for SetS . <nl> - class d { <nl> - static public $ x = " asd " ; <nl> - <nl> - public function __destruct ( ) { <nl> - d : : $ x = " destructor " ; <nl> - } <nl> - <nl> - public static function foo ( ) { <nl> - $ foo = new d ( ) ; <nl> - d : : $ x = $ foo ; <nl> - unset ( $ foo ) ; <nl> - echo " Foo : " ; <nl> - echo ( d : : $ x = " main " ) ; <nl> - echo " \ n " ; <nl> - var_dump ( d : : $ x ) ; <nl> - } <nl> - } <nl> - <nl> - d : : foo ( ) ; <nl> deleted file mode 100644 <nl> index 515fa16d474 . . 00000000000 <nl> mmm a / hphp / test / quick / sets - dtor . php . expect <nl> ppp / dev / null <nl> <nl> - Foo : main <nl> - string ( 10 ) " destructor " <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> deleted file mode 100644 <nl> index bd90f4a7c53 . . 00000000000 <nl> mmm a / hphp / test / quick / shiftDtorOrder . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class A { <nl> - public function __destruct ( ) { echo " ~ A \ n " ; } <nl> - } <nl> - <nl> - class B { <nl> - public function __destruct ( ) { echo " ~ B \ n " ; } <nl> - } <nl> - <nl> - function main ( ) { <nl> - $ k = ( new A ) < < ( new B ) ; <nl> - var_dump ( $ k ) ; <nl> - } <nl> - main ( ) ; <nl> - <nl> deleted file mode 100644 <nl> index 24872c5d228 . . 00000000000 <nl> mmm a / hphp / test / quick / shiftDtorOrder . php . expectf <nl> ppp / dev / null <nl> <nl> - <nl> - Notice : Object of class A could not be converted to int in % s on line 12 <nl> - <nl> - Notice : Object of class B could not be converted to int in % s on line 12 <nl> - ~ A <nl> - ~ B <nl> - int ( 2 ) <nl> mmm a / hphp / test / quick / tostring_throw . php <nl> ppp b / hphp / test / quick / tostring_throw . php <nl> <nl> class stringer { <nl> public function __toString ( ) { throw new Exception ( " nope \ n " ) ; } <nl> } <nl> - class dtor { public function __destruct ( ) { echo " dtor ran \ n " ; } } <nl> + class dtor { } <nl> <nl> function ignore ( ) { } <nl> function foo ( ) { <nl> mmm a / hphp / test / quick / tostring_throw . php . expect <nl> ppp b / hphp / test / quick / tostring_throw . php . expect <nl> @ @ - 1 , 2 + 1 @ @ <nl> - dtor ran <nl> all ok <nl> mmm a / hphp / test / quick / translator_unwind . hhas <nl> ppp b / hphp / test / quick / translator_unwind . hhas <nl> <nl> RetC <nl> } <nl> <nl> - . method [ public ] __destruct ( ) { <nl> - String " dtor : " <nl> - This <nl> - BaseC 0 Warn <nl> - QueryM 1 CGet PT : " x " <nl> - Concat <nl> - String " \ n " <nl> - Concat <nl> - Print <nl> - RetC <nl> - } <nl> - <nl> . property [ private ] x ; <nl> } <nl> <nl> mmm a / hphp / test / quick / translator_unwind . hhas . expect <nl> ppp b / hphp / test / quick / translator_unwind . hhas . expect <nl> ctor : 11 <nl> ctor : 12 <nl> ctor : 13 <nl> ctor : 14 <nl> - dtor : 14 <nl> - dtor : 13 <nl> - dtor : 12 <nl> - dtor : 11 <nl> - dtor : 10 <nl> - dtor : 9 <nl> - dtor : 8 <nl> - dtor : 7 <nl> - dtor : 6 <nl> - dtor : 5 <nl> - dtor : 4 <nl> - dtor : 3 <nl> - dtor : 2 <nl> - dtor : 1 <nl> - dtor : 0 <nl> Received exception : hi <nl> deleted file mode 100644 <nl> index 2758786551a . . 00000000000 <nl> mmm a / hphp / test / quick / trim_dtor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class X { <nl> - public function __destruct ( ) { echo " heh \ n " ; } <nl> - } <nl> - function foo ( $ x ) { } <nl> - <nl> - foo ( new X ( ) , new X ( ) , new X ( ) , new X ( ) ) ; <nl> - echo " yep \ n " ; <nl> deleted file mode 100644 <nl> index 1b994a4636c . . 00000000000 <nl> mmm a / hphp / test / quick / trim_dtor . php . expect <nl> ppp / dev / null <nl> <nl> - heh <nl> - heh <nl> - heh <nl> - heh <nl> - yep <nl> deleted file mode 100644 <nl> index f3c9f9b84ea . . 00000000000 <nl> mmm a / hphp / test / quick / unwind_backtrace . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - function blah ( ) { <nl> - throw new Exception ( ' asd ' ) ; <nl> - } <nl> - <nl> - class something { <nl> - public function __destruct ( ) { <nl> - echo " ~ something \ n " ; <nl> - $ k = debug_backtrace ( ) ; # [ 1 ] [ ' object ' ] ; <nl> - var_dump ( $ k [ 1 ] [ ' class ' ] , isset ( $ k [ 1 ] [ ' object ' ] ) ) ; <nl> - } <nl> - public function yo ( ) { <nl> - blah ( ) ; <nl> - } <nl> - } <nl> - <nl> - class Bar { <nl> - public function foo ( ) { <nl> - $ k = new something ( ) ; <nl> - echo " wat \ n " ; <nl> - blah ( ) ; <nl> - echo " eh \ n " ; <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - ( new Bar ) - > foo ( ) ; <nl> - } <nl> - <nl> - main ( ) ; <nl> deleted file mode 100644 <nl> index 285a4c5d5b6 . . 00000000000 <nl> mmm a / hphp / test / quick / unwind_backtrace . php . expectf <nl> ppp / dev / null <nl> <nl> - wat <nl> - ~ something <nl> - string ( 3 ) " Bar " <nl> - bool ( false ) <nl> - <nl> - Fatal error : Uncaught exception ' Exception ' with message ' asd ' in % s / hphp / test / quick / unwind_backtrace . php : 4 <nl> - Stack trace : <nl> - # 0 % s / hphp / test / quick / unwind_backtrace . php ( 22 ) : blah ( ) <nl> - # 1 % s / hphp / test / quick / unwind_backtrace . php ( 28 ) : Bar - > foo ( ) <nl> - # 2 % s / hphp / test / quick / unwind_backtrace . php ( 31 ) : main ( ) <nl> - # 3 { main } <nl> mmm a / hphp / test / quick / vec / apc . php <nl> ppp b / hphp / test / quick / vec / apc . php <nl> function __wakeup ( ) { <nl> } <nl> } <nl> <nl> - class Dtor { <nl> - public $ val ; <nl> - <nl> - function __construct ( $ val ) { <nl> - $ this - > val = $ val ; <nl> - } <nl> - <nl> - function __destruct ( ) { <nl> - echo " Dtor . . . " . $ this - > val . " \ n " ; <nl> - } <nl> - } <nl> - <nl> function get_count ( ) { <nl> $ count = apc_fetch ( " count " ) ; <nl> if ( ! $ count ) { <nl> function read ( ) { <nl> var_dump ( $ e - > getMessage ( ) ) ; <nl> } <nl> <nl> - try { <nl> - var_dump ( apc_fetch ( " val10 " ) ) ; <nl> - } catch ( Exception $ e ) { <nl> - var_dump ( $ e - > getMessage ( ) ) ; <nl> - } <nl> - <nl> var_dump ( apc_fetch ( " val11 " ) ) ; <nl> } <nl> <nl> function write ( $ count ) { <nl> <nl> apc_store ( " val8 " , vec [ new Wakeup ] ) ; <nl> apc_store ( " val9 " , vec [ new WakeupThrow ] ) ; <nl> - apc_store ( " val10 " , vec [ new Dtor ( 1 ) , new WakeupThrow , new Dtor ( 2 ) ] ) ; <nl> apc_store ( " val11 " , vec [ new Sleep ( 123 ) ] ) ; <nl> } <nl> <nl> mmm a / hphp / test / quick / vec / apc . php . expectf <nl> ppp b / hphp / test / quick / vec / apc . php . expectf <nl> bool ( false ) <nl> bool ( false ) <nl> bool ( false ) <nl> bool ( false ) <nl> - bool ( false ) <nl> - Dtor . . . 1 <nl> - Dtor . . . 2 <nl> Sleep . . . <nl> vec ( 0 ) { <nl> } <nl> vec ( 1 ) { <nl> } <nl> } <nl> string ( 16 ) " Wakeup exception " <nl> - Dtor . . . 1 <nl> - string ( 16 ) " Wakeup exception " <nl> vec ( 1 ) { <nl> object ( Sleep ) # % d ( 1 ) { <nl> [ " val " ] = > <nl> vec ( 1 ) { <nl> } <nl> } <nl> string ( 16 ) " Wakeup exception " <nl> - Dtor . . . 1 <nl> - string ( 16 ) " Wakeup exception " <nl> vec ( 1 ) { <nl> object ( Sleep ) # % d ( 1 ) { <nl> [ " val " ] = > <nl> NULL <nl> } <nl> } <nl> - Dtor . . . 1 <nl> - Dtor . . . 2 <nl> Sleep . . . <nl> vec ( 0 ) { <nl> } <nl> vec ( 1 ) { <nl> } <nl> } <nl> string ( 16 ) " Wakeup exception " <nl> - Dtor . . . 1 <nl> - string ( 16 ) " Wakeup exception " <nl> vec ( 1 ) { <nl> object ( Sleep ) # % d ( 1 ) { <nl> [ " val " ] = > <nl> NULL <nl> } <nl> - } <nl> \ No newline at end of file <nl> + } <nl> mmm a / hphp / test / quick / vec / basic - init . php <nl> ppp b / hphp / test / quick / vec / basic - init . php <nl> function __toString ( ) { <nl> } <nl> <nl> class Noisy { <nl> - public $ id ; <nl> - function __construct ( $ id ) { <nl> - $ this - > id = $ id ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo $ this - > id . " Noisy : : __destruct ( ) \ n " ; <nl> - } <nl> } <nl> <nl> class Thrower { <nl> mmm a / hphp / test / quick / vec / basic - init . php . expect <nl> ppp b / hphp / test / quick / vec / basic - init . php . expect <nl> vec ( 4 ) { <nl> string ( 3 ) " abc " <nl> int ( 10 ) <nl> } <nl> - 3 Noisy : : __destruct ( ) <nl> - 2 Noisy : : __destruct ( ) <nl> - 1 Noisy : : __destruct ( ) <nl> Exception : Thrower : : __construct ( ) <nl> new file mode 100644 <nl> index 00000000000 . . 4977cc25517 <nl> mmm / dev / null <nl> ppp b / hphp / test / quick / vec / convert . php . opts <nl> @ @ - 0 , 0 + 1 @ @ <nl> + - vEval . JitPGODecRefNZReleasePercentCOW = 0 - vEval . JitPGODecRefNZReleasePercent = 0 <nl> deleted file mode 100644 <nl> index d353f81c2d0 . . 00000000000 <nl> mmm a / hphp / test / quick / vec / dtor . php <nl> ppp / dev / null <nl> <nl> - < ? hh <nl> - / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> - <nl> - class Dtor { <nl> - public $ id ; <nl> - function __construct ( $ id ) { <nl> - $ this - > id = $ id ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo " Dtor : : __destruct ( " . $ this - > id . " ) \ n " ; <nl> - } <nl> - } <nl> - <nl> - function main ( $ a , $ b , $ c ) { <nl> - $ v = vec [ new Dtor ( $ a ) , new Dtor ( $ b ) , new Dtor ( $ c ) ] ; <nl> - var_dump ( $ v ) ; <nl> - } <nl> - main ( 1 , 2 , 3 ) ; <nl> deleted file mode 100644 <nl> index a4cb935c713 . . 00000000000 <nl> mmm a / hphp / test / quick / vec / dtor . php . expect <nl> ppp / dev / null <nl> <nl> - vec ( 3 ) { <nl> - object ( Dtor ) # 1 ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 1 ) <nl> - } <nl> - object ( Dtor ) # 2 ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 2 ) <nl> - } <nl> - object ( Dtor ) # 3 ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 3 ) <nl> - } <nl> - } <nl> - Dtor : : __destruct ( 1 ) <nl> - Dtor : : __destruct ( 2 ) <nl> - Dtor : : __destruct ( 3 ) <nl> mmm a / hphp / test / quick / vec / serialize . php <nl> ppp b / hphp / test / quick / vec / serialize . php <nl> function __wakeup ( ) { <nl> } <nl> } <nl> <nl> - class Dtor { <nl> - public $ id ; <nl> - function __construct ( $ id ) { <nl> - $ this - > id = $ id ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo " Dtor : : __destruct ( ) : " . $ this - > id . " \ n " ; <nl> - } <nl> - } <nl> - <nl> function roundtrip ( $ v ) { <nl> echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> var_dump ( $ v ) ; <nl> function main ( ) { <nl> <nl> try_serialize ( vec [ new SleepThrow ] ) ; <nl> try_unserialize ( " v : 1 : { O : 11 : \ " WakeupThrow \ " : 0 : { } } " ) ; <nl> - <nl> - / / Ensure dtors of already unserialized elements run <nl> - try_unserialize ( " v : 5 : { O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 1 ; } O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 2 ; } O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 3 ; } O : 11 : \ " WakeupThrow \ " : 0 : { } O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 4 ; } } " ) ; <nl> - try_unserialize ( " v : 3 : { v : 1 : { i : 123 ; } R : 2 ; O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 1 ; } } " ) ; <nl> - try_unserialize ( " v : 3 : { O : 4 : \ " Dtor \ " : 1 : { s : 2 : \ " id \ " ; i : 1 ; } v : 1 : { i : 123 ; } R : 3 ; } " ) ; <nl> } <nl> <nl> main ( ) ; <nl> mmm a / hphp / test / quick / vec / serialize . php . expectf <nl> ppp b / hphp / test / quick / vec / serialize . php . expectf <nl> Serialize exception : Sleep exception <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> string ( 29 ) " v : 1 : { O : 11 : " WakeupThrow " : 0 : { } } " <nl> Unserialize exception : Wakeup exception <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - string ( 141 ) " v : 5 : { O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 2 ; } O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 3 ; } O : 11 : " WakeupThrow " : 0 : { } O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 4 ; } } " <nl> - Dtor : : __destruct ( ) : 1 <nl> - Dtor : : __destruct ( ) : 2 <nl> - Dtor : : __destruct ( ) : 3 <nl> - Dtor : : __destruct ( ) : 4 <nl> - Unserialize exception : Wakeup exception <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - string ( 50 ) " v : 3 : { v : 1 : { i : 123 ; } R : 2 ; O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } } " <nl> - <nl> - Notice : Unable to unserialize : [ v : 3 : { v : 1 : { i : 123 ; } R : 2 ; O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } } ] . Vecs cannot contain references . in % s on line % d <nl> - bool ( false ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - string ( 50 ) " v : 3 : { O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } v : 1 : { i : 123 ; } R : 3 ; } " <nl> - Dtor : : __destruct ( ) : 1 <nl> - <nl> - Notice : Unable to unserialize : [ v : 3 : { O : 4 : " Dtor " : 1 : { s : 2 : " id " ; i : 1 ; } v : 1 : { i : 123 ; } R : 3 ; } ] . Vecs cannot contain references . in % s on line % d <nl> - bool ( false ) <nl> \ No newline at end of file <nl> mmm a / hphp / test / quick / vec / unset . php <nl> ppp b / hphp / test / quick / vec / unset . php <nl> <nl> < ? hh <nl> <nl> class Dtor { <nl> - function __destruct ( ) { <nl> - echo " Dtor : : __destruct \ n " ; <nl> - } <nl> } <nl> <nl> function do_unset ( $ v , $ k ) { <nl> mmm a / hphp / test / quick / vec / unset . php . expect <nl> ppp b / hphp / test / quick / vec / unset . php . expect <nl> vec ( 3 ) { <nl> object ( Dtor ) # 1 ( 0 ) { <nl> } <nl> } <nl> - Dtor : : __destruct <nl> vec ( 2 ) { <nl> int ( 1 ) <nl> string ( 3 ) " abc " <nl> - } <nl> \ No newline at end of file <nl> + } <nl> deleted file mode 100644 <nl> index ce78570bd72 . . 00000000000 <nl> mmm a / hphp / test / quick / vector - stack - base . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - / / Copyright 2004 - 2015 Facebook . All Rights Reserved . <nl> - <nl> - class dumper { <nl> - private static $ idx = 0 ; <nl> - private $ n ; <nl> - public $ prop = ' default value ' ; <nl> - function __construct ( ) { <nl> - $ this - > n = self : : $ idx + + ; <nl> - printf ( " dumper % d constructing \ n " , $ this - > n ) ; <nl> - } <nl> - function __destruct ( ) { <nl> - printf ( " dumper % d destructing \ n " , $ this - > n ) ; <nl> - if ( isset ( $ this - > arr ) ) { <nl> - var_dump ( $ this - > arr ) ; <nl> - } <nl> - var_dump ( $ this ) ; <nl> - } <nl> - } <nl> - <nl> - function makeObj ( ) { <nl> - return new dumper ; <nl> - } <nl> - <nl> - function makeArr ( ) { <nl> - $ a = array ( ) ; <nl> - $ a [ ' dumper ' ] = new dumper ; <nl> - return $ a ; <nl> - } <nl> - <nl> - function main ( ) { <nl> - echo " Entering main \ n " ; <nl> - / / SetM with array base on the stack <nl> - makeArr ( ) [ ' dumper ' ] = new stdclass ; <nl> - <nl> - / / More complex SetM with array base on the stack <nl> - makeArr ( ) [ ' dumper ' ] - > prop = null ; <nl> - <nl> - / / SetM and CGetM with an object base on the stack <nl> - makeObj ( ) - > prop = ' foo ' ; <nl> - var_dump ( makeObj ( ) - > prop ) ; <nl> - var_dump ( makeObj ( ) - > prop [ 2 ] ) ; <nl> - <nl> - / / UnsetM <nl> - unset ( makeArr ( ) [ ' dumper ' ] ) ; <nl> - <nl> - echo " Done with main \ n " ; <nl> - } <nl> - <nl> - echo " Calling main \ n " ; <nl> - main ( ) ; <nl> - echo " Main has returned \ n " ; <nl> - <nl> deleted file mode 100644 <nl> index cd6b6af179a . . 00000000000 <nl> mmm a / hphp / test / quick / vector - stack - base . php . expect <nl> ppp / dev / null <nl> <nl> - Calling main <nl> - Entering main <nl> - dumper 0 constructing <nl> - dumper 0 destructing <nl> - object ( dumper ) # 1 ( 2 ) { <nl> - [ " n " : " dumper " : private ] = > <nl> - int ( 0 ) <nl> - [ " prop " ] = > <nl> - string ( 13 ) " default value " <nl> - } <nl> - dumper 1 constructing <nl> - dumper 1 destructing <nl> - object ( dumper ) # 2 ( 2 ) { <nl> - [ " n " : " dumper " : private ] = > <nl> - int ( 1 ) <nl> - [ " prop " ] = > <nl> - NULL <nl> - } <nl> - dumper 2 constructing <nl> - dumper 2 destructing <nl> - object ( dumper ) # 2 ( 2 ) { <nl> - [ " n " : " dumper " : private ] = > <nl> - int ( 2 ) <nl> - [ " prop " ] = > <nl> - string ( 3 ) " foo " <nl> - } <nl> - dumper 3 constructing <nl> - dumper 3 destructing <nl> - object ( dumper ) # 2 ( 2 ) { <nl> - [ " n " : " dumper " : private ] = > <nl> - int ( 3 ) <nl> - [ " prop " ] = > <nl> - string ( 13 ) " default value " <nl> - } <nl> - string ( 13 ) " default value " <nl> - dumper 4 constructing <nl> - dumper 4 destructing <nl> - object ( dumper ) # 2 ( 2 ) { <nl> - [ " n " : " dumper " : private ] = > <nl> - int ( 4 ) <nl> - [ " prop " ] = > <nl> - string ( 13 ) " default value " <nl> - } <nl> - string ( 1 ) " f " <nl> - dumper 5 constructing <nl> - dumper 5 destructing <nl> - object ( dumper ) # 2 ( 2 ) { <nl> - [ " n " : " dumper " : private ] = > <nl> - int ( 5 ) <nl> - [ " prop " ] = > <nl> - string ( 13 ) " default value " <nl> - } <nl> - Done with main <nl> - Main has returned <nl> mmm a / hphp / test / quick / vector - unwind - decref . php <nl> ppp b / hphp / test / quick / vector - unwind - decref . php <nl> public function __construct ( ) { <nl> echo " logger2 constructing \ n " ; <nl> } <nl> <nl> - public function __destruct ( ) { <nl> - echo " logger2 destructing \ n " ; <nl> - } <nl> - <nl> public function __set ( $ name , $ value ) { <nl> echo " set was called , throwing an exception \ n " ; <nl> throw new Exception ( ' nope ' ) ; <nl> public function __construct ( ) { <nl> echo " logger constructing \ n " ; <nl> } <nl> <nl> - public function __destruct ( ) { <nl> - echo " logger destructing \ n " ; <nl> - } <nl> - <nl> public function __set ( $ name , $ value ) { <nl> echo " set was called \ n " ; <nl> } <nl> public function __construct ( ) { <nl> echo " c constructing \ n " ; <nl> } <nl> <nl> - public function __destruct ( ) { <nl> - echo " c destructing \ n " ; <nl> - } <nl> - <nl> public function __get ( $ name ) { <nl> echo " returning new logger \ n " ; <nl> return new logger ; <nl> public function __construct ( ) { <nl> echo " d constructing \ n " ; <nl> } <nl> <nl> - public function __destruct ( ) { <nl> - echo " d destructing \ n " ; <nl> - } <nl> - <nl> public function __get ( $ name ) { <nl> echo " returning new logger2 \ n " ; <nl> return new logger2 ; <nl> mmm a / hphp / test / quick / vector - unwind - decref . php . expect <nl> ppp b / hphp / test / quick / vector - unwind - decref . php . expect <nl> calling c . __get ( ) and logger . __set ( ) <nl> returning new logger <nl> logger constructing <nl> set was called <nl> - logger destructing <nl> calling c . __get ( ) and logger . __get ( ) <nl> returning new logger <nl> logger constructing <nl> get was called <nl> - logger destructing <nl> got value 10 <nl> creating new d <nl> d constructing <nl> calling d . __get ( ) and logger2 . __set ( ) <nl> returning new logger2 <nl> logger2 constructing <nl> set was called , throwing an exception <nl> - logger2 destructing <nl> - d destructing <nl> - c destructing <nl> Caught exception <nl> last line <nl> mmm a / hphp / test / quick / xenon / xenon_crash . php <nl> ppp b / hphp / test / quick / xenon / xenon_crash . php <nl> <nl> } <nl> <nl> class X { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> } <nl> <nl> class A { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> - <nl> async function gen1 ( $ a ) { <nl> await RescheduleWaitHandle : : create ( 0 , 0 ) ; / / simulate blocking I / O <nl> return $ a + 1 ; <nl> mmm a / hphp / test / quick / xenon / xenon_crash . php . expect <nl> ppp b / hphp / test / quick / xenon / xenon_crash . php . expect <nl> @ @ - 1 , 6 + 1 @ @ <nl> - string ( 13 ) " X : : __destruct " <nl> - string ( 13 ) " A : : __destruct " <nl> - string ( 13 ) " X : : __destruct " <nl> - string ( 13 ) " A : : __destruct " <nl> - string ( 13 ) " A : : __destruct " <nl> int ( 91 ) <nl> mmm a / hphp / test / quick / zend_closure_005 . php <nl> ppp b / hphp / test / quick / zend_closure_005 . php <nl> function __construct ( $ x ) { <nl> $ this - > x = $ x ; <nl> } <nl> <nl> - function __destruct ( ) { <nl> - echo " Destroyed \ n " ; <nl> - } <nl> - <nl> function getIncer ( $ val ) { <nl> return function ( ) use ( $ val ) { <nl> $ this - > x + = $ val ; <nl> mmm a / hphp / test / quick / zend_closure_005 . php . expect <nl> ppp b / hphp / test / quick / zend_closure_005 . php . expect <nl> <nl> 5 <nl> 7 <nl> 7 <nl> - Destroyed <nl> mmm a / hphp / test / run . php <nl> ppp b / hphp / test / run . php <nl> function run_config_post ( $ outputs , $ test , $ options ) { <nl> if ( ( ! $ is_tc & & ( $ type = = = ' expect ' | | $ type = = = ' hhvm . expect ' ) ) | | <nl> ( $ is_tc & & $ type = = = ' typechecker . expect ' ) ) { <nl> $ wanted = trim ( file_get_contents ( $ file ) ) ; <nl> - if ( isset ( $ options [ ' ignore - oids ' ] ) ) { <nl> + if ( isset ( $ options [ ' ignore - oids ' ] ) | | isset ( $ options [ ' repo ' ] ) ) { <nl> $ output = replace_object_resource_ids ( $ output , ' n ' ) ; <nl> $ wanted = replace_object_resource_ids ( $ wanted , ' n ' ) ; <nl> } <nl> function run_config_post ( $ outputs , $ test , $ options ) { <nl> } else if ( ( ! $ is_tc & & ( $ type = = = ' expectf ' | | $ type = = = ' hhvm . expectf ' ) ) | | <nl> ( $ is_tc & & $ type = = = ' typechecker . expectf ' ) ) { <nl> $ wanted = trim ( file_get_contents ( $ file ) ) ; <nl> - if ( isset ( $ options [ ' ignore - oids ' ] ) ) { <nl> + if ( isset ( $ options [ ' ignore - oids ' ] ) | | isset ( $ options [ ' repo ' ] ) ) { <nl> $ wanted = replace_object_resource_ids ( $ wanted , ' % d ' ) ; <nl> } <nl> $ wanted_re = $ wanted ; <nl> mmm a / hphp / test / slow / arithmetic / power - assign - decref . php <nl> ppp b / hphp / test / slow / arithmetic / power - assign - decref . php <nl> <nl> < ? php <nl> <nl> class D { <nl> - public $ id ; <nl> - <nl> - public function __construct ( $ id ) { <nl> - $ this - > id = $ id ; <nl> - } <nl> - <nl> - public function __destruct ( ) { <nl> - echo " Instance $ this - > id destroyed ! \ n " ; <nl> - } <nl> } <nl> <nl> function main ( ) { <nl> - $ i1 = new D ( ' + = ' ) ; <nl> - $ i2 = new D ( ' - = ' ) ; <nl> - $ i3 = new D ( ' * = ' ) ; <nl> - $ i4 = new D ( ' / = ' ) ; <nl> - $ i5 = new D ( ' % = ' ) ; <nl> - $ i6 = new D ( ' * * = ' ) ; <nl> - $ i7 = new D ( ' & = ' ) ; <nl> - $ i8 = new D ( ' | = ' ) ; <nl> - $ i9 = new D ( ' ^ = ' ) ; <nl> + $ i1 = new D ; <nl> + $ i2 = new D ; <nl> + $ i3 = new D ; <nl> + $ i4 = new D ; <nl> + $ i5 = new D ; <nl> + $ i6 = new D ; <nl> + $ i7 = new D ; <nl> + $ i8 = new D ; <nl> + $ i9 = new D ; <nl> <nl> $ i1 + = 1 ; <nl> $ i2 - = 1 ; <nl> mmm a / hphp / test / slow / arithmetic / power - assign - decref . php . expectf <nl> ppp b / hphp / test / slow / arithmetic / power - assign - decref . php . expectf <nl> <nl> <nl> - Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 26 <nl> - Instance + = destroyed ! <nl> + Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 17 <nl> <nl> - Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 27 <nl> - Instance - = destroyed ! <nl> + Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 18 <nl> <nl> - Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 28 <nl> - Instance * = destroyed ! <nl> + Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 19 <nl> <nl> - Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 29 <nl> - Instance / = destroyed ! <nl> + Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 20 <nl> <nl> - Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 30 <nl> - Instance % = destroyed ! <nl> + Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 21 <nl> <nl> - Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 31 <nl> - Instance * * = destroyed ! <nl> + Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 22 <nl> <nl> - Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 32 <nl> - Instance & = destroyed ! <nl> + Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 23 <nl> <nl> - Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 33 <nl> - Instance | = destroyed ! <nl> + Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 24 <nl> <nl> - Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 34 <nl> - Instance ^ = destroyed ! <nl> + Notice : Object of class D could not be converted to int in % s / arithmetic / power - assign - decref . php on line 25 <nl> int ( 2 ) <nl> int ( 0 ) <nl> int ( 1 ) <nl> mmm a / hphp / test / slow / array / 243 . php <nl> ppp b / hphp / test / slow / array / 243 . php <nl> <nl> < ? php <nl> <nl> class X { <nl> - function __destruct ( ) { <nl> - var_dump ( ' two ' ) ; <nl> - } <nl> } <nl> function test ( $ a ) { <nl> $ x = array ( new X ) ; <nl> mmm a / hphp / test / slow / array / 243 . php . expectf <nl> ppp b / hphp / test / slow / array / 243 . php . expectf <nl> <nl> <nl> - Warning : Cannot use a scalar value as an array in % s / test / slow / array / 243 . php on line 10 <nl> + Warning : Cannot use a scalar value as an array in % s / test / slow / array / 243 . php on line 7 <nl> string ( 3 ) " one " <nl> array ( 1 ) { <nl> [ 0 ] = > <nl> object ( X ) # 1 ( 0 ) { <nl> } <nl> } <nl> - string ( 3 ) " two " <nl> string ( 5 ) " three " <nl> deleted file mode 100644 <nl> index 2397dda4ae5 . . 00000000000 <nl> mmm a / hphp / test / slow / array / array_splice_destructors . php <nl> ppp / dev / null <nl> <nl> - < ? php / * destructor * / <nl> - <nl> - class C { <nl> - private $ a ; <nl> - function __construct ( & $ a ) { $ this - > a = & $ a ; } <nl> - function __destruct ( ) { <nl> - / / tripling the number of things in an array should cause it to realloc <nl> - $ c = count ( $ this - > a ) * 2 ; <nl> - for ( $ i = 0 ; $ i < $ c ; $ i + + ) { $ this - > a [ ] = ' lol ' ; } <nl> - } <nl> - } <nl> - <nl> - function test ( ) { <nl> - $ a = array ( 1 , 2 , 3 ) ; <nl> - $ a [ ] = new C ( & $ a ) ; <nl> - array_splice ( & $ a , 2 ) ; <nl> - var_dump ( $ a ) ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_array_splice_destructors ( ) { <nl> - test ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 9a5a13642ce . . 00000000000 <nl> mmm a / hphp / test / slow / array / array_splice_destructors . php . expect <nl> ppp / dev / null <nl> <nl> - array ( 6 ) { <nl> - [ 0 ] = > <nl> - int ( 1 ) <nl> - [ 1 ] = > <nl> - int ( 2 ) <nl> - [ 2 ] = > <nl> - string ( 3 ) " lol " <nl> - [ 3 ] = > <nl> - string ( 3 ) " lol " <nl> - [ 4 ] = > <nl> - string ( 3 ) " lol " <nl> - [ 5 ] = > <nl> - string ( 3 ) " lol " <nl> - } <nl> deleted file mode 100644 <nl> index 710bced616b . . 00000000000 <nl> mmm a / hphp / test / slow / array / globals_vs_destructor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class C { <nl> - public function __destruct ( ) { <nl> - echo " C : : __destruct \ n " ; <nl> - global $ obj ; <nl> - var_dump ( $ obj ) ; <nl> - $ obj = 23 ; <nl> - echo " C : : __destruct done \ n " ; <nl> - } <nl> - } <nl> - <nl> - function test ( ) { <nl> - $ a = $ GLOBALS ; <nl> - $ a [ ' obj ' ] = new C ; <nl> - $ a [ ' obj ' ] = 42 ; <nl> - var_dump ( $ a [ ' obj ' ] ) ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_globals_vs_destructor ( ) { <nl> - test ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 9219d210b16 . . 00000000000 <nl> mmm a / hphp / test / slow / array / globals_vs_destructor . php . expect <nl> ppp / dev / null <nl> <nl> - C : : __destruct <nl> - int ( 42 ) <nl> - C : : __destruct done <nl> - int ( 23 ) <nl> mmm a / hphp / test / slow / array / promote_string2 . php <nl> ppp b / hphp / test / slow / array / promote_string2 . php <nl> <nl> < ? php <nl> <nl> class X { <nl> - function __destruct ( ) { var_dump ( __METHOD__ ) ; } <nl> function __toString ( ) { return __METHOD__ ; } <nl> } <nl> <nl> mmm a / hphp / test / slow / array / promote_string2 . php . expectf <nl> ppp b / hphp / test / slow / array / promote_string2 . php . expectf <nl> array ( 1 ) { <nl> object ( X ) # 1 ( 0 ) { <nl> } <nl> } <nl> - string ( 13 ) " X : : __destruct " <nl> 1 <nl> <nl> - Warning : Illegal string offset : - 1 in % s / test / slow / array / promote_string2 . php on line 9 <nl> - string ( 13 ) " X : : __destruct " <nl> + Warning : Illegal string offset : - 1 in % s / test / slow / array / promote_string2 . php on line 8 <nl> NULL <nl> string ( 1 ) " x " <nl> 2 <nl> deleted file mode 100644 <nl> index bc6a695d06c . . 00000000000 <nl> mmm a / hphp / test / slow / array / set_bad_key_dtor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - function err ( ) { echo " yep \ n " ; } <nl> - class dtor { private $ i ; function __construct ( $ i ) { $ this - > i = $ i ; } <nl> - function __destruct ( ) { echo " dtor $ this - > i \ n " ; } } <nl> - <nl> - class A { <nl> - public $ z = array ( 1 , 2 , 3 ) ; <nl> - } <nl> - function x ( $ a ) { <nl> - var_dump ( $ a - > z [ new dtor ( 1 ) ] = new dtor ( 5 ) ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_set_bad_key_dtor ( ) { <nl> - set_error_handler ( ' err ' ) ; <nl> - x ( new A ) ; <nl> - echo " done \ n " ; <nl> - } <nl> deleted file mode 100644 <nl> index 8af570a263f . . 00000000000 <nl> mmm a / hphp / test / slow / array / set_bad_key_dtor . php . expect <nl> ppp / dev / null <nl> <nl> - yep <nl> - dtor 5 <nl> - dtor 1 <nl> - NULL <nl> - done <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 7bbea6556ea . . 00000000000 <nl> mmm a / hphp / test / slow / array / set_bad_key_dtor2 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - function err ( ) { echo " yep \ n " ; } <nl> - class dtor { private $ i ; function __construct ( $ i ) { $ this - > i = $ i ; } <nl> - function __destruct ( ) { echo " dtor $ this - > i \ n " ; } } <nl> - <nl> - class stringable { <nl> - function __destruct ( ) { echo " ~ stringable \ n " ; } <nl> - function __toString ( ) { return " z " ; } <nl> - } <nl> - <nl> - class A { <nl> - public $ z = array ( 1 , 2 , 3 ) ; <nl> - } <nl> - function x ( $ a ) { <nl> - var_dump ( $ a - > { new stringable } [ new dtor ( 1 ) ] = new dtor ( 5 ) ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_set_bad_key_dtor2 ( ) { <nl> - set_error_handler ( ' err ' ) ; <nl> - x ( new A ) ; <nl> - echo " done \ n " ; <nl> - } <nl> deleted file mode 100644 <nl> index 0e0488d7b21 . . 00000000000 <nl> mmm a / hphp / test / slow / array / set_bad_key_dtor2 . php . expect <nl> ppp / dev / null <nl> <nl> - yep <nl> - dtor 5 <nl> - dtor 1 <nl> - ~ stringable <nl> - NULL <nl> - done <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 901d3c86537 . . 00000000000 <nl> mmm a / hphp / test / slow / array / set_key_dtor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class dtor { private $ i ; function __construct ( $ i ) { $ this - > i = $ i ; } <nl> - function __destruct ( ) { echo " dtor $ this - > i \ n " ; } } <nl> - <nl> - class heh implements ArrayAccess { <nl> - function offsetExists ( $ x ) { return true ; } <nl> - function offsetGet ( $ x ) { return new heh ( ) ; } <nl> - function offsetSet ( $ x , $ y ) { echo " setting \ n " ; } <nl> - function offsetUnset ( $ x ) { } <nl> - } <nl> - <nl> - class A { <nl> - public $ z ; <nl> - function __construct ( ) { $ this - > z = new heh ; } <nl> - } <nl> - function x ( $ a ) { <nl> - $ a - > z [ new dtor ( 1 ) ] [ new dtor ( 2 ) ] [ new dtor ( 3 ) ] [ new dtor ( 4 ) ] = new dtor ( 5 ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_set_key_dtor ( ) { <nl> - x ( new A ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 674ac638e6f . . 00000000000 <nl> mmm a / hphp / test / slow / array / set_key_dtor . php . expect <nl> ppp / dev / null <nl> <nl> - setting <nl> - dtor 4 <nl> - dtor 3 <nl> - dtor 2 <nl> - dtor 1 <nl> - dtor 5 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 6ee96b26f24 . . 00000000000 <nl> mmm a / hphp / test / slow / array / set_key_dtor2 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class dtor { <nl> - private $ i ; <nl> - function __construct ( $ i ) { $ this - > i = $ i ; } <nl> - function __destruct ( ) { echo " dtor $ this - > i \ n " ; } <nl> - function __toString ( ) { return ' z ' ; } <nl> - } <nl> - <nl> - class heh { <nl> - function __get ( $ x ) { return new heh ; } <nl> - } <nl> - <nl> - class A { <nl> - public $ z ; <nl> - function __construct ( ) { $ this - > z = new heh ; } <nl> - } <nl> - function x ( $ a ) { <nl> - $ a - > { new dtor ( 1 ) } - > { new dtor ( 2 ) } - > { new dtor ( 3 ) } - > { new dtor ( 4 ) } = new dtor ( 5 ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_set_key_dtor2 ( ) { <nl> - x ( new A ) ; <nl> - } <nl> deleted file mode 100644 <nl> index b1045e209b6 . . 00000000000 <nl> mmm a / hphp / test / slow / array / set_key_dtor2 . php . expect <nl> ppp / dev / null <nl> <nl> - dtor 4 <nl> - dtor 3 <nl> - dtor 2 <nl> - dtor 1 <nl> - dtor 5 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index e4174474ce5 . . 00000000000 <nl> mmm a / hphp / test / slow / array / set_key_dtor3 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class dtor { <nl> - private $ i ; <nl> - function __construct ( $ i ) { $ this - > i = $ i ; } <nl> - function __destruct ( ) { echo " dtor $ this - > i \ n " ; } <nl> - function __toString ( ) { return $ this - > i = = 4 ? ' x ' : ' z ' ; } <nl> - } <nl> - <nl> - class heh { <nl> - private $ i = 0 ; <nl> - function __get ( $ x ) { <nl> - if ( $ x = = ' x ' ) return " asd " ; <nl> - return new heh ; <nl> - } <nl> - } <nl> - <nl> - class A { <nl> - public $ z ; <nl> - function __construct ( ) { $ this - > z = new heh ; } <nl> - } <nl> - function x ( $ a ) { <nl> - / / This is going to take the strTestResult branch . <nl> - var_dump ( <nl> - $ a - > { new dtor ( 1 ) } - > { new dtor ( 2 ) } - > { new dtor ( 3 ) } - > { new dtor ( 4 ) } [ 0 ] <nl> - = new dtor ( 5 ) <nl> - ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_set_key_dtor3 ( ) { <nl> - x ( new A ) ; <nl> - } <nl> deleted file mode 100644 <nl> index b4d98cf2d06 . . 00000000000 <nl> mmm a / hphp / test / slow / array / set_key_dtor3 . php . expect <nl> ppp / dev / null <nl> <nl> - dtor 5 <nl> - dtor 4 <nl> - dtor 3 <nl> - dtor 2 <nl> - dtor 1 <nl> - string ( 1 ) " z " <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index b5599f32c01 . . 00000000000 <nl> mmm a / hphp / test / slow / array_access / ratchet_decref_order . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - function err ( ) { echo " err \ n " ; } <nl> - <nl> - class dtor implements ArrayAccess { <nl> - private $ num ; <nl> - function __construct ( $ num ) { $ this - > num = $ num ; } <nl> - function __destruct ( ) { echo " dtor : $ this - > num \ n " ; } <nl> - <nl> - function offsetExists ( $ x ) { return true ; } <nl> - function offsetGet ( $ x ) { return array ( ) ; } <nl> - function offsetSet ( $ x , $ y ) { <nl> - echo " set \ n " ; <nl> - throw new exception ( ) ; <nl> - } <nl> - function offsetUnset ( $ x ) { } <nl> - public $ asd = array ( array ( 0 , 1 , 2 ) ) ; <nl> - } <nl> - <nl> - class heh implements ArrayAccess { <nl> - function offsetExists ( $ x ) { return true ; } <nl> - function offsetGet ( $ x ) { return new dtor ( 1 ) ; } <nl> - function offsetSet ( $ x , $ y ) { } <nl> - function offsetUnset ( $ x ) { } <nl> - } <nl> - <nl> - function get ( ) { echo " get \ n " ; return 0 ; } <nl> - <nl> - function heh2 ( $ x , $ foo ) { <nl> - try { <nl> - return $ x [ $ foo ] - > asd [ 0 ] [ new dtor ( 2 ) ] = new dtor ( 3 ) ; <nl> - } catch ( exception $ x ) { return null ; } <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_ratchet_decref_order ( ) { <nl> - set_error_handler ( ' err ' ) ; <nl> - <nl> - var_dump ( heh2 ( new heh , 0 ) ) ; <nl> - echo " ok \ n " ; <nl> - } <nl> deleted file mode 100644 <nl> index f738301c3f3 . . 00000000000 <nl> mmm a / hphp / test / slow / array_access / ratchet_decref_order . php . expect <nl> ppp / dev / null <nl> <nl> - err <nl> - dtor : 3 <nl> - dtor : 2 <nl> - dtor : 1 <nl> - NULL <nl> - ok <nl> \ No newline at end of file <nl> mmm a / hphp / test / slow / array_for_each / 500 . php <nl> ppp b / hphp / test / slow / array_for_each / 500 . php <nl> <nl> < ? php <nl> <nl> class X { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> } <nl> function test ( ) { <nl> $ a = array ( new X , 0 ) ; <nl> mmm a / hphp / test / slow / array_for_each / 500 . php . expect <nl> ppp b / hphp / test / slow / array_for_each / 500 . php . expect <nl> <nl> object ( X ) # 1 ( 0 ) { <nl> } <nl> int ( 0 ) <nl> - string ( 13 ) " X : : __destruct " <nl> string ( 4 ) " done " <nl> string ( 4 ) " exit " <nl> mmm a / hphp / test / slow / array_iterator / 446 . php <nl> ppp b / hphp / test / slow / array_iterator / 446 . php <nl> class A { <nl> public function __construct ( ) { <nl> var_dump ( __METHOD__ ) ; <nl> } <nl> - public function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> } <nl> class B { <nl> public $ a ; <nl> public function gen ( ) { <nl> ex ( ' die ! ' ) ; <nl> yield ( 2 ) ; <nl> } <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> } <nl> class II { <nl> private $ tn , $ tv ; <nl> function __construct ( $ tn , $ tv ) { <nl> $ this - > tn = $ tn ; <nl> $ this - > tv = $ tv ; <nl> } <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> public function gen ( ) { <nl> return new I ( $ this - > tn , $ this - > tv ) ; <nl> } <nl> function __construct ( $ tn , $ tv ) { <nl> $ this - > tn = $ tn ; <nl> $ this - > tv = $ tv ; <nl> } <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> public function gen ( ) { <nl> return new J ( $ this - > tn , $ this - > tv ) ; <nl> } <nl> function __construct ( $ tn , $ tv ) { <nl> $ this - > tn = $ tn ; <nl> $ this - > tv = $ tv ; <nl> } <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> public function gen ( ) { <nl> return new K ( $ this - > tn , $ this - > tv ) ; <nl> } <nl> function __construct ( $ tn , $ tv ) { <nl> $ this - > tn = $ tn ; <nl> $ this - > tv = $ tv ; <nl> } <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> public function gen ( ) { <nl> return new L ( $ this - > tn , $ this - > tv ) ; <nl> } <nl> public function __construct ( $ tn , $ tv ) { <nl> $ this - > tn = $ tn ; <nl> $ this - > tv = $ tv ; <nl> } <nl> - public function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> public function rewind ( ) { <nl> var_dump ( __METHOD__ ) ; <nl> if ( $ this - > tn = = 0 ) ex ( __METHOD__ ) ; <nl> class J implements IteratorAggregate { <nl> public function __construct ( $ tn , $ tv ) { <nl> $ this - > i = new I ( $ tn , $ tv ) ; <nl> } <nl> - public function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> public function getIterator ( ) { <nl> return $ this - > i ; <nl> } <nl> public function __construct ( $ tn , $ tv ) { <nl> $ this - > tn = $ tn ; <nl> $ this - > tv = $ tv ; <nl> } <nl> - public function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> public function getIterator ( ) { <nl> return new I ( $ this - > tn , $ this - > tv ) ; <nl> } <nl> mmm a / hphp / test / slow / array_iterator / 446 . php . expect <nl> ppp b / hphp / test / slow / array_iterator / 446 . php . expect <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 19 ) " Throwing : I : : rewind " <nl> string ( 20 ) " Exception : I : : rewind " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : I " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 8 ) " I : : valid " <nl> string ( 18 ) " Throwing : I : : valid " <nl> string ( 19 ) " Exception : I : : valid " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : I " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 5 ) " got 2 " <nl> string ( 7 ) " I : : next " <nl> string ( 17 ) " Throwing : I : : next " <nl> string ( 18 ) " Exception : I : : next " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : I " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 19 ) " Throwing : I : : rewind " <nl> string ( 20 ) " Exception : I : : rewind " <nl> - string ( 13 ) " J : : __destruct " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : J " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 8 ) " I : : valid " <nl> string ( 18 ) " Throwing : I : : valid " <nl> string ( 19 ) " Exception : I : : valid " <nl> - string ( 13 ) " J : : __destruct " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : J " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 5 ) " got 2 " <nl> string ( 7 ) " I : : next " <nl> string ( 17 ) " Throwing : I : : next " <nl> string ( 18 ) " Exception : I : : next " <nl> - string ( 13 ) " J : : __destruct " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : J " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 19 ) " Throwing : I : : rewind " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 20 ) " Exception : I : : rewind " <nl> - string ( 13 ) " K : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : K " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 8 ) " I : : valid " <nl> string ( 18 ) " Throwing : I : : valid " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 19 ) " Exception : I : : valid " <nl> - string ( 13 ) " K : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : K " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 10 ) " I : : current " <nl> string ( 5 ) " got 2 " <nl> string ( 7 ) " I : : next " <nl> string ( 17 ) " Throwing : I : : next " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 18 ) " Exception : I : : next " <nl> - string ( 13 ) " K : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : K " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 24 ) " Throwing : L : : getIterator " <nl> string ( 25 ) " Exception : L : : getIterator " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : L " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 24 ) " Throwing : L : : getIterator " <nl> string ( 25 ) " Exception : L : : getIterator " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : L " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 24 ) " Throwing : L : : getIterator " <nl> string ( 25 ) " Exception : L : : getIterator " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : L " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 19 ) " Throwing : I : : rewind " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 20 ) " Exception : I : : rewind " <nl> - string ( 14 ) " II : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : II " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 8 ) " I : : valid " <nl> string ( 18 ) " Throwing : I : : valid " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 19 ) " Exception : I : : valid " <nl> - string ( 14 ) " II : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : II " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 10 ) " I : : current " <nl> string ( 5 ) " got 2 " <nl> string ( 7 ) " I : : next " <nl> string ( 17 ) " Throwing : I : : next " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 18 ) " Exception : I : : next " <nl> - string ( 14 ) " II : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : II " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 19 ) " Throwing : I : : rewind " <nl> - string ( 13 ) " J : : __destruct " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 20 ) " Exception : I : : rewind " <nl> - string ( 14 ) " JJ : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : JJ " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 8 ) " I : : valid " <nl> string ( 18 ) " Throwing : I : : valid " <nl> - string ( 13 ) " J : : __destruct " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 19 ) " Exception : I : : valid " <nl> - string ( 14 ) " JJ : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : JJ " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 8 ) " I : : valid " <nl> - string ( 13 ) " J : : __destruct " <nl> string ( 10 ) " I : : current " <nl> string ( 5 ) " got 1 " <nl> string ( 7 ) " I : : next " <nl> string ( 10 ) " I : : current " <nl> string ( 5 ) " got 2 " <nl> string ( 7 ) " I : : next " <nl> string ( 17 ) " Throwing : I : : next " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 18 ) " Exception : I : : next " <nl> - string ( 14 ) " JJ : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : JJ " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 19 ) " Throwing : I : : rewind " <nl> - string ( 13 ) " I : : __destruct " <nl> - string ( 13 ) " K : : __destruct " <nl> string ( 20 ) " Exception : I : : rewind " <nl> - string ( 14 ) " KK : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : KK " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 8 ) " I : : valid " <nl> string ( 18 ) " Throwing : I : : valid " <nl> - string ( 13 ) " I : : __destruct " <nl> - string ( 13 ) " K : : __destruct " <nl> string ( 19 ) " Exception : I : : valid " <nl> - string ( 14 ) " KK : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : KK " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 9 ) " I : : rewind " <nl> string ( 8 ) " I : : valid " <nl> - string ( 13 ) " K : : __destruct " <nl> string ( 10 ) " I : : current " <nl> string ( 5 ) " got 1 " <nl> string ( 7 ) " I : : next " <nl> string ( 10 ) " I : : current " <nl> string ( 5 ) " got 2 " <nl> string ( 7 ) " I : : next " <nl> string ( 17 ) " Throwing : I : : next " <nl> - string ( 13 ) " I : : __destruct " <nl> string ( 18 ) " Exception : I : : next " <nl> - string ( 14 ) " KK : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : KK " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 24 ) " Throwing : L : : getIterator " <nl> string ( 25 ) " Exception : L : : getIterator " <nl> - string ( 14 ) " LL : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : LL " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 24 ) " Throwing : L : : getIterator " <nl> string ( 25 ) " Exception : L : : getIterator " <nl> - string ( 14 ) " LL : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : LL " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 24 ) " Throwing : L : : getIterator " <nl> string ( 25 ) " Exception : L : : getIterator " <nl> - string ( 14 ) " LL : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 8 ) " Done : LL " <nl> string ( 7 ) " > > > main " <nl> string ( 14 ) " A : : __construct " <nl> string ( 14 ) " Throwing : die ! " <nl> string ( 15 ) " Exception : die ! " <nl> - string ( 13 ) " B : : __destruct " <nl> string ( 7 ) " < < < main " <nl> - string ( 13 ) " A : : __destruct " <nl> string ( 7 ) " Done : B " <nl> deleted file mode 100644 <nl> index 155a0b58531 . . 00000000000 <nl> mmm a / hphp / test / slow / assignment / 1705 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class X { <nl> - function __destruct ( ) { <nl> - var_dump ( ' destruct ' ) ; <nl> - } <nl> - } <nl> - function foo ( ) { <nl> - $ x = new X ; <nl> - var_dump ( ' before ' ) ; <nl> - $ x = null ; <nl> - var_dump ( ' after ' ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_1705 ( ) { <nl> - foo ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 24aeca51727 . . 00000000000 <nl> mmm a / hphp / test / slow / assignment / 1705 . php . expect <nl> ppp / dev / null <nl> <nl> - string ( 6 ) " before " <nl> - string ( 8 ) " destruct " <nl> - string ( 5 ) " after " <nl> deleted file mode 100644 <nl> index 61a06957a66 . . 00000000000 <nl> mmm a / hphp / test / slow / assignment / 1708 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class dom { <nl> - public $ kid ; <nl> - public function __destruct ( ) { <nl> - echo " dom destructing <nl> - " ; <nl> - $ this - > kid - > check ( ) ; <nl> - $ this - > kid - > clear_unset ( ) ; <nl> - } <nl> - } <nl> - <nl> - class node { <nl> - public $ dom ; <nl> - <nl> - public function __construct ( $ dom ) { <nl> - $ this - > dom = $ dom ; <nl> - $ dom - > kid = $ this ; <nl> - } <nl> - public function __destruct ( ) { <nl> - echo " node destructing <nl> - " ; <nl> - } <nl> - public function clear_unset ( ) { <nl> - unset ( $ this - > dom ) ; <nl> - } <nl> - public function clear_set ( ) { <nl> - $ this - > dom = null ; <nl> - } <nl> - public function check ( ) { <nl> - var_dump ( isset ( $ this - > dom ) ) ; <nl> - } <nl> - } <nl> - <nl> - class node_arr { <nl> - public $ doms = array ( ) ; <nl> - <nl> - public function __construct ( $ dom ) { <nl> - $ this - > doms [ 0 ] = $ dom ; <nl> - $ dom - > kid = $ this ; <nl> - } <nl> - public function __destruct ( ) { <nl> - echo " node destructing <nl> - " ; <nl> - } <nl> - public function clear_unset ( ) { <nl> - unset ( $ this - > doms [ 0 ] ) ; <nl> - } <nl> - public function clear_set ( ) { <nl> - $ this - > doms [ 0 ] = null ; <nl> - } <nl> - public function check ( ) { <nl> - var_dump ( isset ( $ this - > doms [ 0 ] ) ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_1708 ( ) { <nl> - echo " <nl> - Property , SetM <nl> - " ; <nl> - $ node = new node ( new dom ) ; <nl> - $ node - > clear_set ( ) ; <nl> - unset ( $ node ) ; <nl> - <nl> - echo " <nl> - Property , UnsetM <nl> - " ; <nl> - $ node = new node ( new dom ) ; <nl> - $ node - > clear_unset ( ) ; <nl> - unset ( $ node ) ; <nl> - <nl> - echo " <nl> - Array , SetM <nl> - " ; <nl> - $ node = new node_arr ( new dom ) ; <nl> - $ node - > clear_set ( ) ; <nl> - unset ( $ node ) ; <nl> - <nl> - echo " <nl> - Array , UnsetM <nl> - " ; <nl> - $ node = new node_arr ( new dom ) ; <nl> - $ node - > clear_unset ( ) ; <nl> - unset ( $ node ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 75d2605b511 . . 00000000000 <nl> mmm a / hphp / test / slow / assignment / 1708 . php . expect <nl> ppp / dev / null <nl> <nl> - <nl> - Property , SetM <nl> - dom destructing <nl> - bool ( false ) <nl> - node destructing <nl> - <nl> - Property , UnsetM <nl> - dom destructing <nl> - bool ( false ) <nl> - node destructing <nl> - <nl> - Array , SetM <nl> - dom destructing <nl> - bool ( false ) <nl> - node destructing <nl> - <nl> - Array , UnsetM <nl> - dom destructing <nl> - bool ( false ) <nl> - node destructing <nl> deleted file mode 100644 <nl> index f9b214f9f97 . . 00000000000 <nl> mmm a / hphp / test / slow / assignment / 1708 . php . skipif <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - # TODO remove this once T12771200 is fixed <nl> - if ( gc_enabled ( ) ) echo " skip \ n " ; <nl> mmm a / hphp / test / slow / async / async - gen - 0ref - on - retc . php <nl> ppp b / hphp / test / slow / async / async - gen - 0ref - on - retc . php <nl> <nl> < ? hh / / decl <nl> <nl> class Foo { <nl> - public function __destruct ( ) { <nl> - echo " generator destructed \ n " ; <nl> - } <nl> } <nl> <nl> async function foo ( ) { <nl> mmm a / hphp / test / slow / async / async - gen - 0ref - on - retc . php . expect <nl> ppp b / hphp / test / slow / async / async - gen - 0ref - on - retc . php . expect <nl> waiting for clearing ref <nl> clearing ref <nl> waiting for foo to finish <nl> finishing and destructing <nl> - generator destructed <nl> survived <nl> mmm a / hphp / test / slow / async / await_cpp_exception . php <nl> ppp b / hphp / test / slow / async / await_cpp_exception . php <nl> <nl> < ? hh / / decl <nl> <nl> - class ExitOnDestruct { <nl> - private function __destruct ( ) { <nl> - echo " exiting \ n " ; <nl> - exit ( 1 ) ; <nl> - } <nl> + function boom ( ) { <nl> + echo " exiting \ n " ; <nl> + exit ( 1 ) ; <nl> } <nl> <nl> async function block ( ) { <nl> await RescheduleWaitHandle : : create ( RescheduleWaitHandle : : QUEUE_DEFAULT , 0 ) ; <nl> } <nl> <nl> + async function failme ( ) { await block ( ) ; throw new Exception ; } <nl> + <nl> async function crash ( ) { <nl> await block ( ) ; <nl> $ block = block ( ) ; <nl> - $ x = new ExitOnDestruct ( ) ; <nl> - echo " triggering destructor \ n " ; <nl> - $ x = null ; <nl> - echo " will exit once suspend hook is called \ n " ; <nl> - await $ block ; <nl> + echo " triggering handler \ n " ; <nl> + await failme ( ) ; <nl> echo " should have exited ! \ n " ; <nl> } <nl> <nl> - <nl> < < __EntryPoint > > <nl> function main_await_cpp_exception ( ) { <nl> - HH \ Asio \ join ( crash ( ) ) ; <nl> + ResumableWaitHandle : : setOnFailCallback ( ( $ wh , $ e ) = = > boom ( ) ) ; <nl> + HH \ Asio \ join ( crash ( ) ) ; <nl> } <nl> mmm a / hphp / test / slow / async / await_cpp_exception . php . expect <nl> ppp b / hphp / test / slow / async / await_cpp_exception . php . expect <nl> <nl> - triggering destructor <nl> + triggering handler <nl> exiting <nl> - will exit once suspend hook is called <nl> deleted file mode 100644 <nl> index 185b9229fc3 . . 00000000000 <nl> mmm a / hphp / test / slow / async / await_cpp_exception2 . php <nl> ppp / dev / null <nl> <nl> - < ? hh / / decl <nl> - <nl> - class ExitOnDestruct { <nl> - private function __destruct ( ) { <nl> - echo " exiting . . . \ n " ; <nl> - exit ( 1 ) ; <nl> - } <nl> - } <nl> - <nl> - class DoubleDecRef { <nl> - private function __destruct ( ) { <nl> - echo " decref \ n " ; <nl> - } <nl> - } <nl> - <nl> - async function block ( ) { <nl> - await RescheduleWaitHandle : : create ( RescheduleWaitHandle : : QUEUE_DEFAULT , 0 ) ; <nl> - } <nl> - <nl> - function foo ( ) { <nl> - static $ wh = null ; <nl> - return $ wh = $ wh ? : block ( ) ; <nl> - } <nl> - <nl> - async function evil ( $ local ) { <nl> - $ dep = foo ( ) ; <nl> - new ExitOnDestruct ( ) ; <nl> - await $ dep ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_await_cpp_exception2 ( ) { <nl> - register_postsend_function ( function ( ) { <nl> - echo " postsend start \ n " ; <nl> - HH \ Asio \ join ( foo ( ) ) ; <nl> - echo " postsend end \ n " ; <nl> - } ) ; <nl> - <nl> - HH \ Asio \ join ( evil ( new DoubleDecRef ( ) ) ) ; <nl> - } <nl> deleted file mode 100644 <nl> index c4baeeb47a3 . . 00000000000 <nl> mmm a / hphp / test / slow / async / await_cpp_exception2 . php . expect <nl> ppp / dev / null <nl> <nl> - exiting . . . <nl> - postsend start <nl> - decref <nl> - postsend end <nl> mmm a / hphp / test / slow / async / foreach_await_as . php <nl> ppp b / hphp / test / slow / async / foreach_await_as . php <nl> public function __construct ( $ where ) { <nl> echo " constructing in { $ this - > where } \ n " ; <nl> } <nl> <nl> - private function __destruct ( ) { <nl> - echo " destructing in { $ this - > where } \ n " ; <nl> - } <nl> } <nl> <nl> function l ( $ obj , $ where ) { <nl> mmm a / hphp / test / slow / async / foreach_await_as . php . expect <nl> ppp b / hphp / test / slow / async / foreach_await_as . php . expect <nl> baz 47 <nl> 47 2209 103823 <nl> foo 48 <nl> bar 48 <nl> - destructing in bar <nl> end bar <nl> - destructing in baz <nl> - end baz <nl> \ No newline at end of file <nl> + end baz <nl> mmm a / hphp / test / slow / async / genva - refcnt . php <nl> ppp b / hphp / test / slow / async / genva - refcnt . php <nl> <nl> < ? hh / / decl <nl> <nl> class Marker { <nl> - public function __destruct ( ) { <nl> - echo " destructing \ n " ; <nl> - } <nl> } <nl> <nl> async function foo ( ) { <nl> public function __destruct ( ) { <nl> } <nl> <nl> async function bar ( ) { <nl> + var_dump ( objprof_get_data ( ) ) ; <nl> echo " genva 1 \ n " ; <nl> list ( $ a , $ b ) = await genva ( foo ( ) , foo ( ) ) ; <nl> echo " unset a \ n " ; <nl> public function __destruct ( ) { <nl> echo " genva 3 \ n " ; <nl> await genva ( foo ( ) , foo ( ) ) ; <nl> echo " done \ n " ; <nl> + var_dump ( objprof_get_data ( ) ) ; <nl> } <nl> <nl> <nl> mmm a / hphp / test / slow / async / genva - refcnt . php . expect <nl> ppp b / hphp / test / slow / async / genva - refcnt . php . expect <nl> <nl> + array ( 0 ) { <nl> + } <nl> genva 1 <nl> unset a <nl> - destructing <nl> unset b <nl> - destructing <nl> genva 2 <nl> - destructing <nl> - destructing <nl> genva 3 <nl> - destructing <nl> - destructing <nl> done <nl> + array ( 0 ) { <nl> + } <nl> exit <nl> mmm a / hphp / test / slow / async / suspend_hook_throw2 . php <nl> ppp b / hphp / test / slow / async / suspend_hook_throw2 . php <nl> function thrower ( $ why , $ what ) { <nl> } <nl> } <nl> <nl> - class dtor { <nl> - function __construct ( private $ i ) { } <nl> - function __destruct ( ) { echo " dtor : $ this - > i \ n " ; } <nl> - } <nl> - <nl> async function foo ( $ resched ) { <nl> - $ dtor = new dtor ( 1 ) ; <nl> echo " enter foo \ n " ; <nl> await $ resched ; <nl> echo " foo fallthrhough \ n " ; <nl> mmm a / hphp / test / slow / async / suspend_hook_throw2 . php . expect <nl> ppp b / hphp / test / slow / async / suspend_hook_throw2 . php . expect <nl> enter foo <nl> caught in get <nl> leaving get <nl> done <nl> - dtor : 1 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index a58b39c6440 . . 00000000000 <nl> mmm a / hphp / test / slow / collection_classes / vector_resize_destructors . php <nl> ppp / dev / null <nl> <nl> - < ? hh / / decl <nl> - <nl> - class C { <nl> - function __construct ( private $ v ) { } <nl> - function __destruct ( ) { <nl> - / / tripling the number of things in a Vector should cause it to realloc <nl> - $ c = $ this - > v - > count ( ) * 2 ; <nl> - for ( $ i = 0 ; $ i < $ c ; $ i + + ) { $ this - > v [ ] = ' lol ' ; } <nl> - } <nl> - } <nl> - <nl> - class D { <nl> - function __construct ( private $ v ) { } <nl> - function __destruct ( ) { <nl> - / / clearing should replace the underlying ArrayData with an empty one <nl> - $ this - > v - > clear ( ) ; <nl> - } <nl> - } <nl> - <nl> - function test ( ) { <nl> - $ v = Vector { 1 , 2 , 3 } ; <nl> - $ v [ ] = new C ( $ v ) ; <nl> - $ v - > resize ( 2 , ' IGNOREME ' ) ; <nl> - var_dump ( $ v ) ; <nl> - <nl> - $ v = Vector { 1 , 2 , 3 } ; <nl> - $ v [ ] = new D ( $ v ) ; <nl> - $ v - > resize ( 2 , ' IGNOREME ' ) ; <nl> - var_dump ( $ v ) ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_vector_resize_destructors ( ) { <nl> - test ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index e3909680da2 . . 00000000000 <nl> mmm a / hphp / test / slow / collection_classes / vector_resize_destructors . php . expect <nl> ppp / dev / null <nl> <nl> - object ( HH \ Vector ) # 1 ( 6 ) { <nl> - [ 0 ] = > <nl> - int ( 1 ) <nl> - [ 1 ] = > <nl> - int ( 2 ) <nl> - [ 2 ] = > <nl> - string ( 3 ) " lol " <nl> - [ 3 ] = > <nl> - string ( 3 ) " lol " <nl> - [ 4 ] = > <nl> - string ( 3 ) " lol " <nl> - [ 5 ] = > <nl> - string ( 3 ) " lol " <nl> - } <nl> - object ( HH \ Vector ) # 2 ( 0 ) { <nl> - } <nl> deleted file mode 100644 <nl> index 226b0e648ec . . 00000000000 <nl> mmm a / hphp / test / slow / collection_classes / vector_splice_destructors . php <nl> ppp / dev / null <nl> <nl> - < ? hh / / decl <nl> - <nl> - class C { <nl> - function __construct ( private $ v ) { } <nl> - function __destruct ( ) { <nl> - / / tripling the number of things in a Vector should cause it to realloc <nl> - $ c = $ this - > v - > count ( ) * 2 ; <nl> - for ( $ i = 0 ; $ i < $ c ; $ i + + ) { $ this - > v [ ] = ' lol ' ; } <nl> - } <nl> - } <nl> - <nl> - class D { <nl> - function __construct ( private $ v ) { } <nl> - function __destruct ( ) { <nl> - / / clearing should replace the underlying ArrayData with an empty one <nl> - $ this - > v - > clear ( ) ; <nl> - } <nl> - } <nl> - <nl> - function test ( ) { <nl> - $ v = Vector { 1 , 2 } ; <nl> - $ v [ ] = new C ( $ v ) ; <nl> - $ v [ ] = 3 ; <nl> - $ v - > splice ( 2 ) ; <nl> - var_dump ( $ v ) ; <nl> - <nl> - $ v = Vector { 1 , 2 } ; <nl> - $ v [ ] = new D ( $ v ) ; <nl> - $ v [ ] = 3 ; <nl> - $ v - > splice ( 2 ) ; <nl> - var_dump ( $ v ) ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_vector_splice_destructors ( ) { <nl> - test ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index e3909680da2 . . 00000000000 <nl> mmm a / hphp / test / slow / collection_classes / vector_splice_destructors . php . expect <nl> ppp / dev / null <nl> <nl> - object ( HH \ Vector ) # 1 ( 6 ) { <nl> - [ 0 ] = > <nl> - int ( 1 ) <nl> - [ 1 ] = > <nl> - int ( 2 ) <nl> - [ 2 ] = > <nl> - string ( 3 ) " lol " <nl> - [ 3 ] = > <nl> - string ( 3 ) " lol " <nl> - [ 4 ] = > <nl> - string ( 3 ) " lol " <nl> - [ 5 ] = > <nl> - string ( 3 ) " lol " <nl> - } <nl> - object ( HH \ Vector ) # 2 ( 0 ) { <nl> - } <nl> mmm a / hphp / test / slow / compilation / generic - decref . php <nl> ppp b / hphp / test / slow / compilation / generic - decref . php <nl> <nl> < ? php <nl> <nl> class X { <nl> - function __destruct ( ) { echo " dead \ n " ; } <nl> } <nl> function thing ( ) { <nl> static $ s = 0 ; <nl> function test ( ) { <nl> <nl> < < __EntryPoint > > <nl> function main_generic_decref ( ) { <nl> - ; <nl> - <nl> - for ( $ i = 0 ; $ i < 101 ; $ i + + ) { <nl> - test ( ) ; <nl> - } <nl> + for ( $ i = 0 ; $ i < 101 ; $ i + + ) { <nl> + test ( ) ; <nl> + } <nl> + var_dump ( hh \ objprof_get_data ( ) ) ; <nl> } <nl> mmm a / hphp / test / slow / compilation / generic - decref . php . expect <nl> ppp b / hphp / test / slow / compilation / generic - decref . php . expect <nl> <nl> - dead <nl> - dead <nl> \ No newline at end of file <nl> + array ( 0 ) { <nl> + } <nl> mmm a / hphp / test / slow / concat / concat_dtor . php <nl> ppp b / hphp / test / slow / concat / concat_dtor . php <nl> function foo ( $ x , $ y ) { <nl> class dtor { <nl> private $ i ; <nl> function __construct ( $ i ) { $ this - > i = $ i ; } <nl> - function __destruct ( ) { echo " dtor : $ this - > i \ n " ; } <nl> function __toString ( ) { echo " toString : $ this - > i \ n " ; return " a " ; } <nl> } <nl> <nl> function go ( ) { <nl> <nl> < < __EntryPoint > > <nl> function main_concat_dtor ( ) { <nl> - go ( ) ; <nl> + go ( ) ; <nl> + var_dump ( hh \ objprof_get_data ( ) ) ; <nl> } <nl> mmm a / hphp / test / slow / concat / concat_dtor . php . expect <nl> ppp b / hphp / test / slow / concat / concat_dtor . php . expect <nl> <nl> toString : 1 <nl> toString : 2 <nl> - dtor : 2 <nl> - dtor : 1 <nl> toString : 3 <nl> toString : 4 <nl> - dtor : 4 <nl> - dtor : 3 <nl> toString : 5 <nl> toString : 6 <nl> - dtor : 6 <nl> - dtor : 5 <nl> toString : 7 <nl> toString : 8 <nl> - dtor : 8 <nl> - dtor : 7 <nl> \ No newline at end of file <nl> + array ( 0 ) { <nl> + } <nl> deleted file mode 100644 <nl> index acf590d4cf1 . . 00000000000 <nl> mmm a / hphp / test / slow / concat / concat_loc . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - function go ( $ wakkawakka ) { <nl> - $ wakkawakka . = new dtor ( 2 ) ; <nl> - mt_rand ( ) ; <nl> - echo $ wakkawakka ; <nl> - } <nl> - <nl> - class dtor { <nl> - private $ i ; <nl> - function __construct ( $ i ) { $ this - > i = $ i ; } <nl> - function __destruct ( ) { <nl> - var_dump ( debug_backtrace ( ) [ 1 ] [ ' args ' ] ) ; <nl> - echo " dtor : $ this - > i \ n " ; <nl> - } <nl> - function __toString ( ) { echo " toString : $ this - > i \ n " ; return " a " ; } <nl> - } <nl> - <nl> - function x ( ) { <nl> - $ z = " asd " . ( new dtor ( 0 ) ) ; <nl> - go ( $ z ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_concat_loc ( ) { <nl> - x ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index b1701a08cc7 . . 00000000000 <nl> mmm a / hphp / test / slow / concat / concat_loc . php . expect <nl> ppp / dev / null <nl> <nl> - toString : 0 <nl> - array ( 0 ) { <nl> - } <nl> - dtor : 0 <nl> - toString : 2 <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - string ( 5 ) " asdaa " <nl> - } <nl> - dtor : 2 <nl> - asdaa <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 609a62e1a7b . . 00000000000 <nl> mmm a / hphp / test / slow / concat / concat_loc . php . opts <nl> ppp / dev / null <nl> <nl> - - vEval . EnableArgsInBacktraces = 1 - vEval . HHIRPartialInlineFrameOpts = 0 <nl> - <nl> mmm a / hphp / test / slow / constructor_destructor / 1568 . php <nl> ppp b / hphp / test / slow / constructor_destructor / 1568 . php <nl> class parent_c { <nl> public function __construct ( ) { <nl> echo " parent__construct " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " parent__destruct " ; <nl> - } <nl> } <nl> class child_c extends parent_c { <nl> public function __construct ( ) { <nl> echo " child__construct " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " child__destruct " ; <nl> - } <nl> } <nl> <nl> < < __EntryPoint > > <nl> mmm a / hphp / test / slow / constructor_destructor / 1568 . php . expect <nl> ppp b / hphp / test / slow / constructor_destructor / 1568 . php . expect <nl> @ @ - 1 + 1 @ @ <nl> - child__constructchild__destruct <nl> \ No newline at end of file <nl> + child__construct <nl> mmm a / hphp / test / slow / constructor_destructor / 1569 . php <nl> ppp b / hphp / test / slow / constructor_destructor / 1569 . php <nl> class parent_c { <nl> public function __construct ( ) { <nl> echo " parent__construct " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " parent__destruct " ; <nl> - } <nl> } <nl> class child_c extends parent_c { <nl> public function __construct ( ) { <nl> echo " child__construct " ; <nl> parent : : __construct ( ) ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " child__destruct " ; <nl> - parent : : __destruct ( ) ; <nl> - } <nl> } <nl> <nl> < < __EntryPoint > > <nl> mmm a / hphp / test / slow / constructor_destructor / 1569 . php . expect <nl> ppp b / hphp / test / slow / constructor_destructor / 1569 . php . expect <nl> @ @ - 1 + 1 @ @ <nl> - child__constructparent__constructchild__destructparent__destruct <nl> \ No newline at end of file <nl> + child__constructparent__construct <nl> mmm a / hphp / test / slow / constructor_destructor / 1570 . php <nl> ppp b / hphp / test / slow / constructor_destructor / 1570 . php <nl> function __construct ( ) { <nl> } <nl> } <nl> class D1 { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> } <nl> class D2 extends C1 { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> } <nl> class D3 extends D2 { <nl> } <nl> class D4 extends B1 { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> } <nl> class D5 extends D4 { <nl> } <nl> mmm a / hphp / test / slow / constructor_destructor / 1570 . php . expectf <nl> ppp b / hphp / test / slow / constructor_destructor / 1570 . php . expectf <nl> <nl> - string ( 14 ) " D1 : : __destruct " <nl> string ( 6 ) " caught " <nl> string ( 6 ) " caught " <nl> string ( 6 ) " caught " <nl> - string ( 14 ) " D1 : : __destruct " <nl> string ( 6 ) " caught " <nl> string ( 6 ) " caught " <nl> string ( 6 ) " caught " <nl> - string ( 14 ) " D1 : : __destruct " <nl> - string ( 14 ) " D2 : : __destruct " <nl> - string ( 14 ) " D2 : : __destruct " <nl> - string ( 14 ) " D4 : : __destruct " <nl> <nl> - Warning : __construct ( ) expects exactly 1 parameter , 0 given in % s / test / slow / constructor_destructor / 1570 . php on line 29 <nl> + Warning : __construct ( ) expects exactly 1 parameter , 0 given in % s / test / slow / constructor_destructor / 1570 . php on line 20 <nl> <nl> - Notice : Undefined variable : a in % s / test / slow / constructor_destructor / 1570 . php on line 29 <nl> - string ( 14 ) " D4 : : __destruct " <nl> - string ( 14 ) " D1 : : __destruct " <nl> - string ( 14 ) " D1 : : __destruct " <nl> - string ( 14 ) " D2 : : __destruct " <nl> - string ( 14 ) " D2 : : __destruct " <nl> - string ( 14 ) " D4 : : __destruct " <nl> + Notice : Undefined variable : a in % s / test / slow / constructor_destructor / 1570 . php on line 20 <nl> <nl> - Warning : __construct ( ) expects exactly 1 parameter , 0 given in % s / test / slow / constructor_destructor / 1570 . php on line 29 <nl> + Warning : __construct ( ) expects exactly 1 parameter , 0 given in % s / test / slow / constructor_destructor / 1570 . php on line 20 <nl> <nl> - Notice : Undefined variable : a in % s / test / slow / constructor_destructor / 1570 . php on line 29 <nl> - string ( 14 ) " D4 : : __destruct " <nl> - string ( 14 ) " D1 : : __destruct " <nl> + Notice : Undefined variable : a in % s / test / slow / constructor_destructor / 1570 . php on line 20 <nl> deleted file mode 100644 <nl> index 30640a52fa6 . . 00000000000 <nl> mmm a / hphp / test / slow / debug_backtrace / metadata_decref_on_return . php <nl> ppp / dev / null <nl> <nl> - < ? php / * destructor * / <nl> - <nl> - class Foo { <nl> - public function __construct ( private $ options ) { <nl> - var_dump ( debug_backtrace ( $ this - > options ) ) ; <nl> - } <nl> - <nl> - public function __destruct ( ) { <nl> - var_dump ( debug_backtrace ( $ this - > options ) ) ; <nl> - } <nl> - } <nl> - <nl> - function bar ( $ options ) { <nl> - var_dump ( debug_backtrace ( $ options ) ) ; <nl> - } <nl> - <nl> - function foo ( $ options ) { <nl> - HH \ set_frame_metadata ( new Foo ( $ options ) ) ; <nl> - bar ( $ options ) ; <nl> - } <nl> - <nl> - foo ( 0 ) ; <nl> - foo ( DEBUG_BACKTRACE_PROVIDE_METADATA ) ; <nl> deleted file mode 100644 <nl> index fbcf6902448 . . 00000000000 <nl> mmm a / hphp / test / slow / debug_backtrace / metadata_decref_on_return . php . expectf <nl> ppp / dev / null <nl> <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - array ( 6 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 18 ) <nl> - [ " function " ] = > <nl> - string ( 11 ) " __construct " <nl> - [ " class " ] = > <nl> - string ( 3 ) " Foo " <nl> - [ " type " ] = > <nl> - string ( 2 ) " - > " <nl> - [ " args " ] = > <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - int ( 0 ) <nl> - } <nl> - } <nl> - [ 1 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 22 ) <nl> - [ " function " ] = > <nl> - string ( 3 ) " foo " <nl> - [ " args " ] = > <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - int ( 0 ) <nl> - } <nl> - } <nl> - } <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 19 ) <nl> - [ " function " ] = > <nl> - string ( 3 ) " bar " <nl> - [ " args " ] = > <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - int ( 0 ) <nl> - } <nl> - } <nl> - [ 1 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 22 ) <nl> - [ " function " ] = > <nl> - string ( 3 ) " foo " <nl> - [ " args " ] = > <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - int ( 0 ) <nl> - } <nl> - } <nl> - } <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - array ( 6 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 20 ) <nl> - [ " function " ] = > <nl> - string ( 10 ) " __destruct " <nl> - [ " class " ] = > <nl> - string ( 3 ) " Foo " <nl> - [ " type " ] = > <nl> - string ( 2 ) " - > " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - [ 1 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 22 ) <nl> - [ " function " ] = > <nl> - string ( 3 ) " foo " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - array ( 6 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 18 ) <nl> - [ " function " ] = > <nl> - string ( 11 ) " __construct " <nl> - [ " class " ] = > <nl> - string ( 3 ) " Foo " <nl> - [ " type " ] = > <nl> - string ( 2 ) " - > " <nl> - [ " args " ] = > <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - int ( 65536 ) <nl> - } <nl> - } <nl> - [ 1 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 23 ) <nl> - [ " function " ] = > <nl> - string ( 3 ) " foo " <nl> - [ " args " ] = > <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - int ( 65536 ) <nl> - } <nl> - } <nl> - } <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 19 ) <nl> - [ " function " ] = > <nl> - string ( 3 ) " bar " <nl> - [ " args " ] = > <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - int ( 65536 ) <nl> - } <nl> - } <nl> - [ 1 ] = > <nl> - array ( 5 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 23 ) <nl> - [ " function " ] = > <nl> - string ( 3 ) " foo " <nl> - [ " args " ] = > <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - int ( 65536 ) <nl> - } <nl> - [ " metadata " ] = > <nl> - object ( Foo ) # 1 ( 1 ) { <nl> - [ " options " : " Foo " : private ] = > <nl> - int ( 65536 ) <nl> - } <nl> - } <nl> - } <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - array ( 6 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 20 ) <nl> - [ " function " ] = > <nl> - string ( 10 ) " __destruct " <nl> - [ " class " ] = > <nl> - string ( 3 ) " Foo " <nl> - [ " type " ] = > <nl> - string ( 2 ) " - > " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - [ 1 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 23 ) <nl> - [ " function " ] = > <nl> - string ( 3 ) " foo " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> mmm a / hphp / test / slow / dict / convert - dtor . php <nl> ppp b / hphp / test / slow / dict / convert - dtor . php <nl> class Dtor { <nl> function __construct ( $ id ) { <nl> $ this - > id = $ id ; <nl> } <nl> - function __destruct ( ) { <nl> - echo " Dtor : : __destruct ( " . $ this - > id . " ) \ n " ; <nl> - } <nl> } <nl> <nl> function main ( ) { <nl> function main ( ) { <nl> <nl> < < __EntryPoint > > <nl> function main_convert_dtor ( ) { <nl> - main ( ) ; <nl> + main ( ) ; <nl> + var_dump ( hh \ objprof_get_data ( ) ) ; <nl> } <nl> mmm a / hphp / test / slow / dict / convert - dtor . php . expectf <nl> ppp b / hphp / test / slow / dict / convert - dtor . php . expectf <nl> dict ( 3 ) { <nl> int ( 3 ) <nl> } <nl> } <nl> - Dtor : : __destruct ( 1 ) <nl> - Dtor : : __destruct ( 2 ) <nl> - Dtor : : __destruct ( 3 ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> vec ( 3 ) { <nl> object ( Dtor ) # % d ( 1 ) { <nl> vec ( 3 ) { <nl> int ( 6 ) <nl> } <nl> } <nl> - Dtor : : __destruct ( 4 ) <nl> - Dtor : : __destruct ( 5 ) <nl> - Dtor : : __destruct ( 6 ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Dtor : : __destruct ( 7 ) <nl> - Dtor : : __destruct ( 8 ) <nl> - Dtor : : __destruct ( 9 ) <nl> Exception : " Invalid keyset key : expected a key of type int or string , Dtor given " <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> array ( 3 ) { <nl> array ( 3 ) { <nl> int ( 12 ) <nl> } <nl> } <nl> - Dtor : : __destruct ( 10 ) <nl> - Dtor : : __destruct ( 11 ) <nl> - Dtor : : __destruct ( 12 ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Dtor : : __destruct ( 13 ) <nl> - Dtor : : __destruct ( 14 ) <nl> - Dtor : : __destruct ( 15 ) <nl> bool ( true ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Dtor : : __destruct ( 16 ) <nl> - Dtor : : __destruct ( 17 ) <nl> - Dtor : : __destruct ( 18 ) <nl> int ( 1 ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Dtor : : __destruct ( 19 ) <nl> - Dtor : : __destruct ( 20 ) <nl> - Dtor : : __destruct ( 21 ) <nl> float ( 1 ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> Notice : Dict to string conversion in % s on line % d <nl> - Dtor : : __destruct ( 22 ) <nl> - Dtor : : __destruct ( 23 ) <nl> - Dtor : : __destruct ( 24 ) <nl> string ( 4 ) " Dict " <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> object ( stdClass ) # % d ( 3 ) { <nl> object ( stdClass ) # % d ( 3 ) { <nl> int ( 27 ) <nl> } <nl> } <nl> - Dtor : : __destruct ( 25 ) <nl> - Dtor : : __destruct ( 26 ) <nl> - Dtor : : __destruct ( 27 ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> object ( HH \ Vector ) # % d ( 3 ) { <nl> [ 0 ] = > <nl> object ( HH \ Vector ) # % d ( 3 ) { <nl> int ( 30 ) <nl> } <nl> } <nl> - Dtor : : __destruct ( 28 ) <nl> - Dtor : : __destruct ( 29 ) <nl> - Dtor : : __destruct ( 30 ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> object ( HH \ Map ) # % d ( 3 ) { <nl> [ 31 ] = > <nl> object ( HH \ Map ) # % d ( 3 ) { <nl> int ( 33 ) <nl> } <nl> } <nl> - Dtor : : __destruct ( 31 ) <nl> - Dtor : : __destruct ( 32 ) <nl> - Dtor : : __destruct ( 33 ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + array ( 0 ) { <nl> + } <nl> mmm a / hphp / test / slow / dict / from - obj - dtor . php <nl> ppp b / hphp / test / slow / dict / from - obj - dtor . php <nl> <nl> / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> <nl> class Cls implements Iterator { <nl> - public $ idx ; <nl> - function __construct ( $ idx ) { <nl> - $ this - > idx = $ idx ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo " Cls : : __destruct " . $ this - > idx . " \ n " ; <nl> - } <nl> - <nl> public function rewind ( ) { } <nl> public function current ( ) { } <nl> public function key ( ) { } <nl> function from_obj ( $ obj ) { <nl> function test ( ) { <nl> for ( $ i = 0 ; $ i < 10 ; $ i + + ) { <nl> echo " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv \ n " ; <nl> - from_obj ( new Cls ( $ i ) ) ; <nl> + from_obj ( new Cls ) ; <nl> + var_dump ( hh \ objprof_get_data ( ) ) ; <nl> echo " ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ \ n " ; <nl> } <nl> } <nl> function test ( ) { <nl> <nl> < < __EntryPoint > > <nl> function main_from_obj_dtor ( ) { <nl> - error_reporting ( E_ERROR ) ; <nl> - test ( ) ; <nl> + error_reporting ( E_ERROR ) ; <nl> + test ( ) ; <nl> } <nl> mmm a / hphp / test / slow / dict / from - obj - dtor . php . expect <nl> ppp b / hphp / test / slow / dict / from - obj - dtor . php . expect <nl> <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 0 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 1 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 2 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 3 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 4 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 5 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 6 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 7 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 8 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 9 <nl> - ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> \ No newline at end of file <nl> + array ( 0 ) { <nl> + } <nl> + ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> mmm a / hphp / test / slow / dv_array / ext_xenon / xenon_crash . php <nl> ppp b / hphp / test / slow / dv_array / ext_xenon / xenon_crash . php <nl> <nl> return array_map ( $ wh = = > \ HH \ Asio \ result ( $ wh ) , $ args ) ; <nl> } <nl> <nl> - class X { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> - } <nl> - <nl> class A { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> - <nl> async function gen1 ( $ a ) { <nl> await RescheduleWaitHandle : : create ( 0 , 0 ) ; / / simulate blocking I / O <nl> return $ a + 1 ; <nl> function __destruct ( ) { <nl> } <nl> <nl> async function genBar ( $ a ) { <nl> - $ x = new X ; <nl> await RescheduleWaitHandle : : create ( 0 , $ a ) ; / / simulate blocking I / O <nl> return $ a + 2 ; <nl> } <nl> mmm a / hphp / test / slow / dv_array / ext_xenon / xenon_crash . php . expect <nl> ppp b / hphp / test / slow / dv_array / ext_xenon / xenon_crash . php . expect <nl> @ @ - 1 , 6 + 1 @ @ <nl> - string ( 13 ) " X : : __destruct " <nl> - string ( 13 ) " A : : __destruct " <nl> - string ( 13 ) " X : : __destruct " <nl> - string ( 13 ) " A : : __destruct " <nl> - string ( 13 ) " A : : __destruct " <nl> int ( 91 ) <nl> mmm a / hphp / test / slow / dv_array_hack_arr / ext_xenon / xenon_crash . php <nl> ppp b / hphp / test / slow / dv_array_hack_arr / ext_xenon / xenon_crash . php <nl> <nl> return array_map ( $ wh = = > \ HH \ Asio \ result ( $ wh ) , $ args ) ; <nl> } <nl> <nl> - class X { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> - } <nl> - <nl> class A { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> - <nl> async function gen1 ( $ a ) { <nl> await RescheduleWaitHandle : : create ( 0 , 0 ) ; / / simulate blocking I / O <nl> return $ a + 1 ; <nl> function __destruct ( ) { <nl> } <nl> <nl> async function genBar ( $ a ) { <nl> - $ x = new X ; <nl> await RescheduleWaitHandle : : create ( 0 , $ a ) ; / / simulate blocking I / O <nl> return $ a + 2 ; <nl> } <nl> mmm a / hphp / test / slow / dv_array_hack_arr / ext_xenon / xenon_crash . php . expect <nl> ppp b / hphp / test / slow / dv_array_hack_arr / ext_xenon / xenon_crash . php . expect <nl> @ @ - 1 , 6 + 1 @ @ <nl> - string ( 13 ) " X : : __destruct " <nl> - string ( 13 ) " A : : __destruct " <nl> - string ( 13 ) " X : : __destruct " <nl> - string ( 13 ) " A : : __destruct " <nl> - string ( 13 ) " A : : __destruct " <nl> int ( 91 ) <nl> deleted file mode 100644 <nl> index 9868e7dc41c . . 00000000000 <nl> mmm a / hphp / test / slow / error_handler / 3329 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class A { <nl> - public function __destruct ( ) { <nl> - restore_error_handler ( ) ; <nl> - } <nl> - public function __construct ( ) { <nl> - set_error_handler ( array ( $ this , " callback " ) ) ; <nl> - } <nl> - public function callback ( $ errno , $ msg ) { <nl> - echo " my logger : " . $ msg . " \ n " ; <nl> - return true ; <nl> - } <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_3329 ( ) { <nl> - $ a = new A ; <nl> - trigger_error ( " blarg " ) ; <nl> - unset ( $ a ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 50b7e006775 . . 00000000000 <nl> mmm a / hphp / test / slow / error_handler / 3329 . php . expect <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - my logger : blarg <nl> deleted file mode 100644 <nl> index 7dccc24f405 . . 00000000000 <nl> mmm a / hphp / test / slow / error_handler / 3329 . php . ini <nl> ppp / dev / null <nl> <nl> - hhvm . enable_obj_destruct_call = 0 <nl> - hhvm . php7 . all = false <nl> deleted file mode 100644 <nl> index fdb35af5b7c . . 00000000000 <nl> mmm a / hphp / test / slow / error_handler / destructor_fatal . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - function foo ( ) { <nl> - for ( $ i = 0 ; $ i < 100 ; $ i + + ) { <nl> - echo " Count : $ i \ n " ; <nl> - } <nl> - } <nl> - <nl> - class X { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - sleep ( 2 ) ; <nl> - foo ( ) ; <nl> - } <nl> - } <nl> - <nl> - class Y { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> - } <nl> - <nl> - function test ( ) { <nl> - $ x = new X ; <nl> - $ y = new Y ; <nl> - set_time_limit ( 1 ) ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_destructor_fatal ( ) { <nl> - set_error_handler ( function ( ) { <nl> - var_dump ( ' Handler ' , func_get_args ( ) ) ; <nl> - } , - 1 ) ; <nl> - <nl> - test ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 7315332a3fd . . 00000000000 <nl> mmm a / hphp / test / slow / error_handler / destructor_fatal . php . expectf <nl> ppp / dev / null <nl> <nl> - string ( 13 ) " Y : : __destruct " <nl> - string ( 13 ) " X : : __destruct " <nl> - Destructor raised a fatal error : Maximum execution time of 1 seconds exceeded <nl> - <nl> - <nl> - Fatal error : Maximum execution time of 1 seconds exceeded in % s / test / slow / error_handler / destructor_fatal . php on line 27 <nl> \ No newline at end of file <nl> mmm a / hphp / test / slow / error_handler / on_return_event_hook . php <nl> ppp b / hphp / test / slow / error_handler / on_return_event_hook . php <nl> class MyClass { <nl> public function __construct ( ) { <nl> echo " constructing \ n " ; <nl> } <nl> - <nl> - public function __destruct ( ) { <nl> - echo " destructing \ n " ; <nl> - } <nl> } <nl> <nl> set_error_handler ( <nl> mmm a / hphp / test / slow / error_handler / on_return_event_hook . php . expectf <nl> ppp b / hphp / test / slow / error_handler / on_return_event_hook . php . expectf <nl> <nl> constructing <nl> - destructing <nl> string ( 4 ) " test " <nl> int ( 42 ) <nl> int ( 2 ) <nl> string ( 75 ) " [ asio ] Ignoring exception thrown by ResumableWaitHandle : : onSuccess callback " <nl> string ( % d ) " % son_return_event_hook . php " <nl> - int ( 34 ) <nl> + int ( 30 ) <nl> array ( 0 ) { <nl> } <nl> deleted file mode 100644 <nl> index ee4cf21c6e7 . . 00000000000 <nl> mmm a / hphp / test / slow / eval_order / 1521 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class X { <nl> - function __destruct ( ) { <nl> - var_dump ( ' done ' ) ; <nl> - } <nl> - } <nl> - function f ( ) { <nl> - $ x = new X ; <nl> - } <nl> - function g ( ) { <nl> - var_dump ( ' start ' ) ; <nl> - f ( ) ; <nl> - var_dump ( ' end ' ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_1521 ( ) { <nl> - g ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 381a2a66cb8 . . 00000000000 <nl> mmm a / hphp / test / slow / eval_order / 1521 . php . expect <nl> ppp / dev / null <nl> <nl> - string ( 5 ) " start " <nl> - string ( 4 ) " done " <nl> - string ( 3 ) " end " <nl> deleted file mode 100644 <nl> index dfaa11130e3 . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / 58 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class a extends Exception { <nl> - function __destruct ( ) { <nl> - var_dump ( ' __destruct ' ) ; <nl> - } <nl> - } <nl> - function foo ( ) { <nl> - $ ex = null ; <nl> - try { <nl> - throw new A ; <nl> - } <nl> - catch ( Exception $ ex ) { <nl> - var_dump ( 1 ) ; <nl> - } <nl> - var_dump ( 2 ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_58 ( ) { <nl> - ; <nl> - foo ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index b8b74b96bf1 . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / 58 . php . expect <nl> ppp / dev / null <nl> <nl> - int ( 1 ) <nl> - int ( 2 ) <nl> - string ( 10 ) " __destruct " <nl> mmm a / hphp / test / slow / exceptions / chain - fault . php <nl> ppp b / hphp / test / slow / exceptions / chain - fault . php <nl> function __construct ( $ msg ) { <nl> echo " Constructing \ n " ; <nl> } <nl> <nl> - function __destruct ( ) { <nl> - echo " Destructing \ n " ; <nl> - } <nl> } <nl> <nl> function thrower ( ) { <nl> mmm a / hphp / test / slow / exceptions / chain - fault . php . expectf <nl> ppp b / hphp / test / slow / exceptions / chain - fault . php . expectf <nl> object ( Exception ) # 2 ( 8 ) { <nl> [ " file " : protected ] = > <nl> string ( % d ) " % s / test / slow / exceptions / chain - fault . php " <nl> [ " line " : protected ] = > <nl> - int ( 18 ) <nl> + int ( 15 ) <nl> [ " trace " : " Exception " : private ] = > <nl> array ( 2 ) { <nl> [ 0 ] = > <nl> object ( Exception ) # 2 ( 8 ) { <nl> [ " file " ] = > <nl> string ( % d ) " % s / test / slow / exceptions / chain - fault . php " <nl> [ " line " ] = > <nl> - int ( 25 ) <nl> + int ( 22 ) <nl> [ " function " ] = > <nl> string ( 7 ) " thrower " <nl> [ " args " ] = > <nl> object ( Exception ) # 2 ( 8 ) { <nl> [ " file " ] = > <nl> string ( % d ) " % s / test / slow / exceptions / chain - fault . php " <nl> [ " line " ] = > <nl> - int ( 34 ) <nl> + int ( 31 ) <nl> [ " function " ] = > <nl> string ( 4 ) " main " <nl> [ " args " ] = > <nl> object ( Exception ) # 2 ( 8 ) { <nl> [ " file " : protected ] = > <nl> string ( % d ) " % s / test / slow / exceptions / chain - fault . php " <nl> [ " line " : protected ] = > <nl> - int ( 16 ) <nl> + int ( 13 ) <nl> [ " trace " : " Exception " : private ] = > <nl> array ( 2 ) { <nl> [ 0 ] = > <nl> object ( Exception ) # 2 ( 8 ) { <nl> [ " file " ] = > <nl> string ( % d ) " % s / test / slow / exceptions / chain - fault . php " <nl> [ " line " ] = > <nl> - int ( 25 ) <nl> + int ( 22 ) <nl> [ " function " ] = > <nl> string ( 7 ) " thrower " <nl> [ " args " ] = > <nl> object ( Exception ) # 2 ( 8 ) { <nl> [ " file " ] = > <nl> string ( % d ) " % s / test / slow / exceptions / chain - fault . php " <nl> [ " line " ] = > <nl> - int ( 34 ) <nl> + int ( 31 ) <nl> [ " function " ] = > <nl> string ( 4 ) " main " <nl> [ " args " ] = > <nl> object ( Exception ) # 2 ( 8 ) { <nl> [ " userMetadata " : protected ] = > <nl> NULL <nl> } <nl> - Destructing <nl> Leaving main <nl> deleted file mode 100644 <nl> index 14b41db86a3 . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / chain - vs - destructor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class X { <nl> - function __destruct ( ) { <nl> - global $ complexException , $ previous ; <nl> - var_dump ( __METHOD__ ) ; <nl> - $ previous = $ complexException - > getPrevious ( ) ; <nl> - } <nl> - } <nl> - <nl> - function createExceptionWithNontrivialPreviousDestructor ( ) { <nl> - global $ complexException ; <nl> - $ complexException = new Exception ( " complex " ) ; <nl> - $ reflectionProp = ( new ReflectionClass ( ' Exception ' ) ) - > getProperty ( ' previous ' ) ; <nl> - $ reflectionProp - > setAccessible ( true ) ; <nl> - $ reflectionProp - > setValue ( $ complexException , array ( new X ( ) ) ) ; <nl> - return $ complexException ; <nl> - } <nl> - <nl> - try { <nl> - try { <nl> - throw new Exception ( " simple " ) ; <nl> - } finally { <nl> - throw createExceptionWithNontrivialPreviousDestructor ( ) ; <nl> - } <nl> - } catch ( Exception $ e ) { <nl> - var_dump ( $ e - > getMessage ( ) ) ; <nl> - } <nl> - var_dump ( $ previous ) ; <nl> deleted file mode 100644 <nl> index b8aa2541d72 . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / chain - vs - destructor . php . expectf <nl> ppp / dev / null <nl> <nl> - string ( 13 ) " X : : __destruct " <nl> - string ( 7 ) " complex " <nl> - object ( Exception ) # 1 ( 8 ) { <nl> - [ " message " : protected ] = > <nl> - string ( 6 ) " simple " <nl> - [ " string " : " Exception " : private ] = > <nl> - string ( 0 ) " " <nl> - [ " code " : protected ] = > <nl> - int ( 0 ) <nl> - [ " file " : protected ] = > <nl> - string ( % d ) " % s / chain - vs - destructor . php " <nl> - [ " line " : protected ] = > <nl> - int ( % d ) <nl> - [ " trace " : " Exception " : private ] = > <nl> - array ( 0 ) { <nl> - } <nl> - [ " previous " : " Exception " : private ] = > <nl> - NULL <nl> - [ " userMetadata " : protected ] = > <nl> - NULL <nl> - } <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / cuf_throw . php <nl> ppp b / hphp / test / slow / exceptions / cuf_throw . php <nl> <nl> < ? php <nl> <nl> class X { <nl> - function __destruct ( ) { <nl> - echo __METHOD__ , " \ n " ; <nl> - } <nl> } <nl> <nl> function test ( $ x ) { <nl> mmm a / hphp / test / slow / exceptions / cuf_throw . php . expect <nl> ppp b / hphp / test / slow / exceptions / cuf_throw . php . expect <nl> <nl> Exception <nl> - X : : __destruct <nl> - Done <nl> \ No newline at end of file <nl> + Done <nl> deleted file mode 100644 <nl> index f0c847e6ea6 . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / dtor_track_errors_crash . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - ini_set ( ' track_errors ' , 1 ) ; <nl> - <nl> - class Foo { <nl> - public function __destruct ( ) { <nl> - throw new Exception ( " FOO " ) ; <nl> - } <nl> - } <nl> - <nl> - $ f = new Foo ( ) ; <nl> deleted file mode 100644 <nl> index 04854a04ef6 . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / dtor_track_errors_crash . php . expectf <nl> ppp / dev / null <nl> <nl> - % SDestructor threw an object exception : exception ' Exception ' with message ' FOO ' % S <nl> - % S <nl> - % S <nl> - % S <nl> deleted file mode 100644 <nl> index 3ea2aca6cb1 . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / extra_args . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - <nl> - class bt { <nl> - function __destruct ( ) { <nl> - global $ bt ; <nl> - $ bt = debug_backtrace ( ) ; <nl> - var_dump ( $ bt ) ; <nl> - } <nl> - } <nl> - <nl> - function foo ( ) { <nl> - if ( isset ( $ GLOBALS [ ' notset ' ] ) ) { <nl> - var_dump ( func_get_args ( ) ) ; <nl> - } <nl> - $ x = new bt ; <nl> - throw new Exception ; <nl> - } <nl> - <nl> - function main ( ) { <nl> - try { <nl> - foo ( new bt ) ; <nl> - } catch ( Exception $ ex ) { <nl> - global $ bt ; <nl> - var_dump ( $ bt ) ; <nl> - } <nl> - } <nl> - <nl> - main ( ) ; <nl> deleted file mode 100644 <nl> index b20017db4b7 . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / extra_args . php . expectf <nl> ppp / dev / null <nl> <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - array ( 7 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 17 ) <nl> - [ " function " ] = > <nl> - string ( 10 ) " __destruct " <nl> - [ " class " ] = > <nl> - string ( 2 ) " bt " <nl> - [ " object " ] = > <nl> - object ( bt ) # 2 ( 0 ) { <nl> - } <nl> - [ " type " ] = > <nl> - string ( 2 ) " - > " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - [ 1 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 22 ) <nl> - [ " function " ] = > <nl> - string ( 3 ) " foo " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - [ 2 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 29 ) <nl> - [ " function " ] = > <nl> - string ( 4 ) " main " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - array ( 7 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 17 ) <nl> - [ " function " ] = > <nl> - string ( 10 ) " __destruct " <nl> - [ " class " ] = > <nl> - string ( 2 ) " bt " <nl> - [ " object " ] = > <nl> - object ( bt ) # 2 ( 0 ) { <nl> - } <nl> - [ " type " ] = > <nl> - string ( 2 ) " - > " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - [ 1 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 22 ) <nl> - [ " function " ] = > <nl> - string ( 3 ) " foo " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - [ 2 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 29 ) <nl> - [ " function " ] = > <nl> - string ( 4 ) " main " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - array ( 7 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 27 ) <nl> - [ " function " ] = > <nl> - string ( 10 ) " __destruct " <nl> - [ " class " ] = > <nl> - string ( 2 ) " bt " <nl> - [ " object " ] = > <nl> - object ( bt ) # 1 ( 0 ) { <nl> - } <nl> - [ " type " ] = > <nl> - string ( 2 ) " - > " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - [ 1 ] = > <nl> - array ( 4 ) { <nl> - [ " file " ] = > <nl> - string ( % d ) " % s " <nl> - [ " line " ] = > <nl> - int ( 29 ) <nl> - [ " function " ] = > <nl> - string ( 4 ) " main " <nl> - [ " args " ] = > <nl> - array ( 0 ) { <nl> - } <nl> - } <nl> - } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 2cc79f9a2cb . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / retc . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Obj { <nl> - public function __destruct ( ) { <nl> - / / Raise a fatal . <nl> - class Obj { <nl> - } <nl> - } <nl> - } <nl> - <nl> - function foo ( ) { <nl> - $ y = new Obj ; <nl> - $ x = new Obj ; <nl> - $ y = new Obj ; <nl> - <nl> - / / Currently our behavior during return when a local dtor throws a <nl> - / / fatal is to swallow it , then keep rethrowing it from the enter <nl> - / / hook for each destructor . Then we return as normal ( and this <nl> - / / test is trying to make sure nothing chokes due to the destroyed <nl> - / / locals ) , then further out the next enter hook will throw the <nl> - / / fatal . <nl> - } <nl> - / / enter hook throws the fatal <nl> - <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_retc ( ) { <nl> - try { <nl> - foo ( ) ; <nl> - } <nl> - catch ( Exception $ x ) { <nl> - echo " notreached \ n " ; <nl> - } <nl> - foo ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 1b31141679c . . 00000000000 <nl> mmm a / hphp / test / slow / exceptions / retc . php . expectf <nl> ppp / dev / null <nl> <nl> - <nl> - Warning : Destructor raised a fatal error : Class already declared : Obj <nl> - in % s / test / slow / exceptions / retc . php on line 14 <nl> - <nl> - Warning : Destructor raised a fatal error : Class already declared : Obj <nl> - in % s / test / slow / exceptions / retc . php on line 22 <nl> - <nl> - Warning : Destructor raised a fatal error : Class already declared : Obj <nl> - in % s / test / slow / exceptions / retc . php on line 22 <nl> - <nl> - Fatal error : Class already declared : Obj in % s / test / slow / exceptions / retc . php on line 6 <nl> mmm a / hphp / test / slow / exceptions / unwind_gen_array_waithandle . php <nl> ppp b / hphp / test / slow / exceptions / unwind_gen_array_waithandle . php <nl> function __construct ( $ msg ) { <nl> self : : $ e = $ this ; <nl> } <nl> } <nl> - function __destruct ( ) { var_dump ( __METHOD__ ) ; } <nl> <nl> function rethrow ( ) { <nl> $ e = self : : $ e ; <nl> mmm a / hphp / test / slow / exceptions / unwind_gen_array_waithandle . php . expect <nl> ppp b / hphp / test / slow / exceptions / unwind_gen_array_waithandle . php . expect <nl> @ @ - 1 , 3 + 1 @ @ <nl> - string ( 14 ) " E1 : : __destruct " <nl> string ( 4 ) " Boom " <nl> - string ( 14 ) " E1 : : __destruct " <nl> mmm a / hphp / test / slow / ext_function / register_shutdown_function . php <nl> ppp b / hphp / test / slow / ext_function / register_shutdown_function . php <nl> function baz ( ) { <nl> register_shutdown_function ( ' onShutdown2 ' ) ; <nl> echo " in Fooz : : baz \ n " ; <nl> } <nl> - function __destruct ( ) { echo " in Fooz : : __destruct ( ) \ n " ; } <nl> } <nl> <nl> function onShutdownRegisterShutdown_foo ( ) { echo " in foo \ n " ; } <nl> mmm a / hphp / test / slow / ext_function / register_shutdown_function . php . expect <nl> ppp b / hphp / test / slow / ext_function / register_shutdown_function . php . expect <nl> in foo <nl> in register <nl> in Fooz : : baz <nl> in shutdown 2 <nl> - in Fooz : : __destruct ( ) <nl> mmm a / hphp / test / slow / ext_session / session_unset . php <nl> ppp b / hphp / test / slow / ext_session / session_unset . php <nl> <nl> < ? php <nl> <nl> - class dtor { public function __destruct ( ) { echo " heyo \ n " ; } } <nl> + class dtor { } <nl> <nl> < < __EntryPoint > > <nl> function main_session_unset ( ) { <nl> mmm a / hphp / test / slow / ext_session / session_unset . php . expectf <nl> ppp b / hphp / test / slow / ext_session / session_unset . php . expectf <nl> <nl> heh <nl> - heyo <nl> after unset <nl> <nl> Notice : Undefined index : asdasd in % s / test / slow / ext_session / session_unset . php on line 12 <nl> deleted file mode 100644 <nl> index 0e3eee74a72 . . 00000000000 <nl> mmm a / hphp / test / slow / ext_weakref / weakref_destroy_in_dtor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - / / Source php weakref extension <nl> - class A { <nl> - private $ wr = null ; <nl> - public function __construct ( ) { <nl> - $ this - > wr = new WeakRef ( $ this ) ; <nl> - } <nl> - public function __destruct ( ) { <nl> - unset ( $ this - > wr ) ; <nl> - } <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_weakref_destroy_in_dtor ( ) { <nl> - $ a = new A ; <nl> - unset ( $ a ) ; <nl> - echo " Done \ n " ; <nl> - } <nl> deleted file mode 100644 <nl> index a965a70ed4e . . 00000000000 <nl> mmm a / hphp / test / slow / ext_weakref / weakref_destroy_in_dtor . php . expect <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - Done <nl> mmm a / hphp / test / slow / ext_weakref / weakref_to_builtin_classes . php <nl> ppp b / hphp / test / slow / ext_weakref / weakref_to_builtin_classes . php <nl> function test ( $ what ) { <nl> $ foo = $ producer ( ) ; <nl> $ w = new WeakRef ( $ foo ) ; <nl> var_dump ( $ w - > valid ( ) ) ; <nl> + __hhvm_intrinsics \ launder_value ( $ foo ) ; <nl> unset ( $ foo ) ; <nl> var_dump ( $ w - > valid ( ) ) ; <nl> } <nl> deleted file mode 100644 <nl> index 3820a50f0d7 . . 00000000000 <nl> mmm a / hphp / test / slow / hni / builtin_call_dtor_order . php <nl> ppp / dev / null <nl> <nl> - < ? hh / / decl <nl> - <nl> - class dtor { <nl> - public function __construct ( private int $ i ) { } <nl> - public function __destruct ( ) { echo " dtor : $ this - > i \ n " ; } <nl> - } <nl> - <nl> - class invoker { <nl> - public function __invoke ( $ x ) { return 2 ; } <nl> - public function __destruct ( ) { echo " ~ invoker \ n " ; } <nl> - } <nl> - <nl> - function foo ( ) { <nl> - array_map ( new invoker , array ( new dtor ( 1 ) , new dtor ( 2 ) ) ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_builtin_call_dtor_order ( ) { <nl> - foo ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 34dab5a7aa8 . . 00000000000 <nl> mmm a / hphp / test / slow / hni / builtin_call_dtor_order . php . expect <nl> ppp / dev / null <nl> <nl> - dtor : 1 <nl> - dtor : 2 <nl> - ~ invoker <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index c79138b7fde . . 00000000000 <nl> mmm a / hphp / test / slow / hni / coerce_dtor_order . php <nl> ppp / dev / null <nl> <nl> - < ? hh / / decl <nl> - <nl> - class X { <nl> - public function __construct ( private int $ i ) { } <nl> - public function __destruct ( ) : void { echo " dtor : $ this - > i \ n " ; } <nl> - public function __toString ( ) : string { return " x " ; } <nl> - } <nl> - <nl> - function err ( ) : void { } <nl> - <nl> - function foo ( ) : void { <nl> - set_error_handler ( ' err ' ) ; <nl> - hash ( new X ( 1 ) , new X ( 2 ) ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_coerce_dtor_order ( ) { <nl> - foo ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 2c0a7d8679e . . 00000000000 <nl> mmm a / hphp / test / slow / hni / coerce_dtor_order . php . expect <nl> ppp / dev / null <nl> <nl> - dtor : 1 <nl> - dtor : 2 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 4f79f1c7db2 . . 00000000000 <nl> mmm a / hphp / test / slow / hni / coerce_dtor_order2 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class X { <nl> - private $ i ; <nl> - public function __construct ( $ i ) { $ this - > i = $ i ; } <nl> - public function __destruct ( ) { echo " dtor : $ this - > i \ n " ; } <nl> - } <nl> - <nl> - function err ( ) { } <nl> - <nl> - function foo ( ) { <nl> - set_error_handler ( ' err ' ) ; <nl> - hash ( new X ( 1 ) , new X ( 2 ) ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_coerce_dtor_order2 ( ) { <nl> - foo ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index b9fbe7671c2 . . 00000000000 <nl> mmm a / hphp / test / slow / hni / coerce_dtor_order2 . php . expect <nl> ppp / dev / null <nl> <nl> - dtor : 2 <nl> - dtor : 1 <nl> deleted file mode 100644 <nl> index 655e34f761e . . 00000000000 <nl> mmm a / hphp / test / slow / hni / exception_dtor_order . php <nl> ppp / dev / null <nl> <nl> - < ? hh / / decl <nl> - <nl> - class dtor { <nl> - public function __construct ( private int $ i ) { } <nl> - public function __destruct ( ) { echo " dtor : $ this - > i \ n " ; } <nl> - } <nl> - <nl> - class invoker { <nl> - public function __invoke ( $ x ) { throw new exception ; } <nl> - public function __destruct ( ) { echo " ~ invoker \ n " ; } <nl> - } <nl> - <nl> - function foo ( ) { <nl> - try { <nl> - array_map ( new invoker , array ( new dtor ( 1 ) , new dtor ( 2 ) ) ) ; <nl> - } catch ( exception $ x ) { <nl> - echo " ok \ n " ; <nl> - } <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_exception_dtor_order ( ) { <nl> - foo ( ) ; <nl> - echo " done \ n " ; <nl> - } <nl> deleted file mode 100644 <nl> index c57062b027d . . 00000000000 <nl> mmm a / hphp / test / slow / hni / exception_dtor_order . php . expect <nl> ppp / dev / null <nl> <nl> - ok <nl> - ~ invoker <nl> - dtor : 1 <nl> - dtor : 2 <nl> - done <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 9b0e2081e4d . . 00000000000 <nl> mmm a / hphp / test / slow / hni / exception_dtor_order2 . php <nl> ppp / dev / null <nl> <nl> - < ? hh / / decl <nl> - <nl> - function err ( ) { throw new Exception ; } <nl> - <nl> - class dtor { <nl> - public function __construct ( private int $ i ) { } <nl> - public function __destruct ( ) { echo " dtor : $ this - > i \ n " ; } <nl> - } <nl> - <nl> - function foo ( ) { <nl> - try { <nl> - hash ( new dtor ( 1 ) , new dtor ( 2 ) ) ; <nl> - } catch ( exception $ x ) { <nl> - echo " ok \ n " ; <nl> - } <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_exception_dtor_order2 ( ) { <nl> - set_error_handler ( ' err ' ) ; <nl> - foo ( ) ; <nl> - echo " done \ n " ; <nl> - } <nl> deleted file mode 100644 <nl> index 92ac4ed493e . . 00000000000 <nl> mmm a / hphp / test / slow / hni / exception_dtor_order2 . php . expect <nl> ppp / dev / null <nl> <nl> - dtor : 2 <nl> - dtor : 1 <nl> - ok <nl> - done <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index a5a6d49beb8 . . 00000000000 <nl> mmm a / hphp / test / slow / hni / exception_dtor_order2 . php . opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vEval . EnableArgsInBacktraces = false <nl> mmm a / hphp / test / slow / ini / substitutions . php <nl> ppp b / hphp / test / slow / ini / substitutions . php <nl> function main_substitutions ( ) { <nl> var_dump ( ini_get ( " hhvm . server_variables " ) ) ; <nl> var_dump ( ini_get ( " hhvm . error_handling . notice_frequency " ) ) ; <nl> var_dump ( ini_get ( " hhvm . error_handling . warning_frequency " ) ) ; <nl> - var_dump ( ini_get ( " hhvm . enable_obj_destruct_call " ) ) ; <nl> var_dump ( ini_get ( " hhvm . enable_xhp " ) ) ; <nl> var_dump ( ini_Get ( " hhvm . jit_a_size " ) ) ; <nl> } <nl> mmm a / hphp / test / slow / ini / substitutions . php . expect <nl> ppp b / hphp / test / slow / ini / substitutions . php . expect <nl> array ( 4 ) { <nl> string ( 1 ) " 1 " <nl> string ( 1 ) " 1 " <nl> string ( 1 ) " 1 " <nl> - string ( 1 ) " 1 " <nl> string ( 8 ) " 15728640 " <nl> deleted file mode 100644 <nl> index b32150a69a6 . . 00000000000 <nl> mmm a / hphp / test / slow / inline - nested - vm - stack . php <nl> ppp / dev / null <nl> <nl> - < ? hh <nl> - <nl> - class Guard { <nl> - function __construct ( private string $ f ) { } <nl> - function __destruct ( ) { <nl> - $ trace = implode ( <nl> - ' , ' , <nl> - array_map ( $ x = = > $ x [ ' function ' ] . ' : ' . $ x [ ' line ' ] , debug_backtrace ( ) ) <nl> - ) ; <nl> - echo $ this - > f . " : $ trace \ n " ; <nl> - } <nl> - } <nl> - <nl> - < < __ALWAYS_INLINE > > <nl> - function red ( ) { <nl> - $ a = new Guard ( __FUNCTION__ ) ; <nl> - } <nl> - <nl> - < < __ALWAYS_INLINE > > <nl> - function green ( ) { <nl> - $ a = new Guard ( __FUNCTION__ ) ; <nl> - red ( ) ; <nl> - } <nl> - <nl> - < < __ALWAYS_INLINE > > <nl> - function blue ( ) { <nl> - $ a = new Guard ( __FUNCTION__ ) ; <nl> - green ( ) ; <nl> - } <nl> - <nl> - function main ( ) { <nl> - blue ( ) ; <nl> - } <nl> - <nl> - for ( $ i = 0 ; $ i < 10 ; $ i + + ) main ( ) ; <nl> deleted file mode 100644 <nl> index 62094236a28 . . 00000000000 <nl> mmm a / hphp / test / slow / inline - nested - vm - stack . php . expect <nl> ppp / dev / null <nl> <nl> - red : __destruct : 17 , red : 22 , green : 28 , blue : 32 , main : 35 <nl> - green : __destruct : 23 , green : 28 , blue : 32 , main : 35 <nl> - blue : __destruct : 29 , blue : 32 , main : 35 <nl> - red : __destruct : 17 , red : 22 , green : 28 , blue : 32 , main : 35 <nl> - green : __destruct : 23 , green : 28 , blue : 32 , main : 35 <nl> - blue : __destruct : 29 , blue : 32 , main : 35 <nl> - red : __destruct : 17 , red : 22 , green : 28 , blue : 32 , main : 35 <nl> - green : __destruct : 23 , green : 28 , blue : 32 , main : 35 <nl> - blue : __destruct : 29 , blue : 32 , main : 35 <nl> - red : __destruct : 17 , red : 22 , green : 28 , blue : 32 , main : 35 <nl> - green : __destruct : 23 , green : 28 , blue : 32 , main : 35 <nl> - blue : __destruct : 29 , blue : 32 , main : 35 <nl> - red : __destruct : 17 , red : 22 , green : 28 , blue : 32 , main : 35 <nl> - green : __destruct : 23 , green : 28 , blue : 32 , main : 35 <nl> - blue : __destruct : 29 , blue : 32 , main : 35 <nl> - red : __destruct : 17 , red : 22 , green : 28 , blue : 32 , main : 35 <nl> - green : __destruct : 23 , green : 28 , blue : 32 , main : 35 <nl> - blue : __destruct : 29 , blue : 32 , main : 35 <nl> - red : __destruct : 17 , red : 22 , green : 28 , blue : 32 , main : 35 <nl> - green : __destruct : 23 , green : 28 , blue : 32 , main : 35 <nl> - blue : __destruct : 29 , blue : 32 , main : 35 <nl> - red : __destruct : 17 , red : 22 , green : 28 , blue : 32 , main : 35 <nl> - green : __destruct : 23 , green : 28 , blue : 32 , main : 35 <nl> - blue : __destruct : 29 , blue : 32 , main : 35 <nl> - red : __destruct : 17 , red : 22 , green : 28 , blue : 32 , main : 35 <nl> - green : __destruct : 23 , green : 28 , blue : 32 , main : 35 <nl> - blue : __destruct : 29 , blue : 32 , main : 35 <nl> - red : __destruct : 17 , red : 22 , green : 28 , blue : 32 , main : 35 <nl> - green : __destruct : 23 , green : 28 , blue : 32 , main : 35 <nl> - blue : __destruct : 29 , blue : 32 , main : 35 <nl> deleted file mode 100644 <nl> index e7e9407a881 . . 00000000000 <nl> mmm a / hphp / test / slow / inline - trim - extra - args . php <nl> ppp / dev / null <nl> <nl> - < ? hh <nl> - <nl> - class Guard { <nl> - function __construct ( private string $ f ) { } <nl> - function __destruct ( ) { <nl> - $ trace = implode ( <nl> - ' , ' , <nl> - array_map ( $ x = = > $ x [ ' function ' ] . ' : ' . $ x [ ' line ' ] , debug_backtrace ( ) ) <nl> - ) ; <nl> - echo $ this - > f . " : $ trace \ n " ; <nl> - } <nl> - } <nl> - <nl> - < < __NEVER_INLINE > > <nl> - function extra ( ) { } <nl> - <nl> - < < __ALWAYS_INLINE > > <nl> - function red ( ) { <nl> - extra ( new Guard ( __FUNCTION__ ) ) ; <nl> - } <nl> - <nl> - < < __ALWAYS_INLINE > > <nl> - function green ( ) { <nl> - extra ( new Guard ( __FUNCTION__ ) ) ; <nl> - red ( ) ; <nl> - } <nl> - <nl> - < < __ALWAYS_INLINE > > <nl> - function blue ( ) { <nl> - extra ( new Guard ( __FUNCTION__ ) ) ; <nl> - green ( ) ; <nl> - } <nl> - <nl> - function main ( ) { <nl> - blue ( ) ; <nl> - } <nl> - <nl> - for ( $ i = 0 ; $ i < 10 ; $ i + + ) main ( ) ; <nl> deleted file mode 100644 <nl> index b5e1ca249c1 . . 00000000000 <nl> mmm a / hphp / test / slow / inline - trim - extra - args . php . expect <nl> ppp / dev / null <nl> <nl> - blue : __destruct : 15 , extra : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 15 , extra : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 15 , extra : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 15 , extra : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 15 , extra : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 15 , extra : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 15 , extra : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 15 , extra : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 15 , extra : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 15 , extra : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 15 , extra : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 15 , extra : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 15 , extra : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 15 , extra : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 15 , extra : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 15 , extra : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 15 , extra : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 15 , extra : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 15 , extra : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 15 , extra : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 15 , extra : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 15 , extra : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 15 , extra : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 15 , extra : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 15 , extra : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 15 , extra : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 15 , extra : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 15 , extra : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 15 , extra : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 15 , extra : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> deleted file mode 100644 <nl> index 6b7479b45cb . . 00000000000 <nl> mmm a / hphp / test / slow / inline - trim - extra - args . php . expect - repo <nl> ppp / dev / null <nl> <nl> - blue : __destruct : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> - blue : __destruct : 30 , blue : 35 , main : 38 <nl> - green : __destruct : 24 , green : 31 , blue : 35 , main : 38 <nl> - red : __destruct : 19 , red : 25 , green : 31 , blue : 35 , main : 38 <nl> deleted file mode 100644 <nl> index 7be711d1b18 . . 00000000000 <nl> mmm a / hphp / test / slow / inlining / 1844 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class X { <nl> - function __destruct ( ) { <nl> - var_dump ( ' done ' ) ; <nl> - } <nl> - } <nl> - function f ( ) { <nl> - $ x = new X ; <nl> - } <nl> - function g ( ) { <nl> - var_dump ( ' start ' ) ; <nl> - f ( ) ; <nl> - var_dump ( ' end ' ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_1844 ( ) { <nl> - g ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 381a2a66cb8 . . 00000000000 <nl> mmm a / hphp / test / slow / inlining / 1844 . php . expect <nl> ppp / dev / null <nl> <nl> - string ( 5 ) " start " <nl> - string ( 4 ) " done " <nl> - string ( 3 ) " end " <nl> deleted file mode 100644 <nl> index cb42350826f . . 00000000000 <nl> mmm a / hphp / test / slow / inlining / 1844 . php . hphp_opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vAutoInline = 5 - d hhvm . php7 . all = 0 - d hhvm . php7 . all = 0 <nl> mmm a / hphp / test / slow / inlining / unreachable - contains - key . php . hphp_opts <nl> ppp b / hphp / test / slow / inlining / unreachable - contains - key . php . hphp_opts <nl> @ @ - 1 + 1 @ @ <nl> - - vRuntime . Eval . AllowObjectDestructors = 0 - vEnableHipHopSyntax = 1 <nl> \ No newline at end of file <nl> + - vEnableHipHopSyntax = 1 <nl> mmm a / hphp / test / slow / inlining / unreachable - idx . php . hphp_opts <nl> ppp b / hphp / test / slow / inlining / unreachable - idx . php . hphp_opts <nl> @ @ - 1 + 1 @ @ <nl> - - vRuntime . Eval . AllowObjectDestructors = 0 - vEnableHipHopSyntax = 1 <nl> + - vEnableHipHopSyntax = 1 <nl> mmm a / hphp / test / slow / inout - loop - 2 . php <nl> ppp b / hphp / test / slow / inout - loop - 2 . php <nl> <nl> < ? hh <nl> <nl> class D { <nl> - function __destruct ( ) { echo " destruct ! \ n " ; } <nl> } <nl> <nl> function foo ( inout int $ x ) { <nl> mmm a / hphp / test / slow / inout - loop - 2 . php . expect <nl> ppp b / hphp / test / slow / inout - loop - 2 . php . expect <nl> @ @ - 1 , 2 + 1 @ @ <nl> - destruct ! <nl> done <nl> mmm a / hphp / test / slow / intercept / extra_args . php <nl> ppp b / hphp / test / slow / intercept / extra_args . php <nl> function foo ( ) { <nl> return 12 ; <nl> } <nl> <nl> - class lol { public function __destruct ( ) { echo " lol \ n " ; } } <nl> + class lol { } <nl> function bar ( ) { <nl> var_dump ( func_get_args ( ) ) ; <nl> $ x = new lol ( ) ; <nl> mmm a / hphp / test / slow / intercept / extra_args . php . expect <nl> ppp b / hphp / test / slow / intercept / extra_args . php . expect <nl> array ( 5 ) { <nl> } <nl> object ( lol ) # 1 ( 0 ) { <nl> } <nl> - lol <nl> array ( 5 ) { <nl> [ 0 ] = > <nl> string ( 3 ) " foo " <nl> array ( 5 ) { <nl> [ 4 ] = > <nl> bool ( true ) <nl> } <nl> - lol <nl> done <nl> deleted file mode 100644 <nl> index a40b98f53a3 . . 00000000000 <nl> mmm a / hphp / test / slow / intercept / interleaved_global_deregistration . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class B { <nl> - <nl> - public function __construct ( ) { <nl> - } <nl> - <nl> - public function __destruct ( ) { <nl> - $ this - > deregister ( ) ; <nl> - } <nl> - <nl> - private function deregister ( ) { <nl> - fb_intercept ( ' ' , false ) ; <nl> - } <nl> - <nl> - public function run ( ) { <nl> - echo " In B \ n " ; <nl> - } <nl> - } <nl> - <nl> - class A { <nl> - <nl> - public function __construct ( ) { <nl> - $ this - > register ( ) ; <nl> - } <nl> - <nl> - public function __destruct ( ) { <nl> - $ this - > deregister ( ) ; <nl> - } <nl> - <nl> - private function register ( ) { <nl> - $ x = new B ( ) ; <nl> - $ proxy = function ( $ name , $ obj , $ params , $ data ) { <nl> - echo " In proxy \ n " ; <nl> - $ data - > run ( ) ; <nl> - } ; <nl> - <nl> - fb_intercept ( ' mail ' , $ proxy , $ x ) ; <nl> - } <nl> - <nl> - private function deregister ( ) { <nl> - fb_intercept ( ' ' , false ) ; <nl> - } <nl> - <nl> - public function run ( ) { <nl> - echo " Running \ n " ; <nl> - mail ( ' nothing ' ) ; <nl> - } <nl> - } <nl> - <nl> - function run ( ) { <nl> - $ a = new A ( ) ; <nl> - $ a - > run ( ) ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_interleaved_global_deregistration ( ) { <nl> - run ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 98144e8b934 . . 00000000000 <nl> mmm a / hphp / test / slow / intercept / interleaved_global_deregistration . php . expect <nl> ppp / dev / null <nl> <nl> - Running <nl> - In proxy <nl> - In B <nl> deleted file mode 100644 <nl> index 2fd6b6a19a0 . . 00000000000 <nl> mmm a / hphp / test / slow / intercept / interleaved_global_deregistration . php . hphp_opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vDynamicInvokeFunctions . 0 = mail - d hhvm . php7 . all = 0 <nl> mmm a / hphp / test / slow / intercept / member_fn_intercept . php <nl> ppp b / hphp / test / slow / intercept / member_fn_intercept . php <nl> public static function foo ( ) { <nl> } <nl> } <nl> <nl> - class lol { public function __destruct ( ) { echo " lol \ n " ; } } <nl> + class lol { } <nl> class B { <nl> public static function bar ( ) { <nl> var_dump ( func_get_args ( ) ) ; <nl> mmm a / hphp / test / slow / intercept / member_fn_intercept . php . expect <nl> ppp b / hphp / test / slow / intercept / member_fn_intercept . php . expect <nl> array ( 5 ) { <nl> } <nl> object ( lol ) # 1 ( 0 ) { <nl> } <nl> - lol <nl> array ( 5 ) { <nl> [ 0 ] = > <nl> string ( 6 ) " A : : foo " <nl> array ( 5 ) { <nl> [ 4 ] = > <nl> bool ( true ) <nl> } <nl> - lol <nl> done <nl> mmm a / hphp / test / slow / intercept / prolog . php <nl> ppp b / hphp / test / slow / intercept / prolog . php <nl> function intercept2 ( ) { <nl> return false ; <nl> } <nl> function intercept3 ( ) { throw new Exception ( " intercept3 " ) ; } <nl> - function __destruct ( ) { } <nl> } <nl> <nl> function getCls ( ) { return new Cls ; } <nl> mmm a / hphp / test / slow / intercept / prolog . php . expectf <nl> ppp b / hphp / test / slow / intercept / prolog . php . expectf <nl> array ( 3 ) { <nl> [ " file " ] = > <nl> string ( % d ) " % s / intercept / prolog . php " <nl> [ " line " ] = > <nl> - int ( 20 ) <nl> + int ( 19 ) <nl> [ " function " ] = > <nl> string ( 4 ) " func " <nl> [ " class " ] = > <nl> array ( 3 ) { <nl> [ " file " ] = > <nl> string ( % d ) " % s / intercept / prolog . php " <nl> [ " line " ] = > <nl> - int ( 28 ) <nl> + int ( 27 ) <nl> [ " function " ] = > <nl> string ( 4 ) " test " <nl> [ " args " ] = > <nl> array ( 3 ) { <nl> } <nl> intercept2 DONE <nl> Caught exception : intercept3 <nl> - intercept3 DONE <nl> \ No newline at end of file <nl> + intercept3 DONE <nl> mmm a / hphp / test / slow / ir_inlining / 1 . php <nl> ppp b / hphp / test / slow / ir_inlining / 1 . php <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> class Dtor { <nl> - public function __destruct ( ) { <nl> - echo " dtor \ n " ; <nl> - } <nl> } <nl> <nl> function id ( $ x ) { <nl> mmm a / hphp / test / slow / ir_inlining / 1 . php . expect <nl> ppp b / hphp / test / slow / ir_inlining / 1 . php . expect <nl> <nl> - dtor <nl> - dtor <nl> haha <nl> asd foo <nl> foo <nl> deleted file mode 100644 <nl> index 7fbf207bd72 . . 00000000000 <nl> mmm a / hphp / test / slow / ir_inlining / inline - decref . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - <nl> - class d { <nl> - public function __construct ( ) { <nl> - echo " d constructing \ n " ; <nl> - } <nl> - <nl> - public function __destruct ( ) { <nl> - $ f0 = 0 ; <nl> - $ f1 = 1 ; <nl> - $ f2 = 2 ; <nl> - echo " d destructing \ n " ; <nl> - } <nl> - <nl> - public $ prop ; <nl> - } <nl> - <nl> - function fun ( d $ o ) { <nl> - $ o - > prop = null ; <nl> - } <nl> - <nl> - function main ( $ c1 , $ c2 , $ c3 , $ c4 ) { <nl> - $ o = new d ; <nl> - $ o - > prop = new d ; <nl> - fun ( $ o ) ; <nl> - var_dump ( $ c1 , $ c2 , $ c3 , $ c4 ) ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_inline_decref ( ) { <nl> - main ( ' ceeone ' , ' ceetwo ' , ' ceethree ' , ' ceefour ' ) ; <nl> - } <nl> deleted file mode 100644 <nl> index ea8709d5596 . . 00000000000 <nl> mmm a / hphp / test / slow / ir_inlining / inline - decref . php . expect <nl> ppp / dev / null <nl> <nl> - d constructing <nl> - d constructing <nl> - d destructing <nl> - string ( 6 ) " ceeone " <nl> - string ( 6 ) " ceetwo " <nl> - string ( 8 ) " ceethree " <nl> - string ( 7 ) " ceefour " <nl> - d destructing <nl> deleted file mode 100644 <nl> index 4b2f2aeabdd . . 00000000000 <nl> mmm a / hphp / test / slow / ir_inlining / static_with_destructor . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class A { <nl> - function __destruct ( ) { <nl> - print " destructor \ n " ; <nl> - } <nl> - <nl> - static function printer ( ) { print " static \ n " ; } <nl> - } <nl> - <nl> - function main ( ) { <nl> - ( new A ( ) ) - > printer ( ) ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_static_with_destructor ( ) { <nl> - main ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 965fa714068 . . 00000000000 <nl> mmm a / hphp / test / slow / ir_inlining / static_with_destructor . php . expect <nl> ppp / dev / null <nl> <nl> - destructor <nl> - static <nl> deleted file mode 100644 <nl> index cf06f7df7b1 . . 00000000000 <nl> mmm a / hphp / test / slow / ir_refcount / refcount_decref_alias . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class X { <nl> - private $ rc_prop = array ( ) ; <nl> - function __construct ( array $ x ) { <nl> - $ this - > rc_prop = $ x ; <nl> - } <nl> - function __destruct ( ) { <nl> - $ this - > rc_prop = null ; <nl> - } <nl> - function thing ( ) { <nl> - return $ this - > rc_prop ; <nl> - } <nl> - } <nl> - <nl> - function go ( ) { <nl> - var_dump ( ( new X ( [ new stdclass ] ) ) - > thing ( ) ) ; <nl> - var_dump ( ( new X ( [ new stdclass ] ) ) - > thing ( ) ) ; <nl> - var_dump ( ( new X ( [ new stdclass ] ) ) - > thing ( ) ) ; <nl> - var_dump ( ( new X ( [ new stdclass ] ) ) - > thing ( ) ) ; <nl> - var_dump ( ( new X ( [ new stdclass ] ) ) - > thing ( ) ) ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_refcount_decref_alias ( ) { <nl> - go ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index d7cd91ee56f . . 00000000000 <nl> mmm a / hphp / test / slow / ir_refcount / refcount_decref_alias . php . expect <nl> ppp / dev / null <nl> <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( stdClass ) # 2 ( 0 ) { <nl> - } <nl> - } <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( stdClass ) # 3 ( 0 ) { <nl> - } <nl> - } <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( stdClass ) # 4 ( 0 ) { <nl> - } <nl> - } <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( stdClass ) # 5 ( 0 ) { <nl> - } <nl> - } <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( stdClass ) # 6 ( 0 ) { <nl> - } <nl> - } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 6b5c0cdfa46 . . 00000000000 <nl> mmm a / hphp / test / slow / ir_refcount / refcount_decref_alias . php . opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vEval . HHIREnableGenTimeInlining = 0 <nl> mmm a / hphp / test / slow / keyset / from - obj - dtor . php <nl> ppp b / hphp / test / slow / keyset / from - obj - dtor . php <nl> class Cls implements Iterator { <nl> function __construct ( $ idx ) { <nl> $ this - > idx = $ idx ; <nl> } <nl> - function __destruct ( ) { <nl> - echo " Cls : : __destruct " . $ this - > idx . " \ n " ; <nl> - } <nl> <nl> public function rewind ( ) { } <nl> public function current ( ) { } <nl> function test ( ) { <nl> for ( $ i = 0 ; $ i < 10 ; $ i + + ) { <nl> echo " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv \ n " ; <nl> from_obj ( new Cls ( $ i ) ) ; <nl> + var_dump ( hh \ objprof_get_data ( ) ) ; <nl> echo " ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ \ n " ; <nl> } <nl> } <nl> mmm a / hphp / test / slow / keyset / from - obj - dtor . php . expect <nl> ppp b / hphp / test / slow / keyset / from - obj - dtor . php . expect <nl> <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 0 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 1 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 2 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 3 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 4 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 5 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 6 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 7 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 8 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 9 <nl> - ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> \ No newline at end of file <nl> + array ( 0 ) { <nl> + } <nl> + ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> mmm a / hphp / test / slow / lang / async_generators . php <nl> ppp b / hphp / test / slow / lang / async_generators . php <nl> private function __construct ( $ what ) { <nl> $ this - > what = $ what ; <nl> echo " constructing { $ this - > what } \ n " ; <nl> } <nl> - <nl> - private function __destruct ( ) { <nl> - echo " destructing { $ this - > what } \ n " ; <nl> - } <nl> } <nl> <nl> class Base { <nl> mmm a / hphp / test / slow / lang / async_generators . php . expect <nl> ppp b / hphp / test / slow / lang / async_generators . php . expect <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : = > 1 <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 2 : got 1 <nl> - destructing SentValue <nl> constructing Key <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : 2 = > 3 <nl> - destructing Key <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 3 : got 2 <nl> - destructing SentValue <nl> foo <nl> got foo 42 <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : = > 42 <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 4 : got 3 <nl> - destructing SentValue <nl> bar before <nl> constructing HH \ AsyncGeneratorWaitHandle <nl> awaiting HH \ AsyncGeneratorWaitHandle <nl> bar after <nl> got bar 47 <nl> constructing Value <nl> result : = > 47 <nl> - destructing Value <nl> - destructing HH \ AsyncGeneratorWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 5 : got 4 <nl> - destructing SentValue <nl> bar before <nl> constructing HH \ AsyncGeneratorWaitHandle <nl> awaiting HH \ AsyncGeneratorWaitHandle <nl> got bar 47 <nl> constructing Key <nl> constructing Value <nl> result : 47 = > 47 <nl> - destructing Key <nl> - destructing Value <nl> - destructing HH \ AsyncGeneratorWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 6 : got 5 <nl> - destructing SentValue <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : EOF <nl> - destructing HH \ StaticWaitHandle <nl> - destructing HH \ AsyncGenerator <nl> mmmmmmmmmmmmmmmmmm - - testing 1mmmmmmmmmmmmmmmmmm - - <nl> creating <nl> constructing HH \ AsyncGenerator <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : = > 1 <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 2 : got 1 <nl> - destructing SentValue <nl> constructing Key <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : 2 = > 3 <nl> - destructing Key <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 3 : got 2 <nl> - destructing SentValue <nl> foo <nl> got foo 42 <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : = > 42 <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 4 : got 3 <nl> - destructing SentValue <nl> bar before <nl> constructing HH \ AsyncGeneratorWaitHandle <nl> awaiting HH \ AsyncGeneratorWaitHandle <nl> bar after <nl> got bar 47 <nl> constructing Value <nl> result : = > 47 <nl> - destructing Value <nl> - destructing HH \ AsyncGeneratorWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 5 : got 4 <nl> - destructing SentValue <nl> bar before <nl> constructing HH \ AsyncGeneratorWaitHandle <nl> awaiting HH \ AsyncGeneratorWaitHandle <nl> got bar 47 <nl> constructing Key <nl> constructing Value <nl> result : 47 = > 47 <nl> - destructing Key <nl> - destructing Value <nl> - destructing HH \ AsyncGeneratorWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 6 : got 5 <nl> constructing HH \ AsyncGeneratorWaitHandle <nl> awaiting HH \ AsyncGeneratorWaitHandle <nl> bar after <nl> got bar 47 <nl> - destructing SentValue <nl> result : EOF <nl> - destructing HH \ AsyncGeneratorWaitHandle <nl> - destructing HH \ AsyncGenerator <nl> mmmmmmmmmmmmmmmmmm - - testing 2mmmmmmmmmmmmmmmmmm - - <nl> creating <nl> constructing HH \ AsyncGenerator <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : = > 1 <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 2 : got 1 <nl> - destructing SentValue <nl> constructing Key <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : 2 = > 3 <nl> - destructing Key <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 3 : got 2 <nl> - destructing SentValue <nl> foo <nl> got foo 42 <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : = > 42 <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 4 : got 3 <nl> - destructing SentValue <nl> bar before <nl> constructing HH \ AsyncGeneratorWaitHandle <nl> awaiting HH \ AsyncGeneratorWaitHandle <nl> bar after <nl> got bar 47 <nl> constructing Value <nl> result : = > 47 <nl> - destructing Value <nl> - destructing HH \ AsyncGeneratorWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 5 : got 4 <nl> - destructing SentValue <nl> bar before <nl> constructing HH \ AsyncGeneratorWaitHandle <nl> awaiting HH \ AsyncGeneratorWaitHandle <nl> got bar 47 <nl> constructing Key <nl> constructing Value <nl> result : 47 = > 47 <nl> - destructing Key <nl> - destructing Value <nl> - destructing HH \ AsyncGeneratorWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 6 : got 5 <nl> constructing Exception <nl> - destructing SentValue <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> - destructing HH \ StaticWaitHandle <nl> - destructing HH \ AsyncGenerator <nl> exception : hello world <nl> - destructing Exception <nl> mmmmmmmmmmmmmmmmmm - - testing 3mmmmmmmmmmmmmmmmmm - - <nl> creating <nl> constructing HH \ AsyncGenerator <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : = > 1 <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 2 : got 1 <nl> - destructing SentValue <nl> constructing Key <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : 2 = > 3 <nl> - destructing Key <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 3 : got 2 <nl> - destructing SentValue <nl> foo <nl> got foo 42 <nl> constructing Value <nl> constructing HH \ StaticWaitHandle <nl> awaiting HH \ StaticWaitHandle <nl> result : = > 42 <nl> - destructing Value <nl> - destructing HH \ StaticWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 4 : got 3 <nl> - destructing SentValue <nl> bar before <nl> constructing HH \ AsyncGeneratorWaitHandle <nl> awaiting HH \ AsyncGeneratorWaitHandle <nl> bar after <nl> got bar 47 <nl> constructing Value <nl> result : = > 47 <nl> - destructing Value <nl> - destructing HH \ AsyncGeneratorWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 5 : got 4 <nl> - destructing SentValue <nl> bar before <nl> constructing HH \ AsyncGeneratorWaitHandle <nl> awaiting HH \ AsyncGeneratorWaitHandle <nl> got bar 47 <nl> constructing Key <nl> constructing Value <nl> result : 47 = > 47 <nl> - destructing Key <nl> - destructing Value <nl> - destructing HH \ AsyncGeneratorWaitHandle <nl> calling next <nl> constructing SentValue <nl> step 6 : got 5 <nl> awaiting HH \ AsyncGeneratorWaitHandle <nl> bar after <nl> got bar 47 <nl> constructing Exception <nl> - destructing SentValue <nl> - destructing HH \ AsyncGeneratorWaitHandle <nl> - destructing HH \ AsyncGenerator <nl> exception : hello world <nl> - destructing Exception <nl> end <nl> mmm a / hphp / test / slow / lang / properties . php <nl> ppp b / hphp / test / slow / lang / properties . php <nl> public function doAssignment ( ) { <nl> } <nl> <nl> class dumper { <nl> - public function __destruct ( ) { <nl> - var_dump ( $ this ) ; <nl> - } <nl> } <nl> function foo ( ) { <nl> return new dumper ; <nl> mmm a / hphp / test / slow / lang / properties . php . expect <nl> ppp b / hphp / test / slow / lang / properties . php . expect <nl> Properties : <nl> " p " = > 112 <nl> " q " = > 223 <nl> " r " = > 340 <nl> - object ( dumper ) # 9 ( 1 ) { <nl> - [ " prop " ] = > <nl> - int ( 10 ) <nl> - } <nl> Test end <nl> new file mode 100644 <nl> index 00000000000 . . 4977cc25517 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / lang / reflection . php . opts <nl> @ @ - 0 , 0 + 1 @ @ <nl> + - vEval . JitPGODecRefNZReleasePercentCOW = 0 - vEval . JitPGODecRefNZReleasePercent = 0 <nl> mmm a / hphp / test / slow / libxml / dom - node - destruction - v1 . php <nl> ppp b / hphp / test / slow / libxml / dom - node - destruction - v1 . php <nl> function init ( ) { <nl> return $ this ; <nl> } <nl> <nl> - function __destruct ( ) { <nl> - echo " Destructing DOMElement # " . $ this - > id . " : " . $ this - > tagName . " \ n " ; <nl> - } <nl> - <nl> function info ( ) { <nl> echo " Querying DOMElement # " . $ this - > id . " : " . $ this - > tagName . " \ n " ; <nl> } <nl> mmm a / hphp / test / slow / libxml / dom - node - destruction - v1 . php . expect <nl> ppp b / hphp / test / slow / libxml / dom - node - destruction - v1 . php . expect <nl> Enter bar ( ) <nl> Enter foo ( ) <nl> Initializing DOMElement # 0 : foo <nl> Initializing DOMElement # 1 : bar <nl> - Destructing DOMElement # 1 : bar <nl> Leave foo ( ) <nl> Querying DOMElement # 0 : foo <nl> Leave bar ( ) <nl> - Destructing DOMElement # 0 : foo <nl> Leave main ( ) <nl> mmm a / hphp / test / slow / libxml / dom - node - destruction - v2 . php <nl> ppp b / hphp / test / slow / libxml / dom - node - destruction - v2 . php <nl> function init ( ) { <nl> return $ this ; <nl> } <nl> <nl> - function __destruct ( ) { <nl> - echo " Destructing DOMElement # " . $ this - > id . " : " . $ this - > tagName . " \ n " ; <nl> - } <nl> - <nl> function info ( ) { <nl> echo " Querying DOMElement # " . $ this - > id . " : " . $ this - > tagName . " \ n " ; <nl> } <nl> mmm a / hphp / test / slow / libxml / dom - node - destruction - v2 . php . expect <nl> ppp b / hphp / test / slow / libxml / dom - node - destruction - v2 . php . expect <nl> Initializing DOMElement # 0 : foo <nl> Initializing DOMElement # 1 : bar <nl> Initializing DOMElement # 2 : fiz <nl> Leave foo ( ) <nl> - Destructing DOMElement # 2 : fiz <nl> - Destructing DOMElement # 0 : foo <nl> Querying DOMElement # : fiz <nl> string ( 12 ) " / foo / bar / fiz " <nl> Leave bar ( ) <nl> - Destructing DOMElement # : fiz <nl> - Destructing DOMElement # 1 : bar <nl> Leave main ( ) <nl> mmm a / hphp / test / slow / memory / uninit - leak . php <nl> ppp b / hphp / test / slow / memory / uninit - leak . php <nl> <nl> const N = 10 ; <nl> <nl> class Obj { <nl> - function __destruct ( ) { <nl> - echo " object destroyed \ n " ; <nl> - } <nl> } <nl> <nl> class X { <nl> function __construct ( ) { <nl> } <nl> <nl> <nl> + function f ( ) { <nl> + $ x = new X ( ) ; <nl> + $ x - > f ( ) ; <nl> + } <nl> + <nl> < < __EntryPoint > > <nl> function main_uninit_leak ( ) { <nl> - $ x = new X ( ) ; <nl> - $ x - > f ( ) ; <nl> - echo " done \ n " ; <nl> + f ( ) ; <nl> + var_dump ( hh \ objprof_get_data ( ) ) ; <nl> + echo " done \ n " ; <nl> } <nl> mmm a / hphp / test / slow / memory / uninit - leak . php . expect <nl> ppp b / hphp / test / slow / memory / uninit - leak . php . expect <nl> <nl> iterating . . . <nl> iterating . . . <nl> - object destroyed <nl> iterating . . . <nl> - object destroyed <nl> iterating . . . <nl> - object destroyed <nl> iterating . . . <nl> - object destroyed <nl> iterating . . . <nl> - object destroyed <nl> iterating . . . <nl> - object destroyed <nl> iterating . . . <nl> - object destroyed <nl> iterating . . . <nl> - object destroyed <nl> iterating . . . <nl> - object destroyed <nl> iterating . . . <nl> - object destroyed <nl> + array ( 0 ) { <nl> + } <nl> done <nl> deleted file mode 100644 <nl> index a9c38d8b69b . . 00000000000 <nl> mmm a / hphp / test / slow / new_object_expression / 781 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class A { <nl> - function __construct ( $ a ) { <nl> - echo " A \ n " ; <nl> - } <nl> - function __destruct ( ) { <nl> - var_dump ( $ this ) ; <nl> - } <nl> - } <nl> - function f ( ) { <nl> - echo " f \ n " ; <nl> - throw new Exception ( ) ; <nl> - } <nl> - function test ( ) { <nl> - $ a = new A ( f ( ) ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_781 ( ) { <nl> - try { <nl> - test ( ) ; <nl> - } <nl> - catch ( Exception $ e ) { <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index 6a69f92020f . . 00000000000 <nl> mmm a / hphp / test / slow / new_object_expression / 781 . php . expect <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - f <nl> mmm a / hphp / test / slow / object / 645 . php <nl> ppp b / hphp / test / slow / object / 645 . php <nl> class A { <nl> public function __construct ( $ a ) { <nl> $ this - > a = $ a + 1 ; <nl> } <nl> - public function __destruct ( ) { <nl> - $ this - > a + = 2 ; <nl> - var_dump ( $ this - > a ) ; <nl> - } <nl> } <nl> class B extends A { <nl> public function __construct ( $ a ) { <nl> mmm a / hphp / test / slow / object / 645 . php . expect <nl> ppp b / hphp / test / slow / object / 645 . php . expect <nl> <nl> int ( 2 ) <nl> - int ( 4 ) <nl> int ( 3 ) <nl> - int ( 5 ) <nl> int ( 2 ) <nl> - int ( 4 ) <nl> deleted file mode 100644 <nl> index d1f4b7f2f30 . . 00000000000 <nl> mmm a / hphp / test / slow / object / 670 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - $ x = null ; <nl> - $ y = 0 ; <nl> - class C { <nl> - public $ p = " C : : \ $ p " ; <nl> - function __destruct ( ) { <nl> - global $ x , $ y ; <nl> - print " In C : : __destruct ( ) : $ y <nl> - " ; <nl> - $ this - > p = " changed " ; <nl> - $ x = $ this ; <nl> - } <nl> - } <nl> - $ c = new C ( ) ; <nl> - var_dump ( $ c ) ; <nl> - $ c = null ; <nl> - $ y = 140 ; <nl> - var_dump ( $ x ) ; <nl> - $ x = null ; <nl> deleted file mode 100644 <nl> index 3b8defd3b1b . . 00000000000 <nl> mmm a / hphp / test / slow / object / 670 . php . expect <nl> ppp / dev / null <nl> <nl> - object ( C ) # 1 ( 1 ) { <nl> - [ " p " ] = > <nl> - string ( 5 ) " C : : $ p " <nl> - } <nl> - In C : : __destruct ( ) : 0 <nl> - object ( C ) # 1 ( 1 ) { <nl> - [ " p " ] = > <nl> - string ( 7 ) " changed " <nl> - } <nl> deleted file mode 100644 <nl> index 4510f4a0583 . . 00000000000 <nl> mmm a / hphp / test / slow / object / 670 . php . hphp_opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vEnableHipHopSyntax = 1 - d hhvm . php7 . all = 0 - d hhvm . php7 . all = 0 <nl> deleted file mode 120000 <nl> index 192ba8eb2b5 . . 00000000000 <nl> mmm a / hphp / test / slow / object / 670 . php . opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - . . / hiphop . opts <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index de4c03ec353 . . 00000000000 <nl> mmm a / hphp / test / slow / object / no - destructors - ok . php <nl> ppp / dev / null <nl> <nl> - < ? hh <nl> - <nl> - class HaveDestructor { <nl> - function __destruct ( ) { } <nl> - } <nl> - <nl> - class NoDestructor { <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_no_destructors_ok ( ) { <nl> - new NoDestructor ( ) ; <nl> - echo " Should get here \ n " ; <nl> - } <nl> deleted file mode 100644 <nl> index 5ce72c54828 . . 00000000000 <nl> mmm a / hphp / test / slow / object / no - destructors - ok . php . expect <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - Should get here <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 03604540973 . . 00000000000 <nl> mmm a / hphp / test / slow / object / no - destructors - ok . php . ini <nl> ppp / dev / null <nl> <nl> - hhvm . allow_object_destructors = false <nl> - hhvm . php7 . all = false <nl> - hhvm . hack . lang . look_for_typechecker = 0 <nl> deleted file mode 100644 <nl> index 2997505e7f6 . . 00000000000 <nl> mmm a / hphp / test / slow / object / no - destructors . php <nl> ppp / dev / null <nl> <nl> - < ? php / * destructor * / <nl> - <nl> - class HaveDestructor { <nl> - function __destruct ( ) { } <nl> - } <nl> - <nl> - echo " Should get here \ n " ; <nl> - new HaveDestructor ( ) ; <nl> - echo " Should not get here \ n " ; <nl> deleted file mode 100644 <nl> index 764593c26b3 . . 00000000000 <nl> mmm a / hphp / test / slow / object / no - destructors . php . expectf <nl> ppp / dev / null <nl> <nl> - Should get here <nl> - <nl> - Fatal error : Class HaveDestructor has a __destruct ( ) method and cannot be instantiated when Eval . DisallowObjectDestructors is set in % s / test / slow / object / no - destructors . php on line 8 <nl> deleted file mode 100644 <nl> index 967b23d2789 . . 00000000000 <nl> mmm a / hphp / test / slow / object / no - destructors . php . ini <nl> ppp / dev / null <nl> <nl> - hhvm . allow_object_destructors = false <nl> - hhvm . php7 . all = false <nl> - hhvm . php7 . all = false <nl> - hhvm . php7 . all = false <nl> - hhvm . php7 . all = false <nl> deleted file mode 100644 <nl> index 234a0e09758 . . 00000000000 <nl> mmm a / hphp / test / slow / object / optional - destruct . php <nl> ppp / dev / null <nl> <nl> - < ? hh / / decl <nl> - <nl> - class Destruct { <nl> - function __destruct ( ) { } <nl> - } <nl> - <nl> - class OptionalDestruct { <nl> - < < __OptionalDestruct > > <nl> - function __destruct ( ) { echo " OptionalDestruct destructing \ n " ; } <nl> - } <nl> - <nl> - $ o = new Redis ( ) ; <nl> - echo " Created Redis \ n " ; <nl> - $ o = new OptionalDestruct ( ) ; <nl> - echo " Created OptionalDestruct \ n " ; <nl> - unset ( $ o ) ; <nl> - new Destruct ( ) ; <nl> deleted file mode 100644 <nl> index 7e4549bc0c6 . . 00000000000 <nl> mmm a / hphp / test / slow / object / optional - destruct . php . expectf <nl> ppp / dev / null <nl> <nl> - Created Redis <nl> - Created OptionalDestruct <nl> - <nl> - Fatal error : Class Destruct has a __destruct ( ) method and cannot be instantiated when Eval . DisallowObjectDestructors is set in % s / test / slow / object / optional - destruct . php on line 17 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 03604540973 . . 00000000000 <nl> mmm a / hphp / test / slow / object / optional - destruct . php . ini <nl> ppp / dev / null <nl> <nl> - hhvm . allow_object_destructors = false <nl> - hhvm . php7 . all = false <nl> - hhvm . hack . lang . look_for_typechecker = 0 <nl> deleted file mode 100644 <nl> index b282b9d60e9 . . 00000000000 <nl> mmm a / hphp / test / slow / object / unserialize - destructor . php <nl> ppp / dev / null <nl> <nl> - < ? hh <nl> - <nl> - class Dtor { <nl> - function __destruct ( ) { <nl> - echo " fail ! \ n " ; <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - $ d = unserialize ( ' O : 4 : " Dtor " : 0 : { } ' ) ; <nl> - } <nl> - main ( ) ; <nl> deleted file mode 100644 <nl> index fcc6c8a09ae . . 00000000000 <nl> mmm a / hphp / test / slow / object / unserialize - destructor . php . expectf <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - Fatal error : Class Dtor has a __destruct ( ) method and cannot be instantiated when % s in % s / test / slow / object / unserialize - destructor . php on line 10 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 952de227f00 . . 00000000000 <nl> mmm a / hphp / test / slow / object / unserialize - destructor . php . hphp_opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vAllowObjectDestructors = 0 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index d2c7f41f383 . . 00000000000 <nl> mmm a / hphp / test / slow / object / unserialize - destructor . php . opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vEval . AllowObjectDestructors = 0 <nl> \ No newline at end of file <nl> mmm a / hphp / test / slow / object_magic_method / 763 . php <nl> ppp b / hphp / test / slow / object_magic_method / 763 . php <nl> class X { <nl> } <nl> else { <nl> class X { <nl> - function __destruct ( ) { <nl> + function foo ( ) { <nl> var_dump ( __METHOD__ ) ; <nl> } <nl> } <nl> } <nl> class Y extends X { <nl> - function __destruct ( ) { <nl> + function foo ( ) { <nl> var_dump ( __METHOD__ ) ; <nl> - parent : : __destruct ( ) ; <nl> + parent : : foo ( ) ; <nl> } <nl> } <nl> class Z extends X { <nl> } <nl> function test ( $ t ) { <nl> var_dump ( ' test : ' . $ t ) ; <nl> - new $ t ( 1 , 2 ) ; <nl> + ( new $ t ( 1 , 2 ) ) - > foo ( ) ; <nl> } <nl> test ( ' X ' ) ; <nl> test ( ' Y ' ) ; <nl> mmm a / hphp / test / slow / object_magic_method / 763 . php . expect <nl> ppp b / hphp / test / slow / object_magic_method / 763 . php . expect <nl> <nl> string ( 6 ) " test : X " <nl> - string ( 13 ) " X : : __destruct " <nl> + string ( 6 ) " X : : foo " <nl> string ( 6 ) " test : Y " <nl> - string ( 13 ) " Y : : __destruct " <nl> - string ( 13 ) " X : : __destruct " <nl> + string ( 6 ) " Y : : foo " <nl> + string ( 6 ) " X : : foo " <nl> string ( 6 ) " test : Z " <nl> - string ( 13 ) " X : : __destruct " <nl> + string ( 6 ) " X : : foo " <nl> deleted file mode 120000 <nl> index a2824ab0039 . . 00000000000 <nl> mmm a / hphp / test / slow / object_method / fpush - leaks - 2 . php <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - fpush - leaks . php <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 210aeed564c . . 00000000000 <nl> mmm a / hphp / test / slow / object_method / fpush - leaks . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> - <nl> - class logger { <nl> - private static $ num ; <nl> - private $ id ; <nl> - <nl> - public function __construct ( ) { <nl> - $ this - > id = self : : $ num + + ; <nl> - printf ( " logger % d constructing \ n " , $ this - > id ) ; <nl> - } <nl> - public function __destruct ( ) { <nl> - printf ( " logger % d destructing \ n " , $ this - > id ) ; <nl> - } <nl> - } <nl> - <nl> - function func ( $ a , $ b ) { } <nl> - <nl> - function main ( $ o ) { <nl> - echo " about to call func \ n " ; <nl> - func ( new logger , $ o - > foo ( ) ) ; <nl> - echo " leaving main \ n " ; <nl> - } <nl> - <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_fpush_leaks ( ) { <nl> - main ( new logger ) ; <nl> - } <nl> deleted file mode 100644 <nl> index be058218e6c . . 00000000000 <nl> mmm a / hphp / test / slow / object_method / fpush - leaks . php . expectf <nl> ppp / dev / null <nl> <nl> - logger 0 constructing <nl> - about to call func <nl> - logger 1 constructing <nl> - <nl> - Fatal error : Call to undefined method logger : : foo ( ) in % s / test / slow / object_method / fpush - leaks . php on line 21 <nl> - logger 0 destructing <nl> \ No newline at end of file <nl> mmm a / hphp / test / slow / object_property / 697 . php <nl> ppp b / hphp / test / slow / object_property / 697 . php <nl> <nl> < ? php <nl> <nl> class X { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> protected $ prot_over_prot = 1 ; <nl> public $ pub_over_pub = 2 ; <nl> protected $ pub_over_prot = 3 ; <nl> } <nl> class Y extends X { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ , $ this ) ; <nl> - } <nl> protected $ prot_over_prot = 4 ; <nl> public $ pub_over_pub = 5 ; <nl> public $ pub_over_prot = 6 ; <nl> function __destruct ( ) { <nl> public $ pub_base = 8 ; <nl> } <nl> class Z extends Y { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> public $ prot_over_prot = 9 ; <nl> public $ pub_over_pub = 10 ; <nl> public $ pub_over_prot = 11 ; <nl> Binary files a / hphp / test / slow / object_property / 697 . php . expect and b / hphp / test / slow / object_property / 697 . php . expect differ <nl> deleted file mode 100644 <nl> index 863e00f5823 . . 00000000000 <nl> mmm a / hphp / test / slow / object_property / dynprop_order . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class dtor { <nl> - private $ i ; <nl> - function __construct ( $ i ) { $ this - > i = $ i ; } <nl> - function __destruct ( ) { echo " dtor : $ this - > i \ n " ; } <nl> - } <nl> - <nl> - class X { <nl> - public $ decl ; <nl> - } <nl> - <nl> - function go ( ) { <nl> - $ x = ( new X ) ; <nl> - $ x - > decl = new dtor ( 0 ) ; <nl> - $ x - > dyn = new dtor ( 1 ) ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_dynprop_order ( ) { <nl> - go ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index cb8701fc625 . . 00000000000 <nl> mmm a / hphp / test / slow / object_property / dynprop_order . php . expect <nl> ppp / dev / null <nl> <nl> - dtor : 0 <nl> - dtor : 1 <nl> mmm a / hphp / test / slow / pipe_expr / pipevar - 4 . php <nl> ppp b / hphp / test / slow / pipe_expr / pipevar - 4 . php <nl> <nl> <nl> class Wrapper { <nl> public function __construct ( public array $ val ) { var_dump ( " Make wrapper " ) ; } <nl> - public function __destruct ( ) { var_dump ( " Destroy wrapper " ) ; } <nl> } <nl> <nl> function beep ( $ x ) { <nl> mmm a / hphp / test / slow / pipe_expr / pipevar - 4 . php . expect <nl> ppp b / hphp / test / slow / pipe_expr / pipevar - 4 . php . expect <nl> string ( 7 ) " beep : 3 " <nl> string ( 7 ) " beep : 3 " <nl> string ( 12 ) " Make wrapper " <nl> string ( 15 ) " beep : < Wrapper > " <nl> - string ( 15 ) " Destroy wrapper " <nl> string ( 13 ) " beep : < array > " <nl> string ( 6 ) " Hello ! " <nl> array ( 4 ) { <nl> mmm a / hphp / test / slow / program_functions / test_runner_config . php <nl> ppp b / hphp / test / slow / program_functions / test_runner_config . php <nl> function main_test_runner_config ( ) { <nl> var_dump ( ini_get ( " hhvm . error_handling . warning_frequency " ) ) ; <nl> var_dump ( ini_get ( " hhvm . allow_hhas " ) ) ; <nl> var_dump ( ini_get ( " hhvm . force_hh " ) ) ; <nl> - var_dump ( ini_get ( " hhvm . enable_obj_destruct_call " ) ) ; <nl> var_dump ( ini_get ( " hhvm . enable_xhp " ) ) ; <nl> var_dump ( ini_get ( " hhvm . jit_a_size " ) ) ; <nl> var_dump ( ini_get ( " hhvm . jit_a_cold_size " ) ) ; <nl> mmm a / hphp / test / slow / program_functions / test_runner_config . php . expect <nl> ppp b / hphp / test / slow / program_functions / test_runner_config . php . expect <nl> string ( 1 ) " 1 " <nl> string ( 1 ) " 1 " <nl> string ( 1 ) " 1 " <nl> string ( 1 ) " 1 " <nl> - string ( 1 ) " 1 " <nl> string ( 8 ) " 15728640 " <nl> string ( 8 ) " 10485760 " <nl> string ( 8 ) " 10485760 " <nl> mmm a / hphp / test / slow / redeclared_classes / 1484 . php <nl> ppp b / hphp / test / slow / redeclared_classes / 1484 . php <nl> class X { <nl> else { <nl> class X { <nl> public $ a = 1 ; <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> } <nl> } <nl> class X1 extends X { <nl> mmm a / hphp / test / slow / redeclared_classes / 1484 . php . expect <nl> ppp b / hphp / test / slow / redeclared_classes / 1484 . php . expect <nl> <nl> int ( 3 ) <nl> int ( 5 ) <nl> - string ( 13 ) " X : : __destruct " <nl> - string ( 13 ) " X : : __destruct " <nl> mmm a / hphp / test / slow / redeclared_classes / 1489 . php <nl> ppp b / hphp / test / slow / redeclared_classes / 1489 . php <nl> class X { <nl> } <nl> else { <nl> class X { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> protected $ prot_over_prot = 1 ; <nl> public $ pub_over_pub = 2 ; <nl> protected $ pub_over_prot = 3 ; <nl> } <nl> } <nl> class Y extends X { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ , $ this ) ; <nl> - } <nl> protected $ prot_over_prot = 4 ; <nl> public $ pub_over_pub = 5 ; <nl> public $ pub_over_prot = 6 ; <nl> function __destruct ( ) { <nl> public $ pub_base = 8 ; <nl> } <nl> class Z extends Y { <nl> - function __destruct ( ) { <nl> - var_dump ( __METHOD__ ) ; <nl> - } <nl> public $ prot_over_prot = 9 ; <nl> public $ pub_over_pub = 10 ; <nl> public $ pub_over_prot = 11 ; <nl> Binary files a / hphp / test / slow / redeclared_classes / 1489 . php . expect and b / hphp / test / slow / redeclared_classes / 1489 . php . expect differ <nl> deleted file mode 100644 <nl> index 0b0b1514c34 . . 00000000000 <nl> mmm a / hphp / test / slow / reference / 1101 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class X { <nl> - public $ x = 10 ; <nl> - function __destruct ( ) { <nl> - var_dump ( ' destruct ' ) ; <nl> - $ this - > x = 0 ; <nl> - } <nl> - } <nl> - function test ( & $ a , $ b ) { <nl> - var_dump ( $ a , $ b ) ; <nl> - } <nl> - function f ( $ x ) { <nl> - unset ( $ GLOBALS [ ' a ' ] ) ; <nl> - return 1 ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_1101 ( ) { <nl> - $ a = array ( new X ) ; <nl> - test ( & $ a [ 0 ] , f ( 1 ) ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 479f07ad11b . . 00000000000 <nl> mmm a / hphp / test / slow / reference / 1101 . php . expect <nl> ppp / dev / null <nl> <nl> - object ( X ) # 1 ( 1 ) { <nl> - [ " x " ] = > <nl> - int ( 10 ) <nl> - } <nl> - int ( 1 ) <nl> - string ( 8 ) " destruct " <nl> mmm a / hphp / test / slow / reflection_classes / 1354 . php <nl> ppp b / hphp / test / slow / reflection_classes / 1354 . php <nl> function dump_class ( $ cls , $ obj ) { <nl> var_dump ( $ func - > isProtected ( ) ) ; <nl> var_dump ( $ func - > isStatic ( ) ) ; <nl> var_dump ( $ func - > isConstructor ( ) ) ; <nl> - var_dump ( $ func - > isDestructor ( ) ) ; <nl> var_dump ( $ func - > getModifiers ( ) & 0xFFFF ) ; <nl> verify_class ( $ func - > getDeclaringClass ( ) ) ; <nl> if ( $ name = = ' method1 ' ) $ func - > invoke ( $ obj , ' invoked ' ) ; <nl> mmm a / hphp / test / slow / reflection_classes / 1354 . php . expect <nl> ppp b / hphp / test / slow / reflection_classes / 1354 . php . expect <nl> bool ( false ) <nl> bool ( false ) <nl> bool ( false ) <nl> bool ( false ) <nl> - bool ( false ) <nl> int ( 256 ) <nl> string ( 4 ) " cls1 " <nl> invokedbool ( true ) <nl> bool ( false ) <nl> bool ( false ) <nl> bool ( false ) <nl> bool ( false ) <nl> - bool ( false ) <nl> int ( 256 ) <nl> string ( 4 ) " cls1 " <nl> invoked <nl> mmm a / hphp / test / slow / spec / tests / basic_concepts / memory_model_and_array_types . php <nl> ppp b / hphp / test / slow / spec / tests / basic_concepts / memory_model_and_array_types . php <nl> <nl> <nl> class Point <nl> { <nl> - private static $ pointCount = 0 ; <nl> - <nl> private $ x ; <nl> private $ y ; <nl> <nl> public function __construct ( $ x = 0 , $ y = 0 ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> } <nl> <nl> public function move ( $ x , $ y ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - } <nl> + } <nl> <nl> public function translate ( $ x , $ y ) <nl> { <nl> public function translate ( $ x , $ y ) <nl> $ this - > y + = $ y ; <nl> } <nl> <nl> - public function __destruct ( ) <nl> - { <nl> - - - self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> - } <nl> - / / / * <nl> - public function __clone ( ) <nl> - { <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> - } <nl> - / / * / <nl> - <nl> public function __toString ( ) <nl> { <nl> return ' ( ' . $ this - > x . ' , ' . $ this - > y . ' ) ' ; <nl> - } <nl> + } <nl> } <nl> <nl> / / / * <nl> mmm a / hphp / test / slow / spec / tests / basic_concepts / memory_model_and_array_types . php . expect <nl> ppp b / hphp / test / slow / spec / tests / basic_concepts / memory_model_and_array_types . php . expect <nl> <nl> mmmmmmmmmmmmmmm - - simple assignment of array types mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 1 , 3 ) , point count = 1 <nl> - <nl> After ' $ a = array ( . . . ) ' , $ a is array ( 3 ) { <nl> [ 0 ] = > <nl> int ( 10 ) <nl> After ' unset ( $ a ) ' , $ a is undefined , $ b is array ( 3 ) { <nl> int ( 3 ) <nl> } <nl> } <nl> - <nl> - Inside Point : : __destruct , ( 1 , 3 ) , point count = 0 <nl> - <nl> After ' unset ( $ b ) ' , $ b is undefined <nl> mmmmmmmmmmmmmmm - - byRef assignment of array types mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 1 , 3 ) , point count = 1 <nl> - <nl> After ' $ a = array ( . . . ) ' , $ a is array ( 3 ) { <nl> [ 0 ] = > <nl> int ( 10 ) <nl> After ' unset ( $ a ) ' , $ a is undefined , $ c is array ( 3 ) { <nl> int ( 3 ) <nl> } <nl> } <nl> - <nl> - Inside Point : : __destruct , ( 1 , 3 ) , point count = 0 <nl> - <nl> End <nl> mmmmmmmmmmmmmmm - - unsetting array elements mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 1 , 3 ) , point count = 1 <nl> - <nl> at start , $ x is 123 , $ a is array ( 4 ) { <nl> [ 0 ] = > <nl> int ( 10 ) <nl> after unset ( $ a [ 1 ] ) , $ x is 123 , $ a is array ( 1 ) { <nl> int ( 3 ) <nl> } <nl> } <nl> - <nl> - Inside Point : : __destruct , ( 1 , 3 ) , point count = 0 <nl> - <nl> after unset ( $ a ) , $ x is 123 , $ a is undefined <nl> mmm a / hphp / test / slow / spec / tests / basic_concepts / memory_model_and_handle_types . php <nl> ppp b / hphp / test / slow / spec / tests / basic_concepts / memory_model_and_handle_types . php <nl> <nl> <nl> class Point <nl> { <nl> - private static $ pointCount = 0 ; <nl> - <nl> private $ x ; <nl> private $ y ; <nl> <nl> public function __construct ( $ x = 0 , $ y = 0 ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> } <nl> <nl> public function move ( $ x , $ y ) <nl> public function translate ( $ x , $ y ) <nl> $ this - > y + = $ y ; <nl> } <nl> <nl> - public function __destruct ( ) <nl> - { <nl> - - - self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> - } <nl> - / / / * <nl> - public function __clone ( ) <nl> - { <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> - } <nl> - / / * / <nl> - <nl> public function __toString ( ) <nl> { <nl> return ' ( ' . $ this - > x . ' , ' . $ this - > y . ' ) ' ; <nl> class C <nl> { <nl> public $ prop1 ; <nl> public $ prop2 ; <nl> - <nl> - public function __destruct ( ) <nl> - { <nl> - echo " \ nInside " . __METHOD__ . " \ n \ n " ; <nl> - } <nl> } <nl> <nl> $ c = new C ; <nl> mmm a / hphp / test / slow / spec / tests / basic_concepts / memory_model_and_handle_types . php . expectf <nl> ppp b / hphp / test / slow / spec / tests / basic_concepts / memory_model_and_handle_types . php . expectf <nl> <nl> mmmmmmmmmmmmmmm - - simple assignment of handle types mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 1 , 3 ) , point count = 1 <nl> - <nl> After ' $ a = new Point ( 1 , 3 ) ' , $ a is ( 1 , 3 ) <nl> After ' $ b = $ a ' , $ b is ( 1 , 3 ) <nl> - <nl> - Inside Point : : __clone , ( 1 , 3 ) , point count = 2 <nl> - <nl> After ' $ d = clone $ b ' , $ d is ( 1 , 3 ) <nl> After ' $ b - > move ( 4 , 6 ) ' , $ d is ( 1 , 3 ) , $ b is ( 4 , 6 ) , and $ a is ( 4 , 6 ) <nl> - <nl> - Inside Point : : __construct , ( 2 , 1 ) , point count = 3 <nl> - <nl> After ' $ a = new Point ( 2 , 1 ) ' , $ d is ( 1 , 3 ) , $ b is ( 4 , 6 ) , and $ a is ( 2 , 1 ) <nl> - <nl> - Inside Point : : __destruct , ( 2 , 1 ) , point count = 2 <nl> - <nl> - <nl> - Inside Point : : __destruct , ( 4 , 6 ) , point count = 1 <nl> - <nl> - <nl> - Inside Point : : __destruct , ( 1 , 3 ) , point count = 0 <nl> - <nl> Done <nl> mmmmmmmmmmmmmmm - - byRef assignment of handle types mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 1 , 3 ) , point count = 1 <nl> - <nl> After ' $ a = new Point ( 1 , 3 ) ' , $ a is ( 1 , 3 ) <nl> After ' $ c = & $ a ' , $ c is ( 1 , 3 ) , and $ a is ( 1 , 3 ) <nl> After ' $ a - > move ( 4 , 6 ) ' , $ c is ( 4 , 6 ) , and $ a is ( 4 , 6 ) <nl> - <nl> - Inside Point : : __construct , ( 2 , 1 ) , point count = 2 <nl> - <nl> - <nl> - Inside Point : : __destruct , ( 4 , 6 ) , point count = 1 <nl> - <nl> After ' $ a = new Point ( 2 , 1 ) ' , $ c is ( 2 , 1 ) , and $ a is ( 2 , 1 ) <nl> After ' unset ( $ a ) ' , $ c is ( 2 , 1 ) <nl> - <nl> - Inside Point : : __destruct , ( 2 , 1 ) , point count = 0 <nl> - <nl> Done <nl> mmmmmmmmmmmmmmm - - value argument passing of handle types mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 1 , 3 ) , point count = 1 <nl> - <nl> After ' $ a = new Point ( 1 , 3 ) ' , $ a is ( 1 , 3 ) <nl> Inside function f1 , $ b is ( 1 , 3 ) <nl> After ' $ b - > move ( 4 , 6 ) ' , $ b is ( 4 , 6 ) <nl> - <nl> - Inside Point : : __construct , ( 5 , 7 ) , point count = 2 <nl> - <nl> After ' new Point ( 5 , 7 ) ' , $ b is ( 5 , 7 ) <nl> - <nl> - Inside Point : : __destruct , ( 5 , 7 ) , point count = 1 <nl> - <nl> After ' f1 ( $ a ) ' , $ a is ( 4 , 6 ) <nl> - <nl> - Inside Point : : __destruct , ( 4 , 6 ) , point count = 0 <nl> - <nl> Done <nl> mmmmmmmmmmmmmmm - - byRef argument passing of handle types mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 1 , 3 ) , point count = 1 <nl> - <nl> After ' $ a = new Point ( 1 , 3 ) ' , $ a is ( 1 , 3 ) <nl> Inside function g1 , $ b is ( 1 , 3 ) <nl> After ' $ b - > move ( 4 , 6 ) ' , $ b is ( 4 , 6 ) <nl> - <nl> - Inside Point : : __construct , ( 5 , 7 ) , point count = 2 <nl> - <nl> - <nl> - Inside Point : : __destruct , ( 4 , 6 ) , point count = 1 <nl> - <nl> After ' new Point ( 5 , 7 ) ' , $ b is ( 5 , 7 ) <nl> After ' g1 ( $ a ) ' , $ a is ( 5 , 7 ) <nl> - <nl> - Inside Point : : __destruct , ( 5 , 7 ) , point count = 0 <nl> - <nl> Done <nl> mmmmmmmmmmmmmmm - - value returning of handle types mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 5 , 7 ) , point count = 1 <nl> - <nl> After ' new Point ( 5 , 7 ) ' , $ b is ( 5 , 7 ) <nl> After ' $ a = f2 ( ) ' , $ a is ( 5 , 7 ) <nl> - <nl> - Inside Point : : __destruct , ( 5 , 7 ) , point count = 0 <nl> - <nl> Done <nl> mmmmmmmmmmmmmmm - - byRef returning of handle types mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 5 , 7 ) , point count = 1 <nl> - <nl> After ' new Point ( 5 , 7 ) ' , $ b is ( 5 , 7 ) <nl> After ' $ a = f2 ( ) ' , $ a is ( 5 , 7 ) <nl> - <nl> - Inside Point : : __destruct , ( 5 , 7 ) , point count = 0 <nl> - <nl> Done <nl> mmmmmmmmmmmmmmm - - unsetting properties mmmmmmmmmmmmmmmmmmmmm - <nl> at start , $ c is object ( C ) # % d ( 2 ) { <nl> after unset ( $ c - > prop1 ) , $ c is object ( C ) # % d ( 1 ) { <nl> } <nl> after unset ( $ c - > prop2 ) , $ c is object ( C ) # % d ( 0 ) { <nl> } <nl> - <nl> - Inside C : : __destruct <nl> - <nl> after unset ( $ c ) , $ c is undefined <nl> Done <nl> mmm a / hphp / test / slow / spec / tests / basic_concepts / storage_duration . php <nl> ppp b / hphp / test / slow / spec / tests / basic_concepts / storage_duration . php <nl> <nl> <nl> class Point <nl> { <nl> - private static $ pointCount = 0 ; <nl> - <nl> private $ x ; <nl> private $ y ; <nl> <nl> - public static function getPointCount ( ) <nl> - { <nl> - return self : : $ pointCount ; <nl> - } <nl> - <nl> public function __construct ( $ x = 0 , $ y = 0 ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> } <nl> <nl> public function move ( $ x , $ y ) <nl> public function translate ( $ x , $ y ) <nl> $ this - > y + = $ y ; <nl> } <nl> <nl> - public function __destruct ( ) <nl> - { <nl> - - - self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> - } <nl> - / / / * <nl> - public function __clone ( ) <nl> - { <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> - } <nl> - / / * / <nl> - <nl> public function __toString ( ) <nl> { <nl> return ' ( ' . $ this - > x . ' , ' . $ this - > y . ' ) ' ; <nl> mmm a / hphp / test / slow / spec / tests / basic_concepts / storage_duration . php . expectf <nl> ppp b / hphp / test / slow / spec / tests / basic_concepts / storage_duration . php . expectf <nl> <nl> mmmmmmmmmmmmmmm - start mmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 0 , 1 ) , point count = 1 <nl> - <nl> mmmmmmmmmmmmmmm - after $ av1 init mmmmmmmmmmmmmmmmmm - <nl> mmmmmmmmmmmmmmm - after $ sv1 decl mmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 0 , 2 ) , point count = 2 <nl> - <nl> mmmmmmmmmmmmmmm - after $ sv1 init mmmmmmmmmmmmmmmmmm - <nl> mmmmmmmmmmmmmmm - Inside function_A mmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 1 , 1 ) , point count = 3 <nl> - <nl> mmmmmmmmmmmmmmm - after $ av2 init mmmmmmmmmmmmmmmmmm - <nl> mmmmmmmmmmmmmmm - after $ sv2 decl mmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 1 , 2 ) , point count = 4 <nl> - <nl> mmmmmmmmmmmmmmm - after $ sv2 init mmmmmmmmmmmmmmmmmm - <nl> mmmmmmmmmmmmmmm - Inside if TRUE mmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 2 , 1 ) , point count = 5 <nl> - <nl> mmmmmmmmmmmmmmm - after $ av3 init mmmmmmmmmmmmmmmmmm - <nl> mmmmmmmmmmmmmmm - after $ sv3 decl mmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 2 , 2 ) , point count = 6 <nl> - <nl> mmmmmmmmmmmmmmm - after $ sv3 init mmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 2 , 3 ) , point count = 7 <nl> - <nl> mmmmmmmmmmmmmmm - after $ av1 reinit mmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __destruct , ( % d , % d ) , point count = 6 <nl> - <nl> - <nl> - Inside Point : : __destruct , ( % d , % d ) , point count = 5 <nl> - <nl> - <nl> - Inside Point : : __destruct , ( % d , % d ) , point count = 4 <nl> - <nl> mmmmmmmmmmmmmmm - after call to func mmmmmmmmmmmmmmmmmm - <nl> $ result = 3628800 <nl> mmmmmmmmmmmmmmm - end mmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __destruct , ( % d , % d ) , point count = 3 <nl> - <nl> - <nl> - Inside Point : : __destruct , ( % d , % d ) , point count = 2 <nl> - <nl> - <nl> - Inside Point : : __destruct , ( % d , % d ) , point count = 1 <nl> - <nl> - <nl> - Inside Point : : __destruct , ( % d , % d ) , point count = 0 <nl> mmm a / hphp / test / slow / spec / tests / classes / Point2 . inc <nl> ppp b / hphp / test / slow / spec / tests / classes / Point2 . inc <nl> <nl> <nl> error_reporting ( - 1 ) ; <nl> <nl> - class Point2 <nl> + class Point2 <nl> { <nl> - private static $ pointCount = 0 ; <nl> - <nl> public $ x ; / / Cartesian x - coordinate <nl> public $ y ; / / Cartesian y - coordinate <nl> <nl> - public static function getPointCount ( ) <nl> - { <nl> - return self : : $ pointCount ; <nl> - } <nl> - <nl> - public function __construct ( $ x = 0 , $ y = 0 ) <nl> + public function __construct ( $ x = 0 , $ y = 0 ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - + + self : : $ pointCount ; <nl> } <nl> <nl> - public function __destruct ( ) <nl> - { <nl> - - - self : : $ pointCount ; <nl> - } <nl> - / / / * <nl> - public function __clone ( ) <nl> - { <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " Inside " . __METHOD__ . " , point count = " . self : : $ pointCount . " \ n " ; <nl> - <nl> - / / return 999 ; / / ignored ; not passed along as the result of ' clone ' <nl> - <nl> - } <nl> - / / * / <nl> - <nl> - public function __toString ( ) <nl> + public function __toString ( ) <nl> { <nl> <nl> return ' ( ' . $ this - > x . ' , ' . $ this - > y . ' ) ' ; <nl> - } <nl> + } <nl> } <nl> mmm a / hphp / test / slow / spec / tests / classes / cloning . php <nl> ppp b / hphp / test / slow / spec / tests / classes / cloning . php <nl> public function __clone ( ) <nl> <nl> include_once ' Point2 . inc ' ; <nl> <nl> - echo " Point count = " . Point2 : : getPointCount ( ) . " \ n " ; <nl> $ p1 = new Point2 ; <nl> var_dump ( $ p1 ) ; <nl> - echo " Point count = " . Point2 : : getPointCount ( ) . " \ n " ; <nl> $ p2 = clone $ p1 ; <nl> var_dump ( $ p2 ) ; <nl> - echo " Point count = " . Point2 : : getPointCount ( ) . " \ n " ; <nl> <nl> var_dump ( $ p3 = clone $ p1 ) ; <nl> - echo " Point count = " . Point2 : : getPointCount ( ) . " \ n " ; <nl> <nl> var_dump ( $ p4 = clone $ p1 ) ; <nl> - echo " Point count = " . Point2 : : getPointCount ( ) . " \ n " ; <nl> <nl> echo " = = = = = = = = = = = = = = = = = use chained cloning in a class heirarchy = = = = = = = = = = = = = = = = = \ n " ; <nl> <nl> mmm a / hphp / test / slow / spec / tests / classes / cloning . php . expectf <nl> ppp b / hphp / test / slow / spec / tests / classes / cloning . php . expectf <nl> object ( C ) # 2 ( 1 ) { <nl> int ( 10 ) <nl> } <nl> = = = = = = = = = = = = = = = = = Use cloning in Point class = = = = = = = = = = = = = = = = = <nl> - Point count = 0 <nl> object ( Point2 ) # 3 ( 2 ) { <nl> [ " x " ] = > <nl> int ( 0 ) <nl> [ " y " ] = > <nl> int ( 0 ) <nl> } <nl> - Point count = 1 <nl> - Inside Point2 : : __clone , point count = 2 <nl> object ( Point2 ) # 4 ( 2 ) { <nl> [ " x " ] = > <nl> int ( 0 ) <nl> [ " y " ] = > <nl> int ( 0 ) <nl> } <nl> - Point count = 2 <nl> - Inside Point2 : : __clone , point count = 3 <nl> object ( Point2 ) # 5 ( 2 ) { <nl> [ " x " ] = > <nl> int ( 0 ) <nl> [ " y " ] = > <nl> int ( 0 ) <nl> } <nl> - Point count = 3 <nl> - Inside Point2 : : __clone , point count = 4 <nl> object ( Point2 ) # 6 ( 2 ) { <nl> [ " x " ] = > <nl> int ( 0 ) <nl> [ " y " ] = > <nl> int ( 0 ) <nl> } <nl> - Point count = 4 <nl> = = = = = = = = = = = = = = = = = use chained cloning in a class heirarchy = = = = = = = = = = = = = = = = = <nl> object ( Manager ) # 7 ( 2 ) { <nl> [ " level " : " Manager " : private ] = > <nl> deleted file mode 100644 <nl> index 9f9499fd47d . . 00000000000 <nl> mmm a / hphp / test / slow / spec / tests / classes / destructors . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - / * <nl> - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> - | Copyright ( c ) 2015 Facebook , Inc . ( http : / / www . facebook . com ) | <nl> - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> - * / <nl> - <nl> - error_reporting ( - 1 ) ; <nl> - <nl> - class D1 <nl> - { <nl> - / / private function __destruct ( ) <nl> - public function __destruct ( ) <nl> - / / protected function __destruct ( ) <nl> - { <nl> - echo " In D1 destructor \ n " ; <nl> - <nl> - / / return ; <nl> - $ v = 123 ; <nl> - return $ v ; / / PHP5 does not diagnose this , and it works ! ! <nl> - } <nl> - } <nl> - <nl> - class D2 extends D1 <nl> - { <nl> - / / / * <nl> - / / protected function __destruct ( ) / / Access level to D2 : : __destruct ( ) must be public <nl> - public function __destruct ( ) <nl> - { <nl> - echo " In D2 destructor \ n " ; <nl> - / / exit ( ) ; <nl> - $ v = parent : : __destruct ( ) ; <nl> - var_dump ( $ v ) ; / / I see the 123 returned ! ! <nl> - <nl> - / / return ; <nl> - / / return 123 ; / / PHP5 does not diagnose this <nl> - } <nl> - / / * / <nl> - } <nl> - <nl> - class D3 extends D2 <nl> - { <nl> - / / / * <nl> - public function __destruct ( ) <nl> - { <nl> - / / parent : : __destruct ( ) ; <nl> - echo " In D3 destructor \ n " ; <nl> - parent : : __destruct ( ) ; <nl> - } <nl> - / / * / <nl> - } <nl> - <nl> - class D4 extends D3 <nl> - { <nl> - / / / * <nl> - public function __destruct ( ) <nl> - { <nl> - echo " In D4 destructor \ n " ; <nl> - parent : : __destruct ( ) ; <nl> - } <nl> - / / * / <nl> - } <nl> - <nl> - / / $ d1 = new D1 ; <nl> - / / $ d2 = new D2 ; <nl> - / / $ d3 = new D3 ; <nl> - $ d4 = new D4 ; <nl> deleted file mode 100644 <nl> index eddc61875d2 . . 00000000000 <nl> mmm a / hphp / test / slow / spec / tests / classes / destructors . php . expectf <nl> ppp / dev / null <nl> <nl> - % AIn D4 destructor <nl> - In D3 destructor <nl> - In D2 destructor <nl> - In D1 destructor <nl> - int ( 123 ) <nl> mmm a / hphp / test / slow / spec / tests / classes / dynamic_properties . php <nl> ppp b / hphp / test / slow / spec / tests / classes / dynamic_properties . php <nl> public function __unset ( $ name ) <nl> <nl> class X <nl> { <nl> - public function __destruct ( ) <nl> - { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> } <nl> <nl> / / / * <nl> mmm a / hphp / test / slow / spec / tests / classes / dynamic_properties . php . expect <nl> ppp b / hphp / test / slow / spec / tests / classes / dynamic_properties . php . expect <nl> key p8 has a value of 999 <nl> key p9 has a value of 999 <nl> key p10 has a value of 999 <nl> mmmmmmmmmmmmmmmmmmmmm - <nl> - X : : __destruct <nl> mmm a / hphp / test / slow / spec / tests / classes / overloading . php <nl> ppp b / hphp / test / slow / spec / tests / classes / overloading . php <nl> public function __unset ( $ name ) <nl> <nl> class X <nl> { <nl> - public function __destruct ( ) <nl> - { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> } <nl> <nl> / / / * <nl> mmm a / hphp / test / slow / spec / tests / classes / overloading . php . expect <nl> ppp b / hphp / test / slow / spec / tests / classes / overloading . php . expect <nl> Point : : __set ( thing , xx ) <nl> Point : : __get ( thing ) <nl> object ( X ) # 2 ( 0 ) { <nl> } <nl> - X : : __destruct <nl> mmm a / hphp / test / slow / spec / tests / classes / overloading_properties . php <nl> ppp b / hphp / test / slow / spec / tests / classes / overloading_properties . php <nl> public function __unset ( $ name ) <nl> <nl> class X <nl> { <nl> - public function __destruct ( ) <nl> - { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> } <nl> <nl> / / / * <nl> mmm a / hphp / test / slow / spec / tests / classes / overloading_properties . php . expect <nl> ppp b / hphp / test / slow / spec / tests / classes / overloading_properties . php . expect <nl> Point : : __set ( thing , xx ) <nl> Point : : __get ( thing ) <nl> object ( X ) # 2 ( 0 ) { <nl> } <nl> - X : : __destruct <nl> deleted file mode 100644 <nl> index 257143b3f23 . . 00000000000 <nl> mmm a / hphp / test / slow / spec / tests / classes / point2_test1 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - / * <nl> - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> - | Copyright ( c ) 2015 Facebook , Inc . ( http : / / www . facebook . com ) | <nl> - + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> - * / <nl> - <nl> - error_reporting ( - 1 ) ; <nl> - <nl> - include_once ' Point2 . inc ' ; <nl> - <nl> - $ p1 = new Point2 ; <nl> - $ p2 = new Point2 ( - 4 , 3 ) ; <nl> - $ p3 = new Point2 ( 20 , 30 ) ; <nl> - <nl> - echo " Point count = " . Point2 : : getPointCount ( ) . " \ n " ; <nl> - $ cName = ' Point2 ' ; <nl> - echo " Point count = " . $ cName : : getPointCount ( ) . " \ n " ; <nl> deleted file mode 100644 <nl> index 27e323c71cb . . 00000000000 <nl> mmm a / hphp / test / slow / spec / tests / classes / point2_test1 . php . expect <nl> ppp / dev / null <nl> <nl> - Point count = 3 <nl> - Point count = 3 <nl> mmm a / hphp / test / slow / spec / tests / classes / setting_state . php <nl> ppp b / hphp / test / slow / spec / tests / classes / setting_state . php <nl> <nl> <nl> class Point <nl> { <nl> - private static $ pointCount = 0 ; <nl> - <nl> private $ x ; <nl> private $ y ; <nl> const CON = 10 ; <nl> class Point <nl> protected $ proti ; <nl> public $ pubi ; <nl> <nl> - public static function getPointCount ( ) <nl> - { <nl> - return self : : $ pointCount ; <nl> - } <nl> - <nl> public function __construct ( $ x = 0 , $ y = 0 ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> } <nl> <nl> public function move ( $ x , $ y ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - } <nl> + } <nl> <nl> public function translate ( $ x , $ y ) <nl> { <nl> public function translate ( $ x , $ y ) <nl> $ this - > y + = $ y ; <nl> } <nl> <nl> - public function __destruct ( ) <nl> - { <nl> - - - self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> - } <nl> - / / / * <nl> - public function __clone ( ) <nl> - { <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> - } <nl> - / / * / <nl> - <nl> public function __toString ( ) <nl> { <nl> return ' ( ' . $ this - > x . ' , ' . $ this - > y . ' ) ' ; <nl> - } <nl> + } <nl> / / / * <nl> static public function __set_state ( array $ properties ) <nl> { <nl> mmm a / hphp / test / slow / spec / tests / classes / setting_state . php . expectf <nl> ppp b / hphp / test / slow / spec / tests / classes / setting_state . php . expectf <nl> <nl> mmmmmmmmmmmmmmm - start mmmmmmmmmmmmmmmmmm - <nl> - <nl> - Inside Point : : __construct , ( 3 , 5 ) , point count = 1 <nl> - <nl> mmmmmmmmmmmmmmm - calling var_export mmmmmmmmmmmmmmmmmm - <nl> string ( % d ) " Point : : __set_state ( array ( <nl> % w ' x ' = > 3 , <nl> array ( 4 ) { <nl> [ " pubi " ] = > <nl> NULL <nl> } <nl> - <nl> - Inside Point : : __construct , ( 0 , 0 ) , point count = 2 <nl> - <nl> object ( Point ) # 2 ( 4 ) { <nl> [ " x " : " Point " : private ] = > <nl> int ( 3 ) <nl> object ( Point ) # 2 ( 4 ) { <nl> NULL <nl> } <nl> Point $ z is ( 3 , 5 ) <nl> - <nl> - Inside Point : : __destruct , ( 3 , 5 ) , point count = 1 <nl> - <nl> - <nl> - Inside Point : : __destruct , ( 3 , 5 ) , point count = 0 <nl> - <nl> mmmmmmmmmmmmmmm - test with inheritance mmmmmmmmmmmmmmmmmm - <nl> mmmmmmmmmmmmmmm - test with type B mmmmmmmmmmmmmmmmmm - <nl> string ( % d ) " B : : __set_state ( array ( <nl> mmm a / hphp / test / slow / spec / tests / classes / sleep_and_wakeup . php <nl> ppp b / hphp / test / slow / spec / tests / classes / sleep_and_wakeup . php <nl> class Point <nl> / / const CON = 10 ; / / excluded from serialization <nl> / / protected static $ prots ; / / excluded from serialization <nl> <nl> - public static function getPointCount ( ) <nl> - { <nl> - return self : : $ pointCount ; <nl> - } <nl> - <nl> public function __construct ( $ x = 0 , $ y = 0 ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - + + self : : $ pointCount ; <nl> $ this - > id = self : : $ nextId + + ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> } <nl> <nl> public function move ( $ x , $ y ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - } <nl> + } <nl> <nl> public function translate ( $ x , $ y ) <nl> { <nl> public function translate ( $ x , $ y ) <nl> $ this - > y + = $ y ; <nl> } <nl> <nl> - public function __destruct ( ) <nl> - { <nl> - - - self : : $ pointCount ; <nl> - <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> - } <nl> - <nl> public function __toString ( ) <nl> { <nl> return ' ID : ' . $ this - > id . ' ( ' . $ this - > x . ' , ' . $ this - > y . ' ) ' ; <nl> - } <nl> + } <nl> / / / * <nl> public function __sleep ( ) <nl> { <nl> - echo " \ nInside " . __METHOD__ . " , $ this , point count = " . self : : $ pointCount . " \ n \ n " ; <nl> - <nl> / / return array ( ' y ' , ' x ' , ' proti ' , ' pubi ' ) ; <nl> return array ( ' y ' , ' x ' ) ; / / get serialized in array insertion order <nl> / / return array ( ' y ' ) ; <nl> public function __sleep ( ) <nl> / / / * <nl> public function __wakeup ( ) <nl> { <nl> - echo " \ nInside " . __METHOD__ . " , $ this , \ $ nextId , = " . self : : $ nextId . " \ n \ n " ; <nl> - <nl> - + + self : : $ pointCount ; <nl> $ this - > id = self : : $ nextId + + ; <nl> } <nl> / / * / <nl> public function __construct ( $ x = 0 , $ y = 0 , $ color = RED ) <nl> public function __toString ( ) <nl> { <nl> return parent : : __toString ( ) . $ this - > color ; <nl> - } <nl> + } <nl> <nl> / / while this method returns an array containing the names of the two inherited , private <nl> / / properties and adds to that the one private property from the current class , <nl> public function __toString ( ) <nl> public function __sleep ( ) <nl> { <nl> echo " \ nInside " . __METHOD__ . " , $ this \ n \ n " ; <nl> - <nl> + <nl> $ a = parent : : __sleep ( ) ; <nl> var_dump ( $ a ) ; <nl> $ a [ ] = ' color ' ; <nl> mmm a / hphp / test / slow / spec / tests / classes / visibility . php <nl> ppp b / hphp / test / slow / spec / tests / classes / visibility . php <nl> class C <nl> / / private static var $ vsprop4 ; <nl> <nl> / / methods <nl> - <nl> + <nl> function f1 ( ) { } <nl> public function f2 ( ) { } <nl> protected function f3 ( ) { } <nl> static protected function sf3 ( ) { } / / visibility and static ordering unimportan <nl> private static function sf4 ( ) { } <nl> <nl> / / constructors <nl> - <nl> + <nl> function __construct ( ) { } / / OK on its own ; implicitly public <nl> / / public function __construct ( ) { } / / OK on its own <nl> / / protected function __construct ( ) { } / / OK on its own <nl> function __construct ( ) { } / / OK on its own ; implicitly public <nl> / / public static function __construct ( ) { } <nl> / / protected static function __construct ( ) { } <nl> / / private static function __construct ( ) { } <nl> - <nl> - / / destructors <nl> - <nl> - function __destruct ( ) { } / / OK on its own ; implicitly public <nl> - / / public function __destruct ( ) { } / / OK on its own <nl> - / / protected function __destruct ( ) { } / / OK on its own <nl> - / / private function __destruct ( ) { } / / OK on its own <nl> - <nl> - / / static function __destruct ( ) { } / / destructors can ' t be static <nl> - / / public static function __destruct ( ) { } <nl> - / / protected static function __destruct ( ) { } <nl> - / / private static function __destruct ( ) { } <nl> } <nl> <nl> echo " CON1 : " . C : : CON1 . " \ n " ; / / use : : notation , as a const is implicitly static <nl> mmm a / hphp / test / slow / spec / tests / constants / core_predefined_constants . php <nl> ppp b / hphp / test / slow / spec / tests / constants / core_predefined_constants . php <nl> public function __construct ( ) <nl> / / . . . <nl> } <nl> <nl> - function __destruct ( ) <nl> - { <nl> - echo " Inside " . __METHOD__ . " \ n " ; <nl> - trace ( " __FUNCTION__ " , __FUNCTION__ ) ; <nl> - <nl> - / / . . . <nl> - } <nl> - <nl> public function setDay ( $ day ) <nl> { <nl> echo " Inside " . __METHOD__ . " \ n " ; <nl> mmm a / hphp / test / slow / spec / tests / constants / core_predefined_constants . php . expectf <nl> ppp b / hphp / test / slow / spec / tests / constants / core_predefined_constants . php . expectf <nl> __TRAIT__ : string ( 0 ) " " <nl> __NAMESPACE__ : string ( 0 ) " " <nl> Inside Date : : setDay <nl> __FUNCTION__ : string ( 6 ) " setDay " <nl> - __LINE__ : int ( 98 ) <nl> + __LINE__ : int ( 90 ) <nl> Inside Date : : priv1 <nl> __FUNCTION__ : string ( 5 ) " priv1 " <nl> Inside Date : : spf1 <nl> __FUNCTION__ : string ( 2 ) " xx " <nl> Inside includefile . php <nl> string ( % d ) " % s / constants / includefile . inc " <nl> string ( % d ) " % s / constants " <nl> - Inside Date : : __destruct <nl> - __FUNCTION__ : string ( 10 ) " __destruct " <nl> - Inside Date : : __destruct <nl> - __FUNCTION__ : string ( 10 ) " __destruct " <nl> mmm a / hphp / test / slow / spec / tests / expressions / primary_expressions / Point2 . inc <nl> ppp b / hphp / test / slow / spec / tests / expressions / primary_expressions / Point2 . inc <nl> <nl> <nl> error_reporting ( - 1 ) ; <nl> <nl> - class Point2 <nl> + class Point2 <nl> { <nl> - private static $ pointCount = 0 ; <nl> - <nl> public $ x ; / / Cartesian x - coordinate <nl> public $ y ; / / Cartesian y - coordinate <nl> <nl> - public static function getPointCount ( ) <nl> - { <nl> - return self : : $ pointCount ; <nl> - } <nl> - <nl> - public function __construct ( $ x = 0 , $ y = 0 ) <nl> + public function __construct ( $ x = 0 , $ y = 0 ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - + + self : : $ pointCount ; <nl> } <nl> <nl> - public function __destruct ( ) <nl> - { <nl> - - - self : : $ pointCount ; <nl> - } <nl> - / / / * <nl> - public function __clone ( ) <nl> - { <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " Inside " . __METHOD__ . " , point count = " . self : : $ pointCount . " \ n " ; <nl> - <nl> - / / return 999 ; / / ignored ; not passed along as the result of ' clone ' <nl> - <nl> - } <nl> - / / * / <nl> - <nl> - public function __toString ( ) <nl> + public function __toString ( ) <nl> { <nl> <nl> return ' ( ' . $ this - > x . ' , ' . $ this - > y . ' ) ' ; <nl> - } <nl> + } <nl> } <nl> mmm a / hphp / test / slow / spec / tests / lexical_structure / tokens / point2 . php <nl> ppp b / hphp / test / slow / spec / tests / lexical_structure / tokens / point2 . php <nl> <nl> <nl> class Point2 <nl> { <nl> - private static $ pointCount = 0 ; <nl> - <nl> public $ x ; <nl> public $ y ; <nl> <nl> - public static function getPointCount ( ) <nl> - { <nl> - return self : : $ pointCount ; <nl> - } <nl> - <nl> public function __construct ( $ x = 0 , $ y = 0 ) <nl> { <nl> / / echo " Inside " . __METHOD__ . " \ n " ; <nl> - <nl> + <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - + + self : : $ pointCount ; <nl> - } <nl> - <nl> - public function __destruct ( ) <nl> - { <nl> - - - self : : $ pointCount ; <nl> - <nl> - echo " Inside " . __METHOD__ . " , pointCount now " . $ this - > getPointCount ( ) . " \ n " ; <nl> - } <nl> - <nl> - public function __clone ( ) <nl> - { <nl> - + + self : : $ pointCount ; <nl> - <nl> - echo " Inside " . __METHOD__ . " , point count = " . self : : $ pointCount . " \ n " ; <nl> } <nl> <nl> public function __toString ( ) <nl> { <nl> return ' ( ' . $ this - > x . ' , ' . $ this - > y . ' ) ' ; <nl> - } <nl> + } <nl> } <nl> mmm a / hphp / test / slow / spec / tests / serialization / Point . inc <nl> ppp b / hphp / test / slow / spec / tests / serialization / Point . inc <nl> <nl> <nl> error_reporting ( - 1 ) ; <nl> <nl> - class Point implements Serializable <nl> + class Point implements Serializable <nl> { <nl> - private static $ pointCount = 0 ; <nl> - <nl> public $ x ; <nl> public $ y ; <nl> <nl> - public static function getPointCount ( ) <nl> - { <nl> - return self : : $ pointCount ; <nl> - } <nl> - <nl> - public function __construct ( $ x = 0 , $ y = 0 ) <nl> + public function __construct ( $ x = 0 , $ y = 0 ) <nl> { <nl> $ this - > x = $ x ; <nl> $ this - > y = $ y ; <nl> - + + self : : $ pointCount ; <nl> - } <nl> - <nl> - public function __destruct ( ) <nl> - { <nl> - - - self : : $ pointCount ; <nl> - } <nl> - / / / * <nl> - public function __clone ( ) <nl> - { <nl> - + + self : : $ pointCount ; <nl> - <nl> - / / echo " Inside " . __METHOD__ . " , point count = " . self : : $ pointCount . " \ n " ; <nl> } <nl> - / / * / <nl> <nl> - public function __toString ( ) <nl> + public function __toString ( ) <nl> { <nl> return ' ( ' . $ this - > x . ' , ' . $ this - > y . ' ) ' ; <nl> } <nl> mmm a / hphp / test / slow / streams / stream_wrapper_register . php <nl> ppp b / hphp / test / slow / streams / stream_wrapper_register . php <nl> function __construct ( ) { <nl> return true ; <nl> } <nl> <nl> - function __destruct ( ) { <nl> - var_dump ( __FUNCTION__ ) ; <nl> - var_dump ( func_get_args ( ) ) ; <nl> - return true ; <nl> - } <nl> - <nl> public function dir_closedir ( ) { <nl> var_dump ( __FUNCTION__ ) ; <nl> var_dump ( func_get_args ( ) ) ; <nl> mmm a / hphp / test / slow / streams / stream_wrapper_register . php . expectf <nl> ppp b / hphp / test / slow / streams / stream_wrapper_register . php . expectf <nl> array ( 3 ) { <nl> [ 2 ] = > <nl> int ( 83 ) <nl> } <nl> - string ( 10 ) " __destruct " <nl> - array ( 0 ) { <nl> - } <nl> string ( 11 ) " __construct " <nl> array ( 0 ) { <nl> } <nl> array ( 1 ) { <nl> [ 0 ] = > <nl> string ( 7 ) " abc : / / d " <nl> } <nl> - string ( 10 ) " __destruct " <nl> - array ( 0 ) { <nl> - } <nl> string ( 11 ) " __construct " <nl> array ( 0 ) { <nl> } <nl> array ( 2 ) { <nl> [ 1 ] = > <nl> int ( 2 ) <nl> } <nl> - string ( 10 ) " __destruct " <nl> - array ( 0 ) { <nl> - } <nl> string ( 11 ) " __construct " <nl> array ( 0 ) { <nl> } <nl> array ( 2 ) { <nl> [ 1 ] = > <nl> int ( 1 ) <nl> } <nl> - string ( 10 ) " __destruct " <nl> - array ( 0 ) { <nl> - } <nl> string ( 11 ) " __construct " <nl> array ( 0 ) { <nl> } <nl> array ( 3 ) { <nl> array ( 0 ) { <nl> } <nl> } <nl> - string ( 10 ) " __destruct " <nl> - array ( 0 ) { <nl> - } <nl> string ( 11 ) " __construct " <nl> array ( 0 ) { <nl> } <nl> array ( 3 ) { <nl> int ( 15 ) <nl> } <nl> } <nl> - string ( 10 ) " __destruct " <nl> - array ( 0 ) { <nl> - } <nl> string ( 11 ) " __construct " <nl> array ( 0 ) { <nl> } <nl> array ( 3 ) { <nl> int ( 25 ) <nl> } <nl> } <nl> - string ( 10 ) " __destruct " <nl> - array ( 0 ) { <nl> - } <nl> string ( 11 ) " __construct " <nl> array ( 0 ) { <nl> } <nl> array ( 3 ) { <nl> [ 2 ] = > <nl> int ( 1 ) <nl> } <nl> - string ( 10 ) " __destruct " <nl> - array ( 0 ) { <nl> - } <nl> string ( 11 ) " __construct " <nl> array ( 0 ) { <nl> } <nl> array ( 2 ) { <nl> [ 1 ] = > <nl> int ( 0 ) <nl> } <nl> - string ( 10 ) " __destruct " <nl> - array ( 0 ) { <nl> - } <nl> string ( 11 ) " __construct " <nl> array ( 0 ) { <nl> } <nl> array ( 2 ) { <nl> [ 1 ] = > <nl> string ( 10 ) " abc : / / dir2 " <nl> } <nl> - string ( 10 ) " __destruct " <nl> - array ( 0 ) { <nl> - } <nl> mmm a / hphp / test / slow / traits / 1998 . php <nl> ppp b / hphp / test / slow / traits / 1998 . php <nl> <nl> <nl> trait Test { <nl> public function __construct ( ) { <nl> - } <nl> - public function __destruct ( ) { <nl> } <nl> public function func ( ) { <nl> } <nl> public function func ( ) { <nl> < < __EntryPoint > > <nl> function main_1998 ( ) { <nl> $ rconstr = new ReflectionMethod ( ' Test : : __construct ' ) ; <nl> - $ rdestr = new ReflectionMethod ( ' Test : : __destruct ' ) ; <nl> $ rfunc = new ReflectionMethod ( ' Test : : func ' ) ; <nl> var_dump ( $ rconstr - > isConstructor ( ) ) ; <nl> - var_dump ( $ rconstr - > isDestructor ( ) ) ; <nl> - var_dump ( $ rdestr - > isConstructor ( ) ) ; <nl> - var_dump ( $ rdestr - > isDestructor ( ) ) ; <nl> var_dump ( $ rfunc - > isConstructor ( ) ) ; <nl> - var_dump ( $ rfunc - > isDestructor ( ) ) ; <nl> } <nl> mmm a / hphp / test / slow / traits / 1998 . php . expect <nl> ppp b / hphp / test / slow / traits / 1998 . php . expect <nl> <nl> bool ( true ) <nl> bool ( false ) <nl> - bool ( false ) <nl> - bool ( true ) <nl> - bool ( false ) <nl> - bool ( false ) <nl> mmm a / hphp / test / slow / traits / 2011 . php <nl> ppp b / hphp / test / slow / traits / 2011 . php <nl> <nl> < ? php <nl> <nl> trait foo { <nl> - <nl> public function __construct ( ) { <nl> var_dump ( __FUNCTION__ ) ; <nl> } <nl> - public function __destruct ( ) { <nl> - var_dump ( __FUNCTION__ ) ; <nl> - } <nl> } <nl> <nl> class bar { <nl> mmm a / hphp / test / slow / traits / 2011 . php . expect <nl> ppp b / hphp / test / slow / traits / 2011 . php . expect <nl> @ @ - 1 , 2 + 1 @ @ <nl> string ( 11 ) " __construct " <nl> - string ( 10 ) " __destruct " <nl> mmm a / hphp / test / slow / u_converter / 2135 . php <nl> ppp b / hphp / test / slow / u_converter / 2135 . php <nl> <nl> - < ? php <nl> + < ? hh <nl> <nl> class MyConverter extends UConverter { <nl> public function toUCallback ( $ reason , $ source , $ codeUnits , & $ error ) { <nl> public function fromUCallback ( $ reason , $ source , $ codePoint , & $ error ) { <nl> } <nl> <nl> function main ( ) { <nl> - $ c = new MyConverter ( ' ascii ' , ' utf - 8 ' ) ; <nl> - $ words = array ( <nl> - " regular " , <nl> - " irregul \ xC1 \ xA1r " , <nl> - " \ xC2 \ xA1unsupported ! " , <nl> - ) ; <nl> - foreach ( $ words as $ word ) { <nl> - $ c - > convert ( $ word ) ; <nl> + using ( $ c = new MyConverter ( ' ascii ' , ' utf - 8 ' ) ) { <nl> + $ words = array ( <nl> + " regular " , <nl> + " irregul \ xC1 \ xA1r " , <nl> + " \ xC2 \ xA1unsupported ! " , <nl> + ) ; <nl> + foreach ( $ words as $ word ) { <nl> + $ c - > convert ( $ word ) ; <nl> + } <nl> } <nl> - unset ( $ c ) ; <nl> } <nl> <nl> <nl> mmm a / hphp / test / slow / unpack_args / unpack_call . php <nl> ppp b / hphp / test / slow / unpack_args / unpack_call . php <nl> function test_call_array_equivalent_multi ( $ args ) { <nl> echo " \ n " ; <nl> } * / <nl> <nl> - class dtor { <nl> - function __destruct ( ) { <nl> - echo " dtor : : __destruct \ n " ; <nl> - } <nl> - } <nl> - <nl> function test_param_mix ( $ args ) { <nl> echo " = " , __FUNCTION__ , " = " , " \ n " ; <nl> var_dump ( $ args ) ; <nl> function test_param_mix ( $ args ) { <nl> $ prefix3 = ' arg that ensures more args passed than declared ' ; <nl> variadic ( $ prefix , $ prefix2 , $ prefix3 , . . . $ args ) ; <nl> variadic_with_func_get_args ( $ prefix , $ prefix2 , . . . $ args ) ; <nl> - variadic_with_func_get_args ( new dtor , new dtor , . . . [ new dtor ] ) ; <nl> - echo " - - after destruct \ n " ; <nl> regular ( $ prefix , $ prefix2 , . . . $ args ) ; <nl> regular ( $ prefix , $ prefix2 , . . . $ args ) ; <nl> variadic ( $ prefix , $ prefix2 , . . . $ args ) ; <nl> mmm a / hphp / test / slow / unpack_args / unpack_call . php . expect <nl> ppp b / hphp / test / slow / unpack_args / unpack_call . php . expect <nl> array ( 5 ) { <nl> [ 4 ] = > <nl> string ( 1 ) " c " <nl> } <nl> - * variadic_with_func_get_args <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - object ( dtor ) # 3 ( 0 ) { <nl> - } <nl> - [ 1 ] = > <nl> - object ( dtor ) # 4 ( 0 ) { <nl> - } <nl> - [ 2 ] = > <nl> - object ( dtor ) # 5 ( 0 ) { <nl> - } <nl> - } <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - object ( dtor ) # 3 ( 0 ) { <nl> - } <nl> - [ 1 ] = > <nl> - object ( dtor ) # 4 ( 0 ) { <nl> - } <nl> - [ 2 ] = > <nl> - object ( dtor ) # 5 ( 0 ) { <nl> - } <nl> - } <nl> - dtor : : __destruct <nl> - dtor : : __destruct <nl> - dtor : : __destruct <nl> mmm after destruct <nl> * regular <nl> string ( 16 ) " passed regularly " <nl> string ( 21 ) " also passed regularly " <nl> array ( 5 ) { <nl> [ 4 ] = > <nl> string ( 1 ) " c " <nl> } <nl> - * variadic_with_func_get_args <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - object ( dtor ) # 6 ( 0 ) { <nl> - } <nl> - [ 1 ] = > <nl> - object ( dtor ) # 7 ( 0 ) { <nl> - } <nl> - [ 2 ] = > <nl> - object ( dtor ) # 8 ( 0 ) { <nl> - } <nl> - } <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - object ( dtor ) # 6 ( 0 ) { <nl> - } <nl> - [ 1 ] = > <nl> - object ( dtor ) # 7 ( 0 ) { <nl> - } <nl> - [ 2 ] = > <nl> - object ( dtor ) # 8 ( 0 ) { <nl> - } <nl> - } <nl> - dtor : : __destruct <nl> - dtor : : __destruct <nl> - dtor : : __destruct <nl> mmm after destruct <nl> * regular <nl> string ( 16 ) " passed regularly " <nl> string ( 21 ) " also passed regularly " <nl> array ( 5 ) { <nl> string ( 1 ) " c " <nl> } <nl> <nl> - Done <nl> \ No newline at end of file <nl> + Done <nl> deleted file mode 100644 <nl> index 932576a9b04 . . 00000000000 <nl> mmm a / hphp / test / slow / unset / 1116 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class X { <nl> - function __construct ( ) { <nl> - echo ' construct <nl> - ' ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo ' destruct <nl> - ' ; <nl> - } <nl> - } <nl> - function test ( ) { <nl> - $ a = new X ; <nl> - echo ' before unset <nl> - ' ; <nl> - unset ( $ a ) ; <nl> - echo ' after unset <nl> - ' ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_1116 ( ) { <nl> - test ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 33e45ca59fa . . 00000000000 <nl> mmm a / hphp / test / slow / unset / 1116 . php . expect <nl> ppp / dev / null <nl> <nl> - construct <nl> - before unset <nl> - destruct <nl> - after unset <nl> deleted file mode 100644 <nl> index 63a57938387 . . 00000000000 <nl> mmm a / hphp / test / slow / unset / order . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class blob { <nl> - function __destruct ( ) { <nl> - echo " Running destructor \ n " ; <nl> - global $ b ; <nl> - $ b = $ this ; <nl> - } <nl> - } <nl> - <nl> - $ b = new blob ; <nl> - var_dump ( $ b ) ; <nl> - unset ( $ b ) ; <nl> - var_dump ( isset ( $ b ) ) ; <nl> - unset ( $ b ) ; <nl> - var_dump ( isset ( $ b ) ) ; <nl> deleted file mode 100644 <nl> index 8317540edc1 . . 00000000000 <nl> mmm a / hphp / test / slow / unset / order . php . expectf <nl> ppp / dev / null <nl> <nl> - object ( blob ) # 1 ( 0 ) { <nl> - } <nl> - Running destructor <nl> - bool ( true ) <nl> - bool ( false ) <nl> deleted file mode 100644 <nl> index 0bba0618e46 . . 00000000000 <nl> mmm a / hphp / test / slow / useless_assignment / 1739 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class MyDestructableClass { <nl> - function __construct ( ) { <nl> - print " In constructor \ n " ; <nl> - $ this - > name = " MyDestructableClass " ; <nl> - } <nl> - function __destruct ( ) { <nl> - print " Destroying " . $ this - > name . " \ n " ; <nl> - } <nl> - } <nl> - function foo ( $ a ) { <nl> - if ( $ a ) return new MyDestructableClass ( ) ; <nl> - return false ; <nl> - } <nl> - function bar ( $ a ) { <nl> - if ( $ a ) { <nl> - $ obj = foo ( 1 ) ; <nl> - $ obj = 1 ; <nl> - var_dump ( 2 ) ; <nl> - } <nl> - var_dump ( 1 ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_1739 ( ) { <nl> - bar ( 1 ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 8660b017b63 . . 00000000000 <nl> mmm a / hphp / test / slow / useless_assignment / 1739 . php . expect <nl> ppp / dev / null <nl> <nl> - In constructor <nl> - Destroying MyDestructableClass <nl> - int ( 2 ) <nl> - int ( 1 ) <nl> deleted file mode 100644 <nl> index 946e48868cf . . 00000000000 <nl> mmm a / hphp / test / slow / useless_assignment / 1742 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class A { <nl> - function __destruct ( ) { <nl> - var_dump ( ' done ' ) ; <nl> - } <nl> - } <nl> - function foo ( ) { <nl> - $ a = 10 ; <nl> - if ( $ a = = 11 ) { <nl> - return null ; <nl> - } <nl> - return new A ( ) ; <nl> - } <nl> - function bar ( ) { <nl> - $ a = foo ( ) ; <nl> - var_dump ( ' doing ' ) ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_1742 ( ) { <nl> - bar ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 159cba0f5a2 . . 00000000000 <nl> mmm a / hphp / test / slow / useless_assignment / 1742 . php . expect <nl> ppp / dev / null <nl> <nl> - string ( 5 ) " doing " <nl> - string ( 4 ) " done " <nl> mmm a / hphp / test / slow / variable_argument / 25 . php <nl> ppp b / hphp / test / slow / variable_argument / 25 . php <nl> <nl> < ? php <nl> <nl> class Y { <nl> - function __destruct ( ) { <nl> - } <nl> } <nl> ; <nl> class X extends Y { <nl> function __get ( $ a ) { <nl> var_dump ( func_num_args ( ) ) ; <nl> return 42 ; <nl> } <nl> - function __destruct ( ) { <nl> - var_dump ( func_get_args ( ) ) ; <nl> - var_dump ( func_get_arg ( 0 ) ) ; <nl> - var_dump ( func_num_args ( ) ) ; <nl> - return 2442 ; <nl> - } <nl> } <nl> $ x = new X ; <nl> var_dump ( $ x - > buz ) ; <nl> mmm a / hphp / test / slow / variable_argument / 25 . php . expectf <nl> ppp b / hphp / test / slow / variable_argument / 25 . php . expectf <nl> array ( 1 ) { <nl> string ( 3 ) " buz " <nl> int ( 1 ) <nl> int ( 42 ) <nl> - array ( 0 ) { <nl> - } <nl> - <nl> - Warning : func_get_arg ( ) : Argument 0 not passed to function in % s / test / slow / variable_argument / 25 . php on line 17 <nl> - bool ( false ) <nl> - int ( 0 ) <nl> mmm a / hphp / test / slow / variable_argument / diagnostic - bug - 3336 . php . expectf <nl> ppp b / hphp / test / slow / variable_argument / diagnostic - bug - 3336 . php . expectf <nl> <nl> <nl> - Warning : foo ( ) expects at least 2 parameters , 0 given in % s on line 3 <nl> + Warning : foo ( ) expects at least 2 parameters , 0 given in % s on line % d <nl> <nl> Notice : Undefined variable : a in % s on line 4 <nl> <nl> <nl> - Warning : foo ( ) expects at least 2 parameters , 1 given in % s on line 3 <nl> + Warning : foo ( ) expects at least 2 parameters , 1 given in % s on line % d <nl> does <nl> this <nl> really <nl> work <nl> <nl> - Warning : bar ( ) expects at least 3 parameters , 0 given in % s on line 8 <nl> + Warning : bar ( ) expects at least 3 parameters , 0 given in % s on line % d <nl> <nl> Notice : Undefined variable : a in % s on line 9 <nl> <nl> <nl> - Warning : bar ( ) expects at least 3 parameters , 1 given in % s on line 8 <nl> + Warning : bar ( ) expects at least 3 parameters , 1 given in % s on line % d <nl> does <nl> <nl> - Warning : bar ( ) expects at least 3 parameters , 2 given in % s on line 8 <nl> + Warning : bar ( ) expects at least 3 parameters , 2 given in % s on line % d <nl> this <nl> really <nl> work <nl> deleted file mode 100644 <nl> index 7d2450bfae3 . . 00000000000 <nl> mmm a / hphp / test / slow / variadic_args / destructors . php <nl> ppp / dev / null <nl> <nl> - < ? php / * destructor * / <nl> - <nl> - error_reporting ( - 1 ) ; <nl> - require_once __DIR__ . ' / variadic_funcs . inc ' ; <nl> - <nl> - class HasD { <nl> - private static $ counter = 0 ; <nl> - private $ name ; <nl> - public function __construct ( $ name = ' HasD ' ) { <nl> - $ this - > name = $ name . ' ' . ( self : : $ counter + + ) ; <nl> - } <nl> - <nl> - public function __destruct ( ) { <nl> - echo __METHOD__ , ' ( ' , $ this - > name , " ) \ n " ; <nl> - } <nl> - } <nl> - <nl> - function help_catch ( Exception $ e ) { <nl> - echo get_class ( $ e ) , ' : ' , $ e - > getMessage ( ) , " \ n " ; <nl> - } <nl> - <nl> - function test_refcount ( ) { <nl> - echo ' = ' , __FUNCTION__ , ' = ' , " \ n " ; <nl> - variadic_only_no_vv ( new HasD ( ) ) ; <nl> - variadic_only_no_vv ( new HasD ( ) , new HasD ( ) ) ; <nl> - variadic_only ( new HasD ( ) ) ; <nl> - variadic_only ( new HasD ( ) , new HasD ( ) ) ; <nl> - echo " \ n " ; <nl> - <nl> - echo ' * cuf * ' , " \ n " ; <nl> - call_user_func ( ' variadic_only_no_vv ' , new HasD ( ) ) ; <nl> - call_user_func ( ' variadic_only_no_vv ' , new HasD ( ) , new HasD ( ) ) ; <nl> - <nl> - echo ' * cufa * ' , " \ n " ; <nl> - call_user_func_array ( ' variadic_only_no_vv ' , [ new HasD ( ) ] ) ; <nl> - call_user_func_array ( ' variadic_only_no_vv ' , [ new HasD ( ) , new HasD ( ) ] ) ; <nl> - call_user_func_array ( ' variadic_only ' , [ new HasD ( ) ] ) ; <nl> - call_user_func_array ( ' variadic_only ' , [ new HasD ( ) , new HasD ( ) ] ) ; <nl> - <nl> - echo " Exiting " , __FUNCTION__ , " \ n " ; <nl> - } <nl> - <nl> - function test_with_exceptions ( ) { <nl> - / / the unset ( $ e ) here is to account for the behavior of the exception <nl> - / / hanging on to arguments when arguments are included in the backtrace . <nl> - echo ' = ' , __FUNCTION__ , ' = ' , " \ n " ; <nl> - $ i1 = new HasD ( ' i1 ' ) ; $ i2 = new HasD ( ' i2 ' ) ; $ i3 = new HasD ( ' i3 ' ) ; <nl> - try { <nl> - variadic_only_no_vv_exc ( $ i1 ) ; <nl> - } catch ( Exception $ e ) { help_catch ( $ e ) ; unset ( $ e ) ; } <nl> - try { <nl> - variadic_only_no_vv_exc ( $ i2 , $ i3 ) ; <nl> - } catch ( Exception $ e ) { help_catch ( $ e ) ; unset ( $ e ) ; } <nl> - <nl> - echo ' * cuf * ' , " \ n " ; <nl> - try { <nl> - call_user_func ( ' variadic_only_no_vv_exc ' , new HasD ( ) ) ; <nl> - } catch ( Exception $ e ) { help_catch ( $ e ) ; unset ( $ e ) ; } <nl> - try { <nl> - call_user_func ( ' variadic_only_no_vv_exc ' , new HasD ( ) , new HasD ( ) ) ; <nl> - } catch ( Exception $ e ) { help_catch ( $ e ) ; unset ( $ e ) ; } <nl> - <nl> - echo ' * cufa * ' , " \ n " ; <nl> - try { <nl> - call_user_func_array ( ' variadic_only_no_vv_exc ' , [ new HasD ( ) ] ) ; <nl> - } catch ( Exception $ e ) { help_catch ( $ e ) ; unset ( $ e ) ; } <nl> - try { <nl> - call_user_func_array ( ' variadic_only_no_vv_exc ' , [ new HasD ( ) , new HasD ( ) ] ) ; <nl> - } catch ( Exception $ e ) { help_catch ( $ e ) ; unset ( $ e ) ; } <nl> - <nl> - echo " Exiting " , __FUNCTION__ , " \ n " ; <nl> - } <nl> - <nl> - function main ( ) { <nl> - test_refcount ( ) ; <nl> - test_with_exceptions ( ) ; <nl> - echo ' Done ' , " \ n " ; <nl> - } <nl> - main ( ) ; <nl> deleted file mode 100644 <nl> index 0ccc219b87b . . 00000000000 <nl> mmm a / hphp / test / slow / variadic_args / destructors . php . expect <nl> ppp / dev / null <nl> <nl> - = test_refcount = <nl> - <nl> - * variadic_only_no_vv <nl> - bool ( true ) <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 1 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 6 ) " HasD 0 " <nl> - } <nl> - } <nl> - HasD : : __destruct ( HasD 0 ) <nl> - <nl> - * variadic_only_no_vv <nl> - bool ( true ) <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 1 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 6 ) " HasD 1 " <nl> - } <nl> - [ 1 ] = > <nl> - object ( HasD ) # 2 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 6 ) " HasD 2 " <nl> - } <nl> - } <nl> - HasD : : __destruct ( HasD 1 ) <nl> - HasD : : __destruct ( HasD 2 ) <nl> - <nl> - * variadic_only <nl> - bool ( true ) <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 2 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 6 ) " HasD 3 " <nl> - } <nl> - } <nl> - bool ( true ) <nl> - bool ( true ) <nl> - HasD : : __destruct ( HasD 3 ) <nl> - <nl> - * variadic_only <nl> - bool ( true ) <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 2 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 6 ) " HasD 4 " <nl> - } <nl> - [ 1 ] = > <nl> - object ( HasD ) # 3 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 6 ) " HasD 5 " <nl> - } <nl> - } <nl> - bool ( true ) <nl> - bool ( true ) <nl> - HasD : : __destruct ( HasD 4 ) <nl> - HasD : : __destruct ( HasD 5 ) <nl> - <nl> - * cuf * <nl> - <nl> - * variadic_only_no_vv <nl> - bool ( true ) <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 3 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 6 ) " HasD 6 " <nl> - } <nl> - } <nl> - HasD : : __destruct ( HasD 6 ) <nl> - <nl> - * variadic_only_no_vv <nl> - bool ( true ) <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 3 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 6 ) " HasD 7 " <nl> - } <nl> - [ 1 ] = > <nl> - object ( HasD ) # 4 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 6 ) " HasD 8 " <nl> - } <nl> - } <nl> - HasD : : __destruct ( HasD 7 ) <nl> - HasD : : __destruct ( HasD 8 ) <nl> - * cufa * <nl> - <nl> - * variadic_only_no_vv <nl> - bool ( true ) <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 4 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 6 ) " HasD 9 " <nl> - } <nl> - } <nl> - HasD : : __destruct ( HasD 9 ) <nl> - <nl> - * variadic_only_no_vv <nl> - bool ( true ) <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 4 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 10 " <nl> - } <nl> - [ 1 ] = > <nl> - object ( HasD ) # 5 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 11 " <nl> - } <nl> - } <nl> - HasD : : __destruct ( HasD 10 ) <nl> - HasD : : __destruct ( HasD 11 ) <nl> - <nl> - * variadic_only <nl> - bool ( true ) <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 5 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 12 " <nl> - } <nl> - } <nl> - bool ( true ) <nl> - bool ( true ) <nl> - HasD : : __destruct ( HasD 12 ) <nl> - <nl> - * variadic_only <nl> - bool ( true ) <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 5 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 13 " <nl> - } <nl> - [ 1 ] = > <nl> - object ( HasD ) # 6 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 14 " <nl> - } <nl> - } <nl> - bool ( true ) <nl> - bool ( true ) <nl> - HasD : : __destruct ( HasD 13 ) <nl> - HasD : : __destruct ( HasD 14 ) <nl> - Exiting test_refcount <nl> - = test_with_exceptions = <nl> - <nl> - * variadic_only_no_vv_exc <nl> - bool ( true ) <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 6 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 5 ) " i1 15 " <nl> - } <nl> - } <nl> - variadic_only_no_vv_exc : Array <nl> - ( <nl> - [ 0 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > i1 15 <nl> - ) <nl> - <nl> - ) <nl> - test_with_exceptions : Array <nl> - ( <nl> - ) <nl> - main : Array <nl> - ( <nl> - ) <nl> - Exception : variadic_only_no_vv_exc : 1 <nl> - <nl> - * variadic_only_no_vv_exc <nl> - bool ( true ) <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 7 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 5 ) " i2 16 " <nl> - } <nl> - [ 1 ] = > <nl> - object ( HasD ) # 8 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 5 ) " i3 17 " <nl> - } <nl> - } <nl> - variadic_only_no_vv_exc : Array <nl> - ( <nl> - [ 0 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > i2 16 <nl> - ) <nl> - <nl> - [ 1 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > i3 17 <nl> - ) <nl> - <nl> - ) <nl> - test_with_exceptions : Array <nl> - ( <nl> - ) <nl> - main : Array <nl> - ( <nl> - ) <nl> - Exception : variadic_only_no_vv_exc : 2 <nl> - * cuf * <nl> - <nl> - * variadic_only_no_vv_exc <nl> - bool ( true ) <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 9 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 18 " <nl> - } <nl> - } <nl> - variadic_only_no_vv_exc : Array <nl> - ( <nl> - [ 0 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 18 <nl> - ) <nl> - <nl> - ) <nl> - call_user_func : Array <nl> - ( <nl> - [ 0 ] = > variadic_only_no_vv_exc <nl> - [ 1 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 18 <nl> - ) <nl> - <nl> - ) <nl> - test_with_exceptions : Array <nl> - ( <nl> - ) <nl> - main : Array <nl> - ( <nl> - ) <nl> - Exception : variadic_only_no_vv_exc : 1 <nl> - HasD : : __destruct ( HasD 18 ) <nl> - <nl> - * variadic_only_no_vv_exc <nl> - bool ( true ) <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 10 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 19 " <nl> - } <nl> - [ 1 ] = > <nl> - object ( HasD ) # 11 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 20 " <nl> - } <nl> - } <nl> - variadic_only_no_vv_exc : Array <nl> - ( <nl> - [ 0 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 19 <nl> - ) <nl> - <nl> - [ 1 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 20 <nl> - ) <nl> - <nl> - ) <nl> - call_user_func : Array <nl> - ( <nl> - [ 0 ] = > variadic_only_no_vv_exc <nl> - [ 1 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 19 <nl> - ) <nl> - <nl> - [ 2 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 20 <nl> - ) <nl> - <nl> - ) <nl> - test_with_exceptions : Array <nl> - ( <nl> - ) <nl> - main : Array <nl> - ( <nl> - ) <nl> - Exception : variadic_only_no_vv_exc : 2 <nl> - HasD : : __destruct ( HasD 19 ) <nl> - HasD : : __destruct ( HasD 20 ) <nl> - * cufa * <nl> - <nl> - * variadic_only_no_vv_exc <nl> - bool ( true ) <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 12 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 21 " <nl> - } <nl> - } <nl> - variadic_only_no_vv_exc : Array <nl> - ( <nl> - [ 0 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 21 <nl> - ) <nl> - <nl> - ) <nl> - call_user_func_array : Array <nl> - ( <nl> - [ 0 ] = > variadic_only_no_vv_exc <nl> - [ 1 ] = > Array <nl> - ( <nl> - [ 0 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 21 <nl> - ) <nl> - <nl> - ) <nl> - <nl> - ) <nl> - test_with_exceptions : Array <nl> - ( <nl> - ) <nl> - main : Array <nl> - ( <nl> - ) <nl> - Exception : variadic_only_no_vv_exc : 1 <nl> - HasD : : __destruct ( HasD 21 ) <nl> - <nl> - * variadic_only_no_vv_exc <nl> - bool ( true ) <nl> - array ( 2 ) { <nl> - [ 0 ] = > <nl> - object ( HasD ) # 13 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 22 " <nl> - } <nl> - [ 1 ] = > <nl> - object ( HasD ) # 14 ( 1 ) { <nl> - [ " name " : " HasD " : private ] = > <nl> - string ( 7 ) " HasD 23 " <nl> - } <nl> - } <nl> - variadic_only_no_vv_exc : Array <nl> - ( <nl> - [ 0 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 22 <nl> - ) <nl> - <nl> - [ 1 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 23 <nl> - ) <nl> - <nl> - ) <nl> - call_user_func_array : Array <nl> - ( <nl> - [ 0 ] = > variadic_only_no_vv_exc <nl> - [ 1 ] = > Array <nl> - ( <nl> - [ 0 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 22 <nl> - ) <nl> - <nl> - [ 1 ] = > HasD Object <nl> - ( <nl> - [ name : HasD : private ] = > HasD 23 <nl> - ) <nl> - <nl> - ) <nl> - <nl> - ) <nl> - test_with_exceptions : Array <nl> - ( <nl> - ) <nl> - main : Array <nl> - ( <nl> - ) <nl> - Exception : variadic_only_no_vv_exc : 2 <nl> - HasD : : __destruct ( HasD 22 ) <nl> - HasD : : __destruct ( HasD 23 ) <nl> - Exiting test_with_exceptions <nl> - HasD : : __destruct ( i3 17 ) <nl> - HasD : : __destruct ( i2 16 ) <nl> - HasD : : __destruct ( i1 15 ) <nl> - Done <nl> deleted file mode 100644 <nl> index 5e1ca4c6a6c . . 00000000000 <nl> mmm a / hphp / test / slow / variadic_args / destructors . php . hphp_opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vJitEnableRenameFunction = 1 - d hhvm . php7 . all = 0 <nl> deleted file mode 100644 <nl> index bdac6ca5f7c . . 00000000000 <nl> mmm a / hphp / test / slow / variadic_args / destructors . php . opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vEval . JitEnableRenameFunction = 1 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 4091bf228cb . . 00000000000 <nl> mmm a / hphp / test / slow / vec / convert - dtor . php <nl> ppp / dev / null <nl> <nl> - < ? hh / / decl <nl> - / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> - <nl> - class Dtor { <nl> - public $ id ; <nl> - function __construct ( $ id ) { <nl> - $ this - > id = $ id ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo " Dtor : : __destruct ( " . $ this - > id . " ) \ n " ; <nl> - } <nl> - } <nl> - <nl> - function main ( ) { <nl> - $ i = 1 ; <nl> - var_dump ( vec ( vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ) ; <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - <nl> - $ i + = 3 ; <nl> - var_dump ( dict ( vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ) ; <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - <nl> - $ i + = 3 ; <nl> - try { <nl> - var_dump ( keyset ( vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ) ; <nl> - } catch ( Exception $ e ) { <nl> - echo " Exception : \ " " . $ e - > getMessage ( ) . " \ " \ n " ; <nl> - } <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - <nl> - $ i + = 3 ; <nl> - var_dump ( ( array ) vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ; <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - <nl> - $ i + = 3 ; <nl> - var_dump ( ( bool ) vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ; <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - <nl> - $ i + = 3 ; <nl> - var_dump ( ( int ) vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ; <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - <nl> - $ i + = 3 ; <nl> - var_dump ( ( float ) vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ; <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - <nl> - $ i + = 3 ; <nl> - var_dump ( ( string ) vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ; <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - <nl> - $ i + = 3 ; <nl> - var_dump ( ( object ) vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ; <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - <nl> - $ i + = 3 ; <nl> - var_dump ( new Vector ( vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ) ; <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - <nl> - $ i + = 3 ; <nl> - var_dump ( new Map ( vec [ new Dtor ( $ i ) , new Dtor ( $ i + 1 ) , new Dtor ( $ i + 2 ) ] ) ) ; <nl> - echo " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ; <nl> - } <nl> - <nl> - <nl> - < < __EntryPoint > > <nl> - function main_convert_dtor ( ) { <nl> - main ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 7a4ffd45920 . . 00000000000 <nl> mmm a / hphp / test / slow / vec / convert - dtor . php . expectf <nl> ppp / dev / null <nl> <nl> - vec ( 3 ) { <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 1 ) <nl> - } <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 2 ) <nl> - } <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 3 ) <nl> - } <nl> - } <nl> - Dtor : : __destruct ( 1 ) <nl> - Dtor : : __destruct ( 2 ) <nl> - Dtor : : __destruct ( 3 ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - dict ( 3 ) { <nl> - [ 0 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 4 ) <nl> - } <nl> - [ 1 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 5 ) <nl> - } <nl> - [ 2 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 6 ) <nl> - } <nl> - } <nl> - Dtor : : __destruct ( 4 ) <nl> - Dtor : : __destruct ( 5 ) <nl> - Dtor : : __destruct ( 6 ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Dtor : : __destruct ( 7 ) <nl> - Dtor : : __destruct ( 8 ) <nl> - Dtor : : __destruct ( 9 ) <nl> - Exception : " Invalid keyset key : expected a key of type int or string , Dtor given " <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - array ( 3 ) { <nl> - [ 0 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 10 ) <nl> - } <nl> - [ 1 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 11 ) <nl> - } <nl> - [ 2 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 12 ) <nl> - } <nl> - } <nl> - Dtor : : __destruct ( 10 ) <nl> - Dtor : : __destruct ( 11 ) <nl> - Dtor : : __destruct ( 12 ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Dtor : : __destruct ( 13 ) <nl> - Dtor : : __destruct ( 14 ) <nl> - Dtor : : __destruct ( 15 ) <nl> - bool ( true ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Dtor : : __destruct ( 16 ) <nl> - Dtor : : __destruct ( 17 ) <nl> - Dtor : : __destruct ( 18 ) <nl> - int ( 1 ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - Dtor : : __destruct ( 19 ) <nl> - Dtor : : __destruct ( 20 ) <nl> - Dtor : : __destruct ( 21 ) <nl> - float ( 1 ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - <nl> - Notice : Vec to string conversion in % s on line % d <nl> - Dtor : : __destruct ( 22 ) <nl> - Dtor : : __destruct ( 23 ) <nl> - Dtor : : __destruct ( 24 ) <nl> - string ( 3 ) " Vec " <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - object ( stdClass ) # % d ( 3 ) { <nl> - [ 0 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 25 ) <nl> - } <nl> - [ 1 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 26 ) <nl> - } <nl> - [ 2 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 27 ) <nl> - } <nl> - } <nl> - Dtor : : __destruct ( 25 ) <nl> - Dtor : : __destruct ( 26 ) <nl> - Dtor : : __destruct ( 27 ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - object ( HH \ Vector ) # % d ( 3 ) { <nl> - [ 0 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 28 ) <nl> - } <nl> - [ 1 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 29 ) <nl> - } <nl> - [ 2 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 30 ) <nl> - } <nl> - } <nl> - Dtor : : __destruct ( 28 ) <nl> - Dtor : : __destruct ( 29 ) <nl> - Dtor : : __destruct ( 30 ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> - object ( HH \ Map ) # % d ( 3 ) { <nl> - [ 0 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 31 ) <nl> - } <nl> - [ 1 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 32 ) <nl> - } <nl> - [ 2 ] = > <nl> - object ( Dtor ) # % d ( 1 ) { <nl> - [ " id " ] = > <nl> - int ( 33 ) <nl> - } <nl> - } <nl> - Dtor : : __destruct ( 31 ) <nl> - Dtor : : __destruct ( 32 ) <nl> - Dtor : : __destruct ( 33 ) <nl> - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> mmm a / hphp / test / slow / vec / from - obj - dtor . php <nl> ppp b / hphp / test / slow / vec / from - obj - dtor . php <nl> class Cls implements Iterator { <nl> function __construct ( $ idx ) { <nl> $ this - > idx = $ idx ; <nl> } <nl> - function __destruct ( ) { <nl> - echo " Cls : : __destruct " . $ this - > idx . " \ n " ; <nl> - } <nl> <nl> public function rewind ( ) { } <nl> public function current ( ) { } <nl> function test ( ) { <nl> for ( $ i = 0 ; $ i < 10 ; $ i + + ) { <nl> echo " vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv \ n " ; <nl> from_obj ( new Cls ( $ i ) ) ; <nl> + var_dump ( hh \ objprof_get_data ( ) ) ; <nl> echo " ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ \ n " ; <nl> } <nl> } <nl> mmm a / hphp / test / slow / vec / from - obj - dtor . php . expect <nl> ppp b / hphp / test / slow / vec / from - obj - dtor . php . expect <nl> <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 0 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 1 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 2 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 3 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 4 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 5 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 6 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 7 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 8 <nl> + array ( 0 ) { <nl> + } <nl> ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv <nl> - Cls : : __destruct 9 <nl> - ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> \ No newline at end of file <nl> + array ( 0 ) { <nl> + } <nl> + ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ <nl> new file mode 100644 <nl> index 00000000000 . . 4977cc25517 <nl> mmm / dev / null <nl> ppp b / hphp / test / slow / xhp / xhp_spread . php . opts <nl> @ @ - 0 , 0 + 1 @ @ <nl> + - vEval . JitPGODecRefNZReleasePercentCOW = 0 - vEval . JitPGODecRefNZReleasePercent = 0 <nl> deleted file mode 100644 <nl> index ec68c408e72 . . 00000000000 <nl> mmm a / hphp / test / slow / yield / 2183 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Evil { <nl> - public function __destruct ( ) { <nl> - echo " in __destruct ( ) : " ; <nl> - var_dump ( $ this ) ; <nl> - try { <nl> - dumpCurrent ( ) ; <nl> - } catch ( Exception $ e ) { <nl> - printf ( " Caught : % s \ n " , $ e - > getMessage ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - function dumpCurrent ( ) { <nl> - echo " current : " ; <nl> - var_dump ( $ GLOBALS [ ' cont ' ] - > current ( ) ) ; <nl> - if ( isset ( $ GLOBALS [ ' gonext ' ] ) ) { <nl> - echo " iter from destructor \ n " ; <nl> - $ GLOBALS [ ' cont ' ] - > next ( ) ; <nl> - } <nl> - } <nl> - function gen ( ) { <nl> - echo " gen 1 \ n " ; <nl> - yield new Evil ; <nl> - echo " gen 2 \ n " ; <nl> - yield null ; <nl> - echo " gen 3 \ n " ; <nl> - yield new Evil ; <nl> - echo " gen 4 \ n " ; <nl> - yield new Evil ; <nl> - echo " gen 5 \ n " ; <nl> - } <nl> - function main ( ) { <nl> - $ GLOBALS [ ' cont ' ] = $ c = gen ( ) ; <nl> - echo " iter 1 \ n " ; <nl> - $ c - > rewind ( ) ; <nl> - <nl> - echo " iter 2 \ n " ; <nl> - $ c - > send ( new Evil ) ; <nl> - $ GLOBALS [ ' gonext ' ] = true ; <nl> - echo " iter 3 \ n " ; <nl> - $ c - > next ( ) ; <nl> - echo " iter 4 \ n " ; <nl> - $ c - > send ( null ) ; <nl> - echo " iter 5 \ n " ; <nl> - $ c - > send ( null ) ; <nl> - echo " Finished ! \ n " ; <nl> - } <nl> - <nl> - < < __EntryPoint > > <nl> - function main_2183 ( ) { <nl> - main ( ) ; <nl> - echo " Returned from main safely \ n " ; <nl> - } <nl> deleted file mode 100644 <nl> index 1761a1bd9c4 . . 00000000000 <nl> mmm a / hphp / test / slow / yield / 2183 . php . expect <nl> ppp / dev / null <nl> <nl> - iter 1 <nl> - gen 1 <nl> - iter 2 <nl> - in __destruct ( ) : object ( Evil ) # 3 ( 0 ) { <nl> - } <nl> - current : object ( Evil ) # 2 ( 0 ) { <nl> - } <nl> - gen 2 <nl> - in __destruct ( ) : object ( Evil ) # 2 ( 0 ) { <nl> - } <nl> - current : NULL <nl> - iter 3 <nl> - gen 3 <nl> - iter 4 <nl> - gen 4 <nl> - in __destruct ( ) : object ( Evil ) # 2 ( 0 ) { <nl> - } <nl> - current : object ( Evil ) # 3 ( 0 ) { <nl> - } <nl> - iter from destructor <nl> - Caught : Generator is already running <nl> - iter 5 <nl> - gen 5 <nl> - in __destruct ( ) : object ( Evil ) # 3 ( 0 ) { <nl> - } <nl> - current : NULL <nl> - iter from destructor <nl> - Caught : Generator is already running <nl> - Finished ! <nl> - Returned from main safely <nl> deleted file mode 100644 <nl> index 4510f4a0583 . . 00000000000 <nl> mmm a / hphp / test / slow / yield / 2183 . php . hphp_opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - - vEnableHipHopSyntax = 1 - d hhvm . php7 . all = 0 - d hhvm . php7 . all = 0 <nl> deleted file mode 120000 <nl> index 192ba8eb2b5 . . 00000000000 <nl> mmm a / hphp / test / slow / yield / 2183 . php . opts <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - . . / hiphop . opts <nl> \ No newline at end of file <nl> mmm a / hphp / test / slow / yield / yieldfrom / yield_from_exception_handling_free_memory . php <nl> ppp b / hphp / test / slow / yield / yieldfrom / yield_from_exception_handling_free_memory . php <nl> <nl> * / <nl> class FooBar implements Iterator { <nl> function __construct ( ) { echo " Constructing new FooBar \ n " ; } <nl> - function __destruct ( ) { echo " Destructing FooBar \ n " ; } <nl> function current ( ) { throw new Exception ; } <nl> function key ( ) { return 0 ; } <nl> function next ( ) { } <nl> mmm a / hphp / test / slow / yield / yieldfrom / yield_from_exception_handling_free_memory . php . expect <nl> ppp b / hphp / test / slow / yield / yieldfrom / yield_from_exception_handling_free_memory . php . expect <nl> Constructing new FooBar <nl> Caught Exception <nl> Unsetting $ x <nl> Finishing bar ( ) <nl> - Destructing FooBar <nl> mmm a / hphp / test / slow / yield / yieldfrom / yield_from_unwind_generator . php <nl> ppp b / hphp / test / slow / yield / yieldfrom / yield_from_unwind_generator . php <nl> <nl> <nl> class GenClass { <nl> function __construct ( ) { echo " Making GenClass \ n " ; } <nl> - function __destruct ( ) { echo " Destroying GenClass \ n " ; } <nl> function genInner ( ) { throw new Exception ; yield 5 ; } <nl> } <nl> <nl> mmm a / hphp / test / slow / yield / yieldfrom / yield_from_unwind_generator . php . expect <nl> ppp b / hphp / test / slow / yield / yieldfrom / yield_from_unwind_generator . php . expect <nl> <nl> Making GenClass <nl> - Destroying GenClass <nl> Caught Exception ( outer ) <nl> Finished genOuter ( ) <nl> deleted file mode 100644 <nl> index 094ae394076 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug20240 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class test <nl> - { <nl> - public $ member ; <nl> - <nl> - function test ( ) { <nl> - $ this - > member = 1 ; <nl> - register_shutdown_function ( array ( $ this , ' destructor ' ) ) ; <nl> - } <nl> - <nl> - function destructor ( ) { <nl> - print __METHOD__ . " \ n " ; <nl> - } <nl> - <nl> - function __destruct ( ) { <nl> - print __METHOD__ . " \ n " ; <nl> - } <nl> - <nl> - function add ( ) { <nl> - $ this - > member + = 1 ; <nl> - print $ this - > member . " \ n " ; <nl> - } <nl> - } <nl> - <nl> - $ t = new test ( ) ; <nl> - <nl> - $ t - > add ( ) ; <nl> - $ t - > add ( ) ; <nl> - <nl> - echo " Done \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index 46267b0e276 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug20240 . php . expectf <nl> ppp / dev / null <nl> <nl> - 2 <nl> - 3 <nl> - Done <nl> - test : : destructor <nl> - test : : __destruct <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> deleted file mode 100644 <nl> index d49c86f61a8 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug20240 . php . skipif <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - < ? php if ( version_compare ( zend_version ( ) , ' 2 . 0 . 0 - dev ' , ' < ' ) ) die ( ' skip ZendEngine 2 is needed ' ) ; ? > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index bb8e113dcd1 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug24635 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class SiteClass { <nl> - function __construct ( ) { $ this - > page = new PageClass ( ) ; } <nl> - } <nl> - class PageClass { <nl> - function Display ( ) { <nl> - $ section = new SectionClass ( " PageClass : : Display " ) ; <nl> - } <nl> - } <nl> - class SectionClass { <nl> - function __construct ( $ comment ) { <nl> - $ this - > Comment = $ comment ; <nl> - } <nl> - function __destruct ( ) { <nl> - out ( $ this - > Comment ) ; / / this line doesn ' t crash PHP <nl> - out ( " \ n < ! - - End Section : " . $ this - > Comment . " - - > " ) ; / / this line <nl> - } <nl> - } <nl> - function out ( $ code ) { return ; } <nl> - $ site = new SiteClass ( ) ; <nl> - $ site - > page - > Display ( ) ; <nl> - echo " OK \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index a0aba9318ad . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug24635 . php . expectf <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - OK <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index d49c86f61a8 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug24635 . php . skipif <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - < ? php if ( version_compare ( zend_version ( ) , ' 2 . 0 . 0 - dev ' , ' < ' ) ) die ( ' skip ZendEngine 2 is needed ' ) ; ? > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 96e2bb9443c . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug29368 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Foo <nl> - { <nl> - function __construct ( ) <nl> - { <nl> - echo __METHOD__ . " \ n " ; <nl> - throw new Exception ; <nl> - } <nl> - function __destruct ( ) <nl> - { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> - } <nl> - <nl> - try <nl> - { <nl> - $ bar = new Foo ; <nl> - } catch ( Exception $ exc ) <nl> - { <nl> - echo " Caught exception ! \ n " ; <nl> - } <nl> - <nl> - unset ( $ bar ) ; <nl> - <nl> - ? > <nl> - = = = DONE = = = <nl> deleted file mode 100644 <nl> index 451fc9e7e1d . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug29368 . php . expectf <nl> ppp / dev / null <nl> <nl> - Foo : : __construct <nl> - Caught exception ! <nl> - = = = DONE = = = <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 331b3a2041f . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug32596 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class BUG { <nl> - public $ error = " please fix this thing , it wasted a nice part of my life ! \ n " ; <nl> - static function instance ( ) { return new BUG ( ) ; } <nl> - <nl> - function __destruct ( ) <nl> - { <nl> - $ c = get_class ( $ this ) ; unset ( $ c ) ; <nl> - echo get_class ( $ this ) . " \ n " ; <nl> - if ( defined ( ' DEBUG_ ' . __CLASS__ ) ) { } <nl> - $ c = get_class ( $ this ) ; / / memory leak only <nl> - echo $ this - > error ; <nl> - } <nl> - } <nl> - <nl> - <nl> - BUG : : instance ( ) - > error ; <nl> - echo " this is still executed \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index 6532dbd273f . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug32596 . php . expectf <nl> ppp / dev / null <nl> <nl> - BUG <nl> - please fix this thing , it wasted a nice part of my life ! <nl> - this is still executed <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index e192ecf6f1e . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug32799 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class test { <nl> - public $ c = 1 ; <nl> - function __destruct ( ) { <nl> - if ( ! isset ( $ GLOBALS [ ' p ' ] ) ) { <nl> - echo " NULL \ n " ; <nl> - } else { <nl> - $ GLOBALS [ ' p ' ] - > c + + ; / / no warning <nl> - print $ GLOBALS [ ' p ' ] - > c . " \ n " ; / / segfault <nl> - var_dump ( $ GLOBALS [ ' p ' ] ) ; <nl> - } <nl> - } <nl> - } <nl> - $ p = new test ; <nl> - $ p = null ; / / destroy the object by a new assignment ( segfault ) <nl> - ? > <nl> deleted file mode 100644 <nl> index fe3a0735d98 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug32799 . php . expectf <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - NULL <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 3e0a92e6e14 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug36006 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Person { <nl> - public $ dad ; <nl> - public function __destruct ( ) { <nl> - $ this - > dad = null ; / * no segfault if this is commented out * / <nl> - } <nl> - } <nl> - <nl> - class Dad extends Person { <nl> - public $ son ; <nl> - public function __construct ( ) { <nl> - $ this - > son = new Person ; <nl> - $ this - > son - > dad = $ this ; / * no segfault if this is commented out * / <nl> - } <nl> - public function __destruct ( ) { <nl> - $ this - > son = null ; <nl> - parent : : __destruct ( ) ; / * segfault here * / <nl> - } <nl> - } <nl> - <nl> - $ o = new Dad ; <nl> - unset ( $ o ) ; <nl> - echo " ok \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index b5754e20373 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug36006 . php . expectf <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - ok <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> deleted file mode 100644 <nl> index 6c8d11e8805 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug36759 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class Foo { <nl> - private $ bar ; <nl> - function __construct ( $ bar ) { <nl> - $ this - > bar = $ bar ; <nl> - } <nl> - function __destruct ( ) { <nl> - echo __METHOD__ , " \ n " ; <nl> - unset ( $ this - > bar ) ; <nl> - } <nl> - } <nl> - <nl> - class Bar { <nl> - function __destruct ( ) { <nl> - echo __METHOD__ , " \ n " ; <nl> - unset ( $ this - > bar ) ; <nl> - } <nl> - } <nl> - function main ( ) { <nl> - $ y = new Bar ( ) ; <nl> - $ x = new Foo ( $ y ) ; <nl> - } <nl> - main ( ) ; <nl> - ? > <nl> deleted file mode 100644 <nl> index 9748c0f27ff . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug36759 . php . expectf <nl> ppp / dev / null <nl> <nl> - Foo : : __destruct <nl> - Bar : : __destruct <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug38220 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / bug38220 . php <nl> function __call ( $ method , $ args ) { <nl> / / Uncomment this line to work without crash <nl> / / $ drv - > obj = null ; <nl> } <nl> - <nl> - function __destruct ( ) { <nl> - echo " A : : __destruct ( ) \ n " ; <nl> - $ this - > close ( ) ; <nl> - } <nl> } <nl> <nl> class myserv { <nl> mmm a / hphp / test / zend / good / Zend / tests / bug38220 . php . expectf <nl> ppp b / hphp / test / zend / good / Zend / tests / bug38220 . php . expectf <nl> A Object <nl> ) <nl> func1 ( ) : 1 <nl> after call func1 <nl> - A : : __destruct ( ) <nl> - before call close <nl> - A Object <nl> - ( <nl> - [ i ] = > 1 <nl> - ) <nl> - close ( ) : 1 <nl> - after call close <nl> before call func1 <nl> A Object <nl> ( <nl> [ i ] = > 2 <nl> ) <nl> - func1 ( ) : 1 <nl> + func1 ( ) : 2 <nl> after call func1 <nl> - A : : __destruct ( ) <nl> - before call close <nl> - A Object <nl> - ( <nl> - [ i ] = > 2 <nl> - ) <nl> - close ( ) : 2 <nl> - after call close <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index c826c268579 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug39346 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class test <nl> - { <nl> - protected $ _id ; <nl> - static $ instances ; <nl> - <nl> - public function __construct ( $ id ) { <nl> - $ this - > _id = $ id ; <nl> - self : : $ instances [ $ this - > _id ] = $ this ; <nl> - } <nl> - <nl> - function __destruct ( ) { <nl> - unset ( self : : $ instances [ $ this - > _id ] ) ; <nl> - } <nl> - } <nl> - $ test = new test ( 2 ) ; <nl> - $ test = new test ( 1 ) ; <nl> - $ test = new test ( 2 ) ; <nl> - $ test = new test ( 3 ) ; <nl> - echo " ok \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index b5754e20373 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug39346 . php . expectf <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - ok <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / Zend / tests / bug47343 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / bug47343 . php <nl> <nl> < ? php <nl> class A <nl> { <nl> - public function __destruct ( ) <nl> - { <nl> - gc_collect_cycles ( ) ; <nl> - } <nl> - <nl> public function getB ( ) <nl> { <nl> $ this - > data [ ' foo ' ] = new B ( $ this ) ; <nl> public function B ( $ A ) <nl> { <nl> $ this - > A = $ A ; <nl> } <nl> - <nl> - public function __destruct ( ) <nl> - { <nl> - } <nl> } <nl> <nl> for ( $ i = 0 ; $ i < 2 ; $ i + + ) <nl> deleted file mode 100644 <nl> index a1ecbd0e14c . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug47353 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class A <nl> - { <nl> - function __destruct ( ) <nl> - { <nl> - $ myArray = array ( ) ; <nl> - <nl> - for ( $ i = 1 ; $ i < = 3000 ; $ i + + ) { <nl> - if ( ! isset ( $ myArray [ $ i ] ) ) <nl> - $ myArray [ $ i ] = array ( ) ; <nl> - $ ref = & $ myArray [ $ i ] ; <nl> - $ ref [ ] = new stdClass ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - $ a = new A ( ) ; <nl> - <nl> - echo " Done \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index 8ad96f878c2 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug47353 . php . expectf <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - Done <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / Zend / tests / bug47771 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / bug47771 . php <nl> function throw_exc ( ) { <nl> } <nl> <nl> class Test { <nl> - <nl> + <nl> public function __construct ( ) { <nl> echo ' Constr ' . " \ n " ; <nl> } <nl> - <nl> - public function __destruct ( ) { <nl> - echo ' Destr ' . " \ n " ; <nl> - } <nl> - <nl> + <nl> } <nl> <nl> try { <nl> - <nl> + <nl> $ T = new Test ( throw_exc ( ) ) ; <nl> - <nl> + <nl> } catch ( Exception $ e ) { <nl> echo ' Exception : ' . $ e - > getMessage ( ) . " \ n " ; <nl> } <nl> deleted file mode 100644 <nl> index 33ab31f0569 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug49893 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class A { <nl> - function __destruct ( ) { <nl> - try { <nl> - throw new Exception ( " 2 " ) ; <nl> - } catch ( Exception $ e ) { <nl> - echo $ e - > getMessage ( ) . " \ n " ; <nl> - } <nl> - } <nl> - } <nl> - class B { <nl> - function __construct ( ) { <nl> - $ this - > a = new A ( ) ; <nl> - throw new Exception ( " 1 " ) ; <nl> - } <nl> - } <nl> - try { <nl> - $ b = new B ( ) ; <nl> - } catch ( Exception $ e ) { <nl> - echo $ e - > getMessage ( ) . " \ n " ; ; <nl> - } <nl> - ? > <nl> deleted file mode 100644 <nl> index 6bf8d1741d9 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug49893 . php . expectf <nl> ppp / dev / null <nl> <nl> - 2 <nl> - 1 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 5323d84b933 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug51822 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class DestructableObject <nl> - { <nl> - public function __destruct ( ) <nl> - { <nl> - echo " 2 \ n " ; <nl> - } <nl> - } <nl> - <nl> - class DestructorCreator <nl> - { <nl> - public function __destruct ( ) <nl> - { <nl> - $ this - > test = new DestructableObject ; <nl> - echo " 1 \ n " ; <nl> - } <nl> - } <nl> - <nl> - class Test <nl> - { <nl> - public static $ mystatic ; <nl> - } <nl> - <nl> - / / Uncomment this to avoid segfault <nl> - / / Test : : $ mystatic = new DestructorCreator ( ) ; <nl> - <nl> - $ x = new Test ( ) ; <nl> - <nl> - if ( ! isset ( Test : : $ mystatic ) ) <nl> - Test : : $ mystatic = new DestructorCreator ( ) ; <nl> - <nl> - echo " bla \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index 73fc1a973b8 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug51822 . php . expectf <nl> ppp / dev / null <nl> <nl> - bla <nl> - 1 <nl> - 2 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> deleted file mode 100644 <nl> index a6cd24f7951 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug60598 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - define ( ' OBJECT_COUNT ' , 10000 ) ; <nl> - <nl> - $ containers = array ( ) ; <nl> - <nl> - class Object { <nl> - protected $ _guid = 0 ; <nl> - public function __construct ( ) { <nl> - global $ containers ; <nl> - $ this - > guid = 1 ; <nl> - $ containers [ spl_object_hash ( $ this ) ] = $ this ; <nl> - } <nl> - public function __destruct ( ) { <nl> - global $ containers ; <nl> - $ containers [ spl_object_hash ( $ this ) ] = NULL ; <nl> - } <nl> - } <nl> - <nl> - for ( $ i = 0 ; $ i < OBJECT_COUNT ; + + $ i ) { <nl> - new Object ( ) ; <nl> - } <nl> - <nl> - / / You probably won ' t see this because of the " zend_mm_heap corrupted " <nl> - ? > <nl> - If you see this , try to increase OBJECT_COUNT to 100 , 000 <nl> deleted file mode 100644 <nl> index 6ce57cc9d32 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug60598 . php . expectf <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - If you see this , try to increase OBJECT_COUNT to 100 , 000 <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 2df798fbfcb . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug62763 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class test1 { <nl> - public function __construct ( ) { <nl> - register_shutdown_function ( array ( $ this , ' shutdown ' ) ) ; <nl> - } <nl> - public function shutdown ( ) { <nl> - exit ( __METHOD__ ) ; <nl> - } <nl> - } <nl> - <nl> - class test2 extends test1 { <nl> - public function __destruct ( ) { <nl> - exit ( __METHOD__ ) ; <nl> - } <nl> - } <nl> - new test1 ; <nl> - new test2 ; <nl> - ? > <nl> deleted file mode 100644 <nl> index 4918f6733fc . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug62763 . php . expectf <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - test1 : : shutdowntest2 : : __destruct <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / Zend / tests / bug63635 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / bug63635 . php <nl> <nl> class Node { <nl> public $ parent = NULL ; <nl> public $ childs = array ( ) ; <nl> - <nl> + <nl> function __construct ( Node $ parent = NULL ) { <nl> if ( $ parent ) { <nl> $ parent - > childs [ ] = $ this ; <nl> } <nl> $ this - > childs [ ] = $ this ; <nl> } <nl> - <nl> - function __destruct ( ) { <nl> - $ this - > childs = NULL ; <nl> - } <nl> } <nl> <nl> define ( " MAX " , 16 ) ; <nl> deleted file mode 100644 <nl> index 8b8c4fc8e12 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug65051 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Foo { <nl> - public $ array ; <nl> - <nl> - public function __destruct ( ) { <nl> - var_dump ( count ( $ this - > array [ 0 ] ) ) ; <nl> - var_dump ( $ this - > array [ 0 ] ) ; <nl> - } <nl> - } <nl> - <nl> - $ array = [ [ new Foo ] ] ; <nl> - $ array [ 0 ] [ 0 ] - > array = & $ array ; <nl> - unset ( $ array [ 0 ] [ 0 ] ) ; <nl> - <nl> - ? > <nl> deleted file mode 100644 <nl> index fd0f4c7dcfb . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / bug65051 . php . expectf <nl> ppp / dev / null <nl> <nl> - int ( 0 ) <nl> - array ( 0 ) { <nl> - } <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / Zend / tests / catch_002 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / catch_002 . php <nl> function __construct ( ) <nl> throw new Exception ( ) ; <nl> echo __METHOD__ . " ( ) Must not be reached \ n " ; <nl> } <nl> - <nl> - function __destruct ( ) <nl> - { <nl> - echo __METHOD__ . " ( ) Must not be called \ n " ; <nl> - } <nl> } <nl> <nl> try <nl> mmm a / hphp / test / zend / good / Zend / tests / catch_003 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / catch_003 . php <nl> function __construct ( ) <nl> self : : fail ( ) ; <nl> echo __METHOD__ . " ( ) Must not be reached \ n " ; <nl> } <nl> - <nl> - function __destruct ( ) <nl> - { <nl> - echo __METHOD__ . " ( ) Must not be called \ n " ; <nl> - } <nl> } <nl> <nl> try <nl> mmm a / hphp / test / zend / good / Zend / tests / catch_004 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / catch_004 . php <nl> function __construct ( ) <nl> echo __METHOD__ . " ( ) Must not be reached \ n " ; <nl> } <nl> <nl> - function __destruct ( ) <nl> - { <nl> - echo __METHOD__ . " ( ) Must not be called \ n " ; <nl> - } <nl> - <nl> static function test ( ) <nl> { <nl> try <nl> mmm a / hphp / test / zend / good / Zend / tests / closure_005 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / closure_005 . php <nl> function __construct ( $ x ) { <nl> $ this - > x = $ x ; <nl> } <nl> <nl> - function __destruct ( ) { <nl> - echo " Destroyed \ n " ; <nl> - } <nl> - <nl> function getIncer ( $ val ) { <nl> return function ( ) use ( $ val ) { <nl> $ this - > x + = $ val ; <nl> function getPrinter ( ) { <nl> echo $ this - > x . " \ n " ; <nl> } ; <nl> } <nl> - <nl> + <nl> function getError ( ) { <nl> return static function ( ) { <nl> echo $ this - > x . " \ n " ; <nl> } ; <nl> } <nl> - <nl> + <nl> function printX ( ) { <nl> echo $ this - > x . " \ n " ; <nl> } <nl> mmm a / hphp / test / zend / good / Zend / tests / closure_005 . php . expectf <nl> ppp b / hphp / test / zend / good / Zend / tests / closure_005 . php . expectf <nl> <nl> 5 <nl> 7 <nl> 7 <nl> - Destroyed <nl> <nl> - Fatal error : % s <nl> \ No newline at end of file <nl> + Fatal error : % s <nl> deleted file mode 100644 <nl> index 10fd9c4171b . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / dtor_scope . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class T <nl> - { <nl> - private $ var = array ( ) ; <nl> - <nl> - public function add ( $ a ) <nl> - { <nl> - array_push ( & $ this - > var , $ a ) ; <nl> - } <nl> - <nl> - public function __destruct ( ) <nl> - { <nl> - print_r ( $ this - > var ) ; <nl> - } <nl> - } <nl> - <nl> - class TT extends T <nl> - { <nl> - } <nl> - $ t = new TT ( ) ; <nl> - $ t - > add ( " Hello " ) ; <nl> - $ t - > add ( " World " ) ; <nl> - ? > <nl> deleted file mode 100644 <nl> index 2d2b4bb0e55 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / dtor_scope . php . expectf <nl> ppp / dev / null <nl> <nl> - Array <nl> - ( <nl> - [ 0 ] = > Hello <nl> - [ 1 ] = > World <nl> - ) <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> deleted file mode 100644 <nl> index 138111c33c9 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / dtor_scope . php . skipif <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - < ? php if ( version_compare ( zend_version ( ) , ' 2 . 0 . 0 - dev ' , ' < ' ) ) die ( ' skip ZendEngine 2 needed ' ) ; ? > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 9512636f4ae . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / errmsg_019 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class test { <nl> - function __destruct ( $ var ) { <nl> - } <nl> - } <nl> - <nl> - echo " Done \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index a79b1b6d814 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / errmsg_019 . php . expectf <nl> ppp / dev / null <nl> <nl> - <nl> - Fatal error : % s <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index b1023ffc9a2 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / errmsg_033 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class test { <nl> - <nl> - static function __destruct ( ) { <nl> - } <nl> - } <nl> - <nl> - echo " Done \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index a79b1b6d814 . . 00000000000 <nl> mmm a / hphp / test / zend / good / Zend / tests / errmsg_033 . php . expectf <nl> ppp / dev / null <nl> <nl> - <nl> - Fatal error : % s <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / Zend / tests / get_class_methods_003 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / get_class_methods_003 . php <nl> <nl> < ? php <nl> <nl> - interface A { <nl> + interface A { <nl> function aa ( ) ; <nl> function bb ( ) ; <nl> static function cc ( ) ; <nl> class C { <nl> public function a ( ) { } <nl> protected function b ( ) { } <nl> private function c ( ) { } <nl> - <nl> + <nl> static public function static_a ( ) { } <nl> static protected function static_b ( ) { } <nl> static private function static_c ( ) { } <nl> static private function static_c ( ) { } <nl> class B extends C implements A { <nl> public function aa ( ) { } <nl> public function bb ( ) { } <nl> - <nl> + <nl> static function cc ( ) { } <nl> - <nl> + <nl> public function __construct ( ) { <nl> var_dump ( get_class_methods ( ' A ' ) ) ; <nl> var_dump ( get_class_methods ( ' B ' ) ) ; <nl> var_dump ( get_class_methods ( ' C ' ) ) ; <nl> } <nl> - <nl> - public function __destruct ( ) { } <nl> } <nl> <nl> new B ; <nl> mmm a / hphp / test / zend / good / Zend / tests / get_class_methods_003 . php . expectf <nl> ppp b / hphp / test / zend / good / Zend / tests / get_class_methods_003 . php . expectf <nl> array ( 3 ) { <nl> [ 2 ] = > <nl> string ( 2 ) " cc " <nl> } <nl> - array ( 9 ) { <nl> + array ( 8 ) { <nl> [ 0 ] = > <nl> string ( 2 ) " aa " <nl> [ 1 ] = > <nl> array ( 9 ) { <nl> [ 3 ] = > <nl> string ( 11 ) " __construct " <nl> [ 4 ] = > <nl> - string ( 10 ) " __destruct " <nl> - [ 5 ] = > <nl> string ( 1 ) " a " <nl> - [ 6 ] = > <nl> + [ 5 ] = > <nl> string ( 1 ) " b " <nl> - [ 7 ] = > <nl> + [ 6 ] = > <nl> string ( 8 ) " static_a " <nl> - [ 8 ] = > <nl> + [ 7 ] = > <nl> string ( 8 ) " static_b " <nl> } <nl> array ( 4 ) { <nl> array ( 4 ) { <nl> string ( 8 ) " static_a " <nl> [ 3 ] = > <nl> string ( 8 ) " static_b " <nl> - } <nl> \ No newline at end of file <nl> + } <nl> mmm a / hphp / test / zend / good / Zend / tests / lsb_010 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / lsb_010 . php <nl> public static function bar ( ) { <nl> public function __construct ( ) { <nl> echo static : : $ className . " : : __construct \ n " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo static : : $ className . " : : __destruct \ n " ; <nl> - } <nl> } <nl> <nl> class FooChild extends Foo { <nl> mmm a / hphp / test / zend / good / Zend / tests / lsb_010 . php . expectf <nl> ppp b / hphp / test / zend / good / Zend / tests / lsb_010 . php . expectf <nl> <nl> Foo : : __construct <nl> FooChild : : __construct <nl> - Foo : : __destruct <nl> - FooChild : : __destruct <nl> Foo : : bar <nl> - FooChild : : bar <nl> \ No newline at end of file <nl> + FooChild : : bar <nl> mmm a / hphp / test / zend / good / Zend / tests / traits / methods_003 . php <nl> ppp b / hphp / test / zend / good / Zend / tests / traits / methods_003 . php <nl> <nl> < ? php <nl> <nl> - trait foo { <nl> + trait foo { <nl> public function __construct ( ) { <nl> var_dump ( __FUNCTION__ ) ; <nl> } <nl> - public function __destruct ( ) { <nl> - var_dump ( __FUNCTION__ ) ; <nl> - } <nl> } <nl> <nl> class bar { <nl> mmm a / hphp / test / zend / good / Zend / tests / traits / methods_003 . php . expectf <nl> ppp b / hphp / test / zend / good / Zend / tests / traits / methods_003 . php . expectf <nl> @ @ - 1 , 2 + 1 @ @ <nl> string ( 11 ) " __construct " <nl> - string ( 10 ) " __destruct " <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / ext / intl / tests / uconverter_oop_callback . php <nl> ppp b / hphp / test / zend / good / ext / intl / tests / uconverter_oop_callback . php <nl> <nl> - < ? php <nl> + < ? hh <nl> class MyConverter extends UConverter { <nl> / * * <nl> * Called during conversion from source encoding to internal UChar representation <nl> public function fromUCallback ( $ reason , $ source , $ codePoint , & $ error ) { <nl> <nl> } <nl> <nl> - $ c = new MyConverter ( ' ascii ' , ' utf - 8 ' ) ; <nl> - foreach ( array ( " regular " , " irregul \ xC1 \ xA1r " , " \ xC2 \ xA1unsupported ! " ) as $ word ) { <nl> - $ c - > convert ( $ word ) ; <nl> + < < __EntryPoint > > <nl> + function main ( ) { <nl> + using ( $ c = new MyConverter ( ' ascii ' , ' utf - 8 ' ) ) { <nl> + foreach ( array ( " regular " , " irregul \ xC1 \ xA1r " , " \ xC2 \ xA1unsupported ! " ) as $ word ) { <nl> + $ c - > convert ( $ word ) ; <nl> + } <nl> + } <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . aba51b22a65 <nl> mmm / dev / null <nl> ppp b / hphp / test / zend / good / ext / intl / tests / uconverter_oop_callback . php . opts <nl> @ @ - 0 , 0 + 1 @ @ <nl> + - vHack . Lang . LookForTypechecker = 0 <nl> mmm a / hphp / test / zend / good / ext / reflection / tests / ReflectionClass_getModifierNames_basic . php <nl> ppp b / hphp / test / zend / good / ext / reflection / tests / ReflectionClass_getModifierNames_basic . php <nl> final class c { } <nl> class x <nl> { <nl> function __construct ( ) { } <nl> - function __destruct ( ) { } <nl> private function a ( ) { } <nl> private static function b ( ) { } <nl> protected function c ( ) { } <nl> mmm a / hphp / test / zend / good / ext / reflection / tests / ReflectionClass_getModifierNames_basic . php . expectf <nl> ppp b / hphp / test / zend / good / ext / reflection / tests / ReflectionClass_getModifierNames_basic . php . expectf <nl> array ( 1 ) { <nl> [ 0 ] = > <nl> string ( 6 ) " public " <nl> } <nl> - string ( 13 ) " x : : __destruct " <nl> - array ( 1 ) { <nl> - [ 0 ] = > <nl> - string ( 6 ) " public " <nl> - } <nl> string ( 4 ) " x : : a " <nl> array ( 1 ) { <nl> [ 0 ] = > <nl> array ( 2 ) { <nl> [ 1 ] = > <nl> string ( 9 ) " protected " <nl> } <nl> - = = DONE = = <nl> \ No newline at end of file <nl> + = = DONE = = <nl> mmm a / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic1 . php <nl> ppp b / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic1 . php <nl> function reflectMethod ( $ class , $ method ) { <nl> var_dump ( $ methodInfo - > isStatic ( ) ) ; <nl> echo " \ nisConstructor ( ) : \ n " ; <nl> var_dump ( $ methodInfo - > isConstructor ( ) ) ; <nl> - echo " \ nisDestructor ( ) : \ n " ; <nl> - var_dump ( $ methodInfo - > isDestructor ( ) ) ; <nl> echo " \ n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n " ; <nl> } <nl> <nl> class TestClass <nl> public function foo ( ) { <nl> echo " Called foo ( ) \ n " ; <nl> } <nl> - <nl> + <nl> static function stat ( ) { <nl> echo " Called stat ( ) \ n " ; <nl> } <nl> - <nl> + <nl> private function priv ( ) { <nl> echo " Called priv ( ) \ n " ; <nl> } <nl> - <nl> + <nl> protected function prot ( ) { } <nl> - <nl> - public function __destruct ( ) { } <nl> } <nl> <nl> class DerivedClass extends TestClass { } <nl> public function int ( ) ; <nl> reflectMethod ( " DerivedClass " , " prot " ) ; <nl> reflectMethod ( " TestInterface " , " int " ) ; <nl> reflectMethod ( " ReflectionProperty " , " __construct " ) ; <nl> - reflectMethod ( " TestClass " , " __destruct " ) ; <nl> <nl> ? > <nl> mmm a / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic1 . php . expectf <nl> ppp b / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic1 . php . expectf <nl> bool ( false ) <nl> isConstructor ( ) : <nl> bool ( false ) <nl> <nl> - isDestructor ( ) : <nl> - bool ( false ) <nl> - <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> Reflecting on method TestClass : : stat ( ) <nl> bool ( true ) <nl> isConstructor ( ) : <nl> bool ( false ) <nl> <nl> - isDestructor ( ) : <nl> - bool ( false ) <nl> - <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> Reflecting on method TestClass : : priv ( ) <nl> bool ( false ) <nl> isConstructor ( ) : <nl> bool ( false ) <nl> <nl> - isDestructor ( ) : <nl> - bool ( false ) <nl> - <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> Reflecting on method TestClass : : prot ( ) <nl> bool ( false ) <nl> isConstructor ( ) : <nl> bool ( false ) <nl> <nl> - isDestructor ( ) : <nl> - bool ( false ) <nl> - <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> Reflecting on method DerivedClass : : prot ( ) <nl> bool ( false ) <nl> isConstructor ( ) : <nl> bool ( false ) <nl> <nl> - isDestructor ( ) : <nl> - bool ( false ) <nl> - <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> Reflecting on method TestInterface : : int ( ) <nl> bool ( false ) <nl> isConstructor ( ) : <nl> bool ( false ) <nl> <nl> - isDestructor ( ) : <nl> - bool ( false ) <nl> - <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> Reflecting on method ReflectionProperty : : __construct ( ) <nl> bool ( false ) <nl> isConstructor ( ) : <nl> bool ( true ) <nl> <nl> - isDestructor ( ) : <nl> - bool ( false ) <nl> - <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Reflecting on method TestClass : : __destruct ( ) <nl> - <nl> - <nl> - isFinal ( ) : <nl> - bool ( false ) <nl> - <nl> - isAbstract ( ) : <nl> - bool ( false ) <nl> - <nl> - isPublic ( ) : <nl> - bool ( true ) <nl> - <nl> - isPrivate ( ) : <nl> - bool ( false ) <nl> - <nl> - isProtected ( ) : <nl> - bool ( false ) <nl> - <nl> - isStatic ( ) : <nl> - bool ( false ) <nl> - <nl> - isConstructor ( ) : <nl> - bool ( false ) <nl> - <nl> - isDestructor ( ) : <nl> - bool ( true ) <nl> - <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic3 . php <nl> ppp b / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic3 . php <nl> private function priv ( ) { <nl> } <nl> <nl> protected function prot ( ) { } <nl> - <nl> - public function __destruct ( ) { } <nl> } <nl> <nl> class DerivedClass extends TestClass { } <nl> public function int ( ) ; <nl> reflectMethod ( " DerivedClass " , " prot " ) ; <nl> reflectMethod ( " TestInterface " , " int " ) ; <nl> reflectMethod ( " ReflectionProperty " , " __construct " ) ; <nl> - reflectMethod ( " TestClass " , " __destruct " ) ; <nl> <nl> <nl> ? > <nl> mmm a / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic3 . php . expectf <nl> ppp b / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic3 . php . expectf <nl> isUserDefined ( ) : <nl> bool ( false ) <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Reflecting on method TestClass : : __destruct ( ) <nl> - <nl> - <nl> - getName ( ) : <nl> - string ( 10 ) " __destruct " <nl> - <nl> - isInternal ( ) : <nl> - bool ( false ) <nl> - <nl> - isUserDefined ( ) : <nl> - bool ( true ) <nl> - <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic4 . php <nl> ppp b / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic4 . php <nl> private function priv ( ) { <nl> } <nl> <nl> protected function prot ( ) { } <nl> - <nl> - public function __destruct ( ) { } <nl> } <nl> <nl> class DerivedClass extends TestClass { } <nl> public function int ( ) ; <nl> reflectMethod ( " DerivedClass " , " prot " ) ; <nl> reflectMethod ( " TestInterface " , " int " ) ; <nl> reflectMethod ( " ReflectionProperty " , " __construct " ) ; <nl> - reflectMethod ( " TestClass " , " __destruct " ) ; <nl> <nl> ? > <nl> mmm a / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic4 . php . expectf <nl> ppp b / hphp / test / zend / good / ext / reflection / tests / ReflectionMethod_basic4 . php . expectf <nl> getFileName ( ) : <nl> string ( % d ) " % sReflectionMethod_basic4 . php " <nl> <nl> getStartLine ( ) : <nl> - int ( 42 ) <nl> + int ( 40 ) <nl> <nl> getEndLine ( ) : <nl> - int ( 42 ) <nl> + int ( 40 ) <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> getEndLine ( ) : <nl> bool ( false ) <nl> <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Reflecting on method TestClass : : __destruct ( ) <nl> - <nl> - <nl> - getFileName ( ) : <nl> - string ( % d ) " % sReflectionMethod_basic4 . php " <nl> - <nl> - getStartLine ( ) : <nl> - int ( 36 ) <nl> - <nl> - getEndLine ( ) : <nl> - int ( 36 ) <nl> - <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_006 . php <nl> ppp b / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_006 . php <nl> <nl> <nl> ob_start ( ) ; <nl> <nl> - / * <nl> + / * <nl> * Prototype : bool session_set_save_handler ( SessionHandler $ handler [ , bool $ register_shutdown_function = true ] ) <nl> * Description : Sets user - level session storage functions <nl> - * Source code : ext / session / session . c <nl> + * Source code : ext / session / session . c <nl> * / <nl> <nl> echo " * * * Testing session_set_save_handler ( ) : using objects in close * * * \ n " ; <nl> <nl> class MySession7_Foo { <nl> public $ state = ' ok ' ; <nl> - function __destruct ( ) { <nl> - $ this - > state = ' destroyed ' ; <nl> - } <nl> } <nl> <nl> class MySession7 extends SessionHandler { <nl> mmm a / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_007 . php <nl> ppp b / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_007 . php <nl> <nl> <nl> ob_start ( ) ; <nl> <nl> - / * <nl> + / * <nl> * Prototype : bool session_set_save_handler ( SessionHandler $ handler [ , bool $ register_shutdown_function = true ] ) <nl> * Description : Sets user - level session storage functions <nl> - * Source code : ext / session / session . c <nl> + * Source code : ext / session / session . c <nl> * / <nl> <nl> echo " * * * Testing session_set_save_handler ( ) : manual shutdown , reopen * * * \ n " ; <nl> public function __construct ( $ num ) { <nl> $ this - > num = $ num ; <nl> echo " ( # $ this - > num ) constructor called \ n " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " ( # $ this - > num ) destructor called \ n " ; <nl> - } <nl> public function finish ( ) { <nl> $ id = session_id ( ) ; <nl> echo " ( # $ this - > num ) finish called $ id \ n " ; <nl> mmm a / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_007 . php . expectf <nl> ppp b / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_007 . php . expectf <nl> <nl> ( # 1 ) writing % s = foo | s : 3 : " bar " ; <nl> ( # 1 ) closing % s <nl> ( # 2 ) constructor called <nl> - ( # 1 ) destructor called <nl> done <nl> ( # 2 ) writing % s = foo | s : 3 : " bar " ; abc | s : 3 : " xyz " ; <nl> ( # 2 ) closing % s <nl> - ( # 2 ) destructor called <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_008 . php <nl> ppp b / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_008 . php <nl> <nl> <nl> ob_start ( ) ; <nl> <nl> - / * <nl> + / * <nl> * Prototype : bool session_set_save_handler ( SessionHandler $ handler [ , bool $ register_shutdown_function = true ] ) <nl> * Description : Sets user - level session storage functions <nl> - * Source code : ext / session / session . c <nl> + * Source code : ext / session / session . c <nl> * / <nl> <nl> echo " * * * Testing session_set_save_handler ( ) : manual shutdown * * * \ n " ; <nl> public function __construct ( $ num ) { <nl> $ this - > num = $ num ; <nl> echo " ( # $ this - > num ) constructor called \ n " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " ( # $ this - > num ) destructor called \ n " ; <nl> - } <nl> public function finish ( ) { <nl> $ id = session_id ( ) ; <nl> echo " ( # $ this - > num ) finish called $ id \ n " ; <nl> mmm a / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_008 . php . expectf <nl> ppp b / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_008 . php . expectf <nl> <nl> ( # 1 ) writing % s = foo | s : 3 : " bar " ; <nl> ( # 1 ) closing % s <nl> done <nl> - ( # 1 ) destructor called <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_009 . php <nl> ppp b / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_009 . php <nl> <nl> <nl> ob_start ( ) ; <nl> <nl> - / * <nl> + / * <nl> * Prototype : bool session_set_save_handler ( SessionHandler $ handler [ , bool $ register_shutdown_function = true ] ) <nl> * Description : Sets user - level session storage functions <nl> - * Source code : ext / session / session . c <nl> + * Source code : ext / session / session . c <nl> * / <nl> <nl> echo " * * * Testing session_set_save_handler ( ) : implicit shutdown * * * \ n " ; <nl> public function __construct ( $ num ) { <nl> $ this - > num = $ num ; <nl> echo " ( # $ this - > num ) constructor called \ n " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " ( # $ this - > num ) destructor called \ n " ; <nl> - } <nl> public function finish ( ) { <nl> $ id = session_id ( ) ; <nl> echo " ( # $ this - > num ) finish called $ id \ n " ; <nl> mmm a / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_009 . php . expectf <nl> ppp b / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_009 . php . expectf <nl> <nl> done <nl> ( # 1 ) writing % s = foo | s : 3 : " bar " ; <nl> ( # 1 ) closing % s <nl> - ( # 1 ) destructor called <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_010 . php <nl> ppp b / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_010 . php <nl> <nl> <nl> ob_start ( ) ; <nl> <nl> - / * <nl> + / * <nl> * Prototype : bool session_set_save_handler ( SessionHandler $ handler [ , bool $ register_shutdown_function = true ] ) <nl> * Description : Sets user - level session storage functions <nl> - * Source code : ext / session / session . c <nl> + * Source code : ext / session / session . c <nl> * / <nl> <nl> echo " * * * Testing session_set_save_handler ( ) : manual shutdown function * * * \ n " ; <nl> public function __construct ( $ num ) { <nl> $ this - > num = $ num ; <nl> echo " ( # $ this - > num ) constructor called \ n " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " ( # $ this - > num ) destructor called \ n " ; <nl> - } <nl> public function finish ( ) { <nl> $ id = session_id ( ) ; <nl> echo " ( # $ this - > num ) finish called $ id \ n " ; <nl> mmm a / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_010 . php . expectf <nl> ppp b / hphp / test / zend / good / ext / session / tests / session_set_save_handler_class_010 . php . expectf <nl> done <nl> ( # 1 ) finish called % s <nl> ( # 1 ) writing % s = foo | s : 3 : " bar " ; <nl> ( # 1 ) closing % s <nl> - ( # 1 ) destructor called <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / ext / spl / tests / iterator_041 . php <nl> ppp b / hphp / test / zend / good / ext / spl / tests / iterator_041 . php <nl> function next ( ) <nl> return parent : : next ( ) ; <nl> } <nl> <nl> - function __destruct ( ) <nl> - { <nl> - / / self : : fail ( 7 , __FUNCTION__ ) ; <nl> - } <nl> - <nl> static function test ( $ func , $ skip = null ) <nl> { <nl> echo " = = = $ func = = = \ n " ; <nl> deleted file mode 100644 <nl> index 22779fd700d . . 00000000000 <nl> mmm a / hphp / test / zend / good / ext / spl / tests / iterator_068 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Test implements Iterator { <nl> - function foo ( ) { <nl> - echo __METHOD__ . " ( ) \ n " ; <nl> - } <nl> - function rewind ( ) { } <nl> - function valid ( ) { } <nl> - function current ( ) { } <nl> - function key ( ) { } <nl> - function next ( ) { } <nl> - } <nl> - <nl> - class TestIteratorIterator extends IteratorIterator { <nl> - function __destruct ( ) { <nl> - echo __METHOD__ . " ( ) \ n " ; <nl> - $ this - > foo ( ) ; <nl> - } <nl> - } <nl> - <nl> - $ obj = new TestIteratorIterator ( new Test ) ; <nl> - $ obj - > foo ( ) ; <nl> - unset ( $ obj ) ; <nl> - <nl> - ? > <nl> - = = = DONE = = = <nl> deleted file mode 100644 <nl> index a811765ff72 . . 00000000000 <nl> mmm a / hphp / test / zend / good / ext / spl / tests / iterator_068 . php . expectf <nl> ppp / dev / null <nl> <nl> - Test : : foo ( ) <nl> - TestIteratorIterator : : __destruct ( ) <nl> - Test : : foo ( ) <nl> - = = = DONE = = = <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / ext / spl / tests / spl_autoload_011 . php <nl> ppp b / hphp / test / zend / good / ext / spl / tests / spl_autoload_011 . php <nl> class A { <nl> public function autoload ( ) { <nl> echo " var : " . $ this - > var . " \ n " ; <nl> } <nl> - public function __destruct ( ) { <nl> - echo " __destruct__ \ n " ; <nl> - } <nl> } <nl> <nl> $ a = new A ; <nl> mmm a / hphp / test / zend / good / ext / spl / tests / spl_autoload_011 . php . expectf <nl> ppp b / hphp / test / zend / good / ext / spl / tests / spl_autoload_011 . php . expectf <nl> <nl> var : 2 <nl> bool ( false ) <nl> = = = DONE = = = <nl> - __destruct__ <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index faeb718283f . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / autoload_005 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - function __autoload ( $ class_name ) <nl> - { <nl> - var_dump ( class_exists ( $ class_name , false ) ) ; <nl> - require_once ( dirname ( __FILE__ ) . ' / ' . $ class_name . ' . p5c ' ) ; <nl> - echo __FUNCTION__ . ' ( ' . $ class_name . " ) \ n " ; <nl> - } <nl> - <nl> - var_dump ( class_exists ( ' autoload_derived ' , false ) ) ; <nl> - var_dump ( class_exists ( ' autoload_derived ' , false ) ) ; <nl> - <nl> - class Test <nl> - { <nl> - function __destruct ( ) { <nl> - echo __METHOD__ . " \ n " ; <nl> - $ o = new autoload_derived ; <nl> - var_dump ( $ o ) ; <nl> - } <nl> - } <nl> - <nl> - $ o = new Test ; <nl> - unset ( $ o ) ; <nl> - <nl> - ? > <nl> - = = = DONE = = = <nl> deleted file mode 100644 <nl> index 12817d263d0 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / autoload_005 . php . expectf <nl> ppp / dev / null <nl> <nl> - bool ( false ) <nl> - bool ( false ) <nl> - Test : : __destruct <nl> - bool ( false ) <nl> - bool ( false ) <nl> - __autoload ( autoload_root ) <nl> - __autoload ( autoload_derived ) <nl> - object ( autoload_derived ) # % d ( 0 ) { <nl> - } <nl> - = = = DONE = = = <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> deleted file mode 100644 <nl> index 43e4f87066e . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / autoload_005 . php . skipif <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - if ( version_compare ( zend_version ( ) , ' 2 . 0 . 0 - dev ' , ' < ' ) ) die ( ' skip ZendEngine 2 needed ' ) ; <nl> - if ( class_exists ( ' autoload_root ' , false ) ) die ( ' skip Autoload test classes exist already ' ) ; <nl> - ? > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 3c9f6330f13 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / bug27468 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class foo { <nl> - function __destruct ( ) { <nl> - foreach ( $ this - > x as $ x ) ; <nl> - } <nl> - } <nl> - new foo ( ) ; <nl> - echo ' OK ' ; <nl> - ? > <nl> deleted file mode 100644 <nl> index 7f3e3fad657 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / bug27468 . php . expectf <nl> ppp / dev / null <nl> <nl> - <nl> - Notice : % s <nl> - <nl> - Warning : % s <nl> - OK <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / tests / classes / ctor_dtor . php <nl> ppp b / hphp / test / zend / good / tests / classes / ctor_dtor . php <nl> class early { <nl> function early ( ) { <nl> echo __CLASS__ . " : : " . __FUNCTION__ . " \ n " ; <nl> } <nl> - function __destruct ( ) { <nl> - echo __CLASS__ . " : : " . __FUNCTION__ . " \ n " ; <nl> - } <nl> } <nl> <nl> class late { <nl> function __construct ( ) { <nl> echo __CLASS__ . " : : " . __FUNCTION__ . " \ n " ; <nl> } <nl> - function __destruct ( ) { <nl> - echo __CLASS__ . " : : " . __FUNCTION__ . " \ n " ; <nl> - } <nl> } <nl> <nl> $ t = new early ( ) ; <nl> mmm a / hphp / test / zend / good / tests / classes / ctor_dtor . php . expectf <nl> ppp b / hphp / test / zend / good / tests / classes / ctor_dtor . php . expectf <nl> <nl> early : : early <nl> early : : early <nl> - early : : __destruct <nl> late : : __construct <nl> Done <nl> - late : : __destruct <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / tests / classes / ctor_dtor_inheritance . php <nl> ppp b / hphp / test / zend / good / tests / classes / ctor_dtor_inheritance . php <nl> <nl> < ? php <nl> <nl> / / This test checks for : <nl> - / / - inherited constructors / destructors are not called automatically <nl> - / / - base classes know about derived properties in constructor / destructor <nl> - / / - base class constructors / destructors know the instanciated class name <nl> + / / - inherited constructors are not called automatically <nl> + / / - base classes know about derived properties in constructor <nl> + / / - base class constructors know the instanciated class name <nl> <nl> class base { <nl> public $ name ; <nl> function __construct ( ) { <nl> $ this - > name = ' base ' ; <nl> print_r ( $ this ) ; <nl> } <nl> - <nl> - function __destruct ( ) { <nl> - echo __CLASS__ . " : : " . __FUNCTION__ . " \ n " ; <nl> - print_r ( $ this ) ; <nl> - } <nl> } <nl> <nl> class derived extends base { <nl> function __construct ( ) { <nl> $ this - > name = ' derived ' ; <nl> print_r ( $ this ) ; <nl> } <nl> - <nl> - function __destruct ( ) { <nl> - parent : : __destruct ( ) ; <nl> - echo __CLASS__ . " : : " . __FUNCTION__ . " \ n " ; <nl> - print_r ( $ this ) ; <nl> - } <nl> } <nl> <nl> echo " Testing class base \ n " ; <nl> mmm a / hphp / test / zend / good / tests / classes / ctor_dtor_inheritance . php . expectf <nl> ppp b / hphp / test / zend / good / tests / classes / ctor_dtor_inheritance . php . expectf <nl> base Object <nl> ( <nl> [ name ] = > base <nl> ) <nl> - base : : __destruct <nl> - base Object <nl> - ( <nl> - [ name ] = > base <nl> - ) <nl> Testing class derived <nl> derived Object <nl> ( <nl> derived Object <nl> [ other ] = > other <nl> [ name ] = > derived <nl> ) <nl> - base : : __destruct <nl> - derived Object <nl> - ( <nl> - [ other ] = > other <nl> - [ name ] = > derived <nl> - ) <nl> - derived : : __destruct <nl> - derived Object <nl> - ( <nl> - [ other ] = > other <nl> - [ name ] = > derived <nl> - ) <nl> - Done <nl> \ No newline at end of file <nl> + Done <nl> mmm a / hphp / test / zend / good / tests / classes / ctor_failure . php <nl> ppp b / hphp / test / zend / good / tests / classes / ctor_failure . php <nl> function __construct ( $ msg ) { <nl> echo __METHOD__ . " ( $ msg ) \ n " ; <nl> throw new Exception ( $ msg ) ; <nl> } <nl> - <nl> - function __destruct ( ) { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> } <nl> <nl> try <nl> deleted file mode 100644 <nl> index 385269378dc . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / destructor_and_echo . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Test <nl> - { <nl> - function __construct ( ) { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> - <nl> - function __destruct ( ) { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> - } <nl> - <nl> - $ o = new Test ; <nl> - <nl> - ? > <nl> - = = = DONE = = = <nl> deleted file mode 100644 <nl> index b57690f1d92 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / destructor_and_echo . php . expectf <nl> ppp / dev / null <nl> <nl> - Test : : __construct <nl> - = = = DONE = = = <nl> - Test : : __destruct <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index ad4af2f8966 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / destructor_and_globals . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - $ test_cnt = 0 ; <nl> - $ test_num = 0 ; <nl> - <nl> - function Show ( ) { <nl> - global $ test_cnt ; <nl> - echo " Count : $ test_cnt \ n " ; <nl> - } <nl> - <nl> - class counter { <nl> - protected $ id ; <nl> - <nl> - public function __construct ( ) { <nl> - global $ test_cnt , $ test_num ; <nl> - $ test_cnt + + ; <nl> - $ this - > id = $ test_num + + ; <nl> - } <nl> - <nl> - public function Show ( ) { <nl> - echo ' Id : ' . $ this - > id . " \ n " ; <nl> - } <nl> - <nl> - / / try protected here <nl> - public function __destruct ( ) { <nl> - global $ test_cnt ; <nl> - $ test_cnt - - ; <nl> - } <nl> - <nl> - static public function destroy ( & $ obj ) { <nl> - $ obj = NULL ; <nl> - } <nl> - } <nl> - Show ( ) ; <nl> - $ obj1 = new counter ; <nl> - $ obj1 - > Show ( ) ; <nl> - Show ( ) ; <nl> - $ obj2 = new counter ; <nl> - $ obj2 - > Show ( ) ; <nl> - Show ( ) ; <nl> - counter : : destroy ( & $ obj1 ) ; <nl> - Show ( ) ; <nl> - / / or uncomment this line and it works <nl> - / / counter : : destroy ( $ obj2 ) ; <nl> - echo " Done \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index b45d3f5c911 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / destructor_and_globals . php . expectf <nl> ppp / dev / null <nl> <nl> - Count : 0 <nl> - Id : 0 <nl> - Count : 1 <nl> - Id : 1 <nl> - Count : 2 <nl> - Count : 1 <nl> - Done <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / tests / classes / destructor_inheritance . php <nl> ppp b / hphp / test / zend / good / tests / classes / destructor_inheritance . php <nl> class base { <nl> function __construct ( ) { <nl> echo __METHOD__ . " \ n " ; <nl> } <nl> - <nl> - function __destruct ( ) { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> } <nl> <nl> class derived extends base { <nl> mmm a / hphp / test / zend / good / tests / classes / destructor_inheritance . php . expectf <nl> ppp b / hphp / test / zend / good / tests / classes / destructor_inheritance . php . expectf <nl> <nl> base : : __construct <nl> - base : : __destruct <nl> - Done <nl> \ No newline at end of file <nl> + Done <nl> deleted file mode 100644 <nl> index d8dcec18cb0 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / destructor_visibility_003 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Base { <nl> - private function __destruct ( ) { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> - } <nl> - <nl> - class Derived extends Base { <nl> - public function __destruct ( ) { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> - } <nl> - <nl> - $ obj = new Derived ; <nl> - <nl> - unset ( $ obj ) ; / / Derived : : __destruct is being called not Base : : __destruct <nl> - <nl> - ? > <nl> - = = = DONE = = = <nl> deleted file mode 100644 <nl> index e15b6751fc9 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / destructor_visibility_003 . php . expectf <nl> ppp / dev / null <nl> <nl> - Derived : : __destruct <nl> - = = = DONE = = = <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 138111c33c9 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / destructor_visibility_003 . php . skipif <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - < ? php if ( version_compare ( zend_version ( ) , ' 2 . 0 . 0 - dev ' , ' < ' ) ) die ( ' skip ZendEngine 2 needed ' ) ; ? > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 356168a5a7a . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / factory_and_singleton_001 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class test { <nl> - protected $ x ; <nl> - <nl> - static private $ test = NULL ; <nl> - static private $ cnt = 0 ; <nl> - <nl> - static function factory ( $ x ) { <nl> - if ( test : : $ test ) { <nl> - return test : : $ test ; <nl> - } else { <nl> - test : : $ test = new test ( $ x ) ; <nl> - return test : : $ test ; <nl> - } <nl> - } <nl> - <nl> - protected function __construct ( $ x ) { <nl> - test : : $ cnt + + ; <nl> - $ this - > x = $ x ; <nl> - } <nl> - <nl> - static function destroy ( ) { <nl> - test : : $ test = NULL ; <nl> - } <nl> - <nl> - protected function __destruct ( ) { <nl> - test : : $ cnt - - ; <nl> - } <nl> - <nl> - public function get ( ) { <nl> - return $ this - > x ; <nl> - } <nl> - <nl> - static public function getX ( ) { <nl> - if ( test : : $ test ) { <nl> - return test : : $ test - > x ; <nl> - } else { <nl> - return NULL ; <nl> - } <nl> - } <nl> - <nl> - static public function count ( ) { <nl> - return test : : $ cnt ; <nl> - } <nl> - } <nl> - <nl> - echo " Access static members \ n " ; <nl> - var_dump ( test : : getX ( ) ) ; <nl> - var_dump ( test : : count ( ) ) ; <nl> - <nl> - echo " Create x and y \ n " ; <nl> - $ x = test : : factory ( 1 ) ; <nl> - $ y = test : : factory ( 2 ) ; <nl> - var_dump ( test : : getX ( ) ) ; <nl> - var_dump ( test : : count ( ) ) ; <nl> - var_dump ( $ x - > get ( ) ) ; <nl> - var_dump ( $ y - > get ( ) ) ; <nl> - <nl> - echo " Destruct x \ n " ; <nl> - $ x = NULL ; <nl> - var_dump ( test : : getX ( ) ) ; <nl> - var_dump ( test : : count ( ) ) ; <nl> - var_dump ( $ y - > get ( ) ) ; <nl> - <nl> - echo " Destruct y \ n " ; <nl> - $ y = NULL ; <nl> - var_dump ( test : : getX ( ) ) ; <nl> - var_dump ( test : : count ( ) ) ; <nl> - <nl> - echo " Destruct static \ n " ; <nl> - test : : destroy ( ) ; <nl> - var_dump ( test : : getX ( ) ) ; <nl> - var_dump ( test : : count ( ) ) ; <nl> - <nl> - echo " Done \ n " ; <nl> - ? > <nl> deleted file mode 100644 <nl> index 1757fc87f9b . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / factory_and_singleton_001 . php . expectf <nl> ppp / dev / null <nl> <nl> - Access static members <nl> - NULL <nl> - int ( 0 ) <nl> - Create x and y <nl> - int ( 1 ) <nl> - int ( 1 ) <nl> - int ( 1 ) <nl> - int ( 1 ) <nl> - Destruct x <nl> - int ( 1 ) <nl> - int ( 1 ) <nl> - int ( 1 ) <nl> - Destruct y <nl> - int ( 1 ) <nl> - int ( 1 ) <nl> - Destruct static <nl> - NULL <nl> - int ( 0 ) <nl> - Done <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 138111c33c9 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / factory_and_singleton_001 . php . skipif <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - < ? php if ( version_compare ( zend_version ( ) , ' 2 . 0 . 0 - dev ' , ' < ' ) ) die ( ' skip ZendEngine 2 needed ' ) ; ? > <nl> \ No newline at end of file <nl> mmm a / hphp / test / zend / good / tests / classes / iterators_002 . php <nl> ppp b / hphp / test / zend / good / tests / classes / iterators_002 . php <nl> function key ( ) { <nl> default : return " ? ? ? " ; <nl> } <nl> } <nl> - function __destruct ( ) { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> } <nl> - <nl> + <nl> class c implements IteratorAggregate { <nl> <nl> public $ max = 3 ; <nl> function getIterator ( ) { <nl> echo __METHOD__ . " \ n " ; <nl> return new c_iter ( $ this ) ; <nl> } <nl> - function __destruct ( ) { <nl> - echo __METHOD__ . " \ n " ; <nl> - } <nl> } <nl> <nl> $ t = new c ( ) ; <nl> mmm a / hphp / test / zend / good / tests / classes / iterators_002 . php . expectf <nl> ppp b / hphp / test / zend / good / tests / classes / iterators_002 . php . expectf <nl> c_iter : : rewind <nl> c_iter : : valid = true <nl> c_iter : : current <nl> double : 0 : 0 <nl> - c_iter : : __destruct <nl> c_iter : : next <nl> c_iter : : valid = true <nl> c_iter : : current <nl> c_iter : : rewind <nl> c_iter : : valid = true <nl> c_iter : : current <nl> double : 1 : 0 <nl> - c_iter : : __destruct <nl> c_iter : : next <nl> c_iter : : valid = true <nl> c_iter : : current <nl> c_iter : : rewind <nl> c_iter : : valid = true <nl> c_iter : : current <nl> double : 2 : 0 <nl> - c_iter : : __destruct <nl> c_iter : : next <nl> c_iter : : valid = false <nl> - c_iter : : __destruct <nl> - c : : __destruct <nl> - Done <nl> \ No newline at end of file <nl> + Done <nl> deleted file mode 100644 <nl> index 9abd217d260 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / tostring_002 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - <nl> - class Test <nl> - { <nl> - function __toString ( ) <nl> - { <nl> - return " Hello \ n " ; <nl> - } <nl> - <nl> - function __destruct ( ) <nl> - { <nl> - echo $ this ; <nl> - } <nl> - } <nl> - <nl> - $ o = new Test ; <nl> - $ o = NULL ; <nl> - <nl> - $ o = new Test ; <nl> - <nl> - ? > <nl> - = = = = DONE = = = = <nl> deleted file mode 100644 <nl> index d8c2144164a . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / tostring_002 . php . expectf <nl> ppp / dev / null <nl> <nl> - Hello <nl> - = = = = DONE = = = = <nl> - Hello <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 138111c33c9 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / classes / tostring_002 . php . skipif <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - < ? php if ( version_compare ( zend_version ( ) , ' 2 . 0 . 0 - dev ' , ' < ' ) ) die ( ' skip ZendEngine 2 needed ' ) ; ? > <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 1330e39a2f4 . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / lang / bug24908 . php <nl> ppp / dev / null <nl> <nl> - < ? php <nl> - class test { <nl> - function __construct ( ) { <nl> - if ( count ( $ _SERVER ) ) echo " O " ; <nl> - } <nl> - function __destruct ( ) { <nl> - if ( count ( $ _SERVER ) ) echo " K \ n " ; <nl> - } <nl> - } <nl> - $ test = new test ( ) ; <nl> - ? > <nl> deleted file mode 100644 <nl> index a0aba9318ad . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / lang / bug24908 . php . expectf <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - OK <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 21bd092d51f . . 00000000000 <nl> mmm a / hphp / test / zend / good / tests / lang / bug24908 . php . ini <nl> ppp / dev / null <nl> <nl> - variables_order = GPS <nl> - hhvm . enable_obj_destruct_call = true <nl> - hhvm . php7 . all = false <nl> mmm a / hphp / test / zend / good / tests / lang / foreachLoopIteratorAggregate . 004 . php <nl> ppp b / hphp / test / zend / good / tests / lang / foreachLoopIteratorAggregate . 004 . php <nl> function key ( ) { <nl> default : return " ? ? ? " ; <nl> } <nl> } <nl> - function __destruct ( ) { <nl> - } <nl> } <nl> - <nl> + <nl> class c implements IteratorAggregate { <nl> <nl> public $ max = 3 ; <nl> function getIterator ( ) { <nl> echo __METHOD__ . " \ n " ; <nl> return new c_iter ( $ this ) ; <nl> } <nl> - function __destruct ( ) { <nl> - } <nl> } <nl> <nl> $ t = new c ( ) ; <nl> mmm a / hphp / tools / hhvm_wrapper . php <nl> ppp b / hphp / tools / hhvm_wrapper . php <nl> function determine_flags ( OptionMap $ opts ) : string { <nl> ' opt - ir ' = > ' - v Eval . HHIRGenerateAsserts = 0 ' , <nl> ' jit - gdb ' = > ' - v Eval . JitNoGdb = false ' , <nl> ' no - pgo ' = > ' - v Eval . JitPGO = false ' , <nl> - ' no - obj - destruct ' = > ' - v Eval . EnableObjDestructCall = 0 ' , <nl> ' hphpd ' = > ' - m debug ' , <nl> ' server ' = > ' - v Eval . JitPGOHotOnly = 0 - m server ' , <nl> } ; <nl>
|
Drop all support for __destruct from hhvm
|
facebook/hhvm
|
4128c2aef3658721261c48f19d1d28a220e43c89
|
2019-02-05T05:30:18Z
|
mmm a / tensorflow / python / training / tracking / util . py <nl> ppp b / tensorflow / python / training / tracking / util . py <nl> def streaming_restore ( status , session = None ) : <nl> # pylint : enable = protected - access <nl> <nl> <nl> + def _objects_with_attributes ( full_list ) : <nl> + " " " Filters out objects with no direct variable dependencies for assertions . " " " <nl> + return [ o for o in full_list if o . _gather_saveables_for_checkpoint ( ) ] # pylint : disable = protected - access <nl> + <nl> + <nl> class CheckpointLoadStatus ( _LoadStatus ) : <nl> " " " Checks the status of checkpoint loading and manages restore ops . <nl> <nl> def assert_consumed ( self ) : <nl> self . _checkpoint . object_graph_proto ) <nl> self . assert_existing_objects_matched ( ) <nl> for node_id , node in enumerate ( self . _checkpoint . object_graph_proto . nodes ) : <nl> + if not node . attributes : <nl> + # Only raise exceptions for the nodes with attributes themselves . Either <nl> + # they ' re ultimately not important , or they have a child with an <nl> + # attribute . <nl> + continue <nl> trackable = self . _checkpoint . object_by_proto_id . get ( node_id , None ) <nl> if trackable is None : <nl> raise AssertionError ( " Unresolved object in checkpoint { } : { } " <nl> def assert_existing_objects_matched ( self ) : <nl> continue <nl> self . _checkpoint . all_python_objects . add ( trackable_object ) <nl> unused_python_objects = ( <nl> - object_identity . ObjectIdentitySet ( self . _checkpoint . all_python_objects ) - <nl> + object_identity . ObjectIdentitySet ( <nl> + _objects_with_attributes ( <nl> + self . _checkpoint . all_python_objects ) ) - <nl> object_identity . ObjectIdentitySet ( <nl> self . _checkpoint . object_by_proto_id . values ( ) ) ) <nl> if unused_python_objects : <nl> def assert_nontrivial_match ( self ) : <nl> self . _checkpoint . all_python_objects . add ( trackable_object ) <nl> if len ( self . _checkpoint . object_by_proto_id ) < = 1 : <nl> unused_python_objects = ( <nl> - object_identity . ObjectIdentitySet ( self . _checkpoint . all_python_objects ) <nl> + object_identity . ObjectIdentitySet ( <nl> + _objects_with_attributes ( self . _checkpoint . all_python_objects ) ) <nl> - object_identity . ObjectIdentitySet ( <nl> self . _checkpoint . object_by_proto_id . values ( ) ) ) <nl> if unused_python_objects : <nl> def __init__ ( self , checkpoint , graph_view ) : <nl> <nl> <nl> def assert_consumed ( self ) : <nl> - " " " Raises an exception if any variables / objects are unmatched . " " " <nl> + " " " Raises an exception if any variables are unmatched . " " " <nl> unused_attributes = list ( self . _checkpoint . unused_attributes . items ( ) ) <nl> if unused_attributes : <nl> unused_attribute_strings = [ <nl> def restore ( self , save_path ) : <nl> The returned status object has the following methods : <nl> <nl> * ` assert_consumed ( ) ` : <nl> - Raises an exception if any variables / objects are unmatched : either <nl> + Raises an exception if any variables are unmatched : either <nl> checkpointed values which don ' t have a matching Python object or <nl> Python objects in the dependency graph with no values in the <nl> checkpoint . This method returns the status object , and so may be <nl> def restore ( self , save_path ) : <nl> The returned status object has the following methods : <nl> <nl> * ` assert_consumed ( ) ` : <nl> - Raises an exception if any variables / objects are unmatched : either <nl> + Raises an exception if any variables are unmatched : either <nl> checkpointed values which don ' t have a matching Python object or <nl> Python objects in the dependency graph with no values in the <nl> checkpoint . This method returns the status object , and so may be <nl> mmm a / tensorflow / python / training / tracking / util_test . py <nl> ppp b / tensorflow / python / training / tracking / util_test . py <nl> def testAmbiguousLoad ( self ) : <nl> load_root . dep_two . dep_three = tracking . AutoTrackable ( ) <nl> trackable_utils . add_variable ( <nl> load_root . dep_one . dep_three , name = " var " , initializer = 0 . ) <nl> + trackable_utils . add_variable ( <nl> + load_root . dep_two . dep_three , name = " var " , initializer = 0 . ) <nl> with self . assertRaises ( AssertionError ) : <nl> status . assert_consumed ( ) <nl> with self . assertRaises ( AssertionError ) : <nl> def testObjectsCombined ( self ) : <nl> self . assertEqual ( 32 . , self . evaluate ( v1 ) ) <nl> self . assertEqual ( 64 . , self . evaluate ( v2 ) ) <nl> <nl> + @ test_util . run_in_graph_and_eager_modes <nl> + def testEmptyContainersIgnored ( self ) : <nl> + checkpoint_directory = self . get_temp_dir ( ) <nl> + save_root = trackable_utils . Checkpoint ( ) <nl> + path = save_root . save ( checkpoint_directory ) <nl> + load_root = trackable_utils . Checkpoint ( ) <nl> + load_root . dep = [ ] <nl> + load_root . dep . append ( [ ] ) <nl> + status = load_root . restore ( path ) <nl> + status . assert_consumed ( ) <nl> + status . assert_existing_objects_matched ( ) <nl> + status . assert_nontrivial_match ( ) <nl> + <nl> @ test_util . run_in_graph_and_eager_modes <nl> def testDependencyLoop ( self ) : <nl> # Note : this test creates garbage during eager execution because it <nl>
|
Checkpointing : Ignore new empty layer containers is assert_existing_objects_matched and assert_consumed
|
tensorflow/tensorflow
|
c56602c0ac991a670b56167b65c453f0479cac54
|
2019-10-31T17:10:16Z
|
mmm a / utils / simple - backport / changelog . sh <nl> ppp b / utils / simple - backport / changelog . sh <nl> <nl> # ! / bin / bash <nl> set - e <nl> <nl> - <nl> script_dir = " $ ( cd " $ ( dirname " $ { BASH_SOURCE [ 0 ] } " ) " > / dev / null 2 > & 1 & & pwd ) " <nl> <nl> from = " $ 1 " <nl>
|
better
|
ClickHouse/ClickHouse
|
6a1b0106ca7a7f5b3f7b104cb23887d5232ebf07
|
2020-08-07T14:52:50Z
|
mmm a / modules / gapi / src / backends / fluid / gfluidbackend . cpp <nl> ppp b / modules / gapi / src / backends / fluid / gfluidbackend . cpp <nl> struct FluidFilterAgent : public FluidAgent <nl> virtual int linesRead ( ) const override ; <nl> public : <nl> using FluidAgent : : FluidAgent ; <nl> + virtual void setInHeight ( int ) override { / * nothing * / } <nl> } ; <nl> <nl> struct FluidResizeAgent : public FluidAgent <nl> struct FluidResizeAgent : public FluidAgent <nl> virtual int linesRead ( ) const override ; <nl> public : <nl> using FluidAgent : : FluidAgent ; <nl> + virtual void setInHeight ( int ) override { / * nothing * / } <nl> } ; <nl> <nl> struct FluidUpscaleAgent : public FluidAgent <nl> struct FluidUpscaleAgent : public FluidAgent <nl> virtual int firstWindow ( ) const override ; <nl> virtual int nextWindow ( ) const override ; <nl> virtual int linesRead ( ) const override ; <nl> + <nl> + int m_inH ; <nl> public : <nl> using FluidAgent : : FluidAgent ; <nl> + virtual void setInHeight ( int h ) override { m_inH = h ; } <nl> } ; <nl> } } / / namespace cv : : gimpl <nl> <nl> static int calcResizeWindow ( int inH , int outH ) <nl> } <nl> } <nl> <nl> - static int maxReadWindow ( const cv : : GFluidKernel & k , int inH , int outH ) <nl> + static int maxLineConsumption ( const cv : : GFluidKernel & k , int inH , int outH , int lpi ) <nl> { <nl> switch ( k . m_kind ) <nl> { <nl> - case cv : : GFluidKernel : : Kind : : Filter : return k . m_window ; break ; <nl> + case cv : : GFluidKernel : : Kind : : Filter : return k . m_window + lpi - 1 ; break ; <nl> case cv : : GFluidKernel : : Kind : : Resize : <nl> { <nl> if ( inH > = outH ) <nl> { <nl> - return calcResizeWindow ( inH , outH ) ; <nl> + / / FIXME : <nl> + / / This is a suboptimal value , can be reduced <nl> + return calcResizeWindow ( inH , outH ) * lpi ; <nl> } <nl> else <nl> { <nl> - / / Upscale always has window of 2 <nl> - return ( inH = = 1 ) ? 1 : 2 ; <nl> + / / FIXME : <nl> + / / This is a suboptimal value , can be reduced <nl> + return ( inH = = 1 ) ? 1 : 2 + lpi - 1 ; <nl> } <nl> } break ; <nl> default : GAPI_Assert ( false ) ; return 0 ; <nl> int cv : : gimpl : : FluidFilterAgent : : linesRead ( ) const <nl> int cv : : gimpl : : FluidResizeAgent : : firstWindow ( ) const <nl> { <nl> auto outIdx = out_buffers [ 0 ] - > priv ( ) . y ( ) ; <nl> - return windowEnd ( outIdx , m_ratio ) - windowStart ( outIdx , m_ratio ) ; <nl> + auto lpi = std : : min ( m_outputLines - m_producedLines , k . m_lpi ) ; <nl> + return windowEnd ( outIdx + lpi - 1 , m_ratio ) - windowStart ( outIdx , m_ratio ) ; <nl> } <nl> <nl> int cv : : gimpl : : FluidResizeAgent : : nextWindow ( ) const <nl> { <nl> auto outIdx = out_buffers [ 0 ] - > priv ( ) . y ( ) ; <nl> - return windowEnd ( outIdx + 1 , m_ratio ) - windowStart ( outIdx + 1 , m_ratio ) ; <nl> + auto lpi = std : : min ( m_outputLines - m_producedLines - k . m_lpi , k . m_lpi ) ; <nl> + auto nextStartIdx = outIdx + 1 + k . m_lpi - 1 ; <nl> + auto nextEndIdx = nextStartIdx + lpi - 1 ; <nl> + return windowEnd ( nextEndIdx , m_ratio ) - windowStart ( nextStartIdx , m_ratio ) ; <nl> } <nl> <nl> int cv : : gimpl : : FluidResizeAgent : : linesRead ( ) const <nl> { <nl> auto outIdx = out_buffers [ 0 ] - > priv ( ) . y ( ) ; <nl> - return windowStart ( outIdx + 1 , m_ratio ) - windowStart ( outIdx , m_ratio ) ; <nl> + return windowStart ( outIdx + 1 + k . m_lpi - 1 , m_ratio ) - windowStart ( outIdx , m_ratio ) ; <nl> } <nl> <nl> int cv : : gimpl : : FluidUpscaleAgent : : firstWindow ( ) const <nl> { <nl> auto outIdx = out_buffers [ 0 ] - > priv ( ) . y ( ) ; <nl> - return upscaleWindowEnd ( outIdx , m_ratio , in_views [ 0 ] . meta ( ) . size . height ) - upscaleWindowStart ( outIdx , m_ratio ) ; <nl> + auto lpi = std : : min ( m_outputLines - m_producedLines , k . m_lpi ) ; <nl> + return upscaleWindowEnd ( outIdx + lpi - 1 , m_ratio , m_inH ) - upscaleWindowStart ( outIdx , m_ratio ) ; <nl> } <nl> <nl> int cv : : gimpl : : FluidUpscaleAgent : : nextWindow ( ) const <nl> { <nl> auto outIdx = out_buffers [ 0 ] - > priv ( ) . y ( ) ; <nl> - return upscaleWindowEnd ( outIdx + 1 , m_ratio , in_views [ 0 ] . meta ( ) . size . height ) - upscaleWindowStart ( outIdx + 1 , m_ratio ) ; <nl> + auto lpi = std : : min ( m_outputLines - m_producedLines - k . m_lpi , k . m_lpi ) ; <nl> + auto nextStartIdx = outIdx + 1 + k . m_lpi - 1 ; <nl> + auto nextEndIdx = nextStartIdx + lpi - 1 ; <nl> + return upscaleWindowEnd ( nextEndIdx , m_ratio , m_inH ) - upscaleWindowStart ( nextStartIdx , m_ratio ) ; <nl> } <nl> <nl> int cv : : gimpl : : FluidUpscaleAgent : : linesRead ( ) const <nl> { <nl> auto outIdx = out_buffers [ 0 ] - > priv ( ) . y ( ) ; <nl> - return upscaleWindowStart ( outIdx + 1 , m_ratio ) - upscaleWindowStart ( outIdx , m_ratio ) ; <nl> + return upscaleWindowStart ( outIdx + 1 + k . m_lpi - 1 , m_ratio ) - upscaleWindowStart ( outIdx , m_ratio ) ; <nl> } <nl> <nl> bool cv : : gimpl : : FluidAgent : : canRead ( ) const <nl> cv : : gimpl : : GFluidExecutable : : GFluidExecutable ( const ade : : Graph & g , <nl> } <nl> } <nl> <nl> + / / cache input height to avoid costly meta ( ) call <nl> + / / ( actually cached and used only in upscale ) <nl> + if ( agent - > in_views [ 0 ] ) <nl> + { <nl> + agent - > setInHeight ( agent - > in_views [ 0 ] . meta ( ) . size . height ) ; <nl> + } <nl> + <nl> / / b . Agent output parameters with Buffer pointers . <nl> agent - > out_buffers . resize ( agent - > op_handle - > outEdges ( ) . size ( ) , nullptr ) ; <nl> for ( auto it : ade : : util : : zip ( ade : : util : : iota ( agent - > out_buffers . size ( ) ) , <nl> void GFluidBackendImpl : : addBackendPasses ( ade : : ExecutionEngineSetupContext & ectx ) <nl> auto & fu = fg . metadata ( node ) . get < FluidUnit > ( ) ; <nl> fu . ratio = ( double ) in_h / out_h ; <nl> <nl> - int w = maxReadWindow ( fu . k , in_h , out_h ) ; <nl> - int line_consumption = fu . k . m_lpi + w - 1 ; <nl> + int line_consumption = maxLineConsumption ( fu . k , in_h , out_h , fu . k . m_lpi ) ; <nl> int border_size = borderSize ( fu . k ) ; <nl> <nl> fu . border_size = border_size ; <nl> mmm a / modules / gapi / src / backends / fluid / gfluidbackend . hpp <nl> ppp b / modules / gapi / src / backends / fluid / gfluidbackend . hpp <nl> struct FluidAgent <nl> bool done ( ) const ; <nl> <nl> void debug ( std : : ostream & os ) ; <nl> - <nl> + / / FIXME : <nl> + / / refactor ( implement a more solid replacement or <nl> + / / drop this method completely ) <nl> + virtual void setInHeight ( int h ) = 0 ; <nl> private : <nl> / / FIXME ! ! ! <nl> / / move to another class <nl> mmm a / modules / gapi / test / gapi_fluid_resize_test . cpp <nl> ppp b / modules / gapi / test / gapi_fluid_resize_test . cpp <nl> GAPI_FLUID_KERNEL ( FCopy , TCopy , false ) <nl> } <nl> } ; <nl> <nl> - GAPI_FLUID_KERNEL ( FResizeNN , cv : : gapi : : core : : GResize , false ) <nl> + GAPI_FLUID_KERNEL ( FResizeNN1Lpi , cv : : gapi : : core : : GResize , false ) <nl> { <nl> static const int Window = 1 ; <nl> static const auto Kind = GFluidKernel : : Kind : : Resize ; <nl> GAPI_FLUID_KERNEL ( FResizeNN , cv : : gapi : : core : : GResize , false ) <nl> cv : : gapi : : fluid : : Buffer & out ) <nl> <nl> { <nl> + auto length = out . length ( ) ; <nl> double vRatio = ( double ) in . meta ( ) . size . height / out . meta ( ) . size . height ; <nl> + double hRatio = ( double ) in . length ( ) / length ; <nl> auto y = out . y ( ) ; <nl> auto inY = in . y ( ) ; <nl> <nl> - auto sy = static_cast < int > ( y * vRatio ) ; <nl> - int idx = sy - inY ; <nl> - <nl> - const auto src = in . InLine < unsigned char > ( idx ) ; <nl> - auto dst = out . OutLine < unsigned char > ( ) ; <nl> + for ( int l = 0 ; l < out . lpi ( ) ; l + + ) <nl> + { <nl> + auto sy = static_cast < int > ( ( y + l ) * vRatio ) ; <nl> + int idx = sy - inY ; <nl> <nl> - double horRatio = ( double ) in . length ( ) / out . length ( ) ; <nl> + const auto src = in . InLine < unsigned char > ( idx ) ; <nl> + auto dst = out . OutLine < unsigned char > ( l ) ; <nl> <nl> - for ( int x = 0 ; x < out . length ( ) ; x + + ) <nl> - { <nl> - auto inX = static_cast < int > ( x * horRatio ) ; <nl> - dst [ x ] = src [ inX ] ; <nl> + for ( int x = 0 ; x < length ; x + + ) <nl> + { <nl> + auto inX = static_cast < int > ( x * hRatio ) ; <nl> + dst [ x ] = src [ inX ] ; <nl> + } <nl> } <nl> } <nl> } ; <nl> template < class Mapper > <nl> inline void calcRow ( const cv : : gapi : : fluid : : View & in , cv : : gapi : : fluid : : Buffer & out , cv : : gapi : : fluid : : Buffer & scratch ) <nl> { <nl> double vRatio = ( double ) in . meta ( ) . size . height / out . meta ( ) . size . height ; <nl> - auto mapY = Mapper : : map ( vRatio , in . y ( ) , in . meta ( ) . size . height , out . y ( ) ) ; <nl> - <nl> - const auto src0 = in . InLine < unsigned char > ( mapY . s0 ) ; <nl> - const auto src1 = in . InLine < unsigned char > ( mapY . s1 ) ; <nl> - <nl> - auto dst = out . OutLine < unsigned char > ( ) ; <nl> auto mapX = scratch . OutLine < typename Mapper : : Unit > ( ) ; <nl> + auto inY = in . y ( ) ; <nl> + auto inH = in . meta ( ) . size . height ; <nl> + auto outY = out . y ( ) ; <nl> + auto length = out . length ( ) ; <nl> <nl> - for ( int x = 0 ; x < out . length ( ) ; x + + ) <nl> + for ( int l = 0 ; l < out . lpi ( ) ; l + + ) <nl> { <nl> - auto alpha0 = mapX [ x ] . alpha0 ; <nl> - auto alpha1 = mapX [ x ] . alpha1 ; <nl> - auto sx0 = mapX [ x ] . s0 ; <nl> - auto sx1 = mapX [ x ] . s1 ; <nl> + auto mapY = Mapper : : map ( vRatio , inY , inH , outY + l ) ; <nl> <nl> - int res0 = src0 [ sx0 ] * alpha0 + src0 [ sx1 ] * alpha1 ; <nl> - int res1 = src1 [ sx0 ] * alpha0 + src1 [ sx1 ] * alpha1 ; <nl> + const auto src0 = in . InLine < unsigned char > ( mapY . s0 ) ; <nl> + const auto src1 = in . InLine < unsigned char > ( mapY . s1 ) ; <nl> <nl> - dst [ x ] = uchar ( ( ( ( mapY . alpha0 * ( res0 > > 4 ) ) > > 16 ) + ( ( mapY . alpha1 * ( res1 > > 4 ) ) > > 16 ) + 2 ) > > 2 ) ; <nl> + auto dst = out . OutLine < unsigned char > ( l ) ; <nl> + <nl> + for ( int x = 0 ; x < length ; x + + ) <nl> + { <nl> + auto alpha0 = mapX [ x ] . alpha0 ; <nl> + auto alpha1 = mapX [ x ] . alpha1 ; <nl> + auto sx0 = mapX [ x ] . s0 ; <nl> + auto sx1 = mapX [ x ] . s1 ; <nl> + <nl> + int res0 = src0 [ sx0 ] * alpha0 + src0 [ sx1 ] * alpha1 ; <nl> + int res1 = src1 [ sx0 ] * alpha0 + src1 [ sx1 ] * alpha1 ; <nl> + <nl> + dst [ x ] = uchar ( ( ( ( mapY . alpha0 * ( res0 > > 4 ) ) > > 16 ) + ( ( mapY . alpha1 * ( res1 > > 4 ) ) > > 16 ) + 2 ) > > 2 ) ; <nl> + } <nl> } <nl> } <nl> } / / namespace func <nl> struct Mapper <nl> } / / namespace areaUpscale <nl> } / / anonymous namespace <nl> <nl> - GAPI_FLUID_KERNEL ( FResizeLinear , cv : : gapi : : core : : GResize , true ) <nl> + GAPI_FLUID_KERNEL ( FResizeLinear1Lpi , cv : : gapi : : core : : GResize , true ) <nl> { <nl> static const int Window = 1 ; <nl> static const auto Kind = GFluidKernel : : Kind : : Resize ; <nl> auto endInCoord = [ ] ( int outCoord , double ratio ) { <nl> } ; <nl> } / / namespace <nl> <nl> - GAPI_FLUID_KERNEL ( FResizeArea , cv : : gapi : : core : : GResize , false ) <nl> + GAPI_FLUID_KERNEL ( FResizeArea1Lpi , cv : : gapi : : core : : GResize , false ) <nl> { <nl> static const int Window = 1 ; <nl> static const auto Kind = GFluidKernel : : Kind : : Resize ; <nl> GAPI_FLUID_KERNEL ( FResizeArea , cv : : gapi : : core : : GResize , false ) <nl> cv : : gapi : : fluid : : Buffer & out ) <nl> <nl> { <nl> - auto y = out . y ( ) ; <nl> + auto firstOutLineIdx = out . y ( ) ; <nl> + auto firstViewLineIdx = in . y ( ) ; <nl> + auto length = out . length ( ) ; <nl> double vRatio = ( double ) in . meta ( ) . size . height / out . meta ( ) . size . height ; <nl> + double hRatio = ( double ) in . length ( ) / length ; <nl> <nl> - int startY = startInCoord ( y , vRatio ) ; <nl> - int endY = endInCoord ( y , vRatio ) ; <nl> - <nl> - auto dst = out . OutLine < unsigned char > ( ) ; <nl> - <nl> - double hRatio = ( double ) in . length ( ) / out . length ( ) ; <nl> - <nl> - for ( int x = 0 ; x < out . length ( ) ; x + + ) <nl> + for ( int l = 0 ; l < out . lpi ( ) ; l + + ) <nl> { <nl> - float res = 0 . 0 ; <nl> + int outY = firstOutLineIdx + l ; <nl> + int startY = startInCoord ( outY , vRatio ) ; <nl> + int endY = endInCoord ( outY , vRatio ) ; <nl> <nl> - int startX = startInCoord ( x , hRatio ) ; <nl> - int endX = endInCoord ( x , hRatio ) ; <nl> + auto dst = out . OutLine < unsigned char > ( l ) ; <nl> <nl> - for ( int inY = startY ; inY < endY ; inY + + ) <nl> + for ( int x = 0 ; x < length ; x + + ) <nl> { <nl> - double startCoordY = inY / vRatio ; <nl> - double endCoordY = startCoordY + 1 / vRatio ; <nl> + float res = 0 . 0 ; <nl> <nl> - if ( startCoordY < y ) startCoordY = y ; <nl> - if ( endCoordY > y + 1 ) endCoordY = y + 1 ; <nl> + int startX = startInCoord ( x , hRatio ) ; <nl> + int endX = endInCoord ( x , hRatio ) ; <nl> <nl> - float fracY = static_cast < float > ( ( inY = = startY | | inY = = endY - 1 ) ? endCoordY - startCoordY : 1 / vRatio ) ; <nl> + for ( int inY = startY ; inY < endY ; inY + + ) <nl> + { <nl> + double startCoordY = inY / vRatio ; <nl> + double endCoordY = startCoordY + 1 / vRatio ; <nl> <nl> - const auto src = in . InLine < unsigned char > ( inY - startY ) ; <nl> + if ( startCoordY < outY ) startCoordY = outY ; <nl> + if ( endCoordY > outY + 1 ) endCoordY = outY + 1 ; <nl> <nl> - float rowSum = 0 . 0f ; <nl> + float fracY = static_cast < float > ( ( inY = = startY | | inY = = endY - 1 ) ? endCoordY - startCoordY : 1 / vRatio ) ; <nl> <nl> - for ( int inX = startX ; inX < endX ; inX + + ) <nl> - { <nl> - double startCoordX = inX / hRatio ; <nl> - double endCoordX = startCoordX + 1 / hRatio ; <nl> + const auto src = in . InLine < unsigned char > ( inY - firstViewLineIdx ) ; <nl> + <nl> + float rowSum = 0 . 0f ; <nl> <nl> - if ( startCoordX < x ) startCoordX = x ; <nl> - if ( endCoordX > x + 1 ) endCoordX = x + 1 ; <nl> + for ( int inX = startX ; inX < endX ; inX + + ) <nl> + { <nl> + double startCoordX = inX / hRatio ; <nl> + double endCoordX = startCoordX + 1 / hRatio ; <nl> <nl> - float fracX = static_cast < float > ( ( inX = = startX | | inX = = endX - 1 ) ? endCoordX - startCoordX : 1 / hRatio ) ; <nl> + if ( startCoordX < x ) startCoordX = x ; <nl> + if ( endCoordX > x + 1 ) endCoordX = x + 1 ; <nl> <nl> - rowSum + = src [ inX ] * fracX ; <nl> + float fracX = static_cast < float > ( ( inX = = startX | | inX = = endX - 1 ) ? endCoordX - startCoordX : 1 / hRatio ) ; <nl> + <nl> + rowSum + = src [ inX ] * fracX ; <nl> + } <nl> + res + = rowSum * fracY ; <nl> } <nl> - res + = rowSum * fracY ; <nl> + dst [ x ] = static_cast < unsigned char > ( std : : rint ( res ) ) ; <nl> } <nl> - dst [ x ] = static_cast < unsigned char > ( std : : rint ( res ) ) ; <nl> } <nl> } <nl> } ; <nl> <nl> - GAPI_FLUID_KERNEL ( FResizeAreaUpscale , cv : : gapi : : core : : GResize , true ) <nl> + GAPI_FLUID_KERNEL ( FResizeAreaUpscale1Lpi , cv : : gapi : : core : : GResize , true ) <nl> { <nl> static const int Window = 1 ; <nl> static const auto Kind = GFluidKernel : : Kind : : Resize ; <nl> GAPI_FLUID_KERNEL ( FResizeAreaUpscale , cv : : gapi : : core : : GResize , true ) <nl> } <nl> } ; <nl> <nl> - static auto fluidResizeTestPackage = [ ] ( int interpolation , cv : : Size szIn , cv : : Size szOut ) <nl> + # define ADD_RESIZE_KERNEL_WITH_LPI ( interp , lpi , scratch ) \ <nl> + struct Resize # # interp # # lpi # # LpiHelper : public FResize # # interp # # 1Lpi { static const int LPI = lpi ; } ; \ <nl> + struct FResize # # interp # # lpi # # Lpi : public cv : : GFluidKernelImpl < Resize # # interp # # lpi # # LpiHelper , cv : : gapi : : core : : GResize , scratch > { } ; <nl> + <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( NN , 2 , false ) <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( NN , 3 , false ) <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( NN , 4 , false ) <nl> + <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( Linear , 2 , true ) <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( Linear , 3 , true ) <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( Linear , 4 , true ) <nl> + <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( Area , 2 , false ) <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( Area , 3 , false ) <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( Area , 4 , false ) <nl> + <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( AreaUpscale , 2 , true ) <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( AreaUpscale , 3 , true ) <nl> + ADD_RESIZE_KERNEL_WITH_LPI ( AreaUpscale , 4 , true ) <nl> + # undef ADD_RESIZE_KERNEL_WITH_LPI <nl> + <nl> + static auto fluidResizeTestPackage = [ ] ( int interpolation , cv : : Size szIn , cv : : Size szOut , int lpi = 1 ) <nl> { <nl> + using namespace cv ; <nl> + using namespace cv : : gapi ; <nl> bool upscale = szIn . width < szOut . width | | szIn . height < szOut . height ; <nl> <nl> - cv : : gapi : : GKernelPackage pkg ; <nl> + # define RESIZE_CASE ( interp , lpi ) \ <nl> + case lpi : pkg = kernels < FCopy , FResize # # interp # # lpi # # Lpi > ( ) ; break ; <nl> + <nl> + # define RESIZE_SWITCH ( interp ) \ <nl> + switch ( lpi ) \ <nl> + { \ <nl> + RESIZE_CASE ( interp , 1 ) \ <nl> + RESIZE_CASE ( interp , 2 ) \ <nl> + RESIZE_CASE ( interp , 3 ) \ <nl> + RESIZE_CASE ( interp , 4 ) \ <nl> + default : CV_Assert ( false ) ; \ <nl> + } <nl> + <nl> + GKernelPackage pkg ; <nl> switch ( interpolation ) <nl> { <nl> - case cv : : INTER_NEAREST : pkg = cv : : gapi : : kernels < FCopy , FResizeNN > ( ) ; break ; <nl> - case cv : : INTER_LINEAR : pkg = cv : : gapi : : kernels < FCopy , FResizeLinear > ( ) ; break ; <nl> - case cv : : INTER_AREA : pkg = upscale ? cv : : gapi : : kernels < FCopy , FResizeAreaUpscale > ( ) <nl> - : cv : : gapi : : kernels < FCopy , FResizeArea > ( ) ; break ; <nl> + case INTER_NEAREST : RESIZE_SWITCH ( NN ) ; break ; <nl> + case INTER_LINEAR : RESIZE_SWITCH ( Linear ) ; break ; <nl> + case INTER_AREA : <nl> + { <nl> + if ( upscale ) <nl> + { <nl> + RESIZE_SWITCH ( AreaUpscale ) <nl> + } <nl> + else <nl> + { <nl> + RESIZE_SWITCH ( Area ) ; <nl> + } <nl> + } break ; <nl> default : CV_Assert ( false ) ; <nl> } <nl> - return cv : : gapi : : combine ( pkg , fluidTestPackage , cv : : unite_policy : : KEEP ) ; <nl> + return combine ( pkg , fluidTestPackage , unite_policy : : KEEP ) ; <nl> + <nl> + # undef RESIZE_SWITCH <nl> + # undef RESIZE_CASE <nl> } ; <nl> <nl> - struct ResizeTestFluid : public TestWithParam < std : : tuple < int , int , cv : : Size , std : : tuple < cv : : Size , cv : : Rect > , double > > { } ; <nl> + struct ResizeTestFluid : public TestWithParam < std : : tuple < int , int , cv : : Size , std : : tuple < cv : : Size , cv : : Rect > , int , double > > { } ; <nl> TEST_P ( ResizeTestFluid , SanityTest ) <nl> { <nl> int type = 0 , interp = 0 ; <nl> cv : : Size sz_in , sz_out ; <nl> + int lpi = 0 ; <nl> double tolerance = 0 . 0 ; <nl> cv : : Rect outRoi ; <nl> std : : tuple < cv : : Size , cv : : Rect > outSizeAndRoi ; <nl> - std : : tie ( type , interp , sz_in , outSizeAndRoi , tolerance ) = GetParam ( ) ; <nl> + std : : tie ( type , interp , sz_in , outSizeAndRoi , lpi , tolerance ) = GetParam ( ) ; <nl> std : : tie ( sz_out , outRoi ) = outSizeAndRoi ; <nl> if ( outRoi = = cv : : Rect { } ) outRoi = { 0 , 0 , sz_out . width , sz_out . height } ; <nl> if ( outRoi . width = = 0 ) outRoi . width = sz_out . width ; <nl> TEST_P ( ResizeTestFluid , SanityTest ) <nl> auto out = cv : : gapi : : resize ( mid , sz_out , fx , fy , interp ) ; <nl> <nl> cv : : GComputation c ( in , out ) ; <nl> - c . apply ( in_mat1 , out_mat , cv : : compile_args ( GFluidOutputRois { { outRoi } } , fluidResizeTestPackage ( interp , sz_in , sz_out ) ) ) ; <nl> + c . apply ( in_mat1 , out_mat , cv : : compile_args ( GFluidOutputRois { { outRoi } } , fluidResizeTestPackage ( interp , sz_in , sz_out , lpi ) ) ) ; <nl> <nl> cv : : Mat mid_mat ; <nl> cv : : blur ( in_mat1 , mid_mat , { 3 , 3 } , { - 1 , - 1 } , cv : : BORDER_REPLICATE ) ; <nl> INSTANTIATE_TEST_CASE_P ( ResizeTestCPU , ResizeTestFluid , <nl> std : : make_tuple ( cv : : Size ( 8 , 4 ) , cv : : Rect { 0 , 0 , 0 , 3 } ) , <nl> std : : make_tuple ( cv : : Size ( 8 , 4 ) , cv : : Rect { 0 , 1 , 0 , 2 } ) , <nl> std : : make_tuple ( cv : : Size ( 8 , 4 ) , cv : : Rect { 0 , 3 , 0 , 1 } ) ) , <nl> + Values ( 1 , 2 , 3 , 4 ) , / / lpi <nl> Values ( 0 . 0 ) ) ) ; <nl> <nl> INSTANTIATE_TEST_CASE_P ( ResizeAreaTestCPU , ResizeTestFluid , <nl> INSTANTIATE_TEST_CASE_P ( ResizeAreaTestCPU , ResizeTestFluid , <nl> std : : make_tuple ( cv : : Size ( 8 , 4 ) , cv : : Rect { 0 , 0 , 0 , 3 } ) , <nl> std : : make_tuple ( cv : : Size ( 8 , 4 ) , cv : : Rect { 0 , 1 , 0 , 2 } ) , <nl> std : : make_tuple ( cv : : Size ( 8 , 4 ) , cv : : Rect { 0 , 3 , 0 , 1 } ) ) , <nl> + Values ( 1 , 2 , 3 , 4 ) , / / lpi <nl> / / Actually this tolerance only for cases where OpenCV <nl> / / uses ResizeAreaFast <nl> Values ( 1 . 0 ) ) ) ; <nl> INSTANTIATE_TEST_CASE_P ( ResizeUpscaleTestCPU , ResizeTestFluid , <nl> std : : make_tuple ( cv : : Size ( 16 , 25 ) , cv : : Rect { 0 , 0 , 16 , 25 } ) , <nl> std : : make_tuple ( cv : : Size ( 16 , 7 ) , cv : : Rect { } ) , <nl> std : : make_tuple ( cv : : Size ( 16 , 8 ) , cv : : Rect { } ) ) , <nl> + Values ( 1 , 2 , 3 , 4 ) , / / lpi <nl> Values ( 0 . 0 ) ) ) ; <nl> <nl> INSTANTIATE_TEST_CASE_P ( ResizeUpscaleOneDimDownscaleAnother , ResizeTestFluid , <nl> INSTANTIATE_TEST_CASE_P ( ResizeUpscaleOneDimDownscaleAnother , ResizeTestFluid , <nl> std : : make_tuple ( cv : : Size ( 5 , 11 ) , cv : : Rect { 0 , 3 , 0 , 3 } ) , <nl> std : : make_tuple ( cv : : Size ( 5 , 11 ) , cv : : Rect { 0 , 6 , 0 , 3 } ) , <nl> std : : make_tuple ( cv : : Size ( 5 , 11 ) , cv : : Rect { 0 , 9 , 0 , 2 } ) ) , <nl> + Values ( 1 , 2 , 3 , 4 ) , / / lpi <nl> Values ( 0 . 0 ) ) ) ; <nl> <nl> INSTANTIATE_TEST_CASE_P ( Resize400_384TestCPU , ResizeTestFluid , <nl> INSTANTIATE_TEST_CASE_P ( Resize400_384TestCPU , ResizeTestFluid , <nl> Values ( cv : : INTER_NEAREST , cv : : INTER_LINEAR , cv : : INTER_AREA ) , <nl> Values ( cv : : Size ( 128 , 400 ) ) , <nl> Values ( std : : make_tuple ( cv : : Size ( 128 , 384 ) , cv : : Rect { } ) ) , <nl> + Values ( 1 , 2 , 3 , 4 ) , / / lpi <nl> Values ( 0 . 0 ) ) ) ; <nl> <nl> INSTANTIATE_TEST_CASE_P ( Resize220_400TestCPU , ResizeTestFluid , <nl> INSTANTIATE_TEST_CASE_P ( Resize220_400TestCPU , ResizeTestFluid , <nl> Values ( cv : : INTER_LINEAR ) , <nl> Values ( cv : : Size ( 220 , 220 ) ) , <nl> Values ( std : : make_tuple ( cv : : Size ( 400 , 400 ) , cv : : Rect { } ) ) , <nl> + Values ( 1 , 2 , 3 , 4 ) , / / lpi <nl> Values ( 0 . 0 ) ) ) ; <nl> <nl> static auto cvBlur = [ ] ( const cv : : Mat & in , cv : : Mat & out , int kernelSize ) <nl>
|
G - API : Introduce LPI ( multiple Lines - Per - Iteration ) support for Resize
|
opencv/opencv
|
922d5796b90072d2c7a9b3ec659b7778eb79e652
|
2018-10-15T14:11:55Z
|
mmm a / dbms / src / IO / AIO . h <nl> ppp b / dbms / src / IO / AIO . h <nl> <nl> <nl> # if ! ( defined ( __FreeBSD__ ) | | defined ( __APPLE__ ) | | defined ( _MSC_VER ) ) <nl> <nl> + # include < boost / noncopyable . hpp > <nl> + <nl> / / / https : / / stackoverflow . com / questions / 20759750 / resolving - redefinition - of - timespec - in - time - h <nl> # define timespec linux_timespec <nl> # define timeval linux_timeval <nl> mmm a / utils / check_include . sh <nl> ppp b / utils / check_include . sh <nl> inc = " - I . \ <nl> - I . / contrib / libmetrohash / src \ <nl> - I . / contrib / double - conversion \ <nl> - I . / contrib / cityhash102 / include \ <nl> + - I . / contrib / murmurhash / include \ <nl> - I . / contrib / zookeeper / src / c / include \ <nl> - I . / contrib / zookeeper / src / c / generated \ <nl> - I . / contrib / libtcmalloc / include \ <nl> if [ - z $ 1 ] ; then <nl> else <nl> echo - n " $ 1 " <nl> echo - n ` grep " # include " $ 1 | wc - l ` " " <nl> - echo - e " # include < $ 1 > \ n int main ( ) { return 0 ; } " | time - - format " % e % M " $ { CXX : = g + + - 7 } - c - std = c + + 1z $ inc - x c + + - <nl> + echo " # include < $ 1 > \ n int main ( ) { return 0 ; } " | time - - format " % e % M " $ { CXX : = g + + - 7 } - c - std = c + + 1z $ inc - x c + + - <nl> fi <nl>
|
fix
|
ClickHouse/ClickHouse
|
300457da7acc6af4c9bfe3feab724ec4e9d02877
|
2018-08-21T18:35:47Z
|
mmm a / scripting / javascript / bindings / ScriptingCore . cpp <nl> ppp b / scripting / javascript / bindings / ScriptingCore . cpp <nl> JSBool jsval_to_ccsize ( JSContext * cx , jsval v , Size * ret ) { <nl> return JS_TRUE ; <nl> } <nl> <nl> - JSBool jsval_to_Color4B ( JSContext * cx , jsval v , Color4B * ret ) { <nl> + JSBool jsval_to_cccolor4b ( JSContext * cx , jsval v , Color4B * ret ) { <nl> JSObject * tmp ; <nl> jsval jsr , jsg , jsb , jsa ; <nl> double r , g , b , a ; <nl> JSBool jsval_to_Color4B ( JSContext * cx , jsval v , Color4B * ret ) { <nl> return JS_TRUE ; <nl> } <nl> <nl> - JSBool jsval_to_Color4F ( JSContext * cx , jsval v , Color4F * ret ) { <nl> + JSBool jsval_to_cccolor4f ( JSContext * cx , jsval v , Color4F * ret ) { <nl> JSObject * tmp ; <nl> jsval jsr , jsg , jsb , jsa ; <nl> double r , g , b , a ; <nl> JSBool jsval_to_Color4F ( JSContext * cx , jsval v , Color4F * ret ) { <nl> return JS_TRUE ; <nl> } <nl> <nl> - JSBool jsval_to_Color3B ( JSContext * cx , jsval v , Color3B * ret ) { <nl> + JSBool jsval_to_cccolor3b ( JSContext * cx , jsval v , Color3B * ret ) { <nl> JSObject * tmp ; <nl> jsval jsr , jsg , jsb ; <nl> double r , g , b ; <nl> jsval long_long_to_jsval ( JSContext * cx , long long v ) { <nl> return OBJECT_TO_JSVAL ( tmp ) ; <nl> } <nl> <nl> - jsval std_string_to_jsval ( JSContext * cx , std : : string & v ) { <nl> + jsval std_string_to_jsval ( JSContext * cx , const std : : string & v ) { <nl> return c_string_to_jsval ( cx , v . c_str ( ) ) ; <nl> } <nl> <nl> jsval c_string_to_jsval ( JSContext * cx , const char * v , size_t length / * = - 1 * / ) <nl> return ret ; <nl> } <nl> <nl> - jsval ccpoint_to_jsval ( JSContext * cx , Point & v ) { <nl> + jsval ccpoint_to_jsval ( JSContext * cx , const Point & v ) { <nl> JSObject * tmp = JS_NewObject ( cx , NULL , NULL , NULL ) ; <nl> if ( ! tmp ) return JSVAL_NULL ; <nl> JSBool ok = JS_DefineProperty ( cx , tmp , " x " , DOUBLE_TO_JSVAL ( v . x ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) & & <nl> jsval ccpoint_to_jsval ( JSContext * cx , Point & v ) { <nl> return JSVAL_NULL ; <nl> } <nl> <nl> - jsval ccacceleration_to_jsval ( JSContext * cx , Acceleration & v ) { <nl> + jsval ccacceleration_to_jsval ( JSContext * cx , const Acceleration & v ) { <nl> JSObject * tmp = JS_NewObject ( cx , NULL , NULL , NULL ) ; <nl> if ( ! tmp ) return JSVAL_NULL ; <nl> JSBool ok = JS_DefineProperty ( cx , tmp , " x " , DOUBLE_TO_JSVAL ( v . x ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) & & <nl> jsval ccacceleration_to_jsval ( JSContext * cx , Acceleration & v ) { <nl> return JSVAL_NULL ; <nl> } <nl> <nl> - jsval ccrect_to_jsval ( JSContext * cx , Rect & v ) { <nl> + jsval ccrect_to_jsval ( JSContext * cx , const Rect & v ) { <nl> JSObject * tmp = JS_NewObject ( cx , NULL , NULL , NULL ) ; <nl> if ( ! tmp ) return JSVAL_NULL ; <nl> JSBool ok = JS_DefineProperty ( cx , tmp , " x " , DOUBLE_TO_JSVAL ( v . origin . x ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) & & <nl> jsval ccrect_to_jsval ( JSContext * cx , Rect & v ) { <nl> return JSVAL_NULL ; <nl> } <nl> <nl> - jsval ccsize_to_jsval ( JSContext * cx , Size & v ) { <nl> + jsval ccsize_to_jsval ( JSContext * cx , const Size & v ) { <nl> JSObject * tmp = JS_NewObject ( cx , NULL , NULL , NULL ) ; <nl> if ( ! tmp ) return JSVAL_NULL ; <nl> JSBool ok = JS_DefineProperty ( cx , tmp , " width " , DOUBLE_TO_JSVAL ( v . width ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) & & <nl> jsval ccsize_to_jsval ( JSContext * cx , Size & v ) { <nl> return JSVAL_NULL ; <nl> } <nl> <nl> - jsval Color4B_to_jsval ( JSContext * cx , Color4B & v ) { <nl> + jsval cccolor4b_to_jsval ( JSContext * cx , const Color4B & v ) { <nl> JSObject * tmp = JS_NewObject ( cx , NULL , NULL , NULL ) ; <nl> if ( ! tmp ) return JSVAL_NULL ; <nl> JSBool ok = JS_DefineProperty ( cx , tmp , " r " , INT_TO_JSVAL ( v . r ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) & & <nl> jsval Color4B_to_jsval ( JSContext * cx , Color4B & v ) { <nl> return JSVAL_NULL ; <nl> } <nl> <nl> - jsval Color4F_to_jsval ( JSContext * cx , Color4F & v ) { <nl> + jsval cccolor4f_to_jsval ( JSContext * cx , const Color4F & v ) { <nl> JSObject * tmp = JS_NewObject ( cx , NULL , NULL , NULL ) ; <nl> if ( ! tmp ) return JSVAL_NULL ; <nl> JSBool ok = JS_DefineProperty ( cx , tmp , " r " , DOUBLE_TO_JSVAL ( v . r ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) & & <nl> jsval Color4F_to_jsval ( JSContext * cx , Color4F & v ) { <nl> return JSVAL_NULL ; <nl> } <nl> <nl> - jsval Color3B_to_jsval ( JSContext * cx , const Color3B & v ) { <nl> + jsval cccolor3b_to_jsval ( JSContext * cx , const Color3B & v ) { <nl> JSObject * tmp = JS_NewObject ( cx , NULL , NULL , NULL ) ; <nl> if ( ! tmp ) return JSVAL_NULL ; <nl> JSBool ok = JS_DefineProperty ( cx , tmp , " r " , INT_TO_JSVAL ( v . r ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) & & <nl> jsval Color3B_to_jsval ( JSContext * cx , const Color3B & v ) { <nl> return JSVAL_NULL ; <nl> } <nl> <nl> - jsval ccaffinetransform_to_jsval ( JSContext * cx , AffineTransform & t ) <nl> + jsval ccaffinetransform_to_jsval ( JSContext * cx , const AffineTransform & t ) <nl> { <nl> JSObject * tmp = JS_NewObject ( cx , NULL , NULL , NULL ) ; <nl> if ( ! tmp ) return JSVAL_NULL ; <nl> jsval ccaffinetransform_to_jsval ( JSContext * cx , AffineTransform & t ) <nl> return JSVAL_NULL ; <nl> } <nl> <nl> + jsval FontDefinition_to_jsval ( JSContext * cx , const FontDefinition & t ) <nl> + { <nl> + JSObject * tmp = JS_NewObject ( cx , NULL , NULL , NULL ) ; <nl> + if ( ! tmp ) return JSVAL_NULL ; <nl> + JSBool ok = JS_TRUE ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " fontName " , std_string_to_jsval ( cx , t . _fontName ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " fontSize " , int32_to_jsval ( cx , t . _fontSize ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " fontAlignmentH " , int32_to_jsval ( cx , t . _alignment ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " fontAlignmentV " , int32_to_jsval ( cx , t . _vertAlignment ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " fontFillColor " , cccolor3b_to_jsval ( cx , t . _fontFillColor ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " fontDimensions " , ccsize_to_jsval ( cx , t . _dimensions ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + / / Shadow <nl> + ok & = JS_DefineProperty ( cx , tmp , " shadowEnabled " , BOOLEAN_TO_JSVAL ( t . _shadow . _shadowEnabled ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " shadowOffset " , ccsize_to_jsval ( cx , t . _shadow . _shadowOffset ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " shadowBlur " , DOUBLE_TO_JSVAL ( t . _shadow . _shadowBlur ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " shadowOpacity " , DOUBLE_TO_JSVAL ( t . _shadow . _shadowOpacity ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + / / Stroke <nl> + ok & = JS_DefineProperty ( cx , tmp , " strokeEnabled " , BOOLEAN_TO_JSVAL ( t . _stroke . _strokeEnabled ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " strokeColor " , cccolor3b_to_jsval ( cx , t . _stroke . _strokeColor ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + ok & = JS_DefineProperty ( cx , tmp , " strokeSize " , DOUBLE_TO_JSVAL ( t . _stroke . _strokeSize ) , NULL , NULL , JSPROP_ENUMERATE | JSPROP_PERMANENT ) ; <nl> + <nl> + if ( ok ) { <nl> + return OBJECT_TO_JSVAL ( tmp ) ; <nl> + } <nl> + return JSVAL_NULL ; <nl> + } <nl> + <nl> # pragma mark - Debug <nl> <nl> void SimpleRunLoop : : update ( float dt ) { <nl> static void serverEntryPoint ( void ) <nl> } / / while ( true ) <nl> } <nl> <nl> - Color3B getColorFromJSObject ( JSContext * cx , JSObject * colorObject ) <nl> + static Color3B getColorFromJSObject ( JSContext * cx , JSObject * colorObject ) <nl> { <nl> jsval jsr ; <nl> Color3B out ; <nl> Size getSizeFromJSObject ( JSContext * cx , JSObject * sizeObject ) <nl> return out ; <nl> } <nl> <nl> - JSBool jsval_to_ccfontdefinition ( JSContext * cx , jsval vp , FontDefinition * out ) <nl> + JSBool jsval_to_FontDefinition ( JSContext * cx , jsval vp , FontDefinition * out ) <nl> { <nl> JSObject * jsobj ; <nl> <nl> mmm a / scripting / javascript / bindings / ScriptingCore . h <nl> ppp b / scripting / javascript / bindings / ScriptingCore . h <nl> JSBool jsval_to_std_string ( JSContext * cx , jsval v , std : : string * ret ) ; <nl> JSBool jsval_to_ccpoint ( JSContext * cx , jsval v , Point * ret ) ; <nl> JSBool jsval_to_ccrect ( JSContext * cx , jsval v , Rect * ret ) ; <nl> JSBool jsval_to_ccsize ( JSContext * cx , jsval v , Size * ret ) ; <nl> - JSBool jsval_to_Color4B ( JSContext * cx , jsval v , Color4B * ret ) ; <nl> - JSBool jsval_to_Color4F ( JSContext * cx , jsval v , Color4F * ret ) ; <nl> - JSBool jsval_to_Color3B ( JSContext * cx , jsval v , Color3B * ret ) ; <nl> + JSBool jsval_to_cccolor4b ( JSContext * cx , jsval v , Color4B * ret ) ; <nl> + JSBool jsval_to_cccolor4f ( JSContext * cx , jsval v , Color4F * ret ) ; <nl> + JSBool jsval_to_cccolor3b ( JSContext * cx , jsval v , Color3B * ret ) ; <nl> JSBool jsval_to_ccarray_of_CCPoint ( JSContext * cx , jsval v , Point * * points , int * numPoints ) ; <nl> JSBool jsval_to_ccarray ( JSContext * cx , jsval v , Array * * ret ) ; <nl> JSBool jsval_to_ccdictionary ( JSContext * cx , jsval v , Dictionary * * ret ) ; <nl> JSBool jsval_to_ccacceleration ( JSContext * cx , jsval v , Acceleration * ret ) ; <nl> JSBool jsvals_variadic_to_ccarray ( JSContext * cx , jsval * vp , int argc , Array * * ret ) ; <nl> JSBool jsval_to_ccaffinetransform ( JSContext * cx , jsval v , AffineTransform * ret ) ; <nl> - JSBool jsval_to_Vertex2F ( JSContext * cx , jsval vp , Vertex2F * out ) ; <nl> + JSBool jsval_to_FontDefinition ( JSContext * cx , jsval vp , FontDefinition * ret ) ; <nl> <nl> / / from native <nl> jsval int32_to_jsval ( JSContext * cx , int32_t l ) ; <nl> jsval uint32_to_jsval ( JSContext * cx , uint32_t number ) ; <nl> jsval long_long_to_jsval ( JSContext * cx , long long v ) ; <nl> - jsval std_string_to_jsval ( JSContext * cx , string & v ) ; <nl> + jsval std_string_to_jsval ( JSContext * cx , const string & v ) ; <nl> jsval c_string_to_jsval ( JSContext * cx , const char * v , size_t length = - 1 ) ; <nl> - jsval ccpoint_to_jsval ( JSContext * cx , Point & v ) ; <nl> - jsval ccrect_to_jsval ( JSContext * cx , Rect & v ) ; <nl> - jsval ccsize_to_jsval ( JSContext * cx , Size & v ) ; <nl> - jsval Color4B_to_jsval ( JSContext * cx , Color4B & v ) ; <nl> - jsval Color4F_to_jsval ( JSContext * cx , Color4F & v ) ; <nl> - jsval Color3B_to_jsval ( JSContext * cx , const Color3B & v ) ; <nl> + jsval ccpoint_to_jsval ( JSContext * cx , const Point & v ) ; <nl> + jsval ccrect_to_jsval ( JSContext * cx , const Rect & v ) ; <nl> + jsval ccsize_to_jsval ( JSContext * cx , const Size & v ) ; <nl> + jsval cccolor4b_to_jsval ( JSContext * cx , const Color4B & v ) ; <nl> + jsval cccolor4f_to_jsval ( JSContext * cx , const Color4F & v ) ; <nl> + jsval cccolor3b_to_jsval ( JSContext * cx , const Color3B & v ) ; <nl> jsval ccdictionary_to_jsval ( JSContext * cx , Dictionary * dict ) ; <nl> jsval ccarray_to_jsval ( JSContext * cx , Array * arr ) ; <nl> - jsval ccacceleration_to_jsval ( JSContext * cx , Acceleration & v ) ; <nl> - jsval ccaffinetransform_to_jsval ( JSContext * cx , AffineTransform & t ) ; <nl> - <nl> + jsval ccacceleration_to_jsval ( JSContext * cx , const Acceleration & v ) ; <nl> + jsval ccaffinetransform_to_jsval ( JSContext * cx , const AffineTransform & t ) ; <nl> + jsval FontDefinition_to_jsval ( JSContext * cx , const FontDefinition & t ) ; <nl> <nl> JSObject * NewGlobalObject ( JSContext * cx , bool debug = false ) ; <nl> JSBool jsStartDebugger ( JSContext * cx , unsigned argc , jsval * vp ) ; <nl>
|
issue : Adding ' FontDefinition_to_jsval ' and reverting some changes .
|
cocos2d/cocos2d-x
|
17e1b656462ca1c6492a27a36717832e82233425
|
2013-07-08T07:18:57Z
|
mmm a / include / swift / SILAnalysis / AliasAnalysis . h <nl> ppp b / include / swift / SILAnalysis / AliasAnalysis . h <nl> namespace swift { <nl> <nl> class SILValue ; <nl> class SILInstruction ; <nl> - class SideEffectAnalysis ; <nl> <nl> / / / This class is a simple wrapper around an alias analysis cache . This is <nl> / / / needed since we do not have an " analysis " infrastructure . <nl> class AliasAnalysis : public SILAnalysis { <nl> using AliasCacheKey = std : : pair < SILValue , SILValue > ; <nl> llvm : : DenseMap < AliasCacheKey , AliasResult > AliasCache ; <nl> SILModule * Mod ; <nl> - SideEffectAnalysis * SEA ; <nl> <nl> using MemoryBehavior = SILInstruction : : MemoryBehavior ; <nl> <nl> AliasResult cacheValue ( AliasCacheKey Key , AliasResult Result ) ; <nl> <nl> public : <nl> - AliasAnalysis ( SILModule * M ) : <nl> - SILAnalysis ( AnalysisKind : : Alias ) , Mod ( M ) , SEA ( nullptr ) { } <nl> + AliasAnalysis ( SILModule * M ) : SILAnalysis ( AnalysisKind : : Alias ) , Mod ( M ) { } <nl> <nl> static bool classof ( const SILAnalysis * S ) { <nl> return S - > getKind ( ) = = AnalysisKind : : Alias ; <nl> } <nl> - <nl> - virtual void initialize ( SILPassManager * PM ) ; <nl> - <nl> - SideEffectAnalysis * getSideEffectAnalysis ( ) const { return SEA ; } <nl> <nl> / / / Perform an alias query to see if V1 , V2 refer to the same values . <nl> AliasResult alias ( SILValue V1 , SILValue V2 , SILType TBAAType1 = SILType ( ) , <nl> mmm a / include / swift / SILPasses / Passes . def <nl> ppp b / include / swift / SILPasses / Passes . def <nl> PASS ( MandatoryInlining , " mandatory - inlining " , <nl> " Inline transparent functions " ) <nl> PASS ( Mem2Reg , " mem2reg " , <nl> " Promote stack allocations to SSA values " ) <nl> - PASS ( MemBehaviorDumper , " mem - behavior - dump " , <nl> - " Dump MemBehavior results from alias analysis for all instruction pairs " ) <nl> PASS ( MergeCondFails , " merge - cond_fails " , <nl> " Remove redundant overflow checks " ) <nl> PASS ( NoReturnFolding , " noreturn - folding " , <nl> mmm a / lib / SILAnalysis / AliasAnalysis . cpp <nl> ppp b / lib / SILAnalysis / AliasAnalysis . cpp <nl> <nl> # define DEBUG_TYPE " sil - aa " <nl> # include " swift / SILAnalysis / AliasAnalysis . h " <nl> # include " swift / SILAnalysis / ValueTracking . h " <nl> - # include " swift / SILAnalysis / SideEffectAnalysis . h " <nl> # include " swift / SILPasses / Utils / Local . h " <nl> - # include " swift / SILPasses / PassManager . h " <nl> # include " swift / SIL / Projection . h " <nl> # include " swift / SIL / SILValue . h " <nl> # include " swift / SIL / SILInstruction . h " <nl> class MemoryBehaviorVisitor <nl> return Behavior ; <nl> } <nl> } <nl> - <nl> - / / / Get the memory behavior from function side - effects . <nl> - MemBehavior getMemBehavior ( const SideEffectAnalysis : : Effects & E ) ; <nl> <nl> MemBehavior visitLoadInst ( LoadInst * LI ) ; <nl> MemBehavior visitStoreInst ( StoreInst * SI ) ; <nl> MemBehavior MemoryBehaviorVisitor : : visitBuiltinInst ( BuiltinInst * BI ) { <nl> return MemBehavior : : MayHaveSideEffects ; <nl> } <nl> <nl> - MemBehavior MemoryBehaviorVisitor : : getMemBehavior ( <nl> - const SideEffectAnalysis : : Effects & E ) { <nl> - if ( E . mayRelease ( ) ) <nl> - return MemBehavior : : MayHaveSideEffects ; <nl> - <nl> - if ( ! IgnoreRefCountIncrements & & E . mayRetain ( ) ) <nl> - return MemBehavior : : MayHaveSideEffects ; <nl> - <nl> - if ( E . mayWrite ( ) ) <nl> - return E . mayRead ( ) ? MemBehavior : : MayReadWrite : MemBehavior : : MayWrite ; <nl> - <nl> - if ( E . mayRead ( ) ) <nl> - return MemBehavior : : MayRead ; <nl> - <nl> - return MemBehavior : : None ; <nl> - } <nl> - <nl> MemBehavior MemoryBehaviorVisitor : : visitApplyInst ( ApplyInst * AI ) { <nl> - <nl> - SideEffectAnalysis : : FunctionEffects ApplyEffects ; <nl> - AA . getSideEffectAnalysis ( ) - > getEffects ( ApplyEffects , AI ) ; <nl> - <nl> - MemBehavior Behavior = MemBehavior : : None ; <nl> - <nl> - / / We can ignore mayTrap ( ) . <nl> - if ( ApplyEffects . mayReadRC ( ) | | <nl> - ( ! IgnoreRefCountIncrements & & ApplyEffects . mayAllocObjects ( ) ) ) { <nl> - Behavior = MemBehavior : : MayHaveSideEffects ; <nl> - } else { <nl> - auto & GlobalEffects = ApplyEffects . getGlobalEffects ( ) ; <nl> - Behavior = getMemBehavior ( GlobalEffects ) ; <nl> - <nl> - / / Check all parameter effects . <nl> - for ( unsigned Idx = 0 , End = AI - > getNumArguments ( ) ; <nl> - Idx < End & & Behavior < MemBehavior : : MayHaveSideEffects ; <nl> - + + Idx ) { <nl> - auto & ArgEffect = ApplyEffects . getParameterEffects ( ) [ Idx ] ; <nl> - auto ArgBehavior = getMemBehavior ( ArgEffect ) ; <nl> - if ( ArgBehavior > Behavior ) { <nl> - SILValue Arg = AI - > getArgument ( Idx ) ; <nl> - / / We only consider the argument effects if the argument aliases V . <nl> - if ( ! Arg . getType ( ) . isAddress ( ) | | <nl> - ! AA . isNoAlias ( Arg , V , Arg . getType ( ) , findTypedAccessType ( V ) ) ) { <nl> - Behavior = ArgBehavior ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - if ( Behavior > MemBehavior : : MayRead & & isLetPointer ( V ) ) <nl> - Behavior = MemBehavior : : MayRead ; <nl> + if ( isLetPointer ( V ) ) <nl> + return MemBehavior : : MayRead ; <nl> <nl> - DEBUG ( llvm : : dbgs ( ) < < " Found apply , returning " < < Behavior < < ' \ n ' ) ; <nl> - return Behavior ; <nl> + DEBUG ( llvm : : dbgs ( ) < < " Found apply we don ' t understand returning " <nl> + " MHSF . \ n " ) ; <nl> + return MemBehavior : : MayHaveSideEffects ; <nl> } <nl> <nl> SILInstruction : : MemoryBehavior <nl> AliasAnalysis : : AliasResult AliasAnalysis : : cacheValue ( AliasCacheKey Key , <nl> return AliasCache [ Key ] = Result ; <nl> } <nl> <nl> - void AliasAnalysis : : initialize ( SILPassManager * PM ) { <nl> - SEA = PM - > getAnalysis < SideEffectAnalysis > ( ) ; <nl> - } <nl> - <nl> SILAnalysis * swift : : createAliasAnalysis ( SILModule * M ) { <nl> return new AliasAnalysis ( M ) ; <nl> } <nl> mmm a / lib / SILPasses / AADumper . cpp <nl> ppp b / lib / SILPasses / AADumper . cpp <nl> <nl> # include " swift / SIL / SILFunction . h " <nl> # include " swift / SIL / SILValue . h " <nl> # include " swift / SILAnalysis / AliasAnalysis . h " <nl> - # include " swift / SILAnalysis / SideEffectAnalysis . h " <nl> # include " swift / SILAnalysis / Analysis . h " <nl> # include " swift / SILPasses / Transforms . h " <nl> # include " llvm / Support / Debug . h " <nl> static bool gatherValues ( SILFunction & Fn , std : : vector < SILValue > & Values ) { <nl> <nl> namespace { <nl> <nl> - / / / Dumps the alias relations between all instructions of a function . <nl> class SILAADumper : public SILFunctionTransform { <nl> <nl> void run ( ) override { <nl> class SILAADumper : public SILFunctionTransform { <nl> StringRef getName ( ) override { return " AA Dumper " ; } <nl> } ; <nl> <nl> - / / / Dumps the memory behavior of instructions in a function . <nl> - class MemBehaviorDumper : public SILFunctionTransform { <nl> - <nl> - / / To reduce the amount of output , we only dump the memory behavior of <nl> - / / selected types of instructions . <nl> - static bool shouldTestInstruction ( SILInstruction * I ) { <nl> - / / Only consider function calls . <nl> - if ( FullApplySite : : isa ( I ) ) <nl> - return true ; <nl> - <nl> - return false ; <nl> - } <nl> - <nl> - void run ( ) override { <nl> - SILFunction & Fn = * getFunction ( ) ; <nl> - llvm : : outs ( ) < < " @ " < < Fn . getName ( ) < < " \ n " ; <nl> - / / Gather up all Values in Fn . <nl> - std : : vector < SILValue > Values ; <nl> - if ( ! gatherValues ( Fn , Values ) ) <nl> - return ; <nl> - <nl> - AliasAnalysis * AA = PM - > getAnalysis < AliasAnalysis > ( ) ; <nl> - SideEffectAnalysis * SEA = PM - > getAnalysis < SideEffectAnalysis > ( ) ; <nl> - SEA - > recompute ( ) ; <nl> - <nl> - unsigned PairCount = 0 ; <nl> - for ( auto & BB : Fn ) { <nl> - for ( auto & I : BB ) { <nl> - if ( shouldTestInstruction ( & I ) ) { <nl> - <nl> - / / Print the memory behavior in relation to all other values in the <nl> - / / function . <nl> - for ( auto & V : Values ) { <nl> - bool Read = AA - > mayReadFromMemory ( & I , V ) ; <nl> - bool Write = AA - > mayWriteToMemory ( & I , V ) ; <nl> - bool SideEffects = AA - > mayHaveSideEffects ( & I , V ) ; <nl> - llvm : : outs ( ) < < <nl> - " PAIR # " < < PairCount + + < < " . \ n " < < <nl> - " " < < SILValue ( & I ) < < <nl> - " " < < V < < <nl> - " r = " < < Read < < " , w = " < < Write < < " , se = " < < SideEffects < < " \ n " ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - llvm : : outs ( ) < < " \ n " ; <nl> - } <nl> - <nl> - StringRef getName ( ) override { return " Memory Behavior Dumper " ; } <nl> - } ; <nl> - <nl> } / / end anonymous namespace <nl> <nl> SILTransform * swift : : createAADumper ( ) { return new SILAADumper ( ) ; } <nl> - <nl> - SILTransform * swift : : createMemBehaviorDumper ( ) { <nl> - return new MemBehaviorDumper ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 130df01fce8d . . 000000000000 <nl> mmm a / test / SILAnalysis / mem - behavior . sil <nl> ppp / dev / null <nl> <nl> - / / RUN : % target - sil - opt % s - aa = basic - aa - mem - behavior - dump - o / dev / null | FileCheck % s <nl> - <nl> - / / REQUIRES : asserts <nl> - <nl> - import Builtin <nl> - import Swift <nl> - <nl> - class X { <nl> - @ sil_stored var a : Int32 <nl> - @ sil_stored var x : X <nl> - <nl> - init ( ) <nl> - } <nl> - <nl> - sil @ unknown_func : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - <nl> - sil @ store_to_int : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) { <nl> - bb0 ( % 0 : $ Int32 , % 1 : $ * Int32 ) : <nl> - store % 0 to % 1 : $ * Int32 <nl> - % r = tuple ( ) <nl> - return % r : $ ( ) <nl> - } <nl> - <nl> - sil @ only_retain : $ @ convention ( thin ) ( @ guaranteed X ) - > ( ) { <nl> - bb0 ( % 0 : $ X ) : <nl> - strong_retain % 0 : $ X <nl> - <nl> - % r = tuple ( ) <nl> - return % r : $ ( ) <nl> - } <nl> - <nl> - / / CHECK - LABEL : @ call_unknown_func <nl> - / / CHECK : PAIR # 1 . <nl> - / / CHECK - NEXT : ( 0 ) : % 4 = apply % 3 ( % 0 , % 1 ) : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - / / CHECK - NEXT : ( 0 ) : % 1 = argument of bb0 : $ * Int32 / / user : % 4 <nl> - / / CHECK - NEXT : r = 1 , w = 1 , se = 1 <nl> - / / CHECK : PAIR # 2 . <nl> - / / CHECK - NEXT : ( 0 ) : % 4 = apply % 3 ( % 0 , % 1 ) : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - / / CHECK - NEXT : ( 0 ) : % 2 = argument of bb0 : $ * Int32 <nl> - / / CHECK - NEXT : r = 1 , w = 1 , se = 1 <nl> - sil @ call_unknown_func : $ @ convention ( thin ) ( Int32 , @ inout Int32 , @ inout Int32 ) - > ( ) { <nl> - bb0 ( % 0 : $ Int32 , % 1 : $ * Int32 , % 2 : $ * Int32 ) : <nl> - % 3 = function_ref @ unknown_func : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - % 4 = apply % 3 ( % 0 , % 1 ) : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - <nl> - % r = tuple ( ) <nl> - return % r : $ ( ) <nl> - } <nl> - <nl> - / / CHECK - LABEL : @ call_store_to_int_not_aliased <nl> - / / CHECK : PAIR # 1 . <nl> - / / CHECK - NEXT : ( 0 ) : % 4 = apply % 3 ( % 0 , % 1 ) : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - / / CHECK - NEXT : ( 0 ) : % 1 = argument of bb0 : $ * Int32 / / user : % 4 <nl> - / / CHECK - NEXT : r = 0 , w = 1 , se = 1 <nl> - / / CHECK : PAIR # 2 . <nl> - / / CHECK - NEXT : ( 0 ) : % 4 = apply % 3 ( % 0 , % 1 ) : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - / / CHECK - NEXT : ( 0 ) : % 2 = argument of bb0 : $ * Int32 <nl> - / / CHECK - NEXT : r = 0 , w = 0 , se = 0 <nl> - sil @ call_store_to_int_not_aliased : $ @ convention ( thin ) ( Int32 , @ inout Int32 , @ inout Int32 ) - > ( ) { <nl> - bb0 ( % 0 : $ Int32 , % 1 : $ * Int32 , % 2 : $ * Int32 ) : <nl> - % 3 = function_ref @ store_to_int : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - % 4 = apply % 3 ( % 0 , % 1 ) : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - <nl> - % r = tuple ( ) <nl> - return % r : $ ( ) <nl> - } <nl> - <nl> - / / CHECK - LABEL : @ call_store_to_int_aliased <nl> - / / CHECK : PAIR # 3 . <nl> - / / CHECK - NEXT : ( 0 ) : % 6 = apply % 5 ( % 0 , % 3 ) : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - / / CHECK - NEXT : ( 0 ) : % 3 = ref_element_addr % 1 : $ X , # X . a / / user : % 6 <nl> - / / CHECK - NEXT : r = 0 , w = 1 , se = 1 <nl> - / / CHECK : PAIR # 4 . <nl> - / / CHECK - NEXT : ( 0 ) : % 6 = apply % 5 ( % 0 , % 3 ) : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - / / CHECK - NEXT : ( 0 ) : % 4 = ref_element_addr % 2 : $ X , # X . a <nl> - / / CHECK - NEXT : r = 0 , w = 1 , se = 1 <nl> - sil @ call_store_to_int_aliased : $ @ convention ( thin ) ( Int32 , @ guaranteed X , @ guaranteed X ) - > ( ) { <nl> - bb0 ( % 0 : $ Int32 , % 1 : $ X , % 2 : $ X ) : <nl> - % 3 = ref_element_addr % 1 : $ X , # X . a <nl> - % 4 = ref_element_addr % 2 : $ X , # X . a <nl> - % 5 = function_ref @ store_to_int : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - % 6 = apply % 5 ( % 0 , % 3 ) : $ @ convention ( thin ) ( Int32 , @ inout Int32 ) - > ( ) <nl> - <nl> - % r = tuple ( ) <nl> - return % r : $ ( ) <nl> - } <nl> - <nl> - sil @ call_only_retain : $ @ convention ( thin ) ( @ guaranteed X , @ guaranteed X ) - > ( ) { <nl> - bb0 ( % 0 : $ X , % 1 : $ X ) : <nl> - % 2 = function_ref @ only_retain : $ @ convention ( thin ) ( @ guaranteed X ) - > ( ) <nl> - % 3 = apply % 2 ( % 0 ) : $ @ convention ( thin ) ( @ guaranteed X ) - > ( ) <nl> - <nl> - % r = tuple ( ) <nl> - return % r : $ ( ) <nl> - } <nl> - <nl> mmm a / test / SILPasses / let_propagation . swift <nl> ppp b / test / SILPasses / let_propagation . swift <nl> <nl> / / It is calle just to trigger flushing of all known stored in LoadStore optimizations . <nl> @ inline ( never ) <nl> func action ( ) { <nl> - print ( " " ) <nl> } <nl> <nl> final public class A0 { <nl>
|
Revert " Use side effect analysis in alias analysis . "
|
apple/swift
|
f80557773884c1ef84471ed3dd7b4fe7caecab46
|
2015-09-15T23:37:53Z
|
mmm a / xbmc / cores / VideoPlayer / VideoPlayer . cpp <nl> ppp b / xbmc / cores / VideoPlayer / VideoPlayer . cpp <nl> void CVideoPlayer : : UpdatePlayState ( double timeout ) <nl> } <nl> } <nl> <nl> - state . time = DVD_TIME_TO_MSEC ( m_clock . GetClock ( false ) ) ; <nl> + state . time = m_clock . GetClock ( false ) * 1000 / DVD_TIME_BASE ; <nl> state . timeMax = m_pDemuxer - > GetStreamLength ( ) ; <nl> } <nl> <nl> void CVideoPlayer : : UpdatePlayState ( double timeout ) <nl> <nl> state . time_offset = DVD_MSEC_TO_TIME ( dispTime ) - state . dts ; <nl> } <nl> - state . time + = DVD_TIME_TO_MSEC ( state . time_offset ) ; <nl> + state . time + = state . time_offset * 1000 / DVD_TIME_BASE ; <nl> state . timeMax = pDisplayTime - > GetTotalTime ( ) ; <nl> } <nl> else <nl>
|
VideoPlayer : drop some faulty DVD time macro usage
|
xbmc/xbmc
|
765b20810c127c299fd9d59b259e961d885c5bdf
|
2017-08-16T11:56:35Z
|
mmm a / src / addrman . cpp <nl> ppp b / src / addrman . cpp <nl> CAddress CAddrMan : : Select_ ( int nUnkBias ) <nl> fChanceFactor * = 1 . 2 ; <nl> } <nl> } else { <nl> - / / use an new node <nl> + / / use a new node <nl> double fChanceFactor = 1 . 0 ; <nl> while ( 1 ) <nl> { <nl>
|
fix a comment in addrman . cpp
|
bitcoin/bitcoin
|
30c8a4084737bc6c8f2969f796acc56cdafb80fa
|
2012-08-18T14:45:24Z
|
mmm a / src / toolkits / activity_classification / ac_data_iterator . cpp <nl> ppp b / src / toolkits / activity_classification / ac_data_iterator . cpp <nl> static std : : map < std : : string , size_t > generate_column_index_map ( const std : : vector < <nl> * \ return The most frequent value within the given vector . <nl> * / <nl> <nl> - static double vec_mode ( const flex_vec & input_vec ) { <nl> - std : : vector < int > histogram ; <nl> - for ( size_t i = 0 ; i < input_vec . size ( ) ; + + i ) { <nl> - size_t value = static_cast < size_t > ( input_vec [ i ] ) ; <nl> + static double vec_mode ( flex_vec : : const_iterator first , <nl> + flex_vec : : const_iterator last ) { <nl> + std : : vector < int > histogram ; <nl> + for ( flex_vec : : const_iterator i = first ; i < last ; + + i ) { <nl> + size_t value = static_cast < size_t > ( * i ) ; <nl> <nl> - / / Each value should be in the index of a class label <nl> - DASSERT_EQ ( static_cast < double > ( static_cast < size_t > ( input_vec [ i ] ) ) , input_vec [ i ] ) ; <nl> + / / Each value should be in the index of a class label <nl> + DASSERT_EQ ( static_cast < double > ( static_cast < size_t > ( * i ) ) , * i ) ; <nl> <nl> - if ( histogram . size ( ) < ( value + 1 ) ) { <nl> - histogram . resize ( value + 1 ) ; <nl> - } <nl> - <nl> - histogram [ value ] + + ; <nl> + if ( histogram . size ( ) < ( value + 1 ) ) { <nl> + histogram . resize ( value + 1 ) ; <nl> } <nl> <nl> - auto majority = std : : max_element ( histogram . begin ( ) , histogram . end ( ) ) ; <nl> + histogram [ value ] + + ; <nl> + } <nl> + <nl> + auto majority = std : : max_element ( histogram . begin ( ) , histogram . end ( ) ) ; <nl> <nl> - / / return index to mode majority value <nl> - return std : : distance ( histogram . begin ( ) , majority ) ; <nl> + / / return index to mode majority value <nl> + return std : : distance ( histogram . begin ( ) , majority ) ; <nl> } <nl> <nl> / * * <nl> static void finalize_chunk ( flex_vec & curr_chunk_features , <nl> <nl> if ( use_target ) { <nl> if ( curr_window_targets . size ( ) > 0 ) { <nl> - curr_chunk_targets . push_back ( vec_mode ( curr_window_targets ) ) ; <nl> + curr_chunk_targets . push_back ( vec_mode ( curr_window_targets . begin ( ) , curr_window_targets . end ( ) ) ) ; <nl> curr_window_targets . clear ( ) ; <nl> } <nl> <nl> variant_map_type _activity_classifier_prepare_data_impl ( const gl_sframe & data , <nl> curr_window_targets . push_back ( line [ column_index_map [ target ] ] ) ; <nl> <nl> if ( curr_window_targets . size ( ) = = static_cast < size_t > ( prediction_window ) ) { <nl> - auto target_val = vec_mode ( curr_window_targets ) ; <nl> + auto target_val = vec_mode ( curr_window_targets . begin ( ) , curr_window_targets . end ( ) ) ; <nl> curr_chunk_targets . push_back ( target_val ) ; <nl> curr_window_targets . clear ( ) ; <nl> } <nl> variant_map_type _activity_classifier_prepare_data_impl ( const gl_sframe & data , <nl> return result_dict ; <nl> } <nl> <nl> + variant_map_type _activity_classifier_prepare_data_aug_impl ( <nl> + const gl_sframe & data , const std : : vector < std : : string > & features , <nl> + const std : : string & session_id , int prediction_window , <nl> + int predictions_in_chunk , const std : : string & target , bool verbose ) { <nl> + <nl> + # ifndef NDEBUG <nl> + DASSERT_GT ( features . size ( ) , 0 ) ; <nl> + DASSERT_TRUE ( prediction_window > 0 ) ; <nl> + DASSERT_TRUE ( predictions_in_chunk > 0 ) ; <nl> + DASSERT_TRUE ( data . contains_column ( session_id ) ) ; <nl> + for ( auto & feat : features ) { <nl> + DASSERT_TRUE ( data . contains_column ( feat ) ) ; <nl> + } <nl> + # endif <nl> + <nl> + bool use_target = ( target ! = " " ) ; <nl> + DASSERT_TRUE ( ! use_target | | data . contains_column ( target ) ) ; <nl> + <nl> + if ( verbose ) { <nl> + logprogress_stream < < " Pre - processing " < < data . size ( ) < < " samples . . . " <nl> + < < std : : endl ; <nl> + } <nl> + <nl> + / / Build a dict of the column order by column name , to later access within <nl> + / / the iterator <nl> + auto column_index_map = generate_column_index_map ( data . column_names ( ) ) ; <nl> + size_t chunk_length = prediction_window * predictions_in_chunk ; <nl> + <nl> + flex_vec curr_chunk_targets ; <nl> + flex_vec curr_chunk_features ; <nl> + <nl> + flexible_type last_session_id = data [ session_id ] [ 0 ] ; <nl> + size_t number_of_sessions = 0 ; <nl> + <nl> + / / Prepare an output SFrame writer , that will write a new SFrame in the <nl> + / / converted batch - processing ready format . <nl> + std : : vector < std : : string > output_column_names = { " features " , " chunk_len " , <nl> + " session_id " } ; <nl> + std : : vector < flex_type_enum > output_column_types = { flex_type_enum : : VECTOR , <nl> + flex_type_enum : : INTEGER , <nl> + data [ session_id ] . dtype ( ) } ; <nl> + if ( use_target ) { <nl> + output_column_names . push_back ( " target " ) ; <nl> + output_column_types . push_back ( flex_type_enum : : VECTOR ) ; <nl> + } <nl> + <nl> + gl_sframe_writer output_writer ( output_column_names , output_column_types , 1 ) ; <nl> + <nl> + if ( verbose ) { <nl> + logprogress_stream < < " Using sequences of size " < < chunk_length <nl> + < < " for model creation . " < < std : : endl ; <nl> + } <nl> + <nl> + time_t last_print_time = time ( 0 ) ; <nl> + size_t processed_lines = 0 ; <nl> + <nl> + / / Iterate over the user data . The features and targets are aggregated , and <nl> + / / handled whenever at the ending of a session is reached . <nl> + size_t chunk_size = 0 ; <nl> + for ( const auto & line : data . range_iterator ( ) ) { <nl> + flexible_type curr_session_id = line [ column_index_map [ session_id ] ] ; <nl> + <nl> + if ( curr_session_id ! = last_session_id ) { <nl> + <nl> + / / Write the aggregated data of the current chunk ( which includes all <nl> + / / the samples in the current session ) as a single new vector in the <nl> + / / converted SFrame , and init all aggregation vectors to begin a new <nl> + / / chunk . <nl> + if ( curr_chunk_features . size ( ) > 0 ) { <nl> + if ( use_target ) { <nl> + output_writer . write ( { curr_chunk_features , chunk_size , last_session_id , <nl> + curr_chunk_targets } , <nl> + 0 ) ; <nl> + } else { <nl> + output_writer . write ( <nl> + { curr_chunk_features , chunk_size , last_session_id } , 0 ) ; <nl> + } <nl> + curr_chunk_features . clear ( ) ; <nl> + curr_chunk_targets . clear ( ) ; <nl> + } <nl> + <nl> + chunk_size = 0 ; <nl> + last_session_id = curr_session_id ; <nl> + number_of_sessions + + ; <nl> + } <nl> + <nl> + chunk_size + = 1 ; <nl> + <nl> + for ( const std : : string & feature_name : features ) { <nl> + curr_chunk_features . push_back ( line [ column_index_map [ feature_name ] ] ) ; <nl> + } <nl> + <nl> + if ( use_target ) { <nl> + curr_chunk_targets . push_back ( line [ column_index_map [ target ] ] ) ; <nl> + } <nl> + <nl> + time_t now = time ( 0 ) ; <nl> + if ( verbose & & difftime ( now , last_print_time ) > 10 ) { <nl> + logprogress_stream < < " Pre - processing : " < < std : : setw ( 3 ) <nl> + < < ( 100 * processed_lines / data . size ( ) ) <nl> + < < " % complete " < < std : : endl ; <nl> + last_print_time = now ; <nl> + } <nl> + processed_lines + = 1 ; <nl> + } <nl> + <nl> + <nl> + if ( curr_chunk_features . size ( ) > 0 ) { <nl> + if ( use_target ) { <nl> + output_writer . write ( { curr_chunk_features , chunk_size , last_session_id , <nl> + curr_chunk_targets } , <nl> + 0 ) ; <nl> + } else { <nl> + output_writer . write ( { curr_chunk_features , chunk_size , last_session_id } , <nl> + 0 ) ; <nl> + } <nl> + curr_chunk_features . clear ( ) ; <nl> + curr_chunk_targets . clear ( ) ; <nl> + } <nl> + <nl> + / / Update the count of the last session in the dataset <nl> + number_of_sessions + + ; <nl> + <nl> + if ( verbose ) { <nl> + logprogress_stream < < " Processed a total of " < < number_of_sessions <nl> + < < " sessions . " < < std : : endl ; <nl> + } <nl> + gl_sframe converted_sframe = output_writer . close ( ) ; <nl> + converted_sframe . materialize ( ) ; <nl> + <nl> + variant_map_type result_dict ; <nl> + result_dict [ " converted_data " ] = converted_sframe ; <nl> + result_dict [ " num_of_sessions " ] = number_of_sessions ; <nl> + <nl> + return result_dict ; <nl> + } <nl> + <nl> } / / namespace <nl> <nl> variant_map_type _activity_classifier_prepare_data ( const gl_sframe & data , <nl> simple_data_iterator : : preprocessed_data simple_data_iterator : : preprocess_data ( <nl> } <nl> <nl> / / Chunk the data , so that each row of the resulting SFrame corresponds to a <nl> - / / sequence of up to predictions_in_chunk prediction windows ( from the same <nl> - / / session ) , each comprising up to prediction_window rows from the original <nl> - / / SFrame . <nl> - variant_map_type result_map = _activity_classifier_prepare_data_impl ( <nl> + / / all samples in a session from the original SFrame . <nl> + variant_map_type result_map = _activity_classifier_prepare_data_aug_impl ( <nl> data , feature_column_names , params . session_id_column_name , <nl> static_cast < int > ( params . prediction_window ) , <nl> static_cast < int > ( params . predictions_in_chunk ) , params . target_column_name , <nl> - / * verbose * / params . verbose ) ; <nl> + / * verbose * / params . is_train ) ; <nl> <nl> preprocessed_data result ; <nl> result . chunks = variant_get_value < gl_sframe > ( result_map . at ( " converted_data " ) ) ; <nl> simple_data_iterator : : preprocessed_data simple_data_iterator : : preprocess_data ( <nl> return result ; <nl> } <nl> <nl> - simple_data_iterator : : simple_data_iterator ( const parameters & params ) <nl> - : data_ ( preprocess_data ( params ) ) , <nl> - num_samples_per_prediction_ ( params . prediction_window ) , <nl> - num_predictions_per_chunk_ ( params . predictions_in_chunk ) , <nl> - range_iterator_ ( data_ . chunks . range_iterator ( ) ) , <nl> - next_row_ ( range_iterator_ . begin ( ) ) , <nl> - end_of_rows_ ( range_iterator_ . end ( ) ) <nl> - { } <nl> + simple_data_iterator : : simple_data_iterator ( const parameters & params ) <nl> + : data_ ( preprocess_data ( params ) ) , <nl> + num_samples_per_prediction_ ( params . prediction_window ) , <nl> + num_predictions_per_chunk_ ( params . predictions_in_chunk ) , <nl> + range_iterator_ ( data_ . chunks . range_iterator ( ) ) , <nl> + next_row_ ( range_iterator_ . begin ( ) ) , <nl> + end_of_rows_ ( range_iterator_ . end ( ) ) , <nl> + sample_in_row_ ( 0 ) , <nl> + is_train_ ( params . is_train ) , <nl> + use_data_augmentation_ ( params . use_data_augmentation ) { } <nl> <nl> const flex_list & simple_data_iterator : : feature_names ( ) const { <nl> return data_ . feature_names ; <nl> bool simple_data_iterator : : has_next_batch ( ) const { <nl> <nl> data_iterator : : batch simple_data_iterator : : next_batch ( size_t batch_size ) { <nl> <nl> + <nl> size_t num_samples_per_chunk = <nl> num_samples_per_prediction_ * num_predictions_per_chunk_ ; <nl> size_t num_features = data_ . feature_names . size ( ) ; <nl> data_iterator : : batch simple_data_iterator : : next_batch ( size_t batch_size ) { <nl> size_t chunk_len_column_index = data_ . chunks . column_index ( " chunk_len " ) ; <nl> size_t session_id_column_index = data_ . chunks . column_index ( " session_id " ) ; <nl> size_t labels_column_index = 0 ; <nl> - size_t weights_column_index = 0 ; <nl> + <nl> if ( data_ . has_target ) { <nl> labels_column_index = data_ . chunks . column_index ( " target " ) ; <nl> - weights_column_index = data_ . chunks . column_index ( " weights " ) ; <nl> } <nl> <nl> / / Allocate buffers for the resulting batch data . <nl> data_iterator : : batch simple_data_iterator : : next_batch ( size_t batch_size ) { <nl> labels . resize ( labels_size , 0 . f ) ; <nl> weights . resize ( labels_size , 0 . f ) ; <nl> } <nl> + std : : vector < batch : : chunk_info > batch_info ; <nl> + batch_info . reserve ( batch_size ) ; <nl> <nl> / / Iterate through SFrame rows until filling the batch or reaching the end of <nl> / / the data . <nl> float * features_out = features . data ( ) ; <nl> float * labels_out = labels . data ( ) ; <nl> float * weights_out = weights . data ( ) ; <nl> - std : : vector < batch : : chunk_info > batch_info ; <nl> - batch_info . reserve ( batch_size ) ; <nl> + <nl> while ( batch_info . size ( ) < batch_size & & next_row_ ! = end_of_rows_ ) { <nl> <nl> const sframe_rows : : row & row = * next_row_ ; <nl> <nl> + flex_int chunk_length = row [ chunk_len_column_index ] . get < flex_int > ( ) ; <nl> + <nl> + / / Only for training , we introduce a random offset <nl> + if ( sample_in_row_ = = 0 & & <nl> + static_cast < size_t > ( chunk_length ) > num_samples_per_prediction_ & & <nl> + is_train_ & & use_data_augmentation_ ) { <nl> + sample_in_row_ = std : : rand ( ) % ( num_samples_per_prediction_ - 1 ) ; <nl> + } <nl> + <nl> + / / Stores the start of next instance <nl> + size_t jump = sample_in_row_ + num_samples_per_chunk ; <nl> + <nl> + / / End keeps track of the start of next instance if the last instance is <nl> + / / smaller <nl> + size_t end = std : : min ( jump , static_cast < size_t > ( chunk_length ) ) ; <nl> + <nl> / / Copy the feature values ( converting from double to float ) . <nl> const flex_vec & feature_vec = row [ features_column_index ] . get < flex_vec > ( ) ; <nl> - ASSERT_EQ ( feature_vec . size ( ) , features_stride ) ; <nl> - features_out = std : : copy ( feature_vec . begin ( ) , feature_vec . end ( ) , <nl> - features_out ) ; <nl> + <nl> + std : : copy ( feature_vec . begin ( ) + sample_in_row_ * num_features , <nl> + feature_vec . begin ( ) + end * num_features , features_out ) ; <nl> + features_out + = num_features * num_samples_per_chunk ; <nl> <nl> if ( data_ . has_target ) { <nl> <nl> - / / Also copy the labels and weights . <nl> - const flex_vec & target_vec = row [ labels_column_index ] . get < flex_vec > ( ) ; <nl> - const flex_vec & weight_vec = row [ weights_column_index ] . get < flex_vec > ( ) ; <nl> - labels_out = std : : copy ( target_vec . begin ( ) , target_vec . end ( ) , labels_out ) ; <nl> - weights_out = std : : copy ( weight_vec . begin ( ) , weight_vec . end ( ) , <nl> - weights_out ) ; <nl> + const flex_vec & label_vec = row [ labels_column_index ] . get < flex_vec > ( ) ; <nl> + <nl> + / / The label is picked using majority voting for every prediction_window <nl> + for ( size_t i = sample_in_row_ ; i < end ; <nl> + i + = num_samples_per_prediction_ ) { <nl> + size_t window_end = std : : min ( i + num_samples_per_prediction_ , end ) ; <nl> + double label = <nl> + vec_mode ( label_vec . begin ( ) + i , label_vec . begin ( ) + window_end ) ; <nl> + labels_out [ ( i - sample_in_row_ ) / num_samples_per_prediction_ ] = <nl> + static_cast < float > ( label ) ; <nl> + weights_out [ ( i - sample_in_row_ ) / num_samples_per_prediction_ ] = 1 . f ; <nl> + } <nl> + labels_out + = num_predictions_per_chunk_ ; <nl> + weights_out + = num_predictions_per_chunk_ ; <nl> } <nl> <nl> batch_info . emplace_back ( ) ; <nl> batch_info . back ( ) . session_id = row [ session_id_column_index ] ; <nl> - batch_info . back ( ) . num_samples = row [ chunk_len_column_index ] ; <nl> + batch_info . back ( ) . num_samples = end - sample_in_row_ ; <nl> + <nl> + sample_in_row_ = end ; <nl> <nl> - + + next_row_ ; <nl> + if ( sample_in_row_ > = static_cast < size_t > ( chunk_length ) ) { <nl> + + + next_row_ ; <nl> + sample_in_row_ = 0 ; <nl> + } <nl> } <nl> <nl> / / Wrap the buffers as float_array values . <nl> void simple_data_iterator : : reset ( ) { <nl> } <nl> <nl> } / / activity_classification <nl> - } / / turi <nl> + } / / namespace turi <nl> mmm a / src / toolkits / activity_classification / ac_data_iterator . hpp <nl> ppp b / src / toolkits / activity_classification / ac_data_iterator . hpp <nl> class data_iterator { <nl> * / <nl> flex_list class_labels ; <nl> <nl> - / * * Generates verbose output when set to true . * / <nl> - bool verbose ; <nl> + / * * Set to true , when the data is used for training . * / <nl> + bool is_train = false ; <nl> + <nl> + / * * Augments training data when set to true * / <nl> + bool use_data_augmentation = false ; <nl> } ; <nl> <nl> / * * Defines the output of a data_iterator . * / <nl> class data_iterator { <nl> } ; <nl> <nl> / * * <nl> - * An array with shape : ( requested_batch_size , <nl> + * An array with shape : ( requested_batch_size , <nl> * 1 , prediction_window * predictions_in_chunk , num_feature_columns ) <nl> * <nl> * Each row is a chunk of feature values from one session . <nl> class simple_data_iterator : public data_iterator { <nl> gl_sframe_range range_iterator_ ; <nl> gl_sframe_range : : iterator next_row_ ; <nl> gl_sframe_range : : iterator end_of_rows_ ; <nl> + size_t sample_in_row_ = 0 ; <nl> + bool is_train_ = false ; <nl> + bool use_data_augmentation_ = false ; <nl> } ; <nl> <nl> / * * <nl> mmm a / src / toolkits / activity_classification / activity_classifier . cpp <nl> ppp b / src / toolkits / activity_classification / activity_classifier . cpp <nl> void activity_classifier : : init_options ( <nl> 10 , <nl> 1 , <nl> std : : numeric_limits < int > : : max ( ) ) ; <nl> + options . create_boolean_option ( <nl> + " use_data_augmentation " , <nl> + " Data augmentation helps use prediction window started with random " <nl> + " offset . " <nl> + " If set to True , the trained model uses augmented data . " , <nl> + false ) ; <nl> <nl> / / Validate user - provided options . <nl> options . set_options ( opts ) ; <nl> void activity_classifier : : init_table_printer ( bool has_validation ) { <nl> } <nl> } <nl> <nl> - void activity_classifier : : train ( gl_sframe data , const std : : string & target_column_name , <nl> - const std : : string & session_id_column_name , <nl> - variant_type validation_data , <nl> - const std : : map < std : : string , flexible_type > & opts ) <nl> - { <nl> - <nl> + void activity_classifier : : train ( <nl> + gl_sframe data , const std : : string & target_column_name , <nl> + const std : : string & session_id_column_name , variant_type validation_data , <nl> + const std : : map < std : : string , flexible_type > & opts ) { <nl> gl_sframe train_data ; <nl> gl_sframe val_data ; <nl> std : : tie ( train_data , val_data ) = <nl> void activity_classifier : : train ( gl_sframe data , const std : : string & target_column <nl> add_or_update_state ( state_update ) ; <nl> } <nl> <nl> - <nl> - <nl> gl_sarray activity_classifier : : predict ( gl_sframe data , <nl> std : : string output_type ) { <nl> if ( output_type . empty ( ) ) { <nl> gl_sarray activity_classifier : : predict ( gl_sframe data , <nl> <nl> / / Bind the data to a data iterator . <nl> std : : unique_ptr < data_iterator > data_it = <nl> - create_iterator ( data , / * requires_labels * / false , / * is_train * / false ) ; <nl> + create_iterator ( data , / * requires_labels * / false , / * is_train * / false , <nl> + / * use_data_augmentation * / false ) ; <nl> <nl> / / Accumulate the class probabilities for each prediction window . <nl> gl_sframe raw_preds_per_window = perform_inference ( data_it . get ( ) ) ; <nl> gl_sframe activity_classifier : : predict_per_window ( gl_sframe data , <nl> <nl> / / Bind the data to a data iterator . <nl> std : : unique_ptr < data_iterator > data_it = <nl> - create_iterator ( data , / * requires_labels * / false , / * is_train * / false ) ; <nl> + create_iterator ( data , / * requires_labels * / false , / * is_train * / false , <nl> + / * use_data_augmentation * / false ) ; <nl> <nl> / / Accumulate the class probabilities for each prediction window . <nl> gl_sframe raw_preds_per_window = perform_inference ( data_it . get ( ) ) ; <nl> void activity_classifier : : import_from_custom_model ( <nl> nn_spec_ - > update_params ( nn_params ) ; <nl> } <nl> <nl> - std : : unique_ptr < data_iterator > <nl> - activity_classifier : : create_iterator ( gl_sframe data , bool requires_labels , <nl> - bool is_train ) const { <nl> - <nl> + std : : unique_ptr < data_iterator > activity_classifier : : create_iterator ( <nl> + gl_sframe data , bool requires_labels , bool is_train , <nl> + bool use_data_augmentation ) const { <nl> data_iterator : : parameters data_params ; <nl> data_params . data = std : : move ( data ) ; <nl> <nl> activity_classifier : : create_iterator ( gl_sframe data , bool requires_labels , <nl> data_params . class_labels = read_state < flex_list > ( " classes " ) ; <nl> } <nl> <nl> - data_params . verbose = is_train ; <nl> + data_params . is_train = is_train ; <nl> if ( requires_labels ) { <nl> data_params . target_column_name = read_state < flex_string > ( " target " ) ; <nl> } <nl> + data_params . use_data_augmentation = use_data_augmentation ; <nl> data_params . session_id_column_name = read_state < flex_string > ( " session_id " ) ; <nl> flex_list features = read_state < flex_list > ( " features " ) ; <nl> data_params . feature_column_names = <nl> void activity_classifier : : init_train ( <nl> gl_sframe data , std : : string target_column_name , <nl> std : : string session_id_column_name , gl_sframe validation_data , <nl> std : : map < std : : string , flexible_type > opts ) { <nl> - <nl> / / Begin printing progress . <nl> / / TODO : Make progress printing optional . <nl> init_table_printer ( ! validation_data . empty ( ) ) ; <nl> void activity_classifier : : init_train ( <nl> feature_column_names . end ( ) ) } } ) ; <nl> <nl> / / Bind the data to a data iterator . <nl> + bool use_data_augmentation = read_state < bool > ( " use_data_augmentation " ) ; <nl> training_data_iterator_ = <nl> - create_iterator ( data , / * requires_labels * / true , / * is_train * / true ) ; <nl> + create_iterator ( data , / * requires_labels * / true , / * is_train * / true , <nl> + use_data_augmentation ) ; <nl> <nl> add_or_update_state ( { { " classes " , training_data_iterator_ - > class_labels ( ) } } ) ; <nl> <nl> / / Bind the validation data to a data iterator . <nl> if ( ! validation_data . empty ( ) ) { <nl> validation_data_iterator_ = create_iterator ( <nl> - validation_data , / * requires_labels * / true , / * is_train * / false ) ; <nl> + validation_data , / * requires_labels * / true , / * is_train * / false , <nl> + / * use_data_augmentation * / false ) ; <nl> } else { <nl> validation_data_iterator_ = nullptr ; <nl> } <nl> mmm a / src / toolkits / activity_classification / activity_classifier . hpp <nl> ppp b / src / toolkits / activity_classification / activity_classifier . hpp <nl> class EXPORT activity_classifier : public ml_model_base { <nl> / / Override points allowing subclasses to inject dependencies <nl> <nl> / / Factory for data_iterator <nl> - virtual std : : unique_ptr < data_iterator > create_iterator ( gl_sframe data , <nl> - bool requires_labels , <nl> - bool is_train ) const ; <nl> + virtual std : : unique_ptr < data_iterator > create_iterator ( <nl> + gl_sframe data , bool requires_labels , bool is_train , <nl> + bool use_data_augmentation ) const ; <nl> <nl> / / Factory for compute_context <nl> virtual std : : unique_ptr < neural_net : : compute_context > create_compute_context ( ) <nl>
|
Data Augmentation for C - API activity classifier ( )
|
apple/turicreate
|
1240c506c978dbec932efd951d586e1a8fc6e919
|
2019-07-04T06:49:32Z
|
mmm a / arangod / VocBase / server . cpp <nl> ppp b / arangod / VocBase / server . cpp <nl> <nl> # include " Wal / LogfileManager . h " <nl> # include " Wal / Marker . h " <nl> <nl> + using namespace arangodb ; <nl> using namespace arangodb : : basics ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> static int OpenDatabases ( TRI_server_t * server , bool isUpgrade ) { <nl> } <nl> <nl> if ( ! StringUtils : : isPrefix ( name , " database - " ) | | StringUtils : : isSuffix ( name , " . tmp " ) ) { <nl> + LOG_TOPIC ( TRACE , Logger : : DATAFILES ) < < " ignoring file ' " < < name < < " ' " ; <nl> continue ; <nl> } <nl> <nl>
|
addeed log output
|
arangodb/arangodb
|
8edc06daf35e8358fbbb6040233284baa1a570a8
|
2016-02-23T21:32:28Z
|
mmm a / utils / build - script <nl> ppp b / utils / build - script <nl> class BuildScriptInvocation ( object ) : <nl> <nl> @ staticmethod <nl> def apply_default_arguments ( toolchain , args ) : <nl> - driver_arguments . apply_default_arguments ( args ) <nl> - <nl> # infer if ninja is required <nl> ninja_required = ( <nl> args . cmake_generator = = ' Ninja ' or args . build_foundation ) <nl> new file mode 100644 <nl> index 000000000000 . . 1141a396f6b3 <nl> mmm / dev / null <nl> ppp b / utils / build_swift / README . md <nl> <nl> + # build_swift <nl> + <nl> + The ` build_swift ` module contains data - structures and functions used by <nl> + the Swift build - script . <nl> + <nl> + # # Unit Tests <nl> + <nl> + You may run the unit test suite using the command : <nl> + <nl> + ` ` ` sh <nl> + $ python - m unittest discover - s utils / build_swift <nl> + ` ` ` <nl> mmm a / utils / build_swift / driver_arguments . py <nl> ppp b / utils / build_swift / driver_arguments . py <nl> <nl> <nl> <nl> __all__ = [ <nl> - ' apply_default_arguments ' , <nl> ' create_argument_parser ' , <nl> ] <nl> <nl> <nl> - def apply_default_arguments ( args ) : <nl> - " " " Preprocess argument namespace to apply default behaviors . " " " <nl> + class _ApplyDefaultsArgumentParser ( argparse . ArgumentParser ) : <nl> + " " " Wrapper class around the default ArgumentParser that allows for <nl> + post - processing the parsed argument namespace to apply default argument <nl> + transformations . <nl> + " " " <nl> + <nl> + def __init__ ( self , apply_defaults = None , * args , * * kwargs ) : <nl> + self . _apply_defaults = apply_defaults <nl> + super ( _ApplyDefaultsArgumentParser , self ) . __init__ ( * args , * * kwargs ) <nl> + <nl> + def parse_known_args ( self , args = None , namespace = None ) : <nl> + args , argv = super ( _ApplyDefaultsArgumentParser , self ) \ <nl> + . parse_known_args ( args , namespace ) <nl> + <nl> + self . _apply_defaults ( args ) <nl> + return args , argv <nl> + <nl> + <nl> + def _apply_default_arguments ( args ) : <nl> + " " " Preprocess argument namespace to apply default behaviors . <nl> + " " " <nl> <nl> # Build cmark if any cmark - related options were specified . <nl> if ( args . cmark_build_variant is not None ) : <nl> def apply_default_arguments ( args ) : <nl> <nl> <nl> def create_argument_parser ( ) : <nl> - parser = argparse . ArgumentParser ( <nl> + " " " Return a configured argument parser . " " " <nl> + <nl> + parser = _ApplyDefaultsArgumentParser ( <nl> + apply_defaults = _apply_default_arguments , <nl> formatter_class = argparse . RawDescriptionHelpFormatter , <nl> usage = USAGE , <nl> description = DESCRIPTION , <nl> def create_argument_parser ( ) : <nl> return parser <nl> <nl> <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> USAGE = " " " <nl> % ( prog ) s [ - h | - - help ] [ OPTION . . . ] <nl> % ( prog ) s - - preset = NAME [ SUBSTITUTION . . . ] <nl> new file mode 100644 <nl> index 000000000000 . . fa71f9fece53 <nl> mmm / dev / null <nl> ppp b / utils / build_swift / tests / __init__ . py <nl> <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2017 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See https : / / swift . org / LICENSE . txt for license information <nl> + # See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> new file mode 100644 <nl> index 000000000000 . . 2ca8d8d1e0f7 <nl> mmm / dev / null <nl> ppp b / utils / build_swift / tests / expected_options . py <nl> <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2017 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See https : / / swift . org / LICENSE . txt for license information <nl> + # See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + <nl> + import argparse <nl> + <nl> + <nl> + __all__ = [ <nl> + ' Option ' , <nl> + ' AppendOption ' , <nl> + ' ChoicesOption ' , <nl> + ' HelpOption ' , <nl> + ' IgnoreOption ' , <nl> + ' IntOption ' , <nl> + ' PathOption ' , <nl> + ' StrOption ' , <nl> + ' ToggleOption ' , <nl> + ' UnsupportedOption ' , <nl> + ' EXPECTED_OPTIONS ' , <nl> + ' EXPECTED_DEFAULTS ' , <nl> + ] <nl> + <nl> + <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + EXPECTED_DEFAULTS = { <nl> + ' android ' : False , <nl> + ' android_api_level ' : ' 21 ' , <nl> + ' android_deploy_device_path ' : ' / data / local / tmp ' , <nl> + ' android_icu_i18n ' : None , <nl> + ' android_icu_i18n_include ' : None , <nl> + ' android_icu_uc ' : None , <nl> + ' android_icu_uc_include ' : None , <nl> + ' android_ndk ' : None , <nl> + ' android_ndk_gcc_version ' : ' 4 . 9 ' , <nl> + ' assertions ' : True , <nl> + ' benchmark ' : False , <nl> + ' benchmark_num_o_iterations ' : 3 , <nl> + ' benchmark_num_onone_iterations ' : 3 , <nl> + ' build_args ' : [ ] , <nl> + ' build_foundation ' : False , <nl> + ' build_jobs ' : 4 , <nl> + ' build_libdispatch ' : False , <nl> + ' build_libicu ' : False , <nl> + ' build_llbuild ' : False , <nl> + ' build_lldb ' : False , <nl> + ' build_ninja ' : False , <nl> + ' build_playgroundlogger ' : False , <nl> + ' build_playgroundsupport ' : False , <nl> + ' build_runtime_with_host_compiler ' : False , <nl> + ' build_stdlib_deployment_targets ' : [ ' all ' ] , <nl> + ' build_subdir ' : ' Ninja - DebugAssert ' , <nl> + ' build_swift_dynamic_sdk_overlay ' : True , <nl> + ' build_swift_dynamic_stdlib ' : True , <nl> + ' build_swift_static_sdk_overlay ' : False , <nl> + ' build_swift_static_stdlib ' : False , <nl> + ' build_swift_stdlib_unittest_extra ' : False , <nl> + ' build_swiftpm ' : False , <nl> + ' build_variant ' : ' Debug ' , <nl> + ' build_xctest ' : False , <nl> + ' clang_compiler_version ' : None , <nl> + ' clang_profile_instr_use ' : None , <nl> + ' clang_user_visible_version ' : ' 5 . 0 . 0 ' , <nl> + ' clean ' : False , <nl> + ' cmake ' : None , <nl> + ' cmake_generator ' : ' Ninja ' , <nl> + ' cmark_assertions ' : True , <nl> + ' cmark_build_variant ' : ' Debug ' , <nl> + ' compiler_vendor ' : ' none ' , <nl> + ' coverage_db ' : None , <nl> + ' cross_compile_hosts ' : [ ] , <nl> + ' darwin_deployment_version_ios ' : ' 7 . 0 ' , <nl> + ' darwin_deployment_version_osx ' : ' 10 . 9 ' , <nl> + ' darwin_deployment_version_tvos ' : ' 9 . 0 ' , <nl> + ' darwin_deployment_version_watchos ' : ' 2 . 0 ' , <nl> + ' darwin_xcrun_toolchain ' : ' default ' , <nl> + ' distcc ' : False , <nl> + ' dry_run ' : False , <nl> + ' enable_asan ' : False , <nl> + ' enable_lsan ' : False , <nl> + ' enable_sil_ownership ' : False , <nl> + ' enable_tsan ' : False , <nl> + ' enable_tsan_runtime ' : None , <nl> + ' enable_ubsan ' : False , <nl> + ' export_compile_commands ' : False , <nl> + ' extra_cmake_options ' : [ ] , <nl> + ' extra_swift_args ' : [ ] , <nl> + ' force_optimized_typechecker ' : False , <nl> + ' foundation_build_variant ' : ' Debug ' , <nl> + ' host_cc ' : None , <nl> + ' host_cxx ' : None , <nl> + ' host_libtool ' : None , <nl> + ' host_lipo ' : None , <nl> + ' host_target ' : ' macosx - x86_64 ' , <nl> + ' host_test ' : False , <nl> + ' install_prefix ' : ' / Applications / Xcode . app / Contents / Developer / Toolchains / ' <nl> + ' XcodeDefault . xctoolchain / usr ' , <nl> + ' install_symroot ' : None , <nl> + ' ios ' : False , <nl> + ' ios_all ' : False , <nl> + ' legacy_impl ' : True , <nl> + ' libdispatch_build_variant ' : ' Debug ' , <nl> + ' libicu_build_variant ' : ' Debug ' , <nl> + ' lit_args ' : ' - sv ' , <nl> + ' lldb_assertions ' : None , <nl> + ' lldb_build_variant ' : ' Debug ' , <nl> + ' llvm_assertions ' : True , <nl> + ' llvm_build_variant ' : ' Debug ' , <nl> + ' llvm_max_parallel_lto_link_jobs ' : 0 , <nl> + ' llvm_targets_to_build ' : ' X86 ; ARM ; AArch64 ; PowerPC ; SystemZ ; Mips ' , <nl> + ' long_test ' : False , <nl> + ' lto_type ' : None , <nl> + ' show_sdks ' : False , <nl> + ' skip_build ' : False , <nl> + ' skip_build_android ' : True , <nl> + ' skip_build_benchmarks ' : False , <nl> + ' skip_build_cygwin ' : False , <nl> + ' skip_build_freebsd ' : False , <nl> + ' skip_build_ios ' : False , <nl> + ' skip_build_ios_device ' : True , <nl> + ' skip_build_ios_simulator ' : True , <nl> + ' skip_build_linux ' : False , <nl> + ' skip_build_osx ' : False , <nl> + ' skip_build_tvos ' : False , <nl> + ' skip_build_tvos_device ' : True , <nl> + ' skip_build_tvos_simulator ' : True , <nl> + ' skip_build_watchos ' : False , <nl> + ' skip_build_watchos_device ' : True , <nl> + ' skip_build_watchos_simulator ' : True , <nl> + ' skip_test_android_host ' : True , <nl> + ' skip_test_cygwin ' : True , <nl> + ' skip_test_freebsd ' : True , <nl> + ' skip_test_ios ' : True , <nl> + ' skip_test_ios_32bit_simulator ' : False , <nl> + ' skip_test_ios_host ' : True , <nl> + ' skip_test_ios_simulator ' : True , <nl> + ' skip_test_linux ' : True , <nl> + ' skip_test_osx ' : True , <nl> + ' skip_test_tvos ' : True , <nl> + ' skip_test_tvos_host ' : True , <nl> + ' skip_test_tvos_simulator ' : True , <nl> + ' skip_test_watchos ' : True , <nl> + ' skip_test_watchos_host ' : True , <nl> + ' skip_test_watchos_simulator ' : True , <nl> + ' stdlib_deployment_targets ' : [ <nl> + ' macosx - x86_64 ' , <nl> + ' iphonesimulator - i386 ' , <nl> + ' iphonesimulator - x86_64 ' , <nl> + ' appletvsimulator - x86_64 ' , <nl> + ' watchsimulator - i386 ' , <nl> + ' iphoneos - armv7 ' , <nl> + ' iphoneos - armv7s ' , <nl> + ' iphoneos - arm64 ' , <nl> + ' appletvos - arm64 ' , <nl> + ' watchos - armv7k ' <nl> + ] , <nl> + ' swift_analyze_code_coverage ' : ' false ' , <nl> + ' swift_assertions ' : True , <nl> + ' swift_build_variant ' : ' Debug ' , <nl> + ' swift_compiler_version ' : None , <nl> + ' swift_stdlib_assertions ' : True , <nl> + ' swift_stdlib_build_variant ' : ' Debug ' , <nl> + ' swift_tools_max_parallel_lto_link_jobs ' : 0 , <nl> + ' swift_user_visible_version ' : ' 4 . 1 ' , <nl> + ' symbols_package ' : None , <nl> + ' test ' : None , <nl> + ' test_optimize_for_size ' : None , <nl> + ' test_optimized ' : None , <nl> + ' tvos ' : False , <nl> + ' tvos_all ' : False , <nl> + ' validation_test ' : None , <nl> + ' verbose_build ' : False , <nl> + ' watchos ' : False , <nl> + ' watchos_all ' : False <nl> + } <nl> + <nl> + <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + class _BaseOption ( object ) : <nl> + <nl> + def __init__ ( self , option_string , dest , default = None ) : <nl> + self . option_string = option_string <nl> + self . dest = dest <nl> + <nl> + if default is None : <nl> + default = EXPECTED_DEFAULTS . get ( dest , None ) <nl> + <nl> + self . default = default <nl> + <nl> + def sanitized_str ( self ) : <nl> + if self . option_string . startswith ( ' - - ' ) : <nl> + return self . option_string [ 2 : ] . replace ( ' - ' , ' _ ' ) <nl> + <nl> + if len ( self . option_string ) = = 2 and self . option_string [ 0 ] = = ' - ' : <nl> + return self . option_string [ 1 ] <nl> + <nl> + raise ValueError ( ' invalid option_string format : ' + self . option_string ) <nl> + <nl> + <nl> + class Option ( _BaseOption ) : <nl> + " " " Option that accepts no arguments . " " " <nl> + <nl> + def __init__ ( self , * args , * * kwargs ) : <nl> + self . value = kwargs . pop ( ' value ' , None ) <nl> + super ( Option , self ) . __init__ ( * args , * * kwargs ) <nl> + <nl> + <nl> + class HelpOption ( _BaseOption ) : <nl> + " " " Option that prints the help message and exits . " " " <nl> + <nl> + pass <nl> + <nl> + <nl> + class ToggleOption ( _BaseOption ) : <nl> + " " " Option that accepts no argument or an optional bool argument . " " " <nl> + <nl> + pass <nl> + <nl> + <nl> + class ChoicesOption ( _BaseOption ) : <nl> + " " " Option that accepts an argument from a predifined list of choices . " " " <nl> + <nl> + def __init__ ( self , * args , * * kwargs ) : <nl> + self . choices = kwargs . pop ( ' choices ' , None ) <nl> + super ( ChoicesOption , self ) . __init__ ( * args , * * kwargs ) <nl> + <nl> + <nl> + class IntOption ( _BaseOption ) : <nl> + " " " Option that accepts an int argument . " " " <nl> + <nl> + pass <nl> + <nl> + <nl> + class StrOption ( _BaseOption ) : <nl> + " " " Option that accepts a str argument . " " " <nl> + <nl> + pass <nl> + <nl> + <nl> + class PathOption ( _BaseOption ) : <nl> + " " " Option that accepts a path argument . " " " <nl> + <nl> + pass <nl> + <nl> + <nl> + class AppendOption ( _BaseOption ) : <nl> + " " " Option that can be called more than once to append argument to internal <nl> + list . <nl> + " " " <nl> + <nl> + pass <nl> + <nl> + <nl> + class UnsupportedOption ( _BaseOption ) : <nl> + " " " Option that is not supported . " " " <nl> + <nl> + def __init__ ( self , * args , * * kwargs ) : <nl> + kwargs [ ' dest ' ] = kwargs . pop ( ' dest ' , None ) <nl> + super ( UnsupportedOption , self ) . __init__ ( * args , * * kwargs ) <nl> + <nl> + <nl> + class IgnoreOption ( _BaseOption ) : <nl> + " " " Option that should be ignored when generating tests . Instead a test <nl> + should be written manually as the behavior cannot or should not be auto - <nl> + generated . <nl> + " " " <nl> + <nl> + pass <nl> + <nl> + <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + EXPECTED_OPTIONS = [ <nl> + # Ignore the help options since they always call sys . exit ( 0 ) <nl> + HelpOption ( ' - h ' , dest = ' help ' , default = argparse . SUPPRESS ) , <nl> + HelpOption ( ' - - help ' , dest = ' help ' , default = argparse . SUPPRESS ) , <nl> + <nl> + Option ( ' - - assertions ' , dest = ' assertions ' , value = True ) , <nl> + Option ( ' - - benchmark ' , dest = ' benchmark ' , value = True ) , <nl> + Option ( ' - - clean ' , dest = ' clean ' , value = True ) , <nl> + Option ( ' - - cmark - assertions ' , dest = ' cmark_assertions ' , value = True ) , <nl> + Option ( ' - - debug ' , dest = ' build_variant ' , value = ' Debug ' ) , <nl> + Option ( ' - - debug - cmark ' , dest = ' cmark_build_variant ' , value = ' Debug ' ) , <nl> + Option ( ' - - debug - foundation ' , <nl> + dest = ' foundation_build_variant ' , value = ' Debug ' ) , <nl> + Option ( ' - - debug - libdispatch ' , <nl> + dest = ' libdispatch_build_variant ' , value = ' Debug ' ) , <nl> + Option ( ' - - debug - libicu ' , dest = ' libicu_build_variant ' , value = ' Debug ' ) , <nl> + Option ( ' - - debug - lldb ' , dest = ' lldb_build_variant ' , value = ' Debug ' ) , <nl> + Option ( ' - - debug - llvm ' , dest = ' llvm_build_variant ' , value = ' Debug ' ) , <nl> + Option ( ' - - debug - swift ' , dest = ' swift_build_variant ' , value = ' Debug ' ) , <nl> + Option ( ' - - debug - swift - stdlib ' , <nl> + dest = ' swift_stdlib_build_variant ' , value = ' Debug ' ) , <nl> + Option ( ' - - dry - run ' , dest = ' dry_run ' , value = True ) , <nl> + Option ( ' - - eclipse ' , dest = ' cmake_generator ' , value = ' Eclipse CDT4 - Ninja ' ) , <nl> + Option ( ' - - enable - sil - ownership ' , dest = ' enable_sil_ownership ' , value = True ) , <nl> + Option ( ' - - force - optimized - typechecker ' , <nl> + dest = ' force_optimized_typechecker ' , value = True ) , <nl> + Option ( ' - - ios ' , dest = ' ios ' , value = True ) , <nl> + Option ( ' - - llbuild ' , dest = ' build_llbuild ' , value = True ) , <nl> + Option ( ' - - lldb ' , dest = ' build_lldb ' , value = True ) , <nl> + Option ( ' - - lldb - assertions ' , dest = ' lldb_assertions ' , value = True ) , <nl> + Option ( ' - - llvm - assertions ' , dest = ' llvm_assertions ' , value = True ) , <nl> + Option ( ' - - make ' , dest = ' cmake_generator ' , value = ' Unix Makefiles ' ) , <nl> + Option ( ' - - no - assertions ' , dest = ' assertions ' , value = False ) , <nl> + Option ( ' - - no - legacy - impl ' , dest = ' legacy_impl ' , value = False ) , <nl> + Option ( ' - - no - lldb - assertions ' , dest = ' lldb_assertions ' , value = False ) , <nl> + Option ( ' - - no - llvm - assertions ' , dest = ' llvm_assertions ' , value = False ) , <nl> + Option ( ' - - no - swift - assertions ' , dest = ' swift_assertions ' , value = False ) , <nl> + Option ( ' - - no - swift - stdlib - assertions ' , <nl> + dest = ' swift_stdlib_assertions ' , value = False ) , <nl> + Option ( ' - - playgroundlogger ' , dest = ' build_playgroundlogger ' , value = True ) , <nl> + Option ( ' - - playgroundsupport ' , dest = ' build_playgroundsupport ' , value = True ) , <nl> + Option ( ' - - release ' , dest = ' build_variant ' , value = ' Release ' ) , <nl> + Option ( ' - - release - debuginfo ' , <nl> + dest = ' build_variant ' , value = ' RelWithDebInfo ' ) , <nl> + Option ( ' - - skip - build ' , dest = ' skip_build ' , value = True ) , <nl> + Option ( ' - - skip - ios ' , dest = ' ios ' , value = False ) , <nl> + Option ( ' - - skip - tvos ' , dest = ' tvos ' , value = False ) , <nl> + Option ( ' - - skip - watchos ' , dest = ' watchos ' , value = False ) , <nl> + Option ( ' - - swift - assertions ' , dest = ' swift_assertions ' , value = True ) , <nl> + Option ( ' - - swift - stdlib - assertions ' , <nl> + dest = ' swift_stdlib_assertions ' , value = True ) , <nl> + Option ( ' - - swiftpm ' , dest = ' build_swiftpm ' , value = True ) , <nl> + Option ( ' - - xcode ' , dest = ' cmake_generator ' , value = ' Xcode ' ) , <nl> + Option ( ' - B ' , dest = ' benchmark ' , value = True ) , <nl> + Option ( ' - R ' , dest = ' build_variant ' , value = ' Release ' ) , <nl> + Option ( ' - S ' , dest = ' skip_build ' , value = True ) , <nl> + Option ( ' - T ' , dest = ' validation_test ' , value = True ) , <nl> + Option ( ' - b ' , dest = ' build_llbuild ' , value = True ) , <nl> + Option ( ' - c ' , dest = ' clean ' , value = True ) , <nl> + Option ( ' - d ' , dest = ' build_variant ' , value = ' Debug ' ) , <nl> + Option ( ' - e ' , dest = ' cmake_generator ' , value = ' Eclipse CDT4 - Ninja ' ) , <nl> + Option ( ' - i ' , dest = ' ios ' , value = True ) , <nl> + Option ( ' - l ' , dest = ' build_lldb ' , value = True ) , <nl> + Option ( ' - m ' , dest = ' cmake_generator ' , value = ' Unix Makefiles ' ) , <nl> + Option ( ' - n ' , dest = ' dry_run ' , value = True ) , <nl> + Option ( ' - o ' , dest = ' test_optimized ' , value = True ) , <nl> + Option ( ' - p ' , dest = ' build_swiftpm ' , value = True ) , <nl> + Option ( ' - r ' , dest = ' build_variant ' , value = ' RelWithDebInfo ' ) , <nl> + Option ( ' - s ' , dest = ' test_optimize_for_size ' , value = True ) , <nl> + Option ( ' - t ' , dest = ' test ' , value = True ) , <nl> + Option ( ' - x ' , dest = ' cmake_generator ' , value = ' Xcode ' ) , <nl> + <nl> + ToggleOption ( ' - - android ' , dest = ' android ' ) , <nl> + ToggleOption ( ' - - build - ninja ' , dest = ' build_ninja ' ) , <nl> + ToggleOption ( ' - - build - runtime - with - host - compiler ' , <nl> + dest = ' build_runtime_with_host_compiler ' ) , <nl> + ToggleOption ( ' - - build - swift - dynamic - sdk - overlay ' , <nl> + dest = ' build_swift_dynamic_sdk_overlay ' ) , <nl> + ToggleOption ( ' - - build - swift - dynamic - stdlib ' , <nl> + dest = ' build_swift_dynamic_stdlib ' ) , <nl> + ToggleOption ( ' - - build - swift - static - sdk - overlay ' , <nl> + dest = ' build_swift_static_sdk_overlay ' ) , <nl> + ToggleOption ( ' - - build - swift - static - stdlib ' , <nl> + dest = ' build_swift_static_stdlib ' ) , <nl> + ToggleOption ( ' - - build - swift - stdlib - unittest - extra ' , <nl> + dest = ' build_swift_stdlib_unittest_extra ' ) , <nl> + ToggleOption ( ' - - distcc ' , dest = ' distcc ' ) , <nl> + ToggleOption ( ' - - enable - asan ' , dest = ' enable_asan ' ) , <nl> + ToggleOption ( ' - - enable - lsan ' , dest = ' enable_lsan ' ) , <nl> + ToggleOption ( ' - - enable - tsan ' , dest = ' enable_tsan ' ) , <nl> + ToggleOption ( ' - - enable - ubsan ' , dest = ' enable_ubsan ' ) , <nl> + ToggleOption ( ' - - export - compile - commands ' , dest = ' export_compile_commands ' ) , <nl> + ToggleOption ( ' - - foundation ' , dest = ' build_foundation ' ) , <nl> + ToggleOption ( ' - - host - test ' , dest = ' host_test ' ) , <nl> + ToggleOption ( ' - - libdispatch ' , dest = ' build_libdispatch ' ) , <nl> + ToggleOption ( ' - - libicu ' , dest = ' build_libicu ' ) , <nl> + ToggleOption ( ' - - long - test ' , dest = ' long_test ' ) , <nl> + ToggleOption ( ' - - show - sdks ' , dest = ' show_sdks ' ) , <nl> + ToggleOption ( ' - - skip - build - android ' , dest = ' skip_build_android ' ) , <nl> + ToggleOption ( ' - - skip - build - benchmarks ' , dest = ' skip_build_benchmarks ' ) , <nl> + ToggleOption ( ' - - skip - build - cygwin ' , dest = ' skip_build_cygwin ' ) , <nl> + ToggleOption ( ' - - skip - build - freebsd ' , dest = ' skip_build_freebsd ' ) , <nl> + ToggleOption ( ' - - skip - build - ios ' , dest = ' skip_build_ios ' ) , <nl> + ToggleOption ( ' - - skip - build - ios - device ' , dest = ' skip_build_ios_device ' ) , <nl> + ToggleOption ( ' - - skip - build - ios - simulator ' , <nl> + dest = ' skip_build_ios_simulator ' ) , <nl> + ToggleOption ( ' - - skip - build - linux ' , dest = ' skip_build_linux ' ) , <nl> + ToggleOption ( ' - - skip - build - osx ' , dest = ' skip_build_osx ' ) , <nl> + ToggleOption ( ' - - skip - build - tvos ' , dest = ' skip_build_tvos ' ) , <nl> + ToggleOption ( ' - - skip - build - tvos - device ' , dest = ' skip_build_tvos_device ' ) , <nl> + ToggleOption ( ' - - skip - build - tvos - simulator ' , <nl> + dest = ' skip_build_tvos_simulator ' ) , <nl> + ToggleOption ( ' - - skip - build - watchos ' , dest = ' skip_build_watchos ' ) , <nl> + ToggleOption ( ' - - skip - build - watchos - device ' , <nl> + dest = ' skip_build_watchos_device ' ) , <nl> + ToggleOption ( ' - - skip - build - watchos - simulator ' , <nl> + dest = ' skip_build_watchos_simulator ' ) , <nl> + ToggleOption ( ' - - skip - test - android - host ' , dest = ' skip_test_android_host ' ) , <nl> + ToggleOption ( ' - - skip - test - cygwin ' , dest = ' skip_test_cygwin ' ) , <nl> + ToggleOption ( ' - - skip - test - freebsd ' , dest = ' skip_test_freebsd ' ) , <nl> + ToggleOption ( ' - - skip - test - ios ' , dest = ' skip_test_ios ' ) , <nl> + ToggleOption ( ' - - skip - test - ios - 32bit - simulator ' , <nl> + dest = ' skip_test_ios_32bit_simulator ' ) , <nl> + ToggleOption ( ' - - skip - test - ios - host ' , dest = ' skip_test_ios_host ' ) , <nl> + ToggleOption ( ' - - skip - test - ios - simulator ' , dest = ' skip_test_ios_simulator ' ) , <nl> + ToggleOption ( ' - - skip - test - linux ' , dest = ' skip_test_linux ' ) , <nl> + ToggleOption ( ' - - skip - test - osx ' , dest = ' skip_test_osx ' ) , <nl> + ToggleOption ( ' - - skip - test - tvos ' , dest = ' skip_test_tvos ' ) , <nl> + ToggleOption ( ' - - skip - test - tvos - host ' , dest = ' skip_test_tvos_host ' ) , <nl> + ToggleOption ( ' - - skip - test - tvos - simulator ' , <nl> + dest = ' skip_test_tvos_simulator ' ) , <nl> + ToggleOption ( ' - - skip - test - watchos ' , dest = ' skip_test_watchos ' ) , <nl> + ToggleOption ( ' - - skip - test - watchos - host ' , dest = ' skip_test_watchos_host ' ) , <nl> + ToggleOption ( ' - - skip - test - watchos - simulator ' , <nl> + dest = ' skip_test_watchos_simulator ' ) , <nl> + ToggleOption ( ' - - test ' , dest = ' test ' ) , <nl> + ToggleOption ( ' - - test - optimize - for - size ' , dest = ' test_optimize_for_size ' ) , <nl> + ToggleOption ( ' - - test - optimized ' , dest = ' test_optimized ' ) , <nl> + ToggleOption ( ' - - tvos ' , dest = ' tvos ' ) , <nl> + ToggleOption ( ' - - validation - test ' , dest = ' validation_test ' ) , <nl> + ToggleOption ( ' - - verbose - build ' , dest = ' verbose_build ' ) , <nl> + ToggleOption ( ' - - watchos ' , dest = ' watchos ' ) , <nl> + ToggleOption ( ' - - xctest ' , dest = ' build_xctest ' ) , <nl> + <nl> + ChoicesOption ( ' - - android - ndk - gcc - version ' , <nl> + dest = ' android_ndk_gcc_version ' , <nl> + choices = [ ' 4 . 8 ' , ' 4 . 9 ' ] ) , <nl> + ChoicesOption ( ' - - compiler - vendor ' , <nl> + dest = ' compiler_vendor ' , <nl> + choices = [ ' none ' , ' apple ' ] ) , <nl> + ChoicesOption ( ' - - swift - analyze - code - coverage ' , <nl> + dest = ' swift_analyze_code_coverage ' , <nl> + choices = [ ' false ' , ' not - merged ' , ' merged ' ] ) , <nl> + <nl> + StrOption ( ' - - android - api - level ' , dest = ' android_api_level ' ) , <nl> + StrOption ( ' - - build - args ' , dest = ' build_args ' ) , <nl> + StrOption ( ' - - build - stdlib - deployment - targets ' , <nl> + dest = ' build_stdlib_deployment_targets ' ) , <nl> + StrOption ( ' - - darwin - deployment - version - ios ' , <nl> + dest = ' darwin_deployment_version_ios ' ) , <nl> + StrOption ( ' - - darwin - deployment - version - osx ' , <nl> + dest = ' darwin_deployment_version_osx ' ) , <nl> + StrOption ( ' - - darwin - deployment - version - tvos ' , <nl> + dest = ' darwin_deployment_version_tvos ' ) , <nl> + StrOption ( ' - - darwin - deployment - version - watchos ' , <nl> + dest = ' darwin_deployment_version_watchos ' ) , <nl> + StrOption ( ' - - darwin - xcrun - toolchain ' , dest = ' darwin_xcrun_toolchain ' ) , <nl> + StrOption ( ' - - enable - tsan - runtime ' , dest = ' enable_tsan_runtime ' ) , <nl> + StrOption ( ' - - host - target ' , dest = ' host_target ' ) , <nl> + StrOption ( ' - - lit - args ' , dest = ' lit_args ' ) , <nl> + StrOption ( ' - - llvm - targets - to - build ' , dest = ' llvm_targets_to_build ' ) , <nl> + <nl> + PathOption ( ' - - android - deploy - device - path ' , <nl> + dest = ' android_deploy_device_path ' ) , <nl> + PathOption ( ' - - android - icu - i18n ' , dest = ' android_icu_i18n ' ) , <nl> + PathOption ( ' - - android - icu - i18n - include ' , dest = ' android_icu_i18n_include ' ) , <nl> + PathOption ( ' - - android - icu - uc ' , dest = ' android_icu_uc ' ) , <nl> + PathOption ( ' - - android - icu - uc - include ' , dest = ' android_icu_uc_include ' ) , <nl> + PathOption ( ' - - android - ndk ' , dest = ' android_ndk ' ) , <nl> + PathOption ( ' - - build - subdir ' , dest = ' build_subdir ' ) , <nl> + PathOption ( ' - - clang - profile - instr - use ' , dest = ' clang_profile_instr_use ' ) , <nl> + PathOption ( ' - - cmake ' , dest = ' cmake ' ) , <nl> + PathOption ( ' - - coverage - db ' , dest = ' coverage_db ' ) , <nl> + PathOption ( ' - - host - cc ' , dest = ' host_cc ' ) , <nl> + PathOption ( ' - - host - cxx ' , dest = ' host_cxx ' ) , <nl> + PathOption ( ' - - host - libtool ' , dest = ' host_libtool ' ) , <nl> + PathOption ( ' - - host - lipo ' , dest = ' host_lipo ' ) , <nl> + PathOption ( ' - - install - prefix ' , dest = ' install_prefix ' ) , <nl> + PathOption ( ' - - install - symroot ' , dest = ' install_symroot ' ) , <nl> + PathOption ( ' - - symbols - package ' , dest = ' symbols_package ' ) , <nl> + <nl> + IntOption ( ' - - benchmark - num - o - iterations ' , <nl> + dest = ' benchmark_num_o_iterations ' ) , <nl> + IntOption ( ' - - benchmark - num - onone - iterations ' , <nl> + dest = ' benchmark_num_onone_iterations ' ) , <nl> + IntOption ( ' - - jobs ' , dest = ' build_jobs ' ) , <nl> + IntOption ( ' - - llvm - max - parallel - lto - link - jobs ' , <nl> + dest = ' llvm_max_parallel_lto_link_jobs ' ) , <nl> + IntOption ( ' - - swift - tools - max - parallel - lto - link - jobs ' , <nl> + dest = ' swift_tools_max_parallel_lto_link_jobs ' ) , <nl> + IntOption ( ' - j ' , dest = ' build_jobs ' ) , <nl> + <nl> + AppendOption ( ' - - cross - compile - hosts ' , dest = ' cross_compile_hosts ' ) , <nl> + AppendOption ( ' - - extra - cmake - options ' , dest = ' extra_cmake_options ' ) , <nl> + AppendOption ( ' - - extra - swift - args ' , dest = ' extra_swift_args ' ) , <nl> + AppendOption ( ' - - stdlib - deployment - targets ' , <nl> + dest = ' stdlib_deployment_targets ' ) , <nl> + <nl> + UnsupportedOption ( ' - - build - jobs ' ) , <nl> + UnsupportedOption ( ' - - common - cmake - options ' ) , <nl> + UnsupportedOption ( ' - - ios - all ' ) , <nl> + UnsupportedOption ( ' - - only - execute ' ) , <nl> + UnsupportedOption ( ' - - skip - test - optimize - for - size ' ) , <nl> + UnsupportedOption ( ' - - skip - test - optimized ' ) , <nl> + UnsupportedOption ( ' - - tvos - all ' ) , <nl> + UnsupportedOption ( ' - - watchos - all ' ) , <nl> + UnsupportedOption ( ' - I ' ) , <nl> + <nl> + # NOTE : LTO flag is a special case that acts both as an option and has <nl> + # valid choices <nl> + Option ( ' - - lto ' , dest = ' lto_type ' ) , <nl> + ChoicesOption ( ' - - lto ' , dest = ' lto_type ' , choices = [ ' thin ' , ' full ' ] ) , <nl> + <nl> + # NOTE : We ' ll need to manually test the behavior of these since they <nl> + # validate compiler version strings . <nl> + IgnoreOption ( ' - - clang - compiler - version ' , <nl> + dest = ' clang_compiler_version ' ) , <nl> + IgnoreOption ( ' - - clang - user - visible - version ' , <nl> + dest = ' clang_user_visible_version ' ) , <nl> + IgnoreOption ( ' - - swift - compiler - version ' , <nl> + dest = ' swift_compiler_version ' ) , <nl> + IgnoreOption ( ' - - swift - user - visible - version ' , <nl> + dest = ' swift_user_visible_version ' ) , <nl> + ] <nl> new file mode 100644 <nl> index 000000000000 . . 8fdb3ba18769 <nl> mmm / dev / null <nl> ppp b / utils / build_swift / tests / test_driver_arguments . py <nl> <nl> + # This source file is part of the Swift . org open source project <nl> + # <nl> + # Copyright ( c ) 2014 - 2017 Apple Inc . and the Swift project authors <nl> + # Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + # <nl> + # See https : / / swift . org / LICENSE . txt for license information <nl> + # See https : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + <nl> + from __future__ import print_function <nl> + <nl> + import os <nl> + import sys <nl> + import unittest <nl> + <nl> + from contextlib import contextmanager <nl> + from io import StringIO <nl> + <nl> + from build_swift import driver_arguments <nl> + from build_swift . tests import expected_options <nl> + <nl> + from swift_build_support . swift_build_support import migration <nl> + from swift_build_support . swift_build_support . SwiftBuildSupport import ( <nl> + get_all_preset_names , <nl> + get_preset_options , <nl> + ) <nl> + <nl> + FILE_PATH = os . path . abspath ( __file__ ) <nl> + TESTS_PATH = os . path . abspath ( os . path . join ( FILE_PATH , os . pardir ) ) <nl> + BUILD_SWIFT_PATH = os . path . abspath ( os . path . join ( TESTS_PATH , os . pardir ) ) <nl> + UTILS_PATH = os . path . abspath ( os . path . join ( BUILD_SWIFT_PATH , os . pardir ) ) <nl> + <nl> + BUILD_SCRIPT_IMPL = os . path . join ( UTILS_PATH , ' build - script - impl ' ) <nl> + <nl> + PRESETS_FILES = [ <nl> + os . path . join ( UTILS_PATH , ' build - presets . ini ' ) , <nl> + ] <nl> + <nl> + <nl> + class ParserError ( Exception ) : <nl> + pass <nl> + <nl> + <nl> + @ contextmanager <nl> + def redirect_stderr ( stream = None ) : <nl> + stream = stream or StringIO ( ) <nl> + old_stderr , sys . stderr = sys . stderr , stream <nl> + try : <nl> + yield stream <nl> + finally : <nl> + sys . stderr = old_stderr <nl> + <nl> + <nl> + @ contextmanager <nl> + def redirect_stdout ( stream = None ) : <nl> + stream = stream or StringIO ( ) <nl> + old_stdout , sys . stdout = sys . stdout , stream <nl> + try : <nl> + yield stream <nl> + finally : <nl> + sys . stdout = old_stdout <nl> + <nl> + <nl> + def _load_all_presets ( presets_files ) : <nl> + preset_names = get_all_preset_names ( presets_files ) <nl> + <nl> + # Hack to filter out mixins which are not expected to be valid presets <nl> + preset_names = [ n for n in preset_names if not n . startswith ( ' mixin ' ) ] <nl> + <nl> + substitutions = { <nl> + ' install_destdir ' : ' / tmp / install ' , <nl> + ' install_symroot ' : ' / tmp / symroot ' , <nl> + ' installable_package ' : ' / tmp / xcode - xyz - root . tar . gz ' , <nl> + } <nl> + <nl> + presets = dict ( ) <nl> + for name in preset_names : <nl> + try : <nl> + # Attempt to parse preset <nl> + presets [ name ] = get_preset_options ( substitutions , <nl> + presets_files , name ) <nl> + except SystemExit : <nl> + continue <nl> + <nl> + return presets <nl> + <nl> + <nl> + class TestDriverArgumentParserMeta ( type ) : <nl> + " " " Metaclass used to dynamically generate test methods for each of the <nl> + individual options accepted by the parser and methods to validate all of <nl> + the presets . <nl> + " " " <nl> + <nl> + def __new__ ( cls , name , bases , attrs ) : <nl> + # Generate tests for each default value <nl> + for dest , value in expected_options . EXPECTED_DEFAULTS . items ( ) : <nl> + test_name = ' test_default_value_ ' + dest <nl> + attrs [ test_name ] = cls . generate_default_value_test ( dest , value ) <nl> + <nl> + # Generate tests for each expected option <nl> + for option in expected_options . EXPECTED_OPTIONS : <nl> + test_name = ' test_option_ ' + option . sanitized_str ( ) <nl> + attrs [ test_name ] = cls . generate_option_test ( option ) <nl> + <nl> + # Generate tests for each preset <nl> + presets = _load_all_presets ( PRESETS_FILES ) <nl> + <nl> + for name , args in presets . items ( ) : <nl> + test_name = ' test_preset_ ' + name <nl> + attrs [ test_name ] = cls . generate_preset_test ( name , args ) <nl> + <nl> + return super ( TestDriverArgumentParserMeta , cls ) . __new__ ( <nl> + cls , name , bases , attrs ) <nl> + <nl> + @ classmethod <nl> + def generate_default_value_test ( cls , dest , default_value ) : <nl> + def test ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + parsed_values = self . parse_args ( [ ] ) <nl> + <nl> + parsed_value = getattr ( parsed_values , dest ) <nl> + if default_value . __class__ is str : <nl> + parsed_value = str ( parsed_value ) <nl> + <nl> + self . assertEqual ( default_value , parsed_value , <nl> + ' Invalid default value for " { } " : { } ! = { } ' <nl> + . format ( dest , default_value , parsed_value ) ) <nl> + <nl> + return test <nl> + <nl> + @ classmethod <nl> + def _generate_option_test ( cls , option ) : <nl> + def test ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ option . option_string ] ) <nl> + self . assertEqual ( getattr ( args , option . dest ) , option . value ) <nl> + <nl> + with self . assertRaises ( ParserError ) : <nl> + self . parse_args ( [ option . option_string , ' foo ' ] ) <nl> + <nl> + return test <nl> + <nl> + @ classmethod <nl> + def _generate_append_option_test ( cls , option ) : <nl> + def test ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + # Range size is arbitrary , just needs to be more than once <nl> + for i in range ( 1 , 4 ) : <nl> + args = self . parse_args ( [ option . option_string , ' ARG ' ] * i ) <nl> + self . assertEqual ( getattr ( args , option . dest ) , [ ' ARG ' ] * i ) <nl> + <nl> + return test <nl> + <nl> + @ classmethod <nl> + def _generate_choices_option_test ( cls , option ) : <nl> + def test ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + for choice in option . choices : <nl> + args = self . parse_args ( [ option . option_string , str ( choice ) ] ) <nl> + self . assertEqual ( getattr ( args , option . dest ) , choice ) <nl> + <nl> + with self . assertRaises ( ParserError ) : <nl> + self . parse_args ( [ option . option_string , ' INVALID ' ] ) <nl> + <nl> + return test <nl> + <nl> + @ classmethod <nl> + def _generate_help_option_test ( cls , option ) : <nl> + def test ( self ) : <nl> + with redirect_stdout ( ) as output , self . assertRaises ( ParserError ) : <nl> + self . parse_args ( [ option . option_string ] ) <nl> + self . assertNotEmpty ( output ) <nl> + <nl> + @ classmethod <nl> + def _generate_int_option_test ( cls , option ) : <nl> + def test ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + for i in [ 0 , 1 , 42 ] : <nl> + args = self . parse_args ( [ option . option_string , str ( i ) ] ) <nl> + self . assertEqual ( int ( getattr ( args , option . dest ) ) , i ) <nl> + <nl> + # FIXME : int - type options should not accept non - int strings <nl> + # with self . assertRaises ( ParserError ) : <nl> + # self . parse_args ( [ option . option_string , str ( 0 . 0 ) ] ) <nl> + # self . parse_args ( [ option . option_string , str ( 1 . 0 ) ] ) <nl> + # self . parse_args ( [ option . option_string , str ( 3 . 14 ) ] ) <nl> + # self . parse_args ( [ option . option_string , ' NaN ' ] ) <nl> + <nl> + return test <nl> + <nl> + @ classmethod <nl> + def _generate_path_option_test ( cls , option ) : <nl> + def test ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + self . parse_args ( [ option . option_string , sys . executable ] ) <nl> + <nl> + # FIXME : path - type options should not accept non - path inputs <nl> + # with self . assertRaises ( ParserError ) : <nl> + # self . parse_args ( [ option . option_string , ' foo ' ] ) <nl> + <nl> + return test <nl> + <nl> + @ classmethod <nl> + def _generate_str_option_test ( cls , option ) : <nl> + def test ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + self . parse_args ( [ option . option_string , ' foo ' ] ) <nl> + <nl> + return test <nl> + <nl> + @ classmethod <nl> + def _generate_toggle_option_test ( cls , option ) : <nl> + def test ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + # Standalone argument <nl> + self . parse_args ( [ option . option_string ] ) <nl> + <nl> + # True values <nl> + # self . parse_args ( [ option . option_string , True ] ) <nl> + # self . parse_args ( [ option . option_string , 1 ] ) <nl> + self . parse_args ( [ option . option_string , ' 1 ' ] ) <nl> + self . parse_args ( [ option . option_string , ' true ' ] ) <nl> + self . parse_args ( [ option . option_string , ' True ' ] ) <nl> + # self . parse_args ( [ option . option_string , ' TRUE ' ] ) <nl> + <nl> + # False values <nl> + # self . parse_args ( [ option . option_string , False ] ) <nl> + # self . parse_args ( [ option . option_string , 0 ] ) <nl> + self . parse_args ( [ option . option_string , ' 0 ' ] ) <nl> + self . parse_args ( [ option . option_string , ' false ' ] ) <nl> + self . parse_args ( [ option . option_string , ' False ' ] ) <nl> + # self . parse_args ( [ option . option_string , ' FALSE ' ] ) <nl> + <nl> + return test <nl> + <nl> + @ classmethod <nl> + def _generate_unsupported_option_test ( cls , option ) : <nl> + def test ( self ) : <nl> + with self . assertRaises ( ParserError ) : <nl> + self . parse_args ( [ option . option_string ] ) <nl> + <nl> + return test <nl> + <nl> + @ classmethod <nl> + def generate_option_test ( cls , option ) : <nl> + if option . __class__ is expected_options . Option : <nl> + return cls . _generate_option_test ( option ) <nl> + elif option . __class__ is expected_options . AppendOption : <nl> + return cls . _generate_append_option_test ( option ) <nl> + elif option . __class__ is expected_options . ChoicesOption : <nl> + return cls . _generate_choices_option_test ( option ) <nl> + elif option . __class__ is expected_options . HelpOption : <nl> + return cls . _generate_help_option_test ( option ) <nl> + elif option . __class__ is expected_options . IntOption : <nl> + return cls . _generate_int_option_test ( option ) <nl> + elif option . __class__ is expected_options . PathOption : <nl> + return cls . _generate_path_option_test ( option ) <nl> + elif option . __class__ is expected_options . StrOption : <nl> + return cls . _generate_str_option_test ( option ) <nl> + elif option . __class__ is expected_options . ToggleOption : <nl> + return cls . _generate_toggle_option_test ( option ) <nl> + elif option . __class__ is expected_options . UnsupportedOption : <nl> + return cls . _generate_unsupported_option_test ( option ) <nl> + <nl> + # Ignore all IgnoreOption tests since they should be manually tested <nl> + elif option . __class__ is expected_options . IgnoreOption : <nl> + return lambda self : None <nl> + <nl> + # Catch - all meaningless test <nl> + return lambda self : \ <nl> + self . fail ( ' Unexpected option " { } " ' . format ( option . option_string ) ) <nl> + <nl> + @ classmethod <nl> + def generate_preset_test ( cls , preset_name , preset_args ) : <nl> + def test ( self ) : <nl> + try : <nl> + self . parse_args ( preset_args , check_impl_args = True ) <nl> + except ParserError as e : <nl> + self . fail ( ' Failed to parse preset " { } " : { } ' . format ( <nl> + preset_name , e ) ) <nl> + <nl> + return test <nl> + <nl> + <nl> + class TestDriverArgumentParser ( unittest . TestCase ) : <nl> + <nl> + __metaclass__ = TestDriverArgumentParserMeta <nl> + <nl> + def parse_args ( self , args , error_message = None , check_impl_args = False ) : <nl> + if error_message is None : <nl> + error_message = ' failed to parse arguments : ' + str ( args ) <nl> + <nl> + with open ( os . devnull , ' w ' ) as devnull : <nl> + try : <nl> + with redirect_stderr ( devnull ) , redirect_stdout ( devnull ) : <nl> + namespace = migration . parse_args ( self . parser , args ) <nl> + except ( SystemExit , ValueError ) as e : <nl> + raise ParserError ( error_message , e ) <nl> + <nl> + if not namespace . build_script_impl_args and not check_impl_args : <nl> + return namespace <nl> + <nl> + try : <nl> + with redirect_stderr ( devnull ) , redirect_stdout ( devnull ) : <nl> + migration . check_impl_args ( BUILD_SCRIPT_IMPL , <nl> + namespace . build_script_impl_args ) <nl> + except ( SystemExit , ValueError ) as e : <nl> + raise ParserError ( error_message , e ) <nl> + <nl> + return namespace <nl> + <nl> + @ contextmanager <nl> + def assertNotRaises ( self , exception ) : <nl> + assert issubclass ( exception , BaseException ) <nl> + <nl> + try : <nl> + yield <nl> + except exception as e : <nl> + self . fail ( str ( e ) ) <nl> + <nl> + def setUp ( self ) : <nl> + self . parser = driver_arguments . create_argument_parser ( ) <nl> + <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + # Manual option tests <nl> + <nl> + def test_option_clang_compiler_version ( self ) : <nl> + option_string = ' - - clang - compiler - version ' <nl> + <nl> + with self . assertNotRaises ( ParserError ) : <nl> + self . parse_args ( [ option_string , ' 5 . 0 . 0 ' ] ) <nl> + self . parse_args ( [ option_string , ' 5 . 0 . 1 ' ] ) <nl> + self . parse_args ( [ option_string , ' 5 . 0 . 0 . 1 ' ] ) <nl> + <nl> + with self . assertRaises ( ParserError ) : <nl> + self . parse_args ( [ option_string , ' 1 ' ] ) <nl> + self . parse_args ( [ option_string , ' 1 . 2 ' ] ) <nl> + self . parse_args ( [ option_string , ' 0 . 0 . 0 . 0 . 1 ' ] ) <nl> + <nl> + def test_option_clang_user_visible_version ( self ) : <nl> + option_string = ' - - clang - user - visible - version ' <nl> + <nl> + with self . assertNotRaises ( ParserError ) : <nl> + self . parse_args ( [ option_string , ' 5 . 0 . 0 ' ] ) <nl> + self . parse_args ( [ option_string , ' 5 . 0 . 1 ' ] ) <nl> + self . parse_args ( [ option_string , ' 5 . 0 . 0 . 1 ' ] ) <nl> + <nl> + with self . assertRaises ( ParserError ) : <nl> + self . parse_args ( [ option_string , ' 1 ' ] ) <nl> + self . parse_args ( [ option_string , ' 1 . 2 ' ] ) <nl> + self . parse_args ( [ option_string , ' 0 . 0 . 0 . 0 . 1 ' ] ) <nl> + <nl> + def test_option_swift_compiler_version ( self ) : <nl> + option_string = ' - - swift - compiler - version ' <nl> + <nl> + with self . assertNotRaises ( ParserError ) : <nl> + self . parse_args ( [ option_string , ' 4 . 1 ' ] ) <nl> + self . parse_args ( [ option_string , ' 4 . 0 . 1 ' ] ) <nl> + self . parse_args ( [ option_string , ' 200 . 99 . 1 ' ] ) <nl> + <nl> + with self . assertRaises ( ParserError ) : <nl> + self . parse_args ( [ option_string , ' 1 ' ] ) <nl> + self . parse_args ( [ option_string , ' 0 . 0 . 0 . 1 ' ] ) <nl> + <nl> + def test_option_swift_user_visible_version ( self ) : <nl> + option_string = ' - - swift - user - visible - version ' <nl> + <nl> + with self . assertNotRaises ( ParserError ) : <nl> + self . parse_args ( [ option_string , ' 4 . 1 ' ] ) <nl> + self . parse_args ( [ option_string , ' 4 . 0 . 1 ' ] ) <nl> + self . parse_args ( [ option_string , ' 200 . 99 . 1 ' ] ) <nl> + <nl> + with self . assertRaises ( ParserError ) : <nl> + self . parse_args ( [ option_string , ' 1 ' ] ) <nl> + self . parse_args ( [ option_string , ' 0 . 0 . 0 . 1 ' ] ) <nl> + <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + # Implied defaults tests <nl> + <nl> + def test_implied_defaults_assertions ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - assertions ' ] ) <nl> + <nl> + self . assertTrue ( args . cmark_assertions ) <nl> + self . assertTrue ( args . llvm_assertions ) <nl> + self . assertTrue ( args . swift_assertions ) <nl> + self . assertTrue ( args . swift_stdlib_assertions ) <nl> + <nl> + def test_implied_defaults_cmark_build_variant ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - debug - cmark ' ] ) <nl> + self . assertTrue ( args . build_cmark ) <nl> + <nl> + def test_implied_defaults_lldb_build_variant ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - debug - lldb ' ] ) <nl> + self . assertTrue ( args . build_lldb ) <nl> + <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - lldb - assertions ' ] ) <nl> + self . assertTrue ( args . build_lldb ) <nl> + <nl> + def test_implied_defaults_build_variant ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - debug ' ] ) <nl> + <nl> + self . assertEquals ( args . cmark_build_variant , ' Debug ' ) <nl> + self . assertEquals ( args . foundation_build_variant , ' Debug ' ) <nl> + self . assertEquals ( args . libdispatch_build_variant , ' Debug ' ) <nl> + self . assertEquals ( args . libicu_build_variant , ' Debug ' ) <nl> + self . assertEquals ( args . lldb_build_variant , ' Debug ' ) <nl> + self . assertEquals ( args . llvm_build_variant , ' Debug ' ) <nl> + self . assertEquals ( args . swift_build_variant , ' Debug ' ) <nl> + self . assertEquals ( args . swift_stdlib_build_variant , ' Debug ' ) <nl> + <nl> + def test_implied_defaults_skip_build ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - skip - build ' ] ) <nl> + <nl> + self . assertTrue ( args . skip_build_benchmarks ) <nl> + <nl> + self . assertTrue ( args . skip_build_linux ) <nl> + self . assertTrue ( args . skip_build_android ) <nl> + self . assertTrue ( args . skip_build_freebsd ) <nl> + self . assertTrue ( args . skip_build_cygwin ) <nl> + self . assertTrue ( args . skip_build_osx ) <nl> + self . assertTrue ( args . skip_build_ios ) <nl> + self . assertTrue ( args . skip_build_tvos ) <nl> + self . assertTrue ( args . skip_build_watchos ) <nl> + <nl> + self . assertFalse ( args . build_foundation ) <nl> + self . assertFalse ( args . build_libdispatch ) <nl> + self . assertFalse ( args . build_libicu ) <nl> + self . assertFalse ( args . build_lldb ) <nl> + self . assertFalse ( args . build_llbuild ) <nl> + self . assertFalse ( args . build_playgroundlogger ) <nl> + self . assertFalse ( args . build_playgroundsupport ) <nl> + self . assertFalse ( args . build_swiftpm ) <nl> + self . assertFalse ( args . build_xctest ) <nl> + <nl> + def test_implied_defaults_skip_build_ios ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - skip - build - ios ' ] ) <nl> + self . assertTrue ( args . skip_build_ios_device ) <nl> + self . assertTrue ( args . skip_build_ios_simulator ) <nl> + <nl> + # Also implies that the tests should be skipped <nl> + self . assertTrue ( args . skip_test_ios_host ) <nl> + self . assertTrue ( args . skip_test_ios_simulator ) <nl> + <nl> + def test_implied_defaults_skip_build_tvos ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - skip - build - tvos ' ] ) <nl> + self . assertTrue ( args . skip_build_tvos_device ) <nl> + self . assertTrue ( args . skip_build_tvos_simulator ) <nl> + <nl> + # Also implies that the tests should be skipped <nl> + self . assertTrue ( args . skip_test_tvos_host ) <nl> + self . assertTrue ( args . skip_test_tvos_simulator ) <nl> + <nl> + def test_implied_defaults_skip_build_watchos ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - skip - build - watchos ' ] ) <nl> + self . assertTrue ( args . skip_build_watchos_device ) <nl> + self . assertTrue ( args . skip_build_watchos_simulator ) <nl> + <nl> + # Also implies that the tests should be skipped <nl> + self . assertTrue ( args . skip_test_watchos_host ) <nl> + self . assertTrue ( args . skip_test_watchos_simulator ) <nl> + <nl> + def test_implied_defaults_validation_test ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - validation - test ' ] ) <nl> + self . assertTrue ( args . test ) <nl> + <nl> + def test_implied_defaults_test_optimized ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - test - optimized ' ] ) <nl> + self . assertTrue ( args . test ) <nl> + <nl> + def test_implied_defaults_test_optimize_for_size ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - test - optimize - for - size ' ] ) <nl> + self . assertTrue ( args . test ) <nl> + <nl> + def test_implied_defaults_skip_all_tests ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ <nl> + ' - - test ' , ' 0 ' , <nl> + ' - - validation - test ' , ' 0 ' , <nl> + ' - - long - test ' , ' 0 ' , <nl> + ] ) <nl> + <nl> + self . assertTrue ( args . skip_test_linux ) <nl> + self . assertTrue ( args . skip_test_freebsd ) <nl> + self . assertTrue ( args . skip_test_cygwin ) <nl> + self . assertTrue ( args . skip_test_osx ) <nl> + self . assertTrue ( args . skip_test_ios ) <nl> + self . assertTrue ( args . skip_test_tvos ) <nl> + self . assertTrue ( args . skip_test_watchos ) <nl> + <nl> + def test_implied_defaults_skip_test_ios ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - skip - test - ios ' ] ) <nl> + self . assertTrue ( args . skip_test_ios_host ) <nl> + self . assertTrue ( args . skip_test_ios_simulator ) <nl> + <nl> + def test_implied_defaults_skip_test_tvos ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - skip - test - tvos ' ] ) <nl> + self . assertTrue ( args . skip_test_tvos_host ) <nl> + self . assertTrue ( args . skip_test_tvos_simulator ) <nl> + <nl> + def test_implied_defaults_skip_test_watchos ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - skip - test - watchos ' ] ) <nl> + self . assertTrue ( args . skip_test_watchos_host ) <nl> + self . assertTrue ( args . skip_test_watchos_simulator ) <nl> + <nl> + def test_implied_defaults_skip_build_android ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - android ' , ' 0 ' ] ) <nl> + self . assertTrue ( args . skip_test_android_host ) <nl> + <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - skip - build - android ' ] ) <nl> + self . assertTrue ( args . skip_test_android_host ) <nl> + <nl> + def test_implied_defaults_host_test ( self ) : <nl> + with self . assertNotRaises ( ParserError ) : <nl> + args = self . parse_args ( [ ' - - host - test ' , ' 0 ' ] ) <nl> + self . assertTrue ( args . skip_test_ios_host ) <nl> + self . assertTrue ( args . skip_test_tvos_host ) <nl> + self . assertTrue ( args . skip_test_watchos_host ) <nl> + self . assertTrue ( args . skip_test_android_host ) <nl> + <nl> + <nl> + if __name__ = = ' __main__ ' : <nl> + unittest . main ( ) <nl>
|
Move legacy argparser ( )
|
apple/swift
|
695ded24d402891561a1b7241b6fd5a00c337e1e
|
2017-09-15T08:05:06Z
|
new file mode 100644 <nl> index 000000000000 . . e3d2f7e51d28 <nl> mmm / dev / null <nl> ppp b / jstests / replsets / reconfig_add_remove_arbiter . js <nl> <nl> + / * <nl> + * Test that replSetReconfig can add and remove arbiters . <nl> + * / <nl> + <nl> + / / isMaster fails on the arbiter once it ' s removed , which blocks all checks . <nl> + TestData . skipCheckDBHashes = true ; <nl> + <nl> + ( function ( ) { <nl> + ' use strict ' ; <nl> + <nl> + load ( ' jstests / replsets / rslib . js ' ) ; <nl> + <nl> + const replTest = new ReplSetTest ( { nodes : 2 } ) ; <nl> + replTest . startSet ( ) ; <nl> + replTest . initiate ( ) ; <nl> + <nl> + jsTestLog ( ' Start arbiter ' ) ; <nl> + const arbiterConn = replTest . add ( ) ; <nl> + const admin = replTest . getPrimary ( ) . getDB ( ' admin ' ) ; <nl> + const conf = replTest . getReplSetConfigFromNode ( ) ; <nl> + conf . members . push ( { _id : 2 , host : arbiterConn . host , arbiterOnly : true } ) ; <nl> + conf . version + + ; <nl> + <nl> + jsTestLog ( ' Add arbiter ' ) ; <nl> + assert . commandWorked ( admin . runCommand ( { replSetReconfig : conf } ) ) ; <nl> + <nl> + replTest . waitForState ( arbiterConn , ReplSetTest . State . ARBITER ) ; <nl> + jsTestLog ( ` Wait for $ { arbiterConn } to enter state ARBITER in primary ' s replSetGetStatus ` ) ; <nl> + assert . soon ( ( ) = > { <nl> + let status = assert . commandWorked ( admin . runCommand ( { replSetGetStatus : 1 } ) ) ; <nl> + return ReplSetTest . State . ARBITER = = = status . members [ 2 ] . state ; <nl> + } ) ; <nl> + <nl> + conf . members . pop ( ) ; <nl> + conf . version + + ; <nl> + <nl> + jsTestLog ( ' Remove arbiter ' ) ; <nl> + assert . commandWorked ( admin . runCommand ( { replSetReconfig : conf } ) ) ; <nl> + <nl> + assert . soon ( <nl> + ( ) = > { <nl> + / / The arbiter dropped connections when it was removed . <nl> + reconnect ( arbiterConn ) ; <nl> + let status = arbiterConn . getDB ( ' admin ' ) . runCommand ( { replSetGetStatus : 1 } ) ; <nl> + print ( ` replSetGetStatus : $ { tojson ( status ) } ` ) ; <nl> + return status . code = = = ErrorCodes . InvalidReplicaSetConfig ; <nl> + } , <nl> + " waiting for arbiter ' s replSetGetStatus to show that the arbiter was removed " , <nl> + undefined / * timeout * / , <nl> + 1000 / * intervalMS * / ) ; <nl> + <nl> + replTest . stopSet ( ) ; <nl> + } ) ( ) ; <nl> mmm a / src / mongo / db / keys_collection_manager . cpp <nl> ppp b / src / mongo / db / keys_collection_manager . cpp <nl> void KeysCollectionManager : : stopMonitoring ( ) { <nl> _refresher . stop ( ) ; <nl> } <nl> <nl> - void KeysCollectionManager : : enableKeyGenerator ( OperationContext * opCtx , bool doEnable ) { <nl> + void KeysCollectionManager : : enableKeyGenerator ( OperationContext * opCtx , bool doEnable ) try { <nl> if ( doEnable ) { <nl> _refresher . switchFunc ( opCtx , [ this ] ( OperationContext * opCtx ) { <nl> KeyGenerator keyGenerator ( _purpose , _client . get ( ) , _keyValidForInterval ) ; <nl> void KeysCollectionManager : : enableKeyGenerator ( OperationContext * opCtx , bool doE <nl> _refresher . switchFunc ( <nl> opCtx , [ this ] ( OperationContext * opCtx ) { return _keysCache . refresh ( opCtx ) ; } ) ; <nl> } <nl> + } catch ( const ExceptionForCat < ErrorCategory : : ShutdownError > & ex ) { <nl> + LOGV2 ( 518091 , " { ex } , doEnable = { doEnable } " , " ex " _attr = ex , " doEnable " _attr = doEnable ) ; <nl> + return ; <nl> } <nl> <nl> bool KeysCollectionManager : : hasSeenKeys ( ) { <nl>
|
SERVER - 46218 Fix removal / shutdown race in arbiter
|
mongodb/mongo
|
32f47846d78a4fdae9564b7ebb442d53e737d845
|
2020-02-20T11:33:38Z
|
mmm a / library / core / ArrayObject . php <nl> ppp b / library / core / ArrayObject . php <nl> public function next ( ) <nl> <nl> / * * <nl> * @ param $ key <nl> - * @ return mixed <nl> + * @ return ArrayObject | StringObject | mixed <nl> * / <nl> public function get ( $ key ) <nl> { <nl> - return $ this - > array [ $ key ] ; <nl> + return self : : detectType ( $ this - > array [ $ key ] ) ; <nl> } <nl> <nl> / * * <nl> public function exists ( $ key ) : bool <nl> <nl> / * * <nl> * @ param $ value <nl> + * @ param bool $ strict <nl> * @ return bool <nl> * / <nl> public function contains ( $ value , bool $ strict = true ) : bool <nl> public function popFront ( ) <nl> <nl> / * * <nl> * @ param $ offset <nl> - * @ param $ length <nl> + * @ param int $ length <nl> + * @ param bool $ preserve_keys <nl> * @ return static <nl> * / <nl> public function slice ( $ offset , int $ length = null , bool $ preserve_keys = false ) : self <nl> public function slice ( $ offset , int $ length = null , bool $ preserve_keys = false ) : <nl> / * * <nl> * @ return mixed <nl> * / <nl> - public function rand ( ) <nl> + public function randGet ( ) <nl> { <nl> - return $ this - > array [ array_rand ( $ this - > array , 1 ) ] ; <nl> + return self : : detectType ( $ this - > array [ array_rand ( $ this - > array , 1 ) ] ) ; <nl> } <nl> <nl> / * * <nl> public function reduce ( callable $ fn ) <nl> } <nl> <nl> / * * <nl> - * @ param null $ search_value <nl> + * @ param int $ search_value <nl> * @ param bool $ strict <nl> * @ return static <nl> * / <nl> public function values ( ) : self <nl> <nl> / * * <nl> * @ param $ column_key <nl> - * @ param null $ index <nl> + * @ param mixed . . . $ index <nl> * @ return static <nl> * / <nl> public function column ( $ column_key , . . . $ index ) : self <nl> public function sort ( int $ sort_flags = SORT_REGULAR ) : self <nl> } <nl> <nl> / * * <nl> - * @ param int $ sort_flags <nl> + * @ param callable $ value_compare_func <nl> * @ return $ this <nl> * / <nl> public function uasort ( callable $ value_compare_func ) : self <nl> public function uasort ( callable $ value_compare_func ) : self <nl> } <nl> <nl> / * * <nl> - * @ param int $ sort_flags <nl> + * @ param callable $ value_compare_func <nl> * @ return $ this <nl> * / <nl> public function uksort ( callable $ value_compare_func ) : self <nl> public function uksort ( callable $ value_compare_func ) : self <nl> } <nl> <nl> / * * <nl> - * @ param int $ sort_flags <nl> + * @ param callable $ value_compare_func <nl> * @ return $ this <nl> * / <nl> public function usort ( callable $ value_compare_func ) : self <nl> public function usort ( callable $ value_compare_func ) : self <nl> return $ this ; <nl> } <nl> <nl> + / * * <nl> + * @ param $ value <nl> + * @ return ArrayObject | StringObject | mixed <nl> + * / <nl> + static function detectType ( $ value ) <nl> + { <nl> + if ( is_array ( $ value ) ) <nl> + { <nl> + return new static ( $ value ) ; <nl> + } <nl> + elseif ( is_string ( $ value ) ) <nl> + { <nl> + return new StringObject ( $ value ) ; <nl> + } <nl> + else <nl> + { <nl> + return $ value ; <nl> + } <nl> + } <nl> + <nl> / * * <nl> * @ return array <nl> * / <nl> mmm a / library / core / StringObject . php <nl> ppp b / library / core / StringObject . php <nl> public function rtrim ( ) : self <nl> <nl> / * * <nl> * @ param int $ offset <nl> - * @ param int | null $ length <nl> - * @ return static <nl> + * @ param mixed . . . $ length <nl> + * @ return StringObject <nl> * / <nl> public function substr ( int $ offset , . . . $ length ) : self <nl> { <nl> public function endsWith ( string $ needle ) : bool <nl> / * * <nl> * @ param string $ delimiter <nl> * @ param int $ limit <nl> - * @ return array <nl> + * @ return ArrayObject <nl> * / <nl> - public function split ( string $ delimiter , int $ limit = PHP_INT_MAX ) : array <nl> + public function split ( string $ delimiter , int $ limit = PHP_INT_MAX ) : ArrayObject <nl> { <nl> - return explode ( $ delimiter , $ this - > string , $ limit ) ; <nl> + return new ArrayObject ( explode ( $ delimiter , $ this - > string , $ limit ) ) ; <nl> } <nl> <nl> / * * <nl> public function char ( int $ index ) : string <nl> / * * <nl> * @ param int $ chunkLength <nl> * @ param string $ chunkEnd <nl> - * @ return array <nl> + * @ return StringObject <nl> + * / <nl> + public function chunkSplit ( int $ chunkLength = 1 , string $ chunkEnd = ' ' ) : StringObject <nl> + { <nl> + return new static ( chunk_split ( $ this - > string , $ chunkLength , $ chunkEnd ) ) ; <nl> + } <nl> + <nl> + / * * <nl> + * @ param int $ splitLength <nl> + * @ return ArrayObject <nl> * / <nl> - public function chunk ( int $ chunkLength = 1 , string $ chunkEnd = ' ' ) : array <nl> + public function chunk ( $ splitLength = 1 ) <nl> { <nl> - return chunk_split ( $ this - > string , $ chunkLength , $ chunkEnd ) ; <nl> + return new ArrayObject ( str_split ( $ this - > string , $ splitLength ) ) ; <nl> } <nl> <nl> / * * <nl> - * @ param bool $ assoc <nl> * @ param int $ depth <nl> * @ param int $ options <nl> * @ return mixed <nl> * / <nl> - public function jsonDecode ( bool $ assoc = true , int $ depth = 512 , int $ options = 0 ) <nl> + public function jsonDecode ( int $ depth = 512 , int $ options = 0 ) <nl> { <nl> - return json_decode ( $ this - > string , $ assoc , $ depth , $ options ) ; <nl> + return new ArrayObject ( json_decode ( $ this - > string , true , $ depth , $ options ) ) ; <nl> } <nl> <nl> / * * <nl>
|
update
|
swoole/swoole-src
|
bdd7c18e7d4dd0e48ce76cc46f01ba6269bae015
|
2019-05-30T07:51:04Z
|
mmm a / cocos / 2d / CCMotionStreak . h <nl> ppp b / cocos / 2d / CCMotionStreak . h <nl> class CC_DLL MotionStreak : public Node , public TextureProtocol <nl> * @ param bFastMode True if enabled fast mode . <nl> * / <nl> inline void setFastMode ( bool bFastMode ) { _fastMode = bFastMode ; } <nl> + / * * Get stroke . <nl> + * <nl> + * @ return float stroke . <nl> + * / <nl> + inline float getStroke ( ) const { return _stroke ; } <nl> + / * * Set stroke . <nl> + * <nl> + * @ param stroke The width of stroke . <nl> + * / <nl> + inline void setStroke ( float stroke ) { _stroke = stroke ; } <nl> <nl> / * * Is the starting position initialized or not . <nl> * <nl>
|
Merge pull request from IgorMats / v3
|
cocos2d/cocos2d-x
|
06a2042a114d1cb2fc51cfe0a2f6a5e3485edf22
|
2015-04-14T01:36:03Z
|
mmm a / xbmc / music / tags / MusicInfoTag . cpp <nl> ppp b / xbmc / music / tags / MusicInfoTag . cpp <nl> void CMusicInfoTag : : SetAlbum ( const CAlbum & album ) <nl> SetArtist ( album . artist ) ; <nl> SetAlbumId ( album . idAlbum ) ; <nl> SetAlbum ( album . strAlbum ) ; <nl> + SetTitle ( album . strAlbum ) ; <nl> SetAlbumArtist ( album . artist ) ; <nl> SetGenre ( album . genre ) ; <nl> SetRating ( ' 0 ' + album . iRating ) ; <nl>
|
CMusicInfoTag : set the title property for albums and don ' t rely on the title property of CFileItem ( fixes )
|
xbmc/xbmc
|
0912f7e6d2ccef24815c063e8b8a85798d9f6918
|
2012-10-14T10:16:54Z
|
mmm a / dbms / src / Storages / StorageReplicatedMergeTree . cpp <nl> ppp b / dbms / src / Storages / StorageReplicatedMergeTree . cpp <nl> void StorageReplicatedMergeTree : : attachPartition ( ASTPtr query , const Field & fie <nl> / / / Выделим добавляемым кускам максимальные свободные номера , меньшие RESERVED_BLOCK_NUMBERS . <nl> / / / NOTE : Проверка свободности номеров никак не синхронизируется . Выполнять несколько запросов ATTACH / DETACH / DROP одновременно нельзя . <nl> Int64 min_used_number = RESERVED_BLOCK_NUMBERS ; <nl> - DayNum_t month = DateLUT : : instance ( ) . makeDayNum ( parse < UInt16 > ( partition . substr ( 0 , 4 ) ) , parse < UInt8 > ( partition . substr ( 4 , 2 ) ) , 0 ) ; <nl> + DayNum_t month = DateLUT : : instance ( ) . makeDayNum ( parse < UInt16 > ( partition . substr ( 0 , 4 ) ) , parse < UInt8 > ( partition . substr ( 4 , 2 ) ) , 1 ) ; <nl> <nl> { <nl> auto existing_parts = data . getDataParts ( ) ; <nl>
|
dbms : fixed error with ATTACH [ # METR - 19835 ] .
|
ClickHouse/ClickHouse
|
5d962f241fb4096e0425121b2c0cefa4544f6d9c
|
2016-01-28T00:39:11Z
|
mmm a / mars / stn / src / longlink_connect_monitor . cc <nl> ppp b / mars / stn / src / longlink_connect_monitor . cc <nl> uint64_t LongLinkConnectMonitor : : __AutoIntervalConnect ( ) { <nl> void LongLinkConnectMonitor : : __OnSignalForeground ( bool _isForeground ) { <nl> ASYNC_BLOCK_START <nl> # ifdef __APPLE__ <nl> + xinfo2 ( TSF " forground : % _ time : % _ tick : % _ " , _isForeground , timeMs ( ) , gettickcount ( ) ) ; <nl> <nl> if ( _isForeground ) { <nl> + xinfo2 ( TSF " longlink : % _ time : % _ % _ % _ " , longlink_ . ConnectStatus ( ) , tickcount_t ( ) . gettickcount ( ) . get ( ) , longlink_ . GetLastRecvTime ( ) . get ( ) , int64_t ( tickcount_t ( ) . gettickcount ( ) - longlink_ . GetLastRecvTime ( ) ) ) ; <nl> + <nl> if ( ( longlink_ . ConnectStatus ( ) = = LongLink : : kConnected ) & & <nl> ( tickcount_t ( ) . gettickcount ( ) - longlink_ . GetLastRecvTime ( ) > tickcountdiff_t ( 4 . 5 * 60 * 1000 ) ) ) { <nl> xwarn2 ( TSF " sock long time no send data , close it " ) ; <nl>
|
add logs
|
Tencent/mars
|
38680ede2744ba0533248bde849b2b4b3d4c9570
|
2017-12-22T03:45:06Z
|
mmm a / arangod / Aql / OptimizerRules . cpp <nl> ppp b / arangod / Aql / OptimizerRules . cpp <nl> <nl> # include < tuple > <nl> # include < iostream > <nl> <nl> - # include < velocypack / Builder . h > <nl> - <nl> using namespace arangodb ; <nl> using namespace arangodb : : aql ; <nl> using EN = arangodb : : aql : : ExecutionNode ; <nl> mmm a / arangod / Indexes / GeoIndex . cpp <nl> ppp b / arangod / Indexes / GeoIndex . cpp <nl> void GeoIndexIterator : : evaluateCondition ( ) { <nl> } else { / / within <nl> _near = false ; <nl> _withinRange = _condition - > getMember ( 2 ) - > getMember ( 1 ) - > getDoubleValue ( ) ; <nl> - _withinLessEq = _condition - > getMember ( 3 ) - > getMember ( 1 ) - > getDoubleValue ( ) ; <nl> + _withinLessEq = _condition - > getMember ( 3 ) - > getMember ( 1 ) - > getBoolValue ( ) ; <nl> } <nl> } else { <nl> LOG ( ERR ) < < " No condition passed to GeoIndexIterator constructor " ; <nl> IndexLookupResult GeoIndexIterator : : next ( ) { <nl> <nl> auto coords = std : : unique_ptr < GeoCoordinates > ( : : GeoIndex_ReadCursor ( _cursor , 1 ) ) ; <nl> if ( coords & & coords - > length ) { <nl> - if ( _near | | GeoIndex_distance ( & _coor , & coords - > coordinates [ 0 ] ) < = _withinRange ) { <nl> + if ( _near <nl> + | | ( ! _withinLessEq & & GeoIndex_distance ( & _coor , & coords - > coordinates [ 0 ] ) < _withinRange ) <nl> + | | ( _withinLessEq & & GeoIndex_distance ( & _coor , & coords - > coordinates [ 0 ] ) < = _withinRange ) <nl> + ) <nl> + { <nl> auto revision = : : GeoIndex : : toRevision ( coords - > coordinates [ 0 ] . data ) ; <nl> return IndexLookupResult { revision } ; <nl> } <nl> void GeoIndexIterator : : nextBabies ( std : : vector < IndexLookupResult > & result , size_t <nl> } <nl> <nl> for ( std : : size_t index = 0 ; index < length ; + + index ) { <nl> - if ( _near | | GeoIndex_distance ( & _coor , & coords - > coordinates [ index ] ) < = _withinRange ) { <nl> + if ( _near <nl> + | | ( ! _withinLessEq & & GeoIndex_distance ( & _coor , & coords - > coordinates [ 0 ] ) < _withinRange ) <nl> + | | ( _withinLessEq & & GeoIndex_distance ( & _coor , & coords - > coordinates [ 0 ] ) < = _withinRange ) <nl> + ) <nl> + { <nl> result . emplace_back ( IndexLookupResult ( : : GeoIndex : : toRevision ( coords - > coordinates [ index ] . data ) ) ) ; <nl> } else { <nl> break ; <nl>
|
distinguish between less and less equal in geoindex filter conditions
|
arangodb/arangodb
|
9ecd4665c711f473c9e64c03fe187d2f0e89dc74
|
2016-12-20T11:15:58Z
|
mmm a / src / mongo / db / dur . cpp <nl> ppp b / src / mongo / db / dur . cpp <nl> namespace mongo { <nl> } <nl> <nl> bool NOINLINE_DECL DurableImpl : : _aCommitIsNeeded ( ) { <nl> - if ( ! Lock : : isLocked ( ) ) { <nl> - DEV log ( ) < < " commitIfNeeded but we are unlocked that is ok but why do we get here " < < endl ; <nl> - Lock : : GlobalRead r ; <nl> - if ( commitJob . bytes ( ) < UncommittedBytesLimit ) { <nl> - / / someone else beat us to it <nl> - return false ; <nl> - } <nl> - commitNow ( ) ; <nl> - } <nl> - else if ( Lock : : isLocked ( ) = = ' w ' ) { <nl> - if ( Lock : : atLeastReadLocked ( " local " ) ) { <nl> - error ( ) < < " can ' t commitNow from commitIfNeeded , as we are in local db lock " < < endl ; <nl> - printStackTrace ( ) ; <nl> - dassert ( false ) ; / / this will make _DEBUG builds terminate . so we will notice in buildbot . <nl> - return false ; <nl> - } <nl> - else if ( Lock : : atLeastReadLocked ( " admin " ) ) { <nl> - error ( ) < < " can ' t commitNow from commitIfNeeded , as we are in admin db lock " < < endl ; <nl> - printStackTrace ( ) ; <nl> - dassert ( false ) ; <nl> - return false ; <nl> + switch ( Lock : : isLocked ( ) ) { <nl> + case ' \ 0 ' : { <nl> + DEV log ( ) < < " commitIfNeeded but we are unlocked that is ok but why do we get here " < < endl ; <nl> + Lock : : GlobalRead r ; <nl> + if ( commitJob . bytes ( ) < UncommittedBytesLimit ) { <nl> + / / someone else beat us to it <nl> + return false ; <nl> + } <nl> + commitNow ( ) ; <nl> + return true ; <nl> } <nl> - else { <nl> + case ' w ' : { <nl> + if ( Lock : : atLeastReadLocked ( " local " ) ) { <nl> + error ( ) < < " can ' t commitNow from commitIfNeeded , as we are in local db lock " < < endl ; <nl> + printStackTrace ( ) ; <nl> + dassert ( false ) ; / / this will make _DEBUG builds terminate . so we will notice in buildbot . <nl> + return false ; <nl> + } <nl> + if ( Lock : : atLeastReadLocked ( " admin " ) ) { <nl> + error ( ) < < " can ' t commitNow from commitIfNeeded , as we are in admin db lock " < < endl ; <nl> + printStackTrace ( ) ; <nl> + dassert ( false ) ; <nl> + return false ; <nl> + } <nl> + <nl> log ( 1 ) < < " commitIfNeeded upgrading from shared write to exclusive write state " <nl> < < endl ; <nl> Lock : : DBWrite : : UpgradeToExclusive ex ; <nl> if ( ex . gotUpgrade ( ) ) { <nl> commitNow ( ) ; <nl> } <nl> + return true ; <nl> } <nl> + <nl> + case ' W ' : <nl> + case ' R ' : <nl> + commitNow ( ) ; <nl> + return true ; <nl> + <nl> + case ' r ' : <nl> + return false ; <nl> + <nl> + default : <nl> + fassertFailed ( 16434 ) ; / / unknown lock type <nl> } <nl> - else { <nl> - / / ' W ' <nl> - commitNow ( ) ; <nl> - } <nl> - return true ; <nl> } <nl> <nl> / * * we may need to commit earlier than normal if data are being written at <nl>
|
SERVER - 6948 Make it safe to call commitIfNeeded ( ) from a read lock
|
mongodb/mongo
|
d4f46ee169f5bf3d365ed60956bd21a9c4664e97
|
2012-09-07T23:39:33Z
|
mmm a / jstests / views / views_creation . js <nl> ppp b / jstests / views / views_creation . js <nl> <nl> - / / Test the creation of views with various options . Once created , views should also be accessible <nl> - / / via listCollections and the like . <nl> + / / Test the creation of views with various options . <nl> <nl> ( function ( ) { <nl> " use strict " ; <nl> <nl> load ( " jstests / aggregation / extras / utils . js " ) ; <nl> <nl> var viewsDB = db . getSiblingDB ( " views_creation " ) ; <nl> - viewsDB . dropDatabase ( ) ; <nl> - assert . eq ( 0 , viewsDB . getCollectionNames ( ) . length ) ; <nl> + assert . commandWorked ( viewsDB . dropDatabase ( ) ) ; <nl> + <nl> + var collNames = viewsDB . getCollectionNames ( ) ; <nl> + assert . eq ( 0 , collNames . length , tojson ( collNames ) ) ; <nl> <nl> / / Create a collection for test purposes . <nl> assert . commandWorked ( viewsDB . runCommand ( { create : " collection " } ) ) ; <nl> <nl> viewsDB . runCommand ( { create : " viewOnView " , viewOn : " view " , pipeline : pipe } ) ) ; <nl> <nl> / / View names are constrained to the same limitations as collection names . <nl> - assert . commandFailed ( <nl> - viewsDB . runCommand ( { create : " " , viewOn : " collection " , pipeline : pipe } ) ) ; <nl> + assert . commandFailed ( viewsDB . runCommand ( { create : " " , viewOn : " collection " , pipeline : pipe } ) ) ; <nl> assert . commandFailedWithCode ( <nl> viewsDB . runCommand ( { create : " system . local . new " , viewOn : " collection " , pipeline : pipe } ) , <nl> ErrorCodes . BadValue ) ; <nl>
|
SERVER - 24765 fix views_creation . js
|
mongodb/mongo
|
920afddd4910e1efa6736331f2b38e7e276bd3d8
|
2016-07-08T17:21:08Z
|
mmm a / tools / distrib / check_copyright . py <nl> ppp b / tools / distrib / check_copyright . py <nl> <nl> ' . cc ' : r ' \ s * ( ? : / / | \ * ) \ s * ' , <nl> ' . h ' : r ' \ s * ( ? : / / | \ * ) \ s * ' , <nl> ' . m ' : r ' \ s * \ * \ s * ' , <nl> + ' . mm ' : r ' \ s * \ * \ s * ' , <nl> ' . php ' : r ' \ s * \ * \ s * ' , <nl> ' . js ' : r ' \ s * \ * \ s * ' , <nl> ' . py ' : r ' # \ s * ' , <nl>
|
Check copyright of Objective - C + + source files
|
grpc/grpc
|
44c4c34b32a753181727935e17ca204291ef9af4
|
2018-01-06T01:25:54Z
|
mmm a / docs / development / releasing . md <nl> ppp b / docs / development / releasing . md <nl> for more information . <nl> <nl> * * NB : * * If releasing from a branch , e . g . 1 - 8 - x , check out the branch with <nl> ` git checkout 1 - 8 - x ` rather than ` git checkout - b remotes / origin / 1 - 8 - x ` . <nl> - The scrips need ` git rev - parse - - abbrev - ref HEAD ` to return a short name , <nl> + The scripts need ` git rev - parse - - abbrev - ref HEAD ` to return a short name , <nl> e . g . no ` remotes / origin / ` <nl> <nl> # # Set your tokens and environment variables <nl>
|
fix tyop
|
electron/electron
|
7bcea57241b21f77a7a8ba816075d472a12e15a7
|
2017-12-05T03:09:12Z
|
mmm a / tensorflow / python / ops / string_ops . py <nl> ppp b / tensorflow / python / ops / string_ops . py <nl> def reduce_join_v2 ( # pylint : disable = missing - docstring <nl> keepdims = False , <nl> separator = " " , <nl> name = None ) : <nl> + " " " Joins all strings into a single string , or joins along an axis . <nl> + <nl> + > > > tf . strings . reduce_join ( [ [ ' abc ' , ' 123 ' ] , <nl> + . . . [ ' def ' , ' 456 ' ] ] ) . numpy ( ) <nl> + b ' abc123def456 ' <nl> + > > > tf . strings . reduce_join ( [ [ ' abc ' , ' 123 ' ] , <nl> + . . . [ ' def ' , ' 456 ' ] ] , axis = - 1 ) . numpy ( ) <nl> + array ( [ b ' abc123 ' , b ' def456 ' ] , dtype = object ) <nl> + > > > tf . strings . reduce_join ( [ [ ' abc ' , ' 123 ' ] , <nl> + . . . [ ' def ' , ' 456 ' ] ] , <nl> + . . . axis = - 1 , <nl> + . . . separator = " " ) . numpy ( ) <nl> + array ( [ b ' abc 123 ' , b ' def 456 ' ] , dtype = object ) <nl> + <nl> + Args : <nl> + input : A ` tf . string ` tensor . <nl> + axis : Which axis to join along . The default behavior is to join all <nl> + elements , producing a scalar . <nl> + keepdims : If true , retains reduced dimensions with length 1 . <nl> + separator : a string added between each string being joined . <nl> + name : A name for the operation ( optional ) . <nl> + <nl> + Returns : <nl> + A ` tf . string ` tensor . <nl> + " " " <nl> with ops . name_scope ( None , " ReduceJoin " , [ inputs , axis ] ) : <nl> inputs_t = ops . convert_to_tensor ( inputs ) <nl> axis = _reduce_join_reduction_dims ( inputs_t , axis ) <nl>
|
Add docstring for strings . reduce_join
|
tensorflow/tensorflow
|
de38438ba192145ec7d5a04257e0935b96b2053f
|
2019-10-09T05:51:32Z
|
mmm a / modules / highgui / test / test_grfmt . cpp <nl> ppp b / modules / highgui / test / test_grfmt . cpp <nl> class CV_GrfmtWriteSequenceImageTest : public cvtest : : BaseTest <nl> ts - > set_failed_test_info ( ts - > FAIL_MISMATCH ) ; <nl> } <nl> } <nl> - if ( ext = = 3 / * TIFF * / ) <nl> + if ( ext = = 3 / * TIFF * / ) <nl> { <nl> / * 4 channels should stay 4 channels * / <nl> - int num_channels = 4 ; <nl> + int num_channels = 4 ; <nl> ts - > printf ( ts - > LOG , " image type depth : % d channels : % d ext : % s \ n " , CV_8U , num_channels , ext_from_int ( ext ) . c_str ( ) ) ; <nl> Mat img ( img_r * k , img_c * k , CV_MAKETYPE ( CV_8U , num_channels ) , Scalar : : all ( 0 ) ) ; <nl> circle ( img , Point2i ( ( img_c * k ) / 2 , ( img_r * k ) / 2 ) , cv : : min ( ( img_r * k ) , ( img_c * k ) ) / 4 , Scalar : : all ( 255 ) ) ; <nl> class CV_GrfmtWriteSequenceImageTest : public cvtest : : BaseTest <nl> <nl> CV_Assert ( img . size ( ) = = img_test . size ( ) ) ; <nl> CV_Assert ( img . type ( ) = = img_test . type ( ) ) ; <nl> - CV_Assert ( img . channels ( ) = = 4 ) ; <nl> + CV_Assert ( img_test . channels ( ) = = 4 ) ; <nl> <nl> double n = norm ( img , img_test ) ; <nl> if ( n > 1 . 0 ) <nl> class CV_GrfmtWriteSequenceImageTest : public cvtest : : BaseTest <nl> } <nl> <nl> } <nl> - <nl> } <nl> <nl> # ifdef HAVE_JPEG <nl>
|
* img_test is now tested for channel numbers instead of img
|
opencv/opencv
|
109e047a283e65424463bc16813f242e5612a483
|
2013-02-13T11:33:07Z
|
mmm a / stdlib / toolchain / CMakeLists . txt <nl> ppp b / stdlib / toolchain / CMakeLists . txt <nl> <nl> # Toolchain - only build products <nl> <nl> + list ( APPEND CMAKE_MODULE_PATH $ { CMAKE_CURRENT_LIST_DIR } / . . / cmake / modules ) <nl> + include ( AddSwiftStdlib ) <nl> + <nl> set ( CXX_COMPILE_FLAGS ) <nl> set ( CXX_LINK_FLAGS ) <nl> <nl>
|
stdlib : repair the macOS - stdlib build
|
apple/swift
|
3a12738ebc30931ba6d07266ceb56802a92307f0
|
2020-02-28T04:45:24Z
|
mmm a / tensorflow / contrib / lite / kernels / activations . cc <nl> ppp b / tensorflow / contrib / lite / kernels / activations . cc <nl> TfLiteStatus TanhEval ( TfLiteContext * context , TfLiteNode * node ) { <nl> return kTfLiteOk ; <nl> } break ; <nl> case kTfLiteUInt8 : { <nl> - optimized_ops : : Tanh ( GetTensorData < uint8_t > ( input ) , GetTensorDims ( input ) , <nl> + optimized_ops : : Tanh ( GetTensorData < uint8_t > ( input ) , GetTensorShape ( input ) , <nl> input - > params . zero_point , data - > input_range_radius , <nl> data - > input_multiplier , data - > input_left_shift , <nl> GetTensorData < uint8_t > ( output ) , <nl> - GetTensorDims ( output ) ) ; <nl> + GetTensorShape ( output ) ) ; <nl> return kTfLiteOk ; <nl> } break ; <nl> default : <nl> TfLiteStatus SigmoidEval ( TfLiteContext * context , TfLiteNode * node ) { <nl> } <nl> case kTfLiteUInt8 : { <nl> optimized_ops : : Logistic ( <nl> - GetTensorData < uint8_t > ( input ) , GetTensorDims ( input ) , <nl> + GetTensorData < uint8_t > ( input ) , GetTensorShape ( input ) , <nl> input - > params . zero_point , data - > input_range_radius , <nl> data - > input_multiplier , data - > input_left_shift , <nl> - GetTensorData < uint8_t > ( output ) , GetTensorDims ( output ) ) ; <nl> + GetTensorData < uint8_t > ( output ) , GetTensorShape ( output ) ) ; <nl> break ; <nl> } <nl> default : <nl> void Softmax2DQuantized ( const TfLiteTensor * input , TfLiteTensor * output , <nl> const int batch_size = input - > dims - > data [ 0 ] ; <nl> const int input_size = input - > dims - > data [ 1 ] ; <nl> optimized_ops : : Softmax ( GetTensorData < uint8_t > ( input ) , <nl> - GetTensorDims ( { batch_size , 1 , 1 , input_size } ) , <nl> + GetTensorShape ( { batch_size , 1 , 1 , input_size } ) , <nl> data - > input_multiplier , data - > input_left_shift , <nl> data - > diff_min , GetTensorData < uint8_t > ( output ) , <nl> - GetTensorDims ( { batch_size , 1 , 1 , input_size } ) ) ; <nl> + GetTensorShape ( { batch_size , 1 , 1 , input_size } ) ) ; <nl> } <nl> <nl> / / Takes a 4D tensor and perform softmax along the forth dimension . <nl> void Softmax4DFloat ( const TfLiteTensor * input , TfLiteTensor * output , <nl> TfLiteSoftmaxParams * params ) { <nl> - optimized_ops : : Softmax ( GetTensorData < float > ( input ) , GetTensorDims ( input ) , <nl> + optimized_ops : : Softmax ( GetTensorData < float > ( input ) , GetTensorShape ( input ) , <nl> params - > beta , GetTensorData < float > ( output ) , <nl> - GetTensorDims ( output ) ) ; <nl> + GetTensorShape ( output ) ) ; <nl> } <nl> <nl> void Softmax4DQuantized ( const TfLiteTensor * input , TfLiteTensor * output , <nl> TfLiteSoftmaxParams * params , OpData * data ) { <nl> - optimized_ops : : Softmax ( GetTensorData < uint8_t > ( input ) , GetTensorDims ( input ) , <nl> + optimized_ops : : Softmax ( GetTensorData < uint8_t > ( input ) , GetTensorShape ( input ) , <nl> data - > input_multiplier , data - > input_left_shift , <nl> data - > diff_min , GetTensorData < uint8_t > ( output ) , <nl> - GetTensorDims ( output ) ) ; <nl> + GetTensorShape ( output ) ) ; <nl> } <nl> <nl> TfLiteStatus SoftmaxEval ( TfLiteContext * context , TfLiteNode * node ) { <nl> TfLiteStatus LogSoftmaxEval ( TfLiteContext * context , TfLiteNode * node ) { <nl> switch ( input - > type ) { <nl> case kTfLiteFloat32 : <nl> optimized_ops : : LogSoftmax ( <nl> - GetTensorData < float > ( input ) , GetTensorDims ( input ) , <nl> - GetTensorData < float > ( output ) , GetTensorDims ( output ) ) ; <nl> + GetTensorData < float > ( input ) , GetTensorShape ( input ) , <nl> + GetTensorData < float > ( output ) , GetTensorShape ( output ) ) ; <nl> return kTfLiteOk ; <nl> default : <nl> context - > ReportError ( context , " Only float32 supported currently . , got % d " , <nl> mmm a / tensorflow / contrib / lite / kernels / internal / logsoftmax_quantized_test . cc <nl> ppp b / tensorflow / contrib / lite / kernels / internal / logsoftmax_quantized_test . cc <nl> namespace tflite { <nl> namespace { <nl> <nl> void RunLogSoftmaxFloatReference ( const uint8 * input_data , <nl> - const Dims < 4 > & dims_common , int32 input_offset , <nl> - const double input_scale , int stride , <nl> - float beta , uint8 * reference_output_data ) { <nl> - const int ref_buffer_size = RequiredBufferSizeForDims ( dims_common ) ; <nl> + const RuntimeShape & shape_common , <nl> + int32 input_offset , const double input_scale , <nl> + int stride , float beta , <nl> + uint8 * reference_output_data ) { <nl> + const int ref_buffer_size = shape_common . FlatSize ( ) ; <nl> std : : vector < float > reference_dequant_data ( ref_buffer_size ) ; <nl> std : : vector < float > reference_output_float_data ( ref_buffer_size ) ; <nl> <nl> / / Reference data generated via Dequant of input into float , and then applying <nl> / / float LogSoftmax . <nl> - reference_ops : : Dequantize ( input_data , dims_common , input_offset , input_scale , <nl> - reference_dequant_data . data ( ) , dims_common ) ; <nl> - optimized_ops : : LogSoftmax ( reference_dequant_data . data ( ) , dims_common , <nl> - reference_output_float_data . data ( ) , dims_common ) ; <nl> + reference_ops : : Dequantize ( <nl> + input_data , ToRuntimeDims ( shape_common ) , input_offset , input_scale , <nl> + reference_dequant_data . data ( ) , ToRuntimeDims ( shape_common ) ) ; <nl> + optimized_ops : : LogSoftmax ( reference_dequant_data . data ( ) , shape_common , <nl> + reference_output_float_data . data ( ) , shape_common ) ; <nl> / / Work with quantized scaling for LogSoftmax , under which 255 represents 0 , <nl> / / and - 16 gets nudged up to 0 . <nl> for ( int i = 0 ; i < ref_buffer_size ; i + + ) { <nl> void RunLogSoftmaxFloatReference ( const uint8 * input_data , <nl> } <nl> <nl> void CheckOutputData ( const uint8 * test_output , const uint8 * reference_output , <nl> - const Dims < 4 > & dims_common , const string & check_label , <nl> - bool be_exacting ) { <nl> - const int buffer_size = RequiredBufferSizeForDims ( dims_common ) ; <nl> + const RuntimeShape & shape_common , <nl> + const string & check_label , bool be_exacting ) { <nl> + const int buffer_size = shape_common . FlatSize ( ) ; <nl> / / While calculating some metrics in floating point , we work with quantized <nl> / / scaling . <nl> std : : vector < int > diff ( buffer_size ) ; <nl> void CheckOutputData ( const uint8 * test_output , const uint8 * reference_output , <nl> <nl> / / Runs the LogSoftmax and compares against the float reference implementation <nl> / / and the quantized reference implementation . <nl> - void RunOneLogSoftmaxTest ( const uint8 * input_data , const Dims < 4 > & dims_common , <nl> - int32 input_offset , const double input_scale , <nl> - int stride , float beta ) { <nl> - const int buffer_size = RequiredBufferSizeForDims ( dims_common ) ; <nl> + void RunOneLogSoftmaxTest ( const uint8 * input_data , <nl> + const RuntimeShape & shape_common , int32 input_offset , <nl> + const double input_scale , int stride , float beta ) { <nl> + const int buffer_size = shape_common . FlatSize ( ) ; <nl> std : : vector < uint8 > optimized_logsoftmax_output ( buffer_size ) ; <nl> std : : vector < uint8 > reference_float_logsoftmax_output ( buffer_size ) ; <nl> std : : vector < uint8 > reference_quant_logsoftmax_output ( buffer_size ) ; <nl> <nl> - RunLogSoftmaxFloatReference ( input_data , dims_common , input_offset , <nl> + RunLogSoftmaxFloatReference ( input_data , shape_common , input_offset , <nl> input_scale , stride , beta , <nl> reference_float_logsoftmax_output . data ( ) ) ; <nl> <nl> void RunOneLogSoftmaxTest ( const uint8 * input_data , const Dims < 4 > & dims_common , <nl> const int diff_min = - tflite : : CalculateInputRadius ( kScaledDiffIntegerBits , <nl> input_beta_left_shift ) ; <nl> <nl> - optimized_ops : : LogSoftmax ( input_data , dims_common , input_beta_multiplier , <nl> + optimized_ops : : LogSoftmax ( input_data , shape_common , input_beta_multiplier , <nl> input_beta_left_shift , reverse_scaling_divisor , <nl> reverse_scaling_right_shift , diff_min , <nl> - optimized_logsoftmax_output . data ( ) , dims_common ) ; <nl> + optimized_logsoftmax_output . data ( ) , shape_common ) ; <nl> reference_ops : : LogSoftmax ( <nl> - input_data , dims_common , input_beta_multiplier , input_beta_left_shift , <nl> + input_data , shape_common , input_beta_multiplier , input_beta_left_shift , <nl> reverse_scaling_divisor , reverse_scaling_right_shift , diff_min , <nl> - reference_quant_logsoftmax_output . data ( ) , dims_common ) ; <nl> + reference_quant_logsoftmax_output . data ( ) , shape_common ) ; <nl> <nl> CheckOutputData ( optimized_logsoftmax_output . data ( ) , <nl> - reference_float_logsoftmax_output . data ( ) , dims_common , <nl> + reference_float_logsoftmax_output . data ( ) , shape_common , <nl> " Optimized vs float reference " , false ) ; <nl> CheckOutputData ( optimized_logsoftmax_output . data ( ) , <nl> - reference_quant_logsoftmax_output . data ( ) , dims_common , <nl> + reference_quant_logsoftmax_output . data ( ) , shape_common , <nl> " Optimized vs quant reference " , true ) ; <nl> CheckOutputData ( reference_quant_logsoftmax_output . data ( ) , <nl> - reference_float_logsoftmax_output . data ( ) , dims_common , <nl> + reference_float_logsoftmax_output . data ( ) , shape_common , <nl> " Quant reference vs float reference " , false ) ; <nl> } <nl> <nl> bool TryOneUniformLogSoftmax ( ) { <nl> const int32 input_offset = UniformRandomInt ( - 256 , 0 ) ; <nl> static constexpr float beta = 1 . 0f ; <nl> <nl> - Dims < 4 > dims_common = <nl> - MakeDimsForInference ( input_depth , input_width , input_height , batch ) ; <nl> - const int buffer_size = RequiredBufferSizeForDims ( dims_common ) ; <nl> + auto shape_common = <nl> + RuntimeShape ( { batch , input_height , input_width , input_depth } ) ; <nl> + const int buffer_size = shape_common . FlatSize ( ) ; <nl> <nl> std : : vector < uint8 > input_data ( buffer_size ) ; <nl> FillRandom ( & input_data ) ; <nl> - RunOneLogSoftmaxTest ( input_data . data ( ) , dims_common , input_offset , <nl> + RunOneLogSoftmaxTest ( input_data . data ( ) , shape_common , input_offset , <nl> input_scale , stride , beta ) ; <nl> return true ; <nl> } <nl> bool TryOneSkyscraperLogSoftmax ( bool small_depth ) { <nl> const int middle_min = UniformRandomInt ( 0 , 255 ) ; <nl> const int sides_max = UniformRandomInt ( 0 , middle_min ) ; <nl> <nl> - Dims < 4 > dims_common = <nl> - MakeDimsForInference ( input_depth , input_width , input_height , batch ) ; <nl> - const int buffer_size = RequiredBufferSizeForDims ( dims_common ) ; <nl> + auto shape_common = <nl> + RuntimeShape ( { batch , input_height , input_width , input_depth } ) ; <nl> + const int buffer_size = shape_common . FlatSize ( ) ; <nl> <nl> std : : vector < uint8 > input_data ( buffer_size ) ; <nl> FillRandomSkyscraper ( & input_data , input_depth , middle_proportion , middle_min , <nl> sides_max ) ; <nl> - RunOneLogSoftmaxTest ( input_data . data ( ) , dims_common , input_offset , <nl> + RunOneLogSoftmaxTest ( input_data . data ( ) , shape_common , input_offset , <nl> input_scale , stride , beta ) ; <nl> return true ; <nl> } <nl> mmm a / tensorflow / contrib / lite / kernels / internal / optimized / legacy_optimized_ops . h <nl> ppp b / tensorflow / contrib / lite / kernels / internal / optimized / legacy_optimized_ops . h <nl> limitations under the License . <nl> namespace tflite { <nl> namespace optimized_ops { <nl> <nl> + / / Unoptimized reference ops : <nl> + using reference_ops : : Relu1 ; <nl> + using reference_ops : : Relu6 ; <nl> + <nl> inline RuntimeShape DimsToShape ( const tflite : : Dims < 4 > & dims ) { <nl> return RuntimeShape ( <nl> { dims . sizes [ 3 ] , dims . sizes [ 2 ] , dims . sizes [ 1 ] , dims . sizes [ 0 ] } ) ; <nl> inline RuntimeShape DimsToShape ( const tflite : : Dims < 4 > & dims ) { <nl> template < FusedActivationFunctionType Ac > <nl> void L2Normalization ( const float * input_data , const Dims < 4 > & input_dims , <nl> float * output_data , const Dims < 4 > & output_dims ) { <nl> - return L2Normalization < Ac > ( input_data , DimsToShape ( input_dims ) , output_data , <nl> - DimsToShape ( output_dims ) ) ; <nl> + L2Normalization < Ac > ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> } <nl> <nl> inline void L2Normalization ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> int32 input_zero_point , uint8 * output_data , <nl> const Dims < 4 > & output_dims ) { <nl> - return L2Normalization ( input_data , DimsToShape ( input_dims ) , input_zero_point , <nl> - output_data , DimsToShape ( output_dims ) ) ; <nl> + L2Normalization ( input_data , DimsToShape ( input_dims ) , input_zero_point , <nl> + output_data , DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Relu ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + Relu ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int kwidth , int kheight , <nl> + float output_activation_min , <nl> + float output_activation_max , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + AveragePool ( input_data , DimsToShape ( input_dims ) , stride_width , stride_height , <nl> + pad_width , pad_height , kwidth , kheight , output_activation_min , <nl> + output_activation_max , output_data , DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int kwidth , int kheight , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + float output_activation_min , output_activation_max ; <nl> + GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> + <nl> + AveragePool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> + pad_height , kwidth , kheight , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> + int pad_width , int pad_height , int filter_width , <nl> + int filter_height , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + AveragePool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> + filter_width , filter_height , output_data , output_dims ) ; <nl> + } <nl> + <nl> + inline void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int filter_width , int filter_height , <nl> + int32 output_activation_min , <nl> + int32 output_activation_max , uint8 * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + AveragePool ( input_data , DimsToShape ( input_dims ) , stride_width , stride_height , <nl> + pad_width , pad_height , filter_width , filter_height , <nl> + output_activation_min , output_activation_max , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int filter_width , int filter_height , <nl> + int32 output_activation_min , int32 output_activation_max , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + static_assert ( Ac = = FusedActivationFunctionType : : kNone | | <nl> + Ac = = FusedActivationFunctionType : : kRelu | | <nl> + Ac = = FusedActivationFunctionType : : kRelu6 | | <nl> + Ac = = FusedActivationFunctionType : : kRelu1 , <nl> + " " ) ; <nl> + if ( Ac = = FusedActivationFunctionType : : kNone ) { <nl> + TFLITE_DCHECK_EQ ( output_activation_min , 0 ) ; <nl> + TFLITE_DCHECK_EQ ( output_activation_max , 255 ) ; <nl> + } <nl> + AveragePool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> + pad_height , filter_width , filter_height , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , int stride , <nl> + int pad_width , int pad_height , int filter_width , <nl> + int filter_height , int32 output_activation_min , <nl> + int32 output_activation_max , uint8 * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + AveragePool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> + filter_width , filter_height , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + inline void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int kwidth , int kheight , <nl> + float output_activation_min , float output_activation_max , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + MaxPool ( input_data , DimsToShape ( input_dims ) , stride_width , stride_height , <nl> + pad_width , pad_height , kwidth , kheight , output_activation_min , <nl> + output_activation_max , output_data , DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , int pad_height , <nl> + int kwidth , int kheight , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + float output_activation_min , output_activation_max ; <nl> + GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> + MaxPool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> + pad_height , kwidth , kheight , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> + int pad_width , int pad_height , int filter_width , int filter_height , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + MaxPool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> + filter_width , filter_height , output_data , output_dims ) ; <nl> + } <nl> + <nl> + inline void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int filter_width , int filter_height , <nl> + int32 output_activation_min , int32 output_activation_max , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + MaxPool ( input_data , DimsToShape ( input_dims ) , stride_width , stride_height , <nl> + pad_width , pad_height , filter_width , filter_height , <nl> + output_activation_min , output_activation_max , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , int pad_height , <nl> + int filter_width , int filter_height , int32 output_activation_min , <nl> + int32 output_activation_max , uint8 * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + static_assert ( Ac = = FusedActivationFunctionType : : kNone | | <nl> + Ac = = FusedActivationFunctionType : : kRelu | | <nl> + Ac = = FusedActivationFunctionType : : kRelu6 | | <nl> + Ac = = FusedActivationFunctionType : : kRelu1 , <nl> + " " ) ; <nl> + if ( Ac = = FusedActivationFunctionType : : kNone ) { <nl> + TFLITE_DCHECK_EQ ( output_activation_min , 0 ) ; <nl> + TFLITE_DCHECK_EQ ( output_activation_max , 255 ) ; <nl> + } <nl> + MaxPool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> + pad_height , filter_width , filter_height , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , int stride , <nl> + int pad_width , int pad_height , int filter_width , int filter_height , <nl> + int32 output_activation_min , int32 output_activation_max , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + MaxPool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> + filter_width , filter_height , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + inline void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int filter_width , int filter_height , <nl> + float output_activation_min , float output_activation_max , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + L2Pool ( input_data , DimsToShape ( input_dims ) , stride_width , stride_height , <nl> + pad_width , pad_height , filter_width , filter_height , <nl> + output_activation_min , output_activation_max , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , int pad_height , <nl> + int filter_width , int filter_height , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + float output_activation_min , output_activation_max ; <nl> + GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> + L2Pool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> + pad_height , filter_width , filter_height , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> + int pad_width , int pad_height , int filter_width , int filter_height , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + L2Pool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> + filter_width , filter_height , output_data , output_dims ) ; <nl> + } <nl> + <nl> + inline void Softmax ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float beta , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + Softmax ( input_data , DimsToShape ( input_dims ) , beta , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Softmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int32 input_beta_multiplier , int32 input_beta_left_shift , <nl> + int diff_min , uint8 * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + Softmax ( input_data , DimsToShape ( input_dims ) , input_beta_multiplier , <nl> + input_beta_left_shift , diff_min , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void LogSoftmax ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + LogSoftmax ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void LogSoftmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int32 input_multiplier , int32 input_left_shift , <nl> + int32 reverse_scaling_divisor , <nl> + int32 reverse_scaling_right_shift , int diff_min , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + LogSoftmax ( input_data , DimsToShape ( input_dims ) , input_multiplier , <nl> + input_left_shift , reverse_scaling_divisor , <nl> + reverse_scaling_right_shift , diff_min , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Logistic ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + Logistic ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Logistic ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int32 input_zero_point , int32 input_range_radius , <nl> + int32 input_multiplier , int input_left_shift , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + Logistic ( input_data , DimsToShape ( input_dims ) , input_zero_point , <nl> + input_range_radius , input_multiplier , input_left_shift , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Logistic ( const int16 * input_data , const Dims < 4 > & input_dims , <nl> + int16 * output_data , const Dims < 4 > & output_dims ) { <nl> + Logistic ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Tanh ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + Tanh ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Tanh ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int32 input_zero_point , int32 input_range_radius , <nl> + int32 input_multiplier , int input_left_shift , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + Tanh ( input_data , DimsToShape ( input_dims ) , input_zero_point , <nl> + input_range_radius , input_multiplier , input_left_shift , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Tanh ( const int16 * input_data , const Dims < 4 > & input_dims , <nl> + int input_left_shift , int16 * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + Tanh ( input_data , DimsToShape ( input_dims ) , input_left_shift , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> } <nl> <nl> } / / namespace optimized_ops <nl> mmm a / tensorflow / contrib / lite / kernels / internal / optimized / optimized_ops . h <nl> ppp b / tensorflow / contrib / lite / kernels / internal / optimized / optimized_ops . h <nl> using VectorMap = typename std : : conditional < <nl> Eigen : : Dynamic , 1 > > , <nl> Eigen : : Map < Eigen : : Matrix < Scalar , Eigen : : Dynamic , 1 > > > : : type ; <nl> <nl> + template < typename Scalar > <nl> + VectorMap < Scalar > MapAsVector ( Scalar * data , const RuntimeShape & shape ) { <nl> + const int size = shape . FlatSize ( ) ; <nl> + return VectorMap < Scalar > ( data , size , 1 ) ; <nl> + } <nl> + <nl> template < typename Scalar , int N > <nl> VectorMap < Scalar > MapAsVector ( Scalar * data , const Dims < N > & dims ) { <nl> const int size = FlatSize ( dims ) ; <nl> using MatrixMap = typename std : : conditional < <nl> Eigen : : Dynamic , Eigen : : Dynamic > > , <nl> Eigen : : Map < Eigen : : Matrix < Scalar , Eigen : : Dynamic , Eigen : : Dynamic > > > : : type ; <nl> <nl> + template < typename Scalar > <nl> + MatrixMap < Scalar > MapAsMatrixWithLastDimAsRows ( Scalar * data , <nl> + const RuntimeShape & shape ) { <nl> + const int dims_count = shape . DimensionsCount ( ) ; <nl> + const int rows = shape . Dims ( dims_count - 1 ) ; <nl> + const int cols = FlatSizeSkipDim ( shape , dims_count - 1 ) ; <nl> + return MatrixMap < Scalar > ( data , rows , cols ) ; <nl> + } <nl> + <nl> + template < typename Scalar > <nl> + MatrixMap < Scalar > MapAsMatrixWithFirstDimAsCols ( Scalar * data , <nl> + const RuntimeShape & shape ) { <nl> + const int cols = shape . Dims ( 0 ) ; <nl> + const int rows = FlatSizeSkipDim ( shape , 0 ) ; <nl> + return MatrixMap < Scalar > ( data , rows , cols ) ; <nl> + } <nl> + <nl> template < typename Scalar , int N > <nl> MatrixMap < Scalar > MapAsMatrixWithFirstDimAsRows ( Scalar * data , <nl> const Dims < N > & dims ) { <nl> void GlobalBatchNormalization ( const float * input_data , <nl> } <nl> } <nl> <nl> - inline void Relu ( const float * input_data , const Dims < 4 > & input_dims , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> + inline void Relu ( const float * input_data , const RuntimeShape & input_shape , <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " Relu ( not fused ) " ) ; <nl> <nl> - const auto input = MapAsVector ( input_data , input_dims ) ; <nl> - auto output = MapAsVector ( output_data , output_dims ) ; <nl> + const auto input = MapAsVector ( input_data , input_shape ) ; <nl> + auto output = MapAsVector ( output_data , output_shape ) ; <nl> output = input . cwiseMax ( 0 . 0f ) ; <nl> } <nl> <nl> inline int NodeOffset ( int b , int h , int w , int height , int width ) { <nl> return ( b * height + h ) * width + w ; <nl> } <nl> <nl> - inline void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , <nl> - int pad_height , int kwidth , int kheight , <nl> - float output_activation_min , <nl> + inline void AveragePool ( const float * input_data , <nl> + const RuntimeShape & input_shape , int stride_width , <nl> + int stride_height , int pad_width , int pad_height , <nl> + int kwidth , int kheight , float output_activation_min , <nl> float output_activation_max , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> + const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " AveragePool " ) ; <nl> - const int batches = MatchingArraySize ( input_dims , 3 , output_dims , 3 ) ; <nl> - const int input_height = ArraySize ( input_dims , 2 ) ; <nl> - const int input_width = ArraySize ( input_dims , 1 ) ; <nl> - const int output_height = ArraySize ( output_dims , 2 ) ; <nl> - const int output_width = ArraySize ( output_dims , 1 ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> + TFLITE_DCHECK_EQ ( input_shape . DimensionsCount ( ) , 4 ) ; <nl> + TFLITE_DCHECK_EQ ( output_shape . DimensionsCount ( ) , 4 ) ; <nl> + const int batches = MatchingDim ( input_shape , 0 , output_shape , 0 ) ; <nl> + const int depth = MatchingDim ( input_shape , 3 , output_shape , 3 ) ; <nl> + const int input_height = input_shape . Dims ( 1 ) ; <nl> + const int input_width = input_shape . Dims ( 2 ) ; <nl> + const int output_height = output_shape . Dims ( 1 ) ; <nl> + const int output_width = output_shape . Dims ( 2 ) ; <nl> <nl> / / TODO ( benoitjacob ) make this a proper reference impl without Eigen ! <nl> - const auto in_mat = MapAsMatrixWithFirstDimAsRows ( input_data , input_dims ) ; <nl> - auto out_mat = MapAsMatrixWithFirstDimAsRows ( output_data , output_dims ) ; <nl> + const auto in_mat = MapAsMatrixWithLastDimAsRows ( input_data , input_shape ) ; <nl> + auto out_mat = MapAsMatrixWithLastDimAsRows ( output_data , output_shape ) ; <nl> / / TODO ( benoitjacob ) get rid of the dynamic memory allocation here ! <nl> Eigen : : VectorXf out_count ( out_mat . cols ( ) ) ; <nl> out_count . setZero ( ) ; <nl> inline void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> for ( int y = 0 ; y < output_height ; + + y ) { <nl> for ( int x = 0 ; x < output_width ; + + x ) { <nl> for ( int c = 0 ; c < depth ; + + c ) { <nl> - output_data [ Offset ( output_dims , c , x , y , b ) ] = <nl> + output_data [ Offset ( output_shape , b , y , x , c ) ] = <nl> ActivationFunctionWithMinMax ( <nl> - output_data [ Offset ( output_dims , c , x , y , b ) ] , <nl> + output_data [ Offset ( output_shape , b , y , x , c ) ] , <nl> output_activation_min , output_activation_max ) ; <nl> } <nl> } <nl> inline void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , <nl> - int pad_height , int kwidth , int kheight , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - float output_activation_min , output_activation_max ; <nl> - GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> - <nl> - AveragePool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> - pad_height , kwidth , kheight , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> - int pad_width , int pad_height , int filter_width , <nl> - int filter_height , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - AveragePool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> - filter_width , filter_height , output_data , output_dims ) ; <nl> - } <nl> - <nl> - inline void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , <nl> - int pad_height , int filter_width , int filter_height , <nl> + inline void AveragePool ( const uint8 * input_data , <nl> + const RuntimeShape & input_shape , int stride_width , <nl> + int stride_height , int pad_width , int pad_height , <nl> + int filter_width , int filter_height , <nl> int32 output_activation_min , <nl> int32 output_activation_max , uint8 * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> + const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " AveragePool / 8bit " ) ; <nl> TFLITE_DCHECK_LE ( output_activation_min , output_activation_max ) ; <nl> - const int batches = MatchingArraySize ( input_dims , 3 , output_dims , 3 ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> - const int input_height = ArraySize ( input_dims , 2 ) ; <nl> - const int input_width = ArraySize ( input_dims , 1 ) ; <nl> - const int output_height = ArraySize ( output_dims , 2 ) ; <nl> - const int output_width = ArraySize ( output_dims , 1 ) ; <nl> + TFLITE_DCHECK_EQ ( input_shape . DimensionsCount ( ) , 4 ) ; <nl> + TFLITE_DCHECK_EQ ( output_shape . DimensionsCount ( ) , 4 ) ; <nl> + const int batches = MatchingDim ( input_shape , 0 , output_shape , 0 ) ; <nl> + const int depth = MatchingDim ( input_shape , 3 , output_shape , 3 ) ; <nl> + const int input_height = input_shape . Dims ( 1 ) ; <nl> + const int input_width = input_shape . Dims ( 2 ) ; <nl> + const int output_height = output_shape . Dims ( 1 ) ; <nl> + const int output_width = output_shape . Dims ( 2 ) ; <nl> for ( int batch = 0 ; batch < batches ; + + batch ) { <nl> for ( int out_y = 0 ; out_y < output_height ; + + out_y ) { <nl> for ( int out_x = 0 ; out_x < output_width ; + + out_x ) { <nl> inline void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> uint16 acc [ kAccBufferMaxSize ] ; <nl> memset ( acc , 0 , depth * sizeof ( acc [ 0 ] ) ) ; <nl> const uint8 * input_ptr = <nl> - input_data + input_dims . strides [ 1 ] * in_x_origin + <nl> - input_dims . strides [ 2 ] * in_y_origin + input_dims . strides [ 3 ] * batch ; <nl> + input_data + <nl> + depth * ( in_x_origin + <nl> + input_width * ( in_y_origin + input_height * batch ) ) ; <nl> for ( int fy = filter_y_start ; fy < filter_y_end ; fy + + ) { <nl> - const uint8 * input_row_ptr = input_ptr + fy * input_dims . strides [ 2 ] + <nl> - filter_x_start * input_dims . strides [ 1 ] ; <nl> + const uint8 * input_row_ptr = <nl> + input_ptr + depth * ( fy * input_width + filter_x_start ) ; <nl> for ( int fx = filter_x_start ; fx < filter_x_end ; fx + + ) { <nl> int channel = 0 ; <nl> # ifdef USE_NEON <nl> inline void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> uint8 * output_ptr = <nl> - output_data + Offset ( output_dims , 0 , out_x , out_y , batch ) ; <nl> + output_data + Offset ( output_shape , batch , out_y , out_x , 0 ) ; <nl> int channel = 0 ; <nl> # ifdef USE_NEON <nl> # define AVGPOOL_DIVIDING_BY ( FILTER_COUNT ) \ <nl> inline void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , <nl> - int pad_height , int filter_width , int filter_height , <nl> - int32 output_activation_min , int32 output_activation_max , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> - static_assert ( Ac = = FusedActivationFunctionType : : kNone | | <nl> - Ac = = FusedActivationFunctionType : : kRelu | | <nl> - Ac = = FusedActivationFunctionType : : kRelu6 | | <nl> - Ac = = FusedActivationFunctionType : : kRelu1 , <nl> - " " ) ; <nl> - if ( Ac = = FusedActivationFunctionType : : kNone ) { <nl> - TFLITE_DCHECK_EQ ( output_activation_min , 0 ) ; <nl> - TFLITE_DCHECK_EQ ( output_activation_max , 255 ) ; <nl> - } <nl> - AveragePool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> - pad_height , filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , int stride , <nl> - int pad_width , int pad_height , int filter_width , <nl> - int filter_height , int32 output_activation_min , <nl> - int32 output_activation_max , uint8 * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - AveragePool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> - filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - inline void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + inline void MaxPool ( const float * input_data , const RuntimeShape & input_shape , <nl> int stride_width , int stride_height , int pad_width , <nl> int pad_height , int kwidth , int kheight , <nl> float output_activation_min , float output_activation_max , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " MaxPool " ) ; <nl> - const int batches = MatchingArraySize ( input_dims , 3 , output_dims , 3 ) ; <nl> - const int input_height = ArraySize ( input_dims , 2 ) ; <nl> - const int input_width = ArraySize ( input_dims , 1 ) ; <nl> - const int output_height = ArraySize ( output_dims , 2 ) ; <nl> - const int output_width = ArraySize ( output_dims , 1 ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> - <nl> - const auto in_mat = MapAsMatrixWithFirstDimAsRows ( input_data , input_dims ) ; <nl> - auto out_mat = MapAsMatrixWithFirstDimAsRows ( output_data , output_dims ) ; <nl> + TFLITE_DCHECK_EQ ( input_shape . DimensionsCount ( ) , 4 ) ; <nl> + TFLITE_DCHECK_EQ ( output_shape . DimensionsCount ( ) , 4 ) ; <nl> + const int batches = MatchingDim ( input_shape , 0 , output_shape , 0 ) ; <nl> + const int depth = MatchingDim ( input_shape , 3 , output_shape , 3 ) ; <nl> + const int input_height = input_shape . Dims ( 1 ) ; <nl> + const int input_width = input_shape . Dims ( 2 ) ; <nl> + const int output_height = output_shape . Dims ( 1 ) ; <nl> + const int output_width = output_shape . Dims ( 2 ) ; <nl> + <nl> + const auto in_mat = MapAsMatrixWithLastDimAsRows ( input_data , input_shape ) ; <nl> + auto out_mat = MapAsMatrixWithLastDimAsRows ( output_data , output_shape ) ; <nl> / / Prefill the output to minimum representable float value <nl> out_mat . setConstant ( std : : numeric_limits < float > : : lowest ( ) ) ; <nl> for ( int b = 0 ; b < batches ; + + b ) { <nl> inline void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> for ( int y = 0 ; y < output_height ; + + y ) { <nl> for ( int x = 0 ; x < output_width ; + + x ) { <nl> for ( int c = 0 ; c < depth ; + + c ) { <nl> - output_data [ Offset ( output_dims , c , x , y , b ) ] = <nl> + output_data [ Offset ( output_shape , b , y , x , c ) ] = <nl> ActivationFunctionWithMinMax ( <nl> - output_data [ Offset ( output_dims , c , x , y , b ) ] , <nl> + output_data [ Offset ( output_shape , b , y , x , c ) ] , <nl> output_activation_min , output_activation_max ) ; <nl> } <nl> } <nl> inline void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , int pad_height , <nl> - int kwidth , int kheight , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - float output_activation_min , output_activation_max ; <nl> - GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> - MaxPool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> - pad_height , kwidth , kheight , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> - int pad_width , int pad_height , int filter_width , int filter_height , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - MaxPool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> - filter_width , filter_height , output_data , output_dims ) ; <nl> - } <nl> - <nl> - inline void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + inline void MaxPool ( const uint8 * input_data , const RuntimeShape & input_shape , <nl> int stride_width , int stride_height , int pad_width , <nl> int pad_height , int filter_width , int filter_height , <nl> int32 output_activation_min , int32 output_activation_max , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + uint8 * output_data , const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " MaxPool / 8bit " ) ; <nl> TFLITE_DCHECK_LE ( output_activation_min , output_activation_max ) ; <nl> - const int batches = MatchingArraySize ( input_dims , 3 , output_dims , 3 ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> - const int input_height = ArraySize ( input_dims , 2 ) ; <nl> - const int input_width = ArraySize ( input_dims , 1 ) ; <nl> - const int output_height = ArraySize ( output_dims , 2 ) ; <nl> - const int output_width = ArraySize ( output_dims , 1 ) ; <nl> + TFLITE_DCHECK_EQ ( input_shape . DimensionsCount ( ) , 4 ) ; <nl> + TFLITE_DCHECK_EQ ( output_shape . DimensionsCount ( ) , 4 ) ; <nl> + const int batches = MatchingDim ( input_shape , 0 , output_shape , 0 ) ; <nl> + const int depth = MatchingDim ( input_shape , 3 , output_shape , 3 ) ; <nl> + const int input_height = input_shape . Dims ( 1 ) ; <nl> + const int input_width = input_shape . Dims ( 2 ) ; <nl> + const int output_height = output_shape . Dims ( 1 ) ; <nl> + const int output_width = output_shape . Dims ( 2 ) ; <nl> for ( int batch = 0 ; batch < batches ; + + batch ) { <nl> for ( int out_y = 0 ; out_y < output_height ; + + out_y ) { <nl> for ( int out_x = 0 ; out_x < output_width ; + + out_x ) { <nl> inline void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> uint8 acc [ kAccBufferMaxSize ] ; <nl> memset ( acc , 0 , depth * sizeof ( acc [ 0 ] ) ) ; <nl> const uint8 * input_ptr = <nl> - input_data + input_dims . strides [ 1 ] * in_x_origin + <nl> - input_dims . strides [ 2 ] * in_y_origin + input_dims . strides [ 3 ] * batch ; <nl> + input_data + <nl> + depth * ( in_x_origin + <nl> + input_width * ( in_y_origin + input_height * batch ) ) ; <nl> for ( int fy = filter_y_start ; fy < filter_y_end ; fy + + ) { <nl> - const uint8 * input_row_ptr = input_ptr + fy * input_dims . strides [ 2 ] + <nl> - filter_x_start * input_dims . strides [ 1 ] ; <nl> + const uint8 * input_row_ptr = <nl> + input_ptr + depth * ( fy * input_width + filter_x_start ) ; <nl> for ( int fx = filter_x_start ; fx < filter_x_end ; fx + + ) { <nl> int channel = 0 ; <nl> # ifdef USE_NEON <nl> inline void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> uint8 * output_ptr = <nl> - output_data + Offset ( output_dims , 0 , out_x , out_y , batch ) ; <nl> + output_data + Offset ( output_shape , batch , out_y , out_x , 0 ) ; <nl> int channel = 0 ; <nl> # ifdef USE_NEON <nl> for ( ; channel < = depth - 16 ; channel + = 16 ) { <nl> inline void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , int pad_height , <nl> - int filter_width , int filter_height , int32 output_activation_min , <nl> - int32 output_activation_max , uint8 * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - static_assert ( Ac = = FusedActivationFunctionType : : kNone | | <nl> - Ac = = FusedActivationFunctionType : : kRelu | | <nl> - Ac = = FusedActivationFunctionType : : kRelu6 | | <nl> - Ac = = FusedActivationFunctionType : : kRelu1 , <nl> - " " ) ; <nl> - if ( Ac = = FusedActivationFunctionType : : kNone ) { <nl> - TFLITE_DCHECK_EQ ( output_activation_min , 0 ) ; <nl> - TFLITE_DCHECK_EQ ( output_activation_max , 255 ) ; <nl> - } <nl> - MaxPool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> - pad_height , filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , int stride , <nl> - int pad_width , int pad_height , int filter_width , int filter_height , <nl> - int32 output_activation_min , int32 output_activation_max , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> - MaxPool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> - filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - inline void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + inline void L2Pool ( const float * input_data , const RuntimeShape & input_shape , <nl> int stride_width , int stride_height , int pad_width , <nl> int pad_height , int filter_width , int filter_height , <nl> float output_activation_min , float output_activation_max , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " L2Pool " ) ; <nl> - const int batches = MatchingArraySize ( input_dims , 3 , output_dims , 3 ) ; <nl> - const int input_height = ArraySize ( input_dims , 2 ) ; <nl> - const int input_width = ArraySize ( input_dims , 1 ) ; <nl> - const int output_height = ArraySize ( output_dims , 2 ) ; <nl> - const int output_width = ArraySize ( output_dims , 1 ) ; <nl> + TFLITE_DCHECK_EQ ( input_shape . DimensionsCount ( ) , 4 ) ; <nl> + TFLITE_DCHECK_EQ ( output_shape . DimensionsCount ( ) , 4 ) ; <nl> + const int batches = MatchingDim ( input_shape , 0 , output_shape , 0 ) ; <nl> + const int input_height = input_shape . Dims ( 1 ) ; <nl> + const int input_width = input_shape . Dims ( 2 ) ; <nl> + const int output_height = output_shape . Dims ( 1 ) ; <nl> + const int output_width = output_shape . Dims ( 2 ) ; <nl> / / Actually carry out L2 Pool . Code is written in forward mode : we go through <nl> / / the input values once , and write to all the pooled regions that it maps to . <nl> - const auto in_mat = MapAsMatrixWithFirstDimAsRows ( input_data , input_dims ) ; <nl> - auto out_mat = MapAsMatrixWithFirstDimAsRows ( output_data , output_dims ) ; <nl> + const auto in_mat = MapAsMatrixWithLastDimAsRows ( input_data , input_shape ) ; <nl> + auto out_mat = MapAsMatrixWithLastDimAsRows ( output_data , output_shape ) ; <nl> Eigen : : VectorXf in_square ( in_mat . rows ( ) ) ; <nl> Eigen : : VectorXf out_count ( out_mat . cols ( ) ) ; <nl> out_count . setZero ( ) ; <nl> inline void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> ( out_mat . array ( ) . rowwise ( ) * out_count . transpose ( ) . array ( ) ) . cwiseSqrt ( ) ; <nl> } <nl> <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , int pad_height , <nl> - int filter_width , int filter_height , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - float output_activation_min , output_activation_max ; <nl> - GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> - L2Pool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> - pad_height , filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> - int pad_width , int pad_height , int filter_width , int filter_height , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - L2Pool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> - filter_width , filter_height , output_data , output_dims ) ; <nl> - } <nl> - <nl> inline void LocalResponseNormalization ( const float * input_data , <nl> const Dims < 4 > & input_dims , int range , <nl> float bias , float alpha , float beta , <nl> inline void LocalResponseNormalization ( const float * input_data , <nl> } <nl> } <nl> <nl> - inline void Softmax ( const float * input_data , const Dims < 4 > & input_dims , <nl> + inline void Softmax ( const float * input_data , const RuntimeShape & input_shape , <nl> float beta , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> + const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " Softmax " ) ; <nl> - MatchingFlatSize ( input_dims , output_dims ) ; <nl> + MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> - const auto in_mat = MapAsMatrixWithFirstDimAsRows ( input_data , input_dims ) ; <nl> - auto out_mat = MapAsMatrixWithFirstDimAsRows ( output_data , output_dims ) ; <nl> + const auto in_mat = MapAsMatrixWithLastDimAsRows ( input_data , input_shape ) ; <nl> + auto out_mat = MapAsMatrixWithLastDimAsRows ( output_data , output_shape ) ; <nl> / / Compute the exponential first , removing the max coefficient for numerical <nl> / / stability . <nl> out_mat = ( in_mat . rowwise ( ) - in_mat . colwise ( ) . maxCoeff ( ) ) . array ( ) * beta ; <nl> inline void Softmax ( const float * input_data , const Dims < 4 > & input_dims , <nl> out_mat . array ( ) . rowwise ( ) * = scale ; <nl> } <nl> <nl> - inline void Softmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + inline void Softmax ( const uint8 * input_data , const RuntimeShape & input_shape , <nl> int32 input_beta_multiplier , int32 input_beta_left_shift , <nl> int diff_min , uint8 * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> + const RuntimeShape & output_shape ) { <nl> / / The representation chosen for the input to the exp ( ) function is Q5 . 26 . <nl> / / We need to leave extra space since values that we skip might be as large as <nl> / / - 32 before multiplying by input_beta_multiplier , and therefore as large as <nl> inline void Softmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> using FixedPoint0 = gemmlowp : : FixedPoint < int32 , 0 > ; <nl> <nl> gemmlowp : : ScopedProfilingLabel label ( " Softmax / 8bit " ) ; <nl> - const int outer_size = MatchingFlatSizeSkipDim ( input_dims , 0 , output_dims ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> + const int trailing_dim = input_shape . DimensionsCount ( ) - 1 ; <nl> + const int outer_size = <nl> + MatchingFlatSizeSkipDim ( input_shape , trailing_dim , output_shape ) ; <nl> + const int depth = <nl> + MatchingDim ( input_shape , trailing_dim , output_shape , trailing_dim ) ; <nl> <nl> for ( int b = 0 ; b < outer_size ; + + b ) { <nl> const uint8 * input_data_ptr = input_data + b * depth ; <nl> inline void Softmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> <nl> / / TODO ( myenik ) : This is the same as the reference implementation , not actually <nl> / / optimized yet . <nl> - inline void LogSoftmax ( const float * input_data , const Dims < 4 > & input_dims , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> + inline void LogSoftmax ( const float * input_data , const RuntimeShape & input_shape , <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " LogSoftmax " ) ; <nl> - const int outer_size = MatchingFlatSizeSkipDim ( input_dims , 0 , output_dims ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> + const int trailing_dim = input_shape . DimensionsCount ( ) - 1 ; <nl> + const int outer_size = <nl> + MatchingFlatSizeSkipDim ( input_shape , trailing_dim , output_shape ) ; <nl> + const int depth = <nl> + MatchingDim ( input_shape , trailing_dim , output_shape , trailing_dim ) ; <nl> <nl> for ( int i = 0 ; i < outer_size ; + + i ) { <nl> const float * block_input_data = input_data + i * depth ; <nl> log_x_for_x_greater_than_or_equal_to_1 ( <nl> } <nl> <nl> / / Currently just a copy of the reference code . <nl> - inline void LogSoftmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + inline void LogSoftmax ( const uint8 * input_data , const RuntimeShape & input_shape , <nl> int32 input_multiplier , int32 input_left_shift , <nl> int32 reverse_scaling_divisor , <nl> int32 reverse_scaling_right_shift , int diff_min , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + uint8 * output_data , const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " LogSoftmax / Uint8 " ) ; <nl> / / The representation chosen for the input to the exp ( ) function is Q5 . 26 . <nl> / / We need to leave extra space since values that we skip might be as large as <nl> inline void LogSoftmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> using FixedPointAccum = gemmlowp : : FixedPoint < int32 , kAccumulationIntegerBits > ; <nl> using FixedPoint0 = gemmlowp : : FixedPoint < int32 , 0 > ; <nl> <nl> - const int outer_size = MatchingFlatSizeSkipDim ( input_dims , 0 , output_dims ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> + const int trailing_dim = input_shape . DimensionsCount ( ) - 1 ; <nl> + const int outer_size = <nl> + MatchingFlatSizeSkipDim ( input_shape , trailing_dim , output_shape ) ; <nl> + const int depth = <nl> + MatchingDim ( input_shape , trailing_dim , output_shape , trailing_dim ) ; <nl> <nl> for ( int i = 0 ; i < outer_size ; + + i ) { <nl> const uint8 * block_input_data = input_data + i * depth ; <nl> inline void LogSoftmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Logistic ( const float * input_data , const Dims < 4 > & input_dims , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> + inline void Logistic ( const float * input_data , const RuntimeShape & input_shape , <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " Logistic " ) ; <nl> - auto input_map = MapAsVector ( input_data , input_dims ) ; <nl> - auto output_map = MapAsVector ( output_data , output_dims ) ; <nl> + auto input_map = MapAsVector ( input_data , input_shape ) ; <nl> + auto output_map = MapAsVector ( output_data , output_shape ) ; <nl> output_map . array ( ) = <nl> input_map . array ( ) . unaryExpr ( Eigen : : internal : : scalar_sigmoid_op < float > ( ) ) ; <nl> } <nl> <nl> - inline void Logistic ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + inline void Logistic ( const uint8 * input_data , const RuntimeShape & input_shape , <nl> int32 input_zero_point , int32 input_range_radius , <nl> int32 input_multiplier , int input_left_shift , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + uint8 * output_data , const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " Logistic / Uint8 " ) ; <nl> - const int size = MatchingFlatSize ( input_dims , output_dims ) ; <nl> + const int size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> int c = 0 ; <nl> # ifdef USE_NEON <nl> inline void Logistic ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Logistic ( const int16 * input_data , const Dims < 4 > & input_dims , <nl> - int16 * output_data , const Dims < 4 > & output_dims ) { <nl> + inline void Logistic ( const int16 * input_data , const RuntimeShape & input_shape , <nl> + int16 * output_data , const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " Logistic / Int16 " ) ; <nl> - const int flat_size = MatchingFlatSize ( output_dims , input_dims ) ; <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> for ( int i = 0 ; i < flat_size ; i + + ) { <nl> } <nl> inline void Logistic ( const int16 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Tanh ( const float * input_data , const Dims < 4 > & input_dims , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> + inline void Tanh ( const float * input_data , const RuntimeShape & input_shape , <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " Tanh " ) ; <nl> - auto input_map = MapAsVector ( input_data , input_dims ) ; <nl> - auto output_map = MapAsVector ( output_data , output_dims ) ; <nl> + auto input_map = MapAsVector ( input_data , input_shape ) ; <nl> + auto output_map = MapAsVector ( output_data , output_shape ) ; <nl> output_map . array ( ) = input_map . array ( ) . tanh ( ) ; <nl> } <nl> <nl> - inline void Tanh ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + inline void Tanh ( const uint8 * input_data , const RuntimeShape & input_shape , <nl> int32 input_zero_point , int32 input_range_radius , <nl> int32 input_multiplier , int input_left_shift , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + uint8 * output_data , const RuntimeShape & output_shape ) { <nl> / / Note that this is almost the exact same code as in Logistic ( ) . <nl> gemmlowp : : ScopedProfilingLabel label ( " Tanh " ) ; <nl> - const int size = MatchingFlatSize ( input_dims , output_dims ) ; <nl> + const int size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> int c = 0 ; <nl> int32_t output_zero_point = 128 ; <nl> inline void Tanh ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Tanh ( const int16 * input_data , const Dims < 4 > & input_dims , <nl> + inline void Tanh ( const int16 * input_data , const RuntimeShape & input_shape , <nl> int input_left_shift , int16 * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> + const RuntimeShape & output_shape ) { <nl> gemmlowp : : ScopedProfilingLabel label ( " Tanh / Int16 " ) ; <nl> / / Support for shifts is limited until we have a parameterized version of <nl> / / SaturatingRoundingMultiplyByPOT ( ) . <nl> TFLITE_DCHECK_GE ( input_left_shift , 0 ) ; <nl> TFLITE_DCHECK_LE ( input_left_shift , 1 ) ; <nl> <nl> - const int flat_size = MatchingFlatSize ( output_dims , input_dims ) ; <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> int c = 0 ; <nl> const int16 * input_data_ptr = input_data ; <nl> mmm a / tensorflow / contrib / lite / kernels / internal / reference / legacy_reference_ops . h <nl> ppp b / tensorflow / contrib / lite / kernels / internal / reference / legacy_reference_ops . h <nl> inline RuntimeShape DimsToShape ( const tflite : : Dims < 4 > & dims ) { <nl> template < FusedActivationFunctionType Ac > <nl> void L2Normalization ( const float * input_data , const Dims < 4 > & input_dims , <nl> float * output_data , const Dims < 4 > & output_dims ) { <nl> - return L2Normalization < Ac > ( input_data , DimsToShape ( input_dims ) , output_data , <nl> - DimsToShape ( output_dims ) ) ; <nl> + L2Normalization < Ac > ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> } <nl> <nl> inline void L2Normalization ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> int32 input_zero_point , uint8 * output_data , <nl> const Dims < 4 > & output_dims ) { <nl> - return L2Normalization ( input_data , DimsToShape ( input_dims ) , input_zero_point , <nl> - output_data , DimsToShape ( output_dims ) ) ; <nl> + L2Normalization ( input_data , DimsToShape ( input_dims ) , input_zero_point , <nl> + output_data , DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Relu ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + Relu ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Relu1 ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + Relu1 ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Relu6 ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + Relu6 ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int kwidth , int kheight , <nl> + float output_activation_min , <nl> + float output_activation_max , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + AveragePool ( input_data , DimsToShape ( input_dims ) , stride_width , stride_height , <nl> + pad_width , pad_height , kwidth , kheight , output_activation_min , <nl> + output_activation_max , output_data , DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int kwidth , int kheight , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + float output_activation_min , output_activation_max ; <nl> + GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> + <nl> + AveragePool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> + pad_height , kwidth , kheight , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> + int pad_width , int pad_height , int filter_width , <nl> + int filter_height , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + AveragePool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> + filter_width , filter_height , output_data , output_dims ) ; <nl> + } <nl> + <nl> + inline void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int filter_width , int filter_height , <nl> + int32 output_activation_min , <nl> + int32 output_activation_max , uint8 * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + AveragePool ( input_data , DimsToShape ( input_dims ) , stride_width , stride_height , <nl> + pad_width , pad_height , filter_width , filter_height , <nl> + output_activation_min , output_activation_max , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int filter_width , int filter_height , <nl> + int32 output_activation_min , int32 output_activation_max , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + static_assert ( Ac = = FusedActivationFunctionType : : kNone | | <nl> + Ac = = FusedActivationFunctionType : : kRelu | | <nl> + Ac = = FusedActivationFunctionType : : kRelu6 | | <nl> + Ac = = FusedActivationFunctionType : : kRelu1 , <nl> + " " ) ; <nl> + if ( Ac = = FusedActivationFunctionType : : kNone ) { <nl> + TFLITE_DCHECK_EQ ( output_activation_min , 0 ) ; <nl> + TFLITE_DCHECK_EQ ( output_activation_max , 255 ) ; <nl> + } <nl> + AveragePool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> + pad_height , filter_width , filter_height , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , int stride , <nl> + int pad_width , int pad_height , int filter_width , <nl> + int filter_height , int32 output_activation_min , <nl> + int32 output_activation_max , uint8 * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + AveragePool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> + filter_width , filter_height , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + inline void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int kwidth , int kheight , <nl> + float output_activation_min , float output_activation_max , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + MaxPool ( input_data , DimsToShape ( input_dims ) , stride_width , stride_height , <nl> + pad_width , pad_height , kwidth , kheight , output_activation_min , <nl> + output_activation_max , output_data , DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , int pad_height , <nl> + int kwidth , int kheight , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + float output_activation_min , output_activation_max ; <nl> + GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> + MaxPool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> + pad_height , kwidth , kheight , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> + int pad_width , int pad_height , int filter_width , int filter_height , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + MaxPool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> + filter_width , filter_height , output_data , output_dims ) ; <nl> + } <nl> + <nl> + inline void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int filter_width , int filter_height , <nl> + int32 output_activation_min , int32 output_activation_max , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + MaxPool ( input_data , DimsToShape ( input_dims ) , stride_width , stride_height , <nl> + pad_width , pad_height , filter_width , filter_height , <nl> + output_activation_min , output_activation_max , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , int pad_height , <nl> + int filter_width , int filter_height , int32 output_activation_min , <nl> + int32 output_activation_max , uint8 * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + static_assert ( Ac = = FusedActivationFunctionType : : kNone | | <nl> + Ac = = FusedActivationFunctionType : : kRelu | | <nl> + Ac = = FusedActivationFunctionType : : kRelu6 | | <nl> + Ac = = FusedActivationFunctionType : : kRelu1 , <nl> + " " ) ; <nl> + if ( Ac = = FusedActivationFunctionType : : kNone ) { <nl> + TFLITE_DCHECK_EQ ( output_activation_min , 0 ) ; <nl> + TFLITE_DCHECK_EQ ( output_activation_max , 255 ) ; <nl> + } <nl> + MaxPool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> + pad_height , filter_width , filter_height , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , int stride , <nl> + int pad_width , int pad_height , int filter_width , int filter_height , <nl> + int32 output_activation_min , int32 output_activation_max , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + MaxPool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> + filter_width , filter_height , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + inline void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , <nl> + int pad_height , int filter_width , int filter_height , <nl> + float output_activation_min , float output_activation_max , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + L2Pool ( input_data , DimsToShape ( input_dims ) , stride_width , stride_height , <nl> + pad_width , pad_height , filter_width , filter_height , <nl> + output_activation_min , output_activation_max , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + int stride_width , int stride_height , int pad_width , int pad_height , <nl> + int filter_width , int filter_height , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + float output_activation_min , output_activation_max ; <nl> + GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> + L2Pool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> + pad_height , filter_width , filter_height , output_activation_min , <nl> + output_activation_max , output_data , output_dims ) ; <nl> + } <nl> + <nl> + / / legacy , for compatibility with old checked - in code <nl> + template < FusedActivationFunctionType Ac > <nl> + void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> + int pad_width , int pad_height , int filter_width , int filter_height , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + L2Pool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> + filter_width , filter_height , output_data , output_dims ) ; <nl> + } <nl> + <nl> + inline void Softmax ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float beta , float * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + Softmax ( input_data , DimsToShape ( input_dims ) , beta , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Softmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int32 input_beta_multiplier , int32 input_beta_left_shift , <nl> + int diff_min , uint8 * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + Softmax ( input_data , DimsToShape ( input_dims ) , input_beta_multiplier , <nl> + input_beta_left_shift , diff_min , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void LogSoftmax ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + LogSoftmax ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void LogSoftmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int32 input_multiplier , int32 input_left_shift , <nl> + int32 reverse_scaling_divisor , <nl> + int32 reverse_scaling_right_shift , int diff_min , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + LogSoftmax ( input_data , DimsToShape ( input_dims ) , input_multiplier , <nl> + input_left_shift , reverse_scaling_divisor , <nl> + reverse_scaling_right_shift , diff_min , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Logistic ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + Logistic ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Logistic ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int32 input_zero_point , int32 input_range_radius , <nl> + int32 input_multiplier , int input_left_shift , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + Logistic ( input_data , DimsToShape ( input_dims ) , input_zero_point , <nl> + input_range_radius , input_multiplier , input_left_shift , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Logistic ( const int16 * input_data , const Dims < 4 > & input_dims , <nl> + int16 * output_data , const Dims < 4 > & output_dims ) { <nl> + Logistic ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Tanh ( const float * input_data , const Dims < 4 > & input_dims , <nl> + float * output_data , const Dims < 4 > & output_dims ) { <nl> + Tanh ( input_data , DimsToShape ( input_dims ) , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Tanh ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + int32 input_zero_point , int32 input_range_radius , <nl> + int32 input_multiplier , int input_left_shift , <nl> + uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + Tanh ( input_data , DimsToShape ( input_dims ) , input_zero_point , <nl> + input_range_radius , input_multiplier , input_left_shift , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> + } <nl> + <nl> + inline void Tanh ( const int16 * input_data , const Dims < 4 > & input_dims , <nl> + int input_left_shift , int16 * output_data , <nl> + const Dims < 4 > & output_dims ) { <nl> + Tanh ( input_data , DimsToShape ( input_dims ) , input_left_shift , output_data , <nl> + DimsToShape ( output_dims ) ) ; <nl> } <nl> <nl> } / / namespace reference_ops <nl> mmm a / tensorflow / contrib / lite / kernels / internal / reference / reference_ops . h <nl> ppp b / tensorflow / contrib / lite / kernels / internal / reference / reference_ops . h <nl> void GlobalBatchNormalization ( const float * input_data , <nl> } <nl> } <nl> <nl> - inline void Relu ( const float * input_data , const Dims < 4 > & input_dims , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - const int flat_size = MatchingFlatSize ( input_dims , output_dims ) ; <nl> + inline void Relu ( const float * input_data , const RuntimeShape & input_shape , <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> for ( int i = 0 ; i < flat_size ; + + i ) { <nl> const float val = input_data [ i ] ; <nl> const float lower = 0 ; <nl> inline void Relu ( const float * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Relu1 ( const float * input_data , const Dims < 4 > & input_dims , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - const int flat_size = MatchingFlatSize ( input_dims , output_dims ) ; <nl> + inline void Relu1 ( const float * input_data , const RuntimeShape & input_shape , <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> + gemmlowp : : ScopedProfilingLabel label ( " Relu1 ( not fused ) " ) ; <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> for ( int i = 0 ; i < flat_size ; + + i ) { <nl> const float val = input_data [ i ] ; <nl> const float upper = 1 ; <nl> inline void Relu1 ( const float * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Relu6 ( const float * input_data , const Dims < 4 > & input_dims , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - const int flat_size = MatchingFlatSize ( input_dims , output_dims ) ; <nl> + inline void Relu6 ( const float * input_data , const RuntimeShape & input_shape , <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> + gemmlowp : : ScopedProfilingLabel label ( " Relu6 ( not fused ) " ) ; <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> for ( int i = 0 ; i < flat_size ; + + i ) { <nl> const float val = input_data [ i ] ; <nl> const float upper = 6 ; <nl> inline int NodeOffset ( int b , int h , int w , int height , int width ) { <nl> return ( b * height + h ) * width + w ; <nl> } <nl> <nl> - inline void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , <nl> - int pad_height , int filter_width , int filter_height , <nl> + inline void AveragePool ( const float * input_data , <nl> + const RuntimeShape & input_shape , int stride_width , <nl> + int stride_height , int pad_width , int pad_height , <nl> + int filter_width , int filter_height , <nl> float output_activation_min , <nl> float output_activation_max , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - const int batches = MatchingArraySize ( input_dims , 3 , output_dims , 3 ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> - const int input_height = ArraySize ( input_dims , 2 ) ; <nl> - const int input_width = ArraySize ( input_dims , 1 ) ; <nl> - const int output_height = ArraySize ( output_dims , 2 ) ; <nl> - const int output_width = ArraySize ( output_dims , 1 ) ; <nl> + const RuntimeShape & output_shape ) { <nl> + TFLITE_DCHECK_EQ ( input_shape . DimensionsCount ( ) , 4 ) ; <nl> + TFLITE_DCHECK_EQ ( output_shape . DimensionsCount ( ) , 4 ) ; <nl> + const int batches = MatchingDim ( input_shape , 0 , output_shape , 0 ) ; <nl> + const int depth = MatchingDim ( input_shape , 3 , output_shape , 3 ) ; <nl> + const int input_height = input_shape . Dims ( 1 ) ; <nl> + const int input_width = input_shape . Dims ( 2 ) ; <nl> + const int output_height = output_shape . Dims ( 1 ) ; <nl> + const int output_width = output_shape . Dims ( 2 ) ; <nl> for ( int batch = 0 ; batch < batches ; + + batch ) { <nl> for ( int out_y = 0 ; out_y < output_height ; + + out_y ) { <nl> for ( int out_x = 0 ; out_x < output_width ; + + out_x ) { <nl> inline void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> const int in_x = in_x_origin + filter_x ; <nl> const int in_y = in_y_origin + filter_y ; <nl> total + = <nl> - input_data [ Offset ( input_dims , channel , in_x , in_y , batch ) ] ; <nl> + input_data [ Offset ( input_shape , batch , in_y , in_x , channel ) ] ; <nl> filter_count + + ; <nl> } <nl> } <nl> const float average = total / filter_count ; <nl> - output_data [ Offset ( output_dims , channel , out_x , out_y , batch ) ] = <nl> + output_data [ Offset ( output_shape , batch , out_y , out_x , channel ) ] = <nl> ActivationFunctionWithMinMax ( average , output_activation_min , <nl> output_activation_max ) ; <nl> } <nl> inline void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , <nl> - int pad_height , int filter_width , int filter_height , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - float output_activation_min , output_activation_max ; <nl> - GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> - AveragePool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> - pad_height , filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void AveragePool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> - int pad_width , int pad_height , int filter_width , <nl> - int filter_height , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - AveragePool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> - filter_width , filter_height , output_data , output_dims ) ; <nl> - } <nl> - <nl> - inline void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , <nl> - int pad_height , int filter_width , int filter_height , <nl> + inline void AveragePool ( const uint8 * input_data , <nl> + const RuntimeShape & input_shape , int stride_width , <nl> + int stride_height , int pad_width , int pad_height , <nl> + int filter_width , int filter_height , <nl> int32 output_activation_min , <nl> int32 output_activation_max , uint8 * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> + const RuntimeShape & output_shape ) { <nl> TFLITE_DCHECK_LE ( output_activation_min , output_activation_max ) ; <nl> - const int batches = MatchingArraySize ( input_dims , 3 , output_dims , 3 ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> - const int input_height = ArraySize ( input_dims , 2 ) ; <nl> - const int input_width = ArraySize ( input_dims , 1 ) ; <nl> - const int output_height = ArraySize ( output_dims , 2 ) ; <nl> - const int output_width = ArraySize ( output_dims , 1 ) ; <nl> + TFLITE_DCHECK_EQ ( input_shape . DimensionsCount ( ) , 4 ) ; <nl> + TFLITE_DCHECK_EQ ( output_shape . DimensionsCount ( ) , 4 ) ; <nl> + const int batches = MatchingDim ( input_shape , 0 , output_shape , 0 ) ; <nl> + const int depth = MatchingDim ( input_shape , 3 , output_shape , 3 ) ; <nl> + const int input_height = input_shape . Dims ( 1 ) ; <nl> + const int input_width = input_shape . Dims ( 2 ) ; <nl> + const int output_height = output_shape . Dims ( 1 ) ; <nl> + const int output_width = output_shape . Dims ( 2 ) ; <nl> for ( int batch = 0 ; batch < batches ; + + batch ) { <nl> for ( int out_y = 0 ; out_y < output_height ; + + out_y ) { <nl> for ( int out_x = 0 ; out_x < output_width ; + + out_x ) { <nl> inline void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + + filter_x ) { <nl> const int in_x = in_x_origin + filter_x ; <nl> const int in_y = in_y_origin + filter_y ; <nl> - acc + = input_data [ Offset ( input_dims , channel , in_x , in_y , batch ) ] ; <nl> + acc + = <nl> + input_data [ Offset ( input_shape , batch , in_y , in_x , channel ) ] ; <nl> filter_count + + ; <nl> } <nl> } <nl> acc = ( acc + filter_count / 2 ) / filter_count ; <nl> acc = std : : max ( acc , output_activation_min ) ; <nl> acc = std : : min ( acc , output_activation_max ) ; <nl> - output_data [ Offset ( output_dims , channel , out_x , out_y , batch ) ] = <nl> + output_data [ Offset ( output_shape , batch , out_y , out_x , channel ) ] = <nl> static_cast < uint8 > ( acc ) ; <nl> } <nl> } <nl> inline void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , <nl> - int pad_height , int filter_width , int filter_height , <nl> - int32 output_activation_min , int32 output_activation_max , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> - static_assert ( Ac = = FusedActivationFunctionType : : kNone | | <nl> - Ac = = FusedActivationFunctionType : : kRelu | | <nl> - Ac = = FusedActivationFunctionType : : kRelu6 | | <nl> - Ac = = FusedActivationFunctionType : : kRelu1 , <nl> - " " ) ; <nl> - if ( Ac = = FusedActivationFunctionType : : kNone ) { <nl> - TFLITE_DCHECK_EQ ( output_activation_min , 0 ) ; <nl> - TFLITE_DCHECK_EQ ( output_activation_max , 255 ) ; <nl> - } <nl> - AveragePool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> - pad_height , filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void AveragePool ( const uint8 * input_data , const Dims < 4 > & input_dims , int stride , <nl> - int pad_width , int pad_height , int filter_width , <nl> - int filter_height , int32 output_activation_min , <nl> - int32 output_activation_max , uint8 * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - AveragePool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> - filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - inline void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + inline void L2Pool ( const float * input_data , const RuntimeShape & input_shape , <nl> int stride_width , int stride_height , int pad_width , <nl> int pad_height , int filter_width , int filter_height , <nl> float output_activation_min , float output_activation_max , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - const int batches = MatchingArraySize ( input_dims , 3 , output_dims , 3 ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> - const int input_height = ArraySize ( input_dims , 2 ) ; <nl> - const int input_width = ArraySize ( input_dims , 1 ) ; <nl> - const int output_height = ArraySize ( output_dims , 2 ) ; <nl> - const int output_width = ArraySize ( output_dims , 1 ) ; <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> + TFLITE_DCHECK_EQ ( input_shape . DimensionsCount ( ) , 4 ) ; <nl> + TFLITE_DCHECK_EQ ( output_shape . DimensionsCount ( ) , 4 ) ; <nl> + const int batches = MatchingDim ( input_shape , 0 , output_shape , 0 ) ; <nl> + const int depth = MatchingDim ( input_shape , 3 , output_shape , 3 ) ; <nl> + const int input_height = input_shape . Dims ( 1 ) ; <nl> + const int input_width = input_shape . Dims ( 2 ) ; <nl> + const int output_height = output_shape . Dims ( 1 ) ; <nl> + const int output_width = output_shape . Dims ( 2 ) ; <nl> for ( int batch = 0 ; batch < batches ; + + batch ) { <nl> for ( int out_y = 0 ; out_y < output_height ; + + out_y ) { <nl> for ( int out_x = 0 ; out_x < output_width ; + + out_x ) { <nl> inline void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> const int in_x = in_x_origin + filter_x ; <nl> const int in_y = in_y_origin + filter_y ; <nl> const float val = <nl> - input_data [ Offset ( input_dims , channel , in_x , in_y , batch ) ] ; <nl> + input_data [ Offset ( input_shape , batch , in_y , in_x , channel ) ] ; <nl> sum_squares + = val * val ; <nl> filter_count + + ; <nl> } <nl> } <nl> const float l2pool_result = std : : sqrt ( sum_squares / filter_count ) ; <nl> - output_data [ Offset ( output_dims , channel , out_x , out_y , batch ) ] = <nl> + output_data [ Offset ( output_shape , batch , out_y , out_x , channel ) ] = <nl> ActivationFunctionWithMinMax ( l2pool_result , output_activation_min , <nl> output_activation_max ) ; <nl> } <nl> inline void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , int pad_height , <nl> - int filter_width , int filter_height , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - float output_activation_min , output_activation_max ; <nl> - GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> - <nl> - L2Pool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> - pad_height , filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void L2Pool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> - int pad_width , int pad_height , int filter_width , int filter_height , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - L2Pool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> - filter_width , filter_height , output_data , output_dims ) ; <nl> - } <nl> - <nl> - inline void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> + inline void MaxPool ( const float * input_data , const RuntimeShape & input_shape , <nl> int stride_width , int stride_height , int pad_width , <nl> int pad_height , int filter_width , int filter_height , <nl> float output_activation_min , float output_activation_max , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - const int batches = MatchingArraySize ( input_dims , 3 , output_dims , 3 ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> - const int input_height = ArraySize ( input_dims , 2 ) ; <nl> - const int input_width = ArraySize ( input_dims , 1 ) ; <nl> - const int output_height = ArraySize ( output_dims , 2 ) ; <nl> - const int output_width = ArraySize ( output_dims , 1 ) ; <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> + TFLITE_DCHECK_EQ ( input_shape . DimensionsCount ( ) , 4 ) ; <nl> + TFLITE_DCHECK_EQ ( output_shape . DimensionsCount ( ) , 4 ) ; <nl> + const int batches = MatchingDim ( input_shape , 0 , output_shape , 0 ) ; <nl> + const int depth = MatchingDim ( input_shape , 3 , output_shape , 3 ) ; <nl> + const int input_height = input_shape . Dims ( 1 ) ; <nl> + const int input_width = input_shape . Dims ( 2 ) ; <nl> + const int output_height = output_shape . Dims ( 1 ) ; <nl> + const int output_width = output_shape . Dims ( 2 ) ; <nl> for ( int batch = 0 ; batch < batches ; + + batch ) { <nl> for ( int out_y = 0 ; out_y < output_height ; + + out_y ) { <nl> for ( int out_x = 0 ; out_x < output_width ; + + out_x ) { <nl> inline void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> const int in_y = in_y_origin + filter_y ; <nl> max = std : : max ( <nl> max , <nl> - input_data [ Offset ( input_dims , channel , in_x , in_y , batch ) ] ) ; <nl> + input_data [ Offset ( input_shape , batch , in_y , in_x , channel ) ] ) ; <nl> } <nl> } <nl> - output_data [ Offset ( output_dims , channel , out_x , out_y , batch ) ] = <nl> + output_data [ Offset ( output_shape , batch , out_y , out_x , channel ) ] = <nl> ActivationFunctionWithMinMax ( max , output_activation_min , <nl> output_activation_max ) ; <nl> } <nl> inline void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , int pad_height , <nl> - int filter_width , int filter_height , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - float output_activation_min , output_activation_max ; <nl> - GetActivationMinMax ( Ac , & output_activation_min , & output_activation_max ) ; <nl> - MaxPool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> - pad_height , filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void MaxPool ( const float * input_data , const Dims < 4 > & input_dims , int stride , <nl> - int pad_width , int pad_height , int filter_width , int filter_height , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - MaxPool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> - filter_width , filter_height , output_data , output_dims ) ; <nl> - } <nl> - <nl> - inline void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + inline void MaxPool ( const uint8 * input_data , const RuntimeShape & input_shape , <nl> int stride_width , int stride_height , int pad_width , <nl> int pad_height , int filter_width , int filter_height , <nl> int32 output_activation_min , int32 output_activation_max , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + uint8 * output_data , const RuntimeShape & output_shape ) { <nl> TFLITE_DCHECK_LE ( output_activation_min , output_activation_max ) ; <nl> TFLITE_DCHECK_GE ( output_activation_min , 0 ) ; <nl> TFLITE_DCHECK_LE ( output_activation_max , 255 ) ; <nl> - const int batches = MatchingArraySize ( input_dims , 3 , output_dims , 3 ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> - const int input_height = ArraySize ( input_dims , 2 ) ; <nl> - const int input_width = ArraySize ( input_dims , 1 ) ; <nl> - const int output_height = ArraySize ( output_dims , 2 ) ; <nl> - const int output_width = ArraySize ( output_dims , 1 ) ; <nl> + TFLITE_DCHECK_EQ ( input_shape . DimensionsCount ( ) , 4 ) ; <nl> + TFLITE_DCHECK_EQ ( output_shape . DimensionsCount ( ) , 4 ) ; <nl> + const int batches = MatchingDim ( input_shape , 0 , output_shape , 0 ) ; <nl> + const int depth = MatchingDim ( input_shape , 3 , output_shape , 3 ) ; <nl> + const int input_height = input_shape . Dims ( 1 ) ; <nl> + const int input_width = input_shape . Dims ( 2 ) ; <nl> + const int output_height = output_shape . Dims ( 1 ) ; <nl> + const int output_width = output_shape . Dims ( 2 ) ; <nl> for ( int batch = 0 ; batch < batches ; + + batch ) { <nl> for ( int out_y = 0 ; out_y < output_height ; + + out_y ) { <nl> for ( int out_x = 0 ; out_x < output_width ; + + out_x ) { <nl> inline void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> const int in_y = in_y_origin + filter_y ; <nl> max = std : : max ( <nl> max , <nl> - input_data [ Offset ( input_dims , channel , in_x , in_y , batch ) ] ) ; <nl> + input_data [ Offset ( input_shape , batch , in_y , in_x , channel ) ] ) ; <nl> } <nl> } <nl> max = std : : max < uint8 > ( max , output_activation_min ) ; <nl> max = std : : min < uint8 > ( max , output_activation_max ) ; <nl> - output_data [ Offset ( output_dims , channel , out_x , out_y , batch ) ] = <nl> + output_data [ Offset ( output_shape , batch , out_y , out_x , channel ) ] = <nl> static_cast < uint8 > ( max ) ; <nl> } <nl> } <nl> inline void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> - int stride_width , int stride_height , int pad_width , int pad_height , <nl> - int filter_width , int filter_height , int32 output_activation_min , <nl> - int32 output_activation_max , uint8 * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - static_assert ( Ac = = FusedActivationFunctionType : : kNone | | <nl> - Ac = = FusedActivationFunctionType : : kRelu | | <nl> - Ac = = FusedActivationFunctionType : : kRelu6 | | <nl> - Ac = = FusedActivationFunctionType : : kRelu1 , <nl> - " " ) ; <nl> - if ( Ac = = FusedActivationFunctionType : : kNone ) { <nl> - TFLITE_DCHECK_EQ ( output_activation_min , 0 ) ; <nl> - TFLITE_DCHECK_EQ ( output_activation_max , 255 ) ; <nl> - } <nl> - MaxPool ( input_data , input_dims , stride_width , stride_height , pad_width , <nl> - pad_height , filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> - / / legacy , for compatibility with old checked - in code <nl> - template < FusedActivationFunctionType Ac > <nl> - void MaxPool ( const uint8 * input_data , const Dims < 4 > & input_dims , int stride , <nl> - int pad_width , int pad_height , int filter_width , int filter_height , <nl> - int32 output_activation_min , int32 output_activation_max , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> - MaxPool < Ac > ( input_data , input_dims , stride , stride , pad_width , pad_height , <nl> - filter_width , filter_height , output_activation_min , <nl> - output_activation_max , output_data , output_dims ) ; <nl> - } <nl> - <nl> inline void LocalResponseNormalization ( const float * input_data , <nl> const Dims < 4 > & input_dims , int range , <nl> float bias , float alpha , float beta , <nl> inline void LocalResponseNormalization ( const float * input_data , <nl> } <nl> } <nl> <nl> - inline void Softmax ( const float * input_data , const Dims < 4 > & input_dims , <nl> + inline void Softmax ( const float * input_data , const RuntimeShape & input_shape , <nl> float beta , float * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> - const int outer_size = MatchingFlatSizeSkipDim ( input_dims , 0 , output_dims ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> + const RuntimeShape & output_shape ) { <nl> + const int trailing_dim = input_shape . DimensionsCount ( ) - 1 ; <nl> + const int outer_size = <nl> + MatchingFlatSizeSkipDim ( input_shape , trailing_dim , output_shape ) ; <nl> + const int depth = <nl> + MatchingDim ( input_shape , trailing_dim , output_shape , trailing_dim ) ; <nl> <nl> for ( int i = 0 ; i < outer_size ; + + i ) { <nl> / / Find max element value which we ' ll use to ensure numerical stability <nl> inline void Softmax ( const float * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Softmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + inline void Softmax ( const uint8 * input_data , const RuntimeShape & input_shape , <nl> int32 input_beta_multiplier , int32 input_beta_left_shift , <nl> int diff_min , uint8 * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> + const RuntimeShape & output_shape ) { <nl> / / The representation chosen for the input to the exp ( ) function is Q5 . 26 . <nl> / / We need to leave extra space since values that we skip might be as large as <nl> / / - 32 before multiplying by input_beta_multiplier , and therefore as large as <nl> inline void Softmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> using FixedPointAccum = gemmlowp : : FixedPoint < int32 , kAccumulationIntegerBits > ; <nl> using FixedPoint0 = gemmlowp : : FixedPoint < int32 , 0 > ; <nl> <nl> - const int outer_size = MatchingFlatSizeSkipDim ( input_dims , 0 , output_dims ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> + const int trailing_dim = input_shape . DimensionsCount ( ) - 1 ; <nl> + const int outer_size = <nl> + MatchingFlatSizeSkipDim ( input_shape , trailing_dim , output_shape ) ; <nl> + const int depth = <nl> + MatchingDim ( input_shape , trailing_dim , output_shape , trailing_dim ) ; <nl> <nl> for ( int i = 0 ; i < outer_size ; + + i ) { <nl> uint8 max_in_row = 0 ; <nl> inline void Softmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void LogSoftmax ( const float * input_data , const Dims < 4 > & input_dims , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - const int outer_size = MatchingFlatSizeSkipDim ( input_dims , 0 , output_dims ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> + inline void LogSoftmax ( const float * input_data , const RuntimeShape & input_shape , <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> + const int trailing_dim = input_shape . DimensionsCount ( ) - 1 ; <nl> + const int outer_size = <nl> + MatchingFlatSizeSkipDim ( input_shape , trailing_dim , output_shape ) ; <nl> + const int depth = <nl> + MatchingDim ( input_shape , trailing_dim , output_shape , trailing_dim ) ; <nl> <nl> for ( int i = 0 ; i < outer_size ; + + i ) { <nl> / / Find max element value which we ' ll use to ensure numerical stability <nl> log_x_for_x_greater_than_or_equal_to_1 ( <nl> input_val ) ; <nl> } <nl> <nl> - inline void LogSoftmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + inline void LogSoftmax ( const uint8 * input_data , const RuntimeShape & input_shape , <nl> int32 input_multiplier , int32 input_left_shift , <nl> int32 reverse_scaling_divisor , <nl> int32 reverse_scaling_right_shift , int diff_min , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + uint8 * output_data , const RuntimeShape & output_shape ) { <nl> / / The representation chosen for the input to the exp ( ) function is Q5 . 26 . <nl> / / We need to leave extra space since values that we skip might be as large as <nl> / / - 32 before multiplying by input_beta_multiplier , and therefore as large as <nl> inline void LogSoftmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> using FixedPointAccum = gemmlowp : : FixedPoint < int32 , kAccumulationIntegerBits > ; <nl> using FixedPoint0 = gemmlowp : : FixedPoint < int32 , 0 > ; <nl> <nl> - const int outer_size = MatchingFlatSizeSkipDim ( input_dims , 0 , output_dims ) ; <nl> - const int depth = MatchingArraySize ( input_dims , 0 , output_dims , 0 ) ; <nl> + const int trailing_dim = input_shape . DimensionsCount ( ) - 1 ; <nl> + const int outer_size = <nl> + MatchingFlatSizeSkipDim ( input_shape , trailing_dim , output_shape ) ; <nl> + const int depth = <nl> + MatchingDim ( input_shape , trailing_dim , output_shape , trailing_dim ) ; <nl> <nl> for ( int i = 0 ; i < outer_size ; + + i ) { <nl> uint8 max_in_row = 0 ; <nl> inline void LogSoftmax ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Logistic ( const float * input_data , const Dims < 4 > & input_dims , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - const int flat_size = MatchingFlatSize ( output_dims , input_dims ) ; <nl> + inline void Logistic ( const float * input_data , const RuntimeShape & input_shape , <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> for ( int i = 0 ; i < flat_size ; i + + ) { <nl> float val = input_data [ i ] ; <nl> inline void Logistic ( const float * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Logistic ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + inline void Logistic ( const uint8 * input_data , const RuntimeShape & input_shape , <nl> int32 input_zero_point , int32 input_range_radius , <nl> int32 input_multiplier , int input_left_shift , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> - const int flat_size = MatchingFlatSize ( output_dims , input_dims ) ; <nl> + uint8 * output_data , const RuntimeShape & output_shape ) { <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> for ( int i = 0 ; i < flat_size ; i + + ) { <nl> const uint8 input_val_u8 = input_data [ i ] ; <nl> inline void Logistic ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Logistic ( const int16 * input_data , const Dims < 4 > & input_dims , <nl> - int16 * output_data , const Dims < 4 > & output_dims ) { <nl> - const int flat_size = MatchingFlatSize ( output_dims , input_dims ) ; <nl> + inline void Logistic ( const int16 * input_data , const RuntimeShape & input_shape , <nl> + int16 * output_data , const RuntimeShape & output_shape ) { <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> for ( int i = 0 ; i < flat_size ; i + + ) { <nl> / / F0 uses 0 integer bits , range [ - 1 , 1 ] . <nl> inline void Logistic ( const int16 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Tanh ( const float * input_data , const Dims < 4 > & input_dims , <nl> - float * output_data , const Dims < 4 > & output_dims ) { <nl> - const int flat_size = MatchingFlatSize ( output_dims , input_dims ) ; <nl> + inline void Tanh ( const float * input_data , const RuntimeShape & input_shape , <nl> + float * output_data , const RuntimeShape & output_shape ) { <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> for ( int i = 0 ; i < flat_size ; i + + ) { <nl> float val = input_data [ i ] ; <nl> inline void Tanh ( const float * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Tanh ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> + inline void Tanh ( const uint8 * input_data , const RuntimeShape & input_shape , <nl> int32 input_zero_point , int32 input_range_radius , <nl> int32 input_multiplier , int input_left_shift , <nl> - uint8 * output_data , const Dims < 4 > & output_dims ) { <nl> + uint8 * output_data , const RuntimeShape & output_shape ) { <nl> const int32 output_zero_point = 128 ; <nl> - const int flat_size = MatchingFlatSize ( output_dims , input_dims ) ; <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> for ( int i = 0 ; i < flat_size ; i + + ) { <nl> const uint8 input_val_u8 = input_data [ i ] ; <nl> inline void Tanh ( const uint8 * input_data , const Dims < 4 > & input_dims , <nl> } <nl> } <nl> <nl> - inline void Tanh ( const int16 * input_data , const Dims < 4 > & input_dims , <nl> + inline void Tanh ( const int16 * input_data , const RuntimeShape & input_shape , <nl> int input_left_shift , int16 * output_data , <nl> - const Dims < 4 > & output_dims ) { <nl> + const RuntimeShape & output_shape ) { <nl> / / Support for shifts is limited until we have a parameterized version of <nl> / / SaturatingRoundingMultiplyByPOT ( ) . <nl> TFLITE_DCHECK_GE ( input_left_shift , 0 ) ; <nl> TFLITE_DCHECK_LE ( input_left_shift , 1 ) ; <nl> <nl> - const int flat_size = MatchingFlatSize ( output_dims , input_dims ) ; <nl> + const int flat_size = MatchingFlatSize ( input_shape , output_shape ) ; <nl> <nl> / / F0 uses 0 integer bits , range [ - 1 , 1 ] . <nl> / / This is the return type of math functions such as tanh , logistic , <nl> mmm a / tensorflow / contrib / lite / kernels / internal / softmax_quantized_test . cc <nl> ppp b / tensorflow / contrib / lite / kernels / internal / softmax_quantized_test . cc <nl> namespace tflite { <nl> namespace { <nl> <nl> void RunSoftmaxFloatReference ( const uint8 * input_data , <nl> - const Dims < 4 > & dims_common , int32 input_offset , <nl> - const double input_scale , int stride , float beta , <nl> + const RuntimeShape & shape_common , <nl> + int32 input_offset , const double input_scale , <nl> + int stride , float beta , <nl> uint8 * reference_output_data ) { <nl> - const int ref_buffer_size = RequiredBufferSizeForDims ( dims_common ) ; <nl> + const int ref_buffer_size = shape_common . FlatSize ( ) ; <nl> std : : vector < float > reference_dequant_data ( ref_buffer_size ) ; <nl> std : : vector < float > reference_output_float_data ( ref_buffer_size ) ; <nl> <nl> / / Reference data generated via Dequant of input into float , and then applying <nl> / / float Softmax . <nl> - reference_ops : : Dequantize ( input_data , dims_common , input_offset , input_scale , <nl> - reference_dequant_data . data ( ) , dims_common ) ; <nl> - optimized_ops : : Softmax ( reference_dequant_data . data ( ) , dims_common , beta , <nl> - reference_output_float_data . data ( ) , dims_common ) ; <nl> + reference_ops : : Dequantize ( <nl> + input_data , ToRuntimeDims ( shape_common ) , input_offset , input_scale , <nl> + reference_dequant_data . data ( ) , ToRuntimeDims ( shape_common ) ) ; <nl> + optimized_ops : : Softmax ( reference_dequant_data . data ( ) , shape_common , beta , <nl> + reference_output_float_data . data ( ) , shape_common ) ; <nl> / / Work with quantized scaling for Softmax , under which 256 represents 1 , but <nl> / / we limit this to 255 . <nl> for ( int i = 0 ; i < ref_buffer_size ; i + + ) { <nl> void RunSoftmaxFloatReference ( const uint8 * input_data , <nl> } <nl> <nl> void CheckOutputData ( const uint8 * test_output , const uint8 * reference_output , <nl> - const Dims < 4 > & dims_common , const string & check_label , <nl> - bool be_exacting ) { <nl> - const int buffer_size = RequiredBufferSizeForDims ( dims_common ) ; <nl> + const RuntimeShape & shape_common , <nl> + const string & check_label , bool be_exacting ) { <nl> + const int buffer_size = shape_common . FlatSize ( ) ; <nl> / / While calculating some metrics in floating point , we work with quantized <nl> / / scaling . <nl> std : : vector < int > diff ( buffer_size ) ; <nl> void CheckOutputData ( const uint8 * test_output , const uint8 * reference_output , <nl> <nl> / / Runs the Softmax and compares against the float reference implementation and <nl> / / the quantized reference implementation . <nl> - void RunOneSoftmaxTest ( const uint8 * input_data , const Dims < 4 > & dims_common , <nl> - int32 input_offset , const double input_scale , int stride , <nl> - float beta ) { <nl> - const int buffer_size = RequiredBufferSizeForDims ( dims_common ) ; <nl> + void RunOneSoftmaxTest ( const uint8 * input_data , <nl> + const RuntimeShape & shape_common , int32 input_offset , <nl> + const double input_scale , int stride , float beta ) { <nl> + const int buffer_size = shape_common . FlatSize ( ) ; <nl> std : : vector < uint8 > optimized_softmax_output ( buffer_size ) ; <nl> std : : vector < uint8 > reference_float_softmax_output ( buffer_size ) ; <nl> std : : vector < uint8 > reference_quant_softmax_output ( buffer_size ) ; <nl> <nl> - RunSoftmaxFloatReference ( input_data , dims_common , input_offset , input_scale , <nl> + RunSoftmaxFloatReference ( input_data , shape_common , input_offset , input_scale , <nl> stride , beta , reference_float_softmax_output . data ( ) ) ; <nl> <nl> int32 input_beta_multiplier ; <nl> void RunOneSoftmaxTest ( const uint8 * input_data , const Dims < 4 > & dims_common , <nl> const int diff_min = - tflite : : CalculateInputRadius ( kScaledDiffIntegerBits , <nl> input_beta_left_shift ) ; <nl> <nl> - optimized_ops : : Softmax ( input_data , dims_common , input_beta_multiplier , <nl> + optimized_ops : : Softmax ( input_data , shape_common , input_beta_multiplier , <nl> input_beta_left_shift , diff_min , <nl> - optimized_softmax_output . data ( ) , dims_common ) ; <nl> - reference_ops : : Softmax ( input_data , dims_common , input_beta_multiplier , <nl> + optimized_softmax_output . data ( ) , shape_common ) ; <nl> + reference_ops : : Softmax ( input_data , shape_common , input_beta_multiplier , <nl> input_beta_left_shift , diff_min , <nl> - reference_quant_softmax_output . data ( ) , dims_common ) ; <nl> + reference_quant_softmax_output . data ( ) , shape_common ) ; <nl> <nl> CheckOutputData ( optimized_softmax_output . data ( ) , <nl> - reference_float_softmax_output . data ( ) , dims_common , <nl> + reference_float_softmax_output . data ( ) , shape_common , <nl> " Optimized vs float reference " , false ) ; <nl> CheckOutputData ( optimized_softmax_output . data ( ) , <nl> - reference_quant_softmax_output . data ( ) , dims_common , <nl> + reference_quant_softmax_output . data ( ) , shape_common , <nl> " Optimized vs quant reference " , true ) ; <nl> CheckOutputData ( reference_quant_softmax_output . data ( ) , <nl> - reference_float_softmax_output . data ( ) , dims_common , <nl> + reference_float_softmax_output . data ( ) , shape_common , <nl> " Quant reference vs float reference " , false ) ; <nl> } <nl> <nl> bool TryOneUniformSoftmax ( ) { <nl> const int32 input_offset = UniformRandomInt ( - 256 , 0 ) ; <nl> const float beta = 1 . 0f + ExponentialRandomPositiveFloat ( 0 . 9f , 2 , 10 ) ; <nl> <nl> - Dims < 4 > dims_common = <nl> - MakeDimsForInference ( input_depth , input_width , input_height , batch ) ; <nl> - const int buffer_size = RequiredBufferSizeForDims ( dims_common ) ; <nl> + auto shape_common = <nl> + RuntimeShape ( { batch , input_height , input_width , input_depth } ) ; <nl> + const int buffer_size = shape_common . FlatSize ( ) ; <nl> <nl> std : : vector < uint8 > input_data ( buffer_size ) ; <nl> FillRandom ( & input_data ) ; <nl> - RunOneSoftmaxTest ( input_data . data ( ) , dims_common , input_offset , input_scale , <nl> + RunOneSoftmaxTest ( input_data . data ( ) , shape_common , input_offset , input_scale , <nl> stride , beta ) ; <nl> return true ; <nl> } <nl> bool TryOneSkyscraperSoftmax ( bool small_depth ) { <nl> const int middle_min = UniformRandomInt ( 0 , 255 ) ; <nl> const int sides_max = UniformRandomInt ( 0 , middle_min ) ; <nl> <nl> - Dims < 4 > dims_common = <nl> - MakeDimsForInference ( input_depth , input_width , input_height , batch ) ; <nl> - const int buffer_size = RequiredBufferSizeForDims ( dims_common ) ; <nl> + auto shape_common = <nl> + RuntimeShape ( { batch , input_height , input_width , input_depth } ) ; <nl> + const int buffer_size = shape_common . FlatSize ( ) ; <nl> <nl> std : : vector < uint8 > input_data ( buffer_size ) ; <nl> FillRandomSkyscraper ( & input_data , input_depth , middle_proportion , middle_min , <nl> sides_max ) ; <nl> - RunOneSoftmaxTest ( input_data . data ( ) , dims_common , input_offset , input_scale , <nl> + RunOneSoftmaxTest ( input_data . data ( ) , shape_common , input_offset , input_scale , <nl> stride , beta ) ; <nl> return true ; <nl> } <nl> mmm a / tensorflow / contrib / lite / kernels / internal / types . h <nl> ppp b / tensorflow / contrib / lite / kernels / internal / types . h <nl> inline int RequiredBufferSizeForDims ( const Dims < 4 > & dims ) { <nl> return FlatSize ( dims ) ; <nl> } <nl> <nl> + / / Flat size calculation , checking that dimensions match with one or more other <nl> + / / arrays . <nl> + inline int MatchingFlatSize ( const RuntimeShape & shape , <nl> + const RuntimeShape & check_shape_0 ) { <nl> + const int dims_count = shape . DimensionsCount ( ) ; <nl> + for ( int i = 0 ; i < dims_count ; + + i ) { <nl> + TFLITE_DCHECK_EQ ( shape . Dims ( i ) , check_shape_0 . Dims ( i ) ) ; <nl> + } <nl> + return shape . FlatSize ( ) ; <nl> + } <nl> + <nl> + inline int MatchingFlatSize ( const RuntimeShape & shape , <nl> + const RuntimeShape & check_shape_0 , <nl> + const RuntimeShape & check_shape_1 ) { <nl> + const int dims_count = shape . DimensionsCount ( ) ; <nl> + for ( int i = 0 ; i < dims_count ; + + i ) { <nl> + TFLITE_DCHECK_EQ ( shape . Dims ( i ) , check_shape_0 . Dims ( i ) ) ; <nl> + } <nl> + return MatchingFlatSize ( shape , check_shape_1 ) ; <nl> + } <nl> + <nl> + inline int MatchingFlatSize ( const RuntimeShape & shape , <nl> + const RuntimeShape & check_shape_0 , <nl> + const RuntimeShape & check_shape_1 , <nl> + const RuntimeShape & check_shape_2 ) { <nl> + const int dims_count = shape . DimensionsCount ( ) ; <nl> + for ( int i = 0 ; i < dims_count ; + + i ) { <nl> + TFLITE_DCHECK_EQ ( shape . Dims ( i ) , check_shape_0 . Dims ( i ) ) ; <nl> + } <nl> + return MatchingFlatSize ( shape , check_shape_1 , check_shape_2 ) ; <nl> + } <nl> + <nl> + inline int MatchingFlatSize ( const RuntimeShape & shape , <nl> + const RuntimeShape & check_shape_0 , <nl> + const RuntimeShape & check_shape_1 , <nl> + const RuntimeShape & check_shape_2 , <nl> + const RuntimeShape & check_shape_3 ) { <nl> + const int dims_count = shape . DimensionsCount ( ) ; <nl> + for ( int i = 0 ; i < dims_count ; + + i ) { <nl> + TFLITE_DCHECK_EQ ( shape . Dims ( i ) , check_shape_0 . Dims ( i ) ) ; <nl> + } <nl> + return MatchingFlatSize ( shape , check_shape_1 , check_shape_2 , check_shape_3 ) ; <nl> + } <nl> + <nl> / / Flat size calculation , checking that dimensions match with one or more other <nl> / / arrays . <nl> template < int N > <nl> inline int MatchingFlatSize ( const Dims < N > & dims , const Dims < N > & check_dims_0 , <nl> for ( int i = 0 ; i < N ; + + i ) { <nl> TFLITE_DCHECK_EQ ( ArraySize ( dims , i ) , ArraySize ( check_dims_0 , i ) ) ; <nl> } <nl> - return FlatSize ( dims , check_dims_1 , check_dims_2 ) ; <nl> + return MatchingFlatSize ( dims , check_dims_1 , check_dims_2 ) ; <nl> } <nl> <nl> template < int N > <nl> inline int MatchingFlatSize ( const Dims < N > & dims , const Dims < N > & check_dims_0 , <nl> for ( int i = 0 ; i < N ; + + i ) { <nl> TFLITE_DCHECK_EQ ( ArraySize ( dims , i ) , ArraySize ( check_dims_0 , i ) ) ; <nl> } <nl> - return FlatSize ( dims , check_dims_1 , check_dims_2 , check_dims_3 ) ; <nl> + return MatchingFlatSize ( dims , check_dims_1 , check_dims_2 , check_dims_3 ) ; <nl> } <nl> <nl> / / Data is required to be contiguous , and so many operators can use either the <nl> mmm a / tensorflow / contrib / lite / kernels / log_softmax_test . cc <nl> ppp b / tensorflow / contrib / lite / kernels / log_softmax_test . cc <nl> TEST ( LogSoftmaxOpTest , CompareWithTFmini ) { <nl> m . Invoke ( ) ; <nl> <nl> std : : unique_ptr < float [ ] > output_buffer ( new float [ input_size * batch_size ] ) ; <nl> - static tflite : : Dims < 4 > input_dims = { { input_size , 1 , 1 , batch_size } , <nl> - { 1 , 0 , 0 , input_size } } ; <nl> - tflite : : reference_ops : : LogSoftmax ( input_buffer , input_dims , <nl> - output_buffer . get ( ) , input_dims ) ; <nl> + auto input_shape = RuntimeShape ( { batch_size , 1 , 1 , input_size } ) ; <nl> + tflite : : reference_ops : : LogSoftmax ( input_buffer , input_shape , <nl> + output_buffer . get ( ) , input_shape ) ; <nl> <nl> std : : vector < float > expected ; <nl> expected . insert ( expected . end ( ) , output_buffer . get ( ) , <nl> mmm a / tensorflow / contrib / lite / kernels / pooling . cc <nl> ppp b / tensorflow / contrib / lite / kernels / pooling . cc <nl> void AverageEvalFloat ( TfLiteContext * context , TfLiteNode * node , <nl> float activation_min , activation_max ; <nl> CalculateActivationRangeFloat ( params - > activation , & activation_min , <nl> & activation_max ) ; <nl> - # define TF_LITE_AVERAGE_POOL ( type ) \ <nl> - type : : AveragePool ( \ <nl> - GetTensorData < float > ( input ) , GetTensorDims ( input ) , params - > stride_width , \ <nl> - params - > stride_height , data - > padding . width , data - > padding . height , \ <nl> - params - > filter_width , params - > filter_height , activation_min , \ <nl> - activation_max , GetTensorData < float > ( output ) , GetTensorDims ( output ) ) <nl> + # define TF_LITE_AVERAGE_POOL ( type ) \ <nl> + type : : AveragePool ( GetTensorData < float > ( input ) , GetTensorShape ( input ) , \ <nl> + params - > stride_width , params - > stride_height , \ <nl> + data - > padding . width , data - > padding . height , \ <nl> + params - > filter_width , params - > filter_height , \ <nl> + activation_min , activation_max , \ <nl> + GetTensorData < float > ( output ) , GetTensorShape ( output ) ) <nl> if ( kernel_type = = kReference ) { <nl> TF_LITE_AVERAGE_POOL ( reference_ops ) ; <nl> } else { <nl> void AverageEvalQuantized ( TfLiteContext * context , TfLiteNode * node , <nl> int32_t activation_max ; <nl> CalculateActivationRangeUint8 ( params - > activation , output , & activation_min , <nl> & activation_max ) ; <nl> - # define TF_LITE_AVERAGE_POOL ( type ) \ <nl> - type : : AveragePool ( GetTensorData < uint8_t > ( input ) , GetTensorDims ( input ) , \ <nl> - params - > stride_width , params - > stride_height , \ <nl> - data - > padding . width , data - > padding . height , \ <nl> - params - > filter_width , params - > filter_height , \ <nl> - activation_min , activation_max , \ <nl> - GetTensorData < uint8_t > ( output ) , GetTensorDims ( output ) ) <nl> + # define TF_LITE_AVERAGE_POOL ( type ) \ <nl> + type : : AveragePool ( GetTensorData < uint8_t > ( input ) , GetTensorShape ( input ) , \ <nl> + params - > stride_width , params - > stride_height , \ <nl> + data - > padding . width , data - > padding . height , \ <nl> + params - > filter_width , params - > filter_height , \ <nl> + activation_min , activation_max , \ <nl> + GetTensorData < uint8_t > ( output ) , GetTensorShape ( output ) ) <nl> if ( kernel_type = = kReference ) { <nl> TF_LITE_AVERAGE_POOL ( reference_ops ) ; <nl> } else { <nl> void MaxEvalFloat ( TfLiteContext * context , TfLiteNode * node , <nl> float activation_min , activation_max ; <nl> CalculateActivationRangeFloat ( params - > activation , & activation_min , <nl> & activation_max ) ; <nl> - # define TF_LITE_MAX_POOL ( type ) \ <nl> - type : : MaxPool ( \ <nl> - GetTensorData < float > ( input ) , GetTensorDims ( input ) , params - > stride_width , \ <nl> - params - > stride_height , data - > padding . width , data - > padding . height , \ <nl> - params - > filter_width , params - > filter_height , activation_min , \ <nl> - activation_max , GetTensorData < float > ( output ) , GetTensorDims ( output ) ) <nl> + # define TF_LITE_MAX_POOL ( type ) \ <nl> + type : : MaxPool ( GetTensorData < float > ( input ) , GetTensorShape ( input ) , \ <nl> + params - > stride_width , params - > stride_height , \ <nl> + data - > padding . width , data - > padding . height , \ <nl> + params - > filter_width , params - > filter_height , activation_min , \ <nl> + activation_max , GetTensorData < float > ( output ) , \ <nl> + GetTensorShape ( output ) ) <nl> if ( kernel_type = = kReference ) { <nl> TF_LITE_MAX_POOL ( reference_ops ) ; <nl> } else { <nl> void MaxEvalQuantized ( TfLiteContext * context , TfLiteNode * node , <nl> CalculateActivationRangeUint8 ( params - > activation , output , & activation_min , <nl> & activation_max ) ; <nl> # define TF_LITE_MAX_POOL ( type ) \ <nl> - type : : MaxPool ( GetTensorData < uint8_t > ( input ) , GetTensorDims ( input ) , \ <nl> + type : : MaxPool ( GetTensorData < uint8_t > ( input ) , GetTensorShape ( input ) , \ <nl> params - > stride_width , params - > stride_height , \ <nl> data - > padding . width , data - > padding . height , \ <nl> params - > filter_width , params - > filter_height , activation_min , \ <nl> activation_max , GetTensorData < uint8_t > ( output ) , \ <nl> - GetTensorDims ( output ) ) <nl> + GetTensorShape ( output ) ) <nl> if ( kernel_type = = kReference ) { <nl> TF_LITE_MAX_POOL ( reference_ops ) ; <nl> } else { <nl> void L2EvalFloat ( TfLiteContext * context , TfLiteNode * node , <nl> float activation_min , activation_max ; <nl> CalculateActivationRangeFloat ( params - > activation , & activation_min , <nl> & activation_max ) ; <nl> - # define TF_LITE_L2_POOL ( type ) \ <nl> - type : : L2Pool ( \ <nl> - GetTensorData < float > ( input ) , GetTensorDims ( input ) , params - > stride_width , \ <nl> - params - > stride_height , data - > padding . width , data - > padding . height , \ <nl> - params - > filter_width , params - > filter_height , activation_min , \ <nl> - activation_max , GetTensorData < float > ( output ) , GetTensorDims ( output ) ) <nl> + # define TF_LITE_L2_POOL ( type ) \ <nl> + type : : L2Pool ( GetTensorData < float > ( input ) , GetTensorShape ( input ) , \ <nl> + params - > stride_width , params - > stride_height , \ <nl> + data - > padding . width , data - > padding . height , \ <nl> + params - > filter_width , params - > filter_height , activation_min , \ <nl> + activation_max , GetTensorData < float > ( output ) , \ <nl> + GetTensorShape ( output ) ) <nl> if ( kernel_type = = kReference ) { <nl> TF_LITE_L2_POOL ( reference_ops ) ; <nl> } else { <nl> mmm a / tensorflow / contrib / lite / kernels / softmax_test . cc <nl> ppp b / tensorflow / contrib / lite / kernels / softmax_test . cc <nl> TEST ( SoftmaxOpTest , CompareWithTFminiBetaEq1 ) { <nl> m . Invoke ( ) ; <nl> <nl> std : : unique_ptr < float [ ] > output_buffer ( new float [ input_size * batch_size ] ) ; <nl> - static tflite : : Dims < 4 > input_dims = { { input_size , 1 , 1 , batch_size } , <nl> - { 1 , 0 , 0 , input_size } } ; <nl> - tflite : : reference_ops : : Softmax ( input_buffer , input_dims , beta , <nl> - output_buffer . get ( ) , input_dims ) ; <nl> + auto input_shape = RuntimeShape ( { batch_size , 1 , 1 , input_size } ) ; <nl> + tflite : : reference_ops : : Softmax ( input_buffer , input_shape , beta , <nl> + output_buffer . get ( ) , input_shape ) ; <nl> <nl> std : : vector < float > expected ; <nl> expected . insert ( expected . end ( ) , output_buffer . get ( ) , <nl> TEST ( SoftmaxOpTest , CompareWithTFminiBetaNotEq1 ) { <nl> m . Invoke ( ) ; <nl> <nl> std : : unique_ptr < float [ ] > output_buffer ( new float [ input_size * batch_size ] ) ; <nl> - static tflite : : Dims < 4 > input_dims = { { input_size , 1 , 1 , batch_size } , <nl> - { 1 , 0 , 0 , input_size } } ; <nl> - tflite : : reference_ops : : Softmax ( input_buffer , input_dims , beta , <nl> - output_buffer . get ( ) , input_dims ) ; <nl> + auto input_shape = RuntimeShape ( { batch_size , 1 , 1 , input_size } ) ; <nl> + tflite : : reference_ops : : Softmax ( input_buffer , input_shape , beta , <nl> + output_buffer . get ( ) , input_shape ) ; <nl> <nl> std : : vector < float > expected ; <nl> expected . insert ( expected . end ( ) , output_buffer . get ( ) , <nl>
|
Automated g4 rollback of changelist 201241214
|
tensorflow/tensorflow
|
35616039860ab25dde6f87b9a9e87f8727fa0daf
|
2018-06-20T20:57:53Z
|
mmm a / bitcoin - qt . pro <nl> ppp b / bitcoin - qt . pro <nl> <nl> TEMPLATE = app <nl> TARGET = <nl> - INCLUDEPATH + = src src / json src / cryptopp src / qt <nl> + INCLUDEPATH + = src src / json src / qt <nl> DEFINES + = QT_GUI <nl> CONFIG + = no_include_pwd <nl> <nl> QMAKE_LFLAGS + = - fstack - protector <nl> QMAKE_CXXFLAGS_WARN_ON = - fdiagnostics - show - option - Wall - Wno - invalid - offsetof - Wno - unused - variable - Wno - unused - parameter - Wno - sign - compare - Wno - char - subscripts - Wno - unused - value - Wno - sequence - point - Wno - parentheses - Wno - unknown - pragmas - Wno - switch <nl> <nl> # Input <nl> - DEPENDPATH + = src / qt src src / cryptopp src json / include <nl> + DEPENDPATH + = src / qt src src json / include <nl> HEADERS + = src / qt / bitcoingui . h \ <nl> src / qt / transactiontablemodel . h \ <nl> src / qt / addresstablemodel . h \ <nl> HEADERS + = src / qt / bitcoingui . h \ <nl> src / util . h \ <nl> src / uint256 . h \ <nl> src / serialize . h \ <nl> - src / cryptopp / stdcpp . h \ <nl> - src / cryptopp / smartptr . h \ <nl> - src / cryptopp / simple . h \ <nl> - src / cryptopp / sha . h \ <nl> - src / cryptopp / secblock . h \ <nl> - src / cryptopp / pch . h \ <nl> - src / cryptopp / misc . h \ <nl> - src / cryptopp / iterhash . h \ <nl> - src / cryptopp / cryptlib . h \ <nl> - src / cryptopp / cpu . h \ <nl> - src / cryptopp / config . h \ <nl> src / strlcpy . h \ <nl> src / main . h \ <nl> src / net . h \ <nl> SOURCES + = src / qt / bitcoin . cpp src / qt / bitcoingui . cpp \ <nl> src / qt / aboutdialog . cpp \ <nl> src / qt / editaddressdialog . cpp \ <nl> src / qt / bitcoinaddressvalidator . cpp \ <nl> - src / cryptopp / sha . cpp \ <nl> - src / cryptopp / cpu . cpp \ <nl> src / util . cpp \ <nl> src / script . cpp \ <nl> src / main . cpp \ <nl> mmm a / src / bitcoinrpc . cpp <nl> ppp b / src / bitcoinrpc . cpp <nl> <nl> / / file license . txt or http : / / www . opensource . org / licenses / mit - license . php . <nl> <nl> # include " headers . h " <nl> - # include " cryptopp / sha . h " <nl> # include " db . h " <nl> # include " net . h " <nl> # include " init . h " <nl> Value getwork ( const Array & params , bool fHelp ) <nl> <nl> / / Byte reverse <nl> for ( int i = 0 ; i < 128 / 4 ; i + + ) <nl> - ( ( unsigned int * ) pdata ) [ i ] = CryptoPP : : ByteReverse ( ( ( unsigned int * ) pdata ) [ i ] ) ; <nl> + ( ( unsigned int * ) pdata ) [ i ] = ByteReverse ( ( ( unsigned int * ) pdata ) [ i ] ) ; <nl> <nl> / / Get saved block <nl> if ( ! mapNewBlock . count ( pdata - > hashMerkleRoot ) ) <nl> deleted file mode 100644 <nl> index fc3f05469303 . . 000000000000 <nl> mmm a / src / cryptopp / License . txt <nl> ppp / dev / null <nl> <nl> - Compilation Copyright ( c ) 1995 - 2009 by Wei Dai . All rights reserved . <nl> - This copyright applies only to this software distribution package <nl> - as a compilation , and does not imply a copyright on any particular <nl> - file in the package . <nl> - <nl> - The following files are copyrighted by their respective original authors , <nl> - and their use is subject to additional licenses included in these files . <nl> - <nl> - mars . cpp - Copyright 1998 Brian Gladman . <nl> - <nl> - All other files in this compilation are placed in the public domain by <nl> - Wei Dai and other contributors . <nl> - <nl> - I would like to thank the following authors for placing their works into <nl> - the public domain : <nl> - <nl> - Joan Daemen - 3way . cpp <nl> - Leonard Janke - cast . cpp , seal . cpp <nl> - Steve Reid - cast . cpp <nl> - Phil Karn - des . cpp <nl> - Andrew M . Kuchling - md2 . cpp , md4 . cpp <nl> - Colin Plumb - md5 . cpp <nl> - Seal Woods - rc6 . cpp <nl> - Chris Morgan - rijndael . cpp <nl> - Paulo Baretto - rijndael . cpp , skipjack . cpp , square . cpp <nl> - Richard De Moliner - safer . cpp <nl> - Matthew Skala - twofish . cpp <nl> - Kevin Springle - camellia . cpp , shacal2 . cpp , ttmac . cpp , whrlpool . cpp , ripemd . cpp <nl> - <nl> - Permission to use , copy , modify , and distribute this compilation for <nl> - any purpose , including commercial applications , is hereby granted <nl> - without fee , subject to the following restrictions : <nl> - <nl> - 1 . Any copy or modification of this compilation in any form , except <nl> - in object code form as part of an application software , must include <nl> - the above copyright notice and this license . <nl> - <nl> - 2 . Users of this software agree that any modification or extension <nl> - they provide to Wei Dai will be considered public domain and not <nl> - copyrighted unless it includes an explicit copyright notice . <nl> - <nl> - 3 . Wei Dai makes no warranty or representation that the operation of the <nl> - software in this compilation will be error - free , and Wei Dai is under no <nl> - obligation to provide any services , by way of maintenance , update , or <nl> - otherwise . THE SOFTWARE AND ANY DOCUMENTATION ARE PROVIDED " AS IS " <nl> - WITHOUT EXPRESS OR IMPLIED WARRANTY INCLUDING , BUT NOT LIMITED TO , <nl> - THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR <nl> - PURPOSE . IN NO EVENT WILL WEI DAI OR ANY OTHER CONTRIBUTOR BE LIABLE FOR <nl> - DIRECT , INCIDENTAL OR CONSEQUENTIAL DAMAGES , EVEN IF <nl> - ADVISED OF THE POSSIBILITY OF SUCH DAMAGES . <nl> - <nl> - 4 . Users will not use Wei Dai or any other contributor ' s name in any <nl> - publicity or advertising , without prior written consent in each case . <nl> - <nl> - 5 . Export of this software from the United States may require a <nl> - specific license from the United States Government . It is the <nl> - responsibility of any person or organization contemplating export <nl> - to obtain such a license before exporting . <nl> - <nl> - 6 . Certain parts of this software may be protected by patents . It <nl> - is the users ' responsibility to obtain the appropriate <nl> - licenses before using those parts . <nl> - <nl> - If this compilation is used in object code form in an application <nl> - software , acknowledgement of the author is not required but would be <nl> - appreciated . The contribution of any useful modifications or extensions <nl> - to Wei Dai is not required but would also be appreciated . <nl> deleted file mode 100644 <nl> index 861c036c6802 . . 000000000000 <nl> mmm a / src / cryptopp / Readme . txt <nl> ppp / dev / null <nl> <nl> - Crypto + + : a C + + Class Library of Cryptographic Schemes <nl> - Version 5 . 6 . 0 ( 3 / 15 / 2009 ) <nl> - <nl> - Crypto + + Library is a free C + + class library of cryptographic schemes . <nl> - Currently the library contains the following algorithms : <nl> - <nl> - algorithm type name <nl> - <nl> - authenticated encryption schemes GCM , CCM , EAX <nl> - <nl> - high speed stream ciphers Panama , Sosemanuk , Salsa20 , XSalsa20 <nl> - <nl> - AES and AES candidates AES ( Rijndael ) , RC6 , MARS , Twofish , Serpent , <nl> - CAST - 256 <nl> - <nl> - IDEA , Triple - DES ( DES - EDE2 and DES - EDE3 ) , <nl> - other block ciphers Camellia , SEED , RC5 , Blowfish , TEA , XTEA , <nl> - Skipjack , SHACAL - 2 <nl> - <nl> - block cipher modes of operation ECB , CBC , CBC ciphertext stealing ( CTS ) , <nl> - CFB , OFB , counter mode ( CTR ) <nl> - <nl> - message authentication codes VMAC , HMAC , CMAC , CBC - MAC , DMAC , <nl> - Two - Track - MAC <nl> - <nl> - SHA - 1 , SHA - 2 ( SHA - 224 , SHA - 256 , SHA - 384 , and <nl> - hash functions SHA - 512 ) , Tiger , WHIRLPOOL , RIPEMD - 128 , <nl> - RIPEMD - 256 , RIPEMD - 160 , RIPEMD - 320 <nl> - <nl> - RSA , DSA , ElGamal , Nyberg - Rueppel ( NR ) , <nl> - public - key cryptography Rabin , Rabin - Williams ( RW ) , LUC , LUCELG , <nl> - DLIES ( variants of DHAES ) , ESIGN <nl> - <nl> - padding schemes for public - key PKCS # 1 v2 . 0 , OAEP , PSS , PSSR , IEEE P1363 <nl> - systems EMSA2 and EMSA5 <nl> - <nl> - Diffie - Hellman ( DH ) , Unified Diffie - Hellman <nl> - key agreement schemes ( DH2 ) , Menezes - Qu - Vanstone ( MQV ) , LUCDIF , <nl> - XTR - DH <nl> - <nl> - elliptic curve cryptography ECDSA , ECNR , ECIES , ECDH , ECMQV <nl> - <nl> - insecure or obsolescent MD2 , MD4 , MD5 , Panama Hash , DES , ARC4 , SEAL <nl> - algorithms retained for backwards 3 . 0 , WAKE , WAKE - OFB , DESX ( DES - XEX3 ) , RC2 , <nl> - compatibility and historical SAFER , 3 - WAY , GOST , SHARK , CAST - 128 , Square <nl> - value <nl> - <nl> - Other features include : <nl> - <nl> - * pseudo random number generators ( PRNG ) : ANSI X9 . 17 appendix C , RandomPool <nl> - * password based key derivation functions : PBKDF1 and PBKDF2 from PKCS # 5 , <nl> - PBKDF from PKCS # 12 appendix B <nl> - * Shamir ' s secret sharing scheme and Rabin ' s information dispersal algorithm <nl> - ( IDA ) <nl> - * fast multi - precision integer ( bignum ) and polynomial operations <nl> - * finite field arithmetics , including GF ( p ) and GF ( 2 ^ n ) <nl> - * prime number generation and verification <nl> - * useful non - cryptographic algorithms <nl> - + DEFLATE ( RFC 1951 ) compression / decompression with gzip ( RFC 1952 ) and <nl> - zlib ( RFC 1950 ) format support <nl> - + hex , base - 32 , and base - 64 coding / decoding <nl> - + 32 - bit CRC and Adler32 checksum <nl> - * class wrappers for these operating system features ( optional ) : <nl> - + high resolution timers on Windows , Unix , and Mac OS <nl> - + Berkeley and Windows style sockets <nl> - + Windows named pipes <nl> - + / dev / random , / dev / urandom , / dev / srandom <nl> - + Microsoft ' s CryptGenRandom on Windows <nl> - * A high level interface for most of the above , using a filter / pipeline <nl> - metaphor <nl> - * benchmarks and validation testing <nl> - * x86 , x86 - 64 ( x64 ) , MMX , and SSE2 assembly code for the most commonly used <nl> - algorithms , with run - time CPU feature detection and code selection <nl> - * some versions are available in FIPS 140 - 2 validated form <nl> - <nl> - You are welcome to use it for any purpose without paying me , but see <nl> - License . txt for the fine print . <nl> - <nl> - The following compilers are supported for this release . Please visit <nl> - http : / / www . cryptopp . com the most up to date build instructions and porting notes . <nl> - <nl> - * MSVC 6 . 0 - 2008 <nl> - * GCC 3 . 3 - 4 . 3 <nl> - * C + + Builder 2009 <nl> - * Intel C + + Compiler 9 - 11 <nl> - * Sun Studio 12 ( CC 5 . 9 ) <nl> - <nl> - * * * Important Usage Notes * * * <nl> - <nl> - 1 . If a constructor for A takes a pointer to an object B ( except primitive <nl> - types such as int and char ) , then A owns B and will delete B at A ' s <nl> - destruction . If a constructor for A takes a reference to an object B , <nl> - then the caller retains ownership of B and should not destroy it until <nl> - A no longer needs it . <nl> - <nl> - 2 . Crypto + + is thread safe at the class level . This means you can use <nl> - Crypto + + safely in a multithreaded application , but you must provide <nl> - synchronization when multiple threads access a common Crypto + + object . <nl> - <nl> - * * * MSVC - Specific Information * * * <nl> - <nl> - On Windows , Crypto + + can be compiled into 3 forms : a static library <nl> - including all algorithms , a DLL with only FIPS Approved algorithms , and <nl> - a static library with only algorithms not in the DLL . <nl> - ( FIPS Approved means Approved according to the FIPS 140 - 2 standard . ) <nl> - The DLL may be used by itself , or it may be used together with the second <nl> - form of the static library . MSVC project files are included to build <nl> - all three forms , and sample applications using each of the three forms <nl> - are also included . <nl> - <nl> - To compile Crypto + + with MSVC , open the " cryptest . dsw " ( for MSVC 6 and MSVC . NET <nl> - 2003 ) or " cryptest . sln " ( for MSVC . NET 2005 ) workspace file and build one or <nl> - more of the following projects : <nl> - <nl> - cryptdll - This builds the DLL . Please note that if you wish to use Crypto + + <nl> - as a FIPS validated module , you must use a pre - built DLL that has undergone <nl> - the FIPS validation process instead of building your own . <nl> - dlltest - This builds a sample application that only uses the DLL . <nl> - cryptest Non - DLL - Import Configuration - This builds the full static library <nl> - along with a full test driver . <nl> - cryptest DLL - Import Configuration - This builds a static library containing <nl> - only algorithms not in the DLL , along with a full test driver that uses <nl> - both the DLL and the static library . <nl> - <nl> - To use the Crypto + + DLL in your application , # include " dll . h " before including <nl> - any other Crypto + + header files , and place the DLL in the same directory as <nl> - your . exe file . dll . h includes the line # pragma comment ( lib , " cryptopp " ) <nl> - so you don ' t have to explicitly list the import library in your project <nl> - settings . To use a static library form of Crypto + + , specify it as <nl> - an additional library to link with in your project settings . <nl> - In either case you should check the compiler options to <nl> - make sure that the library and your application are using the same C + + <nl> - run - time libraries and calling conventions . <nl> - <nl> - * * * DLL Memory Management * * * <nl> - <nl> - Because it ' s possible for the Crypto + + DLL to delete objects allocated <nl> - by the calling application , they must use the same C + + memory heap . Three <nl> - methods are provided to achieve this . <nl> - 1 . The calling application can tell Crypto + + what heap to use . This method <nl> - is required when the calling application uses a non - standard heap . <nl> - 2 . Crypto + + can tell the calling application what heap to use . This method <nl> - is required when the calling application uses a statically linked C + + Run <nl> - Time Library . ( Method 1 does not work in this case because the Crypto + + DLL <nl> - is initialized before the calling application ' s heap is initialized . ) <nl> - 3 . Crypto + + can automatically use the heap provided by the calling application ' s <nl> - dynamically linked C + + Run Time Library . The calling application must <nl> - make sure that the dynamically linked C + + Run Time Library is initialized <nl> - before Crypto + + is loaded . ( At this time it is not clear if it is possible <nl> - to control the order in which DLLs are initialized on Windows 9x machines , <nl> - so it might be best to avoid using this method . ) <nl> - <nl> - When Crypto + + attaches to a new process , it searches all modules loaded <nl> - into the process space for exported functions " GetNewAndDeleteForCryptoPP " <nl> - and " SetNewAndDeleteFromCryptoPP " . If one of these functions is found , <nl> - Crypto + + uses methods 1 or 2 , respectively , by calling the function . <nl> - Otherwise , method 3 is used . <nl> - <nl> - * * * GCC - Specific Information * * * <nl> - <nl> - A makefile is included for you to compile Crypto + + with GCC . Make sure <nl> - you are using GNU Make and GNU ld . The make process will produce two files , <nl> - libcryptopp . a and cryptest . exe . Run " cryptest . exe v " for the validation <nl> - suite . <nl> - <nl> - * * * Documentation and Support * * * <nl> - <nl> - Crypto + + is documented through inline comments in header files , which are <nl> - processed through Doxygen to produce an HTML reference manual . You can find <nl> - a link to the manual from http : / / www . cryptopp . com . Also at that site is <nl> - the Crypto + + FAQ , which you should browse through before attempting to <nl> - use this library , because it will likely answer many of questions that <nl> - may come up . <nl> - <nl> - If you run into any problems , please try the Crypto + + mailing list . <nl> - The subscription information and the list archive are available on <nl> - http : / / www . cryptopp . com . You can also email me directly by visiting <nl> - http : / / www . weidai . com , but you will probably get a faster response through <nl> - the mailing list . <nl> - <nl> - * * * History * * * <nl> - <nl> - 1 . 0 - First public release . Withdrawn at the request of RSA DSI . <nl> - - included Blowfish , BBS , DES , DH , Diamond , DSA , ElGamal , IDEA , <nl> - MD5 , RC4 , RC5 , RSA , SHA , WAKE , secret sharing , DEFLATE compression <nl> - - had a serious bug in the RSA key generation code . <nl> - <nl> - 1 . 1 - Removed RSA , RC4 , RC5 <nl> - - Disabled calls to RSAREF ' s non - public functions <nl> - - Minor bugs fixed <nl> - <nl> - 2 . 0 - a completely new , faster multiprecision integer class <nl> - - added MD5 - MAC , HAVAL , 3 - WAY , TEA , SAFER , LUC , Rabin , BlumGoldwasser , <nl> - elliptic curve algorithms <nl> - - added the Lucas strong probable primality test <nl> - - ElGamal encryption and signature schemes modified to avoid weaknesses <nl> - - Diamond changed to Diamond2 because of key schedule weakness <nl> - - fixed bug in WAKE key setup <nl> - - SHS class renamed to SHA <nl> - - lots of miscellaneous optimizations <nl> - <nl> - 2 . 1 - added Tiger , HMAC , GOST , RIPE - MD160 , LUCELG , LUCDIF , XOR - MAC , <nl> - OAEP , PSSR , SHARK <nl> - - added precomputation to DH , ElGamal , DSA , and elliptic curve algorithms <nl> - - added back RC5 and a new RSA <nl> - - optimizations in elliptic curves over GF ( p ) <nl> - - changed Rabin to use OAEP and PSSR <nl> - - changed many classes to allow copy constructors to work correctly <nl> - - improved exception generation and handling <nl> - <nl> - 2 . 2 - added SEAL , CAST - 128 , Square <nl> - - fixed bug in HAVAL ( padding problem ) <nl> - - fixed bug in triple - DES ( decryption order was reversed ) <nl> - - fixed bug in RC5 ( couldn ' t handle key length not a multiple of 4 ) <nl> - - changed HMAC to conform to RFC - 2104 ( which is not compatible <nl> - with the original HMAC ) <nl> - - changed secret sharing and information dispersal to use GF ( 2 ^ 32 ) <nl> - instead of GF ( 65521 ) <nl> - - removed zero knowledge prover / verifier for graph isomorphism <nl> - - removed several utility classes in favor of the C + + standard library <nl> - <nl> - 2 . 3 - ported to EGCS <nl> - - fixed incomplete workaround of min / max conflict in MSVC <nl> - <nl> - 3 . 0 - placed all names into the " CryptoPP " namespace <nl> - - added MD2 , RC2 , RC6 , MARS , RW , DH2 , MQV , ECDHC , CBC - CTS <nl> - - added abstract base classes PK_SimpleKeyAgreementDomain and <nl> - PK_AuthenticatedKeyAgreementDomain <nl> - - changed DH and LUCDIF to implement the PK_SimpleKeyAgreementDomain <nl> - interface and to perform domain parameter and key validation <nl> - - changed interfaces of PK_Signer and PK_Verifier to sign and verify <nl> - messages instead of message digests <nl> - - changed OAEP to conform to PKCS # 1 v2 . 0 <nl> - - changed benchmark code to produce HTML tables as output <nl> - - changed PSSR to track IEEE P1363a <nl> - - renamed ElGamalSignature to NR and changed it to track IEEE P1363 <nl> - - renamed ECKEP to ECMQVC and changed it to track IEEE P1363 <nl> - - renamed several other classes for clarity <nl> - - removed support for calling RSAREF <nl> - - removed option to compile old SHA ( SHA - 0 ) <nl> - - removed option not to throw exceptions <nl> - <nl> - 3 . 1 - added ARC4 , Rijndael , Twofish , Serpent , CBC - MAC , DMAC <nl> - - added interface for querying supported key lengths of symmetric ciphers <nl> - and MACs <nl> - - added sample code for RSA signature and verification <nl> - - changed CBC - CTS to be compatible with RFC 2040 <nl> - - updated SEAL to version 3 . 0 of the cipher specification <nl> - - optimized multiprecision squaring and elliptic curves over GF ( p ) <nl> - - fixed bug in MARS key setup <nl> - - fixed bug with attaching objects to Deflator <nl> - <nl> - 3 . 2 - added DES - XEX3 , ECDSA , DefaultEncryptorWithMAC <nl> - - renamed DES - EDE to DES - EDE2 and TripleDES to DES - EDE3 <nl> - - optimized ARC4 <nl> - - generalized DSA to allow keys longer than 1024 bits <nl> - - fixed bugs in GF2N and ModularArithmetic that can cause calculation errors <nl> - - fixed crashing bug in Inflator when given invalid inputs <nl> - - fixed endian bug in Serpent <nl> - - fixed padding bug in Tiger <nl> - <nl> - 4 . 0 - added Skipjack , CAST - 256 , Panama , SHA - 2 ( SHA - 256 , SHA - 384 , and SHA - 512 ) , <nl> - and XTR - DH <nl> - - added a faster variant of Rabin ' s Information Dispersal Algorithm ( IDA ) <nl> - - added class wrappers for these operating system features : <nl> - - high resolution timers on Windows , Unix , and MacOS <nl> - - Berkeley and Windows style sockets <nl> - - Windows named pipes <nl> - - / dev / random and / dev / urandom on Linux and FreeBSD <nl> - - Microsoft ' s CryptGenRandom on Windows <nl> - - added support for SEC 1 elliptic curve key format and compressed points <nl> - - added support for X . 509 public key format ( subjectPublicKeyInfo ) for <nl> - RSA , DSA , and elliptic curve schemes <nl> - - added support for DER and OpenPGP signature format for DSA <nl> - - added support for ZLIB compressed data format ( RFC 1950 ) <nl> - - changed elliptic curve encryption to use ECIES ( as defined in SEC 1 ) <nl> - - changed MARS key schedule to reflect the latest specification <nl> - - changed BufferedTransformation interface to support multiple channels <nl> - and messages <nl> - - changed CAST and SHA - 1 implementations to use public domain source code <nl> - - fixed bug in StringSource <nl> - - optmized multi - precision integer code for better performance <nl> - <nl> - 4 . 1 - added more support for the recommended elliptic curve parameters in SEC 2 <nl> - - added Panama MAC , MARC4 <nl> - - added IV stealing feature to CTS mode <nl> - - added support for PKCS # 8 private key format for RSA , DSA , and elliptic <nl> - curve schemes <nl> - - changed Deflate , MD5 , Rijndael , and Twofish to use public domain code <nl> - - fixed a bug with flushing compressed streams <nl> - - fixed a bug with decompressing stored blocks <nl> - - fixed a bug with EC point decompression using non - trinomial basis <nl> - - fixed a bug in NetworkSource : : GeneralPump ( ) <nl> - - fixed a performance issue with EC over GF ( p ) decryption <nl> - - fixed syntax to allow GCC to compile without - fpermissive <nl> - - relaxed some restrictions in the license <nl> - <nl> - 4 . 2 - added support for longer HMAC keys <nl> - - added MD4 ( which is not secure so use for compatibility purposes only ) <nl> - - added compatibility fixes / workarounds for STLport 4 . 5 , GCC 3 . 0 . 2 , <nl> - and MSVC 7 . 0 <nl> - - changed MD2 to use public domain code <nl> - - fixed a bug with decompressing multiple messages with the same object <nl> - - fixed a bug in CBC - MAC with MACing multiple messages with the same object <nl> - - fixed a bug in RC5 and RC6 with zero - length keys <nl> - - fixed a bug in Adler32 where incorrect checksum may be generated <nl> - <nl> - 5 . 0 - added ESIGN , DLIES , WAKE - OFB , PBKDF1 and PBKDF2 from PKCS # 5 <nl> - - added key validation for encryption and signature public / private keys <nl> - - renamed StreamCipher interface to SymmetricCipher , which is now implemented <nl> - by both stream ciphers and block cipher modes including ECB and CBC <nl> - - added keying interfaces to support resetting of keys and IVs without <nl> - having to destroy and recreate objects <nl> - - changed filter interface to support non - blocking input / output <nl> - - changed SocketSource and SocketSink to use overlapped I / O on Microsoft Windows <nl> - - grouped related classes inside structs to help templates , for example <nl> - AESEncryption and AESDecryption are now AES : : Encryption and AES : : Decryption <nl> - - where possible , typedefs have been added to improve backwards <nl> - compatibility when the CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY macro is defined <nl> - - changed Serpent , HAVAL and IDEA to use public domain code <nl> - - implemented SSE2 optimizations for Integer operations <nl> - - fixed a bug in HMAC : : TruncatedFinal ( ) <nl> - - fixed SKIPJACK byte ordering following NIST clarification dated 5 / 9 / 02 <nl> - <nl> - 5 . 01 - added known answer test for X9 . 17 RNG in FIPS 140 power - up self test <nl> - - submitted to NIST / CSE , but not publicly released <nl> - <nl> - 5 . 02 - changed EDC test to MAC integrity check using HMAC / SHA1 <nl> - - improved performance of integrity check <nl> - - added blinding to defend against RSA timing attack <nl> - <nl> - 5 . 03 - created DLL version of Crypto + + for FIPS 140 - 2 validation <nl> - - fixed vulnerabilities in GetNextIV for CTR and OFB modes <nl> - <nl> - 5 . 0 . 4 - Removed DES , SHA - 256 , SHA - 384 , SHA - 512 from DLL <nl> - <nl> - 5 . 1 - added PSS padding and changed PSSR to track IEEE P1363a draft standard <nl> - - added blinding for RSA and Rabin to defend against timing attacks <nl> - on decryption operations <nl> - - changed signing and decryption APIs to support the above <nl> - - changed WaitObjectContainer to allow waiting for more than 64 <nl> - objects at a time on Win32 platforms <nl> - - fixed a bug in CBC and ECB modes with processing non - aligned data <nl> - - fixed standard conformance bugs in DLIES ( DHAES mode ) and RW / EMSA2 <nl> - signature scheme ( these fixes are not backwards compatible ) <nl> - - fixed a number of compiler warnings , minor bugs , and portability problems <nl> - - removed Sapphire <nl> - <nl> - 5 . 2 - merged in changes for 5 . 01 - 5 . 0 . 4 <nl> - - added support for using encoding parameters and key derivation parameters <nl> - with public key encryption ( implemented by OAEP and DL / ECIES ) <nl> - - added Camellia , SHACAL - 2 , Two - Track - MAC , Whirlpool , RIPEMD - 320 , <nl> - RIPEMD - 128 , RIPEMD - 256 , Base - 32 coding , FIPS variant of CFB mode <nl> - - added ThreadUserTimer for timing thread CPU usage <nl> - - added option for password - based key derivation functions <nl> - to iterate until a mimimum elapsed thread CPU time is reached <nl> - - added option ( on by default ) for DEFLATE compression to detect <nl> - uncompressible files and process them more quickly <nl> - - improved compatibility and performance on 64 - bit platforms , <nl> - including Alpha , IA - 64 , x86 - 64 , PPC64 , Sparc64 , and MIPS64 <nl> - - fixed ONE_AND_ZEROS_PADDING to use 0x80 instead 0x01 as padding . <nl> - - fixed encoding / decoding of PKCS # 8 privateKeyInfo to properly <nl> - handle optional attributes <nl> - <nl> - 5 . 2 . 1 - fixed bug in the " dlltest " DLL testing program <nl> - - fixed compiling with STLport using VC . NET <nl> - - fixed compiling with - fPIC using GCC <nl> - - fixed compiling with - msse2 on systems without memalign ( ) <nl> - - fixed inability to instantiate PanamaMAC <nl> - - fixed problems with inline documentation <nl> - <nl> - 5 . 2 . 2 - added SHA - 224 <nl> - - put SHA - 256 , SHA - 384 , SHA - 512 , RSASSA - PSS into DLL <nl> - <nl> - 5 . 2 . 3 - fixed issues with FIPS algorithm test vectors <nl> - - put RSASSA - ISO into DLL <nl> - <nl> - 5 . 3 - ported to MSVC 2005 with support for x86 - 64 <nl> - - added defense against AES timing attacks , and more AES test vectors <nl> - - changed StaticAlgorithmName ( ) of Rijndael to " AES " , CTR to " CTR " <nl> - <nl> - 5 . 4 - added Salsa20 <nl> - - updated Whirlpool to version 3 . 0 <nl> - - ported to GCC 4 . 1 , Sun C + + 5 . 8 , and Borland C + + Builder 2006 <nl> - <nl> - 5 . 5 - added VMAC and Sosemanuk ( with x86 - 64 and SSE2 assembly ) <nl> - - improved speed of integer arithmetic , AES , SHA - 512 , Tiger , Salsa20 , <nl> - Whirlpool , and PANAMA cipher using assembly ( x86 - 64 , MMX , SSE2 ) <nl> - - optimized Camellia and added defense against timing attacks <nl> - - updated benchmarks code to show cycles per byte and to time key / IV setup <nl> - - started using OpenMP for increased multi - core speed <nl> - - enabled GCC optimization flags by default in GNUmakefile <nl> - - added blinding and computational error checking for RW signing <nl> - - changed RandomPool , X917RNG , GetNextIV , DSA / NR / ECDSA / ECNR to reduce <nl> - the risk of reusing random numbers and IVs after virtual machine state <nl> - rollback <nl> - - changed default FIPS mode RNG from AutoSeededX917RNG < DES_EDE3 > to <nl> - AutoSeededX917RNG < AES > <nl> - - fixed PANAMA cipher interface to accept 256 - bit key and 256 - bit IV <nl> - - moved MD2 , MD4 , MD5 , PanamaHash , ARC4 , WAKE_CFB into the namespace " Weak " <nl> - - removed HAVAL , MD5 - MAC , XMAC <nl> - <nl> - 5 . 5 . 1 - fixed VMAC validation failure on 32 - bit big - endian machines <nl> - <nl> - 5 . 5 . 2 - ported x64 assembly language code for AES , Salsa20 , Sosemanuk , and Panama <nl> - to MSVC 2005 ( using MASM since MSVC doesn ' t support inline assembly on x64 ) <nl> - - fixed Salsa20 initialization crash on non - SSE2 machines <nl> - - fixed Whirlpool crash on Pentium 2 machines <nl> - - fixed possible branch prediction analysis ( BPA ) vulnerability in <nl> - MontgomeryReduce ( ) , which may affect security of RSA , RW , LUC <nl> - - fixed link error with MSVC 2003 when using " debug DLL " form of runtime library <nl> - - fixed crash in SSE2_Add on P4 machines when compiled with <nl> - MSVC 6 . 0 SP5 with Processor Pack <nl> - - ported to MSVC 2008 , GCC 4 . 2 , Sun CC 5 . 9 , Intel C + + Compiler 10 . 0 , <nl> - and Borland C + + Builder 2007 <nl> - <nl> - 5 . 6 - added AuthenticatedSymmetricCipher interface class and Filter wrappers <nl> - - added CCM , GCM ( with SSE2 assembly ) , EAX , CMAC , XSalsa20 , and SEED <nl> - - added support for variable length IVs <nl> - - improved AES and SHA - 256 speed on x86 and x64 <nl> - - fixed incorrect VMAC computation on message lengths <nl> - that are > 64 mod 128 ( x86 assembly version is not affected ) <nl> - - fixed compiler error in vmac . cpp on x86 with GCC - fPIC <nl> - - fixed run - time validation error on x86 - 64 with GCC 4 . 3 . 2 - O2 <nl> - - fixed HashFilter bug when putMessage = true <nl> - - removed WORD64_AVAILABLE ; compiler support for 64 - bit int is now required <nl> - - ported to GCC 4 . 3 , C + + Builder 2009 , Sun CC 5 . 10 , Intel C + + Compiler 11 <nl> - <nl> - Written by Wei Dai <nl> deleted file mode 100644 <nl> index 0737027f41f3 . . 000000000000 <nl> mmm a / src / cryptopp / config . h <nl> ppp / dev / null <nl> <nl> - # ifndef CRYPTOPP_CONFIG_H <nl> - # define CRYPTOPP_CONFIG_H <nl> - <nl> - / / / / Bitcoin : disable SSE2 on 32 - bit <nl> - # if ! defined ( _M_X64 ) & & ! defined ( __x86_64__ ) <nl> - # define CRYPTOPP_DISABLE_SSE2 1 <nl> - # endif <nl> - / / / / / / / / / / / / end of Bitcoin changes <nl> - <nl> - <nl> - / / * * * * * * * * * * * * * * * * * Important Settings * * * * * * * * * * * * * * * * * * * * <nl> - <nl> - / / define this if running on a big - endian CPU <nl> - # if ! defined ( IS_LITTLE_ENDIAN ) & & ( defined ( __BIG_ENDIAN__ ) | | defined ( __sparc ) | | defined ( __sparc__ ) | | defined ( __hppa__ ) | | defined ( __mips__ ) | | ( defined ( __MWERKS__ ) & & ! defined ( __INTEL__ ) ) ) <nl> - # define IS_BIG_ENDIAN <nl> - # endif <nl> - <nl> - / / define this if running on a little - endian CPU <nl> - / / big endian will be assumed if IS_LITTLE_ENDIAN is not defined <nl> - # ifndef IS_BIG_ENDIAN <nl> - # define IS_LITTLE_ENDIAN <nl> - # endif <nl> - <nl> - / / define this if you want to disable all OS - dependent features , <nl> - / / such as sockets and OS - provided random number generators <nl> - / / # define NO_OS_DEPENDENCE <nl> - <nl> - / / Define this to use features provided by Microsoft ' s CryptoAPI . <nl> - / / Currently the only feature used is random number generation . <nl> - / / This macro will be ignored if NO_OS_DEPENDENCE is defined . <nl> - # define USE_MS_CRYPTOAPI <nl> - <nl> - / / Define this to 1 to enforce the requirement in FIPS 186 - 2 Change Notice 1 that only 1024 bit moduli be used <nl> - # ifndef DSA_1024_BIT_MODULUS_ONLY <nl> - # define DSA_1024_BIT_MODULUS_ONLY 1 <nl> - # endif <nl> - <nl> - / / * * * * * * * * * * * * * * * * * Less Important Settings * * * * * * * * * * * * * * * <nl> - <nl> - / / define this to retain ( as much as possible ) old deprecated function and class names <nl> - / / # define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - <nl> - # define GZIP_OS_CODE 0 <nl> - <nl> - / / Try this if your CPU has 256K internal cache or a slow multiply instruction <nl> - / / and you want a ( possibly ) faster IDEA implementation using log tables <nl> - / / # define IDEA_LARGECACHE <nl> - <nl> - / / Define this if , for the linear congruential RNG , you want to use <nl> - / / the original constants as specified in S . K . Park and K . W . Miller ' s <nl> - / / CACM paper . <nl> - / / # define LCRNG_ORIGINAL_NUMBERS <nl> - <nl> - / / choose which style of sockets to wrap ( mostly useful for cygwin which has both ) <nl> - # define PREFER_BERKELEY_STYLE_SOCKETS <nl> - / / # define PREFER_WINDOWS_STYLE_SOCKETS <nl> - <nl> - / / set the name of Rijndael cipher , was " Rijndael " before version 5 . 3 <nl> - # define CRYPTOPP_RIJNDAEL_NAME " AES " <nl> - <nl> - / / * * * * * * * * * * * * * * * * * Important Settings Again * * * * * * * * * * * * * * * * * * * * <nl> - / / But the defaults should be ok . <nl> - <nl> - / / namespace support is now required <nl> - # ifdef NO_NAMESPACE <nl> - # error namespace support is now required <nl> - # endif <nl> - <nl> - / / Define this to workaround a Microsoft CryptoAPI bug where <nl> - / / each call to CryptAcquireContext causes a 100 KB memory leak . <nl> - / / Defining this will cause Crypto + + to make only one call to CryptAcquireContext . <nl> - # define WORKAROUND_MS_BUG_Q258000 <nl> - <nl> - # ifdef CRYPTOPP_DOXYGEN_PROCESSING <nl> - / / Avoid putting " CryptoPP : : " in front of everything in Doxygen output <nl> - # define CryptoPP <nl> - # define NAMESPACE_BEGIN ( x ) <nl> - # define NAMESPACE_END <nl> - / / Get Doxygen to generate better documentation for these typedefs <nl> - # define DOCUMENTED_TYPEDEF ( x , y ) class y : public x { } ; <nl> - # else <nl> - # define NAMESPACE_BEGIN ( x ) namespace x { <nl> - # define NAMESPACE_END } <nl> - # define DOCUMENTED_TYPEDEF ( x , y ) typedef x y ; <nl> - # endif <nl> - # define ANONYMOUS_NAMESPACE_BEGIN namespace { <nl> - # define USING_NAMESPACE ( x ) using namespace x ; <nl> - # define DOCUMENTED_NAMESPACE_BEGIN ( x ) namespace x { <nl> - # define DOCUMENTED_NAMESPACE_END } <nl> - <nl> - / / What is the type of the third parameter to bind ? <nl> - / / For Unix , the new standard is : : socklen_t ( typically unsigned int ) , and the old standard is int . <nl> - / / Unfortunately there is no way to tell whether or not socklen_t is defined . <nl> - / / To work around this , TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile . <nl> - # ifndef TYPE_OF_SOCKLEN_T <nl> - # if defined ( _WIN32 ) | | defined ( __CYGWIN__ ) <nl> - # define TYPE_OF_SOCKLEN_T int <nl> - # else <nl> - # define TYPE_OF_SOCKLEN_T : : socklen_t <nl> - # endif <nl> - # endif <nl> - <nl> - # if defined ( __CYGWIN__ ) & & defined ( PREFER_WINDOWS_STYLE_SOCKETS ) <nl> - # define __USE_W32_SOCKETS <nl> - # endif <nl> - <nl> - typedef unsigned char byte ; / / put in global namespace to avoid ambiguity with other byte typedefs <nl> - <nl> - NAMESPACE_BEGIN ( CryptoPP ) <nl> - <nl> - typedef unsigned short word16 ; <nl> - typedef unsigned int word32 ; <nl> - <nl> - # if defined ( _MSC_VER ) | | defined ( __BORLANDC__ ) <nl> - typedef unsigned __int64 word64 ; <nl> - # define W64LIT ( x ) x # # ui64 <nl> - # else <nl> - typedef unsigned long long word64 ; <nl> - # define W64LIT ( x ) x # # ULL <nl> - # endif <nl> - <nl> - / / define large word type , used for file offsets and such <nl> - typedef word64 lword ; <nl> - const lword LWORD_MAX = W64LIT ( 0xffffffffffffffff ) ; <nl> - <nl> - # ifdef __GNUC__ <nl> - # define CRYPTOPP_GCC_VERSION ( __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ ) <nl> - # endif <nl> - <nl> - / / define hword , word , and dword . these are used for multiprecision integer arithmetic <nl> - / / Intel compiler won ' t have _umul128 until version 10 . 0 . See http : / / softwarecommunity . intel . com / isn / Community / en - US / forums / thread / 30231625 . aspx <nl> - # if ( defined ( _MSC_VER ) & & ( ! defined ( __INTEL_COMPILER ) | | __INTEL_COMPILER > = 1000 ) & & ( defined ( _M_X64 ) | | defined ( _M_IA64 ) ) ) | | ( defined ( __DECCXX ) & & defined ( __alpha__ ) ) | | ( defined ( __INTEL_COMPILER ) & & defined ( __x86_64__ ) ) | | ( defined ( __SUNPRO_CC ) & & defined ( __x86_64__ ) ) <nl> - typedef word32 hword ; <nl> - typedef word64 word ; <nl> - # else <nl> - # define CRYPTOPP_NATIVE_DWORD_AVAILABLE <nl> - # if defined ( __alpha__ ) | | defined ( __ia64__ ) | | defined ( _ARCH_PPC64 ) | | defined ( __x86_64__ ) | | defined ( __mips64 ) | | defined ( __sparc64__ ) <nl> - # if defined ( __GNUC__ ) & & ! defined ( __INTEL_COMPILER ) & & ! ( CRYPTOPP_GCC_VERSION = = 40001 & & defined ( __APPLE__ ) ) & & CRYPTOPP_GCC_VERSION > = 30400 <nl> - / / GCC 4 . 0 . 1 on MacOS X is missing __umodti3 and __udivti3 <nl> - / / mode ( TI ) division broken on amd64 with GCC earlier than GCC 3 . 4 <nl> - typedef word32 hword ; <nl> - typedef word64 word ; <nl> - typedef __uint128_t dword ; <nl> - typedef __uint128_t word128 ; <nl> - # define CRYPTOPP_WORD128_AVAILABLE <nl> - # else <nl> - / / if we ' re here , it means we ' re on a 64 - bit CPU but we don ' t have a way to obtain 128 - bit multiplication results <nl> - typedef word16 hword ; <nl> - typedef word32 word ; <nl> - typedef word64 dword ; <nl> - # endif <nl> - # else <nl> - / / being here means the native register size is probably 32 bits or less <nl> - # define CRYPTOPP_BOOL_SLOW_WORD64 1 <nl> - typedef word16 hword ; <nl> - typedef word32 word ; <nl> - typedef word64 dword ; <nl> - # endif <nl> - # endif <nl> - # ifndef CRYPTOPP_BOOL_SLOW_WORD64 <nl> - # define CRYPTOPP_BOOL_SLOW_WORD64 0 <nl> - # endif <nl> - <nl> - const unsigned int WORD_SIZE = sizeof ( word ) ; <nl> - const unsigned int WORD_BITS = WORD_SIZE * 8 ; <nl> - <nl> - NAMESPACE_END <nl> - <nl> - # ifndef CRYPTOPP_L1_CACHE_LINE_SIZE <nl> - / / This should be a lower bound on the L1 cache line size . It ' s used for defense against timing attacks . <nl> - # if defined ( _M_X64 ) | | defined ( __x86_64__ ) <nl> - # define CRYPTOPP_L1_CACHE_LINE_SIZE 64 <nl> - # else <nl> - / / L1 cache line size is 32 on Pentium III and earlier <nl> - # define CRYPTOPP_L1_CACHE_LINE_SIZE 32 <nl> - # endif <nl> - # endif <nl> - <nl> - # if defined ( _MSC_VER ) <nl> - # if _MSC_VER = = 1200 <nl> - # include < malloc . h > <nl> - # endif <nl> - # if _MSC_VER > 1200 | | defined ( _mm_free ) <nl> - # define CRYPTOPP_MSVC6PP_OR_LATER / / VC 6 processor pack or later <nl> - # else <nl> - # define CRYPTOPP_MSVC6_NO_PP / / VC 6 without processor pack <nl> - # endif <nl> - # endif <nl> - <nl> - # ifndef CRYPTOPP_ALIGN_DATA <nl> - # if defined ( CRYPTOPP_MSVC6PP_OR_LATER ) <nl> - # define CRYPTOPP_ALIGN_DATA ( x ) __declspec ( align ( x ) ) <nl> - # elif defined ( __GNUC__ ) <nl> - # define CRYPTOPP_ALIGN_DATA ( x ) __attribute__ ( ( aligned ( x ) ) ) <nl> - # else <nl> - # define CRYPTOPP_ALIGN_DATA ( x ) <nl> - # endif <nl> - # endif <nl> - <nl> - # ifndef CRYPTOPP_SECTION_ALIGN16 <nl> - # if defined ( __GNUC__ ) & & ! defined ( __APPLE__ ) <nl> - / / the alignment attribute doesn ' t seem to work without this section attribute when - fdata - sections is turned on <nl> - # define CRYPTOPP_SECTION_ALIGN16 __attribute__ ( ( section ( " CryptoPP_Align16 " ) ) ) <nl> - # else <nl> - # define CRYPTOPP_SECTION_ALIGN16 <nl> - # endif <nl> - # endif <nl> - <nl> - # if defined ( _MSC_VER ) | | defined ( __fastcall ) <nl> - # define CRYPTOPP_FASTCALL __fastcall <nl> - # else <nl> - # define CRYPTOPP_FASTCALL <nl> - # endif <nl> - <nl> - / / VC60 workaround : it doesn ' t allow typename in some places <nl> - # if defined ( _MSC_VER ) & & ( _MSC_VER < 1300 ) <nl> - # define CPP_TYPENAME <nl> - # else <nl> - # define CPP_TYPENAME typename <nl> - # endif <nl> - <nl> - / / VC60 workaround : can ' t cast unsigned __int64 to float or double <nl> - # if defined ( _MSC_VER ) & & ! defined ( CRYPTOPP_MSVC6PP_OR_LATER ) <nl> - # define CRYPTOPP_VC6_INT64 ( __int64 ) <nl> - # else <nl> - # define CRYPTOPP_VC6_INT64 <nl> - # endif <nl> - <nl> - # ifdef _MSC_VER <nl> - # define CRYPTOPP_NO_VTABLE __declspec ( novtable ) <nl> - # else <nl> - # define CRYPTOPP_NO_VTABLE <nl> - # endif <nl> - <nl> - # ifdef _MSC_VER <nl> - / / 4231 : nonstandard extension used : ' extern ' before template explicit instantiation <nl> - / / 4250 : dominance <nl> - / / 4251 : member needs to have dll - interface <nl> - / / 4275 : base needs to have dll - interface <nl> - / / 4660 : explicitly instantiating a class that ' s already implicitly instantiated <nl> - / / 4661 : no suitable definition provided for explicit template instantiation request <nl> - / / 4786 : identifer was truncated in debug information <nl> - / / 4355 : ' this ' : used in base member initializer list <nl> - / / 4910 : ' __declspec ( dllexport ) ' and ' extern ' are incompatible on an explicit instantiation <nl> - # pragma warning ( disable : 4231 4250 4251 4275 4660 4661 4786 4355 4910 ) <nl> - # endif <nl> - <nl> - # ifdef __BORLANDC__ <nl> - / / 8037 : non - const function called for const object . needed to work around BCB2006 bug <nl> - # pragma warn - 8037 <nl> - # endif <nl> - <nl> - # if ( defined ( _MSC_VER ) & & _MSC_VER < = 1300 ) | | defined ( __MWERKS__ ) | | defined ( _STLPORT_VERSION ) <nl> - # define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION <nl> - # endif <nl> - <nl> - # ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION <nl> - # define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE <nl> - # endif <nl> - <nl> - # ifdef CRYPTOPP_DISABLE_X86ASM / / for backwards compatibility : this macro had both meanings <nl> - # define CRYPTOPP_DISABLE_ASM <nl> - # define CRYPTOPP_DISABLE_SSE2 <nl> - # endif <nl> - <nl> - # if ! defined ( CRYPTOPP_DISABLE_ASM ) & & ( ( defined ( _MSC_VER ) & & defined ( _M_IX86 ) ) | | ( defined ( __GNUC__ ) & & ( defined ( __i386__ ) | | defined ( __x86_64__ ) ) ) ) <nl> - # define CRYPTOPP_X86_ASM_AVAILABLE <nl> - <nl> - # if ! defined ( CRYPTOPP_DISABLE_SSE2 ) & & ( defined ( CRYPTOPP_MSVC6PP_OR_LATER ) | | CRYPTOPP_GCC_VERSION > = 30300 ) <nl> - # define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1 <nl> - # else <nl> - # define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0 <nl> - # endif <nl> - <nl> - / / SSSE3 was actually introduced in GNU as 2 . 17 , which was released 6 / 23 / 2006 , but we can ' t tell what version of binutils is installed . <nl> - / / GCC 4 . 1 . 2 was released on 2 / 13 / 2007 , so we ' ll use that as a proxy for the binutils version . <nl> - # if ! defined ( CRYPTOPP_DISABLE_SSSE3 ) & & ( _MSC_VER > = 1400 | | CRYPTOPP_GCC_VERSION > = 40102 ) <nl> - # define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1 <nl> - # else <nl> - # define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0 <nl> - # endif <nl> - # endif <nl> - <nl> - # if ! defined ( CRYPTOPP_DISABLE_ASM ) & & defined ( _MSC_VER ) & & defined ( _M_X64 ) <nl> - # define CRYPTOPP_X64_MASM_AVAILABLE <nl> - # endif <nl> - <nl> - # if ! defined ( CRYPTOPP_DISABLE_ASM ) & & defined ( __GNUC__ ) & & defined ( __x86_64__ ) <nl> - # define CRYPTOPP_X64_ASM_AVAILABLE <nl> - # endif <nl> - <nl> - # if ! defined ( CRYPTOPP_DISABLE_SSE2 ) & & ( defined ( CRYPTOPP_MSVC6PP_OR_LATER ) | | defined ( __SSE2__ ) ) <nl> - # define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1 <nl> - # else <nl> - # define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0 <nl> - # endif <nl> - <nl> - # if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE | | CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE | | defined ( CRYPTOPP_X64_MASM_AVAILABLE ) <nl> - # define CRYPTOPP_BOOL_ALIGN16_ENABLED 1 <nl> - # else <nl> - # define CRYPTOPP_BOOL_ALIGN16_ENABLED 0 <nl> - # endif <nl> - <nl> - / / how to allocate 16 - byte aligned memory ( for SSE2 ) <nl> - # if defined ( CRYPTOPP_MSVC6PP_OR_LATER ) <nl> - # define CRYPTOPP_MM_MALLOC_AVAILABLE <nl> - # elif defined ( __FreeBSD__ ) | | defined ( __NetBSD__ ) | | defined ( __OpenBSD__ ) <nl> - # define CRYPTOPP_MALLOC_ALIGNMENT_IS_16 <nl> - # elif defined ( __linux__ ) | | defined ( __sun__ ) | | defined ( __CYGWIN__ ) <nl> - # define CRYPTOPP_MEMALIGN_AVAILABLE <nl> - # else <nl> - # define CRYPTOPP_NO_ALIGNED_ALLOC <nl> - # endif <nl> - <nl> - / / how to disable inlining <nl> - # if defined ( _MSC_VER ) & & _MSC_VER > = 1300 <nl> - # define CRYPTOPP_NOINLINE_DOTDOTDOT <nl> - # define CRYPTOPP_NOINLINE __declspec ( noinline ) <nl> - # elif defined ( __GNUC__ ) <nl> - # define CRYPTOPP_NOINLINE_DOTDOTDOT <nl> - # define CRYPTOPP_NOINLINE __attribute__ ( ( noinline ) ) <nl> - # else <nl> - # define CRYPTOPP_NOINLINE_DOTDOTDOT . . . <nl> - # define CRYPTOPP_NOINLINE <nl> - # endif <nl> - <nl> - / / how to declare class constants <nl> - # if ( defined ( _MSC_VER ) & & _MSC_VER < = 1300 ) | | defined ( __INTEL_COMPILER ) <nl> - # define CRYPTOPP_CONSTANT ( x ) enum { x } ; <nl> - # else <nl> - # define CRYPTOPP_CONSTANT ( x ) static const int x ; <nl> - # endif <nl> - <nl> - # if defined ( _M_X64 ) | | defined ( __x86_64__ ) <nl> - # define CRYPTOPP_BOOL_X64 1 <nl> - # else <nl> - # define CRYPTOPP_BOOL_X64 0 <nl> - # endif <nl> - <nl> - / / see http : / / predef . sourceforge . net / prearch . html <nl> - # if defined ( _M_IX86 ) | | defined ( __i386__ ) | | defined ( __i386 ) | | defined ( _X86_ ) | | defined ( __I86__ ) | | defined ( __INTEL__ ) <nl> - # define CRYPTOPP_BOOL_X86 1 <nl> - # else <nl> - # define CRYPTOPP_BOOL_X86 0 <nl> - # endif <nl> - <nl> - # if CRYPTOPP_BOOL_X64 | | CRYPTOPP_BOOL_X86 | | defined ( __powerpc__ ) <nl> - # define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS <nl> - # endif <nl> - <nl> - # define CRYPTOPP_VERSION 560 <nl> - <nl> - / / * * * * * * * * * * * * * * * * * determine availability of OS features * * * * * * * * * * * * * * * * * * * * <nl> - <nl> - # ifndef NO_OS_DEPENDENCE <nl> - <nl> - # if defined ( _WIN32 ) | | defined ( __CYGWIN__ ) <nl> - # define CRYPTOPP_WIN32_AVAILABLE <nl> - # endif <nl> - <nl> - # if defined ( __unix__ ) | | defined ( __MACH__ ) | | defined ( __NetBSD__ ) | | defined ( __sun ) <nl> - # define CRYPTOPP_UNIX_AVAILABLE <nl> - # endif <nl> - <nl> - # if defined ( CRYPTOPP_WIN32_AVAILABLE ) | | defined ( CRYPTOPP_UNIX_AVAILABLE ) <nl> - # define HIGHRES_TIMER_AVAILABLE <nl> - # endif <nl> - <nl> - # ifdef CRYPTOPP_UNIX_AVAILABLE <nl> - # define HAS_BERKELEY_STYLE_SOCKETS <nl> - # endif <nl> - <nl> - # ifdef CRYPTOPP_WIN32_AVAILABLE <nl> - # define HAS_WINDOWS_STYLE_SOCKETS <nl> - # endif <nl> - <nl> - # if defined ( HIGHRES_TIMER_AVAILABLE ) & & ( defined ( HAS_BERKELEY_STYLE_SOCKETS ) | | defined ( HAS_WINDOWS_STYLE_SOCKETS ) ) <nl> - # define SOCKETS_AVAILABLE <nl> - # endif <nl> - <nl> - # if defined ( HAS_WINDOWS_STYLE_SOCKETS ) & & ( ! defined ( HAS_BERKELEY_STYLE_SOCKETS ) | | defined ( PREFER_WINDOWS_STYLE_SOCKETS ) ) <nl> - # define USE_WINDOWS_STYLE_SOCKETS <nl> - # else <nl> - # define USE_BERKELEY_STYLE_SOCKETS <nl> - # endif <nl> - <nl> - # if defined ( HIGHRES_TIMER_AVAILABLE ) & & defined ( CRYPTOPP_WIN32_AVAILABLE ) & & ! defined ( USE_BERKELEY_STYLE_SOCKETS ) <nl> - # define WINDOWS_PIPES_AVAILABLE <nl> - # endif <nl> - <nl> - # if defined ( CRYPTOPP_WIN32_AVAILABLE ) & & defined ( USE_MS_CRYPTOAPI ) <nl> - # define NONBLOCKING_RNG_AVAILABLE <nl> - # define OS_RNG_AVAILABLE <nl> - # endif <nl> - <nl> - # if defined ( CRYPTOPP_UNIX_AVAILABLE ) | | defined ( CRYPTOPP_DOXYGEN_PROCESSING ) <nl> - # define NONBLOCKING_RNG_AVAILABLE <nl> - # define BLOCKING_RNG_AVAILABLE <nl> - # define OS_RNG_AVAILABLE <nl> - # define HAS_PTHREADS <nl> - # define THREADS_AVAILABLE <nl> - # endif <nl> - <nl> - # ifdef CRYPTOPP_WIN32_AVAILABLE <nl> - # define HAS_WINTHREADS <nl> - # define THREADS_AVAILABLE <nl> - # endif <nl> - <nl> - # endif / / NO_OS_DEPENDENCE <nl> - <nl> - / / * * * * * * * * * * * * * * * * * DLL related * * * * * * * * * * * * * * * * * * * * <nl> - <nl> - # ifdef CRYPTOPP_WIN32_AVAILABLE <nl> - <nl> - # ifdef CRYPTOPP_EXPORTS <nl> - # define CRYPTOPP_IS_DLL <nl> - # define CRYPTOPP_DLL __declspec ( dllexport ) <nl> - # elif defined ( CRYPTOPP_IMPORTS ) <nl> - # define CRYPTOPP_IS_DLL <nl> - # define CRYPTOPP_DLL __declspec ( dllimport ) <nl> - # else <nl> - # define CRYPTOPP_DLL <nl> - # endif <nl> - <nl> - # define CRYPTOPP_API __cdecl <nl> - <nl> - # else / / CRYPTOPP_WIN32_AVAILABLE <nl> - <nl> - # define CRYPTOPP_DLL <nl> - # define CRYPTOPP_API <nl> - <nl> - # endif / / CRYPTOPP_WIN32_AVAILABLE <nl> - <nl> - # if defined ( __MWERKS__ ) <nl> - # define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL <nl> - # elif defined ( __BORLANDC__ ) | | defined ( __SUNPRO_CC ) <nl> - # define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL <nl> - # else <nl> - # define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL <nl> - # endif <nl> - <nl> - # if defined ( CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES ) & & ! defined ( CRYPTOPP_IMPORTS ) <nl> - # define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL <nl> - # else <nl> - # define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS <nl> - # endif <nl> - <nl> - # if defined ( __MWERKS__ ) <nl> - # define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class <nl> - # elif defined ( __BORLANDC__ ) | | defined ( __SUNPRO_CC ) <nl> - # define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class <nl> - # else <nl> - # define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class <nl> - # endif <nl> - <nl> - # if defined ( CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES ) & & ! defined ( CRYPTOPP_EXPORTS ) <nl> - # define CRYPTOPP_STATIC_TEMPLATE_CLASS template class <nl> - # else <nl> - # define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS <nl> - # endif <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 8789dc3176c7 . . 000000000000 <nl> mmm a / src / cryptopp / cpu . cpp <nl> ppp / dev / null <nl> <nl> - / / cpu . cpp - written and placed in the public domain by Wei Dai <nl> - <nl> - # include " pch . h " <nl> - <nl> - # ifndef CRYPTOPP_IMPORTS <nl> - <nl> - # include " cpu . h " <nl> - # include " misc . h " <nl> - # include < algorithm > <nl> - <nl> - # ifdef __GNUC__ <nl> - # include < signal . h > <nl> - # include < setjmp . h > <nl> - # endif <nl> - <nl> - # ifdef CRYPTOPP_MSVC6PP_OR_LATER <nl> - # include < emmintrin . h > <nl> - # endif <nl> - <nl> - NAMESPACE_BEGIN ( CryptoPP ) <nl> - <nl> - # ifdef CRYPTOPP_X86_ASM_AVAILABLE <nl> - <nl> - # ifndef _MSC_VER <nl> - typedef void ( * SigHandler ) ( int ) ; <nl> - <nl> - static jmp_buf s_jmpNoCPUID ; <nl> - static void SigIllHandlerCPUID ( int ) <nl> - { <nl> - longjmp ( s_jmpNoCPUID , 1 ) ; <nl> - } <nl> - # endif <nl> - <nl> - bool CpuId ( word32 input , word32 * output ) <nl> - { <nl> - # ifdef _MSC_VER <nl> - __try <nl> - { <nl> - __asm <nl> - { <nl> - mov eax , input <nl> - cpuid <nl> - mov edi , output <nl> - mov [ edi ] , eax <nl> - mov [ edi + 4 ] , ebx <nl> - mov [ edi + 8 ] , ecx <nl> - mov [ edi + 12 ] , edx <nl> - } <nl> - } <nl> - __except ( 1 ) <nl> - { <nl> - return false ; <nl> - } <nl> - return true ; <nl> - # else <nl> - SigHandler oldHandler = signal ( SIGILL , SigIllHandlerCPUID ) ; <nl> - if ( oldHandler = = SIG_ERR ) <nl> - return false ; <nl> - <nl> - bool result = true ; <nl> - if ( setjmp ( s_jmpNoCPUID ) ) <nl> - result = false ; <nl> - else <nl> - { <nl> - __asm__ <nl> - ( <nl> - / / save ebx in case - fPIC is being used <nl> - # if CRYPTOPP_BOOL_X86 <nl> - " push % % ebx ; cpuid ; mov % % ebx , % % edi ; pop % % ebx " <nl> - # else <nl> - " pushq % % rbx ; cpuid ; mov % % ebx , % % edi ; popq % % rbx " <nl> - # endif <nl> - : " = a " ( output [ 0 ] ) , " = D " ( output [ 1 ] ) , " = c " ( output [ 2 ] ) , " = d " ( output [ 3 ] ) <nl> - : " a " ( input ) <nl> - ) ; <nl> - } <nl> - <nl> - signal ( SIGILL , oldHandler ) ; <nl> - return result ; <nl> - # endif <nl> - } <nl> - <nl> - # if ! CRYPTOPP_BOOL_X64 & & ! defined ( _MSC_VER ) & & defined ( __GNUC__ ) <nl> - static jmp_buf s_jmpNoSSE2 ; <nl> - static void SigIllHandlerSSE2 ( int ) <nl> - { <nl> - longjmp ( s_jmpNoSSE2 , 1 ) ; <nl> - } <nl> - # endif <nl> - <nl> - # elif _MSC_VER > = 1400 & & CRYPTOPP_BOOL_X64 <nl> - <nl> - bool CpuId ( word32 input , word32 * output ) <nl> - { <nl> - __cpuid ( ( int * ) output , input ) ; <nl> - return true ; <nl> - } <nl> - <nl> - # endif <nl> - <nl> - # ifdef CRYPTOPP_CPUID_AVAILABLE <nl> - <nl> - static bool TrySSE2 ( ) <nl> - { <nl> - # if CRYPTOPP_BOOL_X64 <nl> - return true ; <nl> - # elif defined ( _MSC_VER ) <nl> - __try <nl> - { <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE <nl> - AS2 ( por xmm0 , xmm0 ) / / executing SSE2 instruction <nl> - # elif CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE <nl> - __mm128i x = _mm_setzero_si128 ( ) ; <nl> - return _mm_cvtsi128_si32 ( x ) = = 0 ; <nl> - # endif <nl> - } <nl> - __except ( 1 ) <nl> - { <nl> - return false ; <nl> - } <nl> - return true ; <nl> - # elif defined ( __GNUC__ ) <nl> - SigHandler oldHandler = signal ( SIGILL , SigIllHandlerSSE2 ) ; <nl> - if ( oldHandler = = SIG_ERR ) <nl> - return false ; <nl> - <nl> - bool result = true ; <nl> - if ( setjmp ( s_jmpNoSSE2 ) ) <nl> - result = false ; <nl> - else <nl> - { <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE <nl> - __asm __volatile ( " por % xmm0 , % xmm0 " ) ; <nl> - # elif CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE <nl> - __mm128i x = _mm_setzero_si128 ( ) ; <nl> - result = _mm_cvtsi128_si32 ( x ) = = 0 ; <nl> - # endif <nl> - } <nl> - <nl> - signal ( SIGILL , oldHandler ) ; <nl> - return result ; <nl> - # else <nl> - return false ; <nl> - # endif <nl> - } <nl> - <nl> - bool g_x86DetectionDone = false ; <nl> - bool g_hasISSE = false , g_hasSSE2 = false , g_hasSSSE3 = false , g_hasMMX = false , g_isP4 = false ; <nl> - word32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE ; <nl> - <nl> - void DetectX86Features ( ) <nl> - { <nl> - word32 cpuid [ 4 ] , cpuid1 [ 4 ] ; <nl> - if ( ! CpuId ( 0 , cpuid ) ) <nl> - return ; <nl> - if ( ! CpuId ( 1 , cpuid1 ) ) <nl> - return ; <nl> - <nl> - g_hasMMX = ( cpuid1 [ 3 ] & ( 1 < < 23 ) ) ! = 0 ; <nl> - if ( ( cpuid1 [ 3 ] & ( 1 < < 26 ) ) ! = 0 ) <nl> - g_hasSSE2 = TrySSE2 ( ) ; <nl> - g_hasSSSE3 = g_hasSSE2 & & ( cpuid1 [ 2 ] & ( 1 < < 9 ) ) ; <nl> - <nl> - if ( ( cpuid1 [ 3 ] & ( 1 < < 25 ) ) ! = 0 ) <nl> - g_hasISSE = true ; <nl> - else <nl> - { <nl> - word32 cpuid2 [ 4 ] ; <nl> - CpuId ( 0x080000000 , cpuid2 ) ; <nl> - if ( cpuid2 [ 0 ] > = 0x080000001 ) <nl> - { <nl> - CpuId ( 0x080000001 , cpuid2 ) ; <nl> - g_hasISSE = ( cpuid2 [ 3 ] & ( 1 < < 22 ) ) ! = 0 ; <nl> - } <nl> - } <nl> - <nl> - std : : swap ( cpuid [ 2 ] , cpuid [ 3 ] ) ; <nl> - if ( memcmp ( cpuid + 1 , " GenuineIntel " , 12 ) = = 0 ) <nl> - { <nl> - g_isP4 = ( ( cpuid1 [ 0 ] > > 8 ) & 0xf ) = = 0xf ; <nl> - g_cacheLineSize = 8 * GETBYTE ( cpuid1 [ 1 ] , 1 ) ; <nl> - } <nl> - else if ( memcmp ( cpuid + 1 , " AuthenticAMD " , 12 ) = = 0 ) <nl> - { <nl> - CpuId ( 0x80000005 , cpuid ) ; <nl> - g_cacheLineSize = GETBYTE ( cpuid [ 2 ] , 0 ) ; <nl> - } <nl> - <nl> - if ( ! g_cacheLineSize ) <nl> - g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE ; <nl> - <nl> - g_x86DetectionDone = true ; <nl> - } <nl> - <nl> - # endif <nl> - <nl> - NAMESPACE_END <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 7f01dad85261 . . 000000000000 <nl> mmm a / src / cryptopp / cpu . h <nl> ppp / dev / null <nl> <nl> - # ifndef CRYPTOPP_CPU_H <nl> - # define CRYPTOPP_CPU_H <nl> - <nl> - # ifdef CRYPTOPP_GENERATE_X64_MASM <nl> - <nl> - # define CRYPTOPP_X86_ASM_AVAILABLE <nl> - # define CRYPTOPP_BOOL_X64 1 <nl> - # define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1 <nl> - # define NAMESPACE_END <nl> - <nl> - # else <nl> - <nl> - # include " config . h " <nl> - <nl> - # ifdef CRYPTOPP_MSVC6PP_OR_LATER <nl> - # include < emmintrin . h > <nl> - # endif <nl> - <nl> - NAMESPACE_BEGIN ( CryptoPP ) <nl> - <nl> - # if defined ( CRYPTOPP_X86_ASM_AVAILABLE ) | | ( _MSC_VER > = 1400 & & CRYPTOPP_BOOL_X64 ) <nl> - <nl> - # define CRYPTOPP_CPUID_AVAILABLE <nl> - <nl> - / / these should not be used directly <nl> - extern CRYPTOPP_DLL bool g_x86DetectionDone ; <nl> - extern CRYPTOPP_DLL bool g_hasSSE2 ; <nl> - extern CRYPTOPP_DLL bool g_hasISSE ; <nl> - extern CRYPTOPP_DLL bool g_hasMMX ; <nl> - extern CRYPTOPP_DLL bool g_hasSSSE3 ; <nl> - extern CRYPTOPP_DLL bool g_isP4 ; <nl> - extern CRYPTOPP_DLL word32 g_cacheLineSize ; <nl> - CRYPTOPP_DLL void CRYPTOPP_API DetectX86Features ( ) ; <nl> - <nl> - CRYPTOPP_DLL bool CRYPTOPP_API CpuId ( word32 input , word32 * output ) ; <nl> - <nl> - # if CRYPTOPP_BOOL_X64 <nl> - inline bool HasSSE2 ( ) { return true ; } <nl> - inline bool HasISSE ( ) { return true ; } <nl> - inline bool HasMMX ( ) { return true ; } <nl> - # else <nl> - <nl> - inline bool HasSSE2 ( ) <nl> - { <nl> - if ( ! g_x86DetectionDone ) <nl> - DetectX86Features ( ) ; <nl> - return g_hasSSE2 ; <nl> - } <nl> - <nl> - inline bool HasISSE ( ) <nl> - { <nl> - if ( ! g_x86DetectionDone ) <nl> - DetectX86Features ( ) ; <nl> - return g_hasISSE ; <nl> - } <nl> - <nl> - inline bool HasMMX ( ) <nl> - { <nl> - if ( ! g_x86DetectionDone ) <nl> - DetectX86Features ( ) ; <nl> - return g_hasMMX ; <nl> - } <nl> - <nl> - # endif <nl> - <nl> - inline bool HasSSSE3 ( ) <nl> - { <nl> - if ( ! g_x86DetectionDone ) <nl> - DetectX86Features ( ) ; <nl> - return g_hasSSSE3 ; <nl> - } <nl> - <nl> - inline bool IsP4 ( ) <nl> - { <nl> - if ( ! g_x86DetectionDone ) <nl> - DetectX86Features ( ) ; <nl> - return g_isP4 ; <nl> - } <nl> - <nl> - inline int GetCacheLineSize ( ) <nl> - { <nl> - if ( ! g_x86DetectionDone ) <nl> - DetectX86Features ( ) ; <nl> - return g_cacheLineSize ; <nl> - } <nl> - <nl> - # else <nl> - <nl> - inline int GetCacheLineSize ( ) <nl> - { <nl> - return CRYPTOPP_L1_CACHE_LINE_SIZE ; <nl> - } <nl> - <nl> - inline bool HasSSSE3 ( ) { return false ; } <nl> - inline bool IsP4 ( ) { return false ; } <nl> - <nl> - / / assume MMX and SSE2 if intrinsics are enabled <nl> - # if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE | | CRYPTOPP_BOOL_X64 <nl> - inline bool HasSSE2 ( ) { return true ; } <nl> - inline bool HasISSE ( ) { return true ; } <nl> - inline bool HasMMX ( ) { return true ; } <nl> - # else <nl> - inline bool HasSSE2 ( ) { return false ; } <nl> - inline bool HasISSE ( ) { return false ; } <nl> - inline bool HasMMX ( ) { return false ; } <nl> - # endif <nl> - <nl> - # endif / / # ifdef CRYPTOPP_X86_ASM_AVAILABLE | | _MSC_VER > = 1400 <nl> - <nl> - # endif <nl> - <nl> - # ifdef CRYPTOPP_GENERATE_X64_MASM <nl> - # define AS1 ( x ) x * newline * <nl> - # define AS2 ( x , y ) x , y * newline * <nl> - # define AS3 ( x , y , z ) x , y , z * newline * <nl> - # define ASS ( x , y , a , b , c , d ) x , y , a * 64 + b * 16 + c * 4 + d * newline * <nl> - # define ASL ( x ) label # # x : * newline * <nl> - # define ASJ ( x , y , z ) x label # # y * newline * <nl> - # define ASC ( x , y ) x label # # y * newline * <nl> - # define AS_HEX ( y ) 0 # # y # # h <nl> - # elif defined ( __GNUC__ ) <nl> - / / define these in two steps to allow arguments to be expanded <nl> - # define GNU_AS1 ( x ) # x " ; " <nl> - # define GNU_AS2 ( x , y ) # x " , " # y " ; " <nl> - # define GNU_AS3 ( x , y , z ) # x " , " # y " , " # z " ; " <nl> - # define GNU_ASL ( x ) " \ n " # x " : " <nl> - # define GNU_ASJ ( x , y , z ) # x " " # y # z " ; " <nl> - # define AS1 ( x ) GNU_AS1 ( x ) <nl> - # define AS2 ( x , y ) GNU_AS2 ( x , y ) <nl> - # define AS3 ( x , y , z ) GNU_AS3 ( x , y , z ) <nl> - # define ASS ( x , y , a , b , c , d ) # x " , " # y " , " # a " * 64 + " # b " * 16 + " # c " * 4 + " # d " ; " <nl> - # define ASL ( x ) GNU_ASL ( x ) <nl> - # define ASJ ( x , y , z ) GNU_ASJ ( x , y , z ) <nl> - # define ASC ( x , y ) # x " " # y " ; " <nl> - # define CRYPTOPP_NAKED <nl> - # define AS_HEX ( y ) 0x # # y <nl> - # else <nl> - # define AS1 ( x ) __asm { x } <nl> - # define AS2 ( x , y ) __asm { x , y } <nl> - # define AS3 ( x , y , z ) __asm { x , y , z } <nl> - # define ASS ( x , y , a , b , c , d ) __asm { x , y , _MM_SHUFFLE ( a , b , c , d ) } <nl> - # define ASL ( x ) __asm { label # # x : } <nl> - # define ASJ ( x , y , z ) __asm { x label # # y } <nl> - # define ASC ( x , y ) __asm { x label # # y } <nl> - # define CRYPTOPP_NAKED __declspec ( naked ) <nl> - # define AS_HEX ( y ) 0x # # y <nl> - # endif <nl> - <nl> - # define IF0 ( y ) <nl> - # define IF1 ( y ) y <nl> - <nl> - # ifdef CRYPTOPP_GENERATE_X64_MASM <nl> - # define ASM_MOD ( x , y ) ( ( x ) MOD ( y ) ) <nl> - # define XMMWORD_PTR XMMWORD PTR <nl> - # else <nl> - / / GNU assembler doesn ' t seem to have mod operator <nl> - # define ASM_MOD ( x , y ) ( ( x ) - ( ( x ) / ( y ) ) * ( y ) ) <nl> - / / GAS 2 . 15 doesn ' t support XMMWORD PTR . it seems necessary only for MASM <nl> - # define XMMWORD_PTR <nl> - # endif <nl> - <nl> - # if CRYPTOPP_BOOL_X86 <nl> - # define AS_REG_1 ecx <nl> - # define AS_REG_2 edx <nl> - # define AS_REG_3 esi <nl> - # define AS_REG_4 edi <nl> - # define AS_REG_5 eax <nl> - # define AS_REG_6 ebx <nl> - # define AS_REG_7 ebp <nl> - # define AS_REG_1d ecx <nl> - # define AS_REG_2d edx <nl> - # define AS_REG_3d esi <nl> - # define AS_REG_4d edi <nl> - # define AS_REG_5d eax <nl> - # define AS_REG_6d ebx <nl> - # define AS_REG_7d ebp <nl> - # define WORD_SZ 4 <nl> - # define WORD_REG ( x ) e # # x <nl> - # define WORD_PTR DWORD PTR <nl> - # define AS_PUSH_IF86 ( x ) AS1 ( push e # # x ) <nl> - # define AS_POP_IF86 ( x ) AS1 ( pop e # # x ) <nl> - # define AS_JCXZ jecxz <nl> - # elif CRYPTOPP_BOOL_X64 <nl> - # ifdef CRYPTOPP_GENERATE_X64_MASM <nl> - # define AS_REG_1 rcx <nl> - # define AS_REG_2 rdx <nl> - # define AS_REG_3 r8 <nl> - # define AS_REG_4 r9 <nl> - # define AS_REG_5 rax <nl> - # define AS_REG_6 r10 <nl> - # define AS_REG_7 r11 <nl> - # define AS_REG_1d ecx <nl> - # define AS_REG_2d edx <nl> - # define AS_REG_3d r8d <nl> - # define AS_REG_4d r9d <nl> - # define AS_REG_5d eax <nl> - # define AS_REG_6d r10d <nl> - # define AS_REG_7d r11d <nl> - # else <nl> - # define AS_REG_1 rdi <nl> - # define AS_REG_2 rsi <nl> - # define AS_REG_3 rdx <nl> - # define AS_REG_4 rcx <nl> - # define AS_REG_5 r8 <nl> - # define AS_REG_6 r9 <nl> - # define AS_REG_7 r10 <nl> - # define AS_REG_1d edi <nl> - # define AS_REG_2d esi <nl> - # define AS_REG_3d edx <nl> - # define AS_REG_4d ecx <nl> - # define AS_REG_5d r8d <nl> - # define AS_REG_6d r9d <nl> - # define AS_REG_7d r10d <nl> - # endif <nl> - # define WORD_SZ 8 <nl> - # define WORD_REG ( x ) r # # x <nl> - # define WORD_PTR QWORD PTR <nl> - # define AS_PUSH_IF86 ( x ) <nl> - # define AS_POP_IF86 ( x ) <nl> - # define AS_JCXZ jrcxz <nl> - # endif <nl> - <nl> - / / helper macro for stream cipher output <nl> - # define AS_XMM_OUTPUT4 ( labelPrefix , inputPtr , outputPtr , x0 , x1 , x2 , x3 , t , p0 , p1 , p2 , p3 , increment ) \ <nl> - AS2 ( test inputPtr , inputPtr ) \ <nl> - ASC ( jz , labelPrefix # # 3 ) \ <nl> - AS2 ( test inputPtr , 15 ) \ <nl> - ASC ( jnz , labelPrefix # # 7 ) \ <nl> - AS2 ( pxor xmm # # x0 , [ inputPtr + p0 * 16 ] ) \ <nl> - AS2 ( pxor xmm # # x1 , [ inputPtr + p1 * 16 ] ) \ <nl> - AS2 ( pxor xmm # # x2 , [ inputPtr + p2 * 16 ] ) \ <nl> - AS2 ( pxor xmm # # x3 , [ inputPtr + p3 * 16 ] ) \ <nl> - AS2 ( add inputPtr , increment * 16 ) \ <nl> - ASC ( jmp , labelPrefix # # 3 ) \ <nl> - ASL ( labelPrefix # # 7 ) \ <nl> - AS2 ( movdqu xmm # # t , [ inputPtr + p0 * 16 ] ) \ <nl> - AS2 ( pxor xmm # # x0 , xmm # # t ) \ <nl> - AS2 ( movdqu xmm # # t , [ inputPtr + p1 * 16 ] ) \ <nl> - AS2 ( pxor xmm # # x1 , xmm # # t ) \ <nl> - AS2 ( movdqu xmm # # t , [ inputPtr + p2 * 16 ] ) \ <nl> - AS2 ( pxor xmm # # x2 , xmm # # t ) \ <nl> - AS2 ( movdqu xmm # # t , [ inputPtr + p3 * 16 ] ) \ <nl> - AS2 ( pxor xmm # # x3 , xmm # # t ) \ <nl> - AS2 ( add inputPtr , increment * 16 ) \ <nl> - ASL ( labelPrefix # # 3 ) \ <nl> - AS2 ( test outputPtr , 15 ) \ <nl> - ASC ( jnz , labelPrefix # # 8 ) \ <nl> - AS2 ( movdqa [ outputPtr + p0 * 16 ] , xmm # # x0 ) \ <nl> - AS2 ( movdqa [ outputPtr + p1 * 16 ] , xmm # # x1 ) \ <nl> - AS2 ( movdqa [ outputPtr + p2 * 16 ] , xmm # # x2 ) \ <nl> - AS2 ( movdqa [ outputPtr + p3 * 16 ] , xmm # # x3 ) \ <nl> - ASC ( jmp , labelPrefix # # 9 ) \ <nl> - ASL ( labelPrefix # # 8 ) \ <nl> - AS2 ( movdqu [ outputPtr + p0 * 16 ] , xmm # # x0 ) \ <nl> - AS2 ( movdqu [ outputPtr + p1 * 16 ] , xmm # # x1 ) \ <nl> - AS2 ( movdqu [ outputPtr + p2 * 16 ] , xmm # # x2 ) \ <nl> - AS2 ( movdqu [ outputPtr + p3 * 16 ] , xmm # # x3 ) \ <nl> - ASL ( labelPrefix # # 9 ) \ <nl> - AS2 ( add outputPtr , increment * 16 ) <nl> - <nl> - NAMESPACE_END <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 15cd6dad67e0 . . 000000000000 <nl> mmm a / src / cryptopp / cryptlib . h <nl> ppp / dev / null <nl> <nl> - / / cryptlib . h - written and placed in the public domain by Wei Dai <nl> - / * ! \ file <nl> - This file contains the declarations for the abstract base <nl> - classes that provide a uniform interface to this library . <nl> - * / <nl> - <nl> - / * ! \ mainpage Crypto + + Library 5 . 6 . 0 API Reference <nl> - < dl > <nl> - < dt > Abstract Base Classes < dd > <nl> - cryptlib . h <nl> - < dt > Authenticated Encryption < dd > <nl> - AuthenticatedSymmetricCipherDocumentation <nl> - < dt > Symmetric Ciphers < dd > <nl> - SymmetricCipherDocumentation <nl> - < dt > Hash Functions < dd > <nl> - SHA1 , SHA224 , SHA256 , SHA384 , SHA512 , Tiger , Whirlpool , RIPEMD160 , RIPEMD320 , RIPEMD128 , RIPEMD256 , Weak1 : : MD2 , Weak1 : : MD4 , Weak1 : : MD5 <nl> - < dt > Non - Cryptographic Checksums < dd > <nl> - CRC32 , Adler32 <nl> - < dt > Message Authentication Codes < dd > <nl> - VMAC , HMAC , CBC_MAC , CMAC , DMAC , TTMAC , GCM ( GMAC ) <nl> - < dt > Random Number Generators < dd > <nl> - NullRNG ( ) , LC_RNG , RandomPool , BlockingRng , NonblockingRng , AutoSeededRandomPool , AutoSeededX917RNG , DefaultAutoSeededRNG <nl> - < dt > Password - based Cryptography < dd > <nl> - PasswordBasedKeyDerivationFunction <nl> - < dt > Public Key Cryptosystems < dd > <nl> - DLIES , ECIES , LUCES , RSAES , RabinES , LUC_IES <nl> - < dt > Public Key Signature Schemes < dd > <nl> - DSA , GDSA , ECDSA , NR , ECNR , LUCSS , RSASS , RSASS_ISO , RabinSS , RWSS , ESIGN <nl> - < dt > Key Agreement < dd > <nl> - # DH , DH2 , # MQV , ECDH , ECMQV , XTR_DH <nl> - < dt > Algebraic Structures < dd > <nl> - Integer , PolynomialMod2 , PolynomialOver , RingOfPolynomialsOver , <nl> - ModularArithmetic , MontgomeryRepresentation , GFP2_ONB , <nl> - GF2NP , GF256 , GF2_32 , EC2N , ECP <nl> - < dt > Secret Sharing and Information Dispersal < dd > <nl> - SecretSharing , SecretRecovery , InformationDispersal , InformationRecovery <nl> - < dt > Compression < dd > <nl> - Deflator , Inflator , Gzip , Gunzip , ZlibCompressor , ZlibDecompressor <nl> - < dt > Input Source Classes < dd > <nl> - StringSource , ArraySource , FileSource , SocketSource , WindowsPipeSource , RandomNumberSource <nl> - < dt > Output Sink Classes < dd > <nl> - StringSinkTemplate , ArraySink , FileSink , SocketSink , WindowsPipeSink , RandomNumberSink <nl> - < dt > Filter Wrappers < dd > <nl> - StreamTransformationFilter , HashFilter , HashVerificationFilter , SignerFilter , SignatureVerificationFilter <nl> - < dt > Binary to Text Encoders and Decoders < dd > <nl> - HexEncoder , HexDecoder , Base64Encoder , Base64Decoder , Base32Encoder , Base32Decoder <nl> - < dt > Wrappers for OS features < dd > <nl> - Timer , Socket , WindowsHandle , ThreadLocalStorage , ThreadUserTimer <nl> - < dt > FIPS 140 related < dd > <nl> - fips140 . h <nl> - < / dl > <nl> - <nl> - In the FIPS 140 - 2 validated DLL version of Crypto + + , only the following implementation class are available . <nl> - < dl > <nl> - < dt > Block Ciphers < dd > <nl> - AES , DES_EDE2 , DES_EDE3 , SKIPJACK <nl> - < dt > Cipher Modes ( replace template parameter BC with one of the block ciphers above ) < dd > <nl> - ECB_Mode \ < BC \ > , CTR_Mode \ < BC \ > , CBC_Mode \ < BC \ > , CFB_FIPS_Mode \ < BC \ > , OFB_Mode \ < BC \ > <nl> - < dt > Hash Functions < dd > <nl> - SHA1 , SHA224 , SHA256 , SHA384 , SHA512 <nl> - < dt > Public Key Signature Schemes ( replace template parameter H with one of the hash functions above ) < dd > <nl> - RSASS \ < PKCS1v15 , H \ > , RSASS \ < PSS , H \ > , RSASS_ISO \ < H \ > , RWSS \ < P1363_EMSA2 , H \ > , DSA , ECDSA \ < ECP , H \ > , ECDSA \ < EC2N , H \ > <nl> - < dt > Message Authentication Codes ( replace template parameter H with one of the hash functions above ) < dd > <nl> - HMAC \ < H \ > , CBC_MAC \ < DES_EDE2 \ > , CBC_MAC \ < DES_EDE3 \ > <nl> - < dt > Random Number Generators < dd > <nl> - DefaultAutoSeededRNG ( AutoSeededX917RNG \ < AES \ > ) <nl> - < dt > Key Agreement < dd > <nl> - # DH <nl> - < dt > Public Key Cryptosystems < dd > <nl> - RSAES \ < OAEP \ < SHA1 \ > \ > <nl> - < / dl > <nl> - <nl> - < p > This reference manual is a work in progress . Some classes are still lacking detailed descriptions . <nl> - < p > Click < a href = " CryptoPPRef . zip " > here < / a > to download a zip archive containing this manual . <nl> - < p > Thanks to Ryan Phillips for providing the Doxygen configuration file <nl> - and getting me started with this manual . <nl> - * / <nl> - <nl> - # ifndef CRYPTOPP_CRYPTLIB_H <nl> - # define CRYPTOPP_CRYPTLIB_H <nl> - <nl> - # include " config . h " <nl> - # include " stdcpp . h " <nl> - <nl> - NAMESPACE_BEGIN ( CryptoPP ) <nl> - <nl> - / / forward declarations <nl> - class Integer ; <nl> - class RandomNumberGenerator ; <nl> - class BufferedTransformation ; <nl> - <nl> - / / ! used to specify a direction for a cipher to operate in ( encrypt or decrypt ) <nl> - enum CipherDir { ENCRYPTION , DECRYPTION } ; <nl> - <nl> - / / ! used to represent infinite time <nl> - const unsigned long INFINITE_TIME = ULONG_MAX ; <nl> - <nl> - / / VC60 workaround : using enums as template parameters causes problems <nl> - template < typename ENUM_TYPE , int VALUE > <nl> - struct EnumToType <nl> - { <nl> - static ENUM_TYPE ToEnum ( ) { return ( ENUM_TYPE ) VALUE ; } <nl> - } ; <nl> - <nl> - enum ByteOrder { LITTLE_ENDIAN_ORDER = 0 , BIG_ENDIAN_ORDER = 1 } ; <nl> - typedef EnumToType < ByteOrder , LITTLE_ENDIAN_ORDER > LittleEndian ; <nl> - typedef EnumToType < ByteOrder , BIG_ENDIAN_ORDER > BigEndian ; <nl> - <nl> - / / ! base class for all exceptions thrown by Crypto + + <nl> - class CRYPTOPP_DLL Exception : public std : : exception <nl> - { <nl> - public : <nl> - / / ! error types <nl> - enum ErrorType { <nl> - / / ! a method is not implemented <nl> - NOT_IMPLEMENTED , <nl> - / / ! invalid function argument <nl> - INVALID_ARGUMENT , <nl> - / / ! BufferedTransformation received a Flush ( true ) signal but can ' t flush buffers <nl> - CANNOT_FLUSH , <nl> - / / ! data integerity check ( such as CRC or MAC ) failed <nl> - DATA_INTEGRITY_CHECK_FAILED , <nl> - / / ! received input data that doesn ' t conform to expected format <nl> - INVALID_DATA_FORMAT , <nl> - / / ! error reading from input device or writing to output device <nl> - IO_ERROR , <nl> - / / ! some error not belong to any of the above categories <nl> - OTHER_ERROR <nl> - } ; <nl> - <nl> - explicit Exception ( ErrorType errorType , const std : : string & s ) : m_errorType ( errorType ) , m_what ( s ) { } <nl> - virtual ~ Exception ( ) throw ( ) { } <nl> - const char * what ( ) const throw ( ) { return ( m_what . c_str ( ) ) ; } <nl> - const std : : string & GetWhat ( ) const { return m_what ; } <nl> - void SetWhat ( const std : : string & s ) { m_what = s ; } <nl> - ErrorType GetErrorType ( ) const { return m_errorType ; } <nl> - void SetErrorType ( ErrorType errorType ) { m_errorType = errorType ; } <nl> - <nl> - private : <nl> - ErrorType m_errorType ; <nl> - std : : string m_what ; <nl> - } ; <nl> - <nl> - / / ! exception thrown when an invalid argument is detected <nl> - class CRYPTOPP_DLL InvalidArgument : public Exception <nl> - { <nl> - public : <nl> - explicit InvalidArgument ( const std : : string & s ) : Exception ( INVALID_ARGUMENT , s ) { } <nl> - } ; <nl> - <nl> - / / ! exception thrown when input data is received that doesn ' t conform to expected format <nl> - class CRYPTOPP_DLL InvalidDataFormat : public Exception <nl> - { <nl> - public : <nl> - explicit InvalidDataFormat ( const std : : string & s ) : Exception ( INVALID_DATA_FORMAT , s ) { } <nl> - } ; <nl> - <nl> - / / ! exception thrown by decryption filters when trying to decrypt an invalid ciphertext <nl> - class CRYPTOPP_DLL InvalidCiphertext : public InvalidDataFormat <nl> - { <nl> - public : <nl> - explicit InvalidCiphertext ( const std : : string & s ) : InvalidDataFormat ( s ) { } <nl> - } ; <nl> - <nl> - / / ! exception thrown by a class if a non - implemented method is called <nl> - class CRYPTOPP_DLL NotImplemented : public Exception <nl> - { <nl> - public : <nl> - explicit NotImplemented ( const std : : string & s ) : Exception ( NOT_IMPLEMENTED , s ) { } <nl> - } ; <nl> - <nl> - / / ! exception thrown by a class when Flush ( true ) is called but it can ' t completely flush its buffers <nl> - class CRYPTOPP_DLL CannotFlush : public Exception <nl> - { <nl> - public : <nl> - explicit CannotFlush ( const std : : string & s ) : Exception ( CANNOT_FLUSH , s ) { } <nl> - } ; <nl> - <nl> - / / ! error reported by the operating system <nl> - class CRYPTOPP_DLL OS_Error : public Exception <nl> - { <nl> - public : <nl> - OS_Error ( ErrorType errorType , const std : : string & s , const std : : string & operation , int errorCode ) <nl> - : Exception ( errorType , s ) , m_operation ( operation ) , m_errorCode ( errorCode ) { } <nl> - ~ OS_Error ( ) throw ( ) { } <nl> - <nl> - / / the operating system API that reported the error <nl> - const std : : string & GetOperation ( ) const { return m_operation ; } <nl> - / / the error code return by the operating system <nl> - int GetErrorCode ( ) const { return m_errorCode ; } <nl> - <nl> - protected : <nl> - std : : string m_operation ; <nl> - int m_errorCode ; <nl> - } ; <nl> - <nl> - / / ! used to return decoding results <nl> - struct CRYPTOPP_DLL DecodingResult <nl> - { <nl> - explicit DecodingResult ( ) : isValidCoding ( false ) , messageLength ( 0 ) { } <nl> - explicit DecodingResult ( size_t len ) : isValidCoding ( true ) , messageLength ( len ) { } <nl> - <nl> - bool operator = = ( const DecodingResult & rhs ) const { return isValidCoding = = rhs . isValidCoding & & messageLength = = rhs . messageLength ; } <nl> - bool operator ! = ( const DecodingResult & rhs ) const { return ! operator = = ( rhs ) ; } <nl> - <nl> - bool isValidCoding ; <nl> - size_t messageLength ; <nl> - <nl> - # ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - operator size_t ( ) const { return isValidCoding ? messageLength : 0 ; } <nl> - # endif <nl> - } ; <nl> - <nl> - / / ! interface for retrieving values given their names <nl> - / * ! \ note This class is used to safely pass a variable number of arbitrarily typed arguments to functions <nl> - and to read values from keys and crypto parameters . <nl> - \ note To obtain an object that implements NameValuePairs for the purpose of parameter <nl> - passing , use the MakeParameters ( ) function . <nl> - \ note To get a value from NameValuePairs , you need to know the name and the type of the value . <nl> - Call GetValueNames ( ) on a NameValuePairs object to obtain a list of value names that it supports . <nl> - Then look at the Name namespace documentation to see what the type of each value is , or <nl> - alternatively , call GetIntValue ( ) with the value name , and if the type is not int , a <nl> - ValueTypeMismatch exception will be thrown and you can get the actual type from the exception object . <nl> - * / <nl> - class CRYPTOPP_NO_VTABLE NameValuePairs <nl> - { <nl> - public : <nl> - virtual ~ NameValuePairs ( ) { } <nl> - <nl> - / / ! exception thrown when trying to retrieve a value using a different type than expected <nl> - class CRYPTOPP_DLL ValueTypeMismatch : public InvalidArgument <nl> - { <nl> - public : <nl> - ValueTypeMismatch ( const std : : string & name , const std : : type_info & stored , const std : : type_info & retrieving ) <nl> - : InvalidArgument ( " NameValuePairs : type mismatch for ' " + name + " ' , stored ' " + stored . name ( ) + " ' , trying to retrieve ' " + retrieving . name ( ) + " ' " ) <nl> - , m_stored ( stored ) , m_retrieving ( retrieving ) { } <nl> - <nl> - const std : : type_info & GetStoredTypeInfo ( ) const { return m_stored ; } <nl> - const std : : type_info & GetRetrievingTypeInfo ( ) const { return m_retrieving ; } <nl> - <nl> - private : <nl> - const std : : type_info & m_stored ; <nl> - const std : : type_info & m_retrieving ; <nl> - } ; <nl> - <nl> - / / ! get a copy of this object or a subobject of it <nl> - template < class T > <nl> - bool GetThisObject ( T & object ) const <nl> - { <nl> - return GetValue ( ( std : : string ( " ThisObject : " ) + typeid ( T ) . name ( ) ) . c_str ( ) , object ) ; <nl> - } <nl> - <nl> - / / ! get a pointer to this object , as a pointer to T <nl> - template < class T > <nl> - bool GetThisPointer ( T * & p ) const <nl> - { <nl> - return GetValue ( ( std : : string ( " ThisPointer : " ) + typeid ( T ) . name ( ) ) . c_str ( ) , p ) ; <nl> - } <nl> - <nl> - / / ! get a named value , returns true if the name exists <nl> - template < class T > <nl> - bool GetValue ( const char * name , T & value ) const <nl> - { <nl> - return GetVoidValue ( name , typeid ( T ) , & value ) ; <nl> - } <nl> - <nl> - / / ! get a named value , returns the default if the name doesn ' t exist <nl> - template < class T > <nl> - T GetValueWithDefault ( const char * name , T defaultValue ) const <nl> - { <nl> - GetValue ( name , defaultValue ) ; <nl> - return defaultValue ; <nl> - } <nl> - <nl> - / / ! get a list of value names that can be retrieved <nl> - CRYPTOPP_DLL std : : string GetValueNames ( ) const <nl> - { std : : string result ; GetValue ( " ValueNames " , result ) ; return result ; } <nl> - <nl> - / / ! get a named value with type int <nl> - / * ! used to ensure we don ' t accidentally try to get an unsigned int <nl> - or some other type when we mean int ( which is the most common case ) * / <nl> - CRYPTOPP_DLL bool GetIntValue ( const char * name , int & value ) const <nl> - { return GetValue ( name , value ) ; } <nl> - <nl> - / / ! get a named value with type int , with default <nl> - CRYPTOPP_DLL int GetIntValueWithDefault ( const char * name , int defaultValue ) const <nl> - { return GetValueWithDefault ( name , defaultValue ) ; } <nl> - <nl> - / / ! used by derived classes to check for type mismatch <nl> - CRYPTOPP_DLL static void CRYPTOPP_API ThrowIfTypeMismatch ( const char * name , const std : : type_info & stored , const std : : type_info & retrieving ) <nl> - { if ( stored ! = retrieving ) throw ValueTypeMismatch ( name , stored , retrieving ) ; } <nl> - <nl> - template < class T > <nl> - void GetRequiredParameter ( const char * className , const char * name , T & value ) const <nl> - { <nl> - if ( ! GetValue ( name , value ) ) <nl> - throw InvalidArgument ( std : : string ( className ) + " : missing required parameter ' " + name + " ' " ) ; <nl> - } <nl> - <nl> - CRYPTOPP_DLL void GetRequiredIntParameter ( const char * className , const char * name , int & value ) const <nl> - { <nl> - if ( ! GetIntValue ( name , value ) ) <nl> - throw InvalidArgument ( std : : string ( className ) + " : missing required parameter ' " + name + " ' " ) ; <nl> - } <nl> - <nl> - / / ! to be implemented by derived classes , users should use one of the above functions instead <nl> - CRYPTOPP_DLL virtual bool GetVoidValue ( const char * name , const std : : type_info & valueType , void * pValue ) const = 0 ; <nl> - } ; <nl> - <nl> - / / ! namespace containing value name definitions <nl> - / * ! value names , types and semantics : <nl> - <nl> - ThisObject : ClassName ( ClassName , copy of this object or a subobject ) <nl> - ThisPointer : ClassName ( const ClassName * , pointer to this object or a subobject ) <nl> - * / <nl> - DOCUMENTED_NAMESPACE_BEGIN ( Name ) <nl> - / / more names defined in argnames . h <nl> - DOCUMENTED_NAMESPACE_END <nl> - <nl> - / / ! empty set of name - value pairs <nl> - class CRYPTOPP_DLL NullNameValuePairs : public NameValuePairs <nl> - { <nl> - public : <nl> - bool GetVoidValue ( const char * name , const std : : type_info & valueType , void * pValue ) const { return false ; } <nl> - } ; <nl> - <nl> - / / ! _ <nl> - extern CRYPTOPP_DLL const NullNameValuePairs g_nullNameValuePairs ; <nl> - <nl> - / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - <nl> - / / ! interface for cloning objects , this is not implemented by most classes yet <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Clonable <nl> - { <nl> - public : <nl> - virtual ~ Clonable ( ) { } <nl> - / / ! this is not implemented by most classes yet <nl> - virtual Clonable * Clone ( ) const { throw NotImplemented ( " Clone ( ) is not implemented yet . " ) ; } / / TODO : make this = 0 <nl> - } ; <nl> - <nl> - / / ! interface for all crypto algorithms <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Algorithm : public Clonable <nl> - { <nl> - public : <nl> - / * ! When FIPS 140 - 2 compliance is enabled and checkSelfTestStatus = = true , <nl> - this constructor throws SelfTestFailure if the self test hasn ' t been run or fails . * / <nl> - Algorithm ( bool checkSelfTestStatus = true ) ; <nl> - / / ! returns name of this algorithm , not universally implemented yet <nl> - virtual std : : string AlgorithmName ( ) const { return " unknown " ; } <nl> - } ; <nl> - <nl> - / / ! keying interface for crypto algorithms that take byte strings as keys <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE SimpleKeyingInterface <nl> - { <nl> - public : <nl> - virtual ~ SimpleKeyingInterface ( ) { } <nl> - <nl> - / / ! returns smallest valid key length in bytes * / <nl> - virtual size_t MinKeyLength ( ) const = 0 ; <nl> - / / ! returns largest valid key length in bytes * / <nl> - virtual size_t MaxKeyLength ( ) const = 0 ; <nl> - / / ! returns default ( recommended ) key length in bytes * / <nl> - virtual size_t DefaultKeyLength ( ) const = 0 ; <nl> - <nl> - / / ! returns the smallest valid key length in bytes that is > = min ( n , GetMaxKeyLength ( ) ) <nl> - virtual size_t GetValidKeyLength ( size_t n ) const = 0 ; <nl> - <nl> - / / ! returns whether n is a valid key length <nl> - virtual bool IsValidKeyLength ( size_t n ) const <nl> - { return n = = GetValidKeyLength ( n ) ; } <nl> - <nl> - / / ! set or reset the key of this object <nl> - / * ! \ param params is used to specify Rounds , BlockSize , etc . * / <nl> - virtual void SetKey ( const byte * key , size_t length , const NameValuePairs & params = g_nullNameValuePairs ) ; <nl> - <nl> - / / ! calls SetKey ( ) with an NameValuePairs object that just specifies " Rounds " <nl> - void SetKeyWithRounds ( const byte * key , size_t length , int rounds ) ; <nl> - <nl> - / / ! calls SetKey ( ) with an NameValuePairs object that just specifies " IV " <nl> - void SetKeyWithIV ( const byte * key , size_t length , const byte * iv , size_t ivLength ) ; <nl> - <nl> - / / ! calls SetKey ( ) with an NameValuePairs object that just specifies " IV " <nl> - void SetKeyWithIV ( const byte * key , size_t length , const byte * iv ) <nl> - { SetKeyWithIV ( key , length , iv , IVSize ( ) ) ; } <nl> - <nl> - enum IV_Requirement { UNIQUE_IV = 0 , RANDOM_IV , UNPREDICTABLE_RANDOM_IV , INTERNALLY_GENERATED_IV , NOT_RESYNCHRONIZABLE } ; <nl> - / / ! returns the minimal requirement for secure IVs <nl> - virtual IV_Requirement IVRequirement ( ) const = 0 ; <nl> - <nl> - / / ! returns whether this object can be resynchronized ( i . e . supports initialization vectors ) <nl> - / * ! If this function returns true , and no IV is passed to SetKey ( ) and CanUseStructuredIVs ( ) = = true , an IV of all 0 ' s will be assumed . * / <nl> - bool IsResynchronizable ( ) const { return IVRequirement ( ) < NOT_RESYNCHRONIZABLE ; } <nl> - / / ! returns whether this object can use random IVs ( in addition to ones returned by GetNextIV ) <nl> - bool CanUseRandomIVs ( ) const { return IVRequirement ( ) < = UNPREDICTABLE_RANDOM_IV ; } <nl> - / / ! returns whether this object can use random but possibly predictable IVs ( in addition to ones returned by GetNextIV ) <nl> - bool CanUsePredictableIVs ( ) const { return IVRequirement ( ) < = RANDOM_IV ; } <nl> - / / ! returns whether this object can use structured IVs , for example a counter ( in addition to ones returned by GetNextIV ) <nl> - bool CanUseStructuredIVs ( ) const { return IVRequirement ( ) < = UNIQUE_IV ; } <nl> - <nl> - virtual unsigned int IVSize ( ) const { throw NotImplemented ( GetAlgorithm ( ) . AlgorithmName ( ) + " : this object doesn ' t support resynchronization " ) ; } <nl> - / / ! returns default length of IVs accepted by this object <nl> - unsigned int DefaultIVLength ( ) const { return IVSize ( ) ; } <nl> - / / ! returns minimal length of IVs accepted by this object <nl> - virtual unsigned int MinIVLength ( ) const { return IVSize ( ) ; } <nl> - / / ! returns maximal length of IVs accepted by this object <nl> - virtual unsigned int MaxIVLength ( ) const { return IVSize ( ) ; } <nl> - / / ! resynchronize with an IV . ivLength = - 1 means use IVSize ( ) <nl> - virtual void Resynchronize ( const byte * iv , int ivLength = - 1 ) { throw NotImplemented ( GetAlgorithm ( ) . AlgorithmName ( ) + " : this object doesn ' t support resynchronization " ) ; } <nl> - / / ! get a secure IV for the next message <nl> - / * ! This method should be called after you finish encrypting one message and are ready to start the next one . <nl> - After calling it , you must call SetKey ( ) or Resynchronize ( ) before using this object again . <nl> - This method is not implemented on decryption objects . * / <nl> - virtual void GetNextIV ( RandomNumberGenerator & rng , byte * IV ) ; <nl> - <nl> - protected : <nl> - virtual const Algorithm & GetAlgorithm ( ) const = 0 ; <nl> - virtual void UncheckedSetKey ( const byte * key , unsigned int length , const NameValuePairs & params ) = 0 ; <nl> - <nl> - void ThrowIfInvalidKeyLength ( size_t length ) ; <nl> - void ThrowIfResynchronizable ( ) ; / / to be called when no IV is passed <nl> - void ThrowIfInvalidIV ( const byte * iv ) ; / / check for NULL IV if it can ' t be used <nl> - size_t ThrowIfInvalidIVLength ( int size ) ; <nl> - const byte * GetIVAndThrowIfInvalid ( const NameValuePairs & params , size_t & size ) ; <nl> - inline void AssertValidKeyLength ( size_t length ) const <nl> - { assert ( IsValidKeyLength ( length ) ) ; } <nl> - } ; <nl> - <nl> - / / ! interface for the data processing part of block ciphers <nl> - <nl> - / * ! Classes derived from BlockTransformation are block ciphers <nl> - in ECB mode ( for example the DES : : Encryption class ) , which are stateless . <nl> - These classes should not be used directly , but only in combination with <nl> - a mode class ( see CipherModeDocumentation in modes . h ) . <nl> - * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BlockTransformation : public Algorithm <nl> - { <nl> - public : <nl> - / / ! encrypt or decrypt inBlock , xor with xorBlock , and write to outBlock <nl> - virtual void ProcessAndXorBlock ( const byte * inBlock , const byte * xorBlock , byte * outBlock ) const = 0 ; <nl> - <nl> - / / ! encrypt or decrypt one block <nl> - / * ! \ pre size of inBlock and outBlock = = BlockSize ( ) * / <nl> - void ProcessBlock ( const byte * inBlock , byte * outBlock ) const <nl> - { ProcessAndXorBlock ( inBlock , NULL , outBlock ) ; } <nl> - <nl> - / / ! encrypt or decrypt one block in place <nl> - void ProcessBlock ( byte * inoutBlock ) const <nl> - { ProcessAndXorBlock ( inoutBlock , NULL , inoutBlock ) ; } <nl> - <nl> - / / ! block size of the cipher in bytes <nl> - virtual unsigned int BlockSize ( ) const = 0 ; <nl> - <nl> - / / ! returns how inputs and outputs should be aligned for optimal performance <nl> - virtual unsigned int OptimalDataAlignment ( ) const ; <nl> - <nl> - / / ! returns true if this is a permutation ( i . e . there is an inverse transformation ) <nl> - virtual bool IsPermutation ( ) const { return true ; } <nl> - <nl> - / / ! returns true if this is an encryption object <nl> - virtual bool IsForwardTransformation ( ) const = 0 ; <nl> - <nl> - / / ! return number of blocks that can be processed in parallel , for bit - slicing implementations <nl> - virtual unsigned int OptimalNumberOfParallelBlocks ( ) const { return 1 ; } <nl> - <nl> - enum { BT_InBlockIsCounter = 1 , BT_DontIncrementInOutPointers = 2 , BT_XorInput = 4 , BT_ReverseDirection = 8 } FlagsForAdvancedProcessBlocks ; <nl> - <nl> - / / ! encrypt and xor blocks according to flags ( see FlagsForAdvancedProcessBlocks ) <nl> - / * ! / note If BT_InBlockIsCounter is set , last byte of inBlocks may be modified . * / <nl> - virtual size_t AdvancedProcessBlocks ( const byte * inBlocks , const byte * xorBlocks , byte * outBlocks , size_t length , word32 flags ) const ; <nl> - <nl> - inline CipherDir GetCipherDirection ( ) const { return IsForwardTransformation ( ) ? ENCRYPTION : DECRYPTION ; } <nl> - } ; <nl> - <nl> - / / ! interface for the data processing part of stream ciphers <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE StreamTransformation : public Algorithm <nl> - { <nl> - public : <nl> - / / ! return a reference to this object , <nl> - / * ! This function is useful for passing a temporary StreamTransformation object to a <nl> - function that takes a non - const reference . * / <nl> - StreamTransformation & Ref ( ) { return * this ; } <nl> - <nl> - / / ! returns block size , if input must be processed in blocks , otherwise 1 <nl> - virtual unsigned int MandatoryBlockSize ( ) const { return 1 ; } <nl> - <nl> - / / ! returns the input block size that is most efficient for this cipher <nl> - / * ! \ note optimal input length is n * OptimalBlockSize ( ) - GetOptimalBlockSizeUsed ( ) for any n > 0 * / <nl> - virtual unsigned int OptimalBlockSize ( ) const { return MandatoryBlockSize ( ) ; } <nl> - / / ! returns how much of the current block is used up <nl> - virtual unsigned int GetOptimalBlockSizeUsed ( ) const { return 0 ; } <nl> - <nl> - / / ! returns how input should be aligned for optimal performance <nl> - virtual unsigned int OptimalDataAlignment ( ) const ; <nl> - <nl> - / / ! encrypt or decrypt an array of bytes of specified length <nl> - / * ! \ note either inString = = outString , or they don ' t overlap * / <nl> - virtual void ProcessData ( byte * outString , const byte * inString , size_t length ) = 0 ; <nl> - <nl> - / / ! for ciphers where the last block of data is special , encrypt or decrypt the last block of data <nl> - / * ! For now the only use of this function is for CBC - CTS mode . * / <nl> - virtual void ProcessLastBlock ( byte * outString , const byte * inString , size_t length ) ; <nl> - / / ! returns the minimum size of the last block , 0 indicating the last block is not special <nl> - virtual unsigned int MinLastBlockSize ( ) const { return 0 ; } <nl> - <nl> - / / ! same as ProcessData ( inoutString , inoutString , length ) <nl> - inline void ProcessString ( byte * inoutString , size_t length ) <nl> - { ProcessData ( inoutString , inoutString , length ) ; } <nl> - / / ! same as ProcessData ( outString , inString , length ) <nl> - inline void ProcessString ( byte * outString , const byte * inString , size_t length ) <nl> - { ProcessData ( outString , inString , length ) ; } <nl> - / / ! implemented as { ProcessData ( & input , & input , 1 ) ; return input ; } <nl> - inline byte ProcessByte ( byte input ) <nl> - { ProcessData ( & input , & input , 1 ) ; return input ; } <nl> - <nl> - / / ! returns whether this cipher supports random access <nl> - virtual bool IsRandomAccess ( ) const = 0 ; <nl> - / / ! for random access ciphers , seek to an absolute position <nl> - virtual void Seek ( lword n ) <nl> - { <nl> - assert ( ! IsRandomAccess ( ) ) ; <nl> - throw NotImplemented ( " StreamTransformation : this object doesn ' t support random access " ) ; <nl> - } <nl> - <nl> - / / ! returns whether this transformation is self - inverting ( e . g . xor with a keystream ) <nl> - virtual bool IsSelfInverting ( ) const = 0 ; <nl> - / / ! returns whether this is an encryption object <nl> - virtual bool IsForwardTransformation ( ) const = 0 ; <nl> - } ; <nl> - <nl> - / / ! interface for hash functions and data processing part of MACs <nl> - <nl> - / * ! HashTransformation objects are stateful . They are created in an initial state , <nl> - change state as Update ( ) is called , and return to the initial <nl> - state when Final ( ) is called . This interface allows a large message to <nl> - be hashed in pieces by calling Update ( ) on each piece followed by <nl> - calling Final ( ) . <nl> - * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE HashTransformation : public Algorithm <nl> - { <nl> - public : <nl> - / / ! return a reference to this object , <nl> - / * ! This function is useful for passing a temporary HashTransformation object to a <nl> - function that takes a non - const reference . * / <nl> - HashTransformation & Ref ( ) { return * this ; } <nl> - <nl> - / / ! process more input <nl> - virtual void Update ( const byte * input , size_t length ) = 0 ; <nl> - <nl> - / / ! request space to write input into <nl> - virtual byte * CreateUpdateSpace ( size_t & size ) { size = 0 ; return NULL ; } <nl> - <nl> - / / ! compute hash for current message , then restart for a new message <nl> - / * ! \ pre size of digest = = DigestSize ( ) . * / <nl> - virtual void Final ( byte * digest ) <nl> - { TruncatedFinal ( digest , DigestSize ( ) ) ; } <nl> - <nl> - / / ! discard the current state , and restart with a new message <nl> - virtual void Restart ( ) <nl> - { TruncatedFinal ( NULL , 0 ) ; } <nl> - <nl> - / / ! size of the hash / digest / MAC returned by Final ( ) <nl> - virtual unsigned int DigestSize ( ) const = 0 ; <nl> - <nl> - / / ! same as DigestSize ( ) <nl> - unsigned int TagSize ( ) const { return DigestSize ( ) ; } <nl> - <nl> - <nl> - / / ! block size of underlying compression function , or 0 if not block based <nl> - virtual unsigned int BlockSize ( ) const { return 0 ; } <nl> - <nl> - / / ! input to Update ( ) should have length a multiple of this for optimal speed <nl> - virtual unsigned int OptimalBlockSize ( ) const { return 1 ; } <nl> - <nl> - / / ! returns how input should be aligned for optimal performance <nl> - virtual unsigned int OptimalDataAlignment ( ) const ; <nl> - <nl> - / / ! use this if your input is in one piece and you don ' t want to call Update ( ) and Final ( ) separately <nl> - virtual void CalculateDigest ( byte * digest , const byte * input , size_t length ) <nl> - { Update ( input , length ) ; Final ( digest ) ; } <nl> - <nl> - / / ! verify that digest is a valid digest for the current message , then reinitialize the object <nl> - / * ! Default implementation is to call Final ( ) and do a bitwise comparison <nl> - between its output and digest . * / <nl> - virtual bool Verify ( const byte * digest ) <nl> - { return TruncatedVerify ( digest , DigestSize ( ) ) ; } <nl> - <nl> - / / ! use this if your input is in one piece and you don ' t want to call Update ( ) and Verify ( ) separately <nl> - virtual bool VerifyDigest ( const byte * digest , const byte * input , size_t length ) <nl> - { Update ( input , length ) ; return Verify ( digest ) ; } <nl> - <nl> - / / ! truncated version of Final ( ) <nl> - virtual void TruncatedFinal ( byte * digest , size_t digestSize ) = 0 ; <nl> - <nl> - / / ! truncated version of CalculateDigest ( ) <nl> - virtual void CalculateTruncatedDigest ( byte * digest , size_t digestSize , const byte * input , size_t length ) <nl> - { Update ( input , length ) ; TruncatedFinal ( digest , digestSize ) ; } <nl> - <nl> - / / ! truncated version of Verify ( ) <nl> - virtual bool TruncatedVerify ( const byte * digest , size_t digestLength ) ; <nl> - <nl> - / / ! truncated version of VerifyDigest ( ) <nl> - virtual bool VerifyTruncatedDigest ( const byte * digest , size_t digestLength , const byte * input , size_t length ) <nl> - { Update ( input , length ) ; return TruncatedVerify ( digest , digestLength ) ; } <nl> - <nl> - protected : <nl> - void ThrowIfInvalidTruncatedSize ( size_t size ) const ; <nl> - } ; <nl> - <nl> - typedef HashTransformation HashFunction ; <nl> - <nl> - / / ! interface for one direction ( encryption or decryption ) of a block cipher <nl> - / * ! \ note These objects usually should not be used directly . See BlockTransformation for more details . * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BlockCipher : public SimpleKeyingInterface , public BlockTransformation <nl> - { <nl> - protected : <nl> - const Algorithm & GetAlgorithm ( ) const { return * this ; } <nl> - } ; <nl> - <nl> - / / ! interface for one direction ( encryption or decryption ) of a stream cipher or cipher mode <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE SymmetricCipher : public SimpleKeyingInterface , public StreamTransformation <nl> - { <nl> - protected : <nl> - const Algorithm & GetAlgorithm ( ) const { return * this ; } <nl> - } ; <nl> - <nl> - / / ! interface for message authentication codes <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE MessageAuthenticationCode : public SimpleKeyingInterface , public HashTransformation <nl> - { <nl> - protected : <nl> - const Algorithm & GetAlgorithm ( ) const { return * this ; } <nl> - } ; <nl> - <nl> - / / ! interface for for one direction ( encryption or decryption ) of a stream cipher or block cipher mode with authentication <nl> - / * ! The StreamTransformation part of this interface is used to encrypt / decrypt the data , and the MessageAuthenticationCode part of this <nl> - interface is used to input additional authenticated data ( AAD , which is MAC ' ed but not encrypted ) , and to generate / verify the MAC . * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AuthenticatedSymmetricCipher : public MessageAuthenticationCode , public StreamTransformation <nl> - { <nl> - public : <nl> - / / ! this indicates that a member function was called in the wrong state , for example trying to encrypt a message before having set the key or IV <nl> - class BadState : public Exception <nl> - { <nl> - public : <nl> - explicit BadState ( const std : : string & name , const char * message ) : Exception ( OTHER_ERROR , name + " : " + message ) { } <nl> - explicit BadState ( const std : : string & name , const char * function , const char * state ) : Exception ( OTHER_ERROR , name + " : " + function + " was called before " + state ) { } <nl> - } ; <nl> - <nl> - / / ! the maximum length of AAD that can be input before the encrypted data <nl> - virtual lword MaxHeaderLength ( ) const = 0 ; <nl> - / / ! the maximum length of encrypted data <nl> - virtual lword MaxMessageLength ( ) const = 0 ; <nl> - / / ! the maximum length of AAD that can be input after the encrypted data <nl> - virtual lword MaxFooterLength ( ) const { return 0 ; } <nl> - / / ! if this function returns true , SpecifyDataLengths ( ) must be called before attempting to input data <nl> - / * ! This is the case for some schemes , such as CCM . * / <nl> - virtual bool NeedsPrespecifiedDataLengths ( ) const { return false ; } <nl> - / / ! this function only needs to be called if NeedsPrespecifiedDataLengths ( ) returns true <nl> - void SpecifyDataLengths ( lword headerLength , lword messageLength , lword footerLength = 0 ) ; <nl> - / / ! encrypt and generate MAC in one call . will truncate MAC if macSize < TagSize ( ) <nl> - virtual void EncryptAndAuthenticate ( byte * ciphertext , byte * mac , size_t macSize , const byte * iv , int ivLength , const byte * header , size_t headerLength , const byte * message , size_t messageLength ) ; <nl> - / / ! decrypt and verify MAC in one call , returning true iff MAC is valid . will assume MAC is truncated if macLength < TagSize ( ) <nl> - virtual bool DecryptAndVerify ( byte * message , const byte * mac , size_t macLength , const byte * iv , int ivLength , const byte * header , size_t headerLength , const byte * ciphertext , size_t ciphertextLength ) ; <nl> - <nl> - / / redeclare this to avoid compiler ambiguity errors <nl> - virtual std : : string AlgorithmName ( ) const = 0 ; <nl> - <nl> - protected : <nl> - const Algorithm & GetAlgorithm ( ) const { return * static_cast < const MessageAuthenticationCode * > ( this ) ; } <nl> - virtual void UncheckedSpecifyDataLengths ( lword headerLength , lword messageLength , lword footerLength ) { } <nl> - } ; <nl> - <nl> - # ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - typedef SymmetricCipher StreamCipher ; <nl> - # endif <nl> - <nl> - / / ! interface for random number generators <nl> - / * ! All return values are uniformly distributed over the range specified . <nl> - * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE RandomNumberGenerator : public Algorithm <nl> - { <nl> - public : <nl> - / / ! update RNG state with additional unpredictable values <nl> - virtual void IncorporateEntropy ( const byte * input , size_t length ) { throw NotImplemented ( " RandomNumberGenerator : IncorporateEntropy not implemented " ) ; } <nl> - <nl> - / / ! returns true if IncorporateEntropy is implemented <nl> - virtual bool CanIncorporateEntropy ( ) const { return false ; } <nl> - <nl> - / / ! generate new random byte and return it <nl> - virtual byte GenerateByte ( ) ; <nl> - <nl> - / / ! generate new random bit and return it <nl> - / * ! Default implementation is to call GenerateByte ( ) and return its lowest bit . * / <nl> - virtual unsigned int GenerateBit ( ) ; <nl> - <nl> - / / ! generate a random 32 bit word in the range min to max , inclusive <nl> - virtual word32 GenerateWord32 ( word32 a = 0 , word32 b = 0xffffffffL ) ; <nl> - <nl> - / / ! generate random array of bytes <nl> - virtual void GenerateBlock ( byte * output , size_t size ) ; <nl> - <nl> - / / ! generate and discard n bytes <nl> - virtual void DiscardBytes ( size_t n ) ; <nl> - <nl> - / / ! generate random bytes as input to a BufferedTransformation <nl> - virtual void GenerateIntoBufferedTransformation ( BufferedTransformation & target , const std : : string & channel , lword length ) ; <nl> - <nl> - / / ! randomly shuffle the specified array , resulting permutation is uniformly distributed <nl> - template < class IT > void Shuffle ( IT begin , IT end ) <nl> - { <nl> - for ( ; begin ! = end ; + + begin ) <nl> - std : : iter_swap ( begin , begin + GenerateWord32 ( 0 , end - begin - 1 ) ) ; <nl> - } <nl> - <nl> - # ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - byte GetByte ( ) { return GenerateByte ( ) ; } <nl> - unsigned int GetBit ( ) { return GenerateBit ( ) ; } <nl> - word32 GetLong ( word32 a = 0 , word32 b = 0xffffffffL ) { return GenerateWord32 ( a , b ) ; } <nl> - word16 GetShort ( word16 a = 0 , word16 b = 0xffff ) { return ( word16 ) GenerateWord32 ( a , b ) ; } <nl> - void GetBlock ( byte * output , size_t size ) { GenerateBlock ( output , size ) ; } <nl> - # endif <nl> - } ; <nl> - <nl> - / / ! returns a reference that can be passed to functions that ask for a RNG but doesn ' t actually use it <nl> - CRYPTOPP_DLL RandomNumberGenerator & CRYPTOPP_API NullRNG ( ) ; <nl> - <nl> - class WaitObjectContainer ; <nl> - class CallStack ; <nl> - <nl> - / / ! interface for objects that you can wait for <nl> - <nl> - class CRYPTOPP_NO_VTABLE Waitable <nl> - { <nl> - public : <nl> - virtual ~ Waitable ( ) { } <nl> - <nl> - / / ! maximum number of wait objects that this object can return <nl> - virtual unsigned int GetMaxWaitObjectCount ( ) const = 0 ; <nl> - / / ! put wait objects into container <nl> - / * ! \ param callStack is used for tracing no wait loops , example : <nl> - something . GetWaitObjects ( c , CallStack ( " my func after X " , 0 ) ) ; <nl> - - or in an outer GetWaitObjects ( ) method that itself takes a callStack parameter : <nl> - innerThing . GetWaitObjects ( c , CallStack ( " MyClass : : GetWaitObjects at X " , & callStack ) ) ; * / <nl> - virtual void GetWaitObjects ( WaitObjectContainer & container , CallStack const & callStack ) = 0 ; <nl> - / / ! wait on this object <nl> - / * ! same as creating an empty container , calling GetWaitObjects ( ) , and calling Wait ( ) on the container * / <nl> - bool Wait ( unsigned long milliseconds , CallStack const & callStack ) ; <nl> - } ; <nl> - <nl> - / / ! the default channel for BufferedTransformation , equal to the empty string <nl> - extern CRYPTOPP_DLL const std : : string DEFAULT_CHANNEL ; <nl> - <nl> - / / ! channel for additional authenticated data , equal to " AAD " <nl> - extern CRYPTOPP_DLL const std : : string AAD_CHANNEL ; <nl> - <nl> - / / ! interface for buffered transformations <nl> - <nl> - / * ! BufferedTransformation is a generalization of BlockTransformation , <nl> - StreamTransformation , and HashTransformation . <nl> - <nl> - A buffered transformation is an object that takes a stream of bytes <nl> - as input ( this may be done in stages ) , does some computation on them , and <nl> - then places the result into an internal buffer for later retrieval . Any <nl> - partial result already in the output buffer is not modified by further <nl> - input . <nl> - <nl> - If a method takes a " blocking " parameter , and you <nl> - pass " false " for it , the method will return before all input has been processed if <nl> - the input cannot be processed without waiting ( for network buffers to become available , for example ) . <nl> - In this case the method will return true <nl> - or a non - zero integer value . When this happens you must continue to call the method with the same <nl> - parameters until it returns false or zero , before calling any other method on it or <nl> - attached BufferedTransformation . The integer return value in this case is approximately <nl> - the number of bytes left to be processed , and can be used to implement a progress bar . <nl> - <nl> - For functions that take a " propagation " parameter , propagation ! = 0 means pass on the signal to attached <nl> - BufferedTransformation objects , with propagation decremented at each step until it reaches 0 . <nl> - - 1 means unlimited propagation . <nl> - <nl> - \ nosubgrouping <nl> - * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BufferedTransformation : public Algorithm , public Waitable <nl> - { <nl> - public : <nl> - / / placed up here for CW8 <nl> - static const std : : string & NULL_CHANNEL ; / / same as DEFAULT_CHANNEL , for backwards compatibility <nl> - <nl> - BufferedTransformation ( ) : Algorithm ( false ) { } <nl> - <nl> - / / ! return a reference to this object <nl> - / * ! This function is useful for passing a temporary BufferedTransformation object to a <nl> - function that takes a non - const reference . * / <nl> - BufferedTransformation & Ref ( ) { return * this ; } <nl> - <nl> - / / ! \ name INPUT <nl> - / / @ { <nl> - / / ! input a byte for processing <nl> - size_t Put ( byte inByte , bool blocking = true ) <nl> - { return Put ( & inByte , 1 , blocking ) ; } <nl> - / / ! input multiple bytes <nl> - size_t Put ( const byte * inString , size_t length , bool blocking = true ) <nl> - { return Put2 ( inString , length , 0 , blocking ) ; } <nl> - <nl> - / / ! input a 16 - bit word <nl> - size_t PutWord16 ( word16 value , ByteOrder order = BIG_ENDIAN_ORDER , bool blocking = true ) ; <nl> - / / ! input a 32 - bit word <nl> - size_t PutWord32 ( word32 value , ByteOrder order = BIG_ENDIAN_ORDER , bool blocking = true ) ; <nl> - <nl> - / / ! request space which can be written into by the caller , and then used as input to Put ( ) <nl> - / * ! \ param size is requested size ( as a hint ) for input , and size of the returned space for output * / <nl> - / * ! \ note The purpose of this method is to help avoid doing extra memory allocations . * / <nl> - virtual byte * CreatePutSpace ( size_t & size ) { size = 0 ; return NULL ; } <nl> - <nl> - virtual bool CanModifyInput ( ) const { return false ; } <nl> - <nl> - / / ! input multiple bytes that may be modified by callee <nl> - size_t PutModifiable ( byte * inString , size_t length , bool blocking = true ) <nl> - { return PutModifiable2 ( inString , length , 0 , blocking ) ; } <nl> - <nl> - bool MessageEnd ( int propagation = - 1 , bool blocking = true ) <nl> - { return ! ! Put2 ( NULL , 0 , propagation < 0 ? - 1 : propagation + 1 , blocking ) ; } <nl> - size_t PutMessageEnd ( const byte * inString , size_t length , int propagation = - 1 , bool blocking = true ) <nl> - { return Put2 ( inString , length , propagation < 0 ? - 1 : propagation + 1 , blocking ) ; } <nl> - <nl> - / / ! input multiple bytes for blocking or non - blocking processing <nl> - / * ! \ param messageEnd means how many filters to signal MessageEnd to , including this one * / <nl> - virtual size_t Put2 ( const byte * inString , size_t length , int messageEnd , bool blocking ) = 0 ; <nl> - / / ! input multiple bytes that may be modified by callee for blocking or non - blocking processing <nl> - / * ! \ param messageEnd means how many filters to signal MessageEnd to , including this one * / <nl> - virtual size_t PutModifiable2 ( byte * inString , size_t length , int messageEnd , bool blocking ) <nl> - { return Put2 ( inString , length , messageEnd , blocking ) ; } <nl> - <nl> - / / ! thrown by objects that have not implemented nonblocking input processing <nl> - struct BlockingInputOnly : public NotImplemented <nl> - { BlockingInputOnly ( const std : : string & s ) : NotImplemented ( s + " : Nonblocking input is not implemented by this object . " ) { } } ; <nl> - / / @ } <nl> - <nl> - / / ! \ name WAITING <nl> - / / @ { <nl> - unsigned int GetMaxWaitObjectCount ( ) const ; <nl> - void GetWaitObjects ( WaitObjectContainer & container , CallStack const & callStack ) ; <nl> - / / @ } <nl> - <nl> - / / ! \ name SIGNALS <nl> - / / @ { <nl> - virtual void IsolatedInitialize ( const NameValuePairs & parameters ) { throw NotImplemented ( " BufferedTransformation : this object can ' t be reinitialized " ) ; } <nl> - virtual bool IsolatedFlush ( bool hardFlush , bool blocking ) = 0 ; <nl> - virtual bool IsolatedMessageSeriesEnd ( bool blocking ) { return false ; } <nl> - <nl> - / / ! initialize or reinitialize this object <nl> - virtual void Initialize ( const NameValuePairs & parameters = g_nullNameValuePairs , int propagation = - 1 ) ; <nl> - / / ! flush buffered input and / or output <nl> - / * ! \ param hardFlush is used to indicate whether all data should be flushed <nl> - \ note Hard flushes must be used with care . It means try to process and output everything , even if <nl> - there may not be enough data to complete the action . For example , hard flushing a HexDecoder would <nl> - cause an error if you do it after inputing an odd number of hex encoded characters . <nl> - For some types of filters , for example ZlibDecompressor , hard flushes can only <nl> - be done at " synchronization points " . These synchronization points are positions in the data <nl> - stream that are created by hard flushes on the corresponding reverse filters , in this <nl> - example ZlibCompressor . This is useful when zlib compressed data is moved across a <nl> - network in packets and compression state is preserved across packets , as in the ssh2 protocol . <nl> - * / <nl> - virtual bool Flush ( bool hardFlush , int propagation = - 1 , bool blocking = true ) ; <nl> - / / ! mark end of a series of messages <nl> - / * ! There should be a MessageEnd immediately before MessageSeriesEnd . * / <nl> - virtual bool MessageSeriesEnd ( int propagation = - 1 , bool blocking = true ) ; <nl> - <nl> - / / ! set propagation of automatically generated and transferred signals <nl> - / * ! propagation = = 0 means do not automaticly generate signals * / <nl> - virtual void SetAutoSignalPropagation ( int propagation ) { } <nl> - <nl> - / / ! <nl> - virtual int GetAutoSignalPropagation ( ) const { return 0 ; } <nl> - public : <nl> - <nl> - # ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - void Close ( ) { MessageEnd ( ) ; } <nl> - # endif <nl> - / / @ } <nl> - <nl> - / / ! \ name RETRIEVAL OF ONE MESSAGE <nl> - / / @ { <nl> - / / ! returns number of bytes that is currently ready for retrieval <nl> - / * ! All retrieval functions return the actual number of bytes <nl> - retrieved , which is the lesser of the request number and <nl> - MaxRetrievable ( ) . * / <nl> - virtual lword MaxRetrievable ( ) const ; <nl> - <nl> - / / ! returns whether any bytes are currently ready for retrieval <nl> - virtual bool AnyRetrievable ( ) const ; <nl> - <nl> - / / ! try to retrieve a single byte <nl> - virtual size_t Get ( byte & outByte ) ; <nl> - / / ! try to retrieve multiple bytes <nl> - virtual size_t Get ( byte * outString , size_t getMax ) ; <nl> - <nl> - / / ! peek at the next byte without removing it from the output buffer <nl> - virtual size_t Peek ( byte & outByte ) const ; <nl> - / / ! peek at multiple bytes without removing them from the output buffer <nl> - virtual size_t Peek ( byte * outString , size_t peekMax ) const ; <nl> - <nl> - / / ! try to retrieve a 16 - bit word <nl> - size_t GetWord16 ( word16 & value , ByteOrder order = BIG_ENDIAN_ORDER ) ; <nl> - / / ! try to retrieve a 32 - bit word <nl> - size_t GetWord32 ( word32 & value , ByteOrder order = BIG_ENDIAN_ORDER ) ; <nl> - <nl> - / / ! try to peek at a 16 - bit word <nl> - size_t PeekWord16 ( word16 & value , ByteOrder order = BIG_ENDIAN_ORDER ) const ; <nl> - / / ! try to peek at a 32 - bit word <nl> - size_t PeekWord32 ( word32 & value , ByteOrder order = BIG_ENDIAN_ORDER ) const ; <nl> - <nl> - / / ! move transferMax bytes of the buffered output to target as input <nl> - lword TransferTo ( BufferedTransformation & target , lword transferMax = LWORD_MAX , const std : : string & channel = DEFAULT_CHANNEL ) <nl> - { TransferTo2 ( target , transferMax , channel ) ; return transferMax ; } <nl> - <nl> - / / ! discard skipMax bytes from the output buffer <nl> - virtual lword Skip ( lword skipMax = LWORD_MAX ) ; <nl> - <nl> - / / ! copy copyMax bytes of the buffered output to target as input <nl> - lword CopyTo ( BufferedTransformation & target , lword copyMax = LWORD_MAX , const std : : string & channel = DEFAULT_CHANNEL ) const <nl> - { return CopyRangeTo ( target , 0 , copyMax , channel ) ; } <nl> - <nl> - / / ! copy copyMax bytes of the buffered output , starting at position ( relative to current position ) , to target as input <nl> - lword CopyRangeTo ( BufferedTransformation & target , lword position , lword copyMax = LWORD_MAX , const std : : string & channel = DEFAULT_CHANNEL ) const <nl> - { lword i = position ; CopyRangeTo2 ( target , i , i + copyMax , channel ) ; return i - position ; } <nl> - <nl> - # ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - unsigned long MaxRetrieveable ( ) const { return MaxRetrievable ( ) ; } <nl> - # endif <nl> - / / @ } <nl> - <nl> - / / ! \ name RETRIEVAL OF MULTIPLE MESSAGES <nl> - / / @ { <nl> - / / ! <nl> - virtual lword TotalBytesRetrievable ( ) const ; <nl> - / / ! number of times MessageEnd ( ) has been received minus messages retrieved or skipped <nl> - virtual unsigned int NumberOfMessages ( ) const ; <nl> - / / ! returns true if NumberOfMessages ( ) > 0 <nl> - virtual bool AnyMessages ( ) const ; <nl> - / / ! start retrieving the next message <nl> - / * ! <nl> - Returns false if no more messages exist or this message <nl> - is not completely retrieved . <nl> - * / <nl> - virtual bool GetNextMessage ( ) ; <nl> - / / ! skip count number of messages <nl> - virtual unsigned int SkipMessages ( unsigned int count = UINT_MAX ) ; <nl> - / / ! <nl> - unsigned int TransferMessagesTo ( BufferedTransformation & target , unsigned int count = UINT_MAX , const std : : string & channel = DEFAULT_CHANNEL ) <nl> - { TransferMessagesTo2 ( target , count , channel ) ; return count ; } <nl> - / / ! <nl> - unsigned int CopyMessagesTo ( BufferedTransformation & target , unsigned int count = UINT_MAX , const std : : string & channel = DEFAULT_CHANNEL ) const ; <nl> - <nl> - / / ! <nl> - virtual void SkipAll ( ) ; <nl> - / / ! <nl> - void TransferAllTo ( BufferedTransformation & target , const std : : string & channel = DEFAULT_CHANNEL ) <nl> - { TransferAllTo2 ( target , channel ) ; } <nl> - / / ! <nl> - void CopyAllTo ( BufferedTransformation & target , const std : : string & channel = DEFAULT_CHANNEL ) const ; <nl> - <nl> - virtual bool GetNextMessageSeries ( ) { return false ; } <nl> - virtual unsigned int NumberOfMessagesInThisSeries ( ) const { return NumberOfMessages ( ) ; } <nl> - virtual unsigned int NumberOfMessageSeries ( ) const { return 0 ; } <nl> - / / @ } <nl> - <nl> - / / ! \ name NON - BLOCKING TRANSFER OF OUTPUT <nl> - / / @ { <nl> - / / ! upon return , byteCount contains number of bytes that have finished being transfered , and returns the number of bytes left in the current transfer block <nl> - virtual size_t TransferTo2 ( BufferedTransformation & target , lword & byteCount , const std : : string & channel = DEFAULT_CHANNEL , bool blocking = true ) = 0 ; <nl> - / / ! upon return , begin contains the start position of data yet to be finished copying , and returns the number of bytes left in the current transfer block <nl> - virtual size_t CopyRangeTo2 ( BufferedTransformation & target , lword & begin , lword end = LWORD_MAX , const std : : string & channel = DEFAULT_CHANNEL , bool blocking = true ) const = 0 ; <nl> - / / ! upon return , messageCount contains number of messages that have finished being transfered , and returns the number of bytes left in the current transfer block <nl> - size_t TransferMessagesTo2 ( BufferedTransformation & target , unsigned int & messageCount , const std : : string & channel = DEFAULT_CHANNEL , bool blocking = true ) ; <nl> - / / ! returns the number of bytes left in the current transfer block <nl> - size_t TransferAllTo2 ( BufferedTransformation & target , const std : : string & channel = DEFAULT_CHANNEL , bool blocking = true ) ; <nl> - / / @ } <nl> - <nl> - / / ! \ name CHANNELS <nl> - / / @ { <nl> - struct NoChannelSupport : public NotImplemented <nl> - { NoChannelSupport ( const std : : string & name ) : NotImplemented ( name + " : this object doesn ' t support multiple channels " ) { } } ; <nl> - struct InvalidChannelName : public InvalidArgument <nl> - { InvalidChannelName ( const std : : string & name , const std : : string & channel ) : InvalidArgument ( name + " : unexpected channel name \ " " + channel + " \ " " ) { } } ; <nl> - <nl> - size_t ChannelPut ( const std : : string & channel , byte inByte , bool blocking = true ) <nl> - { return ChannelPut ( channel , & inByte , 1 , blocking ) ; } <nl> - size_t ChannelPut ( const std : : string & channel , const byte * inString , size_t length , bool blocking = true ) <nl> - { return ChannelPut2 ( channel , inString , length , 0 , blocking ) ; } <nl> - <nl> - size_t ChannelPutModifiable ( const std : : string & channel , byte * inString , size_t length , bool blocking = true ) <nl> - { return ChannelPutModifiable2 ( channel , inString , length , 0 , blocking ) ; } <nl> - <nl> - size_t ChannelPutWord16 ( const std : : string & channel , word16 value , ByteOrder order = BIG_ENDIAN_ORDER , bool blocking = true ) ; <nl> - size_t ChannelPutWord32 ( const std : : string & channel , word32 value , ByteOrder order = BIG_ENDIAN_ORDER , bool blocking = true ) ; <nl> - <nl> - bool ChannelMessageEnd ( const std : : string & channel , int propagation = - 1 , bool blocking = true ) <nl> - { return ! ! ChannelPut2 ( channel , NULL , 0 , propagation < 0 ? - 1 : propagation + 1 , blocking ) ; } <nl> - size_t ChannelPutMessageEnd ( const std : : string & channel , const byte * inString , size_t length , int propagation = - 1 , bool blocking = true ) <nl> - { return ChannelPut2 ( channel , inString , length , propagation < 0 ? - 1 : propagation + 1 , blocking ) ; } <nl> - <nl> - virtual byte * ChannelCreatePutSpace ( const std : : string & channel , size_t & size ) ; <nl> - <nl> - virtual size_t ChannelPut2 ( const std : : string & channel , const byte * begin , size_t length , int messageEnd , bool blocking ) ; <nl> - virtual size_t ChannelPutModifiable2 ( const std : : string & channel , byte * begin , size_t length , int messageEnd , bool blocking ) ; <nl> - <nl> - virtual bool ChannelFlush ( const std : : string & channel , bool hardFlush , int propagation = - 1 , bool blocking = true ) ; <nl> - virtual bool ChannelMessageSeriesEnd ( const std : : string & channel , int propagation = - 1 , bool blocking = true ) ; <nl> - <nl> - virtual void SetRetrievalChannel ( const std : : string & channel ) ; <nl> - / / @ } <nl> - <nl> - / / ! \ name ATTACHMENT <nl> - / * ! Some BufferedTransformation objects ( e . g . Filter objects ) <nl> - allow other BufferedTransformation objects to be attached . When <nl> - this is done , the first object instead of buffering its output , <nl> - sents that output to the attached object as input . The entire <nl> - attachment chain is deleted when the anchor object is destructed . <nl> - * / <nl> - / / @ { <nl> - / / ! returns whether this object allows attachment <nl> - virtual bool Attachable ( ) { return false ; } <nl> - / / ! returns the object immediately attached to this object or NULL for no attachment <nl> - virtual BufferedTransformation * AttachedTransformation ( ) { assert ( ! Attachable ( ) ) ; return 0 ; } <nl> - / / ! <nl> - virtual const BufferedTransformation * AttachedTransformation ( ) const <nl> - { return const_cast < BufferedTransformation * > ( this ) - > AttachedTransformation ( ) ; } <nl> - / / ! delete the current attachment chain and replace it with newAttachment <nl> - virtual void Detach ( BufferedTransformation * newAttachment = 0 ) <nl> - { assert ( ! Attachable ( ) ) ; throw NotImplemented ( " BufferedTransformation : this object is not attachable " ) ; } <nl> - / / ! add newAttachment to the end of attachment chain <nl> - virtual void Attach ( BufferedTransformation * newAttachment ) ; <nl> - / / @ } <nl> - <nl> - protected : <nl> - static int DecrementPropagation ( int propagation ) <nl> - { return propagation ! = 0 ? propagation - 1 : 0 ; } <nl> - <nl> - private : <nl> - byte m_buf [ 4 ] ; / / for ChannelPutWord16 and ChannelPutWord32 , to ensure buffer isn ' t deallocated before non - blocking operation completes <nl> - } ; <nl> - <nl> - / / ! returns a reference to a BufferedTransformation object that discards all input <nl> - BufferedTransformation & TheBitBucket ( ) ; <nl> - <nl> - / / ! interface for crypto material , such as public and private keys , and crypto parameters <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CryptoMaterial : public NameValuePairs <nl> - { <nl> - public : <nl> - / / ! exception thrown when invalid crypto material is detected <nl> - class CRYPTOPP_DLL InvalidMaterial : public InvalidDataFormat <nl> - { <nl> - public : <nl> - explicit InvalidMaterial ( const std : : string & s ) : InvalidDataFormat ( s ) { } <nl> - } ; <nl> - <nl> - / / ! assign values from source to this object <nl> - / * ! \ note This function can be used to create a public key from a private key . * / <nl> - virtual void AssignFrom ( const NameValuePairs & source ) = 0 ; <nl> - <nl> - / / ! check this object for errors <nl> - / * ! \ param level denotes the level of thoroughness : <nl> - 0 - using this object won ' t cause a crash or exception ( rng is ignored ) <nl> - 1 - this object will probably function ( encrypt , sign , etc . ) correctly ( but may not check for weak keys and such ) <nl> - 2 - make sure this object will function correctly , and do reasonable security checks <nl> - 3 - do checks that may take a long time <nl> - \ return true if the tests pass * / <nl> - virtual bool Validate ( RandomNumberGenerator & rng , unsigned int level ) const = 0 ; <nl> - <nl> - / / ! throws InvalidMaterial if this object fails Validate ( ) test <nl> - virtual void ThrowIfInvalid ( RandomNumberGenerator & rng , unsigned int level ) const <nl> - { if ( ! Validate ( rng , level ) ) throw InvalidMaterial ( " CryptoMaterial : this object contains invalid values " ) ; } <nl> - <nl> - / / virtual std : : vector < std : : string > GetSupportedFormats ( bool includeSaveOnly = false , bool includeLoadOnly = false ) ; <nl> - <nl> - / / ! save key into a BufferedTransformation <nl> - virtual void Save ( BufferedTransformation & bt ) const <nl> - { throw NotImplemented ( " CryptoMaterial : this object does not support saving " ) ; } <nl> - <nl> - / / ! load key from a BufferedTransformation <nl> - / * ! \ throws KeyingErr if decode fails <nl> - \ note Generally does not check that the key is valid . <nl> - Call ValidateKey ( ) or ThrowIfInvalidKey ( ) to check that . * / <nl> - virtual void Load ( BufferedTransformation & bt ) <nl> - { throw NotImplemented ( " CryptoMaterial : this object does not support loading " ) ; } <nl> - <nl> - / / ! \ return whether this object supports precomputation <nl> - virtual bool SupportsPrecomputation ( ) const { return false ; } <nl> - / / ! do precomputation <nl> - / * ! The exact semantics of Precompute ( ) is varies , but <nl> - typically it means calculate a table of n objects <nl> - that can be used later to speed up computation . * / <nl> - virtual void Precompute ( unsigned int n ) <nl> - { assert ( ! SupportsPrecomputation ( ) ) ; throw NotImplemented ( " CryptoMaterial : this object does not support precomputation " ) ; } <nl> - / / ! retrieve previously saved precomputation <nl> - virtual void LoadPrecomputation ( BufferedTransformation & storedPrecomputation ) <nl> - { assert ( ! SupportsPrecomputation ( ) ) ; throw NotImplemented ( " CryptoMaterial : this object does not support precomputation " ) ; } <nl> - / / ! save precomputation for later use <nl> - virtual void SavePrecomputation ( BufferedTransformation & storedPrecomputation ) const <nl> - { assert ( ! SupportsPrecomputation ( ) ) ; throw NotImplemented ( " CryptoMaterial : this object does not support precomputation " ) ; } <nl> - <nl> - / / for internal library use <nl> - void DoQuickSanityCheck ( ) const { ThrowIfInvalid ( NullRNG ( ) , 0 ) ; } <nl> - <nl> - # if ( defined ( __SUNPRO_CC ) & & __SUNPRO_CC < 0x590 ) <nl> - / / Sun Studio 11 / CC 5 . 8 workaround : it generates incorrect code when casting to an empty virtual base class <nl> - char m_sunCCworkaround ; <nl> - # endif <nl> - } ; <nl> - <nl> - / / ! interface for generatable crypto material , such as private keys and crypto parameters <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE GeneratableCryptoMaterial : virtual public CryptoMaterial <nl> - { <nl> - public : <nl> - / / ! generate a random key or crypto parameters <nl> - / * ! \ throws KeyingErr if algorithm parameters are invalid , or if a key can ' t be generated <nl> - ( e . g . , if this is a public key object ) * / <nl> - virtual void GenerateRandom ( RandomNumberGenerator & rng , const NameValuePairs & params = g_nullNameValuePairs ) <nl> - { throw NotImplemented ( " GeneratableCryptoMaterial : this object does not support key / parameter generation " ) ; } <nl> - <nl> - / / ! calls the above function with a NameValuePairs object that just specifies " KeySize " <nl> - void GenerateRandomWithKeySize ( RandomNumberGenerator & rng , unsigned int keySize ) ; <nl> - } ; <nl> - <nl> - / / ! interface for public keys <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PublicKey : virtual public CryptoMaterial <nl> - { <nl> - } ; <nl> - <nl> - / / ! interface for private keys <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PrivateKey : public GeneratableCryptoMaterial <nl> - { <nl> - } ; <nl> - <nl> - / / ! interface for crypto prameters <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CryptoParameters : public GeneratableCryptoMaterial <nl> - { <nl> - } ; <nl> - <nl> - / / ! interface for asymmetric algorithms <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AsymmetricAlgorithm : public Algorithm <nl> - { <nl> - public : <nl> - / / ! returns a reference to the crypto material used by this object <nl> - virtual CryptoMaterial & AccessMaterial ( ) = 0 ; <nl> - / / ! returns a const reference to the crypto material used by this object <nl> - virtual const CryptoMaterial & GetMaterial ( ) const = 0 ; <nl> - <nl> - / / ! for backwards compatibility , calls AccessMaterial ( ) . Load ( bt ) <nl> - void BERDecode ( BufferedTransformation & bt ) <nl> - { AccessMaterial ( ) . Load ( bt ) ; } <nl> - / / ! for backwards compatibility , calls GetMaterial ( ) . Save ( bt ) <nl> - void DEREncode ( BufferedTransformation & bt ) const <nl> - { GetMaterial ( ) . Save ( bt ) ; } <nl> - } ; <nl> - <nl> - / / ! interface for asymmetric algorithms using public keys <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PublicKeyAlgorithm : public AsymmetricAlgorithm <nl> - { <nl> - public : <nl> - / / VC60 workaround : no co - variant return type <nl> - CryptoMaterial & AccessMaterial ( ) { return AccessPublicKey ( ) ; } <nl> - const CryptoMaterial & GetMaterial ( ) const { return GetPublicKey ( ) ; } <nl> - <nl> - virtual PublicKey & AccessPublicKey ( ) = 0 ; <nl> - virtual const PublicKey & GetPublicKey ( ) const { return const_cast < PublicKeyAlgorithm * > ( this ) - > AccessPublicKey ( ) ; } <nl> - } ; <nl> - <nl> - / / ! interface for asymmetric algorithms using private keys <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PrivateKeyAlgorithm : public AsymmetricAlgorithm <nl> - { <nl> - public : <nl> - CryptoMaterial & AccessMaterial ( ) { return AccessPrivateKey ( ) ; } <nl> - const CryptoMaterial & GetMaterial ( ) const { return GetPrivateKey ( ) ; } <nl> - <nl> - virtual PrivateKey & AccessPrivateKey ( ) = 0 ; <nl> - virtual const PrivateKey & GetPrivateKey ( ) const { return const_cast < PrivateKeyAlgorithm * > ( this ) - > AccessPrivateKey ( ) ; } <nl> - } ; <nl> - <nl> - / / ! interface for key agreement algorithms <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE KeyAgreementAlgorithm : public AsymmetricAlgorithm <nl> - { <nl> - public : <nl> - CryptoMaterial & AccessMaterial ( ) { return AccessCryptoParameters ( ) ; } <nl> - const CryptoMaterial & GetMaterial ( ) const { return GetCryptoParameters ( ) ; } <nl> - <nl> - virtual CryptoParameters & AccessCryptoParameters ( ) = 0 ; <nl> - virtual const CryptoParameters & GetCryptoParameters ( ) const { return const_cast < KeyAgreementAlgorithm * > ( this ) - > AccessCryptoParameters ( ) ; } <nl> - } ; <nl> - <nl> - / / ! interface for public - key encryptors and decryptors <nl> - <nl> - / * ! This class provides an interface common to encryptors and decryptors <nl> - for querying their plaintext and ciphertext lengths . <nl> - * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_CryptoSystem <nl> - { <nl> - public : <nl> - virtual ~ PK_CryptoSystem ( ) { } <nl> - <nl> - / / ! maximum length of plaintext for a given ciphertext length <nl> - / * ! \ note This function returns 0 if ciphertextLength is not valid ( too long or too short ) . * / <nl> - virtual size_t MaxPlaintextLength ( size_t ciphertextLength ) const = 0 ; <nl> - <nl> - / / ! calculate length of ciphertext given length of plaintext <nl> - / * ! \ note This function returns 0 if plaintextLength is not valid ( too long ) . * / <nl> - virtual size_t CiphertextLength ( size_t plaintextLength ) const = 0 ; <nl> - <nl> - / / ! this object supports the use of the parameter with the given name <nl> - / * ! some possible parameter names : EncodingParameters , KeyDerivationParameters * / <nl> - virtual bool ParameterSupported ( const char * name ) const = 0 ; <nl> - <nl> - / / ! return fixed ciphertext length , if one exists , otherwise return 0 <nl> - / * ! \ note " Fixed " here means length of ciphertext does not depend on length of plaintext . <nl> - It usually does depend on the key length . * / <nl> - virtual size_t FixedCiphertextLength ( ) const { return 0 ; } <nl> - <nl> - / / ! return maximum plaintext length given the fixed ciphertext length , if one exists , otherwise return 0 <nl> - virtual size_t FixedMaxPlaintextLength ( ) const { return 0 ; } <nl> - <nl> - # ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - size_t MaxPlainTextLength ( size_t cipherTextLength ) const { return MaxPlaintextLength ( cipherTextLength ) ; } <nl> - size_t CipherTextLength ( size_t plainTextLength ) const { return CiphertextLength ( plainTextLength ) ; } <nl> - # endif <nl> - } ; <nl> - <nl> - / / ! interface for public - key encryptors <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Encryptor : public PK_CryptoSystem , public PublicKeyAlgorithm <nl> - { <nl> - public : <nl> - / / ! exception thrown when trying to encrypt plaintext of invalid length <nl> - class CRYPTOPP_DLL InvalidPlaintextLength : public Exception <nl> - { <nl> - public : <nl> - InvalidPlaintextLength ( ) : Exception ( OTHER_ERROR , " PK_Encryptor : invalid plaintext length " ) { } <nl> - } ; <nl> - <nl> - / / ! encrypt a byte string <nl> - / * ! \ pre CiphertextLength ( plaintextLength ) ! = 0 ( i . e . , plaintext isn ' t too long ) <nl> - \ pre size of ciphertext = = CiphertextLength ( plaintextLength ) <nl> - * / <nl> - virtual void Encrypt ( RandomNumberGenerator & rng , <nl> - const byte * plaintext , size_t plaintextLength , <nl> - byte * ciphertext , const NameValuePairs & parameters = g_nullNameValuePairs ) const = 0 ; <nl> - <nl> - / / ! create a new encryption filter <nl> - / * ! \ note The caller is responsible for deleting the returned pointer . <nl> - \ note Encoding parameters should be passed in the " EP " channel . <nl> - * / <nl> - virtual BufferedTransformation * CreateEncryptionFilter ( RandomNumberGenerator & rng , <nl> - BufferedTransformation * attachment = NULL , const NameValuePairs & parameters = g_nullNameValuePairs ) const ; <nl> - } ; <nl> - <nl> - / / ! interface for public - key decryptors <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Decryptor : public PK_CryptoSystem , public PrivateKeyAlgorithm <nl> - { <nl> - public : <nl> - / / ! decrypt a byte string , and return the length of plaintext <nl> - / * ! \ pre size of plaintext = = MaxPlaintextLength ( ciphertextLength ) bytes . <nl> - \ return the actual length of the plaintext , indication that decryption failed . <nl> - * / <nl> - virtual DecodingResult Decrypt ( RandomNumberGenerator & rng , <nl> - const byte * ciphertext , size_t ciphertextLength , <nl> - byte * plaintext , const NameValuePairs & parameters = g_nullNameValuePairs ) const = 0 ; <nl> - <nl> - / / ! create a new decryption filter <nl> - / * ! \ note caller is responsible for deleting the returned pointer <nl> - * / <nl> - virtual BufferedTransformation * CreateDecryptionFilter ( RandomNumberGenerator & rng , <nl> - BufferedTransformation * attachment = NULL , const NameValuePairs & parameters = g_nullNameValuePairs ) const ; <nl> - <nl> - / / ! decrypt a fixed size ciphertext <nl> - DecodingResult FixedLengthDecrypt ( RandomNumberGenerator & rng , const byte * ciphertext , byte * plaintext , const NameValuePairs & parameters = g_nullNameValuePairs ) const <nl> - { return Decrypt ( rng , ciphertext , FixedCiphertextLength ( ) , plaintext , parameters ) ; } <nl> - } ; <nl> - <nl> - # ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - typedef PK_CryptoSystem PK_FixedLengthCryptoSystem ; <nl> - typedef PK_Encryptor PK_FixedLengthEncryptor ; <nl> - typedef PK_Decryptor PK_FixedLengthDecryptor ; <nl> - # endif <nl> - <nl> - / / ! interface for public - key signers and verifiers <nl> - <nl> - / * ! This class provides an interface common to signers and verifiers <nl> - for querying scheme properties . <nl> - * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_SignatureScheme <nl> - { <nl> - public : <nl> - / / ! invalid key exception , may be thrown by any function in this class if the private or public key has a length that can ' t be used <nl> - class CRYPTOPP_DLL InvalidKeyLength : public Exception <nl> - { <nl> - public : <nl> - InvalidKeyLength ( const std : : string & message ) : Exception ( OTHER_ERROR , message ) { } <nl> - } ; <nl> - <nl> - / / ! key too short exception , may be thrown by any function in this class if the private or public key is too short to sign or verify anything <nl> - class CRYPTOPP_DLL KeyTooShort : public InvalidKeyLength <nl> - { <nl> - public : <nl> - KeyTooShort ( ) : InvalidKeyLength ( " PK_Signer : key too short for this signature scheme " ) { } <nl> - } ; <nl> - <nl> - virtual ~ PK_SignatureScheme ( ) { } <nl> - <nl> - / / ! signature length if it only depends on the key , otherwise 0 <nl> - virtual size_t SignatureLength ( ) const = 0 ; <nl> - <nl> - / / ! maximum signature length produced for a given length of recoverable message part <nl> - virtual size_t MaxSignatureLength ( size_t recoverablePartLength = 0 ) const { return SignatureLength ( ) ; } <nl> - <nl> - / / ! length of longest message that can be recovered , or 0 if this signature scheme does not support message recovery <nl> - virtual size_t MaxRecoverableLength ( ) const = 0 ; <nl> - <nl> - / / ! length of longest message that can be recovered from a signature of given length , or 0 if this signature scheme does not support message recovery <nl> - virtual size_t MaxRecoverableLengthFromSignatureLength ( size_t signatureLength ) const = 0 ; <nl> - <nl> - / / ! requires a random number generator to sign <nl> - / * ! if this returns false , NullRNG ( ) can be passed to functions that take RandomNumberGenerator & * / <nl> - virtual bool IsProbabilistic ( ) const = 0 ; <nl> - <nl> - / / ! whether or not a non - recoverable message part can be signed <nl> - virtual bool AllowNonrecoverablePart ( ) const = 0 ; <nl> - <nl> - / / ! if this function returns true , during verification you must input the signature before the message , otherwise you can input it at anytime * / <nl> - virtual bool SignatureUpfront ( ) const { return false ; } <nl> - <nl> - / / ! whether you must input the recoverable part before the non - recoverable part during signing <nl> - virtual bool RecoverablePartFirst ( ) const = 0 ; <nl> - } ; <nl> - <nl> - / / ! interface for accumulating messages to be signed or verified <nl> - / * ! Only Update ( ) should be called <nl> - on this class . No other functions inherited from HashTransformation should be called . <nl> - * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_MessageAccumulator : public HashTransformation <nl> - { <nl> - public : <nl> - / / ! should not be called on PK_MessageAccumulator <nl> - unsigned int DigestSize ( ) const <nl> - { throw NotImplemented ( " PK_MessageAccumulator : DigestSize ( ) should not be called " ) ; } <nl> - / / ! should not be called on PK_MessageAccumulator <nl> - void TruncatedFinal ( byte * digest , size_t digestSize ) <nl> - { throw NotImplemented ( " PK_MessageAccumulator : TruncatedFinal ( ) should not be called " ) ; } <nl> - } ; <nl> - <nl> - / / ! interface for public - key signers <nl> - <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Signer : public PK_SignatureScheme , public PrivateKeyAlgorithm <nl> - { <nl> - public : <nl> - / / ! create a new HashTransformation to accumulate the message to be signed <nl> - virtual PK_MessageAccumulator * NewSignatureAccumulator ( RandomNumberGenerator & rng ) const = 0 ; <nl> - <nl> - virtual void InputRecoverableMessage ( PK_MessageAccumulator & messageAccumulator , const byte * recoverableMessage , size_t recoverableMessageLength ) const = 0 ; <nl> - <nl> - / / ! sign and delete messageAccumulator ( even in case of exception thrown ) <nl> - / * ! \ pre size of signature = = MaxSignatureLength ( ) <nl> - \ return actual signature length <nl> - * / <nl> - virtual size_t Sign ( RandomNumberGenerator & rng , PK_MessageAccumulator * messageAccumulator , byte * signature ) const ; <nl> - <nl> - / / ! sign and restart messageAccumulator <nl> - / * ! \ pre size of signature = = MaxSignatureLength ( ) <nl> - \ return actual signature length <nl> - * / <nl> - virtual size_t SignAndRestart ( RandomNumberGenerator & rng , PK_MessageAccumulator & messageAccumulator , byte * signature , bool restart = true ) const = 0 ; <nl> - <nl> - / / ! sign a message <nl> - / * ! \ pre size of signature = = MaxSignatureLength ( ) <nl> - \ return actual signature length <nl> - * / <nl> - virtual size_t SignMessage ( RandomNumberGenerator & rng , const byte * message , size_t messageLen , byte * signature ) const ; <nl> - <nl> - / / ! sign a recoverable message <nl> - / * ! \ pre size of signature = = MaxSignatureLength ( recoverableMessageLength ) <nl> - \ return actual signature length <nl> - * / <nl> - virtual size_t SignMessageWithRecovery ( RandomNumberGenerator & rng , const byte * recoverableMessage , size_t recoverableMessageLength , <nl> - const byte * nonrecoverableMessage , size_t nonrecoverableMessageLength , byte * signature ) const ; <nl> - } ; <nl> - <nl> - / / ! interface for public - key signature verifiers <nl> - / * ! The Recover * functions throw NotImplemented if the signature scheme does not support <nl> - message recovery . <nl> - The Verify * functions throw InvalidDataFormat if the scheme does support message <nl> - recovery and the signature contains a non - empty recoverable message part . The <nl> - Recovery * functions should be used in that case . <nl> - * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Verifier : public PK_SignatureScheme , public PublicKeyAlgorithm <nl> - { <nl> - public : <nl> - / / ! create a new HashTransformation to accumulate the message to be verified <nl> - virtual PK_MessageAccumulator * NewVerificationAccumulator ( ) const = 0 ; <nl> - <nl> - / / ! input signature into a message accumulator <nl> - virtual void InputSignature ( PK_MessageAccumulator & messageAccumulator , const byte * signature , size_t signatureLength ) const = 0 ; <nl> - <nl> - / / ! check whether messageAccumulator contains a valid signature and message , and delete messageAccumulator ( even in case of exception thrown ) <nl> - virtual bool Verify ( PK_MessageAccumulator * messageAccumulator ) const ; <nl> - <nl> - / / ! check whether messageAccumulator contains a valid signature and message , and restart messageAccumulator <nl> - virtual bool VerifyAndRestart ( PK_MessageAccumulator & messageAccumulator ) const = 0 ; <nl> - <nl> - / / ! check whether input signature is a valid signature for input message <nl> - virtual bool VerifyMessage ( const byte * message , size_t messageLen , <nl> - const byte * signature , size_t signatureLength ) const ; <nl> - <nl> - / / ! recover a message from its signature <nl> - / * ! \ pre size of recoveredMessage = = MaxRecoverableLengthFromSignatureLength ( signatureLength ) <nl> - * / <nl> - virtual DecodingResult Recover ( byte * recoveredMessage , PK_MessageAccumulator * messageAccumulator ) const ; <nl> - <nl> - / / ! recover a message from its signature <nl> - / * ! \ pre size of recoveredMessage = = MaxRecoverableLengthFromSignatureLength ( signatureLength ) <nl> - * / <nl> - virtual DecodingResult RecoverAndRestart ( byte * recoveredMessage , PK_MessageAccumulator & messageAccumulator ) const = 0 ; <nl> - <nl> - / / ! recover a message from its signature <nl> - / * ! \ pre size of recoveredMessage = = MaxRecoverableLengthFromSignatureLength ( signatureLength ) <nl> - * / <nl> - virtual DecodingResult RecoverMessage ( byte * recoveredMessage , <nl> - const byte * nonrecoverableMessage , size_t nonrecoverableMessageLength , <nl> - const byte * signature , size_t signatureLength ) const ; <nl> - } ; <nl> - <nl> - / / ! interface for domains of simple key agreement protocols <nl> - <nl> - / * ! A key agreement domain is a set of parameters that must be shared <nl> - by two parties in a key agreement protocol , along with the algorithms <nl> - for generating key pairs and deriving agreed values . <nl> - * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE SimpleKeyAgreementDomain : public KeyAgreementAlgorithm <nl> - { <nl> - public : <nl> - / / ! return length of agreed value produced <nl> - virtual unsigned int AgreedValueLength ( ) const = 0 ; <nl> - / / ! return length of private keys in this domain <nl> - virtual unsigned int PrivateKeyLength ( ) const = 0 ; <nl> - / / ! return length of public keys in this domain <nl> - virtual unsigned int PublicKeyLength ( ) const = 0 ; <nl> - / / ! generate private key <nl> - / * ! \ pre size of privateKey = = PrivateKeyLength ( ) * / <nl> - virtual void GeneratePrivateKey ( RandomNumberGenerator & rng , byte * privateKey ) const = 0 ; <nl> - / / ! generate public key <nl> - / * ! \ pre size of publicKey = = PublicKeyLength ( ) * / <nl> - virtual void GeneratePublicKey ( RandomNumberGenerator & rng , const byte * privateKey , byte * publicKey ) const = 0 ; <nl> - / / ! generate private / public key pair <nl> - / * ! \ note equivalent to calling GeneratePrivateKey ( ) and then GeneratePublicKey ( ) * / <nl> - virtual void GenerateKeyPair ( RandomNumberGenerator & rng , byte * privateKey , byte * publicKey ) const ; <nl> - / / ! derive agreed value from your private key and couterparty ' s public key , return false in case of failure <nl> - / * ! \ note If you have previously validated the public key , use validateOtherPublicKey = false to save time . <nl> - \ pre size of agreedValue = = AgreedValueLength ( ) <nl> - \ pre length of privateKey = = PrivateKeyLength ( ) <nl> - \ pre length of otherPublicKey = = PublicKeyLength ( ) <nl> - * / <nl> - virtual bool Agree ( byte * agreedValue , const byte * privateKey , const byte * otherPublicKey , bool validateOtherPublicKey = true ) const = 0 ; <nl> - <nl> - # ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - bool ValidateDomainParameters ( RandomNumberGenerator & rng ) const <nl> - { return GetCryptoParameters ( ) . Validate ( rng , 2 ) ; } <nl> - # endif <nl> - } ; <nl> - <nl> - / / ! interface for domains of authenticated key agreement protocols <nl> - <nl> - / * ! In an authenticated key agreement protocol , each party has two <nl> - key pairs . The long - lived key pair is called the static key pair , <nl> - and the short - lived key pair is called the ephemeral key pair . <nl> - * / <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AuthenticatedKeyAgreementDomain : public KeyAgreementAlgorithm <nl> - { <nl> - public : <nl> - / / ! return length of agreed value produced <nl> - virtual unsigned int AgreedValueLength ( ) const = 0 ; <nl> - <nl> - / / ! return length of static private keys in this domain <nl> - virtual unsigned int StaticPrivateKeyLength ( ) const = 0 ; <nl> - / / ! return length of static public keys in this domain <nl> - virtual unsigned int StaticPublicKeyLength ( ) const = 0 ; <nl> - / / ! generate static private key <nl> - / * ! \ pre size of privateKey = = PrivateStaticKeyLength ( ) * / <nl> - virtual void GenerateStaticPrivateKey ( RandomNumberGenerator & rng , byte * privateKey ) const = 0 ; <nl> - / / ! generate static public key <nl> - / * ! \ pre size of publicKey = = PublicStaticKeyLength ( ) * / <nl> - virtual void GenerateStaticPublicKey ( RandomNumberGenerator & rng , const byte * privateKey , byte * publicKey ) const = 0 ; <nl> - / / ! generate private / public key pair <nl> - / * ! \ note equivalent to calling GenerateStaticPrivateKey ( ) and then GenerateStaticPublicKey ( ) * / <nl> - virtual void GenerateStaticKeyPair ( RandomNumberGenerator & rng , byte * privateKey , byte * publicKey ) const ; <nl> - <nl> - / / ! return length of ephemeral private keys in this domain <nl> - virtual unsigned int EphemeralPrivateKeyLength ( ) const = 0 ; <nl> - / / ! return length of ephemeral public keys in this domain <nl> - virtual unsigned int EphemeralPublicKeyLength ( ) const = 0 ; <nl> - / / ! generate ephemeral private key <nl> - / * ! \ pre size of privateKey = = PrivateEphemeralKeyLength ( ) * / <nl> - virtual void GenerateEphemeralPrivateKey ( RandomNumberGenerator & rng , byte * privateKey ) const = 0 ; <nl> - / / ! generate ephemeral public key <nl> - / * ! \ pre size of publicKey = = PublicEphemeralKeyLength ( ) * / <nl> - virtual void GenerateEphemeralPublicKey ( RandomNumberGenerator & rng , const byte * privateKey , byte * publicKey ) const = 0 ; <nl> - / / ! generate private / public key pair <nl> - / * ! \ note equivalent to calling GenerateEphemeralPrivateKey ( ) and then GenerateEphemeralPublicKey ( ) * / <nl> - virtual void GenerateEphemeralKeyPair ( RandomNumberGenerator & rng , byte * privateKey , byte * publicKey ) const ; <nl> - <nl> - / / ! derive agreed value from your private keys and couterparty ' s public keys , return false in case of failure <nl> - / * ! \ note The ephemeral public key will always be validated . <nl> - If you have previously validated the static public key , use validateStaticOtherPublicKey = false to save time . <nl> - \ pre size of agreedValue = = AgreedValueLength ( ) <nl> - \ pre length of staticPrivateKey = = StaticPrivateKeyLength ( ) <nl> - \ pre length of ephemeralPrivateKey = = EphemeralPrivateKeyLength ( ) <nl> - \ pre length of staticOtherPublicKey = = StaticPublicKeyLength ( ) <nl> - \ pre length of ephemeralOtherPublicKey = = EphemeralPublicKeyLength ( ) <nl> - * / <nl> - virtual bool Agree ( byte * agreedValue , <nl> - const byte * staticPrivateKey , const byte * ephemeralPrivateKey , <nl> - const byte * staticOtherPublicKey , const byte * ephemeralOtherPublicKey , <nl> - bool validateStaticOtherPublicKey = true ) const = 0 ; <nl> - <nl> - # ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - bool ValidateDomainParameters ( RandomNumberGenerator & rng ) const <nl> - { return GetCryptoParameters ( ) . Validate ( rng , 2 ) ; } <nl> - # endif <nl> - } ; <nl> - <nl> - / / interface for password authenticated key agreement protocols , not implemented yet <nl> - # if 0 <nl> - / / ! interface for protocol sessions <nl> - / * ! The methods should be called in the following order : <nl> - <nl> - InitializeSession ( rng , parameters ) ; / / or call initialize method in derived class <nl> - while ( true ) <nl> - { <nl> - if ( OutgoingMessageAvailable ( ) ) <nl> - { <nl> - length = GetOutgoingMessageLength ( ) ; <nl> - GetOutgoingMessage ( message ) ; <nl> - ; / / send outgoing message <nl> - } <nl> - <nl> - if ( LastMessageProcessed ( ) ) <nl> - break ; <nl> - <nl> - ; / / receive incoming message <nl> - ProcessIncomingMessage ( message ) ; <nl> - } <nl> - ; / / call methods in derived class to obtain result of protocol session <nl> - * / <nl> - class ProtocolSession <nl> - { <nl> - public : <nl> - / / ! exception thrown when an invalid protocol message is processed <nl> - class ProtocolError : public Exception <nl> - { <nl> - public : <nl> - ProtocolError ( ErrorType errorType , const std : : string & s ) : Exception ( errorType , s ) { } <nl> - } ; <nl> - <nl> - / / ! exception thrown when a function is called unexpectedly <nl> - / * ! for example calling ProcessIncomingMessage ( ) when ProcessedLastMessage ( ) = = true * / <nl> - class UnexpectedMethodCall : public Exception <nl> - { <nl> - public : <nl> - UnexpectedMethodCall ( const std : : string & s ) : Exception ( OTHER_ERROR , s ) { } <nl> - } ; <nl> - <nl> - ProtocolSession ( ) : m_rng ( NULL ) , m_throwOnProtocolError ( true ) , m_validState ( false ) { } <nl> - virtual ~ ProtocolSession ( ) { } <nl> - <nl> - virtual void InitializeSession ( RandomNumberGenerator & rng , const NameValuePairs & parameters ) = 0 ; <nl> - <nl> - bool GetThrowOnProtocolError ( ) const { return m_throwOnProtocolError ; } <nl> - void SetThrowOnProtocolError ( bool throwOnProtocolError ) { m_throwOnProtocolError = throwOnProtocolError ; } <nl> - <nl> - bool HasValidState ( ) const { return m_validState ; } <nl> - <nl> - virtual bool OutgoingMessageAvailable ( ) const = 0 ; <nl> - virtual unsigned int GetOutgoingMessageLength ( ) const = 0 ; <nl> - virtual void GetOutgoingMessage ( byte * message ) = 0 ; <nl> - <nl> - virtual bool LastMessageProcessed ( ) const = 0 ; <nl> - virtual void ProcessIncomingMessage ( const byte * message , unsigned int messageLength ) = 0 ; <nl> - <nl> - protected : <nl> - void HandleProtocolError ( Exception : : ErrorType errorType , const std : : string & s ) const ; <nl> - void CheckAndHandleInvalidState ( ) const ; <nl> - void SetValidState ( bool valid ) { m_validState = valid ; } <nl> - <nl> - RandomNumberGenerator * m_rng ; <nl> - <nl> - private : <nl> - bool m_throwOnProtocolError , m_validState ; <nl> - } ; <nl> - <nl> - class KeyAgreementSession : public ProtocolSession <nl> - { <nl> - public : <nl> - virtual unsigned int GetAgreedValueLength ( ) const = 0 ; <nl> - virtual void GetAgreedValue ( byte * agreedValue ) const = 0 ; <nl> - } ; <nl> - <nl> - class PasswordAuthenticatedKeyAgreementSession : public KeyAgreementSession <nl> - { <nl> - public : <nl> - void InitializePasswordAuthenticatedKeyAgreementSession ( RandomNumberGenerator & rng , <nl> - const byte * myId , unsigned int myIdLength , <nl> - const byte * counterPartyId , unsigned int counterPartyIdLength , <nl> - const byte * passwordOrVerifier , unsigned int passwordOrVerifierLength ) ; <nl> - } ; <nl> - <nl> - class PasswordAuthenticatedKeyAgreementDomain : public KeyAgreementAlgorithm <nl> - { <nl> - public : <nl> - / / ! return whether the domain parameters stored in this object are valid <nl> - virtual bool ValidateDomainParameters ( RandomNumberGenerator & rng ) const <nl> - { return GetCryptoParameters ( ) . Validate ( rng , 2 ) ; } <nl> - <nl> - virtual unsigned int GetPasswordVerifierLength ( const byte * password , unsigned int passwordLength ) const = 0 ; <nl> - virtual void GeneratePasswordVerifier ( RandomNumberGenerator & rng , const byte * userId , unsigned int userIdLength , const byte * password , unsigned int passwordLength , byte * verifier ) const = 0 ; <nl> - <nl> - enum RoleFlags { CLIENT = 1 , SERVER = 2 , INITIATOR = 4 , RESPONDER = 8 } ; <nl> - <nl> - virtual bool IsValidRole ( unsigned int role ) = 0 ; <nl> - virtual PasswordAuthenticatedKeyAgreementSession * CreateProtocolSession ( unsigned int role ) const = 0 ; <nl> - } ; <nl> - # endif <nl> - <nl> - / / ! BER Decode Exception Class , may be thrown during an ASN1 BER decode operation <nl> - class CRYPTOPP_DLL BERDecodeErr : public InvalidArgument <nl> - { <nl> - public : <nl> - BERDecodeErr ( ) : InvalidArgument ( " BER decode error " ) { } <nl> - BERDecodeErr ( const std : : string & s ) : InvalidArgument ( s ) { } <nl> - } ; <nl> - <nl> - / / ! interface for encoding and decoding ASN1 objects <nl> - class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ASN1Object <nl> - { <nl> - public : <nl> - virtual ~ ASN1Object ( ) { } <nl> - / / ! decode this object from a BufferedTransformation , using BER ( Basic Encoding Rules ) <nl> - virtual void BERDecode ( BufferedTransformation & bt ) = 0 ; <nl> - / / ! encode this object into a BufferedTransformation , using DER ( Distinguished Encoding Rules ) <nl> - virtual void DEREncode ( BufferedTransformation & bt ) const = 0 ; <nl> - / / ! encode this object into a BufferedTransformation , using BER <nl> - / * ! this may be useful if DEREncode ( ) would be too inefficient * / <nl> - virtual void BEREncode ( BufferedTransformation & bt ) const { DEREncode ( bt ) ; } <nl> - } ; <nl> - <nl> - # ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY <nl> - typedef PK_SignatureScheme PK_SignatureSystem ; <nl> - typedef SimpleKeyAgreementDomain PK_SimpleKeyAgreementDomain ; <nl> - typedef AuthenticatedKeyAgreementDomain PK_AuthenticatedKeyAgreementDomain ; <nl> - # endif <nl> - <nl> - NAMESPACE_END <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 2f5895e2d3ed . . 000000000000 <nl> mmm a / src / cryptopp / iterhash . h <nl> ppp / dev / null <nl> <nl> - # ifndef CRYPTOPP_ITERHASH_H <nl> - # define CRYPTOPP_ITERHASH_H <nl> - <nl> - # include " secblock . h " <nl> - <nl> - NAMESPACE_BEGIN ( CryptoPP ) <nl> - <nl> - / / * * * trimmed down dependency from iterhash . h * * * <nl> - template < class T_HashWordType , class T_Endianness , unsigned int T_BlockSize , unsigned int T_StateSize , class T_Transform , unsigned int T_DigestSize = 0 , bool T_StateAligned = false > <nl> - class CRYPTOPP_NO_VTABLE IteratedHashWithStaticTransform <nl> - { <nl> - public : <nl> - CRYPTOPP_CONSTANT ( DIGESTSIZE = T_DigestSize ? T_DigestSize : T_StateSize ) <nl> - unsigned int DigestSize ( ) const { return DIGESTSIZE ; } ; <nl> - typedef T_HashWordType HashWordType ; <nl> - CRYPTOPP_CONSTANT ( BLOCKSIZE = T_BlockSize ) <nl> - <nl> - protected : <nl> - IteratedHashWithStaticTransform ( ) { this - > Init ( ) ; } <nl> - void HashEndianCorrectedBlock ( const T_HashWordType * data ) { T_Transform : : Transform ( this - > m_state , data ) ; } <nl> - void Init ( ) { T_Transform : : InitState ( this - > m_state ) ; } <nl> - <nl> - T_HashWordType * StateBuf ( ) { return this - > m_state ; } <nl> - FixedSizeAlignedSecBlock < T_HashWordType , T_BlockSize / sizeof ( T_HashWordType ) , T_StateAligned > m_state ; <nl> - } ; <nl> - <nl> - NAMESPACE_END <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index de8037bf619d . . 000000000000 <nl> mmm a / src / cryptopp / misc . h <nl> ppp / dev / null <nl> <nl> - # ifndef CRYPTOPP_MISC_H <nl> - # define CRYPTOPP_MISC_H <nl> - <nl> - # include " cryptlib . h " <nl> - # include " smartptr . h " <nl> - # include < string . h > / / for memcpy and memmove <nl> - <nl> - # ifdef _MSC_VER <nl> - # include < stdlib . h > <nl> - # if _MSC_VER > = 1400 <nl> - / / VC2005 workaround : disable declarations that conflict with winnt . h <nl> - # define _interlockedbittestandset CRYPTOPP_DISABLED_INTRINSIC_1 <nl> - # define _interlockedbittestandreset CRYPTOPP_DISABLED_INTRINSIC_2 <nl> - # define _interlockedbittestandset64 CRYPTOPP_DISABLED_INTRINSIC_3 <nl> - # define _interlockedbittestandreset64 CRYPTOPP_DISABLED_INTRINSIC_4 <nl> - # include < intrin . h > <nl> - # undef _interlockedbittestandset <nl> - # undef _interlockedbittestandreset <nl> - # undef _interlockedbittestandset64 <nl> - # undef _interlockedbittestandreset64 <nl> - # define CRYPTOPP_FAST_ROTATE ( x ) 1 <nl> - # elif _MSC_VER > = 1300 <nl> - # define CRYPTOPP_FAST_ROTATE ( x ) ( ( x ) = = 32 | ( x ) = = 64 ) <nl> - # else <nl> - # define CRYPTOPP_FAST_ROTATE ( x ) ( ( x ) = = 32 ) <nl> - # endif <nl> - # elif ( defined ( __MWERKS__ ) & & TARGET_CPU_PPC ) | | \ <nl> - ( defined ( __GNUC__ ) & & ( defined ( _ARCH_PWR2 ) | | defined ( _ARCH_PWR ) | | defined ( _ARCH_PPC ) | | defined ( _ARCH_PPC64 ) | | defined ( _ARCH_COM ) ) ) <nl> - # define CRYPTOPP_FAST_ROTATE ( x ) ( ( x ) = = 32 ) <nl> - # elif defined ( __GNUC__ ) & & ( CRYPTOPP_BOOL_X64 | | CRYPTOPP_BOOL_X86 ) / / depend on GCC ' s peephole optimization to generate rotate instructions <nl> - # define CRYPTOPP_FAST_ROTATE ( x ) 1 <nl> - # else <nl> - # define CRYPTOPP_FAST_ROTATE ( x ) 0 <nl> - # endif <nl> - <nl> - # ifdef __BORLANDC__ <nl> - # include < mem . h > <nl> - # endif <nl> - <nl> - # if defined ( __GNUC__ ) & & defined ( __linux__ ) <nl> - # define CRYPTOPP_BYTESWAP_AVAILABLE <nl> - # include < byteswap . h > <nl> - # endif <nl> - <nl> - NAMESPACE_BEGIN ( CryptoPP ) <nl> - <nl> - / / * * * * * * * * * * * * * * compile - time assertion * * * * * * * * * * * * * * * <nl> - <nl> - template < bool b > <nl> - struct CompileAssert <nl> - { <nl> - static char dummy [ 2 * b - 1 ] ; <nl> - } ; <nl> - <nl> - # define CRYPTOPP_COMPILE_ASSERT ( assertion ) CRYPTOPP_COMPILE_ASSERT_INSTANCE ( assertion , __LINE__ ) <nl> - # if defined ( CRYPTOPP_EXPORTS ) | | defined ( CRYPTOPP_IMPORTS ) <nl> - # define CRYPTOPP_COMPILE_ASSERT_INSTANCE ( assertion , instance ) <nl> - # else <nl> - # define CRYPTOPP_COMPILE_ASSERT_INSTANCE ( assertion , instance ) static CompileAssert < ( assertion ) > CRYPTOPP_ASSERT_JOIN ( cryptopp_assert_ , instance ) <nl> - # endif <nl> - # define CRYPTOPP_ASSERT_JOIN ( X , Y ) CRYPTOPP_DO_ASSERT_JOIN ( X , Y ) <nl> - # define CRYPTOPP_DO_ASSERT_JOIN ( X , Y ) X # # Y <nl> - <nl> - / / * * * * * * * * * * * * * * misc classes * * * * * * * * * * * * * * * <nl> - <nl> - class CRYPTOPP_DLL Empty <nl> - { <nl> - } ; <nl> - <nl> - / / ! _ <nl> - template < class BASE1 , class BASE2 > <nl> - class CRYPTOPP_NO_VTABLE TwoBases : public BASE1 , public BASE2 <nl> - { <nl> - } ; <nl> - <nl> - / / ! _ <nl> - template < class BASE1 , class BASE2 , class BASE3 > <nl> - class CRYPTOPP_NO_VTABLE ThreeBases : public BASE1 , public BASE2 , public BASE3 <nl> - { <nl> - } ; <nl> - <nl> - template < class T > <nl> - class ObjectHolder <nl> - { <nl> - protected : <nl> - T m_object ; <nl> - } ; <nl> - <nl> - class NotCopyable <nl> - { <nl> - public : <nl> - NotCopyable ( ) { } <nl> - private : <nl> - NotCopyable ( const NotCopyable & ) ; <nl> - void operator = ( const NotCopyable & ) ; <nl> - } ; <nl> - <nl> - template < class T > <nl> - struct NewObject <nl> - { <nl> - T * operator ( ) ( ) const { return new T ; } <nl> - } ; <nl> - <nl> - / * ! This function safely initializes a static object in a multithreaded environment without using locks . <nl> - It may leak memory when two threads try to initialize the static object at the same time <nl> - but this should be acceptable since each static object is only initialized once per session . <nl> - * / <nl> - template < class T , class F = NewObject < T > , int instance = 0 > <nl> - class Singleton <nl> - { <nl> - public : <nl> - Singleton ( F objectFactory = F ( ) ) : m_objectFactory ( objectFactory ) { } <nl> - <nl> - / / prevent this function from being inlined <nl> - CRYPTOPP_NOINLINE const T & Ref ( CRYPTOPP_NOINLINE_DOTDOTDOT ) const ; <nl> - <nl> - private : <nl> - F m_objectFactory ; <nl> - } ; <nl> - <nl> - template < class T , class F , int instance > <nl> - const T & Singleton < T , F , instance > : : Ref ( CRYPTOPP_NOINLINE_DOTDOTDOT ) const <nl> - { <nl> - static simple_ptr < T > s_pObject ; <nl> - static char s_objectState = 0 ; <nl> - <nl> - retry : <nl> - switch ( s_objectState ) <nl> - { <nl> - case 0 : <nl> - s_objectState = 1 ; <nl> - try <nl> - { <nl> - s_pObject . m_p = m_objectFactory ( ) ; <nl> - } <nl> - catch ( . . . ) <nl> - { <nl> - s_objectState = 0 ; <nl> - throw ; <nl> - } <nl> - s_objectState = 2 ; <nl> - break ; <nl> - case 1 : <nl> - goto retry ; <nl> - default : <nl> - break ; <nl> - } <nl> - return * s_pObject . m_p ; <nl> - } <nl> - <nl> - / / * * * * * * * * * * * * * * misc functions * * * * * * * * * * * * * * * <nl> - <nl> - # if ( ! __STDC_WANT_SECURE_LIB__ ) <nl> - inline void memcpy_s ( void * dest , size_t sizeInBytes , const void * src , size_t count ) <nl> - { <nl> - if ( count > sizeInBytes ) <nl> - throw InvalidArgument ( " memcpy_s : buffer overflow " ) ; <nl> - memcpy ( dest , src , count ) ; <nl> - } <nl> - <nl> - inline void memmove_s ( void * dest , size_t sizeInBytes , const void * src , size_t count ) <nl> - { <nl> - if ( count > sizeInBytes ) <nl> - throw InvalidArgument ( " memmove_s : buffer overflow " ) ; <nl> - memmove ( dest , src , count ) ; <nl> - } <nl> - # endif <nl> - <nl> - inline void * memset_z ( void * ptr , int value , size_t num ) <nl> - { <nl> - / / avoid extranous warning on GCC 4 . 3 . 2 Ubuntu 8 . 10 <nl> - # if CRYPTOPP_GCC_VERSION > = 30001 <nl> - if ( __builtin_constant_p ( num ) & & num = = 0 ) <nl> - return ptr ; <nl> - # endif <nl> - return memset ( ptr , value , num ) ; <nl> - } <nl> - <nl> - / / can ' t use std : : min or std : : max in MSVC60 or Cygwin 1 . 1 . 0 <nl> - template < class T > inline const T & STDMIN ( const T & a , const T & b ) <nl> - { <nl> - return b < a ? b : a ; <nl> - } <nl> - <nl> - template < class T1 , class T2 > inline const T1 UnsignedMin ( const T1 & a , const T2 & b ) <nl> - { <nl> - CRYPTOPP_COMPILE_ASSERT ( ( sizeof ( T1 ) < = sizeof ( T2 ) & & T2 ( - 1 ) > 0 ) | | ( sizeof ( T1 ) > sizeof ( T2 ) & & T1 ( - 1 ) > 0 ) ) ; <nl> - assert ( a = = 0 | | a > 0 ) ; / / GCC workaround : get rid of the warning " comparison is always true due to limited range of data type " <nl> - assert ( b > = 0 ) ; <nl> - <nl> - if ( sizeof ( T1 ) < = sizeof ( T2 ) ) <nl> - return b < ( T2 ) a ? ( T1 ) b : a ; <nl> - else <nl> - return ( T1 ) b < a ? ( T1 ) b : a ; <nl> - } <nl> - <nl> - template < class T > inline const T & STDMAX ( const T & a , const T & b ) <nl> - { <nl> - return a < b ? b : a ; <nl> - } <nl> - <nl> - # define RETURN_IF_NONZERO ( x ) size_t returnedValue = x ; if ( returnedValue ) return returnedValue <nl> - <nl> - / / this version of the macro is fastest on Pentium 3 and Pentium 4 with MSVC 6 SP5 w / Processor Pack <nl> - # define GETBYTE ( x , y ) ( unsigned int ) byte ( ( x ) > > ( 8 * ( y ) ) ) <nl> - / / these may be faster on other CPUs / compilers <nl> - / / # define GETBYTE ( x , y ) ( unsigned int ) ( ( ( x ) > > ( 8 * ( y ) ) ) & 255 ) <nl> - / / # define GETBYTE ( x , y ) ( ( ( byte * ) & ( x ) ) [ y ] ) <nl> - <nl> - # define CRYPTOPP_GET_BYTE_AS_BYTE ( x , y ) byte ( ( x ) > > ( 8 * ( y ) ) ) <nl> - <nl> - template < class T > <nl> - unsigned int Parity ( T value ) <nl> - { <nl> - for ( unsigned int i = 8 * sizeof ( value ) / 2 ; i > 0 ; i / = 2 ) <nl> - value ^ = value > > i ; <nl> - return ( unsigned int ) value & 1 ; <nl> - } <nl> - <nl> - template < class T > <nl> - unsigned int BytePrecision ( const T & value ) <nl> - { <nl> - if ( ! value ) <nl> - return 0 ; <nl> - <nl> - unsigned int l = 0 , h = 8 * sizeof ( value ) ; <nl> - <nl> - while ( h - l > 8 ) <nl> - { <nl> - unsigned int t = ( l + h ) / 2 ; <nl> - if ( value > > t ) <nl> - l = t ; <nl> - else <nl> - h = t ; <nl> - } <nl> - <nl> - return h / 8 ; <nl> - } <nl> - <nl> - template < class T > <nl> - unsigned int BitPrecision ( const T & value ) <nl> - { <nl> - if ( ! value ) <nl> - return 0 ; <nl> - <nl> - unsigned int l = 0 , h = 8 * sizeof ( value ) ; <nl> - <nl> - while ( h - l > 1 ) <nl> - { <nl> - unsigned int t = ( l + h ) / 2 ; <nl> - if ( value > > t ) <nl> - l = t ; <nl> - else <nl> - h = t ; <nl> - } <nl> - <nl> - return h ; <nl> - } <nl> - <nl> - template < class T > <nl> - inline T Crop ( T value , size_t size ) <nl> - { <nl> - if ( size < 8 * sizeof ( value ) ) <nl> - return T ( value & ( ( T ( 1 ) < < size ) - 1 ) ) ; <nl> - else <nl> - return value ; <nl> - } <nl> - <nl> - template < class T1 , class T2 > <nl> - inline bool SafeConvert ( T1 from , T2 & to ) <nl> - { <nl> - to = ( T2 ) from ; <nl> - if ( from ! = to | | ( from > 0 ) ! = ( to > 0 ) ) <nl> - return false ; <nl> - return true ; <nl> - } <nl> - <nl> - inline size_t BitsToBytes ( size_t bitCount ) <nl> - { <nl> - return ( ( bitCount + 7 ) / ( 8 ) ) ; <nl> - } <nl> - <nl> - inline size_t BytesToWords ( size_t byteCount ) <nl> - { <nl> - return ( ( byteCount + WORD_SIZE - 1 ) / WORD_SIZE ) ; <nl> - } <nl> - <nl> - inline size_t BitsToWords ( size_t bitCount ) <nl> - { <nl> - return ( ( bitCount + WORD_BITS - 1 ) / ( WORD_BITS ) ) ; <nl> - } <nl> - <nl> - inline size_t BitsToDwords ( size_t bitCount ) <nl> - { <nl> - return ( ( bitCount + 2 * WORD_BITS - 1 ) / ( 2 * WORD_BITS ) ) ; <nl> - } <nl> - <nl> - CRYPTOPP_DLL void CRYPTOPP_API xorbuf ( byte * buf , const byte * mask , size_t count ) ; <nl> - CRYPTOPP_DLL void CRYPTOPP_API xorbuf ( byte * output , const byte * input , const byte * mask , size_t count ) ; <nl> - <nl> - CRYPTOPP_DLL bool CRYPTOPP_API VerifyBufsEqual ( const byte * buf1 , const byte * buf2 , size_t count ) ; <nl> - <nl> - template < class T > <nl> - inline bool IsPowerOf2 ( const T & n ) <nl> - { <nl> - return n > 0 & & ( n & ( n - 1 ) ) = = 0 ; <nl> - } <nl> - <nl> - template < class T1 , class T2 > <nl> - inline T2 ModPowerOf2 ( const T1 & a , const T2 & b ) <nl> - { <nl> - assert ( IsPowerOf2 ( b ) ) ; <nl> - return T2 ( a ) & ( b - 1 ) ; <nl> - } <nl> - <nl> - template < class T1 , class T2 > <nl> - inline T1 RoundDownToMultipleOf ( const T1 & n , const T2 & m ) <nl> - { <nl> - if ( IsPowerOf2 ( m ) ) <nl> - return n - ModPowerOf2 ( n , m ) ; <nl> - else <nl> - return n - n % m ; <nl> - } <nl> - <nl> - template < class T1 , class T2 > <nl> - inline T1 RoundUpToMultipleOf ( const T1 & n , const T2 & m ) <nl> - { <nl> - if ( n + m - 1 < n ) <nl> - throw InvalidArgument ( " RoundUpToMultipleOf : integer overflow " ) ; <nl> - return RoundDownToMultipleOf ( n + m - 1 , m ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - inline unsigned int GetAlignmentOf ( T * dummy = NULL ) / / VC60 workaround <nl> - { <nl> - # ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS <nl> - if ( sizeof ( T ) < 16 ) <nl> - return 1 ; <nl> - # endif <nl> - <nl> - # if ( _MSC_VER > = 1300 ) <nl> - return __alignof ( T ) ; <nl> - # elif defined ( __GNUC__ ) <nl> - return __alignof__ ( T ) ; <nl> - # elif CRYPTOPP_BOOL_SLOW_WORD64 <nl> - return UnsignedMin ( 4U , sizeof ( T ) ) ; <nl> - # else <nl> - return sizeof ( T ) ; <nl> - # endif <nl> - } <nl> - <nl> - inline bool IsAlignedOn ( const void * p , unsigned int alignment ) <nl> - { <nl> - return alignment = = 1 | | ( IsPowerOf2 ( alignment ) ? ModPowerOf2 ( ( size_t ) p , alignment ) = = 0 : ( size_t ) p % alignment = = 0 ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - inline bool IsAligned ( const void * p , T * dummy = NULL ) / / VC60 workaround <nl> - { <nl> - return IsAlignedOn ( p , GetAlignmentOf < T > ( ) ) ; <nl> - } <nl> - <nl> - # ifdef IS_LITTLE_ENDIAN <nl> - typedef LittleEndian NativeByteOrder ; <nl> - # else <nl> - typedef BigEndian NativeByteOrder ; <nl> - # endif <nl> - <nl> - inline ByteOrder GetNativeByteOrder ( ) <nl> - { <nl> - return NativeByteOrder : : ToEnum ( ) ; <nl> - } <nl> - <nl> - inline bool NativeByteOrderIs ( ByteOrder order ) <nl> - { <nl> - return order = = GetNativeByteOrder ( ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - std : : string IntToString ( T a , unsigned int base = 10 ) <nl> - { <nl> - if ( a = = 0 ) <nl> - return " 0 " ; <nl> - bool negate = false ; <nl> - if ( a < 0 ) <nl> - { <nl> - negate = true ; <nl> - a = 0 - a ; / / VC . NET does not like - a <nl> - } <nl> - std : : string result ; <nl> - while ( a > 0 ) <nl> - { <nl> - T digit = a % base ; <nl> - result = char ( ( digit < 10 ? ' 0 ' : ( ' a ' - 10 ) ) + digit ) + result ; <nl> - a / = base ; <nl> - } <nl> - if ( negate ) <nl> - result = " - " + result ; <nl> - return result ; <nl> - } <nl> - <nl> - template < class T1 , class T2 > <nl> - inline T1 SaturatingSubtract ( const T1 & a , const T2 & b ) <nl> - { <nl> - return T1 ( ( a > b ) ? ( a - b ) : 0 ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - inline CipherDir GetCipherDir ( const T & obj ) <nl> - { <nl> - return obj . IsForwardTransformation ( ) ? ENCRYPTION : DECRYPTION ; <nl> - } <nl> - <nl> - CRYPTOPP_DLL void CRYPTOPP_API CallNewHandler ( ) ; <nl> - <nl> - inline void IncrementCounterByOne ( byte * inout , unsigned int s ) <nl> - { <nl> - for ( int i = s - 1 , carry = 1 ; i > = 0 & & carry ; i - - ) <nl> - carry = ! + + inout [ i ] ; <nl> - } <nl> - <nl> - inline void IncrementCounterByOne ( byte * output , const byte * input , unsigned int s ) <nl> - { <nl> - int i , carry ; <nl> - for ( i = s - 1 , carry = 1 ; i > = 0 & & carry ; i - - ) <nl> - carry = ( ( output [ i ] = input [ i ] + 1 ) = = 0 ) ; <nl> - memcpy_s ( output , s , input , i + 1 ) ; <nl> - } <nl> - <nl> - / / * * * * * * * * * * * * * * rotate functions * * * * * * * * * * * * * * * <nl> - <nl> - template < class T > inline T rotlFixed ( T x , unsigned int y ) <nl> - { <nl> - assert ( y < sizeof ( T ) * 8 ) ; <nl> - return T ( ( x < < y ) | ( x > > ( sizeof ( T ) * 8 - y ) ) ) ; <nl> - } <nl> - <nl> - template < class T > inline T rotrFixed ( T x , unsigned int y ) <nl> - { <nl> - assert ( y < sizeof ( T ) * 8 ) ; <nl> - return T ( ( x > > y ) | ( x < < ( sizeof ( T ) * 8 - y ) ) ) ; <nl> - } <nl> - <nl> - template < class T > inline T rotlVariable ( T x , unsigned int y ) <nl> - { <nl> - assert ( y < sizeof ( T ) * 8 ) ; <nl> - return T ( ( x < < y ) | ( x > > ( sizeof ( T ) * 8 - y ) ) ) ; <nl> - } <nl> - <nl> - template < class T > inline T rotrVariable ( T x , unsigned int y ) <nl> - { <nl> - assert ( y < sizeof ( T ) * 8 ) ; <nl> - return T ( ( x > > y ) | ( x < < ( sizeof ( T ) * 8 - y ) ) ) ; <nl> - } <nl> - <nl> - template < class T > inline T rotlMod ( T x , unsigned int y ) <nl> - { <nl> - y % = sizeof ( T ) * 8 ; <nl> - return T ( ( x < < y ) | ( x > > ( sizeof ( T ) * 8 - y ) ) ) ; <nl> - } <nl> - <nl> - template < class T > inline T rotrMod ( T x , unsigned int y ) <nl> - { <nl> - y % = sizeof ( T ) * 8 ; <nl> - return T ( ( x > > y ) | ( x < < ( sizeof ( T ) * 8 - y ) ) ) ; <nl> - } <nl> - <nl> - # ifdef _MSC_VER <nl> - <nl> - template < > inline word32 rotlFixed < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return y ? _lrotl ( x , y ) : x ; <nl> - } <nl> - <nl> - template < > inline word32 rotrFixed < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return y ? _lrotr ( x , y ) : x ; <nl> - } <nl> - <nl> - template < > inline word32 rotlVariable < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return _lrotl ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline word32 rotrVariable < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return _lrotr ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline word32 rotlMod < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - return _lrotl ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline word32 rotrMod < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - return _lrotr ( x , y ) ; <nl> - } <nl> - <nl> - # endif / / # ifdef _MSC_VER <nl> - <nl> - # if _MSC_VER > = 1300 & & ! defined ( __INTEL_COMPILER ) <nl> - / / Intel C + + Compiler 10 . 0 calls a function instead of using the rotate instruction when using these instructions <nl> - <nl> - template < > inline word64 rotlFixed < word64 > ( word64 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return y ? _rotl64 ( x , y ) : x ; <nl> - } <nl> - <nl> - template < > inline word64 rotrFixed < word64 > ( word64 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return y ? _rotr64 ( x , y ) : x ; <nl> - } <nl> - <nl> - template < > inline word64 rotlVariable < word64 > ( word64 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return _rotl64 ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline word64 rotrVariable < word64 > ( word64 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return _rotr64 ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline word64 rotlMod < word64 > ( word64 x , unsigned int y ) <nl> - { <nl> - return _rotl64 ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline word64 rotrMod < word64 > ( word64 x , unsigned int y ) <nl> - { <nl> - return _rotr64 ( x , y ) ; <nl> - } <nl> - <nl> - # endif / / # if _MSC_VER > = 1310 <nl> - <nl> - # if _MSC_VER > = 1400 & & ! defined ( __INTEL_COMPILER ) <nl> - / / Intel C + + Compiler 10 . 0 gives undefined externals with these <nl> - <nl> - template < > inline word16 rotlFixed < word16 > ( word16 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return y ? _rotl16 ( x , y ) : x ; <nl> - } <nl> - <nl> - template < > inline word16 rotrFixed < word16 > ( word16 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return y ? _rotr16 ( x , y ) : x ; <nl> - } <nl> - <nl> - template < > inline word16 rotlVariable < word16 > ( word16 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return _rotl16 ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline word16 rotrVariable < word16 > ( word16 x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return _rotr16 ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline word16 rotlMod < word16 > ( word16 x , unsigned int y ) <nl> - { <nl> - return _rotl16 ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline word16 rotrMod < word16 > ( word16 x , unsigned int y ) <nl> - { <nl> - return _rotr16 ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline byte rotlFixed < byte > ( byte x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return y ? _rotl8 ( x , y ) : x ; <nl> - } <nl> - <nl> - template < > inline byte rotrFixed < byte > ( byte x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return y ? _rotr8 ( x , y ) : x ; <nl> - } <nl> - <nl> - template < > inline byte rotlVariable < byte > ( byte x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return _rotl8 ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline byte rotrVariable < byte > ( byte x , unsigned int y ) <nl> - { <nl> - assert ( y < 8 * sizeof ( x ) ) ; <nl> - return _rotr8 ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline byte rotlMod < byte > ( byte x , unsigned int y ) <nl> - { <nl> - return _rotl8 ( x , y ) ; <nl> - } <nl> - <nl> - template < > inline byte rotrMod < byte > ( byte x , unsigned int y ) <nl> - { <nl> - return _rotr8 ( x , y ) ; <nl> - } <nl> - <nl> - # endif / / # if _MSC_VER > = 1400 <nl> - <nl> - # if ( defined ( __MWERKS__ ) & & TARGET_CPU_PPC ) <nl> - <nl> - template < > inline word32 rotlFixed < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - assert ( y < 32 ) ; <nl> - return y ? __rlwinm ( x , y , 0 , 31 ) : x ; <nl> - } <nl> - <nl> - template < > inline word32 rotrFixed < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - assert ( y < 32 ) ; <nl> - return y ? __rlwinm ( x , 32 - y , 0 , 31 ) : x ; <nl> - } <nl> - <nl> - template < > inline word32 rotlVariable < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - assert ( y < 32 ) ; <nl> - return ( __rlwnm ( x , y , 0 , 31 ) ) ; <nl> - } <nl> - <nl> - template < > inline word32 rotrVariable < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - assert ( y < 32 ) ; <nl> - return ( __rlwnm ( x , 32 - y , 0 , 31 ) ) ; <nl> - } <nl> - <nl> - template < > inline word32 rotlMod < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - return ( __rlwnm ( x , y , 0 , 31 ) ) ; <nl> - } <nl> - <nl> - template < > inline word32 rotrMod < word32 > ( word32 x , unsigned int y ) <nl> - { <nl> - return ( __rlwnm ( x , 32 - y , 0 , 31 ) ) ; <nl> - } <nl> - <nl> - # endif / / # if ( defined ( __MWERKS__ ) & & TARGET_CPU_PPC ) <nl> - <nl> - / / * * * * * * * * * * * * * * endian reversal * * * * * * * * * * * * * * * <nl> - <nl> - template < class T > <nl> - inline unsigned int GetByte ( ByteOrder order , T value , unsigned int index ) <nl> - { <nl> - if ( order = = LITTLE_ENDIAN_ORDER ) <nl> - return GETBYTE ( value , index ) ; <nl> - else <nl> - return GETBYTE ( value , sizeof ( T ) - index - 1 ) ; <nl> - } <nl> - <nl> - inline byte ByteReverse ( byte value ) <nl> - { <nl> - return value ; <nl> - } <nl> - <nl> - inline word16 ByteReverse ( word16 value ) <nl> - { <nl> - # ifdef CRYPTOPP_BYTESWAP_AVAILABLE <nl> - return bswap_16 ( value ) ; <nl> - # elif defined ( _MSC_VER ) & & _MSC_VER > = 1300 <nl> - return _byteswap_ushort ( value ) ; <nl> - # else <nl> - return rotlFixed ( value , 8U ) ; <nl> - # endif <nl> - } <nl> - <nl> - inline word32 ByteReverse ( word32 value ) <nl> - { <nl> - # if defined ( __GNUC__ ) & & defined ( CRYPTOPP_X86_ASM_AVAILABLE ) <nl> - __asm__ ( " bswap % 0 " : " = r " ( value ) : " 0 " ( value ) ) ; <nl> - return value ; <nl> - # elif defined ( CRYPTOPP_BYTESWAP_AVAILABLE ) <nl> - return bswap_32 ( value ) ; <nl> - # elif defined ( __MWERKS__ ) & & TARGET_CPU_PPC <nl> - return ( word32 ) __lwbrx ( & value , 0 ) ; <nl> - # elif _MSC_VER > = 1400 | | ( _MSC_VER > = 1300 & & ! defined ( _DLL ) ) <nl> - return _byteswap_ulong ( value ) ; <nl> - # elif CRYPTOPP_FAST_ROTATE ( 32 ) <nl> - / / 5 instructions with rotate instruction , 9 without <nl> - return ( rotrFixed ( value , 8U ) & 0xff00ff00 ) | ( rotlFixed ( value , 8U ) & 0x00ff00ff ) ; <nl> - # else <nl> - / / 6 instructions with rotate instruction , 8 without <nl> - value = ( ( value & 0xFF00FF00 ) > > 8 ) | ( ( value & 0x00FF00FF ) < < 8 ) ; <nl> - return rotlFixed ( value , 16U ) ; <nl> - # endif <nl> - } <nl> - <nl> - inline word64 ByteReverse ( word64 value ) <nl> - { <nl> - # if defined ( __GNUC__ ) & & defined ( CRYPTOPP_X86_ASM_AVAILABLE ) & & defined ( __x86_64__ ) <nl> - __asm__ ( " bswap % 0 " : " = r " ( value ) : " 0 " ( value ) ) ; <nl> - return value ; <nl> - # elif defined ( CRYPTOPP_BYTESWAP_AVAILABLE ) <nl> - return bswap_64 ( value ) ; <nl> - # elif defined ( _MSC_VER ) & & _MSC_VER > = 1300 <nl> - return _byteswap_uint64 ( value ) ; <nl> - # elif CRYPTOPP_BOOL_SLOW_WORD64 <nl> - return ( word64 ( ByteReverse ( word32 ( value ) ) ) < < 32 ) | ByteReverse ( word32 ( value > > 32 ) ) ; <nl> - # else <nl> - value = ( ( value & W64LIT ( 0xFF00FF00FF00FF00 ) ) > > 8 ) | ( ( value & W64LIT ( 0x00FF00FF00FF00FF ) ) < < 8 ) ; <nl> - value = ( ( value & W64LIT ( 0xFFFF0000FFFF0000 ) ) > > 16 ) | ( ( value & W64LIT ( 0x0000FFFF0000FFFF ) ) < < 16 ) ; <nl> - return rotlFixed ( value , 32U ) ; <nl> - # endif <nl> - } <nl> - <nl> - inline byte BitReverse ( byte value ) <nl> - { <nl> - value = ( ( value & 0xAA ) > > 1 ) | ( ( value & 0x55 ) < < 1 ) ; <nl> - value = ( ( value & 0xCC ) > > 2 ) | ( ( value & 0x33 ) < < 2 ) ; <nl> - return rotlFixed ( value , 4U ) ; <nl> - } <nl> - <nl> - inline word16 BitReverse ( word16 value ) <nl> - { <nl> - value = ( ( value & 0xAAAA ) > > 1 ) | ( ( value & 0x5555 ) < < 1 ) ; <nl> - value = ( ( value & 0xCCCC ) > > 2 ) | ( ( value & 0x3333 ) < < 2 ) ; <nl> - value = ( ( value & 0xF0F0 ) > > 4 ) | ( ( value & 0x0F0F ) < < 4 ) ; <nl> - return ByteReverse ( value ) ; <nl> - } <nl> - <nl> - inline word32 BitReverse ( word32 value ) <nl> - { <nl> - value = ( ( value & 0xAAAAAAAA ) > > 1 ) | ( ( value & 0x55555555 ) < < 1 ) ; <nl> - value = ( ( value & 0xCCCCCCCC ) > > 2 ) | ( ( value & 0x33333333 ) < < 2 ) ; <nl> - value = ( ( value & 0xF0F0F0F0 ) > > 4 ) | ( ( value & 0x0F0F0F0F ) < < 4 ) ; <nl> - return ByteReverse ( value ) ; <nl> - } <nl> - <nl> - inline word64 BitReverse ( word64 value ) <nl> - { <nl> - # if CRYPTOPP_BOOL_SLOW_WORD64 <nl> - return ( word64 ( BitReverse ( word32 ( value ) ) ) < < 32 ) | BitReverse ( word32 ( value > > 32 ) ) ; <nl> - # else <nl> - value = ( ( value & W64LIT ( 0xAAAAAAAAAAAAAAAA ) ) > > 1 ) | ( ( value & W64LIT ( 0x5555555555555555 ) ) < < 1 ) ; <nl> - value = ( ( value & W64LIT ( 0xCCCCCCCCCCCCCCCC ) ) > > 2 ) | ( ( value & W64LIT ( 0x3333333333333333 ) ) < < 2 ) ; <nl> - value = ( ( value & W64LIT ( 0xF0F0F0F0F0F0F0F0 ) ) > > 4 ) | ( ( value & W64LIT ( 0x0F0F0F0F0F0F0F0F ) ) < < 4 ) ; <nl> - return ByteReverse ( value ) ; <nl> - # endif <nl> - } <nl> - <nl> - template < class T > <nl> - inline T BitReverse ( T value ) <nl> - { <nl> - if ( sizeof ( T ) = = 1 ) <nl> - return ( T ) BitReverse ( ( byte ) value ) ; <nl> - else if ( sizeof ( T ) = = 2 ) <nl> - return ( T ) BitReverse ( ( word16 ) value ) ; <nl> - else if ( sizeof ( T ) = = 4 ) <nl> - return ( T ) BitReverse ( ( word32 ) value ) ; <nl> - else <nl> - { <nl> - assert ( sizeof ( T ) = = 8 ) ; <nl> - return ( T ) BitReverse ( ( word64 ) value ) ; <nl> - } <nl> - } <nl> - <nl> - template < class T > <nl> - inline T ConditionalByteReverse ( ByteOrder order , T value ) <nl> - { <nl> - return NativeByteOrderIs ( order ) ? value : ByteReverse ( value ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - void ByteReverse ( T * out , const T * in , size_t byteCount ) <nl> - { <nl> - assert ( byteCount % sizeof ( T ) = = 0 ) ; <nl> - size_t count = byteCount / sizeof ( T ) ; <nl> - for ( size_t i = 0 ; i < count ; i + + ) <nl> - out [ i ] = ByteReverse ( in [ i ] ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - inline void ConditionalByteReverse ( ByteOrder order , T * out , const T * in , size_t byteCount ) <nl> - { <nl> - if ( ! NativeByteOrderIs ( order ) ) <nl> - ByteReverse ( out , in , byteCount ) ; <nl> - else if ( in ! = out ) <nl> - memcpy_s ( out , byteCount , in , byteCount ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - inline void GetUserKey ( ByteOrder order , T * out , size_t outlen , const byte * in , size_t inlen ) <nl> - { <nl> - const size_t U = sizeof ( T ) ; <nl> - assert ( inlen < = outlen * U ) ; <nl> - memcpy_s ( out , outlen * U , in , inlen ) ; <nl> - memset_z ( ( byte * ) out + inlen , 0 , outlen * U - inlen ) ; <nl> - ConditionalByteReverse ( order , out , out , RoundUpToMultipleOf ( inlen , U ) ) ; <nl> - } <nl> - <nl> - # ifndef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS <nl> - inline byte UnalignedGetWordNonTemplate ( ByteOrder order , const byte * block , const byte * ) <nl> - { <nl> - return block [ 0 ] ; <nl> - } <nl> - <nl> - inline word16 UnalignedGetWordNonTemplate ( ByteOrder order , const byte * block , const word16 * ) <nl> - { <nl> - return ( order = = BIG_ENDIAN_ORDER ) <nl> - ? block [ 1 ] | ( block [ 0 ] < < 8 ) <nl> - : block [ 0 ] | ( block [ 1 ] < < 8 ) ; <nl> - } <nl> - <nl> - inline word32 UnalignedGetWordNonTemplate ( ByteOrder order , const byte * block , const word32 * ) <nl> - { <nl> - return ( order = = BIG_ENDIAN_ORDER ) <nl> - ? word32 ( block [ 3 ] ) | ( word32 ( block [ 2 ] ) < < 8 ) | ( word32 ( block [ 1 ] ) < < 16 ) | ( word32 ( block [ 0 ] ) < < 24 ) <nl> - : word32 ( block [ 0 ] ) | ( word32 ( block [ 1 ] ) < < 8 ) | ( word32 ( block [ 2 ] ) < < 16 ) | ( word32 ( block [ 3 ] ) < < 24 ) ; <nl> - } <nl> - <nl> - inline word64 UnalignedGetWordNonTemplate ( ByteOrder order , const byte * block , const word64 * ) <nl> - { <nl> - return ( order = = BIG_ENDIAN_ORDER ) <nl> - ? <nl> - ( word64 ( block [ 7 ] ) | <nl> - ( word64 ( block [ 6 ] ) < < 8 ) | <nl> - ( word64 ( block [ 5 ] ) < < 16 ) | <nl> - ( word64 ( block [ 4 ] ) < < 24 ) | <nl> - ( word64 ( block [ 3 ] ) < < 32 ) | <nl> - ( word64 ( block [ 2 ] ) < < 40 ) | <nl> - ( word64 ( block [ 1 ] ) < < 48 ) | <nl> - ( word64 ( block [ 0 ] ) < < 56 ) ) <nl> - : <nl> - ( word64 ( block [ 0 ] ) | <nl> - ( word64 ( block [ 1 ] ) < < 8 ) | <nl> - ( word64 ( block [ 2 ] ) < < 16 ) | <nl> - ( word64 ( block [ 3 ] ) < < 24 ) | <nl> - ( word64 ( block [ 4 ] ) < < 32 ) | <nl> - ( word64 ( block [ 5 ] ) < < 40 ) | <nl> - ( word64 ( block [ 6 ] ) < < 48 ) | <nl> - ( word64 ( block [ 7 ] ) < < 56 ) ) ; <nl> - } <nl> - <nl> - inline void UnalignedPutWordNonTemplate ( ByteOrder order , byte * block , byte value , const byte * xorBlock ) <nl> - { <nl> - block [ 0 ] = xorBlock ? ( value ^ xorBlock [ 0 ] ) : value ; <nl> - } <nl> - <nl> - inline void UnalignedPutWordNonTemplate ( ByteOrder order , byte * block , word16 value , const byte * xorBlock ) <nl> - { <nl> - if ( order = = BIG_ENDIAN_ORDER ) <nl> - { <nl> - if ( xorBlock ) <nl> - { <nl> - block [ 0 ] = xorBlock [ 0 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - block [ 1 ] = xorBlock [ 1 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - } <nl> - else <nl> - { <nl> - block [ 0 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - block [ 1 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - if ( xorBlock ) <nl> - { <nl> - block [ 0 ] = xorBlock [ 0 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - block [ 1 ] = xorBlock [ 1 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - } <nl> - else <nl> - { <nl> - block [ 0 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - block [ 1 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - inline void UnalignedPutWordNonTemplate ( ByteOrder order , byte * block , word32 value , const byte * xorBlock ) <nl> - { <nl> - if ( order = = BIG_ENDIAN_ORDER ) <nl> - { <nl> - if ( xorBlock ) <nl> - { <nl> - block [ 0 ] = xorBlock [ 0 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 3 ) ; <nl> - block [ 1 ] = xorBlock [ 1 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 2 ) ; <nl> - block [ 2 ] = xorBlock [ 2 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - block [ 3 ] = xorBlock [ 3 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - } <nl> - else <nl> - { <nl> - block [ 0 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 3 ) ; <nl> - block [ 1 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 2 ) ; <nl> - block [ 2 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - block [ 3 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - if ( xorBlock ) <nl> - { <nl> - block [ 0 ] = xorBlock [ 0 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - block [ 1 ] = xorBlock [ 1 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - block [ 2 ] = xorBlock [ 2 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 2 ) ; <nl> - block [ 3 ] = xorBlock [ 3 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 3 ) ; <nl> - } <nl> - else <nl> - { <nl> - block [ 0 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - block [ 1 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - block [ 2 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 2 ) ; <nl> - block [ 3 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 3 ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - inline void UnalignedPutWordNonTemplate ( ByteOrder order , byte * block , word64 value , const byte * xorBlock ) <nl> - { <nl> - if ( order = = BIG_ENDIAN_ORDER ) <nl> - { <nl> - if ( xorBlock ) <nl> - { <nl> - block [ 0 ] = xorBlock [ 0 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 7 ) ; <nl> - block [ 1 ] = xorBlock [ 1 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 6 ) ; <nl> - block [ 2 ] = xorBlock [ 2 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 5 ) ; <nl> - block [ 3 ] = xorBlock [ 3 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 4 ) ; <nl> - block [ 4 ] = xorBlock [ 4 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 3 ) ; <nl> - block [ 5 ] = xorBlock [ 5 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 2 ) ; <nl> - block [ 6 ] = xorBlock [ 6 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - block [ 7 ] = xorBlock [ 7 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - } <nl> - else <nl> - { <nl> - block [ 0 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 7 ) ; <nl> - block [ 1 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 6 ) ; <nl> - block [ 2 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 5 ) ; <nl> - block [ 3 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 4 ) ; <nl> - block [ 4 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 3 ) ; <nl> - block [ 5 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 2 ) ; <nl> - block [ 6 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - block [ 7 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - if ( xorBlock ) <nl> - { <nl> - block [ 0 ] = xorBlock [ 0 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - block [ 1 ] = xorBlock [ 1 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - block [ 2 ] = xorBlock [ 2 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 2 ) ; <nl> - block [ 3 ] = xorBlock [ 3 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 3 ) ; <nl> - block [ 4 ] = xorBlock [ 4 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 4 ) ; <nl> - block [ 5 ] = xorBlock [ 5 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 5 ) ; <nl> - block [ 6 ] = xorBlock [ 6 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 6 ) ; <nl> - block [ 7 ] = xorBlock [ 7 ] ^ CRYPTOPP_GET_BYTE_AS_BYTE ( value , 7 ) ; <nl> - } <nl> - else <nl> - { <nl> - block [ 0 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 0 ) ; <nl> - block [ 1 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 1 ) ; <nl> - block [ 2 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 2 ) ; <nl> - block [ 3 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 3 ) ; <nl> - block [ 4 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 4 ) ; <nl> - block [ 5 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 5 ) ; <nl> - block [ 6 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 6 ) ; <nl> - block [ 7 ] = CRYPTOPP_GET_BYTE_AS_BYTE ( value , 7 ) ; <nl> - } <nl> - } <nl> - } <nl> - # endif / / # ifndef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS <nl> - <nl> - template < class T > <nl> - inline T GetWord ( bool assumeAligned , ByteOrder order , const byte * block ) <nl> - { <nl> - # ifndef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS <nl> - if ( ! assumeAligned ) <nl> - return UnalignedGetWordNonTemplate ( order , block , ( T * ) NULL ) ; <nl> - assert ( IsAligned < T > ( block ) ) ; <nl> - # endif <nl> - return ConditionalByteReverse ( order , * reinterpret_cast < const T * > ( block ) ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - inline void GetWord ( bool assumeAligned , ByteOrder order , T & result , const byte * block ) <nl> - { <nl> - result = GetWord < T > ( assumeAligned , order , block ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - inline void PutWord ( bool assumeAligned , ByteOrder order , byte * block , T value , const byte * xorBlock = NULL ) <nl> - { <nl> - # ifndef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS <nl> - if ( ! assumeAligned ) <nl> - return UnalignedPutWordNonTemplate ( order , block , value , xorBlock ) ; <nl> - assert ( IsAligned < T > ( block ) ) ; <nl> - assert ( IsAligned < T > ( xorBlock ) ) ; <nl> - # endif <nl> - * reinterpret_cast < T * > ( block ) = ConditionalByteReverse ( order , value ) ^ ( xorBlock ? * reinterpret_cast < const T * > ( xorBlock ) : 0 ) ; <nl> - } <nl> - <nl> - template < class T , class B , bool A = false > <nl> - class GetBlock <nl> - { <nl> - public : <nl> - GetBlock ( const void * block ) <nl> - : m_block ( ( const byte * ) block ) { } <nl> - <nl> - template < class U > <nl> - inline GetBlock < T , B , A > & operator ( ) ( U & x ) <nl> - { <nl> - CRYPTOPP_COMPILE_ASSERT ( sizeof ( U ) > = sizeof ( T ) ) ; <nl> - x = GetWord < T > ( A , B : : ToEnum ( ) , m_block ) ; <nl> - m_block + = sizeof ( T ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - private : <nl> - const byte * m_block ; <nl> - } ; <nl> - <nl> - template < class T , class B , bool A = false > <nl> - class PutBlock <nl> - { <nl> - public : <nl> - PutBlock ( const void * xorBlock , void * block ) <nl> - : m_xorBlock ( ( const byte * ) xorBlock ) , m_block ( ( byte * ) block ) { } <nl> - <nl> - template < class U > <nl> - inline PutBlock < T , B , A > & operator ( ) ( U x ) <nl> - { <nl> - PutWord ( A , B : : ToEnum ( ) , m_block , ( T ) x , m_xorBlock ) ; <nl> - m_block + = sizeof ( T ) ; <nl> - if ( m_xorBlock ) <nl> - m_xorBlock + = sizeof ( T ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - private : <nl> - const byte * m_xorBlock ; <nl> - byte * m_block ; <nl> - } ; <nl> - <nl> - template < class T , class B , bool GA = false , bool PA = false > <nl> - struct BlockGetAndPut <nl> - { <nl> - / / function needed because of C + + grammatical ambiguity between expression - statements and declarations <nl> - static inline GetBlock < T , B , GA > Get ( const void * block ) { return GetBlock < T , B , GA > ( block ) ; } <nl> - typedef PutBlock < T , B , PA > Put ; <nl> - } ; <nl> - <nl> - template < class T > <nl> - std : : string WordToString ( T value , ByteOrder order = BIG_ENDIAN_ORDER ) <nl> - { <nl> - if ( ! NativeByteOrderIs ( order ) ) <nl> - value = ByteReverse ( value ) ; <nl> - <nl> - return std : : string ( ( char * ) & value , sizeof ( value ) ) ; <nl> - } <nl> - <nl> - template < class T > <nl> - T StringToWord ( const std : : string & str , ByteOrder order = BIG_ENDIAN_ORDER ) <nl> - { <nl> - T value = 0 ; <nl> - memcpy_s ( & value , sizeof ( value ) , str . data ( ) , UnsignedMin ( str . size ( ) , sizeof ( value ) ) ) ; <nl> - return NativeByteOrderIs ( order ) ? value : ByteReverse ( value ) ; <nl> - } <nl> - <nl> - / / * * * * * * * * * * * * * * help remove warning on g + + * * * * * * * * * * * * * * * <nl> - <nl> - template < bool overflow > struct SafeShifter ; <nl> - <nl> - template < > struct SafeShifter < true > <nl> - { <nl> - template < class T > <nl> - static inline T RightShift ( T value , unsigned int bits ) <nl> - { <nl> - return 0 ; <nl> - } <nl> - <nl> - template < class T > <nl> - static inline T LeftShift ( T value , unsigned int bits ) <nl> - { <nl> - return 0 ; <nl> - } <nl> - } ; <nl> - <nl> - template < > struct SafeShifter < false > <nl> - { <nl> - template < class T > <nl> - static inline T RightShift ( T value , unsigned int bits ) <nl> - { <nl> - return value > > bits ; <nl> - } <nl> - <nl> - template < class T > <nl> - static inline T LeftShift ( T value , unsigned int bits ) <nl> - { <nl> - return value < < bits ; <nl> - } <nl> - } ; <nl> - <nl> - template < unsigned int bits , class T > <nl> - inline T SafeRightShift ( T value ) <nl> - { <nl> - return SafeShifter < ( bits > = ( 8 * sizeof ( T ) ) ) > : : RightShift ( value , bits ) ; <nl> - } <nl> - <nl> - template < unsigned int bits , class T > <nl> - inline T SafeLeftShift ( T value ) <nl> - { <nl> - return SafeShifter < ( bits > = ( 8 * sizeof ( T ) ) ) > : : LeftShift ( value , bits ) ; <nl> - } <nl> - <nl> - / / * * * * * * * * * * * * * * use one buffer for multiple data members * * * * * * * * * * * * * * * <nl> - <nl> - # define CRYPTOPP_BLOCK_1 ( n , t , s ) t * m_ # # n ( ) { return ( t * ) ( m_aggregate + 0 ) ; } size_t SS1 ( ) { return sizeof ( t ) * ( s ) ; } size_t m_ # # n # # Size ( ) { return ( s ) ; } <nl> - # define CRYPTOPP_BLOCK_2 ( n , t , s ) t * m_ # # n ( ) { return ( t * ) ( m_aggregate + SS1 ( ) ) ; } size_t SS2 ( ) { return SS1 ( ) + sizeof ( t ) * ( s ) ; } size_t m_ # # n # # Size ( ) { return ( s ) ; } <nl> - # define CRYPTOPP_BLOCK_3 ( n , t , s ) t * m_ # # n ( ) { return ( t * ) ( m_aggregate + SS2 ( ) ) ; } size_t SS3 ( ) { return SS2 ( ) + sizeof ( t ) * ( s ) ; } size_t m_ # # n # # Size ( ) { return ( s ) ; } <nl> - # define CRYPTOPP_BLOCK_4 ( n , t , s ) t * m_ # # n ( ) { return ( t * ) ( m_aggregate + SS3 ( ) ) ; } size_t SS4 ( ) { return SS3 ( ) + sizeof ( t ) * ( s ) ; } size_t m_ # # n # # Size ( ) { return ( s ) ; } <nl> - # define CRYPTOPP_BLOCK_5 ( n , t , s ) t * m_ # # n ( ) { return ( t * ) ( m_aggregate + SS4 ( ) ) ; } size_t SS5 ( ) { return SS4 ( ) + sizeof ( t ) * ( s ) ; } size_t m_ # # n # # Size ( ) { return ( s ) ; } <nl> - # define CRYPTOPP_BLOCK_6 ( n , t , s ) t * m_ # # n ( ) { return ( t * ) ( m_aggregate + SS5 ( ) ) ; } size_t SS6 ( ) { return SS5 ( ) + sizeof ( t ) * ( s ) ; } size_t m_ # # n # # Size ( ) { return ( s ) ; } <nl> - # define CRYPTOPP_BLOCK_7 ( n , t , s ) t * m_ # # n ( ) { return ( t * ) ( m_aggregate + SS6 ( ) ) ; } size_t SS7 ( ) { return SS6 ( ) + sizeof ( t ) * ( s ) ; } size_t m_ # # n # # Size ( ) { return ( s ) ; } <nl> - # define CRYPTOPP_BLOCK_8 ( n , t , s ) t * m_ # # n ( ) { return ( t * ) ( m_aggregate + SS7 ( ) ) ; } size_t SS8 ( ) { return SS7 ( ) + sizeof ( t ) * ( s ) ; } size_t m_ # # n # # Size ( ) { return ( s ) ; } <nl> - # define CRYPTOPP_BLOCKS_END ( i ) size_t SST ( ) { return SS # # i ( ) ; } void AllocateBlocks ( ) { m_aggregate . New ( SST ( ) ) ; } AlignedSecByteBlock m_aggregate ; <nl> - <nl> - NAMESPACE_END <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index d6b7ef32c847 . . 000000000000 <nl> mmm a / src / cryptopp / obj / . gitignore <nl> ppp / dev / null <nl> <nl> - * <nl> - ! . gitignore <nl> deleted file mode 100644 <nl> index 418c39076dfe . . 000000000000 <nl> mmm a / src / cryptopp / pch . h <nl> ppp / dev / null <nl> <nl> - # ifndef CRYPTOPP_PCH_H <nl> - # define CRYPTOPP_PCH_H <nl> - <nl> - # ifdef CRYPTOPP_GENERATE_X64_MASM <nl> - <nl> - # include " cpu . h " <nl> - <nl> - # else <nl> - <nl> - # include " config . h " <nl> - <nl> - # ifdef USE_PRECOMPILED_HEADERS <nl> - # include " simple . h " <nl> - # include " secblock . h " <nl> - # include " misc . h " <nl> - # include " smartptr . h " <nl> - # endif <nl> - <nl> - # endif <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 2025757dbb58 . . 000000000000 <nl> mmm a / src / cryptopp / secblock . h <nl> ppp / dev / null <nl> <nl> - / / secblock . h - written and placed in the public domain by Wei Dai <nl> - <nl> - # ifndef CRYPTOPP_SECBLOCK_H <nl> - # define CRYPTOPP_SECBLOCK_H <nl> - <nl> - # include " config . h " <nl> - # include " misc . h " <nl> - # include < assert . h > <nl> - <nl> - # if defined ( CRYPTOPP_MEMALIGN_AVAILABLE ) | | defined ( CRYPTOPP_MM_MALLOC_AVAILABLE ) | | defined ( QNX ) <nl> - # include < malloc . h > <nl> - # else <nl> - # include < stdlib . h > <nl> - # endif <nl> - <nl> - NAMESPACE_BEGIN ( CryptoPP ) <nl> - <nl> - / / * * * * * * * * * * * * * * secure memory allocation * * * * * * * * * * * * * * * <nl> - <nl> - template < class T > <nl> - class AllocatorBase <nl> - { <nl> - public : <nl> - typedef T value_type ; <nl> - typedef size_t size_type ; <nl> - # ifdef CRYPTOPP_MSVCRT6 <nl> - typedef ptrdiff_t difference_type ; <nl> - # else <nl> - typedef std : : ptrdiff_t difference_type ; <nl> - # endif <nl> - typedef T * pointer ; <nl> - typedef const T * const_pointer ; <nl> - typedef T & reference ; <nl> - typedef const T & const_reference ; <nl> - <nl> - pointer address ( reference r ) const { return ( & r ) ; } <nl> - const_pointer address ( const_reference r ) const { return ( & r ) ; } <nl> - void construct ( pointer p , const T & val ) { new ( p ) T ( val ) ; } <nl> - void destroy ( pointer p ) { p - > ~ T ( ) ; } <nl> - size_type max_size ( ) const { return ~ size_type ( 0 ) / sizeof ( T ) ; } / / switch to std : : numeric_limits < T > : : max later <nl> - <nl> - protected : <nl> - static void CheckSize ( size_t n ) <nl> - { <nl> - if ( n > ~ size_t ( 0 ) / sizeof ( T ) ) <nl> - throw InvalidArgument ( " AllocatorBase : requested size would cause integer overflow " ) ; <nl> - } <nl> - } ; <nl> - <nl> - # define CRYPTOPP_INHERIT_ALLOCATOR_TYPES \ <nl> - typedef typename AllocatorBase < T > : : value_type value_type ; \ <nl> - typedef typename AllocatorBase < T > : : size_type size_type ; \ <nl> - typedef typename AllocatorBase < T > : : difference_type difference_type ; \ <nl> - typedef typename AllocatorBase < T > : : pointer pointer ; \ <nl> - typedef typename AllocatorBase < T > : : const_pointer const_pointer ; \ <nl> - typedef typename AllocatorBase < T > : : reference reference ; \ <nl> - typedef typename AllocatorBase < T > : : const_reference const_reference ; <nl> - <nl> - # if defined ( _MSC_VER ) & & ( _MSC_VER < 1300 ) <nl> - / / this pragma causes an internal compiler error if placed immediately before std : : swap ( a , b ) <nl> - # pragma warning ( push ) <nl> - # pragma warning ( disable : 4700 ) / / VC60 workaround : don ' t know how to get rid of this warning <nl> - # endif <nl> - <nl> - template < class T , class A > <nl> - typename A : : pointer StandardReallocate ( A & a , T * p , typename A : : size_type oldSize , typename A : : size_type newSize , bool preserve ) <nl> - { <nl> - if ( oldSize = = newSize ) <nl> - return p ; <nl> - <nl> - if ( preserve ) <nl> - { <nl> - typename A : : pointer newPointer = a . allocate ( newSize , NULL ) ; <nl> - memcpy_s ( newPointer , sizeof ( T ) * newSize , p , sizeof ( T ) * STDMIN ( oldSize , newSize ) ) ; <nl> - a . deallocate ( p , oldSize ) ; <nl> - return newPointer ; <nl> - } <nl> - else <nl> - { <nl> - a . deallocate ( p , oldSize ) ; <nl> - return a . allocate ( newSize , NULL ) ; <nl> - } <nl> - } <nl> - <nl> - # if defined ( _MSC_VER ) & & ( _MSC_VER < 1300 ) <nl> - # pragma warning ( pop ) <nl> - # endif <nl> - <nl> - template < class T , bool T_Align16 = false > <nl> - class AllocatorWithCleanup : public AllocatorBase < T > <nl> - { <nl> - public : <nl> - CRYPTOPP_INHERIT_ALLOCATOR_TYPES <nl> - <nl> - pointer allocate ( size_type n , const void * = NULL ) <nl> - { <nl> - CheckSize ( n ) ; <nl> - if ( n = = 0 ) <nl> - return NULL ; <nl> - <nl> - if ( CRYPTOPP_BOOL_ALIGN16_ENABLED & & T_Align16 & & n * sizeof ( T ) > = 16 ) <nl> - { <nl> - byte * p ; <nl> - # ifdef CRYPTOPP_MM_MALLOC_AVAILABLE <nl> - while ( ! ( p = ( byte * ) _mm_malloc ( sizeof ( T ) * n , 16 ) ) ) <nl> - # elif defined ( CRYPTOPP_MEMALIGN_AVAILABLE ) <nl> - while ( ! ( p = ( byte * ) memalign ( 16 , sizeof ( T ) * n ) ) ) <nl> - # elif defined ( CRYPTOPP_MALLOC_ALIGNMENT_IS_16 ) <nl> - while ( ! ( p = ( byte * ) malloc ( sizeof ( T ) * n ) ) ) <nl> - # else <nl> - while ( ! ( p = ( byte * ) malloc ( sizeof ( T ) * n + 16 ) ) ) <nl> - # endif <nl> - CallNewHandler ( ) ; <nl> - <nl> - # ifdef CRYPTOPP_NO_ALIGNED_ALLOC <nl> - size_t adjustment = 16 - ( ( size_t ) p % 16 ) ; <nl> - p + = adjustment ; <nl> - p [ - 1 ] = ( byte ) adjustment ; <nl> - # endif <nl> - <nl> - assert ( IsAlignedOn ( p , 16 ) ) ; <nl> - return ( pointer ) p ; <nl> - } <nl> - <nl> - pointer p ; <nl> - while ( ! ( p = ( pointer ) malloc ( sizeof ( T ) * n ) ) ) <nl> - CallNewHandler ( ) ; <nl> - return p ; <nl> - } <nl> - <nl> - void deallocate ( void * p , size_type n ) <nl> - { <nl> - memset_z ( p , 0 , n * sizeof ( T ) ) ; <nl> - <nl> - if ( CRYPTOPP_BOOL_ALIGN16_ENABLED & & T_Align16 & & n * sizeof ( T ) > = 16 ) <nl> - { <nl> - # ifdef CRYPTOPP_MM_MALLOC_AVAILABLE <nl> - _mm_free ( p ) ; <nl> - # elif defined ( CRYPTOPP_NO_ALIGNED_ALLOC ) <nl> - p = ( byte * ) p - ( ( byte * ) p ) [ - 1 ] ; <nl> - free ( p ) ; <nl> - # else <nl> - free ( p ) ; <nl> - # endif <nl> - return ; <nl> - } <nl> - <nl> - free ( p ) ; <nl> - } <nl> - <nl> - pointer reallocate ( T * p , size_type oldSize , size_type newSize , bool preserve ) <nl> - { <nl> - return StandardReallocate ( * this , p , oldSize , newSize , preserve ) ; <nl> - } <nl> - <nl> - / / VS . NET STL enforces the policy of " All STL - compliant allocators have to provide a <nl> - / / template class member called rebind " . <nl> - template < class U > struct rebind { typedef AllocatorWithCleanup < U , T_Align16 > other ; } ; <nl> - # if _MSC_VER > = 1500 <nl> - AllocatorWithCleanup ( ) { } <nl> - template < class U , bool A > AllocatorWithCleanup ( const AllocatorWithCleanup < U , A > & ) { } <nl> - # endif <nl> - } ; <nl> - <nl> - CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup < byte > ; <nl> - CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup < word16 > ; <nl> - CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup < word32 > ; <nl> - CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup < word64 > ; <nl> - # if CRYPTOPP_BOOL_X86 <nl> - CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup < word , true > ; / / for Integer <nl> - # endif <nl> - <nl> - template < class T > <nl> - class NullAllocator : public AllocatorBase < T > <nl> - { <nl> - public : <nl> - CRYPTOPP_INHERIT_ALLOCATOR_TYPES <nl> - <nl> - pointer allocate ( size_type n , const void * = NULL ) <nl> - { <nl> - assert ( false ) ; <nl> - return NULL ; <nl> - } <nl> - <nl> - void deallocate ( void * p , size_type n ) <nl> - { <nl> - / / / / Bitcoin : don ' t know why this trips , probably a false alarm , depends on the compiler used . <nl> - / / assert ( false ) ; <nl> - } <nl> - <nl> - size_type max_size ( ) const { return 0 ; } <nl> - } ; <nl> - <nl> - / / This allocator can ' t be used with standard collections because <nl> - / / they require that all objects of the same allocator type are equivalent . <nl> - / / So this is for use with SecBlock only . <nl> - template < class T , size_t S , class A = NullAllocator < T > , bool T_Align16 = false > <nl> - class FixedSizeAllocatorWithCleanup : public AllocatorBase < T > <nl> - { <nl> - public : <nl> - CRYPTOPP_INHERIT_ALLOCATOR_TYPES <nl> - <nl> - FixedSizeAllocatorWithCleanup ( ) : m_allocated ( false ) { } <nl> - <nl> - pointer allocate ( size_type n ) <nl> - { <nl> - assert ( IsAlignedOn ( m_array , 8 ) ) ; <nl> - <nl> - if ( n < = S & & ! m_allocated ) <nl> - { <nl> - m_allocated = true ; <nl> - return GetAlignedArray ( ) ; <nl> - } <nl> - else <nl> - return m_fallbackAllocator . allocate ( n ) ; <nl> - } <nl> - <nl> - pointer allocate ( size_type n , const void * hint ) <nl> - { <nl> - if ( n < = S & & ! m_allocated ) <nl> - { <nl> - m_allocated = true ; <nl> - return GetAlignedArray ( ) ; <nl> - } <nl> - else <nl> - return m_fallbackAllocator . allocate ( n , hint ) ; <nl> - } <nl> - <nl> - void deallocate ( void * p , size_type n ) <nl> - { <nl> - if ( p = = GetAlignedArray ( ) ) <nl> - { <nl> - assert ( n < = S ) ; <nl> - assert ( m_allocated ) ; <nl> - m_allocated = false ; <nl> - memset ( p , 0 , n * sizeof ( T ) ) ; <nl> - } <nl> - else <nl> - m_fallbackAllocator . deallocate ( p , n ) ; <nl> - } <nl> - <nl> - pointer reallocate ( pointer p , size_type oldSize , size_type newSize , bool preserve ) <nl> - { <nl> - if ( p = = GetAlignedArray ( ) & & newSize < = S ) <nl> - { <nl> - assert ( oldSize < = S ) ; <nl> - if ( oldSize > newSize ) <nl> - memset ( p + newSize , 0 , ( oldSize - newSize ) * sizeof ( T ) ) ; <nl> - return p ; <nl> - } <nl> - <nl> - pointer newPointer = allocate ( newSize , NULL ) ; <nl> - if ( preserve ) <nl> - memcpy ( newPointer , p , sizeof ( T ) * STDMIN ( oldSize , newSize ) ) ; <nl> - deallocate ( p , oldSize ) ; <nl> - return newPointer ; <nl> - } <nl> - <nl> - size_type max_size ( ) const { return STDMAX ( m_fallbackAllocator . max_size ( ) , S ) ; } <nl> - <nl> - private : <nl> - # ifdef __BORLANDC__ <nl> - T * GetAlignedArray ( ) { return m_array ; } <nl> - T m_array [ S ] ; <nl> - # else <nl> - T * GetAlignedArray ( ) { return ( CRYPTOPP_BOOL_ALIGN16_ENABLED & & T_Align16 ) ? ( T * ) ( ( ( byte * ) m_array ) + ( 0 - ( size_t ) m_array ) % 16 ) : m_array ; } <nl> - CRYPTOPP_ALIGN_DATA ( 8 ) T m_array [ ( CRYPTOPP_BOOL_ALIGN16_ENABLED & & T_Align16 ) ? S + 8 / sizeof ( T ) : S ] ; <nl> - # endif <nl> - A m_fallbackAllocator ; <nl> - bool m_allocated ; <nl> - } ; <nl> - <nl> - / / ! a block of memory allocated using A <nl> - template < class T , class A = AllocatorWithCleanup < T > > <nl> - class SecBlock <nl> - { <nl> - public : <nl> - typedef typename A : : value_type value_type ; <nl> - typedef typename A : : pointer iterator ; <nl> - typedef typename A : : const_pointer const_iterator ; <nl> - typedef typename A : : size_type size_type ; <nl> - <nl> - explicit SecBlock ( size_type size = 0 ) <nl> - : m_size ( size ) { m_ptr = m_alloc . allocate ( size , NULL ) ; } <nl> - SecBlock ( const SecBlock < T , A > & t ) <nl> - : m_size ( t . m_size ) { m_ptr = m_alloc . allocate ( m_size , NULL ) ; memcpy_s ( m_ptr , m_size * sizeof ( T ) , t . m_ptr , m_size * sizeof ( T ) ) ; } <nl> - SecBlock ( const T * t , size_type len ) <nl> - : m_size ( len ) <nl> - { <nl> - m_ptr = m_alloc . allocate ( len , NULL ) ; <nl> - if ( t = = NULL ) <nl> - memset_z ( m_ptr , 0 , len * sizeof ( T ) ) ; <nl> - else <nl> - memcpy ( m_ptr , t , len * sizeof ( T ) ) ; <nl> - } <nl> - <nl> - ~ SecBlock ( ) <nl> - { m_alloc . deallocate ( m_ptr , m_size ) ; } <nl> - <nl> - # ifdef __BORLANDC__ <nl> - operator T * ( ) const <nl> - { return ( T * ) m_ptr ; } <nl> - # else <nl> - operator const void * ( ) const <nl> - { return m_ptr ; } <nl> - operator void * ( ) <nl> - { return m_ptr ; } <nl> - <nl> - operator const T * ( ) const <nl> - { return m_ptr ; } <nl> - operator T * ( ) <nl> - { return m_ptr ; } <nl> - # endif <nl> - <nl> - / / T * operator + ( size_type offset ) <nl> - / / { return m_ptr + offset ; } <nl> - <nl> - / / const T * operator + ( size_type offset ) const <nl> - / / { return m_ptr + offset ; } <nl> - <nl> - / / T & operator [ ] ( size_type index ) <nl> - / / { assert ( index > = 0 & & index < m_size ) ; return m_ptr [ index ] ; } <nl> - <nl> - / / const T & operator [ ] ( size_type index ) const <nl> - / / { assert ( index > = 0 & & index < m_size ) ; return m_ptr [ index ] ; } <nl> - <nl> - iterator begin ( ) <nl> - { return m_ptr ; } <nl> - const_iterator begin ( ) const <nl> - { return m_ptr ; } <nl> - iterator end ( ) <nl> - { return m_ptr + m_size ; } <nl> - const_iterator end ( ) const <nl> - { return m_ptr + m_size ; } <nl> - <nl> - typename A : : pointer data ( ) { return m_ptr ; } <nl> - typename A : : const_pointer data ( ) const { return m_ptr ; } <nl> - <nl> - size_type size ( ) const { return m_size ; } <nl> - bool empty ( ) const { return m_size = = 0 ; } <nl> - <nl> - byte * BytePtr ( ) { return ( byte * ) m_ptr ; } <nl> - const byte * BytePtr ( ) const { return ( const byte * ) m_ptr ; } <nl> - size_type SizeInBytes ( ) const { return m_size * sizeof ( T ) ; } <nl> - <nl> - / / ! set contents and size <nl> - void Assign ( const T * t , size_type len ) <nl> - { <nl> - New ( len ) ; <nl> - memcpy_s ( m_ptr , m_size * sizeof ( T ) , t , len * sizeof ( T ) ) ; <nl> - } <nl> - <nl> - / / ! copy contents and size from another SecBlock <nl> - void Assign ( const SecBlock < T , A > & t ) <nl> - { <nl> - New ( t . m_size ) ; <nl> - memcpy_s ( m_ptr , m_size * sizeof ( T ) , t . m_ptr , m_size * sizeof ( T ) ) ; <nl> - } <nl> - <nl> - SecBlock < T , A > & operator = ( const SecBlock < T , A > & t ) <nl> - { <nl> - Assign ( t ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - / / append to this object <nl> - SecBlock < T , A > & operator + = ( const SecBlock < T , A > & t ) <nl> - { <nl> - size_type oldSize = m_size ; <nl> - Grow ( m_size + t . m_size ) ; <nl> - memcpy_s ( m_ptr + oldSize , m_size * sizeof ( T ) , t . m_ptr , t . m_size * sizeof ( T ) ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - / / append operator <nl> - SecBlock < T , A > operator + ( const SecBlock < T , A > & t ) <nl> - { <nl> - SecBlock < T , A > result ( m_size + t . m_size ) ; <nl> - memcpy_s ( result . m_ptr , result . m_size * sizeof ( T ) , m_ptr , m_size * sizeof ( T ) ) ; <nl> - memcpy_s ( result . m_ptr + m_size , t . m_size * sizeof ( T ) , t . m_ptr , t . m_size * sizeof ( T ) ) ; <nl> - return result ; <nl> - } <nl> - <nl> - bool operator = = ( const SecBlock < T , A > & t ) const <nl> - { <nl> - return m_size = = t . m_size & & VerifyBufsEqual ( m_ptr , t . m_ptr , m_size * sizeof ( T ) ) ; <nl> - } <nl> - <nl> - bool operator ! = ( const SecBlock < T , A > & t ) const <nl> - { <nl> - return ! operator = = ( t ) ; <nl> - } <nl> - <nl> - / / ! change size , without preserving contents <nl> - void New ( size_type newSize ) <nl> - { <nl> - m_ptr = m_alloc . reallocate ( m_ptr , m_size , newSize , false ) ; <nl> - m_size = newSize ; <nl> - } <nl> - <nl> - / / ! change size and set contents to 0 <nl> - void CleanNew ( size_type newSize ) <nl> - { <nl> - New ( newSize ) ; <nl> - memset_z ( m_ptr , 0 , m_size * sizeof ( T ) ) ; <nl> - } <nl> - <nl> - / / ! change size only if newSize > current size . contents are preserved <nl> - void Grow ( size_type newSize ) <nl> - { <nl> - if ( newSize > m_size ) <nl> - { <nl> - m_ptr = m_alloc . reallocate ( m_ptr , m_size , newSize , true ) ; <nl> - m_size = newSize ; <nl> - } <nl> - } <nl> - <nl> - / / ! change size only if newSize > current size . contents are preserved and additional area is set to 0 <nl> - void CleanGrow ( size_type newSize ) <nl> - { <nl> - if ( newSize > m_size ) <nl> - { <nl> - m_ptr = m_alloc . reallocate ( m_ptr , m_size , newSize , true ) ; <nl> - memset ( m_ptr + m_size , 0 , ( newSize - m_size ) * sizeof ( T ) ) ; <nl> - m_size = newSize ; <nl> - } <nl> - } <nl> - <nl> - / / ! change size and preserve contents <nl> - void resize ( size_type newSize ) <nl> - { <nl> - m_ptr = m_alloc . reallocate ( m_ptr , m_size , newSize , true ) ; <nl> - m_size = newSize ; <nl> - } <nl> - <nl> - / / ! swap contents and size with another SecBlock <nl> - void swap ( SecBlock < T , A > & b ) <nl> - { <nl> - std : : swap ( m_alloc , b . m_alloc ) ; <nl> - std : : swap ( m_size , b . m_size ) ; <nl> - std : : swap ( m_ptr , b . m_ptr ) ; <nl> - } <nl> - <nl> - / / private : <nl> - A m_alloc ; <nl> - size_type m_size ; <nl> - T * m_ptr ; <nl> - } ; <nl> - <nl> - typedef SecBlock < byte > SecByteBlock ; <nl> - typedef SecBlock < byte , AllocatorWithCleanup < byte , true > > AlignedSecByteBlock ; <nl> - typedef SecBlock < word > SecWordBlock ; <nl> - <nl> - / / ! a SecBlock with fixed size , allocated statically <nl> - template < class T , unsigned int S , class A = FixedSizeAllocatorWithCleanup < T , S > > <nl> - class FixedSizeSecBlock : public SecBlock < T , A > <nl> - { <nl> - public : <nl> - explicit FixedSizeSecBlock ( ) : SecBlock < T , A > ( S ) { } <nl> - } ; <nl> - <nl> - template < class T , unsigned int S , bool T_Align16 = true > <nl> - class FixedSizeAlignedSecBlock : public FixedSizeSecBlock < T , S , FixedSizeAllocatorWithCleanup < T , S , NullAllocator < T > , T_Align16 > > <nl> - { <nl> - } ; <nl> - <nl> - / / ! a SecBlock that preallocates size S statically , and uses the heap when this size is exceeded <nl> - template < class T , unsigned int S , class A = FixedSizeAllocatorWithCleanup < T , S , AllocatorWithCleanup < T > > > <nl> - class SecBlockWithHint : public SecBlock < T , A > <nl> - { <nl> - public : <nl> - explicit SecBlockWithHint ( size_t size ) : SecBlock < T , A > ( size ) { } <nl> - } ; <nl> - <nl> - template < class T , bool A , class U , bool B > <nl> - inline bool operator = = ( const CryptoPP : : AllocatorWithCleanup < T , A > & , const CryptoPP : : AllocatorWithCleanup < U , B > & ) { return ( true ) ; } <nl> - template < class T , bool A , class U , bool B > <nl> - inline bool operator ! = ( const CryptoPP : : AllocatorWithCleanup < T , A > & , const CryptoPP : : AllocatorWithCleanup < U , B > & ) { return ( false ) ; } <nl> - <nl> - NAMESPACE_END <nl> - <nl> - NAMESPACE_BEGIN ( std ) <nl> - template < class T , class A > <nl> - inline void swap ( CryptoPP : : SecBlock < T , A > & a , CryptoPP : : SecBlock < T , A > & b ) <nl> - { <nl> - a . swap ( b ) ; <nl> - } <nl> - <nl> - # if defined ( _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE ) | | ( defined ( _STLPORT_VERSION ) & & ! defined ( _STLP_MEMBER_TEMPLATE_CLASSES ) ) <nl> - / / working for STLport 5 . 1 . 3 and MSVC 6 SP5 <nl> - template < class _Tp1 , class _Tp2 > <nl> - inline CryptoPP : : AllocatorWithCleanup < _Tp2 > & <nl> - __stl_alloc_rebind ( CryptoPP : : AllocatorWithCleanup < _Tp1 > & __a , const _Tp2 * ) <nl> - { <nl> - return ( CryptoPP : : AllocatorWithCleanup < _Tp2 > & ) ( __a ) ; <nl> - } <nl> - # endif <nl> - <nl> - NAMESPACE_END <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index fd0b0a2596e0 . . 000000000000 <nl> mmm a / src / cryptopp / sha . cpp <nl> ppp / dev / null <nl> <nl> - / / sha . cpp - modified by Wei Dai from Steve Reid ' s public domain sha1 . c <nl> - <nl> - / / Steve Reid implemented SHA - 1 . Wei Dai implemented SHA - 2 . <nl> - / / Both are in the public domain . <nl> - <nl> - / / use " cl / EP / P / DCRYPTOPP_GENERATE_X64_MASM sha . cpp " to generate MASM code <nl> - <nl> - # include " pch . h " <nl> - <nl> - # ifndef CRYPTOPP_IMPORTS <nl> - # ifndef CRYPTOPP_GENERATE_X64_MASM <nl> - <nl> - # include " sha . h " <nl> - # include " misc . h " <nl> - # include " cpu . h " <nl> - <nl> - NAMESPACE_BEGIN ( CryptoPP ) <nl> - <nl> - / / start of Steve Reid ' s code <nl> - <nl> - # define blk0 ( i ) ( W [ i ] = data [ i ] ) <nl> - # define blk1 ( i ) ( W [ i & 15 ] = rotlFixed ( W [ ( i + 13 ) & 15 ] ^ W [ ( i + 8 ) & 15 ] ^ W [ ( i + 2 ) & 15 ] ^ W [ i & 15 ] , 1 ) ) <nl> - <nl> - void SHA1 : : InitState ( HashWordType * state ) <nl> - { <nl> - state [ 0 ] = 0x67452301L ; <nl> - state [ 1 ] = 0xEFCDAB89L ; <nl> - state [ 2 ] = 0x98BADCFEL ; <nl> - state [ 3 ] = 0x10325476L ; <nl> - state [ 4 ] = 0xC3D2E1F0L ; <nl> - } <nl> - <nl> - # define f1 ( x , y , z ) ( z ^ ( x & ( y ^ z ) ) ) <nl> - # define f2 ( x , y , z ) ( x ^ y ^ z ) <nl> - # define f3 ( x , y , z ) ( ( x & y ) | ( z & ( x | y ) ) ) <nl> - # define f4 ( x , y , z ) ( x ^ y ^ z ) <nl> - <nl> - / * ( R0 + R1 ) , R2 , R3 , R4 are the different operations used in SHA1 * / <nl> - # define R0 ( v , w , x , y , z , i ) z + = f1 ( w , x , y ) + blk0 ( i ) + 0x5A827999 + rotlFixed ( v , 5 ) ; w = rotlFixed ( w , 30 ) ; <nl> - # define R1 ( v , w , x , y , z , i ) z + = f1 ( w , x , y ) + blk1 ( i ) + 0x5A827999 + rotlFixed ( v , 5 ) ; w = rotlFixed ( w , 30 ) ; <nl> - # define R2 ( v , w , x , y , z , i ) z + = f2 ( w , x , y ) + blk1 ( i ) + 0x6ED9EBA1 + rotlFixed ( v , 5 ) ; w = rotlFixed ( w , 30 ) ; <nl> - # define R3 ( v , w , x , y , z , i ) z + = f3 ( w , x , y ) + blk1 ( i ) + 0x8F1BBCDC + rotlFixed ( v , 5 ) ; w = rotlFixed ( w , 30 ) ; <nl> - # define R4 ( v , w , x , y , z , i ) z + = f4 ( w , x , y ) + blk1 ( i ) + 0xCA62C1D6 + rotlFixed ( v , 5 ) ; w = rotlFixed ( w , 30 ) ; <nl> - <nl> - void SHA1 : : Transform ( word32 * state , const word32 * data ) <nl> - { <nl> - word32 W [ 16 ] ; <nl> - / * Copy context - > state [ ] to working vars * / <nl> - word32 a = state [ 0 ] ; <nl> - word32 b = state [ 1 ] ; <nl> - word32 c = state [ 2 ] ; <nl> - word32 d = state [ 3 ] ; <nl> - word32 e = state [ 4 ] ; <nl> - / * 4 rounds of 20 operations each . Loop unrolled . * / <nl> - R0 ( a , b , c , d , e , 0 ) ; R0 ( e , a , b , c , d , 1 ) ; R0 ( d , e , a , b , c , 2 ) ; R0 ( c , d , e , a , b , 3 ) ; <nl> - R0 ( b , c , d , e , a , 4 ) ; R0 ( a , b , c , d , e , 5 ) ; R0 ( e , a , b , c , d , 6 ) ; R0 ( d , e , a , b , c , 7 ) ; <nl> - R0 ( c , d , e , a , b , 8 ) ; R0 ( b , c , d , e , a , 9 ) ; R0 ( a , b , c , d , e , 10 ) ; R0 ( e , a , b , c , d , 11 ) ; <nl> - R0 ( d , e , a , b , c , 12 ) ; R0 ( c , d , e , a , b , 13 ) ; R0 ( b , c , d , e , a , 14 ) ; R0 ( a , b , c , d , e , 15 ) ; <nl> - R1 ( e , a , b , c , d , 16 ) ; R1 ( d , e , a , b , c , 17 ) ; R1 ( c , d , e , a , b , 18 ) ; R1 ( b , c , d , e , a , 19 ) ; <nl> - R2 ( a , b , c , d , e , 20 ) ; R2 ( e , a , b , c , d , 21 ) ; R2 ( d , e , a , b , c , 22 ) ; R2 ( c , d , e , a , b , 23 ) ; <nl> - R2 ( b , c , d , e , a , 24 ) ; R2 ( a , b , c , d , e , 25 ) ; R2 ( e , a , b , c , d , 26 ) ; R2 ( d , e , a , b , c , 27 ) ; <nl> - R2 ( c , d , e , a , b , 28 ) ; R2 ( b , c , d , e , a , 29 ) ; R2 ( a , b , c , d , e , 30 ) ; R2 ( e , a , b , c , d , 31 ) ; <nl> - R2 ( d , e , a , b , c , 32 ) ; R2 ( c , d , e , a , b , 33 ) ; R2 ( b , c , d , e , a , 34 ) ; R2 ( a , b , c , d , e , 35 ) ; <nl> - R2 ( e , a , b , c , d , 36 ) ; R2 ( d , e , a , b , c , 37 ) ; R2 ( c , d , e , a , b , 38 ) ; R2 ( b , c , d , e , a , 39 ) ; <nl> - R3 ( a , b , c , d , e , 40 ) ; R3 ( e , a , b , c , d , 41 ) ; R3 ( d , e , a , b , c , 42 ) ; R3 ( c , d , e , a , b , 43 ) ; <nl> - R3 ( b , c , d , e , a , 44 ) ; R3 ( a , b , c , d , e , 45 ) ; R3 ( e , a , b , c , d , 46 ) ; R3 ( d , e , a , b , c , 47 ) ; <nl> - R3 ( c , d , e , a , b , 48 ) ; R3 ( b , c , d , e , a , 49 ) ; R3 ( a , b , c , d , e , 50 ) ; R3 ( e , a , b , c , d , 51 ) ; <nl> - R3 ( d , e , a , b , c , 52 ) ; R3 ( c , d , e , a , b , 53 ) ; R3 ( b , c , d , e , a , 54 ) ; R3 ( a , b , c , d , e , 55 ) ; <nl> - R3 ( e , a , b , c , d , 56 ) ; R3 ( d , e , a , b , c , 57 ) ; R3 ( c , d , e , a , b , 58 ) ; R3 ( b , c , d , e , a , 59 ) ; <nl> - R4 ( a , b , c , d , e , 60 ) ; R4 ( e , a , b , c , d , 61 ) ; R4 ( d , e , a , b , c , 62 ) ; R4 ( c , d , e , a , b , 63 ) ; <nl> - R4 ( b , c , d , e , a , 64 ) ; R4 ( a , b , c , d , e , 65 ) ; R4 ( e , a , b , c , d , 66 ) ; R4 ( d , e , a , b , c , 67 ) ; <nl> - R4 ( c , d , e , a , b , 68 ) ; R4 ( b , c , d , e , a , 69 ) ; R4 ( a , b , c , d , e , 70 ) ; R4 ( e , a , b , c , d , 71 ) ; <nl> - R4 ( d , e , a , b , c , 72 ) ; R4 ( c , d , e , a , b , 73 ) ; R4 ( b , c , d , e , a , 74 ) ; R4 ( a , b , c , d , e , 75 ) ; <nl> - R4 ( e , a , b , c , d , 76 ) ; R4 ( d , e , a , b , c , 77 ) ; R4 ( c , d , e , a , b , 78 ) ; R4 ( b , c , d , e , a , 79 ) ; <nl> - / * Add the working vars back into context . state [ ] * / <nl> - state [ 0 ] + = a ; <nl> - state [ 1 ] + = b ; <nl> - state [ 2 ] + = c ; <nl> - state [ 3 ] + = d ; <nl> - state [ 4 ] + = e ; <nl> - } <nl> - <nl> - / / end of Steve Reid ' s code <nl> - <nl> - / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - <nl> - void SHA224 : : InitState ( HashWordType * state ) <nl> - { <nl> - static const word32 s [ 8 ] = { 0xc1059ed8 , 0x367cd507 , 0x3070dd17 , 0xf70e5939 , 0xffc00b31 , 0x68581511 , 0x64f98fa7 , 0xbefa4fa4 } ; <nl> - memcpy ( state , s , sizeof ( s ) ) ; <nl> - } <nl> - <nl> - void SHA256 : : InitState ( HashWordType * state ) <nl> - { <nl> - static const word32 s [ 8 ] = { 0x6a09e667 , 0xbb67ae85 , 0x3c6ef372 , 0xa54ff53a , 0x510e527f , 0x9b05688c , 0x1f83d9ab , 0x5be0cd19 } ; <nl> - memcpy ( state , s , sizeof ( s ) ) ; <nl> - } <nl> - <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE <nl> - CRYPTOPP_ALIGN_DATA ( 16 ) extern const word32 SHA256_K [ 64 ] CRYPTOPP_SECTION_ALIGN16 = { <nl> - # else <nl> - extern const word32 SHA256_K [ 64 ] = { <nl> - # endif <nl> - 0x428a2f98 , 0x71374491 , 0xb5c0fbcf , 0xe9b5dba5 , <nl> - 0x3956c25b , 0x59f111f1 , 0x923f82a4 , 0xab1c5ed5 , <nl> - 0xd807aa98 , 0x12835b01 , 0x243185be , 0x550c7dc3 , <nl> - 0x72be5d74 , 0x80deb1fe , 0x9bdc06a7 , 0xc19bf174 , <nl> - 0xe49b69c1 , 0xefbe4786 , 0x0fc19dc6 , 0x240ca1cc , <nl> - 0x2de92c6f , 0x4a7484aa , 0x5cb0a9dc , 0x76f988da , <nl> - 0x983e5152 , 0xa831c66d , 0xb00327c8 , 0xbf597fc7 , <nl> - 0xc6e00bf3 , 0xd5a79147 , 0x06ca6351 , 0x14292967 , <nl> - 0x27b70a85 , 0x2e1b2138 , 0x4d2c6dfc , 0x53380d13 , <nl> - 0x650a7354 , 0x766a0abb , 0x81c2c92e , 0x92722c85 , <nl> - 0xa2bfe8a1 , 0xa81a664b , 0xc24b8b70 , 0xc76c51a3 , <nl> - 0xd192e819 , 0xd6990624 , 0xf40e3585 , 0x106aa070 , <nl> - 0x19a4c116 , 0x1e376c08 , 0x2748774c , 0x34b0bcb5 , <nl> - 0x391c0cb3 , 0x4ed8aa4a , 0x5b9cca4f , 0x682e6ff3 , <nl> - 0x748f82ee , 0x78a5636f , 0x84c87814 , 0x8cc70208 , <nl> - 0x90befffa , 0xa4506ceb , 0xbef9a3f7 , 0xc67178f2 <nl> - } ; <nl> - <nl> - # endif / / # ifndef CRYPTOPP_GENERATE_X64_MASM <nl> - <nl> - # if defined ( CRYPTOPP_X86_ASM_AVAILABLE ) | | defined ( CRYPTOPP_GENERATE_X64_MASM ) <nl> - <nl> - # pragma warning ( disable : 4731 ) / / frame pointer register ' ebp ' modified by inline assembly code <nl> - <nl> - static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks ( word32 * state , const word32 * data , size_t len <nl> - # if defined ( _MSC_VER ) & & ( _MSC_VER = = 1200 ) <nl> - , . . . / / VC60 workaround : prevent VC 6 from inlining this function <nl> - # endif <nl> - ) <nl> - { <nl> - # if defined ( _MSC_VER ) & & ( _MSC_VER = = 1200 ) <nl> - AS2 ( mov ecx , [ state ] ) <nl> - AS2 ( mov edx , [ data ] ) <nl> - # endif <nl> - <nl> - # define LOCALS_SIZE 8 * 4 + 16 * 4 + 4 * WORD_SZ <nl> - # define H ( i ) [ BASE + ASM_MOD ( 1024 + 7 - ( i ) , 8 ) * 4 ] <nl> - # define G ( i ) H ( i + 1 ) <nl> - # define F ( i ) H ( i + 2 ) <nl> - # define E ( i ) H ( i + 3 ) <nl> - # define D ( i ) H ( i + 4 ) <nl> - # define C ( i ) H ( i + 5 ) <nl> - # define B ( i ) H ( i + 6 ) <nl> - # define A ( i ) H ( i + 7 ) <nl> - # define Wt ( i ) BASE + 8 * 4 + ASM_MOD ( 1024 + 15 - ( i ) , 16 ) * 4 <nl> - # define Wt_2 ( i ) Wt ( ( i ) - 2 ) <nl> - # define Wt_15 ( i ) Wt ( ( i ) - 15 ) <nl> - # define Wt_7 ( i ) Wt ( ( i ) - 7 ) <nl> - # define K_END [ BASE + 8 * 4 + 16 * 4 + 0 * WORD_SZ ] <nl> - # define STATE_SAVE [ BASE + 8 * 4 + 16 * 4 + 1 * WORD_SZ ] <nl> - # define DATA_SAVE [ BASE + 8 * 4 + 16 * 4 + 2 * WORD_SZ ] <nl> - # define DATA_END [ BASE + 8 * 4 + 16 * 4 + 3 * WORD_SZ ] <nl> - # define Kt ( i ) WORD_REG ( si ) + ( i ) * 4 <nl> - # if CRYPTOPP_BOOL_X86 <nl> - # define BASE esp + 4 <nl> - # elif defined ( __GNUC__ ) <nl> - # define BASE r8 <nl> - # else <nl> - # define BASE rsp <nl> - # endif <nl> - <nl> - # define RA0 ( i , edx , edi ) \ <nl> - AS2 ( add edx , [ Kt ( i ) ] ) \ <nl> - AS2 ( add edx , [ Wt ( i ) ] ) \ <nl> - AS2 ( add edx , H ( i ) ) \ <nl> - <nl> - # define RA1 ( i , edx , edi ) <nl> - <nl> - # define RB0 ( i , edx , edi ) <nl> - <nl> - # define RB1 ( i , edx , edi ) \ <nl> - AS2 ( mov AS_REG_7d , [ Wt_2 ( i ) ] ) \ <nl> - AS2 ( mov edi , [ Wt_15 ( i ) ] ) \ <nl> - AS2 ( mov ebx , AS_REG_7d ) \ <nl> - AS2 ( shr AS_REG_7d , 10 ) \ <nl> - AS2 ( ror ebx , 17 ) \ <nl> - AS2 ( xor AS_REG_7d , ebx ) \ <nl> - AS2 ( ror ebx , 2 ) \ <nl> - AS2 ( xor ebx , AS_REG_7d ) / * s1 ( W_t - 2 ) * / \ <nl> - AS2 ( add ebx , [ Wt_7 ( i ) ] ) \ <nl> - AS2 ( mov AS_REG_7d , edi ) \ <nl> - AS2 ( shr AS_REG_7d , 3 ) \ <nl> - AS2 ( ror edi , 7 ) \ <nl> - AS2 ( add ebx , [ Wt ( i ) ] ) / * s1 ( W_t - 2 ) + W_t - 7 + W_t - 16 * / \ <nl> - AS2 ( xor AS_REG_7d , edi ) \ <nl> - AS2 ( add edx , [ Kt ( i ) ] ) \ <nl> - AS2 ( ror edi , 11 ) \ <nl> - AS2 ( add edx , H ( i ) ) \ <nl> - AS2 ( xor AS_REG_7d , edi ) / * s0 ( W_t - 15 ) * / \ <nl> - AS2 ( add AS_REG_7d , ebx ) / * W_t = s1 ( W_t - 2 ) + W_t - 7 + s0 ( W_t - 15 ) W_t - 16 * / \ <nl> - AS2 ( mov [ Wt ( i ) ] , AS_REG_7d ) \ <nl> - AS2 ( add edx , AS_REG_7d ) \ <nl> - <nl> - # define ROUND ( i , r , eax , ecx , edi , edx ) \ <nl> - / * in : edi = E * / \ <nl> - / * unused : eax , ecx , temp : ebx , AS_REG_7d , out : edx = T1 * / \ <nl> - AS2 ( mov edx , F ( i ) ) \ <nl> - AS2 ( xor edx , G ( i ) ) \ <nl> - AS2 ( and edx , edi ) \ <nl> - AS2 ( xor edx , G ( i ) ) / * Ch ( E , F , G ) = ( G ^ ( E & ( F ^ G ) ) ) * / \ <nl> - AS2 ( mov AS_REG_7d , edi ) \ <nl> - AS2 ( ror edi , 6 ) \ <nl> - AS2 ( ror AS_REG_7d , 25 ) \ <nl> - RA # # r ( i , edx , edi ) / * H + Wt + Kt + Ch ( E , F , G ) * / \ <nl> - AS2 ( xor AS_REG_7d , edi ) \ <nl> - AS2 ( ror edi , 5 ) \ <nl> - AS2 ( xor AS_REG_7d , edi ) / * S1 ( E ) * / \ <nl> - AS2 ( add edx , AS_REG_7d ) / * T1 = S1 ( E ) + Ch ( E , F , G ) + H + Wt + Kt * / \ <nl> - RB # # r ( i , edx , edi ) / * H + Wt + Kt + Ch ( E , F , G ) * / \ <nl> - / * in : ecx = A , eax = B ^ C , edx = T1 * / \ <nl> - / * unused : edx , temp : ebx , AS_REG_7d , out : eax = A , ecx = B ^ C , edx = E * / \ <nl> - AS2 ( mov ebx , ecx ) \ <nl> - AS2 ( xor ecx , B ( i ) ) / * A ^ B * / \ <nl> - AS2 ( and eax , ecx ) \ <nl> - AS2 ( xor eax , B ( i ) ) / * Maj ( A , B , C ) = B ^ ( ( A ^ B ) & ( B ^ C ) * / \ <nl> - AS2 ( mov AS_REG_7d , ebx ) \ <nl> - AS2 ( ror ebx , 2 ) \ <nl> - AS2 ( add eax , edx ) / * T1 + Maj ( A , B , C ) * / \ <nl> - AS2 ( add edx , D ( i ) ) \ <nl> - AS2 ( mov D ( i ) , edx ) \ <nl> - AS2 ( ror AS_REG_7d , 22 ) \ <nl> - AS2 ( xor AS_REG_7d , ebx ) \ <nl> - AS2 ( ror ebx , 11 ) \ <nl> - AS2 ( xor AS_REG_7d , ebx ) \ <nl> - AS2 ( add eax , AS_REG_7d ) / * T1 + S0 ( A ) + Maj ( A , B , C ) * / \ <nl> - AS2 ( mov H ( i ) , eax ) \ <nl> - <nl> - # define SWAP_COPY ( i ) \ <nl> - AS2 ( mov WORD_REG ( bx ) , [ WORD_REG ( dx ) + i * WORD_SZ ] ) \ <nl> - AS1 ( bswap WORD_REG ( bx ) ) \ <nl> - AS2 ( mov [ Wt ( i * ( 1 + CRYPTOPP_BOOL_X64 ) + CRYPTOPP_BOOL_X64 ) ] , WORD_REG ( bx ) ) <nl> - <nl> - # if defined ( __GNUC__ ) <nl> - # if CRYPTOPP_BOOL_X64 <nl> - FixedSizeAlignedSecBlock < byte , LOCALS_SIZE > workspace ; <nl> - # endif <nl> - __asm__ __volatile__ <nl> - ( <nl> - # if CRYPTOPP_BOOL_X64 <nl> - " lea % 4 , % % r8 ; " <nl> - # endif <nl> - " . intel_syntax noprefix ; " <nl> - # elif defined ( CRYPTOPP_GENERATE_X64_MASM ) <nl> - ALIGN 8 <nl> - X86_SHA256_HashBlocks PROC FRAME <nl> - rex_push_reg rsi <nl> - push_reg rdi <nl> - push_reg rbx <nl> - push_reg rbp <nl> - alloc_stack ( LOCALS_SIZE + 8 ) <nl> - . endprolog <nl> - mov rdi , r8 <nl> - lea rsi , [ ? SHA256_K @ CryptoPP @ @ 3QBIB + 48 * 4 ] <nl> - # endif <nl> - <nl> - # if CRYPTOPP_BOOL_X86 <nl> - # ifndef __GNUC__ <nl> - AS2 ( mov edi , [ len ] ) <nl> - AS2 ( lea WORD_REG ( si ) , [ SHA256_K + 48 * 4 ] ) <nl> - # endif <nl> - # if ! defined ( _MSC_VER ) | | ( _MSC_VER < 1400 ) <nl> - AS_PUSH_IF86 ( bx ) <nl> - # endif <nl> - <nl> - AS_PUSH_IF86 ( bp ) <nl> - AS2 ( mov ebx , esp ) <nl> - AS2 ( and esp , - 16 ) <nl> - AS2 ( sub WORD_REG ( sp ) , LOCALS_SIZE ) <nl> - AS_PUSH_IF86 ( bx ) <nl> - # endif <nl> - AS2 ( mov STATE_SAVE , WORD_REG ( cx ) ) <nl> - AS2 ( mov DATA_SAVE , WORD_REG ( dx ) ) <nl> - AS2 ( add WORD_REG ( di ) , WORD_REG ( dx ) ) <nl> - AS2 ( mov DATA_END , WORD_REG ( di ) ) <nl> - AS2 ( mov K_END , WORD_REG ( si ) ) <nl> - <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE <nl> - # if CRYPTOPP_BOOL_X86 <nl> - AS2 ( test edi , 1 ) <nl> - ASJ ( jnz , 2 , f ) <nl> - # endif <nl> - AS2 ( movdqa xmm0 , XMMWORD_PTR [ WORD_REG ( cx ) + 0 * 16 ] ) <nl> - AS2 ( movdqa xmm1 , XMMWORD_PTR [ WORD_REG ( cx ) + 1 * 16 ] ) <nl> - # endif <nl> - <nl> - # if CRYPTOPP_BOOL_X86 <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE <nl> - ASJ ( jmp , 0 , f ) <nl> - # endif <nl> - ASL ( 2 ) / / non - SSE2 <nl> - AS2 ( mov esi , ecx ) <nl> - AS2 ( lea edi , A ( 0 ) ) <nl> - AS2 ( mov ecx , 8 ) <nl> - AS1 ( rep movsd ) <nl> - AS2 ( mov esi , K_END ) <nl> - ASJ ( jmp , 3 , f ) <nl> - # endif <nl> - <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE <nl> - ASL ( 0 ) <nl> - AS2 ( movdqa E ( 0 ) , xmm1 ) <nl> - AS2 ( movdqa A ( 0 ) , xmm0 ) <nl> - # endif <nl> - # if CRYPTOPP_BOOL_X86 <nl> - ASL ( 3 ) <nl> - # endif <nl> - AS2 ( sub WORD_REG ( si ) , 48 * 4 ) <nl> - SWAP_COPY ( 0 ) SWAP_COPY ( 1 ) SWAP_COPY ( 2 ) SWAP_COPY ( 3 ) <nl> - SWAP_COPY ( 4 ) SWAP_COPY ( 5 ) SWAP_COPY ( 6 ) SWAP_COPY ( 7 ) <nl> - # if CRYPTOPP_BOOL_X86 <nl> - SWAP_COPY ( 8 ) SWAP_COPY ( 9 ) SWAP_COPY ( 10 ) SWAP_COPY ( 11 ) <nl> - SWAP_COPY ( 12 ) SWAP_COPY ( 13 ) SWAP_COPY ( 14 ) SWAP_COPY ( 15 ) <nl> - # endif <nl> - AS2 ( mov edi , E ( 0 ) ) / / E <nl> - AS2 ( mov eax , B ( 0 ) ) / / B <nl> - AS2 ( xor eax , C ( 0 ) ) / / B ^ C <nl> - AS2 ( mov ecx , A ( 0 ) ) / / A <nl> - <nl> - ROUND ( 0 , 0 , eax , ecx , edi , edx ) <nl> - ROUND ( 1 , 0 , ecx , eax , edx , edi ) <nl> - ROUND ( 2 , 0 , eax , ecx , edi , edx ) <nl> - ROUND ( 3 , 0 , ecx , eax , edx , edi ) <nl> - ROUND ( 4 , 0 , eax , ecx , edi , edx ) <nl> - ROUND ( 5 , 0 , ecx , eax , edx , edi ) <nl> - ROUND ( 6 , 0 , eax , ecx , edi , edx ) <nl> - ROUND ( 7 , 0 , ecx , eax , edx , edi ) <nl> - ROUND ( 8 , 0 , eax , ecx , edi , edx ) <nl> - ROUND ( 9 , 0 , ecx , eax , edx , edi ) <nl> - ROUND ( 10 , 0 , eax , ecx , edi , edx ) <nl> - ROUND ( 11 , 0 , ecx , eax , edx , edi ) <nl> - ROUND ( 12 , 0 , eax , ecx , edi , edx ) <nl> - ROUND ( 13 , 0 , ecx , eax , edx , edi ) <nl> - ROUND ( 14 , 0 , eax , ecx , edi , edx ) <nl> - ROUND ( 15 , 0 , ecx , eax , edx , edi ) <nl> - <nl> - ASL ( 1 ) <nl> - AS2 ( add WORD_REG ( si ) , 4 * 16 ) <nl> - ROUND ( 0 , 1 , eax , ecx , edi , edx ) <nl> - ROUND ( 1 , 1 , ecx , eax , edx , edi ) <nl> - ROUND ( 2 , 1 , eax , ecx , edi , edx ) <nl> - ROUND ( 3 , 1 , ecx , eax , edx , edi ) <nl> - ROUND ( 4 , 1 , eax , ecx , edi , edx ) <nl> - ROUND ( 5 , 1 , ecx , eax , edx , edi ) <nl> - ROUND ( 6 , 1 , eax , ecx , edi , edx ) <nl> - ROUND ( 7 , 1 , ecx , eax , edx , edi ) <nl> - ROUND ( 8 , 1 , eax , ecx , edi , edx ) <nl> - ROUND ( 9 , 1 , ecx , eax , edx , edi ) <nl> - ROUND ( 10 , 1 , eax , ecx , edi , edx ) <nl> - ROUND ( 11 , 1 , ecx , eax , edx , edi ) <nl> - ROUND ( 12 , 1 , eax , ecx , edi , edx ) <nl> - ROUND ( 13 , 1 , ecx , eax , edx , edi ) <nl> - ROUND ( 14 , 1 , eax , ecx , edi , edx ) <nl> - ROUND ( 15 , 1 , ecx , eax , edx , edi ) <nl> - AS2 ( cmp WORD_REG ( si ) , K_END ) <nl> - ASJ ( jne , 1 , b ) <nl> - <nl> - AS2 ( mov WORD_REG ( dx ) , DATA_SAVE ) <nl> - AS2 ( add WORD_REG ( dx ) , 64 ) <nl> - AS2 ( mov AS_REG_7 , STATE_SAVE ) <nl> - AS2 ( mov DATA_SAVE , WORD_REG ( dx ) ) <nl> - <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE <nl> - # if CRYPTOPP_BOOL_X86 <nl> - AS2 ( test DWORD PTR DATA_END , 1 ) <nl> - ASJ ( jnz , 4 , f ) <nl> - # endif <nl> - AS2 ( movdqa xmm1 , XMMWORD_PTR [ AS_REG_7 + 1 * 16 ] ) <nl> - AS2 ( movdqa xmm0 , XMMWORD_PTR [ AS_REG_7 + 0 * 16 ] ) <nl> - AS2 ( paddd xmm1 , E ( 0 ) ) <nl> - AS2 ( paddd xmm0 , A ( 0 ) ) <nl> - AS2 ( movdqa [ AS_REG_7 + 1 * 16 ] , xmm1 ) <nl> - AS2 ( movdqa [ AS_REG_7 + 0 * 16 ] , xmm0 ) <nl> - AS2 ( cmp WORD_REG ( dx ) , DATA_END ) <nl> - ASJ ( jl , 0 , b ) <nl> - # endif <nl> - <nl> - # if CRYPTOPP_BOOL_X86 <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE <nl> - ASJ ( jmp , 5 , f ) <nl> - ASL ( 4 ) / / non - SSE2 <nl> - # endif <nl> - AS2 ( add [ AS_REG_7 + 0 * 4 ] , ecx ) / / A <nl> - AS2 ( add [ AS_REG_7 + 4 * 4 ] , edi ) / / E <nl> - AS2 ( mov eax , B ( 0 ) ) <nl> - AS2 ( mov ebx , C ( 0 ) ) <nl> - AS2 ( mov ecx , D ( 0 ) ) <nl> - AS2 ( add [ AS_REG_7 + 1 * 4 ] , eax ) <nl> - AS2 ( add [ AS_REG_7 + 2 * 4 ] , ebx ) <nl> - AS2 ( add [ AS_REG_7 + 3 * 4 ] , ecx ) <nl> - AS2 ( mov eax , F ( 0 ) ) <nl> - AS2 ( mov ebx , G ( 0 ) ) <nl> - AS2 ( mov ecx , H ( 0 ) ) <nl> - AS2 ( add [ AS_REG_7 + 5 * 4 ] , eax ) <nl> - AS2 ( add [ AS_REG_7 + 6 * 4 ] , ebx ) <nl> - AS2 ( add [ AS_REG_7 + 7 * 4 ] , ecx ) <nl> - AS2 ( mov ecx , AS_REG_7d ) <nl> - AS2 ( cmp WORD_REG ( dx ) , DATA_END ) <nl> - ASJ ( jl , 2 , b ) <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE <nl> - ASL ( 5 ) <nl> - # endif <nl> - # endif <nl> - <nl> - AS_POP_IF86 ( sp ) <nl> - AS_POP_IF86 ( bp ) <nl> - # if ! defined ( _MSC_VER ) | | ( _MSC_VER < 1400 ) <nl> - AS_POP_IF86 ( bx ) <nl> - # endif <nl> - <nl> - # ifdef CRYPTOPP_GENERATE_X64_MASM <nl> - add rsp , LOCALS_SIZE + 8 <nl> - pop rbp <nl> - pop rbx <nl> - pop rdi <nl> - pop rsi <nl> - ret <nl> - X86_SHA256_HashBlocks ENDP <nl> - # endif <nl> - <nl> - # ifdef __GNUC__ <nl> - " . att_syntax prefix ; " <nl> - : <nl> - : " c " ( state ) , " d " ( data ) , " S " ( SHA256_K + 48 ) , " D " ( len ) <nl> - # if CRYPTOPP_BOOL_X64 <nl> - , " m " ( workspace [ 0 ] ) <nl> - # endif <nl> - : " memory " , " cc " , " % eax " <nl> - # if CRYPTOPP_BOOL_X64 <nl> - , " % rbx " , " % r8 " <nl> - # endif <nl> - ) ; <nl> - # endif <nl> - } <nl> - <nl> - # endif / / # if defined ( CRYPTOPP_X86_ASM_AVAILABLE ) | | defined ( CRYPTOPP_GENERATE_X64_MASM ) <nl> - <nl> - # ifndef CRYPTOPP_GENERATE_X64_MASM <nl> - <nl> - # ifdef CRYPTOPP_X64_MASM_AVAILABLE <nl> - extern " C " { <nl> - void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks ( word32 * state , const word32 * data , size_t len ) ; <nl> - } <nl> - # endif <nl> - <nl> - # if defined ( CRYPTOPP_X86_ASM_AVAILABLE ) | | defined ( CRYPTOPP_X64_MASM_AVAILABLE ) <nl> - <nl> - size_t SHA256 : : HashMultipleBlocks ( const word32 * input , size_t length ) <nl> - { <nl> - X86_SHA256_HashBlocks ( m_state , input , ( length & ( size_t ( 0 ) - BLOCKSIZE ) ) - ! HasSSE2 ( ) ) ; <nl> - return length % BLOCKSIZE ; <nl> - } <nl> - <nl> - size_t SHA224 : : HashMultipleBlocks ( const word32 * input , size_t length ) <nl> - { <nl> - X86_SHA256_HashBlocks ( m_state , input , ( length & ( size_t ( 0 ) - BLOCKSIZE ) ) - ! HasSSE2 ( ) ) ; <nl> - return length % BLOCKSIZE ; <nl> - } <nl> - <nl> - # endif <nl> - <nl> - # define blk2 ( i ) ( W [ i & 15 ] + = s1 ( W [ ( i - 2 ) & 15 ] ) + W [ ( i - 7 ) & 15 ] + s0 ( W [ ( i - 15 ) & 15 ] ) ) <nl> - <nl> - # define Ch ( x , y , z ) ( z ^ ( x & ( y ^ z ) ) ) <nl> - # define Maj ( x , y , z ) ( y ^ ( ( x ^ y ) & ( y ^ z ) ) ) <nl> - <nl> - # define a ( i ) T [ ( 0 - i ) & 7 ] <nl> - # define b ( i ) T [ ( 1 - i ) & 7 ] <nl> - # define c ( i ) T [ ( 2 - i ) & 7 ] <nl> - # define d ( i ) T [ ( 3 - i ) & 7 ] <nl> - # define e ( i ) T [ ( 4 - i ) & 7 ] <nl> - # define f ( i ) T [ ( 5 - i ) & 7 ] <nl> - # define g ( i ) T [ ( 6 - i ) & 7 ] <nl> - # define h ( i ) T [ ( 7 - i ) & 7 ] <nl> - <nl> - # define R ( i ) h ( i ) + = S1 ( e ( i ) ) + Ch ( e ( i ) , f ( i ) , g ( i ) ) + SHA256_K [ i + j ] + ( j ? blk2 ( i ) : blk0 ( i ) ) ; \ <nl> - d ( i ) + = h ( i ) ; h ( i ) + = S0 ( a ( i ) ) + Maj ( a ( i ) , b ( i ) , c ( i ) ) <nl> - <nl> - / / for SHA256 <nl> - # define S0 ( x ) ( rotrFixed ( x , 2 ) ^ rotrFixed ( x , 13 ) ^ rotrFixed ( x , 22 ) ) <nl> - # define S1 ( x ) ( rotrFixed ( x , 6 ) ^ rotrFixed ( x , 11 ) ^ rotrFixed ( x , 25 ) ) <nl> - # define s0 ( x ) ( rotrFixed ( x , 7 ) ^ rotrFixed ( x , 18 ) ^ ( x > > 3 ) ) <nl> - # define s1 ( x ) ( rotrFixed ( x , 17 ) ^ rotrFixed ( x , 19 ) ^ ( x > > 10 ) ) <nl> - <nl> - void SHA256 : : Transform ( word32 * state , const word32 * data ) <nl> - { <nl> - word32 W [ 16 ] ; <nl> - # if defined ( CRYPTOPP_X86_ASM_AVAILABLE ) | | defined ( CRYPTOPP_X64_MASM_AVAILABLE ) <nl> - / / this byte reverse is a waste of time , but this function is only called by MDC <nl> - ByteReverse ( W , data , BLOCKSIZE ) ; <nl> - X86_SHA256_HashBlocks ( state , W , BLOCKSIZE - ! HasSSE2 ( ) ) ; <nl> - # else <nl> - word32 T [ 8 ] ; <nl> - / * Copy context - > state [ ] to working vars * / <nl> - memcpy ( T , state , sizeof ( T ) ) ; <nl> - / * 64 operations , partially loop unrolled * / <nl> - for ( unsigned int j = 0 ; j < 64 ; j + = 16 ) <nl> - { <nl> - R ( 0 ) ; R ( 1 ) ; R ( 2 ) ; R ( 3 ) ; <nl> - R ( 4 ) ; R ( 5 ) ; R ( 6 ) ; R ( 7 ) ; <nl> - R ( 8 ) ; R ( 9 ) ; R ( 10 ) ; R ( 11 ) ; <nl> - R ( 12 ) ; R ( 13 ) ; R ( 14 ) ; R ( 15 ) ; <nl> - } <nl> - / * Add the working vars back into context . state [ ] * / <nl> - state [ 0 ] + = a ( 0 ) ; <nl> - state [ 1 ] + = b ( 0 ) ; <nl> - state [ 2 ] + = c ( 0 ) ; <nl> - state [ 3 ] + = d ( 0 ) ; <nl> - state [ 4 ] + = e ( 0 ) ; <nl> - state [ 5 ] + = f ( 0 ) ; <nl> - state [ 6 ] + = g ( 0 ) ; <nl> - state [ 7 ] + = h ( 0 ) ; <nl> - # endif <nl> - } <nl> - <nl> - / * <nl> - / / smaller but slower <nl> - void SHA256 : : Transform ( word32 * state , const word32 * data ) <nl> - { <nl> - word32 T [ 20 ] ; <nl> - word32 W [ 32 ] ; <nl> - unsigned int i = 0 , j = 0 ; <nl> - word32 * t = T + 8 ; <nl> - <nl> - memcpy ( t , state , 8 * 4 ) ; <nl> - word32 e = t [ 4 ] , a = t [ 0 ] ; <nl> - <nl> - do <nl> - { <nl> - word32 w = data [ j ] ; <nl> - W [ j ] = w ; <nl> - w + = SHA256_K [ j ] ; <nl> - w + = t [ 7 ] ; <nl> - w + = S1 ( e ) ; <nl> - w + = Ch ( e , t [ 5 ] , t [ 6 ] ) ; <nl> - e = t [ 3 ] + w ; <nl> - t [ 3 ] = t [ 3 + 8 ] = e ; <nl> - w + = S0 ( t [ 0 ] ) ; <nl> - a = w + Maj ( a , t [ 1 ] , t [ 2 ] ) ; <nl> - t [ - 1 ] = t [ 7 ] = a ; <nl> - - - t ; <nl> - + + j ; <nl> - if ( j % 8 = = 0 ) <nl> - t + = 8 ; <nl> - } while ( j < 16 ) ; <nl> - <nl> - do <nl> - { <nl> - i = j & 0xf ; <nl> - word32 w = s1 ( W [ i + 16 - 2 ] ) + s0 ( W [ i + 16 - 15 ] ) + W [ i ] + W [ i + 16 - 7 ] ; <nl> - W [ i + 16 ] = W [ i ] = w ; <nl> - w + = SHA256_K [ j ] ; <nl> - w + = t [ 7 ] ; <nl> - w + = S1 ( e ) ; <nl> - w + = Ch ( e , t [ 5 ] , t [ 6 ] ) ; <nl> - e = t [ 3 ] + w ; <nl> - t [ 3 ] = t [ 3 + 8 ] = e ; <nl> - w + = S0 ( t [ 0 ] ) ; <nl> - a = w + Maj ( a , t [ 1 ] , t [ 2 ] ) ; <nl> - t [ - 1 ] = t [ 7 ] = a ; <nl> - <nl> - w = s1 ( W [ ( i + 1 ) + 16 - 2 ] ) + s0 ( W [ ( i + 1 ) + 16 - 15 ] ) + W [ ( i + 1 ) ] + W [ ( i + 1 ) + 16 - 7 ] ; <nl> - W [ ( i + 1 ) + 16 ] = W [ ( i + 1 ) ] = w ; <nl> - w + = SHA256_K [ j + 1 ] ; <nl> - w + = ( t - 1 ) [ 7 ] ; <nl> - w + = S1 ( e ) ; <nl> - w + = Ch ( e , ( t - 1 ) [ 5 ] , ( t - 1 ) [ 6 ] ) ; <nl> - e = ( t - 1 ) [ 3 ] + w ; <nl> - ( t - 1 ) [ 3 ] = ( t - 1 ) [ 3 + 8 ] = e ; <nl> - w + = S0 ( ( t - 1 ) [ 0 ] ) ; <nl> - a = w + Maj ( a , ( t - 1 ) [ 1 ] , ( t - 1 ) [ 2 ] ) ; <nl> - ( t - 1 ) [ - 1 ] = ( t - 1 ) [ 7 ] = a ; <nl> - <nl> - t - = 2 ; <nl> - j + = 2 ; <nl> - if ( j % 8 = = 0 ) <nl> - t + = 8 ; <nl> - } while ( j < 64 ) ; <nl> - <nl> - state [ 0 ] + = a ; <nl> - state [ 1 ] + = t [ 1 ] ; <nl> - state [ 2 ] + = t [ 2 ] ; <nl> - state [ 3 ] + = t [ 3 ] ; <nl> - state [ 4 ] + = e ; <nl> - state [ 5 ] + = t [ 5 ] ; <nl> - state [ 6 ] + = t [ 6 ] ; <nl> - state [ 7 ] + = t [ 7 ] ; <nl> - } <nl> - * / <nl> - <nl> - # undef S0 <nl> - # undef S1 <nl> - # undef s0 <nl> - # undef s1 <nl> - # undef R <nl> - <nl> - / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - <nl> - void SHA384 : : InitState ( HashWordType * state ) <nl> - { <nl> - static const word64 s [ 8 ] = { <nl> - W64LIT ( 0xcbbb9d5dc1059ed8 ) , W64LIT ( 0x629a292a367cd507 ) , <nl> - W64LIT ( 0x9159015a3070dd17 ) , W64LIT ( 0x152fecd8f70e5939 ) , <nl> - W64LIT ( 0x67332667ffc00b31 ) , W64LIT ( 0x8eb44a8768581511 ) , <nl> - W64LIT ( 0xdb0c2e0d64f98fa7 ) , W64LIT ( 0x47b5481dbefa4fa4 ) } ; <nl> - memcpy ( state , s , sizeof ( s ) ) ; <nl> - } <nl> - <nl> - void SHA512 : : InitState ( HashWordType * state ) <nl> - { <nl> - static const word64 s [ 8 ] = { <nl> - W64LIT ( 0x6a09e667f3bcc908 ) , W64LIT ( 0xbb67ae8584caa73b ) , <nl> - W64LIT ( 0x3c6ef372fe94f82b ) , W64LIT ( 0xa54ff53a5f1d36f1 ) , <nl> - W64LIT ( 0x510e527fade682d1 ) , W64LIT ( 0x9b05688c2b3e6c1f ) , <nl> - W64LIT ( 0x1f83d9abfb41bd6b ) , W64LIT ( 0x5be0cd19137e2179 ) } ; <nl> - memcpy ( state , s , sizeof ( s ) ) ; <nl> - } <nl> - <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE & & CRYPTOPP_BOOL_X86 <nl> - CRYPTOPP_ALIGN_DATA ( 16 ) static const word64 SHA512_K [ 80 ] CRYPTOPP_SECTION_ALIGN16 = { <nl> - # else <nl> - static const word64 SHA512_K [ 80 ] = { <nl> - # endif <nl> - W64LIT ( 0x428a2f98d728ae22 ) , W64LIT ( 0x7137449123ef65cd ) , <nl> - W64LIT ( 0xb5c0fbcfec4d3b2f ) , W64LIT ( 0xe9b5dba58189dbbc ) , <nl> - W64LIT ( 0x3956c25bf348b538 ) , W64LIT ( 0x59f111f1b605d019 ) , <nl> - W64LIT ( 0x923f82a4af194f9b ) , W64LIT ( 0xab1c5ed5da6d8118 ) , <nl> - W64LIT ( 0xd807aa98a3030242 ) , W64LIT ( 0x12835b0145706fbe ) , <nl> - W64LIT ( 0x243185be4ee4b28c ) , W64LIT ( 0x550c7dc3d5ffb4e2 ) , <nl> - W64LIT ( 0x72be5d74f27b896f ) , W64LIT ( 0x80deb1fe3b1696b1 ) , <nl> - W64LIT ( 0x9bdc06a725c71235 ) , W64LIT ( 0xc19bf174cf692694 ) , <nl> - W64LIT ( 0xe49b69c19ef14ad2 ) , W64LIT ( 0xefbe4786384f25e3 ) , <nl> - W64LIT ( 0x0fc19dc68b8cd5b5 ) , W64LIT ( 0x240ca1cc77ac9c65 ) , <nl> - W64LIT ( 0x2de92c6f592b0275 ) , W64LIT ( 0x4a7484aa6ea6e483 ) , <nl> - W64LIT ( 0x5cb0a9dcbd41fbd4 ) , W64LIT ( 0x76f988da831153b5 ) , <nl> - W64LIT ( 0x983e5152ee66dfab ) , W64LIT ( 0xa831c66d2db43210 ) , <nl> - W64LIT ( 0xb00327c898fb213f ) , W64LIT ( 0xbf597fc7beef0ee4 ) , <nl> - W64LIT ( 0xc6e00bf33da88fc2 ) , W64LIT ( 0xd5a79147930aa725 ) , <nl> - W64LIT ( 0x06ca6351e003826f ) , W64LIT ( 0x142929670a0e6e70 ) , <nl> - W64LIT ( 0x27b70a8546d22ffc ) , W64LIT ( 0x2e1b21385c26c926 ) , <nl> - W64LIT ( 0x4d2c6dfc5ac42aed ) , W64LIT ( 0x53380d139d95b3df ) , <nl> - W64LIT ( 0x650a73548baf63de ) , W64LIT ( 0x766a0abb3c77b2a8 ) , <nl> - W64LIT ( 0x81c2c92e47edaee6 ) , W64LIT ( 0x92722c851482353b ) , <nl> - W64LIT ( 0xa2bfe8a14cf10364 ) , W64LIT ( 0xa81a664bbc423001 ) , <nl> - W64LIT ( 0xc24b8b70d0f89791 ) , W64LIT ( 0xc76c51a30654be30 ) , <nl> - W64LIT ( 0xd192e819d6ef5218 ) , W64LIT ( 0xd69906245565a910 ) , <nl> - W64LIT ( 0xf40e35855771202a ) , W64LIT ( 0x106aa07032bbd1b8 ) , <nl> - W64LIT ( 0x19a4c116b8d2d0c8 ) , W64LIT ( 0x1e376c085141ab53 ) , <nl> - W64LIT ( 0x2748774cdf8eeb99 ) , W64LIT ( 0x34b0bcb5e19b48a8 ) , <nl> - W64LIT ( 0x391c0cb3c5c95a63 ) , W64LIT ( 0x4ed8aa4ae3418acb ) , <nl> - W64LIT ( 0x5b9cca4f7763e373 ) , W64LIT ( 0x682e6ff3d6b2b8a3 ) , <nl> - W64LIT ( 0x748f82ee5defb2fc ) , W64LIT ( 0x78a5636f43172f60 ) , <nl> - W64LIT ( 0x84c87814a1f0ab72 ) , W64LIT ( 0x8cc702081a6439ec ) , <nl> - W64LIT ( 0x90befffa23631e28 ) , W64LIT ( 0xa4506cebde82bde9 ) , <nl> - W64LIT ( 0xbef9a3f7b2c67915 ) , W64LIT ( 0xc67178f2e372532b ) , <nl> - W64LIT ( 0xca273eceea26619c ) , W64LIT ( 0xd186b8c721c0c207 ) , <nl> - W64LIT ( 0xeada7dd6cde0eb1e ) , W64LIT ( 0xf57d4f7fee6ed178 ) , <nl> - W64LIT ( 0x06f067aa72176fba ) , W64LIT ( 0x0a637dc5a2c898a6 ) , <nl> - W64LIT ( 0x113f9804bef90dae ) , W64LIT ( 0x1b710b35131c471b ) , <nl> - W64LIT ( 0x28db77f523047d84 ) , W64LIT ( 0x32caab7b40c72493 ) , <nl> - W64LIT ( 0x3c9ebe0a15c9bebc ) , W64LIT ( 0x431d67c49c100d4c ) , <nl> - W64LIT ( 0x4cc5d4becb3e42b6 ) , W64LIT ( 0x597f299cfc657e2a ) , <nl> - W64LIT ( 0x5fcb6fab3ad6faec ) , W64LIT ( 0x6c44198c4a475817 ) <nl> - } ; <nl> - <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE & & CRYPTOPP_BOOL_X86 <nl> - / / put assembly version in separate function , otherwise MSVC 2005 SP1 doesn ' t generate correct code for the non - assembly version <nl> - CRYPTOPP_NAKED static void CRYPTOPP_FASTCALL SHA512_SSE2_Transform ( word64 * state , const word64 * data ) <nl> - { <nl> - # ifdef __GNUC__ <nl> - __asm__ __volatile__ <nl> - ( <nl> - " . intel_syntax noprefix ; " <nl> - AS1 ( push ebx ) <nl> - AS2 ( mov ebx , eax ) <nl> - # else <nl> - AS1 ( push ebx ) <nl> - AS1 ( push esi ) <nl> - AS1 ( push edi ) <nl> - AS2 ( lea ebx , SHA512_K ) <nl> - # endif <nl> - <nl> - AS2 ( mov eax , esp ) <nl> - AS2 ( and esp , 0xfffffff0 ) <nl> - AS2 ( sub esp , 27 * 16 ) / / 17 * 16 for expanded data , 20 * 8 for state <nl> - AS1 ( push eax ) <nl> - AS2 ( xor eax , eax ) <nl> - AS2 ( lea edi , [ esp + 4 + 8 * 8 ] ) / / start at middle of state buffer . will decrement pointer each round to avoid copying <nl> - AS2 ( lea esi , [ esp + 4 + 20 * 8 + 8 ] ) / / 16 - byte alignment , then add 8 <nl> - <nl> - AS2 ( movdqa xmm0 , [ ecx + 0 * 16 ] ) <nl> - AS2 ( movdq2q mm4 , xmm0 ) <nl> - AS2 ( movdqa [ edi + 0 * 16 ] , xmm0 ) <nl> - AS2 ( movdqa xmm0 , [ ecx + 1 * 16 ] ) <nl> - AS2 ( movdqa [ edi + 1 * 16 ] , xmm0 ) <nl> - AS2 ( movdqa xmm0 , [ ecx + 2 * 16 ] ) <nl> - AS2 ( movdq2q mm5 , xmm0 ) <nl> - AS2 ( movdqa [ edi + 2 * 16 ] , xmm0 ) <nl> - AS2 ( movdqa xmm0 , [ ecx + 3 * 16 ] ) <nl> - AS2 ( movdqa [ edi + 3 * 16 ] , xmm0 ) <nl> - ASJ ( jmp , 0 , f ) <nl> - <nl> - # define SSE2_S0_S1 ( r , a , b , c ) \ <nl> - AS2 ( movq mm6 , r ) \ <nl> - AS2 ( psrlq r , a ) \ <nl> - AS2 ( movq mm7 , r ) \ <nl> - AS2 ( psllq mm6 , 64 - c ) \ <nl> - AS2 ( pxor mm7 , mm6 ) \ <nl> - AS2 ( psrlq r , b - a ) \ <nl> - AS2 ( pxor mm7 , r ) \ <nl> - AS2 ( psllq mm6 , c - b ) \ <nl> - AS2 ( pxor mm7 , mm6 ) \ <nl> - AS2 ( psrlq r , c - b ) \ <nl> - AS2 ( pxor r , mm7 ) \ <nl> - AS2 ( psllq mm6 , b - a ) \ <nl> - AS2 ( pxor r , mm6 ) <nl> - <nl> - # define SSE2_s0 ( r , a , b , c ) \ <nl> - AS2 ( movdqa xmm6 , r ) \ <nl> - AS2 ( psrlq r , a ) \ <nl> - AS2 ( movdqa xmm7 , r ) \ <nl> - AS2 ( psllq xmm6 , 64 - c ) \ <nl> - AS2 ( pxor xmm7 , xmm6 ) \ <nl> - AS2 ( psrlq r , b - a ) \ <nl> - AS2 ( pxor xmm7 , r ) \ <nl> - AS2 ( psrlq r , c - b ) \ <nl> - AS2 ( pxor r , xmm7 ) \ <nl> - AS2 ( psllq xmm6 , c - a ) \ <nl> - AS2 ( pxor r , xmm6 ) <nl> - <nl> - # define SSE2_s1 ( r , a , b , c ) \ <nl> - AS2 ( movdqa xmm6 , r ) \ <nl> - AS2 ( psrlq r , a ) \ <nl> - AS2 ( movdqa xmm7 , r ) \ <nl> - AS2 ( psllq xmm6 , 64 - c ) \ <nl> - AS2 ( pxor xmm7 , xmm6 ) \ <nl> - AS2 ( psrlq r , b - a ) \ <nl> - AS2 ( pxor xmm7 , r ) \ <nl> - AS2 ( psllq xmm6 , c - b ) \ <nl> - AS2 ( pxor xmm7 , xmm6 ) \ <nl> - AS2 ( psrlq r , c - b ) \ <nl> - AS2 ( pxor r , xmm7 ) <nl> - <nl> - ASL ( SHA512_Round ) <nl> - / / k + w is in mm0 , a is in mm4 , e is in mm5 <nl> - AS2 ( paddq mm0 , [ edi + 7 * 8 ] ) / / h <nl> - AS2 ( movq mm2 , [ edi + 5 * 8 ] ) / / f <nl> - AS2 ( movq mm3 , [ edi + 6 * 8 ] ) / / g <nl> - AS2 ( pxor mm2 , mm3 ) <nl> - AS2 ( pand mm2 , mm5 ) <nl> - SSE2_S0_S1 ( mm5 , 14 , 18 , 41 ) <nl> - AS2 ( pxor mm2 , mm3 ) <nl> - AS2 ( paddq mm0 , mm2 ) / / h + = Ch ( e , f , g ) <nl> - AS2 ( paddq mm5 , mm0 ) / / h + = S1 ( e ) <nl> - AS2 ( movq mm2 , [ edi + 1 * 8 ] ) / / b <nl> - AS2 ( movq mm1 , mm2 ) <nl> - AS2 ( por mm2 , mm4 ) <nl> - AS2 ( pand mm2 , [ edi + 2 * 8 ] ) / / c <nl> - AS2 ( pand mm1 , mm4 ) <nl> - AS2 ( por mm1 , mm2 ) <nl> - AS2 ( paddq mm1 , mm5 ) / / temp = h + Maj ( a , b , c ) <nl> - AS2 ( paddq mm5 , [ edi + 3 * 8 ] ) / / e = d + h <nl> - AS2 ( movq [ edi + 3 * 8 ] , mm5 ) <nl> - AS2 ( movq [ edi + 11 * 8 ] , mm5 ) <nl> - SSE2_S0_S1 ( mm4 , 28 , 34 , 39 ) / / S0 ( a ) <nl> - AS2 ( paddq mm4 , mm1 ) / / a = temp + S0 ( a ) <nl> - AS2 ( movq [ edi - 8 ] , mm4 ) <nl> - AS2 ( movq [ edi + 7 * 8 ] , mm4 ) <nl> - AS1 ( ret ) <nl> - <nl> - / / first 16 rounds <nl> - ASL ( 0 ) <nl> - AS2 ( movq mm0 , [ edx + eax * 8 ] ) <nl> - AS2 ( movq [ esi + eax * 8 ] , mm0 ) <nl> - AS2 ( movq [ esi + eax * 8 + 16 * 8 ] , mm0 ) <nl> - AS2 ( paddq mm0 , [ ebx + eax * 8 ] ) <nl> - ASC ( call , SHA512_Round ) <nl> - AS1 ( inc eax ) <nl> - AS2 ( sub edi , 8 ) <nl> - AS2 ( test eax , 7 ) <nl> - ASJ ( jnz , 0 , b ) <nl> - AS2 ( add edi , 8 * 8 ) <nl> - AS2 ( cmp eax , 16 ) <nl> - ASJ ( jne , 0 , b ) <nl> - <nl> - / / rest of the rounds <nl> - AS2 ( movdqu xmm0 , [ esi + ( 16 - 2 ) * 8 ] ) <nl> - ASL ( 1 ) <nl> - / / data expansion , W [ i - 2 ] already in xmm0 <nl> - AS2 ( movdqu xmm3 , [ esi ] ) <nl> - AS2 ( paddq xmm3 , [ esi + ( 16 - 7 ) * 8 ] ) <nl> - AS2 ( movdqa xmm2 , [ esi + ( 16 - 15 ) * 8 ] ) <nl> - SSE2_s1 ( xmm0 , 6 , 19 , 61 ) <nl> - AS2 ( paddq xmm0 , xmm3 ) <nl> - SSE2_s0 ( xmm2 , 1 , 7 , 8 ) <nl> - AS2 ( paddq xmm0 , xmm2 ) <nl> - AS2 ( movdq2q mm0 , xmm0 ) <nl> - AS2 ( movhlps xmm1 , xmm0 ) <nl> - AS2 ( paddq mm0 , [ ebx + eax * 8 ] ) <nl> - AS2 ( movlps [ esi ] , xmm0 ) <nl> - AS2 ( movlps [ esi + 8 ] , xmm1 ) <nl> - AS2 ( movlps [ esi + 8 * 16 ] , xmm0 ) <nl> - AS2 ( movlps [ esi + 8 * 17 ] , xmm1 ) <nl> - / / 2 rounds <nl> - ASC ( call , SHA512_Round ) <nl> - AS2 ( sub edi , 8 ) <nl> - AS2 ( movdq2q mm0 , xmm1 ) <nl> - AS2 ( paddq mm0 , [ ebx + eax * 8 + 8 ] ) <nl> - ASC ( call , SHA512_Round ) <nl> - / / update indices and loop <nl> - AS2 ( add esi , 16 ) <nl> - AS2 ( add eax , 2 ) <nl> - AS2 ( sub edi , 8 ) <nl> - AS2 ( test eax , 7 ) <nl> - ASJ ( jnz , 1 , b ) <nl> - / / do housekeeping every 8 rounds <nl> - AS2 ( mov esi , 0xf ) <nl> - AS2 ( and esi , eax ) <nl> - AS2 ( lea esi , [ esp + 4 + 20 * 8 + 8 + esi * 8 ] ) <nl> - AS2 ( add edi , 8 * 8 ) <nl> - AS2 ( cmp eax , 80 ) <nl> - ASJ ( jne , 1 , b ) <nl> - <nl> - # define SSE2_CombineState ( i ) \ <nl> - AS2 ( movdqa xmm0 , [ edi + i * 16 ] ) \ <nl> - AS2 ( paddq xmm0 , [ ecx + i * 16 ] ) \ <nl> - AS2 ( movdqa [ ecx + i * 16 ] , xmm0 ) <nl> - <nl> - SSE2_CombineState ( 0 ) <nl> - SSE2_CombineState ( 1 ) <nl> - SSE2_CombineState ( 2 ) <nl> - SSE2_CombineState ( 3 ) <nl> - <nl> - AS1 ( pop esp ) <nl> - AS1 ( emms ) <nl> - <nl> - # if defined ( __GNUC__ ) <nl> - AS1 ( pop ebx ) <nl> - " . att_syntax prefix ; " <nl> - : <nl> - : " a " ( SHA512_K ) , " c " ( state ) , " d " ( data ) <nl> - : " % esi " , " % edi " , " memory " , " cc " <nl> - ) ; <nl> - # else <nl> - AS1 ( pop edi ) <nl> - AS1 ( pop esi ) <nl> - AS1 ( pop ebx ) <nl> - AS1 ( ret ) <nl> - # endif <nl> - } <nl> - # endif / / # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE <nl> - <nl> - void SHA512 : : Transform ( word64 * state , const word64 * data ) <nl> - { <nl> - # if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE & & CRYPTOPP_BOOL_X86 <nl> - if ( HasSSE2 ( ) ) <nl> - { <nl> - SHA512_SSE2_Transform ( state , data ) ; <nl> - return ; <nl> - } <nl> - # endif <nl> - <nl> - # define S0 ( x ) ( rotrFixed ( x , 28 ) ^ rotrFixed ( x , 34 ) ^ rotrFixed ( x , 39 ) ) <nl> - # define S1 ( x ) ( rotrFixed ( x , 14 ) ^ rotrFixed ( x , 18 ) ^ rotrFixed ( x , 41 ) ) <nl> - # define s0 ( x ) ( rotrFixed ( x , 1 ) ^ rotrFixed ( x , 8 ) ^ ( x > > 7 ) ) <nl> - # define s1 ( x ) ( rotrFixed ( x , 19 ) ^ rotrFixed ( x , 61 ) ^ ( x > > 6 ) ) <nl> - <nl> - # define R ( i ) h ( i ) + = S1 ( e ( i ) ) + Ch ( e ( i ) , f ( i ) , g ( i ) ) + SHA512_K [ i + j ] + ( j ? blk2 ( i ) : blk0 ( i ) ) ; \ <nl> - d ( i ) + = h ( i ) ; h ( i ) + = S0 ( a ( i ) ) + Maj ( a ( i ) , b ( i ) , c ( i ) ) <nl> - <nl> - word64 W [ 16 ] ; <nl> - word64 T [ 8 ] ; <nl> - / * Copy context - > state [ ] to working vars * / <nl> - memcpy ( T , state , sizeof ( T ) ) ; <nl> - / * 80 operations , partially loop unrolled * / <nl> - for ( unsigned int j = 0 ; j < 80 ; j + = 16 ) <nl> - { <nl> - R ( 0 ) ; R ( 1 ) ; R ( 2 ) ; R ( 3 ) ; <nl> - R ( 4 ) ; R ( 5 ) ; R ( 6 ) ; R ( 7 ) ; <nl> - R ( 8 ) ; R ( 9 ) ; R ( 10 ) ; R ( 11 ) ; <nl> - R ( 12 ) ; R ( 13 ) ; R ( 14 ) ; R ( 15 ) ; <nl> - } <nl> - / * Add the working vars back into context . state [ ] * / <nl> - state [ 0 ] + = a ( 0 ) ; <nl> - state [ 1 ] + = b ( 0 ) ; <nl> - state [ 2 ] + = c ( 0 ) ; <nl> - state [ 3 ] + = d ( 0 ) ; <nl> - state [ 4 ] + = e ( 0 ) ; <nl> - state [ 5 ] + = f ( 0 ) ; <nl> - state [ 6 ] + = g ( 0 ) ; <nl> - state [ 7 ] + = h ( 0 ) ; <nl> - } <nl> - <nl> - NAMESPACE_END <nl> - <nl> - # endif / / # ifndef CRYPTOPP_GENERATE_X64_MASM <nl> - # endif / / # ifndef CRYPTOPP_IMPORTS <nl> deleted file mode 100644 <nl> index 679081e8fa33 . . 000000000000 <nl> mmm a / src / cryptopp / sha . h <nl> ppp / dev / null <nl> <nl> - # ifndef CRYPTOPP_SHA_H <nl> - # define CRYPTOPP_SHA_H <nl> - <nl> - # include " iterhash . h " <nl> - <nl> - NAMESPACE_BEGIN ( CryptoPP ) <nl> - <nl> - / / / < a href = " http : / / www . weidai . com / scan - mirror / md . html # SHA - 1 " > SHA - 1 < / a > <nl> - class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform < word32 , BigEndian , 64 , 20 , SHA1 > <nl> - { <nl> - public : <nl> - static void CRYPTOPP_API InitState ( HashWordType * state ) ; <nl> - static void CRYPTOPP_API Transform ( word32 * digest , const word32 * data ) ; <nl> - static const char * CRYPTOPP_API StaticAlgorithmName ( ) { return " SHA - 1 " ; } <nl> - } ; <nl> - <nl> - typedef SHA1 SHA ; / / for backwards compatibility <nl> - <nl> - / / ! implements the SHA - 256 standard <nl> - class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform < word32 , BigEndian , 64 , 32 , SHA256 , 32 , true > <nl> - { <nl> - public : <nl> - # if defined ( CRYPTOPP_X86_ASM_AVAILABLE ) | | defined ( CRYPTOPP_X64_MASM_AVAILABLE ) <nl> - size_t HashMultipleBlocks ( const word32 * input , size_t length ) ; <nl> - # endif <nl> - static void CRYPTOPP_API InitState ( HashWordType * state ) ; <nl> - static void CRYPTOPP_API Transform ( word32 * digest , const word32 * data ) ; <nl> - static const char * CRYPTOPP_API StaticAlgorithmName ( ) { return " SHA - 256 " ; } <nl> - } ; <nl> - <nl> - / / ! implements the SHA - 224 standard <nl> - class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform < word32 , BigEndian , 64 , 32 , SHA224 , 28 , true > <nl> - { <nl> - public : <nl> - # if defined ( CRYPTOPP_X86_ASM_AVAILABLE ) | | defined ( CRYPTOPP_X64_MASM_AVAILABLE ) <nl> - size_t HashMultipleBlocks ( const word32 * input , size_t length ) ; <nl> - # endif <nl> - static void CRYPTOPP_API InitState ( HashWordType * state ) ; <nl> - static void CRYPTOPP_API Transform ( word32 * digest , const word32 * data ) { SHA256 : : Transform ( digest , data ) ; } <nl> - static const char * CRYPTOPP_API StaticAlgorithmName ( ) { return " SHA - 224 " ; } <nl> - } ; <nl> - <nl> - / / ! implements the SHA - 512 standard <nl> - class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform < word64 , BigEndian , 128 , 64 , SHA512 , 64 , CRYPTOPP_BOOL_X86 > <nl> - { <nl> - public : <nl> - static void CRYPTOPP_API InitState ( HashWordType * state ) ; <nl> - static void CRYPTOPP_API Transform ( word64 * digest , const word64 * data ) ; <nl> - static const char * CRYPTOPP_API StaticAlgorithmName ( ) { return " SHA - 512 " ; } <nl> - } ; <nl> - <nl> - / / ! implements the SHA - 384 standard <nl> - class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform < word64 , BigEndian , 128 , 64 , SHA384 , 48 , CRYPTOPP_BOOL_X86 > <nl> - { <nl> - public : <nl> - static void CRYPTOPP_API InitState ( HashWordType * state ) ; <nl> - static void CRYPTOPP_API Transform ( word64 * digest , const word64 * data ) { SHA512 : : Transform ( digest , data ) ; } <nl> - static const char * CRYPTOPP_API StaticAlgorithmName ( ) { return " SHA - 384 " ; } <nl> - } ; <nl> - <nl> - NAMESPACE_END <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 8b137891791f . . 000000000000 <nl> mmm a / src / cryptopp / simple . h <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - <nl> deleted file mode 100644 <nl> index 6b4040e99960 . . 000000000000 <nl> mmm a / src / cryptopp / smartptr . h <nl> ppp / dev / null <nl> <nl> - # ifndef CRYPTOPP_SMARTPTR_H <nl> - # define CRYPTOPP_SMARTPTR_H <nl> - <nl> - # include " config . h " <nl> - # include < algorithm > <nl> - <nl> - NAMESPACE_BEGIN ( CryptoPP ) <nl> - <nl> - template < class T > class simple_ptr <nl> - { <nl> - public : <nl> - simple_ptr ( ) : m_p ( NULL ) { } <nl> - ~ simple_ptr ( ) { delete m_p ; } <nl> - T * m_p ; <nl> - } ; <nl> - <nl> - template < class T > class member_ptr <nl> - { <nl> - public : <nl> - explicit member_ptr ( T * p = NULL ) : m_p ( p ) { } <nl> - <nl> - ~ member_ptr ( ) ; <nl> - <nl> - const T & operator * ( ) const { return * m_p ; } <nl> - T & operator * ( ) { return * m_p ; } <nl> - <nl> - const T * operator - > ( ) const { return m_p ; } <nl> - T * operator - > ( ) { return m_p ; } <nl> - <nl> - const T * get ( ) const { return m_p ; } <nl> - T * get ( ) { return m_p ; } <nl> - <nl> - T * release ( ) <nl> - { <nl> - T * old_p = m_p ; <nl> - m_p = 0 ; <nl> - return old_p ; <nl> - } <nl> - <nl> - void reset ( T * p = 0 ) ; <nl> - <nl> - protected : <nl> - member_ptr ( const member_ptr < T > & rhs ) ; / / copy not allowed <nl> - void operator = ( const member_ptr < T > & rhs ) ; / / assignment not allowed <nl> - <nl> - T * m_p ; <nl> - } ; <nl> - <nl> - template < class T > member_ptr < T > : : ~ member_ptr ( ) { delete m_p ; } <nl> - template < class T > void member_ptr < T > : : reset ( T * p ) { delete m_p ; m_p = p ; } <nl> - <nl> - / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - <nl> - template < class T > class value_ptr : public member_ptr < T > <nl> - { <nl> - public : <nl> - value_ptr ( const T & obj ) : member_ptr < T > ( new T ( obj ) ) { } <nl> - value_ptr ( T * p = NULL ) : member_ptr < T > ( p ) { } <nl> - value_ptr ( const value_ptr < T > & rhs ) <nl> - : member_ptr < T > ( rhs . m_p ? new T ( * rhs . m_p ) : NULL ) { } <nl> - <nl> - value_ptr < T > & operator = ( const value_ptr < T > & rhs ) ; <nl> - bool operator = = ( const value_ptr < T > & rhs ) <nl> - { <nl> - return ( ! this - > m_p & & ! rhs . m_p ) | | ( this - > m_p & & rhs . m_p & & * this - > m_p = = * rhs . m_p ) ; <nl> - } <nl> - } ; <nl> - <nl> - template < class T > value_ptr < T > & value_ptr < T > : : operator = ( const value_ptr < T > & rhs ) <nl> - { <nl> - T * old_p = this - > m_p ; <nl> - this - > m_p = rhs . m_p ? new T ( * rhs . m_p ) : NULL ; <nl> - delete old_p ; <nl> - return * this ; <nl> - } <nl> - <nl> - / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - <nl> - template < class T > class clonable_ptr : public member_ptr < T > <nl> - { <nl> - public : <nl> - clonable_ptr ( const T & obj ) : member_ptr < T > ( obj . Clone ( ) ) { } <nl> - clonable_ptr ( T * p = NULL ) : member_ptr < T > ( p ) { } <nl> - clonable_ptr ( const clonable_ptr < T > & rhs ) <nl> - : member_ptr < T > ( rhs . m_p ? rhs . m_p - > Clone ( ) : NULL ) { } <nl> - <nl> - clonable_ptr < T > & operator = ( const clonable_ptr < T > & rhs ) ; <nl> - } ; <nl> - <nl> - template < class T > clonable_ptr < T > & clonable_ptr < T > : : operator = ( const clonable_ptr < T > & rhs ) <nl> - { <nl> - T * old_p = this - > m_p ; <nl> - this - > m_p = rhs . m_p ? rhs . m_p - > Clone ( ) : NULL ; <nl> - delete old_p ; <nl> - return * this ; <nl> - } <nl> - <nl> - / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - <nl> - template < class T > class counted_ptr <nl> - { <nl> - public : <nl> - explicit counted_ptr ( T * p = 0 ) ; <nl> - counted_ptr ( const T & r ) : m_p ( 0 ) { attach ( r ) ; } <nl> - counted_ptr ( const counted_ptr < T > & rhs ) ; <nl> - <nl> - ~ counted_ptr ( ) ; <nl> - <nl> - const T & operator * ( ) const { return * m_p ; } <nl> - T & operator * ( ) { return * m_p ; } <nl> - <nl> - const T * operator - > ( ) const { return m_p ; } <nl> - T * operator - > ( ) { return get ( ) ; } <nl> - <nl> - const T * get ( ) const { return m_p ; } <nl> - T * get ( ) ; <nl> - <nl> - void attach ( const T & p ) ; <nl> - <nl> - counted_ptr < T > & operator = ( const counted_ptr < T > & rhs ) ; <nl> - <nl> - private : <nl> - T * m_p ; <nl> - } ; <nl> - <nl> - template < class T > counted_ptr < T > : : counted_ptr ( T * p ) <nl> - : m_p ( p ) <nl> - { <nl> - if ( m_p ) <nl> - m_p - > m_referenceCount = 1 ; <nl> - } <nl> - <nl> - template < class T > counted_ptr < T > : : counted_ptr ( const counted_ptr < T > & rhs ) <nl> - : m_p ( rhs . m_p ) <nl> - { <nl> - if ( m_p ) <nl> - m_p - > m_referenceCount + + ; <nl> - } <nl> - <nl> - template < class T > counted_ptr < T > : : ~ counted_ptr ( ) <nl> - { <nl> - if ( m_p & & - - m_p - > m_referenceCount = = 0 ) <nl> - delete m_p ; <nl> - } <nl> - <nl> - template < class T > void counted_ptr < T > : : attach ( const T & r ) <nl> - { <nl> - if ( m_p & & - - m_p - > m_referenceCount = = 0 ) <nl> - delete m_p ; <nl> - if ( r . m_referenceCount = = 0 ) <nl> - { <nl> - m_p = r . clone ( ) ; <nl> - m_p - > m_referenceCount = 1 ; <nl> - } <nl> - else <nl> - { <nl> - m_p = const_cast < T * > ( & r ) ; <nl> - m_p - > m_referenceCount + + ; <nl> - } <nl> - } <nl> - <nl> - template < class T > T * counted_ptr < T > : : get ( ) <nl> - { <nl> - if ( m_p & & m_p - > m_referenceCount > 1 ) <nl> - { <nl> - T * temp = m_p - > clone ( ) ; <nl> - m_p - > m_referenceCount - - ; <nl> - m_p = temp ; <nl> - m_p - > m_referenceCount = 1 ; <nl> - } <nl> - return m_p ; <nl> - } <nl> - <nl> - template < class T > counted_ptr < T > & counted_ptr < T > : : operator = ( const counted_ptr < T > & rhs ) <nl> - { <nl> - if ( m_p ! = rhs . m_p ) <nl> - { <nl> - if ( m_p & & - - m_p - > m_referenceCount = = 0 ) <nl> - delete m_p ; <nl> - m_p = rhs . m_p ; <nl> - if ( m_p ) <nl> - m_p - > m_referenceCount + + ; <nl> - } <nl> - return * this ; <nl> - } <nl> - <nl> - / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - <nl> - template < class T > class vector_member_ptrs <nl> - { <nl> - public : <nl> - vector_member_ptrs ( size_t size = 0 ) <nl> - : m_size ( size ) , m_ptr ( new member_ptr < T > [ size ] ) { } <nl> - ~ vector_member_ptrs ( ) <nl> - { delete [ ] this - > m_ptr ; } <nl> - <nl> - member_ptr < T > & operator [ ] ( size_t index ) <nl> - { assert ( index < this - > m_size ) ; return this - > m_ptr [ index ] ; } <nl> - const member_ptr < T > & operator [ ] ( size_t index ) const <nl> - { assert ( index < this - > m_size ) ; return this - > m_ptr [ index ] ; } <nl> - <nl> - size_t size ( ) const { return this - > m_size ; } <nl> - void resize ( size_t newSize ) <nl> - { <nl> - member_ptr < T > * newPtr = new member_ptr < T > [ newSize ] ; <nl> - for ( size_t i = 0 ; i < this - > m_size & & i < newSize ; i + + ) <nl> - newPtr [ i ] . reset ( this - > m_ptr [ i ] . release ( ) ) ; <nl> - delete [ ] this - > m_ptr ; <nl> - this - > m_size = newSize ; <nl> - this - > m_ptr = newPtr ; <nl> - } <nl> - <nl> - private : <nl> - vector_member_ptrs ( const vector_member_ptrs < T > & c ) ; / / copy not allowed <nl> - void operator = ( const vector_member_ptrs < T > & x ) ; / / assignment not allowed <nl> - <nl> - size_t m_size ; <nl> - member_ptr < T > * m_ptr ; <nl> - } ; <nl> - <nl> - NAMESPACE_END <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 9a468ab61ef7 . . 000000000000 <nl> mmm a / src / cryptopp / stdcpp . h <nl> ppp / dev / null <nl> <nl> - # ifndef CRYPTOPP_STDCPP_H <nl> - # define CRYPTOPP_STDCPP_H <nl> - <nl> - # include < stddef . h > <nl> - # include < assert . h > <nl> - # include < limits . h > <nl> - # include < memory > <nl> - # include < string > <nl> - # include < exception > <nl> - # include < typeinfo > <nl> - <nl> - <nl> - # ifdef _MSC_VER <nl> - # include < string . h > / / CodeWarrior doesn ' t have memory . h <nl> - # include < algorithm > <nl> - # include < map > <nl> - # include < vector > <nl> - <nl> - / / re - disable this <nl> - # pragma warning ( disable : 4231 ) <nl> - # endif <nl> - <nl> - # if defined ( _MSC_VER ) & & defined ( _CRTAPI1 ) <nl> - # define CRYPTOPP_MSVCRT6 <nl> - # endif <nl> - <nl> - # endif <nl> mmm a / src / main . cpp <nl> ppp b / src / main . cpp <nl> <nl> # include " db . h " <nl> # include " net . h " <nl> # include " init . h " <nl> - # include " cryptopp / sha . h " <nl> # include < boost / filesystem . hpp > <nl> # include < boost / filesystem / fstream . hpp > <nl> <nl> int static FormatHashBlocks ( void * pbuffer , unsigned int len ) <nl> return blocks ; <nl> } <nl> <nl> - using CryptoPP : : ByteReverse ; <nl> - <nl> static const unsigned int pSHA256InitState [ 8 ] = <nl> { 0x6a09e667 , 0xbb67ae85 , 0x3c6ef372 , 0xa54ff53a , 0x510e527f , 0x9b05688c , 0x1f83d9ab , 0x5be0cd19 } ; <nl> <nl> - inline void SHA256Transform ( void * pstate , void * pinput , const void * pinit ) <nl> + void SHA256Transform ( void * pstate , void * pinput , const void * pinit ) <nl> { <nl> - memcpy ( pstate , pinit , 32 ) ; <nl> - CryptoPP : : SHA256 : : Transform ( ( CryptoPP : : word32 * ) pstate , ( CryptoPP : : word32 * ) pinput ) ; <nl> + SHA256_CTX ctx ; <nl> + unsigned char data [ 64 ] ; <nl> + <nl> + SHA256_Init ( & ctx ) ; <nl> + <nl> + for ( int i = 0 ; i < 16 ; i + + ) <nl> + ( ( uint32_t * ) data ) [ i ] = ByteReverse ( ( ( uint32_t * ) pinput ) [ i ] ) ; <nl> + <nl> + for ( int i = 0 ; i < 8 ; i + + ) <nl> + ctx . h [ i ] = ( ( uint32_t * ) pinit ) [ i ] ; <nl> + <nl> + SHA256_Update ( & ctx , data , sizeof ( data ) ) ; <nl> + for ( int i = 0 ; i < 8 ; i + + ) <nl> + ( ( uint32_t * ) pstate ) [ i ] = ctx . h [ i ] ; <nl> } <nl> <nl> / / <nl> mmm a / src / makefile . linux - mingw <nl> ppp b / src / makefile . linux - mingw <nl> HEADERS = \ <nl> util . h \ <nl> wallet . h <nl> <nl> + <nl> ifdef USE_UPNP <nl> LIBPATHS + = - L " $ ( DEPSDIR ) / miniupnpc " <nl> LIBS + = - l miniupnpc - l iphlpapi <nl> OBJS = \ <nl> obj / bitcoinrpc . o \ <nl> obj / script . o \ <nl> obj / util . o \ <nl> - obj / wallet . o \ <nl> - cryptopp / obj / sha . o \ <nl> - cryptopp / obj / cpu . o <nl> - <nl> + obj / wallet . o <nl> <nl> all : bitcoind . exe <nl> <nl> - cryptopp / obj / % . o : cryptopp / % . cpp <nl> - i586 - mingw32msvc - g + + - c $ ( CFLAGS ) - O3 - DCRYPTOPP_DISABLE_ASM - o $ @ $ < <nl> - <nl> obj / nogui / % . o : % . cpp $ ( HEADERS ) <nl> i586 - mingw32msvc - g + + - c $ ( CFLAGS ) - o $ @ $ < <nl> <nl> clean : <nl> - rm - f obj / * . o <nl> - rm - f obj / nogui / * . o <nl> - rm - f obj / test / * . o <nl> - - rm - f cryptopp / obj / * . o <nl> - rm - f test / * . o <nl> - rm - f headers . h . gch <nl> - rm - f bitcoind . exe <nl> mmm a / src / makefile . mingw <nl> ppp b / src / makefile . mingw <nl> OBJS = \ <nl> obj / bitcoinrpc . o \ <nl> obj / script . o \ <nl> obj / util . o \ <nl> - obj / wallet . o \ <nl> - cryptopp / obj / sha . o \ <nl> - cryptopp / obj / cpu . o <nl> + obj / wallet . o <nl> <nl> <nl> all : bitcoind . exe <nl> <nl> - cryptopp / obj / % . o : cryptopp / % . cpp <nl> - g + + - c $ ( CFLAGS ) - O3 - DCRYPTOPP_DISABLE_ASM - o $ @ $ < <nl> - <nl> obj / nogui / % . o : % . cpp $ ( HEADERS ) <nl> g + + - c $ ( CFLAGS ) - o $ @ $ < <nl> <nl> clean : <nl> - del / Q obj \ * <nl> - del / Q obj \ nogui \ * <nl> - del / Q obj \ test \ * <nl> - - del / Q cryptopp \ obj \ * <nl> - del / Q test \ * . o <nl> - del / Q headers . h . gch <nl> mmm a / src / makefile . osx <nl> ppp b / src / makefile . osx <nl> OBJS = \ <nl> obj / bitcoinrpc . o \ <nl> obj / script . o \ <nl> obj / util . o \ <nl> - obj / wallet . o \ <nl> - cryptopp / obj / sha . o \ <nl> - cryptopp / obj / cpu . o <nl> + obj / wallet . o <nl> <nl> ifdef USE_UPNP <nl> LIBS + = $ ( DEPSDIR ) / lib / libminiupnpc . a <nl> endif <nl> <nl> all : bitcoind <nl> <nl> - cryptopp / obj / % . o : cryptopp / % . cpp <nl> - $ ( CXX ) - c $ ( CFLAGS ) - O3 - DCRYPTOPP_DISABLE_ASM - o $ @ $ < <nl> - <nl> obj / nogui / % . o : % . cpp $ ( HEADERS ) <nl> $ ( CXX ) - c $ ( CFLAGS ) - o $ @ $ < <nl> <nl> clean : <nl> - rm - f obj / * . o <nl> - rm - f obj / nogui / * . o <nl> - rm - f obj / test / * . o <nl> - - rm - f cryptopp / obj / * . o <nl> mmm a / src / makefile . unix <nl> ppp b / src / makefile . unix <nl> OBJS = \ <nl> obj / bitcoinrpc . o \ <nl> obj / script . o \ <nl> obj / util . o \ <nl> - obj / wallet . o \ <nl> - cryptopp / obj / sha . o \ <nl> - cryptopp / obj / cpu . o <nl> + obj / wallet . o <nl> <nl> <nl> all : bitcoind <nl> <nl> <nl> - cryptopp / obj / % . o : cryptopp / % . cpp <nl> - $ ( CXX ) - c $ ( CFLAGS ) - O3 - o $ @ $ < <nl> - <nl> obj / nogui / % . o : % . cpp $ ( HEADERS ) <nl> $ ( CXX ) - c $ ( CXXFLAGS ) - o $ @ $ < <nl> <nl> clean : <nl> - rm - f obj / * . o <nl> - rm - f obj / nogui / * . o <nl> - rm - f obj / test / * . o <nl> - - rm - f cryptopp / obj / * . o <nl> - rm - f headers . h . gch <nl> mmm a / src / makefile . vc <nl> ppp b / src / makefile . vc <nl> OBJS = \ <nl> obj \ protocol . o \ <nl> obj \ script . o \ <nl> obj \ util . o \ <nl> - obj \ wallet . o \ <nl> - cryptopp \ obj \ sha . o \ <nl> - cryptopp \ obj \ cpu . o <nl> - <nl> - CRYPTOPP_OBJS = \ <nl> - cryptopp \ obj \ sha . obj \ <nl> - cryptopp \ obj \ cpu . obj <nl> + obj \ wallet . o <nl> <nl> RC = . . / share <nl> <nl> obj \ ui . obj : $ ( HEADERS ) <nl> <nl> obj \ uibase . obj : $ ( HEADERS ) <nl> <nl> - cryptopp \ obj \ sha . obj : cryptopp \ sha . cpp <nl> - cl $ ( CFLAGS ) / O2 / DCRYPTOPP_DISABLE_ASM / Fo $ @ % s <nl> - <nl> - cryptopp \ obj \ cpu . obj : cryptopp \ cpu . cpp <nl> - cl $ ( CFLAGS ) / O2 / DCRYPTOPP_DISABLE_ASM / Fo $ @ % s <nl> - <nl> . cpp { obj \ nogui } . obj : <nl> cl $ ( CFLAGS ) / Fo $ @ % s <nl> <nl> obj \ nogui \ rpc . obj : $ ( HEADERS ) <nl> <nl> obj \ nogui \ init . obj : $ ( HEADERS ) <nl> <nl> - bitcoind . exe : $ ( OBJS : obj \ = obj \ nogui \ ) $ ( CRYPTOPP_OBJS ) obj \ ui . res <nl> + bitcoind . exe : $ ( OBJS : obj \ = obj \ nogui \ ) obj \ ui . res <nl> link / nologo / OUT : $ @ $ ( LIBPATHS ) $ * * $ ( LIBS ) <nl> <nl> clean : <nl> - del / Q obj \ * <nl> - del / Q obj \ nogui \ * <nl> - - del / Q cryptopp \ obj \ * <nl> - del / Q * . ilk <nl> - del / Q * . pdb <nl> - del / Q bitcoind . exe <nl> new file mode 100644 <nl> index 000000000000 . . e773542d717d <nl> mmm / dev / null <nl> ppp b / src / test / miner_tests . cpp <nl> <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " . . / uint256 . h " <nl> + <nl> + extern void SHA256Transform ( void * pstate , void * pinput , const void * pinit ) ; <nl> + <nl> + BOOST_AUTO_TEST_SUITE ( miner_tests ) <nl> + <nl> + BOOST_AUTO_TEST_CASE ( sha256transform_equality ) <nl> + { <nl> + unsigned int pSHA256InitState [ 8 ] = { 0x6a09e667 , 0xbb67ae85 , 0x3c6ef372 , 0xa54ff53a , 0x510e527f , 0x9b05688c , 0x1f83d9ab , 0x5be0cd19 } ; <nl> + <nl> + <nl> + unsigned char pstate [ 32 ] ; <nl> + unsigned char pinput [ 32 ] ; <nl> + <nl> + int i ; <nl> + <nl> + for ( i = 0 ; i < 32 ; i + + ) { <nl> + pinput [ i ] = i ; <nl> + pstate [ i ] = 0 ; <nl> + } <nl> + <nl> + uint256 hash ; <nl> + <nl> + SHA256Transform ( & hash , pinput , pSHA256InitState ) ; <nl> + <nl> + BOOST_TEST_MESSAGE ( hash . GetHex ( ) ) ; <nl> + <nl> + uint256 hash_reference ( " 0x2df5e1c65ef9f8cde240d23cae2ec036d31a15ec64bc68f64be242b1da6631f3 " ) ; <nl> + <nl> + BOOST_CHECK ( hash = = hash_reference ) ; <nl> + } <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> mmm a / src / test / test_bitcoin . cpp <nl> ppp b / src / test / test_bitcoin . cpp <nl> <nl> # include " transaction_tests . cpp " <nl> # include " DoS_tests . cpp " <nl> # include " base64_tests . cpp " <nl> + # include " miner_tests . cpp " <nl> <nl> CWallet * pwalletMain ; <nl> <nl> void Shutdown ( void * parg ) <nl> { <nl> - exit ( 0 ) ; <nl> + exit ( 0 ) ; <nl> } <nl> mmm a / src / util . h <nl> ppp b / src / util . h <nl> inline bool AffinityBugWorkaround ( void ( * pfn ) ( void * ) ) <nl> return false ; <nl> } <nl> <nl> + template < class T > inline T rotlFixed ( T x , unsigned int y ) <nl> + { <nl> + assert ( y < sizeof ( T ) * 8 ) ; <nl> + return T ( ( x < < y ) | ( x > > ( sizeof ( T ) * 8 - y ) ) ) ; <nl> + } <nl> + <nl> + template < class T > inline T rotrFixed ( T x , unsigned int y ) <nl> + { <nl> + assert ( y < sizeof ( T ) * 8 ) ; <nl> + return T ( ( x > > y ) | ( x < < ( sizeof ( T ) * 8 - y ) ) ) ; <nl> + } <nl> + <nl> + inline uint32_t ByteReverse ( uint32_t value ) <nl> + { <nl> + # if defined ( __MWERKS__ ) & & TARGET_CPU_PPC <nl> + return ( uint32_t ) __lwbrx ( & value , 0 ) ; <nl> + # elif _MSC_VER > = 1400 | | ( _MSC_VER > = 1300 & & ! defined ( _DLL ) ) <nl> + return _byteswap_ulong ( value ) ; <nl> + # else <nl> + / / 6 instructions with rotate instruction , 8 without <nl> + value = ( ( value & 0xFF00FF00 ) > > 8 ) | ( ( value & 0x00FF00FF ) < < 8 ) ; <nl> + return rotlFixed ( value , 16U ) ; <nl> + # endif <nl> + } <nl> + <nl> # endif <nl> mmm a / src / wallet . cpp <nl> ppp b / src / wallet . cpp <nl> <nl> <nl> # include " headers . h " <nl> # include " db . h " <nl> - # include " cryptopp / sha . h " <nl> # include " crypter . h " <nl> <nl> using namespace std ; <nl>
|
remove cryptopp dependency , add simple unittest for SHA256Transform ( )
|
bitcoin/bitcoin
|
6ccff2cbdebca38e4913b679784a4865edfbb12a
|
2011-09-30T18:00:22Z
|
mmm a / infra / mb / mb_config . pyl <nl> ppp b / infra / mb / mb_config . pyl <nl> <nl> # FYI . <nl> ' V8 Linux - swarming staging ' : ' gn_release_x64 ' , <nl> ' V8 Linux64 - cfi ' : ' gn_release_x64_cfi ' , <nl> + ' V8 Linux64 UBSanVptr ' : ' gn_release_x64_ubsan_vptr ' , <nl> ' V8 Linux - vtunejit ' : ' gn_debug_x86_vtunejit ' , <nl> ' V8 Linux64 - gcov coverage ' : ' gn_release_x64_gcc_coverage ' , <nl> ' V8 Linux - predictable ' : ' gn_release_x86_predictable ' , <nl> <nl> ' v8_linux64_tsan_rel ' : ' gn_release_x64_tsan_minimal_symbols ' , <nl> ' v8_linux64_tsan_concurrent_marking_rel_ng ' : <nl> ' gn_release_x64_tsan_concurrent_marking_minimal_symbols ' , <nl> + ' v8_linux64_ubsan_rel_ng ' : ' gn_release_x64_ubsan_vptr_minimal_symbols ' , <nl> ' v8_win_dbg ' : ' gn_debug_x86_trybot ' , <nl> ' v8_win_compile_dbg ' : ' gn_debug_x86_trybot ' , <nl> ' v8_win_rel_ng ' : ' gn_release_x86_trybot ' , <nl> <nl> ' minimal_symbols ' , ' swarming ' ] , <nl> ' gn_release_x64_tsan_minimal_symbols ' : [ <nl> ' gn ' , ' release_bot ' , ' x64 ' , ' tsan ' , ' minimal_symbols ' , ' swarming ' ] , <nl> + ' gn_release_x64_ubsan_vptr ' : [ <nl> + ' gn ' , ' release_bot ' , ' x64 ' , ' ubsan_vptr ' ] , <nl> + ' gn_release_x64_ubsan_vptr_minimal_symbols ' : [ <nl> + ' gn ' , ' release_bot ' , ' x64 ' , ' ubsan_vptr ' , ' minimal_symbols ' ] , <nl> ' gn_release_x64_valgrind ' : [ <nl> ' gn ' , ' release_bot ' , ' x64 ' , ' swarming ' , ' valgrind ' , <nl> ' no_custom_libcxx ' ] , <nl> <nl> ' gyp_defines ' : ' clang = 1 tsan = 1 ' , <nl> } , <nl> <nl> + ' ubsan_vptr ' : { <nl> + # TODO ( krasin ) : Remove is_ubsan_no_recover = true when <nl> + # https : / / llvm . org / bugs / show_bug . cgi ? id = 25569 is fixed and just use <nl> + # ubsan_vptr instead . <nl> + ' gn_args ' : ' is_ubsan_vptr = true is_ubsan_no_recover = true ' , <nl> + } , <nl> + <nl> ' valgrind ' : { <nl> ' gn_args ' : ' v8_has_valgrind = true ' , <nl> ' gyp_defines ' : ' has_valgrind = 1 ' , <nl>
|
[ build ] Add MB configs for ubsan bots
|
v8/v8
|
cd7380bb0bad260bfbee7e936d404f59e5feae06
|
2017-07-18T14:08:09Z
|
mmm a / tools / dockerfile / grpc_csharp_mono / Dockerfile <nl> ppp b / tools / dockerfile / grpc_csharp_mono / Dockerfile <nl> RUN cd / var / local / git / grpc \ <nl> # Install the gRPC C # extension library <nl> RUN make install_grpc_csharp_ext - j12 - C / var / local / git / grpc <nl> <nl> - # TODO : download NuGet from web . The problem is there seems to be no direct link <nl> - # we could use : - ) <nl> - ADD NuGet . exe NuGet . exe <nl> - <nl> # Restore the NuGet dependencies <nl> - RUN cd / var / local / git / grpc / src / csharp & & mono / NuGet . exe restore Grpc . sln <nl> + RUN cd / var / local / git / grpc / src / csharp & & mono / var / local / NuGet . exe restore Grpc . sln <nl> <nl> # Build gRPC solution <nl> RUN cd / var / local / git / grpc / src / csharp & & xbuild Grpc . sln <nl> mmm a / tools / dockerfile / grpc_csharp_mono_base / Dockerfile <nl> ppp b / tools / dockerfile / grpc_csharp_mono_base / Dockerfile <nl> RUN apt - get update & & apt - get install - y \ <nl> nunit - console \ <nl> monodevelop <nl> <nl> + # Download NuGet <nl> + RUN cd / var / local & & wget www . nuget . org / NuGet . exe <nl> + <nl> # Get the source from GitHub <nl> RUN git clone git @ github . com : grpc / grpc . git / var / local / git / grpc <nl> RUN cd / var / local / git / grpc & & \ <nl>
|
Merge pull request from jtattermusch / csharp_docker
|
grpc/grpc
|
df2186fb3f1a18f3c49315b88cfdafa0a82b852c
|
2015-03-03T19:23:07Z
|
mmm a / hphp / runtime / base / program - functions . cpp <nl> ppp b / hphp / runtime / base / program - functions . cpp <nl> <nl> # include < folly / Range . h > <nl> # include < folly / Portability . h > <nl> # include < folly / Singleton . h > <nl> + # include < folly / portability / Environment . h > <nl> <nl> # include < boost / algorithm / string / replace . hpp > <nl> # include < boost / program_options / options_description . hpp > <nl> <nl> <nl> using namespace boost : : program_options ; <nl> using std : : cout ; <nl> - extern char * * environ ; <nl> <nl> constexpr auto MAX_INPUT_NESTING_LEVEL = 64 ; <nl> <nl> mmm a / hphp / runtime / ext / std / ext_std_process . cpp <nl> ppp b / hphp / runtime / ext / std / ext_std_process . cpp <nl> <nl> # include < signal . h > <nl> <nl> # include < folly / String . h > <nl> + # include < folly / portability / Environment . h > <nl> <nl> # include " hphp / util / light - process . h " <nl> # include " hphp / util / lock . h " <nl> <nl> # define _NSIG NSIG <nl> # endif <nl> <nl> - extern char * * environ ; <nl> - <nl> namespace HPHP { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl>
|
Use Folly ' s environment portability header rather than declaring environ manually .
|
facebook/hhvm
|
3db945ce03ef27f78289cfd9c1f2b706216b212e
|
2016-03-23T22:00:43Z
|
mmm a / example / autoencoder / autoencoder . py <nl> ppp b / example / autoencoder / autoencoder . py <nl> def l2_norm ( label , pred ) : <nl> data_iter , X . shape [ 0 ] , self . xpu ) . values ( ) [ 0 ] <nl> data_iter_i = mx . io . NDArrayIter ( { ' data ' : X_i } , batch_size = batch_size , <nl> last_batch_handle = ' roll_over ' ) <nl> + logging . info ( ' Pre - training layer % d . . . ' % i ) <nl> solver . solve ( self . xpu , self . stacks [ i ] , self . args , self . args_grad , data_iter_i , <nl> 0 , n_iter , { } , False ) <nl> <nl> def l2_norm ( label , pred ) : <nl> solver . set_monitor ( Monitor ( 1000 ) ) <nl> data_iter = mx . io . NDArrayIter ( { ' data ' : X } , batch_size = batch_size , shuffle = False , <nl> last_batch_handle = ' roll_over ' ) <nl> + logging . info ( ' Fine tuning . . . ' ) <nl> solver . solve ( self . xpu , self . loss , self . args , self . args_grad , data_iter , <nl> 0 , n_iter , { } , False ) <nl> <nl> mmm a / example / autoencoder / solver . py <nl> ppp b / example / autoencoder / solver . py <nl> def forward_end ( self , i , internals ) : <nl> if i % self . interval = = 0 and logging . getLogger ( ) . isEnabledFor ( self . level ) : <nl> for key in sorted ( internals . keys ( ) ) : <nl> arr = internals [ key ] <nl> - logging . log ( self . level , ' iter : % d param : % s \ t \ tstat ( % s ) : % s ' % ( i , key , self . stat . __name__ , str ( self . stat ( arr . asnumpy ( ) ) ) ) ) <nl> + logging . log ( self . level , ' Iter : % d param : % s \ t \ tstat ( % s ) : % s ' % ( i , key , self . stat . __name__ , str ( self . stat ( arr . asnumpy ( ) ) ) ) ) <nl> <nl> def backward_end ( self , i , weights , grads , metric = None ) : <nl> if i % self . interval = = 0 and logging . getLogger ( ) . isEnabledFor ( self . level ) : <nl> for key in sorted ( grads . keys ( ) ) : <nl> arr = grads [ key ] <nl> - logging . log ( self . level , ' iter : % d param : % s \ t \ tstat ( % s ) : % s \ t \ tgrad_stat : % s ' % ( i , key , self . stat . __name__ , str ( self . stat ( weights [ key ] . asnumpy ( ) ) ) , str ( self . stat ( arr . asnumpy ( ) ) ) ) ) <nl> - if metric is not None : <nl> - logging . info ( ' Iter : % d metric : % f ' % ( i , metric . get ( ) [ 1 ] ) ) <nl> + logging . log ( self . level , ' Iter : % d param : % s \ t \ tstat ( % s ) : % s \ t \ tgrad_stat : % s ' % ( i , key , self . stat . __name__ , str ( self . stat ( weights [ key ] . asnumpy ( ) ) ) , str ( self . stat ( arr . asnumpy ( ) ) ) ) ) <nl> + if i % self . interval = = 0 and metric is not None : <nl> + logging . log ( logging . INFO , ' Iter : % d metric : % f ' % ( i , metric . get ( ) [ 1 ] ) ) <nl> <nl> class Solver ( object ) : <nl> def __init__ ( self , optimizer , * * kwargs ) : <nl> def solve ( self , xpu , sym , args , args_grad , <nl> <nl> output_dict = { } <nl> output_buff = { } <nl> - internal_dict = { } <nl> + internal_dict = dict ( zip ( input_names , input_buffs ) ) <nl> for key , arr in zip ( sym . list_outputs ( ) , exe . outputs ) : <nl> if key in output_names : <nl> output_dict [ key ] = arr <nl> def solve ( self , xpu , sym , args , args_grad , <nl> data_iter . reset ( ) <nl> for i in range ( begin_iter , end_iter ) : <nl> if self . iter_start_callback is not None : <nl> - self . iter_start_callback ( i ) <nl> + if self . iter_start_callback ( i ) : <nl> + return <nl> try : <nl> batch = data_iter . next ( ) <nl> except : <nl> def solve ( self , xpu , sym , args , args_grad , <nl> self . updater ( key , arr , args [ key ] ) <nl> <nl> if self . metric is not None : <nl> + self . metric . reset ( ) <nl> self . metric . update ( [ input_buffs [ - 1 ] . asnumpy ( ) ] , <nl> [ output_buff [ output_names [ 0 ] ] . asnumpy ( ) ] ) <nl> <nl> def solve ( self , xpu , sym , args , args_grad , <nl> self . monitor . backward_end ( i , args , update_dict , self . metric ) <nl> <nl> if self . iter_end_callback is not None : <nl> - self . iter_end_callback ( i ) <nl> + if self . iter_end_callback ( i ) : <nl> + return <nl> exe . outputs [ 0 ] . wait_to_read ( ) <nl> <nl> <nl>
|
autoencoder example update
|
apache/incubator-mxnet
|
292b83935020f8edc8eecd65bde64ddc21b4595e
|
2015-11-12T04:16:57Z
|
mmm a / tensorflow / core / common_runtime / sycl / sycl_device_factory . cc <nl> ppp b / tensorflow / core / common_runtime / sycl / sycl_device_factory . cc <nl> namespace tensorflow { <nl> <nl> class SYCLDeviceFactory : public DeviceFactory { <nl> public : <nl> - Status CreateDevices ( const SessionOptions & options , const string & name_prefix , <nl> - std : : vector < Device * > * devices ) override { <nl> + Status ListPhysicalDevices ( std : : vector < string > * devices ) override { <nl> + return tensorflow : : Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status CreateDevices ( const SessionOptions & options , const string & name_prefix , <nl> + std : : vector < std : : unique_ptr < Device > > * devices ) override { <nl> auto syclInterface = GSYCLInterface : : instance ( ) ; <nl> <nl> size_t n = 1 ; <nl>
|
Add ListPhysicalDevices to SYCLDeviceFactory
|
tensorflow/tensorflow
|
e656cf4837be75165ad749c14f7a4005bf0a0932
|
2019-04-15T15:34:57Z
|
mmm a / tensorflow / docs_src / programmers_guide / version_compat . md <nl> ppp b / tensorflow / docs_src / programmers_guide / version_compat . md <nl> patch versions . The public APIs consist of <nl> * [ ` event ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / util / event . proto ) <nl> * [ ` graph ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / graph . proto ) <nl> * [ ` op_def ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / op_def . proto ) <nl> - * [ ` reader_base ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / kernels / reader_base . proto ) <nl> + * [ ` reader_base ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / reader_base . proto ) <nl> * [ ` summary ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / summary . proto ) <nl> * [ ` tensor ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / tensor . proto ) <nl> * [ ` tensor_shape ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / tensor_shape . proto ) <nl> mmm a / tensorflow / docs_src / programmers_guide / version_semantics . md <nl> ppp b / tensorflow / docs_src / programmers_guide / version_semantics . md <nl> patch versions . The public APIs consist of <nl> [ ` event ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / util / event . proto ) , <nl> [ ` graph ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / graph . proto ) , <nl> [ ` op_def ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / op_def . proto ) , <nl> - [ ` reader_base ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / kernels / reader_base . proto ) , <nl> + [ ` reader_base ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / reader_base . proto ) , <nl> [ ` summary ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / summary . proto ) , <nl> [ ` tensor ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / tensor . proto ) , <nl> [ ` tensor_shape ` ] ( https : / / github . com / tensorflow / tensorflow / blob / master / tensorflow / core / framework / tensor_shape . proto ) , <nl>
|
Merge pull request from yongtang / 07012017 - link
|
tensorflow/tensorflow
|
b51d27575abccff83e540059ff0e9c5eb1773584
|
2017-07-07T01:45:53Z
|
mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / Impl . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorPortAudio / Impl . cpp <nl> XmlNodeRef CImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnection , E <nl> { <nl> pNode = GetISystem ( ) - > CreateXmlNode ( CryAudio : : s_szEventTag ) ; <nl> pNode - > setAttr ( CryAudio : : s_szNameAttribute , pItem - > GetName ( ) ) ; <nl> - pNode - > setAttr ( CryAudio : : Impl : : PortAudio : : s_szPathAttribute , pItem - > GetPath ( ) ) ; <nl> + <nl> + string const & path = pItem - > GetPath ( ) ; <nl> + <nl> + if ( ! path . IsEmpty ( ) ) <nl> + { <nl> + pNode - > setAttr ( CryAudio : : Impl : : PortAudio : : s_szPathAttribute , path . c_str ( ) ) ; <nl> + } <nl> <nl> if ( pEventConnection - > GetActionType ( ) = = CEventConnection : : EActionType : : Start ) <nl> { <nl> mmm a / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / Impl . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAudioControlsEditor / EditorSDLMixer / Impl . cpp <nl> XmlNodeRef CImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnection , E <nl> { <nl> pNode = GetISystem ( ) - > CreateXmlNode ( CryAudio : : s_szEventTag ) ; <nl> pNode - > setAttr ( CryAudio : : s_szNameAttribute , pItem - > GetName ( ) ) ; <nl> - pNode - > setAttr ( CryAudio : : Impl : : SDL_mixer : : s_szPathAttribute , pItem - > GetPath ( ) ) ; <nl> + <nl> + string const & path = pItem - > GetPath ( ) ; <nl> + <nl> + if ( ! path . IsEmpty ( ) ) <nl> + { <nl> + pNode - > setAttr ( CryAudio : : Impl : : SDL_mixer : : s_szPathAttribute , pItem - > GetPath ( ) ) ; <nl> + } <nl> <nl> CEventConnection : : EActionType const actionType = pEventConnection - > GetActionType ( ) ; <nl> <nl> XmlNodeRef CImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnection , E <nl> { <nl> pNode = GetISystem ( ) - > CreateXmlNode ( CryAudio : : s_szEventTag ) ; <nl> pNode - > setAttr ( CryAudio : : s_szNameAttribute , pItem - > GetName ( ) ) ; <nl> - pNode - > setAttr ( CryAudio : : Impl : : SDL_mixer : : s_szPathAttribute , pItem - > GetPath ( ) ) ; <nl> + <nl> + string const & path = pItem - > GetPath ( ) ; <nl> + <nl> + if ( ! path . IsEmpty ( ) ) <nl> + { <nl> + pNode - > setAttr ( CryAudio : : Impl : : SDL_mixer : : s_szPathAttribute , pItem - > GetPath ( ) ) ; <nl> + } <nl> <nl> if ( pParameterConnection - > GetMultiplier ( ) ! = CryAudio : : Impl : : SDL_mixer : : s_defaultParamMultiplier ) <nl> { <nl> XmlNodeRef CImpl : : CreateXMLNodeFromConnection ( ConnectionPtr const pConnection , E <nl> { <nl> pNode = GetISystem ( ) - > CreateXmlNode ( CryAudio : : s_szEventTag ) ; <nl> pNode - > setAttr ( CryAudio : : s_szNameAttribute , pItem - > GetName ( ) ) ; <nl> - pNode - > setAttr ( CryAudio : : Impl : : SDL_mixer : : s_szPathAttribute , pItem - > GetPath ( ) ) ; <nl> + <nl> + string const & path = pItem - > GetPath ( ) ; <nl> + <nl> + if ( ! path . IsEmpty ( ) ) <nl> + { <nl> + pNode - > setAttr ( CryAudio : : Impl : : SDL_mixer : : s_szPathAttribute , pItem - > GetPath ( ) ) ; <nl> + } <nl> + <nl> pNode - > setAttr ( CryAudio : : Impl : : SDL_mixer : : s_szValueAttribute , pStateConnection - > GetValue ( ) ) ; <nl> <nl> if ( ( pItem - > GetFlags ( ) & EItemFlags : : IsLocalized ) ! = 0 ) <nl>
|
! XO ( Audio ) SDL Mixer , Port Audio : Don ' t write empty path attribute to XML .
|
CRYTEK/CRYENGINE
|
9126a5add156cdae982fa10e1cfe9562a948774f
|
2018-09-21T08:38:49Z
|
mmm a / caffe2 / core / operator . cc <nl> ppp b / caffe2 / core / operator . cc <nl> C10_DEFINE_bool ( <nl> C10_DEFINE_bool ( <nl> caffe2_operator_throw_if_fp_exceptions , <nl> false , <nl> - " If set , throws if floating point exceptions ( FE_DIVBYZERO , FE_INVALID , " <nl> - " FE_OVERFLOW ) are detected when running any operator . " ) ; <nl> + " If set , throws if floating point exceptions ( FE_DIVBYZERO , FE_INVALID ) " <nl> + " are detected when running any operator . FE_OVERFLOW is handled separately " <nl> + " by caffe2_operator_throw_if_fp_overflow_exceptions option . " ) ; <nl> + C10_DEFINE_bool ( <nl> + caffe2_operator_throw_if_fp_overflow_exceptions , <nl> + false , <nl> + " If set , throws if floating point exception FE_OVERFLOW is detected when " <nl> + " running any operator . " ) ; <nl> <nl> namespace caffe2 { <nl> <nl> mmm a / caffe2 / core / operator . h <nl> ppp b / caffe2 / core / operator . h <nl> <nl> # endif <nl> <nl> C10_DECLARE_bool ( caffe2_operator_throw_if_fp_exceptions ) ; <nl> + C10_DECLARE_bool ( caffe2_operator_throw_if_fp_overflow_exceptions ) ; <nl> <nl> namespace c10 { <nl> struct FunctionSchema ; <nl> class Operator : public OperatorBase { <nl> CAFFE_ENFORCE ( <nl> ! std : : fetestexcept ( FE_INVALID ) , <nl> " Invalid floating point exception ( FE_INVALID ) reported . " ) ; <nl> + } <nl> + if ( FLAGS_caffe2_operator_throw_if_fp_overflow_exceptions ) { <nl> CAFFE_ENFORCE ( <nl> ! std : : fetestexcept ( FE_OVERFLOW ) , <nl> " Overflow floating point exception ( FE_OVERFLOW ) reported . " ) ; <nl>
|
separate option for FE_OVERFLOW ( )
|
pytorch/pytorch
|
7b9ee598d64bd35cad9afea8276ebd1c069620d9
|
2019-05-19T23:05:27Z
|
deleted file mode 100644 <nl> index 739e22d6341c . . 000000000000 <nl> mmm a / doc / README_osx . md <nl> ppp / dev / null <nl> <nl> - Deterministic macOS DMG Notes . <nl> - <nl> - Working macOS DMGs are created in Linux by combining a recent clang , <nl> - the Apple binutils ( ld , ar , etc ) and DMG authoring tools . <nl> - <nl> - Apple uses clang extensively for development and has upstreamed the necessary <nl> - functionality so that a vanilla clang can take advantage . It supports the use <nl> - of - F , - target , - mmacosx - version - min , and - - sysroot , which are all necessary <nl> - when building for macOS . <nl> - <nl> - Apple ' s version of binutils ( called cctools ) contains lots of functionality <nl> - missing in the FSF ' s binutils . In addition to extra linker options for <nl> - frameworks and sysroots , several other tools are needed as well such as <nl> - install_name_tool , lipo , and nmedit . These do not build under linux , so they <nl> - have been patched to do so . The work here was used as a starting point : <nl> - [ mingwandroid / toolchain4 ] ( https : / / github . com / mingwandroid / toolchain4 ) . <nl> - <nl> - In order to build a working toolchain , the following source packages are needed <nl> - from Apple : cctools , dyld , and ld64 . <nl> - <nl> - These tools inject timestamps by default , which produce non - deterministic <nl> - binaries . The ZERO_AR_DATE environment variable is used to disable that . <nl> - <nl> - This version of cctools has been patched to use the current version of clang ' s <nl> - headers and its libLTO . so rather than those from llvmgcc , as it was <nl> - originally done in toolchain4 . <nl> - <nl> - To complicate things further , all builds must target an Apple SDK . These SDKs <nl> - are free to download , but not redistributable . <nl> - To obtain it , register for a developer account , then download the [ Xcode 7 . 3 . 1 dmg ] ( https : / / developer . apple . com / devcenter / download . action ? path = / Developer_Tools / Xcode_7 . 3 . 1 / Xcode_7 . 3 . 1 . dmg ) . <nl> - <nl> - This file is several gigabytes in size , but only a single directory inside is <nl> - needed : <nl> - ` ` ` <nl> - Xcode . app / Contents / Developer / Platforms / MacOSX . platform / Developer / SDKs / MacOSX10 . 11 . sdk <nl> - ` ` ` <nl> - <nl> - Unfortunately , the usual linux tools ( 7zip , hpmount , loopback mount ) are incapable of opening this file . <nl> - To create a tarball suitable for Gitian input , there are two options : <nl> - <nl> - Using macOS , you can mount the dmg , and then create it with : <nl> - ` ` ` <nl> - $ hdiutil attach Xcode_7 . 3 . 1 . dmg <nl> - $ tar - C / Volumes / Xcode / Xcode . app / Contents / Developer / Platforms / MacOSX . platform / Developer / SDKs / - czf MacOSX10 . 11 . sdk . tar . gz MacOSX10 . 11 . sdk <nl> - ` ` ` <nl> - <nl> - Alternatively , you can use 7zip and SleuthKit to extract the files one by one . <nl> - The script contrib / macdeploy / extract - osx - sdk . sh automates this . First ensure <nl> - the dmg file is in the current directory , and then run the script . You may wish <nl> - to delete the intermediate 5 . hfs file and MacOSX10 . 11 . sdk ( the directory ) when <nl> - you ' ve confirmed the extraction succeeded . <nl> - <nl> - ` ` ` bash <nl> - apt - get install p7zip - full sleuthkit <nl> - contrib / macdeploy / extract - osx - sdk . sh <nl> - rm - rf 5 . hfs MacOSX10 . 11 . sdk <nl> - ` ` ` <nl> - <nl> - The Gitian descriptors build 2 sets of files : Linux tools , then Apple binaries <nl> - which are created using these tools . The build process has been designed to <nl> - avoid including the SDK ' s files in Gitian ' s outputs . All interim tarballs are <nl> - fully deterministic and may be freely redistributed . <nl> - <nl> - genisoimage is used to create the initial DMG . It is not deterministic as - is , <nl> - so it has been patched . A system genisoimage will work fine , but it will not <nl> - be deterministic because the file - order will change between invocations . <nl> - The patch can be seen here : [ theuni / osx - cross - depends ] ( https : / / raw . githubusercontent . com / theuni / osx - cross - depends / master / patches / cdrtools / genisoimage . diff ) . <nl> - No effort was made to fix this cleanly , so it likely leaks memory badly . But <nl> - it ' s only used for a single invocation , so that ' s no real concern . <nl> - <nl> - genisoimage cannot compress DMGs , so afterwards , the ' dmg ' tool from the <nl> - libdmg - hfsplus project is used to compress it . There are several bugs in this <nl> - tool and its maintainer has seemingly abandoned the project . It has been forked <nl> - and is available ( with fixes ) here : [ theuni / libdmg - hfsplus ] ( https : / / github . com / theuni / libdmg - hfsplus ) . <nl> - <nl> - The ' dmg ' tool has the ability to create DMGs from scratch as well , but this <nl> - functionality is broken . Only the compression feature is currently used . <nl> - Ideally , the creation could be fixed and genisoimage would no longer be necessary . <nl> - <nl> - Background images and other features can be added to DMG files by inserting a <nl> - . DS_Store before creation . This is generated by the script <nl> - contrib / macdeploy / custom_dsstore . py . <nl> - <nl> - As of OS X 10 . 9 Mavericks , using an Apple - blessed key to sign binaries is a <nl> - requirement in order to satisfy the new Gatekeeper requirements . Because this <nl> - private key cannot be shared , we ' ll have to be a bit creative in order for the <nl> - build process to remain somewhat deterministic . Here ' s how it works : <nl> - <nl> - - Builders use Gitian to create an unsigned release . This outputs an unsigned <nl> - dmg which users may choose to bless and run . It also outputs an unsigned app <nl> - structure in the form of a tarball , which also contains all of the tools <nl> - that have been previously ( deterministically ) built in order to create a <nl> - final dmg . <nl> - - The Apple keyholder uses this unsigned app to create a detached signature , <nl> - using the script that is also included there . Detached signatures are available from this [ repository ] ( https : / / github . com / bitcoin - core / bitcoin - detached - sigs ) . <nl> - - Builders feed the unsigned app + detached signature back into Gitian . It <nl> - uses the pre - built tools to recombine the pieces into a deterministic dmg . <nl> mmm a / doc / build - osx . md <nl> ppp b / doc / build - osx . md <nl> Notes <nl> * Tested on OS X 10 . 10 Yosemite through macOS 10 . 13 High Sierra on 64 - bit Intel processors only . <nl> <nl> * Building with downloaded Qt binaries is not officially supported . See the notes in [ # 7714 ] ( https : / / github . com / bitcoin / bitcoin / issues / 7714 ) <nl> + <nl> + Deterministic macOS DMG Notes <nl> + mmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + Working macOS DMGs are created in Linux by combining a recent clang , <nl> + the Apple binutils ( ld , ar , etc ) and DMG authoring tools . <nl> + <nl> + Apple uses clang extensively for development and has upstreamed the necessary <nl> + functionality so that a vanilla clang can take advantage . It supports the use <nl> + of - F , - target , - mmacosx - version - min , and - - sysroot , which are all necessary <nl> + when building for macOS . <nl> + <nl> + Apple ' s version of binutils ( called cctools ) contains lots of functionality <nl> + missing in the FSF ' s binutils . In addition to extra linker options for <nl> + frameworks and sysroots , several other tools are needed as well such as <nl> + install_name_tool , lipo , and nmedit . These do not build under linux , so they <nl> + have been patched to do so . The work here was used as a starting point : <nl> + [ mingwandroid / toolchain4 ] ( https : / / github . com / mingwandroid / toolchain4 ) . <nl> + <nl> + In order to build a working toolchain , the following source packages are needed <nl> + from Apple : cctools , dyld , and ld64 . <nl> + <nl> + These tools inject timestamps by default , which produce non - deterministic <nl> + binaries . The ZERO_AR_DATE environment variable is used to disable that . <nl> + <nl> + This version of cctools has been patched to use the current version of clang ' s <nl> + headers and its libLTO . so rather than those from llvmgcc , as it was <nl> + originally done in toolchain4 . <nl> + <nl> + To complicate things further , all builds must target an Apple SDK . These SDKs <nl> + are free to download , but not redistributable . <nl> + To obtain it , register for a developer account , then download the [ Xcode 7 . 3 . 1 dmg ] ( https : / / developer . apple . com / devcenter / download . action ? path = / Developer_Tools / Xcode_7 . 3 . 1 / Xcode_7 . 3 . 1 . dmg ) . <nl> + <nl> + This file is several gigabytes in size , but only a single directory inside is <nl> + needed : <nl> + ` ` ` <nl> + Xcode . app / Contents / Developer / Platforms / MacOSX . platform / Developer / SDKs / MacOSX10 . 11 . sdk <nl> + ` ` ` <nl> + <nl> + Unfortunately , the usual linux tools ( 7zip , hpmount , loopback mount ) are incapable of opening this file . <nl> + To create a tarball suitable for Gitian input , there are two options : <nl> + <nl> + Using macOS , you can mount the dmg , and then create it with : <nl> + ` ` ` <nl> + $ hdiutil attach Xcode_7 . 3 . 1 . dmg <nl> + $ tar - C / Volumes / Xcode / Xcode . app / Contents / Developer / Platforms / MacOSX . platform / Developer / SDKs / - czf MacOSX10 . 11 . sdk . tar . gz MacOSX10 . 11 . sdk <nl> + ` ` ` <nl> + <nl> + Alternatively , you can use 7zip and SleuthKit to extract the files one by one . <nl> + The script contrib / macdeploy / extract - osx - sdk . sh automates this . First ensure <nl> + the dmg file is in the current directory , and then run the script . You may wish <nl> + to delete the intermediate 5 . hfs file and MacOSX10 . 11 . sdk ( the directory ) when <nl> + you ' ve confirmed the extraction succeeded . <nl> + <nl> + ` ` ` bash <nl> + apt - get install p7zip - full sleuthkit <nl> + contrib / macdeploy / extract - osx - sdk . sh <nl> + rm - rf 5 . hfs MacOSX10 . 11 . sdk <nl> + ` ` ` <nl> + <nl> + The Gitian descriptors build 2 sets of files : Linux tools , then Apple binaries <nl> + which are created using these tools . The build process has been designed to <nl> + avoid including the SDK ' s files in Gitian ' s outputs . All interim tarballs are <nl> + fully deterministic and may be freely redistributed . <nl> + <nl> + genisoimage is used to create the initial DMG . It is not deterministic as - is , <nl> + so it has been patched . A system genisoimage will work fine , but it will not <nl> + be deterministic because the file - order will change between invocations . <nl> + The patch can be seen here : [ theuni / osx - cross - depends ] ( https : / / raw . githubusercontent . com / theuni / osx - cross - depends / master / patches / cdrtools / genisoimage . diff ) . <nl> + No effort was made to fix this cleanly , so it likely leaks memory badly . But <nl> + it ' s only used for a single invocation , so that ' s no real concern . <nl> + <nl> + genisoimage cannot compress DMGs , so afterwards , the ' dmg ' tool from the <nl> + libdmg - hfsplus project is used to compress it . There are several bugs in this <nl> + tool and its maintainer has seemingly abandoned the project . It has been forked <nl> + and is available ( with fixes ) here : [ theuni / libdmg - hfsplus ] ( https : / / github . com / theuni / libdmg - hfsplus ) . <nl> + <nl> + The ' dmg ' tool has the ability to create DMGs from scratch as well , but this <nl> + functionality is broken . Only the compression feature is currently used . <nl> + Ideally , the creation could be fixed and genisoimage would no longer be necessary . <nl> + <nl> + Background images and other features can be added to DMG files by inserting a <nl> + . DS_Store before creation . This is generated by the script <nl> + contrib / macdeploy / custom_dsstore . py . <nl> + <nl> + As of OS X 10 . 9 Mavericks , using an Apple - blessed key to sign binaries is a <nl> + requirement in order to satisfy the new Gatekeeper requirements . Because this <nl> + private key cannot be shared , we ' ll have to be a bit creative in order for the <nl> + build process to remain somewhat deterministic . Here ' s how it works : <nl> + <nl> + - Builders use Gitian to create an unsigned release . This outputs an unsigned <nl> + dmg which users may choose to bless and run . It also outputs an unsigned app <nl> + structure in the form of a tarball , which also contains all of the tools <nl> + that have been previously ( deterministically ) built in order to create a <nl> + final dmg . <nl> + - The Apple keyholder uses this unsigned app to create a detached signature , <nl> + using the script that is also included there . Detached signatures are available from this [ repository ] ( https : / / github . com / bitcoin - core / bitcoin - detached - sigs ) . <nl> + - Builders feed the unsigned app + detached signature back into Gitian . It <nl> + uses the pre - built tools to recombine the pieces into a deterministic dmg . <nl> + <nl> mmm a / doc / release - process . md <nl> ppp b / doc / release - process . md <nl> Ensure gitian - builder is up - to - date : <nl> echo ' f9a8cdb38b9c309326764ebc937cba1523a3a751a7ab05df3ecc99d18ae466c9 inputs / osslsigncode - 1 . 7 . 1 . tar . gz ' | sha256sum - c <nl> popd <nl> <nl> - Create the macOS SDK tarball , see the [ macOS readme ] ( README_osx . md ) for details , and copy it into the inputs directory . <nl> + Create the macOS SDK tarball , see the [ macOS build instructions ] ( build - osx . md # deterministic - macos - dmg - notes ) for details , and copy it into the inputs directory . <nl> <nl> # # # Optional : Seed the Gitian sources cache and offline git repositories <nl> <nl>
|
Delete README_osx . md and move its contents into build - osx . md
|
bitcoin/bitcoin
|
f24ed6d39f963e7f1c0b4dbd9b784132ef975f2a
|
2019-01-21T19:24:33Z
|
mmm a / src / lib / outline . cc <nl> ppp b / src / lib / outline . cc <nl> void OutlinePrivate : : buildPrefixSum ( ) { <nl> prefixSum . push_back ( prefixSum . back ( ) + x ) ; <nl> } <nl> <nl> - void Outline : : dump ( QTextStream & stream , const QString & xsl ) const { <nl> + void Outline : : dump ( QTextStream & stream ) const { <nl> d - > buildPrefixSum ( ) ; <nl> stream < < " < ? xml version = \ " 1 . 0 \ " encoding = \ " UTF - 8 \ " ? > " < < endl ; <nl> - QString x = xsl ; <nl> - if ( ! x . isEmpty ( ) ) <nl> - stream < < " < ? xml - stylesheet type = \ " text / xsl \ " href = \ " " < < escape ( x ) < < " \ " ? > " < < endl ; <nl> - stream < < " < outline xmlns = \ " http : / / code . google . com / p / wkhtmltopdf / outline \ " > " < < endl ; <nl> + stream < < " < outline xmlns = \ " http : / / wkhtmltopdf . org / outline \ " > " < < endl ; <nl> d - > dumpChildren ( stream , d - > documentOutlines , 1 ) ; <nl> stream < < " < / outline > " < < endl ; <nl> } <nl> mmm a / src / lib / outline . hh <nl> ppp b / src / lib / outline . hh <nl> public : <nl> int pageCount ( ) ; <nl> void printOutline ( QPrinter * printer ) ; <nl> <nl> - void dump ( QTextStream & stream , const QString & xsl ) const ; <nl> + void dump ( QTextStream & stream ) const ; <nl> private : <nl> OutlinePrivate * d ; <nl> friend class TocPrinter ; <nl> mmm a / src / lib / pdfconverter . cc <nl> ppp b / src / lib / pdfconverter . cc <nl> <nl> # include < QWebFrame > <nl> # include < QWebPage > <nl> # include < QWebSettings > <nl> + # include < QXmlQuery > <nl> # include < algorithm > <nl> # include < qapplication . h > <nl> # include < qfileinfo . h > <nl> void PdfConverterPrivate : : loadTocs ( ) { <nl> style = obj . tocStyleFile . create ( " . xsl " ) ; <nl> StreamDumper styleDump ( style ) ; <nl> dumpDefaultTOCStyleSheet ( styleDump . stream , ps . toc ) ; <nl> - } else <nl> - style = MultiPageLoader : : guessUrlFromString ( style ) . toString ( ) ; <nl> + } <nl> <nl> QString path = obj . tocFile . create ( " . xml " ) ; <nl> StreamDumper sd ( path ) ; <nl> - outline - > dump ( sd . stream , style ) ; <nl> + outline - > dump ( sd . stream ) ; <nl> + <nl> + QFile styleFile ( style ) ; <nl> + if ( ! styleFile . open ( QIODevice : : ReadOnly ) ) { <nl> + emit out . error ( " Could not read the TOC XSL " ) ; <nl> + fail ( ) ; <nl> + } <nl> + <nl> + QFile xmlFile ( path ) ; <nl> + if ( ! xmlFile . open ( QIODevice : : ReadOnly ) ) { <nl> + emit out . error ( " Could not read the TOC XML " ) ; <nl> + fail ( ) ; <nl> + } <nl> + <nl> + QString htmlPath = obj . tocFile . create ( " . html " ) ; <nl> + QFile htmlFile ( htmlPath ) ; <nl> + if ( ! htmlFile . open ( QIODevice : : WriteOnly ) ) { <nl> + emit out . error ( " Could not open the TOC for writing " ) ; <nl> + fail ( ) ; <nl> + } <nl> + <nl> + QXmlQuery query ( QXmlQuery : : XSLT20 ) ; <nl> + query . setFocus ( & xmlFile ) ; <nl> + query . setQuery ( & styleFile ) ; <nl> + query . evaluateTo ( & htmlFile ) ; <nl> <nl> - obj . loaderObject = tocLoader - > addResource ( path , ps . load ) ; <nl> + obj . loaderObject = tocLoader - > addResource ( htmlPath , ps . load ) ; <nl> obj . page = & obj . loaderObject - > page ; <nl> PageObject : : webPageToObject [ obj . page ] = & obj ; <nl> updateWebSettings ( obj . page - > settings ( ) , ps . web ) ; <nl> void PdfConverterPrivate : : findLinks ( QWebFrame * frame , QVector < QPair < QWebElement <nl> if ( ! ulocal & & ! uexternal ) return ; <nl> foreach ( const QWebElement & elm , frame - > findAllElements ( " a " ) ) { <nl> QString n = elm . attribute ( " name " ) ; <nl> + if ( n . isEmpty ( ) ) n = elm . attribute ( " ns0 : name " ) ; <nl> if ( n . startsWith ( " __WKANCHOR_ " ) ) anchors [ n ] = elm ; <nl> <nl> QString h = elm . attribute ( " href " ) ; <nl> + if ( h . isEmpty ( ) ) h = elm . attribute ( " ns0 : href " ) ; <nl> if ( h . startsWith ( " __WKANCHOR_ " ) ) { <nl> local . push_back ( qMakePair ( elm , h ) ) ; <nl> } else { <nl> void PdfConverterPrivate : : printDocument ( ) { <nl> <nl> if ( ! settings . dumpOutline . isEmpty ( ) ) { <nl> StreamDumper sd ( settings . dumpOutline ) ; <nl> - outline - > dump ( sd . stream , " " ) ; <nl> + outline - > dump ( sd . stream ) ; <nl> } <nl> <nl> painter - > end ( ) ; <nl> mmm a / src / lib / tocstylesheet . cc <nl> ppp b / src / lib / tocstylesheet . cc <nl> namespace wkhtmltopdf { <nl> <nl> void dumpDefaultTOCStyleSheet ( QTextStream & stream , settings : : TableOfContent & s ) { <nl> stream < < " < ? xml version = \ " 1 . 0 \ " encoding = \ " UTF - 8 \ " ? > " < < endl <nl> - < < " < xsl : stylesheet version = \ " 1 . 0 \ " " < < endl <nl> + < < " < xsl : stylesheet version = \ " 2 . 0 \ " " < < endl <nl> < < " xmlns : xsl = \ " http : / / www . w3 . org / 1999 / XSL / Transform \ " " < < endl <nl> - < < " xmlns : outline = \ " http : / / code . google . com / p / wkhtmltopdf / outline \ " " < < endl <nl> + < < " xmlns : outline = \ " http : / / wkhtmltopdf . org / outline \ " " < < endl <nl> < < " xmlns = \ " http : / / www . w3 . org / 1999 / xhtml \ " > " < < endl <nl> < < " < xsl : output doctype - public = \ " - / / W3C / / DTD XHTML 1 . 0 Strict / / EN \ " " < < endl <nl> < < " doctype - system = \ " http : / / www . w3 . org / TR / xhtml1 / DTD / xhtml1 - transitional . dtd \ " " < < endl <nl> void dumpDefaultTOCStyleSheet ( QTextStream & stream , settings : : TableOfContent & s <nl> < < " < / div > " < < endl <nl> < < " < / xsl : if > " < < endl <nl> < < " < ul > " < < endl <nl> + < < " < xsl : comment > added to prevent self - closing tags in QtXmlPatterns < / xsl : comment > " < < endl <nl> < < " < xsl : apply - templates select = \ " outline : item \ " / > " < < endl <nl> < < " < / ul > " < < endl <nl> < < " < / li > " < < endl <nl>
|
rework TOC support to use XSL transformation via XmlPatterns
|
wkhtmltopdf/wkhtmltopdf
|
ffafb21f0276885c20e40347bdae57e38cd5c572
|
2014-02-13T09:51:10Z
|
mmm a / tensorflow / lite / delegates / xnnpack / BUILD <nl> ppp b / tensorflow / lite / delegates / xnnpack / BUILD <nl> cc_library ( <nl> ] , <nl> ) <nl> <nl> + cc_library ( <nl> + name = " conv_2d_tester " , <nl> + testonly = 1 , <nl> + srcs = [ " conv_2d_tester . cc " ] , <nl> + hdrs = [ " conv_2d_tester . h " ] , <nl> + deps = [ <nl> + " / / tensorflow / lite : framework " , <nl> + " / / tensorflow / lite : schema_fbs_version " , <nl> + " / / tensorflow / lite / c : common " , <nl> + " / / tensorflow / lite / kernels : builtin_ops " , <nl> + " / / tensorflow / lite / schema : schema_fbs " , <nl> + " @ FP16 " , <nl> + " @ com_google_googletest / / : gtest " , <nl> + " @ flatbuffers " , <nl> + ] , <nl> + ) <nl> + <nl> cc_library ( <nl> name = " depthwise_conv_2d_tester " , <nl> testonly = 1 , <nl> cc_test ( <nl> " / / conditions : default " : [ ] , <nl> } ) , <nl> deps = [ <nl> + " : conv_2d_tester " , <nl> " : test_main " , <nl> - " : xnnpack_delegate " , <nl> - " / / tensorflow / lite : framework " , <nl> - " / / tensorflow / lite : schema_fbs_version " , <nl> - " / / tensorflow / lite / kernels : builtin_ops " , <nl> - " / / tensorflow / lite / schema : schema_fbs " , <nl> - " @ FP16 " , <nl> + " : xnnpack_delegate_test_mode " , <nl> " @ com_google_googletest / / : gtest " , <nl> - " @ flatbuffers " , <nl> ] , <nl> ) <nl> <nl> mmm a / tensorflow / lite / delegates / xnnpack / conv_2d_test . cc <nl> ppp b / tensorflow / lite / delegates / xnnpack / conv_2d_test . cc <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> <nl> - # include < array > <nl> # include < cstdint > <nl> # include < functional > <nl> + # include < memory > <nl> # include < random > <nl> - # include < vector > <nl> <nl> # include < gtest / gtest . h > <nl> - # include < fp16 . h > <nl> - # include " flatbuffers / flatbuffers . h " / / from @ flatbuffers <nl> + # include " tensorflow / lite / delegates / xnnpack / conv_2d_tester . h " <nl> # include " tensorflow / lite / delegates / xnnpack / xnnpack_delegate . h " <nl> - # include " tensorflow / lite / interpreter . h " <nl> - # include " tensorflow / lite / kernels / register . h " <nl> - # include " tensorflow / lite / model . h " <nl> - # include " tensorflow / lite / schema / schema_generated . h " <nl> - # include " tensorflow / lite / version . h " <nl> <nl> namespace tflite { <nl> namespace xnnpack { <nl> <nl> - namespace { <nl> - <nl> - class Conv2DTester { <nl> - public : <nl> - Conv2DTester ( ) = default ; <nl> - Conv2DTester ( const Conv2DTester & ) = delete ; <nl> - Conv2DTester & operator = ( const Conv2DTester & ) = delete ; <nl> - <nl> - Conv2DTester & BatchSize ( int32_t batch_size ) { <nl> - EXPECT_GT ( batch_size , 0 ) ; <nl> - batch_size_ = batch_size ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t BatchSize ( ) const { return batch_size_ ; } <nl> - <nl> - Conv2DTester & InputChannels ( int32_t input_channels ) { <nl> - EXPECT_GT ( input_channels , 0 ) ; <nl> - input_channels_ = input_channels ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t InputChannels ( ) const { return input_channels_ ; } <nl> - <nl> - Conv2DTester & OutputChannels ( int32_t output_channels ) { <nl> - EXPECT_GT ( output_channels , 0 ) ; <nl> - output_channels_ = output_channels ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t OutputChannels ( ) const { return output_channels_ ; } <nl> - <nl> - Conv2DTester & InputHeight ( int32_t input_height ) { <nl> - EXPECT_GT ( input_height , 0 ) ; <nl> - input_height_ = input_height ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t InputHeight ( ) const { return input_height_ ; } <nl> - <nl> - Conv2DTester & InputWidth ( int32_t input_width ) { <nl> - EXPECT_GT ( input_width , 0 ) ; <nl> - input_width_ = input_width ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t InputWidth ( ) const { return input_width_ ; } <nl> - <nl> - int32_t OutputWidth ( ) const { <nl> - if ( SamePadding ( ) ) { <nl> - return ( InputWidth ( ) - 1 ) / StrideWidth ( ) + 1 ; <nl> - } else { <nl> - return ( InputWidth ( ) - ( KernelWidth ( ) - 1 ) * DilationWidth ( ) - 1 ) / <nl> - StrideWidth ( ) + <nl> - 1 ; <nl> - } <nl> - } <nl> - <nl> - int32_t OutputHeight ( ) const { <nl> - if ( SamePadding ( ) ) { <nl> - return ( InputHeight ( ) - 1 ) / StrideHeight ( ) + 1 ; <nl> - } else { <nl> - return ( InputHeight ( ) - ( KernelHeight ( ) - 1 ) * DilationHeight ( ) - 1 ) / <nl> - StrideHeight ( ) + <nl> - 1 ; <nl> - } <nl> - } <nl> - <nl> - Conv2DTester & KernelHeight ( int32_t kernel_height ) { <nl> - EXPECT_GT ( kernel_height , 0 ) ; <nl> - kernel_height_ = kernel_height ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t KernelHeight ( ) const { return kernel_height_ ; } <nl> - <nl> - Conv2DTester & KernelWidth ( int32_t kernel_width ) { <nl> - EXPECT_GT ( kernel_width , 0 ) ; <nl> - kernel_width_ = kernel_width ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t KernelWidth ( ) const { return kernel_width_ ; } <nl> - <nl> - Conv2DTester & StrideHeight ( int32_t stride_height ) { <nl> - EXPECT_GT ( stride_height , 0 ) ; <nl> - stride_height_ = stride_height ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t StrideHeight ( ) const { return stride_height_ ; } <nl> - <nl> - Conv2DTester & StrideWidth ( int32_t stride_width ) { <nl> - EXPECT_GT ( stride_width , 0 ) ; <nl> - stride_width_ = stride_width ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t StrideWidth ( ) const { return stride_width_ ; } <nl> - <nl> - Conv2DTester & DilationHeight ( int32_t dilation_height ) { <nl> - EXPECT_GT ( dilation_height , 0 ) ; <nl> - dilation_height_ = dilation_height ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t DilationHeight ( ) const { return dilation_height_ ; } <nl> - <nl> - Conv2DTester & DilationWidth ( int32_t dilation_width ) { <nl> - EXPECT_GT ( dilation_width , 0 ) ; <nl> - dilation_width_ = dilation_width ; <nl> - return * this ; <nl> - } <nl> - <nl> - int32_t DilationWidth ( ) const { return dilation_width_ ; } <nl> - <nl> - inline Conv2DTester & FP16Weights ( ) { <nl> - fp16_weights_ = true ; <nl> - return * this ; <nl> - } <nl> - <nl> - inline bool FP16Weights ( ) const { return fp16_weights_ ; } <nl> - <nl> - Conv2DTester & SamePadding ( bool same_padding ) { <nl> - same_padding_ = same_padding ; <nl> - return * this ; <nl> - } <nl> - <nl> - bool SamePadding ( ) const { return same_padding_ ; } <nl> - <nl> - void Test ( TfLiteDelegate * delegate ) const { <nl> - std : : vector < char > buffer = CreateTfLiteModel ( ) ; <nl> - const Model * model = GetModel ( buffer . data ( ) ) ; <nl> - <nl> - std : : unique_ptr < Interpreter > delegate_interpreter ; <nl> - ASSERT_EQ ( <nl> - InterpreterBuilder ( model , : : tflite : : ops : : builtin : : BuiltinOpResolver ( ) ) ( <nl> - & delegate_interpreter ) , <nl> - kTfLiteOk ) ; <nl> - std : : unique_ptr < Interpreter > default_interpreter ; <nl> - ASSERT_EQ ( <nl> - InterpreterBuilder ( model , : : tflite : : ops : : builtin : : BuiltinOpResolver ( ) ) ( <nl> - & default_interpreter ) , <nl> - kTfLiteOk ) ; <nl> - <nl> - ASSERT_TRUE ( delegate_interpreter ) ; <nl> - ASSERT_TRUE ( default_interpreter ) ; <nl> - <nl> - ASSERT_EQ ( delegate_interpreter - > inputs ( ) . size ( ) , 1 ) ; <nl> - ASSERT_EQ ( default_interpreter - > inputs ( ) . size ( ) , 1 ) ; <nl> - <nl> - ASSERT_EQ ( delegate_interpreter - > outputs ( ) . size ( ) , 1 ) ; <nl> - ASSERT_EQ ( default_interpreter - > outputs ( ) . size ( ) , 1 ) ; <nl> - <nl> - ASSERT_EQ ( delegate_interpreter - > AllocateTensors ( ) , kTfLiteOk ) ; <nl> - ASSERT_EQ ( default_interpreter - > AllocateTensors ( ) , kTfLiteOk ) ; <nl> - <nl> - ASSERT_EQ ( delegate_interpreter - > ModifyGraphWithDelegate ( delegate ) , <nl> - kTfLiteOk ) ; <nl> - <nl> - std : : random_device random_device ; <nl> - auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> - auto f32rng = std : : bind ( std : : uniform_real_distribution < float > ( ) , rng ) ; <nl> - <nl> - float * default_input_data = default_interpreter - > typed_tensor < float > ( <nl> - default_interpreter - > inputs ( ) [ 0 ] ) ; <nl> - std : : generate ( default_input_data , <nl> - default_input_data + BatchSize ( ) * InputHeight ( ) * <nl> - InputWidth ( ) * InputChannels ( ) , <nl> - std : : ref ( f32rng ) ) ; <nl> - <nl> - float * xnnpack_input_data = delegate_interpreter - > typed_tensor < float > ( <nl> - delegate_interpreter - > inputs ( ) [ 0 ] ) ; <nl> - std : : copy ( default_input_data , <nl> - default_input_data + <nl> - BatchSize ( ) * InputHeight ( ) * InputWidth ( ) * InputChannels ( ) , <nl> - xnnpack_input_data ) ; <nl> - <nl> - default_interpreter - > Invoke ( ) ; <nl> - delegate_interpreter - > Invoke ( ) ; <nl> - <nl> - float * default_output_data = default_interpreter - > typed_tensor < float > ( <nl> - default_interpreter - > outputs ( ) [ 0 ] ) ; <nl> - float * xnnpack_output_data = delegate_interpreter - > typed_tensor < float > ( <nl> - delegate_interpreter - > outputs ( ) [ 0 ] ) ; <nl> - <nl> - for ( size_t i = 0 ; <nl> - i < BatchSize ( ) * OutputHeight ( ) * OutputWidth ( ) * OutputChannels ( ) ; <nl> - i + + ) { <nl> - ASSERT_NEAR ( default_output_data [ i ] , xnnpack_output_data [ i ] , <nl> - std : : numeric_limits < float > : : epsilon ( ) * <nl> - std : : max ( std : : abs ( default_output_data [ i ] ) * 25 . 0f , 1 . 0f ) ) ; <nl> - } <nl> - } <nl> - <nl> - private : <nl> - std : : vector < char > CreateTfLiteModel ( ) const { <nl> - std : : random_device random_device ; <nl> - auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> - auto f32rng = std : : bind ( std : : uniform_real_distribution < float > ( ) , rng ) ; <nl> - <nl> - flatbuffers : : FlatBufferBuilder builder ; <nl> - std : : vector < flatbuffers : : Offset < OperatorCode > > operator_codes { <nl> - { CreateOperatorCode ( builder , BuiltinOperator_CONV_2D , 0 ) } } ; <nl> - std : : vector < flatbuffers : : Offset < tflite : : Operator > > operators ; <nl> - std : : vector < flatbuffers : : Offset < tflite : : Buffer > > buffers { <nl> - { CreateBuffer ( builder , builder . CreateVector ( { } ) ) } } ; <nl> - <nl> - if ( FP16Weights ( ) ) { <nl> - operator_codes . emplace_back ( <nl> - CreateOperatorCode ( builder , BuiltinOperator_DEQUANTIZE ) ) ; <nl> - <nl> - auto f16rng = std : : bind ( fp16_ieee_from_fp32_value , f32rng ) ; <nl> - <nl> - std : : vector < uint16_t > filter_data ( OutputChannels ( ) * KernelHeight ( ) * <nl> - KernelWidth ( ) * InputChannels ( ) ) ; <nl> - std : : vector < uint16_t > bias_data ( OutputChannels ( ) ) ; <nl> - <nl> - std : : generate ( filter_data . begin ( ) , filter_data . end ( ) , f16rng ) ; <nl> - std : : generate ( bias_data . begin ( ) , bias_data . end ( ) , f16rng ) ; <nl> - <nl> - buffers . emplace_back ( CreateBuffer ( <nl> - builder , builder . CreateVector ( <nl> - reinterpret_cast < const uint8_t * > ( filter_data . data ( ) ) , <nl> - sizeof ( uint16_t ) * filter_data . size ( ) ) ) ) ; <nl> - buffers . emplace_back ( CreateBuffer ( <nl> - builder , builder . CreateVector ( <nl> - reinterpret_cast < const uint8_t * > ( bias_data . data ( ) ) , <nl> - sizeof ( uint16_t ) * bias_data . size ( ) ) ) ) ; <nl> - <nl> - const std : : array < int32_t , 1 > dequantize_filter_inputs { { 0 } } ; <nl> - const std : : array < int32_t , 1 > dequantize_filter_outputs { { 3 } } ; <nl> - operators . emplace_back ( CreateOperator ( <nl> - builder , / * opcode_index = * / 1 , <nl> - builder . CreateVector < int32_t > ( dequantize_filter_inputs . data ( ) , <nl> - dequantize_filter_inputs . size ( ) ) , <nl> - builder . CreateVector < int32_t > ( dequantize_filter_outputs . data ( ) , <nl> - dequantize_filter_outputs . size ( ) ) ) ) ; <nl> - const std : : array < int32_t , 1 > dequantize_bias_inputs { { 1 } } ; <nl> - const std : : array < int32_t , 1 > dequantize_bias_outputs { { 4 } } ; <nl> - operators . emplace_back ( CreateOperator ( <nl> - builder , / * opcode_index = * / 1 , <nl> - builder . CreateVector < int32_t > ( dequantize_bias_inputs . data ( ) , <nl> - dequantize_bias_inputs . size ( ) ) , <nl> - builder . CreateVector < int32_t > ( dequantize_bias_outputs . data ( ) , <nl> - dequantize_bias_outputs . size ( ) ) ) ) ; <nl> - } else { <nl> - std : : vector < float > filter_data ( OutputChannels ( ) * KernelHeight ( ) * <nl> - KernelWidth ( ) * InputChannels ( ) ) ; <nl> - std : : vector < float > bias_data ( OutputChannels ( ) ) ; <nl> - <nl> - std : : generate ( filter_data . begin ( ) , filter_data . end ( ) , f32rng ) ; <nl> - std : : generate ( bias_data . begin ( ) , bias_data . end ( ) , f32rng ) ; <nl> - <nl> - buffers . emplace_back ( CreateBuffer ( <nl> - builder , builder . CreateVector ( <nl> - reinterpret_cast < const uint8_t * > ( filter_data . data ( ) ) , <nl> - sizeof ( float ) * filter_data . size ( ) ) ) ) ; <nl> - buffers . emplace_back ( CreateBuffer ( <nl> - builder , builder . CreateVector ( <nl> - reinterpret_cast < const uint8_t * > ( bias_data . data ( ) ) , <nl> - sizeof ( float ) * bias_data . size ( ) ) ) ) ; <nl> - } <nl> - <nl> - const std : : array < int32_t , 4 > input_shape { <nl> - { BatchSize ( ) , InputHeight ( ) , InputWidth ( ) , InputChannels ( ) } } ; <nl> - const std : : array < int32_t , 4 > output_shape { <nl> - { BatchSize ( ) , OutputHeight ( ) , OutputWidth ( ) , OutputChannels ( ) } } ; <nl> - const std : : array < int32_t , 4 > filter_shape { <nl> - { OutputChannels ( ) , KernelHeight ( ) , KernelWidth ( ) , InputChannels ( ) } } ; <nl> - const std : : array < int32_t , 1 > bias_shape { { OutputChannels ( ) } } ; <nl> - <nl> - std : : vector < flatbuffers : : Offset < tflite : : Tensor > > tensors ; <nl> - if ( FP16Weights ( ) ) { <nl> - tensors . emplace_back ( <nl> - CreateTensor ( builder , <nl> - builder . CreateVector < int32_t > ( filter_shape . data ( ) , <nl> - filter_shape . size ( ) ) , <nl> - TensorType_FLOAT16 , / * buffer = * / 1 ) ) ; <nl> - tensors . emplace_back ( CreateTensor ( <nl> - builder , <nl> - builder . CreateVector < int32_t > ( bias_shape . data ( ) , bias_shape . size ( ) ) , <nl> - TensorType_FLOAT16 , / * buffer = * / 2 ) ) ; <nl> - } <nl> - tensors . emplace_back ( CreateTensor ( <nl> - builder , <nl> - builder . CreateVector < int32_t > ( input_shape . data ( ) , input_shape . size ( ) ) , <nl> - TensorType_FLOAT32 ) ) ; <nl> - tensors . emplace_back ( CreateTensor ( <nl> - builder , <nl> - builder . CreateVector < int32_t > ( filter_shape . data ( ) , filter_shape . size ( ) ) , <nl> - TensorType_FLOAT32 , / * buffer = * / FP16Weights ( ) ? 0 : 1 ) ) ; <nl> - tensors . emplace_back ( CreateTensor ( <nl> - builder , <nl> - builder . CreateVector < int32_t > ( bias_shape . data ( ) , bias_shape . size ( ) ) , <nl> - TensorType_FLOAT32 , / * buffer = * / FP16Weights ( ) ? 0 : 2 ) ) ; <nl> - tensors . emplace_back ( CreateTensor ( <nl> - builder , <nl> - builder . CreateVector < int32_t > ( output_shape . data ( ) , output_shape . size ( ) ) , <nl> - TensorType_FLOAT32 ) ) ; <nl> - <nl> - const std : : array < int32_t , 3 > op_inputs { <nl> - { static_cast < int > ( tensors . size ( ) ) - 4 , <nl> - static_cast < int > ( tensors . size ( ) ) - 3 , <nl> - static_cast < int > ( tensors . size ( ) ) - 2 } } ; <nl> - const std : : array < int32_t , 1 > op_outputs { <nl> - { static_cast < int > ( tensors . size ( ) ) - 1 } } ; <nl> - <nl> - flatbuffers : : Offset < Conv2DOptions > conv2d_options = CreateConv2DOptions ( <nl> - builder , SamePadding ( ) ? tflite : : Padding_SAME : tflite : : Padding_VALID , <nl> - StrideWidth ( ) , StrideHeight ( ) , ActivationFunctionType_NONE , <nl> - DilationWidth ( ) , DilationHeight ( ) ) ; <nl> - <nl> - operators . emplace_back ( CreateOperator ( <nl> - builder , / * opcode_index = * / 0 , <nl> - builder . CreateVector < int32_t > ( op_inputs . data ( ) , op_inputs . size ( ) ) , <nl> - builder . CreateVector < int32_t > ( op_outputs . data ( ) , op_outputs . size ( ) ) , <nl> - BuiltinOptions_Conv2DOptions , conv2d_options . Union ( ) ) ) ; <nl> - <nl> - const std : : array < int32_t , 1 > subgraph_inputs { <nl> - { static_cast < int > ( tensors . size ( ) ) - 4 } } ; <nl> - const std : : array < int32_t , 1 > subgraph_outputs { <nl> - { static_cast < int > ( tensors . size ( ) ) - 1 } } ; <nl> - flatbuffers : : Offset < SubGraph > subgraph = CreateSubGraph ( <nl> - builder , builder . CreateVector ( tensors . data ( ) , tensors . size ( ) ) , <nl> - builder . CreateVector < int32_t > ( subgraph_inputs . data ( ) , <nl> - subgraph_inputs . size ( ) ) , <nl> - builder . CreateVector < int32_t > ( subgraph_outputs . data ( ) , <nl> - subgraph_outputs . size ( ) ) , <nl> - builder . CreateVector ( operators . data ( ) , operators . size ( ) ) ) ; <nl> - <nl> - flatbuffers : : Offset < flatbuffers : : String > description = <nl> - builder . CreateString ( " Conv2D model " ) ; <nl> - <nl> - flatbuffers : : Offset < Model > model_buffer = CreateModel ( <nl> - builder , TFLITE_SCHEMA_VERSION , <nl> - builder . CreateVector ( operator_codes . data ( ) , operator_codes . size ( ) ) , <nl> - builder . CreateVector ( & subgraph , 1 ) , description , <nl> - builder . CreateVector ( buffers . data ( ) , buffers . size ( ) ) ) ; <nl> - <nl> - builder . Finish ( model_buffer ) ; <nl> - <nl> - return std : : vector < char > ( builder . GetBufferPointer ( ) , <nl> - builder . GetBufferPointer ( ) + builder . GetSize ( ) ) ; <nl> - } <nl> - <nl> - int32_t batch_size_ = 1 ; <nl> - int32_t input_channels_ = 1 ; <nl> - int32_t output_channels_ = 1 ; <nl> - int32_t input_height_ = 1 ; <nl> - int32_t input_width_ = 1 ; <nl> - int32_t kernel_height_ = 1 ; <nl> - int32_t kernel_width_ = 1 ; <nl> - int32_t stride_height_ = 1 ; <nl> - int32_t stride_width_ = 1 ; <nl> - int32_t dilation_height_ = 1 ; <nl> - int32_t dilation_width_ = 1 ; <nl> - bool fp16_weights_ = false ; <nl> - bool same_padding_ = true ; <nl> - } ; <nl> - <nl> - } / / namespace <nl> - <nl> - TEST ( Conv2D , Pointwise ) { <nl> + TEST ( Conv2D , 1x1 ) { <nl> std : : unique_ptr < TfLiteDelegate , decltype ( & TfLiteXNNPackDelegateDelete ) > <nl> xnnpack_delegate ( TfLiteXNNPackDelegateCreate ( nullptr ) , <nl> TfLiteXNNPackDelegateDelete ) ; <nl> <nl> std : : random_device random_device ; <nl> auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> auto input_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 5 , 25 ) , std : : ref ( rng ) ) ; <nl> auto channel_rng = <nl> - std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 16 ) , std : : ref ( rng ) ) ; <nl> <nl> Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> . InputHeight ( input_rng ( ) ) <nl> . InputWidth ( input_rng ( ) ) <nl> . InputChannels ( channel_rng ( ) ) <nl> . OutputChannels ( channel_rng ( ) ) <nl> . KernelHeight ( 1 ) <nl> . KernelWidth ( 1 ) <nl> + . ValidPadding ( ) <nl> + . Test ( xnnpack_delegate . get ( ) ) ; <nl> + } <nl> + <nl> + TEST ( Conv2D , 3x3 ) { <nl> + std : : unique_ptr < TfLiteDelegate , decltype ( & TfLiteXNNPackDelegateDelete ) > <nl> + xnnpack_delegate ( TfLiteXNNPackDelegateCreate ( nullptr ) , <nl> + TfLiteXNNPackDelegateDelete ) ; <nl> + <nl> + std : : random_device random_device ; <nl> + auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> + auto input_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 5 , 25 ) , std : : ref ( rng ) ) ; <nl> + auto channel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 16 ) , std : : ref ( rng ) ) ; <nl> + <nl> + Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> + . InputHeight ( input_rng ( ) ) <nl> + . InputWidth ( input_rng ( ) ) <nl> + . InputChannels ( channel_rng ( ) ) <nl> + . OutputChannels ( channel_rng ( ) ) <nl> + . KernelHeight ( 3 ) <nl> + . KernelWidth ( 3 ) <nl> + . SamePadding ( ) <nl> + . Test ( xnnpack_delegate . get ( ) ) ; <nl> + } <nl> + <nl> + TEST ( Conv2D , 3x3Stride2 ) { <nl> + std : : unique_ptr < TfLiteDelegate , decltype ( & TfLiteXNNPackDelegateDelete ) > <nl> + xnnpack_delegate ( TfLiteXNNPackDelegateCreate ( nullptr ) , <nl> + TfLiteXNNPackDelegateDelete ) ; <nl> + <nl> + std : : random_device random_device ; <nl> + auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> + auto input_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 5 , 25 ) , std : : ref ( rng ) ) ; <nl> + auto channel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 16 ) , std : : ref ( rng ) ) ; <nl> + <nl> + Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> + . InputHeight ( input_rng ( ) ) <nl> + . InputWidth ( input_rng ( ) ) <nl> + . InputChannels ( channel_rng ( ) ) <nl> + . OutputChannels ( channel_rng ( ) ) <nl> + . KernelHeight ( 3 ) <nl> + . KernelWidth ( 3 ) <nl> + . StrideHeight ( 2 ) <nl> + . StrideWidth ( 2 ) <nl> + . SamePadding ( ) <nl> . Test ( xnnpack_delegate . get ( ) ) ; <nl> } <nl> <nl> TEST ( Conv2D , SmallKernelWithSamePadding ) { <nl> <nl> std : : random_device random_device ; <nl> auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> auto input_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> auto kernel_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 7 ) , std : : ref ( rng ) ) ; <nl> auto channel_rng = <nl> - std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 16 ) , std : : ref ( rng ) ) ; <nl> <nl> Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> . InputHeight ( input_rng ( ) ) <nl> . InputWidth ( input_rng ( ) ) <nl> . InputChannels ( channel_rng ( ) ) <nl> . OutputChannels ( channel_rng ( ) ) <nl> . KernelHeight ( kernel_rng ( ) ) <nl> . KernelWidth ( kernel_rng ( ) ) <nl> - . SamePadding ( true ) <nl> + . SamePadding ( ) <nl> . Test ( xnnpack_delegate . get ( ) ) ; <nl> } <nl> <nl> TEST ( Conv2D , SmallKernelWithValidPadding ) { <nl> <nl> std : : random_device random_device ; <nl> auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> auto input_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> auto kernel_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 7 ) , std : : ref ( rng ) ) ; <nl> auto channel_rng = <nl> - std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 16 ) , std : : ref ( rng ) ) ; <nl> <nl> Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> . InputHeight ( input_rng ( ) ) <nl> . InputWidth ( input_rng ( ) ) <nl> . InputChannels ( channel_rng ( ) ) <nl> . OutputChannels ( channel_rng ( ) ) <nl> . KernelHeight ( kernel_rng ( ) ) <nl> . KernelWidth ( kernel_rng ( ) ) <nl> - . SamePadding ( false ) <nl> + . ValidPadding ( ) <nl> . Test ( xnnpack_delegate . get ( ) ) ; <nl> } <nl> <nl> TEST ( Conv2D , StrideWithSamePadding ) { <nl> <nl> std : : random_device random_device ; <nl> auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> auto input_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> auto kernel_rng = <nl> TEST ( Conv2D , StrideWithSamePadding ) { <nl> auto stride_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 3 ) , std : : ref ( rng ) ) ; <nl> auto channel_rng = <nl> - std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 16 ) , std : : ref ( rng ) ) ; <nl> <nl> Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> . InputHeight ( input_rng ( ) ) <nl> . InputWidth ( input_rng ( ) ) <nl> . InputChannels ( channel_rng ( ) ) <nl> TEST ( Conv2D , StrideWithSamePadding ) { <nl> . KernelWidth ( kernel_rng ( ) ) <nl> . StrideHeight ( stride_rng ( ) ) <nl> . StrideWidth ( stride_rng ( ) ) <nl> - . SamePadding ( true ) <nl> + . SamePadding ( ) <nl> . Test ( xnnpack_delegate . get ( ) ) ; <nl> } <nl> <nl> TEST ( Conv2D , StrideWithValidPadding ) { <nl> <nl> std : : random_device random_device ; <nl> auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> auto input_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> auto kernel_rng = <nl> TEST ( Conv2D , StrideWithValidPadding ) { <nl> auto stride_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 3 ) , std : : ref ( rng ) ) ; <nl> auto channel_rng = <nl> - std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 16 ) , std : : ref ( rng ) ) ; <nl> <nl> Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> . InputHeight ( input_rng ( ) ) <nl> . InputWidth ( input_rng ( ) ) <nl> . InputChannels ( channel_rng ( ) ) <nl> TEST ( Conv2D , StrideWithValidPadding ) { <nl> . KernelWidth ( kernel_rng ( ) ) <nl> . StrideHeight ( stride_rng ( ) ) <nl> . StrideWidth ( stride_rng ( ) ) <nl> - . SamePadding ( false ) <nl> + . ValidPadding ( ) <nl> . Test ( xnnpack_delegate . get ( ) ) ; <nl> } <nl> <nl> TEST ( Conv2D , DilationWithSamePadding ) { <nl> <nl> std : : random_device random_device ; <nl> auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> auto input_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> auto kernel_rng = <nl> TEST ( Conv2D , DilationWithSamePadding ) { <nl> auto dilation_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 3 ) , std : : ref ( rng ) ) ; <nl> auto channel_rng = <nl> - std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 16 ) , std : : ref ( rng ) ) ; <nl> <nl> Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> . InputHeight ( input_rng ( ) ) <nl> . InputWidth ( input_rng ( ) ) <nl> . InputChannels ( channel_rng ( ) ) <nl> TEST ( Conv2D , DilationWithSamePadding ) { <nl> . KernelWidth ( kernel_rng ( ) ) <nl> . DilationHeight ( dilation_rng ( ) ) <nl> . DilationWidth ( dilation_rng ( ) ) <nl> - . SamePadding ( true ) <nl> + . SamePadding ( ) <nl> . Test ( xnnpack_delegate . get ( ) ) ; <nl> } <nl> <nl> TEST ( Conv2D , DilationWithValidPadding ) { <nl> <nl> std : : random_device random_device ; <nl> auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> auto input_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> auto kernel_rng = <nl> TEST ( Conv2D , DilationWithValidPadding ) { <nl> auto dilation_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 3 ) , std : : ref ( rng ) ) ; <nl> auto channel_rng = <nl> - std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 16 ) , std : : ref ( rng ) ) ; <nl> <nl> Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> . InputHeight ( input_rng ( ) ) <nl> . InputWidth ( input_rng ( ) ) <nl> . InputChannels ( channel_rng ( ) ) <nl> TEST ( Conv2D , DilationWithValidPadding ) { <nl> . KernelWidth ( kernel_rng ( ) ) <nl> . DilationHeight ( dilation_rng ( ) ) <nl> . DilationWidth ( dilation_rng ( ) ) <nl> - . SamePadding ( false ) <nl> + . ValidPadding ( ) <nl> . Test ( xnnpack_delegate . get ( ) ) ; <nl> } <nl> <nl> TEST ( Conv2D , FP16Weights ) { <nl> <nl> std : : random_device random_device ; <nl> auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> auto input_rng = <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> auto kernel_rng = <nl> TEST ( Conv2D , FP16Weights ) { <nl> std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> <nl> Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> . InputHeight ( input_rng ( ) ) <nl> . InputWidth ( input_rng ( ) ) <nl> . InputChannels ( channel_rng ( ) ) <nl> TEST ( Conv2D , FP16Weights ) { <nl> . KernelWidth ( kernel_rng ( ) ) <nl> . StrideHeight ( stride_rng ( ) ) <nl> . StrideWidth ( stride_rng ( ) ) <nl> - . SamePadding ( true ) <nl> . FP16Weights ( ) <nl> . Test ( xnnpack_delegate . get ( ) ) ; <nl> } <nl> <nl> + TEST ( Conv2D , ReluActivation ) { <nl> + std : : unique_ptr < TfLiteDelegate , decltype ( & TfLiteXNNPackDelegateDelete ) > <nl> + xnnpack_delegate ( TfLiteXNNPackDelegateCreate ( nullptr ) , <nl> + TfLiteXNNPackDelegateDelete ) ; <nl> + <nl> + std : : random_device random_device ; <nl> + auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> + auto input_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> + auto kernel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 3 , 5 ) , std : : ref ( rng ) ) ; <nl> + auto stride_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 3 ) , std : : ref ( rng ) ) ; <nl> + auto channel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + <nl> + Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> + . InputHeight ( input_rng ( ) ) <nl> + . InputWidth ( input_rng ( ) ) <nl> + . InputChannels ( channel_rng ( ) ) <nl> + . OutputChannels ( channel_rng ( ) ) <nl> + . KernelHeight ( kernel_rng ( ) ) <nl> + . KernelWidth ( kernel_rng ( ) ) <nl> + . StrideHeight ( stride_rng ( ) ) <nl> + . StrideWidth ( stride_rng ( ) ) <nl> + . ReluActivation ( ) <nl> + . Test ( xnnpack_delegate . get ( ) ) ; <nl> + } <nl> + <nl> + TEST ( Conv2D , Relu6Activation ) { <nl> + std : : unique_ptr < TfLiteDelegate , decltype ( & TfLiteXNNPackDelegateDelete ) > <nl> + xnnpack_delegate ( TfLiteXNNPackDelegateCreate ( nullptr ) , <nl> + TfLiteXNNPackDelegateDelete ) ; <nl> + <nl> + std : : random_device random_device ; <nl> + auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> + auto input_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> + auto kernel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 3 , 5 ) , std : : ref ( rng ) ) ; <nl> + auto stride_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 3 ) , std : : ref ( rng ) ) ; <nl> + auto channel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + <nl> + Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> + . InputHeight ( input_rng ( ) ) <nl> + . InputWidth ( input_rng ( ) ) <nl> + . InputChannels ( channel_rng ( ) ) <nl> + . OutputChannels ( channel_rng ( ) ) <nl> + . KernelHeight ( kernel_rng ( ) ) <nl> + . KernelWidth ( kernel_rng ( ) ) <nl> + . StrideHeight ( stride_rng ( ) ) <nl> + . StrideWidth ( stride_rng ( ) ) <nl> + . Relu6Activation ( ) <nl> + . Test ( xnnpack_delegate . get ( ) ) ; <nl> + } <nl> + <nl> + TEST ( Conv2D , ReluMinus1To1Activation ) { <nl> + std : : unique_ptr < TfLiteDelegate , decltype ( & TfLiteXNNPackDelegateDelete ) > <nl> + xnnpack_delegate ( TfLiteXNNPackDelegateCreate ( nullptr ) , <nl> + TfLiteXNNPackDelegateDelete ) ; <nl> + <nl> + std : : random_device random_device ; <nl> + auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> + auto input_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> + auto kernel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 3 , 5 ) , std : : ref ( rng ) ) ; <nl> + auto stride_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 3 ) , std : : ref ( rng ) ) ; <nl> + auto channel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + <nl> + Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> + . InputHeight ( input_rng ( ) ) <nl> + . InputWidth ( input_rng ( ) ) <nl> + . InputChannels ( channel_rng ( ) ) <nl> + . OutputChannels ( channel_rng ( ) ) <nl> + . KernelHeight ( kernel_rng ( ) ) <nl> + . KernelWidth ( kernel_rng ( ) ) <nl> + . StrideHeight ( stride_rng ( ) ) <nl> + . StrideWidth ( stride_rng ( ) ) <nl> + . ReluMinus1To1Activation ( ) <nl> + . Test ( xnnpack_delegate . get ( ) ) ; <nl> + } <nl> + <nl> + TEST ( Conv2D , DISABLED_TanhActivation ) { <nl> + std : : unique_ptr < TfLiteDelegate , decltype ( & TfLiteXNNPackDelegateDelete ) > <nl> + xnnpack_delegate ( TfLiteXNNPackDelegateCreate ( nullptr ) , <nl> + TfLiteXNNPackDelegateDelete ) ; <nl> + <nl> + std : : random_device random_device ; <nl> + auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> + auto input_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> + auto kernel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 3 , 5 ) , std : : ref ( rng ) ) ; <nl> + auto stride_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 3 ) , std : : ref ( rng ) ) ; <nl> + auto channel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + <nl> + Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> + . InputHeight ( input_rng ( ) ) <nl> + . InputWidth ( input_rng ( ) ) <nl> + . InputChannels ( channel_rng ( ) ) <nl> + . OutputChannels ( channel_rng ( ) ) <nl> + . KernelHeight ( kernel_rng ( ) ) <nl> + . KernelWidth ( kernel_rng ( ) ) <nl> + . StrideHeight ( stride_rng ( ) ) <nl> + . StrideWidth ( stride_rng ( ) ) <nl> + . TanhActivation ( ) <nl> + . Test ( xnnpack_delegate . get ( ) ) ; <nl> + } <nl> + <nl> + TEST ( Conv2D , DISABLED_SignBitActivation ) { <nl> + std : : unique_ptr < TfLiteDelegate , decltype ( & TfLiteXNNPackDelegateDelete ) > <nl> + xnnpack_delegate ( TfLiteXNNPackDelegateCreate ( nullptr ) , <nl> + TfLiteXNNPackDelegateDelete ) ; <nl> + <nl> + std : : random_device random_device ; <nl> + auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> + auto input_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> + auto kernel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 3 , 5 ) , std : : ref ( rng ) ) ; <nl> + auto stride_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 3 ) , std : : ref ( rng ) ) ; <nl> + auto channel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + <nl> + Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> + . InputHeight ( input_rng ( ) ) <nl> + . InputWidth ( input_rng ( ) ) <nl> + . InputChannels ( channel_rng ( ) ) <nl> + . OutputChannels ( channel_rng ( ) ) <nl> + . KernelHeight ( kernel_rng ( ) ) <nl> + . KernelWidth ( kernel_rng ( ) ) <nl> + . StrideHeight ( stride_rng ( ) ) <nl> + . StrideWidth ( stride_rng ( ) ) <nl> + . SignBitActivation ( ) <nl> + . Test ( xnnpack_delegate . get ( ) ) ; <nl> + } <nl> + <nl> + TEST ( Conv2D , MultiThreading ) { <nl> + TfLiteXNNPackDelegateOptions delegate_options = <nl> + TfLiteXNNPackDelegateOptionsDefault ( ) ; <nl> + delegate_options . num_threads = 2 ; <nl> + std : : unique_ptr < TfLiteDelegate , decltype ( & TfLiteXNNPackDelegateDelete ) > <nl> + xnnpack_delegate ( TfLiteXNNPackDelegateCreate ( & delegate_options ) , <nl> + TfLiteXNNPackDelegateDelete ) ; <nl> + <nl> + std : : random_device random_device ; <nl> + auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto batch_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 4 ) , std : : ref ( rng ) ) ; <nl> + auto input_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 10 , 25 ) , std : : ref ( rng ) ) ; <nl> + auto kernel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 3 , 5 ) , std : : ref ( rng ) ) ; <nl> + auto stride_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 2 , 3 ) , std : : ref ( rng ) ) ; <nl> + auto channel_rng = <nl> + std : : bind ( std : : uniform_int_distribution < int32_t > ( 1 , 16 ) , std : : ref ( rng ) ) ; <nl> + <nl> + Conv2DTester ( ) <nl> + . BatchSize ( batch_rng ( ) ) <nl> + . InputHeight ( input_rng ( ) ) <nl> + . InputWidth ( input_rng ( ) ) <nl> + . InputChannels ( channel_rng ( ) ) <nl> + . OutputChannels ( channel_rng ( ) ) <nl> + . KernelHeight ( kernel_rng ( ) ) <nl> + . KernelWidth ( kernel_rng ( ) ) <nl> + . StrideHeight ( stride_rng ( ) ) <nl> + . StrideWidth ( stride_rng ( ) ) <nl> + . Test ( xnnpack_delegate . get ( ) ) ; <nl> + } <nl> + <nl> } / / namespace xnnpack <nl> } / / namespace tflite <nl> new file mode 100644 <nl> index 0000000000000 . . 476889bde5195 <nl> mmm / dev / null <nl> ppp b / tensorflow / lite / delegates / xnnpack / conv_2d_tester . cc <nl> <nl> + / * Copyright 2020 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / lite / delegates / xnnpack / conv_2d_tester . h " <nl> + <nl> + # include < array > <nl> + # include < cstdint > <nl> + # include < functional > <nl> + # include < random > <nl> + # include < vector > <nl> + <nl> + # include < gtest / gtest . h > <nl> + # include < fp16 . h > <nl> + # include " flatbuffers / flatbuffers . h " / / from @ flatbuffers <nl> + # include " tensorflow / lite / interpreter . h " <nl> + # include " tensorflow / lite / kernels / register . h " <nl> + # include " tensorflow / lite / model . h " <nl> + # include " tensorflow / lite / schema / schema_generated . h " <nl> + # include " tensorflow / lite / version . h " <nl> + <nl> + namespace tflite { <nl> + namespace xnnpack { <nl> + <nl> + void Conv2DTester : : Test ( TfLiteDelegate * delegate ) const { <nl> + std : : vector < char > buffer = CreateTfLiteModel ( ) ; <nl> + const Model * model = GetModel ( buffer . data ( ) ) ; <nl> + <nl> + std : : unique_ptr < Interpreter > delegate_interpreter ; <nl> + ASSERT_EQ ( <nl> + InterpreterBuilder ( model , : : tflite : : ops : : builtin : : BuiltinOpResolver ( ) ) ( <nl> + & delegate_interpreter ) , <nl> + kTfLiteOk ) ; <nl> + std : : unique_ptr < Interpreter > default_interpreter ; <nl> + ASSERT_EQ ( <nl> + InterpreterBuilder ( model , : : tflite : : ops : : builtin : : BuiltinOpResolver ( ) ) ( <nl> + & default_interpreter ) , <nl> + kTfLiteOk ) ; <nl> + <nl> + ASSERT_TRUE ( delegate_interpreter ) ; <nl> + ASSERT_TRUE ( default_interpreter ) ; <nl> + <nl> + ASSERT_EQ ( delegate_interpreter - > inputs ( ) . size ( ) , 1 ) ; <nl> + ASSERT_EQ ( default_interpreter - > inputs ( ) . size ( ) , 1 ) ; <nl> + <nl> + ASSERT_EQ ( delegate_interpreter - > outputs ( ) . size ( ) , 1 ) ; <nl> + ASSERT_EQ ( default_interpreter - > outputs ( ) . size ( ) , 1 ) ; <nl> + <nl> + ASSERT_EQ ( delegate_interpreter - > AllocateTensors ( ) , kTfLiteOk ) ; <nl> + ASSERT_EQ ( default_interpreter - > AllocateTensors ( ) , kTfLiteOk ) ; <nl> + <nl> + ASSERT_EQ ( delegate_interpreter - > ModifyGraphWithDelegate ( delegate ) , kTfLiteOk ) ; <nl> + <nl> + std : : random_device random_device ; <nl> + auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto input_rng = <nl> + std : : bind ( std : : uniform_real_distribution < float > ( ) , std : : ref ( rng ) ) ; <nl> + float * default_input_data = default_interpreter - > typed_tensor < float > ( <nl> + default_interpreter - > inputs ( ) [ 0 ] ) ; <nl> + std : : generate ( default_input_data , <nl> + default_input_data + BatchSize ( ) * InputHeight ( ) * <nl> + InputWidth ( ) * InputChannels ( ) , <nl> + input_rng ) ; <nl> + <nl> + float * delegate_input_data = delegate_interpreter - > typed_tensor < float > ( <nl> + delegate_interpreter - > inputs ( ) [ 0 ] ) ; <nl> + std : : copy ( default_input_data , <nl> + default_input_data + <nl> + BatchSize ( ) * InputHeight ( ) * InputWidth ( ) * InputChannels ( ) , <nl> + delegate_input_data ) ; <nl> + <nl> + ASSERT_EQ ( default_interpreter - > Invoke ( ) , kTfLiteOk ) ; <nl> + ASSERT_EQ ( delegate_interpreter - > Invoke ( ) , kTfLiteOk ) ; <nl> + <nl> + float * default_output_data = default_interpreter - > typed_tensor < float > ( <nl> + default_interpreter - > outputs ( ) [ 0 ] ) ; <nl> + float * delegate_output_data = delegate_interpreter - > typed_tensor < float > ( <nl> + delegate_interpreter - > outputs ( ) [ 0 ] ) ; <nl> + <nl> + for ( int32_t i = 0 ; i < BatchSize ( ) ; i + + ) { <nl> + for ( int32_t y = 0 ; y < OutputHeight ( ) ; y + + ) { <nl> + for ( int32_t x = 0 ; x < OutputWidth ( ) ; x + + ) { <nl> + for ( int32_t c = 0 ; c < OutputChannels ( ) ; c + + ) { <nl> + const int32_t index = ( ( i * OutputHeight ( ) + y ) * OutputWidth ( ) + x ) * <nl> + OutputChannels ( ) + <nl> + c ; <nl> + ASSERT_NEAR ( default_output_data [ index ] , delegate_output_data [ index ] , <nl> + std : : abs ( default_output_data [ index ] ) * 3 . 0e - 6f ) <nl> + < < " batch " < < i < < " / " < < BatchSize ( ) < < " , y position " < < y <nl> + < < " / " < < OutputHeight ( ) < < " , x position " < < x < < " / " <nl> + < < OutputWidth ( ) < < " , channel " < < c < < " / " <nl> + < < OutputChannels ( ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + std : : vector < char > Conv2DTester : : CreateTfLiteModel ( ) const { <nl> + std : : random_device random_device ; <nl> + auto rng = std : : mt19937 ( random_device ( ) ) ; <nl> + auto range_rng = std : : bind ( <nl> + std : : uniform_real_distribution < float > ( - 25 . 0f , 25 . 0f ) , std : : ref ( rng ) ) ; <nl> + <nl> + flatbuffers : : FlatBufferBuilder builder ; <nl> + std : : vector < flatbuffers : : Offset < OperatorCode > > operator_codes { <nl> + { CreateOperatorCode ( builder , BuiltinOperator_CONV_2D ) } } ; <nl> + std : : vector < flatbuffers : : Offset < tflite : : Operator > > operators ; <nl> + std : : vector < flatbuffers : : Offset < tflite : : Buffer > > buffers { <nl> + { CreateBuffer ( builder , builder . CreateVector ( { } ) ) } } ; <nl> + <nl> + if ( FP16Weights ( ) ) { <nl> + operator_codes . emplace_back ( <nl> + CreateOperatorCode ( builder , BuiltinOperator_DEQUANTIZE ) ) ; <nl> + <nl> + std : : vector < uint16_t > filter_data ( OutputChannels ( ) * KernelHeight ( ) * <nl> + KernelWidth ( ) * InputChannels ( ) ) ; <nl> + std : : vector < uint16_t > bias_data ( OutputChannels ( ) ) ; <nl> + for ( int32_t oc = 0 ; oc < OutputChannels ( ) ; oc + + ) { <nl> + / / Use the same range of all - positive or all - negative values to generate <nl> + / / all weights within the same output channel , but different ranges for <nl> + / / different output channels . This ensures that no catastrophic <nl> + / / cancellation occur , but test covers both positive and negative inputs . <nl> + const float range = range_rng ( ) ; <nl> + auto value_rng = <nl> + std : : bind ( fp16_ieee_from_fp32_value , <nl> + std : : bind ( std : : uniform_real_distribution < float > ( <nl> + std : : min ( range , 0 . 0f ) , std : : max ( range , 0 . 0f ) ) , <nl> + std : : ref ( rng ) ) ) ; <nl> + bias_data [ oc ] = value_rng ( ) ; <nl> + for ( int32_t ic = 0 ; ic < InputChannels ( ) ; ic + + ) { <nl> + for ( int32_t y = 0 ; y < KernelHeight ( ) ; y + + ) { <nl> + for ( int32_t x = 0 ; x < KernelWidth ( ) ; x + + ) { <nl> + const int32_t index = <nl> + ( ( oc * KernelHeight ( ) + y ) * KernelWidth ( ) + x ) * <nl> + InputChannels ( ) + <nl> + ic ; <nl> + filter_data [ index ] = value_rng ( ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + buffers . emplace_back ( CreateBuffer ( <nl> + builder , builder . CreateVector ( <nl> + reinterpret_cast < const uint8_t * > ( filter_data . data ( ) ) , <nl> + sizeof ( uint16_t ) * filter_data . size ( ) ) ) ) ; <nl> + buffers . emplace_back ( CreateBuffer ( <nl> + builder , <nl> + builder . CreateVector ( reinterpret_cast < const uint8_t * > ( bias_data . data ( ) ) , <nl> + sizeof ( uint16_t ) * bias_data . size ( ) ) ) ) ; <nl> + <nl> + const std : : array < int32_t , 1 > dequantize_filter_inputs { { 0 } } ; <nl> + const std : : array < int32_t , 1 > dequantize_filter_outputs { { 3 } } ; <nl> + operators . emplace_back ( CreateOperator ( <nl> + builder , / * opcode_index = * / 1 , <nl> + builder . CreateVector < int32_t > ( dequantize_filter_inputs . data ( ) , <nl> + dequantize_filter_inputs . size ( ) ) , <nl> + builder . CreateVector < int32_t > ( dequantize_filter_outputs . data ( ) , <nl> + dequantize_filter_outputs . size ( ) ) ) ) ; <nl> + const std : : array < int32_t , 1 > dequantize_bias_inputs { { 1 } } ; <nl> + const std : : array < int32_t , 1 > dequantize_bias_outputs { { 4 } } ; <nl> + operators . emplace_back ( CreateOperator ( <nl> + builder , / * opcode_index = * / 1 , <nl> + builder . CreateVector < int32_t > ( dequantize_bias_inputs . data ( ) , <nl> + dequantize_bias_inputs . size ( ) ) , <nl> + builder . CreateVector < int32_t > ( dequantize_bias_outputs . data ( ) , <nl> + dequantize_bias_outputs . size ( ) ) ) ) ; <nl> + } else { <nl> + std : : vector < float > filter_data ( OutputChannels ( ) * KernelHeight ( ) * <nl> + KernelWidth ( ) * InputChannels ( ) ) ; <nl> + std : : vector < float > bias_data ( OutputChannels ( ) ) ; <nl> + for ( int32_t oc = 0 ; oc < OutputChannels ( ) ; oc + + ) { <nl> + / / Use the same range of all - positive or all - negative values to generate <nl> + / / all weights within the same output channel , but different ranges for <nl> + / / different output channels . This ensures that no catastrophic <nl> + / / cancellation occur , but test covers both positive and negative inputs . <nl> + const float range = range_rng ( ) ; <nl> + auto value_rng = <nl> + std : : bind ( std : : uniform_real_distribution < float > ( <nl> + std : : min ( range , 0 . 0f ) , std : : max ( range , 0 . 0f ) ) , <nl> + std : : ref ( rng ) ) ; <nl> + bias_data [ oc ] = value_rng ( ) ; <nl> + for ( int32_t ic = 0 ; ic < InputChannels ( ) ; ic + + ) { <nl> + for ( int32_t y = 0 ; y < KernelHeight ( ) ; y + + ) { <nl> + for ( int32_t x = 0 ; x < KernelWidth ( ) ; x + + ) { <nl> + const int32_t index = <nl> + ( ( oc * KernelHeight ( ) + y ) * KernelWidth ( ) + x ) * <nl> + InputChannels ( ) + <nl> + ic ; <nl> + filter_data [ index ] = value_rng ( ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + buffers . emplace_back ( CreateBuffer ( <nl> + builder , builder . CreateVector ( <nl> + reinterpret_cast < const uint8_t * > ( filter_data . data ( ) ) , <nl> + sizeof ( float ) * filter_data . size ( ) ) ) ) ; <nl> + buffers . emplace_back ( CreateBuffer ( <nl> + builder , <nl> + builder . CreateVector ( reinterpret_cast < const uint8_t * > ( bias_data . data ( ) ) , <nl> + sizeof ( float ) * bias_data . size ( ) ) ) ) ; <nl> + } <nl> + <nl> + const std : : array < int32_t , 4 > input_shape { <nl> + { BatchSize ( ) , InputHeight ( ) , InputWidth ( ) , InputChannels ( ) } } ; <nl> + const std : : array < int32_t , 4 > output_shape { <nl> + { BatchSize ( ) , OutputHeight ( ) , OutputWidth ( ) , OutputChannels ( ) } } ; <nl> + const std : : array < int32_t , 4 > filter_shape { <nl> + { OutputChannels ( ) , KernelHeight ( ) , KernelWidth ( ) , InputChannels ( ) } } ; <nl> + const std : : array < int32_t , 1 > bias_shape { { OutputChannels ( ) } } ; <nl> + <nl> + std : : vector < flatbuffers : : Offset < tflite : : Tensor > > tensors ; <nl> + if ( FP16Weights ( ) ) { <nl> + tensors . emplace_back ( CreateTensor ( <nl> + builder , <nl> + builder . CreateVector < int32_t > ( filter_shape . data ( ) , filter_shape . size ( ) ) , <nl> + TensorType_FLOAT16 , / * buffer = * / 1 ) ) ; <nl> + tensors . emplace_back ( CreateTensor ( <nl> + builder , <nl> + builder . CreateVector < int32_t > ( bias_shape . data ( ) , bias_shape . size ( ) ) , <nl> + TensorType_FLOAT16 , / * buffer = * / 2 ) ) ; <nl> + } <nl> + tensors . emplace_back ( CreateTensor ( <nl> + builder , <nl> + builder . CreateVector < int32_t > ( input_shape . data ( ) , input_shape . size ( ) ) , <nl> + TensorType_FLOAT32 ) ) ; <nl> + tensors . emplace_back ( CreateTensor ( <nl> + builder , <nl> + builder . CreateVector < int32_t > ( filter_shape . data ( ) , filter_shape . size ( ) ) , <nl> + TensorType_FLOAT32 , / * buffer = * / FP16Weights ( ) ? 0 : 1 ) ) ; <nl> + tensors . emplace_back ( CreateTensor ( <nl> + builder , <nl> + builder . CreateVector < int32_t > ( bias_shape . data ( ) , bias_shape . size ( ) ) , <nl> + TensorType_FLOAT32 , / * buffer = * / FP16Weights ( ) ? 0 : 2 ) ) ; <nl> + tensors . emplace_back ( CreateTensor ( <nl> + builder , <nl> + builder . CreateVector < int32_t > ( output_shape . data ( ) , output_shape . size ( ) ) , <nl> + TensorType_FLOAT32 ) ) ; <nl> + <nl> + const std : : array < int32_t , 3 > op_inputs { <nl> + { static_cast < int > ( tensors . size ( ) ) - 4 , <nl> + static_cast < int > ( tensors . size ( ) ) - 3 , <nl> + static_cast < int > ( tensors . size ( ) ) - 2 } } ; <nl> + const std : : array < int32_t , 1 > op_outputs { <nl> + { static_cast < int > ( tensors . size ( ) ) - 1 } } ; <nl> + <nl> + flatbuffers : : Offset < Conv2DOptions > conv2d_options = <nl> + CreateConv2DOptions ( builder , Padding ( ) , StrideWidth ( ) , StrideHeight ( ) , <nl> + Activation ( ) , DilationWidth ( ) , DilationHeight ( ) ) ; <nl> + operators . emplace_back ( CreateOperator ( <nl> + builder , / * opcode_index = * / 0 , <nl> + builder . CreateVector < int32_t > ( op_inputs . data ( ) , op_inputs . size ( ) ) , <nl> + builder . CreateVector < int32_t > ( op_outputs . data ( ) , op_outputs . size ( ) ) , <nl> + BuiltinOptions_Conv2DOptions , conv2d_options . Union ( ) ) ) ; <nl> + <nl> + const std : : array < int32_t , 1 > subgraph_inputs { <nl> + { static_cast < int > ( tensors . size ( ) ) - 4 } } ; <nl> + const std : : array < int32_t , 1 > subgraph_outputs { <nl> + { static_cast < int > ( tensors . size ( ) ) - 1 } } ; <nl> + flatbuffers : : Offset < SubGraph > subgraph = CreateSubGraph ( <nl> + builder , builder . CreateVector ( tensors . data ( ) , tensors . size ( ) ) , <nl> + builder . CreateVector < int32_t > ( subgraph_inputs . data ( ) , <nl> + subgraph_inputs . size ( ) ) , <nl> + builder . CreateVector < int32_t > ( subgraph_outputs . data ( ) , <nl> + subgraph_outputs . size ( ) ) , <nl> + builder . CreateVector ( operators . data ( ) , operators . size ( ) ) ) ; <nl> + <nl> + flatbuffers : : Offset < flatbuffers : : String > description = <nl> + builder . CreateString ( " Conv2D model " ) ; <nl> + <nl> + flatbuffers : : Offset < Model > model_buffer = CreateModel ( <nl> + builder , TFLITE_SCHEMA_VERSION , <nl> + builder . CreateVector ( operator_codes . data ( ) , operator_codes . size ( ) ) , <nl> + builder . CreateVector ( & subgraph , 1 ) , description , <nl> + builder . CreateVector ( buffers . data ( ) , buffers . size ( ) ) ) ; <nl> + <nl> + builder . Finish ( model_buffer ) ; <nl> + <nl> + return std : : vector < char > ( builder . GetBufferPointer ( ) , <nl> + builder . GetBufferPointer ( ) + builder . GetSize ( ) ) ; <nl> + } <nl> + <nl> + } / / namespace xnnpack <nl> + } / / namespace tflite <nl> new file mode 100644 <nl> index 0000000000000 . . 6b22ded3458ae <nl> mmm / dev / null <nl> ppp b / tensorflow / lite / delegates / xnnpack / conv_2d_tester . h <nl> <nl> + / * Copyright 2020 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # ifndef TENSORFLOW_LITE_DELEGATES_XNNPACK_CONV_2D_TESTER_H_ <nl> + # define TENSORFLOW_LITE_DELEGATES_XNNPACK_CONV_2D_TESTER_H_ <nl> + <nl> + # include < cstdint > <nl> + # include < vector > <nl> + <nl> + # include < gtest / gtest . h > <nl> + # include " tensorflow / lite / c / common . h " <nl> + # include " tensorflow / lite / schema / schema_generated . h " <nl> + <nl> + namespace tflite { <nl> + namespace xnnpack { <nl> + <nl> + class Conv2DTester { <nl> + public : <nl> + Conv2DTester ( ) = default ; <nl> + Conv2DTester ( const Conv2DTester & ) = delete ; <nl> + Conv2DTester & operator = ( const Conv2DTester & ) = delete ; <nl> + <nl> + inline Conv2DTester & BatchSize ( int32_t batch_size ) { <nl> + EXPECT_GT ( batch_size , 0 ) ; <nl> + batch_size_ = batch_size ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t BatchSize ( ) const { return batch_size_ ; } <nl> + <nl> + inline Conv2DTester & InputChannels ( int32_t input_channels ) { <nl> + EXPECT_GT ( input_channels , 0 ) ; <nl> + input_channels_ = input_channels ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t InputChannels ( ) const { return input_channels_ ; } <nl> + <nl> + inline Conv2DTester & OutputChannels ( int32_t output_channels ) { <nl> + EXPECT_GT ( output_channels , 0 ) ; <nl> + output_channels_ = output_channels ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t OutputChannels ( ) const { return output_channels_ ; } <nl> + <nl> + inline Conv2DTester & InputHeight ( int32_t input_height ) { <nl> + EXPECT_GT ( input_height , 0 ) ; <nl> + input_height_ = input_height ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t InputHeight ( ) const { return input_height_ ; } <nl> + <nl> + inline Conv2DTester & InputWidth ( int32_t input_width ) { <nl> + EXPECT_GT ( input_width , 0 ) ; <nl> + input_width_ = input_width ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t InputWidth ( ) const { return input_width_ ; } <nl> + <nl> + inline int32_t OutputWidth ( ) const { <nl> + if ( Padding ( ) = = : : tflite : : Padding_SAME ) { <nl> + EXPECT_GE ( InputWidth ( ) , 1 ) ; <nl> + return ( InputWidth ( ) - 1 ) / StrideWidth ( ) + 1 ; <nl> + } else { <nl> + EXPECT_GE ( InputWidth ( ) , DilatedKernelWidth ( ) ) ; <nl> + return 1 + ( InputWidth ( ) - DilatedKernelWidth ( ) ) / StrideWidth ( ) ; <nl> + } <nl> + } <nl> + <nl> + inline int32_t OutputHeight ( ) const { <nl> + if ( Padding ( ) = = : : tflite : : Padding_SAME ) { <nl> + EXPECT_GE ( InputHeight ( ) , 1 ) ; <nl> + return ( InputHeight ( ) - 1 ) / StrideHeight ( ) + 1 ; <nl> + } else { <nl> + EXPECT_GE ( InputHeight ( ) , DilatedKernelHeight ( ) ) ; <nl> + return 1 + ( InputHeight ( ) - DilatedKernelHeight ( ) ) / StrideHeight ( ) ; <nl> + } <nl> + } <nl> + <nl> + inline Conv2DTester & KernelHeight ( int32_t kernel_height ) { <nl> + EXPECT_GT ( kernel_height , 0 ) ; <nl> + kernel_height_ = kernel_height ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t KernelHeight ( ) const { return kernel_height_ ; } <nl> + <nl> + inline Conv2DTester & KernelWidth ( int32_t kernel_width ) { <nl> + EXPECT_GT ( kernel_width , 0 ) ; <nl> + kernel_width_ = kernel_width ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t KernelWidth ( ) const { return kernel_width_ ; } <nl> + <nl> + inline Conv2DTester & StrideHeight ( int32_t stride_height ) { <nl> + EXPECT_GT ( stride_height , 0 ) ; <nl> + stride_height_ = stride_height ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t StrideHeight ( ) const { return stride_height_ ; } <nl> + <nl> + inline Conv2DTester & StrideWidth ( int32_t stride_width ) { <nl> + EXPECT_GT ( stride_width , 0 ) ; <nl> + stride_width_ = stride_width ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t StrideWidth ( ) const { return stride_width_ ; } <nl> + <nl> + inline Conv2DTester & DilationHeight ( int32_t dilation_height ) { <nl> + EXPECT_GT ( dilation_height , 0 ) ; <nl> + dilation_height_ = dilation_height ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t DilationHeight ( ) const { return dilation_height_ ; } <nl> + <nl> + inline Conv2DTester & DilationWidth ( int32_t dilation_width ) { <nl> + EXPECT_GT ( dilation_width , 0 ) ; <nl> + dilation_width_ = dilation_width ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline int32_t DilationWidth ( ) const { return dilation_width_ ; } <nl> + <nl> + inline int32_t DilatedKernelHeight ( ) const { <nl> + return ( KernelHeight ( ) - 1 ) * DilationHeight ( ) + 1 ; <nl> + } <nl> + <nl> + inline int32_t DilatedKernelWidth ( ) const { <nl> + return ( KernelWidth ( ) - 1 ) * DilationWidth ( ) + 1 ; <nl> + } <nl> + <nl> + inline Conv2DTester & FP16Weights ( ) { <nl> + fp16_weights_ = true ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline bool FP16Weights ( ) const { return fp16_weights_ ; } <nl> + <nl> + inline Conv2DTester & SamePadding ( ) { <nl> + padding_ = : : tflite : : Padding_SAME ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline Conv2DTester & ValidPadding ( ) { <nl> + padding_ = : : tflite : : Padding_VALID ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline Conv2DTester & ReluActivation ( ) { <nl> + activation_ = : : tflite : : ActivationFunctionType_RELU ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline Conv2DTester & Relu6Activation ( ) { <nl> + activation_ = : : tflite : : ActivationFunctionType_RELU6 ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline Conv2DTester & ReluMinus1To1Activation ( ) { <nl> + activation_ = : : tflite : : ActivationFunctionType_RELU_N1_TO_1 ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline Conv2DTester & TanhActivation ( ) { <nl> + activation_ = : : tflite : : ActivationFunctionType_TANH ; <nl> + return * this ; <nl> + } <nl> + <nl> + inline Conv2DTester & SignBitActivation ( ) { <nl> + activation_ = : : tflite : : ActivationFunctionType_SIGN_BIT ; <nl> + return * this ; <nl> + } <nl> + <nl> + void Test ( TfLiteDelegate * delegate ) const ; <nl> + <nl> + private : <nl> + std : : vector < char > CreateTfLiteModel ( ) const ; <nl> + <nl> + inline : : tflite : : Padding Padding ( ) const { return padding_ ; } <nl> + <nl> + inline : : tflite : : ActivationFunctionType Activation ( ) const { <nl> + return activation_ ; <nl> + } <nl> + <nl> + int32_t batch_size_ = 1 ; <nl> + int32_t input_channels_ = 1 ; <nl> + int32_t output_channels_ = 1 ; <nl> + int32_t input_height_ = 1 ; <nl> + int32_t input_width_ = 1 ; <nl> + int32_t kernel_height_ = 1 ; <nl> + int32_t kernel_width_ = 1 ; <nl> + int32_t stride_height_ = 1 ; <nl> + int32_t stride_width_ = 1 ; <nl> + int32_t dilation_height_ = 1 ; <nl> + int32_t dilation_width_ = 1 ; <nl> + bool fp16_weights_ = false ; <nl> + : : tflite : : Padding padding_ = : : tflite : : Padding_VALID ; <nl> + : : tflite : : ActivationFunctionType activation_ = <nl> + : : tflite : : ActivationFunctionType_NONE ; <nl> + } ; <nl> + <nl> + } / / namespace xnnpack <nl> + } / / namespace tflite <nl> + <nl> + # endif / / TENSORFLOW_LITE_DELEGATES_XNNPACK_CONV_2D_TESTER_H_ <nl>
|
Update Conv2D tests for XNNPACK delegate
|
tensorflow/tensorflow
|
245f3908068606c7b80da3375e04c2ede5125516
|
2020-05-28T20:22:02Z
|
mmm a / src / video_core / renderer_opengl / gl_rasterizer_cache . cpp <nl> ppp b / src / video_core / renderer_opengl / gl_rasterizer_cache . cpp <nl> static constexpr std : : array < FormatTuple , SurfaceParams : : MaxPixelFormat > tex_form <nl> { GL_COMPRESSED_RG_RGTC2 , GL_RG , GL_UNSIGNED_INT_8_8_8_8 , ComponentType : : UNorm , <nl> true } , / / DXN2UNORM <nl> { GL_COMPRESSED_SIGNED_RG_RGTC2 , GL_RG , GL_INT , ComponentType : : SNorm , true } , / / DXN2SNORM <nl> - { GL_COMPRESSED_RGBA_BPTC_UNORM_ARB , GL_RGB , GL_UNSIGNED_INT_8_8_8_8 , ComponentType : : UNorm , <nl> + { GL_COMPRESSED_RGBA_BPTC_UNORM_ARB , GL_RGBA , GL_UNSIGNED_INT_8_8_8_8 , ComponentType : : UNorm , <nl> true } , / / BC7U <nl> { GL_RGBA8 , GL_RGBA , GL_UNSIGNED_BYTE , ComponentType : : UNorm , false } , / / ASTC_2D_4X4 <nl> { GL_RG8 , GL_RG , GL_UNSIGNED_BYTE , ComponentType : : UNorm , false } , / / G8R8 <nl>
|
Merge pull request from greggameplayer / BC7U_Fix
|
yuzu-emu/yuzu
|
4dacb8a4b1f422f85f55a7d0d6ce2756203b247a
|
2018-08-14T12:03:07Z
|
mmm a / build / cocos2d_libs . xcodeproj / project . pbxproj <nl> ppp b / build / cocos2d_libs . xcodeproj / project . pbxproj <nl> <nl> 500DC9BD19106E89007B91BF / * CCProfiling . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 500DC9BA19106E89007B91BF / * CCProfiling . cpp * / ; } ; <nl> 500DC9BE19106E89007B91BF / * CCProfiling . h in Headers * / = { isa = PBXBuildFile ; fileRef = 500DC9BB19106E89007B91BF / * CCProfiling . h * / ; } ; <nl> 500DC9BF19106E89007B91BF / * CCProfiling . h in Headers * / = { isa = PBXBuildFile ; fileRef = 500DC9BB19106E89007B91BF / * CCProfiling . h * / ; } ; <nl> - 500DC9E5191BF301007B91BF / * CCVertexAttribBind . h in Headers * / = { isa = PBXBuildFile ; fileRef = 500DC9E1191BF301007B91BF / * CCVertexAttribBind . h * / ; } ; <nl> - 500DC9E6191BF301007B91BF / * CCVertexAttribBind . h in Headers * / = { isa = PBXBuildFile ; fileRef = 500DC9E1191BF301007B91BF / * CCVertexAttribBind . h * / ; } ; <nl> - 500DC9E7191BF301007B91BF / * CCVertexAttribBind . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 500DC9E2191BF301007B91BF / * CCVertexAttribBind . cpp * / ; } ; <nl> - 500DC9E8191BF301007B91BF / * CCVertexAttribBind . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 500DC9E2191BF301007B91BF / * CCVertexAttribBind . cpp * / ; } ; <nl> 500DC9E9191BF301007B91BF / * CCGLProgramState . h in Headers * / = { isa = PBXBuildFile ; fileRef = 500DC9E3191BF301007B91BF / * CCGLProgramState . h * / ; } ; <nl> 500DC9EA191BF301007B91BF / * CCGLProgramState . h in Headers * / = { isa = PBXBuildFile ; fileRef = 500DC9E3191BF301007B91BF / * CCGLProgramState . h * / ; } ; <nl> 500DC9EB191BF301007B91BF / * CCGLProgramState . cpp in Sources * / = { isa = PBXBuildFile ; fileRef = 500DC9E4191BF301007B91BF / * CCGLProgramState . cpp * / ; } ; <nl> <nl> 500DC9B519106E6D007B91BF / * TransformUtils . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = TransformUtils . h ; sourceTree = " < group > " ; } ; <nl> 500DC9BA19106E89007B91BF / * CCProfiling . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; name = CCProfiling . cpp ; path = . . / base / CCProfiling . cpp ; sourceTree = " < group > " ; } ; <nl> 500DC9BB19106E89007B91BF / * CCProfiling . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; name = CCProfiling . h ; path = . . / base / CCProfiling . h ; sourceTree = " < group > " ; } ; <nl> - 500DC9E1191BF301007B91BF / * CCVertexAttribBind . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCVertexAttribBind . h ; sourceTree = " < group > " ; } ; <nl> - 500DC9E2191BF301007B91BF / * CCVertexAttribBind . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCVertexAttribBind . cpp ; sourceTree = " < group > " ; } ; <nl> 500DC9E3191BF301007B91BF / * CCGLProgramState . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CCGLProgramState . h ; sourceTree = " < group > " ; } ; <nl> 500DC9E4191BF301007B91BF / * CCGLProgramState . cpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . cpp ; path = CCGLProgramState . cpp ; sourceTree = " < group > " ; } ; <nl> 50272538190BF1B900AAF4ED / * cocos2d . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; name = cocos2d . h ; path = . . / cocos / cocos2d . h ; sourceTree = " < group > " ; } ; <nl> <nl> 1A570238180BCC580088DEC7 / * shaders * / = { <nl> isa = PBXGroup ; <nl> children = ( <nl> - 500DC9E1191BF301007B91BF / * CCVertexAttribBind . h * / , <nl> - 500DC9E2191BF301007B91BF / * CCVertexAttribBind . cpp * / , <nl> 500DC9E3191BF301007B91BF / * CCGLProgramState . h * / , <nl> 500DC9E4191BF301007B91BF / * CCGLProgramState . cpp * / , <nl> 1A57052F180BD9500088DEC7 / * CCGLProgram . cpp * / , <nl> <nl> 1A57022F180BCC1A0088DEC7 / * CCParticleSystemQuad . h in Headers * / , <nl> 500DC96A19106300007B91BF / * CCEventListenerCustom . h in Headers * / , <nl> B2AF2F9718EBAEAE00C5807C / * MathUtil . h in Headers * / , <nl> - 500DC9E5191BF301007B91BF / * CCVertexAttribBind . h in Headers * / , <nl> 1A570236180BCC4D0088DEC7 / * CCScriptSupport . h in Headers * / , <nl> 1A57024D180BCC6F0088DEC7 / * ccShader_Position_uColor_frag . h in Headers * / , <nl> 1A57024F180BCC6F0088DEC7 / * ccShader_Position_uColor_vert . h in Headers * / , <nl> <nl> 1AD71EAC180E26E600808F54 / * Attachment . h in Headers * / , <nl> 500DC94719106300007B91BF / * CCDataVisitor . h in Headers * / , <nl> 2905FA4918CF08D100240AA3 / * UIButton . h in Headers * / , <nl> - 500DC9E6191BF301007B91BF / * CCVertexAttribBind . h in Headers * / , <nl> 500DC96719106300007B91BF / * CCEventListenerAcceleration . h in Headers * / , <nl> 1AD71EB0180E26E600808F54 / * AttachmentLoader . h in Headers * / , <nl> 1AD71EB4180E26E600808F54 / * Bone . h in Headers * / , <nl> <nl> 1A570225180BCC1A0088DEC7 / * CCParticleExamples . cpp in Sources * / , <nl> 1A570229180BCC1A0088DEC7 / * CCParticleSystem . cpp in Sources * / , <nl> 1A57022D180BCC1A0088DEC7 / * CCParticleSystemQuad . cpp in Sources * / , <nl> - 500DC9E7191BF301007B91BF / * CCVertexAttribBind . cpp in Sources * / , <nl> 500DC9B01910633C007B91BF / * CCTouch . cpp in Sources * / , <nl> 50FCEB9B18C72017004AD434 / * ImageViewReader . cpp in Sources * / , <nl> 500DC9AA19106300007B91BF / * ZipUtils . cpp in Sources * / , <nl> <nl> 1AAF5854180E40B9000584C8 / * LocalStorageAndroid . cpp in Sources * / , <nl> 1A9DCA24180E6955007A3AD4 / * ccFPSImages . c in Sources * / , <nl> 1A9DCA28180E6955007A3AD4 / * CCGLBufferedNode . cpp in Sources * / , <nl> - 500DC9E8191BF301007B91BF / * CCVertexAttribBind . cpp in Sources * / , <nl> 50FCEBA018C72017004AD434 / * LayoutReader . cpp in Sources * / , <nl> 50E6D33518E174130051CA34 / * UIHBox . cpp in Sources * / , <nl> 500DC98F19106300007B91BF / * CCRef . cpp in Sources * / , <nl> deleted file mode 100644 <nl> index c2e96241aa63 . . 000000000000 <nl> mmm a / cocos / 2d / CCVertexAttribBind . cpp <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright 2014 Chukong Technologies Inc . <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN false EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # include " base / CCDirector . h " <nl> - # include " 2d / CCVertexAttribBind . h " <nl> - # include " 2d / ccGLStateCache . h " <nl> - # include " base / ccMacros . h " <nl> - # include " 2d / platform / CCFileUtils . h " <nl> - # include " 2d / uthash . h " <nl> - # include " deprecated / CCString . h " <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - VertexAttribType : : VertexAttribType ( ) : _type ( GL_FLOAT ) , _size ( 0 ) , _location ( - 1 ) , _offset ( 0 ) <nl> - { <nl> - } <nl> - VertexAttribType : : VertexAttribType ( GLenum type , int size ) : _type ( type ) , _size ( size ) , _location ( - 1 ) , _offset ( 0 ) <nl> - { <nl> - switch ( type ) { <nl> - case GL_FLOAT_VEC2 : <nl> - _type = GL_FLOAT ; <nl> - _size = 2 ; <nl> - break ; <nl> - case GL_FLOAT_VEC3 : <nl> - _type = GL_FLOAT ; <nl> - _size = 3 ; <nl> - break ; <nl> - case GL_FLOAT_VEC4 : <nl> - _type = GL_FLOAT ; <nl> - _size = 4 ; <nl> - break ; <nl> - <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - <nl> - int VertexAttribType : : getByteSize ( ) <nl> - { <nl> - int byteSize = 0 ; <nl> - switch ( _type ) { <nl> - case GL_BYTE : <nl> - case GL_UNSIGNED_BYTE : <nl> - byteSize = _size ; <nl> - break ; <nl> - case GL_SHORT : <nl> - case GL_UNSIGNED_SHORT : <nl> - byteSize = _size * sizeof ( GLshort ) ; <nl> - break ; <nl> - case GL_FLOAT : <nl> - byteSize = _size * sizeof ( GLfloat ) ; <nl> - break ; <nl> - default : <nl> - CCASSERT ( 0 , " type error " ) ; <nl> - break ; <nl> - } <nl> - return byteSize ; <nl> - } <nl> - <nl> - VertexAttribBind : : VertexAttribBind ( const VertexAttribType * elem , int count ) <nl> - { <nl> - setVertexAttribElems ( elem , count ) ; <nl> - } <nl> - <nl> - VertexAttribBind : : VertexAttribBind ( const std : : vector < VertexAttribType > & elems ) <nl> - { <nl> - setVertexAttribElems ( & elems [ 0 ] , elems . size ( ) ) ; <nl> - } <nl> - <nl> - VertexAttribBind : : VertexAttribBind ( const std : : vector < VertexAttrib * > & attribs ) <nl> - { <nl> - std : : vector < VertexAttribType > elems ; <nl> - for ( auto it = attribs . begin ( ) ; it ! = attribs . end ( ) ; it + + ) { <nl> - VertexAttribType type ( ( * it ) - > type , ( * it ) - > size ) ; <nl> - type . _location = ( * it ) - > index ; <nl> - elems . push_back ( type ) ; <nl> - } <nl> - setVertexAttribElems ( & elems [ 0 ] , elems . size ( ) ) ; <nl> - } <nl> - <nl> - VertexAttribBind : : ~ VertexAttribBind ( ) <nl> - { <nl> - delete [ ] _vertexAttribs ; <nl> - } <nl> - <nl> - void VertexAttribBind : : bindAttribute ( int index , int attribLocation ) <nl> - { <nl> - / / make sure index and attribute location are validate <nl> - _vertexAttribs [ index ] . _location = attribLocation ; <nl> - } <nl> - <nl> - / / bind attributes pointer <nl> - void VertexAttribBind : : bindAttributePtr ( void * vertexPointer ) <nl> - { <nl> - for ( auto i = 0 ; i < _vertexAtttribCount ; i + + ) { <nl> - auto elem = _vertexAttribs [ i ] ; <nl> - if ( elem . _location ! = - 1 ) <nl> - { <nl> - glEnableVertexAttribArray ( elem . _location ) ; <nl> - void * pointer = vertexPointer ? ( void * ) ( ( ( unsigned char * ) vertexPointer ) + elem . _offset ) : ( void * ) elem . _offset ; <nl> - glVertexAttribPointer ( elem . _location , elem . _size , elem . _type , GL_FALSE , _stride , pointer ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - void VertexAttribBind : : setVertexAttribElems ( const VertexAttribType * elem , int count ) <nl> - { <nl> - _vertexAtttribCount = count ; <nl> - _vertexAttribs = new VertexAttribType [ count ] ; <nl> - _stride = 0 ; <nl> - for ( auto i = 0 ; i < count ; i + + ) { <nl> - _vertexAttribs [ i ] = elem [ i ] ; <nl> - _vertexAttribs [ i ] . _offset = _stride ; <nl> - _stride + = _vertexAttribs [ i ] . getByteSize ( ) ; <nl> - } <nl> - } <nl> - <nl> - NS_CC_END <nl> deleted file mode 100644 <nl> index f56059becf84 . . 000000000000 <nl> mmm a / cocos / 2d / CCVertexAttribBind . h <nl> ppp / dev / null <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - Copyright 2014 Chukong Technologies Inc . <nl> - <nl> - http : / / www . cocos2d - x . org <nl> - <nl> - Permission is hereby granted , free of charge , to any person obtaining a copy <nl> - of this software and associated documentation files ( the " Software " ) , to deal <nl> - in the Software without restriction , including without limitation the rights <nl> - to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> - copies of the Software , and to permit persons to whom the Software is <nl> - furnished to do so , subject to the following conditions : <nl> - <nl> - The above copyright notice and this permission notice shall be included in <nl> - all copies or substantial portions of the Software . <nl> - <nl> - THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> - IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN false EVENT SHALL THE <nl> - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> - LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN <nl> - THE SOFTWARE . <nl> - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - # ifndef __CCVRETEXATTRIBBIND_H__ <nl> - # define __CCVRETEXATTRIBBIND_H__ <nl> - <nl> - # include " base / ccMacros . h " <nl> - # include " base / CCRef . h " <nl> - # include " CCGL . h " <nl> - # include " math / CCMath . h " <nl> - # include " 2d / CCGLProgram . h " <nl> - # include < set > <nl> - <nl> - NS_CC_BEGIN <nl> - <nl> - USING_NS_CC_MATH ; <nl> - <nl> - / / / / vertex attribute / / / / / <nl> - class VertexAttribType <nl> - { <nl> - friend class VertexAttribBind ; <nl> - friend class GLProgram ; <nl> - public : <nl> - VertexAttribType ( ) ; <nl> - <nl> - VertexAttribType ( GLenum type , int size ) ; <nl> - <nl> - int getByteSize ( ) ; <nl> - <nl> - protected : <nl> - GLenum _type ; <nl> - int _size ; <nl> - int _location ; <nl> - int _offset ; <nl> - } ; <nl> - <nl> - / / / / vertex attributes bind <nl> - class VertexAttribBind <nl> - { <nl> - public : <nl> - VertexAttribBind ( const VertexAttribType * elem , int count ) ; <nl> - <nl> - VertexAttribBind ( const std : : vector < VertexAttribType > & elems ) ; <nl> - <nl> - VertexAttribBind ( const std : : vector < VertexAttrib * > & attribs ) ; <nl> - <nl> - virtual ~ VertexAttribBind ( ) ; <nl> - <nl> - / * * <nl> - * bind vertex attributes . <nl> - * <nl> - * @ param index Position in _vertexAttribs <nl> - * @ param attribLocation location in shader . It can be queried from GLProgram , eg . program - > getAttribLocation ( " a_position " ) <nl> - * / <nl> - void bindAttribute ( int index , int attribLocation ) ; <nl> - <nl> - / * * bind attributes pointer * * / <nl> - void bindAttributePtr ( void * vertexPointer = nullptr ) ; <nl> - <nl> - protected : <nl> - <nl> - void setVertexAttribElems ( const VertexAttribType * elem , int count ) ; <nl> - <nl> - VertexAttribType * _vertexAttribs ; <nl> - int _vertexAtttribCount ; <nl> - int _stride ; <nl> - } ; <nl> - <nl> - NS_CC_END <nl> - <nl> - # endif / * __CCVRETEXATTRIBBIND_H__ * / <nl>
|
Removes CCVertexAttribBind
|
cocos2d/cocos2d-x
|
453b670ad2fe76f6698fd3df036d0e2f5c8f71c8
|
2014-05-08T21:01:26Z
|
mmm a / src / citra_qt / bootmanager . cpp <nl> ppp b / src / citra_qt / bootmanager . cpp <nl> <nl> # include < QHBoxLayout > <nl> # include < QKeyEvent > <nl> + # include < QApplication > <nl> <nl> # include " common / common . h " <nl> # include " bootmanager . hxx " <nl> class GGLWidgetInternal : public QGLWidget <nl> public : <nl> GGLWidgetInternal ( QGLFormat fmt , GRenderWindow * parent ) : QGLWidget ( parent ) <nl> { <nl> - doneCurrent ( ) ; <nl> parent_ = parent ; <nl> } <nl> <nl> void paintEvent ( QPaintEvent * ev ) <nl> { <nl> - / / Apparently , Windows doesn ' t display anything if we don ' t call this here . <nl> - / / TODO : Breaks linux though because we aren ' t calling doneCurrent ( ) . . . - . - <nl> - / / makeCurrent ( ) ; <nl> } <nl> void resizeEvent ( QResizeEvent * ev ) { <nl> parent_ - > SetClientAreaWidth ( size ( ) . width ( ) ) ; <nl> GRenderWindow : : GRenderWindow ( QWidget * parent ) : QWidget ( parent ) , emu_thread ( this <nl> layout - > addWidget ( child ) ; <nl> layout - > setMargin ( 0 ) ; <nl> setLayout ( layout ) ; <nl> + QObject : : connect ( & emu_thread , SIGNAL ( started ( ) ) , this , SLOT ( moveContext ( ) ) ) ; <nl> + QObject : : connect ( & emu_thread , SIGNAL ( finished ( ) ) , this , SLOT ( moveContext ( ) ) ) ; <nl> <nl> BackupGeometry ( ) ; <nl> } <nl> <nl> + void GRenderWindow : : moveContext ( ) <nl> + { <nl> + DoneCurrent ( ) ; <nl> + / / We need to move GL context to the swapping thread in Qt5 <nl> + # if QT_VERSION > QT_VERSION_CHECK ( 5 , 0 , 0 ) <nl> + / / If the thread started running , move the GL Context to the new thread . Otherwise , move it back . <nl> + child - > context ( ) - > moveToThread ( emu_thread . isRunning ( ) ? & emu_thread : qApp - > thread ( ) ) ; <nl> + # endif <nl> + } <nl> + <nl> GRenderWindow : : ~ GRenderWindow ( ) <nl> { <nl> emu_thread . Stop ( ) ; <nl> GRenderWindow : : ~ GRenderWindow ( ) <nl> <nl> void GRenderWindow : : SwapBuffers ( ) <nl> { <nl> - child - > makeCurrent ( ) ; / / TODO : Not necessary ? <nl> + / / MakeCurrent is already called in renderer_opengl <nl> child - > swapBuffers ( ) ; <nl> } <nl> <nl> void GRenderWindow : : keyReleaseEvent ( QKeyEvent * event ) <nl> if ( ! key_processed ) <nl> QWidget : : keyPressEvent ( event ) ; <nl> * / <nl> - } <nl> \ No newline at end of file <nl> + } <nl> + <nl> mmm a / src / citra_qt / bootmanager . hxx <nl> ppp b / src / citra_qt / bootmanager . hxx <nl> signals : <nl> <nl> class GRenderWindow : public QWidget , public EmuWindow <nl> { <nl> + Q_OBJECT <nl> + <nl> public : <nl> GRenderWindow ( QWidget * parent = NULL ) ; <nl> ~ GRenderWindow ( ) ; <nl> public : <nl> void keyPressEvent ( QKeyEvent * event ) ; <nl> void keyReleaseEvent ( QKeyEvent * event ) ; <nl> <nl> + private slots : <nl> + void moveContext ( ) ; <nl> + <nl> private : <nl> QGLWidget * child ; <nl> <nl> mmm a / src / citra_qt / main . cpp <nl> ppp b / src / citra_qt / main . cpp <nl> void GMainWindow : : BootGame ( std : : string filename ) <nl> registersWidget - > OnCPUStepped ( ) ; <nl> callstackWidget - > OnCPUStepped ( ) ; <nl> <nl> - render_window - > DoneCurrent ( ) ; / / make sure EmuThread can access GL context <nl> render_window - > GetEmuThread ( ) . SetFilename ( filename ) ; <nl> render_window - > GetEmuThread ( ) . start ( ) ; <nl> <nl> void GMainWindow : : ToggleWindowMode ( ) <nl> ui . horizontalLayout - > removeWidget ( render_window ) ; <nl> render_window - > setParent ( NULL ) ; <nl> render_window - > setVisible ( true ) ; <nl> - render_window - > DoneCurrent ( ) ; <nl> render_window - > RestoreGeometry ( ) ; <nl> } <nl> else if ( ! enable & & render_window - > parent ( ) = = NULL ) <nl> void GMainWindow : : ToggleWindowMode ( ) <nl> render_window - > BackupGeometry ( ) ; <nl> ui . horizontalLayout - > addWidget ( render_window ) ; <nl> render_window - > setVisible ( true ) ; <nl> - render_window - > DoneCurrent ( ) ; <nl> } <nl> } <nl> <nl> mmm a / src / video_core / video_core . cpp <nl> ppp b / src / video_core / video_core . cpp <nl> void Init ( EmuWindow * emu_window ) { <nl> glewExperimental = GL_TRUE ; <nl> <nl> g_emu_window = emu_window ; <nl> - g_emu_window - > MakeCurrent ( ) ; <nl> g_renderer = new RendererOpenGL ( ) ; <nl> g_renderer - > SetWindow ( g_emu_window ) ; <nl> g_renderer - > Init ( ) ; <nl>
|
Fix the threading for GL Context in Qt5 .
|
yuzu-emu/yuzu
|
a3a70e56acfde2cf75dfd02a6c2f1828d28efe02
|
2014-08-24T14:47:00Z
|
mmm a / benchmark / single - source / DictionarySwap . swift <nl> ppp b / benchmark / single - source / DictionarySwap . swift <nl> import TestsUtils <nl> public let DictionarySwap = [ <nl> BenchmarkInfo ( name : " DictionarySwap " , runFunction : run_DictionarySwap , tags : [ . validation , . api , . Dictionary ] ) , <nl> BenchmarkInfo ( name : " DictionarySwapOfObjects " , runFunction : run_DictionarySwapOfObjects , tags : [ . validation , . api , . Dictionary ] ) , <nl> + BenchmarkInfo ( name : " DictionarySwapAt " , runFunction : run_DictionarySwapAt , tags : [ . validation , . api , . Dictionary ] ) , <nl> + BenchmarkInfo ( name : " DictionarySwapAtOfObjects " , runFunction : run_DictionarySwapAtOfObjects , tags : [ . validation , . api , . Dictionary ] ) , <nl> ] <nl> <nl> @ inline ( never ) <nl> public func run_DictionarySwap ( _ N : Int ) { <nl> CheckResults ( swappedCorrectly ( swapped , dict [ 25 ] ! , dict [ 75 ] ! ) ) <nl> } <nl> <nl> + @ inline ( never ) <nl> + public func run_DictionarySwapAt ( _ N : Int ) { <nl> + let size = 100 <nl> + var dict = [ Int : Int ] ( minimumCapacity : size ) <nl> + <nl> + / / Fill dictionary <nl> + for i in 1 . . . size { <nl> + dict [ i ] = i <nl> + } <nl> + CheckResults ( dict . count = = size ) <nl> + <nl> + var swapped = false <nl> + for _ in 1 . . . 10000 * N { <nl> + let i25 = dict . index ( forKey : 25 ) ! <nl> + let i75 = dict . index ( forKey : 75 ) ! <nl> + <nl> + dict . values . swapAt ( i25 , i75 ) <nl> + swapped = ! swapped <nl> + if ! swappedCorrectly ( swapped , dict [ 25 ] ! , dict [ 75 ] ! ) { <nl> + break <nl> + } <nl> + } <nl> + <nl> + CheckResults ( swappedCorrectly ( swapped , dict [ 25 ] ! , dict [ 75 ] ! ) ) <nl> + } <nl> + <nl> / / Return true if correctly swapped , false otherwise <nl> func swappedCorrectly ( _ swapped : Bool , _ p25 : Int , _ p75 : Int ) - > Bool { <nl> return swapped & & ( p25 = = 75 & & p75 = = 25 ) | | <nl> public func run_DictionarySwapOfObjects ( _ N : Int ) { <nl> <nl> CheckResults ( swappedCorrectly ( swapped , dict [ Box ( 25 ) ] ! . value , dict [ Box ( 75 ) ] ! . value ) ) <nl> } <nl> + <nl> + @ inline ( never ) <nl> + public func run_DictionarySwapAtOfObjects ( _ N : Int ) { <nl> + let size = 100 <nl> + var dict = [ Box < Int > : Box < Int > ] ( minimumCapacity : size ) <nl> + <nl> + / / Fill dictionary <nl> + for i in 1 . . . size { <nl> + dict [ Box ( i ) ] = Box ( i ) <nl> + } <nl> + CheckResults ( dict . count = = size ) <nl> + <nl> + var swapped = false <nl> + for _ in 1 . . . 10000 * N { <nl> + let b25 = Box ( 25 ) <nl> + let b75 = Box ( 75 ) <nl> + let i25 = dict . index ( forKey : b25 ) ! <nl> + let i75 = dict . index ( forKey : b75 ) ! <nl> + <nl> + dict . values . swapAt ( i25 , i75 ) <nl> + swapped = ! swapped <nl> + if ! swappedCorrectly ( swapped , dict [ Box ( 25 ) ] ! . value , dict [ Box ( 75 ) ] ! . value ) { <nl> + break <nl> + } <nl> + } <nl> + <nl> + CheckResults ( swappedCorrectly ( swapped , dict [ Box ( 25 ) ] ! . value , dict [ Box ( 75 ) ] ! . value ) ) <nl> + } <nl> mmm a / stdlib / public / SwiftShims / GlobalObjects . h <nl> ppp b / stdlib / public / SwiftShims / GlobalObjects . h <nl> struct _SwiftEmptyDictionaryStorage _swiftEmptyDictionaryStorage ; <nl> SWIFT_RUNTIME_STDLIB_INTERFACE <nl> struct _SwiftEmptySetStorage _swiftEmptySetStorage ; <nl> <nl> - struct _SwiftHashingSeed { <nl> + struct _SwiftHashingParameters { <nl> __swift_uint64_t seed0 ; <nl> __swift_uint64_t seed1 ; <nl> + __swift_bool deterministic ; <nl> } ; <nl> - <nl> - SWIFT_RUNTIME_STDLIB_INTERFACE <nl> - struct _SwiftHashingSeed _swift_stdlib_Hashing_seed ; <nl> - <nl> + <nl> SWIFT_RUNTIME_STDLIB_INTERFACE <nl> - __swift_bool _swift_stdlib_Hashing_deterministicHashing ; <nl> + struct _SwiftHashingParameters _swift_stdlib_Hashing_parameters ; <nl> <nl> # ifdef __cplusplus <nl> <nl> mmm a / stdlib / public / core / Hashing . swift <nl> ppp b / stdlib / public / core / Hashing . swift <nl> public struct _Hasher { <nl> / / / of test results . <nl> public / / SPI <nl> static var _isDeterministic : Bool { <nl> - return _swift_stdlib_Hashing_deterministicHashing <nl> + @ _inlineable <nl> + @ inline ( __always ) <nl> + get { <nl> + return _swift_stdlib_Hashing_parameters . deterministic ; <nl> + } <nl> } <nl> <nl> / / / The 128 - bit hash seed used to initialize the hasher state . Initialized <nl> / / / once during process startup . <nl> public / / SPI <nl> static var _seed : ( UInt64 , UInt64 ) { <nl> + @ _inlineable <nl> + @ inline ( __always ) <nl> get { <nl> - if _isDeterministic { return ( 0 , 0 ) } <nl> / / The seed itself is defined in C + + code so that it is initialized during <nl> / / static construction . Almost every Swift program uses hash tables , so <nl> / / initializing the seed during the startup seems to be the right <nl> / / trade - off . <nl> return ( <nl> - _swift_stdlib_Hashing_seed . seed0 , <nl> - _swift_stdlib_Hashing_seed . seed1 ) <nl> + _swift_stdlib_Hashing_parameters . seed0 , <nl> + _swift_stdlib_Hashing_parameters . seed1 ) <nl> } <nl> } <nl> <nl> mmm a / stdlib / public / stubs / GlobalObjects . cpp <nl> ppp b / stdlib / public / stubs / GlobalObjects . cpp <nl> swift : : _SwiftEmptySetStorage swift : : _swiftEmptySetStorage = { <nl> 0 / / int entries ; ( zero ' d bits ) <nl> } ; <nl> <nl> - static swift : : _SwiftHashingSeed initializeHashingSeed ( ) { <nl> + static swift : : _SwiftHashingParameters initializeHashingParameters ( ) { <nl> + / / Setting the environment variable SWIFT_DETERMINISTIC_HASHING to " 1 " <nl> + / / disables randomized hash seeding . This is useful in cases we need to ensure <nl> + / / results are repeatable , e . g . , in certain test environments . ( Note that <nl> + / / even if the seed override is enabled , hash values aren ' t guaranteed to <nl> + / / remain stable across even minor stdlib releases . ) <nl> + auto determinism = getenv ( " SWIFT_DETERMINISTIC_HASHING " ) ; <nl> + if ( determinism & & 0 = = strcmp ( determinism , " 1 " ) ) { <nl> + return { 0 , 0 , true } ; <nl> + } <nl> # if defined ( __APPLE__ ) <nl> / / Use arc4random if available . <nl> - swift : : _SwiftHashingSeed seed = { 0 , 0 } ; <nl> - arc4random_buf ( & seed , sizeof ( seed ) ) ; <nl> - return seed ; <nl> + __swift_uint64_t seed0 = 0 , seed1 = 0 ; <nl> + arc4random_buf ( & seed0 , sizeof ( seed0 ) ) ; <nl> + arc4random_buf ( & seed1 , sizeof ( seed1 ) ) ; <nl> + return { seed0 , seed1 , false } ; <nl> # else <nl> std : : random_device randomDevice ; <nl> std : : mt19937_64 engine ( randomDevice ( ) ) ; <nl> std : : uniform_int_distribution < __swift_uint64_t > distribution ; <nl> - return { distribution ( engine ) , distribution ( engine ) } ; <nl> + return { distribution ( engine ) , distribution ( engine ) , false } ; <nl> # endif <nl> } <nl> <nl> - static __swift_bool initializeHashingDeterminism ( ) { <nl> - / / Setting the environment variable SWIFT_DETERMINISTIC_HASHING to " 1 " <nl> - / / disables randomized hash seeding . This is useful in cases we need to ensure <nl> - / / results are repeatable , e . g . , in certain test environments . ( Note that <nl> - / / even if the seed override is enabled , hash values aren ' t guaranteed to <nl> - / / remain stable across even minor stdlib releases . ) <nl> - auto determinism = getenv ( " SWIFT_DETERMINISTIC_HASHING " ) ; <nl> - return determinism & & 0 = = strcmp ( determinism , " 1 " ) ; <nl> - } <nl> - <nl> SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_BEGIN <nl> - swift : : _SwiftHashingSeed swift : : _swift_stdlib_Hashing_seed = <nl> - initializeHashingSeed ( ) ; <nl> - __swift_bool swift : : _swift_stdlib_Hashing_deterministicHashing = <nl> - initializeHashingDeterminism ( ) ; <nl> + swift : : _SwiftHashingParameters swift : : _swift_stdlib_Hashing_parameters = <nl> + initializeHashingParameters ( ) ; <nl> SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_END <nl> <nl> <nl>
|
Merge remote - tracking branch ' origin / master ' into master - next
|
apple/swift
|
88908235a7ecf94176880dbb5f3ec7d3239fa982
|
2018-03-15T21:09:10Z
|
mmm a / AirLib / include / common / VectorMath . hpp <nl> ppp b / AirLib / include / common / VectorMath . hpp <nl> class VectorMathT { <nl> public : <nl> / / IMPORTANT : make sure fixed size vectorizable types have no alignment assumption <nl> / / https : / / eigen . tuxfamily . org / dox / group__TopicUnalignedArrayAssert . html <nl> - typedef Eigen : : Matrix < float , 1 , 1 > Vector1f ; <nl> - typedef Eigen : : Matrix < double , 1 , 1 > Vector1d ; <nl> - typedef Eigen : : Matrix < float , 2 , 1 , Eigen : : DontAlign > Vector2f ; <nl> - typedef Eigen : : Matrix < double , 4 , 1 , Eigen : : DontAlign > Vector2d ; <nl> + typedef Eigen : : Matrix < float , 1 , 1 > Vector1f ; <nl> + typedef Eigen : : Matrix < double , 1 , 1 > Vector1d ; <nl> + typedef Eigen : : Matrix < float , 2 , 1 , Eigen : : DontAlign > Vector2f ; <nl> + typedef Eigen : : Matrix < double , 4 , 1 , Eigen : : DontAlign > Vector2d ; <nl> typedef Eigen : : Vector3f Vector3f ; <nl> - typedef Eigen : : Vector3d Vector3d ; <nl> - typedef Eigen : : Array3f Array3f ; <nl> - typedef Eigen : : Array3d Array3d ; <nl> + typedef Eigen : : Vector3d Vector3d ; <nl> + typedef Eigen : : Array3f Array3f ; <nl> + typedef Eigen : : Array3d Array3d ; <nl> typedef Eigen : : Quaternion < float , Eigen : : DontAlign > Quaternionf ; <nl> typedef Eigen : : Quaternion < double , Eigen : : DontAlign > Quaterniond ; <nl> - typedef Eigen : : Matrix < double , 3 , 3 > Matrix3x3d ; <nl> + typedef Eigen : : Matrix < double , 3 , 3 > Matrix3x3d ; <nl> typedef Eigen : : Matrix < float , 3 , 3 > Matrix3x3f ; <nl> typedef Eigen : : AngleAxisd AngleAxisd ; <nl> typedef Eigen : : AngleAxisf AngleAxisf ; <nl> class VectorMathT { <nl> typedef common_utils : : RandomGenerator < RealT , std : : uniform_real_distribution < RealT > , 3 > RandomGeneratorZT ; <nl> <nl> struct Pose { <nl> - EIGEN_MAKE_ALIGNED_OPERATOR_NEW <nl> - Vector3T position ; <nl> - QuaternionT orientation ; <nl> + EIGEN_MAKE_ALIGNED_OPERATOR_NEW <nl> + Vector3T position ; <nl> + QuaternionT orientation ; <nl> <nl> - Pose ( ) <nl> - { } <nl> + Pose ( ) <nl> + { } <nl> <nl> Pose ( Vector3T position_val , QuaternionT orientation_val ) <nl> { <nl> class VectorMathT { <nl> position = position_val ; <nl> } <nl> <nl> - friend Pose operator - ( const Pose & lhs , const Pose & rhs ) <nl> - { <nl> - return VectorMathT : : subtract ( lhs , rhs ) ; <nl> - } <nl> + friend Pose operator - ( const Pose & lhs , const Pose & rhs ) <nl> + { <nl> + return VectorMathT : : subtract ( lhs , rhs ) ; <nl> + } <nl> + static friend bool operator = = ( const Pose & lhs , const Pose & rhs ) <nl> + { <nl> + return lhs . position = = rhs . position & & lhs . orientation . coeffs ( ) = = rhs . orientation . coeffs ( ) ; <nl> + } <nl> + static friend bool operator ! = ( const Pose & lhs , const Pose & rhs ) <nl> + { <nl> + return ! ( lhs = = rhs ) ; ; <nl> + } <nl> <nl> static Pose nanPose ( ) <nl> { <nl> class VectorMathT { <nl> } <nl> <nl> static QuaternionT negate ( const QuaternionT & q ) <nl> - { <nl> - / / from Gazebo implementation <nl> - return QuaternionT ( - q . w ( ) , - q . x ( ) , - q . y ( ) , - q . z ( ) ) ; <nl> - } <nl> + { <nl> + / / from Gazebo implementation <nl> + return QuaternionT ( - q . w ( ) , - q . x ( ) , - q . y ( ) , - q . z ( ) ) ; <nl> + } <nl> <nl> <nl> static Vector3T getRandomVectorFromGaussian ( RealT stddev = 1 , RealT mean = 0 ) <nl> class VectorMathT { <nl> return Vector3T ( wx , wy , wz ) ; <nl> } <nl> <nl> - static Vector3T nanVector ( ) <nl> - { <nl> + static Vector3T nanVector ( ) <nl> + { <nl> static const Vector3T val ( std : : numeric_limits < RealT > : : quiet_NaN ( ) , std : : numeric_limits < RealT > : : quiet_NaN ( ) , std : : numeric_limits < RealT > : : quiet_NaN ( ) ) ; <nl> return val ; <nl> - } <nl> + } <nl> <nl> - static QuaternionT nanQuaternion ( ) <nl> - { <nl> - return QuaternionT ( std : : numeric_limits < RealT > : : quiet_NaN ( ) , std : : numeric_limits < RealT > : : quiet_NaN ( ) , <nl> - std : : numeric_limits < RealT > : : quiet_NaN ( ) , std : : numeric_limits < RealT > : : quiet_NaN ( ) ) ; <nl> - } <nl> + static QuaternionT nanQuaternion ( ) <nl> + { <nl> + return QuaternionT ( std : : numeric_limits < RealT > : : quiet_NaN ( ) , std : : numeric_limits < RealT > : : quiet_NaN ( ) , <nl> + std : : numeric_limits < RealT > : : quiet_NaN ( ) , std : : numeric_limits < RealT > : : quiet_NaN ( ) ) ; <nl> + } <nl> <nl> static bool hasNan ( const Vector3T & v ) <nl> { <nl> class VectorMathT { <nl> return q ; <nl> } <nl> <nl> - / / from http : / / osrf - distributions . s3 . amazonaws . com / gazebo / api / dev / Pose_8hh_source . html <nl> - static Vector3T coordPositionSubtract ( const Pose & lhs , const Pose & rhs ) <nl> - { <nl> - QuaternionT tmp ( 0 , <nl> - lhs . position . x ( ) - rhs . position . x ( ) , <nl> - lhs . position . y ( ) - rhs . position . y ( ) , <nl> - lhs . position . z ( ) - rhs . position . z ( ) <nl> - ) ; <nl> - <nl> - tmp = rhs . orientation . inverse ( ) * ( tmp * rhs . orientation ) ; <nl> - <nl> - return tmp . vec ( ) ; <nl> - } <nl> - static QuaternionT coordOrientationSubtract ( const QuaternionT & lhs , const QuaternionT & rhs ) <nl> - { <nl> - QuaternionT result ( rhs . inverse ( ) * lhs ) ; <nl> - result . normalize ( ) ; <nl> - return result ; <nl> - } <nl> - static Pose subtract ( const Pose & lhs , const Pose & rhs ) <nl> - { <nl> - return Pose ( coordPositionSubtract ( lhs , rhs ) , coordOrientationSubtract ( lhs . orientation , rhs . orientation ) ) ; <nl> - } <nl> + / / from http : / / osrf - distributions . s3 . amazonaws . com / gazebo / api / dev / Pose_8hh_source . html <nl> + static Vector3T coordPositionSubtract ( const Pose & lhs , const Pose & rhs ) <nl> + { <nl> + QuaternionT tmp ( 0 , <nl> + lhs . position . x ( ) - rhs . position . x ( ) , <nl> + lhs . position . y ( ) - rhs . position . y ( ) , <nl> + lhs . position . z ( ) - rhs . position . z ( ) <nl> + ) ; <nl> + <nl> + tmp = rhs . orientation . inverse ( ) * ( tmp * rhs . orientation ) ; <nl> + <nl> + return tmp . vec ( ) ; <nl> + } <nl> + static QuaternionT coordOrientationSubtract ( const QuaternionT & lhs , const QuaternionT & rhs ) <nl> + { <nl> + QuaternionT result ( rhs . inverse ( ) * lhs ) ; <nl> + result . normalize ( ) ; <nl> + return result ; <nl> + } <nl> + static Pose subtract ( const Pose & lhs , const Pose & rhs ) <nl> + { <nl> + return Pose ( coordPositionSubtract ( lhs , rhs ) , coordOrientationSubtract ( lhs . orientation , rhs . orientation ) ) ; <nl> + } <nl> <nl> <nl> static std : : string toString ( const Vector3T & vect , const char * prefix = nullptr ) <nl> class VectorMathT { <nl> return angle ; <nl> } <nl> <nl> - / * * <nl> - * \ brief Extracts the yaw part from a quaternion , using RPY / euler ( z - y ' - z ' ' ) angles . <nl> - * RPY rotates about the fixed axes in the order x - y - z , <nl> - * which is the same as euler angles in the order z - y ' - x ' ' . <nl> - * / <nl> - static RealT yawFromQuaternion ( const QuaternionT & q ) { <nl> - return atan2 ( 2 . 0 * ( q . w ( ) * q . z ( ) + q . x ( ) * q . y ( ) ) , <nl> - 1 . 0 - 2 . 0 * ( q . y ( ) * q . y ( ) + q . z ( ) * q . z ( ) ) ) ; <nl> - } <nl> - <nl> - static QuaternionT quaternionFromYaw ( RealT yaw ) { <nl> - return QuaternionT ( Eigen : : AngleAxisd ( yaw , Vector3T : : UnitZ ( ) ) ) ; <nl> - } <nl> + / * * <nl> + * \ brief Extracts the yaw part from a quaternion , using RPY / euler ( z - y ' - z ' ' ) angles . <nl> + * RPY rotates about the fixed axes in the order x - y - z , <nl> + * which is the same as euler angles in the order z - y ' - x ' ' . <nl> + * / <nl> + static RealT yawFromQuaternion ( const QuaternionT & q ) { <nl> + return atan2 ( 2 . 0 * ( q . w ( ) * q . z ( ) + q . x ( ) * q . y ( ) ) , <nl> + 1 . 0 - 2 . 0 * ( q . y ( ) * q . y ( ) + q . z ( ) * q . z ( ) ) ) ; <nl> + } <nl> + <nl> + static QuaternionT quaternionFromYaw ( RealT yaw ) { <nl> + return QuaternionT ( Eigen : : AngleAxisd ( yaw , Vector3T : : UnitZ ( ) ) ) ; <nl> + } <nl> } ; <nl> typedef VectorMathT < Eigen : : Vector3d , Eigen : : Quaternion < double , Eigen : : DontAlign > , double > VectorMathd ; <nl> typedef VectorMathT < Eigen : : Vector3f , Eigen : : Quaternion < float , Eigen : : DontAlign > , float > VectorMathf ; <nl> mmm a / Unreal / Environments / Blocks / Config / DefaultInput . ini <nl> ppp b / Unreal / Environments / Blocks / Config / DefaultInput . ini <nl> bEnableMouseSmoothing = True <nl> bEnableFOVScaling = True <nl> FOVScale = 0 . 011110 <nl> DoubleClickTime = 0 . 200000 <nl> - bCaptureMouseOnLaunch = True <nl> + bCaptureMouseOnLaunch = False <nl> DefaultViewportMouseCaptureMode = NoCapture <nl> bDefaultViewportMouseLock = True <nl> DefaultViewportMouseLockMode = DoNotLock <nl> similarity index 100 % <nl> rename from Unreal / Environments / Blocks / clean_build . bat <nl> rename to Unreal / Environments / Blocks / clean . bat <nl> similarity index 100 % <nl> rename from Unreal / Environments / Blocks / clean_build . sh <nl> rename to Unreal / Environments / Blocks / clean . sh <nl> mmm a / Unreal / Plugins / AirSim / Source / MultiRotorConnector . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / MultiRotorConnector . cpp <nl> void MultiRotorConnector : : initialize ( AFlyingPawn * vehicle_pawn , msr : : airlib : : Mul <nl> memset ( rotor_info_ , 0 , sizeof ( RotorInfo ) * rotor_count_ ) ; <nl> } <nl> <nl> + msr : : airlib : : VehicleCameraBase * MultiRotorConnector : : getCamera ( unsigned int index ) <nl> + { <nl> + return camera_connectors_ . at ( index ) . get ( ) ; <nl> + } <nl> + <nl> MultiRotorConnector : : ~ MultiRotorConnector ( ) <nl> { <nl> delete [ ] rotor_info_ ; <nl> mmm a / Unreal / Plugins / AirSim / Source / MultiRotorConnector . h <nl> ppp b / Unreal / Plugins / AirSim / Source / MultiRotorConnector . h <nl> class MultiRotorConnector : public VehicleConnectorBase <nl> virtual void reportState ( StateReporter & reporter ) override ; <nl> virtual UpdatableObject * getPhysicsBody ( ) override ; <nl> <nl> + virtual msr : : airlib : : VehicleCameraBase * getCamera ( unsigned int index = 0 ) override ; <nl> + <nl> private : <nl> void detectUsbRc ( ) ; <nl> static float joyStickToRC ( int16_t val ) ; <nl> mmm a / Unreal / Plugins / AirSim / Source / PIPCamera . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / PIPCamera . cpp <nl> void APIPCamera : : PostInitializeComponents ( ) <nl> screen_capture_ = UAirBlueprintLib : : GetActorComponent < USceneCaptureComponent2D > ( this , TEXT ( " SceneCaptureComponent " ) ) ; <nl> depth_capture_ = UAirBlueprintLib : : GetActorComponent < USceneCaptureComponent2D > ( this , TEXT ( " DepthCaptureComponent " ) ) ; <nl> seg_capture_ = UAirBlueprintLib : : GetActorComponent < USceneCaptureComponent2D > ( this , TEXT ( " SegmentationCaptureComponent " ) ) ; <nl> + <nl> + / / set default for brigher images <nl> + scene_capture_settings_ . target_gamma = CaptureSettings : : kSceneTargetGamma ; <nl> } <nl> <nl> void APIPCamera : : BeginPlay ( ) <nl> void APIPCamera : : BeginPlay ( ) <nl> <nl> scene_render_target_ = NewObject < UTextureRenderTarget2D > ( ) ; <nl> setCaptureSettings ( ImageType_ : : Scene , scene_capture_settings_ ) ; <nl> - scene_render_target_ - > TargetGamma = 1 . 0f ; / / GEngine - > GetDisplayGamma ( ) ; <nl> / / scene_render_target_ - > bHDR = false ; <nl> - / / scene_render_target_ - > InitAutoFormat ( 960 , 540 ) ; / / 256 X 144 , X 480 <nl> <nl> depth_render_target_ = NewObject < UTextureRenderTarget2D > ( ) ; <nl> setCaptureSettings ( ImageType_ : : Depth , depth_capture_settings_ ) ; <nl> - depth_render_target_ - > TargetGamma = 1 . 0f ; <nl> - / / depth_render_target_ - > InitAutoFormat ( 960 , 540 ) ; <nl> <nl> seg_render_target_ = NewObject < UTextureRenderTarget2D > ( ) ; <nl> setCaptureSettings ( ImageType_ : : Segmentation , seg_capture_settings_ ) ; <nl> - seg_render_target_ - > TargetGamma = 1 . 0f ; <nl> - / / seg_render_target_ - > InitAutoFormat ( 960 , 540 ) ; <nl> } <nl> <nl> void APIPCamera : : EndPlay ( const EEndPlayReason : : Type EndPlayReason ) <nl> void APIPCamera : : setCaptureSettings ( APIPCamera : : ImageType_ type , const APIPCamer <nl> <nl> void APIPCamera : : updateCaptureComponentSettings ( USceneCaptureComponent2D * capture , UTextureRenderTarget2D * render_target , const CaptureSettings & settings ) <nl> { <nl> - if ( render_target ) <nl> + if ( render_target ) { <nl> render_target - > InitAutoFormat ( settings . width , settings . height ) ; / / 256 X 144 , X 480 <nl> + render_target - > TargetGamma = settings . target_gamma ; <nl> + } <nl> / / else we will set this after this components get created <nl> <nl> if ( capture ) { <nl> capture - > FOVAngle = settings . fov_degrees ; <nl> capture - > PostProcessSettings . AutoExposureSpeedDown = capture - > PostProcessSettings . AutoExposureSpeedUp = settings . auto_exposure_speed ; <nl> + capture - > PostProcessSettings . AutoExposureMaxBrightness = capture - > PostProcessSettings . AutoExposureMinBrightness = 1 . 0f ; <nl> + capture - > PostProcessSettings . AutoExposureBias = 1 . 0f ; <nl> capture - > PostProcessSettings . MotionBlurAmount = settings . motion_blur_amount ; <nl> } <nl> / / else we will set this after this components get created <nl> mmm a / Unreal / Plugins / AirSim / Source / PIPCamera . h <nl> ppp b / Unreal / Plugins / AirSim / Source / PIPCamera . h <nl> class AIRSIM_API APIPCamera : public ACameraActor <nl> <nl> public : <nl> struct CaptureSettings { <nl> + static constexpr float kSceneTargetGamma = 1 . 4f ; <nl> + <nl> unsigned int width = 256 , height = 144 ; / / 960 X 540 <nl> float fov_degrees = 90 ; <nl> float auto_exposure_speed = 100 . 0f ; <nl> + float auto_exposure_bias = 1 . 0f ; <nl> + float auto_exposure_max_brightness = 1 . 0f ; <nl> + float auto_exposure_min_brightness = 1 . 0f ; <nl> float motion_blur_amount = 0 . 0f ; <nl> + float target_gamma = 1 . 0f ; / / should be defaulted to kSceneTargetGamma for scene <nl> } ; <nl> <nl> public : <nl> mmm a / Unreal / Plugins / AirSim / Source / Recording / RecordingFile . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / Recording / RecordingFile . cpp <nl> <nl> # include < AirSim . h > <nl> + # include < sstream > <nl> # include " ImageUtils . h " <nl> # include " common / ClockFactory . hpp " <nl> # include " common / common_utils / FileSystem . hpp " <nl> <nl> - void RecordingFile : : appendRecord ( FString image_path , TArray < uint8 > & compressedPng , const msr : : airlib : : PhysicsBody * physics_body ) <nl> + RecordingFile : : RecordingFile ( ) <nl> + : image_path_ ( FString ( common_utils : : FileSystem : : getLogFileNamePath ( " img_ " , " " , " " , false ) . c_str ( ) ) ) , <nl> + log_file_handle_ ( nullptr ) <nl> { <nl> - if ( compressedPng . Num ( ) = = 0 ) <nl> + } <nl> + <nl> + void RecordingFile : : appendRecord ( TArray < uint8 > & image_data , const msr : : airlib : : PhysicsBody * physics_body ) <nl> + { <nl> + if ( image_data . Num ( ) = = 0 ) <nl> return ; <nl> <nl> - FString filePath = image_path + FString : : FromInt ( images_saved_ ) + " . png " ; <nl> - bool imageSavedOk = FFileHelper : : SaveArrayToFile ( compressedPng , * filePath ) ; <nl> + FString filePath = image_path_ + FString : : FromInt ( images_saved_ ) + " . png " ; <nl> + bool imageSavedOk = FFileHelper : : SaveArrayToFile ( image_data , * filePath ) ; <nl> <nl> / / If render command is complete , save image along with position and orientation <nl> <nl> void RecordingFile : : appendRecord ( FString image_path , TArray < uint8 > & compressedPn <nl> <nl> uint64_t timestamp_millis = static_cast < uint64_t > ( msr : : airlib : : ClockFactory : : get ( ) - > nowNanos ( ) / 1 . 0E6 ) ; <nl> <nl> - record_file < < timestamp_millis < < " \ t " ; <nl> - record_file < < kinematics . pose . position . x ( ) < < " \ t " < < kinematics . pose . position . y ( ) < < " \ t " < < kinematics . pose . position . z ( ) < < " \ t " ; <nl> - record_file < < kinematics . pose . orientation . w ( ) < < " \ t " < < kinematics . pose . orientation . x ( ) < < " \ t " < < kinematics . pose . orientation . y ( ) < < " \ t " < < kinematics . pose . orientation . z ( ) < < " \ t " ; <nl> - record_file < < " \ n " ; <nl> + std : : stringstream ss ; <nl> + ss < < timestamp_millis < < " \ t " ; <nl> + ss < < kinematics . pose . position . x ( ) < < " \ t " < < kinematics . pose . position . y ( ) < < " \ t " < < kinematics . pose . position . z ( ) < < " \ t " ; <nl> + ss < < kinematics . pose . orientation . w ( ) < < " \ t " < < kinematics . pose . orientation . x ( ) < < " \ t " < < kinematics . pose . orientation . y ( ) < < " \ t " < < kinematics . pose . orientation . z ( ) < < " \ t " ; <nl> + ss < < " \ n " ; <nl> + <nl> + writeLine ( ss . str ( ) ) ; <nl> <nl> UAirBlueprintLib : : LogMessage ( TEXT ( " Screenshot saved to : " ) , filePath , LogDebugLevel : : Success ) ; <nl> images_saved_ + + ; <nl> } <nl> } <nl> <nl> - void RecordingFile : : startRecording ( ) <nl> + void RecordingFile : : createFile ( const std : : string & file_path ) <nl> { <nl> - if ( record_file . is_open ( ) ) { <nl> - record_file . close ( ) ; <nl> - UAirBlueprintLib : : LogMessage ( TEXT ( " Recording Error " ) , TEXT ( " File was already open " ) , LogDebugLevel : : Failure ) ; <nl> - } <nl> + closeFile ( ) ; <nl> + <nl> + IPlatformFile & platform_file = FPlatformFileManager : : Get ( ) . GetPlatformFile ( ) ; <nl> + log_file_handle_ = platform_file . OpenWrite ( * FString ( file_path . c_str ( ) ) ) ; <nl> + } <nl> + <nl> + bool RecordingFile : : isFileOpen ( ) <nl> + { <nl> + return log_file_handle_ ! = nullptr ; <nl> + } <nl> + <nl> + void RecordingFile : : closeFile ( ) <nl> + { <nl> + if ( isFileOpen ( ) ) <nl> + delete log_file_handle_ ; <nl> + <nl> + log_file_handle_ = nullptr ; <nl> + } <nl> + <nl> + void RecordingFile : : writeLine ( const std : : string & line ) <nl> + { <nl> + <nl> + } <nl> + <nl> + RecordingFile : : ~ RecordingFile ( ) <nl> + { <nl> + closeFile ( ) ; <nl> + } <nl> <nl> + void RecordingFile : : startRecording ( ) <nl> + { <nl> std : : string fullPath = common_utils : : FileSystem : : getLogFileNamePath ( record_filename , " " , " . txt " , true ) ; <nl> - common_utils : : FileSystem : : createTextFile ( fullPath , record_file ) ; <nl> + createFile ( fullPath ) ; <nl> <nl> - if ( record_file . is_open ( ) ) { <nl> + if ( isFileOpen ( ) ) { <nl> is_recording_ = true ; <nl> <nl> UAirBlueprintLib : : LogMessage ( TEXT ( " Recording " ) , TEXT ( " Started " ) , LogDebugLevel : : Success ) ; <nl> void RecordingFile : : startRecording ( ) <nl> void RecordingFile : : stopRecording ( ) <nl> { <nl> is_recording_ = false ; <nl> - if ( ! record_file . is_open ( ) ) { <nl> + if ( isFileOpen ( ) ) { <nl> UAirBlueprintLib : : LogMessage ( TEXT ( " Recording Error " ) , TEXT ( " File was not open " ) , LogDebugLevel : : Failure ) ; <nl> } <nl> else <nl> - record_file . close ( ) ; <nl> + closeFile ( ) ; <nl> <nl> UAirBlueprintLib : : LogMessage ( TEXT ( " Recording " ) , TEXT ( " Stopped " ) , LogDebugLevel : : Success ) ; <nl> } <nl> mmm a / Unreal / Plugins / AirSim / Source / Recording / RecordingFile . h <nl> ppp b / Unreal / Plugins / AirSim / Source / Recording / RecordingFile . h <nl> <nl> + # pragma once <nl> + <nl> + # include < string > <nl> # include " AirBlueprintLib . h " <nl> # include " physics / PhysicsBody . hpp " <nl> + # include " FileManager . h " <nl> <nl> + / / TODO : move struct to its own file ? <nl> + struct RecordingSettings { <nl> + bool record_on_move = true ; <nl> + float record_interval = 0 . 05f ; <nl> + } ; <nl> <nl> class RecordingFile { <nl> public : <nl> - void appendRecord ( FString image_path , TArray < uint8 > & compressedPng , const msr : : airlib : : PhysicsBody * physics_body ) ; <nl> + RecordingFile ( ) ; <nl> + ~ RecordingFile ( ) ; <nl> + <nl> + void appendRecord ( TArray < uint8 > & compressedPng , const msr : : airlib : : PhysicsBody * physics_body ) ; <nl> void startRecording ( ) ; <nl> void stopRecording ( ) ; <nl> bool isRecording ( ) ; <nl> void initializeForPlay ( ) ; <nl> <nl> private : <nl> - std : : ofstream record_file ; <nl> + void createFile ( const std : : string & file_path ) ; <nl> + void closeFile ( ) ; <nl> + void writeLine ( const std : : string & line ) ; <nl> + bool isFileOpen ( ) ; <nl> + <nl> + <nl> + private : <nl> std : : string record_filename = " airsim_rec " ; <nl> unsigned int images_saved_ = 0 ; <nl> + FString image_path_ ; <nl> bool is_recording_ ; <nl> + <nl> + IFileHandle * log_file_handle_ ; <nl> } ; <nl> \ No newline at end of file <nl> mmm a / Unreal / Plugins / AirSim / Source / Recording / RecordingThread . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / Recording / RecordingThread . cpp <nl> <nl> # include " PIPCamera . h " <nl> <nl> <nl> - FRecordingThread * FRecordingThread : : Runnable = NULL ; <nl> + FRecordingThread * FRecordingThread : : instance_ = NULL ; <nl> <nl> - FRecordingThread : : FRecordingThread ( FString path , ASimModeBase * sim_mode , const msr : : airlib : : PhysicsBody * fpv_physics_body ) <nl> - : image_path_ ( path ) , sim_mode_ ( sim_mode ) , fpv_physics_body_ ( fpv_physics_body ) , stop_task_counter_ ( 0 ) <nl> + FRecordingThread : : FRecordingThread ( ) <nl> + : stop_task_counter_ ( 0 ) , camera_ ( nullptr ) , recording_file_ ( nullptr ) , fpv_physics_body_ ( nullptr ) , is_ready_ ( false ) <nl> { <nl> thread_ = FRunnableThread : : Create ( this , TEXT ( " FRecordingThread " ) , 0 , TPri_BelowNormal ) ; / / Windows default , possible to specify more priority <nl> } <nl> <nl> <nl> - FRecordingThread * FRecordingThread : : ThreadInit ( FString path , ASimModeBase * sim_mode , const msr : : airlib : : PhysicsBody * fpv_physics_body ) <nl> + FRecordingThread * FRecordingThread : : ThreadInit ( msr : : airlib : : VehicleCameraBase * camera , RecordingFile * recording_file , const msr : : airlib : : PhysicsBody * fpv_physics_body , const RecordingSettings & settings ) <nl> { <nl> - if ( ! Runnable & & FPlatformProcess : : SupportsMultithreading ( ) ) <nl> + if ( ! instance_ & & FPlatformProcess : : SupportsMultithreading ( ) ) <nl> { <nl> - Runnable = new FRecordingThread ( path , sim_mode , fpv_physics_body ) ; <nl> + instance_ = new FRecordingThread ( ) ; <nl> + instance_ - > camera_ = camera ; <nl> + instance_ - > recording_file_ = recording_file ; <nl> + instance_ - > fpv_physics_body_ = fpv_physics_body ; <nl> + instance_ - > settings_ = settings ; <nl> + <nl> + instance_ - > last_screenshot_on_ = 0 ; <nl> + instance_ - > last_pose_ = msr : : airlib : : Pose ( ) ; <nl> + <nl> + instance_ - > is_ready_ = true ; <nl> } <nl> - return Runnable ; <nl> + return instance_ ; <nl> } <nl> <nl> FRecordingThread : : ~ FRecordingThread ( ) <nl> FRecordingThread : : ~ FRecordingThread ( ) <nl> <nl> bool FRecordingThread : : Init ( ) <nl> { <nl> - if ( sim_mode_ ) <nl> + if ( camera_ & & recording_file_ ) <nl> { <nl> UAirBlueprintLib : : LogMessage ( TEXT ( " Initiated recording thread " ) , TEXT ( " " ) , LogDebugLevel : : Success ) ; <nl> } <nl> uint32 FRecordingThread : : Run ( ) <nl> { <nl> while ( stop_task_counter_ . GetValue ( ) = = 0 ) <nl> { <nl> - APIPCamera * cam = sim_mode_ - > getFpvVehiclePawn ( ) - > getCamera ( ) ; <nl> - if ( cam ! = nullptr ) <nl> - { <nl> - / / todo : should we go as fast as possible , or should we limit this to a particular number of <nl> - / / frames per second ? <nl> - USceneCaptureComponent2D * capture = cam - > getCaptureComponent ( msr : : airlib : : VehicleCameraBase : : ImageType_ : : Scene , false ) ; <nl> - if ( capture ! = nullptr ) { <nl> - UTextureRenderTarget2D * renderTarget = capture - > TextureTarget ; <nl> - if ( renderTarget ! = nullptr ) { <nl> - TArray < uint8 > image_data ; <nl> - RenderRequest request ( false ) ; <nl> - int width , height ; <nl> - request . getScreenshot ( renderTarget , image_data , false , true , width , height ) ; <nl> - SaveImage ( image_data ) ; <nl> - } <nl> + / / make sire all vars are set up <nl> + if ( is_ready_ ) { <nl> + bool interval_elapsed = msr : : airlib : : ClockFactory : : get ( ) - > elapsedSince ( last_screenshot_on_ ) > settings_ . record_interval ; <nl> + bool is_pose_unequal = fpv_physics_body_ & & last_pose_ ! = fpv_physics_body_ - > getKinematics ( ) . pose ; <nl> + if ( interval_elapsed & & ( ! settings_ . record_on_move | | is_pose_unequal ) ) <nl> + { <nl> + last_screenshot_on_ = msr : : airlib : : ClockFactory : : get ( ) - > nowNanos ( ) ; <nl> + last_pose_ = fpv_physics_body_ - > getKinematics ( ) . pose ; <nl> + <nl> + / / todo : should we go as fast as possible , or should we limit this to a particular number of <nl> + / / frames per second ? <nl> + auto response = camera_ - > getImage ( msr : : airlib : : VehicleCameraBase : : ImageType_ : : Scene , false , true ) ; <nl> + TArray < uint8_t > image_data ; <nl> + image_data . Append ( response . image_data . data ( ) , response . image_data . size ( ) ) ; <nl> + recording_file_ - > appendRecord ( image_data , fpv_physics_body_ ) ; <nl> } <nl> } <nl> } <nl> return 0 ; <nl> } <nl> <nl> - void FRecordingThread : : SaveImage ( TArray < uint8 > & image_data ) <nl> - { <nl> - sim_mode_ - > getRecordingFile ( ) . appendRecord ( image_path_ , image_data , fpv_physics_body_ ) ; <nl> - } <nl> <nl> void FRecordingThread : : Stop ( ) <nl> { <nl> void FRecordingThread : : EnsureCompletion ( ) <nl> <nl> void FRecordingThread : : Shutdown ( ) <nl> { <nl> - if ( Runnable ) <nl> + if ( instance_ ) <nl> { <nl> - Runnable - > EnsureCompletion ( ) ; <nl> - delete Runnable ; <nl> - Runnable = NULL ; <nl> + instance_ - > EnsureCompletion ( ) ; <nl> + delete instance_ ; <nl> + instance_ = NULL ; <nl> } <nl> } <nl> \ No newline at end of file <nl> mmm a / Unreal / Plugins / AirSim / Source / Recording / RecordingThread . h <nl> ppp b / Unreal / Plugins / AirSim / Source / Recording / RecordingThread . h <nl> <nl> # pragma once <nl> <nl> # include " AirBlueprintLib . h " <nl> - # include " SimMode / SimModeBase . h " <nl> + # include " VehicleCameraConnector . h " <nl> + # include " Recording / RecordingFile . h " <nl> # include " physics / PhysicsBody . hpp " <nl> - <nl> + # include " common / ClockFactory . hpp " <nl> <nl> class FRecordingThread : public FRunnable <nl> { <nl> + public : <nl> + FRecordingThread ( ) ; <nl> + virtual ~ FRecordingThread ( ) ; <nl> + static FRecordingThread * ThreadInit ( msr : : airlib : : VehicleCameraBase * camera , RecordingFile * recording_file , const msr : : airlib : : PhysicsBody * fpv_physics_body , const RecordingSettings & settings ) ; <nl> + static void Shutdown ( ) ; <nl> + <nl> + private : <nl> + virtual bool Init ( ) ; <nl> + virtual uint32 Run ( ) ; <nl> + virtual void Stop ( ) ; <nl> + <nl> + void EnsureCompletion ( ) ; <nl> + <nl> private : <nl> FString image_path_ ; <nl> - ASimModeBase * sim_mode_ ; <nl> + msr : : airlib : : VehicleCameraBase * camera_ ; <nl> + RecordingFile * recording_file_ ; <nl> const msr : : airlib : : PhysicsBody * fpv_physics_body_ ; <nl> <nl> - static FRecordingThread * Runnable ; <nl> + static FRecordingThread * instance_ ; <nl> FRunnableThread * thread_ ; <nl> <nl> FThreadSafeCounter stop_task_counter_ ; <nl> FRenderCommandFence read_pixel_fence_ ; <nl> <nl> - public : <nl> - FRecordingThread ( FString imagePath , ASimModeBase * sim_mode , const msr : : airlib : : PhysicsBody * fpv_physics_body ) ; <nl> - virtual ~ FRecordingThread ( ) ; <nl> - static FRecordingThread * ThreadInit ( FString path , ASimModeBase * sim_mode , const msr : : airlib : : PhysicsBody * fpv_physics_body ) ; <nl> - static void Shutdown ( ) ; <nl> + RecordingSettings settings_ ; <nl> <nl> - private : <nl> - virtual bool Init ( ) ; <nl> - virtual uint32 Run ( ) ; <nl> - virtual void Stop ( ) ; <nl> - void SaveImage ( TArray < uint8 > & image_data ) ; <nl> + msr : : airlib : : TTimePoint last_screenshot_on_ ; <nl> + msr : : airlib : : Pose last_pose_ ; <nl> <nl> - void EnsureCompletion ( ) ; <nl> + bool is_ready_ ; <nl> } ; <nl> \ No newline at end of file <nl> mmm a / Unreal / Plugins / AirSim / Source / SimMode / SimModeBase . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / SimMode / SimModeBase . cpp <nl> void ASimModeBase : : readSettings ( ) <nl> physics_engine_name = settings . getString ( " PhysicsEngineName " , " FastPhysicsEngine " ) ; <nl> usage_scenario = settings . getString ( " UsageScenario " , " " ) ; <nl> <nl> + Settings record_settings ; <nl> + if ( settings . getChild ( " Recording " , record_settings ) ) { <nl> + recording_settings . record_on_move = record_settings . getBool ( " RecordOnMove " , recording_settings . record_on_move ) ; <nl> + recording_settings . record_interval = record_settings . getFloat ( " RecordInterval " , recording_settings . record_interval ) ; <nl> + } <nl> + <nl> UAirBlueprintLib : : LogMessage ( " Vehicle name : " , fpv_vehicle_name . c_str ( ) , LogDebugLevel : : Informational ) ; <nl> } <nl> <nl> mmm a / Unreal / Plugins / AirSim / Source / SimMode / SimModeBase . h <nl> ppp b / Unreal / Plugins / AirSim / Source / SimMode / SimModeBase . h <nl> class AIRSIM_API ASimModeBase : public AActor <nl> std : : string fpv_vehicle_name ; <nl> std : : string physics_engine_name ; <nl> std : : string usage_scenario ; <nl> + RecordingSettings recording_settings ; <nl> <nl> private : <nl> void readSettings ( ) ; <nl> mmm a / Unreal / Plugins / AirSim / Source / SimMode / SimModeWorldMultiRotor . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / SimMode / SimModeWorldMultiRotor . cpp <nl> void ASimModeWorldMultiRotor : : Tick ( float DeltaSeconds ) <nl> if ( isRecording ( ) & & getRecordingFile ( ) . isRecording ( ) ) { <nl> if ( ! isLoggingStarted ) <nl> { <nl> - FString imagePathPrefix = common_utils : : FileSystem : : getLogFileNamePath ( " img_ " , " " , " " , false ) . c_str ( ) ; <nl> - FRecordingThread : : ThreadInit ( imagePathPrefix , this , static_cast < msr : : airlib : : PhysicsBody * > ( fpv_vehicle_connector_ - > getPhysicsBody ( ) ) ) ; <nl> + FRecordingThread : : ThreadInit ( fpv_vehicle_connector_ - > getCamera ( ) , & getRecordingFile ( ) , <nl> + static_cast < msr : : airlib : : PhysicsBody * > ( fpv_vehicle_connector_ - > getPhysicsBody ( ) ) , recording_settings ) ; <nl> isLoggingStarted = true ; <nl> } <nl> } <nl> mmm a / Unreal / Plugins / AirSim / Source / VehicleCameraConnector . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / VehicleCameraConnector . cpp <nl> msr : : airlib : : VehicleCameraBase : : ImageResponse VehicleCameraConnector : : getImage ( V <nl> return getSceneCaptureImage ( image_type , pixels_as_float , compress , false ) ; <nl> } <nl> <nl> - msr : : airlib : : VehicleCameraBase : : ImageResponse VehicleCameraConnector : : getSceneCaptureImage ( VehicleCameraConnector : : ImageType image_type , bool pixels_as_float , bool compress , bool use_safe_method ) <nl> + msr : : airlib : : VehicleCameraBase : : ImageResponse VehicleCameraConnector : : getSceneCaptureImage ( VehicleCameraConnector : : ImageType image_type , <nl> + bool pixels_as_float , bool compress , bool use_safe_method ) <nl> { <nl> bool visibilityChanged = false ; <nl> if ( ( camera_ - > getEnableCameraTypes ( ) & image_type ) = = ImageType_ : : None <nl> msr : : airlib : : VehicleCameraBase : : ImageResponse VehicleCameraConnector : : getSceneCa <nl> <nl> UTextureRenderTarget2D * textureTarget = capture - > TextureTarget ; <nl> <nl> - TArray < uint8 > image ; <nl> RenderRequest request ( use_safe_method ) ; <nl> int width , height ; <nl> + TArray < uint8 > image ; <nl> request . getScreenshot ( textureTarget , image , pixels_as_float , compress , width , height ) ; <nl> <nl> ImageResponse response ; <nl> mmm a / Unreal / Plugins / AirSim / Source / VehicleCameraConnector . h <nl> ppp b / Unreal / Plugins / AirSim / Source / VehicleCameraConnector . h <nl> class VehicleCameraConnector : public VehicleCameraBase <nl> virtual ImageResponse getImage ( ImageType image_type , bool pixels_as_float , bool compress ) override ; <nl> <nl> private : <nl> - msr : : airlib : : VehicleCameraBase : : ImageResponse getSceneCaptureImage ( ImageType image_type , bool pixels_as_float , bool compress , bool use_safe_method ) ; <nl> + msr : : airlib : : VehicleCameraBase : : ImageResponse getSceneCaptureImage ( ImageType image_type , <nl> + bool pixels_as_float , bool compress , bool use_safe_method ) ; <nl> <nl> void addScreenCaptureHandler ( UWorld * world ) ; <nl> bool getScreenshotScreen ( ImageType image_type , std : : vector < uint8_t > & compressedPng ) ; <nl> mmm a / Unreal / Plugins / AirSim / Source / VehicleConnectorBase . h <nl> ppp b / Unreal / Plugins / AirSim / Source / VehicleConnectorBase . h <nl> class VehicleConnectorBase : public msr : : airlib : : UpdatableObject <nl> virtual void stopApiServer ( ) = 0 ; <nl> virtual bool isApiServerStarted ( ) = 0 ; <nl> virtual msr : : airlib : : VehicleControllerBase * getController ( ) = 0 ; <nl> + virtual msr : : airlib : : VehicleCameraBase * getCamera ( unsigned int index = 0 ) = 0 ; <nl> } ; <nl> mmm a / Unreal / Plugins / AirSim / Source / VehiclePawnBase . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / VehiclePawnBase . cpp <nl> void AVehiclePawnBase : : setupCamerasFromSettings ( ) <nl> Settings & settings = Settings : : singleton ( ) ; <nl> Settings scene_settings_child , depth_settings_child , seg_settings_child ; <nl> APIPCamera : : CaptureSettings scene_settings , depth_settings , seg_settings ; <nl> + scene_settings . target_gamma = APIPCamera : : CaptureSettings : : kSceneTargetGamma ; <nl> if ( settings . getChild ( " SceneCaptureSettings " , scene_settings_child ) ) <nl> createCaptureSettings ( scene_settings_child , scene_settings ) ; <nl> if ( settings . getChild ( " DepthCaptureSettings " , depth_settings_child ) ) <nl> void AVehiclePawnBase : : createCaptureSettings ( const msr : : airlib : : Settings & settin <nl> capture_settings . height = settings . getInt ( " Height " , capture_settings . height ) ; <nl> capture_settings . fov_degrees = settings . getFloat ( " FOV_Degrees " , capture_settings . fov_degrees ) ; <nl> capture_settings . auto_exposure_speed = settings . getFloat ( " AutoExposureSpeed " , capture_settings . auto_exposure_speed ) ; <nl> + capture_settings . auto_exposure_bias = settings . getFloat ( " AutoExposureBias " , capture_settings . auto_exposure_bias ) ; <nl> + capture_settings . auto_exposure_max_brightness = settings . getFloat ( " AutoExposureMaxBrightness " , capture_settings . auto_exposure_max_brightness ) ; <nl> + capture_settings . auto_exposure_min_brightness = settings . getFloat ( " AutoExposureMinBrightness " , capture_settings . auto_exposure_min_brightness ) ; <nl> capture_settings . motion_blur_amount = settings . getFloat ( " MotionBlurAmount " , capture_settings . motion_blur_amount ) ; <nl> + capture_settings . target_gamma = settings . getFloat ( " TargetGamma " , capture_settings . target_gamma ) ; <nl> } <nl> <nl> void AVehiclePawnBase : : EndPlay ( const EEndPlayReason : : Type EndPlayReason ) <nl> new file mode 100644 <nl> index 000000000 . . b8e6b7a1f <nl> mmm / dev / null <nl> ppp b / clean . sh <nl> <nl> + rm - rf build_debug <nl> + rm - rf build_release <nl> \ No newline at end of file <nl>
|
recording switched to Unreal IO , config settings for recording and auto exposure
|
microsoft/AirSim
|
9d5f8c2392c668a17fab6dd8919e14457a9a6bd9
|
2017-07-13T10:55:11Z
|
mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> <nl> # endif <nl> <nl> # include " imgui . h " <nl> + # ifndef IMGUI_DEFINE_MATH_OPERATORS <nl> # define IMGUI_DEFINE_MATH_OPERATORS <nl> + # endif <nl> # include " imgui_internal . h " <nl> <nl> # include < ctype . h > / / toupper , isprint <nl> mmm a / imgui_draw . cpp <nl> ppp b / imgui_draw . cpp <nl> <nl> # endif <nl> <nl> # include " imgui . h " <nl> + # ifndef IMGUI_DEFINE_MATH_OPERATORS <nl> # define IMGUI_DEFINE_MATH_OPERATORS <nl> + # endif <nl> # include " imgui_internal . h " <nl> <nl> # include < stdio . h > / / vsnprintf , sscanf , printf <nl>
|
Fix warning when IMGUI_DEFINE_MATH_OPERATORS is already defined by build system . ( )
|
ocornut/imgui
|
7e59eb026b5e9ede5560492def408e65e1c01c20
|
2018-07-17T15:17:56Z
|
new file mode 100644 <nl> index 00000000000 . . 4ffd40ed1b9 <nl> mmm / dev / null <nl> ppp b / dbms / src / Functions / currentRowPolicies . cpp <nl> <nl> + # include < Functions / IFunction . h > <nl> + # include < Functions / FunctionFactory . h > <nl> + # include < DataTypes / DataTypeArray . h > <nl> + # include < DataTypes / DataTypeString . h > <nl> + # include < DataTypes / DataTypeTuple . h > <nl> + # include < DataTypes / DataTypeUUID . h > <nl> + # include < Columns / ColumnArray . h > <nl> + # include < Columns / ColumnConst . h > <nl> + # include < Columns / ColumnString . h > <nl> + # include < Columns / ColumnTuple . h > <nl> + # include < Interpreters / Context . h > <nl> + # include < Access / RowPolicyContext . h > <nl> + # include < Access / AccessControlManager . h > <nl> + # include < ext / range . h > <nl> + <nl> + <nl> + namespace DB <nl> + { <nl> + namespace ErrorCodes <nl> + { <nl> + extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH ; <nl> + extern const int ILLEGAL_TYPE_OF_ARGUMENT ; <nl> + } <nl> + <nl> + <nl> + / / / The currentRowPolicies ( ) function can be called with 0 . . 2 arguments : <nl> + / / / currentRowPolicies ( ) returns array of tuples ( database , table_name , row_policy_name ) for all the row policies applied for the current user ; <nl> + / / / currentRowPolicies ( table_name ) is equivalent to currentRowPolicies ( currentDatabase ( ) , table_name ) ; <nl> + / / / currentRowPolicies ( database , table_name ) returns array of names of the row policies applied to a specific table and for the current user . <nl> + class FunctionCurrentRowPolicies : public IFunction <nl> + { <nl> + public : <nl> + static constexpr auto name = " currentRowPolicies " ; <nl> + <nl> + static FunctionPtr create ( const Context & context_ ) { return std : : make_shared < FunctionCurrentRowPolicies > ( context_ ) ; } <nl> + explicit FunctionCurrentRowPolicies ( const Context & context_ ) : context ( context_ ) { } <nl> + <nl> + String getName ( ) const override { return name ; } <nl> + size_t getNumberOfArguments ( ) const override { return 0 ; } <nl> + bool isVariadic ( ) const override { return true ; } <nl> + <nl> + void checkNumberOfArgumentsIfVariadic ( size_t number_of_arguments ) const override <nl> + { <nl> + if ( number_of_arguments > 2 ) <nl> + throw Exception ( " Number of arguments for function " + String ( name ) + " doesn ' t match : passed " <nl> + + toString ( number_of_arguments ) + " , should be 0 . . 2 " , <nl> + ErrorCodes : : NUMBER_OF_ARGUMENTS_DOESNT_MATCH ) ; <nl> + } <nl> + <nl> + DataTypePtr getReturnTypeImpl ( const DataTypes & arguments ) const override <nl> + { <nl> + if ( arguments . empty ( ) ) <nl> + return std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeTuple > ( <nl> + DataTypes { std : : make_shared < DataTypeString > ( ) , std : : make_shared < DataTypeString > ( ) , std : : make_shared < DataTypeString > ( ) } ) ) ; <nl> + else <nl> + return std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeString > ( ) ) ; <nl> + } <nl> + <nl> + bool isDeterministic ( ) const override { return false ; } <nl> + <nl> + void executeImpl ( Block & block , const ColumnNumbers & arguments , size_t result_pos , size_t input_rows_count ) override <nl> + { <nl> + if ( arguments . empty ( ) ) <nl> + { <nl> + auto database_column = ColumnString : : create ( ) ; <nl> + auto table_name_column = ColumnString : : create ( ) ; <nl> + auto policy_name_column = ColumnString : : create ( ) ; <nl> + for ( const auto & policy_id : context . getRowPolicy ( ) - > getCurrentPolicyIDs ( ) ) <nl> + { <nl> + const auto policy = context . getAccessControlManager ( ) . tryRead < RowPolicy > ( policy_id ) ; <nl> + if ( policy ) <nl> + { <nl> + const String database = policy - > getDatabase ( ) ; <nl> + const String table_name = policy - > getTableName ( ) ; <nl> + const String policy_name = policy - > getName ( ) ; <nl> + database_column - > insertData ( database . data ( ) , database . length ( ) ) ; <nl> + table_name_column - > insertData ( table_name . data ( ) , table_name . length ( ) ) ; <nl> + policy_name_column - > insertData ( policy_name . data ( ) , policy_name . length ( ) ) ; <nl> + } <nl> + } <nl> + auto offset_column = ColumnArray : : ColumnOffsets : : create ( ) ; <nl> + offset_column - > insertValue ( policy_name_column - > size ( ) ) ; <nl> + block . getByPosition ( result_pos ) . column = ColumnConst : : create ( <nl> + ColumnArray : : create ( <nl> + ColumnTuple : : create ( Columns { std : : move ( database_column ) , std : : move ( table_name_column ) , std : : move ( policy_name_column ) } ) , <nl> + std : : move ( offset_column ) ) , <nl> + input_rows_count ) ; <nl> + return ; <nl> + } <nl> + <nl> + const IColumn * database_column = nullptr ; <nl> + if ( arguments . size ( ) = = 2 ) <nl> + { <nl> + const auto & database_column_with_type = block . getByPosition ( arguments [ 0 ] ) ; <nl> + if ( ! isStringOrFixedString ( database_column_with_type . type ) ) <nl> + throw Exception { " The first argument of function " + String ( name ) <nl> + + " should be a string containing database name , illegal type : " <nl> + + database_column_with_type . type - > getName ( ) , <nl> + ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT } ; <nl> + database_column = database_column_with_type . column . get ( ) ; <nl> + } <nl> + <nl> + const auto & table_name_column_with_type = block . getByPosition ( arguments [ arguments . size ( ) - 1 ] ) ; <nl> + if ( ! isStringOrFixedString ( table_name_column_with_type . type ) ) <nl> + throw Exception { " The " + String ( database_column ? " last " : " " ) + " argument of function " + String ( name ) <nl> + + " should be a string containing table name , illegal type : " + table_name_column_with_type . type - > getName ( ) , <nl> + ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT } ; <nl> + const IColumn * table_name_column = table_name_column_with_type . column . get ( ) ; <nl> + <nl> + auto policy_name_column = ColumnString : : create ( ) ; <nl> + auto offset_column = ColumnArray : : ColumnOffsets : : create ( ) ; <nl> + for ( const auto i : ext : : range ( 0 , input_rows_count ) ) <nl> + { <nl> + String database = database_column ? database_column - > getDataAt ( i ) . toString ( ) : context . getCurrentDatabase ( ) ; <nl> + String table_name = table_name_column - > getDataAt ( i ) . toString ( ) ; <nl> + for ( const auto & policy_id : context . getRowPolicy ( ) - > getCurrentPolicyIDs ( database , table_name ) ) <nl> + { <nl> + const auto policy = context . getAccessControlManager ( ) . tryRead < RowPolicy > ( policy_id ) ; <nl> + if ( policy ) <nl> + { <nl> + const String policy_name = policy - > getName ( ) ; <nl> + policy_name_column - > insertData ( policy_name . data ( ) , policy_name . length ( ) ) ; <nl> + } <nl> + } <nl> + offset_column - > insertValue ( policy_name_column - > size ( ) ) ; <nl> + } <nl> + <nl> + block . getByPosition ( result_pos ) . column = ColumnArray : : create ( std : : move ( policy_name_column ) , std : : move ( offset_column ) ) ; <nl> + } <nl> + <nl> + private : <nl> + const Context & context ; <nl> + } ; <nl> + <nl> + <nl> + / / / The currentRowPolicyIDs ( ) function can be called with 0 . . 2 arguments : <nl> + / / / currentRowPolicyIDs ( ) returns array of IDs of all the row policies applied for the current user ; <nl> + / / / currentRowPolicyIDs ( table_name ) is equivalent to currentRowPolicyIDs ( currentDatabase ( ) , table_name ) ; <nl> + / / / currentRowPolicyIDs ( database , table_name ) returns array of IDs of the row policies applied to a specific table and for the current user . <nl> + class FunctionCurrentRowPolicyIDs : public IFunction <nl> + { <nl> + public : <nl> + static constexpr auto name = " currentRowPolicyIDs " ; <nl> + <nl> + static FunctionPtr create ( const Context & context_ ) { return std : : make_shared < FunctionCurrentRowPolicyIDs > ( context_ ) ; } <nl> + explicit FunctionCurrentRowPolicyIDs ( const Context & context_ ) : context ( context_ ) { } <nl> + <nl> + String getName ( ) const override { return name ; } <nl> + size_t getNumberOfArguments ( ) const override { return 0 ; } <nl> + bool isVariadic ( ) const override { return true ; } <nl> + <nl> + void checkNumberOfArgumentsIfVariadic ( size_t number_of_arguments ) const override <nl> + { <nl> + if ( number_of_arguments > 2 ) <nl> + throw Exception ( " Number of arguments for function " + String ( name ) + " doesn ' t match : passed " <nl> + + toString ( number_of_arguments ) + " , should be 0 . . 2 " , <nl> + ErrorCodes : : NUMBER_OF_ARGUMENTS_DOESNT_MATCH ) ; <nl> + } <nl> + <nl> + DataTypePtr getReturnTypeImpl ( const DataTypes & / * arguments * / ) const override <nl> + { <nl> + return std : : make_shared < DataTypeArray > ( std : : make_shared < DataTypeUUID > ( ) ) ; <nl> + } <nl> + <nl> + bool isDeterministic ( ) const override { return false ; } <nl> + <nl> + void executeImpl ( Block & block , const ColumnNumbers & arguments , size_t result_pos , size_t input_rows_count ) override <nl> + { <nl> + if ( arguments . empty ( ) ) <nl> + { <nl> + auto policy_id_column = ColumnVector < UInt128 > : : create ( ) ; <nl> + for ( const auto & policy_id : context . getRowPolicy ( ) - > getCurrentPolicyIDs ( ) ) <nl> + policy_id_column - > insertValue ( policy_id ) ; <nl> + auto offset_column = ColumnArray : : ColumnOffsets : : create ( ) ; <nl> + offset_column - > insertValue ( policy_id_column - > size ( ) ) ; <nl> + block . getByPosition ( result_pos ) . column <nl> + = ColumnConst : : create ( ColumnArray : : create ( std : : move ( policy_id_column ) , std : : move ( offset_column ) ) , input_rows_count ) ; <nl> + return ; <nl> + } <nl> + <nl> + const IColumn * database_column = nullptr ; <nl> + if ( arguments . size ( ) = = 2 ) <nl> + { <nl> + const auto & database_column_with_type = block . getByPosition ( arguments [ 0 ] ) ; <nl> + if ( ! isStringOrFixedString ( database_column_with_type . type ) ) <nl> + throw Exception { " The first argument of function " + String ( name ) <nl> + + " should be a string containing database name , illegal type : " <nl> + + database_column_with_type . type - > getName ( ) , <nl> + ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT } ; <nl> + database_column = database_column_with_type . column . get ( ) ; <nl> + } <nl> + <nl> + const auto & table_name_column_with_type = block . getByPosition ( arguments [ arguments . size ( ) - 1 ] ) ; <nl> + if ( ! isStringOrFixedString ( table_name_column_with_type . type ) ) <nl> + throw Exception { " The " + String ( database_column ? " last " : " " ) + " argument of function " + String ( name ) <nl> + + " should be a string containing table name , illegal type : " + table_name_column_with_type . type - > getName ( ) , <nl> + ErrorCodes : : ILLEGAL_TYPE_OF_ARGUMENT } ; <nl> + const IColumn * table_name_column = table_name_column_with_type . column . get ( ) ; <nl> + <nl> + auto policy_id_column = ColumnVector < UInt128 > : : create ( ) ; <nl> + auto offset_column = ColumnArray : : ColumnOffsets : : create ( ) ; <nl> + for ( const auto i : ext : : range ( 0 , input_rows_count ) ) <nl> + { <nl> + String database = database_column ? database_column - > getDataAt ( i ) . toString ( ) : context . getCurrentDatabase ( ) ; <nl> + String table_name = table_name_column - > getDataAt ( i ) . toString ( ) ; <nl> + for ( const auto & policy_id : context . getRowPolicy ( ) - > getCurrentPolicyIDs ( database , table_name ) ) <nl> + policy_id_column - > insertValue ( policy_id ) ; <nl> + offset_column - > insertValue ( policy_id_column - > size ( ) ) ; <nl> + } <nl> + <nl> + block . getByPosition ( result_pos ) . column = ColumnArray : : create ( std : : move ( policy_id_column ) , std : : move ( offset_column ) ) ; <nl> + } <nl> + <nl> + private : <nl> + const Context & context ; <nl> + } ; <nl> + <nl> + <nl> + void registerFunctionCurrentRowPolicies ( FunctionFactory & factory ) <nl> + { <nl> + factory . registerFunction < FunctionCurrentRowPolicies > ( ) ; <nl> + factory . registerFunction < FunctionCurrentRowPolicyIDs > ( ) ; <nl> + } <nl> + <nl> + } <nl> mmm a / dbms / src / Functions / registerFunctions . h <nl> ppp b / dbms / src / Functions / registerFunctions . h <nl> class FunctionFactory ; <nl> void registerFunctionCurrentDatabase ( FunctionFactory & ) ; <nl> void registerFunctionCurrentUser ( FunctionFactory & ) ; <nl> void registerFunctionCurrentQuota ( FunctionFactory & ) ; <nl> + void registerFunctionCurrentRowPolicies ( FunctionFactory & ) ; <nl> void registerFunctionHostName ( FunctionFactory & ) ; <nl> void registerFunctionFQDN ( FunctionFactory & ) ; <nl> void registerFunctionVisibleWidth ( FunctionFactory & ) ; <nl> mmm a / dbms / src / Functions / registerFunctionsMiscellaneous . cpp <nl> ppp b / dbms / src / Functions / registerFunctionsMiscellaneous . cpp <nl> void registerFunctionsMiscellaneous ( FunctionFactory & factory ) <nl> registerFunctionCurrentDatabase ( factory ) ; <nl> registerFunctionCurrentUser ( factory ) ; <nl> registerFunctionCurrentQuota ( factory ) ; <nl> + registerFunctionCurrentRowPolicies ( factory ) ; <nl> registerFunctionHostName ( factory ) ; <nl> registerFunctionFQDN ( factory ) ; <nl> registerFunctionVisibleWidth ( factory ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 8ac4ac1b755 <nl> mmm / dev / null <nl> ppp b / dbms / src / Storages / System / StorageSystemRowPolicies . cpp <nl> <nl> + # include < Storages / System / StorageSystemRowPolicies . h > <nl> + # include < DataTypes / DataTypeString . h > <nl> + # include < DataTypes / DataTypesNumber . h > <nl> + # include < DataTypes / DataTypeUUID . h > <nl> + # include < DataTypes / DataTypeDateTime . h > <nl> + # include < DataTypes / DataTypeNullable . h > <nl> + # include < Interpreters / Context . h > <nl> + # include < Access / AccessControlManager . h > <nl> + # include < Access / RowPolicy . h > <nl> + # include < ext / range . h > <nl> + <nl> + <nl> + namespace DB <nl> + { <nl> + NamesAndTypesList StorageSystemRowPolicies : : getNamesAndTypes ( ) <nl> + { <nl> + NamesAndTypesList names_and_types { <nl> + { " database " , std : : make_shared < DataTypeString > ( ) } , <nl> + { " table " , std : : make_shared < DataTypeString > ( ) } , <nl> + { " name " , std : : make_shared < DataTypeString > ( ) } , <nl> + { " full_name " , std : : make_shared < DataTypeString > ( ) } , <nl> + { " id " , std : : make_shared < DataTypeUUID > ( ) } , <nl> + { " source " , std : : make_shared < DataTypeString > ( ) } , <nl> + { " restrictive " , std : : make_shared < DataTypeUInt8 > ( ) } , <nl> + } ; <nl> + <nl> + for ( auto index : ext : : range_with_static_cast < RowPolicy : : ConditionIndex > ( RowPolicy : : MAX_CONDITION_INDEX ) ) <nl> + names_and_types . push_back ( { RowPolicy : : conditionIndexToColumnName ( index ) , std : : make_shared < DataTypeString > ( ) } ) ; <nl> + <nl> + return names_and_types ; <nl> + } <nl> + <nl> + <nl> + void StorageSystemRowPolicies : : fillData ( MutableColumns & res_columns , const Context & context , const SelectQueryInfo & ) const <nl> + { <nl> + const auto & access_control = context . getAccessControlManager ( ) ; <nl> + std : : vector < UUID > ids = access_control . findAll < RowPolicy > ( ) ; <nl> + <nl> + for ( const auto & id : ids ) <nl> + { <nl> + auto policy = access_control . tryRead < RowPolicy > ( id ) ; <nl> + if ( ! policy ) <nl> + continue ; <nl> + const auto * storage = access_control . findStorage ( id ) ; <nl> + <nl> + size_t i = 0 ; <nl> + res_columns [ i + + ] - > insert ( policy - > getDatabase ( ) ) ; <nl> + res_columns [ i + + ] - > insert ( policy - > getTableName ( ) ) ; <nl> + res_columns [ i + + ] - > insert ( policy - > getName ( ) ) ; <nl> + res_columns [ i + + ] - > insert ( policy - > getFullName ( ) ) ; <nl> + res_columns [ i + + ] - > insert ( id ) ; <nl> + res_columns [ i + + ] - > insert ( storage ? storage - > getStorageName ( ) : " " ) ; <nl> + res_columns [ i + + ] - > insert ( policy - > isRestrictive ( ) ) ; <nl> + <nl> + for ( auto index : ext : : range ( RowPolicy : : MAX_CONDITION_INDEX ) ) <nl> + res_columns [ i + + ] - > insert ( policy - > conditions [ index ] ) ; <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . c28342eb18c <nl> mmm / dev / null <nl> ppp b / dbms / src / Storages / System / StorageSystemRowPolicies . h <nl> <nl> + # pragma once <nl> + <nl> + # include < ext / shared_ptr_helper . h > <nl> + # include < Storages / System / IStorageSystemOneBlock . h > <nl> + <nl> + <nl> + namespace DB <nl> + { <nl> + <nl> + class Context ; <nl> + <nl> + <nl> + / / / Implements ` row_policies ` system table , which allows you to get information about row policies . <nl> + class StorageSystemRowPolicies : public ext : : shared_ptr_helper < StorageSystemRowPolicies > , public IStorageSystemOneBlock < StorageSystemRowPolicies > <nl> + { <nl> + public : <nl> + std : : string getName ( ) const override { return " SystemRowPolicies " ; } <nl> + static NamesAndTypesList getNamesAndTypes ( ) ; <nl> + <nl> + protected : <nl> + friend struct ext : : shared_ptr_helper < StorageSystemRowPolicies > ; <nl> + using IStorageSystemOneBlock : : IStorageSystemOneBlock ; <nl> + void fillData ( MutableColumns & res_columns , const Context & context , const SelectQueryInfo & ) const override ; <nl> + } ; <nl> + <nl> + } <nl> mmm a / dbms / src / Storages / System / attachSystemTables . cpp <nl> ppp b / dbms / src / Storages / System / attachSystemTables . cpp <nl> <nl> # include < Storages / System / StorageSystemQuotaUsage . h > <nl> # include < Storages / System / StorageSystemReplicas . h > <nl> # include < Storages / System / StorageSystemReplicationQueue . h > <nl> + # include < Storages / System / StorageSystemRowPolicies . h > <nl> # include < Storages / System / StorageSystemSettings . h > <nl> # include < Storages / System / StorageSystemMergeTreeSettings . h > <nl> # include < Storages / System / StorageSystemTableEngines . h > <nl> void attachSystemTablesLocal ( IDatabase & system_database ) <nl> system_database . attachTable ( " settings " , StorageSystemSettings : : create ( " settings " ) ) ; <nl> system_database . attachTable ( " quotas " , StorageSystemQuotas : : create ( " quotas " ) ) ; <nl> system_database . attachTable ( " quota_usage " , StorageSystemQuotaUsage : : create ( " quota_usage " ) ) ; <nl> + system_database . attachTable ( " row_policies " , StorageSystemRowPolicies : : create ( " row_policies " ) ) ; <nl> system_database . attachTable ( " merge_tree_settings " , SystemMergeTreeSettings : : create ( " merge_tree_settings " ) ) ; <nl> system_database . attachTable ( " build_options " , StorageSystemBuildOptions : : create ( " build_options " ) ) ; <nl> system_database . attachTable ( " formats " , StorageSystemFormats : : create ( " formats " ) ) ; <nl> mmm a / dbms / tests / integration / test_row_policy / test . py <nl> ppp b / dbms / tests / integration / test_row_policy / test . py <nl> def test_reload_users_xml_by_timer ( ) : <nl> assert_eq_with_retry ( instance , " SELECT * FROM mydb . filtered_table1 " , " 1 \ t0 \ n1 \ t1 " ) <nl> assert_eq_with_retry ( instance , " SELECT * FROM mydb . filtered_table2 " , " 0 \ t0 \ t0 \ t0 \ n0 \ t0 \ t6 \ t0 " ) <nl> assert_eq_with_retry ( instance , " SELECT * FROM mydb . filtered_table3 " , " 0 \ t1 \ n1 \ t0 " ) <nl> + <nl> + <nl> + def test_introspection ( ) : <nl> + assert instance . query ( " SELECT currentRowPolicies ( ' mydb ' , ' filtered_table1 ' ) " ) = = " [ ' default ' ] \ n " <nl> + assert instance . query ( " SELECT currentRowPolicies ( ' mydb ' , ' filtered_table2 ' ) " ) = = " [ ' default ' ] \ n " <nl> + assert instance . query ( " SELECT currentRowPolicies ( ' mydb ' , ' filtered_table3 ' ) " ) = = " [ ' default ' ] \ n " <nl> + assert instance . query ( " SELECT arraySort ( currentRowPolicies ( ) ) " ) = = " [ ( ' mydb ' , ' filtered_table1 ' , ' default ' ) , ( ' mydb ' , ' filtered_table2 ' , ' default ' ) , ( ' mydb ' , ' filtered_table3 ' , ' default ' ) ] \ n " <nl> + <nl> + policy1 = " mydb \ tfiltered_table1 \ tdefault \ tdefault ON mydb . filtered_table1 \ t9e8a8f62 - 4965 - 2b5e - 8599 - 57c7b99b3549 \ tusers . xml \ t0 \ ta = 1 \ t \ t \ t \ t \ n " <nl> + policy2 = " mydb \ tfiltered_table2 \ tdefault \ tdefault ON mydb . filtered_table2 \ tcffae79d - b9bf - a2ef - b798 - 019c18470b25 \ tusers . xml \ t0 \ ta + b < 1 or c - d > 5 \ t \ t \ t \ t \ n " <nl> + policy3 = " mydb \ tfiltered_table3 \ tdefault \ tdefault ON mydb . filtered_table3 \ t12fc5cef - e3da - 3940 - ec79 - d8be3911f42b \ tusers . xml \ t0 \ tc = 1 \ t \ t \ t \ t \ n " <nl> + assert instance . query ( " SELECT * from system . row_policies WHERE has ( currentRowPolicyIDs ( ' mydb ' , ' filtered_table1 ' ) , id ) ORDER BY table , name " ) = = policy1 <nl> + assert instance . query ( " SELECT * from system . row_policies WHERE has ( currentRowPolicyIDs ( ' mydb ' , ' filtered_table2 ' ) , id ) ORDER BY table , name " ) = = policy2 <nl> + assert instance . query ( " SELECT * from system . row_policies WHERE has ( currentRowPolicyIDs ( ' mydb ' , ' filtered_table3 ' ) , id ) ORDER BY table , name " ) = = policy3 <nl> + assert instance . query ( " SELECT * from system . row_policies ORDER BY table , name " ) = = policy1 + policy2 + policy3 <nl> + assert instance . query ( " SELECT * from system . row_policies WHERE has ( currentRowPolicyIDs ( ) , id ) ORDER BY table , name " ) = = policy1 + policy2 + policy3 <nl>
|
Add functions currentRowPolicies ( ) and system table ' system . row_policies ' .
|
ClickHouse/ClickHouse
|
6baccb963d3a69919f0a17ab7f8f4abe88675ab2
|
2019-12-19T15:40:15Z
|
new file mode 100644 <nl> index 0000000000 . . c4da73d212 <nl> mmm / dev / null <nl> ppp b / change / react - native - windows - 2020 - 09 - 17 - 20 - 39 - 35 - master . json <nl> <nl> + { <nl> + " type " : " none " , <nl> + " packageName " : " react - native - windows " , <nl> + " email " : " dannyvv @ microsoft . com " , <nl> + " dependentChangeType " : " none " , <nl> + " date " : " 2020 - 09 - 18T03 : 39 : 35 . 689Z " <nl> + } <nl> mmm a / vnext / Scripts / rnw - dependencies . ps1 <nl> ppp b / vnext / Scripts / rnw - dependencies . ps1 <nl> $ requirements = @ ( <nl> Name = ' git ' ; <nl> Tags = @ ( ' appDev ' ) ; <nl> Valid = try { ( Get - Command git . exe - ErrorAction Stop ) - ne $ null } catch { $ false } ; <nl> - Install = { choco install git } ; <nl> + Install = { choco install - y git } ; <nl> } , <nl> @ { <nl> Name = ' VS 2019 with UWP and Desktop / C + + ' ; <nl>
|
Auto - accept git license in rnw - dependencies install script ( )
|
microsoft/react-native-windows
|
64e9d82711d1c751854c9a00917f663463dafd93
|
2020-09-18T16:40:17Z
|
mmm a / . gitmodules <nl> ppp b / . gitmodules <nl> <nl> url = https : / / github . com / ClickHouse - Extras / libgsasl . git <nl> [ submodule " contrib / cppkafka " ] <nl> path = contrib / cppkafka <nl> - url = https : / / github . com / mfontanini / cppkafka . git <nl> + url = https : / / github . com / ClickHouse - Extras / cppkafka . git <nl> [ submodule " contrib / pdqsort " ] <nl> path = contrib / pdqsort <nl> url = https : / / github . com / orlp / pdqsort <nl>
|
Update . gitmodules
|
ClickHouse/ClickHouse
|
f86432dd92df80f5236c79e2fa62e895d1eb4c4f
|
2019-02-12T13:56:43Z
|
mmm a / src / hydrogen - instructions . cc <nl> ppp b / src / hydrogen - instructions . cc <nl> void HCompareObjectEqAndBranch : : PrintDataTo ( StringStream * stream ) { <nl> <nl> bool HCompareObjectEqAndBranch : : KnownSuccessorBlock ( HBasicBlock * * block ) { <nl> if ( FLAG_fold_constants & & left ( ) - > IsConstant ( ) & & right ( ) - > IsConstant ( ) ) { <nl> - * block = HConstant : : cast ( left ( ) ) - > Equals ( HConstant : : cast ( right ( ) ) ) <nl> + * block = HConstant : : cast ( left ( ) ) - > DataEquals ( HConstant : : cast ( right ( ) ) ) <nl> ? FirstSuccessor ( ) : SecondSuccessor ( ) ; <nl> return true ; <nl> } <nl> mmm a / src / hydrogen - instructions . h <nl> ppp b / src / hydrogen - instructions . h <nl> class HConstant V8_FINAL : public HTemplateInstruction < 0 > { <nl> return object_ . IsInitialized ( ) & & object_ = = other ; <nl> } <nl> <nl> - # ifdef DEBUG <nl> - virtual void Verify ( ) V8_OVERRIDE { } <nl> - # endif <nl> - <nl> - DECLARE_CONCRETE_INSTRUCTION ( Constant ) <nl> - <nl> - protected : <nl> - virtual Range * InferRange ( Zone * zone ) V8_OVERRIDE ; <nl> - <nl> virtual bool DataEquals ( HValue * other ) V8_OVERRIDE { <nl> HConstant * other_constant = HConstant : : cast ( other ) ; <nl> if ( has_int32_value_ ) { <nl> class HConstant V8_FINAL : public HTemplateInstruction < 0 > { <nl> } <nl> } <nl> <nl> + # ifdef DEBUG <nl> + virtual void Verify ( ) V8_OVERRIDE { } <nl> + # endif <nl> + <nl> + DECLARE_CONCRETE_INSTRUCTION ( Constant ) <nl> + <nl> + protected : <nl> + virtual Range * InferRange ( Zone * zone ) V8_OVERRIDE ; <nl> + <nl> private : <nl> friend class HGraph ; <nl> HConstant ( Handle < Object > handle , Representation r = Representation : : None ( ) ) ; <nl> class HCompareMinusZeroAndBranch V8_FINAL : public HUnaryControlInstruction { <nl> <nl> class HCompareObjectEqAndBranch : public HTemplateControlInstruction < 2 , 2 > { <nl> public : <nl> - HCompareObjectEqAndBranch ( HValue * left , <nl> - HValue * right , <nl> - HBasicBlock * true_target = NULL , <nl> - HBasicBlock * false_target = NULL ) { <nl> - / / TODO ( danno ) : make this private when the IfBuilder properly constructs <nl> - / / control flow instructions . <nl> - ASSERT ( ! left - > IsConstant ( ) | | <nl> - ( ! HConstant : : cast ( left ) - > HasInteger32Value ( ) | | <nl> - HConstant : : cast ( left ) - > HasSmiValue ( ) ) ) ; <nl> - ASSERT ( ! right - > IsConstant ( ) | | <nl> - ( ! HConstant : : cast ( right ) - > HasInteger32Value ( ) | | <nl> - HConstant : : cast ( right ) - > HasSmiValue ( ) ) ) ; <nl> - SetOperandAt ( 0 , left ) ; <nl> - SetOperandAt ( 1 , right ) ; <nl> - SetSuccessorAt ( 0 , true_target ) ; <nl> - SetSuccessorAt ( 1 , false_target ) ; <nl> - } <nl> - <nl> DECLARE_INSTRUCTION_FACTORY_P2 ( HCompareObjectEqAndBranch , HValue * , HValue * ) ; <nl> DECLARE_INSTRUCTION_FACTORY_P4 ( HCompareObjectEqAndBranch , HValue * , HValue * , <nl> HBasicBlock * , HBasicBlock * ) ; <nl> class HCompareObjectEqAndBranch : public HTemplateControlInstruction < 2 , 2 > { <nl> } <nl> <nl> DECLARE_CONCRETE_INSTRUCTION ( CompareObjectEqAndBranch ) <nl> + <nl> + private : <nl> + HCompareObjectEqAndBranch ( HValue * left , <nl> + HValue * right , <nl> + HBasicBlock * true_target = NULL , <nl> + HBasicBlock * false_target = NULL ) { <nl> + ASSERT ( ! left - > IsConstant ( ) | | <nl> + ( ! HConstant : : cast ( left ) - > HasInteger32Value ( ) | | <nl> + HConstant : : cast ( left ) - > HasSmiValue ( ) ) ) ; <nl> + ASSERT ( ! right - > IsConstant ( ) | | <nl> + ( ! HConstant : : cast ( right ) - > HasInteger32Value ( ) | | <nl> + HConstant : : cast ( right ) - > HasSmiValue ( ) ) ) ; <nl> + SetOperandAt ( 0 , left ) ; <nl> + SetOperandAt ( 1 , right ) ; <nl> + SetSuccessorAt ( 0 , true_target ) ; <nl> + SetSuccessorAt ( 1 , false_target ) ; <nl> + } <nl> } ; <nl> <nl> <nl> new file mode 100644 <nl> index 00000000000 . . 40e3ac116cd <nl> mmm / dev / null <nl> ppp b / test / mjsunit / regress / regress - 346587 . js <nl> <nl> + / / Copyright 2014 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + / / Flags : - - fold - constants - - allow - natives - syntax <nl> + <nl> + function bar ( obj ) { <nl> + assertTrue ( obj . x = = = ' baz ' ) ; <nl> + } <nl> + <nl> + function foo ( ) { <nl> + bar ( { x : ' baz ' } ) ; <nl> + } <nl> + <nl> + foo ( ) ; <nl> + foo ( ) ; <nl> + % OptimizeFunctionOnNextCall ( foo ) ; <nl> + foo ( ) ; <nl>
|
Fix bug in constant folding object comparisons .
|
v8/v8
|
6e1507331e7811b838a1737b0c6b1f079ddc5662
|
2014-03-11T13:34:01Z
|
mmm a / cmake / templates / opencv_run_all_tests_unix . sh . in <nl> ppp b / cmake / templates / opencv_run_all_tests_unix . sh . in <nl> <nl> - # ! / bin / sh <nl> + # ! / bin / bash <nl> <nl> # Text style <nl> <nl>
|
fix opencv_run_all_tests_unix . sh script :
|
opencv/opencv
|
098389d8eb81675f34da158d1f0c4515c41279cd
|
2015-02-06T09:36:18Z
|
mmm a / modules / core / include / opencv2 / core / softfloat . hpp <nl> ppp b / modules / core / include / opencv2 / core / softfloat . hpp <nl> CV_EXPORTS int cvTrunc ( const cv : : softdouble & a ) ; <nl> CV_EXPORTS int cvRound ( const cv : : softfloat & a ) ; <nl> CV_EXPORTS int cvRound ( const cv : : softdouble & a ) ; <nl> <nl> + / * * @ brief Rounds a number to nearest even long long integer * / <nl> + CV_EXPORTS int64_t cvRound64 ( const cv : : softdouble & a ) ; <nl> + <nl> / * * @ brief Rounds a number down to integer * / <nl> CV_EXPORTS int cvFloor ( const cv : : softfloat & a ) ; <nl> CV_EXPORTS int cvFloor ( const cv : : softdouble & a ) ; <nl> template < > inline short saturate_cast < short > ( softdouble a ) { return ( short ) std : : <nl> template < > inline int saturate_cast < int > ( softfloat a ) { return cvRound ( a ) ; } <nl> template < > inline int saturate_cast < int > ( softdouble a ) { return cvRound ( a ) ; } <nl> <nl> - / * * @ brief Saturate cast to unsigned integer <nl> + template < > inline int64_t saturate_cast < int64_t > ( softfloat a ) { return cvRound ( a ) ; } <nl> + template < > inline int64_t saturate_cast < int64_t > ( softdouble a ) { return cvRound64 ( a ) ; } <nl> + <nl> + / * * @ brief Saturate cast to unsigned integer and unsigned long long integer <nl> We intentionally do not clip negative numbers , to make - 1 become 0xffffffff etc . <nl> * / <nl> template < > inline unsigned saturate_cast < unsigned > ( softfloat a ) { return cvRound ( a ) ; } <nl> template < > inline unsigned saturate_cast < unsigned > ( softdouble a ) { return cvRound ( a ) ; } <nl> <nl> + template < > inline uint64_t saturate_cast < uint64_t > ( softfloat a ) { return cvRound ( a ) ; } <nl> + template < > inline uint64_t saturate_cast < uint64_t > ( softdouble a ) { return cvRound64 ( a ) ; } <nl> + <nl> / * * @ brief Min and Max functions * / <nl> inline softfloat min ( const softfloat & a , const softfloat & b ) { return ( a > b ) ? b : a ; } <nl> inline softdouble min ( const softdouble & a , const softdouble & b ) { return ( a > b ) ? b : a ; } <nl> mmm a / modules / core / src / softfloat . cpp <nl> ppp b / modules / core / src / softfloat . cpp <nl> static bool f32_lt ( float32_t , float32_t ) ; <nl> | 64 - bit ( double - precision ) floating - point operations . <nl> * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - * / <nl> static int_fast32_t f64_to_i32 ( float64_t , uint_fast8_t , bool ) ; <nl> + static int_fast64_t f64_to_i64 ( float64_t , uint_fast8_t , bool ) ; <nl> static int_fast32_t f64_to_i32_r_minMag ( float64_t , bool ) ; <nl> static float32_t f64_to_f32 ( float64_t ) ; <nl> static float64_t f64_roundToInt ( float64_t , uint_fast8_t , bool ) ; <nl> int cvRound ( const cv : : softdouble & a ) { return cv : : f64_to_i32 ( a , cv : : round_near_e <nl> int cvFloor ( const cv : : softdouble & a ) { return cv : : f64_to_i32 ( a , cv : : round_min , false ) ; } <nl> int cvCeil ( const cv : : softdouble & a ) { return cv : : f64_to_i32 ( a , cv : : round_max , false ) ; } <nl> <nl> + int64_t cvRound64 ( const cv : : softdouble & a ) { return cv : : f64_to_i64 ( a , cv : : round_near_even , false ) ; } <nl> + <nl> namespace cv <nl> { <nl> softdouble : : operator softfloat ( ) const { return f64_to_f32 ( * this ) ; } <nl> static float32_t softfloat_mulAddF32 ( uint_fast32_t , uint_fast32_t , uint_fast32_t <nl> <nl> / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - * / <nl> + static int_fast64_t softfloat_roundToI64 ( bool , uint_fast64_t , uint_fast64_t , uint_fast8_t , bool ) ; <nl> <nl> struct exp16_sig64 { int_fast16_t exp ; uint_fast64_t sig ; } ; <nl> static struct exp16_sig64 softfloat_normSubnormalF64Sig ( uint_fast64_t ) ; <nl> static int_fast32_t f64_to_i32 ( float64_t a , uint_fast8_t roundingMode , bool exa <nl> return softfloat_roundToI32 ( sign , sig , roundingMode , exact ) ; <nl> } <nl> <nl> + static int_fast64_t f64_to_i64 ( float64_t a , uint_fast8_t roundingMode , bool exact ) <nl> + { <nl> + uint_fast64_t uiA ; <nl> + bool sign ; <nl> + int_fast16_t exp ; <nl> + uint_fast64_t sig ; <nl> + int_fast16_t shiftDist ; <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + uiA = a . v ; <nl> + sign = signF64UI ( uiA ) ; <nl> + exp = expF64UI ( uiA ) ; <nl> + sig = fracF64UI ( uiA ) ; <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + # if ( i64_fromNaN ! = i64_fromPosOverflow ) | | ( i64_fromNaN ! = i64_fromNegOverflow ) <nl> + if ( ( exp = = 0x7FF ) & & sig ) { <nl> + # if ( i64_fromNaN = = i64_fromPosOverflow ) <nl> + sign = 0 ; <nl> + # elif ( i64_fromNaN = = i64_fromNegOverflow ) <nl> + sign = 1 ; <nl> + # else <nl> + raiseFlags ( flag_invalid ) ; <nl> + return i64_fromNaN ; <nl> + # endif <nl> + } <nl> + # endif <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + if ( exp ) sig | = UINT64_C ( 0x0010000000000000 ) ; <nl> + shiftDist = 0x433 - exp ; <nl> + if ( shiftDist < = 0 ) { <nl> + uint_fast64_t z = sig < < - shiftDist ; <nl> + if ( ( shiftDist < - 11 ) | | ( z & UINT64_C ( 0x8000000000000000 ) ) ) <nl> + { <nl> + raiseFlags ( flag_invalid ) ; <nl> + return sign ? i64_fromNegOverflow : i64_fromPosOverflow ; <nl> + } <nl> + return sign ? - ( int_fast64_t ) z : ( int_fast64_t ) z ; <nl> + } <nl> + else { <nl> + if ( shiftDist < 64 ) <nl> + return <nl> + softfloat_roundToI64 ( <nl> + sign , sig > > shiftDist , sig < < ( - shiftDist & 63 ) , roundingMode , exact ) ; <nl> + else <nl> + return <nl> + softfloat_roundToI64 ( <nl> + sign , 0 , ( shiftDist = = 64 ) ? sig : ( sig ! = 0 ) , roundingMode , exact ) ; <nl> + } <nl> + } <nl> + <nl> static int_fast32_t f64_to_i32_r_minMag ( float64_t a , bool exact ) <nl> { <nl> uint_fast64_t uiA ; <nl> static int_fast32_t <nl> return sign ? i32_fromNegOverflow : i32_fromPosOverflow ; <nl> } <nl> <nl> + static int_fast64_t <nl> + softfloat_roundToI64 ( <nl> + bool sign , uint_fast64_t sig , uint_fast64_t sigExtra , uint_fast8_t roundingMode , bool exact ) <nl> + { <nl> + bool roundNearEven , doIncrement ; <nl> + union { uint64_t ui ; int64_t i ; } uZ ; <nl> + int_fast64_t z ; <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + roundNearEven = ( roundingMode = = round_near_even ) ; <nl> + doIncrement = ( UINT64_C ( 0x8000000000000000 ) < = sigExtra ) ; <nl> + if ( ! roundNearEven & & ( roundingMode ! = round_near_maxMag ) ) { <nl> + doIncrement = <nl> + ( roundingMode <nl> + = = ( sign ? round_min : round_max ) ) <nl> + & & sigExtra ; <nl> + } <nl> + if ( doIncrement ) { <nl> + + + sig ; <nl> + if ( ! sig ) goto invalid ; <nl> + sig & = <nl> + ~ ( uint_fast64_t ) <nl> + ( ! ( sigExtra & UINT64_C ( 0x7FFFFFFFFFFFFFFF ) ) <nl> + & roundNearEven ) ; <nl> + } <nl> + uZ . ui = sign ? ( ~ sig + 1 ) : sig ; <nl> + z = uZ . i ; <nl> + if ( z & & ( ( z < 0 ) ^ sign ) ) goto invalid ; <nl> + if ( exact & & sigExtra ) { <nl> + raiseFlags ( flag_inexact ) ; <nl> + } <nl> + return z ; <nl> + / * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + * mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> + invalid : <nl> + raiseFlags ( flag_invalid ) ; <nl> + return sign ? i64_fromNegOverflow : i64_fromPosOverflow ; <nl> + } <nl> + <nl> static struct uint128 <nl> softfloat_shiftRightJam128 ( uint64_t a64 , uint64_t a0 , uint_fast32_t dist ) <nl> { <nl> mmm a / modules / core / test / test_math . cpp <nl> ppp b / modules / core / test / test_math . cpp <nl> TEST ( Core_SoftFloat , sincos64 ) <nl> } <nl> } <nl> <nl> + TEST ( Core_SoftFloat , CvRound ) <nl> + { <nl> + struct <nl> + { <nl> + uint64_t inVal ; <nl> + int64_t out64 ; <nl> + int32_t out32 ; <nl> + } _values [ ] = <nl> + { <nl> + { 0x0123456789abcdefU , 0 , 0 } , / / 3 . 51270056408850369812238561681E - 303 <nl> + { 0x0000000000000000U , 0 , 0 } , / / 0 <nl> + { 0x8000000000000000U , 0 , 0 } , / / - 0 <nl> + { 0x000123456789abcdU , 0 , 0 } , / / 1 . 5822747438273385725152200433E - 309 <nl> + { 0x800123456789abcdU , 0 , 0 } , / / - 1 . 5822747438273385725152200433E - 309 <nl> + { 0x7ff0000000000000U , INT64_MAX , INT32_MAX } , / / + inf <nl> + { 0xfff0000000000000U , INT64_MIN , INT32_MIN } , / / - inf <nl> + { 0x7ff0000000000001U , INT64_MAX , INT32_MAX } , / / nan ( casts to maximum value ) <nl> + { 0xfff0000000000001U , INT64_MAX , INT32_MAX } , / / nan ( casts to maximum value ) <nl> + { 0x7ffa5a5a5a5a5a5aU , INT64_MAX , INT32_MAX } , / / nan ( casts to maximum value ) <nl> + { 0xfffa5a5a5a5a5a5aU , INT64_MAX , INT32_MAX } , / / nan ( casts to maximum value ) <nl> + { 0x7fe123456789abcdU , INT64_MAX , INT32_MAX } , / / 9 . 627645455595956656406699747E307 <nl> + { 0xffe123456789abcdU , INT64_MIN , INT32_MIN } , / / - 9 . 627645455595956656406699747E307 <nl> + { 0x43ffffffffffffffU , INT64_MAX , INT32_MAX } , / / ( 2 ^ 53 - 1 ) * 2 ^ 12 <nl> + { 0xc3ffffffffffffffU , INT64_MIN , INT32_MIN } , / / - ( 2 ^ 53 - 1 ) * 2 ^ 12 <nl> + { 0x43f0000000000000U , INT64_MAX , INT32_MAX } , / / 2 ^ 64 <nl> + { 0xc3f0000000000000U , INT64_MIN , INT32_MIN } , / / - 2 ^ 64 <nl> + { 0x43efffffffffffffU , INT64_MAX , INT32_MAX } , / / ( 2 ^ 53 - 1 ) * 2 ^ 11 <nl> + { 0xc3efffffffffffffU , INT64_MIN , INT32_MIN } , / / - ( 2 ^ 53 - 1 ) * 2 ^ 11 <nl> + { 0x43e0000000000000U , INT64_MAX , INT32_MAX } , / / 2 ^ 63 <nl> + { 0xc3e0000000000000U , - 0x7fffffffffffffff - 1 , INT32_MIN } , / / - 2 ^ 63 <nl> + { 0x43dfffffffffffffU , 0x7ffffffffffffc00 , INT32_MAX } , / / ( 2 ^ 53 - 1 ) * 2 ^ 10 <nl> + { 0xc3dfffffffffffffU , - 0x7ffffffffffffc00 , INT32_MIN } , / / - ( 2 ^ 53 - 1 ) * 2 ^ 10 <nl> + { 0x433fffffffffffffU , 0x1fffffffffffff , INT32_MAX } , / / ( 2 ^ 53 - 1 ) <nl> + { 0xc33fffffffffffffU , - 0x1fffffffffffff , INT32_MIN } , / / - ( 2 ^ 53 - 1 ) <nl> + { 0x432fffffffffffffU , 0x10000000000000 , INT32_MAX } , / / ( 2 ^ 52 - 1 ) + 0 . 5 <nl> + { 0xc32fffffffffffffU , - 0x10000000000000 , INT32_MIN } , / / - ( 2 ^ 52 - 1 ) - 0 . 5 <nl> + { 0x431fffffffffffffU , 0x8000000000000 , INT32_MAX } , / / ( 2 ^ 51 - 1 ) + 0 . 75 <nl> + { 0xc31fffffffffffffU , - 0x8000000000000 , INT32_MIN } , / / - ( 2 ^ 51 - 1 ) - 0 . 75 <nl> + { 0x431ffffffffffffeU , 0x8000000000000 , INT32_MAX } , / / ( 2 ^ 51 - 1 ) + 0 . 5 <nl> + { 0xc31ffffffffffffeU , - 0x8000000000000 , INT32_MIN } , / / - ( 2 ^ 51 - 1 ) - 0 . 5 <nl> + { 0x431ffffffffffffdU , 0x7ffffffffffff , INT32_MAX } , / / ( 2 ^ 51 - 1 ) + 0 . 25 <nl> + { 0xc31ffffffffffffdU , - 0x7ffffffffffff , INT32_MIN } , / / - ( 2 ^ 51 - 1 ) - 0 . 25 <nl> + <nl> + { 0x41f0000000000000U , 0x100000000 , INT32_MAX } , / / 2 ^ 32 = 4294967296 <nl> + { 0xc1f0000000000000U , - 0x100000000 , INT32_MIN } , / / - 2 ^ 32 = - 4294967296 <nl> + { 0x41efffffffffffffU , 0x100000000 , INT32_MAX } , / / 4294967295 . 99999952316284179688 <nl> + { 0xc1efffffffffffffU , - 0x100000000 , INT32_MIN } , / / - 4294967295 . 99999952316284179688 <nl> + { 0x41effffffff00000U , 0x100000000 , INT32_MAX } , / / ( 2 ^ 32 - 1 ) + 0 . 5 = 4294967295 . 5 <nl> + { 0xc1effffffff00000U , - 0x100000000 , INT32_MIN } , / / - ( 2 ^ 32 - 1 ) - 0 . 5 = - 4294967295 . 5 <nl> + { 0x41efffffffe00000U , 0xffffffffll , INT32_MAX } , / / ( 2 ^ 32 - 1 ) <nl> + { 0xc1efffffffe00000U , - 0xffffffffll , INT32_MIN } , / / - ( 2 ^ 32 - 1 ) <nl> + { 0x41e0000000000000U , 0x80000000ll , INT32_MAX } , / / 2 ^ 31 = 2147483648 <nl> + { 0xc1e0000000000000U , - 0x80000000ll , - 0x7fffffff - 1 } , / / - 2 ^ 31 = - 2147483648 <nl> + { 0x41dfffffffffffffU , 0x80000000ll , INT32_MAX } , / / 2147483647 . 99999976158142089844 <nl> + { 0xc1dfffffffffffffU , - 0x80000000ll , - 0x7fffffff - 1 } , / / - 2147483647 . 99999976158142089844 <nl> + <nl> + { 0x41dffffffff00000U , 0x80000000ll , INT32_MAX } , / / ( 2 ^ 31 - 1 ) + 0 . 75 <nl> + { 0xc1dffffffff00000U , - 0x80000000ll , - 0x7fffffff - 1 } , / / - ( 2 ^ 31 - 1 ) - 0 . 75 <nl> + { 0x41dfffffffe00001U , 0x80000000ll , INT32_MAX } , / / ( 2 ^ 31 - 1 ) + 0 . 5 + 2 ^ - 22 <nl> + { 0xc1dfffffffe00001U , - 0x80000000ll , - 0x7fffffff - 1 } , / / - ( 2 ^ 31 - 1 ) - 0 . 5 - 2 ^ - 22 <nl> + { 0x41dfffffffe00000U , 0x80000000ll , INT32_MAX } , / / ( 2 ^ 31 - 1 ) + 0 . 5 <nl> + { 0xc1dfffffffe00000U , - 0x80000000ll , - 0x7fffffff - 1 } , / / - ( 2 ^ 31 - 1 ) - 0 . 5 <nl> + { 0x41dfffffffdfffffU , 0x7fffffff , 0x7fffffff } , / / ( 2 ^ 31 - 1 ) + 0 . 5 - 2 ^ - 22 <nl> + { 0xc1dfffffffdfffffU , - 0x7fffffff , - 0x7fffffff } , / / - ( 2 ^ 31 - 1 ) - 0 . 5 + 2 ^ - 22 <nl> + { 0x41dfffffffd00000U , 0x7fffffff , 0x7fffffff } , / / ( 2 ^ 31 - 1 ) + 0 . 25 <nl> + { 0xc1dfffffffd00000U , - 0x7fffffff , - 0x7fffffff } , / / - ( 2 ^ 31 - 1 ) - 0 . 25 <nl> + { 0x41dfffffffc00000U , 0x7fffffff , 0x7fffffff } , / / ( 2 ^ 31 - 1 ) <nl> + { 0xc1dfffffffc00000U , - 0x7fffffff , - 0x7fffffff } , / / - ( 2 ^ 31 - 1 ) <nl> + { 0x41d0000000000000U , 0x40000000 , 0x40000000 } , / / 2 ^ 30 = 2147483648 <nl> + { 0xc1d0000000000000U , - 0x40000000 , - 0x40000000 } , / / - 2 ^ 30 = - 2147483648 <nl> + <nl> + { 0x4006000000000000U , 3 , 3 } , / / 2 . 75 <nl> + { 0xc006000000000000U , - 3 , - 3 } , / / - 2 . 75 <nl> + { 0x4004000000000001U , 3 , 3 } , / / 2 . 5 + 2 ^ - 51 <nl> + { 0xc004000000000001U , - 3 , - 3 } , / / - 2 . 5 - 2 ^ - 51 <nl> + { 0x4004000000000000U , 2 , 2 } , / / 2 . 5 <nl> + { 0xc004000000000000U , - 2 , - 2 } , / / - 2 . 5 <nl> + { 0x4003ffffffffffffU , 2 , 2 } , / / 2 . 5 - 2 ^ - 51 <nl> + { 0xc003ffffffffffffU , - 2 , - 2 } , / / - 2 . 5 + 2 ^ - 51 <nl> + { 0x4002000000000000U , 2 , 2 } , / / 2 . 25 <nl> + { 0xc002000000000000U , - 2 , - 2 } , / / - 2 . 25 <nl> + <nl> + { 0x3ffc000000000000U , 2 , 2 } , / / 1 . 75 <nl> + { 0xbffc000000000000U , - 2 , - 2 } , / / - 1 . 75 <nl> + { 0x3ff8000000000001U , 2 , 2 } , / / 1 . 5 + 2 ^ - 52 <nl> + { 0xbff8000000000001U , - 2 , - 2 } , / / - 1 . 5 - 2 ^ - 52 <nl> + { 0x3ff8000000000000U , 2 , 2 } , / / 1 . 5 <nl> + { 0xbff8000000000000U , - 2 , - 2 } , / / - 1 . 5 <nl> + { 0x3ff7ffffffffffffU , 1 , 1 } , / / 1 . 5 - 2 ^ - 52 <nl> + { 0xbff7ffffffffffffU , - 1 , - 1 } , / / - 1 . 5 + 2 ^ - 52 <nl> + { 0x3ff4000000000000U , 1 , 1 } , / / 1 . 25 <nl> + { 0xbff4000000000000U , - 1 , - 1 } , / / - 1 . 25 <nl> + <nl> + { 0x3fe8000000000000U , 1 , 1 } , / / 0 . 75 <nl> + { 0xbfe8000000000000U , - 1 , - 1 } , / / - 0 . 75 <nl> + { 0x3fe0000000000001U , 1 , 1 } , / / 0 . 5 + 2 ^ - 53 <nl> + { 0xbfe0000000000001U , - 1 , - 1 } , / / - 0 . 5 - 2 ^ - 53 <nl> + { 0x3fe0000000000000U , 0 , 0 } , / / 0 . 5 <nl> + { 0xbfe0000000000000U , 0 , 0 } , / / - 0 . 5 <nl> + <nl> + { 0x3fd8000000000000U , 0 , 0 } , / / 0 . 375 <nl> + { 0xbfd8000000000000U , 0 , 0 } , / / - 0 . 375 <nl> + { 0x3fd0000000000000U , 0 , 0 } , / / 0 . 25 <nl> + { 0xbfd0000000000000U , 0 , 0 } , / / - 0 . 25 <nl> + <nl> + { 0x0ff123456789abcdU , 0 , 0 } , / / 6 . 89918601543515033558134828315E - 232 <nl> + { 0x8ff123456789abcdU , 0 , 0 } / / - 6 . 89918601543515033558134828315E - 232 <nl> + } ; <nl> + struct testvalues <nl> + { <nl> + softdouble inVal ; <nl> + int64_t out64 ; <nl> + int32_t out32 ; <nl> + } * values = ( testvalues * ) _values ; <nl> + <nl> + for ( int i = 0 , maxi = sizeof ( _values ) / sizeof ( _values [ 0 ] ) ; i < maxi ; i + + ) <nl> + { <nl> + EXPECT_EQ ( values [ i ] . out64 , cvRound64 ( values [ i ] . inVal ) ) ; <nl> + EXPECT_EQ ( values [ i ] . out64 , saturate_cast < int64_t > ( values [ i ] . inVal ) ) ; <nl> + EXPECT_EQ ( ( uint64_t ) ( values [ i ] . out64 ) , saturate_cast < uint64_t > ( values [ i ] . inVal ) ) ; <nl> + EXPECT_EQ ( values [ i ] . out32 , cvRound ( values [ i ] . inVal ) ) ; <nl> + EXPECT_EQ ( values [ i ] . out32 , saturate_cast < int32_t > ( values [ i ] . inVal ) ) ; <nl> + EXPECT_EQ ( ( uint32_t ) ( values [ i ] . out32 ) , saturate_cast < uint32_t > ( values [ i ] . inVal ) ) ; <nl> + } <nl> + } <nl> + <nl> / * End of file . * / <nl>
|
Merge pull request from terfendail : softdouble_round
|
opencv/opencv
|
e49febb70f8f0bc0c10043df16b500f97d8eb0cf
|
2017-12-11T12:48:03Z
|
mmm a / tensorflow / tools / pip_package / setup . py <nl> ppp b / tensorflow / tools / pip_package / setup . py <nl> <nl> <nl> # pylint : disable = line - too - long <nl> CONSOLE_SCRIPTS = [ <nl> - ' tensorboard = tensorflow . tensorboard . tensorboard : main ' , <nl> + ' tensorboard = tensorflow . tensorboard . backend . tensorboard : main ' , <nl> ] <nl> # pylint : enable = line - too - long <nl> <nl>
|
Revert " Fix tensorboard import path "
|
tensorflow/tensorflow
|
f43cea0c6b10873c893929a8a7ea2d5176da5183
|
2016-02-20T07:24:52Z
|
mmm a / tensorflow / python / kernel_tests / matmul_op_test . py <nl> ppp b / tensorflow / python / kernel_tests / matmul_op_test . py <nl> <nl> from tensorflow . python . framework import constant_op <nl> from tensorflow . python . framework import ops <nl> from tensorflow . python . framework import test_util <nl> - from tensorflow . python . ops import gradient_checker_v2 <nl> + from tensorflow . python . ops import array_ops <nl> + from tensorflow . python . ops import gradient_checker <nl> from tensorflow . python . ops import math_ops <nl> from tensorflow . python . ops import random_ops <nl> from tensorflow . python . ops import variables <nl> class MatVecTest ( test_lib . TestCase ) : <nl> def testTwoByTwoCase ( self ) : <nl> a = np . array ( [ [ 1 , 2 ] , [ 3 , 4 ] ] ) <nl> b = np . array ( [ 5 , 6 ] ) <nl> - <nl> - c = math_ops . matvec ( a , b ) <nl> - self . assertAllEqual ( ( 2 , ) , c . shape ) <nl> - <nl> - self . assertAllEqual ( [ 5 + 2 * 6 , 3 * 5 + 4 * 6 ] , c ) <nl> + with self . cached_session ( ) : <nl> + c = math_ops . matvec ( a , b ) <nl> + self . assertAllEqual ( ( 2 , ) , c . shape ) <nl> + c_ = self . evaluate ( c ) <nl> + self . assertAllEqual ( [ 5 + 2 * 6 , 3 * 5 + 4 * 6 ] , c_ ) <nl> <nl> <nl> def _AddTest ( test , op_name , testcase_name , fn ) : <nl> def Test ( self ) : <nl> # np . matrix ( a_np_ ) * np . matrix ( b_np_ ) <nl> effective_a_np = _GetTransposedMatrices ( a_np_ , " a " , kwargs_ ) <nl> effective_b_np = _GetTransposedMatrices ( b_np_ , " b " , kwargs_ ) <nl> - with test_util . device ( use_gpu = use_gpu ) : <nl> + with self . session ( use_gpu = use_gpu ) as sess : <nl> if use_static_shape_ : <nl> a = constant_op . constant ( effective_a_np ) <nl> b = constant_op . constant ( effective_b_np ) <nl> - tf_val = math_ops . matmul ( a , b , * * kwargs_ ) <nl> + res = math_ops . matmul ( a , b , * * kwargs_ ) <nl> + tf_val = self . evaluate ( res ) <nl> else : <nl> - tf_val = math_ops . matmul ( effective_a_np , effective_b_np , * * kwargs_ ) <nl> + a = array_ops . placeholder ( a_np_ . dtype ) <nl> + b = array_ops . placeholder ( b_np_ . dtype ) <nl> + res = math_ops . matmul ( a , b , * * kwargs_ ) <nl> + tf_val = sess . run ( res , feed_dict = { a : effective_a_np , b : effective_b_np } ) <nl> <nl> self . assertAllCloseAccordingToType ( <nl> tf_val , <nl> def Test ( self ) : <nl> self . skipTest ( " Skipping infeasible gradient test . " ) <nl> <nl> # Transpose and possibly conjugate a_np_ and b_np_ according to the <nl> - # attributes such that tf . matmul ( a , b , * * kwargs ) results in a valid matrix <nl> - # multiplication and produces the same result as <nl> + # attributes such that tf . matmul ( effective_a_np , effective_b_np , * * kwargs ) <nl> + # results in a valid matrix multiplication and produces the same result as <nl> # np . matrix ( a_np_ ) * np . matrix ( b_np_ ) <nl> - a = _GetTransposedMatrices ( a_np_ , " a " , kwargs_ ) <nl> - b = _GetTransposedMatrices ( b_np_ , " b " , kwargs_ ) <nl> + effective_a_np = _GetTransposedMatrices ( a_np_ , " a " , kwargs_ ) <nl> + effective_b_np = _GetTransposedMatrices ( b_np_ , " b " , kwargs_ ) <nl> <nl> epsilon = np . finfo ( a_np_ . dtype ) . eps <nl> delta = epsilon * * ( 1 . 0 / 3 . 0 ) <nl> tol = 20 * delta <nl> with self . session ( use_gpu = True ) : <nl> - theoretical , numerical = gradient_checker_v2 . compute_gradient ( <nl> - lambda x : math_ops . matmul ( x , b , * * kwargs_ ) , [ a ] ) <nl> - self . assertAllClose ( theoretical , numerical , rtol = tol , atol = tol ) <nl> - theoretical , numerical = gradient_checker_v2 . compute_gradient ( <nl> - lambda x : math_ops . matmul ( a , x , * * kwargs_ ) , [ b ] ) <nl> - self . assertAllClose ( theoretical , numerical , rtol = tol , atol = tol ) <nl> + a = constant_op . constant ( effective_a_np ) <nl> + b = constant_op . constant ( effective_b_np ) <nl> + res = math_ops . matmul ( a , b , * * kwargs_ ) <nl> + for x , x_init in [ a , effective_a_np ] , [ b , effective_b_np ] : <nl> + theoretical , numerical = gradient_checker . compute_gradient ( <nl> + x , <nl> + x_init . shape , <nl> + res , [ a_np_ . shape [ 0 ] , b_np_ . shape [ 1 ] ] , <nl> + x_init_value = x_init , <nl> + delta = delta ) <nl> + self . assertAllClose ( theoretical , numerical , rtol = tol , atol = tol ) <nl> <nl> return Test <nl> <nl> def testInfixMatmulDoesDotProduct ( self ) : <nl> b = ops . convert_to_tensor ( [ [ 40 . 0 , 50 . 0 ] , [ 60 . 0 , 70 . 0 ] , [ 80 . 0 , 90 . 0 ] ] ) <nl> c = infix_matmul ( a , b ) <nl> d = math_ops . matmul ( a , b ) <nl> - <nl> - self . assertAllEqual ( c , d ) <nl> + with self . cached_session ( ) : <nl> + self . assertAllEqual ( c . eval ( ) , self . evaluate ( d ) ) <nl> <nl> <nl> if __name__ = = " __main__ " : <nl>
|
Automated rollback of commit 2ce0bec9da49d1848ff72233e187b2d12e59b182
|
tensorflow/tensorflow
|
8c6b4484a0965c4dca0ad2f59469acadcabb2ff2
|
2018-12-04T00:29:09Z
|
new file mode 100644 <nl> index 00000000000 . . b4679150029 <nl> mmm / dev / null <nl> ppp b / api / envoy / api / v2 / core / backoff . proto <nl> <nl> + syntax = " proto3 " ; <nl> + <nl> + package envoy . api . v2 . core ; <nl> + <nl> + import " google / protobuf / duration . proto " ; <nl> + <nl> + import " udpa / annotations / migrate . proto " ; <nl> + import " validate / validate . proto " ; <nl> + <nl> + option java_package = " io . envoyproxy . envoy . api . v2 . core " ; <nl> + option java_outer_classname = " BackoffProto " ; <nl> + option java_multiple_files = true ; <nl> + option ( udpa . annotations . file_migrate ) . move_to_package = " envoy . config . core . v3 " ; <nl> + <nl> + / / [ # protodoc - title : Backoff Strategy ] <nl> + <nl> + / / Configuration defining a jittered exponential back off strategy . <nl> + message BackoffStrategy { <nl> + / / The base interval to be used for the next back off computation . It should <nl> + / / be greater than zero and less than or equal to : ref : ` max_interval <nl> + / / < envoy_api_field_core . BackoffStrategy . max_interval > ` . <nl> + google . protobuf . Duration base_interval = 1 [ ( validate . rules ) . duration = { <nl> + required : true <nl> + gte { nanos : 1000000 } <nl> + } ] ; <nl> + <nl> + / / Specifies the maximum interval between retries . This parameter is optional , <nl> + / / but must be greater than or equal to the : ref : ` base_interval <nl> + / / < envoy_api_field_core . BackoffStrategy . base_interval > ` if set . The default <nl> + / / is 10 times the : ref : ` base_interval <nl> + / / < envoy_api_field_core . BackoffStrategy . base_interval > ` . <nl> + google . protobuf . Duration max_interval = 2 [ ( validate . rules ) . duration = { gt { } } ] ; <nl> + } <nl> mmm a / api / envoy / api / v2 / core / base . proto <nl> ppp b / api / envoy / api / v2 / core / base . proto <nl> syntax = " proto3 " ; <nl> <nl> package envoy . api . v2 . core ; <nl> <nl> + import " envoy / api / v2 / core / backoff . proto " ; <nl> import " envoy / api / v2 / core / http_uri . proto " ; <nl> import " envoy / type / percent . proto " ; <nl> import " envoy / type / semantic_version . proto " ; <nl> <nl> import " google / protobuf / any . proto " ; <nl> + import " google / protobuf / duration . proto " ; <nl> import " google / protobuf / struct . proto " ; <nl> import " google / protobuf / wrappers . proto " ; <nl> <nl> message DataSource { <nl> } <nl> } <nl> <nl> + / / The message specifies the retry policy of remote data source when fetching fails . <nl> + message RetryPolicy { <nl> + / / Specifies parameters that control : ref : ` retry backoff strategy < envoy_api_msg_core . BackoffStrategy > ` . <nl> + / / This parameter is optional , in which case the default base interval is 1000 milliseconds . The <nl> + / / default maximum interval is 10 times the base interval . <nl> + BackoffStrategy retry_back_off = 1 ; <nl> + <nl> + / / Specifies the allowed number of retries . This parameter is optional and <nl> + / / defaults to 1 . <nl> + google . protobuf . UInt32Value num_retries = 2 ; <nl> + } <nl> + <nl> / / The message specifies how to fetch data from remote and how to verify it . <nl> message RemoteDataSource { <nl> / / The HTTP URI to fetch the remote data . <nl> message RemoteDataSource { <nl> <nl> / / SHA256 string for verifying data . <nl> string sha256 = 2 [ ( validate . rules ) . string = { min_bytes : 1 } ] ; <nl> + <nl> + / / Retry policy for fetching remote data . <nl> + RetryPolicy retry_policy = 3 ; <nl> } <nl> <nl> / / Async data source which support async data fetch . <nl> new file mode 100644 <nl> index 00000000000 . . 63fc868435a <nl> mmm / dev / null <nl> ppp b / api / envoy / config / core / v3 / backoff . proto <nl> <nl> + syntax = " proto3 " ; <nl> + <nl> + package envoy . config . core . v3 ; <nl> + <nl> + import " google / protobuf / duration . proto " ; <nl> + <nl> + import " udpa / annotations / versioning . proto " ; <nl> + <nl> + import " validate / validate . proto " ; <nl> + <nl> + option java_package = " io . envoyproxy . envoy . config . core . v3 " ; <nl> + option java_outer_classname = " BackoffProto " ; <nl> + option java_multiple_files = true ; <nl> + <nl> + / / [ # protodoc - title : Backoff Strategy ] <nl> + <nl> + / / Configuration defining a jittered exponential back off strategy . <nl> + message BackoffStrategy { <nl> + option ( udpa . annotations . versioning ) . previous_message_type = " envoy . api . v2 . core . BackoffStrategy " ; <nl> + <nl> + / / The base interval to be used for the next back off computation . It should <nl> + / / be greater than zero and less than or equal to : ref : ` max_interval <nl> + / / < envoy_api_field_config . core . v3 . BackoffStrategy . max_interval > ` . <nl> + google . protobuf . Duration base_interval = 1 [ ( validate . rules ) . duration = { <nl> + required : true <nl> + gte { nanos : 1000000 } <nl> + } ] ; <nl> + <nl> + / / Specifies the maximum interval between retries . This parameter is optional , <nl> + / / but must be greater than or equal to the : ref : ` base_interval <nl> + / / < envoy_api_field_config . core . v3 . BackoffStrategy . base_interval > ` if set . The default <nl> + / / is 10 times the : ref : ` base_interval <nl> + / / < envoy_api_field_config . core . v3 . BackoffStrategy . base_interval > ` . <nl> + google . protobuf . Duration max_interval = 2 [ ( validate . rules ) . duration = { gt { } } ] ; <nl> + } <nl> mmm a / api / envoy / config / core / v3 / base . proto <nl> ppp b / api / envoy / config / core / v3 / base . proto <nl> syntax = " proto3 " ; <nl> <nl> package envoy . config . core . v3 ; <nl> <nl> + import " envoy / config / core / v3 / backoff . proto " ; <nl> import " envoy / config / core / v3 / http_uri . proto " ; <nl> import " envoy / type / v3 / percent . proto " ; <nl> import " envoy / type / v3 / semantic_version . proto " ; <nl> <nl> import " google / protobuf / any . proto " ; <nl> + import " google / protobuf / duration . proto " ; <nl> import " google / protobuf / struct . proto " ; <nl> import " google / protobuf / wrappers . proto " ; <nl> <nl> message DataSource { <nl> } <nl> } <nl> <nl> + / / The message specifies the retry policy of remote data source when fetching fails . <nl> + message RetryPolicy { <nl> + option ( udpa . annotations . versioning ) . previous_message_type = " envoy . api . v2 . core . RetryPolicy " ; <nl> + <nl> + / / Specifies parameters that control : ref : ` retry backoff strategy < envoy_api_msg_config . core . v3 . BackoffStrategy > ` . <nl> + / / This parameter is optional , in which case the default base interval is 1000 milliseconds . The <nl> + / / default maximum interval is 10 times the base interval . <nl> + BackoffStrategy retry_back_off = 1 ; <nl> + <nl> + / / Specifies the allowed number of retries . This parameter is optional and <nl> + / / defaults to 1 . <nl> + google . protobuf . UInt32Value num_retries = 2 ; <nl> + } <nl> + <nl> / / The message specifies how to fetch data from remote and how to verify it . <nl> message RemoteDataSource { <nl> option ( udpa . annotations . versioning ) . previous_message_type = " envoy . api . v2 . core . RemoteDataSource " ; <nl> message RemoteDataSource { <nl> <nl> / / SHA256 string for verifying data . <nl> string sha256 = 2 [ ( validate . rules ) . string = { min_bytes : 1 } ] ; <nl> + <nl> + / / Retry policy for fetching remote data . <nl> + RetryPolicy retry_policy = 3 ; <nl> } <nl> <nl> / / Async data source which support async data fetch . <nl> mmm a / docs / root / api - v2 / common_messages / common_messages . rst <nl> ppp b / docs / root / api - v2 / common_messages / common_messages . rst <nl> Common messages <nl> <nl> . . / api / v2 / core / base . proto <nl> . . / api / v2 / core / address . proto <nl> + . . / api / v2 / core / backoff . proto <nl> . . / api / v2 / core / protocol . proto <nl> . . / api / v2 / discovery . proto <nl> . . / api / v2 / core / config_source . proto <nl> mmm a / docs / root / api - v3 / common_messages / common_messages . rst <nl> ppp b / docs / root / api - v3 / common_messages / common_messages . rst <nl> Common messages <nl> <nl> . . / config / core / v3 / base . proto <nl> . . / config / core / v3 / address . proto <nl> + . . / config / core / v3 / backoff . proto <nl> . . / config / core / v3 / protocol . proto <nl> . . / service / discovery / v3 / discovery . proto <nl> . . / config / core / v3 / config_source . proto <nl> mmm a / docs / root / intro / version_history . rst <nl> ppp b / docs / root / intro / version_history . rst <nl> Version history <nl> * admin : added support for displaying ip address subject alternate names in : ref : ` certs < operations_admin_interface_certs > ` end point . <nl> * buffer : force copy when appending small slices to OwnedImpl buffer to avoid fragmentation . <nl> * config : use type URL to select an extension whenever the config type URL ( or its previous versions ) uniquely identify a typed extension , see : ref : ` extension configuration < config_overview_extension_configuration > ` . <nl> + * datasource : added retry policy for remote async data source . <nl> * dns : the STRICT_DNS cluster now only resolves to 0 hosts if DNS resolution successfully returns 0 hosts . <nl> * dns : added support for : ref : ` dns_failure_refresh_rate < envoy_api_field_config . common . dynamic_forward_proxy . v2alpha . DnsCacheConfig . dns_failure_refresh_rate > ` for the : ref : ` dns cache < envoy_api_msg_config . common . dynamic_forward_proxy . v2alpha . DnsCacheConfig > ` to set the DNS refresh rate during failures . <nl> * http filters : http filter extensions use the " envoy . filters . http " name space . A mapping <nl> new file mode 100644 <nl> index 00000000000 . . b4679150029 <nl> mmm / dev / null <nl> ppp b / generated_api_shadow / envoy / api / v2 / core / backoff . proto <nl> <nl> + syntax = " proto3 " ; <nl> + <nl> + package envoy . api . v2 . core ; <nl> + <nl> + import " google / protobuf / duration . proto " ; <nl> + <nl> + import " udpa / annotations / migrate . proto " ; <nl> + import " validate / validate . proto " ; <nl> + <nl> + option java_package = " io . envoyproxy . envoy . api . v2 . core " ; <nl> + option java_outer_classname = " BackoffProto " ; <nl> + option java_multiple_files = true ; <nl> + option ( udpa . annotations . file_migrate ) . move_to_package = " envoy . config . core . v3 " ; <nl> + <nl> + / / [ # protodoc - title : Backoff Strategy ] <nl> + <nl> + / / Configuration defining a jittered exponential back off strategy . <nl> + message BackoffStrategy { <nl> + / / The base interval to be used for the next back off computation . It should <nl> + / / be greater than zero and less than or equal to : ref : ` max_interval <nl> + / / < envoy_api_field_core . BackoffStrategy . max_interval > ` . <nl> + google . protobuf . Duration base_interval = 1 [ ( validate . rules ) . duration = { <nl> + required : true <nl> + gte { nanos : 1000000 } <nl> + } ] ; <nl> + <nl> + / / Specifies the maximum interval between retries . This parameter is optional , <nl> + / / but must be greater than or equal to the : ref : ` base_interval <nl> + / / < envoy_api_field_core . BackoffStrategy . base_interval > ` if set . The default <nl> + / / is 10 times the : ref : ` base_interval <nl> + / / < envoy_api_field_core . BackoffStrategy . base_interval > ` . <nl> + google . protobuf . Duration max_interval = 2 [ ( validate . rules ) . duration = { gt { } } ] ; <nl> + } <nl> mmm a / generated_api_shadow / envoy / api / v2 / core / base . proto <nl> ppp b / generated_api_shadow / envoy / api / v2 / core / base . proto <nl> syntax = " proto3 " ; <nl> <nl> package envoy . api . v2 . core ; <nl> <nl> + import " envoy / api / v2 / core / backoff . proto " ; <nl> import " envoy / api / v2 / core / http_uri . proto " ; <nl> import " envoy / type / percent . proto " ; <nl> import " envoy / type / semantic_version . proto " ; <nl> <nl> import " google / protobuf / any . proto " ; <nl> + import " google / protobuf / duration . proto " ; <nl> import " google / protobuf / struct . proto " ; <nl> import " google / protobuf / wrappers . proto " ; <nl> <nl> message DataSource { <nl> } <nl> } <nl> <nl> + / / The message specifies the retry policy of remote data source when fetching fails . <nl> + message RetryPolicy { <nl> + / / Specifies parameters that control : ref : ` retry backoff strategy < envoy_api_msg_core . BackoffStrategy > ` . <nl> + / / This parameter is optional , in which case the default base interval is 1000 milliseconds . The <nl> + / / default maximum interval is 10 times the base interval . <nl> + BackoffStrategy retry_back_off = 1 ; <nl> + <nl> + / / Specifies the allowed number of retries . This parameter is optional and <nl> + / / defaults to 1 . <nl> + google . protobuf . UInt32Value num_retries = 2 ; <nl> + } <nl> + <nl> / / The message specifies how to fetch data from remote and how to verify it . <nl> message RemoteDataSource { <nl> / / The HTTP URI to fetch the remote data . <nl> message RemoteDataSource { <nl> <nl> / / SHA256 string for verifying data . <nl> string sha256 = 2 [ ( validate . rules ) . string = { min_bytes : 1 } ] ; <nl> + <nl> + / / Retry policy for fetching remote data . <nl> + RetryPolicy retry_policy = 3 ; <nl> } <nl> <nl> / / Async data source which support async data fetch . <nl> new file mode 100644 <nl> index 00000000000 . . 63fc868435a <nl> mmm / dev / null <nl> ppp b / generated_api_shadow / envoy / config / core / v3 / backoff . proto <nl> <nl> + syntax = " proto3 " ; <nl> + <nl> + package envoy . config . core . v3 ; <nl> + <nl> + import " google / protobuf / duration . proto " ; <nl> + <nl> + import " udpa / annotations / versioning . proto " ; <nl> + <nl> + import " validate / validate . proto " ; <nl> + <nl> + option java_package = " io . envoyproxy . envoy . config . core . v3 " ; <nl> + option java_outer_classname = " BackoffProto " ; <nl> + option java_multiple_files = true ; <nl> + <nl> + / / [ # protodoc - title : Backoff Strategy ] <nl> + <nl> + / / Configuration defining a jittered exponential back off strategy . <nl> + message BackoffStrategy { <nl> + option ( udpa . annotations . versioning ) . previous_message_type = " envoy . api . v2 . core . BackoffStrategy " ; <nl> + <nl> + / / The base interval to be used for the next back off computation . It should <nl> + / / be greater than zero and less than or equal to : ref : ` max_interval <nl> + / / < envoy_api_field_config . core . v3 . BackoffStrategy . max_interval > ` . <nl> + google . protobuf . Duration base_interval = 1 [ ( validate . rules ) . duration = { <nl> + required : true <nl> + gte { nanos : 1000000 } <nl> + } ] ; <nl> + <nl> + / / Specifies the maximum interval between retries . This parameter is optional , <nl> + / / but must be greater than or equal to the : ref : ` base_interval <nl> + / / < envoy_api_field_config . core . v3 . BackoffStrategy . base_interval > ` if set . The default <nl> + / / is 10 times the : ref : ` base_interval <nl> + / / < envoy_api_field_config . core . v3 . BackoffStrategy . base_interval > ` . <nl> + google . protobuf . Duration max_interval = 2 [ ( validate . rules ) . duration = { gt { } } ] ; <nl> + } <nl> mmm a / generated_api_shadow / envoy / config / core / v3 / base . proto <nl> ppp b / generated_api_shadow / envoy / config / core / v3 / base . proto <nl> syntax = " proto3 " ; <nl> <nl> package envoy . config . core . v3 ; <nl> <nl> + import " envoy / config / core / v3 / backoff . proto " ; <nl> import " envoy / config / core / v3 / http_uri . proto " ; <nl> import " envoy / type / v3 / percent . proto " ; <nl> import " envoy / type / v3 / semantic_version . proto " ; <nl> <nl> import " google / protobuf / any . proto " ; <nl> + import " google / protobuf / duration . proto " ; <nl> import " google / protobuf / struct . proto " ; <nl> import " google / protobuf / wrappers . proto " ; <nl> <nl> message DataSource { <nl> } <nl> } <nl> <nl> + / / The message specifies the retry policy of remote data source when fetching fails . <nl> + message RetryPolicy { <nl> + option ( udpa . annotations . versioning ) . previous_message_type = " envoy . api . v2 . core . RetryPolicy " ; <nl> + <nl> + / / Specifies parameters that control : ref : ` retry backoff strategy < envoy_api_msg_config . core . v3 . BackoffStrategy > ` . <nl> + / / This parameter is optional , in which case the default base interval is 1000 milliseconds . The <nl> + / / default maximum interval is 10 times the base interval . <nl> + BackoffStrategy retry_back_off = 1 ; <nl> + <nl> + / / Specifies the allowed number of retries . This parameter is optional and <nl> + / / defaults to 1 . <nl> + google . protobuf . UInt32Value num_retries = 2 ; <nl> + } <nl> + <nl> / / The message specifies how to fetch data from remote and how to verify it . <nl> message RemoteDataSource { <nl> option ( udpa . annotations . versioning ) . previous_message_type = " envoy . api . v2 . core . RemoteDataSource " ; <nl> message RemoteDataSource { <nl> <nl> / / SHA256 string for verifying data . <nl> string sha256 = 2 [ ( validate . rules ) . string = { min_bytes : 1 } ] ; <nl> + <nl> + / / Retry policy for fetching remote data . <nl> + RetryPolicy retry_policy = 3 ; <nl> } <nl> <nl> / / Async data source which support async data fetch . <nl> mmm a / source / common / config / BUILD <nl> ppp b / source / common / config / BUILD <nl> envoy_cc_library ( <nl> " / / include / envoy / api : api_interface " , <nl> " / / include / envoy / init : manager_interface " , <nl> " / / include / envoy / upstream : cluster_manager_interface " , <nl> + " / / source / common / common : backoff_lib " , <nl> " / / source / common / common : empty_string " , <nl> " / / source / common / init : target_lib " , <nl> " / / source / common / protobuf : utility_lib " , <nl> mmm a / source / common / config / datasource . cc <nl> ppp b / source / common / config / datasource . cc <nl> namespace Envoy { <nl> namespace Config { <nl> namespace DataSource { <nl> <nl> + / / Parameters of the jittered backoff strategy . <nl> + static constexpr uint32_t RetryInitialDelayMilliseconds = 1000 ; <nl> + static constexpr uint32_t RetryMaxDelayMilliseconds = 10 * 1000 ; <nl> + static constexpr uint32_t RetryCount = 1 ; <nl> + <nl> std : : string read ( const envoy : : config : : core : : v3 : : DataSource & source , bool allow_empty , <nl> Api : : Api & api ) { <nl> switch ( source . specifier_case ( ) ) { <nl> absl : : optional < std : : string > getPath ( const envoy : : config : : core : : v3 : : DataSource & s <nl> : absl : : nullopt ; <nl> } <nl> <nl> + RemoteAsyncDataProvider : : RemoteAsyncDataProvider ( <nl> + Upstream : : ClusterManager & cm , Init : : Manager & manager , <nl> + const envoy : : config : : core : : v3 : : RemoteDataSource & source , Event : : Dispatcher & dispatcher , <nl> + Runtime : : RandomGenerator & random , bool allow_empty , AsyncDataSourceCb & & callback ) <nl> + : allow_empty_ ( allow_empty ) , callback_ ( std : : move ( callback ) ) , <nl> + fetcher_ ( std : : make_unique < Config : : DataFetcher : : RemoteDataFetcher > ( cm , source . http_uri ( ) , <nl> + source . sha256 ( ) , * this ) ) , <nl> + init_target_ ( " RemoteAsyncDataProvider " , [ this ] ( ) { start ( ) ; } ) , <nl> + retries_remaining_ ( <nl> + PROTOBUF_GET_WRAPPED_OR_DEFAULT ( source . retry_policy ( ) , num_retries , RetryCount ) ) { <nl> + <nl> + uint64_t base_interval_ms = RetryInitialDelayMilliseconds ; <nl> + uint64_t max_interval_ms = RetryMaxDelayMilliseconds ; <nl> + if ( source . has_retry_policy ( ) ) { <nl> + if ( source . retry_policy ( ) . has_retry_back_off ( ) ) { <nl> + base_interval_ms = <nl> + PROTOBUF_GET_MS_REQUIRED ( source . retry_policy ( ) . retry_back_off ( ) , base_interval ) ; <nl> + <nl> + max_interval_ms = PROTOBUF_GET_MS_OR_DEFAULT ( source . retry_policy ( ) . retry_back_off ( ) , <nl> + max_interval , base_interval_ms * 10 ) ; <nl> + <nl> + if ( max_interval_ms < base_interval_ms ) { <nl> + throw EnvoyException ( " max_interval must be greater than or equal to the base_interval " ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + backoff_strategy_ = <nl> + std : : make_unique < JitteredBackOffStrategy > ( base_interval_ms , max_interval_ms , random ) ; <nl> + retry_timer_ = dispatcher . createTimer ( [ this ] ( ) - > void { start ( ) ; } ) ; <nl> + <nl> + manager . add ( init_target_ ) ; <nl> + } <nl> + <nl> } / / namespace DataSource <nl> } / / namespace Config <nl> } / / namespace Envoy <nl> mmm a / source / common / config / datasource . h <nl> ppp b / source / common / config / datasource . h <nl> <nl> # include " envoy / init / manager . h " <nl> # include " envoy / upstream / cluster_manager . h " <nl> <nl> + # include " common / common / backoff_strategy . h " <nl> # include " common / common / empty_string . h " <nl> # include " common / common / enum_to_int . h " <nl> # include " common / config / remote_data_fetcher . h " <nl> class RemoteAsyncDataProvider : public Config : : DataFetcher : : RemoteDataFetcherCal <nl> public Logger : : Loggable < Logger : : Id : : config > { <nl> public : <nl> RemoteAsyncDataProvider ( Upstream : : ClusterManager & cm , Init : : Manager & manager , <nl> - const envoy : : config : : core : : v3 : : RemoteDataSource & source , bool allow_empty , <nl> - AsyncDataSourceCb & & callback ) <nl> - : allow_empty_ ( allow_empty ) , callback_ ( std : : move ( callback ) ) , <nl> - fetcher_ ( std : : make_unique < Config : : DataFetcher : : RemoteDataFetcher > ( cm , source . http_uri ( ) , <nl> - source . sha256 ( ) , * this ) ) , <nl> - init_target_ ( " RemoteAsyncDataProvider " , [ this ] ( ) { start ( ) ; } ) { <nl> - manager . add ( init_target_ ) ; <nl> - } <nl> + const envoy : : config : : core : : v3 : : RemoteDataSource & source , <nl> + Event : : Dispatcher & dispatcher , Runtime : : RandomGenerator & random , <nl> + bool allow_empty , AsyncDataSourceCb & & callback ) ; <nl> <nl> - ~ RemoteAsyncDataProvider ( ) override { init_target_ . ready ( ) ; } <nl> + ~ RemoteAsyncDataProvider ( ) override { <nl> + init_target_ . ready ( ) ; <nl> + if ( retry_timer_ ) { <nl> + retry_timer_ - > disableTimer ( ) ; <nl> + } <nl> + } <nl> <nl> / / Config : : DataFetcher : : RemoteDataFetcherCallback <nl> void onSuccess ( const std : : string & data ) override { <nl> class RemoteAsyncDataProvider : public Config : : DataFetcher : : RemoteDataFetcherCal <nl> <nl> / / Config : : DataFetcher : : RemoteDataFetcherCallback <nl> void onFailure ( Config : : DataFetcher : : FailureReason failure ) override { <nl> - ENVOY_LOG ( debug , " Failed to fetch remote data . Failure reason : { } " , enumToInt ( failure ) ) ; <nl> - if ( allow_empty_ ) { <nl> - callback_ ( EMPTY_STRING ) ; <nl> + ENVOY_LOG ( debug , " Failed to fetch remote data , failure reason : { } " , enumToInt ( failure ) ) ; <nl> + if ( retries_remaining_ - - = = 0 ) { <nl> + ENVOY_LOG ( warn , " Retry limit exceeded for fetching data from remote data source . " ) ; <nl> + if ( allow_empty_ ) { <nl> + callback_ ( EMPTY_STRING ) ; <nl> + } <nl> + / / We need to allow server startup to continue . <nl> + init_target_ . ready ( ) ; <nl> + return ; <nl> } <nl> - / / We need to allow server startup to continue . <nl> - init_target_ . ready ( ) ; <nl> + <nl> + const auto retry_ms = std : : chrono : : milliseconds ( backoff_strategy_ - > nextBackOffMs ( ) ) ; <nl> + ENVOY_LOG ( debug , " Remote data provider will retry in { } ms . " , retry_ms . count ( ) ) ; <nl> + retry_timer_ - > enableTimer ( retry_ms ) ; <nl> } <nl> <nl> private : <nl> class RemoteAsyncDataProvider : public Config : : DataFetcher : : RemoteDataFetcherCal <nl> AsyncDataSourceCb callback_ ; <nl> const Config : : DataFetcher : : RemoteDataFetcherPtr fetcher_ ; <nl> Init : : TargetImpl init_target_ ; <nl> + <nl> + Event : : TimerPtr retry_timer_ ; <nl> + BackOffStrategyPtr backoff_strategy_ ; <nl> + uint32_t retries_remaining_ ; <nl> } ; <nl> <nl> using RemoteAsyncDataProviderPtr = std : : unique_ptr < RemoteAsyncDataProvider > ; <nl> mmm a / test / common / config / BUILD <nl> ppp b / test / common / config / BUILD <nl> envoy_cc_test ( <nl> " / / source / common / config : datasource_lib " , <nl> " / / source / common / protobuf : utility_lib " , <nl> " / / source / extensions / common / crypto : utility_lib " , <nl> + " / / test / mocks / event : event_mocks " , <nl> " / / test / mocks / server : server_mocks " , <nl> " / / test / mocks / upstream : upstream_mocks " , <nl> " / / test / test_common : utility_lib " , <nl> mmm a / test / common / config / datasource_test . cc <nl> ppp b / test / common / config / datasource_test . cc <nl> <nl> # include " envoy / config / core / v3 / base . pb . h " <nl> + # include " envoy / config / core / v3 / base . pb . validate . h " <nl> <nl> # include " common / common / empty_string . h " <nl> # include " common / config / datasource . h " <nl> # include " common / protobuf / protobuf . h " <nl> <nl> + # include " test / mocks / event / mocks . h " <nl> # include " test / mocks / server / mocks . h " <nl> # include " test / mocks / upstream / mocks . h " <nl> # include " test / test_common / utility . h " <nl> <nl> # include " gtest / gtest . h " <nl> <nl> + using testing : : AtLeast ; <nl> using testing : : NiceMock ; <nl> using testing : : Return ; <nl> <nl> namespace { <nl> <nl> class AsyncDataSourceTest : public testing : : Test { <nl> protected : <nl> - AsyncDataSourceTest ( ) : api_ ( Api : : createApiForTest ( ) ) { } <nl> - <nl> using AsyncDataSourcePb = envoy : : config : : core : : v3 : : AsyncDataSource ; <nl> <nl> NiceMock < Upstream : : MockClusterManager > cm_ ; <nl> Init : : MockManager init_manager_ ; <nl> Init : : ExpectableWatcherImpl init_watcher_ ; <nl> Init : : TargetHandlePtr init_target_handle_ ; <nl> - Api : : ApiPtr api_ ; <nl> + Api : : ApiPtr api_ { Api : : createApiForTest ( ) } ; <nl> + NiceMock < Runtime : : MockRandomGenerator > random_ ; <nl> + Event : : MockDispatcher dispatcher_ ; <nl> + Event : : MockTimer * retry_timer_ ; <nl> + Event : : TimerCb retry_timer_cb_ ; <nl> + <nl> + Config : : DataSource : : LocalAsyncDataProviderPtr local_data_provider_ ; <nl> + Config : : DataSource : : RemoteAsyncDataProviderPtr remote_data_provider_ ; <nl> + <nl> + using AsyncClientSendFunc = std : : function < Http : : AsyncClient : : Request * ( <nl> + Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & , <nl> + const Http : : AsyncClient : : RequestOptions ) > ; <nl> + <nl> + void initialize ( AsyncClientSendFunc func , int num_retries = 1 ) { <nl> + retry_timer_ = new Event : : MockTimer ( ) ; <nl> + EXPECT_CALL ( init_manager_ , add ( _ ) ) . WillOnce ( Invoke ( [ this ] ( const Init : : Target & target ) { <nl> + init_target_handle_ = target . createHandle ( " test " ) ; <nl> + } ) ) ; <nl> + <nl> + EXPECT_CALL ( dispatcher_ , createTimer_ ( _ ) ) . WillOnce ( Invoke ( [ this ] ( Event : : TimerCb timer_cb ) { <nl> + retry_timer_cb_ = timer_cb ; <nl> + return retry_timer_ ; <nl> + } ) ) ; <nl> + <nl> + EXPECT_CALL ( cm_ , httpAsyncClientForCluster ( " cluster_1 " ) ) <nl> + . Times ( AtLeast ( 1 ) ) <nl> + . WillRepeatedly ( ReturnRef ( cm_ . async_client_ ) ) ; <nl> + <nl> + EXPECT_CALL ( * retry_timer_ , disableTimer ( ) ) ; <nl> + if ( num_retries = = 1 ) { <nl> + EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) . Times ( AtLeast ( 1 ) ) . WillRepeatedly ( Invoke ( func ) ) ; <nl> + } else { <nl> + EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> + . Times ( num_retries ) <nl> + . WillRepeatedly ( Invoke ( func ) ) ; <nl> + } <nl> + } <nl> } ; <nl> <nl> TEST_F ( AsyncDataSourceTest , LoadLocalDataSource ) { <nl> TEST_F ( AsyncDataSourceTest , LoadLocalDataSource ) { <nl> inline_string : <nl> xxxxxx <nl> ) EOF " ; <nl> - TestUtility : : loadFromYaml ( yaml , config ) ; <nl> + TestUtility : : loadFromYamlAndValidate ( yaml , config ) ; <nl> EXPECT_TRUE ( config . has_local ( ) ) ; <nl> <nl> std : : string async_data ; <nl> TEST_F ( AsyncDataSourceTest , LoadLocalDataSource ) { <nl> init_target_handle_ = target . createHandle ( " test " ) ; <nl> } ) ) ; <nl> <nl> - auto provider = std : : make_unique < Config : : DataSource : : LocalAsyncDataProvider > ( <nl> + local_data_provider_ = std : : make_unique < Config : : DataSource : : LocalAsyncDataProvider > ( <nl> init_manager_ , config . local ( ) , true , * api_ , [ & ] ( const std : : string & data ) { <nl> EXPECT_EQ ( init_manager_ . state ( ) , Init : : Manager : : State : : Initializing ) ; <nl> EXPECT_EQ ( data , " xxxxxx " ) ; <nl> TEST_F ( AsyncDataSourceTest , LoadLocalDataSource ) { <nl> EXPECT_CALL ( init_watcher_ , ready ( ) ) ; <nl> <nl> init_target_handle_ - > initialize ( init_watcher_ ) ; <nl> - <nl> EXPECT_EQ ( async_data , " xxxxxx " ) ; <nl> - EXPECT_NE ( nullptr , provider . get ( ) ) ; <nl> } <nl> <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceReturnFailure ) { <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceReturnFailure ) { <nl> http_uri : <nl> uri : https : / / example . com / data <nl> cluster : cluster_1 <nl> + timeout : 1s <nl> sha256 : <nl> xxxxxx <nl> ) EOF " ; <nl> - TestUtility : : loadFromYaml ( yaml , config ) ; <nl> + TestUtility : : loadFromYamlAndValidate ( yaml , config ) ; <nl> EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> <nl> - EXPECT_CALL ( cm_ , httpAsyncClientForCluster ( " cluster_1 " ) ) . WillOnce ( ReturnRef ( cm_ . async_client_ ) ) ; <nl> - EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> - . WillOnce ( <nl> - Invoke ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> - const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> - callbacks . onFailure ( Envoy : : Http : : AsyncClient : : FailureReason : : Reset ) ; <nl> - return nullptr ; <nl> - } ) ) ; <nl> - <nl> - EXPECT_CALL ( init_manager_ , add ( _ ) ) . WillOnce ( Invoke ( [ this ] ( const Init : : Target & target ) { <nl> - init_target_handle_ = target . createHandle ( " test " ) ; <nl> - } ) ) ; <nl> + initialize ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> + const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> + callbacks . onFailure ( Envoy : : Http : : AsyncClient : : FailureReason : : Reset ) ; <nl> + return nullptr ; <nl> + } ) ; <nl> <nl> std : : string async_data = " non - empty " ; <nl> - auto provider = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> - cm_ , init_manager_ , config . remote ( ) , true , [ & ] ( const std : : string & data ) { <nl> + remote_data_provider_ = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> + cm_ , init_manager_ , config . remote ( ) , dispatcher_ , random_ , true , <nl> + [ & ] ( const std : : string & data ) { <nl> EXPECT_EQ ( init_manager_ . state ( ) , Init : : Manager : : State : : Initializing ) ; <nl> EXPECT_EQ ( data , EMPTY_STRING ) ; <nl> async_data = data ; <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceReturnFailure ) { <nl> <nl> EXPECT_CALL ( init_manager_ , state ( ) ) . WillOnce ( Return ( Init : : Manager : : State : : Initializing ) ) ; <nl> EXPECT_CALL ( init_watcher_ , ready ( ) ) ; <nl> - <nl> + EXPECT_CALL ( * retry_timer_ , enableTimer ( _ , _ ) ) <nl> + . WillOnce ( Invoke ( <nl> + [ & ] ( const std : : chrono : : milliseconds & , const ScopeTrackedObject * ) { retry_timer_cb_ ( ) ; } ) ) ; <nl> init_target_handle_ - > initialize ( init_watcher_ ) ; <nl> <nl> EXPECT_EQ ( async_data , EMPTY_STRING ) ; <nl> - EXPECT_NE ( nullptr , provider . get ( ) ) ; <nl> } <nl> <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccessWith503 ) { <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccessWith503 ) { <nl> http_uri : <nl> uri : https : / / example . com / data <nl> cluster : cluster_1 <nl> + timeout : 1s <nl> sha256 : <nl> xxxxxx <nl> ) EOF " ; <nl> - TestUtility : : loadFromYaml ( yaml , config ) ; <nl> + TestUtility : : loadFromYamlAndValidate ( yaml , config ) ; <nl> EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> <nl> - EXPECT_CALL ( cm_ , httpAsyncClientForCluster ( " cluster_1 " ) ) . WillOnce ( ReturnRef ( cm_ . async_client_ ) ) ; <nl> - EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> - . WillOnce ( <nl> - Invoke ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> - const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> - callbacks . onSuccess ( <nl> - Http : : ResponseMessagePtr { new Http : : ResponseMessageImpl ( Http : : ResponseHeaderMapPtr { <nl> - new Http : : TestResponseHeaderMapImpl { { " : status " , " 503 " } } } ) } ) ; <nl> - return nullptr ; <nl> - } ) ) ; <nl> - <nl> - EXPECT_CALL ( init_manager_ , add ( _ ) ) . WillOnce ( Invoke ( [ this ] ( const Init : : Target & target ) { <nl> - init_target_handle_ = target . createHandle ( " test " ) ; <nl> - } ) ) ; <nl> + initialize ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> + const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> + callbacks . onSuccess ( Http : : ResponseMessagePtr { new Http : : ResponseMessageImpl ( <nl> + Http : : ResponseHeaderMapPtr { new Http : : TestResponseHeaderMapImpl { { " : status " , " 503 " } } } ) } ) ; <nl> + return nullptr ; <nl> + } ) ; <nl> <nl> std : : string async_data = " non - empty " ; <nl> - auto provider = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> - cm_ , init_manager_ , config . remote ( ) , true , [ & ] ( const std : : string & data ) { <nl> + remote_data_provider_ = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> + cm_ , init_manager_ , config . remote ( ) , dispatcher_ , random_ , true , <nl> + [ & ] ( const std : : string & data ) { <nl> EXPECT_EQ ( init_manager_ . state ( ) , Init : : Manager : : State : : Initializing ) ; <nl> EXPECT_EQ ( data , EMPTY_STRING ) ; <nl> async_data = data ; <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccessWith503 ) { <nl> <nl> EXPECT_CALL ( init_manager_ , state ( ) ) . WillOnce ( Return ( Init : : Manager : : State : : Initializing ) ) ; <nl> EXPECT_CALL ( init_watcher_ , ready ( ) ) ; <nl> - <nl> + EXPECT_CALL ( * retry_timer_ , enableTimer ( _ , _ ) ) <nl> + . WillOnce ( Invoke ( <nl> + [ & ] ( const std : : chrono : : milliseconds & , const ScopeTrackedObject * ) { retry_timer_cb_ ( ) ; } ) ) ; <nl> init_target_handle_ - > initialize ( init_watcher_ ) ; <nl> + <nl> EXPECT_EQ ( async_data , EMPTY_STRING ) ; <nl> - EXPECT_NE ( nullptr , provider . get ( ) ) ; <nl> } <nl> <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccessWithEmptyBody ) { <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccessWithEmptyBody ) { <nl> http_uri : <nl> uri : https : / / example . com / data <nl> cluster : cluster_1 <nl> + timeout : 1s <nl> sha256 : <nl> xxxxxx <nl> ) EOF " ; <nl> - TestUtility : : loadFromYaml ( yaml , config ) ; <nl> + TestUtility : : loadFromYamlAndValidate ( yaml , config ) ; <nl> EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> <nl> - EXPECT_CALL ( cm_ , httpAsyncClientForCluster ( " cluster_1 " ) ) . WillOnce ( ReturnRef ( cm_ . async_client_ ) ) ; <nl> - EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> - . WillOnce ( <nl> - Invoke ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> - const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> - callbacks . onSuccess ( <nl> - Http : : ResponseMessagePtr { new Http : : ResponseMessageImpl ( Http : : ResponseHeaderMapPtr { <nl> - new Http : : TestResponseHeaderMapImpl { { " : status " , " 200 " } } } ) } ) ; <nl> - return nullptr ; <nl> - } ) ) ; <nl> - <nl> - EXPECT_CALL ( init_manager_ , add ( _ ) ) . WillOnce ( Invoke ( [ this ] ( const Init : : Target & target ) { <nl> - init_target_handle_ = target . createHandle ( " test " ) ; <nl> - } ) ) ; <nl> + initialize ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> + const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> + callbacks . onSuccess ( Http : : ResponseMessagePtr { new Http : : ResponseMessageImpl ( <nl> + Http : : ResponseHeaderMapPtr { new Http : : TestResponseHeaderMapImpl { { " : status " , " 200 " } } } ) } ) ; <nl> + return nullptr ; <nl> + } ) ; <nl> <nl> std : : string async_data = " non - empty " ; <nl> - auto provider = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> - cm_ , init_manager_ , config . remote ( ) , true , [ & ] ( const std : : string & data ) { <nl> + remote_data_provider_ = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> + cm_ , init_manager_ , config . remote ( ) , dispatcher_ , random_ , true , <nl> + [ & ] ( const std : : string & data ) { <nl> EXPECT_EQ ( init_manager_ . state ( ) , Init : : Manager : : State : : Initializing ) ; <nl> EXPECT_EQ ( data , EMPTY_STRING ) ; <nl> async_data = data ; <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccessWithEmptyBody ) { <nl> <nl> EXPECT_CALL ( init_manager_ , state ( ) ) . WillOnce ( Return ( Init : : Manager : : State : : Initializing ) ) ; <nl> EXPECT_CALL ( init_watcher_ , ready ( ) ) ; <nl> - <nl> + EXPECT_CALL ( * retry_timer_ , enableTimer ( _ , _ ) ) <nl> + . WillOnce ( Invoke ( <nl> + [ & ] ( const std : : chrono : : milliseconds & , const ScopeTrackedObject * ) { retry_timer_cb_ ( ) ; } ) ) ; <nl> init_target_handle_ - > initialize ( init_watcher_ ) ; <nl> <nl> EXPECT_EQ ( async_data , EMPTY_STRING ) ; <nl> - EXPECT_NE ( nullptr , provider . get ( ) ) ; <nl> } <nl> <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccessIncorrectSha256 ) { <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccessIncorrectSha256 ) { <nl> http_uri : <nl> uri : https : / / example . com / data <nl> cluster : cluster_1 <nl> + timeout : 1s <nl> sha256 : <nl> xxxxxx <nl> ) EOF " ; <nl> - TestUtility : : loadFromYaml ( yaml , config ) ; <nl> + TestUtility : : loadFromYamlAndValidate ( yaml , config ) ; <nl> EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> <nl> const std : : string body = " hello world " ; <nl> <nl> - EXPECT_CALL ( cm_ , httpAsyncClientForCluster ( " cluster_1 " ) ) . WillOnce ( ReturnRef ( cm_ . async_client_ ) ) ; <nl> - EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> - . WillOnce ( <nl> - Invoke ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> - const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> - Http : : ResponseMessagePtr response ( <nl> - new Http : : ResponseMessageImpl ( Http : : ResponseHeaderMapPtr { <nl> - new Http : : TestResponseHeaderMapImpl { { " : status " , " 200 " } } } ) ) ; <nl> - response - > body ( ) = std : : make_unique < Buffer : : OwnedImpl > ( body ) ; <nl> - <nl> - callbacks . onSuccess ( std : : move ( response ) ) ; <nl> - return nullptr ; <nl> - } ) ) ; <nl> + initialize ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> + const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> + Http : : ResponseMessagePtr response ( new Http : : ResponseMessageImpl ( <nl> + Http : : ResponseHeaderMapPtr { new Http : : TestResponseHeaderMapImpl { { " : status " , " 200 " } } } ) ) ; <nl> + response - > body ( ) = std : : make_unique < Buffer : : OwnedImpl > ( body ) ; <nl> <nl> - EXPECT_CALL ( init_manager_ , add ( _ ) ) . WillOnce ( Invoke ( [ this ] ( const Init : : Target & target ) { <nl> - init_target_handle_ = target . createHandle ( " test " ) ; <nl> - } ) ) ; <nl> + callbacks . onSuccess ( std : : move ( response ) ) ; <nl> + return nullptr ; <nl> + } ) ; <nl> <nl> std : : string async_data = " non - empty " ; <nl> - auto provider = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> - cm_ , init_manager_ , config . remote ( ) , true , [ & ] ( const std : : string & data ) { <nl> + remote_data_provider_ = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> + cm_ , init_manager_ , config . remote ( ) , dispatcher_ , random_ , true , <nl> + [ & ] ( const std : : string & data ) { <nl> EXPECT_EQ ( init_manager_ . state ( ) , Init : : Manager : : State : : Initializing ) ; <nl> EXPECT_EQ ( data , EMPTY_STRING ) ; <nl> async_data = data ; <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccessIncorrectSha256 ) { <nl> <nl> EXPECT_CALL ( init_manager_ , state ( ) ) . WillOnce ( Return ( Init : : Manager : : State : : Initializing ) ) ; <nl> EXPECT_CALL ( init_watcher_ , ready ( ) ) ; <nl> - <nl> + EXPECT_CALL ( * retry_timer_ , enableTimer ( _ , _ ) ) <nl> + . WillOnce ( Invoke ( <nl> + [ & ] ( const std : : chrono : : milliseconds & , const ScopeTrackedObject * ) { retry_timer_cb_ ( ) ; } ) ) ; <nl> init_target_handle_ - > initialize ( init_watcher_ ) ; <nl> + <nl> EXPECT_EQ ( async_data , EMPTY_STRING ) ; <nl> - EXPECT_NE ( nullptr , provider . get ( ) ) ; <nl> } <nl> <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccess ) { <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccess ) { <nl> http_uri : <nl> uri : https : / / example . com / data <nl> cluster : cluster_1 <nl> + timeout : 1s <nl> sha256 : <nl> b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9 <nl> ) EOF " ; <nl> - TestUtility : : loadFromYaml ( yaml , config ) ; <nl> + TestUtility : : loadFromYamlAndValidate ( yaml , config ) ; <nl> EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> <nl> const std : : string body = " hello world " ; <nl> + initialize ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> + const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> + Http : : ResponseMessagePtr response ( new Http : : ResponseMessageImpl ( <nl> + Http : : ResponseHeaderMapPtr { new Http : : TestResponseHeaderMapImpl { { " : status " , " 200 " } } } ) ) ; <nl> + response - > body ( ) = std : : make_unique < Buffer : : OwnedImpl > ( body ) ; <nl> <nl> - EXPECT_CALL ( cm_ , httpAsyncClientForCluster ( " cluster_1 " ) ) . WillOnce ( ReturnRef ( cm_ . async_client_ ) ) ; <nl> - EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> - . WillOnce ( <nl> - Invoke ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> - const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> - Http : : ResponseMessagePtr response ( <nl> - new Http : : ResponseMessageImpl ( Http : : ResponseHeaderMapPtr { <nl> - new Http : : TestResponseHeaderMapImpl { { " : status " , " 200 " } } } ) ) ; <nl> - response - > body ( ) = std : : make_unique < Buffer : : OwnedImpl > ( body ) ; <nl> - <nl> - callbacks . onSuccess ( std : : move ( response ) ) ; <nl> - return nullptr ; <nl> - } ) ) ; <nl> - <nl> - EXPECT_CALL ( init_manager_ , add ( _ ) ) . WillOnce ( Invoke ( [ this ] ( const Init : : Target & target ) { <nl> - init_target_handle_ = target . createHandle ( " test " ) ; <nl> - } ) ) ; <nl> + callbacks . onSuccess ( std : : move ( response ) ) ; <nl> + return nullptr ; <nl> + } ) ; <nl> <nl> std : : string async_data = " non - empty " ; <nl> - auto provider = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> - cm_ , init_manager_ , config . remote ( ) , true , [ & ] ( const std : : string & data ) { <nl> + remote_data_provider_ = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> + cm_ , init_manager_ , config . remote ( ) , dispatcher_ , random_ , true , <nl> + [ & ] ( const std : : string & data ) { <nl> EXPECT_EQ ( init_manager_ . state ( ) , Init : : Manager : : State : : Initializing ) ; <nl> EXPECT_EQ ( data , body ) ; <nl> async_data = data ; <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceSuccess ) { <nl> <nl> EXPECT_CALL ( init_manager_ , state ( ) ) . WillOnce ( Return ( Init : : Manager : : State : : Initializing ) ) ; <nl> EXPECT_CALL ( init_watcher_ , ready ( ) ) ; <nl> - <nl> init_target_handle_ - > initialize ( init_watcher_ ) ; <nl> + <nl> EXPECT_EQ ( async_data , body ) ; <nl> - EXPECT_NE ( nullptr , provider . get ( ) ) ; <nl> } <nl> <nl> - TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceExpectNetworkFailure ) { <nl> + TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceDoNotAllowEmpty ) { <nl> AsyncDataSourcePb config ; <nl> <nl> std : : string yaml = R " EOF ( <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceExpectNetworkFailure ) { <nl> http_uri : <nl> uri : https : / / example . com / data <nl> cluster : cluster_1 <nl> + timeout : 1s <nl> sha256 : <nl> xxxxxx <nl> ) EOF " ; <nl> - TestUtility : : loadFromYaml ( yaml , config ) ; <nl> + TestUtility : : loadFromYamlAndValidate ( yaml , config ) ; <nl> EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> <nl> - EXPECT_CALL ( cm_ , httpAsyncClientForCluster ( " cluster_1 " ) ) . WillOnce ( ReturnRef ( cm_ . async_client_ ) ) ; <nl> - EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> - . WillOnce ( <nl> - Invoke ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> - const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> - callbacks . onSuccess ( <nl> - Http : : ResponseMessagePtr { new Http : : ResponseMessageImpl ( Http : : ResponseHeaderMapPtr { <nl> - new Http : : TestResponseHeaderMapImpl { { " : status " , " 503 " } } } ) } ) ; <nl> - return nullptr ; <nl> - } ) ) ; <nl> - <nl> - EXPECT_CALL ( init_manager_ , add ( _ ) ) . WillOnce ( Invoke ( [ this ] ( const Init : : Target & target ) { <nl> - init_target_handle_ = target . createHandle ( " test " ) ; <nl> - } ) ) ; <nl> + initialize ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> + const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> + callbacks . onSuccess ( Http : : ResponseMessagePtr { new Http : : ResponseMessageImpl ( <nl> + Http : : ResponseHeaderMapPtr { new Http : : TestResponseHeaderMapImpl { { " : status " , " 503 " } } } ) } ) ; <nl> + return nullptr ; <nl> + } ) ; <nl> <nl> std : : string async_data = " non - empty " ; <nl> - auto provider = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> - cm_ , init_manager_ , config . remote ( ) , true , <nl> - [ & async_data ] ( const std : : string & str ) { async_data = str ; } ) ; <nl> + remote_data_provider_ = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> + cm_ , init_manager_ , config . remote ( ) , dispatcher_ , random_ , false , <nl> + [ & ] ( const std : : string & data ) { async_data = data ; } ) ; <nl> <nl> EXPECT_CALL ( init_watcher_ , ready ( ) ) ; <nl> + EXPECT_CALL ( * retry_timer_ , enableTimer ( _ , _ ) ) <nl> + . WillOnce ( Invoke ( <nl> + [ & ] ( const std : : chrono : : milliseconds & , const ScopeTrackedObject * ) { retry_timer_cb_ ( ) ; } ) ) ; <nl> init_target_handle_ - > initialize ( init_watcher_ ) ; <nl> - EXPECT_EQ ( async_data , EMPTY_STRING ) ; <nl> - EXPECT_NE ( nullptr , provider . get ( ) ) ; <nl> + <nl> + EXPECT_EQ ( async_data , " non - empty " ) ; <nl> } <nl> <nl> - TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceDoNotAllowEmptyExpectNetworkFailure ) { <nl> - AsyncDataSourcePb config ; <nl> + TEST_F ( AsyncDataSourceTest , DatasourceReleasedBeforeFetchingData ) { <nl> + const std : : string body = " hello world " ; <nl> + std : : string async_data = " non - empty " ; <nl> <nl> - std : : string yaml = R " EOF ( <nl> + { <nl> + AsyncDataSourcePb config ; <nl> + <nl> + std : : string yaml = R " EOF ( <nl> remote : <nl> http_uri : <nl> uri : https : / / example . com / data <nl> cluster : cluster_1 <nl> + timeout : 1s <nl> sha256 : <nl> - xxxxxx <nl> + b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9 <nl> ) EOF " ; <nl> - TestUtility : : loadFromYaml ( yaml , config ) ; <nl> - EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> + TestUtility : : loadFromYamlAndValidate ( yaml , config ) ; <nl> + EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> <nl> - EXPECT_CALL ( cm_ , httpAsyncClientForCluster ( " cluster_1 " ) ) . WillOnce ( ReturnRef ( cm_ . async_client_ ) ) ; <nl> - EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> - . WillOnce ( <nl> - Invoke ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> - const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> - callbacks . onSuccess ( <nl> - Http : : ResponseMessagePtr { new Http : : ResponseMessageImpl ( Http : : ResponseHeaderMapPtr { <nl> - new Http : : TestResponseHeaderMapImpl { { " : status " , " 503 " } } } ) } ) ; <nl> - return nullptr ; <nl> - } ) ) ; <nl> + initialize ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> + const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> + Http : : ResponseMessagePtr response ( new Http : : ResponseMessageImpl ( <nl> + Http : : ResponseHeaderMapPtr { new Http : : TestResponseHeaderMapImpl { { " : status " , " 200 " } } } ) ) ; <nl> + response - > body ( ) = std : : make_unique < Buffer : : OwnedImpl > ( body ) ; <nl> <nl> - EXPECT_CALL ( init_manager_ , add ( _ ) ) . WillOnce ( Invoke ( [ this ] ( const Init : : Target & target ) { <nl> - init_target_handle_ = target . createHandle ( " test " ) ; <nl> - } ) ) ; <nl> + callbacks . onSuccess ( std : : move ( response ) ) ; <nl> + return nullptr ; <nl> + } ) ; <nl> <nl> - auto provider = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> - cm_ , init_manager_ , config . remote ( ) , false , [ ] ( const std : : string & ) { } ) ; <nl> + remote_data_provider_ = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> + cm_ , init_manager_ , config . remote ( ) , dispatcher_ , random_ , true , <nl> + [ & ] ( const std : : string & data ) { <nl> + EXPECT_EQ ( init_manager_ . state ( ) , Init : : Manager : : State : : Initializing ) ; <nl> + EXPECT_EQ ( data , body ) ; <nl> + async_data = data ; <nl> + } ) ; <nl> + } <nl> <nl> + EXPECT_CALL ( init_manager_ , state ( ) ) . WillOnce ( Return ( Init : : Manager : : State : : Initializing ) ) ; <nl> EXPECT_CALL ( init_watcher_ , ready ( ) ) ; <nl> init_target_handle_ - > initialize ( init_watcher_ ) ; <nl> - EXPECT_NE ( nullptr , provider . get ( ) ) ; <nl> + EXPECT_EQ ( async_data , body ) ; <nl> } <nl> <nl> - TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceExpectInvalidData ) { <nl> + TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceWithRetry ) { <nl> AsyncDataSourcePb config ; <nl> <nl> std : : string yaml = R " EOF ( <nl> TEST_F ( AsyncDataSourceTest , LoadRemoteDataSourceExpectInvalidData ) { <nl> http_uri : <nl> uri : https : / / example . com / data <nl> cluster : cluster_1 <nl> + timeout : 1s <nl> sha256 : <nl> - xxxxxx <nl> + b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9 <nl> + retry_policy : <nl> + retry_back_off : <nl> + base_interval : 1s <nl> + num_retries : 3 <nl> ) EOF " ; <nl> - TestUtility : : loadFromYaml ( yaml , config ) ; <nl> + TestUtility : : loadFromYamlAndValidate ( yaml , config ) ; <nl> EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> <nl> const std : : string body = " hello world " ; <nl> + int num_retries = 3 ; <nl> <nl> - EXPECT_CALL ( cm_ , httpAsyncClientForCluster ( " cluster_1 " ) ) . WillOnce ( ReturnRef ( cm_ . async_client_ ) ) ; <nl> - EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> - . WillOnce ( <nl> - Invoke ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> - const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> - Http : : ResponseMessagePtr response ( <nl> - new Http : : ResponseMessageImpl ( Http : : ResponseHeaderMapPtr { <nl> - new Http : : TestResponseHeaderMapImpl { { " : status " , " 200 " } } } ) ) ; <nl> - response - > body ( ) = std : : make_unique < Buffer : : OwnedImpl > ( body ) ; <nl> - <nl> - callbacks . onSuccess ( std : : move ( response ) ) ; <nl> - return nullptr ; <nl> - } ) ) ; <nl> - <nl> - EXPECT_CALL ( init_manager_ , add ( _ ) ) . WillOnce ( Invoke ( [ this ] ( const Init : : Target & target ) { <nl> - init_target_handle_ = target . createHandle ( " test " ) ; <nl> - } ) ) ; <nl> + initialize ( <nl> + [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> + const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> + callbacks . onSuccess ( Http : : ResponseMessagePtr { new Http : : ResponseMessageImpl ( <nl> + Http : : ResponseHeaderMapPtr { new Http : : TestResponseHeaderMapImpl { { " : status " , " 503 " } } } ) } ) ; <nl> + return nullptr ; <nl> + } , <nl> + num_retries ) ; <nl> <nl> - auto provider = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> - cm_ , init_manager_ , config . remote ( ) , false , [ ] ( const std : : string & ) { } ) ; <nl> + std : : string async_data = " non - empty " ; <nl> + remote_data_provider_ = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> + cm_ , init_manager_ , config . remote ( ) , dispatcher_ , random_ , true , <nl> + [ & ] ( const std : : string & data ) { <nl> + EXPECT_EQ ( init_manager_ . state ( ) , Init : : Manager : : State : : Initializing ) ; <nl> + EXPECT_EQ ( data , body ) ; <nl> + async_data = data ; <nl> + } ) ; <nl> <nl> + EXPECT_CALL ( init_manager_ , state ( ) ) . WillOnce ( Return ( Init : : Manager : : State : : Initializing ) ) ; <nl> EXPECT_CALL ( init_watcher_ , ready ( ) ) ; <nl> + EXPECT_CALL ( * retry_timer_ , enableTimer ( _ , _ ) ) <nl> + . WillRepeatedly ( Invoke ( [ & ] ( const std : : chrono : : milliseconds & , const ScopeTrackedObject * ) { <nl> + if ( - - num_retries = = 0 ) { <nl> + EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> + . WillOnce ( Invoke ( <nl> + [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> + const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> + Http : : ResponseMessagePtr response ( <nl> + new Http : : ResponseMessageImpl ( Http : : ResponseHeaderMapPtr { <nl> + new Http : : TestResponseHeaderMapImpl { { " : status " , " 200 " } } } ) ) ; <nl> + response - > body ( ) = std : : make_unique < Buffer : : OwnedImpl > ( body ) ; <nl> + <nl> + callbacks . onSuccess ( std : : move ( response ) ) ; <nl> + return nullptr ; <nl> + } ) ) ; <nl> + } <nl> + <nl> + retry_timer_cb_ ( ) ; <nl> + } ) ) ; <nl> init_target_handle_ - > initialize ( init_watcher_ ) ; <nl> - EXPECT_NE ( nullptr , provider . get ( ) ) ; <nl> - } <nl> <nl> - TEST_F ( AsyncDataSourceTest , DatasourceReleasedBeforeFetchingData ) { <nl> - const std : : string body = " hello world " ; <nl> - std : : string async_data = " non - empty " ; <nl> - std : : unique_ptr < Config : : DataSource : : RemoteAsyncDataProvider > provider ; <nl> + EXPECT_EQ ( async_data , body ) ; <nl> + } <nl> <nl> - { <nl> - AsyncDataSourcePb config ; <nl> + TEST_F ( AsyncDataSourceTest , BaseIntervalGreaterThanMaxInterval ) { <nl> + AsyncDataSourcePb config ; <nl> <nl> - std : : string yaml = R " EOF ( <nl> + std : : string yaml = R " EOF ( <nl> remote : <nl> http_uri : <nl> uri : https : / / example . com / data <nl> cluster : cluster_1 <nl> + timeout : 1s <nl> sha256 : <nl> b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9 <nl> + retry_policy : <nl> + retry_back_off : <nl> + base_interval : 10s <nl> + max_interval : 1s <nl> + num_retries : 3 <nl> ) EOF " ; <nl> - TestUtility : : loadFromYaml ( yaml , config ) ; <nl> - EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> - <nl> - EXPECT_CALL ( cm_ , httpAsyncClientForCluster ( " cluster_1 " ) ) . WillOnce ( ReturnRef ( cm_ . async_client_ ) ) ; <nl> - EXPECT_CALL ( cm_ . async_client_ , send_ ( _ , _ , _ ) ) <nl> - . WillOnce ( <nl> - Invoke ( [ & ] ( Http : : RequestMessagePtr & , Http : : AsyncClient : : Callbacks & callbacks , <nl> - const Http : : AsyncClient : : RequestOptions & ) - > Http : : AsyncClient : : Request * { <nl> - Http : : ResponseMessagePtr response ( <nl> - new Http : : ResponseMessageImpl ( Http : : ResponseHeaderMapPtr { <nl> - new Http : : TestResponseHeaderMapImpl { { " : status " , " 200 " } } } ) ) ; <nl> - response - > body ( ) = std : : make_unique < Buffer : : OwnedImpl > ( body ) ; <nl> - <nl> - callbacks . onSuccess ( std : : move ( response ) ) ; <nl> - return nullptr ; <nl> - } ) ) ; <nl> + TestUtility : : loadFromYamlAndValidate ( yaml , config ) ; <nl> + EXPECT_TRUE ( config . has_remote ( ) ) ; <nl> <nl> - EXPECT_CALL ( init_manager_ , add ( _ ) ) . WillOnce ( Invoke ( [ this ] ( const Init : : Target & target ) { <nl> - init_target_handle_ = target . createHandle ( " test " ) ; <nl> - } ) ) ; <nl> + EXPECT_THROW_WITH_MESSAGE ( std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> + cm_ , init_manager_ , config . remote ( ) , dispatcher_ , random_ , true , <nl> + [ & ] ( const std : : string & ) { } ) , <nl> + EnvoyException , <nl> + " max_interval must be greater than or equal to the base_interval " ) ; <nl> + } <nl> <nl> - provider = std : : make_unique < Config : : DataSource : : RemoteAsyncDataProvider > ( <nl> - cm_ , init_manager_ , config . remote ( ) , true , [ & ] ( const std : : string & data ) { <nl> - EXPECT_EQ ( init_manager_ . state ( ) , Init : : Manager : : State : : Initializing ) ; <nl> - EXPECT_EQ ( data , body ) ; <nl> - async_data = data ; <nl> - } ) ; <nl> - } <nl> + TEST_F ( AsyncDataSourceTest , BaseIntervalTest ) { <nl> + AsyncDataSourcePb config ; <nl> <nl> - EXPECT_CALL ( init_manager_ , state ( ) ) . WillOnce ( Return ( Init : : Manager : : State : : Initializing ) ) ; <nl> - EXPECT_CALL ( init_watcher_ , ready ( ) ) ; <nl> - init_target_handle_ - > initialize ( init_watcher_ ) ; <nl> - EXPECT_EQ ( async_data , body ) ; <nl> - EXPECT_NE ( nullptr , provider . get ( ) ) ; <nl> + std : : string yaml = R " EOF ( <nl> + remote : <nl> + http_uri : <nl> + uri : https : / / example . com / data <nl> + cluster : cluster_1 <nl> + timeout : 1s <nl> + sha256 : <nl> + xxx <nl> + retry_policy : <nl> + retry_back_off : <nl> + base_interval : 0 . 0001s <nl> + num_retries : 3 <nl> + ) EOF " ; <nl> + EXPECT_THROW ( TestUtility : : loadFromYamlAndValidate ( yaml , config ) , EnvoyException ) ; <nl> } <nl> <nl> } / / namespace <nl>
|
datasource : retry policy for remote data source ( )
|
envoyproxy/envoy
|
bd7c97858556c2851589d7fb73a25e99b8687df3
|
2020-03-07T03:07:11Z
|
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> include ( cmake / OpenCVFindMatlab . cmake ) <nl> <nl> include ( cmake / OpenCVDetectVTK . cmake ) <nl> <nl> + if ( OPENCV_HAL_HEADERS AND OPENCV_HAL_LIBS ) <nl> + get_filename_component ( OPENCV_HAL_HEADERS " $ { OPENCV_HAL_HEADERS } " ABSOLUTE ) <nl> + get_filename_component ( OPENCV_HAL_LIBS " $ { OPENCV_HAL_LIBS } " ABSOLUTE ) <nl> + endif ( ) <nl> + <nl> # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> # Add CUDA libraries ( needed for apps / tools , samples ) <nl> # mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> new file mode 100644 <nl> index 00000000000 . . b298a033ec0 <nl> mmm / dev / null <nl> ppp b / cmake / templates / custom_hal . hpp . in <nl> <nl> + # ifndef _CUSTOM_HAL_INCLUDED_ <nl> + # define _CUSTOM_HAL_INCLUDED_ <nl> + <nl> + @ OPENCV_HAL_HEADERS_INCLUDES @ <nl> + <nl> + # endif <nl> mmm a / modules / core / include / opencv2 / core / base . hpp <nl> ppp b / modules / core / include / opencv2 / core / base . hpp <nl> CV_EXPORTS void setUseIPP ( bool flag ) ; <nl> <nl> / / ! @ } core_utils <nl> <nl> - / / ! @ addtogroup core_utils_neon <nl> - / / ! @ { <nl> - <nl> - # if CV_NEON <nl> - <nl> - inline int32x2_t cv_vrnd_s32_f32 ( float32x2_t v ) <nl> - { <nl> - static int32x2_t v_sign = vdup_n_s32 ( 1 < < 31 ) , <nl> - v_05 = vreinterpret_s32_f32 ( vdup_n_f32 ( 0 . 5f ) ) ; <nl> - <nl> - int32x2_t v_addition = vorr_s32 ( v_05 , vand_s32 ( v_sign , vreinterpret_s32_f32 ( v ) ) ) ; <nl> - return vcvt_s32_f32 ( vadd_f32 ( v , vreinterpret_f32_s32 ( v_addition ) ) ) ; <nl> - } <nl> - <nl> - inline int32x4_t cv_vrndq_s32_f32 ( float32x4_t v ) <nl> - { <nl> - static int32x4_t v_sign = vdupq_n_s32 ( 1 < < 31 ) , <nl> - v_05 = vreinterpretq_s32_f32 ( vdupq_n_f32 ( 0 . 5f ) ) ; <nl> - <nl> - int32x4_t v_addition = vorrq_s32 ( v_05 , vandq_s32 ( v_sign , vreinterpretq_s32_f32 ( v ) ) ) ; <nl> - return vcvtq_s32_f32 ( vaddq_f32 ( v , vreinterpretq_f32_s32 ( v_addition ) ) ) ; <nl> - } <nl> - <nl> - inline uint32x2_t cv_vrnd_u32_f32 ( float32x2_t v ) <nl> - { <nl> - static float32x2_t v_05 = vdup_n_f32 ( 0 . 5f ) ; <nl> - return vcvt_u32_f32 ( vadd_f32 ( v , v_05 ) ) ; <nl> - } <nl> - <nl> - inline uint32x4_t cv_vrndq_u32_f32 ( float32x4_t v ) <nl> - { <nl> - static float32x4_t v_05 = vdupq_n_f32 ( 0 . 5f ) ; <nl> - return vcvtq_u32_f32 ( vaddq_f32 ( v , v_05 ) ) ; <nl> - } <nl> - <nl> - inline float32x4_t cv_vrecpq_f32 ( float32x4_t val ) <nl> - { <nl> - float32x4_t reciprocal = vrecpeq_f32 ( val ) ; <nl> - reciprocal = vmulq_f32 ( vrecpsq_f32 ( val , reciprocal ) , reciprocal ) ; <nl> - reciprocal = vmulq_f32 ( vrecpsq_f32 ( val , reciprocal ) , reciprocal ) ; <nl> - return reciprocal ; <nl> - } <nl> - <nl> - inline float32x2_t cv_vrecp_f32 ( float32x2_t val ) <nl> - { <nl> - float32x2_t reciprocal = vrecpe_f32 ( val ) ; <nl> - reciprocal = vmul_f32 ( vrecps_f32 ( val , reciprocal ) , reciprocal ) ; <nl> - reciprocal = vmul_f32 ( vrecps_f32 ( val , reciprocal ) , reciprocal ) ; <nl> - return reciprocal ; <nl> - } <nl> - <nl> - inline float32x4_t cv_vrsqrtq_f32 ( float32x4_t val ) <nl> - { <nl> - float32x4_t e = vrsqrteq_f32 ( val ) ; <nl> - e = vmulq_f32 ( vrsqrtsq_f32 ( vmulq_f32 ( e , e ) , val ) , e ) ; <nl> - e = vmulq_f32 ( vrsqrtsq_f32 ( vmulq_f32 ( e , e ) , val ) , e ) ; <nl> - return e ; <nl> - } <nl> - <nl> - inline float32x2_t cv_vrsqrt_f32 ( float32x2_t val ) <nl> - { <nl> - float32x2_t e = vrsqrte_f32 ( val ) ; <nl> - e = vmul_f32 ( vrsqrts_f32 ( vmul_f32 ( e , e ) , val ) , e ) ; <nl> - e = vmul_f32 ( vrsqrts_f32 ( vmul_f32 ( e , e ) , val ) , e ) ; <nl> - return e ; <nl> - } <nl> - <nl> - inline float32x4_t cv_vsqrtq_f32 ( float32x4_t val ) <nl> - { <nl> - return cv_vrecpq_f32 ( cv_vrsqrtq_f32 ( val ) ) ; <nl> - } <nl> - <nl> - inline float32x2_t cv_vsqrt_f32 ( float32x2_t val ) <nl> - { <nl> - return cv_vrecp_f32 ( cv_vrsqrt_f32 ( val ) ) ; <nl> - } <nl> - <nl> - # endif <nl> - <nl> - / / ! @ } core_utils_neon <nl> - <nl> } / / cv <nl> <nl> - # include " sse_utils . hpp " <nl> + # include " opencv2 / hal / neon_utils . hpp " <nl> <nl> # endif / / __OPENCV_CORE_BASE_HPP__ <nl> mmm a / modules / core / include / opencv2 / core / utility . hpp <nl> ppp b / modules / core / include / opencv2 / core / utility . hpp <nl> execution time . <nl> * / <nl> CV_EXPORTS_W int64 getCPUTickCount ( ) ; <nl> <nl> - / * * @ brief Available CPU features . <nl> - <nl> - remember to keep this list identical to the one in cvdef . h <nl> - * / <nl> - enum CpuFeatures { <nl> - CPU_MMX = 1 , <nl> - CPU_SSE = 2 , <nl> - CPU_SSE2 = 3 , <nl> - CPU_SSE3 = 4 , <nl> - CPU_SSSE3 = 5 , <nl> - CPU_SSE4_1 = 6 , <nl> - CPU_SSE4_2 = 7 , <nl> - CPU_POPCNT = 8 , <nl> - <nl> - CPU_AVX = 10 , <nl> - CPU_AVX2 = 11 , <nl> - CPU_FMA3 = 12 , <nl> - <nl> - CPU_AVX_512F = 13 , <nl> - CPU_AVX_512BW = 14 , <nl> - CPU_AVX_512CD = 15 , <nl> - CPU_AVX_512DQ = 16 , <nl> - CPU_AVX_512ER = 17 , <nl> - CPU_AVX_512IFMA512 = 18 , <nl> - CPU_AVX_512PF = 19 , <nl> - CPU_AVX_512VBMI = 20 , <nl> - CPU_AVX_512VL = 21 , <nl> - <nl> - CPU_NEON = 100 <nl> - } ; <nl> - <nl> / * * @ brief Returns true if the specified feature is supported by the host hardware . <nl> <nl> The function returns true if the host hardware supports the specified feature . When user calls <nl> mmm a / modules / core / src / arithm . cpp <nl> ppp b / modules / core / src / arithm . cpp <nl> <nl> namespace cv <nl> { <nl> <nl> - struct NOP { } ; <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> + * logical operations * <nl> + \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + void convertAndUnrollScalar ( const Mat & sc , int buftype , uchar * scbuf , size_t blocksize ) <nl> + { <nl> + int scn = ( int ) sc . total ( ) , cn = CV_MAT_CN ( buftype ) ; <nl> + size_t esz = CV_ELEM_SIZE ( buftype ) ; <nl> + getConvertFunc ( sc . depth ( ) , buftype ) ( sc . ptr ( ) , 1 , 0 , 1 , scbuf , 1 , Size ( std : : min ( cn , scn ) , 1 ) , 0 ) ; <nl> + / / unroll the scalar <nl> + if ( scn < cn ) <nl> + { <nl> + CV_Assert ( scn = = 1 ) ; <nl> + size_t esz1 = CV_ELEM_SIZE1 ( buftype ) ; <nl> + for ( size_t i = esz1 ; i < esz ; i + + ) <nl> + scbuf [ i ] = scbuf [ i - esz1 ] ; <nl> + } <nl> + for ( size_t i = esz ; i < blocksize * esz ; i + + ) <nl> + scbuf [ i ] = scbuf [ i - esz ] ; <nl> + } <nl> <nl> - # if CV_SSE2 | | CV_NEON <nl> <nl> - # define FUNCTOR_TEMPLATE ( name ) \ <nl> - template < typename T > struct name { } <nl> + enum { OCL_OP_ADD = 0 , OCL_OP_SUB = 1 , OCL_OP_RSUB = 2 , OCL_OP_ABSDIFF = 3 , OCL_OP_MUL = 4 , <nl> + OCL_OP_MUL_SCALE = 5 , OCL_OP_DIV_SCALE = 6 , OCL_OP_RECIP_SCALE = 7 , OCL_OP_ADDW = 8 , <nl> + OCL_OP_AND = 9 , OCL_OP_OR = 10 , OCL_OP_XOR = 11 , OCL_OP_NOT = 12 , OCL_OP_MIN = 13 , OCL_OP_MAX = 14 , <nl> + OCL_OP_RDIV_SCALE = 15 } ; <nl> <nl> - FUNCTOR_TEMPLATE ( VLoadStore128 ) ; <nl> - # if CV_SSE2 <nl> - FUNCTOR_TEMPLATE ( VLoadStore64 ) ; <nl> - FUNCTOR_TEMPLATE ( VLoadStore128Aligned ) ; <nl> - # if CV_AVX2 <nl> - FUNCTOR_TEMPLATE ( VLoadStore256 ) ; <nl> - FUNCTOR_TEMPLATE ( VLoadStore256Aligned ) ; <nl> - # endif <nl> - # endif <nl> + # ifdef HAVE_OPENCL <nl> <nl> - # endif <nl> + static const char * oclop2str [ ] = { " OP_ADD " , " OP_SUB " , " OP_RSUB " , " OP_ABSDIFF " , <nl> + " OP_MUL " , " OP_MUL_SCALE " , " OP_DIV_SCALE " , " OP_RECIP_SCALE " , <nl> + " OP_ADDW " , " OP_AND " , " OP_OR " , " OP_XOR " , " OP_NOT " , " OP_MIN " , " OP_MAX " , " OP_RDIV_SCALE " , 0 } ; <nl> <nl> - template < typename T , class Op , class VOp > <nl> - void vBinOp ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , T * dst , size_t step , Size sz ) <nl> + static bool ocl_binary_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> + InputArray _mask , bool bitwise , int oclop , bool haveScalar ) <nl> { <nl> - # if CV_SSE2 | | CV_NEON <nl> - VOp vop ; <nl> - # endif <nl> - Op op ; <nl> + bool haveMask = ! _mask . empty ( ) ; <nl> + int srctype = _src1 . type ( ) ; <nl> + int srcdepth = CV_MAT_DEPTH ( srctype ) ; <nl> + int cn = CV_MAT_CN ( srctype ) ; <nl> <nl> - for ( ; sz . height - - ; src1 = ( const T * ) ( ( const uchar * ) src1 + step1 ) , <nl> - src2 = ( const T * ) ( ( const uchar * ) src2 + step2 ) , <nl> - dst = ( T * ) ( ( uchar * ) dst + step ) ) <nl> - { <nl> - int x = 0 ; <nl> + const ocl : : Device d = ocl : : Device : : getDefault ( ) ; <nl> + bool doubleSupport = d . doubleFPConfig ( ) > 0 ; <nl> + if ( oclop < 0 | | ( ( haveMask | | haveScalar ) & & cn > 4 ) | | <nl> + ( ! doubleSupport & & srcdepth = = CV_64F & & ! bitwise ) ) <nl> + return false ; <nl> <nl> - # if CV_NEON | | CV_SSE2 <nl> - # if CV_AVX2 <nl> - if ( USE_AVX2 ) <nl> - { <nl> - for ( ; x < = sz . width - 32 / ( int ) sizeof ( T ) ; x + = 32 / sizeof ( T ) ) <nl> - { <nl> - typename VLoadStore256 < T > : : reg_type r0 = VLoadStore256 < T > : : load ( src1 + x ) ; <nl> - r0 = vop ( r0 , VLoadStore256 < T > : : load ( src2 + x ) ) ; <nl> - VLoadStore256 < T > : : store ( dst + x , r0 ) ; <nl> - } <nl> - } <nl> - # else <nl> - # if CV_SSE2 <nl> - if ( USE_SSE2 ) <nl> - { <nl> - # endif / / CV_SSE2 <nl> - for ( ; x < = sz . width - 32 / ( int ) sizeof ( T ) ; x + = 32 / sizeof ( T ) ) <nl> - { <nl> - typename VLoadStore128 < T > : : reg_type r0 = VLoadStore128 < T > : : load ( src1 + x ) ; <nl> - typename VLoadStore128 < T > : : reg_type r1 = VLoadStore128 < T > : : load ( src1 + x + 16 / sizeof ( T ) ) ; <nl> - r0 = vop ( r0 , VLoadStore128 < T > : : load ( src2 + x ) ) ; <nl> - r1 = vop ( r1 , VLoadStore128 < T > : : load ( src2 + x + 16 / sizeof ( T ) ) ) ; <nl> - VLoadStore128 < T > : : store ( dst + x , r0 ) ; <nl> - VLoadStore128 < T > : : store ( dst + x + 16 / sizeof ( T ) , r1 ) ; <nl> - } <nl> - # if CV_SSE2 <nl> - } <nl> - # endif / / CV_SSE2 <nl> - # endif / / CV_AVX2 <nl> - # endif / / CV_NEON | | CV_SSE2 <nl> - <nl> - # if CV_AVX2 <nl> - / / nothing <nl> - # elif CV_SSE2 <nl> - if ( USE_SSE2 ) <nl> - { <nl> - for ( ; x < = sz . width - 8 / ( int ) sizeof ( T ) ; x + = 8 / sizeof ( T ) ) <nl> - { <nl> - typename VLoadStore64 < T > : : reg_type r = VLoadStore64 < T > : : load ( src1 + x ) ; <nl> - r = vop ( r , VLoadStore64 < T > : : load ( src2 + x ) ) ; <nl> - VLoadStore64 < T > : : store ( dst + x , r ) ; <nl> - } <nl> - } <nl> - # endif <nl> + char opts [ 1024 ] ; <nl> + int kercn = haveMask | | haveScalar ? cn : ocl : : predictOptimalVectorWidth ( _src1 , _src2 , _dst ) ; <nl> + int scalarcn = kercn = = 3 ? 4 : kercn ; <nl> + int rowsPerWI = d . isIntel ( ) ? 4 : 1 ; <nl> <nl> - # if CV_ENABLE_UNROLLED <nl> - for ( ; x < = sz . width - 4 ; x + = 4 ) <nl> - { <nl> - T v0 = op ( src1 [ x ] , src2 [ x ] ) ; <nl> - T v1 = op ( src1 [ x + 1 ] , src2 [ x + 1 ] ) ; <nl> - dst [ x ] = v0 ; dst [ x + 1 ] = v1 ; <nl> - v0 = op ( src1 [ x + 2 ] , src2 [ x + 2 ] ) ; <nl> - v1 = op ( src1 [ x + 3 ] , src2 [ x + 3 ] ) ; <nl> - dst [ x + 2 ] = v0 ; dst [ x + 3 ] = v1 ; <nl> - } <nl> - # endif <nl> + sprintf ( opts , " - D % s % s - D % s - D dstT = % s % s - D dstT_C1 = % s - D workST = % s - D cn = % d - D rowsPerWI = % d " , <nl> + haveMask ? " MASK_ " : " " , haveScalar ? " UNARY_OP " : " BINARY_OP " , oclop2str [ oclop ] , <nl> + bitwise ? ocl : : memopTypeToStr ( CV_MAKETYPE ( srcdepth , kercn ) ) : <nl> + ocl : : typeToStr ( CV_MAKETYPE ( srcdepth , kercn ) ) , doubleSupport ? " - D DOUBLE_SUPPORT " : " " , <nl> + bitwise ? ocl : : memopTypeToStr ( CV_MAKETYPE ( srcdepth , 1 ) ) : <nl> + ocl : : typeToStr ( CV_MAKETYPE ( srcdepth , 1 ) ) , <nl> + bitwise ? ocl : : memopTypeToStr ( CV_MAKETYPE ( srcdepth , scalarcn ) ) : <nl> + ocl : : typeToStr ( CV_MAKETYPE ( srcdepth , scalarcn ) ) , <nl> + kercn , rowsPerWI ) ; <nl> <nl> - for ( ; x < sz . width ; x + + ) <nl> - dst [ x ] = op ( src1 [ x ] , src2 [ x ] ) ; <nl> - } <nl> - } <nl> + ocl : : Kernel k ( " KF " , ocl : : core : : arithm_oclsrc , opts ) ; <nl> + if ( k . empty ( ) ) <nl> + return false ; <nl> <nl> - template < typename T , class Op , class Op32 > <nl> - void vBinOp32 ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> - T * dst , size_t step , Size sz ) <nl> - { <nl> - # if CV_SSE2 | | CV_NEON <nl> - Op32 op32 ; <nl> - # endif <nl> - Op op ; <nl> + UMat src1 = _src1 . getUMat ( ) , src2 ; <nl> + UMat dst = _dst . getUMat ( ) , mask = _mask . getUMat ( ) ; <nl> + <nl> + ocl : : KernelArg src1arg = ocl : : KernelArg : : ReadOnlyNoSize ( src1 , cn , kercn ) ; <nl> + ocl : : KernelArg dstarg = haveMask ? ocl : : KernelArg : : ReadWrite ( dst , cn , kercn ) : <nl> + ocl : : KernelArg : : WriteOnly ( dst , cn , kercn ) ; <nl> + ocl : : KernelArg maskarg = ocl : : KernelArg : : ReadOnlyNoSize ( mask , 1 ) ; <nl> <nl> - for ( ; sz . height - - ; src1 = ( const T * ) ( ( const uchar * ) src1 + step1 ) , <nl> - src2 = ( const T * ) ( ( const uchar * ) src2 + step2 ) , <nl> - dst = ( T * ) ( ( uchar * ) dst + step ) ) <nl> + if ( haveScalar ) <nl> { <nl> - int x = 0 ; <nl> + size_t esz = CV_ELEM_SIZE1 ( srctype ) * scalarcn ; <nl> + double buf [ 4 ] = { 0 , 0 , 0 , 0 } ; <nl> <nl> - # if CV_AVX2 <nl> - if ( USE_AVX2 ) <nl> - { <nl> - if ( ( ( ( size_t ) src1 | ( size_t ) src2 | ( size_t ) dst ) & 31 ) = = 0 ) <nl> - { <nl> - for ( ; x < = sz . width - 8 ; x + = 8 ) <nl> - { <nl> - typename VLoadStore256Aligned < T > : : reg_type r0 = VLoadStore256Aligned < T > : : load ( src1 + x ) ; <nl> - r0 = op32 ( r0 , VLoadStore256Aligned < T > : : load ( src2 + x ) ) ; <nl> - VLoadStore256Aligned < T > : : store ( dst + x , r0 ) ; <nl> - } <nl> - } <nl> - } <nl> - # elif CV_SSE2 <nl> - if ( USE_SSE2 ) <nl> + if ( oclop ! = OCL_OP_NOT ) <nl> { <nl> - if ( ( ( ( size_t ) src1 | ( size_t ) src2 | ( size_t ) dst ) & 15 ) = = 0 ) <nl> - { <nl> - for ( ; x < = sz . width - 8 ; x + = 8 ) <nl> - { <nl> - typename VLoadStore128Aligned < T > : : reg_type r0 = VLoadStore128Aligned < T > : : load ( src1 + x ) ; <nl> - typename VLoadStore128Aligned < T > : : reg_type r1 = VLoadStore128Aligned < T > : : load ( src1 + x + 4 ) ; <nl> - r0 = op32 ( r0 , VLoadStore128Aligned < T > : : load ( src2 + x ) ) ; <nl> - r1 = op32 ( r1 , VLoadStore128Aligned < T > : : load ( src2 + x + 4 ) ) ; <nl> - VLoadStore128Aligned < T > : : store ( dst + x , r0 ) ; <nl> - VLoadStore128Aligned < T > : : store ( dst + x + 4 , r1 ) ; <nl> - } <nl> - } <nl> + Mat src2sc = _src2 . getMat ( ) ; <nl> + convertAndUnrollScalar ( src2sc , srctype , ( uchar * ) buf , 1 ) ; <nl> } <nl> - # endif / / CV_AVX2 <nl> <nl> - # if CV_NEON | | CV_SSE2 <nl> - # if CV_AVX2 <nl> - if ( USE_AVX2 ) <nl> - { <nl> - for ( ; x < = sz . width - 8 ; x + = 8 ) <nl> - { <nl> - typename VLoadStore256 < T > : : reg_type r0 = VLoadStore256 < T > : : load ( src1 + x ) ; <nl> - r0 = op32 ( r0 , VLoadStore256 < T > : : load ( src2 + x ) ) ; <nl> - VLoadStore256 < T > : : store ( dst + x , r0 ) ; <nl> - } <nl> - } <nl> - # else <nl> - # if CV_SSE2 <nl> - if ( USE_SSE2 ) <nl> - { <nl> - # endif / / CV_SSE2 <nl> - for ( ; x < = sz . width - 8 ; x + = 8 ) <nl> - { <nl> - typename VLoadStore128 < T > : : reg_type r0 = VLoadStore128 < T > : : load ( src1 + x ) ; <nl> - typename VLoadStore128 < T > : : reg_type r1 = VLoadStore128 < T > : : load ( src1 + x + 4 ) ; <nl> - r0 = op32 ( r0 , VLoadStore128 < T > : : load ( src2 + x ) ) ; <nl> - r1 = op32 ( r1 , VLoadStore128 < T > : : load ( src2 + x + 4 ) ) ; <nl> - VLoadStore128 < T > : : store ( dst + x , r0 ) ; <nl> - VLoadStore128 < T > : : store ( dst + x + 4 , r1 ) ; <nl> - } <nl> - # if CV_SSE2 <nl> - } <nl> - # endif / / CV_SSE2 <nl> - # endif / / CV_AVX2 <nl> - # endif / / CV_NEON | | CV_SSE2 <nl> + ocl : : KernelArg scalararg = ocl : : KernelArg ( 0 , 0 , 0 , 0 , buf , esz ) ; <nl> <nl> - # if CV_ENABLE_UNROLLED <nl> - for ( ; x < = sz . width - 4 ; x + = 4 ) <nl> - { <nl> - T v0 = op ( src1 [ x ] , src2 [ x ] ) ; <nl> - T v1 = op ( src1 [ x + 1 ] , src2 [ x + 1 ] ) ; <nl> - dst [ x ] = v0 ; dst [ x + 1 ] = v1 ; <nl> - v0 = op ( src1 [ x + 2 ] , src2 [ x + 2 ] ) ; <nl> - v1 = op ( src1 [ x + 3 ] , src2 [ x + 3 ] ) ; <nl> - dst [ x + 2 ] = v0 ; dst [ x + 3 ] = v1 ; <nl> - } <nl> - # endif <nl> + if ( ! haveMask ) <nl> + k . args ( src1arg , dstarg , scalararg ) ; <nl> + else <nl> + k . args ( src1arg , maskarg , dstarg , scalararg ) ; <nl> + } <nl> + else <nl> + { <nl> + src2 = _src2 . getUMat ( ) ; <nl> + ocl : : KernelArg src2arg = ocl : : KernelArg : : ReadOnlyNoSize ( src2 , cn , kercn ) ; <nl> <nl> - for ( ; x < sz . width ; x + + ) <nl> - dst [ x ] = op ( src1 [ x ] , src2 [ x ] ) ; <nl> + if ( ! haveMask ) <nl> + k . args ( src1arg , src2arg , dstarg ) ; <nl> + else <nl> + k . args ( src1arg , src2arg , maskarg , dstarg ) ; <nl> } <nl> + <nl> + size_t globalsize [ ] = { ( size_t ) src1 . cols * cn / kercn , ( ( size_t ) src1 . rows + rowsPerWI - 1 ) / rowsPerWI } ; <nl> + return k . run ( 2 , globalsize , 0 , false ) ; <nl> } <nl> <nl> + # endif <nl> <nl> - template < typename T , class Op , class Op64 > <nl> - void vBinOp64 ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> - T * dst , size_t step , Size sz ) <nl> + static void binary_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> + InputArray _mask , const BinaryFuncC * tab , <nl> + bool bitwise , int oclop ) <nl> { <nl> - # if CV_SSE2 <nl> - Op64 op64 ; <nl> + const _InputArray * psrc1 = & _src1 , * psrc2 = & _src2 ; <nl> + int kind1 = psrc1 - > kind ( ) , kind2 = psrc2 - > kind ( ) ; <nl> + int type1 = psrc1 - > type ( ) , depth1 = CV_MAT_DEPTH ( type1 ) , cn = CV_MAT_CN ( type1 ) ; <nl> + int type2 = psrc2 - > type ( ) , depth2 = CV_MAT_DEPTH ( type2 ) , cn2 = CV_MAT_CN ( type2 ) ; <nl> + int dims1 = psrc1 - > dims ( ) , dims2 = psrc2 - > dims ( ) ; <nl> + Size sz1 = dims1 < = 2 ? psrc1 - > size ( ) : Size ( ) ; <nl> + Size sz2 = dims2 < = 2 ? psrc2 - > size ( ) : Size ( ) ; <nl> + # ifdef HAVE_OPENCL <nl> + bool use_opencl = ( kind1 = = _InputArray : : UMAT | | kind2 = = _InputArray : : UMAT ) & & <nl> + dims1 < = 2 & & dims2 < = 2 ; <nl> # endif <nl> - Op op ; <nl> + bool haveMask = ! _mask . empty ( ) , haveScalar = false ; <nl> + BinaryFuncC func ; <nl> <nl> - for ( ; sz . height - - ; src1 = ( const T * ) ( ( const uchar * ) src1 + step1 ) , <nl> - src2 = ( const T * ) ( ( const uchar * ) src2 + step2 ) , <nl> - dst = ( T * ) ( ( uchar * ) dst + step ) ) <nl> + if ( dims1 < = 2 & & dims2 < = 2 & & kind1 = = kind2 & & sz1 = = sz2 & & type1 = = type2 & & ! haveMask ) <nl> { <nl> - int x = 0 ; <nl> + _dst . create ( sz1 , type1 ) ; <nl> + CV_OCL_RUN ( use_opencl , <nl> + ocl_binary_op ( * psrc1 , * psrc2 , _dst , _mask , bitwise , oclop , false ) ) <nl> <nl> - # if CV_AVX2 <nl> - if ( USE_AVX2 ) <nl> - { <nl> - if ( ( ( ( size_t ) src1 | ( size_t ) src2 | ( size_t ) dst ) & 31 ) = = 0 ) <nl> - { <nl> - for ( ; x < = sz . width - 4 ; x + = 4 ) <nl> - { <nl> - typename VLoadStore256Aligned < T > : : reg_type r0 = VLoadStore256Aligned < T > : : load ( src1 + x ) ; <nl> - r0 = op64 ( r0 , VLoadStore256Aligned < T > : : load ( src2 + x ) ) ; <nl> - VLoadStore256Aligned < T > : : store ( dst + x , r0 ) ; <nl> - } <nl> - } <nl> - } <nl> - # elif CV_SSE2 <nl> - if ( USE_SSE2 ) <nl> + if ( bitwise ) <nl> { <nl> - if ( ( ( ( size_t ) src1 | ( size_t ) src2 | ( size_t ) dst ) & 15 ) = = 0 ) <nl> - { <nl> - for ( ; x < = sz . width - 4 ; x + = 4 ) <nl> - { <nl> - typename VLoadStore128Aligned < T > : : reg_type r0 = VLoadStore128Aligned < T > : : load ( src1 + x ) ; <nl> - typename VLoadStore128Aligned < T > : : reg_type r1 = VLoadStore128Aligned < T > : : load ( src1 + x + 2 ) ; <nl> - r0 = op64 ( r0 , VLoadStore128Aligned < T > : : load ( src2 + x ) ) ; <nl> - r1 = op64 ( r1 , VLoadStore128Aligned < T > : : load ( src2 + x + 2 ) ) ; <nl> - VLoadStore128Aligned < T > : : store ( dst + x , r0 ) ; <nl> - VLoadStore128Aligned < T > : : store ( dst + x + 2 , r1 ) ; <nl> - } <nl> - } <nl> + func = * tab ; <nl> + cn = ( int ) CV_ELEM_SIZE ( type1 ) ; <nl> } <nl> - # endif <nl> + else <nl> + func = tab [ depth1 ] ; <nl> <nl> - for ( ; x < = sz . width - 4 ; x + = 4 ) <nl> + Mat src1 = psrc1 - > getMat ( ) , src2 = psrc2 - > getMat ( ) , dst = _dst . getMat ( ) ; <nl> + Size sz = getContinuousSize ( src1 , src2 , dst ) ; <nl> + size_t len = sz . width * ( size_t ) cn ; <nl> + if ( len = = ( size_t ) ( int ) len ) <nl> { <nl> - T v0 = op ( src1 [ x ] , src2 [ x ] ) ; <nl> - T v1 = op ( src1 [ x + 1 ] , src2 [ x + 1 ] ) ; <nl> - dst [ x ] = v0 ; dst [ x + 1 ] = v1 ; <nl> - v0 = op ( src1 [ x + 2 ] , src2 [ x + 2 ] ) ; <nl> - v1 = op ( src1 [ x + 3 ] , src2 [ x + 3 ] ) ; <nl> - dst [ x + 2 ] = v0 ; dst [ x + 3 ] = v1 ; <nl> + sz . width = ( int ) len ; <nl> + func ( src1 . ptr ( ) , src1 . step , src2 . ptr ( ) , src2 . step , dst . ptr ( ) , dst . step , sz . width , sz . height , 0 ) ; <nl> + return ; <nl> } <nl> - <nl> - for ( ; x < sz . width ; x + + ) <nl> - dst [ x ] = op ( src1 [ x ] , src2 [ x ] ) ; <nl> - } <nl> - } <nl> - <nl> - # if CV_AVX2 <nl> - <nl> - # define FUNCTOR_LOADSTORE_CAST ( name , template_arg , register_type , load_body , store_body ) \ <nl> - template < > \ <nl> - struct name < template_arg > { \ <nl> - typedef register_type reg_type ; \ <nl> - static reg_type load ( const template_arg * p ) { return load_body ( ( const reg_type * ) p ) ; } \ <nl> - static void store ( template_arg * p , reg_type v ) { store_body ( ( reg_type * ) p , v ) ; } \ <nl> - } <nl> - <nl> - # define FUNCTOR_LOADSTORE ( name , template_arg , register_type , load_body , store_body ) \ <nl> - template < > \ <nl> - struct name < template_arg > { \ <nl> - typedef register_type reg_type ; \ <nl> - static reg_type load ( const template_arg * p ) { return load_body ( p ) ; } \ <nl> - static void store ( template_arg * p , reg_type v ) { store_body ( p , v ) ; } \ <nl> - } <nl> - <nl> - # define FUNCTOR_CLOSURE_2arg ( name , template_arg , body ) \ <nl> - template < > \ <nl> - struct name < template_arg > \ <nl> - { \ <nl> - VLoadStore256 < template_arg > : : reg_type operator ( ) ( \ <nl> - const VLoadStore256 < template_arg > : : reg_type & a , \ <nl> - const VLoadStore256 < template_arg > : : reg_type & b ) const \ <nl> - { \ <nl> - body ; \ <nl> - } \ <nl> } <nl> <nl> - # define FUNCTOR_CLOSURE_1arg ( name , template_arg , body ) \ <nl> - template < > \ <nl> - struct name < template_arg > \ <nl> - { \ <nl> - VLoadStore256 < template_arg > : : reg_type operator ( ) ( \ <nl> - const VLoadStore256 < template_arg > : : reg_type & a , \ <nl> - const VLoadStore256 < template_arg > : : reg_type & ) const \ <nl> - { \ <nl> - body ; \ <nl> - } \ <nl> + if ( oclop = = OCL_OP_NOT ) <nl> + haveScalar = true ; <nl> + else if ( ( kind1 = = _InputArray : : MATX ) + ( kind2 = = _InputArray : : MATX ) = = 1 | | <nl> + ! psrc1 - > sameSize ( * psrc2 ) | | type1 ! = type2 ) <nl> + { <nl> + if ( checkScalar ( * psrc1 , type2 , kind1 , kind2 ) ) <nl> + { <nl> + / / src1 is a scalar ; swap it with src2 <nl> + swap ( psrc1 , psrc2 ) ; <nl> + swap ( type1 , type2 ) ; <nl> + swap ( depth1 , depth2 ) ; <nl> + swap ( cn , cn2 ) ; <nl> + swap ( sz1 , sz2 ) ; <nl> + } <nl> + else if ( ! checkScalar ( * psrc2 , type1 , kind2 , kind1 ) ) <nl> + CV_Error ( CV_StsUnmatchedSizes , <nl> + " The operation is neither ' array op array ' ( where arrays have the same size and type ) , " <nl> + " nor ' array op scalar ' , nor ' scalar op array ' " ) ; <nl> + haveScalar = true ; <nl> } <nl> - <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore256 , uchar , __m256i , _mm256_loadu_si256 , _mm256_storeu_si256 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore256 , schar , __m256i , _mm256_loadu_si256 , _mm256_storeu_si256 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore256 , ushort , __m256i , _mm256_loadu_si256 , _mm256_storeu_si256 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore256 , short , __m256i , _mm256_loadu_si256 , _mm256_storeu_si256 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore256 , int , __m256i , _mm256_loadu_si256 , _mm256_storeu_si256 ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore256 , float , __m256 , _mm256_loadu_ps , _mm256_storeu_ps ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore256 , double , __m256d , _mm256_loadu_pd , _mm256_storeu_pd ) ; <nl> - <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore256Aligned , int , __m256i , _mm256_load_si256 , _mm256_store_si256 ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore256Aligned , float , __m256 , _mm256_load_ps , _mm256_store_ps ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore256Aligned , double , __m256d , _mm256_load_pd , _mm256_store_pd ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VAdd ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , uchar , return _mm256_adds_epu8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , schar , return _mm256_adds_epi8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , ushort , return _mm256_adds_epu16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , short , return _mm256_adds_epi16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , int , return _mm256_add_epi32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , float , return _mm256_add_ps ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , double , return _mm256_add_pd ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VSub ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , uchar , return _mm256_subs_epu8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , schar , return _mm256_subs_epi8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , ushort , return _mm256_subs_epu16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , short , return _mm256_subs_epi16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , int , return _mm256_sub_epi32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , float , return _mm256_sub_ps ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , double , return _mm256_sub_pd ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VMin ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , uchar , return _mm256_min_epu8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , schar , return _mm256_min_epi8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , ushort , return _mm256_min_epi16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , short , return _mm256_min_epi16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , int , return _mm256_min_epi32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , float , return _mm256_min_ps ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , double , return _mm256_min_pd ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VMax ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , uchar , return _mm256_max_epu8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , schar , return _mm256_max_epi8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , ushort , return _mm256_max_epu16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , short , return _mm256_max_epi16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , int , return _mm256_max_epi32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , float , return _mm256_max_ps ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , double , return _mm256_max_pd ( a , b ) ) ; <nl> - <nl> - <nl> - static unsigned int CV_DECL_ALIGNED ( 32 ) v32f_absmask [ ] = { 0x7fffffff , 0x7fffffff , 0x7fffffff , 0x7fffffff , <nl> - 0x7fffffff , 0x7fffffff , 0x7fffffff , 0x7fffffff } ; <nl> - static unsigned int CV_DECL_ALIGNED ( 32 ) v64f_absmask [ ] = { 0xffffffff , 0x7fffffff , 0xffffffff , 0x7fffffff , <nl> - 0xffffffff , 0x7fffffff , 0xffffffff , 0x7fffffff } ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VAbsDiff ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , uchar , <nl> - return _mm256_add_epi8 ( _mm256_subs_epu8 ( a , b ) , _mm256_subs_epu8 ( b , a ) ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , schar , <nl> - __m256i d = _mm256_subs_epi8 ( a , b ) ; <nl> - __m256i m = _mm256_cmpgt_epi8 ( b , a ) ; <nl> - return _mm256_subs_epi8 ( _mm256_xor_si256 ( d , m ) , m ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , ushort , <nl> - return _mm256_add_epi16 ( _mm256_subs_epu16 ( a , b ) , _mm256_subs_epu16 ( b , a ) ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , short , <nl> - __m256i M = _mm256_max_epi16 ( a , b ) ; <nl> - __m256i m = _mm256_min_epi16 ( a , b ) ; <nl> - return _mm256_subs_epi16 ( M , m ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , int , <nl> - __m256i d = _mm256_sub_epi32 ( a , b ) ; <nl> - __m256i m = _mm256_cmpgt_epi32 ( b , a ) ; <nl> - return _mm256_sub_epi32 ( _mm256_xor_si256 ( d , m ) , m ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , float , <nl> - return _mm256_and_ps ( _mm256_sub_ps ( a , b ) , * ( const __m256 * ) v32f_absmask ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , double , <nl> - return _mm256_and_pd ( _mm256_sub_pd ( a , b ) , * ( const __m256d * ) v64f_absmask ) ; <nl> - ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VAnd ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAnd , uchar , return _mm256_and_si256 ( a , b ) ) ; <nl> - FUNCTOR_TEMPLATE ( VOr ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VOr , uchar , return _mm256_or_si256 ( a , b ) ) ; <nl> - FUNCTOR_TEMPLATE ( VXor ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VXor , uchar , return _mm256_xor_si256 ( a , b ) ) ; <nl> - FUNCTOR_TEMPLATE ( VNot ) ; <nl> - FUNCTOR_CLOSURE_1arg ( VNot , uchar , return _mm256_xor_si256 ( _mm256_set1_epi32 ( - 1 ) , a ) ) ; <nl> - <nl> - # elif CV_SSE2 <nl> - <nl> - # define FUNCTOR_LOADSTORE_CAST ( name , template_arg , register_type , load_body , store_body ) \ <nl> - template < > \ <nl> - struct name < template_arg > { \ <nl> - typedef register_type reg_type ; \ <nl> - static reg_type load ( const template_arg * p ) { return load_body ( ( const reg_type * ) p ) ; } \ <nl> - static void store ( template_arg * p , reg_type v ) { store_body ( ( reg_type * ) p , v ) ; } \ <nl> + else <nl> + { <nl> + CV_Assert ( psrc1 - > sameSize ( * psrc2 ) & & type1 = = type2 ) ; <nl> } <nl> <nl> - # define FUNCTOR_LOADSTORE ( name , template_arg , register_type , load_body , store_body ) \ <nl> - template < > \ <nl> - struct name < template_arg > { \ <nl> - typedef register_type reg_type ; \ <nl> - static reg_type load ( const template_arg * p ) { return load_body ( p ) ; } \ <nl> - static void store ( template_arg * p , reg_type v ) { store_body ( p , v ) ; } \ <nl> - } <nl> + size_t esz = CV_ELEM_SIZE ( type1 ) ; <nl> + size_t blocksize0 = ( BLOCK_SIZE + esz - 1 ) / esz ; <nl> + BinaryFunc copymask = 0 ; <nl> + bool reallocate = false ; <nl> <nl> - # define FUNCTOR_CLOSURE_2arg ( name , template_arg , body ) \ <nl> - template < > \ <nl> - struct name < template_arg > \ <nl> - { \ <nl> - VLoadStore128 < template_arg > : : reg_type operator ( ) ( \ <nl> - const VLoadStore128 < template_arg > : : reg_type & a , \ <nl> - const VLoadStore128 < template_arg > : : reg_type & b ) const \ <nl> - { \ <nl> - body ; \ <nl> - } \ <nl> + if ( haveMask ) <nl> + { <nl> + int mtype = _mask . type ( ) ; <nl> + CV_Assert ( ( mtype = = CV_8U | | mtype = = CV_8S ) & & _mask . sameSize ( * psrc1 ) ) ; <nl> + copymask = getCopyMaskFunc ( esz ) ; <nl> + reallocate = ! _dst . sameSize ( * psrc1 ) | | _dst . type ( ) ! = type1 ; <nl> } <nl> <nl> - # define FUNCTOR_CLOSURE_1arg ( name , template_arg , body ) \ <nl> - template < > \ <nl> - struct name < template_arg > \ <nl> - { \ <nl> - VLoadStore128 < template_arg > : : reg_type operator ( ) ( \ <nl> - const VLoadStore128 < template_arg > : : reg_type & a , \ <nl> - const VLoadStore128 < template_arg > : : reg_type & ) const \ <nl> - { \ <nl> - body ; \ <nl> - } \ <nl> - } <nl> + AutoBuffer < uchar > _buf ; <nl> + uchar * scbuf = 0 , * maskbuf = 0 ; <nl> <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore128 , uchar , __m128i , _mm_loadu_si128 , _mm_storeu_si128 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore128 , schar , __m128i , _mm_loadu_si128 , _mm_storeu_si128 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore128 , ushort , __m128i , _mm_loadu_si128 , _mm_storeu_si128 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore128 , short , __m128i , _mm_loadu_si128 , _mm_storeu_si128 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore128 , int , __m128i , _mm_loadu_si128 , _mm_storeu_si128 ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore128 , float , __m128 , _mm_loadu_ps , _mm_storeu_ps ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore128 , double , __m128d , _mm_loadu_pd , _mm_storeu_pd ) ; <nl> - <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore64 , uchar , __m128i , _mm_loadl_epi64 , _mm_storel_epi64 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore64 , schar , __m128i , _mm_loadl_epi64 , _mm_storel_epi64 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore64 , ushort , __m128i , _mm_loadl_epi64 , _mm_storel_epi64 ) ; <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore64 , short , __m128i , _mm_loadl_epi64 , _mm_storel_epi64 ) ; <nl> - <nl> - FUNCTOR_LOADSTORE_CAST ( VLoadStore128Aligned , int , __m128i , _mm_load_si128 , _mm_store_si128 ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore128Aligned , float , __m128 , _mm_load_ps , _mm_store_ps ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore128Aligned , double , __m128d , _mm_load_pd , _mm_store_pd ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VAdd ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , uchar , return _mm_adds_epu8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , schar , return _mm_adds_epi8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , ushort , return _mm_adds_epu16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , short , return _mm_adds_epi16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , int , return _mm_add_epi32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , float , return _mm_add_ps ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , double , return _mm_add_pd ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VSub ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , uchar , return _mm_subs_epu8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , schar , return _mm_subs_epi8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , ushort , return _mm_subs_epu16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , short , return _mm_subs_epi16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , int , return _mm_sub_epi32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , float , return _mm_sub_ps ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , double , return _mm_sub_pd ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VMin ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , uchar , return _mm_min_epu8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , schar , <nl> - __m128i m = _mm_cmpgt_epi8 ( a , b ) ; <nl> - return _mm_xor_si128 ( a , _mm_and_si128 ( _mm_xor_si128 ( a , b ) , m ) ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , ushort , return _mm_subs_epu16 ( a , _mm_subs_epu16 ( a , b ) ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , short , return _mm_min_epi16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , int , <nl> - __m128i m = _mm_cmpgt_epi32 ( a , b ) ; <nl> - return _mm_xor_si128 ( a , _mm_and_si128 ( _mm_xor_si128 ( a , b ) , m ) ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , float , return _mm_min_ps ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , double , return _mm_min_pd ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VMax ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , uchar , return _mm_max_epu8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , schar , <nl> - __m128i m = _mm_cmpgt_epi8 ( b , a ) ; <nl> - return _mm_xor_si128 ( a , _mm_and_si128 ( _mm_xor_si128 ( a , b ) , m ) ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , ushort , return _mm_adds_epu16 ( _mm_subs_epu16 ( a , b ) , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , short , return _mm_max_epi16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , int , <nl> - __m128i m = _mm_cmpgt_epi32 ( b , a ) ; <nl> - return _mm_xor_si128 ( a , _mm_and_si128 ( _mm_xor_si128 ( a , b ) , m ) ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , float , return _mm_max_ps ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , double , return _mm_max_pd ( a , b ) ) ; <nl> - <nl> - <nl> - static unsigned int CV_DECL_ALIGNED ( 16 ) v32f_absmask [ ] = { 0x7fffffff , 0x7fffffff , 0x7fffffff , 0x7fffffff } ; <nl> - static unsigned int CV_DECL_ALIGNED ( 16 ) v64f_absmask [ ] = { 0xffffffff , 0x7fffffff , 0xffffffff , 0x7fffffff } ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VAbsDiff ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , uchar , <nl> - return _mm_add_epi8 ( _mm_subs_epu8 ( a , b ) , _mm_subs_epu8 ( b , a ) ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , schar , <nl> - __m128i d = _mm_subs_epi8 ( a , b ) ; <nl> - __m128i m = _mm_cmpgt_epi8 ( b , a ) ; <nl> - return _mm_subs_epi8 ( _mm_xor_si128 ( d , m ) , m ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , ushort , <nl> - return _mm_add_epi16 ( _mm_subs_epu16 ( a , b ) , _mm_subs_epu16 ( b , a ) ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , short , <nl> - __m128i M = _mm_max_epi16 ( a , b ) ; <nl> - __m128i m = _mm_min_epi16 ( a , b ) ; <nl> - return _mm_subs_epi16 ( M , m ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , int , <nl> - __m128i d = _mm_sub_epi32 ( a , b ) ; <nl> - __m128i m = _mm_cmpgt_epi32 ( b , a ) ; <nl> - return _mm_sub_epi32 ( _mm_xor_si128 ( d , m ) , m ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , float , <nl> - return _mm_and_ps ( _mm_sub_ps ( a , b ) , * ( const __m128 * ) v32f_absmask ) ; <nl> - ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , double , <nl> - return _mm_and_pd ( _mm_sub_pd ( a , b ) , * ( const __m128d * ) v64f_absmask ) ; <nl> - ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VAnd ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAnd , uchar , return _mm_and_si128 ( a , b ) ) ; <nl> - FUNCTOR_TEMPLATE ( VOr ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VOr , uchar , return _mm_or_si128 ( a , b ) ) ; <nl> - FUNCTOR_TEMPLATE ( VXor ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VXor , uchar , return _mm_xor_si128 ( a , b ) ) ; <nl> - FUNCTOR_TEMPLATE ( VNot ) ; <nl> - FUNCTOR_CLOSURE_1arg ( VNot , uchar , return _mm_xor_si128 ( _mm_set1_epi32 ( - 1 ) , a ) ) ; <nl> - # endif <nl> + _dst . createSameSize ( * psrc1 , type1 ) ; <nl> + / / if this is mask operation and dst has been reallocated , <nl> + / / we have to clear the destination <nl> + if ( haveMask & & reallocate ) <nl> + _dst . setTo ( 0 . ) ; <nl> <nl> - # if CV_NEON <nl> + CV_OCL_RUN ( use_opencl , <nl> + ocl_binary_op ( * psrc1 , * psrc2 , _dst , _mask , bitwise , oclop , haveScalar ) ) <nl> <nl> - # define FUNCTOR_LOADSTORE ( name , template_arg , register_type , load_body , store_body ) \ <nl> - template < > \ <nl> - struct name < template_arg > { \ <nl> - typedef register_type reg_type ; \ <nl> - static reg_type load ( const template_arg * p ) { return load_body ( p ) ; } ; \ <nl> - static void store ( template_arg * p , reg_type v ) { store_body ( p , v ) ; } ; \ <nl> - } <nl> <nl> - # define FUNCTOR_CLOSURE_2arg ( name , template_arg , body ) \ <nl> - template < > \ <nl> - struct name < template_arg > \ <nl> - { \ <nl> - VLoadStore128 < template_arg > : : reg_type operator ( ) ( \ <nl> - VLoadStore128 < template_arg > : : reg_type a , \ <nl> - VLoadStore128 < template_arg > : : reg_type b ) const \ <nl> - { \ <nl> - return body ; \ <nl> - } ; \ <nl> - } <nl> + Mat src1 = psrc1 - > getMat ( ) , src2 = psrc2 - > getMat ( ) ; <nl> + Mat dst = _dst . getMat ( ) , mask = _mask . getMat ( ) ; <nl> <nl> - # define FUNCTOR_CLOSURE_1arg ( name , template_arg , body ) \ <nl> - template < > \ <nl> - struct name < template_arg > \ <nl> - { \ <nl> - VLoadStore128 < template_arg > : : reg_type operator ( ) ( \ <nl> - VLoadStore128 < template_arg > : : reg_type a , \ <nl> - VLoadStore128 < template_arg > : : reg_type ) const \ <nl> - { \ <nl> - return body ; \ <nl> - } ; \ <nl> + if ( bitwise ) <nl> + { <nl> + func = * tab ; <nl> + cn = ( int ) esz ; <nl> } <nl> + else <nl> + func = tab [ depth1 ] ; <nl> <nl> - FUNCTOR_LOADSTORE ( VLoadStore128 , uchar , uint8x16_t , vld1q_u8 , vst1q_u8 ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore128 , schar , int8x16_t , vld1q_s8 , vst1q_s8 ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore128 , ushort , uint16x8_t , vld1q_u16 , vst1q_u16 ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore128 , short , int16x8_t , vld1q_s16 , vst1q_s16 ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore128 , int , int32x4_t , vld1q_s32 , vst1q_s32 ) ; <nl> - FUNCTOR_LOADSTORE ( VLoadStore128 , float , float32x4_t , vld1q_f32 , vst1q_f32 ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VAdd ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , uchar , vqaddq_u8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , schar , vqaddq_s8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , ushort , vqaddq_u16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , short , vqaddq_s16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , int , vaddq_s32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAdd , float , vaddq_f32 ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VSub ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , uchar , vqsubq_u8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , schar , vqsubq_s8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , ushort , vqsubq_u16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , short , vqsubq_s16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , int , vsubq_s32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VSub , float , vsubq_f32 ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VMin ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , uchar , vminq_u8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , schar , vminq_s8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , ushort , vminq_u16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , short , vminq_s16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , int , vminq_s32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMin , float , vminq_f32 ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VMax ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , uchar , vmaxq_u8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , schar , vmaxq_s8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , ushort , vmaxq_u16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , short , vmaxq_s16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , int , vmaxq_s32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VMax , float , vmaxq_f32 ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VAbsDiff ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , uchar , vabdq_u8 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , schar , vqabsq_s8 ( vqsubq_s8 ( a , b ) ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , ushort , vabdq_u16 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , short , vqabsq_s16 ( vqsubq_s16 ( a , b ) ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , int , vabdq_s32 ( a , b ) ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAbsDiff , float , vabdq_f32 ( a , b ) ) ; <nl> - <nl> - FUNCTOR_TEMPLATE ( VAnd ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VAnd , uchar , vandq_u8 ( a , b ) ) ; <nl> - FUNCTOR_TEMPLATE ( VOr ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VOr , uchar , vorrq_u8 ( a , b ) ) ; <nl> - FUNCTOR_TEMPLATE ( VXor ) ; <nl> - FUNCTOR_CLOSURE_2arg ( VXor , uchar , veorq_u8 ( a , b ) ) ; <nl> - FUNCTOR_TEMPLATE ( VNot ) ; <nl> - FUNCTOR_CLOSURE_1arg ( VNot , uchar , vmvnq_u8 ( a ) ) ; <nl> - # endif <nl> + if ( ! haveScalar ) <nl> + { <nl> + const Mat * arrays [ ] = { & src1 , & src2 , & dst , & mask , 0 } ; <nl> + uchar * ptrs [ 4 ] ; <nl> <nl> - # if CV_SSE2 | | CV_NEON <nl> - # define IF_SIMD ( op ) op <nl> - # else <nl> - # define IF_SIMD ( op ) NOP <nl> - # endif <nl> + NAryMatIterator it ( arrays , ptrs ) ; <nl> + size_t total = it . size , blocksize = total ; <nl> <nl> - template < > inline uchar OpAdd < uchar > : : operator ( ) ( uchar a , uchar b ) const <nl> - { return CV_FAST_CAST_8U ( a + b ) ; } <nl> - template < > inline uchar OpSub < uchar > : : operator ( ) ( uchar a , uchar b ) const <nl> - { return CV_FAST_CAST_8U ( a - b ) ; } <nl> + if ( blocksize * cn > INT_MAX ) <nl> + blocksize = INT_MAX / cn ; <nl> <nl> - template < typename T > struct OpAbsDiff <nl> - { <nl> - typedef T type1 ; <nl> - typedef T type2 ; <nl> - typedef T rtype ; <nl> - T operator ( ) ( T a , T b ) const { return ( T ) std : : abs ( a - b ) ; } <nl> - } ; <nl> - <nl> - template < > inline short OpAbsDiff < short > : : operator ( ) ( short a , short b ) const <nl> - { return saturate_cast < short > ( std : : abs ( a - b ) ) ; } <nl> - <nl> - template < > inline schar OpAbsDiff < schar > : : operator ( ) ( schar a , schar b ) const <nl> - { return saturate_cast < schar > ( std : : abs ( a - b ) ) ; } <nl> - <nl> - template < typename T , typename WT = T > struct OpAbsDiffS <nl> - { <nl> - typedef T type1 ; <nl> - typedef WT type2 ; <nl> - typedef T rtype ; <nl> - T operator ( ) ( T a , WT b ) const { return saturate_cast < T > ( std : : abs ( a - b ) ) ; } <nl> - } ; <nl> - <nl> - template < typename T > struct OpAnd <nl> - { <nl> - typedef T type1 ; <nl> - typedef T type2 ; <nl> - typedef T rtype ; <nl> - T operator ( ) ( T a , T b ) const { return a & b ; } <nl> - } ; <nl> - <nl> - template < typename T > struct OpOr <nl> - { <nl> - typedef T type1 ; <nl> - typedef T type2 ; <nl> - typedef T rtype ; <nl> - T operator ( ) ( T a , T b ) const { return a | b ; } <nl> - } ; <nl> - <nl> - template < typename T > struct OpXor <nl> - { <nl> - typedef T type1 ; <nl> - typedef T type2 ; <nl> - typedef T rtype ; <nl> - T operator ( ) ( T a , T b ) const { return a ^ b ; } <nl> - } ; <nl> - <nl> - template < typename T > struct OpNot <nl> - { <nl> - typedef T type1 ; <nl> - typedef T type2 ; <nl> - typedef T rtype ; <nl> - T operator ( ) ( T a , T ) const { return ~ a ; } <nl> - } ; <nl> - <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - static inline void fixSteps ( Size sz , size_t elemSize , size_t & step1 , size_t & step2 , size_t & step ) <nl> - { <nl> - if ( sz . height = = 1 ) <nl> - step1 = step2 = step = sz . width * elemSize ; <nl> - } <nl> - # endif <nl> - <nl> - static void add8u ( const uchar * src1 , size_t step1 , <nl> - const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiAdd_8u_C1RSfs ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) , 0 ) ) <nl> + if ( haveMask ) <nl> { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> + blocksize = std : : min ( blocksize , blocksize0 ) ; <nl> + _buf . allocate ( blocksize * esz ) ; <nl> + maskbuf = _buf ; <nl> } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp < uchar , OpAdd < uchar > , IF_SIMD ( VAdd < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> <nl> - static void add8s ( const schar * src1 , size_t step1 , <nl> - const schar * src2 , size_t step2 , <nl> - schar * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp < schar , OpAdd < schar > , IF_SIMD ( VAdd < schar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> - <nl> - static void add16u ( const ushort * src1 , size_t step1 , <nl> - const ushort * src2 , size_t step2 , <nl> - ushort * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiAdd_16u_C1RSfs ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) , 0 ) ) <nl> + for ( size_t i = 0 ; i < it . nplanes ; i + + , + + it ) <nl> { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp < ushort , OpAdd < ushort > , IF_SIMD ( VAdd < ushort > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> + for ( size_t j = 0 ; j < total ; j + = blocksize ) <nl> + { <nl> + int bsz = ( int ) MIN ( total - j , blocksize ) ; <nl> <nl> - static void add16s ( const short * src1 , size_t step1 , <nl> - const short * src2 , size_t step2 , <nl> - short * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiAdd_16s_C1RSfs ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) , 0 ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> + func ( ptrs [ 0 ] , 0 , ptrs [ 1 ] , 0 , haveMask ? maskbuf : ptrs [ 2 ] , 0 , bsz * cn , 1 , 0 ) ; <nl> + if ( haveMask ) <nl> + { <nl> + copymask ( maskbuf , 0 , ptrs [ 3 ] , 0 , ptrs [ 2 ] , 0 , Size ( bsz , 1 ) , & esz ) ; <nl> + ptrs [ 3 ] + = bsz ; <nl> + } <nl> + <nl> + bsz * = ( int ) esz ; <nl> + ptrs [ 0 ] + = bsz ; ptrs [ 1 ] + = bsz ; ptrs [ 2 ] + = bsz ; <nl> + } <nl> } <nl> - setIppErrorStatus ( ) ; <nl> } <nl> - # endif <nl> - ( vBinOp < short , OpAdd < short > , IF_SIMD ( VAdd < short > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> + else <nl> + { <nl> + const Mat * arrays [ ] = { & src1 , & dst , & mask , 0 } ; <nl> + uchar * ptrs [ 3 ] ; <nl> <nl> - static void add32s ( const int * src1 , size_t step1 , <nl> - const int * src2 , size_t step2 , <nl> - int * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp32 < int , OpAdd < int > , IF_SIMD ( VAdd < int > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> + NAryMatIterator it ( arrays , ptrs ) ; <nl> + size_t total = it . size , blocksize = std : : min ( total , blocksize0 ) ; <nl> <nl> - static void add32f ( const float * src1 , size_t step1 , <nl> - const float * src2 , size_t step2 , <nl> - float * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiAdd_32f_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp32 < float , OpAdd < float > , IF_SIMD ( VAdd < float > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> + _buf . allocate ( blocksize * ( haveMask ? 2 : 1 ) * esz + 32 ) ; <nl> + scbuf = _buf ; <nl> + maskbuf = alignPtr ( scbuf + blocksize * esz , 16 ) ; <nl> <nl> - static void add64f ( const double * src1 , size_t step1 , <nl> - const double * src2 , size_t step2 , <nl> - double * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp64 < double , OpAdd < double > , IF_SIMD ( VAdd < double > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> + convertAndUnrollScalar ( src2 , src1 . type ( ) , scbuf , blocksize ) ; <nl> <nl> - static void sub8u ( const uchar * src1 , size_t step1 , <nl> - const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiSub_8u_C1RSfs ( src2 , ( int ) step2 , src1 , ( int ) step1 , dst , ( int ) step , ippiSize ( sz ) , 0 ) ) <nl> + for ( size_t i = 0 ; i < it . nplanes ; i + + , + + it ) <nl> { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp < uchar , OpSub < uchar > , IF_SIMD ( VSub < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> + for ( size_t j = 0 ; j < total ; j + = blocksize ) <nl> + { <nl> + int bsz = ( int ) MIN ( total - j , blocksize ) ; <nl> <nl> - static void sub8s ( const schar * src1 , size_t step1 , <nl> - const schar * src2 , size_t step2 , <nl> - schar * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp < schar , OpSub < schar > , IF_SIMD ( VSub < schar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> + func ( ptrs [ 0 ] , 0 , scbuf , 0 , haveMask ? maskbuf : ptrs [ 1 ] , 0 , bsz * cn , 1 , 0 ) ; <nl> + if ( haveMask ) <nl> + { <nl> + copymask ( maskbuf , 0 , ptrs [ 2 ] , 0 , ptrs [ 1 ] , 0 , Size ( bsz , 1 ) , & esz ) ; <nl> + ptrs [ 2 ] + = bsz ; <nl> + } <nl> <nl> - static void sub16u ( const ushort * src1 , size_t step1 , <nl> - const ushort * src2 , size_t step2 , <nl> - ushort * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiSub_16u_C1RSfs ( src2 , ( int ) step2 , src1 , ( int ) step1 , dst , ( int ) step , ippiSize ( sz ) , 0 ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> + bsz * = ( int ) esz ; <nl> + ptrs [ 0 ] + = bsz ; ptrs [ 1 ] + = bsz ; <nl> + } <nl> } <nl> - setIppErrorStatus ( ) ; <nl> } <nl> - # endif <nl> - ( vBinOp < ushort , OpSub < ushort > , IF_SIMD ( VSub < ushort > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> } <nl> <nl> - static void sub16s ( const short * src1 , size_t step1 , <nl> - const short * src2 , size_t step2 , <nl> - short * dst , size_t step , Size sz , void * ) <nl> + static BinaryFuncC * getMaxTab ( ) <nl> { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> + static BinaryFuncC maxTab [ ] = <nl> { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiSub_16s_C1RSfs ( src2 , ( int ) step2 , src1 , ( int ) step1 , dst , ( int ) step , ippiSize ( sz ) , 0 ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp < short , OpSub < short > , IF_SIMD ( VSub < short > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : max8u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : max8s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : max16u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : max16s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : max32s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : max32f ) , ( BinaryFuncC ) cv : : hal : : max64f , <nl> + 0 <nl> + } ; <nl> <nl> - static void sub32s ( const int * src1 , size_t step1 , <nl> - const int * src2 , size_t step2 , <nl> - int * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp32 < int , OpSub < int > , IF_SIMD ( VSub < int > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + return maxTab ; <nl> } <nl> <nl> - static void sub32f ( const float * src1 , size_t step1 , <nl> - const float * src2 , size_t step2 , <nl> - float * dst , size_t step , Size sz , void * ) <nl> + static BinaryFuncC * getMinTab ( ) <nl> { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> + static BinaryFuncC minTab [ ] = <nl> { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiSub_32f_C1R ( src2 , ( int ) step2 , src1 , ( int ) step1 , dst , ( int ) step , ippiSize ( sz ) ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp32 < float , OpSub < float > , IF_SIMD ( VSub < float > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : min8u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : min8s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : min16u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : min16s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : min32s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : min32f ) , ( BinaryFuncC ) cv : : hal : : min64f , <nl> + 0 <nl> + } ; <nl> <nl> - static void sub64f ( const double * src1 , size_t step1 , <nl> - const double * src2 , size_t step2 , <nl> - double * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp64 < double , OpSub < double > , IF_SIMD ( VSub < double > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + return minTab ; <nl> } <nl> <nl> - template < > inline uchar OpMin < uchar > : : operator ( ) ( uchar a , uchar b ) const { return CV_MIN_8U ( a , b ) ; } <nl> - template < > inline uchar OpMax < uchar > : : operator ( ) ( uchar a , uchar b ) const { return CV_MAX_8U ( a , b ) ; } <nl> - <nl> - static void max8u ( const uchar * src1 , size_t step1 , <nl> - const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - uchar * s1 = ( uchar * ) src1 ; <nl> - uchar * s2 = ( uchar * ) src2 ; <nl> - uchar * d = dst ; <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - int i = 0 ; <nl> - for ( ; i < sz . height ; i + + ) <nl> - { <nl> - if ( 0 > ippsMaxEvery_8u ( s1 , s2 , d , sz . width ) ) <nl> - break ; <nl> - s1 + = step1 ; <nl> - s2 + = step2 ; <nl> - d + = step ; <nl> - } <nl> - if ( i = = sz . height ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - vBinOp < uchar , OpMax < uchar > , IF_SIMD ( VMax < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> } <nl> <nl> - static void max8s ( const schar * src1 , size_t step1 , <nl> - const schar * src2 , size_t step2 , <nl> - schar * dst , size_t step , Size sz , void * ) <nl> + void cv : : bitwise_and ( InputArray a , InputArray b , OutputArray c , InputArray mask ) <nl> { <nl> - vBinOp < schar , OpMax < schar > , IF_SIMD ( VMax < schar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + BinaryFuncC f = ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : and8u ) ; <nl> + binary_op ( a , b , c , mask , & f , true , OCL_OP_AND ) ; <nl> } <nl> <nl> - static void max16u ( const ushort * src1 , size_t step1 , <nl> - const ushort * src2 , size_t step2 , <nl> - ushort * dst , size_t step , Size sz , void * ) <nl> + void cv : : bitwise_or ( InputArray a , InputArray b , OutputArray c , InputArray mask ) <nl> { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - ushort * s1 = ( ushort * ) src1 ; <nl> - ushort * s2 = ( ushort * ) src2 ; <nl> - ushort * d = dst ; <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - int i = 0 ; <nl> - for ( ; i < sz . height ; i + + ) <nl> - { <nl> - if ( 0 > ippsMaxEvery_16u ( s1 , s2 , d , sz . width ) ) <nl> - break ; <nl> - s1 = ( ushort * ) ( ( uchar * ) s1 + step1 ) ; <nl> - s2 = ( ushort * ) ( ( uchar * ) s2 + step2 ) ; <nl> - d = ( ushort * ) ( ( uchar * ) d + step ) ; <nl> - } <nl> - if ( i = = sz . height ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - vBinOp < ushort , OpMax < ushort > , IF_SIMD ( VMax < ushort > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + BinaryFuncC f = ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : or8u ) ; <nl> + binary_op ( a , b , c , mask , & f , true , OCL_OP_OR ) ; <nl> } <nl> <nl> - static void max16s ( const short * src1 , size_t step1 , <nl> - const short * src2 , size_t step2 , <nl> - short * dst , size_t step , Size sz , void * ) <nl> + void cv : : bitwise_xor ( InputArray a , InputArray b , OutputArray c , InputArray mask ) <nl> { <nl> - vBinOp < short , OpMax < short > , IF_SIMD ( VMax < short > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + BinaryFuncC f = ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : xor8u ) ; <nl> + binary_op ( a , b , c , mask , & f , true , OCL_OP_XOR ) ; <nl> } <nl> <nl> - static void max32s ( const int * src1 , size_t step1 , <nl> - const int * src2 , size_t step2 , <nl> - int * dst , size_t step , Size sz , void * ) <nl> + void cv : : bitwise_not ( InputArray a , OutputArray c , InputArray mask ) <nl> { <nl> - vBinOp32 < int , OpMax < int > , IF_SIMD ( VMax < int > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + BinaryFuncC f = ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : not8u ) ; <nl> + binary_op ( a , a , c , mask , & f , true , OCL_OP_NOT ) ; <nl> } <nl> <nl> - static void max32f ( const float * src1 , size_t step1 , <nl> - const float * src2 , size_t step2 , <nl> - float * dst , size_t step , Size sz , void * ) <nl> + void cv : : max ( InputArray src1 , InputArray src2 , OutputArray dst ) <nl> { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - float * s1 = ( float * ) src1 ; <nl> - float * s2 = ( float * ) src2 ; <nl> - float * d = dst ; <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - int i = 0 ; <nl> - for ( ; i < sz . height ; i + + ) <nl> - { <nl> - if ( 0 > ippsMaxEvery_32f ( s1 , s2 , d , sz . width ) ) <nl> - break ; <nl> - s1 = ( float * ) ( ( uchar * ) s1 + step1 ) ; <nl> - s2 = ( float * ) ( ( uchar * ) s2 + step2 ) ; <nl> - d = ( float * ) ( ( uchar * ) d + step ) ; <nl> - } <nl> - if ( i = = sz . height ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - vBinOp32 < float , OpMax < float > , IF_SIMD ( VMax < float > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + binary_op ( src1 , src2 , dst , noArray ( ) , getMaxTab ( ) , false , OCL_OP_MAX ) ; <nl> } <nl> <nl> - static void max64f ( const double * src1 , size_t step1 , <nl> - const double * src2 , size_t step2 , <nl> - double * dst , size_t step , Size sz , void * ) <nl> + void cv : : min ( InputArray src1 , InputArray src2 , OutputArray dst ) <nl> { <nl> - # if ARITHM_USE_IPP = = 1 <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - double * s1 = ( double * ) src1 ; <nl> - double * s2 = ( double * ) src2 ; <nl> - double * d = dst ; <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - int i = 0 ; <nl> - for ( ; i < sz . height ; i + + ) <nl> - { <nl> - if ( 0 > ippsMaxEvery_64f ( s1 , s2 , d , sz . width ) ) <nl> - break ; <nl> - s1 = ( double * ) ( ( uchar * ) s1 + step1 ) ; <nl> - s2 = ( double * ) ( ( uchar * ) s2 + step2 ) ; <nl> - d = ( double * ) ( ( uchar * ) d + step ) ; <nl> - } <nl> - if ( i = = sz . height ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - vBinOp64 < double , OpMax < double > , IF_SIMD ( VMax < double > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + binary_op ( src1 , src2 , dst , noArray ( ) , getMinTab ( ) , false , OCL_OP_MIN ) ; <nl> } <nl> <nl> - static void min8u ( const uchar * src1 , size_t step1 , <nl> - const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * ) <nl> + void cv : : max ( const Mat & src1 , const Mat & src2 , Mat & dst ) <nl> { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - uchar * s1 = ( uchar * ) src1 ; <nl> - uchar * s2 = ( uchar * ) src2 ; <nl> - uchar * d = dst ; <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - int i = 0 ; <nl> - for ( ; i < sz . height ; i + + ) <nl> - { <nl> - if ( 0 > ippsMinEvery_8u ( s1 , s2 , d , sz . width ) ) <nl> - break ; <nl> - s1 + = step1 ; <nl> - s2 + = step2 ; <nl> - d + = step ; <nl> - } <nl> - if ( i = = sz . height ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - vBinOp < uchar , OpMin < uchar > , IF_SIMD ( VMin < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + OutputArray _dst ( dst ) ; <nl> + binary_op ( src1 , src2 , _dst , noArray ( ) , getMaxTab ( ) , false , OCL_OP_MAX ) ; <nl> } <nl> <nl> - static void min8s ( const schar * src1 , size_t step1 , <nl> - const schar * src2 , size_t step2 , <nl> - schar * dst , size_t step , Size sz , void * ) <nl> + void cv : : min ( const Mat & src1 , const Mat & src2 , Mat & dst ) <nl> { <nl> - vBinOp < schar , OpMin < schar > , IF_SIMD ( VMin < schar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + OutputArray _dst ( dst ) ; <nl> + binary_op ( src1 , src2 , _dst , noArray ( ) , getMinTab ( ) , false , OCL_OP_MIN ) ; <nl> } <nl> <nl> - static void min16u ( const ushort * src1 , size_t step1 , <nl> - const ushort * src2 , size_t step2 , <nl> - ushort * dst , size_t step , Size sz , void * ) <nl> + void cv : : max ( const UMat & src1 , const UMat & src2 , UMat & dst ) <nl> { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - ushort * s1 = ( ushort * ) src1 ; <nl> - ushort * s2 = ( ushort * ) src2 ; <nl> - ushort * d = dst ; <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - int i = 0 ; <nl> - for ( ; i < sz . height ; i + + ) <nl> - { <nl> - if ( 0 > ippsMinEvery_16u ( s1 , s2 , d , sz . width ) ) <nl> - break ; <nl> - s1 = ( ushort * ) ( ( uchar * ) s1 + step1 ) ; <nl> - s2 = ( ushort * ) ( ( uchar * ) s2 + step2 ) ; <nl> - d = ( ushort * ) ( ( uchar * ) d + step ) ; <nl> - } <nl> - if ( i = = sz . height ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - vBinOp < ushort , OpMin < ushort > , IF_SIMD ( VMin < ushort > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + OutputArray _dst ( dst ) ; <nl> + binary_op ( src1 , src2 , _dst , noArray ( ) , getMaxTab ( ) , false , OCL_OP_MAX ) ; <nl> } <nl> <nl> - static void min16s ( const short * src1 , size_t step1 , <nl> - const short * src2 , size_t step2 , <nl> - short * dst , size_t step , Size sz , void * ) <nl> + void cv : : min ( const UMat & src1 , const UMat & src2 , UMat & dst ) <nl> { <nl> - vBinOp < short , OpMin < short > , IF_SIMD ( VMin < short > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> + OutputArray _dst ( dst ) ; <nl> + binary_op ( src1 , src2 , _dst , noArray ( ) , getMinTab ( ) , false , OCL_OP_MIN ) ; <nl> } <nl> <nl> - static void min32s ( const int * src1 , size_t step1 , <nl> - const int * src2 , size_t step2 , <nl> - int * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp32 < int , OpMin < int > , IF_SIMD ( VMin < int > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> <nl> - static void min32f ( const float * src1 , size_t step1 , <nl> - const float * src2 , size_t step2 , <nl> - float * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - float * s1 = ( float * ) src1 ; <nl> - float * s2 = ( float * ) src2 ; <nl> - float * d = dst ; <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - int i = 0 ; <nl> - for ( ; i < sz . height ; i + + ) <nl> - { <nl> - if ( 0 > ippsMinEvery_32f ( s1 , s2 , d , sz . width ) ) <nl> - break ; <nl> - s1 = ( float * ) ( ( uchar * ) s1 + step1 ) ; <nl> - s2 = ( float * ) ( ( uchar * ) s2 + step2 ) ; <nl> - d = ( float * ) ( ( uchar * ) d + step ) ; <nl> - } <nl> - if ( i = = sz . height ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - vBinOp32 < float , OpMin < float > , IF_SIMD ( VMin < float > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> + * add / subtract * <nl> + \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - static void min64f ( const double * src1 , size_t step1 , <nl> - const double * src2 , size_t step2 , <nl> - double * dst , size_t step , Size sz , void * ) <nl> + namespace cv <nl> { <nl> - # if ARITHM_USE_IPP = = 1 <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - double * s1 = ( double * ) src1 ; <nl> - double * s2 = ( double * ) src2 ; <nl> - double * d = dst ; <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - int i = 0 ; <nl> - for ( ; i < sz . height ; i + + ) <nl> - { <nl> - if ( 0 > ippsMinEvery_64f ( s1 , s2 , d , sz . width ) ) <nl> - break ; <nl> - s1 = ( double * ) ( ( uchar * ) s1 + step1 ) ; <nl> - s2 = ( double * ) ( ( uchar * ) s2 + step2 ) ; <nl> - d = ( double * ) ( ( uchar * ) d + step ) ; <nl> - } <nl> - if ( i = = sz . height ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - vBinOp64 < double , OpMin < double > , IF_SIMD ( VMin < double > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> <nl> - static void absdiff8u ( const uchar * src1 , size_t step1 , <nl> - const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * ) <nl> + static int actualScalarDepth ( const double * data , int len ) <nl> { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> + int i = 0 , minval = INT_MAX , maxval = INT_MIN ; <nl> + for ( ; i < len ; + + i ) <nl> { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiAbsDiff_8u_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> + int ival = cvRound ( data [ i ] ) ; <nl> + if ( ival ! = data [ i ] ) <nl> + break ; <nl> + minval = MIN ( minval , ival ) ; <nl> + maxval = MAX ( maxval , ival ) ; <nl> } <nl> - # endif <nl> - ( vBinOp < uchar , OpAbsDiff < uchar > , IF_SIMD ( VAbsDiff < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> + return i < len ? CV_64F : <nl> + minval > = 0 & & maxval < = ( int ) UCHAR_MAX ? CV_8U : <nl> + minval > = ( int ) SCHAR_MIN & & maxval < = ( int ) SCHAR_MAX ? CV_8S : <nl> + minval > = 0 & & maxval < = ( int ) USHRT_MAX ? CV_16U : <nl> + minval > = ( int ) SHRT_MIN & & maxval < = ( int ) SHRT_MAX ? CV_16S : <nl> + CV_32S ; <nl> } <nl> <nl> - static void absdiff8s ( const schar * src1 , size_t step1 , <nl> - const schar * src2 , size_t step2 , <nl> - schar * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp < schar , OpAbsDiff < schar > , IF_SIMD ( VAbsDiff < schar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> + # ifdef HAVE_OPENCL <nl> <nl> - static void absdiff16u ( const ushort * src1 , size_t step1 , <nl> - const ushort * src2 , size_t step2 , <nl> - ushort * dst , size_t step , Size sz , void * ) <nl> + static bool ocl_arithm_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> + InputArray _mask , int wtype , <nl> + void * usrdata , int oclop , <nl> + bool haveScalar ) <nl> { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiAbsDiff_16u_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp < ushort , OpAbsDiff < ushort > , IF_SIMD ( VAbsDiff < ushort > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> - <nl> - static void absdiff16s ( const short * src1 , size_t step1 , <nl> - const short * src2 , size_t step2 , <nl> - short * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp < short , OpAbsDiff < short > , IF_SIMD ( VAbsDiff < short > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> - <nl> - static void absdiff32s ( const int * src1 , size_t step1 , <nl> - const int * src2 , size_t step2 , <nl> - int * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp32 < int , OpAbsDiff < int > , IF_SIMD ( VAbsDiff < int > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> - <nl> - static void absdiff32f ( const float * src1 , size_t step1 , <nl> - const float * src2 , size_t step2 , <nl> - float * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiAbsDiff_32f_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp32 < float , OpAbsDiff < float > , IF_SIMD ( VAbsDiff < float > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> - <nl> - static void absdiff64f ( const double * src1 , size_t step1 , <nl> - const double * src2 , size_t step2 , <nl> - double * dst , size_t step , Size sz , void * ) <nl> - { <nl> - vBinOp64 < double , OpAbsDiff < double > , IF_SIMD ( VAbsDiff < double > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ; <nl> - } <nl> - <nl> + const ocl : : Device d = ocl : : Device : : getDefault ( ) ; <nl> + bool doubleSupport = d . doubleFPConfig ( ) > 0 ; <nl> + int type1 = _src1 . type ( ) , depth1 = CV_MAT_DEPTH ( type1 ) , cn = CV_MAT_CN ( type1 ) ; <nl> + bool haveMask = ! _mask . empty ( ) ; <nl> <nl> - static void and8u ( const uchar * src1 , size_t step1 , <nl> - const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiAnd_8u_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp < uchar , OpAnd < uchar > , IF_SIMD ( VAnd < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> + if ( ( haveMask | | haveScalar ) & & cn > 4 ) <nl> + return false ; <nl> <nl> - static void or8u ( const uchar * src1 , size_t step1 , <nl> - const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiOr_8u_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp < uchar , OpOr < uchar > , IF_SIMD ( VOr < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> + int dtype = _dst . type ( ) , ddepth = CV_MAT_DEPTH ( dtype ) , wdepth = std : : max ( CV_32S , CV_MAT_DEPTH ( wtype ) ) ; <nl> + if ( ! doubleSupport ) <nl> + wdepth = std : : min ( wdepth , CV_32F ) ; <nl> <nl> - static void xor8u ( const uchar * src1 , size_t step1 , <nl> - const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiXor_8u_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp < uchar , OpXor < uchar > , IF_SIMD ( VXor < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> + wtype = CV_MAKETYPE ( wdepth , cn ) ; <nl> + int type2 = haveScalar ? wtype : _src2 . type ( ) , depth2 = CV_MAT_DEPTH ( type2 ) ; <nl> + if ( ! doubleSupport & & ( depth2 = = CV_64F | | depth1 = = CV_64F ) ) <nl> + return false ; <nl> <nl> - static void not8u ( const uchar * src1 , size_t step1 , <nl> - const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * ) <nl> - { <nl> - # if ( ARITHM_USE_IPP = = 1 ) <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - fixSteps ( sz , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; ( void ) src2 ; <nl> - if ( 0 < = ippiNot_8u_C1R ( src1 , ( int ) step1 , dst , ( int ) step , ippiSize ( sz ) ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - # endif <nl> - ( vBinOp < uchar , OpNot < uchar > , IF_SIMD ( VNot < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , sz ) ) ; <nl> - } <nl> + int kercn = haveMask | | haveScalar ? cn : ocl : : predictOptimalVectorWidth ( _src1 , _src2 , _dst ) ; <nl> + int scalarcn = kercn = = 3 ? 4 : kercn , rowsPerWI = d . isIntel ( ) ? 4 : 1 ; <nl> <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> - * logical operations * <nl> - \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + char cvtstr [ 4 ] [ 32 ] , opts [ 1024 ] ; <nl> + sprintf ( opts , " - D % s % s - D % s - D srcT1 = % s - D srcT1_C1 = % s - D srcT2 = % s - D srcT2_C1 = % s " <nl> + " - D dstT = % s - D dstT_C1 = % s - D workT = % s - D workST = % s - D scaleT = % s - D wdepth = % d - D convertToWT1 = % s " <nl> + " - D convertToWT2 = % s - D convertToDT = % s % s - D cn = % d - D rowsPerWI = % d - D convertFromU = % s " , <nl> + ( haveMask ? " MASK_ " : " " ) , ( haveScalar ? " UNARY_OP " : " BINARY_OP " ) , <nl> + oclop2str [ oclop ] , ocl : : typeToStr ( CV_MAKETYPE ( depth1 , kercn ) ) , <nl> + ocl : : typeToStr ( depth1 ) , ocl : : typeToStr ( CV_MAKETYPE ( depth2 , kercn ) ) , <nl> + ocl : : typeToStr ( depth2 ) , ocl : : typeToStr ( CV_MAKETYPE ( ddepth , kercn ) ) , <nl> + ocl : : typeToStr ( ddepth ) , ocl : : typeToStr ( CV_MAKETYPE ( wdepth , kercn ) ) , <nl> + ocl : : typeToStr ( CV_MAKETYPE ( wdepth , scalarcn ) ) , <nl> + ocl : : typeToStr ( wdepth ) , wdepth , <nl> + ocl : : convertTypeStr ( depth1 , wdepth , kercn , cvtstr [ 0 ] ) , <nl> + ocl : : convertTypeStr ( depth2 , wdepth , kercn , cvtstr [ 1 ] ) , <nl> + ocl : : convertTypeStr ( wdepth , ddepth , kercn , cvtstr [ 2 ] ) , <nl> + doubleSupport ? " - D DOUBLE_SUPPORT " : " " , kercn , rowsPerWI , <nl> + oclop = = OCL_OP_ABSDIFF & & wdepth = = CV_32S & & ddepth = = wdepth ? <nl> + ocl : : convertTypeStr ( CV_8U , ddepth , kercn , cvtstr [ 3 ] ) : " noconvert " ) ; <nl> <nl> - void convertAndUnrollScalar ( const Mat & sc , int buftype , uchar * scbuf , size_t blocksize ) <nl> - { <nl> - int scn = ( int ) sc . total ( ) , cn = CV_MAT_CN ( buftype ) ; <nl> - size_t esz = CV_ELEM_SIZE ( buftype ) ; <nl> - getConvertFunc ( sc . depth ( ) , buftype ) ( sc . ptr ( ) , 1 , 0 , 1 , scbuf , 1 , Size ( std : : min ( cn , scn ) , 1 ) , 0 ) ; <nl> - / / unroll the scalar <nl> - if ( scn < cn ) <nl> + size_t usrdata_esz = CV_ELEM_SIZE ( wdepth ) ; <nl> + const uchar * usrdata_p = ( const uchar * ) usrdata ; <nl> + const double * usrdata_d = ( const double * ) usrdata ; <nl> + float usrdata_f [ 3 ] ; <nl> + int i , n = oclop = = OCL_OP_MUL_SCALE | | oclop = = OCL_OP_DIV_SCALE | | <nl> + oclop = = OCL_OP_RDIV_SCALE | | oclop = = OCL_OP_RECIP_SCALE ? 1 : oclop = = OCL_OP_ADDW ? 3 : 0 ; <nl> + if ( n > 0 & & wdepth = = CV_32F ) <nl> { <nl> - CV_Assert ( scn = = 1 ) ; <nl> - size_t esz1 = CV_ELEM_SIZE1 ( buftype ) ; <nl> - for ( size_t i = esz1 ; i < esz ; i + + ) <nl> - scbuf [ i ] = scbuf [ i - esz1 ] ; <nl> + for ( i = 0 ; i < n ; i + + ) <nl> + usrdata_f [ i ] = ( float ) usrdata_d [ i ] ; <nl> + usrdata_p = ( const uchar * ) usrdata_f ; <nl> } <nl> - for ( size_t i = esz ; i < blocksize * esz ; i + + ) <nl> - scbuf [ i ] = scbuf [ i - esz ] ; <nl> - } <nl> - <nl> - <nl> - enum { OCL_OP_ADD = 0 , OCL_OP_SUB = 1 , OCL_OP_RSUB = 2 , OCL_OP_ABSDIFF = 3 , OCL_OP_MUL = 4 , <nl> - OCL_OP_MUL_SCALE = 5 , OCL_OP_DIV_SCALE = 6 , OCL_OP_RECIP_SCALE = 7 , OCL_OP_ADDW = 8 , <nl> - OCL_OP_AND = 9 , OCL_OP_OR = 10 , OCL_OP_XOR = 11 , OCL_OP_NOT = 12 , OCL_OP_MIN = 13 , OCL_OP_MAX = 14 , <nl> - OCL_OP_RDIV_SCALE = 15 } ; <nl> - <nl> - # ifdef HAVE_OPENCL <nl> - <nl> - static const char * oclop2str [ ] = { " OP_ADD " , " OP_SUB " , " OP_RSUB " , " OP_ABSDIFF " , <nl> - " OP_MUL " , " OP_MUL_SCALE " , " OP_DIV_SCALE " , " OP_RECIP_SCALE " , <nl> - " OP_ADDW " , " OP_AND " , " OP_OR " , " OP_XOR " , " OP_NOT " , " OP_MIN " , " OP_MAX " , " OP_RDIV_SCALE " , 0 } ; <nl> - <nl> - static bool ocl_binary_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> - InputArray _mask , bool bitwise , int oclop , bool haveScalar ) <nl> - { <nl> - bool haveMask = ! _mask . empty ( ) ; <nl> - int srctype = _src1 . type ( ) ; <nl> - int srcdepth = CV_MAT_DEPTH ( srctype ) ; <nl> - int cn = CV_MAT_CN ( srctype ) ; <nl> - <nl> - const ocl : : Device d = ocl : : Device : : getDefault ( ) ; <nl> - bool doubleSupport = d . doubleFPConfig ( ) > 0 ; <nl> - if ( oclop < 0 | | ( ( haveMask | | haveScalar ) & & cn > 4 ) | | <nl> - ( ! doubleSupport & & srcdepth = = CV_64F & & ! bitwise ) ) <nl> - return false ; <nl> - <nl> - char opts [ 1024 ] ; <nl> - int kercn = haveMask | | haveScalar ? cn : ocl : : predictOptimalVectorWidth ( _src1 , _src2 , _dst ) ; <nl> - int scalarcn = kercn = = 3 ? 4 : kercn ; <nl> - int rowsPerWI = d . isIntel ( ) ? 4 : 1 ; <nl> - <nl> - sprintf ( opts , " - D % s % s - D % s - D dstT = % s % s - D dstT_C1 = % s - D workST = % s - D cn = % d - D rowsPerWI = % d " , <nl> - haveMask ? " MASK_ " : " " , haveScalar ? " UNARY_OP " : " BINARY_OP " , oclop2str [ oclop ] , <nl> - bitwise ? ocl : : memopTypeToStr ( CV_MAKETYPE ( srcdepth , kercn ) ) : <nl> - ocl : : typeToStr ( CV_MAKETYPE ( srcdepth , kercn ) ) , doubleSupport ? " - D DOUBLE_SUPPORT " : " " , <nl> - bitwise ? ocl : : memopTypeToStr ( CV_MAKETYPE ( srcdepth , 1 ) ) : <nl> - ocl : : typeToStr ( CV_MAKETYPE ( srcdepth , 1 ) ) , <nl> - bitwise ? ocl : : memopTypeToStr ( CV_MAKETYPE ( srcdepth , scalarcn ) ) : <nl> - ocl : : typeToStr ( CV_MAKETYPE ( srcdepth , scalarcn ) ) , <nl> - kercn , rowsPerWI ) ; <nl> <nl> ocl : : Kernel k ( " KF " , ocl : : core : : arithm_oclsrc , opts ) ; <nl> if ( k . empty ( ) ) <nl> static bool ocl_binary_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> <nl> if ( haveScalar ) <nl> { <nl> - size_t esz = CV_ELEM_SIZE1 ( srctype ) * scalarcn ; <nl> - double buf [ 4 ] = { 0 , 0 , 0 , 0 } ; <nl> - <nl> - if ( oclop ! = OCL_OP_NOT ) <nl> - { <nl> - Mat src2sc = _src2 . getMat ( ) ; <nl> - convertAndUnrollScalar ( src2sc , srctype , ( uchar * ) buf , 1 ) ; <nl> - } <nl> + size_t esz = CV_ELEM_SIZE1 ( wtype ) * scalarcn ; <nl> + double buf [ 4 ] = { 0 , 0 , 0 , 0 } ; <nl> + Mat src2sc = _src2 . getMat ( ) ; <nl> <nl> + if ( ! src2sc . empty ( ) ) <nl> + convertAndUnrollScalar ( src2sc , wtype , ( uchar * ) buf , 1 ) ; <nl> ocl : : KernelArg scalararg = ocl : : KernelArg ( 0 , 0 , 0 , 0 , buf , esz ) ; <nl> <nl> if ( ! haveMask ) <nl> - k . args ( src1arg , dstarg , scalararg ) ; <nl> + { <nl> + if ( n = = 0 ) <nl> + k . args ( src1arg , dstarg , scalararg ) ; <nl> + else if ( n = = 1 ) <nl> + k . args ( src1arg , dstarg , scalararg , <nl> + ocl : : KernelArg ( 0 , 0 , 0 , 0 , usrdata_p , usrdata_esz ) ) ; <nl> + else <nl> + CV_Error ( Error : : StsNotImplemented , " unsupported number of extra parameters " ) ; <nl> + } <nl> else <nl> k . args ( src1arg , maskarg , dstarg , scalararg ) ; <nl> } <nl> static bool ocl_binary_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> ocl : : KernelArg src2arg = ocl : : KernelArg : : ReadOnlyNoSize ( src2 , cn , kercn ) ; <nl> <nl> if ( ! haveMask ) <nl> - k . args ( src1arg , src2arg , dstarg ) ; <nl> + { <nl> + if ( n = = 0 ) <nl> + k . args ( src1arg , src2arg , dstarg ) ; <nl> + else if ( n = = 1 ) <nl> + k . args ( src1arg , src2arg , dstarg , <nl> + ocl : : KernelArg ( 0 , 0 , 0 , 0 , usrdata_p , usrdata_esz ) ) ; <nl> + else if ( n = = 3 ) <nl> + k . args ( src1arg , src2arg , dstarg , <nl> + ocl : : KernelArg ( 0 , 0 , 0 , 0 , usrdata_p , usrdata_esz ) , <nl> + ocl : : KernelArg ( 0 , 0 , 0 , 0 , usrdata_p + usrdata_esz , usrdata_esz ) , <nl> + ocl : : KernelArg ( 0 , 0 , 0 , 0 , usrdata_p + usrdata_esz * 2 , usrdata_esz ) ) ; <nl> + else <nl> + CV_Error ( Error : : StsNotImplemented , " unsupported number of extra parameters " ) ; <nl> + } <nl> else <nl> k . args ( src1arg , src2arg , maskarg , dstarg ) ; <nl> } <nl> <nl> size_t globalsize [ ] = { ( size_t ) src1 . cols * cn / kercn , ( ( size_t ) src1 . rows + rowsPerWI - 1 ) / rowsPerWI } ; <nl> - return k . run ( 2 , globalsize , 0 , false ) ; <nl> + return k . run ( 2 , globalsize , NULL , false ) ; <nl> } <nl> <nl> # endif <nl> <nl> - static void binary_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> - InputArray _mask , const BinaryFunc * tab , <nl> - bool bitwise , int oclop ) <nl> + static void arithm_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> + InputArray _mask , int dtype , BinaryFuncC * tab , bool muldiv = false , <nl> + void * usrdata = 0 , int oclop = - 1 ) <nl> { <nl> const _InputArray * psrc1 = & _src1 , * psrc2 = & _src2 ; <nl> int kind1 = psrc1 - > kind ( ) , kind2 = psrc2 - > kind ( ) ; <nl> + bool haveMask = ! _mask . empty ( ) ; <nl> + bool reallocate = false ; <nl> int type1 = psrc1 - > type ( ) , depth1 = CV_MAT_DEPTH ( type1 ) , cn = CV_MAT_CN ( type1 ) ; <nl> int type2 = psrc2 - > type ( ) , depth2 = CV_MAT_DEPTH ( type2 ) , cn2 = CV_MAT_CN ( type2 ) ; <nl> - int dims1 = psrc1 - > dims ( ) , dims2 = psrc2 - > dims ( ) ; <nl> + int wtype , dims1 = psrc1 - > dims ( ) , dims2 = psrc2 - > dims ( ) ; <nl> Size sz1 = dims1 < = 2 ? psrc1 - > size ( ) : Size ( ) ; <nl> Size sz2 = dims2 < = 2 ? psrc2 - > size ( ) : Size ( ) ; <nl> # ifdef HAVE_OPENCL <nl> - bool use_opencl = ( kind1 = = _InputArray : : UMAT | | kind2 = = _InputArray : : UMAT ) & & <nl> - dims1 < = 2 & & dims2 < = 2 ; <nl> + bool use_opencl = OCL_PERFORMANCE_CHECK ( _dst . isUMat ( ) ) & & dims1 < = 2 & & dims2 < = 2 ; <nl> # endif <nl> - bool haveMask = ! _mask . empty ( ) , haveScalar = false ; <nl> - BinaryFunc func ; <nl> + bool src1Scalar = checkScalar ( * psrc1 , type2 , kind1 , kind2 ) ; <nl> + bool src2Scalar = checkScalar ( * psrc2 , type1 , kind2 , kind1 ) ; <nl> <nl> - if ( dims1 < = 2 & & dims2 < = 2 & & kind1 = = kind2 & & sz1 = = sz2 & & type1 = = type2 & & ! haveMask ) <nl> + if ( ( kind1 = = kind2 | | cn = = 1 ) & & sz1 = = sz2 & & dims1 < = 2 & & dims2 < = 2 & & type1 = = type2 & & <nl> + ! haveMask & & ( ( ! _dst . fixedType ( ) & & ( dtype < 0 | | CV_MAT_DEPTH ( dtype ) = = depth1 ) ) | | <nl> + ( _dst . fixedType ( ) & & _dst . type ( ) = = type1 ) ) & & <nl> + ( ( src1Scalar & & src2Scalar ) | | ( ! src1Scalar & & ! src2Scalar ) ) ) <nl> { <nl> - _dst . create ( sz1 , type1 ) ; <nl> + _dst . createSameSize ( * psrc1 , type1 ) ; <nl> CV_OCL_RUN ( use_opencl , <nl> - ocl_binary_op ( * psrc1 , * psrc2 , _dst , _mask , bitwise , oclop , false ) ) <nl> - <nl> - if ( bitwise ) <nl> - { <nl> - func = * tab ; <nl> - cn = ( int ) CV_ELEM_SIZE ( type1 ) ; <nl> - } <nl> - else <nl> - func = tab [ depth1 ] ; <nl> + ocl_arithm_op ( * psrc1 , * psrc2 , _dst , _mask , <nl> + ( ! usrdata ? type1 : std : : max ( depth1 , CV_32F ) ) , <nl> + usrdata , oclop , false ) ) <nl> <nl> Mat src1 = psrc1 - > getMat ( ) , src2 = psrc2 - > getMat ( ) , dst = _dst . getMat ( ) ; <nl> - Size sz = getContinuousSize ( src1 , src2 , dst ) ; <nl> - size_t len = sz . width * ( size_t ) cn ; <nl> - if ( len = = ( size_t ) ( int ) len ) <nl> - { <nl> - sz . width = ( int ) len ; <nl> - func ( src1 . ptr ( ) , src1 . step , src2 . ptr ( ) , src2 . step , dst . ptr ( ) , dst . step , sz , 0 ) ; <nl> - return ; <nl> - } <nl> + Size sz = getContinuousSize ( src1 , src2 , dst , src1 . channels ( ) ) ; <nl> + tab [ depth1 ] ( src1 . ptr ( ) , src1 . step , src2 . ptr ( ) , src2 . step , dst . ptr ( ) , dst . step , sz . width , sz . height , usrdata ) ; <nl> + return ; <nl> } <nl> <nl> - if ( oclop = = OCL_OP_NOT ) <nl> - haveScalar = true ; <nl> - else if ( ( kind1 = = _InputArray : : MATX ) + ( kind2 = = _InputArray : : MATX ) = = 1 | | <nl> - ! psrc1 - > sameSize ( * psrc2 ) | | type1 ! = type2 ) <nl> + bool haveScalar = false , swapped12 = false ; <nl> + <nl> + if ( dims1 ! = dims2 | | sz1 ! = sz2 | | cn ! = cn2 | | <nl> + ( kind1 = = _InputArray : : MATX & & ( sz1 = = Size ( 1 , 4 ) | | sz1 = = Size ( 1 , 1 ) ) ) | | <nl> + ( kind2 = = _InputArray : : MATX & & ( sz2 = = Size ( 1 , 4 ) | | sz2 = = Size ( 1 , 1 ) ) ) ) <nl> { <nl> if ( checkScalar ( * psrc1 , type2 , kind1 , kind2 ) ) <nl> { <nl> / / src1 is a scalar ; swap it with src2 <nl> swap ( psrc1 , psrc2 ) ; <nl> + swap ( sz1 , sz2 ) ; <nl> swap ( type1 , type2 ) ; <nl> swap ( depth1 , depth2 ) ; <nl> swap ( cn , cn2 ) ; <nl> - swap ( sz1 , sz2 ) ; <nl> + swap ( dims1 , dims2 ) ; <nl> + swapped12 = true ; <nl> + if ( oclop = = OCL_OP_SUB ) <nl> + oclop = OCL_OP_RSUB ; <nl> + if ( oclop = = OCL_OP_DIV_SCALE ) <nl> + oclop = OCL_OP_RDIV_SCALE ; <nl> } <nl> else if ( ! checkScalar ( * psrc2 , type1 , kind2 , kind1 ) ) <nl> CV_Error ( CV_StsUnmatchedSizes , <nl> - " The operation is neither ' array op array ' ( where arrays have the same size and type ) , " <nl> - " nor ' array op scalar ' , nor ' scalar op array ' " ) ; <nl> + " The operation is neither ' array op array ' " <nl> + " ( where arrays have the same size and the same number of channels ) , " <nl> + " nor ' array op scalar ' , nor ' scalar op array ' " ) ; <nl> haveScalar = true ; <nl> + CV_Assert ( type2 = = CV_64F & & ( sz2 . height = = 1 | | sz2 . height = = 4 ) ) ; <nl> + <nl> + if ( ! muldiv ) <nl> + { <nl> + Mat sc = psrc2 - > getMat ( ) ; <nl> + depth2 = actualScalarDepth ( sc . ptr < double > ( ) , cn ) ; <nl> + if ( depth2 = = CV_64F & & ( depth1 < CV_32S | | depth1 = = CV_32F ) ) <nl> + depth2 = CV_32F ; <nl> + } <nl> + else <nl> + depth2 = CV_64F ; <nl> + } <nl> + <nl> + if ( dtype < 0 ) <nl> + { <nl> + if ( _dst . fixedType ( ) ) <nl> + dtype = _dst . type ( ) ; <nl> + else <nl> + { <nl> + if ( ! haveScalar & & type1 ! = type2 ) <nl> + CV_Error ( CV_StsBadArg , <nl> + " When the input arrays in add / subtract / multiply / divide functions have different types , " <nl> + " the output array type must be explicitly specified " ) ; <nl> + dtype = type1 ; <nl> + } <nl> + } <nl> + dtype = CV_MAT_DEPTH ( dtype ) ; <nl> + <nl> + if ( depth1 = = depth2 & & dtype = = depth1 ) <nl> + wtype = dtype ; <nl> + else if ( ! muldiv ) <nl> + { <nl> + wtype = depth1 < = CV_8S & & depth2 < = CV_8S ? CV_16S : <nl> + depth1 < = CV_32S & & depth2 < = CV_32S ? CV_32S : std : : max ( depth1 , depth2 ) ; <nl> + wtype = std : : max ( wtype , dtype ) ; <nl> + <nl> + / / when the result of addition should be converted to an integer type , <nl> + / / and just one of the input arrays is floating - point , it makes sense to convert that input to integer type before the operation , <nl> + / / instead of converting the other input to floating - point and then converting the operation result back to integers . <nl> + if ( dtype < CV_32F & & ( depth1 < CV_32F | | depth2 < CV_32F ) ) <nl> + wtype = CV_32S ; <nl> } <nl> else <nl> { <nl> - CV_Assert ( psrc1 - > sameSize ( * psrc2 ) & & type1 = = type2 ) ; <nl> + wtype = std : : max ( depth1 , std : : max ( depth2 , CV_32F ) ) ; <nl> + wtype = std : : max ( wtype , dtype ) ; <nl> } <nl> <nl> - size_t esz = CV_ELEM_SIZE ( type1 ) ; <nl> - size_t blocksize0 = ( BLOCK_SIZE + esz - 1 ) / esz ; <nl> - BinaryFunc copymask = 0 ; <nl> - bool reallocate = false ; <nl> + dtype = CV_MAKETYPE ( dtype , cn ) ; <nl> + wtype = CV_MAKETYPE ( wtype , cn ) ; <nl> <nl> if ( haveMask ) <nl> { <nl> int mtype = _mask . type ( ) ; <nl> - CV_Assert ( ( mtype = = CV_8U | | mtype = = CV_8S ) & & _mask . sameSize ( * psrc1 ) ) ; <nl> - copymask = getCopyMaskFunc ( esz ) ; <nl> - reallocate = ! _dst . sameSize ( * psrc1 ) | | _dst . type ( ) ! = type1 ; <nl> + CV_Assert ( ( mtype = = CV_8UC1 | | mtype = = CV_8SC1 ) & & _mask . sameSize ( * psrc1 ) ) ; <nl> + reallocate = ! _dst . sameSize ( * psrc1 ) | | _dst . type ( ) ! = dtype ; <nl> } <nl> <nl> - AutoBuffer < uchar > _buf ; <nl> - uchar * scbuf = 0 , * maskbuf = 0 ; <nl> - <nl> - _dst . createSameSize ( * psrc1 , type1 ) ; <nl> - / / if this is mask operation and dst has been reallocated , <nl> - / / we have to clear the destination <nl> - if ( haveMask & & reallocate ) <nl> + _dst . createSameSize ( * psrc1 , dtype ) ; <nl> + if ( reallocate ) <nl> _dst . setTo ( 0 . ) ; <nl> <nl> CV_OCL_RUN ( use_opencl , <nl> - ocl_binary_op ( * psrc1 , * psrc2 , _dst , _mask , bitwise , oclop , haveScalar ) ) <nl> + ocl_arithm_op ( * psrc1 , * psrc2 , _dst , _mask , wtype , <nl> + usrdata , oclop , haveScalar ) ) <nl> <nl> + BinaryFunc cvtsrc1 = type1 = = wtype ? 0 : getConvertFunc ( type1 , wtype ) ; <nl> + BinaryFunc cvtsrc2 = type2 = = type1 ? cvtsrc1 : type2 = = wtype ? 0 : getConvertFunc ( type2 , wtype ) ; <nl> + BinaryFunc cvtdst = dtype = = wtype ? 0 : getConvertFunc ( wtype , dtype ) ; <nl> <nl> - Mat src1 = psrc1 - > getMat ( ) , src2 = psrc2 - > getMat ( ) ; <nl> - Mat dst = _dst . getMat ( ) , mask = _mask . getMat ( ) ; <nl> + size_t esz1 = CV_ELEM_SIZE ( type1 ) , esz2 = CV_ELEM_SIZE ( type2 ) ; <nl> + size_t dsz = CV_ELEM_SIZE ( dtype ) , wsz = CV_ELEM_SIZE ( wtype ) ; <nl> + size_t blocksize0 = ( size_t ) ( BLOCK_SIZE + wsz - 1 ) / wsz ; <nl> + BinaryFunc copymask = getCopyMaskFunc ( dsz ) ; <nl> + Mat src1 = psrc1 - > getMat ( ) , src2 = psrc2 - > getMat ( ) , dst = _dst . getMat ( ) , mask = _mask . getMat ( ) ; <nl> <nl> - if ( bitwise ) <nl> - { <nl> - func = * tab ; <nl> - cn = ( int ) esz ; <nl> - } <nl> - else <nl> - func = tab [ depth1 ] ; <nl> + AutoBuffer < uchar > _buf ; <nl> + uchar * buf , * maskbuf = 0 , * buf1 = 0 , * buf2 = 0 , * wbuf = 0 ; <nl> + size_t bufesz = ( cvtsrc1 ? wsz : 0 ) + <nl> + ( cvtsrc2 | | haveScalar ? wsz : 0 ) + <nl> + ( cvtdst ? wsz : 0 ) + <nl> + ( haveMask ? dsz : 0 ) ; <nl> + BinaryFuncC func = tab [ CV_MAT_DEPTH ( wtype ) ] ; <nl> <nl> if ( ! haveScalar ) <nl> { <nl> static void binary_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> NAryMatIterator it ( arrays , ptrs ) ; <nl> size_t total = it . size , blocksize = total ; <nl> <nl> - if ( blocksize * cn > INT_MAX ) <nl> - blocksize = INT_MAX / cn ; <nl> + if ( haveMask | | cvtsrc1 | | cvtsrc2 | | cvtdst ) <nl> + blocksize = std : : min ( blocksize , blocksize0 ) ; <nl> <nl> + _buf . allocate ( bufesz * blocksize + 64 ) ; <nl> + buf = _buf ; <nl> + if ( cvtsrc1 ) <nl> + buf1 = buf , buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> + if ( cvtsrc2 ) <nl> + buf2 = buf , buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> + wbuf = maskbuf = buf ; <nl> + if ( cvtdst ) <nl> + buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> if ( haveMask ) <nl> - { <nl> - blocksize = std : : min ( blocksize , blocksize0 ) ; <nl> - _buf . allocate ( blocksize * esz ) ; <nl> - maskbuf = _buf ; <nl> - } <nl> + maskbuf = buf ; <nl> <nl> for ( size_t i = 0 ; i < it . nplanes ; i + + , + + it ) <nl> { <nl> for ( size_t j = 0 ; j < total ; j + = blocksize ) <nl> { <nl> int bsz = ( int ) MIN ( total - j , blocksize ) ; <nl> - <nl> - func ( ptrs [ 0 ] , 0 , ptrs [ 1 ] , 0 , haveMask ? maskbuf : ptrs [ 2 ] , 0 , Size ( bsz * cn , 1 ) , 0 ) ; <nl> - if ( haveMask ) <nl> + Size bszn ( bsz * cn , 1 ) ; <nl> + const uchar * sptr1 = ptrs [ 0 ] , * sptr2 = ptrs [ 1 ] ; <nl> + uchar * dptr = ptrs [ 2 ] ; <nl> + if ( cvtsrc1 ) <nl> { <nl> - copymask ( maskbuf , 0 , ptrs [ 3 ] , 0 , ptrs [ 2 ] , 0 , Size ( bsz , 1 ) , & esz ) ; <nl> - ptrs [ 3 ] + = bsz ; <nl> + cvtsrc1 ( sptr1 , 1 , 0 , 1 , buf1 , 1 , bszn , 0 ) ; <nl> + sptr1 = buf1 ; <nl> + } <nl> + if ( ptrs [ 0 ] = = ptrs [ 1 ] ) <nl> + sptr2 = sptr1 ; <nl> + else if ( cvtsrc2 ) <nl> + { <nl> + cvtsrc2 ( sptr2 , 1 , 0 , 1 , buf2 , 1 , bszn , 0 ) ; <nl> + sptr2 = buf2 ; <nl> } <nl> <nl> - bsz * = ( int ) esz ; <nl> - ptrs [ 0 ] + = bsz ; ptrs [ 1 ] + = bsz ; ptrs [ 2 ] + = bsz ; <nl> + if ( ! haveMask & & ! cvtdst ) <nl> + func ( sptr1 , 1 , sptr2 , 1 , dptr , 1 , bszn . width , bszn . height , usrdata ) ; <nl> + else <nl> + { <nl> + func ( sptr1 , 1 , sptr2 , 1 , wbuf , 0 , bszn . width , bszn . height , usrdata ) ; <nl> + if ( ! haveMask ) <nl> + cvtdst ( wbuf , 1 , 0 , 1 , dptr , 1 , bszn , 0 ) ; <nl> + else if ( ! cvtdst ) <nl> + { <nl> + copymask ( wbuf , 1 , ptrs [ 3 ] , 1 , dptr , 1 , Size ( bsz , 1 ) , & dsz ) ; <nl> + ptrs [ 3 ] + = bsz ; <nl> + } <nl> + else <nl> + { <nl> + cvtdst ( wbuf , 1 , 0 , 1 , maskbuf , 1 , bszn , 0 ) ; <nl> + copymask ( maskbuf , 1 , ptrs [ 3 ] , 1 , dptr , 1 , Size ( bsz , 1 ) , & dsz ) ; <nl> + ptrs [ 3 ] + = bsz ; <nl> + } <nl> + } <nl> + ptrs [ 0 ] + = bsz * esz1 ; ptrs [ 1 ] + = bsz * esz2 ; ptrs [ 2 ] + = bsz * dsz ; <nl> } <nl> } <nl> } <nl> static void binary_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> NAryMatIterator it ( arrays , ptrs ) ; <nl> size_t total = it . size , blocksize = std : : min ( total , blocksize0 ) ; <nl> <nl> - _buf . allocate ( blocksize * ( haveMask ? 2 : 1 ) * esz + 32 ) ; <nl> - scbuf = _buf ; <nl> - maskbuf = alignPtr ( scbuf + blocksize * esz , 16 ) ; <nl> - <nl> - convertAndUnrollScalar ( src2 , src1 . type ( ) , scbuf , blocksize ) ; <nl> - <nl> - for ( size_t i = 0 ; i < it . nplanes ; i + + , + + it ) <nl> - { <nl> - for ( size_t j = 0 ; j < total ; j + = blocksize ) <nl> - { <nl> - int bsz = ( int ) MIN ( total - j , blocksize ) ; <nl> - <nl> - func ( ptrs [ 0 ] , 0 , scbuf , 0 , haveMask ? maskbuf : ptrs [ 1 ] , 0 , Size ( bsz * cn , 1 ) , 0 ) ; <nl> - if ( haveMask ) <nl> - { <nl> - copymask ( maskbuf , 0 , ptrs [ 2 ] , 0 , ptrs [ 1 ] , 0 , Size ( bsz , 1 ) , & esz ) ; <nl> - ptrs [ 2 ] + = bsz ; <nl> - } <nl> - <nl> - bsz * = ( int ) esz ; <nl> - ptrs [ 0 ] + = bsz ; ptrs [ 1 ] + = bsz ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - static BinaryFunc * getMaxTab ( ) <nl> - { <nl> - static BinaryFunc maxTab [ ] = <nl> - { <nl> - ( BinaryFunc ) GET_OPTIMIZED ( max8u ) , ( BinaryFunc ) GET_OPTIMIZED ( max8s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( max16u ) , ( BinaryFunc ) GET_OPTIMIZED ( max16s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( max32s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( max32f ) , ( BinaryFunc ) max64f , <nl> - 0 <nl> - } ; <nl> - <nl> - return maxTab ; <nl> - } <nl> - <nl> - static BinaryFunc * getMinTab ( ) <nl> - { <nl> - static BinaryFunc minTab [ ] = <nl> - { <nl> - ( BinaryFunc ) GET_OPTIMIZED ( min8u ) , ( BinaryFunc ) GET_OPTIMIZED ( min8s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( min16u ) , ( BinaryFunc ) GET_OPTIMIZED ( min16s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( min32s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( min32f ) , ( BinaryFunc ) min64f , <nl> - 0 <nl> - } ; <nl> - <nl> - return minTab ; <nl> - } <nl> - <nl> - } <nl> - <nl> - void cv : : bitwise_and ( InputArray a , InputArray b , OutputArray c , InputArray mask ) <nl> - { <nl> - BinaryFunc f = ( BinaryFunc ) GET_OPTIMIZED ( and8u ) ; <nl> - binary_op ( a , b , c , mask , & f , true , OCL_OP_AND ) ; <nl> - } <nl> - <nl> - void cv : : bitwise_or ( InputArray a , InputArray b , OutputArray c , InputArray mask ) <nl> - { <nl> - BinaryFunc f = ( BinaryFunc ) GET_OPTIMIZED ( or8u ) ; <nl> - binary_op ( a , b , c , mask , & f , true , OCL_OP_OR ) ; <nl> - } <nl> - <nl> - void cv : : bitwise_xor ( InputArray a , InputArray b , OutputArray c , InputArray mask ) <nl> - { <nl> - BinaryFunc f = ( BinaryFunc ) GET_OPTIMIZED ( xor8u ) ; <nl> - binary_op ( a , b , c , mask , & f , true , OCL_OP_XOR ) ; <nl> - } <nl> - <nl> - void cv : : bitwise_not ( InputArray a , OutputArray c , InputArray mask ) <nl> - { <nl> - BinaryFunc f = ( BinaryFunc ) GET_OPTIMIZED ( not8u ) ; <nl> - binary_op ( a , a , c , mask , & f , true , OCL_OP_NOT ) ; <nl> - } <nl> - <nl> - void cv : : max ( InputArray src1 , InputArray src2 , OutputArray dst ) <nl> - { <nl> - binary_op ( src1 , src2 , dst , noArray ( ) , getMaxTab ( ) , false , OCL_OP_MAX ) ; <nl> - } <nl> - <nl> - void cv : : min ( InputArray src1 , InputArray src2 , OutputArray dst ) <nl> - { <nl> - binary_op ( src1 , src2 , dst , noArray ( ) , getMinTab ( ) , false , OCL_OP_MIN ) ; <nl> - } <nl> - <nl> - void cv : : max ( const Mat & src1 , const Mat & src2 , Mat & dst ) <nl> - { <nl> - OutputArray _dst ( dst ) ; <nl> - binary_op ( src1 , src2 , _dst , noArray ( ) , getMaxTab ( ) , false , OCL_OP_MAX ) ; <nl> - } <nl> - <nl> - void cv : : min ( const Mat & src1 , const Mat & src2 , Mat & dst ) <nl> - { <nl> - OutputArray _dst ( dst ) ; <nl> - binary_op ( src1 , src2 , _dst , noArray ( ) , getMinTab ( ) , false , OCL_OP_MIN ) ; <nl> - } <nl> - <nl> - void cv : : max ( const UMat & src1 , const UMat & src2 , UMat & dst ) <nl> - { <nl> - OutputArray _dst ( dst ) ; <nl> - binary_op ( src1 , src2 , _dst , noArray ( ) , getMaxTab ( ) , false , OCL_OP_MAX ) ; <nl> - } <nl> - <nl> - void cv : : min ( const UMat & src1 , const UMat & src2 , UMat & dst ) <nl> - { <nl> - OutputArray _dst ( dst ) ; <nl> - binary_op ( src1 , src2 , _dst , noArray ( ) , getMinTab ( ) , false , OCL_OP_MIN ) ; <nl> - } <nl> - <nl> - <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> - * add / subtract * <nl> - \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - namespace cv <nl> - { <nl> - <nl> - static int actualScalarDepth ( const double * data , int len ) <nl> - { <nl> - int i = 0 , minval = INT_MAX , maxval = INT_MIN ; <nl> - for ( ; i < len ; + + i ) <nl> - { <nl> - int ival = cvRound ( data [ i ] ) ; <nl> - if ( ival ! = data [ i ] ) <nl> - break ; <nl> - minval = MIN ( minval , ival ) ; <nl> - maxval = MAX ( maxval , ival ) ; <nl> - } <nl> - return i < len ? CV_64F : <nl> - minval > = 0 & & maxval < = ( int ) UCHAR_MAX ? CV_8U : <nl> - minval > = ( int ) SCHAR_MIN & & maxval < = ( int ) SCHAR_MAX ? CV_8S : <nl> - minval > = 0 & & maxval < = ( int ) USHRT_MAX ? CV_16U : <nl> - minval > = ( int ) SHRT_MIN & & maxval < = ( int ) SHRT_MAX ? CV_16S : <nl> - CV_32S ; <nl> - } <nl> - <nl> - # ifdef HAVE_OPENCL <nl> - <nl> - static bool ocl_arithm_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> - InputArray _mask , int wtype , <nl> - void * usrdata , int oclop , <nl> - bool haveScalar ) <nl> - { <nl> - const ocl : : Device d = ocl : : Device : : getDefault ( ) ; <nl> - bool doubleSupport = d . doubleFPConfig ( ) > 0 ; <nl> - int type1 = _src1 . type ( ) , depth1 = CV_MAT_DEPTH ( type1 ) , cn = CV_MAT_CN ( type1 ) ; <nl> - bool haveMask = ! _mask . empty ( ) ; <nl> - <nl> - if ( ( haveMask | | haveScalar ) & & cn > 4 ) <nl> - return false ; <nl> - <nl> - int dtype = _dst . type ( ) , ddepth = CV_MAT_DEPTH ( dtype ) , wdepth = std : : max ( CV_32S , CV_MAT_DEPTH ( wtype ) ) ; <nl> - if ( ! doubleSupport ) <nl> - wdepth = std : : min ( wdepth , CV_32F ) ; <nl> - <nl> - wtype = CV_MAKETYPE ( wdepth , cn ) ; <nl> - int type2 = haveScalar ? wtype : _src2 . type ( ) , depth2 = CV_MAT_DEPTH ( type2 ) ; <nl> - if ( ! doubleSupport & & ( depth2 = = CV_64F | | depth1 = = CV_64F ) ) <nl> - return false ; <nl> - <nl> - int kercn = haveMask | | haveScalar ? cn : ocl : : predictOptimalVectorWidth ( _src1 , _src2 , _dst ) ; <nl> - int scalarcn = kercn = = 3 ? 4 : kercn , rowsPerWI = d . isIntel ( ) ? 4 : 1 ; <nl> - <nl> - char cvtstr [ 4 ] [ 32 ] , opts [ 1024 ] ; <nl> - sprintf ( opts , " - D % s % s - D % s - D srcT1 = % s - D srcT1_C1 = % s - D srcT2 = % s - D srcT2_C1 = % s " <nl> - " - D dstT = % s - D dstT_C1 = % s - D workT = % s - D workST = % s - D scaleT = % s - D wdepth = % d - D convertToWT1 = % s " <nl> - " - D convertToWT2 = % s - D convertToDT = % s % s - D cn = % d - D rowsPerWI = % d - D convertFromU = % s " , <nl> - ( haveMask ? " MASK_ " : " " ) , ( haveScalar ? " UNARY_OP " : " BINARY_OP " ) , <nl> - oclop2str [ oclop ] , ocl : : typeToStr ( CV_MAKETYPE ( depth1 , kercn ) ) , <nl> - ocl : : typeToStr ( depth1 ) , ocl : : typeToStr ( CV_MAKETYPE ( depth2 , kercn ) ) , <nl> - ocl : : typeToStr ( depth2 ) , ocl : : typeToStr ( CV_MAKETYPE ( ddepth , kercn ) ) , <nl> - ocl : : typeToStr ( ddepth ) , ocl : : typeToStr ( CV_MAKETYPE ( wdepth , kercn ) ) , <nl> - ocl : : typeToStr ( CV_MAKETYPE ( wdepth , scalarcn ) ) , <nl> - ocl : : typeToStr ( wdepth ) , wdepth , <nl> - ocl : : convertTypeStr ( depth1 , wdepth , kercn , cvtstr [ 0 ] ) , <nl> - ocl : : convertTypeStr ( depth2 , wdepth , kercn , cvtstr [ 1 ] ) , <nl> - ocl : : convertTypeStr ( wdepth , ddepth , kercn , cvtstr [ 2 ] ) , <nl> - doubleSupport ? " - D DOUBLE_SUPPORT " : " " , kercn , rowsPerWI , <nl> - oclop = = OCL_OP_ABSDIFF & & wdepth = = CV_32S & & ddepth = = wdepth ? <nl> - ocl : : convertTypeStr ( CV_8U , ddepth , kercn , cvtstr [ 3 ] ) : " noconvert " ) ; <nl> - <nl> - size_t usrdata_esz = CV_ELEM_SIZE ( wdepth ) ; <nl> - const uchar * usrdata_p = ( const uchar * ) usrdata ; <nl> - const double * usrdata_d = ( const double * ) usrdata ; <nl> - float usrdata_f [ 3 ] ; <nl> - int i , n = oclop = = OCL_OP_MUL_SCALE | | oclop = = OCL_OP_DIV_SCALE | | <nl> - oclop = = OCL_OP_RDIV_SCALE | | oclop = = OCL_OP_RECIP_SCALE ? 1 : oclop = = OCL_OP_ADDW ? 3 : 0 ; <nl> - if ( n > 0 & & wdepth = = CV_32F ) <nl> - { <nl> - for ( i = 0 ; i < n ; i + + ) <nl> - usrdata_f [ i ] = ( float ) usrdata_d [ i ] ; <nl> - usrdata_p = ( const uchar * ) usrdata_f ; <nl> - } <nl> - <nl> - ocl : : Kernel k ( " KF " , ocl : : core : : arithm_oclsrc , opts ) ; <nl> - if ( k . empty ( ) ) <nl> - return false ; <nl> - <nl> - UMat src1 = _src1 . getUMat ( ) , src2 ; <nl> - UMat dst = _dst . getUMat ( ) , mask = _mask . getUMat ( ) ; <nl> - <nl> - ocl : : KernelArg src1arg = ocl : : KernelArg : : ReadOnlyNoSize ( src1 , cn , kercn ) ; <nl> - ocl : : KernelArg dstarg = haveMask ? ocl : : KernelArg : : ReadWrite ( dst , cn , kercn ) : <nl> - ocl : : KernelArg : : WriteOnly ( dst , cn , kercn ) ; <nl> - ocl : : KernelArg maskarg = ocl : : KernelArg : : ReadOnlyNoSize ( mask , 1 ) ; <nl> - <nl> - if ( haveScalar ) <nl> - { <nl> - size_t esz = CV_ELEM_SIZE1 ( wtype ) * scalarcn ; <nl> - double buf [ 4 ] = { 0 , 0 , 0 , 0 } ; <nl> - Mat src2sc = _src2 . getMat ( ) ; <nl> - <nl> - if ( ! src2sc . empty ( ) ) <nl> - convertAndUnrollScalar ( src2sc , wtype , ( uchar * ) buf , 1 ) ; <nl> - ocl : : KernelArg scalararg = ocl : : KernelArg ( 0 , 0 , 0 , 0 , buf , esz ) ; <nl> - <nl> - if ( ! haveMask ) <nl> - { <nl> - if ( n = = 0 ) <nl> - k . args ( src1arg , dstarg , scalararg ) ; <nl> - else if ( n = = 1 ) <nl> - k . args ( src1arg , dstarg , scalararg , <nl> - ocl : : KernelArg ( 0 , 0 , 0 , 0 , usrdata_p , usrdata_esz ) ) ; <nl> - else <nl> - CV_Error ( Error : : StsNotImplemented , " unsupported number of extra parameters " ) ; <nl> - } <nl> - else <nl> - k . args ( src1arg , maskarg , dstarg , scalararg ) ; <nl> - } <nl> - else <nl> - { <nl> - src2 = _src2 . getUMat ( ) ; <nl> - ocl : : KernelArg src2arg = ocl : : KernelArg : : ReadOnlyNoSize ( src2 , cn , kercn ) ; <nl> - <nl> - if ( ! haveMask ) <nl> - { <nl> - if ( n = = 0 ) <nl> - k . args ( src1arg , src2arg , dstarg ) ; <nl> - else if ( n = = 1 ) <nl> - k . args ( src1arg , src2arg , dstarg , <nl> - ocl : : KernelArg ( 0 , 0 , 0 , 0 , usrdata_p , usrdata_esz ) ) ; <nl> - else if ( n = = 3 ) <nl> - k . args ( src1arg , src2arg , dstarg , <nl> - ocl : : KernelArg ( 0 , 0 , 0 , 0 , usrdata_p , usrdata_esz ) , <nl> - ocl : : KernelArg ( 0 , 0 , 0 , 0 , usrdata_p + usrdata_esz , usrdata_esz ) , <nl> - ocl : : KernelArg ( 0 , 0 , 0 , 0 , usrdata_p + usrdata_esz * 2 , usrdata_esz ) ) ; <nl> - else <nl> - CV_Error ( Error : : StsNotImplemented , " unsupported number of extra parameters " ) ; <nl> - } <nl> - else <nl> - k . args ( src1arg , src2arg , maskarg , dstarg ) ; <nl> - } <nl> - <nl> - size_t globalsize [ ] = { ( size_t ) src1 . cols * cn / kercn , ( ( size_t ) src1 . rows + rowsPerWI - 1 ) / rowsPerWI } ; <nl> - return k . run ( 2 , globalsize , NULL , false ) ; <nl> - } <nl> - <nl> - # endif <nl> - <nl> - static void arithm_op ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> - InputArray _mask , int dtype , BinaryFunc * tab , bool muldiv = false , <nl> - void * usrdata = 0 , int oclop = - 1 ) <nl> - { <nl> - const _InputArray * psrc1 = & _src1 , * psrc2 = & _src2 ; <nl> - int kind1 = psrc1 - > kind ( ) , kind2 = psrc2 - > kind ( ) ; <nl> - bool haveMask = ! _mask . empty ( ) ; <nl> - bool reallocate = false ; <nl> - int type1 = psrc1 - > type ( ) , depth1 = CV_MAT_DEPTH ( type1 ) , cn = CV_MAT_CN ( type1 ) ; <nl> - int type2 = psrc2 - > type ( ) , depth2 = CV_MAT_DEPTH ( type2 ) , cn2 = CV_MAT_CN ( type2 ) ; <nl> - int wtype , dims1 = psrc1 - > dims ( ) , dims2 = psrc2 - > dims ( ) ; <nl> - Size sz1 = dims1 < = 2 ? psrc1 - > size ( ) : Size ( ) ; <nl> - Size sz2 = dims2 < = 2 ? psrc2 - > size ( ) : Size ( ) ; <nl> - # ifdef HAVE_OPENCL <nl> - bool use_opencl = OCL_PERFORMANCE_CHECK ( _dst . isUMat ( ) ) & & dims1 < = 2 & & dims2 < = 2 ; <nl> - # endif <nl> - bool src1Scalar = checkScalar ( * psrc1 , type2 , kind1 , kind2 ) ; <nl> - bool src2Scalar = checkScalar ( * psrc2 , type1 , kind2 , kind1 ) ; <nl> - <nl> - if ( ( kind1 = = kind2 | | cn = = 1 ) & & sz1 = = sz2 & & dims1 < = 2 & & dims2 < = 2 & & type1 = = type2 & & <nl> - ! haveMask & & ( ( ! _dst . fixedType ( ) & & ( dtype < 0 | | CV_MAT_DEPTH ( dtype ) = = depth1 ) ) | | <nl> - ( _dst . fixedType ( ) & & _dst . type ( ) = = type1 ) ) & & <nl> - ( ( src1Scalar & & src2Scalar ) | | ( ! src1Scalar & & ! src2Scalar ) ) ) <nl> - { <nl> - _dst . createSameSize ( * psrc1 , type1 ) ; <nl> - CV_OCL_RUN ( use_opencl , <nl> - ocl_arithm_op ( * psrc1 , * psrc2 , _dst , _mask , <nl> - ( ! usrdata ? type1 : std : : max ( depth1 , CV_32F ) ) , <nl> - usrdata , oclop , false ) ) <nl> - <nl> - Mat src1 = psrc1 - > getMat ( ) , src2 = psrc2 - > getMat ( ) , dst = _dst . getMat ( ) ; <nl> - Size sz = getContinuousSize ( src1 , src2 , dst , src1 . channels ( ) ) ; <nl> - tab [ depth1 ] ( src1 . ptr ( ) , src1 . step , src2 . ptr ( ) , src2 . step , dst . ptr ( ) , dst . step , sz , usrdata ) ; <nl> - return ; <nl> - } <nl> - <nl> - bool haveScalar = false , swapped12 = false ; <nl> - <nl> - if ( dims1 ! = dims2 | | sz1 ! = sz2 | | cn ! = cn2 | | <nl> - ( kind1 = = _InputArray : : MATX & & ( sz1 = = Size ( 1 , 4 ) | | sz1 = = Size ( 1 , 1 ) ) ) | | <nl> - ( kind2 = = _InputArray : : MATX & & ( sz2 = = Size ( 1 , 4 ) | | sz2 = = Size ( 1 , 1 ) ) ) ) <nl> - { <nl> - if ( checkScalar ( * psrc1 , type2 , kind1 , kind2 ) ) <nl> - { <nl> - / / src1 is a scalar ; swap it with src2 <nl> - swap ( psrc1 , psrc2 ) ; <nl> - swap ( sz1 , sz2 ) ; <nl> - swap ( type1 , type2 ) ; <nl> - swap ( depth1 , depth2 ) ; <nl> - swap ( cn , cn2 ) ; <nl> - swap ( dims1 , dims2 ) ; <nl> - swapped12 = true ; <nl> - if ( oclop = = OCL_OP_SUB ) <nl> - oclop = OCL_OP_RSUB ; <nl> - if ( oclop = = OCL_OP_DIV_SCALE ) <nl> - oclop = OCL_OP_RDIV_SCALE ; <nl> - } <nl> - else if ( ! checkScalar ( * psrc2 , type1 , kind2 , kind1 ) ) <nl> - CV_Error ( CV_StsUnmatchedSizes , <nl> - " The operation is neither ' array op array ' " <nl> - " ( where arrays have the same size and the same number of channels ) , " <nl> - " nor ' array op scalar ' , nor ' scalar op array ' " ) ; <nl> - haveScalar = true ; <nl> - CV_Assert ( type2 = = CV_64F & & ( sz2 . height = = 1 | | sz2 . height = = 4 ) ) ; <nl> - <nl> - if ( ! muldiv ) <nl> - { <nl> - Mat sc = psrc2 - > getMat ( ) ; <nl> - depth2 = actualScalarDepth ( sc . ptr < double > ( ) , cn ) ; <nl> - if ( depth2 = = CV_64F & & ( depth1 < CV_32S | | depth1 = = CV_32F ) ) <nl> - depth2 = CV_32F ; <nl> - } <nl> - else <nl> - depth2 = CV_64F ; <nl> - } <nl> - <nl> - if ( dtype < 0 ) <nl> - { <nl> - if ( _dst . fixedType ( ) ) <nl> - dtype = _dst . type ( ) ; <nl> - else <nl> - { <nl> - if ( ! haveScalar & & type1 ! = type2 ) <nl> - CV_Error ( CV_StsBadArg , <nl> - " When the input arrays in add / subtract / multiply / divide functions have different types , " <nl> - " the output array type must be explicitly specified " ) ; <nl> - dtype = type1 ; <nl> - } <nl> - } <nl> - dtype = CV_MAT_DEPTH ( dtype ) ; <nl> - <nl> - if ( depth1 = = depth2 & & dtype = = depth1 ) <nl> - wtype = dtype ; <nl> - else if ( ! muldiv ) <nl> - { <nl> - wtype = depth1 < = CV_8S & & depth2 < = CV_8S ? CV_16S : <nl> - depth1 < = CV_32S & & depth2 < = CV_32S ? CV_32S : std : : max ( depth1 , depth2 ) ; <nl> - wtype = std : : max ( wtype , dtype ) ; <nl> - <nl> - / / when the result of addition should be converted to an integer type , <nl> - / / and just one of the input arrays is floating - point , it makes sense to convert that input to integer type before the operation , <nl> - / / instead of converting the other input to floating - point and then converting the operation result back to integers . <nl> - if ( dtype < CV_32F & & ( depth1 < CV_32F | | depth2 < CV_32F ) ) <nl> - wtype = CV_32S ; <nl> - } <nl> - else <nl> - { <nl> - wtype = std : : max ( depth1 , std : : max ( depth2 , CV_32F ) ) ; <nl> - wtype = std : : max ( wtype , dtype ) ; <nl> - } <nl> - <nl> - dtype = CV_MAKETYPE ( dtype , cn ) ; <nl> - wtype = CV_MAKETYPE ( wtype , cn ) ; <nl> - <nl> - if ( haveMask ) <nl> - { <nl> - int mtype = _mask . type ( ) ; <nl> - CV_Assert ( ( mtype = = CV_8UC1 | | mtype = = CV_8SC1 ) & & _mask . sameSize ( * psrc1 ) ) ; <nl> - reallocate = ! _dst . sameSize ( * psrc1 ) | | _dst . type ( ) ! = dtype ; <nl> - } <nl> - <nl> - _dst . createSameSize ( * psrc1 , dtype ) ; <nl> - if ( reallocate ) <nl> - _dst . setTo ( 0 . ) ; <nl> - <nl> - CV_OCL_RUN ( use_opencl , <nl> - ocl_arithm_op ( * psrc1 , * psrc2 , _dst , _mask , wtype , <nl> - usrdata , oclop , haveScalar ) ) <nl> - <nl> - BinaryFunc cvtsrc1 = type1 = = wtype ? 0 : getConvertFunc ( type1 , wtype ) ; <nl> - BinaryFunc cvtsrc2 = type2 = = type1 ? cvtsrc1 : type2 = = wtype ? 0 : getConvertFunc ( type2 , wtype ) ; <nl> - BinaryFunc cvtdst = dtype = = wtype ? 0 : getConvertFunc ( wtype , dtype ) ; <nl> - <nl> - size_t esz1 = CV_ELEM_SIZE ( type1 ) , esz2 = CV_ELEM_SIZE ( type2 ) ; <nl> - size_t dsz = CV_ELEM_SIZE ( dtype ) , wsz = CV_ELEM_SIZE ( wtype ) ; <nl> - size_t blocksize0 = ( size_t ) ( BLOCK_SIZE + wsz - 1 ) / wsz ; <nl> - BinaryFunc copymask = getCopyMaskFunc ( dsz ) ; <nl> - Mat src1 = psrc1 - > getMat ( ) , src2 = psrc2 - > getMat ( ) , dst = _dst . getMat ( ) , mask = _mask . getMat ( ) ; <nl> - <nl> - AutoBuffer < uchar > _buf ; <nl> - uchar * buf , * maskbuf = 0 , * buf1 = 0 , * buf2 = 0 , * wbuf = 0 ; <nl> - size_t bufesz = ( cvtsrc1 ? wsz : 0 ) + <nl> - ( cvtsrc2 | | haveScalar ? wsz : 0 ) + <nl> - ( cvtdst ? wsz : 0 ) + <nl> - ( haveMask ? dsz : 0 ) ; <nl> - BinaryFunc func = tab [ CV_MAT_DEPTH ( wtype ) ] ; <nl> - <nl> - if ( ! haveScalar ) <nl> - { <nl> - const Mat * arrays [ ] = { & src1 , & src2 , & dst , & mask , 0 } ; <nl> - uchar * ptrs [ 4 ] ; <nl> - <nl> - NAryMatIterator it ( arrays , ptrs ) ; <nl> - size_t total = it . size , blocksize = total ; <nl> - <nl> - if ( haveMask | | cvtsrc1 | | cvtsrc2 | | cvtdst ) <nl> - blocksize = std : : min ( blocksize , blocksize0 ) ; <nl> - <nl> - _buf . allocate ( bufesz * blocksize + 64 ) ; <nl> - buf = _buf ; <nl> - if ( cvtsrc1 ) <nl> - buf1 = buf , buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> - if ( cvtsrc2 ) <nl> - buf2 = buf , buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> - wbuf = maskbuf = buf ; <nl> - if ( cvtdst ) <nl> - buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> - if ( haveMask ) <nl> - maskbuf = buf ; <nl> - <nl> - for ( size_t i = 0 ; i < it . nplanes ; i + + , + + it ) <nl> - { <nl> - for ( size_t j = 0 ; j < total ; j + = blocksize ) <nl> - { <nl> - int bsz = ( int ) MIN ( total - j , blocksize ) ; <nl> - Size bszn ( bsz * cn , 1 ) ; <nl> - const uchar * sptr1 = ptrs [ 0 ] , * sptr2 = ptrs [ 1 ] ; <nl> - uchar * dptr = ptrs [ 2 ] ; <nl> - if ( cvtsrc1 ) <nl> - { <nl> - cvtsrc1 ( sptr1 , 1 , 0 , 1 , buf1 , 1 , bszn , 0 ) ; <nl> - sptr1 = buf1 ; <nl> - } <nl> - if ( ptrs [ 0 ] = = ptrs [ 1 ] ) <nl> - sptr2 = sptr1 ; <nl> - else if ( cvtsrc2 ) <nl> - { <nl> - cvtsrc2 ( sptr2 , 1 , 0 , 1 , buf2 , 1 , bszn , 0 ) ; <nl> - sptr2 = buf2 ; <nl> - } <nl> - <nl> - if ( ! haveMask & & ! cvtdst ) <nl> - func ( sptr1 , 1 , sptr2 , 1 , dptr , 1 , bszn , usrdata ) ; <nl> - else <nl> - { <nl> - func ( sptr1 , 1 , sptr2 , 1 , wbuf , 0 , bszn , usrdata ) ; <nl> - if ( ! haveMask ) <nl> - cvtdst ( wbuf , 1 , 0 , 1 , dptr , 1 , bszn , 0 ) ; <nl> - else if ( ! cvtdst ) <nl> - { <nl> - copymask ( wbuf , 1 , ptrs [ 3 ] , 1 , dptr , 1 , Size ( bsz , 1 ) , & dsz ) ; <nl> - ptrs [ 3 ] + = bsz ; <nl> - } <nl> - else <nl> - { <nl> - cvtdst ( wbuf , 1 , 0 , 1 , maskbuf , 1 , bszn , 0 ) ; <nl> - copymask ( maskbuf , 1 , ptrs [ 3 ] , 1 , dptr , 1 , Size ( bsz , 1 ) , & dsz ) ; <nl> - ptrs [ 3 ] + = bsz ; <nl> - } <nl> - } <nl> - ptrs [ 0 ] + = bsz * esz1 ; ptrs [ 1 ] + = bsz * esz2 ; ptrs [ 2 ] + = bsz * dsz ; <nl> - } <nl> - } <nl> - } <nl> - else <nl> - { <nl> - const Mat * arrays [ ] = { & src1 , & dst , & mask , 0 } ; <nl> - uchar * ptrs [ 3 ] ; <nl> - <nl> - NAryMatIterator it ( arrays , ptrs ) ; <nl> - size_t total = it . size , blocksize = std : : min ( total , blocksize0 ) ; <nl> - <nl> - _buf . allocate ( bufesz * blocksize + 64 ) ; <nl> - buf = _buf ; <nl> - if ( cvtsrc1 ) <nl> - buf1 = buf , buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> - buf2 = buf ; buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> - wbuf = maskbuf = buf ; <nl> - if ( cvtdst ) <nl> - buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> - if ( haveMask ) <nl> - maskbuf = buf ; <nl> - <nl> - convertAndUnrollScalar ( src2 , wtype , buf2 , blocksize ) ; <nl> - <nl> - for ( size_t i = 0 ; i < it . nplanes ; i + + , + + it ) <nl> - { <nl> - for ( size_t j = 0 ; j < total ; j + = blocksize ) <nl> - { <nl> - int bsz = ( int ) MIN ( total - j , blocksize ) ; <nl> - Size bszn ( bsz * cn , 1 ) ; <nl> - const uchar * sptr1 = ptrs [ 0 ] ; <nl> - const uchar * sptr2 = buf2 ; <nl> - uchar * dptr = ptrs [ 1 ] ; <nl> - <nl> - if ( cvtsrc1 ) <nl> - { <nl> - cvtsrc1 ( sptr1 , 1 , 0 , 1 , buf1 , 1 , bszn , 0 ) ; <nl> - sptr1 = buf1 ; <nl> - } <nl> - <nl> - if ( swapped12 ) <nl> - std : : swap ( sptr1 , sptr2 ) ; <nl> - <nl> - if ( ! haveMask & & ! cvtdst ) <nl> - func ( sptr1 , 1 , sptr2 , 1 , dptr , 1 , bszn , usrdata ) ; <nl> - else <nl> - { <nl> - func ( sptr1 , 1 , sptr2 , 1 , wbuf , 1 , bszn , usrdata ) ; <nl> - if ( ! haveMask ) <nl> - cvtdst ( wbuf , 1 , 0 , 1 , dptr , 1 , bszn , 0 ) ; <nl> - else if ( ! cvtdst ) <nl> - { <nl> - copymask ( wbuf , 1 , ptrs [ 2 ] , 1 , dptr , 1 , Size ( bsz , 1 ) , & dsz ) ; <nl> - ptrs [ 2 ] + = bsz ; <nl> - } <nl> - else <nl> - { <nl> - cvtdst ( wbuf , 1 , 0 , 1 , maskbuf , 1 , bszn , 0 ) ; <nl> - copymask ( maskbuf , 1 , ptrs [ 2 ] , 1 , dptr , 1 , Size ( bsz , 1 ) , & dsz ) ; <nl> - ptrs [ 2 ] + = bsz ; <nl> - } <nl> - } <nl> - ptrs [ 0 ] + = bsz * esz1 ; ptrs [ 1 ] + = bsz * dsz ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - static BinaryFunc * getAddTab ( ) <nl> - { <nl> - static BinaryFunc addTab [ ] = <nl> - { <nl> - ( BinaryFunc ) GET_OPTIMIZED ( add8u ) , ( BinaryFunc ) GET_OPTIMIZED ( add8s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( add16u ) , ( BinaryFunc ) GET_OPTIMIZED ( add16s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( add32s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( add32f ) , ( BinaryFunc ) add64f , <nl> - 0 <nl> - } ; <nl> - <nl> - return addTab ; <nl> - } <nl> - <nl> - static BinaryFunc * getSubTab ( ) <nl> - { <nl> - static BinaryFunc subTab [ ] = <nl> - { <nl> - ( BinaryFunc ) GET_OPTIMIZED ( sub8u ) , ( BinaryFunc ) GET_OPTIMIZED ( sub8s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( sub16u ) , ( BinaryFunc ) GET_OPTIMIZED ( sub16s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( sub32s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( sub32f ) , ( BinaryFunc ) sub64f , <nl> - 0 <nl> - } ; <nl> - <nl> - return subTab ; <nl> - } <nl> - <nl> - static BinaryFunc * getAbsDiffTab ( ) <nl> - { <nl> - static BinaryFunc absDiffTab [ ] = <nl> - { <nl> - ( BinaryFunc ) GET_OPTIMIZED ( absdiff8u ) , ( BinaryFunc ) GET_OPTIMIZED ( absdiff8s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( absdiff16u ) , ( BinaryFunc ) GET_OPTIMIZED ( absdiff16s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( absdiff32s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( absdiff32f ) , ( BinaryFunc ) absdiff64f , <nl> - 0 <nl> - } ; <nl> - <nl> - return absDiffTab ; <nl> - } <nl> - <nl> - } <nl> - <nl> - void cv : : add ( InputArray src1 , InputArray src2 , OutputArray dst , <nl> - InputArray mask , int dtype ) <nl> - { <nl> - arithm_op ( src1 , src2 , dst , mask , dtype , getAddTab ( ) , false , 0 , OCL_OP_ADD ) ; <nl> - } <nl> - <nl> - void cv : : subtract ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> - InputArray mask , int dtype ) <nl> - { <nl> - # ifdef HAVE_TEGRA_OPTIMIZATION <nl> - if ( tegra : : useTegra ( ) ) <nl> - { <nl> - int kind1 = _src1 . kind ( ) , kind2 = _src2 . kind ( ) ; <nl> - Mat src1 = _src1 . getMat ( ) , src2 = _src2 . getMat ( ) ; <nl> - bool src1Scalar = checkScalar ( src1 , _src2 . type ( ) , kind1 , kind2 ) ; <nl> - bool src2Scalar = checkScalar ( src2 , _src1 . type ( ) , kind2 , kind1 ) ; <nl> - <nl> - if ( ! src1Scalar & & ! src2Scalar & & <nl> - src1 . depth ( ) = = CV_8U & & src2 . type ( ) = = src1 . type ( ) & & <nl> - src1 . dims = = 2 & & src2 . size ( ) = = src1 . size ( ) & & <nl> - mask . empty ( ) ) <nl> - { <nl> - if ( dtype < 0 ) <nl> - { <nl> - if ( _dst . fixedType ( ) ) <nl> - { <nl> - dtype = _dst . depth ( ) ; <nl> - } <nl> - else <nl> - { <nl> - dtype = src1 . depth ( ) ; <nl> - } <nl> - } <nl> - <nl> - dtype = CV_MAT_DEPTH ( dtype ) ; <nl> - <nl> - if ( ! _dst . fixedType ( ) | | dtype = = _dst . depth ( ) ) <nl> - { <nl> - _dst . create ( src1 . size ( ) , CV_MAKE_TYPE ( dtype , src1 . channels ( ) ) ) ; <nl> - <nl> - if ( dtype = = CV_16S ) <nl> - { <nl> - Mat dst = _dst . getMat ( ) ; <nl> - if ( tegra : : subtract_8u8u16s ( src1 , src2 , dst ) ) <nl> - return ; <nl> - } <nl> - else if ( dtype = = CV_32F ) <nl> - { <nl> - Mat dst = _dst . getMat ( ) ; <nl> - if ( tegra : : subtract_8u8u32f ( src1 , src2 , dst ) ) <nl> - return ; <nl> - } <nl> - else if ( dtype = = CV_8S ) <nl> - { <nl> - Mat dst = _dst . getMat ( ) ; <nl> - if ( tegra : : subtract_8u8u8s ( src1 , src2 , dst ) ) <nl> - return ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - # endif <nl> - arithm_op ( _src1 , _src2 , _dst , mask , dtype , getSubTab ( ) , false , 0 , OCL_OP_SUB ) ; <nl> - } <nl> - <nl> - void cv : : absdiff ( InputArray src1 , InputArray src2 , OutputArray dst ) <nl> - { <nl> - arithm_op ( src1 , src2 , dst , noArray ( ) , - 1 , getAbsDiffTab ( ) , false , 0 , OCL_OP_ABSDIFF ) ; <nl> - } <nl> - <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> - * multiply / divide * <nl> - \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - namespace cv <nl> - { <nl> - <nl> - template < typename T , typename WT > <nl> - struct Mul_SIMD <nl> - { <nl> - int operator ( ) ( const T * , const T * , T * , int , WT ) const <nl> - { <nl> - return 0 ; <nl> - } <nl> - } ; <nl> - <nl> - # if CV_NEON <nl> - <nl> - template < > <nl> - struct Mul_SIMD < uchar , float > <nl> - { <nl> - int operator ( ) ( const uchar * src1 , const uchar * src2 , uchar * dst , int width , float scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( scale = = 1 . 0f ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint16x8_t v_src1 = vmovl_u8 ( vld1_u8 ( src1 + x ) ) ; <nl> - uint16x8_t v_src2 = vmovl_u8 ( vld1_u8 ( src2 + x ) ) ; <nl> - <nl> - float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src2 ) ) ) ) ; <nl> - float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src2 ) ) ) ) ; <nl> - <nl> - uint16x8_t v_dst = vcombine_u16 ( vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst1 ) ) , <nl> - vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst2 ) ) ) ; <nl> - vst1_u8 ( dst + x , vqmovn_u16 ( v_dst ) ) ; <nl> - } <nl> - else <nl> - { <nl> - float32x4_t v_scale = vdupq_n_f32 ( scale ) ; <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint16x8_t v_src1 = vmovl_u8 ( vld1_u8 ( src1 + x ) ) ; <nl> - uint16x8_t v_src2 = vmovl_u8 ( vld1_u8 ( src2 + x ) ) ; <nl> - <nl> - float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src2 ) ) ) ) ; <nl> - v_dst1 = vmulq_f32 ( v_dst1 , v_scale ) ; <nl> - float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src2 ) ) ) ) ; <nl> - v_dst2 = vmulq_f32 ( v_dst2 , v_scale ) ; <nl> - <nl> - uint16x8_t v_dst = vcombine_u16 ( vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst1 ) ) , <nl> - vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst2 ) ) ) ; <nl> - vst1_u8 ( dst + x , vqmovn_u16 ( v_dst ) ) ; <nl> - } <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct Mul_SIMD < schar , float > <nl> - { <nl> - int operator ( ) ( const schar * src1 , const schar * src2 , schar * dst , int width , float scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( scale = = 1 . 0f ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - int16x8_t v_src1 = vmovl_s8 ( vld1_s8 ( src1 + x ) ) ; <nl> - int16x8_t v_src2 = vmovl_s8 ( vld1_s8 ( src2 + x ) ) ; <nl> - <nl> - float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src2 ) ) ) ) ; <nl> - float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src2 ) ) ) ) ; <nl> - <nl> - int16x8_t v_dst = vcombine_s16 ( vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst1 ) ) , <nl> - vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst2 ) ) ) ; <nl> - vst1_s8 ( dst + x , vqmovn_s16 ( v_dst ) ) ; <nl> - } <nl> - else <nl> - { <nl> - float32x4_t v_scale = vdupq_n_f32 ( scale ) ; <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - int16x8_t v_src1 = vmovl_s8 ( vld1_s8 ( src1 + x ) ) ; <nl> - int16x8_t v_src2 = vmovl_s8 ( vld1_s8 ( src2 + x ) ) ; <nl> - <nl> - float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src2 ) ) ) ) ; <nl> - v_dst1 = vmulq_f32 ( v_dst1 , v_scale ) ; <nl> - float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src2 ) ) ) ) ; <nl> - v_dst2 = vmulq_f32 ( v_dst2 , v_scale ) ; <nl> - <nl> - int16x8_t v_dst = vcombine_s16 ( vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst1 ) ) , <nl> - vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst2 ) ) ) ; <nl> - vst1_s8 ( dst + x , vqmovn_s16 ( v_dst ) ) ; <nl> - } <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct Mul_SIMD < ushort , float > <nl> - { <nl> - int operator ( ) ( const ushort * src1 , const ushort * src2 , ushort * dst , int width , float scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( scale = = 1 . 0f ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint16x8_t v_src1 = vld1q_u16 ( src1 + x ) , v_src2 = vld1q_u16 ( src2 + x ) ; <nl> - <nl> - float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src2 ) ) ) ) ; <nl> - float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src2 ) ) ) ) ; <nl> - <nl> - uint16x8_t v_dst = vcombine_u16 ( vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst1 ) ) , <nl> - vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst2 ) ) ) ; <nl> - vst1q_u16 ( dst + x , v_dst ) ; <nl> - } <nl> - else <nl> - { <nl> - float32x4_t v_scale = vdupq_n_f32 ( scale ) ; <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint16x8_t v_src1 = vld1q_u16 ( src1 + x ) , v_src2 = vld1q_u16 ( src2 + x ) ; <nl> - <nl> - float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src2 ) ) ) ) ; <nl> - v_dst1 = vmulq_f32 ( v_dst1 , v_scale ) ; <nl> - float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src2 ) ) ) ) ; <nl> - v_dst2 = vmulq_f32 ( v_dst2 , v_scale ) ; <nl> - <nl> - uint16x8_t v_dst = vcombine_u16 ( vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst1 ) ) , <nl> - vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst2 ) ) ) ; <nl> - vst1q_u16 ( dst + x , v_dst ) ; <nl> - } <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct Mul_SIMD < short , float > <nl> - { <nl> - int operator ( ) ( const short * src1 , const short * src2 , short * dst , int width , float scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( scale = = 1 . 0f ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - int16x8_t v_src1 = vld1q_s16 ( src1 + x ) , v_src2 = vld1q_s16 ( src2 + x ) ; <nl> - <nl> - float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src2 ) ) ) ) ; <nl> - float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src2 ) ) ) ) ; <nl> - <nl> - int16x8_t v_dst = vcombine_s16 ( vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst1 ) ) , <nl> - vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst2 ) ) ) ; <nl> - vst1q_s16 ( dst + x , v_dst ) ; <nl> - } <nl> - else <nl> - { <nl> - float32x4_t v_scale = vdupq_n_f32 ( scale ) ; <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - int16x8_t v_src1 = vld1q_s16 ( src1 + x ) , v_src2 = vld1q_s16 ( src2 + x ) ; <nl> - <nl> - float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src2 ) ) ) ) ; <nl> - v_dst1 = vmulq_f32 ( v_dst1 , v_scale ) ; <nl> - float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src1 ) ) ) , <nl> - vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src2 ) ) ) ) ; <nl> - v_dst2 = vmulq_f32 ( v_dst2 , v_scale ) ; <nl> - <nl> - int16x8_t v_dst = vcombine_s16 ( vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst1 ) ) , <nl> - vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst2 ) ) ) ; <nl> - vst1q_s16 ( dst + x , v_dst ) ; <nl> - } <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct Mul_SIMD < float , float > <nl> - { <nl> - int operator ( ) ( const float * src1 , const float * src2 , float * dst , int width , float scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( scale = = 1 . 0f ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - float32x4_t v_dst1 = vmulq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> - float32x4_t v_dst2 = vmulq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> - vst1q_f32 ( dst + x , v_dst1 ) ; <nl> - vst1q_f32 ( dst + x + 4 , v_dst2 ) ; <nl> - } <nl> - else <nl> - { <nl> - float32x4_t v_scale = vdupq_n_f32 ( scale ) ; <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - float32x4_t v_dst1 = vmulq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> - v_dst1 = vmulq_f32 ( v_dst1 , v_scale ) ; <nl> - <nl> - float32x4_t v_dst2 = vmulq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> - v_dst2 = vmulq_f32 ( v_dst2 , v_scale ) ; <nl> - <nl> - vst1q_f32 ( dst + x , v_dst1 ) ; <nl> - vst1q_f32 ( dst + x + 4 , v_dst2 ) ; <nl> - } <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - # elif CV_SSE2 <nl> - <nl> - # if CV_SSE4_1 <nl> - <nl> - template < > <nl> - struct Mul_SIMD < ushort , float > <nl> - { <nl> - Mul_SIMD ( ) <nl> - { <nl> - haveSSE = checkHardwareSupport ( CV_CPU_SSE4_1 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const ushort * src1 , const ushort * src2 , ushort * dst , int width , float scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSSE ) <nl> - return x ; <nl> - <nl> - __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> - <nl> - if ( scale ! = 1 . 0f ) <nl> - { <nl> - __m128 v_scale = _mm_set1_ps ( scale ) ; <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i v_src1 = _mm_loadu_si128 ( ( __m128i const * ) ( src1 + x ) ) ; <nl> - __m128i v_src2 = _mm_loadu_si128 ( ( __m128i const * ) ( src2 + x ) ) ; <nl> - <nl> - __m128 v_dst1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( v_src1 , v_zero ) ) , <nl> - _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( v_src2 , v_zero ) ) ) ; <nl> - v_dst1 = _mm_mul_ps ( v_dst1 , v_scale ) ; <nl> - <nl> - __m128 v_dst2 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( v_src1 , v_zero ) ) , <nl> - _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( v_src2 , v_zero ) ) ) ; <nl> - v_dst2 = _mm_mul_ps ( v_dst2 , v_scale ) ; <nl> - <nl> - __m128i v_dsti = _mm_packus_epi32 ( _mm_cvtps_epi32 ( v_dst1 ) , _mm_cvtps_epi32 ( v_dst2 ) ) ; <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , v_dsti ) ; <nl> - } <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - bool haveSSE ; <nl> - } ; <nl> - <nl> - # endif <nl> - <nl> - template < > <nl> - struct Mul_SIMD < schar , float > <nl> - { <nl> - Mul_SIMD ( ) <nl> - { <nl> - haveSSE = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const schar * src1 , const schar * src2 , schar * dst , int width , float scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSSE ) <nl> - return x ; <nl> - <nl> - __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> - <nl> - if ( scale = = 1 . 0f ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i v_src1 = _mm_loadl_epi64 ( ( __m128i const * ) ( src1 + x ) ) ; <nl> - __m128i v_src2 = _mm_loadl_epi64 ( ( __m128i const * ) ( src2 + x ) ) ; <nl> - <nl> - v_src1 = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src1 ) , 8 ) ; <nl> - v_src2 = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src2 ) , 8 ) ; <nl> - <nl> - __m128 v_dst1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> - _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> - <nl> - __m128 v_dst2 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> - _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> - <nl> - __m128i v_dsti = _mm_packs_epi32 ( _mm_cvtps_epi32 ( v_dst1 ) , _mm_cvtps_epi32 ( v_dst2 ) ) ; <nl> - _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi16 ( v_dsti , v_zero ) ) ; <nl> - } <nl> - else <nl> - { <nl> - __m128 v_scale = _mm_set1_ps ( scale ) ; <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i v_src1 = _mm_loadl_epi64 ( ( __m128i const * ) ( src1 + x ) ) ; <nl> - __m128i v_src2 = _mm_loadl_epi64 ( ( __m128i const * ) ( src2 + x ) ) ; <nl> - <nl> - v_src1 = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src1 ) , 8 ) ; <nl> - v_src2 = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src2 ) , 8 ) ; <nl> - <nl> - __m128 v_dst1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> - _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> - v_dst1 = _mm_mul_ps ( v_dst1 , v_scale ) ; <nl> - <nl> - __m128 v_dst2 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> - _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> - v_dst2 = _mm_mul_ps ( v_dst2 , v_scale ) ; <nl> - <nl> - __m128i v_dsti = _mm_packs_epi32 ( _mm_cvtps_epi32 ( v_dst1 ) , _mm_cvtps_epi32 ( v_dst2 ) ) ; <nl> - _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi16 ( v_dsti , v_zero ) ) ; <nl> - } <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - bool haveSSE ; <nl> - } ; <nl> - <nl> - template < > <nl> - struct Mul_SIMD < short , float > <nl> - { <nl> - Mul_SIMD ( ) <nl> - { <nl> - haveSSE = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const short * src1 , const short * src2 , short * dst , int width , float scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSSE ) <nl> - return x ; <nl> - <nl> - __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> - <nl> - if ( scale ! = 1 . 0f ) <nl> - { <nl> - __m128 v_scale = _mm_set1_ps ( scale ) ; <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i v_src1 = _mm_loadu_si128 ( ( __m128i const * ) ( src1 + x ) ) ; <nl> - __m128i v_src2 = _mm_loadu_si128 ( ( __m128i const * ) ( src2 + x ) ) ; <nl> - <nl> - __m128 v_dst1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> - _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> - v_dst1 = _mm_mul_ps ( v_dst1 , v_scale ) ; <nl> - <nl> - __m128 v_dst2 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> - _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> - v_dst2 = _mm_mul_ps ( v_dst2 , v_scale ) ; <nl> - <nl> - __m128i v_dsti = _mm_packs_epi32 ( _mm_cvtps_epi32 ( v_dst1 ) , _mm_cvtps_epi32 ( v_dst2 ) ) ; <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , v_dsti ) ; <nl> - } <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - bool haveSSE ; <nl> - } ; <nl> - <nl> - # endif <nl> - <nl> - template < typename T , typename WT > static void <nl> - mul_ ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> - T * dst , size_t step , Size size , WT scale ) <nl> - { <nl> - step1 / = sizeof ( src1 [ 0 ] ) ; <nl> - step2 / = sizeof ( src2 [ 0 ] ) ; <nl> - step / = sizeof ( dst [ 0 ] ) ; <nl> - <nl> - Mul_SIMD < T , WT > vop ; <nl> - <nl> - if ( scale = = ( WT ) 1 . ) <nl> - { <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int i = vop ( src1 , src2 , dst , size . width , scale ) ; <nl> - # if CV_ENABLE_UNROLLED <nl> - for ( ; i < = size . width - 4 ; i + = 4 ) <nl> - { <nl> - T t0 ; <nl> - T t1 ; <nl> - t0 = saturate_cast < T > ( src1 [ i ] * src2 [ i ] ) ; <nl> - t1 = saturate_cast < T > ( src1 [ i + 1 ] * src2 [ i + 1 ] ) ; <nl> - dst [ i ] = t0 ; <nl> - dst [ i + 1 ] = t1 ; <nl> - <nl> - t0 = saturate_cast < T > ( src1 [ i + 2 ] * src2 [ i + 2 ] ) ; <nl> - t1 = saturate_cast < T > ( src1 [ i + 3 ] * src2 [ i + 3 ] ) ; <nl> - dst [ i + 2 ] = t0 ; <nl> - dst [ i + 3 ] = t1 ; <nl> - } <nl> - # endif <nl> - for ( ; i < size . width ; i + + ) <nl> - dst [ i ] = saturate_cast < T > ( src1 [ i ] * src2 [ i ] ) ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int i = vop ( src1 , src2 , dst , size . width , scale ) ; <nl> - # if CV_ENABLE_UNROLLED <nl> - for ( ; i < = size . width - 4 ; i + = 4 ) <nl> - { <nl> - T t0 = saturate_cast < T > ( scale * ( WT ) src1 [ i ] * src2 [ i ] ) ; <nl> - T t1 = saturate_cast < T > ( scale * ( WT ) src1 [ i + 1 ] * src2 [ i + 1 ] ) ; <nl> - dst [ i ] = t0 ; dst [ i + 1 ] = t1 ; <nl> - <nl> - t0 = saturate_cast < T > ( scale * ( WT ) src1 [ i + 2 ] * src2 [ i + 2 ] ) ; <nl> - t1 = saturate_cast < T > ( scale * ( WT ) src1 [ i + 3 ] * src2 [ i + 3 ] ) ; <nl> - dst [ i + 2 ] = t0 ; dst [ i + 3 ] = t1 ; <nl> - } <nl> - # endif <nl> - for ( ; i < size . width ; i + + ) <nl> - dst [ i ] = saturate_cast < T > ( scale * ( WT ) src1 [ i ] * src2 [ i ] ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - template < typename T > <nl> - struct Div_SIMD <nl> - { <nl> - int operator ( ) ( const T * , const T * , T * , int , double ) const <nl> - { <nl> - return 0 ; <nl> - } <nl> - } ; <nl> - <nl> - template < typename T > <nl> - struct Recip_SIMD <nl> - { <nl> - int operator ( ) ( const T * , T * , int , double ) const <nl> - { <nl> - return 0 ; <nl> - } <nl> - } ; <nl> - <nl> - <nl> - # if CV_SIMD128 <nl> - <nl> - template < > <nl> - struct Div_SIMD < uchar > <nl> - { <nl> - bool haveSIMD ; <nl> - Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const uchar * src1 , const uchar * src2 , uchar * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_uint16x8 v_zero = v_setzero_u16 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_uint16x8 v_src1 = v_load_expand ( src1 + x ) ; <nl> - v_uint16x8 v_src2 = v_load_expand ( src2 + x ) ; <nl> - <nl> - v_uint32x4 t0 , t1 , t2 , t3 ; <nl> - v_expand ( v_src1 , t0 , t1 ) ; <nl> - v_expand ( v_src2 , t2 , t3 ) ; <nl> - <nl> - v_float32x4 f0 = v_cvt_f32 ( v_reinterpret_as_s32 ( t0 ) ) ; <nl> - v_float32x4 f1 = v_cvt_f32 ( v_reinterpret_as_s32 ( t1 ) ) ; <nl> - <nl> - v_float32x4 f2 = v_cvt_f32 ( v_reinterpret_as_s32 ( t2 ) ) ; <nl> - v_float32x4 f3 = v_cvt_f32 ( v_reinterpret_as_s32 ( t3 ) ) ; <nl> - <nl> - f0 = f0 * v_scale / f2 ; <nl> - f1 = f1 * v_scale / f3 ; <nl> - <nl> - v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> - v_uint16x8 res = v_pack_u ( i0 , i1 ) ; <nl> - <nl> - res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> - v_pack_store ( dst + x , res ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - <nl> - template < > <nl> - struct Div_SIMD < schar > <nl> - { <nl> - bool haveSIMD ; <nl> - Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const schar * src1 , const schar * src2 , schar * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_int16x8 v_zero = v_setzero_s16 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_int16x8 v_src1 = v_load_expand ( src1 + x ) ; <nl> - v_int16x8 v_src2 = v_load_expand ( src2 + x ) ; <nl> - <nl> - v_int32x4 t0 , t1 , t2 , t3 ; <nl> - v_expand ( v_src1 , t0 , t1 ) ; <nl> - v_expand ( v_src2 , t2 , t3 ) ; <nl> - <nl> - v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> - v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> - <nl> - v_float32x4 f2 = v_cvt_f32 ( t2 ) ; <nl> - v_float32x4 f3 = v_cvt_f32 ( t3 ) ; <nl> - <nl> - f0 = f0 * v_scale / f2 ; <nl> - f1 = f1 * v_scale / f3 ; <nl> - <nl> - v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> - v_int16x8 res = v_pack ( i0 , i1 ) ; <nl> - <nl> - res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> - v_pack_store ( dst + x , res ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - <nl> - template < > <nl> - struct Div_SIMD < ushort > <nl> - { <nl> - bool haveSIMD ; <nl> - Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const ushort * src1 , const ushort * src2 , ushort * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_uint16x8 v_zero = v_setzero_u16 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_uint16x8 v_src1 = v_load ( src1 + x ) ; <nl> - v_uint16x8 v_src2 = v_load ( src2 + x ) ; <nl> - <nl> - v_uint32x4 t0 , t1 , t2 , t3 ; <nl> - v_expand ( v_src1 , t0 , t1 ) ; <nl> - v_expand ( v_src2 , t2 , t3 ) ; <nl> - <nl> - v_float32x4 f0 = v_cvt_f32 ( v_reinterpret_as_s32 ( t0 ) ) ; <nl> - v_float32x4 f1 = v_cvt_f32 ( v_reinterpret_as_s32 ( t1 ) ) ; <nl> - <nl> - v_float32x4 f2 = v_cvt_f32 ( v_reinterpret_as_s32 ( t2 ) ) ; <nl> - v_float32x4 f3 = v_cvt_f32 ( v_reinterpret_as_s32 ( t3 ) ) ; <nl> - <nl> - f0 = f0 * v_scale / f2 ; <nl> - f1 = f1 * v_scale / f3 ; <nl> - <nl> - v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> - v_uint16x8 res = v_pack_u ( i0 , i1 ) ; <nl> - <nl> - res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> - v_store ( dst + x , res ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct Div_SIMD < short > <nl> - { <nl> - bool haveSIMD ; <nl> - Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const short * src1 , const short * src2 , short * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_int16x8 v_zero = v_setzero_s16 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_int16x8 v_src1 = v_load ( src1 + x ) ; <nl> - v_int16x8 v_src2 = v_load ( src2 + x ) ; <nl> - <nl> - v_int32x4 t0 , t1 , t2 , t3 ; <nl> - v_expand ( v_src1 , t0 , t1 ) ; <nl> - v_expand ( v_src2 , t2 , t3 ) ; <nl> - <nl> - v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> - v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> - <nl> - v_float32x4 f2 = v_cvt_f32 ( t2 ) ; <nl> - v_float32x4 f3 = v_cvt_f32 ( t3 ) ; <nl> - <nl> - f0 = f0 * v_scale / f2 ; <nl> - f1 = f1 * v_scale / f3 ; <nl> - <nl> - v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> - v_int16x8 res = v_pack ( i0 , i1 ) ; <nl> - <nl> - res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> - v_store ( dst + x , res ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct Div_SIMD < int > <nl> - { <nl> - bool haveSIMD ; <nl> - Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const int * src1 , const int * src2 , int * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_int32x4 v_zero = v_setzero_s32 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_int32x4 t0 = v_load ( src1 + x ) ; <nl> - v_int32x4 t1 = v_load ( src1 + x + 4 ) ; <nl> - v_int32x4 t2 = v_load ( src2 + x ) ; <nl> - v_int32x4 t3 = v_load ( src2 + x + 4 ) ; <nl> - <nl> - v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> - v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> - v_float32x4 f2 = v_cvt_f32 ( t2 ) ; <nl> - v_float32x4 f3 = v_cvt_f32 ( t3 ) ; <nl> - <nl> - f0 = f0 * v_scale / f2 ; <nl> - f1 = f1 * v_scale / f3 ; <nl> - <nl> - v_int32x4 res0 = v_round ( f0 ) , res1 = v_round ( f1 ) ; <nl> - <nl> - res0 = v_select ( t2 = = v_zero , v_zero , res0 ) ; <nl> - res1 = v_select ( t3 = = v_zero , v_zero , res1 ) ; <nl> - v_store ( dst + x , res0 ) ; <nl> - v_store ( dst + x + 4 , res1 ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - <nl> - template < > <nl> - struct Div_SIMD < float > <nl> - { <nl> - bool haveSIMD ; <nl> - Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const float * src1 , const float * src2 , float * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_float32x4 v_zero = v_setzero_f32 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_float32x4 f0 = v_load ( src1 + x ) ; <nl> - v_float32x4 f1 = v_load ( src1 + x + 4 ) ; <nl> - v_float32x4 f2 = v_load ( src2 + x ) ; <nl> - v_float32x4 f3 = v_load ( src2 + x + 4 ) ; <nl> - <nl> - v_float32x4 res0 = f0 * v_scale / f2 ; <nl> - v_float32x4 res1 = f1 * v_scale / f3 ; <nl> - <nl> - res0 = v_select ( f2 = = v_zero , v_zero , res0 ) ; <nl> - res1 = v_select ( f3 = = v_zero , v_zero , res1 ) ; <nl> - <nl> - v_store ( dst + x , res0 ) ; <nl> - v_store ( dst + x + 4 , res1 ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / RECIPROCAL / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - template < > <nl> - struct Recip_SIMD < uchar > <nl> - { <nl> - bool haveSIMD ; <nl> - Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const uchar * src2 , uchar * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_uint16x8 v_zero = v_setzero_u16 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_uint16x8 v_src2 = v_load_expand ( src2 + x ) ; <nl> - <nl> - v_uint32x4 t0 , t1 ; <nl> - v_expand ( v_src2 , t0 , t1 ) ; <nl> - <nl> - v_float32x4 f0 = v_cvt_f32 ( v_reinterpret_as_s32 ( t0 ) ) ; <nl> - v_float32x4 f1 = v_cvt_f32 ( v_reinterpret_as_s32 ( t1 ) ) ; <nl> - <nl> - f0 = v_scale / f0 ; <nl> - f1 = v_scale / f1 ; <nl> - <nl> - v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> - v_uint16x8 res = v_pack_u ( i0 , i1 ) ; <nl> - <nl> - res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> - v_pack_store ( dst + x , res ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - <nl> - template < > <nl> - struct Recip_SIMD < schar > <nl> - { <nl> - bool haveSIMD ; <nl> - Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const schar * src2 , schar * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_int16x8 v_zero = v_setzero_s16 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_int16x8 v_src2 = v_load_expand ( src2 + x ) ; <nl> - <nl> - v_int32x4 t0 , t1 ; <nl> - v_expand ( v_src2 , t0 , t1 ) ; <nl> - <nl> - v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> - v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> - <nl> - f0 = v_scale / f0 ; <nl> - f1 = v_scale / f1 ; <nl> - <nl> - v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> - v_int16x8 res = v_pack ( i0 , i1 ) ; <nl> - <nl> - res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> - v_pack_store ( dst + x , res ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - <nl> - template < > <nl> - struct Recip_SIMD < ushort > <nl> - { <nl> - bool haveSIMD ; <nl> - Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const ushort * src2 , ushort * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_uint16x8 v_zero = v_setzero_u16 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_uint16x8 v_src2 = v_load ( src2 + x ) ; <nl> - <nl> - v_uint32x4 t0 , t1 ; <nl> - v_expand ( v_src2 , t0 , t1 ) ; <nl> - <nl> - v_float32x4 f0 = v_cvt_f32 ( v_reinterpret_as_s32 ( t0 ) ) ; <nl> - v_float32x4 f1 = v_cvt_f32 ( v_reinterpret_as_s32 ( t1 ) ) ; <nl> - <nl> - f0 = v_scale / f0 ; <nl> - f1 = v_scale / f1 ; <nl> - <nl> - v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> - v_uint16x8 res = v_pack_u ( i0 , i1 ) ; <nl> - <nl> - res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> - v_store ( dst + x , res ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct Recip_SIMD < short > <nl> - { <nl> - bool haveSIMD ; <nl> - Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const short * src2 , short * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_int16x8 v_zero = v_setzero_s16 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_int16x8 v_src2 = v_load ( src2 + x ) ; <nl> - <nl> - v_int32x4 t0 , t1 ; <nl> - v_expand ( v_src2 , t0 , t1 ) ; <nl> - <nl> - v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> - v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> - <nl> - f0 = v_scale / f0 ; <nl> - f1 = v_scale / f1 ; <nl> - <nl> - v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> - v_int16x8 res = v_pack ( i0 , i1 ) ; <nl> - <nl> - res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> - v_store ( dst + x , res ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct Recip_SIMD < int > <nl> - { <nl> - bool haveSIMD ; <nl> - Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const int * src2 , int * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_int32x4 v_zero = v_setzero_s32 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_int32x4 t0 = v_load ( src2 + x ) ; <nl> - v_int32x4 t1 = v_load ( src2 + x + 4 ) ; <nl> - <nl> - v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> - v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> - <nl> - f0 = v_scale / f0 ; <nl> - f1 = v_scale / f1 ; <nl> - <nl> - v_int32x4 res0 = v_round ( f0 ) , res1 = v_round ( f1 ) ; <nl> - <nl> - res0 = v_select ( t0 = = v_zero , v_zero , res0 ) ; <nl> - res1 = v_select ( t1 = = v_zero , v_zero , res1 ) ; <nl> - v_store ( dst + x , res0 ) ; <nl> - v_store ( dst + x + 4 , res1 ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - <nl> - template < > <nl> - struct Recip_SIMD < float > <nl> - { <nl> - bool haveSIMD ; <nl> - Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const float * src2 , float * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> - v_float32x4 v_zero = v_setzero_f32 ( ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - v_float32x4 f0 = v_load ( src2 + x ) ; <nl> - v_float32x4 f1 = v_load ( src2 + x + 4 ) ; <nl> - <nl> - v_float32x4 res0 = v_scale / f0 ; <nl> - v_float32x4 res1 = v_scale / f1 ; <nl> - <nl> - res0 = v_select ( f0 = = v_zero , v_zero , res0 ) ; <nl> - res1 = v_select ( f1 = = v_zero , v_zero , res1 ) ; <nl> - <nl> - v_store ( dst + x , res0 ) ; <nl> - v_store ( dst + x + 4 , res1 ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - # if CV_SIMD128_64F <nl> - <nl> - template < > <nl> - struct Div_SIMD < double > <nl> - { <nl> - bool haveSIMD ; <nl> - Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const double * src1 , const double * src2 , double * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float64x2 v_scale = v_setall_f64 ( scale ) ; <nl> - v_float64x2 v_zero = v_setzero_f64 ( ) ; <nl> - <nl> - for ( ; x < = width - 4 ; x + = 4 ) <nl> - { <nl> - v_float64x2 f0 = v_load ( src1 + x ) ; <nl> - v_float64x2 f1 = v_load ( src1 + x + 2 ) ; <nl> - v_float64x2 f2 = v_load ( src2 + x ) ; <nl> - v_float64x2 f3 = v_load ( src2 + x + 2 ) ; <nl> - <nl> - v_float64x2 res0 = f0 * v_scale / f2 ; <nl> - v_float64x2 res1 = f1 * v_scale / f3 ; <nl> - <nl> - res0 = v_select ( f0 = = v_zero , v_zero , res0 ) ; <nl> - res1 = v_select ( f1 = = v_zero , v_zero , res1 ) ; <nl> - <nl> - v_store ( dst + x , res0 ) ; <nl> - v_store ( dst + x + 2 , res1 ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct Recip_SIMD < double > <nl> - { <nl> - bool haveSIMD ; <nl> - Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> - <nl> - int operator ( ) ( const double * src2 , double * dst , int width , double scale ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSIMD ) <nl> - return x ; <nl> - <nl> - v_float64x2 v_scale = v_setall_f64 ( scale ) ; <nl> - v_float64x2 v_zero = v_setzero_f64 ( ) ; <nl> - <nl> - for ( ; x < = width - 4 ; x + = 4 ) <nl> - { <nl> - v_float64x2 f0 = v_load ( src2 + x ) ; <nl> - v_float64x2 f1 = v_load ( src2 + x + 2 ) ; <nl> - <nl> - v_float64x2 res0 = v_scale / f0 ; <nl> - v_float64x2 res1 = v_scale / f1 ; <nl> - <nl> - res0 = v_select ( f0 = = v_zero , v_zero , res0 ) ; <nl> - res1 = v_select ( f1 = = v_zero , v_zero , res1 ) ; <nl> - <nl> - v_store ( dst + x , res0 ) ; <nl> - v_store ( dst + x + 2 , res1 ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - # endif <nl> - <nl> - # endif <nl> - <nl> - template < typename T > static void <nl> - div_i ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> - T * dst , size_t step , Size size , double scale ) <nl> - { <nl> - step1 / = sizeof ( src1 [ 0 ] ) ; <nl> - step2 / = sizeof ( src2 [ 0 ] ) ; <nl> - step / = sizeof ( dst [ 0 ] ) ; <nl> - <nl> - Div_SIMD < T > vop ; <nl> - float scale_f = ( float ) scale ; <nl> - <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int i = vop ( src1 , src2 , dst , size . width , scale ) ; <nl> - for ( ; i < size . width ; i + + ) <nl> - { <nl> - T num = src1 [ i ] , denom = src2 [ i ] ; <nl> - dst [ i ] = denom ! = 0 ? saturate_cast < T > ( num * scale_f / denom ) : ( T ) 0 ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - template < typename T > static void <nl> - div_f ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> - T * dst , size_t step , Size size , double scale ) <nl> - { <nl> - T scale_f = ( T ) scale ; <nl> - step1 / = sizeof ( src1 [ 0 ] ) ; <nl> - step2 / = sizeof ( src2 [ 0 ] ) ; <nl> - step / = sizeof ( dst [ 0 ] ) ; <nl> - <nl> - Div_SIMD < T > vop ; <nl> - <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int i = vop ( src1 , src2 , dst , size . width , scale ) ; <nl> - for ( ; i < size . width ; i + + ) <nl> - { <nl> - T num = src1 [ i ] , denom = src2 [ i ] ; <nl> - dst [ i ] = denom ! = 0 ? saturate_cast < T > ( num * scale_f / denom ) : ( T ) 0 ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - template < typename T > static void <nl> - recip_i ( const T * , size_t , const T * src2 , size_t step2 , <nl> - T * dst , size_t step , Size size , double scale ) <nl> - { <nl> - step2 / = sizeof ( src2 [ 0 ] ) ; <nl> - step / = sizeof ( dst [ 0 ] ) ; <nl> - <nl> - Recip_SIMD < T > vop ; <nl> - float scale_f = ( float ) scale ; <nl> - <nl> - for ( ; size . height - - ; src2 + = step2 , dst + = step ) <nl> - { <nl> - int i = vop ( src2 , dst , size . width , scale ) ; <nl> - for ( ; i < size . width ; i + + ) <nl> - { <nl> - T denom = src2 [ i ] ; <nl> - dst [ i ] = denom ! = 0 ? saturate_cast < T > ( scale_f / denom ) : ( T ) 0 ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - template < typename T > static void <nl> - recip_f ( const T * , size_t , const T * src2 , size_t step2 , <nl> - T * dst , size_t step , Size size , double scale ) <nl> - { <nl> - T scale_f = ( T ) scale ; <nl> - step2 / = sizeof ( src2 [ 0 ] ) ; <nl> - step / = sizeof ( dst [ 0 ] ) ; <nl> - <nl> - Recip_SIMD < T > vop ; <nl> - <nl> - for ( ; size . height - - ; src2 + = step2 , dst + = step ) <nl> - { <nl> - int i = vop ( src2 , dst , size . width , scale ) ; <nl> - for ( ; i < size . width ; i + + ) <nl> - { <nl> - T denom = src2 [ i ] ; <nl> - dst [ i ] = denom ! = 0 ? saturate_cast < T > ( scale_f / denom ) : ( T ) 0 ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - <nl> - static void mul8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - float fscale = ( float ) * ( const double * ) scale ; <nl> - # if defined HAVE_IPP <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - if ( std : : fabs ( fscale - 1 ) < = FLT_EPSILON ) <nl> - { <nl> - if ( ippiMul_8u_C1RSfs ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) , 0 ) > = 0 ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - } <nl> - # endif <nl> - mul_ ( src1 , step1 , src2 , step2 , dst , step , sz , fscale ) ; <nl> - } <nl> - <nl> - static void mul8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , <nl> - schar * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - mul_ ( src1 , step1 , src2 , step2 , dst , step , sz , ( float ) * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void mul16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , <nl> - ushort * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - float fscale = ( float ) * ( const double * ) scale ; <nl> - # if defined HAVE_IPP <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - if ( std : : fabs ( fscale - 1 ) < = FLT_EPSILON ) <nl> - { <nl> - if ( ippiMul_16u_C1RSfs ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) , 0 ) > = 0 ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - } <nl> - # endif <nl> - mul_ ( src1 , step1 , src2 , step2 , dst , step , sz , fscale ) ; <nl> - } <nl> - <nl> - static void mul16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , <nl> - short * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - float fscale = ( float ) * ( const double * ) scale ; <nl> - # if defined HAVE_IPP <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - if ( std : : fabs ( fscale - 1 ) < = FLT_EPSILON ) <nl> - { <nl> - if ( ippiMul_16s_C1RSfs ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) , 0 ) > = 0 ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - } <nl> - # endif <nl> - mul_ ( src1 , step1 , src2 , step2 , dst , step , sz , fscale ) ; <nl> - } <nl> - <nl> - static void mul32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , <nl> - int * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - mul_ ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void mul32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , <nl> - float * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - float fscale = ( float ) * ( const double * ) scale ; <nl> - # if defined HAVE_IPP <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - if ( std : : fabs ( fscale - 1 ) < = FLT_EPSILON ) <nl> - { <nl> - if ( ippiMul_32f_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( sz ) ) > = 0 ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - } <nl> - # endif <nl> - mul_ ( src1 , step1 , src2 , step2 , dst , step , sz , fscale ) ; <nl> - } <nl> - <nl> - static void mul64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , <nl> - double * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - mul_ ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void div8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - if ( src1 ) <nl> - div_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - else <nl> - recip_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void div8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , <nl> - schar * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - div_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void div16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , <nl> - ushort * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - div_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void div16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , <nl> - short * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - div_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void div32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , <nl> - int * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - div_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void div32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , <nl> - float * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - div_f ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void div64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , <nl> - double * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - div_f ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void recip8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - recip_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void recip8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , <nl> - schar * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - recip_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void recip16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , <nl> - ushort * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - recip_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void recip16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , <nl> - short * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - recip_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void recip32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , <nl> - int * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - recip_i ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void recip32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , <nl> - float * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - recip_f ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - static void recip64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , <nl> - double * dst , size_t step , Size sz , void * scale ) <nl> - { <nl> - recip_f ( src1 , step1 , src2 , step2 , dst , step , sz , * ( const double * ) scale ) ; <nl> - } <nl> - <nl> - <nl> - static BinaryFunc * getMulTab ( ) <nl> - { <nl> - static BinaryFunc mulTab [ ] = <nl> - { <nl> - ( BinaryFunc ) mul8u , ( BinaryFunc ) mul8s , ( BinaryFunc ) mul16u , <nl> - ( BinaryFunc ) mul16s , ( BinaryFunc ) mul32s , ( BinaryFunc ) mul32f , <nl> - ( BinaryFunc ) mul64f , 0 <nl> - } ; <nl> - <nl> - return mulTab ; <nl> - } <nl> - <nl> - static BinaryFunc * getDivTab ( ) <nl> - { <nl> - static BinaryFunc divTab [ ] = <nl> - { <nl> - ( BinaryFunc ) div8u , ( BinaryFunc ) div8s , ( BinaryFunc ) div16u , <nl> - ( BinaryFunc ) div16s , ( BinaryFunc ) div32s , ( BinaryFunc ) div32f , <nl> - ( BinaryFunc ) div64f , 0 <nl> - } ; <nl> - <nl> - return divTab ; <nl> - } <nl> - <nl> - static BinaryFunc * getRecipTab ( ) <nl> - { <nl> - static BinaryFunc recipTab [ ] = <nl> - { <nl> - ( BinaryFunc ) recip8u , ( BinaryFunc ) recip8s , ( BinaryFunc ) recip16u , <nl> - ( BinaryFunc ) recip16s , ( BinaryFunc ) recip32s , ( BinaryFunc ) recip32f , <nl> - ( BinaryFunc ) recip64f , 0 <nl> - } ; <nl> - <nl> - return recipTab ; <nl> - } <nl> - <nl> - } <nl> - <nl> - void cv : : multiply ( InputArray src1 , InputArray src2 , <nl> - OutputArray dst , double scale , int dtype ) <nl> - { <nl> - arithm_op ( src1 , src2 , dst , noArray ( ) , dtype , getMulTab ( ) , <nl> - true , & scale , std : : abs ( scale - 1 . 0 ) < DBL_EPSILON ? OCL_OP_MUL : OCL_OP_MUL_SCALE ) ; <nl> - } <nl> - <nl> - void cv : : divide ( InputArray src1 , InputArray src2 , <nl> - OutputArray dst , double scale , int dtype ) <nl> - { <nl> - arithm_op ( src1 , src2 , dst , noArray ( ) , dtype , getDivTab ( ) , true , & scale , OCL_OP_DIV_SCALE ) ; <nl> - } <nl> - <nl> - void cv : : divide ( double scale , InputArray src2 , <nl> - OutputArray dst , int dtype ) <nl> - { <nl> - arithm_op ( src2 , src2 , dst , noArray ( ) , dtype , getRecipTab ( ) , true , & scale , OCL_OP_RECIP_SCALE ) ; <nl> - } <nl> - <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> - * addWeighted * <nl> - \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - namespace cv <nl> - { <nl> - <nl> - template < typename T , typename WT > <nl> - struct AddWeighted_SIMD <nl> - { <nl> - int operator ( ) ( const T * , const T * , T * , int , WT , WT , WT ) const <nl> - { <nl> - return 0 ; <nl> - } <nl> - } ; <nl> - <nl> - # if CV_SSE2 <nl> - <nl> - template < > <nl> - struct AddWeighted_SIMD < schar , float > <nl> - { <nl> - AddWeighted_SIMD ( ) <nl> - { <nl> - haveSSE2 = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const schar * src1 , const schar * src2 , schar * dst , int width , float alpha , float beta , float gamma ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSSE2 ) <nl> - return x ; <nl> - <nl> - __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> - __m128 v_alpha = _mm_set1_ps ( alpha ) , v_beta = _mm_set1_ps ( beta ) , <nl> - v_gamma = _mm_set1_ps ( gamma ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i v_src1 = _mm_loadl_epi64 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> - __m128i v_src2 = _mm_loadl_epi64 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> - <nl> - __m128i v_src1_p = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src1 ) , 8 ) ; <nl> - __m128i v_src2_p = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src2 ) , 8 ) ; <nl> - <nl> - __m128 v_dstf0 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src1_p ) , 16 ) ) , v_alpha ) ; <nl> - v_dstf0 = _mm_add_ps ( _mm_add_ps ( v_dstf0 , v_gamma ) , <nl> - _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src2_p ) , 16 ) ) , v_beta ) ) ; <nl> - <nl> - __m128 v_dstf1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src1_p ) , 16 ) ) , v_alpha ) ; <nl> - v_dstf1 = _mm_add_ps ( _mm_add_ps ( v_dstf1 , v_gamma ) , <nl> - _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src2_p ) , 16 ) ) , v_beta ) ) ; <nl> - <nl> - __m128i v_dst16 = _mm_packs_epi32 ( _mm_cvtps_epi32 ( v_dstf0 ) , <nl> - _mm_cvtps_epi32 ( v_dstf1 ) ) ; <nl> - <nl> - _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi16 ( v_dst16 , v_zero ) ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - bool haveSSE2 ; <nl> - } ; <nl> - <nl> - template < > <nl> - struct AddWeighted_SIMD < short , float > <nl> - { <nl> - AddWeighted_SIMD ( ) <nl> - { <nl> - haveSSE2 = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const short * src1 , const short * src2 , short * dst , int width , float alpha , float beta , float gamma ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSSE2 ) <nl> - return x ; <nl> - <nl> - __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> - __m128 v_alpha = _mm_set1_ps ( alpha ) , v_beta = _mm_set1_ps ( beta ) , <nl> - v_gamma = _mm_set1_ps ( gamma ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i v_src1 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> - __m128i v_src2 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> - <nl> - __m128 v_dstf0 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src1 ) , 16 ) ) , v_alpha ) ; <nl> - v_dstf0 = _mm_add_ps ( _mm_add_ps ( v_dstf0 , v_gamma ) , <nl> - _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src2 ) , 16 ) ) , v_beta ) ) ; <nl> - <nl> - __m128 v_dstf1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src1 ) , 16 ) ) , v_alpha ) ; <nl> - v_dstf1 = _mm_add_ps ( _mm_add_ps ( v_dstf1 , v_gamma ) , <nl> - _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src2 ) , 16 ) ) , v_beta ) ) ; <nl> - <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi32 ( _mm_cvtps_epi32 ( v_dstf0 ) , <nl> - _mm_cvtps_epi32 ( v_dstf1 ) ) ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - bool haveSSE2 ; <nl> - } ; <nl> - <nl> - # if CV_SSE4_1 <nl> - <nl> - template < > <nl> - struct AddWeighted_SIMD < ushort , float > <nl> - { <nl> - AddWeighted_SIMD ( ) <nl> - { <nl> - haveSSE4_1 = checkHardwareSupport ( CV_CPU_SSE4_1 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const ushort * src1 , const ushort * src2 , ushort * dst , int width , float alpha , float beta , float gamma ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSSE4_1 ) <nl> - return x ; <nl> - <nl> - __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> - __m128 v_alpha = _mm_set1_ps ( alpha ) , v_beta = _mm_set1_ps ( beta ) , <nl> - v_gamma = _mm_set1_ps ( gamma ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i v_src1 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> - __m128i v_src2 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> - <nl> - __m128 v_dstf0 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( v_src1 , v_zero ) ) , v_alpha ) ; <nl> - v_dstf0 = _mm_add_ps ( _mm_add_ps ( v_dstf0 , v_gamma ) , <nl> - _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( v_src2 , v_zero ) ) , v_beta ) ) ; <nl> - <nl> - __m128 v_dstf1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( v_src1 , v_zero ) ) , v_alpha ) ; <nl> - v_dstf1 = _mm_add_ps ( _mm_add_ps ( v_dstf1 , v_gamma ) , <nl> - _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( v_src2 , v_zero ) ) , v_beta ) ) ; <nl> - <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_packus_epi32 ( _mm_cvtps_epi32 ( v_dstf0 ) , <nl> - _mm_cvtps_epi32 ( v_dstf1 ) ) ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - bool haveSSE4_1 ; <nl> - } ; <nl> - <nl> - # endif <nl> - <nl> - # elif CV_NEON <nl> - <nl> - template < > <nl> - struct AddWeighted_SIMD < schar , float > <nl> - { <nl> - int operator ( ) ( const schar * src1 , const schar * src2 , schar * dst , int width , float alpha , float beta , float gamma ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - float32x4_t g = vdupq_n_f32 ( gamma ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - int8x8_t in1 = vld1_s8 ( src1 + x ) ; <nl> - int16x8_t in1_16 = vmovl_s8 ( in1 ) ; <nl> - float32x4_t in1_f_l = vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( in1_16 ) ) ) ; <nl> - float32x4_t in1_f_h = vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( in1_16 ) ) ) ; <nl> - <nl> - int8x8_t in2 = vld1_s8 ( src2 + x ) ; <nl> - int16x8_t in2_16 = vmovl_s8 ( in2 ) ; <nl> - float32x4_t in2_f_l = vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( in2_16 ) ) ) ; <nl> - float32x4_t in2_f_h = vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( in2_16 ) ) ) ; <nl> - <nl> - float32x4_t out_f_l = vaddq_f32 ( vmulq_n_f32 ( in1_f_l , alpha ) , vmulq_n_f32 ( in2_f_l , beta ) ) ; <nl> - float32x4_t out_f_h = vaddq_f32 ( vmulq_n_f32 ( in1_f_h , alpha ) , vmulq_n_f32 ( in2_f_h , beta ) ) ; <nl> - out_f_l = vaddq_f32 ( out_f_l , g ) ; <nl> - out_f_h = vaddq_f32 ( out_f_h , g ) ; <nl> - <nl> - int16x4_t out_16_l = vqmovn_s32 ( cv_vrndq_s32_f32 ( out_f_l ) ) ; <nl> - int16x4_t out_16_h = vqmovn_s32 ( cv_vrndq_s32_f32 ( out_f_h ) ) ; <nl> - <nl> - int16x8_t out_16 = vcombine_s16 ( out_16_l , out_16_h ) ; <nl> - int8x8_t out = vqmovn_s16 ( out_16 ) ; <nl> - <nl> - vst1_s8 ( dst + x , out ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct AddWeighted_SIMD < ushort , float > <nl> - { <nl> - int operator ( ) ( const ushort * src1 , const ushort * src2 , ushort * dst , int width , float alpha , float beta , float gamma ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - float32x4_t g = vdupq_n_f32 ( gamma ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint16x8_t v_src1 = vld1q_u16 ( src1 + x ) , v_src2 = vld1q_u16 ( src2 + x ) ; <nl> - <nl> - float32x4_t v_s1 = vmulq_n_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src1 ) ) ) , alpha ) ; <nl> - float32x4_t v_s2 = vmulq_n_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src2 ) ) ) , beta ) ; <nl> - uint16x4_t v_dst1 = vqmovn_u32 ( cv_vrndq_u32_f32 ( vaddq_f32 ( vaddq_f32 ( v_s1 , v_s2 ) , g ) ) ) ; <nl> - <nl> - v_s1 = vmulq_n_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src1 ) ) ) , alpha ) ; <nl> - v_s2 = vmulq_n_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src2 ) ) ) , beta ) ; <nl> - uint16x4_t v_dst2 = vqmovn_u32 ( cv_vrndq_u32_f32 ( vaddq_f32 ( vaddq_f32 ( v_s1 , v_s2 ) , g ) ) ) ; <nl> - <nl> - vst1q_u16 ( dst + x , vcombine_u16 ( v_dst1 , v_dst2 ) ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - template < > <nl> - struct AddWeighted_SIMD < short , float > <nl> - { <nl> - int operator ( ) ( const short * src1 , const short * src2 , short * dst , int width , float alpha , float beta , float gamma ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - float32x4_t g = vdupq_n_f32 ( gamma ) ; <nl> - <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - int16x8_t v_src1 = vld1q_s16 ( src1 + x ) , v_src2 = vld1q_s16 ( src2 + x ) ; <nl> - <nl> - float32x4_t v_s1 = vmulq_n_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src1 ) ) ) , alpha ) ; <nl> - float32x4_t v_s2 = vmulq_n_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src2 ) ) ) , beta ) ; <nl> - int16x4_t v_dst1 = vqmovn_s32 ( cv_vrndq_s32_f32 ( vaddq_f32 ( vaddq_f32 ( v_s1 , v_s2 ) , g ) ) ) ; <nl> - <nl> - v_s1 = vmulq_n_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src1 ) ) ) , alpha ) ; <nl> - v_s2 = vmulq_n_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src2 ) ) ) , beta ) ; <nl> - int16x4_t v_dst2 = vqmovn_s32 ( cv_vrndq_s32_f32 ( vaddq_f32 ( vaddq_f32 ( v_s1 , v_s2 ) , g ) ) ) ; <nl> - <nl> - vst1q_s16 ( dst + x , vcombine_s16 ( v_dst1 , v_dst2 ) ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - } ; <nl> - <nl> - # endif <nl> - <nl> - template < typename T , typename WT > static void <nl> - addWeighted_ ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> - T * dst , size_t step , Size size , void * _scalars ) <nl> - { <nl> - const double * scalars = ( const double * ) _scalars ; <nl> - WT alpha = ( WT ) scalars [ 0 ] , beta = ( WT ) scalars [ 1 ] , gamma = ( WT ) scalars [ 2 ] ; <nl> - step1 / = sizeof ( src1 [ 0 ] ) ; <nl> - step2 / = sizeof ( src2 [ 0 ] ) ; <nl> - step / = sizeof ( dst [ 0 ] ) ; <nl> - <nl> - AddWeighted_SIMD < T , WT > vop ; <nl> - <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int x = vop ( src1 , src2 , dst , size . width , alpha , beta , gamma ) ; <nl> - # if CV_ENABLE_UNROLLED <nl> - for ( ; x < = size . width - 4 ; x + = 4 ) <nl> - { <nl> - T t0 = saturate_cast < T > ( src1 [ x ] * alpha + src2 [ x ] * beta + gamma ) ; <nl> - T t1 = saturate_cast < T > ( src1 [ x + 1 ] * alpha + src2 [ x + 1 ] * beta + gamma ) ; <nl> - dst [ x ] = t0 ; dst [ x + 1 ] = t1 ; <nl> - <nl> - t0 = saturate_cast < T > ( src1 [ x + 2 ] * alpha + src2 [ x + 2 ] * beta + gamma ) ; <nl> - t1 = saturate_cast < T > ( src1 [ x + 3 ] * alpha + src2 [ x + 3 ] * beta + gamma ) ; <nl> - dst [ x + 2 ] = t0 ; dst [ x + 3 ] = t1 ; <nl> - } <nl> - # endif <nl> - for ( ; x < size . width ; x + + ) <nl> - dst [ x ] = saturate_cast < T > ( src1 [ x ] * alpha + src2 [ x ] * beta + gamma ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - static void <nl> - addWeighted8u ( const uchar * src1 , size_t step1 , <nl> - const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size size , <nl> - void * _scalars ) <nl> - { <nl> - const double * scalars = ( const double * ) _scalars ; <nl> - float alpha = ( float ) scalars [ 0 ] , beta = ( float ) scalars [ 1 ] , gamma = ( float ) scalars [ 2 ] ; <nl> - <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int x = 0 ; <nl> - <nl> - # if CV_SSE2 <nl> - if ( USE_SSE2 ) <nl> - { <nl> - __m128 a4 = _mm_set1_ps ( alpha ) , b4 = _mm_set1_ps ( beta ) , g4 = _mm_set1_ps ( gamma ) ; <nl> - __m128i z = _mm_setzero_si128 ( ) ; <nl> - <nl> - for ( ; x < = size . width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i u = _mm_unpacklo_epi8 ( _mm_loadl_epi64 ( ( const __m128i * ) ( src1 + x ) ) , z ) ; <nl> - __m128i v = _mm_unpacklo_epi8 ( _mm_loadl_epi64 ( ( const __m128i * ) ( src2 + x ) ) , z ) ; <nl> - <nl> - __m128 u0 = _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( u , z ) ) ; <nl> - __m128 u1 = _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( u , z ) ) ; <nl> - __m128 v0 = _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( v , z ) ) ; <nl> - __m128 v1 = _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( v , z ) ) ; <nl> - <nl> - u0 = _mm_add_ps ( _mm_mul_ps ( u0 , a4 ) , _mm_mul_ps ( v0 , b4 ) ) ; <nl> - u1 = _mm_add_ps ( _mm_mul_ps ( u1 , a4 ) , _mm_mul_ps ( v1 , b4 ) ) ; <nl> - u0 = _mm_add_ps ( u0 , g4 ) ; u1 = _mm_add_ps ( u1 , g4 ) ; <nl> - <nl> - u = _mm_packs_epi32 ( _mm_cvtps_epi32 ( u0 ) , _mm_cvtps_epi32 ( u1 ) ) ; <nl> - u = _mm_packus_epi16 ( u , u ) ; <nl> - <nl> - _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , u ) ; <nl> - } <nl> - } <nl> - # elif CV_NEON <nl> - float32x4_t g = vdupq_n_f32 ( gamma ) ; <nl> - <nl> - for ( ; x < = size . width - 8 ; x + = 8 ) <nl> - { <nl> - uint8x8_t in1 = vld1_u8 ( src1 + x ) ; <nl> - uint16x8_t in1_16 = vmovl_u8 ( in1 ) ; <nl> - float32x4_t in1_f_l = vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( in1_16 ) ) ) ; <nl> - float32x4_t in1_f_h = vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( in1_16 ) ) ) ; <nl> - <nl> - uint8x8_t in2 = vld1_u8 ( src2 + x ) ; <nl> - uint16x8_t in2_16 = vmovl_u8 ( in2 ) ; <nl> - float32x4_t in2_f_l = vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( in2_16 ) ) ) ; <nl> - float32x4_t in2_f_h = vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( in2_16 ) ) ) ; <nl> - <nl> - float32x4_t out_f_l = vaddq_f32 ( vmulq_n_f32 ( in1_f_l , alpha ) , vmulq_n_f32 ( in2_f_l , beta ) ) ; <nl> - float32x4_t out_f_h = vaddq_f32 ( vmulq_n_f32 ( in1_f_h , alpha ) , vmulq_n_f32 ( in2_f_h , beta ) ) ; <nl> - out_f_l = vaddq_f32 ( out_f_l , g ) ; <nl> - out_f_h = vaddq_f32 ( out_f_h , g ) ; <nl> - <nl> - uint16x4_t out_16_l = vqmovun_s32 ( cv_vrndq_s32_f32 ( out_f_l ) ) ; <nl> - uint16x4_t out_16_h = vqmovun_s32 ( cv_vrndq_s32_f32 ( out_f_h ) ) ; <nl> - <nl> - uint16x8_t out_16 = vcombine_u16 ( out_16_l , out_16_h ) ; <nl> - uint8x8_t out = vqmovn_u16 ( out_16 ) ; <nl> - <nl> - vst1_u8 ( dst + x , out ) ; <nl> - } <nl> - # endif <nl> - # if CV_ENABLE_UNROLLED <nl> - for ( ; x < = size . width - 4 ; x + = 4 ) <nl> - { <nl> - float t0 , t1 ; <nl> - t0 = CV_8TO32F ( src1 [ x ] ) * alpha + CV_8TO32F ( src2 [ x ] ) * beta + gamma ; <nl> - t1 = CV_8TO32F ( src1 [ x + 1 ] ) * alpha + CV_8TO32F ( src2 [ x + 1 ] ) * beta + gamma ; <nl> - <nl> - dst [ x ] = saturate_cast < uchar > ( t0 ) ; <nl> - dst [ x + 1 ] = saturate_cast < uchar > ( t1 ) ; <nl> - <nl> - t0 = CV_8TO32F ( src1 [ x + 2 ] ) * alpha + CV_8TO32F ( src2 [ x + 2 ] ) * beta + gamma ; <nl> - t1 = CV_8TO32F ( src1 [ x + 3 ] ) * alpha + CV_8TO32F ( src2 [ x + 3 ] ) * beta + gamma ; <nl> - <nl> - dst [ x + 2 ] = saturate_cast < uchar > ( t0 ) ; <nl> - dst [ x + 3 ] = saturate_cast < uchar > ( t1 ) ; <nl> - } <nl> - # endif <nl> - <nl> - for ( ; x < size . width ; x + + ) <nl> - { <nl> - float t0 = CV_8TO32F ( src1 [ x ] ) * alpha + CV_8TO32F ( src2 [ x ] ) * beta + gamma ; <nl> - dst [ x ] = saturate_cast < uchar > ( t0 ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - static void addWeighted8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , <nl> - schar * dst , size_t step , Size sz , void * scalars ) <nl> - { <nl> - addWeighted_ < schar , float > ( src1 , step1 , src2 , step2 , dst , step , sz , scalars ) ; <nl> - } <nl> - <nl> - static void addWeighted16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , <nl> - ushort * dst , size_t step , Size sz , void * scalars ) <nl> - { <nl> - addWeighted_ < ushort , float > ( src1 , step1 , src2 , step2 , dst , step , sz , scalars ) ; <nl> - } <nl> - <nl> - static void addWeighted16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , <nl> - short * dst , size_t step , Size sz , void * scalars ) <nl> - { <nl> - addWeighted_ < short , float > ( src1 , step1 , src2 , step2 , dst , step , sz , scalars ) ; <nl> - } <nl> - <nl> - static void addWeighted32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , <nl> - int * dst , size_t step , Size sz , void * scalars ) <nl> - { <nl> - addWeighted_ < int , double > ( src1 , step1 , src2 , step2 , dst , step , sz , scalars ) ; <nl> - } <nl> - <nl> - static void addWeighted32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , <nl> - float * dst , size_t step , Size sz , void * scalars ) <nl> - { <nl> - addWeighted_ < float , double > ( src1 , step1 , src2 , step2 , dst , step , sz , scalars ) ; <nl> - } <nl> - <nl> - static void addWeighted64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , <nl> - double * dst , size_t step , Size sz , void * scalars ) <nl> - { <nl> - addWeighted_ < double , double > ( src1 , step1 , src2 , step2 , dst , step , sz , scalars ) ; <nl> - } <nl> - <nl> - static BinaryFunc * getAddWeightedTab ( ) <nl> - { <nl> - static BinaryFunc addWeightedTab [ ] = <nl> - { <nl> - ( BinaryFunc ) GET_OPTIMIZED ( addWeighted8u ) , ( BinaryFunc ) GET_OPTIMIZED ( addWeighted8s ) , ( BinaryFunc ) GET_OPTIMIZED ( addWeighted16u ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( addWeighted16s ) , ( BinaryFunc ) GET_OPTIMIZED ( addWeighted32s ) , ( BinaryFunc ) addWeighted32f , <nl> - ( BinaryFunc ) addWeighted64f , 0 <nl> - } ; <nl> - <nl> - return addWeightedTab ; <nl> - } <nl> - <nl> - } <nl> - <nl> - void cv : : addWeighted ( InputArray src1 , double alpha , InputArray src2 , <nl> - double beta , double gamma , OutputArray dst , int dtype ) <nl> - { <nl> - double scalars [ ] = { alpha , beta , gamma } ; <nl> - arithm_op ( src1 , src2 , dst , noArray ( ) , dtype , getAddWeightedTab ( ) , true , scalars , OCL_OP_ADDW ) ; <nl> - } <nl> - <nl> - <nl> - / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> - * compare * <nl> - \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> - <nl> - namespace cv <nl> - { <nl> - <nl> - template < typename T > <nl> - struct Cmp_SIMD <nl> - { <nl> - explicit Cmp_SIMD ( int ) <nl> - { <nl> - } <nl> - <nl> - int operator ( ) ( const T * , const T * , uchar * , int ) const <nl> - { <nl> - return 0 ; <nl> - } <nl> - } ; <nl> - <nl> - # if CV_NEON <nl> - <nl> - template < > <nl> - struct Cmp_SIMD < schar > <nl> - { <nl> - explicit Cmp_SIMD ( int code_ ) : <nl> - code ( code_ ) <nl> - { <nl> - CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> - code = = CMP_EQ | | code = = CMP_NE ) ; <nl> - <nl> - v_mask = vdupq_n_u8 ( 255 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const schar * src1 , const schar * src2 , uchar * dst , int width ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( code = = CMP_GT ) <nl> - for ( ; x < = width - 16 ; x + = 16 ) <nl> - vst1q_u8 ( dst + x , vcgtq_s8 ( vld1q_s8 ( src1 + x ) , vld1q_s8 ( src2 + x ) ) ) ; <nl> - else if ( code = = CMP_LE ) <nl> - for ( ; x < = width - 16 ; x + = 16 ) <nl> - vst1q_u8 ( dst + x , vcleq_s8 ( vld1q_s8 ( src1 + x ) , vld1q_s8 ( src2 + x ) ) ) ; <nl> - else if ( code = = CMP_EQ ) <nl> - for ( ; x < = width - 16 ; x + = 16 ) <nl> - vst1q_u8 ( dst + x , vceqq_s8 ( vld1q_s8 ( src1 + x ) , vld1q_s8 ( src2 + x ) ) ) ; <nl> - else if ( code = = CMP_NE ) <nl> - for ( ; x < = width - 16 ; x + = 16 ) <nl> - vst1q_u8 ( dst + x , veorq_u8 ( vceqq_s8 ( vld1q_s8 ( src1 + x ) , vld1q_s8 ( src2 + x ) ) , v_mask ) ) ; <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - int code ; <nl> - uint8x16_t v_mask ; <nl> - } ; <nl> - <nl> - template < > <nl> - struct Cmp_SIMD < ushort > <nl> - { <nl> - explicit Cmp_SIMD ( int code_ ) : <nl> - code ( code_ ) <nl> - { <nl> - CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> - code = = CMP_EQ | | code = = CMP_NE ) ; <nl> - <nl> - v_mask = vdup_n_u8 ( 255 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const ushort * src1 , const ushort * src2 , uchar * dst , int width ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( code = = CMP_GT ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint16x8_t v_dst = vcgtq_u16 ( vld1q_u16 ( src1 + x ) , vld1q_u16 ( src2 + x ) ) ; <nl> - vst1_u8 ( dst + x , vmovn_u16 ( v_dst ) ) ; <nl> - } <nl> - else if ( code = = CMP_LE ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint16x8_t v_dst = vcleq_u16 ( vld1q_u16 ( src1 + x ) , vld1q_u16 ( src2 + x ) ) ; <nl> - vst1_u8 ( dst + x , vmovn_u16 ( v_dst ) ) ; <nl> - } <nl> - else if ( code = = CMP_EQ ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint16x8_t v_dst = vceqq_u16 ( vld1q_u16 ( src1 + x ) , vld1q_u16 ( src2 + x ) ) ; <nl> - vst1_u8 ( dst + x , vmovn_u16 ( v_dst ) ) ; <nl> - } <nl> - else if ( code = = CMP_NE ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint16x8_t v_dst = vceqq_u16 ( vld1q_u16 ( src1 + x ) , vld1q_u16 ( src2 + x ) ) ; <nl> - vst1_u8 ( dst + x , veor_u8 ( vmovn_u16 ( v_dst ) , v_mask ) ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - int code ; <nl> - uint8x8_t v_mask ; <nl> - } ; <nl> - <nl> - template < > <nl> - struct Cmp_SIMD < int > <nl> - { <nl> - explicit Cmp_SIMD ( int code_ ) : <nl> - code ( code_ ) <nl> - { <nl> - CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> - code = = CMP_EQ | | code = = CMP_NE ) ; <nl> - <nl> - v_mask = vdup_n_u8 ( 255 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const int * src1 , const int * src2 , uchar * dst , int width ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( code = = CMP_GT ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint32x4_t v_dst1 = vcgtq_s32 ( vld1q_s32 ( src1 + x ) , vld1q_s32 ( src2 + x ) ) ; <nl> - uint32x4_t v_dst2 = vcgtq_s32 ( vld1q_s32 ( src1 + x + 4 ) , vld1q_s32 ( src2 + x + 4 ) ) ; <nl> - vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> - } <nl> - else if ( code = = CMP_LE ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint32x4_t v_dst1 = vcleq_s32 ( vld1q_s32 ( src1 + x ) , vld1q_s32 ( src2 + x ) ) ; <nl> - uint32x4_t v_dst2 = vcleq_s32 ( vld1q_s32 ( src1 + x + 4 ) , vld1q_s32 ( src2 + x + 4 ) ) ; <nl> - vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> - } <nl> - else if ( code = = CMP_EQ ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint32x4_t v_dst1 = vceqq_s32 ( vld1q_s32 ( src1 + x ) , vld1q_s32 ( src2 + x ) ) ; <nl> - uint32x4_t v_dst2 = vceqq_s32 ( vld1q_s32 ( src1 + x + 4 ) , vld1q_s32 ( src2 + x + 4 ) ) ; <nl> - vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> - } <nl> - else if ( code = = CMP_NE ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint32x4_t v_dst1 = vceqq_s32 ( vld1q_s32 ( src1 + x ) , vld1q_s32 ( src2 + x ) ) ; <nl> - uint32x4_t v_dst2 = vceqq_s32 ( vld1q_s32 ( src1 + x + 4 ) , vld1q_s32 ( src2 + x + 4 ) ) ; <nl> - uint8x8_t v_dst = vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ; <nl> - vst1_u8 ( dst + x , veor_u8 ( v_dst , v_mask ) ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - int code ; <nl> - uint8x8_t v_mask ; <nl> - } ; <nl> - <nl> - template < > <nl> - struct Cmp_SIMD < float > <nl> - { <nl> - explicit Cmp_SIMD ( int code_ ) : <nl> - code ( code_ ) <nl> - { <nl> - CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> - code = = CMP_EQ | | code = = CMP_NE ) ; <nl> - <nl> - v_mask = vdup_n_u8 ( 255 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const float * src1 , const float * src2 , uchar * dst , int width ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( code = = CMP_GT ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint32x4_t v_dst1 = vcgtq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> - uint32x4_t v_dst2 = vcgtq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> - vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> - } <nl> - else if ( code = = CMP_LE ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint32x4_t v_dst1 = vcleq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> - uint32x4_t v_dst2 = vcleq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> - vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> - } <nl> - else if ( code = = CMP_EQ ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint32x4_t v_dst1 = vceqq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> - uint32x4_t v_dst2 = vceqq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> - vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> - } <nl> - else if ( code = = CMP_NE ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - uint32x4_t v_dst1 = vceqq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> - uint32x4_t v_dst2 = vceqq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> - uint8x8_t v_dst = vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ; <nl> - vst1_u8 ( dst + x , veor_u8 ( v_dst , v_mask ) ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - int code ; <nl> - uint8x8_t v_mask ; <nl> - } ; <nl> - <nl> - # elif CV_SSE2 <nl> - <nl> - template < > <nl> - struct Cmp_SIMD < schar > <nl> - { <nl> - explicit Cmp_SIMD ( int code_ ) : <nl> - code ( code_ ) <nl> - { <nl> - CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> - code = = CMP_EQ | | code = = CMP_NE ) ; <nl> - <nl> - haveSSE = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> - <nl> - v_mask = _mm_set1_epi8 ( - 1 ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const schar * src1 , const schar * src2 , uchar * dst , int width ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSSE ) <nl> - return x ; <nl> - <nl> - if ( code = = CMP_GT ) <nl> - for ( ; x < = width - 16 ; x + = 16 ) <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_cmpgt_epi8 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ) ; <nl> - else if ( code = = CMP_LE ) <nl> - for ( ; x < = width - 16 ; x + = 16 ) <nl> - { <nl> - __m128i v_gt = _mm_cmpgt_epi8 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_xor_si128 ( v_mask , v_gt ) ) ; <nl> - } <nl> - else if ( code = = CMP_EQ ) <nl> - for ( ; x < = width - 16 ; x + = 16 ) <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_cmpeq_epi8 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ) ; <nl> - else if ( code = = CMP_NE ) <nl> - for ( ; x < = width - 16 ; x + = 16 ) <nl> - { <nl> - __m128i v_eq = _mm_cmpeq_epi8 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_xor_si128 ( v_mask , v_eq ) ) ; <nl> - } <nl> - <nl> - return x ; <nl> - } <nl> - <nl> - int code ; <nl> - __m128i v_mask ; <nl> - bool haveSSE ; <nl> - } ; <nl> - <nl> - template < > <nl> - struct Cmp_SIMD < int > <nl> - { <nl> - explicit Cmp_SIMD ( int code_ ) : <nl> - code ( code_ ) <nl> - { <nl> - CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> - code = = CMP_EQ | | code = = CMP_NE ) ; <nl> - <nl> - haveSSE = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> - <nl> - v_mask = _mm_set1_epi32 ( 0xffffffff ) ; <nl> - } <nl> - <nl> - int operator ( ) ( const int * src1 , const int * src2 , uchar * dst , int width ) const <nl> - { <nl> - int x = 0 ; <nl> - <nl> - if ( ! haveSSE ) <nl> - return x ; <nl> + _buf . allocate ( bufesz * blocksize + 64 ) ; <nl> + buf = _buf ; <nl> + if ( cvtsrc1 ) <nl> + buf1 = buf , buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> + buf2 = buf ; buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> + wbuf = maskbuf = buf ; <nl> + if ( cvtdst ) <nl> + buf = alignPtr ( buf + blocksize * wsz , 16 ) ; <nl> + if ( haveMask ) <nl> + maskbuf = buf ; <nl> <nl> - if ( code = = CMP_GT ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i v_dst0 = _mm_cmpgt_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> - __m128i v_dst1 = _mm_cmpgt_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 4 ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 4 ) ) ) ; <nl> + convertAndUnrollScalar ( src2 , wtype , buf2 , blocksize ) ; <nl> <nl> - _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi16 ( _mm_packs_epi32 ( v_dst0 , v_dst1 ) , v_mask ) ) ; <nl> - } <nl> - else if ( code = = CMP_LE ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> + for ( size_t i = 0 ; i < it . nplanes ; i + + , + + it ) <nl> + { <nl> + for ( size_t j = 0 ; j < total ; j + = blocksize ) <nl> { <nl> - __m128i v_dst0 = _mm_cmpgt_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> - __m128i v_dst1 = _mm_cmpgt_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 4 ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 4 ) ) ) ; <nl> + int bsz = ( int ) MIN ( total - j , blocksize ) ; <nl> + Size bszn ( bsz * cn , 1 ) ; <nl> + const uchar * sptr1 = ptrs [ 0 ] ; <nl> + const uchar * sptr2 = buf2 ; <nl> + uchar * dptr = ptrs [ 1 ] ; <nl> <nl> - _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_xor_si128 ( _mm_packs_epi16 ( _mm_packs_epi32 ( v_dst0 , v_dst1 ) , v_mask ) , v_mask ) ) ; <nl> - } <nl> - else if ( code = = CMP_EQ ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i v_dst0 = _mm_cmpeq_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> - __m128i v_dst1 = _mm_cmpeq_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 4 ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 4 ) ) ) ; <nl> + if ( cvtsrc1 ) <nl> + { <nl> + cvtsrc1 ( sptr1 , 1 , 0 , 1 , buf1 , 1 , bszn , 0 ) ; <nl> + sptr1 = buf1 ; <nl> + } <nl> <nl> - _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi16 ( _mm_packs_epi32 ( v_dst0 , v_dst1 ) , v_mask ) ) ; <nl> - } <nl> - else if ( code = = CMP_NE ) <nl> - for ( ; x < = width - 8 ; x + = 8 ) <nl> - { <nl> - __m128i v_dst0 = _mm_cmpeq_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> - __m128i v_dst1 = _mm_cmpeq_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 4 ) ) , <nl> - _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 4 ) ) ) ; <nl> + if ( swapped12 ) <nl> + std : : swap ( sptr1 , sptr2 ) ; <nl> <nl> - _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_xor_si128 ( v_mask , _mm_packs_epi16 ( _mm_packs_epi32 ( v_dst0 , v_dst1 ) , v_mask ) ) ) ; <nl> + if ( ! haveMask & & ! cvtdst ) <nl> + func ( sptr1 , 1 , sptr2 , 1 , dptr , 1 , bszn . width , bszn . height , usrdata ) ; <nl> + else <nl> + { <nl> + func ( sptr1 , 1 , sptr2 , 1 , wbuf , 1 , bszn . width , bszn . height , usrdata ) ; <nl> + if ( ! haveMask ) <nl> + cvtdst ( wbuf , 1 , 0 , 1 , dptr , 1 , bszn , 0 ) ; <nl> + else if ( ! cvtdst ) <nl> + { <nl> + copymask ( wbuf , 1 , ptrs [ 2 ] , 1 , dptr , 1 , Size ( bsz , 1 ) , & dsz ) ; <nl> + ptrs [ 2 ] + = bsz ; <nl> + } <nl> + else <nl> + { <nl> + cvtdst ( wbuf , 1 , 0 , 1 , maskbuf , 1 , bszn , 0 ) ; <nl> + copymask ( maskbuf , 1 , ptrs [ 2 ] , 1 , dptr , 1 , Size ( bsz , 1 ) , & dsz ) ; <nl> + ptrs [ 2 ] + = bsz ; <nl> + } <nl> + } <nl> + ptrs [ 0 ] + = bsz * esz1 ; ptrs [ 1 ] + = bsz * dsz ; <nl> } <nl> - <nl> - return x ; <nl> + } <nl> } <nl> + } <nl> <nl> - int code ; <nl> - __m128i v_mask ; <nl> - bool haveSSE ; <nl> - } ; <nl> + static BinaryFuncC * getAddTab ( ) <nl> + { <nl> + static BinaryFuncC addTab [ ] = <nl> + { <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : add8u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : add8s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : add16u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : add16s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : add32s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : add32f ) , ( BinaryFuncC ) cv : : hal : : add64f , <nl> + 0 <nl> + } ; <nl> <nl> - # endif <nl> + return addTab ; <nl> + } <nl> <nl> - template < typename T > static void <nl> - cmp_ ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size size , int code ) <nl> + static BinaryFuncC * getSubTab ( ) <nl> { <nl> - step1 / = sizeof ( src1 [ 0 ] ) ; <nl> - step2 / = sizeof ( src2 [ 0 ] ) ; <nl> - if ( code = = CMP_GE | | code = = CMP_LT ) <nl> + static BinaryFuncC subTab [ ] = <nl> { <nl> - std : : swap ( src1 , src2 ) ; <nl> - std : : swap ( step1 , step2 ) ; <nl> - code = code = = CMP_GE ? CMP_LE : CMP_GT ; <nl> - } <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : sub8u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : sub8s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : sub16u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : sub16s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : sub32s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : sub32f ) , ( BinaryFuncC ) cv : : hal : : sub64f , <nl> + 0 <nl> + } ; <nl> <nl> - Cmp_SIMD < T > vop ( code ) ; <nl> + return subTab ; <nl> + } <nl> <nl> - if ( code = = CMP_GT | | code = = CMP_LE ) <nl> - { <nl> - int m = code = = CMP_GT ? 0 : 255 ; <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int x = vop ( src1 , src2 , dst , size . width ) ; <nl> - # if CV_ENABLE_UNROLLED <nl> - for ( ; x < = size . width - 4 ; x + = 4 ) <nl> - { <nl> - int t0 , t1 ; <nl> - t0 = - ( src1 [ x ] > src2 [ x ] ) ^ m ; <nl> - t1 = - ( src1 [ x + 1 ] > src2 [ x + 1 ] ) ^ m ; <nl> - dst [ x ] = ( uchar ) t0 ; dst [ x + 1 ] = ( uchar ) t1 ; <nl> - t0 = - ( src1 [ x + 2 ] > src2 [ x + 2 ] ) ^ m ; <nl> - t1 = - ( src1 [ x + 3 ] > src2 [ x + 3 ] ) ^ m ; <nl> - dst [ x + 2 ] = ( uchar ) t0 ; dst [ x + 3 ] = ( uchar ) t1 ; <nl> - } <nl> - # endif <nl> - for ( ; x < size . width ; x + + ) <nl> - dst [ x ] = ( uchar ) ( - ( src1 [ x ] > src2 [ x ] ) ^ m ) ; <nl> - } <nl> - } <nl> - else if ( code = = CMP_EQ | | code = = CMP_NE ) <nl> + static BinaryFuncC * getAbsDiffTab ( ) <nl> + { <nl> + static BinaryFuncC absDiffTab [ ] = <nl> { <nl> - int m = code = = CMP_EQ ? 0 : 255 ; <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int x = 0 ; <nl> - # if CV_ENABLE_UNROLLED <nl> - for ( ; x < = size . width - 4 ; x + = 4 ) <nl> - { <nl> - int t0 , t1 ; <nl> - t0 = - ( src1 [ x ] = = src2 [ x ] ) ^ m ; <nl> - t1 = - ( src1 [ x + 1 ] = = src2 [ x + 1 ] ) ^ m ; <nl> - dst [ x ] = ( uchar ) t0 ; dst [ x + 1 ] = ( uchar ) t1 ; <nl> - t0 = - ( src1 [ x + 2 ] = = src2 [ x + 2 ] ) ^ m ; <nl> - t1 = - ( src1 [ x + 3 ] = = src2 [ x + 3 ] ) ^ m ; <nl> - dst [ x + 2 ] = ( uchar ) t0 ; dst [ x + 3 ] = ( uchar ) t1 ; <nl> - } <nl> - # endif <nl> - for ( ; x < size . width ; x + + ) <nl> - dst [ x ] = ( uchar ) ( - ( src1 [ x ] = = src2 [ x ] ) ^ m ) ; <nl> - } <nl> - } <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : absdiff8u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : absdiff8s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : absdiff16u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : absdiff16s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : absdiff32s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : absdiff32f ) , ( BinaryFuncC ) cv : : hal : : absdiff64f , <nl> + 0 <nl> + } ; <nl> + <nl> + return absDiffTab ; <nl> + } <nl> + <nl> } <nl> <nl> - # if ARITHM_USE_IPP <nl> - inline static IppCmpOp convert_cmp ( int _cmpop ) <nl> + void cv : : add ( InputArray src1 , InputArray src2 , OutputArray dst , <nl> + InputArray mask , int dtype ) <nl> { <nl> - return _cmpop = = CMP_EQ ? ippCmpEq : <nl> - _cmpop = = CMP_GT ? ippCmpGreater : <nl> - _cmpop = = CMP_GE ? ippCmpGreaterEq : <nl> - _cmpop = = CMP_LT ? ippCmpLess : <nl> - _cmpop = = CMP_LE ? ippCmpLessEq : <nl> - ( IppCmpOp ) - 1 ; <nl> + arithm_op ( src1 , src2 , dst , mask , dtype , getAddTab ( ) , false , 0 , OCL_OP_ADD ) ; <nl> } <nl> - # endif <nl> <nl> - static void cmp8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size size , void * _cmpop ) <nl> + void cv : : subtract ( InputArray _src1 , InputArray _src2 , OutputArray _dst , <nl> + InputArray mask , int dtype ) <nl> { <nl> - # if ARITHM_USE_IPP <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - IppCmpOp op = convert_cmp ( * ( int * ) _cmpop ) ; <nl> - if ( op > = 0 ) <nl> - { <nl> - fixSteps ( size , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiCompare_8u_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( size ) , op ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - } <nl> - # endif <nl> - / / vz optimized cmp_ ( src1 , step1 , src2 , step2 , dst , step , size , * ( int * ) _cmpop ) ; <nl> - int code = * ( int * ) _cmpop ; <nl> - step1 / = sizeof ( src1 [ 0 ] ) ; <nl> - step2 / = sizeof ( src2 [ 0 ] ) ; <nl> - if ( code = = CMP_GE | | code = = CMP_LT ) <nl> + # ifdef HAVE_TEGRA_OPTIMIZATION <nl> + if ( tegra : : useTegra ( ) ) <nl> { <nl> - std : : swap ( src1 , src2 ) ; <nl> - std : : swap ( step1 , step2 ) ; <nl> - code = code = = CMP_GE ? CMP_LE : CMP_GT ; <nl> - } <nl> + int kind1 = _src1 . kind ( ) , kind2 = _src2 . kind ( ) ; <nl> + Mat src1 = _src1 . getMat ( ) , src2 = _src2 . getMat ( ) ; <nl> + bool src1Scalar = checkScalar ( src1 , _src2 . type ( ) , kind1 , kind2 ) ; <nl> + bool src2Scalar = checkScalar ( src2 , _src1 . type ( ) , kind2 , kind1 ) ; <nl> <nl> - if ( code = = CMP_GT | | code = = CMP_LE ) <nl> - { <nl> - int m = code = = CMP_GT ? 0 : 255 ; <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + if ( ! src1Scalar & & ! src2Scalar & & <nl> + src1 . depth ( ) = = CV_8U & & src2 . type ( ) = = src1 . type ( ) & & <nl> + src1 . dims = = 2 & & src2 . size ( ) = = src1 . size ( ) & & <nl> + mask . empty ( ) ) <nl> { <nl> - int x = 0 ; <nl> - # if CV_SSE2 <nl> - if ( USE_SSE2 ) <nl> + if ( dtype < 0 ) <nl> { <nl> - __m128i m128 = code = = CMP_GT ? _mm_setzero_si128 ( ) : _mm_set1_epi8 ( - 1 ) ; <nl> - __m128i c128 = _mm_set1_epi8 ( - 128 ) ; <nl> - for ( ; x < = size . width - 16 ; x + = 16 ) <nl> + if ( _dst . fixedType ( ) ) <nl> { <nl> - __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> - __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> - / / no simd for 8u comparison , that ' s why we need the trick <nl> - r00 = _mm_sub_epi8 ( r00 , c128 ) ; <nl> - r10 = _mm_sub_epi8 ( r10 , c128 ) ; <nl> - <nl> - r00 = _mm_xor_si128 ( _mm_cmpgt_epi8 ( r00 , r10 ) , m128 ) ; <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , r00 ) ; <nl> - <nl> + dtype = _dst . depth ( ) ; <nl> + } <nl> + else <nl> + { <nl> + dtype = src1 . depth ( ) ; <nl> } <nl> - } <nl> - # elif CV_NEON <nl> - uint8x16_t mask = code = = CMP_GT ? vdupq_n_u8 ( 0 ) : vdupq_n_u8 ( 255 ) ; <nl> - <nl> - for ( ; x < = size . width - 16 ; x + = 16 ) <nl> - { <nl> - vst1q_u8 ( dst + x , veorq_u8 ( vcgtq_u8 ( vld1q_u8 ( src1 + x ) , vld1q_u8 ( src2 + x ) ) , mask ) ) ; <nl> } <nl> <nl> - # endif <nl> + dtype = CV_MAT_DEPTH ( dtype ) ; <nl> <nl> - for ( ; x < size . width ; x + + ) { <nl> - dst [ x ] = ( uchar ) ( - ( src1 [ x ] > src2 [ x ] ) ^ m ) ; <nl> - } <nl> - } <nl> - } <nl> - else if ( code = = CMP_EQ | | code = = CMP_NE ) <nl> - { <nl> - int m = code = = CMP_EQ ? 0 : 255 ; <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int x = 0 ; <nl> - # if CV_SSE2 <nl> - if ( USE_SSE2 ) <nl> + if ( ! _dst . fixedType ( ) | | dtype = = _dst . depth ( ) ) <nl> { <nl> - __m128i m128 = code = = CMP_EQ ? _mm_setzero_si128 ( ) : _mm_set1_epi8 ( - 1 ) ; <nl> - for ( ; x < = size . width - 16 ; x + = 16 ) <nl> + _dst . create ( src1 . size ( ) , CV_MAKE_TYPE ( dtype , src1 . channels ( ) ) ) ; <nl> + <nl> + if ( dtype = = CV_16S ) <nl> { <nl> - __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> - __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> - r00 = _mm_xor_si128 ( _mm_cmpeq_epi8 ( r00 , r10 ) , m128 ) ; <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , r00 ) ; <nl> + Mat dst = _dst . getMat ( ) ; <nl> + if ( tegra : : subtract_8u8u16s ( src1 , src2 , dst ) ) <nl> + return ; <nl> + } <nl> + else if ( dtype = = CV_32F ) <nl> + { <nl> + Mat dst = _dst . getMat ( ) ; <nl> + if ( tegra : : subtract_8u8u32f ( src1 , src2 , dst ) ) <nl> + return ; <nl> + } <nl> + else if ( dtype = = CV_8S ) <nl> + { <nl> + Mat dst = _dst . getMat ( ) ; <nl> + if ( tegra : : subtract_8u8u8s ( src1 , src2 , dst ) ) <nl> + return ; <nl> } <nl> } <nl> - # elif CV_NEON <nl> - uint8x16_t mask = code = = CMP_EQ ? vdupq_n_u8 ( 0 ) : vdupq_n_u8 ( 255 ) ; <nl> - <nl> - for ( ; x < = size . width - 16 ; x + = 16 ) <nl> - { <nl> - vst1q_u8 ( dst + x , veorq_u8 ( vceqq_u8 ( vld1q_u8 ( src1 + x ) , vld1q_u8 ( src2 + x ) ) , mask ) ) ; <nl> - } <nl> - # endif <nl> - for ( ; x < size . width ; x + + ) <nl> - dst [ x ] = ( uchar ) ( - ( src1 [ x ] = = src2 [ x ] ) ^ m ) ; <nl> } <nl> } <nl> + # endif <nl> + arithm_op ( _src1 , _src2 , _dst , mask , dtype , getSubTab ( ) , false , 0 , OCL_OP_SUB ) ; <nl> } <nl> <nl> - static void cmp8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size size , void * _cmpop ) <nl> + void cv : : absdiff ( InputArray src1 , InputArray src2 , OutputArray dst ) <nl> { <nl> - cmp_ ( src1 , step1 , src2 , step2 , dst , step , size , * ( int * ) _cmpop ) ; <nl> + arithm_op ( src1 , src2 , dst , noArray ( ) , - 1 , getAbsDiffTab ( ) , false , 0 , OCL_OP_ABSDIFF ) ; <nl> } <nl> <nl> - static void cmp16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size size , void * _cmpop ) <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> + * multiply / divide * <nl> + \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + namespace cv <nl> + { <nl> + <nl> + static BinaryFuncC * getMulTab ( ) <nl> { <nl> - # if ARITHM_USE_IPP <nl> - CV_IPP_CHECK ( ) <nl> + static BinaryFuncC mulTab [ ] = <nl> { <nl> - IppCmpOp op = convert_cmp ( * ( int * ) _cmpop ) ; <nl> - if ( op > = 0 ) <nl> - { <nl> - fixSteps ( size , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiCompare_16u_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( size ) , op ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - } <nl> - # endif <nl> - cmp_ ( src1 , step1 , src2 , step2 , dst , step , size , * ( int * ) _cmpop ) ; <nl> + ( BinaryFuncC ) cv : : hal : : mul8u , ( BinaryFuncC ) cv : : hal : : mul8s , ( BinaryFuncC ) cv : : hal : : mul16u , <nl> + ( BinaryFuncC ) cv : : hal : : mul16s , ( BinaryFuncC ) cv : : hal : : mul32s , ( BinaryFuncC ) cv : : hal : : mul32f , <nl> + ( BinaryFuncC ) cv : : hal : : mul64f , 0 <nl> + } ; <nl> + <nl> + return mulTab ; <nl> } <nl> <nl> - static void cmp16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size size , void * _cmpop ) <nl> + static BinaryFuncC * getDivTab ( ) <nl> { <nl> - # if ARITHM_USE_IPP <nl> - CV_IPP_CHECK ( ) <nl> + static BinaryFuncC divTab [ ] = <nl> { <nl> - IppCmpOp op = convert_cmp ( * ( int * ) _cmpop ) ; <nl> - if ( op > = 0 ) <nl> - { <nl> - fixSteps ( size , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiCompare_16s_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( size ) , op ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - } <nl> - # endif <nl> - / / vz optimized cmp_ ( src1 , step1 , src2 , step2 , dst , step , size , * ( int * ) _cmpop ) ; <nl> + ( BinaryFuncC ) cv : : hal : : div8u , ( BinaryFuncC ) cv : : hal : : div8s , ( BinaryFuncC ) cv : : hal : : div16u , <nl> + ( BinaryFuncC ) cv : : hal : : div16s , ( BinaryFuncC ) cv : : hal : : div32s , ( BinaryFuncC ) cv : : hal : : div32f , <nl> + ( BinaryFuncC ) cv : : hal : : div64f , 0 <nl> + } ; <nl> <nl> - int code = * ( int * ) _cmpop ; <nl> - step1 / = sizeof ( src1 [ 0 ] ) ; <nl> - step2 / = sizeof ( src2 [ 0 ] ) ; <nl> - if ( code = = CMP_GE | | code = = CMP_LT ) <nl> - { <nl> - std : : swap ( src1 , src2 ) ; <nl> - std : : swap ( step1 , step2 ) ; <nl> - code = code = = CMP_GE ? CMP_LE : CMP_GT ; <nl> - } <nl> + return divTab ; <nl> + } <nl> <nl> - if ( code = = CMP_GT | | code = = CMP_LE ) <nl> + static BinaryFuncC * getRecipTab ( ) <nl> + { <nl> + static BinaryFuncC recipTab [ ] = <nl> { <nl> - int m = code = = CMP_GT ? 0 : 255 ; <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int x = 0 ; <nl> - # if CV_SSE2 <nl> - if ( USE_SSE2 ) <nl> - { <nl> - __m128i m128 = code = = CMP_GT ? _mm_setzero_si128 ( ) : _mm_set1_epi16 ( - 1 ) ; <nl> - for ( ; x < = size . width - 16 ; x + = 16 ) <nl> - { <nl> - __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> - __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> - r00 = _mm_xor_si128 ( _mm_cmpgt_epi16 ( r00 , r10 ) , m128 ) ; <nl> - __m128i r01 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 8 ) ) ; <nl> - __m128i r11 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 8 ) ) ; <nl> - r01 = _mm_xor_si128 ( _mm_cmpgt_epi16 ( r01 , r11 ) , m128 ) ; <nl> - r11 = _mm_packs_epi16 ( r00 , r01 ) ; <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , r11 ) ; <nl> - } <nl> - if ( x < = size . width - 8 ) <nl> - { <nl> - __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> - __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> - r00 = _mm_xor_si128 ( _mm_cmpgt_epi16 ( r00 , r10 ) , m128 ) ; <nl> - r10 = _mm_packs_epi16 ( r00 , r00 ) ; <nl> - _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , r10 ) ; <nl> + ( BinaryFuncC ) cv : : hal : : recip8u , ( BinaryFuncC ) cv : : hal : : recip8s , ( BinaryFuncC ) cv : : hal : : recip16u , <nl> + ( BinaryFuncC ) cv : : hal : : recip16s , ( BinaryFuncC ) cv : : hal : : recip32s , ( BinaryFuncC ) cv : : hal : : recip32f , <nl> + ( BinaryFuncC ) cv : : hal : : recip64f , 0 <nl> + } ; <nl> <nl> - x + = 8 ; <nl> - } <nl> - } <nl> - # elif CV_NEON <nl> - uint8x16_t mask = code = = CMP_GT ? vdupq_n_u8 ( 0 ) : vdupq_n_u8 ( 255 ) ; <nl> + return recipTab ; <nl> + } <nl> <nl> - for ( ; x < = size . width - 16 ; x + = 16 ) <nl> - { <nl> - int16x8_t in1 = vld1q_s16 ( src1 + x ) ; <nl> - int16x8_t in2 = vld1q_s16 ( src2 + x ) ; <nl> - uint8x8_t t1 = vmovn_u16 ( vcgtq_s16 ( in1 , in2 ) ) ; <nl> + } <nl> <nl> - in1 = vld1q_s16 ( src1 + x + 8 ) ; <nl> - in2 = vld1q_s16 ( src2 + x + 8 ) ; <nl> - uint8x8_t t2 = vmovn_u16 ( vcgtq_s16 ( in1 , in2 ) ) ; <nl> + void cv : : multiply ( InputArray src1 , InputArray src2 , <nl> + OutputArray dst , double scale , int dtype ) <nl> + { <nl> + arithm_op ( src1 , src2 , dst , noArray ( ) , dtype , getMulTab ( ) , <nl> + true , & scale , std : : abs ( scale - 1 . 0 ) < DBL_EPSILON ? OCL_OP_MUL : OCL_OP_MUL_SCALE ) ; <nl> + } <nl> <nl> - vst1q_u8 ( dst + x , veorq_u8 ( vcombine_u8 ( t1 , t2 ) , mask ) ) ; <nl> - } <nl> - # endif <nl> + void cv : : divide ( InputArray src1 , InputArray src2 , <nl> + OutputArray dst , double scale , int dtype ) <nl> + { <nl> + arithm_op ( src1 , src2 , dst , noArray ( ) , dtype , getDivTab ( ) , true , & scale , OCL_OP_DIV_SCALE ) ; <nl> + } <nl> <nl> - for ( ; x < size . width ; x + + ) { <nl> - dst [ x ] = ( uchar ) ( - ( src1 [ x ] > src2 [ x ] ) ^ m ) ; <nl> - } <nl> - } <nl> - } <nl> - else if ( code = = CMP_EQ | | code = = CMP_NE ) <nl> - { <nl> - int m = code = = CMP_EQ ? 0 : 255 ; <nl> - for ( ; size . height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> - { <nl> - int x = 0 ; <nl> - # if CV_SSE2 <nl> - if ( USE_SSE2 ) <nl> - { <nl> - __m128i m128 = code = = CMP_EQ ? _mm_setzero_si128 ( ) : _mm_set1_epi16 ( - 1 ) ; <nl> - for ( ; x < = size . width - 16 ; x + = 16 ) <nl> - { <nl> - __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> - __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> - r00 = _mm_xor_si128 ( _mm_cmpeq_epi16 ( r00 , r10 ) , m128 ) ; <nl> - __m128i r01 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 8 ) ) ; <nl> - __m128i r11 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 8 ) ) ; <nl> - r01 = _mm_xor_si128 ( _mm_cmpeq_epi16 ( r01 , r11 ) , m128 ) ; <nl> - r11 = _mm_packs_epi16 ( r00 , r01 ) ; <nl> - _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , r11 ) ; <nl> - } <nl> - if ( x < = size . width - 8 ) <nl> - { <nl> - __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> - __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> - r00 = _mm_xor_si128 ( _mm_cmpeq_epi16 ( r00 , r10 ) , m128 ) ; <nl> - r10 = _mm_packs_epi16 ( r00 , r00 ) ; <nl> - _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , r10 ) ; <nl> + void cv : : divide ( double scale , InputArray src2 , <nl> + OutputArray dst , int dtype ) <nl> + { <nl> + arithm_op ( src2 , src2 , dst , noArray ( ) , dtype , getRecipTab ( ) , true , & scale , OCL_OP_RECIP_SCALE ) ; <nl> + } <nl> <nl> - x + = 8 ; <nl> - } <nl> - } <nl> - # elif CV_NEON <nl> - uint8x16_t mask = code = = CMP_EQ ? vdupq_n_u8 ( 0 ) : vdupq_n_u8 ( 255 ) ; <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> + * addWeighted * <nl> + \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - for ( ; x < = size . width - 16 ; x + = 16 ) <nl> - { <nl> - int16x8_t in1 = vld1q_s16 ( src1 + x ) ; <nl> - int16x8_t in2 = vld1q_s16 ( src2 + x ) ; <nl> - uint8x8_t t1 = vmovn_u16 ( vceqq_s16 ( in1 , in2 ) ) ; <nl> + namespace cv <nl> + { <nl> <nl> - in1 = vld1q_s16 ( src1 + x + 8 ) ; <nl> - in2 = vld1q_s16 ( src2 + x + 8 ) ; <nl> - uint8x8_t t2 = vmovn_u16 ( vceqq_s16 ( in1 , in2 ) ) ; <nl> + static BinaryFuncC * getAddWeightedTab ( ) <nl> + { <nl> + static BinaryFuncC addWeightedTab [ ] = <nl> + { <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : addWeighted8u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : addWeighted8s ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : addWeighted16u ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : addWeighted16s ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : addWeighted32s ) , ( BinaryFuncC ) cv : : hal : : addWeighted32f , <nl> + ( BinaryFuncC ) cv : : hal : : addWeighted64f , 0 <nl> + } ; <nl> <nl> - vst1q_u8 ( dst + x , veorq_u8 ( vcombine_u8 ( t1 , t2 ) , mask ) ) ; <nl> - } <nl> - # endif <nl> - for ( ; x < size . width ; x + + ) <nl> - dst [ x ] = ( uchar ) ( - ( src1 [ x ] = = src2 [ x ] ) ^ m ) ; <nl> - } <nl> - } <nl> + return addWeightedTab ; <nl> } <nl> <nl> - static void cmp32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size size , void * _cmpop ) <nl> - { <nl> - cmp_ ( src1 , step1 , src2 , step2 , dst , step , size , * ( int * ) _cmpop ) ; <nl> } <nl> <nl> - static void cmp32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size size , void * _cmpop ) <nl> + void cv : : addWeighted ( InputArray src1 , double alpha , InputArray src2 , <nl> + double beta , double gamma , OutputArray dst , int dtype ) <nl> { <nl> - # if ARITHM_USE_IPP <nl> - CV_IPP_CHECK ( ) <nl> - { <nl> - IppCmpOp op = convert_cmp ( * ( int * ) _cmpop ) ; <nl> - if ( op > = 0 ) <nl> - { <nl> - fixSteps ( size , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; <nl> - if ( 0 < = ippiCompare_32f_C1R ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( size ) , op ) ) <nl> - { <nl> - CV_IMPL_ADD ( CV_IMPL_IPP ) ; <nl> - return ; <nl> - } <nl> - setIppErrorStatus ( ) ; <nl> - } <nl> - } <nl> - # endif <nl> - cmp_ ( src1 , step1 , src2 , step2 , dst , step , size , * ( int * ) _cmpop ) ; <nl> + double scalars [ ] = { alpha , beta , gamma } ; <nl> + arithm_op ( src1 , src2 , dst , noArray ( ) , dtype , getAddWeightedTab ( ) , true , scalars , OCL_OP_ADDW ) ; <nl> } <nl> <nl> - static void cmp64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , <nl> - uchar * dst , size_t step , Size size , void * _cmpop ) <nl> + <nl> + / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> + * compare * <nl> + \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> + <nl> + namespace cv <nl> { <nl> - cmp_ ( src1 , step1 , src2 , step2 , dst , step , size , * ( int * ) _cmpop ) ; <nl> - } <nl> <nl> - static BinaryFunc getCmpFunc ( int depth ) <nl> + static BinaryFuncC getCmpFunc ( int depth ) <nl> { <nl> - static BinaryFunc cmpTab [ ] = <nl> + static BinaryFuncC cmpTab [ ] = <nl> { <nl> - ( BinaryFunc ) GET_OPTIMIZED ( cmp8u ) , ( BinaryFunc ) GET_OPTIMIZED ( cmp8s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( cmp16u ) , ( BinaryFunc ) GET_OPTIMIZED ( cmp16s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( cmp32s ) , <nl> - ( BinaryFunc ) GET_OPTIMIZED ( cmp32f ) , ( BinaryFunc ) cmp64f , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : cmp8u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : cmp8s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : cmp16u ) , ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : cmp16s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : cmp32s ) , <nl> + ( BinaryFuncC ) GET_OPTIMIZED ( cv : : hal : : cmp32f ) , ( BinaryFuncC ) cv : : hal : : cmp64f , <nl> 0 <nl> } ; <nl> <nl> void cv : : compare ( InputArray _src1 , InputArray _src2 , OutputArray _dst , int op ) <nl> _dst . create ( src1 . size ( ) , CV_8UC ( cn ) ) ; <nl> Mat dst = _dst . getMat ( ) ; <nl> Size sz = getContinuousSize ( src1 , src2 , dst , src1 . channels ( ) ) ; <nl> - getCmpFunc ( src1 . depth ( ) ) ( src1 . ptr ( ) , src1 . step , src2 . ptr ( ) , src2 . step , dst . ptr ( ) , dst . step , sz , & op ) ; <nl> + getCmpFunc ( src1 . depth ( ) ) ( src1 . ptr ( ) , src1 . step , src2 . ptr ( ) , src2 . step , dst . ptr ( ) , dst . step , sz . width , sz . height , & op ) ; <nl> return ; <nl> } <nl> <nl> void cv : : compare ( InputArray _src1 , InputArray _src2 , OutputArray _dst , int op ) <nl> <nl> size_t esz = src1 . elemSize ( ) ; <nl> size_t blocksize0 = ( size_t ) ( BLOCK_SIZE + esz - 1 ) / esz ; <nl> - BinaryFunc func = getCmpFunc ( depth1 ) ; <nl> + BinaryFuncC func = getCmpFunc ( depth1 ) ; <nl> <nl> if ( ! haveScalar ) <nl> { <nl> void cv : : compare ( InputArray _src1 , InputArray _src2 , OutputArray _dst , int op ) <nl> size_t total = it . size ; <nl> <nl> for ( size_t i = 0 ; i < it . nplanes ; i + + , + + it ) <nl> - func ( ptrs [ 0 ] , 0 , ptrs [ 1 ] , 0 , ptrs [ 2 ] , 0 , Size ( ( int ) total , 1 ) , & op ) ; <nl> + func ( ptrs [ 0 ] , 0 , ptrs [ 1 ] , 0 , ptrs [ 2 ] , 0 , ( int ) total , 1 , & op ) ; <nl> } <nl> else <nl> { <nl> void cv : : compare ( InputArray _src1 , InputArray _src2 , OutputArray _dst , int op ) <nl> for ( size_t j = 0 ; j < total ; j + = blocksize ) <nl> { <nl> int bsz = ( int ) MIN ( total - j , blocksize ) ; <nl> - func ( ptrs [ 0 ] , 0 , buf , 0 , ptrs [ 1 ] , 0 , Size ( bsz , 1 ) , & op ) ; <nl> + func ( ptrs [ 0 ] , 0 , buf , 0 , ptrs [ 1 ] , 0 , bsz , 1 , & op ) ; <nl> ptrs [ 0 ] + = bsz * esz ; <nl> ptrs [ 1 ] + = bsz ; <nl> } <nl> mmm a / modules / core / src / convert . cpp <nl> ppp b / modules / core / src / convert . cpp <nl> <nl> / / M * / <nl> <nl> # include " precomp . hpp " <nl> + <nl> # include " opencl_kernels_core . hpp " <nl> <nl> # ifdef __APPLE__ <nl> <nl> # define CV_NEON 0 <nl> # endif <nl> <nl> - namespace cv <nl> - { <nl> <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> * split & merge * <nl> \ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> <nl> - # if CV_NEON <nl> - template < typename T > struct VSplit2 ; <nl> - template < typename T > struct VSplit3 ; <nl> - template < typename T > struct VSplit4 ; <nl> - <nl> - # define SPLIT2_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> - template < > \ <nl> - struct name < data_type > \ <nl> - { \ <nl> - void operator ( ) ( const data_type * src , data_type * dst0 , \ <nl> - data_type * dst1 ) const \ <nl> - { \ <nl> - reg_type r = load_func ( src ) ; \ <nl> - store_func ( dst0 , r . val [ 0 ] ) ; \ <nl> - store_func ( dst1 , r . val [ 1 ] ) ; \ <nl> - } \ <nl> - } <nl> - <nl> - # define SPLIT3_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> - template < > \ <nl> - struct name < data_type > \ <nl> - { \ <nl> - void operator ( ) ( const data_type * src , data_type * dst0 , data_type * dst1 , \ <nl> - data_type * dst2 ) const \ <nl> - { \ <nl> - reg_type r = load_func ( src ) ; \ <nl> - store_func ( dst0 , r . val [ 0 ] ) ; \ <nl> - store_func ( dst1 , r . val [ 1 ] ) ; \ <nl> - store_func ( dst2 , r . val [ 2 ] ) ; \ <nl> - } \ <nl> - } <nl> - <nl> - # define SPLIT4_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> - template < > \ <nl> - struct name < data_type > \ <nl> - { \ <nl> - void operator ( ) ( const data_type * src , data_type * dst0 , data_type * dst1 , \ <nl> - data_type * dst2 , data_type * dst3 ) const \ <nl> - { \ <nl> - reg_type r = load_func ( src ) ; \ <nl> - store_func ( dst0 , r . val [ 0 ] ) ; \ <nl> - store_func ( dst1 , r . val [ 1 ] ) ; \ <nl> - store_func ( dst2 , r . val [ 2 ] ) ; \ <nl> - store_func ( dst3 , r . val [ 3 ] ) ; \ <nl> - } \ <nl> - } <nl> - <nl> - SPLIT2_KERNEL_TEMPLATE ( VSplit2 , uchar , uint8x16x2_t , vld2q_u8 , vst1q_u8 ) ; <nl> - SPLIT2_KERNEL_TEMPLATE ( VSplit2 , ushort , uint16x8x2_t , vld2q_u16 , vst1q_u16 ) ; <nl> - SPLIT2_KERNEL_TEMPLATE ( VSplit2 , int , int32x4x2_t , vld2q_s32 , vst1q_s32 ) ; <nl> - SPLIT2_KERNEL_TEMPLATE ( VSplit2 , int64 , int64x1x2_t , vld2_s64 , vst1_s64 ) ; <nl> - <nl> - SPLIT3_KERNEL_TEMPLATE ( VSplit3 , uchar , uint8x16x3_t , vld3q_u8 , vst1q_u8 ) ; <nl> - SPLIT3_KERNEL_TEMPLATE ( VSplit3 , ushort , uint16x8x3_t , vld3q_u16 , vst1q_u16 ) ; <nl> - SPLIT3_KERNEL_TEMPLATE ( VSplit3 , int , int32x4x3_t , vld3q_s32 , vst1q_s32 ) ; <nl> - SPLIT3_KERNEL_TEMPLATE ( VSplit3 , int64 , int64x1x3_t , vld3_s64 , vst1_s64 ) ; <nl> - <nl> - SPLIT4_KERNEL_TEMPLATE ( VSplit4 , uchar , uint8x16x4_t , vld4q_u8 , vst1q_u8 ) ; <nl> - SPLIT4_KERNEL_TEMPLATE ( VSplit4 , ushort , uint16x8x4_t , vld4q_u16 , vst1q_u16 ) ; <nl> - SPLIT4_KERNEL_TEMPLATE ( VSplit4 , int , int32x4x4_t , vld4q_s32 , vst1q_s32 ) ; <nl> - SPLIT4_KERNEL_TEMPLATE ( VSplit4 , int64 , int64x1x4_t , vld4_s64 , vst1_s64 ) ; <nl> - <nl> - # elif CV_SSE2 <nl> - <nl> - template < typename T > <nl> - struct VSplit2 <nl> - { <nl> - VSplit2 ( ) : support ( false ) { } <nl> - void operator ( ) ( const T * , T * , T * ) const { } <nl> - <nl> - bool support ; <nl> - } ; <nl> - <nl> - template < typename T > <nl> - struct VSplit3 <nl> - { <nl> - VSplit3 ( ) : support ( false ) { } <nl> - void operator ( ) ( const T * , T * , T * , T * ) const { } <nl> - <nl> - bool support ; <nl> - } ; <nl> - <nl> - template < typename T > <nl> - struct VSplit4 <nl> - { <nl> - VSplit4 ( ) : support ( false ) { } <nl> - void operator ( ) ( const T * , T * , T * , T * , T * ) const { } <nl> - <nl> - bool support ; <nl> - } ; <nl> - <nl> - # define SPLIT2_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_deinterleave , flavor ) \ <nl> - template < > \ <nl> - struct VSplit2 < data_type > \ <nl> - { \ <nl> - enum \ <nl> - { \ <nl> - ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> - } ; \ <nl> - \ <nl> - VSplit2 ( ) \ <nl> - { \ <nl> - support = checkHardwareSupport ( CV_CPU_SSE2 ) ; \ <nl> - } \ <nl> - \ <nl> - void operator ( ) ( const data_type * src , \ <nl> - data_type * dst0 , data_type * dst1 ) const \ <nl> - { \ <nl> - reg_type v_src0 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src ) ) ; \ <nl> - reg_type v_src1 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC ) ) ; \ <nl> - reg_type v_src2 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 2 ) ) ; \ <nl> - reg_type v_src3 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 3 ) ) ; \ <nl> - \ <nl> - _mm_deinterleave ( v_src0 , v_src1 , v_src2 , v_src3 ) ; \ <nl> - \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 ) , v_src0 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 ) , v_src2 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 + ELEMS_IN_VEC ) , v_src3 ) ; \ <nl> - } \ <nl> - \ <nl> - bool support ; \ <nl> - } <nl> - <nl> - # define SPLIT3_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_deinterleave , flavor ) \ <nl> - template < > \ <nl> - struct VSplit3 < data_type > \ <nl> - { \ <nl> - enum \ <nl> - { \ <nl> - ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> - } ; \ <nl> - \ <nl> - VSplit3 ( ) \ <nl> - { \ <nl> - support = checkHardwareSupport ( CV_CPU_SSE2 ) ; \ <nl> - } \ <nl> - \ <nl> - void operator ( ) ( const data_type * src , \ <nl> - data_type * dst0 , data_type * dst1 , data_type * dst2 ) const \ <nl> - { \ <nl> - reg_type v_src0 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src ) ) ; \ <nl> - reg_type v_src1 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC ) ) ; \ <nl> - reg_type v_src2 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 2 ) ) ; \ <nl> - reg_type v_src3 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 3 ) ) ; \ <nl> - reg_type v_src4 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 4 ) ) ; \ <nl> - reg_type v_src5 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 5 ) ) ; \ <nl> - \ <nl> - _mm_deinterleave ( v_src0 , v_src1 , v_src2 , \ <nl> - v_src3 , v_src4 , v_src5 ) ; \ <nl> - \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 ) , v_src0 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 ) , v_src2 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 + ELEMS_IN_VEC ) , v_src3 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst2 ) , v_src4 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst2 + ELEMS_IN_VEC ) , v_src5 ) ; \ <nl> - } \ <nl> - \ <nl> - bool support ; \ <nl> - } <nl> - <nl> - # define SPLIT4_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_deinterleave , flavor ) \ <nl> - template < > \ <nl> - struct VSplit4 < data_type > \ <nl> - { \ <nl> - enum \ <nl> - { \ <nl> - ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> - } ; \ <nl> - \ <nl> - VSplit4 ( ) \ <nl> - { \ <nl> - support = checkHardwareSupport ( CV_CPU_SSE2 ) ; \ <nl> - } \ <nl> - \ <nl> - void operator ( ) ( const data_type * src , data_type * dst0 , data_type * dst1 , \ <nl> - data_type * dst2 , data_type * dst3 ) const \ <nl> - { \ <nl> - reg_type v_src0 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src ) ) ; \ <nl> - reg_type v_src1 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC ) ) ; \ <nl> - reg_type v_src2 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 2 ) ) ; \ <nl> - reg_type v_src3 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 3 ) ) ; \ <nl> - reg_type v_src4 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 4 ) ) ; \ <nl> - reg_type v_src5 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 5 ) ) ; \ <nl> - reg_type v_src6 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 6 ) ) ; \ <nl> - reg_type v_src7 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 7 ) ) ; \ <nl> - \ <nl> - _mm_deinterleave ( v_src0 , v_src1 , v_src2 , v_src3 , \ <nl> - v_src4 , v_src5 , v_src6 , v_src7 ) ; \ <nl> - \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 ) , v_src0 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 ) , v_src2 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 + ELEMS_IN_VEC ) , v_src3 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst2 ) , v_src4 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst2 + ELEMS_IN_VEC ) , v_src5 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst3 ) , v_src6 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst3 + ELEMS_IN_VEC ) , v_src7 ) ; \ <nl> - } \ <nl> - \ <nl> - bool support ; \ <nl> - } <nl> - <nl> - SPLIT2_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_deinterleave_epi8 , si128 ) ; <nl> - SPLIT2_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_deinterleave_epi16 , si128 ) ; <nl> - SPLIT2_KERNEL_TEMPLATE ( int , __m128 , float , _mm_deinterleave_ps , ps ) ; <nl> - <nl> - SPLIT3_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_deinterleave_epi8 , si128 ) ; <nl> - SPLIT3_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_deinterleave_epi16 , si128 ) ; <nl> - SPLIT3_KERNEL_TEMPLATE ( int , __m128 , float , _mm_deinterleave_ps , ps ) ; <nl> - <nl> - SPLIT4_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_deinterleave_epi8 , si128 ) ; <nl> - SPLIT4_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_deinterleave_epi16 , si128 ) ; <nl> - SPLIT4_KERNEL_TEMPLATE ( int , __m128 , float , _mm_deinterleave_ps , ps ) ; <nl> - <nl> - # endif <nl> - <nl> - template < typename T > static void <nl> - split_ ( const T * src , T * * dst , int len , int cn ) <nl> - { <nl> - int k = cn % 4 ? cn % 4 : 4 ; <nl> - int i , j ; <nl> - if ( k = = 1 ) <nl> - { <nl> - T * dst0 = dst [ 0 ] ; <nl> - <nl> - if ( cn = = 1 ) <nl> - { <nl> - memcpy ( dst0 , src , len * sizeof ( T ) ) ; <nl> - } <nl> - else <nl> - { <nl> - for ( i = 0 , j = 0 ; i < len ; i + + , j + = cn ) <nl> - dst0 [ i ] = src [ j ] ; <nl> - } <nl> - } <nl> - else if ( k = = 2 ) <nl> - { <nl> - T * dst0 = dst [ 0 ] , * dst1 = dst [ 1 ] ; <nl> - i = j = 0 ; <nl> - <nl> - # if CV_NEON <nl> - if ( cn = = 2 ) <nl> - { <nl> - int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> - int inc_j = 2 * inc_i ; <nl> - <nl> - VSplit2 < T > vsplit ; <nl> - for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vsplit ( src + j , dst0 + i , dst1 + i ) ; <nl> - } <nl> - # elif CV_SSE2 <nl> - if ( cn = = 2 ) <nl> - { <nl> - int inc_i = 32 / sizeof ( T ) ; <nl> - int inc_j = 2 * inc_i ; <nl> - <nl> - VSplit2 < T > vsplit ; <nl> - if ( vsplit . support ) <nl> - { <nl> - for ( ; i < = len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vsplit ( src + j , dst0 + i , dst1 + i ) ; <nl> - } <nl> - } <nl> - # endif <nl> - for ( ; i < len ; i + + , j + = cn ) <nl> - { <nl> - dst0 [ i ] = src [ j ] ; <nl> - dst1 [ i ] = src [ j + 1 ] ; <nl> - } <nl> - } <nl> - else if ( k = = 3 ) <nl> - { <nl> - T * dst0 = dst [ 0 ] , * dst1 = dst [ 1 ] , * dst2 = dst [ 2 ] ; <nl> - i = j = 0 ; <nl> - <nl> - # if CV_NEON <nl> - if ( cn = = 3 ) <nl> - { <nl> - int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> - int inc_j = 3 * inc_i ; <nl> - <nl> - VSplit3 < T > vsplit ; <nl> - for ( ; i < = len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vsplit ( src + j , dst0 + i , dst1 + i , dst2 + i ) ; <nl> - } <nl> - # elif CV_SSE2 <nl> - if ( cn = = 3 ) <nl> - { <nl> - int inc_i = 32 / sizeof ( T ) ; <nl> - int inc_j = 3 * inc_i ; <nl> - <nl> - VSplit3 < T > vsplit ; <nl> - <nl> - if ( vsplit . support ) <nl> - { <nl> - for ( ; i < = len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vsplit ( src + j , dst0 + i , dst1 + i , dst2 + i ) ; <nl> - } <nl> - } <nl> - # endif <nl> - for ( ; i < len ; i + + , j + = cn ) <nl> - { <nl> - dst0 [ i ] = src [ j ] ; <nl> - dst1 [ i ] = src [ j + 1 ] ; <nl> - dst2 [ i ] = src [ j + 2 ] ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - T * dst0 = dst [ 0 ] , * dst1 = dst [ 1 ] , * dst2 = dst [ 2 ] , * dst3 = dst [ 3 ] ; <nl> - i = j = 0 ; <nl> - <nl> - # if CV_NEON <nl> - if ( cn = = 4 ) <nl> - { <nl> - int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> - int inc_j = 4 * inc_i ; <nl> - <nl> - VSplit4 < T > vsplit ; <nl> - for ( ; i < = len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vsplit ( src + j , dst0 + i , dst1 + i , dst2 + i , dst3 + i ) ; <nl> - } <nl> - # elif CV_SSE2 <nl> - if ( cn = = 4 ) <nl> - { <nl> - int inc_i = 32 / sizeof ( T ) ; <nl> - int inc_j = 4 * inc_i ; <nl> - <nl> - VSplit4 < T > vsplit ; <nl> - if ( vsplit . support ) <nl> - { <nl> - for ( ; i < = len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vsplit ( src + j , dst0 + i , dst1 + i , dst2 + i , dst3 + i ) ; <nl> - } <nl> - } <nl> - # endif <nl> - for ( ; i < len ; i + + , j + = cn ) <nl> - { <nl> - dst0 [ i ] = src [ j ] ; dst1 [ i ] = src [ j + 1 ] ; <nl> - dst2 [ i ] = src [ j + 2 ] ; dst3 [ i ] = src [ j + 3 ] ; <nl> - } <nl> - } <nl> - <nl> - for ( ; k < cn ; k + = 4 ) <nl> - { <nl> - T * dst0 = dst [ k ] , * dst1 = dst [ k + 1 ] , * dst2 = dst [ k + 2 ] , * dst3 = dst [ k + 3 ] ; <nl> - for ( i = 0 , j = k ; i < len ; i + + , j + = cn ) <nl> - { <nl> - dst0 [ i ] = src [ j ] ; dst1 [ i ] = src [ j + 1 ] ; <nl> - dst2 [ i ] = src [ j + 2 ] ; dst3 [ i ] = src [ j + 3 ] ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - <nl> - # if CV_NEON <nl> - template < typename T > struct VMerge2 ; <nl> - template < typename T > struct VMerge3 ; <nl> - template < typename T > struct VMerge4 ; <nl> - <nl> - # define MERGE2_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> - template < > \ <nl> - struct name < data_type > { \ <nl> - void operator ( ) ( const data_type * src0 , const data_type * src1 , \ <nl> - data_type * dst ) { \ <nl> - reg_type r ; \ <nl> - r . val [ 0 ] = load_func ( src0 ) ; \ <nl> - r . val [ 1 ] = load_func ( src1 ) ; \ <nl> - store_func ( dst , r ) ; \ <nl> - } \ <nl> - } <nl> - <nl> - # define MERGE3_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> - template < > \ <nl> - struct name < data_type > { \ <nl> - void operator ( ) ( const data_type * src0 , const data_type * src1 , \ <nl> - const data_type * src2 , data_type * dst ) { \ <nl> - reg_type r ; \ <nl> - r . val [ 0 ] = load_func ( src0 ) ; \ <nl> - r . val [ 1 ] = load_func ( src1 ) ; \ <nl> - r . val [ 2 ] = load_func ( src2 ) ; \ <nl> - store_func ( dst , r ) ; \ <nl> - } \ <nl> - } <nl> - <nl> - # define MERGE4_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> - template < > \ <nl> - struct name < data_type > { \ <nl> - void operator ( ) ( const data_type * src0 , const data_type * src1 , \ <nl> - const data_type * src2 , const data_type * src3 , \ <nl> - data_type * dst ) { \ <nl> - reg_type r ; \ <nl> - r . val [ 0 ] = load_func ( src0 ) ; \ <nl> - r . val [ 1 ] = load_func ( src1 ) ; \ <nl> - r . val [ 2 ] = load_func ( src2 ) ; \ <nl> - r . val [ 3 ] = load_func ( src3 ) ; \ <nl> - store_func ( dst , r ) ; \ <nl> - } \ <nl> - } <nl> - <nl> - MERGE2_KERNEL_TEMPLATE ( VMerge2 , uchar , uint8x16x2_t , vld1q_u8 , vst2q_u8 ) ; <nl> - MERGE2_KERNEL_TEMPLATE ( VMerge2 , ushort , uint16x8x2_t , vld1q_u16 , vst2q_u16 ) ; <nl> - MERGE2_KERNEL_TEMPLATE ( VMerge2 , int , int32x4x2_t , vld1q_s32 , vst2q_s32 ) ; <nl> - MERGE2_KERNEL_TEMPLATE ( VMerge2 , int64 , int64x1x2_t , vld1_s64 , vst2_s64 ) ; <nl> - <nl> - MERGE3_KERNEL_TEMPLATE ( VMerge3 , uchar , uint8x16x3_t , vld1q_u8 , vst3q_u8 ) ; <nl> - MERGE3_KERNEL_TEMPLATE ( VMerge3 , ushort , uint16x8x3_t , vld1q_u16 , vst3q_u16 ) ; <nl> - MERGE3_KERNEL_TEMPLATE ( VMerge3 , int , int32x4x3_t , vld1q_s32 , vst3q_s32 ) ; <nl> - MERGE3_KERNEL_TEMPLATE ( VMerge3 , int64 , int64x1x3_t , vld1_s64 , vst3_s64 ) ; <nl> - <nl> - MERGE4_KERNEL_TEMPLATE ( VMerge4 , uchar , uint8x16x4_t , vld1q_u8 , vst4q_u8 ) ; <nl> - MERGE4_KERNEL_TEMPLATE ( VMerge4 , ushort , uint16x8x4_t , vld1q_u16 , vst4q_u16 ) ; <nl> - MERGE4_KERNEL_TEMPLATE ( VMerge4 , int , int32x4x4_t , vld1q_s32 , vst4q_s32 ) ; <nl> - MERGE4_KERNEL_TEMPLATE ( VMerge4 , int64 , int64x1x4_t , vld1_s64 , vst4_s64 ) ; <nl> - <nl> - # elif CV_SSE2 <nl> - <nl> - template < typename T > <nl> - struct VMerge2 <nl> - { <nl> - VMerge2 ( ) : support ( false ) { } <nl> - void operator ( ) ( const T * , const T * , T * ) const { } <nl> - <nl> - bool support ; <nl> - } ; <nl> - <nl> - template < typename T > <nl> - struct VMerge3 <nl> - { <nl> - VMerge3 ( ) : support ( false ) { } <nl> - void operator ( ) ( const T * , const T * , const T * , T * ) const { } <nl> - <nl> - bool support ; <nl> - } ; <nl> - <nl> - template < typename T > <nl> - struct VMerge4 <nl> - { <nl> - VMerge4 ( ) : support ( false ) { } <nl> - void operator ( ) ( const T * , const T * , const T * , const T * , T * ) const { } <nl> - <nl> - bool support ; <nl> - } ; <nl> - <nl> - # define MERGE2_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_interleave , flavor , se ) \ <nl> - template < > \ <nl> - struct VMerge2 < data_type > \ <nl> - { \ <nl> - enum \ <nl> - { \ <nl> - ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> - } ; \ <nl> - \ <nl> - VMerge2 ( ) \ <nl> - { \ <nl> - support = checkHardwareSupport ( se ) ; \ <nl> - } \ <nl> - \ <nl> - void operator ( ) ( const data_type * src0 , const data_type * src1 , \ <nl> - data_type * dst ) const \ <nl> - { \ <nl> - reg_type v_src0 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 ) ) ; \ <nl> - reg_type v_src1 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 + ELEMS_IN_VEC ) ) ; \ <nl> - reg_type v_src2 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 ) ) ; \ <nl> - reg_type v_src3 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 + ELEMS_IN_VEC ) ) ; \ <nl> - \ <nl> - _mm_interleave ( v_src0 , v_src1 , v_src2 , v_src3 ) ; \ <nl> - \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst ) , v_src0 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 2 ) , v_src2 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 3 ) , v_src3 ) ; \ <nl> - } \ <nl> - \ <nl> - bool support ; \ <nl> - } <nl> - <nl> - # define MERGE3_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_interleave , flavor , se ) \ <nl> - template < > \ <nl> - struct VMerge3 < data_type > \ <nl> - { \ <nl> - enum \ <nl> - { \ <nl> - ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> - } ; \ <nl> - \ <nl> - VMerge3 ( ) \ <nl> - { \ <nl> - support = checkHardwareSupport ( se ) ; \ <nl> - } \ <nl> - \ <nl> - void operator ( ) ( const data_type * src0 , const data_type * src1 , const data_type * src2 , \ <nl> - data_type * dst ) const \ <nl> - { \ <nl> - reg_type v_src0 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 ) ) ; \ <nl> - reg_type v_src1 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 + ELEMS_IN_VEC ) ) ; \ <nl> - reg_type v_src2 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 ) ) ; \ <nl> - reg_type v_src3 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 + ELEMS_IN_VEC ) ) ; \ <nl> - reg_type v_src4 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src2 ) ) ; \ <nl> - reg_type v_src5 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src2 + ELEMS_IN_VEC ) ) ; \ <nl> - \ <nl> - _mm_interleave ( v_src0 , v_src1 , v_src2 , \ <nl> - v_src3 , v_src4 , v_src5 ) ; \ <nl> - \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst ) , v_src0 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 2 ) , v_src2 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 3 ) , v_src3 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 4 ) , v_src4 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 5 ) , v_src5 ) ; \ <nl> - } \ <nl> - \ <nl> - bool support ; \ <nl> - } <nl> - <nl> - # define MERGE4_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_interleave , flavor , se ) \ <nl> - template < > \ <nl> - struct VMerge4 < data_type > \ <nl> - { \ <nl> - enum \ <nl> - { \ <nl> - ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> - } ; \ <nl> - \ <nl> - VMerge4 ( ) \ <nl> - { \ <nl> - support = checkHardwareSupport ( se ) ; \ <nl> - } \ <nl> - \ <nl> - void operator ( ) ( const data_type * src0 , const data_type * src1 , \ <nl> - const data_type * src2 , const data_type * src3 , \ <nl> - data_type * dst ) const \ <nl> - { \ <nl> - reg_type v_src0 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 ) ) ; \ <nl> - reg_type v_src1 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 + ELEMS_IN_VEC ) ) ; \ <nl> - reg_type v_src2 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 ) ) ; \ <nl> - reg_type v_src3 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 + ELEMS_IN_VEC ) ) ; \ <nl> - reg_type v_src4 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src2 ) ) ; \ <nl> - reg_type v_src5 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src2 + ELEMS_IN_VEC ) ) ; \ <nl> - reg_type v_src6 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src3 ) ) ; \ <nl> - reg_type v_src7 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src3 + ELEMS_IN_VEC ) ) ; \ <nl> - \ <nl> - _mm_interleave ( v_src0 , v_src1 , v_src2 , v_src3 , \ <nl> - v_src4 , v_src5 , v_src6 , v_src7 ) ; \ <nl> - \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst ) , v_src0 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 2 ) , v_src2 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 3 ) , v_src3 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 4 ) , v_src4 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 5 ) , v_src5 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 6 ) , v_src6 ) ; \ <nl> - _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 7 ) , v_src7 ) ; \ <nl> - } \ <nl> - \ <nl> - bool support ; \ <nl> - } <nl> - <nl> - MERGE2_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_interleave_epi8 , si128 , CV_CPU_SSE2 ) ; <nl> - MERGE3_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_interleave_epi8 , si128 , CV_CPU_SSE2 ) ; <nl> - MERGE4_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_interleave_epi8 , si128 , CV_CPU_SSE2 ) ; <nl> - <nl> - # if CV_SSE4_1 <nl> - MERGE2_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_interleave_epi16 , si128 , CV_CPU_SSE4_1 ) ; <nl> - MERGE3_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_interleave_epi16 , si128 , CV_CPU_SSE4_1 ) ; <nl> - MERGE4_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_interleave_epi16 , si128 , CV_CPU_SSE4_1 ) ; <nl> - # endif <nl> - <nl> - MERGE2_KERNEL_TEMPLATE ( int , __m128 , float , _mm_interleave_ps , ps , CV_CPU_SSE2 ) ; <nl> - MERGE3_KERNEL_TEMPLATE ( int , __m128 , float , _mm_interleave_ps , ps , CV_CPU_SSE2 ) ; <nl> - MERGE4_KERNEL_TEMPLATE ( int , __m128 , float , _mm_interleave_ps , ps , CV_CPU_SSE2 ) ; <nl> - <nl> - # endif <nl> - <nl> - template < typename T > static void <nl> - merge_ ( const T * * src , T * dst , int len , int cn ) <nl> - { <nl> - int k = cn % 4 ? cn % 4 : 4 ; <nl> - int i , j ; <nl> - if ( k = = 1 ) <nl> - { <nl> - const T * src0 = src [ 0 ] ; <nl> - for ( i = j = 0 ; i < len ; i + + , j + = cn ) <nl> - dst [ j ] = src0 [ i ] ; <nl> - } <nl> - else if ( k = = 2 ) <nl> - { <nl> - const T * src0 = src [ 0 ] , * src1 = src [ 1 ] ; <nl> - i = j = 0 ; <nl> - # if CV_NEON <nl> - if ( cn = = 2 ) <nl> - { <nl> - int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> - int inc_j = 2 * inc_i ; <nl> - <nl> - VMerge2 < T > vmerge ; <nl> - for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vmerge ( src0 + i , src1 + i , dst + j ) ; <nl> - } <nl> - # elif CV_SSE2 <nl> - if ( cn = = 2 ) <nl> - { <nl> - int inc_i = 32 / sizeof ( T ) ; <nl> - int inc_j = 2 * inc_i ; <nl> - <nl> - VMerge2 < T > vmerge ; <nl> - if ( vmerge . support ) <nl> - for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vmerge ( src0 + i , src1 + i , dst + j ) ; <nl> - } <nl> - # endif <nl> - for ( ; i < len ; i + + , j + = cn ) <nl> - { <nl> - dst [ j ] = src0 [ i ] ; <nl> - dst [ j + 1 ] = src1 [ i ] ; <nl> - } <nl> - } <nl> - else if ( k = = 3 ) <nl> - { <nl> - const T * src0 = src [ 0 ] , * src1 = src [ 1 ] , * src2 = src [ 2 ] ; <nl> - i = j = 0 ; <nl> - # if CV_NEON <nl> - if ( cn = = 3 ) <nl> - { <nl> - int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> - int inc_j = 3 * inc_i ; <nl> - <nl> - VMerge3 < T > vmerge ; <nl> - for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vmerge ( src0 + i , src1 + i , src2 + i , dst + j ) ; <nl> - } <nl> - # elif CV_SSE2 <nl> - if ( cn = = 3 ) <nl> - { <nl> - int inc_i = 32 / sizeof ( T ) ; <nl> - int inc_j = 3 * inc_i ; <nl> - <nl> - VMerge3 < T > vmerge ; <nl> - if ( vmerge . support ) <nl> - for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vmerge ( src0 + i , src1 + i , src2 + i , dst + j ) ; <nl> - } <nl> - # endif <nl> - for ( ; i < len ; i + + , j + = cn ) <nl> - { <nl> - dst [ j ] = src0 [ i ] ; <nl> - dst [ j + 1 ] = src1 [ i ] ; <nl> - dst [ j + 2 ] = src2 [ i ] ; <nl> - } <nl> - } <nl> - else <nl> - { <nl> - const T * src0 = src [ 0 ] , * src1 = src [ 1 ] , * src2 = src [ 2 ] , * src3 = src [ 3 ] ; <nl> - i = j = 0 ; <nl> - # if CV_NEON <nl> - if ( cn = = 4 ) <nl> - { <nl> - int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> - int inc_j = 4 * inc_i ; <nl> - <nl> - VMerge4 < T > vmerge ; <nl> - for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vmerge ( src0 + i , src1 + i , src2 + i , src3 + i , dst + j ) ; <nl> - } <nl> - # elif CV_SSE2 <nl> - if ( cn = = 4 ) <nl> - { <nl> - int inc_i = 32 / sizeof ( T ) ; <nl> - int inc_j = 4 * inc_i ; <nl> - <nl> - VMerge4 < T > vmerge ; <nl> - if ( vmerge . support ) <nl> - for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> - vmerge ( src0 + i , src1 + i , src2 + i , src3 + i , dst + j ) ; <nl> - } <nl> - # endif <nl> - for ( ; i < len ; i + + , j + = cn ) <nl> - { <nl> - dst [ j ] = src0 [ i ] ; dst [ j + 1 ] = src1 [ i ] ; <nl> - dst [ j + 2 ] = src2 [ i ] ; dst [ j + 3 ] = src3 [ i ] ; <nl> - } <nl> - } <nl> - <nl> - for ( ; k < cn ; k + = 4 ) <nl> - { <nl> - const T * src0 = src [ k ] , * src1 = src [ k + 1 ] , * src2 = src [ k + 2 ] , * src3 = src [ k + 3 ] ; <nl> - for ( i = 0 , j = k ; i < len ; i + + , j + = cn ) <nl> - { <nl> - dst [ j ] = src0 [ i ] ; dst [ j + 1 ] = src1 [ i ] ; <nl> - dst [ j + 2 ] = src2 [ i ] ; dst [ j + 3 ] = src3 [ i ] ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - static void split8u ( const uchar * src , uchar * * dst , int len , int cn ) <nl> - { <nl> - split_ ( src , dst , len , cn ) ; <nl> - } <nl> - <nl> - static void split16u ( const ushort * src , ushort * * dst , int len , int cn ) <nl> - { <nl> - split_ ( src , dst , len , cn ) ; <nl> - } <nl> - <nl> - static void split32s ( const int * src , int * * dst , int len , int cn ) <nl> - { <nl> - split_ ( src , dst , len , cn ) ; <nl> - } <nl> - <nl> - static void split64s ( const int64 * src , int64 * * dst , int len , int cn ) <nl> - { <nl> - split_ ( src , dst , len , cn ) ; <nl> - } <nl> - <nl> - static void merge8u ( const uchar * * src , uchar * dst , int len , int cn ) <nl> - { <nl> - merge_ ( src , dst , len , cn ) ; <nl> - } <nl> - <nl> - static void merge16u ( const ushort * * src , ushort * dst , int len , int cn ) <nl> - { <nl> - merge_ ( src , dst , len , cn ) ; <nl> - } <nl> - <nl> - static void merge32s ( const int * * src , int * dst , int len , int cn ) <nl> - { <nl> - merge_ ( src , dst , len , cn ) ; <nl> - } <nl> - <nl> - static void merge64s ( const int64 * * src , int64 * dst , int len , int cn ) <nl> - { <nl> - merge_ ( src , dst , len , cn ) ; <nl> - } <nl> - <nl> typedef void ( * SplitFunc ) ( const uchar * src , uchar * * dst , int len , int cn ) ; <nl> - typedef void ( * MergeFunc ) ( const uchar * * src , uchar * dst , int len , int cn ) ; <nl> <nl> static SplitFunc getSplitFunc ( int depth ) <nl> { <nl> static SplitFunc splitTab [ ] = <nl> { <nl> - ( SplitFunc ) GET_OPTIMIZED ( split8u ) , ( SplitFunc ) GET_OPTIMIZED ( split8u ) , ( SplitFunc ) GET_OPTIMIZED ( split16u ) , ( SplitFunc ) GET_OPTIMIZED ( split16u ) , <nl> - ( SplitFunc ) GET_OPTIMIZED ( split32s ) , ( SplitFunc ) GET_OPTIMIZED ( split32s ) , ( SplitFunc ) GET_OPTIMIZED ( split64s ) , 0 <nl> + ( SplitFunc ) GET_OPTIMIZED ( cv : : hal : : split8u ) , ( SplitFunc ) GET_OPTIMIZED ( cv : : hal : : split8u ) , ( SplitFunc ) GET_OPTIMIZED ( cv : : hal : : split16u ) , ( SplitFunc ) GET_OPTIMIZED ( cv : : hal : : split16u ) , <nl> + ( SplitFunc ) GET_OPTIMIZED ( cv : : hal : : split32s ) , ( SplitFunc ) GET_OPTIMIZED ( cv : : hal : : split32s ) , ( SplitFunc ) GET_OPTIMIZED ( cv : : hal : : split64s ) , 0 <nl> } ; <nl> <nl> return splitTab [ depth ] ; <nl> } <nl> <nl> + typedef void ( * MergeFunc ) ( const uchar * * src , uchar * dst , int len , int cn ) ; <nl> + <nl> static MergeFunc getMergeFunc ( int depth ) <nl> { <nl> static MergeFunc mergeTab [ ] = <nl> { <nl> - ( MergeFunc ) GET_OPTIMIZED ( merge8u ) , ( MergeFunc ) GET_OPTIMIZED ( merge8u ) , ( MergeFunc ) GET_OPTIMIZED ( merge16u ) , ( MergeFunc ) GET_OPTIMIZED ( merge16u ) , <nl> - ( MergeFunc ) GET_OPTIMIZED ( merge32s ) , ( MergeFunc ) GET_OPTIMIZED ( merge32s ) , ( MergeFunc ) GET_OPTIMIZED ( merge64s ) , 0 <nl> + ( MergeFunc ) GET_OPTIMIZED ( cv : : hal : : merge8u ) , ( MergeFunc ) GET_OPTIMIZED ( cv : : hal : : merge8u ) , ( MergeFunc ) GET_OPTIMIZED ( cv : : hal : : merge16u ) , ( MergeFunc ) GET_OPTIMIZED ( cv : : hal : : merge16u ) , <nl> + ( MergeFunc ) GET_OPTIMIZED ( cv : : hal : : merge32s ) , ( MergeFunc ) GET_OPTIMIZED ( cv : : hal : : merge32s ) , ( MergeFunc ) GET_OPTIMIZED ( cv : : hal : : merge64s ) , 0 <nl> } ; <nl> <nl> return mergeTab [ depth ] ; <nl> } <nl> <nl> - } <nl> - <nl> void cv : : split ( const Mat & src , Mat * mv ) <nl> { <nl> int k , depth = src . depth ( ) , cn = src . channels ( ) ; <nl> mmm a / modules / core / src / precomp . hpp <nl> ppp b / modules / core / src / precomp . hpp <nl> typedef void ( * BinaryFunc ) ( const uchar * src1 , size_t step1 , <nl> uchar * dst , size_t step , Size sz , <nl> void * ) ; <nl> <nl> + typedef void ( * BinaryFuncC ) ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , <nl> + void * ) ; <nl> + <nl> BinaryFunc getConvertFunc ( int sdepth , int ddepth ) ; <nl> BinaryFunc getCopyMaskFunc ( size_t esz ) ; <nl> <nl> extern const uchar g_Saturate8u [ ] ; <nl> void deleteThreadAllocData ( ) ; <nl> # endif <nl> <nl> - template < typename T1 , typename T2 = T1 , typename T3 = T1 > struct OpAdd <nl> - { <nl> - typedef T1 type1 ; <nl> - typedef T2 type2 ; <nl> - typedef T3 rtype ; <nl> - T3 operator ( ) ( const T1 a , const T2 b ) const { return saturate_cast < T3 > ( a + b ) ; } <nl> - } ; <nl> - <nl> - template < typename T1 , typename T2 = T1 , typename T3 = T1 > struct OpSub <nl> - { <nl> - typedef T1 type1 ; <nl> - typedef T2 type2 ; <nl> - typedef T3 rtype ; <nl> - T3 operator ( ) ( const T1 a , const T2 b ) const { return saturate_cast < T3 > ( a - b ) ; } <nl> - } ; <nl> - <nl> - template < typename T1 , typename T2 = T1 , typename T3 = T1 > struct OpRSub <nl> - { <nl> - typedef T1 type1 ; <nl> - typedef T2 type2 ; <nl> - typedef T3 rtype ; <nl> - T3 operator ( ) ( const T1 a , const T2 b ) const { return saturate_cast < T3 > ( b - a ) ; } <nl> - } ; <nl> - <nl> - template < typename T > struct OpMin <nl> - { <nl> - typedef T type1 ; <nl> - typedef T type2 ; <nl> - typedef T rtype ; <nl> - T operator ( ) ( const T a , const T b ) const { return std : : min ( a , b ) ; } <nl> - } ; <nl> - <nl> - template < typename T > struct OpMax <nl> - { <nl> - typedef T type1 ; <nl> - typedef T type2 ; <nl> - typedef T rtype ; <nl> - T operator ( ) ( const T a , const T b ) const { return std : : max ( a , b ) ; } <nl> - } ; <nl> - <nl> inline Size getContinuousSize_ ( int flags , int cols , int rows , int widthScale ) <nl> { <nl> int64 sz = ( int64 ) cols * rows * widthScale ; <nl> struct NoVec <nl> size_t operator ( ) ( const void * , const void * , void * , size_t ) const { return 0 ; } <nl> } ; <nl> <nl> - extern volatile bool USE_SSE2 ; <nl> - extern volatile bool USE_SSE4_2 ; <nl> - extern volatile bool USE_AVX ; <nl> - extern volatile bool USE_AVX2 ; <nl> - <nl> enum { BLOCK_SIZE = 1024 } ; <nl> <nl> # if defined HAVE_IPP & & ( IPP_VERSION_X100 > = 700 ) <nl> mmm a / modules / core / src / system . cpp <nl> ppp b / modules / core / src / system . cpp <nl> Mutex * __initialization_mutex_initializer = & getInitializationMutex ( ) ; <nl> # undef max <nl> # undef abs <nl> # include < tchar . h > <nl> - # if defined _MSC_VER <nl> - # if _MSC_VER > = 1400 <nl> - # include < intrin . h > <nl> - # elif defined _M_IX86 <nl> - static void __cpuid ( int * cpuid_data , int ) <nl> - { <nl> - __asm <nl> - { <nl> - push ebx <nl> - push edi <nl> - mov edi , cpuid_data <nl> - mov eax , 1 <nl> - cpuid <nl> - mov [ edi ] , eax <nl> - mov [ edi + 4 ] , ebx <nl> - mov [ edi + 8 ] , ecx <nl> - mov [ edi + 12 ] , edx <nl> - pop edi <nl> - pop ebx <nl> - } <nl> - } <nl> - static void __cpuidex ( int * cpuid_data , int , int ) <nl> - { <nl> - __asm <nl> - { <nl> - push edi <nl> - mov edi , cpuid_data <nl> - mov eax , 7 <nl> - mov ecx , 0 <nl> - cpuid <nl> - mov [ edi ] , eax <nl> - mov [ edi + 4 ] , ebx <nl> - mov [ edi + 8 ] , ecx <nl> - mov [ edi + 12 ] , edx <nl> - pop edi <nl> - } <nl> - } <nl> - # endif <nl> - # endif <nl> <nl> # ifdef WINRT <nl> # include < wrl / client . h > <nl> void Exception : : formatMessage ( ) <nl> msg = format ( " % s : % d : error : ( % d ) % s \ n " , file . c_str ( ) , line , code , err . c_str ( ) ) ; <nl> } <nl> <nl> - struct HWFeatures <nl> - { <nl> - enum { MAX_FEATURE = CV_HARDWARE_MAX_FEATURE } ; <nl> - <nl> - HWFeatures ( void ) <nl> - { <nl> - memset ( have , 0 , sizeof ( have ) ) ; <nl> - x86_family = 0 ; <nl> - } <nl> - <nl> - static HWFeatures initialize ( void ) <nl> - { <nl> - HWFeatures f ; <nl> - int cpuid_data [ 4 ] = { 0 , 0 , 0 , 0 } ; <nl> - <nl> - # if defined _MSC_VER & & ( defined _M_IX86 | | defined _M_X64 ) <nl> - __cpuid ( cpuid_data , 1 ) ; <nl> - # elif defined __GNUC__ & & ( defined __i386__ | | defined __x86_64__ ) <nl> - # ifdef __x86_64__ <nl> - asm __volatile__ <nl> - ( <nl> - " movl $ 1 , % % eax \ n \ t " <nl> - " cpuid \ n \ t " <nl> - : [ eax ] " = a " ( cpuid_data [ 0 ] ) , [ ebx ] " = b " ( cpuid_data [ 1 ] ) , [ ecx ] " = c " ( cpuid_data [ 2 ] ) , [ edx ] " = d " ( cpuid_data [ 3 ] ) <nl> - : <nl> - : " cc " <nl> - ) ; <nl> - # else <nl> - asm volatile <nl> - ( <nl> - " pushl % % ebx \ n \ t " <nl> - " movl $ 1 , % % eax \ n \ t " <nl> - " cpuid \ n \ t " <nl> - " popl % % ebx \ n \ t " <nl> - : " = a " ( cpuid_data [ 0 ] ) , " = c " ( cpuid_data [ 2 ] ) , " = d " ( cpuid_data [ 3 ] ) <nl> - : <nl> - : " cc " <nl> - ) ; <nl> - # endif <nl> - # endif <nl> - <nl> - f . x86_family = ( cpuid_data [ 0 ] > > 8 ) & 15 ; <nl> - if ( f . x86_family > = 6 ) <nl> - { <nl> - f . have [ CV_CPU_MMX ] = ( cpuid_data [ 3 ] & ( 1 < < 23 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_SSE ] = ( cpuid_data [ 3 ] & ( 1 < < 25 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_SSE2 ] = ( cpuid_data [ 3 ] & ( 1 < < 26 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_SSE3 ] = ( cpuid_data [ 2 ] & ( 1 < < 0 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_SSSE3 ] = ( cpuid_data [ 2 ] & ( 1 < < 9 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_FMA3 ] = ( cpuid_data [ 2 ] & ( 1 < < 12 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_SSE4_1 ] = ( cpuid_data [ 2 ] & ( 1 < < 19 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_SSE4_2 ] = ( cpuid_data [ 2 ] & ( 1 < < 20 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_POPCNT ] = ( cpuid_data [ 2 ] & ( 1 < < 23 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_AVX ] = ( ( ( cpuid_data [ 2 ] & ( 1 < < 28 ) ) ! = 0 ) & & ( ( cpuid_data [ 2 ] & ( 1 < < 27 ) ) ! = 0 ) ) ; / / OS uses XSAVE_XRSTORE and CPU support AVX <nl> - <nl> - / / make the second call to the cpuid command in order to get <nl> - / / information about extended features like AVX2 <nl> - # if defined _MSC_VER & & ( defined _M_IX86 | | defined _M_X64 ) <nl> - __cpuidex ( cpuid_data , 7 , 0 ) ; <nl> - # elif defined __GNUC__ & & ( defined __i386__ | | defined __x86_64__ ) <nl> - # ifdef __x86_64__ <nl> - asm __volatile__ <nl> - ( <nl> - " movl $ 7 , % % eax \ n \ t " <nl> - " movl $ 0 , % % ecx \ n \ t " <nl> - " cpuid \ n \ t " <nl> - : [ eax ] " = a " ( cpuid_data [ 0 ] ) , [ ebx ] " = b " ( cpuid_data [ 1 ] ) , [ ecx ] " = c " ( cpuid_data [ 2 ] ) , [ edx ] " = d " ( cpuid_data [ 3 ] ) <nl> - : <nl> - : " cc " <nl> - ) ; <nl> - # else <nl> - asm volatile <nl> - ( <nl> - " pushl % % ebx \ n \ t " <nl> - " movl $ 7 , % % eax \ n \ t " <nl> - " movl $ 0 , % % ecx \ n \ t " <nl> - " cpuid \ n \ t " <nl> - " movl % % ebx , % 0 \ n \ t " <nl> - " popl % % ebx \ n \ t " <nl> - : " = r " ( cpuid_data [ 1 ] ) , " = c " ( cpuid_data [ 2 ] ) <nl> - : <nl> - : " cc " <nl> - ) ; <nl> - # endif <nl> - # endif <nl> - f . have [ CV_CPU_AVX2 ] = ( cpuid_data [ 1 ] & ( 1 < < 5 ) ) ! = 0 ; <nl> - <nl> - f . have [ CV_CPU_AVX_512F ] = ( cpuid_data [ 1 ] & ( 1 < < 16 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_AVX_512DQ ] = ( cpuid_data [ 1 ] & ( 1 < < 17 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_AVX_512IFMA512 ] = ( cpuid_data [ 1 ] & ( 1 < < 21 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_AVX_512PF ] = ( cpuid_data [ 1 ] & ( 1 < < 26 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_AVX_512ER ] = ( cpuid_data [ 1 ] & ( 1 < < 27 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_AVX_512CD ] = ( cpuid_data [ 1 ] & ( 1 < < 28 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_AVX_512BW ] = ( cpuid_data [ 1 ] & ( 1 < < 30 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_AVX_512VL ] = ( cpuid_data [ 1 ] & ( 1 < < 31 ) ) ! = 0 ; <nl> - f . have [ CV_CPU_AVX_512VBMI ] = ( cpuid_data [ 2 ] & ( 1 < < 1 ) ) ! = 0 ; <nl> - } <nl> - <nl> - # if defined ANDROID | | defined __linux__ <nl> - # ifdef __aarch64__ <nl> - f . have [ CV_CPU_NEON ] = true ; <nl> - # else <nl> - int cpufile = open ( " / proc / self / auxv " , O_RDONLY ) ; <nl> - <nl> - if ( cpufile > = 0 ) <nl> - { <nl> - Elf32_auxv_t auxv ; <nl> - const size_t size_auxv_t = sizeof ( auxv ) ; <nl> - <nl> - while ( ( size_t ) read ( cpufile , & auxv , size_auxv_t ) = = size_auxv_t ) <nl> - { <nl> - if ( auxv . a_type = = AT_HWCAP ) <nl> - { <nl> - f . have [ CV_CPU_NEON ] = ( auxv . a_un . a_val & 4096 ) ! = 0 ; <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - close ( cpufile ) ; <nl> - } <nl> - # endif <nl> - # elif ( defined __clang__ | | defined __APPLE__ ) & & ( defined __ARM_NEON__ | | ( defined __ARM_NEON & & defined __aarch64__ ) ) <nl> - f . have [ CV_CPU_NEON ] = true ; <nl> - # endif <nl> - <nl> - return f ; <nl> - } <nl> - <nl> - int x86_family ; <nl> - bool have [ MAX_FEATURE + 1 ] ; <nl> - } ; <nl> - <nl> - static HWFeatures featuresEnabled = HWFeatures : : initialize ( ) , featuresDisabled = HWFeatures ( ) ; <nl> - static HWFeatures * currentFeatures = & featuresEnabled ; <nl> - <nl> bool checkHardwareSupport ( int feature ) <nl> { <nl> CV_DbgAssert ( 0 < = feature & & feature < = CV_HARDWARE_MAX_FEATURE ) ; <nl> - return currentFeatures - > have [ feature ] ; <nl> + return cv : : hal : : checkHardwareSupport ( feature ) ; <nl> } <nl> <nl> - <nl> - volatile bool useOptimizedFlag = true ; <nl> - <nl> - volatile bool USE_SSE2 = featuresEnabled . have [ CV_CPU_SSE2 ] ; <nl> - volatile bool USE_SSE4_2 = featuresEnabled . have [ CV_CPU_SSE4_2 ] ; <nl> - volatile bool USE_AVX = featuresEnabled . have [ CV_CPU_AVX ] ; <nl> - volatile bool USE_AVX2 = featuresEnabled . have [ CV_CPU_AVX2 ] ; <nl> - <nl> void setUseOptimized ( bool flag ) <nl> { <nl> - useOptimizedFlag = flag ; <nl> - currentFeatures = flag ? & featuresEnabled : & featuresDisabled ; <nl> - USE_SSE2 = currentFeatures - > have [ CV_CPU_SSE2 ] ; <nl> + cv : : hal : : setUseOptimized ( flag ) ; <nl> <nl> ipp : : setUseIPP ( flag ) ; <nl> # ifdef HAVE_OPENCL <nl> void setUseOptimized ( bool flag ) <nl> <nl> bool useOptimized ( void ) <nl> { <nl> - return useOptimizedFlag ; <nl> + return cv : : hal : : useOptimized ( ) ; <nl> } <nl> <nl> int64 getTickCount ( void ) <nl> redirectError ( CvErrorCallback errCallback , void * userdata , void * * prevUserdata ) <nl> CV_IMPL int cvCheckHardwareSupport ( int feature ) <nl> { <nl> CV_DbgAssert ( 0 < = feature & & feature < = CV_HARDWARE_MAX_FEATURE ) ; <nl> - return cv : : currentFeatures - > have [ feature ] ; <nl> + return cv : : hal : : checkHardwareSupport ( feature ) ; <nl> } <nl> <nl> CV_IMPL int cvUseOptimized ( int flag ) <nl> { <nl> - int prevMode = cv : : useOptimizedFlag ; <nl> + int prevMode = cv : : useOptimized ( ) ; <nl> cv : : setUseOptimized ( flag ! = 0 ) ; <nl> return prevMode ; <nl> } <nl> mmm a / modules / hal / CMakeLists . txt <nl> ppp b / modules / hal / CMakeLists . txt <nl> set ( the_description " The Hardware Acceleration Layer ( HAL ) module " ) <nl> <nl> set ( OPENCV_MODULE_TYPE STATIC ) <nl> <nl> + if ( OPENCV_HAL_HEADERS AND OPENCV_HAL_LIBS ) <nl> + set ( OPENCV_HAL_HEADERS_INCLUDES " # include \ " $ { OPENCV_HAL_HEADERS } \ " " ) <nl> + set ( DEPS " $ { OPENCV_HAL_LIBS } " ) <nl> + else ( ) <nl> + set ( OPENCV_HAL_HEADERS_INCLUDES " / / using default HAL " ) <nl> + set ( DEPS " " ) <nl> + endif ( ) <nl> + <nl> + configure_file ( " $ { OpenCV_SOURCE_DIR } / cmake / templates / custom_hal . hpp . in " " $ { CMAKE_BINARY_DIR } / custom_hal . hpp " @ ONLY ) <nl> + <nl> if ( UNIX ) <nl> if ( CMAKE_COMPILER_IS_GNUCXX OR CV_ICC ) <nl> set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } - fPIC " ) <nl> endif ( ) <nl> endif ( ) <nl> <nl> - ocv_define_module ( hal ) <nl> + ocv_define_module ( hal $ { DEPS } ) <nl> mmm a / modules / hal / include / opencv2 / hal . hpp <nl> ppp b / modules / hal / include / opencv2 / hal . hpp <nl> <nl> # define __OPENCV_HAL_HPP__ <nl> <nl> # include " opencv2 / hal / defs . h " <nl> + # include " opencv2 / hal / interface . hpp " <nl> <nl> / * * <nl> @ defgroup hal Hardware Acceleration Layer <nl> <nl> @ } <nl> * / <nl> <nl> - <nl> namespace cv { namespace hal { <nl> <nl> / / ! @ addtogroup hal <nl> / / ! @ { <nl> <nl> - namespace Error { <nl> - <nl> - enum <nl> + class Failure <nl> { <nl> - Ok = 0 , <nl> - Unknown = - 1 <nl> + public : <nl> + Failure ( int code_ = Error : : Unknown ) : code ( code_ ) { } <nl> + public : <nl> + int code ; <nl> } ; <nl> <nl> - } <nl> - <nl> int normHamming ( const uchar * a , int n ) ; <nl> int normHamming ( const uchar * a , const uchar * b , int n ) ; <nl> <nl> void sqrt ( const double * src , double * dst , int len ) ; <nl> void invSqrt ( const float * src , float * dst , int len ) ; <nl> void invSqrt ( const double * src , double * dst , int len ) ; <nl> <nl> + void split8u ( const uchar * src , uchar * * dst , int len , int cn ) ; <nl> + void split16u ( const ushort * src , ushort * * dst , int len , int cn ) ; <nl> + void split32s ( const int * src , int * * dst , int len , int cn ) ; <nl> + void split64s ( const int64 * src , int64 * * dst , int len , int cn ) ; <nl> + <nl> + void merge8u ( const uchar * * src , uchar * dst , int len , int cn ) ; <nl> + void merge16u ( const ushort * * src , ushort * dst , int len , int cn ) ; <nl> + void merge32s ( const int * * src , int * dst , int len , int cn ) ; <nl> + void merge64s ( const int64 * * src , int64 * dst , int len , int cn ) ; <nl> + <nl> + void add8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * ) ; <nl> + void add8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , schar * dst , size_t step , int width , int height , void * ) ; <nl> + void add16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , ushort * dst , size_t step , int width , int height , void * ) ; <nl> + void add16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , short * dst , size_t step , int width , int height , void * ) ; <nl> + void add32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , int * dst , size_t step , int width , int height , void * ) ; <nl> + void add32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , float * dst , size_t step , int width , int height , void * ) ; <nl> + void add64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , double * dst , size_t step , int width , int height , void * ) ; <nl> + <nl> + void sub8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * ) ; <nl> + void sub8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , schar * dst , size_t step , int width , int height , void * ) ; <nl> + void sub16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , ushort * dst , size_t step , int width , int height , void * ) ; <nl> + void sub16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , short * dst , size_t step , int width , int height , void * ) ; <nl> + void sub32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , int * dst , size_t step , int width , int height , void * ) ; <nl> + void sub32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , float * dst , size_t step , int width , int height , void * ) ; <nl> + void sub64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , double * dst , size_t step , int width , int height , void * ) ; <nl> + <nl> + void max8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * ) ; <nl> + void max8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , schar * dst , size_t step , int width , int height , void * ) ; <nl> + void max16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , ushort * dst , size_t step , int width , int height , void * ) ; <nl> + void max16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , short * dst , size_t step , int width , int height , void * ) ; <nl> + void max32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , int * dst , size_t step , int width , int height , void * ) ; <nl> + void max32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , float * dst , size_t step , int width , int height , void * ) ; <nl> + void max64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , double * dst , size_t step , int width , int height , void * ) ; <nl> + <nl> + void min8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * ) ; <nl> + void min8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , schar * dst , size_t step , int width , int height , void * ) ; <nl> + void min16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , ushort * dst , size_t step , int width , int height , void * ) ; <nl> + void min16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , short * dst , size_t step , int width , int height , void * ) ; <nl> + void min32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , int * dst , size_t step , int width , int height , void * ) ; <nl> + void min32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , float * dst , size_t step , int width , int height , void * ) ; <nl> + void min64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , double * dst , size_t step , int width , int height , void * ) ; <nl> + <nl> + void absdiff8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * ) ; <nl> + void absdiff8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , schar * dst , size_t step , int width , int height , void * ) ; <nl> + void absdiff16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , ushort * dst , size_t step , int width , int height , void * ) ; <nl> + void absdiff16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , short * dst , size_t step , int width , int height , void * ) ; <nl> + void absdiff32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , int * dst , size_t step , int width , int height , void * ) ; <nl> + void absdiff32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , float * dst , size_t step , int width , int height , void * ) ; <nl> + void absdiff64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , double * dst , size_t step , int width , int height , void * ) ; <nl> + <nl> + void and8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * ) ; <nl> + void or8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * ) ; <nl> + void xor8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * ) ; <nl> + void not8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * ) ; <nl> + <nl> + void cmp8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * _cmpop ) ; <nl> + void cmp8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * _cmpop ) ; <nl> + void cmp16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * _cmpop ) ; <nl> + void cmp16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * _cmpop ) ; <nl> + void cmp32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * _cmpop ) ; <nl> + void cmp32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * _cmpop ) ; <nl> + void cmp64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * _cmpop ) ; <nl> + <nl> + void mul8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * scale ) ; <nl> + void mul8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , schar * dst , size_t step , int width , int height , void * scale ) ; <nl> + void mul16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , ushort * dst , size_t step , int width , int height , void * scale ) ; <nl> + void mul16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , short * dst , size_t step , int width , int height , void * scale ) ; <nl> + void mul32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , int * dst , size_t step , int width , int height , void * scale ) ; <nl> + void mul32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , float * dst , size_t step , int width , int height , void * scale ) ; <nl> + void mul64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , double * dst , size_t step , int width , int height , void * scale ) ; <nl> + <nl> + void div8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * scale ) ; <nl> + void div8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , schar * dst , size_t step , int width , int height , void * scale ) ; <nl> + void div16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , ushort * dst , size_t step , int width , int height , void * scale ) ; <nl> + void div16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , short * dst , size_t step , int width , int height , void * scale ) ; <nl> + void div32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , int * dst , size_t step , int width , int height , void * scale ) ; <nl> + void div32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , float * dst , size_t step , int width , int height , void * scale ) ; <nl> + void div64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , double * dst , size_t step , int width , int height , void * scale ) ; <nl> + <nl> + void recip8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * scale ) ; <nl> + void recip8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , schar * dst , size_t step , int width , int height , void * scale ) ; <nl> + void recip16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , ushort * dst , size_t step , int width , int height , void * scale ) ; <nl> + void recip16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , short * dst , size_t step , int width , int height , void * scale ) ; <nl> + void recip32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , int * dst , size_t step , int width , int height , void * scale ) ; <nl> + void recip32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , float * dst , size_t step , int width , int height , void * scale ) ; <nl> + void recip64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , double * dst , size_t step , int width , int height , void * scale ) ; <nl> + <nl> + void addWeighted8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height , void * _scalars ) ; <nl> + void addWeighted8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , schar * dst , size_t step , int width , int height , void * scalars ) ; <nl> + void addWeighted16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , ushort * dst , size_t step , int width , int height , void * scalars ) ; <nl> + void addWeighted16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , short * dst , size_t step , int width , int height , void * scalars ) ; <nl> + void addWeighted32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , int * dst , size_t step , int width , int height , void * scalars ) ; <nl> + void addWeighted32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , float * dst , size_t step , int width , int height , void * scalars ) ; <nl> + void addWeighted64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , double * dst , size_t step , int width , int height , void * scalars ) ; <nl> / / ! @ } <nl> <nl> } } / / cv : : hal <nl> <nl> + namespace cv { <nl> + <nl> + template < typename T1 , typename T2 = T1 , typename T3 = T1 > struct OpAdd <nl> + { <nl> + typedef T1 type1 ; <nl> + typedef T2 type2 ; <nl> + typedef T3 rtype ; <nl> + T3 operator ( ) ( const T1 a , const T2 b ) const { return saturate_cast < T3 > ( a + b ) ; } <nl> + } ; <nl> + <nl> + template < typename T1 , typename T2 = T1 , typename T3 = T1 > struct OpSub <nl> + { <nl> + typedef T1 type1 ; <nl> + typedef T2 type2 ; <nl> + typedef T3 rtype ; <nl> + T3 operator ( ) ( const T1 a , const T2 b ) const { return saturate_cast < T3 > ( a - b ) ; } <nl> + } ; <nl> + <nl> + template < typename T1 , typename T2 = T1 , typename T3 = T1 > struct OpRSub <nl> + { <nl> + typedef T1 type1 ; <nl> + typedef T2 type2 ; <nl> + typedef T3 rtype ; <nl> + T3 operator ( ) ( const T1 a , const T2 b ) const { return saturate_cast < T3 > ( b - a ) ; } <nl> + } ; <nl> + <nl> + template < typename T > struct OpMin <nl> + { <nl> + typedef T type1 ; <nl> + typedef T type2 ; <nl> + typedef T rtype ; <nl> + T operator ( ) ( const T a , const T b ) const { return std : : min ( a , b ) ; } <nl> + } ; <nl> + <nl> + template < typename T > struct OpMax <nl> + { <nl> + typedef T type1 ; <nl> + typedef T type2 ; <nl> + typedef T rtype ; <nl> + T operator ( ) ( const T a , const T b ) const { return std : : max ( a , b ) ; } <nl> + } ; <nl> + <nl> + template < typename T > struct OpAbsDiff <nl> + { <nl> + typedef T type1 ; <nl> + typedef T type2 ; <nl> + typedef T rtype ; <nl> + T operator ( ) ( T a , T b ) const { return a > b ? a - b : b - a ; } <nl> + } ; <nl> + <nl> + template < typename T > struct OpAnd <nl> + { <nl> + typedef T type1 ; <nl> + typedef T type2 ; <nl> + typedef T rtype ; <nl> + T operator ( ) ( T a , T b ) const { return a & b ; } <nl> + } ; <nl> + <nl> + template < typename T > struct OpOr <nl> + { <nl> + typedef T type1 ; <nl> + typedef T type2 ; <nl> + typedef T rtype ; <nl> + T operator ( ) ( T a , T b ) const { return a | b ; } <nl> + } ; <nl> + <nl> + template < typename T > struct OpXor <nl> + { <nl> + typedef T type1 ; <nl> + typedef T type2 ; <nl> + typedef T rtype ; <nl> + T operator ( ) ( T a , T b ) const { return a ^ b ; } <nl> + } ; <nl> + <nl> + template < typename T > struct OpNot <nl> + { <nl> + typedef T type1 ; <nl> + typedef T type2 ; <nl> + typedef T rtype ; <nl> + T operator ( ) ( T a , T ) const { return ~ a ; } <nl> + } ; <nl> + <nl> + } <nl> + <nl> # endif / / __OPENCV_HAL_HPP__ <nl> mmm a / modules / hal / include / opencv2 / hal / defs . h <nl> ppp b / modules / hal / include / opencv2 / hal / defs . h <nl> <nl> # endif <nl> <nl> # include < limits . h > <nl> + # include " opencv2 / hal / interface . hpp " <nl> <nl> # if defined __ICL <nl> # define CV_ICC __ICL <nl> <nl> <nl> # define CV_CPU_NEON 100 <nl> <nl> - / / when adding to this list remember to update the enum in core / utility . cpp <nl> + / / when adding to this list remember to update the following enum <nl> # define CV_HARDWARE_MAX_FEATURE 255 <nl> <nl> + / * * @ brief Available CPU features . <nl> + * / <nl> + enum CpuFeatures { <nl> + CPU_MMX = 1 , <nl> + CPU_SSE = 2 , <nl> + CPU_SSE2 = 3 , <nl> + CPU_SSE3 = 4 , <nl> + CPU_SSSE3 = 5 , <nl> + CPU_SSE4_1 = 6 , <nl> + CPU_SSE4_2 = 7 , <nl> + CPU_POPCNT = 8 , <nl> + <nl> + CPU_AVX = 10 , <nl> + CPU_AVX2 = 11 , <nl> + CPU_FMA3 = 12 , <nl> + <nl> + CPU_AVX_512F = 13 , <nl> + CPU_AVX_512BW = 14 , <nl> + CPU_AVX_512CD = 15 , <nl> + CPU_AVX_512DQ = 16 , <nl> + CPU_AVX_512ER = 17 , <nl> + CPU_AVX_512IFMA512 = 18 , <nl> + CPU_AVX_512PF = 19 , <nl> + CPU_AVX_512VBMI = 20 , <nl> + CPU_AVX_512VL = 21 , <nl> + <nl> + CPU_NEON = 100 <nl> + } ; <nl> + <nl> / / do not include SSE / AVX / NEON headers for NVCC compiler <nl> # ifndef __CUDACC__ <nl> <nl> <nl> # define CV_VFP 0 <nl> # endif <nl> <nl> - / * primitive types * / <nl> - / * <nl> - schar - signed 1 byte integer <nl> - uchar - unsigned 1 byte integer <nl> - short - signed 2 byte integer <nl> - ushort - unsigned 2 byte integer <nl> - int - signed 4 byte integer <nl> - uint - unsigned 4 byte integer <nl> - int64 - signed 8 byte integer <nl> - uint64 - unsigned 8 byte integer <nl> - * / <nl> - <nl> - # if ! defined _MSC_VER & & ! defined __BORLANDC__ <nl> - # if defined __cplusplus & & __cplusplus > = 201103L & & ! defined __APPLE__ <nl> - # include < cstdint > <nl> - typedef std : : uint32_t uint ; <nl> - # else <nl> - # include < stdint . h > <nl> - typedef uint32_t uint ; <nl> - # endif <nl> - # else <nl> - typedef unsigned uint ; <nl> - # endif <nl> - <nl> - typedef signed char schar ; <nl> - <nl> - # ifndef __IPL_H__ <nl> - typedef unsigned char uchar ; <nl> - typedef unsigned short ushort ; <nl> - # endif <nl> - <nl> - # if defined _MSC_VER | | defined __BORLANDC__ <nl> - typedef __int64 int64 ; <nl> - typedef unsigned __int64 uint64 ; <nl> - # define CV_BIG_INT ( n ) n # # I64 <nl> - # define CV_BIG_UINT ( n ) n # # UI64 <nl> - # else <nl> - typedef int64_t int64 ; <nl> - typedef uint64_t uint64 ; <nl> - # define CV_BIG_INT ( n ) n # # LL <nl> - # define CV_BIG_UINT ( n ) n # # ULL <nl> - # endif <nl> - <nl> / * fundamental constants * / <nl> # define CV_PI 3 . 1415926535897932384626433832795 <nl> # define CV_2PI 6 . 283185307179586476925286766559 <nl> typedef union Cv64suf <nl> } <nl> Cv64suf ; <nl> <nl> + namespace cv { namespace hal { <nl> + <nl> + bool checkHardwareSupport ( int feature ) ; <nl> + void setUseOptimized ( bool onoff ) ; <nl> + bool useOptimized ( ) ; <nl> + <nl> + } } <nl> + <nl> + # define USE_SSE2 ( cv : : hal : : checkHardwareSupport ( CV_CPU_SSE ) ) <nl> + # define USE_SSE4_2 ( cv : : hal : : checkHardwareSupport ( CV_CPU_SSE4_2 ) ) <nl> + # define USE_AVX ( cv : : hal : : checkHardwareSupport ( CV_CPU_AVX ) ) <nl> + # define USE_AVX2 ( cv : : hal : : checkHardwareSupport ( CV_CPU_AVX2 ) ) <nl> + <nl> <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ <nl> * fast math * <nl> new file mode 100644 <nl> index 00000000000 . . 2a5bff04d7e <nl> mmm / dev / null <nl> ppp b / modules / hal / include / opencv2 / hal / interface . hpp <nl> <nl> + # ifndef _HAL_INTERFACE_HPP_INCLUDED_ <nl> + # define _HAL_INTERFACE_HPP_INCLUDED_ <nl> + <nl> + # define CV_HAL_ERROR_OK 0 <nl> + # define CV_HAL_ERROR_NI 1 <nl> + # define CV_HAL_ERROR_UNKNOWN - 1 <nl> + <nl> + # define CV_HAL_CMP_EQ 0 <nl> + # define CV_HAL_CMP_GT 1 <nl> + # define CV_HAL_CMP_GE 2 <nl> + # define CV_HAL_CMP_LT 3 <nl> + # define CV_HAL_CMP_LE 4 <nl> + # define CV_HAL_CMP_NE 5 <nl> + <nl> + # ifdef __cplusplus <nl> + namespace cv { namespace hal { <nl> + <nl> + namespace Error { <nl> + <nl> + enum <nl> + { <nl> + Ok = 0 , <nl> + NotImplemented = 1 , <nl> + Unknown = - 1 <nl> + } ; <nl> + <nl> + } <nl> + <nl> + enum <nl> + { <nl> + CMP_EQ = 0 , <nl> + CMP_GT = 1 , <nl> + CMP_GE = 2 , <nl> + CMP_LT = 3 , <nl> + CMP_LE = 4 , <nl> + CMP_NE = 5 <nl> + } ; <nl> + <nl> + } } <nl> + # endif <nl> + <nl> + # ifdef __cplusplus <nl> + # include < cstddef > <nl> + # else <nl> + # include < stddef . h > <nl> + # endif <nl> + <nl> + / * primitive types * / <nl> + / * <nl> + schar - signed 1 byte integer <nl> + uchar - unsigned 1 byte integer <nl> + short - signed 2 byte integer <nl> + ushort - unsigned 2 byte integer <nl> + int - signed 4 byte integer <nl> + uint - unsigned 4 byte integer <nl> + int64 - signed 8 byte integer <nl> + uint64 - unsigned 8 byte integer <nl> + * / <nl> + <nl> + # if ! defined _MSC_VER & & ! defined __BORLANDC__ <nl> + # if defined __cplusplus & & __cplusplus > = 201103L & & ! defined __APPLE__ <nl> + # include < cstdint > <nl> + typedef std : : uint32_t uint ; <nl> + # else <nl> + # include < stdint . h > <nl> + typedef uint32_t uint ; <nl> + # endif <nl> + # else <nl> + typedef unsigned uint ; <nl> + # endif <nl> + <nl> + typedef signed char schar ; <nl> + <nl> + # ifndef __IPL_H__ <nl> + typedef unsigned char uchar ; <nl> + typedef unsigned short ushort ; <nl> + # endif <nl> + <nl> + # if defined _MSC_VER | | defined __BORLANDC__ <nl> + typedef __int64 int64 ; <nl> + typedef unsigned __int64 uint64 ; <nl> + # define CV_BIG_INT ( n ) n # # I64 <nl> + # define CV_BIG_UINT ( n ) n # # UI64 <nl> + # else <nl> + typedef int64_t int64 ; <nl> + typedef uint64_t uint64 ; <nl> + # define CV_BIG_INT ( n ) n # # LL <nl> + # define CV_BIG_UINT ( n ) n # # ULL <nl> + # endif <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 6026777a6f8 <nl> mmm / dev / null <nl> ppp b / modules / hal / include / opencv2 / hal / neon_utils . hpp <nl> <nl> + / * M / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / IMPORTANT : READ BEFORE DOWNLOADING , COPYING , INSTALLING OR USING . <nl> + / / <nl> + / / By downloading , copying , installing or using the software you agree to this license . <nl> + / / If you do not agree to this license , do not download , install , <nl> + / / copy or use the software . <nl> + / / <nl> + / / <nl> + / / License Agreement <nl> + / / For Open Source Computer Vision Library <nl> + / / <nl> + / / Copyright ( C ) 2015 , Itseez Inc . , all rights reserved . <nl> + / / Third party copyrights are property of their respective owners . <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without modification , <nl> + / / are permitted provided that the following conditions are met : <nl> + / / <nl> + / / * Redistribution ' s of source code must retain the above copyright notice , <nl> + / / this list of conditions and the following disclaimer . <nl> + / / <nl> + / / * Redistribution ' s in binary form must reproduce the above copyright notice , <nl> + / / this list of conditions and the following disclaimer in the documentation <nl> + / / and / or other materials provided with the distribution . <nl> + / / <nl> + / / * The name of the copyright holders may not be used to endorse or promote products <nl> + / / derived from this software without specific prior written permission . <nl> + / / <nl> + / / This software is provided by the copyright holders and contributors " as is " and <nl> + / / any express or implied warranties , including , but not limited to , the implied <nl> + / / warranties of merchantability and fitness for a particular purpose are disclaimed . <nl> + / / In no event shall the Intel Corporation or contributors be liable for any direct , <nl> + / / indirect , incidental , special , exemplary , or consequential damages <nl> + / / ( including , but not limited to , procurement of substitute goods or services ; <nl> + / / loss of use , data , or profits ; or business interruption ) however caused <nl> + / / and on any theory of liability , whether in contract , strict liability , <nl> + / / or tort ( including negligence or otherwise ) arising in any way out of <nl> + / / the use of this software , even if advised of the possibility of such damage . <nl> + / / <nl> + / / M * / <nl> + <nl> + # ifndef __OPENCV_HAL_NEON_UTILS_HPP__ <nl> + # define __OPENCV_HAL_NEON_UTILS_HPP__ <nl> + <nl> + # include " opencv2 / hal / defs . h " <nl> + <nl> + namespace cv { <nl> + <nl> + # if CV_NEON <nl> + <nl> + inline int32x2_t cv_vrnd_s32_f32 ( float32x2_t v ) <nl> + { <nl> + static int32x2_t v_sign = vdup_n_s32 ( 1 < < 31 ) , <nl> + v_05 = vreinterpret_s32_f32 ( vdup_n_f32 ( 0 . 5f ) ) ; <nl> + <nl> + int32x2_t v_addition = vorr_s32 ( v_05 , vand_s32 ( v_sign , vreinterpret_s32_f32 ( v ) ) ) ; <nl> + return vcvt_s32_f32 ( vadd_f32 ( v , vreinterpret_f32_s32 ( v_addition ) ) ) ; <nl> + } <nl> + <nl> + inline int32x4_t cv_vrndq_s32_f32 ( float32x4_t v ) <nl> + { <nl> + static int32x4_t v_sign = vdupq_n_s32 ( 1 < < 31 ) , <nl> + v_05 = vreinterpretq_s32_f32 ( vdupq_n_f32 ( 0 . 5f ) ) ; <nl> + <nl> + int32x4_t v_addition = vorrq_s32 ( v_05 , vandq_s32 ( v_sign , vreinterpretq_s32_f32 ( v ) ) ) ; <nl> + return vcvtq_s32_f32 ( vaddq_f32 ( v , vreinterpretq_f32_s32 ( v_addition ) ) ) ; <nl> + } <nl> + <nl> + inline uint32x2_t cv_vrnd_u32_f32 ( float32x2_t v ) <nl> + { <nl> + static float32x2_t v_05 = vdup_n_f32 ( 0 . 5f ) ; <nl> + return vcvt_u32_f32 ( vadd_f32 ( v , v_05 ) ) ; <nl> + } <nl> + <nl> + inline uint32x4_t cv_vrndq_u32_f32 ( float32x4_t v ) <nl> + { <nl> + static float32x4_t v_05 = vdupq_n_f32 ( 0 . 5f ) ; <nl> + return vcvtq_u32_f32 ( vaddq_f32 ( v , v_05 ) ) ; <nl> + } <nl> + <nl> + inline float32x4_t cv_vrecpq_f32 ( float32x4_t val ) <nl> + { <nl> + float32x4_t reciprocal = vrecpeq_f32 ( val ) ; <nl> + reciprocal = vmulq_f32 ( vrecpsq_f32 ( val , reciprocal ) , reciprocal ) ; <nl> + reciprocal = vmulq_f32 ( vrecpsq_f32 ( val , reciprocal ) , reciprocal ) ; <nl> + return reciprocal ; <nl> + } <nl> + <nl> + inline float32x2_t cv_vrecp_f32 ( float32x2_t val ) <nl> + { <nl> + float32x2_t reciprocal = vrecpe_f32 ( val ) ; <nl> + reciprocal = vmul_f32 ( vrecps_f32 ( val , reciprocal ) , reciprocal ) ; <nl> + reciprocal = vmul_f32 ( vrecps_f32 ( val , reciprocal ) , reciprocal ) ; <nl> + return reciprocal ; <nl> + } <nl> + <nl> + inline float32x4_t cv_vrsqrtq_f32 ( float32x4_t val ) <nl> + { <nl> + float32x4_t e = vrsqrteq_f32 ( val ) ; <nl> + e = vmulq_f32 ( vrsqrtsq_f32 ( vmulq_f32 ( e , e ) , val ) , e ) ; <nl> + e = vmulq_f32 ( vrsqrtsq_f32 ( vmulq_f32 ( e , e ) , val ) , e ) ; <nl> + return e ; <nl> + } <nl> + <nl> + inline float32x2_t cv_vrsqrt_f32 ( float32x2_t val ) <nl> + { <nl> + float32x2_t e = vrsqrte_f32 ( val ) ; <nl> + e = vmul_f32 ( vrsqrts_f32 ( vmul_f32 ( e , e ) , val ) , e ) ; <nl> + e = vmul_f32 ( vrsqrts_f32 ( vmul_f32 ( e , e ) , val ) , e ) ; <nl> + return e ; <nl> + } <nl> + <nl> + inline float32x4_t cv_vsqrtq_f32 ( float32x4_t val ) <nl> + { <nl> + return cv_vrecpq_f32 ( cv_vrsqrtq_f32 ( val ) ) ; <nl> + } <nl> + <nl> + inline float32x2_t cv_vsqrt_f32 ( float32x2_t val ) <nl> + { <nl> + return cv_vrecp_f32 ( cv_vrsqrt_f32 ( val ) ) ; <nl> + } <nl> + <nl> + # endif <nl> + <nl> + } <nl> + <nl> + # endif / / __OPENCV_HAL_NEON_UTILS_HPP__ <nl> similarity index 99 % <nl> rename from modules / core / include / opencv2 / core / sse_utils . hpp <nl> rename to modules / hal / include / opencv2 / hal / sse_utils . hpp <nl> mmm a / modules / core / include / opencv2 / core / sse_utils . hpp <nl> ppp b / modules / hal / include / opencv2 / hal / sse_utils . hpp <nl> <nl> # error sse_utils . hpp header must be compiled as C + + <nl> # endif <nl> <nl> + # include " opencv2 / hal / defs . h " <nl> + <nl> # if CV_SSE2 <nl> <nl> inline void _mm_deinterleave_epi8 ( __m128i & v_r0 , __m128i & v_r1 , __m128i & v_g0 , __m128i & v_g1 ) <nl> new file mode 100644 <nl> index 00000000000 . . dd0be70f2fa <nl> mmm / dev / null <nl> ppp b / modules / hal / samples / simple_hal / CMakeLists . txt <nl> <nl> + cmake_minimum_required ( VERSION 2 . 8 . 8 FATAL_ERROR ) <nl> + <nl> + if ( UNIX ) <nl> + if ( CMAKE_COMPILER_IS_GNUCXX OR CV_ICC ) <nl> + set ( CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS } - fPIC " ) <nl> + endif ( ) <nl> + endif ( ) <nl> + <nl> + add_library ( simple_hal simple . cpp ) <nl> + set ( OPENCV_HAL_DIR " $ { CMAKE_CURRENT_SOURCE_DIR } / . . / . . " ) <nl> + target_include_directories ( simple_hal PUBLIC $ { CMAKE_CURRENT_SOURCE_DIR } $ { OPENCV_HAL_DIR } / include ) <nl> new file mode 100644 <nl> index 00000000000 . . 564a611a5a1 <nl> mmm / dev / null <nl> ppp b / modules / hal / samples / simple_hal / simple . cpp <nl> <nl> + # include " simple . hpp " <nl> + <nl> + int slow_and8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height ) <nl> + { <nl> + for ( ; height - - ; src1 = src1 + step1 , src2 = src2 + step2 , dst = dst + step ) <nl> + for ( int x = 0 ; x < width ; x + + ) <nl> + dst [ x ] = src1 [ x ] & src2 [ x ] ; <nl> + return cv : : hal : : Error : : Ok ; <nl> + } <nl> + <nl> + int slow_or8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height ) <nl> + { <nl> + for ( ; height - - ; src1 = src1 + step1 , src2 = src2 + step2 , dst = dst + step ) <nl> + for ( int x = 0 ; x < width ; x + + ) <nl> + dst [ x ] = src1 [ x ] | src2 [ x ] ; <nl> + return cv : : hal : : Error : : Ok ; <nl> + } <nl> + <nl> + int slow_xor8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height ) <nl> + { <nl> + for ( ; height - - ; src1 = src1 + step1 , src2 = src2 + step2 , dst = dst + step ) <nl> + for ( int x = 0 ; x < width ; x + + ) <nl> + dst [ x ] = src1 [ x ] ^ src2 [ x ] ; <nl> + return cv : : hal : : Error : : Ok ; <nl> + } <nl> + <nl> + int slow_not8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height ) <nl> + { <nl> + for ( ; height - - ; src1 = src1 + step1 , src2 = src2 + step2 , dst = dst + step ) <nl> + for ( int x = 0 ; x < width ; x + + ) <nl> + dst [ x ] = ~ src1 [ x ] ; <nl> + return cv : : hal : : Error : : Ok ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 85a16535de7 <nl> mmm / dev / null <nl> ppp b / modules / hal / samples / simple_hal / simple . hpp <nl> <nl> + # ifndef _SIMPLE_HPP_INCLUDED_ <nl> + # define _SIMPLE_HPP_INCLUDED_ <nl> + <nl> + # include " opencv2 / hal / interface . hpp " <nl> + <nl> + int slow_and8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height ) ; <nl> + int slow_or8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height ) ; <nl> + int slow_xor8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height ) ; <nl> + int slow_not8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , uchar * dst , size_t step , int width , int height ) ; <nl> + <nl> + # undef hal_and8u <nl> + # define hal_and8u slow_and8u <nl> + # undef hal_or8u <nl> + # define hal_or8u slow_or8u <nl> + # undef hal_xor8u <nl> + # define hal_xor8u slow_xor8u <nl> + # undef hal_not8u <nl> + # define hal_not8u slow_not8u <nl> + <nl> + # endif <nl> mmm a / modules / hal / src / arithm . cpp <nl> ppp b / modules / hal / src / arithm . cpp <nl> <nl> / / copy or use the software . <nl> / / <nl> / / <nl> - / / License Agreement <nl> + / / License Agreement <nl> / / For Open Source Computer Vision Library <nl> / / <nl> / / Copyright ( C ) 2000 - 2008 , Intel Corporation , all rights reserved . <nl> - / / Copyright ( C ) 2009 - 2011 , Willow Garage Inc . , all rights reserved . <nl> + / / Copyright ( C ) 2009 , Willow Garage Inc . , all rights reserved . <nl> + / / Copyright ( C ) 2013 , OpenCV Foundation , all rights reserved . <nl> + / / Copyright ( C ) 2015 , Itseez Inc . , all rights reserved . <nl> / / Third party copyrights are property of their respective owners . <nl> / / <nl> / / Redistribution and use in source and binary forms , with or without modification , <nl> <nl> / / M * / <nl> <nl> # include " precomp . hpp " <nl> + # include " arithm_simd . hpp " <nl> + # include " arithm_core . hpp " <nl> + # include " replacement . hpp " <nl> <nl> namespace cv { namespace hal { <nl> <nl> - } } <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + # undef CALL_HAL <nl> + # define CALL_HAL ( fun ) \ <nl> + int res = fun ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; \ <nl> + if ( res = = Error : : Ok ) \ <nl> + return ; \ <nl> + else if ( res ! = Error : : NotImplemented ) \ <nl> + throw Failure ( res ) ; <nl> + <nl> + # if ( ARITHM_USE_IPP = = 1 ) <nl> + static inline void fixSteps ( width , height , size_t elemSize , size_t & step1 , size_t & step2 , size_t & step ) <nl> + { <nl> + if ( height = = 1 ) <nl> + step1 = step2 = step = width * elemSize ; <nl> + } <nl> + # define CALL_IPP_BIN_12 ( fun ) \ <nl> + CV_IPP_CHECK ( ) \ <nl> + { \ <nl> + fixSteps ( width , height , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; \ <nl> + if ( 0 < = fun ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( width , height ) , 0 ) ) \ <nl> + { \ <nl> + CV_IMPL_ADD ( CV_IMPL_IPP ) ; \ <nl> + return ; \ <nl> + } \ <nl> + setIppErrorStatus ( ) ; \ <nl> + } <nl> + # else <nl> + # define CALL_IPP_BIN_12 ( fun ) <nl> + # endif <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / Add <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void add8u ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_add8u ) <nl> + CALL_IPP_BIN_12 ( ippiAdd_8u_C1RSfs ) <nl> + ( vBinOp < uchar , cv : : OpAdd < uchar > , IF_SIMD ( VAdd < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void add8s ( const schar * src1 , size_t step1 , <nl> + const schar * src2 , size_t step2 , <nl> + schar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_add8s ) <nl> + vBinOp < schar , cv : : OpAdd < schar > , IF_SIMD ( VAdd < schar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void add16u ( const ushort * src1 , size_t step1 , <nl> + const ushort * src2 , size_t step2 , <nl> + ushort * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_add16u ) <nl> + CALL_IPP_BIN_12 ( ippiAdd_16u_C1RSfs ) <nl> + ( vBinOp < ushort , cv : : OpAdd < ushort > , IF_SIMD ( VAdd < ushort > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void add16s ( const short * src1 , size_t step1 , <nl> + const short * src2 , size_t step2 , <nl> + short * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_add16s ) <nl> + CALL_IPP_BIN_12 ( ippiAdd_16s_C1RSfs ) <nl> + ( vBinOp < short , cv : : OpAdd < short > , IF_SIMD ( VAdd < short > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void add32s ( const int * src1 , size_t step1 , <nl> + const int * src2 , size_t step2 , <nl> + int * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_add32s ) <nl> + vBinOp32 < int , cv : : OpAdd < int > , IF_SIMD ( VAdd < int > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void add32f ( const float * src1 , size_t step1 , <nl> + const float * src2 , size_t step2 , <nl> + float * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_add32f ) <nl> + CALL_IPP_BIN_12 ( ippiAdd_32f_C1R ) <nl> + ( vBinOp32 < float , cv : : OpAdd < float > , IF_SIMD ( VAdd < float > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void add64f ( const double * src1 , size_t step1 , <nl> + const double * src2 , size_t step2 , <nl> + double * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_add64f ) <nl> + vBinOp64 < double , cv : : OpAdd < double > , IF_SIMD ( VAdd < double > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + # if ( ARITHM_USE_IPP = = 1 ) <nl> + # define CALL_IPP_BIN_21 ( fun ) \ <nl> + CV_IPP_CHECK ( ) \ <nl> + { \ <nl> + fixSteps ( width , height , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; \ <nl> + if ( 0 < = fun ( src2 , ( int ) step2 , src1 , ( int ) step1 , dst , ( int ) step , ippiSize ( width , height ) , 0 ) ) \ <nl> + { \ <nl> + CV_IMPL_ADD ( CV_IMPL_IPP ) ; \ <nl> + return ; \ <nl> + } \ <nl> + setIppErrorStatus ( ) ; \ <nl> + } <nl> + # else <nl> + # define CALL_IPP_BIN_21 ( fun ) <nl> + # endif <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / Subtract <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void sub8u ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_sub8u ) <nl> + CALL_IPP_BIN_21 ( ippiSub_8u_C1RSfs ) <nl> + ( vBinOp < uchar , cv : : OpSub < uchar > , IF_SIMD ( VSub < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void sub8s ( const schar * src1 , size_t step1 , <nl> + const schar * src2 , size_t step2 , <nl> + schar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_sub8s ) <nl> + vBinOp < schar , cv : : OpSub < schar > , IF_SIMD ( VSub < schar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void sub16u ( const ushort * src1 , size_t step1 , <nl> + const ushort * src2 , size_t step2 , <nl> + ushort * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_sub16u ) <nl> + CALL_IPP_BIN_21 ( ippiSub_16u_C1RSfs ) <nl> + ( vBinOp < ushort , cv : : OpSub < ushort > , IF_SIMD ( VSub < ushort > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void sub16s ( const short * src1 , size_t step1 , <nl> + const short * src2 , size_t step2 , <nl> + short * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_sub16s ) <nl> + CALL_IPP_BIN_21 ( ippiSub_16s_C1RSfs ) <nl> + ( vBinOp < short , cv : : OpSub < short > , IF_SIMD ( VSub < short > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void sub32s ( const int * src1 , size_t step1 , <nl> + const int * src2 , size_t step2 , <nl> + int * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_sub32s ) <nl> + vBinOp32 < int , cv : : OpSub < int > , IF_SIMD ( VSub < int > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void sub32f ( const float * src1 , size_t step1 , <nl> + const float * src2 , size_t step2 , <nl> + float * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_sub32f ) <nl> + CALL_IPP_BIN_21 ( ippiSub_32f_C1R ) <nl> + ( vBinOp32 < float , cv : : OpSub < float > , IF_SIMD ( VSub < float > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void sub64f ( const double * src1 , size_t step1 , <nl> + const double * src2 , size_t step2 , <nl> + double * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_sub64f ) <nl> + vBinOp64 < double , cv : : OpSub < double > , IF_SIMD ( VSub < double > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + # if ( ARITHM_USE_IPP = = 1 ) <nl> + # define CALL_IPP_MIN_MAX ( fun , type ) \ <nl> + CV_IPP_CHECK ( ) \ <nl> + { \ <nl> + type * s1 = ( type * ) src1 ; \ <nl> + type * s2 = ( type * ) src2 ; \ <nl> + type * d = dst ; \ <nl> + fixSteps ( width , height , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; \ <nl> + int i = 0 ; \ <nl> + for ( ; i < height ; i + + ) \ <nl> + { \ <nl> + if ( 0 > fun ( s1 , s2 , d , width ) ) \ <nl> + break ; \ <nl> + s1 = ( type * ) ( ( uchar * ) s1 + step1 ) ; \ <nl> + s2 = ( type * ) ( ( uchar * ) s2 + step2 ) ; \ <nl> + d = ( type * ) ( ( uchar * ) d + step ) ; \ <nl> + } \ <nl> + if ( i = = height ) \ <nl> + { \ <nl> + CV_IMPL_ADD ( CV_IMPL_IPP ) ; \ <nl> + return ; \ <nl> + } \ <nl> + setIppErrorStatus ( ) ; \ <nl> + } <nl> + # else <nl> + # define CALL_IPP_MIN_MAX ( fun , type ) <nl> + # endif <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / Max <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void max8u ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_max8u ) <nl> + CALL_IPP_MIN_MAX ( ippsMaxEvery_8u , uchar ) <nl> + vBinOp < uchar , cv : : OpMax < uchar > , IF_SIMD ( VMax < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void max8s ( const schar * src1 , size_t step1 , <nl> + const schar * src2 , size_t step2 , <nl> + schar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_max8s ) <nl> + vBinOp < schar , cv : : OpMax < schar > , IF_SIMD ( VMax < schar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void max16u ( const ushort * src1 , size_t step1 , <nl> + const ushort * src2 , size_t step2 , <nl> + ushort * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_max16u ) <nl> + CALL_IPP_MIN_MAX ( ippsMaxEvery_16u , ushort ) <nl> + vBinOp < ushort , cv : : OpMax < ushort > , IF_SIMD ( VMax < ushort > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void max16s ( const short * src1 , size_t step1 , <nl> + const short * src2 , size_t step2 , <nl> + short * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_max16s ) <nl> + vBinOp < short , cv : : OpMax < short > , IF_SIMD ( VMax < short > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void max32s ( const int * src1 , size_t step1 , <nl> + const int * src2 , size_t step2 , <nl> + int * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_max32s ) <nl> + vBinOp32 < int , cv : : OpMax < int > , IF_SIMD ( VMax < int > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void max32f ( const float * src1 , size_t step1 , <nl> + const float * src2 , size_t step2 , <nl> + float * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_max32f ) <nl> + CALL_IPP_MIN_MAX ( ippsMaxEvery_32f , float ) <nl> + vBinOp32 < float , cv : : OpMax < float > , IF_SIMD ( VMax < float > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void max64f ( const double * src1 , size_t step1 , <nl> + const double * src2 , size_t step2 , <nl> + double * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_max64f ) <nl> + CALL_IPP_MIN_MAX ( ippsMaxEvery_64f , double ) <nl> + vBinOp64 < double , cv : : OpMax < double > , IF_SIMD ( VMax < double > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / Min <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void min8u ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_min8u ) <nl> + CALL_IPP_MIN_MAX ( ippsMinEvery_8u , uchar ) <nl> + vBinOp < uchar , cv : : OpMin < uchar > , IF_SIMD ( VMin < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void min8s ( const schar * src1 , size_t step1 , <nl> + const schar * src2 , size_t step2 , <nl> + schar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_min8s ) <nl> + vBinOp < schar , cv : : OpMin < schar > , IF_SIMD ( VMin < schar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void min16u ( const ushort * src1 , size_t step1 , <nl> + const ushort * src2 , size_t step2 , <nl> + ushort * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_min16u ) <nl> + CALL_IPP_MIN_MAX ( ippsMinEvery_16u , ushort ) <nl> + vBinOp < ushort , cv : : OpMin < ushort > , IF_SIMD ( VMin < ushort > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void min16s ( const short * src1 , size_t step1 , <nl> + const short * src2 , size_t step2 , <nl> + short * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_min16s ) <nl> + vBinOp < short , cv : : OpMin < short > , IF_SIMD ( VMin < short > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void min32s ( const int * src1 , size_t step1 , <nl> + const int * src2 , size_t step2 , <nl> + int * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_min32s ) <nl> + vBinOp32 < int , cv : : OpMin < int > , IF_SIMD ( VMin < int > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void min32f ( const float * src1 , size_t step1 , <nl> + const float * src2 , size_t step2 , <nl> + float * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_min32f ) <nl> + CALL_IPP_MIN_MAX ( ippsMinEvery_32f , float ) <nl> + vBinOp32 < float , cv : : OpMin < float > , IF_SIMD ( VMin < float > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void min64f ( const double * src1 , size_t step1 , <nl> + const double * src2 , size_t step2 , <nl> + double * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_min64f ) <nl> + CALL_IPP_MIN_MAX ( ippsMinEvery_64f , double ) <nl> + vBinOp64 < double , cv : : OpMin < double > , IF_SIMD ( VMin < double > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / AbsDiff <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void absdiff8u ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_absdiff8u ) <nl> + CALL_IPP_BIN_12 ( ippiAbsDiff_8u_C1R ) <nl> + ( vBinOp < uchar , cv : : OpAbsDiff < uchar > , IF_SIMD ( VAbsDiff < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void absdiff8s ( const schar * src1 , size_t step1 , <nl> + const schar * src2 , size_t step2 , <nl> + schar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_absdiff8s ) <nl> + vBinOp < schar , cv : : OpAbsDiff < schar > , IF_SIMD ( VAbsDiff < schar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void absdiff16u ( const ushort * src1 , size_t step1 , <nl> + const ushort * src2 , size_t step2 , <nl> + ushort * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_absdiff16u ) <nl> + CALL_IPP_BIN_12 ( ippiAbsDiff_16u_C1R ) <nl> + ( vBinOp < ushort , cv : : OpAbsDiff < ushort > , IF_SIMD ( VAbsDiff < ushort > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void absdiff16s ( const short * src1 , size_t step1 , <nl> + const short * src2 , size_t step2 , <nl> + short * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_absdiff16s ) <nl> + vBinOp < short , cv : : OpAbsDiff < short > , IF_SIMD ( VAbsDiff < short > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void absdiff32s ( const int * src1 , size_t step1 , <nl> + const int * src2 , size_t step2 , <nl> + int * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_absdiff32s ) <nl> + vBinOp32 < int , cv : : OpAbsDiff < int > , IF_SIMD ( VAbsDiff < int > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + void absdiff32f ( const float * src1 , size_t step1 , <nl> + const float * src2 , size_t step2 , <nl> + float * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_absdiff32f ) <nl> + CALL_IPP_BIN_12 ( ippiAbsDiff_32f_C1R ) <nl> + ( vBinOp32 < float , cv : : OpAbsDiff < float > , IF_SIMD ( VAbsDiff < float > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void absdiff64f ( const double * src1 , size_t step1 , <nl> + const double * src2 , size_t step2 , <nl> + double * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_absdiff64f ) <nl> + vBinOp64 < double , cv : : OpAbsDiff < double > , IF_SIMD ( VAbsDiff < double > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / Logical <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void and8u ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_and8u ) <nl> + CALL_IPP_BIN_12 ( ippiAnd_8u_C1R ) <nl> + ( vBinOp < uchar , cv : : OpAnd < uchar > , IF_SIMD ( VAnd < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void or8u ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_or8u ) <nl> + CALL_IPP_BIN_12 ( ippiOr_8u_C1R ) <nl> + ( vBinOp < uchar , cv : : OpOr < uchar > , IF_SIMD ( VOr < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void xor8u ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_xor8u ) <nl> + CALL_IPP_BIN_12 ( ippiXor_8u_C1R ) <nl> + ( vBinOp < uchar , cv : : OpXor < uchar > , IF_SIMD ( VXor < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + void not8u ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * ) <nl> + { <nl> + CALL_HAL ( hal_not8u ) <nl> + CALL_IPP_BIN_12 ( ippiNot_8u_C1R ) <nl> + ( vBinOp < uchar , cv : : OpNot < uchar > , IF_SIMD ( VNot < uchar > ) > ( src1 , step1 , src2 , step2 , dst , step , width , height ) ) ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + # undef CALL_HAL <nl> + # define CALL_HAL ( fun ) \ <nl> + int res = fun ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( int * ) _cmpop ) ; \ <nl> + if ( res = = Error : : Ok ) \ <nl> + return ; \ <nl> + else if ( res ! = Error : : NotImplemented ) \ <nl> + throw Failure ( res ) ; <nl> + <nl> + # if ARITHM_USE_IPP <nl> + inline static IppCmpOp convert_cmp ( int _cmpop ) <nl> + { <nl> + return _cmpop = = CMP_EQ ? ippCmpEq : <nl> + _cmpop = = CMP_GT ? ippCmpGreater : <nl> + _cmpop = = CMP_GE ? ippCmpGreaterEq : <nl> + _cmpop = = CMP_LT ? ippCmpLess : <nl> + _cmpop = = CMP_LE ? ippCmpLessEq : <nl> + ( IppCmpOp ) - 1 ; <nl> + } <nl> + # define CALL_IPP_CMP ( fun ) \ <nl> + CV_IPP_CHECK ( ) \ <nl> + { \ <nl> + IppCmpOp op = convert_cmp ( * ( int * ) _cmpop ) ; \ <nl> + if ( op > = 0 ) \ <nl> + { \ <nl> + fixSteps ( width , height , sizeof ( dst [ 0 ] ) , step1 , step2 , step ) ; \ <nl> + if ( 0 < = fun ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( width , height ) , op ) ) \ <nl> + { \ <nl> + CV_IMPL_ADD ( CV_IMPL_IPP ) ; \ <nl> + return ; \ <nl> + } \ <nl> + setIppErrorStatus ( ) ; \ <nl> + } \ <nl> + } <nl> + # else <nl> + # define CALL_IPP_CMP ( fun ) <nl> + # endif <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / Compare <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void cmp8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * _cmpop ) <nl> + { <nl> + CALL_HAL ( hal_cmp8u ) <nl> + CALL_IPP_CMP ( ippiCompare_8u_C1R ) <nl> + / / vz optimized cmp_ ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( int * ) _cmpop ) ; <nl> + int code = * ( int * ) _cmpop ; <nl> + step1 / = sizeof ( src1 [ 0 ] ) ; <nl> + step2 / = sizeof ( src2 [ 0 ] ) ; <nl> + if ( code = = CMP_GE | | code = = CMP_LT ) <nl> + { <nl> + std : : swap ( src1 , src2 ) ; <nl> + std : : swap ( step1 , step2 ) ; <nl> + code = code = = CMP_GE ? CMP_LE : CMP_GT ; <nl> + } <nl> + <nl> + if ( code = = CMP_GT | | code = = CMP_LE ) <nl> + { <nl> + int m = code = = CMP_GT ? 0 : 255 ; <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int x = 0 ; <nl> + # if CV_SSE2 <nl> + if ( USE_SSE2 ) <nl> + { <nl> + __m128i m128 = code = = CMP_GT ? _mm_setzero_si128 ( ) : _mm_set1_epi8 ( - 1 ) ; <nl> + __m128i c128 = _mm_set1_epi8 ( - 128 ) ; <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + { <nl> + __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> + __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> + / / no simd for 8u comparison , that ' s why we need the trick <nl> + r00 = _mm_sub_epi8 ( r00 , c128 ) ; <nl> + r10 = _mm_sub_epi8 ( r10 , c128 ) ; <nl> + <nl> + r00 = _mm_xor_si128 ( _mm_cmpgt_epi8 ( r00 , r10 ) , m128 ) ; <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , r00 ) ; <nl> + <nl> + } <nl> + } <nl> + # elif CV_NEON <nl> + uint8x16_t mask = code = = CMP_GT ? vdupq_n_u8 ( 0 ) : vdupq_n_u8 ( 255 ) ; <nl> + <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + { <nl> + vst1q_u8 ( dst + x , veorq_u8 ( vcgtq_u8 ( vld1q_u8 ( src1 + x ) , vld1q_u8 ( src2 + x ) ) , mask ) ) ; <nl> + } <nl> + <nl> + # endif <nl> + <nl> + for ( ; x < width ; x + + ) { <nl> + dst [ x ] = ( uchar ) ( - ( src1 [ x ] > src2 [ x ] ) ^ m ) ; <nl> + } <nl> + } <nl> + } <nl> + else if ( code = = CMP_EQ | | code = = CMP_NE ) <nl> + { <nl> + int m = code = = CMP_EQ ? 0 : 255 ; <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int x = 0 ; <nl> + # if CV_SSE2 <nl> + if ( USE_SSE2 ) <nl> + { <nl> + __m128i m128 = code = = CMP_EQ ? _mm_setzero_si128 ( ) : _mm_set1_epi8 ( - 1 ) ; <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + { <nl> + __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> + __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> + r00 = _mm_xor_si128 ( _mm_cmpeq_epi8 ( r00 , r10 ) , m128 ) ; <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , r00 ) ; <nl> + } <nl> + } <nl> + # elif CV_NEON <nl> + uint8x16_t mask = code = = CMP_EQ ? vdupq_n_u8 ( 0 ) : vdupq_n_u8 ( 255 ) ; <nl> + <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + { <nl> + vst1q_u8 ( dst + x , veorq_u8 ( vceqq_u8 ( vld1q_u8 ( src1 + x ) , vld1q_u8 ( src2 + x ) ) , mask ) ) ; <nl> + } <nl> + # endif <nl> + for ( ; x < width ; x + + ) <nl> + dst [ x ] = ( uchar ) ( - ( src1 [ x ] = = src2 [ x ] ) ^ m ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void cmp8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * _cmpop ) <nl> + { <nl> + CALL_HAL ( hal_cmp8s ) <nl> + cmp_ ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( int * ) _cmpop ) ; <nl> + } <nl> + <nl> + void cmp16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * _cmpop ) <nl> + { <nl> + CALL_HAL ( hal_cmp16u ) <nl> + CALL_IPP_CMP ( ippiCompare_16u_C1R ) <nl> + cmp_ ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( int * ) _cmpop ) ; <nl> + } <nl> + <nl> + void cmp16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * _cmpop ) <nl> + { <nl> + CALL_HAL ( hal_cmp16s ) <nl> + CALL_IPP_CMP ( ippiCompare_16s_C1R ) <nl> + / / vz optimized cmp_ ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( int * ) _cmpop ) ; <nl> + <nl> + int code = * ( int * ) _cmpop ; <nl> + step1 / = sizeof ( src1 [ 0 ] ) ; <nl> + step2 / = sizeof ( src2 [ 0 ] ) ; <nl> + if ( code = = CMP_GE | | code = = CMP_LT ) <nl> + { <nl> + std : : swap ( src1 , src2 ) ; <nl> + std : : swap ( step1 , step2 ) ; <nl> + code = code = = CMP_GE ? CMP_LE : CMP_GT ; <nl> + } <nl> + <nl> + if ( code = = CMP_GT | | code = = CMP_LE ) <nl> + { <nl> + int m = code = = CMP_GT ? 0 : 255 ; <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int x = 0 ; <nl> + # if CV_SSE2 <nl> + if ( USE_SSE2 ) <nl> + { <nl> + __m128i m128 = code = = CMP_GT ? _mm_setzero_si128 ( ) : _mm_set1_epi16 ( - 1 ) ; <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + { <nl> + __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> + __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> + r00 = _mm_xor_si128 ( _mm_cmpgt_epi16 ( r00 , r10 ) , m128 ) ; <nl> + __m128i r01 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 8 ) ) ; <nl> + __m128i r11 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 8 ) ) ; <nl> + r01 = _mm_xor_si128 ( _mm_cmpgt_epi16 ( r01 , r11 ) , m128 ) ; <nl> + r11 = _mm_packs_epi16 ( r00 , r01 ) ; <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , r11 ) ; <nl> + } <nl> + if ( x < = width - 8 ) <nl> + { <nl> + __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> + __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> + r00 = _mm_xor_si128 ( _mm_cmpgt_epi16 ( r00 , r10 ) , m128 ) ; <nl> + r10 = _mm_packs_epi16 ( r00 , r00 ) ; <nl> + _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , r10 ) ; <nl> + <nl> + x + = 8 ; <nl> + } <nl> + } <nl> + # elif CV_NEON <nl> + uint8x16_t mask = code = = CMP_GT ? vdupq_n_u8 ( 0 ) : vdupq_n_u8 ( 255 ) ; <nl> + <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + { <nl> + int16x8_t in1 = vld1q_s16 ( src1 + x ) ; <nl> + int16x8_t in2 = vld1q_s16 ( src2 + x ) ; <nl> + uint8x8_t t1 = vmovn_u16 ( vcgtq_s16 ( in1 , in2 ) ) ; <nl> + <nl> + in1 = vld1q_s16 ( src1 + x + 8 ) ; <nl> + in2 = vld1q_s16 ( src2 + x + 8 ) ; <nl> + uint8x8_t t2 = vmovn_u16 ( vcgtq_s16 ( in1 , in2 ) ) ; <nl> + <nl> + vst1q_u8 ( dst + x , veorq_u8 ( vcombine_u8 ( t1 , t2 ) , mask ) ) ; <nl> + } <nl> + # endif <nl> + <nl> + for ( ; x < width ; x + + ) { <nl> + dst [ x ] = ( uchar ) ( - ( src1 [ x ] > src2 [ x ] ) ^ m ) ; <nl> + } <nl> + } <nl> + } <nl> + else if ( code = = CMP_EQ | | code = = CMP_NE ) <nl> + { <nl> + int m = code = = CMP_EQ ? 0 : 255 ; <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int x = 0 ; <nl> + # if CV_SSE2 <nl> + if ( USE_SSE2 ) <nl> + { <nl> + __m128i m128 = code = = CMP_EQ ? _mm_setzero_si128 ( ) : _mm_set1_epi16 ( - 1 ) ; <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + { <nl> + __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> + __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> + r00 = _mm_xor_si128 ( _mm_cmpeq_epi16 ( r00 , r10 ) , m128 ) ; <nl> + __m128i r01 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 8 ) ) ; <nl> + __m128i r11 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 8 ) ) ; <nl> + r01 = _mm_xor_si128 ( _mm_cmpeq_epi16 ( r01 , r11 ) , m128 ) ; <nl> + r11 = _mm_packs_epi16 ( r00 , r01 ) ; <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , r11 ) ; <nl> + } <nl> + if ( x < = width - 8 ) <nl> + { <nl> + __m128i r00 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> + __m128i r10 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> + r00 = _mm_xor_si128 ( _mm_cmpeq_epi16 ( r00 , r10 ) , m128 ) ; <nl> + r10 = _mm_packs_epi16 ( r00 , r00 ) ; <nl> + _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , r10 ) ; <nl> + <nl> + x + = 8 ; <nl> + } <nl> + } <nl> + # elif CV_NEON <nl> + uint8x16_t mask = code = = CMP_EQ ? vdupq_n_u8 ( 0 ) : vdupq_n_u8 ( 255 ) ; <nl> + <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + { <nl> + int16x8_t in1 = vld1q_s16 ( src1 + x ) ; <nl> + int16x8_t in2 = vld1q_s16 ( src2 + x ) ; <nl> + uint8x8_t t1 = vmovn_u16 ( vceqq_s16 ( in1 , in2 ) ) ; <nl> + <nl> + in1 = vld1q_s16 ( src1 + x + 8 ) ; <nl> + in2 = vld1q_s16 ( src2 + x + 8 ) ; <nl> + uint8x8_t t2 = vmovn_u16 ( vceqq_s16 ( in1 , in2 ) ) ; <nl> + <nl> + vst1q_u8 ( dst + x , veorq_u8 ( vcombine_u8 ( t1 , t2 ) , mask ) ) ; <nl> + } <nl> + # endif <nl> + for ( ; x < width ; x + + ) <nl> + dst [ x ] = ( uchar ) ( - ( src1 [ x ] = = src2 [ x ] ) ^ m ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void cmp32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * _cmpop ) <nl> + { <nl> + CALL_HAL ( hal_cmp32s ) <nl> + cmp_ ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( int * ) _cmpop ) ; <nl> + } <nl> + <nl> + void cmp32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * _cmpop ) <nl> + { <nl> + CALL_HAL ( hal_cmp32f ) <nl> + CALL_IPP_CMP ( ippiCompare_32f_C1R ) <nl> + cmp_ ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( int * ) _cmpop ) ; <nl> + } <nl> + <nl> + void cmp64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * _cmpop ) <nl> + { <nl> + CALL_HAL ( hal_cmp64f ) <nl> + cmp_ ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( int * ) _cmpop ) ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + # undef CALL_HAL <nl> + # define CALL_HAL ( fun ) \ <nl> + int res = fun ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; \ <nl> + if ( res = = Error : : Ok ) \ <nl> + return ; \ <nl> + else if ( res ! = Error : : NotImplemented ) \ <nl> + throw Failure ( res ) ; <nl> + <nl> + # if defined HAVE_IPP <nl> + # define CALL_IPP_MUL ( fun ) \ <nl> + CV_IPP_CHECK ( ) \ <nl> + { \ <nl> + if ( std : : fabs ( fscale - 1 ) < = FLT_EPSILON ) \ <nl> + { \ <nl> + if ( fun ( src1 , ( int ) step1 , src2 , ( int ) step2 , dst , ( int ) step , ippiSize ( width , height ) , 0 ) > = 0 ) \ <nl> + { \ <nl> + CV_IMPL_ADD ( CV_IMPL_IPP ) ; \ <nl> + return ; \ <nl> + } \ <nl> + setIppErrorStatus ( ) ; \ <nl> + } \ <nl> + } <nl> + # else <nl> + # define CALL_IPP_MUL ( fun ) <nl> + # endif <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / Multilpy <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void mul8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_mul8u ) <nl> + float fscale = ( float ) * ( const double * ) scale ; <nl> + CALL_IPP_MUL ( ippiMul_8u_C1RSfs ) <nl> + mul_ ( src1 , step1 , src2 , step2 , dst , step , width , height , fscale ) ; <nl> + } <nl> + <nl> + void mul8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , <nl> + schar * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_mul8s ) <nl> + mul_ ( src1 , step1 , src2 , step2 , dst , step , width , height , ( float ) * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void mul16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , <nl> + ushort * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_mul16u ) <nl> + float fscale = ( float ) * ( const double * ) scale ; <nl> + CALL_IPP_MUL ( ippiMul_16u_C1RSfs ) <nl> + mul_ ( src1 , step1 , src2 , step2 , dst , step , width , height , fscale ) ; <nl> + } <nl> + <nl> + void mul16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , <nl> + short * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_mul16s ) <nl> + float fscale = ( float ) * ( const double * ) scale ; <nl> + CALL_IPP_MUL ( ippiMul_16s_C1RSfs ) <nl> + mul_ ( src1 , step1 , src2 , step2 , dst , step , width , height , fscale ) ; <nl> + } <nl> + <nl> + void mul32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , <nl> + int * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_mul32s ) <nl> + mul_ ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void mul32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , <nl> + float * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_mul32f ) <nl> + float fscale = ( float ) * ( const double * ) scale ; <nl> + CALL_IPP_MUL ( ippiMul_32f_C1R ) <nl> + mul_ ( src1 , step1 , src2 , step2 , dst , step , width , height , fscale ) ; <nl> + } <nl> + <nl> + void mul64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , <nl> + double * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_mul64f ) <nl> + mul_ ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / Divide <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void div8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_div8u ) <nl> + if ( src1 ) <nl> + div_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + else <nl> + recip_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void div8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , <nl> + schar * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_div8s ) <nl> + div_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void div16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , <nl> + ushort * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_div16u ) <nl> + div_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void div16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , <nl> + short * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_div16s ) <nl> + div_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void div32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , <nl> + int * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_div32s ) <nl> + div_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void div32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , <nl> + float * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_div32f ) <nl> + div_f ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void div64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , <nl> + double * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_div64f ) <nl> + div_f ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / Reciprocial <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void recip8u ( const uchar * src1 , size_t step1 , const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_recip8u ) <nl> + recip_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void recip8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , <nl> + schar * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_recip8s ) <nl> + recip_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void recip16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , <nl> + ushort * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_recip16u ) <nl> + recip_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void recip16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , <nl> + short * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_recip16s ) <nl> + recip_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void recip32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , <nl> + int * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_recip32s ) <nl> + recip_i ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void recip32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , <nl> + float * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_recip32f ) <nl> + recip_f ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + void recip64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , <nl> + double * dst , size_t step , int width , int height , void * scale ) <nl> + { <nl> + CALL_HAL ( hal_recip64f ) <nl> + recip_f ( src1 , step1 , src2 , step2 , dst , step , width , height , * ( const double * ) scale ) ; <nl> + } <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + # undef CALL_HAL <nl> + # define CALL_HAL ( fun ) \ <nl> + int res = fun ( src1 , step1 , src2 , step2 , dst , step , width , height , scalars ) ; \ <nl> + if ( res = = Error : : Ok ) \ <nl> + return ; \ <nl> + else if ( res ! = Error : : NotImplemented ) \ <nl> + throw Failure ( res ) ; <nl> + <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + / / Add weighted <nl> + / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + void <nl> + addWeighted8u ( const uchar * src1 , size_t step1 , <nl> + const uchar * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , <nl> + void * scalars ) <nl> + { <nl> + CALL_HAL ( hal_addWeighted8u ) <nl> + const double * scalars_ = ( const double * ) scalars ; <nl> + float alpha = ( float ) scalars_ [ 0 ] , beta = ( float ) scalars_ [ 1 ] , gamma = ( float ) scalars_ [ 2 ] ; <nl> + <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int x = 0 ; <nl> + <nl> + # if CV_SSE2 <nl> + if ( USE_SSE2 ) <nl> + { <nl> + __m128 a4 = _mm_set1_ps ( alpha ) , b4 = _mm_set1_ps ( beta ) , g4 = _mm_set1_ps ( gamma ) ; <nl> + __m128i z = _mm_setzero_si128 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i u = _mm_unpacklo_epi8 ( _mm_loadl_epi64 ( ( const __m128i * ) ( src1 + x ) ) , z ) ; <nl> + __m128i v = _mm_unpacklo_epi8 ( _mm_loadl_epi64 ( ( const __m128i * ) ( src2 + x ) ) , z ) ; <nl> + <nl> + __m128 u0 = _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( u , z ) ) ; <nl> + __m128 u1 = _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( u , z ) ) ; <nl> + __m128 v0 = _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( v , z ) ) ; <nl> + __m128 v1 = _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( v , z ) ) ; <nl> + <nl> + u0 = _mm_add_ps ( _mm_mul_ps ( u0 , a4 ) , _mm_mul_ps ( v0 , b4 ) ) ; <nl> + u1 = _mm_add_ps ( _mm_mul_ps ( u1 , a4 ) , _mm_mul_ps ( v1 , b4 ) ) ; <nl> + u0 = _mm_add_ps ( u0 , g4 ) ; u1 = _mm_add_ps ( u1 , g4 ) ; <nl> + <nl> + u = _mm_packs_epi32 ( _mm_cvtps_epi32 ( u0 ) , _mm_cvtps_epi32 ( u1 ) ) ; <nl> + u = _mm_packus_epi16 ( u , u ) ; <nl> + <nl> + _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , u ) ; <nl> + } <nl> + } <nl> + # elif CV_NEON <nl> + float32x4_t g = vdupq_n_f32 ( gamma ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint8x8_t in1 = vld1_u8 ( src1 + x ) ; <nl> + uint16x8_t in1_16 = vmovl_u8 ( in1 ) ; <nl> + float32x4_t in1_f_l = vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( in1_16 ) ) ) ; <nl> + float32x4_t in1_f_h = vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( in1_16 ) ) ) ; <nl> + <nl> + uint8x8_t in2 = vld1_u8 ( src2 + x ) ; <nl> + uint16x8_t in2_16 = vmovl_u8 ( in2 ) ; <nl> + float32x4_t in2_f_l = vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( in2_16 ) ) ) ; <nl> + float32x4_t in2_f_h = vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( in2_16 ) ) ) ; <nl> + <nl> + float32x4_t out_f_l = vaddq_f32 ( vmulq_n_f32 ( in1_f_l , alpha ) , vmulq_n_f32 ( in2_f_l , beta ) ) ; <nl> + float32x4_t out_f_h = vaddq_f32 ( vmulq_n_f32 ( in1_f_h , alpha ) , vmulq_n_f32 ( in2_f_h , beta ) ) ; <nl> + out_f_l = vaddq_f32 ( out_f_l , g ) ; <nl> + out_f_h = vaddq_f32 ( out_f_h , g ) ; <nl> + <nl> + uint16x4_t out_16_l = vqmovun_s32 ( cv_vrndq_s32_f32 ( out_f_l ) ) ; <nl> + uint16x4_t out_16_h = vqmovun_s32 ( cv_vrndq_s32_f32 ( out_f_h ) ) ; <nl> + <nl> + uint16x8_t out_16 = vcombine_u16 ( out_16_l , out_16_h ) ; <nl> + uint8x8_t out = vqmovn_u16 ( out_16 ) ; <nl> + <nl> + vst1_u8 ( dst + x , out ) ; <nl> + } <nl> + # endif <nl> + # if CV_ENABLE_UNROLLED <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + float t0 , t1 ; <nl> + t0 = CV_8TO32F ( src1 [ x ] ) * alpha + CV_8TO32F ( src2 [ x ] ) * beta + gamma ; <nl> + t1 = CV_8TO32F ( src1 [ x + 1 ] ) * alpha + CV_8TO32F ( src2 [ x + 1 ] ) * beta + gamma ; <nl> + <nl> + dst [ x ] = saturate_cast < uchar > ( t0 ) ; <nl> + dst [ x + 1 ] = saturate_cast < uchar > ( t1 ) ; <nl> + <nl> + t0 = CV_8TO32F ( src1 [ x + 2 ] ) * alpha + CV_8TO32F ( src2 [ x + 2 ] ) * beta + gamma ; <nl> + t1 = CV_8TO32F ( src1 [ x + 3 ] ) * alpha + CV_8TO32F ( src2 [ x + 3 ] ) * beta + gamma ; <nl> + <nl> + dst [ x + 2 ] = saturate_cast < uchar > ( t0 ) ; <nl> + dst [ x + 3 ] = saturate_cast < uchar > ( t1 ) ; <nl> + } <nl> + # endif <nl> + <nl> + for ( ; x < width ; x + + ) <nl> + { <nl> + float t0 = CV_8TO32F ( src1 [ x ] ) * alpha + CV_8TO32F ( src2 [ x ] ) * beta + gamma ; <nl> + dst [ x ] = saturate_cast < uchar > ( t0 ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void addWeighted8s ( const schar * src1 , size_t step1 , const schar * src2 , size_t step2 , <nl> + schar * dst , size_t step , int width , int height , void * scalars ) <nl> + { <nl> + CALL_HAL ( hal_addWeighted8s ) <nl> + addWeighted_ < schar , float > ( src1 , step1 , src2 , step2 , dst , step , width , height , scalars ) ; <nl> + } <nl> + <nl> + void addWeighted16u ( const ushort * src1 , size_t step1 , const ushort * src2 , size_t step2 , <nl> + ushort * dst , size_t step , int width , int height , void * scalars ) <nl> + { <nl> + CALL_HAL ( hal_addWeighted16u ) <nl> + addWeighted_ < ushort , float > ( src1 , step1 , src2 , step2 , dst , step , width , height , scalars ) ; <nl> + } <nl> + <nl> + void addWeighted16s ( const short * src1 , size_t step1 , const short * src2 , size_t step2 , <nl> + short * dst , size_t step , int width , int height , void * scalars ) <nl> + { <nl> + CALL_HAL ( hal_addWeighted16s ) <nl> + addWeighted_ < short , float > ( src1 , step1 , src2 , step2 , dst , step , width , height , scalars ) ; <nl> + } <nl> + <nl> + void addWeighted32s ( const int * src1 , size_t step1 , const int * src2 , size_t step2 , <nl> + int * dst , size_t step , int width , int height , void * scalars ) <nl> + { <nl> + CALL_HAL ( hal_addWeighted32s ) <nl> + addWeighted_ < int , double > ( src1 , step1 , src2 , step2 , dst , step , width , height , scalars ) ; <nl> + } <nl> + <nl> + void addWeighted32f ( const float * src1 , size_t step1 , const float * src2 , size_t step2 , <nl> + float * dst , size_t step , int width , int height , void * scalars ) <nl> + { <nl> + CALL_HAL ( hal_addWeighted32f ) <nl> + addWeighted_ < float , double > ( src1 , step1 , src2 , step2 , dst , step , width , height , scalars ) ; <nl> + } <nl> + <nl> + void addWeighted64f ( const double * src1 , size_t step1 , const double * src2 , size_t step2 , <nl> + double * dst , size_t step , int width , int height , void * scalars ) <nl> + { <nl> + CALL_HAL ( hal_addWeighted64f ) <nl> + addWeighted_ < double , double > ( src1 , step1 , src2 , step2 , dst , step , width , height , scalars ) ; <nl> + } <nl> + <nl> + } } / / cv : : hal : : <nl> new file mode 100644 <nl> index 00000000000 . . a65e74c3812 <nl> mmm / dev / null <nl> ppp b / modules / hal / src / arithm_core . hpp <nl> <nl> + / * M / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / IMPORTANT : READ BEFORE DOWNLOADING , COPYING , INSTALLING OR USING . <nl> + / / <nl> + / / By downloading , copying , installing or using the software you agree to this license . <nl> + / / If you do not agree to this license , do not download , install , <nl> + / / copy or use the software . <nl> + / / <nl> + / / <nl> + / / License Agreement <nl> + / / For Open Source Computer Vision Library <nl> + / / <nl> + / / Copyright ( C ) 2000 - 2008 , Intel Corporation , all rights reserved . <nl> + / / Copyright ( C ) 2009 , Willow Garage Inc . , all rights reserved . <nl> + / / Copyright ( C ) 2013 , OpenCV Foundation , all rights reserved . <nl> + / / Copyright ( C ) 2015 , Itseez Inc . , all rights reserved . <nl> + / / Third party copyrights are property of their respective owners . <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without modification , <nl> + / / are permitted provided that the following conditions are met : <nl> + / / <nl> + / / * Redistribution ' s of source code must retain the above copyright notice , <nl> + / / this list of conditions and the following disclaimer . <nl> + / / <nl> + / / * Redistribution ' s in binary form must reproduce the above copyright notice , <nl> + / / this list of conditions and the following disclaimer in the documentation <nl> + / / and / or other materials provided with the distribution . <nl> + / / <nl> + / / * The name of the copyright holders may not be used to endorse or promote products <nl> + / / derived from this software without specific prior written permission . <nl> + / / <nl> + / / This software is provided by the copyright holders and contributors " as is " and <nl> + / / any express or implied warranties , including , but not limited to , the implied <nl> + / / warranties of merchantability and fitness for a particular purpose are disclaimed . <nl> + / / In no event shall the Intel Corporation or contributors be liable for any direct , <nl> + / / indirect , incidental , special , exemplary , or consequential damages <nl> + / / ( including , but not limited to , procurement of substitute goods or services ; <nl> + / / loss of use , data , or profits ; or business interruption ) however caused <nl> + / / and on any theory of liability , whether in contract , strict liability , <nl> + / / or tort ( including negligence or otherwise ) arising in any way out of <nl> + / / the use of this software , even if advised of the possibility of such damage . <nl> + / / <nl> + / / M * / <nl> + <nl> + # ifndef __OPENCV_HAL_ARITHM_CORE_HPP__ <nl> + # define __OPENCV_HAL_ARITHM_CORE_HPP__ <nl> + <nl> + # include " arithm_simd . hpp " <nl> + <nl> + const uchar g_Saturate8u [ ] = <nl> + { <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , <nl> + 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , <nl> + 32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , <nl> + 48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 , <nl> + 64 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , <nl> + 80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 91 , 92 , 93 , 94 , 95 , <nl> + 96 , 97 , 98 , 99 , 100 , 101 , 102 , 103 , 104 , 105 , 106 , 107 , 108 , 109 , 110 , 111 , <nl> + 112 , 113 , 114 , 115 , 116 , 117 , 118 , 119 , 120 , 121 , 122 , 123 , 124 , 125 , 126 , 127 , <nl> + 128 , 129 , 130 , 131 , 132 , 133 , 134 , 135 , 136 , 137 , 138 , 139 , 140 , 141 , 142 , 143 , <nl> + 144 , 145 , 146 , 147 , 148 , 149 , 150 , 151 , 152 , 153 , 154 , 155 , 156 , 157 , 158 , 159 , <nl> + 160 , 161 , 162 , 163 , 164 , 165 , 166 , 167 , 168 , 169 , 170 , 171 , 172 , 173 , 174 , 175 , <nl> + 176 , 177 , 178 , 179 , 180 , 181 , 182 , 183 , 184 , 185 , 186 , 187 , 188 , 189 , 190 , 191 , <nl> + 192 , 193 , 194 , 195 , 196 , 197 , 198 , 199 , 200 , 201 , 202 , 203 , 204 , 205 , 206 , 207 , <nl> + 208 , 209 , 210 , 211 , 212 , 213 , 214 , 215 , 216 , 217 , 218 , 219 , 220 , 221 , 222 , 223 , <nl> + 224 , 225 , 226 , 227 , 228 , 229 , 230 , 231 , 232 , 233 , 234 , 235 , 236 , 237 , 238 , 239 , <nl> + 240 , 241 , 242 , 243 , 244 , 245 , 246 , 247 , 248 , 249 , 250 , 251 , 252 , 253 , 254 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , <nl> + 255 <nl> + } ; <nl> + <nl> + <nl> + # define CV_FAST_CAST_8U ( t ) ( assert ( - 256 < = ( t ) & & ( t ) < = 512 ) , g_Saturate8u [ ( t ) + 256 ] ) <nl> + # define CV_MIN_8U ( a , b ) ( ( a ) - CV_FAST_CAST_8U ( ( a ) - ( b ) ) ) <nl> + # define CV_MAX_8U ( a , b ) ( ( a ) + CV_FAST_CAST_8U ( ( b ) - ( a ) ) ) <nl> + <nl> + const float g_8x32fTab [ ] = <nl> + { <nl> + - 128 . f , - 127 . f , - 126 . f , - 125 . f , - 124 . f , - 123 . f , - 122 . f , - 121 . f , <nl> + - 120 . f , - 119 . f , - 118 . f , - 117 . f , - 116 . f , - 115 . f , - 114 . f , - 113 . f , <nl> + - 112 . f , - 111 . f , - 110 . f , - 109 . f , - 108 . f , - 107 . f , - 106 . f , - 105 . f , <nl> + - 104 . f , - 103 . f , - 102 . f , - 101 . f , - 100 . f , - 99 . f , - 98 . f , - 97 . f , <nl> + - 96 . f , - 95 . f , - 94 . f , - 93 . f , - 92 . f , - 91 . f , - 90 . f , - 89 . f , <nl> + - 88 . f , - 87 . f , - 86 . f , - 85 . f , - 84 . f , - 83 . f , - 82 . f , - 81 . f , <nl> + - 80 . f , - 79 . f , - 78 . f , - 77 . f , - 76 . f , - 75 . f , - 74 . f , - 73 . f , <nl> + - 72 . f , - 71 . f , - 70 . f , - 69 . f , - 68 . f , - 67 . f , - 66 . f , - 65 . f , <nl> + - 64 . f , - 63 . f , - 62 . f , - 61 . f , - 60 . f , - 59 . f , - 58 . f , - 57 . f , <nl> + - 56 . f , - 55 . f , - 54 . f , - 53 . f , - 52 . f , - 51 . f , - 50 . f , - 49 . f , <nl> + - 48 . f , - 47 . f , - 46 . f , - 45 . f , - 44 . f , - 43 . f , - 42 . f , - 41 . f , <nl> + - 40 . f , - 39 . f , - 38 . f , - 37 . f , - 36 . f , - 35 . f , - 34 . f , - 33 . f , <nl> + - 32 . f , - 31 . f , - 30 . f , - 29 . f , - 28 . f , - 27 . f , - 26 . f , - 25 . f , <nl> + - 24 . f , - 23 . f , - 22 . f , - 21 . f , - 20 . f , - 19 . f , - 18 . f , - 17 . f , <nl> + - 16 . f , - 15 . f , - 14 . f , - 13 . f , - 12 . f , - 11 . f , - 10 . f , - 9 . f , <nl> + - 8 . f , - 7 . f , - 6 . f , - 5 . f , - 4 . f , - 3 . f , - 2 . f , - 1 . f , <nl> + 0 . f , 1 . f , 2 . f , 3 . f , 4 . f , 5 . f , 6 . f , 7 . f , <nl> + 8 . f , 9 . f , 10 . f , 11 . f , 12 . f , 13 . f , 14 . f , 15 . f , <nl> + 16 . f , 17 . f , 18 . f , 19 . f , 20 . f , 21 . f , 22 . f , 23 . f , <nl> + 24 . f , 25 . f , 26 . f , 27 . f , 28 . f , 29 . f , 30 . f , 31 . f , <nl> + 32 . f , 33 . f , 34 . f , 35 . f , 36 . f , 37 . f , 38 . f , 39 . f , <nl> + 40 . f , 41 . f , 42 . f , 43 . f , 44 . f , 45 . f , 46 . f , 47 . f , <nl> + 48 . f , 49 . f , 50 . f , 51 . f , 52 . f , 53 . f , 54 . f , 55 . f , <nl> + 56 . f , 57 . f , 58 . f , 59 . f , 60 . f , 61 . f , 62 . f , 63 . f , <nl> + 64 . f , 65 . f , 66 . f , 67 . f , 68 . f , 69 . f , 70 . f , 71 . f , <nl> + 72 . f , 73 . f , 74 . f , 75 . f , 76 . f , 77 . f , 78 . f , 79 . f , <nl> + 80 . f , 81 . f , 82 . f , 83 . f , 84 . f , 85 . f , 86 . f , 87 . f , <nl> + 88 . f , 89 . f , 90 . f , 91 . f , 92 . f , 93 . f , 94 . f , 95 . f , <nl> + 96 . f , 97 . f , 98 . f , 99 . f , 100 . f , 101 . f , 102 . f , 103 . f , <nl> + 104 . f , 105 . f , 106 . f , 107 . f , 108 . f , 109 . f , 110 . f , 111 . f , <nl> + 112 . f , 113 . f , 114 . f , 115 . f , 116 . f , 117 . f , 118 . f , 119 . f , <nl> + 120 . f , 121 . f , 122 . f , 123 . f , 124 . f , 125 . f , 126 . f , 127 . f , <nl> + 128 . f , 129 . f , 130 . f , 131 . f , 132 . f , 133 . f , 134 . f , 135 . f , <nl> + 136 . f , 137 . f , 138 . f , 139 . f , 140 . f , 141 . f , 142 . f , 143 . f , <nl> + 144 . f , 145 . f , 146 . f , 147 . f , 148 . f , 149 . f , 150 . f , 151 . f , <nl> + 152 . f , 153 . f , 154 . f , 155 . f , 156 . f , 157 . f , 158 . f , 159 . f , <nl> + 160 . f , 161 . f , 162 . f , 163 . f , 164 . f , 165 . f , 166 . f , 167 . f , <nl> + 168 . f , 169 . f , 170 . f , 171 . f , 172 . f , 173 . f , 174 . f , 175 . f , <nl> + 176 . f , 177 . f , 178 . f , 179 . f , 180 . f , 181 . f , 182 . f , 183 . f , <nl> + 184 . f , 185 . f , 186 . f , 187 . f , 188 . f , 189 . f , 190 . f , 191 . f , <nl> + 192 . f , 193 . f , 194 . f , 195 . f , 196 . f , 197 . f , 198 . f , 199 . f , <nl> + 200 . f , 201 . f , 202 . f , 203 . f , 204 . f , 205 . f , 206 . f , 207 . f , <nl> + 208 . f , 209 . f , 210 . f , 211 . f , 212 . f , 213 . f , 214 . f , 215 . f , <nl> + 216 . f , 217 . f , 218 . f , 219 . f , 220 . f , 221 . f , 222 . f , 223 . f , <nl> + 224 . f , 225 . f , 226 . f , 227 . f , 228 . f , 229 . f , 230 . f , 231 . f , <nl> + 232 . f , 233 . f , 234 . f , 235 . f , 236 . f , 237 . f , 238 . f , 239 . f , <nl> + 240 . f , 241 . f , 242 . f , 243 . f , 244 . f , 245 . f , 246 . f , 247 . f , <nl> + 248 . f , 249 . f , 250 . f , 251 . f , 252 . f , 253 . f , 254 . f , 255 . f <nl> + } ; <nl> + <nl> + # define CV_8TO32F ( x ) g_8x32fTab [ ( x ) + 128 ] <nl> + <nl> + namespace cv { <nl> + <nl> + template < > inline uchar OpAdd < uchar > : : operator ( ) ( uchar a , uchar b ) const <nl> + { return CV_FAST_CAST_8U ( a + b ) ; } <nl> + <nl> + template < > inline uchar OpSub < uchar > : : operator ( ) ( uchar a , uchar b ) const <nl> + { return CV_FAST_CAST_8U ( a - b ) ; } <nl> + <nl> + template < > inline short OpAbsDiff < short > : : operator ( ) ( short a , short b ) const <nl> + { return saturate_cast < short > ( std : : abs ( a - b ) ) ; } <nl> + <nl> + template < > inline schar OpAbsDiff < schar > : : operator ( ) ( schar a , schar b ) const <nl> + { return saturate_cast < schar > ( std : : abs ( a - b ) ) ; } <nl> + <nl> + template < > inline uchar OpMin < uchar > : : operator ( ) ( uchar a , uchar b ) const { return CV_MIN_8U ( a , b ) ; } <nl> + <nl> + template < > inline uchar OpMax < uchar > : : operator ( ) ( uchar a , uchar b ) const { return CV_MAX_8U ( a , b ) ; } <nl> + <nl> + } <nl> + <nl> + namespace cv { namespace hal { <nl> + <nl> + template < typename T , class Op , class VOp > <nl> + void vBinOp ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , T * dst , size_t step , int width , int height ) <nl> + { <nl> + # if CV_SSE2 | | CV_NEON <nl> + VOp vop ; <nl> + # endif <nl> + Op op ; <nl> + <nl> + for ( ; height - - ; src1 = ( const T * ) ( ( const uchar * ) src1 + step1 ) , <nl> + src2 = ( const T * ) ( ( const uchar * ) src2 + step2 ) , <nl> + dst = ( T * ) ( ( uchar * ) dst + step ) ) <nl> + { <nl> + int x = 0 ; <nl> + <nl> + # if CV_NEON | | CV_SSE2 <nl> + # if CV_AVX2 <nl> + if ( USE_AVX2 ) <nl> + { <nl> + for ( ; x < = width - 32 / ( int ) sizeof ( T ) ; x + = 32 / sizeof ( T ) ) <nl> + { <nl> + typename VLoadStore256 < T > : : reg_type r0 = VLoadStore256 < T > : : load ( src1 + x ) ; <nl> + r0 = vop ( r0 , VLoadStore256 < T > : : load ( src2 + x ) ) ; <nl> + VLoadStore256 < T > : : store ( dst + x , r0 ) ; <nl> + } <nl> + } <nl> + # else <nl> + # if CV_SSE2 <nl> + if ( USE_SSE2 ) <nl> + { <nl> + # endif / / CV_SSE2 <nl> + for ( ; x < = width - 32 / ( int ) sizeof ( T ) ; x + = 32 / sizeof ( T ) ) <nl> + { <nl> + typename VLoadStore128 < T > : : reg_type r0 = VLoadStore128 < T > : : load ( src1 + x ) ; <nl> + typename VLoadStore128 < T > : : reg_type r1 = VLoadStore128 < T > : : load ( src1 + x + 16 / sizeof ( T ) ) ; <nl> + r0 = vop ( r0 , VLoadStore128 < T > : : load ( src2 + x ) ) ; <nl> + r1 = vop ( r1 , VLoadStore128 < T > : : load ( src2 + x + 16 / sizeof ( T ) ) ) ; <nl> + VLoadStore128 < T > : : store ( dst + x , r0 ) ; <nl> + VLoadStore128 < T > : : store ( dst + x + 16 / sizeof ( T ) , r1 ) ; <nl> + } <nl> + # if CV_SSE2 <nl> + } <nl> + # endif / / CV_SSE2 <nl> + # endif / / CV_AVX2 <nl> + # endif / / CV_NEON | | CV_SSE2 <nl> + <nl> + # if CV_AVX2 <nl> + / / nothing <nl> + # elif CV_SSE2 <nl> + if ( USE_SSE2 ) <nl> + { <nl> + for ( ; x < = width - 8 / ( int ) sizeof ( T ) ; x + = 8 / sizeof ( T ) ) <nl> + { <nl> + typename VLoadStore64 < T > : : reg_type r = VLoadStore64 < T > : : load ( src1 + x ) ; <nl> + r = vop ( r , VLoadStore64 < T > : : load ( src2 + x ) ) ; <nl> + VLoadStore64 < T > : : store ( dst + x , r ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> + # if CV_ENABLE_UNROLLED <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + T v0 = op ( src1 [ x ] , src2 [ x ] ) ; <nl> + T v1 = op ( src1 [ x + 1 ] , src2 [ x + 1 ] ) ; <nl> + dst [ x ] = v0 ; dst [ x + 1 ] = v1 ; <nl> + v0 = op ( src1 [ x + 2 ] , src2 [ x + 2 ] ) ; <nl> + v1 = op ( src1 [ x + 3 ] , src2 [ x + 3 ] ) ; <nl> + dst [ x + 2 ] = v0 ; dst [ x + 3 ] = v1 ; <nl> + } <nl> + # endif <nl> + <nl> + for ( ; x < width ; x + + ) <nl> + dst [ x ] = op ( src1 [ x ] , src2 [ x ] ) ; <nl> + } <nl> + } <nl> + <nl> + template < typename T , class Op , class Op32 > <nl> + void vBinOp32 ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> + T * dst , size_t step , int width , int height ) <nl> + { <nl> + # if CV_SSE2 | | CV_NEON <nl> + Op32 op32 ; <nl> + # endif <nl> + Op op ; <nl> + <nl> + for ( ; height - - ; src1 = ( const T * ) ( ( const uchar * ) src1 + step1 ) , <nl> + src2 = ( const T * ) ( ( const uchar * ) src2 + step2 ) , <nl> + dst = ( T * ) ( ( uchar * ) dst + step ) ) <nl> + { <nl> + int x = 0 ; <nl> + <nl> + # if CV_AVX2 <nl> + if ( USE_AVX2 ) <nl> + { <nl> + if ( ( ( ( size_t ) src1 | ( size_t ) src2 | ( size_t ) dst ) & 31 ) = = 0 ) <nl> + { <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + typename VLoadStore256Aligned < T > : : reg_type r0 = VLoadStore256Aligned < T > : : load ( src1 + x ) ; <nl> + r0 = op32 ( r0 , VLoadStore256Aligned < T > : : load ( src2 + x ) ) ; <nl> + VLoadStore256Aligned < T > : : store ( dst + x , r0 ) ; <nl> + } <nl> + } <nl> + } <nl> + # elif CV_SSE2 <nl> + if ( USE_SSE2 ) <nl> + { <nl> + if ( ( ( ( size_t ) src1 | ( size_t ) src2 | ( size_t ) dst ) & 15 ) = = 0 ) <nl> + { <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + typename VLoadStore128Aligned < T > : : reg_type r0 = VLoadStore128Aligned < T > : : load ( src1 + x ) ; <nl> + typename VLoadStore128Aligned < T > : : reg_type r1 = VLoadStore128Aligned < T > : : load ( src1 + x + 4 ) ; <nl> + r0 = op32 ( r0 , VLoadStore128Aligned < T > : : load ( src2 + x ) ) ; <nl> + r1 = op32 ( r1 , VLoadStore128Aligned < T > : : load ( src2 + x + 4 ) ) ; <nl> + VLoadStore128Aligned < T > : : store ( dst + x , r0 ) ; <nl> + VLoadStore128Aligned < T > : : store ( dst + x + 4 , r1 ) ; <nl> + } <nl> + } <nl> + } <nl> + # endif / / CV_AVX2 <nl> + <nl> + # if CV_NEON | | CV_SSE2 <nl> + # if CV_AVX2 <nl> + if ( USE_AVX2 ) <nl> + { <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + typename VLoadStore256 < T > : : reg_type r0 = VLoadStore256 < T > : : load ( src1 + x ) ; <nl> + r0 = op32 ( r0 , VLoadStore256 < T > : : load ( src2 + x ) ) ; <nl> + VLoadStore256 < T > : : store ( dst + x , r0 ) ; <nl> + } <nl> + } <nl> + # else <nl> + # if CV_SSE2 <nl> + if ( USE_SSE2 ) <nl> + { <nl> + # endif / / CV_SSE2 <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + typename VLoadStore128 < T > : : reg_type r0 = VLoadStore128 < T > : : load ( src1 + x ) ; <nl> + typename VLoadStore128 < T > : : reg_type r1 = VLoadStore128 < T > : : load ( src1 + x + 4 ) ; <nl> + r0 = op32 ( r0 , VLoadStore128 < T > : : load ( src2 + x ) ) ; <nl> + r1 = op32 ( r1 , VLoadStore128 < T > : : load ( src2 + x + 4 ) ) ; <nl> + VLoadStore128 < T > : : store ( dst + x , r0 ) ; <nl> + VLoadStore128 < T > : : store ( dst + x + 4 , r1 ) ; <nl> + } <nl> + # if CV_SSE2 <nl> + } <nl> + # endif / / CV_SSE2 <nl> + # endif / / CV_AVX2 <nl> + # endif / / CV_NEON | | CV_SSE2 <nl> + <nl> + # if CV_ENABLE_UNROLLED <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + T v0 = op ( src1 [ x ] , src2 [ x ] ) ; <nl> + T v1 = op ( src1 [ x + 1 ] , src2 [ x + 1 ] ) ; <nl> + dst [ x ] = v0 ; dst [ x + 1 ] = v1 ; <nl> + v0 = op ( src1 [ x + 2 ] , src2 [ x + 2 ] ) ; <nl> + v1 = op ( src1 [ x + 3 ] , src2 [ x + 3 ] ) ; <nl> + dst [ x + 2 ] = v0 ; dst [ x + 3 ] = v1 ; <nl> + } <nl> + # endif <nl> + <nl> + for ( ; x < width ; x + + ) <nl> + dst [ x ] = op ( src1 [ x ] , src2 [ x ] ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + template < typename T , class Op , class Op64 > <nl> + void vBinOp64 ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> + T * dst , size_t step , int width , int height ) <nl> + { <nl> + # if CV_SSE2 <nl> + Op64 op64 ; <nl> + # endif <nl> + Op op ; <nl> + <nl> + for ( ; height - - ; src1 = ( const T * ) ( ( const uchar * ) src1 + step1 ) , <nl> + src2 = ( const T * ) ( ( const uchar * ) src2 + step2 ) , <nl> + dst = ( T * ) ( ( uchar * ) dst + step ) ) <nl> + { <nl> + int x = 0 ; <nl> + <nl> + # if CV_AVX2 <nl> + if ( USE_AVX2 ) <nl> + { <nl> + if ( ( ( ( size_t ) src1 | ( size_t ) src2 | ( size_t ) dst ) & 31 ) = = 0 ) <nl> + { <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + typename VLoadStore256Aligned < T > : : reg_type r0 = VLoadStore256Aligned < T > : : load ( src1 + x ) ; <nl> + r0 = op64 ( r0 , VLoadStore256Aligned < T > : : load ( src2 + x ) ) ; <nl> + VLoadStore256Aligned < T > : : store ( dst + x , r0 ) ; <nl> + } <nl> + } <nl> + } <nl> + # elif CV_SSE2 <nl> + if ( USE_SSE2 ) <nl> + { <nl> + if ( ( ( ( size_t ) src1 | ( size_t ) src2 | ( size_t ) dst ) & 15 ) = = 0 ) <nl> + { <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + typename VLoadStore128Aligned < T > : : reg_type r0 = VLoadStore128Aligned < T > : : load ( src1 + x ) ; <nl> + typename VLoadStore128Aligned < T > : : reg_type r1 = VLoadStore128Aligned < T > : : load ( src1 + x + 2 ) ; <nl> + r0 = op64 ( r0 , VLoadStore128Aligned < T > : : load ( src2 + x ) ) ; <nl> + r1 = op64 ( r1 , VLoadStore128Aligned < T > : : load ( src2 + x + 2 ) ) ; <nl> + VLoadStore128Aligned < T > : : store ( dst + x , r0 ) ; <nl> + VLoadStore128Aligned < T > : : store ( dst + x + 2 , r1 ) ; <nl> + } <nl> + } <nl> + } <nl> + # endif <nl> + <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + T v0 = op ( src1 [ x ] , src2 [ x ] ) ; <nl> + T v1 = op ( src1 [ x + 1 ] , src2 [ x + 1 ] ) ; <nl> + dst [ x ] = v0 ; dst [ x + 1 ] = v1 ; <nl> + v0 = op ( src1 [ x + 2 ] , src2 [ x + 2 ] ) ; <nl> + v1 = op ( src1 [ x + 3 ] , src2 [ x + 3 ] ) ; <nl> + dst [ x + 2 ] = v0 ; dst [ x + 3 ] = v1 ; <nl> + } <nl> + <nl> + for ( ; x < width ; x + + ) <nl> + dst [ x ] = op ( src1 [ x ] , src2 [ x ] ) ; <nl> + } <nl> + } <nl> + <nl> + template < typename T > static void <nl> + cmp_ ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> + uchar * dst , size_t step , int width , int height , int code ) <nl> + { <nl> + step1 / = sizeof ( src1 [ 0 ] ) ; <nl> + step2 / = sizeof ( src2 [ 0 ] ) ; <nl> + if ( code = = CMP_GE | | code = = CMP_LT ) <nl> + { <nl> + std : : swap ( src1 , src2 ) ; <nl> + std : : swap ( step1 , step2 ) ; <nl> + code = code = = CMP_GE ? CMP_LE : CMP_GT ; <nl> + } <nl> + <nl> + Cmp_SIMD < T > vop ( code ) ; <nl> + <nl> + if ( code = = CMP_GT | | code = = CMP_LE ) <nl> + { <nl> + int m = code = = CMP_GT ? 0 : 255 ; <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int x = vop ( src1 , src2 , dst , width ) ; <nl> + # if CV_ENABLE_UNROLLED <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + int t0 , t1 ; <nl> + t0 = - ( src1 [ x ] > src2 [ x ] ) ^ m ; <nl> + t1 = - ( src1 [ x + 1 ] > src2 [ x + 1 ] ) ^ m ; <nl> + dst [ x ] = ( uchar ) t0 ; dst [ x + 1 ] = ( uchar ) t1 ; <nl> + t0 = - ( src1 [ x + 2 ] > src2 [ x + 2 ] ) ^ m ; <nl> + t1 = - ( src1 [ x + 3 ] > src2 [ x + 3 ] ) ^ m ; <nl> + dst [ x + 2 ] = ( uchar ) t0 ; dst [ x + 3 ] = ( uchar ) t1 ; <nl> + } <nl> + # endif <nl> + for ( ; x < width ; x + + ) <nl> + dst [ x ] = ( uchar ) ( - ( src1 [ x ] > src2 [ x ] ) ^ m ) ; <nl> + } <nl> + } <nl> + else if ( code = = CMP_EQ | | code = = CMP_NE ) <nl> + { <nl> + int m = code = = CMP_EQ ? 0 : 255 ; <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int x = 0 ; <nl> + # if CV_ENABLE_UNROLLED <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + int t0 , t1 ; <nl> + t0 = - ( src1 [ x ] = = src2 [ x ] ) ^ m ; <nl> + t1 = - ( src1 [ x + 1 ] = = src2 [ x + 1 ] ) ^ m ; <nl> + dst [ x ] = ( uchar ) t0 ; dst [ x + 1 ] = ( uchar ) t1 ; <nl> + t0 = - ( src1 [ x + 2 ] = = src2 [ x + 2 ] ) ^ m ; <nl> + t1 = - ( src1 [ x + 3 ] = = src2 [ x + 3 ] ) ^ m ; <nl> + dst [ x + 2 ] = ( uchar ) t0 ; dst [ x + 3 ] = ( uchar ) t1 ; <nl> + } <nl> + # endif <nl> + for ( ; x < width ; x + + ) <nl> + dst [ x ] = ( uchar ) ( - ( src1 [ x ] = = src2 [ x ] ) ^ m ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + template < typename T , typename WT > static void <nl> + mul_ ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> + T * dst , size_t step , int width , int height , WT scale ) <nl> + { <nl> + step1 / = sizeof ( src1 [ 0 ] ) ; <nl> + step2 / = sizeof ( src2 [ 0 ] ) ; <nl> + step / = sizeof ( dst [ 0 ] ) ; <nl> + <nl> + Mul_SIMD < T , WT > vop ; <nl> + <nl> + if ( scale = = ( WT ) 1 . ) <nl> + { <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int i = vop ( src1 , src2 , dst , width , scale ) ; <nl> + # if CV_ENABLE_UNROLLED <nl> + for ( ; i < = width - 4 ; i + = 4 ) <nl> + { <nl> + T t0 ; <nl> + T t1 ; <nl> + t0 = saturate_cast < T > ( src1 [ i ] * src2 [ i ] ) ; <nl> + t1 = saturate_cast < T > ( src1 [ i + 1 ] * src2 [ i + 1 ] ) ; <nl> + dst [ i ] = t0 ; <nl> + dst [ i + 1 ] = t1 ; <nl> + <nl> + t0 = saturate_cast < T > ( src1 [ i + 2 ] * src2 [ i + 2 ] ) ; <nl> + t1 = saturate_cast < T > ( src1 [ i + 3 ] * src2 [ i + 3 ] ) ; <nl> + dst [ i + 2 ] = t0 ; <nl> + dst [ i + 3 ] = t1 ; <nl> + } <nl> + # endif <nl> + for ( ; i < width ; i + + ) <nl> + dst [ i ] = saturate_cast < T > ( src1 [ i ] * src2 [ i ] ) ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int i = vop ( src1 , src2 , dst , width , scale ) ; <nl> + # if CV_ENABLE_UNROLLED <nl> + for ( ; i < = width - 4 ; i + = 4 ) <nl> + { <nl> + T t0 = saturate_cast < T > ( scale * ( WT ) src1 [ i ] * src2 [ i ] ) ; <nl> + T t1 = saturate_cast < T > ( scale * ( WT ) src1 [ i + 1 ] * src2 [ i + 1 ] ) ; <nl> + dst [ i ] = t0 ; dst [ i + 1 ] = t1 ; <nl> + <nl> + t0 = saturate_cast < T > ( scale * ( WT ) src1 [ i + 2 ] * src2 [ i + 2 ] ) ; <nl> + t1 = saturate_cast < T > ( scale * ( WT ) src1 [ i + 3 ] * src2 [ i + 3 ] ) ; <nl> + dst [ i + 2 ] = t0 ; dst [ i + 3 ] = t1 ; <nl> + } <nl> + # endif <nl> + for ( ; i < width ; i + + ) <nl> + dst [ i ] = saturate_cast < T > ( scale * ( WT ) src1 [ i ] * src2 [ i ] ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + <nl> + template < typename T > static void <nl> + div_i ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> + T * dst , size_t step , int width , int height , double scale ) <nl> + { <nl> + step1 / = sizeof ( src1 [ 0 ] ) ; <nl> + step2 / = sizeof ( src2 [ 0 ] ) ; <nl> + step / = sizeof ( dst [ 0 ] ) ; <nl> + <nl> + Div_SIMD < T > vop ; <nl> + float scale_f = ( float ) scale ; <nl> + <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int i = vop ( src1 , src2 , dst , width , scale ) ; <nl> + for ( ; i < width ; i + + ) <nl> + { <nl> + T num = src1 [ i ] , denom = src2 [ i ] ; <nl> + dst [ i ] = denom ! = 0 ? saturate_cast < T > ( num * scale_f / denom ) : ( T ) 0 ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + template < typename T > static void <nl> + div_f ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> + T * dst , size_t step , int width , int height , double scale ) <nl> + { <nl> + T scale_f = ( T ) scale ; <nl> + step1 / = sizeof ( src1 [ 0 ] ) ; <nl> + step2 / = sizeof ( src2 [ 0 ] ) ; <nl> + step / = sizeof ( dst [ 0 ] ) ; <nl> + <nl> + Div_SIMD < T > vop ; <nl> + <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int i = vop ( src1 , src2 , dst , width , scale ) ; <nl> + for ( ; i < width ; i + + ) <nl> + { <nl> + T num = src1 [ i ] , denom = src2 [ i ] ; <nl> + dst [ i ] = denom ! = 0 ? saturate_cast < T > ( num * scale_f / denom ) : ( T ) 0 ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + template < typename T > static void <nl> + recip_i ( const T * , size_t , const T * src2 , size_t step2 , <nl> + T * dst , size_t step , int width , int height , double scale ) <nl> + { <nl> + step2 / = sizeof ( src2 [ 0 ] ) ; <nl> + step / = sizeof ( dst [ 0 ] ) ; <nl> + <nl> + Recip_SIMD < T > vop ; <nl> + float scale_f = ( float ) scale ; <nl> + <nl> + for ( ; height - - ; src2 + = step2 , dst + = step ) <nl> + { <nl> + int i = vop ( src2 , dst , width , scale ) ; <nl> + for ( ; i < width ; i + + ) <nl> + { <nl> + T denom = src2 [ i ] ; <nl> + dst [ i ] = denom ! = 0 ? saturate_cast < T > ( scale_f / denom ) : ( T ) 0 ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + template < typename T > static void <nl> + recip_f ( const T * , size_t , const T * src2 , size_t step2 , <nl> + T * dst , size_t step , int width , int height , double scale ) <nl> + { <nl> + T scale_f = ( T ) scale ; <nl> + step2 / = sizeof ( src2 [ 0 ] ) ; <nl> + step / = sizeof ( dst [ 0 ] ) ; <nl> + <nl> + Recip_SIMD < T > vop ; <nl> + <nl> + for ( ; height - - ; src2 + = step2 , dst + = step ) <nl> + { <nl> + int i = vop ( src2 , dst , width , scale ) ; <nl> + for ( ; i < width ; i + + ) <nl> + { <nl> + T denom = src2 [ i ] ; <nl> + dst [ i ] = denom ! = 0 ? saturate_cast < T > ( scale_f / denom ) : ( T ) 0 ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + template < typename T , typename WT > static void <nl> + addWeighted_ ( const T * src1 , size_t step1 , const T * src2 , size_t step2 , <nl> + T * dst , size_t step , int width , int height , void * _scalars ) <nl> + { <nl> + const double * scalars = ( const double * ) _scalars ; <nl> + WT alpha = ( WT ) scalars [ 0 ] , beta = ( WT ) scalars [ 1 ] , gamma = ( WT ) scalars [ 2 ] ; <nl> + step1 / = sizeof ( src1 [ 0 ] ) ; <nl> + step2 / = sizeof ( src2 [ 0 ] ) ; <nl> + step / = sizeof ( dst [ 0 ] ) ; <nl> + <nl> + AddWeighted_SIMD < T , WT > vop ; <nl> + <nl> + for ( ; height - - ; src1 + = step1 , src2 + = step2 , dst + = step ) <nl> + { <nl> + int x = vop ( src1 , src2 , dst , width , alpha , beta , gamma ) ; <nl> + # if CV_ENABLE_UNROLLED <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + T t0 = saturate_cast < T > ( src1 [ x ] * alpha + src2 [ x ] * beta + gamma ) ; <nl> + T t1 = saturate_cast < T > ( src1 [ x + 1 ] * alpha + src2 [ x + 1 ] * beta + gamma ) ; <nl> + dst [ x ] = t0 ; dst [ x + 1 ] = t1 ; <nl> + <nl> + t0 = saturate_cast < T > ( src1 [ x + 2 ] * alpha + src2 [ x + 2 ] * beta + gamma ) ; <nl> + t1 = saturate_cast < T > ( src1 [ x + 3 ] * alpha + src2 [ x + 3 ] * beta + gamma ) ; <nl> + dst [ x + 2 ] = t0 ; dst [ x + 3 ] = t1 ; <nl> + } <nl> + # endif <nl> + for ( ; x < width ; x + + ) <nl> + dst [ x ] = saturate_cast < T > ( src1 [ x ] * alpha + src2 [ x ] * beta + gamma ) ; <nl> + } <nl> + } <nl> + <nl> + } } / / cv : : hal : : <nl> + <nl> + <nl> + # endif / / __OPENCV_HAL_ARITHM_CORE_HPP__ <nl> new file mode 100644 <nl> index 00000000000 . . 4e4029875c2 <nl> mmm / dev / null <nl> ppp b / modules / hal / src / arithm_simd . hpp <nl> <nl> + / * M / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / IMPORTANT : READ BEFORE DOWNLOADING , COPYING , INSTALLING OR USING . <nl> + / / <nl> + / / By downloading , copying , installing or using the software you agree to this license . <nl> + / / If you do not agree to this license , do not download , install , <nl> + / / copy or use the software . <nl> + / / <nl> + / / <nl> + / / License Agreement <nl> + / / For Open Source Computer Vision Library <nl> + / / <nl> + / / Copyright ( C ) 2000 - 2008 , Intel Corporation , all rights reserved . <nl> + / / Copyright ( C ) 2009 , Willow Garage Inc . , all rights reserved . <nl> + / / Copyright ( C ) 2013 , OpenCV Foundation , all rights reserved . <nl> + / / Copyright ( C ) 2015 , Itseez Inc . , all rights reserved . <nl> + / / Third party copyrights are property of their respective owners . <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without modification , <nl> + / / are permitted provided that the following conditions are met : <nl> + / / <nl> + / / * Redistribution ' s of source code must retain the above copyright notice , <nl> + / / this list of conditions and the following disclaimer . <nl> + / / <nl> + / / * Redistribution ' s in binary form must reproduce the above copyright notice , <nl> + / / this list of conditions and the following disclaimer in the documentation <nl> + / / and / or other materials provided with the distribution . <nl> + / / <nl> + / / * The name of the copyright holders may not be used to endorse or promote products <nl> + / / derived from this software without specific prior written permission . <nl> + / / <nl> + / / This software is provided by the copyright holders and contributors " as is " and <nl> + / / any express or implied warranties , including , but not limited to , the implied <nl> + / / warranties of merchantability and fitness for a particular purpose are disclaimed . <nl> + / / In no event shall the Intel Corporation or contributors be liable for any direct , <nl> + / / indirect , incidental , special , exemplary , or consequential damages <nl> + / / ( including , but not limited to , procurement of substitute goods or services ; <nl> + / / loss of use , data , or profits ; or business interruption ) however caused <nl> + / / and on any theory of liability , whether in contract , strict liability , <nl> + / / or tort ( including negligence or otherwise ) arising in any way out of <nl> + / / the use of this software , even if advised of the possibility of such damage . <nl> + / / <nl> + / / M * / <nl> + <nl> + # ifndef __OPENCV_HAL_ARITHM_SIMD_HPP__ <nl> + # define __OPENCV_HAL_ARITHM_SIMD_HPP__ <nl> + <nl> + namespace cv { namespace hal { <nl> + <nl> + struct NOP { } ; <nl> + <nl> + # if CV_SSE2 | | CV_NEON <nl> + # define IF_SIMD ( op ) op <nl> + # else <nl> + # define IF_SIMD ( op ) NOP <nl> + # endif <nl> + <nl> + <nl> + # if CV_SSE2 | | CV_NEON <nl> + <nl> + # define FUNCTOR_TEMPLATE ( name ) \ <nl> + template < typename T > struct name { } <nl> + <nl> + FUNCTOR_TEMPLATE ( VLoadStore128 ) ; <nl> + # if CV_SSE2 <nl> + FUNCTOR_TEMPLATE ( VLoadStore64 ) ; <nl> + FUNCTOR_TEMPLATE ( VLoadStore128Aligned ) ; <nl> + # if CV_AVX2 <nl> + FUNCTOR_TEMPLATE ( VLoadStore256 ) ; <nl> + FUNCTOR_TEMPLATE ( VLoadStore256Aligned ) ; <nl> + # endif <nl> + # endif <nl> + <nl> + # endif <nl> + <nl> + # if CV_AVX2 <nl> + <nl> + # define FUNCTOR_LOADSTORE_CAST ( name , template_arg , register_type , load_body , store_body ) \ <nl> + template < > \ <nl> + struct name < template_arg > { \ <nl> + typedef register_type reg_type ; \ <nl> + static reg_type load ( const template_arg * p ) { return load_body ( ( const reg_type * ) p ) ; } \ <nl> + static void store ( template_arg * p , reg_type v ) { store_body ( ( reg_type * ) p , v ) ; } \ <nl> + } <nl> + <nl> + # define FUNCTOR_LOADSTORE ( name , template_arg , register_type , load_body , store_body ) \ <nl> + template < > \ <nl> + struct name < template_arg > { \ <nl> + typedef register_type reg_type ; \ <nl> + static reg_type load ( const template_arg * p ) { return load_body ( p ) ; } \ <nl> + static void store ( template_arg * p , reg_type v ) { store_body ( p , v ) ; } \ <nl> + } <nl> + <nl> + # define FUNCTOR_CLOSURE_2arg ( name , template_arg , body ) \ <nl> + template < > \ <nl> + struct name < template_arg > \ <nl> + { \ <nl> + VLoadStore256 < template_arg > : : reg_type operator ( ) ( \ <nl> + const VLoadStore256 < template_arg > : : reg_type & a , \ <nl> + const VLoadStore256 < template_arg > : : reg_type & b ) const \ <nl> + { \ <nl> + body ; \ <nl> + } \ <nl> + } <nl> + <nl> + # define FUNCTOR_CLOSURE_1arg ( name , template_arg , body ) \ <nl> + template < > \ <nl> + struct name < template_arg > \ <nl> + { \ <nl> + VLoadStore256 < template_arg > : : reg_type operator ( ) ( \ <nl> + const VLoadStore256 < template_arg > : : reg_type & a , \ <nl> + const VLoadStore256 < template_arg > : : reg_type & ) const \ <nl> + { \ <nl> + body ; \ <nl> + } \ <nl> + } <nl> + <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore256 , uchar , __m256i , _mm256_loadu_si256 , _mm256_storeu_si256 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore256 , schar , __m256i , _mm256_loadu_si256 , _mm256_storeu_si256 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore256 , ushort , __m256i , _mm256_loadu_si256 , _mm256_storeu_si256 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore256 , short , __m256i , _mm256_loadu_si256 , _mm256_storeu_si256 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore256 , int , __m256i , _mm256_loadu_si256 , _mm256_storeu_si256 ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore256 , float , __m256 , _mm256_loadu_ps , _mm256_storeu_ps ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore256 , double , __m256d , _mm256_loadu_pd , _mm256_storeu_pd ) ; <nl> + <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore256Aligned , int , __m256i , _mm256_load_si256 , _mm256_store_si256 ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore256Aligned , float , __m256 , _mm256_load_ps , _mm256_store_ps ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore256Aligned , double , __m256d , _mm256_load_pd , _mm256_store_pd ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VAdd ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , uchar , return _mm256_adds_epu8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , schar , return _mm256_adds_epi8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , ushort , return _mm256_adds_epu16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , short , return _mm256_adds_epi16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , int , return _mm256_add_epi32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , float , return _mm256_add_ps ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , double , return _mm256_add_pd ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VSub ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , uchar , return _mm256_subs_epu8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , schar , return _mm256_subs_epi8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , ushort , return _mm256_subs_epu16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , short , return _mm256_subs_epi16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , int , return _mm256_sub_epi32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , float , return _mm256_sub_ps ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , double , return _mm256_sub_pd ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VMin ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , uchar , return _mm256_min_epu8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , schar , return _mm256_min_epi8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , ushort , return _mm256_min_epi16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , short , return _mm256_min_epi16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , int , return _mm256_min_epi32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , float , return _mm256_min_ps ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , double , return _mm256_min_pd ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VMax ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , uchar , return _mm256_max_epu8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , schar , return _mm256_max_epi8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , ushort , return _mm256_max_epu16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , short , return _mm256_max_epi16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , int , return _mm256_max_epi32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , float , return _mm256_max_ps ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , double , return _mm256_max_pd ( a , b ) ) ; <nl> + <nl> + <nl> + static unsigned int CV_DECL_ALIGNED ( 32 ) v32f_absmask [ ] = { 0x7fffffff , 0x7fffffff , 0x7fffffff , 0x7fffffff , <nl> + 0x7fffffff , 0x7fffffff , 0x7fffffff , 0x7fffffff } ; <nl> + static unsigned int CV_DECL_ALIGNED ( 32 ) v64f_absmask [ ] = { 0xffffffff , 0x7fffffff , 0xffffffff , 0x7fffffff , <nl> + 0xffffffff , 0x7fffffff , 0xffffffff , 0x7fffffff } ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VAbsDiff ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , uchar , <nl> + return _mm256_add_epi8 ( _mm256_subs_epu8 ( a , b ) , _mm256_subs_epu8 ( b , a ) ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , schar , <nl> + __m256i d = _mm256_subs_epi8 ( a , b ) ; <nl> + __m256i m = _mm256_cmpgt_epi8 ( b , a ) ; <nl> + return _mm256_subs_epi8 ( _mm256_xor_si256 ( d , m ) , m ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , ushort , <nl> + return _mm256_add_epi16 ( _mm256_subs_epu16 ( a , b ) , _mm256_subs_epu16 ( b , a ) ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , short , <nl> + __m256i M = _mm256_max_epi16 ( a , b ) ; <nl> + __m256i m = _mm256_min_epi16 ( a , b ) ; <nl> + return _mm256_subs_epi16 ( M , m ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , int , <nl> + __m256i d = _mm256_sub_epi32 ( a , b ) ; <nl> + __m256i m = _mm256_cmpgt_epi32 ( b , a ) ; <nl> + return _mm256_sub_epi32 ( _mm256_xor_si256 ( d , m ) , m ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , float , <nl> + return _mm256_and_ps ( _mm256_sub_ps ( a , b ) , * ( const __m256 * ) v32f_absmask ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , double , <nl> + return _mm256_and_pd ( _mm256_sub_pd ( a , b ) , * ( const __m256d * ) v64f_absmask ) ; <nl> + ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VAnd ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAnd , uchar , return _mm256_and_si256 ( a , b ) ) ; <nl> + FUNCTOR_TEMPLATE ( VOr ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VOr , uchar , return _mm256_or_si256 ( a , b ) ) ; <nl> + FUNCTOR_TEMPLATE ( VXor ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VXor , uchar , return _mm256_xor_si256 ( a , b ) ) ; <nl> + FUNCTOR_TEMPLATE ( VNot ) ; <nl> + FUNCTOR_CLOSURE_1arg ( VNot , uchar , return _mm256_xor_si256 ( _mm256_set1_epi32 ( - 1 ) , a ) ) ; <nl> + <nl> + # elif CV_SSE2 <nl> + <nl> + # define FUNCTOR_LOADSTORE_CAST ( name , template_arg , register_type , load_body , store_body ) \ <nl> + template < > \ <nl> + struct name < template_arg > { \ <nl> + typedef register_type reg_type ; \ <nl> + static reg_type load ( const template_arg * p ) { return load_body ( ( const reg_type * ) p ) ; } \ <nl> + static void store ( template_arg * p , reg_type v ) { store_body ( ( reg_type * ) p , v ) ; } \ <nl> + } <nl> + <nl> + # define FUNCTOR_LOADSTORE ( name , template_arg , register_type , load_body , store_body ) \ <nl> + template < > \ <nl> + struct name < template_arg > { \ <nl> + typedef register_type reg_type ; \ <nl> + static reg_type load ( const template_arg * p ) { return load_body ( p ) ; } \ <nl> + static void store ( template_arg * p , reg_type v ) { store_body ( p , v ) ; } \ <nl> + } <nl> + <nl> + # define FUNCTOR_CLOSURE_2arg ( name , template_arg , body ) \ <nl> + template < > \ <nl> + struct name < template_arg > \ <nl> + { \ <nl> + VLoadStore128 < template_arg > : : reg_type operator ( ) ( \ <nl> + const VLoadStore128 < template_arg > : : reg_type & a , \ <nl> + const VLoadStore128 < template_arg > : : reg_type & b ) const \ <nl> + { \ <nl> + body ; \ <nl> + } \ <nl> + } <nl> + <nl> + # define FUNCTOR_CLOSURE_1arg ( name , template_arg , body ) \ <nl> + template < > \ <nl> + struct name < template_arg > \ <nl> + { \ <nl> + VLoadStore128 < template_arg > : : reg_type operator ( ) ( \ <nl> + const VLoadStore128 < template_arg > : : reg_type & a , \ <nl> + const VLoadStore128 < template_arg > : : reg_type & ) const \ <nl> + { \ <nl> + body ; \ <nl> + } \ <nl> + } <nl> + <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore128 , uchar , __m128i , _mm_loadu_si128 , _mm_storeu_si128 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore128 , schar , __m128i , _mm_loadu_si128 , _mm_storeu_si128 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore128 , ushort , __m128i , _mm_loadu_si128 , _mm_storeu_si128 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore128 , short , __m128i , _mm_loadu_si128 , _mm_storeu_si128 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore128 , int , __m128i , _mm_loadu_si128 , _mm_storeu_si128 ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore128 , float , __m128 , _mm_loadu_ps , _mm_storeu_ps ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore128 , double , __m128d , _mm_loadu_pd , _mm_storeu_pd ) ; <nl> + <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore64 , uchar , __m128i , _mm_loadl_epi64 , _mm_storel_epi64 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore64 , schar , __m128i , _mm_loadl_epi64 , _mm_storel_epi64 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore64 , ushort , __m128i , _mm_loadl_epi64 , _mm_storel_epi64 ) ; <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore64 , short , __m128i , _mm_loadl_epi64 , _mm_storel_epi64 ) ; <nl> + <nl> + FUNCTOR_LOADSTORE_CAST ( VLoadStore128Aligned , int , __m128i , _mm_load_si128 , _mm_store_si128 ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore128Aligned , float , __m128 , _mm_load_ps , _mm_store_ps ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore128Aligned , double , __m128d , _mm_load_pd , _mm_store_pd ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VAdd ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , uchar , return _mm_adds_epu8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , schar , return _mm_adds_epi8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , ushort , return _mm_adds_epu16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , short , return _mm_adds_epi16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , int , return _mm_add_epi32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , float , return _mm_add_ps ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , double , return _mm_add_pd ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VSub ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , uchar , return _mm_subs_epu8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , schar , return _mm_subs_epi8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , ushort , return _mm_subs_epu16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , short , return _mm_subs_epi16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , int , return _mm_sub_epi32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , float , return _mm_sub_ps ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , double , return _mm_sub_pd ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VMin ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , uchar , return _mm_min_epu8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , schar , <nl> + __m128i m = _mm_cmpgt_epi8 ( a , b ) ; <nl> + return _mm_xor_si128 ( a , _mm_and_si128 ( _mm_xor_si128 ( a , b ) , m ) ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , ushort , return _mm_subs_epu16 ( a , _mm_subs_epu16 ( a , b ) ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , short , return _mm_min_epi16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , int , <nl> + __m128i m = _mm_cmpgt_epi32 ( a , b ) ; <nl> + return _mm_xor_si128 ( a , _mm_and_si128 ( _mm_xor_si128 ( a , b ) , m ) ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , float , return _mm_min_ps ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , double , return _mm_min_pd ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VMax ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , uchar , return _mm_max_epu8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , schar , <nl> + __m128i m = _mm_cmpgt_epi8 ( b , a ) ; <nl> + return _mm_xor_si128 ( a , _mm_and_si128 ( _mm_xor_si128 ( a , b ) , m ) ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , ushort , return _mm_adds_epu16 ( _mm_subs_epu16 ( a , b ) , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , short , return _mm_max_epi16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , int , <nl> + __m128i m = _mm_cmpgt_epi32 ( b , a ) ; <nl> + return _mm_xor_si128 ( a , _mm_and_si128 ( _mm_xor_si128 ( a , b ) , m ) ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , float , return _mm_max_ps ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , double , return _mm_max_pd ( a , b ) ) ; <nl> + <nl> + <nl> + static unsigned int CV_DECL_ALIGNED ( 16 ) v32f_absmask [ ] = { 0x7fffffff , 0x7fffffff , 0x7fffffff , 0x7fffffff } ; <nl> + static unsigned int CV_DECL_ALIGNED ( 16 ) v64f_absmask [ ] = { 0xffffffff , 0x7fffffff , 0xffffffff , 0x7fffffff } ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VAbsDiff ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , uchar , <nl> + return _mm_add_epi8 ( _mm_subs_epu8 ( a , b ) , _mm_subs_epu8 ( b , a ) ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , schar , <nl> + __m128i d = _mm_subs_epi8 ( a , b ) ; <nl> + __m128i m = _mm_cmpgt_epi8 ( b , a ) ; <nl> + return _mm_subs_epi8 ( _mm_xor_si128 ( d , m ) , m ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , ushort , <nl> + return _mm_add_epi16 ( _mm_subs_epu16 ( a , b ) , _mm_subs_epu16 ( b , a ) ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , short , <nl> + __m128i M = _mm_max_epi16 ( a , b ) ; <nl> + __m128i m = _mm_min_epi16 ( a , b ) ; <nl> + return _mm_subs_epi16 ( M , m ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , int , <nl> + __m128i d = _mm_sub_epi32 ( a , b ) ; <nl> + __m128i m = _mm_cmpgt_epi32 ( b , a ) ; <nl> + return _mm_sub_epi32 ( _mm_xor_si128 ( d , m ) , m ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , float , <nl> + return _mm_and_ps ( _mm_sub_ps ( a , b ) , * ( const __m128 * ) v32f_absmask ) ; <nl> + ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , double , <nl> + return _mm_and_pd ( _mm_sub_pd ( a , b ) , * ( const __m128d * ) v64f_absmask ) ; <nl> + ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VAnd ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAnd , uchar , return _mm_and_si128 ( a , b ) ) ; <nl> + FUNCTOR_TEMPLATE ( VOr ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VOr , uchar , return _mm_or_si128 ( a , b ) ) ; <nl> + FUNCTOR_TEMPLATE ( VXor ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VXor , uchar , return _mm_xor_si128 ( a , b ) ) ; <nl> + FUNCTOR_TEMPLATE ( VNot ) ; <nl> + FUNCTOR_CLOSURE_1arg ( VNot , uchar , return _mm_xor_si128 ( _mm_set1_epi32 ( - 1 ) , a ) ) ; <nl> + # endif <nl> + <nl> + # if CV_NEON <nl> + <nl> + # define FUNCTOR_LOADSTORE ( name , template_arg , register_type , load_body , store_body ) \ <nl> + template < > \ <nl> + struct name < template_arg > { \ <nl> + typedef register_type reg_type ; \ <nl> + static reg_type load ( const template_arg * p ) { return load_body ( p ) ; } ; \ <nl> + static void store ( template_arg * p , reg_type v ) { store_body ( p , v ) ; } ; \ <nl> + } <nl> + <nl> + # define FUNCTOR_CLOSURE_2arg ( name , template_arg , body ) \ <nl> + template < > \ <nl> + struct name < template_arg > \ <nl> + { \ <nl> + VLoadStore128 < template_arg > : : reg_type operator ( ) ( \ <nl> + VLoadStore128 < template_arg > : : reg_type a , \ <nl> + VLoadStore128 < template_arg > : : reg_type b ) const \ <nl> + { \ <nl> + return body ; \ <nl> + } ; \ <nl> + } <nl> + <nl> + # define FUNCTOR_CLOSURE_1arg ( name , template_arg , body ) \ <nl> + template < > \ <nl> + struct name < template_arg > \ <nl> + { \ <nl> + VLoadStore128 < template_arg > : : reg_type operator ( ) ( \ <nl> + VLoadStore128 < template_arg > : : reg_type a , \ <nl> + VLoadStore128 < template_arg > : : reg_type ) const \ <nl> + { \ <nl> + return body ; \ <nl> + } ; \ <nl> + } <nl> + <nl> + FUNCTOR_LOADSTORE ( VLoadStore128 , uchar , uint8x16_t , vld1q_u8 , vst1q_u8 ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore128 , schar , int8x16_t , vld1q_s8 , vst1q_s8 ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore128 , ushort , uint16x8_t , vld1q_u16 , vst1q_u16 ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore128 , short , int16x8_t , vld1q_s16 , vst1q_s16 ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore128 , int , int32x4_t , vld1q_s32 , vst1q_s32 ) ; <nl> + FUNCTOR_LOADSTORE ( VLoadStore128 , float , float32x4_t , vld1q_f32 , vst1q_f32 ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VAdd ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , uchar , vqaddq_u8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , schar , vqaddq_s8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , ushort , vqaddq_u16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , short , vqaddq_s16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , int , vaddq_s32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAdd , float , vaddq_f32 ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VSub ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , uchar , vqsubq_u8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , schar , vqsubq_s8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , ushort , vqsubq_u16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , short , vqsubq_s16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , int , vsubq_s32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VSub , float , vsubq_f32 ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VMin ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , uchar , vminq_u8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , schar , vminq_s8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , ushort , vminq_u16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , short , vminq_s16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , int , vminq_s32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMin , float , vminq_f32 ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VMax ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , uchar , vmaxq_u8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , schar , vmaxq_s8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , ushort , vmaxq_u16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , short , vmaxq_s16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , int , vmaxq_s32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VMax , float , vmaxq_f32 ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VAbsDiff ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , uchar , vabdq_u8 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , schar , vqabsq_s8 ( vqsubq_s8 ( a , b ) ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , ushort , vabdq_u16 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , short , vqabsq_s16 ( vqsubq_s16 ( a , b ) ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , int , vabdq_s32 ( a , b ) ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAbsDiff , float , vabdq_f32 ( a , b ) ) ; <nl> + <nl> + FUNCTOR_TEMPLATE ( VAnd ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VAnd , uchar , vandq_u8 ( a , b ) ) ; <nl> + FUNCTOR_TEMPLATE ( VOr ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VOr , uchar , vorrq_u8 ( a , b ) ) ; <nl> + FUNCTOR_TEMPLATE ( VXor ) ; <nl> + FUNCTOR_CLOSURE_2arg ( VXor , uchar , veorq_u8 ( a , b ) ) ; <nl> + FUNCTOR_TEMPLATE ( VNot ) ; <nl> + FUNCTOR_CLOSURE_1arg ( VNot , uchar , vmvnq_u8 ( a ) ) ; <nl> + # endif <nl> + <nl> + <nl> + template < typename T > <nl> + struct Cmp_SIMD <nl> + { <nl> + explicit Cmp_SIMD ( int ) <nl> + { <nl> + } <nl> + <nl> + int operator ( ) ( const T * , const T * , uchar * , int ) const <nl> + { <nl> + return 0 ; <nl> + } <nl> + } ; <nl> + <nl> + # if CV_NEON <nl> + <nl> + template < > <nl> + struct Cmp_SIMD < schar > <nl> + { <nl> + explicit Cmp_SIMD ( int code_ ) : <nl> + code ( code_ ) <nl> + { <nl> + / / CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> + / / code = = CMP_EQ | | code = = CMP_NE ) ; <nl> + <nl> + v_mask = vdupq_n_u8 ( 255 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const schar * src1 , const schar * src2 , uchar * dst , int width ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( code = = CMP_GT ) <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + vst1q_u8 ( dst + x , vcgtq_s8 ( vld1q_s8 ( src1 + x ) , vld1q_s8 ( src2 + x ) ) ) ; <nl> + else if ( code = = CMP_LE ) <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + vst1q_u8 ( dst + x , vcleq_s8 ( vld1q_s8 ( src1 + x ) , vld1q_s8 ( src2 + x ) ) ) ; <nl> + else if ( code = = CMP_EQ ) <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + vst1q_u8 ( dst + x , vceqq_s8 ( vld1q_s8 ( src1 + x ) , vld1q_s8 ( src2 + x ) ) ) ; <nl> + else if ( code = = CMP_NE ) <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + vst1q_u8 ( dst + x , veorq_u8 ( vceqq_s8 ( vld1q_s8 ( src1 + x ) , vld1q_s8 ( src2 + x ) ) , v_mask ) ) ; <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + int code ; <nl> + uint8x16_t v_mask ; <nl> + } ; <nl> + <nl> + template < > <nl> + struct Cmp_SIMD < ushort > <nl> + { <nl> + explicit Cmp_SIMD ( int code_ ) : <nl> + code ( code_ ) <nl> + { <nl> + / / CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> + / / code = = CMP_EQ | | code = = CMP_NE ) ; <nl> + <nl> + v_mask = vdup_n_u8 ( 255 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const ushort * src1 , const ushort * src2 , uchar * dst , int width ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( code = = CMP_GT ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint16x8_t v_dst = vcgtq_u16 ( vld1q_u16 ( src1 + x ) , vld1q_u16 ( src2 + x ) ) ; <nl> + vst1_u8 ( dst + x , vmovn_u16 ( v_dst ) ) ; <nl> + } <nl> + else if ( code = = CMP_LE ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint16x8_t v_dst = vcleq_u16 ( vld1q_u16 ( src1 + x ) , vld1q_u16 ( src2 + x ) ) ; <nl> + vst1_u8 ( dst + x , vmovn_u16 ( v_dst ) ) ; <nl> + } <nl> + else if ( code = = CMP_EQ ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint16x8_t v_dst = vceqq_u16 ( vld1q_u16 ( src1 + x ) , vld1q_u16 ( src2 + x ) ) ; <nl> + vst1_u8 ( dst + x , vmovn_u16 ( v_dst ) ) ; <nl> + } <nl> + else if ( code = = CMP_NE ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint16x8_t v_dst = vceqq_u16 ( vld1q_u16 ( src1 + x ) , vld1q_u16 ( src2 + x ) ) ; <nl> + vst1_u8 ( dst + x , veor_u8 ( vmovn_u16 ( v_dst ) , v_mask ) ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + int code ; <nl> + uint8x8_t v_mask ; <nl> + } ; <nl> + <nl> + template < > <nl> + struct Cmp_SIMD < int > <nl> + { <nl> + explicit Cmp_SIMD ( int code_ ) : <nl> + code ( code_ ) <nl> + { <nl> + / / CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> + / / code = = CMP_EQ | | code = = CMP_NE ) ; <nl> + <nl> + v_mask = vdup_n_u8 ( 255 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const int * src1 , const int * src2 , uchar * dst , int width ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( code = = CMP_GT ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint32x4_t v_dst1 = vcgtq_s32 ( vld1q_s32 ( src1 + x ) , vld1q_s32 ( src2 + x ) ) ; <nl> + uint32x4_t v_dst2 = vcgtq_s32 ( vld1q_s32 ( src1 + x + 4 ) , vld1q_s32 ( src2 + x + 4 ) ) ; <nl> + vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> + } <nl> + else if ( code = = CMP_LE ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint32x4_t v_dst1 = vcleq_s32 ( vld1q_s32 ( src1 + x ) , vld1q_s32 ( src2 + x ) ) ; <nl> + uint32x4_t v_dst2 = vcleq_s32 ( vld1q_s32 ( src1 + x + 4 ) , vld1q_s32 ( src2 + x + 4 ) ) ; <nl> + vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> + } <nl> + else if ( code = = CMP_EQ ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint32x4_t v_dst1 = vceqq_s32 ( vld1q_s32 ( src1 + x ) , vld1q_s32 ( src2 + x ) ) ; <nl> + uint32x4_t v_dst2 = vceqq_s32 ( vld1q_s32 ( src1 + x + 4 ) , vld1q_s32 ( src2 + x + 4 ) ) ; <nl> + vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> + } <nl> + else if ( code = = CMP_NE ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint32x4_t v_dst1 = vceqq_s32 ( vld1q_s32 ( src1 + x ) , vld1q_s32 ( src2 + x ) ) ; <nl> + uint32x4_t v_dst2 = vceqq_s32 ( vld1q_s32 ( src1 + x + 4 ) , vld1q_s32 ( src2 + x + 4 ) ) ; <nl> + uint8x8_t v_dst = vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ; <nl> + vst1_u8 ( dst + x , veor_u8 ( v_dst , v_mask ) ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + int code ; <nl> + uint8x8_t v_mask ; <nl> + } ; <nl> + <nl> + template < > <nl> + struct Cmp_SIMD < float > <nl> + { <nl> + explicit Cmp_SIMD ( int code_ ) : <nl> + code ( code_ ) <nl> + { <nl> + / / CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> + / / code = = CMP_EQ | | code = = CMP_NE ) ; <nl> + <nl> + v_mask = vdup_n_u8 ( 255 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const float * src1 , const float * src2 , uchar * dst , int width ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( code = = CMP_GT ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint32x4_t v_dst1 = vcgtq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> + uint32x4_t v_dst2 = vcgtq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> + vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> + } <nl> + else if ( code = = CMP_LE ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint32x4_t v_dst1 = vcleq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> + uint32x4_t v_dst2 = vcleq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> + vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> + } <nl> + else if ( code = = CMP_EQ ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint32x4_t v_dst1 = vceqq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> + uint32x4_t v_dst2 = vceqq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> + vst1_u8 ( dst + x , vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ) ; <nl> + } <nl> + else if ( code = = CMP_NE ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint32x4_t v_dst1 = vceqq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> + uint32x4_t v_dst2 = vceqq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> + uint8x8_t v_dst = vmovn_u16 ( vcombine_u16 ( vmovn_u32 ( v_dst1 ) , vmovn_u32 ( v_dst2 ) ) ) ; <nl> + vst1_u8 ( dst + x , veor_u8 ( v_dst , v_mask ) ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + int code ; <nl> + uint8x8_t v_mask ; <nl> + } ; <nl> + <nl> + # elif CV_SSE2 <nl> + <nl> + template < > <nl> + struct Cmp_SIMD < schar > <nl> + { <nl> + explicit Cmp_SIMD ( int code_ ) : <nl> + code ( code_ ) <nl> + { <nl> + / / CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> + / / code = = CMP_EQ | | code = = CMP_NE ) ; <nl> + <nl> + haveSSE = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> + <nl> + v_mask = _mm_set1_epi8 ( - 1 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const schar * src1 , const schar * src2 , uchar * dst , int width ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSSE ) <nl> + return x ; <nl> + <nl> + if ( code = = CMP_GT ) <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_cmpgt_epi8 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ) ; <nl> + else if ( code = = CMP_LE ) <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + { <nl> + __m128i v_gt = _mm_cmpgt_epi8 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_xor_si128 ( v_mask , v_gt ) ) ; <nl> + } <nl> + else if ( code = = CMP_EQ ) <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_cmpeq_epi8 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ) ; <nl> + else if ( code = = CMP_NE ) <nl> + for ( ; x < = width - 16 ; x + = 16 ) <nl> + { <nl> + __m128i v_eq = _mm_cmpeq_epi8 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_xor_si128 ( v_mask , v_eq ) ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + int code ; <nl> + __m128i v_mask ; <nl> + bool haveSSE ; <nl> + } ; <nl> + <nl> + template < > <nl> + struct Cmp_SIMD < int > <nl> + { <nl> + explicit Cmp_SIMD ( int code_ ) : <nl> + code ( code_ ) <nl> + { <nl> + / / CV_Assert ( code = = CMP_GT | | code = = CMP_LE | | <nl> + / / code = = CMP_EQ | | code = = CMP_NE ) ; <nl> + <nl> + haveSSE = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> + <nl> + v_mask = _mm_set1_epi32 ( 0xffffffff ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const int * src1 , const int * src2 , uchar * dst , int width ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSSE ) <nl> + return x ; <nl> + <nl> + if ( code = = CMP_GT ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_dst0 = _mm_cmpgt_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> + __m128i v_dst1 = _mm_cmpgt_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 4 ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 4 ) ) ) ; <nl> + <nl> + _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi16 ( _mm_packs_epi32 ( v_dst0 , v_dst1 ) , v_mask ) ) ; <nl> + } <nl> + else if ( code = = CMP_LE ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_dst0 = _mm_cmpgt_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> + __m128i v_dst1 = _mm_cmpgt_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 4 ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 4 ) ) ) ; <nl> + <nl> + _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_xor_si128 ( _mm_packs_epi16 ( _mm_packs_epi32 ( v_dst0 , v_dst1 ) , v_mask ) , v_mask ) ) ; <nl> + } <nl> + else if ( code = = CMP_EQ ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_dst0 = _mm_cmpeq_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> + __m128i v_dst1 = _mm_cmpeq_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 4 ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 4 ) ) ) ; <nl> + <nl> + _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi16 ( _mm_packs_epi32 ( v_dst0 , v_dst1 ) , v_mask ) ) ; <nl> + } <nl> + else if ( code = = CMP_NE ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_dst0 = _mm_cmpeq_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ) ; <nl> + __m128i v_dst1 = _mm_cmpeq_epi32 ( _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x + 4 ) ) , <nl> + _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x + 4 ) ) ) ; <nl> + <nl> + _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_xor_si128 ( v_mask , _mm_packs_epi16 ( _mm_packs_epi32 ( v_dst0 , v_dst1 ) , v_mask ) ) ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + int code ; <nl> + __m128i v_mask ; <nl> + bool haveSSE ; <nl> + } ; <nl> + <nl> + # endif <nl> + <nl> + <nl> + template < typename T , typename WT > <nl> + struct Mul_SIMD <nl> + { <nl> + int operator ( ) ( const T * , const T * , T * , int , WT ) const <nl> + { <nl> + return 0 ; <nl> + } <nl> + } ; <nl> + <nl> + # if CV_NEON <nl> + <nl> + template < > <nl> + struct Mul_SIMD < uchar , float > <nl> + { <nl> + int operator ( ) ( const uchar * src1 , const uchar * src2 , uchar * dst , int width , float scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( scale = = 1 . 0f ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint16x8_t v_src1 = vmovl_u8 ( vld1_u8 ( src1 + x ) ) ; <nl> + uint16x8_t v_src2 = vmovl_u8 ( vld1_u8 ( src2 + x ) ) ; <nl> + <nl> + float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src2 ) ) ) ) ; <nl> + float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src2 ) ) ) ) ; <nl> + <nl> + uint16x8_t v_dst = vcombine_u16 ( vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst1 ) ) , <nl> + vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst2 ) ) ) ; <nl> + vst1_u8 ( dst + x , vqmovn_u16 ( v_dst ) ) ; <nl> + } <nl> + else <nl> + { <nl> + float32x4_t v_scale = vdupq_n_f32 ( scale ) ; <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint16x8_t v_src1 = vmovl_u8 ( vld1_u8 ( src1 + x ) ) ; <nl> + uint16x8_t v_src2 = vmovl_u8 ( vld1_u8 ( src2 + x ) ) ; <nl> + <nl> + float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src2 ) ) ) ) ; <nl> + v_dst1 = vmulq_f32 ( v_dst1 , v_scale ) ; <nl> + float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src2 ) ) ) ) ; <nl> + v_dst2 = vmulq_f32 ( v_dst2 , v_scale ) ; <nl> + <nl> + uint16x8_t v_dst = vcombine_u16 ( vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst1 ) ) , <nl> + vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst2 ) ) ) ; <nl> + vst1_u8 ( dst + x , vqmovn_u16 ( v_dst ) ) ; <nl> + } <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct Mul_SIMD < schar , float > <nl> + { <nl> + int operator ( ) ( const schar * src1 , const schar * src2 , schar * dst , int width , float scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( scale = = 1 . 0f ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + int16x8_t v_src1 = vmovl_s8 ( vld1_s8 ( src1 + x ) ) ; <nl> + int16x8_t v_src2 = vmovl_s8 ( vld1_s8 ( src2 + x ) ) ; <nl> + <nl> + float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src2 ) ) ) ) ; <nl> + float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src2 ) ) ) ) ; <nl> + <nl> + int16x8_t v_dst = vcombine_s16 ( vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst1 ) ) , <nl> + vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst2 ) ) ) ; <nl> + vst1_s8 ( dst + x , vqmovn_s16 ( v_dst ) ) ; <nl> + } <nl> + else <nl> + { <nl> + float32x4_t v_scale = vdupq_n_f32 ( scale ) ; <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + int16x8_t v_src1 = vmovl_s8 ( vld1_s8 ( src1 + x ) ) ; <nl> + int16x8_t v_src2 = vmovl_s8 ( vld1_s8 ( src2 + x ) ) ; <nl> + <nl> + float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src2 ) ) ) ) ; <nl> + v_dst1 = vmulq_f32 ( v_dst1 , v_scale ) ; <nl> + float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src2 ) ) ) ) ; <nl> + v_dst2 = vmulq_f32 ( v_dst2 , v_scale ) ; <nl> + <nl> + int16x8_t v_dst = vcombine_s16 ( vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst1 ) ) , <nl> + vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst2 ) ) ) ; <nl> + vst1_s8 ( dst + x , vqmovn_s16 ( v_dst ) ) ; <nl> + } <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct Mul_SIMD < ushort , float > <nl> + { <nl> + int operator ( ) ( const ushort * src1 , const ushort * src2 , ushort * dst , int width , float scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( scale = = 1 . 0f ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint16x8_t v_src1 = vld1q_u16 ( src1 + x ) , v_src2 = vld1q_u16 ( src2 + x ) ; <nl> + <nl> + float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src2 ) ) ) ) ; <nl> + float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src2 ) ) ) ) ; <nl> + <nl> + uint16x8_t v_dst = vcombine_u16 ( vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst1 ) ) , <nl> + vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst2 ) ) ) ; <nl> + vst1q_u16 ( dst + x , v_dst ) ; <nl> + } <nl> + else <nl> + { <nl> + float32x4_t v_scale = vdupq_n_f32 ( scale ) ; <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint16x8_t v_src1 = vld1q_u16 ( src1 + x ) , v_src2 = vld1q_u16 ( src2 + x ) ; <nl> + <nl> + float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src2 ) ) ) ) ; <nl> + v_dst1 = vmulq_f32 ( v_dst1 , v_scale ) ; <nl> + float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src2 ) ) ) ) ; <nl> + v_dst2 = vmulq_f32 ( v_dst2 , v_scale ) ; <nl> + <nl> + uint16x8_t v_dst = vcombine_u16 ( vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst1 ) ) , <nl> + vqmovn_u32 ( cv_vrndq_u32_f32 ( v_dst2 ) ) ) ; <nl> + vst1q_u16 ( dst + x , v_dst ) ; <nl> + } <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct Mul_SIMD < short , float > <nl> + { <nl> + int operator ( ) ( const short * src1 , const short * src2 , short * dst , int width , float scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( scale = = 1 . 0f ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + int16x8_t v_src1 = vld1q_s16 ( src1 + x ) , v_src2 = vld1q_s16 ( src2 + x ) ; <nl> + <nl> + float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src2 ) ) ) ) ; <nl> + float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src2 ) ) ) ) ; <nl> + <nl> + int16x8_t v_dst = vcombine_s16 ( vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst1 ) ) , <nl> + vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst2 ) ) ) ; <nl> + vst1q_s16 ( dst + x , v_dst ) ; <nl> + } <nl> + else <nl> + { <nl> + float32x4_t v_scale = vdupq_n_f32 ( scale ) ; <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + int16x8_t v_src1 = vld1q_s16 ( src1 + x ) , v_src2 = vld1q_s16 ( src2 + x ) ; <nl> + <nl> + float32x4_t v_dst1 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src2 ) ) ) ) ; <nl> + v_dst1 = vmulq_f32 ( v_dst1 , v_scale ) ; <nl> + float32x4_t v_dst2 = vmulq_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src1 ) ) ) , <nl> + vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src2 ) ) ) ) ; <nl> + v_dst2 = vmulq_f32 ( v_dst2 , v_scale ) ; <nl> + <nl> + int16x8_t v_dst = vcombine_s16 ( vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst1 ) ) , <nl> + vqmovn_s32 ( cv_vrndq_s32_f32 ( v_dst2 ) ) ) ; <nl> + vst1q_s16 ( dst + x , v_dst ) ; <nl> + } <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct Mul_SIMD < float , float > <nl> + { <nl> + int operator ( ) ( const float * src1 , const float * src2 , float * dst , int width , float scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( scale = = 1 . 0f ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + float32x4_t v_dst1 = vmulq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> + float32x4_t v_dst2 = vmulq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> + vst1q_f32 ( dst + x , v_dst1 ) ; <nl> + vst1q_f32 ( dst + x + 4 , v_dst2 ) ; <nl> + } <nl> + else <nl> + { <nl> + float32x4_t v_scale = vdupq_n_f32 ( scale ) ; <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + float32x4_t v_dst1 = vmulq_f32 ( vld1q_f32 ( src1 + x ) , vld1q_f32 ( src2 + x ) ) ; <nl> + v_dst1 = vmulq_f32 ( v_dst1 , v_scale ) ; <nl> + <nl> + float32x4_t v_dst2 = vmulq_f32 ( vld1q_f32 ( src1 + x + 4 ) , vld1q_f32 ( src2 + x + 4 ) ) ; <nl> + v_dst2 = vmulq_f32 ( v_dst2 , v_scale ) ; <nl> + <nl> + vst1q_f32 ( dst + x , v_dst1 ) ; <nl> + vst1q_f32 ( dst + x + 4 , v_dst2 ) ; <nl> + } <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + # elif CV_SSE2 <nl> + <nl> + # if CV_SSE4_1 <nl> + <nl> + template < > <nl> + struct Mul_SIMD < ushort , float > <nl> + { <nl> + Mul_SIMD ( ) <nl> + { <nl> + haveSSE = checkHardwareSupport ( CV_CPU_SSE4_1 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const ushort * src1 , const ushort * src2 , ushort * dst , int width , float scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSSE ) <nl> + return x ; <nl> + <nl> + __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> + <nl> + if ( scale ! = 1 . 0f ) <nl> + { <nl> + __m128 v_scale = _mm_set1_ps ( scale ) ; <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_src1 = _mm_loadu_si128 ( ( __m128i const * ) ( src1 + x ) ) ; <nl> + __m128i v_src2 = _mm_loadu_si128 ( ( __m128i const * ) ( src2 + x ) ) ; <nl> + <nl> + __m128 v_dst1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( v_src1 , v_zero ) ) , <nl> + _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( v_src2 , v_zero ) ) ) ; <nl> + v_dst1 = _mm_mul_ps ( v_dst1 , v_scale ) ; <nl> + <nl> + __m128 v_dst2 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( v_src1 , v_zero ) ) , <nl> + _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( v_src2 , v_zero ) ) ) ; <nl> + v_dst2 = _mm_mul_ps ( v_dst2 , v_scale ) ; <nl> + <nl> + __m128i v_dsti = _mm_packus_epi32 ( _mm_cvtps_epi32 ( v_dst1 ) , _mm_cvtps_epi32 ( v_dst2 ) ) ; <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , v_dsti ) ; <nl> + } <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + bool haveSSE ; <nl> + } ; <nl> + <nl> + # endif <nl> + <nl> + template < > <nl> + struct Mul_SIMD < schar , float > <nl> + { <nl> + Mul_SIMD ( ) <nl> + { <nl> + haveSSE = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const schar * src1 , const schar * src2 , schar * dst , int width , float scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSSE ) <nl> + return x ; <nl> + <nl> + __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> + <nl> + if ( scale = = 1 . 0f ) <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_src1 = _mm_loadl_epi64 ( ( __m128i const * ) ( src1 + x ) ) ; <nl> + __m128i v_src2 = _mm_loadl_epi64 ( ( __m128i const * ) ( src2 + x ) ) ; <nl> + <nl> + v_src1 = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src1 ) , 8 ) ; <nl> + v_src2 = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src2 ) , 8 ) ; <nl> + <nl> + __m128 v_dst1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> + _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> + <nl> + __m128 v_dst2 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> + _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> + <nl> + __m128i v_dsti = _mm_packs_epi32 ( _mm_cvtps_epi32 ( v_dst1 ) , _mm_cvtps_epi32 ( v_dst2 ) ) ; <nl> + _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi16 ( v_dsti , v_zero ) ) ; <nl> + } <nl> + else <nl> + { <nl> + __m128 v_scale = _mm_set1_ps ( scale ) ; <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_src1 = _mm_loadl_epi64 ( ( __m128i const * ) ( src1 + x ) ) ; <nl> + __m128i v_src2 = _mm_loadl_epi64 ( ( __m128i const * ) ( src2 + x ) ) ; <nl> + <nl> + v_src1 = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src1 ) , 8 ) ; <nl> + v_src2 = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src2 ) , 8 ) ; <nl> + <nl> + __m128 v_dst1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> + _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> + v_dst1 = _mm_mul_ps ( v_dst1 , v_scale ) ; <nl> + <nl> + __m128 v_dst2 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> + _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> + v_dst2 = _mm_mul_ps ( v_dst2 , v_scale ) ; <nl> + <nl> + __m128i v_dsti = _mm_packs_epi32 ( _mm_cvtps_epi32 ( v_dst1 ) , _mm_cvtps_epi32 ( v_dst2 ) ) ; <nl> + _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi16 ( v_dsti , v_zero ) ) ; <nl> + } <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + bool haveSSE ; <nl> + } ; <nl> + <nl> + template < > <nl> + struct Mul_SIMD < short , float > <nl> + { <nl> + Mul_SIMD ( ) <nl> + { <nl> + haveSSE = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const short * src1 , const short * src2 , short * dst , int width , float scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSSE ) <nl> + return x ; <nl> + <nl> + __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> + <nl> + if ( scale ! = 1 . 0f ) <nl> + { <nl> + __m128 v_scale = _mm_set1_ps ( scale ) ; <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_src1 = _mm_loadu_si128 ( ( __m128i const * ) ( src1 + x ) ) ; <nl> + __m128i v_src2 = _mm_loadu_si128 ( ( __m128i const * ) ( src2 + x ) ) ; <nl> + <nl> + __m128 v_dst1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> + _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> + v_dst1 = _mm_mul_ps ( v_dst1 , v_scale ) ; <nl> + <nl> + __m128 v_dst2 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src1 ) , 16 ) ) , <nl> + _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src2 ) , 16 ) ) ) ; <nl> + v_dst2 = _mm_mul_ps ( v_dst2 , v_scale ) ; <nl> + <nl> + __m128i v_dsti = _mm_packs_epi32 ( _mm_cvtps_epi32 ( v_dst1 ) , _mm_cvtps_epi32 ( v_dst2 ) ) ; <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , v_dsti ) ; <nl> + } <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + bool haveSSE ; <nl> + } ; <nl> + <nl> + # endif <nl> + <nl> + template < typename T > <nl> + struct Div_SIMD <nl> + { <nl> + int operator ( ) ( const T * , const T * , T * , int , double ) const <nl> + { <nl> + return 0 ; <nl> + } <nl> + } ; <nl> + <nl> + template < typename T > <nl> + struct Recip_SIMD <nl> + { <nl> + int operator ( ) ( const T * , T * , int , double ) const <nl> + { <nl> + return 0 ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + # if CV_SIMD128 <nl> + <nl> + template < > <nl> + struct Div_SIMD < uchar > <nl> + { <nl> + bool haveSIMD ; <nl> + Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const uchar * src1 , const uchar * src2 , uchar * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_uint16x8 v_zero = v_setzero_u16 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_uint16x8 v_src1 = v_load_expand ( src1 + x ) ; <nl> + v_uint16x8 v_src2 = v_load_expand ( src2 + x ) ; <nl> + <nl> + v_uint32x4 t0 , t1 , t2 , t3 ; <nl> + v_expand ( v_src1 , t0 , t1 ) ; <nl> + v_expand ( v_src2 , t2 , t3 ) ; <nl> + <nl> + v_float32x4 f0 = v_cvt_f32 ( v_reinterpret_as_s32 ( t0 ) ) ; <nl> + v_float32x4 f1 = v_cvt_f32 ( v_reinterpret_as_s32 ( t1 ) ) ; <nl> + <nl> + v_float32x4 f2 = v_cvt_f32 ( v_reinterpret_as_s32 ( t2 ) ) ; <nl> + v_float32x4 f3 = v_cvt_f32 ( v_reinterpret_as_s32 ( t3 ) ) ; <nl> + <nl> + f0 = f0 * v_scale / f2 ; <nl> + f1 = f1 * v_scale / f3 ; <nl> + <nl> + v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> + v_uint16x8 res = v_pack_u ( i0 , i1 ) ; <nl> + <nl> + res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> + v_pack_store ( dst + x , res ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + template < > <nl> + struct Div_SIMD < schar > <nl> + { <nl> + bool haveSIMD ; <nl> + Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const schar * src1 , const schar * src2 , schar * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_int16x8 v_zero = v_setzero_s16 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_int16x8 v_src1 = v_load_expand ( src1 + x ) ; <nl> + v_int16x8 v_src2 = v_load_expand ( src2 + x ) ; <nl> + <nl> + v_int32x4 t0 , t1 , t2 , t3 ; <nl> + v_expand ( v_src1 , t0 , t1 ) ; <nl> + v_expand ( v_src2 , t2 , t3 ) ; <nl> + <nl> + v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> + v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> + <nl> + v_float32x4 f2 = v_cvt_f32 ( t2 ) ; <nl> + v_float32x4 f3 = v_cvt_f32 ( t3 ) ; <nl> + <nl> + f0 = f0 * v_scale / f2 ; <nl> + f1 = f1 * v_scale / f3 ; <nl> + <nl> + v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> + v_int16x8 res = v_pack ( i0 , i1 ) ; <nl> + <nl> + res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> + v_pack_store ( dst + x , res ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + template < > <nl> + struct Div_SIMD < ushort > <nl> + { <nl> + bool haveSIMD ; <nl> + Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const ushort * src1 , const ushort * src2 , ushort * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_uint16x8 v_zero = v_setzero_u16 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_uint16x8 v_src1 = v_load ( src1 + x ) ; <nl> + v_uint16x8 v_src2 = v_load ( src2 + x ) ; <nl> + <nl> + v_uint32x4 t0 , t1 , t2 , t3 ; <nl> + v_expand ( v_src1 , t0 , t1 ) ; <nl> + v_expand ( v_src2 , t2 , t3 ) ; <nl> + <nl> + v_float32x4 f0 = v_cvt_f32 ( v_reinterpret_as_s32 ( t0 ) ) ; <nl> + v_float32x4 f1 = v_cvt_f32 ( v_reinterpret_as_s32 ( t1 ) ) ; <nl> + <nl> + v_float32x4 f2 = v_cvt_f32 ( v_reinterpret_as_s32 ( t2 ) ) ; <nl> + v_float32x4 f3 = v_cvt_f32 ( v_reinterpret_as_s32 ( t3 ) ) ; <nl> + <nl> + f0 = f0 * v_scale / f2 ; <nl> + f1 = f1 * v_scale / f3 ; <nl> + <nl> + v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> + v_uint16x8 res = v_pack_u ( i0 , i1 ) ; <nl> + <nl> + res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> + v_store ( dst + x , res ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct Div_SIMD < short > <nl> + { <nl> + bool haveSIMD ; <nl> + Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const short * src1 , const short * src2 , short * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_int16x8 v_zero = v_setzero_s16 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_int16x8 v_src1 = v_load ( src1 + x ) ; <nl> + v_int16x8 v_src2 = v_load ( src2 + x ) ; <nl> + <nl> + v_int32x4 t0 , t1 , t2 , t3 ; <nl> + v_expand ( v_src1 , t0 , t1 ) ; <nl> + v_expand ( v_src2 , t2 , t3 ) ; <nl> + <nl> + v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> + v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> + <nl> + v_float32x4 f2 = v_cvt_f32 ( t2 ) ; <nl> + v_float32x4 f3 = v_cvt_f32 ( t3 ) ; <nl> + <nl> + f0 = f0 * v_scale / f2 ; <nl> + f1 = f1 * v_scale / f3 ; <nl> + <nl> + v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> + v_int16x8 res = v_pack ( i0 , i1 ) ; <nl> + <nl> + res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> + v_store ( dst + x , res ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct Div_SIMD < int > <nl> + { <nl> + bool haveSIMD ; <nl> + Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const int * src1 , const int * src2 , int * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_int32x4 v_zero = v_setzero_s32 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_int32x4 t0 = v_load ( src1 + x ) ; <nl> + v_int32x4 t1 = v_load ( src1 + x + 4 ) ; <nl> + v_int32x4 t2 = v_load ( src2 + x ) ; <nl> + v_int32x4 t3 = v_load ( src2 + x + 4 ) ; <nl> + <nl> + v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> + v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> + v_float32x4 f2 = v_cvt_f32 ( t2 ) ; <nl> + v_float32x4 f3 = v_cvt_f32 ( t3 ) ; <nl> + <nl> + f0 = f0 * v_scale / f2 ; <nl> + f1 = f1 * v_scale / f3 ; <nl> + <nl> + v_int32x4 res0 = v_round ( f0 ) , res1 = v_round ( f1 ) ; <nl> + <nl> + res0 = v_select ( t2 = = v_zero , v_zero , res0 ) ; <nl> + res1 = v_select ( t3 = = v_zero , v_zero , res1 ) ; <nl> + v_store ( dst + x , res0 ) ; <nl> + v_store ( dst + x + 4 , res1 ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + template < > <nl> + struct Div_SIMD < float > <nl> + { <nl> + bool haveSIMD ; <nl> + Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const float * src1 , const float * src2 , float * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_float32x4 v_zero = v_setzero_f32 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_float32x4 f0 = v_load ( src1 + x ) ; <nl> + v_float32x4 f1 = v_load ( src1 + x + 4 ) ; <nl> + v_float32x4 f2 = v_load ( src2 + x ) ; <nl> + v_float32x4 f3 = v_load ( src2 + x + 4 ) ; <nl> + <nl> + v_float32x4 res0 = f0 * v_scale / f2 ; <nl> + v_float32x4 res1 = f1 * v_scale / f3 ; <nl> + <nl> + res0 = v_select ( f2 = = v_zero , v_zero , res0 ) ; <nl> + res1 = v_select ( f3 = = v_zero , v_zero , res1 ) ; <nl> + <nl> + v_store ( dst + x , res0 ) ; <nl> + v_store ( dst + x + 4 , res1 ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / RECIPROCAL / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + template < > <nl> + struct Recip_SIMD < uchar > <nl> + { <nl> + bool haveSIMD ; <nl> + Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const uchar * src2 , uchar * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_uint16x8 v_zero = v_setzero_u16 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_uint16x8 v_src2 = v_load_expand ( src2 + x ) ; <nl> + <nl> + v_uint32x4 t0 , t1 ; <nl> + v_expand ( v_src2 , t0 , t1 ) ; <nl> + <nl> + v_float32x4 f0 = v_cvt_f32 ( v_reinterpret_as_s32 ( t0 ) ) ; <nl> + v_float32x4 f1 = v_cvt_f32 ( v_reinterpret_as_s32 ( t1 ) ) ; <nl> + <nl> + f0 = v_scale / f0 ; <nl> + f1 = v_scale / f1 ; <nl> + <nl> + v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> + v_uint16x8 res = v_pack_u ( i0 , i1 ) ; <nl> + <nl> + res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> + v_pack_store ( dst + x , res ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + template < > <nl> + struct Recip_SIMD < schar > <nl> + { <nl> + bool haveSIMD ; <nl> + Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const schar * src2 , schar * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_int16x8 v_zero = v_setzero_s16 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_int16x8 v_src2 = v_load_expand ( src2 + x ) ; <nl> + <nl> + v_int32x4 t0 , t1 ; <nl> + v_expand ( v_src2 , t0 , t1 ) ; <nl> + <nl> + v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> + v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> + <nl> + f0 = v_scale / f0 ; <nl> + f1 = v_scale / f1 ; <nl> + <nl> + v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> + v_int16x8 res = v_pack ( i0 , i1 ) ; <nl> + <nl> + res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> + v_pack_store ( dst + x , res ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + template < > <nl> + struct Recip_SIMD < ushort > <nl> + { <nl> + bool haveSIMD ; <nl> + Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const ushort * src2 , ushort * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_uint16x8 v_zero = v_setzero_u16 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_uint16x8 v_src2 = v_load ( src2 + x ) ; <nl> + <nl> + v_uint32x4 t0 , t1 ; <nl> + v_expand ( v_src2 , t0 , t1 ) ; <nl> + <nl> + v_float32x4 f0 = v_cvt_f32 ( v_reinterpret_as_s32 ( t0 ) ) ; <nl> + v_float32x4 f1 = v_cvt_f32 ( v_reinterpret_as_s32 ( t1 ) ) ; <nl> + <nl> + f0 = v_scale / f0 ; <nl> + f1 = v_scale / f1 ; <nl> + <nl> + v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> + v_uint16x8 res = v_pack_u ( i0 , i1 ) ; <nl> + <nl> + res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> + v_store ( dst + x , res ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct Recip_SIMD < short > <nl> + { <nl> + bool haveSIMD ; <nl> + Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const short * src2 , short * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_int16x8 v_zero = v_setzero_s16 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_int16x8 v_src2 = v_load ( src2 + x ) ; <nl> + <nl> + v_int32x4 t0 , t1 ; <nl> + v_expand ( v_src2 , t0 , t1 ) ; <nl> + <nl> + v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> + v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> + <nl> + f0 = v_scale / f0 ; <nl> + f1 = v_scale / f1 ; <nl> + <nl> + v_int32x4 i0 = v_round ( f0 ) , i1 = v_round ( f1 ) ; <nl> + v_int16x8 res = v_pack ( i0 , i1 ) ; <nl> + <nl> + res = v_select ( v_src2 = = v_zero , v_zero , res ) ; <nl> + v_store ( dst + x , res ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct Recip_SIMD < int > <nl> + { <nl> + bool haveSIMD ; <nl> + Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const int * src2 , int * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_int32x4 v_zero = v_setzero_s32 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_int32x4 t0 = v_load ( src2 + x ) ; <nl> + v_int32x4 t1 = v_load ( src2 + x + 4 ) ; <nl> + <nl> + v_float32x4 f0 = v_cvt_f32 ( t0 ) ; <nl> + v_float32x4 f1 = v_cvt_f32 ( t1 ) ; <nl> + <nl> + f0 = v_scale / f0 ; <nl> + f1 = v_scale / f1 ; <nl> + <nl> + v_int32x4 res0 = v_round ( f0 ) , res1 = v_round ( f1 ) ; <nl> + <nl> + res0 = v_select ( t0 = = v_zero , v_zero , res0 ) ; <nl> + res1 = v_select ( t1 = = v_zero , v_zero , res1 ) ; <nl> + v_store ( dst + x , res0 ) ; <nl> + v_store ( dst + x + 4 , res1 ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + template < > <nl> + struct Recip_SIMD < float > <nl> + { <nl> + bool haveSIMD ; <nl> + Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const float * src2 , float * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float32x4 v_scale = v_setall_f32 ( ( float ) scale ) ; <nl> + v_float32x4 v_zero = v_setzero_f32 ( ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + v_float32x4 f0 = v_load ( src2 + x ) ; <nl> + v_float32x4 f1 = v_load ( src2 + x + 4 ) ; <nl> + <nl> + v_float32x4 res0 = v_scale / f0 ; <nl> + v_float32x4 res1 = v_scale / f1 ; <nl> + <nl> + res0 = v_select ( f0 = = v_zero , v_zero , res0 ) ; <nl> + res1 = v_select ( f1 = = v_zero , v_zero , res1 ) ; <nl> + <nl> + v_store ( dst + x , res0 ) ; <nl> + v_store ( dst + x + 4 , res1 ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + # if CV_SIMD128_64F <nl> + <nl> + template < > <nl> + struct Div_SIMD < double > <nl> + { <nl> + bool haveSIMD ; <nl> + Div_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const double * src1 , const double * src2 , double * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float64x2 v_scale = v_setall_f64 ( scale ) ; <nl> + v_float64x2 v_zero = v_setzero_f64 ( ) ; <nl> + <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + v_float64x2 f0 = v_load ( src1 + x ) ; <nl> + v_float64x2 f1 = v_load ( src1 + x + 2 ) ; <nl> + v_float64x2 f2 = v_load ( src2 + x ) ; <nl> + v_float64x2 f3 = v_load ( src2 + x + 2 ) ; <nl> + <nl> + v_float64x2 res0 = f0 * v_scale / f2 ; <nl> + v_float64x2 res1 = f1 * v_scale / f3 ; <nl> + <nl> + res0 = v_select ( f0 = = v_zero , v_zero , res0 ) ; <nl> + res1 = v_select ( f1 = = v_zero , v_zero , res1 ) ; <nl> + <nl> + v_store ( dst + x , res0 ) ; <nl> + v_store ( dst + x + 2 , res1 ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct Recip_SIMD < double > <nl> + { <nl> + bool haveSIMD ; <nl> + Recip_SIMD ( ) { haveSIMD = checkHardwareSupport ( CV_CPU_SSE2 ) | | checkHardwareSupport ( CV_CPU_NEON ) ; } <nl> + <nl> + int operator ( ) ( const double * src2 , double * dst , int width , double scale ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSIMD ) <nl> + return x ; <nl> + <nl> + v_float64x2 v_scale = v_setall_f64 ( scale ) ; <nl> + v_float64x2 v_zero = v_setzero_f64 ( ) ; <nl> + <nl> + for ( ; x < = width - 4 ; x + = 4 ) <nl> + { <nl> + v_float64x2 f0 = v_load ( src2 + x ) ; <nl> + v_float64x2 f1 = v_load ( src2 + x + 2 ) ; <nl> + <nl> + v_float64x2 res0 = v_scale / f0 ; <nl> + v_float64x2 res1 = v_scale / f1 ; <nl> + <nl> + res0 = v_select ( f0 = = v_zero , v_zero , res0 ) ; <nl> + res1 = v_select ( f1 = = v_zero , v_zero , res1 ) ; <nl> + <nl> + v_store ( dst + x , res0 ) ; <nl> + v_store ( dst + x + 2 , res1 ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + # endif <nl> + <nl> + # endif <nl> + <nl> + <nl> + template < typename T , typename WT > <nl> + struct AddWeighted_SIMD <nl> + { <nl> + int operator ( ) ( const T * , const T * , T * , int , WT , WT , WT ) const <nl> + { <nl> + return 0 ; <nl> + } <nl> + } ; <nl> + <nl> + # if CV_SSE2 <nl> + <nl> + template < > <nl> + struct AddWeighted_SIMD < schar , float > <nl> + { <nl> + AddWeighted_SIMD ( ) <nl> + { <nl> + haveSSE2 = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const schar * src1 , const schar * src2 , schar * dst , int width , float alpha , float beta , float gamma ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSSE2 ) <nl> + return x ; <nl> + <nl> + __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> + __m128 v_alpha = _mm_set1_ps ( alpha ) , v_beta = _mm_set1_ps ( beta ) , <nl> + v_gamma = _mm_set1_ps ( gamma ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_src1 = _mm_loadl_epi64 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> + __m128i v_src2 = _mm_loadl_epi64 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> + <nl> + __m128i v_src1_p = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src1 ) , 8 ) ; <nl> + __m128i v_src2_p = _mm_srai_epi16 ( _mm_unpacklo_epi8 ( v_zero , v_src2 ) , 8 ) ; <nl> + <nl> + __m128 v_dstf0 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src1_p ) , 16 ) ) , v_alpha ) ; <nl> + v_dstf0 = _mm_add_ps ( _mm_add_ps ( v_dstf0 , v_gamma ) , <nl> + _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src2_p ) , 16 ) ) , v_beta ) ) ; <nl> + <nl> + __m128 v_dstf1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src1_p ) , 16 ) ) , v_alpha ) ; <nl> + v_dstf1 = _mm_add_ps ( _mm_add_ps ( v_dstf1 , v_gamma ) , <nl> + _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src2_p ) , 16 ) ) , v_beta ) ) ; <nl> + <nl> + __m128i v_dst16 = _mm_packs_epi32 ( _mm_cvtps_epi32 ( v_dstf0 ) , <nl> + _mm_cvtps_epi32 ( v_dstf1 ) ) ; <nl> + <nl> + _mm_storel_epi64 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi16 ( v_dst16 , v_zero ) ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + bool haveSSE2 ; <nl> + } ; <nl> + <nl> + template < > <nl> + struct AddWeighted_SIMD < short , float > <nl> + { <nl> + AddWeighted_SIMD ( ) <nl> + { <nl> + haveSSE2 = checkHardwareSupport ( CV_CPU_SSE2 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const short * src1 , const short * src2 , short * dst , int width , float alpha , float beta , float gamma ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSSE2 ) <nl> + return x ; <nl> + <nl> + __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> + __m128 v_alpha = _mm_set1_ps ( alpha ) , v_beta = _mm_set1_ps ( beta ) , <nl> + v_gamma = _mm_set1_ps ( gamma ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_src1 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> + __m128i v_src2 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> + <nl> + __m128 v_dstf0 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src1 ) , 16 ) ) , v_alpha ) ; <nl> + v_dstf0 = _mm_add_ps ( _mm_add_ps ( v_dstf0 , v_gamma ) , <nl> + _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpacklo_epi16 ( v_zero , v_src2 ) , 16 ) ) , v_beta ) ) ; <nl> + <nl> + __m128 v_dstf1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src1 ) , 16 ) ) , v_alpha ) ; <nl> + v_dstf1 = _mm_add_ps ( _mm_add_ps ( v_dstf1 , v_gamma ) , <nl> + _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_srai_epi32 ( _mm_unpackhi_epi16 ( v_zero , v_src2 ) , 16 ) ) , v_beta ) ) ; <nl> + <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_packs_epi32 ( _mm_cvtps_epi32 ( v_dstf0 ) , <nl> + _mm_cvtps_epi32 ( v_dstf1 ) ) ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + bool haveSSE2 ; <nl> + } ; <nl> + <nl> + # if CV_SSE4_1 <nl> + <nl> + template < > <nl> + struct AddWeighted_SIMD < ushort , float > <nl> + { <nl> + AddWeighted_SIMD ( ) <nl> + { <nl> + haveSSE4_1 = checkHardwareSupport ( CV_CPU_SSE4_1 ) ; <nl> + } <nl> + <nl> + int operator ( ) ( const ushort * src1 , const ushort * src2 , ushort * dst , int width , float alpha , float beta , float gamma ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + if ( ! haveSSE4_1 ) <nl> + return x ; <nl> + <nl> + __m128i v_zero = _mm_setzero_si128 ( ) ; <nl> + __m128 v_alpha = _mm_set1_ps ( alpha ) , v_beta = _mm_set1_ps ( beta ) , <nl> + v_gamma = _mm_set1_ps ( gamma ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + __m128i v_src1 = _mm_loadu_si128 ( ( const __m128i * ) ( src1 + x ) ) ; <nl> + __m128i v_src2 = _mm_loadu_si128 ( ( const __m128i * ) ( src2 + x ) ) ; <nl> + <nl> + __m128 v_dstf0 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( v_src1 , v_zero ) ) , v_alpha ) ; <nl> + v_dstf0 = _mm_add_ps ( _mm_add_ps ( v_dstf0 , v_gamma ) , <nl> + _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpacklo_epi16 ( v_src2 , v_zero ) ) , v_beta ) ) ; <nl> + <nl> + __m128 v_dstf1 = _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( v_src1 , v_zero ) ) , v_alpha ) ; <nl> + v_dstf1 = _mm_add_ps ( _mm_add_ps ( v_dstf1 , v_gamma ) , <nl> + _mm_mul_ps ( _mm_cvtepi32_ps ( _mm_unpackhi_epi16 ( v_src2 , v_zero ) ) , v_beta ) ) ; <nl> + <nl> + _mm_storeu_si128 ( ( __m128i * ) ( dst + x ) , _mm_packus_epi32 ( _mm_cvtps_epi32 ( v_dstf0 ) , <nl> + _mm_cvtps_epi32 ( v_dstf1 ) ) ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + <nl> + bool haveSSE4_1 ; <nl> + } ; <nl> + <nl> + # endif <nl> + <nl> + # elif CV_NEON <nl> + <nl> + template < > <nl> + struct AddWeighted_SIMD < schar , float > <nl> + { <nl> + int operator ( ) ( const schar * src1 , const schar * src2 , schar * dst , int width , float alpha , float beta , float gamma ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + float32x4_t g = vdupq_n_f32 ( gamma ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + int8x8_t in1 = vld1_s8 ( src1 + x ) ; <nl> + int16x8_t in1_16 = vmovl_s8 ( in1 ) ; <nl> + float32x4_t in1_f_l = vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( in1_16 ) ) ) ; <nl> + float32x4_t in1_f_h = vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( in1_16 ) ) ) ; <nl> + <nl> + int8x8_t in2 = vld1_s8 ( src2 + x ) ; <nl> + int16x8_t in2_16 = vmovl_s8 ( in2 ) ; <nl> + float32x4_t in2_f_l = vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( in2_16 ) ) ) ; <nl> + float32x4_t in2_f_h = vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( in2_16 ) ) ) ; <nl> + <nl> + float32x4_t out_f_l = vaddq_f32 ( vmulq_n_f32 ( in1_f_l , alpha ) , vmulq_n_f32 ( in2_f_l , beta ) ) ; <nl> + float32x4_t out_f_h = vaddq_f32 ( vmulq_n_f32 ( in1_f_h , alpha ) , vmulq_n_f32 ( in2_f_h , beta ) ) ; <nl> + out_f_l = vaddq_f32 ( out_f_l , g ) ; <nl> + out_f_h = vaddq_f32 ( out_f_h , g ) ; <nl> + <nl> + int16x4_t out_16_l = vqmovn_s32 ( cv_vrndq_s32_f32 ( out_f_l ) ) ; <nl> + int16x4_t out_16_h = vqmovn_s32 ( cv_vrndq_s32_f32 ( out_f_h ) ) ; <nl> + <nl> + int16x8_t out_16 = vcombine_s16 ( out_16_l , out_16_h ) ; <nl> + int8x8_t out = vqmovn_s16 ( out_16 ) ; <nl> + <nl> + vst1_s8 ( dst + x , out ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct AddWeighted_SIMD < ushort , float > <nl> + { <nl> + int operator ( ) ( const ushort * src1 , const ushort * src2 , ushort * dst , int width , float alpha , float beta , float gamma ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + float32x4_t g = vdupq_n_f32 ( gamma ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + uint16x8_t v_src1 = vld1q_u16 ( src1 + x ) , v_src2 = vld1q_u16 ( src2 + x ) ; <nl> + <nl> + float32x4_t v_s1 = vmulq_n_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src1 ) ) ) , alpha ) ; <nl> + float32x4_t v_s2 = vmulq_n_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_low_u16 ( v_src2 ) ) ) , beta ) ; <nl> + uint16x4_t v_dst1 = vqmovn_u32 ( cv_vrndq_u32_f32 ( vaddq_f32 ( vaddq_f32 ( v_s1 , v_s2 ) , g ) ) ) ; <nl> + <nl> + v_s1 = vmulq_n_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src1 ) ) ) , alpha ) ; <nl> + v_s2 = vmulq_n_f32 ( vcvtq_f32_u32 ( vmovl_u16 ( vget_high_u16 ( v_src2 ) ) ) , beta ) ; <nl> + uint16x4_t v_dst2 = vqmovn_u32 ( cv_vrndq_u32_f32 ( vaddq_f32 ( vaddq_f32 ( v_s1 , v_s2 ) , g ) ) ) ; <nl> + <nl> + vst1q_u16 ( dst + x , vcombine_u16 ( v_dst1 , v_dst2 ) ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + template < > <nl> + struct AddWeighted_SIMD < short , float > <nl> + { <nl> + int operator ( ) ( const short * src1 , const short * src2 , short * dst , int width , float alpha , float beta , float gamma ) const <nl> + { <nl> + int x = 0 ; <nl> + <nl> + float32x4_t g = vdupq_n_f32 ( gamma ) ; <nl> + <nl> + for ( ; x < = width - 8 ; x + = 8 ) <nl> + { <nl> + int16x8_t v_src1 = vld1q_s16 ( src1 + x ) , v_src2 = vld1q_s16 ( src2 + x ) ; <nl> + <nl> + float32x4_t v_s1 = vmulq_n_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src1 ) ) ) , alpha ) ; <nl> + float32x4_t v_s2 = vmulq_n_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_low_s16 ( v_src2 ) ) ) , beta ) ; <nl> + int16x4_t v_dst1 = vqmovn_s32 ( cv_vrndq_s32_f32 ( vaddq_f32 ( vaddq_f32 ( v_s1 , v_s2 ) , g ) ) ) ; <nl> + <nl> + v_s1 = vmulq_n_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src1 ) ) ) , alpha ) ; <nl> + v_s2 = vmulq_n_f32 ( vcvtq_f32_s32 ( vmovl_s16 ( vget_high_s16 ( v_src2 ) ) ) , beta ) ; <nl> + int16x4_t v_dst2 = vqmovn_s32 ( cv_vrndq_s32_f32 ( vaddq_f32 ( vaddq_f32 ( v_s1 , v_s2 ) , g ) ) ) ; <nl> + <nl> + vst1q_s16 ( dst + x , vcombine_s16 ( v_dst1 , v_dst2 ) ) ; <nl> + } <nl> + <nl> + return x ; <nl> + } <nl> + } ; <nl> + <nl> + # endif <nl> + <nl> + } } <nl> + <nl> + # endif / / __OPENCV_HAL_ARITHM_SIMD_HPP__ <nl> new file mode 100644 <nl> index 00000000000 . . 6a08b9f44af <nl> mmm / dev / null <nl> ppp b / modules / hal / src / hardware . cpp <nl> <nl> + # include " precomp . hpp " <nl> + <nl> + # if defined WIN32 | | defined _WIN32 | | defined WINCE <nl> + # include < windows . h > <nl> + # if defined _MSC_VER <nl> + # if _MSC_VER > = 1400 <nl> + # include < intrin . h > <nl> + # elif defined _M_IX86 <nl> + static void __cpuid ( int * cpuid_data , int ) <nl> + { <nl> + __asm <nl> + { <nl> + push ebx <nl> + push edi <nl> + mov edi , cpuid_data <nl> + mov eax , 1 <nl> + cpuid <nl> + mov [ edi ] , eax <nl> + mov [ edi + 4 ] , ebx <nl> + mov [ edi + 8 ] , ecx <nl> + mov [ edi + 12 ] , edx <nl> + pop edi <nl> + pop ebx <nl> + } <nl> + } <nl> + static void __cpuidex ( int * cpuid_data , int , int ) <nl> + { <nl> + __asm <nl> + { <nl> + push edi <nl> + mov edi , cpuid_data <nl> + mov eax , 7 <nl> + mov ecx , 0 <nl> + cpuid <nl> + mov [ edi ] , eax <nl> + mov [ edi + 4 ] , ebx <nl> + mov [ edi + 8 ] , ecx <nl> + mov [ edi + 12 ] , edx <nl> + pop edi <nl> + } <nl> + } <nl> + # endif <nl> + # endif <nl> + # endif <nl> + <nl> + # if defined ANDROID | | defined __linux__ <nl> + # include < unistd . h > <nl> + # include < fcntl . h > <nl> + # include < elf . h > <nl> + # include < linux / auxvec . h > <nl> + # endif <nl> + <nl> + # if defined __linux__ | | defined __APPLE__ | | defined __EMSCRIPTEN__ <nl> + # include < unistd . h > <nl> + # include < stdio . h > <nl> + # include < sys / types . h > <nl> + # if defined ANDROID <nl> + # include < sys / sysconf . h > <nl> + # endif <nl> + # endif <nl> + <nl> + # ifdef ANDROID <nl> + # include < android / log . h > <nl> + # endif <nl> + <nl> + struct HWFeatures <nl> + { <nl> + enum { MAX_FEATURE = CV_HARDWARE_MAX_FEATURE } ; <nl> + <nl> + HWFeatures ( void ) <nl> + { <nl> + memset ( have , 0 , sizeof ( have ) ) ; <nl> + x86_family = 0 ; <nl> + } <nl> + <nl> + static HWFeatures initialize ( void ) <nl> + { <nl> + HWFeatures f ; <nl> + int cpuid_data [ 4 ] = { 0 , 0 , 0 , 0 } ; <nl> + <nl> + # if defined _MSC_VER & & ( defined _M_IX86 | | defined _M_X64 ) <nl> + __cpuid ( cpuid_data , 1 ) ; <nl> + # elif defined __GNUC__ & & ( defined __i386__ | | defined __x86_64__ ) <nl> + # ifdef __x86_64__ <nl> + asm __volatile__ <nl> + ( <nl> + " movl $ 1 , % % eax \ n \ t " <nl> + " cpuid \ n \ t " <nl> + : [ eax ] " = a " ( cpuid_data [ 0 ] ) , [ ebx ] " = b " ( cpuid_data [ 1 ] ) , [ ecx ] " = c " ( cpuid_data [ 2 ] ) , [ edx ] " = d " ( cpuid_data [ 3 ] ) <nl> + : <nl> + : " cc " <nl> + ) ; <nl> + # else <nl> + asm volatile <nl> + ( <nl> + " pushl % % ebx \ n \ t " <nl> + " movl $ 1 , % % eax \ n \ t " <nl> + " cpuid \ n \ t " <nl> + " popl % % ebx \ n \ t " <nl> + : " = a " ( cpuid_data [ 0 ] ) , " = c " ( cpuid_data [ 2 ] ) , " = d " ( cpuid_data [ 3 ] ) <nl> + : <nl> + : " cc " <nl> + ) ; <nl> + # endif <nl> + # endif <nl> + <nl> + f . x86_family = ( cpuid_data [ 0 ] > > 8 ) & 15 ; <nl> + if ( f . x86_family > = 6 ) <nl> + { <nl> + f . have [ CV_CPU_MMX ] = ( cpuid_data [ 3 ] & ( 1 < < 23 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_SSE ] = ( cpuid_data [ 3 ] & ( 1 < < 25 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_SSE2 ] = ( cpuid_data [ 3 ] & ( 1 < < 26 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_SSE3 ] = ( cpuid_data [ 2 ] & ( 1 < < 0 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_SSSE3 ] = ( cpuid_data [ 2 ] & ( 1 < < 9 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_FMA3 ] = ( cpuid_data [ 2 ] & ( 1 < < 12 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_SSE4_1 ] = ( cpuid_data [ 2 ] & ( 1 < < 19 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_SSE4_2 ] = ( cpuid_data [ 2 ] & ( 1 < < 20 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_POPCNT ] = ( cpuid_data [ 2 ] & ( 1 < < 23 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_AVX ] = ( ( ( cpuid_data [ 2 ] & ( 1 < < 28 ) ) ! = 0 ) & & ( ( cpuid_data [ 2 ] & ( 1 < < 27 ) ) ! = 0 ) ) ; / / OS uses XSAVE_XRSTORE and CPU support AVX <nl> + <nl> + / / make the second call to the cpuid command in order to get <nl> + / / information about extended features like AVX2 <nl> + # if defined _MSC_VER & & ( defined _M_IX86 | | defined _M_X64 ) <nl> + __cpuidex ( cpuid_data , 7 , 0 ) ; <nl> + # elif defined __GNUC__ & & ( defined __i386__ | | defined __x86_64__ ) <nl> + # ifdef __x86_64__ <nl> + asm __volatile__ <nl> + ( <nl> + " movl $ 7 , % % eax \ n \ t " <nl> + " movl $ 0 , % % ecx \ n \ t " <nl> + " cpuid \ n \ t " <nl> + : [ eax ] " = a " ( cpuid_data [ 0 ] ) , [ ebx ] " = b " ( cpuid_data [ 1 ] ) , [ ecx ] " = c " ( cpuid_data [ 2 ] ) , [ edx ] " = d " ( cpuid_data [ 3 ] ) <nl> + : <nl> + : " cc " <nl> + ) ; <nl> + # else <nl> + asm volatile <nl> + ( <nl> + " pushl % % ebx \ n \ t " <nl> + " movl $ 7 , % % eax \ n \ t " <nl> + " movl $ 0 , % % ecx \ n \ t " <nl> + " cpuid \ n \ t " <nl> + " movl % % ebx , % 0 \ n \ t " <nl> + " popl % % ebx \ n \ t " <nl> + : " = r " ( cpuid_data [ 1 ] ) , " = c " ( cpuid_data [ 2 ] ) <nl> + : <nl> + : " cc " <nl> + ) ; <nl> + # endif <nl> + # endif <nl> + f . have [ CV_CPU_AVX2 ] = ( cpuid_data [ 1 ] & ( 1 < < 5 ) ) ! = 0 ; <nl> + <nl> + f . have [ CV_CPU_AVX_512F ] = ( cpuid_data [ 1 ] & ( 1 < < 16 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_AVX_512DQ ] = ( cpuid_data [ 1 ] & ( 1 < < 17 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_AVX_512IFMA512 ] = ( cpuid_data [ 1 ] & ( 1 < < 21 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_AVX_512PF ] = ( cpuid_data [ 1 ] & ( 1 < < 26 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_AVX_512ER ] = ( cpuid_data [ 1 ] & ( 1 < < 27 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_AVX_512CD ] = ( cpuid_data [ 1 ] & ( 1 < < 28 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_AVX_512BW ] = ( cpuid_data [ 1 ] & ( 1 < < 30 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_AVX_512VL ] = ( cpuid_data [ 1 ] & ( 1 < < 31 ) ) ! = 0 ; <nl> + f . have [ CV_CPU_AVX_512VBMI ] = ( cpuid_data [ 2 ] & ( 1 < < 1 ) ) ! = 0 ; <nl> + } <nl> + <nl> + # if defined ANDROID | | defined __linux__ <nl> + # ifdef __aarch64__ <nl> + f . have [ CV_CPU_NEON ] = true ; <nl> + # else <nl> + int cpufile = open ( " / proc / self / auxv " , O_RDONLY ) ; <nl> + <nl> + if ( cpufile > = 0 ) <nl> + { <nl> + Elf32_auxv_t auxv ; <nl> + const size_t size_auxv_t = sizeof ( auxv ) ; <nl> + <nl> + while ( ( size_t ) read ( cpufile , & auxv , size_auxv_t ) = = size_auxv_t ) <nl> + { <nl> + if ( auxv . a_type = = AT_HWCAP ) <nl> + { <nl> + f . have [ CV_CPU_NEON ] = ( auxv . a_un . a_val & 4096 ) ! = 0 ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + close ( cpufile ) ; <nl> + } <nl> + # endif <nl> + # elif ( defined __clang__ | | defined __APPLE__ ) & & ( defined __ARM_NEON__ | | ( defined __ARM_NEON & & defined __aarch64__ ) ) <nl> + f . have [ CV_CPU_NEON ] = true ; <nl> + # endif <nl> + <nl> + return f ; <nl> + } <nl> + <nl> + int x86_family ; <nl> + bool have [ MAX_FEATURE + 1 ] ; <nl> + } ; <nl> + <nl> + static HWFeatures featuresEnabled = HWFeatures : : initialize ( ) , featuresDisabled = HWFeatures ( ) ; <nl> + static HWFeatures * currentFeatures = & featuresEnabled ; <nl> + volatile bool useOptimizedFlag = true ; <nl> + <nl> + namespace cv { namespace hal { <nl> + <nl> + bool checkHardwareSupport ( int feature ) <nl> + { <nl> + / / CV_DbgAssert ( 0 < = feature & & feature < = CV_HARDWARE_MAX_FEATURE ) ; <nl> + return currentFeatures - > have [ feature ] ; <nl> + } <nl> + <nl> + void setUseOptimized ( bool flag ) <nl> + { <nl> + useOptimizedFlag = flag ; <nl> + currentFeatures = flag ? & featuresEnabled : & featuresDisabled ; <nl> + } <nl> + <nl> + bool useOptimized ( void ) <nl> + { <nl> + return useOptimizedFlag ; <nl> + } <nl> + <nl> + } } <nl> new file mode 100644 <nl> index 00000000000 . . 982b24c2505 <nl> mmm / dev / null <nl> ppp b / modules / hal / src / merge . cpp <nl> <nl> + / * M / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / IMPORTANT : READ BEFORE DOWNLOADING , COPYING , INSTALLING OR USING . <nl> + / / <nl> + / / By downloading , copying , installing or using the software you agree to this license . <nl> + / / If you do not agree to this license , do not download , install , <nl> + / / copy or use the software . <nl> + / / <nl> + / / <nl> + / / License Agreement <nl> + / / For Open Source Computer Vision Library <nl> + / / <nl> + / / Copyright ( C ) 2000 - 2008 , Intel Corporation , all rights reserved . <nl> + / / Copyright ( C ) 2009 - 2011 , Willow Garage Inc . , all rights reserved . <nl> + / / Copyright ( C ) 2014 - 2015 , Itseez Inc . , all rights reserved . <nl> + / / Third party copyrights are property of their respective owners . <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without modification , <nl> + / / are permitted provided that the following conditions are met : <nl> + / / <nl> + / / * Redistribution ' s of source code must retain the above copyright notice , <nl> + / / this list of conditions and the following disclaimer . <nl> + / / <nl> + / / * Redistribution ' s in binary form must reproduce the above copyright notice , <nl> + / / this list of conditions and the following disclaimer in the documentation <nl> + / / and / or other materials provided with the distribution . <nl> + / / <nl> + / / * The name of the copyright holders may not be used to endorse or promote products <nl> + / / derived from this software without specific prior written permission . <nl> + / / <nl> + / / This software is provided by the copyright holders and contributors " as is " and <nl> + / / any express or implied warranties , including , but not limited to , the implied <nl> + / / warranties of merchantability and fitness for a particular purpose are disclaimed . <nl> + / / In no event shall the Intel Corporation or contributors be liable for any direct , <nl> + / / indirect , incidental , special , exemplary , or consequential damages <nl> + / / ( including , but not limited to , procurement of substitute goods or services ; <nl> + / / loss of use , data , or profits ; or business interruption ) however caused <nl> + / / and on any theory of liability , whether in contract , strict liability , <nl> + / / or tort ( including negligence or otherwise ) arising in any way out of <nl> + / / the use of this software , even if advised of the possibility of such damage . <nl> + / / <nl> + / / M * / <nl> + <nl> + # include " precomp . hpp " <nl> + <nl> + namespace cv { namespace hal { <nl> + <nl> + # if CV_NEON <nl> + template < typename T > struct VMerge2 ; <nl> + template < typename T > struct VMerge3 ; <nl> + template < typename T > struct VMerge4 ; <nl> + <nl> + # define MERGE2_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> + template < > \ <nl> + struct name < data_type > { \ <nl> + void operator ( ) ( const data_type * src0 , const data_type * src1 , \ <nl> + data_type * dst ) { \ <nl> + reg_type r ; \ <nl> + r . val [ 0 ] = load_func ( src0 ) ; \ <nl> + r . val [ 1 ] = load_func ( src1 ) ; \ <nl> + store_func ( dst , r ) ; \ <nl> + } \ <nl> + } <nl> + <nl> + # define MERGE3_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> + template < > \ <nl> + struct name < data_type > { \ <nl> + void operator ( ) ( const data_type * src0 , const data_type * src1 , \ <nl> + const data_type * src2 , data_type * dst ) { \ <nl> + reg_type r ; \ <nl> + r . val [ 0 ] = load_func ( src0 ) ; \ <nl> + r . val [ 1 ] = load_func ( src1 ) ; \ <nl> + r . val [ 2 ] = load_func ( src2 ) ; \ <nl> + store_func ( dst , r ) ; \ <nl> + } \ <nl> + } <nl> + <nl> + # define MERGE4_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> + template < > \ <nl> + struct name < data_type > { \ <nl> + void operator ( ) ( const data_type * src0 , const data_type * src1 , \ <nl> + const data_type * src2 , const data_type * src3 , \ <nl> + data_type * dst ) { \ <nl> + reg_type r ; \ <nl> + r . val [ 0 ] = load_func ( src0 ) ; \ <nl> + r . val [ 1 ] = load_func ( src1 ) ; \ <nl> + r . val [ 2 ] = load_func ( src2 ) ; \ <nl> + r . val [ 3 ] = load_func ( src3 ) ; \ <nl> + store_func ( dst , r ) ; \ <nl> + } \ <nl> + } <nl> + <nl> + MERGE2_KERNEL_TEMPLATE ( VMerge2 , uchar , uint8x16x2_t , vld1q_u8 , vst2q_u8 ) ; <nl> + MERGE2_KERNEL_TEMPLATE ( VMerge2 , ushort , uint16x8x2_t , vld1q_u16 , vst2q_u16 ) ; <nl> + MERGE2_KERNEL_TEMPLATE ( VMerge2 , int , int32x4x2_t , vld1q_s32 , vst2q_s32 ) ; <nl> + MERGE2_KERNEL_TEMPLATE ( VMerge2 , int64 , int64x1x2_t , vld1_s64 , vst2_s64 ) ; <nl> + <nl> + MERGE3_KERNEL_TEMPLATE ( VMerge3 , uchar , uint8x16x3_t , vld1q_u8 , vst3q_u8 ) ; <nl> + MERGE3_KERNEL_TEMPLATE ( VMerge3 , ushort , uint16x8x3_t , vld1q_u16 , vst3q_u16 ) ; <nl> + MERGE3_KERNEL_TEMPLATE ( VMerge3 , int , int32x4x3_t , vld1q_s32 , vst3q_s32 ) ; <nl> + MERGE3_KERNEL_TEMPLATE ( VMerge3 , int64 , int64x1x3_t , vld1_s64 , vst3_s64 ) ; <nl> + <nl> + MERGE4_KERNEL_TEMPLATE ( VMerge4 , uchar , uint8x16x4_t , vld1q_u8 , vst4q_u8 ) ; <nl> + MERGE4_KERNEL_TEMPLATE ( VMerge4 , ushort , uint16x8x4_t , vld1q_u16 , vst4q_u16 ) ; <nl> + MERGE4_KERNEL_TEMPLATE ( VMerge4 , int , int32x4x4_t , vld1q_s32 , vst4q_s32 ) ; <nl> + MERGE4_KERNEL_TEMPLATE ( VMerge4 , int64 , int64x1x4_t , vld1_s64 , vst4_s64 ) ; <nl> + <nl> + # elif CV_SSE2 <nl> + <nl> + template < typename T > <nl> + struct VMerge2 <nl> + { <nl> + VMerge2 ( ) : support ( false ) { } <nl> + void operator ( ) ( const T * , const T * , T * ) const { } <nl> + <nl> + bool support ; <nl> + } ; <nl> + <nl> + template < typename T > <nl> + struct VMerge3 <nl> + { <nl> + VMerge3 ( ) : support ( false ) { } <nl> + void operator ( ) ( const T * , const T * , const T * , T * ) const { } <nl> + <nl> + bool support ; <nl> + } ; <nl> + <nl> + template < typename T > <nl> + struct VMerge4 <nl> + { <nl> + VMerge4 ( ) : support ( false ) { } <nl> + void operator ( ) ( const T * , const T * , const T * , const T * , T * ) const { } <nl> + <nl> + bool support ; <nl> + } ; <nl> + <nl> + # define MERGE2_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_interleave , flavor , se ) \ <nl> + template < > \ <nl> + struct VMerge2 < data_type > \ <nl> + { \ <nl> + enum \ <nl> + { \ <nl> + ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> + } ; \ <nl> + \ <nl> + VMerge2 ( ) \ <nl> + { \ <nl> + support = checkHardwareSupport ( se ) ; \ <nl> + } \ <nl> + \ <nl> + void operator ( ) ( const data_type * src0 , const data_type * src1 , \ <nl> + data_type * dst ) const \ <nl> + { \ <nl> + reg_type v_src0 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 ) ) ; \ <nl> + reg_type v_src1 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 + ELEMS_IN_VEC ) ) ; \ <nl> + reg_type v_src2 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 ) ) ; \ <nl> + reg_type v_src3 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 + ELEMS_IN_VEC ) ) ; \ <nl> + \ <nl> + _mm_interleave ( v_src0 , v_src1 , v_src2 , v_src3 ) ; \ <nl> + \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst ) , v_src0 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 2 ) , v_src2 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 3 ) , v_src3 ) ; \ <nl> + } \ <nl> + \ <nl> + bool support ; \ <nl> + } <nl> + <nl> + # define MERGE3_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_interleave , flavor , se ) \ <nl> + template < > \ <nl> + struct VMerge3 < data_type > \ <nl> + { \ <nl> + enum \ <nl> + { \ <nl> + ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> + } ; \ <nl> + \ <nl> + VMerge3 ( ) \ <nl> + { \ <nl> + support = checkHardwareSupport ( se ) ; \ <nl> + } \ <nl> + \ <nl> + void operator ( ) ( const data_type * src0 , const data_type * src1 , const data_type * src2 , \ <nl> + data_type * dst ) const \ <nl> + { \ <nl> + reg_type v_src0 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 ) ) ; \ <nl> + reg_type v_src1 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 + ELEMS_IN_VEC ) ) ; \ <nl> + reg_type v_src2 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 ) ) ; \ <nl> + reg_type v_src3 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 + ELEMS_IN_VEC ) ) ; \ <nl> + reg_type v_src4 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src2 ) ) ; \ <nl> + reg_type v_src5 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src2 + ELEMS_IN_VEC ) ) ; \ <nl> + \ <nl> + _mm_interleave ( v_src0 , v_src1 , v_src2 , \ <nl> + v_src3 , v_src4 , v_src5 ) ; \ <nl> + \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst ) , v_src0 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 2 ) , v_src2 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 3 ) , v_src3 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 4 ) , v_src4 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 5 ) , v_src5 ) ; \ <nl> + } \ <nl> + \ <nl> + bool support ; \ <nl> + } <nl> + <nl> + # define MERGE4_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_interleave , flavor , se ) \ <nl> + template < > \ <nl> + struct VMerge4 < data_type > \ <nl> + { \ <nl> + enum \ <nl> + { \ <nl> + ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> + } ; \ <nl> + \ <nl> + VMerge4 ( ) \ <nl> + { \ <nl> + support = checkHardwareSupport ( se ) ; \ <nl> + } \ <nl> + \ <nl> + void operator ( ) ( const data_type * src0 , const data_type * src1 , \ <nl> + const data_type * src2 , const data_type * src3 , \ <nl> + data_type * dst ) const \ <nl> + { \ <nl> + reg_type v_src0 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 ) ) ; \ <nl> + reg_type v_src1 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src0 + ELEMS_IN_VEC ) ) ; \ <nl> + reg_type v_src2 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 ) ) ; \ <nl> + reg_type v_src3 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src1 + ELEMS_IN_VEC ) ) ; \ <nl> + reg_type v_src4 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src2 ) ) ; \ <nl> + reg_type v_src5 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src2 + ELEMS_IN_VEC ) ) ; \ <nl> + reg_type v_src6 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src3 ) ) ; \ <nl> + reg_type v_src7 = _mm_loadu_ # # flavor ( ( const cast_type * ) ( src3 + ELEMS_IN_VEC ) ) ; \ <nl> + \ <nl> + _mm_interleave ( v_src0 , v_src1 , v_src2 , v_src3 , \ <nl> + v_src4 , v_src5 , v_src6 , v_src7 ) ; \ <nl> + \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst ) , v_src0 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 2 ) , v_src2 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 3 ) , v_src3 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 4 ) , v_src4 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 5 ) , v_src5 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 6 ) , v_src6 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst + ELEMS_IN_VEC * 7 ) , v_src7 ) ; \ <nl> + } \ <nl> + \ <nl> + bool support ; \ <nl> + } <nl> + <nl> + MERGE2_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_interleave_epi8 , si128 , CV_CPU_SSE2 ) ; <nl> + MERGE3_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_interleave_epi8 , si128 , CV_CPU_SSE2 ) ; <nl> + MERGE4_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_interleave_epi8 , si128 , CV_CPU_SSE2 ) ; <nl> + <nl> + # if CV_SSE4_1 <nl> + MERGE2_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_interleave_epi16 , si128 , CV_CPU_SSE4_1 ) ; <nl> + MERGE3_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_interleave_epi16 , si128 , CV_CPU_SSE4_1 ) ; <nl> + MERGE4_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_interleave_epi16 , si128 , CV_CPU_SSE4_1 ) ; <nl> + # endif <nl> + <nl> + MERGE2_KERNEL_TEMPLATE ( int , __m128 , float , _mm_interleave_ps , ps , CV_CPU_SSE2 ) ; <nl> + MERGE3_KERNEL_TEMPLATE ( int , __m128 , float , _mm_interleave_ps , ps , CV_CPU_SSE2 ) ; <nl> + MERGE4_KERNEL_TEMPLATE ( int , __m128 , float , _mm_interleave_ps , ps , CV_CPU_SSE2 ) ; <nl> + <nl> + # endif <nl> + <nl> + template < typename T > static void <nl> + merge_ ( const T * * src , T * dst , int len , int cn ) <nl> + { <nl> + int k = cn % 4 ? cn % 4 : 4 ; <nl> + int i , j ; <nl> + if ( k = = 1 ) <nl> + { <nl> + const T * src0 = src [ 0 ] ; <nl> + for ( i = j = 0 ; i < len ; i + + , j + = cn ) <nl> + dst [ j ] = src0 [ i ] ; <nl> + } <nl> + else if ( k = = 2 ) <nl> + { <nl> + const T * src0 = src [ 0 ] , * src1 = src [ 1 ] ; <nl> + i = j = 0 ; <nl> + # if CV_NEON <nl> + if ( cn = = 2 ) <nl> + { <nl> + int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> + int inc_j = 2 * inc_i ; <nl> + <nl> + VMerge2 < T > vmerge ; <nl> + for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vmerge ( src0 + i , src1 + i , dst + j ) ; <nl> + } <nl> + # elif CV_SSE2 <nl> + if ( cn = = 2 ) <nl> + { <nl> + int inc_i = 32 / sizeof ( T ) ; <nl> + int inc_j = 2 * inc_i ; <nl> + <nl> + VMerge2 < T > vmerge ; <nl> + if ( vmerge . support ) <nl> + for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vmerge ( src0 + i , src1 + i , dst + j ) ; <nl> + } <nl> + # endif <nl> + for ( ; i < len ; i + + , j + = cn ) <nl> + { <nl> + dst [ j ] = src0 [ i ] ; <nl> + dst [ j + 1 ] = src1 [ i ] ; <nl> + } <nl> + } <nl> + else if ( k = = 3 ) <nl> + { <nl> + const T * src0 = src [ 0 ] , * src1 = src [ 1 ] , * src2 = src [ 2 ] ; <nl> + i = j = 0 ; <nl> + # if CV_NEON <nl> + if ( cn = = 3 ) <nl> + { <nl> + int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> + int inc_j = 3 * inc_i ; <nl> + <nl> + VMerge3 < T > vmerge ; <nl> + for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vmerge ( src0 + i , src1 + i , src2 + i , dst + j ) ; <nl> + } <nl> + # elif CV_SSE2 <nl> + if ( cn = = 3 ) <nl> + { <nl> + int inc_i = 32 / sizeof ( T ) ; <nl> + int inc_j = 3 * inc_i ; <nl> + <nl> + VMerge3 < T > vmerge ; <nl> + if ( vmerge . support ) <nl> + for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vmerge ( src0 + i , src1 + i , src2 + i , dst + j ) ; <nl> + } <nl> + # endif <nl> + for ( ; i < len ; i + + , j + = cn ) <nl> + { <nl> + dst [ j ] = src0 [ i ] ; <nl> + dst [ j + 1 ] = src1 [ i ] ; <nl> + dst [ j + 2 ] = src2 [ i ] ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + const T * src0 = src [ 0 ] , * src1 = src [ 1 ] , * src2 = src [ 2 ] , * src3 = src [ 3 ] ; <nl> + i = j = 0 ; <nl> + # if CV_NEON <nl> + if ( cn = = 4 ) <nl> + { <nl> + int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> + int inc_j = 4 * inc_i ; <nl> + <nl> + VMerge4 < T > vmerge ; <nl> + for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vmerge ( src0 + i , src1 + i , src2 + i , src3 + i , dst + j ) ; <nl> + } <nl> + # elif CV_SSE2 <nl> + if ( cn = = 4 ) <nl> + { <nl> + int inc_i = 32 / sizeof ( T ) ; <nl> + int inc_j = 4 * inc_i ; <nl> + <nl> + VMerge4 < T > vmerge ; <nl> + if ( vmerge . support ) <nl> + for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vmerge ( src0 + i , src1 + i , src2 + i , src3 + i , dst + j ) ; <nl> + } <nl> + # endif <nl> + for ( ; i < len ; i + + , j + = cn ) <nl> + { <nl> + dst [ j ] = src0 [ i ] ; dst [ j + 1 ] = src1 [ i ] ; <nl> + dst [ j + 2 ] = src2 [ i ] ; dst [ j + 3 ] = src3 [ i ] ; <nl> + } <nl> + } <nl> + <nl> + for ( ; k < cn ; k + = 4 ) <nl> + { <nl> + const T * src0 = src [ k ] , * src1 = src [ k + 1 ] , * src2 = src [ k + 2 ] , * src3 = src [ k + 3 ] ; <nl> + for ( i = 0 , j = k ; i < len ; i + + , j + = cn ) <nl> + { <nl> + dst [ j ] = src0 [ i ] ; dst [ j + 1 ] = src1 [ i ] ; <nl> + dst [ j + 2 ] = src2 [ i ] ; dst [ j + 3 ] = src3 [ i ] ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + <nl> + void merge8u ( const uchar * * src , uchar * dst , int len , int cn ) <nl> + { <nl> + merge_ ( src , dst , len , cn ) ; <nl> + } <nl> + <nl> + void merge16u ( const ushort * * src , ushort * dst , int len , int cn ) <nl> + { <nl> + merge_ ( src , dst , len , cn ) ; <nl> + } <nl> + <nl> + void merge32s ( const int * * src , int * dst , int len , int cn ) <nl> + { <nl> + merge_ ( src , dst , len , cn ) ; <nl> + } <nl> + <nl> + void merge64s ( const int64 * * src , int64 * dst , int len , int cn ) <nl> + { <nl> + merge_ ( src , dst , len , cn ) ; <nl> + } <nl> + <nl> + } } <nl> mmm a / modules / hal / src / precomp . hpp <nl> ppp b / modules / hal / src / precomp . hpp <nl> <nl> # include < cstdlib > <nl> # include < limits > <nl> # include < float . h > <nl> + # include < cstring > <nl> + # include < cassert > <nl> + <nl> + # include " opencv2 / hal / sse_utils . hpp " <nl> + # include " opencv2 / hal / neon_utils . hpp " <nl> + <nl> + # if defined HAVE_IPP & & ( IPP_VERSION_X100 > = 700 ) <nl> + # define ARITHM_USE_IPP 1 <nl> + # else <nl> + # define ARITHM_USE_IPP 0 <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . c8cc19224e5 <nl> mmm / dev / null <nl> ppp b / modules / hal / src / replacement . hpp <nl> <nl> + / * M / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / IMPORTANT : READ BEFORE DOWNLOADING , COPYING , INSTALLING OR USING . <nl> + / / <nl> + / / By downloading , copying , installing or using the software you agree to this license . <nl> + / / If you do not agree to this license , do not download , install , <nl> + / / copy or use the software . <nl> + / / <nl> + / / <nl> + / / License Agreement <nl> + / / For Open Source Computer Vision Library <nl> + / / <nl> + / / Copyright ( C ) 2000 - 2008 , Intel Corporation , all rights reserved . <nl> + / / Copyright ( C ) 2009 , Willow Garage Inc . , all rights reserved . <nl> + / / Copyright ( C ) 2013 , OpenCV Foundation , all rights reserved . <nl> + / / Copyright ( C ) 2015 , Itseez Inc . , all rights reserved . <nl> + / / Third party copyrights are property of their respective owners . <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without modification , <nl> + / / are permitted provided that the following conditions are met : <nl> + / / <nl> + / / * Redistribution ' s of source code must retain the above copyright notice , <nl> + / / this list of conditions and the following disclaimer . <nl> + / / <nl> + / / * Redistribution ' s in binary form must reproduce the above copyright notice , <nl> + / / this list of conditions and the following disclaimer in the documentation <nl> + / / and / or other materials provided with the distribution . <nl> + / / <nl> + / / * The name of the copyright holders may not be used to endorse or promote products <nl> + / / derived from this software without specific prior written permission . <nl> + / / <nl> + / / This software is provided by the copyright holders and contributors " as is " and <nl> + / / any express or implied warranties , including , but not limited to , the implied <nl> + / / warranties of merchantability and fitness for a particular purpose are disclaimed . <nl> + / / In no event shall the Intel Corporation or contributors be liable for any direct , <nl> + / / indirect , incidental , special , exemplary , or consequential damages <nl> + / / ( including , but not limited to , procurement of substitute goods or services ; <nl> + / / loss of use , data , or profits ; or business interruption ) however caused <nl> + / / and on any theory of liability , whether in contract , strict liability , <nl> + / / or tort ( including negligence or otherwise ) arising in any way out of <nl> + / / the use of this software , even if advised of the possibility of such damage . <nl> + / / <nl> + / / M * / <nl> + <nl> + # ifndef __OPENCV_HAL_REPLACEMENT_HPP__ <nl> + # define __OPENCV_HAL_REPLACEMENT_HPP__ <nl> + <nl> + # include " opencv2 / hal . hpp " <nl> + <nl> + inline int hal_t_add8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_add8s ( const schar * , size_t , const schar * , size_t , schar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_add16u ( const ushort * , size_t , const ushort * , size_t , ushort * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_add16s ( const short * , size_t , const short * , size_t , short * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_add32s ( const int * , size_t , const int * , size_t , int * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_add32f ( const float * , size_t , const float * , size_t , float * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_add64f ( const double * , size_t , const double * , size_t , double * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_sub8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_sub8s ( const schar * , size_t , const schar * , size_t , schar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_sub16u ( const ushort * , size_t , const ushort * , size_t , ushort * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_sub16s ( const short * , size_t , const short * , size_t , short * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_sub32s ( const int * , size_t , const int * , size_t , int * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_sub32f ( const float * , size_t , const float * , size_t , float * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_sub64f ( const double * , size_t , const double * , size_t , double * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_max8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_max8s ( const schar * , size_t , const schar * , size_t , schar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_max16u ( const ushort * , size_t , const ushort * , size_t , ushort * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_max16s ( const short * , size_t , const short * , size_t , short * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_max32s ( const int * , size_t , const int * , size_t , int * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_max32f ( const float * , size_t , const float * , size_t , float * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_max64f ( const double * , size_t , const double * , size_t , double * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_min8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_min8s ( const schar * , size_t , const schar * , size_t , schar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_min16u ( const ushort * , size_t , const ushort * , size_t , ushort * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_min16s ( const short * , size_t , const short * , size_t , short * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_min32s ( const int * , size_t , const int * , size_t , int * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_min32f ( const float * , size_t , const float * , size_t , float * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_min64f ( const double * , size_t , const double * , size_t , double * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_absdiff8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_absdiff8s ( const schar * , size_t , const schar * , size_t , schar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_absdiff16u ( const ushort * , size_t , const ushort * , size_t , ushort * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_absdiff16s ( const short * , size_t , const short * , size_t , short * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_absdiff32s ( const int * , size_t , const int * , size_t , int * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_absdiff32f ( const float * , size_t , const float * , size_t , float * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_absdiff64f ( const double * , size_t , const double * , size_t , double * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_and8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_or8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_xor8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_not8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + <nl> + # define hal_add8u hal_t_add8u <nl> + # define hal_add8s hal_t_add8s <nl> + # define hal_add16u hal_t_add16u <nl> + # define hal_add16s hal_t_add16s <nl> + # define hal_add32s hal_t_add32s <nl> + # define hal_add32f hal_t_add32f <nl> + # define hal_add64f hal_t_add64f <nl> + # define hal_sub8u hal_t_sub8u <nl> + # define hal_sub8s hal_t_sub8s <nl> + # define hal_sub16u hal_t_sub16u <nl> + # define hal_sub16s hal_t_sub16s <nl> + # define hal_sub32s hal_t_sub32s <nl> + # define hal_sub32f hal_t_sub32f <nl> + # define hal_sub64f hal_t_sub64f <nl> + # define hal_max8u hal_t_max8u <nl> + # define hal_max8s hal_t_max8s <nl> + # define hal_max16u hal_t_max16u <nl> + # define hal_max16s hal_t_max16s <nl> + # define hal_max32s hal_t_max32s <nl> + # define hal_max32f hal_t_max32f <nl> + # define hal_max64f hal_t_max64f <nl> + # define hal_min8u hal_t_min8u <nl> + # define hal_min8s hal_t_min8s <nl> + # define hal_min16u hal_t_min16u <nl> + # define hal_min16s hal_t_min16s <nl> + # define hal_min32s hal_t_min32s <nl> + # define hal_min32f hal_t_min32f <nl> + # define hal_min64f hal_t_min64f <nl> + # define hal_absdiff8u hal_t_absdiff8u <nl> + # define hal_absdiff8s hal_t_absdiff8s <nl> + # define hal_absdiff16u hal_t_absdiff16u <nl> + # define hal_absdiff16s hal_t_absdiff16s <nl> + # define hal_absdiff32s hal_t_absdiff32s <nl> + # define hal_absdiff32f hal_t_absdiff32f <nl> + # define hal_absdiff64f hal_t_absdiff64f <nl> + # define hal_and8u hal_t_and8u <nl> + # define hal_or8u hal_t_or8u <nl> + # define hal_xor8u hal_t_xor8u <nl> + # define hal_not8u hal_t_not8u <nl> + <nl> + inline int hal_t_cmp8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_cmp8s ( const schar * , size_t , const schar * , size_t , uchar * , size_t , int , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_cmp16u ( const ushort * , size_t , const ushort * , size_t , uchar * , size_t , int , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_cmp16s ( const short * , size_t , const short * , size_t , uchar * , size_t , int , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_cmp32s ( const int * , size_t , const int * , size_t , uchar * , size_t , int , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_cmp32f ( const float * , size_t , const float * , size_t , uchar * , size_t , int , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_cmp64f ( const double * , size_t , const double * , size_t , uchar * , size_t , int , int , int ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + <nl> + # define hal_cmp8u hal_t_cmp8u <nl> + # define hal_cmp8s hal_t_cmp8s <nl> + # define hal_cmp16u hal_t_cmp16u <nl> + # define hal_cmp16s hal_t_cmp16s <nl> + # define hal_cmp32s hal_t_cmp32s <nl> + # define hal_cmp32f hal_t_cmp32f <nl> + # define hal_cmp64f hal_t_cmp64f <nl> + <nl> + inline int hal_t_mul8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_mul8s ( const schar * , size_t , const schar * , size_t , schar * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_mul16u ( const ushort * , size_t , const ushort * , size_t , ushort * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_mul16s ( const short * , size_t , const short * , size_t , short * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_mul32s ( const int * , size_t , const int * , size_t , int * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_mul32f ( const float * , size_t , const float * , size_t , float * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_mul64f ( const double * , size_t , const double * , size_t , double * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_div8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_div8s ( const schar * , size_t , const schar * , size_t , schar * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_div16u ( const ushort * , size_t , const ushort * , size_t , ushort * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_div16s ( const short * , size_t , const short * , size_t , short * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_div32s ( const int * , size_t , const int * , size_t , int * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_div32f ( const float * , size_t , const float * , size_t , float * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_div64f ( const double * , size_t , const double * , size_t , double * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_recip8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_recip8s ( const schar * , size_t , const schar * , size_t , schar * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_recip16u ( const ushort * , size_t , const ushort * , size_t , ushort * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_recip16s ( const short * , size_t , const short * , size_t , short * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_recip32s ( const int * , size_t , const int * , size_t , int * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_recip32f ( const float * , size_t , const float * , size_t , float * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_recip64f ( const double * , size_t , const double * , size_t , double * , size_t , int , int , double ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + <nl> + # define hal_mul8u hal_t_mul8u <nl> + # define hal_mul8s hal_t_mul8s <nl> + # define hal_mul16u hal_t_mul16u <nl> + # define hal_mul16s hal_t_mul16s <nl> + # define hal_mul32s hal_t_mul32s <nl> + # define hal_mul32f hal_t_mul32f <nl> + # define hal_mul64f hal_t_mul64f <nl> + # define hal_div8u hal_t_div8u <nl> + # define hal_div8s hal_t_div8s <nl> + # define hal_div16u hal_t_div16u <nl> + # define hal_div16s hal_t_div16s <nl> + # define hal_div32s hal_t_div32s <nl> + # define hal_div32f hal_t_div32f <nl> + # define hal_div64f hal_t_div64f <nl> + # define hal_recip8u hal_t_recip8u <nl> + # define hal_recip8s hal_t_recip8s <nl> + # define hal_recip16u hal_t_recip16u <nl> + # define hal_recip16s hal_t_recip16s <nl> + # define hal_recip32s hal_t_recip32s <nl> + # define hal_recip32f hal_t_recip32f <nl> + # define hal_recip64f hal_t_recip64f <nl> + <nl> + inline int hal_t_addWeighted8u ( const uchar * , size_t , const uchar * , size_t , uchar * , size_t , int , int , void * ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_addWeighted8s ( const schar * , size_t , const schar * , size_t , schar * , size_t , int , int , void * ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_addWeighted16u ( const ushort * , size_t , const ushort * , size_t , ushort * , size_t , int , int , void * ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_addWeighted16s ( const short * , size_t , const short * , size_t , short * , size_t , int , int , void * ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_addWeighted32s ( const int * , size_t , const int * , size_t , int * , size_t , int , int , void * ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_addWeighted32f ( const float * , size_t , const float * , size_t , float * , size_t , int , int , void * ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + inline int hal_t_addWeighted64f ( const double * , size_t , const double * , size_t , double * , size_t , int , int , void * ) { return cv : : hal : : Error : : NotImplemented ; } <nl> + <nl> + # define hal_addWeighted8u hal_t_addWeighted8u <nl> + # define hal_addWeighted8s hal_t_addWeighted8s <nl> + # define hal_addWeighted16u hal_t_addWeighted16u <nl> + # define hal_addWeighted16s hal_t_addWeighted16s <nl> + # define hal_addWeighted32s hal_t_addWeighted32s <nl> + # define hal_addWeighted32f hal_t_addWeighted32f <nl> + # define hal_addWeighted64f hal_t_addWeighted64f <nl> + <nl> + # include " custom_hal . hpp " <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . c31bf8cc44e <nl> mmm / dev / null <nl> ppp b / modules / hal / src / split . cpp <nl> <nl> + / * M / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / <nl> + / / IMPORTANT : READ BEFORE DOWNLOADING , COPYING , INSTALLING OR USING . <nl> + / / <nl> + / / By downloading , copying , installing or using the software you agree to this license . <nl> + / / If you do not agree to this license , do not download , install , <nl> + / / copy or use the software . <nl> + / / <nl> + / / <nl> + / / License Agreement <nl> + / / For Open Source Computer Vision Library <nl> + / / <nl> + / / Copyright ( C ) 2000 - 2008 , Intel Corporation , all rights reserved . <nl> + / / Copyright ( C ) 2009 - 2011 , Willow Garage Inc . , all rights reserved . <nl> + / / Copyright ( C ) 2014 - 2015 , Itseez Inc . , all rights reserved . <nl> + / / Third party copyrights are property of their respective owners . <nl> + / / <nl> + / / Redistribution and use in source and binary forms , with or without modification , <nl> + / / are permitted provided that the following conditions are met : <nl> + / / <nl> + / / * Redistribution ' s of source code must retain the above copyright notice , <nl> + / / this list of conditions and the following disclaimer . <nl> + / / <nl> + / / * Redistribution ' s in binary form must reproduce the above copyright notice , <nl> + / / this list of conditions and the following disclaimer in the documentation <nl> + / / and / or other materials provided with the distribution . <nl> + / / <nl> + / / * The name of the copyright holders may not be used to endorse or promote products <nl> + / / derived from this software without specific prior written permission . <nl> + / / <nl> + / / This software is provided by the copyright holders and contributors " as is " and <nl> + / / any express or implied warranties , including , but not limited to , the implied <nl> + / / warranties of merchantability and fitness for a particular purpose are disclaimed . <nl> + / / In no event shall the Intel Corporation or contributors be liable for any direct , <nl> + / / indirect , incidental , special , exemplary , or consequential damages <nl> + / / ( including , but not limited to , procurement of substitute goods or services ; <nl> + / / loss of use , data , or profits ; or business interruption ) however caused <nl> + / / and on any theory of liability , whether in contract , strict liability , <nl> + / / or tort ( including negligence or otherwise ) arising in any way out of <nl> + / / the use of this software , even if advised of the possibility of such damage . <nl> + / / <nl> + / / M * / <nl> + <nl> + # include " precomp . hpp " <nl> + <nl> + namespace cv { namespace hal { <nl> + <nl> + # if CV_NEON <nl> + template < typename T > struct VSplit2 ; <nl> + template < typename T > struct VSplit3 ; <nl> + template < typename T > struct VSplit4 ; <nl> + <nl> + # define SPLIT2_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> + template < > \ <nl> + struct name < data_type > \ <nl> + { \ <nl> + void operator ( ) ( const data_type * src , data_type * dst0 , \ <nl> + data_type * dst1 ) const \ <nl> + { \ <nl> + reg_type r = load_func ( src ) ; \ <nl> + store_func ( dst0 , r . val [ 0 ] ) ; \ <nl> + store_func ( dst1 , r . val [ 1 ] ) ; \ <nl> + } \ <nl> + } <nl> + <nl> + # define SPLIT3_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> + template < > \ <nl> + struct name < data_type > \ <nl> + { \ <nl> + void operator ( ) ( const data_type * src , data_type * dst0 , data_type * dst1 , \ <nl> + data_type * dst2 ) const \ <nl> + { \ <nl> + reg_type r = load_func ( src ) ; \ <nl> + store_func ( dst0 , r . val [ 0 ] ) ; \ <nl> + store_func ( dst1 , r . val [ 1 ] ) ; \ <nl> + store_func ( dst2 , r . val [ 2 ] ) ; \ <nl> + } \ <nl> + } <nl> + <nl> + # define SPLIT4_KERNEL_TEMPLATE ( name , data_type , reg_type , load_func , store_func ) \ <nl> + template < > \ <nl> + struct name < data_type > \ <nl> + { \ <nl> + void operator ( ) ( const data_type * src , data_type * dst0 , data_type * dst1 , \ <nl> + data_type * dst2 , data_type * dst3 ) const \ <nl> + { \ <nl> + reg_type r = load_func ( src ) ; \ <nl> + store_func ( dst0 , r . val [ 0 ] ) ; \ <nl> + store_func ( dst1 , r . val [ 1 ] ) ; \ <nl> + store_func ( dst2 , r . val [ 2 ] ) ; \ <nl> + store_func ( dst3 , r . val [ 3 ] ) ; \ <nl> + } \ <nl> + } <nl> + <nl> + SPLIT2_KERNEL_TEMPLATE ( VSplit2 , uchar , uint8x16x2_t , vld2q_u8 , vst1q_u8 ) ; <nl> + SPLIT2_KERNEL_TEMPLATE ( VSplit2 , ushort , uint16x8x2_t , vld2q_u16 , vst1q_u16 ) ; <nl> + SPLIT2_KERNEL_TEMPLATE ( VSplit2 , int , int32x4x2_t , vld2q_s32 , vst1q_s32 ) ; <nl> + SPLIT2_KERNEL_TEMPLATE ( VSplit2 , int64 , int64x1x2_t , vld2_s64 , vst1_s64 ) ; <nl> + <nl> + SPLIT3_KERNEL_TEMPLATE ( VSplit3 , uchar , uint8x16x3_t , vld3q_u8 , vst1q_u8 ) ; <nl> + SPLIT3_KERNEL_TEMPLATE ( VSplit3 , ushort , uint16x8x3_t , vld3q_u16 , vst1q_u16 ) ; <nl> + SPLIT3_KERNEL_TEMPLATE ( VSplit3 , int , int32x4x3_t , vld3q_s32 , vst1q_s32 ) ; <nl> + SPLIT3_KERNEL_TEMPLATE ( VSplit3 , int64 , int64x1x3_t , vld3_s64 , vst1_s64 ) ; <nl> + <nl> + SPLIT4_KERNEL_TEMPLATE ( VSplit4 , uchar , uint8x16x4_t , vld4q_u8 , vst1q_u8 ) ; <nl> + SPLIT4_KERNEL_TEMPLATE ( VSplit4 , ushort , uint16x8x4_t , vld4q_u16 , vst1q_u16 ) ; <nl> + SPLIT4_KERNEL_TEMPLATE ( VSplit4 , int , int32x4x4_t , vld4q_s32 , vst1q_s32 ) ; <nl> + SPLIT4_KERNEL_TEMPLATE ( VSplit4 , int64 , int64x1x4_t , vld4_s64 , vst1_s64 ) ; <nl> + <nl> + # elif CV_SSE2 <nl> + <nl> + template < typename T > <nl> + struct VSplit2 <nl> + { <nl> + VSplit2 ( ) : support ( false ) { } <nl> + void operator ( ) ( const T * , T * , T * ) const { } <nl> + <nl> + bool support ; <nl> + } ; <nl> + <nl> + template < typename T > <nl> + struct VSplit3 <nl> + { <nl> + VSplit3 ( ) : support ( false ) { } <nl> + void operator ( ) ( const T * , T * , T * , T * ) const { } <nl> + <nl> + bool support ; <nl> + } ; <nl> + <nl> + template < typename T > <nl> + struct VSplit4 <nl> + { <nl> + VSplit4 ( ) : support ( false ) { } <nl> + void operator ( ) ( const T * , T * , T * , T * , T * ) const { } <nl> + <nl> + bool support ; <nl> + } ; <nl> + <nl> + # define SPLIT2_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_deinterleave , flavor ) \ <nl> + template < > \ <nl> + struct VSplit2 < data_type > \ <nl> + { \ <nl> + enum \ <nl> + { \ <nl> + ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> + } ; \ <nl> + \ <nl> + VSplit2 ( ) \ <nl> + { \ <nl> + support = checkHardwareSupport ( CV_CPU_SSE2 ) ; \ <nl> + } \ <nl> + \ <nl> + void operator ( ) ( const data_type * src , \ <nl> + data_type * dst0 , data_type * dst1 ) const \ <nl> + { \ <nl> + reg_type v_src0 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src ) ) ; \ <nl> + reg_type v_src1 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC ) ) ; \ <nl> + reg_type v_src2 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 2 ) ) ; \ <nl> + reg_type v_src3 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 3 ) ) ; \ <nl> + \ <nl> + _mm_deinterleave ( v_src0 , v_src1 , v_src2 , v_src3 ) ; \ <nl> + \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 ) , v_src0 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 ) , v_src2 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 + ELEMS_IN_VEC ) , v_src3 ) ; \ <nl> + } \ <nl> + \ <nl> + bool support ; \ <nl> + } <nl> + <nl> + # define SPLIT3_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_deinterleave , flavor ) \ <nl> + template < > \ <nl> + struct VSplit3 < data_type > \ <nl> + { \ <nl> + enum \ <nl> + { \ <nl> + ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> + } ; \ <nl> + \ <nl> + VSplit3 ( ) \ <nl> + { \ <nl> + support = checkHardwareSupport ( CV_CPU_SSE2 ) ; \ <nl> + } \ <nl> + \ <nl> + void operator ( ) ( const data_type * src , \ <nl> + data_type * dst0 , data_type * dst1 , data_type * dst2 ) const \ <nl> + { \ <nl> + reg_type v_src0 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src ) ) ; \ <nl> + reg_type v_src1 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC ) ) ; \ <nl> + reg_type v_src2 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 2 ) ) ; \ <nl> + reg_type v_src3 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 3 ) ) ; \ <nl> + reg_type v_src4 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 4 ) ) ; \ <nl> + reg_type v_src5 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 5 ) ) ; \ <nl> + \ <nl> + _mm_deinterleave ( v_src0 , v_src1 , v_src2 , \ <nl> + v_src3 , v_src4 , v_src5 ) ; \ <nl> + \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 ) , v_src0 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 ) , v_src2 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 + ELEMS_IN_VEC ) , v_src3 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst2 ) , v_src4 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst2 + ELEMS_IN_VEC ) , v_src5 ) ; \ <nl> + } \ <nl> + \ <nl> + bool support ; \ <nl> + } <nl> + <nl> + # define SPLIT4_KERNEL_TEMPLATE ( data_type , reg_type , cast_type , _mm_deinterleave , flavor ) \ <nl> + template < > \ <nl> + struct VSplit4 < data_type > \ <nl> + { \ <nl> + enum \ <nl> + { \ <nl> + ELEMS_IN_VEC = 16 / sizeof ( data_type ) \ <nl> + } ; \ <nl> + \ <nl> + VSplit4 ( ) \ <nl> + { \ <nl> + support = checkHardwareSupport ( CV_CPU_SSE2 ) ; \ <nl> + } \ <nl> + \ <nl> + void operator ( ) ( const data_type * src , data_type * dst0 , data_type * dst1 , \ <nl> + data_type * dst2 , data_type * dst3 ) const \ <nl> + { \ <nl> + reg_type v_src0 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src ) ) ; \ <nl> + reg_type v_src1 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC ) ) ; \ <nl> + reg_type v_src2 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 2 ) ) ; \ <nl> + reg_type v_src3 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 3 ) ) ; \ <nl> + reg_type v_src4 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 4 ) ) ; \ <nl> + reg_type v_src5 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 5 ) ) ; \ <nl> + reg_type v_src6 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 6 ) ) ; \ <nl> + reg_type v_src7 = _mm_loadu_ # # flavor ( ( cast_type const * ) ( src + ELEMS_IN_VEC * 7 ) ) ; \ <nl> + \ <nl> + _mm_deinterleave ( v_src0 , v_src1 , v_src2 , v_src3 , \ <nl> + v_src4 , v_src5 , v_src6 , v_src7 ) ; \ <nl> + \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 ) , v_src0 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst0 + ELEMS_IN_VEC ) , v_src1 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 ) , v_src2 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst1 + ELEMS_IN_VEC ) , v_src3 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst2 ) , v_src4 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst2 + ELEMS_IN_VEC ) , v_src5 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst3 ) , v_src6 ) ; \ <nl> + _mm_storeu_ # # flavor ( ( cast_type * ) ( dst3 + ELEMS_IN_VEC ) , v_src7 ) ; \ <nl> + } \ <nl> + \ <nl> + bool support ; \ <nl> + } <nl> + <nl> + SPLIT2_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_deinterleave_epi8 , si128 ) ; <nl> + SPLIT2_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_deinterleave_epi16 , si128 ) ; <nl> + SPLIT2_KERNEL_TEMPLATE ( int , __m128 , float , _mm_deinterleave_ps , ps ) ; <nl> + <nl> + SPLIT3_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_deinterleave_epi8 , si128 ) ; <nl> + SPLIT3_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_deinterleave_epi16 , si128 ) ; <nl> + SPLIT3_KERNEL_TEMPLATE ( int , __m128 , float , _mm_deinterleave_ps , ps ) ; <nl> + <nl> + SPLIT4_KERNEL_TEMPLATE ( uchar , __m128i , __m128i , _mm_deinterleave_epi8 , si128 ) ; <nl> + SPLIT4_KERNEL_TEMPLATE ( ushort , __m128i , __m128i , _mm_deinterleave_epi16 , si128 ) ; <nl> + SPLIT4_KERNEL_TEMPLATE ( int , __m128 , float , _mm_deinterleave_ps , ps ) ; <nl> + <nl> + # endif <nl> + <nl> + template < typename T > static void <nl> + split_ ( const T * src , T * * dst , int len , int cn ) <nl> + { <nl> + int k = cn % 4 ? cn % 4 : 4 ; <nl> + int i , j ; <nl> + if ( k = = 1 ) <nl> + { <nl> + T * dst0 = dst [ 0 ] ; <nl> + <nl> + if ( cn = = 1 ) <nl> + { <nl> + memcpy ( dst0 , src , len * sizeof ( T ) ) ; <nl> + } <nl> + else <nl> + { <nl> + for ( i = 0 , j = 0 ; i < len ; i + + , j + = cn ) <nl> + dst0 [ i ] = src [ j ] ; <nl> + } <nl> + } <nl> + else if ( k = = 2 ) <nl> + { <nl> + T * dst0 = dst [ 0 ] , * dst1 = dst [ 1 ] ; <nl> + i = j = 0 ; <nl> + <nl> + # if CV_NEON <nl> + if ( cn = = 2 ) <nl> + { <nl> + int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> + int inc_j = 2 * inc_i ; <nl> + <nl> + VSplit2 < T > vsplit ; <nl> + for ( ; i < len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vsplit ( src + j , dst0 + i , dst1 + i ) ; <nl> + } <nl> + # elif CV_SSE2 <nl> + if ( cn = = 2 ) <nl> + { <nl> + int inc_i = 32 / sizeof ( T ) ; <nl> + int inc_j = 2 * inc_i ; <nl> + <nl> + VSplit2 < T > vsplit ; <nl> + if ( vsplit . support ) <nl> + { <nl> + for ( ; i < = len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vsplit ( src + j , dst0 + i , dst1 + i ) ; <nl> + } <nl> + } <nl> + # endif <nl> + for ( ; i < len ; i + + , j + = cn ) <nl> + { <nl> + dst0 [ i ] = src [ j ] ; <nl> + dst1 [ i ] = src [ j + 1 ] ; <nl> + } <nl> + } <nl> + else if ( k = = 3 ) <nl> + { <nl> + T * dst0 = dst [ 0 ] , * dst1 = dst [ 1 ] , * dst2 = dst [ 2 ] ; <nl> + i = j = 0 ; <nl> + <nl> + # if CV_NEON <nl> + if ( cn = = 3 ) <nl> + { <nl> + int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> + int inc_j = 3 * inc_i ; <nl> + <nl> + VSplit3 < T > vsplit ; <nl> + for ( ; i < = len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vsplit ( src + j , dst0 + i , dst1 + i , dst2 + i ) ; <nl> + } <nl> + # elif CV_SSE2 <nl> + if ( cn = = 3 ) <nl> + { <nl> + int inc_i = 32 / sizeof ( T ) ; <nl> + int inc_j = 3 * inc_i ; <nl> + <nl> + VSplit3 < T > vsplit ; <nl> + <nl> + if ( vsplit . support ) <nl> + { <nl> + for ( ; i < = len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vsplit ( src + j , dst0 + i , dst1 + i , dst2 + i ) ; <nl> + } <nl> + } <nl> + # endif <nl> + for ( ; i < len ; i + + , j + = cn ) <nl> + { <nl> + dst0 [ i ] = src [ j ] ; <nl> + dst1 [ i ] = src [ j + 1 ] ; <nl> + dst2 [ i ] = src [ j + 2 ] ; <nl> + } <nl> + } <nl> + else <nl> + { <nl> + T * dst0 = dst [ 0 ] , * dst1 = dst [ 1 ] , * dst2 = dst [ 2 ] , * dst3 = dst [ 3 ] ; <nl> + i = j = 0 ; <nl> + <nl> + # if CV_NEON <nl> + if ( cn = = 4 ) <nl> + { <nl> + int inc_i = ( sizeof ( T ) = = 8 ) ? 1 : 16 / sizeof ( T ) ; <nl> + int inc_j = 4 * inc_i ; <nl> + <nl> + VSplit4 < T > vsplit ; <nl> + for ( ; i < = len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vsplit ( src + j , dst0 + i , dst1 + i , dst2 + i , dst3 + i ) ; <nl> + } <nl> + # elif CV_SSE2 <nl> + if ( cn = = 4 ) <nl> + { <nl> + int inc_i = 32 / sizeof ( T ) ; <nl> + int inc_j = 4 * inc_i ; <nl> + <nl> + VSplit4 < T > vsplit ; <nl> + if ( vsplit . support ) <nl> + { <nl> + for ( ; i < = len - inc_i ; i + = inc_i , j + = inc_j ) <nl> + vsplit ( src + j , dst0 + i , dst1 + i , dst2 + i , dst3 + i ) ; <nl> + } <nl> + } <nl> + # endif <nl> + for ( ; i < len ; i + + , j + = cn ) <nl> + { <nl> + dst0 [ i ] = src [ j ] ; dst1 [ i ] = src [ j + 1 ] ; <nl> + dst2 [ i ] = src [ j + 2 ] ; dst3 [ i ] = src [ j + 3 ] ; <nl> + } <nl> + } <nl> + <nl> + for ( ; k < cn ; k + = 4 ) <nl> + { <nl> + T * dst0 = dst [ k ] , * dst1 = dst [ k + 1 ] , * dst2 = dst [ k + 2 ] , * dst3 = dst [ k + 3 ] ; <nl> + for ( i = 0 , j = k ; i < len ; i + + , j + = cn ) <nl> + { <nl> + dst0 [ i ] = src [ j ] ; dst1 [ i ] = src [ j + 1 ] ; <nl> + dst2 [ i ] = src [ j + 2 ] ; dst3 [ i ] = src [ j + 3 ] ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void split8u ( const uchar * src , uchar * * dst , int len , int cn ) <nl> + { <nl> + split_ ( src , dst , len , cn ) ; <nl> + } <nl> + <nl> + void split16u ( const ushort * src , ushort * * dst , int len , int cn ) <nl> + { <nl> + split_ ( src , dst , len , cn ) ; <nl> + } <nl> + <nl> + void split32s ( const int * src , int * * dst , int len , int cn ) <nl> + { <nl> + split_ ( src , dst , len , cn ) ; <nl> + } <nl> + <nl> + void split64s ( const int64 * src , int64 * * dst , int len , int cn ) <nl> + { <nl> + split_ ( src , dst , len , cn ) ; <nl> + } <nl> + <nl> + } } <nl> mmm a / modules / imgproc / src / precomp . hpp <nl> ppp b / modules / imgproc / src / precomp . hpp <nl> extern const float icv8x32fSqrTab [ ] ; <nl> # include " _geom . h " <nl> # include " filterengine . hpp " <nl> <nl> + # include " opencv2 / hal / sse_utils . hpp " <nl> + <nl> # endif / * __OPENCV_CV_INTERNAL_H_ * / <nl>
|
Merge pull request from mshabunin : hal_extend
|
opencv/opencv
|
54c1637ba15fc62f7e3e9544aafd2341cf1cfa74
|
2015-12-07T10:01:22Z
|
mmm a / . gitignore <nl> ppp b / . gitignore <nl> local . properties <nl> # Ignore python compiled files <nl> * . pyc <nl> <nl> - # Ignore files build by airplay <nl> + # Ignore files build by airplay and marmalade <nl> build_ * _xcode / <nl> + build_ * _vc10 / <nl> <nl> # Ignore files build by xcode <nl> * . mode * v * <nl>
|
ignore marmalade vs10 project directories
|
cocos2d/cocos2d-x
|
ec72d16276c173015826358931e3be3170131f4b
|
2012-12-02T14:10:38Z
|
mmm a / stdlib / public / core / Index . swift <nl> ppp b / stdlib / public / core / Index . swift <nl> public func ~ > < T : BidirectionalIndexType > ( <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / = = = mmm RandomAccessIndexType mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> - / / / This protocol is an implementation detail of ` RandomAccessIndexType ` ; do <nl> - / / / not use it directly . <nl> - / / / <nl> - / / / Its requirements are inherited by ` RandomAccessIndexType ` and thus must <nl> - / / / be satisfied by types conforming to that protocol . <nl> - public protocol _RandomAccessIndexType : BidirectionalIndexType , Strideable { <nl> + <nl> + / / / An * index * that can be offset by an arbitrary number of positions , <nl> + / / / and can measure the distance to any reachable value , in O ( 1 ) . <nl> + public protocol RandomAccessIndexType : BidirectionalIndexType , Strideable { <nl> / / / Return the minimum number of applications of ` successor ` or <nl> / / / ` predecessor ` required to reach ` other ` from ` self ` . <nl> / / / <nl> public protocol _RandomAccessIndexType : BidirectionalIndexType , Strideable { <nl> func advancedBy ( n : Distance ) - > Self <nl> } <nl> <nl> - / / / An * index * that can be offset by an arbitrary number of positions , <nl> - / / / and can measure the distance to any reachable value , in O ( 1 ) . <nl> - public protocol RandomAccessIndexType <nl> - : BidirectionalIndexType , _RandomAccessIndexType { <nl> - / * typealias Distance : IntegerArithmeticType * / <nl> - } <nl> - <nl> / / advance and distance implementations <nl> <nl> / / / Do not use this operator directly ; call distance ( start , end ) instead . <nl> @ transparent <nl> - public func ~ > < T : _RandomAccessIndexType > ( start : T , rest : ( _Distance , ( T ) ) ) <nl> + public func ~ > < T : RandomAccessIndexType > ( start : T , rest : ( _Distance , ( T ) ) ) <nl> - > T . Distance { <nl> let end = rest . 1 <nl> return start . distanceTo ( end ) <nl> public func ~ > < T : _RandomAccessIndexType > ( start : T , rest : ( _Distance , ( T ) ) ) <nl> <nl> / / / Do not use this operator directly ; call advance ( start , n ) instead . <nl> @ transparent <nl> - public func ~ > < T : _RandomAccessIndexType > ( <nl> + public func ~ > < T : RandomAccessIndexType > ( <nl> start : T , rest : ( _Advance , ( T . Distance ) ) <nl> ) - > T { <nl> let n = rest . 1 <nl> public func ~ > < T : _RandomAccessIndexType > ( <nl> <nl> / / / Do not use this operator directly ; call advance ( start , n , end ) instead . <nl> @ transparent <nl> - public func ~ > < T : _RandomAccessIndexType > ( <nl> + public func ~ > < T : RandomAccessIndexType > ( <nl> start : T , rest : ( _Advance , ( T . Distance , T ) ) <nl> ) - > T { <nl> let n = rest . 1 . 0 <nl>
|
[ stdlib ] Kill _RandomAccessIndexType
|
apple/swift
|
f56efcbe6744a20995d960e86d1ac28dafdf0714
|
2015-05-23T18:52:24Z
|
mmm a / tensorflow / contrib / lite / delegates / eager / delegate_test . cc <nl> ppp b / tensorflow / contrib / lite / delegates / eager / delegate_test . cc <nl> TEST_F ( DelegateTest , FullGraph ) { <nl> <nl> ASSERT_THAT ( GetShape ( 8 ) , ElementsAre ( 2 , 1 ) ) ; <nl> ASSERT_THAT ( GetValues ( 8 ) , ElementsAre ( 14 . 52f , 38 . 72f ) ) ; <nl> + ASSERT_EQ ( GetType ( 8 ) , kTfLiteFloat32 ) ; <nl> + } <nl> + <nl> + TEST_F ( DelegateTest , NonFloatTypeInference ) { <nl> + AddTensors ( 3 , { 0 , 1 } , { 2 } , kTfLiteInt32 , { 2 } ) ; <nl> + <nl> + AddTfOp ( testing : : kAdd , { 0 , 1 } , { 2 } ) ; <nl> + <nl> + ConfigureDelegate ( ) ; <nl> + <nl> + SetShape ( 0 , { 2 , 2 } ) ; <nl> + SetTypedValues < int > ( 0 , { 1 , 2 , 3 , 4 } ) ; <nl> + SetShape ( 1 , { 2 , 2 } ) ; <nl> + SetTypedValues < int > ( 1 , { 4 , 3 , 2 , 1 } ) ; <nl> + <nl> + ASSERT_TRUE ( Invoke ( ) ) ; <nl> + <nl> + ASSERT_THAT ( GetShape ( 2 ) , ElementsAre ( 2 , 2 ) ) ; <nl> + ASSERT_THAT ( GetTypedValues < int > ( 2 ) , ElementsAre ( 5 , 5 , 5 , 5 ) ) ; <nl> + ASSERT_EQ ( GetType ( 2 ) , kTfLiteInt32 ) ; <nl> } <nl> <nl> TEST_F ( DelegateTest , MixedGraph ) { <nl> mmm a / tensorflow / contrib / lite / delegates / eager / kernel . cc <nl> ppp b / tensorflow / contrib / lite / delegates / eager / kernel . cc <nl> TfLiteStatus Eval ( TfLiteContext * context , TfLiteNode * node ) { <nl> TfLiteTensor * tensor = & context - > tensors [ tensor_index ] ; <nl> TF_LITE_ENSURE_OK ( <nl> context , <nl> - CopyShape ( context , buffer_map - > GetTensor ( tensor_index ) , tensor ) ) ; <nl> + CopyShapeAndType ( context , buffer_map - > GetTensor ( tensor_index ) , tensor ) ) ; <nl> tensor - > buffer_handle = tensor_index ; <nl> tensor - > data_is_stale = true ; <nl> } <nl> mmm a / tensorflow / contrib / lite / delegates / eager / test_util . cc <nl> ppp b / tensorflow / contrib / lite / delegates / eager / test_util . cc <nl> namespace testing { <nl> <nl> bool EagerModelTest : : Invoke ( ) { return interpreter_ - > Invoke ( ) = = kTfLiteOk ; } <nl> <nl> - void EagerModelTest : : SetValues ( int tensor_index , <nl> - const std : : vector < float > & values ) { <nl> - float * v = interpreter_ - > typed_tensor < float > ( tensor_index ) ; <nl> - for ( float f : values ) { <nl> - * v + + = f ; <nl> - } <nl> - } <nl> - <nl> - std : : vector < float > EagerModelTest : : GetValues ( int tensor_index ) { <nl> - TfLiteTensor * o = interpreter_ - > tensor ( tensor_index ) ; <nl> - return std : : vector < float > ( o - > data . f , o - > data . f + o - > bytes / sizeof ( float ) ) ; <nl> - } <nl> - <nl> void EagerModelTest : : SetShape ( int tensor_index , <nl> const std : : vector < int > & values ) { <nl> ASSERT_EQ ( interpreter_ - > ResizeInputTensor ( tensor_index , values ) , kTfLiteOk ) ; <nl> std : : vector < int > EagerModelTest : : GetShape ( int tensor_index ) { <nl> return result ; <nl> } <nl> <nl> + TfLiteType EagerModelTest : : GetType ( int tensor_index ) { <nl> + return interpreter_ - > tensor ( tensor_index ) - > type ; <nl> + } <nl> + <nl> void EagerModelTest : : AddTensors ( int num_tensors , const std : : vector < int > & inputs , <nl> const std : : vector < int > & outputs , <nl> - const TfLiteType & type , <nl> - const std : : vector < int > & dims ) { <nl> + TfLiteType type , const std : : vector < int > & dims ) { <nl> interpreter_ - > AddTensors ( num_tensors ) ; <nl> for ( int i = 0 ; i < num_tensors ; + + i ) { <nl> TfLiteQuantizationParams quant ; <nl> + / / Suppress explicit output type specification to ensure type inference <nl> + / / works properly . <nl> + if ( std : : find ( outputs . begin ( ) , outputs . end ( ) , i ) ! = outputs . end ( ) ) { <nl> + type = kTfLiteFloat32 ; <nl> + } <nl> CHECK_EQ ( interpreter_ - > SetTensorParametersReadWrite ( i , type , <nl> / * name = * / " " , <nl> / * dims = * / dims , quant ) , <nl> void EagerModelTest : : AddTfOp ( TfOpType op , const std : : vector < int > & inputs , <nl> return " attr { key : ' " + key + " ' value { " + value + " } } " ; <nl> } ; <nl> <nl> + / / Crude type attribution , will need fleshing out as more tests are added . <nl> + / / TODO ( b / 113613439 ) : Use nodedef string utilities to properly handle <nl> + / / all types . <nl> + string type_attribute = attr ( " T " , " type : DT_FLOAT " ) ; <nl> + if ( interpreter_ - > tensor ( inputs [ 0 ] ) - > type = = kTfLiteInt32 ) { <nl> + type_attribute = attr ( " T " , " type : DT_INT32 " ) ; <nl> + } <nl> + <nl> if ( op = = kUnpack ) { <nl> - string attributes = attr ( " T " , " type : DT_FLOAT " ) + attr ( " num " , " i : 2 " ) + <nl> - attr ( " axis " , " i : 0 " ) ; <nl> + string attributes = <nl> + type_attribute + attr ( " num " , " i : 2 " ) + attr ( " axis " , " i : 0 " ) ; <nl> AddTfOp ( " EagerUnpack " , " Unpack " , attributes , inputs , outputs ) ; <nl> } else if ( op = = kIdentity ) { <nl> - string attributes = attr ( " T " , " type : DT_FLOAT " ) ; <nl> + string attributes = type_attribute ; <nl> AddTfOp ( " EagerIdentity " , " Identity " , attributes , inputs , outputs ) ; <nl> } else if ( op = = kAdd ) { <nl> - string attributes = attr ( " T " , " type : DT_FLOAT " ) ; <nl> + string attributes = type_attribute ; <nl> AddTfOp ( " EagerAdd " , " Add " , attributes , inputs , outputs ) ; <nl> } else if ( op = = kMul ) { <nl> - string attributes = attr ( " T " , " type : DT_FLOAT " ) ; <nl> + string attributes = type_attribute ; <nl> AddTfOp ( " EagerMul " , " Mul " , attributes , inputs , outputs ) ; <nl> } else if ( op = = kNonExistent ) { <nl> AddTfOp ( " NonExistentOp " , " NonExistentOp " , " " , inputs , outputs ) ; <nl> mmm a / tensorflow / contrib / lite / delegates / eager / test_util . h <nl> ppp b / tensorflow / contrib / lite / delegates / eager / test_util . h <nl> class EagerModelTest : public : : testing : : Test { <nl> <nl> bool Invoke ( ) ; <nl> <nl> + / / Sets the ( typed ) tensor ' s values at the given index . <nl> + template < typename T > <nl> + void SetTypedValues ( int tensor_index , const std : : vector < T > & values ) { <nl> + memcpy ( interpreter_ - > typed_tensor < T > ( tensor_index ) , values . data ( ) , <nl> + values . size ( ) * sizeof ( T ) ) ; <nl> + } <nl> + <nl> + / / Returns the ( typed ) tensor ' s values at the given index . <nl> + template < typename T > <nl> + std : : vector < T > GetTypedValues ( int tensor_index ) { <nl> + const TfLiteTensor * t = interpreter_ - > tensor ( tensor_index ) ; <nl> + const T * tdata = interpreter_ - > typed_tensor < T > ( tensor_index ) ; <nl> + return std : : vector < T > ( tdata , tdata + t - > bytes / sizeof ( T ) ) ; <nl> + } <nl> + <nl> / / Sets the tensor ' s values at the given index . <nl> - void SetValues ( int tensor_index , const std : : vector < float > & values ) ; <nl> + void SetValues ( int tensor_index , const std : : vector < float > & values ) { <nl> + SetTypedValues < float > ( tensor_index , values ) ; <nl> + } <nl> <nl> / / Returns the tensor ' s values at the given index . <nl> - std : : vector < float > GetValues ( int tensor_index ) ; <nl> + std : : vector < float > GetValues ( int tensor_index ) { <nl> + return GetTypedValues < float > ( tensor_index ) ; <nl> + } <nl> <nl> / / Sets the tensor ' s shape at the given index . <nl> void SetShape ( int tensor_index , const std : : vector < int > & values ) ; <nl> class EagerModelTest : public : : testing : : Test { <nl> / / Returns the tensor ' s shape at the given index . <nl> std : : vector < int > GetShape ( int tensor_index ) ; <nl> <nl> + / / Returns the tensor ' s type at the given index . <nl> + TfLiteType GetType ( int tensor_index ) ; <nl> + <nl> const TestErrorReporter & error_reporter ( ) const { return error_reporter_ ; } <nl> <nl> / / Adds ` num_tensor ` tensors to the model . ` inputs ` contains the indices of <nl> / / the input tensors and ` outputs ` contains the indices of the output <nl> / / tensors . All tensors are set to have ` type ` and ` dims ` . <nl> void AddTensors ( int num_tensors , const std : : vector < int > & inputs , <nl> - const std : : vector < int > & outputs , const TfLiteType & type , <nl> + const std : : vector < int > & outputs , TfLiteType type , <nl> const std : : vector < int > & dims ) ; <nl> <nl> / / Adds a TFLite Mul op . ` inputs ` contains the indices of the input tensors <nl> mmm a / tensorflow / contrib / lite / delegates / eager / util . cc <nl> ppp b / tensorflow / contrib / lite / delegates / eager / util . cc <nl> TfLiteStatus ConvertStatus ( TfLiteContext * context , <nl> return kTfLiteOk ; <nl> } <nl> <nl> - TfLiteStatus CopyShape ( TfLiteContext * context , const tensorflow : : Tensor & src , <nl> - TfLiteTensor * tensor ) { <nl> + TfLiteStatus CopyShapeAndType ( TfLiteContext * context , <nl> + const tensorflow : : Tensor & src , <nl> + TfLiteTensor * tensor ) { <nl> + tensor - > type = GetTensorFlowLiteType ( static_cast < TF_DataType > ( src . dtype ( ) ) ) ; <nl> + if ( tensor - > type = = kTfLiteNoType ) { <nl> + context - > ReportError ( context , <nl> + " TF Lite does not support TensorFlow data type : % s " , <nl> + DataTypeString ( src . dtype ( ) ) . c_str ( ) ) ; <nl> + return kTfLiteError ; <nl> + } <nl> + <nl> int num_dims = src . dims ( ) ; <nl> TfLiteIntArray * shape = TfLiteIntArrayCreate ( num_dims ) ; <nl> for ( int j = 0 ; j < num_dims ; + + j ) { <nl> TF_DataType GetTensorFlowDataType ( TfLiteType type ) { <nl> } <nl> } <nl> <nl> + TfLiteType GetTensorFlowLiteType ( TF_DataType type ) { <nl> + switch ( type ) { <nl> + case TF_FLOAT : <nl> + return kTfLiteFloat32 ; <nl> + case TF_INT16 : <nl> + return kTfLiteInt16 ; <nl> + case TF_INT32 : <nl> + return kTfLiteInt32 ; <nl> + case TF_UINT8 : <nl> + return kTfLiteUInt8 ; <nl> + case TF_INT64 : <nl> + return kTfLiteInt64 ; <nl> + case TF_COMPLEX64 : <nl> + return kTfLiteComplex64 ; <nl> + case TF_STRING : <nl> + return kTfLiteString ; <nl> + case TF_BOOL : <nl> + return kTfLiteBool ; <nl> + default : <nl> + return kTfLiteNoType ; <nl> + } <nl> + } <nl> + <nl> } / / namespace eager <nl> } / / namespace tflite <nl> mmm a / tensorflow / contrib / lite / delegates / eager / util . h <nl> ppp b / tensorflow / contrib / lite / delegates / eager / util . h <nl> namespace eager { <nl> TfLiteStatus ConvertStatus ( TfLiteContext * context , <nl> const tensorflow : : Status & status ) ; <nl> <nl> - / / Copies the given shape of the given ' src ' into a TF Lite ' tensor ' . Logs an <nl> - / / error and returns kTfLiteError if the shape can ' t be converted . <nl> - TfLiteStatus CopyShape ( TfLiteContext * context , const tensorflow : : Tensor & src , <nl> - TfLiteTensor * tensor ) ; <nl> + / / Copies the given shape and type of the TensorFlow ' src ' tensor into a TF Lite <nl> + / / ' tensor ' . Logs an error and returns kTfLiteError if the shape or type can ' t <nl> + / / be converted . <nl> + TfLiteStatus CopyShapeAndType ( TfLiteContext * context , <nl> + const tensorflow : : Tensor & src , <nl> + TfLiteTensor * tensor ) ; <nl> <nl> / / Returns the TF C API Data type that corresponds to the given TfLiteType . <nl> TF_DataType GetTensorFlowDataType ( TfLiteType type ) ; <nl> <nl> + / / Returns the TfLiteType that corresponds to the given TF C API Data type . <nl> + TfLiteType GetTensorFlowLiteType ( TF_DataType ) ; <nl> + <nl> } / / namespace eager <nl> } / / namespace tflite <nl> <nl> mmm a / tensorflow / contrib / lite / delegates / eager / util_test . cc <nl> ppp b / tensorflow / contrib / lite / delegates / eager / util_test . cc <nl> namespace eager { <nl> namespace { <nl> <nl> using tensorflow : : DT_FLOAT ; <nl> + using tensorflow : : DT_INT32 ; <nl> using tensorflow : : Tensor ; <nl> using : : testing : : ElementsAre ; <nl> <nl> TEST ( UtilTest , ConvertStatus ) { <nl> EXPECT_TRUE ( context . error . empty ( ) ) ; <nl> } <nl> <nl> - TEST ( UtilTest , CopyShape ) { <nl> + TEST ( UtilTest , CopyShapeAndType ) { <nl> TestContext context ; <nl> context . ReportError = ReportError ; <nl> context . ResizeTensor = ResizeTensor ; <nl> <nl> TfLiteTensor dst ; <nl> <nl> - EXPECT_EQ ( CopyShape ( & context , Tensor ( ) , & dst ) , kTfLiteOk ) ; <nl> + EXPECT_EQ ( CopyShapeAndType ( & context , Tensor ( ) , & dst ) , kTfLiteOk ) ; <nl> EXPECT_THAT ( context . new_size , ElementsAre ( 0 ) ) ; <nl> + EXPECT_EQ ( dst . type , kTfLiteFloat32 ) ; <nl> <nl> - EXPECT_EQ ( CopyShape ( & context , Tensor ( DT_FLOAT , { 1 , 2 } ) , & dst ) , kTfLiteOk ) ; <nl> + EXPECT_EQ ( CopyShapeAndType ( & context , Tensor ( DT_FLOAT , { 1 , 2 } ) , & dst ) , <nl> + kTfLiteOk ) ; <nl> EXPECT_THAT ( context . new_size , ElementsAre ( 1 , 2 ) ) ; <nl> + EXPECT_EQ ( dst . type , kTfLiteFloat32 ) ; <nl> <nl> - EXPECT_EQ ( CopyShape ( & context , Tensor ( DT_FLOAT , { 1LL < < 44 , 2 } ) , & dst ) , <nl> + EXPECT_EQ ( CopyShapeAndType ( & context , Tensor ( DT_INT32 , { 1 , 2 } ) , & dst ) , <nl> + kTfLiteOk ) ; <nl> + EXPECT_THAT ( context . new_size , ElementsAre ( 1 , 2 ) ) ; <nl> + EXPECT_EQ ( dst . type , kTfLiteInt32 ) ; <nl> + <nl> + EXPECT_EQ ( CopyShapeAndType ( & context , Tensor ( DT_FLOAT , { 1LL < < 44 , 2 } ) , & dst ) , <nl> kTfLiteError ) ; <nl> EXPECT_EQ ( context . error , <nl> " Dimension value in TensorFlow shape is larger than supported by " <nl> " TF Lite " ) ; <nl> + <nl> + EXPECT_EQ ( <nl> + CopyShapeAndType ( & context , Tensor ( tensorflow : : DT_HALF , { 1 , 2 } ) , & dst ) , <nl> + kTfLiteError ) ; <nl> + EXPECT_EQ ( context . error , <nl> + " TF Lite does not support TensorFlow data type : half " ) ; <nl> } <nl> <nl> - TEST ( UtilTest , TypeConversions ) { <nl> + TEST ( UtilTest , TypeConversionsFromTFLite ) { <nl> EXPECT_EQ ( TF_FLOAT , GetTensorFlowDataType ( kTfLiteNoType ) ) ; <nl> EXPECT_EQ ( TF_FLOAT , GetTensorFlowDataType ( kTfLiteFloat32 ) ) ; <nl> EXPECT_EQ ( TF_INT16 , GetTensorFlowDataType ( kTfLiteInt16 ) ) ; <nl> TEST ( UtilTest , TypeConversions ) { <nl> EXPECT_EQ ( TF_BOOL , GetTensorFlowDataType ( kTfLiteBool ) ) ; <nl> } <nl> <nl> + TEST ( UtilTest , TypeConversionsFromTensorFlow ) { <nl> + EXPECT_EQ ( kTfLiteFloat32 , GetTensorFlowLiteType ( TF_FLOAT ) ) ; <nl> + EXPECT_EQ ( kTfLiteInt16 , GetTensorFlowLiteType ( TF_INT16 ) ) ; <nl> + EXPECT_EQ ( kTfLiteInt32 , GetTensorFlowLiteType ( TF_INT32 ) ) ; <nl> + EXPECT_EQ ( kTfLiteUInt8 , GetTensorFlowLiteType ( TF_UINT8 ) ) ; <nl> + EXPECT_EQ ( kTfLiteInt64 , GetTensorFlowLiteType ( TF_INT64 ) ) ; <nl> + EXPECT_EQ ( kTfLiteComplex64 , GetTensorFlowLiteType ( TF_COMPLEX64 ) ) ; <nl> + EXPECT_EQ ( kTfLiteString , GetTensorFlowLiteType ( TF_STRING ) ) ; <nl> + EXPECT_EQ ( kTfLiteBool , GetTensorFlowLiteType ( TF_BOOL ) ) ; <nl> + EXPECT_EQ ( kTfLiteNoType , GetTensorFlowLiteType ( TF_RESOURCE ) ) ; <nl> + EXPECT_EQ ( kTfLiteNoType , GetTensorFlowLiteType ( TF_VARIANT ) ) ; <nl> + } <nl> + <nl> } / / namespace <nl> } / / namespace eager <nl> } / / namespace tflite <nl>
|
Propagate eager output tensor types in TFLite
|
tensorflow/tensorflow
|
7dfc0756439aede05ec471193780a4de9f61874e
|
2018-09-05T23:43:49Z
|
new file mode 100644 <nl> index 000000000 . . 09aa2b383 <nl> Binary files / dev / null and b / doc / images / callback_events . png differ <nl> mmm a / src / json . hpp <nl> ppp b / src / json . hpp <nl> class basic_json <nl> This enumeration collects the different JSON types . It is internally used <nl> to distinguish the stored values , and the functions @ ref is_null ( ) , @ ref <nl> is_object ( ) , @ ref is_array ( ) , @ ref is_string ( ) , @ ref is_boolean ( ) , @ ref <nl> - is_number ( ) , and @ ref is_discarded ( ) rely on it . <nl> + is_number ( ) ( with @ ref is_number_integer ( ) , @ ref is_number_unsigned ( ) , and <nl> + @ ref is_number_float ( ) ) , @ ref is_discarded ( ) , @ ref is_primitive ( ) , and <nl> + @ ref is_structured ( ) rely on it . <nl> + <nl> + @ note There are three enumeration entries ( number_integer , <nl> + number_unsigned , and number_float ) , because the library distinguishes <nl> + these three types for numbers : @ ref number_unsigned_t is used for unsigned <nl> + integers , @ ref number_integer_t is used for signed integers , and @ ref <nl> + number_float_t is used for floating - point numbers or to approximate <nl> + integers which do not fit in the limits of their respective type . <nl> + <nl> + @ sa @ ref basic_json ( const value_t value_type ) - - create a JSON value with <nl> + the default value for a given type <nl> <nl> @ since version 1 . 0 . 0 <nl> * / <nl> class basic_json <nl> array , / / / < array ( ordered collection of values ) <nl> string , / / / < string value <nl> boolean , / / / < boolean value <nl> - number_integer , / / / < number value ( integer ) <nl> + number_integer , / / / < number value ( signed integer ) <nl> number_unsigned , / / / < number value ( unsigned integer ) <nl> number_float , / / / < number value ( floating - point ) <nl> discarded / / / < discarded by the the parser callback function <nl> class basic_json <nl> / * ! <nl> @ brief a JSON value <nl> <nl> - The actual storage for a JSON value of the @ ref basic_json class . <nl> + The actual storage for a JSON value of the @ ref basic_json class . This <nl> + union combines the different storage types for the JSON value types <nl> + defined in @ ref value_t . <nl> + <nl> + JSON type | value_t type | used type <nl> + mmmmmmmmm | mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmm <nl> + object | object | pointer to @ ref object_t <nl> + array | array | pointer to @ ref array_t <nl> + string | string | pointer to @ ref string_t <nl> + boolean | boolean | @ ref boolean_t <nl> + number | number_integer | @ ref number_integer_t <nl> + number | number_unsigned | @ ref number_unsigned_t <nl> + number | number_float | @ ref number_float_t <nl> + null | null | * no value is stored * <nl> + <nl> + @ note Variable - length types ( objects , arrays , and strings ) are stored as <nl> + pointers . The size of the union should not exceed 64 bits if the default <nl> + value types are used . <nl> <nl> @ since version 1 . 0 . 0 <nl> * / <nl> class basic_json <nl> This enumeration lists the parser events that can trigger calling a <nl> callback function of type @ ref parser_callback_t during parsing . <nl> <nl> + @ image html callback_events . png " Example when certain parse events are triggered " <nl> + <nl> @ since version 1 . 0 . 0 <nl> * / <nl> enum class parse_event_t : uint8_t <nl> class basic_json <nl> parse_event_t : : array_end | the parser read ` ] ` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array <nl> parse_event_t : : value | the parser finished reading a JSON value | depth of the value | the parsed JSON value <nl> <nl> + @ image html callback_events . png " Example when certain parse events are triggered " <nl> + <nl> Discarding a value ( i . e . , returning ` false ` ) has different effects <nl> depending on the context in which function was called : <nl> <nl> class basic_json <nl> type of the current JSON <nl> * / <nl> template < typename ReferenceType , typename ThisType > <nl> - static ReferenceType get_ref_impl ( ThisType & obj ) <nl> + static constexpr ReferenceType get_ref_impl ( ThisType & obj ) <nl> { <nl> - / / delegate the call to get_ptr < > ( ) <nl> + / / helper type <nl> using PointerType = typename std : : add_pointer < ReferenceType > : : type ; <nl> - auto ptr = obj . template get_ptr < PointerType > ( ) ; <nl> <nl> - if ( ptr ! = nullptr ) <nl> - { <nl> - return * ptr ; <nl> - } <nl> - else <nl> - { <nl> - throw std : : domain_error ( " incompatible ReferenceType for get_ref , actual type is " + <nl> - obj . type_name ( ) ) ; <nl> - } <nl> + / / delegate the call to get_ptr < > ( ) <nl> + return obj . template get_ptr < PointerType > ( ) ! = nullptr <nl> + ? * obj . template get_ptr < PointerType > ( ) <nl> + : throw std : : domain_error ( " incompatible ReferenceType for get_ref , actual type is " + <nl> + obj . type_name ( ) ) ; <nl> } <nl> <nl> public : <nl> class basic_json <nl> std : : is_reference < ReferenceType > : : value <nl> and std : : is_const < typename std : : remove_reference < ReferenceType > : : type > : : value <nl> , int > : : type = 0 > <nl> - ReferenceType get_ref ( ) const <nl> + constexpr ReferenceType get_ref ( ) const <nl> { <nl> / / delegate call to get_ref_impl <nl> return get_ref_impl < ReferenceType > ( * this ) ; <nl> class basic_json <nl> @ throw std : : invalid_argument if the low surrogate is invalid ; example : <nl> ` " " missing or wrong low surrogate " " ` <nl> <nl> + @ complexity Constant . <nl> + <nl> @ see < http : / / en . wikipedia . org / wiki / UTF - 8 # Sample_code > <nl> * / <nl> static string_t to_unicode ( const std : : size_t codepoint1 , <nl> class basic_json <nl> function consists of a large block of code with ` goto ` jumps . <nl> <nl> @ return the class of the next token read from the buffer <nl> + <nl> + @ complexity Linear in the length of the input . \ n <nl> + <nl> + Proposition : The loop below will always terminate for finite input . \ n <nl> + <nl> + Proof ( by contradiction ) : Assume a finite input . To loop forever , the <nl> + loop must never hit code with a ` break ` statement . The only code <nl> + snippets without a ` break ` statement are the continue statements for <nl> + whitespace and byte - order - marks . To loop forever , the input must be an <nl> + infinite sequence of whitespace or byte - order - marks . This contradicts <nl> + the assumption of finite input , q . e . d . <nl> * / <nl> token_type scan ( ) noexcept <nl> { <nl> class basic_json <nl> { <nl> 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> 0 , 32 , 32 , 0 , 0 , 32 , 0 , 0 , <nl> - 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , <nl> - 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> 160 , 128 , 0 , 128 , 128 , 128 , 128 , 128 , <nl> 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , <nl> 192 , 192 , 192 , 192 , 192 , 192 , 192 , 192 , <nl> class basic_json <nl> basic_json_parser_9 : <nl> yyaccept = 0 ; <nl> yych = * ( m_marker = + + m_cursor ) ; <nl> - if ( yych < = 0x0F ) <nl> + if ( yych < = 0x1F ) <nl> { <nl> goto basic_json_parser_5 ; <nl> } <nl> class basic_json <nl> { <nl> goto basic_json_parser_31 ; <nl> } <nl> - if ( yych < = 0x0F ) <nl> + if ( yych < = 0x1F ) <nl> { <nl> goto basic_json_parser_33 ; <nl> } <nl> class basic_json <nl> according to the nature of the escape . Some escapes create new <nl> characters ( e . g . , ` " \ \ n " ` is replaced by ` " \ n " ` ) , some are copied <nl> as is ( e . g . , ` " \ \ \ \ " ` ) . Furthermore , Unicode escapes of the shape <nl> - ` " \ \ uxxxx " ` need special care . In this case , to_unicode takes care <nl> - of the construction of the values . <nl> + ` " \ \ uxxxx " ` need special care . In this case , @ ref to_unicode takes <nl> + care of the construction of the values . <nl> 2 . Unescaped characters are copied as is . <nl> <nl> + @ pre ` m_cursor - m_start > = 2 ` , meaning the length of the last token <nl> + is at least 2 bytes which is trivially true for any string ( which <nl> + consists of at least two quotes ) . <nl> + <nl> + " c1 c2 c3 . . . " <nl> + ^ ^ <nl> + m_start m_cursor <nl> + <nl> + @ complexity Linear in the length of the string . \ n <nl> + <nl> + Lemma : The loop body will always terminate . \ n <nl> + <nl> + Proof ( by contradiction ) : Assume the loop body does not terminate . As <nl> + the loop body does not contain another loop , one of the called <nl> + functions must never return . The called functions are ` std : : strtoul ` <nl> + and @ ref to_unicode . Neither function can loop forever , so the loop <nl> + body will never loop forever which contradicts the assumption that the <nl> + loop body does not terminate , q . e . d . \ n <nl> + <nl> + Lemma : The loop condition for the for loop is eventually false . \ n <nl> + <nl> + Proof ( by contradiction ) : Assume the loop does not terminate . Due to <nl> + the above lemma , this can only be due to a tautological loop <nl> + condition ; that is , the loop condition i < m_cursor - 1 must always be <nl> + true . Let x be the change of i for any loop iteration . Then <nl> + m_start + 1 + x < m_cursor - 1 must hold to loop indefinitely . <nl> + This can be rephrased to m_cursor - m_start - 2 > x . With the <nl> + precondition , we x < = 0 , meaning that the loop condition holds <nl> + indefinitly if i is always decreased . However , observe that the <nl> + value of i is strictly increasing with each iteration , as it is <nl> + incremented by 1 in the iteration expression and never <nl> + decremented inside the loop body . Hence , the loop condition <nl> + will eventually be false which contradicts the assumption that <nl> + the loop condition is a tautology , q . e . d . <nl> + <nl> @ return string value of current token without opening and closing <nl> quotes <nl> @ throw std : : out_of_range if to_unicode fails <nl> * / <nl> string_t get_string ( ) const <nl> { <nl> + assert ( m_cursor - m_start > = 2 ) ; <nl> + <nl> string_t result ; <nl> result . reserve ( static_cast < size_t > ( m_cursor - m_start - 2 ) ) ; <nl> <nl> class basic_json <nl> <nl> / * ! <nl> @ brief create and return a reference to the pointed to value <nl> + <nl> + @ complexity Linear in the number of reference tokens . <nl> * / <nl> reference get_and_create ( reference j ) const <nl> { <nl> class basic_json <nl> basic_json result ; <nl> <nl> / / iterate the JSON object values <nl> + assert ( value . m_value . object ! = nullptr ) ; <nl> for ( const auto & element : * value . m_value . object ) <nl> { <nl> if ( not element . second . is_primitive ( ) ) <nl> mmm a / src / json . hpp . re2c <nl> ppp b / src / json . hpp . re2c <nl> class basic_json <nl> This enumeration collects the different JSON types . It is internally used <nl> to distinguish the stored values , and the functions @ ref is_null ( ) , @ ref <nl> is_object ( ) , @ ref is_array ( ) , @ ref is_string ( ) , @ ref is_boolean ( ) , @ ref <nl> - is_number ( ) , and @ ref is_discarded ( ) rely on it . <nl> + is_number ( ) ( with @ ref is_number_integer ( ) , @ ref is_number_unsigned ( ) , and <nl> + @ ref is_number_float ( ) ) , @ ref is_discarded ( ) , @ ref is_primitive ( ) , and <nl> + @ ref is_structured ( ) rely on it . <nl> + <nl> + @ note There are three enumeration entries ( number_integer , <nl> + number_unsigned , and number_float ) , because the library distinguishes <nl> + these three types for numbers : @ ref number_unsigned_t is used for unsigned <nl> + integers , @ ref number_integer_t is used for signed integers , and @ ref <nl> + number_float_t is used for floating - point numbers or to approximate <nl> + integers which do not fit in the limits of their respective type . <nl> + <nl> + @ sa @ ref basic_json ( const value_t value_type ) - - create a JSON value with <nl> + the default value for a given type <nl> <nl> @ since version 1 . 0 . 0 <nl> * / <nl> class basic_json <nl> array , / / / < array ( ordered collection of values ) <nl> string , / / / < string value <nl> boolean , / / / < boolean value <nl> - number_integer , / / / < number value ( integer ) <nl> + number_integer , / / / < number value ( signed integer ) <nl> number_unsigned , / / / < number value ( unsigned integer ) <nl> number_float , / / / < number value ( floating - point ) <nl> discarded / / / < discarded by the the parser callback function <nl> class basic_json <nl> / * ! <nl> @ brief a JSON value <nl> <nl> - The actual storage for a JSON value of the @ ref basic_json class . <nl> + The actual storage for a JSON value of the @ ref basic_json class . This <nl> + union combines the different storage types for the JSON value types <nl> + defined in @ ref value_t . <nl> + <nl> + JSON type | value_t type | used type <nl> + mmmmmmmmm | mmmmmmmmmmmmmmm | mmmmmmmmmmmmmmmmmmmmmmmm <nl> + object | object | pointer to @ ref object_t <nl> + array | array | pointer to @ ref array_t <nl> + string | string | pointer to @ ref string_t <nl> + boolean | boolean | @ ref boolean_t <nl> + number | number_integer | @ ref number_integer_t <nl> + number | number_unsigned | @ ref number_unsigned_t <nl> + number | number_float | @ ref number_float_t <nl> + null | null | * no value is stored * <nl> + <nl> + @ note Variable - length types ( objects , arrays , and strings ) are stored as <nl> + pointers . The size of the union should not exceed 64 bits if the default <nl> + value types are used . <nl> <nl> @ since version 1 . 0 . 0 <nl> * / <nl> class basic_json <nl> This enumeration lists the parser events that can trigger calling a <nl> callback function of type @ ref parser_callback_t during parsing . <nl> <nl> + @ image html callback_events . png " Example when certain parse events are triggered " <nl> + <nl> @ since version 1 . 0 . 0 <nl> * / <nl> enum class parse_event_t : uint8_t <nl> class basic_json <nl> parse_event_t : : array_end | the parser read ` ] ` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array <nl> parse_event_t : : value | the parser finished reading a JSON value | depth of the value | the parsed JSON value <nl> <nl> + @ image html callback_events . png " Example when certain parse events are triggered " <nl> + <nl> Discarding a value ( i . e . , returning ` false ` ) has different effects <nl> depending on the context in which function was called : <nl> <nl> class basic_json <nl> type of the current JSON <nl> * / <nl> template < typename ReferenceType , typename ThisType > <nl> - static ReferenceType get_ref_impl ( ThisType & obj ) <nl> + static constexpr ReferenceType get_ref_impl ( ThisType & obj ) <nl> { <nl> - / / delegate the call to get_ptr < > ( ) <nl> + / / helper type <nl> using PointerType = typename std : : add_pointer < ReferenceType > : : type ; <nl> - auto ptr = obj . template get_ptr < PointerType > ( ) ; <nl> <nl> - if ( ptr ! = nullptr ) <nl> - { <nl> - return * ptr ; <nl> - } <nl> - else <nl> - { <nl> - throw std : : domain_error ( " incompatible ReferenceType for get_ref , actual type is " + <nl> - obj . type_name ( ) ) ; <nl> - } <nl> + / / delegate the call to get_ptr < > ( ) <nl> + return obj . template get_ptr < PointerType > ( ) ! = nullptr <nl> + ? * obj . template get_ptr < PointerType > ( ) <nl> + : throw std : : domain_error ( " incompatible ReferenceType for get_ref , actual type is " + <nl> + obj . type_name ( ) ) ; <nl> } <nl> <nl> public : <nl> class basic_json <nl> std : : is_reference < ReferenceType > : : value <nl> and std : : is_const < typename std : : remove_reference < ReferenceType > : : type > : : value <nl> , int > : : type = 0 > <nl> - ReferenceType get_ref ( ) const <nl> + constexpr ReferenceType get_ref ( ) const <nl> { <nl> / / delegate call to get_ref_impl <nl> return get_ref_impl < ReferenceType > ( * this ) ; <nl> class basic_json <nl> @ throw std : : invalid_argument if the low surrogate is invalid ; example : <nl> ` " " missing or wrong low surrogate " " ` <nl> <nl> + @ complexity Constant . <nl> + <nl> @ see < http : / / en . wikipedia . org / wiki / UTF - 8 # Sample_code > <nl> * / <nl> static string_t to_unicode ( const std : : size_t codepoint1 , <nl> class basic_json <nl> function consists of a large block of code with ` goto ` jumps . <nl> <nl> @ return the class of the next token read from the buffer <nl> + <nl> + @ complexity Linear in the length of the input . \ n <nl> + <nl> + Proposition : The loop below will always terminate for finite input . \ n <nl> + <nl> + Proof ( by contradiction ) : Assume a finite input . To loop forever , the <nl> + loop must never hit code with a ` break ` statement . The only code <nl> + snippets without a ` break ` statement are the continue statements for <nl> + whitespace and byte - order - marks . To loop forever , the input must be an <nl> + infinite sequence of whitespace or byte - order - marks . This contradicts <nl> + the assumption of finite input , q . e . d . <nl> * / <nl> token_type scan ( ) noexcept <nl> { <nl> class basic_json <nl> " false " { last_token_type = token_type : : literal_false ; break ; } <nl> <nl> / / number <nl> - decimal_point = [ . ] ; <nl> + decimal_point = " . " ; <nl> digit = [ 0 - 9 ] ; <nl> digit_1_9 = [ 1 - 9 ] ; <nl> - e = [ eE ] ; <nl> - minus = [ - ] ; <nl> - plus = [ + ] ; <nl> - zero = [ 0 ] ; <nl> - exp = e ( minus | plus ) ? digit + ; <nl> + e = " e " | " E " ; <nl> + minus = " - " ; <nl> + plus = " + " ; <nl> + zero = " 0 " ; <nl> + exp = e ( minus | plus ) ? digit + ; <nl> frac = decimal_point digit + ; <nl> - int = ( zero | digit_1_9 digit * ) ; <nl> + int = ( zero | digit_1_9 digit * ) ; <nl> number = minus ? int frac ? exp ? ; <nl> number { last_token_type = token_type : : value_number ; break ; } <nl> <nl> / / string <nl> - quotation_mark = [ " ] ; <nl> - escape = [ \ \ ] ; <nl> - unescaped = [ ^ " \ \ \ x00 \ x01 \ x02 \ x03 \ x04 \ x05 \ x06 \ x07 \ x08 \ x09 \ x0A \ x0B \ x0C \ x0D \ x0E \ x0F ] ; <nl> - single_escaped = [ " \ \ / bfnrt ] ; <nl> - unicode_escaped = [ u ] [ 0 - 9a - fA - F ] { 4 } ; <nl> + quotation_mark = " \ " " ; <nl> + escape = " \ \ " ; <nl> + unescaped = [ ^ " \ \ \ x00 - \ x1f ] ; <nl> + single_escaped = " \ " " | " \ \ " | " / " | " b " | " f " | " n " | " r " | " t " ; <nl> + unicode_escaped = " u " [ 0 - 9a - fA - F ] { 4 } ; <nl> escaped = escape ( single_escaped | unicode_escaped ) ; <nl> char = unescaped | escaped ; <nl> string = quotation_mark char * quotation_mark ; <nl> string { last_token_type = token_type : : value_string ; break ; } <nl> <nl> / / end of file <nl> - ' \ 000 ' { last_token_type = token_type : : end_of_input ; break ; } <nl> + " \ 000 " { last_token_type = token_type : : end_of_input ; break ; } <nl> <nl> / / anything else is an error <nl> . { last_token_type = token_type : : parse_error ; break ; } <nl> class basic_json <nl> according to the nature of the escape . Some escapes create new <nl> characters ( e . g . , ` " \ \ n " ` is replaced by ` " \ n " ` ) , some are copied <nl> as is ( e . g . , ` " \ \ \ \ " ` ) . Furthermore , Unicode escapes of the shape <nl> - ` " \ \ uxxxx " ` need special care . In this case , to_unicode takes care <nl> - of the construction of the values . <nl> + ` " \ \ uxxxx " ` need special care . In this case , @ ref to_unicode takes <nl> + care of the construction of the values . <nl> 2 . Unescaped characters are copied as is . <nl> <nl> + @ pre ` m_cursor - m_start > = 2 ` , meaning the length of the last token <nl> + is at least 2 bytes which is trivially true for any string ( which <nl> + consists of at least two quotes ) . <nl> + <nl> + " c1 c2 c3 . . . " <nl> + ^ ^ <nl> + m_start m_cursor <nl> + <nl> + @ complexity Linear in the length of the string . \ n <nl> + <nl> + Lemma : The loop body will always terminate . \ n <nl> + <nl> + Proof ( by contradiction ) : Assume the loop body does not terminate . As <nl> + the loop body does not contain another loop , one of the called <nl> + functions must never return . The called functions are ` std : : strtoul ` <nl> + and @ ref to_unicode . Neither function can loop forever , so the loop <nl> + body will never loop forever which contradicts the assumption that the <nl> + loop body does not terminate , q . e . d . \ n <nl> + <nl> + Lemma : The loop condition for the for loop is eventually false . \ n <nl> + <nl> + Proof ( by contradiction ) : Assume the loop does not terminate . Due to <nl> + the above lemma , this can only be due to a tautological loop <nl> + condition ; that is , the loop condition i < m_cursor - 1 must always be <nl> + true . Let x be the change of i for any loop iteration . Then <nl> + m_start + 1 + x < m_cursor - 1 must hold to loop indefinitely . <nl> + This can be rephrased to m_cursor - m_start - 2 > x . With the <nl> + precondition , we x < = 0 , meaning that the loop condition holds <nl> + indefinitly if i is always decreased . However , observe that the <nl> + value of i is strictly increasing with each iteration , as it is <nl> + incremented by 1 in the iteration expression and never <nl> + decremented inside the loop body . Hence , the loop condition <nl> + will eventually be false which contradicts the assumption that <nl> + the loop condition is a tautology , q . e . d . <nl> + <nl> @ return string value of current token without opening and closing <nl> quotes <nl> @ throw std : : out_of_range if to_unicode fails <nl> * / <nl> string_t get_string ( ) const <nl> { <nl> + assert ( m_cursor - m_start > = 2 ) ; <nl> + <nl> string_t result ; <nl> result . reserve ( static_cast < size_t > ( m_cursor - m_start - 2 ) ) ; <nl> <nl> class basic_json <nl> <nl> / * ! <nl> @ brief create and return a reference to the pointed to value <nl> + <nl> + @ complexity Linear in the number of reference tokens . <nl> * / <nl> reference get_and_create ( reference j ) const <nl> { <nl> class basic_json <nl> basic_json result ; <nl> <nl> / / iterate the JSON object values <nl> + assert ( value . m_value . object ! = nullptr ) ; <nl> for ( const auto & element : * value . m_value . object ) <nl> { <nl> if ( not element . second . is_primitive ( ) ) <nl> mmm a / test / src / unit . cpp <nl> ppp b / test / src / unit . cpp <nl> TEST_CASE ( " parser class " ) <nl> CHECK_THROWS_WITH ( json : : parser ( " \ " \ b \ " " ) . parse ( ) , " parse error - unexpected ' \ " ' " ) ; <nl> / / improve code coverage <nl> CHECK_THROWS_AS ( json : : parser ( " \ uFF01 " ) . parse ( ) , std : : invalid_argument ) ; <nl> + / / unescaped control characters <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x00 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x01 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x02 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x03 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x04 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x05 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x06 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x07 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x08 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x09 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x0a \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x0b \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x0c \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x0d \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x0e \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x0f \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x10 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x11 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x12 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x13 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x14 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x15 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x16 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x17 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x18 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x19 \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x1a \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x1b \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x1c \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x1d \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x1e \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> + CHECK_THROWS_AS ( json : : parser ( " \ " \ x1f \ " " ) . parse ( ) , std : : invalid_argument ) ; <nl> } <nl> <nl> SECTION ( " escaped " ) <nl>
|
minor changes
|
nlohmann/json
|
4e7501e59aff4c9dc27b4175bdefb49319d82ed3
|
2016-07-22T13:34:45Z
|
mmm a / src / btree / slice . cc <nl> ppp b / src / btree / slice . cc <nl> void btree_slice_t : : delete_all_keys_for_backfill ( order_token_t token ) { <nl> btree_delete_all_keys_for_backfill ( this , token ) ; <nl> } <nl> <nl> - void btree_slice_t : : backfill ( repli_timestamp since_when , backfill_callback_t * callback , UNUSED order_token_t token ) { <nl> + void btree_slice_t : : backfill ( repli_timestamp since_when , backfill_callback_t * callback , order_token_t token ) { <nl> assert_thread ( ) ; <nl> <nl> - / / TODO : We need to make sure that callers are using a proper substore token . <nl> - <nl> - / / order_sink_ . check_out ( token ) ; <nl> + order_sink_ . check_out ( token ) ; <nl> <nl> - btree_backfill ( this , since_when , callback , order_token_t : : ignore ) ; <nl> + btree_backfill ( this , since_when , callback , token ) ; <nl> } <nl> <nl> void btree_slice_t : : set_replication_clock ( repli_timestamp_t t , UNUSED order_token_t token ) { <nl> mmm a / src / replication / backfill_out . cc <nl> ppp b / src / replication / backfill_out . cc <nl> class backfill_and_streaming_manager_t : <nl> <nl> backfilling_ = true ; <nl> } <nl> - coro_t : : spawn_now ( boost : : bind ( & btree_slice_t : : backfill , & shard - > btree , backfill_from , this , order_token_t : : ignore ) ) ; <nl> + coro_t : : spawn_now ( boost : : bind ( & btree_slice_t : : backfill , & shard - > btree , backfill_from , this , shard - > substore_order_source . check_in ( ) ) ) ; <nl> } <nl> <nl> ~ slice_manager_t ( ) { <nl>
|
Made backfill_out pass a proper order token to btree_slice_t : : backfill .
|
rethinkdb/rethinkdb
|
170124712fc81dfce2aeb7437fffbbc6796a2c93
|
2011-06-06T22:30:49Z
|
mmm a / caffe2 / python / data_parallel_model . py <nl> ppp b / caffe2 / python / data_parallel_model . py <nl> def Parallelize_GPU ( <nl> ) <nl> <nl> if optimize_gradient_memory : <nl> - _OptimizeGradientMemoryDEPRECATED ( <nl> - model_helper_obj , losses_by_gpu , devices <nl> - ) <nl> + _OptimizeGradientMemorySimple ( model_helper_obj , losses_by_gpu , devices ) <nl> <nl> model_helper_obj . _data_parallel_model_init_nets = [ <nl> model_helper_obj . param_init_net , <nl> def Parallelize_GPU_BMUF ( <nl> devices = range ( 0 , workspace . NumCudaDevices ( ) ) , <nl> net_type = ' dag ' , <nl> master_gpu = None , <nl> + optimize_gradient_memory = False <nl> ) : <nl> ' ' ' <nl> Function to create model that run on many GPUs and creates a net for <nl> def _InitializeModels ( gpu_id ) : <nl> model_helper_obj . _device_grouped_blobs = \ <nl> _GroupByDevice ( devices , model_helper_obj . params , non_datapar_params ) <nl> <nl> + model_helper_obj . _param_names = \ <nl> + model_helper_obj . _device_grouped_blobs . keys ( ) <nl> + <nl> _AddGradientOperators ( <nl> devices , model_helper_obj , model_helper_obj . _losses_by_gpu <nl> ) <nl> def _InitializeParamUpdate ( gpu_id ) : <nl> param_name <nl> ) <nl> <nl> + if optimize_gradient_memory : <nl> + _OptimizeGradientMemorySimple ( <nl> + model_helper_obj , model_helper_obj . _losses_by_gpu , devices <nl> + ) <nl> + <nl> model_helper_obj . _data_parallel_model_init_nets = [ <nl> model_helper_obj . param_init_net , <nl> model_helper_obj . _global_model_init_net <nl> def _ComputeBlobsToSync ( model ) : <nl> return ( blobs_to_sync , sync_names ) <nl> <nl> <nl> - def _OptimizeGradientMemoryDEPRECATED ( model , losses_by_gpu , devices ) : <nl> + def _OptimizeGradientMemorySimple ( model , losses_by_gpu , devices ) : <nl> log . warning ( " mmmmmm - DEPRECATED API , please use " + <nl> " data_parallel_model . OptimizeGradientMemory ( ) mmm - - " ) <nl> for device in devices : <nl>
|
Add option to enable memonger for gradients and add param_names for save_model .
|
pytorch/pytorch
|
75a6f909c5453bd48f2ee6001c65ec23bdcfc2c8
|
2017-05-26T18:31:35Z
|
mmm a / googletest / include / gtest / internal / gtest - param - util . h <nl> ppp b / googletest / include / gtest / internal / gtest - param - util . h <nl> class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { <nl> <nl> test_param_names . insert ( param_name ) ; <nl> <nl> - if ( ! test_info - > test_base_name . empty ( ) ) { <nl> - test_name_stream < < test_info - > test_base_name < < " / " ; <nl> - } <nl> - test_name_stream < < param_name ; <nl> + test_name_stream < < test_info - > test_base_name < < " / " < < param_name ; <nl> MakeAndRegisterTestInfo ( <nl> test_suite_name . c_str ( ) , test_name_stream . GetString ( ) . c_str ( ) , <nl> nullptr , / / No type parameter . <nl> mmm a / googletest / test / googletest - output - test - golden - lin . txt <nl> ppp b / googletest / test / googletest - output - test - golden - lin . txt <nl> Expected equality of these values : <nl> 3 <nl> Stack trace : ( omitted ) <nl> <nl> - [ 0 ; 32m [ = = = = = = = = = = ] [ mRunning 85 tests from 40 test suites . <nl> + [ 0 ; 32m [ = = = = = = = = = = ] [ mRunning 84 tests from 39 test suites . <nl> [ 0 ; 32m [ mmmmmmmmm - ] [ mGlobal test environment set - up . <nl> FooEnvironment : : SetUp ( ) called . <nl> BarEnvironment : : SetUp ( ) called . <nl> Expected equality of these values : <nl> Stack trace : ( omitted ) <nl> <nl> [ 0 ; 31m [ FAILED ] [ mPrintingFailingParams / FailingParamTest . Fails / 0 , where GetParam ( ) = 2 <nl> - [ 0 ; 32m [ mmmmmmmmm - ] [ m1 test from All / EmptyBasenameParamInst <nl> - [ 0 ; 32m [ RUN ] [ mAll / EmptyBasenameParamInst . Passes / 0 <nl> - [ 0 ; 32m [ OK ] [ mAll / EmptyBasenameParamInst . Passes / 0 <nl> [ 0 ; 32m [ mmmmmmmmm - ] [ m2 tests from PrintingStrings / ParamTest <nl> [ 0 ; 32m [ RUN ] [ mPrintingStrings / ParamTest . Success / a <nl> [ 0 ; 32m [ OK ] [ mPrintingStrings / ParamTest . Success / a <nl> Failed <nl> Expected fatal failure . <nl> Stack trace : ( omitted ) <nl> <nl> - [ 0 ; 32m [ = = = = = = = = = = ] [ m85 tests from 40 test suites ran . <nl> - [ 0 ; 32m [ PASSED ] [ m31 tests . <nl> + [ 0 ; 32m [ = = = = = = = = = = ] [ m84 tests from 39 test suites ran . <nl> + [ 0 ; 32m [ PASSED ] [ m30 tests . <nl> [ 0 ; 31m [ FAILED ] [ m54 tests , listed below : <nl> [ 0 ; 31m [ FAILED ] [ mNonfatalFailureTest . EscapesStringOperands <nl> [ 0 ; 31m [ FAILED ] [ mNonfatalFailureTest . DiffForLongStrings <nl> mmm a / googletest / test / googletest - output - test_ . cc <nl> ppp b / googletest / test / googletest - output - test_ . cc <nl> INSTANTIATE_TEST_SUITE_P ( PrintingFailingParams , <nl> FailingParamTest , <nl> testing : : Values ( 2 ) ) ; <nl> <nl> - / / Tests that an empty value for the test suite basename yields just <nl> - / / the test name without any prior / <nl> - class EmptyBasenameParamInst : public testing : : TestWithParam < int > { } ; <nl> - <nl> - TEST_P ( EmptyBasenameParamInst , Passes ) { EXPECT_EQ ( 1 , GetParam ( ) ) ; } <nl> - <nl> - INSTANTIATE_TEST_SUITE_P ( All , EmptyBasenameParamInst , testing : : Values ( 1 ) ) ; <nl> - <nl> static const char kGoldenString [ ] = " \ " Line \ 0 1 \ " \ nLine 2 " ; <nl> <nl> TEST ( NonfatalFailureTest , EscapesStringOperands ) { <nl>
|
Googletest export
|
google/googletest
|
4c25e2b87fcb78abcfdee2739db9ed7a19754cd3
|
2019-10-16T18:32:23Z
|
mmm a / modules / java / generator / android - 21 / java / org / opencv / android / JavaCamera2View . java <nl> ppp b / modules / java / generator / android - 21 / java / org / opencv / android / JavaCamera2View . java <nl> <nl> <nl> import java . nio . ByteBuffer ; <nl> import java . util . Arrays ; <nl> + import java . util . List ; <nl> <nl> import android . annotation . TargetApi ; <nl> import android . content . Context ; <nl> <nl> <nl> import org . opencv . core . CvType ; <nl> import org . opencv . core . Mat ; <nl> + import org . opencv . core . Size ; <nl> import org . opencv . imgproc . Imgproc ; <nl> <nl> / * * <nl> protected void disconnectCamera ( ) { <nl> } <nl> } <nl> <nl> + public static class JavaCameraSizeAccessor implements ListItemAccessor { <nl> + @ Override <nl> + public int getWidth ( Object obj ) { <nl> + android . util . Size size = ( android . util . Size ) obj ; <nl> + return size . getWidth ( ) ; <nl> + } <nl> + <nl> + @ Override <nl> + public int getHeight ( Object obj ) { <nl> + android . util . Size size = ( android . util . Size ) obj ; <nl> + return size . getHeight ( ) ; <nl> + } <nl> + } <nl> + <nl> boolean calcPreviewSize ( final int width , final int height ) { <nl> Log . i ( LOGTAG , " calcPreviewSize : " + width + " x " + height ) ; <nl> if ( mCameraID = = null ) { <nl> boolean calcPreviewSize ( final int width , final int height ) { <nl> try { <nl> CameraCharacteristics characteristics = manager . getCameraCharacteristics ( mCameraID ) ; <nl> StreamConfigurationMap map = characteristics . get ( CameraCharacteristics . SCALER_STREAM_CONFIGURATION_MAP ) ; <nl> - int bestWidth = 0 , bestHeight = 0 ; <nl> - float aspect = ( float ) width / height ; <nl> android . util . Size [ ] sizes = map . getOutputSizes ( ImageReader . class ) ; <nl> - bestWidth = sizes [ 0 ] . getWidth ( ) ; <nl> - bestHeight = sizes [ 0 ] . getHeight ( ) ; <nl> - for ( android . util . Size sz : sizes ) { <nl> - int w = sz . getWidth ( ) , h = sz . getHeight ( ) ; <nl> - Log . d ( LOGTAG , " trying size : " + w + " x " + h ) ; <nl> - if ( width > = w & & height > = h & & bestWidth < = w & & bestHeight < = h <nl> - & & Math . abs ( aspect - ( float ) w / h ) < 0 . 2 ) { <nl> - bestWidth = w ; <nl> - bestHeight = h ; <nl> - } <nl> - } <nl> - Log . i ( LOGTAG , " best size : " + bestWidth + " x " + bestHeight ) ; <nl> - assert ( ! ( bestWidth = = 0 | | bestHeight = = 0 ) ) ; <nl> - if ( mPreviewSize . getWidth ( ) = = bestWidth & & mPreviewSize . getHeight ( ) = = bestHeight ) <nl> + List < android . util . Size > sizes_list = Arrays . asList ( sizes ) ; <nl> + Size frameSize = calculateCameraFrameSize ( sizes_list , new JavaCameraSizeAccessor ( ) , width , height ) ; <nl> + Log . i ( LOGTAG , " Selected preview size to " + Integer . valueOf ( ( int ) frameSize . width ) + " x " + Integer . valueOf ( ( int ) frameSize . height ) ) ; <nl> + assert ( ! ( frameSize . width = = 0 | | frameSize . height = = 0 ) ) ; <nl> + if ( mPreviewSize . getWidth ( ) = = frameSize . width & & mPreviewSize . getHeight ( ) = = frameSize . height ) <nl> return false ; <nl> else { <nl> - mPreviewSize = new android . util . Size ( bestWidth , bestHeight ) ; <nl> + mPreviewSize = new android . util . Size ( ( int ) frameSize . width , ( int ) frameSize . height ) ; <nl> return true ; <nl> } <nl> } catch ( CameraAccessException e ) { <nl> mmm a / modules / java / generator / android / java / org / opencv / android / CameraBridgeViewBase . java <nl> ppp b / modules / java / generator / android / java / org / opencv / android / CameraBridgeViewBase . java <nl> <nl> public abstract class CameraBridgeViewBase extends SurfaceView implements SurfaceHolder . Callback { <nl> <nl> private static final String TAG = " CameraBridge " ; <nl> - private static final int MAX_UNSPECIFIED = - 1 ; <nl> + protected static final int MAX_UNSPECIFIED = - 1 ; <nl> private static final int STOPPED = 0 ; <nl> private static final int STARTED = 1 ; <nl> <nl> protected Size calculateCameraFrameSize ( List < ? > supportedSizes , ListItemAccessor <nl> for ( Object size : supportedSizes ) { <nl> int width = accessor . getWidth ( size ) ; <nl> int height = accessor . getHeight ( size ) ; <nl> + Log . d ( TAG , " trying size : " + width + " x " + height ) ; <nl> <nl> if ( width < = maxAllowedWidth & & height < = maxAllowedHeight ) { <nl> if ( width > = calcWidth & & height > = calcHeight ) { <nl> protected Size calculateCameraFrameSize ( List < ? > supportedSizes , ListItemAccessor <nl> } <nl> } <nl> } <nl> + if ( ( calcWidth = = 0 | | calcHeight = = 0 ) & & supportedSizes . size ( ) > 0 ) <nl> + { <nl> + Log . i ( TAG , " fallback to the first frame size " ) ; <nl> + Object size = supportedSizes . get ( 0 ) ; <nl> + calcWidth = accessor . getWidth ( size ) ; <nl> + calcHeight = accessor . getHeight ( size ) ; <nl> + } <nl> <nl> return new Size ( calcWidth , calcHeight ) ; <nl> } <nl>
|
android : JavaCamera2View use calculateCameraFrameSize ( ) method
|
opencv/opencv
|
3998b41d6843217e639a3ba53389222ec0620351
|
2019-07-04T21:43:09Z
|
mmm a / tensorflow / contrib / tpu / BUILD <nl> ppp b / tensorflow / contrib / tpu / BUILD <nl> load ( " / / tensorflow : tensorflow . bzl " , " tf_py_test " ) <nl> <nl> package ( <nl> default_visibility = [ <nl> + " / / cloud / vmm / testing / tests / tpu : __subpackages__ " , <nl> " / / learning / brain : __subpackages__ " , <nl> " / / tensorflow : __subpackages__ " , <nl> ] , <nl>
|
Internal Change
|
tensorflow/tensorflow
|
522db88624f39946f66c3f4dff07c33cc4499311
|
2017-09-22T19:21:05Z
|
mmm a / src / wallet / wallet_ismine . cpp <nl> ppp b / src / wallet / wallet_ismine . cpp <nl> isminetype IsMine ( const CKeyStore & keystore , const CScript & scriptPubKey ) <nl> txnouttype whichType ; <nl> if ( ! Solver ( scriptPubKey , whichType , vSolutions ) ) { <nl> if ( keystore . HaveWatchOnly ( scriptPubKey ) ) <nl> - return ISMINE_WATCH_NOPUBKEY ; <nl> + return ISMINE_WATCH_UNSOLVABLE ; <nl> return ISMINE_NO ; <nl> } <nl> <nl> isminetype IsMine ( const CKeyStore & keystore , const CScript & scriptPubKey ) <nl> if ( keystore . HaveWatchOnly ( scriptPubKey ) ) { <nl> / / TODO : This could be optimized some by doing some work after the above solver <nl> CScript scriptSig ; <nl> - return ProduceSignature ( DummySignatureCreator ( & keystore ) , scriptPubKey , scriptSig ) ? ISMINE_WATCH_PUBKEY : ISMINE_WATCH_NOPUBKEY ; <nl> + return ProduceSignature ( DummySignatureCreator ( & keystore ) , scriptPubKey , scriptSig ) ? ISMINE_WATCH_SOLVABLE : ISMINE_WATCH_UNSOLVABLE ; <nl> } <nl> return ISMINE_NO ; <nl> } <nl> mmm a / src / wallet / wallet_ismine . h <nl> ppp b / src / wallet / wallet_ismine . h <nl> enum isminetype <nl> { <nl> ISMINE_NO = 0 , <nl> / / ! Indicates that we dont know how to create a scriptSig that would solve this if we were given the appropriate private keys <nl> - ISMINE_WATCH_NOPUBKEY = 1 , <nl> + ISMINE_WATCH_UNSOLVABLE = 1 , <nl> / / ! Indicates that we know how to create a scriptSig that would solve this if we were given the appropriate private keys <nl> - ISMINE_WATCH_PUBKEY = 2 , <nl> - ISMINE_WATCH_ONLY = ISMINE_WATCH_NOPUBKEY | ISMINE_WATCH_PUBKEY , <nl> + ISMINE_WATCH_SOLVABLE = 2 , <nl> + ISMINE_WATCH_ONLY = ISMINE_WATCH_SOLVABLE | ISMINE_WATCH_UNSOLVABLE , <nl> ISMINE_SPENDABLE = 4 , <nl> ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE <nl> } ; <nl>
|
SQUASH " Add have - pubkey distinction to ISMINE flags "
|
bitcoin/bitcoin
|
428a898acd37e1c0afa21623a8fe5728859067be
|
2015-08-08T16:30:53Z
|
mmm a / atom / browser / api / atom_api_window . cc <nl> ppp b / atom / browser / api / atom_api_window . cc <nl> void Window : : FlashFrame ( bool flash ) { <nl> window_ - > FlashFrame ( flash ) ; <nl> } <nl> <nl> + void Window : : SetSkipTaskbar ( bool skip ) { <nl> + window_ - > SetSkipTaskbar ( skip ) ; <nl> + } <nl> + <nl> void Window : : SetKiosk ( bool kiosk ) { <nl> window_ - > SetKiosk ( kiosk ) ; <nl> } <nl> void Window : : BuildPrototype ( v8 : : Isolate * isolate , <nl> . SetMethod ( " setTitle " , & Window : : SetTitle ) <nl> . SetMethod ( " getTitle " , & Window : : GetTitle ) <nl> . SetMethod ( " flashFrame " , & Window : : FlashFrame ) <nl> + . SetMethod ( " setSkipTaskbar " , & Window : : SetSkipTaskbar ) <nl> . SetMethod ( " setKiosk " , & Window : : SetKiosk ) <nl> . SetMethod ( " isKiosk " , & Window : : IsKiosk ) <nl> . SetMethod ( " setRepresentedFilename " , & Window : : SetRepresentedFilename ) <nl> mmm a / atom / browser / api / atom_api_window . h <nl> ppp b / atom / browser / api / atom_api_window . h <nl> class Window : public mate : : EventEmitter , <nl> void SetTitle ( const std : : string & title ) ; <nl> std : : string GetTitle ( ) ; <nl> void FlashFrame ( bool flash ) ; <nl> + void SetSkipTaskbar ( bool skip ) ; <nl> void SetKiosk ( bool kiosk ) ; <nl> bool IsKiosk ( ) ; <nl> void OpenDevTools ( ) ; <nl> mmm a / atom / browser / native_window . cc <nl> ppp b / atom / browser / native_window . cc <nl> void NativeWindow : : InitFromOptions ( base : : DictionaryValue * options ) { <nl> if ( options - > GetBoolean ( switches : : kFullscreen , & fullscreen ) & & fullscreen ) { <nl> SetFullscreen ( true ) ; <nl> } <nl> + bool skip ; <nl> + if ( options - > GetBoolean ( switches : : kSkipTaskbar , & skip ) & & skip ) { <nl> + SetSkipTaskbar ( skip ) ; <nl> + } <nl> bool kiosk ; <nl> if ( options - > GetBoolean ( switches : : kKiosk , & kiosk ) & & kiosk ) { <nl> SetKiosk ( kiosk ) ; <nl> mmm a / atom / browser / native_window . h <nl> ppp b / atom / browser / native_window . h <nl> class NativeWindow : public brightray : : DefaultWebContentsDelegate , <nl> virtual void SetTitle ( const std : : string & title ) = 0 ; <nl> virtual std : : string GetTitle ( ) = 0 ; <nl> virtual void FlashFrame ( bool flash ) = 0 ; <nl> + virtual void SetSkipTaskbar ( bool skip ) = 0 ; <nl> virtual void SetKiosk ( bool kiosk ) = 0 ; <nl> virtual bool IsKiosk ( ) = 0 ; <nl> virtual void SetRepresentedFilename ( const std : : string & filename ) ; <nl> mmm a / atom / browser / native_window_gtk . cc <nl> ppp b / atom / browser / native_window_gtk . cc <nl> void NativeWindowGtk : : FlashFrame ( bool flash ) { <nl> gtk_window_set_urgency_hint ( window_ , flash ) ; <nl> } <nl> <nl> + void NativeWindowGtk : : SetSkipTaskbar ( bool skip ) { <nl> + gtk_window_set_skip_taskbar_hint ( window_ , skip ) ; <nl> + gtk_window_set_skip_pager_hint ( window_ , skip ) ; <nl> + } <nl> + <nl> void NativeWindowGtk : : SetKiosk ( bool kiosk ) { <nl> SetFullscreen ( kiosk ) ; <nl> } <nl> mmm a / atom / browser / native_window_gtk . h <nl> ppp b / atom / browser / native_window_gtk . h <nl> class NativeWindowGtk : public NativeWindow , <nl> virtual void SetTitle ( const std : : string & title ) OVERRIDE ; <nl> virtual std : : string GetTitle ( ) OVERRIDE ; <nl> virtual void FlashFrame ( bool flash ) OVERRIDE ; <nl> + virtual void SetSkipTaskbar ( bool skip ) OVERRIDE ; <nl> virtual void SetKiosk ( bool kiosk ) OVERRIDE ; <nl> virtual bool IsKiosk ( ) OVERRIDE ; <nl> virtual gfx : : NativeWindow GetNativeWindow ( ) OVERRIDE ; <nl> mmm a / atom / browser / native_window_mac . h <nl> ppp b / atom / browser / native_window_mac . h <nl> class NativeWindowMac : public NativeWindow { <nl> virtual void SetTitle ( const std : : string & title ) OVERRIDE ; <nl> virtual std : : string GetTitle ( ) OVERRIDE ; <nl> virtual void FlashFrame ( bool flash ) OVERRIDE ; <nl> + virtual void SetSkipTaskbar ( bool skip ) OVERRIDE ; <nl> virtual void SetKiosk ( bool kiosk ) OVERRIDE ; <nl> virtual bool IsKiosk ( ) OVERRIDE ; <nl> virtual void SetRepresentedFilename ( const std : : string & filename ) OVERRIDE ; <nl> mmm a / atom / browser / native_window_mac . mm <nl> ppp b / atom / browser / native_window_mac . mm <nl> - ( void ) mouseDragged : ( NSEvent * ) event { <nl> } <nl> } <nl> <nl> + void NativeWindowMac : : SetSkipTaskbar ( bool skip ) { <nl> + } <nl> + <nl> void NativeWindowMac : : SetKiosk ( bool kiosk ) { <nl> if ( kiosk & & ! is_kiosk_ ) { <nl> kiosk_options_ = [ NSApp currentSystemPresentationOptions ] ; <nl> mmm a / atom / browser / native_window_win . cc <nl> ppp b / atom / browser / native_window_win . cc <nl> void NativeWindowWin : : FlashFrame ( bool flash ) { <nl> window_ - > FlashFrame ( flash ) ; <nl> } <nl> <nl> + void NativeWindowWin : : SetSkipTaskbar ( bool skip ) { <nl> + } <nl> + <nl> void NativeWindowWin : : SetKiosk ( bool kiosk ) { <nl> SetFullscreen ( kiosk ) ; <nl> } <nl> mmm a / atom / browser / native_window_win . h <nl> ppp b / atom / browser / native_window_win . h <nl> class NativeWindowWin : public NativeWindow , <nl> virtual void SetTitle ( const std : : string & title ) OVERRIDE ; <nl> virtual std : : string GetTitle ( ) OVERRIDE ; <nl> virtual void FlashFrame ( bool flash ) OVERRIDE ; <nl> + virtual void SetSkipTaskbar ( bool skip ) OVERRIDE ; <nl> virtual void SetKiosk ( bool kiosk ) OVERRIDE ; <nl> virtual bool IsKiosk ( ) OVERRIDE ; <nl> virtual gfx : : NativeWindow GetNativeWindow ( ) OVERRIDE ; <nl> mmm a / atom / common / options_switches . cc <nl> ppp b / atom / common / options_switches . cc <nl> const char kMaxHeight [ ] = " max - height " ; <nl> const char kResizable [ ] = " resizable " ; <nl> const char kFullscreen [ ] = " fullscreen " ; <nl> <nl> + / / Whether the window should show in taskbar . <nl> + const char kSkipTaskbar [ ] = " skip - taskbar " ; <nl> + <nl> / / Start with the kiosk mode , see Opera ' s page for description : <nl> / / http : / / www . opera . com / support / mastering / kiosk / <nl> const char kKiosk [ ] = " kiosk " ; <nl> mmm a / atom / common / options_switches . h <nl> ppp b / atom / common / options_switches . h <nl> extern const char kMaxWidth [ ] ; <nl> extern const char kMaxHeight [ ] ; <nl> extern const char kResizable [ ] ; <nl> extern const char kFullscreen [ ] ; <nl> + extern const char kSkipTaskbar [ ] ; <nl> extern const char kKiosk [ ] ; <nl> extern const char kAlwaysOnTop [ ] ; <nl> extern const char kNodeIntegration [ ] ; <nl>
|
gtk : Add BrowserWindow . setSkipTaskbar API .
|
electron/electron
|
70d33654142c87a9dc9b018c61208d2ca06f341a
|
2014-06-16T02:29:51Z
|
mmm a / examples / CMakeLists . txt <nl> ppp b / examples / CMakeLists . txt <nl> add_example ( dir_nav_ex ) <nl> add_example ( file_to_code_ex ) <nl> add_example ( gui_api_ex ) <nl> add_example ( image_ex ) <nl> + add_example ( krls_ex ) <nl> add_example ( logger_ex ) <nl> add_example ( logger_ex_2 ) <nl> add_example ( matrix_ex ) <nl> new file mode 100644 <nl> index 000000000 . . 394785ba5 <nl> mmm / dev / null <nl> ppp b / examples / krls_ex . cpp <nl> <nl> + / * <nl> + This is an example illustrating the use of the krls object <nl> + from the dlib C + + Library . <nl> + <nl> + The krls object allows you to perform online regression . This <nl> + example will train an instance of it on the sinc function . <nl> + <nl> + * / <nl> + <nl> + # include < iostream > <nl> + # include < vector > <nl> + <nl> + # include " dlib / svm . h " <nl> + <nl> + using namespace std ; <nl> + using namespace dlib ; <nl> + <nl> + / / Here is the sinc function we will be trying to learn with the krls <nl> + / / object . <nl> + double sinc ( double x ) <nl> + { <nl> + if ( x = = 0 ) <nl> + return 1 ; <nl> + return sin ( x ) / x ; <nl> + } <nl> + <nl> + int main ( ) <nl> + { <nl> + / / Here we declare that our samples will be 1 dimensional column vectors . The reason for <nl> + / / using a matrix here is that in general you can use N dimensional vectors as inputs to the <nl> + / / krls object . But here we only have 1 dimension to make the example simple . <nl> + typedef matrix < double , 1 , 1 > sample_type ; <nl> + <nl> + / / Now we are making a typedef for the kind of kernel we want to use . I picked the <nl> + / / radial basis kernel because it only has one parameter and generally gives good <nl> + / / results without much fiddling . <nl> + typedef radial_basis_kernel < sample_type > kernel_type ; <nl> + <nl> + / / Here we declare an instance of the krls object . The first argument to the constructor <nl> + / / is the kernel we wish to use . The second is a parameter that determines the numerical <nl> + / / accuracy with which the object will perform part of the regression algorithm . Generally <nl> + / / smaller values give better results but cause the algorithm to run slower . You just have <nl> + / / to play with it to decide what balance of speed and accuracy is right for your problem . <nl> + / / Here we have set it to 0 . 001 . <nl> + krls < kernel_type > test ( kernel_type ( 0 . 1 ) , 0 . 001 ) ; <nl> + <nl> + / / now we train our object on a few samples of the sinc function . <nl> + sample_type m ; <nl> + for ( double x = - 10 ; x < = 4 ; x + = 1 ) <nl> + { <nl> + m ( 0 ) = x ; <nl> + test . train ( m , sinc ( x ) ) ; <nl> + } <nl> + <nl> + / / now we output the value of the sinc function for a few test points as well as the <nl> + / / value predicted by krls object . <nl> + m ( 0 ) = 2 . 5 ; cout < < sinc ( m ( 0 ) ) < < " " < < test ( m ) < < endl ; <nl> + m ( 0 ) = 0 . 1 ; cout < < sinc ( m ( 0 ) ) < < " " < < test ( m ) < < endl ; <nl> + m ( 0 ) = - 4 ; cout < < sinc ( m ( 0 ) ) < < " " < < test ( m ) < < endl ; <nl> + m ( 0 ) = 5 . 0 ; cout < < sinc ( m ( 0 ) ) < < " " < < test ( m ) < < endl ; <nl> + <nl> + / / The output is as follows : <nl> + / / 0 . 239389 0 . 238808 <nl> + / / 0 . 998334 0 . 997779 <nl> + / / - 0 . 189201 - 0 . 189754 <nl> + / / - 0 . 191785 - 0 . 1979 <nl> + <nl> + / / The first column is the true value of the sinc function and the second <nl> + / / column is the output from the krls estimate . <nl> + <nl> + } <nl> + <nl> + <nl>
|
added the krls example
|
davisking/dlib
|
246a14f99654bc6192e1fb157b7b69d72a1bb265
|
2008-05-23T00:08:49Z
|
mmm a / src / heap . cc <nl> ppp b / src / heap . cc <nl> void Heap : : ScavengeObject ( HeapObject * * p , HeapObject * object ) { <nl> <nl> <nl> static inline bool IsShortcutCandidate ( HeapObject * object , Map * map ) { <nl> - / / A ConsString object with Heap : : empty_string ( ) as the right side <nl> - / / is a candidate for being shortcut by the scavenger . <nl> + / / A ConsString with an empty string as the right side is a <nl> + / / candidate for being shortcut by the scavenger unless it is a <nl> + / / symbol . It ' s not common to have non - flat symbols , so we do not <nl> + / / shortcut them thereby avoiding turning symbols into strings . <nl> + ASSERT ( kNotStringTag ! = 0 & & kSymbolTag ! = 0 ) ; <nl> + static const uint32_t kShortcutTypeMask = <nl> + kIsNotStringMask | <nl> + kIsSymbolMask | <nl> + kStringRepresentationMask ; <nl> ASSERT ( object - > map ( ) = = map ) ; <nl> - if ( map - > instance_type ( ) > = FIRST_NONSTRING_TYPE ) return false ; <nl> - return ( StringShape ( map ) . representation_tag ( ) = = kConsStringTag ) & & <nl> - ( ConsString : : cast ( object ) - > unchecked_second ( ) = = Heap : : empty_string ( ) ) ; <nl> + InstanceType type = map - > instance_type ( ) ; <nl> + if ( ( type & kShortcutTypeMask ) ! = kConsStringTag ) return false ; <nl> + ASSERT ( object - > IsString ( ) & & ! object - > IsSymbol ( ) ) ; <nl> + return ConsString : : cast ( object ) - > unchecked_second ( ) = = Heap : : empty_string ( ) ; <nl> } <nl> <nl> <nl> mmm a / src / mark - compact . cc <nl> ppp b / src / mark - compact . cc <nl> void MarkCompactCollector : : Prepare ( GCTracer * tracer ) { <nl> <nl> void MarkCompactCollector : : Finish ( ) { <nl> # ifdef DEBUG <nl> + SymbolTable * symbol_table = SymbolTable : : cast ( Heap : : symbol_table ( ) ) ; <nl> + SymbolTableVerifier v ; <nl> + symbol_table - > IterateElements ( & v ) ; <nl> + <nl> ASSERT ( state_ = = SWEEP_SPACES | | state_ = = REBUILD_RSETS ) ; <nl> state_ = IDLE ; <nl> # endif <nl>
|
Fixed issue 303 by not shortcutting cons - symbols and added
|
v8/v8
|
850d5ed38013b467434fbe2533a9779c36d7fdb0
|
2009-04-14T09:58:42Z
|
mmm a / etc / evergreen . yml <nl> ppp b / etc / evergreen . yml <nl> variables : <nl> - name : aggregation_multiversion_fuzzer_gen <nl> - name : aggregation_wildcard_fuzzer_gen <nl> - name : audit <nl> - - name : auth_audit_gen <nl> + - name : auth_audit <nl> - name : benchmarks_orphaned <nl> - name : benchmarks_sharding <nl> - name : buildscripts_test <nl> variables : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_default_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_default_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_100ms_refresh_jscore_passthrough <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_10sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_default_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_100ms_refresh_jscore_passthrough <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_10sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_default_refresh_jscore_passthrough <nl> - name : replica_sets_auth_gen <nl> variables : <nl> - name : sharding_auth_audit_gen <nl> - name : sharding_ese_gen <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> <nl> - & stitch_support_task_group_template <nl> name : stitch_support_task_group_template <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = audit - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : auth <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = auth - - storageEngine = wiredTiger <nl> + <nl> - name : auth_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 4 <nl> <nl> + - < < : * task_template <nl> + name : auth_audit <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = auth_audit - - storageEngine = wiredTiger <nl> + <nl> - name : auth_audit_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = causally_consistent_jscore_txns_passthrough - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : sharded_causally_consistent_jscore_txns_passthrough <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = sharded_causally_consistent_jscore_txns_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = replica_sets_multi_stmt_txn_jscore_passthrough - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : replica_sets_multi_stmt_txn_stepdown_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = replica_sets_multi_stmt_txn_stepdown_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : replica_sets_multi_stmt_txn_stepdown_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> task_path_suffix : / data / multiversion <nl> resmoke_args : - - suites = multiversion - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : noPassthrough <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = no_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : noPassthrough_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 11 <nl> <nl> + - < < : * task_template <nl> + name : noPassthroughWithMongod <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = no_passthrough_with_mongod - - storageEngine = wiredTiger <nl> + <nl> - name : noPassthroughWithMongod_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = bulk_gle_passthrough - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : slow1 <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = slow1 - - storageEngine = wiredTiger <nl> + resmoke_jobs_max : 1 <nl> + <nl> - name : slow1_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = sharding_jscore_op_query_passthrough - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : sharding_jscore_passthrough_wire_ops <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = sharding_jscore_passthrough - - storageEngine = wiredTiger - - shellReadMode = legacy - - shellWriteMode = compatibility - - excludeWithAnyTags = requires_find_command <nl> + <nl> - name : sharding_jscore_passthrough_wire_ops_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = sharded_multi_stmt_txn_jscore_passthrough - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : multi_shard_multi_stmt_txn_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = multi_shard_multi_stmt_txn_jscore_passthrough - - storageEngine = wiredTiger <nl> + resmoke_jobs_max : 0 # No cap on number of jobs . <nl> + <nl> - name : multi_shard_multi_stmt_txn_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> fallback_num_sub_suites : 28 <nl> resmoke_jobs_max : 0 # No cap on number of jobs . <nl> <nl> + - < < : * task_template <nl> + name : multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 4 <nl> <nl> + - < < : * task_template <nl> + name : multi_stmt_txn_jscore_passthrough_with_migration <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = multi_stmt_txn_jscore_passthrough_with_migration - - storageEngine = wiredTiger <nl> + <nl> - name : multi_stmt_txn_jscore_passthrough_with_migration_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = read_concern_linearizable_passthrough - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : read_concern_majority_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = read_concern_majority_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : read_concern_majority_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = write_concern_majority_passthrough - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : secondary_reads_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = secondary_reads_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : secondary_reads_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = replica_sets - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : replica_sets_ese <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = replica_sets_ese - - storageEngine = wiredTiger <nl> + <nl> - name : replica_sets_ese_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 7 <nl> <nl> + - < < : * task_template <nl> + name : replica_sets_auth <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = replica_sets_auth - - storageEngine = wiredTiger <nl> + <nl> - name : replica_sets_auth_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 15 <nl> <nl> + - < < : * task_template <nl> + name : sharding <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = sharding - - storageEngine = wiredTiger <nl> + <nl> + - < < : * task_template <nl> + name : sharding_csrs_continuous_config_stepdown <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = sharding_continuous_config_stepdown - - storageEngine = wiredTiger <nl> + <nl> - name : sharding_csrs_continuous_config_stepdown_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 22 <nl> <nl> + - < < : * task_template <nl> + name : sharding_ese <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = sharding_ese - - storageEngine = wiredTiger <nl> + <nl> - name : sharding_ese_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 21 <nl> <nl> + - < < : * task_template <nl> + name : sharding_op_query <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = sharding - - shellReadMode = legacy - - storageEngine = wiredTiger - - excludeWithAnyTags = requires_find_command <nl> + <nl> - name : sharding_op_query_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> resmoke_args : - - shellReadMode = legacy - - storageEngine = wiredTiger - - excludeWithAnyTags = requires_find_command <nl> fallback_num_sub_suites : 12 <nl> <nl> + - < < : * task_template <nl> + name : sharding_auth <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = sharding_auth - - storageEngine = wiredTiger <nl> + <nl> - name : sharding_auth_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 20 <nl> <nl> + - < < : * task_template <nl> + name : sharding_auth_audit <nl> + depends_on : <nl> + - name : sharding_auth <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = sharding_auth_audit - - storageEngine = wiredTiger <nl> + <nl> - name : sharding_auth_audit_gen <nl> depends_on : <nl> - name : sharding_auth_gen <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 20 <nl> <nl> + - < < : * task_template <nl> + name : sharding_last_stable_mongos_and_mixed_shards <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " do multiversion setup " <nl> + - func : " run tests " <nl> + vars : <nl> + task_path_suffix : / data / multiversion <nl> + resmoke_args : - - suites = sharding_last_stable_mongos_and_mixed_shards <nl> + <nl> - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> vars : <nl> task : sharding_last_stable_mongos_and_mixed_shards <nl> - use_large_distro : " true " <nl> use_multiversion : / data / multiversion <nl> resmoke_args : " " <nl> fallback_num_sub_suites : 12 <nl> tasks : <nl> snmp_config_path : SNMPCONFPATH = snmpconf <nl> resmoke_args : - - suites = snmp - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : ssl <nl> + commands : <nl> + - func : " do setup " <nl> + - command : shell . exec <nl> + type : test <nl> + params : <nl> + working_dir : src <nl> + script : | <nl> + set - o errexit <nl> + set - o verbose <nl> + <nl> + $ { activate_virtualenv } <nl> + if [ " Windows_NT " = " $ OS " ] ; then <nl> + / cygdrive / c / python / python36 / python . exe - m pip install - r etc / pip / evgtest - requirements . txt <nl> + else <nl> + python3 - m pip install - r etc / pip / evgtest - requirements . txt <nl> + fi <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = ssl - - storageEngine = wiredTiger <nl> + <nl> - name : ssl_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 5 <nl> <nl> + - < < : * task_template <nl> + name : sslSpecial <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = ssl_special - - storageEngine = wiredTiger <nl> + <nl> - name : sslSpecial_gen <nl> commands : <nl> - func : " generate resmoke tasks " <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = session_jscore_passthrough - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : causally_consistent_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = causally_consistent_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : causally_consistent_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 6 <nl> <nl> + - < < : * task_template <nl> + name : causally_consistent_jscore_passthrough_auth <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = causally_consistent_jscore_passthrough_auth - - storageEngine = wiredTiger <nl> + <nl> - name : causally_consistent_jscore_passthrough_auth_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 7 <nl> <nl> + - < < : * task_template <nl> + name : sharded_causally_consistent_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = sharded_causally_consistent_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : sharded_causally_consistent_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 6 <nl> <nl> + - < < : * task_template <nl> + name : retryable_writes_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = retryable_writes_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : retryable_writes_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 8 <nl> <nl> + - < < : * task_template <nl> + name : logical_session_cache_replication_default_refresh_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = logical_session_cache_replication_default_refresh_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : logical_session_cache_replication_default_refresh_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 7 <nl> <nl> + - < < : * task_template <nl> + name : logical_session_cache_replication_100ms_refresh_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = logical_session_cache_replication_100ms_refresh_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 8 <nl> <nl> + - < < : * task_template <nl> + name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = logical_session_cache_replication_1sec_refresh_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 7 <nl> <nl> + - < < : * task_template <nl> + name : logical_session_cache_replication_10sec_refresh_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = logical_session_cache_replication_10sec_refresh_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = logical_session_cache_sharding_100ms_refresh_jscore_passthrough - - storageEngine = wiredTiger <nl> <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> + - < < : * task_template <nl> + name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> depends_on : <nl> - name : jsCore <nl> commands : <nl> - - func : " generate resmoke tasks " <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> vars : <nl> - task : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> - depends_on : jsCore <nl> + resmoke_args : - - suites = logical_session_cache_sharding_1sec_refresh_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " generate resmoke tasks " <nl> + vars : <nl> + task : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + depends_on : jsCore <nl> resmoke_args : - - storageEngine = wiredTiger <nl> fallback_num_sub_suites : 3 <nl> <nl> tasks : <nl> vars : <nl> resmoke_args : - - suites = logical_session_cache_standalone_100ms_refresh_jscore_passthrough - - storageEngine = wiredTiger <nl> <nl> + - < < : * task_template <nl> + name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + depends_on : <nl> + - name : jsCore <nl> + commands : <nl> + - func : " do setup " <nl> + - func : " run tests " <nl> + vars : <nl> + resmoke_args : - - suites = logical_session_cache_standalone_1sec_refresh_jscore_passthrough - - storageEngine = wiredTiger <nl> + <nl> - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> depends_on : <nl> - name : jsCore <nl> buildvariants : <nl> - name : integration_tests_sharded <nl> - name : jsCore <nl> - name : jsCore_txns <nl> - - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_default_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_default_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_100ms_refresh_jscore_passthrough <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_10sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_default_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_100ms_refresh_jscore_passthrough <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_10sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_default_refresh_jscore_passthrough <nl> - name : parallel <nl> buildvariants : <nl> - rhel62 - large <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : bulk_gle_passthrough <nl> - name : concurrency <nl> - name : concurrency_simultaneous <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : serial_run <nl> - name : sharding_jscore_passthrough <nl> - - name : slow1_gen <nl> + - name : slow1 <nl> - name : tool <nl> <nl> - name : linux - 64 - lsm <nl> buildvariants : <nl> - ubuntu1404 - build <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : failpoints_auth <nl> buildvariants : <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - name : multiversion <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> # - name : concurrency_sharded_replication_multi_stmt_txn_with_balancer # Removed until SERVER - 38499 is resolved . <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : powercycle <nl> - name : powercycle_fcv4 . 0 <nl> buildvariants : <nl> - name : powercycle_replication_smalloplog <nl> - name : powercycle_syncdelay <nl> - name : powercycle_write_concern_majority <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - ubuntu1804 - build <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : failpoints_auth <nl> buildvariants : <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - name : multiversion <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharding_auth_gen <nl> + - name : sharding_auth <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : watchdog_inmemory <nl> - name : watchdog_wiredtiger <nl> - name : package <nl> buildvariants : <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - name : sasl <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> <nl> - name : enterprise - ubuntu1804 - 64 - clang - cxx17 <nl> display_name : ~ Enterprise Ubuntu 18 . 04 ( System clang 6 . 0 C + + 17 libc + + DEBUG ) <nl> buildvariants : <nl> - name : jsCore_auth <nl> - name : jsCore_txns <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : sasl <nl> - - name : sharding_auth_gen <nl> + - name : sharding_auth <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : watchdog_wiredtiger <nl> buildvariants : <nl> - ubuntu1604 - build <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : failpoints_auth <nl> buildvariants : <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - name : multiversion <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : tool <nl> - name : package <nl> distros : <nl> buildvariants : <nl> - name : compile_all_run_unittests_TG <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : failpoints <nl> - name : failpoints_auth <nl> - name : gle_auth <nl> buildvariants : <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - name : compile_all_run_unittests_TG <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : failpoints <nl> - name : failpoints_auth <nl> - name : gle_auth <nl> buildvariants : <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - ubuntu1604 - power8 - build <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : failpoints <nl> - name : failpoints_auth <nl> - name : gle_auth <nl> buildvariants : <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - name : concurrency <nl> - name : concurrency_replication <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_ese_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_ese <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> - - name : sharding_ese_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> - - name : sharding_csrs_continuous_config_stepdown_gen <nl> + - name : sharding <nl> + - name : sharding_ese <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> + - name : sharding_csrs_continuous_config_stepdown <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - ubuntu1804 - zseries - build <nl> - name : jsCore <nl> - name : replica_sets_jscore_passthrough <nl> - - name : ssl_gen <nl> + - name : ssl <nl> - name : publish_packages <nl> distros : <nl> - ubuntu1804 - test <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - name : concurrency <nl> - name : concurrency_replication <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_ese_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_ese <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> - - name : sharding_ese_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> - - name : sharding_csrs_continuous_config_stepdown_gen <nl> + - name : sharding <nl> + - name : sharding_ese <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> + - name : sharding_csrs_continuous_config_stepdown <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : tool <nl> - name : write_concern_majority_passthrough <nl> - name : publish_packages <nl> buildvariants : <nl> - name : aggregation_auth <nl> - name : aggregation <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : ese <nl> - name : failpoints_auth <nl> - name : jsCore <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - - name : replica_sets_auth_gen <nl> - - name : replica_sets_ese_gen <nl> + - name : replica_sets_auth <nl> + - name : replica_sets_ese <nl> - name : replica_sets_jscore_passthrough <nl> - name : powercycle <nl> - name : sasl <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> - - name : sharding_ese_gen <nl> - - name : slow1_gen <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> + - name : sharding_ese <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : package <nl> buildvariants : <nl> - linux - 64 - amzn - build <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : failpoints_auth <nl> buildvariants : <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - name : multiversion <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - name : aggregation_auth <nl> - name : aggregation <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : ese <nl> - name : failpoints_auth <nl> - name : jsCore <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - - name : replica_sets_auth_gen <nl> - - name : replica_sets_ese_gen <nl> + - name : replica_sets_auth <nl> + - name : replica_sets_ese <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> - - name : sharding_ese_gen <nl> - - name : slow1_gen <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> + - name : sharding_ese <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : package <nl> buildvariants : <nl> - amazon2 - build <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : failpoints_auth <nl> buildvariants : <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - name : multiversion <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> multiversion_edition : enterprise <nl> tooltags : " " <nl> build_mongoreplay : false <nl> - large_distro_name : windows - 64 - vs2017 - compile <nl> display_tasks : <nl> - * dbtest <nl> - * unittests <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : aggregation_expression_multiversion_fuzzer_gen <nl> - - name : auth_gen <nl> - - name : causally_consistent_jscore_passthrough_gen <nl> - - name : causally_consistent_jscore_passthrough_auth_gen <nl> - - name : sharded_causally_consistent_jscore_passthrough_gen <nl> + - name : auth <nl> + - name : causally_consistent_jscore_passthrough <nl> + - name : causally_consistent_jscore_passthrough_auth <nl> + - name : sharded_causally_consistent_jscore_passthrough <nl> - name : change_streams <nl> - name : change_streams_mongos_passthrough <nl> - name : change_streams_mongos_sessions_passthrough <nl> buildvariants : <nl> - name : jsCore_txns <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - name : jsonSchema <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : multi_shard_multi_stmt_txn_jscore_passthrough_gen <nl> - - name : multi_stmt_txn_jscore_passthrough_with_migration_gen <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : multi_shard_multi_stmt_txn_jscore_passthrough <nl> + - name : multi_stmt_txn_jscore_passthrough_with_migration <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : rollback_fuzzer_gen <nl> - name : rollback_fuzzer_clean_shutdowns_gen <nl> - name : rollback_fuzzer_unclean_shutdowns_gen <nl> buildvariants : <nl> - name : read_concern_linearizable_passthrough <nl> distros : <nl> - windows - 64 - vs2017 - compile <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> + distros : <nl> + - windows - 64 - vs2017 - compile <nl> - name : read_only <nl> - name : read_only_sharded <nl> - name : replica_sets <nl> buildvariants : <nl> - name : replica_sets_multi_stmt_txn_jscore_passthrough <nl> distros : <nl> - windows - 64 - vs2017 - compile <nl> - - name : replica_sets_multi_stmt_txn_stepdown_jscore_passthrough_gen <nl> + - name : replica_sets_multi_stmt_txn_stepdown_jscore_passthrough <nl> + distros : <nl> + - windows - 64 - vs2017 - compile <nl> - name : replica_sets_kill_primary_jscore_passthrough <nl> distros : <nl> - windows - 64 - vs2017 - compile <nl> buildvariants : <nl> - name : replica_sets_kill_secondaries_jscore_passthrough <nl> distros : <nl> - windows - 64 - vs2017 - compile <nl> - - name : retryable_writes_jscore_passthrough_gen <nl> + - name : retryable_writes_jscore_passthrough <nl> + distros : <nl> + - windows - 64 - vs2017 - compile <nl> - name : retryable_writes_jscore_stepdown_passthrough <nl> distros : <nl> - windows - 64 - vs2017 - compile <nl> - name : session_jscore_passthrough <nl> - - name : sharding_gen <nl> + - name : sharding <nl> + distros : <nl> + - windows - 64 - vs2017 - compile <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - windows - 64 - vs2017 - compile <nl> - name : jsCore <nl> - name : replica_sets <nl> - - name : sharding_gen <nl> + - name : sharding <nl> <nl> - name : enterprise - windows - 64 - 2k8 - inmem <nl> display_name : Enterprise Windows 2008R2 ( inMemory ) <nl> buildvariants : <nl> multiversion_edition : enterprise <nl> tooltags : " ssl sasl " <nl> build_mongoreplay : false <nl> - large_distro_name : windows - 64 - vs2017 - compile <nl> display_tasks : <nl> - * dbtest <nl> - * unittests <nl> buildvariants : <nl> distros : <nl> - windows - 64 - vs2017 - compile <nl> - name : audit <nl> - - name : auth_audit_gen <nl> + - name : auth_audit <nl> - name : concurrency <nl> - name : concurrency_replication <nl> - name : concurrency_replication_causal_consistency <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : read_concern_linearizable_passthrough <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> + - name : sharding_auth <nl> + distros : <nl> + - windows - 64 - vs2017 - compile <nl> + - name : sharding_auth_audit <nl> + distros : <nl> + - windows - 64 - vs2017 - compile <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> <nl> - name : windows - 64 - 2k8 - ssl <nl> display_name : Windows 2008R2 <nl> buildvariants : <nl> use_scons_cache : true <nl> tooltags : " ssl " <nl> build_mongoreplay : false <nl> - large_distro_name : windows - 64 - vs2017 - compile <nl> display_tasks : <nl> - * dbtest <nl> - * unittests <nl> buildvariants : <nl> - name : aggregation_one_shard_sharded_collections <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : bulk_gle_passthrough <nl> - name : concurrency <nl> - name : concurrency_replication <nl> buildvariants : <nl> - name : jstestfuzz_sharded_causal_consistency_gen <nl> - name : jstestfuzz_sharded_continuous_stepdown_gen <nl> - name : jstestfuzz_sharded_session_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - name : multiversion <nl> - name : multiversion_auth <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : powercycle <nl> buildvariants : <nl> - name : powercycle_replication <nl> - name : powercycle_syncdelay <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - name : replica_sets_jscore_passthrough <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> + - name : sharding <nl> + distros : <nl> + - windows - 64 - vs2017 - compile <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : slow1_gen <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + distros : <nl> + - windows - 64 - vs2017 - compile <nl> + - name : slow1 <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - name : aggregation_one_shard_sharded_collections <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : bulk_gle_passthrough <nl> - - name : causally_consistent_jscore_passthrough_gen <nl> - - name : causally_consistent_jscore_passthrough_auth_gen <nl> - - name : sharded_causally_consistent_jscore_passthrough_gen <nl> + - name : causally_consistent_jscore_passthrough <nl> + - name : causally_consistent_jscore_passthrough_auth <nl> + - name : sharded_causally_consistent_jscore_passthrough <nl> - name : change_streams <nl> - name : change_streams_mongos_passthrough <nl> - name : change_streams_mongos_sessions_passthrough <nl> buildvariants : <nl> - name : jstestfuzz_sharded_gen <nl> - name : jstestfuzz_sharded_causal_consistency_gen <nl> - name : jstestfuzz_sharded_session_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - name : replica_sets_jscore_passthrough <nl> - name : replica_sets_kill_secondaries_jscore_passthrough <nl> - - name : retryable_writes_jscore_passthrough_gen <nl> + - name : retryable_writes_jscore_passthrough <nl> - name : rollback_fuzzer_gen <nl> - name : rollback_fuzzer_clean_shutdowns_gen <nl> - name : rollback_fuzzer_unclean_shutdowns_gen <nl> - name : serial_run <nl> - name : session_jscore_passthrough <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> buildvariants : <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : slow1_gen <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : slow1 <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> tasks : <nl> - name : compile_all_run_unittests_TG <nl> - name : aggregation <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : jsCore <nl> buildvariants : <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - name : mongosTest <nl> - name : replica_sets <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> tasks : <nl> - name : compile_all_run_unittests_TG <nl> - name : audit <nl> - - name : auth_audit_gen <nl> + - name : auth_audit <nl> - name : ese <nl> - name : jsCore <nl> - name : jsCore_auth <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : push <nl> distros : <nl> - rhel70 - small <nl> buildvariants : <nl> tasks : <nl> - name : compile_all_run_unittests_TG <nl> - name : audit <nl> - - name : auth_audit_gen <nl> + - name : auth_audit <nl> - name : ese <nl> - name : jsCore <nl> - name : jsCore_auth <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> <nl> - name : enterprise - osx - 1011 - xcode - 10 - cxx17 <nl> display_name : ~ Enterprise macOS 10 . 11 ( XCode 10 C + + 17 ) <nl> buildvariants : <nl> tasks : <nl> - name : compile_all_run_unittests_TG <nl> - name : audit <nl> - - name : auth_audit_gen <nl> + - name : auth_audit <nl> - name : ese <nl> - name : jsCore <nl> - name : jsCore_auth <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> <nl> buildvariants : <nl> tasks : <nl> - name : compile_all_run_unittests_TG <nl> - name : audit <nl> - - name : auth_audit_gen <nl> + - name : auth_audit <nl> - name : ese <nl> - name : jsCore <nl> - name : jsCore_auth <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : sasl <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> buildvariants : <nl> - name : aggregation_one_shard_sharded_collections <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : buildscripts_test <nl> - name : bulk_gle_passthrough <nl> - name : change_streams <nl> buildvariants : <nl> - name : change_streams_whole_cluster_mongos_passthrough <nl> - name : change_streams_whole_cluster_secondary_reads_passthrough <nl> - name : change_streams_whole_cluster_sharded_collections_passthrough <nl> - - name : causally_consistent_jscore_passthrough_gen <nl> - - name : causally_consistent_jscore_passthrough_auth_gen <nl> - - name : sharded_causally_consistent_jscore_passthrough_gen <nl> + - name : causally_consistent_jscore_passthrough <nl> + - name : causally_consistent_jscore_passthrough_auth <nl> + - name : sharded_causally_consistent_jscore_passthrough <nl> - name : concurrency <nl> - name : concurrency_replication <nl> - name : concurrency_replication_causal_consistency <nl> buildvariants : <nl> - name : jstestfuzz_sharded_causal_consistency_gen <nl> - name : jstestfuzz_sharded_continuous_stepdown_gen <nl> - name : jstestfuzz_sharded_session_gen <nl> - - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_default_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_default_refresh_jscore_passthrough <nl> - name : multiversion <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> buildvariants : <nl> - name : replica_sets_kill_secondaries_jscore_passthrough <nl> distros : <nl> - rhel62 - large <nl> - - name : retryable_writes_jscore_passthrough_gen <nl> + - name : retryable_writes_jscore_passthrough <nl> + distros : <nl> + - rhel62 - large <nl> - name : sasl <nl> - name : session_jscore_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_multi_stmt_txn_jscore_passthrough <nl> - name : sharding_gen <nl> buildvariants : <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : sharding_csrs_continuous_config_stepdown_gen <nl> + - name : sharding_csrs_continuous_config_stepdown <nl> + distros : <nl> + - rhel62 - large <nl> - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : tool <nl> - name : update_fuzzer_gen <nl> - name : update_fuzzer_replication_gen <nl> - name : write_concern_majority_passthrough <nl> distros : <nl> - rhel62 - large <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> + distros : <nl> + - rhel62 - large <nl> <nl> - name : enterprise - rhel - 62 - 64 - bit - required - majority - read - concern - off <nl> display_name : " ! Enterprise RHEL 6 . 2 ( majority read concern off ) " <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - name : change_streams <nl> - name : change_streams_mongos_passthrough <nl> buildvariants : <nl> - name : jsCore_op_query <nl> - name : jsCore_txns <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough_gen <nl> - - name : multi_shard_multi_stmt_txn_jscore_passthrough_gen <nl> + - name : multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough <nl> + - name : multi_shard_multi_stmt_txn_jscore_passthrough <nl> - name : multiversion_auth <nl> - name : multiversion <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : read_only <nl> - name : read_only_sharded <nl> - name : replica_sets <nl> - - name : replica_sets_ese_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_ese <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : replica_sets_initsync_jscore_passthrough <nl> - name : replica_sets_initsync_static_jscore_passthrough <nl> - name : replica_sets_multi_stmt_txn_jscore_passthrough <nl> - - name : replica_sets_multi_stmt_txn_stepdown_jscore_passthrough_gen <nl> + - name : replica_sets_multi_stmt_txn_stepdown_jscore_passthrough <nl> - name : replica_sets_kill_primary_jscore_passthrough <nl> - name : replica_sets_terminate_primary_jscore_passthrough <nl> - name : replica_sets_kill_secondaries_jscore_passthrough <nl> - - name : retryable_writes_jscore_passthrough_gen <nl> + - name : retryable_writes_jscore_passthrough <nl> - name : sasl <nl> - name : session_jscore_passthrough <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharded_multi_stmt_txn_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_ese_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> + - name : sharding <nl> + - name : sharding_ese <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : sharding_op_query_gen <nl> - - name : sharding_csrs_continuous_config_stepdown_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + - name : sharding_op_query <nl> + - name : sharding_csrs_continuous_config_stepdown <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : update_fuzzer_gen <nl> - name : update_fuzzer_replication_gen <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> <nl> - & enterprise - rhel - 70 - 64 - bit - template <nl> name : enterprise - rhel - 70 - 64 - bit <nl> buildvariants : <nl> distros : <nl> - rhel70 <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : benchmarks_orphaned <nl> - name : benchmarks_sharding <nl> - name : ese <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : external_auth <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : package <nl> buildvariants : <nl> name : hot_backups - rhel - 70 - 64 - bit <nl> display_name : " hot_backups RHEL 7 . 0 " <nl> batchtime : 1440 # 1 day <nl> - run_on : <nl> - - rhel70 <nl> expansions : <nl> < < : * enterprise - rhel - 70 - 64 - bit - expansions - template <nl> compile_flags : - - ssl - - use - cpu - profiler MONGO_DISTMOD = rhel70 - j $ ( grep - c ^ processor / proc / cpuinfo ) - - release - - variables - files = etc / scons / mongodbtoolchain_gcc . vars - - enterprise - features = hot_backups <nl> has_packages : false <nl> tasks : <nl> - name : compile_all_run_unittests_TG <nl> + distros : <nl> + - rhel70 <nl> - name : jsCore <nl> - - name : noPassthrough_gen <nl> + distros : <nl> + - rhel70 <nl> + - name : noPassthrough <nl> + distros : <nl> + - rhel70 <nl> <nl> - name : ubuntu1604 - debug <nl> display_name : " * Ubuntu 16 . 04 DEBUG " <nl> buildvariants : <nl> - ubuntu1604 - build <nl> - name : jsCore <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets_jscore_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> <nl> buildvariants : <nl> - rhel62 - large <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : failpoints_auth <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_default_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_default_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_100ms_refresh_jscore_passthrough <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_10sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_default_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_100ms_refresh_jscore_passthrough <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_10sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_default_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - name : multiversion <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : tool <nl> - name : package <nl> distros : <nl> buildvariants : <nl> - rhel70 <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : failpoints_auth <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - name : multiversion <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> distros : <nl> - rhel70 <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : sharding_jscore_passthrough <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - name : concurrency <nl> - name : concurrency_replication <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_ese_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_ese <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> - - name : sharding_ese_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> - - name : sharding_csrs_continuous_config_stepdown_gen <nl> + - name : sharding <nl> + - name : sharding_ese <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> + - name : sharding_csrs_continuous_config_stepdown <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> - name : publish_packages <nl> distros : <nl> - rhel70 - small <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - name : concurrency <nl> - name : concurrency_replication <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_ese_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_ese <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> - - name : sharding_ese_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> - - name : sharding_csrs_continuous_config_stepdown_gen <nl> + - name : sharding <nl> + - name : sharding_ese <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> + - name : sharding_csrs_continuous_config_stepdown <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> - name : publish_packages <nl> distros : <nl> - rhel70 - small <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - name : concurrency <nl> - name : concurrency_replication <nl> buildvariants : <nl> - name : jsCore_op_query <nl> - name : jsCore_txns <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_ese_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_ese <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> - - name : sharding_ese_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> - - name : sharding_csrs_continuous_config_stepdown_gen <nl> + - name : sharding <nl> + - name : sharding_ese <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> + - name : sharding_csrs_continuous_config_stepdown <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> - name : publish_packages <nl> distros : <nl> - rhel62 - large <nl> buildvariants : <nl> - rhel72 - zseries - build <nl> - name : jsCore <nl> - name : replica_sets_jscore_passthrough <nl> - - name : ssl_gen <nl> + - name : ssl <nl> - name : publish_packages <nl> distros : <nl> - rhel70 <nl> buildvariants : <nl> - rhel67 - zseries - build <nl> - name : jsCore <nl> - name : replica_sets_jscore_passthrough <nl> - - name : ssl_gen <nl> + - name : ssl <nl> - name : publish_packages <nl> distros : <nl> - rhel62 - large <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharding_auth_gen <nl> + - name : sharding_auth <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : package <nl> distros : <nl> - ubuntu1604 - packer <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharding_auth_gen <nl> + - name : sharding_auth <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : watchdog_inmemory <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharding_auth_gen <nl> + - name : sharding_auth <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : package <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - name : concurrency <nl> - name : concurrency_replication <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_ese_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_ese <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> - - name : sharding_ese_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> - - name : sharding_csrs_continuous_config_stepdown_gen <nl> + - name : sharding <nl> + - name : sharding_ese <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> + - name : sharding_csrs_continuous_config_stepdown <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> - name : publish_packages <nl> distros : <nl> - suse12 - test <nl> buildvariants : <nl> - suse12 - zseries - build <nl> - name : jsCore <nl> - name : replica_sets_jscore_passthrough <nl> - - name : ssl_gen <nl> + - name : ssl <nl> - name : publish_packages <nl> distros : <nl> - suse12 - test <nl> buildvariants : <nl> - suse12 - build <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : failpoints_auth <nl> buildvariants : <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - name : multiversion <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharding_auth_gen <nl> + - name : sharding_auth <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : package <nl> buildvariants : <nl> - debian81 - build <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : failpoints_auth <nl> buildvariants : <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - name : multiversion <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharding_auth_gen <nl> + - name : sharding_auth <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : package <nl> buildvariants : <nl> - debian92 - build <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : failpoints_auth <nl> buildvariants : <nl> - name : jstestfuzz_sharded_gen <nl> - name : mongosTest <nl> - name : multiversion <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> buildvariants : <nl> - name : concurrency_sharded_replication_with_balancer <nl> - name : concurrency_simultaneous <nl> - name : concurrency_simultaneous_replication <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> buildvariants : <nl> scons_cache_scope : shared <nl> tooltags : " ssl sasl " <nl> build_mongoreplay : true <nl> - large_distro_name : rhel62 - large <nl> display_tasks : <nl> - * dbtest <nl> - * unittests <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - - name : causally_consistent_jscore_passthrough_gen <nl> - - name : causally_consistent_jscore_passthrough_auth_gen <nl> - - name : sharded_causally_consistent_jscore_passthrough_gen <nl> + - name : causally_consistent_jscore_passthrough <nl> + - name : causally_consistent_jscore_passthrough_auth <nl> + - name : sharded_causally_consistent_jscore_passthrough <nl> - name : change_streams <nl> - name : change_streams_mongos_passthrough <nl> - name : change_streams_mongos_sessions_passthrough <nl> buildvariants : <nl> - name : jstestfuzz_sharded_gen <nl> - name : jstestfuzz_sharded_session_gen <nl> - name : jstestfuzz_sharded_causal_consistency_gen <nl> - - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_default_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_default_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_100ms_refresh_jscore_passthrough <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_10sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_default_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_100ms_refresh_jscore_passthrough <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_10sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_default_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - - name : retryable_writes_jscore_passthrough_gen <nl> + - name : retryable_writes_jscore_passthrough <nl> - name : retryable_writes_jscore_stepdown_passthrough <nl> - name : rollback_fuzzer_gen <nl> - name : sasl <nl> - name : session_jscore_passthrough <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharded_collections_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : tool <nl> - name : update_fuzzer_gen <nl> - name : update_fuzzer_replication_gen <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> + distros : <nl> + - rhel62 - large <nl> <nl> - name : enterprise - rhel - 62 - 64 - bit - required - inmem <nl> display_name : " ! Enterprise RHEL 6 . 2 ( inMemory ) " <nl> buildvariants : <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - name : aggregation_facet_unwind_passthrough <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : concurrency <nl> - name : benchrun_embedded_aggregation <nl> distros : <nl> buildvariants : <nl> - name : jsonSchema <nl> - name : jstestfuzz_gen <nl> - name : jstestfuzz_concurrent_gen <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : powercycle_mobile <nl> - name : serial_run <nl> - name : session_jscore_passthrough <nl> buildvariants : <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - name : aggregation_facet_unwind_passthrough <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : concurrency <nl> - name : disk_mobile <nl> - name : failpoints <nl> buildvariants : <nl> - name : jsonSchema <nl> - name : jstestfuzz_gen <nl> - name : jstestfuzz_concurrent_gen <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : serial_run <nl> - name : session_jscore_passthrough <nl> <nl> buildvariants : <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - name : aggregation_facet_unwind_passthrough <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : concurrency <nl> - name : disk_mobile <nl> - name : failpoints <nl> buildvariants : <nl> - name : jsonSchema <nl> - name : jstestfuzz_gen <nl> - name : jstestfuzz_concurrent_gen <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : serial_run <nl> - name : session_jscore_passthrough <nl> <nl> buildvariants : <nl> - rhel62 - large <nl> - name : aggregation <nl> - name : aggregation_auth <nl> - - name : auth_gen <nl> + - name : auth <nl> - name : concurrency <nl> distros : <nl> - rhel62 - large # Some workloads require a lot of memory , use a bigger machine for this suite . <nl> buildvariants : <nl> - name : jstestfuzz_concurrent_sharded_gen <nl> - name : jstestfuzz_replication_gen <nl> - name : jstestfuzz_sharded_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : bulk_gle_passthrough <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : rollback_fuzzer_gen <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> - name : tool <nl> - name : update_fuzzer_gen <nl> - name : update_fuzzer_replication_gen <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - name : concurrency <nl> - name : concurrency_replication <nl> buildvariants : <nl> - name : jsCore_op_query <nl> - name : jsCore_txns <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : tool <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> <nl> - name : enterprise - rhel - 72 - s390x - inmem <nl> display_name : Enterprise RHEL 7 . 2 s390x ( inMemory ) DEBUG <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - name : concurrency <nl> distros : <nl> buildvariants : <nl> - name : jsCore_op_query <nl> - name : jsCore_txns <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : noPassthrough_gen <nl> - - name : noPassthroughWithMongod_gen <nl> + - name : noPassthrough <nl> + - name : noPassthroughWithMongod <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : replica_sets <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : sasl <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> + - name : sharding <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : tool <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - - name : causally_consistent_jscore_passthrough_gen <nl> - - name : causally_consistent_jscore_passthrough_auth_gen <nl> - - name : sharded_causally_consistent_jscore_passthrough_gen <nl> + - name : causally_consistent_jscore_passthrough <nl> + - name : causally_consistent_jscore_passthrough_auth <nl> + - name : sharded_causally_consistent_jscore_passthrough <nl> - name : change_streams <nl> - name : change_streams_mongos_passthrough <nl> - name : change_streams_mongos_sessions_passthrough <nl> buildvariants : <nl> - name : jsCore_txns <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - name : jsonSchema <nl> - - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_replication_default_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_100ms_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_10sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_replication_default_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_100ms_refresh_jscore_passthrough <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_10sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_sharding_default_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_100ms_refresh_jscore_passthrough <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_10sec_refresh_jscore_passthrough <nl> - name : logical_session_cache_standalone_default_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough_gen <nl> - - name : multi_shard_multi_stmt_txn_jscore_passthrough_gen <nl> + - name : multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough <nl> + - name : multi_shard_multi_stmt_txn_jscore_passthrough <nl> - name : multiversion_auth <nl> - name : multiversion <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : read_only <nl> - name : read_only_sharded <nl> - name : replica_sets <nl> - - name : replica_sets_ese_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_ese <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : replica_sets_initsync_jscore_passthrough <nl> - name : replica_sets_initsync_static_jscore_passthrough <nl> - name : replica_sets_multi_stmt_txn_jscore_passthrough <nl> - - name : replica_sets_multi_stmt_txn_stepdown_jscore_passthrough_gen <nl> + - name : replica_sets_multi_stmt_txn_stepdown_jscore_passthrough <nl> - name : replica_sets_kill_primary_jscore_passthrough <nl> - name : replica_sets_terminate_primary_jscore_passthrough <nl> - name : replica_sets_kill_secondaries_jscore_passthrough <nl> - - name : retryable_writes_jscore_passthrough_gen <nl> + - name : retryable_writes_jscore_passthrough <nl> - name : retryable_writes_jscore_stepdown_passthrough <nl> - name : sasl <nl> - name : session_jscore_passthrough <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharded_multi_stmt_txn_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_ese_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> + - name : sharding <nl> + - name : sharding_ese <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> - name : update_fuzzer_gen <nl> - name : update_fuzzer_replication_gen <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> <nl> - name : ubuntu1604 - asan <nl> display_name : ~ ASAN SSL Ubuntu 16 . 04 <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - - name : causally_consistent_jscore_passthrough_gen <nl> - - name : causally_consistent_jscore_passthrough_auth_gen <nl> - - name : sharded_causally_consistent_jscore_passthrough_gen <nl> + - name : causally_consistent_jscore_passthrough <nl> + - name : causally_consistent_jscore_passthrough_auth <nl> + - name : sharded_causally_consistent_jscore_passthrough <nl> - name : change_streams <nl> - name : change_streams_mongos_passthrough <nl> - name : change_streams_mongos_sessions_passthrough <nl> buildvariants : <nl> - name : jsCore_txns <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - name : jsonSchema <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - - name : multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough_gen <nl> - - name : multi_shard_multi_stmt_txn_jscore_passthrough_gen <nl> + - name : multi_shard_local_read_write_multi_stmt_txn_jscore_passthrough <nl> + - name : multi_shard_multi_stmt_txn_jscore_passthrough <nl> - name : multiversion_auth <nl> - name : multiversion <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : read_only <nl> - name : read_only_sharded <nl> - name : replica_sets <nl> - - name : replica_sets_ese_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_ese <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : replica_sets_initsync_jscore_passthrough <nl> - name : replica_sets_initsync_static_jscore_passthrough <nl> - name : replica_sets_multi_stmt_txn_jscore_passthrough <nl> - - name : replica_sets_multi_stmt_txn_stepdown_jscore_passthrough_gen <nl> + - name : replica_sets_multi_stmt_txn_stepdown_jscore_passthrough <nl> - name : replica_sets_kill_primary_jscore_passthrough <nl> - name : replica_sets_terminate_primary_jscore_passthrough <nl> - name : replica_sets_kill_secondaries_jscore_passthrough <nl> - - name : retryable_writes_jscore_passthrough_gen <nl> + - name : retryable_writes_jscore_passthrough <nl> - name : retryable_writes_jscore_stepdown_passthrough <nl> - name : sasl <nl> - name : session_jscore_passthrough <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - name : sharded_multi_stmt_txn_jscore_passthrough <nl> - - name : sharding_gen <nl> - - name : sharding_ese_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> + - name : sharding <nl> + - name : sharding_ese <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : stitch_support_lib_build_and_test <nl> - name : stitch_support_lib_build_and_archive <nl> - name : tool <nl> - name : update_fuzzer_gen <nl> - name : update_fuzzer_replication_gen <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> <nl> - name : ubuntu1604 - debug - aubsan - lite <nl> display_name : " ! { A , UB } SAN Enterprise SSL Ubuntu 16 . 04 DEBUG " <nl> buildvariants : <nl> - name : aggregation_read_concern_majority_passthrough <nl> - name : aggregation_sharded_collections_passthrough <nl> - name : audit <nl> - - name : auth_gen <nl> - - name : auth_audit_gen <nl> + - name : auth <nl> + - name : auth_audit <nl> - name : bulk_gle_passthrough <nl> - - name : causally_consistent_jscore_passthrough_gen <nl> - - name : causally_consistent_jscore_passthrough_auth_gen <nl> - - name : sharded_causally_consistent_jscore_passthrough_gen <nl> + - name : causally_consistent_jscore_passthrough <nl> + - name : causally_consistent_jscore_passthrough_auth <nl> + - name : sharded_causally_consistent_jscore_passthrough <nl> - name : concurrency <nl> - name : concurrency_replication <nl> - name : concurrency_replication_causal_consistency <nl> buildvariants : <nl> - name : jsCore_op_query <nl> - name : jsCore_txns <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough_gen <nl> - - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough_gen <nl> + - name : logical_session_cache_replication_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_sharding_1sec_refresh_jscore_passthrough <nl> + - name : logical_session_cache_standalone_1sec_refresh_jscore_passthrough <nl> - name : mongosTest <nl> - name : multiversion_auth <nl> - name : multiversion <nl> - - name : noPassthroughWithMongod_gen <nl> - - name : noPassthrough_gen <nl> + - name : noPassthroughWithMongod <nl> + - name : noPassthrough <nl> - name : parallel <nl> - name : parallel_compatibility <nl> - name : read_concern_linearizable_passthrough <nl> - - name : read_concern_majority_passthrough_gen <nl> + - name : read_concern_majority_passthrough <nl> - name : read_only <nl> - name : read_only_sharded <nl> - name : replica_sets <nl> - - name : replica_sets_ese_gen <nl> - - name : replica_sets_auth_gen <nl> + - name : replica_sets_ese <nl> + - name : replica_sets_auth <nl> - name : replica_sets_jscore_passthrough <nl> - name : replica_sets_initsync_jscore_passthrough <nl> - name : replica_sets_initsync_static_jscore_passthrough <nl> - name : replica_sets_kill_secondaries_jscore_passthrough <nl> - name : sasl <nl> - - name : sharded_causally_consistent_jscore_txns_passthrough_gen <nl> + - name : sharded_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_causally_consistent_jscore_txns_passthrough <nl> - name : sharded_collections_jscore_passthrough <nl> - name : sharded_jscore_txns <nl> - name : sharded_jscore_txns_sharded_collections <nl> - - name : sharding_gen <nl> - - name : sharding_ese_gen <nl> - - name : sharding_auth_gen <nl> - - name : sharding_auth_audit_gen <nl> + - name : sharding <nl> + - name : sharding_ese <nl> + - name : sharding_auth <nl> + - name : sharding_auth_audit <nl> - name : sharding_gle_auth_basics_passthrough <nl> - name : sharding_gle_auth_basics_passthrough_write_cmd <nl> - - name : sharding_last_stable_mongos_and_mixed_shards_gen <nl> + - name : sharding_last_stable_mongos_and_mixed_shards <nl> - name : sharding_jscore_passthrough <nl> - name : sharding_jscore_op_query_passthrough <nl> - - name : sharding_jscore_passthrough_wire_ops_gen <nl> - - name : sharding_op_query_gen <nl> - - name : slow1_gen <nl> + - name : sharding_jscore_passthrough_wire_ops <nl> + - name : sharding_op_query <nl> + - name : slow1 <nl> - name : serial_run <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> - name : tool <nl> - name : write_concern_majority_passthrough <nl> - - name : secondary_reads_passthrough_gen <nl> + - name : secondary_reads_passthrough <nl> <nl> - name : enterprise - ubuntu - dynamic - 1604 - 64 - bit <nl> display_name : " * Shared Library Enterprise Ubuntu 16 . 04 " <nl> buildvariants : <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - name : sasl <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> <nl> - name : enterprise - ubuntu1804 - 64 - v3 - toolchain - canary - clang - debug <nl> display_name : Enterprise Ubuntu 18 . 04 ( Toolchain V3 Clang Canary Builder ) DEBUG <nl> buildvariants : <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - name : sasl <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl> <nl> - name : windows - 64 - vs2017 - cxx17 <nl> display_name : " Windows VS2017 Canary C + + 17 Builder " <nl> buildvariants : <nl> - name : causally_consistent_jscore_txns_passthrough <nl> - name : sasl <nl> - name : snmp <nl> - - name : ssl_gen <nl> - - name : sslSpecial_gen <nl> + - name : ssl <nl> + - name : sslSpecial <nl>
|
Revert " SERVER - 39127 : Split long - running tasks on all variants "
|
mongodb/mongo
|
bbe09aa5e0966ada5232ffbcb098efdd78b4f24e
|
2019-01-25T14:22:26Z
|
mmm a / include / grpcpp / impl / codegen / core_codegen_interface . h <nl> ppp b / include / grpcpp / impl / codegen / core_codegen_interface . h <nl> namespace grpc { <nl> / / / \ warning This interface should be considered internal and private . <nl> class CoreCodegenInterface { <nl> public : <nl> + virtual ~ CoreCodegenInterface ( ) = default ; <nl> + <nl> / / / Upon a failed assertion , log the error . <nl> virtual void assert_fail ( const char * failed_assertion , const char * file , <nl> int line ) = 0 ; <nl> mmm a / include / grpcpp / impl / codegen / grpc_library . h <nl> ppp b / include / grpcpp / impl / codegen / grpc_library . h <nl> namespace grpc { <nl> <nl> class GrpcLibraryInterface { <nl> public : <nl> + virtual ~ GrpcLibraryInterface ( ) = default ; <nl> virtual void init ( ) = 0 ; <nl> virtual void shutdown ( ) = 0 ; <nl> } ; <nl>
|
Merge pull request from toanju / fix - non - virtual - dtor
|
grpc/grpc
|
48bdcab141a665a44444f534ef59fecfbd7e93e3
|
2018-02-16T17:37:19Z
|
mmm a / tools / esptool <nl> ppp b / tools / esptool <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit de30f21a222ec62f5a023dd955439b4f57702768 <nl> + Subproject commit 4fa0bd7b0d1f69f5ff22b043adc07c5e562a8931 <nl> mmm a / tools / pyserial <nl> ppp b / tools / pyserial <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit c54c81d933b847458d465cd77e96cd702ff2e7be <nl> + Subproject commit 0e7634747568547b8a7f9fd0c48ed74f16af4b23 <nl> mmm a / tools / upload . py <nl> ppp b / tools / upload . py <nl> <nl> cmdline = cmdline + [ ' write_flash ' ] <nl> if len ( write_option ) : <nl> cmdline = cmdline + [ write_option ] <nl> + cmdline = cmdline + [ ' - - flash_size ' , ' detect ' ] <nl> cmdline = cmdline + [ write_addr , binary ] <nl> <nl> erase_file = ' ' <nl>
|
Update to pyserial 3 . 5 , esptool 3 . 0 ( )
|
esp8266/Arduino
|
8565ac8fbc4683a08640dae219992da1947e40a3
|
2020-12-02T01:41:23Z
|
mmm a / db / storage . cpp <nl> ppp b / db / storage . cpp <nl> void BasicRecStore : : init ( const char * fn , unsigned recsize ) <nl> log ( ) < < " warning : non - clean shutdown for file " < < fn < < ' \ n ' ; <nl> h . cleanShutdown = 2 ; <nl> writeHeader ( ) ; <nl> + f . fsync ( ) ; <nl> } <nl> # if defined ( _RECSTORE ) <nl> boost : : thread t ( writerThread ) ; <nl>
|
minor recstore
|
mongodb/mongo
|
176c9a1e255115f5abdaf8a39c9b084b3560dc6a
|
2009-02-06T20:56:36Z
|
mmm a / lib / SILOptimizer / Mandatory / PredictableMemOpt . cpp <nl> ppp b / lib / SILOptimizer / Mandatory / PredictableMemOpt . cpp <nl> class AvailableValueAggregator { <nl> / / / ownership is enabled . <nl> void addMissingDestroysForCopiedValues ( LoadBorrowInst * li , SILValue newVal , <nl> const SmallBitVector & instsToSkip ) ; <nl> - void addHandOffCopyDestroysForPhis ( LoadBorrowInst * li , SILValue newVal , <nl> - SmallBitVector & instsToSkipOut ) ; <nl> + <nl> + / / / As a result of us using the SSA updater , insert hand off copy / destroys at <nl> + / / / each phi and make sure that intermediate phis do not leak by inserting <nl> + / / / destroys along paths that go through the intermediate phi that do not also <nl> + / / / go through the <nl> + void addHandOffCopyDestroysForPhis ( SILInstruction * load , SILValue newVal , <nl> + SmallBitVector & instsToSkipOut ) ; <nl> } ; <nl> <nl> } / / end anonymous namespace <nl> AvailableValueAggregator : : addMissingDestroysForCopiedValues ( LoadInst * li , <nl> return nullptr ; <nl> } <nl> <nl> - void AvailableValueAggregator : : addHandOffCopyDestroysForPhis ( LoadBorrowInst * lbi , SILValue newVal , <nl> - SmallBitVector & instsToSkip ) { <nl> + void AvailableValueAggregator : : addHandOffCopyDestroysForPhis ( <nl> + SILInstruction * load , SILValue newVal , SmallBitVector & instsToSkip ) { <nl> + assert ( isa < LoadBorrowInst > ( load ) | | isa < LoadInst > ( load ) ) ; <nl> + <nl> ValueLifetimeAnalysis : : Frontier lifetimeFrontier ; <nl> SmallPtrSet < SILBasicBlock * , 8 > visitedBlocks ; <nl> SmallVector < SILBasicBlock * , 8 > leakingBlocks ; <nl> void AvailableValueAggregator : : addHandOffCopyDestroysForPhis ( LoadBorrowInst * lbi <nl> auto errorKind = ownership : : ErrorBehaviorKind : : ReturnFalse ; <nl> LinearLifetimeChecker checker ( visitedBlocks , deadEndBlocks ) ; <nl> auto error = checker . checkValue ( <nl> - phiArg , { BranchPropagatedUser ( & lbi - > getAllOperands ( ) [ 0 ] ) } , { } , <nl> + phiArg , { BranchPropagatedUser ( & load - > getAllOperands ( ) [ 0 ] ) } , { } , <nl> errorKind , & leakingBlocks ) ; <nl> <nl> if ( ! error . getFoundError ( ) ) { <nl> / / If we did not find an error , then our copy_value must be strongly <nl> / / control equivalent as our load_borrow . So just insert a destroy_value <nl> / / for the copy_value . <nl> - auto next = std : : next ( lbi - > getIterator ( ) ) ; <nl> + auto next = std : : next ( load - > getIterator ( ) ) ; <nl> SILBuilderWithScope builder ( next ) ; <nl> builder . emitDestroyValueOperation ( next - > getLoc ( ) , phiArg ) ; <nl> continue ; <nl> void AvailableValueAggregator : : addHandOffCopyDestroysForPhis ( LoadBorrowInst * lbi <nl> / / this if we found a loop since our leaking blocks will lifetime extend the <nl> / / value over the loop . <nl> if ( ! error . getFoundOverConsume ( ) ) { <nl> - auto next = std : : next ( lbi - > getIterator ( ) ) ; <nl> + auto next = std : : next ( load - > getIterator ( ) ) ; <nl> SILBuilderWithScope builder ( next ) ; <nl> builder . emitDestroyValueOperation ( next - > getLoc ( ) , phiArg ) ; <nl> } <nl>
|
Merge pull request from gottesmm / pr - fe75266370825e5d95381c70f6bf20f16b738542
|
apple/swift
|
16ea9fa3f063c3a2febacf5a55a8183cf0434de3
|
2019-11-15T02:20:30Z
|
mmm a / src / redis / pubsub . cc <nl> ppp b / src / redis / pubsub . cc <nl> int pubsub_runtime_t : : publish ( std : : string & channel , std : : string & message ) { <nl> bool match_pattern ( const char * , const char * ) ; <nl> <nl> bool star_match ( const char * chan , const char * patt ) { <nl> - assert ( * patt = = ' * ' ) ; <nl> + rassert ( * patt = = ' * ' ) ; <nl> + + patt ; <nl> <nl> / / If * is the last charater in the pattern than we automatically match the rest of the pattern <nl> bool star_match ( const char * chan , const char * patt ) { <nl> } <nl> <nl> bool group_match ( const char * chan , const char * patt ) { <nl> - assert ( * patt = = ' [ ' ) ; <nl> + rassert ( * patt = = ' [ ' ) ; <nl> + + patt ; <nl> <nl> std : : vector < char > group ; <nl>
|
Replaced assert calls in redis code with rassert .
|
rethinkdb/rethinkdb
|
fe914b30c0f2638165be1f97288380fad53c5925
|
2011-10-27T00:02:36Z
|
mmm a / lib / SILGen / SILGenBuilder . cpp <nl> ppp b / lib / SILGen / SILGenBuilder . cpp <nl> ManagedValue SILGenBuilder : : createTuple ( SILLocation loc , SILType type , <nl> / / We need to look for the first non - trivial value and use that as our cleanup <nl> / / cloner value . <nl> auto iter = find_if ( elements , [ & ] ( ManagedValue mv ) - > bool { <nl> - return mv . getType ( ) . isTrivial ( getModule ( ) ) ; <nl> + return ! mv . getType ( ) . isTrivial ( getModule ( ) ) ; <nl> } ) ; <nl> <nl> llvm : : SmallVector < SILValue , 8 > forwardedValues ; <nl>
|
[ + 0 - normal - args ] Fix a typo in createTuple where we were looking for the first trivial element instead of the first non - trivial element .
|
apple/swift
|
0a5f0547539ea40e9cbb232aac4fc75e6c589f0c
|
2018-02-16T00:43:59Z
|
mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> endif ( ) <nl> <nl> if ( ANDROID OR WIN32 ) <nl> set ( OPENCV_DOC_INSTALL_PATH doc ) <nl> - elseif ( INSTALL_TO_MANGLED_PATHS ) <nl> - set ( OPENCV_DOC_INSTALL_PATH share / OpenCV - $ { OPENCV_VERSION } / doc ) <nl> else ( ) <nl> set ( OPENCV_DOC_INSTALL_PATH share / OpenCV / doc ) <nl> endif ( ) <nl> if ( NOT OPENCV_TEST_INSTALL_PATH ) <nl> set ( OPENCV_TEST_INSTALL_PATH " $ { OPENCV_BIN_INSTALL_PATH } " ) <nl> endif ( ) <nl> <nl> + if ( OPENCV_TEST_DATA_PATH ) <nl> + get_filename_component ( OPENCV_TEST_DATA_PATH $ { OPENCV_TEST_DATA_PATH } ABSOLUTE ) <nl> + endif ( ) <nl> + <nl> if ( OPENCV_TEST_DATA_PATH AND NOT OPENCV_TEST_DATA_INSTALL_PATH ) <nl> if ( ANDROID ) <nl> set ( OPENCV_TEST_DATA_INSTALL_PATH " sdk / etc / testdata " ) <nl> if ( ANDROID ) <nl> set ( OPENCV_CONFIG_INSTALL_PATH sdk / native / jni ) <nl> set ( OPENCV_INCLUDE_INSTALL_PATH sdk / native / jni / include ) <nl> set ( OPENCV_SAMPLES_SRC_INSTALL_PATH samples / native ) <nl> + set ( OPENCV_OTHER_INSTALL_PATH sdk / etc ) <nl> else ( ) <nl> set ( LIBRARY_OUTPUT_PATH " $ { OpenCV_BINARY_DIR } / lib " ) <nl> set ( 3P_LIBRARY_OUTPUT_PATH " $ { OpenCV_BINARY_DIR } / 3rdparty / lib $ { LIB_SUFFIX } " ) <nl> + <nl> if ( WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows ) <nl> if ( OpenCV_STATIC ) <nl> set ( OPENCV_LIB_INSTALL_PATH " $ { OpenCV_INSTALL_BINARIES_PREFIX } staticlib $ { LIB_SUFFIX } " ) <nl> else ( ) <nl> endif ( ) <nl> set ( OPENCV_3P_LIB_INSTALL_PATH " $ { OpenCV_INSTALL_BINARIES_PREFIX } staticlib $ { LIB_SUFFIX } " ) <nl> set ( OPENCV_SAMPLES_SRC_INSTALL_PATH samples / native ) <nl> + set ( OPENCV_JAR_INSTALL_PATH java ) <nl> + set ( OPENCV_OTHER_INSTALL_PATH etc ) <nl> else ( ) <nl> set ( OPENCV_LIB_INSTALL_PATH lib $ { LIB_SUFFIX } ) <nl> set ( OPENCV_3P_LIB_INSTALL_PATH share / OpenCV / 3rdparty / $ { OPENCV_LIB_INSTALL_PATH } ) <nl> set ( OPENCV_SAMPLES_SRC_INSTALL_PATH share / OpenCV / samples ) <nl> + set ( OPENCV_JAR_INSTALL_PATH share / OpenCV / java ) <nl> + set ( OPENCV_OTHER_INSTALL_PATH share / OpenCV ) <nl> endif ( ) <nl> set ( OPENCV_INCLUDE_INSTALL_PATH " include " ) <nl> <nl> set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) <nl> <nl> if ( INSTALL_TO_MANGLED_PATHS ) <nl> set ( OPENCV_INCLUDE_INSTALL_PATH $ { OPENCV_INCLUDE_INSTALL_PATH } / opencv - $ { OPENCV_VERSION } ) <nl> + string ( REPLACE " OpenCV " " OpenCV - $ { OPENCV_VERSION } " OPENCV_3P_LIB_INSTALL_PATH " $ { OPENCV_3P_LIB_INSTALL_PATH } " ) <nl> + string ( REPLACE " OpenCV " " OpenCV - $ { OPENCV_VERSION } " OPENCV_SAMPLES_SRC_INSTALL_PATH " $ { OPENCV_SAMPLES_SRC_INSTALL_PATH } " ) <nl> + string ( REPLACE " OpenCV " " OpenCV - $ { OPENCV_VERSION } " OPENCV_CONFIG_INSTALL_PATH " $ { OPENCV_CONFIG_INSTALL_PATH } " ) <nl> + string ( REPLACE " OpenCV " " OpenCV - $ { OPENCV_VERSION } " OPENCV_DOC_INSTALL_PATH " $ { OPENCV_DOC_INSTALL_PATH } " ) <nl> + string ( REPLACE " OpenCV " " OpenCV - $ { OPENCV_VERSION } " OPENCV_JAR_INSTALL_PATH " $ { OPENCV_JAR_INSTALL_PATH } " ) <nl> + string ( REPLACE " OpenCV " " OpenCV - $ { OPENCV_VERSION } " OPENCV_TEST_DATA_INSTALL_PATH " $ { OPENCV_TEST_DATA_INSTALL_PATH } " ) <nl> + string ( REPLACE " OpenCV " " OpenCV - $ { OPENCV_VERSION } " OPENCV_OTHER_INSTALL_PATH " $ { OPENCV_OTHER_INSTALL_PATH } " ) <nl> endif ( ) <nl> <nl> + <nl> if ( WIN32 ) <nl> # Postfix of DLLs : <nl> set ( OPENCV_DLLVERSION " $ { OPENCV_VERSION_MAJOR } $ { OPENCV_VERSION_MINOR } $ { OPENCV_VERSION_PATCH } " ) <nl> mmm a / cmake / OpenCVGenConfig . cmake <nl> ppp b / cmake / OpenCVGenConfig . cmake <nl> configure_file ( " $ { OpenCV_SOURCE_DIR } / cmake / templates / OpenCVConfig - version . cmake . <nl> set ( OpenCV_INCLUDE_DIRS_CONFIGCMAKE " \ " \ $ { OpenCV_INSTALL_PATH } / $ { OPENCV_INCLUDE_INSTALL_PATH } / opencv " " \ $ { OpenCV_INSTALL_PATH } / $ { OPENCV_INCLUDE_INSTALL_PATH } \ " " ) <nl> <nl> set ( OpenCV2_INCLUDE_DIRS_CONFIGCMAKE " \ " \ " " ) <nl> - if ( INSTALL_TO_MANGLED_PATHS ) <nl> - string ( REPLACE " OpenCV " " OpenCV - $ { OPENCV_VERSION } " OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE " $ { OPENCV_3P_LIB_INSTALL_PATH } " ) <nl> - set ( OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE " \ " \ $ { OpenCV_INSTALL_PATH } / $ { OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE } \ " " ) <nl> - endif ( ) <nl> + set ( OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE " \ " \ $ { OpenCV_INSTALL_PATH } / $ { OPENCV_3P_LIB_INSTALL_PATH } \ " " ) <nl> <nl> if ( UNIX ) # ANDROID configuration is created here also <nl> # http : / / www . vtk . org / Wiki / CMake / Tutorials / Packaging reference <nl> if ( UNIX ) # ANDROID configuration is created here also <nl> # < prefix > / ( share | lib ) / < name > * / ( U ) <nl> # < prefix > / ( share | lib ) / < name > * / ( cmake | CMake ) / ( U ) <nl> if ( USE_IPPICV ) <nl> - if ( INSTALL_TO_MANGLED_PATHS ) <nl> - file ( RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV " $ { CMAKE_INSTALL_PREFIX } / $ { OPENCV_CONFIG_INSTALL_PATH } - $ { OPENCV_VERSION } / " $ { IPPICV_INSTALL_PATH } ) <nl> - else ( ) <nl> - file ( RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV " $ { CMAKE_INSTALL_PREFIX } / $ { OPENCV_CONFIG_INSTALL_PATH } / " $ { IPPICV_INSTALL_PATH } ) <nl> - endif ( ) <nl> + file ( RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV " $ { CMAKE_INSTALL_PREFIX } / $ { OPENCV_CONFIG_INSTALL_PATH } / " $ { IPPICV_INSTALL_PATH } ) <nl> endif ( ) <nl> configure_file ( " $ { OpenCV_SOURCE_DIR } / cmake / templates / OpenCVConfig . cmake . in " " $ { CMAKE_BINARY_DIR } / unix - install / OpenCVConfig . cmake " @ ONLY ) <nl> configure_file ( " $ { OpenCV_SOURCE_DIR } / cmake / templates / OpenCVConfig - version . cmake . in " " $ { CMAKE_BINARY_DIR } / unix - install / OpenCVConfig - version . cmake " @ ONLY ) <nl> - if ( INSTALL_TO_MANGLED_PATHS ) <nl> - install ( FILES $ { CMAKE_BINARY_DIR } / unix - install / OpenCVConfig . cmake DESTINATION $ { OPENCV_CONFIG_INSTALL_PATH } - $ { OPENCV_VERSION } / COMPONENT dev ) <nl> - install ( FILES $ { CMAKE_BINARY_DIR } / unix - install / OpenCVConfig - version . cmake DESTINATION $ { OPENCV_CONFIG_INSTALL_PATH } - $ { OPENCV_VERSION } / COMPONENT dev ) <nl> - install ( EXPORT OpenCVModules DESTINATION $ { OPENCV_CONFIG_INSTALL_PATH } - $ { OPENCV_VERSION } / FILE OpenCVModules $ { modules_file_suffix } . cmake COMPONENT dev ) <nl> - else ( ) <nl> - install ( FILES " $ { CMAKE_BINARY_DIR } / unix - install / OpenCVConfig . cmake " DESTINATION $ { OPENCV_CONFIG_INSTALL_PATH } / COMPONENT dev ) <nl> - install ( FILES $ { CMAKE_BINARY_DIR } / unix - install / OpenCVConfig - version . cmake DESTINATION $ { OPENCV_CONFIG_INSTALL_PATH } / COMPONENT dev ) <nl> - install ( EXPORT OpenCVModules DESTINATION $ { OPENCV_CONFIG_INSTALL_PATH } / FILE OpenCVModules $ { modules_file_suffix } . cmake COMPONENT dev ) <nl> - endif ( ) <nl> + install ( FILES " $ { CMAKE_BINARY_DIR } / unix - install / OpenCVConfig . cmake " DESTINATION $ { OPENCV_CONFIG_INSTALL_PATH } / COMPONENT dev ) <nl> + install ( FILES $ { CMAKE_BINARY_DIR } / unix - install / OpenCVConfig - version . cmake DESTINATION $ { OPENCV_CONFIG_INSTALL_PATH } / COMPONENT dev ) <nl> + install ( EXPORT OpenCVModules DESTINATION $ { OPENCV_CONFIG_INSTALL_PATH } / FILE OpenCVModules $ { modules_file_suffix } . cmake COMPONENT dev ) <nl> endif ( ) <nl> <nl> if ( ANDROID ) <nl> mmm a / data / CMakeLists . txt <nl> ppp b / data / CMakeLists . txt <nl> <nl> file ( GLOB HAAR_CASCADES haarcascades / * . xml ) <nl> file ( GLOB LBP_CASCADES lbpcascades / * . xml ) <nl> <nl> - if ( ANDROID ) <nl> - install ( FILES $ { HAAR_CASCADES } DESTINATION sdk / etc / haarcascades COMPONENT libs ) <nl> - install ( FILES $ { LBP_CASCADES } DESTINATION sdk / etc / lbpcascades COMPONENT libs ) <nl> - else ( ) <nl> - install ( FILES $ { HAAR_CASCADES } DESTINATION share / OpenCV / haarcascades COMPONENT libs ) <nl> - install ( FILES $ { LBP_CASCADES } DESTINATION share / OpenCV / lbpcascades COMPONENT libs ) <nl> - endif ( ) <nl> + install ( FILES $ { HAAR_CASCADES } DESTINATION $ { OPENCV_OTHER_INSTALL_PATH } / haarcascades COMPONENT libs ) <nl> + install ( FILES $ { LBP_CASCADES } DESTINATION $ { OPENCV_OTHER_INSTALL_PATH } / lbpcascades COMPONENT libs ) <nl> <nl> if ( INSTALL_TESTS AND OPENCV_TEST_DATA_PATH ) <nl> install ( DIRECTORY " $ { OPENCV_TEST_DATA_PATH } / " DESTINATION " $ { OPENCV_TEST_DATA_INSTALL_PATH } " COMPONENT " tests " ) <nl> - endif ( ) <nl> \ No newline at end of file <nl> + endif ( ) <nl> mmm a / doc / CMakeLists . txt <nl> ppp b / doc / CMakeLists . txt <nl> if ( HAVE_DOC_GENERATOR ) <nl> set ( FIXED_ORDER_MODULES core imgproc imgcodecs videoio highgui video calib3d features2d objdetect ml flann photo stitching ) <nl> list ( REMOVE_ITEM BASE_MODULES $ { FIXED_ORDER_MODULES } ) <nl> set ( BASE_MODULES $ { FIXED_ORDER_MODULES } $ { BASE_MODULES } ) <nl> - <nl> - set ( DOC_LIST <nl> - " $ { OpenCV_SOURCE_DIR } / doc / opencv - logo . png " <nl> - " $ { OpenCV_SOURCE_DIR } / doc / opencv - logo2 . png " <nl> - " $ { OpenCV_SOURCE_DIR } / doc / opencv - logo - white . png " <nl> - " $ { OpenCV_SOURCE_DIR } / doc / opencv . ico " <nl> - " $ { OpenCV_SOURCE_DIR } / doc / pattern . png " <nl> - " $ { OpenCV_SOURCE_DIR } / doc / acircles_pattern . png " ) <nl> - set ( OPTIONAL_DOC_LIST " " ) <nl> endif ( HAVE_DOC_GENERATOR ) <nl> <nl> # = = = = = = = = = Doxygen docs = = = = = = = = = <nl> if ( BUILD_DOCS AND DOXYGEN_FOUND ) <nl> COMMAND $ { DOXYGEN_EXECUTABLE } $ { doxyfile } <nl> DEPENDS $ { doxyfile } $ { rootfile } $ { bibfile } $ { deps } <nl> ) <nl> + install ( DIRECTORY $ { CMAKE_CURRENT_BINARY_DIR } / doxygen / html <nl> + DESTINATION " $ { OPENCV_DOC_INSTALL_PATH } " <nl> + COMPONENT " docs " OPTIONAL <nl> + ) <nl> endif ( ) <nl> - <nl> - if ( HAVE_DOC_GENERATOR ) <nl> - # installation <nl> - foreach ( f $ { DOC_LIST } ) <nl> - install ( FILES " $ { f } " DESTINATION " $ { OPENCV_DOC_INSTALL_PATH } " COMPONENT docs ) <nl> - endforeach ( ) <nl> - foreach ( f $ { OPTIONAL_DOC_LIST } ) <nl> - install ( FILES " $ { f } " DESTINATION " $ { OPENCV_DOC_INSTALL_PATH } " OPTIONAL COMPONENT docs ) <nl> - endforeach ( ) <nl> - <nl> - # dummy targets <nl> - add_custom_target ( docs ) <nl> - add_custom_target ( html_docs ) <nl> - endif ( HAVE_DOC_GENERATOR ) <nl> mmm a / modules / java / CMakeLists . txt <nl> ppp b / modules / java / CMakeLists . txt <nl> else ( ANDROID ) <nl> COMMENT " Generating $ { JAR_NAME } " <nl> ) <nl> <nl> - if ( WIN32 ) <nl> - set ( JAR_INSTALL_DIR java ) <nl> - else ( WIN32 ) <nl> - set ( JAR_INSTALL_DIR share / OpenCV / java ) <nl> - endif ( WIN32 ) <nl> - install ( FILES $ { JAR_FILE } OPTIONAL DESTINATION $ { JAR_INSTALL_DIR } COMPONENT java ) <nl> + install ( FILES $ { JAR_FILE } OPTIONAL DESTINATION $ { OPENCV_JAR_INSTALL_PATH } COMPONENT java ) <nl> endif ( ANDROID ) <nl> <nl> # step 5 : build native part <nl> if ( ANDROID ) <nl> else ( ) <nl> if ( NOT INSTALL_CREATE_DISTRIB ) <nl> ocv_install_target ( $ { the_module } OPTIONAL EXPORT OpenCVModules <nl> - RUNTIME DESTINATION $ { JAR_INSTALL_DIR } COMPONENT java <nl> - LIBRARY DESTINATION $ { JAR_INSTALL_DIR } COMPONENT java ) <nl> + RUNTIME DESTINATION $ { OPENCV_JAR_INSTALL_PATH } COMPONENT java <nl> + LIBRARY DESTINATION $ { OPENCV_JAR_INSTALL_PATH } COMPONENT java ) <nl> else ( ) <nl> ocv_install_target ( $ { the_module } OPTIONAL EXPORT OpenCVModules <nl> - RUNTIME DESTINATION $ { JAR_INSTALL_DIR } / $ { OpenCV_ARCH } COMPONENT java <nl> - LIBRARY DESTINATION $ { JAR_INSTALL_DIR } / $ { OpenCV_ARCH } COMPONENT java ) <nl> + RUNTIME DESTINATION $ { OPENCV_JAR_INSTALL_PATH } / $ { OpenCV_ARCH } COMPONENT java <nl> + LIBRARY DESTINATION $ { OPENCV_JAR_INSTALL_PATH } / $ { OpenCV_ARCH } COMPONENT java ) <nl> endif ( ) <nl> endif ( ) <nl> <nl>
|
Fixed mangled install layout on unix machines
|
opencv/opencv
|
632afe6ae3f95fc4228a0c3b92ce08eaed748183
|
2015-03-13T11:18:37Z
|
mmm a / xbmc / filesystem / VideoDatabaseDirectory / DirectoryNodeEpisodes . cpp <nl> ppp b / xbmc / filesystem / VideoDatabaseDirectory / DirectoryNodeEpisodes . cpp <nl> bool CDirectoryNodeEpisodes : : GetContent ( CFileItemList & items ) const <nl> <nl> return bSuccess ; <nl> } <nl> + <nl> + NODE_TYPE CDirectoryNodeEpisodes : : GetChildType ( ) const <nl> + { <nl> + return NODE_TYPE_EPISODES ; <nl> + } <nl> mmm a / xbmc / filesystem / VideoDatabaseDirectory / DirectoryNodeEpisodes . h <nl> ppp b / xbmc / filesystem / VideoDatabaseDirectory / DirectoryNodeEpisodes . h <nl> namespace XFILE <nl> CDirectoryNodeEpisodes ( const std : : string & strEntryName , CDirectoryNode * pParent ) ; <nl> protected : <nl> virtual bool GetContent ( CFileItemList & items ) const ; <nl> + NODE_TYPE GetChildType ( ) const override ; <nl> } ; <nl> } <nl> } <nl>
|
[ DirectoryNodes ] override GetChildType ( ) for Episode DirectoryNodes
|
xbmc/xbmc
|
ec26ffa1dbaec64d2422771f90f55e20795c3f05
|
2016-11-28T19:31:15Z
|
mmm a / addons / resource . language . en_gb / resources / strings . po <nl> ppp b / addons / resource . language . en_gb / resources / strings . po <nl> msgstr " " <nl> # : xbmc \ video \ dialogs \ GUIDialogAudioSubtitleSettings . cpp <nl> # : xbmc \ video \ dialogs \ GUIDialogVideoSettings . cpp <nl> msgctxt " # 12376 " <nl> - msgid " Set as default for all videos " <nl> + msgid " Set as default for all media " <nl> msgstr " " <nl> <nl> # : xbmc \ video \ dialogs \ GUIDialogAudioSubtitleSettings . cpp <nl> msgstr " " <nl> <nl> # : xbmc / settings / dialogs / GUIDialogAudioDSPManager . cpp <nl> msgctxt " # 15040 " <nl> - msgid " Settings dialogue can be only used on OSD menu during playback ! " <nl> + msgid " The settings dialogue can only be opened from the OSD menu during playback " <nl> msgstr " " <nl> <nl> # : xbmc / settings / dialogs / GUIDialogAudioDSPSettings . cpp <nl> msgstr " " <nl> <nl> # : xbmc / cores / AudioEngine / DSPAddons / ActiveAEDSP . cpp <nl> msgctxt " # 15049 " <nl> - msgid " The audio DSP manager has been enabled without any enabled DSP add - on . Enable at least one add - on in order to use the audio DSP functionality . " <nl> + msgid " The audio DSP manager has been enabled without any enabled DSP add - on . Enable at least one add - on in order to use the DSP functionality . " <nl> msgstr " " <nl> <nl> # . Name of a list with amount of entries behind on GUI <nl>
|
Merge pull request from uNiversaI / dspstrings
|
xbmc/xbmc
|
62ecccc6333b02150305e974f39b844100e5c3f9
|
2015-07-25T18:44:05Z
|
mmm a / selfdrive / locationd / calibrationd . py <nl> ppp b / selfdrive / locationd / calibrationd . py <nl> def is_calibration_valid ( vp ) : <nl> def sanity_clip ( vp ) : <nl> if np . isnan ( vp ) . any ( ) : <nl> vp = VP_INIT <nl> - return [ np . clip ( vp [ 0 ] , VP_VALIDITY_CORNERS [ 0 , 0 ] - 20 , VP_VALIDITY_CORNERS [ 1 , 0 ] + 20 ) , <nl> - np . clip ( vp [ 1 ] , VP_VALIDITY_CORNERS [ 0 , 1 ] - 20 , VP_VALIDITY_CORNERS [ 1 , 1 ] + 20 ) ] <nl> + return np . array ( [ np . clip ( vp [ 0 ] , VP_VALIDITY_CORNERS [ 0 , 0 ] - 20 , VP_VALIDITY_CORNERS [ 1 , 0 ] + 20 ) , <nl> + np . clip ( vp [ 1 ] , VP_VALIDITY_CORNERS [ 0 , 1 ] - 20 , VP_VALIDITY_CORNERS [ 1 , 1 ] + 20 ) ] ) <nl> <nl> <nl> def intrinsics_from_vp ( vp ) : <nl>
|
needs to be array
|
commaai/openpilot
|
48b4a57980d043e8c4434b5e2f3d4109f1d11c01
|
2020-01-23T19:08:05Z
|
mmm a / drivers / ruby / lib / func . rb <nl> ppp b / drivers / ruby / lib / func . rb <nl> def new_func ( & b ) <nl> : iso8601 = > - 1 , <nl> : index_create = > - 1 , <nl> : random = > - 1 , <nl> - : http = > 1 <nl> + : http = > 1 , <nl> + : distinct = > - 1 <nl> } <nl> @ @ method_aliases = { <nl> : lt = > : < , <nl> mmm a / src / rdb_protocol / batching . cc <nl> ppp b / src / rdb_protocol / batching . cc <nl> batcher_t batchspec_t : : to_batcher ( ) const { <nl> ? max_size <nl> : std : : max < int64_t > ( 1 , max_size / first_scaledown_factor ) ; <nl> microtime_t cur_time = current_microtime ( ) ; <nl> - / / TODO : Look into real_end_time . This logic seems somewhat odd . <nl> + microtime_t latency_buffer = 1000000 ; <nl> microtime_t real_end_time = <nl> batch_type = = batch_type_t : : NORMAL <nl> ? ( end_time > cur_time <nl> ? end_time <nl> - : std : : numeric_limits < decltype ( batchspec_t ( ) . end_time ) > : : max ( ) ) <nl> + : cur_time + latency_buffer ) <nl> : ( batch_type = = batch_type_t : : NORMAL_FIRST <nl> ? ( end_time > cur_time <nl> ? cur_time + ( end_time - cur_time ) / first_scaledown_factor <nl> - : cur_time ) <nl> + : cur_time + latency_buffer / first_scaledown_factor ) <nl> : std : : numeric_limits < decltype ( batchspec_t ( ) . end_time ) > : : max ( ) ) ; <nl> return batcher_t ( batch_type , real_min_els , real_max_els , real_max_size , <nl> real_end_time ) ; <nl> mmm a / src / rdb_protocol / datum_stream . cc <nl> ppp b / src / rdb_protocol / datum_stream . cc <nl> <nl> # include " rdb_protocol / term . hpp " <nl> # include " rdb_protocol / val . hpp " <nl> <nl> + # include " debug . hpp " <nl> + <nl> namespace ql { <nl> <nl> rdb_namespace_interface_t : : rdb_namespace_interface_t ( <nl> ordered_distinct_datum_stream_t : : next_raw_batch ( env_t * env , const batchspec_t & b <nl> profile : : sampler_t sampler ( " Ordered distinct . " , env - > trace ) ; <nl> while ( ret . size ( ) = = 0 ) { <nl> std : : vector < counted_t < const datum_t > > v = source - > next_batch ( env , bs ) ; <nl> + if ( v . size ( ) = = 0 ) break ; <nl> for ( auto & & el : v ) { <nl> if ( ! last_val . has ( ) | | * last_val ! = * el ) { <nl> last_val = el ; <nl> ret . push_back ( std : : move ( el ) ) ; <nl> } <nl> + sampler . new_sample ( ) ; <nl> } <nl> } <nl> return ret ; <nl> mmm a / src / rdb_protocol / shards . cc <nl> ppp b / src / rdb_protocol / shards . cc <nl> class map_trans_t : public ungrouped_op_t { <nl> <nl> / / Note : this removes duplicates ONLY TO SAVE NETWORK TRAFFIC . It ' s possible <nl> / / for duplicates to survive , either because they ' re on different shards or <nl> - / / because they span shard boundaries . ` ordered_distinct_datum_stream_t ` in <nl> + / / because they span batch boundaries . ` ordered_distinct_datum_stream_t ` in <nl> / / ` datum_stream . cc ` removes any duplicates that survive this ` lst_transform ` . <nl> class distinct_trans_t : public ungrouped_op_t { <nl> public : <nl> class distinct_trans_t : public ungrouped_op_t { <nl> r_sanity_check ( sindex_val . has ( ) ) ; <nl> * it = sindex_val ; <nl> } <nl> - if ( ! last_val . has ( ) | | * it ! = last_val ) { <nl> + if ( ! last_val . has ( ) | | * * it ! = * last_val ) { <nl> loc - > swap ( * it ) ; <nl> last_val = * loc ; <nl> + + loc ; <nl> mmm a / src / rdb_protocol / terms / sort . cc <nl> ppp b / src / rdb_protocol / terms / sort . cc <nl> class orderby_term_t : public op_term_t { <nl> class distinct_term_t : public op_term_t { <nl> public : <nl> distinct_term_t ( compile_env_t * env , const protob_t < const Term > & term ) <nl> - : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> + : op_term_t ( env , term , argspec_t ( 1 ) , optargspec_t ( { " index " } ) ) { } <nl> private : <nl> virtual counted_t < val_t > eval_impl ( scope_env_t * env , UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > v = arg ( env , 0 ) ; <nl> class distinct_term_t : public op_term_t { <nl> if ( v - > get_type ( ) . is_convertible ( val_t : : type_t : : TABLE ) ) { <nl> counted_t < table_t > tbl = v - > as_table ( ) ; <nl> tbl - > add_sorting ( idx . has ( ) ? idx - > as_str ( ) . to_std ( ) : tbl - > get_pkey ( ) , <nl> - sorting_t : : UNORDERED , <nl> + sorting_t : : ASCENDING , <nl> this ) ; <nl> counted_t < datum_stream_t > s = tbl - > as_datum_stream ( env - > env , backtrace ( ) ) ; <nl> s - > add_transformation ( distinct_wire_func_t ( idx . has ( ) ) , backtrace ( ) ) ; <nl>
|
Streaming distinct works .
|
rethinkdb/rethinkdb
|
fdbe28eecbae1425e789113d55ff6d96850589fb
|
2014-07-01T22:27:58Z
|
mmm a / 3rdParty / V8 / v8 <nl> ppp b / 3rdParty / V8 / v8 <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit f2d3d92e0055c21dd3f8e8473d7921a5cce5a36f <nl> + Subproject commit d12a9da7103c17bf14fe2fb42749a2ab1e5dd33f <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> set ( BIN_ARANGOVPACK arangovpack ) <nl> <nl> # test binaries <nl> set ( TEST_BASICS_SUITE basics_suite ) <nl> + set ( TEST_CACHE_SUITE cache_suite ) <nl> set ( TEST_GEO_SUITE geo_suite ) <nl> set ( CLEAN_AUTOGENERATED_FILES ) <nl> set ( PACKAGES_LIST ) <nl> find_program ( GIT_EXE git ) <nl> if ( DEFINED GIT_EXE AND IS_DIRECTORY " $ { CMAKE_SOURCE_DIR } / . git " ) <nl> execute_process ( <nl> WORKING_DIRECTORY $ { CMAKE_SOURCE_DIR } <nl> - <nl> + <nl> COMMAND $ { GIT_EXE } describe - - all - - tags - - long - - dirty = - dirty <nl> OUTPUT_VARIABLE GIT_OUTPUT ) <nl> <nl> endif ( ) <nl> <nl> math ( EXPR BITS " 8 * $ { CMAKE_SIZEOF_VOID_P } " ) <nl> add_definitions ( " - DARANGODB_BITS = $ { BITS } " ) <nl> - <nl> + <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> # # COMPILER FEATURES <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> if ( MSVC ) <nl> add_definitions ( " - D_CRT_SECURE_NO_WARNINGS = 1 " ) <nl> add_definitions ( " - DFD_SETSIZE = 8192 " ) <nl> add_definitions ( " - DU_STATIC_IMPLEMENTATION = 1 " ) <nl> - <nl> + <nl> # https : / / blogs . msdn . microsoft . com / vcblog / 2016 / 04 / 14 / stl - fixes - in - vs - 2015 - update - 2 / <nl> # https : / / connect . microsoft . com / VisualStudio / feedback / details / 1892487 <nl> # http : / / lists . boost . org / boost - users / 2016 / 04 / 85968 . php <nl> add_definitions ( " - D_ENABLE_ATOMIC_ALIGNMENT_FIX " ) <nl> - <nl> + <nl> set ( MSVC_LIBS Shlwapi . lib ; crypt32 . lib ; WINMM . LIB ; Ws2_32 . lib ) <nl> <nl> set ( CMAKE_EXE_LINKER_FLAGS <nl> if ( APPLE ) <nl> endif ( ) <nl> endif ( ) <nl> <nl> - if ( USE_LOCAL_CLOCK_GETTIME ) <nl> + if ( USE_LOCAL_CLOCK_GETTIME ) <nl> message ( STATUS " using a home - made clock_gettime " ) <nl> endif ( ) <nl> endif ( ) <nl> mmm a / UnitTests / CMakeLists . txt <nl> ppp b / UnitTests / CMakeLists . txt <nl> add_executable ( $ { TEST_BASICS_SUITE } <nl> . . / lib / Basics / WorkMonitorDummy . cpp <nl> ) <nl> <nl> - include_directories ( <nl> - $ { TEST_BASICS_SUITE } <nl> + include_directories ( $ { TEST_BASICS_SUITE } <nl> PUBLIC $ { Boost_UNIT_TEST_INCLUDE_DIR } <nl> ) <nl> <nl> target_link_libraries ( $ { TEST_BASICS_SUITE } <nl> ) <nl> <nl> if ( NOT USE_PRECOMPILED_V8 ) <nl> - add_dependencies ( basics_suite v8_build ) <nl> + add_dependencies ( $ { TEST_BASICS_SUITE } v8_build ) <nl> + endif ( ) <nl> + <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + # # cache_suite <nl> + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> + <nl> + add_executable ( $ { TEST_CACHE_SUITE } <nl> + Cache / Runner . cpp <nl> + Cache / CachedValue . cpp <nl> + Cache / FrequencyBuffer . cpp <nl> + Cache / Manager . cpp <nl> + Cache / Metadata . cpp <nl> + Cache / MockScheduler . cpp <nl> + Cache / PlainBucket . cpp <nl> + Cache / PlainCache . cpp <nl> + Cache / Rebalancer . cpp <nl> + Cache / State . cpp <nl> + Cache / TransactionalBucket . cpp <nl> + Cache / TransactionWindow . cpp <nl> + . . / lib / Basics / WorkMonitorDummy . cpp <nl> + . . / arangod / Cache / Cache . cpp <nl> + . . / arangod / Cache / CacheManagerFeatureThreads . cpp <nl> + . . / arangod / Cache / CachedValue . cpp <nl> + . . / arangod / Cache / Manager . cpp <nl> + . . / arangod / Cache / ManagerTasks . cpp <nl> + . . / arangod / Cache / Metadata . cpp <nl> + . . / arangod / Cache / PlainBucket . cpp <nl> + . . / arangod / Cache / PlainCache . cpp <nl> + . . / arangod / Cache / Rebalancer . cpp <nl> + . . / arangod / Cache / State . cpp <nl> + . . / arangod / Cache / TransactionalBucket . cpp <nl> + . . / arangod / Cache / TransactionalCache . cpp <nl> + . . / arangod / Cache / TransactionWindow . cpp <nl> + ) <nl> + <nl> + include_directories ( $ { TEST_CACHE_SUITE } <nl> + PUBLIC $ { Boost_UNIT_TEST_INCLUDE_DIR } <nl> + ) <nl> + <nl> + target_link_libraries ( $ { TEST_CACHE_SUITE } <nl> + $ { LIB_ARANGO } <nl> + $ { MSVC_LIBS } <nl> + boost_system <nl> + boost_boost <nl> + $ { SYSTEM_LIBRARIES } <nl> + ) <nl> + <nl> + if ( NOT USE_PRECOMPILED_V8 ) <nl> + add_dependencies ( $ { TEST_CACHE_SUITE } v8_build ) <nl> endif ( ) <nl> <nl> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # <nl> target_link_libraries ( $ { TEST_GEO_SUITE } <nl> ) <nl> <nl> if ( NOT USE_PRECOMPILED_V8 ) <nl> - add_dependencies ( geo_suite v8_build ) <nl> + add_dependencies ( $ { TEST_GEO_SUITE } v8_build ) <nl> endif ( ) <nl> new file mode 100644 <nl> index 00000000000 . . fa8371ceb35 <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / CachedValue . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite for arangodb : : cache : : CachedValue <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # define BOOST_TEST_INCLUDED <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " Cache / CachedValue . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < string > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - setup / tear - down <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + struct CCacheCachedValueSetup { <nl> + CCacheCachedValueSetup ( ) { BOOST_TEST_MESSAGE ( " setup CachedValue " ) ; } <nl> + <nl> + ~ CCacheCachedValueSetup ( ) { BOOST_TEST_MESSAGE ( " tear - down CachedValue " ) ; } <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - test suite <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief setup <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_FIXTURE_TEST_SUITE ( CCacheCachedValueTest , CCacheCachedValueSetup ) <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test construct with valid data <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_construct_valid ) { <nl> + uint64_t k = 1 ; <nl> + std : : string v ( " test " ) ; <nl> + CachedValue * cv ; <nl> + <nl> + / / fixed key , variable value <nl> + cv = CachedValue : : construct ( & k , sizeof ( uint64_t ) , v . data ( ) , v . size ( ) ) ; <nl> + BOOST_CHECK ( nullptr ! = cv ) ; <nl> + BOOST_CHECK_EQUAL ( sizeof ( uint64_t ) , cv - > keySize ) ; <nl> + BOOST_CHECK_EQUAL ( v . size ( ) , cv - > valueSize ) ; <nl> + BOOST_CHECK_EQUAL ( sizeof ( CachedValue ) + sizeof ( uint64_t ) + v . size ( ) , <nl> + cv - > size ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( k , * reinterpret_cast < uint64_t const * > ( cv - > key ( ) ) ) ; <nl> + BOOST_CHECK_EQUAL ( 0 , memcmp ( v . data ( ) , cv - > value ( ) , v . size ( ) ) ) ; <nl> + delete cv ; <nl> + <nl> + / / variable key , fixed value <nl> + cv = CachedValue : : construct ( v . data ( ) , v . size ( ) , & k , sizeof ( uint64_t ) ) ; <nl> + BOOST_CHECK ( nullptr ! = cv ) ; <nl> + BOOST_CHECK_EQUAL ( v . size ( ) , cv - > keySize ) ; <nl> + BOOST_CHECK_EQUAL ( sizeof ( uint64_t ) , cv - > valueSize ) ; <nl> + BOOST_CHECK_EQUAL ( sizeof ( CachedValue ) + sizeof ( uint64_t ) + v . size ( ) , <nl> + cv - > size ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( 0 , memcmp ( v . data ( ) , cv - > key ( ) , v . size ( ) ) ) ; <nl> + BOOST_CHECK_EQUAL ( k , * reinterpret_cast < uint64_t const * > ( cv - > value ( ) ) ) ; <nl> + delete cv ; <nl> + <nl> + / / fixed key , zero length value <nl> + cv = CachedValue : : construct ( & k , sizeof ( uint64_t ) , nullptr , 0 ) ; <nl> + BOOST_CHECK ( nullptr ! = cv ) ; <nl> + BOOST_CHECK_EQUAL ( sizeof ( uint64_t ) , cv - > keySize ) ; <nl> + BOOST_CHECK_EQUAL ( 0ULL , cv - > valueSize ) ; <nl> + BOOST_CHECK_EQUAL ( sizeof ( CachedValue ) + sizeof ( uint64_t ) , cv - > size ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( k , * reinterpret_cast < uint64_t const * > ( cv - > key ( ) ) ) ; <nl> + BOOST_CHECK ( nullptr = = cv - > value ( ) ) ; <nl> + delete cv ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test construct with invalid data <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_construct_invalid ) { <nl> + uint64_t k = 1 ; <nl> + std : : string v ( " test " ) ; <nl> + CachedValue * cv ; <nl> + <nl> + / / zero size key <nl> + cv = CachedValue : : construct ( & k , 0 , v . data ( ) , v . size ( ) ) ; <nl> + BOOST_CHECK ( nullptr = = cv ) ; <nl> + <nl> + / / nullptr key , zero size <nl> + cv = CachedValue : : construct ( nullptr , 0 , v . data ( ) , v . size ( ) ) ; <nl> + BOOST_CHECK ( nullptr = = cv ) ; <nl> + <nl> + / / nullptr key , non - zero size <nl> + cv = CachedValue : : construct ( nullptr , sizeof ( uint64_t ) , v . data ( ) , v . size ( ) ) ; <nl> + BOOST_CHECK ( nullptr = = cv ) ; <nl> + <nl> + / / nullptr value , non - zero length <nl> + cv = CachedValue : : construct ( & k , sizeof ( uint64_t ) , nullptr , v . size ( ) ) ; <nl> + BOOST_CHECK ( nullptr = = cv ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test copy <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_copy ) { <nl> + uint64_t k = 1 ; <nl> + std : : string v ( " test " ) ; <nl> + <nl> + / / fixed key , variable value <nl> + auto original = <nl> + CachedValue : : construct ( & k , sizeof ( uint64_t ) , v . data ( ) , v . size ( ) ) ; <nl> + auto copy = original - > copy ( ) ; <nl> + BOOST_CHECK ( nullptr ! = copy ) ; <nl> + BOOST_CHECK_EQUAL ( sizeof ( uint64_t ) , copy - > keySize ) ; <nl> + BOOST_CHECK_EQUAL ( v . size ( ) , copy - > valueSize ) ; <nl> + BOOST_CHECK_EQUAL ( sizeof ( CachedValue ) + sizeof ( uint64_t ) + v . size ( ) , <nl> + copy - > size ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( k , * reinterpret_cast < uint64_t const * > ( copy - > key ( ) ) ) ; <nl> + BOOST_CHECK_EQUAL ( 0 , memcmp ( v . data ( ) , copy - > value ( ) , v . size ( ) ) ) ; <nl> + delete original ; <nl> + delete copy ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test key comparison <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_key_comparison ) { <nl> + std : : string k1 ( " test " ) ; <nl> + std : : string k2 ( " testing " ) ; <nl> + std : : string k3 ( " TEST " ) ; <nl> + uint64_t v = 1 ; <nl> + <nl> + auto cv = CachedValue : : construct ( k1 . data ( ) , k1 . size ( ) , & v , sizeof ( uint64_t ) ) ; <nl> + <nl> + / / same key <nl> + BOOST_CHECK ( cv - > sameKey ( k1 . data ( ) , k1 . size ( ) ) ) ; <nl> + <nl> + / / different length , matching prefix <nl> + BOOST_CHECK ( ! cv - > sameKey ( k2 . data ( ) , k2 . size ( ) ) ) ; <nl> + <nl> + / / same length , different key <nl> + BOOST_CHECK ( ! cv - > sameKey ( k3 . data ( ) , k3 . size ( ) ) ) ; <nl> + <nl> + delete cv ; <nl> + } <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate tests <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / <nl> + / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> new file mode 100644 <nl> index 00000000000 . . 25808bd8e6c <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / FrequencyBuffer . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite for arangodb : : cache : : FrequencyBuffer <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # define BOOST_TEST_INCLUDED <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " Cache / FrequencyBuffer . h " <nl> + <nl> + # include < stdint . h > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - setup / tear - down <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + struct CCacheFrequencyBufferSetup { <nl> + CCacheFrequencyBufferSetup ( ) { BOOST_TEST_MESSAGE ( " setup FrequencyBuffer " ) ; } <nl> + <nl> + ~ CCacheFrequencyBufferSetup ( ) { <nl> + BOOST_TEST_MESSAGE ( " tear - down FrequencyBuffer " ) ; <nl> + } <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - test suite <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief setup <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_FIXTURE_TEST_SUITE ( CCacheFrequencyBufferTest , CCacheFrequencyBufferSetup ) <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test behavior with ints <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_uint8_t ) { <nl> + uint8_t zero = 0 ; <nl> + uint8_t one = 1 ; <nl> + uint8_t two = 2 ; <nl> + <nl> + / / check that default construction is as expected <nl> + BOOST_CHECK ( uint8_t ( ) = = zero ) ; <nl> + <nl> + FrequencyBuffer < uint8_t > buffer ( 8 ) ; <nl> + BOOST_CHECK_EQUAL ( buffer . memoryUsage ( ) , sizeof ( FrequencyBuffer < uint8_t > ) + 8 ) ; <nl> + <nl> + for ( size_t i = 0 ; i < 4 ; i + + ) { <nl> + buffer . insertRecord ( two ) ; <nl> + } <nl> + for ( size_t i = 0 ; i < 2 ; i + + ) { <nl> + buffer . insertRecord ( one ) ; <nl> + } <nl> + <nl> + auto frequencies = buffer . getFrequencies ( ) ; <nl> + BOOST_CHECK_EQUAL ( 2ULL , frequencies - > size ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( one , ( * frequencies ) [ 0 ] . first ) ; <nl> + BOOST_CHECK_EQUAL ( 2ULL , ( * frequencies ) [ 0 ] . second ) ; <nl> + BOOST_CHECK_EQUAL ( two , ( * frequencies ) [ 1 ] . first ) ; <nl> + BOOST_CHECK_EQUAL ( 4ULL , ( * frequencies ) [ 1 ] . second ) ; <nl> + <nl> + for ( size_t i = 0 ; i < 8 ; i + + ) { <nl> + buffer . insertRecord ( one ) ; <nl> + } <nl> + <nl> + frequencies = buffer . getFrequencies ( ) ; <nl> + BOOST_CHECK_EQUAL ( 1ULL , frequencies - > size ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( one , ( * frequencies ) [ 0 ] . first ) ; <nl> + BOOST_CHECK_EQUAL ( 8ULL , ( * frequencies ) [ 0 ] . second ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test behavior with pointers <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_pointers ) { <nl> + uint8_t * zero = nullptr ; <nl> + uint8_t one = 1 ; <nl> + uint8_t two = 2 ; <nl> + <nl> + / / check that default construction is as expected <nl> + typedef uint8_t * smallptr ; <nl> + BOOST_CHECK ( smallptr ( ) = = zero ) ; <nl> + <nl> + FrequencyBuffer < uint8_t * > buffer ( 8 ) ; <nl> + BOOST_CHECK_EQUAL ( buffer . memoryUsage ( ) , <nl> + sizeof ( FrequencyBuffer < uint8_t * > ) + ( 8 * sizeof ( uint8_t * ) ) ) ; <nl> + <nl> + for ( size_t i = 0 ; i < 4 ; i + + ) { <nl> + buffer . insertRecord ( & two ) ; <nl> + } <nl> + for ( size_t i = 0 ; i < 2 ; i + + ) { <nl> + buffer . insertRecord ( & one ) ; <nl> + } <nl> + <nl> + auto frequencies = buffer . getFrequencies ( ) ; <nl> + BOOST_CHECK_EQUAL ( 2ULL , frequencies - > size ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( & one , ( * frequencies ) [ 0 ] . first ) ; <nl> + BOOST_CHECK_EQUAL ( 2ULL , ( * frequencies ) [ 0 ] . second ) ; <nl> + BOOST_CHECK_EQUAL ( & two , ( * frequencies ) [ 1 ] . first ) ; <nl> + BOOST_CHECK_EQUAL ( 4ULL , ( * frequencies ) [ 1 ] . second ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate tests <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / <nl> + / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> new file mode 100644 <nl> index 00000000000 . . 510651cc401 <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / Manager . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite for arangodb : : cache : : Manager <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Random / RandomGenerator . h " <nl> + <nl> + # define BOOST_TEST_INCLUDED <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " Cache / CacheManagerFeatureThreads . h " <nl> + # include " Cache / Manager . h " <nl> + # include " Cache / PlainCache . h " <nl> + <nl> + # include " MockScheduler . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < queue > <nl> + # include < string > <nl> + # include < thread > <nl> + # include < vector > <nl> + <nl> + # include < iostream > <nl> + <nl> + using namespace arangodb ; <nl> + using namespace arangodb : : cache ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - setup / tear - down <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + struct CCacheManagerSetup { <nl> + CCacheManagerSetup ( ) { BOOST_TEST_MESSAGE ( " setup Manager " ) ; } <nl> + <nl> + ~ CCacheManagerSetup ( ) { BOOST_TEST_MESSAGE ( " tear - down Manager " ) ; } <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - test suite <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief setup <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_FIXTURE_TEST_SUITE ( CCacheManagerTest , CCacheManagerSetup ) <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test constructor with valid data <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_constructor ) { <nl> + uint64_t requestLimit = 1024 * 1024 ; <nl> + Manager manager ( nullptr , requestLimit ) ; <nl> + <nl> + BOOST_CHECK_EQUAL ( requestLimit , manager . globalLimit ( ) ) ; <nl> + <nl> + BOOST_CHECK ( 0ULL < manager . globalAllocation ( ) ) ; <nl> + BOOST_CHECK ( requestLimit > manager . globalAllocation ( ) ) ; <nl> + <nl> + uint64_t bigRequestLimit = 4ULL * 1024ULL * 1024ULL * 1024ULL ; <nl> + Manager bigManager ( nullptr , bigRequestLimit ) ; <nl> + <nl> + BOOST_CHECK_EQUAL ( bigRequestLimit , bigManager . globalLimit ( ) ) ; <nl> + <nl> + BOOST_CHECK ( ( 1024ULL * 1024ULL ) < bigManager . globalAllocation ( ) ) ; <nl> + BOOST_CHECK ( bigRequestLimit > bigManager . globalAllocation ( ) ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test mixed load behavior ( multi - threaded ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_mixed_load ) { <nl> + uint64_t initialSize = 16ULL * 1024ULL ; <nl> + RandomGenerator : : initialize ( RandomGenerator : : RandomType : : MERSENNE ) ; <nl> + MockScheduler scheduler ( 4 ) ; <nl> + Manager manager ( scheduler . ioService ( ) , 1024ULL * 1024ULL * 1024ULL ) ; <nl> + size_t cacheCount = 4 ; <nl> + size_t threadCount = 4 ; <nl> + std : : vector < std : : shared_ptr < Cache > > caches ; <nl> + for ( size_t i = 0 ; i < cacheCount ; i + + ) { <nl> + caches . emplace_back ( <nl> + manager . createCache ( Manager : : CacheType : : Plain , initialSize , true ) ) ; <nl> + } <nl> + <nl> + uint64_t chunkSize = 4 * 1024 * 1024 ; <nl> + uint64_t initialInserts = 1 * 1024 * 1024 ; <nl> + uint64_t operationCount = 4 * 1024 * 1024 ; <nl> + std : : atomic < uint64_t > hitCount ( 0 ) ; <nl> + std : : atomic < uint64_t > missCount ( 0 ) ; <nl> + auto worker = [ & manager , & caches , cacheCount , initialInserts , operationCount , <nl> + & hitCount , <nl> + & missCount ] ( uint64_t lower , uint64_t upper ) - > void { <nl> + / / fill with some initial data <nl> + for ( uint64_t i = 0 ; i < initialInserts ; i + + ) { <nl> + uint64_t item = lower + i ; <nl> + size_t cacheIndex = item % cacheCount ; <nl> + CachedValue * value = CachedValue : : construct ( & item , sizeof ( uint64_t ) , <nl> + & item , sizeof ( uint64_t ) ) ; <nl> + bool ok = caches [ cacheIndex ] - > insert ( value ) ; <nl> + if ( ! ok ) { <nl> + delete value ; <nl> + } <nl> + } <nl> + <nl> + / / initialize valid range for keys that * might * be in cache <nl> + uint64_t validLower = lower ; <nl> + uint64_t validUpper = lower + initialInserts - 1 ; <nl> + <nl> + / / commence mixed workload <nl> + for ( uint64_t i = 0 ; i < operationCount ; i + + ) { <nl> + uint32_t r = RandomGenerator : : interval ( 99UL ) ; <nl> + <nl> + if ( r > = 99 ) { / / remove something <nl> + if ( validLower = = validUpper ) { <nl> + continue ; / / removed too much <nl> + } <nl> + <nl> + uint64_t item = validLower + + ; <nl> + size_t cacheIndex = item % cacheCount ; <nl> + <nl> + caches [ cacheIndex ] - > remove ( & item , sizeof ( uint64_t ) ) ; <nl> + } else if ( r > = 95 ) { / / insert something <nl> + if ( validUpper = = upper ) { <nl> + continue ; / / already maxed out range <nl> + } <nl> + <nl> + uint64_t item = + + validUpper ; <nl> + size_t cacheIndex = item % cacheCount ; <nl> + CachedValue * value = CachedValue : : construct ( & item , sizeof ( uint64_t ) , <nl> + & item , sizeof ( uint64_t ) ) ; <nl> + bool ok = caches [ cacheIndex ] - > insert ( value ) ; <nl> + if ( ! ok ) { <nl> + delete value ; <nl> + } <nl> + } else { / / lookup something <nl> + uint64_t item = RandomGenerator : : interval ( <nl> + static_cast < int64_t > ( validLower ) , static_cast < int64_t > ( validUpper ) ) ; <nl> + size_t cacheIndex = item % cacheCount ; <nl> + <nl> + Cache : : Finding f = caches [ cacheIndex ] - > find ( & item , sizeof ( uint64_t ) ) ; <nl> + if ( f . found ( ) ) { <nl> + hitCount + + ; <nl> + TRI_ASSERT ( f . value ( ) ! = nullptr ) ; <nl> + TRI_ASSERT ( f . value ( ) - > sameKey ( & item , sizeof ( uint64_t ) ) ) ; <nl> + } else { <nl> + missCount + + ; <nl> + TRI_ASSERT ( f . value ( ) = = nullptr ) ; <nl> + } <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + std : : vector < std : : thread * > threads ; <nl> + / / dispatch threads <nl> + for ( size_t i = 0 ; i < threadCount ; i + + ) { <nl> + uint64_t lower = i * chunkSize ; <nl> + uint64_t upper = ( ( i + 1 ) * chunkSize ) - 1 ; <nl> + threads . push_back ( new std : : thread ( worker , lower , upper ) ) ; <nl> + } <nl> + <nl> + / / join threads <nl> + for ( auto t : threads ) { <nl> + t - > join ( ) ; <nl> + delete t ; <nl> + } <nl> + <nl> + for ( auto cache : caches ) { <nl> + manager . destroyCache ( cache ) ; <nl> + } <nl> + <nl> + RandomGenerator : : shutdown ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test creation / destruction chaos ( multi - threaded ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_lifecycle_chaos ) { <nl> + uint64_t initialSize = 16ULL * 1024ULL ; <nl> + RandomGenerator : : initialize ( RandomGenerator : : RandomType : : MERSENNE ) ; <nl> + MockScheduler scheduler ( 4 ) ; <nl> + Manager manager ( scheduler . ioService ( ) , 1024ULL * 1024ULL * 1024ULL ) ; <nl> + size_t threadCount = 4 ; <nl> + uint64_t operationCount = 4ULL * 1024ULL ; <nl> + <nl> + auto worker = [ & manager , initialSize , operationCount ] ( ) - > void { <nl> + std : : queue < std : : shared_ptr < Cache > > caches ; <nl> + <nl> + for ( uint64_t i = 0 ; i < operationCount ; i + + ) { <nl> + uint32_t r = RandomGenerator : : interval ( 1UL ) ; <nl> + switch ( r ) { <nl> + case 0 : { <nl> + caches . emplace ( manager . createCache ( Manager : : CacheType : : Plain , <nl> + initialSize , true ) ) ; <nl> + } <nl> + case 1 : <nl> + default : { <nl> + if ( ! caches . empty ( ) ) { <nl> + auto cache = caches . front ( ) ; <nl> + caches . pop ( ) ; <nl> + manager . destroyCache ( cache ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + std : : vector < std : : thread * > threads ; <nl> + / / dispatch threads <nl> + for ( size_t i = 0 ; i < threadCount ; i + + ) { <nl> + threads . push_back ( new std : : thread ( worker ) ) ; <nl> + } <nl> + <nl> + / / join threads <nl> + for ( auto t : threads ) { <nl> + t - > join ( ) ; <nl> + delete t ; <nl> + } <nl> + <nl> + RandomGenerator : : shutdown ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate tests <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / <nl> + / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> new file mode 100644 <nl> index 00000000000 . . 47a2337dc12 <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / Metadata . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite for arangodb : : cache : : Metadata <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # define BOOST_TEST_INCLUDED <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " Cache / Metadata . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < memory > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - setup / tear - down <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + struct CCacheMetadataSetup { <nl> + CCacheMetadataSetup ( ) { BOOST_TEST_MESSAGE ( " setup Metadata " ) ; } <nl> + <nl> + ~ CCacheMetadataSetup ( ) { BOOST_TEST_MESSAGE ( " tear - down Metadata " ) ; } <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - test suite <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief setup <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_FIXTURE_TEST_SUITE ( CCacheMetadataTest , CCacheMetadataSetup ) <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test constructor with valid data <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_constructor ) { <nl> + uint64_t dummy ; <nl> + std : : shared_ptr < Cache > dummyCache ( reinterpret_cast < Cache * > ( & dummy ) , <nl> + [ ] ( Cache * p ) - > void { } ) ; <nl> + uint8_t dummyTable ; <nl> + uint32_t logSize = 1 ; <nl> + uint64_t limit = 1024 ; <nl> + <nl> + Metadata metadata ( dummyCache , limit , & dummyTable , logSize ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test getters <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_getters ) { <nl> + uint64_t dummy ; <nl> + std : : shared_ptr < Cache > dummyCache ( reinterpret_cast < Cache * > ( & dummy ) , <nl> + [ ] ( Cache * p ) - > void { } ) ; <nl> + uint8_t dummyTable ; <nl> + uint32_t logSize = 1 ; <nl> + uint64_t limit = 1024 ; <nl> + <nl> + Metadata metadata ( dummyCache , limit , & dummyTable , logSize ) ; <nl> + <nl> + metadata . lock ( ) ; <nl> + <nl> + BOOST_CHECK ( dummyCache = = metadata . cache ( ) ) ; <nl> + <nl> + BOOST_CHECK_EQUAL ( logSize , metadata . logSize ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( 0UL , metadata . auxiliaryLogSize ( ) ) ; <nl> + <nl> + BOOST_CHECK_EQUAL ( limit , metadata . softLimit ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( limit , metadata . hardLimit ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( 0UL , metadata . usage ( ) ) ; <nl> + <nl> + BOOST_CHECK ( & dummyTable = = metadata . table ( ) ) ; <nl> + BOOST_CHECK ( nullptr = = metadata . auxiliaryTable ( ) ) ; <nl> + <nl> + metadata . unlock ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test usage limits <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_usage_limits ) { <nl> + uint64_t dummy ; <nl> + std : : shared_ptr < Cache > dummyCache ( reinterpret_cast < Cache * > ( & dummy ) , <nl> + [ ] ( Cache * p ) - > void { } ) ; <nl> + uint8_t dummyTable ; <nl> + uint32_t logSize = 1 ; <nl> + bool success ; <nl> + <nl> + Metadata metadata ( dummyCache , 1024ULL , & dummyTable , logSize ) ; <nl> + <nl> + metadata . lock ( ) ; <nl> + <nl> + success = metadata . adjustUsageIfAllowed ( 512LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + success = metadata . adjustUsageIfAllowed ( 512LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + success = metadata . adjustUsageIfAllowed ( 512LL ) ; <nl> + BOOST_CHECK ( ! success ) ; <nl> + <nl> + success = metadata . adjustLimits ( 2048ULL , 2048ULL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + <nl> + success = metadata . adjustUsageIfAllowed ( 1024LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + <nl> + success = metadata . adjustLimits ( 1024ULL , 2048ULL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + <nl> + success = metadata . adjustUsageIfAllowed ( 512LL ) ; <nl> + BOOST_CHECK ( ! success ) ; <nl> + success = metadata . adjustUsageIfAllowed ( - 512LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + success = metadata . adjustUsageIfAllowed ( 512LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + success = metadata . adjustUsageIfAllowed ( - 1024LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + success = metadata . adjustUsageIfAllowed ( 512LL ) ; <nl> + BOOST_CHECK ( ! success ) ; <nl> + <nl> + success = metadata . adjustLimits ( 1024ULL , 1024ULL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + success = metadata . adjustLimits ( 512ULL , 512ULL ) ; <nl> + BOOST_CHECK ( ! success ) ; <nl> + <nl> + metadata . unlock ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test migration methods <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_migration ) { <nl> + uint64_t dummy ; <nl> + std : : shared_ptr < Cache > dummyCache ( reinterpret_cast < Cache * > ( & dummy ) , <nl> + [ ] ( Cache * p ) - > void { } ) ; <nl> + uint8_t dummyTable ; <nl> + uint8_t dummyAuxiliaryTable ; <nl> + uint32_t logSize = 1 ; <nl> + uint32_t auxiliaryLogSize = 2 ; <nl> + uint64_t limit = 1024 ; <nl> + <nl> + Metadata metadata ( dummyCache , limit , & dummyTable , logSize ) ; <nl> + <nl> + metadata . lock ( ) ; <nl> + <nl> + metadata . grantAuxiliaryTable ( & dummyAuxiliaryTable , auxiliaryLogSize ) ; <nl> + BOOST_CHECK_EQUAL ( auxiliaryLogSize , metadata . auxiliaryLogSize ( ) ) ; <nl> + BOOST_CHECK ( & dummyAuxiliaryTable = = metadata . auxiliaryTable ( ) ) ; <nl> + <nl> + metadata . swapTables ( ) ; <nl> + BOOST_CHECK_EQUAL ( logSize , metadata . auxiliaryLogSize ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( auxiliaryLogSize , metadata . logSize ( ) ) ; <nl> + BOOST_CHECK ( & dummyTable = = metadata . auxiliaryTable ( ) ) ; <nl> + BOOST_CHECK ( & dummyAuxiliaryTable = = metadata . table ( ) ) ; <nl> + <nl> + uint8_t * result = metadata . releaseAuxiliaryTable ( ) ; <nl> + BOOST_CHECK_EQUAL ( 0UL , metadata . auxiliaryLogSize ( ) ) ; <nl> + BOOST_CHECK ( nullptr = = metadata . auxiliaryTable ( ) ) ; <nl> + BOOST_CHECK ( result = = & dummyTable ) ; <nl> + <nl> + result = metadata . releaseTable ( ) ; <nl> + BOOST_CHECK_EQUAL ( 0UL , metadata . logSize ( ) ) ; <nl> + BOOST_CHECK ( nullptr = = metadata . table ( ) ) ; <nl> + BOOST_CHECK ( result = = & dummyAuxiliaryTable ) ; <nl> + <nl> + metadata . unlock ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate tests <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / <nl> + / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> new file mode 100644 <nl> index 00000000000 . . 04877b0e452 <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / MockScheduler . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief helper for cache suite <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " MockScheduler . h " <nl> + # include " Basics / Common . h " <nl> + <nl> + # include < boost / asio / io_service . hpp > <nl> + # include < boost / bind . hpp > <nl> + # include < boost / thread / thread . hpp > <nl> + <nl> + # include < memory > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + MockScheduler : : MockScheduler ( size_t threads ) <nl> + : _ioService ( new boost : : asio : : io_service ( ) ) , <nl> + _serviceGuard ( new boost : : asio : : io_service : : work ( * _ioService ) ) { <nl> + for ( size_t i = 0 ; i < threads ; i + + ) { <nl> + auto worker = std : : bind ( static_cast < size_t ( boost : : asio : : io_service : : * ) ( ) > ( <nl> + & boost : : asio : : io_service : : run ) , <nl> + _ioService . get ( ) ) ; <nl> + _group . emplace_back ( new std : : thread ( worker ) ) ; <nl> + } <nl> + } <nl> + <nl> + MockScheduler : : ~ MockScheduler ( ) { <nl> + _serviceGuard . reset ( ) ; <nl> + for ( auto g : _group ) { <nl> + g - > join ( ) ; <nl> + delete g ; <nl> + } <nl> + _ioService - > stop ( ) ; <nl> + } <nl> + <nl> + boost : : asio : : io_service * MockScheduler : : ioService ( ) { return _ioService . get ( ) ; } <nl> new file mode 100644 <nl> index 00000000000 . . f47a7900336 <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / MockScheduler . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief helper for cache suite <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef UNITTESTS_CACHE_MOCK_SCHEDULER_H <nl> + # define UNITTESTS_CACHE_MOCK_SCHEDULER_H <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # include " Basics / asio - helper . h " <nl> + <nl> + # include < memory > <nl> + # include < thread > <nl> + # include < vector > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + class MockScheduler { <nl> + typedef std : : unique_ptr < boost : : asio : : io_service : : work > asio_worker ; <nl> + std : : unique_ptr < boost : : asio : : io_service > _ioService ; <nl> + std : : unique_ptr < boost : : asio : : io_service : : work > _serviceGuard ; <nl> + std : : vector < std : : thread * > _group ; <nl> + <nl> + public : <nl> + MockScheduler ( size_t threads ) ; <nl> + ~ MockScheduler ( ) ; <nl> + boost : : asio : : io_service * ioService ( ) ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 5432c1ec762 <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / PlainBucket . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite for arangodb : : cache : : PlainBucket <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # define BOOST_TEST_INCLUDED <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " Cache / PlainBucket . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < string > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - setup / tear - down <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + struct CCachePlainBucketSetup { <nl> + CCachePlainBucketSetup ( ) { BOOST_TEST_MESSAGE ( " setup PlainBucket " ) ; } <nl> + <nl> + ~ CCachePlainBucketSetup ( ) { BOOST_TEST_MESSAGE ( " tear - down PlainBucket " ) ; } <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - test suite <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief setup <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_FIXTURE_TEST_SUITE ( CCachePlainBucketTest , CCachePlainBucketSetup ) <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test insertion to full and fail beyond <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_insertion ) { <nl> + PlainBucket bucket ; <nl> + bool success ; <nl> + <nl> + uint32_t hashes [ 6 ] = { <nl> + 1 , 2 , 3 , <nl> + 4 , 5 , 6 } ; / / don ' t have to be real , but should be unique and non - zero <nl> + uint64_t keys [ 6 ] = { 0 , 1 , 2 , 3 , 4 , 5 } ; <nl> + uint64_t values [ 6 ] = { 0 , 1 , 2 , 3 , 4 , 5 } ; <nl> + CachedValue * ptrs [ 6 ] ; <nl> + for ( size_t i = 0 ; i < 6 ; i + + ) { <nl> + ptrs [ i ] = CachedValue : : construct ( & ( keys [ i ] ) , sizeof ( uint64_t ) , & ( values [ i ] ) , <nl> + sizeof ( uint64_t ) ) ; <nl> + } <nl> + <nl> + success = bucket . lock ( - 1LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + <nl> + / / insert five to fill <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + for ( size_t i = 0 ; i < 5 ; i + + ) { <nl> + bucket . insert ( hashes [ i ] , ptrs [ i ] ) ; <nl> + if ( i < 4 ) { <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + } else { <nl> + BOOST_CHECK ( bucket . isFull ( ) ) ; <nl> + } <nl> + } <nl> + for ( size_t i = 0 ; i < 5 ; i + + ) { <nl> + CachedValue * res = bucket . find ( hashes [ i ] , ptrs [ i ] - > key ( ) , ptrs [ i ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ i ] ) ; <nl> + } <nl> + <nl> + / / check that insert is ignored if full <nl> + bucket . insert ( hashes [ 5 ] , ptrs [ 5 ] ) ; <nl> + CachedValue * res = bucket . find ( hashes [ 5 ] , ptrs [ 5 ] - > key ( ) , ptrs [ 5 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + <nl> + bucket . unlock ( ) ; <nl> + <nl> + / / cleanup <nl> + for ( size_t i = 0 ; i < 6 ; i + + ) { <nl> + delete ptrs [ i ] ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test removal <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_removal ) { <nl> + PlainBucket bucket ; <nl> + bool success ; <nl> + <nl> + uint32_t hashes [ 3 ] = { <nl> + 1 , 2 , 3 } ; / / don ' t have to be real , but should be unique and non - zero <nl> + uint64_t keys [ 3 ] = { 0 , 1 , 2 } ; <nl> + uint64_t values [ 3 ] = { 0 , 1 , 2 } ; <nl> + CachedValue * ptrs [ 3 ] ; <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + ptrs [ i ] = CachedValue : : construct ( & ( keys [ i ] ) , sizeof ( uint64_t ) , & ( values [ i ] ) , <nl> + sizeof ( uint64_t ) ) ; <nl> + } <nl> + <nl> + success = bucket . lock ( - 1LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + bucket . insert ( hashes [ i ] , ptrs [ i ] ) ; <nl> + } <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + CachedValue * res = bucket . find ( hashes [ i ] , ptrs [ i ] - > key ( ) , ptrs [ i ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ i ] ) ; <nl> + } <nl> + <nl> + CachedValue * res ; <nl> + res = bucket . remove ( hashes [ 1 ] , ptrs [ 1 ] - > key ( ) , ptrs [ 1 ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ 1 ] ) ; <nl> + res = bucket . find ( hashes [ 1 ] , ptrs [ 1 ] - > key ( ) , ptrs [ 1 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + res = bucket . remove ( hashes [ 0 ] , ptrs [ 0 ] - > key ( ) , ptrs [ 0 ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ 0 ] ) ; <nl> + res = bucket . find ( hashes [ 0 ] , ptrs [ 0 ] - > key ( ) , ptrs [ 0 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + res = bucket . remove ( hashes [ 2 ] , ptrs [ 2 ] - > key ( ) , ptrs [ 2 ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ 2 ] ) ; <nl> + res = bucket . find ( hashes [ 2 ] , ptrs [ 2 ] - > key ( ) , ptrs [ 2 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + <nl> + bucket . unlock ( ) ; <nl> + <nl> + / / cleanup <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + delete ptrs [ i ] ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test eviction with subsequent insertion <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_eviction ) { <nl> + PlainBucket bucket ; <nl> + bool success ; <nl> + <nl> + uint32_t hashes [ 6 ] = { <nl> + 1 , 2 , 3 , <nl> + 4 , 5 , 6 } ; / / don ' t have to be real , but should be unique and non - zero <nl> + uint64_t keys [ 6 ] = { 0 , 1 , 2 , 3 , 4 , 5 } ; <nl> + uint64_t values [ 6 ] = { 0 , 1 , 2 , 3 , 4 , 5 } ; <nl> + CachedValue * ptrs [ 6 ] ; <nl> + for ( size_t i = 0 ; i < 6 ; i + + ) { <nl> + ptrs [ i ] = CachedValue : : construct ( & ( keys [ i ] ) , sizeof ( uint64_t ) , & ( values [ i ] ) , <nl> + sizeof ( uint64_t ) ) ; <nl> + } <nl> + <nl> + success = bucket . lock ( - 1LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + <nl> + / / insert five to fill <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + for ( size_t i = 0 ; i < 5 ; i + + ) { <nl> + bucket . insert ( hashes [ i ] , ptrs [ i ] ) ; <nl> + if ( i < 4 ) { <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + } else { <nl> + BOOST_CHECK ( bucket . isFull ( ) ) ; <nl> + } <nl> + } <nl> + for ( size_t i = 0 ; i < 5 ; i + + ) { <nl> + CachedValue * res = bucket . find ( hashes [ i ] , ptrs [ i ] - > key ( ) , ptrs [ i ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ i ] ) ; <nl> + } <nl> + <nl> + / / check that we get proper eviction candidate <nl> + CachedValue * candidate = bucket . evictionCandidate ( ) ; <nl> + BOOST_CHECK ( candidate = = ptrs [ 0 ] ) ; <nl> + bucket . evict ( candidate , false ) ; <nl> + CachedValue * res = bucket . find ( hashes [ 0 ] , ptrs [ 0 ] - > key ( ) , ptrs [ 0 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + <nl> + / / check that we still find the right candidate if not full <nl> + candidate = bucket . evictionCandidate ( ) ; <nl> + BOOST_CHECK ( candidate = = ptrs [ 1 ] ) ; <nl> + bucket . evict ( candidate , true ) ; <nl> + res = bucket . find ( hashes [ 1 ] , ptrs [ 1 ] - > key ( ) , ptrs [ 1 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + <nl> + / / check that we can insert now after eviction optimized for insertion <nl> + bucket . insert ( hashes [ 5 ] , ptrs [ 5 ] ) ; <nl> + res = bucket . find ( hashes [ 5 ] , ptrs [ 5 ] - > key ( ) , ptrs [ 5 ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ 5 ] ) ; <nl> + <nl> + bucket . unlock ( ) ; <nl> + <nl> + / / cleanup <nl> + for ( size_t i = 0 ; i < 6 ; i + + ) { <nl> + delete ptrs [ i ] ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate tests <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / <nl> + / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> new file mode 100644 <nl> index 00000000000 . . fe27633f6fb <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / PlainCache . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite for arangodb : : cache : : PlainBucket <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Random / RandomGenerator . h " <nl> + <nl> + # define BOOST_TEST_INCLUDED <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " Cache / Manager . h " <nl> + # include " Cache / PlainCache . h " <nl> + <nl> + # include " MockScheduler . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < string > <nl> + # include < thread > <nl> + # include < vector > <nl> + <nl> + # include < iostream > <nl> + <nl> + using namespace arangodb ; <nl> + using namespace arangodb : : cache ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - setup / tear - down <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + struct CCachePlainCacheSetup { <nl> + CCachePlainCacheSetup ( ) { BOOST_TEST_MESSAGE ( " setup PlainCache " ) ; } <nl> + <nl> + ~ CCachePlainCacheSetup ( ) { BOOST_TEST_MESSAGE ( " tear - down PlainCache " ) ; } <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - test suite <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief setup <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_FIXTURE_TEST_SUITE ( CCachePlainCacheTest , CCachePlainCacheSetup ) <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test construction ( single - threaded ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_st_construction ) { <nl> + Manager manager ( nullptr , 1024ULL * 1024ULL ) ; <nl> + auto cache1 = <nl> + manager . createCache ( Manager : : CacheType : : Plain , 256ULL * 1024ULL , false ) ; <nl> + auto cache2 = <nl> + manager . createCache ( Manager : : CacheType : : Plain , 512ULL * 1024ULL , false ) ; <nl> + <nl> + BOOST_CHECK_EQUAL ( 0ULL , cache1 - > usage ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( 256ULL * 1024ULL , cache1 - > limit ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( 0ULL , cache2 - > usage ( ) ) ; <nl> + BOOST_CHECK ( 512ULL * 1024ULL > cache2 - > limit ( ) ) ; <nl> + <nl> + manager . destroyCache ( cache1 ) ; <nl> + manager . destroyCache ( cache2 ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test insertion ( single - threaded ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_st_insertion ) { <nl> + uint64_t cacheLimit = 256ULL * 1024ULL ; <nl> + Manager manager ( nullptr , 4ULL * cacheLimit ) ; <nl> + auto cache = <nl> + manager . createCache ( Manager : : CacheType : : Plain , cacheLimit , false ) ; <nl> + <nl> + for ( uint64_t i = 0 ; i < 1024 ; i + + ) { <nl> + CachedValue * value = <nl> + CachedValue : : construct ( & i , sizeof ( uint64_t ) , & i , sizeof ( uint64_t ) ) ; <nl> + bool success = cache - > insert ( value ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + auto f = cache - > find ( & i , sizeof ( uint64_t ) ) ; <nl> + BOOST_CHECK ( f . found ( ) ) ; <nl> + } <nl> + <nl> + for ( uint64_t i = 0 ; i < 1024 ; i + + ) { <nl> + uint64_t j = 2 * i ; <nl> + CachedValue * value = <nl> + CachedValue : : construct ( & i , sizeof ( uint64_t ) , & j , sizeof ( uint64_t ) ) ; <nl> + bool success = cache - > insert ( value ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + auto f = cache - > find ( & i , sizeof ( uint64_t ) ) ; <nl> + BOOST_CHECK ( f . found ( ) ) ; <nl> + BOOST_CHECK ( 0 = = memcmp ( f . value ( ) - > value ( ) , & j , sizeof ( uint64_t ) ) ) ; <nl> + } <nl> + <nl> + uint64_t notInserted = 0 ; <nl> + for ( uint64_t i = 1024 ; i < 128 * 1024 ; i + + ) { <nl> + CachedValue * value = <nl> + CachedValue : : construct ( & i , sizeof ( uint64_t ) , & i , sizeof ( uint64_t ) ) ; <nl> + bool success = cache - > insert ( value ) ; <nl> + if ( success ) { <nl> + auto f = cache - > find ( & i , sizeof ( uint64_t ) ) ; <nl> + BOOST_CHECK ( f . found ( ) ) ; <nl> + } else { <nl> + delete value ; <nl> + notInserted + + ; <nl> + } <nl> + } <nl> + BOOST_CHECK ( notInserted > 0 ) ; <nl> + <nl> + manager . destroyCache ( cache ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test removal ( single - threaded ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_st_removal ) { <nl> + uint64_t cacheLimit = 256ULL * 1024ULL ; <nl> + Manager manager ( nullptr , 4ULL * cacheLimit ) ; <nl> + auto cache = <nl> + manager . createCache ( Manager : : CacheType : : Plain , cacheLimit , false ) ; <nl> + <nl> + for ( uint64_t i = 0 ; i < 1024 ; i + + ) { <nl> + CachedValue * value = <nl> + CachedValue : : construct ( & i , sizeof ( uint64_t ) , & i , sizeof ( uint64_t ) ) ; <nl> + bool success = cache - > insert ( value ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + auto f = cache - > find ( & i , sizeof ( uint64_t ) ) ; <nl> + BOOST_CHECK ( f . found ( ) ) ; <nl> + BOOST_CHECK ( f . value ( ) ! = nullptr ) ; <nl> + BOOST_CHECK ( f . value ( ) - > sameKey ( & i , sizeof ( uint64_t ) ) ) ; <nl> + } <nl> + <nl> + / / test removal of bogus keys <nl> + for ( uint64_t i = 1024 ; i < 2048 ; i + + ) { <nl> + bool removed = cache - > remove ( & i , sizeof ( uint64_t ) ) ; <nl> + BOOST_ASSERT ( removed ) ; <nl> + / / ensure existing keys not removed <nl> + for ( uint64_t j = 0 ; j < 1024 ; j + + ) { <nl> + auto f = cache - > find ( & j , sizeof ( uint64_t ) ) ; <nl> + BOOST_CHECK ( f . found ( ) ) ; <nl> + BOOST_CHECK ( f . value ( ) ! = nullptr ) ; <nl> + BOOST_CHECK ( f . value ( ) - > sameKey ( & j , sizeof ( uint64_t ) ) ) ; <nl> + } <nl> + } <nl> + <nl> + / / remove actual keys <nl> + for ( uint64_t i = 0 ; i < 1024 ; i + + ) { <nl> + bool removed = cache - > remove ( & i , sizeof ( uint64_t ) ) ; <nl> + BOOST_CHECK ( removed ) ; <nl> + auto f = cache - > find ( & i , sizeof ( uint64_t ) ) ; <nl> + BOOST_CHECK ( ! f . found ( ) ) ; <nl> + } <nl> + <nl> + manager . destroyCache ( cache ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test growth behavior ( single - threaded ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_st_growth ) { <nl> + uint64_t initialSize = 16ULL * 1024ULL ; <nl> + uint64_t minimumSize = 64ULL * initialSize ; <nl> + MockScheduler scheduler ( 4 ) ; <nl> + Manager manager ( scheduler . ioService ( ) , 1024ULL * 1024ULL * 1024ULL ) ; <nl> + auto cache = <nl> + manager . createCache ( Manager : : CacheType : : Plain , initialSize , true ) ; <nl> + <nl> + for ( uint64_t i = 0 ; i < 4ULL * 1024ULL * 1024ULL ; i + + ) { <nl> + CachedValue * value = <nl> + CachedValue : : construct ( & i , sizeof ( uint64_t ) , & i , sizeof ( uint64_t ) ) ; <nl> + bool success = cache - > insert ( value ) ; <nl> + if ( ! success ) { <nl> + delete value ; <nl> + } <nl> + } <nl> + <nl> + BOOST_CHECK ( cache - > usage ( ) > minimumSize ) ; <nl> + <nl> + manager . destroyCache ( cache ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test shrink behavior ( single - threaded ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_st_shrink ) { <nl> + uint64_t initialSize = 16ULL * 1024ULL ; <nl> + RandomGenerator : : initialize ( RandomGenerator : : RandomType : : MERSENNE ) ; <nl> + MockScheduler scheduler ( 4 ) ; <nl> + Manager manager ( scheduler . ioService ( ) , 1024ULL * 1024ULL * 1024ULL ) ; <nl> + auto cache = <nl> + manager . createCache ( Manager : : CacheType : : Plain , initialSize , true ) ; <nl> + <nl> + for ( uint64_t i = 0 ; i < 16ULL * 1024ULL * 1024ULL ; i + + ) { <nl> + CachedValue * value = <nl> + CachedValue : : construct ( & i , sizeof ( uint64_t ) , & i , sizeof ( uint64_t ) ) ; <nl> + bool success = cache - > insert ( value ) ; <nl> + if ( ! success ) { <nl> + delete value ; <nl> + } <nl> + } <nl> + <nl> + uint64_t target = cache - > usage ( ) / 2 ; <nl> + while ( ! cache - > resize ( target ) ) { <nl> + } ; <nl> + <nl> + for ( uint64_t i = 0 ; i < 16ULL * 1024ULL * 1024ULL ; i + + ) { <nl> + CachedValue * value = <nl> + CachedValue : : construct ( & i , sizeof ( uint64_t ) , & i , sizeof ( uint64_t ) ) ; <nl> + bool success = cache - > insert ( value ) ; <nl> + if ( ! success ) { <nl> + delete value ; <nl> + } <nl> + } <nl> + <nl> + uint64_t lastUsage = cache - > usage ( ) ; <nl> + while ( true ) { <nl> + usleep ( 10000 ) ; <nl> + if ( cache - > usage ( ) = = lastUsage ) { <nl> + break ; <nl> + } <nl> + lastUsage = cache - > usage ( ) ; <nl> + } <nl> + BOOST_CHECK_MESSAGE ( cache - > usage ( ) < = target , <nl> + cache - > usage ( ) < < " ! < = " < < target ) ; <nl> + <nl> + manager . destroyCache ( cache ) ; <nl> + RandomGenerator : : shutdown ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test mixed load behavior ( multi - threaded ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_mt_mixed_load ) { <nl> + uint64_t initialSize = 16ULL * 1024ULL ; <nl> + RandomGenerator : : initialize ( RandomGenerator : : RandomType : : MERSENNE ) ; <nl> + MockScheduler scheduler ( 4 ) ; <nl> + Manager manager ( scheduler . ioService ( ) , 1024ULL * 1024ULL * 1024ULL ) ; <nl> + size_t threadCount = 4 ; <nl> + std : : shared_ptr < Cache > cache = <nl> + manager . createCache ( Manager : : CacheType : : Plain , initialSize , true ) ; <nl> + <nl> + uint64_t chunkSize = 16 * 1024 * 1024 ; <nl> + uint64_t initialInserts = 4 * 1024 * 1024 ; <nl> + uint64_t operationCount = 16 * 1024 * 1024 ; <nl> + std : : atomic < uint64_t > hitCount ( 0 ) ; <nl> + std : : atomic < uint64_t > missCount ( 0 ) ; <nl> + auto worker = [ & manager , & cache , initialInserts , operationCount , & hitCount , <nl> + & missCount ] ( uint64_t lower , uint64_t upper ) - > void { <nl> + / / fill with some initial data <nl> + for ( uint64_t i = 0 ; i < initialInserts ; i + + ) { <nl> + uint64_t item = lower + i ; <nl> + CachedValue * value = CachedValue : : construct ( & item , sizeof ( uint64_t ) , <nl> + & item , sizeof ( uint64_t ) ) ; <nl> + bool ok = cache - > insert ( value ) ; <nl> + if ( ! ok ) { <nl> + delete value ; <nl> + } <nl> + } <nl> + <nl> + / / initialize valid range for keys that * might * be in cache <nl> + uint64_t validLower = lower ; <nl> + uint64_t validUpper = lower + initialInserts - 1 ; <nl> + <nl> + / / commence mixed workload <nl> + for ( uint64_t i = 0 ; i < operationCount ; i + + ) { <nl> + uint32_t r = RandomGenerator : : interval ( 99UL ) ; <nl> + <nl> + if ( r > = 99 ) { / / remove something <nl> + if ( validLower = = validUpper ) { <nl> + continue ; / / removed too much <nl> + } <nl> + <nl> + uint64_t item = validLower + + ; <nl> + <nl> + cache - > remove ( & item , sizeof ( uint64_t ) ) ; <nl> + } else if ( r > = 95 ) { / / insert something <nl> + if ( validUpper = = upper ) { <nl> + continue ; / / already maxed out range <nl> + } <nl> + <nl> + uint64_t item = + + validUpper ; <nl> + CachedValue * value = CachedValue : : construct ( & item , sizeof ( uint64_t ) , <nl> + & item , sizeof ( uint64_t ) ) ; <nl> + bool ok = cache - > insert ( value ) ; <nl> + if ( ! ok ) { <nl> + delete value ; <nl> + } <nl> + } else { / / lookup something <nl> + uint64_t item = RandomGenerator : : interval ( <nl> + static_cast < int64_t > ( validLower ) , static_cast < int64_t > ( validUpper ) ) ; <nl> + <nl> + Cache : : Finding f = cache - > find ( & item , sizeof ( uint64_t ) ) ; <nl> + if ( f . found ( ) ) { <nl> + hitCount + + ; <nl> + TRI_ASSERT ( f . value ( ) ! = nullptr ) ; <nl> + TRI_ASSERT ( f . value ( ) - > sameKey ( & item , sizeof ( uint64_t ) ) ) ; <nl> + } else { <nl> + missCount + + ; <nl> + TRI_ASSERT ( f . value ( ) = = nullptr ) ; <nl> + } <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + std : : vector < std : : thread * > threads ; <nl> + / / dispatch threads <nl> + for ( size_t i = 0 ; i < threadCount ; i + + ) { <nl> + uint64_t lower = i * chunkSize ; <nl> + uint64_t upper = ( ( i + 1 ) * chunkSize ) - 1 ; <nl> + threads . push_back ( new std : : thread ( worker , lower , upper ) ) ; <nl> + } <nl> + <nl> + / / join threads <nl> + for ( auto t : threads ) { <nl> + t - > join ( ) ; <nl> + delete t ; <nl> + } <nl> + <nl> + manager . destroyCache ( cache ) ; <nl> + RandomGenerator : : shutdown ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate tests <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / <nl> + / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> new file mode 100644 <nl> index 00000000000 . . a55e8107497 <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / Rebalancer . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite for arangodb : : cache : : Manager <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Random / RandomGenerator . h " <nl> + <nl> + # define BOOST_TEST_INCLUDED <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " Cache / Manager . h " <nl> + # include " Cache / PlainCache . h " <nl> + # include " Cache / Rebalancer . h " <nl> + <nl> + # include " MockScheduler . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < queue > <nl> + # include < string > <nl> + # include < thread > <nl> + # include < vector > <nl> + <nl> + using namespace arangodb ; <nl> + using namespace arangodb : : cache ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - setup / tear - down <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + struct CCacheRebalancerSetup { <nl> + CCacheRebalancerSetup ( ) { BOOST_TEST_MESSAGE ( " setup Rebalancer " ) ; } <nl> + <nl> + ~ CCacheRebalancerSetup ( ) { BOOST_TEST_MESSAGE ( " tear - down Rebalancer " ) ; } <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - test suite <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief setup <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_FIXTURE_TEST_SUITE ( CCacheRebalancerTest , CCacheRebalancerSetup ) <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test rebalancing ( multi - threaded ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_rebalancing ) { <nl> + uint64_t initialSize = 16ULL * 1024ULL ; <nl> + RandomGenerator : : initialize ( RandomGenerator : : RandomType : : MERSENNE ) ; <nl> + MockScheduler scheduler ( 4 ) ; <nl> + Manager manager ( scheduler . ioService ( ) , 128ULL * 1024ULL * 1024ULL ) ; <nl> + Rebalancer rebalancer ( & manager ) ; <nl> + <nl> + size_t cacheCount = 4 ; <nl> + size_t threadCount = 4 ; <nl> + std : : vector < std : : shared_ptr < Cache > > caches ; <nl> + for ( size_t i = 0 ; i < cacheCount ; i + + ) { <nl> + caches . emplace_back ( <nl> + manager . createCache ( Manager : : CacheType : : Plain , initialSize , true ) ) ; <nl> + } <nl> + <nl> + bool doneRebalancing = false ; <nl> + auto rebalanceWorker = [ & rebalancer , & doneRebalancing ] ( ) - > void { <nl> + while ( ! doneRebalancing ) { <nl> + bool rebalanced = rebalancer . rebalance ( ) ; <nl> + if ( rebalanced ) { <nl> + usleep ( 500 * 1000 ) ; <nl> + } else { <nl> + usleep ( 100 ) ; <nl> + } <nl> + } <nl> + } ; <nl> + auto rebalancerThread = new std : : thread ( rebalanceWorker ) ; <nl> + <nl> + uint64_t chunkSize = 4 * 1024 * 1024 ; <nl> + uint64_t initialInserts = 1 * 1024 * 1024 ; <nl> + uint64_t operationCount = 4 * 1024 * 1024 ; <nl> + std : : atomic < uint64_t > hitCount ( 0 ) ; <nl> + std : : atomic < uint64_t > missCount ( 0 ) ; <nl> + auto worker = [ & manager , & caches , cacheCount , initialInserts , operationCount , <nl> + & hitCount , <nl> + & missCount ] ( uint64_t lower , uint64_t upper ) - > void { <nl> + / / fill with some initial data <nl> + for ( uint64_t i = 0 ; i < initialInserts ; i + + ) { <nl> + uint64_t item = lower + i ; <nl> + size_t cacheIndex = item % cacheCount ; <nl> + CachedValue * value = CachedValue : : construct ( & item , sizeof ( uint64_t ) , <nl> + & item , sizeof ( uint64_t ) ) ; <nl> + bool ok = caches [ cacheIndex ] - > insert ( value ) ; <nl> + if ( ! ok ) { <nl> + delete value ; <nl> + } <nl> + } <nl> + <nl> + / / initialize valid range for keys that * might * be in cache <nl> + uint64_t validLower = lower ; <nl> + uint64_t validUpper = lower + initialInserts - 1 ; <nl> + <nl> + / / commence mixed workload <nl> + for ( uint64_t i = 0 ; i < operationCount ; i + + ) { <nl> + uint32_t r = RandomGenerator : : interval ( 99UL ) ; <nl> + <nl> + if ( r > = 99 ) { / / remove something <nl> + if ( validLower = = validUpper ) { <nl> + continue ; / / removed too much <nl> + } <nl> + <nl> + uint64_t item = validLower + + ; <nl> + size_t cacheIndex = item % cacheCount ; <nl> + <nl> + caches [ cacheIndex ] - > remove ( & item , sizeof ( uint64_t ) ) ; <nl> + } else if ( r > = 95 ) { / / insert something <nl> + if ( validUpper = = upper ) { <nl> + continue ; / / already maxed out range <nl> + } <nl> + <nl> + uint64_t item = + + validUpper ; <nl> + size_t cacheIndex = item % cacheCount ; <nl> + CachedValue * value = CachedValue : : construct ( & item , sizeof ( uint64_t ) , <nl> + & item , sizeof ( uint64_t ) ) ; <nl> + bool ok = caches [ cacheIndex ] - > insert ( value ) ; <nl> + if ( ! ok ) { <nl> + delete value ; <nl> + } <nl> + } else { / / lookup something <nl> + uint64_t item = RandomGenerator : : interval ( <nl> + static_cast < int64_t > ( validLower ) , static_cast < int64_t > ( validUpper ) ) ; <nl> + size_t cacheIndex = item % cacheCount ; <nl> + <nl> + Cache : : Finding f = caches [ cacheIndex ] - > find ( & item , sizeof ( uint64_t ) ) ; <nl> + if ( f . found ( ) ) { <nl> + hitCount + + ; <nl> + TRI_ASSERT ( f . value ( ) ! = nullptr ) ; <nl> + TRI_ASSERT ( f . value ( ) - > sameKey ( & item , sizeof ( uint64_t ) ) ) ; <nl> + } else { <nl> + missCount + + ; <nl> + TRI_ASSERT ( f . value ( ) = = nullptr ) ; <nl> + } <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + std : : vector < std : : thread * > threads ; <nl> + / / dispatch threads <nl> + for ( size_t i = 0 ; i < threadCount ; i + + ) { <nl> + uint64_t lower = i * chunkSize ; <nl> + uint64_t upper = ( ( i + 1 ) * chunkSize ) - 1 ; <nl> + threads . push_back ( new std : : thread ( worker , lower , upper ) ) ; <nl> + } <nl> + <nl> + / / join threads <nl> + for ( auto t : threads ) { <nl> + t - > join ( ) ; <nl> + delete t ; <nl> + } <nl> + <nl> + doneRebalancing = true ; <nl> + rebalancerThread - > join ( ) ; <nl> + delete rebalancerThread ; <nl> + <nl> + for ( auto cache : caches ) { <nl> + manager . destroyCache ( cache ) ; <nl> + } <nl> + <nl> + RandomGenerator : : shutdown ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate tests <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / <nl> + / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> new file mode 100644 <nl> index 00000000000 . . b742ba38849 <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / Runner . cpp <nl> <nl> + # define BOOST_TEST_MODULE " C / C + + Unit Tests for ArangoDB Cache " <nl> + # include < boost / test / included / unit_test . hpp > <nl> new file mode 100644 <nl> index 00000000000 . . 43aac0a13e7 <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / State . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite for arangodb : : cache : : State <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # define BOOST_TEST_INCLUDED <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " Cache / State . h " <nl> + <nl> + # include < stdint . h > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - setup / tear - down <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + struct CCacheStateSetup { <nl> + CCacheStateSetup ( ) { BOOST_TEST_MESSAGE ( " setup State " ) ; } <nl> + <nl> + ~ CCacheStateSetup ( ) { BOOST_TEST_MESSAGE ( " tear - down State " ) ; } <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - test suite <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief setup <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_FIXTURE_TEST_SUITE ( CCacheStateTest , CCacheStateSetup ) <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test lock methods <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_lock ) { <nl> + State state ; <nl> + bool success ; <nl> + <nl> + uint32_t outsideState = 0 ; <nl> + <nl> + auto cb1 = [ & outsideState ] ( ) - > void { outsideState = 1 ; } ; <nl> + <nl> + auto cb2 = [ & outsideState ] ( ) - > void { outsideState = 2 ; } ; <nl> + <nl> + / / check lock without contention <nl> + BOOST_CHECK ( ! state . isLocked ( ) ) ; <nl> + success = state . lock ( - 1 , cb1 ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + BOOST_CHECK ( state . isLocked ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( 1UL , outsideState ) ; <nl> + <nl> + / / check lock with contention <nl> + success = state . lock ( 10LL , cb2 ) ; <nl> + BOOST_CHECK ( ! success ) ; <nl> + BOOST_CHECK ( state . isLocked ( ) ) ; <nl> + BOOST_CHECK_EQUAL ( 1UL , outsideState ) ; <nl> + <nl> + / / check unlock <nl> + state . unlock ( ) ; <nl> + BOOST_CHECK ( ! state . isLocked ( ) ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test methods for non - lock flags <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_flags ) { <nl> + State state ; <nl> + bool success ; <nl> + <nl> + success = state . lock ( ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + BOOST_CHECK ( ! state . isSet ( State : : Flag : : migrated ) ) ; <nl> + state . unlock ( ) ; <nl> + <nl> + success = state . lock ( ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + BOOST_CHECK ( ! state . isSet ( State : : Flag : : migrated ) ) ; <nl> + state . toggleFlag ( State : : Flag : : migrated ) ; <nl> + BOOST_CHECK ( state . isSet ( State : : Flag : : migrated ) ) ; <nl> + state . unlock ( ) ; <nl> + <nl> + success = state . lock ( ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + BOOST_CHECK ( state . isSet ( State : : Flag : : migrated ) ) ; <nl> + state . unlock ( ) ; <nl> + <nl> + success = state . lock ( ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + BOOST_CHECK ( state . isSet ( State : : Flag : : migrated ) ) ; <nl> + state . toggleFlag ( State : : Flag : : migrated ) ; <nl> + BOOST_CHECK ( ! state . isSet ( State : : Flag : : migrated ) ) ; <nl> + state . unlock ( ) ; <nl> + <nl> + success = state . lock ( ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + BOOST_CHECK ( ! state . isSet ( State : : Flag : : migrated ) ) ; <nl> + state . unlock ( ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate tests <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / <nl> + / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> new file mode 100644 <nl> index 00000000000 . . 94f85acab1f <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / TransactionWindow . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite for arangodb : : cache : : TransactionWindow <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # define BOOST_TEST_INCLUDED <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " Cache / TransactionWindow . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < iostream > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - setup / tear - down <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + struct CCacheTransactionWindowSetup { <nl> + CCacheTransactionWindowSetup ( ) { <nl> + BOOST_TEST_MESSAGE ( " setup TransactionWindow " ) ; <nl> + } <nl> + <nl> + ~ CCacheTransactionWindowSetup ( ) { <nl> + BOOST_TEST_MESSAGE ( " tear - down TransactionWindow " ) ; <nl> + } <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - test suite <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief setup <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_FIXTURE_TEST_SUITE ( CCacheTransactionWindowTest , <nl> + CCacheTransactionWindowSetup ) <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test transaction term management <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_transaction_term ) { <nl> + TransactionWindow transactions ; <nl> + <nl> + BOOST_CHECK_EQUAL ( 0ULL , transactions . term ( ) ) ; <nl> + <nl> + transactions . start ( ) ; <nl> + BOOST_CHECK_EQUAL ( 1ULL , transactions . term ( ) ) ; <nl> + transactions . end ( ) ; <nl> + BOOST_CHECK_EQUAL ( 2ULL , transactions . term ( ) ) ; <nl> + <nl> + transactions . start ( ) ; <nl> + BOOST_CHECK_EQUAL ( 3ULL , transactions . term ( ) ) ; <nl> + transactions . start ( ) ; <nl> + BOOST_CHECK_EQUAL ( 3ULL , transactions . term ( ) ) ; <nl> + transactions . end ( ) ; <nl> + BOOST_CHECK_EQUAL ( 3ULL , transactions . term ( ) ) ; <nl> + transactions . end ( ) ; <nl> + BOOST_CHECK_EQUAL ( 4ULL , transactions . term ( ) ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate tests <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / <nl> + / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> new file mode 100644 <nl> index 00000000000 . . 590a4b1e855 <nl> mmm / dev / null <nl> ppp b / UnitTests / Cache / TransactionalBucket . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test suite for arangodb : : cache : : TransactionalBucket <nl> + / / / <nl> + / / / @ file <nl> + / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2017 triagens GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / @ author Copyright 2017 , triAGENS GmbH , Cologne , Germany <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # define BOOST_TEST_INCLUDED <nl> + # include < boost / test / unit_test . hpp > <nl> + <nl> + # include " Cache / TransactionalBucket . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < string > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - setup / tear - down <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + struct CCacheTransactionalBucketSetup { <nl> + CCacheTransactionalBucketSetup ( ) { <nl> + BOOST_TEST_MESSAGE ( " setup TransactionalBucket " ) ; <nl> + } <nl> + <nl> + ~ CCacheTransactionalBucketSetup ( ) { <nl> + BOOST_TEST_MESSAGE ( " tear - down TransactionalBucket " ) ; <nl> + } <nl> + } ; <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / - - SECTION - - test suite <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief setup <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_FIXTURE_TEST_SUITE ( CCacheTransactionalBucketTest , <nl> + CCacheTransactionalBucketSetup ) <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test lock methods <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_locks ) { <nl> + TransactionalBucket bucket ; <nl> + bool success ; <nl> + <nl> + / / check lock without contention <nl> + BOOST_CHECK ( ! bucket . isLocked ( ) ) ; <nl> + success = bucket . lock ( 0ULL , - 1LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + BOOST_CHECK ( bucket . isLocked ( ) ) ; <nl> + <nl> + / / check lock with contention <nl> + success = bucket . lock ( 0ULL , 10LL ) ; <nl> + BOOST_CHECK ( ! success ) ; <nl> + BOOST_CHECK ( bucket . isLocked ( ) ) ; <nl> + <nl> + / / check unlock <nl> + bucket . unlock ( ) ; <nl> + BOOST_CHECK ( ! bucket . isLocked ( ) ) ; <nl> + <nl> + / / check that blacklist term is updated appropriately <nl> + BOOST_CHECK_EQUAL ( 0ULL , bucket . _blacklistTerm ) ; <nl> + bucket . lock ( 1ULL , - 1LL ) ; <nl> + BOOST_CHECK_EQUAL ( 1ULL , bucket . _blacklistTerm ) ; <nl> + bucket . unlock ( ) ; <nl> + BOOST_CHECK_EQUAL ( 1ULL , bucket . _blacklistTerm ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test insertion to full and fail beyond <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_insertion ) { <nl> + TransactionalBucket bucket ; <nl> + bool success ; <nl> + <nl> + uint32_t hashes [ 4 ] = { <nl> + 1 , 2 , 3 , 4 } ; / / don ' t have to be real , but should be unique and non - zero <nl> + uint64_t keys [ 4 ] = { 0 , 1 , 2 , 3 } ; <nl> + uint64_t values [ 4 ] = { 0 , 1 , 2 , 3 } ; <nl> + CachedValue * ptrs [ 4 ] ; <nl> + for ( size_t i = 0 ; i < 4 ; i + + ) { <nl> + ptrs [ i ] = CachedValue : : construct ( & ( keys [ i ] ) , sizeof ( uint64_t ) , & ( values [ i ] ) , <nl> + sizeof ( uint64_t ) ) ; <nl> + } <nl> + <nl> + success = bucket . lock ( 0 , - 1LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + <nl> + / / insert three to fill <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + bucket . insert ( hashes [ i ] , ptrs [ i ] ) ; <nl> + if ( i < 2 ) { <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + } else { <nl> + BOOST_CHECK ( bucket . isFull ( ) ) ; <nl> + } <nl> + } <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + CachedValue * res = bucket . find ( hashes [ i ] , ptrs [ i ] - > key ( ) , ptrs [ i ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ i ] ) ; <nl> + } <nl> + <nl> + / / check that insert is ignored if full <nl> + bucket . insert ( hashes [ 3 ] , ptrs [ 3 ] ) ; <nl> + CachedValue * res = bucket . find ( hashes [ 3 ] , ptrs [ 3 ] - > key ( ) , ptrs [ 3 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + <nl> + bucket . unlock ( ) ; <nl> + <nl> + / / cleanup <nl> + for ( size_t i = 0 ; i < 4 ; i + + ) { <nl> + delete ptrs [ i ] ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test removal <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_removal ) { <nl> + TransactionalBucket bucket ; <nl> + bool success ; <nl> + <nl> + uint32_t hashes [ 3 ] = { <nl> + 1 , 2 , 3 } ; / / don ' t have to be real , but should be unique and non - zero <nl> + uint64_t keys [ 3 ] = { 0 , 1 , 2 } ; <nl> + uint64_t values [ 3 ] = { 0 , 1 , 2 } ; <nl> + CachedValue * ptrs [ 3 ] ; <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + ptrs [ i ] = CachedValue : : construct ( & ( keys [ i ] ) , sizeof ( uint64_t ) , & ( values [ i ] ) , <nl> + sizeof ( uint64_t ) ) ; <nl> + } <nl> + <nl> + success = bucket . lock ( 0 , - 1LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + bucket . insert ( hashes [ i ] , ptrs [ i ] ) ; <nl> + } <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + CachedValue * res = bucket . find ( hashes [ i ] , ptrs [ i ] - > key ( ) , ptrs [ i ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ i ] ) ; <nl> + } <nl> + <nl> + CachedValue * res ; <nl> + res = bucket . remove ( hashes [ 1 ] , ptrs [ 1 ] - > key ( ) , ptrs [ 1 ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ 1 ] ) ; <nl> + res = bucket . find ( hashes [ 1 ] , ptrs [ 1 ] - > key ( ) , ptrs [ 1 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + res = bucket . remove ( hashes [ 0 ] , ptrs [ 0 ] - > key ( ) , ptrs [ 0 ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ 0 ] ) ; <nl> + res = bucket . find ( hashes [ 0 ] , ptrs [ 0 ] - > key ( ) , ptrs [ 0 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + res = bucket . remove ( hashes [ 2 ] , ptrs [ 2 ] - > key ( ) , ptrs [ 2 ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ 2 ] ) ; <nl> + res = bucket . find ( hashes [ 2 ] , ptrs [ 2 ] - > key ( ) , ptrs [ 2 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + <nl> + bucket . unlock ( ) ; <nl> + <nl> + / / cleanup <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + delete ptrs [ i ] ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test eviction with subsequent insertion <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_eviction ) { <nl> + TransactionalBucket bucket ; <nl> + bool success ; <nl> + <nl> + uint32_t hashes [ 4 ] = { <nl> + 1 , 2 , 3 , 4 } ; / / don ' t have to be real , but should be unique and non - zero <nl> + uint64_t keys [ 4 ] = { 0 , 1 , 2 , 3 } ; <nl> + uint64_t values [ 4 ] = { 0 , 1 , 2 , 3 } ; <nl> + CachedValue * ptrs [ 4 ] ; <nl> + for ( size_t i = 0 ; i < 4 ; i + + ) { <nl> + ptrs [ i ] = CachedValue : : construct ( & ( keys [ i ] ) , sizeof ( uint64_t ) , & ( values [ i ] ) , <nl> + sizeof ( uint64_t ) ) ; <nl> + } <nl> + <nl> + success = bucket . lock ( 0 , - 1LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + <nl> + / / insert three to fill <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + bucket . insert ( hashes [ i ] , ptrs [ i ] ) ; <nl> + if ( i < 2 ) { <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + } else { <nl> + BOOST_CHECK ( bucket . isFull ( ) ) ; <nl> + } <nl> + } <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + CachedValue * res = bucket . find ( hashes [ i ] , ptrs [ i ] - > key ( ) , ptrs [ i ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ i ] ) ; <nl> + } <nl> + <nl> + / / check that we get proper eviction candidate <nl> + CachedValue * candidate = bucket . evictionCandidate ( ) ; <nl> + BOOST_CHECK ( candidate = = ptrs [ 0 ] ) ; <nl> + bucket . evict ( candidate , false ) ; <nl> + CachedValue * res = bucket . find ( hashes [ 0 ] , ptrs [ 0 ] - > key ( ) , ptrs [ 0 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + <nl> + / / check that we still find the right candidate if not full <nl> + candidate = bucket . evictionCandidate ( ) ; <nl> + BOOST_CHECK ( candidate = = ptrs [ 1 ] ) ; <nl> + bucket . evict ( candidate , true ) ; <nl> + res = bucket . find ( hashes [ 1 ] , ptrs [ 1 ] - > key ( ) , ptrs [ 1 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + <nl> + / / check that we can insert now after eviction optimized for insertion <nl> + bucket . insert ( hashes [ 3 ] , ptrs [ 3 ] ) ; <nl> + res = bucket . find ( hashes [ 3 ] , ptrs [ 3 ] - > key ( ) , ptrs [ 3 ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ 3 ] ) ; <nl> + <nl> + bucket . unlock ( ) ; <nl> + <nl> + / / cleanup <nl> + for ( size_t i = 0 ; i < 4 ; i + + ) { <nl> + delete ptrs [ i ] ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief test blacklist methods <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_CASE ( tst_blacklist ) { <nl> + TransactionalBucket bucket ; <nl> + bool success ; <nl> + CachedValue * res ; <nl> + <nl> + uint32_t hashes [ 7 ] = { 1 , 1 , 2 , 3 , <nl> + 4 , 5 , 6 } ; / / don ' t have to be real , want some overlap <nl> + uint64_t keys [ 6 ] = { 0 , 1 , 2 , 3 , 4 , 5 } ; <nl> + uint64_t values [ 6 ] = { 0 , 1 , 2 , 3 , 4 , 5 } ; <nl> + CachedValue * ptrs [ 6 ] ; <nl> + for ( size_t i = 0 ; i < 6 ; i + + ) { <nl> + ptrs [ i ] = CachedValue : : construct ( & ( keys [ i ] ) , sizeof ( uint64_t ) , & ( values [ i ] ) , <nl> + sizeof ( uint64_t ) ) ; <nl> + } <nl> + <nl> + success = bucket . lock ( 0 , - 1LL ) ; <nl> + BOOST_CHECK ( success ) ; <nl> + <nl> + / / insert three to fill <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + bucket . insert ( hashes [ i ] , ptrs [ i ] ) ; <nl> + if ( i < 2 ) { <nl> + BOOST_CHECK ( ! bucket . isFull ( ) ) ; <nl> + } else { <nl> + BOOST_CHECK ( bucket . isFull ( ) ) ; <nl> + } <nl> + } <nl> + for ( size_t i = 0 ; i < 3 ; i + + ) { <nl> + res = bucket . find ( hashes [ i ] , ptrs [ i ] - > key ( ) , ptrs [ i ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ i ] ) ; <nl> + } <nl> + <nl> + / / blacklist 1 - 4 to fill blacklist <nl> + for ( size_t i = 1 ; i < 5 ; i + + ) { <nl> + bucket . blacklist ( hashes [ i ] , ptrs [ i ] - > key ( ) , ptrs [ i ] - > keySize ) ; <nl> + } <nl> + for ( size_t i = 1 ; i < 5 ; i + + ) { <nl> + BOOST_CHECK ( bucket . isBlacklisted ( hashes [ i ] ) ) ; <nl> + res = bucket . find ( hashes [ i ] , ptrs [ i ] - > key ( ) , ptrs [ i ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + } <nl> + / / verify actually not fully blacklisted <nl> + BOOST_CHECK ( ! bucket . isFullyBlacklisted ( ) ) ; <nl> + BOOST_CHECK ( ! bucket . isBlacklisted ( hashes [ 6 ] ) ) ; <nl> + / / verify it didn ' t remove matching hash with non - matching key <nl> + res = bucket . find ( hashes [ 0 ] , ptrs [ 0 ] - > key ( ) , ptrs [ 0 ] - > keySize ) ; <nl> + BOOST_CHECK ( res = = ptrs [ 0 ] ) ; <nl> + <nl> + / / verify we can ' t insert a key with a blacklisted hash <nl> + bucket . insert ( hashes [ 1 ] , ptrs [ 1 ] ) ; <nl> + res = bucket . find ( hashes [ 1 ] , ptrs [ 1 ] - > key ( ) , ptrs [ 1 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + <nl> + / / proceed to fully blacklist <nl> + bucket . blacklist ( hashes [ 5 ] , ptrs [ 5 ] - > key ( ) , ptrs [ 5 ] - > keySize ) ; <nl> + BOOST_CHECK ( bucket . isBlacklisted ( hashes [ 5 ] ) ) ; <nl> + res = bucket . find ( hashes [ 5 ] , ptrs [ 5 ] - > key ( ) , ptrs [ 5 ] - > keySize ) ; <nl> + BOOST_CHECK ( nullptr = = res ) ; <nl> + / / make sure it still didn ' t remove non - matching key <nl> + res = bucket . find ( hashes [ 0 ] , ptrs [ 0 ] - > key ( ) , ptrs [ 0 ] - > keySize ) ; <nl> + BOOST_CHECK ( ptrs [ 0 ] = = res ) ; <nl> + / / make sure it ' s fully blacklisted <nl> + BOOST_CHECK ( bucket . isFullyBlacklisted ( ) ) ; <nl> + BOOST_CHECK ( bucket . isBlacklisted ( hashes [ 6 ] ) ) ; <nl> + <nl> + bucket . unlock ( ) ; <nl> + <nl> + / / check that updating blacklist term clears blacklist <nl> + bucket . lock ( 2ULL , - 1LL ) ; <nl> + BOOST_CHECK ( ! bucket . isFullyBlacklisted ( ) ) ; <nl> + for ( size_t i = 0 ; i < 7 ; i + + ) { <nl> + BOOST_CHECK ( ! bucket . isBlacklisted ( hashes [ i ] ) ) ; <nl> + } <nl> + bucket . unlock ( ) ; <nl> + <nl> + / / cleanup <nl> + for ( size_t i = 0 ; i < 6 ; i + + ) { <nl> + delete ptrs [ i ] ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief generate tests <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + BOOST_AUTO_TEST_SUITE_END ( ) <nl> + <nl> + / / Local Variables : <nl> + / / mode : outline - minor <nl> + / / outline - regexp : " ^ \ \ ( / / / @ brief \ \ | / / / { @ inheritDoc } \ \ | / / / @ addtogroup \ \ | / / <nl> + / / - - SECTION - - \ \ | / / / @ \ \ } \ \ ) " <nl> + / / End : <nl> mmm a / arangod / CMakeLists . txt <nl> ppp b / arangod / CMakeLists . txt <nl> SET ( ARANGOD_SOURCES <nl> Aql / VariableGenerator . cpp <nl> Aql / grammar . cpp <nl> Aql / tokens . cpp <nl> + Cache / Cache . cpp <nl> + Cache / CacheManagerFeature . cpp <nl> + Cache / CacheManagerFeatureThreads . cpp <nl> + Cache / CachedValue . cpp <nl> + Cache / Manager . cpp <nl> + Cache / ManagerTasks . cpp <nl> + Cache / Metadata . cpp <nl> + Cache / PlainBucket . cpp <nl> + Cache / PlainCache . cpp <nl> + Cache / Rebalancer . cpp <nl> + Cache / State . cpp <nl> + Cache / TransactionalBucket . cpp <nl> + Cache / TransactionalCache . cpp <nl> + Cache / TransactionWindow . cpp <nl> Cluster / AgencyCallback . cpp <nl> Cluster / AgencyCallbackRegistry . cpp <nl> Cluster / ClusterComm . cpp <nl> new file mode 100644 <nl> index 00000000000 . . 6a66f677a64 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / Cache . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / Cache . h " <nl> + # include " Basics / Common . h " <nl> + # include " Basics / fasthash . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / Manager . h " <nl> + # include " Cache / Metadata . h " <nl> + # include " Cache / State . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < algorithm > <nl> + # include < chrono > <nl> + # include < list > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + Cache : : Finding : : Finding ( CachedValue * v ) : _value ( v ) { <nl> + if ( _value ! = nullptr ) { <nl> + _value - > lease ( ) ; <nl> + } <nl> + } <nl> + <nl> + Cache : : Finding : : Finding ( Finding const & other ) : _value ( other . _value ) { <nl> + if ( _value ! = nullptr ) { <nl> + _value - > lease ( ) ; <nl> + } <nl> + } <nl> + <nl> + Cache : : Finding : : Finding ( Finding & & other ) : _value ( other . _value ) { <nl> + other . _value = nullptr ; <nl> + } <nl> + <nl> + Cache : : Finding & Cache : : Finding : : operator = ( Finding const & other ) { <nl> + if ( & other = = this ) { <nl> + return * this ; <nl> + } <nl> + <nl> + if ( _value ! = nullptr ) { <nl> + _value - > release ( ) ; <nl> + } <nl> + <nl> + _value = other . _value ; <nl> + if ( _value ! = nullptr ) { <nl> + _value - > lease ( ) ; <nl> + } <nl> + <nl> + return * this ; <nl> + } <nl> + <nl> + Cache : : Finding & Cache : : Finding : : operator = ( Finding & & other ) { <nl> + if ( & other = = this ) { <nl> + return * this ; <nl> + } <nl> + <nl> + if ( _value ! = nullptr ) { <nl> + _value - > release ( ) ; <nl> + } <nl> + <nl> + _value = other . _value ; <nl> + other . _value = nullptr ; <nl> + <nl> + return * this ; <nl> + } <nl> + <nl> + Cache : : Finding : : ~ Finding ( ) { <nl> + if ( _value ! = nullptr ) { <nl> + _value - > release ( ) ; <nl> + } <nl> + } <nl> + <nl> + void Cache : : Finding : : reset ( CachedValue * v ) { <nl> + if ( _value ! = nullptr ) { <nl> + _value - > release ( ) ; <nl> + } <nl> + <nl> + _value = v ; <nl> + if ( _value ! = nullptr ) { <nl> + _value - > lease ( ) ; <nl> + } <nl> + } <nl> + <nl> + bool Cache : : Finding : : found ( ) const { return ( _value ! = nullptr ) ; } <nl> + <nl> + CachedValue const * Cache : : Finding : : value ( ) const { return _value ; } <nl> + <nl> + CachedValue * Cache : : Finding : : copy ( ) const { <nl> + return ( ( _value = = nullptr ) ? nullptr : _value - > copy ( ) ) ; <nl> + } <nl> + <nl> + void Cache : : destroy ( std : : shared_ptr < Cache > cache ) { <nl> + if ( cache . get ( ) ! = nullptr ) { <nl> + cache - > shutdown ( ) ; <nl> + } <nl> + } <nl> + <nl> + uint64_t Cache : : limit ( ) { <nl> + uint64_t limit = 0 ; <nl> + _state . lock ( ) ; <nl> + if ( isOperational ( ) ) { <nl> + _metadata - > lock ( ) ; <nl> + limit = _metadata - > softLimit ( ) ; <nl> + _metadata - > unlock ( ) ; <nl> + } <nl> + _state . unlock ( ) ; <nl> + return limit ; <nl> + } <nl> + <nl> + uint64_t Cache : : usage ( ) { <nl> + uint64_t usage = 0 ; <nl> + _state . lock ( ) ; <nl> + if ( isOperational ( ) ) { <nl> + _metadata - > lock ( ) ; <nl> + usage = _metadata - > usage ( ) ; <nl> + _metadata - > unlock ( ) ; <nl> + } <nl> + _state . unlock ( ) ; <nl> + return usage ; <nl> + } <nl> + <nl> + bool Cache : : resize ( uint64_t requestedLimit ) { <nl> + _state . lock ( ) ; <nl> + bool allowed = isOperational ( ) ; <nl> + bool resized = false ; <nl> + startOperation ( ) ; <nl> + _state . unlock ( ) ; <nl> + <nl> + if ( allowed ) { <nl> + / / wait for previous resizes to finish <nl> + while ( true ) { <nl> + _metadata - > lock ( ) ; <nl> + if ( ! _metadata - > isSet ( State : : Flag : : resizing ) ) { <nl> + _metadata - > unlock ( ) ; <nl> + break ; <nl> + } <nl> + _metadata - > unlock ( ) ; <nl> + } <nl> + <nl> + resized = requestResize ( requestedLimit , false ) ; <nl> + } <nl> + endOperation ( ) ; <nl> + return resized ; <nl> + } <nl> + <nl> + Cache : : Cache ( Manager * manager , uint64_t requestedLimit , bool allowGrowth , <nl> + std : : function < void ( Cache * ) > deleter ) <nl> + : _state ( ) , <nl> + _allowGrowth ( allowGrowth ) , <nl> + _evictionStats ( 1024 ) , <nl> + _insertionCount ( 0 ) , <nl> + _manager ( manager ) , <nl> + _openOperations ( ) , <nl> + _migrateRequestTime ( std : : chrono : : steady_clock : : now ( ) ) , <nl> + _resizeRequestTime ( std : : chrono : : steady_clock : : now ( ) ) { <nl> + try { <nl> + _metadata = _manager - > registerCache ( this , requestedLimit , deleter ) ; <nl> + } catch ( std : : bad_alloc ) { <nl> + / / could not register , mark as non - operational <nl> + if ( ! _state . isSet ( State : : Flag : : shutdown ) ) { <nl> + _state . toggleFlag ( State : : Flag : : shutdown ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + bool Cache : : isOperational ( ) const { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + return ( ! _state . isSet ( State : : Flag : : shutdown ) & & <nl> + ! _state . isSet ( State : : Flag : : shuttingDown ) ) ; <nl> + } <nl> + <nl> + void Cache : : startOperation ( ) { + + _openOperations ; } <nl> + <nl> + void Cache : : endOperation ( ) { - - _openOperations ; } <nl> + <nl> + bool Cache : : isMigrating ( ) const { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + return _state . isSet ( State : : Flag : : migrating ) ; <nl> + } <nl> + <nl> + bool Cache : : requestResize ( uint64_t requestedLimit , bool internal ) { <nl> + bool resized = false ; <nl> + int64_t lockTries = internal ? 10LL : - 1LL ; <nl> + bool ok = _state . lock ( lockTries ) ; <nl> + if ( ok ) { <nl> + if ( ! internal | | ( _allowGrowth & & ( std : : chrono : : steady_clock : : now ( ) > <nl> + _resizeRequestTime ) ) ) { <nl> + _metadata - > lock ( ) ; <nl> + uint64_t newLimit = <nl> + ( requestedLimit > 0 ) ? requestedLimit : ( _metadata - > hardLimit ( ) * 2 ) ; <nl> + _metadata - > unlock ( ) ; <nl> + auto result = _manager - > requestResize ( _metadata , newLimit ) ; <nl> + _resizeRequestTime = result . second ; <nl> + resized = result . first ; <nl> + } <nl> + _state . unlock ( ) ; <nl> + } <nl> + return resized ; <nl> + } <nl> + <nl> + void Cache : : requestMigrate ( uint32_t requestedLogSize ) { <nl> + if ( ( + + _insertionCount & 0xFFF ) = = 0 ) { <nl> + auto stats = _evictionStats . getFrequencies ( ) ; <nl> + if ( ( ( stats - > size ( ) = = 1 ) & & <nl> + ( ( * stats ) [ 0 ] . first = = static_cast < uint8_t > ( Stat : : eviction ) ) ) | | <nl> + ( ( stats - > size ( ) = = 2 ) & & <nl> + ( ( * stats ) [ 0 ] . second * 16 > ( * stats ) [ 1 ] . second ) ) ) { <nl> + bool ok = _state . lock ( 10LL ) ; <nl> + if ( ok ) { <nl> + if ( ! isMigrating ( ) & & <nl> + ( std : : chrono : : steady_clock : : now ( ) > _migrateRequestTime ) ) { <nl> + _metadata - > lock ( ) ; <nl> + uint32_t newLogSize = ( requestedLogSize > 0 ) <nl> + ? requestedLogSize <nl> + : ( _metadata - > logSize ( ) + 1 ) ; <nl> + _metadata - > unlock ( ) ; <nl> + auto result = _manager - > requestMigrate ( _metadata , newLogSize ) ; <nl> + _resizeRequestTime = result . second ; <nl> + if ( result . first ) { <nl> + _evictionStats . clear ( ) ; <nl> + } <nl> + } <nl> + _state . unlock ( ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + void Cache : : freeValue ( CachedValue * value ) { <nl> + while ( value - > refCount . load ( ) > 0 ) { <nl> + usleep ( 1 ) ; <nl> + } <nl> + <nl> + delete value ; <nl> + } <nl> + <nl> + bool Cache : : reclaimMemory ( uint64_t size ) { <nl> + _metadata - > lock ( ) ; <nl> + _metadata - > adjustUsageIfAllowed ( - static_cast < int64_t > ( size ) ) ; <nl> + bool underLimit = ( _metadata - > softLimit ( ) > = _metadata - > usage ( ) ) ; <nl> + _metadata - > unlock ( ) ; <nl> + <nl> + return underLimit ; <nl> + } <nl> + <nl> + uint32_t Cache : : hashKey ( void const * key , uint32_t keySize ) const { <nl> + return std : : max ( static_cast < uint32_t > ( 1 ) , <nl> + fasthash32 ( key , keySize , 0xdeadbeefUL ) ) ; <nl> + } <nl> + <nl> + void Cache : : recordStat ( Cache : : Stat stat ) { <nl> + _evictionStats . insertRecord ( static_cast < uint8_t > ( stat ) ) ; <nl> + } <nl> + <nl> + Manager : : MetadataItr & Cache : : metadata ( ) { return _metadata ; } <nl> + <nl> + void Cache : : beginShutdown ( ) { <nl> + _state . lock ( ) ; <nl> + if ( ! _state . isSet ( State : : Flag : : shutdown ) & & <nl> + ! _state . isSet ( State : : Flag : : shuttingDown ) ) { <nl> + _state . toggleFlag ( State : : Flag : : shuttingDown ) ; <nl> + } <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + void Cache : : shutdown ( ) { <nl> + _state . lock ( ) ; <nl> + if ( ! _state . isSet ( State : : Flag : : shutdown ) ) { <nl> + if ( ! _state . isSet ( State : : Flag : : shuttingDown ) ) { <nl> + _state . toggleFlag ( State : : Flag : : shuttingDown ) ; <nl> + } <nl> + <nl> + while ( _openOperations . load ( ) > 0 ) { <nl> + _state . unlock ( ) ; <nl> + usleep ( 10 ) ; <nl> + _state . lock ( ) ; <nl> + } <nl> + <nl> + _state . clear ( ) ; <nl> + _state . toggleFlag ( State : : Flag : : shutdown ) ; <nl> + clearTables ( ) ; <nl> + _manager - > unregisterCache ( _metadata ) ; <nl> + } <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + bool Cache : : canResize ( ) { <nl> + bool allowed = true ; <nl> + _state . lock ( ) ; <nl> + if ( isOperational ( ) ) { <nl> + _metadata - > lock ( ) ; <nl> + if ( _metadata - > isSet ( State : : Flag : : resizing ) ) { <nl> + allowed = false ; <nl> + } <nl> + _metadata - > unlock ( ) ; <nl> + } else { <nl> + allowed = false ; <nl> + } <nl> + _state . unlock ( ) ; <nl> + <nl> + return allowed ; <nl> + } <nl> + <nl> + bool Cache : : canMigrate ( ) { <nl> + bool allowed = true ; <nl> + _state . lock ( ) ; <nl> + if ( isOperational ( ) ) { <nl> + _metadata - > lock ( ) ; <nl> + if ( _metadata - > isSet ( State : : Flag : : migrating ) ) { <nl> + allowed = false ; <nl> + } <nl> + _metadata - > unlock ( ) ; <nl> + } else { <nl> + allowed = false ; <nl> + } <nl> + _state . unlock ( ) ; <nl> + <nl> + return allowed ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . a77b27ea572 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / Cache . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_CACHE_H <nl> + # define ARANGODB_CACHE_CACHE_H <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / FrequencyBuffer . h " <nl> + # include " Cache / Manager . h " <nl> + # include " Cache / ManagerTasks . h " <nl> + # include " Cache / Metadata . h " <nl> + # include " Cache / State . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < list > <nl> + # include < memory > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief The common structure of all caches managed by Manager . <nl> + / / / <nl> + / / / Any pure virtual functions are documented in derived classes implementing <nl> + / / / them . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + class Cache { <nl> + public : <nl> + typedef FrequencyBuffer < uint8_t > StatBuffer ; <nl> + <nl> + public : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief A helper class for managing CachedValue lifecycles . <nl> + / / / <nl> + / / / Returned to clients by Cache : : find . Clients must destroy the Finding <nl> + / / / object within a short period of time to allow proper memory management <nl> + / / / within the cache system . If the underlying value needs to be retained for <nl> + / / / any significant period of time , it must be copied so that the finding <nl> + / / / object may be destroyed . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + class Finding { <nl> + public : <nl> + Finding ( CachedValue * v ) ; <nl> + Finding ( Finding const & other ) ; <nl> + Finding ( Finding & & other ) ; <nl> + Finding & operator = ( Finding const & other ) ; <nl> + Finding & operator = ( Finding & & other ) ; <nl> + ~ Finding ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Changes the underlying CachedValue pointer . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void reset ( CachedValue * v ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Specifies whether the value was found . If not , value is nullptr . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool found ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Returns the underlying value pointer . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + CachedValue const * value ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Creates a copy of the underlying value and returns a pointer . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + CachedValue * copy ( ) const ; <nl> + <nl> + private : <nl> + CachedValue * _value ; <nl> + } ; <nl> + <nl> + public : <nl> + / / primary functionality ; documented in derived classes <nl> + virtual Finding find ( void const * key , uint32_t keySize ) = 0 ; <nl> + virtual bool insert ( CachedValue * value ) = 0 ; <nl> + virtual bool remove ( void const * key , uint32_t keySize ) = 0 ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Returns the limit on memory usage for this cache in bytes . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t limit ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Returns the current memory usage for this cache in bytes . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t usage ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Request that this cache be given a new limit as specified . <nl> + / / / <nl> + / / / If there is enough free memory globally and the cache is not currently <nl> + / / / resizing , the request should be granted . If downsizing the cache , it may <nl> + / / / need to free some memory , which will be done in an asynchronous task . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool resize ( uint64_t requestedLimit = 0 ) ; <nl> + <nl> + protected : <nl> + State _state ; <nl> + <nl> + / / whether to allow the cache to resize larger when it fills <nl> + bool _allowGrowth ; <nl> + <nl> + / / structures to handle eviction - upon - insertion rate <nl> + enum class Stat : uint8_t { eviction = 1 , noEviction = 2 } ; <nl> + StatBuffer _evictionStats ; <nl> + std : : atomic < uint64_t > _insertionCount ; <nl> + <nl> + / / allow communication with manager <nl> + Manager * _manager ; <nl> + Manager : : MetadataItr _metadata ; <nl> + <nl> + / / keep track of number of open operations to allow clean shutdown <nl> + std : : atomic < uint32_t > _openOperations ; <nl> + <nl> + / / times to wait until requesting is allowed again <nl> + Manager : : time_point _migrateRequestTime ; <nl> + Manager : : time_point _resizeRequestTime ; <nl> + <nl> + / / friend class manager and tasks <nl> + friend class FreeMemoryTask ; <nl> + friend class Manager ; <nl> + friend class MigrateTask ; <nl> + <nl> + protected : <nl> + / / shutdown cache and let its memory be reclaimed <nl> + static void destroy ( std : : shared_ptr < Cache > cache ) ; <nl> + <nl> + Cache ( Manager * manager , uint64_t requestedLimit , bool allowGrowth , <nl> + std : : function < void ( Cache * ) > deleter ) ; <nl> + <nl> + bool isOperational ( ) const ; <nl> + void startOperation ( ) ; <nl> + void endOperation ( ) ; <nl> + <nl> + bool isMigrating ( ) const ; <nl> + bool requestResize ( uint64_t requestedLimit = 0 , bool internal = true ) ; <nl> + void requestMigrate ( uint32_t requestedLogSize = 0 ) ; <nl> + <nl> + void freeValue ( CachedValue * value ) ; <nl> + bool reclaimMemory ( uint64_t size ) ; <nl> + virtual void clearTables ( ) = 0 ; <nl> + <nl> + uint32_t hashKey ( void const * key , uint32_t keySize ) const ; <nl> + void recordStat ( Cache : : Stat stat ) ; <nl> + <nl> + / / management <nl> + Manager : : MetadataItr & metadata ( ) ; <nl> + void beginShutdown ( ) ; <nl> + void shutdown ( ) ; <nl> + bool canResize ( ) ; <nl> + bool canMigrate ( ) ; <nl> + virtual bool freeMemory ( ) = 0 ; <nl> + virtual bool migrate ( ) = 0 ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 97d570cf96f <nl> mmm / dev / null <nl> ppp b / arangod / Cache / CacheManagerFeature . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2016 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Dr . Frank Celler <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " CacheManagerFeature . h " <nl> + <nl> + # ifdef _WIN32 <nl> + # include < stdio . h > <nl> + # include < windows . h > <nl> + # endif <nl> + <nl> + # include " ApplicationFeatures / ApplicationServer . h " <nl> + # include " Basics / ArangoGlobalContext . h " <nl> + # include " Basics / WorkMonitor . h " <nl> + # include " Basics / asio - helper . h " <nl> + # include " Cache / CacheManagerFeatureThreads . h " <nl> + # include " Cache / Manager . h " <nl> + # include " Logger / LogAppender . h " <nl> + # include " ProgramOptions / ProgramOptions . h " <nl> + # include " ProgramOptions / Section . h " <nl> + / / # include " RestServer / ServerFeature . h " <nl> + # include " Scheduler / Scheduler . h " <nl> + # include " Scheduler / SchedulerFeature . h " <nl> + <nl> + using namespace arangodb ; <nl> + using namespace arangodb : : application_features ; <nl> + using namespace arangodb : : basics ; <nl> + using namespace arangodb : : cache ; <nl> + using namespace arangodb : : options ; <nl> + using namespace arangodb : : rest ; <nl> + <nl> + Manager * CacheManagerFeature : : MANAGER = nullptr ; <nl> + <nl> + static constexpr uint64_t MIN_REBALANCING_INTERVAL = 500 * 1000 ; <nl> + <nl> + CacheManagerFeature : : CacheManagerFeature ( <nl> + application_features : : ApplicationServer * server ) <nl> + : ApplicationFeature ( server , " CacheManager " ) , <nl> + _manager ( nullptr ) , <nl> + _rebalancer ( nullptr ) , <nl> + _cacheSize ( 16 * 1024 * 1024 ) , <nl> + _rebalancingInterval ( 2 * 1000 * 1000 ) { <nl> + / / TODO : set intelligent default for _cacheSize <nl> + setOptional ( true ) ; <nl> + requiresElevatedPrivileges ( false ) ; <nl> + startsAfter ( " Scheduler " ) ; <nl> + } <nl> + <nl> + CacheManagerFeature : : ~ CacheManagerFeature ( ) { } <nl> + <nl> + void CacheManagerFeature : : collectOptions ( <nl> + std : : shared_ptr < options : : ProgramOptions > options ) { <nl> + options - > addSection ( " cache " , " Configure the hash cache " ) ; <nl> + <nl> + options - > addOption ( " - - cache . size " , " size of cache in bytes " , <nl> + new UInt64Parameter ( & _cacheSize ) ) ; <nl> + <nl> + options - > addOption ( " - - cache . rebalancing - interval " , <nl> + " microseconds between rebalancing attempts " , <nl> + new UInt64Parameter ( & _rebalancingInterval ) ) ; <nl> + } <nl> + <nl> + void CacheManagerFeature : : validateOptions ( <nl> + std : : shared_ptr < options : : ProgramOptions > ) { <nl> + if ( _cacheSize < Manager : : MINIMUM_SIZE ) { <nl> + LOG_TOPIC ( FATAL , arangodb : : Logger : : FIXME ) <nl> + < < " invalid value for ` - - cache . size ' , need at least " <nl> + < < Manager : : MINIMUM_SIZE ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + if ( _cacheSize < ( MIN_REBALANCING_INTERVAL ) ) { <nl> + LOG_TOPIC ( FATAL , arangodb : : Logger : : FIXME ) <nl> + < < " invalid value for ` - - cache . rebalancing - interval ' , need at least " <nl> + < < ( MIN_REBALANCING_INTERVAL ) ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + } <nl> + <nl> + void CacheManagerFeature : : start ( ) { <nl> + auto scheduler = SchedulerFeature : : SCHEDULER ; <nl> + auto ioService = ( scheduler = = nullptr ) ? nullptr : scheduler - > ioService ( ) ; <nl> + _manager . reset ( new Manager ( ioService , _cacheSize ) ) ; <nl> + MANAGER = _manager . get ( ) ; <nl> + _rebalancer . reset ( <nl> + new CacheRebalancerThread ( _manager . get ( ) , _rebalancingInterval ) ) ; <nl> + _rebalancer - > start ( ) ; <nl> + LOG_TOPIC ( DEBUG , Logger : : STARTUP ) < < " cache manager has started " ; <nl> + } <nl> + <nl> + void CacheManagerFeature : : beginShutdown ( ) { <nl> + if ( _manager ! = nullptr ) { <nl> + _manager - > beginShutdown ( ) ; <nl> + _rebalancer - > beginShutdown ( ) ; <nl> + } <nl> + } <nl> + <nl> + void CacheManagerFeature : : stop ( ) { <nl> + if ( _manager ! = nullptr ) { <nl> + _manager - > shutdown ( ) ; <nl> + } <nl> + } <nl> + <nl> + void CacheManagerFeature : : unprepare ( ) { MANAGER = nullptr ; } <nl> new file mode 100644 <nl> index 00000000000 . . 7646559ba91 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / CacheManagerFeature . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2016 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGOD_CACHE_CACHE_MANAGER_FEATURE_H <nl> + # define ARANGOD_CACHE_CACHE_MANAGER_FEATURE_H 1 <nl> + <nl> + # include " ApplicationFeatures / ApplicationFeature . h " <nl> + <nl> + # include " Basics / asio - helper . h " <nl> + # include " Cache / CacheManagerFeatureThreads . h " <nl> + # include " Cache / Manager . h " <nl> + <nl> + namespace arangodb { <nl> + <nl> + class CacheManagerFeature final <nl> + : public application_features : : ApplicationFeature { <nl> + public : <nl> + static cache : : Manager * MANAGER ; <nl> + <nl> + public : <nl> + explicit CacheManagerFeature ( application_features : : ApplicationServer * server ) ; <nl> + ~ CacheManagerFeature ( ) ; <nl> + <nl> + public : <nl> + void collectOptions ( std : : shared_ptr < options : : ProgramOptions > ) override final ; <nl> + void validateOptions ( std : : shared_ptr < options : : ProgramOptions > ) override final ; <nl> + void start ( ) override final ; <nl> + void beginShutdown ( ) override final ; <nl> + void stop ( ) override final ; <nl> + void unprepare ( ) override final ; <nl> + <nl> + private : <nl> + std : : unique_ptr < cache : : Manager > _manager ; <nl> + std : : unique_ptr < CacheRebalancerThread > _rebalancer ; <nl> + uint64_t _cacheSize ; <nl> + uint64_t _rebalancingInterval ; <nl> + } ; <nl> + } <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 925a89a069c <nl> mmm / dev / null <nl> ppp b / arangod / Cache / CacheManagerFeatureThreads . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / CacheManagerFeatureThreads . h " <nl> + # include " Basics / Common . h " <nl> + # include " Basics / ConditionLocker . h " <nl> + # include " Basics / ConditionVariable . h " <nl> + # include " Basics / Thread . h " <nl> + # include " Cache / Manager . h " <nl> + # include " Cache / Rebalancer . h " <nl> + <nl> + # include < stdint . h > <nl> + <nl> + using namespace arangodb ; <nl> + <nl> + CacheRebalancerThread : : CacheRebalancerThread ( cache : : Manager * manager , <nl> + uint64_t interval ) <nl> + : Thread ( " CacheRebalancerThread " ) , <nl> + _manager ( manager ) , <nl> + _rebalancer ( _manager ) , <nl> + _fullInterval ( interval ) , <nl> + _shortInterval ( 100 ) { } <nl> + <nl> + CacheRebalancerThread : : ~ CacheRebalancerThread ( ) { shutdown ( ) ; } <nl> + <nl> + void CacheRebalancerThread : : beginShutdown ( ) { <nl> + Thread : : beginShutdown ( ) ; <nl> + <nl> + CONDITION_LOCKER ( guard , _condition ) ; <nl> + guard . signal ( ) ; <nl> + } <nl> + <nl> + void CacheRebalancerThread : : run ( ) { <nl> + while ( ! isStopping ( ) ) { <nl> + bool ran = _rebalancer . rebalance ( ) ; <nl> + uint64_t interval = ran ? _fullInterval : _shortInterval ; <nl> + <nl> + CONDITION_LOCKER ( guard , _condition ) ; <nl> + guard . wait ( interval ) ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . c0a486590da <nl> mmm / dev / null <nl> ppp b / arangod / Cache / CacheManagerFeatureThreads . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_MANAGER_FEATURE_THREADS_H <nl> + # define ARANGODB_CACHE_MANAGER_FEATURE_THREADS_H <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Basics / ConditionVariable . h " <nl> + # include " Basics / Thread . h " <nl> + # include " Cache / Manager . h " <nl> + # include " Cache / Rebalancer . h " <nl> + <nl> + # include < stdint . h > <nl> + <nl> + namespace arangodb { <nl> + <nl> + class CacheRebalancerThread : public Thread { <nl> + public : <nl> + CacheRebalancerThread ( cache : : Manager * manager , uint64_t interval ) ; <nl> + ~ CacheRebalancerThread ( ) ; <nl> + <nl> + void beginShutdown ( ) override ; <nl> + <nl> + protected : <nl> + void run ( ) override ; <nl> + <nl> + private : <nl> + cache : : Manager * _manager ; <nl> + cache : : Rebalancer _rebalancer ; <nl> + uint64_t _fullInterval ; <nl> + uint64_t _shortInterval ; <nl> + basics : : ConditionVariable _condition ; <nl> + } ; <nl> + <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 6e0248a6190 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / CachedValue . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / CachedValue . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < cstring > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + uint8_t const * CachedValue : : key ( ) const { <nl> + uint8_t const * buf = reinterpret_cast < uint8_t const * > ( this ) ; <nl> + return ( buf + sizeof ( CachedValue ) ) ; <nl> + } <nl> + <nl> + uint8_t const * CachedValue : : value ( ) const { <nl> + if ( valueSize = = 0 ) { <nl> + return nullptr ; <nl> + } <nl> + <nl> + uint8_t const * buf = reinterpret_cast < uint8_t const * > ( this ) ; <nl> + return ( buf + sizeof ( CachedValue ) + keySize ) ; <nl> + } <nl> + <nl> + uint64_t CachedValue : : size ( ) const { <nl> + uint64_t size = sizeof ( CachedValue ) ; <nl> + size + = keySize ; <nl> + size + = valueSize ; <nl> + return size ; <nl> + } <nl> + <nl> + bool CachedValue : : sameKey ( void const * k , uint32_t kSize ) const { <nl> + if ( keySize ! = kSize ) { <nl> + return false ; <nl> + } <nl> + <nl> + return ( 0 = = memcmp ( key ( ) , k , keySize ) ) ; <nl> + } <nl> + <nl> + void CachedValue : : lease ( ) { refCount + + ; } <nl> + <nl> + void CachedValue : : release ( ) { refCount - - ; } <nl> + <nl> + bool CachedValue : : isFreeable ( ) { return ( refCount . load ( ) = = 0 ) ; } <nl> + <nl> + CachedValue * CachedValue : : copy ( ) const { <nl> + uint8_t * buf = new uint8_t [ size ( ) ] ; <nl> + memcpy ( buf , this , size ( ) ) ; <nl> + return reinterpret_cast < CachedValue * > ( buf ) ; <nl> + } <nl> + <nl> + CachedValue * CachedValue : : construct ( void const * k , uint32_t kSize , <nl> + void const * v , uint64_t vSize ) { <nl> + if ( kSize = = 0 | | k = = nullptr | | ( vSize > 0 & & v = = nullptr ) ) { <nl> + return nullptr ; <nl> + } <nl> + <nl> + uint8_t * buf = new uint8_t [ sizeof ( CachedValue ) + kSize + vSize ] ; <nl> + CachedValue * cv = reinterpret_cast < CachedValue * > ( buf ) ; <nl> + <nl> + cv - > refCount = 0 ; <nl> + cv - > keySize = kSize ; <nl> + cv - > valueSize = vSize ; <nl> + std : : memcpy ( const_cast < uint8_t * > ( cv - > key ( ) ) , k , kSize ) ; <nl> + if ( vSize > 0 ) { <nl> + std : : memcpy ( const_cast < uint8_t * > ( cv - > value ( ) ) , v , vSize ) ; <nl> + } <nl> + <nl> + return cv ; <nl> + } <nl> + <nl> + void CachedValue : : operator delete ( void * ptr ) { <nl> + delete [ ] reinterpret_cast < uint8_t * > ( ptr ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 5ac9bf1a3fc <nl> mmm / dev / null <nl> ppp b / arangod / Cache / CachedValue . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_CACHED_VALUE_H <nl> + # define ARANGODB_CACHE_CACHED_VALUE_H <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief This is the beginning of a cache data entry . <nl> + / / / <nl> + / / / It will be allocated using new uint8_t [ ] with the correct size for header , <nl> + / / / key and value . The key and value reside directly behind the header entries <nl> + / / / contained in this struct . The reference count is used to lend CachedValues <nl> + / / / to clients . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + struct CachedValue { <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Reference count ( to avoid premature deletion ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + std : : atomic < uint32_t > refCount ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Size of the key in bytes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint32_t keySize ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Size of the value in bytes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t valueSize ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Returns a pointer offset to the key <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint8_t const * key ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Returns a pointer offset to the value <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint8_t const * value ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Returns the allocated size of bytes including the key and value <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t size ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Utility method to compare underlying key to external key <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool sameKey ( void const * k , uint32_t kSize ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Increase reference count <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void lease ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Decrease reference count <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void release ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Checks whether value can be freed ( i . e . no references to it ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool isFreeable ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Create a copy of this CachedValue object <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + CachedValue * copy ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Construct a CachedValue object from a given key and value <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + static CachedValue * construct ( void const * k , uint32_t kSize , void const * v , <nl> + uint64_t vSize ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Custom deleter to handle casting issues <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + static void operator delete ( void * ptr ) ; <nl> + } ; <nl> + <nl> + / / ensure that header size is what we expect <nl> + static_assert ( sizeof ( CachedValue ) = = 16 ) ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 41836733f66 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / FrequencyBuffer . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_FREQUENCY_BUFFER_H <nl> + # define ARANGODB_CACHE_FREQUENCY_BUFFER_H <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < algorithm > <nl> + # include < atomic > <nl> + # include < memory > <nl> + # include < unordered_map > <nl> + # include < utility > <nl> + # include < vector > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Lockless structure to calculate approximate relative event <nl> + / / / frequencies . <nl> + / / / <nl> + / / / Used to record events and then compute the number of occurrences of each <nl> + / / / within a certain time - frame . The underlying structure is a circular buffer <nl> + / / / which over - writes itself after it fills up ( thus only maintaining a recent <nl> + / / / window on the records ) . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + template < class T > <nl> + class FrequencyBuffer { <nl> + public : <nl> + typedef std : : vector < std : : pair < T , uint64_t > > stats_t ; <nl> + <nl> + private : <nl> + std : : atomic < uint64_t > _current ; <nl> + uint64_t _capacity ; <nl> + uint64_t _mask ; <nl> + std : : unique_ptr < T [ ] > _buffer ; <nl> + <nl> + public : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Initialize with the given capacity . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + FrequencyBuffer ( uint64_t capacity ) : _current ( 0 ) { <nl> + size_t i = 0 ; <nl> + for ( ; ( 1ULL < < i ) < capacity ; i + + ) { <nl> + } <nl> + _capacity = ( 1 < < i ) ; <nl> + _mask = _capacity - 1 ; <nl> + _buffer . reset ( new T [ _capacity ] ( ) ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Reports the memory usage in bytes . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t memoryUsage ( ) { <nl> + return ( ( _capacity * sizeof ( T ) ) + sizeof ( FrequencyBuffer < T > ) ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Insert an individual event record . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void insertRecord ( T const & record ) { <nl> + + + _current ; <nl> + _buffer [ _current & _mask ] = record ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Remove all occurrences of the specified event record . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void purgeRecord ( T const & record ) { <nl> + for ( size_t i = 0 ; i < _capacity ; i + + ) { <nl> + if ( _buffer [ i ] = = record ) { <nl> + _buffer [ i ] = T ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Return a list of ( event , count ) pairs for each recorded event in <nl> + / / / ascending order . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + std : : shared_ptr < FrequencyBuffer : : stats_t > getFrequencies ( ) const { <nl> + / / calculate frequencies <nl> + std : : unordered_map < T , uint64_t > frequencies ; <nl> + for ( size_t i = 0 ; i < _capacity ; i + + ) { <nl> + T entry = _buffer [ i ] ; <nl> + if ( entry ! = T ( ) ) { <nl> + frequencies [ entry ] + + ; <nl> + } <nl> + } <nl> + <nl> + / / gather and sort frequencies <nl> + std : : shared_ptr < stats_t > data ( new stats_t ( ) ) ; <nl> + data - > reserve ( frequencies . size ( ) ) ; <nl> + for ( auto f : frequencies ) { <nl> + data - > emplace_back ( std : : pair < T , uint64_t > ( f . first , f . second ) ) ; <nl> + } <nl> + std : : sort ( data - > begin ( ) , data - > end ( ) , <nl> + [ ] ( std : : pair < T , uint64_t > & left , std : : pair < T , uint64_t > & right ) { <nl> + return left . second < right . second ; <nl> + } ) ; <nl> + <nl> + return data ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Clear the buffer , removing all event records . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void clear ( ) { <nl> + for ( size_t i = 0 ; i < _capacity ; i + + ) { <nl> + _buffer [ i ] = T ( ) ; <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . f2994ea2c28 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / Manager . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / Manager . h " <nl> + # include " Basics / Common . h " <nl> + # include " Basics / asio - helper . h " <nl> + # include " Cache / Cache . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / FrequencyBuffer . h " <nl> + # include " Cache / ManagerTasks . h " <nl> + # include " Cache / Metadata . h " <nl> + # include " Cache / PlainCache . h " <nl> + # include " Cache / State . h " <nl> + # include " Cache / TransactionalCache . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < algorithm > <nl> + # include < atomic > <nl> + # include < chrono > <nl> + # include < list > <nl> + # include < memory > <nl> + # include < set > <nl> + # include < stack > <nl> + # include < utility > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + uint64_t Manager : : MINIMUM_SIZE = 1024 * 1024 ; <nl> + <nl> + static constexpr size_t TABLE_LOG_SIZE_ADJUSTMENT = 6 ; <nl> + static constexpr size_t MIN_TABLE_LOG_SIZE = 3 ; <nl> + static constexpr size_t MIN_LOG_SIZE = 10 ; <nl> + static constexpr size_t MIN_CACHE_SIZE = 1024 ; <nl> + / / use 16 for sizeof std : : list node - - should be valid for most libraries <nl> + static constexpr uint64_t CACHE_RECORD_OVERHEAD = sizeof ( Metadata ) + 16 ; <nl> + / / assume at most 16 slots in each stack - - TODO : check validity <nl> + static constexpr uint64_t TABLE_LISTS_OVERHEAD = 32 * 16 * 8 ; <nl> + static constexpr int64_t TRIES_FAST = 100 ; <nl> + <nl> + Manager : : Manager ( boost : : asio : : io_service * ioService , uint64_t globalLimit ) <nl> + : _state ( ) , <nl> + _accessStats ( ( globalLimit > = ( 1024ULL * 1024ULL * 1024ULL ) ) <nl> + ? ( ( 1024ULL * 1024ULL ) / sizeof ( std : : shared_ptr < Cache > ) ) <nl> + : ( globalLimit / 8192ULL ) ) , <nl> + _accessCounter ( 0 ) , <nl> + _caches ( ) , <nl> + _globalSoftLimit ( globalLimit ) , <nl> + _globalHardLimit ( globalLimit ) , <nl> + _globalAllocation ( sizeof ( Manager ) + TABLE_LISTS_OVERHEAD + <nl> + _accessStats . memoryUsage ( ) ) , <nl> + _transactions ( ) , <nl> + _ioService ( ioService ) , <nl> + _resizeAttempt ( 0 ) , <nl> + _outstandingTasks ( 0 ) , <nl> + _rebalancingTasks ( 0 ) , <nl> + _resizingTasks ( 0 ) { <nl> + TRI_ASSERT ( _globalAllocation < _globalSoftLimit ) ; <nl> + TRI_ASSERT ( _globalAllocation < _globalHardLimit ) ; <nl> + } <nl> + <nl> + Manager : : ~ Manager ( ) { shutdown ( ) ; } <nl> + <nl> + std : : shared_ptr < Cache > Manager : : createCache ( Manager : : CacheType type , <nl> + uint64_t requestedLimit , <nl> + bool allowGrowth ) { <nl> + std : : shared_ptr < Cache > result ( nullptr ) ; <nl> + _state . lock ( ) ; <nl> + bool allowed = isOperational ( ) ; <nl> + _state . unlock ( ) ; <nl> + <nl> + if ( allowed ) { <nl> + switch ( type ) { <nl> + case CacheType : : Plain : <nl> + result = PlainCache : : create ( this , requestedLimit , allowGrowth ) ; <nl> + break ; <nl> + case CacheType : : Transactional : <nl> + result = TransactionalCache : : create ( this , requestedLimit , allowGrowth ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + void Manager : : destroyCache ( std : : shared_ptr < Cache > cache ) { <nl> + Cache : : destroy ( cache ) ; <nl> + } <nl> + <nl> + void Manager : : beginShutdown ( ) { <nl> + _state . lock ( ) ; <nl> + if ( isOperational ( ) ) { <nl> + _state . toggleFlag ( State : : Flag : : shuttingDown ) ; <nl> + for ( MetadataItr metadata = _caches . begin ( ) ; metadata ! = _caches . end ( ) ; <nl> + metadata + + ) { <nl> + metadata - > lock ( ) ; <nl> + metadata - > cache ( ) - > beginShutdown ( ) ; <nl> + metadata - > unlock ( ) ; <nl> + } <nl> + } <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + void Manager : : shutdown ( ) { <nl> + _state . lock ( ) ; <nl> + if ( ! _state . isSet ( State : : Flag : : shutdown ) ) { <nl> + if ( ! _state . isSet ( State : : Flag : : shuttingDown ) ) { <nl> + _state . toggleFlag ( State : : Flag : : shuttingDown ) ; <nl> + } <nl> + while ( ! _caches . empty ( ) ) { <nl> + _caches . begin ( ) - > lock ( ) ; <nl> + std : : shared_ptr < Cache > cache = _caches . begin ( ) - > cache ( ) ; <nl> + _caches . begin ( ) - > unlock ( ) ; <nl> + _state . unlock ( ) ; <nl> + cache - > shutdown ( ) ; <nl> + _state . lock ( ) ; <nl> + } <nl> + freeUnusedTables ( ) ; <nl> + _state . clear ( ) ; <nl> + _state . toggleFlag ( State : : Flag : : shutdown ) ; <nl> + } <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + / / change global cache limit <nl> + bool Manager : : resize ( uint64_t newGlobalLimit ) { <nl> + if ( newGlobalLimit < MINIMUM_SIZE ) { <nl> + return false ; <nl> + } <nl> + <nl> + bool success = true ; <nl> + _state . lock ( ) ; <nl> + <nl> + if ( ! isOperational ( ) | | globalProcessRunning ( ) ) { <nl> + / / shut ( ting ) down or still have another global process running already <nl> + success = false ; <nl> + } else { <nl> + / / otherwise we need to actually resize <nl> + _state . toggleFlag ( State : : Flag : : resizing ) ; <nl> + internalResize ( newGlobalLimit , true ) ; <nl> + } <nl> + <nl> + _state . unlock ( ) ; <nl> + return success ; <nl> + } <nl> + <nl> + uint64_t Manager : : globalLimit ( ) { <nl> + _state . lock ( ) ; <nl> + uint64_t limit = <nl> + _state . isSet ( State : : Flag : : resizing ) ? _globalSoftLimit : _globalHardLimit ; <nl> + _state . unlock ( ) ; <nl> + <nl> + return limit ; <nl> + } <nl> + <nl> + uint64_t Manager : : globalAllocation ( ) { <nl> + _state . lock ( ) ; <nl> + uint64_t allocation = _globalAllocation ; <nl> + _state . unlock ( ) ; <nl> + <nl> + return allocation ; <nl> + } <nl> + <nl> + void Manager : : startTransaction ( ) { _transactions . start ( ) ; } <nl> + <nl> + void Manager : : endTransaction ( ) { _transactions . end ( ) ; } <nl> + <nl> + Manager : : MetadataItr Manager : : registerCache ( <nl> + Cache * cache , uint64_t requestedLimit , <nl> + std : : function < void ( Cache * ) > deleter ) { <nl> + uint32_t logSize = 0 ; <nl> + uint32_t tableLogSize = MIN_TABLE_LOG_SIZE ; <nl> + for ( ; ( 1ULL < < logSize ) < requestedLimit ; logSize + + ) { <nl> + } <nl> + uint64_t grantedLimit = 1ULL < < logSize ; <nl> + if ( logSize > ( TABLE_LOG_SIZE_ADJUSTMENT + MIN_TABLE_LOG_SIZE ) ) { <nl> + tableLogSize = logSize - TABLE_LOG_SIZE_ADJUSTMENT ; <nl> + } <nl> + <nl> + _state . lock ( ) ; <nl> + if ( ! isOperational ( ) ) { <nl> + _state . unlock ( ) ; <nl> + throw std : : bad_alloc ( ) ; <nl> + } <nl> + <nl> + while ( logSize > = MIN_LOG_SIZE ) { <nl> + uint64_t tableAllocation = <nl> + _tables [ tableLogSize ] . empty ( ) ? tableSize ( tableLogSize ) : 0 ; <nl> + if ( increaseAllowed ( grantedLimit + tableAllocation + <nl> + CACHE_RECORD_OVERHEAD ) ) { <nl> + break ; <nl> + } <nl> + <nl> + grantedLimit > > = 1U ; <nl> + logSize - - ; <nl> + if ( tableLogSize > MIN_TABLE_LOG_SIZE ) { <nl> + tableLogSize - - ; <nl> + } <nl> + } <nl> + <nl> + if ( logSize < MIN_LOG_SIZE ) { <nl> + _state . unlock ( ) ; <nl> + throw std : : bad_alloc ( ) ; <nl> + } <nl> + <nl> + _globalAllocation + = ( grantedLimit + CACHE_RECORD_OVERHEAD ) ; <nl> + _caches . emplace_front ( std : : shared_ptr < Cache > ( cache , deleter ) , grantedLimit ) ; <nl> + MetadataItr metadata = _caches . begin ( ) ; <nl> + metadata - > lock ( ) ; <nl> + leaseTable ( metadata , tableLogSize ) ; <nl> + metadata - > unlock ( ) ; <nl> + _state . unlock ( ) ; <nl> + <nl> + return metadata ; <nl> + } <nl> + <nl> + void Manager : : unregisterCache ( Manager : : MetadataItr & metadata ) { <nl> + _state . lock ( ) ; <nl> + <nl> + if ( _caches . empty ( ) ) { <nl> + _state . unlock ( ) ; <nl> + return ; <nl> + } <nl> + <nl> + metadata - > lock ( ) ; <nl> + _globalAllocation - = ( metadata - > hardLimit ( ) + CACHE_RECORD_OVERHEAD ) ; <nl> + reclaimTables ( metadata ) ; <nl> + _accessStats . purgeRecord ( metadata - > cache ( ) ) ; <nl> + metadata - > unlock ( ) ; <nl> + <nl> + _caches . erase ( metadata ) ; <nl> + <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + std : : pair < bool , Manager : : time_point > Manager : : requestResize ( <nl> + Manager : : MetadataItr & metadata , uint64_t requestedLimit ) { <nl> + Manager : : time_point nextRequest = futureTime ( 30 ) ; <nl> + bool allowed = false ; <nl> + <nl> + bool ok = _state . lock ( TRIES_FAST ) ; <nl> + if ( ok ) { <nl> + if ( isOperational ( ) & & ! _state . isSet ( State : : Flag : : resizing ) ) { <nl> + metadata - > lock ( ) ; <nl> + <nl> + if ( ! metadata - > isSet ( State : : Flag : : resizing ) & & <nl> + ( ( requestedLimit < metadata - > hardLimit ( ) ) | | <nl> + increaseAllowed ( requestedLimit - metadata - > hardLimit ( ) ) ) ) { <nl> + allowed = true ; <nl> + if ( requestedLimit > metadata - > hardLimit ( ) ) { <nl> + / / if cache is growing , let it keep growing quickly <nl> + nextRequest = std : : chrono : : steady_clock : : now ( ) ; <nl> + } <nl> + resizeCache ( TaskEnvironment : : none , metadata , <nl> + requestedLimit ) ; / / unlocks metadata <nl> + } else { <nl> + metadata - > unlock ( ) ; <nl> + } <nl> + } <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + return std : : pair < bool , Manager : : time_point > ( allowed , nextRequest ) ; <nl> + } <nl> + <nl> + std : : pair < bool , Manager : : time_point > Manager : : requestMigrate ( <nl> + Manager : : MetadataItr & metadata , uint32_t requestedLogSize ) { <nl> + Manager : : time_point nextRequest = futureTime ( 30 ) ; <nl> + bool allowed = false ; <nl> + <nl> + bool ok = _state . lock ( TRIES_FAST ) ; <nl> + if ( ok ) { <nl> + if ( isOperational ( ) & & ! _state . isSet ( State : : Flag : : resizing ) ) { <nl> + if ( ! _tables [ requestedLogSize ] . empty ( ) | | <nl> + increaseAllowed ( tableSize ( requestedLogSize ) ) ) { <nl> + allowed = true ; <nl> + } <nl> + if ( allowed ) { <nl> + metadata - > lock ( ) ; <nl> + if ( metadata - > isSet ( State : : Flag : : migrating ) ) { <nl> + allowed = false ; <nl> + metadata - > unlock ( ) ; <nl> + } else { <nl> + nextRequest = std : : chrono : : steady_clock : : now ( ) ; <nl> + migrateCache ( TaskEnvironment : : none , metadata , <nl> + requestedLogSize ) ; / / unlocks metadata <nl> + } <nl> + } <nl> + } <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + return std : : pair < bool , Manager : : time_point > ( allowed , nextRequest ) ; <nl> + } <nl> + <nl> + void Manager : : reportAccess ( std : : shared_ptr < Cache > cache ) { <nl> + if ( ( ( + + _accessCounter ) & 0x7FULL ) = = 0 ) { / / record 1 in 128 <nl> + _accessStats . insertRecord ( cache ) ; <nl> + } <nl> + } <nl> + <nl> + bool Manager : : isOperational ( ) const { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + return ( ! _state . isSet ( State : : Flag : : shutdown ) & & <nl> + ! _state . isSet ( State : : Flag : : shuttingDown ) ) ; <nl> + } <nl> + <nl> + bool Manager : : globalProcessRunning ( ) const { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + return ( _state . isSet ( State : : Flag : : rebalancing ) | | <nl> + _state . isSet ( State : : Flag : : resizing ) ) ; <nl> + } <nl> + <nl> + boost : : asio : : io_service * Manager : : ioService ( ) { return _ioService ; } <nl> + <nl> + void Manager : : prepareTask ( Manager : : TaskEnvironment environment ) { <nl> + _outstandingTasks + + ; <nl> + switch ( environment ) { <nl> + case TaskEnvironment : : rebalancing : { <nl> + _rebalancingTasks + + ; <nl> + break ; <nl> + } <nl> + case TaskEnvironment : : resizing : { <nl> + _resizingTasks + + ; <nl> + break ; <nl> + } <nl> + case TaskEnvironment : : none : <nl> + default : { break ; } <nl> + } <nl> + } <nl> + <nl> + void Manager : : unprepareTask ( Manager : : TaskEnvironment environment ) { <nl> + switch ( environment ) { <nl> + case TaskEnvironment : : rebalancing : { <nl> + if ( ( - - _rebalancingTasks ) = = 0 ) { <nl> + _state . lock ( ) ; <nl> + _state . toggleFlag ( State : : Flag : : rebalancing ) ; <nl> + _state . unlock ( ) ; <nl> + } ; <nl> + break ; <nl> + } <nl> + case TaskEnvironment : : resizing : { <nl> + if ( ( - - _resizingTasks ) = = 0 ) { <nl> + _state . lock ( ) ; <nl> + internalResize ( _globalSoftLimit , false ) ; <nl> + _state . unlock ( ) ; <nl> + } ; <nl> + break ; <nl> + } <nl> + case TaskEnvironment : : none : <nl> + default : { break ; } <nl> + } <nl> + <nl> + _outstandingTasks - - ; <nl> + } <nl> + <nl> + bool Manager : : rebalance ( ) { <nl> + _state . lock ( ) ; <nl> + if ( ! isOperational ( ) | | globalProcessRunning ( ) ) { <nl> + _state . unlock ( ) ; <nl> + return false ; <nl> + } <nl> + <nl> + / / start rebalancing <nl> + _state . toggleFlag ( State : : Flag : : rebalancing ) ; <nl> + <nl> + / / determine strategy <nl> + <nl> + / / allow background tasks if more than 7 / 8ths full <nl> + bool allowTasks = <nl> + _globalAllocation > ( _globalHardLimit - ( _globalHardLimit > > 3 ) ) ; <nl> + <nl> + / / be aggressive if more than 3 / 4ths full <nl> + bool beAggressive = <nl> + _globalAllocation > ( _globalHardLimit - ( _globalHardLimit > > 2 ) ) ; <nl> + <nl> + / / aim for 1 / 4th with background tasks , 1 / 8th if no tasks but aggressive , no <nl> + / / goal otherwise <nl> + uint64_t goal = beAggressive ? ( allowTasks ? ( _globalAllocation > > 2 ) <nl> + : ( _globalAllocation > > 3 ) ) <nl> + : 0 ; <nl> + <nl> + / / get stats on cache access to prioritize freeing from less frequently used <nl> + / / caches first , so more frequently used ones stay large <nl> + std : : shared_ptr < PriorityList > cacheList = priorityList ( ) ; <nl> + <nl> + / / just adjust limits <nl> + uint64_t reclaimed = resizeAllCaches ( TaskEnvironment : : rebalancing , cacheList , <nl> + allowTasks , beAggressive , goal ) ; <nl> + _globalAllocation - = reclaimed ; <nl> + <nl> + if ( _rebalancingTasks . load ( ) = = 0 ) { <nl> + _state . toggleFlag ( State : : Flag : : rebalancing ) ; <nl> + } <nl> + <nl> + _state . unlock ( ) ; <nl> + return true ; <nl> + } <nl> + <nl> + void Manager : : internalResize ( uint64_t newGlobalLimit , bool firstAttempt ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + bool done = false ; <nl> + std : : shared_ptr < PriorityList > cacheList ( nullptr ) ; <nl> + uint64_t reclaimed = 0 ; <nl> + <nl> + if ( firstAttempt ) { <nl> + _resizeAttempt = 0 ; <nl> + } <nl> + <nl> + if ( ! isOperational ( ) ) { <nl> + / / abort resizing process so we can shutdown <nl> + done = true ; <nl> + } <nl> + <nl> + / / if limit is safe , just set it <nl> + done = adjustGlobalLimitsIfAllowed ( newGlobalLimit ) ; <nl> + <nl> + / / see if we can free enough from unused tables <nl> + if ( ! done ) { <nl> + freeUnusedTables ( ) ; <nl> + done = adjustGlobalLimitsIfAllowed ( newGlobalLimit ) ; <nl> + } <nl> + <nl> + / / must resize individual caches <nl> + if ( ! done ) { <nl> + _globalSoftLimit = newGlobalLimit ; <nl> + <nl> + / / get stats on cache access to prioritize freeing from less frequently used <nl> + / / caches first , so more frequently used ones stay large <nl> + cacheList = priorityList ( ) ; <nl> + <nl> + / / first just adjust limits down to usage <nl> + reclaimed = resizeAllCaches ( TaskEnvironment : : resizing , cacheList , true , <nl> + true , _globalAllocation - _globalSoftLimit ) ; <nl> + _globalAllocation - = reclaimed ; <nl> + done = adjustGlobalLimitsIfAllowed ( newGlobalLimit ) ; <nl> + } <nl> + <nl> + / / still haven ' t freed enough , now try cutting allocations more aggressively <nl> + / / by allowing use of background tasks to actually free memory from caches <nl> + if ( ! done ) { <nl> + if ( ( _resizeAttempt % 2 ) = = 0 ) { <nl> + reclaimed = resizeAllCaches ( TaskEnvironment : : resizing , cacheList , false , <nl> + true , _globalAllocation - _globalSoftLimit ) ; <nl> + } else { <nl> + reclaimed = migrateAllCaches ( TaskEnvironment : : resizing , cacheList , <nl> + _globalAllocation - _globalSoftLimit ) ; <nl> + } <nl> + } <nl> + <nl> + if ( ( _resizingTasks . load ( ) = = 0 ) ) { <nl> + _state . toggleFlag ( State : : Flag : : resizing ) ; <nl> + } <nl> + } <nl> + <nl> + uint64_t Manager : : resizeAllCaches ( Manager : : TaskEnvironment environment , <nl> + std : : shared_ptr < PriorityList > cacheList , <nl> + bool noTasks , bool aggressive , <nl> + uint64_t goal ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + uint64_t reclaimed = 0 ; <nl> + <nl> + for ( std : : shared_ptr < Cache > c : * cacheList ) { <nl> + / / skip this cache if it is already resizing or shutdown ! <nl> + if ( ! c - > canResize ( ) ) { <nl> + continue ; <nl> + } <nl> + <nl> + MetadataItr metadata = c - > metadata ( ) ; <nl> + metadata - > lock ( ) ; <nl> + <nl> + uint64_t newLimit ; <nl> + if ( aggressive ) { <nl> + newLimit = <nl> + ( noTasks ? metadata - > usage ( ) <nl> + : std : : min ( metadata - > usage ( ) , metadata - > hardLimit ( ) / 4 ) ) ; <nl> + } else { <nl> + newLimit = <nl> + ( noTasks ? std : : max ( metadata - > usage ( ) , metadata - > hardLimit ( ) / 2 ) <nl> + : std : : min ( metadata - > usage ( ) , metadata - > hardLimit ( ) / 2 ) ) ; <nl> + } <nl> + newLimit = std : : max ( newLimit , MIN_CACHE_SIZE ) ; <nl> + <nl> + reclaimed + = metadata - > hardLimit ( ) - newLimit ; <nl> + resizeCache ( environment , metadata , newLimit ) ; / / unlocks cache <nl> + <nl> + if ( goal > 0 & & reclaimed > = goal ) { <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + return reclaimed ; <nl> + } <nl> + <nl> + uint64_t Manager : : migrateAllCaches ( Manager : : TaskEnvironment environment , <nl> + std : : shared_ptr < PriorityList > cacheList , <nl> + uint64_t goal ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + uint64_t reclaimed = 0 ; <nl> + <nl> + for ( std : : shared_ptr < Cache > c : * cacheList ) { <nl> + / / skip this cache if it is already migrating or shutdown ! <nl> + if ( ! c - > canMigrate ( ) ) { <nl> + continue ; <nl> + } <nl> + <nl> + MetadataItr metadata = c - > metadata ( ) ; <nl> + metadata - > lock ( ) ; <nl> + <nl> + uint32_t logSize = metadata - > logSize ( ) ; <nl> + if ( ( logSize > MIN_TABLE_LOG_SIZE ) & & <nl> + increaseAllowed ( tableSize ( logSize - 1 ) ) ) { <nl> + reclaimed + = ( tableSize ( logSize ) - tableSize ( logSize - 1 ) ) ; <nl> + migrateCache ( environment , metadata , logSize - 1 ) ; / / unlocks metadata <nl> + } <nl> + if ( metadata - > isLocked ( ) ) { <nl> + metadata - > unlock ( ) ; <nl> + } <nl> + <nl> + if ( goal > 0 & & reclaimed > = goal ) { <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + return reclaimed ; <nl> + } <nl> + <nl> + void Manager : : freeUnusedTables ( ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + for ( size_t i = 0 ; i < 32 ; i + + ) { <nl> + while ( ! _tables [ i ] . empty ( ) ) { <nl> + uint8_t * table = _tables [ i ] . top ( ) ; <nl> + delete [ ] table ; <nl> + _tables [ i ] . pop ( ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + bool Manager : : adjustGlobalLimitsIfAllowed ( uint64_t newGlobalLimit ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + if ( newGlobalLimit < _globalAllocation ) { <nl> + return false ; <nl> + } <nl> + <nl> + _globalSoftLimit = newGlobalLimit ; <nl> + _globalHardLimit = newGlobalLimit ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void Manager : : resizeCache ( Manager : : TaskEnvironment environment , <nl> + Manager : : MetadataItr & metadata , uint64_t newLimit ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + TRI_ASSERT ( metadata - > isLocked ( ) ) ; <nl> + <nl> + if ( metadata - > usage ( ) < = newLimit ) { <nl> + bool success = metadata - > adjustLimits ( newLimit , newLimit ) ; <nl> + TRI_ASSERT ( success ) ; <nl> + metadata - > unlock ( ) ; <nl> + return ; <nl> + } <nl> + <nl> + bool success = metadata - > adjustLimits ( newLimit , metadata - > hardLimit ( ) ) ; <nl> + TRI_ASSERT ( success ) ; <nl> + TRI_ASSERT ( ! metadata - > isSet ( State : : Flag : : resizing ) ) ; <nl> + metadata - > toggleFlag ( State : : Flag : : resizing ) ; <nl> + metadata - > unlock ( ) ; <nl> + <nl> + auto task = std : : make_shared < FreeMemoryTask > ( environment , this , metadata ) ; <nl> + bool dispatched = task - > dispatch ( ) ; <nl> + if ( ! dispatched ) { <nl> + / / TODO : decide what to do if we don ' t have an io_service <nl> + } <nl> + } <nl> + <nl> + void Manager : : migrateCache ( Manager : : TaskEnvironment environment , <nl> + Manager : : MetadataItr & metadata , uint32_t logSize ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + TRI_ASSERT ( metadata - > isLocked ( ) ) ; <nl> + <nl> + bool unlocked ; <nl> + try { <nl> + leaseTable ( metadata , logSize ) ; <nl> + TRI_ASSERT ( ! metadata - > isSet ( State : : Flag : : migrating ) ) ; <nl> + metadata - > toggleFlag ( State : : Flag : : migrating ) ; <nl> + metadata - > unlock ( ) ; <nl> + unlocked = true ; <nl> + <nl> + auto task = std : : make_shared < MigrateTask > ( environment , this , metadata ) ; <nl> + bool dispatched = task - > dispatch ( ) ; <nl> + if ( ! dispatched ) { <nl> + / / TODO : decide what to do if we don ' t have an io_service <nl> + metadata - > lock ( ) ; <nl> + reclaimTables ( metadata , true ) ; <nl> + metadata - > unlock ( ) ; <nl> + } <nl> + } catch ( std : : bad_alloc ) { <nl> + if ( unlocked ) { <nl> + metadata - > lock ( ) ; <nl> + } <nl> + if ( metadata - > auxiliaryTable ( ) ! = nullptr ) { <nl> + uint8_t * junk = metadata - > releaseAuxiliaryTable ( ) ; <nl> + delete junk ; <nl> + } <nl> + metadata - > unlock ( ) ; <nl> + } <nl> + } <nl> + <nl> + void Manager : : leaseTable ( Manager : : MetadataItr & metadata , uint32_t logSize ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + TRI_ASSERT ( metadata - > isLocked ( ) ) ; <nl> + <nl> + uint8_t * table = nullptr ; <nl> + if ( _tables [ logSize ] . empty ( ) ) { <nl> + table = reinterpret_cast < uint8_t * > ( new PlainBucket [ 1 < < logSize ] ) ; <nl> + memset ( table , 0 , tableSize ( logSize ) ) ; <nl> + _globalAllocation + = tableSize ( logSize ) ; <nl> + } else { <nl> + table = _tables [ logSize ] . top ( ) ; <nl> + _tables [ logSize ] . pop ( ) ; <nl> + } <nl> + <nl> + / / if main null , main , otherwise auxiliary <nl> + metadata - > grantAuxiliaryTable ( table , logSize ) ; <nl> + if ( metadata - > table ( ) = = nullptr ) { <nl> + metadata - > swapTables ( ) ; <nl> + } <nl> + } <nl> + <nl> + void Manager : : reclaimTables ( Manager : : MetadataItr & metadata , <nl> + bool auxiliaryOnly ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + TRI_ASSERT ( metadata - > isLocked ( ) ) ; <nl> + <nl> + uint8_t * table ; <nl> + uint32_t logSize ; <nl> + <nl> + logSize = metadata - > auxiliaryLogSize ( ) ; <nl> + table = metadata - > releaseAuxiliaryTable ( ) ; <nl> + if ( table ! = nullptr ) { <nl> + _tables [ logSize ] . push ( table ) ; <nl> + } <nl> + <nl> + if ( auxiliaryOnly ) { <nl> + return ; <nl> + } <nl> + <nl> + logSize = metadata - > logSize ( ) ; <nl> + table = metadata - > releaseTable ( ) ; <nl> + if ( table ! = nullptr ) { <nl> + _tables [ logSize ] . push ( table ) ; <nl> + } <nl> + } <nl> + <nl> + bool Manager : : increaseAllowed ( uint64_t increase ) const { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + if ( _state . isSet ( State : : Flag : : resizing ) & & <nl> + ( _globalAllocation < = _globalSoftLimit ) ) { <nl> + return ( increase < = ( _globalSoftLimit - _globalAllocation ) ) ; <nl> + } <nl> + <nl> + return ( increase < = ( _globalHardLimit - _globalAllocation ) ) ; <nl> + } <nl> + <nl> + uint64_t Manager : : tableSize ( uint32_t logSize ) const { <nl> + return ( sizeof ( PlainBucket ) * ( 1ULL < < logSize ) ) ; <nl> + } <nl> + <nl> + std : : shared_ptr < Manager : : PriorityList > Manager : : priorityList ( ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + std : : shared_ptr < PriorityList > list ( new PriorityList ( ) ) ; <nl> + list - > reserve ( _caches . size ( ) ) ; <nl> + <nl> + / / catalog accessed caches <nl> + auto stats = _accessStats . getFrequencies ( ) ; <nl> + std : : set < Cache * > accessed ; <nl> + for ( auto s : * stats ) { <nl> + accessed . emplace ( s . first . get ( ) ) ; <nl> + } <nl> + <nl> + / / gather all unaccessed caches at beginning of list <nl> + for ( MetadataItr m = _caches . begin ( ) ; m ! = _caches . end ( ) ; m + + ) { <nl> + m - > lock ( ) ; <nl> + std : : shared_ptr < Cache > cache = m - > cache ( ) ; <nl> + m - > unlock ( ) ; <nl> + <nl> + auto found = accessed . find ( cache . get ( ) ) ; <nl> + if ( found = = accessed . end ( ) ) { <nl> + list - > emplace_back ( cache ) ; <nl> + } <nl> + } <nl> + <nl> + / / gather all accessed caches in order <nl> + for ( auto s : * stats ) { <nl> + list - > emplace_back ( s . first ) ; <nl> + } <nl> + <nl> + return list ; <nl> + } <nl> + <nl> + Manager : : time_point Manager : : futureTime ( uint64_t secondsFromNow ) { <nl> + return ( std : : chrono : : steady_clock : : now ( ) + <nl> + std : : chrono : : seconds ( secondsFromNow ) ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . cd7d6336b9d <nl> mmm / dev / null <nl> ppp b / arangod / Cache / Manager . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_MANAGER_H <nl> + # define ARANGODB_CACHE_MANAGER_H <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Basics / asio - helper . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / FrequencyBuffer . h " <nl> + # include " Cache / Metadata . h " <nl> + # include " Cache / State . h " <nl> + # include " Cache / TransactionWindow . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + # include < chrono > <nl> + # include < list > <nl> + # include < memory > <nl> + # include < stack > <nl> + # include < utility > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + class Cache ; / / forward declaration <nl> + class FreeMemoryTask ; / / forward declaration <nl> + class MigrateTask ; / / forward declaration <nl> + class Rebalancer ; / / forward declaration <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Coordinates a system of caches all sharing a single memory pool . <nl> + / / / <nl> + / / / Allows clients to create and destroy both transactional and <nl> + / / / non - transactional caches with individual usage limits , but all subject to a <nl> + / / / combined global limit . Re - uses memory from old , destroyed caches if possible <nl> + / / / when allocating new ones to allow fast creation and destruction of <nl> + / / / short - lived caches . <nl> + / / / <nl> + / / / The global limit may be adjusted , and compliance may be achieved through <nl> + / / / asynchronous background tasks . The manager periodically rebalances the <nl> + / / / allocations across the pool of caches to allow more frequently used ones to <nl> + / / / have more space . <nl> + / / / <nl> + / / / There should be a single Manager instance exposed via <nl> + / / / CacheManagerFeature : : MANAGER mmm use this unless you are very certain you <nl> + / / / need a different instance . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + class Manager { <nl> + public : <nl> + static uint64_t MINIMUM_SIZE ; <nl> + typedef FrequencyBuffer < std : : shared_ptr < Cache > > StatBuffer ; <nl> + typedef std : : vector < std : : shared_ptr < Cache > > PriorityList ; <nl> + typedef std : : chrono : : time_point < std : : chrono : : steady_clock > time_point ; <nl> + typedef std : : list < Metadata > : : iterator MetadataItr ; <nl> + <nl> + public : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Initialize the manager with an io_service and global usage limit . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + Manager ( boost : : asio : : io_service * ioService , uint64_t globalLimit ) ; <nl> + ~ Manager ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Enum to specify which type of cache to create . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + enum CacheType { Plain , Transactional } ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Creates an individual cache . <nl> + / / / <nl> + / / / The type must be specified . It is possible that the cache cannot be <nl> + / / / created ( e . g . in situations of extreme memory pressure ) , in which case the <nl> + / / / returned pointer will be nullptr . If there isn ' t enough memory to create a <nl> + / / / cache with the requested limit , the actual limit may be smaller . If the <nl> + / / / third parameter is true , the cache will be allowed to grow if it becomes <nl> + / / / full and memory is available globally ; otherwise the limit given to it by <nl> + / / / the manager is a hard upper limit which may only be adjusted downward . <nl> + / / / This parameter is true by default . It should likely only be set to be <nl> + / / / false for low - priority , short - lived caches . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + std : : shared_ptr < Cache > createCache ( Manager : : CacheType type , <nl> + uint64_t requestedLimit , <nl> + bool allowGrowth = true ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Destroy the given cache . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void destroyCache ( std : : shared_ptr < Cache > cache ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Prepare for shutdown . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void beginShutdown ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Actually shutdown the manager and all caches . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void shutdown ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Change the global usage limit . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool resize ( uint64_t newGlobalLimit ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Report the current global usage limit . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t globalLimit ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Report the current amoutn of memory allocated to all caches . <nl> + / / / <nl> + / / / This serves as an upper bound on the current memory usage of all caches . <nl> + / / / The actual global usage is not recorded , as this would require significant <nl> + / / / additional synchronization between the caches and slow things down <nl> + / / / considerably . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t globalAllocation ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Signal the beginning of a transaction . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void startTransaction ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Signal the end of a transaction . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void endTransaction ( ) ; <nl> + <nl> + private : <nl> + / / simple state variable for locking and other purposes <nl> + State _state ; <nl> + <nl> + / / structure to handle access frequency monitoring <nl> + Manager : : StatBuffer _accessStats ; <nl> + std : : atomic < uint64_t > _accessCounter ; <nl> + <nl> + / / list of metadata objects to keep track of all the registered caches <nl> + std : : list < Metadata > _caches ; <nl> + <nl> + / / actual tables to lease out <nl> + std : : stack < uint8_t * > _tables [ 32 ] ; <nl> + <nl> + / / global statistics <nl> + uint64_t _globalSoftLimit ; <nl> + uint64_t _globalHardLimit ; <nl> + uint64_t _globalAllocation ; <nl> + <nl> + / / transaction management <nl> + TransactionWindow _transactions ; <nl> + <nl> + / / task management <nl> + enum TaskEnvironment { none , rebalancing , resizing } ; <nl> + boost : : asio : : io_service * _ioService ; <nl> + uint64_t _resizeAttempt ; <nl> + std : : atomic < uint64_t > _outstandingTasks ; <nl> + std : : atomic < uint64_t > _rebalancingTasks ; <nl> + std : : atomic < uint64_t > _resizingTasks ; <nl> + <nl> + / / friend class tasks and caches to allow access <nl> + friend class Cache ; <nl> + friend class FreeMemoryTask ; <nl> + friend class MigrateTask ; <nl> + friend class PlainCache ; <nl> + friend class Rebalancer ; <nl> + friend class TransactionalCache ; <nl> + <nl> + private : / / used by caches <nl> + / / register and unregister individual caches <nl> + Manager : : MetadataItr registerCache ( Cache * cache , uint64_t requestedLimit , <nl> + std : : function < void ( Cache * ) > deleter ) ; <nl> + void unregisterCache ( Manager : : MetadataItr & metadata ) ; <nl> + <nl> + / / allow individual caches to request changes to their allocations <nl> + std : : pair < bool , Manager : : time_point > requestResize ( <nl> + Manager : : MetadataItr & metadata , uint64_t requestedLimit ) ; <nl> + std : : pair < bool , Manager : : time_point > requestMigrate ( <nl> + Manager : : MetadataItr & metadata , uint32_t requestedLogSize ) ; <nl> + <nl> + / / method for lr - accessed heuristics <nl> + void reportAccess ( std : : shared_ptr < Cache > cache ) ; <nl> + <nl> + private : / / used internally and by tasks <nl> + / / check if shutdown or shutting down <nl> + bool isOperational ( ) const ; <nl> + / / check if there is already a global process running <nl> + bool globalProcessRunning ( ) const ; <nl> + <nl> + / / expose io_service <nl> + boost : : asio : : io_service * ioService ( ) ; <nl> + <nl> + / / coordinate state with task lifecycles <nl> + void prepareTask ( TaskEnvironment environment ) ; <nl> + void unprepareTask ( TaskEnvironment environment ) ; <nl> + <nl> + / / periodically run to rebalance allocations globally <nl> + bool rebalance ( ) ; <nl> + <nl> + / / helpers for global resizing <nl> + void internalResize ( uint64_t newGlobalLimit , bool firstAttempt ) ; <nl> + uint64_t resizeAllCaches ( TaskEnvironment environment , <nl> + std : : shared_ptr < PriorityList > cacheList , <nl> + bool noTasks , bool aggressive , uint64_t goal ) ; <nl> + uint64_t migrateAllCaches ( TaskEnvironment environment , <nl> + std : : shared_ptr < PriorityList > cacheList , <nl> + uint64_t goal ) ; <nl> + void freeUnusedTables ( ) ; <nl> + bool adjustGlobalLimitsIfAllowed ( uint64_t newGlobalLimit ) ; <nl> + <nl> + / / methods to adjust individual caches <nl> + void resizeCache ( TaskEnvironment environment , Manager : : MetadataItr & metadata , <nl> + uint64_t newLimit ) ; <nl> + void migrateCache ( TaskEnvironment environment , Manager : : MetadataItr & metadata , <nl> + uint32_t logSize ) ; <nl> + void leaseTable ( Manager : : MetadataItr & metadata , uint32_t logSize ) ; <nl> + void reclaimTables ( Manager : : MetadataItr & metadata , <nl> + bool auxiliaryOnly = false ) ; <nl> + <nl> + / / helpers for individual allocations <nl> + bool increaseAllowed ( uint64_t increase ) const ; <nl> + uint64_t tableSize ( uint32_t logSize ) const ; <nl> + <nl> + / / helper for lr - accessed heuristics <nl> + std : : shared_ptr < PriorityList > priorityList ( ) ; <nl> + <nl> + / / helper for wait times <nl> + Manager : : time_point futureTime ( uint64_t secondsFromNow ) ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 26c9772f225 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / ManagerTasks . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / ManagerTasks . h " <nl> + # include " Basics / Common . h " <nl> + # include " Basics / asio - helper . h " <nl> + # include " Cache / Cache . h " <nl> + # include " Cache / Manager . h " <nl> + # include " Cache / Metadata . h " <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + FreeMemoryTask : : FreeMemoryTask ( Manager : : TaskEnvironment environment , <nl> + Manager * manager , Manager : : MetadataItr & metadata ) <nl> + : _environment ( environment ) , _manager ( manager ) { <nl> + metadata - > lock ( ) ; <nl> + _cache = metadata - > cache ( ) ; <nl> + metadata - > unlock ( ) ; <nl> + } <nl> + <nl> + FreeMemoryTask : : ~ FreeMemoryTask ( ) { } <nl> + <nl> + bool FreeMemoryTask : : dispatch ( ) { <nl> + auto ioService = _manager - > ioService ( ) ; <nl> + if ( ioService = = nullptr ) { <nl> + return false ; <nl> + } <nl> + <nl> + _manager - > prepareTask ( _environment ) ; <nl> + auto self = shared_from_this ( ) ; <nl> + ioService - > post ( [ self , this ] ( ) - > void { run ( ) ; } ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void FreeMemoryTask : : run ( ) { <nl> + bool ran = _cache - > freeMemory ( ) ; <nl> + <nl> + if ( ran ) { <nl> + _manager - > _state . lock ( ) ; <nl> + auto metadata = _cache - > metadata ( ) ; <nl> + metadata - > lock ( ) ; <nl> + uint64_t reclaimed = metadata - > hardLimit ( ) - metadata - > softLimit ( ) ; <nl> + metadata - > adjustLimits ( metadata - > softLimit ( ) , metadata - > softLimit ( ) ) ; <nl> + metadata - > toggleFlag ( State : : Flag : : resizing ) ; <nl> + metadata - > unlock ( ) ; <nl> + _manager - > _globalAllocation - = reclaimed ; <nl> + _manager - > _state . unlock ( ) ; <nl> + } <nl> + <nl> + _manager - > unprepareTask ( _environment ) ; <nl> + } <nl> + <nl> + MigrateTask : : MigrateTask ( Manager : : TaskEnvironment environment , Manager * manager , <nl> + Manager : : MetadataItr & metadata ) <nl> + : _environment ( environment ) , _manager ( manager ) { <nl> + metadata - > lock ( ) ; <nl> + _cache = metadata - > cache ( ) ; <nl> + metadata - > unlock ( ) ; <nl> + } <nl> + <nl> + MigrateTask : : ~ MigrateTask ( ) { } <nl> + <nl> + bool MigrateTask : : dispatch ( ) { <nl> + auto ioService = _manager - > ioService ( ) ; <nl> + if ( ioService = = nullptr ) { <nl> + return false ; <nl> + } <nl> + <nl> + _manager - > prepareTask ( _environment ) ; <nl> + auto self = shared_from_this ( ) ; <nl> + ioService - > post ( [ self , this ] ( ) - > void { run ( ) ; } ) ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void MigrateTask : : run ( ) { <nl> + / / do the actual migration <nl> + bool ran = _cache - > migrate ( ) ; <nl> + <nl> + if ( ran ) { <nl> + _manager - > _state . lock ( ) ; <nl> + auto metadata = _cache - > metadata ( ) ; <nl> + metadata - > lock ( ) ; <nl> + _manager - > reclaimTables ( metadata , true ) ; <nl> + metadata - > toggleFlag ( State : : Flag : : migrating ) ; <nl> + metadata - > unlock ( ) ; <nl> + _manager - > _state . unlock ( ) ; <nl> + } <nl> + <nl> + _manager - > unprepareTask ( _environment ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 078944f49a6 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / ManagerTasks . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_MANAGER_TASKS_H <nl> + # define ARANGODB_CACHE_MANAGER_TASKS_H <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Cache / Cache . h " <nl> + # include " Cache / Manager . h " <nl> + # include " Cache / Metadata . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + # include < memory > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + class FreeMemoryTask : public std : : enable_shared_from_this < FreeMemoryTask > { <nl> + private : <nl> + Manager : : TaskEnvironment _environment ; <nl> + Manager * _manager ; <nl> + std : : shared_ptr < Cache > _cache ; <nl> + <nl> + public : <nl> + FreeMemoryTask ( ) = delete ; <nl> + FreeMemoryTask ( FreeMemoryTask const & ) = delete ; <nl> + FreeMemoryTask & operator = ( FreeMemoryTask const & ) = delete ; <nl> + <nl> + FreeMemoryTask ( Manager : : TaskEnvironment environment , Manager * manager , <nl> + Manager : : MetadataItr & metadata ) ; <nl> + ~ FreeMemoryTask ( ) ; <nl> + <nl> + bool dispatch ( ) ; <nl> + <nl> + private : <nl> + void run ( ) ; <nl> + } ; <nl> + <nl> + class MigrateTask : public std : : enable_shared_from_this < MigrateTask > { <nl> + private : <nl> + Manager : : TaskEnvironment _environment ; <nl> + Manager * _manager ; <nl> + std : : shared_ptr < Cache > _cache ; <nl> + <nl> + public : <nl> + MigrateTask ( ) = delete ; <nl> + MigrateTask ( MigrateTask const & ) = delete ; <nl> + MigrateTask & operator = ( MigrateTask const & ) = delete ; <nl> + <nl> + MigrateTask ( Manager : : TaskEnvironment environment , Manager * manager , <nl> + Manager : : MetadataItr & metadata ) ; <nl> + ~ MigrateTask ( ) ; <nl> + <nl> + bool dispatch ( ) ; <nl> + <nl> + private : <nl> + void run ( ) ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . f5dfed471fa <nl> mmm / dev / null <nl> ppp b / arangod / Cache / Metadata . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / Metadata . h " <nl> + # include " Cache / Cache . h " <nl> + # include " Cache / State . h " <nl> + <nl> + # include < atomic > <nl> + # include < cstdint > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + Metadata : : Metadata ( std : : shared_ptr < Cache > cache , uint64_t limit , uint8_t * table , <nl> + uint32_t logSize ) <nl> + : _state ( ) , <nl> + _cache ( cache ) , <nl> + _usage ( 0 ) , <nl> + _softLimit ( limit ) , <nl> + _hardLimit ( limit ) , <nl> + _table ( table ) , <nl> + _auxiliaryTable ( nullptr ) , <nl> + _logSize ( logSize ) , <nl> + _auxiliaryLogSize ( 0 ) { } <nl> + <nl> + Metadata : : Metadata ( Metadata const & other ) <nl> + : _state ( other . _state ) , <nl> + _cache ( other . _cache ) , <nl> + _usage ( other . _usage ) , <nl> + _softLimit ( other . _softLimit ) , <nl> + _hardLimit ( other . _hardLimit ) , <nl> + _table ( other . _table ) , <nl> + _auxiliaryTable ( other . _auxiliaryTable ) , <nl> + _logSize ( other . _logSize ) , <nl> + _auxiliaryLogSize ( other . _auxiliaryLogSize ) { } <nl> + <nl> + void Metadata : : lock ( ) { _state . lock ( ) ; } <nl> + <nl> + void Metadata : : unlock ( ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + bool Metadata : : isLocked ( ) const { return _state . isLocked ( ) ; } <nl> + <nl> + std : : shared_ptr < Cache > Metadata : : cache ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _cache ; <nl> + } <nl> + <nl> + uint32_t Metadata : : logSize ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _logSize ; <nl> + } <nl> + <nl> + uint32_t Metadata : : auxiliaryLogSize ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _auxiliaryLogSize ; <nl> + } <nl> + <nl> + uint8_t * Metadata : : table ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _table ; <nl> + } <nl> + <nl> + uint8_t * Metadata : : auxiliaryTable ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _auxiliaryTable ; <nl> + } <nl> + <nl> + uint64_t Metadata : : usage ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _usage ; <nl> + } <nl> + <nl> + uint64_t Metadata : : softLimit ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _softLimit ; <nl> + } <nl> + <nl> + uint64_t Metadata : : hardLimit ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _hardLimit ; <nl> + } <nl> + <nl> + bool Metadata : : adjustUsageIfAllowed ( int64_t usageChange ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + <nl> + if ( usageChange < 0 ) { <nl> + _usage - = static_cast < uint64_t > ( - usageChange ) ; <nl> + return true ; <nl> + } <nl> + <nl> + if ( ( static_cast < uint64_t > ( usageChange ) + _usage < = _softLimit ) | | <nl> + ( ( _usage > _softLimit ) & & <nl> + ( static_cast < uint64_t > ( usageChange ) + _usage < = _hardLimit ) ) ) { <nl> + _usage + = static_cast < uint64_t > ( usageChange ) ; <nl> + return true ; <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + bool Metadata : : adjustLimits ( uint64_t softLimit , uint64_t hardLimit ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + <nl> + if ( hardLimit < _usage ) { <nl> + return false ; <nl> + } <nl> + <nl> + _softLimit = softLimit ; <nl> + _hardLimit = hardLimit ; <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + void Metadata : : grantAuxiliaryTable ( uint8_t * table , uint32_t logSize ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + _auxiliaryTable = table ; <nl> + _auxiliaryLogSize = logSize ; <nl> + } <nl> + <nl> + void Metadata : : swapTables ( ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + std : : swap ( _table , _auxiliaryTable ) ; <nl> + std : : swap ( _logSize , _auxiliaryLogSize ) ; <nl> + } <nl> + <nl> + uint8_t * Metadata : : releaseTable ( ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + uint8_t * table = _table ; <nl> + _table = nullptr ; <nl> + _logSize = 0 ; <nl> + return table ; <nl> + } <nl> + <nl> + uint8_t * Metadata : : releaseAuxiliaryTable ( ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + uint8_t * table = _auxiliaryTable ; <nl> + _auxiliaryTable = nullptr ; <nl> + _auxiliaryLogSize = 0 ; <nl> + return table ; <nl> + } <nl> + <nl> + bool Metadata : : isSet ( State : : Flag flag ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _state . isSet ( flag ) ; <nl> + } <nl> + <nl> + void Metadata : : toggleFlag ( State : : Flag flag ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + _state . toggleFlag ( flag ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 0ad3814fc46 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / Metadata . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_METADATA_H <nl> + # define ARANGODB_CACHE_METADATA_H <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Cache / State . h " <nl> + <nl> + # include < atomic > <nl> + # include < cstdint > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + class Cache ; / / forward declaration <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Metadata object to facilitate information sharing between individual <nl> + / / / Cache instances and Manager . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + class Metadata { <nl> + public : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Initializes record with given information . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + Metadata ( std : : shared_ptr < Cache > cache , uint64_t limit , <nl> + uint8_t * table = nullptr , uint32_t logSize = 0 ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Initializes record from an existing record . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + Metadata ( Metadata const & other ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Locks the record . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void lock ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Unlocks the record . Requires record to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void unlock ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Returns true if the record is locked , false otherwise . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool isLocked ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Returns a shared pointer to the underlying cache . Requires record <nl> + / / / to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + std : : shared_ptr < Cache > cache ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Pointer to the table . Requires record to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint8_t * table ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief The base - 2 logarithm of the number of buckets in the table . <nl> + / / / Requires record to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint32_t logSize ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Pointer to the auxiliary table . Requires record to be locked . <nl> + / / / <nl> + / / / Will typically be nullptr . This will be set to a non - null value prior to <nl> + / / / migration . During migration , both tables will temporarily be in use . Upon <nl> + / / / completion of migration , the tables are swapped and the old table is <nl> + / / / released to the manager . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint8_t * auxiliaryTable ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief The base - 2 logarithm of the number of buckets in the auxiliary <nl> + / / / table . Requires record to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint32_t auxiliaryLogSize ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief The current memory usage of the cache in bytes . Requires record to <nl> + / / / be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t usage ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief The soft usage limit for this cache . Requires record to be locked . <nl> + / / / <nl> + / / / Typically , this will be equal to the hard limit . It may be lower when the <nl> + / / / cache is resizing . If the current usage is below the soft limit , then new <nl> + / / / insertions are not allowed to exceed the soft limit . If the current usage <nl> + / / / is above the soft limit , then new insertions may occur as long as they do <nl> + / / / not exceed the hard limit ; a background task will be working in parallel <nl> + / / / to remove older values to bring usage below the soft limit . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t softLimit ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief The hard usage limit for this cache . Requires record to be locked . <nl> + / / / <nl> + / / / Usage is guaranteed to remain under this value at all times . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t hardLimit ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Adjusts usage by the specified amount if it will not violate <nl> + / / / limits . Requires record to be locked . <nl> + / / / <nl> + / / / Returns true if adjusted , false otherwise . Used by caches to check - and - set <nl> + / / / in a single operation to determine whether they can afford to store a new <nl> + / / / value . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool adjustUsageIfAllowed ( int64_t usageChange ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Sets the soft and hard usage limits . Requires record to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool adjustLimits ( uint64_t softLimit , uint64_t hardLimit ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Lets the manager grant a new table lease to the cache for <nl> + / / / migration . Requires record to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void grantAuxiliaryTable ( uint8_t * table , uint32_t logSize ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Swap the main and auxiliary tables ( both pointers and sizes ) . <nl> + / / / Requires record to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void swapTables ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Release the main table back to the manager . Requires record to be <nl> + / / / locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint8_t * releaseTable ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Release the auxiliary table back to the manager . Requires record to <nl> + / / / be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint8_t * releaseAuxiliaryTable ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Checks if flag is set in state . Requires record to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool isSet ( State : : Flag flag ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Toggles flag in state . Requires record to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void toggleFlag ( State : : Flag flag ) ; <nl> + <nl> + private : <nl> + State _state ; <nl> + <nl> + / / pointer to underlying cache <nl> + std : : shared_ptr < Cache > _cache ; <nl> + <nl> + / / vital information about memory usage <nl> + uint64_t _usage ; <nl> + uint64_t _softLimit ; <nl> + uint64_t _hardLimit ; <nl> + <nl> + / / information about table leases <nl> + uint8_t * _table ; <nl> + uint8_t * _auxiliaryTable ; <nl> + uint32_t _logSize ; <nl> + uint32_t _auxiliaryLogSize ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 03faf08ab35 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / PlainBucket . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / PlainBucket . h " <nl> + # include " Basics / Common . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / State . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + size_t PlainBucket : : SLOTS_DATA = 5 ; <nl> + <nl> + PlainBucket : : PlainBucket ( ) { <nl> + _state . lock ( ) ; <nl> + clear ( ) ; <nl> + } <nl> + <nl> + bool PlainBucket : : lock ( int64_t maxTries ) { return _state . lock ( maxTries ) ; } <nl> + <nl> + void PlainBucket : : unlock ( ) { <nl> + TRI_ASSERT ( _state . isLocked ( ) ) ; <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + bool PlainBucket : : isLocked ( ) const { return _state . isLocked ( ) ; } <nl> + <nl> + bool PlainBucket : : isMigrated ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _state . isSet ( State : : Flag : : migrated ) ; <nl> + } <nl> + <nl> + bool PlainBucket : : isFull ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + bool hasEmptySlot = false ; <nl> + for ( size_t i = 0 ; i < SLOTS_DATA ; i + + ) { <nl> + size_t slot = SLOTS_DATA - ( i + 1 ) ; <nl> + if ( _cachedHashes [ slot ] = = 0 ) { <nl> + hasEmptySlot = true ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + return ! hasEmptySlot ; <nl> + } <nl> + <nl> + CachedValue * PlainBucket : : find ( uint32_t hash , void const * key , uint32_t keySize , <nl> + bool moveToFront ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + CachedValue * result = nullptr ; <nl> + <nl> + for ( size_t i = 0 ; i < SLOTS_DATA ; i + + ) { <nl> + if ( _cachedHashes [ i ] = = 0 ) { <nl> + break ; <nl> + } <nl> + if ( _cachedHashes [ i ] = = hash & & _cachedData [ i ] - > sameKey ( key , keySize ) ) { <nl> + result = _cachedData [ i ] ; <nl> + if ( moveToFront ) { <nl> + moveSlot ( i , true ) ; <nl> + } <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + / / requires there to be an open slot , otherwise will not be inserted <nl> + void PlainBucket : : insert ( uint32_t hash , CachedValue * value ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + for ( size_t i = 0 ; i < SLOTS_DATA ; i + + ) { <nl> + if ( _cachedHashes [ i ] = = 0 ) { <nl> + / / found an empty slot <nl> + _cachedHashes [ i ] = hash ; <nl> + _cachedData [ i ] = value ; <nl> + if ( i ! = 0 ) { <nl> + moveSlot ( i , true ) ; <nl> + } <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + CachedValue * PlainBucket : : remove ( uint32_t hash , void const * key , <nl> + uint32_t keySize ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + CachedValue * value = find ( hash , key , keySize , false ) ; <nl> + if ( value ! = nullptr ) { <nl> + evict ( value , false ) ; <nl> + } <nl> + <nl> + return value ; <nl> + } <nl> + <nl> + CachedValue * PlainBucket : : evictionCandidate ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + for ( size_t i = 0 ; i < SLOTS_DATA ; i + + ) { <nl> + size_t slot = SLOTS_DATA - ( i + 1 ) ; <nl> + if ( _cachedHashes [ slot ] = = 0 ) { <nl> + continue ; <nl> + } <nl> + if ( _cachedData [ slot ] - > isFreeable ( ) ) { <nl> + return _cachedData [ slot ] ; <nl> + } <nl> + } <nl> + <nl> + return nullptr ; <nl> + } <nl> + <nl> + void PlainBucket : : evict ( CachedValue * value , bool optimizeForInsertion ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + for ( size_t i = 0 ; i < SLOTS_DATA ; i + + ) { <nl> + size_t slot = SLOTS_DATA - ( i + 1 ) ; <nl> + if ( _cachedData [ slot ] = = value ) { <nl> + / / found a match <nl> + _cachedHashes [ slot ] = 0 ; <nl> + _cachedData [ slot ] = nullptr ; <nl> + moveSlot ( slot , optimizeForInsertion ) ; <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void PlainBucket : : clear ( ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + memset ( this , 0 , sizeof ( PlainBucket ) ) ; <nl> + } <nl> + <nl> + void PlainBucket : : moveSlot ( size_t slot , bool moveToFront ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + uint32_t hash = _cachedHashes [ slot ] ; <nl> + CachedValue * value = _cachedData [ slot ] ; <nl> + size_t i = slot ; <nl> + if ( moveToFront ) { <nl> + / / move slot to front <nl> + for ( ; i > = 1 ; i - - ) { <nl> + _cachedHashes [ i ] = _cachedHashes [ i - 1 ] ; <nl> + _cachedData [ i ] = _cachedData [ i - 1 ] ; <nl> + } <nl> + } else { <nl> + / / move slot to back <nl> + for ( ; ( i < SLOTS_DATA - 1 ) & & ( _cachedHashes [ i + 1 ] ! = 0 ) ; i + + ) { <nl> + _cachedHashes [ i ] = _cachedHashes [ i + 1 ] ; <nl> + _cachedData [ i ] = _cachedData [ i + 1 ] ; <nl> + } <nl> + } <nl> + if ( i ! = slot ) { <nl> + _cachedHashes [ i ] = hash ; <nl> + _cachedData [ i ] = value ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 6ead5417a6a <nl> mmm / dev / null <nl> ppp b / arangod / Cache / PlainBucket . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_PLAIN_BUCKET_H <nl> + # define ARANGODB_CACHE_PLAIN_BUCKET_H <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / State . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Bucket structure for PlainCache . <nl> + / / / <nl> + / / / Contains only a State variable and five slots each for hashes and data <nl> + / / / pointers . Most querying and manipulation can be handled via the exposed <nl> + / / / methods . Bucket must be locked before doing anything else to ensure proper <nl> + / / / synchronization . Data entries are carefully laid out to ensure the structure <nl> + / / / fits in a single cacheline . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + struct alignas ( 64 ) PlainBucket { <nl> + State _state ; <nl> + <nl> + / / actual cached entries <nl> + uint32_t _cachedHashes [ 5 ] ; <nl> + CachedValue * _cachedData [ 5 ] ; <nl> + static size_t SLOTS_DATA ; <nl> + <nl> + / / padding , if necessary ? <nl> + # ifdef TRI_PADDING_32 <nl> + uint32_t _padding [ 3 ] ; <nl> + # endif <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Initialize an empty bucket . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + PlainBucket ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Attempt to lock bucket ( failing after maxTries attempts ) . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool lock ( int64_t maxTries ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Unlock the bucket . Requires bucket to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void unlock ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Checks whether the bucket is locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool isLocked ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Checks whether the bucket has been migrated . Requires state to be <nl> + / / / locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool isMigrated ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Checks whether bucket is full . Requires state to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool isFull ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Looks up a given key and returns associated value . Requires state <nl> + / / / to be locked . <nl> + / / / <nl> + / / / Takes an input hash and key ( specified by pointer and size ) , and searches <nl> + / / / the bucket for a matching entry . If a matching entry is found , it is <nl> + / / / returned . By default , a matching entry will be moved to the front of the <nl> + / / / bucket to allow basic LRU semantics . If no matching entry is found , <nl> + / / / nothing will be changed and a nullptr will be returned . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + CachedValue * find ( uint32_t hash , void const * key , uint32_t keySize , <nl> + bool moveToFront = true ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Inserts a given value . Requires state to be locked . <nl> + / / / <nl> + / / / Requires that the bucket is not full and does not already contain an item <nl> + / / / with the same key . If it is full , the item will not be inserted . If an <nl> + / / / item with the same key exists , this is not detected but it is likely to <nl> + / / / produce bugs later on down the line . When inserting , the item is put into <nl> + / / / the first empty slot , then moved to the front . If attempting to insert and <nl> + / / / the bucket is full , the user should evict an item and specify the <nl> + / / / optimizeForInsertion flag to be true . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void insert ( uint32_t hash , CachedValue * value ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Removes an item with the given key if one exists . Requires state to <nl> + / / / be locked . <nl> + / / / <nl> + / / / Search for a matching key . If none exists , do nothing and return a <nl> + / / / nullptr . If one exists , remove it from the bucket and return the pointer <nl> + / / / to the value . Upon removal , the empty slot generated is moved to the back <nl> + / / / of the bucket ( to remove the gap ) . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + CachedValue * remove ( uint32_t hash , void const * key , uint32_t keySize ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Searches for the best candidate in the bucket to evict . Requires <nl> + / / / state to be locked . <nl> + / / / <nl> + / / / Returns a pointer to least recently used freeable value . If the bucket <nl> + / / / contains no values or all have outstanding references , then it returns <nl> + / / / nullptr . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + CachedValue * evictionCandidate ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Evicts the given value from the bucket . Requires state to be <nl> + / / / locked . <nl> + / / / <nl> + / / / By default , it will move the empty slot to the back of the bucket . If <nl> + / / / preparing an empty slot for insertion , specify the second parameter to be <nl> + / / / true . This will move the empty slot to the front instead . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void evict ( CachedValue * value , bool optimizeForInsertion = false ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Reinitializes a bucket to be completely empty and unlocked . <nl> + / / / Requires state to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void clear ( ) ; <nl> + <nl> + private : <nl> + void moveSlot ( size_t slot , bool moveToFront ) ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . dd3f52b8e39 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / PlainCache . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / PlainCache . h " <nl> + # include " Basics / Common . h " <nl> + # include " Cache / Cache . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / FrequencyBuffer . h " <nl> + # include " Cache / Metadata . h " <nl> + # include " Cache / PlainBucket . h " <nl> + # include " Cache / State . h " <nl> + # include " Random / RandomGenerator . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + # include < chrono > <nl> + # include < list > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + static constexpr int64_t TRIES_FAST = 50LL ; <nl> + static constexpr int64_t TRIES_SLOW = 10000LL ; <nl> + static constexpr int64_t TRIES_GUARANTEE = - 1LL ; <nl> + <nl> + Cache : : Finding PlainCache : : find ( void const * key , uint32_t keySize ) { <nl> + TRI_ASSERT ( key ! = nullptr ) ; <nl> + Finding result ( nullptr ) ; <nl> + uint32_t hash = hashKey ( key , keySize ) ; <nl> + <nl> + bool ok ; <nl> + PlainBucket * bucket ; <nl> + std : : tie ( ok , bucket ) = getBucket ( hash , TRIES_FAST ) ; <nl> + <nl> + if ( ok ) { <nl> + result . reset ( bucket - > find ( hash , key , keySize ) ) ; <nl> + bucket - > unlock ( ) ; <nl> + endOperation ( ) ; <nl> + } <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + bool PlainCache : : insert ( CachedValue * value ) { <nl> + TRI_ASSERT ( value ! = nullptr ) ; <nl> + bool inserted = false ; <nl> + uint32_t hash = hashKey ( value - > key ( ) , value - > keySize ) ; <nl> + <nl> + bool ok ; <nl> + PlainBucket * bucket ; <nl> + std : : tie ( ok , bucket ) = getBucket ( hash , TRIES_FAST ) ; <nl> + <nl> + if ( ok ) { <nl> + int64_t change = value - > size ( ) ; <nl> + CachedValue * candidate = bucket - > find ( hash , value - > key ( ) , value - > keySize ) ; <nl> + <nl> + if ( candidate = = nullptr & & bucket - > isFull ( ) ) { <nl> + candidate = bucket - > evictionCandidate ( ) ; <nl> + } <nl> + if ( candidate ! = nullptr ) { <nl> + change - = candidate - > size ( ) ; <nl> + } <nl> + <nl> + _metadata - > lock ( ) ; <nl> + bool allowed = _metadata - > adjustUsageIfAllowed ( change ) ; <nl> + _metadata - > unlock ( ) ; <nl> + <nl> + if ( allowed ) { <nl> + if ( candidate ! = nullptr ) { <nl> + bucket - > evict ( candidate , true ) ; <nl> + freeValue ( candidate ) ; <nl> + recordStat ( Stat : : eviction ) ; <nl> + } else { <nl> + recordStat ( Stat : : noEviction ) ; <nl> + } <nl> + bucket - > insert ( hash , value ) ; <nl> + inserted = true ; <nl> + } else { <nl> + requestResize ( ) ; / / let function do the hard work <nl> + } <nl> + <nl> + bucket - > unlock ( ) ; <nl> + requestMigrate ( ) ; / / let function do the hard work <nl> + endOperation ( ) ; <nl> + } <nl> + <nl> + return inserted ; <nl> + } <nl> + <nl> + bool PlainCache : : remove ( void const * key , uint32_t keySize ) { <nl> + TRI_ASSERT ( key ! = nullptr ) ; <nl> + bool removed = false ; <nl> + uint32_t hash = hashKey ( key , keySize ) ; <nl> + <nl> + bool ok ; <nl> + PlainBucket * bucket ; <nl> + std : : tie ( ok , bucket ) = getBucket ( hash , TRIES_SLOW ) ; <nl> + <nl> + if ( ok ) { <nl> + int64_t change = 0 ; <nl> + CachedValue * candidate = bucket - > remove ( hash , key , keySize ) ; <nl> + <nl> + if ( candidate ! = nullptr ) { <nl> + change - = candidate - > size ( ) ; <nl> + <nl> + _metadata - > lock ( ) ; <nl> + bool allowed = _metadata - > adjustUsageIfAllowed ( change ) ; <nl> + TRI_ASSERT ( allowed ) ; <nl> + _metadata - > unlock ( ) ; <nl> + <nl> + freeValue ( candidate ) ; <nl> + } <nl> + <nl> + removed = true ; <nl> + bucket - > unlock ( ) ; <nl> + endOperation ( ) ; <nl> + } <nl> + <nl> + return removed ; <nl> + } <nl> + <nl> + std : : shared_ptr < Cache > PlainCache : : create ( Manager * manager , <nl> + uint64_t requestedSize , <nl> + bool allowGrowth ) { <nl> + PlainCache * cache = new PlainCache ( manager , requestedSize , allowGrowth ) ; <nl> + <nl> + if ( cache = = nullptr ) { <nl> + return std : : shared_ptr < Cache > ( nullptr ) ; <nl> + } <nl> + <nl> + cache - > metadata ( ) - > lock ( ) ; <nl> + std : : shared_ptr < Cache > result = cache - > metadata ( ) - > cache ( ) ; <nl> + cache - > metadata ( ) - > unlock ( ) ; <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + PlainCache : : PlainCache ( Manager * manager , uint64_t requestedLimit , <nl> + bool allowGrowth ) <nl> + : Cache ( manager , requestedLimit , allowGrowth , <nl> + [ ] ( Cache * p ) - > void { delete reinterpret_cast < PlainCache * > ( p ) ; } ) , <nl> + _auxiliaryTable ( nullptr ) , <nl> + _auxiliaryLogSize ( 0 ) , <nl> + _auxiliaryTableSize ( 1 ) , <nl> + _auxiliaryMaskShift ( 32 ) , <nl> + _auxiliaryBucketMask ( 0 ) { <nl> + _state . lock ( ) ; <nl> + if ( isOperational ( ) ) { <nl> + _metadata - > lock ( ) ; <nl> + _table = reinterpret_cast < PlainBucket * > ( _metadata - > table ( ) ) ; <nl> + _logSize = _metadata - > logSize ( ) ; <nl> + _tableSize = ( 1 < < _logSize ) ; <nl> + _maskShift = 32 - _logSize ; <nl> + _bucketMask = ( _tableSize - 1 ) < < _maskShift ; <nl> + _metadata - > unlock ( ) ; <nl> + } <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + PlainCache : : ~ PlainCache ( ) { <nl> + _state . lock ( ) ; <nl> + if ( isOperational ( ) ) { <nl> + _state . unlock ( ) ; <nl> + shutdown ( ) ; <nl> + } <nl> + if ( _state . isLocked ( ) ) { <nl> + _state . unlock ( ) ; <nl> + } <nl> + } <nl> + <nl> + bool PlainCache : : freeMemory ( ) { <nl> + _state . lock ( ) ; <nl> + if ( ! isOperational ( ) ) { <nl> + _state . unlock ( ) ; <nl> + return false ; <nl> + } <nl> + startOperation ( ) ; <nl> + _state . unlock ( ) ; <nl> + <nl> + bool underLimit = reclaimMemory ( 0ULL ) ; <nl> + while ( ! underLimit ) { <nl> + / / pick a random bucket <nl> + uint32_t randomHash = RandomGenerator : : interval ( UINT32_MAX ) ; <nl> + bool ok ; <nl> + PlainBucket * bucket ; <nl> + std : : tie ( ok , bucket ) = getBucket ( randomHash , TRIES_FAST , false ) ; <nl> + <nl> + if ( ok ) { <nl> + / / evict LRU freeable value if exists <nl> + CachedValue * candidate = bucket - > evictionCandidate ( ) ; <nl> + <nl> + if ( candidate ! = nullptr ) { <nl> + uint64_t size = candidate - > size ( ) ; <nl> + bucket - > evict ( candidate ) ; <nl> + freeValue ( candidate ) ; <nl> + <nl> + underLimit = reclaimMemory ( size ) ; <nl> + } <nl> + <nl> + bucket - > unlock ( ) ; <nl> + } <nl> + } <nl> + <nl> + endOperation ( ) ; <nl> + return true ; <nl> + } <nl> + <nl> + bool PlainCache : : migrate ( ) { <nl> + _state . lock ( ) ; <nl> + if ( ! isOperational ( ) ) { <nl> + _state . unlock ( ) ; <nl> + return false ; <nl> + } <nl> + startOperation ( ) ; <nl> + _metadata - > lock ( ) ; <nl> + if ( _metadata - > table ( ) = = nullptr | | _metadata - > auxiliaryTable ( ) = = nullptr ) { <nl> + _metadata - > unlock ( ) ; <nl> + _state . unlock ( ) ; <nl> + endOperation ( ) ; <nl> + return false ; <nl> + } <nl> + _auxiliaryTable = reinterpret_cast < PlainBucket * > ( _metadata - > auxiliaryTable ( ) ) ; <nl> + _auxiliaryLogSize = _metadata - > auxiliaryLogSize ( ) ; <nl> + _auxiliaryTableSize = ( 1 < < _auxiliaryLogSize ) ; <nl> + _auxiliaryMaskShift = ( 32 - _auxiliaryLogSize ) ; <nl> + _auxiliaryBucketMask = ( _auxiliaryTableSize - 1 ) < < _auxiliaryMaskShift ; <nl> + _metadata - > unlock ( ) ; <nl> + _state . toggleFlag ( State : : Flag : : migrating ) ; <nl> + _state . unlock ( ) ; <nl> + <nl> + for ( uint32_t i = 0 ; i < _tableSize ; i + + ) { <nl> + / / lock current bucket <nl> + PlainBucket * bucket = & ( _table [ i ] ) ; <nl> + bucket - > lock ( - 1LL ) ; <nl> + <nl> + / / collect target bucket ( s ) <nl> + std : : vector < PlainBucket * > targets ; <nl> + if ( _logSize > _auxiliaryLogSize ) { <nl> + uint32_t targetIndex = ( i < < _maskShift ) > > _auxiliaryMaskShift ; <nl> + targets . emplace_back ( & ( _auxiliaryTable [ targetIndex ] ) ) ; <nl> + } else { <nl> + uint32_t baseIndex = ( i < < _maskShift ) > > _auxiliaryMaskShift ; <nl> + for ( size_t j = 0 ; j < ( 1U < < ( _auxiliaryLogSize - _logSize ) ) ; j + + ) { <nl> + uint32_t targetIndex = baseIndex + j ; <nl> + targets . emplace_back ( & ( _auxiliaryTable [ targetIndex ] ) ) ; <nl> + } <nl> + } <nl> + / / lock target bucket ( s ) <nl> + for ( PlainBucket * targetBucket : targets ) { <nl> + targetBucket - > lock ( TRIES_GUARANTEE ) ; <nl> + } <nl> + <nl> + for ( size_t j = 0 ; j < PlainBucket : : SLOTS_DATA ; j + + ) { <nl> + size_t k = PlainBucket : : SLOTS_DATA - ( j + 1 ) ; <nl> + if ( ( * bucket ) . _cachedHashes [ k ] ! = 0 ) { <nl> + uint32_t hash = ( * bucket ) . _cachedHashes [ k ] ; <nl> + CachedValue * value = ( * bucket ) . _cachedData [ k ] ; <nl> + <nl> + uint32_t targetIndex = <nl> + ( hash & _auxiliaryBucketMask ) > > _auxiliaryMaskShift ; <nl> + PlainBucket * targetBucket = & ( _auxiliaryTable [ targetIndex ] ) ; <nl> + if ( targetBucket - > isFull ( ) ) { <nl> + CachedValue * candidate = targetBucket - > evictionCandidate ( ) ; <nl> + targetBucket - > evict ( candidate , true ) ; <nl> + uint64_t size = candidate - > size ( ) ; <nl> + freeValue ( candidate ) ; <nl> + reclaimMemory ( size ) ; <nl> + } <nl> + targetBucket - > insert ( hash , value ) ; <nl> + <nl> + ( * bucket ) . _cachedHashes [ k ] = 0 ; <nl> + ( * bucket ) . _cachedData [ k ] = nullptr ; <nl> + } <nl> + } <nl> + <nl> + / / unlock targets <nl> + for ( PlainBucket * targetBucket : targets ) { <nl> + targetBucket - > unlock ( ) ; <nl> + } <nl> + <nl> + / / finish up this bucket ' s migration <nl> + bucket - > _state . toggleFlag ( State : : Flag : : migrated ) ; <nl> + bucket - > unlock ( ) ; <nl> + } <nl> + <nl> + / / swap tables and unmark local migrating flag <nl> + _state . lock ( ) ; <nl> + std : : swap ( _table , _auxiliaryTable ) ; <nl> + std : : swap ( _logSize , _auxiliaryLogSize ) ; <nl> + std : : swap ( _tableSize , _auxiliaryTableSize ) ; <nl> + std : : swap ( _maskShift , _auxiliaryMaskShift ) ; <nl> + std : : swap ( _bucketMask , _auxiliaryBucketMask ) ; <nl> + _state . toggleFlag ( State : : Flag : : migrating ) ; <nl> + _state . unlock ( ) ; <nl> + <nl> + / / clear out old table <nl> + clearTable ( _auxiliaryTable , _auxiliaryTableSize ) ; <nl> + <nl> + / / release references to old table <nl> + _state . lock ( ) ; <nl> + _auxiliaryTable = nullptr ; <nl> + _auxiliaryLogSize = 0 ; <nl> + _auxiliaryTableSize = 1 ; <nl> + _auxiliaryMaskShift = 32 ; <nl> + _auxiliaryBucketMask = 0 ; <nl> + _state . unlock ( ) ; <nl> + <nl> + / / swap table in metadata <nl> + _metadata - > lock ( ) ; <nl> + _metadata - > swapTables ( ) ; <nl> + _metadata - > unlock ( ) ; <nl> + <nl> + endOperation ( ) ; <nl> + return true ; <nl> + } <nl> + <nl> + void PlainCache : : clearTables ( ) { <nl> + if ( _table ! = nullptr ) { <nl> + clearTable ( _table , _tableSize ) ; <nl> + } <nl> + if ( _auxiliaryTable ! = nullptr ) { <nl> + clearTable ( _auxiliaryTable , _auxiliaryTableSize ) ; <nl> + } <nl> + } <nl> + <nl> + std : : pair < bool , PlainBucket * > PlainCache : : getBucket ( uint32_t hash , <nl> + int64_t maxTries , <nl> + bool singleOperation ) { <nl> + PlainBucket * bucket = nullptr ; <nl> + bool started = false ; <nl> + <nl> + bool ok = _state . lock ( maxTries ) ; <nl> + if ( ok ) { <nl> + ok = isOperational ( ) ; <nl> + if ( ok ) { <nl> + if ( singleOperation ) { <nl> + startOperation ( ) ; <nl> + started = true ; <nl> + _metadata - > lock ( ) ; <nl> + _manager - > reportAccess ( _metadata - > cache ( ) ) ; <nl> + _metadata - > unlock ( ) ; <nl> + } <nl> + <nl> + bucket = & ( _table [ getIndex ( hash , false ) ] ) ; <nl> + ok = bucket - > lock ( maxTries ) ; <nl> + if ( ok & & <nl> + bucket - > isMigrated ( ) ) { / / get bucket from auxiliary table instead <nl> + bucket - > unlock ( ) ; <nl> + bucket = & ( _auxiliaryTable [ getIndex ( hash , true ) ] ) ; <nl> + ok = bucket - > lock ( maxTries ) ; <nl> + if ( ok & & bucket - > isMigrated ( ) ) { <nl> + ok = false ; <nl> + bucket - > unlock ( ) ; <nl> + } <nl> + } <nl> + } <nl> + if ( ! ok & & started ) { <nl> + endOperation ( ) ; <nl> + } <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + return std : : pair < bool , PlainBucket * > ( ok , bucket ) ; <nl> + } <nl> + <nl> + void PlainCache : : clearTable ( PlainBucket * table , uint64_t tableSize ) { <nl> + for ( uint64_t i = 0 ; i < tableSize ; i + + ) { <nl> + PlainBucket * bucket = & ( table [ i ] ) ; <nl> + bucket - > lock ( - 1LL ) ; <nl> + CachedValue * value = bucket - > evictionCandidate ( ) ; <nl> + while ( value ! = nullptr ) { <nl> + bucket - > evict ( value ) ; <nl> + _metadata - > lock ( ) ; <nl> + _metadata - > adjustUsageIfAllowed ( - static_cast < int64_t > ( value - > size ( ) ) ) ; <nl> + _metadata - > unlock ( ) ; <nl> + freeValue ( value ) ; <nl> + <nl> + value = bucket - > evictionCandidate ( ) ; <nl> + } <nl> + bucket - > clear ( ) ; <nl> + } <nl> + } <nl> + <nl> + uint32_t PlainCache : : getIndex ( uint32_t hash , bool useAuxiliary ) const { <nl> + if ( useAuxiliary ) { <nl> + return ( ( hash & _auxiliaryBucketMask ) > > _auxiliaryMaskShift ) ; <nl> + } <nl> + <nl> + return ( ( hash & _bucketMask ) > > _maskShift ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 039df374001 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / PlainCache . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_PLAIN_CACHE_H <nl> + # define ARANGODB_CACHE_PLAIN_CACHE_H <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Cache / Cache . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / FrequencyBuffer . h " <nl> + # include " Cache / Manager . h " <nl> + # include " Cache / ManagerTasks . h " <nl> + # include " Cache / Metadata . h " <nl> + # include " Cache / PlainBucket . h " <nl> + # include " Cache / State . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + # include < chrono > <nl> + # include < list > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + class Manager ; / / forward declaration <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief A simple , LRU - ish cache . <nl> + / / / <nl> + / / / To create a cache , see Manager class . Once created , the class has a very <nl> + / / / simple API following that of the base Cache class . For any non - pure - virtual <nl> + / / / functions , see Cache . h for documentation . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + class PlainCache final : public Cache { <nl> + public : <nl> + PlainCache ( ) = delete ; <nl> + PlainCache ( PlainCache const & ) = delete ; <nl> + PlainCache & operator = ( PlainCache const & ) = delete ; <nl> + <nl> + public : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Looks up the given key . <nl> + / / / <nl> + / / / May report a false negative if it fails to acquire a lock in a timely <nl> + / / / fashion . Should not block for long . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + Cache : : Finding find ( void const * key , uint32_t keySize ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Attempts to insert the given value . <nl> + / / / <nl> + / / / Returns true if inserted , false otherwise . Will not insert value if this <nl> + / / / would cause the total usage to exceed the limits . May also not insert <nl> + / / / value if it fails to acquire a lock in a timely fashion . Should not block <nl> + / / / for long . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool insert ( CachedValue * value ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Attempts to remove the given key . <nl> + / / / <nl> + / / / Returns true if the key guaranteed not to be in the cache , false if the <nl> + / / / key may remain in the cache . May leave the key in the cache if it fails to <nl> + / / / acquire a lock in a timely fashion . Makes more attempts to acquire a lock <nl> + / / / before quitting , so may block for longer than find or insert . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool remove ( void const * key , uint32_t keySize ) ; <nl> + <nl> + private : <nl> + / / main table info <nl> + PlainBucket * _table ; <nl> + uint32_t _logSize ; <nl> + uint64_t _tableSize ; <nl> + uint32_t _maskShift ; <nl> + uint32_t _bucketMask ; <nl> + <nl> + / / auxiliary table info <nl> + PlainBucket * _auxiliaryTable ; <nl> + uint32_t _auxiliaryLogSize ; <nl> + uint64_t _auxiliaryTableSize ; <nl> + uint32_t _auxiliaryMaskShift ; <nl> + uint32_t _auxiliaryBucketMask ; <nl> + <nl> + / / friend class manager and tasks <nl> + friend class FreeMemoryTask ; <nl> + friend class Manager ; <nl> + friend class MigrateTask ; <nl> + <nl> + private : <nl> + / / creator - - do not use constructor explicitly <nl> + static std : : shared_ptr < Cache > create ( Manager * manager , uint64_t requestedSize , <nl> + bool allowGrowth ) ; <nl> + <nl> + PlainCache ( Manager * manager , uint64_t requestedLimit , bool allowGrowth ) ; <nl> + ~ PlainCache ( ) ; <nl> + <nl> + / / management <nl> + bool freeMemory ( ) ; <nl> + bool migrate ( ) ; <nl> + void clearTables ( ) ; <nl> + <nl> + / / helpers <nl> + std : : pair < bool , PlainBucket * > getBucket ( uint32_t hash , int64_t maxTries , <nl> + bool singleOperation = true ) ; <nl> + void clearTable ( PlainBucket * table , uint64_t tableSize ) ; <nl> + uint32_t getIndex ( uint32_t hash , bool useAuxiliary ) const ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . dd3e0ff7cab <nl> mmm / dev / null <nl> ppp b / arangod / Cache / Rebalancer . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / Rebalancer . h " <nl> + # include " Basics / Common . h " <nl> + # include " Cache / Manager . h " <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + Rebalancer : : Rebalancer ( Manager * manager ) : _manager ( manager ) { } <nl> + <nl> + bool Rebalancer : : rebalance ( ) { <nl> + if ( _manager ! = nullptr ) { <nl> + return _manager - > rebalance ( ) ; <nl> + } <nl> + return false ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 290e24f3f80 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / Rebalancer . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_REBALANCER_H <nl> + # define ARANGODB_CACHE_REBALANCER_H <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # include " Manager . h " <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Dedicated class to rebalance Manager . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + class Rebalancer { <nl> + public : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Initialize state with no open transactions . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + Rebalancer ( Manager * manager ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Rebalance the manager . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool rebalance ( ) ; <nl> + <nl> + private : <nl> + Manager * _manager ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . f960719ef8a <nl> mmm / dev / null <nl> ppp b / arangod / Cache / State . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / State . h " <nl> + # include " Basics / Common . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + State : : State ( ) : _state ( 0 ) { } <nl> + <nl> + State : : State ( State const & other ) : _state ( other . _state . load ( ) ) { } <nl> + <nl> + bool State : : isLocked ( ) const { <nl> + return ( ( _state . load ( ) & static_cast < uint32_t > ( Flag : : locked ) ) > 0 ) ; <nl> + } <nl> + <nl> + bool State : : lock ( int64_t maxTries , State : : CallbackType cb ) { <nl> + int64_t attempt = 0 ; <nl> + while ( maxTries < 0 | | attempt < maxTries ) { <nl> + / / expect unlocked , but need to preserve migrating status <nl> + uint32_t expected = _state . load ( ) & ( ~ static_cast < uint32_t > ( Flag : : locked ) ) ; <nl> + bool success = _state . compare_exchange_strong ( <nl> + expected , <nl> + ( expected | static_cast < uint32_t > ( Flag : : locked ) ) ) ; / / try to lock <nl> + if ( success ) { <nl> + cb ( ) ; <nl> + return true ; <nl> + } <nl> + attempt + + ; <nl> + / / TODO : exponential back - off for failure ? <nl> + } <nl> + <nl> + return false ; <nl> + } <nl> + <nl> + void State : : unlock ( ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + _state & = ~ static_cast < uint32_t > ( Flag : : locked ) ; <nl> + } <nl> + <nl> + bool State : : isSet ( State : : Flag flag ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return ( ( _state . load ( ) & static_cast < uint32_t > ( flag ) ) > 0 ) ; <nl> + } <nl> + <nl> + void State : : toggleFlag ( State : : Flag flag ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + _state ^ = static_cast < uint32_t > ( flag ) ; <nl> + } <nl> + <nl> + void State : : clear ( ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + _state = static_cast < uint32_t > ( Flag : : locked ) ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . 19f06d56fd7 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / State . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_STATE_H <nl> + # define ARANGODB_CACHE_STATE_H <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # include < atomic > <nl> + # include < cstdint > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Simple state class with a small footprint . <nl> + / / / <nl> + / / / Underlying store is simply a std : : atomic < uint32_t > , and each bit corresponds <nl> + / / / to a flag that can be set . The lowest bit is special and is designated as <nl> + / / / the locking flag . Any access ( read or modify ) to the state must occur when <nl> + / / / the state is already locked ; the two exceptions are to check whether the <nl> + / / / state is locked and , of course , to lock it . Any flags besides the lock flag <nl> + / / / are treated uniformly , and can be checked or toggled . Each flag is defined <nl> + / / / via an enum and must correspond to exactly one set bit . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + struct State { <nl> + typedef std : : function < void ( ) > CallbackType ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Flags which can be queried or toggled to reflect state . <nl> + / / / <nl> + / / / Each flag must have exactly one bit set , fit in uint32_t . The ' locked ' <nl> + / / / flag is special and should remain the least - significant bit . When other <nl> + / / / flags are added , they should be kept in alphabetical order for readability , <nl> + / / / and all flag values should be adjusted to keep bit - significance in <nl> + / / / ascending order . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + enum class Flag : uint32_t { <nl> + locked = 0x00000001 , <nl> + blacklisted = 0x00000002 , <nl> + migrated = 0x00000004 , <nl> + migrating = 0x00000008 , <nl> + rebalancing = 0x00000010 , <nl> + resizing = 0x00000020 , <nl> + shutdown = 0x00000040 , <nl> + shuttingDown = 0x00000080 <nl> + } ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Initializes state with no flags set and unlocked <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + State ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Initializes state to match another <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + State ( State const & other ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Checks if state is locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool isLocked ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Used to lock state . Returns true if locked , false otherwise . <nl> + / / / <nl> + / / / By default , it will try as many times as necessary to acquire the lock . <nl> + / / / The number of tries may be limited to any positive integer value to avoid <nl> + / / / excessively long waits . The return value indicates whether the state was <nl> + / / / locked or not . The optional second parameter is a function which will be <nl> + / / / called upon successfully locking the state . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool lock ( int64_t maxTries = - 1LL , State : : CallbackType cb = [ ] ( ) - > void { } ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Unlocks the state . Requires state to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void unlock ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Checks whether the given flag is set . Requires state to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + bool isSet ( State : : Flag flag ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Toggles the given flag . Requires state to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void toggleFlag ( State : : Flag flag ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Unsets all flags besides Flag : : locked . Requires state to be locked . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void clear ( ) ; <nl> + <nl> + private : <nl> + std : : atomic < uint32_t > _state ; <nl> + } ; <nl> + <nl> + / / ensure that state is exactly the size of uint32_t <nl> + static_assert ( sizeof ( State ) = = sizeof ( uint32_t ) ) ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 72ccf9a8476 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / TransactionWindow . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / TransactionWindow . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + TransactionWindow : : TransactionWindow ( ) : _open ( 0 ) , _term ( 0 ) { } <nl> + <nl> + void TransactionWindow : : start ( ) { <nl> + if ( + + _open = = 1 ) { <nl> + _term + + ; <nl> + } <nl> + } <nl> + <nl> + void TransactionWindow : : end ( ) { <nl> + if ( - - _open = = 0 ) { <nl> + _term + + ; <nl> + } <nl> + } <nl> + <nl> + uint64_t TransactionWindow : : term ( ) { return _term . load ( ) ; } <nl> new file mode 100644 <nl> index 00000000000 . . 085fc5da851 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / TransactionWindow . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_TRANSACTION_WINDOW_H <nl> + # define ARANGODB_CACHE_TRANSACTION_WINDOW_H <nl> + <nl> + # include " Basics / Common . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Manage windows in time when there are either no ongoing transactions <nl> + / / / or some . <nl> + / / / <nl> + / / / Allows clients to start a transaction , end a transaction , and query an <nl> + / / / identifier for the current window . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + class TransactionWindow { <nl> + public : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Initialize state with no open transactions . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + TransactionWindow ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Signal the beginning of a transaction . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void start ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Signal the end of a transaction . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + void end ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief Return the current window identifier . <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + uint64_t term ( ) ; <nl> + <nl> + private : <nl> + std : : atomic < uint64_t > _open ; <nl> + std : : atomic < uint64_t > _term ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 8b1d089ba58 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / TransactionalBucket . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / TransactionalBucket . h " <nl> + # include " Basics / Common . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / State . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + size_t TransactionalBucket : : SLOTS_DATA = 3 ; <nl> + size_t TransactionalBucket : : SLOTS_BLACKLIST = 4 ; <nl> + <nl> + TransactionalBucket : : TransactionalBucket ( ) { <nl> + memset ( this , 0 , sizeof ( TransactionalBucket ) ) ; <nl> + } <nl> + <nl> + bool TransactionalBucket : : lock ( uint64_t transactionTerm , int64_t maxTries ) { <nl> + return _state . lock ( maxTries , <nl> + [ & ] ( ) - > void { updateBlacklistTerm ( transactionTerm ) ; } ) ; <nl> + } <nl> + <nl> + void TransactionalBucket : : unlock ( ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + _state . unlock ( ) ; <nl> + } <nl> + <nl> + bool TransactionalBucket : : isLocked ( ) const { return _state . isLocked ( ) ; } <nl> + <nl> + bool TransactionalBucket : : isMigrated ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _state . isSet ( State : : Flag : : blacklisted ) ; <nl> + } <nl> + <nl> + bool TransactionalBucket : : isFullyBlacklisted ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + return _state . isSet ( State : : Flag : : blacklisted ) ; <nl> + } <nl> + <nl> + bool TransactionalBucket : : isFull ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + bool hasEmptySlot = false ; <nl> + for ( size_t i = 0 ; i < SLOTS_DATA ; i + + ) { <nl> + size_t slot = SLOTS_DATA - ( i + 1 ) ; <nl> + if ( _cachedHashes [ slot ] = = 0 ) { <nl> + hasEmptySlot = true ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + return ! hasEmptySlot ; <nl> + } <nl> + <nl> + CachedValue * TransactionalBucket : : find ( uint32_t hash , void const * key , <nl> + uint32_t keySize , bool moveToFront ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + CachedValue * result = nullptr ; <nl> + <nl> + for ( size_t i = 0 ; i < SLOTS_DATA ; i + + ) { <nl> + if ( _cachedHashes [ i ] = = 0 ) { <nl> + break ; <nl> + } <nl> + if ( _cachedHashes [ i ] = = hash & & _cachedData [ i ] - > sameKey ( key , keySize ) ) { <nl> + result = _cachedData [ i ] ; <nl> + if ( moveToFront ) { <nl> + moveSlot ( i , true ) ; <nl> + } <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + void TransactionalBucket : : insert ( uint32_t hash , CachedValue * value ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + if ( isBlacklisted ( hash ) ) { <nl> + return ; <nl> + } <nl> + <nl> + for ( size_t i = 0 ; i < SLOTS_DATA ; i + + ) { <nl> + if ( _cachedHashes [ i ] = = 0 ) { <nl> + / / found an empty slot <nl> + _cachedHashes [ i ] = hash ; <nl> + _cachedData [ i ] = value ; <nl> + if ( i ! = 0 ) { <nl> + moveSlot ( i , true ) ; <nl> + } <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + CachedValue * TransactionalBucket : : remove ( uint32_t hash , void const * key , <nl> + uint32_t keySize ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + CachedValue * value = find ( hash , key , keySize , false ) ; <nl> + if ( value ! = nullptr ) { <nl> + evict ( value , false ) ; <nl> + } <nl> + <nl> + return value ; <nl> + } <nl> + <nl> + void TransactionalBucket : : blacklist ( uint32_t hash , void const * key , <nl> + uint32_t keySize ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + / / remove key if it ' s here <nl> + remove ( hash , key , keySize ) ; <nl> + <nl> + if ( isFullyBlacklisted ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> + for ( size_t i = 0 ; i < SLOTS_BLACKLIST ; i + + ) { <nl> + if ( _blacklistHashes [ i ] = = 0 ) { <nl> + / / found an empty slot <nl> + _blacklistHashes [ i ] = hash ; <nl> + return ; <nl> + } <nl> + } <nl> + <nl> + / / no empty slot found , fully blacklist <nl> + _state . toggleFlag ( State : : Flag : : blacklisted ) ; <nl> + } <nl> + <nl> + bool TransactionalBucket : : isBlacklisted ( uint32_t hash ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + if ( isFullyBlacklisted ( ) ) { <nl> + return true ; <nl> + } <nl> + <nl> + bool blacklisted = false ; <nl> + for ( size_t i = 0 ; i < SLOTS_BLACKLIST ; i + + ) { <nl> + if ( _blacklistHashes [ i ] = = hash ) { <nl> + blacklisted = true ; <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + return blacklisted ; <nl> + } <nl> + <nl> + CachedValue * TransactionalBucket : : evictionCandidate ( ) const { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + for ( size_t i = 0 ; i < SLOTS_DATA ; i + + ) { <nl> + size_t slot = SLOTS_DATA - ( i + 1 ) ; <nl> + if ( _cachedHashes [ slot ] = = 0 ) { <nl> + continue ; <nl> + } <nl> + if ( _cachedData [ slot ] - > isFreeable ( ) ) { <nl> + return _cachedData [ slot ] ; <nl> + } <nl> + } <nl> + <nl> + return nullptr ; <nl> + } <nl> + <nl> + void TransactionalBucket : : evict ( CachedValue * value , bool optimizeForInsertion ) { <nl> + TRI_ASSERT ( isLocked ( ) ) ; <nl> + for ( size_t i = 0 ; i < SLOTS_DATA ; i + + ) { <nl> + size_t slot = SLOTS_DATA - ( i + 1 ) ; <nl> + if ( _cachedData [ slot ] = = value ) { <nl> + / / found a match <nl> + _cachedHashes [ slot ] = 0 ; <nl> + _cachedData [ slot ] = nullptr ; <nl> + moveSlot ( slot , optimizeForInsertion ) ; <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + void TransactionalBucket : : updateBlacklistTerm ( uint64_t term ) { <nl> + if ( term > _blacklistTerm ) { <nl> + _blacklistTerm = term ; <nl> + <nl> + if ( isFullyBlacklisted ( ) ) { <nl> + _state . toggleFlag ( State : : Flag : : blacklisted ) ; <nl> + } <nl> + <nl> + memset ( _blacklistHashes , 0 , ( SLOTS_BLACKLIST * sizeof ( uint32_t ) ) ) ; <nl> + } <nl> + } <nl> + <nl> + void TransactionalBucket : : moveSlot ( size_t slot , bool moveToFront ) { <nl> + uint32_t hash = _cachedHashes [ slot ] ; <nl> + CachedValue * value = _cachedData [ slot ] ; <nl> + size_t i = slot ; <nl> + if ( moveToFront ) { <nl> + / / move slot to front <nl> + for ( ; i > = 1 ; i - - ) { <nl> + _cachedHashes [ i ] = _cachedHashes [ i - 1 ] ; <nl> + _cachedData [ i ] = _cachedData [ i - 1 ] ; <nl> + } <nl> + } else { <nl> + / / move slot to back <nl> + for ( ; ( i < SLOTS_DATA - 1 ) & & ( _cachedHashes [ i + 1 ] ! = 0 ) ; i + + ) { <nl> + _cachedHashes [ i ] = _cachedHashes [ i + 1 ] ; <nl> + _cachedData [ i ] = _cachedData [ i + 1 ] ; <nl> + } <nl> + } <nl> + if ( i ! = slot ) { <nl> + _cachedHashes [ i ] = hash ; <nl> + _cachedData [ i ] = value ; <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . c6466119946 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / TransactionalBucket . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_TRANSACTIONAL_BUCKET_H <nl> + # define ARANGODB_CACHE_TRANSACTIONAL_BUCKET_H <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / State . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + struct alignas ( 64 ) TransactionalBucket { <nl> + State _state ; <nl> + <nl> + / / actual cached entries <nl> + uint32_t _cachedHashes [ 3 ] ; <nl> + CachedValue * _cachedData [ 3 ] ; <nl> + static size_t SLOTS_DATA ; <nl> + <nl> + / / blacklist entries for transactional semantics <nl> + uint32_t _blacklistHashes [ 4 ] ; <nl> + uint64_t _blacklistTerm ; <nl> + static size_t SLOTS_BLACKLIST ; <nl> + <nl> + / / padding , if necessary ? <nl> + # ifdef TRI_PADDING_32 <nl> + uint32_t _padding [ 3 ] ; <nl> + # endif <nl> + <nl> + TransactionalBucket ( ) ; <nl> + <nl> + / / must lock before using any other operations <nl> + bool lock ( uint64_t transactionTerm , int64_t maxTries ) ; <nl> + void unlock ( ) ; <nl> + <nl> + / / state checkers <nl> + bool isLocked ( ) const ; <nl> + bool isMigrated ( ) const ; <nl> + bool isFullyBlacklisted ( ) const ; <nl> + bool isFull ( ) const ; <nl> + <nl> + / / primary functions <nl> + CachedValue * find ( uint32_t hash , void const * key , uint32_t keySize , <nl> + bool moveToFront = true ) ; <nl> + void insert ( uint32_t hash , CachedValue * value ) ; <nl> + CachedValue * remove ( uint32_t hash , void const * key , uint32_t keySize ) ; <nl> + void blacklist ( uint32_t hash , void const * key , uint32_t keySize ) ; <nl> + <nl> + / / auxiliary functions <nl> + bool isBlacklisted ( uint32_t hash ) const ; <nl> + CachedValue * evictionCandidate ( ) const ; <nl> + void evict ( CachedValue * value , bool optimizeForInsertion ) ; <nl> + <nl> + private : <nl> + void updateBlacklistTerm ( uint64_t term ) ; <nl> + void moveSlot ( size_t slot , bool moveToFront ) ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> new file mode 100644 <nl> index 00000000000 . . 6144ba58769 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / TransactionalCache . cpp <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # include " Cache / TransactionalCache . h " <nl> + # include " Basics / Common . h " <nl> + # include " Cache / Cache . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / FrequencyBuffer . h " <nl> + # include " Cache / Metadata . h " <nl> + # include " Cache / TransactionalBucket . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + # include < chrono > <nl> + # include < list > <nl> + <nl> + using namespace arangodb : : cache ; <nl> + <nl> + Cache : : Finding TransactionalCache : : find ( void const * key , uint32_t keySize ) { <nl> + / / TODO : implement this ; <nl> + return Cache : : Finding ( nullptr ) ; <nl> + } <nl> + <nl> + bool TransactionalCache : : insert ( CachedValue * value ) { <nl> + / / TODO : implement this <nl> + return false ; <nl> + } <nl> + <nl> + bool TransactionalCache : : remove ( void const * key , uint32_t keySize ) { <nl> + / / TODO : implement this <nl> + return false ; <nl> + } <nl> + <nl> + void TransactionalCache : : blackList ( void const * key , uint32_t keySize ) { <nl> + / / TODO : implement this <nl> + } <nl> + <nl> + std : : shared_ptr < Cache > TransactionalCache : : create ( Manager * manager , <nl> + uint64_t requestedSize , <nl> + bool allowGrowth ) { <nl> + TransactionalCache * cache = <nl> + new TransactionalCache ( manager , requestedSize , allowGrowth ) ; <nl> + <nl> + if ( cache = = nullptr ) { <nl> + return std : : shared_ptr < Cache > ( nullptr ) ; <nl> + } <nl> + <nl> + cache - > metadata ( ) - > lock ( ) ; <nl> + auto result = cache - > metadata ( ) - > cache ( ) ; <nl> + cache - > metadata ( ) - > unlock ( ) ; <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + TransactionalCache : : TransactionalCache ( Manager * manager , <nl> + uint64_t requestedLimit , <nl> + bool allowGrowth ) <nl> + : Cache ( manager , requestedLimit , allowGrowth , [ ] ( Cache * p ) - > void { <nl> + delete reinterpret_cast < TransactionalCache * > ( p ) ; <nl> + } ) { <nl> + / / TODO : implement this <nl> + } <nl> + <nl> + TransactionalCache : : ~ TransactionalCache ( ) { <nl> + / / TODO : implement this <nl> + } <nl> + <nl> + bool TransactionalCache : : freeMemory ( ) { <nl> + / / TODO : implement this <nl> + return false ; <nl> + } <nl> + <nl> + bool TransactionalCache : : migrate ( ) { <nl> + / / TODO : implement this <nl> + return false ; <nl> + } <nl> + <nl> + void TransactionalCache : : clearTables ( ) { <nl> + / / TODO : implement this <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . f9b21493b64 <nl> mmm / dev / null <nl> ppp b / arangod / Cache / TransactionalCache . h <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / DISCLAIMER <nl> + / / / <nl> + / / / Copyright 2014 - 2017 ArangoDB GmbH , Cologne , Germany <nl> + / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> + / / / <nl> + / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + / / / you may not use this file except in compliance with the License . <nl> + / / / You may obtain a copy of the License at <nl> + / / / <nl> + / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + / / / <nl> + / / / Unless required by applicable law or agreed to in writing , software <nl> + / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> + / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + / / / See the License for the specific language governing permissions and <nl> + / / / limitations under the License . <nl> + / / / <nl> + / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> + / / / <nl> + / / / @ author Daniel H . Larkin <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifndef ARANGODB_CACHE_TRANSACTIONAL_CACHE_H <nl> + # define ARANGODB_CACHE_TRANSACTIONAL_CACHE_H <nl> + <nl> + # include " Basics / Common . h " <nl> + # include " Cache / Cache . h " <nl> + # include " Cache / CachedValue . h " <nl> + # include " Cache / FrequencyBuffer . h " <nl> + # include " Cache / Metadata . h " <nl> + # include " Cache / TransactionalBucket . h " <nl> + <nl> + # include < stdint . h > <nl> + # include < atomic > <nl> + # include < chrono > <nl> + # include < list > <nl> + <nl> + namespace arangodb { <nl> + namespace cache { <nl> + <nl> + class Manager ; / / forward declaration <nl> + <nl> + class TransactionalCache final : public Cache { <nl> + public : <nl> + TransactionalCache ( ) = delete ; <nl> + TransactionalCache ( TransactionalCache const & ) = delete ; <nl> + TransactionalCache & operator = ( TransactionalCache const & ) = delete ; <nl> + <nl> + public : <nl> + Cache : : Finding find ( void const * key , uint32_t keySize ) ; <nl> + bool insert ( CachedValue * value ) ; <nl> + bool remove ( void const * key , uint32_t keySize ) ; <nl> + void blackList ( void const * key , uint32_t keySize ) ; <nl> + <nl> + private : <nl> + / / main table info <nl> + TransactionalBucket * _table ; <nl> + uint32_t _logSize ; <nl> + uint64_t _tableSize ; <nl> + uint32_t _maskShift ; <nl> + uint32_t _bucketMask ; <nl> + <nl> + / / auxiliary table info <nl> + TransactionalBucket * _auxiliaryTable ; <nl> + uint32_t _auxiliaryLogSize ; <nl> + uint64_t _auxiliaryTableSize ; <nl> + uint32_t _auxiliaryMaskShift ; <nl> + uint32_t _auxiliaryBucketMask ; <nl> + <nl> + / / friend class manager and tasks <nl> + friend class FreeMemoryTask ; <nl> + friend class Manager ; <nl> + friend class MigrateTask ; <nl> + <nl> + private : <nl> + / / creator - - do not use constructor explicitly <nl> + static std : : shared_ptr < Cache > create ( Manager * manager , uint64_t requestedSize , <nl> + bool allowGrowth ) ; <nl> + <nl> + TransactionalCache ( Manager * manager , uint64_t requestedLimit , <nl> + bool allowGrowth ) ; <nl> + ~ TransactionalCache ( ) ; <nl> + <nl> + / / management <nl> + bool freeMemory ( ) ; <nl> + bool migrate ( ) ; <nl> + void clearTables ( ) ; <nl> + } ; <nl> + <nl> + } ; / / end namespace cache <nl> + } ; / / end namespace arangodb <nl> + <nl> + # endif <nl> mmm a / arangod / RestServer / arangod . cpp <nl> ppp b / arangod / RestServer / arangod . cpp <nl> <nl> <nl> # include " Actions / ActionFeature . h " <nl> # include " Agency / AgencyFeature . h " <nl> - # include " Aql / AqlFunctionFeature . h " <nl> # include " ApplicationFeatures / ConfigFeature . h " <nl> # include " ApplicationFeatures / DaemonFeature . h " <nl> # include " ApplicationFeatures / GreetingsFeature . h " <nl> <nl> # include " ApplicationFeatures / TempFeature . h " <nl> # include " ApplicationFeatures / V8PlatformFeature . h " <nl> # include " ApplicationFeatures / VersionFeature . h " <nl> + # include " Aql / AqlFunctionFeature . h " <nl> # include " Basics / ArangoGlobalContext . h " <nl> + # include " Cache / CacheManagerFeature . h " <nl> # include " Cluster / ClusterFeature . h " <nl> # include " GeneralServer / AuthenticationFeature . h " <nl> # include " GeneralServer / GeneralServerFeature . h " <nl> <nl> # include " StorageEngine / EngineSelectorFeature . h " <nl> <nl> / / TODO - the following MMFiles includes should probably be removed <nl> - # include " MMFiles / MMFilesLogfileManager . h " <nl> + # include " MMFiles / MMFilesLogfileManager . h " <nl> # include " MMFiles / MMFilesPersistentIndexFeature . h " <nl> # include " MMFiles / MMFilesWalRecoveryFeature . h " <nl> <nl> / / # include " StorageEngine / RocksDBEngine . h " / / enable when adding Rocksdb Engine <nl> - / / this include will be disabled until <nl> - / / we begin to implement the RocksDB <nl> - / / engine <nl> + / / this include will be disabled until <nl> + / / we begin to implement the RocksDB <nl> + / / engine <nl> # include " MMFiles / MMFilesEngine . h " <nl> # include " V8Server / FoxxQueuesFeature . h " <nl> # include " V8Server / V8DealerFeature . h " <nl> static int runServer ( int argc , char * * argv ) { <nl> server . addFeature ( new AuthenticationFeature ( & server ) ) ; <nl> server . addFeature ( new AqlFeature ( & server ) ) ; <nl> server . addFeature ( new BootstrapFeature ( & server ) ) ; <nl> - server . addFeature ( new CheckVersionFeature ( & server , & ret , nonServerFeatures ) ) ; <nl> + server . addFeature ( new CacheManagerFeature ( & server ) ) ; <nl> + server . addFeature ( <nl> + new CheckVersionFeature ( & server , & ret , nonServerFeatures ) ) ; <nl> server . addFeature ( new ClusterFeature ( & server ) ) ; <nl> server . addFeature ( new ConfigFeature ( & server , name ) ) ; <nl> server . addFeature ( new ConsoleFeature ( & server ) ) ; <nl> static int runServer ( int argc , char * * argv ) { <nl> / / storage engines <nl> server . addFeature ( new MMFilesEngine ( & server ) ) ; <nl> server . addFeature ( new MMFilesWalRecoveryFeature ( & server ) ) ; <nl> - / / server . addFeature ( new RocksDBEngine ( & server ) ) ; / / enable RocksDB storage here <nl> + / / server . addFeature ( new RocksDBEngine ( & server ) ) ; / / enable RocksDB storage <nl> + / / here <nl> <nl> try { <nl> server . run ( argc , argv ) ; <nl> static int runServer ( int argc , char * * argv ) { <nl> ret = EXIT_SUCCESS ; <nl> } <nl> } catch ( std : : exception const & ex ) { <nl> - LOG_TOPIC ( ERR , arangodb : : Logger : : FIXME ) < < " arangod terminated because of an unhandled exception : " <nl> - < < ex . what ( ) ; <nl> + LOG_TOPIC ( ERR , arangodb : : Logger : : FIXME ) <nl> + < < " arangod terminated because of an unhandled exception : " <nl> + < < ex . what ( ) ; <nl> ret = EXIT_FAILURE ; <nl> } catch ( . . . ) { <nl> - LOG_TOPIC ( ERR , arangodb : : Logger : : FIXME ) < < " arangod terminated because of an unhandled exception of " <nl> - " unknown type " ; <nl> + LOG_TOPIC ( ERR , arangodb : : Logger : : FIXME ) <nl> + < < " arangod terminated because of an unhandled exception of " <nl> + " unknown type " ; <nl> ret = EXIT_FAILURE ; <nl> } <nl> Logger : : flush ( ) ; <nl> <nl> return context . exit ( ret ) ; <nl> } catch ( std : : exception const & ex ) { <nl> - LOG_TOPIC ( ERR , arangodb : : Logger : : FIXME ) < < " arangod terminated because of an unhandled exception : " <nl> - < < ex . what ( ) ; <nl> + LOG_TOPIC ( ERR , arangodb : : Logger : : FIXME ) <nl> + < < " arangod terminated because of an unhandled exception : " <nl> + < < ex . what ( ) ; <nl> } catch ( . . . ) { <nl> - LOG_TOPIC ( ERR , arangodb : : Logger : : FIXME ) < < " arangod terminated because of an unhandled exception of " <nl> - " unknown type " ; <nl> + LOG_TOPIC ( ERR , arangodb : : Logger : : FIXME ) <nl> + < < " arangod terminated because of an unhandled exception of " <nl> + " unknown type " ; <nl> } <nl> exit ( EXIT_FAILURE ) ; <nl> } <nl> mmm a / js / client / modules / @ arangodb / testing . js <nl> ppp b / js / client / modules / @ arangodb / testing . js <nl> const optionsDocumentation = [ <nl> ' - ` skipArangoBench ` : if set to true benchmark tests are skipped ' , <nl> ' - ` skipAuthentication : testing authentication and authentication_paramaters will be skipped . ' , <nl> ' - ` skipBoost ` : if set to true the boost unittests are skipped ' , <nl> + ' - ` skipCache ` : if set to true , the hash cache unittests are skipped ' , <nl> ' - ` skipConfig ` : omit the noisy configuration tests ' , <nl> ' - ` skipFoxxQueues ` : omit the test for the foxx queues ' , <nl> ' - ` skipEndpoints ` : if set to true endpoints tests are skipped ' , <nl> const optionsDefaults = { <nl> ' skipArangoBenchNonConnKeepAlive ' : true , <nl> ' skipAuthentication ' : false , <nl> ' skipBoost ' : false , <nl> + ' skipCache ' : false , <nl> ' skipEndpoints ' : false , <nl> ' skipGeo ' : false , <nl> ' skipLogAnalysis ' : true , <nl> function readImportantLogLines ( logPath ) { <nl> / / / echo 1 > / proc / sys / kernel / core_uses_pid <nl> / / / echo / var / tmp / core - % e - % p - % t > / proc / sys / kernel / core_pattern <nl> / / / <nl> - / / / or at system startup by altering / etc / sysctl . d / corepattern . conf : <nl> + / / / or at system startup by altering / etc / sysctl . d / corepattern . conf : <nl> / / / # We want core files to be located in a central location <nl> / / / # and know the PID plus the process name for later use . <nl> / / / kernel . core_uses_pid = 1 <nl> function analyzeCoreDump ( instanceInfo , options , storeArangodPath , pid ) { <nl> executeExternalAndWait ( ' / bin / bash ' , args ) ; <nl> GDB_OUTPUT = fs . read ( gdbOutputFile ) ; <nl> print ( GDB_OUTPUT ) ; <nl> - <nl> + <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> function analyzeServerCrash ( arangod , options , checkStr ) { <nl> print ( RED + " apport handles corefiles on your system . Uninstall it if you want us to get corefiles for analysis . " ) ; <nl> return ; <nl> } <nl> - <nl> + <nl> if ( matchSystemdCoredump . exec ( cp ) = = null ) { <nl> options . coreDirectory = " / var / lib / systemd / coredump " ; <nl> } <nl> function runArangoBenchmark ( options , instanceInfo , cmds ) { <nl> ' server . username ' : options . username , <nl> ' server . password ' : options . password , <nl> ' server . endpoint ' : instanceInfo . endpoint , <nl> - / / " server . request - timeout " : 1200 / / default now . <nl> + / / " server . request - timeout " : 1200 / / default now . <nl> ' server . connection - timeout ' : 10 / / 5s default <nl> } ; <nl> <nl> function shutdownArangod ( arangod , options ) { <nl> arangod . exitStatus . status = = = ' RUNNING ' ) { <nl> const requestOptions = makeAuthorizationHeaders ( options ) ; <nl> requestOptions . method = ' DELETE ' ; <nl> - <nl> + <nl> print ( arangod . url + ' / _admin / shutdown ' ) ; <nl> if ( options . useKillExternal ) { <nl> killExternal ( arangod . pid ) ; <nl> function shutdownInstance ( instanceInfo , options ) { <nl> fs . join ( instanceInfo . rootDir , ' core . dmp ' ) <nl> ] ; <nl> } <nl> - <nl> + <nl> killExternal ( arangod . pid , 11 ) ; <nl> <nl> analyzeServerCrash ( arangod , options , ' instance forcefully KILLED after 60s - ' + arangod . exitStatus . signal ) ; <nl> function startArango ( protocol , options , addArgs , rootDir , role ) { <nl> let args = makeArgsArangod ( options , appDir , role ) ; <nl> let endpoint ; <nl> let port ; <nl> - <nl> + <nl> if ( ! addArgs [ ' server . endpoint ' ] ) { <nl> port = findFreePort ( options . minPort , options . maxPort ) ; <nl> endpoint = protocol + ' : / / 127 . 0 . 0 . 1 : ' + port ; <nl> function startArango ( protocol , options , addArgs , rootDir , role ) { <nl> instanceInfo . pid = executeArangod ( ARANGOD_BIN , toArgv ( args ) , options ) . pid ; <nl> } catch ( x ) { <nl> print ( ' failed to run arangod - ' + JSON . stringify ( x ) ) ; <nl> - throw ( x ) ; <nl> + throw ( x ) ; <nl> } <nl> instanceInfo . role = role ; <nl> <nl> function startInstanceAgency ( instanceInfo , protocol , options , addArgs , rootDir ) <nl> instanceArgs [ ' server . endpoint ' ] = protocol + ' : / / 127 . 0 . 0 . 1 : ' + port ; <nl> instanceArgs [ ' agency . my - address ' ] = protocol + ' : / / 127 . 0 . 0 . 1 : ' + port ; <nl> instanceArgs [ ' agency . supervision - grace - period ' ] = ' 10 . 0 ' ; <nl> - instanceArgs [ ' agency . supervision - frequency ' ] = ' 1 . 0 ' ; <nl> + instanceArgs [ ' agency . supervision - frequency ' ] = ' 1 . 0 ' ; <nl> <nl> if ( i = = = N - 1 ) { <nl> let l = [ ] ; <nl> function findTests ( ) { <nl> } <nl> <nl> testsCases . common = doOnePath ( ' js / common / tests / shell ' ) ; <nl> - <nl> + <nl> testsCases . server_only = doOnePath ( ' js / server / tests / shell ' ) ; <nl> <nl> testsCases . client_only = doOnePath ( ' js / client / tests / shell ' ) ; <nl> testFuncs . fail = function ( options ) { <nl> success : { <nl> status : true , <nl> message : " this testcase will always be successfull " , <nl> - duration : 1 <nl> + duration : 1 <nl> } <nl> } <nl> } ; <nl> testFuncs . fail = function ( options ) { <nl> <nl> testFuncs . arangosh = function ( options ) { <nl> let ret = { } ; <nl> - [ <nl> - ' testArangoshExitCodeNoConnect ' , <nl> - ' testArangoshExitCodeFail ' , <nl> - ' testArangoshExitCodeFailButCaught ' , <nl> - ' testArangoshExitCodeEmpty ' , <nl> - ' testArangoshExitCodeSuccess ' , <nl> - ' testArangoshExitCodeStatements ' , <nl> - ' testArangoshExitCodeStatements2 ' , <nl> - ' testArangoshExitCodeNewlines ' , <nl> + [ <nl> + ' testArangoshExitCodeNoConnect ' , <nl> + ' testArangoshExitCodeFail ' , <nl> + ' testArangoshExitCodeFailButCaught ' , <nl> + ' testArangoshExitCodeEmpty ' , <nl> + ' testArangoshExitCodeSuccess ' , <nl> + ' testArangoshExitCodeStatements ' , <nl> + ' testArangoshExitCodeStatements2 ' , <nl> + ' testArangoshExitCodeNewlines ' , <nl> ' testArangoshExitCodeEcho ' , <nl> ' testArangoshShebang ' , <nl> ] . forEach ( function ( what ) { <nl> testFuncs . arangosh = function ( options ) { <nl> " didn ' t get expected return code ( " + expectedReturnCode + " ) : \ n " + <nl> yaml . safeDump ( rc ) ; <nl> } <nl> - <nl> + <nl> + + ret [ section ] [ ' total ' ] ; <nl> ret [ section ] [ ' status ' ] = failSuccess ; <nl> ret [ section ] [ ' duration ' ] = deltaTime ; <nl> print ( ( failSuccess ? GREEN : RED ) + ' Status : ' + ( failSuccess ? ' SUCCESS ' : ' FAIL ' ) + RESET ) ; <nl> } <nl> - <nl> + <nl> runTest ( ' testArangoshExitCodeNoConnect ' , ' Starting arangosh with failing connect : ' , " db . _databases ( ) ; " , 1 , { ' server . endpoint ' : ' tcp : / / 127 . 0 . 0 . 1 : 0 ' } ) ; <nl> print ( ) ; <nl> <nl> runTest ( ' testArangoshExitCodeFail ' , ' Starting arangosh with exception throwing script : ' , " throw ( ' foo ' ) " , 1 , { } ) ; <nl> print ( ) ; <nl> - <nl> + <nl> runTest ( ' testArangoshExitCodeFailButCaught ' , ' Starting arangosh with a caught exception : ' , " try { throw ( ' foo ' ) ; } catch ( err ) { } " , 0 , { } ) ; <nl> print ( ) ; <nl> - <nl> + <nl> runTest ( ' testArangoshExitCodeEmpty ' , ' Starting arangosh with empty script : ' , " " , 0 , { } ) ; <nl> print ( ) ; <nl> - <nl> + <nl> runTest ( ' testArangoshExitCodeSuccess ' , ' Starting arangosh with regular terminating script : ' , " ; " , 0 , { } ) ; <nl> print ( ) ; <nl> - <nl> + <nl> runTest ( ' testArangoshExitCodeStatements ' , ' Starting arangosh with multiple statements : ' , " var a = 1 ; if ( a ! = = 1 ) throw ( ' boom ! ' ) ; " , 0 , { } ) ; <nl> print ( ) ; <nl> - <nl> + <nl> runTest ( ' testArangoshExitCodeStatements2 ' , ' Starting arangosh with multiple statements : ' , " var a = 1 ; \ nif ( a ! = = 1 ) throw ( ' boom ! ' ) ; \ nif ( a = = = 1 ) print ( ' success ' ) ; " , 0 , { } ) ; <nl> print ( ) ; <nl> - <nl> + <nl> runTest ( ' testArangoshExitCodeNewlines ' , ' Starting arangosh with newlines : ' , " q = ` FOR i \ nIN [ 1 , 2 , 3 ] \ nRETURN i ` ; \ nq + = ' abc ' \ n " , 0 , { } ) ; <nl> print ( ) ; <nl> - <nl> + <nl> if ( platform . substr ( 0 , 3 ) ! = = ' win ' ) { <nl> var echoSuccess = true ; <nl> var deltaTime2 = 0 ; <nl> testFuncs . arangosh = function ( options ) { <nl> print ( ' \ nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - ' ) ; <nl> print ( ' Starting arangosh via echo ' ) ; <nl> print ( ' mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - ' ) ; <nl> - <nl> + <nl> fs . write ( execFile , <nl> ' echo " db . _databases ( ) ; " | ' + fs . makeAbsolute ( ARANGOSH_BIN ) + ' - - server . endpoint tcp : / / 127 . 0 . 0 . 1 : 0 ' ) ; <nl> <nl> testFuncs . arangosh = function ( options ) { <nl> " didn ' t get expected return code ( 1 ) : \ n " + <nl> yaml . safeDump ( rc ) ; <nl> } <nl> - <nl> + <nl> fs . remove ( execFile ) ; <nl> <nl> + + ret . testArangoshExitCodeEcho [ ' total ' ] ; <nl> testFuncs . arangosh = function ( options ) { <nl> ret . testArangoshExitCodeEcho [ ' duration ' ] = deltaTime2 ; <nl> print ( ( echoSuccess ? GREEN : RED ) + ' Status : ' + ( echoSuccess ? ' SUCCESS ' : ' FAIL ' ) + RESET ) ; <nl> } <nl> - <nl> + <nl> / / test shebang execution with arangosh <nl> if ( ! options . skipShebang & & platform . substr ( 0 , 3 ) ! = = ' win ' ) { <nl> var shebangSuccess = true ; <nl> testFuncs . boost = function ( options ) { <nl> } <nl> } <nl> <nl> + if ( ! options . skipHashCache ) { <nl> + const run = locateBoostTest ( ' cache_suite ' ) ; <nl> + <nl> + if ( run ! = = ' ' ) { <nl> + results . cache_suite = executeAndWait ( run , args , options , <nl> + ' cache_suite ' ) ; <nl> + } else { <nl> + results . cache_suite = { <nl> + status : false , <nl> + message : " binary ' cache_suite ' not found " <nl> + } ; <nl> + } <nl> + } <nl> + <nl> if ( ! options . skipGeo ) { <nl> const run = locateBoostTest ( ' geo_suite ' ) ; <nl> <nl> testFuncs . replication_static = function ( options ) { <nl> let master = startInstance ( ' tcp ' , options , { <nl> ' server . authentication ' : ' true ' <nl> } , ' master_static ' ) ; <nl> - <nl> + <nl> const mr = makeResults ( ' replication ' , master ) ; <nl> <nl> if ( master = = = false ) { <nl> testFuncs . endpoints = function ( options ) { <nl> } <nl> <nl> let result = runInArangosh ( options , instanceInfo , ' js / client / tests / endpoint - spec . js ' ) ; <nl> - <nl> + <nl> print ( CYAN + ' Shutting down . . . ' + RESET ) ; <nl> / / mop : mehhh . . . when launched with a socket we can ' t use download : S <nl> shutdownInstance ( instanceInfo , Object . assign ( options , { useKillExternal : true } ) ) ; <nl> testFuncs . upgrade = function ( options ) { <nl> + + result . upgrade . total ; <nl> <nl> result . upgrade . second = executeAndWait ( ARANGOD_BIN , argv , options , ' upgrade ' ) ; <nl> - <nl> + <nl> if ( result . upgrade . second . status ! = = true ) { <nl> print ( ' not removing ' + tmpDataDir ) ; <nl> return result . upgrade ; <nl> } <nl> <nl> cleanupDirectories . push ( tmpDataDir ) ; <nl> - <nl> - result . upgrade . status = true ; <nl> + <nl> + result . upgrade . status = true ; <nl> return result ; <nl> } ; <nl> <nl>
|
Added hash cache system .
|
arangodb/arangodb
|
09600f0971c007c751ff1a91923651c68b307526
|
2017-02-24T20:31:40Z
|
mmm a / cocos2dx / platform / emscripten / CCEGLView . cpp <nl> ppp b / cocos2dx / platform / emscripten / CCEGLView . cpp <nl> bool CCEGLView : : initGL ( ) <nl> } <nl> <nl> / / FIXME : Get the actual canvas size somehow . <nl> - EGLint width = 300 ; <nl> - EGLint height = 150 ; <nl> + EGLint width = 800 ; <nl> + EGLint height = 500 ; <nl> + # warning Assuming screen size is 800X500 . Mouse cursor will be offset if a different sized canvas is used . <nl> <nl> if ( ( m_eglDisplay = = EGL_NO_DISPLAY ) | | ( m_eglSurface = = EGL_NO_SURFACE ) ) <nl> return EXIT_FAILURE ; <nl>
|
Hack : use 800x500 resolution for window for emscripten so that mouse roughly lines up .
|
cocos2d/cocos2d-x
|
576ff593c74a110a07b4359afd936563fe13c057
|
2013-05-06T20:26:31Z
|
mmm a / src / api . cc <nl> ppp b / src / api . cc <nl> v8 : : Local < v8 : : StackTrace > Message : : GetStackTrace ( ) const { <nl> } <nl> <nl> <nl> - MUST_USE_RESULT static i : : MaybeHandle < i : : Object > CallV8HeapFunction ( <nl> - i : : Isolate * isolate , const char * name , i : : Handle < i : : Object > recv , int argc , <nl> - i : : Handle < i : : Object > argv [ ] ) { <nl> - i : : Handle < i : : Object > object_fun = <nl> - i : : Object : : GetProperty ( <nl> - isolate , isolate - > js_builtins_object ( ) , name ) . ToHandleChecked ( ) ; <nl> - i : : Handle < i : : JSFunction > fun = i : : Handle < i : : JSFunction > : : cast ( object_fun ) ; <nl> - return i : : Execution : : Call ( isolate , fun , recv , argc , argv ) ; <nl> - } <nl> - <nl> - <nl> - MUST_USE_RESULT static i : : MaybeHandle < i : : Object > CallV8HeapFunction ( <nl> - i : : Isolate * isolate , const char * name , i : : Handle < i : : Object > data ) { <nl> - i : : Handle < i : : Object > argv [ ] = { data } ; <nl> - return CallV8HeapFunction ( isolate , name , isolate - > js_builtins_object ( ) , <nl> - arraysize ( argv ) , argv ) ; <nl> - } <nl> - <nl> - <nl> Maybe < int > Message : : GetLineNumber ( Local < Context > context ) const { <nl> PREPARE_FOR_EXECUTION_PRIMITIVE ( context , " v8 : : Message : : GetLineNumber ( ) " , int ) ; <nl> + i : : Handle < i : : JSFunction > fun = isolate - > message_get_line_number ( ) ; <nl> + i : : Handle < i : : Object > undefined = isolate - > factory ( ) - > undefined_value ( ) ; <nl> + i : : Handle < i : : Object > args [ ] = { Utils : : OpenHandle ( this ) } ; <nl> i : : Handle < i : : Object > result ; <nl> has_pending_exception = <nl> - ! CallV8HeapFunction ( isolate , " $ messageGetLineNumber " , <nl> - Utils : : OpenHandle ( this ) ) . ToHandle ( & result ) ; <nl> + ! i : : Execution : : Call ( isolate , fun , undefined , arraysize ( args ) , args ) <nl> + . ToHandle ( & result ) ; <nl> RETURN_ON_FAILED_EXECUTION_PRIMITIVE ( int ) ; <nl> return Just ( static_cast < int > ( result - > Number ( ) ) ) ; <nl> } <nl> int Message : : GetEndPosition ( ) const { <nl> Maybe < int > Message : : GetStartColumn ( Local < Context > context ) const { <nl> PREPARE_FOR_EXECUTION_PRIMITIVE ( context , " v8 : : Message : : GetStartColumn ( ) " , <nl> int ) ; <nl> - auto self = Utils : : OpenHandle ( this ) ; <nl> - i : : Handle < i : : Object > start_col_obj ; <nl> + i : : Handle < i : : JSFunction > fun = isolate - > message_get_column_number ( ) ; <nl> + i : : Handle < i : : Object > undefined = isolate - > factory ( ) - > undefined_value ( ) ; <nl> + i : : Handle < i : : Object > args [ ] = { Utils : : OpenHandle ( this ) } ; <nl> + i : : Handle < i : : Object > result ; <nl> has_pending_exception = <nl> - ! CallV8HeapFunction ( isolate , " $ messageGetPositionInLine " , self ) <nl> - . ToHandle ( & start_col_obj ) ; <nl> + ! i : : Execution : : Call ( isolate , fun , undefined , arraysize ( args ) , args ) <nl> + . ToHandle ( & result ) ; <nl> RETURN_ON_FAILED_EXECUTION_PRIMITIVE ( int ) ; <nl> - return Just ( static_cast < int > ( start_col_obj - > Number ( ) ) ) ; <nl> + return Just ( static_cast < int > ( result - > Number ( ) ) ) ; <nl> } <nl> <nl> <nl> int Message : : GetStartColumn ( ) const { <nl> <nl> <nl> Maybe < int > Message : : GetEndColumn ( Local < Context > context ) const { <nl> - PREPARE_FOR_EXECUTION_PRIMITIVE ( context , " v8 : : Message : : GetEndColumn ( ) " , int ) ; <nl> auto self = Utils : : OpenHandle ( this ) ; <nl> - i : : Handle < i : : Object > start_col_obj ; <nl> + PREPARE_FOR_EXECUTION_PRIMITIVE ( context , " v8 : : Message : : GetEndColumn ( ) " , int ) ; <nl> + i : : Handle < i : : JSFunction > fun = isolate - > message_get_column_number ( ) ; <nl> + i : : Handle < i : : Object > undefined = isolate - > factory ( ) - > undefined_value ( ) ; <nl> + i : : Handle < i : : Object > args [ ] = { self } ; <nl> + i : : Handle < i : : Object > result ; <nl> has_pending_exception = <nl> - ! CallV8HeapFunction ( isolate , " $ messageGetPositionInLine " , self ) <nl> - . ToHandle ( & start_col_obj ) ; <nl> + ! i : : Execution : : Call ( isolate , fun , undefined , arraysize ( args ) , args ) <nl> + . ToHandle ( & result ) ; <nl> RETURN_ON_FAILED_EXECUTION_PRIMITIVE ( int ) ; <nl> int start = self - > start_position ( ) ; <nl> int end = self - > end_position ( ) ; <nl> - return Just ( static_cast < int > ( start_col_obj - > Number ( ) ) + ( end - start ) ) ; <nl> + return Just ( static_cast < int > ( result - > Number ( ) ) + ( end - start ) ) ; <nl> } <nl> <nl> <nl> bool Message : : IsOpaque ( ) const { <nl> <nl> MaybeLocal < String > Message : : GetSourceLine ( Local < Context > context ) const { <nl> PREPARE_FOR_EXECUTION ( context , " v8 : : Message : : GetSourceLine ( ) " , String ) ; <nl> + i : : Handle < i : : JSFunction > fun = isolate - > message_get_source_line ( ) ; <nl> + i : : Handle < i : : Object > undefined = isolate - > factory ( ) - > undefined_value ( ) ; <nl> + i : : Handle < i : : Object > args [ ] = { Utils : : OpenHandle ( this ) } ; <nl> i : : Handle < i : : Object > result ; <nl> has_pending_exception = <nl> - ! CallV8HeapFunction ( isolate , " $ messageGetSourceLine " , <nl> - Utils : : OpenHandle ( this ) ) . ToHandle ( & result ) ; <nl> + ! i : : Execution : : Call ( isolate , fun , undefined , arraysize ( args ) , args ) <nl> + . ToHandle ( & result ) ; <nl> RETURN_ON_FAILED_EXECUTION ( String ) ; <nl> Local < String > str ; <nl> if ( result - > IsString ( ) ) { <nl> Maybe < bool > Value : : Equals ( Local < Context > context , Local < Value > that ) const { <nl> } <nl> PREPARE_FOR_EXECUTION_PRIMITIVE ( context , " v8 : : Value : : Equals ( ) " , bool ) ; <nl> i : : Handle < i : : Object > args [ ] = { other } ; <nl> + i : : Handle < i : : JSFunction > fun ( i : : JSFunction : : cast ( <nl> + isolate - > js_builtins_object ( ) - > javascript_builtin ( i : : Builtins : : EQUALS ) ) ) ; <nl> i : : Handle < i : : Object > result ; <nl> has_pending_exception = <nl> - ! CallV8HeapFunction ( isolate , " EQUALS " , self , arraysize ( args ) , args ) <nl> + ! i : : Execution : : Call ( isolate , fun , self , arraysize ( args ) , args ) <nl> . ToHandle ( & result ) ; <nl> RETURN_ON_FAILED_EXECUTION_PRIMITIVE ( bool ) ; <nl> return Just ( * result = = i : : Smi : : FromInt ( i : : EQUAL ) ) ; <nl> Maybe < bool > v8 : : Object : : DefineOwnProperty ( v8 : : Local < v8 : : Context > context , <nl> i : : Handle < i : : JSArray > desc_array = <nl> isolate - > factory ( ) - > NewJSArrayWithElements ( desc , i : : FAST_ELEMENTS , 3 ) ; <nl> i : : Handle < i : : Object > args [ ] = { self , key_obj , value_obj , desc_array } ; <nl> + i : : Handle < i : : Object > undefined = isolate - > factory ( ) - > undefined_value ( ) ; <nl> + i : : Handle < i : : JSFunction > fun = isolate - > object_define_own_property ( ) ; <nl> i : : Handle < i : : Object > result ; <nl> has_pending_exception = <nl> - ! CallV8HeapFunction ( isolate , " $ objectDefineOwnProperty " , <nl> - isolate - > factory ( ) - > undefined_value ( ) , <nl> - arraysize ( args ) , args ) . ToHandle ( & result ) ; <nl> + ! i : : Execution : : Call ( isolate , fun , undefined , arraysize ( args ) , args ) <nl> + . ToHandle ( & result ) ; <nl> RETURN_ON_FAILED_EXECUTION_PRIMITIVE ( bool ) ; <nl> return Just ( result - > BooleanValue ( ) ) ; <nl> } <nl> MaybeLocal < Value > v8 : : Object : : GetOwnPropertyDescriptor ( Local < Context > context , <nl> auto obj = Utils : : OpenHandle ( this ) ; <nl> auto key_name = Utils : : OpenHandle ( * key ) ; <nl> i : : Handle < i : : Object > args [ ] = { obj , key_name } ; <nl> + i : : Handle < i : : JSFunction > fun = isolate - > object_get_own_property_descriptor ( ) ; <nl> + i : : Handle < i : : Object > undefined = isolate - > factory ( ) - > undefined_value ( ) ; <nl> i : : Handle < i : : Object > result ; <nl> has_pending_exception = <nl> - ! CallV8HeapFunction ( isolate , " $ objectGetOwnPropertyDescriptor " , <nl> - isolate - > factory ( ) - > undefined_value ( ) , <nl> - arraysize ( args ) , args ) . ToHandle ( & result ) ; <nl> + ! i : : Execution : : Call ( isolate , fun , undefined , arraysize ( args ) , args ) <nl> + . ToHandle ( & result ) ; <nl> RETURN_ON_FAILED_EXECUTION ( Value ) ; <nl> RETURN_ESCAPED ( Utils : : ToLocal ( result ) ) ; <nl> } <nl> mmm a / src / bootstrapper . cc <nl> ppp b / src / bootstrapper . cc <nl> void Bootstrapper : : ImportNatives ( Isolate * isolate , Handle < JSObject > container ) { <nl> INSTALL_NATIVE ( JSFunction , " GetStackTraceLine " , get_stack_trace_line_fun ) ; <nl> INSTALL_NATIVE ( JSFunction , " ToCompletePropertyDescriptor " , <nl> to_complete_property_descriptor ) ; <nl> + INSTALL_NATIVE ( JSFunction , " ObjectDefineOwnProperty " , <nl> + object_define_own_property ) ; <nl> + INSTALL_NATIVE ( JSFunction , " ObjectGetOwnPropertyDescriptor " , <nl> + object_get_own_property_descriptor ) ; <nl> + INSTALL_NATIVE ( JSFunction , " MessageGetLineNumber " , message_get_line_number ) ; <nl> + INSTALL_NATIVE ( JSFunction , " MessageGetColumnNumber " , <nl> + message_get_column_number ) ; <nl> + INSTALL_NATIVE ( JSFunction , " MessageGetSourceLine " , message_get_source_line ) ; <nl> + INSTALL_NATIVE ( JSObject , " StackOverflowBoilerplate " , <nl> + stack_overflow_boilerplate ) ; <nl> INSTALL_NATIVE ( JSFunction , " JsonSerializeAdapter " , json_serialize_adapter ) ; <nl> <nl> INSTALL_NATIVE ( JSFunction , " Error " , error_function ) ; <nl> mmm a / src / contexts . h <nl> ppp b / src / contexts . h <nl> enum BindingFlags { <nl> promise_has_user_defined_reject_handler ) \ <nl> V ( TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX , JSFunction , \ <nl> to_complete_property_descriptor ) \ <nl> + V ( OBJECT_DEFINE_OWN_PROPERTY_INDEX , JSFunction , object_define_own_property ) \ <nl> + V ( OBJECT_GET_OWN_PROPERTY_DESCROPTOR_INDEX , JSFunction , \ <nl> + object_get_own_property_descriptor ) \ <nl> + V ( MESSAGE_GET_LINE_NUMBER_INDEX , JSFunction , message_get_line_number ) \ <nl> + V ( MESSAGE_GET_COLUMN_NUMBER_INDEX , JSFunction , message_get_column_number ) \ <nl> + V ( MESSAGE_GET_SOURCE_LINE_INDEX , JSFunction , message_get_source_line ) \ <nl> + V ( STACK_OVERFLOW_BOILERPLATE_INDEX , JSObject , stack_overflow_boilerplate ) \ <nl> V ( JSON_SERIALIZE_ADAPTER_INDEX , JSFunction , json_serialize_adapter ) \ <nl> V ( DERIVED_HAS_TRAP_INDEX , JSFunction , derived_has_trap ) \ <nl> V ( DERIVED_GET_TRAP_INDEX , JSFunction , derived_get_trap ) \ <nl> mmm a / src / isolate . cc <nl> ppp b / src / isolate . cc <nl> Object * Isolate : : StackOverflow ( ) { <nl> / / At this point we cannot create an Error object using its javascript <nl> / / constructor . Instead , we copy the pre - constructed boilerplate and <nl> / / attach the stack trace as a hidden property . <nl> - Handle < String > key = factory ( ) - > stack_overflow_string ( ) ; <nl> - Handle < Object > boilerplate = <nl> - Object : : GetProperty ( js_builtins_object ( ) , key ) . ToHandleChecked ( ) ; <nl> - if ( boilerplate - > IsUndefined ( ) ) { <nl> - return Throw ( heap ( ) - > undefined_value ( ) , nullptr ) ; <nl> - } <nl> - Handle < JSObject > exception = <nl> - factory ( ) - > CopyJSObject ( Handle < JSObject > : : cast ( boilerplate ) ) ; <nl> + Handle < JSObject > boilerplate = stack_overflow_boilerplate ( ) ; <nl> + Handle < JSObject > exception = factory ( ) - > CopyJSObject ( boilerplate ) ; <nl> Throw ( * exception , nullptr ) ; <nl> <nl> CaptureAndSetSimpleStackTrace ( exception , factory ( ) - > undefined_value ( ) ) ; <nl> mmm a / src / messages . js <nl> ppp b / src / messages . js <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> var $ errorToString ; <nl> - var $ getStackTraceLine ; <nl> var $ internalErrorSymbol ; <nl> - var $ messageGetPositionInLine ; <nl> - var $ messageGetLineNumber ; <nl> - var $ messageGetSourceLine ; <nl> - var $ stackOverflowBoilerplate ; <nl> var $ stackTraceSymbol ; <nl> var MakeError ; <nl> var MakeEvalError ; <nl> function GetLineNumber ( message ) { <nl> } <nl> <nl> <nl> + / / Returns the offset of the given position within the containing line . <nl> + function GetColumnNumber ( message ) { <nl> + var script = % MessageGetScript ( message ) ; <nl> + var start_position = % MessageGetStartPosition ( message ) ; <nl> + var location = script . locationFromPosition ( start_position , true ) ; <nl> + if ( location = = null ) return - 1 ; <nl> + return location . column ; <nl> + } <nl> + <nl> + <nl> / / Returns the source code line containing the given source <nl> / / position , or the empty string if the position is invalid . <nl> function GetSourceLine ( message ) { <nl> function GetSourceLine ( message ) { <nl> return location . sourceText ( ) ; <nl> } <nl> <nl> + <nl> / * * <nl> * Find a line number given a specific source position . <nl> * @ param { number } position The source position . <nl> utils . SetUpLockedPrototype ( SourceSlice , <nl> ) ; <nl> <nl> <nl> - / / Returns the offset of the given position within the containing <nl> - / / line . <nl> - function GetPositionInLine ( message ) { <nl> - var script = % MessageGetScript ( message ) ; <nl> - var start_position = % MessageGetStartPosition ( message ) ; <nl> - var location = script . locationFromPosition ( start_position , true ) ; <nl> - if ( location = = null ) return - 1 ; <nl> - return location . column ; <nl> - } <nl> - <nl> - <nl> function GetStackTraceLine ( recv , fun , pos , isGlobal ) { <nl> return new CallSite ( recv , fun , pos , false ) . toString ( ) ; <nl> } <nl> utils . InstallFunctions ( GlobalError . prototype , DONT_ENUM , <nl> [ ' toString ' , ErrorToString ] ) ; <nl> <nl> $ errorToString = ErrorToString ; <nl> - $ messageGetPositionInLine = GetPositionInLine ; <nl> - $ messageGetLineNumber = GetLineNumber ; <nl> - $ messageGetSourceLine = GetSourceLine ; <nl> <nl> MakeError = function ( type , arg0 , arg1 , arg2 ) { <nl> return MakeGenericError ( GlobalError , type , arg0 , arg1 , arg2 ) ; <nl> MakeURIError = function ( ) { <nl> <nl> / / Boilerplate for exceptions for stack overflows . Used from <nl> / / Isolate : : StackOverflow ( ) . <nl> - $ stackOverflowBoilerplate = MakeRangeError ( kStackOverflow ) ; <nl> - % DefineAccessorPropertyUnchecked ( $ stackOverflowBoilerplate , ' stack ' , <nl> + var StackOverflowBoilerplate = MakeRangeError ( kStackOverflow ) ; <nl> + % DefineAccessorPropertyUnchecked ( StackOverflowBoilerplate , ' stack ' , <nl> StackTraceGetter , StackTraceSetter , <nl> DONT_ENUM ) ; <nl> <nl> utils . ExportToRuntime ( function ( to ) { <nl> to . NoSideEffectToString = NoSideEffectToString ; <nl> to . ToDetailString = ToDetailString ; <nl> to . MakeError = MakeGenericError ; <nl> + to . MessageGetLineNumber = GetLineNumber ; <nl> + to . MessageGetColumnNumber = GetColumnNumber ; <nl> + to . MessageGetSourceLine = GetSourceLine ; <nl> + to . StackOverflowBoilerplate = StackOverflowBoilerplate ; <nl> } ) ; <nl> <nl> } ) ; <nl> mmm a / src / v8natives . js <nl> ppp b / src / v8natives . js <nl> <nl> / / found in the LICENSE file . <nl> <nl> var $ functionSourceString ; <nl> - var $ objectDefineOwnProperty ; <nl> - var $ objectGetOwnPropertyDescriptor ; <nl> <nl> ( function ( global , utils ) { <nl> <nl> function GetIterator ( obj , method ) { <nl> / / Exports <nl> <nl> $ functionSourceString = FunctionSourceString ; <nl> - $ objectDefineOwnProperty = DefineOwnPropertyFromAPI ; <nl> - $ objectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor ; <nl> <nl> utils . ObjectDefineProperties = ObjectDefineProperties ; <nl> utils . ObjectDefineProperty = ObjectDefineProperty ; <nl> utils . Export ( function ( to ) { <nl> <nl> utils . ExportToRuntime ( function ( to ) { <nl> to . GlobalEval = GlobalEval ; <nl> + to . ObjectDefineOwnProperty = DefineOwnPropertyFromAPI ; <nl> + to . ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor ; <nl> to . ToCompletePropertyDescriptor = ToCompletePropertyDescriptor ; <nl> } ) ; <nl> <nl>
|
Remove property loads from js builtins objects from runtime .
|
v8/v8
|
40f6e80d22d2e146b781aa661b76087ab9a492c4
|
2015-08-17T15:08:36Z
|
mmm a / src / compiler / js - heap - broker . cc <nl> ppp b / src / compiler / js - heap - broker . cc <nl> HEAP_BROKER_OBJECT_LIST ( FORWARD_DECL ) <nl> <nl> class ObjectData : public ZoneObject { <nl> public : <nl> - static ObjectData * Serialize ( JSHeapBroker * broker , Handle < Object > object ) ; <nl> - <nl> ObjectData ( JSHeapBroker * broker , Handle < Object > object , bool is_smi ) <nl> : broker_ ( broker ) , object_ ( object ) , is_smi_ ( is_smi ) { <nl> broker - > AddData ( object , this ) ; <nl> void JSRegExpData : : SerializeAsRegExpBoilerplate ( ) { <nl> last_index_ = broker ( ) - > GetOrCreateData ( boilerplate - > last_index ( ) ) ; <nl> } <nl> <nl> - ObjectData * ObjectData : : Serialize ( JSHeapBroker * broker , Handle < Object > object ) { <nl> - CHECK ( broker - > SerializingAllowed ( ) ) ; <nl> - return object - > IsSmi ( ) ? new ( broker - > zone ( ) ) ObjectData ( broker , object , true ) <nl> - : HeapObjectData : : Serialize ( <nl> - broker , Handle < HeapObject > : : cast ( object ) ) ; <nl> - } <nl> - <nl> - HeapObjectData * HeapObjectData : : Serialize ( JSHeapBroker * broker , <nl> - Handle < HeapObject > object ) { <nl> - CHECK ( broker - > SerializingAllowed ( ) ) ; <nl> - Handle < Map > map ( object - > map ( ) , broker - > isolate ( ) ) ; <nl> - <nl> - # define RETURN_CREATE_DATA_IF_MATCH ( name ) \ <nl> - if ( object - > Is # # name ( ) ) { \ <nl> - return new ( broker - > zone ( ) ) \ <nl> - name # # Data ( broker , Handle < name > : : cast ( object ) ) ; \ <nl> - } <nl> - HEAP_BROKER_OBJECT_LIST ( RETURN_CREATE_DATA_IF_MATCH ) <nl> - # undef RETURN_CREATE_DATA_IF_MATCH <nl> - UNREACHABLE ( ) ; <nl> - } <nl> - <nl> bool ObjectRef : : equals ( const ObjectRef & other ) const { <nl> return data_ = = other . data_ ; <nl> } <nl> ObjectData * JSHeapBroker : : GetData ( Handle < Object > object ) const { <nl> return it ! = refs_ . end ( ) ? it - > second : nullptr ; <nl> } <nl> <nl> + / / clang - format off <nl> ObjectData * JSHeapBroker : : GetOrCreateData ( Handle < Object > object ) { <nl> CHECK ( SerializingAllowed ( ) ) ; <nl> ObjectData * data = GetData ( object ) ; <nl> ObjectData * JSHeapBroker : : GetOrCreateData ( Handle < Object > object ) { <nl> / / TODO ( neis ) : Remove these Allow * once we serialize everything upfront . <nl> AllowHandleAllocation handle_allocation ; <nl> AllowHandleDereference handle_dereference ; <nl> - / / TODO ( neis ) : Inline Serialize here , now that we have subclass - specific <nl> - / / Serialize methods . <nl> - data = ObjectData : : Serialize ( this , object ) ; <nl> + if ( object - > IsSmi ( ) ) { <nl> + data = new ( zone ( ) ) ObjectData ( this , object , true ) ; <nl> + # define CREATE_DATA_IF_MATCH ( name ) \ <nl> + } else if ( object - > Is # # name ( ) ) { \ <nl> + data = new ( zone ( ) ) name # # Data ( this , Handle < name > : : cast ( object ) ) ; <nl> + HEAP_BROKER_OBJECT_LIST ( CREATE_DATA_IF_MATCH ) <nl> + # undef CREATE_DATA_IF_MATCH <nl> + } else { <nl> + UNREACHABLE ( ) ; <nl> + } <nl> } <nl> CHECK_NOT_NULL ( data ) ; <nl> return data ; <nl> } <nl> + / / clang - format on <nl> <nl> ObjectData * JSHeapBroker : : GetOrCreateData ( Object * object ) { <nl> return GetOrCreateData ( handle ( object , isolate ( ) ) ) ; <nl>
|
[ turbofan ] Inline ObjectData : : Serialize ( ) .
|
v8/v8
|
2f01682bea41882b6c9ed724b869d8b540e00574
|
2018-09-18T13:50:02Z
|
mmm a / hphp / hack / hhi / typestructure . hhi <nl> ppp b / hphp / hack / hhi / typestructure . hhi <nl> enum TypeStructureKind : int { <nl> OF_INTERFACE = 0 ; <nl> OF_TRAIT = 0 ; <nl> OF_ENUM = 0 ; <nl> + OF_DICT = 0 ; <nl> + OF_VEC = 0 ; <nl> + OF_KEYSET = 0 ; <nl> OF_UNRESOLVED = 0 ; <nl> } <nl> <nl>
|
Add Hack arrays to TypeStructureKind enum
|
facebook/hhvm
|
b57e30ad816ef79018cbb7339500ec2633839545
|
2016-11-08T02:01:55Z
|
mmm a / xbmc / BackgroundInfoLoader . cpp <nl> ppp b / xbmc / BackgroundInfoLoader . cpp <nl> void CBackgroundInfoLoader : : Load ( CFileItemList & items ) <nl> { <nl> StopThread ( ) ; <nl> <nl> - if ( items . Size ( ) = = 0 ) <nl> + if ( items . IsEmpty ( ) ) <nl> return ; <nl> <nl> CSingleLock lock ( m_lock ) ; <nl> mmm a / xbmc / FileItem . cpp <nl> ppp b / xbmc / FileItem . cpp <nl> void CFileItemList : : Sort ( SortDescription sortDescription ) <nl> } <nl> <nl> / / replace the current list with the re - ordered one <nl> - m_items . assign ( sortedFileItems . begin ( ) , sortedFileItems . end ( ) ) ; <nl> + m_items = std : : move ( sortedFileItems ) ; <nl> } <nl> <nl> void CFileItemList : : Randomize ( ) <nl> mmm a / xbmc / GUIInfoManager . cpp <nl> ppp b / xbmc / GUIInfoManager . cpp <nl> <nl> # include " system . h " <nl> # include " CompileInfo . h " <nl> # include " GUIInfoManager . h " <nl> + # include " view / GUIViewState . h " <nl> # include " windows / GUIMediaWindow . h " <nl> # include " dialogs / GUIDialogKeyboardGeneric . h " <nl> # include " dialogs / GUIDialogNumeric . h " <nl> mmm a / xbmc / LangInfo . cpp <nl> ppp b / xbmc / LangInfo . cpp <nl> void CLangInfo : : GetRegionNames ( std : : vector < std : : string > & array ) <nl> std : : string strName = it - > first ; <nl> if ( strName = = " N / A " ) <nl> strName = g_localizeStrings . Get ( 416 ) ; <nl> - array . push_back ( strName ) ; <nl> + array . emplace_back ( std : : move ( strName ) ) ; <nl> } <nl> } <nl> <nl> void CLangInfo : : SettingOptionsLanguageNamesFiller ( const CSetting * setting , std : : <nl> return ; <nl> <nl> for ( ADDON : : VECADDONS : : const_iterator addon = addons . begin ( ) ; addon ! = addons . end ( ) ; + + addon ) <nl> - list . push_back ( make_pair ( ( * addon ) - > Name ( ) , ( * addon ) - > Name ( ) ) ) ; <nl> + list . emplace_back ( ( * addon ) - > Name ( ) , ( * addon ) - > Name ( ) ) ; <nl> <nl> sort ( list . begin ( ) , list . end ( ) , SortLanguage ( ) ) ; <nl> } <nl> void CLangInfo : : SettingOptionsISO6391LanguagesFiller ( const CSetting * setting , st <nl> std : : vector < std : : string > languages = g_LangCodeExpander . GetLanguageNames ( CLangCodeExpander : : ISO_639_1 , true ) ; <nl> sort ( languages . begin ( ) , languages . end ( ) , sortstringbyname ( ) ) ; <nl> for ( std : : vector < std : : string > : : const_iterator language = languages . begin ( ) ; language ! = languages . end ( ) ; + + language ) <nl> - list . push_back ( std : : make_pair ( * language , * language ) ) ; <nl> + list . emplace_back ( * language , * language ) ; <nl> } <nl> <nl> void CLangInfo : : SettingOptionsAudioStreamLanguagesFiller ( const CSetting * setting , std : : vector < std : : pair < std : : string , std : : string > > & list , std : : string & current , void * data ) <nl> { <nl> - list . push_back ( make_pair ( g_localizeStrings . Get ( 308 ) , " original " ) ) ; <nl> - list . push_back ( make_pair ( g_localizeStrings . Get ( 309 ) , " default " ) ) ; <nl> + list . emplace_back ( g_localizeStrings . Get ( 308 ) , " original " ) ; <nl> + list . emplace_back ( g_localizeStrings . Get ( 309 ) , " default " ) ; <nl> <nl> AddLanguages ( list ) ; <nl> } <nl> <nl> void CLangInfo : : SettingOptionsSubtitleStreamLanguagesFiller ( const CSetting * setting , std : : vector < std : : pair < std : : string , std : : string > > & list , std : : string & current , void * data ) <nl> { <nl> - list . push_back ( make_pair ( g_localizeStrings . Get ( 231 ) , " none " ) ) ; <nl> - list . push_back ( make_pair ( g_localizeStrings . Get ( 13207 ) , " forced_only " ) ) ; <nl> - list . push_back ( make_pair ( g_localizeStrings . Get ( 308 ) , " original " ) ) ; <nl> - list . push_back ( make_pair ( g_localizeStrings . Get ( 309 ) , " default " ) ) ; <nl> + list . emplace_back ( g_localizeStrings . Get ( 231 ) , " none " ) ; <nl> + list . emplace_back ( g_localizeStrings . Get ( 13207 ) , " forced_only " ) ; <nl> + list . emplace_back ( g_localizeStrings . Get ( 308 ) , " original " ) ; <nl> + list . emplace_back ( g_localizeStrings . Get ( 309 ) , " default " ) ; <nl> <nl> AddLanguages ( list ) ; <nl> } <nl> <nl> void CLangInfo : : SettingOptionsSubtitleDownloadlanguagesFiller ( const CSetting * setting , std : : vector < std : : pair < std : : string , std : : string > > & list , std : : string & current , void * data ) <nl> { <nl> - list . push_back ( make_pair ( g_localizeStrings . Get ( 308 ) , " original " ) ) ; <nl> - list . push_back ( make_pair ( g_localizeStrings . Get ( 309 ) , " default " ) ) ; <nl> + list . emplace_back ( g_localizeStrings . Get ( 308 ) , " original " ) ; <nl> + list . emplace_back ( g_localizeStrings . Get ( 309 ) , " default " ) ; <nl> <nl> AddLanguages ( list ) ; <nl> } <nl> void CLangInfo : : SettingOptionsRegionsFiller ( const CSetting * setting , std : : vector <nl> for ( unsigned int i = 0 ; i < regions . size ( ) ; + + i ) <nl> { <nl> std : : string region = regions [ i ] ; <nl> - list . push_back ( std : : make_pair ( region , region ) ) ; <nl> + list . emplace_back ( region , region ) ; <nl> <nl> if ( ! match & & region = = ( ( CSettingString * ) setting ) - > GetValue ( ) ) <nl> { <nl> mmm a / xbmc / addons / AddonManager . cpp <nl> ppp b / xbmc / addons / AddonManager . cpp <nl> bool CAddonMgr : : GetAddonsInternal ( const TYPE & type , VECADDONS & addons , bool enab <nl> AddonPtr runningAddon = addon - > GetRunningInstance ( ) ; <nl> if ( runningAddon ) <nl> addon = runningAddon ; <nl> - addons . push_back ( addon ) ; <nl> + addons . emplace_back ( std : : move ( addon ) ) ; <nl> } <nl> } <nl> } <nl> bool CAddonMgr : : AddonsFromRepoXML ( const TiXmlElement * root , VECADDONS & addons ) <nl> { <nl> AddonPtr addon = Factory ( info , ADDON_UNKNOWN ) ; <nl> if ( addon . get ( ) ) <nl> - addons . push_back ( addon ) ; <nl> + addons . push_back ( std : : move ( addon ) ) ; <nl> m_cpluff - > release_info ( context , info ) ; <nl> } <nl> element = element - > NextSiblingElement ( " addon " ) ; <nl> mmm a / xbmc / addons / Skin . cpp <nl> ppp b / xbmc / addons / Skin . cpp <nl> int CSkinInfo : : GetStartWindow ( ) const <nl> bool CSkinInfo : : LoadStartupWindows ( const cp_extension_t * ext ) <nl> { <nl> m_startupWindows . clear ( ) ; <nl> - m_startupWindows . push_back ( CStartupWindow ( WINDOW_HOME , " 513 " ) ) ; <nl> - m_startupWindows . push_back ( CStartupWindow ( WINDOW_TV_CHANNELS , " 19180 " ) ) ; <nl> - m_startupWindows . push_back ( CStartupWindow ( WINDOW_RADIO_CHANNELS , " 19183 " ) ) ; <nl> - m_startupWindows . push_back ( CStartupWindow ( WINDOW_PROGRAMS , " 0 " ) ) ; <nl> - m_startupWindows . push_back ( CStartupWindow ( WINDOW_PICTURES , " 1 " ) ) ; <nl> - m_startupWindows . push_back ( CStartupWindow ( WINDOW_MUSIC , " 2 " ) ) ; <nl> - m_startupWindows . push_back ( CStartupWindow ( WINDOW_VIDEOS , " 3 " ) ) ; <nl> - m_startupWindows . push_back ( CStartupWindow ( WINDOW_FILES , " 7 " ) ) ; <nl> - m_startupWindows . push_back ( CStartupWindow ( WINDOW_SETTINGS_MENU , " 5 " ) ) ; <nl> - m_startupWindows . push_back ( CStartupWindow ( WINDOW_WEATHER , " 8 " ) ) ; <nl> + m_startupWindows . emplace_back ( WINDOW_HOME , " 513 " ) ; <nl> + m_startupWindows . emplace_back ( WINDOW_TV_CHANNELS , " 19180 " ) ; <nl> + m_startupWindows . emplace_back ( WINDOW_RADIO_CHANNELS , " 19183 " ) ; <nl> + m_startupWindows . emplace_back ( WINDOW_PROGRAMS , " 0 " ) ; <nl> + m_startupWindows . emplace_back ( WINDOW_PICTURES , " 1 " ) ; <nl> + m_startupWindows . emplace_back ( WINDOW_MUSIC , " 2 " ) ; <nl> + m_startupWindows . emplace_back ( WINDOW_VIDEOS , " 3 " ) ; <nl> + m_startupWindows . emplace_back ( WINDOW_FILES , " 7 " ) ; <nl> + m_startupWindows . emplace_back ( WINDOW_SETTINGS_MENU , " 5 " ) ; <nl> + m_startupWindows . emplace_back ( WINDOW_WEATHER , " 8 " ) ; <nl> return true ; <nl> } <nl> <nl> mmm a / xbmc / addons / Skin . h <nl> ppp b / xbmc / addons / Skin . h <nl> class CSkinInfo : public CAddon <nl> class CStartupWindow <nl> { <nl> public : <nl> - CStartupWindow ( int id , const std : : string & name ) : <nl> + CStartupWindow ( int id , const char * name ) : <nl> m_id ( id ) , m_name ( name ) <nl> { <nl> } ; <nl> mmm a / xbmc / interfaces / builtins / PlayerBuiltins . cpp <nl> ppp b / xbmc / interfaces / builtins / PlayerBuiltins . cpp <nl> <nl> # include " utils / SeekHandler . h " <nl> # include " utils / StringUtils . h " <nl> # include " utils / URIUtils . h " <nl> + # include " view / GUIViewState . h " <nl> # include " video / windows / GUIWindowVideoBase . h " <nl> # include " pvr / channels / PVRChannel . h " <nl> # include " pvr / recordings / PVRRecording . h " <nl> mmm a / xbmc / music / MusicDatabase . cpp <nl> ppp b / xbmc / music / MusicDatabase . cpp <nl> bool CMusicDatabase : : GetSong ( int idSong , CSong & song ) <nl> <nl> int idSongArtistRole = record - > at ( songArtistOffset + artistCredit_idRole ) . get_asInt ( ) ; <nl> if ( idSongArtistRole = = ROLE_ARTIST ) <nl> - song . artistCredits . push_back ( GetArtistCreditFromDataset ( record , songArtistOffset ) ) ; <nl> + song . artistCredits . emplace_back ( GetArtistCreditFromDataset ( record , songArtistOffset ) ) ; <nl> else <nl> song . AppendArtistRole ( GetArtistRoleFromDataset ( record , songArtistOffset ) ) ; <nl> <nl> bool CMusicDatabase : : GetAlbum ( int idAlbum , CAlbum & album , bool getSongs / * = tru <nl> int idSong = record - > at ( song_idSong ) . get_asInt ( ) ; / / Same as songartist . idSong by join <nl> if ( songs . find ( idSong ) = = songs . end ( ) ) <nl> { <nl> - album . songs . push_back ( GetSongFromDataset ( record ) ) ; <nl> + album . songs . emplace_back ( GetSongFromDataset ( record ) ) ; <nl> songs . insert ( idSong ) ; <nl> } <nl> <nl> int idSongArtistRole = record - > at ( songArtistOffset + artistCredit_idRole ) . get_asInt ( ) ; <nl> / / By query order song is the last one appened to the album song vector . <nl> if ( idSongArtistRole = = ROLE_ARTIST ) <nl> - album . songs . back ( ) . artistCredits . push_back ( GetArtistCreditFromDataset ( record , songArtistOffset ) ) ; <nl> + album . songs . back ( ) . artistCredits . emplace_back ( GetArtistCreditFromDataset ( record , songArtistOffset ) ) ; <nl> else <nl> album . songs . back ( ) . AppendArtistRole ( GetArtistRoleFromDataset ( record , songArtistOffset ) ) ; <nl> <nl> bool CMusicDatabase : : GetArtist ( int idArtist , CArtist & artist , bool fetchAll / * = <nl> { <nl> const dbiplus : : sql_record * const record = m_pDS . get ( ) - > get_sql_record ( ) ; <nl> <nl> - artist . discography . push_back ( std : : make_pair ( record - > at ( discographyOffset + 1 ) . get_asString ( ) , record - > at ( discographyOffset + 2 ) . get_asString ( ) ) ) ; <nl> + artist . discography . emplace_back ( record - > at ( discographyOffset + 1 ) . get_asString ( ) , record - > at ( discographyOffset + 2 ) . get_asString ( ) ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> } <nl> bool CMusicDatabase : : GetArtistsByAlbum ( int idAlbum , CFileItem * item ) <nl> VECARTISTCREDITS artistCredits ; <nl> while ( ! m_pDS - > eof ( ) ) <nl> { <nl> - artistCredits . push_back ( GetArtistCreditFromDataset ( m_pDS - > get_sql_record ( ) , 0 ) ) ; <nl> + artistCredits . emplace_back ( GetArtistCreditFromDataset ( m_pDS - > get_sql_record ( ) , 0 ) ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> m_pDS - > close ( ) ; <nl> bool CMusicDatabase : : GetArtistsByAlbum ( int idAlbum , CFileItem * item ) <nl> for ( VECARTISTCREDITS : : const_iterator artistCredit = artistCredits . begin ( ) ; artistCredit ! = artistCredits . end ( ) ; + + artistCredit ) <nl> { <nl> artistidObj . push_back ( artistCredit - > GetArtistId ( ) ) ; <nl> - albumartists . push_back ( artistCredit - > GetArtist ( ) ) ; <nl> + albumartists . emplace_back ( artistCredit - > GetArtist ( ) ) ; <nl> if ( ! artistCredit - > GetMusicBrainzArtistID ( ) . empty ( ) ) <nl> - musicBrainzID . push_back ( artistCredit - > GetMusicBrainzArtistID ( ) ) ; <nl> + musicBrainzID . emplace_back ( artistCredit - > GetMusicBrainzArtistID ( ) ) ; <nl> } <nl> item - > GetMusicInfoTag ( ) - > SetAlbumArtist ( albumartists ) ; <nl> item - > GetMusicInfoTag ( ) - > SetMusicBrainzAlbumArtistID ( musicBrainzID ) ; <nl> mmm a / xbmc / music / windows / GUIWindowMusicBase . cpp <nl> ppp b / xbmc / music / windows / GUIWindowMusicBase . cpp <nl> <nl> # include " music / dialogs / GUIDialogSongInfo . h " <nl> # include " addons / GUIDialogAddonInfo . h " <nl> # include " dialogs / GUIDialogSmartPlaylistEditor . h " <nl> + # include " view / GUIViewState . h " <nl> # include " music / tags / MusicInfoTag . h " <nl> # include " guilib / GUIWindowManager . h " <nl> # include " input / Key . h " <nl> mmm a / xbmc / music / windows / GUIWindowMusicNav . cpp <nl> ppp b / xbmc / music / windows / GUIWindowMusicNav . cpp <nl> <nl> # include " guilib / GUIWindowManager . h " <nl> # include " dialogs / GUIDialogOK . h " <nl> # include " guilib / GUIKeyboardFactory . h " <nl> + # include " view / GUIViewState . h " <nl> # include " input / Key . h " <nl> # include " dialogs / GUIDialogYesNo . h " <nl> # include " guilib / GUIEditControl . h " <nl> mmm a / xbmc / music / windows / GUIWindowMusicPlaylist . cpp <nl> ppp b / xbmc / music / windows / GUIWindowMusicPlaylist . cpp <nl> <nl> <nl> # include " GUIWindowMusicPlaylist . h " <nl> # include " dialogs / GUIDialogSmartPlaylistEditor . h " <nl> + # include " view / GUIViewState . h " <nl> # include " Util . h " <nl> # include " playlists / PlayListM3U . h " <nl> # include " Application . h " <nl> mmm a / xbmc / pictures / GUIWindowPictures . cpp <nl> ppp b / xbmc / pictures / GUIWindowPictures . cpp <nl> <nl> # include " guilib / GUIWindowManager . h " <nl> # include " input / Key . h " <nl> # include " dialogs / GUIDialogOK . h " <nl> + # include " view / GUIViewState . h " <nl> # include " playlists / PlayList . h " <nl> # include " settings / MediaSourceSettings . h " <nl> # include " settings / Settings . h " <nl> mmm a / xbmc / pvr / windows / GUIWindowPVRGuide . cpp <nl> ppp b / xbmc / pvr / windows / GUIWindowPVRGuide . cpp <nl> <nl> # include " epg / GUIEPGGridContainer . h " <nl> # include " GUIUserMessages . h " <nl> # include " epg / EpgContainer . h " <nl> + # include " view / GUIViewState . h " <nl> # include " input / Key . h " <nl> # include " messaging / ApplicationMessenger . h " <nl> # include " settings / AdvancedSettings . h " <nl> mmm a / xbmc / video / VideoDatabase . cpp <nl> ppp b / xbmc / video / VideoDatabase . cpp <nl> bool CVideoDatabase : : GetPathsLinkedToTvShow ( int idShow , std : : vector < std : : string > <nl> m_pDS - > query ( sql ) ; <nl> while ( ! m_pDS - > eof ( ) ) <nl> { <nl> - paths . push_back ( m_pDS - > fv ( 0 ) . get_asString ( ) ) ; <nl> + paths . emplace_back ( m_pDS - > fv ( 0 ) . get_asString ( ) ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> return true ; <nl> bool CVideoDatabase : : GetSubPaths ( const std : : string & basepath , std : : vector < std : : p <nl> m_pDS - > query ( sql ) ; <nl> while ( ! m_pDS - > eof ( ) ) <nl> { <nl> - subpaths . push_back ( make_pair ( m_pDS - > fv ( 0 ) . get_asInt ( ) , m_pDS - > fv ( 1 ) . get_asString ( ) ) ) ; <nl> + subpaths . emplace_back ( m_pDS - > fv ( 0 ) . get_asInt ( ) , m_pDS - > fv ( 1 ) . get_asString ( ) ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> m_pDS - > close ( ) ; <nl> void CVideoDatabase : : DeleteDetailsForTvShow ( int idTvShow ) <nl> <nl> std : : vector < std : : string > ids ; <nl> for ( int iType = VIDEODB_ID_TV_MIN + 1 ; iType < VIDEODB_ID_TV_MAX ; iType + + ) <nl> - ids . push_back ( StringUtils : : Format ( " c % 02d = NULL " , iType ) ) ; <nl> + ids . emplace_back ( StringUtils : : Format ( " c % 02d = NULL " , iType ) ) ; <nl> <nl> strSQL = " update tvshow set " ; <nl> strSQL + = StringUtils : : Join ( ids , " , " ) ; <nl> std : : string CVideoDatabase : : GetValueString ( const CVideoInfoTag & details , int min <nl> switch ( offsets [ i ] . type ) <nl> { <nl> case VIDEODB_TYPE_STRING : <nl> - conditions . push_back ( PrepareSQL ( " c % 02d = ' % s ' " , i , ( ( std : : string * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) - > c_str ( ) ) ) ; <nl> + conditions . emplace_back ( PrepareSQL ( " c % 02d = ' % s ' " , i , ( ( std : : string * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) - > c_str ( ) ) ) ; <nl> break ; <nl> case VIDEODB_TYPE_INT : <nl> - conditions . push_back ( PrepareSQL ( " c % 02d = ' % i ' " , i , * ( int * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) ) ; <nl> + conditions . emplace_back ( PrepareSQL ( " c % 02d = ' % i ' " , i , * ( int * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) ) ; <nl> break ; <nl> case VIDEODB_TYPE_COUNT : <nl> { <nl> int value = * ( int * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ; <nl> if ( value ) <nl> - conditions . push_back ( PrepareSQL ( " c % 02d = % i " , i , value ) ) ; <nl> + conditions . emplace_back ( PrepareSQL ( " c % 02d = % i " , i , value ) ) ; <nl> else <nl> - conditions . push_back ( PrepareSQL ( " c % 02d = NULL " , i ) ) ; <nl> + conditions . emplace_back ( PrepareSQL ( " c % 02d = NULL " , i ) ) ; <nl> } <nl> break ; <nl> case VIDEODB_TYPE_BOOL : <nl> - conditions . push_back ( PrepareSQL ( " c % 02d = ' % s ' " , i , * ( bool * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ? " true " : " false " ) ) ; <nl> + conditions . emplace_back ( PrepareSQL ( " c % 02d = ' % s ' " , i , * ( bool * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ? " true " : " false " ) ) ; <nl> break ; <nl> case VIDEODB_TYPE_FLOAT : <nl> - conditions . push_back ( PrepareSQL ( " c % 02d = ' % f ' " , i , * ( float * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) ) ; <nl> + conditions . emplace_back ( PrepareSQL ( " c % 02d = ' % f ' " , i , * ( float * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) ) ; <nl> break ; <nl> case VIDEODB_TYPE_STRINGARRAY : <nl> - conditions . push_back ( PrepareSQL ( " c % 02d = ' % s ' " , i , StringUtils : : Join ( * ( ( std : : vector < std : : string > * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) , <nl> + conditions . emplace_back ( PrepareSQL ( " c % 02d = ' % s ' " , i , StringUtils : : Join ( * ( ( std : : vector < std : : string > * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) , <nl> g_advancedSettings . m_videoItemSeparator ) . c_str ( ) ) ) ; <nl> break ; <nl> case VIDEODB_TYPE_DATE : <nl> - conditions . push_back ( PrepareSQL ( " c % 02d = ' % s ' " , i , ( ( CDateTime * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) - > GetAsDBDate ( ) . c_str ( ) ) ) ; <nl> + conditions . emplace_back ( PrepareSQL ( " c % 02d = ' % s ' " , i , ( ( CDateTime * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) - > GetAsDBDate ( ) . c_str ( ) ) ) ; <nl> break ; <nl> case VIDEODB_TYPE_DATETIME : <nl> - conditions . push_back ( PrepareSQL ( " c % 02d = ' % s ' " , i , ( ( CDateTime * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) - > GetAsDBDateTime ( ) . c_str ( ) ) ) ; <nl> + conditions . emplace_back ( PrepareSQL ( " c % 02d = ' % s ' " , i , ( ( CDateTime * ) ( ( ( char * ) & details ) + offsets [ i ] . offset ) ) - > GetAsDBDateTime ( ) . c_str ( ) ) ) ; <nl> break ; <nl> } <nl> } <nl> void CVideoDatabase : : SetStreamDetailsForFileId ( const CStreamDetails & details , in <nl> if ( details . GetVideoDuration ( ) ) <nl> { <nl> std : : vector < std : : pair < std : : string , int > > tables ; <nl> - tables . push_back ( std : : make_pair ( " movie " , VIDEODB_ID_RUNTIME ) ) ; <nl> - tables . push_back ( std : : make_pair ( " episode " , VIDEODB_ID_EPISODE_RUNTIME ) ) ; <nl> - tables . push_back ( std : : make_pair ( " musicvideo " , VIDEODB_ID_MUSICVIDEO_RUNTIME ) ) ; <nl> + tables . emplace_back ( " movie " , VIDEODB_ID_RUNTIME ) ; <nl> + tables . emplace_back ( " episode " , VIDEODB_ID_EPISODE_RUNTIME ) ; <nl> + tables . emplace_back ( " musicvideo " , VIDEODB_ID_MUSICVIDEO_RUNTIME ) ; <nl> for ( std : : vector < std : : pair < std : : string , int > > : : iterator i = tables . begin ( ) ; i ! = tables . end ( ) ; + + i ) <nl> { <nl> std : : string sql = PrepareSQL ( " update % s set c % 02d = % d where idFile = % d and c % 02d = ' ' " , <nl> void CVideoDatabase : : GetEpisodesByFile ( const std : : string & strFilenameAndPath , st <nl> m_pDS - > query ( strSQL ) ; <nl> while ( ! m_pDS - > eof ( ) ) <nl> { <nl> - episodes . push_back ( GetDetailsForEpisode ( m_pDS ) ) ; <nl> + episodes . emplace_back ( GetDetailsForEpisode ( m_pDS ) ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> m_pDS - > close ( ) ; <nl> CVideoInfoTag CVideoDatabase : : GetDetailsForMovie ( const dbiplus : : sql_record * cons <nl> VIDEODB_ID_TV_TITLE , links [ i ] ) ; <nl> m_pDS2 - > query ( strSQL ) ; <nl> if ( ! m_pDS2 - > eof ( ) ) <nl> - details . m_showLink . push_back ( m_pDS2 - > fv ( 0 ) . get_asString ( ) ) ; <nl> + details . m_showLink . emplace_back ( m_pDS2 - > fv ( 0 ) . get_asString ( ) ) ; <nl> } <nl> m_pDS2 - > close ( ) ; <nl> } <nl> void CVideoDatabase : : GetCast ( int media_id , const std : : string & media_type , std : : v <nl> info . order = m_pDS2 - > fv ( 2 ) . get_asInt ( ) ; <nl> info . thumbUrl . ParseString ( m_pDS2 - > fv ( 3 ) . get_asString ( ) ) ; <nl> info . thumb = m_pDS2 - > fv ( 4 ) . get_asString ( ) ; <nl> - cast . push_back ( info ) ; <nl> + cast . emplace_back ( std : : move ( info ) ) ; <nl> } <nl> m_pDS2 - > next ( ) ; <nl> } <nl> void CVideoDatabase : : GetTags ( int media_id , const std : : string & media_type , std : : v <nl> m_pDS2 - > query ( sql ) ; <nl> while ( ! m_pDS2 - > eof ( ) ) <nl> { <nl> - tags . push_back ( m_pDS2 - > fv ( 0 ) . get_asString ( ) ) ; <nl> + tags . emplace_back ( m_pDS2 - > fv ( 0 ) . get_asString ( ) ) ; <nl> m_pDS2 - > next ( ) ; <nl> } <nl> m_pDS2 - > close ( ) ; <nl> bool CVideoDatabase : : GetArtTypes ( const MediaType & mediaType , std : : vector < std : : st <nl> <nl> while ( ! m_pDS - > eof ( ) ) <nl> { <nl> - artTypes . push_back ( m_pDS - > fv ( 0 ) . get_asString ( ) ) ; <nl> + artTypes . emplace_back ( m_pDS - > fv ( 0 ) . get_asString ( ) ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> m_pDS - > close ( ) ; <nl> void CVideoDatabase : : UpdateTables ( int iVersion ) <nl> show . title = m_pDS - > fv ( 2 ) . get_asString ( ) ; <nl> show . year = m_pDS - > fv ( 3 ) . get_asString ( ) ; <nl> show . ident = m_pDS - > fv ( 4 ) . get_asString ( ) ; <nl> - shows . push_back ( show ) ; <nl> + shows . emplace_back ( std : : move ( show ) ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> m_pDS - > close ( ) ; <nl> void CVideoDatabase : : UpdateTables ( int iVersion ) <nl> link . show = m_pDS - > fv ( 0 ) . get_asInt ( ) ; <nl> link . pathId = m_pDS - > fv ( 1 ) . get_asInt ( ) ; <nl> link . path = m_pDS - > fv ( 2 ) . get_asString ( ) ; <nl> - shows . push_back ( link ) ; <nl> + shows . emplace_back ( std : : move ( link ) ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> m_pDS - > close ( ) ; <nl> bool CVideoDatabase : : GetMusicVideoAlbumsNav ( const std : : string & strBaseDir , CFile <nl> pItem - > SetLabelPreformated ( true ) ; <nl> if ( ! items . Contains ( pItem - > GetPath ( ) ) ) <nl> { <nl> - pItem - > GetVideoInfoTag ( ) - > m_artist . push_back ( m_pDS - > fv ( 2 ) . get_asString ( ) ) ; <nl> + pItem - > GetVideoInfoTag ( ) - > m_artist . emplace_back ( m_pDS - > fv ( 2 ) . get_asString ( ) ) ; <nl> items . Add ( pItem ) ; <nl> } <nl> } <nl> bool CVideoDatabase : : GetPeopleNav ( const std : : string & strBaseDir , CFileItemList & <nl> } <nl> pItem - > GetVideoInfoTag ( ) - > m_relevance = m_pDS - > fv ( 3 ) . get_asInt ( ) ; <nl> if ( idContent = = VIDEODB_CONTENT_MUSICVIDEOS ) <nl> - pItem - > GetVideoInfoTag ( ) - > m_artist . push_back ( pItem - > GetLabel ( ) ) ; <nl> + pItem - > GetVideoInfoTag ( ) - > m_artist . emplace_back ( pItem - > GetLabel ( ) ) ; <nl> items . Add ( pItem ) ; <nl> m_pDS - > next ( ) ; <nl> } <nl> mmm a / xbmc / video / windows / GUIWindowVideoBase . cpp <nl> ppp b / xbmc / video / windows / GUIWindowVideoBase . cpp <nl> <nl> # include " dialogs / GUIDialogSmartPlaylistEditor . h " <nl> # include " dialogs / GUIDialogProgress . h " <nl> # include " dialogs / GUIDialogYesNo . h " <nl> + # include " view / GUIViewState . h " <nl> # include " playlists / PlayListFactory . h " <nl> # include " Application . h " <nl> # include " NfoFile . h " <nl> mmm a / xbmc / video / windows / GUIWindowVideoNav . cpp <nl> ppp b / xbmc / video / windows / GUIWindowVideoNav . cpp <nl> <nl> # include " GUIPassword . h " <nl> # include " filesystem / MultiPathDirectory . h " <nl> # include " filesystem / VideoDatabaseDirectory . h " <nl> + # include " view / GUIViewState . h " <nl> # include " dialogs / GUIDialogOK . h " <nl> # include " PartyModeManager . h " <nl> # include " music / MusicDatabase . h " <nl> mmm a / xbmc / windows / GUIMediaWindow . cpp <nl> ppp b / xbmc / windows / GUIMediaWindow . cpp <nl> <nl> # include " utils / URIUtils . h " <nl> # include " utils / Variant . h " <nl> # include " video / VideoLibraryQueue . h " <nl> + # include " view / GUIViewState . h " <nl> <nl> # define CONTROL_BTNVIEWASICONS 2 <nl> # define CONTROL_BTNSORTBY 3 <nl> mmm a / xbmc / windows / GUIMediaWindow . h <nl> ppp b / xbmc / windows / GUIMediaWindow . h <nl> <nl> # include " guilib / GUIWindow . h " <nl> # include " playlists / SmartPlayList . h " <nl> # include " view / GUIViewControl . h " <nl> - # include " view / GUIViewState . h " <nl> <nl> class CFileItemList ; <nl> + class CGUIViewState ; <nl> <nl> / / base class for all media windows <nl> class CGUIMediaWindow : public CGUIWindow <nl>
|
Merge pull request from MaxKellermann / cleanup1
|
xbmc/xbmc
|
a1ede5480897b1efed94b3b090ada08114ef68cb
|
2016-04-19T18:30:06Z
|
mmm a / arangod / CMakeLists . txt <nl> ppp b / arangod / CMakeLists . txt <nl> add_executable ( <nl> Replication / ContinuousSyncer . cpp <nl> Replication / InitialSyncer . cpp <nl> Replication / Syncer . cpp <nl> - Rest / AnyServer . cpp <nl> RestHandler / RestAdminLogHandler . cpp <nl> RestHandler / RestBaseHandler . cpp <nl> RestHandler / RestBatchHandler . cpp <nl> deleted file mode 100644 <nl> index 016ea4c9838 . . 00000000000 <nl> mmm a / arangod / Rest / AnyServer . cpp <nl> ppp / dev / null <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / DISCLAIMER <nl> - / / / <nl> - / / / Copyright 2014 - 2016 ArangoDB GmbH , Cologne , Germany <nl> - / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> - / / / <nl> - / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - / / / you may not use this file except in compliance with the License . <nl> - / / / You may obtain a copy of the License at <nl> - / / / <nl> - / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - / / / <nl> - / / / Unless required by applicable law or agreed to in writing , software <nl> - / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> - / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - / / / See the License for the specific language governing permissions and <nl> - / / / limitations under the License . <nl> - / / / <nl> - / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> - / / / <nl> - / / / @ author Dr . Frank Celler <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # include " AnyServer . h " <nl> - <nl> - # ifdef TRI_HAVE_SYS_WAIT_H <nl> - # include < sys / wait . h > <nl> - # endif <nl> - <nl> - # ifdef TRI_HAVE_SYS_PRCTL_H <nl> - # include < sys / prctl . h > <nl> - # endif <nl> - <nl> - # include " ApplicationServer / ApplicationServer . h " <nl> - # include " Basics / FileUtils . h " <nl> - # include " Basics / Logger . h " <nl> - # include " Basics / process - utils . h " <nl> - <nl> - # include < fstream > <nl> - <nl> - using namespace arangodb ; <nl> - using namespace arangodb : : basics ; <nl> - using namespace arangodb : : rest ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief writes a pid file <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static void WritePidFile ( std : : string const & pidFile , int pid ) { <nl> - std : : ofstream out ( pidFile . c_str ( ) , std : : ios : : trunc ) ; <nl> - <nl> - if ( ! out ) { <nl> - LOG ( FATAL ) < < " cannot write pid - file ' " < < pidFile . c_str ( ) < < " ' " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - out < < pid ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief checks a pid file <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - static void CheckPidFile ( std : : string const & pidFile ) { <nl> - / / check if the pid - file exists <nl> - if ( ! pidFile . empty ( ) ) { <nl> - if ( FileUtils : : isDirectory ( pidFile ) ) { <nl> - LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' is a directory " ; FATAL_ERROR_EXIT ( ) ; <nl> - } else if ( FileUtils : : exists ( pidFile ) & & FileUtils : : size ( pidFile ) > 0 ) { <nl> - LOG ( INFO ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' already exists , verifying pid " ; <nl> - <nl> - std : : ifstream f ( pidFile . c_str ( ) ) ; <nl> - <nl> - / / file can be opened <nl> - if ( f ) { <nl> - TRI_pid_t oldPid ; <nl> - <nl> - f > > oldPid ; <nl> - <nl> - if ( oldPid = = 0 ) { <nl> - LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' is unreadable " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - LOG ( DEBUG ) < < " found old pid : " < < oldPid ; <nl> - <nl> - # ifdef TRI_HAVE_FORK <nl> - int r = kill ( oldPid , 0 ) ; <nl> - # else <nl> - int r = 0 ; / / TODO for windows use TerminateProcess <nl> - # endif <nl> - <nl> - if ( r = = 0 ) { <nl> - LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' exists and process with pid " < < oldPid < < " is still running " ; FATAL_ERROR_EXIT ( ) ; <nl> - } else if ( errno = = EPERM ) { <nl> - LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' exists and process with pid " < < oldPid < < " is still running " ; FATAL_ERROR_EXIT ( ) ; <nl> - } else if ( errno = = ESRCH ) { <nl> - LOG ( ERR ) < < " pid - file ' " < < pidFile . c_str ( ) < < " exists , but no process with pid " < < oldPid < < " exists " ; <nl> - <nl> - if ( ! FileUtils : : remove ( pidFile ) ) { <nl> - LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' exists , no process with pid " < < oldPid < < " exists , but pid - file cannot be removed " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - LOG ( INFO ) < < " removed stale pid - file ' " < < pidFile . c_str ( ) < < " ' " ; <nl> - } else { <nl> - LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' exists and kill " < < oldPid < < " failed " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / failed to open file <nl> - else { <nl> - LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' exists , but cannot be opened " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - } <nl> - <nl> - LOG ( DEBUG ) < < " using pid - file ' " < < pidFile . c_str ( ) < < " ' " ; <nl> - } <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief forks a new process <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # ifdef TRI_HAVE_FORK <nl> - <nl> - static int ForkProcess ( std : : string const & workingDirectory , <nl> - std : : string & current ) { <nl> - / / fork off the parent process <nl> - TRI_pid_t pid = fork ( ) ; <nl> - <nl> - if ( pid < 0 ) { <nl> - LOG ( FATAL ) < < " cannot fork " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - / / Upon successful completion , fork ( ) shall return 0 to the child process and <nl> - / / shall return the process ID of the child process to the parent process . <nl> - <nl> - / / if we got a good PID , then we can exit the parent process <nl> - if ( pid > 0 ) { <nl> - LOG ( DEBUG ) < < " started child process with pid " < < pid ; <nl> - return pid ; <nl> - } <nl> - <nl> - / / change the file mode mask <nl> - umask ( 0 ) ; <nl> - <nl> - / / create a new SID for the child process <nl> - TRI_pid_t sid = setsid ( ) ; <nl> - <nl> - if ( sid < 0 ) { <nl> - LOG ( FATAL ) < < " cannot create sid " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - / / store current working directory <nl> - int err = 0 ; <nl> - current = FileUtils : : currentDirectory ( & err ) ; <nl> - <nl> - if ( err ! = 0 ) { <nl> - LOG ( FATAL ) < < " cannot get current directory " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - / / change the current working directory <nl> - if ( ! workingDirectory . empty ( ) ) { <nl> - if ( ! FileUtils : : changeDirectory ( workingDirectory ) ) { <nl> - LOG ( FATAL ) < < " cannot change into working directory ' " < < workingDirectory . c_str ( ) < < " ' " ; FATAL_ERROR_EXIT ( ) ; <nl> - } else { <nl> - LOG ( INFO ) < < " changed working directory for child process to ' " < < workingDirectory . c_str ( ) < < " ' " ; <nl> - } <nl> - } <nl> - <nl> - / / we ' re a daemon so there won ' t be a terminal attached <nl> - / / close the standard file descriptors and re - open them mapped to / dev / null <nl> - int fd = open ( " / dev / null " , O_RDWR | O_CREAT , 0644 ) ; <nl> - <nl> - if ( fd < 0 ) { <nl> - LOG ( FATAL ) < < " cannot open / dev / null " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - if ( dup2 ( fd , STDIN_FILENO ) < 0 ) { <nl> - LOG ( FATAL ) < < " cannot re - map stdin to / dev / null " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - if ( dup2 ( fd , STDOUT_FILENO ) < 0 ) { <nl> - LOG ( FATAL ) < < " cannot re - map stdout to / dev / null " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - if ( dup2 ( fd , STDERR_FILENO ) < 0 ) { <nl> - LOG ( FATAL ) < < " cannot re - map stderr to / dev / null " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - close ( fd ) ; <nl> - <nl> - return 0 ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief waits for the supervisor process with pid to return its exit status <nl> - / / / waits for at most 10 seconds . if the supervisor has not returned until then , <nl> - / / / we assume a successful start <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - int WaitForSupervisor ( int pid ) { <nl> - if ( ! isatty ( STDIN_FILENO ) ) { <nl> - / / during system boot , we don ' t have a tty , and we don ' t want to delay <nl> - / / the boot process <nl> - return EXIT_SUCCESS ; <nl> - } <nl> - <nl> - / / in case a tty is present , this is probably a manual invocation of the start <nl> - / / procedure <nl> - double const end = TRI_microtime ( ) + 10 . 0 ; <nl> - <nl> - while ( TRI_microtime ( ) < end ) { <nl> - int status ; <nl> - int res = waitpid ( pid , & status , WNOHANG ) ; <nl> - <nl> - if ( res = = - 1 ) { <nl> - / / error in waitpid . don ' t know what to do <nl> - break ; <nl> - } <nl> - <nl> - if ( res ! = 0 & & WIFEXITED ( status ) ) { <nl> - / / give information about supervisor exit code <nl> - if ( WEXITSTATUS ( status ) = = 0 ) { <nl> - / / exit code 0 <nl> - return EXIT_SUCCESS ; <nl> - } else if ( WIFSIGNALED ( status ) ) { <nl> - switch ( WTERMSIG ( status ) ) { <nl> - case 2 : <nl> - case 9 : <nl> - case 15 : <nl> - / / terminated normally <nl> - return EXIT_SUCCESS ; <nl> - default : <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - / / failure ! <nl> - LOG ( ERR ) < < " unable to start arangod . please check the logfiles for errors " ; <nl> - return EXIT_FAILURE ; <nl> - } <nl> - <nl> - / / sleep a while and retry <nl> - usleep ( 500 * 1000 ) ; <nl> - } <nl> - <nl> - / / enough time has elapsed . . . we now abort our loop <nl> - return EXIT_SUCCESS ; <nl> - } <nl> - <nl> - # else <nl> - <nl> - / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> - / / TODO : use windows API CreateProcess & CreateThread to minic fork ( ) <nl> - / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> - <nl> - static int ForkProcess ( std : : string const & workingDirectory , <nl> - std : : string & current ) { <nl> - / / fork off the parent process <nl> - TRI_pid_t pid = - 1 ; / / fork ( ) ; <nl> - <nl> - if ( pid < 0 ) { <nl> - LOG ( FATAL ) < < " cannot fork " ; FATAL_ERROR_EXIT ( ) ; <nl> - } <nl> - <nl> - return 0 ; <nl> - } <nl> - <nl> - # endif <nl> - <nl> - AnyServer : : AnyServer ( ) <nl> - : _mode ( ServerMode : : MODE_STANDALONE ) , <nl> - _daemonMode ( false ) , <nl> - _supervisorMode ( false ) , <nl> - _pidFile ( " " ) , <nl> - _workingDirectory ( " " ) , <nl> - _applicationServer ( nullptr ) { } <nl> - <nl> - AnyServer : : ~ AnyServer ( ) { delete _applicationServer ; } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief starts the server <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - int AnyServer : : start ( ) { <nl> - startupProgress ( ) ; <nl> - <nl> - if ( _applicationServer = = nullptr ) { <nl> - buildApplicationServer ( ) ; <nl> - } <nl> - <nl> - startupProgress ( ) ; <nl> - <nl> - if ( _supervisorMode ) { <nl> - return startupSupervisor ( ) ; <nl> - } else if ( _daemonMode ) { <nl> - return startupDaemon ( ) ; <nl> - } else { <nl> - _applicationServer - > setupLogging ( true , false , false ) ; <nl> - <nl> - startupProgress ( ) ; <nl> - <nl> - if ( ! _pidFile . empty ( ) ) { <nl> - CheckPidFile ( _pidFile ) ; <nl> - WritePidFile ( _pidFile , TRI_CurrentProcessId ( ) ) ; <nl> - } <nl> - <nl> - startupProgress ( ) ; <nl> - <nl> - int res = startupServer ( ) ; <nl> - <nl> - if ( ! _pidFile . empty ( ) ) { <nl> - if ( ! FileUtils : : remove ( _pidFile ) ) { <nl> - LOG ( DEBUG ) < < " cannot remove pid file ' " < < _pidFile . c_str ( ) < < " ' " ; <nl> - } <nl> - } <nl> - startupProgress ( ) ; <nl> - <nl> - return res ; <nl> - } <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief begins shutdown sequence <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void AnyServer : : beginShutdown ( ) { <nl> - if ( _applicationServer ! = nullptr ) { <nl> - _applicationServer - > beginShutdown ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief starts a supervisor <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # ifdef TRI_HAVE_FORK <nl> - <nl> - int AnyServer : : startupSupervisor ( ) { <nl> - static time_t const MIN_TIME_ALIVE_IN_SEC = 30 ; <nl> - <nl> - LOG ( INFO ) < < " starting up in supervisor mode " ; <nl> - <nl> - CheckPidFile ( _pidFile ) ; <nl> - <nl> - _applicationServer - > setupLogging ( false , true , false ) ; <nl> - <nl> - std : : string current ; <nl> - int result = ForkProcess ( _workingDirectory , current ) ; <nl> - <nl> - / / main process <nl> - if ( result ! = 0 ) { <nl> - / / wait for a few seconds for the supervisor to return <nl> - / / if it returns within a reasonable time , we can fetch its exit code <nl> - / / and report it <nl> - return WaitForSupervisor ( result ) ; <nl> - } <nl> - <nl> - / / child process <nl> - else { <nl> - setMode ( ServerMode : : MODE_SERVICE ) ; <nl> - <nl> - time_t startTime = time ( 0 ) ; <nl> - time_t t ; <nl> - bool done = false ; <nl> - result = 0 ; <nl> - <nl> - while ( ! done ) { <nl> - / / fork of the server <nl> - TRI_pid_t pid = fork ( ) ; <nl> - <nl> - if ( pid < 0 ) { <nl> - TRI_EXIT_FUNCTION ( EXIT_FAILURE , NULL ) ; <nl> - } <nl> - <nl> - / / parent <nl> - if ( 0 < pid ) { <nl> - _applicationServer - > setupLogging ( false , true , true ) ; <nl> - TRI_SetProcessTitle ( " arangodb [ supervisor ] " ) ; <nl> - LOG ( DEBUG ) < < " supervisor mode : within parent " ; <nl> - <nl> - int status ; <nl> - waitpid ( pid , & status , 0 ) ; <nl> - bool horrible = true ; <nl> - <nl> - if ( WIFEXITED ( status ) ) { <nl> - / / give information about cause of death <nl> - if ( WEXITSTATUS ( status ) = = 0 ) { <nl> - LOG ( INFO ) < < " child " < < pid < < " died of natural causes " ; <nl> - done = true ; <nl> - horrible = false ; <nl> - } else { <nl> - t = time ( 0 ) - startTime ; <nl> - <nl> - LOG ( ERR ) < < " child " < < pid < < " died a horrible death , exit status " < < WEXITSTATUS ( status ) ; <nl> - <nl> - if ( t < MIN_TIME_ALIVE_IN_SEC ) { <nl> - LOG ( ERR ) < < " child only survived for " < < t < < " seconds , this will not work - please fix the error first " ; <nl> - done = true ; <nl> - } else { <nl> - done = false ; <nl> - } <nl> - } <nl> - } else if ( WIFSIGNALED ( status ) ) { <nl> - switch ( WTERMSIG ( status ) ) { <nl> - case 2 : <nl> - case 9 : <nl> - case 15 : <nl> - LOG ( INFO ) < < " child " < < pid < < " died of natural causes , exit status " < < WTERMSIG ( status ) ; <nl> - done = true ; <nl> - horrible = false ; <nl> - break ; <nl> - <nl> - default : <nl> - t = time ( 0 ) - startTime ; <nl> - <nl> - LOG ( ERR ) < < " child " < < pid < < " died a horrible death , signal " < < WTERMSIG ( status ) ; <nl> - <nl> - if ( t < MIN_TIME_ALIVE_IN_SEC ) { <nl> - LOG ( ERR ) < < " child only survived for " < < t < < " seconds , this will not work - please fix the error first " ; <nl> - done = true ; <nl> - <nl> - # ifdef WCOREDUMP <nl> - if ( WCOREDUMP ( status ) ) { <nl> - LOG ( WARN ) < < " child process " < < pid < < " produced a core dump " ; <nl> - } <nl> - # endif <nl> - } else { <nl> - done = false ; <nl> - } <nl> - <nl> - break ; <nl> - } <nl> - } else { <nl> - LOG ( ERR ) < < " child " < < pid < < " died a horrible death , unknown cause " ; <nl> - done = false ; <nl> - } <nl> - <nl> - / / remove pid file <nl> - if ( horrible ) { <nl> - if ( ! FileUtils : : remove ( _pidFile ) ) { <nl> - LOG ( DEBUG ) < < " cannot remove pid file ' " < < _pidFile . c_str ( ) < < " ' " ; <nl> - } <nl> - <nl> - result = EXIT_FAILURE ; <nl> - } <nl> - } <nl> - <nl> - / / child <nl> - else { <nl> - _applicationServer - > setupLogging ( true , false , true ) ; <nl> - LOG ( DEBUG ) < < " supervisor mode : within child " ; <nl> - <nl> - / / write the pid file <nl> - WritePidFile ( _pidFile , TRI_CurrentProcessId ( ) ) ; <nl> - <nl> - / / force child to stop if supervisor dies <nl> - # ifdef TRI_HAVE_PRCTL <nl> - prctl ( PR_SET_PDEATHSIG , SIGTERM , 0 , 0 , 0 ) ; <nl> - # endif <nl> - <nl> - / / startup server <nl> - result = startupServer ( ) ; <nl> - <nl> - / / remove pid file <nl> - if ( ! FileUtils : : remove ( _pidFile ) ) { <nl> - LOG ( DEBUG ) < < " cannot remove pid file ' " < < _pidFile . c_str ( ) < < " ' " ; <nl> - } <nl> - <nl> - / / and stop <nl> - TRI_EXIT_FUNCTION ( result , NULL ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief starts a daemon <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - int AnyServer : : startupDaemon ( ) { <nl> - LOG ( INFO ) < < " starting up in daemon mode " ; <nl> - <nl> - CheckPidFile ( _pidFile ) ; <nl> - <nl> - _applicationServer - > setupLogging ( false , true , false ) ; <nl> - <nl> - std : : string current ; <nl> - int result = ForkProcess ( _workingDirectory , current ) ; <nl> - <nl> - / / main process <nl> - if ( result ! = 0 ) { <nl> - TRI_SetProcessTitle ( " arangodb [ daemon ] " ) ; <nl> - WritePidFile ( _pidFile , result ) ; <nl> - <nl> - / / issue # 549 : this is used as the exit code <nl> - result = 0 ; <nl> - } <nl> - <nl> - / / child process <nl> - else { <nl> - setMode ( ServerMode : : MODE_SERVICE ) ; <nl> - _applicationServer - > setupLogging ( true , false , true ) ; <nl> - LOG ( DEBUG ) < < " daemon mode : within child " ; <nl> - <nl> - / / and startup server <nl> - result = startupServer ( ) ; <nl> - <nl> - / / remove pid file <nl> - if ( ! FileUtils : : remove ( _pidFile ) ) { <nl> - LOG ( DEBUG ) < < " cannot remove pid file ' " < < _pidFile . c_str ( ) < < " ' " ; <nl> - } <nl> - } <nl> - <nl> - return result ; <nl> - } <nl> - <nl> - # else <nl> - <nl> - int AnyServer : : startupSupervisor ( ) { return 0 ; } <nl> - <nl> - int AnyServer : : startupDaemon ( ) { return 0 ; } <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 67f4d19d6ba . . 00000000000 <nl> mmm a / arangod / Rest / AnyServer . h <nl> ppp / dev / null <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / DISCLAIMER <nl> - / / / <nl> - / / / Copyright 2014 - 2016 ArangoDB GmbH , Cologne , Germany <nl> - / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> - / / / <nl> - / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - / / / you may not use this file except in compliance with the License . <nl> - / / / You may obtain a copy of the License at <nl> - / / / <nl> - / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - / / / <nl> - / / / Unless required by applicable law or agreed to in writing , software <nl> - / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> - / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - / / / See the License for the specific language governing permissions and <nl> - / / / limitations under the License . <nl> - / / / <nl> - / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> - / / / <nl> - / / / @ author Dr . Frank Celler <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # ifndef ARANGOD_REST_ANY_SERVER_H <nl> - # define ARANGOD_REST_ANY_SERVER_H 1 <nl> - <nl> - # include " Basics / Common . h " <nl> - <nl> - namespace arangodb { <nl> - namespace rest { <nl> - class ApplicationServer ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief rest server base <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - class AnyServer { <nl> - AnyServer ( AnyServer const & ) = delete ; <nl> - AnyServer & operator = ( AnyServer const & ) = delete ; <nl> - <nl> - public : <nl> - AnyServer ( ) ; <nl> - <nl> - virtual ~ AnyServer ( ) ; <nl> - <nl> - public : <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief enumeration for server modes <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - enum class ServerMode { MODE_STANDALONE , MODE_SERVICE } ; <nl> - <nl> - public : <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief starts the server <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - int start ( ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief begins shutdown sequence <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void beginShutdown ( ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief set the server mode <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void setMode ( ServerMode mode ) { _mode = mode ; } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief get the server mode as a string <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - char const * modeString ( ) const { <nl> - if ( _mode = = ServerMode : : MODE_STANDALONE ) { <nl> - return " standalone " ; <nl> - } <nl> - <nl> - TRI_ASSERT ( _mode = = ServerMode : : MODE_SERVICE ) ; <nl> - return " service " ; <nl> - } <nl> - <nl> - protected : <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief builds the application server <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - virtual void buildApplicationServer ( ) = 0 ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief start the server using the description <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - virtual int startupServer ( ) = 0 ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief to be called when something happened <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - virtual void startupProgress ( ) { } ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief to be called when we ' re ready for action . <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - virtual void startupFinished ( ) { } ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief to be called when we ' re starting to shutdown . <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - virtual void shutDownBegins ( ) { } ; <nl> - <nl> - protected : <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief the server mode <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - ServerMode _mode ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief running in daemon mode <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool _daemonMode ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief running in supervisor mode <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - bool _supervisorMode ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief was docuBlock pidFile <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - std : : string _pidFile ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief working directory <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - std : : string _workingDirectory ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief application server <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - ApplicationServer * _applicationServer ; <nl> - <nl> - private : <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief starts a supervisor <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - int startupSupervisor ( ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief starts a daemon <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - int startupDaemon ( ) ; <nl> - } ; <nl> - } <nl> - } <nl> - <nl> - # endif <nl> mmm a / arangod / RestHandler / RestDebugHandler . cpp <nl> ppp b / arangod / RestHandler / RestDebugHandler . cpp <nl> <nl> <nl> # include " RestDebugHandler . h " <nl> <nl> - # include " Rest / AnyServer . h " <nl> + # include " RestServer / ArangoServer . h " <nl> # include " Rest / HttpRequest . h " <nl> # include " Rest / Version . h " <nl> <nl> using namespace arangodb : : rest ; <nl> / / / @ brief ArangoDB server <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - extern AnyServer * ArangoInstance ; <nl> + extern ArangoServer * ArangoInstance ; <nl> <nl> RestDebugHandler : : RestDebugHandler ( HttpRequest * request ) <nl> : RestVocbaseBaseHandler ( request ) { } <nl> mmm a / arangod / RestHandler / RestVersionHandler . cpp <nl> ppp b / arangod / RestHandler / RestVersionHandler . cpp <nl> <nl> <nl> # include " RestVersionHandler . h " <nl> <nl> - # include " Rest / AnyServer . h " <nl> + # include " RestServer / ArangoServer . h " <nl> # include " Rest / HttpRequest . h " <nl> # include " Rest / Version . h " <nl> <nl> using namespace arangodb : : rest ; <nl> / / / @ brief ArangoDB server <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - extern AnyServer * ArangoInstance ; <nl> + extern ArangoServer * ArangoInstance ; <nl> <nl> RestVersionHandler : : RestVersionHandler ( HttpRequest * request ) <nl> : RestBaseHandler ( request ) { } <nl> mmm a / arangod / RestServer / ArangoServer . cpp <nl> ppp b / arangod / RestServer / ArangoServer . cpp <nl> <nl> <nl> # include " ArangoServer . h " <nl> <nl> + # ifdef TRI_HAVE_SYS_WAIT_H <nl> + # include < sys / wait . h > <nl> + # endif <nl> + <nl> + # ifdef TRI_HAVE_SYS_PRCTL_H <nl> + # include < sys / prctl . h > <nl> + # endif <nl> + <nl> # include < v8 . h > <nl> # include < iostream > <nl> + # include < fstream > <nl> <nl> # include " Actions / RestActionHandler . h " <nl> # include " Actions / actions . h " <nl> + # include " ApplicationServer / ApplicationServer . h " <nl> # include " Aql / Query . h " <nl> # include " Aql / QueryCache . h " <nl> # include " Aql / RestAqlHandler . h " <nl> # include " Basics / FileUtils . h " <nl> + # include " Basics / Logger . h " <nl> # include " Basics / Nonce . h " <nl> # include " Basics / ProgramOptions . h " <nl> # include " Basics / ProgramOptionsDescription . h " <nl> # include " Basics / RandomGenerator . h " <nl> + # include " Basics / ThreadPool . h " <nl> # include " Basics / Utf8Helper . h " <nl> # include " Basics / files . h " <nl> - # include " Basics / init . h " <nl> - # include " Basics / Logger . h " <nl> # include " Basics / messages . h " <nl> - # include " Basics / ThreadPool . h " <nl> + # include " Basics / process - utils . h " <nl> # include " Basics / tri - strings . h " <nl> # include " Cluster / ApplicationCluster . h " <nl> # include " Cluster / ClusterComm . h " <nl> <nl> # include " V8 / v8 - conv . h " <nl> # include " V8 / v8 - utils . h " <nl> # include " V8Server / ApplicationV8 . h " <nl> - # include " VocBase / auth . h " <nl> # include " VocBase / KeyGenerator . h " <nl> + # include " VocBase / auth . h " <nl> # include " VocBase / server . h " <nl> # include " Wal / LogfileManager . h " <nl> <nl> bool ALLOW_USE_DATABASE_IN_REST_ACTIONS ; <nl> <nl> bool IGNORE_DATAFILE_ERRORS ; <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief writes a pid file <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + static void WritePidFile ( std : : string const & pidFile , int pid ) { <nl> + std : : ofstream out ( pidFile . c_str ( ) , std : : ios : : trunc ) ; <nl> + <nl> + if ( ! out ) { <nl> + LOG ( FATAL ) < < " cannot write pid - file ' " < < pidFile . c_str ( ) < < " ' " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + out < < pid ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief checks a pid file <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + static void CheckPidFile ( std : : string const & pidFile ) { <nl> + / / check if the pid - file exists <nl> + if ( ! pidFile . empty ( ) ) { <nl> + if ( FileUtils : : isDirectory ( pidFile ) ) { <nl> + LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' is a directory " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } else if ( FileUtils : : exists ( pidFile ) & & FileUtils : : size ( pidFile ) > 0 ) { <nl> + LOG ( INFO ) < < " pid - file ' " < < pidFile . c_str ( ) <nl> + < < " ' already exists , verifying pid " ; <nl> + <nl> + std : : ifstream f ( pidFile . c_str ( ) ) ; <nl> + <nl> + / / file can be opened <nl> + if ( f ) { <nl> + TRI_pid_t oldPid ; <nl> + <nl> + f > > oldPid ; <nl> + <nl> + if ( oldPid = = 0 ) { <nl> + LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' is unreadable " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + LOG ( DEBUG ) < < " found old pid : " < < oldPid ; <nl> + <nl> + # ifdef TRI_HAVE_FORK <nl> + int r = kill ( oldPid , 0 ) ; <nl> + # else <nl> + int r = 0 ; / / TODO for windows use TerminateProcess <nl> + # endif <nl> + <nl> + if ( r = = 0 ) { <nl> + LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) <nl> + < < " ' exists and process with pid " < < oldPid <nl> + < < " is still running " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } else if ( errno = = EPERM ) { <nl> + LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) <nl> + < < " ' exists and process with pid " < < oldPid <nl> + < < " is still running " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } else if ( errno = = ESRCH ) { <nl> + LOG ( ERR ) < < " pid - file ' " < < pidFile . c_str ( ) <nl> + < < " exists , but no process with pid " < < oldPid <nl> + < < " exists " ; <nl> + <nl> + if ( ! FileUtils : : remove ( pidFile ) ) { <nl> + LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) <nl> + < < " ' exists , no process with pid " < < oldPid <nl> + < < " exists , but pid - file cannot be removed " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + LOG ( INFO ) < < " removed stale pid - file ' " < < pidFile . c_str ( ) < < " ' " ; <nl> + } else { <nl> + LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) < < " ' exists and kill " <nl> + < < oldPid < < " failed " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + } <nl> + <nl> + / / failed to open file <nl> + else { <nl> + LOG ( FATAL ) < < " pid - file ' " < < pidFile . c_str ( ) <nl> + < < " ' exists , but cannot be opened " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + } <nl> + <nl> + LOG ( DEBUG ) < < " using pid - file ' " < < pidFile . c_str ( ) < < " ' " ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief forks a new process <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifdef TRI_HAVE_FORK <nl> + <nl> + static int ForkProcess ( std : : string const & workingDirectory , <nl> + std : : string & current ) { <nl> + / / fork off the parent process <nl> + TRI_pid_t pid = fork ( ) ; <nl> + <nl> + if ( pid < 0 ) { <nl> + LOG ( FATAL ) < < " cannot fork " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + / / Upon successful completion , fork ( ) shall return 0 to the child process and <nl> + / / shall return the process ID of the child process to the parent process . <nl> + <nl> + / / if we got a good PID , then we can exit the parent process <nl> + if ( pid > 0 ) { <nl> + LOG ( DEBUG ) < < " started child process with pid " < < pid ; <nl> + return pid ; <nl> + } <nl> + <nl> + / / change the file mode mask <nl> + umask ( 0 ) ; <nl> + <nl> + / / create a new SID for the child process <nl> + TRI_pid_t sid = setsid ( ) ; <nl> + <nl> + if ( sid < 0 ) { <nl> + LOG ( FATAL ) < < " cannot create sid " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + / / store current working directory <nl> + int err = 0 ; <nl> + current = FileUtils : : currentDirectory ( & err ) ; <nl> + <nl> + if ( err ! = 0 ) { <nl> + LOG ( FATAL ) < < " cannot get current directory " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + / / change the current working directory <nl> + if ( ! workingDirectory . empty ( ) ) { <nl> + if ( ! FileUtils : : changeDirectory ( workingDirectory ) ) { <nl> + LOG ( FATAL ) < < " cannot change into working directory ' " <nl> + < < workingDirectory . c_str ( ) < < " ' " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } else { <nl> + LOG ( INFO ) < < " changed working directory for child process to ' " <nl> + < < workingDirectory . c_str ( ) < < " ' " ; <nl> + } <nl> + } <nl> + <nl> + / / we ' re a daemon so there won ' t be a terminal attached <nl> + / / close the standard file descriptors and re - open them mapped to / dev / null <nl> + int fd = open ( " / dev / null " , O_RDWR | O_CREAT , 0644 ) ; <nl> + <nl> + if ( fd < 0 ) { <nl> + LOG ( FATAL ) < < " cannot open / dev / null " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + if ( dup2 ( fd , STDIN_FILENO ) < 0 ) { <nl> + LOG ( FATAL ) < < " cannot re - map stdin to / dev / null " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + if ( dup2 ( fd , STDOUT_FILENO ) < 0 ) { <nl> + LOG ( FATAL ) < < " cannot re - map stdout to / dev / null " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + if ( dup2 ( fd , STDERR_FILENO ) < 0 ) { <nl> + LOG ( FATAL ) < < " cannot re - map stderr to / dev / null " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + close ( fd ) ; <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief waits for the supervisor process with pid to return its exit status <nl> + / / / waits for at most 10 seconds . if the supervisor has not returned until then , <nl> + / / / we assume a successful start <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + int WaitForSupervisor ( int pid ) { <nl> + if ( ! isatty ( STDIN_FILENO ) ) { <nl> + / / during system boot , we don ' t have a tty , and we don ' t want to delay <nl> + / / the boot process <nl> + return EXIT_SUCCESS ; <nl> + } <nl> + <nl> + / / in case a tty is present , this is probably a manual invocation of the start <nl> + / / procedure <nl> + double const end = TRI_microtime ( ) + 10 . 0 ; <nl> + <nl> + while ( TRI_microtime ( ) < end ) { <nl> + int status ; <nl> + int res = waitpid ( pid , & status , WNOHANG ) ; <nl> + <nl> + if ( res = = - 1 ) { <nl> + / / error in waitpid . don ' t know what to do <nl> + break ; <nl> + } <nl> + <nl> + if ( res ! = 0 & & WIFEXITED ( status ) ) { <nl> + / / give information about supervisor exit code <nl> + if ( WEXITSTATUS ( status ) = = 0 ) { <nl> + / / exit code 0 <nl> + return EXIT_SUCCESS ; <nl> + } else if ( WIFSIGNALED ( status ) ) { <nl> + switch ( WTERMSIG ( status ) ) { <nl> + case 2 : <nl> + case 9 : <nl> + case 15 : <nl> + / / terminated normally <nl> + return EXIT_SUCCESS ; <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + / / failure ! <nl> + LOG ( ERR ) <nl> + < < " unable to start arangod . please check the logfiles for errors " ; <nl> + return EXIT_FAILURE ; <nl> + } <nl> + <nl> + / / sleep a while and retry <nl> + usleep ( 500 * 1000 ) ; <nl> + } <nl> + <nl> + / / enough time has elapsed . . . we now abort our loop <nl> + return EXIT_SUCCESS ; <nl> + } <nl> + <nl> + # else <nl> + <nl> + / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> + / / TODO : use windows API CreateProcess & CreateThread to minic fork ( ) <nl> + / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> + <nl> + static int ForkProcess ( std : : string const & workingDirectory , <nl> + std : : string & current ) { <nl> + / / fork off the parent process <nl> + TRI_pid_t pid = - 1 ; / / fork ( ) ; <nl> + <nl> + if ( pid < 0 ) { <nl> + LOG ( FATAL ) < < " cannot fork " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> + } <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> + # endif <nl> + <nl> + ArangoServer : : ArangoServer ( int argc , char * * argv ) <nl> + : _mode ( ServerMode : : MODE_STANDALONE ) , <nl> + _daemonMode ( false ) , <nl> + _supervisorMode ( false ) , <nl> + _pidFile ( " " ) , <nl> + _workingDirectory ( " " ) , <nl> + _applicationServer ( nullptr ) , <nl> + _argc ( argc ) , <nl> + _argv ( argv ) , <nl> + _tempPath ( ) , <nl> + _applicationScheduler ( nullptr ) , <nl> + _applicationDispatcher ( nullptr ) , <nl> + _applicationEndpointServer ( nullptr ) , <nl> + _applicationCluster ( nullptr ) , <nl> + _jobManager ( nullptr ) , <nl> + _applicationV8 ( nullptr ) , <nl> + _authenticateSystemOnly ( false ) , <nl> + _disableAuthentication ( false ) , <nl> + _disableAuthenticationUnixSockets ( false ) , <nl> + _dispatcherThreads ( 8 ) , <nl> + _dispatcherQueueSize ( 16384 ) , <nl> + _v8Contexts ( 8 ) , <nl> + _indexThreads ( 2 ) , <nl> + _databasePath ( ) , <nl> + _queryCacheMode ( " off " ) , <nl> + _queryCacheMaxResults ( 128 ) , <nl> + _defaultMaximalSize ( TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE ) , <nl> + _defaultWaitForSync ( false ) , <nl> + _forceSyncProperties ( true ) , <nl> + _ignoreDatafileErrors ( false ) , <nl> + _disableReplicationApplier ( false ) , <nl> + _disableQueryTracking ( false ) , <nl> + _throwCollectionNotLoadedError ( false ) , <nl> + _foxxQueues ( true ) , <nl> + _foxxQueuesPollInterval ( 1 . 0 ) , <nl> + _server ( nullptr ) , <nl> + _queryRegistry ( nullptr ) , <nl> + _pairForAqlHandler ( nullptr ) , <nl> + _pairForJobHandler ( nullptr ) , <nl> + _indexPool ( nullptr ) , <nl> + _threadAffinity ( 0 ) { <nl> + TRI_SetApplicationName ( " arangod " ) ; <nl> + <nl> + # ifndef TRI_HAVE_THREAD_AFFINITY <nl> + _threadAffinity = 0 ; <nl> + # endif <nl> + <nl> + / / set working directory and database directory <nl> + # ifdef _WIN32 <nl> + _workingDirectory = " . " ; <nl> + # else <nl> + _workingDirectory = " / var / tmp " ; <nl> + # endif <nl> + <nl> + _defaultLanguage = Utf8Helper : : DefaultUtf8Helper . getCollatorLanguage ( ) ; <nl> + <nl> + TRI_InitServerGlobals ( ) ; <nl> + <nl> + _server = new TRI_server_t ; <nl> + } <nl> + <nl> + ArangoServer : : ~ ArangoServer ( ) { <nl> + delete _indexPool ; <nl> + delete _jobManager ; <nl> + delete _server ; <nl> + <nl> + Nonce : : destroy ( ) ; <nl> + <nl> + delete _applicationServer ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief starts the server <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + int ArangoServer : : start ( ) { <nl> + if ( _applicationServer = = nullptr ) { <nl> + buildApplicationServer ( ) ; <nl> + } <nl> + <nl> + if ( _supervisorMode ) { <nl> + return startupSupervisor ( ) ; <nl> + } else if ( _daemonMode ) { <nl> + return startupDaemon ( ) ; <nl> + } else { <nl> + _applicationServer - > setupLogging ( true , false , false ) ; <nl> + <nl> + if ( ! _pidFile . empty ( ) ) { <nl> + CheckPidFile ( _pidFile ) ; <nl> + WritePidFile ( _pidFile , TRI_CurrentProcessId ( ) ) ; <nl> + } <nl> + <nl> + int res = startupServer ( ) ; <nl> + <nl> + if ( ! _pidFile . empty ( ) ) { <nl> + if ( ! FileUtils : : remove ( _pidFile ) ) { <nl> + LOG ( DEBUG ) < < " cannot remove pid file ' " < < _pidFile . c_str ( ) < < " ' " ; <nl> + } <nl> + } <nl> + <nl> + return res ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief begins shutdown sequence <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void ArangoServer : : beginShutdown ( ) { <nl> + if ( _applicationServer ! = nullptr ) { <nl> + _applicationServer - > beginShutdown ( ) ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief starts a supervisor <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + # ifdef TRI_HAVE_FORK <nl> + <nl> + int ArangoServer : : startupSupervisor ( ) { <nl> + static time_t const MIN_TIME_ALIVE_IN_SEC = 30 ; <nl> + <nl> + LOG ( INFO ) < < " starting up in supervisor mode " ; <nl> + <nl> + CheckPidFile ( _pidFile ) ; <nl> + <nl> + _applicationServer - > setupLogging ( false , true , false ) ; <nl> + <nl> + std : : string current ; <nl> + int result = ForkProcess ( _workingDirectory , current ) ; <nl> + <nl> + / / main process <nl> + if ( result ! = 0 ) { <nl> + / / wait for a few seconds for the supervisor to return <nl> + / / if it returns within a reasonable time , we can fetch its exit code <nl> + / / and report it <nl> + return WaitForSupervisor ( result ) ; <nl> + } <nl> + <nl> + / / child process <nl> + else { <nl> + setMode ( ServerMode : : MODE_SERVICE ) ; <nl> + <nl> + time_t startTime = time ( 0 ) ; <nl> + time_t t ; <nl> + bool done = false ; <nl> + result = 0 ; <nl> + <nl> + while ( ! done ) { <nl> + / / fork of the server <nl> + TRI_pid_t pid = fork ( ) ; <nl> + <nl> + if ( pid < 0 ) { <nl> + TRI_EXIT_FUNCTION ( EXIT_FAILURE , NULL ) ; <nl> + } <nl> + <nl> + / / parent <nl> + if ( 0 < pid ) { <nl> + _applicationServer - > setupLogging ( false , true , true ) ; <nl> + TRI_SetProcessTitle ( " arangodb [ supervisor ] " ) ; <nl> + LOG ( DEBUG ) < < " supervisor mode : within parent " ; <nl> + <nl> + int status ; <nl> + waitpid ( pid , & status , 0 ) ; <nl> + bool horrible = true ; <nl> + <nl> + if ( WIFEXITED ( status ) ) { <nl> + / / give information about cause of death <nl> + if ( WEXITSTATUS ( status ) = = 0 ) { <nl> + LOG ( INFO ) < < " child " < < pid < < " died of natural causes " ; <nl> + done = true ; <nl> + horrible = false ; <nl> + } else { <nl> + t = time ( 0 ) - startTime ; <nl> + <nl> + LOG ( ERR ) < < " child " < < pid <nl> + < < " died a horrible death , exit status " <nl> + < < WEXITSTATUS ( status ) ; <nl> + <nl> + if ( t < MIN_TIME_ALIVE_IN_SEC ) { <nl> + LOG ( ERR ) < < " child only survived for " < < t <nl> + < < " seconds , this will not work - please fix the error " <nl> + " first " ; <nl> + done = true ; <nl> + } else { <nl> + done = false ; <nl> + } <nl> + } <nl> + } else if ( WIFSIGNALED ( status ) ) { <nl> + switch ( WTERMSIG ( status ) ) { <nl> + case 2 : <nl> + case 9 : <nl> + case 15 : <nl> + LOG ( INFO ) < < " child " < < pid <nl> + < < " died of natural causes , exit status " <nl> + < < WTERMSIG ( status ) ; <nl> + done = true ; <nl> + horrible = false ; <nl> + break ; <nl> + <nl> + default : <nl> + t = time ( 0 ) - startTime ; <nl> + <nl> + LOG ( ERR ) < < " child " < < pid < < " died a horrible death , signal " <nl> + < < WTERMSIG ( status ) ; <nl> + <nl> + if ( t < MIN_TIME_ALIVE_IN_SEC ) { <nl> + LOG ( ERR ) < < " child only survived for " < < t <nl> + < < " seconds , this will not work - please fix the " <nl> + " error first " ; <nl> + done = true ; <nl> + <nl> + # ifdef WCOREDUMP <nl> + if ( WCOREDUMP ( status ) ) { <nl> + LOG ( WARN ) < < " child process " < < pid <nl> + < < " produced a core dump " ; <nl> + } <nl> + # endif <nl> + } else { <nl> + done = false ; <nl> + } <nl> + <nl> + break ; <nl> + } <nl> + } else { <nl> + LOG ( ERR ) < < " child " < < pid <nl> + < < " died a horrible death , unknown cause " ; <nl> + done = false ; <nl> + } <nl> + <nl> + / / remove pid file <nl> + if ( horrible ) { <nl> + if ( ! FileUtils : : remove ( _pidFile ) ) { <nl> + LOG ( DEBUG ) < < " cannot remove pid file ' " < < _pidFile . c_str ( ) < < " ' " ; <nl> + } <nl> + <nl> + result = EXIT_FAILURE ; <nl> + } <nl> + } <nl> + <nl> + / / child <nl> + else { <nl> + _applicationServer - > setupLogging ( true , false , true ) ; <nl> + LOG ( DEBUG ) < < " supervisor mode : within child " ; <nl> + <nl> + / / write the pid file <nl> + WritePidFile ( _pidFile , TRI_CurrentProcessId ( ) ) ; <nl> + <nl> + / / force child to stop if supervisor dies <nl> + # ifdef TRI_HAVE_PRCTL <nl> + prctl ( PR_SET_PDEATHSIG , SIGTERM , 0 , 0 , 0 ) ; <nl> + # endif <nl> + <nl> + / / startup server <nl> + result = startupServer ( ) ; <nl> + <nl> + / / remove pid file <nl> + if ( ! FileUtils : : remove ( _pidFile ) ) { <nl> + LOG ( DEBUG ) < < " cannot remove pid file ' " < < _pidFile . c_str ( ) < < " ' " ; <nl> + } <nl> + <nl> + / / and stop <nl> + TRI_EXIT_FUNCTION ( result , NULL ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief starts a daemon <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + int ArangoServer : : startupDaemon ( ) { <nl> + LOG ( INFO ) < < " starting up in daemon mode " ; <nl> + <nl> + CheckPidFile ( _pidFile ) ; <nl> + <nl> + _applicationServer - > setupLogging ( false , true , false ) ; <nl> + <nl> + std : : string current ; <nl> + int result = ForkProcess ( _workingDirectory , current ) ; <nl> + <nl> + / / main process <nl> + if ( result ! = 0 ) { <nl> + TRI_SetProcessTitle ( " arangodb [ daemon ] " ) ; <nl> + WritePidFile ( _pidFile , result ) ; <nl> + <nl> + / / issue # 549 : this is used as the exit code <nl> + result = 0 ; <nl> + } <nl> + <nl> + / / child process <nl> + else { <nl> + setMode ( ServerMode : : MODE_SERVICE ) ; <nl> + _applicationServer - > setupLogging ( true , false , true ) ; <nl> + LOG ( DEBUG ) < < " daemon mode : within child " ; <nl> + <nl> + / / and startup server <nl> + result = startupServer ( ) ; <nl> + <nl> + / / remove pid file <nl> + if ( ! FileUtils : : remove ( _pidFile ) ) { <nl> + LOG ( DEBUG ) < < " cannot remove pid file ' " < < _pidFile . c_str ( ) < < " ' " ; <nl> + } <nl> + } <nl> + <nl> + return result ; <nl> + } <nl> + <nl> + # else <nl> + <nl> + int ArangoServer : : startupSupervisor ( ) { return 0 ; } <nl> + <nl> + int ArangoServer : : startupDaemon ( ) { return 0 ; } <nl> + <nl> + # endif <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief converts list of size_t to string <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void ArangoServer : : defineHandlers ( HttpHandlerFactory * factory ) { <nl> <nl> / / And now some handlers which are registered in both / _api and / _admin <nl> factory - > addPrefixHandler ( <nl> - " / _api / job " , <nl> - RestHandlerCreator < arangodb : : RestJobHandler > : : createData < <nl> - std : : pair < Dispatcher * , AsyncJobManager * > * > , <nl> + " / _api / job " , RestHandlerCreator < arangodb : : RestJobHandler > : : createData < <nl> + std : : pair < Dispatcher * , AsyncJobManager * > * > , <nl> _pairForJobHandler ) ; <nl> <nl> factory - > addHandler ( " / _api / version " , <nl> void ArangoServer : : defineHandlers ( HttpHandlerFactory * factory ) { <nl> <nl> / / And now the _admin handlers <nl> factory - > addPrefixHandler ( <nl> - " / _admin / job " , <nl> - RestHandlerCreator < arangodb : : RestJobHandler > : : createData < <nl> - std : : pair < Dispatcher * , AsyncJobManager * > * > , <nl> + " / _admin / job " , RestHandlerCreator < arangodb : : RestJobHandler > : : createData < <nl> + std : : pair < Dispatcher * , AsyncJobManager * > * > , <nl> _pairForJobHandler ) ; <nl> <nl> factory - > addHandler ( " / _admin / version " , <nl> void ArangoServer : : defineHandlers ( HttpHandlerFactory * factory ) { <nl> / / further admin handlers <nl> factory - > addHandler ( <nl> " / _admin / log " , <nl> - RestHandlerCreator < arangodb : : RestAdminLogHandler > : : createNoData , <nl> - nullptr ) ; <nl> + RestHandlerCreator < arangodb : : RestAdminLogHandler > : : createNoData , nullptr ) ; <nl> <nl> - factory - > addPrefixHandler ( " / _admin / work - monitor " , <nl> - RestHandlerCreator < WorkMonitorHandler > : : createNoData , <nl> - nullptr ) ; <nl> + factory - > addPrefixHandler ( <nl> + " / _admin / work - monitor " , <nl> + RestHandlerCreator < WorkMonitorHandler > : : createNoData , nullptr ) ; <nl> <nl> / / This handler is to activate SYS_DEBUG_FAILAT on DB servers <nl> # ifdef TRI_ENABLE_FAILURE_TESTS <nl> void ArangoServer : : defineHandlers ( HttpHandlerFactory * factory ) { <nl> <nl> factory - > addPrefixHandler ( <nl> " / _admin / shutdown " , <nl> - RestHandlerCreator < arangodb : : RestShutdownHandler > : : createData < <nl> - void * > , <nl> + RestHandlerCreator < arangodb : : RestShutdownHandler > : : createData < void * > , <nl> static_cast < void * > ( _applicationServer ) ) ; <nl> } <nl> <nl> static bool SetRequestContext ( arangodb : : rest : : HttpRequest * request , <nl> return true ; <nl> } <nl> <nl> - ArangoServer : : ArangoServer ( int argc , char * * argv ) <nl> - : _argc ( argc ) , <nl> - _argv ( argv ) , <nl> - _tempPath ( ) , <nl> - _applicationScheduler ( nullptr ) , <nl> - _applicationDispatcher ( nullptr ) , <nl> - _applicationEndpointServer ( nullptr ) , <nl> - _applicationCluster ( nullptr ) , <nl> - _jobManager ( nullptr ) , <nl> - _applicationV8 ( nullptr ) , <nl> - _authenticateSystemOnly ( false ) , <nl> - _disableAuthentication ( false ) , <nl> - _disableAuthenticationUnixSockets ( false ) , <nl> - _dispatcherThreads ( 8 ) , <nl> - _dispatcherQueueSize ( 16384 ) , <nl> - _v8Contexts ( 8 ) , <nl> - _indexThreads ( 2 ) , <nl> - _databasePath ( ) , <nl> - _queryCacheMode ( " off " ) , <nl> - _queryCacheMaxResults ( 128 ) , <nl> - _defaultMaximalSize ( TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE ) , <nl> - _defaultWaitForSync ( false ) , <nl> - _forceSyncProperties ( true ) , <nl> - _ignoreDatafileErrors ( false ) , <nl> - _disableReplicationApplier ( false ) , <nl> - _disableQueryTracking ( false ) , <nl> - _throwCollectionNotLoadedError ( false ) , <nl> - _foxxQueues ( true ) , <nl> - _foxxQueuesPollInterval ( 1 . 0 ) , <nl> - _server ( nullptr ) , <nl> - _queryRegistry ( nullptr ) , <nl> - _pairForAqlHandler ( nullptr ) , <nl> - _pairForJobHandler ( nullptr ) , <nl> - _indexPool ( nullptr ) , <nl> - _threadAffinity ( 0 ) { <nl> - TRI_SetApplicationName ( " arangod " ) ; <nl> - <nl> - # ifndef TRI_HAVE_THREAD_AFFINITY <nl> - _threadAffinity = 0 ; <nl> - # endif <nl> - <nl> - / / set working directory and database directory <nl> - # ifdef _WIN32 <nl> - _workingDirectory = " . " ; <nl> - # else <nl> - _workingDirectory = " / var / tmp " ; <nl> - # endif <nl> - <nl> - _defaultLanguage = Utf8Helper : : DefaultUtf8Helper . getCollatorLanguage ( ) ; <nl> - <nl> - TRI_InitServerGlobals ( ) ; <nl> - <nl> - _server = new TRI_server_t ; <nl> - } <nl> - <nl> - ArangoServer : : ~ ArangoServer ( ) { <nl> - delete _indexPool ; <nl> - delete _jobManager ; <nl> - delete _server ; <nl> - <nl> - Nonce : : destroy ( ) ; <nl> - } <nl> - <nl> void ArangoServer : : buildApplicationServer ( ) { <nl> _applicationServer = <nl> new ApplicationServer ( " arangod " , " [ < options > ] < database - directory > " , <nl> void ArangoServer : : buildApplicationServer ( ) { <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> <nl> if ( ! _applicationServer - > parse ( _argc , _argv , additional ) ) { <nl> - LOG ( FATAL ) < < " cannot parse command line arguments " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " cannot parse command line arguments " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> / / set the temp - path <nl> void ArangoServer : : buildApplicationServer ( ) { <nl> <nl> if ( ! Utf8Helper : : DefaultUtf8Helper . setCollatorLanguage ( _defaultLanguage ) ) { <nl> char const * ICU_env = getenv ( " ICU_DATA " ) ; <nl> - LOG ( FATAL ) < < " failed to initialize ICU ; ICU_DATA = ' " < < ( ICU_env ! = nullptr ? ICU_env : " " ) < < " ' " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " failed to initialize ICU ; ICU_DATA = ' " <nl> + < < ( ICU_env ! = nullptr ? ICU_env : " " ) < < " ' " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> if ( Utf8Helper : : DefaultUtf8Helper . getCollatorCountry ( ) ! = " " ) { <nl> void ArangoServer : : buildApplicationServer ( ) { <nl> <nl> / / validate journal size <nl> if ( _defaultMaximalSize < TRI_JOURNAL_MINIMAL_SIZE ) { <nl> - LOG ( FATAL ) < < " invalid value for ' - - database . maximal - journal - size ' . expected at least " < < TRI_JOURNAL_MINIMAL_SIZE ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " invalid value for ' - - database . maximal - journal - size ' . " <nl> + " expected at least " <nl> + < < TRI_JOURNAL_MINIMAL_SIZE ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> / / validate queue size <nl> if ( _dispatcherQueueSize < = 128 ) { <nl> - LOG ( FATAL ) < < " invalid value for ` - - server . maximal - queue - size ' " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " invalid value for ` - - server . maximal - queue - size ' " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> void ArangoServer : : buildApplicationServer ( ) { <nl> std : : vector < std : : string > arguments = _applicationServer - > programArguments ( ) ; <nl> <nl> if ( 1 < arguments . size ( ) ) { <nl> - LOG ( FATAL ) < < " expected at most one database directory , got " < < arguments . size ( ) ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " expected at most one database directory , got " <nl> + < < arguments . size ( ) ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } else if ( 1 = = arguments . size ( ) ) { <nl> _databasePath = arguments [ 0 ] ; <nl> } <nl> <nl> if ( _databasePath . empty ( ) ) { <nl> LOG ( INFO ) < < " please use the ' - - database . directory ' option " ; <nl> - LOG ( FATAL ) < < " no database path has been supplied , giving up " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " no database path has been supplied , giving up " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> runStartupChecks ( ) ; <nl> void ArangoServer : : buildApplicationServer ( ) { <nl> if ( _daemonMode | | _supervisorMode ) { <nl> if ( _pidFile . empty ( ) ) { <nl> LOG ( INFO ) < < " please use the ' - - pid - file ' option " ; <nl> - LOG ( FATAL ) < < " no pid - file defined , but daemon or supervisor mode was requested " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) <nl> + < < " no pid - file defined , but daemon or supervisor mode was requested " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> OperationMode : : server_operation_mode_e mode = <nl> OperationMode : : determineMode ( _applicationServer - > programOptions ( ) ) ; <nl> if ( mode ! = OperationMode : : MODE_SERVER ) { <nl> - LOG ( FATAL ) < < " invalid mode . must not specify - - console together with - - daemon or - - supervisor " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " invalid mode . must not specify - - console together with " <nl> + " - - daemon or - - supervisor " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> / / make the pid filename absolute <nl> void ArangoServer : : buildApplicationServer ( ) { <nl> <nl> LOG ( DEBUG ) < < " using absolute pid file ' " < < _pidFile . c_str ( ) < < " ' " ; <nl> } else { <nl> - LOG ( FATAL ) < < " cannot determine current directory " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " cannot determine current directory " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> } <nl> <nl> int ArangoServer : : startupServer ( ) { <nl> if ( ! wal : : LogfileManager : : instance ( ) - > prepare ( ) | | <nl> ! wal : : LogfileManager : : instance ( ) - > start ( ) ) { <nl> / / unable to initialize & start WAL logfile manager <nl> - LOG ( FATAL ) < < " unable to start WAL logfile manager " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " unable to start WAL logfile manager " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> int ArangoServer : : startupServer ( ) { <nl> _dispatcherThreads = 1 ; <nl> } <nl> <nl> - startupProgress ( ) ; <nl> - <nl> / / open all databases <nl> bool const iterateMarkersOnOpen = <nl> ! wal : : LogfileManager : : instance ( ) - > hasFoundLastTick ( ) ; <nl> int ArangoServer : : startupServer ( ) { <nl> <nl> if ( ! checkVersion ) { <nl> if ( ! wal : : LogfileManager : : instance ( ) - > open ( ) ) { <nl> - LOG ( FATAL ) < < " Unable to finish WAL recovery procedure " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " Unable to finish WAL recovery procedure " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> } <nl> <nl> - startupProgress ( ) ; <nl> - <nl> / / fetch the system database <nl> TRI_vocbase_t * vocbase = <nl> TRI_UseDatabaseServer ( _server , TRI_VOC_SYSTEM_DATABASE ) ; <nl> <nl> if ( vocbase = = nullptr ) { <nl> - LOG ( FATAL ) < < " No _system database found in database directory . Cannot start ! " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) <nl> + < < " No _system database found in database directory . Cannot start ! " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> TRI_ASSERT ( vocbase ! = nullptr ) ; <nl> <nl> - startupProgress ( ) ; <nl> - <nl> / / initialize V8 <nl> if ( ! _applicationServer - > programOptions ( ) . has ( " javascript . v8 - contexts " ) ) { <nl> / / the option was added recently so it ' s not always set <nl> int ArangoServer : : startupServer ( ) { <nl> } <nl> } <nl> <nl> - startupProgress ( ) ; <nl> - <nl> _applicationV8 - > setVocbase ( vocbase ) ; <nl> _applicationV8 - > setConcurrency ( _v8Contexts ) ; <nl> _applicationV8 - > defineDouble ( " DISPATCHER_THREADS " , _dispatcherThreads ) ; <nl> int ArangoServer : : startupServer ( ) { <nl> / / prepare everything <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> <nl> - startupProgress ( ) ; <nl> - <nl> if ( ! startServer ) { <nl> _applicationScheduler - > disable ( ) ; <nl> _applicationDispatcher - > disable ( ) ; <nl> int ArangoServer : : startupServer ( ) { <nl> / / prepare scheduler and dispatcher <nl> _applicationServer - > prepare ( ) ; <nl> <nl> - startupProgress ( ) ; <nl> - <nl> auto const role = ServerState : : instance ( ) - > getRole ( ) ; <nl> <nl> / / now we can create the queues <nl> int ArangoServer : : startupServer ( ) { <nl> } <nl> } <nl> <nl> - startupProgress ( ) ; <nl> - <nl> / / and finish prepare <nl> _applicationServer - > prepare2 ( ) ; <nl> <nl> - startupProgress ( ) ; <nl> - <nl> / / run version check ( will exit ! ) <nl> if ( checkVersion ) { <nl> _applicationV8 - > versionCheck ( ) ; <nl> } <nl> <nl> - startupProgress ( ) ; <nl> - <nl> _applicationV8 - > upgradeDatabase ( skipUpgrade , performUpgrade ) ; <nl> <nl> - startupProgress ( ) ; <nl> - <nl> / / setup the V8 actions <nl> if ( startServer ) { <nl> _applicationV8 - > prepareServer ( ) ; <nl> } <nl> <nl> - startupProgress ( ) ; <nl> - <nl> _pairForAqlHandler = new std : : pair < ApplicationV8 * , aql : : QueryRegistry * > ( <nl> _applicationV8 , _queryRegistry ) ; <nl> _pairForJobHandler = new std : : pair < Dispatcher * , AsyncJobManager * > ( <nl> int ArangoServer : : startupServer ( ) { <nl> ( void * ) & httpOptions ) ; <nl> } <nl> <nl> - startupProgress ( ) ; <nl> - <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> / / try to figure out the thread affinity <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> int ArangoServer : : startupServer ( ) { <nl> size_t nd = _applicationDispatcher - > numberOfThreads ( ) ; <nl> <nl> if ( ns ! = 0 & & nd ! = 0 ) { <nl> - LOG ( INFO ) < < " the server has " < < n < < " ( hyper ) cores , using " < < ns < < " scheduler threads , " < < nd < < " dispatcher threads " ; <nl> + LOG ( INFO ) < < " the server has " < < n < < " ( hyper ) cores , using " < < ns <nl> + < < " scheduler threads , " < < nd < < " dispatcher threads " ; <nl> } else { <nl> _threadAffinity = 0 ; <nl> } <nl> int ArangoServer : : startupServer ( ) { <nl> } <nl> } <nl> <nl> - <nl> / / active deadlock detection in case we ' re not running in cluster mode <nl> if ( ! arangodb : : ServerState : : instance ( ) - > isRunningInCluster ( ) ) { <nl> TRI_EnableDeadlockDetectionDatabasesServer ( _server ) ; <nl> } <nl> <nl> - <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> / / start the main event loop <nl> / / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <nl> int ArangoServer : : startupServer ( ) { <nl> / / turned on , <nl> / / then we refuse to start <nl> if ( ! vocbase - > _authInfoLoaded & & ! _disableAuthentication ) { <nl> - LOG ( FATAL ) < < " could not load required authentication information " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " could not load required authentication information " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> } <nl> <nl> int ArangoServer : : startupServer ( ) { <nl> LOG ( INFO ) < < " Authentication is turned off " ; <nl> } <nl> <nl> - LOG ( INFO ) < < " ArangoDB ( version " < < TRI_VERSION_FULL < < " ) is ready for business . Have fun ! " ; <nl> - <nl> - startupFinished ( ) ; <nl> + LOG ( INFO ) < < " ArangoDB ( version " < < TRI_VERSION_FULL <nl> + < < " ) is ready for business . Have fun ! " ; <nl> <nl> int res ; <nl> <nl> int ArangoServer : : startupServer ( ) { <nl> res = runServer ( vocbase ) ; <nl> } <nl> <nl> - shutDownBegins ( ) ; <nl> - <nl> / / stop the replication appliers so all replication transactions can end <nl> TRI_StopReplicationAppliersServer ( _server ) ; <nl> <nl> int ArangoServer : : startupServer ( ) { <nl> closeDatabases ( ) ; <nl> <nl> if ( mode = = OperationMode : : MODE_CONSOLE ) { <nl> - std : : cout < < std : : endl <nl> - < < TRI_BYE_MESSAGE < < std : : endl ; <nl> + std : : cout < < std : : endl < < TRI_BYE_MESSAGE < < std : : endl ; <nl> } <nl> <nl> TRI_ShutdownStatistics ( ) ; <nl> void ArangoServer : : runStartupChecks ( ) { <nl> int64_t alignment = <nl> std : : stol ( std : : string ( cpuAlignment . c_str ( ) + start , end - start ) ) ; <nl> if ( ( alignment & 2 ) = = 0 ) { <nl> - LOG ( FATAL ) < < " possibly incompatible CPU alignment settings found in ' " < < filename . c_str ( ) < < " ' . this may cause arangod to abort with SIGBUS . please set the value in ' " < < filename . c_str ( ) < < " ' to 2 " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) <nl> + < < " possibly incompatible CPU alignment settings found in ' " <nl> + < < filename . c_str ( ) < < " ' . this may cause arangod to abort with " <nl> + " SIGBUS . please set the value in ' " <nl> + < < filename . c_str ( ) < < " ' to 2 " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> alignmentDetected = true ; <nl> void ArangoServer : : runStartupChecks ( ) { <nl> <nl> } catch ( . . . ) { <nl> / / ignore that we cannot detect the alignment <nl> - LOG ( TRACE ) < < " unable to detect CPU alignment settings . could not process file ' " < < filename . c_str ( ) < < " ' " ; <nl> + LOG ( TRACE ) <nl> + < < " unable to detect CPU alignment settings . could not process file ' " <nl> + < < filename . c_str ( ) < < " ' " ; <nl> } <nl> <nl> if ( ! alignmentDetected ) { <nl> - LOG ( WARN ) < < " unable to detect CPU alignment settings . could not process file ' " < < filename . c_str ( ) < < " ' . this may cause arangod to abort with SIGBUS . it may be necessary to set the value in ' " < < filename . c_str ( ) < < " ' to 2 " ; <nl> + LOG ( WARN ) <nl> + < < " unable to detect CPU alignment settings . could not process file ' " <nl> + < < filename . c_str ( ) <nl> + < < " ' . this may cause arangod to abort with SIGBUS . it may be " <nl> + " necessary to set the value in ' " <nl> + < < filename . c_str ( ) < < " ' to 2 " ; <nl> } <nl> } <nl> # endif <nl> int ArangoServer : : runUnitTests ( TRI_vocbase_t * vocbase ) { <nl> localContext - > Global ( ) - > Set ( TRI_V8_ASCII_STRING ( " SYS_UNIT_TESTS_RESULT " ) , <nl> v8 : : True ( isolate ) ) ; <nl> <nl> - v8 : : Local < v8 : : String > name ( TRI_V8_ASCII_STRING ( TRI_V8_SHELL_COMMAND_NAME ) ) ; <nl> + v8 : : Local < v8 : : String > name ( <nl> + TRI_V8_ASCII_STRING ( TRI_V8_SHELL_COMMAND_NAME ) ) ; <nl> <nl> / / run tests <nl> auto input = TRI_V8_ASCII_STRING ( <nl> int ArangoServer : : runScript ( TRI_vocbase_t * vocbase ) { <nl> TRI_ExecuteGlobalJavaScriptFile ( isolate , _scriptFile [ i ] . c_str ( ) ) ; <nl> <nl> if ( ! r ) { <nl> - LOG ( FATAL ) < < " cannot load script ' " < < _scriptFile [ i ] . c_str ( ) < < " ' , giving up " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " cannot load script ' " < < _scriptFile [ i ] . c_str ( ) <nl> + < < " ' , giving up " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> } <nl> <nl> int ArangoServer : : runScript ( TRI_vocbase_t * vocbase ) { <nl> localContext - > Global ( ) - > Get ( mainFuncName ) ) ; <nl> <nl> if ( main . IsEmpty ( ) | | main - > IsUndefined ( ) ) { <nl> - LOG ( FATAL ) < < " no main function defined , giving up " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " no main function defined , giving up " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } else { <nl> v8 : : Handle < v8 : : Value > args [ ] = { params } ; <nl> <nl> int ArangoServer : : runScript ( TRI_vocbase_t * vocbase ) { <nl> ok = TRI_ObjectToDouble ( result ) = = 0 ; <nl> } <nl> } catch ( arangodb : : basics : : Exception const & ex ) { <nl> - LOG ( ERR ) < < " caught exception " < < TRI_errno_string ( ex . code ( ) ) < < " : " < < ex . what ( ) ; <nl> + LOG ( ERR ) < < " caught exception " < < TRI_errno_string ( ex . code ( ) ) < < " : " <nl> + < < ex . what ( ) ; <nl> ok = false ; <nl> } catch ( std : : bad_alloc const & ) { <nl> - LOG ( ERR ) < < " caught exception " < < TRI_errno_string ( TRI_ERROR_OUT_OF_MEMORY ) ; <nl> + LOG ( ERR ) < < " caught exception " <nl> + < < TRI_errno_string ( TRI_ERROR_OUT_OF_MEMORY ) ; <nl> ok = false ; <nl> } catch ( . . . ) { <nl> LOG ( ERR ) < < " caught unknown exception " ; <nl> void ArangoServer : : openDatabases ( bool checkVersion , bool performUpgrade , <nl> _disableReplicationApplier , iterateMarkersOnOpen ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - LOG ( FATAL ) < < " cannot create server instance : out of memory " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " cannot create server instance : out of memory " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> res = TRI_StartServer ( _server , checkVersion , performUpgrade ) ; <nl> void ArangoServer : : openDatabases ( bool checkVersion , bool performUpgrade , <nl> TRI_EXIT_FUNCTION ( EXIT_SUCCESS , nullptr ) ; <nl> } <nl> <nl> - LOG ( FATAL ) < < " cannot start server : " < < TRI_errno_string ( res ) ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " cannot start server : " < < TRI_errno_string ( res ) ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> LOG ( TRACE ) < < " found system database " ; <nl> mmm a / arangod / RestServer / ArangoServer . h <nl> ppp b / arangod / RestServer / ArangoServer . h <nl> <nl> # endif <nl> <nl> # include " Aql / QueryRegistry . h " <nl> - # include " Rest / AnyServer . h " <nl> # include " Rest / OperationMode . h " <nl> # include " VocBase / vocbase . h " <nl> <nl> class ApplicationCluster ; <nl> / / / @ brief ArangoDB server <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - class ArangoServer : public rest : : AnyServer { <nl> - private : <nl> - ArangoServer ( const ArangoServer & ) ; <nl> - ArangoServer & operator = ( const ArangoServer & ) ; <nl> + class ArangoServer { <nl> + ArangoServer ( const ArangoServer & ) = delete ; <nl> + ArangoServer & operator = ( const ArangoServer & ) = delete ; <nl> <nl> public : <nl> ArangoServer ( int , char * * ) ; <nl> class ArangoServer : public rest : : AnyServer { <nl> ~ ArangoServer ( ) ; <nl> <nl> public : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief enumeration for server modes <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + enum class ServerMode { MODE_STANDALONE , MODE_SERVICE } ; <nl> + <nl> + public : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief starts the server <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + int start ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief begins shutdown sequence <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void beginShutdown ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief set the server mode <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void setMode ( ServerMode mode ) { _mode = mode ; } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief get the server mode as a string <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + char const * modeString ( ) const { <nl> + if ( _mode = = ServerMode : : MODE_STANDALONE ) { <nl> + return " standalone " ; <nl> + } <nl> + <nl> + TRI_ASSERT ( _mode = = ServerMode : : MODE_SERVICE ) ; <nl> + return " service " ; <nl> + } <nl> + <nl> + protected : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief builds the application server <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> void buildApplicationServer ( ) ; <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief start the server using the description <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> int startupServer ( ) ; <nl> <nl> + protected : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief the server mode <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + ServerMode _mode ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief running in daemon mode <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool _daemonMode ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief running in supervisor mode <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + bool _supervisorMode ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief was docuBlock pidFile <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + std : : string _pidFile ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief working directory <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + std : : string _workingDirectory ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief application server <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + rest : : ApplicationServer * _applicationServer ; <nl> + <nl> + private : <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief starts a supervisor <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + int startupSupervisor ( ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief starts a daemon <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + int startupDaemon ( ) ; <nl> + <nl> private : <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief run arbitrary checks at startup <nl> mmm a / arangod / RestServer / arangod . cpp <nl> ppp b / arangod / RestServer / arangod . cpp <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> # include " Basics / Common . h " <nl> + <nl> # include " Rest / InitializeRest . h " <nl> # include " RestServer / ArangoServer . h " <nl> # include < signal . h > <nl> using namespace arangodb : : rest ; <nl> / / / @ brief ArangoDB server <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - AnyServer * ArangoInstance = nullptr ; <nl> + ArangoServer * ArangoInstance = nullptr ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief Hooks for OS - Specific functions <nl> mmm a / arangosh / Benchmark / arangob . cpp <nl> ppp b / arangosh / Benchmark / arangob . cpp <nl> <nl> # include " Basics / ProgramOptionsDescription . h " <nl> # include " Basics / StringBuffer . h " <nl> # include " Basics / StringUtils . h " <nl> - # include " Basics / init . h " <nl> # include " Basics / random . h " <nl> # include " Basics / terminal - utils . h " <nl> # include " Basics / tri - strings . h " <nl> int main ( int argc , char * argv [ ] ) { <nl> <nl> arangobEntryFunction ( ) ; <nl> <nl> - TRIAGENS_C_INITIALIZE ( argc , argv ) ; <nl> TRIAGENS_REST_INITIALIZE ( argc , argv ) ; <nl> <nl> Logger : : initialize ( false ) ; <nl> int main ( int argc , char * argv [ ] ) { <nl> <nl> if ( BaseClient . endpointServer ( ) = = nullptr ) { <nl> std : : string endpointString = BaseClient . endpointString ( ) ; <nl> - LOG ( FATAL ) < < " invalid value for - - server . endpoint ( ' " < < endpointString . c_str ( ) < < " ' ) " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " invalid value for - - server . endpoint ( ' " <nl> + < < endpointString . c_str ( ) < < " ' ) " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> } <nl> <nl> BenchmarkOperation * testCase = GetTestCase ( TestCase ) ; <nl> <nl> if ( testCase = = nullptr ) { <nl> - LOG ( FATAL ) < < " invalid test case name ' " < < TestCase . c_str ( ) < < " ' " ; FATAL_ERROR_EXIT ( ) ; <nl> + LOG ( FATAL ) < < " invalid test case name ' " < < TestCase . c_str ( ) < < " ' " ; <nl> + FATAL_ERROR_EXIT ( ) ; <nl> return EXIT_FAILURE ; / / will not be reached <nl> } <nl> <nl> mmm a / arangosh / V8Client / arangodump . cpp <nl> ppp b / arangosh / V8Client / arangodump . cpp <nl> <nl> # include " Basics / VelocyPackHelper . h " <nl> # include " Basics / VelocyPackHelper . h " <nl> # include " Basics / files . h " <nl> - # include " Basics / init . h " <nl> # include " Basics / terminal - utils . h " <nl> # include " Basics / tri - strings . h " <nl> # include " Rest / Endpoint . h " <nl> int main ( int argc , char * argv [ ] ) { <nl> <nl> LocalEntryFunction ( ) ; <nl> <nl> - TRIAGENS_C_INITIALIZE ( argc , argv ) ; <nl> TRIAGENS_REST_INITIALIZE ( argc , argv ) ; <nl> <nl> Logger : : initialize ( false ) ; <nl> mmm a / arangosh / V8Client / arangoimp . cpp <nl> ppp b / arangosh / V8Client / arangoimp . cpp <nl> <nl> # include " Basics / ProgramOptions . h " <nl> # include " Basics / ProgramOptionsDescription . h " <nl> # include " Basics / files . h " <nl> - # include " Basics / init . h " <nl> # include " Basics / terminal - utils . h " <nl> # include " Basics / tri - strings . h " <nl> # include " Rest / Endpoint . h " <nl> int main ( int argc , char * argv [ ] ) { <nl> <nl> LocalEntryFunction ( ) ; <nl> <nl> - TRIAGENS_C_INITIALIZE ( argc , argv ) ; <nl> TRIAGENS_REST_INITIALIZE ( argc , argv ) ; <nl> <nl> Logger : : initialize ( false ) ; <nl> mmm a / arangosh / V8Client / arangorestore . cpp <nl> ppp b / arangosh / V8Client / arangorestore . cpp <nl> <nl> # include " Basics / StringUtils . h " <nl> # include " Basics / VelocyPackHelper . h " <nl> # include " Basics / files . h " <nl> - # include " Basics / init . h " <nl> # include " Basics / terminal - utils . h " <nl> # include " Basics / tri - strings . h " <nl> # include " Rest / Endpoint . h " <nl> int main ( int argc , char * argv [ ] ) { <nl> <nl> LocalEntryFunction ( ) ; <nl> <nl> - TRIAGENS_C_INITIALIZE ( argc , argv ) ; <nl> TRIAGENS_REST_INITIALIZE ( argc , argv ) ; <nl> <nl> Logger : : initialize ( false ) ; <nl> mmm a / arangosh / V8Client / arangosh . cpp <nl> ppp b / arangosh / V8Client / arangosh . cpp <nl> <nl> # include " Basics / StringUtils . h " <nl> # include " Basics / Utf8Helper . h " <nl> # include " Basics / files . h " <nl> - # include " Basics / init . h " <nl> # include " Basics / messages . h " <nl> # include " Basics / shell - colors . h " <nl> # include " Basics / terminal - utils . h " <nl> int main ( int argc , char * args [ ] ) { <nl> # endif <nl> LocalEntryFunction ( ) ; <nl> <nl> - TRIAGENS_C_INITIALIZE ( argc , args ) ; <nl> TRIAGENS_REST_INITIALIZE ( argc , args ) ; <nl> <nl> Logger : : initialize ( false ) ; <nl> deleted file mode 100644 <nl> index 37bf291ddb2 . . 00000000000 <nl> mmm a / lib / Basics / InitializeBasics . cpp <nl> ppp / dev / null <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / DISCLAIMER <nl> - / / / <nl> - / / / Copyright 2014 - 2016 ArangoDB GmbH , Cologne , Germany <nl> - / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> - / / / <nl> - / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - / / / you may not use this file except in compliance with the License . <nl> - / / / You may obtain a copy of the License at <nl> - / / / <nl> - / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - / / / <nl> - / / / Unless required by applicable law or agreed to in writing , software <nl> - / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> - / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - / / / See the License for the specific language governing permissions and <nl> - / / / limitations under the License . <nl> - / / / <nl> - / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> - / / / <nl> - / / / @ author Dr . Frank Celler <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # include " InitializeBasics . h " <nl> - # include " Basics / init . h " <nl> - # include " Basics / error . h " <nl> - # include " Basics / hashes . h " <nl> - # include " Basics / random . h " <nl> - # include " Basics / RandomGenerator . h " <nl> - <nl> - namespace arangodb { <nl> - namespace basics { <nl> - void InitializeBasics ( int argv , char * argc [ ] ) { <nl> - TRIAGENS_C_INITIALIZE ( argv , argc ) ; <nl> - <nl> - / / use the rng so the linker does not remove it from the executable <nl> - / / we might need it later because . so files might refer to the symbols <nl> - Random : : random_e v = Random : : selectVersion ( Random : : RAND_MERSENNE ) ; <nl> - Random : : UniformInteger random ( 0 , INT32_MAX ) ; <nl> - random . random ( ) ; <nl> - Random : : selectVersion ( v ) ; <nl> - <nl> - # ifdef TRI_BROKEN_CXA_GUARD <nl> - pthread_cond_t cond ; <nl> - pthread_cond_init ( & cond , 0 ) ; <nl> - pthread_cond_broadcast ( & cond ) ; <nl> - # endif <nl> - } <nl> - <nl> - void ShutdownBasics ( ) { TRIAGENS_C_SHUTDOWN ; } <nl> - } <nl> - } <nl> deleted file mode 100644 <nl> index cc39618f13d . . 00000000000 <nl> mmm a / lib / Basics / InitializeBasics . h <nl> ppp / dev / null <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / DISCLAIMER <nl> - / / / <nl> - / / / Copyright 2014 - 2016 ArangoDB GmbH , Cologne , Germany <nl> - / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> - / / / <nl> - / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - / / / you may not use this file except in compliance with the License . <nl> - / / / You may obtain a copy of the License at <nl> - / / / <nl> - / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - / / / <nl> - / / / Unless required by applicable law or agreed to in writing , software <nl> - / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> - / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - / / / See the License for the specific language governing permissions and <nl> - / / / limitations under the License . <nl> - / / / <nl> - / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> - / / / <nl> - / / / @ author Dr . Frank Celler <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # ifndef LIB_BASICS_INITIALIZE_BASICS_H <nl> - # define LIB_BASICS_INITIALIZE_BASICS_H 1 <nl> - <nl> - # include " Basics / Common . h " <nl> - <nl> - namespace arangodb { <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief the namespace containing the basic classes and functions <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - namespace basics { <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief initialize function <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - extern void InitializeBasics ( int argv , char * argc [ ] ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief shutdown function <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - extern void ShutdownBasics ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief initialize <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # define TRIAGENS_BASICS_INITIALIZE ( a , b ) \ <nl> - do { \ <nl> - arangodb : : basics : : InitializeBasics ( ( a ) , ( b ) ) ; \ <nl> - } while ( 0 ) <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief shutdown <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # define TRIAGENS_BASICS_SHUTDOWN \ <nl> - do { \ <nl> - arangodb : : basics : : ShutdownBasics ( ) ; \ <nl> - } while ( 0 ) <nl> - <nl> - # endif <nl> deleted file mode 100644 <nl> index 194e7910e55 . . 00000000000 <nl> mmm a / lib / Basics / init . cpp <nl> ppp / dev / null <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / DISCLAIMER <nl> - / / / <nl> - / / / Copyright 2014 - 2016 ArangoDB GmbH , Cologne , Germany <nl> - / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> - / / / <nl> - / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - / / / you may not use this file except in compliance with the License . <nl> - / / / You may obtain a copy of the License at <nl> - / / / <nl> - / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - / / / <nl> - / / / Unless required by applicable law or agreed to in writing , software <nl> - / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> - / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - / / / See the License for the specific language governing permissions and <nl> - / / / limitations under the License . <nl> - / / / <nl> - / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> - / / / <nl> - / / / @ author Dr . Frank Celler <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # include " init . h " <nl> - <nl> - # include " Basics / Logger . h " <nl> - # include " Basics / files . h " <nl> - # include " Basics / hashes . h " <nl> - # include " Basics / mimetypes . h " <nl> - # include " Basics / process - utils . h " <nl> - # include " Basics / random . h " <nl> - <nl> - using namespace arangodb ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief initialize function <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void TRI_InitializeC ( int argc , char * argv [ ] ) { <nl> - TRI_InitializeMemory ( ) ; <nl> - TRI_InitializeDebugging ( ) ; <nl> - TRI_InitializeError ( ) ; <nl> - TRI_InitializeFiles ( ) ; <nl> - TRI_InitializeMimetypes ( ) ; <nl> - Logger : : initialize ( false ) ; <nl> - TRI_InitializeHashes ( ) ; <nl> - TRI_InitializeRandom ( ) ; <nl> - TRI_InitializeProcess ( argc , argv ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief shutdown function <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void TRI_ShutdownC ( ) { <nl> - TRI_ShutdownProcess ( ) ; <nl> - TRI_ShutdownRandom ( ) ; <nl> - TRI_ShutdownHashes ( ) ; <nl> - Logger : : shutdown ( true ) ; <nl> - TRI_ShutdownMimetypes ( ) ; <nl> - TRI_ShutdownFiles ( ) ; <nl> - TRI_ShutdownError ( ) ; <nl> - TRI_ShutdownDebugging ( ) ; <nl> - TRI_ShutdownMemory ( ) ; <nl> - } <nl> deleted file mode 100644 <nl> index b8458e4d7b3 . . 00000000000 <nl> mmm a / lib / Basics / init . h <nl> ppp / dev / null <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / DISCLAIMER <nl> - / / / <nl> - / / / Copyright 2014 - 2016 ArangoDB GmbH , Cologne , Germany <nl> - / / / Copyright 2004 - 2014 triAGENS GmbH , Cologne , Germany <nl> - / / / <nl> - / / / Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> - / / / you may not use this file except in compliance with the License . <nl> - / / / You may obtain a copy of the License at <nl> - / / / <nl> - / / / http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> - / / / <nl> - / / / Unless required by applicable law or agreed to in writing , software <nl> - / / / distributed under the License is distributed on an " AS IS " BASIS , <nl> - / / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> - / / / See the License for the specific language governing permissions and <nl> - / / / limitations under the License . <nl> - / / / <nl> - / / / Copyright holder is ArangoDB GmbH , Cologne , Germany <nl> - / / / <nl> - / / / @ author Dr . Frank Celler <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # ifndef LIB_BASICS_INIT_H <nl> - # define LIB_BASICS_INIT_H 1 <nl> - <nl> - # include " Basics / Common . h " <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief initialize function <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void TRI_InitializeC ( int argc , char * argv [ ] ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief shutdown function <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void TRI_ShutdownC ( void ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief initialize <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # define TRIAGENS_C_INITIALIZE ( a , b ) \ <nl> - do { \ <nl> - TRI_InitializeC ( ( a ) , ( b ) ) ; \ <nl> - } while ( 0 ) <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief shutdown <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # define TRIAGENS_C_SHUTDOWN \ <nl> - do { \ <nl> - TRI_ShutdownC ( ) ; \ <nl> - } while ( 0 ) <nl> - <nl> - # endif <nl> mmm a / lib / Rest / InitializeRest . cpp <nl> ppp b / lib / Rest / InitializeRest . cpp <nl> <nl> # error missing thread support for openssl , please recomple OpenSSL with threads <nl> # endif <nl> <nl> + # include " Basics / Logger . h " <nl> + # include " Basics / RandomGenerator . h " <nl> + # include " Basics / error . h " <nl> + # include " Basics / files . h " <nl> + # include " Basics / hashes . h " <nl> # include " Basics / locks . h " <nl> - # include " Basics / InitializeBasics . h " <nl> + # include " Basics / mimetypes . h " <nl> + # include " Basics / process - utils . h " <nl> + # include " Basics / random . h " <nl> # include " Basics / threads . h " <nl> # include " Rest / Version . h " <nl> <nl> void opensslCleanup ( ) { <nl> } <nl> } <nl> <nl> + using namespace arangodb : : basics ; <nl> + <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / initialization <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> void opensslCleanup ( ) { <nl> namespace arangodb { <nl> namespace rest { <nl> void InitializeRest ( int argc , char * argv [ ] ) { <nl> - TRIAGENS_BASICS_INITIALIZE ( argc , argv ) ; <nl> + TRI_InitializeMemory ( ) ; <nl> + TRI_InitializeDebugging ( ) ; <nl> + TRI_InitializeError ( ) ; <nl> + TRI_InitializeFiles ( ) ; <nl> + TRI_InitializeMimetypes ( ) ; <nl> + Logger : : initialize ( false ) ; <nl> + TRI_InitializeHashes ( ) ; <nl> + TRI_InitializeRandom ( ) ; <nl> + TRI_InitializeProcess ( argc , argv ) ; <nl> + <nl> + / / use the rng so the linker does not remove it from the executable <nl> + / / we might need it later because . so files might refer to the symbols <nl> + Random : : random_e v = Random : : selectVersion ( Random : : RAND_MERSENNE ) ; <nl> + Random : : UniformInteger random ( 0 , INT32_MAX ) ; <nl> + random . random ( ) ; <nl> + Random : : selectVersion ( v ) ; <nl> + <nl> + # ifdef TRI_BROKEN_CXA_GUARD <nl> + pthread_cond_t cond ; <nl> + pthread_cond_init ( & cond , 0 ) ; <nl> + pthread_cond_broadcast ( & cond ) ; <nl> + # endif <nl> <nl> SSL_library_init ( ) ; <nl> SSL_load_error_strings ( ) ; <nl> void ShutdownRest ( ) { <nl> EVP_cleanup ( ) ; <nl> CRYPTO_cleanup_all_ex_data ( ) ; <nl> <nl> - TRIAGENS_BASICS_SHUTDOWN ; <nl> + TRI_ShutdownProcess ( ) ; <nl> + TRI_ShutdownRandom ( ) ; <nl> + TRI_ShutdownHashes ( ) ; <nl> + Logger : : shutdown ( true ) ; <nl> + TRI_ShutdownMimetypes ( ) ; <nl> + TRI_ShutdownFiles ( ) ; <nl> + TRI_ShutdownError ( ) ; <nl> + TRI_ShutdownDebugging ( ) ; <nl> + TRI_ShutdownMemory ( ) ; <nl> } <nl> } <nl> } <nl>
|
simplified init
|
arangodb/arangodb
|
6fa4e319bbb6546d8f1ff4bf57bfb49b047cc480
|
2016-02-23T14:26:22Z
|
mmm a / xbmc / utils / Variant . cpp <nl> ppp b / xbmc / utils / Variant . cpp <nl> <nl> # include " PlatformDefs . h " <nl> # include < string . h > <nl> # include " json / value . h " <nl> - # include " ISerializable . h " <nl> <nl> using namespace std ; <nl> <nl> CVariant : : CVariant ( const CVariant & variant ) <nl> * this = variant ; <nl> } <nl> <nl> - CVariant : : CVariant ( ISerializable & serializable ) <nl> - { <nl> - * this = serializable ; <nl> - } <nl> - <nl> CVariant : : ~ CVariant ( ) <nl> { <nl> if ( isString ( ) & & m_data . string ) <nl> CVariant & CVariant : : operator = ( const CVariant & rhs ) <nl> return * this ; <nl> } <nl> <nl> - CVariant & CVariant : : operator = ( ISerializable & rhs ) <nl> - { <nl> - rhs . Serialize ( * this ) ; <nl> - return * this ; <nl> - } <nl> - <nl> void CVariant : : push_back ( CVariant variant ) <nl> { <nl> if ( m_type = = VariantTypeNull ) <nl> mmm a / xbmc / utils / Variant . h <nl> ppp b / xbmc / utils / Variant . h <nl> namespace Json <nl> class Value ; <nl> } <nl> <nl> - class ISerializable ; <nl> - <nl> class CVariant <nl> { <nl> public : <nl> class CVariant <nl> CVariant ( const char * str ) ; <nl> CVariant ( const std : : string & str ) ; <nl> CVariant ( const CVariant & variant ) ; <nl> - CVariant ( ISerializable & serializable ) ; <nl> <nl> ~ CVariant ( ) ; <nl> <nl> class CVariant <nl> CVariant & operator [ ] ( unsigned int position ) ; <nl> <nl> CVariant & operator = ( const CVariant & rhs ) ; <nl> - CVariant & operator = ( ISerializable & rhs ) ; <nl> <nl> void push_back ( CVariant variant ) ; <nl> <nl>
|
Removed Serializeable dependency in Variant
|
xbmc/xbmc
|
ca1b99f64a99507189b8401a17e1dc8d0534927b
|
2010-11-20T19:28:38Z
|
mmm a / bindings / python / cntk / io / __init__ . py <nl> ppp b / bindings / python / cntk / io / __init__ . py <nl> def __getitem__ ( self , name ) : <nl> <nl> @ typemap <nl> def next_minibatch ( self , minibatch_size_in_samples , <nl> - input_map = None , device = None ) : <nl> + input_map = None , device = None , num_data_partitions = None , partition_index = None ) : <nl> ' ' ' <nl> Reads a minibatch that contains data for all input streams . The <nl> minibatch size is specified in terms of # samples and / or # sequences for the <nl> def next_minibatch ( self , minibatch_size_in_samples , <nl> to : class : ` StreamInformation ` which will be used to convert the <nl> returned data . <nl> device ( ` DeviceDescriptor ` , defaults to ` None ` ) : CNTK DeviceDescriptor <nl> + num_data_partitions : Used for distributed training , indicates into how many partitions <nl> + the source should split the data . <nl> + partition_index : Used for distributed training , indicates data from which partition to take . <nl> <nl> Returns : <nl> - A mapping of : class : ` StramInformation ` to : class : ` MinibatchData ` if <nl> + a mapping of : class : ` StreamInformation ` to : class : ` MinibatchData ` if <nl> ` ` input_map ` ` was not specified . Otherwise , the returned value will <nl> - be a mapping of : class : ` ~ cntk . ops . variabls . Variable ` to class : ` MinibatchData ` . <nl> + be a mapping of : class : ` ~ cntk . ops . variables . Variable ` to class : ` MinibatchData ` . <nl> ' ' ' <nl> if device is None : <nl> device = use_default_device ( ) <nl> <nl> - mb = super ( MinibatchSource , self ) . get_next_minibatch ( <nl> - minibatch_size_in_samples , device ) <nl> + if num_data_partitions is None : <nl> + num_data_partitions = 1 <nl> + <nl> + if partition_index is None : <nl> + partition_index = 0 <nl> + <nl> + mb = super ( MinibatchSource , self ) . get_next_minibatch ( 0 , <nl> + minibatch_size_in_samples , num_data_partitions , partition_index , device ) <nl> <nl> if input_map : <nl> if not mb : <nl> mmm a / bindings / python / cntk / tests / distributed_test . py <nl> ppp b / bindings / python / cntk / tests / distributed_test . py <nl> def run_distributed_training ( tmpdir , create_func ) : <nl> assert isinstance ( trainer . model , Function ) <nl> assert trainer . model . __doc__ <nl> <nl> + <nl> + def test_distributed_mb_source ( tmpdir ) : <nl> + input_dim = 69 <nl> + <nl> + ctf_data = ' ' ' \ <nl> + 0 | S0 3 : 1 | # < s > | S1 3 : 1 | # < s > <nl> + 0 | S0 4 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + 0 | S0 5 : 1 | # B | S1 36 : 1 | # ~ B <nl> + 0 | S0 4 : 1 | # A | S1 31 : 1 | # ~ AE <nl> + 0 | S0 7 : 1 | # D | S1 38 : 1 | # ~ D <nl> + 0 | S0 12 : 1 | # I | S1 47 : 1 | # ~ IY <nl> + 0 | S0 1 : 1 | # < / s > | S1 1 : 1 | # < / s > <nl> + 2 | S0 60 : 1 | # < s > | S1 3 : 1 | # < s > <nl> + 2 | S0 61 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + 2 | S0 61 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + 3 | S0 60 : 1 | # < s > | S1 3 : 1 | # < s > <nl> + 3 | S0 61 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + 3 | S0 61 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + 3 | S0 61 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + 4 | S0 60 : 1 | # < s > | S1 3 : 1 | # < s > <nl> + 5 | S0 60 : 1 | # < s > | S1 3 : 1 | # < s > <nl> + 5 | S0 61 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + 6 | S0 60 : 1 | # < s > | S1 3 : 1 | # < s > <nl> + 6 | S0 61 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + 7 | S0 60 : 1 | # < s > | S1 3 : 1 | # < s > <nl> + 8 | S0 60 : 1 | # < s > | S1 3 : 1 | # < s > <nl> + 8 | S0 61 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + 9 | S0 60 : 1 | # < s > | S1 3 : 1 | # < s > <nl> + 9 | S0 61 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + 10 | S0 61 : 1 | # A | S1 32 : 1 | # ~ AH <nl> + ' ' ' <nl> + from cntk . io import MinibatchSource , CTFDeserializer , StreamDef , StreamDefs , FULL_DATA_SWEEP <nl> + <nl> + ctf_file = str ( tmpdir / ' 2seqtest . txt ' ) <nl> + with open ( ctf_file , ' w ' ) as f : <nl> + f . write ( ctf_data ) <nl> + <nl> + # No randomization <nl> + <nl> + mb0 = MinibatchSource ( CTFDeserializer ( ctf_file , StreamDefs ( <nl> + features = StreamDef ( field = ' S0 ' , shape = input_dim , is_sparse = True ) , <nl> + labels = StreamDef ( field = ' S1 ' , shape = input_dim , is_sparse = True ) <nl> + ) ) , <nl> + randomize = False , epoch_size = FULL_DATA_SWEEP ) <nl> + mb1 = MinibatchSource ( CTFDeserializer ( ctf_file , StreamDefs ( <nl> + features = StreamDef ( field = ' S0 ' , shape = input_dim , is_sparse = True ) , <nl> + labels = StreamDef ( field = ' S1 ' , shape = input_dim , is_sparse = True ) <nl> + ) ) , <nl> + randomize = False , epoch_size = FULL_DATA_SWEEP ) <nl> + input = input_variable ( shape = ( input_dim , ) ) <nl> + label = input_variable ( shape = ( input_dim , ) ) <nl> + input_map = { <nl> + input : mb0 . streams . features , <nl> + label : mb0 . streams . labels <nl> + } <nl> + <nl> + data = mb0 . next_minibatch ( minibatch_size_in_samples = 10 , input_map = input_map , num_data_partitions = 2 , partition_index = 0 ) <nl> + assert ( data [ input ] . num_samples = = 7 ) <nl> + <nl> + data = mb0 . next_minibatch ( minibatch_size_in_samples = 10 , input_map = input_map , num_data_partitions = 2 , partition_index = 0 ) <nl> + assert ( data [ input ] . num_samples = = 4 ) <nl> + <nl> + data = mb0 . next_minibatch ( minibatch_size_in_samples = 10 , input_map = input_map , num_data_partitions = 2 , partition_index = 0 ) <nl> + assert ( data [ input ] . num_samples = = 5 ) <nl> + <nl> + data = mb1 . next_minibatch ( minibatch_size_in_samples = 10 , input_map = input_map , num_data_partitions = 2 , partition_index = 1 ) <nl> + assert ( data [ input ] . num_samples = = 3 ) <nl> + <nl> + data = mb1 . next_minibatch ( minibatch_size_in_samples = 10 , input_map = input_map , num_data_partitions = 2 , partition_index = 1 ) <nl> + assert ( data [ input ] . num_samples = = 5 ) <nl> + <nl> + # Radomization <nl> + <nl> + mb3 = MinibatchSource ( CTFDeserializer ( ctf_file , StreamDefs ( <nl> + features = StreamDef ( field = ' S0 ' , shape = input_dim , is_sparse = True ) , <nl> + labels = StreamDef ( field = ' S1 ' , shape = input_dim , is_sparse = True ) <nl> + ) ) , <nl> + randomize = True , epoch_size = FULL_DATA_SWEEP ) <nl> + <nl> + mb4 = MinibatchSource ( CTFDeserializer ( ctf_file , StreamDefs ( <nl> + features = StreamDef ( field = ' S0 ' , shape = input_dim , is_sparse = True ) , <nl> + labels = StreamDef ( field = ' S1 ' , shape = input_dim , is_sparse = True ) <nl> + ) ) , <nl> + randomize = True , epoch_size = FULL_DATA_SWEEP ) <nl> + <nl> + data = mb3 . next_minibatch ( minibatch_size_in_samples = 10 , input_map = input_map , num_data_partitions = 2 , partition_index = 0 ) <nl> + assert ( data [ input ] . num_samples = = 5 ) <nl> + <nl> + data = mb3 . next_minibatch ( minibatch_size_in_samples = 10 , input_map = input_map , num_data_partitions = 2 , partition_index = 0 ) <nl> + assert ( data [ input ] . num_samples = = 4 ) <nl> + <nl> + data = mb4 . next_minibatch ( minibatch_size_in_samples = 10 , input_map = input_map , num_data_partitions = 2 , partition_index = 1 ) <nl> + assert ( len ( data ) = = 0 ) <nl> + <nl> + <nl> def test_distributed ( tmpdir , is_1bit_sgd ) : <nl> quantized = ( True if is_1bit_sgd = = 1 else False ) <nl> <nl>
|
Allow splitting of data in get next minibatch
|
microsoft/CNTK
|
a6c74a28d8e734de7d9c5e916ae51ea70deed9df
|
2017-02-03T11:36:17Z
|
mmm a / hphp / hack / test / integration_ml / dune <nl> ppp b / hphp / hack / test / integration_ml / dune <nl> <nl> server_command_types <nl> server_env <nl> test_injector_config ) ) <nl> + <nl> + ( executable <nl> + ( name test_coverage_counts ) <nl> + ( modules test_coverage_counts ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name coverage_counts ) <nl> + ( deps test_coverage_counts . exe ) <nl> + ( action ( run . / test_coverage_counts . exe ) ) ) <nl> + <nl> + <nl> + ( executable <nl> + ( name test_new_file ) <nl> + ( modules test_new_file ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name new_file ) <nl> + ( deps test_new_file . exe ) <nl> + ( action ( run . / test_new_file . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_capitalization ) <nl> + ( modules test_capitalization ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name capitalization ) <nl> + ( deps test_capitalization . exe ) <nl> + ( action ( run . / test_capitalization . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_modify_file ) <nl> + ( modules test_modify_file ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name modify_file ) <nl> + ( deps test_modify_file . exe ) <nl> + ( action ( run . / test_modify_file . exe ) ) ) <nl> + <nl> + <nl> + ( executable <nl> + ( name test_delete_file ) <nl> + ( modules test_delete_file ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name delete_file ) <nl> + ( deps test_delete_file . exe ) <nl> + ( action ( run . / test_delete_file . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_duplicated_file ) <nl> + ( modules test_duplicated_file ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name duplicated_file ) <nl> + ( deps test_duplicated_file . exe ) <nl> + ( action ( run . / test_duplicated_file . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_failed_decl ) <nl> + ( modules test_failed_decl ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name failed_decl ) <nl> + ( deps test_failed_decl . exe ) <nl> + ( action ( run . / test_failed_decl . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_duplicate_parent ) <nl> + ( modules test_duplicate_parent ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name duplicate_parent ) <nl> + ( deps test_duplicate_parent . exe ) <nl> + ( action ( run . / test_duplicate_parent . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_added_parent ) <nl> + ( modules test_added_parent ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name added_parent ) <nl> + ( deps test_added_parent . exe ) <nl> + ( action ( run . / test_added_parent . exe ) ) ) <nl> + <nl> + <nl> + ( executable <nl> + ( name test_get_dependent_classes ) <nl> + ( modules test_get_dependent_classes ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name get_dependent_classes ) <nl> + ( deps test_get_dependent_classes . exe ) <nl> + ( action ( run . / test_get_dependent_classes . exe ) ) ) <nl> + <nl> + ; " : integration_test_base " , <nl> + ; " / / hphp / hack / src / decl : decl " , <nl> + ; " / / hphp / hack / src / deps : deps " , <nl> + ; " / / hphp / hack / src / errors : errors " , <nl> + ; " / / hphp / hack / src / naming : naming " , <nl> + ; " / / hphp / hack / src / server : server_env " , <nl> + ; " / / hphp / hack / src / utils : core " , <nl> + ; " / / hphp / hack / src / utils : relative_path " , <nl> + ; " / / hphp / hack / src / utils / collections : collections " , <nl> + ; <nl> + ( executable <nl> + ( name test_infer_type ) <nl> + ( modules test_infer_type ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name infer_type ) <nl> + ( deps test_infer_type . exe ) <nl> + ( action ( run . / test_infer_type . exe ) ) ) <nl> + <nl> + ; " : integration_test_base " , <nl> + ; " / / hphp / hack / src / decl : decl " , <nl> + ; " / / hphp / hack / src / errors : errors " , <nl> + ; " / / hphp / hack / src / hhi : hhi " , <nl> + ; " / / hphp / hack / src / options : global_options " , <nl> + ; " / / hphp / hack / src / options : tc_options " , <nl> + ; " / / hphp / hack / src / server : server " , <nl> + ; " / / hphp / hack / src / server : server_command_types " , <nl> + ; " / / hphp / hack / src / server : server_env " , <nl> + ; " / / hphp / hack / src / server : server_services " , <nl> + ; " / / hphp / hack / src / typing : typing " , <nl> + ; " / / hphp / hack / src / typing : typing_ast " , <nl> + ; " / / hphp / hack / src / utils : core " , <nl> + ; " / / hphp / hack / src / utils / collections : collections " , <nl> + <nl> + ( executable <nl> + ( name test_getfundeps ) <nl> + ( modules test_getfundeps ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name getfundeps ) <nl> + ( deps test_getfundeps . exe ) <nl> + ( action ( run . / test_getfundeps . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_isfunlocallable ) <nl> + ( modules test_isfunlocallable ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name isfunlocallable ) <nl> + ( deps test_isfunlocallable . exe ) <nl> + ( action ( run . / test_isfunlocallable . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_server_hover ) <nl> + ( modules test_server_hover ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name server_hover ) <nl> + ( deps test_server_hover . exe ) <nl> + ( action ( run . / test_server_hover . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_failed_naming ) <nl> + ( modules test_failed_naming ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name failed_naming ) <nl> + ( deps test_failed_naming . exe ) <nl> + ( action ( run . / test_failed_naming . exe ) ) ) <nl> + <nl> + ; " : integration_test_base " , <nl> + ; " / / hphp / hack / src / errors : errors " , <nl> + ; " / / hphp / hack / src / server : server_env " , <nl> + <nl> + ( executable <nl> + ( name test_gconst_file ) <nl> + ( modules test_gconst_file ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name gconst_file ) <nl> + ( deps test_gconst_file . exe ) <nl> + ( action ( run . / test_gconst_file . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_ide_utils ) <nl> + ( modules test_ide_utils ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name ide_utils ) <nl> + ( deps test_ide_utils . exe ) <nl> + ( action ( run . / test_ide_utils . exe ) ) ) <nl> + <nl> + ; " : integration_test_base " , <nl> + ; " / / hphp / hack / src / decl : decl " , <nl> + ; " / / hphp / hack / src / deps : deps " , <nl> + ; " / / hphp / hack / src / errors : errors " , <nl> + ; " / / hphp / hack / src / heap : heap " , <nl> + ; " / / hphp / hack / src / options : tc_options " , <nl> + ; " / / hphp / hack / src / server : server_env " , <nl> + ; " / / hphp / hack / src / server : server_services " , <nl> + ; " / / hphp / hack / src / typing : typing " , <nl> + ; " / / hphp / hack / src / typing : typing_ast " , <nl> + ; " / / hphp / hack / src / utils : core " , <nl> + ; " / / hphp / hack / src / utils / collections : collections " , <nl> + <nl> + ( executable <nl> + ( name test_unbound_name ) <nl> + ( modules test_unbound_name ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name unbound_name ) <nl> + ( deps test_unbound_name . exe ) <nl> + ( action ( run . / test_unbound_name . exe ) ) ) <nl> + <nl> + ; " : integration_test_base " , <nl> + ; " / / hphp / hack / src / errors : errors " , <nl> + ; " / / hphp / hack / src / server : server_env " , <nl> + <nl> + ( executable <nl> + ( name test_decl_decl ) <nl> + ( modules test_decl_decl ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name decl_decl ) <nl> + ( deps test_decl_decl . exe ) <nl> + ( action ( run . / test_decl_decl . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_rx_if_implements ) <nl> + ( modules test_rx_if_implements ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name rx_if_implements ) <nl> + ( deps test_rx_if_implements . exe ) <nl> + ( action ( run . / test_rx_if_implements . exe ) ) ) <nl> + <nl> + ; " : integration_test_base " , <nl> + ; " / / hphp / hack / src / decl : decl " , <nl> + ; " / / hphp / hack / src / errors : errors " , <nl> + ; " / / hphp / hack / src / server : server_env " , <nl> + ; " / / hphp / hack / src / utils : core " , <nl> + ; " / / hphp / hack / src / utils / collections : collections " , <nl> + <nl> + ( executable <nl> + ( name test_function_arg_rx_if_implements1 ) <nl> + ( modules test_function_arg_rx_if_implements1 ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name function_arg_rx_if_implements1 ) <nl> + ( deps test_function_arg_rx_if_implements1 . exe ) <nl> + ( action ( run . / test_function_arg_rx_if_implements1 . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_function_arg_rx_if_implements2 ) <nl> + ( modules test_function_arg_rx_if_implements2 ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name function_arg_rx_if_implements2 ) <nl> + ( deps test_function_arg_rx_if_implements2 . exe ) <nl> + ( action ( run . / test_function_arg_rx_if_implements2 . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_lazy_decl_idempotence ) <nl> + ( modules test_lazy_decl_idempotence ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name lazy_decl_idempotence ) <nl> + ( deps test_lazy_decl_idempotence . exe ) <nl> + ( action ( run . / test_lazy_decl_idempotence . exe ) ) ) <nl> + <nl> + ; " : integration_test_base " , <nl> + ; " / / hphp / hack / src / decl : decl " , <nl> + ; " / / hphp / hack / src / deps : deps " , <nl> + ; " / / hphp / hack / src / errors : errors " , <nl> + ; " / / hphp / hack / src / heap : heap " , <nl> + ; " / / hphp / hack / src / options : global_options " , <nl> + ; " / / hphp / hack / src / options : parser_options " , <nl> + ; " / / hphp / hack / src / options : tc_options " , <nl> + ; " / / hphp / hack / src / server : server_env " , <nl> + ; " / / hphp / hack / src / server : server_services " , <nl> + ; " / / hphp / hack / src / typing : typing_check_service " , <nl> + ; " / / hphp / hack / src / utils : core " , <nl> + ; " / / hphp / hack / src / utils : relative_path " , <nl> + ; " / / hphp / hack / src / utils / collections : collections " , <nl> + <nl> + ( executable <nl> + ( name test_interrupt ) <nl> + ( modules test_interrupt ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name interrupt ) <nl> + ( deps test_interrupt . exe ) <nl> + ( action ( run . / test_interrupt . exe ) ) ) <nl> + <nl> + ; " : integration_test_base " , <nl> + ; " / / hphp / hack / src / decl : decl " , <nl> + ; " / / hphp / hack / src / deps : deps " , <nl> + ; " / / hphp / hack / src / errors : errors " , <nl> + ; " / / hphp / hack / src / heap : heap " , <nl> + ; " / / hphp / hack / src / naming : naming " , <nl> + ; " / / hphp / hack / src / options : global_options " , <nl> + ; " / / hphp / hack / src / options : parser_options " , <nl> + ; " / / hphp / hack / src / options : tc_options " , <nl> + ; " / / hphp / hack / src / procs : procs " , <nl> + ; " / / hphp / hack / src / server : server " , <nl> + ; " / / hphp / hack / src / server : server_env " , <nl> + ; " / / hphp / hack / src / server : server_services " , <nl> + ; " / / hphp / hack / src / typing : typing_check_service " , <nl> + ; " / / hphp / hack / src / utils : core " , <nl> + ; " / / hphp / hack / src / utils : relative_path " , <nl> + ; " / / hphp / hack / src / utils / collections : collections " , <nl> + <nl> + ( executable <nl> + ( name test_interrupt2 ) <nl> + ( modules test_interrupt2 ) <nl> + ( libraries <nl> + integration_test_base <nl> + errors <nl> + server_env ) ) <nl> + <nl> + ( alias <nl> + ( name interrupt2 ) <nl> + ( deps test_interrupt2 . exe ) <nl> + ( action ( run . / test_interrupt2 . exe ) ) ) <nl> + <nl> + ; " : integration_test_base " , <nl> + ; " / / hphp / hack / src / decl : decl " , <nl> + ; " / / hphp / hack / src / deps : deps " , <nl> + ; " / / hphp / hack / src / errors : errors " , <nl> + ; " / / hphp / hack / src / heap : heap " , <nl> + ; " / / hphp / hack / src / options : global_options " , <nl> + ; " / / hphp / hack / src / options : parser_options " , <nl> + ; " / / hphp / hack / src / options : tc_options " , <nl> + ; " / / hphp / hack / src / procs : procs " , <nl> + ; " / / hphp / hack / src / server : server " , <nl> + ; " / / hphp / hack / src / server : server_extras " , <nl> + ; " / / hphp / hack / src / server : server_services " , <nl> + ; " / / hphp / hack / src / typing : typing_check_service " , <nl> + ; " / / hphp / hack / src / utils : core " , <nl> + ; " / / hphp / hack / src / utils : relative_path " , <nl> + ; " / / hphp / hack / src / utils / collections : collections " , <nl> + <nl> + ( alias <nl> + ( name runtest ) <nl> + ( deps <nl> + ( alias coverage_counts ) <nl> + ( alias new_file ) <nl> + ( alias capitalization ) <nl> + ( alias modify_file ) <nl> + ( alias delete_file ) <nl> + ( alias duplicated_file ) <nl> + ( alias failed_decl ) <nl> + ( alias duplicate_parent ) <nl> + ( alias added_parent ) <nl> + ( alias get_dependent_classes ) <nl> + ( alias infer_type ) <nl> + ( alias getfundeps ) <nl> + ( alias isfunlocallable ) <nl> + ( alias server_hover ) <nl> + ( alias failed_naming ) <nl> + ( alias gconst_file ) <nl> + ( alias ide_utils ) <nl> + ( alias unbound_name ) <nl> + ( alias decl_decl ) <nl> + ( alias rx_if_implements ) <nl> + ( alias function_arg_rx_if_implements1 ) <nl> + ( alias function_arg_rx_if_implements2 ) <nl> + ( alias lazy_decl_idempotence ) <nl> + ( alias interrupt ) <nl> + ( alias interrupt2 ) ) ) <nl> new file mode 100644 <nl> index 00000000000 . . a7dfcbc1b91 <nl> mmm / dev / null <nl> ppp b / hphp / hack / test / integration_ml / saved_state / dune <nl> <nl> + ( executable <nl> + ( name test_saved_state ) <nl> + ( modules test_saved_state ) <nl> + ( ocamlc_flags ( : standard - custom ) ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name saved_state ) <nl> + ( deps test_saved_state . exe ) <nl> + ( action ( run . / test_saved_state . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_saved_state_with_decl_error ) <nl> + ( modules test_saved_state_with_decl_error ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name saved_state_with_decl_error ) <nl> + ( deps test_saved_state_with_decl_error . exe ) <nl> + ( action ( run . / test_saved_state_with_decl_error . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_saved_state_with_naming_error ) <nl> + ( modules test_saved_state_with_naming_error ) <nl> + ( libraries <nl> + integration_test_base <nl> + pcre <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name saved_state_with_naming_error ) <nl> + ( deps test_saved_state_with_naming_error . exe ) <nl> + ( action ( run . / test_saved_state_with_naming_error . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_saved_state_with_parse_error ) <nl> + ( modules test_saved_state_with_parse_error ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name saved_state_with_parse_error ) <nl> + ( deps test_saved_state_with_parse_error . exe ) <nl> + ( action ( run . / test_saved_state_with_parse_error . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_disk_race_conditions ) <nl> + ( modules test_disk_race_conditions ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name disk_race_conditions ) <nl> + ( deps test_disk_race_conditions . exe ) <nl> + ( action ( run . / test_disk_race_conditions . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_prechecked_basic ) <nl> + ( modules test_prechecked_basic ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name prechecked_basic ) <nl> + ( deps test_prechecked_basic . exe ) <nl> + ( action ( run . / test_prechecked_basic . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_prechecked_advanced ) <nl> + ( modules test_prechecked_advanced ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name prechecked_advanced ) <nl> + ( deps test_prechecked_advanced . exe ) <nl> + ( action ( run . / test_prechecked_advanced . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_prechecked_incremental ) <nl> + ( modules test_prechecked_incremental ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name prechecked_incremental ) <nl> + ( deps test_prechecked_incremental . exe ) <nl> + ( action ( run . / test_prechecked_incremental . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_prechecked_incremental_after_init ) <nl> + ( modules test_prechecked_incremental_after_init ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name prechecked_incremental_after_init ) <nl> + ( deps test_prechecked_incremental_after_init . exe ) <nl> + ( action ( run . / test_prechecked_incremental_after_init . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_prechecked_find_refs ) <nl> + ( modules test_prechecked_find_refs ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name prechecked_find_refs ) <nl> + ( deps test_prechecked_find_refs . exe ) <nl> + ( action ( run . / test_prechecked_find_refs . exe ) ) ) <nl> + <nl> + ( library <nl> + ( name no_op_common ) <nl> + ( modules no_op_common ) <nl> + ( libraries <nl> + core_kernel <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( executable <nl> + ( name test_no_op_open ) <nl> + ( modules test_no_op_open ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + no_op_common ) ) <nl> + <nl> + ( alias <nl> + ( name no_op_open ) <nl> + ( deps test_no_op_open . exe ) <nl> + ( action ( run . / test_no_op_open . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_no_op_edit ) <nl> + ( modules test_no_op_edit ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + no_op_common ) ) <nl> + <nl> + ( alias <nl> + ( name no_op_edit ) <nl> + ( deps test_no_op_edit . exe ) <nl> + ( action ( run . / test_no_op_edit . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_no_op_close ) <nl> + ( modules test_no_op_close ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + no_op_common ) ) <nl> + <nl> + ( alias <nl> + ( name no_op_close ) <nl> + ( deps test_no_op_close . exe ) <nl> + ( action ( run . / test_no_op_close . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_deps_all_members ) <nl> + ( modules test_deps_all_members ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name deps_all_members ) <nl> + ( deps test_deps_all_members . exe ) <nl> + ( action ( run . / test_deps_all_members . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_similar_files ) <nl> + ( modules test_similar_files ) <nl> + ( libraries <nl> + integration_test_base <nl> + pcre <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name similar_files ) <nl> + ( deps test_similar_files . exe ) <nl> + ( action ( run . / test_similar_files . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_disable_conservative_redecl_class ) <nl> + ( modules test_disable_conservative_redecl_class ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name disable_conservative_redecl_class ) <nl> + ( deps test_disable_conservative_redecl_class . exe ) <nl> + ( action ( run . / test_disable_conservative_redecl_class . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_predeclare_ide_deps ) <nl> + ( modules test_predeclare_ide_deps ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name predeclare_ide_deps ) <nl> + ( deps test_predeclare_ide_deps . exe ) <nl> + ( action ( run . / test_predeclare_ide_deps . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_ide_cache ) <nl> + ( modules test_ide_cache ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name ide_cache ) <nl> + ( deps test_ide_cache . exe ) <nl> + ( action ( run . / test_ide_cache . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_ide_tast_cache ) <nl> + ( modules test_ide_tast_cache ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name ide_tast_cache ) <nl> + ( deps test_ide_tast_cache . exe ) <nl> + ( action ( run . / test_ide_tast_cache . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_load_decls_enum_add_member ) <nl> + ( modules test_load_decls_enum_add_member ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name load_decls_enum_add_member ) <nl> + ( deps test_load_decls_enum_add_member . exe ) <nl> + ( action ( run . / test_load_decls_enum_add_member . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_load_decls_stale_derived_class ) <nl> + ( modules test_load_decls_stale_derived_class ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name load_decls_stale_derived_class ) <nl> + ( deps test_load_decls_stale_derived_class . exe ) <nl> + ( action ( run . / test_load_decls_stale_derived_class . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_load_decls_fixme_in_hot_similar_class ) <nl> + ( modules test_load_decls_fixme_in_hot_similar_class ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name load_decls_fixme_in_hot_similar_class ) <nl> + ( deps test_load_decls_fixme_in_hot_similar_class . exe ) <nl> + ( action ( run . / test_load_decls_fixme_in_hot_similar_class . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_load_decls_fixme_in_hot_unchanged_interface ) <nl> + ( modules test_load_decls_fixme_in_hot_unchanged_interface ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name load_decls_fixme_in_hot_unchanged_interface ) <nl> + ( deps test_load_decls_fixme_in_hot_unchanged_interface . exe ) <nl> + ( action ( run . / test_load_decls_fixme_in_hot_unchanged_interface . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_load_decls_fixme_in_hot_changed_class ) <nl> + ( modules test_load_decls_fixme_in_hot_changed_class ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name load_decls_fixme_in_hot_changed_class ) <nl> + ( deps test_load_decls_fixme_in_hot_changed_class . exe ) <nl> + ( action ( run . / test_load_decls_fixme_in_hot_changed_class . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_load_decls_cold_synthesized_ancestors ) <nl> + ( modules test_load_decls_cold_synthesized_ancestors ) <nl> + ( libraries <nl> + asserter <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name load_decls_cold_synthesized_ancestors ) <nl> + ( deps test_load_decls_cold_synthesized_ancestors . exe ) <nl> + ( action ( run . / test_load_decls_cold_synthesized_ancestors . exe ) ) ) <nl> + <nl> + ( executable <nl> + ( name test_fun_deps_load_from_state ) <nl> + ( modules test_fun_deps_load_from_state ) <nl> + ( libraries <nl> + integration_test_base <nl> + temp_file ) ) <nl> + <nl> + ( alias <nl> + ( name fun_deps_load_from_state ) <nl> + ( deps test_fun_deps_load_from_state . exe ) <nl> + ( action ( run . / test_fun_deps_load_from_state . exe ) ) ) <nl> + <nl> + ( alias <nl> + ( name runtest ) <nl> + ( deps <nl> + ( alias saved_state ) <nl> + ( alias saved_state_with_decl_error ) <nl> + ( alias saved_state_with_naming_error ) <nl> + ( alias saved_state_with_parse_error ) <nl> + ( alias disk_race_conditions ) <nl> + ( alias prechecked_basic ) <nl> + ( alias prechecked_advanced ) <nl> + ( alias prechecked_incremental ) <nl> + ( alias prechecked_incremental_after_init ) <nl> + ( alias prechecked_find_refs ) <nl> + ( alias no_op_open ) <nl> + ( alias no_op_edit ) <nl> + ( alias no_op_close ) <nl> + ( alias deps_all_members ) <nl> + ( alias similar_files ) <nl> + ( alias disable_conservative_redecl_class ) <nl> + ( alias predeclare_ide_deps ) <nl> + ( alias ide_cache ) <nl> + ( alias ide_tast_cache ) <nl> + ( alias load_decls_enum_add_member ) <nl> + ( alias load_decls_stale_derived_class ) <nl> + ( alias load_decls_fixme_in_hot_similar_class ) <nl> + ( alias load_decls_fixme_in_hot_unchanged_interface ) <nl> + ( alias load_decls_fixme_in_hot_changed_class ) <nl> + ( alias load_decls_cold_synthesized_ancestors ) <nl> + ( alias fun_deps_load_from_state ) ) ) <nl> mmm a / hphp / hack / test / integration_ml / test_get_dependent_classes . ml <nl> ppp b / hphp / hack / test / integration_ml / test_get_dependent_classes . ml <nl> let ( ) = <nl> let get_classes path = <nl> match Naming_table . get_file_info env . ServerEnv . naming_table path with <nl> | None - > SSet . empty <nl> - | Some info - > SSet . of_list @ @ List . map info . FileInfo . classes snd <nl> + | Some info - > SSet . of_list @ @ List . map info . FileInfo . classes ~ f : snd <nl> in <nl> <nl> let dependent_classes = Decl_redecl_service . get_dependent_classes <nl> let ( ) = <nl> ( SSet . of_list [ " \ \ C " ; " \ \ H " ; " \ \ J " ; " \ \ : M " ; ] ) <nl> in <nl> <nl> - let expected_dependent_classes = List . sort String . compare <nl> + let expected_dependent_classes = List . sort ~ cmp : String . compare <nl> [ " \ \ C " ; " \ \ D " ; " \ \ E " ; " \ \ F " ; " \ \ G " ; " \ \ H " ; <nl> " \ \ I " ; " \ \ J " ; " \ \ K " ; " \ \ L " ; " \ \ : M " ; " \ \ : N " ; ] <nl> in <nl> mmm a / hphp / hack / test / integration_ml / test_getfundeps . ml <nl> ppp b / hphp / hack / test / integration_ml / test_getfundeps . ml <nl> let ( ) = <nl> ( String . concat " \ n " result ) in <nl> Test . fail msg <nl> end in <nl> - List . iter tests do_test <nl> + List . iter tests ~ f : do_test <nl> mmm a / hphp / hack / test / integration_ml / test_isfunlocallable . ml <nl> ppp b / hphp / hack / test / integration_ml / test_isfunlocallable . ml <nl> let ( ) = <nl> ( String . concat " \ n " result ) in <nl> Test . fail msg <nl> end in <nl> - List . iter tests do_test <nl> + List . iter tests ~ f : do_test <nl> mmm a / hphp / hack / test / integration_ml / test_server_hover . ml <nl> ppp b / hphp / hack / test / integration_ml / test_server_hover . ml <nl> module Test = Integration_test_base <nl> <nl> let pos_at ( line1 , column1 ) ( line2 , column2 ) = <nl> Some ( Pos . make_from_lnum_bol_cnum <nl> - Relative_path . default <nl> - ( line1 , 0 , column1 - 1 ) <nl> - ( line2 , 0 , column2 ) ) <nl> + ~ pos_file : Relative_path . default <nl> + ~ pos_start : ( line1 , 0 , column1 - 1 ) <nl> + ~ pos_end : ( line2 , 0 , column2 ) ) <nl> <nl> let class_members = " < ? hh / / strict <nl> abstract class ClassMembers { <nl> mmm a / hphp / hack / test / utils / asserter / dune <nl> ppp b / hphp / hack / test / utils / asserter / dune <nl> <nl> ( modules asserter ) <nl> ( libraries <nl> hh_json <nl> + relative_path <nl> str ) ) <nl>
|
add remaining of integration_ml tests
|
facebook/hhvm
|
1278ef2bf1f090f525b62a731a08bd1bce3627a2
|
2019-05-17T07:25:40Z
|
mmm a / hphp / runtime / vm / jit / irgen - builtin . cpp <nl> ppp b / hphp / runtime / vm / jit / irgen - builtin . cpp <nl> SSATmp * opt_shapes_idx ( IRGS & env , const ParamPrep & params ) { <nl> <nl> const EnumValues * getEnumValues ( IRGS & env , const ParamPrep & params ) { <nl> if ( RO : : EvalLogArrayProvenance ) return nullptr ; <nl> - if ( params . size ( ) ! = 0 ) return nullptr ; <nl> if ( ! ( params . ctx & & params . ctx - > hasConstVal ( TCls ) ) ) return nullptr ; <nl> auto const cls = params . ctx - > clsVal ( ) ; <nl> if ( ! ( isEnum ( cls ) & & classHasPersistentRDS ( cls ) ) ) return nullptr ; <nl> const EnumValues * getEnumValues ( IRGS & env , const ParamPrep & params ) { <nl> } <nl> <nl> SSATmp * opt_enum_names ( IRGS & env , const ParamPrep & params ) { <nl> + if ( params . size ( ) ! = 0 ) return nullptr ; <nl> auto const enum_values = getEnumValues ( env , params ) ; <nl> return enum_values ? cns ( env , enum_values - > names . get ( ) ) : nullptr ; <nl> } <nl> <nl> SSATmp * opt_enum_values ( IRGS & env , const ParamPrep & params ) { <nl> + if ( params . size ( ) ! = 0 ) return nullptr ; <nl> auto const enum_values = getEnumValues ( env , params ) ; <nl> return enum_values ? cns ( env , enum_values - > values . get ( ) ) : nullptr ; <nl> } <nl> <nl> + SSATmp * opt_enum_is_valid ( IRGS & env , const ParamPrep & params ) { <nl> + if ( params . size ( ) ! = 1 ) return nullptr ; <nl> + auto const value = params [ 0 ] . value ; <nl> + if ( ! value - > type ( ) . isKnownDataType ( ) ) return nullptr ; <nl> + auto const enum_values = getEnumValues ( env , params ) ; <nl> + if ( ! enum_values ) return nullptr ; <nl> + auto const ad = MixedArray : : asMixed ( enum_values - > names . get ( ) ) ; <nl> + auto const op = ad - > isDict ( ) ? AKExistsDict : AKExistsArr ; <nl> + if ( value - > isA ( TInt ) ) { <nl> + if ( ad - > keyTypes ( ) . mustBeStrs ( ) ) return cns ( env , false ) ; <nl> + return gen ( env , op , cns ( env , ad - > asArrayData ( ) ) , value ) ; <nl> + } else if ( value - > isA ( TStr ) ) { <nl> + / / We ' re not doing intish - casts here , so we bail if ad has any int keys . <nl> + if ( ! ad - > keyTypes ( ) . mustBeStrs ( ) ) return nullptr ; <nl> + return gen ( env , op , cns ( env , ad - > asArrayData ( ) ) , value ) ; <nl> + } <nl> + return cns ( env , false ) ; <nl> + } <nl> + <nl> + SSATmp * opt_enum_coerce ( IRGS & env , const ParamPrep & params ) { <nl> + auto const valid = opt_enum_is_valid ( env , params ) ; <nl> + if ( ! valid ) return nullptr ; <nl> + return cond ( env , <nl> + [ & ] ( Block * taken ) { gen ( env , JmpZero , taken , valid ) ; } , <nl> + [ & ] { <nl> + / / We never need to coerce strs to ints here , but we may need to coerce <nl> + / / ints to strs if the enum is a string type with intish values . <nl> + auto const value = params [ 0 ] . value ; <nl> + auto const isstr = isStringType ( params . ctx - > clsVal ( ) - > enumBaseTy ( ) ) ; <nl> + if ( value - > isA ( TInt ) & & isstr ) return gen ( env , ConvIntToStr , value ) ; <nl> + gen ( env , IncRef , value ) ; <nl> + return value ; <nl> + } , <nl> + [ & ] { return cns ( env , TInitNull ) ; } <nl> + ) ; <nl> + } <nl> + <nl> SSATmp * opt_tag_provenance_here ( IRGS & env , const ParamPrep & params ) { <nl> if ( params . size ( ) ! = 1 ) return nullptr ; <nl> if ( RO : : EvalLogArrayProvenance ) return nullptr ; <nl> const hphp_fast_string_imap < OptEmitFn > s_opt_emit_fns { <nl> { " HH \ \ Shapes : : idx " , opt_shapes_idx } , <nl> { " HH \ \ BuiltinEnum : : getNames " , opt_enum_names } , <nl> { " HH \ \ BuiltinEnum : : getValues " , opt_enum_values } , <nl> + { " HH \ \ BuiltinEnum : : coerce " , opt_enum_coerce } , <nl> + { " HH \ \ BuiltinEnum : : isValid " , opt_enum_is_valid } , <nl> { " HH \ \ is_meth_caller " , opt_is_meth_caller } , <nl> { " HH \ \ tag_provenance_here " , opt_tag_provenance_here } , <nl> { " HH \ \ array_mark_legacy " , opt_array_mark_legacy } , <nl>
|
Optimize enum coerce and isValid
|
facebook/hhvm
|
db312f634d5c2cf70c990fda43639acda81dd9c8
|
2020-03-06T21:39:28Z
|
mmm a / src / arm / disasm - arm . cc <nl> ppp b / src / arm / disasm - arm . cc <nl> bool Decoder : : IsConstantPoolAt ( byte * instr_ptr ) { <nl> int Decoder : : ConstantPoolSizeAt ( byte * instr_ptr ) { <nl> if ( IsConstantPoolAt ( instr_ptr ) ) { <nl> int instruction_bits = * ( reinterpret_cast < int * > ( instr_ptr ) ) ; <nl> - return DecodeConstantPoolLength ( instruction_bits ) ; <nl> + return DecodeConstantPoolLength ( instruction_bits ) / Assembler : : kInstrSize ; <nl> } else { <nl> return - 1 ; <nl> } <nl>
|
ConstantPoolSizeAt ( ) should return number of Instructions instead , otherwise , some of the code will be treated as constant pool when printing code in ARM disassembler .
|
v8/v8
|
899ec323af52d740b04340b528078a006ba43910
|
2013-08-29T11:49:46Z
|
mmm a / src / compiler / backend / mips / code - generator - mips . cc <nl> ppp b / src / compiler / backend / mips / code - generator - mips . cc <nl> CodeGenerator : : CodeGenResult CodeGenerator : : AssembleArchInstruction ( <nl> kSimd128RegZero ) ; <nl> break ; <nl> } <nl> + case kMipsI32x4BitMask : { <nl> + CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> + Register dst = i . OutputRegister ( ) ; <nl> + Simd128Register src = i . InputSimd128Register ( 0 ) ; <nl> + Simd128Register scratch0 = kSimd128RegZero ; <nl> + Simd128Register scratch1 = kSimd128ScratchReg ; <nl> + __ srli_w ( scratch0 , src , 31 ) ; <nl> + __ srli_d ( scratch1 , scratch0 , 31 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ shf_w ( scratch1 , scratch0 , 0x0E ) ; <nl> + __ slli_d ( scratch1 , scratch1 , 2 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ copy_u_b ( dst , scratch0 , 0 ) ; <nl> + break ; <nl> + } <nl> case kMipsI16x8Splat : { <nl> CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> __ fill_h ( i . OutputSimd128Register ( ) , i . InputRegister ( 0 ) ) ; <nl> CodeGenerator : : CodeGenResult CodeGenerator : : AssembleArchInstruction ( <nl> kSimd128RegZero ) ; <nl> break ; <nl> } <nl> + case kMipsI16x8BitMask : { <nl> + CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> + Register dst = i . OutputRegister ( ) ; <nl> + Simd128Register src = i . InputSimd128Register ( 0 ) ; <nl> + Simd128Register scratch0 = kSimd128RegZero ; <nl> + Simd128Register scratch1 = kSimd128ScratchReg ; <nl> + __ srli_h ( scratch0 , src , 15 ) ; <nl> + __ srli_w ( scratch1 , scratch0 , 15 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ srli_d ( scratch1 , scratch0 , 30 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ shf_w ( scratch1 , scratch0 , 0x0E ) ; <nl> + __ slli_d ( scratch1 , scratch1 , 4 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ copy_u_b ( dst , scratch0 , 0 ) ; <nl> + break ; <nl> + } <nl> case kMipsI8x16Splat : { <nl> CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> __ fill_b ( i . OutputSimd128Register ( ) , i . InputRegister ( 0 ) ) ; <nl> CodeGenerator : : CodeGenResult CodeGenerator : : AssembleArchInstruction ( <nl> kSimd128RegZero ) ; <nl> break ; <nl> } <nl> + case kMipsI8x16BitMask : { <nl> + CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> + Register dst = i . OutputRegister ( ) ; <nl> + Simd128Register src = i . InputSimd128Register ( 0 ) ; <nl> + Simd128Register scratch0 = kSimd128RegZero ; <nl> + Simd128Register scratch1 = kSimd128ScratchReg ; <nl> + __ srli_b ( scratch0 , src , 7 ) ; <nl> + __ srli_h ( scratch1 , scratch0 , 7 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ srli_w ( scratch1 , scratch0 , 14 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ srli_d ( scratch1 , scratch0 , 28 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ shf_w ( scratch1 , scratch0 , 0x0E ) ; <nl> + __ ilvev_b ( scratch0 , scratch1 , scratch0 ) ; <nl> + __ copy_u_h ( dst , scratch0 , 0 ) ; <nl> + break ; <nl> + } <nl> case kMipsS128And : { <nl> CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> __ and_v ( i . OutputSimd128Register ( ) , i . InputSimd128Register ( 0 ) , <nl> mmm a / src / compiler / backend / mips / instruction - codes - mips . h <nl> ppp b / src / compiler / backend / mips / instruction - codes - mips . h <nl> namespace compiler { <nl> V ( MipsI32x4GtU ) \ <nl> V ( MipsI32x4GeU ) \ <nl> V ( MipsI32x4Abs ) \ <nl> + V ( MipsI32x4BitMask ) \ <nl> V ( MipsI16x8Splat ) \ <nl> V ( MipsI16x8ExtractLaneU ) \ <nl> V ( MipsI16x8ExtractLaneS ) \ <nl> namespace compiler { <nl> V ( MipsI16x8GeU ) \ <nl> V ( MipsI16x8RoundingAverageU ) \ <nl> V ( MipsI16x8Abs ) \ <nl> + V ( MipsI16x8BitMask ) \ <nl> V ( MipsI8x16Splat ) \ <nl> V ( MipsI8x16ExtractLaneU ) \ <nl> V ( MipsI8x16ExtractLaneS ) \ <nl> namespace compiler { <nl> V ( MipsI8x16GeU ) \ <nl> V ( MipsI8x16RoundingAverageU ) \ <nl> V ( MipsI8x16Abs ) \ <nl> + V ( MipsI8x16BitMask ) \ <nl> V ( MipsS128And ) \ <nl> V ( MipsS128Or ) \ <nl> V ( MipsS128Xor ) \ <nl> mmm a / src / compiler / backend / mips / instruction - scheduler - mips . cc <nl> ppp b / src / compiler / backend / mips / instruction - scheduler - mips . cc <nl> int InstructionScheduler : : GetTargetInstructionFlags ( <nl> case kMipsI16x8UConvertI8x16High : <nl> case kMipsI16x8UConvertI8x16Low : <nl> case kMipsI16x8Abs : <nl> + case kMipsI16x8BitMask : <nl> case kMipsI32x4Add : <nl> case kMipsI32x4AddHoriz : <nl> case kMipsI32x4Eq : <nl> int InstructionScheduler : : GetTargetInstructionFlags ( <nl> case kMipsI32x4UConvertI16x8High : <nl> case kMipsI32x4UConvertI16x8Low : <nl> case kMipsI32x4Abs : <nl> + case kMipsI32x4BitMask : <nl> case kMipsI8x16Add : <nl> case kMipsI8x16AddSaturateS : <nl> case kMipsI8x16AddSaturateU : <nl> int InstructionScheduler : : GetTargetInstructionFlags ( <nl> case kMipsI8x16SubSaturateU : <nl> case kMipsI8x16UConvertI16x8 : <nl> case kMipsI8x16Abs : <nl> + case kMipsI8x16BitMask : <nl> case kMipsIns : <nl> case kMipsLsa : <nl> case kMipsMaddD : <nl> mmm a / src / compiler / backend / mips / instruction - selector - mips . cc <nl> ppp b / src / compiler / backend / mips / instruction - selector - mips . cc <nl> void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> V ( I32x4GtU , kMipsI32x4GtU ) \ <nl> V ( I32x4GeU , kMipsI32x4GeU ) \ <nl> V ( I32x4Abs , kMipsI32x4Abs ) \ <nl> + V ( I32x4BitMask , kMipsI32x4BitMask ) \ <nl> V ( I16x8Add , kMipsI16x8Add ) \ <nl> V ( I16x8AddSaturateS , kMipsI16x8AddSaturateS ) \ <nl> V ( I16x8AddSaturateU , kMipsI16x8AddSaturateU ) \ <nl> void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> V ( I16x8UConvertI32x4 , kMipsI16x8UConvertI32x4 ) \ <nl> V ( I16x8RoundingAverageU , kMipsI16x8RoundingAverageU ) \ <nl> V ( I16x8Abs , kMipsI16x8Abs ) \ <nl> + V ( I16x8BitMask , kMipsI16x8BitMask ) \ <nl> V ( I8x16Add , kMipsI8x16Add ) \ <nl> V ( I8x16AddSaturateS , kMipsI8x16AddSaturateS ) \ <nl> V ( I8x16AddSaturateU , kMipsI8x16AddSaturateU ) \ <nl> void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> V ( I8x16SConvertI16x8 , kMipsI8x16SConvertI16x8 ) \ <nl> V ( I8x16UConvertI16x8 , kMipsI8x16UConvertI16x8 ) \ <nl> V ( I8x16Abs , kMipsI8x16Abs ) \ <nl> + V ( I8x16BitMask , kMipsI8x16BitMask ) \ <nl> V ( S128And , kMipsS128And ) \ <nl> V ( S128Or , kMipsS128Or ) \ <nl> V ( S128Xor , kMipsS128Xor ) \ <nl> mmm a / src / compiler / backend / mips64 / code - generator - mips64 . cc <nl> ppp b / src / compiler / backend / mips64 / code - generator - mips64 . cc <nl> CodeGenerator : : CodeGenResult CodeGenerator : : AssembleArchInstruction ( <nl> kSimd128RegZero ) ; <nl> break ; <nl> } <nl> + case kMips64I32x4BitMask : { <nl> + CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> + Register dst = i . OutputRegister ( ) ; <nl> + Simd128Register src = i . InputSimd128Register ( 0 ) ; <nl> + Simd128Register scratch0 = kSimd128RegZero ; <nl> + Simd128Register scratch1 = kSimd128ScratchReg ; <nl> + __ srli_w ( scratch0 , src , 31 ) ; <nl> + __ srli_d ( scratch1 , scratch0 , 31 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ shf_w ( scratch1 , scratch0 , 0x0E ) ; <nl> + __ slli_d ( scratch1 , scratch1 , 2 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ copy_u_b ( dst , scratch0 , 0 ) ; <nl> + break ; <nl> + } <nl> case kMips64I16x8Splat : { <nl> CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> __ fill_h ( i . OutputSimd128Register ( ) , i . InputRegister ( 0 ) ) ; <nl> CodeGenerator : : CodeGenResult CodeGenerator : : AssembleArchInstruction ( <nl> kSimd128RegZero ) ; <nl> break ; <nl> } <nl> + case kMips64I16x8BitMask : { <nl> + CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> + Register dst = i . OutputRegister ( ) ; <nl> + Simd128Register src = i . InputSimd128Register ( 0 ) ; <nl> + Simd128Register scratch0 = kSimd128RegZero ; <nl> + Simd128Register scratch1 = kSimd128ScratchReg ; <nl> + __ srli_h ( scratch0 , src , 15 ) ; <nl> + __ srli_w ( scratch1 , scratch0 , 15 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ srli_d ( scratch1 , scratch0 , 30 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ shf_w ( scratch1 , scratch0 , 0x0E ) ; <nl> + __ slli_d ( scratch1 , scratch1 , 4 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ copy_u_b ( dst , scratch0 , 0 ) ; <nl> + break ; <nl> + } <nl> case kMips64I8x16Splat : { <nl> CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> __ fill_b ( i . OutputSimd128Register ( ) , i . InputRegister ( 0 ) ) ; <nl> CodeGenerator : : CodeGenResult CodeGenerator : : AssembleArchInstruction ( <nl> kSimd128RegZero ) ; <nl> break ; <nl> } <nl> + case kMips64I8x16BitMask : { <nl> + CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> + Register dst = i . OutputRegister ( ) ; <nl> + Simd128Register src = i . InputSimd128Register ( 0 ) ; <nl> + Simd128Register scratch0 = kSimd128RegZero ; <nl> + Simd128Register scratch1 = kSimd128ScratchReg ; <nl> + __ srli_b ( scratch0 , src , 7 ) ; <nl> + __ srli_h ( scratch1 , scratch0 , 7 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ srli_w ( scratch1 , scratch0 , 14 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ srli_d ( scratch1 , scratch0 , 28 ) ; <nl> + __ or_v ( scratch0 , scratch0 , scratch1 ) ; <nl> + __ shf_w ( scratch1 , scratch0 , 0x0E ) ; <nl> + __ ilvev_b ( scratch0 , scratch1 , scratch0 ) ; <nl> + __ copy_u_h ( dst , scratch0 , 0 ) ; <nl> + break ; <nl> + } <nl> case kMips64S128And : { <nl> CpuFeatureScope msa_scope ( tasm ( ) , MIPS_SIMD ) ; <nl> __ and_v ( i . OutputSimd128Register ( ) , i . InputSimd128Register ( 0 ) , <nl> mmm a / src / compiler / backend / mips64 / instruction - codes - mips64 . h <nl> ppp b / src / compiler / backend / mips64 / instruction - codes - mips64 . h <nl> namespace compiler { <nl> V ( Mips64I32x4GtU ) \ <nl> V ( Mips64I32x4GeU ) \ <nl> V ( Mips64I32x4Abs ) \ <nl> + V ( Mips64I32x4BitMask ) \ <nl> V ( Mips64I16x8Splat ) \ <nl> V ( Mips64I16x8ExtractLaneU ) \ <nl> V ( Mips64I16x8ExtractLaneS ) \ <nl> namespace compiler { <nl> V ( Mips64I16x8GeU ) \ <nl> V ( Mips64I16x8RoundingAverageU ) \ <nl> V ( Mips64I16x8Abs ) \ <nl> + V ( Mips64I16x8BitMask ) \ <nl> V ( Mips64I8x16Splat ) \ <nl> V ( Mips64I8x16ExtractLaneU ) \ <nl> V ( Mips64I8x16ExtractLaneS ) \ <nl> namespace compiler { <nl> V ( Mips64I8x16GeU ) \ <nl> V ( Mips64I8x16RoundingAverageU ) \ <nl> V ( Mips64I8x16Abs ) \ <nl> + V ( Mips64I8x16BitMask ) \ <nl> V ( Mips64S128And ) \ <nl> V ( Mips64S128Or ) \ <nl> V ( Mips64S128Xor ) \ <nl> mmm a / src / compiler / backend / mips64 / instruction - scheduler - mips64 . cc <nl> ppp b / src / compiler / backend / mips64 / instruction - scheduler - mips64 . cc <nl> int InstructionScheduler : : GetTargetInstructionFlags ( <nl> case kMips64I16x8UConvertI8x16Low : <nl> case kMips64I16x8RoundingAverageU : <nl> case kMips64I16x8Abs : <nl> + case kMips64I16x8BitMask : <nl> case kMips64I32x4Add : <nl> case kMips64I32x4AddHoriz : <nl> case kMips64I32x4Eq : <nl> int InstructionScheduler : : GetTargetInstructionFlags ( <nl> case kMips64I32x4UConvertI16x8High : <nl> case kMips64I32x4UConvertI16x8Low : <nl> case kMips64I32x4Abs : <nl> + case kMips64I32x4BitMask : <nl> case kMips64I8x16Add : <nl> case kMips64I8x16AddSaturateS : <nl> case kMips64I8x16AddSaturateU : <nl> int InstructionScheduler : : GetTargetInstructionFlags ( <nl> case kMips64I8x16SubSaturateU : <nl> case kMips64I8x16RoundingAverageU : <nl> case kMips64I8x16Abs : <nl> + case kMips64I8x16BitMask : <nl> case kMips64Ins : <nl> case kMips64Lsa : <nl> case kMips64MaxD : <nl> mmm a / src / compiler / backend / mips64 / instruction - selector - mips64 . cc <nl> ppp b / src / compiler / backend / mips64 / instruction - selector - mips64 . cc <nl> void InstructionSelector : : VisitInt64AbsWithOverflow ( Node * node ) { <nl> V ( I32x4UConvertI16x8Low , kMips64I32x4UConvertI16x8Low ) \ <nl> V ( I32x4UConvertI16x8High , kMips64I32x4UConvertI16x8High ) \ <nl> V ( I32x4Abs , kMips64I32x4Abs ) \ <nl> + V ( I32x4BitMask , kMips64I32x4BitMask ) \ <nl> V ( I16x8Neg , kMips64I16x8Neg ) \ <nl> V ( I16x8SConvertI8x16Low , kMips64I16x8SConvertI8x16Low ) \ <nl> V ( I16x8SConvertI8x16High , kMips64I16x8SConvertI8x16High ) \ <nl> V ( I16x8UConvertI8x16Low , kMips64I16x8UConvertI8x16Low ) \ <nl> V ( I16x8UConvertI8x16High , kMips64I16x8UConvertI8x16High ) \ <nl> V ( I16x8Abs , kMips64I16x8Abs ) \ <nl> + V ( I16x8BitMask , kMips64I16x8BitMask ) \ <nl> V ( I8x16Neg , kMips64I8x16Neg ) \ <nl> V ( I8x16Abs , kMips64I8x16Abs ) \ <nl> + V ( I8x16BitMask , kMips64I8x16BitMask ) \ <nl> V ( S128Not , kMips64S128Not ) \ <nl> V ( V32x4AnyTrue , kMips64V32x4AnyTrue ) \ <nl> V ( V32x4AllTrue , kMips64V32x4AllTrue ) \ <nl>
|
[ mips ] [ wasm - simd ] Bitmask instructions
|
v8/v8
|
93210c88c579dfab22c57d55385d91ed00f7b8bf
|
2020-06-04T01:23:28Z
|
mmm a / src / video_core / renderer_opengl / gl_rasterizer . cpp <nl> ppp b / src / video_core / renderer_opengl / gl_rasterizer . cpp <nl> void RasterizerOpenGL : : SetupTexture ( u32 binding , const Tegra : : Texture : : FullTextu <nl> glBindTextureUnit ( binding , 0 ) ; <nl> return ; <nl> } <nl> - glBindTextureUnit ( binding , view - > GetTexture ( ) ) ; <nl> - <nl> - if ( view - > GetSurfaceParams ( ) . IsBuffer ( ) ) { <nl> - return ; <nl> + const GLuint handle = view - > GetTexture ( texture . tic . x_source , texture . tic . y_source , <nl> + texture . tic . z_source , texture . tic . w_source ) ; <nl> + glBindTextureUnit ( binding , handle ) ; <nl> + if ( ! view - > GetSurfaceParams ( ) . IsBuffer ( ) ) { <nl> + glBindSampler ( binding , sampler_cache . GetSampler ( texture . tsc ) ) ; <nl> } <nl> - / / Apply swizzle to textures that are not buffers . <nl> - view - > ApplySwizzle ( texture . tic . x_source , texture . tic . y_source , texture . tic . z_source , <nl> - texture . tic . w_source ) ; <nl> - <nl> - glBindSampler ( binding , sampler_cache . GetSampler ( texture . tsc ) ) ; <nl> } <nl> <nl> void RasterizerOpenGL : : SetupDrawImages ( std : : size_t stage_index , const Shader & shader ) { <nl> void RasterizerOpenGL : : SetupImage ( u32 binding , const Tegra : : Texture : : TICEntry & t <nl> glBindImageTexture ( binding , 0 , 0 , GL_FALSE , 0 , GL_READ_ONLY , GL_R8 ) ; <nl> return ; <nl> } <nl> - if ( ! tic . IsBuffer ( ) ) { <nl> - view - > ApplySwizzle ( tic . x_source , tic . y_source , tic . z_source , tic . w_source ) ; <nl> - } <nl> if ( entry . is_written ) { <nl> view - > MarkAsModified ( texture_cache . Tick ( ) ) ; <nl> } <nl> - glBindImageTexture ( binding , view - > GetTexture ( ) , 0 , GL_TRUE , 0 , GL_READ_WRITE , <nl> - view - > GetFormat ( ) ) ; <nl> + const GLuint handle = view - > GetTexture ( tic . x_source , tic . y_source , tic . z_source , tic . w_source ) ; <nl> + glBindImageTexture ( binding , handle , 0 , GL_TRUE , 0 , GL_READ_WRITE , view - > GetFormat ( ) ) ; <nl> } <nl> <nl> void RasterizerOpenGL : : SyncViewport ( ) { <nl> mmm a / src / video_core / renderer_opengl / gl_texture_cache . cpp <nl> ppp b / src / video_core / renderer_opengl / gl_texture_cache . cpp <nl> MICROPROFILE_DEFINE ( OpenGL_Texture_Buffer_Copy , " OpenGL " , " Texture Buffer Copy " , <nl> namespace { <nl> <nl> struct FormatTuple { <nl> - GLint internal_format ; <nl> + GLenum internal_format ; <nl> GLenum format = GL_NONE ; <nl> GLenum type = GL_NONE ; <nl> } ; <nl> OGLTexture CreateTexture ( const SurfaceParams & params , GLenum target , GLenum inte <nl> return texture ; <nl> } <nl> <nl> + constexpr u32 EncodeSwizzle ( SwizzleSource x_source , SwizzleSource y_source , SwizzleSource z_source , <nl> + SwizzleSource w_source ) { <nl> + return ( static_cast < u32 > ( x_source ) < < 24 ) | ( static_cast < u32 > ( y_source ) < < 16 ) | <nl> + ( static_cast < u32 > ( z_source ) < < 8 ) | static_cast < u32 > ( w_source ) ; <nl> + } <nl> + <nl> } / / Anonymous namespace <nl> <nl> CachedSurface : : CachedSurface ( const GPUVAddr gpu_addr , const SurfaceParams & params , <nl> void CachedSurface : : DecorateSurfaceName ( ) { <nl> } <nl> <nl> void CachedSurfaceView : : DecorateViewName ( GPUVAddr gpu_addr , std : : string prefix ) { <nl> - LabelGLObject ( GL_TEXTURE , texture_view . handle , gpu_addr , prefix ) ; <nl> + LabelGLObject ( GL_TEXTURE , main_view . handle , gpu_addr , prefix ) ; <nl> } <nl> <nl> View CachedSurface : : CreateView ( const ViewParams & view_key ) { <nl> View CachedSurface : : CreateViewInner ( const ViewParams & view_key , const bool is_pr <nl> } <nl> <nl> CachedSurfaceView : : CachedSurfaceView ( CachedSurface & surface , const ViewParams & params , <nl> - const bool is_proxy ) <nl> - : VideoCommon : : ViewBase ( params ) , surface { surface } , is_proxy { is_proxy } { <nl> - target = GetTextureTarget ( params . target ) ; <nl> - format = GetFormatTuple ( surface . GetSurfaceParams ( ) . pixel_format ) . internal_format ; <nl> + bool is_proxy ) <nl> + : VideoCommon : : ViewBase ( params ) , surface { surface } , <nl> + format { GetFormatTuple ( surface . GetSurfaceParams ( ) . pixel_format ) . internal_format } , <nl> + target { GetTextureTarget ( params . target ) } , is_proxy { is_proxy } { <nl> if ( ! is_proxy ) { <nl> - texture_view = CreateTextureView ( ) ; <nl> + main_view = CreateTextureView ( ) ; <nl> } <nl> - swizzle = EncodeSwizzle ( SwizzleSource : : R , SwizzleSource : : G , SwizzleSource : : B , SwizzleSource : : A ) ; <nl> } <nl> <nl> CachedSurfaceView : : ~ CachedSurfaceView ( ) = default ; <nl> void CachedSurfaceView : : Attach ( GLenum attachment , GLenum target ) const { <nl> } <nl> } <nl> <nl> - void CachedSurfaceView : : ApplySwizzle ( SwizzleSource x_source , SwizzleSource y_source , <nl> + GLuint CachedSurfaceView : : GetTexture ( SwizzleSource x_source , SwizzleSource y_source , <nl> SwizzleSource z_source , SwizzleSource w_source ) { <nl> - u32 new_swizzle = EncodeSwizzle ( x_source , y_source , z_source , w_source ) ; <nl> - if ( new_swizzle = = swizzle ) <nl> - return ; <nl> - swizzle = new_swizzle ; <nl> - const std : : array gl_swizzle = { GetSwizzleSource ( x_source ) , GetSwizzleSource ( y_source ) , <nl> - GetSwizzleSource ( z_source ) , GetSwizzleSource ( w_source ) } ; <nl> - const GLuint handle = GetTexture ( ) ; <nl> - const PixelFormat format = surface . GetSurfaceParams ( ) . pixel_format ; <nl> - switch ( format ) { <nl> + if ( GetSurfaceParams ( ) . IsBuffer ( ) ) { <nl> + return GetTexture ( ) ; <nl> + } <nl> + const u32 new_swizzle = EncodeSwizzle ( x_source , y_source , z_source , w_source ) ; <nl> + if ( current_swizzle = = new_swizzle ) { <nl> + return current_view ; <nl> + } <nl> + current_swizzle = new_swizzle ; <nl> + <nl> + const auto [ entry , is_cache_miss ] = view_cache . try_emplace ( new_swizzle ) ; <nl> + OGLTextureView & view = entry - > second ; <nl> + if ( ! is_cache_miss ) { <nl> + current_view = view . handle ; <nl> + return view . handle ; <nl> + } <nl> + view = CreateTextureView ( ) ; <nl> + current_view = view . handle ; <nl> + <nl> + std : : array swizzle { x_source , y_source , z_source , w_source } ; <nl> + <nl> + switch ( const PixelFormat format = GetSurfaceParams ( ) . pixel_format ) { <nl> case PixelFormat : : Z24S8 : <nl> case PixelFormat : : Z32FS8 : <nl> case PixelFormat : : S8Z24 : <nl> - glTextureParameteri ( handle , GL_DEPTH_STENCIL_TEXTURE_MODE , <nl> + UNIMPLEMENTED_IF ( x_source ! = SwizzleSource : : R & & x_source ! = SwizzleSource : : G ) ; <nl> + glTextureParameteri ( view . handle , GL_DEPTH_STENCIL_TEXTURE_MODE , <nl> GetComponent ( format , x_source = = SwizzleSource : : R ) ) ; <nl> + <nl> + / / Make sure we sample the first component <nl> + std : : transform ( swizzle . begin ( ) , swizzle . end ( ) , swizzle . begin ( ) , [ ] ( SwizzleSource value ) { <nl> + return value = = SwizzleSource : : G ? SwizzleSource : : R : value ; <nl> + } ) ; <nl> + [ [ fallthrough ] ] ; <nl> + default : { <nl> + const std : : array gl_swizzle = { GetSwizzleSource ( swizzle [ 0 ] ) , GetSwizzleSource ( swizzle [ 1 ] ) , <nl> + GetSwizzleSource ( swizzle [ 2 ] ) , GetSwizzleSource ( swizzle [ 3 ] ) } ; <nl> + glTextureParameteriv ( view . handle , GL_TEXTURE_SWIZZLE_RGBA , gl_swizzle . data ( ) ) ; <nl> break ; <nl> - default : <nl> - glTextureParameteriv ( handle , GL_TEXTURE_SWIZZLE_RGBA , gl_swizzle . data ( ) ) ; <nl> - break ; <nl> } <nl> + } <nl> + return view . handle ; <nl> } <nl> <nl> OGLTextureView CachedSurfaceView : : CreateTextureView ( ) const { <nl> mmm a / src / video_core / renderer_opengl / gl_texture_cache . h <nl> ppp b / src / video_core / renderer_opengl / gl_texture_cache . h <nl> class CachedSurfaceView final : public VideoCommon : : ViewBase { <nl> / / / Attaches this texture view to the current bound GL_DRAW_FRAMEBUFFER <nl> void Attach ( GLenum attachment , GLenum target ) const ; <nl> <nl> - void ApplySwizzle ( Tegra : : Texture : : SwizzleSource x_source , <nl> + GLuint GetTexture ( Tegra : : Texture : : SwizzleSource x_source , <nl> Tegra : : Texture : : SwizzleSource y_source , <nl> Tegra : : Texture : : SwizzleSource z_source , <nl> Tegra : : Texture : : SwizzleSource w_source ) ; <nl> class CachedSurfaceView final : public VideoCommon : : ViewBase { <nl> if ( is_proxy ) { <nl> return surface . GetTexture ( ) ; <nl> } <nl> - return texture_view . handle ; <nl> + return main_view . handle ; <nl> } <nl> <nl> GLenum GetFormat ( ) const { <nl> class CachedSurfaceView final : public VideoCommon : : ViewBase { <nl> } <nl> <nl> private : <nl> - u32 EncodeSwizzle ( Tegra : : Texture : : SwizzleSource x_source , <nl> - Tegra : : Texture : : SwizzleSource y_source , <nl> - Tegra : : Texture : : SwizzleSource z_source , <nl> - Tegra : : Texture : : SwizzleSource w_source ) const { <nl> - return ( static_cast < u32 > ( x_source ) < < 24 ) | ( static_cast < u32 > ( y_source ) < < 16 ) | <nl> - ( static_cast < u32 > ( z_source ) < < 8 ) | static_cast < u32 > ( w_source ) ; <nl> - } <nl> - <nl> OGLTextureView CreateTextureView ( ) const ; <nl> <nl> CachedSurface & surface ; <nl> - GLenum target { } ; <nl> - GLenum format { } ; <nl> + const GLenum format ; <nl> + const GLenum target ; <nl> + const bool is_proxy ; <nl> + <nl> + std : : unordered_map < u32 , OGLTextureView > view_cache ; <nl> + OGLTextureView main_view ; <nl> <nl> - OGLTextureView texture_view ; <nl> - u32 swizzle { } ; <nl> - bool is_proxy { } ; <nl> + / / Use an invalid default so it always fails the comparison test <nl> + u32 current_swizzle = 0xffffffff ; <nl> + GLuint current_view = 0 ; <nl> } ; <nl> <nl> class TextureCacheOpenGL final : public TextureCacheBase { <nl> mmm a / src / video_core / renderer_vulkan / vk_texture_cache . cpp <nl> ppp b / src / video_core / renderer_vulkan / vk_texture_cache . cpp <nl> CachedSurfaceView : : ~ CachedSurfaceView ( ) = default ; <nl> <nl> VkImageView CachedSurfaceView : : GetHandle ( SwizzleSource x_source , SwizzleSource y_source , <nl> SwizzleSource z_source , SwizzleSource w_source ) { <nl> - const u32 swizzle = EncodeSwizzle ( x_source , y_source , z_source , w_source ) ; <nl> - if ( last_image_view & & last_swizzle = = swizzle ) { <nl> + const u32 new_swizzle = EncodeSwizzle ( x_source , y_source , z_source , w_source ) ; <nl> + if ( last_image_view & & last_swizzle = = new_swizzle ) { <nl> return last_image_view ; <nl> } <nl> - last_swizzle = swizzle ; <nl> + last_swizzle = new_swizzle ; <nl> <nl> - const auto [ entry , is_cache_miss ] = view_cache . try_emplace ( swizzle ) ; <nl> + const auto [ entry , is_cache_miss ] = view_cache . try_emplace ( new_swizzle ) ; <nl> auto & image_view = entry - > second ; <nl> if ( ! is_cache_miss ) { <nl> return last_image_view = * image_view ; <nl> } <nl> <nl> - auto swizzle_x = MaxwellToVK : : SwizzleSource ( x_source ) ; <nl> - auto swizzle_y = MaxwellToVK : : SwizzleSource ( y_source ) ; <nl> - auto swizzle_z = MaxwellToVK : : SwizzleSource ( z_source ) ; <nl> - auto swizzle_w = MaxwellToVK : : SwizzleSource ( w_source ) ; <nl> - <nl> + std : : array swizzle { MaxwellToVK : : SwizzleSource ( x_source ) , MaxwellToVK : : SwizzleSource ( y_source ) , <nl> + MaxwellToVK : : SwizzleSource ( z_source ) , MaxwellToVK : : SwizzleSource ( w_source ) } ; <nl> if ( params . pixel_format = = VideoCore : : Surface : : PixelFormat : : A1B5G5R5U ) { <nl> / / A1B5G5R5 is implemented as A1R5G5B5 , we have to change the swizzle here . <nl> - std : : swap ( swizzle_x , swizzle_z ) ; <nl> + std : : swap ( swizzle [ 0 ] , swizzle [ 2 ] ) ; <nl> } <nl> <nl> / / Games can sample depth or stencil values on textures . This is decided by the swizzle value on <nl> VkImageView CachedSurfaceView : : GetHandle ( SwizzleSource x_source , SwizzleSource y <nl> UNIMPLEMENTED ( ) ; <nl> } <nl> <nl> - / / Vulkan doesn ' t seem to understand swizzling of a depth stencil image , use identity <nl> - swizzle_x = VK_COMPONENT_SWIZZLE_R ; <nl> - swizzle_y = VK_COMPONENT_SWIZZLE_G ; <nl> - swizzle_z = VK_COMPONENT_SWIZZLE_B ; <nl> - swizzle_w = VK_COMPONENT_SWIZZLE_A ; <nl> + / / Make sure we sample the first component <nl> + std : : transform ( <nl> + swizzle . begin ( ) , swizzle . end ( ) , swizzle . begin ( ) , [ ] ( VkComponentSwizzle component ) { <nl> + return component = = VK_COMPONENT_SWIZZLE_G ? VK_COMPONENT_SWIZZLE_R : component ; <nl> + } ) ; <nl> } <nl> <nl> VkImageViewCreateInfo ci ; <nl> VkImageView CachedSurfaceView : : GetHandle ( SwizzleSource x_source , SwizzleSource y <nl> ci . image = surface . GetImageHandle ( ) ; <nl> ci . viewType = image_view_type ; <nl> ci . format = surface . GetImage ( ) . GetFormat ( ) ; <nl> - ci . components = { swizzle_x , swizzle_y , swizzle_z , swizzle_w } ; <nl> + ci . components = { swizzle [ 0 ] , swizzle [ 1 ] , swizzle [ 2 ] , swizzle [ 3 ] } ; <nl> ci . subresourceRange . aspectMask = aspect ; <nl> ci . subresourceRange . baseMipLevel = base_level ; <nl> ci . subresourceRange . levelCount = num_levels ; <nl> mmm a / src / video_core / texture_cache / texture_cache . h <nl> ppp b / src / video_core / texture_cache / texture_cache . h <nl> class TextureCache { <nl> params . target = target ; <nl> params . is_tiled = false ; <nl> params . srgb_conversion = false ; <nl> - params . is_layered = false ; <nl> + params . is_layered = <nl> + target = = SurfaceTarget : : Texture1DArray | | target = = SurfaceTarget : : Texture2DArray | | <nl> + target = = SurfaceTarget : : TextureCubemap | | target = = SurfaceTarget : : TextureCubeArray ; <nl> params . block_width = 0 ; <nl> params . block_height = 0 ; <nl> params . block_depth = 0 ; <nl>
|
Merge pull request from ReinUsesLisp / depth - sampling
|
yuzu-emu/yuzu
|
1bb3122c1f139420113ac2eb01bcf73890f52814
|
2020-05-29T03:33:38Z
|
mmm a / hphp / hack / src / utils / core / dune <nl> ppp b / hphp / hack / src / utils / core / dune <nl> <nl> ( c_flags ( : standard <nl> ( : include config / build - timestamp - opt ) ) ) <nl> ( libraries <nl> + base <nl> string <nl> imported_core <nl> hh_json <nl> mmm a / hphp / hack / src / utils / core / hh_core . ml <nl> ppp b / hphp / hack / src / utils / core / hh_core . ml <nl> <nl> * ) <nl> <nl> module List = struct <nl> - include Core_list <nl> + include Base . List <nl> <nl> let rec fold_left_env env l ~ init ~ f = <nl> match l with <nl> module List = struct <nl> let filter_map_env env xs ~ f = <nl> let ( env , l ) = rev_map_env env xs ~ f in <nl> ( env , rev_filter_map l ~ f : ( fun x - > x ) ) <nl> - <nl> - let for_all2 = List . for_all2 <nl> - <nl> - let same_length_and_for_all2 ~ f l1 l2 = <nl> - List . length l1 = List . length l2 & & for_all2 f l1 l2 <nl> end <nl> mmm a / hphp / hack / src / utils / core / hh_core . mli <nl> ppp b / hphp / hack / src / utils / core / hh_core . mli <nl> clean it up manually , and then delete this comment once the interface is in <nl> shape . * ) <nl> <nl> module List : sig <nl> - include module type of Core_list <nl> + include module type of Base . List <nl> <nl> val fold_left_env : <nl> ' a - > ' b list - > init : ' c - > f : ( ' a - > ' c - > ' b - > ' a * ' c ) - > ' a * ' c <nl> module List : sig <nl> <nl> val filter_map_env : <nl> ' a - > ' b list - > f : ( ' a - > ' b - > ' a * ' c option ) - > ' a * ' c list <nl> - <nl> - val for_all2 : f : ( ' a - > ' b - > bool ) - > ' a list - > ' b list - > bool <nl> - <nl> - val same_length_and_for_all2 : <nl> - f : ( ' a - > ' b - > bool ) - > ' a list - > ' b list - > bool <nl> end <nl> mmm a / hphp / hack / src / utils / hh_json / hh_json . ml <nl> ppp b / hphp / hack / src / utils / hh_json / hh_json . ml <nl> Caveats : <nl> ( + ) Numbers are just stored as strings <nl> * ) <nl> <nl> - module List = Core_list <nl> + module List = Base . List <nl> <nl> type json = <nl> | JSON_Object of ( string * json ) list <nl> let string_of_file filename = <nl> ( * Writing JSON * ) <nl> <nl> let sort_object obj_entries = <nl> - List . sort ~ cmp : ( fun ( k1 , _ ) ( k2 , _ ) - > Pervasives . compare k1 k2 ) obj_entries <nl> + List . sort <nl> + ~ compare : ( fun ( k1 , _ ) ( k2 , _ ) - > Pervasives . compare k1 k2 ) <nl> + obj_entries <nl> <nl> module type Output_stream_intf = sig <nl> type t <nl> mmm a / hphp / hack / src / utils / hh_json / hh_json_helpers . ml <nl> ppp b / hphp / hack / src / utils / hh_json / hh_json_helpers . ml <nl> end <nl> module AdhocJsonHelpers = struct <nl> let try_get_val key json = <nl> let obj = Hh_json . get_object_exn json in <nl> - Core_list . Assoc . find obj key <nl> + Base . List . Assoc . find ~ equal : String . equal obj key <nl> <nl> let get_string_val key ? default json = <nl> let v = try_get_val key json in <nl> mmm a / hphp / hack / src / utils / lsp / dune <nl> ppp b / hphp / hack / src / utils / lsp / dune <nl> <nl> ( name lsp ) <nl> ( wrapped false ) <nl> ( libraries <nl> + base <nl> file_content <nl> file_url <nl> hh_json <nl> mmm a / hphp / hack / src / utils / lsp / lsp . ml <nl> ppp b / hphp / hack / src / utils / lsp / lsp . ml <nl> module CodeActionKind = struct <nl> ( * Create a new sub - kind of an existing kind * ) <nl> let sub_kind : t - > string - > t = <nl> let cons_to_end ( ss : string list ) ( s : string ) = <nl> - Core_list . ( fold_right ss ~ f : cons ~ init : [ s ] ) <nl> + Base . List . ( fold_right ss ~ f : cons ~ init : [ s ] ) <nl> in <nl> ( fun ( k , ks ) s - > ( k , cons_to_end ks s ) ) <nl> <nl> mmm a / hphp / hack / src / utils / lsp / lsp_helpers . ml <nl> ppp b / hphp / hack / src / utils / lsp / lsp_helpers . ml <nl> let update_diagnostics_due_to_change <nl> | _ - > None <nl> in <nl> let replaces = <nl> - Core_list . map change . DidChange . contentChanges ~ f : replace_of_change <nl> + Base . List . map change . DidChange . contentChanges ~ f : replace_of_change <nl> in <nl> let apply_all_replaces diagnostic = <nl> - Core_list . fold replaces ~ init : ( Some diagnostic ) ~ f : apply_replace <nl> + Base . List . fold replaces ~ init : ( Some diagnostic ) ~ f : apply_replace <nl> in <nl> - Core_list . filter_map diagnostics ~ f : apply_all_replaces ) <nl> + Base . List . filter_map diagnostics ~ f : apply_all_replaces ) <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * Accessors * ) <nl> mmm a / hphp / hack / src / utils / scheduler . ml <nl> ppp b / hphp / hack / src / utils / scheduler . ml <nl> struct <nl> in <nl> let ready_jobs = ready_funs @ ready_channels @ ! env . ready_jobs in <nl> let ready_jobs = <nl> - List . sort ready_jobs ~ cmp : ( fun x y - > x . priority - y . priority ) <nl> + List . sort ready_jobs ~ compare : ( fun x y - > x . priority - y . priority ) <nl> in <nl> env : = { ready_jobs ; waiting_jobs = waiting_funs @ waiting_channels } <nl> <nl> mmm a / hphp / hack / src / utils / sys / sys_utils . ml <nl> ppp b / hphp / hack / src / utils / sys / sys_utils . ml <nl> let append_file ~ file s = <nl> output_string chan s ; <nl> close_out chan <nl> <nl> - let write_strings_to_file ~ file ss = <nl> + let write_strings_to_file ~ file ( ss : string list ) = <nl> let chan = open_out_gen [ Open_wronly ; Open_creat ] 0o666 file in <nl> List . iter ~ f : ( output_string chan ) ss ; <nl> close_out chan <nl> mmm a / hphp / hack / src / utils / sys / tty . ml <nl> ppp b / hphp / hack / src / utils / sys / tty . ml <nl> let read_choice message choices = <nl> ( String . concat " | " ( List . map choices String_utils . string_of_char ) ) ; <nl> let choice = read_char ( ) in <nl> print_newline ( ) ; <nl> - if List . mem choices choice then <nl> + if List . mem ~ equal : Char . equal choices choice then <nl> choice <nl> else <nl> loop ( ) <nl> mmm a / hphp / hack / test / full_fidelity / full_fidelity_test_utils . ml <nl> ppp b / hphp / hack / test / full_fidelity / full_fidelity_test_utils . ml <nl> let tree_dump_node node = <nl> in <nl> aux 0 node <nl> <nl> - let tree_dump_list lst = <nl> + let tree_dump_list ( lst : PositionedSyntax . t list ) = <nl> List . concat_map ~ f : tree_dump_node lst | > String . concat " \ n " <nl> <nl> let printer w1 w2 s1 s2 = <nl> let adjust l1 l2 = <nl> let len = max ( List . length l1 ) ( List . length l2 ) in <nl> ( aux l1 len , aux l2 len ) <nl> <nl> - let dump_diff expected actual = <nl> + let dump_diff <nl> + ( expected : PositionedSyntax . t list ) ( actual : PositionedSyntax . t list ) = <nl> let l1 = List . concat_map ~ f : tree_dump_node expected in <nl> let l2 = List . concat_map ~ f : tree_dump_node actual in <nl> let ( l1 , l2 ) = adjust l1 l2 in <nl> mmm a / hphp / hack / test / integration_ml / test_get_dependent_classes . ml <nl> ppp b / hphp / hack / test / integration_ml / test_get_dependent_classes . ml <nl> let test ( ) = <nl> in <nl> let expected_dependent_classes = <nl> List . sort <nl> - ~ cmp : String . compare <nl> + ~ compare : String . compare <nl> [ <nl> " \ \ C " ; <nl> " \ \ D " ; <nl> mmm a / hphp / runtime / vm / verifier / fuzzer / nondet . ml <nl> ppp b / hphp / runtime / vm / verifier / fuzzer / nondet . ml <nl> let fmap = ( > > | ) <nl> <nl> let lift f l = l > > | f <nl> <nl> - let bind = Hh_core . List . bind <nl> + let bind lst f = Hh_core . List . bind lst ~ f <nl> <nl> let ( > > = ) = bind <nl> <nl>
|
Core_list - > Base . List
|
facebook/hhvm
|
0c6e7061ea1ee10eef660a9cebcd6c929cc1e775
|
2019-10-30T18:43:11Z
|
mmm a / src / dbg / commandline . cpp <nl> ppp b / src / dbg / commandline . cpp <nl> bool isCmdLineEmpty ( ) <nl> <nl> char * getCommandLineArgs ( ) <nl> { <nl> - char * commandLineArguments = NULL ; <nl> - char * extensionPtr = strchr ( commandLine , ' . ' ) ; <nl> - <nl> - if ( ! extensionPtr ) <nl> - return NULL ; <nl> - <nl> - commandLineArguments = strchr ( extensionPtr , ' ' ) ; <nl> - <nl> - if ( ! commandLineArguments ) <nl> - return NULL ; <nl> - <nl> - return ( commandLineArguments + 1 ) ; <nl> - <nl> + auto args = * commandLine = = ' \ " ' ? strchr ( commandLine + 1 , ' \ " ' ) : nullptr ; <nl> + args = strchr ( args ? args : commandLine , ' ' ) ; <nl> + return args ? args + 1 : nullptr ; <nl> } <nl> <nl> void CmdLineCacheSave ( JSON Root , const String & cacheFile ) <nl> mmm a / src / dbg / debugger . cpp <nl> ppp b / src / dbg / debugger . cpp <nl> static void debugLoopFunction ( void * lpParameter , bool attach ) <nl> char * commandLineArguments = NULL ; <nl> commandLineArguments = getCommandLineArgs ( ) ; <nl> <nl> - if ( commandLineArguments ) <nl> + if ( commandLineArguments & & * commandLineArguments ) <nl> init - > commandline = commandLineArguments ; <nl> } <nl> <nl>
|
DBG : fixed command line parsing ( closes issue )
|
x64dbg/x64dbg
|
6680096b86c85e5026c2edb48075fc78d8dfeda2
|
2017-05-01T23:38:23Z
|
mmm a / dbms / src / Functions / FunctionsArray . cpp <nl> ppp b / dbms / src / Functions / FunctionsArray . cpp <nl> <nl> # include < Interpreters / AggregationCommon . h > <nl> # include < Columns / ColumnTuple . h > <nl> # include < Columns / ColumnAggregateFunction . h > <nl> + # include < boost / iterator / counting_iterator . hpp > <nl> # include < tuple > <nl> # include < array > <nl> <nl> bool FunctionRange : : executeInternal ( Block & block , const IColumn * const arg , co <nl> IColumn : : Offset_t offset { } ; <nl> for ( const auto i : ext : : range ( 0 , in - > size ( ) ) ) <nl> { <nl> - std : : copy ( ext : : make_range_iterator ( T { } ) , ext : : make_range_iterator ( in_data [ i ] ) , & out_data [ offset ] ) ; <nl> + std : : copy ( boost : : counting_iterator ( T { } ) , boost : : counting_iterator ( in_data [ i ] ) , & out_data [ offset ] ) ; <nl> offset + = in_data [ i ] ; <nl> out_offsets [ i ] = offset ; <nl> } <nl> bool FunctionRange : : executeInternal ( Block & block , const IColumn * const arg , co <nl> IColumn : : Offset_t offset { } ; <nl> for ( const auto i : ext : : range ( 0 , in - > size ( ) ) ) <nl> { <nl> - std : : copy ( ext : : make_range_iterator ( T { } ) , ext : : make_range_iterator ( in_data ) , & out_data [ offset ] ) ; <nl> + std : : copy ( boost : : counting_iterator ( T { } ) , boost : : counting_iterator ( in_data ) , & out_data [ offset ] ) ; <nl> offset + = in_data ; <nl> out_offsets [ i ] = offset ; <nl> } <nl> mmm a / libs / libcommon / include / ext / make_array_n . h <nl> ppp b / libs / libcommon / include / ext / make_array_n . h <nl> <nl> * / <nl> namespace ext <nl> { <nl> - <nl> namespace detail <nl> { <nl> <nl> mmm a / libs / libcommon / include / ext / range . h <nl> ppp b / libs / libcommon / include / ext / range . h <nl> namespace ext <nl> template < typename T > <nl> using range_iterator = boost : : counting_iterator < T > ; <nl> <nl> - template < typename T > <nl> - using reverse_range_iterator = std : : reverse_iterator < range_iterator < T > > ; <nl> - <nl> / * * \ brief Range - based for loop adapter for ( reverse_ ) range_iterator . <nl> - * By and large should be in conjunction with ext : : range and ext : : reverse_range . * / <nl> - template < typename T , bool forward > <nl> + * By and large should be in conjunction with ext : : range and ext : : reverse_range . <nl> + * / <nl> + template < typename T > <nl> struct range_wrapper <nl> { <nl> using value_type = typename std : : remove_reference < T > : : type ; <nl> - using range_iterator_t = ext : : range_iterator < value_type > ; <nl> - using iterator = typename std : : conditional < forward , <nl> - range_iterator_t , <nl> - ext : : reverse_range_iterator < value_type > > : : type ; <nl> + using iterator = range_iterator < value_type > ; <nl> <nl> - value_type begin_ , end_ ; <nl> + value_type begin_ ; <nl> + value_type end_ ; <nl> <nl> - iterator begin ( ) const { return iterator ( range_iterator_t { begin_ } ) ; } <nl> - iterator end ( ) const { return iterator ( range_iterator_t { end_ } ) ; } <nl> + iterator begin ( ) const { return iterator ( begin_ ) ; } <nl> + iterator end ( ) const { return iterator ( end_ ) ; } <nl> } ; <nl> <nl> / * * \ brief Constructs range_wrapper for forward - iteration over [ begin , end ) in range - based for loop . <nl> * Usage example : <nl> * for ( const auto i : ext : : range ( 0 , 4 ) ) print ( i ) ; <nl> * Output : <nl> - * 0 1 2 3 * / <nl> - template < typename T1 , typename T2 > <nl> - inline ext : : range_wrapper < typename std : : common_type < T1 , T2 > : : type , true > range ( T1 begin , T2 end ) <nl> + * 0 1 2 3 <nl> + * / <nl> + template < typename T1 , typename T2 > <nl> + inline range_wrapper < typename std : : common_type < T1 , T2 > : : type > range ( T1 begin , T2 end ) <nl> { <nl> using common_type = typename std : : common_type < T1 , T2 > : : type ; <nl> return { static_cast < common_type > ( begin ) , static_cast < common_type > ( end ) } ; <nl> } <nl> - <nl> - / * * \ brief Constructs range_wrapper for backward - iteration over [ begin , end ) in range - based for loop . <nl> - * Usage example : <nl> - * for ( const auto i : ext : : reverse_range ( 0 , 4 ) ) print ( i ) ; <nl> - * Output : <nl> - * 3 2 1 0 * / <nl> - template < typename T1 , typename T2 > <nl> - inline ext : : range_wrapper < typename std : : common_type < T1 , T2 > : : type , false > reverse_range ( T1 begin , T2 end ) <nl> - { <nl> - using common_type = typename std : : common_type < T1 , T2 > : : type ; <nl> - return { static_cast < common_type > ( end ) , static_cast < common_type > ( begin ) } ; <nl> - } <nl> - <nl> - template < typename T > <nl> - inline ext : : range_iterator < T > make_range_iterator ( const T value ) <nl> - { <nl> - return { value } ; <nl> - } <nl> } <nl>
|
Removed useless code [ # CLICKHOUSE - 31 ] .
|
ClickHouse/ClickHouse
|
3ddea6b2608aeade5158afe5b51fac929630da72
|
2017-06-13T04:14:23Z
|
deleted file mode 100644 <nl> index ecd85eaa72 . . 0000000000 <nl> mmm a / vnpy / api / xtp / vnxtp / include / brigand / algorithms / transform . hpp <nl> ppp / dev / null <nl> <nl> - / * ! <nl> - @ file <nl> - <nl> - @ copyright Edouard Alligand and Joel Falcou 2015 - 2017 <nl> - ( See accompanying file LICENSE . md or copy at http : / / boost . org / LICENSE_1_0 . txt ) <nl> - * / <nl> - # ifndef BOOST_BRIGAND_ALGORITHMS_TRANSFORM_HPP <nl> - # define BOOST_BRIGAND_ALGORITHMS_TRANSFORM_HPP <nl> - <nl> - # include < brigand / functions / lambda / apply . hpp > <nl> - # include < brigand / sequences / back . hpp > <nl> - # include < brigand / sequences / filled_list . hpp > <nl> - # include < brigand / sequences / size . hpp > <nl> - <nl> - namespace brigand <nl> - { <nl> - namespace detail <nl> - { <nl> - template < class L1 , class L2 > <nl> - struct rot90 ; <nl> - <nl> - template < class . . . L1 , template < class . . . > class S1 , class . . . T1 , template < class . . . > class S2 , <nl> - class . . . T2 , template < class . . . > class S3 , class . . . T3 , template < class . . . > class S4 , <nl> - class . . . T4 , template < class . . . > class S5 , class . . . T5 , template < class . . . > class S6 , <nl> - class . . . T6 , template < class . . . > class S7 , class . . . T7 , template < class . . . > class S8 , <nl> - class . . . T8 , class . . . L2 > <nl> - struct rot90 < list < L1 . . . > , list < S1 < T1 . . . > , S2 < T2 . . . > , S3 < T3 . . . > , S4 < T4 . . . > , S5 < T5 . . . > , S6 < T6 . . . > , <nl> - S7 < T7 . . . > , S8 < T8 . . . > , L2 . . . > > <nl> - : rot90 < list < push_back < L1 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 > . . . > , list < L2 . . . > > <nl> - { <nl> - } ; <nl> - <nl> - template < class . . . L1 , template < class . . . > class S , class . . . T , class . . . L2 > <nl> - struct rot90 < list < L1 . . . > , list < S < T . . . > , L2 . . . > > : rot90 < list < push_back < L1 , T > . . . > , list < L2 . . . > > <nl> - { <nl> - } ; <nl> - <nl> - template < class L1 > <nl> - struct rot90 < L1 , list < > > <nl> - { <nl> - using type = L1 ; <nl> - } ; <nl> - <nl> - template < class Func , class Seq1 , class Seq2 , class Seqs > <nl> - struct transform_impl ; <nl> - <nl> - template < class F , class T1 , class T2 , class Seq > <nl> - struct transform_apply ; <nl> - <nl> - template < class F , class T1 , class T2 , class . . . Ts > <nl> - struct transform_apply < F , T1 , T2 , list < Ts . . . > > <nl> - { <nl> - using type = brigand : : apply < F , T1 , T2 , Ts . . . > ; <nl> - } ; <nl> - <nl> - template < class Func , template < class . . . > class Seq1 , class . . . T1 , <nl> - template < class . . . > class Seq2 , class . . . T2 , class . . . Seqs > <nl> - struct transform_impl < Func , Seq1 < T1 . . . > , Seq2 < T2 . . . > , list < Seqs . . . > > <nl> - { <nl> - using type = Seq1 < typename transform_apply < Func , T1 , T2 , Seqs > : : type . . . > ; <nl> - } ; <nl> - <nl> - template < unsigned int N , class Seq1 , class Seq2 , class . . . FuncOrSeqs > <nl> - struct transform : transform_impl < back < list < FuncOrSeqs . . . > > , Seq1 , Seq2 , <nl> - typename rot90 < filled_list < list < > , size < Seq1 > : : value > , <nl> - pop_back < list < FuncOrSeqs . . . > > > : : type > <nl> - { <nl> - } ; <nl> - <nl> - template < template < class . . . > class Seq , class . . . T , class Func > <nl> - struct transform < 0 , Seq < T . . . > , Func > <nl> - { <nl> - using type = Seq < brigand : : apply < Func , T > . . . > ; <nl> - } ; <nl> - <nl> - / / fast track for eager <nl> - template < template < class . . . > class Seq , class . . . T , template < typename . . . > class Func > <nl> - struct transform < 0 , Seq < T . . . > , bind < Func , _1 > > <nl> - { <nl> - using type = Seq < Func < T > . . . > ; <nl> - } ; <nl> - <nl> - / / fast track for lazy <nl> - template < template < class . . . > class Seq , class . . . T , template < typename . . . > class Func > <nl> - struct transform < 0 , Seq < T . . . > , Func < _1 > > <nl> - { <nl> - using type = Seq < typename Func < T > : : type . . . > ; <nl> - } ; <nl> - <nl> - template < template < class . . . > class Seq1 , class . . . T1 , template < class . . . > class Seq2 , <nl> - class . . . T2 , class Func > <nl> - struct transform < 1 , Seq1 < T1 . . . > , Seq2 < T2 . . . > , Func > <nl> - { <nl> - using type = Seq1 < brigand : : apply < Func , T1 , T2 > . . . > ; <nl> - } ; <nl> - } <nl> - <nl> - namespace lazy <nl> - { <nl> - template < typename Sequence1 , typename OpSeq1 , typename . . . OpSeq2 > <nl> - struct transform : detail : : transform < sizeof . . . ( OpSeq2 ) , Sequence1 , OpSeq1 , OpSeq2 . . . > <nl> - { <nl> - } ; <nl> - } <nl> - <nl> - / / Main transform entry point <nl> - template < typename Sequence1 , typename OpSeq1 , typename . . . OpSeq2 > <nl> - using transform = typename detail : : transform < sizeof . . . ( OpSeq2 ) , Sequence1 , OpSeq1 , OpSeq2 . . . > : : type ; <nl> - } <nl> - # endif <nl>
|
Delete transform . hpp
|
vnpy/vnpy
|
5d2a91ed3f0484a8f1bccd9f33bf0b99155a7136
|
2020-02-24T13:49:32Z
|
mmm a / doc / statuscodes . md <nl> ppp b / doc / statuscodes . md <nl> situations in which they are generated . <nl> | Error parsing response proto | INTERNAL | Client | <nl> | Error parsing request proto | INTERNAL | Server | <nl> | Sent or received message was larger than configured limit | RESOURCE_EXHAUSTED | Both | <nl> - | Keepalive watchdog times out | INTERNAL | Both | <nl> + | Keepalive watchdog times out | UNAVAILABLE | Both | <nl> <nl> The following status codes are never generated by the library : <nl> - INVALID_ARGUMENT <nl>
|
Make changes to doc
|
grpc/grpc
|
bb872692b7c0acb6263842f6e6e9549f5642aa09
|
2018-10-02T21:41:20Z
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.