diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / bindings / python / cntk / __init__ . py <nl> ppp b / bindings / python / cntk / __init__ . py <nl> <nl> from . import cntk_py <nl> <nl> from . train import * <nl> + <nl> from . learner import * <nl> from . initializer import * <nl> from . utils import * <nl> <nl> from . debug import save_as_legacy_model <nl> from . device import * <nl> from . layers import * <nl> - from . distributed import * <nl> from . sample_installer import install_samples <nl> <nl> DATATYPE = np . float32 <nl> mmm a / bindings / python / cntk / train / __init__ . py <nl> ppp b / bindings / python / cntk / train / __init__ . py <nl> <nl> <nl> from . trainer import * <nl> from . training_session import * <nl> + from . distributed import * <nl> similarity index 98 % <nl> rename from bindings / python / cntk / distributed . py <nl> rename to bindings / python / cntk / train / distributed . py <nl> mmm a / bindings / python / cntk / distributed . py <nl> ppp b / bindings / python / cntk / train / distributed . py <nl> <nl> # for full license information . <nl> # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> - from . import cntk_py <nl> - from . train import trainer <nl> - from . utils import typemap <nl> + from . . import cntk_py <nl> + from . . train import trainer <nl> + from . . utils import typemap <nl> <nl> # Preload libmpi . so . 12 for non - Windows platform to work around MPI_Init failure bug <nl> # https : / / xrunhprof . wordpress . com / 2014 / 11 / 04 / an - openmpi - python - and - dlopen - issue / <nl> mmm a / bindings / python / cntk / utils / swig_helper . py <nl> ppp b / bindings / python / cntk / utils / swig_helper . py <nl> def map_if_possible ( obj ) : <nl> from cntk . train . training_session import TrainingSession <nl> from cntk . io import MinibatchSource , MinibatchData , StreamConfiguration <nl> from cntk . axis import Axis <nl> - from cntk . distributed import WorkerDescriptor , Communicator , DistributedLearner <nl> + from cntk . train . distributed import WorkerDescriptor , Communicator , DistributedLearner <nl> from cntk import Value <nl> _typemap = { <nl> cntk_py . Variable : Variable , <nl> | Move distributed to train namespace . | microsoft/CNTK | 33052e72eda1a95d7d0ad9a15175a056a9abbd65 | 2017-03-02T21:59:15Z |
mmm a / hphp / hack / src / parser / full_fidelity_parser_helpers . ml <nl> ppp b / hphp / hack / src / parser / full_fidelity_parser_helpers . ml <nl> module WithParser ( Parser : Parser_S ) = struct <nl> <nl> ( * Parse with parse_item while a condition is met . * ) <nl> let parse_list_while parser ( parse_item : Parser . t - > Parser . t * Parser . SC . r ) predicate = <nl> - let rec aux parser acc ( recent_lexer : Lexer . t option ) = <nl> + let rec aux parser acc = <nl> if peek_token_kind parser = TokenKind . EndOfFile | | <nl> not ( predicate parser ) <nl> then <nl> ( parser , acc ) <nl> else <nl> + let lexer_before = Parser . lexer parser in <nl> let ( parser , result ) = parse_item parser in <nl> ( * ERROR RECOVERY : If the item is was parsed as ' missing ' , then it means <nl> * the parser bailed out of that scope . So , pass on whatever ' s been <nl> * accumulated so far , but with a ' Missing ' SyntaxNode prepended . * ) <nl> if SC . is_missing result <nl> then ( parser , result : : acc ) <nl> - else let current_lexer = Some ( Parser . lexer parser ) in <nl> + else let current_lexer = Parser . lexer parser in <nl> ( * INFINITE LOOP PREVENTION : If parse_item does not actually make <nl> * progress , just bail <nl> * ) <nl> - if current_lexer = recent_lexer <nl> + if Lexer . start_offset lexer_before = Lexer . start_offset current_lexer & & <nl> + Lexer . end_offset lexer_before = Lexer . end_offset current_lexer <nl> then ( parser , result : : acc ) <nl> - else aux parser ( result : : acc ) current_lexer ( * Or if nothing ' s wrong , recurse . * ) <nl> + else aux parser ( result : : acc ) ( * Or if nothing ' s wrong , recurse . * ) <nl> in <nl> - let ( parser , items ) = aux parser [ ] None in <nl> + let ( parser , items ) = aux parser [ ] in <nl> make_list parser ( List . rev items ) <nl> <nl> let parse_terminated_list parser parse_item terminator = <nl> | Replace structural comparison of lexers with comparing start / end offsets | facebook/hhvm | 0d64be142a9f69f78d81a1e47ebd31acf9d30784 | 2018-07-13T16:27:30Z |
mmm a / src / network / ReactorThread . c <nl> ppp b / src / network / ReactorThread . c <nl> int swReactorThread_onReceive_buffer_check_eof ( swReactor * reactor , swEvent * even <nl> switch ( swConnection_error ( errno ) ) <nl> { <nl> case SW_ERROR : <nl> - swWarn ( " recv from connection [ fd = % d ] failed . Error : % s [ % d ] " , conn - > fd , strerror ( errno ) , errno ) ; <nl> + swSysError ( " recv from connection [ % d @ % d ] failed . " , event - > fd , reactor - > id ) ; <nl> return SW_OK ; <nl> case SW_CLOSE : <nl> goto close_fd ; <nl> int swReactorThread_onReceive_no_buffer ( swReactor * reactor , swEvent * event ) <nl> switch ( swConnection_error ( errno ) ) <nl> { <nl> case SW_ERROR : <nl> - swWarn ( " recv from connection [ fd = % d ] failed . Error : % s [ % d ] " , event - > fd , strerror ( errno ) , errno ) ; <nl> + swSysError ( " recv from connection [ % d @ % d ] failed . " , event - > fd , reactor - > id ) ; <nl> return SW_OK ; <nl> case SW_CLOSE : <nl> goto close_fd ; <nl> int swReactorThread_onReceive_buffer_check_length ( swReactor * reactor , swEvent * e <nl> switch ( swConnection_error ( errno ) ) <nl> { <nl> case SW_ERROR : <nl> - swWarn ( " recv from connection [ fd = % d ] failed . Error : % s [ % d ] " , conn - > fd , strerror ( errno ) , errno ) ; <nl> + swSysError ( " recv from connection [ % d @ % d ] failed . " , event - > fd , reactor - > id ) ; <nl> return SW_OK ; <nl> case SW_CLOSE : <nl> goto close_fd ; <nl> int swReactorThread_onReceive_http_request ( swReactor * reactor , swEvent * event ) <nl> switch ( swConnection_error ( errno ) ) <nl> { <nl> case SW_ERROR : <nl> - swWarn ( " recv from connection [ fd = % d ] failed . Error : % s [ % d ] " , conn - > fd , strerror ( errno ) , errno ) ; <nl> + swSysError ( " recv from connection [ % d @ % d ] failed . " , event - > fd , reactor - > id ) ; <nl> return SW_OK ; <nl> case SW_CLOSE : <nl> goto close_fd ; <nl> | Update reactor thread error message . | swoole/swoole-src | f51d4ebbf5a66fc0c351cc9158d9700cd86f8f37 | 2014-12-19T11:09:06Z |
mmm a / etc / perf . yml <nl> ppp b / etc / perf . yml <nl> functions : <nl> set - o verbose <nl> virtualenv . / venv <nl> source . / venv / bin / activate <nl> - pip install - r . . / dsi / requirements / analysis . txt <nl> python - u . . / dsi / analysis / compare . py - b stand . json - c node . json <nl> - command : " json . send " <nl> params : <nl> functions : <nl> set - v <nl> virtualenv . / venv <nl> source . / venv / bin / activate <nl> - pip install - r . . / dsi / requirements / analysis . txt <nl> + pip install argparse python - dateutil <nl> - command : json . get_history <nl> params : <nl> task : $ { task_name } <nl> | Revert " SERVER - 24919 : Perf . yml should consistently call pip install in venv " | mongodb/mongo | b3589be5ce8fe43b6f36a02fb80ed4aa358eee41 | 2016-07-07T00:30:10Z |
mmm a / src / heap / heap . cc <nl> ppp b / src / heap / heap . cc <nl> void Heap : : RegisterDeserializedObjectsForBlackAllocation ( <nl> Address addr = chunk . start ; <nl> while ( addr < chunk . end ) { <nl> HeapObject * obj = HeapObject : : FromAddress ( addr ) ; <nl> - / / There might be grey objects due to black to grey transitions in <nl> - / / incremental marking . E . g . see VisitNativeContextIncremental . <nl> - DCHECK ( ObjectMarking : : IsBlackOrGrey < IncrementalMarking : : kAtomicity > ( <nl> - obj , MarkingState : : Internal ( obj ) ) ) ; <nl> + / / Objects can have any color because incremental marking can <nl> + / / start in the middle of Heap : : ReserveSpace ( ) . <nl> if ( ObjectMarking : : IsBlack < IncrementalMarking : : kAtomicity > ( <nl> obj , MarkingState : : Internal ( obj ) ) ) { <nl> incremental_marking ( ) - > ProcessBlackAllocatedObject ( obj ) ; <nl> | [ heap ] Remove incorrect assert in RegisterDeserializedObjectsForBlackAllocation . | v8/v8 | d141367d1d997bbc10b43b92c02060bda690f984 | 2017-07-11T11:53:33Z |
mmm a / AUTHORS <nl> ppp b / AUTHORS <nl> a license to everyone to use it as detailed in LICENSE . ) <nl> * Timothy Trindle < titrindl @ microsoft . com > ( copyright owned by Microsoft , Inc . ) <nl> * Matthew Andres Moreno < m . more500 @ gmail . com > <nl> * Eric Mandel < eric @ cfa . harvard . edu > <nl> + * Anthony Catel < paraboul @ gmail . com > <nl> * Simon Cooper < simon . d . cooper @ hotmail . co . uk > <nl> * Amir Rasouli < arasouli91 @ gmail . com > <nl> mmm a / system / lib / gl / gl . c <nl> ppp b / system / lib / gl / gl . c <nl> GLAPI void APIENTRY emscripten_glGetInfoLog ( GLhandleARB obj , GLsizei maxLength , <nl> GLAPI void APIENTRY emscripten_glBindProgram ( GLenum target , GLuint program ) ; <nl> <nl> extern void * emscripten_webgl1_get_proc_address ( const char * name ) ; <nl> + extern void * emscripten_webgl1_ext_get_proc_address ( const char * name ) ; <nl> extern void * emscripten_webgl2_get_proc_address ( const char * name ) ; <nl> + extern void * emscripten_webgl2_ext_get_proc_address ( const char * name ) ; <nl> <nl> # ifdef LEGACY_GL_EMULATION <nl> <nl> for line in open ( ' a ' ) . readlines ( ) : <nl> / / behavior : different functionality is available under <nl> / / different vendor suffixes . In emscripten_GetProcAddress ( ) <nl> / / function , all these suffixes will be ignored when performing <nl> - / / the function pointer lookup . The functions <nl> - / / emscripten_webgl_get_proc_address ( ) , <nl> - / / emscripten_webgl1_get_proc_address ( ) and <nl> - / / emscripten_webgl2_get_proc_address ( ) however are " strict " <nl> - / / lookups , that provide WebGL specific function entry points that <nl> - / / look up the exact function name with suffixes . <nl> + / / the function pointer lookup . <nl> void * emscripten_GetProcAddress ( const char * name_ ) { <nl> char * name = malloc ( strlen ( name_ ) + 1 ) ; <nl> strcpy ( name , name_ ) ; <nl> void * emscripten_GetProcAddress ( const char * name_ ) { <nl> if ( end ) * end = 0 ; <nl> end = strstr ( name , " ANGLE " ) ; <nl> if ( end ) * end = 0 ; <nl> + end = strstr ( name , " WEBGL " ) ; <nl> + if ( end ) * end = 0 ; <nl> <nl> void * ptr = emscripten_webgl1_get_proc_address ( name ) ; <nl> <nl> + if ( ! ptr ) ptr = emscripten_webgl1_ext_get_proc_address ( name ) ; <nl> + <nl> # if LEGACY_GL_EMULATION <nl> if ( ! ptr ) ptr = emscripten_legacy_gl_emulation_GetProcAddress ( name ) ; <nl> # endif <nl> # if USE_WEBGL2 <nl> if ( ! ptr ) ptr = emscripten_webgl2_get_proc_address ( name ) ; <nl> + if ( ! ptr ) ptr = emscripten_webgl2_ext_get_proc_address ( name ) ; <nl> # endif <nl> <nl> free ( name ) ; <nl> mmm a / system / lib / gl / webgl1 . c <nl> ppp b / system / lib / gl / webgl1 . c <nl> RET_SYNC_GL_FUNCTION_3 ( EM_FUNC_SIG_VIII , void , glGetQueryObjectui64vEXT , GLenum , <nl> <nl> # endif / / ~ __EMSCRIPTEN_PTHREADS__ <nl> <nl> + void * emscripten_webgl1_ext_get_proc_address ( const char * name ) <nl> + { <nl> + RETURN_FN_WITH_SUFFIX ( glGenQueries , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDeleteQueries , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glIsQuery , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glBeginQuery , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glEndQuery , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glQueryCounter , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGetQueryiv , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGetQueryObjectiv , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGetQueryObjectuiv , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGetQueryObjecti64v , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGetQueryObjectui64v , EXT ) ; <nl> + <nl> + / / WebGL 1 , Extensions <nl> + RETURN_FN_WITH_SUFFIX ( glBindVertexArray , OES ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDeleteVertexArrays , OES ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGenVertexArrays , OES ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glIsVertexArray , OES ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawBuffers , WEBGL ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawArraysInstanced , ANGLE ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawElementsInstanced , ANGLE ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glVertexAttribDivisor , ANGLE ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGenQueries , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDeleteQueries , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glIsQuery , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glBeginQuery , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glEndQuery , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glQueryCounter , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGetQueryiv , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGetQueryObjectiv , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGetQueryObjectuiv , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGetQueryObjecti64v , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGetQueryObjectui64v , EXT ) ; <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> void * emscripten_webgl1_get_proc_address ( const char * name ) <nl> { <nl> RETURN_FN ( glActiveTexture ) ; <nl> mmm a / system / lib / gl / webgl1 . h <nl> ppp b / system / lib / gl / webgl1 . h <nl> extern pthread_key_t currentThreadOwnsItsWebGLContext ; <nl> <nl> / / When building with multithreading , return pointers to C functions that can perform proxying . <nl> # define RETURN_FN ( functionName ) if ( ! strcmp ( name , # functionName ) ) return functionName ; <nl> + # define RETURN_FN_WITH_SUFFIX ( functionName , suffix ) if ( ! strcmp ( name , # functionName ) ) return functionName # # suffix ; <nl> <nl> # else <nl> <nl> / / When building with singlethreading , return pointers to JS library layer so that C code ( Regal library ) <nl> / / can override them . <nl> # define RETURN_FN ( functionName ) if ( ! strcmp ( name , # functionName ) ) return emscripten_ # # functionName ; <nl> + # define RETURN_FN_WITH_SUFFIX ( functionName , suffix ) if ( ! strcmp ( name , # functionName ) ) return emscripten_ # # functionName # # suffix ; <nl> <nl> # endif <nl> mmm a / system / lib / gl / webgl2 . c <nl> ppp b / system / lib / gl / webgl2 . c <nl> GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES ( GLuint array ) { return glIsV <nl> GL_APICALL void GL_APIENTRY glDrawBuffersEXT ( GLsizei n , const GLenum * bufs ) { glDrawBuffers ( n , bufs ) ; } <nl> GL_APICALL void GL_APIENTRY glDrawBuffersWEBGL ( GLsizei n , const GLenum * bufs ) { glDrawBuffers ( n , bufs ) ; } <nl> <nl> + void * emscripten_webgl2_ext_get_proc_address ( const char * name ) <nl> + { <nl> + RETURN_FN_WITH_SUFFIX ( glVertexAttribDivisor , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glVertexAttribDivisor , ARB ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glVertexAttribDivisor , ANGLE ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawArraysInstanced , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawArraysInstanced , ARB ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawArraysInstanced , ANGLE ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawElementsInstanced , NV ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawElementsInstanced , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawElementsInstanced , ARB ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawElementsInstanced , ANGLE ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glBindVertexArray , OES ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDeleteVertexArrays , OES ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glGenVertexArrays , OES ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glIsVertexArray , OES ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawBuffers , EXT ) ; <nl> + RETURN_FN_WITH_SUFFIX ( glDrawBuffers , WEBGL ) ; <nl> + <nl> + return 0 ; <nl> + } <nl> + <nl> void * emscripten_webgl2_get_proc_address ( const char * name ) <nl> { <nl> RETURN_FN ( glReadBuffer ) ; <nl> | Fix emscripten_GetProcAddress with various suffixes ( ) | emscripten-core/emscripten | f8d9751855d78e36a78a30d007eeadebf01cc610 | 2019-05-02T22:24:28Z |
mmm a / BUILD <nl> ppp b / BUILD <nl> cc_library ( <nl> " src / core / surface / server . c " , <nl> " src / core / surface / server_chttp2 . c " , <nl> " src / core / surface / server_create . c " , <nl> + " src / core / surface / validate_metadata . c " , <nl> " src / core / surface / version . c " , <nl> " src / core / transport / byte_stream . c " , <nl> " src / core / transport / chttp2 / alpn . c " , <nl> cc_library ( <nl> " src / core / surface / server . c " , <nl> " src / core / surface / server_chttp2 . c " , <nl> " src / core / surface / server_create . c " , <nl> + " src / core / surface / validate_metadata . c " , <nl> " src / core / surface / version . c " , <nl> " src / core / transport / byte_stream . c " , <nl> " src / core / transport / chttp2 / alpn . c " , <nl> objc_library ( <nl> " src / core / surface / server . c " , <nl> " src / core / surface / server_chttp2 . c " , <nl> " src / core / surface / server_create . c " , <nl> + " src / core / surface / validate_metadata . c " , <nl> " src / core / surface / version . c " , <nl> " src / core / transport / byte_stream . c " , <nl> " src / core / transport / chttp2 / alpn . c " , <nl> mmm a / Makefile <nl> ppp b / Makefile <nl> LIBGRPC_SRC = \ <nl> src / core / surface / server . c \ <nl> src / core / surface / server_chttp2 . c \ <nl> src / core / surface / server_create . c \ <nl> + src / core / surface / validate_metadata . c \ <nl> src / core / surface / version . c \ <nl> src / core / transport / byte_stream . c \ <nl> src / core / transport / chttp2 / alpn . c \ <nl> LIBGRPC_UNSECURE_SRC = \ <nl> src / core / surface / server . c \ <nl> src / core / surface / server_chttp2 . c \ <nl> src / core / surface / server_create . c \ <nl> + src / core / surface / validate_metadata . c \ <nl> src / core / surface / version . c \ <nl> src / core / transport / byte_stream . c \ <nl> src / core / transport / chttp2 / alpn . c \ <nl> mmm a / binding . gyp <nl> ppp b / binding . gyp <nl> <nl> ' src / core / surface / server . c ' , <nl> ' src / core / surface / server_chttp2 . c ' , <nl> ' src / core / surface / server_create . c ' , <nl> + ' src / core / surface / validate_metadata . c ' , <nl> ' src / core / surface / version . c ' , <nl> ' src / core / transport / byte_stream . c ' , <nl> ' src / core / transport / chttp2 / alpn . c ' , <nl> mmm a / build . yaml <nl> ppp b / build . yaml <nl> filegroups : <nl> - src / core / surface / server . c <nl> - src / core / surface / server_chttp2 . c <nl> - src / core / surface / server_create . c <nl> + - src / core / surface / validate_metadata . c <nl> - src / core / surface / version . c <nl> - src / core / transport / byte_stream . c <nl> - src / core / transport / chttp2 / alpn . c <nl> mmm a / gRPC . podspec <nl> ppp b / gRPC . podspec <nl> Pod : : Spec . new do | s | <nl> ' src / core / surface / server . c ' , <nl> ' src / core / surface / server_chttp2 . c ' , <nl> ' src / core / surface / server_create . c ' , <nl> + ' src / core / surface / validate_metadata . c ' , <nl> ' src / core / surface / version . c ' , <nl> ' src / core / transport / byte_stream . c ' , <nl> ' src / core / transport / chttp2 / alpn . c ' , <nl> mmm a / grpc . gemspec <nl> ppp b / grpc . gemspec <nl> Gem : : Specification . new do | s | <nl> s . files + = % w ( src / core / surface / server . c ) <nl> s . files + = % w ( src / core / surface / server_chttp2 . c ) <nl> s . files + = % w ( src / core / surface / server_create . c ) <nl> + s . files + = % w ( src / core / surface / validate_metadata . c ) <nl> s . files + = % w ( src / core / surface / version . c ) <nl> s . files + = % w ( src / core / transport / byte_stream . c ) <nl> s . files + = % w ( src / core / transport / chttp2 / alpn . c ) <nl> mmm a / include / grpc / grpc . h <nl> ppp b / include / grpc / grpc . h <nl> <nl> / * <nl> * <nl> - * Copyright 2015 , Google Inc . <nl> + * Copyright 2015 - 2016 , Google Inc . <nl> * All rights reserved . <nl> * <nl> * Redistribution and use in source and binary forms , with or without <nl> void grpc_server_destroy ( grpc_server * server ) ; <nl> thread - safety issues raised by it should not be of concern . * / <nl> int grpc_tracer_set_enabled ( const char * name , int enabled ) ; <nl> <nl> + / * * Check whether a metadata key is legal ( will be accepted by core ) * / <nl> + int grpc_header_key_is_legal ( const char * key , size_t length ) ; <nl> + <nl> + / * * Check whether a non - binary metadata value is legal ( will be accepted by <nl> + core ) * / <nl> + int grpc_header_nonbin_value_is_legal ( const char * value , size_t length ) ; <nl> + <nl> + / * * Check whether a metadata key corresponds to a binary value * / <nl> + int grpc_is_binary_header ( const char * key , size_t length ) ; <nl> + <nl> # ifdef __cplusplus <nl> } <nl> # endif <nl> mmm a / package . json <nl> ppp b / package . json <nl> <nl> " src / core / surface / server . c " , <nl> " src / core / surface / server_chttp2 . c " , <nl> " src / core / surface / server_create . c " , <nl> + " src / core / surface / validate_metadata . c " , <nl> " src / core / surface / version . c " , <nl> " src / core / transport / byte_stream . c " , <nl> " src / core / transport / chttp2 / alpn . c " , <nl> mmm a / src / core / surface / call . c <nl> ppp b / src / core / surface / call . c <nl> <nl> / * <nl> * <nl> - * Copyright 2015 , Google Inc . <nl> + * Copyright 2015 - 2016 , Google Inc . <nl> * All rights reserved . <nl> * <nl> * Redistribution and use in source and binary forms , with or without <nl> <nl> # include < string . h > <nl> <nl> # include < grpc / compression . h > <nl> + # include < grpc / grpc . h > <nl> # include < grpc / support / alloc . h > <nl> # include < grpc / support / log . h > <nl> # include < grpc / support / string_util . h > <nl> static int prepare_application_metadata ( grpc_call * call , int count , <nl> GPR_ASSERT ( sizeof ( grpc_linked_mdelem ) = = sizeof ( md - > internal_data ) ) ; <nl> l - > md = grpc_mdelem_from_string_and_buffer ( <nl> md - > key , ( const gpr_uint8 * ) md - > value , md - > value_length ) ; <nl> - if ( ! grpc_mdstr_is_legal_header ( l - > md - > key ) ) { <nl> + if ( ! grpc_header_key_is_legal ( grpc_mdstr_as_c_string ( l - > md - > key ) , <nl> + GRPC_MDSTR_LENGTH ( l - > md - > key ) ) ) { <nl> gpr_log ( GPR_ERROR , " attempt to send invalid metadata key : % s " , <nl> grpc_mdstr_as_c_string ( l - > md - > key ) ) ; <nl> return 0 ; <nl> - } else if ( ! grpc_mdstr_is_bin_suffixed ( l - > md - > key ) & & <nl> - ! grpc_mdstr_is_legal_nonbin_header ( l - > md - > value ) ) { <nl> + } else if ( ! grpc_is_binary_header ( grpc_mdstr_as_c_string ( l - > md - > key ) , <nl> + GRPC_MDSTR_LENGTH ( l - > md - > key ) ) & & <nl> + ! grpc_header_nonbin_value_is_legal ( <nl> + grpc_mdstr_as_c_string ( l - > md - > value ) , <nl> + GRPC_MDSTR_LENGTH ( l - > md - > value ) ) ) { <nl> gpr_log ( GPR_ERROR , " attempt to send invalid metadata value " ) ; <nl> return 0 ; <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . 21d29a6295c <nl> mmm / dev / null <nl> ppp b / src / core / surface / validate_metadata . c <nl> <nl> + / * <nl> + * <nl> + * Copyright 2016 , Google Inc . <nl> + * All rights reserved . <nl> + * <nl> + * Redistribution and use in source and binary forms , with or without <nl> + * modification , are permitted provided that the following conditions are <nl> + * met : <nl> + * <nl> + * * Redistributions of source code must retain the above copyright <nl> + * notice , this list of conditions and the following disclaimer . <nl> + * * Redistributions in binary form must reproduce the above <nl> + * copyright notice , this list of conditions and the following disclaimer <nl> + * in the documentation and / or other materials provided with the <nl> + * distribution . <nl> + * * Neither the name of Google Inc . nor the names of its <nl> + * contributors may be used to endorse or promote products derived from <nl> + * this software without specific prior written permission . <nl> + * <nl> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + * " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + * LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + * A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + * SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + * LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + * DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + * THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + * OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + * <nl> + * / <nl> + <nl> + # include < stdlib . h > <nl> + # include < string . h > <nl> + <nl> + # include " grpc / support / port_platform . h " <nl> + <nl> + static int conforms_to ( const char * s , size_t len , const gpr_uint8 * legal_bits ) { <nl> + const char * p = s ; <nl> + const char * e = s + len ; <nl> + for ( ; p ! = e ; p + + ) { <nl> + int idx = * p ; <nl> + int byte = idx / 8 ; <nl> + int bit = idx % 8 ; <nl> + if ( ( legal_bits [ byte ] & ( 1 < < bit ) ) = = 0 ) return 0 ; <nl> + } <nl> + return 1 ; <nl> + } <nl> + <nl> + int grpc_header_key_is_legal ( const char * key , size_t length ) { <nl> + static const gpr_uint8 legal_header_bits [ 256 / 8 ] = { <nl> + 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x20 , 0xff , 0x03 , 0x00 , 0x00 , 0x00 , <nl> + 0x80 , 0xfe , 0xff , 0xff , 0x07 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , <nl> + 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } ; <nl> + return conforms_to ( key , length , legal_header_bits ) ; <nl> + } <nl> + <nl> + int grpc_header_nonbin_value_is_legal ( const char * value , size_t length ) { <nl> + static const gpr_uint8 legal_header_bits [ 256 / 8 ] = { <nl> + 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , <nl> + 0xff , 0xff , 0xff , 0xff , 0x7f , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , <nl> + 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } ; <nl> + return conforms_to ( value , length , legal_header_bits ) ; <nl> + } <nl> + <nl> + int grpc_is_binary_header ( const char * key , size_t length ) { <nl> + if ( length < 5 ) return 0 ; <nl> + return 0 = = memcmp ( key + length - 4 , " - bin " , 4 ) ; <nl> + } <nl> mmm a / src / core / transport / chttp2 / bin_encoder . c <nl> ppp b / src / core / transport / chttp2 / bin_encoder . c <nl> <nl> / * <nl> * <nl> - * Copyright 2015 , Google Inc . <nl> + * Copyright 2015 - 2016 , Google Inc . <nl> * All rights reserved . <nl> * <nl> * Redistribution and use in source and binary forms , with or without <nl> gpr_slice grpc_chttp2_base64_encode_and_huffman_compress ( gpr_slice input ) { <nl> GPR_ASSERT ( in = = GPR_SLICE_END_PTR ( input ) ) ; <nl> return output ; <nl> } <nl> - <nl> - int grpc_is_binary_header ( const char * key , size_t length ) { <nl> - if ( length < 5 ) return 0 ; <nl> - return 0 = = memcmp ( key + length - 4 , " - bin " , 4 ) ; <nl> - } <nl> mmm a / src / core / transport / chttp2 / bin_encoder . h <nl> ppp b / src / core / transport / chttp2 / bin_encoder . h <nl> <nl> / * <nl> * <nl> - * Copyright 2015 , Google Inc . <nl> + * Copyright 2015 - 2016 , Google Inc . <nl> * All rights reserved . <nl> * <nl> * Redistribution and use in source and binary forms , with or without <nl> gpr_slice grpc_chttp2_huffman_compress ( gpr_slice input ) ; <nl> return y ; * / <nl> gpr_slice grpc_chttp2_base64_encode_and_huffman_compress ( gpr_slice input ) ; <nl> <nl> - int grpc_is_binary_header ( const char * key , size_t length ) ; <nl> - <nl> # endif / * GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H * / <nl> mmm a / src / core / transport / chttp2 / hpack_encoder . c <nl> ppp b / src / core / transport / chttp2 / hpack_encoder . c <nl> <nl> / * <nl> * <nl> - * Copyright 2015 , Google Inc . <nl> + * Copyright 2015 - 2016 , Google Inc . <nl> * All rights reserved . <nl> * <nl> * Redistribution and use in source and binary forms , with or without <nl> <nl> # include < assert . h > <nl> # include < string . h > <nl> <nl> + / * This is here for grpc_is_binary_header <nl> + * TODO ( murgatroid99 ) : Remove this <nl> + * / <nl> + # include < grpc / grpc . h > <nl> + <nl> # include < grpc / support / alloc . h > <nl> # include < grpc / support / log . h > <nl> # include < grpc / support / useful . h > <nl> mmm a / src / core / transport / chttp2 / hpack_parser . c <nl> ppp b / src / core / transport / chttp2 / hpack_parser . c <nl> <nl> / * <nl> * <nl> - * Copyright 2015 , Google Inc . <nl> + * Copyright 2015 - 2016 , Google Inc . <nl> * All rights reserved . <nl> * <nl> * Redistribution and use in source and binary forms , with or without <nl> <nl> # include < string . h > <nl> # include < assert . h > <nl> <nl> + / * This is here for grpc_is_binary_header <nl> + * TODO ( murgatroid99 ) : Remove this <nl> + * / <nl> + # include < grpc / grpc . h > <nl> + <nl> # include < grpc / support / alloc . h > <nl> # include < grpc / support / log . h > <nl> # include < grpc / support / port_platform . h > <nl> mmm a / src / core / transport / metadata . c <nl> ppp b / src / core / transport / metadata . c <nl> gpr_slice grpc_mdstr_as_base64_encoded_and_huffman_compressed ( grpc_mdstr * gs ) { <nl> gpr_mu_unlock ( & shard - > mu ) ; <nl> return slice ; <nl> } <nl> - <nl> - static int conforms_to ( grpc_mdstr * s , const gpr_uint8 * legal_bits ) { <nl> - const gpr_uint8 * p = GPR_SLICE_START_PTR ( s - > slice ) ; <nl> - const gpr_uint8 * e = GPR_SLICE_END_PTR ( s - > slice ) ; <nl> - for ( ; p ! = e ; p + + ) { <nl> - int idx = * p ; <nl> - int byte = idx / 8 ; <nl> - int bit = idx % 8 ; <nl> - if ( ( legal_bits [ byte ] & ( 1 < < bit ) ) = = 0 ) return 0 ; <nl> - } <nl> - return 1 ; <nl> - } <nl> - <nl> - int grpc_mdstr_is_legal_header ( grpc_mdstr * s ) { <nl> - static const gpr_uint8 legal_header_bits [ 256 / 8 ] = { <nl> - 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x20 , 0xff , 0x03 , 0x00 , 0x00 , 0x00 , <nl> - 0x80 , 0xfe , 0xff , 0xff , 0x07 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , <nl> - 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } ; <nl> - return conforms_to ( s , legal_header_bits ) ; <nl> - } <nl> - <nl> - int grpc_mdstr_is_legal_nonbin_header ( grpc_mdstr * s ) { <nl> - static const gpr_uint8 legal_header_bits [ 256 / 8 ] = { <nl> - 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , <nl> - 0xff , 0xff , 0xff , 0xff , 0x7f , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , <nl> - 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } ; <nl> - return conforms_to ( s , legal_header_bits ) ; <nl> - } <nl> - <nl> - int grpc_mdstr_is_bin_suffixed ( grpc_mdstr * s ) { <nl> - / * TODO ( ctiller ) : consider caching this * / <nl> - return grpc_is_binary_header ( ( const char * ) GPR_SLICE_START_PTR ( s - > slice ) , <nl> - GPR_SLICE_LENGTH ( s - > slice ) ) ; <nl> - } <nl> mmm a / src / core / transport / metadata . h <nl> ppp b / src / core / transport / metadata . h <nl> void grpc_mdelem_unref ( grpc_mdelem * md ) ; <nl> Does not promise that the returned string has no embedded nulls however . * / <nl> const char * grpc_mdstr_as_c_string ( grpc_mdstr * s ) ; <nl> <nl> + # define GRPC_MDSTR_LENGTH ( s ) ( GPR_SLICE_LENGTH ( s - > slice ) ) <nl> + <nl> int grpc_mdstr_is_legal_header ( grpc_mdstr * s ) ; <nl> int grpc_mdstr_is_legal_nonbin_header ( grpc_mdstr * s ) ; <nl> int grpc_mdstr_is_bin_suffixed ( grpc_mdstr * s ) ; <nl> mmm a / test / core / transport / chttp2 / bin_encoder_test . c <nl> ppp b / test / core / transport / chttp2 / bin_encoder_test . c <nl> <nl> / * <nl> * <nl> - * Copyright 2015 , Google Inc . <nl> + * Copyright 2015 - 2016 , Google Inc . <nl> * All rights reserved . <nl> * <nl> * Redistribution and use in source and binary forms , with or without <nl> <nl> <nl> # include < string . h > <nl> <nl> + / * This is here for grpc_is_binary_header <nl> + * TODO ( murgatroid99 ) : Remove this <nl> + * / <nl> + # include < grpc / grpc . h > <nl> # include " src / core / support / string . h " <nl> # include < grpc / support / alloc . h > <nl> # include < grpc / support / log . h > <nl> mmm a / tools / doxygen / Doxyfile . core . internal <nl> ppp b / tools / doxygen / Doxyfile . core . internal <nl> src / core / surface / metadata_array . c \ <nl> src / core / surface / server . c \ <nl> src / core / surface / server_chttp2 . c \ <nl> src / core / surface / server_create . c \ <nl> + src / core / surface / validate_metadata . c \ <nl> src / core / surface / version . c \ <nl> src / core / transport / byte_stream . c \ <nl> src / core / transport / chttp2 / alpn . c \ <nl> mmm a / tools / run_tests / run_interop_tests . py <nl> ppp b / tools / run_tests / run_interop_tests . py <nl> def aggregate_http2_results ( stdout ) : <nl> match = re . search ( r ' \ { " cases [ ^ \ ] ] * \ ] \ } ' , stdout ) <nl> if not match : <nl> return None <nl> - <nl> + <nl> results = json . loads ( match . group ( 0 ) ) <nl> skipped = 0 <nl> passed = 0 <nl> def aggregate_http2_results ( stdout ) : <nl> for test_case in _HTTP2_TEST_CASES : <nl> if server_name = = " go " : <nl> # TODO ( carl - mastrangelo ) : Reenable after https : / / github . com / grpc / grpc - go / issues / 434 <nl> - continue <nl> + continue <nl> test_job = cloud_to_cloud_jobspec ( http2Interop , <nl> test_case , <nl> server_name , <nl> def aggregate_http2_results ( stdout ) : <nl> job [ 0 ] . http2results = aggregate_http2_results ( job [ 0 ] . message ) <nl> <nl> report_utils . render_interop_html_report ( <nl> - set ( [ str ( l ) for l in languages ] ) , servers , _TEST_CASES , _AUTH_TEST_CASES , <nl> + set ( [ str ( l ) for l in languages ] ) , servers , _TEST_CASES , _AUTH_TEST_CASES , <nl> _HTTP2_TEST_CASES , resultset , num_failures , <nl> args . cloud_to_prod_auth or args . cloud_to_prod , args . http2_interop ) <nl> <nl> mmm a / tools / run_tests / sources_and_headers . json <nl> ppp b / tools / run_tests / sources_and_headers . json <nl> <nl> " src / core / surface / server_chttp2 . c " , <nl> " src / core / surface / server_create . c " , <nl> " src / core / surface / surface_trace . h " , <nl> + " src / core / surface / validate_metadata . c " , <nl> " src / core / surface / version . c " , <nl> " src / core / transport / byte_stream . c " , <nl> " src / core / transport / byte_stream . h " , <nl> <nl> " src / core / surface / server_chttp2 . c " , <nl> " src / core / surface / server_create . c " , <nl> " src / core / surface / surface_trace . h " , <nl> + " src / core / surface / validate_metadata . c " , <nl> " src / core / surface / version . c " , <nl> " src / core / transport / byte_stream . c " , <nl> " src / core / transport / byte_stream . h " , <nl> mmm a / vsprojects / vcxproj / grpc / grpc . vcxproj <nl> ppp b / vsprojects / vcxproj / grpc / grpc . vcxproj <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ server_create . c " > <nl> < / ClCompile > <nl> + < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ validate_metadata . c " > <nl> + < / ClCompile > <nl> < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ version . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " . . \ . . \ . . \ src \ core \ transport \ byte_stream . c " > <nl> mmm a / vsprojects / vcxproj / grpc / grpc . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc / grpc . vcxproj . filters <nl> <nl> < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ server_create . c " > <nl> < Filter > src \ core \ surface < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ validate_metadata . c " > <nl> + < Filter > src \ core \ surface < / Filter > <nl> + < / ClCompile > <nl> < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ version . c " > <nl> < Filter > src \ core \ surface < / Filter > <nl> < / ClCompile > <nl> mmm a / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj <nl> ppp b / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj <nl> <nl> < / ClCompile > <nl> < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ server_create . c " > <nl> < / ClCompile > <nl> + < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ validate_metadata . c " > <nl> + < / ClCompile > <nl> < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ version . c " > <nl> < / ClCompile > <nl> < ClCompile Include = " . . \ . . \ . . \ src \ core \ transport \ byte_stream . c " > <nl> mmm a / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj . filters <nl> ppp b / vsprojects / vcxproj / grpc_unsecure / grpc_unsecure . vcxproj . filters <nl> <nl> < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ server_create . c " > <nl> < Filter > src \ core \ surface < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ validate_metadata . c " > <nl> + < Filter > src \ core \ surface < / Filter > <nl> + < / ClCompile > <nl> < ClCompile Include = " . . \ . . \ . . \ src \ core \ surface \ version . c " > <nl> < Filter > src \ core \ surface < / Filter > <nl> < / ClCompile > <nl> | Expose core metadata validation functions in public headers | grpc/grpc | c3910cadb49eabcf196e056c1bd5860eb9966c29 | 2016-01-06T21:14:23Z |
mmm a / script / lib / util . py <nl> ppp b / script / lib / util . py <nl> def s3put ( bucket , access_key , secret_key , prefix , key_prefix , files ) : <nl> ' - - secret_key ' , secret_key , <nl> ' - - prefix ' , prefix , <nl> ' - - key_prefix ' , key_prefix , <nl> + ' - - no_overwrite ' , <nl> ' - - grant ' , ' public - read ' <nl> ] + files <nl> <nl> mmm a / script / upload . py <nl> ppp b / script / upload . py <nl> def main ( ) : <nl> upload_atom_shell ( github , release_id , <nl> os . path . join ( DIST_DIR , CHROMEDRIVER_NAME ) ) <nl> <nl> - # Upload node ' s headers to S3 . <nl> - bucket , access_key , secret_key = s3_config ( ) <nl> - upload_node ( bucket , access_key , secret_key , ATOM_SHELL_VERSION ) <nl> - <nl> if args . publish_release : <nl> - # Press the publish button . <nl> - publish_release ( github , release_id ) <nl> + # Upload node ' s headers to S3 . <nl> + bucket , access_key , secret_key = s3_config ( ) <nl> + upload_node ( bucket , access_key , secret_key , ATOM_SHELL_VERSION ) <nl> <nl> # Upload the SHASUMS . txt . <nl> execute ( [ sys . executable , <nl> os . path . join ( SOURCE_ROOT , ' script ' , ' upload - checksums . py ' ) , <nl> ' - v ' , ATOM_SHELL_VERSION ] ) <nl> <nl> + # Press the publish button . <nl> + publish_release ( github , release_id ) <nl> + <nl> <nl> def parse_args ( ) : <nl> parser = argparse . ArgumentParser ( description = ' upload distribution file ' ) <nl> | Don ' t overwrite files on S3 | electron/electron | 45fb3ec41d5ae36595183ab0baa17811eabb289d | 2014-11-07T13:45:40Z |
mmm a / src / mongo / db / auth / authorization_manager . cpp <nl> ppp b / src / mongo / db / auth / authorization_manager . cpp <nl> namespace { <nl> for ( unordered_map < UserName , User * > : : iterator it = _userCache . begin ( ) ; <nl> it ! = _userCache . end ( ) ; + + it ) { <nl> it - > second - > invalidate ( ) ; <nl> + / / Need to decrement ref count and manually clean up User object to prevent memory leaks <nl> + / / since we ' re pinning all User objects by incrementing their ref count when we <nl> + / / initially populate the cache . <nl> + / / TODO ( spencer ) : remove this once we ' re not pinning User objects . <nl> + it - > second - > decrementRefCount ( ) ; <nl> + if ( it - > second - > getRefCount ( ) = = 0 ) <nl> + delete it - > second ; <nl> } <nl> _userCache . clear ( ) ; <nl> } <nl> mmm a / src / mongo / db / commands / user_management_commands . cpp <nl> ppp b / src / mongo / db / commands / user_management_commands . cpp <nl> namespace mongo { <nl> userObjBuilder . append ( " otherDBRoles " , args . otherDBRoles ) ; <nl> } <nl> <nl> - status = getGlobalAuthorizationManager ( ) - > insertPrivilegeDocument ( dbname , <nl> - userObjBuilder . obj ( ) ) ; <nl> + AuthorizationManager * authzManager = getGlobalAuthorizationManager ( ) ; <nl> + status = authzManager - > insertPrivilegeDocument ( dbname , userObjBuilder . obj ( ) ) ; <nl> + if ( ! status . isOK ( ) ) { <nl> + addStatus ( status , result ) ; <nl> + return false ; <nl> + } <nl> + <nl> + / / Rebuild full user cache on every user modification . <nl> + / / TODO ( spencer ) : Remove this once we update user cache on - demand for each user <nl> + / / modification . <nl> + status = authzManager - > initilizeAllV1UserData ( ) ; <nl> if ( ! status . isOK ( ) ) { <nl> addStatus ( status , result ) ; <nl> return false ; <nl> namespace mongo { <nl> } <nl> BSONObj updateObj = BSON ( " $ set " < < setBuilder . obj ( ) ) ; <nl> <nl> - status = getGlobalAuthorizationManager ( ) - > updatePrivilegeDocument ( <nl> - UserName ( args . userName , dbname ) , updateObj ) ; <nl> + AuthorizationManager * authzManager = getGlobalAuthorizationManager ( ) ; <nl> + status = authzManager - > updatePrivilegeDocument ( UserName ( args . userName , dbname ) , <nl> + updateObj ) ; <nl> + <nl> + if ( ! status . isOK ( ) ) { <nl> + addStatus ( status , result ) ; <nl> + return false ; <nl> + } <nl> <nl> + / / Rebuild full user cache on every user modification . <nl> + / / TODO ( spencer ) : Remove this once we update user cache on - demand for each user <nl> + / / modification . <nl> + status = authzManager - > initilizeAllV1UserData ( ) ; <nl> if ( ! status . isOK ( ) ) { <nl> addStatus ( status , result ) ; <nl> return false ; <nl> | Fully rebuild User cache on all user modifications . SERVER - 9518 | mongodb/mongo | 10c130a0c7fc88bde739beb725a20aa600f32ff1 | 2013-07-23T17:08:00Z |
mmm a / src / arch / mock / io . hpp <nl> ppp b / src / arch / mock / io . hpp <nl> struct mock_iocallback_t { <nl> virtual ~ mock_iocallback_t ( ) { } <nl> } ; <nl> <nl> + # define DEFAULT_DISK_ACCOUNT NULL <nl> + <nl> template < class inner_io_config_t > <nl> class mock_file_t <nl> { <nl> class mock_file_t <nl> mode_create = 1 < < 2 <nl> } ; <nl> <nl> + struct account_t { <nl> + account_t ( UNUSED mock_file_t * f , UNUSED int p ) { } <nl> + } ; <nl> + <nl> protected : <nl> mock_file_t ( const char * path , int mode , const typename inner_io_config_t : : io_backend_t io_backend = ( typename inner_io_config_t : : io_backend_t ) - 1 ) <nl> : mode ( mode ) <nl> class mock_file_t <nl> <nl> / * These always return ' false ' ; the reason they return bool instead of void <nl> is for consistency with other asynchronous - callback methods * / <nl> - bool read_async ( size_t offset , size_t length , void * buf , mock_iocallback_t * cb ) { <nl> + bool read_async ( size_t offset , size_t length , void * buf , UNUSED account_t * account , mock_iocallback_t * cb ) { <nl> rassert ( mode & mode_read ) ; <nl> read_blocking ( offset , length , buf ) ; <nl> random_delay ( cb , & mock_iocallback_t : : on_io_complete ) ; <nl> return false ; <nl> } <nl> <nl> - bool write_async ( size_t offset , size_t length , const void * buf , mock_iocallback_t * cb ) { <nl> + bool write_async ( size_t offset , size_t length , const void * buf , UNUSED account_t * account , mock_iocallback_t * cb ) { <nl> rassert ( mode & mode_write ) ; <nl> write_blocking ( offset , length , buf ) ; <nl> random_delay ( cb , & mock_iocallback_t : : on_io_complete ) ; <nl> class mock_file_t <nl> } ; <nl> <nl> template < class inner_io_config_t > <nl> - class mock_direct_file_t : private mock_file_t < inner_io_config_t > { <nl> + class mock_direct_file_t : public mock_file_t < inner_io_config_t > { <nl> public : <nl> using mock_file_t < inner_io_config_t > : : exists ; <nl> using mock_file_t < inner_io_config_t > : : is_block_device ; <nl> | Fix mock_io built | rethinkdb/rethinkdb | b8e9087996d8f138c3addd425e0426f6de6b6c3b | 2011-04-23T00:34:30Z |
mmm a / Code / CryEngine / Cry3DEngine / LightEntity . cpp <nl> ppp b / Code / CryEngine / Cry3DEngine / LightEntity . cpp <nl> int CLightEntity : : UpdateGSMLightSourceNearestShadowFrustum ( int nFrustumIndex , co <nl> bool CLightEntity : : IsOnePassTraversalFrustum ( const ShadowMapFrustum * pFr ) <nl> { <nl> return GetCVars ( ) - > e_OnePassOctreeTraversal & & ( <nl> + pFr - > m_eFrustumType = = ShadowMapFrustum : : e_PerObject | | <nl> pFr - > m_eFrustumType = = ShadowMapFrustum : : e_GsmCached | | <nl> pFr - > m_eFrustumType = = ShadowMapFrustum : : e_HeightMapAO | | <nl> pFr - > m_eFrustumType = = ShadowMapFrustum : : e_GsmDynamic | | <nl> void CLightEntity : : CollectShadowCascadeForOnePassTraversal ( ShadowMapFrustum * pFr <nl> if ( IsOnePassTraversalFrustum ( pFr ) & & CLightEntity : : s_pShadowFrustumsCollector ) <nl> { <nl> assert ( m_light . m_Flags & DLF_CASTSHADOW_MAPS & & ! pFr - > pOnePassShadowView ) ; <nl> + assert ( stl : : find_index ( * CLightEntity : : s_pShadowFrustumsCollector , std : : pair < ShadowMapFrustum * , const CLightEntity * > ( pFr , this ) ) < 0 ) ; <nl> + <nl> CLightEntity : : s_pShadowFrustumsCollector - > emplace_back ( pFr , this ) ; <nl> } <nl> } <nl> void CLightEntity : : ProcessPerObjectFrustum ( ShadowMapFrustum * pFr , struct SPerObj <nl> pFr - > ResetCasterLists ( ) ; <nl> pFr - > castersList . Add ( pPerObjectShadow - > pCaster ) ; <nl> <nl> + if ( pPerObjectShadow - > pCaster - > GetRenderNodeType ( ) = = eERType_MovableBrush | | pPerObjectShadow - > pCaster - > GetRenderNodeType ( ) = = eERType_Character ) <nl> + { <nl> + / / mark the object to be rendered into shadow map <nl> + COctreeNode : : SetTraversalFrameId ( ( IRenderNode * ) pPerObjectShadow - > pCaster , passInfo . GetMainFrameID ( ) ) ; <nl> + } <nl> + <nl> / / get caster ' s bounding box and scale <nl> AABB objectBBox ; <nl> pPerObjectShadow - > pCaster - > FillBBox ( objectBBox ) ; <nl> void CLightEntity : : ProcessPerObjectFrustum ( ShadowMapFrustum * pFr , struct SPerObj <nl> pFr - > fBlurS = 0 . 0f ; <nl> pFr - > fBlurT = 0 . 0f ; <nl> <nl> + ( ( CLightEntity * ) pLightSource ) - > CollectShadowCascadeForOnePassTraversal ( pFr ) ; <nl> + <nl> if ( GetCVars ( ) - > e_ShadowsFrustums ) <nl> { <nl> pFr - > DrawFrustum ( GetRenderer ( ) , ( GetCVars ( ) - > e_ShadowsFrustums = = 1 ) ? 1000 : 1 ) ; <nl> mmm a / Code / CryEngine / Cry3DEngine / ObjectsTree . cpp <nl> ppp b / Code / CryEngine / Cry3DEngine / ObjectsTree . cpp <nl> void COctreeNode : : Render_Object_Nodes ( bool bNodeCompletelyInFrustum , int nRender <nl> const bool bPushIntoOcclusionCuller = Get3DEngine ( ) - > IsStatObjBufferRenderTasksAllowed ( ) & & passInfo . IsGeneralPass ( ) & & JobManager : : InvokeAsJob ( " CheckOcclusion " ) ; <nl> <nl> / / check culling of all passes <nl> - passCullMask = UpdateCullMask ( m_cachedShadowFrameId , m_renderFlags , passInfo , m_objectsBox , nodeDistance , m_fObjectsMaxViewDist , ! bPushIntoOcclusionCuller , bNodeCompletelyInFrustum , & m_occlusionTestClient , passCullMask ) ; <nl> + passCullMask = UpdateCullMask ( m_onePassTraversalFrameId , m_renderFlags , passInfo , m_objectsBox , nodeDistance , m_fObjectsMaxViewDist , ! bPushIntoOcclusionCuller , bNodeCompletelyInFrustum , & m_occlusionTestClient , passCullMask ) ; <nl> <nl> / / stop if no any passes see this node <nl> if ( ! passCullMask ) <nl> bool IsAABBInsideHull ( const SPlaneObject * pHullPlanes , int nPlanesNum , const AAB <nl> bool IsSphereInsideHull ( const SPlaneObject * pHullPlanes , int nPlanesNum , const Sphere & objSphere ) ; <nl> <nl> / / single function for all possible culling types , used for octree nodes and for objects <nl> - uint32 COctreeNode : : UpdateCullMask ( uint32 cachedShadowFrameId , const IRenderNode : : RenderFlagsType renderFlags , const SRenderingPassInfo & passInfo , const AABB & nodeBox , const float nodeDistance , const float nodeMaxViewDistance , const bool bTestCoverageBuffer , <nl> + uint32 COctreeNode : : UpdateCullMask ( uint32 onePassTraversalFrameId , const IRenderNode : : RenderFlagsType renderFlags , const SRenderingPassInfo & passInfo , const AABB & nodeBox , const float nodeDistance , const float nodeMaxViewDistance , const bool bTestCoverageBuffer , <nl> bool & bCompletelyInMainFrustum , OcclusionTestClient * occlusionTestClient , uint32 passCullMask ) <nl> { <nl> assert ( nodeDistance > = 0 & & _finite ( nodeDistance ) ) ; <nl> uint32 COctreeNode : : UpdateCullMask ( uint32 cachedShadowFrameId , const IRenderNode <nl> <nl> ShadowMapFrustum * pFr = ( * shadowPasses ) [ n ] . GetIRenderView ( ) - > GetShadowFrustumOwner ( ) ; <nl> <nl> - if ( pFr - > IsCached ( ) ) <nl> + if ( pFr - > IsCached ( ) | | pFr - > m_eFrustumType = = ShadowMapFrustum : : e_PerObject ) <nl> { <nl> / / cull casters not marked for shadow cache sliced update <nl> - if ( cachedShadowFrameId < passInfo . GetMainFrameID ( ) ) <nl> + if ( onePassTraversalFrameId < passInfo . GetMainFrameID ( ) ) <nl> { <nl> passCullMask & = ~ BIT ( passId ) ; <nl> } <nl> void COctreeNode : : Render_LightSources ( bool bNodeCompletelyInFrustum , const SRend <nl> <nl> float nodeDistance = sqrt_tpl ( Distance : : Point_AABBSq ( vCamPos , m_objectsBox ) * sqr ( passInfo . GetZoomFactor ( ) ) ) ; <nl> <nl> - uint32 passCullMask = UpdateCullMask ( m_cachedShadowFrameId , m_renderFlags , passInfo , m_objectsBox , nodeDistance , m_fObjectsMaxViewDist , false , bNodeCompletelyInFrustum , & m_occlusionTestClient , kPassCullMainMask ) ; <nl> + uint32 passCullMask = UpdateCullMask ( m_onePassTraversalFrameId , m_renderFlags , passInfo , m_objectsBox , nodeDistance , m_fObjectsMaxViewDist , false , bNodeCompletelyInFrustum , & m_occlusionTestClient , kPassCullMainMask ) ; <nl> <nl> if ( bNodeCompletelyInFrustum | | passInfo . GetCamera ( ) . IsAABBVisible_EH ( m_objectsBox , & bNodeCompletelyInFrustum ) ) <nl> { <nl> void COctreeNode : : Render_LightSources ( bool bNodeCompletelyInFrustum , const SRend <nl> float entDistance = sqrt_tpl ( Distance : : Point_AABBSq ( vCamPos , objBox ) ) * passInfo . GetZoomFactor ( ) ; <nl> <nl> bool bObjectCompletelyInFrustum = bNodeCompletelyInFrustum ; <nl> - uint32 objCullMask = UpdateCullMask ( pObj - > m_cachedShadowFrameId , pObj - > m_dwRndFlags , passInfo , objBox , entDistance , pObj - > m_fWSMaxViewDist , true , bObjectCompletelyInFrustum , nullptr , passCullMask ) ; <nl> + uint32 objCullMask = UpdateCullMask ( pObj - > m_onePassTraversalFrameId , pObj - > m_dwRndFlags , passInfo , objBox , entDistance , pObj - > m_fWSMaxViewDist , true , bObjectCompletelyInFrustum , nullptr , passCullMask ) ; <nl> <nl> if ( objCullMask ) <nl> { <nl> bool COctreeNode : : GetShadowCastersTimeSliced ( IRenderNode * pIgnoreNode , ShadowMap <nl> else <nl> pFrustum - > castersList . Add ( pNode ) ; <nl> <nl> - / / mark the object to be rendered into shadow cache <nl> - pNode - > m_cachedShadowFrameId = passInfo . GetMainFrameID ( ) ; <nl> + / / mark the object to be rendered into shadow map <nl> + COctreeNode : : SetTraversalFrameId ( pNode , passInfo . GetMainFrameID ( ) ) ; <nl> } <nl> } <nl> } <nl> - <nl> - if ( pFrustum - > GetCasterNum ( ) ) <nl> - { <nl> - / / mark the path to this node <nl> - / / for cached cascades only m_cachedShadowFrameId will be used to guide one - pass tree traversal ( without frustum check ) <nl> - COctreeNode * pOcNode = this ; <nl> - while ( pOcNode & & pOcNode - > m_cachedShadowFrameId ! = passInfo . GetMainFrameID ( ) ) <nl> - { <nl> - pOcNode - > m_cachedShadowFrameId = passInfo . GetMainFrameID ( ) ; <nl> - pOcNode = pOcNode - > m_pParent ; <nl> - } <nl> - } <nl> } <nl> } <nl> <nl> void COctreeNode : : RenderVegetations ( TDoublyLinkedList < IRenderNode > * lstObjects , <nl> <nl> / / check culling of all passes <nl> bool bObjectCompletelyInFrustum = bOcNodeCompletelyInFrustum ; <nl> - uint32 objCullMask = UpdateCullMask ( pObj - > m_cachedShadowFrameId , pObj - > m_dwRndFlags , passInfo , objBox , fEntDistance , pObj - > m_fWSMaxViewDist , bCheckPerObjectOcclusion , bObjectCompletelyInFrustum , nullptr , passCullMask ) ; <nl> + uint32 objCullMask = UpdateCullMask ( pObj - > m_onePassTraversalFrameId , pObj - > m_dwRndFlags , passInfo , objBox , fEntDistance , pObj - > m_fWSMaxViewDist , bCheckPerObjectOcclusion , bObjectCompletelyInFrustum , nullptr , passCullMask ) ; <nl> <nl> if ( objCullMask ) <nl> { <nl> void COctreeNode : : RenderBrushes ( TDoublyLinkedList < IRenderNode > * lstObjects , cons <nl> <nl> / / check culling of all passes <nl> bool bObjectCompletelyInFrustum = bOcNodeCompletelyInFrustum ; <nl> - uint32 objCullMask = UpdateCullMask ( pObj - > m_cachedShadowFrameId , pObj - > m_dwRndFlags , passInfo , objBox , fEntDistance , pObj - > m_fWSMaxViewDist , bCheckPerObjectOcclusion , bObjectCompletelyInFrustum , nullptr , passCullMask ) ; <nl> + uint32 objCullMask = UpdateCullMask ( pObj - > m_onePassTraversalFrameId , pObj - > m_dwRndFlags , passInfo , objBox , fEntDistance , pObj - > m_fWSMaxViewDist , bCheckPerObjectOcclusion , bObjectCompletelyInFrustum , nullptr , passCullMask ) ; <nl> <nl> if ( objCullMask ) <nl> { <nl> void COctreeNode : : RenderObjectIntoShadowViews ( const SRenderingPassInfo & passInfo <nl> IF ( renderFlags & skipShadowCastersRndFlags , 0 ) <nl> return ; <nl> <nl> - IF ( GetCVars ( ) - > e_ShadowsPerObject & & Get3DEngine ( ) - > GetPerObjectShadow ( pObj ) , 0 ) <nl> - return ; <nl> - <nl> EERType nodeType = pObj - > GetRenderNodeType ( ) ; <nl> <nl> + bool bMarkedForTraversal = ( pObj - > m_onePassTraversalFrameId = = passInfoGeneral . GetMainFrameID ( ) ) ; <nl> + <nl> if ( passCullMask & ~ kPassCullMainMask & & <nl> renderFlags & ERF_CASTSHADOWMAPS & & <nl> pObj - > m_fWSMaxViewDist > fMinShadowCasterViewDist & & <nl> void COctreeNode : : RenderObjectIntoShadowViews ( const SRenderingPassInfo & passInfo <nl> continue ; <nl> } <nl> <nl> + if ( bMarkedForTraversal ) <nl> + { <nl> + bool bHasPerObjectShadow = GetCVars ( ) - > e_ShadowsPerObject & & gEnv - > p3DEngine - > GetPerObjectShadow ( pObj ) ; <nl> + bool bMarkedForPerObjectShadow = bHasPerObjectShadow ; <nl> + bool bMarkedForCachedShadow = ! bHasPerObjectShadow ; <nl> + <nl> + ShadowMapFrustum * pFr = passInfoShadow . GetIRenderView ( ) - > GetShadowFrustumOwner ( ) ; <nl> + <nl> + if ( bMarkedForPerObjectShadow & & ( pFr - > m_eFrustumType ! = ShadowMapFrustum : : e_PerObject ) & & ( pFr - > m_Flags & DLF_SUN ) ) <nl> + { <nl> + / / exclude from all non per - object sun cascades <nl> + passId + + ; <nl> + continue ; <nl> + } <nl> + <nl> + if ( ! bMarkedForCachedShadow & & pFr - > IsCached ( ) ) <nl> + { <nl> + / / exclude from cached cascade if not marked for it <nl> + passId + + ; <nl> + continue ; <nl> + } <nl> + } <nl> + <nl> passInfoShadow . GetRendItemSorter ( ) . IncreaseObjectCounter ( ) ; <nl> <nl> switch ( nodeType ) <nl> void COctreeNode : : RenderDecalsAndRoads ( TDoublyLinkedList < IRenderNode > * lstObject <nl> <nl> / / check culling of all passes <nl> bool bObjectCompletelyInFrustum = bOcNodeCompletelyInFrustum ; <nl> - uint32 objCullMask = UpdateCullMask ( pObj - > m_cachedShadowFrameId , pObj - > m_dwRndFlags , passInfo , objBox , fEntDistance , pObj - > m_fWSMaxViewDist , true , bObjectCompletelyInFrustum , nullptr , passCullMask & kPassCullMainMask ) ; <nl> + uint32 objCullMask = UpdateCullMask ( pObj - > m_onePassTraversalFrameId , pObj - > m_dwRndFlags , passInfo , objBox , fEntDistance , pObj - > m_fWSMaxViewDist , true , bObjectCompletelyInFrustum , nullptr , passCullMask & kPassCullMainMask ) ; <nl> <nl> if ( objCullMask ) <nl> { <nl> void COctreeNode : : RenderCommonObjects ( TDoublyLinkedList < IRenderNode > * lstObjects <nl> <nl> / / check culling of all passes <nl> bool bObjectCompletelyInFrustum = bOcNodeCompletelyInFrustum ; <nl> - uint32 objCullMask = UpdateCullMask ( pObj - > m_cachedShadowFrameId , pObj - > m_dwRndFlags , passInfo , objBox , fEntDistance , pObj - > m_fWSMaxViewDist , true , bObjectCompletelyInFrustum , nullptr , passCullMask ) ; <nl> + uint32 objCullMask = UpdateCullMask ( pObj - > m_onePassTraversalFrameId , pObj - > m_dwRndFlags , passInfo , objBox , fEntDistance , pObj - > m_fWSMaxViewDist , true , bObjectCompletelyInFrustum , nullptr , passCullMask ) ; <nl> <nl> if ( objCullMask ) <nl> { <nl> bool CObjManager : : IsBoxOccluded ( const AABB & objBox , <nl> <nl> return false ; <nl> } <nl> + <nl> + void COctreeNode : : SetTraversalFrameId ( IRenderNode * pObj , uint32 onePassTraversalFrameId ) <nl> + { <nl> + pObj - > m_onePassTraversalFrameId = onePassTraversalFrameId ; <nl> + <nl> + / / mark also the path to this object , m_onePassTraversalFrameId will be used to guide the tree traversal <nl> + <nl> + COctreeNode * pOcNode = ( COctreeNode * ) pObj - > m_pOcNode ; <nl> + <nl> + while ( pOcNode & & pOcNode - > m_onePassTraversalFrameId ! = onePassTraversalFrameId ) <nl> + { <nl> + pOcNode - > m_onePassTraversalFrameId = onePassTraversalFrameId ; <nl> + <nl> + pOcNode = pOcNode - > m_pParent ; <nl> + } <nl> + } <nl> mmm a / Code / CryEngine / Cry3DEngine / ObjectsTree . h <nl> ppp b / Code / CryEngine / Cry3DEngine / ObjectsTree . h <nl> class COctreeNode : public IOctreeNode , Cry3DEngineBase , IStreamCallback <nl> bool DeleteObject ( IRenderNode * pObj ) ; <nl> void Render_Object_Nodes ( bool bNodeCompletelyInFrustum , int nRenderMask , const Vec3 & vAmbColor , uint32 passCullMask , const SRenderingPassInfo & passInfo ) ; <nl> void Render_LightSources ( bool bNodeCompletelyInFrustum , const SRenderingPassInfo & passInfo ) ; <nl> - static uint32 UpdateCullMask ( uint32 shadowCacheFrameId , const IRenderNode : : RenderFlagsType renderFlags , const SRenderingPassInfo & passInfo , const AABB & nodeBox , const float nodeDistance , const float nodeMaxViewDist , const bool bTestCoverageBuffer , <nl> + static uint32 UpdateCullMask ( uint32 onePassTraversalFrameId , const IRenderNode : : RenderFlagsType renderFlags , const SRenderingPassInfo & passInfo , const AABB & nodeBox , const float nodeDistance , const float nodeMaxViewDist , const bool bTestCoverageBuffer , <nl> bool & bCompletelyInMainFrustum , OcclusionTestClient * occlusionTestClient , uint32 passCullMask ) ; <nl> void CheckUpdateStaticInstancing ( ) ; <nl> void RenderDebug ( ) ; <nl> class COctreeNode : public IOctreeNode , Cry3DEngineBase , IStreamCallback <nl> void OffsetObjects ( const Vec3 & offset ) ; <nl> void SetVisArea ( CVisArea * pVisArea ) ; <nl> void SetTerrainNode ( struct CTerrainNode * node ) { m_pTerrainNode = node ; } <nl> - <nl> + static void SetTraversalFrameId ( IRenderNode * pObj , uint32 onePassTraversalFrameId ) ; <nl> static COctreeNode * Create ( const AABB & box , struct CVisArea * pVisArea , COctreeNode * pParent = NULL ) ; <nl> <nl> protected : <nl> class COctreeNode : public IOctreeNode , Cry3DEngineBase , IStreamCallback <nl> static int m_nInstCounterLoaded ; <nl> <nl> volatile int m_updateStaticInstancingLock ; <nl> - uint32 m_cachedShadowFrameId = 0 ; <nl> + uint32 m_onePassTraversalFrameId = 0 ; / / Used to request visiting of the node during one - pass traversal <nl> } ; <nl> <nl> # endif <nl> mmm a / Code / CryEngine / Cry3DEngine / ParticleSystem / ParticleComponentRuntime . h <nl> ppp b / Code / CryEngine / Cry3DEngine / ParticleSystem / ParticleComponentRuntime . h <nl> class CParticleComponentRuntime : public _i_reference_target_t , public IParticle <nl> void UpdateLocalSpace ( SUpdateRange range ) ; <nl> void DebugStabilityCheck ( ) ; <nl> <nl> - CParticleComponent * m_pComponent ; <nl> + _smart_ptr < CParticleComponent > m_pComponent ; <nl> CParticleEmitter * m_pEmitter ; <nl> CParticleContainer m_container ; <nl> TDynArray < SInstance > m_subInstances ; <nl> mmm a / Code / CryEngine / Cry3DEngine / ParticleSystem / ParticleEmitter . cpp <nl> ppp b / Code / CryEngine / Cry3DEngine / ParticleSystem / ParticleEmitter . cpp <nl> void CParticleEmitter : : Update ( ) <nl> m_pEffectOriginal - > Compile ( ) ; <nl> m_attributeInstance . Reset ( m_pEffectOriginal - > GetAttributeTable ( ) ) ; <nl> UpdateRuntimes ( ) ; <nl> - m_effectEditVersion = m_pEffectOriginal - > GetEditVersion ( ) + m_emitterEditVersion ; <nl> } <nl> <nl> UpdateFromEntity ( ) ; <nl> void CParticleEmitter : : UpdateBoundingBox ( const float frameTime ) <nl> if ( m_realBounds . IsReset ( ) ) <nl> { <nl> m_bounds . Reset ( ) ; <nl> + m_reRegister = true ; <nl> return ; <nl> } <nl> <nl> void CParticleEmitter : : UpdateRuntimes ( ) <nl> <nl> m_componentRuntimes = newRuntimes ; <nl> <nl> + m_effectEditVersion = m_pEffectOriginal - > GetEditVersion ( ) + m_emitterEditVersion ; <nl> + <nl> m_parentContainer . AddParticle ( ) ; <nl> <nl> for ( auto & pRuntime : m_componentRuntimes ) <nl> void CParticleEmitter : : Register ( ) <nl> <nl> if ( m_registered ) <nl> return ; <nl> + if ( m_bounds . IsEmpty ( ) | | m_bounds . IsReset ( ) ) <nl> + return ; <nl> + <nl> bool posContained = GetBBox ( ) . IsContainPoint ( GetPos ( ) ) ; <nl> SetRndFlags ( ERF_REGISTER_BY_POSITION , posContained ) ; <nl> SetRndFlags ( ERF_REGISTER_BY_BBOX , m_spawnParams . bRegisterByBBox ) ; <nl> mmm a / Code / CryEngine / Cry3DEngine / cvars . cpp <nl> ppp b / Code / CryEngine / Cry3DEngine / cvars . cpp <nl> void CVars : : Init ( ) <nl> " Force shadow cascades to be centered 0 = disable 1 = enable " ) ; <nl> DefineConstIntCVar ( e_ShadowsCascadesDebug , 0 , VF_CHEAT , <nl> " 0 = off , 1 = visualize sun shadow cascades on screen " ) ; <nl> - REGISTER_CVAR_CB ( e_ShadowsPerObject , 1 , VF_NULL , <nl> + REGISTER_CVAR_CB ( e_ShadowsPerObject , 0 , VF_NULL , <nl> " Per object shadow maps 0 = off , 1 = on , - 1 = don ' t draw object shadows " , OnPerCharacterShadowsChange ) ; <nl> REGISTER_CVAR ( e_ShadowsPerObjectResolutionScale , 1 , VF_NULL , <nl> " Global scale for per object shadow texture resolution \ n " <nl> mmm a / Code / CryEngine / CryAnimation / AttachmentVCloth . cpp <nl> ppp b / Code / CryEngine / CryAnimation / AttachmentVCloth . cpp <nl> bool CClothSimulator : : CheckCameraDistanceLessThan ( float dist ) const <nl> <nl> bool CClothSimulator : : CheckForceSkinningByFpsThreshold ( ) <nl> { <nl> - bool forceSkinning = false ; <nl> float fps = gEnv - > pTimer - > GetFrameRate ( ) ; <nl> - forceSkinning = fps < m_config . forceSkinningFpsThreshold ; <nl> + bool forceSkinning = fps < m_config . forceSkinningFpsThreshold ; <nl> <nl> / / force skinning only after n - th frame with framerate below threshold <nl> if ( forceSkinning & & ( m_forceSkinningAfterNFramesCounter < Console : : GetInst ( ) . ca_ClothForceSkinningAfterNFrames ) ) <nl> mmm a / Code / CryEngine / CryAnimation / AttachmentVCloth . h <nl> ppp b / Code / CryEngine / CryAnimation / AttachmentVCloth . h <nl> struct SParticleHot <nl> float lraDist ; / / ! < distance to closest constraint <nl> int lraNextParent ; / / ! < index of next parent on path to closest constraint <nl> <nl> - SParticleHot ( ) : collisionExist ( false ) , timer ( 0 ) , alpha ( 0 ) , lraIdx ( - 1 ) , lraDist ( 0 ) , lraNextParent ( - 1 ) , collisionNormal ( ZERO ) , pos ( ZERO ) <nl> + SParticleHot ( ) : pos ( ZERO ) , alpha ( 0 ) , factorAttached ( 0 ) , timer ( 0 ) , collisionExist ( false ) , collisionNormal ( ZERO ) , lraIdx ( - 1 ) , lraDist ( 0 ) , lraNextParent ( - 1 ) <nl> { <nl> } <nl> } ; <nl> class CClothSimulator <nl> , m_links ( nullptr ) <nl> , m_gravity ( 0 , 0 , - 9 . 8f ) <nl> , m_time ( 0 . 0f ) <nl> + , m_timeInterval ( 0 . 0f ) <nl> , m_dt ( 0 . 0f ) <nl> , m_dtPrev ( - 1 ) <nl> , m_dtNormalize ( 100 . 0f ) / / i . e . normalize substep to 1 / dt with dt = 0 . 01 <nl> class CClothSimulator <nl> , m_bUseDijkstraForLRA ( true ) <nl> , m_bIsInitialized ( false ) <nl> , m_bIsGpuSkinning ( false ) <nl> + , m_debugCollidableSubsteppingId ( 0 ) <nl> { <nl> } <nl> <nl> mmm a / Code / CryEngine / CryAnimation / AttachmentVClothPreProcess . cpp <nl> ppp b / Code / CryEngine / CryAnimation / AttachmentVClothPreProcess . cpp <nl> bool AttachmentVClothPreProcess : : CreateLinks ( std : : vector < Vec3 > const & vtx , std : : <nl> } <nl> <nl> / / for each vertex , trace ccw fan around it and store in m_pVtxEdges <nl> - STopology * pTopologyCCW = new STopology [ vtx . size ( ) ] ; <nl> + std : : vector < STopology > pTopologyCCW ( vtx . size ( ) ) ; <nl> int nVtxEdges = 0 ; <nl> for ( int i = 0 ; i < nTris ; i + + ) <nl> { <nl> mmm a / Code / CryEngine / CryAnimation / CharacterManager . cpp <nl> ppp b / Code / CryEngine / CryAnimation / CharacterManager . cpp <nl> void CharacterManager : : UpdateStreaming_SKEL ( std : : vector < CDefaultSkeletonReferenc <nl> else <nl> estp = estpNormal ; <nl> <nl> - si . pStreamer = new CryCHRLoader ; <nl> + si . pStreamer = std : : make_shared < CryCHRLoader > ( ) ; <nl> si . pStreamer - > BeginLoadCHRRenderMesh ( pSkel , it - > m_RefByInstances , estp ) ; <nl> } <nl> } <nl> void CharacterManager : : UpdateStreaming_SKIN ( std : : vector < CDefaultSkinningReferenc <nl> else <nl> estp = estpNormal ; <nl> <nl> - si . pStreamer = new CryCHRLoader ; <nl> + si . pStreamer = std : : make_shared < CryCHRLoader > ( ) ; <nl> si . pStreamer - > BeginLoadSkinRenderMesh ( pSkin , i , estp ) ; <nl> } <nl> } <nl> mmm a / Code / CryEngine / CryAnimation / Command_Buffer . h <nl> ppp b / Code / CryEngine / CryAnimation / Command_Buffer . h <nl> class CState <nl> CState ( ) <nl> : m_pDefaultSkeleton ( nullptr ) <nl> , m_location ( IDENTITY ) <nl> + , m_pFallbackPoseData ( nullptr ) <nl> , m_pPoseData ( nullptr ) <nl> , m_jointCount ( 0 ) <nl> , m_originalTimeDelta ( 0 . 0f ) <nl> mmm a / Code / CryEngine / CryAnimation / GlobalAnimationHeaderAIM . cpp <nl> ppp b / Code / CryEngine / CryAnimation / GlobalAnimationHeaderAIM . cpp <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> if ( numPoses ! = 9 ) <nl> return q * 2 ; <nl> <nl> - uint32 i = - 1 ; <nl> - f32 t = 0 ; <nl> - <nl> f32 diag = 1 . 70f ; <nl> <nl> f32 eup = 1 . 60f ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> f32 edown = 1 . 6f ; <nl> f32 mdown = 1 . 20f ; <nl> <nl> - i = 4 ; <nl> + uint32 i = 4 ; <nl> arrQuat [ i ] . i0 = 3 ; <nl> - t = eup ; <nl> + f32 t = eup ; <nl> arrQuat [ i ] . w0 = Vec4 ( 1 - t , 0 , 0 , t ) ; / / 3 - mirrored 0 - scaled <nl> arrQuat [ i ] . i1 = 4 ; <nl> t = mup ; <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 - t , t , 0 ) ; / / 4 - mirrored 1 - scaled <nl> arrQuat [ i ] . i2 = 1 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 , 0 ) ; <nl> arrQuat [ i ] . i3 = 0 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> <nl> i = 5 ; <nl> arrQuat [ i ] . i0 = 3 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 4 ; <nl> t = mside ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> t = eside ; <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 - t , t ) ; / / 1 - mirrored 0 - scaled <nl> arrQuat [ i ] . i3 = 0 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> t = eup ; <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 - t , t , 0 ) ; / / 3 - mirrored 0 - scaled <nl> arrQuat [ i ] . i2 = 0 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 , 0 ) ; <nl> arrQuat [ i ] . i3 = 1 ; <nl> t = eside ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> <nl> i = 7 ; <nl> arrQuat [ i ] . i0 = 2 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 1 ; <nl> t = eside ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> t = mside ; <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 - t , t ) ; / / 4 - mirrored 5 - scaled <nl> arrQuat [ i ] . i3 = 5 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> t = eup ; <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 - t , t , 0 ) ; / / 5 - mirrored 2 - scaled <nl> arrQuat [ i ] . i2 = 2 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 , 0 ) ; <nl> arrQuat [ i ] . i3 = 1 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> t = eside ; <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 - t , t ) ; / / 1 - mirrored 2 - scaled <nl> arrQuat [ i ] . i3 = 2 ; <nl> - t = 1 . 0f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> t = mside ; <nl> arrQuat [ i ] . w0 = Vec4 ( 1 - t , t , 0 , 0 ) ; / / 4 - mirrored 3 - scaled <nl> arrQuat [ i ] . i1 = 3 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 , 0 , 0 ) ; <nl> arrQuat [ i ] . i2 = 6 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 , 0 ) ; <nl> arrQuat [ i ] . i3 = 7 ; <nl> t = eside ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> i = 11 ; <nl> arrQuat [ i ] . i0 = 6 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 7 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 , 0 , 0 ) ; <nl> arrQuat [ i ] . i2 = 4 ; <nl> t = mdown ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> t = eside ; <nl> arrQuat [ i ] . w0 = Vec4 ( 1 - t , t , 0 , 0 ) ; / / 7 - mirrored 6 - scaled <nl> arrQuat [ i ] . i1 = 6 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 , 0 , 0 ) ; <nl> arrQuat [ i ] . i2 = 3 ; <nl> t = edown ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> <nl> i = 13 ; <nl> arrQuat [ i ] . i0 = 5 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 4 ; <nl> t = mside ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> t = eside ; <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 - t , t ) ; / / 7 mirrored 8 - scaled <nl> arrQuat [ i ] . i3 = 8 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> i = 14 ; <nl> arrQuat [ i ] . i0 = 7 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 8 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 , 0 , 0 ) ; <nl> arrQuat [ i ] . i2 = 5 ; <nl> t = edown ; <nl> uint32 GlobalAnimationHeaderAIM : : Debug_AnnotateExamples2 ( uint32 numPoses , QuadIn <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> i = 15 ; <nl> arrQuat [ i ] . i0 = 8 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 7 ; <nl> t = eside ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> if ( numPoses ! = 9 ) <nl> return q * 2 ; <nl> <nl> - uint32 i = - 1 ; <nl> - f32 t = 0 ; <nl> - <nl> f32 diag = 1 . 70f ; <nl> <nl> f32 eup = 1 . 60f ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> f32 edown = 1 . 6f ; <nl> f32 mdown = 1 . 20f ; <nl> <nl> - i = 4 ; <nl> + uint32 i = 4 ; <nl> arrQuat [ i ] . i0 = 3 ; <nl> - t = eup ; <nl> + f32 t = eup ; <nl> arrQuat [ i ] . w0 = Vec4 ( 1 - t , 0 , 0 , t ) ; / / 3 - mirrored 0 - scaled <nl> arrQuat [ i ] . i1 = 4 ; <nl> t = mup ; <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 - t , t , 0 ) ; / / 4 - mirrored 1 - scaled <nl> arrQuat [ i ] . i2 = 1 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 , 0 ) ; <nl> arrQuat [ i ] . i3 = 0 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> <nl> i = 5 ; <nl> arrQuat [ i ] . i0 = 3 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 4 ; <nl> t = mside ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> t = eside ; <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 - t , t ) ; / / 1 - mirrored 0 - scaled <nl> arrQuat [ i ] . i3 = 0 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> t = eup ; <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 - t , t , 0 ) ; / / 3 - mirrored 0 - scaled <nl> arrQuat [ i ] . i2 = 0 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 , 0 ) ; <nl> arrQuat [ i ] . i3 = 1 ; <nl> t = eside ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> <nl> i = 7 ; <nl> arrQuat [ i ] . i0 = 2 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 1 ; <nl> t = eside ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> t = mside ; <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 - t , t ) ; / / 4 - mirrored 5 - scaled <nl> arrQuat [ i ] . i3 = 5 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> t = eup ; <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 - t , t , 0 ) ; / / 5 - mirrored 2 - scaled <nl> arrQuat [ i ] . i2 = 2 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 , 0 ) ; <nl> arrQuat [ i ] . i3 = 1 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> t = eside ; <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 - t , t ) ; / / 1 - mirrored 2 - scaled <nl> arrQuat [ i ] . i3 = 2 ; <nl> - t = 1 . 0f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> t = mside ; <nl> arrQuat [ i ] . w0 = Vec4 ( 1 - t , t , 0 , 0 ) ; / / 4 - mirrored 3 - scaled <nl> arrQuat [ i ] . i1 = 3 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 , 0 , 0 ) ; <nl> arrQuat [ i ] . i2 = 6 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 , 0 ) ; <nl> arrQuat [ i ] . i3 = 7 ; <nl> t = eside ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> i = 11 ; <nl> arrQuat [ i ] . i0 = 6 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 7 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 , 0 , 0 ) ; <nl> arrQuat [ i ] . i2 = 4 ; <nl> t = mdown ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> t = eside ; <nl> arrQuat [ i ] . w0 = Vec4 ( 1 - t , t , 0 , 0 ) ; / / 7 - mirrored 6 - scaled <nl> arrQuat [ i ] . i1 = 6 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 , 0 , 0 ) ; <nl> arrQuat [ i ] . i2 = 3 ; <nl> t = edown ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> <nl> i = 13 ; <nl> arrQuat [ i ] . i0 = 5 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 4 ; <nl> t = mside ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> t = eside ; <nl> arrQuat [ i ] . w2 = Vec4 ( 0 , 0 , 1 - t , t ) ; / / 7 mirrored 8 - scaled <nl> arrQuat [ i ] . i3 = 8 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w3 = Vec4 ( 0 , 0 , 0 , 1 ) ; <nl> arrQuat [ i ] . col = RGBA8 ( 0xff , 0x00 , 0x00 , 0xff ) ; <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> i = 14 ; <nl> arrQuat [ i ] . i0 = 7 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 8 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w1 = Vec4 ( 0 , 1 , 0 , 0 ) ; <nl> arrQuat [ i ] . i2 = 5 ; <nl> t = edown ; <nl> uint32 VExampleInit : : AnnotateExamples ( uint32 numPoses , QuadIndices * arrQuat ) <nl> arrQuat [ i ] . height = Vec3 ( 0 , 0 , 0 . 001f ) ; <nl> i = 15 ; <nl> arrQuat [ i ] . i0 = 8 ; <nl> - t = 1 . 00f ; <nl> + <nl> arrQuat [ i ] . w0 = Vec4 ( 1 , 0 , 0 , 0 ) ; <nl> arrQuat [ i ] . i1 = 7 ; <nl> t = eside ; <nl> mmm a / Code / CryEngine / CryAnimation / LoaderCHR . cpp <nl> ppp b / Code / CryEngine / CryAnimation / LoaderCHR . cpp <nl> void CryCHRLoader : : StreamOnComplete ( IReadStream * pStream , unsigned nError ) <nl> pModelMesh - > InitRenderMeshSync ( m_arrNewRenderChunks , m_pNewRenderMesh ) ; <nl> m_pNewRenderMesh = nullptr ; <nl> m_arrNewRenderChunks . clear ( ) ; <nl> - <nl> - pModelMesh - > m_stream . pStreamer = nullptr ; <nl> } <nl> else if ( m_pModelSkin ) <nl> { <nl> EndStreamSkinSync ( pStream ) ; <nl> <nl> int nRenderLod = ( int ) pStream - > GetParams ( ) . dwUserData ; <nl> - m_pModelSkin - > m_arrModelMeshes [ nRenderLod ] . m_stream . pStreamer = NULL ; <nl> } <nl> - m_pStream = NULL ; <nl> - delete this ; <nl> + <nl> + ClearModel ( ) ; <nl> } <nl> <nl> / / cleans up the resources allocated during load <nl> void CryCHRLoader : : ClearModel ( ) <nl> { <nl> m_strGeomFileNameNoExt = " " ; <nl> - / / m_animListIDs . clear ( ) ; <nl> + m_pStream = nullptr ; <nl> + m_arrNewRenderChunks . clear ( ) ; <nl> + m_pNewRenderMesh = nullptr ; <nl> + m_RefByInstances . clear ( ) ; <nl> } <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> mmm a / Code / CryEngine / CryAnimation / Memory / MultiBuffer . h <nl> ppp b / Code / CryEngine / CryAnimation / Memory / MultiBuffer . h <nl> inline void * MultiBuffer < TTypeList > : : GetBuffer ( ) <nl> template < typename TTypeList > <nl> inline void * MultiBuffer < TTypeList > : : GetField ( size_t index ) <nl> { <nl> - assert ( GetBuffer ( ) ) ; <nl> + void * pBuffer = GetBuffer ( ) ; <nl> + assert ( pBuffer ) ; <nl> <nl> const size_t offset = ( index > 0 ) ? ( m_offsets [ index - 1 ] ) : ( 0 ) ; <nl> - return static_cast < char * > ( GetBuffer ( ) ) + offset ; <nl> + return static_cast < char * > ( pBuffer ) + offset ; <nl> } <nl> <nl> template < typename TTypeList > <nl> mmm a / Code / CryEngine / CryAnimation / ModelAnimationSet . cpp <nl> ppp b / Code / CryEngine / CryAnimation / ModelAnimationSet . cpp <nl> const char * CAnimationSet : : GetDBAFilePath ( const uint32 nAnimationId ) const <nl> int32 globalID = header . m_nGlobalAnimId ; <nl> if ( header . m_nAssetType = = CAF_File ) <nl> { <nl> + const CAnimationManager & animationManager = g_pCharacterManager - > GetAnimationManager ( ) ; <nl> assert ( globalID > = 0 ) ; <nl> - assert ( globalID < g_AnimationManager . m_arrGlobalCAF . size ( ) ) ; <nl> + assert ( globalID < animationManager . m_arrGlobalCAF . size ( ) ) ; <nl> return g_pCharacterManager - > GetDBAFilePathByGlobalID ( globalID ) ; <nl> } <nl> else <nl> uint32 CAnimationSet : : GetTotalPosKeys ( const uint32 nAnimationId ) const <nl> <nl> if ( header . m_nAssetType = = CAF_File ) <nl> { <nl> + const CAnimationManager & animationManager = g_pCharacterManager - > GetAnimationManager ( ) ; <nl> assert ( globalID > = 0 ) ; <nl> - assert ( globalID < g_AnimationManager . m_arrGlobalCAF . size ( ) ) ; <nl> - return g_AnimationManager . m_arrGlobalCAF [ globalID ] . GetTotalPosKeys ( ) ; <nl> + assert ( globalID < animationManager . m_arrGlobalCAF . size ( ) ) ; <nl> + return animationManager . m_arrGlobalCAF [ globalID ] . GetTotalPosKeys ( ) ; <nl> } <nl> return 0 ; <nl> } <nl> uint32 CAnimationSet : : GetTotalRotKeys ( const uint32 nAnimationId ) const <nl> <nl> if ( header . m_nAssetType = = CAF_File ) <nl> { <nl> + const CAnimationManager & animationManager = g_pCharacterManager - > GetAnimationManager ( ) ; <nl> assert ( globalID > = 0 ) ; <nl> - assert ( globalID < g_AnimationManager . m_arrGlobalCAF . size ( ) ) ; <nl> - return g_AnimationManager . m_arrGlobalCAF [ globalID ] . GetTotalRotKeys ( ) ; <nl> + assert ( globalID < animationManager . m_arrGlobalCAF . size ( ) ) ; <nl> + return animationManager . m_arrGlobalCAF [ globalID ] . GetTotalRotKeys ( ) ; <nl> } <nl> return 0 ; <nl> } <nl> mmm a / Code / CryEngine / CryAnimation / ModelMesh . h <nl> ppp b / Code / CryEngine / CryAnimation / ModelMesh . h <nl> struct RChunk <nl> <nl> struct MeshStreamInfo <nl> { <nl> - MeshStreamInfo ( ) <nl> + MeshStreamInfo ( ) : <nl> + nRoundIds ( ) , <nl> + nFrameId ( 0 ) , <nl> + nKeepResidentRefs ( 0 ) , <nl> + bHasMeshFile ( false ) , <nl> + bIsUrgent ( false ) , <nl> + pStreamer ( nullptr ) <nl> { <nl> - memset ( this , 0 , sizeof ( * this ) ) ; <nl> } <nl> <nl> uint32 nRoundIds [ MAX_STREAM_PREDICTION_ZONES ] ; <nl> struct MeshStreamInfo <nl> uint32 nKeepResidentRefs ; <nl> bool bHasMeshFile ; <nl> bool bIsUrgent ; <nl> - CryCHRLoader * pStreamer ; <nl> + std : : shared_ptr < CryCHRLoader > pStreamer ; <nl> } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / Code / CryEngine / CryAnimation / PoseModifier / PoseModifier . cpp <nl> ppp b / Code / CryEngine / CryAnimation / PoseModifier / PoseModifier . cpp <nl> CIkCCD : : CIkCCD ( ) : <nl> m_endNodeIndex ( - 1 ) , <nl> m_targetNodeIndex ( - 1 ) , <nl> m_weightNodeIndex ( - 1 ) , <nl> + m_nIterations ( 0 ) , <nl> + m_fStepSize ( 0 ) , <nl> + m_fThreshold ( 0 ) , <nl> m_bInitialized ( false ) , <nl> m_bDraw ( false ) <nl> { <nl> mmm a / Code / CryEngine / CryAnimation / Vertex / VertexCommandBuffer . h <nl> ppp b / Code / CryEngine / CryAnimation / Vertex / VertexCommandBuffer . h <nl> struct SVertexAnimationJob <nl> _smart_ptr < IRenderMesh > m_previousRenderMesh ; <nl> <nl> public : <nl> - SVertexAnimationJob ( ) : pRenderMeshSyncVariable ( nullptr ) { } <nl> + SVertexAnimationJob ( ) : commandBufferLength ( 0 ) , pRenderMeshSyncVariable ( nullptr ) , commandBuffer ( ) { } <nl> <nl> void Begin ( JobManager : : SJobState * pJob ) ; <nl> void Execute ( int ) ; <nl> mmm a / Code / CryEngine / CryCommon / Cry3DEngine / IRenderNode . h <nl> ppp b / Code / CryEngine / CryCommon / Cry3DEngine / IRenderNode . h <nl> struct IRenderNode : public IShadowCaster <nl> / / ! though the CryGUID could be used to generate it <nl> uint32 m_nEditorSelectionID ; <nl> <nl> - / / ! Used to request rendering of the object into cached shadow map <nl> - uint32 m_cachedShadowFrameId = 0 ; <nl> + / / ! Used to request visiting of the node during one - pass traversal <nl> + uint32 m_onePassTraversalFrameId = 0 ; <nl> } ; <nl> <nl> inline void IRenderNode : : SetViewDistRatio ( int nViewDistRatio ) <nl> struct SFogVolumeProperties <nl> / / Common parameters . <nl> / / Center position & rotation values are taken from the entity matrix . <nl> <nl> - int m_volumeType = IFogVolumeRenderNode : : eFogVolumeType_Box ; <nl> + int m_volumeType = IFogVolumeRenderNode : : eFogVolumeType_Box ; <nl> Vec3 m_size = Vec3 ( 1 . f ) ; <nl> ColorF m_color = ColorF ( 1 , 1 , 1 , 1 ) ; <nl> bool m_useGlobalFogColor = false ; <nl> mmm a / Code / CryEngine / CryCommon / CryCore / ToolsHelpers / ResourceCompilerHelper . inl <nl> ppp b / Code / CryEngine / CryCommon / CryCore / ToolsHelpers / ResourceCompilerHelper . inl <nl> <nl> / / Copyright 2001 - 2017 Crytek GmbH / Crytek Group . All rights reserved . <nl> <nl> # if ! defined ( CRY_PLATFORM ) <nl> - # error CRY_PLATFORM is not defined , probably # include " stdafx . h " is missing . <nl> + # error CRY_PLATFORM is not defined , probably # include " stdafx . h " is missing . <nl> # endif <nl> <nl> # if defined ( CRY_ENABLE_RC_HELPER ) <nl> <nl> - # undef RC_EXECUTABLE <nl> - # define RC_EXECUTABLE " rc . exe " <nl> + # undef RC_EXECUTABLE <nl> + # define RC_EXECUTABLE " rc . exe " <nl> <nl> - # include " ResourceCompilerHelper . h " <nl> - # include " EngineSettingsManager . h " <nl> - # include < CrySystem / File / LineStreamBuffer . h > <nl> - # include < CrySystem / CryUtils . h > <nl> + # include " ResourceCompilerHelper . h " <nl> + # include " EngineSettingsManager . h " <nl> + # include < CrySystem / File / LineStreamBuffer . h > <nl> + # include < CrySystem / CryUtils . h > <nl> <nl> - # pragma warning ( disable : 4312 ) <nl> + # pragma warning ( disable : 4312 ) <nl> <nl> - # include < CryCore / Platform / CryLibrary . h > <nl> - # include < shellapi . h > / / ShellExecuteW ( ) <nl> - # include < CryCore / Assert / CryAssert . h > <nl> + # include < CryCore / Platform / CryLibrary . h > <nl> + # include < shellapi . h > / / ShellExecuteW ( ) <nl> + # include < CryCore / Assert / CryAssert . h > <nl> <nl> - # include < stdio . h > <nl> - # include < memory > / / std : : unique_ptr for CryTIFPlugin . <nl> + # include < stdio . h > <nl> + # include < memory > / / std : : unique_ptr for CryTIFPlugin . <nl> <nl> / / pseudo - variable that represents the DOS header of the module <nl> EXTERN_C IMAGE_DOS_HEADER __ImageBase ; <nl> EXTERN_C IMAGE_DOS_HEADER __ImageBase ; <nl> namespace <nl> { <nl> <nl> - class RcLock <nl> - { <nl> - public : <nl> - RcLock ( ) <nl> - { <nl> - InitializeCriticalSection ( & m_cs ) ; <nl> - } <nl> - ~ RcLock ( ) <nl> + class RcLock <nl> { <nl> - DeleteCriticalSection ( & m_cs ) ; <nl> - } <nl> + public : <nl> + RcLock ( ) <nl> + { <nl> + InitializeCriticalSection ( & m_cs ) ; <nl> + } <nl> + ~ RcLock ( ) <nl> + { <nl> + DeleteCriticalSection ( & m_cs ) ; <nl> + } <nl> <nl> - void Lock ( ) <nl> - { <nl> - EnterCriticalSection ( & m_cs ) ; <nl> - } <nl> - void Unlock ( ) <nl> - { <nl> - LeaveCriticalSection ( & m_cs ) ; <nl> - } <nl> + void Lock ( ) <nl> + { <nl> + EnterCriticalSection ( & m_cs ) ; <nl> + } <nl> + void Unlock ( ) <nl> + { <nl> + LeaveCriticalSection ( & m_cs ) ; <nl> + } <nl> <nl> - private : <nl> - CRITICAL_SECTION m_cs ; <nl> - } ; <nl> + private : <nl> + CRITICAL_SECTION m_cs ; <nl> + } ; <nl> <nl> - template < class LockClass > <nl> - class RcAutoLock <nl> - { <nl> - public : <nl> - RcAutoLock ( LockClass & lock ) <nl> - : m_lock ( lock ) <nl> + template < class LockClass > <nl> + class RcAutoLock <nl> { <nl> - m_lock . Lock ( ) ; <nl> - } <nl> - ~ RcAutoLock ( ) <nl> - { <nl> - m_lock . Unlock ( ) ; <nl> - } <nl> + public : <nl> + RcAutoLock ( LockClass & lock ) <nl> + : m_lock ( lock ) <nl> + { <nl> + m_lock . Lock ( ) ; <nl> + } <nl> + ~ RcAutoLock ( ) <nl> + { <nl> + m_lock . Unlock ( ) ; <nl> + } <nl> <nl> - private : <nl> - RcAutoLock ( ) ; <nl> - RcAutoLock ( const RcAutoLock < LockClass > & ) ; <nl> - RcAutoLock < LockClass > & operator = ( const RcAutoLock < LockClass > & ) ; <nl> + private : <nl> + RcAutoLock ( ) ; <nl> + RcAutoLock ( const RcAutoLock < LockClass > & ) ; <nl> + RcAutoLock < LockClass > & operator = ( const RcAutoLock < LockClass > & ) ; <nl> <nl> - private : <nl> - LockClass & m_lock ; <nl> - } ; <nl> + private : <nl> + LockClass & m_lock ; <nl> + } ; <nl> <nl> - class CRcCancellationToken <nl> - { <nl> - public : <nl> - void SetHandle ( HANDLE handle ) <nl> + class CRcCancellationToken <nl> { <nl> - RcAutoLock < RcLock > lock ( m_lock ) ; <nl> - m_handle = handle ; <nl> - } <nl> + public : <nl> + void SetHandle ( HANDLE handle ) <nl> + { <nl> + RcAutoLock < RcLock > lock ( m_lock ) ; <nl> + m_handle = handle ; <nl> + } <nl> <nl> - void CancelProcess ( ) <nl> - { <nl> - RcAutoLock < RcLock > lock ( m_lock ) ; <nl> - if ( m_handle ) <nl> + void CancelProcess ( ) <nl> { <nl> - TerminateProcess ( m_handle , eRcExitCode_Crash ) ; <nl> - WaitForSingleObject ( m_handle , INFINITE ) ; <nl> + RcAutoLock < RcLock > lock ( m_lock ) ; <nl> + if ( m_handle ) <nl> + { <nl> + TerminateProcess ( m_handle , eRcExitCode_Crash ) ; <nl> + WaitForSingleObject ( m_handle , INFINITE ) ; <nl> + } <nl> } <nl> - } <nl> <nl> - private : <nl> - HANDLE m_handle = 0 ; <nl> - RcLock m_lock ; <nl> - } ; <nl> + private : <nl> + HANDLE m_handle = 0 ; <nl> + RcLock m_lock ; <nl> + } ; <nl> <nl> - static bool CallProcessHelper ( const wchar_t * szStartingDirectory , const wchar_t * szCommandLine , bool bShowWindow , LineStreamBuffer * pListener , int & exitCode , void * pEnvironment , CRcCancellationToken * pCancellationToken ) <nl> - { <nl> - if ( pCancellationToken ) <nl> + static bool CallProcessHelper ( const wchar_t * szStartingDirectory , const wchar_t * szCommandLine , bool bShowWindow , LineStreamBuffer * pListener , int & exitCode , void * pEnvironment , CRcCancellationToken * pCancellationToken ) <nl> { <nl> - pCancellationToken - > SetHandle ( 0 ) ; <nl> - } <nl> - <nl> - HANDLE hChildStdOutRd , hChildStdOutWr ; <nl> - HANDLE hChildStdInRd , hChildStdInWr ; <nl> - HANDLE handlesToInherit [ 2 ] = { } ; <nl> - PROCESS_INFORMATION pi = { 0 } ; <nl> - <nl> - / / Create a pipe to read the stdout of the RC . <nl> - typedef std : : unique_ptr < _PROC_THREAD_ATTRIBUTE_LIST , void ( * ) ( LPPROC_THREAD_ATTRIBUTE_LIST ) > AttributeListPtr ; <nl> - AttributeListPtr pAttributeList ( nullptr , [ ] ( LPPROC_THREAD_ATTRIBUTE_LIST p ) { } ) ; <nl> - <nl> - SECURITY_ATTRIBUTES saAttr = { 0 } ; <nl> - if ( pListener ) <nl> - { <nl> - saAttr . bInheritHandle = TRUE ; <nl> - saAttr . lpSecurityDescriptor = 0 ; <nl> - CreatePipe ( & hChildStdOutRd , & hChildStdOutWr , & saAttr , 0 ) ; <nl> - SetHandleInformation ( hChildStdOutRd , HANDLE_FLAG_INHERIT , 0 ) ; / / Need to do this according to MSDN <nl> - CreatePipe ( & hChildStdInRd , & hChildStdInWr , & saAttr , 0 ) ; <nl> - SetHandleInformation ( hChildStdInWr , HANDLE_FLAG_INHERIT , 0 ) ; / / Need to do this according to MSDN <nl> - <nl> - / / We do not want the RC process to inherit any handlers except a couple of std pipes to prevent cases when <nl> - / / deleting and renaming files in the engine can fail because there is more than one handle open to the same file . <nl> - handlesToInherit [ 0 ] = hChildStdOutWr ; <nl> - handlesToInherit [ 1 ] = hChildStdInRd ; <nl> - SIZE_T size = 0 ; <nl> - InitializeProcThreadAttributeList ( nullptr , 1 , 0 , & size ) ; <nl> - AttributeListPtr p ( reinterpret_cast < LPPROC_THREAD_ATTRIBUTE_LIST > ( HeapAlloc ( GetProcessHeap ( ) , 0 , size ) ) , [ ] ( LPPROC_THREAD_ATTRIBUTE_LIST p ) <nl> + if ( pCancellationToken ) <nl> { <nl> - DeleteProcThreadAttributeList ( p ) ; <nl> - HeapFree ( GetProcessHeap ( ) , 0 , p ) ; <nl> - } ) ; <nl> - if ( p & & InitializeProcThreadAttributeList ( p . get ( ) , 1 , 0 , & size ) ) <nl> - { <nl> - UpdateProcThreadAttribute ( p . get ( ) , 0 , PROC_THREAD_ATTRIBUTE_HANDLE_LIST , handlesToInherit , sizeof ( handlesToInherit ) , nullptr , nullptr ) ; <nl> - pAttributeList = std : : move ( p ) ; <nl> + pCancellationToken - > SetHandle ( 0 ) ; <nl> } <nl> - CRY_ASSERT ( pAttributeList ) ; <nl> - } <nl> <nl> - STARTUPINFOEXW siex = { 0 } ; <nl> - siex . StartupInfo . cb = sizeof ( siex ) ; <nl> - siex . lpAttributeList = pAttributeList . get ( ) ; <nl> - siex . StartupInfo . dwX = 100 ; <nl> - siex . StartupInfo . dwY = 100 ; <nl> - if ( pListener ) <nl> - { <nl> - siex . StartupInfo . hStdError = hChildStdOutWr ; <nl> - siex . StartupInfo . hStdOutput = hChildStdOutWr ; <nl> - siex . StartupInfo . hStdInput = hChildStdInRd ; <nl> - siex . StartupInfo . dwFlags = STARTF_USEPOSITION | STARTF_USESTDHANDLES ; <nl> - } <nl> - else <nl> - { <nl> - siex . StartupInfo . dwFlags = STARTF_USEPOSITION ; <nl> - } <nl> + HANDLE hChildStdOutRd , hChildStdOutWr ; <nl> + HANDLE hChildStdInRd , hChildStdInWr ; <nl> + HANDLE handlesToInherit [ 2 ] = { } ; <nl> + PROCESS_INFORMATION pi = { 0 } ; <nl> <nl> - const DWORD creationFlags = ( bShowWindow ? 0 : CREATE_NO_WINDOW ) | EXTENDED_STARTUPINFO_PRESENT | CREATE_UNICODE_ENVIRONMENT ; <nl> + / / Create a pipe to read the stdout of the RC . <nl> + typedef std : : unique_ptr < _PROC_THREAD_ATTRIBUTE_LIST , void ( * ) ( LPPROC_THREAD_ATTRIBUTE_LIST ) > AttributeListPtr ; <nl> + AttributeListPtr pAttributeList ( nullptr , [ ] ( LPPROC_THREAD_ATTRIBUTE_LIST p ) { } ) ; <nl> <nl> - SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 3 > wRemoteCmdLine ; <nl> - wRemoteCmdLine . append ( szCommandLine ) ; <nl> + SECURITY_ATTRIBUTES saAttr = { 0 } ; <nl> + if ( pListener ) <nl> + { <nl> + saAttr . bInheritHandle = TRUE ; <nl> + saAttr . lpSecurityDescriptor = 0 ; <nl> + CreatePipe ( & hChildStdOutRd , & hChildStdOutWr , & saAttr , 0 ) ; <nl> + SetHandleInformation ( hChildStdOutRd , HANDLE_FLAG_INHERIT , 0 ) ; / / Need to do this according to MSDN <nl> + CreatePipe ( & hChildStdInRd , & hChildStdInWr , & saAttr , 0 ) ; <nl> + SetHandleInformation ( hChildStdInWr , HANDLE_FLAG_INHERIT , 0 ) ; / / Need to do this according to MSDN <nl> + <nl> + / / We do not want the RC process to inherit any handlers except a couple of std pipes to prevent cases when <nl> + / / deleting and renaming files in the engine can fail because there is more than one handle open to the same file . <nl> + handlesToInherit [ 0 ] = hChildStdOutWr ; <nl> + handlesToInherit [ 1 ] = hChildStdInRd ; <nl> + SIZE_T size = 0 ; <nl> + InitializeProcThreadAttributeList ( nullptr , 1 , 0 , & size ) ; <nl> + AttributeListPtr p ( reinterpret_cast < LPPROC_THREAD_ATTRIBUTE_LIST > ( HeapAlloc ( GetProcessHeap ( ) , 0 , size ) ) , [ ] ( LPPROC_THREAD_ATTRIBUTE_LIST p ) <nl> + { <nl> + DeleteProcThreadAttributeList ( p ) ; <nl> + HeapFree ( GetProcessHeap ( ) , 0 , p ) ; <nl> + } ) ; <nl> + if ( p & & InitializeProcThreadAttributeList ( p . get ( ) , 1 , 0 , & size ) ) <nl> + { <nl> + UpdateProcThreadAttribute ( p . get ( ) , 0 , PROC_THREAD_ATTRIBUTE_HANDLE_LIST , handlesToInherit , sizeof ( handlesToInherit ) , nullptr , nullptr ) ; <nl> + pAttributeList = std : : move ( p ) ; <nl> + } <nl> + CRY_ASSERT ( pAttributeList ) ; <nl> + } <nl> <nl> - if ( ! CreateProcessW ( <nl> - nullptr , / / No module name ( use command line ) . <nl> - const_cast < wchar_t * > ( wRemoteCmdLine . c_str ( ) ) , / / Command line . <nl> - nullptr , / / Process handle not inheritable . <nl> - nullptr , / / Thread handle not inheritable . <nl> - pListener ? true : false , / / Handle inheritance . <nl> - creationFlags , / / creation flags . <nl> - pEnvironment , / / if null , use parent ' s environment block . <nl> - szStartingDirectory , / / Set starting directory . <nl> - & siex . StartupInfo , / / Pointer to STARTUPINFO structure . <nl> - & pi ) ) / / Pointer to PROCESS_INFORMATION structure . <nl> - { <nl> - / / The following code block is commented out instead of being deleted <nl> - / / because it ' s good to have at hand for a debugging session . <nl> + STARTUPINFOEXW siex = { 0 } ; <nl> + siex . StartupInfo . cb = sizeof ( siex ) ; <nl> + siex . lpAttributeList = pAttributeList . get ( ) ; <nl> + siex . StartupInfo . dwX = 100 ; <nl> + siex . StartupInfo . dwY = 100 ; <nl> + if ( pListener ) <nl> + { <nl> + siex . StartupInfo . hStdError = hChildStdOutWr ; <nl> + siex . StartupInfo . hStdOutput = hChildStdOutWr ; <nl> + siex . StartupInfo . hStdInput = hChildStdInRd ; <nl> + siex . StartupInfo . dwFlags = STARTF_USEPOSITION | STARTF_USESTDHANDLES ; <nl> + } <nl> + else <nl> + { <nl> + siex . StartupInfo . dwFlags = STARTF_USEPOSITION ; <nl> + } <nl> + <nl> + const DWORD creationFlags = ( bShowWindow ? 0 : CREATE_NO_WINDOW ) | EXTENDED_STARTUPINFO_PRESENT | CREATE_UNICODE_ENVIRONMENT ; <nl> + <nl> + SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 3 > wRemoteCmdLine ; <nl> + wRemoteCmdLine . append ( szCommandLine ) ; <nl> + <nl> + if ( ! CreateProcessW ( <nl> + nullptr , / / No module name ( use command line ) . <nl> + const_cast < wchar_t * > ( wRemoteCmdLine . c_str ( ) ) , / / Command line . <nl> + nullptr , / / Process handle not inheritable . <nl> + nullptr , / / Thread handle not inheritable . <nl> + pListener ? true : false , / / Handle inheritance . <nl> + creationFlags , / / creation flags . <nl> + pEnvironment , / / if null , use parent ' s environment block . <nl> + szStartingDirectory , / / Set starting directory . <nl> + & siex . StartupInfo , / / Pointer to STARTUPINFO structure . <nl> + & pi ) ) / / Pointer to PROCESS_INFORMATION structure . <nl> + { <nl> + / / The following code block is commented out instead of being deleted <nl> + / / because it ' s good to have at hand for a debugging session . <nl> # if 0 <nl> - const size_t charsInMessageBuffer = 32768 ; / / msdn about FormatMessage ( ) : " The output buffer cannot be larger than 64K bytes . " <nl> - wchar_t szMessageBuffer [ charsInMessageBuffer ] = L " " ; <nl> - FormatMessageW ( FORMAT_MESSAGE_FROM_SYSTEM , NULL , GetLastError ( ) , 0 , szMessageBuffer , charsInMessageBuffer , NULL ) ; <nl> - GetCurrentDirectoryW ( charsInMessageBuffer , szMessageBuffer ) ; <nl> + const size_t charsInMessageBuffer = 32768 ; / / msdn about FormatMessage ( ) : " The output buffer cannot be larger than 64K bytes . " <nl> + wchar_t szMessageBuffer [ charsInMessageBuffer ] = L " " ; <nl> + FormatMessageW ( FORMAT_MESSAGE_FROM_SYSTEM , NULL , GetLastError ( ) , 0 , szMessageBuffer , charsInMessageBuffer , NULL ) ; <nl> + GetCurrentDirectoryW ( charsInMessageBuffer , szMessageBuffer ) ; <nl> # endif <nl> - return false ; <nl> - } <nl> - <nl> - if ( pCancellationToken ) <nl> - { <nl> - pCancellationToken - > SetHandle ( pi . hProcess ) ; <nl> - } <nl> + return false ; <nl> + } <nl> <nl> - bool bFailedToReadOutput = false ; <nl> + if ( pCancellationToken ) <nl> + { <nl> + pCancellationToken - > SetHandle ( pi . hProcess ) ; <nl> + } <nl> <nl> - if ( pListener ) <nl> - { <nl> - / / Close the pipe that writes to the child process , since we don ' t actually have any input for it . <nl> - CloseHandle ( hChildStdInWr ) ; <nl> + bool bFailedToReadOutput = false ; <nl> <nl> - / / Read all the output from the child process . <nl> - CloseHandle ( hChildStdOutWr ) ; <nl> - for ( ; ; ) <nl> + if ( pListener ) <nl> { <nl> - char buffer [ 2048 ] ; <nl> - DWORD bytesRead ; <nl> - if ( ! ReadFile ( hChildStdOutRd , buffer , sizeof ( buffer ) , & bytesRead , NULL ) | | ( bytesRead = = 0 ) ) <nl> + / / Close the pipe that writes to the child process , since we don ' t actually have any input for it . <nl> + CloseHandle ( hChildStdInWr ) ; <nl> + <nl> + / / Read all the output from the child process . <nl> + CloseHandle ( hChildStdOutWr ) ; <nl> + for ( ; ; ) <nl> { <nl> - break ; <nl> + char buffer [ 2048 ] ; <nl> + DWORD bytesRead ; <nl> + if ( ! ReadFile ( hChildStdOutRd , buffer , sizeof ( buffer ) , & bytesRead , NULL ) | | ( bytesRead = = 0 ) ) <nl> + { <nl> + break ; <nl> + } <nl> + pListener - > HandleText ( buffer , bytesRead ) ; <nl> } <nl> - pListener - > HandleText ( buffer , bytesRead ) ; <nl> - } <nl> - CloseHandle ( hChildStdOutRd ) ; <nl> - CloseHandle ( hChildStdInRd ) ; <nl> + CloseHandle ( hChildStdOutRd ) ; <nl> + CloseHandle ( hChildStdInRd ) ; <nl> <nl> - bFailedToReadOutput = pListener - > IsTruncated ( ) ; <nl> - } <nl> + bFailedToReadOutput = pListener - > IsTruncated ( ) ; <nl> + } <nl> <nl> - / / Wait until child process exits . <nl> - WaitForSingleObject ( pi . hProcess , INFINITE ) ; <nl> + / / Wait until child process exits . <nl> + WaitForSingleObject ( pi . hProcess , INFINITE ) ; <nl> <nl> - if ( pCancellationToken ) <nl> - { <nl> - pCancellationToken - > SetHandle ( 0 ) ; <nl> - } <nl> + if ( pCancellationToken ) <nl> + { <nl> + pCancellationToken - > SetHandle ( 0 ) ; <nl> + } <nl> <nl> - DWORD processExitcode = 0 ; <nl> - if ( bFailedToReadOutput | | GetExitCodeProcess ( pi . hProcess , & processExitcode ) = = 0 ) <nl> - { <nl> - exitCode = eRcExitCode_Error ; <nl> - } <nl> + DWORD processExitcode = 0 ; <nl> + if ( bFailedToReadOutput | | GetExitCodeProcess ( pi . hProcess , & processExitcode ) = = 0 ) <nl> + { <nl> + exitCode = eRcExitCode_Error ; <nl> + } <nl> <nl> - exitCode = ( int ) processExitcode ; <nl> + exitCode = ( int ) processExitcode ; <nl> <nl> - / / Close process and thread handles . <nl> - CloseHandle ( pi . hProcess ) ; <nl> - CloseHandle ( pi . hThread ) ; <nl> + / / Close process and thread handles . <nl> + CloseHandle ( pi . hProcess ) ; <nl> + CloseHandle ( pi . hThread ) ; <nl> <nl> - return true ; <nl> - } <nl> + return true ; <nl> + } <nl> <nl> - CRcCancellationToken s_rcCancellationToken ; <nl> + CRcCancellationToken s_rcCancellationToken ; <nl> <nl> } <nl> <nl> CRcCancellationToken s_rcCancellationToken ; <nl> / / " " , " / / storage " , " / / storage / . " , " nonexisting_dir " , " f : / " ( if f : drive doesn ' t exist ) <nl> static bool DirectoryExists ( const wchar_t * szPathPart0 , const wchar_t * szPathPart1 = 0 ) <nl> { <nl> - SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 2 > dir ; <nl> + SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 2 > dir ; <nl> <nl> if ( szPathPart0 & & szPathPart0 [ 0 ] ) <nl> { <nl> static bool IsRelativePath ( const char * p ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> static void ShowMessageBoxRcNotFound ( const wchar_t * const szCmdLine , const wchar_t * const szDir ) <nl> { <nl> - SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 4 + 150 > tmp ; <nl> + SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 4 + 150 > tmp ; <nl> <nl> if ( szCmdLine & & szCmdLine [ 0 ] ) <nl> { <nl> static void CryFindEngineToolsFolder ( unsigned int nEngineToolsPathSize , wchar_t * <nl> return ; <nl> } <nl> <nl> - SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 2 > filename ; <nl> + SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 2 > filename ; <nl> <nl> while ( wchar_t * pathEnd = wcsrchr ( szEngineToolsPath , L ' \ \ ' ) ) <nl> { <nl> static void CryFindEngineToolsFolder ( unsigned int nEngineToolsPathSize , wchar_t * <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> namespace <nl> { <nl> - class ResourceCompilerLineHandler <nl> - { <nl> - public : <nl> - ResourceCompilerLineHandler ( IResourceCompilerListener * listener ) <nl> - : m_listener ( listener ) <nl> + class ResourceCompilerLineHandler <nl> { <nl> - } <nl> - <nl> - void HandleLine ( const char * line ) <nl> - { <nl> - if ( ! m_listener | | ! line ) <nl> + public : <nl> + ResourceCompilerLineHandler ( IResourceCompilerListener * listener ) <nl> + : m_listener ( listener ) <nl> { <nl> - return ; <nl> } <nl> <nl> - / / check the first three characters to see if it ' s a warning or error . <nl> - bool bHasPrefix ; <nl> - IResourceCompilerListener : : MessageSeverity severity ; <nl> - if ( ( line [ 0 ] = = ' E ' ) & & ( line [ 1 ] = = ' : ' ) & & ( line [ 2 ] = = ' ' ) ) <nl> + void HandleLine ( const char * line ) <nl> { <nl> - bHasPrefix = true ; <nl> - severity = IResourceCompilerListener : : MessageSeverity_Error ; <nl> - line + = 3 ; / / skip the prefix <nl> - } <nl> - else if ( ( line [ 0 ] = = ' W ' ) & & ( line [ 1 ] = = ' : ' ) & & ( line [ 2 ] = = ' ' ) ) <nl> - { <nl> - bHasPrefix = true ; <nl> - severity = IResourceCompilerListener : : MessageSeverity_Warning ; <nl> - line + = 3 ; / / skip the prefix <nl> - } <nl> - else if ( ( line [ 0 ] = = ' ' ) & & ( line [ 1 ] = = ' ' ) & & ( line [ 2 ] = = ' ' ) ) <nl> - { <nl> - bHasPrefix = true ; <nl> - severity = IResourceCompilerListener : : MessageSeverity_Info ; <nl> - line + = 3 ; / / skip the prefix <nl> - } <nl> - else <nl> - { <nl> - bHasPrefix = false ; <nl> - severity = IResourceCompilerListener : : MessageSeverity_Info ; <nl> - } <nl> + if ( ! m_listener | | ! line ) <nl> + { <nl> + return ; <nl> + } <nl> <nl> - if ( bHasPrefix ) <nl> - { <nl> - / / skip thread info " % d > " , if present <nl> + / / check the first three characters to see if it ' s a warning or error . <nl> + bool bHasPrefix ; <nl> + IResourceCompilerListener : : MessageSeverity severity ; <nl> + if ( ( line [ 0 ] = = ' E ' ) & & ( line [ 1 ] = = ' : ' ) & & ( line [ 2 ] = = ' ' ) ) <nl> { <nl> - const char * p = line ; <nl> - while ( * p = = ' ' ) <nl> - { <nl> - + + p ; <nl> - } <nl> - if ( isdigit ( * p ) ) <nl> + bHasPrefix = true ; <nl> + severity = IResourceCompilerListener : : MessageSeverity_Error ; <nl> + line + = 3 ; / / skip the prefix <nl> + } <nl> + else if ( ( line [ 0 ] = = ' W ' ) & & ( line [ 1 ] = = ' : ' ) & & ( line [ 2 ] = = ' ' ) ) <nl> + { <nl> + bHasPrefix = true ; <nl> + severity = IResourceCompilerListener : : MessageSeverity_Warning ; <nl> + line + = 3 ; / / skip the prefix <nl> + } <nl> + else if ( ( line [ 0 ] = = ' ' ) & & ( line [ 1 ] = = ' ' ) & & ( line [ 2 ] = = ' ' ) ) <nl> + { <nl> + bHasPrefix = true ; <nl> + severity = IResourceCompilerListener : : MessageSeverity_Info ; <nl> + line + = 3 ; / / skip the prefix <nl> + } <nl> + else <nl> + { <nl> + bHasPrefix = false ; <nl> + severity = IResourceCompilerListener : : MessageSeverity_Info ; <nl> + } <nl> + <nl> + if ( bHasPrefix ) <nl> + { <nl> + / / skip thread info " % d > " , if present <nl> { <nl> - while ( isdigit ( * p ) ) <nl> + const char * p = line ; <nl> + while ( * p = = ' ' ) <nl> { <nl> + + p ; <nl> } <nl> - if ( * p = = ' > ' ) <nl> + if ( isdigit ( * p ) ) <nl> { <nl> - line = p + 1 ; <nl> + while ( isdigit ( * p ) ) <nl> + { <nl> + + + p ; <nl> + } <nl> + if ( * p = = ' > ' ) <nl> + { <nl> + line = p + 1 ; <nl> + } <nl> } <nl> } <nl> - } <nl> <nl> - / / skip time info " % d : % d " , if present <nl> - { <nl> - const char * p = line ; <nl> - while ( * p = = ' ' ) <nl> - { <nl> - + + p ; <nl> - } <nl> - if ( isdigit ( * p ) ) <nl> + / / skip time info " % d : % d " , if present <nl> { <nl> - while ( isdigit ( * p ) ) <nl> + const char * p = line ; <nl> + while ( * p = = ' ' ) <nl> { <nl> + + p ; <nl> } <nl> - if ( * p = = ' : ' ) <nl> + if ( isdigit ( * p ) ) <nl> { <nl> - + + p ; <nl> - if ( isdigit ( * p ) ) <nl> + while ( isdigit ( * p ) ) <nl> { <nl> - while ( isdigit ( * p ) ) <nl> - { <nl> - + + p ; <nl> - } <nl> - while ( * p = = ' ' ) <nl> + + + p ; <nl> + } <nl> + if ( * p = = ' : ' ) <nl> + { <nl> + + + p ; <nl> + if ( isdigit ( * p ) ) <nl> { <nl> - + + p ; <nl> + while ( isdigit ( * p ) ) <nl> + { <nl> + + + p ; <nl> + } <nl> + while ( * p = = ' ' ) <nl> + { <nl> + + + p ; <nl> + } <nl> + line = p ; <nl> } <nl> - line = p ; <nl> } <nl> } <nl> } <nl> } <nl> - } <nl> <nl> - m_listener - > OnRCMessage ( severity , line ) ; <nl> - } <nl> + m_listener - > OnRCMessage ( severity , line ) ; <nl> + } <nl> <nl> - private : <nl> - IResourceCompilerListener * m_listener ; <nl> - } ; <nl> + private : <nl> + IResourceCompilerListener * m_listener ; <nl> + } ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> int CResourceCompilerHelper : : GetResourceCompilerConfigPath ( char * outBuffer , size <nl> if ( ! pathBuffer [ 0 ] ) <nl> { <nl> dirFound = false ; <nl> - } else { <nl> + } <nl> + else <nl> + { <nl> rcIniPath . append ( & pathBuffer [ 0 ] ) ; <nl> rcIniPath . append ( L " / Tools / rc " ) ; <nl> } <nl> - <nl> + <nl> break ; <nl> case eRcExePath_editor : <nl> CryFindEngineToolsFolder ( CRY_ARRAY_COUNT ( pathBuffer ) , pathBuffer ) ; <nl> int CResourceCompilerHelper : : GetResourceCompilerConfigPath ( char * outBuffer , size <nl> { <nl> dirFound = false ; <nl> } <nl> - else { <nl> + else <nl> + { <nl> rcIniPath . append ( & pathBuffer [ 0 ] ) ; <nl> rcIniPath . append ( L " / rc " ) ; <nl> } <nl> - <nl> + <nl> break ; <nl> default : <nl> dirFound = false ; <nl> int CResourceCompilerHelper : : GetResourceCompilerConfigPath ( char * outBuffer , size <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> bool CResourceCompilerHelper : : CallProcess ( const wchar_t * szStartingDirectory , const wchar_t * szCommandLine , bool bShowWindow , LineStreamBuffer * pListener , int & exitCode , void * pEnvironment ) <nl> - { <nl> + { <nl> return CallProcessHelper ( szStartingDirectory , szCommandLine , bShowWindow , pListener , exitCode , pEnvironment , nullptr ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> CResourceCompilerHelper : : ERcCallResult CResourceCompilerHelper : : CallResourceCompiler ( <nl> - const char * szFileName , <nl> - const char * szAdditionalSettings , <nl> - IResourceCompilerListener * listener , <nl> - bool bMayShowWindow , <nl> - CResourceCompilerHelper : : ERcExePath rcExePath , <nl> - bool bSilent , <nl> - bool bNoUserDialog , <nl> - const wchar_t * szWorkingDirectory ) <nl> + const char * szFileName , <nl> + const char * szAdditionalSettings , <nl> + IResourceCompilerListener * listener , <nl> + bool bMayShowWindow , <nl> + CResourceCompilerHelper : : ERcExePath rcExePath , <nl> + bool bSilent , <nl> + bool bNoUserDialog , <nl> + const wchar_t * szWorkingDirectory ) <nl> { <nl> / / make command for execution <nl> - SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 3 > wRemoteCmdLine ; <nl> + SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 3 > wRemoteCmdLine ; <nl> CSettingsManagerTools smTools = CSettingsManagerTools ( ) ; <nl> <nl> if ( ! szAdditionalSettings ) <nl> CResourceCompilerHelper : : ERcCallResult CResourceCompilerHelper : : CallResourceComp <nl> szAdditionalSettings = " " ; <nl> } <nl> <nl> - SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 3 > rcDirectory ; <nl> + SettingsManagerHelpers : : CFixedString < wchar_t , MAX_PATH * 3 > rcDirectory ; <nl> { <nl> wchar_t pathBuffer [ 512 ] ; <nl> switch ( rcExePath ) <nl> CResourceCompilerHelper : : ERcCallResult CResourceCompilerHelper : : CallResourceComp <nl> } <nl> <nl> bool bSucceed = true ; <nl> - int exitCode ; <nl> + int exitCode ; <nl> if ( listener ) <nl> { <nl> ResourceCompilerLineHandler lineHandler ( listener ) ; <nl> ERcExitCode CResourceCompilerHelper : : InvokeResourceCompiler ( const char * szSrcFil <nl> RemovePath ( szDstFilePath , szDstFilename , CRY_ARRAY_COUNT ( szDstFilename ) ) ; <nl> RemoveFilename ( szDstFilePath , szDstPath , CRY_ARRAY_COUNT ( szDstPath ) ) ; <nl> <nl> - wRemoteCmdLine . appendAscii ( " / overwritefilename = \ " " ) ; <nl> + wRemoteCmdLine . appendAscii ( " \ " / overwritefilename = " ) ; <nl> wRemoteCmdLine . appendAscii ( szDstFilename ) ; <nl> wRemoteCmdLine . appendAscii ( " \ " " ) ; <nl> - wRemoteCmdLine . appendAscii ( " / targetroot = \ " " ) ; <nl> + wRemoteCmdLine . appendAscii ( " \ " / targetroot = " ) ; <nl> if ( IsRelativePath ( szDstPath ) ) <nl> { <nl> wRemoteCmdLine . append ( szProjectDir ) ; <nl> ERcExitCode CResourceCompilerHelper : : InvokeResourceCompiler ( const char * szSrcFil <nl> PROCESS_INFORMATION pi ; <nl> ZeroMemory ( & pi , sizeof ( pi ) ) ; <nl> <nl> - # if defined ( DEBUG ) & & ! defined ( NDEBUG ) & & defined ( _RENDERER ) <nl> + # if defined ( DEBUG ) & & ! defined ( NDEBUG ) & & defined ( _RENDERER ) <nl> extern ILog * iLog ; <nl> <nl> char tmp1 [ 512 ] ; <nl> ERcExitCode CResourceCompilerHelper : : InvokeResourceCompiler ( const char * szSrcFil <nl> SettingsManagerHelpers : : ConvertUtf16ToUtf8 ( wRemoteCmdLine . c_str ( ) , dst2 ) ; <nl> <nl> iLog - > Log ( " Debug : RC : dir \ " % s \ " , cmd \ " % s \ " \ n " , tmp1 , tmp2 ) ; <nl> - # endif <nl> + # endif <nl> <nl> if ( ! CreateProcessW ( <nl> - NULL , / / No module name ( use command line ) . <nl> - const_cast < wchar_t * > ( wRemoteCmdLine . c_str ( ) ) , / / Command line . <nl> - NULL , / / Process handle not inheritable . <nl> - NULL , / / Thread handle not inheritable . <nl> - FALSE , / / Set handle inheritance to FALSE . <nl> - BELOW_NORMAL_PRIORITY_CLASS + ( bUserDialog ? 0 : CREATE_NO_WINDOW ) , / / creation flags . <nl> - NULL , / / Use parent ' s environment block . <nl> - wDir . c_str ( ) , / / Set starting directory . <nl> - & si , / / Pointer to STARTUPINFO structure . <nl> - & pi ) ) / / Pointer to PROCESS_INFORMATION structure . <nl> + NULL , / / No module name ( use command line ) . <nl> + const_cast < wchar_t * > ( wRemoteCmdLine . c_str ( ) ) , / / Command line . <nl> + NULL , / / Process handle not inheritable . <nl> + NULL , / / Thread handle not inheritable . <nl> + FALSE , / / Set handle inheritance to FALSE . <nl> + BELOW_NORMAL_PRIORITY_CLASS + ( bUserDialog ? 0 : CREATE_NO_WINDOW ) , / / creation flags . <nl> + NULL , / / Use parent ' s environment block . <nl> + wDir . c_str ( ) , / / Set starting directory . <nl> + & si , / / Pointer to STARTUPINFO structure . <nl> + & pi ) ) / / Pointer to PROCESS_INFORMATION structure . <nl> { <nl> eRet = eRcExitCode_FatalError ; <nl> } <nl> void CResourceCompilerHelper : : GetOutputFilename ( const char * szFilePath , char * bu <nl> if ( ext ) <nl> { <nl> if ( stricmp ( ext , " tif " ) = = 0 | | <nl> - stricmp ( ext , " hdr " ) = = 0 ) <nl> + stricmp ( ext , " hdr " ) = = 0 ) <nl> { <nl> ReplaceExtension ( szFilePath , " dds " , buffer , bufferSizeInBytes ) ; <nl> return ; <nl> bool CResourceCompilerHelper : : IsImageFormat ( const char * szExtension ) <nl> if ( szExtension ) <nl> { <nl> if ( stricmp ( szExtension , " dds " ) = = 0 | | / / DirectX surface format <nl> - stricmp ( szExtension , " hdr " ) = = 0 ) / / RGBE high dynamic range image <nl> + stricmp ( szExtension , " hdr " ) = = 0 ) / / RGBE high dynamic range image <nl> { <nl> return true ; <nl> } <nl> mmm a / Code / CryEngine / CryCommon / CrySchematyc2 / BasicTypes . h <nl> ppp b / Code / CryEngine / CryCommon / CrySchematyc2 / BasicTypes . h <nl> namespace Schematyc2 <nl> # else <nl> typedef struct <nl> { <nl> - unsigned long Data1 ; <nl> - unsigned short Data2 ; <nl> - unsigned short Data3 ; <nl> - unsigned char Data4 [ 8 ] ; <nl> + uint32 Data1 ; <nl> + uint16 Data2 ; <nl> + uint16 Data3 ; <nl> + uint8 Data4 [ 8 ] ; <nl> } SysGUID ; <nl> # endif <nl> <nl> mmm a / Code / CryEngine / CryCommon / CrySchematyc2 / GUID . h <nl> ppp b / Code / CryEngine / CryCommon / CrySchematyc2 / GUID . h <nl> namespace Schematyc2 <nl> CryGUID cryGUID ; <nl> SysGUID sysGUID ; <nl> } ; <nl> + <nl> + static_assert ( sizeof ( CryGUID ) = = sizeof ( SysGUID ) , " CryGUID and SysGUID have different sizes " ) ; <nl> + static_assert ( sizeof ( CryGUID ) = = 16 , " CryGUID has unexpected size " ) ; <nl> } ; <nl> + static_assert ( sizeof ( SGUID ) = = 16 , " SGUID has unexpected size " ) ; <nl> <nl> inline bool Serialize ( Serialization : : IArchive & archive , SGUID & value , const char * szName , const char * szLabel ) <nl> { <nl> mmm a / Code / CryEngine / CryCommon / CrySchematyc2 / Utils / StringUtils . h <nl> ppp b / Code / CryEngine / CryCommon / CrySchematyc2 / Utils / StringUtils . h <nl> namespace Schematyc2 <nl> CRY_ASSERT ( outputSize > = s_uint32StringBufferSize ) ; <nl> if ( outputSize > = s_uint32StringBufferSize ) <nl> { <nl> - ltoa ( input , output . begin ( ) , 10 ) ; <nl> + _ui64toa ( input , output . begin ( ) , 10 ) ; <nl> } <nl> else if ( outputSize > 0 ) <nl> { <nl> namespace Schematyc2 <nl> inline const char * UInt32ToString ( uint32 input , stack_string & output ) <nl> { <nl> char temp [ s_uint32StringBufferSize ] = " " ; <nl> - ltoa ( input , temp , 10 ) ; <nl> + _ui64toa ( input , temp , 10 ) ; <nl> output = temp ; <nl> return output . c_str ( ) ; <nl> } <nl> namespace Schematyc2 <nl> inline const char * UInt32ToString ( uint32 input , string & output ) <nl> { <nl> char temp [ s_uint32StringBufferSize ] = " " ; <nl> - ltoa ( input , temp , 10 ) ; <nl> + _ui64toa ( input , temp , 10 ) ; <nl> output = temp ; <nl> return output . c_str ( ) ; <nl> } <nl> mmm a / Code / CryEngine / RenderDll / Common / RenderDisplayContext . cpp <nl> ppp b / Code / CryEngine / RenderDll / Common / RenderDisplayContext . cpp <nl> void CRenderDisplayContext : : AllocateSwapChain ( ) <nl> scDesc . BufferCount = ( isMainContext & & ( CRenderer : : CV_r_minimizeLatency > 0 | | bWaitable ) ) ? MAX_FRAMES_IN_FLIGHT : defaultBufferCount ; <nl> scDesc . OutputWindow = ( HWND ) m_hWnd ; <nl> <nl> - scDesc . Windowed = windowed ? 1 : 0 ; <nl> + / / Always create a swapchain for windowed mode as per Microsoft recommendations here : https : / / msdn . microsoft . com / en - us / library / windows / desktop / bb174579 ( v = vs . 85 ) . aspx <nl> + / / Specifically : " We recommend that you create a windowed swap chain and allow the end user to change the swap chain to full screen through SetFullscreenState ; that is , do not set the Windowed member of DXGI_SWAP_CHAIN_DESC to FALSE to force the swap chain to be full screen . " <nl> + scDesc . Windowed = 1 ; <nl> scDesc . SwapEffect = DXGI_SWAP_EFFECT_DISCARD ; <nl> scDesc . Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH ; <nl> <nl> mmm a / Code / CryEngine / RenderDll / XRenderD3D9 / D3DSystem . cpp <nl> ppp b / Code / CryEngine / RenderDll / XRenderD3D9 / D3DSystem . cpp <nl> bool CD3D9Renderer : : HandleMessage ( HWND hWnd , UINT message , WPARAM wParam , LPARAM <nl> } <nl> } <nl> break ; <nl> + <nl> + case WM_ACTIVATE : <nl> + { <nl> + / / Toggle DXGI fullscreen state when user alt - tabs out <nl> + / / This is required since we explicitly set the DXGI_MWA_NO_WINDOW_CHANGES , forbidding DXGI from handling this itself <nl> + if ( IsFullscreen ( ) ) <nl> + { <nl> + gcpRendD3D - > ExecuteRenderThreadCommand ( [ wParam ] ( ) <nl> + { <nl> + gcpRendD3D - > GetBaseDisplayContext ( ) - > SetFullscreenState ( wParam ! = 0 ) ; <nl> + } , ERenderCommandFlags : : FlushAndWait ) ; <nl> + } <nl> + } <nl> + break ; <nl> } <nl> return false ; <nl> } <nl> mmm a / Code / Sandbox / Libs / CrySubstance / SubstancePreset . cpp <nl> ppp b / Code / Sandbox / Libs / CrySubstance / SubstancePreset . cpp <nl> CSubstancePreset : : ~ CSubstancePreset ( ) <nl> void CSubstancePreset : : LoadGraphInstance ( ) <nl> { <nl> m_pGraphInstance = CSubstanceManager : : Instance ( ) - > InstantiateGraph ( m_substanceArchive , m_graphName ) ; <nl> + if ( ! m_pGraphInstance ) <nl> + { <nl> + return ; <nl> + } <nl> + <nl> for each ( SubstanceAir : : InputInstanceBase * inputInstance in m_pGraphInstance - > getInputs ( ) ) <nl> { <nl> if ( inputInstance - > mDesc . mIdentifier = = " $ outputsize " ) <nl> mmm a / Code / Sandbox / Plugins / DependencyGraph / GraphView . cpp <nl> ppp b / Code / Sandbox / Plugins / DependencyGraph / GraphView . cpp <nl> void CGraphView : : ShowGraphContextMenu ( QPointF screenPos ) <nl> CAbstractDictionary * pAvailableNodesDictionary = pModel - > GetRuntimeContext ( ) . GetAvailableNodesDictionary ( ) ; <nl> if ( pAvailableNodesDictionary ) <nl> { <nl> - m_pSearchPopupContent - > SetDictionary ( * pAvailableNodesDictionary ) ; <nl> + m_pSearchPopupContent - > AddDictionary ( * pAvailableNodesDictionary ) ; <nl> m_pSearchPopup - > ShowAt ( QPoint ( screenPos . x ( ) , screenPos . y ( ) ) ) ; <nl> } <nl> } <nl> mmm a / Code / Sandbox / Plugins / EditorAnimation / AnimationCompressionManager . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAnimation / AnimationCompressionManager . cpp <nl> class CAnimationCompressionManager : : CBackgroundTaskUpdateLocalAnimations : publi <nl> { <nl> public : <nl> CBackgroundTaskUpdateLocalAnimations ( CAnimationCompressionManager * pManager ) <nl> - : m_pManager ( pManager ) <nl> + : m_pManager ( pManager ) , <nl> + m_totalFileCount ( 0 ) <nl> { <nl> } <nl> <nl> mmm a / Code / Sandbox / Plugins / EditorAnimation / CharacterTool / AnimEventPlayers . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAnimation / CharacterTool / AnimEventPlayers . cpp <nl> TSerializeParameterFunc g_atlEventFunctions [ sizeof ( g_atlEvents ) / sizeof ( g_atlEv <nl> static Vec3 GetBonePosition ( ICharacterInstance * character , const QuatTS & physicalLocation , const char * boneName ) <nl> { <nl> int jointId = - 1 ; <nl> - if ( boneName ! = ' \ 0 ' ) <nl> + if ( boneName & & boneName [ 0 ] ! = ' \ 0 ' ) <nl> jointId = character - > GetIDefaultSkeleton ( ) . GetJointIDByName ( boneName ) ; <nl> if ( jointId ! = - 1 ) <nl> return ( physicalLocation * character - > GetISkeletonPose ( ) - > GetAbsJointByID ( jointId ) ) . t ; <nl> mmm a / Code / Sandbox / Plugins / EditorAnimation / CharacterTool / CompressionMachine . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorAnimation / CharacterTool / CompressionMachine . cpp <nl> static void FormatPreviewName ( string * name , string * path , int index ) <nl> CompressionMachine : : CompressionMachine ( ) <nl> : m_state ( eState_Idle ) <nl> , m_showOriginalAnimation ( false ) <nl> + , m_loop ( false ) <nl> , m_previewReloadListener ( new AnimationSetExtender ( this ) ) <nl> , m_referenceReloadListener ( new AnimationSetExtender ( this ) ) <nl> , m_normalizedStartTime ( 0 . 0f ) <nl> mmm a / Code / Sandbox / Plugins / EditorAnimation / CharacterTool / CompressionMachine . h <nl> ppp b / Code / Sandbox / Plugins / EditorAnimation / CharacterTool / CompressionMachine . h <nl> class CompressionMachine : public QObject , public InterlockedReferenceTarget <nl> string uncompressedAnimationPath ; <nl> <nl> Animation ( ) <nl> - : state ( eAnimationState_NotSet ) <nl> - , enabled ( true ) <nl> + : enabled ( true ) <nl> + , state ( eAnimationState_NotSet ) <nl> + , type ( UNKNOWN ) <nl> , hasSourceFile ( true ) <nl> , hasReferenceCompressed ( false ) <nl> , hasPreviewCompressed ( false ) <nl> - , type ( UNKNOWN ) <nl> + , previewTask ( nullptr ) <nl> + , referenceTask ( nullptr ) <nl> + , compressionSessionIndex ( 0 ) <nl> { } <nl> <nl> } ; <nl> mmm a / Code / Sandbox / Plugins / EditorAnimation / CharacterTool / GizmoSink . h <nl> ppp b / Code / Sandbox / Plugins / EditorAnimation / CharacterTool / GizmoSink . h <nl> enum GizmoLayer <nl> class GizmoSink : public Serialization : : IGizmoSink <nl> { <nl> public : <nl> - GizmoSink ( ) : m_lastIndex ( 0 ) , m_scene ( 0 ) { } <nl> + GizmoSink ( ) : m_lastIndex ( 0 ) , m_currentLayer ( 0 ) , m_scene ( 0 ) { } <nl> void SetScene ( Manip : : CScene * scene ) { m_scene = scene ; } <nl> ExplorerEntry * ActiveEntry ( ) { return m_activeEntry . get ( ) ; } <nl> <nl> mmm a / Code / Sandbox / Plugins / EditorSchematyc / ComponentsWidget . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorSchematyc / ComponentsWidget . cpp <nl> void CComponentsWidget : : OnContextMenu ( const QPoint & point ) <nl> else <nl> { <nl> if ( m_pModel ) <nl> - m_pContextMenuContent - > SetDictionary ( * m_pModel - > GetAvailableComponentsDictionary ( ) ) ; <nl> + m_pContextMenuContent - > AddDictionary ( * m_pModel - > GetAvailableComponentsDictionary ( ) ) ; <nl> <nl> m_pContextMenu - > ShowAt ( menuPos ) ; <nl> } <nl> void CComponentsWidget : : OnAddButton ( bool checked ) <nl> const QPoint menuPos = m_pAddButton - > mapToGlobal ( m_pAddButton - > mapFromParent ( m_pAddButton - > pos ( ) ) ) ; <nl> <nl> if ( m_pModel ) <nl> - m_pContextMenuContent - > SetDictionary ( * m_pModel - > GetAvailableComponentsDictionary ( ) ) ; <nl> + m_pContextMenuContent - > AddDictionary ( * m_pModel - > GetAvailableComponentsDictionary ( ) ) ; <nl> <nl> m_pContextMenu - > ShowAt ( menuPos , QPopupWidget : : TopRight ) ; <nl> } <nl> mmm a / Code / Sandbox / Plugins / EditorSchematyc / NodeGraphRuntimeContext . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorSchematyc / NodeGraphRuntimeContext . cpp <nl> CNodesDictionary : : ~ CNodesDictionary ( ) <nl> Clear ( ) ; <nl> } <nl> <nl> + void CNodesDictionary : : ClearEntries ( ) <nl> + { <nl> + for ( CNodesDictionaryCategoryEntry * pCategoryEntry : m_categories ) <nl> + { <nl> + delete pCategoryEntry ; <nl> + } <nl> + m_categories . clear ( ) ; <nl> + <nl> + for ( CNodesDictionaryNodeEntry * pNodeEntry : m_nodes ) <nl> + { <nl> + delete pNodeEntry ; <nl> + } <nl> + m_nodes . clear ( ) ; <nl> + } <nl> + <nl> const CAbstractDictionaryEntry * CNodesDictionary : : GetEntry ( int32 index ) const <nl> { <nl> if ( index < m_categories . size ( ) ) <nl> void CNodesDictionary : : LoadLoadsFromScriptGraph ( Schematyc : : IScriptGraph & scriptG <nl> scriptGraph . PopulateNodeCreationMenu ( creator ) ; <nl> } <nl> <nl> - void CNodesDictionary : : Clear ( ) <nl> - { <nl> - for ( CNodesDictionaryCategoryEntry * pCategoryEntry : m_categories ) <nl> - { <nl> - delete pCategoryEntry ; <nl> - } <nl> - m_categories . clear ( ) ; <nl> - <nl> - for ( CNodesDictionaryNodeEntry * pNodeEntry : m_nodes ) <nl> - { <nl> - delete pNodeEntry ; <nl> - } <nl> - m_nodes . clear ( ) ; <nl> - } <nl> - <nl> void AddNodeStyle ( CryGraphEditor : : CNodeGraphViewStyle & viewStyle , const char * szStyleId , const char * szIcon , QColor color , bool coloredHeaderIconText = true ) <nl> { <nl> CryGraphEditor : : CNodeWidgetStyle * pStyle = new CryGraphEditor : : CNodeWidgetStyle ( szStyleId , viewStyle ) ; <nl> mmm a / Code / Sandbox / Plugins / EditorSchematyc / NodeGraphRuntimeContext . h <nl> ppp b / Code / Sandbox / Plugins / EditorSchematyc / NodeGraphRuntimeContext . h <nl> class CNodesDictionary : public CAbstractDictionary <nl> virtual ~ CNodesDictionary ( ) ; <nl> <nl> / / CAbstractDictionary <nl> + virtual void ClearEntries ( ) override ; <nl> virtual int32 GetNumEntries ( ) const override { return m_categories . size ( ) + m_nodes . size ( ) ; } <nl> virtual const CAbstractDictionaryEntry * GetEntry ( int32 index ) const override ; <nl> <nl> class CNodesDictionary : public CAbstractDictionary <nl> void LoadLoadsFromScriptGraph ( Schematyc : : IScriptGraph & scriptGraph ) ; <nl> void SetStyle ( const CryGraphEditor : : CNodeGraphViewStyle * pStyle ) { m_pStyle = pStyle ; } <nl> <nl> - void Clear ( ) ; <nl> - <nl> private : <nl> const CryGraphEditor : : CNodeGraphViewStyle * m_pStyle ; <nl> std : : vector < CNodesDictionaryCategoryEntry * > m_categories ; <nl> mmm a / Code / Sandbox / Plugins / EditorSchematyc2 / Editor / DocGraphView . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorSchematyc2 / Editor / DocGraphView . cpp <nl> namespace Schematyc2 <nl> gotoLabel . Format ( " Goto % s " , pNodeImpl - > GetOutputName ( nodeOutputIdx ) ) ; <nl> popupMenu . AppendMenu ( MF_STRING , EPopupMenuItemEx : : DEFINITION , gotoLabel . c_str ( ) ) ; <nl> popupMenu . AppendMenu ( MF_STRING , EPopupMenuItemEx : : REFERENCES , " Find references " ) ; <nl> + popupMenu . AppendMenu ( MF_STRING , EPopupMenuItemEx : : REFERENCES_ALL , " Find All references " ) ; <nl> } <nl> <nl> if ( Schematyc2 : : NodeUtils : : CanGoToNodeType ( nodeType ) ) <nl> { <nl> popupMenu . AppendMenu ( MF_STRING , EPopupMenuItemEx : : REFERENCES , " Find references " ) ; <nl> + popupMenu . AppendMenu ( MF_STRING , EPopupMenuItemEx : : REFERENCES_ALL , " Find All references " ) ; <nl> popupMenu . AppendMenu ( MF_MENUBARBREAK ) ; <nl> } <nl> <nl> namespace Schematyc2 <nl> } <nl> break ; <nl> } <nl> + case EPopupMenuItemEx : : REFERENCES_ALL : <nl> + { <nl> + if ( pNode ) <nl> + { <nl> + CDocGraphViewNodePtr pNodeImpl = std : : static_pointer_cast < CDocGraphViewNode > ( pNode ) ; <nl> + const TScriptFile & file = pNodeImpl - > GetScriptFile ( ) ; <nl> + <nl> + SGUID refGuid = pNodeImpl - > GetRefGUID ( ) ; <nl> + SGUID refGoBack = pNodeImpl - > GetGraphGUID ( ) ; <nl> + <nl> + stack_string name = pNodeImpl - > GetName ( ) ; <nl> + <nl> + if ( pNodeImpl - > GetType ( ) = = EScriptGraphNodeType : : State & & nodeOutputIdx ! = INVALID_INDEX ) <nl> + { <nl> + refGuid = pNodeImpl - > GetOutputTypeId ( nodeOutputIdx ) . AsScriptTypeGUID ( ) ; <nl> + name = pNodeImpl - > GetOutputName ( nodeOutputIdx ) ; <nl> + } <nl> + <nl> + stack_string : : size_type pos = name . rfind ( ' ' ) ; <nl> + if ( pos ! = stack_string : : npos ) <nl> + { <nl> + name = name . substr ( pos ) ; <nl> + } <nl> + <nl> + Schematyc2 : : LibUtils : : FindAndLogReferences ( refGuid , refGoBack , name . c_str ( ) , & file , true ) ; <nl> + } <nl> + break ; <nl> + } <nl> case EPopupMenuItemEx : : DEFINITION : <nl> { <nl> if ( pNode ) <nl> namespace Schematyc2 <nl> m_pLayout - > addWidget ( m_pPropertyTree , 1 ) ; <nl> <nl> m_pPropertyTree - > setSizeHint ( QSize ( 250 , 400 ) ) ; <nl> - m_pPropertyTree - > setExpandLevels ( 1 ) ; <nl> + m_pPropertyTree - > setExpandLevels ( 5 ) ; <nl> m_pPropertyTree - > setSliderUpdateDelay ( 5 ) ; <nl> m_pPropertyTree - > setValueColumnWidth ( 0 . 6f ) ; <nl> m_pPropertyTree - > attach ( Serialization : : SStruct ( * this ) ) ; <nl> mmm a / Code / Sandbox / Plugins / EditorSchematyc2 / Editor / DocGraphView . h <nl> ppp b / Code / Sandbox / Plugins / EditorSchematyc2 / Editor / DocGraphView . h <nl> namespace Schematyc2 <nl> ADD_OUTPUT = EPopupMenuItem : : CUSTOM , <nl> REMOVE_OUTPUT , <nl> REFERENCES , <nl> - DEFINITION <nl> + DEFINITION , <nl> + REFERENCES_ALL <nl> } ; <nl> } ; <nl> <nl> mmm a / Code / Sandbox / Plugins / EditorSubstance / EditorSubstanceManager . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorSubstance / EditorSubstanceManager . cpp <nl> namespace EditorSubstance { <nl> <nl> void CManager : : OnCreatorAccepted ( ) <nl> { <nl> - CreateInstance ( m_pPresetCreator - > GetSubstanceArchive ( ) , m_pPresetCreator - > GetTargetFileName ( ) , m_pPresetCreator - > GetGraphName ( ) , m_pPresetCreator - > GetOutputs ( ) , m_pPresetCreator - > GetResolution ( ) ) ; <nl> + if ( ! m_pPresetCreator - > GetSubstanceArchive ( ) . empty ( ) ) <nl> + { <nl> + CreateInstance ( m_pPresetCreator - > GetSubstanceArchive ( ) , m_pPresetCreator - > GetTargetFileName ( ) , m_pPresetCreator - > GetGraphName ( ) , m_pPresetCreator - > GetOutputs ( ) , m_pPresetCreator - > GetResolution ( ) ) ; <nl> + } <nl> OnCreatorRejected ( ) ; <nl> } <nl> <nl> mmm a / Code / Sandbox / Plugins / EditorSubstance / PresetCreator . cpp <nl> ppp b / Code / Sandbox / Plugins / EditorSubstance / PresetCreator . cpp <nl> namespace EditorSubstance <nl> m_resolution = res ; <nl> } ) ; <nl> <nl> + CAssetManager * pAssetManager = GetIEditor ( ) - > GetAssetManager ( ) ; <nl> + pAssetManager - > signalBeforeAssetsRemoved . Connect ( [ this , asset ] ( const std : : vector < CAsset * > & assets ) <nl> + { <nl> + if ( std : : find ( assets . begin ( ) , assets . end ( ) , asset ) ! = assets . end ( ) ) <nl> + { <nl> + m_substanceArchive . clear ( ) ; <nl> + m_pOutputsWidget - > setDisabled ( true ) ; <nl> + } <nl> + } , ( uintptr_t ) this ) ; <nl> + } <nl> + <nl> + CPressetCreator : : ~ CPressetCreator ( ) <nl> + { <nl> + GetIEditor ( ) - > GetAssetManager ( ) - > signalBeforeAssetsRemoved . DisconnectById ( ( uintptr_t ) this ) ; <nl> } <nl> + <nl> const string & CPressetCreator : : GetTargetFileName ( ) const <nl> { <nl> return m_finalFileName ; <nl> namespace EditorSubstance <nl> <nl> void CPressetCreator : : OnEditOutputs ( ) <nl> { <nl> + if ( m_substanceArchive . empty ( ) ) <nl> + { <nl> + return ; <nl> + } <nl> + <nl> if ( m_pOutputsGraphEditor ) <nl> { <nl> m_pOutputsGraphEditor - > raise ( ) ; <nl> mmm a / Code / Sandbox / Plugins / EditorSubstance / PresetCreator . h <nl> ppp b / Code / Sandbox / Plugins / EditorSubstance / PresetCreator . h <nl> namespace EditorSubstance <nl> { <nl> public : <nl> CPressetCreator ( CAsset * asset , const string & graphName , std : : vector < SSubstanceOutput > & outputs , const Vec2i & resolution , QWidget * parent = nullptr ) ; <nl> + virtual ~ CPressetCreator ( ) ; <nl> const string & GetTargetFileName ( ) const ; <nl> const string & GetGraphName ( ) const { return m_graphName ; } ; <nl> const string & GetSubstanceArchive ( ) const { return m_substanceArchive ; } <nl> mmm a / Code / Sandbox / Plugins / SchematycEditor / GenericWidget . cpp <nl> ppp b / Code / Sandbox / Plugins / SchematycEditor / GenericWidget . cpp <nl> QToolBar * CGenericWidget : : CreateToolBar ( ) <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CGenericWidget : : AddCategory ( CAbstractDictionary & category ) <nl> { <nl> - m_pDictionaryWidget - > SetDictionary ( category ) ; <nl> + m_pDictionaryWidget - > AddDictionary ( category ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> void CGenericWidget : : ReloadCategory ( CAbstractDictionary & category , bool checked ) <nl> categoryImpl . BuildFromScriptClass ( pScriptFile , m_classGUID ) ; <nl> } <nl> } <nl> - m_pDictionaryWidget - > SetDictionary ( categoryImpl ) ; <nl> + m_pDictionaryWidget - > AddDictionary ( categoryImpl ) ; <nl> } <nl> <nl> } / / namespace SchematycEd <nl> mmm a / Code / Sandbox / Plugins / SchematycEditor / LegacyOpenDlg . cpp <nl> ppp b / Code / Sandbox / Plugins / SchematycEditor / LegacyOpenDlg . cpp <nl> namespace SchematycEd { <nl> <nl> CLegacyOpenDlg : : CLegacyOpenDlg ( ) <nl> : CEditorDialog ( " OpenLegacy " , nullptr , false ) <nl> - , m_dialogDict ( new CLegacyOpenDlgModel ) <nl> - , m_dialogDictWidget ( new CDictionaryWidget ) <nl> + , m_pDialogDict ( new CLegacyOpenDlgModel ) <nl> + , m_pDialogDictWidget ( new CDictionaryWidget ) <nl> { <nl> QVBoxLayout * layout = new QVBoxLayout ( ) ; <nl> setLayout ( layout ) ; <nl> CLegacyOpenDlg : : CLegacyOpenDlg ( ) <nl> QPushButton * closeBtn = new QPushButton ( tr ( " & Close " ) ) ; <nl> connect ( closeBtn , & QPushButton : : clicked , [ this ] ( ) { close ( ) ; } ) ; <nl> <nl> - layout - > addWidget ( m_dialogDictWidget ) ; <nl> + layout - > addWidget ( m_pDialogDictWidget ) ; <nl> layout - > addWidget ( closeBtn ) ; <nl> <nl> - m_dialogDictWidget - > SetDictionary ( * m_dialogDict ) ; <nl> + m_pDialogDictWidget - > AddDictionary ( * m_pDialogDict ) ; <nl> } <nl> <nl> CLegacyOpenDlg : : ~ CLegacyOpenDlg ( ) <nl> { <nl> - delete m_dialogDict ; <nl> - m_dialogDictWidget - > deleteLater ( ) ; <nl> + delete m_pDialogDict ; <nl> + m_pDialogDictWidget - > deleteLater ( ) ; <nl> } <nl> <nl> CDictionaryWidget * CLegacyOpenDlg : : GetDialogDictWidget ( ) const <nl> { <nl> - return m_dialogDictWidget ; <nl> + return m_pDialogDictWidget ; <nl> } <nl> <nl> } / / namespace SchematycEd <nl> mmm a / Code / Sandbox / Plugins / SchematycEditor / LegacyOpenDlg . h <nl> ppp b / Code / Sandbox / Plugins / SchematycEditor / LegacyOpenDlg . h <nl> class CLegacyOpenDlg : public CEditorDialog <nl> CDictionaryWidget * GetDialogDictWidget ( ) const ; <nl> <nl> private : <nl> - CLegacyOpenDlgModel * m_dialogDict ; <nl> - CDictionaryWidget * m_dialogDictWidget ; <nl> + CLegacyOpenDlgModel * m_pDialogDict ; <nl> + CDictionaryWidget * m_pDialogDictWidget ; <nl> } ; <nl> <nl> } / / namespace SchematycEd <nl> | ! I integrate from / / ce / main . . . | CRYTEK/CRYENGINE | 016cc4040e0b6f282cdd864ded1e01b2a3b073be | 2018-01-25T23:05:10Z |
mmm a / src / audio_core / stream . cpp <nl> ppp b / src / audio_core / stream . cpp <nl> s64 Stream : : GetBufferReleaseCycles ( const Buffer & buffer ) const { <nl> } <nl> <nl> static void VolumeAdjustSamples ( std : : vector < s16 > & samples , float game_volume ) { <nl> - const float volume { std : : clamp ( Settings : : values . volume - ( 1 . 0f - game_volume ) , 0 . 0f , 1 . 0f ) } ; <nl> + const float volume { std : : clamp ( Settings : : Volume ( ) - ( 1 . 0f - game_volume ) , 0 . 0f , 1 . 0f ) } ; <nl> <nl> if ( volume = = 1 . 0f ) { <nl> return ; <nl> mmm a / src / core / settings . cpp <nl> ppp b / src / core / settings . cpp <nl> void LogSettings ( ) { <nl> LogSetting ( " Services_BCATBoxcatLocal " , Settings : : values . bcat_boxcat_local ) ; <nl> } <nl> <nl> + float Volume ( ) { <nl> + if ( values . audio_muted ) { <nl> + return 0 . 0f ; <nl> + } <nl> + return values . volume ; <nl> + } <nl> + <nl> bool IsGPULevelExtreme ( ) { <nl> return values . gpu_accuracy = = GPUAccuracy : : Extreme ; <nl> } <nl> mmm a / src / core / settings . h <nl> ppp b / src / core / settings . h <nl> struct Values { <nl> bool use_dev_keys ; <nl> <nl> / / Audio <nl> + bool audio_muted ; <nl> std : : string sink_id ; <nl> bool enable_audio_stretching ; <nl> std : : string audio_device_id ; <nl> struct Values { <nl> std : : map < u64 , std : : vector < std : : string > > disabled_addons ; <nl> } extern values ; <nl> <nl> + float Volume ( ) ; <nl> + <nl> bool IsGPULevelExtreme ( ) ; <nl> bool IsGPULevelHigh ( ) ; <nl> <nl> mmm a / src / yuzu / configuration / config . cpp <nl> ppp b / src / yuzu / configuration / config . cpp <nl> const std : : array < int , Settings : : NativeKeyboard : : NumKeyboardMods > Config : : default <nl> / / This must be in alphabetical order according to action name as it must have the same order as <nl> / / UISetting : : values . shortcuts , which is alphabetically ordered . <nl> / / clang - format off <nl> - const std : : array < UISettings : : Shortcut , 15 > Config : : default_hotkeys { { <nl> + const std : : array < UISettings : : Shortcut , 16 > Config : : default_hotkeys { { <nl> { QStringLiteral ( " Capture Screenshot " ) , QStringLiteral ( " Main Window " ) , { QStringLiteral ( " Ctrl + P " ) , Qt : : ApplicationShortcut } } , <nl> { QStringLiteral ( " Change Docked Mode " ) , QStringLiteral ( " Main Window " ) , { QStringLiteral ( " F10 " ) , Qt : : ApplicationShortcut } } , <nl> { QStringLiteral ( " Continue / Pause Emulation " ) , QStringLiteral ( " Main Window " ) , { QStringLiteral ( " F4 " ) , Qt : : WindowShortcut } } , <nl> const std : : array < UISettings : : Shortcut , 15 > Config : : default_hotkeys { { <nl> { QStringLiteral ( " Increase Speed Limit " ) , QStringLiteral ( " Main Window " ) , { QStringLiteral ( " + " ) , Qt : : ApplicationShortcut } } , <nl> { QStringLiteral ( " Load Amiibo " ) , QStringLiteral ( " Main Window " ) , { QStringLiteral ( " F2 " ) , Qt : : ApplicationShortcut } } , <nl> { QStringLiteral ( " Load File " ) , QStringLiteral ( " Main Window " ) , { QStringLiteral ( " Ctrl + O " ) , Qt : : WindowShortcut } } , <nl> + { QStringLiteral ( " Mute Audio " ) , QStringLiteral ( " Main Window " ) , { QStringLiteral ( " Ctrl + M " ) , Qt : : WindowShortcut } } , <nl> { QStringLiteral ( " Restart Emulation " ) , QStringLiteral ( " Main Window " ) , { QStringLiteral ( " F6 " ) , Qt : : WindowShortcut } } , <nl> { QStringLiteral ( " Stop Emulation " ) , QStringLiteral ( " Main Window " ) , { QStringLiteral ( " F5 " ) , Qt : : WindowShortcut } } , <nl> { QStringLiteral ( " Toggle Filter Bar " ) , QStringLiteral ( " Main Window " ) , { QStringLiteral ( " Ctrl + F " ) , Qt : : WindowShortcut } } , <nl> mmm a / src / yuzu / configuration / config . h <nl> ppp b / src / yuzu / configuration / config . h <nl> class Config { <nl> default_mouse_buttons ; <nl> static const std : : array < int , Settings : : NativeKeyboard : : NumKeyboardKeys > default_keyboard_keys ; <nl> static const std : : array < int , Settings : : NativeKeyboard : : NumKeyboardMods > default_keyboard_mods ; <nl> - static const std : : array < UISettings : : Shortcut , 15 > default_hotkeys ; <nl> + static const std : : array < UISettings : : Shortcut , 16 > default_hotkeys ; <nl> <nl> private : <nl> void ReadValues ( ) ; <nl> mmm a / src / yuzu / main . cpp <nl> ppp b / src / yuzu / main . cpp <nl> void GMainWindow : : InitializeHotkeys ( ) { <nl> Settings : : values . use_docked_mode ) ; <nl> dock_status_button - > setChecked ( Settings : : values . use_docked_mode ) ; <nl> } ) ; <nl> + connect ( hotkey_registry . GetHotkey ( main_window , QStringLiteral ( " Mute Audio " ) , this ) , <nl> + & QShortcut : : activated , this , <nl> + [ ] { Settings : : values . audio_muted = ! Settings : : values . audio_muted ; } ) ; <nl> } <nl> <nl> void GMainWindow : : SetDefaultUIGeometry ( ) { <nl> | Merge pull request from Kewlan / mute - audio - hotkey | yuzu-emu/yuzu | 9eaccac6744ab3f48d9f11c677616f0f40c03209 | 2020-06-27T06:47:13Z |
mmm a / lib / Demangling / Demangler . cpp <nl> ppp b / lib / Demangling / Demangler . cpp <nl> NodePointer Demangler : : popTypeAndGetAnyGeneric ( ) { <nl> <nl> NodePointer Demangler : : demangleBuiltinType ( ) { <nl> NodePointer Ty = nullptr ; <nl> + const int maxTypeSize = 4096 ; / / a very conservative upper bound <nl> switch ( nextChar ( ) ) { <nl> case ' b ' : <nl> Ty = createNode ( Node : : Kind : : BuiltinTypeName , <nl> NodePointer Demangler : : demangleBuiltinType ( ) { <nl> break ; <nl> case ' f ' : { <nl> int size = demangleIndex ( ) - 1 ; <nl> - if ( size < = 0 ) <nl> + if ( size < = 0 | | size > maxTypeSize ) <nl> return nullptr ; <nl> CharVector name ; <nl> name . append ( BUILTIN_TYPE_NAME_FLOAT , * this ) ; <nl> NodePointer Demangler : : demangleBuiltinType ( ) { <nl> } <nl> case ' i ' : { <nl> int size = demangleIndex ( ) - 1 ; <nl> - if ( size < = 0 ) <nl> + if ( size < = 0 | | size > maxTypeSize ) <nl> return nullptr ; <nl> CharVector name ; <nl> name . append ( BUILTIN_TYPE_NAME_INT , * this ) ; <nl> NodePointer Demangler : : demangleBuiltinType ( ) { <nl> } <nl> case ' v ' : { <nl> int elts = demangleIndex ( ) - 1 ; <nl> - if ( elts < = 0 ) <nl> + if ( elts < = 0 | | elts > maxTypeSize ) <nl> return nullptr ; <nl> NodePointer EltType = popTypeAndGetChild ( ) ; <nl> if ( ! EltType | | EltType - > getKind ( ) ! = Node : : Kind : : BuiltinTypeName | | <nl> mmm a / test / Demangle / Inputs / manglings . txt <nl> ppp b / test / Demangle / Inputs / manglings . txt <nl> _TTSf2o___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ mmm > function <nl> _TTSf2do___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ mmm > function signature specialization < Arg [ 0 ] = Dead and Guaranteed To Owned > of function signature specialization < Arg [ 0 ] = Exploded , Arg [ 1 ] = Dead > of Swift . _LegacyStringCore . init ( Swift . _StringBuffer ) - > Swift . _LegacyStringCore <nl> _TTSf2dos___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ mmm > function signature specialization < Arg [ 0 ] = Dead and Guaranteed To Owned and Exploded > of function signature specialization < Arg [ 0 ] = Exploded , Arg [ 1 ] = Dead > of Swift . _LegacyStringCore . init ( Swift . _StringBuffer ) - > Swift . _LegacyStringCore <nl> _TTSf mmm > _TTSf <nl> + _ $ S3BBBBf0602365061_ mmm > _ $ S3BBBBf0602365061_ <nl> + _ $ S3BBBBi0602365061_ mmm > _ $ S3BBBBi0602365061_ <nl> + _ $ S3BBBBv0602365061_ mmm > _ $ S3BBBBv0602365061_ <nl> | Merge remote - tracking branch ' origin / master ' into master - next | apple/swift | 0e896c5d85541e506818612219e01836c3805186 | 2018-05-07T21:10:13Z |
mmm a / cocos2dx / platform / wophone / CCAccelerometer_wophone . cpp <nl> ppp b / cocos2dx / platform / wophone / CCAccelerometer_wophone . cpp <nl> void CCAccelerometer : : addDelegate ( CCAccelerometerDelegate * pDelegate ) <nl> <nl> void CCAccelerometer : : didAccelerate ( CCAcceleration * pAccelerationValue ) <nl> { <nl> - m_pAccelDelegate - > didAccelerate ( pAccelerationValue ) ; <nl> + m_pDelegate - > didAccelerate ( pAccelerationValue ) ; <nl> } <nl> <nl> } / / namespace cocos2d <nl> | fix a compiling error on wophone | cocos2d/cocos2d-x | 0cfbf4344a094f1a09772155a32889531d6ead1c | 2011-08-30T02:54:32Z |
mmm a / lib / Sema / TypeCheckConstraints . cpp <nl> ppp b / lib / Sema / TypeCheckConstraints . cpp <nl> void ConstraintSystem : : markChildInactive ( ConstraintSystem * childCS ) { <nl> auto boundTy = childCS - > getFixedType ( typeVar ) ; <nl> auto supertypes = enumerateDirectSupertypes ( boundTy ) ; <nl> auto & explored = ExploredTypeBindings [ typeVar ] ; <nl> + <nl> + bool addedAny = false ; <nl> for ( auto supertype : supertypes ) { <nl> if ( explored . count ( supertype - > getCanonicalType ( ) ) > 0 ) <nl> continue ; <nl> <nl> PotentialBindings . push_back ( { typeVar , supertype } ) ; <nl> + addedAny = true ; <nl> + } <nl> + <nl> + if ( ! addedAny ) { <nl> + / / If we haven ' t added any constraints for this type variable , check <nl> + / / whether we can fall back to a default literal type . <nl> + / / FIXME : This would be far , far more efficient if we keep constraints <nl> + / / related to a type variable on - line . <nl> + for ( auto constraint : Constraints ) { <nl> + if ( constraint - > getClassification ( ) ! = ConstraintClassification : : Literal ) <nl> + continue ; <nl> + <nl> + if ( auto constrainedVar <nl> + = constraint - > getFirstType ( ) - > getAs < TypeVariableType > ( ) ) { <nl> + if ( getRepresentative ( constrainedVar ) ! = typeVar ) <nl> + continue ; <nl> + <nl> + if ( auto literalType = <nl> + TC . getDefaultLiteralType ( constraint - > getLiteralKind ( ) ) ) { <nl> + if ( explored . count ( literalType - > getCanonicalType ( ) ) = = 0 ) <nl> + PotentialBindings . push_back ( { typeVar , literalType } ) ; <nl> + } <nl> + } <nl> + } <nl> } <nl> } <nl> } <nl> | When we run out of supertypes in our fallback , allow a fallback to the | apple/swift | 11e06f41253da0c2cdb2e94faa2f2ea2bbb46035 | 2012-10-09T00:07:15Z |
mmm a / cocos / 2d / cocos2d . cpp <nl> ppp b / cocos / 2d / cocos2d . cpp <nl> NS_CC_BEGIN <nl> <nl> const char * cocos2dVersion ( ) <nl> { <nl> - return " 3 . 0 - rc1 " ; <nl> + return " 3 . 0 " ; <nl> } <nl> <nl> NS_CC_END <nl> | update version | cocos2d/cocos2d-x | 3703c6f73a49b8403c5058b8bb06a97fb9507467 | 2014-04-08T10:14:46Z |
deleted file mode 100644 <nl> index f51c1d15d52 . . 00000000000 <nl> mmm a / drivers / ruby / play . rb <nl> ppp / dev / null <nl> <nl> - load ' quickstart2 . rb ' <nl> - <nl> - # r . db ( ' test ' ) . table_list . foreach { | x | r . db ( ' test ' ) . table_drop ( r . implicit_var ) } . run <nl> mmm a / src / rdb_protocol / datum_stream . cc <nl> ppp b / src / rdb_protocol / datum_stream . cc <nl> const datum_t * filter_datum_stream_t : : next_impl ( ) { <nl> env_checkpoint_t outer_checkpoint ( env , & env_t : : discard_checkpoint ) ; <nl> if ( ! ( arg = src - > next ( ) ) ) return 0 ; <nl> env_checkpoint_t inner_checkpoint ( env , & env_t : : discard_checkpoint ) ; <nl> - if ( f - > filter_call ( env , arg ) ) { <nl> - outer_checkpoint . reset ( & env_t : : merge_checkpoint ) ; <nl> - break ; <nl> + if ( f - > filter_call ( arg ) ) { <nl> + outer_checkpoint . reset ( & env_t : : merge_checkpoint ) ; <nl> + break ; <nl> } <nl> } <nl> return arg ; <nl> mmm a / src / rdb_protocol / func . cc <nl> ppp b / src / rdb_protocol / func . cc <nl> bool func_term_t : : is_deterministic_impl ( ) const { <nl> return func - > is_deterministic ( ) ; <nl> } <nl> <nl> - bool func_t : : filter_call ( env_t * env , const datum_t * arg ) { <nl> + bool func_t : : filter_call ( const datum_t * arg ) { <nl> const datum_t * d = call ( arg ) - > as_datum ( ) ; <nl> if ( d - > get_type ( ) = = datum_t : : R_OBJECT ) { <nl> - func_t * f2 = new_filter_func ( env , d , this ) ; <nl> - d = f2 - > call ( arg ) - > as_datum ( ) ; <nl> - } <nl> - if ( d - > get_type ( ) = = datum_t : : R_BOOL ) return d - > as_bool ( ) ; <nl> - rfail ( " FILTER must be passed either an OBJECT or a predicate ( got % s ) . " , <nl> - d - > get_type_name ( ) ) ; <nl> - } <nl> - <nl> - func_t * func_t : : new_filter_func ( env_t * env , const datum_t * obj , <nl> - const pb_rcheckable_t * bt_src ) { <nl> - env_wrapper_t < Term > * twrap = env - > add_ptr ( new env_wrapper_t < Term > ( ) ) ; <nl> - int x = env - > gensym ( ) ; <nl> - Term * t = pb : : set_func ( & twrap - > t , x ) ; <nl> - pb : : set ( t , Term_TermType_ALL , 0 , 0 ) ; <nl> - for ( std : : map < const std : : string , const datum_t * > : : const_iterator <nl> - it = obj - > as_object ( ) . begin ( ) ; it ! = obj - > as_object ( ) . end ( ) ; + + it ) { <nl> - std : : string key = it - > first ; <nl> - const datum_t * val = it - > second ; <nl> - <nl> - Term * arg = t - > add_args ( ) ; <nl> - N2 ( EQ , <nl> - N2 ( GETATTR , pb : : set_var ( arg , x ) , pb : : set_str ( arg , key ) ) , <nl> - val - > write_to_protobuf ( pb : : set_datum ( arg ) ) ) ; <nl> + const std : : map < const std : : string , const datum_t * > & obj = d - > as_object ( ) ; <nl> + for ( auto it = obj . begin ( ) ; it ! = obj . end ( ) ; + + it ) { <nl> + r_sanity_check ( it - > second ! = NULL ) ; <nl> + const datum_t * elt = arg - > el ( it - > first , NOTHROW ) ; <nl> + if ( elt = = NULL ) { <nl> + rfail ( " No attribute ` % s ` in object . " , it - > first . c_str ( ) ) ; <nl> + } else if ( * elt ! = * it - > second ) { <nl> + return false ; <nl> + } <nl> + } <nl> + return true ; <nl> + } else if ( d - > get_type ( ) = = datum_t : : R_BOOL ) { <nl> + return d - > as_bool ( ) ; <nl> + } else { <nl> + rfail ( " FILTER must be passed either an OBJECT or a predicate ( got % s ) . " , <nl> + d - > get_type_name ( ) ) ; <nl> } <nl> - bt_src - > propagate ( & twrap - > t ) ; <nl> - return env - > add_ptr ( new func_t ( env , & twrap - > t ) ) ; <nl> } <nl> <nl> - <nl> func_t * func_t : : new_identity_func ( env_t * env , const datum_t * obj , <nl> const pb_rcheckable_t * bt_src ) { <nl> env_wrapper_t < Term > * twrap = env - > add_ptr ( new env_wrapper_t < Term > ( ) ) ; <nl> mmm a / src / rdb_protocol / func . hpp <nl> ppp b / src / rdb_protocol / func . hpp <nl> class func_t : public ptr_baggable_t , public pb_rcheckable_t { <nl> func_t ( env_t * env , const Term * _source ) ; <nl> / / Some queries , like filter , can take a shortcut object instead of a <nl> / / function as their argument . <nl> - static func_t * new_filter_func ( env_t * env , const datum_t * obj , <nl> - const pb_rcheckable_t * root ) ; <nl> static func_t * new_identity_func ( env_t * env , const datum_t * obj , <nl> const pb_rcheckable_t * root ) ; <nl> val_t * call ( const std : : vector < const datum_t * > & args ) ; <nl> class func_t : public ptr_baggable_t , public pb_rcheckable_t { <nl> val_t * call ( ) ; <nl> val_t * call ( const datum_t * arg ) ; <nl> val_t * call ( const datum_t * arg1 , const datum_t * arg2 ) ; <nl> - bool filter_call ( env_t * env , const datum_t * arg ) ; <nl> + bool filter_call ( const datum_t * arg ) ; <nl> <nl> void dump_scope ( std : : map < int64_t , Datum > * out ) const ; <nl> bool is_deterministic ( ) const ; <nl> mmm a / src / rdb_protocol / transform_visitors . cc <nl> ppp b / src / rdb_protocol / transform_visitors . cc <nl> void transform_visitor_t : : operator ( ) ( ql : : filter_wire_func_t & func / * NOLINT * / ) con <nl> ql : : env_checkpoint_t ( ql_env , & ql : : env_t : : discard_checkpoint ) ; <nl> ql : : func_t * f = func . compile ( ql_env ) ; <nl> const ql : : datum_t * arg = ql_env - > add_ptr ( new ql : : datum_t ( json , ql_env ) ) ; <nl> - if ( f - > filter_call ( ql_env , arg ) ) out - > push_back ( arg - > as_json ( ) ) ; <nl> + if ( f - > filter_call ( arg ) ) { <nl> + out - > push_back ( arg - > as_json ( ) ) ; <nl> + } <nl> } <nl> <nl> terminal_initializer_visitor_t : : terminal_initializer_visitor_t ( <nl> | Merge review 286 by @ srh ( ) | rethinkdb/rethinkdb | f48f376eacaaa7f6fca88fbb3840312102516462 | 2013-03-21T21:11:38Z |
mmm a / docs / index . md <nl> ppp b / docs / index . md <nl> Please cite Caffe in your publications if it helps your research : <nl> Author = { Yangqing Jia } , <nl> Title = { { Caffe } : An Open Source Convolutional Architecture for Fast Feature Embedding } , <nl> Year = { 2013 } , <nl> - Howpublished = { \ url { http : / / caffe . berkeleyvision . org / } <nl> + Howpublished = { \ url { http : / / caffe . berkeleyvision . org / } } <nl> } <nl> <nl> If you do publish a paper where Caffe helped your research , we encourage you to update the [ publications wiki ] ( https : / / github . com / BVLC / caffe / wiki / Publications ) . <nl> mmm a / docs / installation . md <nl> ppp b / docs / installation . md <nl> Be sure to set your MATLAB and Python paths in ` Makefile . config ` first ! <nl> <nl> * Speed * : for a faster build , compile in parallel by doing ` make all - j8 ` where 8 is the number of parallel threads for compilation ( a good choice for the number of threads is the number of cores in your machine ) . <nl> <nl> - Now that you have installed Caffe , check out the [ MNIST demo ] ( mnist . html ) and the pretrained [ ImageNet example ] ( imagenet . html ) . <nl> + Now that you have installed Caffe , check out the [ MNIST tutorial ] ( gathered / examples / mnist . html ) and the [ reference ImageNet model tutorial ] ( gathered / examples / imagenet . html ) . <nl> <nl> # # # Compilation using CMake ( beta ) <nl> <nl> | Back - merge to dev for doc fixes + cherry - picks | BVLC/caffe | c05ba59260dc9c359d900928e33c9730dc7908bf | 2014-08-28T17:55:33Z |
mmm a / tensorflow / compiler / xla / literal . cc <nl> ppp b / tensorflow / compiler / xla / literal . cc <nl> constexpr int kMinimumAlignment = 64 ; <nl> / / <nl> / / Precondition : size % 2 = = 0 ( elements in the array are 16 bits long ) <nl> void ConvertEndianShort ( string * bytes ) { <nl> - CHECK_EQ ( bytes - > size ( ) / 2 , 0 ) ; <nl> + CHECK_EQ ( bytes - > size ( ) % 2 , 0 ) ; <nl> for ( int64 i = 0 , end = bytes - > size ( ) ; i < end ; i + = 2 ) { <nl> std : : swap ( ( * bytes ) [ i ] , ( * bytes ) [ i + 1 ] ) ; <nl> } <nl> } <nl> <nl> void ConvertEndianShort ( char * bytes , int64 size ) { <nl> - CHECK_EQ ( size / 2 , 0 ) ; <nl> + CHECK_EQ ( size % 2 , 0 ) ; <nl> for ( int64 i = 0 ; i < size ; i + = 2 ) { <nl> std : : swap ( bytes [ i ] , bytes [ i + 1 ] ) ; <nl> } <nl> mmm a / tensorflow / core / kernels / BUILD <nl> ppp b / tensorflow / core / kernels / BUILD <nl> cc_library ( <nl> " / / tensorflow : arm_any " : [ ] , <nl> " / / tensorflow : ios " : [ ] , <nl> " / / tensorflow : linux_ppc64le " : [ ] , <nl> + " / / tensorflow : linux_s390x " : [ ] , <nl> " / / conditions : default " : [ <nl> " TENSORFLOW_USE_CUSTOM_CONTRACTION_KERNEL " , <nl> " TENSORFLOW_USE_MKLDNN_CONTRACTION_KERNEL " , <nl> cc_library ( <nl> " / / tensorflow : arm_any " : [ ] , <nl> " / / tensorflow : ios " : [ ] , <nl> " / / tensorflow : linux_ppc64le " : [ ] , <nl> + " / / tensorflow : linux_s390x " : [ ] , <nl> " / / conditions : default " : [ " @ mkl_dnn / / : mkldnn_single_threaded " ] , <nl> } ) , <nl> ) <nl> tf_cc_test ( <nl> " / / tensorflow : arm_any " : [ ] , <nl> " / / tensorflow : ios " : [ ] , <nl> " / / tensorflow : linux_ppc64le " : [ ] , <nl> + " / / tensorflow : linux_s390x " : [ ] , <nl> " : no_mkldnn_contraction_kernel " : [ ] , <nl> " / / conditions : default " : [ " eigen_mkldnn_contraction_kernel_test . cc " ] , <nl> } ) , <nl> mmm a / tensorflow / core / kernels / data / experimental / lmdb_dataset_op_test . cc <nl> ppp b / tensorflow / core / kernels / data / experimental / lmdb_dataset_op_test . cc <nl> namespace { <nl> <nl> constexpr char kNodeName [ ] = " lmdb_dataset " ; <nl> constexpr char kIteratorPrefix [ ] = " Iterator " ; <nl> + # if __BYTE_ORDER__ = = __ORDER_BIG_ENDIAN__ <nl> + constexpr char kDataFileName [ ] = " data_bigendian . mdb " ; <nl> + # else <nl> constexpr char kDataFileName [ ] = " data . mdb " ; <nl> + # endif <nl> constexpr char kDataFileLoc [ ] = " core / lib / lmdb / testdata " ; <nl> <nl> class LMDBDatasetParams : public DatasetParams { <nl> mmm a / third_party / cpuinfo / BUILD . bazel <nl> ppp b / third_party / cpuinfo / BUILD . bazel <nl> cc_library ( <nl> " : linux_armeabi " : COMMON_SRCS + ARM_SRCS + LINUX_SRCS + LINUX_ARM32_SRCS , <nl> " : linux_aarch64 " : COMMON_SRCS + ARM_SRCS + LINUX_SRCS + LINUX_ARM64_SRCS , <nl> " : linux_mips64 " : COMMON_SRCS + LINUX_SRCS , <nl> + " : linux_s390x " : COMMON_SRCS + LINUX_SRCS , <nl> " : macos_x86_64 " : COMMON_SRCS + X86_SRCS + MACH_SRCS + MACH_X86_SRCS , <nl> " : windows_x86_64 " : COMMON_SRCS + X86_SRCS + WINDOWS_X86_SRCS , <nl> " : android_armv7 " : COMMON_SRCS + ARM_SRCS + LINUX_SRCS + LINUX_ARM32_SRCS + ANDROID_ARM_SRCS , <nl> config_setting ( <nl> values = { " cpu " : " mips64 " } , <nl> ) <nl> <nl> + config_setting ( <nl> + name = " linux_s390x " , <nl> + values = { " cpu " : " s390x " } , <nl> + ) <nl> + <nl> config_setting ( <nl> name = " macos_x86_64 " , <nl> values = { <nl> | Add several fixes for s390x architecture and other Big - Endian systems | tensorflow/tensorflow | 53279cac41534e8c85d103ad3ffdde9ae5718e99 | 2020-10-28T15:14:47Z |
mmm a / cocos2dx / support / CCUserDefault . cpp <nl> ppp b / cocos2dx / support / CCUserDefault . cpp <nl> THE SOFTWARE . <nl> # include " CCUserDefault . h " <nl> # include " platform / CCCommon . h " <nl> # include " platform / CCFileUtils . h " <nl> - # include < libxml / parser . h > <nl> - # include < libxml / tree . h > <nl> + # include " tinyxml2 / tinyxml2 . h " <nl> <nl> / / root name of xml <nl> # define USERDEFAULT_ROOT_NAME " userDefaultRoot " <nl> using namespace std ; <nl> <nl> NS_CC_BEGIN <nl> <nl> - static xmlDocPtr g_sharedDoc = NULL ; <nl> - <nl> / * * <nl> * define the functions here because we don ' t want to <nl> * export xmlNodePtr and other types in " CCUserDefault . h " <nl> static xmlDocPtr g_sharedDoc = NULL ; <nl> <nl> static xmlNodePtr getXMLNodeForKey ( const char * pKey , xmlNodePtr * rootNode ) <nl> { <nl> - xmlNodePtr curNode = NULL ; <nl> + tinyxml2 : : XMLElement * curNode = NULL ; <nl> <nl> / / check the key value <nl> if ( ! pKey ) <nl> static xmlNodePtr getXMLNodeForKey ( const char * pKey , xmlNodePtr * rootNode ) <nl> <nl> do <nl> { <nl> - / / get root node <nl> - * rootNode = xmlDocGetRootElement ( g_sharedDoc ) ; <nl> - if ( NULL = = * rootNode ) <nl> - { <nl> - CCLOG ( " read root node error " ) ; <nl> - break ; <nl> - } <nl> - <nl> - / / find the node <nl> - curNode = ( * rootNode ) - > xmlChildrenNode ; <nl> - while ( NULL ! = curNode ) <nl> - { <nl> - if ( ! xmlStrcmp ( curNode - > name , BAD_CAST pKey ) ) <nl> - { <nl> - break ; <nl> - } <nl> - <nl> - curNode = curNode - > next ; <nl> - } <nl> - } while ( 0 ) ; <nl> - <nl> - return curNode ; <nl> - } <nl> - <nl> - static inline const char * getValueForKey ( const char * pKey ) <nl> - { <nl> - const char * ret = NULL ; <nl> - xmlNodePtr rootNode ; <nl> - xmlNodePtr node = getXMLNodeForKey ( pKey , & rootNode ) ; <nl> - <nl> - / / find the node <nl> - if ( node ) <nl> - { <nl> - ret = ( const char * ) xmlNodeGetContent ( node ) ; <nl> - } <nl> - <nl> - return ret ; <nl> + tinyxml2 : : XMLDocument * xmlDoc = new tinyxml2 : : XMLDocument ( ) ; <nl> + * doc = xmlDoc ; <nl> + CCFileData data ( CCUserDefault : : sharedUserDefault ( ) - > getXMLFilePath ( ) . c_str ( ) , " rt " ) ; <nl> + const char * pXmlBuffer = ( const char * ) data . getBuffer ( ) ; <nl> + if ( NULL = = pXmlBuffer ) <nl> + { <nl> + CCLOG ( " can not read xml file " ) ; <nl> + break ; <nl> + } <nl> + xmlDoc - > Parse ( pXmlBuffer ) ; <nl> + / / get root node <nl> + * rootNode = xmlDoc - > RootElement ( ) ; <nl> + if ( NULL = = * rootNode ) <nl> + { <nl> + CCLOG ( " read root node error " ) ; <nl> + break ; <nl> + } <nl> + / / find the node <nl> + curNode = ( * rootNode ) - > FirstChildElement ( ) ; <nl> + while ( NULL ! = curNode ) <nl> + { <nl> + const char * nodeName = curNode - > Value ( ) ; <nl> + if ( ! strcmp ( nodeName , pKey ) ) <nl> + { <nl> + break ; <nl> + } <nl> + <nl> + curNode = curNode - > NextSiblingElement ( ) ; <nl> + } <nl> + } while ( 0 ) ; <nl> + <nl> + return curNode ; <nl> } <nl> <nl> static void setValueForKey ( const char * pKey , const char * pValue ) <nl> { <nl> - xmlNodePtr rootNode ; <nl> - xmlNodePtr node ; <nl> - <nl> - / / check the params <nl> - if ( ! pKey | | ! pValue ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - / / find the node <nl> - node = getXMLNodeForKey ( pKey , & rootNode ) ; <nl> - <nl> - / / if node exist , change the content <nl> - if ( node ) <nl> - { <nl> - xmlNodeSetContent ( node , BAD_CAST pValue ) ; <nl> - } <nl> - else <nl> - { <nl> - if ( rootNode ) <nl> - { <nl> - / / the node doesn ' t exist , add a new one <nl> - / / libxml in android doesn ' t support xmlNewTextChild , so use this approach <nl> - xmlNodePtr tmpNode = xmlNewNode ( NULL , BAD_CAST pKey ) ; <nl> - xmlNodePtr content = xmlNewText ( BAD_CAST pValue ) ; <nl> - xmlAddChild ( rootNode , tmpNode ) ; <nl> - xmlAddChild ( tmpNode , content ) ; <nl> - } <nl> - } <nl> + tinyxml2 : : XMLElement * rootNode ; <nl> + tinyxml2 : : XMLDocument * doc ; <nl> + tinyxml2 : : XMLElement * node ; <nl> + / / check the params <nl> + if ( ! pKey | | ! pValue ) <nl> + { <nl> + return ; <nl> + } <nl> + / / find the node <nl> + node = getXMLNodeForKey ( pKey , & rootNode , & doc ) ; <nl> + / / if node exist , change the content <nl> + if ( node ) <nl> + { <nl> + node - > FirstChild ( ) - > SetValue ( pValue ) ; <nl> + } <nl> + else <nl> + { <nl> + if ( rootNode ) <nl> + { <nl> + <nl> + tinyxml2 : : XMLElement * tmpNode = doc - > NewElement ( pKey ) ; / / new tinyxml2 : : XMLElement ( pKey ) ; <nl> + rootNode - > LinkEndChild ( tmpNode ) ; <nl> + tinyxml2 : : XMLText * content = doc - > NewText ( pValue ) ; / / new tinyxml2 : : XMLText ( pValue ) ; <nl> + tmpNode - > LinkEndChild ( content ) ; <nl> + <nl> + } <nl> + } <nl> + <nl> + <nl> + / / save file and free doc <nl> + if ( doc ) <nl> + { <nl> + <nl> + doc - > SaveFile ( CCUserDefault : : sharedUserDefault ( ) - > getXMLFilePath ( ) . c_str ( ) ) ; <nl> + delete doc ; <nl> + } <nl> } <nl> <nl> / * * <nl> bool CCUserDefault : : m_sbIsFilePathInitialized = false ; <nl> * / <nl> CCUserDefault : : ~ CCUserDefault ( ) <nl> { <nl> - flush ( ) ; <nl> - if ( g_sharedDoc ) <nl> - { <nl> - xmlFreeDoc ( g_sharedDoc ) ; <nl> - g_sharedDoc = NULL ; <nl> - } <nl> - <nl> + CC_SAFE_DELETE ( m_spUserDefault ) ; <nl> m_spUserDefault = NULL ; <nl> } <nl> <nl> CCUserDefault : : CCUserDefault ( ) <nl> { <nl> - g_sharedDoc = xmlReadFile ( getXMLFilePath ( ) . c_str ( ) , " utf - 8 " , XML_PARSE_RECOVER ) ; <nl> + m_spUserDefault = NULL ; <nl> } <nl> <nl> void CCUserDefault : : purgeSharedUserDefault ( ) <nl> void CCUserDefault : : purgeSharedUserDefault ( ) <nl> <nl> bool CCUserDefault : : getBoolForKey ( const char * pKey , bool defaultValue ) <nl> { <nl> - const char * value = getValueForKey ( pKey ) ; <nl> - bool ret = defaultValue ; <nl> - <nl> - if ( value ) <nl> - { <nl> - ret = ( ! strcmp ( value , " true " ) ) ; <nl> - xmlFree ( ( void * ) value ) ; <nl> - } <nl> - <nl> - return ret ; <nl> + const char * value = NULL ; <nl> + tinyxml2 : : XMLElement * rootNode ; <nl> + tinyxml2 : : XMLDocument * doc ; <nl> + tinyxml2 : : XMLElement * node ; <nl> + node = getXMLNodeForKey ( pKey , & rootNode , & doc ) ; <nl> + / / find the node <nl> + if ( node ) <nl> + { <nl> + value = ( const char * ) ( node - > FirstChild ( ) - > Value ( ) ) ; <nl> + } <nl> + <nl> + bool ret = defaultValue ; <nl> + <nl> + if ( value ) <nl> + { <nl> + ret = ( ! strcmp ( value , " true " ) ) ; <nl> + } <nl> + <nl> + if ( doc ) delete doc ; <nl> + <nl> + return ret ; <nl> } <nl> <nl> int CCUserDefault : : getIntegerForKey ( const char * pKey ) <nl> int CCUserDefault : : getIntegerForKey ( const char * pKey ) <nl> <nl> int CCUserDefault : : getIntegerForKey ( const char * pKey , int defaultValue ) <nl> { <nl> - const char * value = getValueForKey ( pKey ) ; <nl> - int ret = defaultValue ; <nl> - <nl> - if ( value ) <nl> - { <nl> - ret = atoi ( value ) ; <nl> - xmlFree ( ( void * ) value ) ; <nl> - } <nl> - <nl> - return ret ; <nl> + const char * value = NULL ; <nl> + tinyxml2 : : XMLElement * rootNode ; <nl> + tinyxml2 : : XMLDocument * doc ; <nl> + tinyxml2 : : XMLElement * node ; <nl> + node = getXMLNodeForKey ( pKey , & rootNode , & doc ) ; <nl> + / / find the node <nl> + if ( node ) <nl> + { <nl> + value = ( const char * ) ( node - > FirstChild ( ) - > Value ( ) ) ; <nl> + } <nl> + <nl> + int ret = defaultValue ; <nl> + <nl> + if ( value ) <nl> + { <nl> + ret = atoi ( value ) ; <nl> + } <nl> + <nl> + if ( doc ) <nl> + { <nl> + delete doc ; <nl> + } <nl> + <nl> + <nl> + return ret ; <nl> } <nl> <nl> float CCUserDefault : : getFloatForKey ( const char * pKey ) <nl> double CCUserDefault : : getDoubleForKey ( const char * pKey ) <nl> <nl> double CCUserDefault : : getDoubleForKey ( const char * pKey , double defaultValue ) <nl> { <nl> - const char * value = getValueForKey ( pKey ) ; <nl> - double ret = defaultValue ; <nl> - <nl> - if ( value ) <nl> - { <nl> - ret = atof ( value ) ; <nl> - xmlFree ( ( void * ) value ) ; <nl> - } <nl> - <nl> - return ret ; <nl> + const char * value = NULL ; <nl> + tinyxml2 : : XMLElement * rootNode ; <nl> + tinyxml2 : : XMLDocument * doc ; <nl> + tinyxml2 : : XMLElement * node ; <nl> + node = getXMLNodeForKey ( pKey , & rootNode , & doc ) ; <nl> + / / find the node <nl> + if ( node ) <nl> + { <nl> + value = ( const char * ) ( node - > FirstChild ( ) - > Value ( ) ) ; <nl> + } <nl> + <nl> + double ret = defaultValue ; <nl> + <nl> + if ( value ) <nl> + { <nl> + ret = atof ( value ) ; <nl> + } <nl> + <nl> + if ( doc ) delete doc ; <nl> + <nl> + return ret ; <nl> } <nl> <nl> std : : string CCUserDefault : : getStringForKey ( const char * pKey ) <nl> std : : string CCUserDefault : : getStringForKey ( const char * pKey ) <nl> <nl> string CCUserDefault : : getStringForKey ( const char * pKey , const std : : string & defaultValue ) <nl> { <nl> - const char * value = getValueForKey ( pKey ) ; <nl> - string ret = defaultValue ; <nl> - <nl> - if ( value ) <nl> - { <nl> - ret = string ( value ) ; <nl> - xmlFree ( ( void * ) value ) ; <nl> - } <nl> - <nl> - return ret ; <nl> + const char * value = NULL ; <nl> + tinyxml2 : : XMLElement * rootNode ; <nl> + tinyxml2 : : XMLDocument * doc ; <nl> + tinyxml2 : : XMLElement * node ; <nl> + node = getXMLNodeForKey ( pKey , & rootNode , & doc ) ; <nl> + / / find the node <nl> + if ( node ) <nl> + { <nl> + value = ( const char * ) ( node - > FirstChild ( ) - > Value ( ) ) ; <nl> + } <nl> + <nl> + string ret = defaultValue ; <nl> + <nl> + if ( value ) <nl> + { <nl> + ret = string ( value ) ; <nl> + } <nl> + <nl> + if ( doc ) delete doc ; <nl> + <nl> + return ret ; <nl> } <nl> <nl> void CCUserDefault : : setBoolForKey ( const char * pKey , bool value ) <nl> CCUserDefault * CCUserDefault : : sharedUserDefault ( ) <nl> bool CCUserDefault : : isXMLFileExist ( ) <nl> { <nl> FILE * fp = fopen ( m_sFilePath . c_str ( ) , " r " ) ; <nl> - bool bRet = false ; <nl> + bool bRet = false ; <nl> <nl> - if ( fp ) <nl> - { <nl> - bRet = true ; <nl> - fclose ( fp ) ; <nl> - } <nl> + if ( fp ) <nl> + { <nl> + bRet = true ; <nl> + fclose ( fp ) ; <nl> + } <nl> <nl> - return bRet ; <nl> + return bRet ; <nl> } <nl> <nl> void CCUserDefault : : initXMLFilePath ( ) <nl> void CCUserDefault : : initXMLFilePath ( ) <nl> / / create new xml file <nl> bool CCUserDefault : : createXMLFile ( ) <nl> { <nl> - bool bRet = false ; <nl> - xmlDocPtr doc = NULL ; <nl> - <nl> - do <nl> - { <nl> - / / new doc <nl> - doc = xmlNewDoc ( BAD_CAST " 1 . 0 " ) ; <nl> - if ( doc = = NULL ) <nl> - { <nl> - CCLOG ( " can not create xml doc " ) ; <nl> - break ; <nl> - } <nl> - <nl> - / / new root node <nl> - xmlNodePtr rootNode = xmlNewNode ( NULL , BAD_CAST USERDEFAULT_ROOT_NAME ) ; <nl> - if ( rootNode = = NULL ) <nl> - { <nl> - CCLOG ( " can not create root node " ) ; <nl> - break ; <nl> - } <nl> - <nl> - / / set root node <nl> - xmlDocSetRootElement ( doc , rootNode ) ; <nl> - <nl> - / / save xml file <nl> - xmlSaveFile ( m_sFilePath . c_str ( ) , doc ) ; <nl> - <nl> - bRet = true ; <nl> - } while ( 0 ) ; <nl> - <nl> - / / if doc is not null , free it <nl> - if ( doc ) <nl> - { <nl> - xmlFreeDoc ( doc ) ; <nl> - } <nl> - <nl> - return bRet ; <nl> + bool bRet = false ; <nl> + tinyxml2 : : XMLDocument * pDoc = new tinyxml2 : : XMLDocument ( ) ; <nl> + if ( NULL = = pDoc ) <nl> + { <nl> + return false ; <nl> + } <nl> + tinyxml2 : : XMLDeclaration * pDeclaration = pDoc - > NewDeclaration ( " 1 . 0 " ) ; <nl> + if ( NULL = = pDeclaration ) <nl> + { <nl> + return false ; <nl> + } <nl> + pDoc - > LinkEndChild ( pDeclaration ) ; <nl> + tinyxml2 : : XMLElement * pRootEle = pDoc - > NewElement ( USERDEFAULT_ROOT_NAME ) ; <nl> + if ( NULL = = pRootEle ) <nl> + { <nl> + return false ; <nl> + } <nl> + pDoc - > LinkEndChild ( pRootEle ) ; <nl> + bRet = pDoc - > SaveFile ( m_sFilePath . c_str ( ) ) ; <nl> + <nl> + if ( pDoc ) <nl> + { <nl> + delete pDoc ; <nl> + } <nl> + <nl> + return bRet ; <nl> } <nl> <nl> const string & CCUserDefault : : getXMLFilePath ( ) <nl> const string & CCUserDefault : : getXMLFilePath ( ) <nl> <nl> void CCUserDefault : : flush ( ) <nl> { <nl> - / / save to file <nl> - if ( g_sharedDoc ) <nl> - { <nl> - xmlSaveFile ( CCUserDefault : : sharedUserDefault ( ) - > getXMLFilePath ( ) . c_str ( ) , g_sharedDoc ) ; <nl> - } <nl> } <nl> <nl> NS_CC_END <nl> | added ccuserdefault tinyxml2 ver | cocos2d/cocos2d-x | 05bece9d07c40b7212ad84012aab5f6726fc5740 | 2013-01-26T02:41:27Z |
mmm a / plugin / sframe / iter_sframe . cc <nl> ppp b / plugin / sframe / iter_sframe . cc <nl> <nl> * \ author Bing Xu <nl> * / <nl> <nl> - # include < unity / lib / image_util . hpp > <nl> - # include < unity / lib / gl_sframe . hpp > <nl> - # include < unity / lib / gl_sarray . hpp > <nl> # include < mxnet / io . h > <nl> # include < dmlc / base . h > <nl> # include < dmlc / io . h > <nl> <nl> # include < dmlc / parameter . h > <nl> # include < string > <nl> # include < memory > <nl> + # include < unity / lib / image_util . hpp > <nl> + # include < unity / lib / gl_sframe . hpp > <nl> + # include < unity / lib / gl_sarray . hpp > <nl> # include " . . / . . / src / io / inst_vector . h " <nl> # include " . . / . . / src / io / image_recordio . h " <nl> # include " . . / . . / src / io / image_augmenter . h " <nl> mmm a / src / ndarray / ndarray_function . cu <nl> ppp b / src / ndarray / ndarray_function . cu <nl> <nl> + / * ! <nl> + * Copyright ( c ) 2015 by Contributors <nl> + * \ file ndarray_function_cpu . cc <nl> + * \ brief GPU Implementation of ndarray function . <nl> + * / <nl> + <nl> / / this will be invoked by nvcc and compile GPU version <nl> # include < dmlc / logging . h > <nl> # include " . / ndarray_function . h " <nl> mmm a / src / operator / activation . cu <nl> ppp b / src / operator / activation . cu <nl> Operator * CreateOp < gpu > ( ActivationParam param ) { <nl> # if MXNET_USE_CUDNN = = 1 <nl> return new CuDNNActivationOp ( param ) ; <nl> # else <nl> - switch ( param . act_type ) { <nl> + switch ( param . act_type ) { <nl> case activation : : kReLU : <nl> return new ActivationOp < gpu , mshadow_op : : relu , mshadow_op : : relu_grad > ( ) ; <nl> case activation : : kSigmoid : <nl> Operator * CreateOp < gpu > ( ActivationParam param ) { <nl> } <nl> # endif / / MXNET_USE_CUDNN <nl> } <nl> - } / / op <nl> + } / / namespace op <nl> } / / namespace mxnet <nl> <nl> mmm a / src / operator / convolution . cu <nl> ppp b / src / operator / convolution . cu <nl> <nl> # include " . / convolution - inl . h " <nl> # if MXNET_USE_CUDNN = = 1 <nl> # include " . / cudnn_convolution - inl . h " <nl> - # endif / / MXNET_USE_CUDNN <nl> + # endif / / MXNET_USE_CUDNN <nl> <nl> namespace mxnet { <nl> namespace op { <nl> Operator * CreateOp < gpu > ( ConvolutionParam param ) { <nl> return new CuDNNConvolutionOp ( param ) ; <nl> # else <nl> return new ConvolutionOp < gpu > ( param ) ; <nl> - # endif / / MXNET_USE_CUDNN <nl> + # endif / / MXNET_USE_CUDNN <nl> } <nl> <nl> } / / namespace op <nl> mmm a / src / operator / cudnn_batch_norm . cu <nl> ppp b / src / operator / cudnn_batch_norm . cu <nl> <nl> * / <nl> <nl> # include " . / cudnn_batch_norm - inl . h " <nl> + # include < vector > <nl> <nl> namespace mxnet { <nl> namespace op { <nl> class CuDNNBatchNormOp : public Operator { <nl> <nl> Stream < gpu > * s = ctx . get_stream < gpu > ( ) ; <nl> Tensor < gpu , 4 > x = in_data [ cudnnbatchnorm : : kData ] . get_with_shape < gpu , 4 , real_t > ( shape_ , s ) ; <nl> - Tensor < gpu , 1 > gamma = in_data [ cudnnbatchnorm : : kGamma ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> - Tensor < gpu , 1 > beta = in_data [ cudnnbatchnorm : : kBeta ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > gamma = <nl> + in_data [ cudnnbatchnorm : : kGamma ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > beta = <nl> + in_data [ cudnnbatchnorm : : kBeta ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> Tensor < gpu , 4 > y = out_data [ cudnnbatchnorm : : kOut ] . get_with_shape < gpu , 4 , real_t > ( shape_ , s ) ; <nl> - Tensor < gpu , 1 > moving_mean = aux_states [ cudnnbatchnorm : : kMovingMean ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> - Tensor < gpu , 1 > moving_inv_var = aux_states [ cudnnbatchnorm : : kMovingInvVar ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > moving_mean = <nl> + aux_states [ cudnnbatchnorm : : kMovingMean ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > moving_inv_var = <nl> + aux_states [ cudnnbatchnorm : : kMovingInvVar ] <nl> + . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> float a = 1 . 0f , b = 0 . 0f ; <nl> if ( ctx . is_train ) { <nl> - Tensor < gpu , 1 > save_mean = out_data [ cudnnbatchnorm : : kMean ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> - Tensor < gpu , 1 > save_inv_var = out_data [ cudnnbatchnorm : : kInvVar ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > save_mean = <nl> + out_data [ cudnnbatchnorm : : kMean ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > save_inv_var = <nl> + out_data [ cudnnbatchnorm : : kInvVar ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> CHECK_EQ ( cudnnBatchNormalizationForwardTraining ( s - > dnn_handle_ , <nl> CUDNN_BATCHNORM_SPATIAL , <nl> & a , <nl> class CuDNNBatchNormOp : public Operator { <nl> Tensor < gpu , 4 > x = in_data [ cudnnbatchnorm : : kData ] . get_with_shape < gpu , 4 , real_t > ( shape_ , s ) ; <nl> Tensor < gpu , 4 > dx = in_grad [ cudnnbatchnorm : : kData ] . get_with_shape < gpu , 4 , real_t > ( shape_ , s ) ; <nl> Tensor < gpu , 4 > dy = out_grad [ cudnnbatchnorm : : kOut ] . get_with_shape < gpu , 4 , real_t > ( shape_ , s ) ; <nl> - Tensor < gpu , 1 > gamma = in_data [ cudnnbatchnorm : : kGamma ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> - Tensor < gpu , 1 > dbeta = in_grad [ cudnnbatchnorm : : kBeta ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> - Tensor < gpu , 1 > dgamma = in_grad [ cudnnbatchnorm : : kGamma ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> - Tensor < gpu , 1 > save_mean = out_data [ cudnnbatchnorm : : kMean ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> - Tensor < gpu , 1 > save_inv_var = out_data [ cudnnbatchnorm : : kInvVar ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > gamma = <nl> + in_data [ cudnnbatchnorm : : kGamma ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > dbeta = <nl> + in_grad [ cudnnbatchnorm : : kBeta ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > dgamma = <nl> + in_grad [ cudnnbatchnorm : : kGamma ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > save_mean = <nl> + out_data [ cudnnbatchnorm : : kMean ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> + Tensor < gpu , 1 > save_inv_var = <nl> + out_data [ cudnnbatchnorm : : kInvVar ] . get_with_shape < gpu , 1 , real_t > ( Shape1 ( shape_ [ 1 ] ) , s ) ; <nl> float a = 1 . 0f , b = 0 . 0f ; <nl> CHECK_EQ ( s - > dnn_handle_ownership_ , mshadow : : Stream < gpu > : : OwnHandle ) ; <nl> # if CUDNN_VERSION > = 4007 <nl> mmm a / src / operator / deconvolution . cu <nl> ppp b / src / operator / deconvolution . cu <nl> <nl> # include " . / deconvolution - inl . h " <nl> # if MXNET_USE_CUDNN = = 1 <nl> # include " . / cudnn_deconvolution - inl . h " <nl> - # endif / / MXNET_USE_CUDNN <nl> + # endif / / MXNET_USE_CUDNN <nl> <nl> namespace mxnet { <nl> namespace op { <nl> Operator * CreateOp < gpu > ( DeconvolutionParam param ) { <nl> return new CuDNNDeconvolutionOp ( param ) ; <nl> # else <nl> return new DeconvolutionOp < gpu > ( param ) ; <nl> - # endif / / MXNET_USE_CUDNN <nl> + # endif / / MXNET_USE_CUDNN <nl> } <nl> <nl> } / / namespace op <nl> mmm a / src / operator / elementwise_binary_scalar_op . cu <nl> ppp b / src / operator / elementwise_binary_scalar_op . cu <nl> <nl> namespace mxnet { <nl> namespace op { <nl> template < > <nl> - Operator * CreateElementwiseBinaryScalarOp < gpu > ( elembinary : : ElementwiseBinaryScalarOpType type , ScalarOpParam param ) { <nl> - return CreateElementwiseBinaryScalarOp_ < gpu > ( type , param ) ; <nl> + Operator * CreateElementwiseBinaryScalarOp < gpu > ( elembinary : : ElementwiseBinaryScalarOpType type , <nl> + ScalarOpParam param ) { <nl> + return CreateElementwiseBinaryScalarOp_ < gpu > ( type , param ) ; <nl> } <nl> } / / namespace op <nl> } / / namespace mxnet <nl> mmm a / src / operator / pooling . cu <nl> ppp b / src / operator / pooling . cu <nl> <nl> # include " . / pooling - inl . h " <nl> # if MXNET_USE_CUDNN = = 1 <nl> # include " . / cudnn_pooling - inl . h " <nl> - # endif / / MXNET_USE_CUDNN <nl> + # endif / / MXNET_USE_CUDNN <nl> <nl> namespace mxnet { <nl> namespace op { <nl> mmm a / src / operator / regression_output . cu <nl> ppp b / src / operator / regression_output . cu <nl> namespace mxnet { <nl> namespace op { <nl> <nl> template < > <nl> - Operator * CreateRegressionOutputOp < gpu > ( reg_enum : : RegressionOutputType type , RegressionOutputParam param ) { <nl> + Operator * CreateRegressionOutputOp < gpu > ( reg_enum : : RegressionOutputType type , <nl> + RegressionOutputParam param ) { <nl> switch ( type ) { <nl> case reg_enum : : kLinear : <nl> return new RegressionOutputOp < gpu , mshadow : : op : : identity , mshadow : : op : : minus > ( param ) ; <nl> mmm a / src / operator / softmax_activation . cu <nl> ppp b / src / operator / softmax_activation . cu <nl> Operator * CreateOp < gpu > ( SoftmaxActivationParam param ) { <nl> return new SoftmaxActivationOp < gpu > ( param ) ; <nl> # endif / / MXNET_USE_CUDNN <nl> } <nl> - } / / op <nl> + } / / namespace op <nl> } / / namespace mxnet <nl> <nl> | lint . cu codes | apache/incubator-mxnet | 945e6e993715bd68b11fb77cb80299bbea09cd45 | 2016-03-19T16:38:50Z |
mmm a / js / apps / system / _admin / aardvark / APP / frontend / js / views / viewsView . js <nl> ppp b / js / apps / system / _admin / aardvark / APP / frontend / js / views / viewsView . js <nl> <nl> processData : false , <nl> success : function ( data ) { <nl> self . $ el . html ( self . template . render ( { <nl> - views : data <nl> + views : data . result <nl> } ) ) ; <nl> } , <nl> error : function ( error ) { <nl> | Fix response processing for view Views ( ) | arangodb/arangodb | 304fc511f289c7e9f117391de8155c7bb3fb698b | 2018-07-25T16:05:22Z |
mmm a / Marlin / src / pins / linux / pins_RAMPS_LINUX . h <nl> ppp b / Marlin / src / pins / linux / pins_RAMPS_LINUX . h <nl> <nl> # endif <nl> <nl> # ifndef MARLIN_EEPROM_SIZE <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # endif <nl> <nl> # define IS_RAMPS_EFB <nl> mmm a / Marlin / src / pins / lpc1768 / pins_BTT_SKR_V1_3 . h <nl> ppp b / Marlin / src / pins / lpc1768 / pins_BTT_SKR_V1_3 . h <nl> <nl> # define E1_SERIAL_RX_PIN P1_01 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> <nl> / * * <nl> mmm a / Marlin / src / pins / lpc1768 / pins_BTT_SKR_V1_4 . h <nl> ppp b / Marlin / src / pins / lpc1768 / pins_BTT_SKR_V1_4 . h <nl> <nl> # define Z2_SERIAL_RX_PIN P1_01 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / lpc1768 / pins_BTT_SKR_common . h <nl> ppp b / Marlin / src / pins / lpc1768 / pins_BTT_SKR_common . h <nl> <nl> # endif <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / <nl> / / Steppers <nl> mmm a / Marlin / src / pins / lpc1768 / pins_GMARSH_X6_REV1 . h <nl> ppp b / Marlin / src / pins / lpc1768 / pins_GMARSH_X6_REV1 . h <nl> <nl> # define BOARD_INFO_NAME " GMARSH X6 REV1 " <nl> <nl> / / Ignore temp readings during develpment . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / <nl> / / Enable 12MHz clock output on P1 . 27 pin to sync TMC2208 chip clocks <nl> <nl> # define E2_SERIAL_RX_PIN P2_06 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # else <nl> # error " TMC2208 UART configuration is required for GMarsh X6 . " <nl> # endif <nl> mmm a / Marlin / src / pins / lpc1768 / pins_MKS_SBASE . h <nl> ppp b / Marlin / src / pins / lpc1768 / pins_MKS_SBASE . h <nl> <nl> # define E0_SERIAL_RX_PIN P0_26 / / TH4 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> <nl> / / UNUSED <nl> mmm a / Marlin / src / pins / lpc1768 / pins_MKS_SGEN_L . h <nl> ppp b / Marlin / src / pins / lpc1768 / pins_MKS_SGEN_L . h <nl> <nl> # define Z2_SERIAL_RX_PIN P1_17 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif / / TMC2208 | | TMC2209 <nl> <nl> / / <nl> mmm a / Marlin / src / pins / lpc1768 / pins_RAMPS_RE_ARM . h <nl> ppp b / Marlin / src / pins / lpc1768 / pins_RAMPS_RE_ARM . h <nl> <nl> # endif <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / lpc1769 / pins_AZTEEG_X5_MINI . h <nl> ppp b / Marlin / src / pins / lpc1769 / pins_AZTEEG_X5_MINI . h <nl> <nl> / / DIGIPOT slave addresses <nl> / / <nl> # ifndef DIGIPOT_I2C_ADDRESS_A <nl> - # define DIGIPOT_I2C_ADDRESS_A 0x2C / / unshifted slave address for first DIGIPOT <nl> + # define DIGIPOT_I2C_ADDRESS_A 0x2C / / unshifted slave address for first DIGIPOT <nl> # endif <nl> <nl> # ifndef DIGIPOT_I2C_ADDRESS_B <nl> - # define DIGIPOT_I2C_ADDRESS_B 0x2E / / unshifted slave address for second DIGIPOT <nl> + # define DIGIPOT_I2C_ADDRESS_B 0x2E / / unshifted slave address for second DIGIPOT <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / lpc1769 / pins_MKS_SGEN . h <nl> ppp b / Marlin / src / pins / lpc1769 / pins_MKS_SGEN . h <nl> <nl> # define E1_SERIAL_RX_PIN P4_28 / / J8 - 6 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> mmm a / Marlin / src / pins / lpc1769 / pins_TH3D_EZBOARD . h <nl> ppp b / Marlin / src / pins / lpc1769 / pins_TH3D_EZBOARD . h <nl> <nl> # define E0_SERIAL_RX_PIN P0_21 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / mega / pins_INTAMSYS40 . h <nl> ppp b / Marlin / src / pins / mega / pins_INTAMSYS40 . h <nl> <nl> <nl> / / Motor current PWM conversion , PWM value = MotorCurrentSetting * 255 / range <nl> # ifndef MOTOR_CURRENT_PWM_RANGE <nl> - # define MOTOR_CURRENT_PWM_RANGE 2000 <nl> + # define MOTOR_CURRENT_PWM_RANGE 2000 <nl> # endif <nl> # define DEFAULT_PWM_MOTOR_CURRENT { 1300 , 1300 , 1250 } <nl> <nl> mmm a / Marlin / src / pins / mega / pins_MIGHTYBOARD_REVE . h <nl> ppp b / Marlin / src / pins / mega / pins_MIGHTYBOARD_REVE . h <nl> <nl> # define DIGIPOTS_I2C_SDA_E1 77 / / J6 <nl> <nl> # ifndef DIGIPOT_I2C_ADDRESS_A <nl> - # define DIGIPOT_I2C_ADDRESS_A 0x2F / / unshifted slave address ( 5E < - 2F < < 1 ) <nl> + # define DIGIPOT_I2C_ADDRESS_A 0x2F / / unshifted slave address ( 5E < - 2F < < 1 ) <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / ramps / pins_AZTEEG_X3_PRO . h <nl> ppp b / Marlin / src / pins / ramps / pins_AZTEEG_X3_PRO . h <nl> <nl> <nl> / / DIGIPOT slave addresses <nl> # ifndef DIGIPOT_I2C_ADDRESS_A <nl> - # define DIGIPOT_I2C_ADDRESS_A 0x2C / / unshifted slave address for first DIGIPOT 0x2C ( 0x58 < - 0x2C < < 1 ) <nl> + # define DIGIPOT_I2C_ADDRESS_A 0x2C / / unshifted slave address for first DIGIPOT 0x2C ( 0x58 < - 0x2C < < 1 ) <nl> # endif <nl> # ifndef DIGIPOT_I2C_ADDRESS_B <nl> - # define DIGIPOT_I2C_ADDRESS_B 0x2E / / unshifted slave address for second DIGIPOT 0x2E ( 0x5C < - 0x2E < < 1 ) <nl> + # define DIGIPOT_I2C_ADDRESS_B 0x2E / / unshifted slave address for second DIGIPOT 0x2E ( 0x5C < - 0x2E < < 1 ) <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / ramps / pins_RAMPS_CREALITY . h <nl> ppp b / Marlin / src / pins / ramps / pins_RAMPS_CREALITY . h <nl> <nl> <nl> # define SUICIDE_PIN 12 / / Used by CR2020 Industrial series <nl> # ifndef SUICIDE_PIN_INVERTING <nl> - # define SUICIDE_PIN_INVERTING true <nl> + # define SUICIDE_PIN_INVERTING true <nl> # endif <nl> mmm a / Marlin / src / pins / sam / pins_PRINTRBOARD_G2 . h <nl> ppp b / Marlin / src / pins / sam / pins_PRINTRBOARD_G2 . h <nl> <nl> <nl> # define FET_SAFETY_PIN 31 / / PA7 must be pulsed low every 50 mS or FETs are turned off <nl> # define FET_SAFETY_DELAY 50 / / 50 mS delay between pulses <nl> - # define FET_SAFETY_INVERTED true / / true - negative going pulse of 2 uS <nl> + # define FET_SAFETY_INVERTED true / / true - negative going pulse of 2 uS <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> mmm a / Marlin / src / pins / sam / pins_RADDS . h <nl> ppp b / Marlin / src / pins / sam / pins_RADDS . h <nl> <nl> / / <nl> # if EITHER ( NO_EEPROM_SELECTED , I2C_EEPROM ) <nl> # define I2C_EEPROM <nl> - # define MARLIN_EEPROM_SIZE 0x2000 / / 8KB <nl> + # define MARLIN_EEPROM_SIZE 0x2000 / / 8KB <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / sam / pins_RAMPS_SMART . h <nl> ppp b / Marlin / src / pins / sam / pins_RAMPS_SMART . h <nl> <nl> <nl> / / I2C EEPROM with 4K of space <nl> # define I2C_EEPROM <nl> - # define MARLIN_EEPROM_SIZE 0x1000 <nl> + # define MARLIN_EEPROM_SIZE 0x1000 <nl> <nl> # define RESET_PIN 42 / / Resets the board if the jumper is attached <nl> <nl> mmm a / Marlin / src / pins / sam / pins_RURAMPS4D_11 . h <nl> ppp b / Marlin / src / pins / sam / pins_RURAMPS4D_11 . h <nl> <nl> / / <nl> / / EEPROM <nl> / / <nl> - # define MARLIN_EEPROM_SIZE 0x8000 / / 32Kb ( 24lc256 ) <nl> + # define MARLIN_EEPROM_SIZE 0x8000 / / 32Kb ( 24lc256 ) <nl> # define I2C_EEPROM / / EEPROM on I2C - 0 <nl> / / # define EEPROM_SD / / EEPROM on SDCARD <nl> / / # define SPI_EEPROM / / EEPROM on SPI - 0 <nl> mmm a / Marlin / src / pins / sam / pins_RURAMPS4D_13 . h <nl> ppp b / Marlin / src / pins / sam / pins_RURAMPS4D_13 . h <nl> <nl> / / <nl> / / EEPROM <nl> / / <nl> - # define MARLIN_EEPROM_SIZE 0x8000 / / 32Kb ( 24lc256 ) <nl> + # define MARLIN_EEPROM_SIZE 0x8000 / / 32Kb ( 24lc256 ) <nl> # define I2C_EEPROM / / EEPROM on I2C - 0 <nl> / / # define EEPROM_SD / / EEPROM on SDCARD <nl> / / # define SPI_EEPROM / / EEPROM on SPI - 0 <nl> mmm a / Marlin / src / pins / samd / pins_RAMPS_144 . h <nl> ppp b / Marlin / src / pins / samd / pins_RAMPS_144 . h <nl> <nl> / / <nl> / / # define QSPI_EEPROM / / Use AGCM4 onboard QSPI EEPROM ( Uses 4K of RAM ) <nl> # define I2C_EEPROM / / EEPROM on I2C - 0 <nl> - # define MARLIN_EEPROM_SIZE 0x8000 / / 32K ( 24lc256 ) <nl> + # define MARLIN_EEPROM_SIZE 0x8000 / / 32K ( 24lc256 ) <nl> <nl> / / <nl> / / Limit Switches <nl> mmm a / Marlin / src / pins / stm32f0 / pins_MALYAN_M300 . h <nl> ppp b / Marlin / src / pins / stm32f0 / pins_MALYAN_M300 . h <nl> <nl> / / <nl> / / Timers <nl> / / <nl> - # define STEP_TIMER 6 <nl> - # define TEMP_TIMER 7 <nl> + # define STEP_TIMER 6 <nl> + # define TEMP_TIMER 7 <nl> <nl> / / <nl> / / Limit Switches <nl> mmm a / Marlin / src / pins / stm32f1 / pins_BTT_SKR_E3_DIP . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_BTT_SKR_E3_DIP . h <nl> <nl> # define DISABLE_JTAG <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> # if EITHER ( NO_EEPROM_SELECTED , FLASH_EEPROM_EMULATION ) <nl> # define FLASH_EEPROM_EMULATION <nl> <nl> # define E0_SERIAL_RX_PIN PD2 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> <nl> / / <nl> <nl> / / USB connect control <nl> / / <nl> # define USB_CONNECT_PIN PC13 <nl> - # define USB_CONNECT_INVERTING false <nl> + # define USB_CONNECT_INVERTING false <nl> <nl> / * * <nl> * _____ <nl> <nl> * <nl> * / <nl> <nl> - # define CLCD_SPI_BUS 1 / / SPI1 connector <nl> + # define CLCD_SPI_BUS 1 / / SPI1 connector <nl> <nl> # define BEEPER_PIN PB6 <nl> <nl> <nl> # error " SD CUSTOM_CABLE is not compatible with SKR E3 DIP . " <nl> # endif <nl> <nl> - # define ON_BOARD_SPI_DEVICE 1 / / SPI1 <nl> + # define ON_BOARD_SPI_DEVICE 1 / / SPI1 <nl> # define ONBOARD_SD_CS_PIN PA4 / / Chip select for " System " SD card <nl> mmm a / Marlin / src / pins / stm32f1 / pins_BTT_SKR_MINI_E3_common . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_BTT_SKR_MINI_E3_common . h <nl> <nl> # define DISABLE_JTAG <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> # if EITHER ( NO_EEPROM_SELECTED , FLASH_EEPROM_EMULATION ) <nl> # define FLASH_EEPROM_EMULATION <nl> <nl> # define USB_CONNECT_PIN PC13 <nl> # endif <nl> <nl> - # define USB_CONNECT_INVERTING false <nl> + # define USB_CONNECT_INVERTING false <nl> <nl> / * * <nl> * SKR Mini E3 V1 . 0 , V1 . 2 SKR Mini E3 V2 . 0 <nl> <nl> * <nl> * / <nl> <nl> - # define CLCD_SPI_BUS 1 / / SPI1 connector <nl> + # define CLCD_SPI_BUS 1 / / SPI1 connector <nl> <nl> # define BEEPER_PIN EXP1_9 <nl> <nl> <nl> # error " SD CUSTOM_CABLE is not compatible with SKR Mini E3 . " <nl> # endif <nl> <nl> - # define ON_BOARD_SPI_DEVICE 1 / / SPI1 <nl> + # define ON_BOARD_SPI_DEVICE 1 / / SPI1 <nl> # define ONBOARD_SD_CS_PIN PA4 / / Chip select for " System " SD card <nl> mmm a / Marlin / src / pins / stm32f1 / pins_BTT_SKR_MINI_V1_1 . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_BTT_SKR_MINI_V1_1 . h <nl> <nl> # define DISABLE_JTAG <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> # if EITHER ( NO_EEPROM_SELECTED , FLASH_EEPROM_EMULATION ) <nl> # define FLASH_EEPROM_EMULATION <nl> <nl> # define MOSI_PIN PA7 <nl> # define SS_PIN PA4 <nl> # endif <nl> - # define ON_BOARD_SPI_DEVICE 1 / / SPI1 <nl> + # define ON_BOARD_SPI_DEVICE 1 / / SPI1 <nl> # define ONBOARD_SD_CS_PIN PA4 / / Chip select for " System " SD card <nl> mmm a / Marlin / src / pins / stm32f1 / pins_CCROBOT_MEEB_3DP . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_CCROBOT_MEEB_3DP . h <nl> <nl> / / <nl> # if EITHER ( NO_EEPROM_SELECTED , FLASH_EEPROM_EMULATION ) <nl> # define FLASH_EEPROM_EMULATION <nl> - # define EEPROM_PAGE_SIZE 0x800U / / 2KB <nl> + # define EEPROM_PAGE_SIZE 0x800U / / 2KB <nl> # define EEPROM_START_ADDRESS ( 0x8000000UL + ( STM32_FLASH_SIZE ) * 1024UL - ( EEPROM_PAGE_SIZE ) * 2UL ) <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # endif <nl> <nl> / / <nl> <nl> # define E0_SERIAL_RX_PIN PC4 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> <nl> / / <nl> / / Temperature Sensors <nl> <nl> # define SS_PIN PA4 <nl> # endif <nl> <nl> - # define ON_BOARD_SPI_DEVICE 1 / / SPI1 <nl> + # define ON_BOARD_SPI_DEVICE 1 / / SPI1 <nl> # define ONBOARD_SD_CS_PIN PA4 / / Chip select for SD - NAND <nl> <nl> # endif <nl> mmm a / Marlin / src / pins / stm32f1 / pins_CHITU3D . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_CHITU3D . h <nl> <nl> / / # define I2C_EEPROM <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / <nl> / / Steppers <nl> mmm a / Marlin / src / pins / stm32f1 / pins_CHITU3D_V5 . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_CHITU3D_V5 . h <nl> <nl> <nl> / / Emulated DOGM <nl> <nl> - # define GRAPHICAL_TFT_UPSCALE 3 <nl> + # define GRAPHICAL_TFT_UPSCALE 3 <nl> # ifndef XPT2046_X_CALIBRATION <nl> # define XPT2046_X_CALIBRATION - 12316 <nl> # endif <nl> mmm a / Marlin / src / pins / stm32f1 / pins_CHITU3D_V6 . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_CHITU3D_V6 . h <nl> <nl> <nl> / / Emulated DOGM <nl> # elif ENABLED ( FSMC_GRAPHICAL_TFT ) <nl> - # define GRAPHICAL_TFT_UPSCALE 3 <nl> + # define GRAPHICAL_TFT_UPSCALE 3 <nl> <nl> # ifndef XPT2046_X_CALIBRATION <nl> # define XPT2046_X_CALIBRATION - 12316 <nl> mmm a / Marlin / src / pins / stm32f1 / pins_CREALITY_V4 . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_CREALITY_V4 . h <nl> <nl> # if ENABLED ( IIC_BL24CXX_EEPROM ) <nl> # define IIC_EEPROM_SDA PA11 <nl> # define IIC_EEPROM_SCL PA12 <nl> - # define MARLIN_EEPROM_SIZE 0x800 / / 2Kb ( 24C16 ) <nl> + # define MARLIN_EEPROM_SIZE 0x800 / / 2Kb ( 24C16 ) <nl> # else <nl> # define SDCARD_EEPROM_EMULATION / / SD EEPROM until all EEPROM is BL24CXX <nl> - # define MARLIN_EEPROM_SIZE 0x800 / / 2Kb <nl> + # define MARLIN_EEPROM_SIZE 0x800 / / 2Kb <nl> # endif <nl> <nl> / / SPI <nl> <nl> / / <nl> # define SD_DETECT_PIN PC7 <nl> # define SDCARD_CONNECTION ONBOARD <nl> - # define ON_BOARD_SPI_DEVICE 1 <nl> + # define ON_BOARD_SPI_DEVICE 1 <nl> # define ONBOARD_SD_CS_PIN PA4 / / SDSS <nl> # define SDIO_SUPPORT <nl> <nl> mmm a / Marlin / src / pins / stm32f1 / pins_FYSETC_AIO_II . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_FYSETC_AIO_II . h <nl> <nl> # define pins_v2_20190128 / / new pins define <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / <nl> / / Flash EEPROM Emulation <nl> <nl> / / Stepper current PWM <nl> / / <nl> # ifndef MOTOR_CURRENT_PWM_RANGE <nl> - # define MOTOR_CURRENT_PWM_RANGE 1500 / / origin : 2000 <nl> + # define MOTOR_CURRENT_PWM_RANGE 1500 / / origin : 2000 <nl> # endif <nl> # define DEFAULT_PWM_MOTOR_CURRENT { 500 , 500 , 400 } / / origin : { 1300 , 1300 , 1250 } <nl> <nl> <nl> # define DOGLCD_CS PB7 <nl> # endif <nl> <nl> - / / # define LCD_CONTRAST_INIT 190 <nl> + / / # define LCD_CONTRAST_INIT 190 <nl> / / # define LCD_SCREEN_ROT_90 <nl> / / # define LCD_SCREEN_ROT_180 <nl> / / # define LCD_SCREEN_ROT_270 <nl> mmm a / Marlin / src / pins / stm32f1 / pins_FYSETC_CHEETAH . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_FYSETC_CHEETAH . h <nl> <nl> / / https : / / github . com / FYSETC / Cheetah <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> # define DISABLE_JTAG <nl> <nl> <nl> # define LCD_PINS_D4 PB13 / / SCLK <nl> # define LCD_PINS_ENABLE PB15 / / DATA MOSI <nl> <nl> - / / # define LCD_CONTRAST_INIT 190 <nl> + / / # define LCD_CONTRAST_INIT 190 <nl> <nl> # if ENABLED ( NEWPANEL ) <nl> # define BTN_EN1 PC10 <nl> <nl> # define CLCD_SOFT_SPI_MISO PB14 <nl> # define CLCD_SOFT_SPI_SCLK PB13 <nl> # else <nl> - # define CLCD_SPI_BUS 2 <nl> + # define CLCD_SPI_BUS 2 <nl> # endif <nl> # endif <nl> mmm a / Marlin / src / pins / stm32f1 / pins_GTM32_MINI . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_GTM32_MINI . h <nl> <nl> / / # define DISABLE_JTAGSWD <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / Enable EEPROM Emulation for this board as it doesn ' t have EEPROM <nl> # if EITHER ( NO_EEPROM_SELECTED , FLASH_EEPROM_EMULATION ) <nl> # define FLASH_EEPROM_EMULATION <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # endif <nl> <nl> / / <nl> <nl> / / ESP WiFi can be soldered to J9 connector which is wired to USART2 . <nl> / / Must define WIFISUPPORT in Configuration . h for the printer . <nl> / / <nl> - # define ESP_WIFI_MODULE_COM 2 <nl> - # define ESP_WIFI_MODULE_BAUDRATE 115200 <nl> + # define ESP_WIFI_MODULE_COM 2 <nl> + # define ESP_WIFI_MODULE_BAUDRATE 115200 <nl> # define ESP_WIFI_MODULE_RESET_PIN - 1 <nl> mmm a / Marlin / src / pins / stm32f1 / pins_GTM32_MINI_A30 . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_GTM32_MINI_A30 . h <nl> <nl> / / # define DISABLE_JTAGSWD <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / Enable EEPROM Emulation for this board as it doesn ' t have EEPROM <nl> # if EITHER ( NO_EEPROM_SELECTED , FLASH_EEPROM_EMULATION ) <nl> # define FLASH_EEPROM_EMULATION <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # endif <nl> <nl> / / <nl> <nl> / / ESP WiFi can be soldered to J9 connector which is wired to USART2 . <nl> / / Must define WIFISUPPORT in Configuration . h for the printer . <nl> / / <nl> - # define ESP_WIFI_MODULE_COM 2 <nl> - # define ESP_WIFI_MODULE_BAUDRATE 115200 <nl> + # define ESP_WIFI_MODULE_COM 2 <nl> + # define ESP_WIFI_MODULE_BAUDRATE 115200 <nl> # define ESP_WIFI_MODULE_RESET_PIN - 1 <nl> mmm a / Marlin / src / pins / stm32f1 / pins_GTM32_PRO_VB . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_GTM32_PRO_VB . h <nl> <nl> / / # define DISABLE_JTAGSWD <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / Enable EEPROM Emulation for this board as it doesn ' t have EEPROM <nl> # if EITHER ( NO_EEPROM_SELECTED , FLASH_EEPROM_EMULATION ) <nl> # define FLASH_EEPROM_EMULATION <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # endif <nl> <nl> / / <nl> <nl> / / ESP WiFi can be soldered to J9 connector which is wired to USART2 . <nl> / / Must define WIFISUPPORT in Configuration . h for the printer . <nl> / / <nl> - # define ESP_WIFI_MODULE_COM 2 <nl> - # define ESP_WIFI_MODULE_BAUDRATE 115200 <nl> + # define ESP_WIFI_MODULE_COM 2 <nl> + # define ESP_WIFI_MODULE_BAUDRATE 115200 <nl> # define ESP_WIFI_MODULE_RESET_PIN - 1 <nl> mmm a / Marlin / src / pins / stm32f1 / pins_GTM32_REV_B . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_GTM32_REV_B . h <nl> <nl> / / # define DISABLE_JTAGSWD <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / Enable EEPROM Emulation for this board as it doesn ' t have EEPROM <nl> # if EITHER ( NO_EEPROM_SELECTED , FLASH_EEPROM_EMULATION ) <nl> # define FLASH_EEPROM_EMULATION <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # endif <nl> <nl> / / <nl> <nl> / / ESP WiFi can be soldered to J9 connector which is wired to USART2 . <nl> / / Must define WIFISUPPORT in Configuration . h for the printer . <nl> / / <nl> - # define ESP_WIFI_MODULE_COM 2 <nl> - # define ESP_WIFI_MODULE_BAUDRATE 115200 <nl> + # define ESP_WIFI_MODULE_COM 2 <nl> + # define ESP_WIFI_MODULE_BAUDRATE 115200 <nl> # define ESP_WIFI_MODULE_RESET_PIN - 1 <nl> mmm a / Marlin / src / pins / stm32f1 / pins_JGAURORA_A5S_A1 . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_JGAURORA_A5S_A1 . h <nl> <nl> / / Enable EEPROM Emulation for this board , so that we don ' t overwrite factory data <nl> <nl> / / # define I2C_EEPROM / / AT24C64 <nl> - / / # define MARLIN_EEPROM_SIZE 0x8000UL / / 64KB <nl> + / / # define MARLIN_EEPROM_SIZE 0x8000UL / / 64KB <nl> <nl> / / # define FLASH_EEPROM_EMULATION <nl> - / / # define MARLIN_EEPROM_SIZE 0x1000UL / / 4KB <nl> + / / # define MARLIN_EEPROM_SIZE 0x1000UL / / 4KB <nl> / / # define MARLIN_EEPROM_SIZE ( EEPROM_START_ADDRESS + ( EEPROM_PAGE_SIZE ) * 2UL ) <nl> <nl> / / # define EEPROM_CHITCHAT <nl> mmm a / Marlin / src / pins / stm32f1 / pins_LONGER3D_LK . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_LONGER3D_LK . h <nl> <nl> # define DOGLCD_MOSI - 1 / / Prevent auto - define by Conditionals_post . h <nl> # define DOGLCD_SCK - 1 <nl> <nl> - # define GRAPHICAL_TFT_UPSCALE 2 <nl> + # define GRAPHICAL_TFT_UPSCALE 2 <nl> # define TFT_WIDTH 320 <nl> # define TFT_HEIGHT 240 <nl> # define TFT_PIXEL_OFFSET_X 32 <nl> mmm a / Marlin / src / pins / stm32f1 / pins_MALYAN_M200 . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_MALYAN_M200 . h <nl> <nl> / / On STM32F103 : <nl> / / PB3 , PB6 , PB7 , and PB8 can be used with pwm , which rules out TIM2 and TIM4 . <nl> / / On STM32F070 , 16 and 17 are in use , but 1 and 3 are available . <nl> - # define STEP_TIMER 1 <nl> - # define TEMP_TIMER 3 <nl> + # define STEP_TIMER 1 <nl> + # define TEMP_TIMER 3 <nl> <nl> / / <nl> / / Limit Switches <nl> mmm a / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN . h <nl> <nl> <nl> / / Reduce baud rate for software serial reliability <nl> # if HAS_TMC_SW_SERIAL <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> # endif <nl> mmm a / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN_E3_common . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN_E3_common . h <nl> <nl> # define E0_SERIAL_RX_PIN PC11 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN_MINI . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN_MINI . h <nl> <nl> # define E0_STEP_PIN PD6 <nl> # define E0_DIR_PIN PD3 <nl> <nl> - <nl> / / Motor current PWM pins <nl> # define MOTOR_CURRENT_PWM_XY_PIN PA6 <nl> # define MOTOR_CURRENT_PWM_Z_PIN PA7 <nl> <nl> # define SERVO0_PIN PA8 / / Enable BLTOUCH support on IO0 ( WIFI connector ) <nl> <nl> # define MT_DET_1_PIN PA4 <nl> - # define MT_DET_PIN_INVERTING false <nl> + # define MT_DET_PIN_INVERTING false <nl> <nl> # define WIFI_IO0_PIN PC13 <nl> <nl> <nl> # define FSMC_CS_PIN PD7 / / NE4 <nl> # define FSMC_RS_PIN PD11 / / A0 <nl> <nl> - # define LCD_USE_DMA_FSMC / / Use DMA transfers to send data to the TFT <nl> + # define LCD_USE_DMA_FSMC / / Use DMA transfers to send data to the TFT <nl> # define FSMC_DMA_DEV DMA2 <nl> - # define FSMC_DMA_CHANNEL DMA_CH5 <nl> + # define FSMC_DMA_CHANNEL DMA_CH5 <nl> <nl> # define LCD_RESET_PIN PC6 / / FSMC_RST <nl> # define LCD_BACKLIGHT_PIN PD13 <nl> <nl> # define TOUCH_MOSI_PIN PB15 / / SPI2_MOSI <nl> # endif <nl> <nl> - # elif ENABLED ( TFT_320x240 ) / / TFT32 / 28 <nl> + # elif ENABLED ( TFT_320x240 ) / / TFT32 / 28 <nl> <nl> # define TFT_RESET_PIN PC6 <nl> # define TFT_BACKLIGHT_PIN PD13 <nl> <nl> # define ILI9341_COLOR_RGB <nl> # endif <nl> <nl> - # define HAS_SPI_FLASH 1 <nl> + # define HAS_SPI_FLASH 1 <nl> # define SPI_FLASH_SIZE 0x1000000 / / 16MB <nl> # if HAS_SPI_FLASH <nl> # define W25QXX_CS_PIN PB12 / / Flash chip - select <nl> mmm a / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN_NANO . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN_NANO . h <nl> <nl> # define FSMC_DMA_CHANNEL DMA_CH5 <nl> <nl> # define TOUCH_BUTTONS_HW_SPI <nl> - # define TOUCH_BUTTONS_HW_SPI_DEVICE 2 <nl> + # define TOUCH_BUTTONS_HW_SPI_DEVICE 2 <nl> # endif <nl> <nl> / / LVGL Configs <nl> <nl> # define DOGLCD_SCK - 1 <nl> <nl> # ifndef GRAPHICAL_TFT_UPSCALE <nl> - # define GRAPHICAL_TFT_UPSCALE 3 <nl> + # define GRAPHICAL_TFT_UPSCALE 3 <nl> # endif <nl> # ifndef TFT_WIDTH <nl> # define TFT_WIDTH 480 <nl> mmm a / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN_NANO_V2 . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN_NANO_V2 . h <nl> <nl> # endif <nl> <nl> # ifndef GRAPHICAL_TFT_UPSCALE <nl> - # define GRAPHICAL_TFT_UPSCALE 3 <nl> + # define GRAPHICAL_TFT_UPSCALE 3 <nl> # endif <nl> # ifndef TFT_PIXEL_OFFSET_Y <nl> # define TFT_PIXEL_OFFSET_Y 32 <nl> mmm a / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN_PRO . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_MKS_ROBIN_PRO . h <nl> <nl> / / <nl> / / Note : MKS Robin board is using SPI2 interface . <nl> / / <nl> - / / # define SPI_MODULE 2 <nl> + / / # define SPI_MODULE 2 <nl> # define ENABLE_SPI2 <nl> <nl> / / <nl> mmm a / Marlin / src / pins / stm32f1 / pins_STM32F1R . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_STM32F1R . h <nl> <nl> # define DEFAULT_MACHINE_NAME " STM32F103RET6 " <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / <nl> / / Limit Switches <nl> <nl> # if HAS_SPI_LCD <nl> <nl> # if ENABLED ( REPRAPWORLD_GRAPHICAL_LCD ) <nl> - # define LCD_PINS_RS 49 / / CS chip select / SS chip slave select <nl> - # define LCD_PINS_ENABLE 51 / / SID ( MOSI ) <nl> - # define LCD_PINS_D4 52 / / SCK ( CLK ) clock <nl> + # define LCD_PINS_RS 49 / / CS chip select / SS chip slave select <nl> + # define LCD_PINS_ENABLE 51 / / SID ( MOSI ) <nl> + # define LCD_PINS_D4 52 / / SCK ( CLK ) clock <nl> # elif BOTH ( NEWPANEL , PANEL_ONE ) <nl> # define LCD_PINS_RS PB8 <nl> # define LCD_PINS_ENABLE PD2 <nl> <nl> # define LCD_PINS_D6 PB14 <nl> # define LCD_PINS_D7 PB15 <nl> # if DISABLED ( NEWPANEL ) <nl> - # define BEEPER_PIN 33 <nl> + # define BEEPER_PIN 33 <nl> / / Buttons attached to a shift register <nl> / / Not wired yet <nl> - / / # define SHIFT_CLK 38 <nl> - / / # define SHIFT_LD 42 <nl> - / / # define SHIFT_OUT 40 <nl> - / / # define SHIFT_EN 17 <nl> + / / # define SHIFT_CLK 38 <nl> + / / # define SHIFT_LD 42 <nl> + / / # define SHIFT_OUT 40 <nl> + / / # define SHIFT_EN 17 <nl> # endif <nl> # endif <nl> <nl> <nl> <nl> # if ENABLED ( REPRAP_DISCOUNT_SMART_CONTROLLER ) <nl> <nl> - # define BEEPER_PIN 37 <nl> + # define BEEPER_PIN 37 <nl> <nl> - # define BTN_EN1 31 <nl> - # define BTN_EN2 33 <nl> - # define BTN_ENC 35 <nl> + # define BTN_EN1 31 <nl> + # define BTN_EN2 33 <nl> + # define BTN_ENC 35 <nl> <nl> - # define SD_DETECT_PIN 49 <nl> - # define KILL_PIN 41 <nl> + # define SD_DETECT_PIN 49 <nl> + # define KILL_PIN 41 <nl> <nl> # if ENABLED ( BQ_LCD_SMART_CONTROLLER ) <nl> - # define LCD_BACKLIGHT_PIN 39 <nl> + # define LCD_BACKLIGHT_PIN 39 <nl> # endif <nl> <nl> # elif ENABLED ( REPRAPWORLD_GRAPHICAL_LCD ) <nl> <nl> - # define BTN_EN1 64 <nl> - # define BTN_EN2 59 <nl> - # define BTN_ENC 63 <nl> - # define SD_DETECT_PIN 42 <nl> + # define BTN_EN1 64 <nl> + # define BTN_EN2 59 <nl> + # define BTN_ENC 63 <nl> + # define SD_DETECT_PIN 42 <nl> <nl> # elif ENABLED ( LCD_I2C_PANELOLU2 ) <nl> <nl> - # define BTN_EN1 47 <nl> - # define BTN_EN2 43 <nl> - # define BTN_ENC 32 <nl> - # define LCD_SDSS 53 <nl> + # define BTN_EN1 47 <nl> + # define BTN_EN2 43 <nl> + # define BTN_ENC 32 <nl> + # define LCD_SDSS 53 <nl> # define SD_DETECT_PIN - 1 <nl> - # define KILL_PIN 41 <nl> + # define KILL_PIN 41 <nl> <nl> # elif ENABLED ( LCD_I2C_VIKI ) <nl> <nl> - # define BTN_EN1 22 / / https : / / files . panucatt . com / datasheets / viki_wiring_diagram . pdf explains 40 / 42 . <nl> - # define BTN_EN2 7 / / 22 / 7 are unused on RAMPS_14 . 22 is unused and 7 the SERVO0_PIN on RAMPS_13 . <nl> + # define BTN_EN1 22 / / https : / / files . panucatt . com / datasheets / viki_wiring_diagram . pdf explains 40 / 42 . <nl> + # define BTN_EN2 7 / / 22 / 7 are unused on RAMPS_14 . 22 is unused and 7 the SERVO0_PIN on RAMPS_13 . <nl> <nl> # define BTN_ENC - 1 <nl> - # define LCD_SDSS 53 <nl> - # define SD_DETECT_PIN 49 <nl> + # define LCD_SDSS 53 <nl> + # define SD_DETECT_PIN 49 <nl> <nl> # elif ANY ( VIKI2 , miniVIKI ) <nl> <nl> - # define BEEPER_PIN 33 <nl> + # define BEEPER_PIN 33 <nl> <nl> / / Pins for DOGM SPI LCD Support <nl> - # define DOGLCD_A0 44 <nl> - # define DOGLCD_CS 45 <nl> + # define DOGLCD_A0 44 <nl> + # define DOGLCD_CS 45 <nl> # define LCD_SCREEN_ROT_180 <nl> <nl> - # define BTN_EN1 22 <nl> - # define BTN_EN2 7 <nl> - # define BTN_ENC 39 <nl> + # define BTN_EN1 22 <nl> + # define BTN_EN2 7 <nl> + # define BTN_ENC 39 <nl> <nl> - # define SDSS 53 <nl> + # define SDSS 53 <nl> # define SD_DETECT_PIN - 1 / / Pin 49 for display sd interface , 72 for easy adapter board <nl> <nl> - # define KILL_PIN 31 <nl> + # define KILL_PIN 31 <nl> <nl> - # define STAT_LED_RED_PIN 32 <nl> - # define STAT_LED_BLUE_PIN 35 <nl> + # define STAT_LED_RED_PIN 32 <nl> + # define STAT_LED_BLUE_PIN 35 <nl> <nl> # elif ENABLED ( ELB_FULL_GRAPHIC_CONTROLLER ) <nl> - # define BTN_EN1 35 <nl> - # define BTN_EN2 37 <nl> - # define BTN_ENC 31 <nl> - # define SD_DETECT_PIN 49 <nl> - # define LCD_SDSS 53 <nl> - # define KILL_PIN 41 <nl> - # define BEEPER_PIN 23 <nl> - # define DOGLCD_CS 29 <nl> - # define DOGLCD_A0 27 <nl> - # define LCD_BACKLIGHT_PIN 33 <nl> + # define BTN_EN1 35 <nl> + # define BTN_EN2 37 <nl> + # define BTN_ENC 31 <nl> + # define SD_DETECT_PIN 49 <nl> + # define LCD_SDSS 53 <nl> + # define KILL_PIN 41 <nl> + # define BEEPER_PIN 23 <nl> + # define DOGLCD_CS 29 <nl> + # define DOGLCD_A0 27 <nl> + # define LCD_BACKLIGHT_PIN 33 <nl> <nl> # elif ENABLED ( MINIPANEL ) <nl> <nl> - # define BEEPER_PIN 42 <nl> + # define BEEPER_PIN 42 <nl> / / Pins for DOGM SPI LCD Support <nl> - # define DOGLCD_A0 44 <nl> - # define DOGLCD_CS 66 <nl> - # define LCD_BACKLIGHT_PIN 65 / / backlight LED on A11 / D65 <nl> - # define SDSS 53 <nl> + # define DOGLCD_A0 44 <nl> + # define DOGLCD_CS 66 <nl> + # define LCD_BACKLIGHT_PIN 65 / / backlight LED on A11 / D65 <nl> + # define SDSS 53 <nl> <nl> - # define KILL_PIN 64 <nl> + # define KILL_PIN 64 <nl> / / GLCD features <nl> / / Uncomment screen orientation <nl> / / # define LCD_SCREEN_ROT_90 <nl> / / # define LCD_SCREEN_ROT_180 <nl> / / # define LCD_SCREEN_ROT_270 <nl> / / The encoder and click button <nl> - # define BTN_EN1 40 <nl> - # define BTN_EN2 63 <nl> - # define BTN_ENC 59 <nl> + # define BTN_EN1 40 <nl> + # define BTN_EN2 63 <nl> + # define BTN_ENC 59 <nl> / / not connected to a pin <nl> - # define SD_DETECT_PIN 49 <nl> + # define SD_DETECT_PIN 49 <nl> <nl> # else <nl> <nl> / / Beeper on AUX - 4 <nl> - # define BEEPER_PIN 33 <nl> + # define BEEPER_PIN 33 <nl> <nl> / / Buttons directly attached to AUX - 2 <nl> # if ENABLED ( REPRAPWORLD_KEYPAD ) <nl> - # define BTN_EN1 64 <nl> - # define BTN_EN2 59 <nl> - # define BTN_ENC 63 <nl> - # define SHIFT_OUT 40 <nl> - # define SHIFT_CLK 44 <nl> - # define SHIFT_LD 42 <nl> + # define BTN_EN1 64 <nl> + # define BTN_EN2 59 <nl> + # define BTN_ENC 63 <nl> + # define SHIFT_OUT 40 <nl> + # define SHIFT_CLK 44 <nl> + # define SHIFT_LD 42 <nl> # elif ENABLED ( PANEL_ONE ) <nl> - # define BTN_EN1 59 / / AUX2 PIN 3 <nl> - # define BTN_EN2 63 / / AUX2 PIN 4 <nl> - # define BTN_ENC 49 / / AUX3 PIN 7 <nl> + # define BTN_EN1 59 / / AUX2 PIN 3 <nl> + # define BTN_EN2 63 / / AUX2 PIN 4 <nl> + # define BTN_ENC 49 / / AUX3 PIN 7 <nl> # else <nl> - # define BTN_EN1 37 <nl> - # define BTN_EN2 35 <nl> - # define BTN_ENC 31 <nl> + # define BTN_EN1 37 <nl> + # define BTN_EN2 35 <nl> + # define BTN_ENC 31 <nl> # endif <nl> <nl> # if ENABLED ( G3D_PANEL ) <nl> - # define SD_DETECT_PIN 49 <nl> - # define KILL_PIN 41 <nl> + # define SD_DETECT_PIN 49 <nl> + # define KILL_PIN 41 <nl> # else <nl> / / # define SD_DETECT_PIN - 1 / / Ramps doesn ' t use this <nl> # endif <nl> mmm a / Marlin / src / pins / stm32f1 / pins_STM3R_MINI . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_STM3R_MINI . h <nl> <nl> # define I2C_EEPROM <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / <nl> / / Limit Switches <nl> <nl> # if HAS_SPI_LCD <nl> <nl> # if ENABLED ( REPRAPWORLD_GRAPHICAL_LCD ) <nl> - # define LCD_PINS_RS 49 / / CS chip select / SS chip slave select <nl> - # define LCD_PINS_ENABLE 51 / / SID ( MOSI ) <nl> - # define LCD_PINS_D4 52 / / SCK ( CLK ) clock <nl> + # define LCD_PINS_RS 49 / / CS chip select / SS chip slave select <nl> + # define LCD_PINS_ENABLE 51 / / SID ( MOSI ) <nl> + # define LCD_PINS_D4 52 / / SCK ( CLK ) clock <nl> # elif BOTH ( NEWPANEL , PANEL_ONE ) <nl> # define LCD_PINS_RS PB8 <nl> # define LCD_PINS_ENABLE PD2 <nl> <nl> # define LCD_PINS_D6 PB14 <nl> # define LCD_PINS_D7 PB15 <nl> # if DISABLED ( NEWPANEL ) <nl> - # define BEEPER_PIN 33 <nl> + # define BEEPER_PIN 33 <nl> / / Buttons attached to a shift register <nl> / / Not wired yet <nl> - / / # define SHIFT_CLK 38 <nl> - / / # define SHIFT_LD 42 <nl> - / / # define SHIFT_OUT 40 <nl> - / / # define SHIFT_EN 17 <nl> + / / # define SHIFT_CLK 38 <nl> + / / # define SHIFT_LD 42 <nl> + / / # define SHIFT_OUT 40 <nl> + / / # define SHIFT_EN 17 <nl> # endif <nl> # endif <nl> <nl> <nl> <nl> # if ENABLED ( REPRAP_DISCOUNT_SMART_CONTROLLER ) <nl> <nl> - # define BEEPER_PIN 37 <nl> + # define BEEPER_PIN 37 <nl> <nl> - # define BTN_EN1 31 <nl> - # define BTN_EN2 33 <nl> - # define BTN_ENC 35 <nl> + # define BTN_EN1 31 <nl> + # define BTN_EN2 33 <nl> + # define BTN_ENC 35 <nl> <nl> - # define SD_DETECT_PIN 49 <nl> - # define KILL_PIN 41 <nl> + # define SD_DETECT_PIN 49 <nl> + # define KILL_PIN 41 <nl> <nl> # if ENABLED ( BQ_LCD_SMART_CONTROLLER ) <nl> - # define LCD_BACKLIGHT_PIN 39 <nl> + # define LCD_BACKLIGHT_PIN 39 <nl> # endif <nl> <nl> # elif ENABLED ( REPRAPWORLD_GRAPHICAL_LCD ) <nl> <nl> - # define BTN_EN1 64 <nl> - # define BTN_EN2 59 <nl> - # define BTN_ENC 63 <nl> - # define SD_DETECT_PIN 42 <nl> + # define BTN_EN1 64 <nl> + # define BTN_EN2 59 <nl> + # define BTN_ENC 63 <nl> + # define SD_DETECT_PIN 42 <nl> <nl> # elif ENABLED ( LCD_I2C_PANELOLU2 ) <nl> <nl> - # define BTN_EN1 47 <nl> - # define BTN_EN2 43 <nl> - # define BTN_ENC 32 <nl> - # define LCD_SDSS 53 <nl> + # define BTN_EN1 47 <nl> + # define BTN_EN2 43 <nl> + # define BTN_ENC 32 <nl> + # define LCD_SDSS 53 <nl> # define SD_DETECT_PIN - 1 <nl> - # define KILL_PIN 41 <nl> + # define KILL_PIN 41 <nl> <nl> # elif ENABLED ( LCD_I2C_VIKI ) <nl> <nl> - # define BTN_EN1 22 / / https : / / files . panucatt . com / datasheets / viki_wiring_diagram . pdf explains 40 / 42 . <nl> - # define BTN_EN2 7 / / 22 / 7 are unused on RAMPS_14 . 22 is unused and 7 the SERVO0_PIN on RAMPS_13 . <nl> + # define BTN_EN1 22 / / https : / / files . panucatt . com / datasheets / viki_wiring_diagram . pdf explains 40 / 42 . <nl> + # define BTN_EN2 7 / / 22 / 7 are unused on RAMPS_14 . 22 is unused and 7 the SERVO0_PIN on RAMPS_13 . <nl> <nl> # define BTN_ENC - 1 <nl> - # define LCD_SDSS 53 <nl> - # define SD_DETECT_PIN 49 <nl> + # define LCD_SDSS 53 <nl> + # define SD_DETECT_PIN 49 <nl> <nl> # elif ANY ( VIKI2 , miniVIKI ) <nl> <nl> - # define BEEPER_PIN 33 <nl> + # define BEEPER_PIN 33 <nl> <nl> / / Pins for DOGM SPI LCD Support <nl> - # define DOGLCD_A0 44 <nl> - # define DOGLCD_CS 45 <nl> + # define DOGLCD_A0 44 <nl> + # define DOGLCD_CS 45 <nl> # define LCD_SCREEN_ROT_180 <nl> <nl> - # define BTN_EN1 22 <nl> - # define BTN_EN2 7 <nl> - # define BTN_ENC 39 <nl> + # define BTN_EN1 22 <nl> + # define BTN_EN2 7 <nl> + # define BTN_ENC 39 <nl> <nl> - # define SDSS 53 <nl> + # define SDSS 53 <nl> # define SD_DETECT_PIN - 1 / / Pin 49 for display sd interface , 72 for easy adapter board <nl> <nl> - # define KILL_PIN 31 <nl> + # define KILL_PIN 31 <nl> <nl> - # define STAT_LED_RED_PIN 32 <nl> - # define STAT_LED_BLUE_PIN 35 <nl> + # define STAT_LED_RED_PIN 32 <nl> + # define STAT_LED_BLUE_PIN 35 <nl> <nl> # elif ENABLED ( ELB_FULL_GRAPHIC_CONTROLLER ) <nl> <nl> - # define BTN_EN1 35 <nl> - # define BTN_EN2 37 <nl> - # define BTN_ENC 31 <nl> - # define SD_DETECT_PIN 49 <nl> - # define LCD_SDSS 53 <nl> - # define KILL_PIN 41 <nl> - # define BEEPER_PIN 23 <nl> - # define DOGLCD_CS 29 <nl> - # define DOGLCD_A0 27 <nl> - # define LCD_BACKLIGHT_PIN 33 <nl> + # define BTN_EN1 35 <nl> + # define BTN_EN2 37 <nl> + # define BTN_ENC 31 <nl> + # define SD_DETECT_PIN 49 <nl> + # define LCD_SDSS 53 <nl> + # define KILL_PIN 41 <nl> + # define BEEPER_PIN 23 <nl> + # define DOGLCD_CS 29 <nl> + # define DOGLCD_A0 27 <nl> + # define LCD_BACKLIGHT_PIN 33 <nl> <nl> # elif ENABLED ( MINIPANEL ) <nl> <nl> - # define BEEPER_PIN 42 <nl> + # define BEEPER_PIN 42 <nl> / / Pins for DOGM SPI LCD Support <nl> - # define DOGLCD_A0 44 <nl> - # define DOGLCD_CS 66 <nl> - # define LCD_BACKLIGHT_PIN 65 / / backlight LED on A11 / D65 <nl> - # define SDSS 53 <nl> + # define DOGLCD_A0 44 <nl> + # define DOGLCD_CS 66 <nl> + # define LCD_BACKLIGHT_PIN 65 / / backlight LED on A11 / D65 <nl> + # define SDSS 53 <nl> <nl> - # define KILL_PIN 64 <nl> + # define KILL_PIN 64 <nl> / / GLCD features <nl> / / Uncomment screen orientation <nl> / / # define LCD_SCREEN_ROT_90 <nl> / / # define LCD_SCREEN_ROT_180 <nl> / / # define LCD_SCREEN_ROT_270 <nl> / / The encoder and click button <nl> - # define BTN_EN1 40 <nl> - # define BTN_EN2 63 <nl> - # define BTN_ENC 59 <nl> + # define BTN_EN1 40 <nl> + # define BTN_EN2 63 <nl> + # define BTN_ENC 59 <nl> / / not connected to a pin <nl> - # define SD_DETECT_PIN 49 <nl> + # define SD_DETECT_PIN 49 <nl> <nl> # else <nl> <nl> / / Beeper on AUX - 4 <nl> - # define BEEPER_PIN 33 <nl> + # define BEEPER_PIN 33 <nl> <nl> / / Buttons directly attached to AUX - 2 <nl> # if ENABLED ( REPRAPWORLD_KEYPAD ) <nl> - # define BTN_EN1 64 <nl> - # define BTN_EN2 59 <nl> - # define BTN_ENC 63 <nl> - # define SHIFT_OUT 40 <nl> - # define SHIFT_CLK 44 <nl> - # define SHIFT_LD 42 <nl> + # define BTN_EN1 64 <nl> + # define BTN_EN2 59 <nl> + # define BTN_ENC 63 <nl> + # define SHIFT_OUT 40 <nl> + # define SHIFT_CLK 44 <nl> + # define SHIFT_LD 42 <nl> # elif ENABLED ( PANEL_ONE ) <nl> - # define BTN_EN1 59 / / AUX2 PIN 3 <nl> - # define BTN_EN2 63 / / AUX2 PIN 4 <nl> - # define BTN_ENC 49 / / AUX3 PIN 7 <nl> + # define BTN_EN1 59 / / AUX2 PIN 3 <nl> + # define BTN_EN2 63 / / AUX2 PIN 4 <nl> + # define BTN_ENC 49 / / AUX3 PIN 7 <nl> # else <nl> - # define BTN_EN1 37 <nl> - # define BTN_EN2 35 <nl> - # define BTN_ENC 31 <nl> + # define BTN_EN1 37 <nl> + # define BTN_EN2 35 <nl> + # define BTN_ENC 31 <nl> # endif <nl> <nl> # if ENABLED ( G3D_PANEL ) <nl> - # define SD_DETECT_PIN 49 <nl> - # define KILL_PIN 41 <nl> + # define SD_DETECT_PIN 49 <nl> + # define KILL_PIN 41 <nl> # else <nl> / / # define SD_DETECT_PIN - 1 / / Ramps doesn ' t use this <nl> # endif <nl> mmm a / Marlin / src / pins / stm32f1 / pins_TRIGORILLA_PRO . h <nl> ppp b / Marlin / src / pins / stm32f1 / pins_TRIGORILLA_PRO . h <nl> <nl> / / <nl> # define HEATER_0_PIN PG12 / / HEATER1 <nl> # define HEATER_BED_PIN PG11 / / HOT BED <nl> - # define HEATER_BED_INVERTING true <nl> + # define HEATER_BED_INVERTING true <nl> <nl> / / <nl> / / Fans <nl> mmm a / Marlin / src / pins / stm32f4 / pins_ARMED . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_ARMED . h <nl> <nl> # define DEFAULT_MACHINE_NAME BOARD_INFO_NAME <nl> <nl> # define I2C_EEPROM <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> <nl> / / <nl> / / Limit Switches <nl> <nl> # define Z2_SERIAL_RX_PIN EXT4_PIN <nl> # define Z2_SERIAL_TX_PIN EXT4_PIN <nl> <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> mmm a / Marlin / src / pins / stm32f4 / pins_BEAST . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_BEAST . h <nl> <nl> # define I2C_EEPROM <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / <nl> / / Steppers <nl> <nl> # if HAS_SPI_LCD <nl> <nl> # if ENABLED ( REPRAPWORLD_GRAPHICAL_LCD ) <nl> - # define LCD_PINS_RS 49 / / CS chip select / SS chip slave select <nl> - # define LCD_PINS_ENABLE 51 / / SID ( MOSI ) <nl> - # define LCD_PINS_D4 52 / / SCK ( CLK ) clock <nl> + # define LCD_PINS_RS 49 / / CS chip select / SS chip slave select <nl> + # define LCD_PINS_ENABLE 51 / / SID ( MOSI ) <nl> + # define LCD_PINS_D4 52 / / SCK ( CLK ) clock <nl> # elif BOTH ( NEWPANEL , PANEL_ONE ) <nl> # define LCD_PINS_RS PB8 <nl> # define LCD_PINS_ENABLE PD2 <nl> <nl> # define LCD_PINS_D6 PB14 <nl> # define LCD_PINS_D7 PB15 <nl> # if DISABLED ( NEWPANEL ) <nl> - # define BEEPER_PIN 33 <nl> + # define BEEPER_PIN 33 <nl> / / Buttons attached to a shift register <nl> / / Not wired yet <nl> - / / # define SHIFT_CLK 38 <nl> - / / # define SHIFT_LD 42 <nl> - / / # define SHIFT_OUT 40 <nl> - / / # define SHIFT_EN 17 <nl> + / / # define SHIFT_CLK 38 <nl> + / / # define SHIFT_LD 42 <nl> + / / # define SHIFT_OUT 40 <nl> + / / # define SHIFT_EN 17 <nl> # endif <nl> # endif <nl> <nl> <nl> <nl> # if ENABLED ( REPRAP_DISCOUNT_SMART_CONTROLLER ) <nl> <nl> - # define BEEPER_PIN 37 <nl> + # define BEEPER_PIN 37 <nl> <nl> - # define BTN_EN1 31 <nl> - # define BTN_EN2 33 <nl> - # define BTN_ENC 35 <nl> + # define BTN_EN1 31 <nl> + # define BTN_EN2 33 <nl> + # define BTN_ENC 35 <nl> <nl> - # define SD_DETECT_PIN 49 <nl> - # define KILL_PIN 41 <nl> + # define SD_DETECT_PIN 49 <nl> + # define KILL_PIN 41 <nl> <nl> # if ENABLED ( BQ_LCD_SMART_CONTROLLER ) <nl> - # define LCD_BACKLIGHT_PIN 39 <nl> + # define LCD_BACKLIGHT_PIN 39 <nl> # endif <nl> <nl> # elif ENABLED ( REPRAPWORLD_GRAPHICAL_LCD ) <nl> <nl> - # define BTN_EN1 64 <nl> - # define BTN_EN2 59 <nl> - # define BTN_ENC 63 <nl> - # define SD_DETECT_PIN 42 <nl> + # define BTN_EN1 64 <nl> + # define BTN_EN2 59 <nl> + # define BTN_ENC 63 <nl> + # define SD_DETECT_PIN 42 <nl> <nl> # elif ENABLED ( LCD_I2C_PANELOLU2 ) <nl> <nl> - # define BTN_EN1 47 <nl> - # define BTN_EN2 43 <nl> - # define BTN_ENC 32 <nl> - # define LCD_SDSS 53 <nl> + # define BTN_EN1 47 <nl> + # define BTN_EN2 43 <nl> + # define BTN_ENC 32 <nl> + # define LCD_SDSS 53 <nl> # define SD_DETECT_PIN - 1 <nl> - # define KILL_PIN 41 <nl> + # define KILL_PIN 41 <nl> <nl> # elif ENABLED ( LCD_I2C_VIKI ) <nl> <nl> - # define BTN_EN1 22 / / https : / / files . panucatt . com / datasheets / viki_wiring_diagram . pdf explains 40 / 42 . <nl> - # define BTN_EN2 7 / / 22 / 7 are unused on RAMPS_14 . 22 is unused and 7 the SERVO0_PIN on RAMPS_13 . <nl> + # define BTN_EN1 22 / / https : / / files . panucatt . com / datasheets / viki_wiring_diagram . pdf explains 40 / 42 . <nl> + # define BTN_EN2 7 / / 22 / 7 are unused on RAMPS_14 . 22 is unused and 7 the SERVO0_PIN on RAMPS_13 . <nl> <nl> # define BTN_ENC - 1 <nl> - # define LCD_SDSS 53 <nl> - # define SD_DETECT_PIN 49 <nl> + # define LCD_SDSS 53 <nl> + # define SD_DETECT_PIN 49 <nl> <nl> # elif ANY ( VIKI2 , miniVIKI ) <nl> <nl> - # define BEEPER_PIN 33 <nl> + # define BEEPER_PIN 33 <nl> <nl> / / Pins for DOGM SPI LCD Support <nl> - # define DOGLCD_A0 44 <nl> - # define DOGLCD_CS 45 <nl> + # define DOGLCD_A0 44 <nl> + # define DOGLCD_CS 45 <nl> # define LCD_SCREEN_ROT_180 <nl> <nl> - # define BTN_EN1 22 <nl> - # define BTN_EN2 7 <nl> - # define BTN_ENC 39 <nl> + # define BTN_EN1 22 <nl> + # define BTN_EN2 7 <nl> + # define BTN_ENC 39 <nl> <nl> - # define SDSS 53 <nl> + # define SDSS 53 <nl> # define SD_DETECT_PIN - 1 / / Pin 49 for display sd interface , 72 for easy adapter board <nl> <nl> - # define KILL_PIN 31 <nl> + # define KILL_PIN 31 <nl> <nl> - # define STAT_LED_RED_PIN 32 <nl> - # define STAT_LED_BLUE_PIN 35 <nl> + # define STAT_LED_RED_PIN 32 <nl> + # define STAT_LED_BLUE_PIN 35 <nl> <nl> # elif ENABLED ( ELB_FULL_GRAPHIC_CONTROLLER ) <nl> <nl> - # define BTN_EN1 35 <nl> - # define BTN_EN2 37 <nl> - # define BTN_ENC 31 <nl> - # define SD_DETECT_PIN 49 <nl> - # define LCD_SDSS 53 <nl> - # define KILL_PIN 41 <nl> - # define BEEPER_PIN 23 <nl> - # define DOGLCD_CS 29 <nl> - # define DOGLCD_A0 27 <nl> - # define LCD_BACKLIGHT_PIN 33 <nl> + # define BTN_EN1 35 <nl> + # define BTN_EN2 37 <nl> + # define BTN_ENC 31 <nl> + # define SD_DETECT_PIN 49 <nl> + # define LCD_SDSS 53 <nl> + # define KILL_PIN 41 <nl> + # define BEEPER_PIN 23 <nl> + # define DOGLCD_CS 29 <nl> + # define DOGLCD_A0 27 <nl> + # define LCD_BACKLIGHT_PIN 33 <nl> <nl> # elif ENABLED ( MINIPANEL ) <nl> <nl> - # define BEEPER_PIN 42 <nl> + # define BEEPER_PIN 42 <nl> / / Pins for DOGM SPI LCD Support <nl> - # define DOGLCD_A0 44 <nl> - # define DOGLCD_CS 66 <nl> - # define LCD_BACKLIGHT_PIN 65 / / backlight LED on A11 / D65 <nl> - # define SDSS 53 <nl> + # define DOGLCD_A0 44 <nl> + # define DOGLCD_CS 66 <nl> + # define LCD_BACKLIGHT_PIN 65 / / backlight LED on A11 / D65 <nl> + # define SDSS 53 <nl> <nl> - # define KILL_PIN 64 <nl> + # define KILL_PIN 64 <nl> / / GLCD features <nl> / / Uncomment screen orientation <nl> / / # define LCD_SCREEN_ROT_90 <nl> / / # define LCD_SCREEN_ROT_180 <nl> / / # define LCD_SCREEN_ROT_270 <nl> / / The encoder and click button <nl> - # define BTN_EN1 40 <nl> - # define BTN_EN2 63 <nl> - # define BTN_ENC 59 <nl> + # define BTN_EN1 40 <nl> + # define BTN_EN2 63 <nl> + # define BTN_ENC 59 <nl> / / not connected to a pin <nl> - # define SD_DETECT_PIN 49 <nl> + # define SD_DETECT_PIN 49 <nl> <nl> # else <nl> <nl> / / Beeper on AUX - 4 <nl> - # define BEEPER_PIN 33 <nl> + # define BEEPER_PIN 33 <nl> <nl> / / Buttons directly attached to AUX - 2 <nl> # if ENABLED ( REPRAPWORLD_KEYPAD ) <nl> - # define BTN_EN1 64 <nl> - # define BTN_EN2 59 <nl> - # define BTN_ENC 63 <nl> - # define SHIFT_OUT 40 <nl> - # define SHIFT_CLK 44 <nl> - # define SHIFT_LD 42 <nl> + # define BTN_EN1 64 <nl> + # define BTN_EN2 59 <nl> + # define BTN_ENC 63 <nl> + # define SHIFT_OUT 40 <nl> + # define SHIFT_CLK 44 <nl> + # define SHIFT_LD 42 <nl> # elif ENABLED ( PANEL_ONE ) <nl> - # define BTN_EN1 59 / / AUX2 PIN 3 <nl> - # define BTN_EN2 63 / / AUX2 PIN 4 <nl> - # define BTN_ENC 49 / / AUX3 PIN 7 <nl> + # define BTN_EN1 59 / / AUX2 PIN 3 <nl> + # define BTN_EN2 63 / / AUX2 PIN 4 <nl> + # define BTN_ENC 49 / / AUX3 PIN 7 <nl> # else <nl> - # define BTN_EN1 37 <nl> - # define BTN_EN2 35 <nl> - # define BTN_ENC 31 <nl> + # define BTN_EN1 37 <nl> + # define BTN_EN2 35 <nl> + # define BTN_ENC 31 <nl> # endif <nl> <nl> # if ENABLED ( G3D_PANEL ) <nl> - # define SD_DETECT_PIN 49 <nl> - # define KILL_PIN 41 <nl> + # define SD_DETECT_PIN 49 <nl> + # define KILL_PIN 41 <nl> # else <nl> / / # define SD_DETECT_PIN - 1 / / Ramps doesn ' t use this <nl> # endif <nl> mmm a / Marlin / src / pins / stm32f4 / pins_BLACK_STM32F407VE . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_BLACK_STM32F407VE . h <nl> <nl> <nl> / / # define I2C_EEPROM <nl> # define SRAM_EEPROM_EMULATION <nl> - # define MARLIN_EEPROM_SIZE 0x2000 / / 8KB <nl> + # define MARLIN_EEPROM_SIZE 0x2000 / / 8KB <nl> <nl> / / <nl> / / Servos <nl> mmm a / Marlin / src / pins / stm32f4 / pins_BTT_BTT002_V1_0 . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_BTT_BTT002_V1_0 . h <nl> <nl> # endif <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / <nl> / / Limit Switches <nl> <nl> # define E0_SERIAL_RX_PIN PD7 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / stm32f4 / pins_BTT_GTR_V1_0 . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_BTT_GTR_V1_0 . h <nl> <nl> <nl> / / Onboard I2C EEPROM <nl> # define I2C_EEPROM <nl> - # define MARLIN_EEPROM_SIZE 0x2000 / / 8KB ( 24C64 . . . 64Kb = 8KB ) <nl> + # define MARLIN_EEPROM_SIZE 0x2000 / / 8KB ( 24C64 . . . 64Kb = 8KB ) <nl> <nl> # define TP / / Enable to define servo and probe pins <nl> <nl> <nl> # define E7_SERIAL_RX_PIN PH14 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / stm32f4 / pins_BTT_SKR_PRO_common . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_BTT_SKR_PRO_common . h <nl> <nl> # define E2_SERIAL_RX_PIN PD6 <nl> <nl> / / Reduce baud rate to improve software serial reliability <nl> - # define TMC_BAUD_RATE 19200 <nl> + # define TMC_BAUD_RATE 19200 <nl> # endif <nl> <nl> / / <nl> <nl> *  ̄  ̄ <nl> * W1 <nl> * / <nl> - # define ESP_WIFI_MODULE_COM 6 / / Must also set either SERIAL_PORT or SERIAL_PORT_2 to this <nl> + # define ESP_WIFI_MODULE_COM 6 / / Must also set either SERIAL_PORT or SERIAL_PORT_2 to this <nl> # define ESP_WIFI_MODULE_BAUDRATE BAUDRATE / / Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 <nl> # define ESP_WIFI_MODULE_RESET_PIN PG0 <nl> # define ESP_WIFI_MODULE_ENABLE_PIN PG1 <nl> mmm a / Marlin / src / pins / stm32f4 / pins_FLYF407ZG . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_FLYF407ZG . h <nl> <nl> / / the 128kB sector allocated for EEPROM emulation . <nl> # define FLASH_EEPROM_LEVELING <nl> # elif ENABLED ( I2C_EEPROM ) <nl> - # define MARLIN_EEPROM_SIZE 0x2000 / / 8KB <nl> + # define MARLIN_EEPROM_SIZE 0x2000 / / 8KB <nl> # endif <nl> <nl> # ifndef MARLIN_EEPROM_SIZE <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / stm32f4 / pins_FYSETC_S6 . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_FYSETC_S6 . h <nl> <nl> # endif <nl> <nl> / / Change the priority to 3 . Priority 2 is for software serial . <nl> - / / # define TEMP_TIMER_IRQ_PRIO 3 <nl> + / / # define TEMP_TIMER_IRQ_PRIO 3 <nl> <nl> / / <nl> / / EEPROM Emulation <nl> <nl> / / 128 kB sector allocated for EEPROM emulation . <nl> # define FLASH_EEPROM_LEVELING <nl> # elif ENABLED ( I2C_EEPROM ) <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / stm32f4 / pins_GENERIC_STM32F4 . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_GENERIC_STM32F4 . h <nl> <nl> / / # define I2C_EEPROM <nl> <nl> # ifndef MARLIN_EEPROM_SIZE <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # endif <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / <nl> / / Limit Switches <nl> mmm a / Marlin / src / pins / stm32f4 / pins_LERDGE_K . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_LERDGE_K . h <nl> <nl> / / Misc . Functions <nl> / / <nl> # define SDSS PC11 <nl> - # define LED_PIN PA15 / / Alive <nl> + # define LED_PIN PA15 / / Alive <nl> # define PS_ON_PIN - 1 <nl> # define KILL_PIN - 1 <nl> - # define POWER_LOSS_PIN PA4 / / Power - loss / nAC_FAULT <nl> + # define POWER_LOSS_PIN PA4 / / Power - loss / nAC_FAULT <nl> <nl> # define SCK_PIN PC12 <nl> # define MISO_PIN PC8 <nl> mmm a / Marlin / src / pins / stm32f4 / pins_LERDGE_S . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_LERDGE_S . h <nl> <nl> # define BOARD_INFO_NAME " Lerdge S " <nl> # define DEFAULT_MACHINE_NAME " LERDGE " <nl> <nl> - # define STEP_TIMER 4 <nl> - # define TEMP_TIMER 2 <nl> + # define STEP_TIMER 4 <nl> + # define TEMP_TIMER 2 <nl> <nl> / / # define I2C_EEPROM <nl> <nl> <nl> <nl> # if ENABLED ( SPI_EEPROM ) <nl> / / Lerdge has an SPI EEPROM Winbond W25Q128 ( 128Mbits ) https : / / www . pjrc . com / teensy / W25Q128FV . pdf <nl> - # define SPI_CHAN_EEPROM1 1 <nl> + # define SPI_CHAN_EEPROM1 1 <nl> # define SPI_EEPROM1_CS PB12 / / datasheet : / CS pin , found with multimeter , not tested <nl> # define EEPROM_SCK PB13 / / datasheet : CLK pin , found with multimeter , not tested <nl> # define EEPROM_MISO PB14 / / datasheet : DO pin , found with multimeter , not tested <nl> # define EEPROM_MOSI PB15 / / datasheet : DI pin , found with multimeter , not tested <nl> - # define EEPROM_PAGE_SIZE 0x1000U / / 4KB ( from datasheet ) <nl> + # define EEPROM_PAGE_SIZE 0x1000U / / 4KB ( from datasheet ) <nl> # define MARLIN_EEPROM_SIZE 16UL * ( EEPROM_PAGE_SIZE ) / / Limit to 64KB for now . . . <nl> # else <nl> - # define MARLIN_EEPROM_SIZE 0x800U / / On SD , Limit to 2KB , require this amount of RAM <nl> + # define MARLIN_EEPROM_SIZE 0x800U / / On SD , Limit to 2KB , require this amount of RAM <nl> # endif <nl> <nl> / / <nl> mmm a / Marlin / src / pins / stm32f4 / pins_LERDGE_X . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_LERDGE_X . h <nl> <nl> # define BOARD_INFO_NAME " Lerdge X " <nl> # define DEFAULT_MACHINE_NAME " LERDGE " <nl> <nl> - # define STEP_TIMER 4 <nl> - # define TEMP_TIMER 2 <nl> + # define STEP_TIMER 4 <nl> + # define TEMP_TIMER 2 <nl> <nl> # define I2C_EEPROM <nl> <nl> <nl> # define KILL_PIN - 1 <nl> <nl> / / Lerdge supports auto - power off and power loss sense through a single pin . <nl> - # define POWER_LOSS_PIN PC14 / / Power - loss / nAC_FAULT <nl> + # define POWER_LOSS_PIN PC14 / / Power - loss / nAC_FAULT <nl> <nl> # define SCK_PIN PC12 <nl> # define MISO_PIN PC8 <nl> mmm a / Marlin / src / pins / stm32f4 / pins_RUMBA32_AUS3D . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_RUMBA32_AUS3D . h <nl> <nl> # if NO_EEPROM_SELECTED <nl> # if MB ( RUMBA32_V1_0 ) <nl> # define FLASH_EEPROM_EMULATION <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # elif MB ( RUMBA32_V1_1 ) <nl> # define I2C_EEPROM <nl> - # define MARLIN_EEPROM_SIZE 0x2000 / / 8KB ( 24LC64T - I / OT ) <nl> + # define MARLIN_EEPROM_SIZE 0x2000 / / 8KB ( 24LC64T - I / OT ) <nl> # endif <nl> # endif <nl> <nl> mmm a / Marlin / src / pins / stm32f4 / pins_RUMBA32_MKS . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_RUMBA32_MKS . h <nl> <nl> <nl> # if NO_EEPROM_SELECTED <nl> # define FLASH_EEPROM_EMULATION <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> # endif <nl> <nl> # if ENABLED ( FLASH_EEPROM_EMULATION ) <nl> mmm a / Marlin / src / pins / stm32f4 / pins_RUMBA32_common . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_RUMBA32_common . h <nl> <nl> / / TIM7 is used for SERVO <nl> / / TIMER_SERIAL defaults to TIM7 so we ' ll override it here <nl> / / <nl> - # define STEP_TIMER 10 <nl> - # define TEMP_TIMER 14 <nl> + # define STEP_TIMER 10 <nl> + # define TEMP_TIMER 14 <nl> # define TIMER_SERIAL TIM9 <nl> # define HAL_TIMER_RATE F_CPU <nl> <nl> mmm a / Marlin / src / pins / stm32f4 / pins_VAKE403D . h <nl> ppp b / Marlin / src / pins / stm32f4 / pins_VAKE403D . h <nl> <nl> # define BOARD_INFO_NAME " STM32F4 VAkE " <nl> <nl> / / # define I2C_EEPROM <nl> - # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> + # define MARLIN_EEPROM_SIZE 0x1000 / / 4KB <nl> <nl> / / <nl> / / Servos <nl> mmm a / Marlin / src / pins / stm32f7 / pins_THE_BORG . h <nl> ppp b / Marlin / src / pins / stm32f7 / pins_THE_BORG . h <nl> <nl> # define DEFAULT_MACHINE_NAME BOARD_INFO_NAME <nl> <nl> # ifndef MARLIN_EEPROM_SIZE <nl> - # define MARLIN_EEPROM_SIZE 0x1000 <nl> + # define MARLIN_EEPROM_SIZE 0x1000 <nl> # endif <nl> <nl> / / Ignore temp readings during development . <nl> - / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> + / / # define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 <nl> <nl> / / <nl> / / Limit Switches <nl> mmm a / Marlin / src / pins / teensy2 / pins_5DPRINT . h <nl> ppp b / Marlin / src / pins / teensy2 / pins_5DPRINT . h <nl> <nl> <nl> / / DIGIPOTS slave addresses <nl> # ifndef DIGIPOT_I2C_ADDRESS_A <nl> - # define DIGIPOT_I2C_ADDRESS_A 0x2C / / unshifted slave address for DIGIPOT 0x2C ( 0x58 < - 0x2C < < 1 ) <nl> + # define DIGIPOT_I2C_ADDRESS_A 0x2C / / unshifted slave address for DIGIPOT 0x2C ( 0x58 < - 0x2C < < 1 ) <nl> # endif <nl> mmm a / Marlin / src / pins / teensy2 / pins_PRINTRBOARD_REVF . h <nl> ppp b / Marlin / src / pins / teensy2 / pins_PRINTRBOARD_REVF . h <nl> <nl> # define DAC_STEPPER_MAX 3520 <nl> # define DAC_STEPPER_VREF 1 / / internal Vref , gain 1x = 2 . 048V <nl> # define DAC_STEPPER_GAIN 0 <nl> - # define DAC_OR_ADDRESS 0x00 <nl> + # define DAC_OR_ADDRESS 0x00 <nl> <nl> / / <nl> / / Temperature Sensors <nl> | Reformat pins files | MarlinFirmware/Marlin | a9f7e855d8c030d0d9f34f950a66824b576548b5 | 2020-08-22T06:22:21Z |
mmm a / api / envoy / config / tap / v3 / common . proto <nl> ppp b / api / envoy / config / tap / v3 / common . proto <nl> message HttpGenericBodyMatch { <nl> option ( validate . required ) = true ; <nl> <nl> / / Text string to be located in HTTP body . <nl> - string string_match = 1 ; <nl> + string string_match = 1 [ ( validate . rules ) . string = { min_len : 1 } ] ; <nl> <nl> / / Sequence of bytes to be located in HTTP body . <nl> - bytes binary_match = 2 ; <nl> + bytes binary_match = 2 [ ( validate . rules ) . bytes = { min_len : 1 } ] ; <nl> } <nl> } <nl> <nl> mmm a / api / envoy / config / tap / v4alpha / common . proto <nl> ppp b / api / envoy / config / tap / v4alpha / common . proto <nl> message HttpGenericBodyMatch { <nl> option ( validate . required ) = true ; <nl> <nl> / / Text string to be located in HTTP body . <nl> - string string_match = 1 ; <nl> + string string_match = 1 [ ( validate . rules ) . string = { min_len : 1 } ] ; <nl> <nl> / / Sequence of bytes to be located in HTTP body . <nl> - bytes binary_match = 2 ; <nl> + bytes binary_match = 2 [ ( validate . rules ) . bytes = { min_len : 1 } ] ; <nl> } <nl> } <nl> <nl> mmm a / generated_api_shadow / envoy / config / tap / v3 / common . proto <nl> ppp b / generated_api_shadow / envoy / config / tap / v3 / common . proto <nl> message HttpGenericBodyMatch { <nl> option ( validate . required ) = true ; <nl> <nl> / / Text string to be located in HTTP body . <nl> - string string_match = 1 ; <nl> + string string_match = 1 [ ( validate . rules ) . string = { min_len : 1 } ] ; <nl> <nl> / / Sequence of bytes to be located in HTTP body . <nl> - bytes binary_match = 2 ; <nl> + bytes binary_match = 2 [ ( validate . rules ) . bytes = { min_len : 1 } ] ; <nl> } <nl> } <nl> <nl> mmm a / generated_api_shadow / envoy / config / tap / v4alpha / common . proto <nl> ppp b / generated_api_shadow / envoy / config / tap / v4alpha / common . proto <nl> message HttpGenericBodyMatch { <nl> option ( validate . required ) = true ; <nl> <nl> / / Text string to be located in HTTP body . <nl> - string string_match = 1 ; <nl> + string string_match = 1 [ ( validate . rules ) . string = { min_len : 1 } ] ; <nl> <nl> / / Sequence of bytes to be located in HTTP body . <nl> - bytes binary_match = 2 ; <nl> + bytes binary_match = 2 [ ( validate . rules ) . bytes = { min_len : 1 } ] ; <nl> } <nl> } <nl> <nl> new file mode 100644 <nl> index 00000000000 . . b59917510f2 <nl> mmm / dev / null <nl> ppp b / test / extensions / filters / http / common / fuzz / filter_corpus / clusterfuzz - testcase - minimized - filter_fuzz_test - 5728217898680320 <nl> <nl> + config { <nl> + name : " envoy . filters . http . tap " <nl> + typed_config { <nl> + type_url : " type . googleapis . com / envoy . extensions . filters . http . tap . v3 . Tap " <nl> + value : " \ no \ 022m \ nb \ n ` \ nD \ 032B \ n @ \ n \ 030 \ 032 \ 026 \ n \ 024 \ n \ n \ 032 \ 010 \ 032 \ 006J \ 004 \ 022 \ 002 \ n \ 000 \ n \ 006 \ 032 \ 004 \ 032 \ 002 * \ 000 \ n $ \ n \ " \ n \ 002 \ 001 \ n \ 034 \ 032 \ 032 \ 032 \ 030 \ n \ 026 \ n \ 002 \ 001 \ n \ 020 \ 032 \ 016 \ 032 \ 014 \ n \ n \ n \ 002 \ 001 \ n \ 004 \ 032 \ 002B \ 000 \ n \ 030 \ n \ 026 \ n \ 002 \ 001 \ n \ 020 \ 032 \ 016 \ 032 \ 014 \ n \ n \ n \ 002 \ 001 \ n \ 004 \ 032 \ 002B \ 000 \ 022 \ 007 \ n \ 005 \ 032 \ 003 \ n \ 001 ( " <nl> + } <nl> + } <nl> \ No newline at end of file <nl> | fuzz : fixing unsigned integer underflow ( ) | envoyproxy/envoy | 8f668e976ea0bbd7d3ac352247c1fdead6acbb31 | 2020-07-28T06:27:47Z |
mmm a / AirLib / include / vehicles / MultiRotorParamsFactory . hpp <nl> ppp b / AirLib / include / vehicles / MultiRotorParamsFactory . hpp <nl> class MultiRotorParamsFactory { <nl> { <nl> / / read settings and override defaults <nl> Settings & settings = Settings : : singleton ( ) ; <nl> - if ( ! settings . isLoadSuccess ( ) ) <nl> - throw std : : runtime_error ( " Cannot load settings . json " ) ; <nl> - <nl> Settings child ; <nl> settings . getChild ( vehicle_name , child ) ; <nl> <nl> mmm a / Unreal / Plugins / AirSim / Source / MultiRotorConnector . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / MultiRotorConnector . cpp <nl> <nl> # include " AirSim . h " <nl> # include " MultiRotorConnector . h " <nl> # include " AirBlueprintLib . h " <nl> - # include " controllers / Settings . hpp " <nl> # include < exception > <nl> <nl> using namespace msr : : airlib ; <nl> <nl> - void MultiRotorConnector : : initialize ( AFlyingPawn * vehicle_pawn , msr : : airlib : : MultiRotorParams * vehicle_params ) <nl> + void MultiRotorConnector : : initialize ( AFlyingPawn * vehicle_pawn , msr : : airlib : : MultiRotorParams * vehicle_params , bool enable_rpc , std : : string api_server_address ) <nl> { <nl> + enable_rpc_ = enable_rpc ; <nl> + api_server_address_ = api_server_address ; <nl> vehicle_pawn_ = vehicle_pawn ; <nl> vehicle_pawn_ - > initialize ( ) ; <nl> <nl> void MultiRotorConnector : : updateRendering ( float dt ) <nl> <nl> void MultiRotorConnector : : startApiServer ( ) <nl> { <nl> - auto settings = Settings : : singleton ( ) ; <nl> - bool rpcEnabled = settings . getBool ( " RpcEnabled " , false ) ; <nl> - if ( settings . setBool ( " RpcEnabled " , rpcEnabled ) & & settings . isLoadSuccess ( ) ) { <nl> - / / update settings file so it knows about this new boolean switch <nl> - settings . saveJSonFile ( settings . getFileName ( ) ) ; <nl> - } <nl> - <nl> - if ( rpcEnabled ) { <nl> + if ( enable_rpc_ ) { <nl> controller_cancelable_ . reset ( new msr : : airlib : : DroneControllerCancelable ( <nl> vehicle_ . getController ( ) ) ) ; <nl> - api_server_address_ = Settings : : singleton ( ) . getString ( " LocalHostIp " , " 127 . 0 . 0 . 1 " ) ; <nl> rpclib_server_ . reset ( new msr : : airlib : : RpcLibServer ( controller_cancelable_ . get ( ) , api_server_address_ ) ) ; <nl> rpclib_server_ - > start ( ) ; <nl> } <nl> mmm a / Unreal / Plugins / AirSim / Source / MultiRotorConnector . h <nl> ppp b / Unreal / Plugins / AirSim / Source / MultiRotorConnector . h <nl> class MultiRotorConnector : public VehicleConnectorBase <nl> <nl> / / VehicleConnectorBase interface <nl> / / implements game interface to update pawn <nl> - void initialize ( AFlyingPawn * vehicle_pawn , msr : : airlib : : MultiRotorParams * vehicle_params ) ; <nl> + void initialize ( AFlyingPawn * vehicle_pawn , msr : : airlib : : MultiRotorParams * vehicle_params , bool enable_rpc , std : : string api_server_address ) ; <nl> virtual void beginPlay ( ) override ; <nl> virtual void endPlay ( ) override ; <nl> virtual void updateRenderedState ( ) override ; <nl> class MultiRotorConnector : public VehicleConnectorBase <nl> std : : vector < std : : string > controller_messages_ ; <nl> msr : : airlib : : Environment environment_ ; <nl> AFlyingPawn * vehicle_pawn_ ; <nl> - std : : string api_server_address_ ; <nl> <nl> msr : : airlib : : MultiRotorParams * vehicle_params_ ; <nl> std : : unique_ptr < msr : : airlib : : DroneControllerCancelable > controller_cancelable_ ; <nl> class MultiRotorConnector : public VehicleConnectorBase <nl> real_T rotor_controls_filtered_ [ 4 ] ; <nl> <nl> Pose last_pose , last_debug_pose ; <nl> + <nl> + bool enable_rpc_ ; <nl> + std : : string api_server_address_ ; <nl> } ; <nl> mmm a / Unreal / Plugins / AirSim / Source / SimMode / SimModeBase . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / SimMode / SimModeBase . cpp <nl> <nl> # include " SimModeBase . h " <nl> # include " AirBlueprintLib . h " <nl> # include " Runtime / Launch / Resources / Version . h " <nl> + # include " controllers / Settings . hpp " <nl> <nl> ASimModeBase : : ASimModeBase ( ) <nl> { <nl> void ASimModeBase : : initializeSettings ( ) <nl> try { <nl> Settings & settings = Settings : : loadJSonFile ( " settings . json " ) ; <nl> auto settings_filename = Settings : : singleton ( ) . getFileName ( ) ; <nl> - std : : string msg = " Loading settings from " + settings_filename ; <nl> - UAirBlueprintLib : : LogMessage ( FString ( msg . c_str ( ) ) , TEXT ( " " ) , LogDebugLevel : : Informational , 30 ) ; <nl> + if ( settings . isLoadSuccess ( ) ) { <nl> + std : : string msg = " Loaded settings from " + settings_filename ; <nl> + UAirBlueprintLib : : LogMessage ( FString ( msg . c_str ( ) ) , TEXT ( " " ) , LogDebugLevel : : Informational ) ; <nl> + <nl> + enable_rpc = settings . getBool ( " RpcEnabled " , true ) ; <nl> + api_server_address = settings . getString ( " LocalHostIp " , " 127 . 0 . 0 . 1 " ) ; <nl> + } <nl> + else { <nl> + / / write some settings in new file otherwise the string " null " is written if all settigs are empty <nl> + enable_rpc = settings . setBool ( " RpcEnabled " , true ) ; <nl> + settings . setString ( " LocalHostIp " , " 127 . 0 . 0 . 1 " ) ; <nl> + settings . saveJSonFile ( settings_filename ) ; <nl> + std : : string msg = " Settings file " + settings_filename + " is created . " ; <nl> + UAirBlueprintLib : : LogMessage ( FString ( msg . c_str ( ) ) , TEXT ( " See docs at https : / / git . io / v9mYY " ) , LogDebugLevel : : Informational ) ; <nl> + } <nl> } <nl> catch ( std : : exception ex ) { <nl> UAirBlueprintLib : : LogMessage ( FString ( " Error loading settings from ~ / Documents / AirSim / settings . json " ) , TEXT ( " " ) , LogDebugLevel : : Failure , 30 ) ; <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> virtual void setupInputBindings ( ) ; <nl> bool is_recording ; <nl> int record_tick_count ; <nl> + bool enable_rpc ; <nl> + std : : string api_server_address ; <nl> <nl> private : <nl> void initializeSettings ( ) ; <nl> mmm a / Unreal / Plugins / AirSim / Source / SimMode / SimModeWorldMultiRotor . cpp <nl> ppp b / Unreal / Plugins / AirSim / Source / SimMode / SimModeWorldMultiRotor . cpp <nl> ASimModeWorldBase : : VehiclePtr ASimModeWorldMultiRotor : : createVehicle ( AFlyingPawn <nl> vehicle_params_ = MultiRotorParamsFactory : : createConfig ( pawn - > getVehicleName ( ) ) ; <nl> <nl> auto vehicle = std : : make_shared < MultiRotorConnector > ( ) ; <nl> - vehicle - > initialize ( pawn , vehicle_params_ . get ( ) ) ; <nl> + vehicle - > initialize ( pawn , vehicle_params_ . get ( ) , enable_rpc , api_server_address ) ; <nl> return std : : static_pointer_cast < VehicleConnectorBase > ( vehicle ) ; <nl> } <nl> <nl> | initial settings in one place , remove settings dependency from connector | microsoft/AirSim | dd55f71a7cd8f598ce12962726ae2c81659dd3e3 | 2017-04-26T02:29:14Z |
mmm a / dlib / image_processing / box_overlap_testing_abstract . h <nl> ppp b / dlib / image_processing / box_overlap_testing_abstract . h <nl> namespace dlib <nl> - returns true if a and b overlap " enough " . This is defined precisely below . <nl> - if ( a . intersect ( b ) . area ( ) / ( a + b ) . area ( ) > get_match_thresh ( ) | | <nl> a . intersect ( b ) . area ( ) / a . area ( ) > get_overlap_thresh ( ) | | <nl> - a . intersect ( b ) . area ( ) / a . area ( ) > get_overlap_thresh ( ) ) then <nl> + a . intersect ( b ) . area ( ) / b . area ( ) > get_overlap_thresh ( ) ) then <nl> - returns true <nl> - else <nl> - returns false <nl> | fixed typo in spec | davisking/dlib | 55a0ee9c8dec584291ff13e029008436120a8da2 | 2014-08-15T00:40:42Z |
mmm a / src / random . cpp <nl> ppp b / src / random . cpp <nl> <nl> std : : abort ( ) ; <nl> } <nl> <nl> - static inline int64_t GetPerformanceCounter ( ) <nl> + static inline int64_t GetPerformanceCounter ( ) noexcept <nl> { <nl> / / Read the hardware time stamp counter when available . <nl> / / See https : / / en . wikipedia . org / wiki / Time_Stamp_Counter for more information . <nl> static void InitHardwareRand ( ) { } <nl> static void ReportHardwareRand ( ) { } <nl> # endif <nl> <nl> - static bool GetHardwareRand ( unsigned char * ent32 ) { <nl> + static bool GetHardwareRand ( unsigned char * ent32 ) noexcept { <nl> # if defined ( __x86_64__ ) | | defined ( __amd64__ ) | | defined ( __i386__ ) <nl> if ( rdrand_supported ) { <nl> uint8_t ok ; <nl> struct RNGState { <nl> bool m_strongly_seeded GUARDED_BY ( m_mutex ) = false ; <nl> std : : unique_ptr < Mutex [ ] > m_mutex_openssl ; <nl> <nl> - RNGState ( ) <nl> + RNGState ( ) noexcept <nl> { <nl> InitHardwareRand ( ) ; <nl> <nl> struct RNGState { <nl> * <nl> * If this function has never been called with strong_seed = true , false is returned . <nl> * / <nl> - bool MixExtract ( unsigned char * out , size_t num , CSHA512 & & hasher , bool strong_seed ) <nl> + bool MixExtract ( unsigned char * out , size_t num , CSHA512 & & hasher , bool strong_seed ) noexcept <nl> { <nl> assert ( num < = 32 ) ; <nl> unsigned char buf [ 64 ] ; <nl> struct RNGState { <nl> } <nl> } ; <nl> <nl> - RNGState & GetRNGState ( ) <nl> + RNGState & GetRNGState ( ) noexcept <nl> { <nl> / / This C + + 11 idiom relies on the guarantee that static variable are initialized <nl> / / on first call , even when multiple parallel calls are permitted . <nl> void LockingCallbackOpenSSL ( int mode , int i , const char * file , int line ) NO_THRE <nl> } <nl> } <nl> <nl> - static void SeedTimestamp ( CSHA512 & hasher ) <nl> + / * A note on the use of noexcept in the seeding functions below : <nl> + * <nl> + * None of the RNG code should ever throw any exception , with the sole exception <nl> + * of MilliSleep in SeedSleep , which can ( and does ) support interruptions which <nl> + * cause a boost : : thread_interrupted to be thrown . <nl> + * <nl> + * This means that SeedSleep , and all functions that invoke it are throwing . <nl> + * However , we know that GetRandBytes ( ) and GetStrongRandBytes ( ) never trigger <nl> + * this sleeping logic , so they are noexcept . The same is true for all the <nl> + * GetRand * ( ) functions that use GetRandBytes ( ) indirectly . <nl> + * <nl> + * TODO : After moving away from interruptible boost - based thread management , <nl> + * everything can become noexcept here . <nl> + * / <nl> + <nl> + static void SeedTimestamp ( CSHA512 & hasher ) noexcept <nl> { <nl> int64_t perfcounter = GetPerformanceCounter ( ) ; <nl> hasher . Write ( ( const unsigned char * ) & perfcounter , sizeof ( perfcounter ) ) ; <nl> } <nl> <nl> - static void SeedFast ( CSHA512 & hasher ) <nl> + static void SeedFast ( CSHA512 & hasher ) noexcept <nl> { <nl> unsigned char buffer [ 32 ] ; <nl> <nl> static void SeedFast ( CSHA512 & hasher ) <nl> SeedTimestamp ( hasher ) ; <nl> } <nl> <nl> - static void SeedSlow ( CSHA512 & hasher ) <nl> + static void SeedSlow ( CSHA512 & hasher ) noexcept <nl> { <nl> unsigned char buffer [ 32 ] ; <nl> <nl> static void SeedSleep ( CSHA512 & hasher ) <nl> RandAddSeedPerfmon ( hasher ) ; <nl> } <nl> <nl> - static void SeedStartup ( CSHA512 & hasher ) <nl> + static void SeedStartup ( CSHA512 & hasher ) noexcept <nl> { <nl> # ifdef WIN32 <nl> RAND_screen ( ) ; <nl> static void ProcRand ( unsigned char * out , int num , RNGLevel level ) <nl> } <nl> } <nl> <nl> - void GetRandBytes ( unsigned char * buf , int num ) { ProcRand ( buf , num , RNGLevel : : FAST ) ; } <nl> - void GetStrongRandBytes ( unsigned char * buf , int num ) { ProcRand ( buf , num , RNGLevel : : SLOW ) ; } <nl> + void GetRandBytes ( unsigned char * buf , int num ) noexcept { ProcRand ( buf , num , RNGLevel : : FAST ) ; } <nl> + void GetStrongRandBytes ( unsigned char * buf , int num ) noexcept { ProcRand ( buf , num , RNGLevel : : SLOW ) ; } <nl> void RandAddSeedSleep ( ) { ProcRand ( nullptr , 0 , RNGLevel : : SLEEP ) ; } <nl> <nl> - uint64_t GetRand ( uint64_t nMax ) <nl> + uint64_t GetRand ( uint64_t nMax ) noexcept <nl> { <nl> if ( nMax = = 0 ) <nl> return 0 ; <nl> uint64_t GetRand ( uint64_t nMax ) <nl> return ( nRand % nMax ) ; <nl> } <nl> <nl> - int GetRandInt ( int nMax ) <nl> + int GetRandInt ( int nMax ) noexcept <nl> { <nl> return GetRand ( nMax ) ; <nl> } <nl> <nl> - uint256 GetRandHash ( ) <nl> + uint256 GetRandHash ( ) noexcept <nl> { <nl> uint256 hash ; <nl> GetRandBytes ( ( unsigned char * ) & hash , sizeof ( hash ) ) ; <nl> void FastRandomContext : : RandomSeed ( ) <nl> requires_seed = false ; <nl> } <nl> <nl> - uint256 FastRandomContext : : rand256 ( ) <nl> + uint256 FastRandomContext : : rand256 ( ) noexcept <nl> { <nl> if ( bytebuf_size < 32 ) { <nl> FillByteBuffer ( ) ; <nl> std : : vector < unsigned char > FastRandomContext : : randbytes ( size_t len ) <nl> return ret ; <nl> } <nl> <nl> - FastRandomContext : : FastRandomContext ( const uint256 & seed ) : requires_seed ( false ) , bytebuf_size ( 0 ) , bitbuf_size ( 0 ) <nl> + FastRandomContext : : FastRandomContext ( const uint256 & seed ) noexcept : requires_seed ( false ) , bytebuf_size ( 0 ) , bitbuf_size ( 0 ) <nl> { <nl> rng . SetKey ( seed . begin ( ) , 32 ) ; <nl> } <nl> bool Random_SanityCheck ( ) <nl> return true ; <nl> } <nl> <nl> - FastRandomContext : : FastRandomContext ( bool fDeterministic ) : requires_seed ( ! fDeterministic ) , bytebuf_size ( 0 ) , bitbuf_size ( 0 ) <nl> + FastRandomContext : : FastRandomContext ( bool fDeterministic ) noexcept : requires_seed ( ! fDeterministic ) , bytebuf_size ( 0 ) , bitbuf_size ( 0 ) <nl> { <nl> if ( ! fDeterministic ) { <nl> return ; <nl> mmm a / src / random . h <nl> ppp b / src / random . h <nl> <nl> * <nl> * Thread - safe . <nl> * / <nl> - void GetRandBytes ( unsigned char * buf , int num ) ; <nl> - uint64_t GetRand ( uint64_t nMax ) ; <nl> - int GetRandInt ( int nMax ) ; <nl> - uint256 GetRandHash ( ) ; <nl> + void GetRandBytes ( unsigned char * buf , int num ) noexcept ; <nl> + uint64_t GetRand ( uint64_t nMax ) noexcept ; <nl> + int GetRandInt ( int nMax ) noexcept ; <nl> + uint256 GetRandHash ( ) noexcept ; <nl> <nl> / * * <nl> * Gather entropy from various sources , feed it into the internal PRNG , and <nl> uint256 GetRandHash ( ) ; <nl> * <nl> * Thread - safe . <nl> * / <nl> - void GetStrongRandBytes ( unsigned char * buf , int num ) ; <nl> + void GetStrongRandBytes ( unsigned char * buf , int num ) noexcept ; <nl> <nl> / * * <nl> * Sleep for 1ms , gather entropy from various sources , and feed them to the PRNG state . <nl> class FastRandomContext { <nl> } <nl> <nl> public : <nl> - explicit FastRandomContext ( bool fDeterministic = false ) ; <nl> + explicit FastRandomContext ( bool fDeterministic = false ) noexcept ; <nl> <nl> / * * Initialize with explicit seed ( only for testing ) * / <nl> - explicit FastRandomContext ( const uint256 & seed ) ; <nl> + explicit FastRandomContext ( const uint256 & seed ) noexcept ; <nl> <nl> / / Do not permit copying a FastRandomContext ( move it , or create a new one to get reseeded ) . <nl> FastRandomContext ( const FastRandomContext & ) = delete ; <nl> class FastRandomContext { <nl> FastRandomContext & operator = ( FastRandomContext & & from ) noexcept ; <nl> <nl> / * * Generate a random 64 - bit integer . * / <nl> - uint64_t rand64 ( ) <nl> + uint64_t rand64 ( ) noexcept <nl> { <nl> if ( bytebuf_size < 8 ) FillByteBuffer ( ) ; <nl> uint64_t ret = ReadLE64 ( bytebuf + 64 - bytebuf_size ) ; <nl> class FastRandomContext { <nl> } <nl> <nl> / * * Generate a random ( bits ) - bit integer . * / <nl> - uint64_t randbits ( int bits ) { <nl> + uint64_t randbits ( int bits ) noexcept { <nl> if ( bits = = 0 ) { <nl> return 0 ; <nl> } else if ( bits > 32 ) { <nl> class FastRandomContext { <nl> } <nl> <nl> / * * Generate a random integer in the range [ 0 . . range ) . * / <nl> - uint64_t randrange ( uint64_t range ) <nl> + uint64_t randrange ( uint64_t range ) noexcept <nl> { <nl> - - range ; <nl> int bits = CountBits ( range ) ; <nl> class FastRandomContext { <nl> std : : vector < unsigned char > randbytes ( size_t len ) ; <nl> <nl> / * * Generate a random 32 - bit integer . * / <nl> - uint32_t rand32 ( ) { return randbits ( 32 ) ; } <nl> + uint32_t rand32 ( ) noexcept { return randbits ( 32 ) ; } <nl> <nl> / * * generate a random uint256 . * / <nl> - uint256 rand256 ( ) ; <nl> + uint256 rand256 ( ) noexcept ; <nl> <nl> / * * Generate a random boolean . * / <nl> - bool randbool ( ) { return randbits ( 1 ) ; } <nl> + bool randbool ( ) noexcept { return randbits ( 1 ) ; } <nl> <nl> / / Compatibility with the C + + 11 UniformRandomBitGenerator concept <nl> typedef uint64_t result_type ; <nl> static constexpr uint64_t min ( ) { return 0 ; } <nl> static constexpr uint64_t max ( ) { return std : : numeric_limits < uint64_t > : : max ( ) ; } <nl> - inline uint64_t operator ( ) ( ) { return rand64 ( ) ; } <nl> + inline uint64_t operator ( ) ( ) noexcept { return rand64 ( ) ; } <nl> } ; <nl> <nl> / * * More efficient than using std : : shuffle on a FastRandomContext . <nl> | Sprinkle some sweet noexcepts over the RNG code | bitcoin/bitcoin | a1f252eda87356fa329c838a7bf569808489648f | 2019-01-17T00:34:56Z |
mmm a / editor / editor_export . cpp <nl> ppp b / editor / editor_export . cpp <nl> bool EditorExportPlatformPC : : can_export ( const Ref < EditorExportPreset > & p_preset , <nl> return valid ; <nl> } <nl> <nl> - String EditorExportPlatformPC : : get_binary_extension ( const Ref < EditorExportPreset > & p_preset ) const { <nl> + List < String > EditorExportPlatformPC : : get_binary_extensions ( const Ref < EditorExportPreset > & p_preset ) const { <nl> + List < String > list ; <nl> for ( Map < String , String > : : Element * E = extensions . front ( ) ; E ; E = E - > next ( ) ) { <nl> if ( p_preset - > get ( E - > key ( ) ) ) { <nl> - return extensions [ E - > key ( ) ] ; <nl> + list . push_back ( extensions [ E - > key ( ) ] ) ; <nl> + return list ; <nl> } <nl> } <nl> <nl> if ( extensions . has ( " default " ) ) { <nl> - return extensions [ " default " ] ; <nl> + list . push_back ( extensions [ " default " ] ) ; <nl> + return list ; <nl> } <nl> <nl> - return " " ; <nl> + return list ; <nl> } <nl> <nl> Error EditorExportPlatformPC : : export_project ( const Ref < EditorExportPreset > & p_preset , bool p_debug , const String & p_path , int p_flags ) { <nl> mmm a / editor / editor_export . h <nl> ppp b / editor / editor_export . h <nl> class EditorExportPlatform : public Reference { <nl> <nl> virtual bool can_export ( const Ref < EditorExportPreset > & p_preset , String & r_error , bool & r_missing_templates ) const = 0 ; <nl> <nl> - virtual String get_binary_extension ( const Ref < EditorExportPreset > & p_preset ) const = 0 ; <nl> + virtual List < String > get_binary_extensions ( const Ref < EditorExportPreset > & p_preset ) const = 0 ; <nl> virtual Error export_project ( const Ref < EditorExportPreset > & p_preset , bool p_debug , const String & p_path , int p_flags = 0 ) = 0 ; <nl> virtual Error export_pack ( const Ref < EditorExportPreset > & p_preset , bool p_debug , const String & p_path , int p_flags = 0 ) ; <nl> virtual Error export_zip ( const Ref < EditorExportPreset > & p_preset , bool p_debug , const String & p_path , int p_flags = 0 ) ; <nl> class EditorExportPlatformPC : public EditorExportPlatform { <nl> virtual Ref < Texture > get_logo ( ) const ; <nl> <nl> virtual bool can_export ( const Ref < EditorExportPreset > & p_preset , String & r_error , bool & r_missing_templates ) const ; <nl> - virtual String get_binary_extension ( const Ref < EditorExportPreset > & p_preset ) const ; <nl> + virtual List < String > get_binary_extensions ( const Ref < EditorExportPreset > & p_preset ) const ; <nl> virtual Error export_project ( const Ref < EditorExportPreset > & p_preset , bool p_debug , const String & p_path , int p_flags = 0 ) ; <nl> <nl> void set_extension ( const String & p_extension , const String & p_feature_key = " default " ) ; <nl> mmm a / editor / project_export . cpp <nl> ppp b / editor / project_export . cpp <nl> void ProjectExportDialog : : _export_project ( ) { <nl> export_project - > set_access ( FileDialog : : ACCESS_FILESYSTEM ) ; <nl> export_project - > clear_filters ( ) ; <nl> <nl> + List < String > extension_list = platform - > get_binary_extensions ( current ) ; <nl> + for ( int i = 0 ; i < extension_list . size ( ) ; i + + ) { <nl> + export_project - > add_filter ( " * . " + extension_list [ i ] + " ; " + platform - > get_name ( ) + " Export " ) ; <nl> + } <nl> + <nl> if ( current - > get_export_path ( ) ! = " " ) { <nl> export_project - > set_current_path ( current - > get_export_path ( ) ) ; <nl> } else { <nl> - String extension = platform - > get_binary_extension ( current ) ; <nl> - if ( extension ! = String ( ) ) { <nl> - export_project - > add_filter ( " * . " + extension + " ; " + platform - > get_name ( ) + " Export " ) ; <nl> - export_project - > set_current_file ( default_filename + " . " + extension ) ; <nl> + if ( extension_list . size ( ) > = 1 ) { <nl> + export_project - > set_current_file ( default_filename + " . " + extension_list [ 0 ] ) ; <nl> } else { <nl> export_project - > set_current_file ( default_filename ) ; <nl> } <nl> mmm a / platform / android / export / export . cpp <nl> ppp b / platform / android / export / export . cpp <nl> class EditorExportAndroid : public EditorExportPlatform { <nl> return valid ; <nl> } <nl> <nl> - virtual String get_binary_extension ( const Ref < EditorExportPreset > & p_preset ) const { <nl> - return " apk " ; <nl> + virtual List < String > get_binary_extensions ( const Ref < EditorExportPreset > & p_preset ) const { <nl> + List < String > list ; <nl> + list . push_back ( " apk " ) ; <nl> + return list ; <nl> } <nl> <nl> virtual Error export_project ( const Ref < EditorExportPreset > & p_preset , bool p_debug , const String & p_path , int p_flags = 0 ) { <nl> mmm a / platform / iphone / export / export . cpp <nl> ppp b / platform / iphone / export / export . cpp <nl> class EditorExportPlatformIOS : public EditorExportPlatform { <nl> virtual String get_os_name ( ) const { return " iOS " ; } <nl> virtual Ref < Texture > get_logo ( ) const { return logo ; } <nl> <nl> - virtual String get_binary_extension ( const Ref < EditorExportPreset > & p_preset ) const { return " ipa " ; } <nl> + virtual List < String > get_binary_extensions ( const Ref < EditorExportPreset > & p_preset ) const { <nl> + List < String > list ; <nl> + list . push_back ( " ipa " ) ; <nl> + return list ; <nl> + } <nl> virtual Error export_project ( const Ref < EditorExportPreset > & p_preset , bool p_debug , const String & p_path , int p_flags = 0 ) ; <nl> <nl> virtual bool can_export ( const Ref < EditorExportPreset > & p_preset , String & r_error , bool & r_missing_templates ) const ; <nl> mmm a / platform / javascript / export / export . cpp <nl> ppp b / platform / javascript / export / export . cpp <nl> class EditorExportPlatformJavaScript : public EditorExportPlatform { <nl> virtual Ref < Texture > get_logo ( ) const ; <nl> <nl> virtual bool can_export ( const Ref < EditorExportPreset > & p_preset , String & r_error , bool & r_missing_templates ) const ; <nl> - virtual String get_binary_extension ( const Ref < EditorExportPreset > & p_preset ) const ; <nl> + virtual List < String > get_binary_extensions ( const Ref < EditorExportPreset > & p_preset ) const ; <nl> virtual Error export_project ( const Ref < EditorExportPreset > & p_preset , bool p_debug , const String & p_path , int p_flags = 0 ) ; <nl> <nl> virtual bool poll_devices ( ) ; <nl> bool EditorExportPlatformJavaScript : : can_export ( const Ref < EditorExportPreset > & p <nl> return valid ; <nl> } <nl> <nl> - String EditorExportPlatformJavaScript : : get_binary_extension ( const Ref < EditorExportPreset > & p_preset ) const { <nl> + List < String > EditorExportPlatformJavaScript : : get_binary_extensions ( const Ref < EditorExportPreset > & p_preset ) const { <nl> <nl> - return " html " ; <nl> + List < String > list ; <nl> + list . push_back ( " html " ) ; <nl> + return list ; <nl> } <nl> <nl> Error EditorExportPlatformJavaScript : : export_project ( const Ref < EditorExportPreset > & p_preset , bool p_debug , const String & p_path , int p_flags ) { <nl> mmm a / platform / osx / export / export . cpp <nl> ppp b / platform / osx / export / export . cpp <nl> class EditorExportPlatformOSX : public EditorExportPlatform { <nl> virtual String get_os_name ( ) const { return " OSX " ; } <nl> virtual Ref < Texture > get_logo ( ) const { return logo ; } <nl> <nl> - virtual String get_binary_extension ( const Ref < EditorExportPreset > & p_preset ) const { return use_dmg ( ) ? " dmg " : " zip " ; } <nl> + virtual List < String > get_binary_extensions ( const Ref < EditorExportPreset > & p_preset ) const { <nl> + List < String > list ; <nl> + if ( use_dmg ( ) ) { <nl> + list . push_back ( " dmg " ) ; <nl> + } <nl> + list . push_back ( " zip " ) ; <nl> + return list ; <nl> + } <nl> virtual Error export_project ( const Ref < EditorExportPreset > & p_preset , bool p_debug , const String & p_path , int p_flags = 0 ) ; <nl> <nl> virtual bool can_export ( const Ref < EditorExportPreset > & p_preset , String & r_error , bool & r_missing_templates ) const ; <nl> Error EditorExportPlatformOSX : : export_project ( const Ref < EditorExportPreset > & p_p <nl> io2 . opaque = & dst_f ; <nl> zipFile dst_pkg_zip = NULL ; <nl> <nl> - if ( use_dmg ( ) ) { <nl> + String export_format = use_dmg ( ) & & p_path . ends_with ( " dmg " ) ? " dmg " : " zip " ; <nl> + if ( export_format = = " dmg " ) { <nl> / / We ' re on OSX so we can export to DMG , but first we create our application bundle <nl> tmp_app_path_name = EditorSettings : : get_singleton ( ) - > get_cache_dir ( ) . plus_file ( pkg_name + " . app " ) ; <nl> print_line ( " Exporting to " + tmp_app_path_name ) ; <nl> Error EditorExportPlatformOSX : : export_project ( const Ref < EditorExportPreset > & p_p <nl> print_line ( " ADDING : " + file + " size : " + itos ( data . size ( ) ) ) ; <nl> total_size + = data . size ( ) ; <nl> <nl> - if ( use_dmg ( ) ) { <nl> + if ( export_format = = " dmg " ) { <nl> / / write it into our application bundle <nl> file = tmp_app_path_name + " / " + file ; <nl> <nl> Error EditorExportPlatformOSX : : export_project ( const Ref < EditorExportPreset > & p_p <nl> if ( err = = OK ) { <nl> ep . step ( " Making PKG " , 1 ) ; <nl> <nl> - if ( use_dmg ( ) ) { <nl> + if ( export_format = = " dmg " ) { <nl> String pack_path = tmp_app_path_name + " / Contents / Resources / " + pkg_name + " . pck " ; <nl> Vector < SharedObject > shared_objects ; <nl> err = save_pack ( p_preset , pack_path , & shared_objects ) ; <nl> mmm a / platform / uwp / export / export . cpp <nl> ppp b / platform / uwp / export / export . cpp <nl> class EditorExportUWP : public EditorExportPlatform { <nl> return " UWP " ; <nl> } <nl> <nl> - virtual String get_binary_extension ( const Ref < EditorExportPreset > & p_preset ) const { <nl> - return " appx " ; <nl> + virtual List < String > get_binary_extensions ( const Ref < EditorExportPreset > & p_preset ) const { <nl> + List < String > list ; <nl> + list . push_back ( " appx " ) ; <nl> + return list ; <nl> } <nl> <nl> virtual Ref < Texture > get_logo ( ) const { <nl> | Export for OS X on OS X now lets you select . dmg or . zip | godotengine/godot | d51999f11d7f6c1b30310a08cde7b12666e673ac | 2018-11-01T13:08:26Z |
mmm a / src / clustering / administration / issues / machine_down . hpp <nl> ppp b / src / clustering / administration / issues / machine_down . hpp <nl> class machine_down_issue_t : public global_issue_t { <nl> } <nl> <nl> machine_id_t machine_id ; <nl> + <nl> + private : <nl> + DISABLE_COPYING ( machine_down_issue_t ) ; <nl> } ; <nl> <nl> class machine_down_issue_tracker_t : public global_issue_tracker_t { <nl> | Added DISABLE_COPYING to machine_down_issue_t . | rethinkdb/rethinkdb | 4efe9253cf2779fbaa18dd9672ebe1cfe496fd94 | 2012-05-01T22:59:21Z |
mmm a / cocos / editor - support / cocostudio / ActionTimeline / CCBoneNode . cpp <nl> ppp b / cocos / editor - support / cocostudio / ActionTimeline / CCBoneNode . cpp <nl> void BoneNode : : removeChild ( Node * child , bool cleanup / * = true * / ) <nl> <nl> void BoneNode : : removeFromBoneList ( BoneNode * bone ) <nl> { <nl> - _childBones . eraseObject ( bone ) ; <nl> auto skeletonNode = dynamic_cast < SkeletonNode * > ( bone ) ; <nl> - if ( skeletonNode ! = nullptr ) / / nested skeleton <nl> - return ; <nl> - <nl> - bone - > _rootSkeleton = nullptr ; <nl> - auto subBones = bone - > getAllSubBones ( ) ; <nl> - subBones . pushBack ( bone ) ; <nl> - for ( auto & subBone : subBones ) <nl> + if ( skeletonNode = = nullptr ) / / not a nested skeleton <nl> { <nl> - subBone - > _rootSkeleton = nullptr ; <nl> - _rootSkeleton - > _subBonesMap . erase ( subBone - > getName ( ) ) ; <nl> - if ( bone - > _isRackShow & & bone - > _visible ) <nl> + bone - > _rootSkeleton = nullptr ; <nl> + auto subBones = bone - > getAllSubBones ( ) ; <nl> + subBones . pushBack ( bone ) ; <nl> + for ( auto & subBone : subBones ) <nl> { <nl> - _rootSkeleton - > _subDrawBonesDirty = true ; <nl> - _rootSkeleton - > _subDrawBonesOrderDirty = true ; <nl> + subBone - > _rootSkeleton = nullptr ; <nl> + _rootSkeleton - > _subBonesMap . erase ( subBone - > getName ( ) ) ; <nl> + if ( bone - > _isRackShow & & bone - > _visible ) <nl> + { <nl> + _rootSkeleton - > _subDrawBonesDirty = true ; <nl> + _rootSkeleton - > _subDrawBonesOrderDirty = true ; <nl> + } <nl> } <nl> } <nl> + _childBones . eraseObject ( bone ) ; <nl> } <nl> <nl> void BoneNode : : addToBoneList ( BoneNode * bone ) <nl> void BoneNode : : onDraw ( const cocos2d : : Mat4 & transform , uint32_t flags ) <nl> glDrawArrays ( GL_TRIANGLE_FAN , 0 , 4 ) ; <nl> <nl> # ifdef CC_STUDIO_ENABLED_VIEW <nl> - glVertexAttribPointer ( GLProgram : : VERTEX_ATTRIB_POSITION , 3 , GL_FLOAT , GL_FALSE , 0 , _noMVPVertices ) ; <nl> - glVertexAttribPointer ( GLProgram : : VERTEX_ATTRIB_COLOR , 4 , GL_FLOAT , GL_FALSE , 0 , _squareColors ) ; <nl> + glVertexAttribPointer ( cocos2d : : GLProgram : : VERTEX_ATTRIB_POSITION , 3 , GL_FLOAT , GL_FALSE , 0 , _noMVPVertices ) ; <nl> + glVertexAttribPointer ( cocos2d : : GLProgram : : VERTEX_ATTRIB_COLOR , 4 , GL_FLOAT , GL_FALSE , 0 , _squareColors ) ; <nl> <nl> glEnable ( GL_LINE_SMOOTH ) ; <nl> glHint ( GL_LINE_SMOOTH_HINT , GL_DONT_CARE ) ; <nl> mmm a / cocos / editor - support / cocostudio / ActionTimeline / CCSkeletonNode . cpp <nl> ppp b / cocos / editor - support / cocostudio / ActionTimeline / CCSkeletonNode . cpp <nl> void SkeletonNode : : onDraw ( const cocos2d : : Mat4 & transform , uint32_t flags ) <nl> <nl> cocos2d : : GL : : enableVertexAttribs ( cocos2d : : GL : : VERTEX_ATTRIB_FLAG_POSITION | cocos2d : : GL : : VERTEX_ATTRIB_FLAG_COLOR ) ; <nl> <nl> - / / <nl> - / / Attributes <nl> - / / <nl> - # ifdef EMSCRIPTEN <nl> - setGLBufferData ( _noMVPVertices , 8 * sizeof ( Vec3 ) , 0 ) ; <nl> - glVertexAttribPointer ( GLProgram : : VERTEX_ATTRIB_POSITION , 3 , GL_FLOAT , GL_FALSE , 0 , 0 ) ; <nl> - <nl> - setGLBufferData ( _squareColors , 8 * sizeof ( Color4F ) , 1 ) ; <nl> - glVertexAttribPointer ( GLProgram : : VERTEX_ATTRIB_COLOR , 4 , GL_FLOAT , GL_FALSE , 0 , 0 ) ; <nl> - # else <nl> glBindBuffer ( GL_ARRAY_BUFFER , 0 ) ; <nl> glVertexAttribPointer ( cocos2d : : GLProgram : : VERTEX_ATTRIB_POSITION , 3 , GL_FLOAT , GL_FALSE , 0 , _noMVPVertices ) ; <nl> glVertexAttribPointer ( cocos2d : : GLProgram : : VERTEX_ATTRIB_COLOR , 4 , GL_FLOAT , GL_FALSE , 0 , _squareColors ) ; <nl> - # endif / / EMSCRIPTEN <nl> <nl> cocos2d : : GL : : blendFunc ( _blendFunc . src , _blendFunc . dst ) ; <nl> <nl> mmm a / cocos / editor - support / cocostudio / WidgetReader / Node3DReader / Node3DReader . cpp <nl> ppp b / cocos / editor - support / cocostudio / WidgetReader / Node3DReader / Node3DReader . cpp <nl> namespace cocostudio <nl> node - > setScaleZ ( scale - > z ( ) ) ; <nl> } <nl> <nl> - node - > setCameraMask ( cameraMask , false ) ; <nl> + node - > setCameraMask ( cameraMask , true ) ; <nl> <nl> auto nodeReader = NodeReader : : getInstance ( ) ; <nl> nodeReader - > setPropsWithFlatBuffers ( node , ( Table * ) ( options - > nodeOptions ( ) ) ) ; <nl> mmm a / tests / cpp - tests / Classes / ExtensionsTest / CocoStudioActionTimelineTest / ActionTimelineTestScene . cpp <nl> ppp b / tests / cpp - tests / Classes / ExtensionsTest / CocoStudioActionTimelineTest / ActionTimelineTestScene . cpp <nl> void TestActionTimelineSkeleton : : onEnter ( ) <nl> { <nl> nestSkeleton - > removeFromParentAndCleanup ( false ) ; <nl> } <nl> - / / bug fixed while leftleg ' s child hide with leftleg ' s visible <nl> } ) ; <nl> } <nl> <nl> mmm a / web <nl> ppp b / web <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 18c6047a6f8952254cdbc6de7f120f8959af0ba7 <nl> + Subproject commit f26bb7a49e7ed37e43496c7edd0937a3c34a47d0 <nl> | Merge pull request from pandamicro / v3 | cocos2d/cocos2d-x | 8d836dade664a0c8e8424bda49e94af32e0a17c2 | 2015-08-03T14:12:05Z |
mmm a / tensorflow / python / ops / script_ops . py <nl> ppp b / tensorflow / python / ops / script_ops . py <nl> def log_huber ( x , m ) : <nl> <nl> @ deprecation . deprecated ( <nl> date = None , <nl> - instructions = " " " tf . py_func is deprecated in TF V2 . Instead , use <nl> - tf . py_function , which takes a python function which manipulates tf eager <nl> + instructions = " " " tf . py_func is deprecated in TF V2 . Instead , there are two <nl> + options available in V2 . <nl> + - tf . py_function takes a python function which manipulates tf eager <nl> tensors instead of numpy arrays . It ' s easy to convert a tf eager tensor to <nl> an ndarray ( just call tensor . numpy ( ) ) but having access to eager tensors <nl> means ` tf . py_function ` s can use accelerators such as GPUs as well as <nl> being differentiable using a gradient tape . <nl> + - tf . numpy_function maintains the semantics of the deprecated tf . py_func <nl> + ( it is not differentiable , and manipulates numpy arrays ) . It drops the <nl> + stateful argument making all functions stateful . <nl> " " " ) <nl> @ tf_export ( v1 = [ " py_func " ] ) <nl> def py_func ( func , inp , Tout , stateful = True , name = None ) : <nl> def my_func ( x ) : <nl> return _internal_py_func ( <nl> func = func , inp = inp , Tout = Tout , stateful = stateful , eager = False , name = name ) <nl> <nl> + @ tf_export ( " numpy_function " , v1 = [ ] ) <nl> + def numpy_function ( func , inp , Tout , name = None ) : <nl> + return py_func ( func , inp , Tout , stateful = True , name = name ) <nl> + <nl> + numpy_function . __doc__ = py_func . __doc__ . replace ( <nl> + " py_func " , " numpy_function " ) <nl> + <nl> <nl> ops . NotDifferentiable ( " PyFunc " ) <nl> ops . NotDifferentiable ( " PyFuncStateless " ) <nl> mmm a / tensorflow / tools / api / golden / v2 / tensorflow . pbtxt <nl> ppp b / tensorflow / tools / api / golden / v2 / tensorflow . pbtxt <nl> tf_module { <nl> name : " not_equal " <nl> argspec : " args = [ \ ' x \ ' , \ ' y \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' ] , " <nl> } <nl> + member_method { <nl> + name : " numpy_function " <nl> + argspec : " args = [ \ ' func \ ' , \ ' inp \ ' , \ ' Tout \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' ] , " <nl> + } <nl> member_method { <nl> name : " one_hot " <nl> argspec : " args = [ \ ' indices \ ' , \ ' depth \ ' , \ ' on_value \ ' , \ ' off_value \ ' , \ ' axis \ ' , \ ' dtype \ ' , \ ' name \ ' ] , varargs = None , keywords = None , defaults = [ \ ' None \ ' , \ ' None \ ' , \ ' None \ ' , \ ' None \ ' , \ ' None \ ' ] , " <nl> | Re - export py_func as numpy_function for V2 | tensorflow/tensorflow | 07cea8cc4ca430ded136bef94f247ffbd1207c46 | 2019-02-12T02:51:24Z |
mmm a / lib / SIL / AbstractionPattern . cpp <nl> ppp b / lib / SIL / AbstractionPattern . cpp <nl> AbstractionPattern AbstractionPattern : : getFunctionInputType ( ) const { <nl> AbstractionPattern <nl> AbstractionPattern : : getFunctionParamType ( unsigned index ) const { <nl> switch ( getKind ( ) ) { <nl> + case Kind : : Opaque : <nl> + return * this ; <nl> case Kind : : Type : { <nl> if ( isTypeParameter ( ) ) <nl> return AbstractionPattern : : getOpaque ( ) ; <nl> - auto fnType = cast < AnyFunctionType > ( getType ( ) ) ; <nl> - auto param = fnType . getParams ( ) [ index ] ; <nl> + auto params = cast < AnyFunctionType > ( getType ( ) ) . getParams ( ) ; <nl> + return AbstractionPattern ( getGenericSignatureForFunctionComponent ( ) , <nl> + params [ index ] . getParameterType ( ) ) ; <nl> + } <nl> + case Kind : : CFunctionAsMethodType : { <nl> + auto params = cast < AnyFunctionType > ( getType ( ) ) . getParams ( ) ; <nl> + assert ( params . size ( ) > 0 ) ; <nl> + <nl> + / / The last parameter is ' self ' . <nl> + if ( index = = params . size ( ) - 1 ) { <nl> + return getCFunctionAsMethodSelfPattern ( params . back ( ) . getParameterType ( ) ) ; <nl> + } <nl> + <nl> + / / A parameter of type ( ) does not correspond to a Clang parameter . <nl> + auto paramType = params [ index ] . getParameterType ( ) ; <nl> + if ( paramType - > isVoid ( ) ) <nl> + return AbstractionPattern ( paramType ) ; <nl> + <nl> + / / Otherwise , we ' re talking about the formal parameter clause . <nl> + / / Jump over the self parameter in the Clang type . <nl> + unsigned clangIndex = index ; <nl> + auto memberStatus = getImportAsMemberStatus ( ) ; <nl> + if ( memberStatus . isInstance ( ) & & clangIndex > = memberStatus . getSelfIndex ( ) ) <nl> + + + clangIndex ; <nl> + return AbstractionPattern ( getGenericSignatureForFunctionComponent ( ) , <nl> + paramType , <nl> + getClangFunctionParameterType ( getClangType ( ) , clangIndex ) ) ; <nl> + } <nl> + case Kind : : ObjCMethodType : { <nl> + auto params = cast < AnyFunctionType > ( getType ( ) ) . getParams ( ) ; <nl> + assert ( params . size ( ) > 0 ) ; <nl> + <nl> + / / The last parameter is ' self ' . <nl> + if ( index = = params . size ( ) - 1 ) { <nl> + return getObjCMethodSelfPattern ( params . back ( ) . getParameterType ( ) ) ; <nl> + } <nl> + <nl> + / / A parameter of type ( ) does not correspond to a Clang parameter . <nl> + auto paramType = params [ index ] . getParameterType ( ) ; <nl> + if ( paramType - > isVoid ( ) ) <nl> + return AbstractionPattern ( paramType ) ; <nl> + <nl> + / / Otherwise , we ' re talking about the formal parameter clause . <nl> + auto method = getObjCMethod ( ) ; <nl> + auto errorInfo = getEncodedForeignErrorInfo ( ) ; <nl> + <nl> + unsigned paramIndex = index ; <nl> + if ( errorInfo . hasErrorParameter ( ) ) { <nl> + auto errorParamIndex = errorInfo . getErrorParameterIndex ( ) ; <nl> + <nl> + if ( ! errorInfo . isErrorParameterReplacedWithVoid ( ) ) { <nl> + if ( paramIndex > = errorParamIndex ) { <nl> + paramIndex + + ; <nl> + } <nl> + } <nl> + } <nl> + <nl> return AbstractionPattern ( getGenericSignatureForFunctionComponent ( ) , <nl> - param . getParameterType ( ) ) ; <nl> + paramType , <nl> + method - > parameters ( ) [ paramIndex ] - > getType ( ) . getTypePtr ( ) ) ; <nl> + } <nl> + case Kind : : ClangType : { <nl> + auto params = cast < AnyFunctionType > ( getType ( ) ) . getParams ( ) ; <nl> + return AbstractionPattern ( getGenericSignatureForFunctionComponent ( ) , <nl> + params [ index ] . getParameterType ( ) , <nl> + getClangFunctionParameterType ( getClangType ( ) , index ) ) ; <nl> } <nl> default : <nl> / / FIXME : Re - implement this <nl> mmm a / lib / SIL / SILFunctionType . cpp <nl> ppp b / lib / SIL / SILFunctionType . cpp <nl> getUncachedSILFunctionTypeForConstant ( SILModule & M , <nl> / / pretend that it ' s import - as - member . <nl> if ( ! foreignInfo . Self . isImportAsMember ( ) & & <nl> isImporterGeneratedAccessor ( clangDecl , constant ) ) { <nl> - assert ( origLoweredInterfaceType - > getNumParams ( ) = = 2 ) ; <nl> - <nl> - / / The ' self ' parameter is still the second argument . <nl> unsigned selfIndex = cast < AccessorDecl > ( decl ) - > isSetter ( ) ? 1 : 0 ; <nl> - assert ( selfIndex = = 1 | | <nl> - origLoweredInterfaceType . getParams ( ) [ 0 ] . getType ( ) - > isVoid ( ) ) ; <nl> foreignInfo . Self . setSelfIndex ( selfIndex ) ; <nl> } <nl> <nl> TypeConverter : : getLoweredFormalTypes ( SILDeclRef constant , <nl> / / Replace the type in the abstraction pattern with the curried type . <nl> bridgingFnPattern . rewriteType ( genericSig , curried ) ; <nl> <nl> - / / Implode non - self parameters . <nl> - / / <nl> - / / FIXME : Remove this once AbstractionPattern is ported to the new <nl> - / / function type representation . <nl> - if ( bridgedParams . size ( ) ! = 1 | | <nl> - bridgedParams [ 0 ] . isVariadic ( ) ) { <nl> - bool hasInOut = false ; <nl> - for ( auto param : bridgedParams ) <nl> - hasInOut | = param . isInOut ( ) ; <nl> - <nl> - if ( ! hasInOut ) { <nl> - auto implodedParams = AnyFunctionType : : composeInput ( <nl> - Context , bridgedParams , true ) ; <nl> - bridgedParams . clear ( ) ; <nl> - bridgedParams . emplace_back ( implodedParams ) ; <nl> - } <nl> - } <nl> - <nl> / / Build the uncurried function type . <nl> if ( innerExtInfo . throws ( ) ) <nl> extInfo = extInfo . withThrows ( true ) ; <nl> | SIL : Don ' t implode parameters into a tuple in TypeConverter : : getLoweredFormalTypes ( ) | apple/swift | 8b73e0b27be0af032467168fbdf15c579a77554e | 2018-09-14T20:37:43Z |
mmm a / swoole_server . c <nl> ppp b / swoole_server . c <nl> PHP_METHOD ( swoole_server , bind ) <nl> / / connection is closed <nl> if ( conn - > active = = 0 ) <nl> { <nl> - swTrace ( " fd : % ld a : % d , uid : % ld " , fd , conn - > active , conn - > uid ) ; <nl> + swTrace ( " fd : % ld a : % d , uid : % d " , fd , conn - > active , conn - > uid ) ; <nl> RETURN_FALSE ; <nl> } <nl> <nl> | waring free . | swoole/swoole-src | bda36fbb882d367d0c26e9619fba9e12f963fb6a | 2017-02-07T07:27:45Z |
mmm a / util / mmap_posix . cpp <nl> ppp b / util / mmap_posix . cpp <nl> namespace mongo { <nl> theFileAllocator ( ) . allocateAsap ( filename , length ) ; <nl> len = length ; <nl> <nl> - massert ( 10446 , " mmap ( ) can ' t map area of size 0 " , length > 0 ) ; <nl> + massert ( 10446 , ( string ) " mmap ( ) can ' t map area of size 0 [ " + filename + " ] " , length > 0 ) ; <nl> <nl> <nl> fd = open ( filename , O_RDWR | O_NOATIME ) ; <nl> | better debugging for weird mmap issue | mongodb/mongo | 315995b8c7e3a5bd55d0248535bf5742bd7bdb7f | 2009-12-28T22:46:41Z |
mmm a / docs - translations / ko - KR / api / app . md <nl> ppp b / docs - translations / ko - KR / api / app . md <nl> Returns : <nl> <nl> 이 이벤트를 처리할 땐 반드시 ` event . preventDefault ( ) ` 를 호출해야 합니다 . <nl> <nl> - Windows에선 ` process . argv ` 를 통해 파일 경로를 얻을 수 있습니다 . <nl> + Windows에선 ` process . argv ` ( 메인 프로세스에서 ) 를 통해 파일 경로를 얻을 수 있습니다 . <nl> <nl> # # # Event : ' open - url ' _OS X_ <nl> <nl> mmm a / docs - translations / ko - KR / api / browser - window . md <nl> ppp b / docs - translations / ko - KR / api / browser - window . md <nl> Linux 플랫폼에선 Unity 데스크톱 환경만 지원합니다 . 그리고 <nl> 아이콘입니다 . ` null ` 로 지정하면 빈 오버레이가 사용됩니다 <nl> * ` description ` String - 접근성 설정에 의한 스크린 리더에 제공될 설명입니다 <nl> <nl> - 현재 작업표시줄 아이콘에 16px 크기의 오버레이를 지정합니다 . 보통 이 기능은 <nl> + 현재 작업표시줄 아이콘에 16 x 16 픽셀 크기의 오버레이를 지정합니다 . 보통 이 기능은 <nl> 어플리케이션의 여러 상태를 사용자에게 소극적으로 알리기 위한 방법으로 사용됩니다 . <nl> <nl> # # # ` win . setHasShadow ( hasShadow ) ` _OS X_ <nl> mmm a / docs - translations / ko - KR / api / clipboard . md <nl> ppp b / docs - translations / ko - KR / api / clipboard . md <nl> console . log ( clipboard . readText ( ' selection ' ) ) ; <nl> <nl> 클립보드에 ` image ` 를 씁니다 . <nl> <nl> + # # # ` clipboard . readRtf ( [ type ] ) ` <nl> + <nl> + * ` type ` String ( optional ) <nl> + <nl> + 클립보드로부터 RTF 형식으로 컨텐츠를 읽어옵니다 . <nl> + <nl> + # # # ` clipboard . writeRtf ( text [ , type ] ) ` <nl> + <nl> + * ` text ` String <nl> + * ` type ` String ( optional ) <nl> + <nl> + 클립보드에 ` text ` 를 RTF 형식으로 씁니다 . <nl> + <nl> # # # ` clipboard . clear ( [ type ] ) ` <nl> <nl> * ` type ` String ( optional ) <nl> mmm a / docs - translations / ko - KR / api / ipc - renderer . md <nl> ppp b / docs - translations / ko - KR / api / ipc - renderer . md <nl> <nl> <nl> 이벤트가 일어나면 ` event ` 객체와 임의의 인자와 함께 ` callback ` 함수가 호출됩니다 . <nl> <nl> - # # # ` ipcMain . removeListener ( channel , callback ) ` <nl> + # # # ` ipcRenderer . removeListener ( channel , callback ) ` <nl> <nl> * ` channel ` String - 이벤트의 이름 <nl> * ` callback ` Function - ` ipcMain . on ( channel , callback ) ` 에서 사용한 함수의 레퍼런스 <nl> <nl> 메시지 전송을 멈출수 없을 때 , 이 함수를 통해 지정한 채널에 대한 콜백을 삭제할 수 <nl> 있습니다 . <nl> <nl> - # # # ` ipcMain . removeAllListeners ( channel ) ` <nl> + # # # ` ipcRenderer . removeAllListeners ( channel ) ` <nl> <nl> * ` channel ` String - 이벤트의 이름 <nl> <nl> 이 ipc 채널에 등록된 * 모든 * 핸들러들을 삭제합니다 . <nl> <nl> - # # # ` ipcMain . once ( channel , callback ) ` <nl> + # # # ` ipcRenderer . once ( channel , callback ) ` <nl> <nl> - ` ipcMain . on ( ) ` 대신 이 함수를 사용할 경우 핸들러가 단 한 번만 호출됩니다 . <nl> + ` ipcRenderer . on ( ) ` 대신 이 함수를 사용할 경우 핸들러가 단 한 번만 호출됩니다 . <nl> ` callback ` 이 한 번 호출된 이후 활성화되지 않습니다 . <nl> <nl> # # 메시지 보내기 <nl> mmm a / docs - translations / ko - KR / api / session . md <nl> ppp b / docs - translations / ko - KR / api / session . md <nl> myWindow . webContents . session . setCertificateVerifyProc ( function ( hostname , cert , c <nl> * ` handler ` Function <nl> * ` webContents ` Object - [ WebContents ] ( web - contents . md ) 권한을 요청 . <nl> * ` permission ` String - ' media ' , ' geolocation ' , ' notifications ' , <nl> - ' midiSysex ' 의 나열 . <nl> + ' midiSysex ' , ' pointerLock ' , ' fullscreen ' 의 나열 . <nl> * ` callback ` Function - 권한 허용 및 거부 . <nl> <nl> ` session ` 의 권한 요청에 응답을 하는데 사용하는 핸들러를 설정합니다 . <nl> - ` callback ( ' granted ' ) ` 를 호출하면 권한 제공을 허용하고 ` callback ( ' denied ' ) ` 를 <nl> + ` callback ( true ) ` 를 호출하면 권한 제공을 허용하고 ` callback ( false ) ` 를 <nl> 호출하면 권한 제공을 거부합니다 . <nl> <nl> ` ` ` javascript <nl> session . fromPartition ( partition ) . setPermissionRequestHandler ( function ( webContents , permission , callback ) { <nl> if ( webContents . getURL ( ) = = = host ) { <nl> if ( permission = = " notifications " ) { <nl> - callback ( ) ; / / 거부됨 . <nl> + callback ( false ) ; / / 거부됨 . <nl> return ; <nl> } <nl> } <nl> <nl> - callback ( ' granted ' ) ; <nl> + callback ( true ) ; <nl> } ) ; <nl> ` ` ` <nl> <nl> mmm a / docs - translations / ko - KR / tutorial / application - distribution . md <nl> ppp b / docs - translations / ko - KR / tutorial / application - distribution . md <nl> electron / resources / <nl> <nl> # # # Windows <nl> <nl> - ` electron . exe ` 을 원하는 이름으로 변경할 수 있습니다 . <nl> - 그리고 [ rcedit ] ( https : / / github . com / atom / rcedit ) <nl> - 를 사용하여 아이콘을 변경할 수 있습니다 . <nl> + [ rcedit ] ( https : / / github . com / atom / rcedit ) 를 통해 ` electron . exe ` 을 원하는 이름으로 <nl> + 변경할 수 있고 , 또한 아이콘과 기타 정보도 변경할 수 있습니다 . <nl> <nl> # # # OS X <nl> <nl> mmm a / docs - translations / ko - KR / tutorial / using - selenium - and - webdriver . md <nl> ppp b / docs - translations / ko - KR / tutorial / using - selenium - and - webdriver . md <nl> var driver = new webdriver . Builder ( ) <nl> . withCapabilities ( { <nl> chromeOptions : { <nl> / / 여기에 사용중인 Electron 바이너리의 경로를 지정하세요 . <nl> - binary : ' / Path - to - Your - App . app / Contents / MacOS / Atom ' , <nl> + binary : ' / Path - to - Your - App . app / Contents / MacOS / Electron ' , <nl> } <nl> } ) <nl> . forBrowser ( ' electron ' ) <nl> | : memo : Update as upstream | electron/electron | f63d8b4d5ec2a139e616acd14330630fd254105d | 2016-02-15T02:05:29Z |
new file mode 100644 <nl> index 00000000000 . . 5acb17e46b7 <nl> mmm / dev / null <nl> ppp b / misc / format_server . py <nl> <nl> + import argparse <nl> + from http . server import HTTPServer , BaseHTTPRequestHandler <nl> + import requests <nl> + import subprocess <nl> + <nl> + <nl> + class TaichiFormatServer ( BaseHTTPRequestHandler ) : <nl> + <nl> + def _set_headers ( self ) : <nl> + self . send_response ( 200 ) <nl> + self . send_header ( " Content - type " , " text / html " ) <nl> + self . end_headers ( ) <nl> + <nl> + def _html ( self , message ) : <nl> + content = f " < html > < body > { message } < / body > < / html > " <nl> + return content . encode ( " utf8 " ) <nl> + <nl> + def writeln ( self , f ) : <nl> + self . wfile . write ( self . _html ( f + ' < br > ' ) ) <nl> + <nl> + def exec ( self , cmd ) : <nl> + self . writeln ( f " > > > { cmd } " ) <nl> + p = subprocess . getoutput ( cmd ) <nl> + for l in p . split ( ' \ n ' ) : <nl> + self . writeln ( l ) <nl> + <nl> + return p <nl> + <nl> + def do_GET ( self ) : <nl> + print ( self . path ) <nl> + path = self . path [ 1 : ] <nl> + self . _set_headers ( ) <nl> + if not path . isdigit ( ) : <nl> + self . writeln ( <nl> + " Error : Invalid input format . Usage example : https : / / server : 8000 / 12345 , where ' 12345 ' is the PR id " <nl> + ) <nl> + return <nl> + pr_id = int ( path ) <nl> + <nl> + ret = requests . get ( <nl> + f ' https : / / api . github . com / repos / taichi - dev / taichi / pulls / { pr_id } ' ) <nl> + if ret . status_code = = 404 : <nl> + self . writeln ( f " Error : PR { pr_id } not found ! " ) <nl> + return <nl> + ret = ret . json ( ) <nl> + url = ret [ ' url ' ] <nl> + <nl> + self . writeln ( <nl> + f " Processing < a href = ' https : / / github . com / taichi - dev / taichi / pull / { pr_id } ' > PR { pr_id } < / a > " <nl> + ) <nl> + self . writeln ( f " [ < a href = ' { url } ' > Metadata < / a > ] " ) <nl> + head = ret [ " head " ] <nl> + repo_url = head [ " repo " ] [ " html_url " ] <nl> + sha = head [ " sha " ] <nl> + self . writeln ( f " repo url { repo_url } " ) <nl> + self . writeln ( f " head commit id { sha } " ) <nl> + num_commits = int ( ret [ " commits " ] ) <nl> + self . writeln ( f " # commits id { num_commits } " ) <nl> + <nl> + commits = self . exec ( f ' git log - n { num_commits + 1 } - - format = " % H " ' ) . split ( <nl> + ' \ n ' ) <nl> + fork_commit = commits [ num_commits - 1 ] <nl> + user_id = ret [ ' user ' ] [ ' login ' ] <nl> + branch_name = head [ ' ref ' ] <nl> + ssh_url = head [ ' repo ' ] [ ' ssh_url ' ] <nl> + self . exec ( f ' git remote add { user_id } { ssh_url } ' ) <nl> + self . exec ( f ' git fetch { user_id } { branch_name } ' ) <nl> + self . exec ( f ' git branch - d { user_id } - { branch_name } ' ) <nl> + self . exec ( <nl> + f ' git checkout - b { user_id } - { branch_name } { user_id } / { branch_name } ' ) <nl> + self . exec ( f ' ti format { fork_commit } ' ) <nl> + self . exec ( ' git add - - all ' ) <nl> + self . exec ( f ' git commit - m " [ skip ci ] enforce code format " ' ) <nl> + self . exec ( f ' git push { user_id } { user_id } - { branch_name } : { branch_name } ' ) <nl> + <nl> + # self . exec ( f ' git checkout master ' ) <nl> + def x ( ) : <nl> + a = 1 <nl> + <nl> + <nl> + def run ( addr , port ) : <nl> + server_address = ( addr , port ) <nl> + httpd = HTTPServer ( server_address , TaichiFormatServer ) <nl> + print ( f " Starting Taichi format server on { addr } : { port } " ) <nl> + httpd . serve_forever ( ) <nl> + <nl> + <nl> + if __name__ = = " __main__ " : <nl> + parser = argparse . ArgumentParser ( description = " Run the Taichi format server " ) <nl> + parser . add_argument ( <nl> + " - l " , <nl> + " - - listen " , <nl> + default = " localhost " , <nl> + help = " Specify the IP address on which the server listens " , <nl> + ) <nl> + parser . add_argument ( <nl> + " - p " , <nl> + " - - port " , <nl> + type = int , <nl> + default = 8000 , <nl> + help = " Port on which the server listens " , <nl> + ) <nl> + args = parser . parse_args ( ) <nl> + run ( addr = args . listen , port = args . port ) <nl> mmm a / python / taichi / core / util . py <nl> ppp b / python / taichi / core / util . py <nl> def print_red_bold ( * args , * * kwargs ) : <nl> print ( Style . RESET_ALL , end = ' ' ) <nl> <nl> <nl> - def format ( all = False ) : <nl> + def format ( all = False , diff = None ) : <nl> import os <nl> import taichi as tc <nl> from yapf . yapflib . yapf_api import FormatFile <nl> def format ( all = False ) : <nl> for d in directories : <nl> files + = list ( Path ( os . path . join ( tc . get_repo_directory ( ) , d ) ) . rglob ( ' * ' ) ) <nl> else : <nl> - files = repo . index . diff ( ' HEAD ' ) <nl> + if diff is None : <nl> + files = repo . index . diff ( ' HEAD ' ) <nl> + else : <nl> + files = repo . index . diff ( diff ) <nl> files = list ( <nl> map ( lambda x : os . path . join ( tc . get_repo_directory ( ) , x . a_path ) , files ) ) <nl> <nl> mmm a / python / taichi / main . py <nl> ppp b / python / taichi / main . py <nl> def main ( debug = False ) : <nl> elif mode = = " build " : <nl> ti . core . build ( ) <nl> elif mode = = " format " : <nl> - ti . core . format ( ) <nl> + diff = None <nl> + if len ( sys . argv ) > = 3 : <nl> + diff = sys . argv [ 2 ] <nl> + ti . core . format ( diff = diff ) <nl> elif mode = = " format_all " : <nl> ti . core . format ( all = True ) <nl> elif mode = = " statement " : <nl> | Format server script ( ) | taichi-dev/taichi | 642bc93115800f7bb79ff2b6b147277a4b70680d | 2020-03-14T01:44:51Z |
mmm a / tensorflow / python / keras / activations . py <nl> ppp b / tensorflow / python / keras / activations . py <nl> def sigmoid ( x ) : <nl> the result of the function gets close to 1 . <nl> <nl> Sigmoid is equivalent to a 2 - element Softmax , where the second element is <nl> - assumed to be zero . The sigmoid function always returns a value between 0 and 1 . <nl> + assumed to be zero . The sigmoid function always returns a value between <nl> + 0 and 1 . <nl> <nl> For example : <nl> <nl> | Update activations . py | tensorflow/tensorflow | e8b2a8950245d04d8f56844945a29c4dfdfd68f1 | 2020-04-02T19:36:02Z |
mmm a / cmake / Modules / Platform / Emscripten . cmake <nl> ppp b / cmake / Modules / Platform / Emscripten . cmake <nl> endif ( ) <nl> <nl> # In order for check_function_exists ( ) detection to work , we must signal it to pass an additional flag , which causes the compilation <nl> # to abort if linking results in any undefined symbols . The CMake detection mechanism depends on the undefined symbol error to be raised . <nl> - set ( CMAKE_REQUIRED_FLAGS " - s ERROR_ON_UNDEFINED_SYMBOLS = 1 " ) <nl> + # Disable wasm in cmake checks so that ( 1 ) we do not depend on wasm support just for configuration ( perhaps the user does not intend <nl> + # to build to wasm ; using asm . js only depends on js which we need anyhow ) , and ( 2 ) we don ' t have issues with a separate . wasm file <nl> + # on the side , async startup , etc . . <nl> + set ( CMAKE_REQUIRED_FLAGS " - s ERROR_ON_UNDEFINED_SYMBOLS = 1 - s WASM = 0 " ) <nl> <nl> # Locate where the Emscripten compiler resides in relative to this toolchain file . <nl> if ( " $ { EMSCRIPTEN_ROOT_PATH } " STREQUAL " " ) <nl> mmm a / embuilder . py <nl> ppp b / embuilder . py <nl> def build_port ( port_name , lib_name , params ) : <nl> } <nl> ' ' ' , [ ' gl . bc ' ] ) <nl> elif what = = ' native_optimizer ' : <nl> - build ( C_BARE , [ ' optimizer . 2 . exe ' ] , [ ' - O2 ' ] ) <nl> + build ( C_BARE , [ ' optimizer . 2 . exe ' ] , [ ' - O2 ' , ' - s ' , ' WASM = 0 ' ] ) <nl> elif what = = ' wasm_compiler_rt ' : <nl> if shared . Settings . WASM_BACKEND : <nl> build ( C_BARE , [ ' wasm_compiler_rt . a ' ] , [ ' - s ' , ' WASM = 1 ' ] ) <nl> mmm a / emcc . py <nl> ppp b / emcc . py <nl> def filter_emscripten_options ( argv ) : <nl> cmd + = [ ' - s ' , ' ERROR_ON_UNDEFINED_SYMBOLS = 1 ' ] # configure tests should fail when an undefined symbol exists <nl> cmd + = [ ' - s ' , ' NO_EXIT_RUNTIME = 0 ' ] # configure tests want a more shell - like style , where we emit return codes on exit ( ) <nl> cmd + = [ ' - s ' , ' NODERAWFS = 1 ' ] # use node . js raw filesystem access , to behave just like a native executable <nl> + # Disable wasm in configuration checks so that ( 1 ) we do not depend on wasm support just for configuration ( perhaps the user does not intend <nl> + # to build to wasm ; using asm . js only depends on js which we need anyhow ) , and ( 2 ) we don ' t have issues with a separate . wasm file <nl> + # on the side , async startup , etc . . <nl> + cmd + = [ ' - s ' , ' WASM = 0 ' ] <nl> <nl> logging . debug ( ' just configuring : ' + ' ' . join ( cmd ) ) <nl> if debug_configure : open ( tempout , ' a ' ) . write ( ' emcc , just configuring : ' + ' ' . join ( cmd ) + ' \ n \ n ' ) <nl> def detect_fixed_language_mode ( args ) : <nl> assert key ! = ' WASM_BACKEND ' , ' do not set - s WASM_BACKEND , instead set EMCC_WASM_BACKEND = 1 in the environment ' <nl> newargs = [ arg for arg in newargs if arg is not ' ' ] <nl> <nl> - # Handle aliases in settings flags <nl> + # Handle aliases in settings flags . These are settings whose name <nl> + # has changed . <nl> settings_aliases = { <nl> + ' BINARYEN ' : ' WASM ' , <nl> ' BINARYEN_MEM_MAX ' : ' WASM_MEM_MAX ' , <nl> # TODO : change most ( all ? ) other BINARYEN * names to WASM * <nl> } <nl> def check ( input_file ) : <nl> if shared . Settings . EMULATE_FUNCTION_POINTER_CASTS : <nl> shared . Settings . ALIASING_FUNCTION_POINTERS = 0 <nl> <nl> + if shared . Settings . LEGACY_VM_SUPPORT : <nl> + # legacy vms don ' t have wasm <nl> + shared . Settings . WASM = 0 <nl> + <nl> if shared . Settings . SPLIT_MEMORY : <nl> + if shared . Settings . WASM : <nl> + logging . error ( ' WASM is not compatible with SPLIT_MEMORY ' ) <nl> + sys . exit ( 1 ) <nl> assert shared . Settings . SPLIT_MEMORY > shared . Settings . TOTAL_STACK , ' SPLIT_MEMORY must be at least TOTAL_STACK ( stack must fit in first chunk ) ' <nl> assert shared . Settings . SPLIT_MEMORY & ( shared . Settings . SPLIT_MEMORY - 1 ) = = 0 , ' SPLIT_MEMORY must be a power of 2 ' <nl> if shared . Settings . ASM_JS = = 1 : <nl> def check ( input_file ) : <nl> newargs . append ( ' - DSTB_IMAGE_IMPLEMENTATION ' ) <nl> <nl> if shared . Settings . ASMFS and final_suffix in JS_CONTAINING_SUFFIXES : <nl> + if shared . Settings . WASM : <nl> + logging . error ( ' ASMFS not yet compatible with wasm ( shared . make_fetch_worker is asm . js - specific ) ' ) <nl> + sys . exit ( 1 ) <nl> input_files . append ( ( next_arg_index , shared . path_from_root ( ' system ' , ' lib ' , ' fetch ' , ' asmfs . cpp ' ) ) ) <nl> newargs . append ( ' - D__EMSCRIPTEN_ASMFS__ = 1 ' ) <nl> next_arg_index + = 1 <nl> def check ( input_file ) : <nl> exit_with_error ( ' - s ASMFS = 1 requires either - s USE_PTHREADS = 1 or - s USE_PTHREADS = 2 to be set ! ' ) <nl> <nl> if shared . Settings . FETCH and final_suffix in JS_CONTAINING_SUFFIXES : <nl> + if shared . Settings . WASM : <nl> + logging . error ( ' FETCH not yet compatible with wasm ( shared . make_fetch_worker is asm . js - specific ) ' ) <nl> + sys . exit ( 1 ) <nl> input_files . append ( ( next_arg_index , shared . path_from_root ( ' system ' , ' lib ' , ' fetch ' , ' emscripten_fetch . cpp ' ) ) ) <nl> next_arg_index + = 1 <nl> options . js_libraries . append ( shared . path_from_root ( ' src ' , ' library_fetch . js ' ) ) <nl> def check ( input_file ) : <nl> options . js_opts = True <nl> options . force_js_opts = True <nl> <nl> - if shared . Settings . BINARYEN : <nl> - shared . Settings . WASM = 1 # these are synonyms <nl> - <nl> if shared . Settings . WASM : <nl> - shared . Settings . BINARYEN = 1 # these are synonyms <nl> - <nl> # When only targeting wasm , the . asm . js file is not executable , so is treated as an intermediate build file that can be cleaned up . <nl> if shared . Building . is_wasm_only ( ) : <nl> asm_target = asm_target . replace ( ' . asm . js ' , ' . temp . asm . js ' ) <nl> def check ( input_file ) : <nl> <nl> if shared . Settings . TOTAL_MEMORY < 16 * 1024 * 1024 : <nl> exit_with_error ( ' TOTAL_MEMORY must be at least 16MB , was ' + str ( shared . Settings . TOTAL_MEMORY ) ) <nl> - if shared . Settings . BINARYEN : <nl> + if shared . Settings . WASM : <nl> if shared . Settings . TOTAL_MEMORY % 65536 ! = 0 : <nl> exit_with_error ( ' For wasm , TOTAL_MEMORY must be a multiple of 64KB , was ' + str ( shared . Settings . TOTAL_MEMORY ) ) <nl> else : <nl> def check ( input_file ) : <nl> <nl> if shared . Settings . WASM_BACKEND : <nl> options . js_opts = None <nl> - shared . Settings . BINARYEN = shared . Settings . WASM = 1 <nl> + shared . Settings . WASM = 1 <nl> <nl> # wasm backend output can benefit from the binaryen optimizer ( in asm2wasm , <nl> # we run the optimizer during asm2wasm itself ) . use it , if not overridden <nl> def check ( input_file ) : <nl> # to bootstrap struct_info , we need binaryen <nl> os . environ [ ' EMCC_WASM_BACKEND_BINARYEN ' ] = ' 1 ' <nl> <nl> - if shared . Settings . BINARYEN : <nl> + if shared . Settings . WASM : <nl> if shared . Settings . SINGLE_FILE : <nl> # placeholder strings for JS glue , to be replaced with subresource locations in do_binaryen <nl> shared . Settings . WASM_TEXT_FILE = shared . FilenameReplacementStrings . WASM_TEXT_FILE <nl> def check ( input_file ) : <nl> ' interpret - asm2wasm ' not in shared . Settings . BINARYEN_METHOD and \ <nl> not shared . Settings . USE_PTHREADS <nl> <nl> + # wasm side modules have suffix . wasm <nl> + if shared . Settings . SIDE_MODULE and target . endswith ( ' . js ' ) : <nl> + logging . warning ( ' output suffix . js requested , but wasm side modules are just wasm files ; emitting only a . wasm , no . js ' ) <nl> + <nl> + if options . separate_asm : <nl> + logging . error ( ' cannot - - separate - asm when emitting wasm , since not emitting asm . js ' ) <nl> + sys . exit ( 1 ) <nl> + <nl> # wasm outputs are only possible with a side wasm <nl> if target . endswith ( WASM_ENDINGS ) : <nl> - if not ( shared . Settings . BINARYEN and shared . Settings . SIDE_MODULE ) : <nl> + if not ( shared . Settings . WASM and shared . Settings . SIDE_MODULE ) : <nl> logging . warning ( ' output file " % s " has a wasm suffix , but we cannot emit wasm by itself , except as a dynamic library ( see SIDE_MODULE option ) . specify an output file with suffix . js or . html , and a wasm file will be created on the side ' % target ) <nl> return 1 <nl> <nl> if shared . Settings . EVAL_CTORS : <nl> - if not shared . Settings . BINARYEN : <nl> + if not shared . Settings . WASM : <nl> # for asm . js : this option is not a js optimizer pass , but does run the js optimizer internally , so <nl> # we need to generate proper code for that ( for wasm , we run a binaryen tool for this ) <nl> shared . Settings . RUNNING_JS_OPTS = 1 <nl> def check ( input_file ) : <nl> <nl> if shared . Settings . CYBERDWARF : <nl> newargs . append ( ' - g ' ) <nl> + options . debug_level = max ( options . debug_level , 2 ) <nl> shared . Settings . BUNDLED_CD_DEBUG_FILE = target + " . cd " <nl> options . js_libraries . append ( shared . path_from_root ( ' src ' , ' library_cyberdwarf . js ' ) ) <nl> options . js_libraries . append ( shared . path_from_root ( ' src ' , ' library_debugger_toolkit . js ' ) ) <nl> def repl ( m ) : <nl> if DEBUG : <nl> # Copy into temp dir as well , so can be run there too <nl> shared . safe_copy ( memfile , os . path . join ( shared . get_emscripten_temp_dir ( ) , os . path . basename ( memfile ) ) ) <nl> - if not shared . Settings . BINARYEN or not shared . Settings . MEM_INIT_IN_WASM : <nl> + if not shared . Settings . WASM or not shared . Settings . MEM_INIT_IN_WASM : <nl> return ' memoryInitializer = " % s " ; ' % shared . JS . get_subresource_location ( memfile , embed_memfile ( options ) ) <nl> else : <nl> return ' ' <nl> def get_eliminate ( ) : <nl> # with commaified code breaks late aggressive variable elimination ) <nl> # do not do this with binaryen , as commaifying confuses binaryen call type detection ( FIXME , in theory , but unimportant ) <nl> debugging = options . debug_level = = 0 or options . profiling <nl> - if shared . Settings . SIMPLIFY_IFS and debugging and shared . Settings . OUTLINING_LIMIT = = 0 and not shared . Settings . BINARYEN : <nl> + if shared . Settings . SIMPLIFY_IFS and debugging and shared . Settings . OUTLINING_LIMIT = = 0 and not shared . Settings . WASM : <nl> optimizer . queue + = [ ' simplifyIfs ' ] <nl> <nl> if shared . Settings . PRECISE_F32 : optimizer . queue + = [ ' optimizeFrounds ' ] <nl> def get_eliminate ( ) : <nl> optimizer . flush ( ) <nl> shared . Building . eliminate_duplicate_funcs ( final ) <nl> <nl> - if shared . Settings . EVAL_CTORS and options . memory_init_file and options . debug_level < 4 and not shared . Settings . BINARYEN : <nl> + if shared . Settings . EVAL_CTORS and options . memory_init_file and options . debug_level < 4 and not shared . Settings . WASM : <nl> optimizer . flush ( ) <nl> shared . Building . eval_ctors ( final , memfile ) <nl> if DEBUG : save_intermediate ( ' eval - ctors ' , ' js ' ) <nl> <nl> if options . js_opts : <nl> # some compilation modes require us to minify later or not at all <nl> - if not shared . Settings . EMTERPRETIFY and not shared . Settings . BINARYEN : <nl> + if not shared . Settings . EMTERPRETIFY and not shared . Settings . WASM : <nl> optimizer . do_minify ( ) <nl> <nl> if options . opt_level > = 2 : <nl> def get_eliminate ( ) : <nl> if shared . Settings . CYBERDWARF : <nl> execute ( [ shared . PYTHON , shared . path_from_root ( ' tools ' , ' emdebug_cd_merger . py ' ) , target + ' . cd ' , target + ' . symbols ' ] ) <nl> <nl> - if options . debug_level > = 4 and not shared . Settings . BINARYEN : <nl> + if options . debug_level > = 4 and not shared . Settings . WASM : <nl> emit_js_source_maps ( target , optimizer . js_transform_tempfiles ) <nl> <nl> # track files that will need native eols <nl> generated_text_files_with_native_eols = [ ] <nl> - if ( options . separate_asm or shared . Settings . BINARYEN ) and not shared . Settings . WASM_BACKEND : <nl> + <nl> + if ( options . separate_asm or shared . Settings . WASM ) and not shared . Settings . WASM_BACKEND : <nl> separate_asm_js ( final , asm_target ) <nl> generated_text_files_with_native_eols + = [ asm_target ] <nl> <nl> - if shared . Settings . BINARYEN : <nl> + if shared . Settings . WASM : <nl> binaryen_method_sanity_check ( ) <nl> do_binaryen ( target , asm_target , options , memfile , wasm_binary_target , <nl> wasm_text_target , misc_temp_files , optimizer ) <nl> def emterpretify ( js_target , optimizer , options ) : <nl> # minify ( if requested ) after emterpreter processing , and finalize output <nl> logging . debug ( ' finalizing emterpreted code ' ) <nl> shared . Settings . FINALIZE_ASM_JS = 1 <nl> - if not shared . Settings . BINARYEN : <nl> + if not shared . Settings . WASM : <nl> optimizer . do_minify ( ) <nl> optimizer . queue + = [ ' last ' ] <nl> optimizer . flush ( ' finalizing - emterpreted - code ' ) <nl> def emterpretify ( js_target , optimizer , options ) : <nl> original = js_target + ' . orig . js ' # the emterpretify tool saves the original here <nl> final = original <nl> logging . debug ( ' finalizing original ( non - emterpreted ) code at ' + final ) <nl> - if not shared . Settings . BINARYEN : <nl> + if not shared . Settings . WASM : <nl> optimizer . do_minify ( ) <nl> optimizer . queue + = [ ' last ' ] <nl> optimizer . flush ( ' finalizing - original - code ' ) <nl> def generate_html ( target , options , js_target , target_basename , <nl> <nl> # Download . asm . js if - - separate - asm was passed in an asm . js build , or if ' asmjs ' is one <nl> # of the wasm run methods . <nl> - if not options . separate_asm or ( shared . Settings . BINARYEN and ' asmjs ' not in shared . Settings . BINARYEN_METHOD ) : <nl> + if not options . separate_asm or ( shared . Settings . WASM and ' asmjs ' not in shared . Settings . BINARYEN_METHOD ) : <nl> assert len ( asm_mods ) = = 0 , ' no - - separate - asm means no client code mods are possible ' <nl> else : <nl> script . un_src ( ) <nl> def generate_html ( target , options , js_target , target_basename , <nl> codeXHR . send ( null ) ; <nl> ' ' ' % ( shared . JS . get_subresource_location ( asm_target ) , ' \ n ' . join ( asm_mods ) , script . inline ) <nl> <nl> - if shared . Settings . BINARYEN and not shared . Settings . BINARYEN_ASYNC_COMPILATION : <nl> + if shared . Settings . WASM and not shared . Settings . BINARYEN_ASYNC_COMPILATION : <nl> # We need to load the wasm file before anything else , it has to be synchronously ready TODO : optimize <nl> script . un_src ( ) <nl> script . inline = ' ' ' <nl> mmm a / emscripten . py <nl> ppp b / emscripten . py <nl> def create_backend_args ( infile , temp_js , settings ) : <nl> args + = [ ' - emscripten - asyncify - whitelist = ' + ' , ' . join ( settings [ ' ASYNCIFY_WHITELIST ' ] ) ] <nl> if settings [ ' NO_EXIT_RUNTIME ' ] : <nl> args + = [ ' - emscripten - no - exit - runtime ' ] <nl> - if settings [ ' BINARYEN ' ] : <nl> + if settings [ ' WASM ' ] : <nl> args + = [ ' - emscripten - wasm ' ] <nl> if shared . Building . is_wasm_only ( ) : <nl> args + = [ ' - emscripten - only - wasm ' ] <nl> def memory_and_global_initializers ( pre , metadata , mem_init , settings ) : <nl> <nl> if settings [ ' SIDE_MODULE ' ] : <nl> pre = pre . replace ( ' GLOBAL_BASE ' , ' gb ' ) <nl> - if settings [ ' SIDE_MODULE ' ] or settings [ ' BINARYEN ' ] : <nl> + if settings [ ' SIDE_MODULE ' ] or settings [ ' WASM ' ] : <nl> pre = pre . replace ( ' { { { STATIC_BUMP } } } ' , str ( staticbump ) ) <nl> <nl> return pre <nl> def get_exported_implemented_functions ( all_exported_functions , all_implemented , <nl> funcs + = [ ' setDynamicTop ' ] <nl> if not settings [ ' RELOCATABLE ' ] : <nl> funcs + = [ ' setTempRet0 ' , ' getTempRet0 ' ] <nl> - if not ( settings [ ' BINARYEN ' ] and settings [ ' SIDE_MODULE ' ] ) : <nl> + if not ( settings [ ' WASM ' ] and settings [ ' SIDE_MODULE ' ] ) : <nl> funcs + = [ ' setThrew ' ] <nl> if settings [ ' EMTERPRETIFY ' ] : <nl> funcs + = [ ' emterpret ' ] <nl> def proxy_debug_print ( call_type , settings ) : <nl> return ' ' <nl> <nl> def include_asm_consts ( pre , forwarded_json , metadata , settings ) : <nl> - if settings [ ' BINARYEN ' ] and settings [ ' SIDE_MODULE ' ] : <nl> + if settings [ ' WASM ' ] and settings [ ' SIDE_MODULE ' ] : <nl> assert len ( metadata [ ' asmConsts ' ] ) = = 0 , ' EM_ASM is not yet supported in shared wasm module ( it cannot be stored in the wasm itself , need some solution ) ' <nl> <nl> asm_consts , all_sigs , call_types = all_asm_consts ( metadata ) <nl> asm_const_funcs = [ ] <nl> for s in range ( len ( all_sigs ) ) : <nl> sig = all_sigs [ s ] <nl> + if ' j ' in sig : <nl> + logging . error ( ' emscript : EM_ASM should not receive i64s as inputs , they are not valid in JS ' ) <nl> + sys . exit ( 1 ) <nl> call_type = call_types [ s ] if s < len ( call_types ) else ' ' <nl> if ' _emscripten_asm_const_ ' + call_type + sig in forwarded_json [ ' Functions ' ] [ ' libraryFunctions ' ] : continue # Only one invoker needs to be emitted for each ASM_CONST ( signature x call_type ) item <nl> forwarded_json [ ' Functions ' ] [ ' libraryFunctions ' ] [ ' _emscripten_asm_const_ ' + call_type + sig ] = 1 <nl> def make_emulated_param ( i ) : <nl> # when emulating function pointers , we don ' t need wrappers <nl> # but if relocating , then we also have the copies in - module , and do <nl> # in wasm we never need wrappers though <nl> - if clean_item not in implemented_functions and not ( settings [ ' EMULATED_FUNCTION_POINTERS ' ] and not settings [ ' RELOCATABLE ' ] ) and not settings [ ' BINARYEN ' ] : <nl> + if clean_item not in implemented_functions and not ( settings [ ' EMULATED_FUNCTION_POINTERS ' ] and not settings [ ' RELOCATABLE ' ] ) and not settings [ ' WASM ' ] : <nl> # this is imported into asm , we must wrap it <nl> call_ident = clean_item <nl> if call_ident in metadata [ ' redirects ' ] : call_ident = metadata [ ' redirects ' ] [ call_ident ] <nl> def make_function_tables_impls ( function_table_data , settings ) : <nl> def create_mftCall_funcs ( function_table_data , settings ) : <nl> mftCall_funcs = [ ] <nl> if settings [ ' EMULATED_FUNCTION_POINTERS ' ] : <nl> - if settings [ ' RELOCATABLE ' ] and not settings [ ' BINARYEN ' ] : # in wasm , emulated function pointers are just simple table calls <nl> + if settings [ ' RELOCATABLE ' ] and not settings [ ' WASM ' ] : # in wasm , emulated function pointers are just simple table calls <nl> for sig , table in function_table_data . items ( ) : <nl> params = ' , ' . join ( [ ' ptr ' ] + [ ' p % d ' % p for p in range ( len ( sig ) - 1 ) ] ) <nl> coerced_params = ' , ' . join ( [ shared . JS . make_coercion ( ' ptr ' , ' i ' , settings ) ] + [ shared . JS . make_coercion ( ' p % d ' , unfloat ( sig [ p + 1 ] ) , settings ) % p for p in range ( len ( sig ) - 1 ) ] ) <nl> def create_asm_global_funcs ( bg_funcs , metadata , settings ) : <nl> def create_asm_global_vars ( bg_vars , settings ) : <nl> access_quote = access_quoter ( settings ) <nl> asm_global_vars = ' ' . join ( [ ' var ' + g + ' = env ' + access_quote ( g ) + ' | 0 ; \ n ' for g in bg_vars ] ) <nl> - if settings [ ' BINARYEN ' ] and settings [ ' SIDE_MODULE ' ] : <nl> + if settings [ ' WASM ' ] and settings [ ' SIDE_MODULE ' ] : <nl> # wasm side modules internally define their stack , these are set at module startup time <nl> asm_global_vars + = ' \ n var STACKTOP = 0 , STACK_MAX = 0 ; \ n ' <nl> <nl> def create_asm_setup ( debug_tables , function_table_data , metadata , settings ) : <nl> if settings [ ' ASSERTIONS ' ] : <nl> for sig in function_table_sigs : <nl> asm_setup + = ' \ nfunction nullFunc_ ' + sig + ' ( x ) { ' + get_function_pointer_error ( sig , function_table_sigs , settings ) + ' abort ( x ) } \ n ' <nl> - if settings [ ' BINARYEN ' ] : <nl> + if settings [ ' WASM ' ] : <nl> def table_size ( table ) : <nl> table_contents = table [ table . index ( ' [ ' ) + 1 : table . index ( ' ] ' ) ] <nl> if len ( table_contents ) = = 0 : # empty table <nl> def create_basic_funcs ( function_table_sigs , settings ) : <nl> if settings [ ' RESERVED_FUNCTION_POINTERS ' ] : <nl> basic_funcs . append ( ' jsCall_ % s ' % sig ) <nl> if settings [ ' EMULATED_FUNCTION_POINTERS ' ] : <nl> - if not settings [ ' BINARYEN ' ] : # in wasm , emulated function pointers are just simple table calls <nl> + if not settings [ ' WASM ' ] : # in wasm , emulated function pointers are just simple table calls <nl> basic_funcs . append ( ' ftCall_ % s ' % sig ) <nl> return basic_funcs <nl> <nl> <nl> def create_basic_vars ( exported_implemented_functions , forwarded_json , metadata , settings ) : <nl> basic_vars = [ ' DYNAMICTOP_PTR ' , ' tempDoublePtr ' , ' ABORT ' ] <nl> - if not ( settings [ ' BINARYEN ' ] and settings [ ' SIDE_MODULE ' ] ) : <nl> + if not ( settings [ ' WASM ' ] and settings [ ' SIDE_MODULE ' ] ) : <nl> basic_vars + = [ ' STACKTOP ' , ' STACK_MAX ' ] <nl> if metadata . get ( ' preciseI64MathUsed ' ) : <nl> basic_vars + = [ ' cttz_i8 ' ] <nl> def create_basic_vars ( exported_implemented_functions , forwarded_json , metadata , <nl> if forwarded_json [ ' Functions ' ] [ ' libraryFunctions ' ] . get ( ' _llvm_cttz_i32 ' ) : <nl> basic_vars + = [ ' cttz_i8 ' ] <nl> if settings [ ' RELOCATABLE ' ] : <nl> - if not ( settings [ ' BINARYEN ' ] and settings [ ' SIDE_MODULE ' ] ) : <nl> + if not ( settings [ ' WASM ' ] and settings [ ' SIDE_MODULE ' ] ) : <nl> basic_vars + = [ ' gb ' , ' fb ' ] <nl> else : <nl> basic_vars + = [ ' memoryBase ' , ' tableBase ' ] # wasm side modules have a specific convention for these <nl> def create_exports ( exported_implemented_functions , in_table , function_table_data <nl> <nl> def create_asm_runtime_funcs ( settings ) : <nl> funcs = [ ] <nl> - if not ( settings [ ' BINARYEN ' ] and settings [ ' SIDE_MODULE ' ] ) : <nl> + if not ( settings [ ' WASM ' ] and settings [ ' SIDE_MODULE ' ] ) : <nl> funcs + = [ ' stackAlloc ' , ' stackSave ' , ' stackRestore ' , ' establishStackSpace ' , ' setThrew ' ] <nl> if not settings [ ' RELOCATABLE ' ] : <nl> funcs + = [ ' setTempRet0 ' , ' getTempRet0 ' ] <nl> def create_receiving ( function_table_data , function_tables_defs , exported_impleme <nl> receiving + = ' Module [ " asm " ] = asm ; \ n ' + ' ; \ n ' . join ( [ ' var ' + s + ' = Module [ " ' + s + ' " ] = function ( ) { ' + runtime_assertions + ' return Module [ " asm " ] [ " ' + s + ' " ] . apply ( null , arguments ) } ' for s in exported_implemented_functions + function_tables ( function_table_data , settings ) ] ) <nl> receiving + = ' ; \ n ' <nl> <nl> - if settings [ ' EXPORT_FUNCTION_TABLES ' ] and not settings [ ' BINARYEN ' ] : <nl> + if settings [ ' EXPORT_FUNCTION_TABLES ' ] and not settings [ ' WASM ' ] : <nl> for table in function_table_data . values ( ) : <nl> tableName = table . split ( ) [ 1 ] <nl> table = table . replace ( ' var ' + tableName , ' var ' + tableName + ' = Module [ " ' + tableName + ' " ] ' ) <nl> def create_receiving ( function_table_data , function_tables_defs , exported_impleme <nl> <nl> if settings [ ' EMULATED_FUNCTION_POINTERS ' ] : <nl> receiving + = ' \ n ' + function_tables_defs . replace ( ' / / EMSCRIPTEN_END_FUNCS \ n ' , ' ' ) + ' \ n ' + ' ' . join ( [ ' Module [ " dynCall_ % s " ] = dynCall_ % s \ n ' % ( sig , sig ) for sig in function_table_data ] ) <nl> - if not settings [ ' BINARYEN ' ] : <nl> + if not settings [ ' WASM ' ] : <nl> for sig in function_table_data . keys ( ) : <nl> name = ' FUNCTION_TABLE_ ' + sig <nl> fullname = name if not settings [ ' SIDE_MODULE ' ] else ( ' SIDE_ ' + name ) <nl> def create_named_globals ( metadata , settings ) : <nl> } <nl> Module [ ' NAMED_GLOBALS ' ] = NAMED_GLOBALS ; <nl> ' ' ' % ' , ' . join ( ' " ' + k + ' " : ' + str ( v ) for k , v in metadata [ ' namedGlobals ' ] . items ( ) ) <nl> - if settings [ ' BINARYEN ' ] : <nl> + if settings [ ' WASM ' ] : <nl> # wasm side modules are pure wasm , and cannot create their g $ . . ( ) methods , so we help them out <nl> # TODO : this works if we are the main module , but if the supplying module is later , it won ' t , so <nl> # we ' ll need another solution for that . one option is to scan the module imports , if / when <nl> mmm a / site / source / docs / compiling / WebAssembly . rst <nl> ppp b / site / source / docs / compiling / WebAssembly . rst <nl> For more background , see <nl> Setup <nl> = = = = = <nl> <nl> - WebAssembly is supported by default in Emscripten . To build to wasm , use <nl> + WebAssembly is emitted by default , without the need for any special flags . <nl> <nl> - . . code - block : : bash <nl> + . . note : : If you * * don ' t * * want WebAssembly , you can disable it with something like <nl> <nl> - emcc [ . . args . . ] - s WASM = 1 <nl> - and then just run the output js or html file . <nl> + : : <nl> <nl> - Notes : <nl> + emcc [ . . args . . ] - s WASM = 0 <nl> <nl> - - Emscripten ' s WebAssembly support depends on ` Binaryen < https : / / github . com / WebAssembly / binaryen > ` _ , which will be automatically fetched and built for you ( you may see logging about that , the first time you compile to WebAssembly ) . <nl> - - The ` ` WASM ` ` , ` ` BINARYEN * ` ` , etc . options only matter when compiling to your final executable . In other words , the same . o files are used for both asm . js and WebAssembly . Only when linking them and compiling to asm . js or WebAssembly do you need to specify WebAssembly if you want that . That means that it is easy to build your project to both asm . js and WebAssembly . <nl> + . . note : : Emscripten ' s WebAssembly support depends on ` Binaryen < https : / / github . com / WebAssembly / binaryen > ` _ , which will be automatically fetched and built for you ( you may see logging about that , the first time you compile to WebAssembly ) . <nl> + . . note : : The ` ` WASM ` ` , ` ` BINARYEN * ` ` , etc . options only matter when compiling to your final executable . In other words , the same . o files are used for both asm . js and WebAssembly . Only when linking them and compiling to asm . js or WebAssembly do you need to specify WebAssembly if you want that . That means that it is easy to build your project to both asm . js and WebAssembly . <nl> <nl> Binaryen methods <nl> = = = = = = = = = = = = = = = = <nl> Note that when using the WebAssembly backend in this manner , you do not actually <nl> <nl> - When doing so , you do not need the ` ` EMCC_WASM_BACKEND = 1 ` ` env var , as emcc will detect the lack of the asm . js backend and infer it must use the wasm backend . ( However , you can still set it , and it ' s a little faster , since it avoids the check ) . <nl> - If you build LLVM by yourself , note that WebAssembly is not built by default . You should pass ` ` - DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD = WebAssembly ` ` to ` ` cmake ` ` . <nl> - - Edit ` ` LLVM_ROOT ` ` in ` ` ~ / . emscripten ` ` so that it points to the ` ` bin ` ` directory of your custom LLVM build . <nl> \ No newline at end of file <nl> + - Edit ` ` LLVM_ROOT ` ` in ` ` ~ / . emscripten ` ` so that it points to the ` ` bin ` ` directory of your custom LLVM build . <nl> mmm a / site / source / docs / getting_started / FAQ . rst <nl> ppp b / site / source / docs / getting_started / FAQ . rst <nl> You might also want to go through the : ref : ` Tutorial ` again , as this is updated <nl> I tried something : why doesn ’ t it work ? <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> - If something doesn ' t work ( for example a : ref : ` compiler flag < emccdoc > ` , a * libc * function , etc . ) then first search the comprehensive documentation on this site . <nl> + Some general steps that might help figure things out : <nl> <nl> - Next check if there is a test for the failing functionality in the : ref : ` Emscripten test suite < emscripten - test - suite > ` ( run ` ` grep - r ` ` in * * tests / * * ) . * * All * * the tests are known to pass on the master branch , so they provide concrete " known - good " examples of how various options and code are used . <nl> + * See if the problem happens without optimizations ( ` - O0 ` , or not specifying any optimization level ) . Without optimizations , emscripten enables many assertions at compile and runtime , which may catch a problem and display an error message with a suggestion for how to fix it . <nl> + * Search the documentation on this site . <nl> + * Check if there is a test for the failing functionality in the : ref : ` Emscripten test suite < emscripten - test - suite > ` ( run ` ` grep - r ` ` in * * tests / * * ) . They should all pass ( with only rare exceptions ) , so they provide concrete " known - good " examples of how various options and code are used . <nl> <nl> <nl> Do I need to change my build system to use Emscripten ? <nl> Make sure you optimize code by building with ` ` - O2 ` ` ( even more : ref : ` aggressive <nl> Why is my compiled code big ? <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> - Make sure you build with ` ` - O2 ` ` so code is optimized and minified . You should also set up gzip compression on your webserver , which all browsers now support . <nl> - <nl> - . . note : : You can : ref : ` use the closure compiler < emcc - closure > ` to reduce code size even further ( ` ` - - closure 1 ` ` ) . However that will require that your code be prepared for closure compiler advanced optimizations , including proper exports and so forth . It is usually not worth the effort over an optimized build and supporting gzip on your webserver . <nl> + Make sure you build with ` ` - O3 ` ` or ` ` - Os ` ` so code is fully optimized and minified . You should use the closure compiler , gzip compression on your webserver , etc . , see the : ref : ` section on code size in Optimizing code < optimizing - code - size > ` . <nl> <nl> <nl> <nl> Make sure you are using the Emscripten bundled system headers . Using : ref : ` emcc <nl> How can I reduce startup time ? <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> - Make sure that you are running an : ref : ` optimized build < Optimizing - Code > ` ( smaller builds are faster to start up ) . If the sheer code size is causing the slow startup , you can try ` Outlining : a workaround for JITs and big functions < http : / / mozakai . blogspot . com / 2013 / 08 / outlining - workaround - for - jits - and - big . html > ` _ . <nl> + Make sure that you are running an : ref : ` optimized build < Optimizing - Code > ` ( smaller builds are faster to start up ) . <nl> <nl> Network latency is also a possible factor in startup time . Consider putting the file loading code in a separate script element from the generated code so that the browser can start the network download in parallel to starting up the codebase ( run the : ref : ` file packager < packaging - files > ` and put file loading code in one script element , and the generated codebase in a later script element ) . <nl> <nl> <nl> + What is " No WebAssembly support found . Build with - s WASM = 0 to target JavaScript instead " or " no native wasm support detected " ? <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + Those errors indicate that WebAssembly support is not present in the VM you are trying to run the code in . Compile with ` ` - s WASM = 0 ` ` to disable WebAssembly ( and emit asm . js instead ) if you want your code to run in such environments ( all modern browsers support WebAssembly , but in some cases you may want to reach 100 % of browsers , including legacy ones ) . <nl> + <nl> + <nl> Why does my code fail to compile with an error message about inline assembly ( or ` ` { " text " : " asm " } ` ` ) ? <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> mmm a / site / source / docs / getting_started / Tutorial . rst <nl> ppp b / site / source / docs / getting_started / Tutorial . rst <nl> To build the JavaScript version of this code , simply specify the C / C + + file afte <nl> . / emcc tests / hello_world . c <nl> <nl> <nl> - There should now be an * * a . out . js * * file in the current directory . Run it using : term : ` node . js ` : <nl> + You should see two files generated by that command : * * a . out . js * * and * * a . out . wasm * * . The second is a WebAssembly file containing the compiled code , and the first is a JavaScript file containing the runtime support to load and execute it . You can run them using : term : ` node . js ` : <nl> <nl> : : <nl> <nl> There should now be an * * a . out . js * * file in the current directory . Run it using <nl> <nl> This prints " hello , world ! " to the console , as expected . <nl> <nl> + . . note : : Older node . js versions do not have WebAssembly support yet . In that case you will see an error message suggesting that you build with ` ` - s WASM = 0 ` ` to disable WebAssembly , and then emscripten will emit the compiled code as JavaScript . In general , WebAssembly is recommended as it has widespread browser support and is more efficient both to execute and to download ( and therefore emscripten emits it by default ) , but sometimes you may need your code to run in an environment where it is not yet present and so should disable it . <nl> + <nl> . . tip : : If an error occurs when calling * emcc * , run it with the ` ` - v ` ` option to print out a lot of useful debug information . <nl> <nl> . . note : : In this section , and later on , we run some files from the ` ` tests / ` ` folder . That folder contains files for the Emscripten test suite . Some can be run standalone , but others must be run through the test harness itself , see : ref : ` emscripten - test - suite ` for more information . <nl> mmm a / site / source / docs / optimizing / Optimizing - Code . rst <nl> ppp b / site / source / docs / optimizing / Optimizing - Code . rst <nl> Advanced compiler settings <nl> <nl> There are several flags you can : ref : ` pass to the compiler < emcc - s - option - value > ` to affect code generation , which will also affect performance — for example : ref : ` DISABLE_EXCEPTION_CATCHING < optimizing - code - exception - catching > ` . These are documented in ` src / settings . js < https : / / github . com / kripken / emscripten / blob / master / src / settings . js > ` _ . Some of these will be directly affected by the optimization settings ( you can find out which ones by searching for ` ` apply_opt_level ` ` in ` tools / shared . py < https : / / github . com / kripken / emscripten / blob / 1 . 29 . 12 / tools / shared . py # L958 > ` _ ) . <nl> <nl> + WebAssembly <nl> + = = = = = = = = = = = <nl> + <nl> + Emscripten will emit WebAssembly by default . You can switch that off with ` ` - s WASM = 0 ` ` ( and then emscripten emits asm . js ) , which is necessary if you want the output to run in places where wasm support is not present yet , but the downside is larger and slower code . <nl> + <nl> + . . _optimizing - code - size : <nl> <nl> Code size <nl> = = = = = = = = = <nl> <nl> This section describes optimisations and issues that are relevant to code size . They are useful both for small projects or libraries where you want the smallest footprint you can achieve , and in large projects where the sheer size may cause issues ( like slow startup speed ) that you want to avoid . <nl> <nl> - . . _optimizing - code - memory - initialization : <nl> - <nl> - Memory initialization <nl> mmmmmmmmmmmmmmmmmmmmm - <nl> - <nl> - By default Emscripten emits the static memory initialization code inside the * * . js * * file . This can cause the JavaScript file to be very large , which will slow down startup . It can also cause problems in JavaScript engines with limits on array sizes , resulting in errors like ` ` Array initializer too large ` ` or ` ` Too much recursion ` ` . <nl> - <nl> - The ` ` - - memory - init - file 1 ` ` : ref : ` emcc option < emcc - memory - init - file > ` causes the compiler to emit this code in a separate binary file with suffix * * . mem * * . The * * . mem * * file is loaded ( asynchronously ) by the main * * . js * * file before ` ` main ( ) ` ` is called and compiled code is able to run . <nl> - <nl> - . . note : : From Emscripten 1 . 21 . 1 this setting is enabled by default for fully optimized builds , that is , ` ` - O2 ` ` and above . <nl> - <nl> - <nl> . . _optimizing - code - oz - os : <nl> <nl> Trading off code size and performance <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + <nl> You may wish to build the less performance - sensitive source files in your project using : ref : ` - Os < emcc - Os > ` or : ref : ` - Oz < emcc - Oz > ` and the remainder using : ref : ` - O2 < emcc - O2 > ` ( : ref : ` - Os < emcc - Os > ` and : ref : ` - Oz < emcc - Oz > ` are similar to : ref : ` - O2 < emcc - O2 > ` , but reduce code size at the expense of performance . : ref : ` - Oz < emcc - Oz > ` reduces code size more than : ref : ` - Os < emcc - Os > ` . ) <nl> <nl> - Note that ` ` - Oz ` ` may take longer to build . For example , it enables ` ` EVAL_CTORS ` ` which tries to optimize out C + + global constructors , which takes time . <nl> + Separately , you can do the final link / build command with ` ` - Os ` ` or ` ` - Oz ` ` to make the compiler focus more on code size when generating WebAssembly / asm . js . <nl> <nl> Miscellaneous code size tips <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> - In addition to the above ( defining a separate memory initialization file as : ref : ` mentioned above < optimizing - code - memory - initialization > ` , and using ` ` - Os ` ` or ` ` - Oz ` ` as : ref : ` mentioned above < optimizing - code - oz - os > ` ) , the following tips can help to reduce code size : <nl> + In addition to the above , the following tips can help to reduce code size : <nl> <nl> + - Use : ref : ` the closure compiler < emcc - closure > ` on the non - compiled code : ` ` - - closure 1 ` ` . This can hugely reduce the size of the support JavaScript code , and is highly recommended . However , if you add your own additional JavaScript code ( in a ` ` - - pre - js ` ` , for example ) then you need to make sure it uses ` closure annotations properly < https : / / developers . google . com / closure / compiler / docs / api - tutorial3 > ` _ . <nl> - ` Floh ' s blogpost on this topic < http : / / floooh . github . io / 2016 / 08 / 27 / asmjs - diet . html > ` _ is very helpful . <nl> - Use : ref : ` llvm - lto < emcc - llvm - lto > ` when compiling from bitcode to JavaScript : ` ` - - llvm - lto 1 ` ` . This can break some code as the LTO code path is less tested . <nl> - Disable inlining when possible , using ` ` - s INLINING_LIMIT = 1 ` ` . Compiling with - Os or - Oz generally avoids inlining too . ( Inlining can make code faster , though , so use this carefully . ) <nl> - - Use : ref : ` closure < emcc - closure > ` on the outside non - asm . js code : ` ` - - closure 1 ` ` . This can break code that doesn ' t use ` closure annotations properly < https : / / developers . google . com / closure / compiler / docs / api - tutorial3 > ` _ . <nl> + - Make sure to use gzip compression on your webserver , which all browsers now support . <nl> - You can use the ` ` NO_FILESYSTEM ` ` option to disable bundling of filesystem support code ( the compiler should optimize it out if not used , but may not always succeed ) . This can be useful if you are building a pure computational library , for example . See ` ` settings . js ` ` for more details . <nl> - You can use ` ` ELIMINATE_DUPLICATE_FUNCTIONS ` ` to remove duplicate functions , which C + + templates often create . See ` ` settings . js ` ` for more details . <nl> - You can move some of your code into the ` Emterpreter < https : / / github . com / kripken / emscripten / wiki / Emterpreter > ` _ , which will then run much slower ( as it is interpreted ) , but it will transfer all that code into a smaller amount of data . <nl> - - You can use separate modules through ` dynamic linking < https : / / github . com / kripken / emscripten / wiki / Linking > ` _ . That can increase the total code size of everything , but reduces the maximum size of a single module , which can help in some cases ( e . g . if a single big module hits a memory limit ) . <nl> <nl> Very large codebases <nl> = = = = = = = = = = = = = = = = = = = = <nl> The previous section on reducing code size can be helpful on very large codebase <nl> Avoid memory spikes by separating out asm . js <nl> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> <nl> - By default Emscripten emits one JS file , containing the entire codebase : Both the asm . js code that was compiled , and the general code that sets up the environment , connects to browser APIs , etc . in a very large codebase , this can be inefficient in terms of memory usage , as having all of that in one script means the JS engine might use some memory to parse and compile the asm . js , and might not free it before starting to run the codebase . And in a large game , starting to run the code might allocate a large typed array for memory , so you might see a " spike " of memory , after which temporary compilation memory will be freed . And if big enough , that spike can cause the browser to run out of memory and fail to load the application . This is a known problem on ` Chrome < https : / / code . google . com / p / v8 / issues / detail ? id = 4392 > ` _ ( other browsers do not seem to have this issue ) . <nl> + When emitting asm . js , by default Emscripten emits one JS file , containing the entire codebase : Both the asm . js code that was compiled , and the general code that sets up the environment , connects to browser APIs , etc . in a very large codebase , this can be inefficient in terms of memory usage , as having all of that in one script means the JS engine might use some memory to parse and compile the asm . js , and might not free it before starting to run the codebase . And in a large game , starting to run the code might allocate a large typed array for memory , so you might see a " spike " of memory , after which temporary compilation memory will be freed . And if big enough , that spike can cause the browser to run out of memory and fail to load the application . This is a known problem on ` Chrome < https : / / code . google . com / p / v8 / issues / detail ? id = 4392 > ` _ ( other browsers do not seem to have this issue ) . <nl> <nl> A workaround is to separate out the asm . js into another file , and to make sure that the browser has a turn of the event loop between compiling the asm . js module and starting to run the application . This can be achieved by running * * emcc * * with ` ` - - separate - asm ` ` . <nl> <nl> Outlining increases overall code size , and can itself make some code less optimi <nl> <nl> The ` ` OUTLINING_LIMIT ` ` setting defines the function size at which Emscripten will try to break large functions into smaller ones . Search for this setting in ` settings . js < https : / / github . com / kripken / emscripten / blob / master / src / settings . js > ` _ for information on how to determine what functions may need to be outlined and how to choose an appropriate function size . <nl> <nl> + . . note : : This setting is useful for asm . js , but generally not helpful for WebAssembly . <nl> <nl> . . _optimizing - code - aggressive - variable - elimination : <nl> <nl> Aggressive variable elimination attempts to remove variables whenever possible , <nl> <nl> You can enable aggressive variable elimination with ` ` - s AGGRESSIVE_VARIABLE_ELIMINATION = 1 ` ` . <nl> <nl> + . . note : : This setting is useful for asm . js , but generally not helpful for WebAssembly . <nl> + <nl> . . note : : This setting can be harmful in some cases . Test before using it . <nl> <nl> <nl> To re - enable exceptions in optimized code , run * emcc * with ` ` - s DISABLE_EXCEPTIO <nl> <nl> . . note : : When exception catching is disabled , a thrown exception terminates the application . In other words , an exception is still thrown , but it isn ' t caught . <nl> <nl> - . . note : : Even with catch blocks not being emitted , there is some code size overhead unless you build your source files with ` ` - fno - exceptions ` ` , which will omit all exceptions support code ( for example , it will avoid creating proper C + + exception objects in errors in std : : vector , and just abort the application if they occur ) . ` - fno - rtti ` may help as well . <nl> + . . note : : Even with catch blocks not being emitted , there is some code size overhead unless you build your source files with ` ` - fno - exceptions ` ` , which will omit all exceptions support code ( for example , it will avoid creating proper C + + exception objects in errors in std : : vector , and just abort the application if they occur ) <nl> + <nl> + C + + RTTI <nl> + mmmmmm - - <nl> + <nl> + C + + run - time type info support ( dynamic casts , etc . ) adds overhead that is sometimes not needed . For example , in Box2D neither rtti nor exceptions are needed , and if you build the source files with ` ` - fno - rtti - fno - exceptions ` ` then it shrinks the output by 15 % ( ! ) . <nl> <nl> Memory Growth <nl> mmmmmmmmmmmm - <nl> mmm a / site / source / docs / porting / guidelines / portability_guidelines . rst <nl> ppp b / site / source / docs / porting / guidelines / portability_guidelines . rst <nl> Emscripten can be used to compile almost any * portable * C + + / C code to JavaScript <nl> <nl> This section explains what types of code are non - portable ( or more difficult to port ) , and what code can be compiled but will run slowly . Developers can use this information for evaluating the effort to port and re - write code . <nl> <nl> + Current Web limitations <nl> + = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + - Multithreading depends on SharedArrayBuffer , which is still being standardized and implemented by browsers . Emscripten has working support for threads , which you can try in development browsers by setting the proper preference . <nl> + - SIMD is also in the process of standardization and implementation . <nl> + <nl> Code that cannot be compiled <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> The following types of code would need to be re - written in order to work with Emscripten . ( While in theory it might be possible for Emscripten to work around these issues using emulation , it would be very slow . ) <nl> - <nl> - - Code that is multi - threaded and uses shared state . JavaScript has threads ( web workers ) , but they cannot share state — instead they pass messages . <nl> - <nl> - . . note : : Should the JavaScript standards bodies add shared state to web workers , multithreaded code would become possible to support . <nl> <nl> - Code relying on a big - endian architecture . Emscripten - compiled code currently requires a little - endian host to run on , which accounts for 99 % of machines connected to the internet . This is because JavaScript typed arrays ( used for views on memory ) obey the host byte ordering and LLVM needs to know which endianness to target . <nl> - - Code that relies on x86 alignment behavior . x86 allows unaligned reads and writes ( so for example you can read a 16 - bit value from a non - even address ) , but other architectures do not ( ARM will raise ` ` SIGILL ` ` ) . For Emscripten - generated JavaScript the behavior is undefined . If you build your code with ` ` SAFE_HEAP = 1 ` ` then you will get a clear runtime exception , see : ref : ` Debugging ` . <nl> - Code that uses low - level features of the native environment , for example native stack manipulation in conjunction with ` ` setjmp ` ` / ` ` longjmp ` ` ( we support proper ` ` setjmp ` ` / ` ` longjmp ` ` , i . e . , jumping down the stack , but not jumping up to an unwound stack , which is undefined behavior ) . <nl> - Code that scans registers or the stack . This won ' t work because a variable in a register or on the stack may be held in a JavaScript local variable ( which cannot be scanned ) . <nl> <nl> - . . note : : Code of this type might be used for conservative garbage collection . You can do conservative scanning when there is no other code on the stack , e . g . from an iteration of the main event loop . <nl> + . . note : : Code of this type might be used for conservative garbage collection . You can do conservative scanning when there is no other code on the stack , e . g . from an iteration of the main event loop . Other solutions include the SpillPointers pass in Binaryen . <nl> <nl> - Code with architecture - specific inline assembly ( like an ` ` asm ( ) ` ` containing x86 code ) is not portable . That code would need to be replaced with portable C or C + + . Sometimes a codebase will have both portable code and optional inline assembly as an optimization , so you might find an option to disable the inline assembly . <nl> <nl> Code that compiles but might run slowly <nl> <nl> The following types of code will compile , but may not run as fast as expected : <nl> <nl> - - 64 - bit ` ` int ` ` variables . Mathematical operations ( + , - , \ * , / ) are slow because they are emulated ( bitwise operations are reasonably fast ) . JavaScript does not have a native 64 - bit ` ` int ` ` type so this is unavoidable . <nl> - <nl> + - In asm . js ( but not WebAssembly ) , 64 - bit ` ` int ` ` variables . Mathematical operations ( + , - , \ * , / ) are slow because they are emulated ( bitwise operations are reasonably fast ) . JavaScript does not have a native 64 - bit ` ` int ` ` type so this is unavoidable . <nl> - C + + Exceptions . In JavaScript such code generally makes the JavaScript engine turn off various optimizations . For that reason exceptions are turned off by default in ` ` - O1 ` ` and above . To re - enable them , run * emcc * with ` ` - s DISABLE_EXCEPTION_CATCHING = 0 ` ` ( see ` src / settings . js < https : / / github . com / kripken / emscripten / blob / 1 . 29 . 12 / src / settings . js # L298 > ` _ ) . <nl> - <nl> - ` ` setjmp ` ` also prevents : term : ` relooping ` around it , forcing us to emulate control flow using a less efficient approach . <nl> <nl> + <nl> + Other issues <nl> + = = = = = = = = = = = = <nl> + <nl> + - Code that relies on x86 alignment behavior . x86 allows unaligned reads and writes ( so for example you can read a 16 - bit value from a non - even address ) , but other architectures do not ( 32 - bit ARM will raise ` ` SIGILL ` ` ) . For asm . js loads and stores are forced to aligned offsets ; for WebAssembly unaligned loads and stores will work but may be slow depending on the underlying CPU . If you build your code with ` ` SAFE_HEAP = 1 ` ` then you will get a clear runtime exception , see : ref : ` Debugging ` . <nl> + <nl> mmm a / site / source / docs / tools_reference / emcc . rst <nl> ppp b / site / source / docs / tools_reference / emcc . rst <nl> Options that are modified or new in * emcc * are listed below : <nl> Runs the : term : ` Closure Compiler ` . Possible ` ` on ` ` values are : <nl> <nl> - ` ` 0 ` ` : No closure compiler ( default in ` ` - O2 ` ` and below ) . <nl> - - ` ` 1 ` ` : Run closure compiler . This greatly reduces code size and may in some cases increase runtime speed ( although the opposite can also occur ) . Note that it takes time to run , and may require some changes to the code . In * * asm . js * * mode , closure will only be used on the ' shell ' code around the compiled code ( the compiled code will be processed by the custom * * asm . js * * minifier ) . <nl> + - ` ` 1 ` ` : Run closure compiler . This greatly reduces the size of the support JavaScript code ( everything but the WebAssembly or asm . js ) . Note that this increases compile time significantly . <nl> - ` ` 2 ` ` : Run closure compiler on * all * the emitted code , even on * * asm . js * * output in * * asm . js * * mode . This can further reduce code size , but does prevent a significant amount of * * asm . js * * optimizations , so it is not recommended unless you want to reduce code size at all costs . <nl> <nl> . . note : : <nl> mmm a / src / jsifier . js <nl> ppp b / src / jsifier . js <nl> function JSify ( data , functionsOnly ) { <nl> print ( ' for ( var i = gb ; i < gb + { { { STATIC_BUMP } } } ; + + i ) HEAP8 [ i ] = 0 ; \ n ' ) ; <nl> print ( ' / / STATICTOP = STATIC_BASE + ' + Runtime . alignMemory ( Variables . nextIndexedOffset ) + ' ; \ n ' ) ; / / comment as metadata only <nl> } <nl> - if ( BINARYEN ) { <nl> + if ( WASM ) { <nl> / / export static base and bump , needed for linking in wasm binary ' s memory , dynamic linking , etc . <nl> print ( ' var STATIC_BUMP = { { { STATIC_BUMP } } } ; ' ) ; <nl> print ( ' Module [ " STATIC_BASE " ] = STATIC_BASE ; ' ) ; <nl> mmm a / src / library . js <nl> ppp b / src / library . js <nl> LibraryManager . library = { <nl> switch ( name ) { <nl> case { { { cDefine ( ' _SC_PAGE_SIZE ' ) } } } : return PAGE_SIZE ; <nl> case { { { cDefine ( ' _SC_PHYS_PAGES ' ) } } } : <nl> - # if BINARYEN <nl> + # if WASM <nl> var maxHeapSize = 2 * 1024 * 1024 * 1024 - 65536 ; <nl> # else <nl> var maxHeapSize = 2 * 1024 * 1024 * 1024 - 16777216 ; <nl> LibraryManager . library = { <nl> return ' var cttz_i8 = allocate ( [ ' + range ( 256 ) . map ( function ( x ) { return cttz ( x ) } ) . join ( ' , ' ) + ' ] , " i8 " , ALLOC_STATIC ) ; ' ; <nl> # endif <nl> } ] , <nl> - # if BINARYEN = = 0 / / binaryen will convert these calls to wasm anyhow <nl> + # if WASM = = 0 / / binaryen will convert these calls to wasm anyhow <nl> llvm_cttz_i32__asm : true , <nl> # endif <nl> llvm_cttz_i32__sig : ' ii ' , <nl> LibraryManager . library = { <nl> <nl> var lib_module ; <nl> try { <nl> - # if BINARYEN <nl> + # if WASM <nl> / / the shared library is a shared wasm library ( see tools / shared . py WebAssembly . make_shared_library ) <nl> var lib_data = FS . readFile ( filename , { encoding : ' binary ' } ) ; <nl> if ( ! ( lib_data instanceof Uint8Array ) ) lib_data = new Uint8Array ( lib_data ) ; <nl> mmm a / src / library_pthread . js <nl> ppp b / src / library_pthread . js <nl> var LibraryPThread = { <nl> / / object in Module [ ' mainScriptUrlOrBlob ' ] , or a URL to it , so that pthread Workers can <nl> / / independently load up the same main application file . <nl> urlOrBlob : Module [ ' mainScriptUrlOrBlob ' ] | | currentScriptUrl , <nl> - # if BINARYEN <nl> + # if WASM <nl> wasmMemory : Module [ ' wasmMemory ' ] , <nl> wasmModule : Module [ ' wasmModule ' ] , <nl> # else <nl> mmm a / src / postamble . js <nl> ppp b / src / postamble . js <nl> Module [ ' callMain ' ] = function callMain ( args ) { <nl> HEAP32 [ ( argv > > 2 ) + argc ] = 0 ; <nl> <nl> # if EMTERPRETIFY_ASYNC <nl> - var initialEmtStackTop = Module [ ' asm ' ] [ ' emtStackSave ' ] ( ) ; <nl> + var initialEmtStackTop = Module [ ' emtStackSave ' ] ( ) ; <nl> # endif <nl> <nl> try { <nl> Module [ ' callMain ' ] = function callMain ( args ) { <nl> Module [ ' noExitRuntime ' ] = true ; <nl> # if EMTERPRETIFY_ASYNC <nl> / / an infinite loop keeps the C stack around , but the emterpreter stack must be unwound - we do not want to restore the call stack at infinite loop <nl> - Module [ ' asm ' ] . emtStackRestore ( initialEmtStackTop ) ; <nl> + Module [ ' emtStackRestore ' ] ( initialEmtStackTop ) ; <nl> # endif <nl> return ; <nl> } else { <nl> mmm a / src / preamble . js <nl> ppp b / src / preamble . js <nl> function abortStackOverflow ( allocSize ) { <nl> <nl> # if ABORTING_MALLOC <nl> function abortOnCannotGrowMemory ( ) { <nl> - # if BINARYEN <nl> + # if WASM <nl> abort ( ' Cannot enlarge memory arrays . Either ( 1 ) compile with - s TOTAL_MEMORY = X with X higher than the current value ' + TOTAL_MEMORY + ' , ( 2 ) compile with - s ALLOW_MEMORY_GROWTH = 1 which allows increasing the size at runtime , or ( 3 ) if you want malloc to return NULL ( 0 ) instead of this abort , compile with - s ABORTING_MALLOC = 0 ' ) ; <nl> # else <nl> abort ( ' Cannot enlarge memory arrays . Either ( 1 ) compile with - s TOTAL_MEMORY = X with X higher than the current value ' + TOTAL_MEMORY + ' , ( 2 ) compile with - s ALLOW_MEMORY_GROWTH = 1 which allows increasing the size at runtime but prevents some optimizations , ( 3 ) set Module . TOTAL_MEMORY to a higher value before the program runs , or ( 4 ) if you want malloc to return NULL ( 0 ) instead of this abort , compile with - s ABORTING_MALLOC = 0 ' ) ; <nl> if ( typeof SharedArrayBuffer = = = ' undefined ' | | typeof Atomics = = = ' undefined ' ) <nl> # endif <nl> <nl> # if USE_PTHREADS <nl> - # if ! BINARYEN <nl> + # if ! WASM <nl> if ( typeof SharedArrayBuffer ! = = ' undefined ' ) { <nl> if ( ! ENVIRONMENT_IS_PTHREAD ) buffer = new SharedArrayBuffer ( TOTAL_MEMORY ) ; <nl> / / Currently SharedArrayBuffer does not have a slice ( ) operation , so polyfill it in . <nl> if ( ! ENVIRONMENT_IS_PTHREAD ) { <nl> } <nl> <nl> updateGlobalBufferViews ( ) ; <nl> - # endif / / ! BINARYEN <nl> + # endif / / ! WASM <nl> # else / / USE_PTHREADS <nl> <nl> # if SPLIT_MEMORY = = 0 <nl> if ( Module [ ' buffer ' ] ) { <nl> # endif <nl> } else { <nl> / / Use a WebAssembly memory where available <nl> - # if BINARYEN <nl> + # if WASM <nl> if ( typeof WebAssembly = = = ' object ' & & typeof WebAssembly . Memory = = = ' function ' ) { <nl> # if ASSERTIONS <nl> assert ( TOTAL_MEMORY % WASM_PAGE_SIZE = = = 0 ) ; <nl> if ( Module [ ' buffer ' ] ) { <nl> # endif / / ALLOW_MEMORY_GROWTH <nl> buffer = Module [ ' wasmMemory ' ] . buffer ; <nl> } else <nl> - # endif / / BINARYEN <nl> + # endif / / WASM <nl> { <nl> buffer = new ArrayBuffer ( TOTAL_MEMORY ) ; <nl> } <nl> addOnPreRun ( function ( ) { <nl> } <nl> } <nl> / / if we can load dynamic libraries synchronously , do so , otherwise , preload <nl> - # if BINARYEN <nl> + # if WASM <nl> if ( Module [ ' dynamicLibraries ' ] & & Module [ ' dynamicLibraries ' ] . length > 0 & & ! Module [ ' readBinary ' ] ) { <nl> / / we can ' t read binary data synchronously , so preload <nl> addRunDependency ( ' preload_dynamicLibraries ' ) ; <nl> var cyberDWARFFile = ' { { { BUNDLED_CD_DEBUG_FILE } } } ' ; <nl> <nl> # include " URIUtils . js " <nl> <nl> - # if BINARYEN <nl> + # if WASM <nl> function integrateWasmJS ( ) { <nl> / / wasm . js has several methods for creating the compiled code module here : <nl> / / * ' native - wasm ' : use native WebAssembly support in the browser <nl> function integrateWasmJS ( ) { <nl> <nl> function doNativeWasm ( global , env , providedBuffer ) { <nl> if ( typeof WebAssembly ! = = ' object ' ) { <nl> + # if BINARYEN_METHOD = = ' native - wasm ' <nl> + # if ASSERTIONS <nl> + / / when the method is just native - wasm , our error message can be very specific <nl> + abort ( ' No WebAssembly support found . Build with - s WASM = 0 to target JavaScript instead . ' ) ; <nl> + # endif <nl> + # endif <nl> Module [ ' printErr ' ] ( ' no native wasm support detected ' ) ; <nl> return false ; <nl> } <nl> function integrateWasmJS ( ) { <nl> var exports ; <nl> # if BINARYEN_METHOD = = ' native - wasm ' <nl> exports = doNativeWasm ( global , env , providedBuffer ) ; <nl> - # else <nl> + # else / / native - wasm <nl> # if BINARYEN_METHOD = = ' asmjs ' <nl> exports = doJustAsm ( global , env , providedBuffer ) ; <nl> # else <nl> function integrateWasmJS ( ) { <nl> abort ( ' bad method : ' + curr ) ; <nl> } <nl> } <nl> - # endif <nl> - # endif <nl> + # endif / / asmjs <nl> + # endif / / native - wasm <nl> <nl> - if ( ! exports ) abort ( ' no binaryen method succeeded . consider enabling more options , like interpreting , if you want that : https : / / github . com / kripken / emscripten / wiki / WebAssembly # binaryen - methods ' ) ; <nl> + # if ASSERTIONS <nl> + assert ( exports , ' no binaryen method succeeded . consider enabling more options , like interpreting , if you want that : https : / / github . com / kripken / emscripten / wiki / WebAssembly # binaryen - methods ' ) ; <nl> + # else <nl> + assert ( exports , ' no binaryen method succeeded . ' ) ; <nl> + # endif <nl> <nl> # if RUNTIME_LOGGING <nl> Module [ ' printErr ' ] ( ' binaryen method succeeded . ' ) ; <nl> mmm a / src / settings . js <nl> ppp b / src / settings . js <nl> var FORCE_ALIGNED_MEMORY = 0 ; / / If enabled , assumes all reads and writes are fu <nl> var WARN_UNALIGNED = 0 ; / / Warn at compile time about instructions that LLVM tells us are not fully aligned . <nl> / / This is useful to find places in your code where you might refactor to ensure proper <nl> / / alignment . <nl> + / / This is currently only supported in asm . js , not wasm . <nl> var PRECISE_I64_MATH = 1 ; / / If enabled , i64 addition etc . is emulated - which is slow but precise . If disabled , <nl> / / we use the ' double trick ' which is fast but incurs rounding at high values . <nl> / / If set to 2 , we always include the i64 math code , which is necessary in the case <nl> var STB_IMAGE = 0 ; / / Enables building of stb - image , a tiny public - domain librar <nl> / / When enabled , stb - image will be used automatically from IMG_Load and IMG_Load_RW . You <nl> / / can also call the stbi_ * functions directly yourself . <nl> <nl> - var LEGACY_VM_SUPPORT = 0 ; / / Enable this to get support for non - modern browsers , node . js , etc . This adds : <nl> - / / * Polyfilling for Math . clz32 , Math . trunc , Math . imul , Math . fround <nl> + var LEGACY_VM_SUPPORT = 0 ; / / Enable this to get support for non - modern browsers , node . js , etc . This gives you <nl> + / / the highest possible probability of the code working everywhere , even in rare old <nl> + / / browsers and shell environments . Specifically : <nl> + / / * Add polyfilling for Math . clz32 , Math . trunc , Math . imul , Math . fround . <nl> + / / * Disable WebAssembly . <nl> <nl> var LZ4 = 0 ; / / Enable this to support lz4 - compressed file packages . They are stored compressed in memory , and <nl> / / decompressed on the fly , avoiding storing the entire decompressed data in memory at once . <nl> var USE_GLFW = 2 ; / / Specify the GLFW version that is being linked against . <nl> / / Only relevant , if you are linking against the GLFW library . <nl> / / Valid options are 2 for GLFW2 and 3 for GLFW3 . <nl> <nl> - var BINARYEN = 0 ; / / Whether to use [ Binaryen ] ( https : / / github . com / WebAssembly / binaryen ) to <nl> - / / compile code to WebAssembly . <nl> - / / This will fetch the binaryen port and build it . ( If , instead , you set <nl> - / / BINARYEN_ROOT in your ~ / . emscripten file , then we use that instead <nl> - / / of the port , which can useful for local dev work on binaryen itself ) . <nl> + var WASM = 1 ; / / Whether to use compile code to WebAssembly . Set this to 0 to compile <nl> + / / to asm . js . <nl> + / / This will fetch the binaryen port and build it . ( If , instead , you set <nl> + / / BINARYEN_ROOT in your ~ / . emscripten file , then we use that instead <nl> + / / of the port , which can useful for local dev work on binaryen itself ) . <nl> + <nl> + var WASM_BACKEND = 0 ; / / Whether to use the WebAssembly backend that is in development in LLVM . <nl> + / / This requires that BINARYEN be set , as we use Binaryen ' s s2wasm to <nl> + / / translate the backend output . <nl> + / / You should not set this yourself , instead set EMCC_WASM_BACKEND = 1 in the <nl> + / / environment . <nl> + var EXPERIMENTAL_USE_LLD = 0 ; / / Whether to use lld as a linker for the <nl> + / / WebAssembly backend , instead of s2wasm . <nl> + / / Currently an experiment , the plan is to make <nl> + / / this the default behavior long - term , and remove <nl> + / / the flag . <nl> + / / You should not set this yourself , instead set <nl> + / / EMCC_EXPERIMENTAL_USE_LLD = 1 in the environment . <nl> + <nl> var BINARYEN_METHOD = " native - wasm " ; / / How we should run WebAssembly code . By default , we run it natively . <nl> / / See binaryen ' s src / js / wasm . js - post . js for more details and options . <nl> var BINARYEN_SCRIPTS = " " ; / / An optional comma - separated list of script hooks to run after binaryen , <nl> var LEGALIZE_JS_FFI = 1 ; / / Whether to legalize the JS FFI interfaces ( imports / e <nl> / / LEGALIZE_JS_FFI = 0 is incompatible with RUNNING_JS_OPTS and using <nl> / / non - wasm BINARYEN_METHOD settings . <nl> <nl> - var WASM = 0 ; / / Alias for BINARYEN , the two are identical . Both make us compile code to WebAssembly . <nl> - <nl> - var WASM_BACKEND = 0 ; / / Whether to use the WebAssembly backend that is in development in LLVM . <nl> - / / This requires that BINARYEN be set , as we use Binaryen ' s s2wasm to <nl> - / / translate the backend output . <nl> - / / You should not set this yourself , instead set EMCC_WASM_BACKEND = 1 in the <nl> - / / environment . <nl> - var EXPERIMENTAL_USE_LLD = 0 ; / / Whether to use lld as a linker for the <nl> - / / WebAssembly backend , instead of s2wasm . <nl> - / / Currently an experiment , the plan is to make <nl> - / / this the default behavior long - term , and remove <nl> - / / the flag . <nl> - / / You should not set this yourself , instead set <nl> - / / EMCC_EXPERIMENTAL_USE_LLD = 1 in the environment . <nl> - <nl> / / Ports <nl> <nl> var USE_SDL = 1 ; / / Specify the SDL version that is being linked against . <nl> mmm a / src / support . js <nl> ppp b / src / support . js <nl> var loadedDynamicLibraries = [ ] ; <nl> <nl> function loadDynamicLibrary ( lib ) { <nl> var libModule ; <nl> - # if BINARYEN <nl> + # if WASM <nl> var bin ; <nl> if ( lib . buffer ) { <nl> / / we were provided the binary , in a typed array <nl> function loadDynamicLibrary ( lib ) { <nl> loadedDynamicLibraries . push ( libModule ) ; <nl> } <nl> <nl> - # if BINARYEN <nl> + # if WASM <nl> / / Loads a side module from binary data <nl> function loadWebAssemblyModule ( binary ) { <nl> var int32View = new Uint32Array ( new Uint8Array ( binary . subarray ( 0 , 24 ) ) . buffer ) ; <nl> function loadWebAssemblyModule ( binary ) { <nl> } <nl> return exports ; <nl> } <nl> - # endif / / BINARYEN <nl> + # endif / / WASM <nl> # endif / / RELOCATABLE <nl> <nl> # if EMULATED_FUNCTION_POINTERS <nl> function addFunction ( func , sig ) { <nl> # endif / / WASM_BACKEND <nl> # if ASSERTIONS <nl> if ( typeof sig = = = ' undefined ' ) { <nl> - Module . printErr ( ' Warning : addFunction : Provide a wasm function signature ' + <nl> - ' string as a second argument ' ) ; <nl> + Module . printErr ( ' warning : addFunction ( ) : You should provide a wasm function signature string as a second argument . This is not necessary for asm . js and asm2wasm , but is required for the LLVM wasm backend , so it is recommended for full portability . ' ) ; <nl> } <nl> # endif / / ASSERTIONS <nl> # if EMULATED_FUNCTION_POINTERS = = 0 <nl> function addFunction ( func , sig ) { <nl> } <nl> throw ' Finished up all reserved function pointers . Use a higher value for RESERVED_FUNCTION_POINTERS . ' ; <nl> # else <nl> - # if BINARYEN <nl> + # if WASM <nl> / / we can simply append to the wasm table <nl> var table = Module [ ' wasmTable ' ] ; <nl> var ret = table . length ; <nl> mmm a / tests / cmake / target_js / CMakeLists . txt <nl> ppp b / tests / cmake / target_js / CMakeLists . txt <nl> else ( ) # Either MinSizeRel , RelWithDebInfo or Release , all which run with optimi <nl> SET ( linkFlags " - O2 - s NO_EXIT_RUNTIME = 1 " ) <nl> endif ( ) <nl> <nl> + # Ensure synchronous startup for this test , whose output expects it <nl> + SET ( linkFlags " $ { linkFlags } - s BINARYEN_ASYNC_COMPILATION = 0 " ) <nl> + <nl> # Test that the CMake - provided macro check_function_exists ( ) works . <nl> include ( CheckFunctionExists ) <nl> check_function_exists ( " strtod " HAVE_STRTOD ) <nl> mmm a / tests / runner . py <nl> ppp b / tests / runner . py <nl> def uses_memory_init_file ( self ) : <nl> return int ( self . emcc_args [ self . emcc_args . index ( ' - - memory - init - file ' ) + 1 ] ) <nl> else : <nl> # side modules handle memory differently ; binaryen puts the memory in the wasm module <nl> - return ( ' - O2 ' in self . emcc_args or ' - O3 ' in self . emcc_args or ' - Oz ' in self . emcc_args ) and not ( Settings . SIDE_MODULE or Settings . BINARYEN ) <nl> + return ( ' - O2 ' in self . emcc_args or ' - O3 ' in self . emcc_args or ' - Oz ' in self . emcc_args ) and not ( Settings . SIDE_MODULE or Settings . WASM ) <nl> <nl> def set_temp_dir ( self , temp_dir ) : <nl> self . temp_dir = temp_dir <nl> def count_wasm_contents ( self , wasm_binary , what ) : <nl> ret = line . split ( ' : ' ) [ 1 ] . strip ( ) <nl> return int ( ret ) <nl> <nl> + def get_wasm_text ( self , wasm_binary ) : <nl> + return run_process ( [ os . path . join ( Building . get_binaryen_bin ( ) , ' wasm - dis ' ) , wasm_binary ] , stdout = PIPE ) . stdout <nl> + <nl> + def is_exported_in_wasm ( self , name , wasm ) : <nl> + wat = self . get_wasm_text ( wasm ) <nl> + return ( ' ( export " % s " ' % name ) in wat <nl> + <nl> def run_generated_code ( self , engine , filename , args = [ ] , check_timeout = True , output_nicerizer = None , assert_returncode = 0 ) : <nl> stdout = os . path . join ( self . get_dir ( ) , ' stdout ' ) # use files , as PIPE can get too full and hang us <nl> stderr = os . path . join ( self . get_dir ( ) , ' stderr ' ) <nl> def __init__ ( self , * args , * * kwargs ) : <nl> @ classmethod <nl> def setUpClass ( self ) : <nl> super ( BrowserCore , self ) . setUpClass ( ) <nl> - self . also_wasm = os . environ . get ( ' EMCC_BROWSER_ALSO_WASM ' , ' 0 ' ) = = ' 1 ' <nl> + self . also_asmjs = os . environ . get ( ' EMCC_BROWSER_ALSO_ASMJS ' , ' 0 ' ) = = ' 1 ' <nl> self . test_port = int ( os . environ . get ( ' EMCC_BROWSER_TEST_PORT ' , ' 8888 ' ) ) <nl> self . harness_port = int ( os . environ . get ( ' EMCC_BROWSER_HARNESS_PORT ' , ' 9999 ' ) ) <nl> if not has_browser ( ) : return <nl> def reftest ( self , expected ) : <nl> ' ' ' % ( self . test_port , basename ) ) <nl> <nl> def btest ( self , filename , expected = None , reference = None , force_c = False , reference_slack = 0 , manual_reference = False , post_build = None , <nl> - args = [ ] , outfile = ' test . html ' , message = ' . ' , also_proxied = False , url_suffix = ' ' , timeout = None , also_wasm = True ) : # TODO : use in all other tests <nl> + args = [ ] , outfile = ' test . html ' , message = ' . ' , also_proxied = False , url_suffix = ' ' , timeout = None ) : <nl> # if we are provided the source and not a path , use that <nl> filename_is_src = ' \ n ' in filename <nl> src = filename if filename_is_src else ' ' <nl> filepath = path_from_root ( ' tests ' , filename ) if not filename_is_src else ( ' main . c ' if force_c else ' main . cpp ' ) <nl> temp_filepath = os . path . join ( self . get_dir ( ) , os . path . basename ( filepath ) ) <nl> + # when self . also_asmjs , we run tests in asm . js mode too , and not just the default wasm . <nl> + # otherwise , for now we run pthreads tests just in asm . js , no wasm , since wasm doesn ' t work yet . <nl> + if not self . also_asmjs and ' WASM = 0 ' not in args and ' USE_PTHREADS ' in str ( args ) : <nl> + args + = [ ' - s ' , ' WASM = 0 ' ] <nl> original_args = args [ : ] <nl> if filename_is_src : <nl> with open ( temp_filepath , ' w ' ) as f : f . write ( src ) <nl> def btest ( self , filename , expected = None , reference = None , force_c = False , referenc <nl> if post_build : post_build ( ) <nl> if not isinstance ( expected , list ) : expected = [ expected ] <nl> self . run_browser ( outfile + url_suffix , message , [ ' / report_result ? ' + e for e in expected ] , timeout = timeout ) <nl> - if also_wasm and self . also_wasm : <nl> - wasm_args = args + [ ' - s ' , ' WASM = 1 ' ] <nl> - # Filter out separate - asm , which is implied by wasm <nl> - wasm_args = [ a for a in wasm_args if a ! = ' - - separate - asm ' ] <nl> - # wasm doesn ' t support USE_PTHREADS = 2 <nl> - wasm_args = [ ' USE_PTHREADS = 1 ' if a = = ' USE_PTHREADS = 2 ' else a for a in wasm_args ] <nl> + if self . also_asmjs and not ' WASM = 0 ' in args : <nl> self . btest ( filename , expected , reference , force_c , reference_slack , manual_reference , post_build , <nl> - wasm_args , outfile , message , also_proxied = False , timeout = timeout , also_wasm = False ) <nl> + args + [ ' - s ' , ' WASM = 0 ' ] , outfile , message , also_proxied = False , timeout = timeout ) <nl> if also_proxied : <nl> print ( ' proxied . . . ' ) <nl> if reference : <nl> mmm a / tests / test_browser . py <nl> ppp b / tests / test_browser . py <nl> def test_zzz_html_source_map ( self ) : <nl> # sourceContent when the maps are relative paths <nl> try_delete ( html_file ) <nl> try_delete ( html_file + ' . map ' ) <nl> - Popen ( [ PYTHON , EMCC , ' src . cpp ' , ' - o ' , ' src . html ' , ' - g4 ' ] , <nl> + Popen ( [ PYTHON , EMCC , ' src . cpp ' , ' - o ' , ' src . html ' , ' - g4 ' , ' - s ' , ' WASM = 0 ' ] , <nl> cwd = self . get_dir ( ) ) . communicate ( ) <nl> assert os . path . exists ( html_file ) <nl> assert os . path . exists ( html_file + ' . map ' ) <nl> webbrowser . open_new ( ' file : / / ' + html_file ) <nl> - time . sleep ( 1 ) <nl> print ( ' ' ' <nl> If manually bisecting : <nl> Check that you see src . cpp among the page sources . <nl> def test_zzz_html_source_map ( self ) : <nl> ' ' ' ) <nl> <nl> def test_emscripten_log ( self ) : <nl> + # TODO : wasm support for source maps <nl> src = os . path . join ( self . get_dir ( ) , ' src . cpp ' ) <nl> open ( src , ' w ' ) . write ( self . with_report_result ( open ( path_from_root ( ' tests ' , ' emscripten_log ' , ' emscripten_log . cpp ' ) ) . read ( ) ) ) <nl> <nl> - Popen ( [ PYTHON , EMCC , src , ' - - pre - js ' , path_from_root ( ' src ' , ' emscripten - source - map . min . js ' ) , ' - g ' , ' - o ' , ' page . html ' , ' - s ' , ' DEMANGLE_SUPPORT = 1 ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , src , ' - - pre - js ' , path_from_root ( ' src ' , ' emscripten - source - map . min . js ' ) , ' - g ' , ' - o ' , ' page . html ' , ' - s ' , ' DEMANGLE_SUPPORT = 1 ' , ' - s ' , ' WASM = 0 ' ] ) . communicate ( ) <nl> self . run_browser ( ' page . html ' , None , ' / report_result ? 1 ' ) <nl> <nl> def build_native_lzma ( self ) : <nl> def test_sdl_canvas_proxy ( self ) : <nl> <nl> @ requires_hardware <nl> def test_glgears_proxy ( self ) : <nl> - self . btest ( ' hello_world_gles_proxy . c ' , reference = ' gears . png ' , args = [ ' - - proxy - to - worker ' , ' - s ' , ' GL_TESTING = 1 ' , ' - DSTATIC_GEARS = 1 ' , ' - lGL ' , ' - lglut ' ] , manual_reference = True , post_build = self . post_manual_reftest ) <nl> + # we modify the asm . js , this is a non - wasm test <nl> + self . btest ( ' hello_world_gles_proxy . c ' , reference = ' gears . png ' , args = [ ' - - proxy - to - worker ' , ' - s ' , ' GL_TESTING = 1 ' , ' - DSTATIC_GEARS = 1 ' , ' - lGL ' , ' - lglut ' , ' - s ' , ' WASM = 0 ' ] , manual_reference = True , post_build = self . post_manual_reftest ) <nl> <nl> # test noProxy option applied at runtime <nl> <nl> def test_chunked_synchronous_xhr ( self ) : <nl> prejs_file . close ( ) <nl> # vs . os . path . join ( self . get_dir ( ) , filename ) <nl> # vs . path_from_root ( ' tests ' , ' hello_world_gles . c ' ) <nl> - Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , c_source_filename ) , ' - g ' , ' - s ' , ' SMALL_XHR_CHUNKS = 1 ' , ' - o ' , worker_filename , <nl> - ' - - pre - js ' , prejs_filename ] ) . communicate ( ) <nl> - <nl> + run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , c_source_filename ) , ' - g ' , ' - s ' , ' SMALL_XHR_CHUNKS = 1 ' , ' - o ' , worker_filename , <nl> + ' - - pre - js ' , prejs_filename ] ) <nl> chunkSize = 1024 <nl> data = os . urandom ( 10 * chunkSize + 1 ) # 10 full chunks and one 1 byte chunk <nl> checksum = zlib . adler32 ( data ) & 0xffffffff # Python 2 compatibility : force bigint <nl> def test_cubegeom_pre_vao_es ( self ) : <nl> @ requires_hardware <nl> def test_cubegeom_u4fv_2 ( self ) : <nl> self . btest ( ' cubegeom_u4fv_2 . c ' , reference = ' cubegeom_u4fv_2 . png ' , args = [ ' - s ' , ' LEGACY_GL_EMULATION = 1 ' , ' - lGL ' , ' - lSDL ' ] ) <nl> - self . btest ( ' cubegeom_u4fv_2 . c ' , reference = ' cubegeom_u4fv_2 . png ' , args = [ ' - s ' , ' LEGACY_GL_EMULATION = 1 ' , ' - lGL ' , ' - lSDL ' , ' - s ' , ' SPLIT_MEMORY = 16777216 ' ] ) # check for uniform4fv slice being valid in split memory <nl> + self . btest ( ' cubegeom_u4fv_2 . c ' , reference = ' cubegeom_u4fv_2 . png ' , args = [ ' - s ' , ' LEGACY_GL_EMULATION = 1 ' , ' - lGL ' , ' - lSDL ' , ' - s ' , ' SPLIT_MEMORY = 16777216 ' , ' - s ' , ' WASM = 0 ' ] ) # check for uniform4fv slice being valid in split memory <nl> <nl> @ requires_hardware <nl> def test_cube_explosion ( self ) : <nl> def test_openal_capture_sanity ( self ) : <nl> self . btest ( ' openal_capture_sanity . c ' , expected = ' 0 ' ) <nl> <nl> def test_runtimelink ( self ) : <nl> - main , supp = self . setup_runtimelink_test ( ) <nl> - open ( ' supp . cpp ' , ' w ' ) . write ( supp ) <nl> - Popen ( [ PYTHON , EMCC , ' supp . cpp ' , ' - o ' , ' supp . js ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - O2 ' ] ) . communicate ( ) <nl> - self . btest ( main , args = [ ' - DBROWSER = 1 ' , ' - s ' , ' MAIN_MODULE = 1 ' , ' - O2 ' , ' - s ' , ' RUNTIME_LINKED_LIBS = [ " supp . js " ] ' ] , expected = ' 76 ' ) <nl> + for wasm in [ 0 , 1 ] : <nl> + print ( wasm ) <nl> + main , supp = self . setup_runtimelink_test ( ) <nl> + open ( ' supp . cpp ' , ' w ' ) . write ( supp ) <nl> + Popen ( [ PYTHON , EMCC , ' supp . cpp ' , ' - o ' , ' supp . ' + ( ' wasm ' if wasm else ' js ' ) , ' - s ' , ' SIDE_MODULE = 1 ' , ' - O2 ' , ' - s ' , ' WASM = % d ' % wasm ] ) . communicate ( ) <nl> + self . btest ( main , args = [ ' - DBROWSER = 1 ' , ' - s ' , ' MAIN_MODULE = 1 ' , ' - O2 ' , ' - s ' , ' WASM = % d ' % wasm , ' - s ' , ' RUNTIME_LINKED_LIBS = [ " supp . ' + ( ' wasm ' if wasm else ' js ' ) + ' " ] ' ] , expected = ' 76 ' ) <nl> <nl> def test_pre_run_deps ( self ) : <nl> # Adding a dependency in preRun will delay run <nl> def test_mem_init ( self ) : <nl> ' ' ' % self . test_port ) <nl> <nl> # with assertions , we notice when memory was written to too early <nl> - self . btest ( ' mem_init . cpp ' , expected = ' 9 ' , args = [ ' - - pre - js ' , ' pre . js ' , ' - - post - js ' , ' post . js ' , ' - - memory - init - file ' , ' 1 ' ] ) <nl> + self . btest ( ' mem_init . cpp ' , expected = ' 9 ' , args = [ ' - s ' , ' WASM = 0 ' , ' - - pre - js ' , ' pre . js ' , ' - - post - js ' , ' post . js ' , ' - - memory - init - file ' , ' 1 ' ] ) <nl> # otherwise , we just overwrite <nl> - self . btest ( ' mem_init . cpp ' , expected = ' 3 ' , args = [ ' - - pre - js ' , ' pre . js ' , ' - - post - js ' , ' post . js ' , ' - - memory - init - file ' , ' 1 ' , ' - s ' , ' ASSERTIONS = 0 ' ] ) <nl> + self . btest ( ' mem_init . cpp ' , expected = ' 3 ' , args = [ ' - s ' , ' WASM = 0 ' , ' - - pre - js ' , ' pre . js ' , ' - - post - js ' , ' post . js ' , ' - - memory - init - file ' , ' 1 ' , ' - s ' , ' ASSERTIONS = 0 ' ] ) <nl> <nl> def test_mem_init_request ( self ) : <nl> def test ( what , status ) : <nl> def test ( what , status ) : <nl> console . log ( ' WARNING : ' + x ) ; <nl> } ; <nl> ' ' ' % self . test_port ) <nl> - self . btest ( ' mem_init_request . cpp ' , expected = status , args = [ ' - - pre - js ' , ' pre . js ' , ' - - memory - init - file ' , ' 1 ' ] ) <nl> + self . btest ( ' mem_init_request . cpp ' , expected = status , args = [ ' - s ' , ' WASM = 0 ' , ' - - pre - js ' , ' pre . js ' , ' - - memory - init - file ' , ' 1 ' ] ) <nl> <nl> test ( ' test . html . mem ' , ' 1 ' ) <nl> test ( ' nothing . nowhere ' , ' 0 ' ) <nl> def test_sdl_mousewheel ( self ) : <nl> self . btest ( path_from_root ( ' tests ' , ' test_sdl_mousewheel . c ' ) , args = opts + [ ' - DAUTOMATE_SUCCESS = 1 ' , ' - lSDL ' , ' - lGL ' ] , expected = ' 0 ' ) <nl> <nl> def test_codemods ( self ) : <nl> + # tests asm . js client - side code modifications <nl> for opt_level in [ 0 , 2 ] : <nl> print ( ' opt level ' , opt_level ) <nl> - opts = ' - O ' + str ( opt_level ) <nl> + opts = [ ' - O ' + str ( opt_level ) , ' - s ' , ' WASM = 0 ' ] <nl> # sanity checks , building with and without precise float semantics generates different results <nl> - self . btest ( path_from_root ( ' tests ' , ' codemods . cpp ' ) , expected = ' 2 ' , args = [ opts ] ) <nl> - self . btest ( path_from_root ( ' tests ' , ' codemods . cpp ' ) , expected = ' 1 ' , args = [ opts , ' - s ' , ' PRECISE_F32 = 1 ' ] ) <nl> - self . btest ( path_from_root ( ' tests ' , ' codemods . cpp ' ) , expected = ' 1 ' , args = [ opts , ' - s ' , ' PRECISE_F32 = 2 ' , ' - - separate - asm ' ] ) # empty polyfill , but browser has support , so semantics are like float <nl> + self . btest ( path_from_root ( ' tests ' , ' codemods . cpp ' ) , expected = ' 2 ' , args = opts ) <nl> + self . btest ( path_from_root ( ' tests ' , ' codemods . cpp ' ) , expected = ' 1 ' , args = opts + [ ' - s ' , ' PRECISE_F32 = 1 ' ] ) <nl> + self . btest ( path_from_root ( ' tests ' , ' codemods . cpp ' ) , expected = ' 1 ' , args = opts + [ ' - s ' , ' PRECISE_F32 = 2 ' , ' - - separate - asm ' ] ) # empty polyfill , but browser has support , so semantics are like float <nl> <nl> def test_wget ( self ) : <nl> with open ( os . path . join ( self . get_dir ( ) , ' test . txt ' ) , ' w ' ) as f : <nl> def test_wget_data ( self ) : <nl> self . btest ( path_from_root ( ' tests ' , ' test_wget_data . c ' ) , expected = ' 1 ' , args = [ ' - s ' , ' EMTERPRETIFY = 1 ' , ' - s ' , ' EMTERPRETIFY_ASYNC = 1 ' , ' - O2 ' , ' - g2 ' , ' - s ' , ' ASSERTIONS = 1 ' ] ) <nl> <nl> def test_locate_file ( self ) : <nl> - self . clear ( ) <nl> - open ( ' src . cpp ' , ' w ' ) . write ( self . with_report_result ( r ' ' ' <nl> - # include < stdio . h > <nl> - # include < string . h > <nl> - # include < assert . h > <nl> - int main ( ) { <nl> - FILE * f = fopen ( " data . txt " , " r " ) ; <nl> - assert ( f & & " could not open file " ) ; <nl> - char buf [ 100 ] ; <nl> - int num = fread ( buf , 1 , 20 , f ) ; <nl> - assert ( num = = 20 & & " could not read 20 bytes " ) ; <nl> - buf [ 20 ] = 0 ; <nl> - fclose ( f ) ; <nl> - int result = ! strcmp ( " load me right before " , buf ) ; <nl> - printf ( " | % s | : % d \ n " , buf , result ) ; <nl> - REPORT_RESULT ( result ) ; <nl> - return 0 ; <nl> - } <nl> - ' ' ' ) ) <nl> - open ( ' data . txt ' , ' w ' ) . write ( ' load me right before . . . ' ) <nl> - open ( ' pre . js ' , ' w ' ) . write ( ' Module . locateFile = function ( x ) { return " sub / " + x } ; ' ) <nl> - Popen ( [ PYTHON , FILE_PACKAGER , ' test . data ' , ' - - preload ' , ' data . txt ' ] , stdout = open ( ' data . js ' , ' w ' ) ) . communicate ( ) <nl> - # put pre . js first , then the file packager data , so locateFile is there for the file loading code <nl> - Popen ( [ PYTHON , EMCC , ' src . cpp ' , ' - O2 ' , ' - g ' , ' - - pre - js ' , ' pre . js ' , ' - - pre - js ' , ' data . js ' , ' - o ' , ' page . html ' , ' - s ' , ' FORCE_FILESYSTEM = 1 ' ] ) . communicate ( ) <nl> - os . mkdir ( ' sub ' ) <nl> - shutil . move ( ' page . html . mem ' , os . path . join ( ' sub ' , ' page . html . mem ' ) ) <nl> - shutil . move ( ' test . data ' , os . path . join ( ' sub ' , ' test . data ' ) ) <nl> - self . run_browser ( ' page . html ' , None , ' / report_result ? 1 ' ) <nl> + for wasm in [ 0 , 1 ] : <nl> + print ( ' wasm ' , wasm ) <nl> + self . clear ( ) <nl> + open ( ' src . cpp ' , ' w ' ) . write ( self . with_report_result ( r ' ' ' <nl> + # include < stdio . h > <nl> + # include < string . h > <nl> + # include < assert . h > <nl> + int main ( ) { <nl> + FILE * f = fopen ( " data . txt " , " r " ) ; <nl> + assert ( f & & " could not open file " ) ; <nl> + char buf [ 100 ] ; <nl> + int num = fread ( buf , 1 , 20 , f ) ; <nl> + assert ( num = = 20 & & " could not read 20 bytes " ) ; <nl> + buf [ 20 ] = 0 ; <nl> + fclose ( f ) ; <nl> + int result = ! strcmp ( " load me right before " , buf ) ; <nl> + printf ( " | % s | : % d \ n " , buf , result ) ; <nl> + REPORT_RESULT ( result ) ; <nl> + return 0 ; <nl> + } <nl> + ' ' ' ) ) <nl> + open ( ' data . txt ' , ' w ' ) . write ( ' load me right before . . . ' ) <nl> + open ( ' pre . js ' , ' w ' ) . write ( ' Module . locateFile = function ( x ) { return " sub / " + x } ; ' ) <nl> + Popen ( [ PYTHON , FILE_PACKAGER , ' test . data ' , ' - - preload ' , ' data . txt ' ] , stdout = open ( ' data . js ' , ' w ' ) ) . communicate ( ) <nl> + # put pre . js first , then the file packager data , so locateFile is there for the file loading code <nl> + Popen ( [ PYTHON , EMCC , ' src . cpp ' , ' - O2 ' , ' - g ' , ' - - pre - js ' , ' pre . js ' , ' - - pre - js ' , ' data . js ' , ' - o ' , ' page . html ' , ' - s ' , ' FORCE_FILESYSTEM = 1 ' , ' - s ' , ' WASM = ' + str ( wasm ) ] ) . communicate ( ) <nl> + os . mkdir ( ' sub ' ) <nl> + if wasm : <nl> + shutil . move ( ' page . wasm ' , os . path . join ( ' sub ' , ' page . wasm ' ) ) <nl> + else : <nl> + shutil . move ( ' page . html . mem ' , os . path . join ( ' sub ' , ' page . html . mem ' ) ) <nl> + shutil . move ( ' test . data ' , os . path . join ( ' sub ' , ' test . data ' ) ) <nl> + self . run_browser ( ' page . html ' , None , ' / report_result ? 1 ' ) <nl> <nl> - # alternatively , put locateFile in the HTML <nl> - print ( ' in html ' ) <nl> + # alternatively , put locateFile in the HTML <nl> + print ( ' in html ' ) <nl> <nl> - open ( ' shell . html ' , ' w ' ) . write ( ' ' ' <nl> - < body > <nl> - < script > <nl> - var Module = { <nl> - locateFile : function ( x ) { return " sub / " + x } <nl> - } ; <nl> - < / script > <nl> + open ( ' shell . html ' , ' w ' ) . write ( ' ' ' <nl> + < body > <nl> + < script > <nl> + var Module = { <nl> + locateFile : function ( x ) { return " sub / " + x } <nl> + } ; <nl> + < / script > <nl> <nl> - { { { SCRIPT } } } <nl> - < / body > <nl> - ' ' ' ) <nl> + { { { SCRIPT } } } <nl> + < / body > <nl> + ' ' ' ) <nl> <nl> - def in_html ( expected , args = [ ] ) : <nl> - Popen ( [ PYTHON , EMCC , ' src . cpp ' , ' - O2 ' , ' - g ' , ' - - shell - file ' , ' shell . html ' , ' - - pre - js ' , ' data . js ' , ' - o ' , ' page . html ' , ' - s ' , ' SAFE_HEAP = 1 ' , ' - s ' , ' ASSERTIONS = 1 ' , ' - s ' , ' FORCE_FILESYSTEM = 1 ' ] + args ) . communicate ( ) <nl> - shutil . move ( ' page . html . mem ' , os . path . join ( ' sub ' , ' page . html . mem ' ) ) <nl> - self . run_browser ( ' page . html ' , None , ' / report_result ? ' + expected ) <nl> - <nl> - in_html ( ' 1 ' ) <nl> - <nl> - # verify that the mem init request succeeded in the latter case <nl> - open ( ' src . cpp ' , ' w ' ) . write ( self . with_report_result ( r ' ' ' <nl> - # include < stdio . h > <nl> - # include < emscripten . h > <nl> - <nl> - int main ( ) { <nl> - int result = EM_ASM_INT ( { <nl> - return Module [ ' memoryInitializerRequest ' ] . status ; <nl> - } ) ; <nl> - printf ( " memory init request : % d \ n " , result ) ; <nl> - REPORT_RESULT ( result ) ; <nl> - return 0 ; <nl> - } <nl> - ' ' ' ) ) <nl> + def in_html ( expected , args = [ ] ) : <nl> + Popen ( [ PYTHON , EMCC , ' src . cpp ' , ' - O2 ' , ' - g ' , ' - - shell - file ' , ' shell . html ' , ' - - pre - js ' , ' data . js ' , ' - o ' , ' page . html ' , ' - s ' , ' SAFE_HEAP = 1 ' , ' - s ' , ' ASSERTIONS = 1 ' , ' - s ' , ' FORCE_FILESYSTEM = 1 ' , ' - s ' , ' WASM = ' + str ( wasm ) ] + args ) . communicate ( ) <nl> + if wasm : <nl> + shutil . move ( ' page . wasm ' , os . path . join ( ' sub ' , ' page . wasm ' ) ) <nl> + else : <nl> + shutil . move ( ' page . html . mem ' , os . path . join ( ' sub ' , ' page . html . mem ' ) ) <nl> + self . run_browser ( ' page . html ' , None , ' / report_result ? ' + expected ) <nl> + <nl> + in_html ( ' 1 ' ) <nl> + <nl> + # verify that the mem init request succeeded in the latter case <nl> + if not wasm : <nl> + open ( ' src . cpp ' , ' w ' ) . write ( self . with_report_result ( r ' ' ' <nl> + # include < stdio . h > <nl> + # include < emscripten . h > <nl> + <nl> + int main ( ) { <nl> + int result = EM_ASM_INT ( { <nl> + return Module [ ' memoryInitializerRequest ' ] . status ; <nl> + } ) ; <nl> + printf ( " memory init request : % d \ n " , result ) ; <nl> + REPORT_RESULT ( result ) ; <nl> + return 0 ; <nl> + } <nl> + ' ' ' ) ) <nl> <nl> - in_html ( ' 200 ' ) <nl> + in_html ( ' 200 ' ) <nl> <nl> @ requires_hardware <nl> def test_glfw3 ( self ) : <nl> def test_asm_swapping ( self ) : <nl> ' ' ' ) <nl> for opts in [ [ ] , [ ' - O1 ' ] , [ ' - O2 ' , ' - profiling ' ] , [ ' - O2 ' ] ] : <nl> print ( opts ) <nl> - opts + = [ ' - - pre - js ' , ' run . js ' , ' - s ' , ' SWAPPABLE_ASM_MODULE = 1 ' ] # important that both modules are built with the same opts <nl> + opts + = [ ' - s ' , ' WASM = 0 ' , ' - - pre - js ' , ' run . js ' , ' - s ' , ' SWAPPABLE_ASM_MODULE = 1 ' ] # important that both modules are built with the same opts <nl> open ( ' second . cpp ' , ' w ' ) . write ( self . with_report_result ( open ( path_from_root ( ' tests ' , ' asm_swap2 . cpp ' ) ) . read ( ) ) ) <nl> Popen ( [ PYTHON , EMCC , ' second . cpp ' ] + opts ) . communicate ( ) <nl> Popen ( [ PYTHON , path_from_root ( ' tools ' , ' distill_asm . py ' ) , ' a . out . js ' , ' second . js ' , ' swap - in ' ] ) . communicate ( ) <nl> def test_emterpreter_async_sleep2_safeheap ( self ) : <nl> <nl> @ requires_hardware <nl> def test_sdl_audio_beep_sleep ( self ) : <nl> - self . btest ( ' sdl_audio_beep_sleep . cpp ' , ' 1 ' , args = [ ' - s ' , ' EMTERPRETIFY = 1 ' , ' - s ' , ' EMTERPRETIFY_ASYNC = 1 ' , ' - Os ' , ' - s ' , ' ASSERTIONS = 1 ' , ' - s ' , ' DISABLE_EXCEPTION_CATCHING = 0 ' , ' - profiling ' , ' - s ' , ' SAFE_HEAP = 1 ' , ' - lSDL ' ] , timeout = 60 ) <nl> + self . btest ( ' sdl_audio_beep_sleep . cpp ' , ' 1 ' , args = [ ' - s ' , ' EMTERPRETIFY = 1 ' , ' - s ' , ' EMTERPRETIFY_ASYNC = 1 ' , ' - Os ' , ' - s ' , ' ASSERTIONS = 1 ' , ' - s ' , ' DISABLE_EXCEPTION_CATCHING = 0 ' , ' - profiling ' , ' - s ' , ' SAFE_HEAP = 1 ' , ' - lSDL ' ] , timeout = 90 ) <nl> <nl> def test_mainloop_reschedule ( self ) : <nl> self . btest ( ' mainloop_reschedule . cpp ' , ' 1 ' , args = [ ' - s ' , ' EMTERPRETIFY = 1 ' , ' - s ' , ' EMTERPRETIFY_ASYNC = 1 ' , ' - Os ' ] , timeout = 30 ) <nl> def test_modularize ( self ) : <nl> print ( ' test on ' , opts , args , code ) <nl> src = open ( path_from_root ( ' tests ' , ' browser_test_hello_world . c ' ) ) . read ( ) <nl> open ( ' test . c ' , ' w ' ) . write ( self . with_report_result ( src ) ) <nl> - Popen ( [ PYTHON , EMCC , ' test . c ' , ' - s ' , ' MODULARIZE = 1 ' ] + args + opts ) . communicate ( ) <nl> + # this test is synchronous , so avoid async startup due to wasm features <nl> + Popen ( [ PYTHON , EMCC , ' test . c ' , ' - s ' , ' MODULARIZE = 1 ' , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' , ' - s ' , ' SINGLE_FILE = 1 ' ] + args + opts ) . communicate ( ) <nl> open ( ' a . html ' , ' w ' ) . write ( ' ' ' <nl> < script src = " a . out . js " > < / script > <nl> < script > <nl> def test_modularize_and_preload_files ( self ) : <nl> # generate a dummy file <nl> open ( ' dummy_file ' , ' w ' ) . write ( ' dummy ' ) <nl> # compile the code with the modularize feature and the preload - file option enabled <nl> - Popen ( [ PYTHON , EMCC , ' test . c ' , ' - s ' , ' MODULARIZE = 1 ' , ' - s ' , ' EXPORT_NAME = " Foo " ' , ' - - preload - file ' , ' dummy_file ' ] + opts ) . communicate ( ) <nl> + # no wasm , since this tests customizing total memory at runtime <nl> + Popen ( [ PYTHON , EMCC , ' test . c ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' MODULARIZE = 1 ' , ' - s ' , ' EXPORT_NAME = " Foo " ' , ' - - preload - file ' , ' dummy_file ' ] + opts ) . communicate ( ) <nl> open ( ' a . html ' , ' w ' ) . write ( ' ' ' <nl> < script src = " a . out . js " > < / script > <nl> < script > <nl> def test_webidl ( self ) : <nl> <nl> def test_dynamic_link ( self ) : <nl> open ( ' pre . js ' , ' w ' ) . write ( ' ' ' <nl> - Module . dynamicLibraries = [ ' side . js ' ] ; <nl> + Module . dynamicLibraries = [ ' side . wasm ' ] ; <nl> ' ' ' ) <nl> open ( ' main . cpp ' , ' w ' ) . write ( r ' ' ' <nl> # include < stdio . h > <nl> def test_dynamic_link ( self ) : <nl> return ret ; <nl> } <nl> ' ' ' ) <nl> - Popen ( [ PYTHON , EMCC , ' side . cpp ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - O2 ' , ' - o ' , ' side . js ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' side . cpp ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - O2 ' , ' - o ' , ' side . wasm ' ] ) . communicate ( ) <nl> self . btest ( self . in_dir ( ' main . cpp ' ) , ' 2 ' , args = [ ' - s ' , ' MAIN_MODULE = 1 ' , ' - O2 ' , ' - - pre - js ' , ' pre . js ' ] ) <nl> <nl> print ( ' wasm in worker ( we can read binary data synchronously there ) ' ) <nl> def test_dynamic_link ( self ) : <nl> open ( ' pre . js ' , ' w ' ) . write ( ' ' ' <nl> var Module = { dynamicLibraries : [ ' side . wasm ' ] } ; <nl> ' ' ' ) <nl> - Popen ( [ PYTHON , EMCC , ' side . cpp ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - O2 ' , ' - o ' , ' side . js ' , ' - s ' , ' WASM = 1 ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' side . cpp ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - O2 ' , ' - o ' , ' side . wasm ' , ' - s ' , ' WASM = 1 ' ] ) . communicate ( ) <nl> self . btest ( self . in_dir ( ' main . cpp ' ) , ' 2 ' , args = [ ' - s ' , ' MAIN_MODULE = 1 ' , ' - O2 ' , ' - - pre - js ' , ' pre . js ' , ' - s ' , ' WASM = 1 ' , ' - - proxy - to - worker ' ] ) <nl> <nl> print ( ' wasm ( will auto - preload since no sync binary reading ) ' ) <nl> def test_dynamic_link ( self ) : <nl> @ requires_hardware <nl> def test_dynamic_link_glemu ( self ) : <nl> open ( ' pre . js ' , ' w ' ) . write ( ' ' ' <nl> - Module . dynamicLibraries = [ ' side . js ' ] ; <nl> + Module . dynamicLibraries = [ ' side . wasm ' ] ; <nl> ' ' ' ) <nl> open ( ' main . cpp ' , ' w ' ) . write ( r ' ' ' <nl> # include < stdio . h > <nl> def test_dynamic_link_glemu ( self ) : <nl> return ( const char * ) glGetString ( GL_EXTENSIONS ) ; <nl> } <nl> ' ' ' ) <nl> - Popen ( [ PYTHON , EMCC , ' side . cpp ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - O2 ' , ' - o ' , ' side . js ' , ' - lSDL ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' side . cpp ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - O2 ' , ' - o ' , ' side . wasm ' , ' - lSDL ' ] ) . communicate ( ) <nl> <nl> self . btest ( self . in_dir ( ' main . cpp ' ) , ' 1 ' , args = [ ' - s ' , ' MAIN_MODULE = 1 ' , ' - O2 ' , ' - s ' , ' LEGACY_GL_EMULATION = 1 ' , ' - lSDL ' , ' - lGL ' , ' - - pre - js ' , ' pre . js ' ] ) <nl> <nl> def test_pthread_gcc_atomic_fetch_and_op ( self ) : <nl> for debug in [ [ ] , [ ' - g1 ' ] , [ ' - g2 ' ] , [ ' - g4 ' ] ] : <nl> for f32 in [ [ ] , [ ' - s ' , ' PRECISE_F32 = 1 ' ] ] : <nl> print ( opt , debug , f32 ) <nl> - self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_gcc_atomic_fetch_and_op . cpp ' ) , expected = ' 0 ' , args = opt + debug + f32 + [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_POOL_SIZE = 8 ' ] , timeout = 60 , also_wasm = False ) <nl> + self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_gcc_atomic_fetch_and_op . cpp ' ) , expected = ' 0 ' , args = opt + debug + f32 + [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_POOL_SIZE = 8 ' , ' - s ' , ' WASM = 0 ' ] , timeout = 60 ) <nl> <nl> # 64 bit version of the above test . <nl> def test_pthread_gcc_64bit_atomic_fetch_and_op ( self ) : <nl> - self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_gcc_64bit_atomic_fetch_and_op . cpp ' ) , expected = ' 0 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_POOL_SIZE = 8 ' ] , timeout = 30 , also_wasm = False ) <nl> + self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_gcc_64bit_atomic_fetch_and_op . cpp ' ) , expected = ' 0 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_POOL_SIZE = 8 ' , ' - s ' , ' WASM = 0 ' ] , timeout = 30 ) <nl> <nl> # Test the old GCC atomic __sync_op_and_fetch builtin operations . <nl> def test_pthread_gcc_atomic_op_and_fetch ( self ) : <nl> - self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_gcc_atomic_op_and_fetch . cpp ' ) , expected = ' 0 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_POOL_SIZE = 8 ' ] , timeout = 30 , also_wasm = False ) <nl> + self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_gcc_atomic_op_and_fetch . cpp ' ) , expected = ' 0 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_POOL_SIZE = 8 ' , ' - s ' , ' WASM = 0 ' ] , timeout = 30 ) <nl> <nl> # 64 bit version of the above test . <nl> def test_pthread_gcc_64bit_atomic_op_and_fetch ( self ) : <nl> - self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_gcc_64bit_atomic_op_and_fetch . cpp ' ) , expected = ' 0 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_POOL_SIZE = 8 ' ] , timeout = 30 , also_wasm = False ) <nl> + self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_gcc_64bit_atomic_op_and_fetch . cpp ' ) , expected = ' 0 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_POOL_SIZE = 8 ' , ' - s ' , ' WASM = 0 ' ] , timeout = 30 ) <nl> <nl> # Tests the rest of the remaining GCC atomics after the two above tests . <nl> def test_pthread_gcc_atomics ( self ) : <nl> def test_pthread_gcc_atomics ( self ) : <nl> # Test the __sync_lock_test_and_set and __sync_lock_release primitives . <nl> def test_pthread_gcc_spinlock ( self ) : <nl> for arg in [ [ ] , [ ' - DUSE_EMSCRIPTEN_INTRINSICS ' ] ] : <nl> - self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_gcc_spinlock . cpp ' ) , expected = ' 800 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_POOL_SIZE = 8 ' ] + arg , timeout = 30 , also_wasm = False ) <nl> + self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_gcc_spinlock . cpp ' ) , expected = ' 800 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_POOL_SIZE = 8 ' , ' - s ' , ' WASM = 0 ' ] + arg , timeout = 30 ) <nl> <nl> # Test that basic thread creation works . <nl> def test_pthread_create ( self ) : <nl> def test_pthread_setspecific_mainthread ( self ) : <nl> self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_setspecific_mainthread . cpp ' ) , expected = ' 0 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' ] , timeout = 30 ) <nl> <nl> self . prep_no_SAB ( ) <nl> - self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_setspecific_mainthread . cpp ' ) , expected = ' 0 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - - shell - file ' , ' html . html ' ] , timeout = 30 , also_wasm = False ) <nl> + self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_setspecific_mainthread . cpp ' ) , expected = ' 0 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - - shell - file ' , ' html . html ' , ' - s ' , ' WASM = 0 ' ] , timeout = 30 ) <nl> <nl> # Test the - s PTHREAD_HINT_NUM_CORES = x command line variable . <nl> def test_pthread_num_logical_cores ( self ) : <nl> self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_num_logical_cores . cpp ' ) , expected = ' 0 ' , args = [ ' - O3 ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_HINT_NUM_CORES = 2 ' ] , timeout = 30 ) <nl> <nl> self . prep_no_SAB ( ) <nl> - self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_num_logical_cores . cpp ' ) , expected = ' 0 ' , args = [ ' - O3 ' , ' - g ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_HINT_NUM_CORES = 2 ' , ' - - shell - file ' , ' html . html ' ] , timeout = 30 , also_wasm = False ) <nl> + self . btest ( path_from_root ( ' tests ' , ' pthread ' , ' test_pthread_num_logical_cores . cpp ' ) , expected = ' 0 ' , args = [ ' - O3 ' , ' - g ' , ' - s ' , ' USE_PTHREADS = 2 ' , ' - - separate - asm ' , ' - s ' , ' PTHREAD_HINT_NUM_CORES = 2 ' , ' - - shell - file ' , ' html . html ' , ' - s ' , ' WASM = 0 ' ] , timeout = 30 ) <nl> <nl> # Test that pthreads have access to filesystem . <nl> def test_pthread_file_io ( self ) : <nl> def test_pthread_custom_pthread_main_url ( self ) : <nl> <nl> # Test that it is possible to define " Module . pthreadMainPrefixURL " string to locate where pthread - main . js will be loaded from . <nl> open ( self . in_dir ( ' shell . html ' ) , ' w ' ) . write ( open ( path_from_root ( ' src ' , ' shell . html ' ) ) . read ( ) . replace ( ' var Module = { ' , ' var Module = { pthreadMainPrefixURL : " cdn / " , ' ) ) <nl> - Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - - shell - file ' , ' shell . html ' , ' - s ' , ' IN_TEST_HARNESS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' PTHREAD_POOL_SIZE = 1 ' , ' - o ' , ' test . html ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - - shell - file ' , ' shell . html ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' IN_TEST_HARNESS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' PTHREAD_POOL_SIZE = 1 ' , ' - o ' , ' test . html ' ] ) . communicate ( ) <nl> shutil . move ( ' pthread - main . js ' , os . path . join ( ' cdn ' , ' pthread - main . js ' ) ) <nl> self . run_browser ( ' test . html ' , ' ' , ' / report_result ? 1 ' ) <nl> <nl> # Test that it is possible to define " Module . locateFile ( foo ) " function to locate where pthread - main . js will be loaded from . <nl> open ( self . in_dir ( ' shell2 . html ' ) , ' w ' ) . write ( open ( path_from_root ( ' src ' , ' shell . html ' ) ) . read ( ) . replace ( ' var Module = { ' , ' var Module = { locateFile : function ( filename ) { if ( filename = = " pthread - main . js " ) return " cdn / pthread - main . js " ; else return filename ; } , ' ) ) <nl> - Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - - shell - file ' , ' shell2 . html ' , ' - s ' , ' IN_TEST_HARNESS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' PTHREAD_POOL_SIZE = 1 ' , ' - o ' , ' test2 . html ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - - shell - file ' , ' shell2 . html ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' IN_TEST_HARNESS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' PTHREAD_POOL_SIZE = 1 ' , ' - o ' , ' test2 . html ' ] ) . communicate ( ) <nl> try_delete ( ' pthread - main . js ' ) <nl> self . run_browser ( ' test2 . html ' , ' ' , ' / report_result ? 1 ' ) <nl> <nl> def test_pthread_clock_drift ( self ) : <nl> <nl> # test atomicrmw i64 <nl> def test_atomicrmw_i64 ( self ) : <nl> - Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' atomicrmw_i64 . ll ' ) , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' IN_TEST_HARNESS = 1 ' , ' - o ' , ' test . html ' ] ) . communicate ( ) <nl> + # TODO : enable this with wasm , currently pthreads / atomics have limitations <nl> + Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' atomicrmw_i64 . ll ' ) , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' IN_TEST_HARNESS = 1 ' , ' - o ' , ' test . html ' , ' - s ' , ' WASM = 0 ' ] ) . communicate ( ) <nl> self . run_browser ( ' test . html ' , None , ' / report_result ? 0 ' ) <nl> <nl> # Test that it is possible to send a signal via calling alarm ( timeout ) , which in turn calls to the signal handler set by signal ( SIGALRM , func ) ; <nl> def test_meminit_pairs ( self ) : <nl> for j in range ( 256 ) ) for i in range ( 256 ) ) <nl> with open ( path_from_root ( ' tests ' , ' meminit_pairs . c ' ) ) as f : <nl> d + = ' " \ n } ; \ n ' + f . read ( ) <nl> - args = [ " - O2 " , " - - memory - init - file " , " 0 " , " - s " , " MEM_INIT_METHOD = 2 " , " - s " , " ASSERTIONS = 1 " ] <nl> + args = [ " - O2 " , " - - memory - init - file " , " 0 " , " - s " , " MEM_INIT_METHOD = 2 " , " - s " , " ASSERTIONS = 1 " , ' - s ' , ' WASM = 0 ' ] <nl> self . btest ( d , expected = ' 0 ' , args = args + [ " - - closure " , " 0 " ] ) <nl> self . btest ( d , expected = ' 0 ' , args = args + [ " - - closure " , " 0 " , " - g " ] ) <nl> self . btest ( d , expected = ' 0 ' , args = args + [ " - - closure " , " 1 " ] ) <nl> def test_meminit_big ( self ) : <nl> with open ( path_from_root ( ' tests ' , ' meminit_pairs . c ' ) ) as f : <nl> d + = ' " \ n } ; \ n ' + f . read ( ) <nl> assert len ( d ) > ( 1 < < 27 ) # more than 32M memory initializer <nl> - args = [ " - O2 " , " - - memory - init - file " , " 0 " , " - s " , " MEM_INIT_METHOD = 2 " , " - s " , " ASSERTIONS = 1 " ] <nl> + args = [ " - O2 " , " - - memory - init - file " , " 0 " , " - s " , " MEM_INIT_METHOD = 2 " , " - s " , " ASSERTIONS = 1 " , ' - s ' , ' WASM = 0 ' ] <nl> self . btest ( d , expected = ' 0 ' , args = args + [ " - - closure " , " 0 " ] ) <nl> self . btest ( d , expected = ' 0 ' , args = args + [ " - - closure " , " 0 " , " - g " ] ) <nl> self . btest ( d , expected = ' 0 ' , args = args + [ " - - closure " , " 1 " ] ) <nl> def test_separate_asm ( self ) : <nl> for opts in [ [ ' - O0 ' ] , [ ' - O1 ' ] , [ ' - O2 ' ] , [ ' - O2 ' , ' - - closure ' , ' 1 ' ] ] : <nl> print ( opts ) <nl> open ( ' src . cpp ' , ' w ' ) . write ( self . with_report_result ( open ( path_from_root ( ' tests ' , ' browser_test_hello_world . c ' ) ) . read ( ) ) ) <nl> - Popen ( [ PYTHON , EMCC , ' src . cpp ' , ' - o ' , ' test . html ' ] + opts ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' src . cpp ' , ' - o ' , ' test . html ' , ' - s ' , ' WASM = 0 ' ] + opts ) . communicate ( ) <nl> self . run_browser ( ' test . html ' , None , ' / report_result ? 0 ' ) <nl> <nl> open ( ' one . html ' , ' w ' ) . write ( ' < script src = " test . js " > < / script > ' ) <nl> def test_separate_asm ( self ) : <nl> <nl> self . clear ( ) <nl> assert not os . path . exists ( ' tests . asm . js ' ) <nl> - self . btest ( ' browser_test_hello_world . c ' , expected = ' 0 ' , args = opts + [ ' - - separate - asm ' ] ) <nl> + self . btest ( ' browser_test_hello_world . c ' , expected = ' 0 ' , args = opts + [ ' - s ' , ' WASM = 0 ' , ' - - separate - asm ' ] ) <nl> assert os . path . exists ( ' test . asm . js ' ) <nl> os . unlink ( ' test . asm . js ' ) <nl> self . run_browser ( ' test . html ' , None , ' [ no http server activity ] ' , timeout = 5 ) # fail without the asm <nl> def test_vanilla_html_when_proxying ( self ) : <nl> self . run_browser ( ' test . html ' , None , ' / report_result ? 0 ' ) <nl> <nl> def test_in_flight_memfile_request ( self ) : <nl> + # test the XHR for an asm . js mem init file being in flight already <nl> for o in [ 0 , 1 , 2 ] : <nl> print ( o ) <nl> - opts = [ ' - O ' + str ( o ) ] <nl> + opts = [ ' - O ' + str ( o ) , ' - s ' , ' WASM = 0 ' ] <nl> <nl> print ( ' plain html ' ) <nl> open ( ' src . cpp ' , ' w ' ) . write ( self . with_report_result ( open ( path_from_root ( ' tests ' , ' in_flight_memfile_request . c ' ) ) . read ( ) ) ) <nl> def test_in_flight_memfile_request ( self ) : <nl> def test_split_memory_large_file ( self ) : <nl> size = 2 * 1024 * 1024 <nl> open ( ' huge . dat ' , ' wb ' ) . write ( bytearray ( ( x * x ) & 255 for x in range ( size * 2 ) ) ) # larger than a memory chunk <nl> - self . btest ( ' split_memory_large_file . cpp ' , expected = ' 1 ' , args = [ ' - s ' , ' SPLIT_MEMORY = ' + str ( size ) , ' - s ' , ' TOTAL_MEMORY = 128MB ' , ' - s ' , ' TOTAL_STACK = 10240 ' , ' - - preload - file ' , ' huge . dat ' ] , timeout = 60 ) <nl> + self . btest ( ' split_memory_large_file . cpp ' , expected = ' 1 ' , args = [ ' - s ' , ' WASM = 0 ' , ' - s ' , ' SPLIT_MEMORY = ' + str ( size ) , ' - s ' , ' TOTAL_MEMORY = 128MB ' , ' - s ' , ' TOTAL_STACK = 10240 ' , ' - - preload - file ' , ' huge . dat ' ] , timeout = 60 ) <nl> <nl> - def test_binaryen ( self ) : <nl> + def test_binaryen_interpreter ( self ) : <nl> self . btest ( ' browser_test_hello_world . c ' , expected = ' 0 ' , args = [ ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " interpret - binary " ' ] ) <nl> self . btest ( ' browser_test_hello_world . c ' , expected = ' 0 ' , args = [ ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " interpret - binary " ' , ' - O2 ' ] ) <nl> <nl> - def test_binaryen_native ( self ) : <nl> - for opts in [ <nl> - [ ] , <nl> - [ ' - O1 ' ] , <nl> - [ ' - O2 ' ] , <nl> - [ ' - O3 ' ] , <nl> - [ ' - Os ' ] , <nl> - [ ' - Oz ' ] , <nl> - [ ' - O2 ' , ' - - js - opts ' , ' 1 ' ] , <nl> - [ ' - O2 ' , ' - s ' , ' EMTERPRETIFY = 1 ' ] , <nl> - [ ' - O2 ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' ] , <nl> - [ ' - O2 ' , ' - s ' , ' EMTERPRETIFY = 1 ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' ] , <nl> - [ ' - O2 ' , ' - s ' , ' OUTLINING_LIMIT = 1000 ' ] , <nl> - [ ' - O2 ' , ' - - closure ' , ' 1 ' ] , <nl> - ] : <nl> - print ( opts ) <nl> - self . btest ( ' browser_test_hello_world . c ' , expected = ' 0 ' , args = [ ' - s ' , ' BINARYEN = 1 ' ] + opts ) <nl> - <nl> def test_binaryen_async ( self ) : <nl> # notice when we use async compilation <nl> script = ' ' ' <nl> def test_webgl_offscreen_canvas_in_mainthread_after_pthread ( self ) : <nl> <nl> # Tests the feature that shell html page can preallocate the typed array and place it to Module . buffer before loading the script page . <nl> # In this build mode , the - s TOTAL_MEMORY = xxx option will be ignored . <nl> + # Preallocating the buffer in this was is asm . js only ( wasm needs a Memory ) . <nl> def test_preallocated_heap ( self ) : <nl> - self . btest ( ' test_preallocated_heap . cpp ' , expected = ' 1 ' , args = [ ' - s ' , ' TOTAL_MEMORY = 16MB ' , ' - s ' , ' ABORTING_MALLOC = 0 ' , ' - - shell - file ' , path_from_root ( ' tests ' , ' test_preallocated_heap_shell . html ' ) ] ) <nl> + self . btest ( ' test_preallocated_heap . cpp ' , expected = ' 1 ' , args = [ ' - s ' , ' WASM = 0 ' , ' - s ' , ' TOTAL_MEMORY = 16MB ' , ' - s ' , ' ABORTING_MALLOC = 0 ' , ' - - shell - file ' , path_from_root ( ' tests ' , ' test_preallocated_heap_shell . html ' ) ] ) <nl> <nl> # Tests emscripten_fetch ( ) usage to XHR data directly to memory without persisting results to IndexedDB . <nl> def test_fetch_to_memory ( self ) : <nl> # Test error reporting in the negative case when the file URL doesn ' t exist . ( http 404 ) <nl> - self . btest ( ' fetch / to_memory . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - DFILE_DOES_NOT_EXIST ' ] ) <nl> + self . btest ( ' fetch / to_memory . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' WASM = 0 ' , ' - DFILE_DOES_NOT_EXIST ' ] ) <nl> <nl> # Test the positive case when the file URL exists . ( http 200 ) <nl> shutil . copyfile ( path_from_root ( ' tests ' , ' gears . png ' ) , os . path . join ( self . get_dir ( ) , ' gears . png ' ) ) <nl> - self . btest ( ' fetch / to_memory . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' ] ) <nl> + self . btest ( ' fetch / to_memory . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' WASM = 0 ' ] ) <nl> <nl> # Tests emscripten_fetch ( ) usage to persist an XHR into IndexedDB and subsequently load up from there . <nl> def test_fetch_cached_xhr ( self ) : <nl> shutil . copyfile ( path_from_root ( ' tests ' , ' gears . png ' ) , os . path . join ( self . get_dir ( ) , ' gears . png ' ) ) <nl> - self . btest ( ' fetch / cached_xhr . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' ] ) <nl> + self . btest ( ' fetch / cached_xhr . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' WASM = 0 ' ] ) <nl> <nl> # Test emscripten_fetch ( ) usage to stream a XHR in to memory without storing the full file in memory <nl> def test_fetch_stream_file ( self ) : <nl> def test_fetch_stream_file ( self ) : <nl> for i in range ( 1024 ) : <nl> f . write ( s ) <nl> f . close ( ) <nl> - self . btest ( ' fetch / stream_file . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' TOTAL_MEMORY = 536870912 ' ] ) <nl> + self . btest ( ' fetch / stream_file . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' TOTAL_MEMORY = 536870912 ' ] ) <nl> <nl> # Tests emscripten_fetch ( ) usage in synchronous mode when used from the main thread proxied to a Worker with - s PROXY_TO_PTHREAD = 1 option . <nl> def test_fetch_sync_xhr ( self ) : <nl> shutil . copyfile ( path_from_root ( ' tests ' , ' gears . png ' ) , os . path . join ( self . get_dir ( ) , ' gears . png ' ) ) <nl> - self . btest ( ' fetch / sync_xhr . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> + self . btest ( ' fetch / sync_xhr . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> <nl> # Tests that the Fetch API works for synchronous XHRs when used with - - proxy - to - worker . <nl> def test_fetch_sync_xhr_in_proxy_to_worker ( self ) : <nl> shutil . copyfile ( path_from_root ( ' tests ' , ' gears . png ' ) , os . path . join ( self . get_dir ( ) , ' gears . png ' ) ) <nl> - self . btest ( ' fetch / sync_xhr . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - - proxy - to - worker ' ] ) <nl> + self . btest ( ' fetch / sync_xhr . cpp ' , expected = ' 1 ' , args = [ ' - - std = c + + 11 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' WASM = 0 ' , ' - - proxy - to - worker ' ] ) <nl> <nl> def test_fetch_idb_store ( self ) : <nl> - self . btest ( ' fetch / idb_store . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> + self . btest ( ' fetch / idb_store . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> <nl> def test_fetch_idb_delete ( self ) : <nl> shutil . copyfile ( path_from_root ( ' tests ' , ' gears . png ' ) , os . path . join ( self . get_dir ( ) , ' gears . png ' ) ) <nl> - self . btest ( ' fetch / idb_delete . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> + self . btest ( ' fetch / idb_delete . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' FETCH = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> <nl> def test_asmfs_hello_file ( self ) : <nl> # Test basic file loading and the valid character set for files . <nl> os . mkdir ( os . path . join ( self . get_dir ( ) , ' dirrey ' ) ) <nl> shutil . copyfile ( path_from_root ( ' tests ' , ' asmfs ' , ' hello_file . txt ' ) , os . path . join ( self . get_dir ( ) , ' dirrey ' , ' hello file ! # $ % & \ ' ( ) + , - . ; = @ [ ] ^ _ ` { } ~ % % . txt ' ) ) <nl> - self . btest ( ' asmfs / hello_file . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> + self . btest ( ' asmfs / hello_file . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> <nl> def test_asmfs_read_file_twice ( self ) : <nl> shutil . copyfile ( path_from_root ( ' tests ' , ' asmfs ' , ' hello_file . txt ' ) , os . path . join ( self . get_dir ( ) , ' hello_file . txt ' ) ) <nl> - self . btest ( ' asmfs / read_file_twice . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> + self . btest ( ' asmfs / read_file_twice . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> <nl> def test_asmfs_fopen_write ( self ) : <nl> - self . btest ( ' asmfs / fopen_write . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> + self . btest ( ' asmfs / fopen_write . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> <nl> def test_asmfs_mkdir_create_unlink_rmdir ( self ) : <nl> - self . btest ( ' cstdio / test_remove . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> + self . btest ( ' cstdio / test_remove . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> <nl> def test_asmfs_dirent_test_readdir ( self ) : <nl> - self . btest ( ' dirent / test_readdir . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> + self . btest ( ' dirent / test_readdir . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> <nl> def test_asmfs_dirent_test_readdir_empty ( self ) : <nl> - self . btest ( ' dirent / test_readdir_empty . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> + self . btest ( ' dirent / test_readdir_empty . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> <nl> def test_asmfs_unistd_close ( self ) : <nl> - self . btest ( ' unistd / close . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> + self . btest ( ' unistd / close . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> <nl> def test_asmfs_unistd_access ( self ) : <nl> - self . btest ( ' unistd / access . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> + self . btest ( ' unistd / access . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> <nl> def test_asmfs_unistd_unlink ( self ) : <nl> # TODO : Once symlinks are supported , remove - DNO_SYMLINK = 1 <nl> - self . btest ( ' unistd / unlink . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - DNO_SYMLINK = 1 ' ] ) <nl> + self . btest ( ' unistd / unlink . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - DNO_SYMLINK = 1 ' ] ) <nl> <nl> def test_asmfs_test_fcntl_open ( self ) : <nl> - self . btest ( ' fcntl - open / src . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> + self . btest ( ' fcntl - open / src . c ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' , ' - s ' , ' PROXY_TO_PTHREAD = 1 ' ] ) <nl> <nl> def test_asmfs_relative_paths ( self ) : <nl> - self . btest ( ' asmfs / relative_paths . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> + self . btest ( ' asmfs / relative_paths . cpp ' , expected = ' 0 ' , args = [ ' - s ' , ' ASMFS = 1 ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - s ' , ' FETCH_DEBUG = 1 ' ] ) <nl> <nl> def test_pthread_locale ( self ) : <nl> for args in [ <nl> def test_hello_thread ( self ) : <nl> <nl> # Tests that it is possible to load the main . js file of the application manually via a Blob URL , and still use pthreads . <nl> def test_load_js_from_blob_with_pthreads ( self ) : <nl> + # TODO : enable this with wasm , currently pthreads / atomics have limitations <nl> src = os . path . join ( self . get_dir ( ) , ' src . c ' ) <nl> open ( src , ' w ' ) . write ( self . with_report_result ( open ( path_from_root ( ' tests ' , ' pthread ' , ' hello_thread . c ' ) ) . read ( ) ) ) <nl> - <nl> - Popen ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - o ' , ' hello_thread_with_blob_url . js ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' USE_PTHREADS = 1 ' , ' - o ' , ' hello_thread_with_blob_url . js ' , ' - s ' , ' WASM = 0 ' ] ) . communicate ( ) <nl> shutil . copyfile ( path_from_root ( ' tests ' , ' pthread ' , ' main_js_as_blob_loader . html ' ) , os . path . join ( self . get_dir ( ) , ' hello_thread_with_blob_url . html ' ) ) <nl> self . run_browser ( ' hello_thread_with_blob_url . html ' , ' hello from thread ! ' , ' / report_result ? 1 ' ) <nl> <nl> mmm a / tests / test_core . py <nl> ppp b / tests / test_core . py <nl> def is_emterpreter ( self ) : <nl> def is_split_memory ( self ) : <nl> return ' SPLIT_MEMORY = ' in str ( self . emcc_args ) <nl> def is_wasm ( self ) : <nl> - return ' BINARYEN ' in str ( self . emcc_args ) or self . is_wasm_backend ( ) <nl> + return ' WASM = 0 ' not in str ( self . emcc_args ) or self . is_wasm_backend ( ) <nl> def is_linux ( self ) : <nl> return LINUX <nl> def is_macos ( self ) : <nl> def process ( filename ) : <nl> ' ' ' <nl> <nl> def build_dlfcn_lib ( self , lib_src , dirname , filename ) : <nl> - if Settings . BINARYEN : <nl> + if Settings . WASM : <nl> # emcc emits a wasm in this case <nl> self . build ( lib_src , dirname , filename , js_outfile = False ) <nl> shutil . move ( filename + ' . o . wasm ' , os . path . join ( dirname , ' liblib . so ' ) ) <nl> def test_dylink_zlib ( self ) : <nl> Settings . BINARYEN_TRAP_MODE = ' clamp ' # avoid using asm2wasm imports , which don ' t work in side modules yet ( should they ? ) <nl> Building . COMPILER_TEST_OPTS + = [ ' - I ' + path_from_root ( ' tests ' , ' zlib ' ) ] <nl> <nl> - Popen ( [ PYTHON , path_from_root ( ' embuilder . py ' ) , ' build ' , ' zlib ' ] ) . communicate ( ) <nl> + run_process ( [ PYTHON , path_from_root ( ' embuilder . py ' ) , ' build ' , ' zlib ' ] ) <nl> + <nl> zlib = Cache . get_path ( os . path . join ( ' ports - builds ' , ' zlib ' , ' libz . a ' ) ) <nl> try : <nl> os . environ [ ' EMCC_FORCE_STDLIBS ' ] = ' libcextra ' <nl> def test ( ) : <nl> time . sleep ( random . random ( ) / ( 10 * num ) ) # add some timing nondeterminism here , not that we need it , but whatever <nl> self . do_run ( src , ' hello world \ n77 . \ n ' ) <nl> ret = open ( ' src . cpp . o . js ' , ' rb ' ) . read ( ) <nl> - if Settings . BINARYEN : <nl> + if Settings . WASM : <nl> ret + = open ( ' src . cpp . o . wasm ' , ' rb ' ) . read ( ) <nl> return ret <nl> builds = [ test ( ) for i in range ( num ) ] <nl> def test_eval_ctors ( self ) : <nl> int main ( ) { } <nl> ' ' ' , " constructing ! \ n " ) ; <nl> <nl> - code_file = ' src . cpp . o . js ' if not Settings . BINARYEN else ' src . cpp . o . wasm ' <nl> + code_file = ' src . cpp . o . js ' if not Settings . WASM else ' src . cpp . o . wasm ' <nl> <nl> def do_test ( test ) : <nl> self . emcc_args = orig_args + [ ' - s ' , ' EVAL_CTORS = 1 ' ] <nl> def build_and_check ( ) : <nl> import json <nl> Building . emcc ( src_filename , Settings . serialize ( ) + self . emcc_args + <nl> Building . COMPILER_TEST_OPTS , out_filename , stderr = PIPE ) <nl> - map_referent = out_filename if not Settings . BINARYEN else wasm_filename <nl> + map_referent = out_filename if not Settings . WASM else wasm_filename <nl> # after removing the @ line and @ sourceMappingURL comments , the build <nl> # result should be identical to the non - source - mapped debug version . <nl> # this is worth checking because the parser AST swaps strings for token <nl> def test_stack_overflow_check ( self ) : <nl> self . emcc_args = args + [ ' - s ' , ' ASSERTIONS = 1 ' ] <nl> self . do_run ( open ( path_from_root ( ' tests ' , ' stack_overflow . cpp ' ) , ' r ' ) . read ( ) , ' Stack overflow ! Attempted to allocate ' ) <nl> <nl> - @ no_wasm <nl> - def test_binaryen ( self ) : <nl> - self . emcc_args + = [ ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " interpret - binary " ' ] <nl> - self . do_run ( open ( path_from_root ( ' tests ' , ' hello_world . c ' ) ) . read ( ) , ' hello , world ! ' ) <nl> - <nl> @ no_wasm_backend ( ' Wasm backend emits non - trapping float - to - int conversion ' ) <nl> def test_binaryen_trap_mode ( self ) : <nl> if not self . is_wasm ( ) : return self . skip ( ' wasm test ' ) <nl> def setUp ( self ) : <nl> return TT <nl> <nl> # Main asm . js test modes <nl> - default = make_run ( " default " , compiler = CLANG , emcc_args = [ " - s " , " ASM_JS = 2 " ] ) <nl> - asm1 = make_run ( " asm1 " , compiler = CLANG , emcc_args = [ " - O1 " ] ) <nl> - asm2 = make_run ( " asm2 " , compiler = CLANG , emcc_args = [ " - O2 " ] ) <nl> - asm3 = make_run ( " asm3 " , compiler = CLANG , emcc_args = [ " - O3 " ] ) <nl> - asm2g = make_run ( " asm2g " , compiler = CLANG , emcc_args = [ " - O2 " , " - g " , " - s " , " ASSERTIONS = 1 " , " - s " , " SAFE_HEAP = 1 " ] ) <nl> + default = make_run ( ' default ' , compiler = CLANG , emcc_args = [ ' - s ' , ' ASM_JS = 2 ' , ' - s ' , ' WASM = 0 ' ] ) <nl> + asm1 = make_run ( ' asm1 ' , compiler = CLANG , emcc_args = [ ' - O1 ' , ' - s ' , ' WASM = 0 ' ] ) <nl> + asm2 = make_run ( ' asm2 ' , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' WASM = 0 ' ] ) <nl> + asm3 = make_run ( ' asm3 ' , compiler = CLANG , emcc_args = [ ' - O3 ' , ' - s ' , ' WASM = 0 ' ] ) <nl> + asm2g = make_run ( ' asm2g ' , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' WASM = 0 ' , ' - g ' , ' - s ' , ' ASSERTIONS = 1 ' , ' - s ' , ' SAFE_HEAP = 1 ' ] ) <nl> <nl> # Main wasm test modes <nl> - binaryen0 = make_run ( " binaryen0 " , compiler = CLANG , emcc_args = [ ' - O0 ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm " ' ] ) <nl> - binaryen1 = make_run ( " binaryen1 " , compiler = CLANG , emcc_args = [ ' - O1 ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm " ' ] ) <nl> - binaryen2 = make_run ( " binaryen2 " , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm " ' ] ) <nl> - binaryen3 = make_run ( " binaryen3 " , compiler = CLANG , emcc_args = [ ' - O3 ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm " ' ] ) <nl> - binaryens = make_run ( " binaryens " , compiler = CLANG , emcc_args = [ ' - Os ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm " ' ] ) <nl> - binaryenz = make_run ( " binaryenz " , compiler = CLANG , emcc_args = [ ' - Oz ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm " ' ] ) <nl> + binaryen0 = make_run ( ' binaryen0 ' , compiler = CLANG , emcc_args = [ ' - O0 ' ] ) <nl> + binaryen1 = make_run ( ' binaryen1 ' , compiler = CLANG , emcc_args = [ ' - O1 ' ] ) <nl> + binaryen2 = make_run ( ' binaryen2 ' , compiler = CLANG , emcc_args = [ ' - O2 ' ] ) <nl> + binaryen3 = make_run ( ' binaryen3 ' , compiler = CLANG , emcc_args = [ ' - O3 ' ] ) <nl> + binaryens = make_run ( ' binaryens ' , compiler = CLANG , emcc_args = [ ' - Os ' ] ) <nl> + binaryenz = make_run ( ' binaryenz ' , compiler = CLANG , emcc_args = [ ' - Oz ' ] ) <nl> <nl> # Secondary test modes - run directly when there is a specific need <nl> <nl> # asm . js <nl> - asm2f = make_run ( " asm2f " , compiler = CLANG , emcc_args = [ " - Oz " , " - s " , " PRECISE_F32 = 1 " , " - s " , " ALLOW_MEMORY_GROWTH = 1 " ] ) <nl> - asm2i = make_run ( " asm2i " , compiler = CLANG , emcc_args = [ " - O2 " , ' - s ' , ' EMTERPRETIFY = 1 ' ] ) <nl> - asm2nn = make_run ( " asm2nn " , compiler = CLANG , emcc_args = [ " - O2 " ] , env = { " EMCC_NATIVE_OPTIMIZER " : " 0 " } ) <nl> + asm2f = make_run ( ' asm2f ' , compiler = CLANG , emcc_args = [ ' - Oz ' , ' - s ' , ' PRECISE_F32 = 1 ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' , ' - s ' , ' WASM = 0 ' ] ) <nl> + asm2i = make_run ( ' asm2i ' , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' EMTERPRETIFY = 1 ' , ' - s ' , ' WASM = 0 ' ] ) <nl> + asm2nn = make_run ( ' asm2nn ' , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' WASM = 0 ' ] , env = { ' EMCC_NATIVE_OPTIMIZER ' : ' 0 ' } ) <nl> <nl> # wasm <nl> - binaryen2jo = make_run ( " binaryen2jo " , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm , asmjs " ' ] ) <nl> - binaryen3jo = make_run ( " binaryen3jo " , compiler = CLANG , emcc_args = [ ' - O3 ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm , asmjs " ' ] ) <nl> - binaryen2s = make_run ( " binaryen2s " , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm " ' , ' - s ' , ' SAFE_HEAP = 1 ' ] ) <nl> - binaryen2_interpret = make_run ( " binaryen2_interpret " , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " interpret - binary " ' ] ) <nl> + binaryen2jo = make_run ( ' binaryen2jo ' , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm , asmjs " ' ] ) <nl> + binaryen3jo = make_run ( ' binaryen3jo ' , compiler = CLANG , emcc_args = [ ' - O3 ' , ' - s ' , ' BINARYEN_METHOD = " native - wasm , asmjs " ' ] ) <nl> + binaryen2s = make_run ( ' binaryen2s ' , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' SAFE_HEAP = 1 ' ] ) <nl> + binaryen2_interpret = make_run ( ' binaryen2_interpret ' , compiler = CLANG , emcc_args = [ ' - O2 ' , ' - s ' , ' BINARYEN_METHOD = " interpret - binary " ' ] ) <nl> <nl> del T # T is just a shape for the specific subclasses , we don ' t test it itself <nl> mmm a / tests / test_other . py <nl> ppp b / tests / test_other . py <nl> def test_emcc_python_version ( self ) : <nl> assert expected_call not in output <nl> assert output = = ' ' , output <nl> <nl> - def test_emcc ( self ) : <nl> + def test_emcc_1 ( self ) : <nl> for compiler in [ EMCC , EMXX ] : <nl> shortcompiler = os . path . basename ( compiler ) <nl> suffix = ' . c ' if compiler = = EMCC else ' . cpp ' <nl> def test_emcc ( self ) : <nl> output = run_process ( [ PYTHON , compiler , ' - dumpversion ' ] , stdout = PIPE , stderr = PIPE ) <nl> self . assertEqual ( EMSCRIPTEN_VERSION + os . linesep , output . stdout , ' results should be identical ' ) <nl> <nl> - # emcc src . cpp = = > writes a . out . js <nl> + # emcc src . cpp = = > writes a . out . js and a . out . wasm <nl> self . clear ( ) <nl> output = run_process ( [ PYTHON , compiler , path_from_root ( ' tests ' , ' hello_world ' + suffix ) ] , stdout = PIPE , stderr = PIPE ) <nl> assert len ( output . stdout ) = = 0 , output . stdout <nl> assert os . path . exists ( ' a . out . js ' ) , output . stdout + ' \ n ' + output . stderr <nl> + assert os . path . exists ( ' a . out . wasm ' ) , output . stdout + ' \ n ' + output . stderr <nl> self . assertContained ( ' hello , world ! ' , run_js ( ' a . out . js ' ) ) <nl> <nl> # properly report source code errors , and stop there <nl> def test_emcc ( self ) : <nl> self . assertContained ( ' errors generated ' , process . stderr ) <nl> assert ' compiler frontend failed to generate LLVM bitcode , halting ' in process . stderr . split ( ' errors generated . ' ) [ 1 ] <nl> <nl> + def test_emcc_2 ( self ) : <nl> + for compiler in [ EMCC , EMXX ] : <nl> + shortcompiler = os . path . basename ( compiler ) <nl> + suffix = ' . c ' if compiler = = EMCC else ' . cpp ' <nl> + <nl> # emcc src . cpp - c and emcc src . cpp - o src . [ o | bc ] = = > should give a . bc file <nl> # regression check : - o js should create " js " , with bitcode content <nl> for args in [ [ ' - c ' ] , [ ' - o ' , ' src . o ' ] , [ ' - o ' , ' src . bc ' ] , [ ' - o ' , ' src . so ' ] , [ ' - o ' , ' js ' ] , [ ' - O1 ' , ' - c ' , ' - o ' , ' / dev / null ' ] , [ ' - O1 ' , ' - o ' , ' / dev / null ' ] ] : <nl> def test_emcc ( self ) : <nl> assert os . path . exists ( target + ' . js ' ) , ' Expected % s to exist since args are % s : % s ' % ( target + ' . js ' , str ( args ) , output . stdout + ' \ n ' + output . stderr ) <nl> self . assertContained ( ' hello , world ! ' , run_js ( target + ' . js ' ) ) <nl> <nl> + def test_emcc_3 ( self ) : <nl> + for compiler in [ EMCC , EMXX ] : <nl> + shortcompiler = os . path . basename ( compiler ) <nl> + suffix = ' . c ' if compiler = = EMCC else ' . cpp ' <nl> + <nl> # handle singleton archives <nl> self . clear ( ) <nl> Popen ( [ PYTHON , compiler , path_from_root ( ' tests ' , ' hello_world ' + suffix ) , ' - o ' , ' a . bc ' ] , stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> def test_emcc ( self ) : <nl> if not os . path . exists ( ' a_dir ' ) : os . mkdir ( ' a_dir ' ) <nl> os . chdir ( ' a_dir ' ) <nl> if not os . path . exists ( ' b_dir ' ) : os . mkdir ( ' b_dir ' ) <nl> - output = run_process ( [ PYTHON , compiler , path_from_root ( ' tests ' , ' hello_world . ll ' ) , ' - o ' , path ] , stdout = PIPE , stderr = PIPE ) <nl> + # use single file so we don ' t have more files to clean up <nl> + output = run_process ( [ PYTHON , compiler , path_from_root ( ' tests ' , ' hello_world . ll ' ) , ' - o ' , path , ' - s ' , ' SINGLE_FILE = 1 ' ] , stdout = PIPE , stderr = PIPE ) <nl> print ( output ) <nl> assert os . path . exists ( path ) , path + ' does not exist ; ' + output . stdout + ' \ n ' + output . stderr <nl> last = os . getcwd ( ) <nl> def test_emcc ( self ) : <nl> os . chdir ( self . get_dir ( ) ) <nl> self . clear ( ) <nl> <nl> + def test_emcc_4 ( self ) : <nl> + for compiler in [ EMCC , EMXX ] : <nl> + shortcompiler = os . path . basename ( compiler ) <nl> + suffix = ' . c ' if compiler = = EMCC else ' . cpp ' <nl> + <nl> # Optimization : emcc src . cpp - o something . js [ - Ox ] . - O0 is the same as not specifying any optimization setting <nl> for params , opt_level , bc_params , closure , has_malloc in [ # bc params are used after compiling to bitcode <nl> ( [ ' - o ' , ' something . js ' ] , 0 , None , 0 , 1 ) , <nl> def test_emcc ( self ) : <nl> ( [ ' - o ' , ' something . bc ' , ' - O2 ' ] , 2 , [ ' - O2 ' ] , 0 , 0 ) , <nl> ( [ ' - o ' , ' something . bc ' , ' - O3 ' ] , 3 , [ ' - O3 ' ] , 0 , 0 ) , <nl> ( [ ' - O1 ' , ' - o ' , ' something . bc ' ] , 1 , [ ] , 0 , 0 ) , <nl> + # non - wasm <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . js ' ] , 0 , None , 0 , 1 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . js ' , ' - O0 ' ] , 0 , None , 0 , 0 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . js ' , ' - O1 ' ] , 1 , None , 0 , 0 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . js ' , ' - O1 ' , ' - g ' ] , 1 , None , 0 , 0 ) , # no closure since debug <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . js ' , ' - O2 ' ] , 2 , None , 0 , 1 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . js ' , ' - O2 ' , ' - g ' ] , 2 , None , 0 , 0 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . js ' , ' - Os ' ] , 2 , None , 0 , 1 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . js ' , ' - O3 ' ] , 3 , None , 0 , 1 ) , <nl> + # and , test compiling to bitcode first <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . bc ' ] , 0 , [ ' - s ' , ' WASM = 0 ' ] , 0 , 0 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . bc ' , ' - O0 ' ] , 0 , [ ' - s ' , ' WASM = 0 ' ] , 0 , 0 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . bc ' , ' - O1 ' ] , 1 , [ ' - s ' , ' WASM = 0 ' , ' - O1 ' ] , 0 , 0 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . bc ' , ' - O2 ' ] , 2 , [ ' - s ' , ' WASM = 0 ' , ' - O2 ' ] , 0 , 0 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - o ' , ' something . bc ' , ' - O3 ' ] , 3 , [ ' - s ' , ' WASM = 0 ' , ' - O3 ' ] , 0 , 0 ) , <nl> + ( [ ' - s ' , ' WASM = 0 ' , ' - O1 ' , ' - o ' , ' something . bc ' ] , 1 , [ ' - s ' , ' WASM = 0 ' ] , 0 , 0 ) , <nl> ] : <nl> print ( params , opt_level , bc_params , closure , has_malloc ) <nl> self . clear ( ) <nl> def test_emcc ( self ) : <nl> if keep_debug : <nl> assert ( ' switch ( label ) ' in generated or ' switch ( label | 0 ) ' in generated ) = = ( opt_level < = 0 ) , ' relooping should be in opt > = 1 ' <nl> assert ( ' assert ( STACKTOP < STACK_MAX ' in generated ) = = ( opt_level = = 0 ) , ' assertions should be in opt = = 0 ' <nl> - assert ' $ i ' in generated or ' $ storemerge ' in generated or ' $ original ' in generated , ' micro opts should always be on ' <nl> - if opt_level > = 2 and ' - g ' in params : <nl> - assert re . search ( ' HEAP8 \ [ \ $ ? \ w + ? \ + ? \ ( + \ $ ? \ w + ? ' , generated ) or re . search ( ' HEAP8 \ [ HEAP32 \ [ ' , generated ) or re . search ( ' [ i $ ] \ d + & ~ \ ( 1 < < [ i $ ] \ d + \ ) ' , generated ) , ' eliminator should create compound expressions , and fewer one - time vars ' # also in - O1 , but easier to test in - O2 <nl> - if opt_level = = 0 or ' - g ' in params : assert ' function _main ( ) { ' in generated or ' function _main ( ) { ' in generated , ' Should be unminified ' <nl> - elif opt_level > = 2 : assert ( ' function _main ( ) { ' in generated or ' " use asm " ; var a = ' in generated ) , ' Should be whitespace - minified ' <nl> + if ' WASM = 0 ' in params : <nl> + if opt_level > = 2 and ' - g ' in params : <nl> + assert re . search ( ' HEAP8 \ [ \ $ ? \ w + ? \ + ? \ ( + \ $ ? \ w + ? ' , generated ) or re . search ( ' HEAP8 \ [ HEAP32 \ [ ' , generated ) or re . search ( ' [ i $ ] \ d + & ~ \ ( 1 < < [ i $ ] \ d + \ ) ' , generated ) , ' eliminator should create compound expressions , and fewer one - time vars ' # also in - O1 , but easier to test in - O2 <nl> + if opt_level = = 0 or ' - g ' in params : assert ' function _main ( ) { ' in generated or ' function _main ( ) { ' in generated , ' Should be unminified ' <nl> + elif opt_level > = 2 : assert ( ' function _main ( ) { ' in generated or ' " use asm " ; var a = ' in generated ) , ' Should be whitespace - minified ' <nl> + <nl> + def test_emcc_5 ( self ) : <nl> + for compiler in [ EMCC , EMXX ] : <nl> + shortcompiler = os . path . basename ( compiler ) <nl> + suffix = ' . c ' if compiler = = EMCC else ' . cpp ' <nl> <nl> - # emcc - s INLINING_LIMIT = 0 src . cpp = = > should pass - s to emscripten . py . <nl> + # asm . js optimization levels <nl> for params , test , text in [ <nl> ( [ ' - O2 ' ] , lambda generated : ' function addRunDependency ' in generated , ' shell has unminified utilities ' ) , <nl> ( [ ' - O2 ' , ' - - closure ' , ' 1 ' ] , lambda generated : ' function addRunDependency ' not in generated and ' ; function ' in generated , ' closure minifies the shell , removes whitespace ' ) , <nl> def test_emcc ( self ) : <nl> ] : <nl> print ( params , text ) <nl> self . clear ( ) <nl> - output = run_process ( [ PYTHON , compiler , path_from_root ( ' tests ' , ' hello_world_loop . cpp ' ) , ' - o ' , ' a . out . js ' ] + params , stdout = PIPE , stderr = PIPE ) <nl> + output = run_process ( [ PYTHON , compiler , path_from_root ( ' tests ' , ' hello_world_loop . cpp ' ) , ' - o ' , ' a . out . js ' , ' - s ' , ' WASM = 0 ' ] + params , stdout = PIPE , stderr = PIPE ) <nl> assert len ( output . stdout ) = = 0 , output . stdout <nl> assert os . path . exists ( ' a . out . js ' ) , output . stdout + ' \ n ' + output . stderr <nl> self . assertContained ( ' hello , world ! ' , run_js ( ' a . out . js ' ) ) <nl> assert test ( open ( ' a . out . js ' ) . read ( ) ) , text <nl> <nl> + def test_emcc_6 ( self ) : <nl> + for compiler in [ EMCC , EMXX ] : <nl> + shortcompiler = os . path . basename ( compiler ) <nl> + suffix = ' . c ' if compiler = = EMCC else ' . cpp ' <nl> + <nl> # Compiling two source files into a final JS . <nl> for args , target in [ ( [ ] , ' a . out . js ' ) , ( [ ' - o ' , ' combined . js ' ] , ' combined . js ' ) ] : <nl> self . clear ( ) <nl> def test_emcc ( self ) : <nl> assert os . path . exists ( ' combined . bc . js ' ) , ' Expected % s to exist ' % ( ' combined . bc . js ' ) <nl> self . assertContained ( ' side got : hello from main , over ' , run_js ( ' combined . bc . js ' ) ) <nl> <nl> + def test_emcc_7 ( self ) : <nl> + for compiler in [ EMCC , EMXX ] : <nl> + shortcompiler = os . path . basename ( compiler ) <nl> + suffix = ' . c ' if compiler = = EMCC else ' . cpp ' <nl> + <nl> # - - js - transform < transform > <nl> self . clear ( ) <nl> trans = os . path . join ( self . get_dir ( ) , ' t . py ' ) <nl> trans_file = open ( trans , ' w ' ) <nl> trans_file . write ( ' ' ' <nl> import sys <nl> - f = open ( sys . argv [ 1 ] , ' w ' ) <nl> + f = open ( sys . argv [ 1 ] , ' a ' ) <nl> f . write ( ' transformed ! ' ) <nl> f . close ( ) <nl> ' ' ' ) <nl> trans_file . close ( ) <nl> output = Popen ( [ PYTHON , compiler , path_from_root ( ' tests ' , ' hello_world ' + suffix ) , ' - - js - transform ' , ' % s t . py ' % ( PYTHON ) ] , stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> - assert open ( ' a . out . js ' ) . read ( ) = = ' transformed ! ' , ' Transformed output must be as expected ' <nl> + assert ' transformed ! ' in open ( ' a . out . js ' ) . read ( ) , ' Transformed output must be as expected ' <nl> <nl> for opts in [ 0 , 1 , 2 , 3 ] : <nl> print ( ' mem init in ' , opts ) <nl> self . clear ( ) <nl> - output = Popen ( [ PYTHON , compiler , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - O ' + str ( opts ) ] , stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> + output = Popen ( [ PYTHON , compiler , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 0 ' , ' - O ' + str ( opts ) ] , stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> assert os . path . exists ( ' a . out . js . mem ' ) = = ( opts > = 2 ) , ' mem file should exist in - O2 + ' <nl> <nl> + def test_emcc_asm_v_wasm ( self ) : <nl> + for opts in ( [ ] , [ ' - O1 ' ] , [ ' - O2 ' ] , [ ' - O3 ' ] ) : <nl> + print ( ' opts ' , opts ) <nl> + for mode in ( [ ] , [ ' - s ' , ' WASM = 0 ' ] , [ ' - s ' , ' BINARYEN = 0 ' ] , [ ' - s ' , ' WASM = 1 ' ] , [ ' - s ' , ' BINARYEN = 1 ' ] ) : <nl> + self . clear ( ) <nl> + wasm = ' = 0 ' not in str ( mode ) <nl> + print ( ' mode ' , mode , ' wasm ? ' , wasm ) <nl> + run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) ] + opts + mode ) <nl> + assert os . path . exists ( ' a . out . js ' ) <nl> + assert os . path . exists ( ' a . out . wasm ' ) = = wasm <nl> + for engine in JS_ENGINES : <nl> + print ( ' engine ' , engine ) <nl> + out = run_js ( ' a . out . js ' , engine = engine , stderr = PIPE , full_output = True ) <nl> + self . assertContained ( ' hello , world ! ' , out ) <nl> + if not wasm and engine = = SPIDERMONKEY_ENGINE : self . validate_asmjs ( out ) <nl> + if not wasm : <nl> + src = open ( ' a . out . js ' ) . read ( ) <nl> + if opts = = [ ] : <nl> + assert ' almost asm ' in src <nl> + else : <nl> + assert ' use asm ' in src <nl> + <nl> # Test that if multiple processes attempt to access or build stuff to the cache on demand , that exactly one of the processes <nl> # will , and the other processes will block to wait until that process finishes . <nl> def test_emcc_multiprocess_cache_access ( self ) : <nl> def test_emcc_multiprocess_cache_access ( self ) : <nl> tasks = [ ] <nl> num_times_libc_was_built = 0 <nl> for i in range ( 3 ) : <nl> - p = subprocess . Popen ( [ PYTHON , EMCC , c_file , ' - - cache ' , cache_dir_name ] , stderr = subprocess . STDOUT , stdout = PIPE , universal_newlines = True ) <nl> + p = subprocess . Popen ( [ PYTHON , EMCC , c_file , ' - - cache ' , cache_dir_name , ' - o ' , ' % d . js ' % i ] , stderr = subprocess . STDOUT , stdout = PIPE , universal_newlines = True ) <nl> tasks + = [ p ] <nl> for p in tasks : <nl> stdout , stderr = p . communicate ( ) <nl> + print ( ' stdout : \ n ' , stdout ) <nl> + print ( ' stderr : \ n ' , stderr ) <nl> assert not p . returncode , ' A child process failed with return code % s : % s ' % ( p . returncode , stderr ) <nl> if ' generating system library : libc . bc ' in stdout : <nl> num_times_libc_was_built + = 1 <nl> class Test { <nl> <nl> def test_asm_minify ( self ) : <nl> def test ( args ) : <nl> - Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world_loop_malloc . cpp ' ) ] + args ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world_loop_malloc . cpp ' ) , ' - s ' , ' WASM = 0 ' ] + args ) . communicate ( ) <nl> self . assertContained ( ' hello , world ! ' , run_js ( self . in_dir ( ' a . out . js ' ) ) ) <nl> return open ( self . in_dir ( ' a . out . js ' ) ) . read ( ) <nl> <nl> def test ( args , expected , moar_expected = None ) : <nl> print ( args , expected , moar_expected ) <nl> out , err = Popen ( [ PYTHON , EMCC , ' src . c ' ] + args , stderr = PIPE ) . communicate ( ) <nl> self . assertContained ( expected , run_js ( self . in_dir ( ' a . out . js ' ) , stderr = PIPE , full_output = True , assert_returncode = None ) ) <nl> - print ( ' with emulated function pointers ' ) <nl> - Popen ( [ PYTHON , EMCC , ' src . c ' ] + args + [ ' - s ' , ' EMULATED_FUNCTION_POINTERS = 1 ' ] , stderr = PIPE ) . communicate ( ) <nl> + print ( ' in asm . js ' ) <nl> + out , err = Popen ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' WASM = 0 ' ] + args , stderr = PIPE ) . communicate ( ) <nl> + self . assertContained ( expected , run_js ( self . in_dir ( ' a . out . js ' ) , stderr = PIPE , full_output = True , assert_returncode = None ) ) <nl> + # TODO : emulation function support in wasm is imperfect <nl> + print ( ' with emulated function pointers in asm . js ' ) <nl> + Popen ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' ] + args + [ ' - s ' , ' EMULATED_FUNCTION_POINTERS = 1 ' ] , stderr = PIPE ) . communicate ( ) <nl> out = run_js ( self . in_dir ( ' a . out . js ' ) , stderr = PIPE , full_output = True , assert_returncode = None ) <nl> self . assertContained ( expected , out ) <nl> if moar_expected : self . assertContained ( moar_expected , out ) <nl> def measure_funcs ( filename ) : <nl> for outlining_limit in outlining_limits : <nl> print ( ' \ n ' , Building . COMPILER_TEST_OPTS , debug , outlining_limit , ' \ n ' ) <nl> # TODO : test without - g3 , tell all sorts <nl> - Popen ( [ PYTHON , EMCC , src ] + libs + [ ' - o ' , ' test . js ' , ' - O2 ' ] + debug + [ ' - s ' , ' OUTLINING_LIMIT = % d ' % outlining_limit ] + args ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , src ] + libs + [ ' - o ' , ' test . js ' , ' - O2 ' , ' - s ' , ' WASM = 0 ' ] + debug + [ ' - s ' , ' OUTLINING_LIMIT = % d ' % outlining_limit ] + args ) . communicate ( ) <nl> assert os . path . exists ( ' test . js ' ) <nl> shutil . copyfile ( ' test . js ' , ' % d_test . js ' % outlining_limit ) <nl> for engine in JS_ENGINES : <nl> def test_export_all ( self ) : <nl> open ( lib_name , ' w ' ) . write ( lib ) <nl> <nl> open ( ' main . js ' , ' w ' ) . write ( ' ' ' <nl> - _libf1 ( ) ; <nl> - _libf2 ( ) ; <nl> + var Module = { <nl> + onRuntimeInitialized : function ( ) { <nl> + _libf1 ( ) ; <nl> + _libf2 ( ) ; <nl> + } <nl> + } ; <nl> ' ' ' ) <nl> <nl> - Building . emcc ( lib_name , [ ' - s ' , ' EXPORT_ALL = 1 ' , ' - s ' , ' LINKABLE = 1 ' , ' - - post - js ' , ' main . js ' ] , output_filename = ' a . out . js ' ) <nl> + Building . emcc ( lib_name , [ ' - s ' , ' EXPORT_ALL = 1 ' , ' - s ' , ' LINKABLE = 1 ' , ' - - pre - js ' , ' main . js ' ] , output_filename = ' a . out . js ' ) <nl> <nl> self . assertContained ( ' libf1 \ nlibf2 \ n ' , run_js ( os . path . join ( self . get_dir ( ) , ' a . out . js ' ) ) ) <nl> <nl> def test_dup_o_in_one_a ( self ) : <nl> <nl> def test_export_in_a ( self ) : <nl> export_name = ' this_is_an_entry_point ' <nl> + full_export_name = ' _ ' + export_name <nl> <nl> open ( ' export . c ' , ' w ' ) . write ( r ' ' ' <nl> # include < stdio . h > <nl> def test_export_in_a ( self ) : <nl> } <nl> ' ' ' ) <nl> <nl> - definition = ' function _ % s ( ' % export_name <nl> - <nl> # Sanity check : the symbol should not be linked in if not requested . <nl> Popen ( [ PYTHON , EMCC , ' main . c ' , ' - L . ' , ' - lexport ' ] ) . communicate ( ) <nl> - self . assertNotContained ( definition , open ( os . path . join ( self . get_dir ( ) , ' a . out . js ' ) ) . read ( ) ) <nl> + assert not self . is_exported_in_wasm ( full_export_name , ' a . out . wasm ' ) <nl> <nl> # Sanity check : exporting without a definition does not cause it to appear . <nl> # Note : exporting main prevents emcc from warning that it generated no code . <nl> - Popen ( [ PYTHON , EMCC , ' main . c ' , ' - s ' , ' ' ' EXPORTED_FUNCTIONS = [ ' _main ' , ' _ % s ' ] ' ' ' % export_name ] ) . communicate ( ) <nl> - self . assertNotContained ( definition , open ( os . path . join ( self . get_dir ( ) , ' a . out . js ' ) ) . read ( ) ) <nl> + Popen ( [ PYTHON , EMCC , ' main . c ' , ' - s ' , ' ' ' EXPORTED_FUNCTIONS = [ ' _main ' , ' % s ' ] ' ' ' % full_export_name ] ) . communicate ( ) <nl> + assert not self . is_exported_in_wasm ( full_export_name , ' a . out . wasm ' ) <nl> <nl> # Actual test : defining symbol in library and exporting it causes it to appear in the output . <nl> - Popen ( [ PYTHON , EMCC , ' main . c ' , ' - L . ' , ' - lexport ' , ' - s ' , ' ' ' EXPORTED_FUNCTIONS = [ ' _ % s ' ] ' ' ' % export_name ] ) . communicate ( ) <nl> - self . assertContained ( definition , open ( os . path . join ( self . get_dir ( ) , ' a . out . js ' ) ) . read ( ) ) <nl> + Popen ( [ PYTHON , EMCC , ' main . c ' , ' - L . ' , ' - lexport ' , ' - s ' , ' ' ' EXPORTED_FUNCTIONS = [ ' % s ' ] ' ' ' % full_export_name ] ) . communicate ( ) <nl> + assert self . is_exported_in_wasm ( full_export_name , ' a . out . wasm ' ) <nl> <nl> def test_embed_file ( self ) : <nl> open ( os . path . join ( self . get_dir ( ) , ' somefile . txt ' ) , ' w ' ) . write ( ' ' ' hello from a file with lots of data and stuff in it thank you very much ' ' ' ) <nl> def test_js_link ( self ) : <nl> Module . print ( MESSAGE ) ; <nl> ' ' ' ) <nl> <nl> - Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - - pre - js ' , ' before . js ' , ' - - post - js ' , ' after . js ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - - pre - js ' , ' before . js ' , ' - - post - js ' , ' after . js ' , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' ] ) . communicate ( ) <nl> self . assertContained ( ' hello from main \ nhello from js \ n ' , run_js ( os . path . join ( self . get_dir ( ) , ' a . out . js ' ) ) ) <nl> <nl> def test_sdl_endianness ( self ) : <nl> def test_prepost ( self ) : <nl> } ; <nl> ' ' ' ) <nl> <nl> - Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - - pre - js ' , ' pre . js ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - - pre - js ' , ' pre . js ' , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' ] ) . communicate ( ) <nl> self . assertContained ( ' pre - run \ nhello from main \ npost - run \ n ' , run_js ( os . path . join ( self . get_dir ( ) , ' a . out . js ' ) ) ) <nl> <nl> # never run , so no preRun or postRun <nl> def test_prepost ( self ) : <nl> # noInitialRun prevents run <nl> for no_initial_run , run_dep in [ ( 0 , 0 ) , ( 1 , 0 ) , ( 0 , 1 ) ] : <nl> print ( no_initial_run , run_dep ) <nl> - Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' ] ) . communicate ( ) <nl> src = ' var Module = { noInitialRun : % d } ; \ n ' % no_initial_run + open ( os . path . join ( self . get_dir ( ) , ' a . out . js ' ) ) . read ( ) <nl> if run_dep : <nl> src = src . replace ( ' / / { { PRE_RUN_ADDITIONS } } ' , ' / / { { PRE_RUN_ADDITIONS } } \ naddRunDependency ( " test " ) ; ' ) \ <nl> def test_debuginfo ( self ) : <nl> <nl> try : <nl> os . environ [ ' EMCC_DEBUG ' ] = ' 1 ' <nl> - for args , expect_llvm , expect_js in [ <nl> - ( [ ' - O0 ' ] , False , True ) , <nl> - ( [ ' - O0 ' , ' - g ' ] , True , True ) , <nl> - ( [ ' - O0 ' , ' - g4 ' ] , True , True ) , <nl> - ( [ ' - O1 ' ] , False , True ) , <nl> - ( [ ' - O1 ' , ' - g ' ] , True , True ) , <nl> - ( [ ' - O2 ' ] , False , False ) , <nl> - ( [ ' - O2 ' , ' - g ' ] , False , True ) , # drop llvm debug info as js opts kill it anyway <nl> - ( [ ' - O2 ' , ' - g4 ' ] , True , True ) , # drop llvm debug info as js opts kill it anyway <nl> + for args , expect_llvm in [ <nl> + ( [ ' - O0 ' ] , False ) , <nl> + ( [ ' - O0 ' , ' - g ' ] , True ) , <nl> + ( [ ' - O0 ' , ' - g4 ' ] , True ) , <nl> + ( [ ' - O1 ' ] , False ) , <nl> + ( [ ' - O1 ' , ' - g ' ] , True ) , <nl> + ( [ ' - O2 ' ] , False ) , <nl> + ( [ ' - O2 ' , ' - g ' ] , True ) , <nl> ] : <nl> - print ( args , expect_llvm , expect_js ) <nl> + print ( args , expect_llvm ) <nl> with clean_write_access_to_canonical_temp_dir ( self . canonical_temp_dir ) : <nl> err = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . cpp ' ) ] + args , stdout = PIPE , stderr = PIPE ) . stderr <nl> - assert expect_llvm = = ( ' strip - debug ' not in err ) <nl> - assert expect_js = = ( ' registerize ' not in err ) <nl> + assert expect_llvm = = ( ' strip - debug ' not in err ) , err <nl> finally : <nl> del os . environ [ ' EMCC_DEBUG ' ] <nl> <nl> def test_embind ( self ) : <nl> path_from_root ( ' tests ' , ' embind ' , ' embind_test . cpp ' ) , <nl> ' - - pre - js ' , path_from_root ( ' tests ' , ' embind ' , ' test . pre . js ' ) , <nl> ' - - post - js ' , path_from_root ( ' tests ' , ' embind ' , ' test . post . js ' ) , <nl> + ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' <nl> ] + args , <nl> stderr = PIPE if fail else None , <nl> env = environ ) . communicate ( ) <nl> def test_demangle ( self ) : <nl> <nl> # full demangle support <nl> <nl> - Popen ( [ PYTHON , EMCC , ' src . cpp ' , ' - s ' , ' DEMANGLE_SUPPORT = 1 ' ] ) . communicate ( ) <nl> + run_process ( [ PYTHON , EMCC , ' src . cpp ' , ' - s ' , ' DEMANGLE_SUPPORT = 1 ' ] ) <nl> output = run_js ( ' a . out . js ' ) <nl> self . assertContained ( ' ' ' operator new ( unsigned int ) <nl> _main <nl> def test_demangle ( self ) : <nl> void wakaw : : Cm : : RasterBase < wakaw : : watwat : : Polocator > : : merbine1 < wakaw : : Cm : : RasterBase < wakaw : : watwat : : Polocator > : : OR > ( unsigned int const * , unsigned int ) <nl> ' ' ' , output ) <nl> # test for multiple functions in one stack trace <nl> - assert ' one ( int ) ' in output <nl> - assert ' two ( char ) ' in output <nl> + run_process ( [ PYTHON , EMCC , ' src . cpp ' , ' - s ' , ' DEMANGLE_SUPPORT = 1 ' , ' - g ' ] ) <nl> + output = run_js ( ' a . out . js ' ) <nl> + assert ' one ( int ) ' in output , out <nl> + assert ' two ( char ) ' in output , out <nl> <nl> def test_demangle_cpp ( self ) : <nl> open ( ' src . cpp ' , ' w ' ) . write ( ' ' ' <nl> def test_module_exports_with_closure ( self ) : <nl> self . clear ( ) <nl> <nl> # compile with - O2 - - closure 0 <nl> - Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' Module - exports ' , ' test . c ' ) , ' - o ' , ' test . js ' , ' - O2 ' , ' - - closure ' , ' 0 ' , ' - - pre - js ' , path_from_root ( ' tests ' , ' Module - exports ' , ' setup . js ' ) , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _bufferTest " ] ' , ' - s ' , ' EXTRA_EXPORTED_RUNTIME_METHODS = [ " ccall " , " cwrap " ] ' ] , stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' Module - exports ' , ' test . c ' ) , ' - o ' , ' test . js ' , ' - O2 ' , ' - - closure ' , ' 0 ' , ' - - pre - js ' , path_from_root ( ' tests ' , ' Module - exports ' , ' setup . js ' ) , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _bufferTest " ] ' , ' - s ' , ' EXTRA_EXPORTED_RUNTIME_METHODS = [ " ccall " , " cwrap " ] ' , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' ] , stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> <nl> # Check that compilation was successful <nl> assert os . path . exists ( ' test . js ' ) <nl> test_js_closure_0 = open ( ' test . js ' ) . read ( ) <nl> <nl> # Check that test . js compiled with - - closure 0 contains " module [ ' exports ' ] = Module ; " <nl> - assert ( " module [ ' exports ' ] = Module ; " in test_js_closure_0 ) or ( ' module [ " exports " ] = Module ' in test_js_closure_0 ) <nl> + assert ( " module [ ' exports ' ] = Module ; " in test_js_closure_0 ) or ( ' module [ " exports " ] = Module ' in test_js_closure_0 ) or ( ' module [ " exports " ] = Module ; ' in test_js_closure_0 ) <nl> <nl> # Check that main . js ( which requires test . js ) completes successfully when run in node . js <nl> # in order to check that the exports are indeed functioning correctly . <nl> def test_module_exports_with_closure ( self ) : <nl> assert not os . path . exists ( path_from_root ( ' tests ' , ' Module - exports ' , ' test . js ' ) ) <nl> <nl> # compile with - O2 - - closure 1 <nl> - Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' Module - exports ' , ' test . c ' ) , ' - o ' , path_from_root ( ' tests ' , ' Module - exports ' , ' test . js ' ) , ' - O2 ' , ' - - closure ' , ' 1 ' , ' - - pre - js ' , path_from_root ( ' tests ' , ' Module - exports ' , ' setup . js ' ) , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _bufferTest " ] ' ] , stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' Module - exports ' , ' test . c ' ) , ' - o ' , path_from_root ( ' tests ' , ' Module - exports ' , ' test . js ' ) , ' - O2 ' , ' - - closure ' , ' 1 ' , ' - - pre - js ' , path_from_root ( ' tests ' , ' Module - exports ' , ' setup . js ' ) , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _bufferTest " ] ' , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' ] , stdout = PIPE , stderr = PIPE ) . communicate ( ) <nl> <nl> # Check that compilation was successful <nl> assert os . path . exists ( path_from_root ( ' tests ' , ' Module - exports ' , ' test . js ' ) ) <nl> def check_simd ( self , expected_simds , expected_out ) : <nl> assert simds > = expected_simds , ' expecting to see at least % d SIMD * uses , but seeing % d ' % ( expected_simds , simds ) <nl> <nl> def test_autovectorize_linpack ( self ) : <nl> - Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' linpack . c ' ) , ' - O2 ' , ' - s ' , ' SIMD = 1 ' , ' - DSP ' , ' - s ' , ' PRECISE_F32 = 1 ' , ' - - profiling ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' linpack . c ' ) , ' - O2 ' , ' - s ' , ' SIMD = 1 ' , ' - DSP ' , ' - s ' , ' PRECISE_F32 = 1 ' , ' - - profiling ' , ' - s ' , ' WASM = 0 ' ] ) . communicate ( ) <nl> self . check_simd ( 30 , ' Unrolled Single Precision ' ) <nl> <nl> def test_dependency_file ( self ) : <nl> def test_js_lib_using_asm_lib ( self ) : <nl> asmlibfunc__asm : true , <nl> asmlibfunc__sig : ' ii ' , <nl> asmlibfunc : function ( x ) { <nl> - return x + 1 ; <nl> + x = x | 0 ; <nl> + return x + 1 | 0 ; <nl> } <nl> } ) ; <nl> ' ' ' ) <nl> def test_warn_unaligned ( self ) : <nl> return 0 ; <nl> } <nl> ' ' ' ) <nl> - output = run_process ( [ PYTHON , EMCC , ' src . cpp ' , ' - s ' , ' WARN_UNALIGNED = 1 ' ] , stderr = PIPE ) <nl> - output = run_process ( [ PYTHON , EMCC , ' src . cpp ' , ' - s ' , ' WARN_UNALIGNED = 1 ' , ' - g ' ] , stderr = PIPE ) <nl> + output = run_process ( [ PYTHON , EMCC , ' src . cpp ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' WARN_UNALIGNED = 1 ' ] , stderr = PIPE ) <nl> + output = run_process ( [ PYTHON , EMCC , ' src . cpp ' , ' - s ' , ' WASM = 0 ' , ' - s ' , ' WARN_UNALIGNED = 1 ' , ' - g ' ] , stderr = PIPE ) <nl> assert ' emcc : warning : unaligned store ' in output . stderr , output . stderr <nl> assert ' emcc : warning : unaligned store ' in output . stderr , output . stderr <nl> assert ' @ line 11 " src . cpp " ' in output . stderr , output . stderr <nl> <nl> def test_LEGACY_VM_SUPPORT ( self ) : <nl> # when modern features are lacking , we can polyfill them or at least warn <nl> - with open ( ' pre . js ' , ' w ' ) as f : f . write ( ' Math . imul = undefined ; ' ) <nl> def test ( expected , opts = [ ] ) : <nl> + self . clear ( ) <nl> + with open ( ' pre . js ' , ' w ' ) as f : f . write ( ' Math . imul = undefined ; ' ) <nl> subprocess . check_call ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - - pre - js ' , ' pre . js ' ] + opts ) <nl> self . assertContained ( expected , run_js ( ' a . out . js ' , stderr = PIPE , full_output = True , engine = NODE_JS , assert_returncode = None ) ) <nl> test ( ' this is a legacy browser , build with LEGACY_VM_SUPPORT ' ) <nl> + assert os . path . exists ( ' a . out . wasm ' ) , ' emit wasm by default ' <nl> test ( ' hello , world ! ' , [ ' - s ' , ' LEGACY_VM_SUPPORT = 1 ' ] ) <nl> + assert not os . path . exists ( ' a . out . wasm ' ) , ' LEGACY_VM_SUPPORT disables wasm ' <nl> <nl> def test_on_abort ( self ) : <nl> expected_output = ' Module . onAbort was called ' <nl> def add_on_abort_and_verify ( extra = ' ' ) : <nl> abort ( ) ; <nl> } <nl> ' ' ' ) <nl> - subprocess . check_call ( [ PYTHON , EMCC , ' src . c ' ] ) <nl> + subprocess . check_call ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' ] ) <nl> add_on_abort_and_verify ( ) <nl> <nl> # test direct abort ( ) JS call <nl> def add_on_abort_and_verify ( extra = ' ' ) : <nl> EM_ASM ( { abort ( ) } ) ; <nl> } <nl> ' ' ' ) <nl> - subprocess . check_call ( [ PYTHON , EMCC , ' src . c ' ] ) <nl> + subprocess . check_call ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' ] ) <nl> add_on_abort_and_verify ( ) <nl> <nl> # test throwing in an abort handler , and catching that <nl> def add_on_abort_and_verify ( extra = ' ' ) : <nl> } ) ; <nl> } <nl> ' ' ' ) <nl> - subprocess . check_call ( [ PYTHON , EMCC , ' src . c ' ] ) <nl> + subprocess . check_call ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' ] ) <nl> with open ( ' a . out . js ' ) as f : <nl> js = f . read ( ) <nl> with open ( ' a . out . js ' , ' w ' ) as f : <nl> def test_no_exit_runtime ( self ) : <nl> } <nl> ' ' ' ) <nl> <nl> - for no_exit in [ 0 , 1 ] : <nl> - for opts in [ [ ] , [ ' - O1 ' ] , [ ' - O2 ' , ' - g2 ' ] , [ ' - O2 ' , ' - g2 ' , ' - - llvm - lto ' , ' 1 ' ] ] : <nl> - print ( no_exit , opts ) <nl> - Popen ( [ PYTHON , EMCC ] + opts + [ ' code . cpp ' , ' - s ' , ' NO_EXIT_RUNTIME = ' + str ( no_exit ) ] ) . communicate ( ) <nl> - output = run_js ( os . path . join ( self . get_dir ( ) , ' a . out . js ' ) , stderr = PIPE , full_output = True , engine = NODE_JS ) <nl> - src = open ( ' a . out . js ' ) . read ( ) <nl> - exit = 1 - no_exit <nl> - assert ' coming around ' in output <nl> - assert ( ' going away ' in output ) = = exit , ' destructors should not run if no exit ' <nl> - assert ( ' _ZN5WasteILi2EED ' in src ) = = exit , ' destructors should not appear if no exit ' <nl> - assert ( ' atexit ( ' in src ) = = exit , ' atexit should not appear or be called ' <nl> + for wasm in [ 0 , 1 ] : <nl> + for no_exit in [ 0 , 1 ] : <nl> + for opts in [ [ ] , [ ' - O1 ' ] , [ ' - O2 ' , ' - g2 ' ] , [ ' - O2 ' , ' - g2 ' , ' - - llvm - lto ' , ' 1 ' ] ] : <nl> + print ( wasm , no_exit , opts ) <nl> + cmd = [ PYTHON , EMCC ] + opts + [ ' code . cpp ' , ' - s ' , ' NO_EXIT_RUNTIME = ' + str ( no_exit ) , ' - s ' , ' WASM = ' + str ( wasm ) ] <nl> + if wasm : <nl> + cmd + = [ ' - - profiling - funcs ' ] # for function names <nl> + run_process ( cmd ) <nl> + output = run_js ( os . path . join ( self . get_dir ( ) , ' a . out . js ' ) , stderr = PIPE , full_output = True , engine = NODE_JS ) <nl> + src = open ( ' a . out . js ' ) . read ( ) <nl> + if wasm : <nl> + src + = ' \ n ' + self . get_wasm_text ( ' a . out . wasm ' ) <nl> + exit = 1 - no_exit <nl> + print ( ' exit : ' , exit , ' opts : ' , opts ) <nl> + assert ' coming around ' in output <nl> + assert ( ' going away ' in output ) = = exit , ' destructors should not run if no exit ' <nl> + assert ( ' _ZN5WasteILi2EED ' in src ) = = exit , ' destructors should not appear if no exit : \ n ' + src <nl> + assert ( ' atexit ( ' in src ) = = exit , ' atexit should not appear or be called ' <nl> <nl> def test_no_exit_runtime_warnings_flush ( self ) : <nl> # check we warn if there is unflushed info <nl> def test_os_oz ( self ) : <nl> with clean_write_access_to_canonical_temp_dir ( self . canonical_temp_dir ) : <nl> err = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . cpp ' ) ] + args , stdout = PIPE , stderr = PIPE ) . stderr <nl> self . assertContained ( expect , err ) <nl> - if ' - O3 ' in args or ' - Oz ' in args or ' - Os ' in args : <nl> - self . assertContained ( ' registerizeHarder ' , err ) <nl> - else : <nl> - self . assertNotContained ( ' registerizeHarder ' , err ) <nl> self . assertContained ( ' hello , world ! ' , run_js ( ' a . out . js ' ) ) <nl> finally : <nl> del os . environ [ ' EMCC_DEBUG ' ] <nl> def test_implicit_func ( self ) : <nl> self . assertContained ( e , output ) <nl> <nl> def test_incorrect_static_call ( self ) : <nl> - for opts in [ 0 , 1 ] : <nl> - for asserts in [ 0 , 1 ] : <nl> - extra = [ ] <nl> - if opts ! = 1 - asserts : extra = [ ' - s ' , ' ASSERTIONS = ' + str ( asserts ) ] <nl> - cmd = [ PYTHON , EMCC , path_from_root ( ' tests ' , ' sillyfuncast2_noasm . ll ' ) , ' - O ' + str ( opts ) ] + extra <nl> - print ( cmd ) <nl> - stderr = run_process ( cmd , stderr = PIPE ) . stderr <nl> - assert ( ' ' ' unexpected number of arguments 3 in call to ' doit ' , should be 2 ' ' ' in stderr ) = = asserts , stderr <nl> - assert ( ' ' ' unexpected return type i32 in call to ' doit ' , should be void ' ' ' in stderr ) = = asserts , stderr <nl> - assert ( ' ' ' unexpected argument type float at index 1 in call to ' doit ' , should be i32 ' ' ' in stderr ) = = asserts , stderr <nl> + for wasm in [ 0 , 1 ] : <nl> + for opts in [ 0 , 1 ] : <nl> + for asserts in [ 0 , 1 ] : <nl> + extra = [ ] <nl> + if opts ! = 1 - asserts : extra = [ ' - s ' , ' ASSERTIONS = ' + str ( asserts ) ] <nl> + cmd = [ PYTHON , EMCC , path_from_root ( ' tests ' , ' sillyfuncast2_noasm . ll ' ) , ' - O ' + str ( opts ) , ' - s ' , ' WASM = ' + str ( wasm ) ] + extra <nl> + print ( opts , asserts , wasm , cmd ) <nl> + stderr = run_process ( cmd , stdout = PIPE , stderr = PIPE , check = False ) . stderr <nl> + assert ( ' unexpected ' in stderr ) = = asserts , stderr <nl> + assert ( " to ' doit ' " in stderr ) = = asserts , stderr <nl> <nl> def test_llvm_lit ( self ) : <nl> grep_path = Building . which ( ' grep ' ) <nl> def test ( src , nums ) : <nl> print ( opts , ifs ) <nl> if type ( ifs ) = = int : ifs = [ ifs ] <nl> try_delete ( ' a . out . js ' ) <nl> - Popen ( [ PYTHON , EMCC , ' src . c ' , ' - O2 ' ] + opts , stdout = PIPE ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' src . c ' , ' - O2 ' , ' - s ' , ' WASM = 0 ' ] + opts , stdout = PIPE ) . communicate ( ) <nl> src = open ( ' a . out . js ' ) . read ( ) <nl> main = src [ src . find ( ' function _main ' ) : src . find ( ' \ n } ' , src . find ( ' function _main ' ) ) ] <nl> actual_ifs = main . count ( ' if ( ' ) <nl> def test_bad_function_pointer_cast ( self ) : <nl> for emulate_casts in [ 0 , 1 ] : <nl> for emulate_fps in [ 0 , 1 ] : <nl> for relocate in [ 0 , 1 ] : <nl> - cmd = [ PYTHON , EMCC , ' src . cpp ' , ' - O ' + str ( opts ) , ' - s ' , ' SAFE_HEAP = ' + str ( safe ) ] <nl> - if emulate_casts : <nl> - cmd + = [ ' - s ' , ' EMULATE_FUNCTION_POINTER_CASTS = 1 ' ] <nl> - if emulate_fps : <nl> - cmd + = [ ' - s ' , ' EMULATED_FUNCTION_POINTERS = 1 ' ] <nl> - if relocate : <nl> - cmd + = [ ' - s ' , ' RELOCATABLE = 1 ' ] # disables asm - optimized safe heap <nl> - print ( cmd ) <nl> - Popen ( cmd ) . communicate ( ) <nl> - output = run_js ( ' a . out . js ' , stderr = PIPE , full_output = True , assert_returncode = None ) <nl> - if emulate_casts : <nl> - assert ' Hello , world . ' in output , output <nl> - elif safe : <nl> - assert ' Function table mask error ' in output , output <nl> - else : <nl> - if opts = = 0 : <nl> - assert ' Invalid function pointer called ' in output , output <nl> + for wasm in [ 0 , 1 ] : <nl> + cmd = [ PYTHON , EMCC , ' src . cpp ' , ' - O ' + str ( opts ) , ' - s ' , ' SAFE_HEAP = ' + str ( safe ) , ' - s ' , ' WASM = ' + str ( wasm ) ] <nl> + if emulate_casts : <nl> + cmd + = [ ' - s ' , ' EMULATE_FUNCTION_POINTER_CASTS = 1 ' ] <nl> + if emulate_fps : <nl> + cmd + = [ ' - s ' , ' EMULATED_FUNCTION_POINTERS = 1 ' ] <nl> + if relocate : <nl> + cmd + = [ ' - s ' , ' RELOCATABLE = 1 ' ] # disables asm - optimized safe heap <nl> + print ( cmd ) <nl> + Popen ( cmd ) . communicate ( ) <nl> + output = run_js ( ' a . out . js ' , stderr = PIPE , full_output = True , assert_returncode = None ) <nl> + if emulate_casts : <nl> + # success ! <nl> + self . assertContained ( ' Hello , world . ' , output ) <nl> else : <nl> - assert ' abort ( ' in output , output <nl> + # otherwise , the error depends on the mode we are in <nl> + if wasm and ( relocate or emulate_fps ) : <nl> + # wasm trap raised by the vm <nl> + self . assertContained ( ' function signature mismatch ' , output ) <nl> + elif safe and not wasm : <nl> + # non - wasm safe mode checks asm . js function table masks <nl> + self . assertContained ( ' Function table mask error ' , output ) <nl> + elif opts = = 0 : <nl> + # informative error message ( assertions are enabled in - O0 ) <nl> + self . assertContained ( ' Invalid function pointer called ' , output ) <nl> + else : <nl> + # non - informative abort ( ) <nl> + self . assertContained ( ' abort ( ' , output ) <nl> <nl> def test_aliased_func_pointers ( self ) : <nl> open ( ' src . cpp ' , ' w ' ) . write ( r ' ' ' <nl> def test_aliased_func_pointers ( self ) : <nl> sizes_dd = { } <nl> <nl> for alias in [ None , 0 , 1 ] : <nl> - cmd = [ PYTHON , EMCC , ' src . cpp ' , ' - O1 ' ] <nl> + cmd = [ PYTHON , EMCC , ' src . cpp ' , ' - O1 ' , ' - s ' , ' WASM = 0 ' ] <nl> if alias is not None : <nl> cmd + = [ ' - s ' , ' ALIASING_FUNCTION_POINTERS = ' + str ( alias ) ] <nl> else : <nl> def test_returncode ( self ) : <nl> for code in [ 0 , 123 ] : <nl> for no_exit in [ 0 , 1 ] : <nl> for call_exit in [ 0 , 1 ] : <nl> - subprocess . check_call ( [ PYTHON , EMCC , ' src . cpp ' , ' - DCODE = % d ' % code , ' - s ' , ' NO_EXIT_RUNTIME = % d ' % no_exit , ' - DCALL_EXIT = % d ' % call_exit ] ) <nl> - for engine in JS_ENGINES : <nl> - print ( code , no_exit , call_exit , engine ) <nl> - process = run_process ( engine + [ ' a . out . js ' ] , stdout = PIPE , stderr = PIPE , check = False ) <nl> - # we always emit the right exit code , whether we exit the runtime or not <nl> - assert process . returncode = = code , [ process . returncode , process . stdout , process . stderr ] <nl> - assert not process . stdout , process . stdout <nl> - if not call_exit : <nl> - assert not process . stderr , process . stderr <nl> - assert ( ' but NO_EXIT_RUNTIME is set , so halting execution but not exiting the runtime or preventing further async execution ( build with NO_EXIT_RUNTIME = 0 , if you want a true shutdown ) ' in process . stderr ) = = ( no_exit and call_exit ) , process . stderr <nl> + for async in [ 0 , 1 ] : <nl> + subprocess . check_call ( [ PYTHON , EMCC , ' src . cpp ' , ' - DCODE = % d ' % code , ' - s ' , ' NO_EXIT_RUNTIME = % d ' % no_exit , ' - DCALL_EXIT = % d ' % call_exit , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = % d ' % async ] ) <nl> + for engine in JS_ENGINES : <nl> + if async and engine = = V8_ENGINE : continue # async compilation can ' t return a code in d8 <nl> + print ( code , no_exit , call_exit , async , engine ) <nl> + process = run_process ( engine + [ ' a . out . js ' ] , stdout = PIPE , stderr = PIPE , check = False ) <nl> + # we always emit the right exit code , whether we exit the runtime or not <nl> + assert process . returncode = = code , [ process . returncode , process . stdout , process . stderr ] <nl> + assert not process . stdout , process . stdout <nl> + if not call_exit : <nl> + assert not process . stderr , process . stderr <nl> + assert ( ' but NO_EXIT_RUNTIME is set , so halting execution but not exiting the runtime or preventing further async execution ( build with NO_EXIT_RUNTIME = 0 , if you want a true shutdown ) ' in process . stderr ) = = ( no_exit and call_exit ) , process . stderr <nl> <nl> def test_emscripten_force_exit_NO_EXIT_RUNTIME ( self ) : <nl> open ( ' src . cpp ' , ' w ' ) . write ( r ' ' ' <nl> def test ( args , be_clean ) : <nl> test ( [ ' - o ' , ' c . html ' ] , True ) <nl> test ( [ ' - c ' ] , False ) <nl> <nl> - def test_dash_g ( self ) : <nl> + def test_js_dash_g ( self ) : <nl> open ( ' src . c ' , ' w ' ) . write ( ' ' ' <nl> # include < stdio . h > <nl> # include < assert . h > <nl> def check ( has ) : <nl> assert found_line_num = = has , ' Must have debug info with the line number ' <nl> assert found_filename = = has , ' Must have debug info with the filename ' <nl> <nl> - Popen ( [ PYTHON , EMCC , ' src . c ' , ' - g ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - g ' ] ) . communicate ( ) <nl> check ( True ) <nl> - Popen ( [ PYTHON , EMCC , ' src . c ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' ] ) . communicate ( ) <nl> check ( False ) <nl> - Popen ( [ PYTHON , EMCC , ' src . c ' , ' - g0 ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - g0 ' ] ) . communicate ( ) <nl> check ( False ) <nl> - Popen ( [ PYTHON , EMCC , ' src . c ' , ' - g0 ' , ' - g ' ] ) . communicate ( ) # later one overrides <nl> + Popen ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - g0 ' , ' - g ' ] ) . communicate ( ) # later one overrides <nl> check ( True ) <nl> - Popen ( [ PYTHON , EMCC , ' src . c ' , ' - g ' , ' - g0 ' ] ) . communicate ( ) # later one overrides <nl> + Popen ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - g ' , ' - g0 ' ] ) . communicate ( ) # later one overrides <nl> check ( False ) <nl> <nl> def test_dash_g_bc ( self ) : <nl> def do ( name , source , moar_opts ) : <nl> self . clear ( ) <nl> Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , source ) , ' - o ' , name + ' . js ' ] + opts + moar_opts ) . communicate ( ) <nl> sizes [ name ] = get_size ( name + ' . js ' ) <nl> + if os . path . exists ( name + ' . wasm ' ) : <nl> + sizes [ name ] + = get_size ( name + ' . wasm ' ) <nl> self . assertContained ( ' hello , world ! ' , run_js ( name + ' . js ' ) ) <nl> do ( ' normal ' , ' hello_world_fopen . c ' , [ ] ) <nl> do ( ' no_fs ' , ' hello_world . c ' , [ ] ) # without fopen , we should auto - detect we do not need full fs support and can do NO_FILESYSTEM <nl> def do ( name , source , moar_opts ) : <nl> do ( ' no_nuthin ' , ' hello_world . c ' , [ ' - s ' , ' EXPORTED_RUNTIME_METHODS = [ ] ' ] ) <nl> print ( ' ' , sizes ) <nl> assert sizes [ ' no_fs ' ] < sizes [ ' normal ' ] <nl> - assert abs ( sizes [ ' no_nuthin ' ] - sizes [ ' no_fs ' ] ) < 10 , ' almost no difference between then , now that we export nothing by default anyhow ' <nl> + assert abs ( sizes [ ' no_nuthin ' ] - sizes [ ' no_fs ' ] ) < 30 , ' almost no difference between then , now that we export nothing by default anyhow ' <nl> assert sizes [ ' no_nuthin ' ] < ratio * sizes [ ' normal ' ] <nl> assert sizes [ ' no_nuthin ' ] < absolute , str ( sizes [ ' no_nuthin ' ] ) + ' > = ' + str ( absolute ) <nl> - assert sizes [ ' no_fs_manual ' ] < sizes [ ' no_fs ' ] # manual can remove a tiny bit more <nl> - test ( [ ' - s ' , ' ASSERTIONS = 0 ' ] , 0 . 75 , 360000 ) # we don ' t care about code size with assertions <nl> - test ( [ ' - O1 ' ] , 0 . 66 , 210000 ) <nl> - test ( [ ' - O2 ' ] , 0 . 50 , 70000 ) <nl> - test ( [ ' - O3 ' , ' - - closure ' , ' 1 ' ] , 0 . 60 , 50000 ) <nl> - test ( [ ' - O3 ' , ' - - closure ' , ' 2 ' ] , 0 . 60 , 41000 ) # might change now and then <nl> + assert sizes [ ' no_fs_manual ' ] < sizes [ ' no_fs ' ] + 30 # manual can usually remove a tiny bit more <nl> + test ( [ ' - s ' , ' ASSERTIONS = 0 ' ] , 0 . 75 , 120000 ) # we don ' t care about code size with assertions <nl> + test ( [ ' - O1 ' ] , 0 . 66 , 90000 ) <nl> + test ( [ ' - O2 ' ] , 0 . 50 , 45000 ) <nl> + test ( [ ' - O3 ' , ' - - closure ' , ' 1 ' ] , 0 . 60 , 17000 ) <nl> + # asm . js too <nl> + test ( [ ' - O3 ' , ' - - closure ' , ' 1 ' , ' - s ' , ' WASM = 0 ' ] , 0 . 60 , 36000 ) <nl> + test ( [ ' - O3 ' , ' - - closure ' , ' 2 ' , ' - s ' , ' WASM = 0 ' ] , 0 . 60 , 33000 ) # might change now and then <nl> <nl> def test_no_nuthin_2 ( self ) : <nl> # focus on EXPORTED_RUNTIME_METHODS effects , on hello_world_em_asm <nl> def do ( name , moar_opts ) : <nl> self . clear ( ) <nl> Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world_em_asm . c ' ) , ' - o ' , name + ' . js ' ] + opts + moar_opts ) . communicate ( ) <nl> sizes [ name ] = get_size ( name + ' . js ' ) <nl> + if os . path . exists ( name + ' . wasm ' ) : <nl> + sizes [ name ] + = get_size ( name + ' . wasm ' ) <nl> self . assertContained ( ' hello , world ! ' , run_js ( name + ' . js ' ) ) <nl> do ( ' normal ' , [ ] ) <nl> do ( ' no_nuthin ' , [ ' - s ' , ' EXPORTED_RUNTIME_METHODS = [ ] ' ] ) <nl> print ( ' ' , sizes ) <nl> assert abs ( sizes [ ' no_nuthin ' ] - sizes [ ' normal ' ] ) < 10 <nl> assert sizes [ ' no_nuthin ' ] < absolute <nl> - test ( [ ' - s ' , ' ASSERTIONS = 0 ' ] , 220000 ) # we don ' t care about code size with assertions <nl> - test ( [ ' - O1 ' ] , 215000 ) <nl> - test ( [ ' - O2 ' ] , 55000 ) <nl> - test ( [ ' - O3 ' , ' - - closure ' , ' 1 ' ] , 38000 ) <nl> - test ( [ ' - O3 ' , ' - - closure ' , ' 2 ' ] , 35000 ) # might change now and then <nl> + test ( [ ' - s ' , ' ASSERTIONS = 0 ' ] , 95000 ) # we don ' t care about code size with assertions <nl> + test ( [ ' - O1 ' ] , 80000 ) <nl> + test ( [ ' - O2 ' ] , 42000 ) <nl> + test ( [ ' - O3 ' , ' - - closure ' , ' 1 ' ] , 12000 ) # closure is great ! <nl> + # asm . js comparison with closure 1 and 2 . these numbers are fairly close , might change now and then . <nl> + test ( [ ' - O3 ' , ' - - closure ' , ' 1 ' , ' - s ' , ' WASM = 0 ' ] , 28000 ) <nl> + test ( [ ' - O3 ' , ' - - closure ' , ' 2 ' , ' - s ' , ' WASM = 0 ' ] , 26000 ) <nl> <nl> def test_no_browser ( self ) : <nl> BROWSER_INIT = ' var Browser ' <nl> def do_emcc_test ( source , args , output , emcc_args = [ ] ) : <nl> source = ' src . cpp ' <nl> else : <nl> source = path_from_root ( ' tests ' , source ) <nl> - Popen ( [ PYTHON , EMCC , source , ' - O2 ' , ' - s ' , ' EMTERPRETIFY = 1 ' , ' - g2 ' ] + emcc_args ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , source , ' - O2 ' , ' - s ' , ' EMTERPRETIFY = 1 ' , ' - g2 ' , ' - s ' , ' WASM = 0 ' ] + emcc_args ) . communicate ( ) <nl> self . assertTextDataContained ( output , run_js ( ' a . out . js ' , args = args ) ) <nl> out = run_js ( ' a . out . js ' , engine = SPIDERMONKEY_ENGINE , args = args , stderr = PIPE , full_output = True ) <nl> self . assertTextDataContained ( output , out ) <nl> def do_test ( source , args , output ) : <nl> source = ' src . cpp ' <nl> else : <nl> source = path_from_root ( ' tests ' , source ) <nl> - Popen ( [ PYTHON , EMCC , source , ' - O2 ' , ' - - profiling ' , ' - s ' , ' FINALIZE_ASM_JS = 0 ' , ' - s ' , ' GLOBAL_BASE = 2048 ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 0 ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , source , ' - O2 ' , ' - - profiling ' , ' - s ' , ' FINALIZE_ASM_JS = 0 ' , ' - s ' , ' GLOBAL_BASE = 2048 ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 0 ' , ' - s ' , ' WASM = 0 ' ] ) . communicate ( ) <nl> Popen ( [ PYTHON , path_from_root ( ' tools ' , ' emterpretify . py ' ) , ' a . out . js ' , ' em . out . js ' , ' ASYNC = 0 ' ] ) . communicate ( ) <nl> self . assertTextDataContained ( output , run_js ( ' a . out . js ' , args = args ) ) <nl> self . assertTextDataContained ( output , run_js ( ' em . out . js ' , args = args ) ) <nl> def do_test ( source , args , output ) : <nl> <nl> # generate default shell for js test <nl> def make_default ( args = [ ] ) : <nl> - Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - O2 ' , ' - - profiling ' , ' - s ' , ' FINALIZE_ASM_JS = 0 ' , ' - s ' , ' GLOBAL_BASE = 2048 ' ] + args ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - O2 ' , ' - - profiling ' , ' - s ' , ' FINALIZE_ASM_JS = 0 ' , ' - s ' , ' GLOBAL_BASE = 2048 ' , ' - s ' , ' WASM = 0 ' ] + args ) . communicate ( ) <nl> default = open ( ' a . out . js ' ) . read ( ) <nl> start = default . index ( ' function _main ( ' ) <nl> end = default . index ( ' } ' , start ) <nl> def do_log_test ( source , expected , func ) : <nl> print ( ' seen ' , seen , ' , expected ' , expected , type ( seen ) , type ( expected ) ) <nl> assert expected = = seen or ( type ( expected ) in [ list , tuple ] and seen in expected ) , [ ' expect ' , expected , ' but see ' , seen ] <nl> <nl> - do_log_test ( path_from_root ( ' tests ' , ' primes . cpp ' ) , list ( range ( 88 , 94 ) ) , ' _main ' ) <nl> - do_log_test ( path_from_root ( ' tests ' , ' fannkuch . cpp ' ) , list ( range ( 226 , 235 ) ) , ' __Z15fannkuch_workerPv ' ) <nl> + do_log_test ( path_from_root ( ' tests ' , ' primes . cpp ' ) , list ( range ( 88 , 101 ) ) , ' _main ' ) <nl> + do_log_test ( path_from_root ( ' tests ' , ' fannkuch . cpp ' ) , list ( range ( 226 , 241 ) ) , ' __Z15fannkuch_workerPv ' ) <nl> <nl> def test_emterpreter_advise ( self ) : <nl> out = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' emterpreter_advise . cpp ' ) , ' - s ' , ' EMTERPRETIFY = 1 ' , ' - s ' , ' EMTERPRETIFY_ASYNC = 1 ' , ' - s ' , ' EMTERPRETIFY_ADVISE = 1 ' ] , stdout = PIPE ) . stdout <nl> def test ( args , expected ) : <nl> os . environ [ ' EMCC_DEBUG ' ] = ' 1 ' <nl> os . environ [ ' EMCC_NATIVE_OPTIMIZER ' ] = ' 1 ' <nl> with clean_write_access_to_canonical_temp_dir ( self . canonical_temp_dir ) : <nl> - err = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - O2 ' , ] + args , stderr = PIPE ) . stderr <nl> + err = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - O2 ' , ' - s ' , ' WASM = 0 ' ] + args , stderr = PIPE ) . stderr <nl> finally : <nl> if old_debug : os . environ [ ' EMCC_DEBUG ' ] = old_debug <nl> else : del os . environ [ ' EMCC_DEBUG ' ] <nl> class Descriptor <nl> assert os . path . exists ( ' a . out . js ' ) <nl> <nl> def test_f0 ( self ) : <nl> - Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' fasta . cpp ' ) , ' - O2 ' , ' - s ' , ' PRECISE_F32 = 1 ' , ' - profiling ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' fasta . cpp ' ) , ' - O2 ' , ' - s ' , ' PRECISE_F32 = 1 ' , ' - profiling ' , ' - s ' , ' WASM = 0 ' ] ) . communicate ( ) <nl> src = open ( ' a . out . js ' ) . read ( ) <nl> assert ' = f0 ; ' in src or ' = f0 , ' in src <nl> <nl> def test_merge_pair ( self ) : <nl> def test ( filename , full ) : <nl> print ( ' mmm - ' , filename , full ) <nl> - Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , filename ) , ' - O1 ' , ' - profiling ' , ' - o ' , ' left . js ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , path_from_root ( ' tests ' , filename ) , ' - O1 ' , ' - profiling ' , ' - o ' , ' left . js ' , ' - s ' , ' WASM = 0 ' ] ) . communicate ( ) <nl> src = open ( ' left . js ' ) . read ( ) <nl> open ( ' right . js ' , ' w ' ) . write ( src . replace ( ' function _main ( ) { ' , ' function _main ( ) { Module . print ( " replaced " ) ; ' ) ) <nl> <nl> def test_file_packager_huge ( self ) : <nl> self . assertContained ( MESSAGE , err ) <nl> self . clear ( ) <nl> <nl> - def test_nosplit ( self ) : # relooper shouldn ' t split nodes if - Os or - Oz <nl> - open ( ' src . cpp ' , ' w ' ) . write ( r ' ' ' <nl> - # include < stdio . h > <nl> - int main ( int argc , char * * argv ) { <nl> - printf ( " extra code \ n " ) ; <nl> - printf ( " to make the function big enough to justify splitting \ n " ) ; <nl> - if ( argc = = 1 ) { <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - } else if ( argc / 2 = = 2 ) { <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 2 \ n " ) ; <nl> - } else if ( argc / 3 = = 3 ) { <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 3 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - } else if ( argc / 4 = = 4 ) { <nl> - printf ( " 4 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - } else if ( argc / 5 = = 5 ) { <nl> - printf ( " five \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - printf ( " 1 \ n " ) ; <nl> - } <nl> - printf ( " hai \ n " ) ; <nl> - return 5 ; <nl> - } <nl> - ' ' ' ) <nl> - def test ( opts , expected ) : <nl> - print ( opts ) <nl> - Popen ( [ PYTHON , EMCC , ' src . cpp ' , ' - - profiling ' ] + opts ) . communicate ( ) <nl> - src = open ( ' a . out . js ' ) . read ( ) <nl> - main = self . get_func ( src , ' _main ' ) <nl> - rets = main . count ( ' return ' ) <nl> - print ( ' ' , rets ) <nl> - assert rets = = expected , [ rets , ' ! = ' , expected ] <nl> - test ( [ ' - O1 ' ] , 6 ) <nl> - test ( [ ' - O2 ' ] , 6 ) <nl> - test ( [ ' - Os ' ] , 1 ) <nl> - test ( [ ' - Oz ' ] , 1 ) <nl> - <nl> def test_massive_alloc ( self ) : <nl> if SPIDERMONKEY_ENGINE not in JS_ENGINES : return self . skip ( ' cannot run without spidermonkey , node cannnot alloc huge arrays ' ) <nl> <nl> def test_massive_alloc ( self ) : <nl> # include < stdlib . h > <nl> <nl> int main ( ) { <nl> - return ( int ) malloc ( 1024 * 1024 * 1400 ) ; <nl> + volatile int x = ( int ) malloc ( 1024 * 1024 * 1400 ) ; <nl> + return x = = 0 ; / / can ' t alloc it , but don ' t fail catastrophically , expect null <nl> } <nl> ' ' ' ) <nl> - Popen ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' ] ) . communicate ( ) [ 1 ] <nl> - assert os . path . exists ( ' a . out . js ' ) <nl> - output = run_js ( ' a . out . js ' , stderr = PIPE , full_output = True , engine = SPIDERMONKEY_ENGINE , assert_returncode = None ) <nl> + run_process ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' , ' - s ' , ' WASM = 0 ' ] ) <nl> # just care about message regarding allocating over 1GB of memory <nl> + output = run_js ( ' a . out . js ' , stderr = PIPE , full_output = True , engine = SPIDERMONKEY_ENGINE ) <nl> self . assertContained ( ' ' ' Warning : Enlarging memory arrays , this is not fast ! 16777216 , 1543503872 \ n ' ' ' , output ) <nl> + print ( ' wasm ' ) <nl> + run_process ( [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' ] ) <nl> + # no message about growth , just check return code <nl> + run_js ( ' a . out . js ' , stderr = PIPE , full_output = True , engine = SPIDERMONKEY_ENGINE ) <nl> <nl> def test_failing_alloc ( self ) : <nl> for pre_fail , post_fail , opts in [ <nl> ( ' ' , ' ' , [ ] ) , <nl> ( ' EM_ASM ( Module . temp = HEAP32 [ DYNAMICTOP_PTR > > 2 ] ) ; ' , ' EM_ASM ( assert ( Module . temp = = = HEAP32 [ DYNAMICTOP_PTR > > 2 ] , " must not adjust DYNAMICTOP when an alloc fails ! " ) ) ; ' , [ ] ) , <nl> - ( ' ' , ' ' , [ ' - s ' , ' SPLIT_MEMORY = ' + str ( 16 * 1024 * 1024 ) , ' - DSPLIT ' ] ) , <nl> + ( ' ' , ' ' , [ ' - s ' , ' SPLIT_MEMORY = ' + str ( 16 * 1024 * 1024 ) , ' - DSPLIT ' , ' - s ' , ' WASM = 0 ' ] ) , <nl> + # also test non - wasm in normal mode <nl> + ( ' ' , ' ' , [ ' - s ' , ' WASM = 0 ' ] ) , <nl> + ( ' EM_ASM ( Module . temp = HEAP32 [ DYNAMICTOP_PTR > > 2 ] ) ; ' , ' EM_ASM ( assert ( Module . temp = = = HEAP32 [ DYNAMICTOP_PTR > > 2 ] , " must not adjust DYNAMICTOP when an alloc fails ! " ) ) ; ' , [ ' - s ' , ' WASM = 0 ' ] ) , <nl> ] : <nl> for growth in [ 0 , 1 ] : <nl> for aborting in [ 0 , 1 ] : <nl> def test_failing_alloc ( self ) : <nl> args = [ PYTHON , EMCC , os . path . join ( self . get_dir ( ) , ' main . cpp ' ) ] + opts <nl> if growth : args + = [ ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' ] <nl> if not aborting : args + = [ ' - s ' , ' ABORTING_MALLOC = 0 ' ] <nl> - print ( args , pre_fail ) <nl> + print ( ' test_failing_alloc ' , args , pre_fail ) <nl> check_execute ( args ) <nl> # growth also disables aborting <nl> can_manage_another = ( not aborting ) or growth <nl> def test_emulated_function_pointers ( self ) : <nl> open ( ' src . c ' , ' w ' ) . write ( src ) <nl> def test ( args , expected ) : <nl> print ( args , expected ) <nl> - out , err = Popen ( [ PYTHON , EMCC , ' src . c ' ] + args , stderr = PIPE ) . communicate ( ) <nl> + out , err = Popen ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' WASM = 0 ' ] + args , stderr = PIPE ) . communicate ( ) <nl> self . assertContained ( expected , run_js ( self . in_dir ( ' a . out . js ' ) ) ) <nl> <nl> for opts in [ 0 , 1 , 2 , 3 ] : <nl> def test_emulated_function_pointers_2 ( self ) : <nl> <nl> def test ( args , expected ) : <nl> print ( args , expected . replace ( ' \ n ' , ' ' ) ) <nl> - Popen ( [ PYTHON , EMCC , ' src . c ' ] + args ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' WASM = 0 ' ] + args ) . communicate ( ) <nl> self . assertContained ( expected , run_js ( self . in_dir ( ' a . out . js ' ) ) ) <nl> <nl> for opts in [ 0 , 1 , 2 ] : <nl> def test ( args , expected ) : <nl> test ( [ ' - O ' + str ( opts ) , ' - s ' , ' MAIN_MODULE = 1 ' , ' - s ' , ' EMULATED_FUNCTION_POINTERS = 1 ' ] , flipped ) # but you can disable that <nl> <nl> def test_minimal_dynamic ( self ) : <nl> - def test ( main_args = [ ] , library_args = [ ] , expected = ' hello from main \ nhello from library ' ) : <nl> - print ( ' testing ' , main_args , library_args ) <nl> - self . clear ( ) <nl> - open ( ' library . c ' , ' w ' ) . write ( r ' ' ' <nl> - # include < stdio . h > <nl> - void library_func ( ) { <nl> - # ifdef USE_PRINTF <nl> - printf ( " hello from library : % p \ n " , ( int ) & library_func ) ; <nl> - # else <nl> - puts ( " hello from library " ) ; <nl> - # endif <nl> - } <nl> - ' ' ' ) <nl> - check_execute ( [ PYTHON , EMCC , ' library . c ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - O2 ' , ' - o ' , ' library . js ' ] + library_args ) <nl> - open ( ' main . c ' , ' w ' ) . write ( r ' ' ' <nl> - # include < dlfcn . h > <nl> - # include < stdio . h > <nl> - int main ( ) { <nl> - puts ( " hello from main " ) ; <nl> - void * lib_handle = dlopen ( " library . js " , 0 ) ; <nl> - typedef void ( * voidfunc ) ( ) ; <nl> - voidfunc x = ( voidfunc ) dlsym ( lib_handle , " library_func " ) ; <nl> - if ( ! x ) puts ( " cannot find side function " ) ; <nl> - else x ( ) ; <nl> - } <nl> - ' ' ' ) <nl> - check_execute ( [ PYTHON , EMCC , ' main . c ' , ' - s ' , ' MAIN_MODULE = 1 ' , ' - - embed - file ' , ' library . js ' , ' - O2 ' ] + main_args ) <nl> - self . assertContained ( expected , run_js ( ' a . out . js ' , assert_returncode = None , stderr = subprocess . STDOUT ) ) <nl> - size = os . stat ( ' a . out . js ' ) . st_size <nl> - side_size = os . stat ( ' library . js ' ) . st_size <nl> - print ( ' sizes : ' , size , side_size ) <nl> - return ( size , side_size ) <nl> - <nl> - def percent_diff ( x , y ) : <nl> - small = min ( x , y ) <nl> - large = max ( x , y ) <nl> - return float ( 100 * large ) / small - 100 <nl> - <nl> - # main module tests <nl> - <nl> - full = test ( ) <nl> - printf = test ( library_args = [ ' - DUSE_PRINTF ' ] ) # printf is not used in main , but libc was linked in , so it ' s there <nl> - dce = test ( main_args = [ ' - s ' , ' MAIN_MODULE = 2 ' ] ) # dce in main , and side happens to be ok since it uses puts as well <nl> - dce_fail = test ( main_args = [ ' - s ' , ' MAIN_MODULE = 2 ' ] , library_args = [ ' - DUSE_PRINTF ' ] , expected = ' undefined ' ) # printf is not used in main , and we dce , so we failz <nl> - dce_save = test ( main_args = [ ' - s ' , ' MAIN_MODULE = 2 ' , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _main " , " _printf " ] ' ] , <nl> - library_args = [ ' - DUSE_PRINTF ' ] ) # exporting printf in main keeps it alive for the library <nl> - <nl> - assert percent_diff ( full [ 0 ] , printf [ 0 ] ) < 4 <nl> - assert percent_diff ( dce [ 0 ] , dce_fail [ 0 ] ) < 4 <nl> - assert dce [ 0 ] < 0 . 2 * full [ 0 ] # big effect , 80 % + is gone <nl> - assert dce_save [ 0 ] > 1 . 1 * dce [ 0 ] # save exported all of printf <nl> - <nl> - # side module tests <nl> - <nl> - side_dce_fail = test ( library_args = [ ' - s ' , ' SIDE_MODULE = 2 ' ] , expected = ' cannot find side function ' ) # mode 2 , so dce in side , but library_func is not exported , so it is dce ' d <nl> - side_dce_work = test ( library_args = [ ' - s ' , ' SIDE_MODULE = 2 ' , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _library_func " ] ' ] , expected = ' hello from library ' ) # mode 2 , so dce in side , and library_func is not exported <nl> - <nl> - assert side_dce_fail [ 1 ] < 0 . 95 * side_dce_work [ 1 ] # removing that function saves a chunk <nl> + for wasm in ( 1 , 0 ) : <nl> + print ( ' wasm ? ' , wasm ) <nl> + library_file = ' library . wasm ' if wasm else ' library . js ' <nl> + def test ( main_args = [ ] , library_args = [ ] , expected = ' hello from main \ nhello from library ' ) : <nl> + print ( ' testing ' , main_args , library_args ) <nl> + self . clear ( ) <nl> + open ( ' library . c ' , ' w ' ) . write ( r ' ' ' <nl> + # include < stdio . h > <nl> + void library_func ( ) { <nl> + # ifdef USE_PRINTF <nl> + printf ( " hello from library : % p \ n " , ( int ) & library_func ) ; <nl> + # else <nl> + puts ( " hello from library " ) ; <nl> + # endif <nl> + } <nl> + ' ' ' ) <nl> + check_execute ( [ PYTHON , EMCC , ' library . c ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - O2 ' , ' - o ' , library_file , ' - s ' , ' WASM = ' + str ( wasm ) ] + library_args ) <nl> + open ( ' main . c ' , ' w ' ) . write ( r ' ' ' <nl> + # include < dlfcn . h > <nl> + # include < stdio . h > <nl> + int main ( ) { <nl> + puts ( " hello from main " ) ; <nl> + void * lib_handle = dlopen ( " % s " , 0 ) ; <nl> + if ( ! lib_handle ) { <nl> + puts ( " cannot load side module " ) ; <nl> + return 1 ; <nl> + } <nl> + typedef void ( * voidfunc ) ( ) ; <nl> + voidfunc x = ( voidfunc ) dlsym ( lib_handle , " library_func " ) ; <nl> + if ( ! x ) puts ( " cannot find side function " ) ; <nl> + else x ( ) ; <nl> + } <nl> + ' ' ' % library_file ) <nl> + check_execute ( [ PYTHON , EMCC , ' main . c ' , ' - s ' , ' MAIN_MODULE = 1 ' , ' - - embed - file ' , library_file , ' - O2 ' , ' - s ' , ' WASM = ' + str ( wasm ) ] + main_args ) <nl> + self . assertContained ( expected , run_js ( ' a . out . js ' , assert_returncode = None , stderr = subprocess . STDOUT ) ) <nl> + size = os . stat ( ' a . out . js ' ) . st_size <nl> + if wasm : <nl> + size + = os . stat ( ' a . out . wasm ' ) . st_size <nl> + side_size = os . stat ( library_file ) . st_size <nl> + print ( ' sizes : ' , size , side_size ) <nl> + return ( size , side_size ) <nl> + <nl> + def percent_diff ( x , y ) : <nl> + small = min ( x , y ) <nl> + large = max ( x , y ) <nl> + return float ( 100 * large ) / small - 100 <nl> + <nl> + # main module tests <nl> + <nl> + full = test ( ) <nl> + printf = test ( library_args = [ ' - DUSE_PRINTF ' ] ) # printf is not used in main , but libc was linked in , so it ' s there <nl> + dce = test ( main_args = [ ' - s ' , ' MAIN_MODULE = 2 ' ] ) # dce in main , and side happens to be ok since it uses puts as well <nl> + dce_fail = test ( main_args = [ ' - s ' , ' MAIN_MODULE = 2 ' ] , library_args = [ ' - DUSE_PRINTF ' ] , expected = ( ' cannot ' , ' undefined ' ) ) # printf is not used in main , and we dce , so we failz <nl> + dce_save = test ( main_args = [ ' - s ' , ' MAIN_MODULE = 2 ' , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _main " , " _printf " ] ' ] , <nl> + library_args = [ ' - DUSE_PRINTF ' ] ) # exporting printf in main keeps it alive for the library <nl> + <nl> + assert percent_diff ( full [ 0 ] , printf [ 0 ] ) < 4 <nl> + assert percent_diff ( dce [ 0 ] , dce_fail [ 0 ] ) < 4 <nl> + assert dce [ 0 ] < 0 . 2 * full [ 0 ] # big effect , 80 % + is gone <nl> + assert dce_save [ 0 ] > 1 . 1 * dce [ 0 ] # save exported all of printf <nl> + <nl> + # side module tests <nl> + <nl> + side_dce_fail = test ( library_args = [ ' - s ' , ' SIDE_MODULE = 2 ' ] , expected = ' cannot find side function ' ) # mode 2 , so dce in side , but library_func is not exported , so it is dce ' d <nl> + side_dce_work = test ( library_args = [ ' - s ' , ' SIDE_MODULE = 2 ' , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _library_func " ] ' ] , expected = ' hello from library ' ) # mode 2 , so dce in side , and library_func is not exported <nl> + <nl> + assert side_dce_fail [ 1 ] < 0 . 95 * side_dce_work [ 1 ] # removing that function saves a chunk <nl> <nl> def test_ld_library_path ( self ) : <nl> open ( ' hello1 . c ' , ' w ' ) . write ( r ' ' ' <nl> def test_ld_library_path ( self ) : <nl> void * h ; <nl> void ( * f ) ( ) ; <nl> <nl> - h = dlopen ( " libhello1 . js " , RTLD_NOW ) ; <nl> + h = dlopen ( " libhello1 . wasm " , RTLD_NOW ) ; <nl> f = dlsym ( h , " hello1 " ) ; <nl> f ( ) ; <nl> dlclose ( h ) ; <nl> - h = dlopen ( " libhello2 . js " , RTLD_NOW ) ; <nl> + h = dlopen ( " libhello2 . wasm " , RTLD_NOW ) ; <nl> f = dlsym ( h , " hello2 " ) ; <nl> f ( ) ; <nl> dlclose ( h ) ; <nl> - h = dlopen ( " libhello3 . js " , RTLD_NOW ) ; <nl> + h = dlopen ( " libhello3 . wasm " , RTLD_NOW ) ; <nl> f = dlsym ( h , " hello3 " ) ; <nl> f ( ) ; <nl> dlclose ( h ) ; <nl> - h = dlopen ( " / usr / local / lib / libhello4 . js " , RTLD_NOW ) ; <nl> + h = dlopen ( " / usr / local / lib / libhello4 . wasm " , RTLD_NOW ) ; <nl> f = dlsym ( h , " hello4 " ) ; <nl> f ( ) ; <nl> dlclose ( h ) ; <nl> def test_ld_library_path ( self ) : <nl> <nl> ' ' ' ) <nl> <nl> - Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello1 . js ' , ' hello1 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' ] ) . communicate ( ) <nl> - Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello2 . js ' , ' hello2 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' ] ) . communicate ( ) <nl> - Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello3 . js ' , ' hello3 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' ] ) . communicate ( ) <nl> - Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello4 . js ' , ' hello4 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' ] ) . communicate ( ) <nl> - Popen ( [ PYTHON , EMCC , ' - o ' , ' main . js ' , ' main . c ' , ' - s ' , ' MAIN_MODULE = 1 ' , <nl> - ' - - embed - file ' , ' libhello1 . js @ / lib / libhello1 . js ' , <nl> - ' - - embed - file ' , ' libhello2 . js @ / usr / lib / libhello2 . js ' , <nl> - ' - - embed - file ' , ' libhello3 . js @ / libhello3 . js ' , <nl> - ' - - embed - file ' , ' libhello4 . js @ / usr / local / lib / libhello4 . js ' , <nl> + Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello1 . wasm ' , ' hello1 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello2 . wasm ' , ' hello2 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello3 . wasm ' , ' hello3 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello4 . wasm ' , ' hello4 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' - o ' , ' main . js ' , ' main . c ' , ' - s ' , ' MAIN_MODULE = 1 ' , ' - s ' , ' TOTAL_MEMORY = ' + str ( 32 * 1024 * 1024 ) , <nl> + ' - - embed - file ' , ' libhello1 . wasm @ / lib / libhello1 . wasm ' , <nl> + ' - - embed - file ' , ' libhello2 . wasm @ / usr / lib / libhello2 . wasm ' , <nl> + ' - - embed - file ' , ' libhello3 . wasm @ / libhello3 . wasm ' , <nl> + ' - - embed - file ' , ' libhello4 . wasm @ / usr / local / lib / libhello4 . wasm ' , <nl> ' - - pre - js ' , ' pre . js ' ] ) . communicate ( ) <nl> out = run_js ( ' main . js ' ) <nl> self . assertContained ( ' Hello1 ' , out ) <nl> def test_ld_library_path ( self ) : <nl> self . assertContained ( ' Hello4 ' , out ) <nl> <nl> def test_dlopen_rtld_global ( self ) : <nl> + # TODO : wasm support . this test checks RTLD_GLOBAL where a module is loaded <nl> + # before the module providing a global it needs is . in asm . js we use JS <nl> + # to create a redirection function . In wasm we just have wasm , so we <nl> + # need to introspect the wasm module . Browsers may add that eventually , <nl> + # or we could ship a little library that does it . <nl> open ( ' hello1 . c ' , ' w ' ) . write ( r ' ' ' <nl> # include < stdio . h > <nl> <nl> def test_dlopen_rtld_global ( self ) : <nl> } <nl> ' ' ' ) <nl> <nl> - Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello1 . js ' , ' hello1 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' ] ) . communicate ( ) <nl> - Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello2 . js ' , ' hello2 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' ] ) . communicate ( ) <nl> - Popen ( [ PYTHON , EMCC , ' - o ' , ' main . js ' , ' main . c ' , ' - s ' , ' MAIN_MODULE = 1 ' , <nl> + Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello1 . js ' , ' hello1 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - s ' , ' WASM = 0 ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' - o ' , ' libhello2 . js ' , ' hello2 . c ' , ' - s ' , ' SIDE_MODULE = 1 ' , ' - s ' , ' WASM = 0 ' ] ) . communicate ( ) <nl> + Popen ( [ PYTHON , EMCC , ' - o ' , ' main . js ' , ' main . c ' , ' - s ' , ' MAIN_MODULE = 1 ' , ' - s ' , ' WASM = 0 ' , <nl> ' - - embed - file ' , ' libhello1 . js ' , <nl> ' - - embed - file ' , ' libhello2 . js ' ] ) . communicate ( ) <nl> out = run_js ( ' main . js ' ) <nl> def test_meminit_crc ( self ) : <nl> # include < stdio . h > <nl> int main ( ) { printf ( " Mary had a little lamb . \ n " ) ; } <nl> ' ' ' ) <nl> - out , err = Popen ( [ PYTHON , EMCC , ' src . c ' , ' - O2 ' , ' - - memory - init - file ' , ' 0 ' , ' - s ' , ' MEM_INIT_METHOD = 2 ' , ' - s ' , ' ASSERTIONS = 1 ' ] ) . communicate ( ) <nl> + out , err = Popen ( [ PYTHON , EMCC , ' src . c ' , ' - O2 ' , ' - - memory - init - file ' , ' 0 ' , ' - s ' , ' MEM_INIT_METHOD = 2 ' , ' - s ' , ' ASSERTIONS = 1 ' , ' - s ' , ' WASM = 0 ' ] ) . communicate ( ) <nl> with open ( ' a . out . js ' , ' r ' ) as f : <nl> d = f . read ( ) <nl> d = d . replace ( ' Mary had ' , ' Paul had ' ) <nl> def test_almost_asm_warning ( self ) : <nl> # last warning flag should " win " <nl> ( [ ' - O1 ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' , ' - Wno - almost - asm ' , ' - Walmost - asm ' ] , True ) ] : <nl> print ( args , expected ) <nl> - err = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) ] + args , stderr = PIPE ) . stderr <nl> + err = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 0 ' ] + args , stderr = PIPE ) . stderr <nl> assert ( warning in err ) = = expected , err <nl> if not expected : <nl> assert err = = ' ' , err <nl> def test_split_memory ( self ) : # make sure multiple split memory chunks get used <nl> ' ' ' ) <nl> for opts in [ 0 , 1 , 2 ] : <nl> print ( opts ) <nl> - check_execute ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) ] ) <nl> + check_execute ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) ] ) <nl> self . assertContained ( ' success . ' , run_js ( ' a . out . js ' ) ) <nl> <nl> def test_split_memory_2 ( self ) : # make allocation starts in the first chunk , and moves forward properly <nl> def test_split_memory_2 ( self ) : # make allocation starts in the first chunk , and <nl> ' ' ' ) <nl> for opts in [ 0 , 1 , 2 ] : <nl> print ( opts ) <nl> - check_execute ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) ] ) <nl> + check_execute ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) ] ) <nl> self . assertContained ( ' success . ' , run_js ( ' a . out . js ' ) ) <nl> <nl> def test_split_memory_sbrk ( self ) : <nl> def test_split_memory_sbrk ( self ) : <nl> ' ' ' ) <nl> for opts in [ 0 , 1 , 2 ] : <nl> print ( opts ) <nl> - check_execute ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) ] ) <nl> + check_execute ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) ] ) <nl> self . assertContained ( ' success . ' , run_js ( ' a . out . js ' ) ) <nl> <nl> def test_split_memory_faking ( self ) : # fake HEAP8 etc . objects have some faked fake method . they are fake <nl> def test_split_memory_faking ( self ) : # fake HEAP8 etc . objects have some faked fa <nl> ' ' ' ) <nl> for opts in [ 0 , 1 , 2 ] : <nl> print ( opts ) <nl> - check_execute ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) , ' - s ' , ' ASSERTIONS = 1 ' ] ) <nl> + check_execute ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) , ' - s ' , ' ASSERTIONS = 1 ' ] ) <nl> self . assertContained ( ' success . ' , run_js ( ' a . out . js ' , stderr = PIPE , assert_returncode = None ) ) <nl> <nl> def test_split_memory_release ( self ) : <nl> def test_split_memory_release ( self ) : <nl> ' ' ' ) <nl> for opts in [ 0 , 1 , 2 ] : <nl> print ( opts ) <nl> - check_execute ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) ] ) <nl> + check_execute ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) ] ) <nl> self . assertContained ( ' success . ' , run_js ( ' a . out . js ' ) ) <nl> <nl> def test_split_memory_use_existing ( self ) : <nl> def test_split_memory_use_existing ( self ) : <nl> ' ' ' ) <nl> for opts in [ 0 , 1 , 2 ] : <nl> print ( opts ) <nl> - check_execute ( [ PYTHON , EMCC , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) ] ) <nl> + check_execute ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , ' src . c ' , ' - s ' , ' SPLIT_MEMORY = 8388608 ' , ' - s ' , ' TOTAL_MEMORY = 64MB ' , ' - O ' + str ( opts ) ] ) <nl> self . assertContained ( ' success . ' , run_js ( ' a . out . js ' ) ) <nl> <nl> def test_sixtyfour_bit_return_value ( self ) : <nl> def test_sixtyfour_bit_return_value ( self ) : <nl> # The MS 32 bits should be available in Runtime . getTempRet0 ( ) even when compiled with - O2 - - closure 1 <nl> <nl> # Compile test . c and wrap it in a native JavaScript binding so we can call our compiled function from JS . <nl> - check_execute ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' return64bit ' , ' test . c ' ) , ' - - pre - js ' , path_from_root ( ' tests ' , ' return64bit ' , ' testbindstart . js ' ) , ' - - pre - js ' , path_from_root ( ' tests ' , ' return64bit ' , ' testbind . js ' ) , ' - - post - js ' , path_from_root ( ' tests ' , ' return64bit ' , ' testbindend . js ' ) , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _test " ] ' , ' - o ' , ' test . js ' , ' - O2 ' , ' - - closure ' , ' 1 ' ] ) <nl> + check_execute ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' return64bit ' , ' test . c ' ) , ' - - pre - js ' , path_from_root ( ' tests ' , ' return64bit ' , ' testbindstart . js ' ) , ' - - pre - js ' , path_from_root ( ' tests ' , ' return64bit ' , ' testbind . js ' ) , ' - - post - js ' , path_from_root ( ' tests ' , ' return64bit ' , ' testbindend . js ' ) , ' - s ' , ' EXPORTED_FUNCTIONS = [ " _test " ] ' , ' - o ' , ' test . js ' , ' - O2 ' , ' - - closure ' , ' 1 ' , ' - g1 ' , ' - s ' , ' BINARYEN_ASYNC_COMPILATION = 0 ' ] ) <nl> <nl> # Simple test program to load the test . js binding library and call the binding to the <nl> # C function returning the 64 bit long . <nl> def test_zeroinit ( self ) : <nl> } <nl> ' ' ' ) <nl> check_execute ( [ PYTHON , EMCC , ' src . c ' , ' - O2 ' , ' - g ' ] ) <nl> - size = os . stat ( ' a . out . js . mem ' ) . st_size <nl> - assert size < 4096 , size <nl> + size = os . stat ( ' a . out . wasm ' ) . st_size <nl> + # size should be much smaller than the size of that zero - initialized buffer <nl> + assert size < ( 123456 / 2 ) , size <nl> <nl> def test_separate_asm_warning ( self ) : <nl> # Test that - s PRECISE_F32 = 2 raises a warning that - - separate - asm is implied . <nl> - stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' PRECISE_F32 = 2 ' , ' - o ' , ' a . html ' ] , stderr = PIPE ) . stderr <nl> + stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 0 ' , ' - s ' , ' PRECISE_F32 = 2 ' , ' - o ' , ' a . html ' ] , stderr = PIPE ) . stderr <nl> self . assertContained ( ' forcing separate asm output ' , stderr ) <nl> <nl> # Test that - s PRECISE_F32 = 2 - - separate - asm should not post a warning . <nl> - stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' PRECISE_F32 = 2 ' , ' - o ' , ' a . html ' , ' - - separate - asm ' ] , stderr = PIPE ) . stderr <nl> + stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 0 ' , ' - s ' , ' PRECISE_F32 = 2 ' , ' - o ' , ' a . html ' , ' - - separate - asm ' ] , stderr = PIPE ) . stderr <nl> self . assertNotContained ( ' forcing separate asm output ' , stderr ) <nl> <nl> # Test that - s PRECISE_F32 = 1 should not post a warning . <nl> - stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' PRECISE_F32 = 1 ' , ' - o ' , ' a . html ' ] , stderr = PIPE ) . stderr <nl> + stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 0 ' , ' - s ' , ' PRECISE_F32 = 1 ' , ' - o ' , ' a . html ' ] , stderr = PIPE ) . stderr <nl> self . assertNotContained ( ' forcing separate asm output ' , stderr ) <nl> <nl> # Manually doing separate asm should show a warning , if not targeting html <nl> warning = ' - - separate - asm works best when compiling to HTML ' <nl> - stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - - separate - asm ' ] , stderr = PIPE ) . stderr <nl> + stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 0 ' , ' - - separate - asm ' ] , stderr = PIPE ) . stderr <nl> self . assertContained ( warning , stderr ) <nl> - stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - - separate - asm ' , ' - o ' , ' a . html ' ] , stderr = PIPE ) . stderr <nl> + stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 0 ' , ' - - separate - asm ' , ' - o ' , ' a . html ' ] , stderr = PIPE ) . stderr <nl> self . assertNotContained ( warning , stderr ) <nl> <nl> # test that the warning can be suppressed <nl> - stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - - separate - asm ' , ' - Wno - separate - asm ' ] , stderr = PIPE ) . stderr <nl> + stderr = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 0 ' , ' - - separate - asm ' , ' - Wno - separate - asm ' ] , stderr = PIPE ) . stderr <nl> self . assertNotContained ( warning , stderr ) <nl> <nl> def test_canonicalize_nan_warning ( self ) : <nl> def test_canonicalize_nan_warning ( self ) : <nl> self . assertContained ( ' / / @ line 12 " src . cpp " ' , stderr ) <nl> <nl> def test_only_my_code ( self ) : <nl> - check_execute ( [ PYTHON , EMCC , ' - O1 ' , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - - separate - asm ' ] ) <nl> + check_execute ( [ PYTHON , EMCC , ' - O1 ' , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - - separate - asm ' , ' - s ' , ' WASM = 0 ' ] ) <nl> count = open ( ' a . out . asm . js ' ) . read ( ) . count ( ' function ' ) <nl> assert count > 30 , count # libc brings in a bunch of stuff <nl> <nl> def test ( filename , opts , expected_funcs , expected_vars ) : <nl> print ( filename , opts ) <nl> - check_execute ( [ PYTHON , EMCC , path_from_root ( ' tests ' , filename ) , ' - - separate - asm ' , ' - s ' , ' ONLY_MY_CODE = 1 ' ] + opts ) <nl> + check_execute ( [ PYTHON , EMCC , path_from_root ( ' tests ' , filename ) , ' - - separate - asm ' , ' - s ' , ' ONLY_MY_CODE = 1 ' , ' - s ' , ' WASM = 0 ' ] + opts ) <nl> full = ' var Module = { } ; \ n ' + open ( ' a . out . asm . js ' ) . read ( ) <nl> open ( ' asm . js ' , ' w ' ) . write ( full ) <nl> funcs = open ( ' a . out . asm . js ' ) . read ( ) . count ( ' function ' ) <nl> def test_EM_ASM_i64 ( self ) : <nl> } <nl> ' ' ' ) <nl> err = run_process ( [ PYTHON , EMCC , ' src . cpp ' , ' - Oz ' ] , stderr = PIPE , check = False ) . stderr <nl> - self . assertContained ( ' LLVM ERROR : EM_ASM should not receive i64s as inputs , they are not valid in JS ' , err ) <nl> + self . assertContained ( ' EM_ASM should not receive i64s as inputs , they are not valid in JS ' , err ) <nl> <nl> def test_eval_ctors ( self ) : <nl> for wasm in ( 1 , 0 ) : <nl> def test_override_environment ( self ) : <nl> } ) ; <nl> } <nl> ' ' ' ) <nl> - check_execute ( [ PYTHON , EMCC , ' main . cpp ' ] ) <nl> + # use SINGLE_FILE since we don ' t want to depend on loading a side . wasm file on the environment in this test ; <nl> + # with the wrong env we have very odd failures <nl> + check_execute ( [ PYTHON , EMCC , ' main . cpp ' , ' - s ' , ' SINGLE_FILE = 1 ' ] ) <nl> src = open ( ' a . out . js ' ) . read ( ) <nl> envs = [ ' WEB ' , ' WORKER ' , ' NODE ' , ' SHELL ' ] <nl> for env in envs : <nl> - curr = ' var Module = { ENVIRONMENT : " % s " } ; \ n ' % env <nl> - open ( ' test . js ' , ' w ' ) . write ( curr + src ) <nl> for engine in JS_ENGINES : <nl> if engine = = V8_ENGINE : continue # ban v8 , weird failures <nl> actual = ' NODE ' if engine = = NODE_JS else ' SHELL ' <nl> print ( env , actual , engine ) <nl> + module = { ' ENVIRONMENT ' : env } <nl> + if env ! = actual : <nl> + # avoid problems with arguments detection , which may cause very odd failures with the wrong environment code <nl> + module [ ' arguments ' ] = [ ] <nl> + curr = ' var Module = % s ; \ n ' % str ( module ) <nl> + print ( ' ' + curr ) <nl> + open ( ' test . js ' , ' w ' ) . write ( curr + src ) <nl> fail = False <nl> try : <nl> seen = run_js ( ' test . js ' , engine = engine , stderr = PIPE ) <nl> def test_disable_inlining ( self ) : <nl> try_delete ( ' test . bc ' ) <nl> <nl> def test_output_eol ( self ) : <nl> - for params in [ [ ] , [ ' - - separate - asm ' ] , [ ' - - proxy - to - worker ' ] , [ ' - - proxy - to - worker ' , ' - - separate - asm ' ] ] : <nl> + # - - separate - asm only makes sense without wasm ( no asm . js with wasm ) <nl> + for params in [ [ ] , [ ' - - separate - asm ' , ' - s ' , ' WASM = 0 ' ] , [ ' - - proxy - to - worker ' ] , [ ' - - proxy - to - worker ' , ' - - separate - asm ' , ' - s ' , ' WASM = 0 ' ] ] : <nl> for output_suffix in [ ' html ' , ' js ' ] : <nl> for eol in [ ' windows ' , ' linux ' ] : <nl> files = [ ' a . js ' ] <nl> def test_output_eol ( self ) : <nl> if output_suffix = = ' html ' : files + = [ ' a . html ' ] <nl> cmd = [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - o ' , ' a . ' + output_suffix , ' - - output_eol ' , eol ] + params <nl> print ( cmd ) <nl> - Popen ( cmd ) . communicate ( ) <nl> + run_process ( cmd ) <nl> for f in files : <nl> print ( str ( cmd ) + ' ' + str ( params ) + ' ' + eol + ' ' + f ) <nl> assert os . path . isfile ( f ) <nl> def test_binaryen_asmjs_outputs ( self ) : <nl> ( [ ' - s ' , ' BINARYEN_METHOD = " native - wasm , asmjs " ' ] , True ) <nl> ] : <nl> with temp_directory ( ) as temp_dir : <nl> - cmd = [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 1 ' , ' - o ' , os . path . join ( temp_dir , ' a . js ' ) ] + args <nl> + cmd = [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - o ' , os . path . join ( temp_dir , ' a . js ' ) ] + args <nl> print ( ' ' . join ( cmd ) ) <nl> subprocess . check_call ( cmd ) <nl> assert os . path . exists ( os . path . join ( temp_dir , ' a . asm . js ' ) ) = = output_asmjs <nl> def test_binaryen_asmjs_outputs ( self ) : <nl> <nl> # Test that outputting to . wasm does not nuke an existing . asm . js file , if user wants to manually dual - deploy both to same directory . <nl> with temp_directory ( ) as temp_dir : <nl> - cmd = [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - o ' , os . path . join ( temp_dir , ' a . js ' ) , ' - - separate - asm ' ] <nl> + cmd = [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 0 ' , ' - o ' , os . path . join ( temp_dir , ' a . js ' ) , ' - - separate - asm ' ] <nl> print ( ' ' . join ( cmd ) ) <nl> subprocess . check_call ( cmd ) <nl> assert os . path . exists ( os . path . join ( temp_dir , ' a . asm . js ' ) ) <nl> <nl> - cmd = [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - o ' , os . path . join ( temp_dir , ' a . js ' ) , ' - s ' , ' WASM = 1 ' ] <nl> + cmd = [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 0 ' , ' - o ' , os . path . join ( temp_dir , ' a . js ' ) , ' - s ' , ' WASM = 1 ' ] <nl> print ( ' ' . join ( cmd ) ) <nl> subprocess . check_call ( cmd ) <nl> assert os . path . exists ( os . path . join ( temp_dir , ' a . asm . js ' ) ) <nl> def test_binaryen_mem ( self ) : <nl> assert parts [ 6 ] = = str ( expect_max ) <nl> <nl> def test_binaryen_invalid_mem ( self ) : <nl> - ret = subprocess . check_call ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 1 ' , ' - s ' , ' TOTAL_MEMORY = 33MB ' ] ) <nl> + ret = subprocess . check_call ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' TOTAL_MEMORY = 33MB ' ] ) <nl> <nl> - ret = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM = 1 ' , ' - s ' , ' TOTAL_MEMORY = 32MB + 1 ' ] , stderr = subprocess . PIPE , check = False ) . stderr <nl> + ret = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' TOTAL_MEMORY = 32MB + 1 ' ] , stderr = subprocess . PIPE , check = False ) . stderr <nl> assert ' TOTAL_MEMORY must be a multiple of 64KB ' in ret , ret <nl> <nl> - ret = subprocess . check_call ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' TOTAL_MEMORY = 32MB ' ] ) <nl> + ret = subprocess . check_call ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' TOTAL_MEMORY = 32MB ' ] ) <nl> <nl> - ret = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' TOTAL_MEMORY = 33MB ' ] , stderr = subprocess . PIPE , check = False ) . stderr <nl> + ret = run_process ( [ PYTHON , EMCC , ' - s ' , ' WASM = 0 ' , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' TOTAL_MEMORY = 33MB ' ] , stderr = subprocess . PIPE , check = False ) . stderr <nl> assert ' TOTAL_MEMORY must be a multiple of 16MB ' in ret , ret <nl> <nl> ret = run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . c ' ) , ' - s ' , ' WASM_MEM_MAX = 33MB ' ] , stderr = subprocess . PIPE , check = False ) . stderr <nl> def test_sysconf_phys_pages ( self ) : <nl> for args , expected in [ <nl> ( [ ] , 1024 ) , <nl> ( [ ' - s ' , ' TOTAL_MEMORY = 32MB ' ] , 2048 ) , <nl> - ( [ ' - s ' , ' TOTAL_MEMORY = 32MB ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' ] , ( 2 * 1024 * 1024 * 1024 - 16777216 ) / / 16384 ) , <nl> + ( [ ' - s ' , ' TOTAL_MEMORY = 32MB ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' ] , ( 2 * 1024 * 1024 * 1024 - 65536 ) / / 16384 ) , <nl> + ( [ ' - s ' , ' TOTAL_MEMORY = 32MB ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' , ' - s ' , ' WASM = 0 ' ] , ( 2 * 1024 * 1024 * 1024 - 16777216 ) / / 16384 ) , <nl> ( [ ' - s ' , ' TOTAL_MEMORY = 32MB ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " interpret - asm2wasm " ' ] , 2048 ) , <nl> ( [ ' - s ' , ' TOTAL_MEMORY = 32MB ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " interpret - asm2wasm " ' ] , ( 2 * 1024 * 1024 * 1024 - 65536 ) / / 16384 ) , <nl> ( [ ' - s ' , ' TOTAL_MEMORY = 32MB ' , ' - s ' , ' ALLOW_MEMORY_GROWTH = 1 ' , ' - s ' , ' BINARYEN = 1 ' , ' - s ' , ' BINARYEN_METHOD = " interpret - asm2wasm " ' , ' - s ' , ' WASM_MEM_MAX = 128MB ' ] , 2048 * 4 ) <nl> def test_wasm_backend ( self ) : <nl> else : <nl> os . environ [ ' EMCC_WASM_BACKEND ' ] = old <nl> <nl> + def test_wasm_nope ( self ) : <nl> + for opts in [ [ ] , [ ' - O2 ' ] ] : <nl> + print ( opts ) <nl> + # check we show a good error message if there is no wasm support <nl> + open ( ' pre . js ' , ' w ' ) . write ( ' WebAssembly = undefined ; \ n ' ) <nl> + run_process ( [ PYTHON , EMCC , path_from_root ( ' tests ' , ' hello_world . cpp ' ) , ' - - pre - js ' , ' pre . js ' ] + opts ) <nl> + out = run_js ( ' a . out . js ' , stderr = STDOUT , assert_returncode = None ) <nl> + if opts = = [ ] : <nl> + self . assertContained ( ' No WebAssembly support found . Build with - s WASM = 0 to target JavaScript instead . ' , out ) <nl> + else : <nl> + self . assertContained ( ' no native wasm support detected ' , out ) <nl> + <nl> def test_check_engine ( self ) : <nl> compiler_engine = COMPILER_ENGINE <nl> bogus_engine = [ ' / fake / inline4 ' ] <nl> def test_single_file ( self ) : <nl> if closure_enabled : <nl> cmd + = [ ' - - closure ' , ' 1 ' ] <nl> if wasm_enabled : <nl> - method = ' interpret - binary ' <nl> + method = ' native - wasm ' <nl> if asmjs_fallback_enabled : <nl> method + = ' , asmjs ' <nl> cmd + = [ ' - s ' , ' WASM = 1 ' , ' - s ' , " BINARYEN_METHOD = ' " + method + " ' " ] <nl> + else : <nl> + cmd + = [ ' - s ' , ' WASM = 0 ' ] <nl> <nl> print ( ' ' . join ( cmd ) ) <nl> self . clear ( ) <nl> mmm a / tests / test_sanity . py <nl> ppp b / tests / test_sanity . py <nl> def test_nostdincxx ( self ) : <nl> <nl> for compiler in [ EMCC ] : <nl> print ( compiler ) <nl> + run_process ( [ PYTHON , EMCC ] + MINIMAL_HELLO_WORLD + [ ' - v ' ] ) # run once to ensure binaryen port is all ready <nl> output = run_process ( [ PYTHON , EMCC ] + MINIMAL_HELLO_WORLD + [ ' - v ' ] , stdout = PIPE , stderr = PIPE ) <nl> out = output . stdout <nl> err = output . stderr <nl> output2 = run_process ( [ PYTHON , EMCC ] + MINIMAL_HELLO_WORLD + [ ' - v ' , ' - nostdinc + + ' ] , stdout = PIPE , stderr = PIPE ) <nl> out2 = output2 . stdout <nl> err2 = output2 . stderr <nl> - assert out = = out2 <nl> + self . assertIdentical ( out , out2 ) <nl> def focus ( e ) : <nl> assert ' search starts here : ' in e , e <nl> assert e . count ( ' End of search list . ' ) = = 1 , e <nl> def test_emcc_ports ( self ) : <nl> assert not os . path . exists ( PORTS_DIR ) <nl> <nl> # Building a file that doesn ' t need ports should not trigger anything <nl> - output = self . do ( [ compiler , path_from_root ( ' tests ' , ' hello_world_sdl . cpp ' ) ] ) <nl> + # ( avoid wasm to avoid the binaryen port ) <nl> + output = self . do ( [ compiler , path_from_root ( ' tests ' , ' hello_world_sdl . cpp ' ) , ' - s ' , ' WASM = 0 ' ] ) <nl> print ( ' no ' , output ) <nl> - assert RETRIEVING_MESSAGE not in output <nl> + assert RETRIEVING_MESSAGE not in output , output <nl> assert BUILDING_MESSAGE not in output <nl> assert not os . path . exists ( PORTS_DIR ) <nl> <nl> # Building a file that need a port does trigger stuff <nl> - output = self . do ( [ compiler , path_from_root ( ' tests ' , ' hello_world_sdl . cpp ' ) , ' - s ' , ' USE_SDL = 2 ' ] ) <nl> + output = self . do ( [ compiler , path_from_root ( ' tests ' , ' hello_world_sdl . cpp ' ) , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_SDL = 2 ' ] ) <nl> print ( ' yes ' , output ) <nl> assert RETRIEVING_MESSAGE in output , output <nl> assert BUILDING_MESSAGE in output , output <nl> def test_emcc_ports ( self ) : <nl> <nl> def second_use ( ) : <nl> # Using it again avoids retrieve and build <nl> - output = self . do ( [ compiler , path_from_root ( ' tests ' , ' hello_world_sdl . cpp ' ) , ' - s ' , ' USE_SDL = 2 ' ] ) <nl> + output = self . do ( [ compiler , path_from_root ( ' tests ' , ' hello_world_sdl . cpp ' ) , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_SDL = 2 ' ] ) <nl> assert RETRIEVING_MESSAGE not in output , output <nl> assert BUILDING_MESSAGE not in output , output <nl> <nl> def second_use ( ) : <nl> z . write ( os . path . join ( ' old - sub ' , ' a . txt ' ) ) <nl> z . write ( os . path . join ( ' old - sub ' , ' b . txt ' ) ) <nl> z . close ( ) <nl> - output = self . do ( [ compiler , path_from_root ( ' tests ' , ' hello_world_sdl . cpp ' ) , ' - s ' , ' USE_SDL = 2 ' ] ) <nl> + output = self . do ( [ compiler , path_from_root ( ' tests ' , ' hello_world_sdl . cpp ' ) , ' - s ' , ' WASM = 0 ' , ' - s ' , ' USE_SDL = 2 ' ] ) <nl> assert RETRIEVING_MESSAGE in output , output <nl> assert BUILDING_MESSAGE in output , output <nl> assert os . path . exists ( PORTS_DIR ) <nl> def test_native_optimizer ( self ) : <nl> restore_and_set_up ( ) <nl> <nl> def build ( ) : <nl> - return self . check_working ( [ EMCC ] + MINIMAL_HELLO_WORLD + [ ' - O2 ' ] , ' running js post - opts ' ) <nl> + return self . check_working ( [ EMCC ] + MINIMAL_HELLO_WORLD + [ ' - O2 ' , ' - s ' , ' WASM = 0 ' ] , ' running js post - opts ' ) <nl> <nl> def test ( ) : <nl> self . assertContained ( ' hello , world ! ' , run_js ( ' a . out . js ' ) ) <nl> mmm a / tools / gen_struct_info . py <nl> ppp b / tools / gen_struct_info . py <nl> def inspect_code ( headers , cpp_opts , structs , defines ) : <nl> try : <nl> # Compile the program . <nl> show ( ' Compiling generated code . . . ' ) <nl> - subprocess . check_call ( [ shared . PYTHON , shared . EMCC ] + cpp_opts + [ ' - o ' , js_file [ 1 ] , src_file [ 1 ] , ' - s ' , ' BOOTSTRAPPING_STRUCT_INFO = 1 ' , ' - s ' , ' WARN_ON_UNDEFINED_SYMBOLS = 0 ' , ' - Oz ' , ' - - js - opts ' , ' 0 ' , ' - - memory - init - file ' , ' 0 ' ] , env = safe_env ) # - Oz optimizes enough to avoid warnings on code size / num locals <nl> + subprocess . check_call ( [ shared . PYTHON , shared . EMCC ] + cpp_opts + [ ' - o ' , js_file [ 1 ] , src_file [ 1 ] , ' - s ' , ' BOOTSTRAPPING_STRUCT_INFO = 1 ' , ' - s ' , ' WARN_ON_UNDEFINED_SYMBOLS = 0 ' , ' - Oz ' , ' - - js - opts ' , ' 0 ' , ' - - memory - init - file ' , ' 0 ' , ' - s ' , ' SINGLE_FILE = 1 ' ] , env = safe_env ) # - Oz optimizes enough to avoid warnings on code size / num locals <nl> except : <nl> sys . stderr . write ( ' FAIL : Compilation failed ! \ n ' ) <nl> sys . exit ( 1 ) <nl> mmm a / tools / ports / binaryen . py <nl> ppp b / tools / ports / binaryen . py <nl> <nl> TAG = ' version_47 ' <nl> <nl> def needed ( settings , shared , ports ) : <nl> - if not settings . BINARYEN : return False <nl> + if not settings . WASM : return False <nl> try : <nl> if shared . BINARYEN_ROOT : # if defined , and not falsey , we don ' t need the port <nl> logging . debug ( ' binaryen root already set to ' + shared . BINARYEN_ROOT ) <nl> mmm a / tools / shared . py <nl> ppp b / tools / shared . py <nl> def get_binaryen ( ) : <nl> # fetch the port , so we have binaryen set up . indicate we need binaryen <nl> # using the settings <nl> from . import system_libs <nl> - old = Settings . BINARYEN <nl> - Settings . BINARYEN = 1 <nl> + old = Settings . WASM <nl> + Settings . WASM = 1 <nl> system_libs . get_port ( ' binaryen ' , Settings ) <nl> - Settings . BINARYEN = old <nl> + Settings . WASM = old <nl> <nl> @ staticmethod <nl> def get_binaryen_bin ( ) : <nl> def make_initializer ( sig , settings = None ) : <nl> return ' Math_fround ( 0 ) ' <nl> elif sig = = ' j ' : <nl> if settings : <nl> - assert settings [ ' BINARYEN ' ] , ' j aka i64 only makes sense in wasm - only mode in binaryen ' <nl> + assert settings [ ' WASM ' ] , ' j aka i64 only makes sense in wasm - only mode in binaryen ' <nl> return ' i64 ( 0 ) ' <nl> elif sig = = ' F ' : <nl> return ' SIMD_Float32x4_check ( SIMD_Float32x4 ( 0 , 0 , 0 , 0 ) ) ' <nl> def make_coercion ( value , sig , settings = None , ffi_arg = False , ffi_result = False , co <nl> return ' + ' + value <nl> elif sig = = ' j ' : <nl> if settings : <nl> - assert settings [ ' BINARYEN ' ] , ' j aka i64 only makes sense in wasm - only mode in binaryen ' <nl> + assert settings [ ' WASM ' ] , ' j aka i64 only makes sense in wasm - only mode in binaryen ' <nl> return ' i64 ( ' + value + ' ) ' <nl> elif sig = = ' F ' : <nl> return ' SIMD_Float32x4_check ( ' + value + ' ) ' <nl> mmm a / tools / system_libs . py <nl> ppp b / tools / system_libs . py <nl> class Dummy ( object ) : <nl> force . add ( malloc_name ( ) ) <nl> <nl> # if building to wasm , we need more math code , since we have less builtins <nl> - if shared . Settings . BINARYEN : <nl> + if shared . Settings . WASM : <nl> system_libs + = [ ( ' wasm - libc ' , ' bc ' , create_wasm_libc , wasm_libc_symbols , [ ] , False ) ] <nl> # if libc is included , we definitely must be , as it might need us <nl> for data in system_libs : <nl> def do_create ( ) : <nl> <nl> # Handle backend compiler_rt separately because it is not a bitcode system lib like the others . <nl> # Here , just ensure that it ' s in the cache . <nl> - if shared . Settings . BINARYEN and shared . Settings . WASM_BACKEND : <nl> + if shared . Settings . WASM and shared . Settings . WASM_BACKEND : <nl> shared . Cache . get ( ' wasm_compiler_rt . a ' , lambda : create_wasm_compiler_rt ( ' wasm_compiler_rt . a ' ) , extension = ' a ' ) <nl> shared . Cache . get ( ' wasm_libc_rt . a ' , lambda : create_wasm_libc_rt ( ' wasm_libc_rt . a ' ) , extension = ' a ' ) <nl> <nl> | Emit WebAssembly by default ( ) | emscripten-core/emscripten | 6e5818017d1b2e09e9f7ad22a32e9a191f6f9a3b | 2018-05-10T02:44:18Z |
mmm a / xbmc / dbwrappers / Database . cpp <nl> ppp b / xbmc / dbwrappers / Database . cpp <nl> bool CDatabase : : Connect ( const std : : string & dbName , const DatabaseSettings & dbSet <nl> / / database name is always required <nl> m_pDB - > setDatabase ( dbName . c_str ( ) ) ; <nl> <nl> - / / set SSL configuration regardless if any are empty ( all empty means no SSL ) . <nl> - m_pDB - > setSSLConfig ( dbSettings . key . c_str ( ) , dbSettings . cert . c_str ( ) , dbSettings . ca . c_str ( ) , dbSettings . capath . c_str ( ) , dbSettings . ciphers . c_str ( ) ) ; <nl> + / / set configuration regardless if any are empty <nl> + m_pDB - > setConfig ( dbSettings . key . c_str ( ) , <nl> + dbSettings . cert . c_str ( ) , <nl> + dbSettings . ca . c_str ( ) , <nl> + dbSettings . capath . c_str ( ) , <nl> + dbSettings . ciphers . c_str ( ) , <nl> + dbSettings . compression ) ; <nl> <nl> / / create the datasets <nl> m_pDS . reset ( m_pDB - > CreateDataset ( ) ) ; <nl> mmm a / xbmc / dbwrappers / dataset . cpp <nl> ppp b / xbmc / dbwrappers / dataset . cpp <nl> Database : : ~ Database ( ) { <nl> disconnect ( ) ; / / Disconnect if connected to database <nl> } <nl> <nl> - int Database : : connectFull ( const char * newHost , const char * newPort , const char * newDb , const char * newLogin , const char * newPasswd , <nl> - const char * newKey , const char * newCert , const char * newCA , const char * newCApath , const char * newCiphers ) { <nl> + int Database : : connectFull ( const char * newHost , const char * newPort , const char * newDb , const char * newLogin , <nl> + const char * newPasswd , const char * newKey , const char * newCert , const char * newCA , <nl> + const char * newCApath , const char * newCiphers , bool newCompression ) { <nl> host = newHost ; <nl> port = newPort ; <nl> db = newDb ; <nl> int Database : : connectFull ( const char * newHost , const char * newPort , const char * <nl> ca = newCA ; <nl> capath = newCApath ; <nl> ciphers = newCiphers ; <nl> + compression = newCompression ; <nl> return connect ( true ) ; <nl> } <nl> <nl> mmm a / xbmc / dbwrappers / dataset . h <nl> ppp b / xbmc / dbwrappers / dataset . h <nl> class Dataset ; / / forward declaration of class Dataset <nl> class Database { <nl> protected : <nl> bool active ; <nl> + bool compression ; <nl> std : : string error , / / Error description <nl> host , port , db , login , passwd , / / Login info <nl> sequence_table , / / Sequence table for nextid <nl> class Database { <nl> const char * getSequenceTable ( void ) { return sequence_table . c_str ( ) ; } <nl> / * Get the default character set * / <nl> const char * getDefaultCharset ( void ) { return default_charset . c_str ( ) ; } <nl> - / * Sets SSL configuration * / <nl> - virtual void setSSLConfig ( const char * newKey , const char * newCert , const char * newCA , const char * newCApath , const char * newCiphers ) { <nl> + / * Sets configuration * / <nl> + virtual void setConfig ( const char * newKey , const char * newCert , const char * newCA , const char * newCApath , const char * newCiphers , bool newCompression ) { <nl> key = newKey ; <nl> cert = newCert ; <nl> ca = newCA ; <nl> capath = newCApath ; <nl> ciphers = newCiphers ; <nl> + compression = newCompression ; <nl> } <nl> <nl> / * virtual methods that must be overloaded in derived classes * / <nl> class Database { <nl> virtual int connectFull ( const char * newDb , const char * newHost = NULL , <nl> const char * newLogin = NULL , const char * newPasswd = NULL , const char * newPort = NULL , <nl> const char * newKey = NULL , const char * newCert = NULL , const char * newCA = NULL , <nl> - const char * newCApath = NULL , const char * newCiphers = NULL ) ; <nl> + const char * newCApath = NULL , const char * newCiphers = NULL , bool newCompression = false ) ; <nl> virtual void disconnect ( void ) { active = false ; } <nl> virtual int reset ( void ) { return DB_COMMAND_OK ; } <nl> virtual int create ( void ) { return DB_COMMAND_OK ; } <nl> mmm a / xbmc / dbwrappers / mysqldataset . cpp <nl> ppp b / xbmc / dbwrappers / mysqldataset . cpp <nl> int MysqlDatabase : : connect ( bool create_new ) { <nl> return DB_CONNECTION_NONE ; <nl> <nl> / / establish connection with just user credentials <nl> - if ( mysql_real_connect ( conn , host . c_str ( ) , login . c_str ( ) , passwd . c_str ( ) , NULL , atoi ( port . c_str ( ) ) , NULL , 0 ) ! = NULL ) <nl> + if ( mysql_real_connect ( conn , host . c_str ( ) , <nl> + login . c_str ( ) , <nl> + passwd . c_str ( ) , <nl> + NULL , <nl> + atoi ( port . c_str ( ) ) , <nl> + NULL , <nl> + compression ? CLIENT_COMPRESS : 0 ) ! = NULL ) <nl> { <nl> / / disable mysql autocommit since we handle it <nl> / / mysql_autocommit ( conn , false ) ; <nl> mmm a / xbmc / settings / AdvancedSettings . cpp <nl> ppp b / xbmc / settings / AdvancedSettings . cpp <nl> void CAdvancedSettings : : ParseSettingsFile ( const std : : string & file ) <nl> XMLUtils : : GetString ( pDatabase , " ca " , m_databaseVideo . ca ) ; <nl> XMLUtils : : GetString ( pDatabase , " capath " , m_databaseVideo . capath ) ; <nl> XMLUtils : : GetString ( pDatabase , " ciphers " , m_databaseVideo . ciphers ) ; <nl> + XMLUtils : : GetBoolean ( pDatabase , " compression " , m_databaseVideo . compression ) ; <nl> } <nl> <nl> pDatabase = pRootElement - > FirstChildElement ( " musicdatabase " ) ; <nl> void CAdvancedSettings : : ParseSettingsFile ( const std : : string & file ) <nl> XMLUtils : : GetString ( pDatabase , " ca " , m_databaseMusic . ca ) ; <nl> XMLUtils : : GetString ( pDatabase , " capath " , m_databaseMusic . capath ) ; <nl> XMLUtils : : GetString ( pDatabase , " ciphers " , m_databaseMusic . ciphers ) ; <nl> + XMLUtils : : GetBoolean ( pDatabase , " compression " , m_databaseMusic . compression ) ; <nl> } <nl> <nl> pDatabase = pRootElement - > FirstChildElement ( " tvdatabase " ) ; <nl> void CAdvancedSettings : : ParseSettingsFile ( const std : : string & file ) <nl> XMLUtils : : GetString ( pDatabase , " ca " , m_databaseTV . ca ) ; <nl> XMLUtils : : GetString ( pDatabase , " capath " , m_databaseTV . capath ) ; <nl> XMLUtils : : GetString ( pDatabase , " ciphers " , m_databaseTV . ciphers ) ; <nl> + XMLUtils : : GetBoolean ( pDatabase , " compression " , m_databaseTV . compression ) ; <nl> } <nl> <nl> pDatabase = pRootElement - > FirstChildElement ( " epgdatabase " ) ; <nl> void CAdvancedSettings : : ParseSettingsFile ( const std : : string & file ) <nl> XMLUtils : : GetString ( pDatabase , " ca " , m_databaseEpg . ca ) ; <nl> XMLUtils : : GetString ( pDatabase , " capath " , m_databaseEpg . capath ) ; <nl> XMLUtils : : GetString ( pDatabase , " ciphers " , m_databaseEpg . ciphers ) ; <nl> + XMLUtils : : GetBoolean ( pDatabase , " compression " , m_databaseEpg . compression ) ; <nl> } <nl> <nl> pElement = pRootElement - > FirstChildElement ( " enablemultimediakeys " ) ; <nl> mmm a / xbmc / settings / AdvancedSettings . h <nl> ppp b / xbmc / settings / AdvancedSettings . h <nl> class DatabaseSettings <nl> ca . clear ( ) ; <nl> capath . clear ( ) ; <nl> ciphers . clear ( ) ; <nl> + compression = false ; <nl> } ; <nl> std : : string type ; <nl> std : : string host ; <nl> class DatabaseSettings <nl> std : : string ca ; <nl> std : : string capath ; <nl> std : : string ciphers ; <nl> + bool compression ; <nl> } ; <nl> <nl> struct TVShowRegexp <nl> | Merge pull request from mkortstiege / mysql_compress | xbmc/xbmc | 8a00df36992a333ebd171f500d8af1b2d4fbb448 | 2015-03-01T11:08:54Z |
mmm a / stdlib / public / SDK / Foundation / NSSet . swift <nl> ppp b / stdlib / public / SDK / Foundation / NSSet . swift <nl> extension Set { <nl> / / / <nl> / / / The provided ` NSSet ` will be copied to ensure that the copy can <nl> / / / not be mutated by other code . <nl> - fileprivate init ( _cocoaSet : __shared _NSSet ) { <nl> + fileprivate init ( _cocoaSet : __shared AnyObject ) { <nl> assert ( _isBridgedVerbatimToObjectiveC ( Element . self ) , <nl> " Set can be backed by NSSet _variantStorage only when the member type can be bridged verbatim to Objective - C " ) <nl> / / FIXME : We would like to call CFSetCreateCopy ( ) to avoid doing an <nl> extension Set { <nl> / / <nl> / / The bug is fixed in : OS X 10 . 11 . 0 , iOS 9 . 0 , all versions of tvOS <nl> / / and watchOS . <nl> - self = Set ( <nl> - _immutableCocoaSet : <nl> - unsafeBitCast ( _cocoaSet . copy ( with : nil ) as AnyObject , to : _NSSet . self ) ) <nl> + self = Set ( _immutableCocoaSet : _cocoaSet . copy ( with : nil ) ) <nl> } <nl> } <nl> <nl> extension Set : _ObjectiveCBridgeable { <nl> } <nl> <nl> if _isBridgedVerbatimToObjectiveC ( Element . self ) { <nl> - result = Set < Element > ( _cocoaSet : unsafeBitCast ( s , to : _NSSet . self ) ) <nl> + result = Set < Element > ( _cocoaSet : s ) <nl> return <nl> } <nl> <nl> mmm a / stdlib / public / core / Set . swift <nl> ppp b / stdlib / public / core / Set . swift <nl> public struct Set < Element : Hashable > { <nl> / / / is a reference type ) . <nl> @ inlinable <nl> public / / SPI ( Foundation ) <nl> - init ( _immutableCocoaSet : __owned _NSSet ) { <nl> + init ( _immutableCocoaSet : __owned AnyObject ) { <nl> _sanityCheck ( _isBridgedVerbatimToObjectiveC ( Element . self ) , <nl> " Set can be backed by NSSet _variant only when the member type can be bridged verbatim to Objective - C " ) <nl> self . init ( _cocoa : _CocoaSet ( _immutableCocoaSet ) ) <nl> mmm a / stdlib / public / core / SetBridging . swift <nl> ppp b / stdlib / public / core / SetBridging . swift <nl> <nl> import SwiftShims <nl> <nl> @ _silgen_name ( " swift_stdlib_CFSetGetValues " ) <nl> - @ usableFromInline <nl> internal <nl> - func _stdlib_CFSetGetValues ( _ nss : _NSSet , _ : UnsafeMutablePointer < AnyObject > ) <nl> + func _stdlib_CFSetGetValues ( <nl> + _ nss : AnyObject , <nl> + _ : UnsafeMutablePointer < AnyObject > ) <nl> <nl> / / / Equivalent to ` NSSet . allObjects ` , but does not leave objects on the <nl> / / / autorelease pool . <nl> - internal func _stdlib_NSSet_allObjects ( _ nss : _NSSet ) - > _BridgingBuffer { <nl> + internal func _stdlib_NSSet_allObjects ( _ object : AnyObject ) - > _BridgingBuffer { <nl> + let nss = unsafeBitCast ( object , to : _NSSet . self ) <nl> let storage = _BridgingBuffer ( nss . count ) <nl> _stdlib_CFSetGetValues ( nss , storage . baseAddress ) <nl> return storage <nl> internal func _stdlib_NSSet_allObjects ( _ nss : _NSSet ) - > _BridgingBuffer { <nl> <nl> extension _NativeSet { / / Bridging <nl> @ usableFromInline <nl> - internal __consuming func bridged ( ) - > _NSSet { <nl> + internal __consuming func bridged ( ) - > AnyObject { <nl> / / We can zero - cost bridge if our keys are verbatim <nl> / / or if we ' re the empty singleton . <nl> <nl> - / / Temporary var for SOME type safety before a cast . <nl> + / / Temporary var for SOME type safety . <nl> let nsSet : _NSSetCore <nl> <nl> if _storage = = = _RawSetStorage . empty | | count = = 0 { <nl> extension _NativeSet { / / Bridging <nl> / / Cast from " minimal NSSet " to " NSSet " <nl> / / Note that if you actually ask Swift for this cast , it will fail . <nl> / / Never trust a shadow protocol ! <nl> - return unsafeBitCast ( nsSet , to : _NSSet . self ) <nl> + return nsSet <nl> } <nl> } <nl> <nl> final internal class _SwiftDeferredNSSet < Element : Hashable > <nl> @ _fixed_layout <nl> internal struct _CocoaSet { <nl> @ usableFromInline <nl> - internal let object : _NSSet <nl> + internal let object : AnyObject <nl> <nl> @ inlinable <nl> - internal init ( _ object : __owned _NSSet ) { <nl> + internal init ( _ object : __owned AnyObject ) { <nl> self . object = object <nl> } <nl> } <nl> extension _CocoaSet { <nl> return index . element <nl> } <nl> <nl> - @ inlinable <nl> + @ usableFromInline <nl> internal func member ( for element : AnyObject ) - > AnyObject ? { <nl> - return object . member ( element ) <nl> + let nss = unsafeBitCast ( object , to : _NSSet . self ) <nl> + return nss . member ( element ) <nl> } <nl> } <nl> <nl> extension _CocoaSet : _SetBuffer { <nl> " An NSSet member wasn ' t listed amongst its enumerated contents " ) <nl> } <nl> <nl> - @ inlinable <nl> + @ usableFromInline <nl> internal var count : Int { <nl> - return object . count <nl> + let nss = unsafeBitCast ( object , to : _NSSet . self ) <nl> + return nss . count <nl> } <nl> <nl> - @ inlinable <nl> + @ usableFromInline <nl> internal func contains ( _ element : AnyObject ) - > Bool { <nl> - return object . member ( element ) ! = nil <nl> + let nss = unsafeBitCast ( object , to : _NSSet . self ) <nl> + return nss . member ( element ) ! = nil <nl> } <nl> <nl> @ usableFromInline / / FIXME ( cocoa - index ) : Make inlinable <nl> extension _CocoaSet . Iterator : IteratorProtocol { <nl> <nl> extension Set { <nl> @ inlinable <nl> - public __consuming func _bridgeToObjectiveCImpl ( ) - > _NSSetCore { <nl> + public __consuming func _bridgeToObjectiveCImpl ( ) - > AnyObject { <nl> guard _variant . isNative else { <nl> return _variant . asCocoa . object <nl> } <nl> mmm a / stdlib / public / core / SetVariant . swift <nl> ppp b / stdlib / public / core / SetVariant . swift <nl> extension Set { <nl> @ usableFromInline <nl> @ _fixed_layout <nl> internal struct _Variant { <nl> - # if _runtime ( _ObjC ) <nl> - @ usableFromInline <nl> - internal var object : _BridgeStorage < _RawSetStorage , _NSSet > <nl> - # else <nl> @ usableFromInline <nl> internal var object : _BridgeStorage < _RawSetStorage , AnyObject > <nl> - # endif <nl> <nl> @ inlinable <nl> @ inline ( __always ) <nl> mmm a / stdlib / public / core / ShadowProtocols . swift <nl> ppp b / stdlib / public / core / ShadowProtocols . swift <nl> internal protocol _NSDictionary : _NSDictionaryCore { <nl> / / / Covers a set of operations everyone needs to implement in order to <nl> / / / be a useful ` NSSet ` subclass . <nl> @ objc <nl> - public protocol _NSSetCore : <nl> - _NSCopying , _NSFastEnumeration { <nl> + internal protocol _NSSetCore : _NSCopying , _NSFastEnumeration { <nl> <nl> / / The following methods should be overridden when implementing an <nl> / / NSSet subclass . <nl> public protocol _NSSetCore : <nl> / / / forced to implement operations that ` NSSet ` already <nl> / / / supplies . <nl> @ unsafe_no_objc_tagged_pointer @ objc <nl> - public protocol _NSSet : _NSSetCore { <nl> + internal protocol _NSSet : _NSSetCore { <nl> } <nl> <nl> / / / A shadow for the API of NSNumber we will use in the core <nl> public protocol _NSNumber { <nl> # else <nl> <nl> public protocol _NSArrayCore { } <nl> - public protocol _NSSetCore { } <nl> <nl> # endif <nl> mmm a / test / api - digester / Outputs / stability - stdlib - abi . swift . expected <nl> ppp b / test / api - digester / Outputs / stability - stdlib - abi . swift . expected <nl> Protocol _NSDictionary has been removed <nl> Protocol _NSDictionaryCore has been removed <nl> Var Dictionary . _Variant . object has declared type change from _BridgeStorage < _RawDictionaryStorage , _NSDictionary > to _BridgeStorage < _RawDictionaryStorage , AnyObject > <nl> Var _CocoaDictionary . object has declared type change from _NSDictionary to AnyObject <nl> + <nl> + Class _EmptySetSingleton has removed conformance to _NSSetCore <nl> + Class _SetStorage has removed conformance to _NSSetCore <nl> + Constructor Set . init ( _immutableCocoaSet : ) has parameter 0 type change from _NSSet to AnyObject <nl> + Constructor _CocoaSet . init ( _ : ) has parameter 0 type change from _NSSet to AnyObject <nl> + Func Set . _bridgeToObjectiveCImpl ( ) has return type change from _NSSetCore to AnyObject <nl> + Func _NativeSet . bridged ( ) has return type change from _NSSet to AnyObject <nl> + Func _stdlib_CFSetGetValues ( _ : _ : ) has been removed <nl> + Protocol _NSSet has been removed <nl> + Protocol _NSSetCore has been removed <nl> + Var Set . _Variant . object has declared type change from _BridgeStorage < _RawSetStorage , _NSSet > to _BridgeStorage < _RawSetStorage , AnyObject > <nl> + Var _CocoaSet . object has declared type change from _NSSet to AnyObject <nl> | [ stdlib ] Make _NSSetCore , _NSSet internal | apple/swift | 4f8eeae64e83de883f1ec36c9d28fa1ef81020b5 | 2018-11-15T09:54:25Z |
mmm a / src / allocation . cc <nl> ppp b / src / allocation . cc <nl> <nl> <nl> # include < stdlib . h > / / For free , malloc . <nl> # include " src / base / bits . h " <nl> + # include " src / base / lazy - instance . h " <nl> # include " src / base / logging . h " <nl> # include " src / base / platform / platform . h " <nl> + # include " src / base / utils / random - number - generator . h " <nl> + # include " src / flags . h " <nl> # include " src / utils . h " <nl> # include " src / v8 . h " <nl> <nl> bool AlignedAllocVirtualMemory ( size_t size , size_t alignment , void * hint , <nl> return result - > IsReserved ( ) ; <nl> } <nl> <nl> + namespace { <nl> + <nl> + struct RNGInitializer { <nl> + static void Construct ( void * mem ) { <nl> + auto rng = new ( mem ) base : : RandomNumberGenerator ( ) ; <nl> + int64_t random_seed = FLAG_random_seed ; <nl> + if ( random_seed ) { <nl> + rng - > SetSeed ( random_seed ) ; <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + } / / namespace <nl> + <nl> + static base : : LazyInstance < base : : RandomNumberGenerator , RNGInitializer > : : type <nl> + random_number_generator = LAZY_INSTANCE_INITIALIZER ; <nl> + <nl> + void * GetRandomMmapAddr ( ) { <nl> + # if defined ( ADDRESS_SANITIZER ) | | defined ( MEMORY_SANITIZER ) | | \ <nl> + defined ( THREAD_SANITIZER ) <nl> + / / Dynamic tools do not support custom mmap addresses . <nl> + return NULL ; <nl> + # endif <nl> + uintptr_t raw_addr ; <nl> + random_number_generator . Pointer ( ) - > NextBytes ( & raw_addr , sizeof ( raw_addr ) ) ; <nl> + # if V8_OS_POSIX <nl> + # if V8_TARGET_ARCH_X64 <nl> + / / Currently available CPUs have 48 bits of virtual addressing . Truncate <nl> + / / the hint address to 46 bits to give the kernel a fighting chance of <nl> + / / fulfilling our placement request . <nl> + raw_addr & = V8_UINT64_C ( 0x3ffffffff000 ) ; <nl> + # elif V8_TARGET_ARCH_PPC64 <nl> + # if V8_OS_AIX <nl> + / / AIX : 64 bits of virtual addressing , but we limit address range to : <nl> + / / a ) minimize Segment Lookaside Buffer ( SLB ) misses and <nl> + raw_addr & = V8_UINT64_C ( 0x3ffff000 ) ; <nl> + / / Use extra address space to isolate the mmap regions . <nl> + raw_addr + = V8_UINT64_C ( 0x400000000000 ) ; <nl> + # elif V8_TARGET_BIG_ENDIAN <nl> + / / Big - endian Linux : 44 bits of virtual addressing . <nl> + raw_addr & = V8_UINT64_C ( 0x03fffffff000 ) ; <nl> + # else <nl> + / / Little - endian Linux : 48 bits of virtual addressing . <nl> + raw_addr & = V8_UINT64_C ( 0x3ffffffff000 ) ; <nl> + # endif <nl> + # elif V8_TARGET_ARCH_S390X <nl> + / / Linux on Z uses bits 22 - 32 for Region Indexing , which translates to 42 bits <nl> + / / of virtual addressing . Truncate to 40 bits to allow kernel chance to <nl> + / / fulfill request . <nl> + raw_addr & = V8_UINT64_C ( 0xfffffff000 ) ; <nl> + # elif V8_TARGET_ARCH_S390 <nl> + / / 31 bits of virtual addressing . Truncate to 29 bits to allow kernel chance <nl> + / / to fulfill request . <nl> + raw_addr & = 0x1ffff000 ; <nl> + # else <nl> + raw_addr & = 0x3ffff000 ; <nl> + <nl> + # ifdef __sun <nl> + / / For our Solaris / illumos mmap hint , we pick a random address in the bottom <nl> + / / half of the top half of the address space ( that is , the third quarter ) . <nl> + / / Because we do not MAP_FIXED , this will be treated only as a hint - - the <nl> + / / system will not fail to mmap ( ) because something else happens to already <nl> + / / be mapped at our random address . We deliberately set the hint high enough <nl> + / / to get well above the system ' s break ( that is , the heap ) ; Solaris and <nl> + / / illumos will try the hint and if that fails allocate as if there were <nl> + / / no hint at all . The high hint prevents the break from getting hemmed in <nl> + / / at low values , ceding half of the address space to the system heap . <nl> + raw_addr + = 0x80000000 ; <nl> + # elif V8_OS_AIX <nl> + / / The range 0x30000000 - 0xD0000000 is available on AIX ; <nl> + / / choose the upper range . <nl> + raw_addr + = 0x90000000 ; <nl> + # else <nl> + / / The range 0x20000000 - 0x60000000 is relatively unpopulated across a <nl> + / / variety of ASLR modes ( PAE kernel , NX compat mode , etc ) and on macos <nl> + / / 10 . 6 and 10 . 7 . <nl> + raw_addr + = 0x20000000 ; <nl> + # endif <nl> + # endif <nl> + # else / / V8_OS_WIN <nl> + / / The address range used to randomize RWX allocations in OS : : Allocate <nl> + / / Try not to map pages into the default range that windows loads DLLs <nl> + / / Use a multiple of 64k to prevent committing unused memory . <nl> + / / Note : This does not guarantee RWX regions will be within the <nl> + / / range kAllocationRandomAddressMin to kAllocationRandomAddressMax <nl> + # ifdef V8_HOST_ARCH_64_BIT <nl> + static const uintptr_t kAllocationRandomAddressMin = 0x0000000080000000 ; <nl> + static const uintptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000 ; <nl> + # else <nl> + static const uintptr_t kAllocationRandomAddressMin = 0x04000000 ; <nl> + static const uintptr_t kAllocationRandomAddressMax = 0x3FFF0000 ; <nl> + # endif <nl> + raw_addr < < = kPageSizeBits ; <nl> + raw_addr + = kAllocationRandomAddressMin ; <nl> + raw_addr & = kAllocationRandomAddressMax ; <nl> + # endif / / V8_OS_WIN <nl> + return reinterpret_cast < void * > ( raw_addr ) ; <nl> + } <nl> + <nl> } / / namespace internal <nl> } / / namespace v8 <nl> mmm a / src / allocation . h <nl> ppp b / src / allocation . h <nl> bool AllocVirtualMemory ( size_t size , void * hint , VirtualMemory * result ) ; <nl> bool AlignedAllocVirtualMemory ( size_t size , size_t alignment , void * hint , <nl> VirtualMemory * result ) ; <nl> <nl> + / / Generate a random address to be used for hinting mmap ( ) . <nl> + void * GetRandomMmapAddr ( ) ; <nl> + <nl> } / / namespace internal <nl> } / / namespace v8 <nl> <nl> mmm a / src / api . cc <nl> ppp b / src / api . cc <nl> class ArrayBufferAllocator : public v8 : : ArrayBuffer : : Allocator { <nl> virtual void Free ( void * data , size_t ) { free ( data ) ; } <nl> <nl> virtual void * Reserve ( size_t length ) { <nl> - return base : : OS : : ReserveRegion ( length , base : : OS : : GetRandomMmapAddr ( ) ) ; <nl> + return base : : OS : : ReserveRegion ( length , i : : GetRandomMmapAddr ( ) ) ; <nl> } <nl> <nl> virtual void Free ( void * data , size_t length , <nl> mmm a / src / base / platform / platform - aix . cc <nl> ppp b / src / base / platform / platform - aix . cc <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return result ; <nl> } <nl> <nl> - void OS : : SignalCodeMovingGC ( ) { } <nl> + void OS : : SignalCodeMovingGC ( void * hint ) { } <nl> <nl> } / / namespace base <nl> } / / namespace v8 <nl> mmm a / src / base / platform / platform - cygwin . cc <nl> ppp b / src / base / platform / platform - cygwin . cc <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return result ; <nl> } <nl> <nl> - <nl> - void OS : : SignalCodeMovingGC ( ) { <nl> + void OS : : SignalCodeMovingGC ( void * hint ) { <nl> / / Nothing to do on Cygwin . <nl> } <nl> <nl> mmm a / src / base / platform / platform - freebsd . cc <nl> ppp b / src / base / platform / platform - freebsd . cc <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return result ; <nl> } <nl> <nl> - void OS : : SignalCodeMovingGC ( ) { } <nl> + void OS : : SignalCodeMovingGC ( void * hint ) { } <nl> <nl> } / / namespace base <nl> } / / namespace v8 <nl> mmm a / src / base / platform / platform - fuchsia . cc <nl> ppp b / src / base / platform / platform - fuchsia . cc <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return std : : vector < SharedLibraryAddress > ( ) ; <nl> } <nl> <nl> - void OS : : SignalCodeMovingGC ( ) { <nl> + void OS : : SignalCodeMovingGC ( void * hint ) { <nl> CHECK ( false ) ; / / TODO ( scottmg ) : Port , https : / / crbug . com / 731217 . <nl> } <nl> <nl> mmm a / src / base / platform / platform - linux . cc <nl> ppp b / src / base / platform / platform - linux . cc <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return result ; <nl> } <nl> <nl> - void OS : : SignalCodeMovingGC ( ) { <nl> + void OS : : SignalCodeMovingGC ( void * hint ) { <nl> / / Support for ll_prof . py . <nl> / / <nl> / / The Linux profiler built into the kernel logs all mmap ' s with <nl> void OS : : SignalCodeMovingGC ( ) { <nl> OS : : PrintError ( " Failed to open % s \ n " , OS : : GetGCFakeMMapFile ( ) ) ; <nl> OS : : Abort ( ) ; <nl> } <nl> - void * addr = mmap ( OS : : GetRandomMmapAddr ( ) , size , PROT_READ | PROT_EXEC , <nl> - MAP_PRIVATE , fileno ( f ) , 0 ) ; <nl> + void * addr = <nl> + mmap ( hint , size , PROT_READ | PROT_EXEC , MAP_PRIVATE , fileno ( f ) , 0 ) ; <nl> DCHECK_NE ( MAP_FAILED , addr ) ; <nl> OS : : Free ( addr , size ) ; <nl> fclose ( f ) ; <nl> mmm a / src / base / platform / platform - macos . cc <nl> ppp b / src / base / platform / platform - macos . cc <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return result ; <nl> } <nl> <nl> - void OS : : SignalCodeMovingGC ( ) { } <nl> + void OS : : SignalCodeMovingGC ( void * hint ) { } <nl> <nl> TimezoneCache * OS : : CreateTimezoneCache ( ) { <nl> return new PosixDefaultTimezoneCache ( ) ; <nl> mmm a / src / base / platform / platform - openbsd . cc <nl> ppp b / src / base / platform / platform - openbsd . cc <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return result ; <nl> } <nl> <nl> - <nl> - void OS : : SignalCodeMovingGC ( ) { <nl> + void OS : : SignalCodeMovingGC ( void * hint ) { <nl> / / Support for ll_prof . py . <nl> / / <nl> / / The Linux profiler built into the kernel logs all mmap ' s with <nl> void OS : : SignalCodeMovingGC ( ) { <nl> OS : : PrintError ( " Failed to open % s \ n " , OS : : GetGCFakeMMapFile ( ) ) ; <nl> OS : : Abort ( ) ; <nl> } <nl> - void * addr = mmap ( NULL , size , PROT_READ | PROT_EXEC , MAP_PRIVATE , <nl> - fileno ( f ) , 0 ) ; <nl> - DCHECK ( addr ! = MAP_FAILED ) ; <nl> + void * addr = <nl> + mmap ( hint , size , PROT_READ | PROT_EXEC , MAP_PRIVATE , fileno ( f ) , 0 ) ; <nl> + DCHECK_NE ( MAP_FAILED , addr ) ; <nl> OS : : Free ( addr , size ) ; <nl> fclose ( f ) ; <nl> } <nl> mmm a / src / base / platform / platform - posix . cc <nl> ppp b / src / base / platform / platform - posix . cc <nl> void OS : : Unprotect ( void * address , const size_t size ) { <nl> # endif <nl> } <nl> <nl> - static LazyInstance < RandomNumberGenerator > : : type <nl> - platform_random_number_generator = LAZY_INSTANCE_INITIALIZER ; <nl> - <nl> - <nl> - void OS : : Initialize ( int64_t random_seed , bool hard_abort , <nl> - const char * const gc_fake_mmap ) { <nl> - if ( random_seed ) { <nl> - platform_random_number_generator . Pointer ( ) - > SetSeed ( random_seed ) ; <nl> - } <nl> + void OS : : Initialize ( bool hard_abort , const char * const gc_fake_mmap ) { <nl> g_hard_abort = hard_abort ; <nl> g_gc_fake_mmap = gc_fake_mmap ; <nl> } <nl> const char * OS : : GetGCFakeMMapFile ( ) { <nl> } <nl> <nl> <nl> - void * OS : : GetRandomMmapAddr ( ) { <nl> - # if defined ( ADDRESS_SANITIZER ) | | defined ( MEMORY_SANITIZER ) | | \ <nl> - defined ( THREAD_SANITIZER ) <nl> - / / Dynamic tools do not support custom mmap addresses . <nl> - return NULL ; <nl> - # endif <nl> - uintptr_t raw_addr ; <nl> - platform_random_number_generator . Pointer ( ) - > NextBytes ( & raw_addr , <nl> - sizeof ( raw_addr ) ) ; <nl> - # if V8_TARGET_ARCH_X64 <nl> - / / Currently available CPUs have 48 bits of virtual addressing . Truncate <nl> - / / the hint address to 46 bits to give the kernel a fighting chance of <nl> - / / fulfilling our placement request . <nl> - raw_addr & = V8_UINT64_C ( 0x3ffffffff000 ) ; <nl> - # elif V8_TARGET_ARCH_PPC64 <nl> - # if V8_OS_AIX <nl> - / / AIX : 64 bits of virtual addressing , but we limit address range to : <nl> - / / a ) minimize Segment Lookaside Buffer ( SLB ) misses and <nl> - raw_addr & = V8_UINT64_C ( 0x3ffff000 ) ; <nl> - / / Use extra address space to isolate the mmap regions . <nl> - raw_addr + = V8_UINT64_C ( 0x400000000000 ) ; <nl> - # elif V8_TARGET_BIG_ENDIAN <nl> - / / Big - endian Linux : 44 bits of virtual addressing . <nl> - raw_addr & = V8_UINT64_C ( 0x03fffffff000 ) ; <nl> - # else <nl> - / / Little - endian Linux : 48 bits of virtual addressing . <nl> - raw_addr & = V8_UINT64_C ( 0x3ffffffff000 ) ; <nl> - # endif <nl> - # elif V8_TARGET_ARCH_S390X <nl> - / / Linux on Z uses bits 22 - 32 for Region Indexing , which translates to 42 bits <nl> - / / of virtual addressing . Truncate to 40 bits to allow kernel chance to <nl> - / / fulfill request . <nl> - raw_addr & = V8_UINT64_C ( 0xfffffff000 ) ; <nl> - # elif V8_TARGET_ARCH_S390 <nl> - / / 31 bits of virtual addressing . Truncate to 29 bits to allow kernel chance <nl> - / / to fulfill request . <nl> - raw_addr & = 0x1ffff000 ; <nl> - # else <nl> - raw_addr & = 0x3ffff000 ; <nl> - <nl> - # ifdef __sun <nl> - / / For our Solaris / illumos mmap hint , we pick a random address in the bottom <nl> - / / half of the top half of the address space ( that is , the third quarter ) . <nl> - / / Because we do not MAP_FIXED , this will be treated only as a hint - - the <nl> - / / system will not fail to mmap ( ) because something else happens to already <nl> - / / be mapped at our random address . We deliberately set the hint high enough <nl> - / / to get well above the system ' s break ( that is , the heap ) ; Solaris and <nl> - / / illumos will try the hint and if that fails allocate as if there were <nl> - / / no hint at all . The high hint prevents the break from getting hemmed in <nl> - / / at low values , ceding half of the address space to the system heap . <nl> - raw_addr + = 0x80000000 ; <nl> - # elif V8_OS_AIX <nl> - / / The range 0x30000000 - 0xD0000000 is available on AIX ; <nl> - / / choose the upper range . <nl> - raw_addr + = 0x90000000 ; <nl> - # else <nl> - / / The range 0x20000000 - 0x60000000 is relatively unpopulated across a <nl> - / / variety of ASLR modes ( PAE kernel , NX compat mode , etc ) and on macos <nl> - / / 10 . 6 and 10 . 7 . <nl> - raw_addr + = 0x20000000 ; <nl> - # endif <nl> - # endif <nl> - return reinterpret_cast < void * > ( raw_addr ) ; <nl> - } <nl> - <nl> - <nl> size_t OS : : AllocateAlignment ( ) { <nl> return static_cast < size_t > ( sysconf ( _SC_PAGESIZE ) ) ; <nl> } <nl> class PosixMemoryMappedFile final : public OS : : MemoryMappedFile { <nl> <nl> <nl> / / static <nl> - OS : : MemoryMappedFile * OS : : MemoryMappedFile : : open ( const char * name ) { <nl> + OS : : MemoryMappedFile * OS : : MemoryMappedFile : : open ( const char * name , void * hint ) { <nl> if ( FILE * file = fopen ( name , " r + " ) ) { <nl> if ( fseek ( file , 0 , SEEK_END ) = = 0 ) { <nl> long size = ftell ( file ) ; / / NOLINT ( runtime / int ) <nl> if ( size > = 0 ) { <nl> - void * const memory = <nl> - mmap ( OS : : GetRandomMmapAddr ( ) , size , PROT_READ | PROT_WRITE , <nl> - MAP_SHARED , fileno ( file ) , 0 ) ; <nl> + void * const memory = mmap ( hint , size , PROT_READ | PROT_WRITE , <nl> + MAP_SHARED , fileno ( file ) , 0 ) ; <nl> if ( memory ! = MAP_FAILED ) { <nl> return new PosixMemoryMappedFile ( file , memory , size ) ; <nl> } <nl> OS : : MemoryMappedFile * OS : : MemoryMappedFile : : open ( const char * name ) { <nl> <nl> <nl> / / static <nl> - OS : : MemoryMappedFile * OS : : MemoryMappedFile : : create ( const char * name , <nl> + OS : : MemoryMappedFile * OS : : MemoryMappedFile : : create ( const char * name , void * hint , <nl> size_t size , void * initial ) { <nl> if ( FILE * file = fopen ( name , " w + " ) ) { <nl> size_t result = fwrite ( initial , 1 , size , file ) ; <nl> if ( result = = size & & ! ferror ( file ) ) { <nl> - void * memory = mmap ( OS : : GetRandomMmapAddr ( ) , result , <nl> - PROT_READ | PROT_WRITE , MAP_SHARED , fileno ( file ) , 0 ) ; <nl> + void * memory = mmap ( hint , result , PROT_READ | PROT_WRITE , MAP_SHARED , <nl> + fileno ( file ) , 0 ) ; <nl> if ( memory ! = MAP_FAILED ) { <nl> return new PosixMemoryMappedFile ( file , memory , result ) ; <nl> } <nl> mmm a / src / base / platform / platform - qnx . cc <nl> ppp b / src / base / platform / platform - qnx . cc <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return result ; <nl> } <nl> <nl> - void OS : : SignalCodeMovingGC ( ) { } <nl> + void OS : : SignalCodeMovingGC ( void * hint ) { } <nl> <nl> } / / namespace base <nl> } / / namespace v8 <nl> mmm a / src / base / platform / platform - solaris . cc <nl> ppp b / src / base / platform / platform - solaris . cc <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return std : : vector < SharedLibraryAddress > ( ) ; <nl> } <nl> <nl> - void OS : : SignalCodeMovingGC ( ) { } <nl> + void OS : : SignalCodeMovingGC ( void * hint ) { } <nl> <nl> } / / namespace base <nl> } / / namespace v8 <nl> mmm a / src / base / platform / platform - win32 . cc <nl> ppp b / src / base / platform / platform - win32 . cc <nl> <nl> # include " src / base / win32 - headers . h " <nl> <nl> # include " src / base / bits . h " <nl> - # include " src / base / lazy - instance . h " <nl> # include " src / base / macros . h " <nl> # include " src / base / platform / platform . h " <nl> # include " src / base / platform / time . h " <nl> # include " src / base / timezone - cache . h " <nl> - # include " src / base / utils / random - number - generator . h " <nl> <nl> / / Extra functions for MinGW . Most of these are the _s functions which are in <nl> / / the Microsoft Visual Studio C + + CRT . <nl> size_t OS : : AllocateAlignment ( ) { <nl> return allocate_alignment ; <nl> } <nl> <nl> - <nl> - static LazyInstance < RandomNumberGenerator > : : type <nl> - platform_random_number_generator = LAZY_INSTANCE_INITIALIZER ; <nl> - <nl> - <nl> - void OS : : Initialize ( int64_t random_seed , bool hard_abort , <nl> - const char * const gc_fake_mmap ) { <nl> - if ( random_seed ) { <nl> - platform_random_number_generator . Pointer ( ) - > SetSeed ( random_seed ) ; <nl> - } <nl> + void OS : : Initialize ( bool hard_abort , const char * const gc_fake_mmap ) { <nl> g_hard_abort = hard_abort ; <nl> } <nl> <nl> - <nl> - void * OS : : GetRandomMmapAddr ( ) { <nl> - / / The address range used to randomize RWX allocations in OS : : Allocate <nl> - / / Try not to map pages into the default range that windows loads DLLs <nl> - / / Use a multiple of 64k to prevent committing unused memory . <nl> - / / Note : This does not guarantee RWX regions will be within the <nl> - / / range kAllocationRandomAddressMin to kAllocationRandomAddressMax <nl> - # ifdef V8_HOST_ARCH_64_BIT <nl> - static const uintptr_t kAllocationRandomAddressMin = 0x0000000080000000 ; <nl> - static const uintptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000 ; <nl> - # else <nl> - static const uintptr_t kAllocationRandomAddressMin = 0x04000000 ; <nl> - static const uintptr_t kAllocationRandomAddressMax = 0x3FFF0000 ; <nl> - # endif <nl> - uintptr_t address ; <nl> - platform_random_number_generator . Pointer ( ) - > NextBytes ( & address , <nl> - sizeof ( address ) ) ; <nl> - address < < = kPageSizeBits ; <nl> - address + = kAllocationRandomAddressMin ; <nl> - address & = kAllocationRandomAddressMax ; <nl> - return reinterpret_cast < void * > ( address ) ; <nl> - } <nl> - <nl> namespace { <nl> <nl> static void * RandomizedVirtualAlloc ( size_t size , int action , int protection , <nl> class Win32MemoryMappedFile final : public OS : : MemoryMappedFile { <nl> <nl> <nl> / / static <nl> - OS : : MemoryMappedFile * OS : : MemoryMappedFile : : open ( const char * name ) { <nl> + OS : : MemoryMappedFile * OS : : MemoryMappedFile : : open ( const char * name , void * hint ) { <nl> / / Open a physical file <nl> HANDLE file = CreateFileA ( name , GENERIC_READ | GENERIC_WRITE , <nl> FILE_SHARE_READ | FILE_SHARE_WRITE , NULL , OPEN_EXISTING , 0 , NULL ) ; <nl> OS : : MemoryMappedFile * OS : : MemoryMappedFile : : open ( const char * name ) { <nl> <nl> DWORD size = GetFileSize ( file , NULL ) ; <nl> <nl> - / / Create a file mapping for the physical file <nl> + / / Create a file mapping for the physical file . Ignore hint on Windows . <nl> HANDLE file_mapping = <nl> CreateFileMapping ( file , NULL , PAGE_READWRITE , 0 , size , NULL ) ; <nl> if ( file_mapping = = NULL ) return NULL ; <nl> OS : : MemoryMappedFile * OS : : MemoryMappedFile : : open ( const char * name ) { <nl> <nl> <nl> / / static <nl> - OS : : MemoryMappedFile * OS : : MemoryMappedFile : : create ( const char * name , <nl> + OS : : MemoryMappedFile * OS : : MemoryMappedFile : : create ( const char * name , void * hint , <nl> size_t size , void * initial ) { <nl> / / Open a physical file <nl> HANDLE file = CreateFileA ( name , GENERIC_READ | GENERIC_WRITE , <nl> FILE_SHARE_READ | FILE_SHARE_WRITE , NULL , <nl> OPEN_ALWAYS , 0 , NULL ) ; <nl> if ( file = = NULL ) return NULL ; <nl> - / / Create a file mapping for the physical file <nl> + / / Create a file mapping for the physical file . Ignore hint on Windows . <nl> HANDLE file_mapping = CreateFileMapping ( file , NULL , PAGE_READWRITE , 0 , <nl> static_cast < DWORD > ( size ) , NULL ) ; <nl> if ( file_mapping = = NULL ) return NULL ; <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return LoadSymbols ( process_handle ) ; <nl> } <nl> <nl> - <nl> - void OS : : SignalCodeMovingGC ( ) { <nl> - } <nl> - <nl> - <nl> # else / / __MINGW32__ <nl> std : : vector < OS : : SharedLibraryAddress > OS : : GetSharedLibraryAddresses ( ) { <nl> return std : : vector < OS : : SharedLibraryAddress > ( ) ; <nl> } <nl> - <nl> - <nl> - void OS : : SignalCodeMovingGC ( ) { } <nl> # endif / / __MINGW32__ <nl> <nl> + void OS : : SignalCodeMovingGC ( void * hint ) { } <nl> <nl> int OS : : ActivationFrameAlignment ( ) { <nl> # ifdef _WIN64 <nl> mmm a / src / base / platform / platform . h <nl> ppp b / src / base / platform / platform . h <nl> class TimezoneCache ; <nl> class V8_BASE_EXPORT OS { <nl> public : <nl> / / Initialize the OS class . <nl> - / / - random_seed : Used for the GetRandomMmapAddress ( ) if non - zero . <nl> / / - hard_abort : If true , OS : : Abort ( ) will crash instead of aborting . <nl> / / - gc_fake_mmap : Name of the file for fake gc mmap used in ll_prof . <nl> - static void Initialize ( int64_t random_seed , <nl> - bool hard_abort , <nl> - const char * const gc_fake_mmap ) ; <nl> + static void Initialize ( bool hard_abort , const char * const gc_fake_mmap ) ; <nl> <nl> / / Returns the accumulated user time for thread . This routine <nl> / / can be used for profiling . The implementation should <nl> class V8_BASE_EXPORT OS { <nl> / / Make a region of memory readable and writable . <nl> static void Unprotect ( void * address , const size_t size ) ; <nl> <nl> - / / Generate a random address to be used for hinting mmap ( ) . <nl> - static void * GetRandomMmapAddr ( ) ; <nl> - <nl> / / Get the Alignment guaranteed by Allocate ( ) . <nl> static size_t AllocateAlignment ( ) ; <nl> <nl> class V8_BASE_EXPORT OS { <nl> virtual void * memory ( ) const = 0 ; <nl> virtual size_t size ( ) const = 0 ; <nl> <nl> - static MemoryMappedFile * open ( const char * name ) ; <nl> - static MemoryMappedFile * create ( const char * name , size_t size , <nl> + static MemoryMappedFile * open ( const char * name , void * hint ) ; <nl> + static MemoryMappedFile * create ( const char * name , void * hint , size_t size , <nl> void * initial ) ; <nl> } ; <nl> <nl> class V8_BASE_EXPORT OS { <nl> / / process that a code moving garbage collection starts . Can do <nl> / / nothing , in which case the code objects must not move ( e . g . , by <nl> / / using - - never - compact ) if accurate profiling is desired . <nl> - static void SignalCodeMovingGC ( ) ; <nl> + static void SignalCodeMovingGC ( void * hint ) ; <nl> <nl> / / Support runtime detection of whether the hard float option of the <nl> / / EABI is used . <nl> mmm a / src / d8 . cc <nl> ppp b / src / d8 . cc <nl> Counter * CounterCollection : : GetNextCounter ( ) { <nl> <nl> void Shell : : MapCounters ( v8 : : Isolate * isolate , const char * name ) { <nl> counters_file_ = base : : OS : : MemoryMappedFile : : create ( <nl> - name , sizeof ( CounterCollection ) , & local_counters_ ) ; <nl> + name , nullptr , sizeof ( CounterCollection ) , & local_counters_ ) ; <nl> void * memory = ( counters_file_ = = NULL ) ? <nl> NULL : counters_file_ - > memory ( ) ; <nl> if ( memory = = NULL ) { <nl> mmm a / src / heap / heap . cc <nl> ppp b / src / heap / heap . cc <nl> bool Heap : : SetUp ( ) { <nl> } <nl> <nl> mmap_region_base_ = <nl> - reinterpret_cast < uintptr_t > ( base : : OS : : GetRandomMmapAddr ( ) ) & <nl> + reinterpret_cast < uintptr_t > ( v8 : : internal : : GetRandomMmapAddr ( ) ) & <nl> ~ kMmapRegionMask ; <nl> <nl> / / Set up memory allocator . <nl> mmm a / src / heap / heap . h <nl> ppp b / src / heap / heap . h <nl> class Heap { <nl> void ReportCodeStatistics ( const char * title ) ; <nl> # endif <nl> void * GetRandomMmapAddr ( ) { <nl> - void * result = base : : OS : : GetRandomMmapAddr ( ) ; <nl> + void * result = v8 : : internal : : GetRandomMmapAddr ( ) ; <nl> # if V8_TARGET_ARCH_X64 <nl> # if V8_OS_MACOSX <nl> / / The Darwin kernel [ as of macOS 10 . 12 . 5 ] does not clean up page <nl> class Heap { <nl> / / killed . Confine the hint to a 32 - bit section of the virtual address <nl> / / space . See crbug . com / 700928 . <nl> uintptr_t offset = <nl> - reinterpret_cast < uintptr_t > ( base : : OS : : GetRandomMmapAddr ( ) ) & <nl> + reinterpret_cast < uintptr_t > ( v8 : : internal : : GetRandomMmapAddr ( ) ) & <nl> kMmapRegionMask ; <nl> result = reinterpret_cast < void * > ( mmap_region_base_ + offset ) ; <nl> # endif / / V8_OS_MACOSX <nl> mmm a / src / heap / spaces . cc <nl> ppp b / src / heap / spaces . cc <nl> bool CodeRange : : SetUp ( size_t requested ) { <nl> requested , <nl> Max ( kCodeRangeAreaAlignment , <nl> static_cast < size_t > ( base : : OS : : AllocateAlignment ( ) ) ) , <nl> - base : : OS : : GetRandomMmapAddr ( ) , & reservation ) ) { <nl> + v8 : : internal : : GetRandomMmapAddr ( ) , & reservation ) ) { <nl> return false ; <nl> } <nl> <nl> mmm a / src / log . cc <nl> ppp b / src / log . cc <nl> void Logger : : CodeDisableOptEvent ( AbstractCode * code , <nl> void Logger : : CodeMovingGCEvent ( ) { <nl> if ( ! is_logging_code_events ( ) ) return ; <nl> if ( ! log_ - > IsEnabled ( ) | | ! FLAG_ll_prof ) return ; <nl> - base : : OS : : SignalCodeMovingGC ( ) ; <nl> + base : : OS : : SignalCodeMovingGC ( GetRandomMmapAddr ( ) ) ; <nl> } <nl> <nl> void Logger : : RegExpCodeCreateEvent ( AbstractCode * code , String * source ) { <nl> mmm a / src / v8 . cc <nl> ppp b / src / v8 . cc <nl> void V8 : : InitializeOncePerProcessImpl ( ) { <nl> FLAG_max_semi_space_size = 1 ; <nl> } <nl> <nl> - base : : OS : : Initialize ( FLAG_random_seed , FLAG_hard_abort , FLAG_gc_fake_mmap ) ; <nl> + base : : OS : : Initialize ( FLAG_hard_abort , FLAG_gc_fake_mmap ) ; <nl> <nl> Isolate : : InitializeOncePerProcess ( ) ; <nl> <nl> mmm a / test / cctest / test - allocation . cc <nl> ppp b / test / cctest / test - allocation . cc <nl> size_t GetHugeMemoryAmount ( ) { <nl> static size_t huge_memory = 0 ; <nl> if ( ! huge_memory ) { <nl> for ( int i = 0 ; i < 100 ; i + + ) { <nl> - huge_memory | = bit_cast < size_t > ( v8 : : base : : OS : : GetRandomMmapAddr ( ) ) ; <nl> + huge_memory | = bit_cast < size_t > ( v8 : : internal : : GetRandomMmapAddr ( ) ) ; <nl> } <nl> / / Make it larger than the available address space . <nl> huge_memory * = 2 ; <nl> mmm a / test / cctest / test - platform - linux . cc <nl> ppp b / test / cctest / test - platform - linux . cc <nl> namespace internal { <nl> TEST ( OSReserveMemory ) { <nl> size_t mem_size = 0 ; <nl> void * mem_addr = OS : : ReserveAlignedRegion ( 1 * MB , OS : : AllocateAlignment ( ) , <nl> - OS : : GetRandomMmapAddr ( ) , & mem_size ) ; <nl> + GetRandomMmapAddr ( ) , & mem_size ) ; <nl> CHECK_NE ( 0 , mem_size ) ; <nl> CHECK_NOT_NULL ( mem_addr ) ; <nl> size_t block_size = 4 * KB ; <nl> mmm a / test / cctest / test - platform - win32 . cc <nl> ppp b / test / cctest / test - platform - win32 . cc <nl> namespace internal { <nl> TEST ( OSReserveMemory ) { <nl> size_t mem_size = 0 ; <nl> void * mem_addr = OS : : ReserveAlignedRegion ( 1 * MB , OS : : AllocateAlignment ( ) , <nl> - OS : : GetRandomMmapAddr ( ) , & mem_size ) ; <nl> + GetRandomMmapAddr ( ) , & mem_size ) ; <nl> CHECK_NE ( 0 , mem_size ) ; <nl> CHECK_NOT_NULL ( mem_addr ) ; <nl> size_t block_size = 4 * KB ; <nl> mmm a / test / unittests / heap / heap - unittest . cc <nl> ppp b / test / unittests / heap / heap - unittest . cc <nl> TEST_F ( HeapTest , ASLR ) { <nl> } <nl> if ( hints . size ( ) = = 1 ) { <nl> EXPECT_TRUE ( ( * hints . begin ( ) ) = = nullptr ) ; <nl> - EXPECT_TRUE ( base : : OS : : GetRandomMmapAddr ( ) = = nullptr ) ; <nl> + EXPECT_TRUE ( v8 : : internal : : GetRandomMmapAddr ( ) = = nullptr ) ; <nl> } else { <nl> / / It is unlikely that 1000 random samples will collide to less then 500 <nl> / / values . <nl> | [ Memory ] Move GetRandomMmapAddr from base : : OS platform to v8 : : internal . | v8/v8 | d607f1e72d082c9c4dac4d6359858e20a10f16b6 | 2017-09-22T15:26:18Z |
mmm a / xbmc / peripherals / Peripherals . cpp <nl> ppp b / xbmc / peripherals / Peripherals . cpp <nl> void CPeripherals : : OnDeviceAdded ( const CPeripheralBus & bus , const CPeripheral & p <nl> { <nl> OnDeviceChanged ( ) ; <nl> <nl> + / / ! @ todo Improve device notifications in v18 <nl> + # if 0 <nl> bool bNotify = true ; <nl> <nl> / / don ' t show a notification for devices detected during the initial scan <nl> void CPeripherals : : OnDeviceAdded ( const CPeripheralBus & bus , const CPeripheral & p <nl> <nl> if ( bNotify ) <nl> CGUIDialogKaiToast : : QueueNotification ( CGUIDialogKaiToast : : Info , g_localizeStrings . Get ( 35005 ) , peripheral . DeviceName ( ) ) ; <nl> + # endif <nl> } <nl> <nl> void CPeripherals : : OnDeviceDeleted ( const CPeripheralBus & bus , const CPeripheral & peripheral ) <nl> void CPeripherals : : OnDeviceDeleted ( const CPeripheralBus & bus , const CPeripheral <nl> OnDeviceChanged ( ) ; <nl> <nl> / / ! @ todo Improve device notifications in v18 <nl> - bool bNotify = false ; <nl> + # if 0 <nl> + bool bNotify = true ; <nl> <nl> / / don ' t show a notification for emulated peripherals <nl> if ( peripheral . Type ( ) = = PERIPHERAL_JOYSTICK_EMULATION ) / / ! @ todo Change to peripheral . IsEmulated ( ) <nl> void CPeripherals : : OnDeviceDeleted ( const CPeripheralBus & bus , const CPeripheral <nl> <nl> if ( bNotify ) <nl> CGUIDialogKaiToast : : QueueNotification ( CGUIDialogKaiToast : : Info , g_localizeStrings . Get ( 35006 ) , peripheral . DeviceName ( ) ) ; <nl> + # endif <nl> } <nl> <nl> void CPeripherals : : OnDeviceChanged ( ) <nl> | Hide notifications shown on device connect | xbmc/xbmc | ff1c719c4fc317d89b0121a26654e9e1e7b9cfee | 2016-12-31T21:26:15Z |
mmm a / src / bootstrapper . cc <nl> ppp b / src / bootstrapper . cc <nl> void Genesis : : InitializeGlobal ( Handle < JSGlobalObject > global_object , <nl> Builtins : : kPromisePrototypeCatch , 1 , true ) ; <nl> native_context ( ) - > set_promise_catch ( * promise_catch ) ; <nl> <nl> + SimpleInstallFunction ( isolate_ , prototype , " finally " , <nl> + Builtins : : kPromisePrototypeFinally , 1 , true , <nl> + DONT_ENUM ) ; <nl> + <nl> + { <nl> + Handle < SharedFunctionInfo > info = SimpleCreateSharedFunctionInfo ( <nl> + isolate ( ) , Builtins : : kPromiseThenFinally , <nl> + isolate_ - > factory ( ) - > empty_string ( ) , 1 ) ; <nl> + info - > set_native ( true ) ; <nl> + native_context ( ) - > set_promise_then_finally_shared_fun ( * info ) ; <nl> + } <nl> + <nl> + { <nl> + Handle < SharedFunctionInfo > info = SimpleCreateSharedFunctionInfo ( <nl> + isolate ( ) , Builtins : : kPromiseCatchFinally , <nl> + isolate_ - > factory ( ) - > empty_string ( ) , 1 ) ; <nl> + info - > set_native ( true ) ; <nl> + native_context ( ) - > set_promise_catch_finally_shared_fun ( * info ) ; <nl> + } <nl> + <nl> + { <nl> + Handle < SharedFunctionInfo > info = SimpleCreateSharedFunctionInfo ( <nl> + isolate ( ) , Builtins : : kPromiseValueThunkFinally , <nl> + isolate_ - > factory ( ) - > empty_string ( ) , 0 ) ; <nl> + native_context ( ) - > set_promise_value_thunk_finally_shared_fun ( * info ) ; <nl> + } <nl> + <nl> + { <nl> + Handle < SharedFunctionInfo > info = SimpleCreateSharedFunctionInfo ( <nl> + isolate ( ) , Builtins : : kPromiseThrowerFinally , <nl> + isolate_ - > factory ( ) - > empty_string ( ) , 0 ) ; <nl> + native_context ( ) - > set_promise_thrower_finally_shared_fun ( * info ) ; <nl> + } <nl> + <nl> / / Force the Promise constructor to fast properties , so that we can use the <nl> / / fast paths for various things like <nl> / / <nl> void Genesis : : InitializeGlobal_harmony_string_matchall ( ) { <nl> } <nl> } <nl> <nl> - void Genesis : : InitializeGlobal_harmony_promise_finally ( ) { <nl> - if ( ! FLAG_harmony_promise_finally ) return ; <nl> - <nl> - Handle < JSFunction > constructor ( native_context ( ) - > promise_function ( ) ) ; <nl> - Handle < JSObject > prototype ( JSObject : : cast ( constructor - > instance_prototype ( ) ) ) ; <nl> - SimpleInstallFunction ( isolate ( ) , prototype , " finally " , <nl> - Builtins : : kPromisePrototypeFinally , 1 , true , DONT_ENUM ) ; <nl> - <nl> - / / The promise prototype map has changed because we added a property <nl> - / / to prototype , so we update the saved map . <nl> - Handle < Map > prototype_map ( prototype - > map ( ) ) ; <nl> - Map : : SetShouldBeFastPrototypeMap ( prototype_map , true , isolate ( ) ) ; <nl> - <nl> - { <nl> - Handle < SharedFunctionInfo > info = SimpleCreateSharedFunctionInfo ( <nl> - isolate ( ) , Builtins : : kPromiseThenFinally , factory ( ) - > empty_string ( ) , 1 ) ; <nl> - info - > set_native ( true ) ; <nl> - native_context ( ) - > set_promise_then_finally_shared_fun ( * info ) ; <nl> - } <nl> - <nl> - { <nl> - Handle < SharedFunctionInfo > info = SimpleCreateSharedFunctionInfo ( <nl> - isolate ( ) , Builtins : : kPromiseCatchFinally , factory ( ) - > empty_string ( ) , <nl> - 1 ) ; <nl> - info - > set_native ( true ) ; <nl> - native_context ( ) - > set_promise_catch_finally_shared_fun ( * info ) ; <nl> - } <nl> - <nl> - { <nl> - Handle < SharedFunctionInfo > info = SimpleCreateSharedFunctionInfo ( <nl> - isolate ( ) , Builtins : : kPromiseValueThunkFinally , <nl> - factory ( ) - > empty_string ( ) , 0 ) ; <nl> - native_context ( ) - > set_promise_value_thunk_finally_shared_fun ( * info ) ; <nl> - } <nl> - <nl> - { <nl> - Handle < SharedFunctionInfo > info = SimpleCreateSharedFunctionInfo ( <nl> - isolate ( ) , Builtins : : kPromiseThrowerFinally , factory ( ) - > empty_string ( ) , <nl> - 0 ) ; <nl> - native_context ( ) - > set_promise_thrower_finally_shared_fun ( * info ) ; <nl> - } <nl> - } <nl> - <nl> void Genesis : : InitializeGlobal_harmony_bigint ( ) { <nl> Factory * factory = isolate ( ) - > factory ( ) ; <nl> Handle < JSGlobalObject > global ( native_context ( ) - > global_object ( ) ) ; <nl> mmm a / src / flag - definitions . h <nl> ppp b / src / flag - definitions . h <nl> DEFINE_IMPLICATION ( harmony_class_fields , harmony_private_fields ) <nl> V ( harmony_regexp_named_captures , " harmony regexp named captures " ) \ <nl> V ( harmony_regexp_property , " harmony Unicode regexp property classes " ) \ <nl> V ( harmony_function_tostring , " harmony Function . prototype . toString " ) \ <nl> - V ( harmony_promise_finally , " harmony Promise . prototype . finally " ) \ <nl> V ( harmony_optional_catch_binding , " allow omitting binding in catch blocks " ) \ <nl> V ( harmony_import_meta , " harmony import . meta property " ) \ <nl> V ( harmony_bigint , " harmony arbitrary precision integers " ) \ <nl> mmm a / test / debugger / debug / es8 / promise - finally . js <nl> ppp b / test / debugger / debug / es8 / promise - finally . js <nl> <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 : - - harmony - promise - finally <nl> - <nl> Debug = debug . Debug <nl> <nl> var exception = null ; <nl> mmm a / test / mjsunit / harmony / promise - prototype - finally . js <nl> ppp b / test / mjsunit / harmony / promise - prototype - finally . js <nl> <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 : - - harmony - promise - finally - - allow - natives - syntax <nl> + / / Flags : - - allow - natives - syntax <nl> <nl> assertThrows ( ( ) = > Promise . prototype . finally . call ( 5 ) , TypeError ) ; <nl> <nl> mmm a / test / test262 / testcfg . py <nl> ppp b / test / test262 / testcfg . py <nl> <nl> ' BigInt ' : ' - - harmony - bigint ' , <nl> ' regexp - named - groups ' : ' - - harmony - regexp - named - captures ' , <nl> ' regexp - unicode - property - escapes ' : ' - - harmony - regexp - property ' , <nl> - ' Promise . prototype . finally ' : ' - - harmony - promise - finally ' , <nl> ' class - fields - public ' : ' - - harmony - public - fields ' , <nl> ' optional - catch - binding ' : ' - - harmony - optional - catch - binding ' , <nl> ' class - fields - private ' : ' - - harmony - private - fields ' , <nl> | Remove always - true - - harmony - promise - finally runtime flag | v8/v8 | 51c9123e60f9a5a8c60f30bd0ace1f0059ee4819 | 2018-06-04T20:15:52Z |
mmm a / trunk / research / librtmp / srs_bandwidth_check . c <nl> ppp b / trunk / research / librtmp / srs_bandwidth_check . c <nl> int main ( int argc , char * * argv ) <nl> <nl> rtmp = srs_rtmp_create2 ( argv [ 1 ] ) ; <nl> <nl> - srs_trace ( " bandwidth check / test url : % s " , argv [ 1 ] ) ; <nl> + srs_lib_trace ( " bandwidth check / test url : % s " , argv [ 1 ] ) ; <nl> <nl> if ( ( ret = srs_simple_handshake ( rtmp ) ) ! = 0 ) { <nl> - srs_trace ( " simple handshake failed . " ) ; <nl> + srs_lib_trace ( " simple handshake failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " simple handshake success " ) ; <nl> + srs_lib_trace ( " simple handshake success " ) ; <nl> <nl> if ( ( ret = srs_connect_app2 ( rtmp , <nl> srs_server_ip , srs_server , srs_primary_authors , srs_version , & srs_id , & srs_pid ) ) ! = 0 ) { <nl> - srs_trace ( " connect vhost / app failed . " ) ; <nl> + srs_lib_trace ( " connect vhost / app failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " connect vhost / app success " ) ; <nl> + srs_lib_trace ( " connect vhost / app success " ) ; <nl> <nl> if ( ( ret = srs_bandwidth_check ( rtmp , <nl> & start_time , & end_time , & play_kbps , & publish_kbps , <nl> & play_bytes , & publish_bytes , & play_duration , & publish_duration ) ) ! = 0 <nl> ) { <nl> - srs_trace ( " bandwidth check / test failed . " ) ; <nl> + srs_lib_trace ( " bandwidth check / test failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " bandwidth check / test success " ) ; <nl> + srs_lib_trace ( " bandwidth check / test success " ) ; <nl> <nl> - srs_trace ( " \ n % s , % s \ n " <nl> + srs_lib_trace ( " \ n % s , % s \ n " <nl> " % s , % s , srs_pid = % d , srs_id = % d \ n " <nl> " duration : % dms ( % d + % d ) \ n " <nl> " play : % dkbps \ n " <nl> int main ( int argc , char * * argv ) <nl> ( int ) ( end_time - start_time ) , play_duration , publish_duration , <nl> play_kbps , publish_kbps ) ; <nl> <nl> - srs_trace ( " " ) ; <nl> - srs_trace ( " completed " ) ; <nl> + srs_lib_trace ( " " ) ; <nl> + srs_lib_trace ( " completed " ) ; <nl> <nl> return ret ; <nl> } <nl> mmm a / trunk / research / librtmp / srs_detect_rtmp . c <nl> ppp b / trunk / research / librtmp / srs_detect_rtmp . c <nl> int main ( int argc , char * * argv ) <nl> duration = atoi ( argv [ 2 ] ) ; <nl> timeout = atoi ( argv [ 3 ] ) ; <nl> <nl> - srs_trace ( " rtmp url : % s " , rtmp_url ) ; <nl> - srs_trace ( " duration : % ds , timeout : % ds " , duration , timeout ) ; <nl> + srs_lib_trace ( " rtmp url : % s " , rtmp_url ) ; <nl> + srs_lib_trace ( " duration : % ds , timeout : % ds " , duration , timeout ) ; <nl> <nl> if ( duration < = 0 | | timeout < = 0 ) { <nl> - srs_trace ( " duration and timeout must be positive . " ) ; <nl> + srs_lib_trace ( " duration and timeout must be positive . " ) ; <nl> exit ( - 2 ) ; <nl> } <nl> <nl> rtmp = srs_rtmp_create ( rtmp_url ) ; <nl> <nl> if ( ( ret = __srs_dns_resolve ( rtmp ) ) ! = 0 ) { <nl> - srs_trace ( " dns resolve failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " dns resolve failed . ret = % d " , ret ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " dns resolve success " ) ; <nl> + srs_lib_trace ( " dns resolve success " ) ; <nl> time_dns_resolve = srs_get_time_ms ( ) ; <nl> <nl> if ( ( ret = __srs_connect_server ( rtmp ) ) ! = 0 ) { <nl> - srs_trace ( " socket connect failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " socket connect failed . ret = % d " , ret ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " socket connect success " ) ; <nl> + srs_lib_trace ( " socket connect success " ) ; <nl> time_socket_connect = srs_get_time_ms ( ) ; <nl> <nl> if ( ( ret = __srs_do_simple_handshake ( rtmp ) ) ! = 0 ) { <nl> - srs_trace ( " do simple handshake failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " do simple handshake failed . ret = % d " , ret ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " do simple handshake success " ) ; <nl> + srs_lib_trace ( " do simple handshake success " ) ; <nl> <nl> if ( ( ret = srs_connect_app ( rtmp ) ) ! = 0 ) { <nl> - srs_trace ( " connect vhost / app failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " connect vhost / app failed . ret = % d " , ret ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " connect vhost / app success " ) ; <nl> + srs_lib_trace ( " connect vhost / app success " ) ; <nl> <nl> if ( ( ret = srs_play_stream ( rtmp ) ) ! = 0 ) { <nl> - srs_trace ( " play stream failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " play stream failed . ret = % d " , ret ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " play stream success " ) ; <nl> + srs_lib_trace ( " play stream success " ) ; <nl> time_play_stream = srs_get_time_ms ( ) ; <nl> <nl> for ( ; ; ) { <nl> if ( ( ret = srs_read_packet ( rtmp , & type , & timestamp , & data , & size ) ) ! = 0 ) { <nl> - srs_trace ( " read packet failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " read packet failed . ret = % d " , ret ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " got packet : type = % s , time = % d , size = % d " , <nl> + srs_lib_trace ( " got packet : type = % s , time = % d , size = % d " , <nl> srs_type2string ( type ) , timestamp , size ) ; <nl> <nl> if ( SRS_RTMP_TYPE_VIDEO = = type | | SRS_RTMP_TYPE_AUDIO = = type ) { <nl> int main ( int argc , char * * argv ) <nl> free ( data ) ; <nl> <nl> if ( srs_get_time_ms ( ) - time_startup > timeout * 1000 ) { <nl> - srs_trace ( " timeout , terminate . " ) ; <nl> + srs_lib_trace ( " timeout , terminate . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> <nl> if ( ( timestamp - basetime ) > duration * 1000 ) { <nl> - srs_trace ( " duration exceed , terminate . " ) ; <nl> + srs_lib_trace ( " duration exceed , terminate . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> } <nl> int main ( int argc , char * * argv ) <nl> " \ " remark2 \ " : \ " if code is not 0 , user must ignore all data \ " " <nl> ) ; <nl> <nl> - srs_trace ( " " ) ; <nl> - srs_trace ( " completed " ) ; <nl> + srs_lib_trace ( " " ) ; <nl> + srs_lib_trace ( " completed " ) ; <nl> <nl> return ret ; <nl> } <nl> mmm a / trunk / research / librtmp / srs_flv_injecter . c <nl> ppp b / trunk / research / librtmp / srs_flv_injecter . c <nl> int main ( int argc , char * * argv ) <nl> tmp_file = ( char * ) malloc ( tmp_file_size ) ; <nl> snprintf ( tmp_file , tmp_file_size , " % s . tmp " , out_flv_file ) ; <nl> <nl> - srs_trace ( " input : % s " , in_flv_file ) ; <nl> - srs_trace ( " output : % s " , out_flv_file ) ; <nl> - srs_trace ( " tmp_file : % s " , tmp_file ) ; <nl> + srs_lib_trace ( " input : % s " , in_flv_file ) ; <nl> + srs_lib_trace ( " output : % s " , out_flv_file ) ; <nl> + srs_lib_trace ( " tmp_file : % s " , tmp_file ) ; <nl> <nl> ret = process ( in_flv_file , tmp_file , & ic , & oc ) ; <nl> <nl> int main ( int argc , char * * argv ) <nl> unlink ( tmp_file ) ; <nl> if ( ret = = ERROR_INJECTED ) { <nl> ret = 0 ; <nl> - srs_trace ( " file already injected . " ) ; <nl> + srs_lib_trace ( " file already injected . " ) ; <nl> } else { <nl> - srs_trace ( " error , remove tmp file . " ) ; <nl> + srs_lib_trace ( " error , remove tmp file . " ) ; <nl> } <nl> } else { <nl> rename ( tmp_file , out_flv_file ) ; <nl> - srs_trace ( " completed , rename to % s " , out_flv_file ) ; <nl> + srs_lib_trace ( " completed , rename to % s " , out_flv_file ) ; <nl> } <nl> <nl> free ( tmp_file ) ; <nl> int process ( const char * in_flv_file , const char * out_flv_file , srs_flv_t * pic , s <nl> <nl> if ( ( ic = srs_flv_open_read ( in_flv_file ) ) = = NULL ) { <nl> ret = 2 ; <nl> - srs_trace ( " open input flv file failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " open input flv file failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> * pic = ic ; <nl> <nl> if ( ( oc = srs_flv_open_write ( out_flv_file ) ) = = NULL ) { <nl> ret = 2 ; <nl> - srs_trace ( " open output flv file failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " open output flv file failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> * poc = oc ; <nl> int parse_metadata ( char * data , int size , srs_amf0_t * pname , srs_amf0_t * pdata ) <nl> * pname = srs_amf0_parse ( data , size , & nparsed ) ; <nl> <nl> if ( * pname = = NULL | | nparsed > = size ) { <nl> - srs_trace ( " invalid amf0 name data . " ) ; <nl> + srs_lib_trace ( " invalid amf0 name data . " ) ; <nl> return - 1 ; <nl> } <nl> <nl> * pdata = srs_amf0_parse ( data + nparsed , size - nparsed , & nparsed ) ; <nl> if ( * pdata = = NULL | | nparsed > size ) { <nl> - srs_trace ( " invalid amf0 value data " ) ; <nl> + srs_lib_trace ( " invalid amf0 value data " ) ; <nl> return - 1 ; <nl> } <nl> <nl> int build_keyframes ( srs_flv_t ic , srs_amf0_t * pname , srs_amf0_t * pdata , srs_amf0 <nl> return ret ; <nl> } <nl> <nl> - srs_trace ( " build keyframe infos from flv " ) ; <nl> + srs_lib_trace ( " build keyframe infos from flv " ) ; <nl> for ( ; ; ) { <nl> offset = srs_flv_tellg ( ic ) ; <nl> <nl> / / tag header <nl> if ( ( ret = srs_flv_read_tag_header ( ic , & type , & size , & timestamp ) ) ! = 0 ) { <nl> if ( srs_flv_is_eof ( ret ) ) { <nl> - srs_trace ( " parse completed . " ) ; <nl> + srs_lib_trace ( " parse completed . " ) ; <nl> return 0 ; <nl> } <nl> - srs_trace ( " flv get packet failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " flv get packet failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> <nl> if ( size < = 0 ) { <nl> - srs_trace ( " invalid size = % d " , size ) ; <nl> + srs_lib_trace ( " invalid size = % d " , size ) ; <nl> return ret ; <nl> } <nl> <nl> int do_inject_flv ( srs_flv_t ic , srs_flv_t oc , srs_amf0_t amf0_name , srs_amf0_t a <nl> free ( data ) ; <nl> } <nl> <nl> - srs_trace ( " build keyframe infos from flv " ) ; <nl> + srs_lib_trace ( " build keyframe infos from flv " ) ; <nl> for ( ; ; ) { <nl> / / tag header <nl> if ( ( ret = srs_flv_read_tag_header ( ic , & type , & size , & timestamp ) ) ! = 0 ) { <nl> if ( srs_flv_is_eof ( ret ) ) { <nl> - srs_trace ( " parse completed . " ) ; <nl> + srs_lib_trace ( " parse completed . " ) ; <nl> return 0 ; <nl> } <nl> - srs_trace ( " flv get packet failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " flv get packet failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> <nl> if ( size < = 0 ) { <nl> - srs_trace ( " invalid size = % d " , size ) ; <nl> + srs_lib_trace ( " invalid size = % d " , size ) ; <nl> break ; <nl> } <nl> <nl> mmm a / trunk / research / librtmp / srs_flv_parser . c <nl> ppp b / trunk / research / librtmp / srs_flv_parser . c <nl> int main ( int argc , char * * argv ) <nl> } <nl> <nl> in_flv_file = argv [ 1 ] ; <nl> - srs_trace ( " input : % s " , in_flv_file ) ; <nl> + srs_lib_trace ( " input : % s " , in_flv_file ) ; <nl> <nl> if ( ( flv = srs_flv_open_read ( in_flv_file ) ) = = NULL ) { <nl> ret = 2 ; <nl> - srs_trace ( " open flv file failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " open flv file failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> <nl> int parse_script_data ( u_int32_t timestamp , char * data , int size , int64_t offset ) <nl> / / amf0 <nl> amf0_name = srs_amf0_parse ( data , size , & nparsed ) ; <nl> if ( amf0_name = = NULL | | nparsed > = size ) { <nl> - srs_trace ( " invalid amf0 name data . " ) ; <nl> + srs_lib_trace ( " invalid amf0 name data . " ) ; <nl> return - 1 ; <nl> } <nl> amf0_data = srs_amf0_parse ( data + nparsed , size - nparsed , & nparsed ) ; <nl> <nl> - srs_trace ( " packet type = % s , time = % d , size = % d , data - size = % d , \ n " <nl> + srs_lib_trace ( " packet type = % s , time = % d , size = % d , data - size = % d , \ n " <nl> " offset = % d \ n [ + 00 , + 15 ] % s \ n [ - 15 , EOF ] % s \ n % s % s " , <nl> srs_type2string ( SRS_RTMP_TYPE_SCRIPT ) , timestamp , size + FLV_HEADER_SIZE , size , <nl> ( int ) offset , hbuf , tbuf , <nl> int parse_audio_data ( u_int32_t timestamp , char * data , int size , int64_t offset ) <nl> / / bytes <nl> parse_bytes ( data , size , hbuf , sizeof ( hbuf ) , tbuf , sizeof ( tbuf ) , 16 ) ; <nl> <nl> - srs_trace ( " packet type = % s , time = % d , size = % d , data - size = % d , \ n " <nl> + srs_lib_trace ( " packet type = % s , time = % d , size = % d , data - size = % d , \ n " <nl> " offset = % d \ n [ + 00 , + 15 ] % s \ n [ - 15 , EOF ] % s \ n " , <nl> srs_type2string ( SRS_RTMP_TYPE_AUDIO ) , timestamp , size + FLV_HEADER_SIZE , size , <nl> ( int ) offset , hbuf , tbuf ) ; <nl> int parse_video_data ( u_int32_t timestamp , char * data , int size , int64_t offset ) <nl> / / bytes <nl> parse_bytes ( data , size , hbuf , sizeof ( hbuf ) , tbuf , sizeof ( tbuf ) , 16 ) ; <nl> <nl> - srs_trace ( " packet type = % s , time = % d , size = % d , data - size = % d , \ n " <nl> + srs_lib_trace ( " packet type = % s , time = % d , size = % d , data - size = % d , \ n " <nl> " offset = % d \ n [ + 00 , + 15 ] % s \ n [ - 15 , EOF ] % s \ n " , <nl> srs_type2string ( SRS_RTMP_TYPE_VIDEO ) , timestamp , size + FLV_HEADER_SIZE , size , <nl> ( int ) offset , hbuf , tbuf ) ; <nl> int parse_flv ( srs_flv_t flv ) <nl> return ret ; <nl> } <nl> <nl> - srs_trace ( " start parse flv " ) ; <nl> + srs_lib_trace ( " start parse flv " ) ; <nl> for ( ; ; ) { <nl> offset = srs_flv_tellg ( flv ) ; <nl> <nl> / / tag header <nl> if ( ( ret = srs_flv_read_tag_header ( flv , & type , & size , & timestamp ) ) ! = 0 ) { <nl> if ( srs_flv_is_eof ( ret ) ) { <nl> - srs_trace ( " parse completed . " ) ; <nl> + srs_lib_trace ( " parse completed . " ) ; <nl> return 0 ; <nl> } <nl> - srs_trace ( " flv get packet failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " flv get packet failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> <nl> if ( size < = 0 ) { <nl> - srs_trace ( " invalid size = % d " , size ) ; <nl> + srs_lib_trace ( " invalid size = % d " , size ) ; <nl> break ; <nl> } <nl> <nl> mmm a / trunk / research / librtmp / srs_h264_raw_publish . c <nl> ppp b / trunk / research / librtmp / srs_h264_raw_publish . c <nl> int read_h264_frame ( char * data , int size , char * * pp , int * pnb_start_code , int fp <nl> / / we search the h264 frame from the buffer which cached the h264 data . <nl> / / please get h264 raw data from device , it always a encoded frame . <nl> if ( ! srs_h264_startswith_annexb ( p , size - ( p - data ) , pnb_start_code ) ) { <nl> - srs_trace ( " h264 raw data invalid . " ) ; <nl> + srs_lib_trace ( " h264 raw data invalid . " ) ; <nl> return - 1 ; <nl> } <nl> <nl> int read_h264_frame ( char * data , int size , char * * pp , int * pnb_start_code , int fp <nl> * pp = p ; <nl> * frame_size = p - * frame ; <nl> if ( * frame_size < = 0 ) { <nl> - srs_trace ( " h264 raw data invalid . " ) ; <nl> + srs_lib_trace ( " h264 raw data invalid . " ) ; <nl> return - 1 ; <nl> } <nl> <nl> int main ( int argc , char * * argv ) <nl> <nl> const char * raw_file = argv [ 1 ] ; <nl> const char * rtmp_url = argv [ 2 ] ; <nl> - srs_trace ( " raw_file = % s , rtmp_url = % s " , raw_file , rtmp_url ) ; <nl> + srs_lib_trace ( " raw_file = % s , rtmp_url = % s " , raw_file , rtmp_url ) ; <nl> <nl> / / open file <nl> int raw_fd = open ( raw_file , O_RDONLY ) ; <nl> if ( raw_fd < 0 ) { <nl> - srs_trace ( " open h264 raw file % s failed . " , raw_fd ) ; <nl> + srs_lib_trace ( " open h264 raw file % s failed . " , raw_fd ) ; <nl> goto rtmp_destroy ; <nl> } <nl> <nl> off_t file_size = lseek ( raw_fd , 0 , SEEK_END ) ; <nl> if ( file_size < = 0 ) { <nl> - srs_trace ( " h264 raw file % s empty . " , raw_file ) ; <nl> + srs_lib_trace ( " h264 raw file % s empty . " , raw_file ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " read entirely h264 raw file , size = % dKB " , ( int ) ( file_size / 1024 ) ) ; <nl> + srs_lib_trace ( " read entirely h264 raw file , size = % dKB " , ( int ) ( file_size / 1024 ) ) ; <nl> <nl> char * h264_raw = ( char * ) malloc ( file_size ) ; <nl> if ( ! h264_raw ) { <nl> - srs_trace ( " alloc raw buffer failed for file % s . " , raw_file ) ; <nl> + srs_lib_trace ( " alloc raw buffer failed for file % s . " , raw_file ) ; <nl> goto rtmp_destroy ; <nl> } <nl> <nl> lseek ( raw_fd , 0 , SEEK_SET ) ; <nl> ssize_t nb_read = 0 ; <nl> if ( ( nb_read = read ( raw_fd , h264_raw , file_size ) ) ! = file_size ) { <nl> - srs_trace ( " buffer % s failed , expect = % dKB , actual = % dKB . " , <nl> + srs_lib_trace ( " buffer % s failed , expect = % dKB , actual = % dKB . " , <nl> raw_file , ( int ) ( file_size / 1024 ) , ( int ) ( nb_read / 1024 ) ) ; <nl> goto rtmp_destroy ; <nl> } <nl> int main ( int argc , char * * argv ) <nl> srs_rtmp_t rtmp = srs_rtmp_create ( rtmp_url ) ; <nl> <nl> if ( srs_simple_handshake ( rtmp ) ! = 0 ) { <nl> - srs_trace ( " simple handshake failed . " ) ; <nl> + srs_lib_trace ( " simple handshake failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " simple handshake success " ) ; <nl> + srs_lib_trace ( " simple handshake success " ) ; <nl> <nl> if ( srs_connect_app ( rtmp ) ! = 0 ) { <nl> - srs_trace ( " connect vhost / app failed . " ) ; <nl> + srs_lib_trace ( " connect vhost / app failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " connect vhost / app success " ) ; <nl> + srs_lib_trace ( " connect vhost / app success " ) ; <nl> <nl> if ( srs_publish_stream ( rtmp ) ! = 0 ) { <nl> - srs_trace ( " publish stream failed . " ) ; <nl> + srs_lib_trace ( " publish stream failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " publish stream success " ) ; <nl> + srs_lib_trace ( " publish stream success " ) ; <nl> <nl> u_int32_t dts = 0 ; <nl> u_int32_t pts = 0 ; <nl> int main ( int argc , char * * argv ) <nl> if ( read_h264_frame ( h264_raw , file_size , & p , & nb_start_code , fps , <nl> & data , & size , & dts , & pts ) < 0 <nl> ) { <nl> - srs_trace ( " read a frame from file buffer failed . " ) ; <nl> + srs_lib_trace ( " read a frame from file buffer failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> <nl> / / send out the h264 packet over RTMP <nl> if ( srs_write_h264_raw_frames ( rtmp , data , size , dts , pts ) ! = 0 ) { <nl> - srs_trace ( " send h264 raw data failed . " ) ; <nl> + srs_lib_trace ( " send h264 raw data failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> <nl> / / 5bits , 7 . 3 . 1 NAL unit syntax , <nl> / / H . 264 - AVC - ISO_IEC_14496 - 10 . pdf , page 44 . <nl> u_int8_t nut = ( char ) data [ nb_start_code ] & 0x1f ; <nl> - srs_trace ( " sent packet : type = % s , time = % d , size = % d , fps = % d , b [ % d ] = % # x ( % s ) " , <nl> + srs_lib_trace ( " sent packet : type = % s , time = % d , size = % d , fps = % d , b [ % d ] = % # x ( % s ) " , <nl> srs_type2string ( SRS_RTMP_TYPE_VIDEO ) , dts , size , fps , nb_start_code , ( char ) data [ nb_start_code ] , <nl> ( nut = = 7 ? " SPS " : ( nut = = 8 ? " PPS " : ( nut = = 5 ? " I " : ( nut = = 1 ? " P " : " Unknown " ) ) ) ) ) ; <nl> <nl> / / @ remark , when use encode device , it not need to sleep . <nl> usleep ( 1000 / fps * 1000 ) ; <nl> } <nl> - srs_trace ( " h264 raw data completed " ) ; <nl> + srs_lib_trace ( " h264 raw data completed " ) ; <nl> <nl> rtmp_destroy : <nl> srs_rtmp_destroy ( rtmp ) ; <nl> mmm a / trunk / research / librtmp / srs_ingest_flv . c <nl> ppp b / trunk / research / librtmp / srs_ingest_flv . c <nl> int main ( int argc , char * * argv ) <nl> } <nl> } <nl> <nl> - srs_trace ( " input : % s " , in_flv_file ) ; <nl> - srs_trace ( " output : % s " , out_rtmp_url ) ; <nl> + srs_lib_trace ( " input : % s " , in_flv_file ) ; <nl> + srs_lib_trace ( " output : % s " , out_rtmp_url ) ; <nl> <nl> if ( ( flv = srs_flv_open_read ( in_flv_file ) ) = = NULL ) { <nl> ret = 2 ; <nl> - srs_trace ( " open flv file failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " open flv file failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> <nl> ortmp = srs_rtmp_create ( out_rtmp_url ) ; <nl> <nl> ret = proxy ( flv , ortmp ) ; <nl> - srs_trace ( " ingest flv to RTMP completed " ) ; <nl> + srs_lib_trace ( " ingest flv to RTMP completed " ) ; <nl> <nl> srs_rtmp_destroy ( ortmp ) ; <nl> srs_flv_close ( flv ) ; <nl> int do_proxy ( srs_flv_t flv , srs_rtmp_t ortmp , int64_t re , u_int32_t * ptimestamp ) <nl> int size ; <nl> char * data = NULL ; <nl> <nl> - srs_trace ( " start ingest flv to RTMP stream " ) ; <nl> + srs_lib_trace ( " start ingest flv to RTMP stream " ) ; <nl> for ( ; ; ) { <nl> / / tag header <nl> if ( ( ret = srs_flv_read_tag_header ( flv , & type , & size , ptimestamp ) ) ! = 0 ) { <nl> if ( srs_flv_is_eof ( ret ) ) { <nl> - srs_trace ( " parse completed . " ) ; <nl> + srs_lib_trace ( " parse completed . " ) ; <nl> return 0 ; <nl> } <nl> - srs_trace ( " flv get packet failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " flv get packet failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> <nl> if ( size < = 0 ) { <nl> - srs_trace ( " invalid size = % d " , size ) ; <nl> + srs_lib_trace ( " invalid size = % d " , size ) ; <nl> break ; <nl> } <nl> <nl> int do_proxy ( srs_flv_t flv , srs_rtmp_t ortmp , int64_t re , u_int32_t * ptimestamp ) <nl> } <nl> <nl> if ( ( ret = srs_write_packet ( ortmp , type , * ptimestamp , data , size ) ) ! = 0 ) { <nl> - srs_trace ( " irtmp get packet failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " irtmp get packet failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_verbose ( " ortmp sent packet : type = % s , time = % d , size = % d " , <nl> + srs_lib_verbose ( " ortmp sent packet : type = % s , time = % d , size = % d " , <nl> srs_type2string ( type ) , * ptimestamp , size ) ; <nl> <nl> re_update ( re , * ptimestamp ) ; <nl> int connect_oc ( srs_rtmp_t ortmp ) <nl> int ret = 0 ; <nl> <nl> if ( ( ret = srs_simple_handshake ( ortmp ) ) ! = 0 ) { <nl> - srs_trace ( " ortmp simple handshake failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " ortmp simple handshake failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_trace ( " ortmp simple handshake success " ) ; <nl> + srs_lib_trace ( " ortmp simple handshake success " ) ; <nl> <nl> if ( ( ret = srs_connect_app ( ortmp ) ) ! = 0 ) { <nl> - srs_trace ( " ortmp connect vhost / app failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " ortmp connect vhost / app failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_trace ( " ortmp connect vhost / app success " ) ; <nl> + srs_lib_trace ( " ortmp connect vhost / app success " ) ; <nl> <nl> if ( ( ret = srs_publish_stream ( ortmp ) ) ! = 0 ) { <nl> - srs_trace ( " ortmp publish stream failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " ortmp publish stream failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_trace ( " ortmp publish stream success " ) ; <nl> + srs_lib_trace ( " ortmp publish stream success " ) ; <nl> <nl> return ret ; <nl> } <nl> int64_t re_create ( ) <nl> <nl> / / use the starttime to get the deviation <nl> int64_t deviation = re - tools_main_entrance_startup_time ; <nl> - srs_trace ( " deviation is % d ms , pulse is % d ms " , ( int ) ( deviation ) , ( int ) ( RE_PULSE_MS ) ) ; <nl> + srs_lib_trace ( " deviation is % d ms , pulse is % d ms " , ( int ) ( deviation ) , ( int ) ( RE_PULSE_MS ) ) ; <nl> <nl> / / so , we adjust time to max ( 0 , deviation ) <nl> / / because the last pulse , we already sleeped <nl> int adjust = ( int ) ( deviation ) ; <nl> if ( adjust > 0 ) { <nl> - srs_trace ( " adjust re time for % d ms " , adjust ) ; <nl> + srs_lib_trace ( " adjust re time for % d ms " , adjust ) ; <nl> re - = adjust ; <nl> } else { <nl> - srs_trace ( " no need to adjust re time " ) ; <nl> + srs_lib_trace ( " no need to adjust re time " ) ; <nl> } <nl> <nl> return re ; <nl> void re_cleanup ( int64_t re , u_int32_t time ) <nl> int64_t now = srs_get_time_ms ( ) ; <nl> int64_t diff = time - ( now - re ) ; <nl> if ( diff > 0 ) { <nl> - srs_trace ( " re_cleanup sleep for the last pulse for % d ms " , ( int ) diff ) ; <nl> + srs_lib_trace ( " re_cleanup sleep for the last pulse for % d ms " , ( int ) diff ) ; <nl> usleep ( diff * 1000 ) ; <nl> } <nl> } <nl> mmm a / trunk / research / librtmp / srs_ingest_rtmp . c <nl> ppp b / trunk / research / librtmp / srs_ingest_rtmp . c <nl> int main ( int argc , char * * argv ) <nl> } <nl> } <nl> <nl> - srs_trace ( " input : % s " , in_rtmp_url ) ; <nl> - srs_trace ( " output : % s " , out_rtmp_url ) ; <nl> + srs_lib_trace ( " input : % s " , in_rtmp_url ) ; <nl> + srs_lib_trace ( " output : % s " , out_rtmp_url ) ; <nl> <nl> irtmp = srs_rtmp_create ( in_rtmp_url ) ; <nl> ortmp = srs_rtmp_create ( out_rtmp_url ) ; <nl> <nl> ret = proxy ( irtmp , ortmp ) ; <nl> - srs_trace ( " proxy completed " ) ; <nl> + srs_lib_trace ( " proxy completed " ) ; <nl> <nl> srs_rtmp_destroy ( irtmp ) ; <nl> srs_rtmp_destroy ( ortmp ) ; <nl> int proxy ( srs_rtmp_t irtmp , srs_rtmp_t ortmp ) <nl> return ret ; <nl> } <nl> <nl> - srs_trace ( " start proxy RTMP stream " ) ; <nl> + srs_lib_trace ( " start proxy RTMP stream " ) ; <nl> for ( ; ; ) { <nl> if ( ( ret = srs_read_packet ( irtmp , & type , & timestamp , & data , & size ) ) ! = 0 ) { <nl> - srs_trace ( " irtmp get packet failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " irtmp get packet failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_verbose ( " irtmp got packet : type = % s , time = % d , size = % d " , <nl> + srs_lib_verbose ( " irtmp got packet : type = % s , time = % d , size = % d " , <nl> srs_type2string ( type ) , timestamp , size ) ; <nl> <nl> if ( ( ret = srs_write_packet ( ortmp , type , timestamp , data , size ) ) ! = 0 ) { <nl> - srs_trace ( " irtmp get packet failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " irtmp get packet failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_verbose ( " ortmp sent packet : type = % s , time = % d , size = % d " , <nl> + srs_lib_verbose ( " ortmp sent packet : type = % s , time = % d , size = % d " , <nl> srs_type2string ( type ) , timestamp , size ) ; <nl> } <nl> <nl> int connect_ic ( srs_rtmp_t irtmp ) <nl> int ret = 0 ; <nl> <nl> if ( ( ret = srs_simple_handshake ( irtmp ) ) ! = 0 ) { <nl> - srs_trace ( " irtmp simple handshake failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " irtmp simple handshake failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_trace ( " irtmp simple handshake success " ) ; <nl> + srs_lib_trace ( " irtmp simple handshake success " ) ; <nl> <nl> if ( ( ret = srs_connect_app ( irtmp ) ) ! = 0 ) { <nl> - srs_trace ( " irtmp connect vhost / app failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " irtmp connect vhost / app failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_trace ( " irtmp connect vhost / app success " ) ; <nl> + srs_lib_trace ( " irtmp connect vhost / app success " ) ; <nl> <nl> if ( ( ret = srs_play_stream ( irtmp ) ) ! = 0 ) { <nl> - srs_trace ( " irtmp play stream failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " irtmp play stream failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_trace ( " irtmp play stream success " ) ; <nl> + srs_lib_trace ( " irtmp play stream success " ) ; <nl> <nl> return ret ; <nl> } <nl> int connect_oc ( srs_rtmp_t ortmp ) <nl> int ret = 0 ; <nl> <nl> if ( ( ret = srs_simple_handshake ( ortmp ) ) ! = 0 ) { <nl> - srs_trace ( " ortmp simple handshake failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " ortmp simple handshake failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_trace ( " ortmp simple handshake success " ) ; <nl> + srs_lib_trace ( " ortmp simple handshake success " ) ; <nl> <nl> if ( ( ret = srs_connect_app ( ortmp ) ) ! = 0 ) { <nl> - srs_trace ( " ortmp connect vhost / app failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " ortmp connect vhost / app failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_trace ( " ortmp connect vhost / app success " ) ; <nl> + srs_lib_trace ( " ortmp connect vhost / app success " ) ; <nl> <nl> if ( ( ret = srs_publish_stream ( ortmp ) ) ! = 0 ) { <nl> - srs_trace ( " ortmp publish stream failed . ret = % d " , ret ) ; <nl> + srs_lib_trace ( " ortmp publish stream failed . ret = % d " , ret ) ; <nl> return ret ; <nl> } <nl> - srs_trace ( " ortmp publish stream success " ) ; <nl> + srs_lib_trace ( " ortmp publish stream success " ) ; <nl> <nl> return ret ; <nl> } <nl> mmm a / trunk / research / librtmp / srs_play . c <nl> ppp b / trunk / research / librtmp / srs_play . c <nl> int main ( int argc , char * * argv ) <nl> exit ( - 1 ) ; <nl> } <nl> <nl> - srs_trace ( " rtmp url : % s " , argv [ 1 ] ) ; <nl> + srs_lib_trace ( " rtmp url : % s " , argv [ 1 ] ) ; <nl> srs_rtmp_t rtmp = srs_rtmp_create ( argv [ 1 ] ) ; <nl> <nl> if ( srs_simple_handshake ( rtmp ) ! = 0 ) { <nl> - srs_trace ( " simple handshake failed . " ) ; <nl> + srs_lib_trace ( " simple handshake failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " simple handshake success " ) ; <nl> + srs_lib_trace ( " simple handshake success " ) ; <nl> <nl> if ( srs_connect_app ( rtmp ) ! = 0 ) { <nl> - srs_trace ( " connect vhost / app failed . " ) ; <nl> + srs_lib_trace ( " connect vhost / app failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " connect vhost / app success " ) ; <nl> + srs_lib_trace ( " connect vhost / app success " ) ; <nl> <nl> if ( srs_play_stream ( rtmp ) ! = 0 ) { <nl> - srs_trace ( " play stream failed . " ) ; <nl> + srs_lib_trace ( " play stream failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " play stream success " ) ; <nl> + srs_lib_trace ( " play stream success " ) ; <nl> <nl> for ( ; ; ) { <nl> int type , size ; <nl> int main ( int argc , char * * argv ) <nl> if ( srs_read_packet ( rtmp , & type , & timestamp , & data , & size ) ! = 0 ) { <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " got packet : type = % s , time = % d , size = % d " , <nl> + srs_lib_trace ( " got packet : type = % s , time = % d , size = % d " , <nl> srs_type2string ( type ) , timestamp , size ) ; <nl> <nl> free ( data ) ; <nl> mmm a / trunk / research / librtmp / srs_publish . c <nl> ppp b / trunk / research / librtmp / srs_publish . c <nl> int main ( int argc , char * * argv ) <nl> <nl> / / warn it . <nl> / / @ see : https : / / github . com / winlinvip / simple - rtmp - server / issues / 126 <nl> - srs_trace ( " \ 033 [ 33m % s \ 033 [ 0m " , <nl> + srs_lib_trace ( " \ 033 [ 33m % s \ 033 [ 0m " , <nl> " [ warning ] it ' s only a sample to use librtmp . " <nl> " please never use it to publish and test forward / transcode / edge / HLS whatever . " <nl> " you should refer to this tool to use the srs - librtmp to publish the real media stream . " <nl> " read about : https : / / github . com / winlinvip / simple - rtmp - server / issues / 126 " ) ; <nl> - srs_trace ( " rtmp url : % s " , argv [ 1 ] ) ; <nl> + srs_lib_trace ( " rtmp url : % s " , argv [ 1 ] ) ; <nl> srs_rtmp_t rtmp = srs_rtmp_create ( argv [ 1 ] ) ; <nl> <nl> if ( srs_simple_handshake ( rtmp ) ! = 0 ) { <nl> - srs_trace ( " simple handshake failed . " ) ; <nl> + srs_lib_trace ( " simple handshake failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " simple handshake success " ) ; <nl> + srs_lib_trace ( " simple handshake success " ) ; <nl> <nl> if ( srs_connect_app ( rtmp ) ! = 0 ) { <nl> - srs_trace ( " connect vhost / app failed . " ) ; <nl> + srs_lib_trace ( " connect vhost / app failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " connect vhost / app success " ) ; <nl> + srs_lib_trace ( " connect vhost / app success " ) ; <nl> <nl> if ( srs_publish_stream ( rtmp ) ! = 0 ) { <nl> - srs_trace ( " publish stream failed . " ) ; <nl> + srs_lib_trace ( " publish stream failed . " ) ; <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " publish stream success " ) ; <nl> + srs_lib_trace ( " publish stream success " ) ; <nl> <nl> u_int32_t timestamp = 0 ; <nl> for ( ; ; ) { <nl> int main ( int argc , char * * argv ) <nl> if ( srs_write_packet ( rtmp , type , timestamp , data , size ) ! = 0 ) { <nl> goto rtmp_destroy ; <nl> } <nl> - srs_trace ( " sent packet : type = % s , time = % d , size = % d " , <nl> + srs_lib_trace ( " sent packet : type = % s , time = % d , size = % d " , <nl> srs_type2string ( type ) , timestamp , size ) ; <nl> <nl> usleep ( 40 * 1000 ) ; <nl> mmm a / trunk / src / core / srs_core . hpp <nl> ppp b / trunk / src / core / srs_core . hpp <nl> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . <nl> / / current release version <nl> # define VERSION_MAJOR 2 <nl> # define VERSION_MINOR 0 <nl> - # define VERSION_REVISION 11 <nl> + # define VERSION_REVISION 12 <nl> / / server info . <nl> # define RTMP_SIG_SRS_KEY " SRS " <nl> # define RTMP_SIG_SRS_ROLE " origin / edge server " <nl> mmm a / trunk / src / libs / srs_librtmp . hpp <nl> ppp b / trunk / src / libs / srs_librtmp . hpp <nl> extern int64_t srs_get_nrecv_bytes ( srs_rtmp_t rtmp ) ; <nl> <nl> / / log to console , for use srs - librtmp application . <nl> extern const char * srs_format_time ( ) ; <nl> - # define srs_trace ( msg , . . . ) printf ( " [ % s ] " , srs_format_time ( ) ) ; printf ( msg , # # __VA_ARGS__ ) ; printf ( " \ n " ) <nl> - # define srs_verbose ( msg , . . . ) printf ( " [ % s ] " , srs_format_time ( ) ) ; printf ( msg , # # __VA_ARGS__ ) ; printf ( " \ n " ) <nl> + # define srs_lib_trace ( msg , . . . ) printf ( " [ % s ] " , srs_format_time ( ) ) ; printf ( msg , # # __VA_ARGS__ ) ; printf ( " \ n " ) <nl> + # define srs_lib_verbose ( msg , . . . ) printf ( " [ % s ] " , srs_format_time ( ) ) ; printf ( msg , # # __VA_ARGS__ ) ; printf ( " \ n " ) <nl> <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> | rename the confict macro to srs_lib_trace | ossrs/srs | 606fc13a030930052fabd64573b9a9efb819d5d5 | 2014-11-08T10:37:15Z |
mmm a / caffe2 / CMakeLists . txt <nl> ppp b / caffe2 / CMakeLists . txt <nl> if ( NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE ) <nl> $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / ir_iostream . cpp <nl> $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / iter_visitor . cpp <nl> $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / kernel . cpp <nl> + $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / kernel_cache . cpp <nl> $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / manager . cpp <nl> $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / mutator . cpp <nl> + $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / lower_loops . cpp <nl> + $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / lower_utils . cpp <nl> $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / lower2device . cpp <nl> $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / parser . cpp <nl> $ { TORCH_SRC_DIR } / csrc / jit / codegen / cuda / partition . cpp <nl> mmm a / test / cpp / jit / test_gpu . cpp <nl> ppp b / test / cpp / jit / test_gpu . cpp <nl> <nl> # include < torch / csrc / jit / codegen / cuda / kernel . h > <nl> # include < torch / csrc / jit / codegen / cuda / lower2device . h > <nl> # include < torch / csrc / jit / codegen / cuda / mutator . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> # include < torch / csrc / jit / codegen / cuda / tensor_meta . h > <nl> # include < torch / csrc / jit / codegen / cuda / transform_replay . h > <nl> <nl> using namespace torch : : jit : : fuser ; <nl> TensorView * makeDummyTensor ( int nDims ) { <nl> std : : vector < IterDomain * > dom ; <nl> for ( int i = 0 ; i < nDims ; i + + ) <nl> - dom . push_back ( new IterDomain ( new Int ( ) ) ) ; <nl> + dom . push_back ( new IterDomain ( new Int ( 0 ) , new Int ( ) ) ) ; <nl> <nl> return new TensorView ( new TensorDomain ( dom ) , DataType : : Float ) ; <nl> } <nl> void testGPU_FusionTVSplit ( ) { <nl> <nl> tv = tv - > split ( 2 , 2 ) ; <nl> TORCH_CHECK ( tv - > nDims ( ) = = 4 ) ; <nl> - Expr * outer = tv - > axis ( 2 ) - > size ( ) - > getOrigin ( ) ; <nl> + Expr * outer = tv - > axis ( 2 ) - > extent ( ) - > getOrigin ( ) ; <nl> <nl> TORCH_CHECK ( <nl> outer - > getExprType ( ) . value ( ) = = ExprType : : BinaryOp & & <nl> static_cast < BinaryOp * > ( outer ) - > getBinaryOpType ( ) = = <nl> BinaryOpType : : CeilDiv & & <nl> static_cast < BinaryOp * > ( outer ) - > lhs ( ) - > sameAs ( <nl> - tv - > getRootDomain ( ) - > axis ( 2 ) - > size ( ) ) & & <nl> + tv - > getRootDomain ( ) - > axis ( 2 ) - > extent ( ) ) & & <nl> static_cast < Int * > ( static_cast < BinaryOp * > ( outer ) - > rhs ( ) ) <nl> - > sameAs ( new Int ( 2 ) ) ) ; <nl> <nl> IterDomain * inner = static_cast < IterDomain * > ( tv - > axis ( 3 ) ) ; <nl> TORCH_CHECK ( <nl> - inner - > size ( ) - > isScalar ( ) & & <nl> - static_cast < Int * > ( inner - > size ( ) ) - > isConst ( ) & & <nl> - static_cast < Int * > ( inner - > size ( ) ) - > value ( ) . value ( ) = = 2 ) ; <nl> + inner - > extent ( ) - > isScalar ( ) & & <nl> + static_cast < Int * > ( inner - > extent ( ) ) - > isConst ( ) & & <nl> + static_cast < Int * > ( inner - > extent ( ) ) - > value ( ) . value ( ) = = 2 ) ; <nl> } <nl> <nl> void testGPU_FusionTVMerge ( ) { <nl> void testGPU_FusionTVMerge ( ) { <nl> TensorView * tv = makeDummyTensor ( 3 ) ; <nl> <nl> tv = tv - > merge ( 1 ) ; <nl> - Expr * axisOp = tv - > axis ( 1 ) - > size ( ) - > getOrigin ( ) ; <nl> + Expr * axisOp = tv - > axis ( 1 ) - > extent ( ) - > getOrigin ( ) ; <nl> <nl> TORCH_CHECK ( <nl> tv - > nDims ( ) = = 2 & & axisOp - > getExprType ( ) = = ExprType : : BinaryOp & & <nl> static_cast < BinaryOp * > ( axisOp ) - > getBinaryOpType ( ) = = BinaryOpType : : Mul & & <nl> static_cast < BinaryOp * > ( axisOp ) - > lhs ( ) = = <nl> - tv - > getRootDomain ( ) - > axis ( 1 ) - > size ( ) & & <nl> + tv - > getRootDomain ( ) - > axis ( 1 ) - > extent ( ) & & <nl> static_cast < BinaryOp * > ( axisOp ) - > rhs ( ) = = <nl> - tv - > getRootDomain ( ) - > axis ( 2 ) - > size ( ) ) ; <nl> + tv - > getRootDomain ( ) - > axis ( 2 ) - > extent ( ) ) ; <nl> } <nl> <nl> void testGPU_FusionTVReorder ( ) { <nl> void testGPU_FusionReplaceAll ( ) { <nl> void testGPU_FusionParser ( ) { <nl> auto g = std : : make_shared < Graph > ( ) ; <nl> const auto graph0_string = R " IR ( <nl> - graph ( % 0 : Float ( 2 , 3 , 4 ) , <nl> - % 1 : Float ( 2 , 3 , 4 ) ) : <nl> - % c0 : Float ( 2 , 3 , 4 ) = aten : : mul ( % 0 , % 1 ) <nl> - % d0 : Float ( 2 , 3 , 4 ) = aten : : mul ( % c0 , % 0 ) <nl> + graph ( % 0 : Float ( 2 ) , <nl> + % 1 : Float ( 2 ) ) : <nl> + % c0 : Float ( 2 ) = aten : : mul ( % 0 , % 1 ) <nl> + % d0 : Float ( 2 ) = aten : : mul ( % c0 , % 0 ) <nl> return ( % d0 ) ) IR " ; <nl> torch : : jit : : parseIR ( graph0_string , g . get ( ) ) ; <nl> <nl> void testGPU_FusionParser ( ) { <nl> < < " return ( a + b - 1 ) / b ; \ n " <nl> < < " } \ n " <nl> < < " \ n " <nl> - < < " __global__ void CUDAGeneratedKernel ( Tensor < float > T4 , Tensor < float > T5 , Tensor < float > T6 ) { \ n " <nl> - < < " float T7 [ 1 ] ; \ n " <nl> - < < " if ( ( ( ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T5 . size [ 2 ] ) / T5 . size [ 1 ] ) < T5 . size [ 0 ] ) & & ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T5 . size [ 2 ] ) % T5 . size [ 1 ] ) < T5 . size [ 1 ] ) ) & & ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) % T5 . size [ 2 ] ) < T5 . size [ 2 ] ) ) ) { \ n " <nl> - < < " T7 [ 0 ] \ n " <nl> - < < " = T4 [ ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T4 . size [ 2 ] ) / T4 . size [ 1 ] ) * T4 . stride [ 0 ] ) + ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T4 . size [ 2 ] ) % T4 . size [ 1 ] ) * T4 . stride [ 1 ] ) + ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) % T4 . size [ 2 ] ) * T4 . stride [ 2 ] ) ] \ n " <nl> - < < " * T5 [ ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T5 . size [ 2 ] ) / T5 . size [ 1 ] ) * T5 . stride [ 0 ] ) + ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T5 . size [ 2 ] ) % T5 . size [ 1 ] ) * T5 . stride [ 1 ] ) + ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) % T5 . size [ 2 ] ) * T5 . stride [ 2 ] ) ] ; \ n " <nl> + < < " __global__ void CUDAGeneratedKernel ( Tensor < float , 1 > T0 , Tensor < float , 1 > T1 , Tensor < float , 1 > T3 ) { \ n " <nl> + < < " float T2 [ 4 ] ; \ n " <nl> + < < " if ( ( ( ( ( ( blockIdx . x * 4 ) + ( 4 - 1 ) ) * 128 ) + threadIdx . x ) < T1 . size [ 0 ] ) ) { \ n " <nl> + < < " for ( size_t i64 = 0 ; i64 < 4 ; + + i64 ) { \ n " <nl> + < < " T2 [ i64 ] \ n " <nl> + < < " = T0 [ ( ( ( ( ( blockIdx . x * 4 ) + i64 ) * 128 ) + threadIdx . x ) * T0 . stride [ 0 ] ) ] \ n " <nl> + < < " * T1 [ ( ( ( ( ( blockIdx . x * 4 ) + i64 ) * 128 ) + threadIdx . x ) * T1 . stride [ 0 ] ) ] ; \ n " <nl> + < < " } \ n " <nl> + < < " } else { \ n " <nl> + < < " for ( size_t i64 = 0 ; i64 < 4 ; + + i64 ) { \ n " <nl> + < < " if ( ( ( ( ( ( blockIdx . x * 4 ) + i64 ) * 128 ) + threadIdx . x ) < T1 . size [ 0 ] ) ) { \ n " <nl> + < < " T2 [ i64 ] \ n " <nl> + < < " = T0 [ ( ( ( ( ( blockIdx . x * 4 ) + i64 ) * 128 ) + threadIdx . x ) * T0 . stride [ 0 ] ) ] \ n " <nl> + < < " * T1 [ ( ( ( ( ( blockIdx . x * 4 ) + i64 ) * 128 ) + threadIdx . x ) * T1 . stride [ 0 ] ) ] ; \ n " <nl> + < < " } \ n " <nl> + < < " } \ n " <nl> < < " } \ n " <nl> - < < " if ( ( ( ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T6 . size [ 2 ] ) / T6 . size [ 1 ] ) < T6 . size [ 0 ] ) & & ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T6 . size [ 2 ] ) % T6 . size [ 1 ] ) < T6 . size [ 1 ] ) ) & & ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) % T6 . size [ 2 ] ) < T6 . size [ 2 ] ) ) ) { \ n " <nl> - < < " T6 [ ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T6 . size [ 2 ] ) / T6 . size [ 1 ] ) * T6 . stride [ 0 ] ) + ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T6 . size [ 2 ] ) % T6 . size [ 1 ] ) * T6 . stride [ 1 ] ) + ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) % T6 . size [ 2 ] ) * T6 . stride [ 2 ] ) ] \ n " <nl> - < < " = T7 [ 0 ] \ n " <nl> - < < " * T4 [ ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T4 . size [ 2 ] ) / T4 . size [ 1 ] ) * T4 . stride [ 0 ] ) + ( ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) / T4 . size [ 2 ] ) % T4 . size [ 1 ] ) * T4 . stride [ 1 ] ) + ( ( ( ( blockIdx . x * 128 ) + threadIdx . x ) % T4 . size [ 2 ] ) * T4 . stride [ 2 ] ) ] ; \ n " <nl> + < < " if ( ( ( ( ( ( blockIdx . x * 4 ) + ( 4 - 1 ) ) * 128 ) + threadIdx . x ) < T3 . size [ 0 ] ) ) { \ n " <nl> + < < " for ( size_t i65 = 0 ; i65 < 4 ; + + i65 ) { \ n " <nl> + < < " T3 [ ( ( ( ( ( blockIdx . x * 4 ) + i65 ) * 128 ) + threadIdx . x ) * T3 . stride [ 0 ] ) ] \ n " <nl> + < < " = T2 [ i65 ] \ n " <nl> + < < " * T0 [ ( ( ( ( ( blockIdx . x * 4 ) + i65 ) * 128 ) + threadIdx . x ) * T0 . stride [ 0 ] ) ] ; \ n " <nl> + < < " } \ n " <nl> + < < " } else { \ n " <nl> + < < " for ( size_t i65 = 0 ; i65 < 4 ; + + i65 ) { \ n " <nl> + < < " if ( ( ( ( ( ( blockIdx . x * 4 ) + i65 ) * 128 ) + threadIdx . x ) < T3 . size [ 0 ] ) ) { \ n " <nl> + < < " T3 [ ( ( ( ( ( blockIdx . x * 4 ) + i65 ) * 128 ) + threadIdx . x ) * T3 . stride [ 0 ] ) ] \ n " <nl> + < < " = T2 [ i65 ] \ n " <nl> + < < " * T0 [ ( ( ( ( ( blockIdx . x * 4 ) + i65 ) * 128 ) + threadIdx . x ) * T0 . stride [ 0 ] ) ] ; \ n " <nl> + < < " } \ n " <nl> + < < " } \ n " <nl> < < " } \ n " <nl> < < " } \ n " ; <nl> <nl> void testGPU_FusionCodeGen ( ) { <nl> fusion . addOutput ( tv2 ) ; <nl> <nl> tv0 - > computeAt ( tv2 , - 1 ) ; <nl> - / * <nl> - std : : stringstream ref ; <nl> - ref <nl> - < < " __device__ int ceilDiv ( const int a , const int b ) { \ n " <nl> - < < " return ( a + b - 1 ) / b ; \ n " <nl> - < < " } \ n " <nl> - < < " \ n " <nl> - < < " __global__ void CUDAGeneratedKernel ( Tensor < float > T3 ) { \ n " <nl> - < < " for ( size_t i49 { 0 } ; i49 < i38 ; + + i49 ) { \ n " <nl> - < < " for ( size_t i50 { 0 } ; i50 < i37 ; + + i50 ) { \ n " <nl> - < < " for ( size_t i51 { 0 } ; i51 < 2 ; + + i51 ) { \ n " <nl> - < < " for ( size_t i52 { 0 } ; i52 < i41 ; + + i52 ) { \ n " <nl> - < < " float T5 [ 1 ] ; \ n " <nl> - < < " if ( ( ( ( ( ( i50 * 4 ) + ( i49 / T3 . size [ 1 ] ) ) < T3 . size [ 0 ] <nl> - ) & & ( ( i49 % T3 . size [ 1 ] ) < T3 . size [ 1 ] ) ) & & ( ( ( i52 * 2 ) + i51 ) < <nl> - T3 . size [ 2 ] ) ) ) { \ n " <nl> - < < " T5 [ 0 ] \ n " <nl> - < < " = float ( 0 ) \ n " <nl> - < < " + float ( 1 ) ; \ n " <nl> - < < " } \ n " <nl> - < < " float T4 [ 1 ] ; \ n " <nl> - < < " if ( ( ( ( ( ( i50 * 4 ) + ( i49 / T3 . size [ 1 ] ) ) < T3 . size [ 0 ] <nl> - ) & & ( ( i49 % T3 . size [ 1 ] ) < T3 . size [ 1 ] ) ) & & ( ( ( i52 * 2 ) + i51 ) < <nl> - T3 . size [ 2 ] ) ) ) { \ n " <nl> - < < " T4 [ 0 ] \ n " <nl> - < < " = T5 [ 0 ] \ n " <nl> - < < " + float ( 2 ) ; \ n " <nl> - < < " } \ n " <nl> - < < " if ( ( ( ( ( ( i50 * 4 ) + ( i49 / T3 . size [ 1 ] ) ) < T3 . size [ 0 ] <nl> - ) & & ( ( i49 % T3 . size [ 1 ] ) < T3 . size [ 1 ] ) ) & & ( ( ( i52 * 2 ) + i51 ) < <nl> - T3 . size [ 2 ] ) ) ) { \ n " <nl> - < < " T3 [ ( ( i50 * 4 ) + ( i49 / T3 . size [ 1 ] ) ) + ( i49 % <nl> - T3 . size [ 1 ] ) + ( ( i52 * 2 ) + i51 ) ] \ n " <nl> - < < " = T4 [ 0 ] \ n " <nl> - < < " + float ( 3 ) ; \ n " <nl> - < < " } \ n " <nl> - < < " } \ n " <nl> - < < " } \ n " <nl> - < < " } \ n " <nl> - < < " } \ n " <nl> - < < " } \ n " <nl> - ; <nl> - <nl> - GPULower gpulw ( & fusion ) ; <nl> - std : : stringstream cdg ; <nl> - gpulw . printKernel ( cdg ) ; <nl> - <nl> - if ( ref . str ( ) . size ( ) ! = cdg . str ( ) . size ( ) | | <nl> - ref . str ( ) . compare ( cdg . str ( ) ) ! = 0 ) { <nl> - std : : cerr <nl> - < < " Codegen mismatch , codegen possibly changed , or is incorrect . " <nl> - < < " \ n = = = = = = = = = REF = = = = = = = = = \ n " <nl> - < < ref . str ( ) < < " \ n = = = = = = = = = RESULT = = = = = = = = = = \ n " <nl> - < < cdg . str ( ) < < " \ n = = = = = = = = = = = = = = = = = " < < std : : endl ; <nl> - TORCH_CHECK ( false ) ; <nl> - } <nl> - * / <nl> + <nl> + std : : stringstream ref ; <nl> + ref < < " __device__ int ceilDiv ( const int a , const int b ) { \ n " <nl> + < < " return ( a + b - 1 ) / b ; \ n " <nl> + < < " } \ n " <nl> + < < " \ n " <nl> + < < " __global__ void CUDAGeneratedKernel ( Tensor < float , 3 > T2 ) { \ n " <nl> + < < " for ( size_t i82 = 0 ; i82 < ( 4 * T2 . size [ 1 ] ) ; + + i82 ) { \ n " <nl> + < < " for ( size_t i83 = 0 ; i83 < ( ceilDiv ( T2 . size [ 0 ] , 4 ) ) ; + + i83 ) { \ n " <nl> + < < " for ( size_t i84 = 0 ; i84 < 2 ; + + i84 ) { \ n " <nl> + < < " for ( size_t i85 = 0 ; i85 < ( ceilDiv ( T2 . size [ 2 ] , 2 ) ) ; + + i85 ) { \ n " <nl> + < < " float T0 [ 1 ] ; \ n " <nl> + < < " if ( ( ( ( ( ( i83 * 4 ) + ( i82 / T2 . size [ 1 ] ) ) < T2 . size [ 0 ] ) & & ( ( i82 % T2 . size [ 1 ] ) < T2 . size [ 1 ] ) ) & & ( ( ( i85 * 2 ) + i84 ) < T2 . size [ 2 ] ) ) ) { \ n " <nl> + < < " T0 [ 0 ] \ n " <nl> + < < " = float ( 0 ) \ n " <nl> + < < " + float ( 1 ) ; \ n " <nl> + < < " } \ n " <nl> + < < " float T1 [ 1 ] ; \ n " <nl> + < < " if ( ( ( ( ( ( i83 * 4 ) + ( i82 / T2 . size [ 1 ] ) ) < T2 . size [ 0 ] ) & & ( ( i82 % T2 . size [ 1 ] ) < T2 . size [ 1 ] ) ) & & ( ( ( i85 * 2 ) + i84 ) < T2 . size [ 2 ] ) ) ) { \ n " <nl> + < < " T1 [ 0 ] \ n " <nl> + < < " = T0 [ 0 ] \ n " <nl> + < < " + float ( 2 ) ; \ n " <nl> + < < " } \ n " <nl> + < < " if ( ( ( ( ( ( i83 * 4 ) + ( i82 / T2 . size [ 1 ] ) ) < T2 . size [ 0 ] ) & & ( ( i82 % T2 . size [ 1 ] ) < T2 . size [ 1 ] ) ) & & ( ( ( i85 * 2 ) + i84 ) < T2 . size [ 2 ] ) ) ) { \ n " <nl> + < < " T2 [ ( ( ( i83 * 4 ) + ( i82 / T2 . size [ 1 ] ) ) * T2 . stride [ 0 ] ) + ( ( i82 % T2 . size [ 1 ] ) * T2 . stride [ 1 ] ) + ( ( ( i85 * 2 ) + i84 ) * T2 . stride [ 2 ] ) ] \ n " <nl> + < < " = T1 [ 0 ] \ n " <nl> + < < " + float ( 3 ) ; \ n " <nl> + < < " } \ n " <nl> + < < " } \ n " <nl> + < < " } \ n " <nl> + < < " } \ n " <nl> + < < " } \ n " <nl> + < < " } \ n " ; <nl> + <nl> + GPULower gpulw ( & fusion ) ; <nl> + std : : stringstream cdg ; <nl> + gpulw . printKernel ( cdg ) ; <nl> + <nl> + if ( ref . str ( ) . size ( ) ! = cdg . str ( ) . size ( ) | | <nl> + ref . str ( ) . compare ( cdg . str ( ) ) ! = 0 ) { <nl> + std : : cerr <nl> + < < " Codegen mismatch , codegen possibly changed , or is incorrect . " <nl> + < < " \ n = = = = = = = = = REF = = = = = = = = = \ n " <nl> + < < ref . str ( ) < < " \ n = = = = = = = = = RESULT = = = = = = = = = = \ n " <nl> + < < cdg . str ( ) < < " \ n = = = = = = = = = = = = = = = = = " < < std : : endl ; <nl> + TORCH_CHECK ( false ) ; <nl> + } <nl> + <nl> torch : : jit : : fuser : : cuda : : CudaKernel prog ; <nl> prog . device_ = 0 ; <nl> / / These can be set to anything as there are no bindings ! <nl> void testGPU_FusionCodeGen ( ) { <nl> at : : Tensor output = at : : empty ( { 16 , 8 , 8 } , options ) ; <nl> std : : vector < at : : Tensor > outputs { { output } } ; <nl> <nl> - torch : : jit : : fuser : : cuda : : compileKernel ( fusion , prog ) ; <nl> + torch : : jit : : fuser : : cuda : : compileKernel ( fusion , & prog ) ; <nl> torch : : jit : : fuser : : cuda : : runTestKernel ( prog , { } , outputs ) ; <nl> <nl> at : : Tensor output_ref = at : : zeros_like ( output , options ) ; <nl> void testGPU_FusionCodeGen2 ( ) { <nl> tv3 - > axis ( 0 ) - > parallelize ( ParallelType : : BIDx ) ; <nl> tv3 - > axis ( - 1 ) - > parallelize ( ParallelType : : TIDx ) ; <nl> <nl> - / * <nl> std : : stringstream ref ; <nl> - ref <nl> - < < " __device__ int ceilDiv ( const int a , const int b ) { \ n " <nl> - < < " return ( a + b - 1 ) / b ; \ n " <nl> - < < " } \ n " <nl> - < < " \ n " <nl> - < < " __global__ void kernel ( Tensor < float > T0 , Tensor < float > T1 , Tensor < float > <nl> - T3 ) { \ n " <nl> - < < " for ( size_t i13 = 0 ; i13 < 4 ; + + i13 ) { \ n " <nl> - < < " for ( size_t i15 = 0 ; i15 < T1 . size [ 1 ] ; + + i15 ) { \ n " <nl> - < < " float T2 [ 1 ] ; \ n " <nl> - < < " if ( ( ( ( blockIdx . x * 4 ) + i13 ) < T1 . size [ 0 ] ) ) { \ n " <nl> - < < " T2 [ 0 ] \ n " <nl> - < < " = T1 [ ( ( blockIdx . x * 4 ) + i13 ) * T1 . stride [ 0 ] + i15 * <nl> - T1 . stride [ 1 ] + threadIdx . x * T1 . stride [ 2 ] ] \ n " <nl> - < < " + float ( 2 ) ; \ n " <nl> - < < " } \ n " <nl> - < < " if ( ( ( ( blockIdx . x * 4 ) + i13 ) < T1 . size [ 0 ] ) ) { \ n " <nl> - < < " T3 [ ( ( blockIdx . x * 4 ) + i13 ) * T3 . stride [ 0 ] + i15 * <nl> - T3 . stride [ 1 ] + threadIdx . x * T3 . stride [ 2 ] ] \ n " <nl> - < < " = T0 [ ( ( blockIdx . x * 4 ) + i13 ) * T0 . stride [ 0 ] + i15 * <nl> - T0 . stride [ 1 ] + threadIdx . x * T0 . stride [ 2 ] ] \ n " <nl> - < < " + T2 [ 0 ] ; \ n " <nl> - < < " } \ n " <nl> - < < " } \ n " <nl> - < < " } \ n " <nl> - < < " } \ n " <nl> - ; <nl> + ref < < " __device__ int ceilDiv ( const int a , const int b ) { \ n " <nl> + < < " return ( a + b - 1 ) / b ; \ n " <nl> + < < " } \ n " <nl> + < < " \ n " <nl> + < < " __global__ void CUDAGeneratedKernel ( Tensor < float , 3 > T0 , Tensor < float , 3 > T1 , Tensor < float , 3 > T3 ) { \ n " <nl> + < < " for ( size_t i33 = 0 ; i33 < 4 ; + + i33 ) { \ n " <nl> + < < " for ( size_t i34 = 0 ; i34 < T3 . size [ 1 ] ; + + i34 ) { \ n " <nl> + < < " float T2 [ 1 ] ; \ n " <nl> + < < " if ( ( ( ( blockIdx . x * 4 ) + i33 ) < T3 . size [ 0 ] ) ) { \ n " <nl> + < < " T2 [ 0 ] \ n " <nl> + < < " = T1 [ ( ( ( blockIdx . x * 4 ) + i33 ) * T1 . stride [ 0 ] ) + ( i34 * T1 . stride [ 1 ] ) + ( threadIdx . x * T1 . stride [ 2 ] ) ] \ n " <nl> + < < " + float ( 2 ) ; \ n " <nl> + < < " } \ n " <nl> + < < " if ( ( ( ( blockIdx . x * 4 ) + i33 ) < T3 . size [ 0 ] ) ) { \ n " <nl> + < < " T3 [ ( ( ( blockIdx . x * 4 ) + i33 ) * T3 . stride [ 0 ] ) + ( i34 * T3 . stride [ 1 ] ) + ( threadIdx . x * T3 . stride [ 2 ] ) ] \ n " <nl> + < < " = T0 [ ( ( ( blockIdx . x * 4 ) + i33 ) * T0 . stride [ 0 ] ) + ( i34 * T0 . stride [ 1 ] ) + ( threadIdx . x * T0 . stride [ 2 ] ) ] \ n " <nl> + < < " + T2 [ 0 ] ; \ n " <nl> + < < " } \ n " <nl> + < < " } \ n " <nl> + < < " } \ n " <nl> + < < " } \ n " ; <nl> <nl> GPULower gpulw ( & fusion ) ; <nl> std : : stringstream cdg ; <nl> void testGPU_FusionCodeGen2 ( ) { <nl> < < cdg . str ( ) < < " \ n = = = = = = = = = = = = = = = = = " < < std : : endl ; <nl> TORCH_CHECK ( false ) ; <nl> } <nl> - * / <nl> + <nl> torch : : jit : : fuser : : cuda : : CudaKernel prog ; <nl> prog . device_ = 0 ; <nl> prog . grid ( 4 ) ; <nl> void testGPU_FusionCodeGen2 ( ) { <nl> std : : vector < at : : Tensor > inputs { { input1 , input2 } } ; <nl> std : : vector < at : : Tensor > outputs { { output } } ; <nl> <nl> - torch : : jit : : fuser : : cuda : : compileKernel ( fusion , prog ) ; <nl> + torch : : jit : : fuser : : cuda : : compileKernel ( fusion , & prog ) ; <nl> torch : : jit : : fuser : : cuda : : runTestKernel ( prog , inputs , outputs ) ; <nl> <nl> at : : Tensor tv2_ref = input2 + 2 . 0 ; <nl> void testGPU_FusionSimplePWise ( ) { <nl> / / Set up symbolic sizes for the axes should be dimensionality of the problem <nl> std : : vector < IterDomain * > dom ; <nl> for ( int i = 0 ; i < nDims ; i + + ) <nl> - dom . push_back ( new IterDomain ( new Int ( ) ) ) ; <nl> + dom . push_back ( new IterDomain ( new Int ( 0 ) , new Int ( ) ) ) ; <nl> <nl> / / Set up your input tensor views <nl> TensorView * tv0 = new TensorView ( new TensorDomain ( dom ) , DataType : : Float ) ; <nl> void testGPU_FusionSimplePWise ( ) { <nl> std : : vector < at : : Tensor > inputs { { input1 , input2 } } ; <nl> std : : vector < at : : Tensor > outputs { { output } } ; <nl> <nl> - torch : : jit : : fuser : : cuda : : compileKernel ( fusion , prog ) ; <nl> + torch : : jit : : fuser : : cuda : : compileKernel ( fusion , & prog ) ; <nl> torch : : jit : : fuser : : cuda : : runTestKernel ( prog , inputs , outputs ) ; <nl> <nl> at : : Tensor tv2_ref = input2 + 2 . 0 ; <nl> void testGPU_FusionExecKernel ( ) { <nl> / / Register your outputs <nl> fusion . addOutput ( tv3 ) ; <nl> <nl> + tv3 - > split ( 0 , 4 ) ; <nl> + <nl> / / For all inputs , computeAt the output inline , temporaries should be squeezed <nl> / / between them <nl> - tv0 - > computeAt ( tv3 , - 1 ) ; <nl> - tv1 - > computeAt ( tv3 , - 1 ) ; <nl> + tv0 - > computeAt ( tv3 , 1 ) ; <nl> + tv1 - > computeAt ( tv3 , 1 ) ; <nl> <nl> / / Parallelize TV3 <nl> tv3 - > axis ( 0 ) - > parallelize ( ParallelType : : BIDx ) ; <nl> + tv2 - > axis ( 1 ) - > parallelize ( ParallelType : : Unroll ) ; <nl> + tv3 - > axis ( 1 ) - > parallelize ( ParallelType : : Unroll ) ; <nl> + tv2 - > axis ( - 1 ) - > parallelize ( ParallelType : : TIDx ) ; <nl> tv3 - > axis ( - 1 ) - > parallelize ( ParallelType : : TIDx ) ; <nl> <nl> torch : : jit : : fuser : : cuda : : CudaKernel prog ; <nl> void testGPU_FusionExecKernel ( ) { <nl> std : : vector < at : : Tensor > inputs { { input1 , input2 } } ; <nl> std : : vector < at : : Tensor > outputs { { output } } ; <nl> <nl> - torch : : jit : : fuser : : cuda : : compileKernel ( fusion , prog ) ; <nl> + torch : : jit : : fuser : : cuda : : compileKernel ( fusion , & prog ) ; <nl> torch : : jit : : fuser : : cuda : : runTestKernel ( prog , inputs , outputs ) ; <nl> <nl> at : : Tensor check = at : : full ( { 1 , 128 } , 4 , options ) ; <nl> void testGPU_FusionForLoop ( ) { <nl> FusionGuard fg ( & fusion ) ; <nl> <nl> const auto TV0 = new TensorView ( <nl> - new TensorDomain ( { new IterDomain ( new Int ( 16 ) ) } ) , DataType : : Float ) ; <nl> + new TensorDomain ( { new IterDomain ( new Int ( 0 ) , new Int ( 16 ) ) } ) , <nl> + DataType : : Float ) ; <nl> const auto TV1 = new TensorView ( <nl> - new TensorDomain ( { new IterDomain ( new Int ( 16 ) ) } ) , DataType : : Float ) ; <nl> + new TensorDomain ( { new IterDomain ( new Int ( 0 ) , new Int ( 16 ) ) } ) , <nl> + DataType : : Float ) ; <nl> <nl> fusion . addInput ( TV0 ) ; <nl> fusion . addInput ( TV1 ) ; <nl> <nl> - auto ID0 = new IterDomain ( new Int ( 8 ) ) ; <nl> + auto ID0 = new IterDomain ( new Int ( 0 ) , new Int ( 8 ) ) ; <nl> <nl> TensorView * TV2 = static_cast < TensorView * > ( add ( TV0 , TV1 ) ) ; <nl> BinaryOp * op = static_cast < BinaryOp * > ( TV2 - > getOrigin ( ) ) ; <nl> void testGPU_FusionForLoop ( ) { <nl> } <nl> } <nl> <nl> - void testGPU_Fusion ( ) { } <nl> + void testGPU_FusionLoopUnroll ( ) { <nl> + Fusion fusion ; <nl> + FusionGuard fg ( & fusion ) ; <nl> + <nl> + / / Set up your input tensor views <nl> + TensorView * tv0 = makeDummyTensor ( 1 ) ; <nl> + TensorView * tv1 = makeDummyTensor ( 1 ) ; <nl> + <nl> + / / Register your inputs <nl> + fusion . addInput ( tv0 ) ; <nl> + fusion . addInput ( tv1 ) ; <nl> + <nl> + / / Do math with it , it returns a ` Val * ` but can be static_casted back to <nl> + / / TensorView <nl> + TensorView * tv2 = static_cast < TensorView * > ( add ( tv1 , new Float ( 2 . 0 ) ) ) ; <nl> + TensorView * tv3 = static_cast < TensorView * > ( add ( tv0 , tv2 ) ) ; <nl> + <nl> + / / Register your outputs <nl> + fusion . addOutput ( tv3 ) ; <nl> + <nl> + int block_size = 16 ; <nl> + <nl> + tv3 - > split ( 0 , block_size ) ; <nl> + tv3 - > split ( 0 , 4 ) ; <nl> + <nl> + / / For all inputs , computeAt the output inline , temporaries should be squeezed <nl> + / / between them <nl> + tv0 - > computeAt ( tv3 , 1 ) ; <nl> + tv1 - > computeAt ( tv3 , 1 ) ; <nl> + <nl> + / / Parallelize <nl> + tv2 - > axis ( 1 ) - > parallelize ( ParallelType : : Unroll ) ; <nl> + tv3 - > axis ( 1 ) - > parallelize ( ParallelType : : Unroll ) ; <nl> + tv2 - > axis ( - 1 ) - > parallelize ( ParallelType : : TIDx ) ; <nl> + tv3 - > axis ( - 1 ) - > parallelize ( ParallelType : : TIDx ) ; <nl> + tv3 - > axis ( 0 ) - > parallelize ( ParallelType : : BIDx ) ; <nl> + <nl> + / / GPULower lower ( & fusion ) ; <nl> + / / lower . printKernel ( std : : cout ) ; <nl> + <nl> + int inp_size = 129 ; <nl> + <nl> + torch : : jit : : fuser : : cuda : : CudaKernel prog ; <nl> + prog . device_ = 0 ; <nl> + prog . grid ( ( inp_size + 63 ) / 64 ) ; <nl> + prog . block ( block_size ) ; <nl> + <nl> + auto options = at : : TensorOptions ( ) . dtype ( at : : kFloat ) . device ( at : : kCUDA , 0 ) ; <nl> + <nl> + at : : Tensor input1 = at : : ones ( { inp_size } , options ) ; <nl> + at : : Tensor input2 = at : : ones_like ( input1 ) ; <nl> + <nl> + at : : Tensor output = at : : empty_like ( input1 ) ; <nl> + std : : vector < at : : Tensor > inputs { { input1 , input2 } } ; <nl> + std : : vector < at : : Tensor > outputs { { output } } ; <nl> + <nl> + torch : : jit : : fuser : : cuda : : compileKernel ( fusion , & prog ) ; <nl> + torch : : jit : : fuser : : cuda : : runTestKernel ( prog , inputs , outputs ) ; <nl> + <nl> + at : : Tensor check = at : : full ( { inp_size } , 4 , options ) ; <nl> + <nl> + TORCH_CHECK ( output . equal ( check ) ) ; <nl> + } <nl> <nl> } / / namespace jit <nl> } / / namespace torch <nl> mmm a / test / cpp / jit / tests . h <nl> ppp b / test / cpp / jit / tests . h <nl> namespace jit { <nl> _ ( GPU_FusionCodeGen2 ) \ <nl> _ ( GPU_FusionSimplePWise ) \ <nl> _ ( GPU_FusionExecKernel ) \ <nl> - _ ( GPU_FusionForLoop ) <nl> + _ ( GPU_FusionForLoop ) \ <nl> + _ ( GPU_FusionLoopUnroll ) <nl> # else <nl> # define TH_FORALL_TESTS_CUDA ( _ ) \ <nl> _ ( ArgumentSpec ) \ <nl> mmm a / test / test_jit_cuda_fuser . py <nl> ppp b / test / test_jit_cuda_fuser . py <nl> def t ( x , y , z , q ) : <nl> @ unittest . skipIf ( GRAPH_EXECUTOR ! = ProfilingMode . PROFILING , " Requires profiling node to run cuda fuser " ) <nl> @ skipIfRocm <nl> def test_scalar_input ( self ) : <nl> - def t ( x , y , z ) : <nl> - # type : ( Tensor , Tensor , float ) - > Tensor <nl> + def t ( x : torch . Tensor , y : torch . Tensor , z : float ) : <nl> o = x + y <nl> o = o + z <nl> return o <nl> t_jit = torch . jit . script ( t ) <nl> - x = torch . randn ( 4 , 8 , dtype = torch . float , device = " cuda " ) <nl> - y = torch . randn ( 4 , 8 , dtype = torch . float , device = " cuda " ) <nl> + x = torch . randn ( 4 , 8 , 32 , 32 , dtype = torch . float , device = " cuda " ) <nl> + y = torch . randn ( 4 , 8 , 1 , 32 , dtype = torch . float , device = " cuda " ) <nl> + y = y . expand ( 4 , 8 , 32 , 32 ) <nl> + jit_o = t_jit ( x , y , 2 . 0 ) <nl> + jit_o = t_jit ( x , y , 2 . 0 ) <nl> + o = t ( x , y , 2 . 0 ) <nl> + self . assertEqual ( o , jit_o ) <nl> + self . assertTrue ( self . _has_cuda_fusion_group ( t_jit . graph_for ( x , y , 2 . 0 ) ) ) <nl> + <nl> + @ unittest . skipIf ( not RUN_CUDA , " requires CUDA " ) <nl> + @ unittest . skipIf ( GRAPH_EXECUTOR ! = ProfilingMode . PROFILING , " Requires profiling node to run cuda fuser " ) <nl> + @ skipIfRocm <nl> + def test_broadcasting ( self ) : <nl> + def t ( x : torch . Tensor , y : torch . Tensor , z : float ) : <nl> + o = x + y <nl> + o = o + z <nl> + return o <nl> + t_jit = torch . jit . script ( t ) <nl> + x = torch . randn ( 4 , 8 , 32 , 32 , dtype = torch . float , device = " cuda " ) <nl> + y = torch . randn ( 32 , 32 , dtype = torch . float , device = " cuda " ) <nl> jit_o = t_jit ( x , y , 2 . 0 ) <nl> jit_o = t_jit ( x , y , 2 . 0 ) <nl> o = t ( x , y , 2 . 0 ) <nl> self . assertEqual ( o , jit_o ) <nl> self . assertTrue ( self . _has_cuda_fusion_group ( t_jit . graph_for ( x , y , 2 . 0 ) ) ) <nl> <nl> + @ unittest . skipIf ( not RUN_CUDA , " requires CUDA " ) <nl> + @ unittest . skipIf ( GRAPH_EXECUTOR ! = ProfilingMode . PROFILING , " Requires profiling node to run cuda fuser " ) <nl> + @ skipIfRocm <nl> + def test_broadcasting_multiple_output_shape ( self ) : <nl> + def t ( x : torch . Tensor , y : torch . Tensor , z : torch . Tensor ) : <nl> + o = x + 12 <nl> + o1 = o + y <nl> + o2 = o + z <nl> + oo = o1 . sum ( ) + o2 . sum ( ) <nl> + return oo <nl> + t_jit = torch . jit . script ( t ) <nl> + x = torch . randn ( 32 , 32 , dtype = torch . float , device = " cuda " ) <nl> + y = torch . randn ( 2 , 32 , 32 , dtype = torch . float , device = " cuda " ) <nl> + z = torch . randn ( 4 , 32 , 32 , dtype = torch . float , device = " cuda " ) <nl> + jit_o = t_jit ( x , y , z ) <nl> + jit_o = t_jit ( x , y , z ) <nl> + o = t ( x , y , z ) <nl> + self . assertEqual ( o , jit_o ) <nl> + # Currently cannot fuse this <nl> + self . assertFalse ( self . _has_cuda_fusion_group ( t_jit . graph_for ( x , y , z ) ) ) <nl> <nl> if __name__ = = ' __main__ ' : <nl> run_tests ( ) <nl> mmm a / tools / build_variables . bzl <nl> ppp b / tools / build_variables . bzl <nl> libtorch_cuda_sources = [ <nl> " torch / csrc / jit / codegen / cuda / ir_iostream . cpp " , <nl> " torch / csrc / jit / codegen / cuda / iter_visitor . cpp " , <nl> " torch / csrc / jit / codegen / cuda / kernel . cpp " , <nl> + " torch / csrc / jit / codegen / cuda / kernel_cache . cpp " , <nl> + " torch / csrc / jit / codegen / cuda / lower_loops . cpp " , <nl> + " torch / csrc / jit / codegen / cuda / lower_utils . cpp " , <nl> " torch / csrc / jit / codegen / cuda / lower2device . cpp " , <nl> " torch / csrc / jit / codegen / cuda / manager . cpp " , <nl> " torch / csrc / jit / codegen / cuda / mutator . cpp " , <nl> deleted file mode 100644 <nl> index bcfae7335d34 . . 000000000000 <nl> mmm a / torch / csrc / jit / codegen / cuda / data_struct_str . h <nl> ppp / dev / null <nl> <nl> - STRINGIFY ( template < typename T > struct Tensor { <nl> - public : <nl> - T & operator [ ] ( int ind ) { <nl> - return data [ ind ] ; <nl> - } ; <nl> - <nl> - int size [ 8 ] ; <nl> - int stride [ 8 ] ; <nl> - T * data ; <nl> - int nDim ; <nl> - } ; ) <nl> mmm a / torch / csrc / jit / codegen / cuda / dispatch . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / dispatch . cpp <nl> <nl> # include < torch / csrc / jit / codegen / cuda / fusion . h > <nl> # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> # include < torch / csrc / jit / codegen / cuda / type . h > <nl> <nl> # include < torch / csrc / jit / codegen / cuda / dispatch . h > <nl> mmm a / torch / csrc / jit / codegen / cuda / fusion . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / fusion . cpp <nl> <nl> # include < torch / csrc / jit / codegen / cuda / fusion . h > <nl> + # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> # include < torch / csrc / jit / codegen / cuda / ir_printer . h > <nl> <nl> namespace torch { <nl> std : : vector < Expr * > ExprSort : : getExprs ( <nl> return es . exprs ; <nl> } <nl> <nl> + void InputsOf : : handle ( TensorView * tv ) { <nl> + if ( FusionGuard : : getCurFusion ( ) - > hasInput ( tv ) ) <nl> + inputs . push_back ( tv ) ; <nl> + } <nl> + <nl> + std : : vector < TensorView * > InputsOf : : output ( Fusion * fusion , Val * output_ ) { <nl> + TORCH_CHECK ( <nl> + fusion - > hasOutput ( output_ ) , <nl> + " Asked for the inputs of " , <nl> + output_ , <nl> + " however , it is not an output of the provided fusion . " ) ; <nl> + InputsOf io ; <nl> + io . traverseFrom ( FusionGuard : : getCurFusion ( ) , { output_ } ) ; <nl> + return io . inputs ; <nl> + } <nl> + <nl> Fusion : : ~ Fusion ( ) { <nl> { <nl> auto it = val_set_ . begin ( ) ; <nl> std : : vector < Expr * > Fusion : : exprs ( bool from_outputs_only , bool breadth_first ) { <nl> return ExprSort : : getExprs ( this , from_outputs_only , breadth_first ) ; <nl> } <nl> <nl> + std : : vector < TensorView * > Fusion : : inputsOf ( Val * val ) { <nl> + return InputsOf : : output ( this , val ) ; <nl> + } <nl> + <nl> void Fusion : : print ( ) { <nl> FusionGuard fg ( this ) ; <nl> std : : cout < < " % kernel { \ n " ; <nl> mmm a / torch / csrc / jit / codegen / cuda / fusion . h <nl> ppp b / torch / csrc / jit / codegen / cuda / fusion . h <nl> struct TypeHash { <nl> * / <nl> <nl> struct Fusion ; <nl> + struct TensorView ; <nl> <nl> / / Fusion Guard is our " context manager " . It holds the actrive fusion and allows <nl> / / it to be accessed anywhere through FusionGuard : : getCurFusion ( ) . <nl> struct ExprSort : public IterVisitor { <nl> bool breadth_first ) ; <nl> } ; <nl> <nl> + / / Expr sort will take a fusion and return a topologically sorted list of <nl> + / / expressions . <nl> + struct InputsOf : public IterVisitor { <nl> + using IterVisitor : : handle ; <nl> + <nl> + private : <nl> + std : : vector < TensorView * > inputs ; <nl> + <nl> + void handle ( TensorView * tv ) override ; <nl> + <nl> + public : <nl> + static std : : vector < TensorView * > output ( Fusion * fusion , Val * output_ ) ; <nl> + } ; <nl> + <nl> / * <nl> * Fusion is mutable but unique . Nodes cannot be copied in any way from one <nl> * Fusion to another . If anything like that is desired , it would require <nl> struct TORCH_CUDA_API Fusion : public IRInputOutput { <nl> bool from_outputs_only = false , <nl> bool breadth_first = false ) ; <nl> <nl> + std : : vector < TensorView * > inputsOf ( Val * val ) ; <nl> + <nl> / / Print this fusion to cout . <nl> void print ( ) ; <nl> <nl> struct TORCH_CUDA_API Fusion : public IRInputOutput { <nl> / / Return the Expr that produces val ( const version ) <nl> const Expr * origin ( const Val * val ) const ; <nl> <nl> - bool lowered = false ; <nl> - <nl> private : <nl> / / Sets of all Vals / Exprs registered with this fusion <nl> std : : set < Val * > val_set_ ; <nl> mmm a / torch / csrc / jit / codegen / cuda / index_compute . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / index_compute . cpp <nl> void IndexCompute : : replayBackward ( Merge * expr ) { <nl> ax > = 0 & & ax < indices . size ( ) , <nl> " Hit an invalid MERGE transformation during IndexCompute , axis is not within bounds . " ) ; <nl> <nl> - Val * I = expr - > in ( ) - > axis ( ax + 1 ) - > size ( ) ; <nl> + Val * I = expr - > in ( ) - > axis ( ax + 1 ) - > extent ( ) ; <nl> Val * ind = indices [ ax ] ; <nl> indices [ ax ] = div ( ind , I ) ; <nl> indices . insert ( indices . begin ( ) + ax + 1 , mod ( ind , I ) ) ; <nl> IndexCompute : : IndexCompute ( const TensorView * tv , std : : vector < Val * > _indices ) { <nl> <nl> TensorDomain * td = tv - > domain ( ) ; <nl> <nl> - bool exclude_reduction = td - > size ( ) > indices . size ( ) ; <nl> + bool exclude_reduction = td - > nDims ( ) > indices . size ( ) ; <nl> <nl> TORCH_CHECK ( <nl> - exclude_reduction | | td - > size ( ) = = indices . size ( ) , <nl> + exclude_reduction | | td - > nDims ( ) = = indices . size ( ) , <nl> " For IndexCompute the number of axis should match the number of dimensions " <nl> " in the TensorView . " ) ; <nl> <nl> IndexCompute : : IndexCompute ( const TensorView * tv , std : : vector < Val * > _indices ) { <nl> / / being consumed , not produced , then insert dummy dimensions in the <nl> / / indices for bookkeeping while replaying split / merge / reorder operations . <nl> if ( exclude_reduction ) <nl> - for ( decltype ( td - > size ( ) ) i { 0 } ; i < td - > size ( ) ; i + + ) <nl> + for ( decltype ( td - > nDims ( ) ) i { 0 } ; i < td - > nDims ( ) ; i + + ) <nl> if ( td - > axis ( i ) - > isReduction ( ) ) <nl> indices . insert ( indices . begin ( ) + i , new Int ( - 1 ) ) ; <nl> <nl> IndexCompute : : IndexCompute ( const TensorView * tv , std : : vector < Val * > _indices ) { <nl> TensorDomain * root = TransformIter : : runBackward ( td , true ) ; <nl> <nl> TORCH_INTERNAL_ASSERT ( <nl> - root - > size ( ) = = indices . size ( ) , <nl> + root - > nDims ( ) = = indices . size ( ) , <nl> " Error during IndexCompute . The number of indices generated " <nl> " after running the transformations backwards should match " <nl> " the number of dimensions of the root TensorView . " ) ; <nl> IndexCompute : : IndexCompute ( const TensorView * tv , std : : vector < Val * > _indices ) { <nl> / / Remove indices associated with reduction axes , we had them just for <nl> / / bookkeeping . <nl> if ( exclude_reduction ) { <nl> - for ( auto i = root - > size ( ) - 1 ; i > = 0 ; i - - ) <nl> + for ( auto i = root - > nDims ( ) - 1 ; i > = 0 ; i - - ) <nl> if ( root - > axis ( i ) - > isReduction ( ) ) <nl> indices . erase ( indices . begin ( ) + i ) ; <nl> } <nl> mmm a / torch / csrc / jit / codegen / cuda / ir_base_nodes . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / ir_base_nodes . cpp <nl> <nl> - # include < torch / csrc / jit / codegen / cuda / ir_base_nodes . h > <nl> # include < torch / csrc / jit / codegen / cuda / fusion . h > <nl> + # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> <nl> # include < torch / csrc / jit / codegen / cuda / ir_printer . h > <nl> # include < torch / csrc / jit / codegen / cuda / mutator . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> <nl> # include < torch / csrc / jit / codegen / cuda / dispatch . h > <nl> <nl> Val : : Val ( ValType _vtype , DataType _dtype ) : vtype_ { _vtype } , dtype_ { _dtype } { <nl> } <nl> } <nl> <nl> + / / Traverse origin of all values involved in constructing the provided val . <nl> + / / Check if all values involved are constant values , meaning the provided <nl> + / / val is also a constant value . <nl> namespace { <nl> <nl> struct ConstCheck : OptOutConstDispatch { <nl> struct ConstCheck : OptOutConstDispatch { <nl> void handle ( const NamedScalar * const ns ) override { <nl> is_const_ = false ; <nl> } <nl> - <nl> void handle ( const Val * const val ) override { <nl> const Expr * orig = FusionGuard : : getCurFusion ( ) - > origin ( val ) ; <nl> if ( orig ! = nullptr ) <nl> bool Val : : isConstScalar ( ) const { <nl> return ConstCheck : : isConst ( this ) ; <nl> } <nl> <nl> + bool Val : : isZeroInt ( ) const { <nl> + if ( isConstScalar ( ) & & getValType ( ) . value ( ) = = ValType : : Scalar & & <nl> + getDataType ( ) . value ( ) = = DataType : : Int & & <nl> + static_cast < const Int * > ( this ) - > value ( ) . value ( ) = = 0 ) <nl> + return true ; <nl> + return false ; <nl> + } <nl> + <nl> + bool Val : : isOneInt ( ) const { <nl> + if ( isConstScalar ( ) & & getValType ( ) . value ( ) = = ValType : : Scalar & & <nl> + getDataType ( ) . value ( ) = = DataType : : Int & & <nl> + static_cast < const Int * > ( this ) - > value ( ) . value ( ) = = 1 ) <nl> + return true ; <nl> + return false ; <nl> + } <nl> + <nl> c10 : : optional < DataType > Val : : getDataType ( ) const { <nl> TORCH_INTERNAL_ASSERT ( <nl> dtype_ ! = DataType : : Null , " Value does not have a data type . " ) ; <nl> bool Scope : : sameAs ( const Scope & other ) const { <nl> return true ; <nl> } <nl> <nl> + void Scope : : clear ( ) { <nl> + this - > exprs_ = std : : vector < Expr * > ( ) ; <nl> + } <nl> + <nl> bool IRInputOutput : : hasInput ( const Val * const input ) const { <nl> for ( auto val : inputs_ ) <nl> if ( val = = input ) <nl> mmm a / torch / csrc / jit / codegen / cuda / ir_base_nodes . h <nl> ppp b / torch / csrc / jit / codegen / cuda / ir_base_nodes . h <nl> struct TORCH_CUDA_API Val : public Statement { <nl> return isScalar ( ) & & dtype_ = = DataType : : Int ; <nl> } <nl> <nl> + bool isZeroInt ( ) const ; <nl> + bool isOneInt ( ) const ; <nl> + <nl> / / Returns the Expr that this value is an output of , returns nullptr if none <nl> / / was found <nl> Expr * getOrigin ( ) ; <nl> struct TORCH_CUDA_API Scope { <nl> <nl> bool sameAs ( const Scope & other ) const ; <nl> <nl> + void clear ( ) ; <nl> + <nl> private : <nl> std : : vector < Expr * > exprs_ ; <nl> } ; <nl> mmm a / torch / csrc / jit / codegen / cuda / ir_interface_nodes . h <nl> ppp b / torch / csrc / jit / codegen / cuda / ir_interface_nodes . h <nl> namespace fuser { <nl> <nl> / * <nl> * A Float32 value . For now we don ' t have any other type besides <nl> - * Float32 . reorder_ This value can be a symbolic value ( defined after the kernel <nl> + * Float32 . This value can be a symbolic value ( defined after the kernel <nl> * is compiled ) or a constant value ( inlined into the kernel definition ) . <nl> * / <nl> struct TORCH_CUDA_API Float : public Val { <nl> struct TORCH_CUDA_API Int : public Val { <nl> return maybe_value_ ; <nl> } <nl> <nl> - bool sameAs ( const Int * const other ) const ; <nl> + virtual bool sameAs ( const Int * const other ) const ; <nl> <nl> private : <nl> const c10 : : optional < int > maybe_value_ ; <nl> } ; <nl> <nl> struct TransformReplay ; <nl> + struct TransformIter ; <nl> struct OptOutMutator ; <nl> struct GPULower ; <nl> / * <nl> struct GPULower ; <nl> * these transformations are kept and used for generating actual code referncing <nl> * physical memory . Generally when users are thinking of code generation in <nl> * reference to a Tensor , this is the class they should be interacting with . <nl> + * <nl> + * The reason we need both TensorView and TensorDomain is that we need to have a <nl> + * record of both what is being computed and how it is being computed . For <nl> + * Example we may have the operation : TV3 [ I , J , K ] = TV2 [ I , J , K ] + TV1 [ I , J , K ] <nl> + * The mathematical operationss here are on the tensor views TV1 , TV2 , and TV3 . <nl> + * This operation is a pointwise operation . To compute this pointwise operation <nl> + * we iterate over the 3D TensorDomain [ I , J , K ] , where K is the fastest <nl> + * changing dimension . <nl> * / <nl> struct TORCH_CUDA_API TensorView : public Val { <nl> ~ TensorView ( ) = default ; <nl> struct TORCH_CUDA_API TensorView : public Val { <nl> <nl> / / Split " axis " into 2 axes where the inner axes is size of " factor " <nl> / / and outer axis is size axis . size ( ) / factor <nl> - TensorView * split ( int axis , int factor ) { <nl> - return split_ ( this , axis , factor ) ; <nl> - } <nl> + TensorView * split ( int axis , int factor ) ; <nl> <nl> / / Merge " axis " and " axis + 1 " into 1 dimension <nl> - TensorView * merge ( int axis ) { <nl> - return merge_ ( this , axis ) ; <nl> - } <nl> + TensorView * merge ( int axis ) ; <nl> <nl> - / / Reorder axes according to map [ old_pos ] = new_pos <nl> - TensorView * reorder ( const std : : unordered_map < int , int > & map ) { <nl> - return reorder_ ( this , map ) ; <nl> - } <nl> + / / Reorder axes according to axis2pos [ old_pos ] = new_pos <nl> + TensorView * reorder ( const std : : unordered_map < int , int > & axis2pos ) ; <nl> <nl> - / / Implementations for split / merge / reorder <nl> - friend TORCH_CUDA_API TensorView * split_ ( TensorView * , int axis , int factor ) ; <nl> - friend TORCH_CUDA_API TensorView * merge_ ( TensorView * , int axis ) ; <nl> - friend TORCH_CUDA_API TensorView * reorder_ ( <nl> - TensorView * , <nl> - const std : : unordered_map < int , int > & ) ; <nl> - friend TORCH_CUDA_API OptOutMutator ; <nl> friend TORCH_CUDA_API TransformReplay ; <nl> + friend TORCH_CUDA_API TransformIter ; <nl> + friend TORCH_CUDA_API OptOutMutator ; <nl> friend TORCH_CUDA_API GPULower ; <nl> <nl> protected : <nl> mmm a / torch / csrc / jit / codegen / cuda / ir_internal_nodes . h <nl> ppp b / torch / csrc / jit / codegen / cuda / ir_internal_nodes . h <nl> struct TORCH_CUDA_API BinaryOp : public Expr { <nl> } ; <nl> <nl> / * <nl> - * Simply a representation of an iterable from 0 to size . TensorDomains which <nl> - * represent how to iterate over a tensor is made up of IterDomains . We directly <nl> - * set parallization strategies on IterDomains . <nl> + * Simply a representation of an annotated 1D iterable from start to extent . <nl> + * TensorDomains which represent how to iterate over a tensor is made up of <nl> + * IterDomains to form an ND iterable . We directly set parallization strategies <nl> + * on IterDomains . <nl> * / <nl> struct TORCH_CUDA_API IterDomain : public Val { <nl> ~ IterDomain ( ) = default ; <nl> struct TORCH_CUDA_API IterDomain : public Val { <nl> IterDomain ( ) = delete ; <nl> <nl> IterDomain ( <nl> - Val * int_size , <nl> + Val * _start , <nl> + Val * _extent , <nl> ParallelType _parallel_method = ParallelType : : Serial , <nl> bool _reduction_domain = false ) ; <nl> <nl> struct TORCH_CUDA_API IterDomain : public Val { <nl> TORCH_CHECK ( <nl> t ! = ParallelType : : Vectorize , " Vectorization not yet supported . " ) ; <nl> if ( t = = ParallelType : : Unroll ) <nl> - TORCH_CHECK ( false , " Unrolling not yet supported . " ) ; <nl> + TORCH_CHECK ( <nl> + start ( ) - > isZeroInt ( ) & & extent ( ) - > isConstScalar ( ) , <nl> + " Unrolling only supported with start = 0 and extent as a const int , but got " , <nl> + " a start of " , <nl> + start ( ) , <nl> + " and extent " , <nl> + extent ( ) , <nl> + " . " ) ; <nl> } <nl> } <nl> <nl> struct TORCH_CUDA_API IterDomain : public Val { <nl> return parallel_method_ ; <nl> } <nl> <nl> - Val * size ( ) const ; <nl> + Val * start ( ) const noexcept { <nl> + return start_ ; <nl> + } <nl> + Val * extent ( ) const ; <nl> <nl> IterDomain ( const IterDomain & other ) = delete ; <nl> IterDomain & operator = ( const IterDomain & other ) = delete ; <nl> struct TORCH_CUDA_API IterDomain : public Val { <nl> IterDomain & operator = ( IterDomain & & other ) = delete ; <nl> <nl> private : <nl> - Val * const size_ ; <nl> + Val * const start_ ; <nl> + Val * const extent_ ; <nl> ParallelType parallel_method_ = ParallelType : : Serial ; <nl> bool is_reduction_domain_ ; <nl> } ; <nl> - <nl> - / / A list of IterDomains representing how to iterate across a given Tensor . <nl> + / * <nl> + * TensorDomain holds a vector of IterDomains . It holds an IterDomain for every <nl> + * logical axis in its associated tensor . TensorDomain does not directly hold <nl> + * the Tensor it is associated with , and in theory could be associated with <nl> + * multiple tensors . TensorDomain ' s primary responsibility is to provide a <nl> + * mechanism to access history of transformations that were used to generate it . <nl> + * This is done through the normal interaction of Expr / Val in Fusion . i . e . if we <nl> + * want to know the previous operation generating a particular TensorDomain we <nl> + * can simply call FusionGuard : : getCurFusion ( ) - > origin ( a_tensor_domain ) which <nl> + * should give us an operation in the list [ split , merge , reorder ] or similar <nl> + * operations that take in a TensorDomain , applies a transformation and outputs <nl> + * a tensor domain . <nl> + * / <nl> struct TORCH_CUDA_API TensorDomain : public Val { <nl> ~ TensorDomain ( ) = default ; <nl> <nl> struct TORCH_CUDA_API TensorDomain : public Val { <nl> TensorDomain ( std : : vector < IterDomain * > _domain ) <nl> : Val ( ValType : : TensorDomain ) , domain_ ( _domain ) { } <nl> <nl> - std : : vector < IterDomain * > : : size_type size ( ) const { <nl> + std : : vector < IterDomain * > : : size_type nDims ( ) const { <nl> return domain_ . size ( ) ; <nl> } <nl> <nl> struct TORCH_CUDA_API TensorDomain : public Val { <nl> / / uint . <nl> IterDomain * axis ( int i ) const ; <nl> <nl> + / / Split " axis " into 2 axes where the inner axes is size of " factor " <nl> + / / and outer axis is size axis . size ( ) / factor <nl> + TensorDomain * split ( int axis , int factor ) ; <nl> + <nl> + / / Merge " axis " and " axis + 1 " into 1 dimension <nl> + TensorDomain * merge ( int axis ) ; <nl> + <nl> + / / Reorder axes according to map [ old_pos ] = new_pos <nl> + TensorDomain * reorder ( const std : : unordered_map < int , int > & axis2pos ) ; <nl> + <nl> + TensorDomain * rootDomain ( ) ; <nl> + <nl> private : <nl> std : : vector < IterDomain * > domain_ ; <nl> } ; <nl> struct TORCH_CUDA_API ForLoop : public Expr { <nl> ~ ForLoop ( ) = default ; <nl> ForLoop ( <nl> Val * _index , <nl> - IterDomain * _range , <nl> + IterDomain * _iter_domain , <nl> const std : : vector < Expr * > & _body = { } , <nl> Expr * parent_scope = nullptr ) ; <nl> <nl> struct TORCH_CUDA_API ForLoop : public Expr { <nl> return index_ ; <nl> } <nl> <nl> - IterDomain * range ( ) const noexcept { <nl> - return range_ ; <nl> + IterDomain * iter_domain ( ) const noexcept { <nl> + return iter_domain_ ; <nl> } <nl> <nl> Scope & body ( ) noexcept { <nl> struct TORCH_CUDA_API ForLoop : public Expr { <nl> <nl> private : <nl> Val * const index_ ; <nl> - IterDomain * const range_ ; <nl> + IterDomain * const iter_domain_ ; <nl> Scope body_ ; <nl> Expr * parent_scope_ ; <nl> } ; <nl> struct TORCH_CUDA_API TensorIndex : public Val { <nl> " Cannot index with a value other than an int . " ) ; <nl> } <nl> <nl> - std : : vector < Val * > : : size_type size ( ) const { <nl> + std : : vector < Val * > : : size_type nDims ( ) const { <nl> return indices_ . size ( ) ; <nl> } <nl> <nl> mmm a / torch / csrc / jit / codegen / cuda / ir_iostream . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / ir_iostream . cpp <nl> <nl> # include < torch / csrc / jit / codegen / cuda / ir_iostream . h > <nl> # include < torch / csrc / jit / codegen / cuda / fusion . h > <nl> # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> <nl> # include < iostream > <nl> <nl> void IRPrinter : : printHeader ( Fusion * fusion , const std : : string & kernel_name_ ) { <nl> for ( Val * val : vals ) { <nl> switch ( val - > getValType ( ) . value ( ) ) { <nl> case ( ValType : : TensorView ) : <nl> - os < < " Tensor < " < < val - > getDataType ( ) . value ( ) < < " > T " < < val - > name ( ) ; <nl> + os < < " Tensor < " < < val - > getDataType ( ) . value ( ) < < " , " <nl> + < < static_cast < TensorView * > ( val ) - > getRootDomain ( ) - > nDims ( ) < < " > T " <nl> + < < val - > name ( ) ; <nl> break ; <nl> case ( ValType : : Scalar ) : <nl> os < < val - > getDataType ( ) . value ( ) < < " " < < val ; <nl> void IRPrinter : : handle ( Fusion * fusion ) { <nl> <nl> void IRPrinter : : handle ( const TensorDomain * const td ) { <nl> os < < " [ " ; <nl> - for ( std : : vector < const IterDomain * > : : size_type i = 0 ; i < td - > size ( ) ; i + + ) { <nl> + for ( std : : vector < const IterDomain * > : : size_type i = 0 ; i < td - > nDims ( ) ; i + + ) { <nl> handle ( td - > axis ( i ) ) ; <nl> - if ( i ! = td - > size ( ) - 1 ) <nl> + if ( i ! = td - > nDims ( ) - 1 ) <nl> os < < " , " ; <nl> } <nl> os < < " ] " ; <nl> void IRPrinter : : handle ( const IterDomain * const id ) { <nl> default : <nl> os < < id - > parallel_method ( ) ; <nl> } <nl> + <nl> os < < " { " ; <nl> - print_inline ( id - > size ( ) ) ; <nl> + if ( ! id - > start ( ) - > isZeroInt ( ) ) { <nl> + print_inline ( id - > start ( ) ) ; <nl> + os < < " : " ; <nl> + } <nl> + print_inline ( id - > extent ( ) ) ; <nl> os < < " } " ; <nl> } <nl> <nl> void IRPrinter : : handle ( const BinaryOp * const bop ) { <nl> } <nl> <nl> void IRPrinter : : handle ( const ForLoop * const fl ) { <nl> - if ( fl - > range ( ) - > isThread ( ) ) { <nl> + if ( fl - > iter_domain ( ) - > isThread ( ) ) { <nl> for ( auto & expr : fl - > constBody ( ) . exprs ( ) ) <nl> handle ( expr ) ; <nl> return ; <nl> void IRPrinter : : handle ( const ForLoop * const fl ) { <nl> indent ( ) ; <nl> os < < " for ( size_t " ; <nl> handle ( fl - > index ( ) ) ; <nl> - os < < " { 0 } ; " ; <nl> + os < < " = " ; <nl> + print_inline ( fl - > iter_domain ( ) - > start ( ) ) ; <nl> + os < < " ; " ; <nl> handle ( fl - > index ( ) ) ; <nl> os < < " < " ; <nl> - print_inline ( fl - > range ( ) - > size ( ) ) ; <nl> + print_inline ( fl - > iter_domain ( ) - > extent ( ) ) ; <nl> os < < " ; + + " ; <nl> handle ( fl - > index ( ) ) ; <nl> os < < " ) { \ n " ; <nl> void IRPrinter : : printKernel ( <nl> const std : : vector < Expr * > & exprs , <nl> const std : : string & kernel_name ) { <nl> Fusion * fusion = FusionGuard : : getCurFusion ( ) ; <nl> - / / if ( exprs . size ( ) ! = 0 ) <nl> - / / fusion = exprs [ 0 ] - > fusion ( ) ; <nl> <nl> printHeader ( fusion , kernel_name ) ; <nl> for ( auto * expr : exprs ) { <nl> mmm a / torch / csrc / jit / codegen / cuda / ir_iostream . h <nl> ppp b / torch / csrc / jit / codegen / cuda / ir_iostream . h <nl> struct Add ; <nl> * / <nl> <nl> struct TORCH_CUDA_API IRPrinter : public OptInConstDispatch { <nl> + public : <nl> std : : ostream & os ; <nl> bool print_inline_ = false ; <nl> <nl> struct TORCH_CUDA_API IRPrinter : public OptInConstDispatch { <nl> <nl> void printHeader ( Fusion * fusion , const std : : string & kernel_name_ ) ; <nl> <nl> - public : <nl> IRPrinter ( std : : ostream & _os ) : os ( _os ) { } <nl> <nl> virtual void handle ( Fusion * const f ) ; <nl> mmm a / torch / csrc / jit / codegen / cuda / ir_nodes . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / ir_nodes . cpp <nl> <nl> # include < torch / csrc / jit / codegen / cuda / arith . h > <nl> # include < torch / csrc / jit / codegen / cuda / ir_interface_nodes . h > <nl> # include < torch / csrc / jit / codegen / cuda / ir_iostream . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> + # include < torch / csrc / jit / codegen / cuda / transform_iter . h > <nl> + <nl> + # include < torch / csrc / jit / codegen / cuda / ir_iostream . h > <nl> <nl> # include < sstream > <nl> <nl> namespace torch { <nl> namespace jit { <nl> namespace fuser { <nl> <nl> + namespace { <nl> + struct ScalarCheck : OptInDispatch { <nl> + Val * v1_ ; <nl> + Val * v2_ ; <nl> + bool same = false ; <nl> + <nl> + void handle ( Float * f ) override { <nl> + same = static_cast < Float * > ( v1_ ) - > sameAs ( static_cast < Float * > ( v2_ ) ) ; <nl> + } <nl> + <nl> + void handle ( Int * i ) override { <nl> + same = static_cast < Int * > ( v1_ ) - > sameAs ( static_cast < Int * > ( v2_ ) ) ; <nl> + } <nl> + <nl> + void handle ( NamedScalar * ns ) override { <nl> + same = <nl> + static_cast < NamedScalar * > ( v1_ ) - > sameAs ( static_cast < NamedScalar * > ( v2_ ) ) ; <nl> + } <nl> + <nl> + ScalarCheck ( Val * _v1 , Val * _v2 ) : v1_ ( _v1 ) , v2_ ( _v2 ) { <nl> + OptInDispatch : : handle ( v1_ ) ; <nl> + } <nl> + <nl> + public : <nl> + static bool sameAs ( Val * v1 , Val * v2 ) { <nl> + if ( v1 = = v2 ) <nl> + return true ; <nl> + <nl> + if ( v1 - > getValType ( ) ! = v2 - > getValType ( ) ) <nl> + return false ; <nl> + <nl> + if ( v1 - > getDataType ( ) ! = v2 - > getDataType ( ) ) <nl> + return false ; <nl> + <nl> + ScalarCheck sc ( v1 , v2 ) ; <nl> + return sc . same ; <nl> + } <nl> + } ; <nl> + } / / namespace <nl> + <nl> bool Float : : sameAs ( const Float * const other ) const { <nl> if ( isConst ( ) & & other - > isConst ( ) ) <nl> return * value ( ) = = * ( other - > value ( ) ) ; <nl> bool BinaryOp : : sameAs ( const BinaryOp * other ) const { <nl> } <nl> <nl> IterDomain : : IterDomain ( <nl> - Val * _size , <nl> + Val * _start , <nl> + Val * _extent , <nl> ParallelType _parallel_method , <nl> bool _reduction_domain ) <nl> : Val ( ValType : : IterDomain , DataType : : Int ) , <nl> - size_ ( _size ) , <nl> + start_ ( _start ) , <nl> + extent_ ( _extent ) , <nl> parallel_method_ ( _parallel_method ) , <nl> is_reduction_domain_ ( _reduction_domain ) { <nl> TORCH_INTERNAL_ASSERT ( <nl> - _size - > isAnInt ( ) , <nl> - " Cannot create an iter domain over a size that is not an int . " ) ; <nl> + _extent - > isAnInt ( ) , <nl> + " Cannot create an iter domain over an extent that is not an int but recieved " , <nl> + _extent , <nl> + " . " ) ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + _start - > isAnInt ( ) , <nl> + " Cannot create an iter domain with a start that is not an int but recieved " , <nl> + _extent , <nl> + " . " ) ; <nl> } <nl> <nl> bool IterDomain : : sameAs ( const IterDomain * const other ) const { <nl> bool is_same = isReduction ( ) = = other - > isReduction ( ) & & <nl> parallel_method ( ) = = other - > parallel_method ( ) ; <nl> + is_same = is_same & & ScalarCheck : : sameAs ( extent ( ) , other - > extent ( ) ) ; <nl> + is_same = is_same & & ScalarCheck : : sameAs ( start ( ) , other - > start ( ) ) ; <nl> <nl> - if ( size ( ) - > getValType ( ) = = ValType : : NamedScalar & & <nl> - other - > size ( ) - > getValType ( ) = = ValType : : NamedScalar ) { <nl> - is_same = is_same & & <nl> - ( static_cast < NamedScalar * > ( size ( ) ) - > name ( ) . compare ( <nl> - static_cast < NamedScalar * > ( other - > size ( ) ) - > name ( ) ) = = 0 ) ; <nl> - } else { <nl> - is_same = is_same & & size ( ) - > sameAs ( other - > size ( ) ) ; <nl> - } <nl> return is_same ; <nl> } <nl> <nl> - Val * IterDomain : : size ( ) const { <nl> + Val * IterDomain : : extent ( ) const { <nl> if ( isThread ( ) ) { <nl> - if ( size_ - > getValType ( ) = = ValType : : Scalar ) <nl> - if ( static_cast < Int * > ( size_ ) - > isConst ( ) ) <nl> - return size_ ; <nl> + if ( extent_ - > getValType ( ) = = ValType : : Scalar ) <nl> + if ( static_cast < Int * > ( extent_ ) - > isConst ( ) ) <nl> + return extent_ ; <nl> <nl> std : : string parallel_dim = stringifyThreadSize ( parallel_method_ ) ; <nl> return new NamedScalar ( parallel_dim , DataType : : Int ) ; <nl> } <nl> - return size_ ; <nl> + return extent_ ; <nl> } <nl> <nl> bool TensorDomain : : sameAs ( const TensorDomain * const other ) const { <nl> - if ( size ( ) ! = other - > size ( ) ) <nl> + if ( nDims ( ) ! = other - > nDims ( ) ) <nl> return false ; <nl> <nl> - for ( decltype ( size ( ) ) i = 0 ; i < size ( ) ; i + + ) <nl> + for ( decltype ( nDims ( ) ) i = 0 ; i < nDims ( ) ; i + + ) <nl> if ( ! ( axis ( i ) - > sameAs ( other - > axis ( i ) ) ) ) <nl> return false ; <nl> <nl> TensorDomain * TensorDomain : : noReductions ( ) const { <nl> / / uint . <nl> IterDomain * TensorDomain : : axis ( int i ) const { <nl> if ( i < 0 ) <nl> - i + = size ( ) ; <nl> + i + = nDims ( ) ; <nl> TORCH_CHECK ( <nl> - i > = 0 & & i < size ( ) , " Tried to access axis " , i , " in domain " , this ) ; <nl> + i > = 0 & & i < nDims ( ) , " Tried to access axis " , i , " in domain " , this ) ; <nl> return domain_ [ i ] ; <nl> } <nl> <nl> + / / Split " axis " into 2 axes where the inner axes is size of " factor " <nl> + / / and outer axis is size axis . extent ( ) / factor <nl> + TensorDomain * TensorDomain : : split ( int axis_ , int factor ) { <nl> + if ( axis_ < 0 ) <nl> + axis_ + = nDims ( ) ; <nl> + <nl> + TORCH_INTERNAL_ASSERT ( <nl> + axis_ > = 0 & & axis_ < nDims ( ) , <nl> + " Tried to split on axis outside TensorDomain ' s range . " ) ; <nl> + <nl> + IterDomain * id = axis ( axis_ ) ; <nl> + <nl> + TORCH_CHECK ( <nl> + id - > start ( ) - > isZeroInt ( ) , <nl> + " Splitting IterDomains with starting values that aren ' t 0 , is not supported at this time . " ) ; <nl> + <nl> + if ( id - > parallel_method ( ) ! = ParallelType : : Serial ) <nl> + TORCH_CHECK ( <nl> + false , <nl> + " Splitting an axis of non - Serial iteration is not supported at this time . " <nl> + " Parallelization strategy must be set after calling split . " ) ; <nl> + <nl> + std : : vector < IterDomain * > new_domain ; <nl> + <nl> + Int * fact = new Int ( factor ) ; <nl> + Int * one = new Int ( 1 ) ; <nl> + <nl> + for ( decltype ( nDims ( ) ) i = 0 ; i < nDims ( ) ; i + + ) { <nl> + if ( i ! = axis_ ) <nl> + new_domain . push_back ( axis ( i ) ) ; <nl> + else { <nl> + / / outer loop size <nl> + Val * vo = ceilDiv ( id - > extent ( ) , fact ) ; <nl> + Int * so = static_cast < Int * > ( vo ) ; <nl> + <nl> + / / outer loop IterDomain <nl> + IterDomain * ido = new IterDomain ( <nl> + new Int ( 0 ) , so , id - > parallel_method ( ) , id - > isReduction ( ) ) ; <nl> + new_domain . push_back ( ido ) ; <nl> + <nl> + / / inner loop IterDomain <nl> + IterDomain * idi = new IterDomain ( <nl> + new Int ( 0 ) , fact , id - > parallel_method ( ) , id - > isReduction ( ) ) ; <nl> + new_domain . push_back ( idi ) ; <nl> + } <nl> + } <nl> + TensorDomain * split_td = new TensorDomain ( new_domain ) ; <nl> + Split * split_node = <nl> + new Split ( split_td , this , axis_ , fact ) ; / / For record keeping <nl> + return split_td ; <nl> + } <nl> + <nl> + / / Merge " axis " and " axis + 1 " into 1 dimension <nl> + TensorDomain * TensorDomain : : merge ( int axis_ ) { <nl> + if ( axis_ < 0 ) <nl> + axis_ + = nDims ( ) ; <nl> + <nl> + TORCH_CHECK ( <nl> + axis_ > = 0 & & axis_ + 1 < nDims ( ) , <nl> + " Trying to merge axis_ outside of TensorView ' s range . " ) ; <nl> + <nl> + IterDomain * first = axis ( axis_ ) ; <nl> + IterDomain * second = axis ( axis_ + 1 ) ; <nl> + <nl> + TORCH_CHECK ( <nl> + first - > start ( ) - > isZeroInt ( ) & & second - > start ( ) - > isZeroInt ( ) , <nl> + " Merging IterDomains with starting values that aren ' t 0 , is not supported at this time . " ) ; <nl> + TORCH_CHECK ( <nl> + first - > isReduction ( ) = = second - > isReduction ( ) , <nl> + " Merging domains requires that they ' re either both a reduction axis_ , or both an iteration axis_ . " ) ; <nl> + TORCH_CHECK ( <nl> + first - > parallel_method ( ) = = second - > parallel_method ( ) , <nl> + " Axes must have matching parallel types . " ) ; <nl> + <nl> + Val * merged_id_size = mul ( first - > extent ( ) , second - > extent ( ) ) ; <nl> + IterDomain * merged_id = new IterDomain ( <nl> + new Int ( 0 ) , <nl> + static_cast < Int * > ( merged_id_size ) , <nl> + first - > parallel_method ( ) , <nl> + first - > isReduction ( ) ) ; <nl> + <nl> + std : : vector < IterDomain * > new_domain ; <nl> + for ( decltype ( nDims ( ) ) i = 0 ; i < nDims ( ) ; i + + ) { <nl> + if ( i < axis_ | | i > axis_ + 1 ) <nl> + new_domain . push_back ( axis ( i ) ) ; <nl> + else if ( i = = axis_ ) { <nl> + new_domain . push_back ( merged_id ) ; <nl> + } <nl> + } <nl> + TensorDomain * merged_td = new TensorDomain ( new_domain ) ; <nl> + Merge * merge_node = new Merge ( merged_td , this , axis_ ) ; / / For record keeping <nl> + return merged_td ; <nl> + } <nl> + <nl> + / / Reorder axes according to map [ old_pos ] = new_pos <nl> + TensorDomain * TensorDomain : : reorder ( <nl> + const std : : unordered_map < int , int > & axis2pos_ ) { <nl> + / / START VALIDATION CHECKS <nl> + / / Eventhough these checks are already in TensorView , we want to redo them as <nl> + / / we can enter this function from other places , not through TensorView <nl> + <nl> + / / adjust based on negative values ( any negative values gets nDims added to <nl> + / / it ) <nl> + std : : unordered_map < int , int > axis2pos ; <nl> + auto ndims = nDims ( ) ; <nl> + std : : transform ( <nl> + axis2pos_ . begin ( ) , <nl> + axis2pos_ . end ( ) , <nl> + std : : inserter ( axis2pos , axis2pos . begin ( ) ) , <nl> + [ ndims ] ( std : : unordered_map < int , int > : : value_type entry ) { <nl> + return std : : unordered_map < int , int > : : value_type ( { <nl> + entry . first < 0 ? entry . first + ndims : entry . first , <nl> + entry . second < 0 ? entry . second + ndims : entry . second , <nl> + } ) ; <nl> + } ) ; <nl> + <nl> + / / Check if any adjusted values are < 0 , or > = nDims , which are invalid <nl> + bool out_of_range = std : : any_of ( <nl> + axis2pos . begin ( ) , <nl> + axis2pos . end ( ) , <nl> + [ ndims ] ( std : : unordered_map < int , int > : : value_type entry ) { <nl> + return entry . first < 0 | | entry . first > = ndims | | entry . second < 0 | | <nl> + entry . second > = ndims ; <nl> + } ) ; <nl> + <nl> + TORCH_CHECK ( <nl> + ! out_of_range , <nl> + " TensorView reorder axes are outside the number of dimensions in the TensorView . " ) <nl> + <nl> + / / Going to use sets , to see if any duplicate values are in the map . <nl> + <nl> + std : : set < int > old_pos_set ; <nl> + std : : transform ( <nl> + axis2pos . begin ( ) , <nl> + axis2pos . end ( ) , <nl> + std : : inserter ( old_pos_set , old_pos_set . begin ( ) ) , <nl> + [ ] ( std : : unordered_map < int , int > : : value_type entry ) { <nl> + return entry . first ; <nl> + } ) ; <nl> + <nl> + std : : set < int > new_pos_set ; <nl> + std : : transform ( <nl> + axis2pos . begin ( ) , <nl> + axis2pos . end ( ) , <nl> + std : : inserter ( new_pos_set , new_pos_set . begin ( ) ) , <nl> + [ ] ( std : : unordered_map < int , int > : : value_type entry ) { <nl> + return entry . first ; <nl> + } ) ; <nl> + <nl> + / / Error out if duplicate values are found . <nl> + TORCH_CHECK ( <nl> + old_pos_set . size ( ) = = axis2pos . size ( ) & & <nl> + new_pos_set . size ( ) = = axis2pos . size ( ) , <nl> + " Duplicate entries in transformation map sent to TensorView reorder . " ) ; <nl> + <nl> + / / END VALIDATION CHECKS <nl> + <nl> + / / Map to save , from previous order , to new order . <nl> + std : : vector < int > pos2axis ( ndims , - 1 ) ; <nl> + <nl> + / / Go through each old and new position , make sure they ' re within 0 - ndims <nl> + for ( std : : pair < int , int > elem : axis2pos ) { <nl> + int old_pos = elem . first ; <nl> + int new_pos = elem . second ; <nl> + <nl> + assert ( old_pos > = 0 & & old_pos < ndims & & new_pos > = 0 & & new_pos < ndims ) ; <nl> + <nl> + if ( pos2axis [ new_pos ] ! = - 1 ) <nl> + TORCH_CHECK ( false , " Reorder found duplicate destination positions . " ) ; <nl> + <nl> + pos2axis [ new_pos ] = old_pos ; <nl> + } <nl> + <nl> + std : : set < int > old_positions ( pos2axis . begin ( ) , pos2axis . end ( ) ) ; <nl> + old_positions . erase ( - 1 ) ; <nl> + <nl> + if ( old_positions . size ( ) ! = axis2pos . size ( ) ) <nl> + TORCH_INTERNAL_ASSERT ( <nl> + false , " Reorder found duplicate destination positions . " ) ; <nl> + <nl> + std : : set < int > all_positions ; <nl> + for ( decltype ( ndims ) i { 0 } ; i < ndims ; i + + ) <nl> + all_positions . insert ( i ) ; <nl> + <nl> + / / Check what positions haven ' t been specified . <nl> + std : : set < int > positions_left ; <nl> + std : : set_difference ( <nl> + all_positions . begin ( ) , <nl> + all_positions . end ( ) , <nl> + old_positions . begin ( ) , <nl> + old_positions . end ( ) , <nl> + std : : inserter ( positions_left , positions_left . end ( ) ) ) ; <nl> + <nl> + / / Fill in positions that weren ' t specified , in relative order , <nl> + / / in empty spots in the set of new positions . <nl> + / / pos2axis [ new_position ] = old_position <nl> + auto it = positions_left . begin ( ) ; / / old positions left <nl> + std : : transform ( <nl> + pos2axis . begin ( ) , pos2axis . end ( ) , pos2axis . begin ( ) , [ & it ] ( int i ) - > int { <nl> + return i = = - 1 ? * it + + : i ; <nl> + } ) ; <nl> + <nl> + std : : vector < IterDomain * > reordered_domain ; <nl> + std : : transform ( <nl> + pos2axis . begin ( ) , <nl> + pos2axis . end ( ) , <nl> + std : : back_inserter ( reordered_domain ) , <nl> + [ this ] ( int i ) - > IterDomain * { return this - > axis ( i ) ; } ) ; <nl> + <nl> + TensorDomain * reordered_td = new TensorDomain ( reordered_domain ) ; <nl> + Reorder * merge_node = new Reorder ( reordered_td , this , pos2axis ) ; <nl> + return reordered_td ; <nl> + } <nl> + <nl> + TensorDomain * TensorDomain : : rootDomain ( ) { <nl> + return TransformIter : : getRoot ( this ) ; <nl> + } <nl> + <nl> Split : : Split ( TensorDomain * _out , TensorDomain * _in , int _axis , Int * _factor ) <nl> : Expr ( ExprType : : Split ) , <nl> out_ { _out } , <nl> bool Reorder : : sameAs ( const Reorder * const other ) const { <nl> <nl> ForLoop : : ForLoop ( <nl> Val * _index , <nl> - IterDomain * _range , <nl> + IterDomain * _iter_domain , <nl> const std : : vector < Expr * > & _body , <nl> Expr * _parent_scope ) <nl> : Expr ( ExprType : : ForLoop ) , <nl> index_ { _index } , <nl> - range_ { _range } , <nl> + iter_domain_ { _iter_domain } , <nl> parent_scope_ { _parent_scope } { <nl> TORCH_INTERNAL_ASSERT ( <nl> _index - > isAnInt ( ) , <nl> " Cannot create a for loop with an index that is not an int . " ) ; <nl> addInput ( _index ) ; <nl> - addInput ( _range ) ; <nl> + addInput ( _iter_domain ) ; <nl> this - > name_ = FusionGuard : : getCurFusion ( ) - > registerExpr ( this ) ; <nl> for ( Expr * expr : _body ) <nl> body ( ) . push_back ( expr ) ; <nl> } <nl> <nl> bool ForLoop : : sameAs ( const ForLoop * other ) const { <nl> - if ( this - > range ( ) ! = other - > range ( ) ) <nl> + if ( this - > iter_domain ( ) ! = other - > iter_domain ( ) ) <nl> return false ; <nl> if ( ! ( constBody ( ) . sameAs ( other - > constBody ( ) ) ) ) <nl> return false ; <nl> bool IfThenElse : : sameAs ( const IfThenElse * other ) const { <nl> } <nl> <nl> bool TensorIndex : : sameAs ( const TensorIndex * const other ) const { <nl> - if ( size ( ) ! = other - > size ( ) ) <nl> + if ( nDims ( ) ! = other - > nDims ( ) ) <nl> return false ; <nl> <nl> if ( ! view ( ) - > sameAs ( other - > view ( ) ) ) <nl> return false ; <nl> <nl> - for ( decltype ( size ( ) ) i = 0 ; i < size ( ) ; i + + ) <nl> + for ( decltype ( nDims ( ) ) i = 0 ; i < nDims ( ) ; i + + ) <nl> if ( ! ( index ( i ) - > sameAs ( other - > index ( i ) ) ) ) <nl> return false ; <nl> <nl> bool TensorIndex : : sameAs ( const TensorIndex * const other ) const { <nl> <nl> Val * TensorIndex : : index ( int i ) const { <nl> if ( i < 0 ) <nl> - i + = size ( ) ; <nl> - assert ( i > = 0 & & i < size ( ) ) ; <nl> + i + = nDims ( ) ; <nl> + assert ( i > = 0 & & i < nDims ( ) ) ; <nl> return indices_ [ i ] ; <nl> } <nl> <nl> mmm a / torch / csrc / jit / codegen / cuda / iter_visitor . h <nl> ppp b / torch / csrc / jit / codegen / cuda / iter_visitor . h <nl> enum class ValType ; <nl> struct TORCH_CUDA_API IterVisitor : public OptOutDispatch { <nl> virtual ~ IterVisitor ( ) = default ; <nl> <nl> + using OptOutDispatch : : handle ; <nl> + <nl> IterVisitor ( ) = default ; <nl> <nl> IterVisitor ( const IterVisitor & other ) = default ; <nl> struct TORCH_CUDA_API IterVisitor : public OptOutDispatch { <nl> std : : vector < Statement * > next ( Expr * expr ) ; <nl> std : : vector < Statement * > next ( Val * v ) ; <nl> <nl> - void handle ( Statement * s ) { <nl> + virtual void handle ( Statement * s ) { <nl> OptOutDispatch : : handle ( s ) ; <nl> } <nl> - void handle ( Expr * e ) { <nl> + virtual void handle ( Expr * e ) { <nl> OptOutDispatch : : handle ( e ) ; <nl> } <nl> - void handle ( Val * v ) { <nl> + virtual void handle ( Val * v ) { <nl> OptOutDispatch : : handle ( v ) ; <nl> } <nl> <nl> struct TORCH_CUDA_API DependencyCheck : public IterVisitor { <nl> <nl> / / when handle is called on val , we know 2 things . Val is a dependency of of . <nl> / / and dep_chain contains the values in between of and dependency . <nl> - void handle ( Val * val ) ; <nl> + void handle ( Val * val ) override ; <nl> <nl> / / When we handle an expr we pop off its outputs from the dep_chain <nl> - void handle ( Expr * expr ) ; <nl> + void handle ( Expr * expr ) override ; <nl> <nl> / / When we visit an Expr we place its outputs on the dep_chain <nl> void toVisitCallback ( Statement * stmt ) ; <nl> mmm a / torch / csrc / jit / codegen / cuda / kernel . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / kernel . cpp <nl> <nl> - # include < torch / csrc / jit / codegen / cuda / kernel . h > <nl> - # include < torch / csrc / jit / codegen / cuda / lower2device . h > <nl> - # include < iostream > <nl> - <nl> # include < ATen / cuda / CUDAContext . h > <nl> # include < ATen / cuda / nvrtc_stub / ATenNVRTC . h > <nl> + # include < c10 / core / ScalarType . h > <nl> # include < c10 / cuda / CUDACachingAllocator . h > <nl> + # include < c10 / util / ArrayRef . h > <nl> + <nl> + # include < torch / csrc / jit / codegen / cuda / kernel . h > <nl> + # include < torch / csrc / jit / codegen / cuda / kernel_arg . h > <nl> + # include < torch / csrc / jit / codegen / cuda / kernel_resource_strings . h > <nl> + # include < torch / csrc / jit / codegen / cuda / lower2device . h > <nl> + <nl> # include < torch / csrc / jit / resource_guard . h > <nl> + # include < iostream > <nl> <nl> namespace torch { <nl> namespace jit { <nl> static int ceilDiv ( const int a , const int b ) { <nl> return ( a + b - 1 ) / b ; <nl> } <nl> <nl> + / / Go through a tensor , and grab it ' s sizes / strides potentially broadcasted <nl> + struct ExtractSizeStride { <nl> + std : : vector < int64_t > sizes ; <nl> + std : : vector < int64_t > strides ; <nl> + <nl> + ExtractSizeStride ( <nl> + const at : : Tensor & val , <nl> + c10 : : optional < at : : IntArrayRef > broadcasted_size = c10 : : nullopt ) { <nl> + if ( broadcasted_size ) { <nl> + int b_dim = ( int ) broadcasted_size - > size ( ) ; <nl> + int o_dim = ( int ) val . dim ( ) ; <nl> + TORCH_CHECK ( b_dim > = o_dim ) ; <nl> + for ( int i = 0 ; i < b_dim ; i + + ) { <nl> + sizes . push_back ( broadcasted_size - > at ( i ) ) ; <nl> + int index = i + o_dim - b_dim ; <nl> + if ( index < 0 ) { <nl> + strides . push_back ( 0 ) ; <nl> + } else if ( val . sizes ( ) [ index ] = = sizes [ i ] ) { <nl> + strides . push_back ( val . strides ( ) [ index ] ) ; <nl> + } else { <nl> + TORCH_CHECK ( <nl> + val . sizes ( ) [ index ] = = 1 , <nl> + " Not compatible dimension size for broadcast " ) ; <nl> + strides . push_back ( 0 ) ; <nl> + } <nl> + } <nl> + } else { <nl> + auto o_dim = val . dim ( ) ; <nl> + for ( decltype ( val . dim ( ) ) i { 0 } ; i < o_dim ; i + + ) { <nl> + sizes . push_back ( val . sizes ( ) [ i ] ) ; <nl> + strides . push_back ( val . strides ( ) [ i ] ) ; <nl> + } <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + struct KernelArgumentHolder { <nl> + private : <nl> + std : : vector < ArgAbstract * > arguments ; <nl> + std : : vector < void * > void_ptrs ; <nl> + bool changed = true ; <nl> + <nl> + public : <nl> + virtual ~ KernelArgumentHolder ( ) { <nl> + for ( auto arg : arguments ) <nl> + delete arg ; <nl> + } <nl> + <nl> + / / Push a tensor to the arguments <nl> + void push ( <nl> + const at : : Tensor & val , <nl> + c10 : : optional < at : : IntArrayRef > broadcasted_size = c10 : : nullopt ) { <nl> + changed = true ; <nl> + ExtractSizeStride ess ( val , std : : move ( broadcasted_size ) ) ; <nl> + int nDims = ess . sizes . size ( ) ; <nl> + <nl> + c10 : : ScalarType dtype = val . scalar_type ( ) ; <nl> + TensorArgAbstract * tensor_arg = getTensorArg ( dtype , nDims ) ; <nl> + tensor_arg - > setPointer ( val . data_ptr ( ) ) ; <nl> + for ( int i = 0 ; i < nDims ; i + + ) { <nl> + tensor_arg - > setSize ( i , ess . sizes [ i ] ) ; <nl> + tensor_arg - > setStride ( i , ess . strides [ i ] ) ; <nl> + } <nl> + arguments . push_back ( tensor_arg ) ; <nl> + } <nl> + <nl> + / / Push a scalar or integer to the arguments <nl> + void push ( const IValue & val ) { <nl> + changed = true ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + val . isScalar ( ) , <nl> + " Tried to push an arg to run in a fused kernel , expected a scalar but got , " , <nl> + val ) ; <nl> + switch ( val . toScalar ( ) . type ( ) ) { <nl> + case ( c10 : : ScalarType : : Double ) : <nl> + arguments . push_back ( new FloatArg ( ( float ) val . toDouble ( ) ) ) ; <nl> + return ; <nl> + case ( c10 : : ScalarType : : Long ) : <nl> + arguments . push_back ( new IntArg ( ( int ) val . toInt ( ) ) ) ; <nl> + return ; <nl> + default : <nl> + TORCH_INTERNAL_ASSERT ( <nl> + false , <nl> + " Tried to create argument to send to a fused kernel , but got an unexpected type . " ) ; <nl> + } <nl> + TORCH_INTERNAL_ASSERT ( <nl> + false , <nl> + " Tried to create argument to send to a fused kernel , but got a non - scalar type . " ) ; <nl> + } <nl> + <nl> + / / Create buffer , flatten arguments into it , align by 8 Bytes , return pointers <nl> + / / in the buffer <nl> + void * * getBuffer ( ) { <nl> + if ( changed ) { <nl> + void_ptrs = std : : vector < void * > ( arguments . size ( ) , nullptr ) ; <nl> + for ( decltype ( arguments . size ( ) ) i { 0 } ; i < arguments . size ( ) ; i + + ) <nl> + void_ptrs [ i ] = static_cast < void * > ( arguments [ i ] - > arg ( ) ) ; <nl> + changed = false ; <nl> + } <nl> + return void_ptrs . data ( ) ; <nl> + } <nl> + } ; <nl> + <nl> std : : pair < std : : string , std : : string > codeGeneration ( Fusion & fusion ) { <nl> std : : stringstream str_stream ; <nl> - <nl> - str_stream < < " namespace " < < CG_NAMESPACE < < " { \ n " < < typeinfo < < " \ n " ; <nl> + str_stream < < " namespace " < < CG_NAMESPACE < < " { \ n " <nl> + < < code_template_tensor_struct < < " \ n " ; <nl> std : : stringstream cdg ; <nl> GPULower gpulw ( & fusion ) ; <nl> gpulw . printKernel ( str_stream , KERNEL_NAME ) ; <nl> str_stream < < " \ n } / / namespace " ; <nl> <nl> std : : string func_name = std : : string ( CG_NAMESPACE ) + " : : " + KERNEL_NAME ; <nl> - <nl> return std : : make_pair ( func_name , str_stream . str ( ) ) ; <nl> } ; <nl> <nl> - void prepare_argument ( <nl> - std : : vector < void * > & arguments , <nl> - std : : vector < Tensor < float > > & tensor_args , <nl> - const at : : Tensor & val ) { <nl> - tensor_args . emplace_back ( ) ; <nl> - Tensor < float > & t = tensor_args . back ( ) ; <nl> - / / passing address , type doesn ' t really matter here ; <nl> - t . data = static_cast < float * > ( val . data_ptr ( ) ) ; <nl> - <nl> - for ( decltype ( val . dim ( ) ) i { 0 } ; i < val . dim ( ) ; i + + ) { <nl> - t . size [ i ] = val . sizes ( ) [ i ] ; <nl> - t . stride [ i ] = val . strides ( ) [ i ] ; <nl> - } <nl> - <nl> - arguments . push_back ( & ( tensor_args . back ( ) ) ) ; <nl> - } ; <nl> + } / / namespace <nl> <nl> - void prepare_argument ( <nl> - std : : vector < void * > & arguments , <nl> - std : : vector < Tensor < float > > & tensor_args , <nl> - std : : vector < int > & int_args , <nl> - std : : vector < float > & float_args , <nl> - const IValue & val ) { <nl> - if ( val . isTensor ( ) ) { <nl> - prepare_argument ( arguments , tensor_args , val . toTensor ( ) ) ; <nl> - } else if ( val . isDouble ( ) ) { <nl> - float_args . push_back ( val . to < float > ( ) ) ; <nl> - arguments . push_back ( & ( float_args . back ( ) ) ) ; <nl> - } else if ( val . isInt ( ) ) { <nl> - int_args . push_back ( val . to < int > ( ) ) ; <nl> - arguments . push_back ( & ( int_args . back ( ) ) ) ; <nl> - } else { <nl> - TORCH_CHECK ( false , " Not supported input IValue encounted . " ) ; <nl> + bool KernelArgsReq : : matchKernelSize ( const at : : IntArrayRef inputs ) { <nl> + if ( inputs . size ( ) ! = low_ . size ( ) ) { <nl> + return false ; <nl> } <nl> - } ; <nl> - <nl> - } / / namespace <nl> + for ( decltype ( inputs . size ( ) ) i { 0 } ; i < inputs . size ( ) ; i + + ) { <nl> + if ( inputs [ i ] < low_ [ i ] | | inputs [ i ] > hi_ [ i ] ) { <nl> + return false ; <nl> + } <nl> + } <nl> + return true ; <nl> + } <nl> <nl> - void compileKernel ( Fusion & fusion , CudaKernel & entry ) { <nl> + void compileKernel ( Fusion & fusion , CudaKernel * entry ) { <nl> / / generating cuda code ; <nl> std : : string code ; <nl> std : : string func_name ; <nl> void compileKernel ( Fusion & fusion , CudaKernel & entry ) { <nl> <nl> / / set device for the operation ; <nl> const auto prior_device = at : : cuda : : current_device ( ) ; <nl> - at : : cuda : : set_device ( entry . device_ ) ; <nl> + at : : cuda : : set_device ( entry - > device_ ) ; <nl> <nl> const auto prop = at : : cuda : : getCurrentDeviceProperties ( ) ; <nl> int nvrtc_major , nvrtc_minor ; <nl> AT_CUDA_NVRTC_CHECK ( nvrtc ( ) . nvrtcVersion ( & nvrtc_major , & nvrtc_minor ) ) ; <nl> <nl> / / Short - circuits if NVRTC version too low <nl> - AT_ASSERT ( nvrtc_major > = 6 ) ; <nl> + TORCH_INTERNAL_ASSERT ( nvrtc_major > = 6 ) ; <nl> / / Major and minor is determined by device properties and <nl> / / possibly " downcompiled " to a lower ( compatible ) compute architecture <nl> / / based on the NVRTC version <nl> void compileKernel ( Fusion & fusion , CudaKernel & entry ) { <nl> ptx . resize ( ptx_size ) ; <nl> AT_CUDA_NVRTC_CHECK ( nvrtc ( ) . nvrtcGetPTX ( program , ptx . data ( ) ) ) ; <nl> <nl> - AT_CUDA_DRIVER_CHECK ( nvrtc ( ) . cuModuleLoadData ( & ( entry . module_ ) , ptx . data ( ) ) ) ; <nl> + AT_CUDA_DRIVER_CHECK ( nvrtc ( ) . cuModuleLoadData ( & ( entry - > module_ ) , ptx . data ( ) ) ) ; <nl> AT_CUDA_DRIVER_CHECK ( nvrtc ( ) . cuModuleGetFunction ( <nl> - & ( entry . function_ ) , entry . module_ , lowered_kernel_name ) ) ; <nl> + & ( entry - > function_ ) , entry - > module_ , lowered_kernel_name ) ) ; <nl> AT_CUDA_DRIVER_CHECK ( nvrtc ( ) . cuOccupancyMaxActiveBlocksPerMultiprocessor ( <nl> - & entry . max_blocks_ , entry . function_ , 128 , 0 ) ) ; <nl> - entry . max_blocks_ * = prop - > multiProcessorCount ; <nl> + & entry - > max_blocks_ , entry - > function_ , 128 , 0 ) ) ; <nl> + entry - > max_blocks_ * = prop - > multiProcessorCount ; <nl> } <nl> <nl> void runKernel ( <nl> - CudaKernel & entry , <nl> + CudaKernel * entry , <nl> const at : : ArrayRef < IValue > & inputs , <nl> std : : vector < at : : Tensor > & outputs ) { <nl> const auto prior_device = at : : cuda : : current_device ( ) ; <nl> - at : : cuda : : set_device ( entry . device_ ) ; <nl> + at : : cuda : : set_device ( entry - > device_ ) ; <nl> auto stream = at : : cuda : : getCurrentCUDAStream ( ) ; <nl> <nl> / / TODO : Proper API to establish reasonable launch configurations ; <nl> / / Naive launch config ; <nl> size_t numel = outputs [ 0 ] . numel ( ) ; <nl> - const auto nBlocks = std : : min ( entry . max_blocks_ , ceilDiv ( numel , 128 ) ) ; <nl> - <nl> - / / TODO : Proper API to tranform JIT I / O Tensor to CodeGen I / O Tensor <nl> - std : : vector < void * > arguments ; <nl> - <nl> - / / TODO : There are better ways to do this ; <nl> - / / argument holder ; <nl> - / / host code , ` T ` in ` Tensor < T > ` doesn ' t really matter , as we only interact <nl> - / / with the address ; Just put a float here to simply the argument holder . <nl> - auto max_capacity = inputs . size ( ) + outputs . size ( ) ; <nl> - std : : vector < Tensor < float > > tensor_args ; <nl> - std : : vector < int > int_args ; <nl> - std : : vector < float > float_args ; <nl> - tensor_args . reserve ( max_capacity ) ; <nl> - int_args . reserve ( max_capacity ) ; <nl> - float_args . reserve ( max_capacity ) ; <nl> + <nl> + / / TODO : we can ' t randomly clap down this until we got striding . <nl> + / / const auto nBlocks = std : : min ( entry - > max_blocks_ , ceilDiv ( numel , 128 ) ) ; <nl> + const auto nBlocks = ceilDiv ( numel , 128 ) ; <nl> + <nl> + KernelArgumentHolder kernel_args ; <nl> <nl> / / Naive I / O setup , I ' m ignoring all the potential transformation ( i . e . I / O <nl> / / allocated here from the subgraph could be , and very likely are , different <nl> / / from I / O expected by the generated CUDA kernel . <nl> for ( auto & input : inputs ) { <nl> - prepare_argument ( arguments , tensor_args , int_args , float_args , input ) ; <nl> + if ( input . isTensor ( ) ) { <nl> + kernel_args . push ( input . toTensor ( ) , outputs [ 0 ] . sizes ( ) ) ; <nl> + } else { <nl> + kernel_args . push ( input ) ; <nl> + } <nl> } <nl> + <nl> for ( auto & output : outputs ) { <nl> - prepare_argument ( arguments , tensor_args , output ) ; <nl> + kernel_args . push ( output ) ; <nl> } <nl> <nl> / / launch kernel ; <nl> AT_CUDA_DRIVER_CHECK ( nvrtc ( ) . cuLaunchKernel ( <nl> - entry . function_ , <nl> + entry - > function_ , <nl> nBlocks , <nl> 1 , <nl> 1 , <nl> void runKernel ( <nl> 1 , <nl> 0 , <nl> stream , <nl> - arguments . data ( ) , <nl> + kernel_args . getBuffer ( ) , <nl> nullptr ) ) ; <nl> <nl> / / Resets device ( see at : : DeviceGuard notes above ) <nl> at : : cuda : : set_device ( prior_device ) ; <nl> - <nl> - / * <nl> - for ( auto & output : outputs ) { <nl> - output . fill_ ( 0 . 24 ) ; <nl> - } <nl> - * / <nl> } <nl> <nl> / / WARNING : <nl> void runTestKernel ( <nl> at : : cuda : : set_device ( entry . device_ ) ; <nl> auto stream = at : : cuda : : getCurrentCUDAStream ( ) ; <nl> <nl> - / / TODO : Proper API to tranform JIT I / O Tensor to CodeGen I / O Tensor <nl> - std : : vector < void * > arguments ; <nl> - <nl> - / / TODO : There are better ways to do this ; <nl> - / / argument holder ; <nl> - / / host code , ` T ` in ` Tensor < T > ` doesn ' t really matter , as we only interact <nl> - / / with the address ; Just put a float here to simply the argument holder . <nl> - auto max_capacity = inputs . size ( ) + outputs . size ( ) ; <nl> - std : : vector < Tensor < float > > tensor_args ; <nl> - std : : vector < int > int_args ; <nl> - std : : vector < float > float_args ; <nl> - tensor_args . reserve ( max_capacity ) ; <nl> - int_args . reserve ( max_capacity ) ; <nl> - float_args . reserve ( max_capacity ) ; <nl> + KernelArgumentHolder kernel_args ; <nl> <nl> / / Naive I / O setup , I ' m ignoring all the potential transformation ( i . e . I / O <nl> / / allocated here from the subgraph could be , and very likely are , different <nl> / / from I / O expected by the generated CUDA kernel . <nl> for ( auto & input : inputs ) { <nl> - prepare_argument ( arguments , tensor_args , input ) ; <nl> + kernel_args . push ( input , outputs [ 0 ] . sizes ( ) ) ; <nl> } <nl> + <nl> for ( auto & output : outputs ) { <nl> - prepare_argument ( arguments , tensor_args , output ) ; <nl> + kernel_args . push ( output ) ; <nl> } <nl> <nl> / / launch kernel ; <nl> void runTestKernel ( <nl> entry . block_ . z , <nl> 0 , <nl> stream , <nl> - arguments . data ( ) , <nl> + kernel_args . getBuffer ( ) , <nl> nullptr ) ) ; <nl> <nl> / / Resets device ( see at : : DeviceGuard notes above ) <nl> mmm a / torch / csrc / jit / codegen / cuda / kernel . h <nl> ppp b / torch / csrc / jit / codegen / cuda / kernel . h <nl> namespace jit { <nl> namespace fuser { <nl> namespace cuda { <nl> <nl> - / / include IO data structure for host code <nl> - # define STRINGIFY ( . . . ) __VA_ARGS__ <nl> - # include < torch / csrc / jit / codegen / cuda / data_struct_str . h > <nl> - # undef STRINGIFY <nl> + / / Not checking explicit broadcasting yet . <nl> + / / check only shape falls in the range ; <nl> + struct KernelArgsReq { <nl> + / / We are checking accumulated output shape for now , this is a restricting <nl> + / / aproach , we should check applicability on input tensor shapes instead . <nl> + bool matchKernelSize ( const c10 : : IntArrayRef inputs ) ; <nl> + std : : vector < size_t > low_ ; <nl> + std : : vector < size_t > hi_ ; <nl> + } ; <nl> <nl> class CudaKernel { <nl> public : <nl> class CudaKernel { <nl> dim3 grid_ ; <nl> } ; <nl> <nl> - / / include IO data structure for stringification <nl> - # define STRINGIFY ( . . . ) # __VA_ARGS__ <nl> - static auto typeinfo = <nl> - # include " data_struct_str . h " <nl> - ; <nl> - # undef STRINGIFY <nl> - <nl> / / compile Fusion to CUDA functions : <nl> / / 1 . JIT compilation via nvrtc to generate CUDA c + + kernel code ; <nl> / / 2 . CUDA Drive API to load CUDA c + + kernel code as function_ ; <nl> - TORCH_CUDA_API void compileKernel ( Fusion & fusion , CudaKernel & entry ) ; <nl> + TORCH_CUDA_API void compileKernel ( Fusion & fusion , CudaKernel * entry ) ; <nl> <nl> / / run loaded kernel through Function . <nl> / / inputs / outputs is given in the sense of a PyTorch JIT ir node . This function <nl> / / wraps IO data structure for tensors on host . <nl> TORCH_CUDA_API void runKernel ( <nl> - CudaKernel & entry , <nl> + CudaKernel * entry , <nl> const at : : ArrayRef < IValue > & inputs , <nl> std : : vector < at : : Tensor > & outputs ) ; <nl> <nl> new file mode 100644 <nl> index 000000000000 . . 51a588dcea98 <nl> mmm / dev / null <nl> ppp b / torch / csrc / jit / codegen / cuda / kernel_arg . h <nl> <nl> + # pragma once <nl> + <nl> + # include < c10 / core / ScalarType . h > <nl> + <nl> + namespace torch { <nl> + namespace jit { <nl> + namespace fuser { <nl> + namespace cuda { <nl> + <nl> + / / This should match the tensor used in the code generation ( almost exactly ) <nl> + template < typename T , int N > <nl> + struct TensorArgCodegen { <nl> + T & operator [ ] ( int64_t ind ) { <nl> + return data [ ind ] ; <nl> + } ; <nl> + <nl> + T * data ; <nl> + int64_t size [ N ] ; <nl> + int64_t stride [ N ] ; <nl> + constexpr int nDims ( ) { <nl> + return N ; <nl> + } <nl> + } ; <nl> + <nl> + struct ArgAbstract { <nl> + virtual ~ ArgAbstract ( ) { } <nl> + virtual void * arg ( ) = 0 ; <nl> + } ; <nl> + <nl> + struct IntArg : public ArgAbstract { <nl> + int val_ ; <nl> + IntArg ( int _val ) : val_ ( _val ) { } ; <nl> + void * arg ( ) { <nl> + return & val_ ; <nl> + } <nl> + } ; <nl> + <nl> + struct FloatArg : public ArgAbstract { <nl> + float val_ ; <nl> + FloatArg ( float _val ) : val_ ( _val ) { } ; <nl> + void * arg ( ) { <nl> + return & val_ ; <nl> + } <nl> + } ; <nl> + <nl> + struct TensorArgAbstract : ArgAbstract { <nl> + virtual ~ TensorArgAbstract ( ) { } ; <nl> + virtual void setSize ( int i , int64_t size ) = 0 ; <nl> + virtual void setStride ( int i , int64_t stride ) = 0 ; <nl> + virtual void setPointer ( void * ptr ) = 0 ; <nl> + } ; <nl> + <nl> + / / This should match the tensor used in the code generation ( almost exactly ) <nl> + template < typename TENSOR_TYPE > <nl> + struct TensorArg : public TensorArgAbstract { <nl> + TENSOR_TYPE instance_ ; <nl> + <nl> + void setSize ( int i , int64_t size ) override { <nl> + instance_ . size [ i ] = size ; <nl> + } <nl> + void setStride ( int i , int64_t stride ) override { <nl> + instance_ . stride [ i ] = stride ; <nl> + } <nl> + void setPointer ( void * ptr ) override { <nl> + instance_ . data = static_cast < decltype ( TENSOR_TYPE : : data ) > ( ptr ) ; <nl> + } <nl> + <nl> + void * arg ( ) override { <nl> + return & instance_ ; <nl> + } <nl> + } ; <nl> + <nl> + template < typename T > <nl> + TensorArgAbstract * getTensorArg ( int nDims ) { <nl> + switch ( nDims ) { <nl> + case ( 1 ) : <nl> + return new TensorArg < TensorArgCodegen < T , 1 > > ( ) ; <nl> + case ( 2 ) : <nl> + return new TensorArg < TensorArgCodegen < T , 2 > > ( ) ; <nl> + case ( 3 ) : <nl> + return new TensorArg < TensorArgCodegen < T , 3 > > ( ) ; <nl> + case ( 4 ) : <nl> + return new TensorArg < TensorArgCodegen < T , 4 > > ( ) ; <nl> + case ( 5 ) : <nl> + return new TensorArg < TensorArgCodegen < T , 5 > > ( ) ; <nl> + case ( 6 ) : <nl> + return new TensorArg < TensorArgCodegen < T , 6 > > ( ) ; <nl> + case ( 7 ) : <nl> + return new TensorArg < TensorArgCodegen < T , 7 > > ( ) ; <nl> + case ( 8 ) : <nl> + return new TensorArg < TensorArgCodegen < T , 8 > > ( ) ; <nl> + default : <nl> + TORCH_INTERNAL_ASSERT ( <nl> + false , <nl> + " Tried to gerneate a tensor to run a generated kernel with " , <nl> + nDims , <nl> + " dimensions , however it must be a 1 - 8 dimensional tensor . " ) ; <nl> + } <nl> + } <nl> + <nl> + TensorArgAbstract * getTensorArg ( c10 : : ScalarType dtype , int nDims ) { <nl> + switch ( dtype ) { <nl> + case ( at : : kFloat ) : <nl> + return getTensorArg < float > ( nDims ) ; <nl> + default : <nl> + TORCH_CHECK ( <nl> + false , <nl> + " Dtype : " , <nl> + dtype , <nl> + " not currently supported in code generated kernels . " ) ; <nl> + } <nl> + } <nl> + <nl> + } / / namespace cuda <nl> + } / / namespace fuser <nl> + } / / namespace jit <nl> + } / / namespace torch <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 717fb914c846 <nl> mmm / dev / null <nl> ppp b / torch / csrc / jit / codegen / cuda / kernel_cache . cpp <nl> <nl> + # include < torch / csrc / jit / codegen / cuda / kernel_cache . h > <nl> + <nl> + / * <nl> + * / <nl> + <nl> + namespace torch { <nl> + namespace jit { <nl> + namespace fuser { <nl> + namespace cuda { <nl> + <nl> + at : : optional < CudaKernel * > CudaKernelCache : : getKernelPtr ( <nl> + c10 : : IntArrayRef sizes ) { <nl> + for ( auto & iter : kernels_ ) { <nl> + if ( iter . first . matchKernelSize ( sizes ) ) { <nl> + return & ( iter . second ) ; <nl> + } <nl> + } <nl> + return at : : nullopt ; <nl> + } <nl> + <nl> + CudaKernel * CudaKernelCache : : allocateKernelInCache ( KernelArgsReq args_req ) { <nl> + kernels_ . emplace_back ( std : : make_pair ( std : : move ( args_req ) , CudaKernel ( ) ) ) ; <nl> + return & ( kernels_ . back ( ) . second ) ; <nl> + } <nl> + <nl> + } / / namespace cuda <nl> + } / / namespace fuser <nl> + } / / namespace jit <nl> + } / / namespace torch <nl> new file mode 100644 <nl> index 000000000000 . . 2d1276a0ed21 <nl> mmm / dev / null <nl> ppp b / torch / csrc / jit / codegen / cuda / kernel_cache . h <nl> <nl> + # pragma once <nl> + <nl> + # include < c10 / util / ArrayRef . h > <nl> + # include < torch / csrc / WindowsTorchApiMacro . h > <nl> + <nl> + # include < torch / csrc / jit / codegen / cuda / kernel . h > <nl> + <nl> + / * <nl> + * / <nl> + <nl> + namespace torch { <nl> + namespace jit { <nl> + namespace fuser { <nl> + namespace cuda { <nl> + <nl> + class CudaKernelCache { <nl> + public : <nl> + CudaKernelCache ( ) = default ; <nl> + <nl> + at : : optional < CudaKernel * > getKernelPtr ( c10 : : IntArrayRef sizes ) ; <nl> + CudaKernel * allocateKernelInCache ( KernelArgsReq args_req ) ; <nl> + <nl> + / / private : <nl> + / / TODO : In theory we should assume contiguity remain constant across runs <nl> + / / ( job for BailOut node from profiling executor ) . In reality we might <nl> + / / want to be safe and cache on that as well . <nl> + / / Assuming constant nDims . Cache of kernels targetting different tensor size ; <nl> + / / We should flatten <nl> + std : : vector < std : : pair < KernelArgsReq , CudaKernel > > kernels_ ; <nl> + } ; <nl> + <nl> + } / / namespace cuda <nl> + } / / namespace fuser <nl> + } / / namespace jit <nl> + } / / namespace torch <nl> new file mode 100644 <nl> index 000000000000 . . d074355ee6dc <nl> mmm / dev / null <nl> ppp b / torch / csrc / jit / codegen / cuda / kernel_resource_strings . h <nl> <nl> + namespace torch { <nl> + namespace jit { <nl> + namespace fuser { <nl> + namespace cuda { <nl> + <nl> + / / IO data structure for kernel code ; <nl> + static auto code_template_tensor_struct = R " ( <nl> + typedef unsigned char uint8_t ; <nl> + typedef signed char int8_t ; <nl> + typedef short int int16_t ; <nl> + typedef long long int int64_t ; <nl> + <nl> + template < typename T , int N > <nl> + struct Tensor { <nl> + T & operator [ ] ( int64_t ind ) { <nl> + return data [ ind ] ; <nl> + } ; <nl> + <nl> + T * data ; <nl> + int64_t size [ N ] ; <nl> + int64_t stride [ N ] ; <nl> + } ; <nl> + ) " ; <nl> + <nl> + } / / namespace cuda <nl> + } / / namespace fuser <nl> + } / / namespace jit <nl> + } / / namespace torch <nl> \ No newline at end of file <nl> mmm a / torch / csrc / jit / codegen / cuda / lower2device . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / lower2device . cpp <nl> <nl> + # include < torch / csrc / jit / codegen / cuda / arith . h > <nl> # include < torch / csrc / jit / codegen / cuda / fusion . h > <nl> - # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> + # include < torch / csrc / jit / codegen / cuda / index_compute . h > <nl> + # include < torch / csrc / jit / codegen / cuda / ir_iostream . h > <nl> + # include < torch / csrc / jit / codegen / cuda / lower_loops . h > <nl> + # include < torch / csrc / jit / codegen / cuda / lower_utils . h > <nl> # include < torch / csrc / jit / codegen / cuda / mutator . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> + # include < torch / csrc / jit / codegen / cuda / predicate_compute . h > <nl> + # include < torch / csrc / jit / codegen / cuda / transform_iter . h > <nl> # include < torch / csrc / jit / codegen / cuda / transform_replay . h > <nl> # include < torch / csrc / jit / codegen / cuda / type . h > <nl> <nl> namespace torch { <nl> namespace jit { <nl> namespace fuser { <nl> <nl> - / / START HELPER FUNCTIONS <nl> - namespace { <nl> - <nl> - bool isTV ( const Val * const val ) { <nl> - return val - > getValType ( ) . value ( ) = = ValType : : TensorView ; <nl> - } <nl> - <nl> - / / Check if we ' re a TensorView op that we can generate code for . <nl> - bool isTVOp ( const Expr * expr ) { <nl> - if ( expr - > nOutputs ( ) = = 1 & & isTV ( expr - > output ( 0 ) ) & & <nl> - ( expr - > getExprType ( ) . value ( ) = = ExprType : : BinaryOp | | <nl> - expr - > getExprType ( ) . value ( ) = = ExprType : : UnaryOp ) ) <nl> - return true ; <nl> - return false ; <nl> - } <nl> - <nl> - TensorView * asTV ( Val * val ) { <nl> - TORCH_INTERNAL_ASSERT ( isTV ( val ) ) ; <nl> - return static_cast < TensorView * > ( val ) ; <nl> - } <nl> - <nl> - const TensorView * asConstTV ( const Val * const val ) { <nl> - TORCH_INTERNAL_ASSERT ( isTV ( val ) ) ; <nl> - return static_cast < const TensorView * > ( val ) ; <nl> - } <nl> - <nl> - struct parentScope_ : private OptInDispatch { <nl> - private : <nl> - Expr * parent_ = nullptr ; <nl> - <nl> - void handle ( ForLoop * fl ) final { <nl> - parent_ = fl - > parentScope ( ) ; <nl> - } <nl> - <nl> - void handle ( IfThenElse * ite ) final { <nl> - parent_ = ite - > parentScope ( ) ; <nl> - } <nl> - <nl> - void handle ( Expr * expr ) final { <nl> - OptInDispatch : : handle ( expr ) ; <nl> - } <nl> - <nl> - public : <nl> - static Expr * parent ( Expr * scope ) { <nl> - parentScope_ sp ; <nl> - sp . handle ( scope ) ; <nl> - return sp . parent_ ; <nl> - } <nl> - } ; <nl> - <nl> - struct forLoopCount : private OptInDispatch { <nl> - private : <nl> - unsigned int count_ = 0 ; <nl> - <nl> - void handle ( ForLoop * fl ) final { <nl> - count_ + + ; <nl> - } <nl> - <nl> - void handle ( IfThenElse * ite ) final { } <nl> - <nl> - void handle ( Expr * expr ) final { <nl> - OptInDispatch : : handle ( expr ) ; <nl> - } <nl> - <nl> - public : <nl> - static unsigned int count ( Expr * scope ) { <nl> - forLoopCount flc ; <nl> - Expr * it = scope ; <nl> - while ( it ! = nullptr ) { <nl> - flc . handle ( it ) ; <nl> - it = parentScope_ : : parent ( it ) ; <nl> - } <nl> - return flc . count_ ; <nl> - } <nl> - } ; <nl> - <nl> - struct scopePushBack : private OptInDispatch { <nl> - private : <nl> - Expr * _expr = nullptr ; <nl> - void handle ( ForLoop * fl ) final { <nl> - fl - > body ( ) . push_back ( _expr ) ; <nl> - } <nl> - <nl> - void handle ( IfThenElse * ite ) final { <nl> - ite - > body ( ) . push_back ( _expr ) ; <nl> - } <nl> - <nl> - void handle ( Expr * expr ) final { <nl> - OptInDispatch : : handle ( expr ) ; <nl> - } <nl> - <nl> - public : <nl> - static void pushBack ( Expr * scope , Expr * expr ) { <nl> - scopePushBack pb ; <nl> - TORCH_INTERNAL_ASSERT ( <nl> - expr ! = nullptr & & scope ! = nullptr , <nl> - " Cannot push back , scope or expr is a nullptr . " ) ; <nl> - pb . _expr = expr ; <nl> - pb . handle ( scope ) ; <nl> - } <nl> - } ; <nl> - <nl> - struct forLoopIndices : private OptInDispatch { <nl> - private : <nl> - std : : vector < Val * > inds_ ; <nl> - void handle ( ForLoop * fl ) final { <nl> - inds_ . insert ( inds_ . begin ( ) , fl - > index ( ) ) ; <nl> - } <nl> - <nl> - void handle ( IfThenElse * ite ) final { } <nl> - <nl> - void handle ( Expr * expr ) final { <nl> - OptInDispatch : : handle ( expr ) ; <nl> - } <nl> - <nl> - public : <nl> - static std : : vector < Val * > get ( Expr * scope ) { <nl> - forLoopIndices fli ; <nl> - Expr * it = scope ; <nl> - while ( it ! = nullptr ) { <nl> - fli . handle ( it ) ; <nl> - it = parentScope_ : : parent ( it ) ; <nl> - } <nl> - return fli . inds_ ; <nl> - } <nl> - } ; <nl> - <nl> - struct forLoopIDs : private OptInDispatch { <nl> - private : <nl> - std : : vector < IterDomain * > IDs_ ; <nl> - void handle ( ForLoop * fl ) final { <nl> - IDs_ . insert ( IDs_ . begin ( ) , fl - > range ( ) ) ; <nl> - } <nl> - <nl> - void handle ( IfThenElse * ite ) final { } <nl> - <nl> - void handle ( Expr * expr ) final { <nl> - OptInDispatch : : handle ( expr ) ; <nl> - } <nl> - <nl> - public : <nl> - static std : : vector < IterDomain * > get ( Expr * scope ) { <nl> - forLoopIDs fli ; <nl> - Expr * it = scope ; <nl> - while ( it ! = nullptr ) { <nl> - fli . handle ( it ) ; <nl> - it = parentScope_ : : parent ( it ) ; <nl> - } <nl> - return fli . IDs_ ; <nl> - } <nl> - } ; <nl> - <nl> - } / / namespace <nl> - / / END HELPER FUNCTIONS <nl> - <nl> - / / Open a new inner most for loop <nl> - void GPULower : : openFor ( IterDomain * id ) { <nl> - ForLoop * new_scope = nullptr ; <nl> - if ( id - > isThread ( ) ) { <nl> - new_scope = new ForLoop ( <nl> - new NamedScalar ( stringify ( id - > parallel_method ( ) ) , DataType : : Int ) , <nl> - id , <nl> - { } , <nl> - active_scope ) ; <nl> - } else { <nl> - new_scope = new ForLoop ( new Int ( ) , id , { } , active_scope ) ; <nl> - } <nl> - pushBack ( new_scope ) ; <nl> - active_scope = new_scope ; <nl> - } <nl> - <nl> - / / Close the inner most scope <nl> - void GPULower : : closeScope ( ) { <nl> - TORCH_INTERNAL_ASSERT ( <nl> - active_scope ! = nullptr , <nl> - " Tried to close the active scope , but there isn ' t one set . " ) ; <nl> - Expr * parent = parentScope_ : : parent ( active_scope ) ; <nl> - active_scope = parent ; <nl> - } <nl> - <nl> - / / Close all scopes <nl> - void GPULower : : resetScope ( ) { <nl> - active_scope = nullptr ; <nl> - } <nl> - <nl> / / Clear out the last recorded computeAtView <nl> void GPULower : : clearActiveView ( ) { <nl> active_view_axis = 0 ; <nl> void GPULower : : setActiveView ( const TensorView * const tv ) { <nl> active_view = tv - > getComputeAtView ( ) ; <nl> } <nl> <nl> - std : : vector < Val * > GPULower : : getLoopIndices ( ) { <nl> - return forLoopIndices : : get ( active_scope ) ; <nl> - } <nl> - <nl> - std : : vector < IterDomain * > GPULower : : getLoopIterDomains ( ) { <nl> - return forLoopIDs : : get ( active_scope ) ; <nl> - } <nl> - <nl> TensorIndex * GPULower : : getGlobalProducerIndex ( <nl> TensorView * producer , <nl> TensorView * consumer ) { <nl> TensorIndex * GPULower : : getGlobalProducerIndex ( <nl> / / This replay will ignore reduction dimensions on the producer <nl> TransformReplay : : fullReplay ( consumer , cloned_tv ) ; <nl> TORCH_INTERNAL_ASSERT ( <nl> - getLoopIndices ( ) . size ( ) = = cloned_tv - > nDims ( ) , <nl> + scope_utils : : getLoopIndices ( active_scope ) . size ( ) = = cloned_tv - > nDims ( ) , <nl> " Dimensionality error in code generator while computing indexing . " ) ; <nl> <nl> - const std : : vector < Val * > computed_inds = <nl> - IndexCompute : : computeIndices ( cloned_tv , getLoopIndices ( ) ) ; <nl> + const std : : vector < Val * > computed_inds = IndexCompute : : computeIndices ( <nl> + cloned_tv , scope_utils : : getLoopIndices ( active_scope ) ) ; <nl> <nl> TORCH_INTERNAL_ASSERT ( <nl> - computed_inds . size ( ) = = producer - > getRootDomain ( ) - > size ( ) , <nl> + computed_inds . size ( ) = = producer - > getRootDomain ( ) - > nDims ( ) , <nl> " Dimensionality error in code generator while computing indexing . " ) ; <nl> <nl> std : : vector < Val * > strided_inds ; <nl> TensorIndex * GPULower : : getLocalProducerIndex ( <nl> TensorView * producer , <nl> TensorView * consumer ) { <nl> TORCH_INTERNAL_ASSERT ( <nl> - computeForDepth ( ) = = producer - > nDims ( ) , <nl> + scope_utils : : computeForDepth ( active_scope ) = = producer - > nDims ( ) , <nl> " Expected a tensor with " , <nl> - computeForDepth ( ) , <nl> + scope_utils : : computeForDepth ( active_scope ) , <nl> " dimensions but got one with " , <nl> producer - > nDims ( ) ) ; <nl> <nl> - std : : vector < Val * > loopInds = getLoopIndices ( ) ; <nl> - std : : vector < IterDomain * > ranges = getLoopIterDomains ( ) ; <nl> + std : : vector < Val * > loopInds = scope_utils : : getLoopIndices ( active_scope ) ; <nl> + std : : vector < IterDomain * > ranges = <nl> + scope_utils : : getLoopIterDomains ( active_scope ) ; <nl> std : : vector < Val * > computed_inds ; <nl> std : : vector < IterDomain * > used_ranges ; <nl> + bool unrolled = false ; <nl> for ( decltype ( loopInds . size ( ) ) i { 0 } ; i < loopInds . size ( ) ; i + + ) { <nl> - if ( producer - > hasComputeAt ( ) & & i < producer - > getComputeAtAxis ( ) ) <nl> + if ( ranges [ i ] - > parallel_method ( ) = = ParallelType : : Unroll ) <nl> + unrolled = true ; <nl> + if ( ! unrolled & & producer - > hasComputeAt ( ) & & <nl> + i < producer - > getComputeAtAxis ( ) ) <nl> continue ; <nl> if ( ranges [ i ] - > isThread ( ) ) <nl> continue ; <nl> TensorIndex * GPULower : : getLocalProducerIndex ( <nl> for ( decltype ( computed_inds . size ( ) ) i { 0 } ; i < computed_inds . size ( ) ; i + + ) { <nl> Val * ind = computed_inds [ i ] ; <nl> for ( decltype ( used_ranges . size ( ) ) j { i + 1 } ; j < used_ranges . size ( ) ; j + + ) <nl> - ind = mul ( ind , used_ranges [ i ] - > size ( ) ) ; <nl> + ind = mul ( ind , used_ranges [ i ] - > extent ( ) ) ; <nl> computed_inds [ i ] = ind ; <nl> } <nl> if ( computed_inds . size ( ) = = 0 ) <nl> TensorIndex * GPULower : : getProducerIndex ( <nl> <nl> TensorIndex * GPULower : : getGlobalConsumerIndex ( TensorView * consumer ) { <nl> TORCH_INTERNAL_ASSERT ( <nl> - getLoopIndices ( ) . size ( ) = = consumer - > nDims ( ) , <nl> + scope_utils : : getLoopIndices ( active_scope ) . size ( ) = = consumer - > nDims ( ) , <nl> " Dimensionality error in code generator while computing indexing . " ) ; <nl> <nl> - const std : : vector < Val * > computed_inds = <nl> - IndexCompute : : computeIndices ( consumer , getLoopIndices ( ) ) ; <nl> + const std : : vector < Val * > computed_inds = IndexCompute : : computeIndices ( <nl> + consumer , scope_utils : : getLoopIndices ( active_scope ) ) ; <nl> <nl> TORCH_INTERNAL_ASSERT ( <nl> - computed_inds . size ( ) = = consumer - > getRootDomain ( ) - > size ( ) , <nl> + computed_inds . size ( ) = = consumer - > getRootDomain ( ) - > nDims ( ) , <nl> " Dimensionality error in code generator while computing indexing . " ) ; <nl> <nl> std : : vector < Val * > strided_inds ; <nl> TensorIndex * GPULower : : getGlobalConsumerIndex ( TensorView * consumer ) { <nl> <nl> TensorIndex * GPULower : : getLocalConsumerIndex ( TensorView * consumer ) { <nl> TORCH_INTERNAL_ASSERT ( <nl> - computeForDepth ( ) = = consumer - > nDims ( ) , <nl> + scope_utils : : computeForDepth ( active_scope ) = = consumer - > nDims ( ) , <nl> " Expected a tensor with " , <nl> - computeForDepth ( ) , <nl> + scope_utils : : computeForDepth ( active_scope ) , <nl> " dimensions but got one with " , <nl> consumer - > nDims ( ) ) ; <nl> <nl> - std : : vector < Val * > loopInds = getLoopIndices ( ) ; <nl> - std : : vector < IterDomain * > ranges = getLoopIterDomains ( ) ; <nl> + std : : vector < Val * > loopInds = scope_utils : : getLoopIndices ( active_scope ) ; <nl> + std : : vector < IterDomain * > ranges = <nl> + scope_utils : : getLoopIterDomains ( active_scope ) ; <nl> std : : vector < Val * > computed_inds ; <nl> std : : vector < IterDomain * > used_ranges ; <nl> - <nl> + bool unrolled = false ; <nl> for ( decltype ( loopInds . size ( ) ) i { 0 } ; i < loopInds . size ( ) ; i + + ) { <nl> - if ( i < consumer - > getComputeAtAxis ( ) ) <nl> + if ( ranges [ i ] - > parallel_method ( ) = = ParallelType : : Unroll ) <nl> + unrolled = true ; <nl> + if ( ! unrolled & & consumer - > hasComputeAt ( ) & & <nl> + i < consumer - > getComputeAtAxis ( ) ) <nl> continue ; <nl> if ( ranges [ i ] - > isThread ( ) ) <nl> continue ; <nl> TensorIndex * GPULower : : getLocalConsumerIndex ( TensorView * consumer ) { <nl> for ( decltype ( computed_inds . size ( ) ) i { 0 } ; i < computed_inds . size ( ) ; i + + ) { <nl> Val * ind = computed_inds [ i ] ; <nl> for ( decltype ( used_ranges . size ( ) ) j { i + 1 } ; j < used_ranges . size ( ) ; j + + ) <nl> - ind = mul ( ind , used_ranges [ i ] - > size ( ) ) ; <nl> + ind = mul ( ind , used_ranges [ i ] - > extent ( ) ) ; <nl> computed_inds [ i ] = ind ; <nl> } <nl> <nl> TensorIndex * GPULower : : getConsumerIndex ( TensorView * consumer ) { <nl> return getLocalConsumerIndex ( consumer ) ; <nl> } <nl> <nl> - / / Track how far our for loop scope is <nl> - unsigned int GPULower : : computeForDepth ( ) { <nl> - return forLoopCount : : count ( active_scope ) ; <nl> - } <nl> - <nl> - / / Push an expr to the active scope <nl> void GPULower : : pushBack ( Expr * expr ) { <nl> - if ( active_scope = = nullptr ) { <nl> - lowered_exprs . push_back ( expr ) ; <nl> - return ; <nl> - } <nl> - scopePushBack : : pushBack ( active_scope , expr ) ; <nl> - } <nl> - <nl> - / / Return the parent of the active scope <nl> - Expr * GPULower : : parentScope ( ) { <nl> if ( active_scope = = nullptr ) <nl> - return nullptr ; <nl> - return parentScope_ : : parent ( active_scope ) ; <nl> + lowered_exprs . push_back ( expr ) ; <nl> + else <nl> + scope_utils : : pushBack ( active_scope , expr ) ; <nl> } <nl> <nl> - Allocate * GPULower : : getAlloc ( TensorView * tv ) { <nl> + Statement * GPULower : : mutate ( Expr * expr ) { <nl> + Statement * mutated_stmt = OptOutMutator : : mutate ( expr ) ; <nl> TORCH_INTERNAL_ASSERT ( <nl> - ! ( FusionGuard : : getCurFusion ( ) - > hasInput ( tv ) | | <nl> - FusionGuard : : getCurFusion ( ) - > hasOutput ( tv ) ) , <nl> - " Tried to allocate an input or output tensor . " ) ; <nl> - <nl> - std : : vector < Val * > alloc_dims ; <nl> + mutated_stmt - > isExpr ( ) , <nl> + " Tried to generate a kernel but hit a non expression during lowering : " , <nl> + mutated_stmt ) ; <nl> + return mutated_stmt ; <nl> + } <nl> <nl> - for ( decltype ( tv - > nDims ( ) ) i = tv - > getComputeAtAxis ( ) ; i < tv - > nDims ( ) ; i + + ) { <nl> - IterDomain * dim = tv - > getComputeAtAxis ( i ) ; <nl> - if ( dim - > isThreadDim ( ) ) <nl> - continue ; <nl> - alloc_dims . push_back ( dim - > size ( ) ) ; <nl> + Statement * GPULower : : mutate ( IfThenElse * ite ) { <nl> + Expr * prev_scope = active_scope ; <nl> + active_scope = ite ; <nl> + std : : vector < Expr * > mutated_exprs ; <nl> + bool is_mutated = false ; <nl> + for ( auto expr : ite - > body ( ) . exprs ( ) ) { <nl> + Statement * mutated_stmt = mutate ( expr ) ; <nl> + Expr * mutated_expr = ir_utils : : asExpr ( mutated_stmt ) ; <nl> + mutated_exprs . push_back ( mutated_expr ) ; <nl> + is_mutated = is_mutated | ( mutated_expr ! = expr ) ; <nl> } <nl> <nl> - Val * size ; <nl> - if ( alloc_dims . size ( ) = = 0 ) { <nl> - size = new Int ( 1 ) ; <nl> - } else { <nl> - size = alloc_dims [ 0 ] ; <nl> - for ( decltype ( alloc_dims . size ( ) ) i { 1 } ; i < alloc_dims . size ( ) ; i + + ) { <nl> - size = mul ( size , alloc_dims [ i ] ) ; <nl> - } <nl> + std : : vector < Expr * > mutated_else_exprs ; <nl> + for ( auto expr : ite - > elseBody ( ) . exprs ( ) ) { <nl> + Statement * mutated_stmt = mutate ( expr ) ; <nl> + Expr * mutated_expr = ir_utils : : asExpr ( mutated_stmt ) ; <nl> + mutated_else_exprs . push_back ( mutated_expr ) ; <nl> + is_mutated = is_mutated | ( mutated_expr ! = expr ) ; <nl> } <nl> - return new Allocate ( tv , size ) ; <nl> - } <nl> - <nl> - IfThenElse * GPULower : : getPredicate ( const TensorView * const pred_tv ) { <nl> - TensorIndex * ti = new TensorIndex ( <nl> - pred_tv , IndexCompute : : computeIndices ( pred_tv , getLoopIndices ( ) ) ) ; <nl> <nl> - std : : vector < Int * > all_preds = PredicateCompute : : computePredicates ( ti ) ; <nl> + if ( is_mutated ) { <nl> + ite - > body ( ) . clear ( ) ; <nl> + for ( auto expr : mutated_exprs ) <nl> + ite - > body ( ) . push_back ( expr ) ; <nl> + ite - > elseBody ( ) . clear ( ) ; <nl> + for ( auto expr : mutated_else_exprs ) <nl> + ite - > elseBody ( ) . push_back ( expr ) ; <nl> + } <nl> <nl> - std : : vector < Int * > preds ; <nl> + active_scope = prev_scope ; <nl> <nl> - Int * one = new Int ( 1 ) ; <nl> + if ( is_mutated ) { <nl> + auto new_ite = new IfThenElse ( <nl> + ite - > cond ( ) , mutated_exprs , mutated_else_exprs , ite - > parentScope ( ) ) ; <nl> + return new_ite ; <nl> + } <nl> <nl> - for ( Int * pred : all_preds ) <nl> - if ( ! pred - > sameAs ( one ) ) <nl> - preds . push_back ( pred ) ; <nl> + return ite ; <nl> + } <nl> <nl> - if ( preds . size ( ) = = 0 ) { <nl> - return new IfThenElse ( one , { } , { } , active_scope ) ; <nl> + Statement * GPULower : : mutate ( ForLoop * fl ) { <nl> + Expr * prev_scope = active_scope ; <nl> + active_scope = fl ; <nl> + std : : vector < Expr * > mutated_exprs ; <nl> + bool is_mutated = false ; <nl> + for ( auto expr : fl - > body ( ) . exprs ( ) ) { <nl> + Statement * mutated_stmt = mutate ( expr ) ; <nl> + Expr * mutated_expr = ir_utils : : asExpr ( mutated_stmt ) ; <nl> + mutated_exprs . push_back ( mutated_expr ) ; <nl> + is_mutated = is_mutated | ( mutated_expr ! = expr ) ; <nl> } <nl> <nl> - Int * cond = preds [ 0 ] ; <nl> + active_scope = prev_scope ; <nl> <nl> - for ( decltype ( preds . size ( ) ) i { 1 } ; i < preds . size ( ) ; i + + ) <nl> - cond = static_cast < Int * > ( andOp ( cond , preds [ i ] ) ) ; <nl> + if ( is_mutated ) { <nl> + auto newFL = new ForLoop ( <nl> + fl - > index ( ) , fl - > iter_domain ( ) , mutated_exprs , fl - > parentScope ( ) ) ; <nl> + return newFL ; <nl> + } <nl> <nl> - return new IfThenElse ( cond , { } , { } , active_scope ) ; <nl> + return fl ; <nl> } <nl> <nl> - / / Custom dispatch for Expr , want to find out of it ' s a TV op <nl> - void GPULower : : handle ( Expr * expr ) { <nl> - if ( ! isTVOp ( expr ) ) <nl> - return ; <nl> - <nl> - TensorView * out = static_cast < TensorView * > ( expr - > output ( 0 ) ) ; <nl> + Statement * GPULower : : mutate ( UnaryOp * uop ) { <nl> + if ( ! ir_utils : : isTVOp ( uop ) ) <nl> + return OptOutMutator : : mutate ( uop ) ; <nl> <nl> - updateView ( out ) ; <nl> - <nl> - / / 8 ) Run operation <nl> - OptOutDispatch : : handle ( expr ) ; <nl> + TensorIndex * out = getConsumerIndex ( ir_utils : : asTV ( uop - > out ( ) ) ) ; <nl> + Val * in = uop - > in ( ) ; <nl> + if ( ir_utils : : isTV ( in ) ) <nl> + in = getProducerIndex ( ir_utils : : asTV ( in ) , ir_utils : : asTV ( uop - > out ( ) ) ) ; <nl> + Expr * new_op = new UnaryOp ( uop - > getUnaryOpType ( ) , out , in ) ; <nl> <nl> - / / 9 ) Close predicate <nl> - if ( active_scope ! = nullptr & & <nl> - active_scope - > getExprType ( ) = = ExprType : : IfThenElse ) <nl> - closeScope ( ) ; <nl> + return new_op ; <nl> } <nl> <nl> - void GPULower : : handle ( UnaryOp * uop ) { <nl> - TORCH_INTERNAL_ASSERT ( <nl> - isTV ( uop - > out ( ) ) , <nl> - " Expected a tensor view but got " , <nl> - uop - > out ( ) - > getValType ( ) . value ( ) ) ; <nl> - TensorIndex * out = getConsumerIndex ( asTV ( uop - > out ( ) ) ) ; <nl> - Val * in = uop - > in ( ) ; <nl> - if ( isTV ( in ) ) <nl> - in = getProducerIndex ( asTV ( in ) , asTV ( uop - > out ( ) ) ) ; <nl> - pushBack ( new UnaryOp ( uop - > getUnaryOpType ( ) , out , in ) ) ; <nl> - } <nl> + Statement * GPULower : : mutate ( BinaryOp * bop ) { <nl> + if ( ! ir_utils : : isTVOp ( bop ) ) <nl> + return OptOutMutator : : mutate ( bop ) ; <nl> <nl> - void GPULower : : handle ( BinaryOp * bop ) { <nl> - TORCH_INTERNAL_ASSERT ( <nl> - isTV ( bop - > out ( ) ) , <nl> - " Expected a tensor view but got " , <nl> - bop - > out ( ) - > getValType ( ) . value ( ) ) ; <nl> - TensorIndex * out = getConsumerIndex ( asTV ( bop - > out ( ) ) ) ; <nl> + TensorIndex * out = getConsumerIndex ( ir_utils : : asTV ( bop - > out ( ) ) ) ; <nl> Val * lhs = bop - > lhs ( ) ; <nl> Val * rhs = bop - > rhs ( ) ; <nl> <nl> - if ( isTV ( lhs ) ) <nl> - lhs = getProducerIndex ( asTV ( lhs ) , asTV ( bop - > out ( ) ) ) ; <nl> - <nl> - if ( isTV ( rhs ) ) <nl> - rhs = getProducerIndex ( asTV ( rhs ) , asTV ( bop - > out ( ) ) ) ; <nl> - <nl> - pushBack ( new BinaryOp ( bop - > getBinaryOpType ( ) , out , lhs , rhs ) ) ; <nl> - } <nl> - <nl> - / * <nl> - * This is one of the most complex parts of the code lowering logic . what we <nl> - * need to do is : 1 ) Reduce loop structure <nl> - * - Reset all loops if active_view = = nullptr ( I ' m not the last in a series <nl> - * of computeAts ) <nl> - * - Else reduce to active_view_axis if loop_depth > active_view_axis <nl> - * 2 ) Set active_view ( _axis ) <nl> - * - If there is a computeAt set for this TV <nl> - * 3 ) Open to compute At <nl> - * - If there is a computeAt set for this TV <nl> - * 4 ) Allocate the output . <nl> - * 5 ) If this is a reduction , initialize the output ( open for loops to inner <nl> - * most , predicate , initialize , close predicate , close to computeAt ) 6 ) Open to <nl> - * inner most loop 7 ) Open predicate 8 ) Run operation 9 ) Close predicate <nl> - * / <nl> - <nl> - / / Update fors based on tv . <nl> - void GPULower : : updateView ( TensorView * tv ) { <nl> - / / 1 ) Reduce loop structure <nl> - if ( active_view = = nullptr ) { <nl> - / / - Reset all loops if active_view = = nullptr ( I ' m not the last in a series <nl> - / / of computeAts ) <nl> - resetScope ( ) ; <nl> - } else { <nl> - / / - Else reduce to active_view_axis if loop_depth > active_view_axis <nl> - auto depth = computeForDepth ( ) ; <nl> - for ( auto i = depth ; i > active_view_axis ; i - - ) { <nl> - closeScope ( ) ; <nl> - } <nl> - } <nl> - if ( tv - > hasComputeAt ( ) ) { <nl> - / / 2 ) Set active_view ( _axis ) <nl> - / / - If there is a computeAt set for this TV <nl> - setActiveView ( tv ) ; <nl> - <nl> - / / 3 ) Open to compute At <nl> - / / - If there is a computeAt set for this TV <nl> - auto depth = computeForDepth ( ) ; <nl> - for ( auto i = depth ; i < tv - > getComputeAtAxis ( ) ; i + + ) <nl> - openFor ( tv - > getComputeAtAxis ( i ) ) ; <nl> - } else { <nl> - if ( active_view ! = nullptr ) <nl> - / / If we ' re the last computeAt of a block , active view should match this <nl> - / / tv <nl> - TORCH_INTERNAL_ASSERT ( <nl> - tv - > sameAs ( active_view ) , <nl> - " Error detected in code lowering . Expected " , <nl> - active_view , <nl> - " but recieved " , <nl> - tv ) ; <nl> - clearActiveView ( ) ; <nl> - } <nl> - <nl> - / / 4 ) Allocate the output . <nl> + if ( ir_utils : : isTV ( lhs ) ) <nl> + lhs = getProducerIndex ( ir_utils : : asTV ( lhs ) , ir_utils : : asTV ( bop - > out ( ) ) ) ; <nl> <nl> - if ( ! FusionGuard : : getCurFusion ( ) - > hasInput ( tv ) & & <nl> - ! FusionGuard : : getCurFusion ( ) - > hasOutput ( tv ) ) { <nl> - pushBack ( getAlloc ( tv ) ) ; <nl> - } <nl> - <nl> - / / TODO : <nl> - / / 5 ) If this is a reduction , initialize the output ( open for loops to inner <nl> - / / most , predicate , initialize , close predicate , close to computeAt ) <nl> + if ( ir_utils : : isTV ( rhs ) ) <nl> + rhs = getProducerIndex ( ir_utils : : asTV ( rhs ) , ir_utils : : asTV ( bop - > out ( ) ) ) ; <nl> <nl> - / / 6 ) Open to inner most loop <nl> - for ( decltype ( tv - > nDims ( ) ) i = computeForDepth ( ) ; i < tv - > nDims ( ) ; i + + ) <nl> - openFor ( tv - > getComputeAtAxis ( i ) ) ; <nl> + Expr * new_op = new BinaryOp ( bop - > getBinaryOpType ( ) , out , lhs , rhs ) ; <nl> <nl> - / / 7 ) Open predicate <nl> - IfThenElse * pred = getPredicate ( tv ) ; <nl> - if ( ! pred - > cond ( ) - > sameAs ( new Int ( 1 ) ) ) { <nl> - pushBack ( pred ) ; <nl> - active_scope = pred ; <nl> - } <nl> + return new_op ; <nl> } <nl> <nl> / / TensorViews are all based on symbolic sizes . When we first initialize them we <nl> void GPULower : : replaceSizes ( ) { <nl> Fusion * fusion = FusionGuard : : getCurFusion ( ) ; <nl> / / Sizes of inputs / outputs - > T . size [ . . . ] <nl> std : : unordered_map < Val * , Val * > size_map ; <nl> - / / Replacement of full tensor views <nl> - std : : unordered_map < Val * , Val * > tv_map ; <nl> <nl> / / Grab inputs and outputs <nl> std : : vector < TensorView * > orig_inp_out ; <nl> - std : : vector < TensorView * > orig_intermediates ; <nl> + std : : vector < TensorView * > all_tvs ; <nl> + <nl> + for ( auto * val : fusion - > inputs ( ) ) <nl> + if ( ir_utils : : isTV ( val ) ) <nl> + orig_inp_out . push_back ( ir_utils : : asTV ( val ) ) ; <nl> + <nl> + for ( auto * val : fusion - > outputs ( ) ) <nl> + if ( ir_utils : : isTV ( val ) ) <nl> + orig_inp_out . push_back ( ir_utils : : asTV ( val ) ) ; <nl> <nl> for ( auto * val : fusion - > deterministic_vals ( ) ) { <nl> - if ( isTV ( val ) ) { <nl> - if ( fusion - > hasInput ( val ) | | fusion - > hasOutput ( val ) ) { <nl> - orig_inp_out . push_back ( asTV ( val ) ) ; <nl> - } else { <nl> - orig_intermediates . push_back ( asTV ( val ) ) ; <nl> - } <nl> + if ( ir_utils : : isTV ( val ) ) { <nl> + all_tvs . push_back ( ir_utils : : asTV ( val ) ) ; <nl> } <nl> } <nl> <nl> void GPULower : : replaceSizes ( ) { <nl> / / option which seems less elegant but would also work is build up the domain <nl> / / on the new tensor , and then simply replace it into the original one . <nl> for ( TensorView * tv : orig_inp_out ) { <nl> - TensorView * new_tv = <nl> - new TensorView ( tv - > domain ( ) , tv - > getDataType ( ) . value ( ) ) ; <nl> - <nl> - / / We can place the new_tv in the map right away . <nl> - tv_map [ tv ] = new_tv ; <nl> - <nl> / / Replace the domain with one based on Ti . size [ j ] <nl> - std : : vector < IterDomain * > new_domain ; <nl> + std : : vector < IterDomain * > new_domain_iters ; <nl> TensorDomain * root_td = tv - > getRootDomain ( ) ; <nl> - for ( decltype ( root_td - > size ( ) ) i { 0 } ; i < root_td - > size ( ) ; i + + ) { <nl> - Val * orig_size = root_td - > axis ( i ) - > size ( ) ; <nl> + for ( decltype ( root_td - > nDims ( ) ) i { 0 } ; i < root_td - > nDims ( ) ; i + + ) { <nl> + Val * orig_size = root_td - > axis ( i ) - > extent ( ) ; <nl> std : : stringstream ss ; <nl> - ss < < " T " < < new_tv - > name ( ) < < " . size [ " < < i < < " ] " ; <nl> + ss < < " T " < < tv - > name ( ) < < " . size [ " < < i < < " ] " ; <nl> Val * new_size = <nl> new NamedScalar ( ss . str ( ) , orig_size - > getDataType ( ) . value ( ) ) ; <nl> - size_map [ orig_size ] = new_size ; <nl> - <nl> - new_domain . push_back ( new IterDomain ( <nl> - new_size , <nl> - root_td - > axis ( i ) - > parallel_method ( ) , <nl> - root_td - > axis ( i ) - > isReduction ( ) ) ) ; <nl> + if ( ! orig_size - > sameAs ( new_size ) | | <nl> + size_map . find ( orig_size ) = = size_map . end ( ) ) <nl> + size_map [ orig_size ] = new_size ; <nl> } <nl> - new_tv - > setDomain ( new TensorDomain ( new_domain ) ) ; <nl> } <nl> <nl> - for ( TensorView * tv : orig_intermediates ) { <nl> - TensorView * new_tv = <nl> - new TensorView ( tv - > domain ( ) , tv - > getDataType ( ) . value ( ) ) ; <nl> - tv_map [ tv ] = new_tv ; <nl> + / / If we already lowered all inputs / outputs we can just return . <nl> + if ( size_map . size ( ) = = 0 ) <nl> + return ; <nl> <nl> - std : : vector < IterDomain * > new_domain ; <nl> + for ( TensorView * tv : all_tvs ) { <nl> + std : : vector < IterDomain * > new_domain_iters ; <nl> TensorDomain * root_td = tv - > getRootDomain ( ) ; <nl> <nl> - for ( decltype ( root_td - > size ( ) ) i { 0 } ; i < root_td - > size ( ) ; i + + ) { <nl> - Val * new_size = root_td - > axis ( i ) - > size ( ) ; <nl> + for ( decltype ( root_td - > nDims ( ) ) i { 0 } ; i < root_td - > nDims ( ) ; i + + ) { <nl> + Val * new_size = root_td - > axis ( i ) - > extent ( ) ; <nl> if ( size_map . find ( new_size ) ! = size_map . end ( ) ) <nl> new_size = size_map [ new_size ] ; <nl> - new_domain . push_back ( new IterDomain ( <nl> + new_domain_iters . push_back ( new IterDomain ( <nl> + root_td - > axis ( i ) - > start ( ) , <nl> new_size , <nl> root_td - > axis ( i ) - > parallel_method ( ) , <nl> root_td - > axis ( i ) - > isReduction ( ) ) ) ; <nl> } <nl> - new_tv - > setDomain ( new TensorDomain ( new_domain ) ) ; <nl> - } <nl> <nl> - / / Now that we have the base tensor views . Lets fix its members . <nl> - for ( auto entry : tv_map ) { <nl> - TensorView * orig_tv = asTV ( entry . first ) ; <nl> - TensorView * new_tv = asTV ( entry . second ) ; <nl> - <nl> - / / Domain in the new TV is the root domain , replay it like the original <nl> - / / domain . <nl> - TransformReplay : : fullReplay ( orig_tv , new_tv ) ; <nl> + TensorDomain * old_domain = tv - > domain ( ) ; <nl> + TensorDomain * new_domain = TransformReplay : : fullReplay ( <nl> + old_domain , new TensorDomain ( new_domain_iters ) ) ; <nl> <nl> + TORCH_INTERNAL_ASSERT ( <nl> + old_domain - > nDims ( ) = = new_domain - > nDims ( ) , <nl> + " Tried to set symbolic sizes through the kernel , but hit a snag , Replayed domain should be the same size as the target domain , but got " , <nl> + new_domain - > nDims ( ) , <nl> + " and " , <nl> + old_domain - > nDims ( ) ) ; <nl> / / Parallelize all iter domains <nl> - for ( decltype ( new_tv - > domain ( ) - > size ( ) ) i { 0 } ; i < new_tv - > domain ( ) - > size ( ) ; <nl> - i + + ) <nl> - new_tv - > axis ( i ) - > parallelize ( orig_tv - > axis ( i ) - > parallel_method ( ) ) ; <nl> - <nl> - / / Set compute at view and axis <nl> - TensorView * computeAtTV = orig_tv - > getComputeAtView ( ) ; <nl> - if ( computeAtTV ! = nullptr ) { <nl> - TORCH_INTERNAL_ASSERT ( <nl> - tv_map . find ( computeAtTV ) ! = tv_map . end ( ) , <nl> - " Expected to find a translation for " , <nl> - computeAtTV , <nl> - " but one wasn ' t found . " ) ; <nl> - new_tv - > setComputeAt ( <nl> - asTV ( tv_map [ computeAtTV ] ) , ( int ) ( orig_tv - > getComputeAtAxis ( ) ) ) ; <nl> - } <nl> - } <nl> + for ( decltype ( new_domain - > nDims ( ) ) i { 0 } ; i < new_domain - > nDims ( ) ; i + + ) <nl> + new_domain - > axis ( i ) - > parallelize ( old_domain - > axis ( i ) - > parallel_method ( ) ) ; <nl> <nl> - ReplaceAll : : instancesOf ( tv_map ) ; <nl> + tv - > setDomain ( new_domain ) ; <nl> + } <nl> } <nl> <nl> + namespace { <nl> + <nl> + / / Some pre - compilation checks <nl> + void validate ( Fusion * fusion ) { <nl> + for ( Val * val : fusion - > vals ( ) ) { <nl> + if ( ir_utils : : isTV ( val ) ) { <nl> + TensorView * tv = ir_utils : : asTV ( val ) ; <nl> + for ( decltype ( tv - > nDims ( ) ) i { 0 } ; i < tv - > nDims ( ) ; i + + ) { <nl> + IterDomain * id = tv - > getComputeAtAxis ( i ) ; <nl> + <nl> + if ( id - > isThread ( ) ) <nl> + TORCH_CHECK ( <nl> + ! id - > isReduction ( ) , <nl> + " Parallelization on reduction axes not support at the moment found on , " , <nl> + tv , <nl> + " . " ) ; <nl> + } <nl> + } / / if ir_utils : : isTV <nl> + } / / for ( Val * val : fusion - > vals ( ) ) <nl> + <nl> + } / / validate <nl> + } / / namespace <nl> + <nl> / / Traverse through the fusion and print CUDA code associated with it <nl> std : : vector < Expr * > GPULower : : getLoweredExprs ( ) { <nl> FusionGuard fg ( fusion_ ) ; <nl> <nl> - TORCH_CHECK ( <nl> - ! fusion_ - > lowered , <nl> - " Fusions can only be lowered once as of now . You could reuse the lowering using " , <nl> - " std : : vector < Expr * > GPULower : : getLoweredExprs ( ) the result can be printed as " , <nl> - " a kernel with IRPrinter irp ( os ) ; irp . printKernel ( lowered_exprs , kernel_name ) ; " ) ; <nl> + validate ( fusion_ ) ; <nl> <nl> / / Initialize members of the class <nl> - lowered_exprs = std : : vector < Expr * > ( ) ; <nl> active_view = nullptr ; <nl> active_view_axis = 0 ; <nl> <nl> replaceSizes ( ) ; <nl> <nl> - / / Run through and lower the expressions <nl> - std : : vector < Expr * > exprs = fusion_ - > exprs ( true ) ; <nl> - for ( auto * expr : exprs ) <nl> - handle ( expr ) ; <nl> + auto loop_nests = LoopNestGenerator : : getLoopNest ( fusion_ ) ; <nl> + auto unrolled_loops = UnrollPass : : runPass ( fusion_ , loop_nests ) ; <nl> + / / Run through loop nests and further lower the expressions <nl> + for ( auto * expr : unrolled_loops ) { <nl> + Statement * mutated_stmt = mutate ( expr ) ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + mutated_stmt - > isExpr ( ) , <nl> + " Tried to generate a kernel but hit a non expression during lowering : " , <nl> + mutated_stmt ) ; <nl> + lowered_exprs . push_back ( static_cast < Expr * > ( mutated_stmt ) ) ; <nl> + } <nl> <nl> - fusion_ - > lowered = true ; <nl> return lowered_exprs ; <nl> } <nl> <nl> std : : ostream & GPULower : : printKernel ( <nl> std : : ostream & os , <nl> const std : : string & kernel_name ) { <nl> FusionGuard fg ( fusion_ ) ; <nl> - <nl> getLoweredExprs ( ) ; <nl> <nl> IRPrinter irp ( os ) ; <nl> std : : ostream & GPULower : : printKernel ( <nl> <nl> } / / namespace fuser <nl> } / / namespace jit <nl> - } / / namespace torch <nl> \ No newline at end of file <nl> + } / / namespace torch <nl> mmm a / torch / csrc / jit / codegen / cuda / lower2device . h <nl> ppp b / torch / csrc / jit / codegen / cuda / lower2device . h <nl> <nl> <nl> # include < torch / csrc / WindowsTorchApiMacro . h > <nl> <nl> - # include < torch / csrc / jit / codegen / cuda / arith . h > <nl> - # include < torch / csrc / jit / codegen / cuda / index_compute . h > <nl> - # include < torch / csrc / jit / codegen / cuda / ir_iostream . h > <nl> - # include < torch / csrc / jit / codegen / cuda / iter_visitor . h > <nl> - # include < torch / csrc / jit / codegen / cuda / predicate_compute . h > <nl> - # include < torch / csrc / jit / codegen / cuda / transform_iter . h > <nl> + # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> <nl> # include < map > <nl> # include < ostream > <nl> namespace fuser { <nl> / / keep user references intact so they can lower it as they describe the kernel . <nl> / / Right now we can only lower once . <nl> <nl> - struct TORCH_CUDA_API GPULower : public OptOutDispatch { <nl> + struct TORCH_CUDA_API GPULower : public OptOutMutator { <nl> private : <nl> bool lowered = false ; <nl> - Fusion * fusion_ ; <nl> + Fusion * const fusion_ ; <nl> std : : vector < Expr * > lowered_exprs ; <nl> Expr * active_scope = nullptr ; <nl> + <nl> / / Track the last computeAt TensorView and axis <nl> const TensorView * active_view ; <nl> unsigned int active_view_axis ; <nl> <nl> - / / Open a new inner most for loop <nl> - void openFor ( IterDomain * ) ; <nl> - / / Close the inner most for loop <nl> - void closeScope ( ) ; <nl> - / / Close all for loops <nl> - void resetScope ( ) ; <nl> / / Clear out the last recorded computeAtView <nl> void clearActiveView ( ) ; <nl> / / Set active views from computeAtView <nl> void setActiveView ( const TensorView * const ) ; <nl> - / / Grab the index variables of the active loop nest <nl> - std : : vector < Val * > getLoopIndices ( ) ; <nl> - / / Grab the iterDomains of the active loops <nl> - std : : vector < IterDomain * > getLoopIterDomains ( ) ; <nl> - / / Gets the indexing of a TensorView producer . These are values consumed in a <nl> - / / TensorView Expr . We use the consumer ( left hand side of the = ) to compute <nl> - / / the indexing into the consumer . <nl> + <nl> + / / Indexing functions <nl> + / / Consumer = Producer <nl> + / / i . e . T0 = T1 . . . - > T0 is the consumer , T1 is the producer <nl> + / / Producer indexing dispatch <nl> TensorIndex * getProducerIndex ( TensorView * producer , TensorView * consumer ) ; <nl> + / / Producer if it ' s in global memory <nl> TensorIndex * getGlobalProducerIndex ( <nl> TensorView * producer , <nl> TensorView * consumer ) ; <nl> + / / Producer indexing if it ' s in registers <nl> TensorIndex * getLocalProducerIndex ( <nl> TensorView * producer , <nl> TensorView * consumer ) ; <nl> + / / Consumer index dispatch <nl> TensorIndex * getConsumerIndex ( TensorView * consumer ) ; <nl> + / / Consumer indexing if it ' s in global memory <nl> TensorIndex * getGlobalConsumerIndex ( TensorView * consumer ) ; <nl> + / / Consumer indexing if it ' s in local memory <nl> TensorIndex * getLocalConsumerIndex ( TensorView * consumer ) ; <nl> <nl> - / / Track how far our for loop scope is <nl> - unsigned int computeForDepth ( ) ; <nl> - / / Push an expr to the active scope <nl> - void pushBack ( Expr * expr ) ; <nl> - / / Return the parent of the active scope <nl> - Expr * parentScope ( ) ; <nl> - <nl> - / / Get Register allocation statement for tensorview <nl> - Allocate * getAlloc ( TensorView * ) ; <nl> / / Get a predicate based on a particular tensorview <nl> IfThenElse * getPredicate ( const TensorView * const ) ; <nl> <nl> + / / Wrap pushBack in lower_utils if active_scope is null we want it to go <nl> + / / straight to lower_exprs <nl> + void pushBack ( Expr * ) ; <nl> + <nl> / / Custom dispatch for Expr , want to find out of it ' s a TV op <nl> - void handle ( Expr * ) final ; <nl> + Statement * mutate ( Expr * ) final ; <nl> <nl> - / / Remake operations with TensorIndex <nl> - void handle ( UnaryOp * ) final ; <nl> - void handle ( BinaryOp * ) final ; <nl> + / / Open the for loop . <nl> + Statement * mutate ( ForLoop * ) final ; <nl> <nl> - / / Ignore split / merge / reorder operations , <nl> - / / we don ' t want to print them . <nl> - void handle ( Split * ) final { } <nl> - void handle ( Merge * ) final { } <nl> - void handle ( Reorder * ) final { } <nl> + / / Open the for loop . <nl> + Statement * mutate ( IfThenElse * ) final ; <nl> <nl> - / / Update for loop structure based on producing provided TensorView <nl> - void updateView ( TensorView * ) ; <nl> + / / Remake operations with TensorIndex <nl> + Statement * mutate ( UnaryOp * ) final ; <nl> + Statement * mutate ( BinaryOp * ) final ; <nl> <nl> / / TensorViews are all based on symbolic sizes . When we first initialize them <nl> / / we don ' t know if they ' re inputs or outputs which would mean that they have <nl> new file mode 100644 <nl> index 000000000000 . . 7eee9ef8d20c <nl> mmm / dev / null <nl> ppp b / torch / csrc / jit / codegen / cuda / lower_loops . cpp <nl> <nl> + # include < torch / csrc / jit / codegen / cuda / lower_loops . h > <nl> + # include < torch / csrc / jit / codegen / cuda / arith . h > <nl> + # include < torch / csrc / jit / codegen / cuda / lower_utils . h > <nl> + <nl> + # include < torch / csrc / jit / codegen / cuda / index_compute . h > <nl> + # include < torch / csrc / jit / codegen / cuda / ir_iostream . h > <nl> + # include < torch / csrc / jit / codegen / cuda / predicate_compute . h > <nl> + <nl> + namespace torch { <nl> + namespace jit { <nl> + namespace fuser { <nl> + / / all the way in the loop nest , grab predicate <nl> + / * <nl> + for ( i : ceil ( I / 4 ) ) { <nl> + for ( j : ceil ( J / 128 ) ) { <nl> + <nl> + if ( i * 4 + 3 < I & & j * 128 + 127 < J ) { <nl> + for ( k : 4 ) <nl> + for ( l : 128 ) <nl> + T0 [ ( i * 4 + k ) * J + j * 128 + l ] = … <nl> + } else { <nl> + for ( k : 4 ) <nl> + for ( l : 128 ) <nl> + if ( i * 4 + k < I & & j * 128 + l < J ) <nl> + T0 [ ( i * 4 + k ) * J + j * 128 + l ] = … <nl> + } <nl> + <nl> + } <nl> + } <nl> + * / <nl> + <nl> + / / Custom dispatch for Expr , want to find out of it ' s a TV op <nl> + void UnrollPass : : handle ( Expr * expr ) { <nl> + OptOutDispatch : : handle ( expr ) ; <nl> + } <nl> + <nl> + namespace { <nl> + Int * getPredicate ( const TensorView * const pred_tv , std : : vector < Val * > indices ) { <nl> + TensorIndex * ti = new TensorIndex ( <nl> + pred_tv , IndexCompute : : computeIndices ( pred_tv , std : : move ( indices ) ) ) ; <nl> + std : : vector < Int * > all_preds = PredicateCompute : : computePredicates ( ti ) ; <nl> + <nl> + std : : vector < Int * > preds ; <nl> + <nl> + Int * one = new Int ( 1 ) ; <nl> + <nl> + for ( Int * pred : all_preds ) <nl> + if ( ! pred - > sameAs ( one ) ) <nl> + preds . push_back ( pred ) ; <nl> + <nl> + if ( preds . size ( ) = = 0 ) { <nl> + return one ; <nl> + } else { <nl> + Int * cond = preds [ 0 ] ; <nl> + <nl> + for ( decltype ( preds . size ( ) ) i { 1 } ; i < preds . size ( ) ; i + + ) <nl> + cond = static_cast < Int * > ( andOp ( cond , preds [ i ] ) ) ; <nl> + <nl> + return cond ; <nl> + } <nl> + } <nl> + } / / namespace <nl> + <nl> + / / Open the for loop . <nl> + void UnrollPass : : handle ( ForLoop * fl ) { <nl> + / / Setup for loop scoping <nl> + for_loops . push_back ( fl ) ; <nl> + bool prev_unroll = within_unroll ; <nl> + within_unroll = ir_utils : : isUnrolledFor ( fl ) | | within_unroll ; <nl> + <nl> + for ( auto expr : fl - > body ( ) . exprs ( ) ) { <nl> + OptOutDispatch : : handle ( expr ) ; <nl> + } <nl> + <nl> + TensorView * out ; <nl> + bool has_TV_op = false ; <nl> + for ( Expr * expr : fl - > body ( ) . exprs ( ) ) <nl> + if ( ir_utils : : isTVOp ( expr ) ) { <nl> + / / Predicate determining op for unroll <nl> + out = ir_utils : : asTV ( expr - > output ( 0 ) ) ; <nl> + has_TV_op = true ; <nl> + break ; <nl> + } <nl> + <nl> + if ( within_unroll & & has_TV_op ) { <nl> + / / Setup unrolled loop information : <nl> + <nl> + / / Indices used to detect when we can unroll a loop safely <nl> + / / For loops outside the unroll , it ' s just he index , for loops inside <nl> + / / the unroll , if it ' s a thread it ' s the thread index , otherwise it ' s <nl> + / / the size - 1 <nl> + std : : vector < Val * > unroll_pred_inds ; <nl> + auto it = for_loops . begin ( ) ; <nl> + while ( it ! = for_loops . end ( ) ) { <nl> + if ( ir_utils : : isUnrolledFor ( * it ) ) <nl> + break ; <nl> + unroll_pred_inds . push_back ( ( * it ) - > index ( ) ) ; <nl> + it + + ; <nl> + } <nl> + <nl> + / / This is the outer most loop that needs to be unrolled <nl> + ForLoop * first_unroll = * it ; <nl> + <nl> + / / Indicies inside the unroll <nl> + while ( it ! = for_loops . end ( ) ) { <nl> + IterDomain * id = ( * it ) - > iter_domain ( ) ; <nl> + if ( id - > isThread ( ) ) <nl> + unroll_pred_inds . push_back ( ( * it ) - > index ( ) ) ; <nl> + else <nl> + unroll_pred_inds . push_back ( sub ( id - > extent ( ) , new Int ( 1 ) ) ) ; <nl> + it + + ; <nl> + } <nl> + <nl> + / / Make predicates for the unrolling , and the epilogue <nl> + Int * unroll_predicate = getPredicate ( out , unroll_pred_inds ) ; <nl> + <nl> + / / Make the IfThenElse controlling the unrolling <nl> + IfThenElse * unroll_ite = <nl> + new IfThenElse ( unroll_predicate , { } , { } , first_unroll - > parentScope ( ) ) ; <nl> + <nl> + / / Get the loop nest for the unrolled path <nl> + ForLoop * unrolled_loop = <nl> + scope_utils : : cloneLoopNest ( first_unroll , unroll_ite ) ; <nl> + unroll_ite - > body ( ) . push_back ( unrolled_loop ) ; <nl> + <nl> + / / Loop nest for inlined path <nl> + ForLoop * inlined_loop = <nl> + scope_utils : : cloneLoopNest ( first_unroll , unroll_ite ) ; <nl> + unroll_ite - > elseBody ( ) . push_back ( inlined_loop ) ; <nl> + <nl> + / / Inner most inlined loop <nl> + Expr * inner_most_inlined_loop = <nl> + scope_utils : : firstInnerMostScope ( inlined_loop ) ; <nl> + <nl> + loop_replacement_map . insert ( { first_unroll , unroll_ite } ) ; <nl> + <nl> + bool first_expr = true ; <nl> + for ( auto expr : fl - > body ( ) . exprs ( ) ) { <nl> + if ( ! ir_utils : : isTVOp ( expr ) ) <nl> + continue ; <nl> + <nl> + / / Setup the expressions that need predicates around them . <nl> + Int * inline_predicate = <nl> + getPredicate ( out , scope_utils : : getLoopIndices ( for_loops . back ( ) ) ) ; <nl> + IfThenElse * inline_ite = <nl> + new IfThenElse ( inline_predicate , { expr } , { } , inner_most_inlined_loop ) ; <nl> + std : : unordered_map < Expr * , Expr * > inline_replacement_map ; <nl> + inline_replacement_map . emplace ( std : : pair < Expr * , Expr * > ( expr , inline_ite ) ) ; <nl> + scope_utils : : replaceExprsInScope ( <nl> + inner_most_inlined_loop , inline_replacement_map ) ; <nl> + <nl> + } / / for expr <nl> + <nl> + } else { / / if ( ! within_unroll ) <nl> + <nl> + for ( auto expr : fl - > body ( ) . exprs ( ) ) { <nl> + if ( ! ir_utils : : isTVOp ( expr ) ) <nl> + continue ; <nl> + <nl> + / / ! within_unroll <nl> + TensorView * out = ir_utils : : asTV ( ir_utils : : asExpr ( expr ) - > outputs ( ) [ 0 ] ) ; <nl> + Int * pred = <nl> + getPredicate ( out , scope_utils : : getLoopIndices ( for_loops . back ( ) ) ) ; <nl> + if ( ! pred - > isOneInt ( ) ) { <nl> + IfThenElse * inline_ite = <nl> + new IfThenElse ( pred , { expr } , { } , for_loops . back ( ) ) ; <nl> + for_loops . back ( ) - > body ( ) . insert_before ( expr , inline_ite ) ; <nl> + for_loops . back ( ) - > body ( ) . erase ( expr ) ; <nl> + } <nl> + } <nl> + } / / else ( if ( ! within_unroll ) ) <nl> + for_loops . pop_back ( ) ; <nl> + bool within_unroll = prev_unroll ; <nl> + } <nl> + <nl> + / / Generate the loop nest structure and place it in lowered_exprs <nl> + void UnrollPass : : computeMap ( ) { <nl> + FusionGuard fg ( fusion_ ) ; <nl> + <nl> + / / Initialize members of the class <nl> + active_view = nullptr ; <nl> + active_view_axis = 0 ; <nl> + <nl> + / / Run through loop nests and further lower the expressions <nl> + for ( auto * expr : incoming_exprs_ ) { <nl> + OptOutDispatch : : handle ( expr ) ; <nl> + } <nl> + } <nl> + <nl> + std : : vector < Expr * > UnrollPass : : runPass ( <nl> + Fusion * fusion , <nl> + const std : : vector < Expr * > & exprs ) { <nl> + FusionGuard fg ( fusion ) ; <nl> + UnrollPass up ( fusion , exprs ) ; <nl> + up . computeMap ( ) ; <nl> + std : : vector < Expr * > mutated_exprs ; <nl> + for ( Expr * expr : exprs ) { <nl> + if ( up . loop_replacement_map . find ( expr ) ! = up . loop_replacement_map . end ( ) ) { <nl> + mutated_exprs . push_back ( up . loop_replacement_map [ expr ] ) ; <nl> + } else { <nl> + if ( ir_utils : : isScope ( expr ) ) <nl> + scope_utils : : replaceExprsInScope ( expr , up . loop_replacement_map ) ; <nl> + mutated_exprs . push_back ( expr ) ; <nl> + } <nl> + } <nl> + return mutated_exprs ; <nl> + } <nl> + <nl> + void LoopNestGenerator : : pushAlloc ( TensorView * tv ) { <nl> + TORCH_INTERNAL_ASSERT ( <nl> + ! ( FusionGuard : : getCurFusion ( ) - > hasInput ( tv ) | | <nl> + FusionGuard : : getCurFusion ( ) - > hasOutput ( tv ) ) , <nl> + " Tried to allocate an input or output tensor . " ) ; <nl> + <nl> + / / Compute at axis can be = = tv - > nDims ( ) meaning it ' s inline <nl> + decltype ( tv - > nDims ( ) ) alloc_pos = 0 ; <nl> + bool reset = true ; <nl> + while ( alloc_pos < = tv - > nDims ( ) ) { <nl> + if ( tv - > hasComputeAt ( ) & & alloc_pos = = tv - > getComputeAtAxis ( ) ) { <nl> + reset = false ; <nl> + break ; <nl> + } <nl> + if ( alloc_pos < tv - > nDims ( ) & & <nl> + tv - > getComputeAtAxis ( alloc_pos ) - > parallel_method ( ) = = <nl> + ParallelType : : Unroll ) { <nl> + reset = false ; <nl> + break ; <nl> + } <nl> + alloc_pos + + ; <nl> + } <nl> + alloc_pos = reset ? 0 : alloc_pos ; <nl> + <nl> + std : : vector < Val * > alloc_dims ; <nl> + for ( auto i = alloc_pos ; i < tv - > nDims ( ) ; i + + ) { <nl> + IterDomain * dim = tv - > getComputeAtAxis ( i ) ; <nl> + if ( dim - > isThreadDim ( ) ) <nl> + continue ; <nl> + / / TORCH_INTERNAL_ASSERT ( ) <nl> + alloc_dims . push_back ( dim - > extent ( ) ) ; <nl> + } <nl> + <nl> + Val * size ; <nl> + if ( alloc_dims . size ( ) = = 0 ) { <nl> + size = new Int ( 1 ) ; <nl> + } else { <nl> + size = alloc_dims [ 0 ] ; <nl> + for ( decltype ( alloc_dims . size ( ) ) i { 1 } ; i < alloc_dims . size ( ) ; i + + ) { <nl> + size = mul ( size , alloc_dims [ i ] ) ; <nl> + } <nl> + } <nl> + Allocate * alloc = new Allocate ( tv , size ) ; <nl> + if ( alloc_pos = = 0 ) { <nl> + lowered_exprs . insert ( lowered_exprs . begin ( ) , alloc ) ; <nl> + } else if ( alloc_pos = = for_loops . size ( ) ) { <nl> + / / inline <nl> + scope_utils : : pushBack ( for_loops [ alloc_pos - 1 ] , alloc ) ; <nl> + } else { <nl> + scope_utils : : insertBefore ( <nl> + for_loops [ alloc_pos - 1 ] , for_loops [ alloc_pos ] , alloc ) ; <nl> + } <nl> + } <nl> + <nl> + / / Clear out the last recorded computeAtView <nl> + void LoopNestGenerator : : clearActiveView ( ) { <nl> + active_view_axis = 0 ; <nl> + active_view = nullptr ; <nl> + } <nl> + <nl> + / / Set active views from computeAtView <nl> + void LoopNestGenerator : : setActiveView ( const TensorView * const tv ) { <nl> + active_view_axis = tv - > getComputeAtAxis ( ) ; <nl> + active_view = tv - > getComputeAtView ( ) ; <nl> + } <nl> + <nl> + void LoopNestGenerator : : openFor ( IterDomain * id ) { <nl> + if ( for_loops . size ( ) > 0 ) { <nl> + ForLoop * new_scope = scope_utils : : openFor ( for_loops . back ( ) , id ) ; <nl> + for_loops . push_back ( new_scope ) ; <nl> + } else { <nl> + for_loops . push_back ( scope_utils : : openFor ( nullptr , id ) ) ; <nl> + lowered_exprs . push_back ( for_loops . back ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + void LoopNestGenerator : : pushBack ( Expr * expr ) { <nl> + if ( for_loops . size ( ) = = 0 ) <nl> + lowered_exprs . push_back ( expr ) ; <nl> + else <nl> + scope_utils : : pushBack ( for_loops . back ( ) , expr ) ; <nl> + } <nl> + <nl> + / * <nl> + * This is one of the most complex parts of the code lowering logic . what we <nl> + * need to do is : 1 ) Reduce loop structure <nl> + * - Reset all loops if active_view = = nullptr ( I ' m not the last in a series <nl> + * of computeAts ) <nl> + * - Else reduce to active_view_axis if loop_depth > active_view_axis <nl> + * 2 ) Set active_view ( _axis ) <nl> + * - If there is a computeAt set for this TV <nl> + * 3 ) Open to compute At <nl> + * - If there is a computeAt set for this TV <nl> + * 4 ) Allocate the output . <nl> + * 5 ) If this is a reduction , initialize the output ( open for loops to inner <nl> + * most , predicate , initialize , close predicate , close to computeAt ) 6 ) Open to <nl> + * inner most loop 7 ) Open predicate 8 ) Run operation 9 ) Close predicate <nl> + * / <nl> + <nl> + / / Update fors based on tv . <nl> + void LoopNestGenerator : : updateLoopNest ( TensorView * tv ) { <nl> + / / 1 ) Reduce loop structure <nl> + if ( active_view ! = nullptr ) { <nl> + / / - Else reduce to active_view_axis if loop_depth > active_view_axis <nl> + auto depth = for_loops . size ( ) ; <nl> + for ( auto i = depth ; i > active_view_axis ; i - - ) { <nl> + for_loops . pop_back ( ) ; <nl> + } <nl> + } <nl> + <nl> + if ( tv - > hasComputeAt ( ) ) { <nl> + / / 2 ) Set active_view ( _axis ) <nl> + / / - If there is a computeAt set for this TV <nl> + setActiveView ( tv ) ; <nl> + <nl> + / / 3 ) Open to compute At <nl> + / / - If there is a computeAt set for this TV <nl> + auto depth = for_loops . size ( ) ; <nl> + <nl> + for ( auto i = depth ; i < tv - > getComputeAtAxis ( ) ; i + + ) <nl> + openFor ( tv - > getComputeAtAxis ( i ) ) ; <nl> + } else { <nl> + if ( active_view ! = nullptr ) <nl> + / / If we ' re the last computeAt of a block , active view should match this <nl> + / / tv <nl> + TORCH_INTERNAL_ASSERT ( <nl> + tv - > sameAs ( active_view ) , <nl> + " Error detected in code lowering . Expected " , <nl> + active_view , <nl> + " but recieved " , <nl> + tv ) ; <nl> + <nl> + clearActiveView ( ) ; <nl> + } <nl> + / / 4 ) Allocate the output . <nl> + if ( ! FusionGuard : : getCurFusion ( ) - > hasInput ( tv ) & & <nl> + ! FusionGuard : : getCurFusion ( ) - > hasOutput ( tv ) ) { <nl> + pushAlloc ( tv ) ; <nl> + } <nl> + / / TODO : <nl> + / / 5 ) If this is a reduction , initialize the output ( open for loops to inner <nl> + / / most , predicate , initialize , close predicate , close to computeAt ) <nl> + <nl> + / / 6 ) Open to inner most loop <nl> + for ( decltype ( tv - > nDims ( ) ) i = for_loops . size ( ) ; i < tv - > nDims ( ) ; i + + ) <nl> + openFor ( tv - > getComputeAtAxis ( i ) ) ; <nl> + } <nl> + <nl> + / / Custom dispatch for Expr , want to find out of it ' s a TV op <nl> + void LoopNestGenerator : : handle ( Expr * expr ) { <nl> + if ( ! ir_utils : : isTVOp ( expr ) ) <nl> + return ; <nl> + <nl> + TensorView * out = static_cast < TensorView * > ( expr - > output ( 0 ) ) ; <nl> + updateLoopNest ( out ) ; <nl> + <nl> + pushBack ( expr ) ; <nl> + } <nl> + <nl> + / / Generate the loop nest structure and place it in lowered_exprs <nl> + void LoopNestGenerator : : generate ( ) { <nl> + FusionGuard fg ( fusion_ ) ; <nl> + <nl> + / / Initialize members of the class <nl> + lowered_exprs = std : : vector < Expr * > ( ) ; <nl> + active_view = nullptr ; <nl> + active_view_axis = 0 ; <nl> + <nl> + std : : vector < Expr * > exprs = fusion_ - > exprs ( true ) ; <nl> + for ( auto * expr : exprs ) <nl> + handle ( expr ) ; <nl> + } <nl> + <nl> + } / / namespace fuser <nl> + } / / namespace jit <nl> + } / / namespace torch <nl> new file mode 100644 <nl> index 000000000000 . . 3cc1ef86fcef <nl> mmm / dev / null <nl> ppp b / torch / csrc / jit / codegen / cuda / lower_loops . h <nl> <nl> + # pragma once <nl> + # include < torch / csrc / WindowsTorchApiMacro . h > <nl> + <nl> + # include < torch / csrc / jit / codegen / cuda / dispatch . h > <nl> + <nl> + # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> + namespace torch { <nl> + namespace jit { <nl> + namespace fuser { <nl> + <nl> + struct UnrollPass : public OptOutDispatch { <nl> + private : <nl> + std : : unordered_map < Expr * , Expr * > loop_replacement_map ; <nl> + Fusion * fusion_ ; <nl> + const std : : vector < Expr * > & incoming_exprs_ ; <nl> + <nl> + / / Keep all for loops conveniently to make unrolling easier <nl> + std : : vector < ForLoop * > for_loops ; <nl> + <nl> + / / keep track if we ' re within an unrolled loop <nl> + bool within_unroll = false ; <nl> + <nl> + / / Track the last computeAt TensorView and axis <nl> + const TensorView * active_view ; <nl> + unsigned int active_view_axis ; <nl> + <nl> + / / Custom dispatch for Expr , want to find out of it ' s a TV op <nl> + void handle ( Expr * ) final ; <nl> + <nl> + / / Open the for loop . <nl> + void handle ( ForLoop * ) final ; <nl> + <nl> + UnrollPass ( Fusion * _fusion , const std : : vector < Expr * > & _incoming_exprs ) <nl> + : fusion_ ( _fusion ) , incoming_exprs_ ( _incoming_exprs ) { } <nl> + <nl> + void computeMap ( ) ; <nl> + <nl> + public : <nl> + static std : : vector < Expr * > runPass ( <nl> + Fusion * fusion , <nl> + const std : : vector < Expr * > & exprs ) ; <nl> + } ; <nl> + <nl> + struct TORCH_CUDA_API LoopNestGenerator : public OptOutDispatch { <nl> + private : <nl> + std : : vector < Expr * > lowered_exprs ; <nl> + Fusion * fusion_ ; <nl> + <nl> + / / Track the last computeAt TensorView and axis <nl> + const TensorView * active_view ; <nl> + unsigned int active_view_axis ; <nl> + <nl> + / / Keep all for loops conveniently to make unrolling easier <nl> + std : : vector < ForLoop * > for_loops ; <nl> + <nl> + / / Get Register allocation statement for tensorview <nl> + void pushAlloc ( TensorView * ) ; <nl> + <nl> + / / Clear out the last recorded computeAtView <nl> + void clearActiveView ( ) ; <nl> + / / Set active views from computeAtView <nl> + void setActiveView ( const TensorView * const ) ; <nl> + <nl> + / / Open a new inner most for loop <nl> + void openFor ( IterDomain * ) ; <nl> + <nl> + / / Wrap pushBack in lower_utils if active_scope is null we want it to go <nl> + / / straight to lower_exprs <nl> + void pushBack ( Expr * ) ; <nl> + <nl> + / / Update for loop structure based on this TensorView <nl> + void updateLoopNest ( TensorView * ) ; <nl> + <nl> + / / Check if a TV op , generate for loop nest around it <nl> + void handle ( Expr * ) final ; <nl> + <nl> + / / Generate the loop nest structure and place it in lowered_exprs <nl> + void generate ( ) ; <nl> + <nl> + LoopNestGenerator ( Fusion * _fusion ) : fusion_ ( _fusion ) { } <nl> + <nl> + public : <nl> + static std : : vector < Expr * > getLoopNest ( Fusion * fusion ) { <nl> + FusionGuard fg ( fusion ) ; <nl> + LoopNestGenerator lng ( fusion ) ; <nl> + lng . generate ( ) ; <nl> + return lng . lowered_exprs ; <nl> + } <nl> + } ; <nl> + <nl> + } / / namespace fuser <nl> + } / / namespace jit <nl> + } / / namespace torch <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . bb71dfb28db3 <nl> mmm / dev / null <nl> ppp b / torch / csrc / jit / codegen / cuda / lower_utils . cpp <nl> <nl> + # include < torch / csrc / jit / codegen / cuda / lower_utils . h > <nl> + # include < torch / csrc / jit / codegen / cuda / ir_iostream . h > <nl> + namespace torch { <nl> + namespace jit { <nl> + namespace fuser { <nl> + <nl> + namespace scope_utils { <nl> + <nl> + / / START SCOPE HELPER SYSTEMS <nl> + namespace { <nl> + <nl> + struct forLoopIndices : private OptInDispatch { <nl> + private : <nl> + std : : vector < Val * > inds_ ; <nl> + void handle ( ForLoop * fl ) final { <nl> + inds_ . insert ( inds_ . begin ( ) , fl - > index ( ) ) ; <nl> + } <nl> + <nl> + void handle ( IfThenElse * ite ) final { } <nl> + <nl> + void handle ( Expr * expr ) final { <nl> + OptInDispatch : : handle ( expr ) ; <nl> + } <nl> + <nl> + public : <nl> + static std : : vector < Val * > get ( Expr * scope ) { <nl> + forLoopIndices fli ; <nl> + Expr * it = scope ; <nl> + while ( it ! = nullptr ) { <nl> + fli . handle ( it ) ; <nl> + it = scope_utils : : getParent ( it ) ; <nl> + } <nl> + return fli . inds_ ; <nl> + } <nl> + } ; <nl> + <nl> + struct forLoopIDs : private OptInDispatch { <nl> + private : <nl> + std : : vector < IterDomain * > IDs_ ; <nl> + void handle ( ForLoop * fl ) final { <nl> + IDs_ . insert ( IDs_ . begin ( ) , fl - > iter_domain ( ) ) ; <nl> + } <nl> + <nl> + void handle ( IfThenElse * ite ) final { } <nl> + <nl> + void handle ( Expr * expr ) final { <nl> + OptInDispatch : : handle ( expr ) ; <nl> + } <nl> + <nl> + public : <nl> + static std : : vector < IterDomain * > get ( Expr * scope ) { <nl> + forLoopIDs fli ; <nl> + Expr * it = scope ; <nl> + while ( it ! = nullptr ) { <nl> + fli . handle ( it ) ; <nl> + it = scope_utils : : getParent ( it ) ; <nl> + } <nl> + return fli . IDs_ ; <nl> + } <nl> + } ; <nl> + <nl> + struct forLoopCount : private OptInDispatch { <nl> + private : <nl> + unsigned int count_ = 0 ; <nl> + <nl> + void handle ( ForLoop * fl ) final { <nl> + count_ + + ; <nl> + } <nl> + <nl> + void handle ( IfThenElse * ite ) final { } <nl> + <nl> + void handle ( Expr * expr ) final { <nl> + OptInDispatch : : handle ( expr ) ; <nl> + } <nl> + <nl> + public : <nl> + static unsigned int get ( Expr * scope ) { <nl> + forLoopCount flc ; <nl> + Expr * it = scope ; <nl> + while ( it ! = nullptr ) { <nl> + flc . handle ( it ) ; <nl> + it = scope_utils : : getParent ( it ) ; <nl> + } <nl> + return flc . count_ ; <nl> + } <nl> + } ; <nl> + <nl> + struct scopePushBack : private OptInDispatch { <nl> + private : <nl> + Expr * expr_ ; <nl> + void handle ( ForLoop * fl ) final { <nl> + fl - > body ( ) . push_back ( expr_ ) ; <nl> + } <nl> + <nl> + void handle ( IfThenElse * ite ) final { <nl> + ite - > body ( ) . push_back ( expr_ ) ; <nl> + } <nl> + <nl> + void handle ( Expr * expr ) final { <nl> + OptInDispatch : : handle ( expr ) ; <nl> + } <nl> + <nl> + scopePushBack ( Expr * expr ) : expr_ ( expr ) { } <nl> + <nl> + public : <nl> + static void push ( Expr * scope , Expr * expr ) { <nl> + scopePushBack pb ( expr ) ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + expr ! = nullptr & & scope ! = nullptr , <nl> + " Cannot push back , scope or expr is a nullptr . " ) ; <nl> + pb . handle ( scope ) ; <nl> + } <nl> + } ; <nl> + <nl> + struct scopeInsertBefore : private OptInDispatch { <nl> + private : <nl> + Expr * ref_ ; <nl> + Expr * expr_ ; <nl> + void handle ( ForLoop * fl ) final { <nl> + fl - > body ( ) . insert_before ( ref_ , expr_ ) ; <nl> + } <nl> + <nl> + void handle ( IfThenElse * ite ) final { <nl> + ite - > body ( ) . insert_before ( ref_ , expr_ ) ; <nl> + } <nl> + <nl> + void handle ( Expr * expr ) final { <nl> + OptInDispatch : : handle ( expr ) ; <nl> + } <nl> + <nl> + scopeInsertBefore ( Expr * ref , Expr * expr ) : ref_ ( ref ) , expr_ ( expr ) { } <nl> + <nl> + public : <nl> + static void insert ( Expr * scope , Expr * ref , Expr * expr ) { <nl> + scopeInsertBefore scb ( ref , expr ) ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + expr ! = nullptr & & scope ! = nullptr , <nl> + " Cannot push back , scope or expr is a nullptr . " ) ; <nl> + scb . handle ( scope ) ; <nl> + } <nl> + } ; <nl> + <nl> + struct parentScope : private OptInDispatch { <nl> + private : <nl> + Expr * parent_ = nullptr ; <nl> + <nl> + void handle ( ForLoop * fl ) final { <nl> + parent_ = fl - > parentScope ( ) ; <nl> + } <nl> + <nl> + void handle ( IfThenElse * ite ) final { <nl> + parent_ = ite - > parentScope ( ) ; <nl> + } <nl> + <nl> + void handle ( Expr * expr ) final { <nl> + OptInDispatch : : handle ( expr ) ; <nl> + } <nl> + <nl> + public : <nl> + static Expr * get ( Expr * scope ) { <nl> + parentScope sp ; <nl> + sp . handle ( scope ) ; <nl> + return sp . parent_ ; <nl> + } <nl> + } ; <nl> + <nl> + struct scopeClearExprs : private OptInDispatch { <nl> + private : <nl> + Expr * _expr = nullptr ; <nl> + void handle ( ForLoop * fl ) final { <nl> + fl - > body ( ) . clear ( ) ; <nl> + } <nl> + <nl> + void handle ( IfThenElse * ite ) final { <nl> + ite - > body ( ) . clear ( ) ; <nl> + } <nl> + <nl> + void handle ( Expr * expr ) final { <nl> + OptInDispatch : : handle ( expr ) ; <nl> + } <nl> + <nl> + public : <nl> + static void clear ( Expr * scope ) { <nl> + scopeClearExprs sce ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + scope ! = nullptr , " Cannot clear scope , scope is a nullptr . " ) ; <nl> + sce . handle ( scope ) ; <nl> + } <nl> + } ; <nl> + <nl> + void assertScope ( Expr * expr ) { <nl> + TORCH_INTERNAL_ASSERT ( <nl> + expr - > getExprType ( ) = = ExprType : : ForLoop | | <nl> + expr - > getExprType ( ) = = ExprType : : IfThenElse , <nl> + " Assert Scope failed when calling a scope_util function . " ) ; <nl> + } <nl> + <nl> + struct CloneLoopNest : public OptOutMutator { <nl> + private : <nl> + Expr * parent_scope_ = nullptr ; <nl> + Expr * to_clone_ = nullptr ; <nl> + <nl> + Statement * mutate ( ForLoop * fl ) final { <nl> + std : : vector < Expr * > mutated_exprs ; <nl> + for ( Expr * expr : fl - > body ( ) . exprs ( ) ) { <nl> + mutated_exprs . push_back ( ir_utils : : asExpr ( OptOutMutator : : mutate ( expr ) ) ) ; <nl> + } <nl> + if ( fl = = to_clone_ ) <nl> + return new ForLoop ( <nl> + fl - > index ( ) , fl - > iter_domain ( ) , mutated_exprs , parent_scope_ ) ; <nl> + return new ForLoop ( <nl> + fl - > index ( ) , fl - > iter_domain ( ) , mutated_exprs , fl - > parentScope ( ) ) ; <nl> + } <nl> + <nl> + CloneLoopNest ( Expr * _to_clone , Expr * _parent_scope ) <nl> + : parent_scope_ ( _parent_scope ) , to_clone_ ( _to_clone ) { } <nl> + <nl> + public : <nl> + static ForLoop * getClone ( ForLoop * _to_clone , Expr * _parent_scope ) { <nl> + TORCH_INTERNAL_ASSERT ( <nl> + _to_clone ! = nullptr , <nl> + " Tried to clone a scope , but received a nullptr . " ) ; <nl> + CloneLoopNest cln ( _to_clone , _parent_scope ) ; <nl> + return ir_utils : : asForLoop ( ir_utils : : asExpr ( cln . mutate ( _to_clone ) ) ) ; <nl> + } <nl> + } ; <nl> + <nl> + struct ReplaceExprsInScope : public OptOutDispatch { <nl> + private : <nl> + std : : unordered_map < Expr * , Expr * > replacement_map_ ; <nl> + <nl> + void handle ( Expr * expr ) final { <nl> + OptOutDispatch : : handle ( expr ) ; <nl> + } <nl> + <nl> + void handle ( ForLoop * fl ) final { <nl> + for ( Expr * expr : fl - > body ( ) . exprs ( ) ) { <nl> + auto it = replacement_map_ . find ( expr ) ; <nl> + if ( it = = replacement_map_ . end ( ) ) { <nl> + handle ( expr ) ; <nl> + continue ; <nl> + } <nl> + fl - > body ( ) . insert_before ( expr , replacement_map_ [ expr ] ) ; <nl> + fl - > body ( ) . erase ( expr ) ; <nl> + } <nl> + } <nl> + <nl> + void handle ( IfThenElse * ite ) final { <nl> + for ( Expr * expr : ite - > body ( ) . exprs ( ) ) { <nl> + auto it = replacement_map_ . find ( expr ) ; <nl> + if ( it = = replacement_map_ . end ( ) ) { <nl> + handle ( expr ) ; <nl> + continue ; <nl> + } <nl> + ite - > body ( ) . insert_before ( expr , replacement_map_ [ expr ] ) ; <nl> + ite - > body ( ) . erase ( expr ) ; <nl> + } <nl> + for ( Expr * expr : ite - > elseBody ( ) . exprs ( ) ) { <nl> + auto it = replacement_map_ . find ( expr ) ; <nl> + if ( it = = replacement_map_ . end ( ) ) { <nl> + handle ( expr ) ; <nl> + continue ; <nl> + } <nl> + ite - > elseBody ( ) . insert_before ( expr , replacement_map_ [ expr ] ) ; <nl> + ite - > elseBody ( ) . erase ( expr ) ; <nl> + } <nl> + } <nl> + <nl> + ReplaceExprsInScope ( std : : unordered_map < Expr * , Expr * > _replacement_map ) <nl> + : replacement_map_ ( std : : move ( _replacement_map ) ) { } <nl> + <nl> + public : <nl> + static void replace ( <nl> + Expr * scope , <nl> + std : : unordered_map < Expr * , Expr * > replacement_map ) { <nl> + ReplaceExprsInScope reis ( std : : move ( replacement_map ) ) ; <nl> + reis . handle ( scope ) ; <nl> + } <nl> + } ; <nl> + <nl> + struct FirstInnerMostScope : private OptInDispatch { <nl> + private : <nl> + Expr * active_scope = nullptr ; <nl> + <nl> + void handle ( ForLoop * fl ) final { <nl> + for ( auto expr : fl - > body ( ) . exprs ( ) ) { <nl> + if ( ir_utils : : isScope ( expr ) ) { <nl> + active_scope = expr ; <nl> + return ; <nl> + } <nl> + } <nl> + active_scope = nullptr ; <nl> + } <nl> + <nl> + void handle ( IfThenElse * ite ) final { <nl> + for ( auto expr : ite - > body ( ) . exprs ( ) ) { <nl> + if ( ir_utils : : isScope ( expr ) ) { <nl> + active_scope = expr ; <nl> + return ; <nl> + } <nl> + } <nl> + for ( auto expr : ite - > elseBody ( ) . exprs ( ) ) { <nl> + if ( ir_utils : : isScope ( expr ) ) { <nl> + active_scope = expr ; <nl> + return ; <nl> + } <nl> + } <nl> + active_scope = nullptr ; <nl> + } <nl> + <nl> + Expr * getInner ( Expr * expr ) { <nl> + OptInDispatch : : handle ( expr ) ; <nl> + return active_scope ; <nl> + } <nl> + <nl> + public : <nl> + static Expr * get ( Expr * scope ) { <nl> + TORCH_INTERNAL_ASSERT ( <nl> + scope ! = nullptr , <nl> + " Tried to get inner most scope , but was provided nullptr . " ) ; <nl> + <nl> + FirstInnerMostScope fims ; <nl> + Expr * inner = fims . getInner ( scope ) ; <nl> + while ( fims . getInner ( inner ) ! = nullptr ) <nl> + inner = fims . getInner ( inner ) ; <nl> + return inner ; <nl> + } <nl> + } ; <nl> + <nl> + / / END SCOPE HELPER SYSTEMS <nl> + } / / namespace <nl> + <nl> + / / Grab the index variables of the active loop nest <nl> + std : : vector < Val * > getLoopIndices ( Expr * scope ) { <nl> + if ( scope = = nullptr ) <nl> + return std : : vector < Val * > ( ) ; <nl> + assertScope ( scope ) ; <nl> + return forLoopIndices : : get ( scope ) ; <nl> + } <nl> + <nl> + / / Grab the iterDomains of the active loops <nl> + std : : vector < IterDomain * > getLoopIterDomains ( Expr * scope ) { <nl> + if ( scope = = nullptr ) <nl> + return std : : vector < IterDomain * > ( ) ; <nl> + assertScope ( scope ) ; <nl> + return forLoopIDs : : get ( scope ) ; <nl> + } <nl> + <nl> + / / Track how far our for loop scope is <nl> + unsigned int computeForDepth ( Expr * scope ) { <nl> + if ( scope = = nullptr ) <nl> + return 0 ; <nl> + assertScope ( scope ) ; <nl> + return forLoopCount : : get ( scope ) ; <nl> + } <nl> + <nl> + / / Push back an expr to scope <nl> + void pushBack ( Expr * scope , Expr * expr ) { <nl> + TORCH_INTERNAL_ASSERT ( <nl> + scope ! = nullptr , " Scope is a nullptr , cannot push an expr to it . " ) ; <nl> + assertScope ( scope ) ; <nl> + scopePushBack : : push ( scope , expr ) ; <nl> + } <nl> + <nl> + / / Insert expr in scope before ref <nl> + void insertBefore ( Expr * scope , Expr * ref , Expr * expr ) { <nl> + scopeInsertBefore : : insert ( scope , ref , expr ) ; <nl> + } <nl> + <nl> + / / Return the parent of the active scope <nl> + Expr * getParent ( Expr * scope ) { <nl> + TORCH_INTERNAL_ASSERT ( <nl> + scope ! = nullptr , <nl> + " Tried to close the active scope , but there isn ' t one set . " ) ; <nl> + assertScope ( scope ) ; <nl> + return parentScope : : get ( scope ) ; <nl> + } <nl> + <nl> + / / Open a new inner most for loop <nl> + ForLoop * openFor ( Expr * scope , IterDomain * id ) { <nl> + ForLoop * new_scope = nullptr ; <nl> + if ( id - > isThread ( ) ) { <nl> + new_scope = new ForLoop ( <nl> + new NamedScalar ( stringify ( id - > parallel_method ( ) ) , DataType : : Int ) , <nl> + id , <nl> + { } , <nl> + scope ) ; <nl> + } else { <nl> + new_scope = new ForLoop ( new Int ( ) , id , { } , scope ) ; <nl> + } <nl> + if ( scope ! = nullptr ) <nl> + pushBack ( scope , new_scope ) ; <nl> + return new_scope ; <nl> + } <nl> + <nl> + / / Close the inner most for loop <nl> + Expr * closeScope ( Expr * scope ) { <nl> + TORCH_INTERNAL_ASSERT ( <nl> + scope ! = nullptr , " Tried to close a scope but got a nullptr . " ) ; <nl> + return getParent ( scope ) ; <nl> + } <nl> + <nl> + / / Clear all expressions from the scope <nl> + Expr * clearScope ( Expr * scope ) { <nl> + TORCH_INTERNAL_ASSERT ( <nl> + scope ! = nullptr , " Tried to clear a scope but got a nullptr . " ) ; <nl> + assertScope ( scope ) ; <nl> + scopeClearExprs : : clear ( scope ) ; <nl> + return scope ; <nl> + } <nl> + <nl> + ForLoop * cloneLoopNest ( ForLoop * to_clone , Expr * parent_scope ) { <nl> + return CloneLoopNest : : getClone ( to_clone , parent_scope ) ; <nl> + } <nl> + <nl> + void replaceExprsInScope ( <nl> + Expr * scope , <nl> + std : : unordered_map < Expr * , Expr * > replacement_map ) { <nl> + TORCH_INTERNAL_ASSERT ( <nl> + replacement_map . find ( scope ) = = replacement_map . end ( ) , <nl> + " Error trying to replace expressions in a scope , scope wants to be replaced entirely . " ) ; <nl> + ReplaceExprsInScope : : replace ( scope , std : : move ( replacement_map ) ) ; <nl> + } <nl> + <nl> + Expr * firstInnerMostScope ( Expr * scope ) { <nl> + return FirstInnerMostScope : : get ( scope ) ; <nl> + } <nl> + <nl> + } / / namespace scope_utils <nl> + <nl> + namespace ir_utils { <nl> + <nl> + bool isTV ( const Val * const val ) { <nl> + return val - > getValType ( ) . value ( ) = = ValType : : TensorView ; <nl> + } <nl> + <nl> + / / Check if we ' re a TensorView op that we can generate code for . <nl> + bool isTVOp ( const Expr * expr ) { <nl> + if ( expr - > nOutputs ( ) = = 1 & & isTV ( expr - > output ( 0 ) ) & & <nl> + ( expr - > getExprType ( ) . value ( ) = = ExprType : : BinaryOp | | <nl> + expr - > getExprType ( ) . value ( ) = = ExprType : : UnaryOp ) ) <nl> + return true ; <nl> + return false ; <nl> + } <nl> + <nl> + void ASSERT_EXPR ( Statement * stmt ) { <nl> + TORCH_INTERNAL_ASSERT ( <nl> + stmt - > isExpr ( ) , <nl> + " Tried to generate a kernel but hit a non expression during lowering : " , <nl> + stmt ) ; <nl> + } <nl> + <nl> + Expr * asExpr ( Statement * stmt ) { <nl> + ASSERT_EXPR ( stmt ) ; <nl> + return static_cast < Expr * > ( stmt ) ; <nl> + } <nl> + <nl> + TensorView * asTV ( Val * val ) { <nl> + TORCH_INTERNAL_ASSERT ( isTV ( val ) ) ; <nl> + return static_cast < TensorView * > ( val ) ; <nl> + } <nl> + <nl> + bool isScope ( const Expr * expr ) { <nl> + return expr - > getExprType ( ) = = ExprType : : ForLoop | | <nl> + expr - > getExprType ( ) = = ExprType : : IfThenElse ; <nl> + } <nl> + <nl> + ForLoop * asForLoop ( Statement * stmt ) { <nl> + Expr * expr = asExpr ( stmt ) ; <nl> + TORCH_INTERNAL_ASSERT ( expr - > getExprType ( ) = = ExprType : : ForLoop ) ; <nl> + return static_cast < ForLoop * > ( expr ) ; <nl> + } <nl> + <nl> + const TensorView * asConstTV ( const Val * const val ) { <nl> + TORCH_INTERNAL_ASSERT ( isTV ( val ) ) ; <nl> + return static_cast < const TensorView * > ( val ) ; <nl> + } <nl> + <nl> + bool isUnrolledFor ( const Expr * expr ) { <nl> + if ( expr - > getExprType ( ) ! = ExprType : : ForLoop ) { <nl> + return false ; <nl> + } <nl> + return static_cast < const ForLoop * > ( expr ) - > iter_domain ( ) - > parallel_method ( ) = = <nl> + ParallelType : : Unroll ; <nl> + } <nl> + <nl> + } / / namespace ir_utils <nl> + <nl> + } / / namespace fuser <nl> + } / / namespace jit <nl> + } / / namespace torch <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 000000000000 . . 208cd7d01903 <nl> mmm / dev / null <nl> ppp b / torch / csrc / jit / codegen / cuda / lower_utils . h <nl> <nl> + # pragma once <nl> + <nl> + # include < torch / csrc / WindowsTorchApiMacro . h > <nl> + <nl> + # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> + <nl> + / / Provides utilities for dealing with nested ForLoop and IfThenElse scopes <nl> + <nl> + namespace torch { <nl> + namespace jit { <nl> + namespace fuser { <nl> + <nl> + namespace scope_utils { <nl> + <nl> + / / Grab the index variables of the active loop nest <nl> + std : : vector < Val * > getLoopIndices ( Expr * scope ) ; <nl> + <nl> + / / Grab the iterDomains of the active loops <nl> + std : : vector < IterDomain * > getLoopIterDomains ( Expr * scope ) ; <nl> + <nl> + / / Track how far our for loop scope is <nl> + unsigned int computeForDepth ( Expr * scope ) ; <nl> + <nl> + / / Push back an expr to scope <nl> + void pushBack ( Expr * scope , Expr * expr ) ; <nl> + <nl> + / / Insert expr in scope before ref <nl> + void insertBefore ( Expr * scope , Expr * ref , Expr * expr ) ; <nl> + <nl> + / / Return the parent of the active scope <nl> + Expr * getParent ( Expr * scope ) ; <nl> + <nl> + / / Open a new inner most for loop <nl> + ForLoop * openFor ( Expr * scope , IterDomain * ) ; <nl> + <nl> + / / Close the inner most for loop <nl> + Expr * closeScope ( Expr * scope ) ; <nl> + <nl> + / / Clear all expressions from the scope <nl> + Expr * clearScope ( Expr * scope ) ; <nl> + <nl> + / / Provide a new for loop matching the one provided <nl> + ForLoop * cloneLoopNest ( ForLoop * to_clone , Expr * parent_scope ) ; <nl> + <nl> + / / Run through a scope and replace expressions inside with replacement_map <nl> + void replaceExprsInScope ( <nl> + Expr * scope , <nl> + std : : unordered_map < Expr * , Expr * > replacement_map ) ; <nl> + <nl> + Expr * firstInnerMostScope ( Expr * scope ) ; <nl> + <nl> + } / / namespace scope_utils <nl> + <nl> + namespace ir_utils { <nl> + <nl> + bool isTV ( const Val * const ) ; <nl> + <nl> + bool isTVOp ( const Expr * ) ; <nl> + <nl> + void ASSERT_EXPR ( Statement * ) ; <nl> + <nl> + bool isScope ( const Expr * ) ; <nl> + <nl> + Expr * asExpr ( Statement * ) ; <nl> + <nl> + TensorView * asTV ( Val * ) ; <nl> + <nl> + ForLoop * asForLoop ( Statement * ) ; <nl> + <nl> + const TensorView * asConstTV ( const Val * const ) ; <nl> + <nl> + bool isUnrolledFor ( const Expr * ) ; <nl> + <nl> + } / / namespace ir_utils <nl> + } / / namespace fuser <nl> + } / / namespace jit <nl> + } / / namespace torch <nl> mmm a / torch / csrc / jit / codegen / cuda / manager . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / manager . cpp <nl> <nl> # include < torch / csrc / jit / codegen / cuda / manager . h > <nl> - # include < torch / csrc / jit / codegen / cuda / kernel . h > <nl> - # include < torch / csrc / jit / codegen / cuda / parser . h > <nl> - <nl> # include < torch / csrc / jit / codegen / cuda / fusion . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> + # include < torch / csrc / jit / codegen / cuda / kernel_cache . h > <nl> + # include < torch / csrc / jit / codegen / cuda / parser . h > <nl> # include < torch / csrc / jit / codegen / cuda / utils . h > <nl> # include < torch / csrc / jit / passes / canonicalize . h > <nl> + # include < torch / csrc / jit / passes / shape_analysis . h > <nl> <nl> # include < unordered_map > <nl> <nl> namespace cuda { <nl> <nl> namespace { <nl> <nl> + KernelArgsReq expandSizeSupport ( const at : : IntArrayRef sizes ) { <nl> + KernelArgsReq req ; <nl> + for ( auto size : sizes ) { <nl> + req . low_ . push_back ( size ) ; <nl> + req . hi_ . push_back ( size ) ; <nl> + } <nl> + return req ; <nl> + } <nl> + <nl> / / CudaFusionManager holds compiled ` CudaKernel ` and handles all interfacing <nl> / / including compilation and execution . <nl> / / <nl> class CudaFusionManager { <nl> / / is even more restricting in a good way ) <nl> int32_t registerOrGetCacheId ( std : : shared_ptr < Graph > & graph ) { <nl> std : : lock_guard < std : : mutex > guard ( mutex_ ) ; <nl> + <nl> / / prepare graph for lowering ; <nl> + / / TODO : this is needed . Otherwise caching on tensor size would not work , as <nl> + / / different tensor size would result in unique string representation . <nl> + EraseShapeInformation ( graph ) ; <nl> Canonicalize ( graph , false ) ; <nl> - / / EraseShapeInformation ( graph ) ; <nl> auto repr = graph - > toString ( false ) ; <nl> <nl> / / create new graph_cache_ entry ; <nl> class CudaFusionManager { <nl> <nl> graph_cache_ [ repr ] = kernel_id ; <nl> <nl> - Fusion fusion ; <nl> - / / lower torch : : jit : : Graph to torch : : jit : : fuser : : cuda : : fusion <nl> - parseJitIR ( graph , fusion ) ; <nl> + / / create entry for cached kernel ; <nl> + kernel_cache_ . insert ( { kernel_id , CudaKernelCache ( ) } ) ; <nl> <nl> - / / default constructor via accessing empty key ; <nl> - compileKernel ( fusion , kernel_cache_ [ kernel_id ] ) ; <nl> - <nl> - return kernel_id ; <nl> - } else { <nl> - return graph_cache_ [ repr ] ; <nl> + / / TODO : we should compile here using profiled information : <nl> + / / size ( range ) / stride ( contiguity ) <nl> } <nl> + <nl> + return graph_cache_ [ repr ] ; <nl> } ; <nl> <nl> void runFusionNode ( <nl> int32_t kernel_id , <nl> + std : : shared_ptr < Graph > & graph , <nl> const at : : ArrayRef < IValue > inputs , <nl> std : : vector < at : : Tensor > outputs ) { <nl> + std : : lock_guard < std : : mutex > guard ( mutex_ ) ; <nl> TORCH_CHECK ( <nl> kernel_cache_ . count ( kernel_id ) ! = 0 , " kernel id not recognized " ) ; <nl> <nl> - CudaKernel & cuda_kernel_entry = kernel_cache_ [ kernel_id ] ; <nl> + / / TODO : temporary hack <nl> + auto cuda_kernel = <nl> + kernel_cache_ [ kernel_id ] . getKernelPtr ( outputs [ 0 ] . sizes ( ) ) ; <nl> + if ( cuda_kernel ) { <nl> + / / TODO : update launch config for specific sizes ; <nl> + / / maybe we should store it in CudaKernel and compute it later <nl> + runKernel ( * cuda_kernel , inputs , outputs ) ; <nl> + } else { <nl> + / / major HACK ! <nl> + auto kernel_arg_req = expandSizeSupport ( outputs [ 0 ] . sizes ( ) ) ; <nl> + cuda_kernel = <nl> + kernel_cache_ [ kernel_id ] . allocateKernelInCache ( kernel_arg_req ) ; <nl> <nl> - runKernel ( cuda_kernel_entry , inputs , outputs ) ; <nl> + / / lower torch : : jit : : Graph to torch : : jit : : fuser : : cuda : : fusion <nl> + Fusion fusion ; <nl> + / / TODO : pass contiguity infor as well as size req , so we can apply proper <nl> + / / transform to computation <nl> + / / we should propagate more information back : <nl> + / / 1 . device ; <nl> + / / 2 . launch config ; <nl> + parseJitIR ( graph , fusion ) ; <nl> + cuda_kernel . value ( ) - > device_ = 0 ; <nl> + <nl> + / / NVRTC compile kernel <nl> + compileKernel ( fusion , cuda_kernel . value ( ) ) ; <nl> + <nl> + runKernel ( * cuda_kernel , inputs , outputs ) ; <nl> + } <nl> } <nl> <nl> private : <nl> class CudaFusionManager { <nl> } ; <nl> <nl> std : : unordered_map < std : : string , int32_t > graph_cache_ ; <nl> - std : : unordered_map < int64_t , CudaKernel > kernel_cache_ ; <nl> + std : : unordered_map < int64_t , CudaKernelCache > kernel_cache_ ; <nl> <nl> int32_t next_unique_id_ = 0 ; <nl> } ; <nl> void runCudaFusionGroup ( const Node * const fusion_node , Stack & stack ) { <nl> int32_t kernel_id = fusion_node - > i ( attr : : cache_id ) ; <nl> <nl> / / Currently we just construct I / O tensors for static graph ; <nl> - const std : : shared_ptr < Graph > graph = fusion_node - > g ( attr : : Subgraph ) ; <nl> + std : : shared_ptr < Graph > graph = fusion_node - > g ( attr : : Subgraph ) ; <nl> + <nl> const auto nInputs = graph - > inputs ( ) . size ( ) ; <nl> at : : ArrayRef < IValue > inputs = last ( stack , nInputs ) ; <nl> <nl> + / / shape inference in graph <nl> + bool matched_static_inputs = true ; <nl> + for ( int i = 0 ; i < nInputs ; i + + ) { <nl> + auto & static_input = graph - > inputs ( ) [ i ] ; <nl> + auto & dynamic_input = inputs [ i ] ; / / this is FILO stack <nl> + if ( ( * dynamic_input . type ( ) ) ! = ( * static_input - > type ( ) ) ) { <nl> + matched_static_inputs = false ; <nl> + break ; <nl> + } <nl> + if ( dynamic_input . isTensor ( ) ) { <nl> + at : : Tensor inp_tensor = dynamic_input . toTensor ( ) ; <nl> + / / we need to return use shape inference when static shape is not complete <nl> + / / even though it is compatible with profiling graph . <nl> + / / TODO : we could relax on a bunch of checks here , like strides & gradient <nl> + if ( ! static_input - > type ( ) - > cast < TensorType > ( ) - > sizes ( ) . isComplete ( ) | | <nl> + ! static_input - > type ( ) <nl> + - > cast < TensorType > ( ) <nl> + - > isCompatibleWithInCurrentExecutionContext ( inp_tensor ) ) { <nl> + matched_static_inputs = false ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / TODO : expose the API to populate shape inference . This allows separate CI <nl> + / / tests <nl> + / / matched_static_inputs = false ; <nl> + if ( ! matched_static_inputs ) { <nl> + / / update shape information per the new inputs ; <nl> + / / shape inference done through PyTorch JIT shape propagation ; <nl> + EraseShapeInformation ( graph ) ; <nl> + for ( int i = 0 ; i < nInputs ; i + + ) { <nl> + graph - > inputs ( ) [ i ] - > setType ( inputs [ i ] . type ( ) ) ; <nl> + } <nl> + / / shape inference <nl> + PropagateInputShapes ( graph ) ; <nl> + } <nl> + <nl> / / we need to construct outputs ; <nl> std : : vector < at : : Tensor > outputs ; <nl> for ( const auto * const output : graph - > outputs ( ) ) { <nl> void runCudaFusionGroup ( const Node * const fusion_node , Stack & stack ) { <nl> outputs . push_back ( tensor ) ; <nl> } <nl> <nl> - CudaFusionManager : : getManager ( ) . runFusionNode ( kernel_id , inputs , outputs ) ; <nl> + CudaFusionManager : : getManager ( ) . runFusionNode ( <nl> + kernel_id , graph , inputs , outputs ) ; <nl> <nl> drop ( stack , inputs . size ( ) ) ; <nl> stack . insert ( <nl> mmm a / torch / csrc / jit / codegen / cuda / mutator . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / mutator . cpp <nl> void OptOutMutator : : mutate ( Fusion * fusion ) { <nl> / / MUTATE FUNCTIONS FOR VALS <nl> <nl> Statement * OptOutMutator : : mutate ( IterDomain * id ) { <nl> - Val * s = mutateAsVal ( id - > size ( ) ) - > asVal ( ) ; <nl> - if ( ! s - > sameAs ( id - > size ( ) ) ) { <nl> - Val * mutated_val = <nl> - new IterDomain ( s , id - > parallel_method ( ) , id - > isReduction ( ) ) ; <nl> - registerMutation ( id , mutated_val ) ; <nl> - return mutated_val ; <nl> - } <nl> - return id ; <nl> + Val * s = mutateAsVal ( id - > start ( ) ) - > asVal ( ) ; <nl> + Val * e = mutateAsVal ( id - > extent ( ) ) - > asVal ( ) ; <nl> + if ( s - > sameAs ( id - > start ( ) ) & & e - > sameAs ( id - > extent ( ) ) ) <nl> + return id ; <nl> + <nl> + Val * mutated_val = <nl> + new IterDomain ( s , e , id - > parallel_method ( ) , id - > isReduction ( ) ) ; <nl> + registerMutation ( id , mutated_val ) ; <nl> + return mutated_val ; <nl> } <nl> <nl> Statement * OptOutMutator : : mutate ( TensorDomain * td ) { <nl> std : : vector < IterDomain * > dom ; <nl> bool mutated = false ; <nl> - for ( decltype ( td - > size ( ) ) i = 0 ; i < td - > size ( ) ; i + + ) { <nl> + for ( decltype ( td - > nDims ( ) ) i = 0 ; i < td - > nDims ( ) ; i + + ) { <nl> IterDomain * id = static_cast < IterDomain * > ( mutateAsVal ( td - > axis ( i ) ) ) ; <nl> dom . push_back ( id ) ; <nl> if ( ! id - > sameAs ( td - > axis ( i ) ) ) <nl> Statement * OptOutMutator : : mutate ( BinaryOp * bop ) { <nl> return new BinaryOp ( bop - > getBinaryOpType ( ) , out , lhs , rhs ) ; <nl> } <nl> <nl> - Statement * OptOutMutator : : mutate ( ForLoop * n ) { <nl> - return n ; <nl> + Statement * OptOutMutator : : mutate ( ForLoop * fl ) { <nl> + Val * index = mutateAsVal ( fl - > index ( ) ) - > asVal ( ) ; <nl> + Val * val_id = mutateAsVal ( fl - > iter_domain ( ) ) - > asVal ( ) ; <nl> + <nl> + TORCH_INTERNAL_ASSERT ( val_id - > getValType ( ) = = ValType : : IterDomain ) ; <nl> + IterDomain * id = static_cast < IterDomain * > ( val_id ) ; <nl> + <nl> + bool is_mutated = ! index - > sameAs ( fl - > index ( ) ) ; <nl> + is_mutated = is_mutated | ! id - > sameAs ( fl - > iter_domain ( ) ) ; <nl> + <nl> + std : : vector < Expr * > mutated_exprs ; <nl> + for ( auto expr : fl - > body ( ) . exprs ( ) ) { <nl> + Statement * mutated_stmt = mutate ( expr ) ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + mutated_stmt - > isExpr ( ) , <nl> + " While mutating a for loop , received a non - expression for a body entry . " ) ; <nl> + Expr * mutated_expr = static_cast < Expr * > ( mutated_stmt ) ; <nl> + mutated_exprs . push_back ( mutated_expr ) ; <nl> + / / could use sameAs here , but we ' d have to check the output value separately <nl> + is_mutated = is_mutated | ( mutated_expr ! = expr ) ; <nl> + } <nl> + <nl> + if ( is_mutated ) { <nl> + auto newFL = new ForLoop ( index , id , mutated_exprs , fl - > parentScope ( ) ) ; <nl> + return newFL ; <nl> + } <nl> + <nl> + return fl ; <nl> } <nl> <nl> - Statement * OptOutMutator : : mutate ( IfThenElse * n ) { <nl> - return n ; <nl> + Statement * OptOutMutator : : mutate ( IfThenElse * ite ) { <nl> + Val * val_cond = mutateAsVal ( ite - > cond ( ) ) - > asVal ( ) ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + val_cond - > getValType ( ) . value ( ) = = ValType : : Scalar & & <nl> + val_cond - > getDataType ( ) . value ( ) = = DataType : : Int ) ; <nl> + Int * cond = static_cast < Int * > ( val_cond ) ; <nl> + <nl> + bool is_mutated = ! cond - > sameAs ( ite - > cond ( ) ) ; <nl> + <nl> + std : : vector < Expr * > mutated_exprs ; <nl> + for ( auto expr : ite - > body ( ) . exprs ( ) ) { <nl> + Statement * mutated_stmt = mutate ( expr ) ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + mutated_stmt - > isExpr ( ) , <nl> + " While mutating a for loop , received a non - expression for a body entry . " ) ; <nl> + Expr * mutated_expr = static_cast < Expr * > ( mutated_stmt ) ; <nl> + mutated_exprs . push_back ( mutated_expr ) ; <nl> + / / could use sameAs here , but we ' d have to check the output value separately <nl> + is_mutated = is_mutated | ( mutated_expr ! = expr ) ; <nl> + } <nl> + <nl> + std : : vector < Expr * > mutated_else_exprs ; <nl> + for ( auto expr : ite - > elseBody ( ) . exprs ( ) ) { <nl> + Statement * mutated_stmt = mutate ( expr ) ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + mutated_stmt - > isExpr ( ) , <nl> + " While mutating a for loop , received a non - expression for a body entry . " ) ; <nl> + Expr * mutated_expr = static_cast < Expr * > ( mutated_stmt ) ; <nl> + mutated_else_exprs . push_back ( mutated_expr ) ; <nl> + / / could use sameAs here , but we ' d have to check the output value separately <nl> + is_mutated = is_mutated | ( mutated_expr ! = expr ) ; <nl> + } <nl> + <nl> + if ( is_mutated ) { <nl> + auto newITE = new IfThenElse ( <nl> + cond , ite - > body ( ) . exprs ( ) , ite - > elseBody ( ) . exprs ( ) , ite - > parentScope ( ) ) ; <nl> + return newITE ; <nl> + } <nl> + <nl> + return ite ; <nl> } <nl> <nl> / / START REPLACE ALL <nl> mmm a / torch / csrc / jit / codegen / cuda / mutator . h <nl> ppp b / torch / csrc / jit / codegen / cuda / mutator . h <nl> <nl> <nl> # include < torch / csrc / jit / codegen / cuda / dispatch . h > <nl> # include < torch / csrc / jit / codegen / cuda / ir_base_nodes . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> <nl> # include < unordered_map > <nl> <nl> mmm a / torch / csrc / jit / codegen / cuda / parser . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / parser . cpp <nl> <nl> # include < torch / csrc / jit / codegen / cuda / parser . h > <nl> <nl> # include < torch / csrc / jit / codegen / cuda / arith . h > <nl> + # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> # include < torch / csrc / jit / codegen / cuda / ir_iostream . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> + <nl> # include < torch / csrc / jit / frontend / function_schema_parser . h > <nl> # include < torch / csrc / jit / ir / constants . h > <nl> <nl> namespace cuda { <nl> <nl> namespace { <nl> <nl> - typedef Val CgValue ; <nl> - typedef Expr CgOp ; <nl> + typedef Val * CgValue ; <nl> + typedef Expr * CgOp ; <nl> <nl> typedef void ( <nl> - * ParseFuncPtr ) ( const Node * const , std : : unordered_map < size_t , CgValue * > & ) ; <nl> + * ParseFuncPtr ) ( const Node * const , std : : unordered_map < size_t , CgValue > & ) ; <nl> <nl> / / TODO : add a mutex to make it thread safe . <nl> class IrParser { <nl> + private : <nl> + static const int nthreads = 128 ; <nl> + static const int unroll_factor = 4 ; <nl> + <nl> public : <nl> IrParser ( std : : shared_ptr < Graph > graph , Fusion & fusion ) <nl> : graph_ ( std : : move ( graph ) ) , fusion_ ( & fusion ) { <nl> class IrParser { <nl> } <nl> } <nl> <nl> + / / Fuses pointwise ops with loop unrolling ( factor = 4 ) . <nl> void parse ( ) { <nl> FusionGuard fg ( fusion_ ) ; <nl> auto block = graph_ - > block ( ) ; <nl> <nl> + / / in case of broadcast , we don ' t support explicit broadcast , so we need to <nl> + / / convert / expand all inputs tensors to comply to the broadcasted size . <nl> + / / This supports very limited case , which we try to accomodate in graph <nl> + / / partition , that we only merge nodes with identical output shapes . <nl> + int broadcast_dim = <nl> + block - > outputs ( ) [ 0 ] - > type ( ) - > cast < TensorType > ( ) - > dim ( ) . value ( ) ; <nl> + <nl> / / register all inputs ; <nl> / / shape propagation during parsing is effctively done in parsing rules , as <nl> / / we only explicitly register inputs in the graph . <nl> for ( auto val : block - > inputs ( ) ) { <nl> - TORCH_CHECK ( registerValue ( val ) ) ; <nl> + TORCH_CHECK ( registerValue ( val , broadcast_dim ) ) ; <nl> fusion_ - > addInput ( value_maps_ [ val - > unique ( ) ] ) ; <nl> } <nl> <nl> class IrParser { <nl> / / Merge all dimensions because we ' re only supporting pointwise <nl> while ( out - > nDims ( ) > 1 ) <nl> out - > merge ( 0 ) ; <nl> - / / Split into 128 so we can map blocks / threads <nl> - out - > split ( 0 , 128 ) ; <nl> + / / Split into 128 which will be bockDim . x <nl> + out - > split ( 0 , nthreads ) ; <nl> + / / Split by another 4 which will be our unroll factor <nl> + out - > split ( 0 , unroll_factor ) ; <nl> <nl> / / Map blocks / threads <nl> out - > axis ( 0 ) - > parallelize ( ParallelType : : BIDx ) ; <nl> + out - > axis ( 1 ) - > parallelize ( ParallelType : : Unroll ) ; <nl> out - > axis ( - 1 ) - > parallelize ( ParallelType : : TIDx ) ; <nl> } <nl> <nl> - for ( auto jit_input : block - > inputs ( ) ) { <nl> - TensorView * inp = <nl> - static_cast < TensorView * > ( value_maps_ [ jit_input - > unique ( ) ] ) ; <nl> - for ( auto jit_output : block - > outputs ( ) ) { <nl> - TensorView * out = <nl> - static_cast < TensorView * > ( value_maps_ [ jit_output - > unique ( ) ] ) ; <nl> - if ( DependencyCheck : : isDependencyOf ( inp , out ) ) { <nl> - inp - > computeAt ( out , - 1 ) ; <nl> - break ; <nl> - } <nl> + / / Run through outputs , grab all inputs of outputs <nl> + / / squeeze with computeAt to set overall structure . <nl> + for ( auto jit_output : block - > outputs ( ) ) { <nl> + TensorView * out = <nl> + static_cast < TensorView * > ( value_maps_ [ jit_output - > unique ( ) ] ) ; <nl> + <nl> + for ( TensorView * inp : fusion_ - > inputsOf ( out ) ) { <nl> + inp - > computeAt ( out , 1 ) ; <nl> } <nl> } <nl> + <nl> + / / Run through intermediates , unroll , and bind their axes <nl> + for ( auto entry : value_maps_ ) { <nl> + CgValue val = entry . second ; <nl> + if ( fusion_ - > hasInput ( val ) | | fusion_ - > hasOutput ( val ) ) <nl> + continue ; <nl> + if ( val - > getValType ( ) . value ( ) ! = ValType : : TensorView ) <nl> + continue ; <nl> + TensorView * tv = static_cast < TensorView * > ( val ) ; <nl> + tv - > axis ( - 2 ) - > parallelize ( ParallelType : : Unroll ) ; <nl> + tv - > axis ( - 1 ) - > parallelize ( ParallelType : : TIDx ) ; <nl> + } <nl> } <nl> <nl> static bool canParseNode ( const Node * const node ) { <nl> class IrParser { <nl> . push_back ( std : : make_pair ( op , fn ) ) ; <nl> } <nl> <nl> - protected : <nl> + private : <nl> static void parseBinaryOpWithAlpha ( <nl> const Node * const node , <nl> - std : : unordered_map < size_t , CgValue * > & value_maps ) { <nl> + std : : unordered_map < size_t , CgValue > & value_maps ) { <nl> static std : : unordered_map < Symbol , BinaryOpType > op_mapping ( { <nl> { aten : : add , BinaryOpType : : Add } , <nl> { aten : : sub , BinaryOpType : : Sub } , <nl> class IrParser { <nl> <nl> static void parseBinaryOp ( <nl> const Node * const node , <nl> - std : : unordered_map < size_t , CgValue * > & value_maps ) { <nl> + std : : unordered_map < size_t , CgValue > & value_maps ) { <nl> static std : : unordered_map < Symbol , BinaryOpType > op_mapping ( { <nl> { aten : : mul , BinaryOpType : : Mul } , <nl> { aten : : div , BinaryOpType : : Div } , <nl> class IrParser { <nl> } <nl> } <nl> <nl> - bool registerValue ( const JitValue * val ) { <nl> - return registerTensor ( val ) | | registerScalar ( val ) ; <nl> + bool registerValue ( const JitValue * val , int broadcast_dim = - 1 ) { <nl> + return registerTensor ( val , broadcast_dim ) | | registerScalar ( val ) ; <nl> } <nl> <nl> bool registerScalar ( const JitValue * val ) { <nl> if ( val - > type ( ) - > isSubtypeOf ( static_cast < c10 : : TypePtr > ( FloatType : : get ( ) ) ) ) { <nl> - CgValue * cg_val ; <nl> + CgValue cg_val ; <nl> if ( auto ival = constant_as < float > ( val ) ) { <nl> cg_val = new Float ( ival . value ( ) ) ; <nl> } else { <nl> class IrParser { <nl> return true ; <nl> } else if ( val - > type ( ) - > isSubtypeOf ( <nl> static_cast < c10 : : TypePtr > ( IntType : : get ( ) ) ) ) { <nl> - CgValue * cg_val ; <nl> + CgValue cg_val ; <nl> if ( auto ival = constant_as < int > ( val ) ) { <nl> cg_val = new Float ( ival . value ( ) ) ; <nl> } else { <nl> class IrParser { <nl> return false ; <nl> } <nl> <nl> - bool registerTensor ( const JitValue * val ) { <nl> - CgValue * cg_val ; <nl> + bool registerTensor ( const JitValue * val , int broadcast_dim = - 1 ) { <nl> + CgValue cg_val ; <nl> if ( val - > isCompleteTensor ( ) ) { <nl> + auto tensor_type = val - > type ( ) - > cast < TensorType > ( ) ; <nl> + if ( broadcast_dim > = 0 ) { <nl> + tensor_type = tensor_type - > withDim ( broadcast_dim ) ; <nl> + } <nl> / / TODO : make this a static function in Tensor class ; <nl> / / create tensor ; <nl> - cg_val = new TensorView ( val - > type ( ) - > cast < TensorType > ( ) ) ; <nl> + cg_val = new TensorView ( tensor_type ) ; <nl> value_maps_ . emplace ( val - > unique ( ) , cg_val ) ; <nl> return true ; <nl> } <nl> class IrParser { <nl> Fusion * fusion_ ; <nl> <nl> / / maps from JitValue : : unique ( ) to fusion Val ; <nl> - std : : unordered_map < size_t , CgValue * > value_maps_ ; <nl> + std : : unordered_map < size_t , CgValue > value_maps_ ; <nl> / / parsing rule registry . <nl> static std : : unordered_map < <nl> Symbol , <nl> mmm a / torch / csrc / jit / codegen / cuda / partition . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / partition . cpp <nl> <nl> # include < torch / csrc / jit / codegen / cuda / partition . h > <nl> + # include < ATen / core / jit_type . h > <nl> # include < torch / csrc / jit / codegen / cuda / parser . h > <nl> <nl> namespace torch { <nl> inline bool isFusableNode ( const Node * const node ) { <nl> return ( isNodeParsible ( node ) | | node - > kind ( ) = = prim : : CudaFusionGroup ) ; <nl> } <nl> <nl> + / / TODO : how would symbolic shape from profiling executor play with this ? <nl> + static bool compatible_broadcast_shape ( <nl> + const c10 : : VaryingShape & e , <nl> + const c10 : : VaryingShape & a ) { <nl> + if ( e . isComplete ( ) & & a . isComplete ( ) ) { <nl> + auto e_size = e . concrete_sizes ( ) . value ( ) ; <nl> + auto a_size = a . concrete_sizes ( ) . value ( ) ; <nl> + for ( size_t i = 0 ; i < e_size . size ( ) ; i + + ) { <nl> + if ( e_size [ i ] ! = a_size [ i ] ) { <nl> + return false ; <nl> + } <nl> + } <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> } / / namespace <nl> <nl> bool isFusableCudaFusionGroup ( const Node * const node ) { <nl> bool isFusableCudaFusionGroup ( <nl> if ( isFusableNode ( node ) ) { <nl> auto device = getDevice ( fusion ) ; <nl> <nl> - return ( device . has_value ( ) & & isFusableDevice ( node , device . value ( ) ) ) ; <nl> + auto tensor_type = fusion - > outputs ( ) [ 0 ] - > type ( ) - > cast < TensorType > ( ) ; <nl> + if ( tensor_type ) { <nl> + for ( auto output : node - > outputs ( ) ) { <nl> + / / We only check shape of tensor output <nl> + auto output_type = output - > type ( ) - > cast < TensorType > ( ) ; <nl> + if ( output_type ) { <nl> + bool output_tensor = false ; <nl> + for ( auto use : output - > uses ( ) ) { <nl> + if ( use . user ! = fusion ) { <nl> + output_tensor = true ; <nl> + break ; <nl> + } <nl> + } <nl> + / / if the output is not used by outside , there ' s no need to check its <nl> + / / shape <nl> + if ( output_tensor & & <nl> + ! compatible_broadcast_shape ( <nl> + tensor_type - > sizes ( ) , output_type - > sizes ( ) ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> + } <nl> + return ( device . has_value ( ) & & isFusableDevice ( node , device . value ( ) ) ) ; <nl> + } <nl> } <nl> return false ; <nl> } <nl> mmm a / torch / csrc / jit / codegen / cuda / predicate_compute . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / predicate_compute . cpp <nl> std : : vector < Int * > PredicateCompute : : computePredicates ( const TensorIndex * ti ) { <nl> const TensorView * tv = ti - > view ( ) ; <nl> <nl> TensorDomain * root = tv - > getRootDomain ( ) ; <nl> - TORCH_CHECK ( root - > size ( ) = = ti - > size ( ) ) ; <nl> - for ( decltype ( ti - > size ( ) ) i { 0 } ; i < ti - > size ( ) ; i + + ) <nl> + TORCH_CHECK ( root - > nDims ( ) = = ti - > nDims ( ) ) ; <nl> + for ( decltype ( ti - > nDims ( ) ) i { 0 } ; i < ti - > nDims ( ) ; i + + ) <nl> <nl> if ( FusionGuard : : getCurFusion ( ) - > origin ( ti - > index ( i ) ) ! = nullptr ) { <nl> - Val * pred = lt ( ti - > index ( i ) , root - > axis ( i ) - > size ( ) ) ; <nl> + Val * pred = lt ( ti - > index ( i ) , root - > axis ( i ) - > extent ( ) ) ; <nl> TORCH_CHECK ( <nl> pred - > getValType ( ) . value ( ) = = ValType : : Scalar & & <nl> pred - > getDataType ( ) . value ( ) = = DataType : : Int ) ; <nl> mmm a / torch / csrc / jit / codegen / cuda / predicate_compute . h <nl> ppp b / torch / csrc / jit / codegen / cuda / predicate_compute . h <nl> <nl> # pragma once <nl> <nl> # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> <nl> / * <nl> * Predicate compute takes a TensorView and set of indices . The number of <nl> deleted file mode 100644 <nl> index 80d8705524ca . . 000000000000 <nl> mmm a / torch / csrc / jit / codegen / cuda / tensor . h <nl> ppp / dev / null <nl> <nl> - # pragma once <nl> - <nl> - # include < torch / csrc / WindowsTorchApiMacro . h > <nl> - <nl> - # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor_meta . h > <nl> - <nl> - / * <nl> - * This file currently contains items associated with tensors , tensor domains , <nl> - * tensor views and transforms associated with them ( split , merge , reorder , <nl> - * compute_at ) . <nl> - * <nl> - * Tensor is our link to the tensors described and used in the JIT . We create <nl> - * our own wrapper version as a stepping stone into our IR structure , this <nl> - * allows us to link our concept of tensors with that of the JIT . <nl> - * <nl> - * IterDomain for now is an annotated size . The size is a range for us to <nl> - * iterate over ( number of elements , not including stride ) . The annotations are <nl> - * associated with if there ' s a parallelization mechanism associated with the <nl> - * iter domain , and if we need to reduce over it . <nl> - * <nl> - * TensorDomain holds a vector ( could be changed to an array ) of IterDomains . It <nl> - * holds an IterDomain for every logical axis in its associated tensor . <nl> - * TensorDomain does not directly hold the Tensor it is associated . <nl> - * TensorDomain ' s primary responsibility is to hold the history of <nl> - * transformations that were used to generate it . This is done through the <nl> - * normal interaction of Expr / Val in Fusion . i . e . if we want to know the <nl> - * previous operation generating a particular TensorDomain we can simply call <nl> - * FusionGuard : : getCurFusion ( ) - > origin ( a_tensor_domain ) which should give us an <nl> - * operation in the list [ split , merge , reorder ] or similar operations that take <nl> - * in a TensorDomain , applies a transformation and outputs a tensor domain . <nl> - * <nl> - * TensorView is the glue between TensorDomain and Tensor . TensorView is <nl> - * intended to be used directly in mathematical operations . TensorView is <nl> - * directly used in the " what " is being computed . TensorView holds a reference <nl> - * to the Tensor it ' s a view of , as well as the TensorDomain of that particular <nl> - * view . TensorView provides the history of the what is being computed and that <nl> - * history can be accessed , similar to the mechanism TensorDomain uses , through <nl> - * normal Expr / Val interactions in Fusion . i . e . <nl> - * FusionGuard : : getCurFusion ( ) - > origin ( a_tensor_view ) which should give us an <nl> - * operation that takes in a TensorView , other inputs ( other TensorViews , or <nl> - * Scalars ) applies a mathematical operation and outputs a TensorView ( and other <nl> - * outputs ? ) . <nl> - * <nl> - * The reason we need TensorView and TensorDomain is that we need to have a <nl> - * record of both what is being computed and how it is being computed . For <nl> - * Example we may have the operation : TV3 [ I , J , K ] = TV2 [ I , J , K ] + TV1 [ I , J , K ] <nl> - * The mathematical operationss here are on the tensor views TV1 , TV2 , and TV3 . <nl> - * This operation is a pointwise operation . To compute this pointwise operation <nl> - * we iterate over the 3D TensorDomain [ I , J , K ] , where K is the fastest <nl> - * changing dimension . <nl> - * <nl> - * For now the functions split , merge , reorder , and compute_at are also in this <nl> - * file and its associated . cpp file . However , they may be moved later . <nl> - * <nl> - * / <nl> - <nl> - namespace torch { <nl> - namespace jit { <nl> - namespace fuser { <nl> - <nl> - struct TransformReplay ; <nl> - struct TensorView ; <nl> - <nl> - TORCH_CUDA_API TensorView * split_ ( TensorView * , int axis , int factor ) ; <nl> - TORCH_CUDA_API TensorView * merge_ ( TensorView * , int axis ) ; <nl> - TORCH_CUDA_API TensorView * reorder_ ( <nl> - TensorView * , <nl> - const std : : unordered_map < int , int > & ) ; <nl> - <nl> - } / / namespace fuser <nl> - } / / namespace jit <nl> - } / / namespace torch <nl> mmm a / torch / csrc / jit / codegen / cuda / tensor_meta . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / tensor_meta . cpp <nl> namespace fuser { <nl> * / <nl> <nl> / / debug print . remove this guy ! <nl> + # ifdef TC_DEBUG <nl> template < typename T > <nl> std : : ostream & operator < < ( std : : ostream & os , const std : : vector < T > & data ) { <nl> os < < " ( " ; <nl> std : : ostream & operator < < ( std : : ostream & os , const std : : vector < T > & data ) { <nl> } <nl> return os < < " ) " ; <nl> } <nl> + # endif <nl> <nl> TensorContiguity : : TensorContiguity ( <nl> const std : : vector < int64_t > & sizes , <nl> mmm a / torch / csrc / jit / codegen / cuda / tensor_view . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / tensor_view . cpp <nl> c10 : : optional < TensorContiguity > infer_contiguity_from_tensor_type ( <nl> <nl> } / / namespace <nl> <nl> - TensorView * split_ ( TensorView * tv , int axis , int factor ) { <nl> - TensorDomain * td = tv - > domain ( ) ; <nl> - <nl> - if ( axis < 0 ) <nl> - axis + = td - > size ( ) ; <nl> - <nl> - assert ( axis > = 0 & & axis < td - > size ( ) ) ; <nl> - <nl> - IterDomain * id = td - > axis ( axis ) ; <nl> - <nl> - if ( id - > parallel_method ( ) ! = ParallelType : : Serial ) <nl> - TORCH_CHECK ( <nl> - false , <nl> - " Splitting an axis of non - Serial iteration is not supported at this time . " <nl> - " Parallelization strategy must be set after calling split . " ) ; <nl> - <nl> - if ( tv - > getComputeAtView ( ) ! = nullptr ) <nl> - if ( axis < tv - > getComputeAtAxis ( ) ) <nl> - TORCH_CHECK ( false , " Cannot split axis within the compute at range . " ) ; <nl> - <nl> - std : : vector < IterDomain * > new_domain ; <nl> - <nl> - Int * fact = new Int ( factor ) ; <nl> - Int * one = new Int ( 1 ) ; <nl> - <nl> - for ( decltype ( td - > size ( ) ) i = 0 ; i < td - > size ( ) ; i + + ) { <nl> - if ( i ! = axis ) <nl> - new_domain . push_back ( td - > axis ( i ) ) ; <nl> - else { <nl> - / / outer loop size <nl> - Val * vo = ceilDiv ( id - > size ( ) , fact ) ; <nl> - Int * so = static_cast < Int * > ( vo ) ; <nl> - <nl> - / / outer loop IterDomain <nl> - IterDomain * ido = <nl> - new IterDomain ( so , id - > parallel_method ( ) , id - > isReduction ( ) ) ; <nl> - new_domain . push_back ( ido ) ; <nl> - <nl> - / / inner loop IterDomain <nl> - IterDomain * idi = <nl> - new IterDomain ( fact , id - > parallel_method ( ) , id - > isReduction ( ) ) ; <nl> - new_domain . push_back ( idi ) ; <nl> - } <nl> - } <nl> - TensorDomain * split_td = new TensorDomain ( new_domain ) ; <nl> - Split * split_node = new Split ( split_td , td , axis , fact ) ; / / For record keeping <nl> - tv - > setDomain ( split_td ) ; <nl> - return tv ; <nl> - } <nl> - <nl> - TensorView * merge_ ( TensorView * tv , int axis ) { <nl> - TensorDomain * td = tv - > domain ( ) ; <nl> - <nl> - if ( axis < 0 ) <nl> - axis + = td - > size ( ) ; <nl> - <nl> - assert ( axis > = 0 & & axis + 1 < td - > size ( ) ) ; <nl> - <nl> - if ( tv - > getComputeAtView ( ) ! = nullptr ) <nl> - if ( axis < tv - > getComputeAtAxis ( ) ) <nl> - TORCH_CHECK ( false , " Cannot split axis within compute at range . " ) ; <nl> - <nl> - IterDomain * first = td - > axis ( axis ) ; <nl> - IterDomain * second = td - > axis ( axis + 1 ) ; <nl> - <nl> - assert ( first - > isReduction ( ) = = second - > isReduction ( ) ) ; <nl> - assert ( first - > parallel_method ( ) = = second - > parallel_method ( ) ) ; <nl> - <nl> - Val * merged_id_size = mul ( first - > size ( ) , second - > size ( ) ) ; <nl> - IterDomain * merged_id = new IterDomain ( <nl> - static_cast < Int * > ( merged_id_size ) , <nl> - first - > parallel_method ( ) , <nl> - first - > isReduction ( ) ) ; <nl> - <nl> - std : : vector < IterDomain * > new_domain ; <nl> - for ( decltype ( td - > size ( ) ) i = 0 ; i < td - > size ( ) ; i + + ) { <nl> - if ( i < axis | | i > axis + 1 ) <nl> - new_domain . push_back ( td - > axis ( i ) ) ; <nl> - else if ( i = = axis ) { <nl> - new_domain . push_back ( merged_id ) ; <nl> - } <nl> - } <nl> - TensorDomain * merged_td = new TensorDomain ( new_domain ) ; <nl> - Merge * merge_node = new Merge ( merged_td , td , axis ) ; / / For record keeping <nl> - tv - > setDomain ( merged_td ) ; <nl> - return tv ; <nl> - } <nl> - <nl> - / * <nl> - * Takes axis2pos map , axis2pos [ old_pos ] = new_pos , to modify the ordering of <nl> - * the iter axes . <nl> - * / <nl> - TensorView * reorder_ ( <nl> - TensorView * tv , <nl> - const std : : unordered_map < int , int > & axis2pos ) { <nl> - TensorDomain * td = tv - > domain ( ) ; <nl> - auto ndims = td - > size ( ) ; <nl> - / / Map to save from previous order , to new order . <nl> - std : : vector < int > pos2axis ( ndims , - 1 ) ; <nl> - <nl> - / / Go through each old and new position , make sure they ' re within 0 - ndims <nl> - for ( std : : pair < int , int > elem : axis2pos ) { <nl> - int old_pos = elem . first ; <nl> - int new_pos = elem . second ; <nl> - <nl> - if ( old_pos < 0 ) <nl> - old_pos + = ndims ; <nl> - if ( new_pos < 0 ) <nl> - new_pos + = ndims ; <nl> - <nl> - assert ( old_pos > = 0 & & old_pos < ndims & & new_pos > = 0 & & new_pos < ndims ) ; <nl> - <nl> - if ( pos2axis [ new_pos ] ! = - 1 ) <nl> - TORCH_CHECK ( false , " Reorder found duplicate destination positions . " ) ; <nl> - <nl> - pos2axis [ new_pos ] = old_pos ; <nl> - } <nl> - <nl> - std : : set < int > old_positions ( pos2axis . begin ( ) , pos2axis . end ( ) ) ; <nl> - old_positions . erase ( - 1 ) ; <nl> - <nl> - if ( old_positions . size ( ) ! = axis2pos . size ( ) ) <nl> - TORCH_INTERNAL_ASSERT ( <nl> - false , " Reorder found duplicate destination positions . " ) ; <nl> - <nl> - std : : set < int > all_positions ; <nl> - for ( decltype ( ndims ) i { 0 } ; i < ndims ; i + + ) <nl> - all_positions . insert ( i ) ; <nl> - <nl> - / / Check what positions haven ' t been specified . <nl> - std : : set < int > positions_left ; <nl> - std : : set_difference ( <nl> - all_positions . begin ( ) , <nl> - all_positions . end ( ) , <nl> - old_positions . begin ( ) , <nl> - old_positions . end ( ) , <nl> - std : : inserter ( positions_left , positions_left . end ( ) ) ) ; <nl> - <nl> - / / Fill in positions that weren ' t specified , in relative order , <nl> - / / in empty spots in the set of new positions . <nl> - / / pos2axis [ new_position ] = old_position <nl> - auto it = positions_left . begin ( ) ; / / old positions left <nl> - for ( decltype ( pos2axis . size ( ) ) i = 0 ; i < pos2axis . size ( ) ; i + + ) { <nl> - if ( pos2axis [ i ] = = - 1 ) <nl> - pos2axis [ i ] = * it + + ; <nl> - } <nl> - <nl> - / / pos2axis is now filled <nl> - if ( tv - > getComputeAtView ( ) ! = nullptr ) { <nl> - for ( int i = 0 ; i < tv - > getComputeAtAxis ( ) ; i + + ) { <nl> - if ( pos2axis [ i ] ! = i ) <nl> - TORCH_CHECK ( false , " Cannot reorder axis within compute at range . " ) ; <nl> - } <nl> - } <nl> - <nl> - std : : vector < IterDomain * > reordered_domain ; <nl> - for ( int entry : pos2axis ) <nl> - reordered_domain . push_back ( td - > axis ( entry ) ) ; <nl> - <nl> - TensorDomain * reordered_td = new TensorDomain ( reordered_domain ) ; <nl> - Reorder * merge_node = new Reorder ( reordered_td , td , pos2axis ) ; <nl> - tv - > setDomain ( reordered_td ) ; <nl> - return tv ; <nl> - } <nl> - <nl> TensorView : : TensorView ( TensorDomain * _domain , DataType dtype ) <nl> : Val ( ValType : : TensorView , dtype ) , domain_ ( _domain ) { } <nl> <nl> TensorView : : TensorView ( const std : : shared_ptr < c10 : : TensorType > & tensor_type ) <nl> TORCH_CHECK ( <nl> tensor_type - > dim ( ) . has_value ( ) , " Requires static rank for Tensor " ) ; <nl> for ( int i = 0 ; i < tensor_type - > dim ( ) . value ( ) ; i + + ) { <nl> - sizes . push_back ( new IterDomain ( new Int ( ) ) ) ; <nl> + sizes . push_back ( new IterDomain ( new Int ( 0 ) , new Int ( ) ) ) ; <nl> } <nl> domain_ = new TensorDomain ( sizes ) ; <nl> } <nl> TensorView * TensorView : : newForOutput ( DataType dtype ) const { <nl> / / consumers and we ' re copying over a producer . <nl> if ( this - > axis ( i ) - > isReduction ( ) ) <nl> continue ; <nl> - domain_copy . push_back ( new IterDomain ( this - > axis ( i ) - > size ( ) ) ) ; <nl> + domain_copy . push_back ( <nl> + new IterDomain ( this - > axis ( i ) - > start ( ) , this - > axis ( i ) - > extent ( ) ) ) ; <nl> } <nl> TensorDomain * td = new TensorDomain ( domain_copy ) ; <nl> return new TensorView ( td , dtype ) ; <nl> void TensorView : : resetView ( ) { <nl> } <nl> <nl> std : : vector < IterDomain * > : : size_type TensorView : : nDims ( ) const { <nl> - return domain ( ) - > size ( ) ; <nl> + return domain ( ) - > nDims ( ) ; <nl> } <nl> <nl> IterDomain * TensorView : : axis ( int pos ) const { <nl> if ( pos < 0 ) <nl> - pos + = domain ( ) - > size ( ) ; <nl> + pos + = domain ( ) - > nDims ( ) ; <nl> TORCH_CHECK ( <nl> - pos > = 0 & & pos < domain ( ) - > size ( ) , <nl> + pos > = 0 & & pos < domain ( ) - > nDims ( ) , <nl> " Tried to access position " , <nl> pos , <nl> " in domain : " , <nl> IterDomain * TensorView : : axis ( int pos ) const { <nl> <nl> void TensorView : : copyDomain ( const TensorDomain * td ) { <nl> std : : vector < IterDomain * > idv ; <nl> - for ( decltype ( td - > size ( ) ) i = 0 ; i < td - > size ( ) ; i + + ) <nl> + for ( decltype ( td - > nDims ( ) ) i = 0 ; i < td - > nDims ( ) ; i + + ) <nl> idv . push_back ( td - > axis ( i ) ) ; <nl> setDomain ( new TensorDomain ( idv ) ) ; <nl> } <nl> TensorView * TensorView : : computeAt ( TensorView * consumer , int axis ) { <nl> return this ; <nl> } <nl> <nl> + TensorView * TensorView : : split ( int axis , int factor ) { <nl> + if ( axis < 0 ) <nl> + axis + = domain ( ) - > nDims ( ) ; <nl> + <nl> + TORCH_CHECK ( <nl> + axis > = 0 & & axis < domain ( ) - > nDims ( ) , <nl> + " Trying to split axis outside of TensorView ' s range . " ) ; <nl> + <nl> + if ( getComputeAtView ( ) ! = nullptr ) <nl> + if ( axis < getComputeAtAxis ( ) ) <nl> + TORCH_CHECK ( false , " Cannot split axis within compute at range . " ) ; <nl> + <nl> + setDomain ( domain ( ) - > split ( axis , factor ) ) ; <nl> + return this ; <nl> + } <nl> + <nl> + / / Merge " axis " and " axis + 1 " into 1 dimension <nl> + TensorView * TensorView : : merge ( int axis ) { <nl> + if ( axis < 0 ) <nl> + axis + = domain ( ) - > nDims ( ) ; <nl> + <nl> + TORCH_CHECK ( <nl> + axis > = 0 & & axis + 1 < domain ( ) - > nDims ( ) , <nl> + " Trying to merge axis outside of TensorView ' s range . " ) ; <nl> + <nl> + if ( getComputeAtView ( ) ! = nullptr ) <nl> + if ( axis + 1 < getComputeAtAxis ( ) ) <nl> + TORCH_CHECK ( false , " Cannot merge axis within compute at range . " ) ; <nl> + <nl> + setDomain ( domain ( ) - > merge ( axis ) ) ; <nl> + return this ; <nl> + } <nl> + <nl> + / / Reorder axes according to map [ old_pos ] = new_pos <nl> + TensorView * TensorView : : reorder ( const std : : unordered_map < int , int > & axis2pos_ ) { <nl> + / / START VALIDATION CHECKS <nl> + / / adjust based on negative values ( any negative values gets nDims added to <nl> + / / it ) <nl> + std : : unordered_map < int , int > axis2pos ; <nl> + auto ndims = nDims ( ) ; <nl> + std : : transform ( <nl> + axis2pos_ . begin ( ) , <nl> + axis2pos_ . end ( ) , <nl> + std : : inserter ( axis2pos , axis2pos . begin ( ) ) , <nl> + [ ndims ] ( std : : unordered_map < int , int > : : value_type entry ) { <nl> + return std : : unordered_map < int , int > : : value_type ( { <nl> + entry . first < 0 ? entry . first + ndims : entry . first , <nl> + entry . second < 0 ? entry . second + ndims : entry . second , <nl> + } ) ; <nl> + } ) ; <nl> + <nl> + / / Check if any adjusted values are < 0 , or > = nDims , which are invalid <nl> + bool out_of_range = std : : any_of ( <nl> + axis2pos . begin ( ) , <nl> + axis2pos . end ( ) , <nl> + [ ndims ] ( std : : unordered_map < int , int > : : value_type entry ) { <nl> + return entry . first < 0 | | entry . first > = ndims | | entry . second < 0 | | <nl> + entry . second > = ndims ; <nl> + } ) ; <nl> + <nl> + TORCH_CHECK ( <nl> + ! out_of_range , <nl> + " TensorView reorder axes are outside the number of dimensions in the TensorView . " ) <nl> + <nl> + / / Going to use sets , to see if any duplicate values are in the map . <nl> + <nl> + std : : set < int > old_pos_set ; <nl> + std : : transform ( <nl> + axis2pos . begin ( ) , <nl> + axis2pos . end ( ) , <nl> + std : : inserter ( old_pos_set , old_pos_set . begin ( ) ) , <nl> + [ ] ( std : : unordered_map < int , int > : : value_type entry ) { <nl> + return entry . first ; <nl> + } ) ; <nl> + <nl> + std : : set < int > new_pos_set ; <nl> + std : : transform ( <nl> + axis2pos . begin ( ) , <nl> + axis2pos . end ( ) , <nl> + std : : inserter ( new_pos_set , new_pos_set . begin ( ) ) , <nl> + [ ] ( std : : unordered_map < int , int > : : value_type entry ) { <nl> + return entry . first ; <nl> + } ) ; <nl> + <nl> + / / Error out if duplicate values are found . <nl> + TORCH_CHECK ( <nl> + old_pos_set . size ( ) = = axis2pos . size ( ) & & <nl> + new_pos_set . size ( ) = = axis2pos . size ( ) , <nl> + " Duplicate entries in transformation map sent to TensorView reorder . " ) ; <nl> + <nl> + / / Check if we ' re trying to reorder any values outside of the computeAt axis <nl> + <nl> + if ( hasComputeAt ( ) ) { <nl> + auto compute_at_axis = getComputeAtAxis ( ) ; <nl> + bool outside_computeat = std : : any_of ( <nl> + axis2pos . begin ( ) , <nl> + axis2pos . end ( ) , <nl> + [ compute_at_axis ] ( std : : unordered_map < int , int > : : value_type entry ) { <nl> + return entry . first < compute_at_axis | | <nl> + entry . second < compute_at_axis ; <nl> + } ) ; <nl> + TORCH_CHECK ( <nl> + ! outside_computeat , <nl> + " Cannot reorder dimensions that are outside computeAt axis . " ) ; <nl> + } <nl> + / / END VALIDATION CHECKS <nl> + setDomain ( domain ( ) - > reorder ( axis2pos_ ) ) ; <nl> + <nl> + return this ; <nl> + } <nl> + <nl> } / / namespace fuser <nl> } / / namespace jit <nl> } / / namespace torch <nl> mmm a / torch / csrc / jit / codegen / cuda / transform_iter . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / transform_iter . cpp <nl> TensorDomain * TransformIter : : runBackward ( <nl> return root ; <nl> } <nl> <nl> - TensorView * TransformIter : : replay ( Split * expr , TensorView * tv ) { <nl> - return tv - > split ( <nl> + TensorDomain * TransformIter : : replay ( Split * expr , TensorDomain * td ) { <nl> + return td - > split ( <nl> expr - > axis ( ) , static_cast < Int * > ( expr - > factor ( ) ) - > value ( ) . value ( ) ) ; <nl> } <nl> <nl> - TensorView * TransformIter : : replay ( Merge * expr , TensorView * tv ) { <nl> - return tv - > merge ( expr - > axis ( ) ) ; <nl> + TensorDomain * TransformIter : : replay ( Merge * expr , TensorDomain * td ) { <nl> + return td - > merge ( expr - > axis ( ) ) ; <nl> } <nl> <nl> - TensorView * TransformIter : : replay ( Reorder * expr , TensorView * tv ) { <nl> + TensorDomain * TransformIter : : replay ( Reorder * expr , TensorDomain * td ) { <nl> std : : unordered_map < int , int > axis2pos ; <nl> for ( decltype ( expr - > pos2axis ( ) . size ( ) ) i { 0 } ; i < expr - > pos2axis ( ) . size ( ) ; i + + ) <nl> axis2pos [ expr - > pos2axis ( ) [ i ] ] = i ; <nl> - return tv - > reorder ( axis2pos ) ; <nl> + return td - > reorder ( axis2pos ) ; <nl> } <nl> <nl> - TensorView * TransformIter : : replay ( Expr * expr , TensorView * tv ) { <nl> + TensorDomain * TransformIter : : replay ( Expr * expr , TensorDomain * td ) { <nl> TORCH_INTERNAL_ASSERT ( expr - > isExpr ( ) ) ; <nl> switch ( * ( expr - > getExprType ( ) ) ) { <nl> case ( ExprType : : Split ) : <nl> - return replay ( static_cast < Split * > ( expr ) , tv ) ; <nl> + return replay ( static_cast < Split * > ( expr ) , td ) ; <nl> case ( ExprType : : Merge ) : <nl> - return replay ( static_cast < Merge * > ( expr ) , tv ) ; <nl> + return replay ( static_cast < Merge * > ( expr ) , td ) ; <nl> case ( ExprType : : Reorder ) : <nl> - return replay ( static_cast < Reorder * > ( expr ) , tv ) ; <nl> + return replay ( static_cast < Reorder * > ( expr ) , td ) ; <nl> default : <nl> TORCH_INTERNAL_ASSERT ( false , " Could not detect expr type in replay . " ) ; <nl> } <nl> } <nl> <nl> - TensorView * TransformIter : : runReplay ( TensorView * tv ) { <nl> + TensorDomain * TransformIter : : runReplay ( TensorDomain * td ) { <nl> for ( auto it = record . begin ( ) ; it < record . end ( ) ; + + it ) { <nl> - tv = TransformIter : : replay ( * it , tv ) ; <nl> + td = TransformIter : : replay ( * it , td ) ; <nl> } <nl> - return tv ; <nl> + return td ; <nl> } <nl> <nl> } / / namespace fuser <nl> mmm a / torch / csrc / jit / codegen / cuda / transform_iter . h <nl> ppp b / torch / csrc / jit / codegen / cuda / transform_iter . h <nl> <nl> <nl> # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> # include < torch / csrc / jit / codegen / cuda / iter_visitor . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> <nl> namespace torch { <nl> namespace jit { <nl> struct TORCH_CUDA_API TransformIter : public IterVisitor { <nl> / / order operations root - > td . <nl> TensorDomain * runBackward ( TensorDomain * td , bool generate_record ) ; <nl> <nl> - virtual TensorView * replay ( Split * expr , TensorView * tv ) ; <nl> - virtual TensorView * replay ( Merge * expr , TensorView * tv ) ; <nl> - virtual TensorView * replay ( Reorder * expr , TensorView * tv ) ; <nl> + virtual TensorDomain * replay ( Split * expr , TensorDomain * tv ) ; <nl> + virtual TensorDomain * replay ( Merge * expr , TensorDomain * tv ) ; <nl> + virtual TensorDomain * replay ( Reorder * expr , TensorDomain * tv ) ; <nl> <nl> / / dispatch <nl> - TensorView * replay ( Expr * expr , TensorView * tv ) ; <nl> + TensorDomain * replay ( Expr * expr , TensorDomain * tv ) ; <nl> <nl> / / Runs through operations recorded in record from root - > present <nl> - TensorView * runReplay ( TensorView * tv ) ; <nl> + TensorDomain * runReplay ( TensorDomain * tv ) ; <nl> <nl> / / Forward record from root , to replay_ref / ref_root <nl> std : : vector < Expr * > record ; <nl> mmm a / torch / csrc / jit / codegen / cuda / transform_replay . cpp <nl> ppp b / torch / csrc / jit / codegen / cuda / transform_replay . cpp <nl> void TransformReplay : : replayBackward ( Reorder * expr ) { <nl> TensorDomain * TransformReplay : : replayBackward ( <nl> TensorDomain * td , <nl> bool create_record ) { <nl> - influence = std : : vector < bool > ( td - > size ( ) , false ) ; <nl> + influence = std : : vector < bool > ( td - > nDims ( ) , false ) ; <nl> for ( int i = 0 ; i < compute_at_axis ; i + + ) <nl> influence [ i ] = true ; <nl> return TransformIter : : runBackward ( td , create_record ) ; <nl> } <nl> <nl> / * <nl> - * Replay functions , takes a TensorView and steps through the operations in <nl> + * Replay functions , takes a TensorDomain and steps through the operations in <nl> * " record " based on influence axes . Will also update influence and propagate <nl> * it forward . <nl> * / <nl> - TensorView * TransformReplay : : replay ( Split * expr , TensorView * tv ) { <nl> + TensorDomain * TransformReplay : : replay ( Split * expr , TensorDomain * td ) { <nl> int axis = expr - > axis ( ) ; <nl> + bool run_split = influence [ axis ] ; <nl> + <nl> + / / Propagate influence <nl> + influence . insert ( influence . begin ( ) + axis + 1 , influence [ axis ] ) ; <nl> + <nl> / / Forward prop influence <nl> - if ( influence [ axis ] ) { <nl> + if ( run_split ) { <nl> / / Make sure split axis is real . <nl> int real_axis = axis_map [ expr - > axis ( ) ] ; <nl> TORCH_INTERNAL_ASSERT ( <nl> real_axis ! = - 1 , <nl> " During transformation replay attempted to split an imaginary axis . " ) ; <nl> - / / Replay split <nl> - tv - > split ( real_axis , * ( expr - > factor ( ) - > value ( ) ) ) ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + td - > axis ( real_axis ) - > start ( ) - > isZeroInt ( ) , <nl> + " Transform Replay tried to split an IterDomain with a start value that is not 0 , " , <nl> + " this is not currently supported . " ) ; <nl> / / Inserted a real axis , push everything in axis_map over to the right <nl> / / after this inserted axis <nl> for ( decltype ( axis_map . size ( ) ) i { 0 } ; i < axis_map . size ( ) ; i + + ) <nl> TensorView * TransformReplay : : replay ( Split * expr , TensorView * tv ) { <nl> axis_map . insert ( <nl> axis_map . begin ( ) + expr - > axis ( ) + 1 , <nl> real_axis + 1 ) ; / / insert axis at position axis . <nl> + <nl> + / / Replay split <nl> + return td - > split ( real_axis , * ( expr - > factor ( ) - > value ( ) ) ) ; <nl> } else { <nl> / / Fake it <nl> axis_map . insert ( axis_map . begin ( ) + expr - > axis ( ) + 1 , - 1 ) ; <nl> } <nl> <nl> - influence . insert ( influence . begin ( ) + axis + 1 , influence [ axis ] ) ; <nl> - <nl> - return tv ; <nl> + return td ; <nl> } <nl> <nl> - TensorView * TransformReplay : : replay ( Merge * expr , TensorView * tv ) { <nl> + TensorDomain * TransformReplay : : replay ( Merge * expr , TensorDomain * td ) { <nl> int axis = expr - > axis ( ) ; <nl> + bool merge = influence [ axis ] | | influence [ axis + 1 ] ; <nl> + axis_map . erase ( axis_map . begin ( ) + expr - > axis ( ) + 1 ) ; <nl> + <nl> + for ( decltype ( axis_map . size ( ) ) i = expr - > axis ( ) + 1 ; i < axis_map . size ( ) ; i + + ) <nl> + if ( axis_map [ i ] ! = - 1 ) <nl> + axis_map [ i ] - - ; <nl> <nl> - if ( influence [ axis ] | | influence [ axis + 1 ] ) { <nl> + / / Forward prop influence <nl> + influence [ axis ] = influence [ axis ] | | influence [ axis + 1 ] ; <nl> + influence . erase ( influence . begin ( ) + axis + 1 ) ; <nl> + <nl> + if ( merge ) { <nl> / / Make sure both merge axes are real . <nl> TORCH_INTERNAL_ASSERT ( <nl> axis_map [ axis ] ! = - 1 & & axis_map [ axis + 1 ] ! = - 1 , <nl> " During transformation replay attempted to merge an imaginary axis . " ) ; <nl> / / Replay merge <nl> - tv - > merge ( axis_map [ axis ] ) ; <nl> + TORCH_INTERNAL_ASSERT ( <nl> + td - > axis ( axis ) - > start ( ) - > isZeroInt ( ) & & <nl> + td - > axis ( axis + 1 ) - > start ( ) - > isZeroInt ( ) , <nl> + " Transform Replay tried to Merge IterDomains with a start value that is not 0 , " , <nl> + " this is not currently supported . " ) ; <nl> + return td - > merge ( axis_map [ axis ] ) ; <nl> } else { <nl> / / If we aren ' t applying the merge , we won ' t change any following axis <nl> / / Doesn ' t matter which axis we propagate for the merge in the axis_map <nl> assert ( axis_map [ axis + 1 ] = = - 1 ) ; <nl> + return td ; <nl> } <nl> - axis_map . erase ( axis_map . begin ( ) + expr - > axis ( ) + 1 ) ; <nl> - <nl> - for ( decltype ( axis_map . size ( ) ) i = expr - > axis ( ) + 1 ; i < axis_map . size ( ) ; i + + ) <nl> - if ( axis_map [ i ] ! = - 1 ) <nl> - axis_map [ i ] - - ; <nl> - <nl> - / / Forward prop influence <nl> - influence [ axis ] = influence [ axis ] | | influence [ axis + 1 ] ; <nl> - influence . erase ( influence . begin ( ) + axis + 1 ) ; <nl> - <nl> - return tv ; <nl> } <nl> <nl> - TensorView * TransformReplay : : replay ( Reorder * expr , TensorView * tv ) { <nl> + TensorDomain * TransformReplay : : replay ( Reorder * expr , TensorDomain * td ) { <nl> / / axis2pos [ old_pos ] = new_pos is sent to reorder , Reorder holds <nl> / / pos2axis [ new_pos ] = old_pos Generate new axis2pos map <nl> std : : unordered_map < int , int > axis2pos ; <nl> TensorView * TransformReplay : : replay ( Reorder * expr , TensorView * tv ) { <nl> axis2pos [ entry . first ] = axis + + ; <nl> } <nl> <nl> - for ( decltype ( tv - > nDims ( ) ) i { 0 } ; i < tv - > nDims ( ) ; i + + ) { <nl> + for ( decltype ( td - > nDims ( ) ) i { 0 } ; i < td - > nDims ( ) ; i + + ) { <nl> if ( axis2pos . find ( i ) = = axis2pos . end ( ) ) <nl> axis2pos [ i ] = axis + + ; <nl> } <nl> <nl> / / replay reorder <nl> - tv - > reorder ( axis2pos ) ; <nl> + TensorDomain * reordered_td = td - > reorder ( axis2pos ) ; <nl> <nl> / / Fake transform : <nl> for ( decltype ( pos2axis . size ( ) ) i = 0 ; i < pos2axis . size ( ) ; i + + ) { <nl> TensorView * TransformReplay : : replay ( Reorder * expr , TensorView * tv ) { <nl> influence = reordered_influence ; <nl> axis_map = reordered_axis_map ; <nl> <nl> - return tv ; <nl> + return reordered_td ; <nl> } <nl> <nl> / * <nl> TensorView * TransformReplay : : replay ( Reorder * expr , TensorView * tv ) { <nl> * outside of compute_at_axis . <nl> * <nl> * / <nl> - TensorView * TransformReplay : : runReplay ( <nl> - TensorView * replay_ref , <nl> - TensorView * replay_target , <nl> + TensorDomain * TransformReplay : : runReplay ( <nl> + TensorDomain * replay_ref , <nl> + TensorDomain * replay_target , <nl> int compute_at_axis ) { <nl> if ( compute_at_axis < 0 ) <nl> compute_at_axis + = int ( replay_ref - > nDims ( ) ) + 1 ; <nl> <nl> TORCH_CHECK ( <nl> compute_at_axis > = 0 & & compute_at_axis < int ( replay_ref - > nDims ( ) ) + 1 , <nl> - " Transform replay cannot be performed as the compute_at_axis is not in the valid range . " ) ; <nl> + " Transform replay cannot be performed as the compute_at_axis is not in the valid range , it should be 0 or greater , and less than " , <nl> + int ( replay_ref - > nDims ( ) ) + 1 , <nl> + " . " ) ; <nl> <nl> this - > compute_at_axis = compute_at_axis ; <nl> <nl> TensorView * TransformReplay : : runReplay ( <nl> / / Reset the tensor domain of the target , this is the only way we can be <nl> / / certain That we can actually replay the ops of ref . <nl> / / Trace back to the root TensorDomain ' s of ref and target <nl> - replay_target - > resetView ( ) ; <nl> + replay_target = replay_target - > rootDomain ( ) ; <nl> <nl> / * STEP 2 * / <nl> / / Mark compute_at_axis and below as " influenced " , trace back through <nl> TensorView * TransformReplay : : runReplay ( <nl> / / produce these axis <nl> / / As we trace the ref , record the operations to go from replay_ref - > <nl> / / ref_root , save in " record " <nl> - TensorDomain * ref_root = replayBackward ( replay_ref - > domain ( ) , true ) ; <nl> + TensorDomain * ref_root = replayBackward ( replay_ref , true ) ; <nl> / / We ' re going to save a copy of this vector , class member influnce will be <nl> / / used during replay to forward propagate influence . <nl> std : : vector < bool > root_influence_vector = influence ; <nl> TensorView * TransformReplay : : runReplay ( <nl> axis_map . push_back ( i ) ; <nl> <nl> / / Domain sizes must match at root for replay . <nl> - if ( axis_map . size ( ) ! = ref_root - > size ( ) ) { <nl> + if ( axis_map . size ( ) ! = ref_root - > nDims ( ) ) { <nl> std : : stringstream err_msg ; <nl> err_msg <nl> < < " Transforms cannot be replayed as source and destinations do not have the same root sizes . " <nl> TensorView * TransformReplay : : runReplay ( <nl> } <nl> <nl> / * <nl> - * TODO : Decide if the following check is reasonable , when we ' re parsing the <nl> - * JIT graph , we are using symbolic sizes for each tensor individually , so <nl> - * they won ' t all have the same size . <nl> + * TODO : The JIT graph has symbolic sizes , so inputs may actually have the <nl> + * same sizes ( assuming no broadcasts / reductions ) , we at some point want to <nl> + * have some size matching , and sizes should actually match at this point , but <nl> + * the check below won ' t work . <nl> * / <nl> <nl> / / for ( decltype ( axis_map . size ( ) ) i { 0 } ; i < axis_map . size ( ) ; i + + ) { <nl> TensorView * TransformReplay : : runReplay ( <nl> / / actually execute those based on influence . If we didn ' t track all <nl> / / axes , we wouldn ' t know what axis split / merge / reorder are referencing <nl> / / as they ' re relative to the " full " replay that produced the reference . <nl> - TensorView * replayed = TransformIter : : runReplay ( replay_target ) ; <nl> + TensorDomain * replayed = TransformIter : : runReplay ( replay_target ) ; <nl> <nl> for ( decltype ( replayed - > nDims ( ) ) i { 0 } ; i < compute_at_axis ; i + + ) <nl> if ( replayed - > axis ( i ) - > isReduction ( ) ) <nl> TensorView * TransformReplay : : runReplay ( <nl> return replayed ; <nl> } <nl> <nl> + TensorView * TransformReplay : : runReplay ( <nl> + TensorView * replay_ref , <nl> + TensorView * replay_target , <nl> + int compute_at_axis ) { <nl> + TensorDomain * td = <nl> + runReplay ( replay_ref - > domain ( ) , replay_target - > domain ( ) , compute_at_axis ) ; <nl> + replay_target - > setDomain ( td ) ; <nl> + return replay_target ; <nl> + } <nl> + <nl> TensorView * TransformReplay : : replay ( <nl> TensorView * replay_ref , <nl> TensorView * replay_target , <nl> TensorView * TransformReplay : : fullReplay ( <nl> TensorView * replay_ref , <nl> TensorView * replay_target ) { <nl> TransformReplay tr ; <nl> - tr . runReplay ( replay_ref , replay_target , - 1 ) ; <nl> - return replay_target ; <nl> + return tr . runReplay ( replay_ref , replay_target , - 1 ) ; <nl> + } <nl> + <nl> + TensorDomain * TransformReplay : : fullReplay ( <nl> + TensorDomain * replay_ref , <nl> + TensorDomain * replay_target ) { <nl> + TransformReplay tr ; <nl> + return tr . runReplay ( replay_ref , replay_target , - 1 ) ; <nl> } <nl> <nl> } / / namespace fuser <nl> mmm a / torch / csrc / jit / codegen / cuda / transform_replay . h <nl> ppp b / torch / csrc / jit / codegen / cuda / transform_replay . h <nl> <nl> # include < torch / csrc / WindowsTorchApiMacro . h > <nl> <nl> # include < torch / csrc / jit / codegen / cuda / ir_all_nodes . h > <nl> - # include < torch / csrc / jit / codegen / cuda / tensor . h > <nl> # include < torch / csrc / jit / codegen / cuda / transform_iter . h > <nl> <nl> # include < algorithm > <nl> struct TORCH_CUDA_API TransformReplay : public TransformIter { <nl> * " record " based on influence axes . Will also update influence and propagate <nl> * it forward . <nl> * / <nl> - TensorView * replay ( Split * expr , TensorView * tv ) ; <nl> - TensorView * replay ( Merge * expr , TensorView * tv ) ; <nl> - TensorView * replay ( Reorder * expr , TensorView * tv ) ; <nl> + TensorDomain * replay ( Split * expr , TensorDomain * tv ) ; <nl> + TensorDomain * replay ( Merge * expr , TensorDomain * tv ) ; <nl> + TensorDomain * replay ( Reorder * expr , TensorDomain * tv ) ; <nl> <nl> / * <nl> * Takes replay_ref and replays its transformations on replay_target <nl> * Replays from begining of both TensorDomains . could be more efficient to try <nl> - * and find a common ancestor to start from , but that ' s outside the scope of <nl> - * this work for now . <nl> - * <nl> + * and find a common ancestor to start from , but likely not a worthwhile <nl> + * optimization . <nl> + * / <nl> + TensorDomain * runReplay ( <nl> + TensorDomain * replay_ref , <nl> + TensorDomain * replay_target , <nl> + int compute_at_axis ) ; <nl> + <nl> + / * <nl> + * Takes replay_ref and replays its transformations on replay_target <nl> + * Replays from begining of both TensorDomains . could be more efficient to try <nl> + * and find a common ancestor to start from , but likely not a worthwhile <nl> + * optimization . <nl> * / <nl> TensorView * runReplay ( <nl> TensorView * replay_ref , <nl> struct TORCH_CUDA_API TransformReplay : public TransformIter { <nl> static TensorView * fullReplay ( <nl> TensorView * replay_ref , <nl> TensorView * replay_target ) ; <nl> + <nl> + static TensorDomain * fullReplay ( <nl> + TensorDomain * replay_ref , <nl> + TensorDomain * replay_target ) ; <nl> } ; <nl> <nl> } / / namespace fuser <nl> | New CUDA Fuser : Unrolling support , interface refactor ( ) | pytorch/pytorch | f11c4f90c2e273b532fa6f8f2709f957fa0749bb | 2020-04-16T16:20:24Z |
mmm a / src / mongo / db / structure / record_store_v1_simple_test . cpp <nl> ppp b / src / mongo / db / structure / record_store_v1_simple_test . cpp <nl> using namespace mongo ; <nl> <nl> namespace { <nl> <nl> + char zeros [ 20 * 1024 * 1024 ] = { } ; <nl> + <nl> TEST ( SimpleRecordStoreV1 , quantizeAllocationSpaceSimple ) { <nl> ASSERT_EQUALS ( RecordStoreV1Base : : quantizeAllocationSpace ( 33 ) , 36 ) ; <nl> ASSERT_EQUALS ( RecordStoreV1Base : : quantizeAllocationSpace ( 1000 ) , 1024 ) ; <nl> namespace { <nl> Record * record = rs . recordFor ( result . getValue ( ) ) ; <nl> ASSERT_EQUALS ( string ( " abc " ) , string ( record - > data ( ) ) ) ; <nl> } <nl> + <nl> + / / mmmmmmmmmmmmmmm - <nl> + <nl> + / * * <nl> + * Inserts take the first deleted record with the correct size . <nl> + * / <nl> + TEST ( SimpleRecordStoreV1 , InsertTakesFirstDeletedWithExactSize ) { <nl> + DummyTransactionExperiment txn ; <nl> + DummyExtentManager em ; <nl> + DummyRecordStoreV1MetaData * md = new DummyRecordStoreV1MetaData ( false , 0 ) ; <nl> + SimpleRecordStoreV1 rs ( & txn , " test . foo " , md , & em , false ) ; <nl> + <nl> + { <nl> + LocAndSize recs [ ] = { <nl> + { DiskLoc ( 0 , 1000 ) , 100 } , <nl> + { DiskLoc ( 0 , 1100 ) , 100 } , <nl> + { DiskLoc ( 0 , 1300 ) , 100 } , <nl> + { DiskLoc ( 2 , 1100 ) , 100 } , <nl> + { } <nl> + } ; <nl> + LocAndSize drecs [ ] = { <nl> + { DiskLoc ( 0 , 1200 ) , 100 } , <nl> + { DiskLoc ( 2 , 1100 ) , 100 } , <nl> + { DiskLoc ( 1 , 1000 ) , 1000 } , <nl> + { } <nl> + } ; <nl> + <nl> + initializeV1RS ( & txn , recs , drecs , & em , md ) ; <nl> + } <nl> + <nl> + rs . insertRecord ( & txn , zeros , 100 - Record : : HeaderSize , 0 ) ; <nl> + <nl> + { <nl> + LocAndSize recs [ ] = { <nl> + { DiskLoc ( 0 , 1000 ) , 100 } , <nl> + { DiskLoc ( 0 , 1100 ) , 100 } , <nl> + { DiskLoc ( 0 , 1300 ) , 100 } , <nl> + { DiskLoc ( 0 , 1200 ) , 100 } , <nl> + { DiskLoc ( 2 , 1100 ) , 100 } , <nl> + { } <nl> + } ; <nl> + LocAndSize drecs [ ] = { <nl> + { DiskLoc ( 2 , 1100 ) , 100 } , <nl> + { DiskLoc ( 1 , 1000 ) , 1000 } , <nl> + { } <nl> + } ; <nl> + assertStateV1RS ( recs , drecs , & em , md ) ; <nl> + } <nl> + } <nl> + <nl> } <nl> mmm a / src / mongo / db / structure / record_store_v1_test_help . cpp <nl> ppp b / src / mongo / db / structure / record_store_v1_test_help . cpp <nl> <nl> <nl> # include " mongo / db / structure / record_store_v1_test_help . h " <nl> <nl> + # include < algorithm > <nl> + # include < map > <nl> + # include < set > <nl> + # include < vector > <nl> + <nl> # include " mongo / db / storage / extent . h " <nl> + # include " mongo / db / storage / record . h " <nl> + # include " mongo / unittest / unittest . h " <nl> <nl> namespace mongo { <nl> bool DummyTransactionExperiment : : commitIfNeeded ( bool force ) { <nl> namespace mongo { <nl> DiskLoc loc ( _extents . size ( ) , 0 ) ; <nl> _extents . push_back ( info ) ; <nl> <nl> - Extent * e = getExtent ( loc ) ; <nl> + Extent * e = getExtent ( loc , false ) ; <nl> e - > magic = Extent : : extentSignature ; <nl> e - > myLoc = loc ; <nl> e - > xnext . Null ( ) ; <nl> namespace mongo { <nl> <nl> Record * DummyExtentManager : : recordForV1 ( const DiskLoc & loc ) const { <nl> invariant ( static_cast < size_t > ( loc . a ( ) ) < _extents . size ( ) ) ; <nl> - / / log ( ) < < " DummyExtentManager : : recordForV1 : " < < loc ; <nl> + invariant ( static_cast < size_t > ( loc . getOfs ( ) ) < _extents [ loc . a ( ) ] . length ) ; <nl> char * root = _extents [ loc . a ( ) ] . data ; <nl> return reinterpret_cast < Record * > ( root + loc . getOfs ( ) ) ; <nl> } <nl> namespace mongo { <nl> invariant ( ! loc . isNull ( ) ) ; <nl> invariant ( static_cast < size_t > ( loc . a ( ) ) < _extents . size ( ) ) ; <nl> invariant ( loc . getOfs ( ) = = 0 ) ; <nl> - return reinterpret_cast < Extent * > ( _extents [ loc . a ( ) ] . data ) ; <nl> + Extent * ext = reinterpret_cast < Extent * > ( _extents [ loc . a ( ) ] . data ) ; <nl> + if ( doSanityCheck ) <nl> + ext - > assertOk ( ) ; <nl> + return ext ; <nl> } <nl> <nl> int DummyExtentManager : : maxSize ( ) const { <nl> namespace mongo { <nl> return new CacheHint ( ) ; <nl> } <nl> <nl> + namespace { <nl> + void accumulateExtentSizeRequirements ( const LocAndSize * las , std : : map < int , size_t > * sizes ) { <nl> + if ( ! las ) <nl> + return ; <nl> + <nl> + while ( ! las - > loc . isNull ( ) ) { <nl> + / / We require passed in offsets to be > 1000 to leave room for Extent headers . <nl> + invariant ( Extent : : HeaderSize ( ) < 1000 ) ; <nl> + invariant ( las - > loc . getOfs ( ) > = 1000 ) ; <nl> + <nl> + const size_t end = las - > loc . getOfs ( ) + las - > size ; <nl> + size_t & sizeNeeded = ( * sizes ) [ las - > loc . a ( ) ] ; <nl> + sizeNeeded = std : : max ( sizeNeeded , end ) ; <nl> + las + + ; <nl> + } <nl> + } <nl> + <nl> + void printRecList ( const ExtentManager * em , const RecordStoreV1MetaData * md ) { <nl> + log ( ) < < " * * * BEGIN ACTUAL RECORD LIST * * * " ; <nl> + DiskLoc extLoc = md - > firstExtent ( ) ; <nl> + std : : set < DiskLoc > seenLocs ; <nl> + while ( ! extLoc . isNull ( ) ) { <nl> + Extent * ext = em - > getExtent ( extLoc , true ) ; <nl> + DiskLoc actualLoc = ext - > firstRecord ; <nl> + while ( ! actualLoc . isNull ( ) ) { <nl> + const Record * actualRec = em - > recordForV1 ( actualLoc ) ; <nl> + const int actualSize = actualRec - > lengthWithHeaders ( ) ; <nl> + <nl> + log ( ) < < " loc : " < < actualLoc / / < - - hex <nl> + < < " ( " < < actualLoc . getOfs ( ) < < " ) size : " < < actualSize ; <nl> + <nl> + const bool foundCycle = ! seenLocs . insert ( actualLoc ) . second ; <nl> + invariant ( ! foundCycle ) ; <nl> + <nl> + const int nextOfs = actualRec - > nextOfs ( ) ; <nl> + actualLoc = ( nextOfs = = DiskLoc : : NullOfs ? DiskLoc ( ) <nl> + : DiskLoc ( actualLoc . a ( ) , nextOfs ) ) ; <nl> + } <nl> + extLoc = ext - > xnext ; <nl> + } <nl> + log ( ) < < " * * * END ACTUAL RECORD LIST * * * " ; <nl> + } <nl> + <nl> + void printDRecList ( const ExtentManager * em , const RecordStoreV1MetaData * md ) { <nl> + log ( ) < < " * * * BEGIN ACTUAL DELETED RECORD LIST * * * " ; <nl> + std : : set < DiskLoc > seenLocs ; <nl> + for ( int bucketIdx = 0 ; bucketIdx < RecordStoreV1Base : : Buckets ; bucketIdx + + ) { <nl> + DiskLoc actualLoc = md - > deletedListEntry ( bucketIdx ) ; <nl> + while ( ! actualLoc . isNull ( ) ) { <nl> + const DeletedRecord * actualDrec = & em - > recordForV1 ( actualLoc ) - > asDeleted ( ) ; <nl> + const int actualSize = actualDrec - > lengthWithHeaders ( ) ; <nl> + <nl> + <nl> + log ( ) < < " loc : " < < actualLoc / / < - - hex <nl> + < < " ( " < < actualLoc . getOfs ( ) < < " ) size : " < < actualSize ; <nl> + <nl> + const bool foundCycle = ! seenLocs . insert ( actualLoc ) . second ; <nl> + invariant ( ! foundCycle ) ; <nl> + <nl> + actualLoc = actualDrec - > nextDeleted ( ) ; <nl> + } <nl> + } <nl> + log ( ) < < " * * * END ACTUAL DELETED RECORD LIST * * * " ; <nl> + } <nl> + } <nl> + <nl> + void initializeV1RS ( TransactionExperiment * txn , <nl> + const LocAndSize * records , <nl> + const LocAndSize * drecs , <nl> + DummyExtentManager * em , <nl> + DummyRecordStoreV1MetaData * md ) { <nl> + invariant ( records | | drecs ) ; / / if both are NULL nothing is being created . . . <nl> + invariant ( em - > numFiles ( ) = = 0 ) ; <nl> + invariant ( md - > firstExtent ( ) . isNull ( ) ) ; <nl> + <nl> + / / pre - allocate extents ( even extents that aren ' t part of this RS ) <nl> + { <nl> + typedef std : : map < int , size_t > ExtentSizes ; <nl> + ExtentSizes extentSizes ; <nl> + accumulateExtentSizeRequirements ( records , & extentSizes ) ; <nl> + accumulateExtentSizeRequirements ( drecs , & extentSizes ) ; <nl> + invariant ( ! extentSizes . empty ( ) ) ; <nl> + <nl> + const int maxExtent = extentSizes . rbegin ( ) - > first ; <nl> + for ( int i = 0 ; i < = maxExtent ; i + + ) { <nl> + const size_t size = extentSizes . count ( i ) ? extentSizes [ i ] : 0 ; <nl> + const DiskLoc loc = em - > allocateExtent ( txn , md - > isCapped ( ) , size , 0 ) ; <nl> + <nl> + / / This function and assertState depend on these details of DummyExtentManager <nl> + invariant ( loc . a ( ) = = i ) ; <nl> + invariant ( loc . getOfs ( ) = = 0 ) ; <nl> + } <nl> + <nl> + / / link together extents that should be part of this RS <nl> + md - > setFirstExtent ( txn , DiskLoc ( extentSizes . begin ( ) - > first , 0 ) ) ; <nl> + for ( ExtentSizes : : iterator it = extentSizes . begin ( ) ; <nl> + boost : : next ( it ) ! = extentSizes . end ( ) ; / * + + it * / ) { <nl> + const int a = it - > first ; <nl> + + + it ; <nl> + const int b = it - > first ; <nl> + em - > getExtent ( DiskLoc ( a , 0 ) ) - > xnext = DiskLoc ( b , 0 ) ; <nl> + em - > getExtent ( DiskLoc ( b , 0 ) ) - > xprev = DiskLoc ( a , 0 ) ; <nl> + } <nl> + } <nl> + <nl> + if ( records & & ! records [ 0 ] . loc . isNull ( ) ) { <nl> + / / TODO figure out how to handle capExtent specially in cappedCollections <nl> + int recIdx = 0 ; <nl> + DiskLoc extLoc = md - > firstExtent ( ) ; <nl> + while ( ! extLoc . isNull ( ) ) { <nl> + Extent * ext = em - > getExtent ( extLoc ) ; <nl> + while ( extLoc . a ( ) = = records [ recIdx ] . loc . a ( ) ) { / / for all records in this extent <nl> + const DiskLoc loc = records [ recIdx ] . loc ; <nl> + const int size = records [ recIdx ] . size ; ; <nl> + invariant ( size > = Record : : HeaderSize ) ; <nl> + <nl> + md - > incrementStats ( txn , size - Record : : HeaderSize , 1 ) ; <nl> + <nl> + if ( ext - > firstRecord . isNull ( ) ) <nl> + ext - > firstRecord = loc ; <nl> + <nl> + Record * rec = em - > recordForV1 ( loc ) ; <nl> + rec - > lengthWithHeaders ( ) = size ; <nl> + rec - > extentOfs ( ) = 0 ; <nl> + <nl> + const DiskLoc nextLoc = records [ + + recIdx ] . loc ; <nl> + if ( nextLoc . a ( ) = = loc . a ( ) ) { <nl> + Record * nextRec = em - > recordForV1 ( loc ) ; <nl> + rec - > nextOfs ( ) = nextLoc . getOfs ( ) ; <nl> + nextRec - > prevOfs ( ) = loc . getOfs ( ) ; <nl> + } <nl> + else { <nl> + rec - > nextOfs ( ) = DiskLoc : : NullOfs ; <nl> + ext - > lastRecord = loc ; <nl> + } <nl> + } <nl> + extLoc = ext - > xnext ; <nl> + } <nl> + invariant ( records [ recIdx ] . loc . isNull ( ) ) ; <nl> + } <nl> <nl> + if ( drecs & & ! drecs [ 0 ] . loc . isNull ( ) ) { <nl> + int drecIdx = 0 ; <nl> + DiskLoc * prevNextPtr = NULL ; <nl> + int lastBucket = - 1 ; <nl> + while ( ! drecs [ drecIdx ] . loc . isNull ( ) ) { <nl> + const DiskLoc loc = drecs [ drecIdx ] . loc ; <nl> + const int size = drecs [ drecIdx ] . size ; <nl> + invariant ( size > = Record : : HeaderSize ) ; <nl> + const int bucket = RecordStoreV1Base : : bucket ( size ) ; <nl> + <nl> + if ( bucket ! = lastBucket ) { <nl> + invariant ( bucket > lastBucket ) ; / / if this fails , drecs weren ' t sorted by bucket <nl> + md - > setDeletedListEntry ( txn , bucket , loc ) ; <nl> + lastBucket = bucket ; <nl> + } <nl> + else { <nl> + * prevNextPtr = loc ; <nl> + } <nl> + <nl> + DeletedRecord * drec = & em - > recordForV1 ( loc ) - > asDeleted ( ) ; <nl> + drec - > lengthWithHeaders ( ) = size ; <nl> + drec - > extentOfs ( ) = 0 ; <nl> + drec - > nextDeleted ( ) = DiskLoc ( ) ; <nl> + prevNextPtr = & drec - > nextDeleted ( ) ; <nl> + <nl> + drecIdx + + ; <nl> + } <nl> + } <nl> + <nl> + / / Make sure we set everything up as requested . <nl> + assertStateV1RS ( records , drecs , em , md ) ; <nl> + } <nl> + <nl> + void assertStateV1RS ( const LocAndSize * records , <nl> + const LocAndSize * drecs , <nl> + const ExtentManager * em , <nl> + const DummyRecordStoreV1MetaData * md ) { <nl> + invariant ( records | | drecs ) ; / / if both are NULL nothing is being asserted . . . <nl> + <nl> + if ( records ) { <nl> + try { <nl> + long long dataSize = 0 ; <nl> + long long numRecs = 0 ; <nl> + <nl> + int recIdx = 0 ; <nl> + <nl> + DiskLoc extLoc = md - > firstExtent ( ) ; <nl> + while ( ! extLoc . isNull ( ) ) { <nl> + Extent * ext = em - > getExtent ( extLoc , true ) ; <nl> + DiskLoc actualLoc = ext - > firstRecord ; <nl> + while ( ! actualLoc . isNull ( ) ) { <nl> + const Record * actualRec = em - > recordForV1 ( actualLoc ) ; <nl> + const int actualSize = actualRec - > lengthWithHeaders ( ) ; <nl> + <nl> + dataSize + = actualSize - Record : : HeaderSize ; <nl> + numRecs + = 1 ; <nl> + <nl> + ASSERT_EQUALS ( actualLoc , records [ recIdx ] . loc ) ; <nl> + ASSERT_EQUALS ( actualSize , records [ recIdx ] . size ) ; <nl> + <nl> + ASSERT_EQUALS ( actualRec - > extentOfs ( ) , extLoc . getOfs ( ) ) ; <nl> + <nl> + recIdx + + ; <nl> + const int nextOfs = actualRec - > nextOfs ( ) ; <nl> + actualLoc = ( nextOfs = = DiskLoc : : NullOfs ? DiskLoc ( ) <nl> + : DiskLoc ( actualLoc . a ( ) , nextOfs ) ) ; <nl> + } <nl> + extLoc = ext - > xnext ; <nl> + } <nl> + <nl> + / / both the expected and actual record lists must be done at this point <nl> + ASSERT_EQUALS ( records [ recIdx ] . loc , DiskLoc ( ) ) ; <nl> + <nl> + ASSERT_EQUALS ( dataSize , md - > dataSize ( ) ) ; <nl> + ASSERT_EQUALS ( numRecs , md - > numRecords ( ) ) ; <nl> + } <nl> + catch ( . . . ) { <nl> + printRecList ( em , md ) ; <nl> + throw ; <nl> + } <nl> + } <nl> + <nl> + if ( drecs ) { <nl> + try { <nl> + int drecIdx = 0 ; <nl> + for ( int bucketIdx = 0 ; bucketIdx < RecordStoreV1Base : : Buckets ; bucketIdx + + ) { <nl> + DiskLoc actualLoc = md - > deletedListEntry ( bucketIdx ) ; <nl> + while ( ! actualLoc . isNull ( ) ) { <nl> + const DeletedRecord * actualDrec = & em - > recordForV1 ( actualLoc ) - > asDeleted ( ) ; <nl> + const int actualSize = actualDrec - > lengthWithHeaders ( ) ; <nl> + <nl> + ASSERT_EQUALS ( actualLoc , drecs [ drecIdx ] . loc ) ; <nl> + ASSERT_EQUALS ( actualSize , drecs [ drecIdx ] . size ) ; <nl> + <nl> + / / Make sure the drec is correct <nl> + ASSERT_EQUALS ( actualDrec - > extentOfs ( ) , 0 ) ; <nl> + ASSERT_EQUALS ( bucketIdx , RecordStoreV1Base : : bucket ( actualSize ) ) ; <nl> + <nl> + drecIdx + + ; <nl> + actualLoc = actualDrec - > nextDeleted ( ) ; <nl> + } <nl> + } <nl> + / / both the expected and actual deleted lists must be done at this point <nl> + ASSERT_EQUALS ( drecs [ drecIdx ] . loc , DiskLoc ( ) ) ; <nl> + } <nl> + catch ( . . . ) { <nl> + printDRecList ( em , md ) ; <nl> + throw ; <nl> + } <nl> + } <nl> + } <nl> } <nl> mmm a / src / mongo / db / structure / record_store_v1_test_help . h <nl> ppp b / src / mongo / db / structure / record_store_v1_test_help . h <nl> namespace mongo { <nl> <nl> std : : vector < ExtentInfo > _extents ; <nl> } ; <nl> + <nl> + struct LocAndSize { <nl> + DiskLoc loc ; <nl> + int size ; / / with headers <nl> + } ; <nl> <nl> + / * * <nl> + * Creates a V1 structure with the passed in records and DeletedRecords ( drecs ) . <nl> + * <nl> + * List of LocAndSize are terminated by a Null DiskLoc . Passing a NULL pointer is shorthand for <nl> + * an empty list . Each extent gets it ' s own DiskLoc file number . DiskLoc Offsets must be > 1000 . <nl> + * <nl> + * records must be sorted by extent / file . offsets within an extent can be in any order . <nl> + * <nl> + * drecs must be grouped into size - buckets , but the ordering within the size buckets is up to <nl> + * you . <nl> + * <nl> + * You are responsible for ensuring the records and drecs don ' t overlap ( unless you are testing <nl> + * a corrupt initial state ) . <nl> + * <nl> + * ExtentManager and MetaData must both be empty . <nl> + * / <nl> + void initializeV1RS ( TransactionExperiment * txn , <nl> + const LocAndSize * records , <nl> + const LocAndSize * drecs , <nl> + DummyExtentManager * em , <nl> + DummyRecordStoreV1MetaData * md ) ; <nl> + <nl> + / * * <nl> + * Asserts that the V1RecordStore defined by md has the passed in records and drecs in the <nl> + * correct order . <nl> + * <nl> + * List of LocAndSize are terminated by a Null DiskLoc . Passing a NULL pointer means don ' t check <nl> + * that list . <nl> + * / <nl> + void assertStateV1RS ( const LocAndSize * records , <nl> + const LocAndSize * drecs , <nl> + const ExtentManager * em , <nl> + const DummyRecordStoreV1MetaData * md ) ; <nl> } <nl> | SERVER - 13640 Helper for writing RecordStoreV1 structural tests | mongodb/mongo | 746576ae51166bb2a1a74ddb637b73679dee254e | 2014-05-12T16:06:25Z |
mmm a / docs / en / operations / system_tables . md <nl> ppp b / docs / en / operations / system_tables . md <nl> Columns : <nl> - 1 — TCP . <nl> - 2 — HTTP . <nl> - ` os_user ` ( String ) — User ' s OS . <nl> - - ` client_hostname ` ( String ) — Server name that the [ clickhouse - client ] ( . . / interfaces / cli . md ) is connected to . <nl> - - ` client_name ` ( String ) — The [ clickhouse - client ] ( . . / interfaces / cli . md ) name . <nl> - - ` client_revision ` ( UInt32 ) — Revision of the [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_major ` ( UInt32 ) — Major version of the [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_minor ` ( UInt32 ) — Minor version of the [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_patch ` ( UInt32 ) — Patch component of the [ clickhouse - client ] ( . . / interfaces / cli . md ) version . <nl> + - ` client_hostname ` ( String ) — Server name that the [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client is connected to . <nl> + - ` client_name ` ( String ) — The [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client name . <nl> + - ` client_revision ` ( UInt32 ) — Revision of the [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client . <nl> + - ` client_version_major ` ( UInt32 ) — Major version of the [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client . <nl> + - ` client_version_minor ` ( UInt32 ) — Minor version of the [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client . <nl> + - ` client_version_patch ` ( UInt32 ) — Patch component of the [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client version . <nl> - ` http_method ` ( UInt8 ) — HTTP method that initiated the query . Possible values : <nl> - 0 — The query was launched from the TCP interface . <nl> - 1 — ` GET ` method was used . <nl> Columns : <nl> - 1 — TCP . <nl> - 2 — HTTP . <nl> - ` os_user ` ( String ) — User ' s OS . <nl> - - ` client_hostname ` ( String ) — Server name that the [ clickhouse - client ] ( . . / interfaces / cli . md ) is connected to . <nl> - - ` client_name ` ( String ) — The [ clickhouse - client ] ( . . / interfaces / cli . md ) name . <nl> - - ` client_revision ` ( UInt32 ) — Revision of the [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_major ` ( UInt32 ) — Major version of the [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_minor ` ( UInt32 ) — Minor version of the [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_patch ` ( UInt32 ) — Patch component of the [ clickhouse - client ] ( . . / interfaces / cli . md ) version . <nl> + - ` client_hostname ` ( String ) — Server name that the [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client is connected to . <nl> + - ` client_name ` ( String ) — The [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client name . <nl> + - ` client_revision ` ( UInt32 ) — Revision of the [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client . <nl> + - ` client_version_major ` ( UInt32 ) — Major version of the [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client . <nl> + - ` client_version_minor ` ( UInt32 ) — Minor version of the [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client . <nl> + - ` client_version_patch ` ( UInt32 ) — Patch component of the [ clickhouse - client ] ( . . / interfaces / cli . md ) or another TCP client version . <nl> - ` http_method ` ( UInt8 ) — HTTP method that initiated the query . Possible values : <nl> - 0 — The query was launched from the TCP interface . <nl> - 1 — ` GET ` method was used . <nl> mmm a / docs / ru / operations / system_tables . md <nl> ppp b / docs / ru / operations / system_tables . md <nl> ClickHouse создаёт таблицу только в том случае , к <nl> - 1 — TCP . <nl> - 2 — HTTP . <nl> - ` os_user ` ( String ) — операционная система пользователя . <nl> - - ` client_hostname ` ( String ) — имя сервера , к которому присоединился [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_name ` ( String ) — [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_revision ` ( UInt32 ) — ревизия [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_major ` ( UInt32 ) — старшая версия [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_minor ` ( UInt32 ) — младшая версия [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_patch ` ( UInt32 ) — патч [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> + - ` client_hostname ` ( String ) — имя сервера , с которого присоединился [ clickhouse - client ] ( . . / interfaces / cli . md ) или другой TCP клиент . <nl> + - ` client_name ` ( String ) — [ clickhouse - client ] ( . . / interfaces / cli . md ) или другой TCP клиент . <nl> + - ` client_revision ` ( UInt32 ) — ревизия [ clickhouse - client ] ( . . / interfaces / cli . md ) или другого TCP клиента . <nl> + - ` client_version_major ` ( UInt32 ) — старшая версия [ clickhouse - client ] ( . . / interfaces / cli . md ) или другого TCP клиента . <nl> + - ` client_version_minor ` ( UInt32 ) — младшая версия [ clickhouse - client ] ( . . / interfaces / cli . md ) или другого TCP клиента . <nl> + - ` client_version_patch ` ( UInt32 ) — патч [ clickhouse - client ] ( . . / interfaces / cli . md ) или другого TCP клиента . <nl> - ` http_method ` ( UInt8 ) — HTTP метод , инициировавший запрос . Возможные значения : <nl> - 0 — запрос запущен с интерфейса TCP . <nl> - 1 — ` GET ` . <nl> ClickHouse создаёт таблицу только в том случае , к <nl> - 1 — TCP . <nl> - 2 — HTTP . <nl> - ` os_user ` ( String ) — операционная система пользователя . <nl> - - ` client_hostname ` ( String ) — имя сервера , к которому присоединился [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_name ` ( String ) — [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_revision ` ( UInt32 ) — ревизия [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_major ` ( UInt32 ) — старшая версия [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_minor ` ( UInt32 ) — младшая версия [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> - - ` client_version_patch ` ( UInt32 ) — патч [ clickhouse - client ] ( . . / interfaces / cli . md ) . <nl> + - ` client_hostname ` ( String ) — имя сервера , с которого присоединился [ clickhouse - client ] ( . . / interfaces / cli . md ) или другой TCP клиент . <nl> + - ` client_name ` ( String ) — [ clickhouse - client ] ( . . / interfaces / cli . md ) или другой TCP клиент . <nl> + - ` client_revision ` ( UInt32 ) — ревизия [ clickhouse - client ] ( . . / interfaces / cli . md ) или другого TCP клиента . <nl> + - ` client_version_major ` ( UInt32 ) — старшая версия [ clickhouse - client ] ( . . / interfaces / cli . md ) или другого TCP клиента . <nl> + - ` client_version_minor ` ( UInt32 ) — младшая версия [ clickhouse - client ] ( . . / interfaces / cli . md ) или другого TCP клиента . <nl> + - ` client_version_patch ` ( UInt32 ) — патч [ clickhouse - client ] ( . . / interfaces / cli . md ) или другого TCP клиента . <nl> - ` http_method ` ( UInt8 ) — HTTP метод , инициировавший запрос . Возможные значения : <nl> - 0 — запрос запущен с интерфейса TCP . <nl> - 1 — ` GET ` . <nl> | Fix the client_ * columns documentation | ClickHouse/ClickHouse | 1d56709656a7a7ea36ae9c991e72e608338058bb | 2019-12-02T11:48:52Z |
mmm a / doc / classes / RigidBody . xml <nl> ppp b / doc / classes / RigidBody . xml <nl> <nl> < member name = " axis_lock_linear_z " type = " bool " setter = " set_axis_lock " getter = " get_axis_lock " default = " false " > <nl> Lock the body ' s movement in the Z axis . <nl> < / member > <nl> - < member name = " bounce " type = " float " setter = " set_bounce " getter = " get_bounce " > <nl> - The body ' s bounciness . Values range from [ code ] 0 [ / code ] ( no bounce ) to [ code ] 1 [ / code ] ( full bounciness ) . <nl> - Deprecated , use [ member PhysicsMaterial . bounce ] instead via [ member physics_material_override ] . <nl> - < / member > <nl> < member name = " can_sleep " type = " bool " setter = " set_can_sleep " getter = " is_able_to_sleep " default = " true " > <nl> If [ code ] true [ / code ] , the RigidBody will not calculate forces and will act as a static body while there is no movement . It will wake up when forces are applied through other collisions or when the [ code ] apply_impulse [ / code ] method is used . <nl> < / member > <nl> <nl> < member name = " custom_integrator " type = " bool " setter = " set_use_custom_integrator " getter = " is_using_custom_integrator " default = " false " > <nl> If [ code ] true [ / code ] , internal force integration will be disabled ( like gravity or air friction ) for this body . Other than collision response , the body will only move as determined by the [ method _integrate_forces ] function , if defined . <nl> < / member > <nl> - < member name = " friction " type = " float " setter = " set_friction " getter = " get_friction " > <nl> - The body ' s friction , from 0 ( frictionless ) to 1 ( max friction ) . <nl> - Deprecated , use [ member PhysicsMaterial . friction ] instead via [ member physics_material_override ] . <nl> - < / member > <nl> < member name = " gravity_scale " type = " float " setter = " set_gravity_scale " getter = " get_gravity_scale " default = " 1 . 0 " > <nl> This is multiplied by the global 3D gravity setting found in [ b ] Project & gt ; Project Settings & gt ; Physics & gt ; 3d [ / b ] to produce RigidBody ' s gravity . For example , a value of 1 will be normal gravity , 2 will apply double gravity , and 0 . 5 will apply half gravity to this object . <nl> < / member > <nl> mmm a / doc / classes / RigidBody2D . xml <nl> ppp b / doc / classes / RigidBody2D . xml <nl> <nl> < member name = " applied_torque " type = " float " setter = " set_applied_torque " getter = " get_applied_torque " default = " 0 . 0 " > <nl> The body ' s total applied torque . <nl> < / member > <nl> - < member name = " bounce " type = " float " setter = " set_bounce " getter = " get_bounce " > <nl> - The body ' s bounciness . Values range from [ code ] 0 [ / code ] ( no bounce ) to [ code ] 1 [ / code ] ( full bounciness ) . <nl> - Deprecated , use [ member PhysicsMaterial . bounce ] instead via [ member physics_material_override ] . <nl> - < / member > <nl> < member name = " can_sleep " type = " bool " setter = " set_can_sleep " getter = " is_able_to_sleep " default = " true " > <nl> If [ code ] true [ / code ] , the body will not calculate forces and will act as a static body if there is no movement . The body will wake up when other forces are applied via collisions or by using [ method apply_impulse ] or [ method add_force ] . <nl> < / member > <nl> <nl> < member name = " custom_integrator " type = " bool " setter = " set_use_custom_integrator " getter = " is_using_custom_integrator " default = " false " > <nl> If [ code ] true [ / code ] , internal force integration is disabled for this body . Aside from collision response , the body will only move as determined by the [ method _integrate_forces ] function . <nl> < / member > <nl> - < member name = " friction " type = " float " setter = " set_friction " getter = " get_friction " > <nl> - The body ' s friction . Values range from [ code ] 0 [ / code ] ( frictionless ) to [ code ] 1 [ / code ] ( maximum friction ) . <nl> - Deprecated , use [ member PhysicsMaterial . friction ] instead via [ member physics_material_override ] . <nl> - < / member > <nl> < member name = " gravity_scale " type = " float " setter = " set_gravity_scale " getter = " get_gravity_scale " default = " 1 . 0 " > <nl> Multiplies the gravity applied to the body . The body ' s gravity is calculated from the [ b ] Default Gravity [ / b ] value in [ b ] Project & gt ; Project Settings & gt ; Physics & gt ; 2d [ / b ] and / or any additional gravity vector applied by [ Area2D ] s . <nl> < / member > <nl> mmm a / doc / classes / StaticBody . xml <nl> ppp b / doc / classes / StaticBody . xml <nl> <nl> < methods > <nl> < / methods > <nl> < members > <nl> - < member name = " bounce " type = " float " setter = " set_bounce " getter = " get_bounce " > <nl> - The body ' s bounciness . Values range from [ code ] 0 [ / code ] ( no bounce ) to [ code ] 1 [ / code ] ( full bounciness ) . <nl> - Deprecated , use [ member PhysicsMaterial . bounce ] instead via [ member physics_material_override ] . <nl> - < / member > <nl> < member name = " constant_angular_velocity " type = " Vector3 " setter = " set_constant_angular_velocity " getter = " get_constant_angular_velocity " default = " Vector3 ( 0 , 0 , 0 ) " > <nl> The body ' s constant angular velocity . This does not rotate the body , but affects other bodies that touch it , as if it was in a state of rotation . <nl> < / member > <nl> < member name = " constant_linear_velocity " type = " Vector3 " setter = " set_constant_linear_velocity " getter = " get_constant_linear_velocity " default = " Vector3 ( 0 , 0 , 0 ) " > <nl> The body ' s constant linear velocity . This does not move the body , but affects other bodies that touch it , as if it was in a state of movement . <nl> < / member > <nl> - < member name = " friction " type = " float " setter = " set_friction " getter = " get_friction " > <nl> - The body ' s friction , from 0 ( frictionless ) to 1 ( full friction ) . <nl> - Deprecated , use [ member PhysicsMaterial . friction ] instead via [ member physics_material_override ] . <nl> - < / member > <nl> < member name = " physics_material_override " type = " PhysicsMaterial " setter = " set_physics_material_override " getter = " get_physics_material_override " > <nl> The physics material override for the body . <nl> If a material is assigned to this property , it will be used instead of any other physics material , such as an inherited one . <nl> mmm a / doc / classes / StaticBody2D . xml <nl> ppp b / doc / classes / StaticBody2D . xml <nl> <nl> < methods > <nl> < / methods > <nl> < members > <nl> - < member name = " bounce " type = " float " setter = " set_bounce " getter = " get_bounce " > <nl> - The body ' s bounciness . Values range from [ code ] 0 [ / code ] ( no bounce ) to [ code ] 1 [ / code ] ( full bounciness ) . <nl> - Deprecated , use [ member PhysicsMaterial . bounce ] instead via [ member physics_material_override ] . <nl> - < / member > <nl> < member name = " constant_angular_velocity " type = " float " setter = " set_constant_angular_velocity " getter = " get_constant_angular_velocity " default = " 0 . 0 " > <nl> The body ' s constant angular velocity . This does not rotate the body , but affects colliding bodies , as if it were rotating . <nl> < / member > <nl> < member name = " constant_linear_velocity " type = " Vector2 " setter = " set_constant_linear_velocity " getter = " get_constant_linear_velocity " default = " Vector2 ( 0 , 0 ) " > <nl> The body ' s constant linear velocity . This does not move the body , but affects colliding bodies , as if it were moving . <nl> < / member > <nl> - < member name = " friction " type = " float " setter = " set_friction " getter = " get_friction " > <nl> - The body ' s friction . Values range from [ code ] 0 [ / code ] ( no friction ) to [ code ] 1 [ / code ] ( full friction ) . <nl> - Deprecated , use [ member PhysicsMaterial . friction ] instead via [ member physics_material_override ] . <nl> - < / member > <nl> < member name = " physics_material_override " type = " PhysicsMaterial " setter = " set_physics_material_override " getter = " get_physics_material_override " > <nl> The physics material override for the body . <nl> If a material is assigned to this property , it will be used instead of any other physics material , such as an inherited one . <nl> mmm a / scene / 2d / physics_body_2d . cpp <nl> ppp b / scene / 2d / physics_body_2d . cpp <nl> real_t StaticBody2D : : get_constant_angular_velocity ( ) const { <nl> return constant_angular_velocity ; <nl> } <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - void StaticBody2D : : set_friction ( real_t p_friction ) { <nl> - <nl> - if ( p_friction = = 1 . 0 & & physics_material_override . is_null ( ) ) { / / default value , don ' t create an override for that <nl> - return ; <nl> - } <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method set_friction has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - ERR_FAIL_COND_MSG ( p_friction < 0 | | p_friction > 1 , " Friction must be between 0 and 1 . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - physics_material_override . instance ( ) ; <nl> - set_physics_material_override ( physics_material_override ) ; <nl> - } <nl> - physics_material_override - > set_friction ( p_friction ) ; <nl> - } <nl> - <nl> - real_t StaticBody2D : : get_friction ( ) const { <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method get_friction has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - return 1 ; <nl> - } <nl> - <nl> - return physics_material_override - > get_friction ( ) ; <nl> - } <nl> - <nl> - void StaticBody2D : : set_bounce ( real_t p_bounce ) { <nl> - <nl> - if ( p_bounce = = 0 . 0 & & physics_material_override . is_null ( ) ) { / / default value , don ' t create an override for that <nl> - return ; <nl> - } <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method set_bounce has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - ERR_FAIL_COND_MSG ( p_bounce < 0 | | p_bounce > 1 , " Bounce must be between 0 and 1 . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - physics_material_override . instance ( ) ; <nl> - set_physics_material_override ( physics_material_override ) ; <nl> - } <nl> - physics_material_override - > set_bounce ( p_bounce ) ; <nl> - } <nl> - <nl> - real_t StaticBody2D : : get_bounce ( ) const { <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method get_bounce has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - return physics_material_override - > get_bounce ( ) ; <nl> - } <nl> - # endif / / DISABLE_DEPRECATED <nl> - <nl> void StaticBody2D : : set_physics_material_override ( const Ref < PhysicsMaterial > & p_physics_material_override ) { <nl> if ( physics_material_override . is_valid ( ) ) { <nl> if ( physics_material_override - > is_connected ( CoreStringNames : : get_singleton ( ) - > changed , this , " _reload_physics_characteristics " ) ) <nl> void StaticBody2D : : _bind_methods ( ) { <nl> ClassDB : : bind_method ( D_METHOD ( " get_constant_linear_velocity " ) , & StaticBody2D : : get_constant_linear_velocity ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " get_constant_angular_velocity " ) , & StaticBody2D : : get_constant_angular_velocity ) ; <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - ClassDB : : bind_method ( D_METHOD ( " set_friction " , " friction " ) , & StaticBody2D : : set_friction ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " get_friction " ) , & StaticBody2D : : get_friction ) ; <nl> - <nl> - ClassDB : : bind_method ( D_METHOD ( " set_bounce " , " bounce " ) , & StaticBody2D : : set_bounce ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " get_bounce " ) , & StaticBody2D : : get_bounce ) ; <nl> - # endif / / DISABLE_DEPRECATED <nl> - <nl> ClassDB : : bind_method ( D_METHOD ( " set_physics_material_override " , " physics_material_override " ) , & StaticBody2D : : set_physics_material_override ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " get_physics_material_override " ) , & StaticBody2D : : get_physics_material_override ) ; <nl> <nl> void StaticBody2D : : _bind_methods ( ) { <nl> <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : VECTOR2 , " constant_linear_velocity " ) , " set_constant_linear_velocity " , " get_constant_linear_velocity " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " constant_angular_velocity " ) , " set_constant_angular_velocity " , " get_constant_angular_velocity " ) ; <nl> - # ifndef DISABLE_DEPRECATED <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " friction " , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 01 " , 0 ) , " set_friction " , " get_friction " ) ; <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " bounce " , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 01 " , 0 ) , " set_bounce " , " get_bounce " ) ; <nl> - # endif / / DISABLE_DEPRECATED <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : OBJECT , " physics_material_override " , PROPERTY_HINT_RESOURCE_TYPE , " PhysicsMaterial " ) , " set_physics_material_override " , " get_physics_material_override " ) ; <nl> } <nl> <nl> real_t RigidBody2D : : get_weight ( ) const { <nl> return mass * ( real_t ( GLOBAL_DEF ( " physics / 2d / default_gravity " , 98 ) ) / 10 ) ; <nl> } <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - void RigidBody2D : : set_friction ( real_t p_friction ) { <nl> - <nl> - if ( p_friction = = 1 . 0 & & physics_material_override . is_null ( ) ) { / / default value , don ' t create an override for that <nl> - return ; <nl> - } <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method set_friction has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - ERR_FAIL_COND_MSG ( p_friction < 0 | | p_friction > 1 , " Friction must be between 0 and 1 . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - physics_material_override . instance ( ) ; <nl> - set_physics_material_override ( physics_material_override ) ; <nl> - } <nl> - physics_material_override - > set_friction ( p_friction ) ; <nl> - } <nl> - real_t RigidBody2D : : get_friction ( ) const { <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method get_friction has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - return 1 ; <nl> - } <nl> - <nl> - return physics_material_override - > get_friction ( ) ; <nl> - } <nl> - <nl> - void RigidBody2D : : set_bounce ( real_t p_bounce ) { <nl> - <nl> - if ( p_bounce = = 0 . 0 & & physics_material_override . is_null ( ) ) { / / default value , don ' t create an override for that <nl> - return ; <nl> - } <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method set_bounce has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - ERR_FAIL_COND ( p_bounce < 0 | | p_bounce > 1 ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - physics_material_override . instance ( ) ; <nl> - set_physics_material_override ( physics_material_override ) ; <nl> - } <nl> - physics_material_override - > set_bounce ( p_bounce ) ; <nl> - } <nl> - real_t RigidBody2D : : get_bounce ( ) const { <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method get_bounce has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - return physics_material_override - > get_bounce ( ) ; <nl> - } <nl> - # endif / / DISABLE_DEPRECATED <nl> - <nl> void RigidBody2D : : set_physics_material_override ( const Ref < PhysicsMaterial > & p_physics_material_override ) { <nl> if ( physics_material_override . is_valid ( ) ) { <nl> if ( physics_material_override - > is_connected ( CoreStringNames : : get_singleton ( ) - > changed , this , " _reload_physics_characteristics " ) ) <nl> void RigidBody2D : : _bind_methods ( ) { <nl> ClassDB : : bind_method ( D_METHOD ( " set_weight " , " weight " ) , & RigidBody2D : : set_weight ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " get_weight " ) , & RigidBody2D : : get_weight ) ; <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - ClassDB : : bind_method ( D_METHOD ( " set_friction " , " friction " ) , & RigidBody2D : : set_friction ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " get_friction " ) , & RigidBody2D : : get_friction ) ; <nl> - <nl> - ClassDB : : bind_method ( D_METHOD ( " set_bounce " , " bounce " ) , & RigidBody2D : : set_bounce ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " get_bounce " ) , & RigidBody2D : : get_bounce ) ; <nl> - # endif / / DISABLE_DEPRECATED <nl> - <nl> ClassDB : : bind_method ( D_METHOD ( " set_physics_material_override " , " physics_material_override " ) , & RigidBody2D : : set_physics_material_override ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " get_physics_material_override " ) , & RigidBody2D : : get_physics_material_override ) ; <nl> <nl> void RigidBody2D : : _bind_methods ( ) { <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " mass " , PROPERTY_HINT_EXP_RANGE , " 0 . 01 , 65535 , 0 . 01 " ) , " set_mass " , " get_mass " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " inertia " , PROPERTY_HINT_EXP_RANGE , " 0 . 01 , 65535 , 0 . 01 " , 0 ) , " set_inertia " , " get_inertia " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " weight " , PROPERTY_HINT_EXP_RANGE , " 0 . 01 , 65535 , 0 . 01 " , PROPERTY_USAGE_EDITOR ) , " set_weight " , " get_weight " ) ; <nl> - # ifndef DISABLE_DEPRECATED <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " friction " , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 01 " , 0 ) , " set_friction " , " get_friction " ) ; <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " bounce " , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 01 " , 0 ) , " set_bounce " , " get_bounce " ) ; <nl> - # endif / / DISABLE_DEPRECATED <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : OBJECT , " physics_material_override " , PROPERTY_HINT_RESOURCE_TYPE , " PhysicsMaterial " ) , " set_physics_material_override " , " get_physics_material_override " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " gravity_scale " , PROPERTY_HINT_RANGE , " - 128 , 128 , 0 . 01 " ) , " set_gravity_scale " , " get_gravity_scale " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " custom_integrator " ) , " set_use_custom_integrator " , " is_using_custom_integrator " ) ; <nl> mmm a / scene / 2d / physics_body_2d . h <nl> ppp b / scene / 2d / physics_body_2d . h <nl> class StaticBody2D : public PhysicsBody2D { <nl> static void _bind_methods ( ) ; <nl> <nl> public : <nl> - # ifndef DISABLE_DEPRECATED <nl> - void set_friction ( real_t p_friction ) ; <nl> - real_t get_friction ( ) const ; <nl> - <nl> - void set_bounce ( real_t p_bounce ) ; <nl> - real_t get_bounce ( ) const ; <nl> - # endif <nl> void set_physics_material_override ( const Ref < PhysicsMaterial > & p_physics_material_override ) ; <nl> Ref < PhysicsMaterial > get_physics_material_override ( ) const ; <nl> <nl> class RigidBody2D : public PhysicsBody2D { <nl> void set_weight ( real_t p_weight ) ; <nl> real_t get_weight ( ) const ; <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - void set_friction ( real_t p_friction ) ; <nl> - real_t get_friction ( ) const ; <nl> - <nl> - void set_bounce ( real_t p_bounce ) ; <nl> - real_t get_bounce ( ) const ; <nl> - # endif <nl> - <nl> void set_physics_material_override ( const Ref < PhysicsMaterial > & p_physics_material_override ) ; <nl> Ref < PhysicsMaterial > get_physics_material_override ( ) const ; <nl> <nl> mmm a / scene / 3d / physics_body . cpp <nl> ppp b / scene / 3d / physics_body . cpp <nl> PhysicsBody : : PhysicsBody ( PhysicsServer : : BodyMode p_mode ) : <nl> collision_mask = 1 ; <nl> } <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - void StaticBody : : set_friction ( real_t p_friction ) { <nl> - <nl> - if ( p_friction = = 1 . 0 & & physics_material_override . is_null ( ) ) { / / default value , don ' t create an override for that <nl> - return ; <nl> - } <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method set_friction has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - ERR_FAIL_COND_MSG ( p_friction < 0 | | p_friction > 1 , " Friction must be between 0 and 1 . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - physics_material_override . instance ( ) ; <nl> - set_physics_material_override ( physics_material_override ) ; <nl> - } <nl> - physics_material_override - > set_friction ( p_friction ) ; <nl> - } <nl> - <nl> - real_t StaticBody : : get_friction ( ) const { <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method get_friction has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - return 1 ; <nl> - } <nl> - <nl> - return physics_material_override - > get_friction ( ) ; <nl> - } <nl> - <nl> - void StaticBody : : set_bounce ( real_t p_bounce ) { <nl> - <nl> - if ( p_bounce = = 0 . 0 & & physics_material_override . is_null ( ) ) { / / default value , don ' t create an override for that <nl> - return ; <nl> - } <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method set_bounce has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - ERR_FAIL_COND_MSG ( p_bounce < 0 | | p_bounce > 1 , " Bounce must be between 0 and 1 . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - physics_material_override . instance ( ) ; <nl> - set_physics_material_override ( physics_material_override ) ; <nl> - } <nl> - physics_material_override - > set_bounce ( p_bounce ) ; <nl> - } <nl> - <nl> - real_t StaticBody : : get_bounce ( ) const { <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method get_bounce has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - return physics_material_override - > get_bounce ( ) ; <nl> - } <nl> - # endif <nl> - <nl> void StaticBody : : set_physics_material_override ( const Ref < PhysicsMaterial > & p_physics_material_override ) { <nl> if ( physics_material_override . is_valid ( ) ) { <nl> if ( physics_material_override - > is_connected ( CoreStringNames : : get_singleton ( ) - > changed , this , " _reload_physics_characteristics " ) ) <nl> void StaticBody : : _bind_methods ( ) { <nl> ClassDB : : bind_method ( D_METHOD ( " get_constant_linear_velocity " ) , & StaticBody : : get_constant_linear_velocity ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " get_constant_angular_velocity " ) , & StaticBody : : get_constant_angular_velocity ) ; <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - ClassDB : : bind_method ( D_METHOD ( " set_friction " , " friction " ) , & StaticBody : : set_friction ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " get_friction " ) , & StaticBody : : get_friction ) ; <nl> - <nl> - ClassDB : : bind_method ( D_METHOD ( " set_bounce " , " bounce " ) , & StaticBody : : set_bounce ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " get_bounce " ) , & StaticBody : : get_bounce ) ; <nl> - # endif / / DISABLE_DEPRECATED <nl> - <nl> ClassDB : : bind_method ( D_METHOD ( " set_physics_material_override " , " physics_material_override " ) , & StaticBody : : set_physics_material_override ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " get_physics_material_override " ) , & StaticBody : : get_physics_material_override ) ; <nl> <nl> void StaticBody : : _bind_methods ( ) { <nl> ClassDB : : bind_method ( D_METHOD ( " add_collision_exception_with " , " body " ) , & PhysicsBody : : add_collision_exception_with ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " remove_collision_exception_with " , " body " ) , & PhysicsBody : : remove_collision_exception_with ) ; <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " friction " , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 01 " , 0 ) , " set_friction " , " get_friction " ) ; <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " bounce " , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 01 " , 0 ) , " set_bounce " , " get_bounce " ) ; <nl> - # endif / / DISABLE_DEPRECATED <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : OBJECT , " physics_material_override " , PROPERTY_HINT_RESOURCE_TYPE , " PhysicsMaterial " ) , " set_physics_material_override " , " get_physics_material_override " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : VECTOR3 , " constant_linear_velocity " ) , " set_constant_linear_velocity " , " get_constant_linear_velocity " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : VECTOR3 , " constant_angular_velocity " ) , " set_constant_angular_velocity " , " get_constant_angular_velocity " ) ; <nl> real_t RigidBody : : get_weight ( ) const { <nl> return mass * real_t ( GLOBAL_DEF ( " physics / 3d / default_gravity " , 9 . 8 ) ) ; <nl> } <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - void RigidBody : : set_friction ( real_t p_friction ) { <nl> - <nl> - if ( p_friction = = 1 . 0 & & physics_material_override . is_null ( ) ) { / / default value , don ' t create an override for that <nl> - return ; <nl> - } <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method set_friction has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - ERR_FAIL_COND ( p_friction < 0 | | p_friction > 1 ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - physics_material_override . instance ( ) ; <nl> - set_physics_material_override ( physics_material_override ) ; <nl> - } <nl> - physics_material_override - > set_friction ( p_friction ) ; <nl> - } <nl> - real_t RigidBody : : get_friction ( ) const { <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method get_friction has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - return 1 ; <nl> - } <nl> - <nl> - return physics_material_override - > get_friction ( ) ; <nl> - } <nl> - <nl> - void RigidBody : : set_bounce ( real_t p_bounce ) { <nl> - <nl> - if ( p_bounce = = 0 . 0 & & physics_material_override . is_null ( ) ) { / / default value , don ' t create an override for that <nl> - return ; <nl> - } <nl> - <nl> - WARN_DEPRECATED_MSG ( " The method set_bounce has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - <nl> - ERR_FAIL_COND ( p_bounce < 0 | | p_bounce > 1 ) ; <nl> - <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - physics_material_override . instance ( ) ; <nl> - set_physics_material_override ( physics_material_override ) ; <nl> - } <nl> - physics_material_override - > set_bounce ( p_bounce ) ; <nl> - } <nl> - real_t RigidBody : : get_bounce ( ) const { <nl> - WARN_DEPRECATED_MSG ( " The method get_bounce has been deprecated and will be removed in the future , use physics material instead . " ) ; <nl> - if ( physics_material_override . is_null ( ) ) { <nl> - return 0 ; <nl> - } <nl> - <nl> - return physics_material_override - > get_bounce ( ) ; <nl> - } <nl> - # endif / / DISABLE_DEPRECATED <nl> - <nl> void RigidBody : : set_physics_material_override ( const Ref < PhysicsMaterial > & p_physics_material_override ) { <nl> if ( physics_material_override . is_valid ( ) ) { <nl> if ( physics_material_override - > is_connected ( CoreStringNames : : get_singleton ( ) - > changed , this , " _reload_physics_characteristics " ) ) <nl> void RigidBody : : _bind_methods ( ) { <nl> ClassDB : : bind_method ( D_METHOD ( " set_weight " , " weight " ) , & RigidBody : : set_weight ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " get_weight " ) , & RigidBody : : get_weight ) ; <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - ClassDB : : bind_method ( D_METHOD ( " set_friction " , " friction " ) , & RigidBody : : set_friction ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " get_friction " ) , & RigidBody : : get_friction ) ; <nl> - <nl> - ClassDB : : bind_method ( D_METHOD ( " set_bounce " , " bounce " ) , & RigidBody : : set_bounce ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " get_bounce " ) , & RigidBody : : get_bounce ) ; <nl> - # endif / / DISABLE_DEPRECATED <nl> - <nl> ClassDB : : bind_method ( D_METHOD ( " set_physics_material_override " , " physics_material_override " ) , & RigidBody : : set_physics_material_override ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " get_physics_material_override " ) , & RigidBody : : get_physics_material_override ) ; <nl> <nl> void RigidBody : : _bind_methods ( ) { <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : INT , " mode " , PROPERTY_HINT_ENUM , " Rigid , Static , Character , Kinematic " ) , " set_mode " , " get_mode " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " mass " , PROPERTY_HINT_EXP_RANGE , " 0 . 01 , 65535 , 0 . 01 " ) , " set_mass " , " get_mass " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " weight " , PROPERTY_HINT_EXP_RANGE , " 0 . 01 , 65535 , 0 . 01 " , PROPERTY_USAGE_EDITOR ) , " set_weight " , " get_weight " ) ; <nl> - # ifndef DISABLE_DEPRECATED <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " friction " , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 01 " , 0 ) , " set_friction " , " get_friction " ) ; <nl> - ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " bounce " , PROPERTY_HINT_RANGE , " 0 , 1 , 0 . 01 " , 0 ) , " set_bounce " , " get_bounce " ) ; <nl> - # endif / / DISABLE_DEPRECATED <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : OBJECT , " physics_material_override " , PROPERTY_HINT_RESOURCE_TYPE , " PhysicsMaterial " ) , " set_physics_material_override " , " get_physics_material_override " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : REAL , " gravity_scale " , PROPERTY_HINT_RANGE , " - 128 , 128 , 0 . 01 " ) , " set_gravity_scale " , " get_gravity_scale " ) ; <nl> ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL , " custom_integrator " ) , " set_use_custom_integrator " , " is_using_custom_integrator " ) ; <nl> mmm a / scene / 3d / physics_body . h <nl> ppp b / scene / 3d / physics_body . h <nl> class StaticBody : public PhysicsBody { <nl> static void _bind_methods ( ) ; <nl> <nl> public : <nl> - # ifndef DISABLE_DEPRECATED <nl> - void set_friction ( real_t p_friction ) ; <nl> - real_t get_friction ( ) const ; <nl> - <nl> - void set_bounce ( real_t p_bounce ) ; <nl> - real_t get_bounce ( ) const ; <nl> - # endif <nl> - <nl> void set_physics_material_override ( const Ref < PhysicsMaterial > & p_physics_material_override ) ; <nl> Ref < PhysicsMaterial > get_physics_material_override ( ) const ; <nl> <nl> class RigidBody : public PhysicsBody { <nl> void set_weight ( real_t p_weight ) ; <nl> real_t get_weight ( ) const ; <nl> <nl> - # ifndef DISABLE_DEPRECATED <nl> - void set_friction ( real_t p_friction ) ; <nl> - real_t get_friction ( ) const ; <nl> - <nl> - void set_bounce ( real_t p_bounce ) ; <nl> - real_t get_bounce ( ) const ; <nl> - # endif <nl> - <nl> void set_physics_material_override ( const Ref < PhysicsMaterial > & p_physics_material_override ) ; <nl> Ref < PhysicsMaterial > get_physics_material_override ( ) const ; <nl> <nl> | Merge pull request from akien - mga / remove - deprecated - friction - bounce | godotengine/godot | c48237967a0a4d3901c157a828017d7330df0578 | 2020-02-12T20:49:38Z |
mmm a / csharp / src / Google . Protobuf . Benchmarks / Google . Protobuf . Benchmarks . csproj <nl> ppp b / csharp / src / Google . Protobuf . Benchmarks / Google . Protobuf . Benchmarks . csproj <nl> <nl> < PropertyGroup > <nl> < OutputType > Exe < / OutputType > <nl> < TargetFramework > netcoreapp2 . 1 < / TargetFramework > <nl> + < IsPackable > False < / IsPackable > <nl> < / PropertyGroup > <nl> <nl> < ItemGroup > <nl> | Make the C # benchmarks non - packable | protocolbuffers/protobuf | 2de68bc33a9ff51b56a72b582ca5a057167d9181 | 2019-03-15T09:39:50Z |
mmm a / include / swift / Serialization / ModuleFormat . h <nl> ppp b / include / swift / Serialization / ModuleFormat . h <nl> const uint16_t VERSION_MAJOR = 0 ; <nl> / / / in source control , you should also update the comment to briefly <nl> / / / describe what change you made . The content of this comment isn ' t important ; <nl> / / / it just ensures a conflict if two people change the module format . <nl> - const uint16_t VERSION_MINOR = 350 ; / / Last change : special decl names <nl> + const uint16_t VERSION_MINOR = 351 ; / / Last change : open_existential_box_value <nl> <nl> using DeclID = PointerEmbeddedInt < unsigned , 31 > ; <nl> using DeclIDField = BCFixed < 31 > ; <nl> | Merge remote - tracking branch ' origin / master ' into master - next | apple/swift | dbb3d651cacf6aec883bd0fe76d5e4318db057c8 | 2017-07-18T17:28:50Z |
new file mode 100644 <nl> index 00000000000 . . eef969b284b <nl> mmm / dev / null <nl> ppp b / tools / internal_ci / linux / grpc_build_artifacts . cfg <nl> <nl> + # Copyright 2017 , Google Inc . <nl> + # All rights reserved . <nl> + # <nl> + # Redistribution and use in source and binary forms , with or without <nl> + # modification , are permitted provided that the following conditions are <nl> + # met : <nl> + # <nl> + # * Redistributions of source code must retain the above copyright <nl> + # notice , this list of conditions and the following disclaimer . <nl> + # * Redistributions in binary form must reproduce the above <nl> + # copyright notice , this list of conditions and the following disclaimer <nl> + # in the documentation and / or other materials provided with the <nl> + # distribution . <nl> + # * Neither the name of Google Inc . nor the names of its <nl> + # contributors may be used to endorse or promote products derived from <nl> + # this software without specific prior written permission . <nl> + # <nl> + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + # " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + # LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + # A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + # SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + # LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + # DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + # THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + # ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + # OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + # Config file for the internal CI ( in protobuf text format ) <nl> + <nl> + # Location of the continuous shell script in repository . <nl> + build_file : " grpc / tools / internal_ci / linux / grpc_build_artifacts . sh " <nl> + timeout_mins : 120 <nl> + action { <nl> + define_artifacts { <nl> + regex : " * * / * sponge_log . xml " <nl> + regex : " github / grpc / artifacts / * * " <nl> + } <nl> + } <nl> new file mode 100755 <nl> index 00000000000 . . 1b12be143e9 <nl> mmm / dev / null <nl> ppp b / tools / internal_ci / linux / grpc_build_artifacts . sh <nl> <nl> + # ! / bin / bash <nl> + # Copyright 2017 , Google Inc . <nl> + # All rights reserved . <nl> + # <nl> + # Redistribution and use in source and binary forms , with or without <nl> + # modification , are permitted provided that the following conditions are <nl> + # met : <nl> + # <nl> + # * Redistributions of source code must retain the above copyright <nl> + # notice , this list of conditions and the following disclaimer . <nl> + # * Redistributions in binary form must reproduce the above <nl> + # copyright notice , this list of conditions and the following disclaimer <nl> + # in the documentation and / or other materials provided with the <nl> + # distribution . <nl> + # * Neither the name of Google Inc . nor the names of its <nl> + # contributors may be used to endorse or promote products derived from <nl> + # this software without specific prior written permission . <nl> + # <nl> + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + # " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + # LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + # A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + # SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + # LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + # DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + # THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + # ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + # OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + set - ex <nl> + <nl> + # change to grpc repo root <nl> + cd $ ( dirname $ 0 ) / . . / . . / . . <nl> + <nl> + source tools / internal_ci / helper_scripts / prepare_build_linux_rc <nl> + <nl> + tools / run_tests / task_runner . py - f artifact linux <nl> new file mode 100644 <nl> index 00000000000 . . 4d2506944a4 <nl> mmm / dev / null <nl> ppp b / tools / internal_ci / macos / grpc_build_artifacts . cfg <nl> <nl> + # Copyright 2017 , Google Inc . <nl> + # All rights reserved . <nl> + # <nl> + # Redistribution and use in source and binary forms , with or without <nl> + # modification , are permitted provided that the following conditions are <nl> + # met : <nl> + # <nl> + # * Redistributions of source code must retain the above copyright <nl> + # notice , this list of conditions and the following disclaimer . <nl> + # * Redistributions in binary form must reproduce the above <nl> + # copyright notice , this list of conditions and the following disclaimer <nl> + # in the documentation and / or other materials provided with the <nl> + # distribution . <nl> + # * Neither the name of Google Inc . nor the names of its <nl> + # contributors may be used to endorse or promote products derived from <nl> + # this software without specific prior written permission . <nl> + # <nl> + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + # " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + # LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + # A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + # SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + # LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + # DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + # THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + # ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + # OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + # Config file for the internal CI ( in protobuf text format ) <nl> + <nl> + # Location of the continuous shell script in repository . <nl> + build_file : " grpc / tools / internal_ci / macos / grpc_build_artifacts . sh " <nl> + timeout_mins : 120 <nl> + action { <nl> + define_artifacts { <nl> + regex : " * * / * sponge_log . xml " <nl> + regex : " github / grpc / artifacts / * * " <nl> + } <nl> + } <nl> new file mode 100755 <nl> index 00000000000 . . b4c118f7854 <nl> mmm / dev / null <nl> ppp b / tools / internal_ci / macos / grpc_build_artifacts . sh <nl> <nl> + # ! / bin / bash <nl> + # Copyright 2017 , Google Inc . <nl> + # All rights reserved . <nl> + # <nl> + # Redistribution and use in source and binary forms , with or without <nl> + # modification , are permitted provided that the following conditions are <nl> + # met : <nl> + # <nl> + # * Redistributions of source code must retain the above copyright <nl> + # notice , this list of conditions and the following disclaimer . <nl> + # * Redistributions in binary form must reproduce the above <nl> + # copyright notice , this list of conditions and the following disclaimer <nl> + # in the documentation and / or other materials provided with the <nl> + # distribution . <nl> + # * Neither the name of Google Inc . nor the names of its <nl> + # contributors may be used to endorse or promote products derived from <nl> + # this software without specific prior written permission . <nl> + # <nl> + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + # " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + # LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + # A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + # SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + # LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + # DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + # THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + # ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + # OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + set - ex <nl> + <nl> + # change to grpc repo root <nl> + cd $ ( dirname $ 0 ) / . . / . . / . . <nl> + <nl> + git submodule update - - init <nl> + <nl> + tools / run_tests / task_runner . py - f artifact macos <nl> new file mode 100644 <nl> index 00000000000 . . 648f038b451 <nl> mmm / dev / null <nl> ppp b / tools / internal_ci / windows / grpc_build_artifacts . bat <nl> <nl> + @ rem Copyright 2017 , Google Inc . <nl> + @ rem All rights reserved . <nl> + @ rem <nl> + @ rem Redistribution and use in source and binary forms , with or without <nl> + @ rem modification , are permitted provided that the following conditions are <nl> + @ rem met : <nl> + @ rem <nl> + @ rem * Redistributions of source code must retain the above copyright <nl> + @ rem notice , this list of conditions and the following disclaimer . <nl> + @ rem * Redistributions in binary form must reproduce the above <nl> + @ rem copyright notice , this list of conditions and the following disclaimer <nl> + @ rem in the documentation and / or other materials provided with the <nl> + @ rem distribution . <nl> + @ rem * Neither the name of Google Inc . nor the names of its <nl> + @ rem contributors may be used to endorse or promote products derived from <nl> + @ rem this software without specific prior written permission . <nl> + @ rem <nl> + @ rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + @ rem " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + @ rem LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + @ rem A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + @ rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + @ rem SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + @ rem LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + @ rem DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + @ rem THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + @ rem ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + @ rem OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + @ rem make sure msys binaries are preferred over cygwin binaries <nl> + @ rem set path to python 2 . 7 <nl> + set PATH = C : \ tools \ msys64 \ usr \ bin ; C : \ Python27 ; % PATH % <nl> + <nl> + @ rem enter repo root <nl> + cd / d % ~ dp0 \ . . \ . . \ . . <nl> + <nl> + git submodule update - - init <nl> + <nl> + python tools / run_tests / task_runner . py - f artifact windows | | goto : error <nl> + goto : EOF <nl> + <nl> + : error <nl> + exit / b % errorlevel % <nl> new file mode 100644 <nl> index 00000000000 . . 89511815e1a <nl> mmm / dev / null <nl> ppp b / tools / internal_ci / windows / grpc_build_artifacts . cfg <nl> <nl> + # Copyright 2017 , Google Inc . <nl> + # All rights reserved . <nl> + # <nl> + # Redistribution and use in source and binary forms , with or without <nl> + # modification , are permitted provided that the following conditions are <nl> + # met : <nl> + # <nl> + # * Redistributions of source code must retain the above copyright <nl> + # notice , this list of conditions and the following disclaimer . <nl> + # * Redistributions in binary form must reproduce the above <nl> + # copyright notice , this list of conditions and the following disclaimer <nl> + # in the documentation and / or other materials provided with the <nl> + # distribution . <nl> + # * Neither the name of Google Inc . nor the names of its <nl> + # contributors may be used to endorse or promote products derived from <nl> + # this software without specific prior written permission . <nl> + # <nl> + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS <nl> + # " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT <nl> + # LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR <nl> + # A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT <nl> + # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , <nl> + # SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT <nl> + # LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , <nl> + # DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY <nl> + # THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT <nl> + # ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE <nl> + # OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . <nl> + <nl> + # Config file for the internal CI ( in protobuf text format ) <nl> + <nl> + # Location of the continuous shell script in repository . <nl> + build_file : " grpc / tools / internal_ci / windows / grpc_build_artifacts . bat " <nl> + timeout_mins : 120 <nl> + action { <nl> + define_artifacts { <nl> + regex : " * * / * sponge_log . xml " <nl> + regex : " github / grpc / artifacts / * * " <nl> + } <nl> + } <nl> | Merge pull request from jtattermusch / internal_ci_artifact_builds | grpc/grpc | 746f21ade866d92efdab3e633fa63429bda20813 | 2017-05-15T17:42:18Z |
mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> NOTE ( enum_raw_value_incrementing_from_zero , none , <nl> <nl> / / Derived conformances <nl> <nl> + ERROR ( cannot_synthesize_in_extension , none , <nl> + " implementation of % 0 cannot be automatically synthesized in an extension yet " , ( Type ) ) <nl> + <nl> ERROR ( broken_raw_representable_requirement , none , <nl> " RawRepresentable protocol is broken : unexpected requirement " , ( ) ) <nl> ERROR ( broken_equatable_requirement , none , <nl> ERROR ( broken_encodable_requirement , none , <nl> ERROR ( broken_decodable_requirement , none , <nl> " Decodable protocol is broken : unexpected requirement " , ( ) ) <nl> <nl> + NOTE ( codable_extraneous_codingkey_case_here , none , <nl> + " CodingKey case % 0 does match any stored properties " , ( Identifier ) ) <nl> + NOTE ( codable_non_conforming_property_here , none , <nl> + " cannot automatically synthesize % 0 because % 1 does not conform to % 0 " , ( Type , Identifier ) ) <nl> + NOTE ( codable_non_decoded_property_here , none , <nl> + " cannot automatically synthesize % 0 because % 1 does not have a matching CodingKey and does not have a default value " , ( Type , Identifier ) ) <nl> + NOTE ( codable_codingkeys_type_is_not_an_enum_here , none , <nl> + " cannot automatically synthesize % 0 because ' CodingKeys ' is not an enum " , ( Type ) ) <nl> + NOTE ( codable_codingkeys_type_does_not_conform_here , none , <nl> + " cannot automatically synthesize % 0 because ' CodingKeys ' does not conform to CodingKey " , ( Type ) ) <nl> + <nl> / / Dynamic Self <nl> ERROR ( dynamic_self_non_method , none , <nl> " % select { global | local } 0 function cannot return ' Self ' " , ( bool ) ) <nl> mmm a / lib / Sema / DerivedConformanceCodable . cpp <nl> ppp b / lib / Sema / DerivedConformanceCodable . cpp <nl> <nl> / / protocols for a struct or class . <nl> / / <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> - / / <nl> + <nl> # include " TypeChecker . h " <nl> # include " swift / AST / Decl . h " <nl> # include " swift / AST / Expr . h " <nl> using namespace DerivedConformance ; <nl> / / / Returns whether the type represented by the given ClassDecl inherits from a <nl> / / / type which conforms to the given protocol . <nl> / / / <nl> - / / / \ param type The \ c ClassDecl whose superclass to look up . <nl> + / / / \ param target The \ c ClassDecl whose superclass to look up . <nl> / / / <nl> / / / \ param proto The protocol to check conformance for . <nl> - static bool inheritsConformanceTo ( ClassDecl * type , ProtocolDecl * proto ) { <nl> - if ( ! type - > hasSuperclass ( ) ) <nl> + static bool inheritsConformanceTo ( ClassDecl * target , ProtocolDecl * proto ) { <nl> + if ( ! target - > hasSuperclass ( ) ) <nl> return false ; <nl> <nl> - auto & C = type - > getASTContext ( ) ; <nl> - auto * superclassDecl = type - > getSuperclassDecl ( ) ; <nl> + auto & C = target - > getASTContext ( ) ; <nl> + auto * superclassDecl = target - > getSuperclassDecl ( ) ; <nl> auto * superclassModule = superclassDecl - > getModuleContext ( ) ; <nl> - return ( bool ) superclassModule - > lookupConformance ( type - > getSuperclass ( ) , <nl> + return ( bool ) superclassModule - > lookupConformance ( target - > getSuperclass ( ) , <nl> proto , <nl> C . getLazyResolver ( ) ) ; <nl> } <nl> <nl> / / / Returns whether the superclass of the given class conforms to Encodable . <nl> / / / <nl> - / / / \ param type The \ c ClassDecl whose superclass to check . <nl> - static bool superclassIsEncodable ( ClassDecl * type ) { <nl> - auto & C = type - > getASTContext ( ) ; <nl> - return inheritsConformanceTo ( type , <nl> + / / / \ param target The \ c ClassDecl whose superclass to check . <nl> + static bool superclassIsEncodable ( ClassDecl * target ) { <nl> + auto & C = target - > getASTContext ( ) ; <nl> + return inheritsConformanceTo ( target , <nl> C . getProtocol ( KnownProtocolKind : : Encodable ) ) ; <nl> } <nl> <nl> / / / Returns whether the superclass of the given class conforms to Decodable . <nl> / / / <nl> - / / / \ param type The \ c ClassDecl whose superclass to check . <nl> - static bool superclassIsDecodable ( ClassDecl * type ) { <nl> - auto & C = type - > getASTContext ( ) ; <nl> - return inheritsConformanceTo ( type , <nl> + / / / \ param target The \ c ClassDecl whose superclass to check . <nl> + static bool superclassIsDecodable ( ClassDecl * target ) { <nl> + auto & C = target - > getASTContext ( ) ; <nl> + return inheritsConformanceTo ( target , <nl> C . getProtocol ( KnownProtocolKind : : Decodable ) ) ; <nl> } <nl> <nl> - / / / Validates that all the variables declared in the given list of declarations <nl> - / / / conform to the given protocol . <nl> - / / / <nl> - / / / Produces a diagnostic on the given typechecker for every var which does not <nl> - / / / conform . Calls a success callback for every var which does conform . <nl> + / / / Returns whether the given variable conforms to the given protocol . <nl> / / / <nl> - / / / \ param tc The typechecker to use in validating { En , Decodable } conformance . <nl> + / / / \ param tc The typechecker to use in validating { En , De } codable conformance . <nl> / / / <nl> / / / \ param context The \ c DeclContext the var declarations belong to . <nl> / / / <nl> - / / / \ param vars The var range to validate . <nl> + / / / \ param varDecl The \ c VarDecl to validate . <nl> / / / <nl> - / / / \ param proto The protocol to check conformance to . <nl> - / / / <nl> - / / / \ param callback A callback to call on every valid var decl . <nl> - template < typename ValidVarCallback > <nl> - static bool <nl> - validateVarsConformToProtocol ( TypeChecker & tc , DeclContext * context , <nl> - NominalTypeDecl : : StoredPropertyRange & vars , <nl> - ProtocolDecl * proto , ValidVarCallback & callback ) { <nl> - bool allConform = true ; <nl> - for ( auto varDecl : vars ) { <nl> - / / If the decl doesn ' t yet have a type , we may be seeing it before the type <nl> - / / checker has gotten around to evaluating its type . For example : <nl> - / / <nl> - / / func foo ( ) { <nl> - / / let b = Bar ( from : decoder ) / / < - evaluates Bar conformance to Codable , <nl> - / / / / forcing derivation <nl> - / / } <nl> - / / <nl> - / / struct Bar : Codable { <nl> - / / var x : Int / / < - we get to valuate x ' s var decl here , but its type <nl> - / / / / hasn ' t yet been evaluated <nl> - / / } <nl> - / / <nl> - / / Validate the decl eagerly . <nl> - if ( ! varDecl - > hasType ( ) ) <nl> - tc . validateDecl ( varDecl ) ; <nl> - <nl> - / / If the var decl didn ' t validate , it may still not have a type ; confirm it <nl> - / / has a type before ensuring the type conforms to Codable . <nl> - if ( ! varDecl - > hasType ( ) | | <nl> - ! tc . conformsToProtocol ( varDecl - > getType ( ) , proto , context , <nl> - ConformanceCheckFlags : : Used ) ) { <nl> - / / TODO : We should produce a diagnostic note here explaining that we found <nl> - / / a var not conforming to Codable . <nl> - allConform = false ; <nl> - continue ; <nl> - } <nl> - <nl> - callback ( varDecl ) ; <nl> - } <nl> - <nl> - return allConform ; <nl> + / / / \ param proto The \ c ProtocolDecl to check conformance to . <nl> + static bool varConformsToProtocol ( TypeChecker & tc , DeclContext * context , <nl> + VarDecl * varDecl , ProtocolDecl * proto ) { <nl> + / / If the decl doesn ' t yet have a type , we may be seeing it before the type <nl> + / / checker has gotten around to evaluating its type . For example : <nl> + / / <nl> + / / func foo ( ) { <nl> + / / let b = Bar ( from : decoder ) / / < - evaluates Bar conformance to Codable , <nl> + / / / / forcing derivation <nl> + / / } <nl> + / / <nl> + / / struct Bar : Codable { <nl> + / / var x : Int / / < - we get to valuate x ' s var decl here , but its type <nl> + / / / / hasn ' t yet been evaluated <nl> + / / } <nl> + / / <nl> + / / Validate the decl eagerly . <nl> + if ( ! varDecl - > hasType ( ) ) <nl> + tc . validateDecl ( varDecl ) ; <nl> + <nl> + / / If the var decl didn ' t validate , it may still not have a type ; confirm it <nl> + / / has a type before ensuring the type conforms to Codable . <nl> + / / TODO : Peer through Optional and collection types to get at inner type . <nl> + return varDecl - > hasType ( ) & & <nl> + tc . conformsToProtocol ( varDecl - > getType ( ) , proto , context , <nl> + ConformanceCheckFlags : : Used ) ; <nl> } <nl> <nl> / / / Validates the given CodingKeys enum decl by ensuring its cases are a 1 - to - 1 <nl> / / / match with the stored vars of the given type . <nl> / / / <nl> - / / / \ param tc The typechecker to use in validating { En , Decodable } conformance . <nl> + / / / \ param tc The typechecker to use in validating { En , De } codable conformance . <nl> / / / <nl> / / / \ param codingKeysDecl The \ c CodingKeys enum decl to validate . <nl> / / / <nl> - / / / \ param type The nominal type decl to validate the \ c CodingKeys against . <nl> + / / / \ param target The nominal type decl to validate the \ c CodingKeys against . <nl> / / / <nl> / / / \ param proto The { En , De } codable protocol to validate all the keys conform <nl> / / / to . <nl> - static bool validateCodingKeysEnum ( TypeChecker & tc , EnumDecl * codingKeysDecl , <nl> - NominalTypeDecl * type , ProtocolDecl * proto ) { <nl> + static bool <nl> + validateCodingKeysEnum ( TypeChecker & tc , EnumDecl * codingKeysDecl , <nl> + NominalTypeDecl * target , ProtocolDecl * proto ) { <nl> / / Look through all var decls in the given type . <nl> / / * Filter out lazy / computed vars ( currently already done by <nl> / / getStoredProperties ) . <nl> static bool validateCodingKeysEnum ( TypeChecker & tc , EnumDecl * codingKeysDecl , <nl> / / <nl> / / If any of the entries in the CodingKeys decl are not present in the type <nl> / / by name , then this decl doesn ' t match . <nl> - / / If there are any vars left in the type , then this decl doesn ' t match . <nl> - / / <nl> - / / NOTE : If we change the behavior to ignore vars with default values , then we <nl> - / / can further filter out the type names to remove those which <nl> - / / correspond to vars with default values . <nl> - llvm : : SmallDenseSet < Identifier , 8 > names ; <nl> - <nl> - auto storedProperties = type - > getStoredProperties ( / * skipInaccessible = * / true ) ; <nl> - auto validVarCallback = [ & names ] ( VarDecl * varDecl ) { <nl> - names . insert ( varDecl - > getName ( ) ) ; <nl> - } ; <nl> - <nl> - if ( ! validateVarsConformToProtocol ( tc , type - > getDeclContext ( ) , <nl> - storedProperties , proto , validVarCallback ) ) <nl> - return false ; <nl> + / / If there are any vars left in the type which don ' t have a default value <nl> + / / ( for Decodable ) , then this decl doesn ' t match . <nl> + <nl> + / / Here we ' ll hold on to properties by name - - when we ' ve validated a property <nl> + / / against its CodingKey entry , it will get removed . <nl> + llvm : : SmallDenseMap < Identifier , VarDecl * , 8 > properties ; <nl> + for ( auto * varDecl : target - > getStoredProperties ( / * skipInaccessible = * / true ) ) { <nl> + properties [ varDecl - > getName ( ) ] = varDecl ; <nl> + } <nl> <nl> + bool propertiesAreValid = true ; <nl> for ( auto elt : codingKeysDecl - > getAllElements ( ) ) { <nl> - auto it = names . find ( elt - > getName ( ) ) ; <nl> - if ( it = = names . end ( ) ) { <nl> - / / TODO : Produce diagnostic here complaining that the CodingKeys enum <nl> - / / contains a case which does not correspond to a var . <nl> + auto it = properties . find ( elt - > getName ( ) ) ; <nl> + if ( it = = properties . end ( ) ) { <nl> + tc . diagnose ( elt - > getLoc ( ) , diag : : codable_extraneous_codingkey_case_here , <nl> + elt - > getName ( ) ) ; <nl> / / TODO : Investigate typo - correction here ; perhaps the case name was <nl> / / misspelled and we can provide a fix - it . <nl> - return false ; <nl> + propertiesAreValid = false ; <nl> + continue ; <nl> + } <nl> + <nl> + / / We have a property to map to . Ensure it ' s { En , De } codable . <nl> + bool conforms = varConformsToProtocol ( tc , target - > getDeclContext ( ) , <nl> + it - > second , proto ) ; <nl> + if ( ! conforms ) { <nl> + tc . diagnose ( it - > second - > getLoc ( ) , <nl> + diag : : codable_non_conforming_property_here , <nl> + proto - > getDeclaredType ( ) , it - > second - > getName ( ) ) ; <nl> + propertiesAreValid = false ; <nl> + continue ; <nl> } <nl> <nl> - names . erase ( it ) ; <nl> + / / The property was valid . Remove it from the list . <nl> + properties . erase ( it ) ; <nl> } <nl> <nl> - / / TODO : Produce diagnostic here complaining that there are vars which are not <nl> - / / listed in the CodingKeys enum . <nl> - return names . empty ( ) ; <nl> + if ( ! propertiesAreValid ) <nl> + return false ; <nl> + <nl> + / / If there are any remaining properties which the CodingKeys did not cover , <nl> + / / we can skip them on encode . On decode , though , we can only skip them if <nl> + / / they have a default value . <nl> + if ( ! properties . empty ( ) & & <nl> + proto = = tc . Context . getProtocol ( KnownProtocolKind : : Decodable ) ) { <nl> + for ( auto it = properties . begin ( ) ; it ! = properties . end ( ) ; + + it ) { <nl> + if ( it - > second - > getParentInitializer ( ) ! = nullptr ) { <nl> + / / Var has a default value . <nl> + continue ; <nl> + } <nl> + <nl> + propertiesAreValid = false ; <nl> + tc . diagnose ( it - > second - > getLoc ( ) , diag : : codable_non_decoded_property_here , <nl> + proto - > getDeclaredType ( ) , it - > first ) ; <nl> + } <nl> + } <nl> + <nl> + return propertiesAreValid ; <nl> } <nl> <nl> / / / Returns whether the given type has a valid nested \ c CodingKeys enum . <nl> static bool validateCodingKeysEnum ( TypeChecker & tc , EnumDecl * codingKeysDecl , <nl> / / / <nl> / / / \ param tc The typechecker to use in validating { En , Decodable } conformance . <nl> / / / <nl> - / / / \ param type The type decl whose nested \ c CodingKeys type to validate . <nl> + / / / \ param target The type decl whose nested \ c CodingKeys type to validate . <nl> / / / <nl> / / / \ param proto The { En , De } codable protocol to ensure the properties matching <nl> / / / the keys conform to . <nl> static std : : pair < / * has type ? * / bool , / * error ? * / bool > <nl> - hasValidCodingKeysEnum ( TypeChecker & tc , NominalTypeDecl * type , <nl> + hasValidCodingKeysEnum ( TypeChecker & tc , NominalTypeDecl * target , <nl> ProtocolDecl * proto ) { <nl> auto & C = tc . Context ; <nl> - auto codingKeysDecls = type - > lookupDirect ( DeclName ( C . Id_CodingKeys ) ) ; <nl> + auto codingKeysDecls = target - > lookupDirect ( DeclName ( C . Id_CodingKeys ) ) ; <nl> if ( codingKeysDecls . empty ( ) ) <nl> return { / * has type ? * / false , / * error ? * / false } ; <nl> <nl> hasValidCodingKeysEnum ( TypeChecker & tc , NominalTypeDecl * type , <nl> <nl> auto * codingKeysTypeDecl = dyn_cast < TypeDecl > ( result ) ; <nl> if ( ! codingKeysTypeDecl ) { <nl> - / / TODO : Produce a diagnostic complaining that the " CodingKeys " entity we <nl> - / / found is not a type . <nl> + tc . diagnose ( result - > getLoc ( ) , <nl> + diag : : codable_codingkeys_type_is_not_an_enum_here , <nl> + proto - > getDeclaredType ( ) ) ; <nl> return { / * has type ? * / true , / * error ? * / true } ; <nl> } <nl> <nl> + / / CodingKeys may be a typealias . If so , follow the alias to its canonical <nl> + / / type . <nl> + auto codingKeysType = codingKeysTypeDecl - > getDeclaredInterfaceType ( ) ; <nl> + if ( isa < TypeAliasDecl > ( codingKeysTypeDecl ) ) { <nl> + auto canType = codingKeysType - > getCanonicalType ( ) ; <nl> + assert ( canType ) ; <nl> + codingKeysTypeDecl = canType - > getAnyNominal ( ) ; <nl> + } <nl> + <nl> / / Ensure that the type we found conforms to the CodingKey protocol . <nl> auto * codingKeyProto = C . getProtocol ( KnownProtocolKind : : CodingKey ) ; <nl> - auto codingKeysType = codingKeysTypeDecl - > getDeclaredInterfaceType ( ) ; <nl> if ( ! tc . conformsToProtocol ( codingKeysType , codingKeyProto , <nl> - type - > getDeclContext ( ) , <nl> + target - > getDeclContext ( ) , <nl> ConformanceCheckFlags : : Used ) ) { <nl> - / / TODO : Produce a diagnostic complaining that the " CodingKeys " entity we <nl> - / / found does not conform to CodingKey . <nl> + tc . diagnose ( codingKeysTypeDecl - > getLoc ( ) , <nl> + diag : : codable_codingkeys_type_does_not_conform_here , <nl> + proto - > getDeclaredType ( ) ) ; <nl> return { / * has type ? * / true , / * error ? * / true } ; <nl> } <nl> <nl> - / / CodingKeys should eventually be an enum . If it ' s a typealias , we ' ll need to <nl> - / / follow it . <nl> - auto * codingKeysEnum = dyn_cast < EnumDecl > ( result ) ; <nl> - if ( isa < TypeAliasDecl > ( result ) ) { <nl> - / / TODO : Do we have to follow through multiple layers of typealiases <nl> - / / here ? Or will getCanonicalType ( ) do that for us ? <nl> - auto canType = codingKeysType - > getCanonicalType ( ) ; <nl> - assert ( canType ) ; <nl> - <nl> - codingKeysEnum = dyn_cast < EnumDecl > ( codingKeysType - > getAnyNominal ( ) ) ; <nl> - } <nl> - <nl> + / / CodingKeys must be an enum for synthesized conformance . <nl> + auto * codingKeysEnum = dyn_cast < EnumDecl > ( codingKeysTypeDecl ) ; <nl> if ( ! codingKeysEnum ) { <nl> - / / TODO : Produce a diagnostic complaining that we cannot derive Codable <nl> - / / with a non - enum CodingKeys type . <nl> + tc . diagnose ( codingKeysTypeDecl - > getLoc ( ) , <nl> + diag : : codable_codingkeys_type_is_not_an_enum_here , <nl> + proto - > getDeclaredType ( ) ) ; <nl> return { / * has type ? * / true , / * error ? * / true } ; <nl> } <nl> <nl> - bool valid = validateCodingKeysEnum ( tc , codingKeysEnum , type , proto ) ; <nl> + bool valid = validateCodingKeysEnum ( tc , codingKeysEnum , target , proto ) ; <nl> return { / * has type ? * / true , / * error ? * / ! valid } ; <nl> } <nl> <nl> hasValidCodingKeysEnum ( TypeChecker & tc , NominalTypeDecl * type , <nl> / / / <nl> / / / \ param tc The typechecker to use in validating { En , De } codable conformance . <nl> / / / <nl> - / / / \ param type The nominal type decl whose nested \ c CodingKeys type to <nl> + / / / \ param target The nominal type decl whose nested \ c CodingKeys type to <nl> / / / synthesize . <nl> / / / <nl> / / / \ param proto The { En , De } codable protocol to validate all the keys conform <nl> / / / to . <nl> static EnumDecl * synthesizeCodingKeysEnum ( TypeChecker & tc , <nl> - NominalTypeDecl * type , <nl> + NominalTypeDecl * target , <nl> ProtocolDecl * proto ) { <nl> auto & C = tc . Context ; <nl> - auto * typeDC = cast < DeclContext > ( type ) ; <nl> + auto * targetDC = cast < DeclContext > ( target ) ; <nl> <nl> / / We want to look through all the var declarations of this type to create <nl> / / enum cases based on those var names . <nl> static EnumDecl * synthesizeCodingKeysEnum ( TypeChecker & tc , <nl> MutableArrayRef < TypeLoc > inherited = C . AllocateCopy ( protoTypeLoc ) ; <nl> <nl> auto * enumDecl = new ( C ) EnumDecl ( SourceLoc ( ) , C . Id_CodingKeys , SourceLoc ( ) , <nl> - inherited , nullptr , typeDC ) ; <nl> + inherited , nullptr , targetDC ) ; <nl> enumDecl - > setImplicit ( ) ; <nl> enumDecl - > setAccessibility ( Accessibility : : Private ) ; <nl> <nl> static EnumDecl * synthesizeCodingKeysEnum ( TypeChecker & tc , <nl> <nl> / / For classes which inherit from something Encodable or Decodable , we <nl> / / provide case ` super ` as the first key ( to be used in encoding super ) . <nl> - auto * classDecl = dyn_cast < ClassDecl > ( type ) ; <nl> + auto * classDecl = dyn_cast < ClassDecl > ( target ) ; <nl> if ( classDecl & & <nl> ( superclassIsEncodable ( classDecl ) | | superclassIsDecodable ( classDecl ) ) ) { <nl> / / TODO : Ensure the class doesn ' t already have or inherit a variable named <nl> static EnumDecl * synthesizeCodingKeysEnum ( TypeChecker & tc , <nl> <nl> / / Each of these vars needs a case in the enum . For each var decl , if the type <nl> / / conforms to { En , De } codable , add it to the enum . <nl> - auto storedProperties = type - > getStoredProperties ( / * skipInaccessible = * / true ) ; <nl> - auto validVarCallback = [ & C , & enumDC , & mutableEnumDC ] ( VarDecl * varDecl ) { <nl> + bool allConform = true ; <nl> + for ( auto * varDecl : target - > getStoredProperties ( / * skipInaccessible = * / true ) ) { <nl> + if ( ! varConformsToProtocol ( tc , target - > getDeclContext ( ) , varDecl , proto ) ) { <nl> + tc . diagnose ( varDecl - > getLoc ( ) , <nl> + diag : : codable_non_conforming_property_here , <nl> + proto - > getDeclaredType ( ) , varDecl - > getName ( ) ) ; <nl> + allConform = false ; <nl> + continue ; <nl> + } <nl> + <nl> auto * elt = new ( C ) EnumElementDecl ( SourceLoc ( ) , varDecl - > getName ( ) , <nl> TypeLoc ( ) , / * HasArgumentType = * / false , <nl> SourceLoc ( ) , nullptr , enumDC ) ; <nl> elt - > setImplicit ( ) ; <nl> mutableEnumDC - > addMember ( elt ) ; <nl> - } ; <nl> + } <nl> <nl> - if ( ! validateVarsConformToProtocol ( tc , type - > getDeclContext ( ) , <nl> - storedProperties , proto , validVarCallback ) ) <nl> + if ( ! allConform ) <nl> return nullptr ; <nl> <nl> / / Forcibly derive conformance to CodingKey . <nl> tc . checkConformancesInContext ( enumDC , mutableEnumDC ) ; <nl> <nl> / / Add to the type . <nl> - cast < IterableDeclContext > ( type ) - > addMember ( enumDecl ) ; <nl> + cast < IterableDeclContext > ( target ) - > addMember ( enumDecl ) ; <nl> return enumDecl ; <nl> } <nl> <nl> + / / / Fetches the \ c CodingKeys enum nested in \ c target , potentially reaching <nl> + / / / through a typealias if the " CodingKeys " entity is a typealias . <nl> + / / / <nl> + / / / This is only useful once a \ c CodingKeys enum has been validated ( via \ c <nl> + / / / hasValidCodingKeysEnum ) or synthesized ( via \ c synthesizeCodingKeysEnum ) . <nl> + / / / <nl> + / / / \ param C The \ c ASTContext to perform the lookup in . <nl> + / / / <nl> + / / / \ param target The target type to look in . <nl> + / / / <nl> + / / / \ return A retrieved canonical \ c CodingKeys enum if \ c target has a valid <nl> + / / / one ; \ c nullptr otherwise . <nl> + static EnumDecl * lookupEvaluatedCodingKeysEnum ( ASTContext & C , <nl> + NominalTypeDecl * target ) { <nl> + auto codingKeyDecls = target - > lookupDirect ( DeclName ( C . Id_CodingKeys ) ) ; <nl> + if ( codingKeyDecls . empty ( ) ) <nl> + return nullptr ; <nl> + <nl> + auto * codingKeysDecl = codingKeyDecls . front ( ) ; <nl> + if ( auto * typealiasDecl = dyn_cast < TypeAliasDecl > ( codingKeysDecl ) ) { <nl> + codingKeysDecl = typealiasDecl - > getDeclaredInterfaceType ( ) <nl> + - > getCanonicalType ( ) - > getAnyNominal ( ) ; <nl> + } <nl> + <nl> + return dyn_cast < EnumDecl > ( codingKeysDecl ) ; <nl> + } <nl> + <nl> / / / Creates a new var decl representing <nl> / / / <nl> / / / var / let container : containerBase < keyType > <nl> static void deriveBodyEncodable_encode ( AbstractFunctionDecl * encodeDecl ) { <nl> / / } <nl> <nl> / / The enclosing type decl . <nl> - auto * typeDecl = cast < NominalTypeDecl > ( encodeDecl - > getDeclContext ( ) ) ; <nl> + auto * targetDecl = cast < NominalTypeDecl > ( encodeDecl - > getDeclContext ( ) ) ; <nl> <nl> auto * funcDC = cast < DeclContext > ( encodeDecl ) ; <nl> auto & C = funcDC - > getASTContext ( ) ; <nl> <nl> - / / We ' ll want the CodingKeys enum for this type . <nl> - auto * codingKeysDecl = typeDecl - > lookupDirect ( DeclName ( C . Id_CodingKeys ) ) [ 0 ] ; <nl> + / / We ' ll want the CodingKeys enum for this type , potentially looking through <nl> + / / a typealias . <nl> + auto * codingKeysEnum = lookupEvaluatedCodingKeysEnum ( C , targetDecl ) ; <nl> / / We should have bailed already if : <nl> / / a ) The type does not have CodingKeys <nl> - assert ( codingKeysDecl & & " Missing CodingKeys decl . " ) ; <nl> / / b ) The type is not an enum <nl> - auto * codingKeysEnum = cast < EnumDecl > ( codingKeysDecl ) ; <nl> + assert ( codingKeysEnum & & " Missing CodingKeys decl . " ) ; <nl> <nl> SmallVector < ASTNode , 5 > statements ; <nl> <nl> static void deriveBodyEncodable_encode ( AbstractFunctionDecl * encodeDecl ) { <nl> / / Only ill - formed code would produce multiple results for this lookup . <nl> / / This would get diagnosed later anyway , so we ' re free to only look at <nl> / / the first result here . <nl> - auto matchingVars = typeDecl - > lookupDirect ( DeclName ( elt - > getName ( ) ) ) ; <nl> + auto matchingVars = targetDecl - > lookupDirect ( DeclName ( elt - > getName ( ) ) ) ; <nl> <nl> / / self . x <nl> auto * selfRef = createSelfDeclRef ( encodeDecl ) ; <nl> static void deriveBodyEncodable_encode ( AbstractFunctionDecl * encodeDecl ) { <nl> } <nl> <nl> / / Classes which inherit from something Codable should encode super as well . <nl> - auto * classDecl = dyn_cast < ClassDecl > ( typeDecl ) ; <nl> + auto * classDecl = dyn_cast < ClassDecl > ( targetDecl ) ; <nl> if ( classDecl & & superclassIsEncodable ( classDecl ) ) { <nl> / / Need to generate ` try super . encode ( to : container . superEncoder ( ) ) ` <nl> <nl> static void deriveBodyEncodable_encode ( AbstractFunctionDecl * encodeDecl ) { <nl> / / / <nl> / / / \ param parentDecl The parent declaration of the type . <nl> / / / <nl> - / / / \ param type The nominal type to synthesize the function for . <nl> + / / / \ param target The nominal type to synthesize the function for . <nl> static FuncDecl * deriveEncodable_encode ( TypeChecker & tc , Decl * parentDecl , <nl> - NominalTypeDecl * type ) { <nl> + NominalTypeDecl * target ) { <nl> auto & C = tc . Context ; <nl> - auto * typeDC = cast < DeclContext > ( type ) ; <nl> + auto * targetDC = cast < DeclContext > ( target ) ; <nl> <nl> / / Expected type : ( Self ) - > ( Encoder ) throws - > ( ) <nl> / / Constructed as : func type <nl> static FuncDecl * deriveEncodable_encode ( TypeChecker & tc , Decl * parentDecl , <nl> auto innerType = FunctionType : : get ( inputType , returnType , extInfo ) ; <nl> <nl> / / Params : ( self [ implicit ] , Encoder ) <nl> - auto * selfDecl = ParamDecl : : createSelf ( SourceLoc ( ) , typeDC ) ; <nl> + auto * selfDecl = ParamDecl : : createSelf ( SourceLoc ( ) , targetDC ) ; <nl> auto * encoderParam = new ( C ) ParamDecl ( / * isLet = * / true , SourceLoc ( ) , <nl> SourceLoc ( ) , C . Id_to , SourceLoc ( ) , <nl> - C . Id_encoder , encoderType , typeDC ) ; <nl> + C . Id_encoder , encoderType , targetDC ) ; <nl> encoderParam - > setInterfaceType ( encoderType ) ; <nl> <nl> ParameterList * params [ ] = { ParameterList : : createWithoutLoc ( selfDecl ) , <nl> static FuncDecl * deriveEncodable_encode ( TypeChecker & tc , Decl * parentDecl , <nl> SourceLoc ( ) , name , SourceLoc ( ) , <nl> / * Throws = * / true , SourceLoc ( ) , SourceLoc ( ) , <nl> nullptr , params , <nl> - TypeLoc : : withoutLoc ( returnType ) , typeDC ) ; <nl> + TypeLoc : : withoutLoc ( returnType ) , <nl> + targetDC ) ; <nl> encodeDecl - > setImplicit ( ) ; <nl> encodeDecl - > setBodySynthesizer ( deriveBodyEncodable_encode ) ; <nl> <nl> / / This method should be marked as ' override ' for classes inheriting Encodable <nl> / / conformance from a parent class . <nl> - auto * classDecl = dyn_cast < ClassDecl > ( type ) ; <nl> + auto * classDecl = dyn_cast < ClassDecl > ( target ) ; <nl> if ( classDecl & & superclassIsEncodable ( classDecl ) ) { <nl> auto * attr = new ( C ) SimpleDeclAttr < DAK_Override > ( / * IsImplicit = * / true ) ; <nl> encodeDecl - > getAttrs ( ) . add ( attr ) ; <nl> } <nl> <nl> / / Evaluate the type of Self in ( Self ) - > ( Encoder ) throws - > ( ) . <nl> - Type selfType = typeDC - > getDeclaredInterfaceType ( ) ; <nl> + Type selfType = targetDC - > getDeclaredInterfaceType ( ) ; <nl> Type interfaceType ; <nl> - if ( auto sig = typeDC - > getGenericSignatureOfContext ( ) ) { <nl> + if ( auto sig = targetDC - > getGenericSignatureOfContext ( ) ) { <nl> / / Evaluate the below , but in a generic environment ( if Self is generic ) . <nl> - encodeDecl - > setGenericEnvironment ( typeDC - > getGenericEnvironmentOfContext ( ) ) ; <nl> + encodeDecl - > setGenericEnvironment ( <nl> + targetDC - > getGenericEnvironmentOfContext ( ) ) ; <nl> interfaceType = GenericFunctionType : : get ( sig , selfType , innerType , <nl> FunctionType : : ExtInfo ( ) ) ; <nl> } else { <nl> static FuncDecl * deriveEncodable_encode ( TypeChecker & tc , Decl * parentDecl , <nl> } <nl> <nl> encodeDecl - > setInterfaceType ( interfaceType ) ; <nl> - encodeDecl - > setAccessibility ( std : : max ( type - > getFormalAccess ( ) , <nl> + encodeDecl - > setAccessibility ( std : : max ( target - > getFormalAccess ( ) , <nl> Accessibility : : Internal ) ) ; <nl> <nl> / / If the type was not imported , the derived conformance is either from the <nl> / / type itself or an extension , in which case we will emit the declaration <nl> / / normally . <nl> - if ( type - > hasClangNode ( ) ) <nl> + if ( target - > hasClangNode ( ) ) <nl> tc . Context . addExternalDecl ( encodeDecl ) ; <nl> <nl> - cast < IterableDeclContext > ( type ) - > addMember ( encodeDecl ) ; <nl> + cast < IterableDeclContext > ( target ) - > addMember ( encodeDecl ) ; <nl> return encodeDecl ; <nl> } <nl> <nl> static void deriveBodyDecodable_init ( AbstractFunctionDecl * initDecl ) { <nl> / / } <nl> <nl> / / The enclosing type decl . <nl> - auto * typeDecl = cast < NominalTypeDecl > ( initDecl - > getDeclContext ( ) ) ; <nl> + auto * targetDecl = cast < NominalTypeDecl > ( initDecl - > getDeclContext ( ) ) ; <nl> <nl> auto * funcDC = cast < DeclContext > ( initDecl ) ; <nl> auto & C = funcDC - > getASTContext ( ) ; <nl> <nl> - / / We ' ll want the CodingKeys enum for this type . <nl> - auto * codingKeysDecl = typeDecl - > lookupDirect ( DeclName ( C . Id_CodingKeys ) ) [ 0 ] ; <nl> + / / We ' ll want the CodingKeys enum for this type , potentially looking through <nl> + / / a typealias . <nl> + auto * codingKeysEnum = lookupEvaluatedCodingKeysEnum ( C , targetDecl ) ; <nl> / / We should have bailed already if : <nl> / / a ) The type does not have CodingKeys <nl> - assert ( codingKeysDecl & & " Missing CodingKeys decl . " ) ; <nl> / / b ) The type is not an enum <nl> - auto * codingKeysEnum = cast < EnumDecl > ( codingKeysDecl ) ; <nl> + assert ( codingKeysEnum & & " Missing CodingKeys decl . " ) ; <nl> <nl> / / Generate a reference to containerExpr ahead of time in case there are no <nl> / / properties to encode or decode , but the type is a class which inherits from <nl> static void deriveBodyDecodable_init ( AbstractFunctionDecl * initDecl ) { <nl> / / Only ill - formed code would produce multiple results for this lookup . <nl> / / This would get diagnosed later anyway , so we ' re free to only look at <nl> / / the first result here . <nl> - auto matchingVars = typeDecl - > lookupDirect ( DeclName ( elt - > getName ( ) ) ) ; <nl> + auto matchingVars = targetDecl - > lookupDirect ( DeclName ( elt - > getName ( ) ) ) ; <nl> auto * varDecl = cast < VarDecl > ( matchingVars [ 0 ] ) ; <nl> <nl> / / Don ' t output a decode statement for a var let with a default value . <nl> static void deriveBodyDecodable_init ( AbstractFunctionDecl * initDecl ) { <nl> / / Type . self ( where Type = = = type ( of : x ) <nl> auto varType = varDecl - > getType ( ) ; <nl> auto * metaTyRef = TypeExpr : : createImplicit ( varType , C ) ; <nl> - auto * typeExpr = new ( C ) DotSelfExpr ( metaTyRef , SourceLoc ( ) , SourceLoc ( ) , <nl> - varType ) ; <nl> + auto * targetExpr = new ( C ) DotSelfExpr ( metaTyRef , SourceLoc ( ) , <nl> + SourceLoc ( ) , varType ) ; <nl> <nl> / / CodingKeys . x <nl> auto * eltRef = new ( C ) DeclRefExpr ( elt , DeclNameLoc ( ) , / * implicit = * / true ) ; <nl> static void deriveBodyDecodable_init ( AbstractFunctionDecl * initDecl ) { <nl> / * Implicit = * / true ) ; <nl> <nl> / / container . decode ( Type . self , forKey : CodingKeys . x ) <nl> - Expr * args [ 2 ] = { typeExpr , keyExpr } ; <nl> + Expr * args [ 2 ] = { targetExpr , keyExpr } ; <nl> auto * callExpr = CallExpr : : createImplicit ( C , decodeCall , <nl> C . AllocateCopy ( args ) , <nl> C . AllocateCopy ( argNames ) ) ; <nl> static void deriveBodyDecodable_init ( AbstractFunctionDecl * initDecl ) { <nl> } <nl> <nl> / / Classes which inherit from something Decodable should decode super as well . <nl> - auto * classDecl = dyn_cast < ClassDecl > ( typeDecl ) ; <nl> + auto * classDecl = dyn_cast < ClassDecl > ( targetDecl ) ; <nl> if ( classDecl & & superclassIsDecodable ( classDecl ) ) { <nl> / / Need to generate ` try super . init ( from : container . superDecoder ( ) ) ` <nl> <nl> static void deriveBodyDecodable_init ( AbstractFunctionDecl * initDecl ) { <nl> / / / <nl> / / / \ param parentDecl The parent declaration of the type . <nl> / / / <nl> - / / / \ param type The nominal type to synthesize the function for . <nl> + / / / \ param target The nominal type to synthesize the function for . <nl> static ValueDecl * deriveDecodable_init ( TypeChecker & tc , Decl * parentDecl , <nl> - NominalTypeDecl * type ) { <nl> + NominalTypeDecl * target ) { <nl> auto & C = tc . Context ; <nl> - auto * typeDC = cast < DeclContext > ( type ) ; <nl> + auto * targetDC = cast < DeclContext > ( target ) ; <nl> <nl> / / Expected type : ( Self ) - > ( Decoder ) throws - > ( Self ) <nl> / / Constructed as : func type <nl> static ValueDecl * deriveDecodable_init ( TypeChecker & tc , Decl * parentDecl , <nl> / * Throws = * / true ) ; <nl> <nl> / / ( Self ) <nl> - auto returnType = typeDC - > getDeclaredInterfaceType ( ) ; <nl> + auto returnType = targetDC - > getDeclaredInterfaceType ( ) ; <nl> <nl> / / ( from : Decoder ) throws - > ( Self ) <nl> Type innerType = FunctionType : : get ( inputType , returnType , extInfo ) ; <nl> <nl> / / Params : ( self [ implicit ] , Decoder ) <nl> / / self should be inout if the type is a value type ; not inout otherwise . <nl> - auto inOut = ! isa < ClassDecl > ( type ) ; <nl> - auto * selfDecl = ParamDecl : : createSelf ( SourceLoc ( ) , typeDC , <nl> + auto inOut = ! isa < ClassDecl > ( target ) ; <nl> + auto * selfDecl = ParamDecl : : createSelf ( SourceLoc ( ) , targetDC , <nl> / * isStatic = * / false , <nl> / * isInOut = * / inOut ) ; <nl> auto * decoderParamDecl = new ( C ) ParamDecl ( / * isLet = * / true , SourceLoc ( ) , <nl> SourceLoc ( ) , C . Id_from , <nl> SourceLoc ( ) , C . Id_decoder , <nl> - decoderType , typeDC ) ; <nl> + decoderType , targetDC ) ; <nl> decoderParamDecl - > setImplicit ( ) ; <nl> decoderParamDecl - > setInterfaceType ( decoderType ) ; <nl> <nl> static ValueDecl * deriveDecodable_init ( TypeChecker & tc , Decl * parentDecl , <nl> / * Failability = * / OTK_None , <nl> / * FailabilityLoc = * / SourceLoc ( ) , <nl> / * Throws = * / true , / * ThrowsLoc = * / SourceLoc ( ) , selfDecl , paramList , <nl> - / * GenericParams = * / nullptr , typeDC ) ; <nl> + / * GenericParams = * / nullptr , targetDC ) ; <nl> initDecl - > setImplicit ( ) ; <nl> initDecl - > setBodySynthesizer ( deriveBodyDecodable_init ) ; <nl> <nl> / / This constructor should be marked as ` required ` for non - final classes . <nl> - if ( isa < ClassDecl > ( type ) & & ! type - > getAttrs ( ) . hasAttribute < FinalAttr > ( ) ) { <nl> + if ( isa < ClassDecl > ( target ) & & ! target - > getAttrs ( ) . hasAttribute < FinalAttr > ( ) ) { <nl> auto * reqAttr = new ( C ) SimpleDeclAttr < DAK_Required > ( / * IsImplicit = * / true ) ; <nl> initDecl - > getAttrs ( ) . add ( reqAttr ) ; <nl> } <nl> static ValueDecl * deriveDecodable_init ( TypeChecker & tc , Decl * parentDecl , <nl> Type selfInitType = initDecl - > computeInterfaceSelfType ( / * init = * / true ) ; <nl> Type interfaceType ; <nl> Type initializerType ; <nl> - if ( auto sig = typeDC - > getGenericSignatureOfContext ( ) ) { <nl> + if ( auto sig = targetDC - > getGenericSignatureOfContext ( ) ) { <nl> / / Evaluate the below , but in a generic environment ( if Self is generic ) . <nl> - initDecl - > setGenericEnvironment ( typeDC - > getGenericEnvironmentOfContext ( ) ) ; <nl> + initDecl - > setGenericEnvironment ( targetDC - > getGenericEnvironmentOfContext ( ) ) ; <nl> interfaceType = GenericFunctionType : : get ( sig , selfType , innerType , <nl> FunctionType : : ExtInfo ( ) ) ; <nl> initializerType = GenericFunctionType : : get ( sig , selfInitType , innerType , <nl> static ValueDecl * deriveDecodable_init ( TypeChecker & tc , Decl * parentDecl , <nl> initDecl - > setInterfaceType ( interfaceType ) ; <nl> initDecl - > setInitializerInterfaceType ( initializerType ) ; <nl> initDecl - > setAccessibility ( <nl> - std : : max ( type - > getFormalAccess ( ) , Accessibility : : Internal ) ) ; <nl> + std : : max ( target - > getFormalAccess ( ) , Accessibility : : Internal ) ) ; <nl> <nl> / / If the type was not imported , the derived conformance is either from the <nl> / / type itself or an extension , in which case we will emit the declaration <nl> / / normally . <nl> - if ( type - > hasClangNode ( ) ) <nl> + if ( target - > hasClangNode ( ) ) <nl> tc . Context . addExternalDecl ( initDecl ) ; <nl> <nl> - cast < IterableDeclContext > ( type ) - > addMember ( initDecl ) ; <nl> + cast < IterableDeclContext > ( target ) - > addMember ( initDecl ) ; <nl> return initDecl ; <nl> } <nl> <nl> static ValueDecl * deriveDecodable_init ( TypeChecker & tc , Decl * parentDecl , <nl> / / / <nl> / / / \ param tc The typechecker to use in validating { En , Decodable } conformance . <nl> / / / <nl> - / / / \ param type The type to validate . <nl> + / / / \ param target The type to validate . <nl> / / / <nl> / / / \ param proto The * codable protocol to check for validity . <nl> - static bool canSynthesize ( TypeChecker & tc , NominalTypeDecl * type , <nl> + static bool canSynthesize ( TypeChecker & tc , NominalTypeDecl * target , <nl> ProtocolDecl * proto ) { <nl> / / First , look up if the type has a valid CodingKeys enum we can use . <nl> bool hasType , error ; <nl> - std : : tie ( hasType , error ) = hasValidCodingKeysEnum ( tc , type , proto ) ; <nl> + std : : tie ( hasType , error ) = hasValidCodingKeysEnum ( tc , target , proto ) ; <nl> <nl> / / We found a type , but it wasn ' t valid . <nl> if ( error ) <nl> static bool canSynthesize ( TypeChecker & tc , NominalTypeDecl * type , <nl> <nl> / / We can try to synthesize a type here . <nl> if ( ! hasType ) { <nl> - auto * synthesizedEnum = synthesizeCodingKeysEnum ( tc , type , proto ) ; <nl> + auto * synthesizedEnum = synthesizeCodingKeysEnum ( tc , target , proto ) ; <nl> if ( ! synthesizedEnum ) <nl> return false ; <nl> } <nl> static bool canSynthesize ( TypeChecker & tc , NominalTypeDecl * type , <nl> <nl> ValueDecl * DerivedConformance : : deriveEncodable ( TypeChecker & tc , <nl> Decl * parentDecl , <nl> - NominalTypeDecl * type , <nl> + NominalTypeDecl * target , <nl> ValueDecl * requirement ) { <nl> / / We can only synthesize Encodable for structs and classes . <nl> - if ( ! isa < StructDecl > ( type ) & & ! isa < ClassDecl > ( type ) ) <nl> + if ( ! isa < StructDecl > ( target ) & & ! isa < ClassDecl > ( target ) ) <nl> return nullptr ; <nl> <nl> if ( requirement - > getName ( ) ! = tc . Context . Id_encode ) { <nl> ValueDecl * DerivedConformance : : deriveEncodable ( TypeChecker & tc , <nl> return nullptr ; <nl> } <nl> <nl> + / / Conformance can ' t be synthesized in an extension . <nl> + auto encodableProto = tc . Context . getProtocol ( KnownProtocolKind : : Encodable ) ; <nl> + auto encodableType = encodableProto - > getDeclaredType ( ) ; <nl> + if ( target ! = parentDecl ) { <nl> + tc . diagnose ( parentDecl - > getLoc ( ) , diag : : cannot_synthesize_in_extension , <nl> + encodableType ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> / / Check other preconditions for synthesized conformance . <nl> / / This synthesizes a CodingKeys enum if possible . <nl> - auto encodableProto = tc . Context . getProtocol ( KnownProtocolKind : : Encodable ) ; <nl> - if ( canSynthesize ( tc , type , encodableProto ) ) <nl> - return deriveEncodable_encode ( tc , parentDecl , type ) ; <nl> + if ( canSynthesize ( tc , target , encodableProto ) ) <nl> + return deriveEncodable_encode ( tc , parentDecl , target ) ; <nl> <nl> / / Known protocol requirement but could not synthesize . <nl> / / FIXME : We have to output at least one error diagnostic here because we <nl> / / returned true from NominalTypeDecl : : derivesProtocolConformance ; if we <nl> / / don ' t , we expect to return a witness here later and crash on an <nl> / / assertion . Producing an error stops compilation before then . <nl> - auto encodableType = encodableProto - > getDeclaredType ( ) ; <nl> - tc . diagnose ( type , diag : : type_does_not_conform , type - > getDeclaredType ( ) , <nl> + tc . diagnose ( target , diag : : type_does_not_conform , target - > getDeclaredType ( ) , <nl> encodableType ) ; <nl> tc . diagnose ( requirement , diag : : no_witnesses , diag : : RequirementKind : : Func , <nl> requirement - > getFullName ( ) , encodableType , / * AddFixIt = * / false ) ; <nl> ValueDecl * DerivedConformance : : deriveEncodable ( TypeChecker & tc , <nl> <nl> ValueDecl * DerivedConformance : : deriveDecodable ( TypeChecker & tc , <nl> Decl * parentDecl , <nl> - NominalTypeDecl * type , <nl> + NominalTypeDecl * target , <nl> ValueDecl * requirement ) { <nl> / / We can only synthesize Encodable for structs and classes . <nl> - if ( ! isa < StructDecl > ( type ) & & ! isa < ClassDecl > ( type ) ) <nl> + if ( ! isa < StructDecl > ( target ) & & ! isa < ClassDecl > ( target ) ) <nl> return nullptr ; <nl> <nl> if ( requirement - > getName ( ) ! = tc . Context . Id_init ) { <nl> ValueDecl * DerivedConformance : : deriveDecodable ( TypeChecker & tc , <nl> return nullptr ; <nl> } <nl> <nl> + / / Conformance can ' t be synthesized in an extension . <nl> + auto decodableProto = tc . Context . getProtocol ( KnownProtocolKind : : Decodable ) ; <nl> + auto decodableType = decodableProto - > getDeclaredType ( ) ; <nl> + if ( target ! = parentDecl ) { <nl> + tc . diagnose ( parentDecl - > getLoc ( ) , diag : : cannot_synthesize_in_extension , <nl> + decodableType ) ; <nl> + return nullptr ; <nl> + } <nl> + <nl> / / Check other preconditions for synthesized conformance . <nl> / / This synthesizes a CodingKeys enum if possible . <nl> - auto decodableProto = tc . Context . getProtocol ( KnownProtocolKind : : Decodable ) ; <nl> - if ( canSynthesize ( tc , type , decodableProto ) ) <nl> - return deriveDecodable_init ( tc , parentDecl , type ) ; <nl> + if ( canSynthesize ( tc , target , decodableProto ) ) <nl> + return deriveDecodable_init ( tc , parentDecl , target ) ; <nl> <nl> / / Known protocol requirement but could not synthesize . <nl> / / FIXME : We have to output at least one error diagnostic here because we <nl> / / returned true from NominalTypeDecl : : derivesProtocolConformance ; if we <nl> / / don ' t , we expect to return a witness here later and crash on an <nl> / / assertion . Producing an error stops compilation before then . <nl> - auto decodableType = decodableProto - > getDeclaredType ( ) ; <nl> - tc . diagnose ( type , diag : : type_does_not_conform , type - > getDeclaredType ( ) , <nl> + tc . diagnose ( target , diag : : type_does_not_conform , target - > getDeclaredType ( ) , <nl> decodableType ) ; <nl> tc . diagnose ( requirement , diag : : no_witnesses , <nl> diag : : RequirementKind : : Constructor , requirement - > getFullName ( ) , <nl> new file mode 100644 <nl> index 000000000000 . . 04380efefda0 <nl> mmm / dev / null <nl> ppp b / test / decl / protocol / special / coding / class_codable_codingkeys_typealias . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift - verify - ignore - unknown <nl> + <nl> + / / Simple classes with all Codable properties whose CodingKeys come from a <nl> + / / typealias should get derived conformance to Codable . <nl> + class SimpleClass : Codable { <nl> + var x : Int = 1 <nl> + var y : Double = . pi <nl> + static var z : String = " foo " <nl> + <nl> + private typealias CodingKeys = A / / expected - note { { ' CodingKeys ' declared here } } <nl> + private typealias A = B <nl> + private typealias B = C <nl> + private typealias C = MyRealCodingKeys <nl> + <nl> + private enum MyRealCodingKeys : String , CodingKey { <nl> + case x <nl> + case y <nl> + } <nl> + } <nl> + <nl> + / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> + let _ = SimpleClass . init ( from : ) <nl> + let _ = SimpleClass . encode ( to : ) <nl> + <nl> + / / The synthesized CodingKeys type should not be accessible from outside the <nl> + / / class . <nl> + let _ = SimpleClass . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> mmm a / test / decl / protocol / special / coding / class_codable_computed_vars . swift <nl> ppp b / test / decl / protocol / special / coding / class_codable_computed_vars . swift <nl> class ClassWithComputedMembers : Codable { <nl> } <nl> } <nl> <nl> - / / These are wrapped in a dummy function to avoid binding a global variable . <nl> - func foo ( ) { <nl> - / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> - let _ = ClassWithComputedMembers . init ( from : ) <nl> - let _ = ClassWithComputedMembers . encode ( to : ) <nl> + / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> + let _ = ClassWithComputedMembers . init ( from : ) <nl> + let _ = ClassWithComputedMembers . encode ( to : ) <nl> <nl> - / / The synthesized CodingKeys type should not be accessible from outside the <nl> - / / class . <nl> - let _ = ClassWithComputedMembers . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> - } <nl> + / / The synthesized CodingKeys type should not be accessible from outside the <nl> + / / class . <nl> + let _ = ClassWithComputedMembers . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> new file mode 100644 <nl> index 000000000000 . . 51c10c3ccaa7 <nl> mmm / dev / null <nl> ppp b / test / decl / protocol / special / coding / class_codable_ignore_nonconforming_property . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift - verify - ignore - unknown <nl> + <nl> + struct NonCodable { } <nl> + <nl> + / / Classes which have a default property that is not Codable , but which has a <nl> + / / default value and is skipped in its CodingKeys should still derive <nl> + / / conformance . <nl> + class SimpleClass : Codable { <nl> + var w : NonCodable = NonCodable ( ) <nl> + var x : Int = 1 <nl> + var y : Double = . pi <nl> + static var z : String = " foo " <nl> + <nl> + private enum CodingKeys : String , CodingKey { / / expected - note { { ' CodingKeys ' declared here } } <nl> + case x <nl> + case y <nl> + } <nl> + } <nl> + <nl> + / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> + let _ = SimpleClass . init ( from : ) <nl> + let _ = SimpleClass . encode ( to : ) <nl> + <nl> + / / The synthesized CodingKeys type should not be accessible from outside the <nl> + / / class . <nl> + let _ = SimpleClass . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> mmm a / test / decl / protocol / special / coding / class_codable_inheritance . swift <nl> ppp b / test / decl / protocol / special / coding / class_codable_inheritance . swift <nl> class SimpleChildClass : SimpleClass { <nl> } <nl> } <nl> <nl> - / / These are wrapped in a dummy function to avoid binding a global variable . <nl> - func foo ( ) { <nl> - / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> - let _ = SimpleChildClass . init ( from : ) <nl> - let _ = SimpleChildClass . encode ( to : ) <nl> - <nl> - / / The synthesized CodingKeys type should not be accessible from outside the <nl> - / / class . <nl> - let _ = SimpleChildClass . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> - } <nl> + / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> + let _ = SimpleChildClass . init ( from : ) <nl> + let _ = SimpleChildClass . encode ( to : ) <nl> + <nl> + / / The synthesized CodingKeys type should not be accessible from outside the <nl> + / / class . <nl> + let _ = SimpleChildClass . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> new file mode 100644 <nl> index 000000000000 . . a4ce3323a878 <nl> mmm / dev / null <nl> ppp b / test / decl / protocol / special / coding / class_codable_invalid_codingkeys . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift - verify - ignore - unknown <nl> + <nl> + / / Classes with a CodingKeys entity which is not a type should not derive <nl> + / / conformance . <nl> + class InvalidCodingKeys1 : Codable { / / expected - error { { type ' InvalidCodingKeys1 ' does not conform to protocol ' Decodable ' } } <nl> + / / expected - error @ - 1 { { type ' InvalidCodingKeys1 ' does not conform to protocol ' Encodable ' } } <nl> + let CodingKeys = 5 / / expected - note { { cannot automatically synthesize ' Decodable ' because ' CodingKeys ' is not an enum } } <nl> + / / expected - note @ - 1 { { cannot automatically synthesize ' Encodable ' because ' CodingKeys ' is not an enum } } <nl> + } <nl> + <nl> + / / Classes with a CodingKeys entity which does not conform to CodingKey should <nl> + / / not derive conformance . <nl> + class InvalidCodingKeys2 : Codable { / / expected - error { { type ' InvalidCodingKeys2 ' does not conform to protocol ' Decodable ' } } <nl> + / / expected - error @ - 1 { { type ' InvalidCodingKeys2 ' does not conform to protocol ' Encodable ' } } <nl> + enum CodingKeys { } / / expected - note { { cannot automatically synthesize ' Decodable ' because ' CodingKeys ' does not conform to CodingKey } } <nl> + / / expected - note @ - 1 { { cannot automatically synthesize ' Encodable ' because ' CodingKeys ' does not conform to CodingKey } } <nl> + } <nl> + <nl> + / / Classes with a CodingKeys entity which is not an enum should not derive <nl> + / / conformance . <nl> + class InvalidCodingKeys3 : Codable { / / expected - error { { type ' InvalidCodingKeys3 ' does not conform to protocol ' Decodable ' } } <nl> + / / expected - error @ - 1 { { type ' InvalidCodingKeys3 ' does not conform to protocol ' Encodable ' } } <nl> + struct CodingKeys : CodingKey { / / expected - note { { cannot automatically synthesize ' Decodable ' because ' CodingKeys ' is not an enum } } <nl> + / / expected - note @ - 1 { { cannot automatically synthesize ' Encodable ' because ' CodingKeys ' is not an enum } } <nl> + var stringValue : String <nl> + init ? ( stringValue : String ) { <nl> + self . stringValue = stringValue <nl> + self . intValue = nil <nl> + } <nl> + <nl> + var intValue : Int ? <nl> + init ? ( intValue : Int ) { <nl> + self . stringValue = " \ ( intValue ) " <nl> + self . intValue = intValue <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 1ff88c7122ce <nl> mmm / dev / null <nl> ppp b / test / decl / protocol / special / coding / class_codable_nonconforming_property . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift - verify - ignore - unknown <nl> + <nl> + struct NonCodable { } <nl> + <nl> + / / Classes whose properties are not all Codable should fail to synthesize <nl> + / / conformance . <nl> + class NonConformingClass : Codable { / / expected - error { { type ' NonConformingClass ' does not conform to protocol ' Decodable ' } } <nl> + / / expected - error @ - 1 { { type ' NonConformingClass ' does not conform to protocol ' Decodable ' } } <nl> + / / expected - error @ - 2 { { type ' NonConformingClass ' does not conform to protocol ' Encodable ' } } <nl> + / / expected - error @ - 3 { { type ' NonConformingClass ' does not conform to protocol ' Encodable ' } } <nl> + / / expected - note @ - 4 { { did you mean ' init ' ? } } <nl> + var w : NonCodable = NonCodable ( ) / / expected - note { { cannot automatically synthesize ' Decodable ' because ' w ' does not conform to ' Decodable ' } } <nl> + / / expected - note @ - 1 { { cannot automatically synthesize ' Decodable ' because ' w ' does not conform to ' Decodable ' } } <nl> + / / expected - note @ - 2 { { cannot automatically synthesize ' Encodable ' because ' w ' does not conform to ' Encodable ' } } <nl> + / / expected - note @ - 3 { { cannot automatically synthesize ' Encodable ' because ' w ' does not conform to ' Encodable ' } } <nl> + var x : Int = 1 <nl> + var y : Double = . pi <nl> + static var z : String = " foo " <nl> + <nl> + / / These lines have to be within the NonConformingClass type because <nl> + / / CodingKeys should be private . <nl> + func foo ( ) { <nl> + / / They should not get a CodingKeys type . <nl> + let _ = NonConformingClass . CodingKeys . self / / expected - error { { type ' NonConformingClass ' has no member ' CodingKeys ' } } <nl> + let _ = NonConformingClass . CodingKeys . x / / expected - error { { type ' NonConformingClass ' has no member ' CodingKeys ' } } <nl> + let _ = NonConformingClass . CodingKeys . y / / expected - error { { type ' NonConformingClass ' has no member ' CodingKeys ' } } <nl> + let _ = NonConformingClass . CodingKeys . z / / expected - error { { type ' NonConformingClass ' has no member ' CodingKeys ' } } <nl> + } <nl> + } <nl> + <nl> + / / They should not receive Codable methods . <nl> + let _ = NonConformingClass . init ( from : ) / / expected - error { { type ' NonConformingClass ' has no member ' init ( from : ) ' } } <nl> + let _ = NonConformingClass . encode ( to : ) / / expected - error { { type ' NonConformingClass ' has no member ' encode ( to : ) ' } } <nl> + <nl> + / / They should not get a CodingKeys type . <nl> + let _ = NonConformingClass . CodingKeys . self / / expected - error { { type ' NonConformingClass ' has no member ' CodingKeys ' } } <nl> mmm a / test / decl / protocol / special / coding / class_codable_simple . swift <nl> ppp b / test / decl / protocol / special / coding / class_codable_simple . swift <nl> class SimpleClass : Codable { <nl> } <nl> } <nl> <nl> - / / These are wrapped in a dummy function to avoid binding a global variable . <nl> - func foo ( ) { <nl> - / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> - let _ = SimpleClass . init ( from : ) <nl> - let _ = SimpleClass . encode ( to : ) <nl> + / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> + let _ = SimpleClass . init ( from : ) <nl> + let _ = SimpleClass . encode ( to : ) <nl> <nl> - / / The synthesized CodingKeys type should not be accessible from outside the <nl> - / / class . <nl> - let _ = SimpleClass . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> - } <nl> + / / The synthesized CodingKeys type should not be accessible from outside the <nl> + / / class . <nl> + let _ = SimpleClass . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> mmm a / test / decl / protocol / special / coding / class_codable_simple_extension . swift <nl> ppp b / test / decl / protocol / special / coding / class_codable_simple_extension . swift <nl> <nl> - / / RUN : % target - typecheck - verify - swift - verify - ignore - unknown <nl> + / / RUN : % target - typecheck - verify - swift <nl> <nl> - / / Simple classes where Codable conformance is added in extensions should still <nl> - / / derive conformance . <nl> - class SimpleClass { <nl> + / / Simple classes where Codable conformance is added in extensions should not <nl> + / / derive conformance yet . <nl> + class SimpleClass { / / expected - note { { did you mean ' init ' ? } } <nl> var x : Int = 1 <nl> var y : Double = . pi <nl> static var z : String = " foo " <nl> <nl> - / / These lines have to be within the SimpleClass type because CodingKeys <nl> - / / should be private . <nl> func foo ( ) { <nl> - / / They should receive a synthesized CodingKeys enum . <nl> - let _ = SimpleClass . CodingKeys . self <nl> - <nl> - / / The enum should have a case for each of the vars . <nl> - let _ = SimpleClass . CodingKeys . x <nl> - let _ = SimpleClass . CodingKeys . y <nl> - <nl> - / / Static vars should not be part of the CodingKeys enum . <nl> - let _ = SimpleClass . CodingKeys . z / / expected - error { { type ' SimpleClass . CodingKeys ' has no member ' z ' } } <nl> + / / They should not get a CodingKeys type . <nl> + let _ = SimpleClass . CodingKeys . self / / expected - error { { type ' SimpleClass ' has no member ' CodingKeys ' } } <nl> + let _ = SimpleClass . CodingKeys . x / / expected - error { { type ' SimpleClass ' has no member ' CodingKeys ' } } <nl> + let _ = SimpleClass . CodingKeys . y / / expected - error { { type ' SimpleClass ' has no member ' CodingKeys ' } } <nl> + let _ = SimpleClass . CodingKeys . z / / expected - error { { type ' SimpleClass ' has no member ' CodingKeys ' } } <nl> } <nl> } <nl> <nl> - extension SimpleClass : Codable { } <nl> + extension SimpleClass : Codable { } / / expected - error { { implementation of ' Decodable ' cannot be automatically synthesized in an extension } } <nl> + / / expected - error @ - 1 { { implementation of ' Decodable ' cannot be automatically synthesized in an extension } } <nl> + / / expected - error @ - 2 { { implementation of ' Encodable ' cannot be automatically synthesized in an extension } } <nl> + / / expected - error @ - 3 { { implementation of ' Encodable ' cannot be automatically synthesized in an extension } } <nl> <nl> - / / These are wrapped in a dummy function to avoid binding a global variable . <nl> - func foo ( ) { <nl> - / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> - let _ = SimpleClass . init ( from : ) <nl> - let _ = SimpleClass . encode ( to : ) <nl> + / / They should not receive Codable methods . <nl> + let _ = SimpleClass . init ( from : ) / / expected - error { { type ' SimpleClass ' has no member ' init ( from : ) ' } } <nl> + let _ = SimpleClass . encode ( to : ) / / expected - error { { type ' SimpleClass ' has no member ' encode ( to : ) ' } } <nl> <nl> - / / The synthesized CodingKeys type should not be accessible from outside the <nl> - / / class . <nl> - let _ = SimpleClass . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> - } <nl> + / / They should not get a CodingKeys type . <nl> + let _ = SimpleClass . CodingKeys . self / / expected - error { { type ' SimpleClass ' has no member ' CodingKeys ' } } <nl> new file mode 100644 <nl> index 000000000000 . . 0d5c543d5717 <nl> mmm / dev / null <nl> ppp b / test / decl / protocol / special / coding / struct_codable_codingkeys_typealias . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift - verify - ignore - unknown <nl> + <nl> + / / Simple structs with all Codable properties whose CodingKeys come from a <nl> + / / typealias should get derived conformance to Codable . <nl> + struct SimpleStruct : Codable { <nl> + var x : Int = 1 <nl> + var y : Double = . pi <nl> + static var z : String = " foo " <nl> + <nl> + private typealias CodingKeys = A / / expected - note { { ' CodingKeys ' declared here } } <nl> + private typealias A = B <nl> + private typealias B = C <nl> + private typealias C = MyRealCodingKeys <nl> + <nl> + private enum MyRealCodingKeys : String , CodingKey { <nl> + case x <nl> + case y <nl> + } <nl> + } <nl> + <nl> + / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> + let _ = SimpleStruct . init ( from : ) <nl> + let _ = SimpleStruct . encode ( to : ) <nl> + <nl> + / / The synthesized CodingKeys type should not be accessible from outside the <nl> + / / struct . <nl> + let _ = SimpleStruct . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> new file mode 100644 <nl> index 000000000000 . . 53e4b82212bf <nl> mmm / dev / null <nl> ppp b / test / decl / protocol / special / coding / struct_codable_ignore_nonconforming_property . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift - verify - ignore - unknown <nl> + <nl> + struct NonCodable { } <nl> + <nl> + / / Structs which have a default property that is not Codable , but which has a <nl> + / / default value and is skipped in its CodingKeys should still derive <nl> + / / conformance . <nl> + struct SimpleStruct : Codable { <nl> + var w : NonCodable = NonCodable ( ) <nl> + var x : Int <nl> + var y : Double <nl> + static var z : String = " foo " <nl> + <nl> + private enum CodingKeys : String , CodingKey { / / expected - note { { ' CodingKeys ' declared here } } <nl> + case x <nl> + case y <nl> + } <nl> + } <nl> + <nl> + / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> + let _ = SimpleStruct . init ( from : ) <nl> + let _ = SimpleStruct . encode ( to : ) <nl> + <nl> + / / The synthesized CodingKeys type should not be accessible from outside the <nl> + / / struct . <nl> + let _ = SimpleStruct . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> new file mode 100644 <nl> index 000000000000 . . 13f1777ce52f <nl> mmm / dev / null <nl> ppp b / test / decl / protocol / special / coding / struct_codable_invalid_codingkeys . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift - verify - ignore - unknown <nl> + <nl> + / / Structs with a CodingKeys entity which is not a type should not derive <nl> + / / conformance . <nl> + struct InvalidCodingKeys1 : Codable { / / expected - error { { type ' InvalidCodingKeys1 ' does not conform to protocol ' Decodable ' } } <nl> + / / expected - error @ - 1 { { type ' InvalidCodingKeys1 ' does not conform to protocol ' Encodable ' } } <nl> + let CodingKeys = 5 / / expected - note { { cannot automatically synthesize ' Decodable ' because ' CodingKeys ' is not an enum } } <nl> + / / expected - note @ - 1 { { cannot automatically synthesize ' Encodable ' because ' CodingKeys ' is not an enum } } <nl> + } <nl> + <nl> + / / Structs with a CodingKeys entity which does not conform to CodingKey should <nl> + / / not derive conformance . <nl> + struct InvalidCodingKeys2 : Codable { / / expected - error { { type ' InvalidCodingKeys2 ' does not conform to protocol ' Decodable ' } } <nl> + / / expected - error @ - 1 { { type ' InvalidCodingKeys2 ' does not conform to protocol ' Encodable ' } } <nl> + enum CodingKeys { } / / expected - note { { cannot automatically synthesize ' Decodable ' because ' CodingKeys ' does not conform to CodingKey } } <nl> + / / expected - note @ - 1 { { cannot automatically synthesize ' Encodable ' because ' CodingKeys ' does not conform to CodingKey } } <nl> + } <nl> + <nl> + / / Structs with a CodingKeys entity which is not an enum should not derive <nl> + / / conformance . <nl> + struct InvalidCodingKeys3 : Codable { / / expected - error { { type ' InvalidCodingKeys3 ' does not conform to protocol ' Decodable ' } } <nl> + / / expected - error @ - 1 { { type ' InvalidCodingKeys3 ' does not conform to protocol ' Encodable ' } } <nl> + struct CodingKeys : CodingKey { / / expected - note { { cannot automatically synthesize ' Decodable ' because ' CodingKeys ' is not an enum } } <nl> + / / expected - note @ - 1 { { cannot automatically synthesize ' Encodable ' because ' CodingKeys ' is not an enum } } <nl> + var stringValue : String <nl> + init ? ( stringValue : String ) { <nl> + self . stringValue = stringValue <nl> + self . intValue = nil <nl> + } <nl> + <nl> + var intValue : Int ? <nl> + init ? ( intValue : Int ) { <nl> + self . stringValue = " \ ( intValue ) " <nl> + self . intValue = intValue <nl> + } <nl> + } <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 9351eb638048 <nl> mmm / dev / null <nl> ppp b / test / decl / protocol / special / coding / struct_codable_nonconforming_property . swift <nl> <nl> + / / RUN : % target - typecheck - verify - swift - verify - ignore - unknown <nl> + <nl> + struct NonCodable { } <nl> + <nl> + / / Structs whose properties are not all Codable should fail to synthesize <nl> + / / conformance . <nl> + struct NonConformingStruct : Codable { / / expected - error { { type ' NonConformingStruct ' does not conform to protocol ' Decodable ' } } <nl> + / / expected - error @ - 1 { { type ' NonConformingStruct ' does not conform to protocol ' Decodable ' } } <nl> + / / expected - error @ - 2 { { type ' NonConformingStruct ' does not conform to protocol ' Encodable ' } } <nl> + / / expected - error @ - 3 { { type ' NonConformingStruct ' does not conform to protocol ' Encodable ' } } <nl> + / / expected - note @ - 4 { { did you mean ' init ' ? } } <nl> + var w : NonCodable / / expected - note { { cannot automatically synthesize ' Decodable ' because ' w ' does not conform to ' Decodable ' } } <nl> + / / expected - note @ - 1 { { cannot automatically synthesize ' Decodable ' because ' w ' does not conform to ' Decodable ' } } <nl> + / / expected - note @ - 2 { { cannot automatically synthesize ' Encodable ' because ' w ' does not conform to ' Encodable ' } } <nl> + / / expected - note @ - 3 { { cannot automatically synthesize ' Encodable ' because ' w ' does not conform to ' Encodable ' } } <nl> + var x : Int <nl> + var y : Double <nl> + static var z : String = " foo " <nl> + <nl> + / / These lines have to be within the NonConformingStruct type because <nl> + / / CodingKeys should be private . <nl> + func foo ( ) { <nl> + / / They should not get a CodingKeys type . <nl> + let _ = NonConformingStruct . CodingKeys . self / / expected - error { { type ' NonConformingStruct ' has no member ' CodingKeys ' } } <nl> + let _ = NonConformingStruct . CodingKeys . x / / expected - error { { type ' NonConformingStruct ' has no member ' CodingKeys ' } } <nl> + let _ = NonConformingStruct . CodingKeys . y / / expected - error { { type ' NonConformingStruct ' has no member ' CodingKeys ' } } <nl> + let _ = NonConformingStruct . CodingKeys . z / / expected - error { { type ' NonConformingStruct ' has no member ' CodingKeys ' } } <nl> + } <nl> + } <nl> + <nl> + / / They should not receive Codable methods . <nl> + let _ = NonConformingStruct . init ( from : ) / / expected - error { { type ' NonConformingStruct ' has no member ' init ( from : ) ' } } <nl> + let _ = NonConformingStruct . encode ( to : ) / / expected - error { { type ' NonConformingStruct ' has no member ' encode ( to : ) ' } } <nl> + <nl> + / / They should not get a CodingKeys type . <nl> + let _ = NonConformingStruct . CodingKeys . self / / expected - error { { type ' NonConformingStruct ' has no member ' CodingKeys ' } } <nl> mmm a / test / decl / protocol / special / coding / struct_codable_simple_extension . swift <nl> ppp b / test / decl / protocol / special / coding / struct_codable_simple_extension . swift <nl> <nl> / / RUN : % target - typecheck - verify - swift - verify - ignore - unknown <nl> <nl> - / / Simple structs where Codable conformance is added in extensions should still <nl> - / / derive conformance . <nl> - struct SimpleStruct { <nl> + / / Simple structs where Codable conformance is added in extensions should not <nl> + / / derive conformance yet . <nl> + struct SimpleStruct { / / expected - note { { did you mean ' init ' ? } } <nl> var x : Int <nl> var y : Double <nl> static var z : String = " foo " <nl> <nl> - / / These lines have to be within the SimpleStruct type because CodingKeys <nl> - / / should be private . <nl> func foo ( ) { <nl> - / / They should receive synthesized init ( from : ) and an encode ( to : ) . <nl> - let _ = SimpleStruct . init ( from : ) <nl> - let _ = SimpleStruct . encode ( to : ) <nl> - <nl> - / / They should receive a synthesized CodingKeys enum . <nl> - let _ = SimpleStruct . CodingKeys . self <nl> - <nl> - / / The enum should have a case for each of the vars . <nl> - let _ = SimpleStruct . CodingKeys . x <nl> - let _ = SimpleStruct . CodingKeys . y <nl> - <nl> - / / Static vars should not be part of the CodingKeys enum . <nl> - let _ = SimpleStruct . CodingKeys . z / / expected - error { { type ' SimpleStruct . CodingKeys ' has no member ' z ' } } <nl> + / / They should not receive a synthesized CodingKeys enum . <nl> + let _ = SimpleStruct . CodingKeys . self / / expected - error { { type ' SimpleStruct ' has no member ' CodingKeys ' } } <nl> + let _ = SimpleStruct . CodingKeys . x / / expected - error { { type ' SimpleStruct ' has no member ' CodingKeys ' } } <nl> + let _ = SimpleStruct . CodingKeys . y / / expected - error { { type ' SimpleStruct ' has no member ' CodingKeys ' } } <nl> + let _ = SimpleStruct . CodingKeys . z / / expected - error { { type ' SimpleStruct ' has no member ' CodingKeys ' } } <nl> } <nl> } <nl> <nl> - extension SimpleStruct : Codable { } <nl> + extension SimpleStruct : Codable { } / / expected - error { { implementation of ' Decodable ' cannot be automatically synthesized in an extension } } <nl> + / / expected - error @ - 1 { { implementation of ' Decodable ' cannot be automatically synthesized in an extension } } <nl> + / / expected - error @ - 2 { { implementation of ' Encodable ' cannot be automatically synthesized in an extension } } <nl> + / / expected - error @ - 3 { { implementation of ' Encodable ' cannot be automatically synthesized in an extension } } <nl> <nl> - / / These are wrapped in a dummy function to avoid binding a global variable . <nl> - func foo ( ) { <nl> - / / The synthesized CodingKeys type should not be accessible from outside the <nl> - / / struct . <nl> - let _ = SimpleStruct . CodingKeys . self / / expected - error { { ' CodingKeys ' is inaccessible due to ' private ' protection level } } <nl> - } <nl> + / / They should not receive Codable methods . <nl> + let _ = SimpleStruct . init ( from : ) / / expected - error { { type ' SimpleStruct ' has no member ' init ( from : ) ' } } <nl> + let _ = SimpleStruct . encode ( to : ) / / expected - error { { type ' SimpleStruct ' has no member ' encode ( to : ) ' } } <nl> + <nl> + / / They should not get a CodingKeys type . <nl> + let _ = SimpleStruct . CodingKeys . self / / expected - error { { type ' SimpleStruct ' has no member ' CodingKeys ' } } <nl> | Merge remote - tracking branch ' origin / master ' into master - next | apple/swift | 3f37e4bda6edd4250e1905c13d22d010b1b143c9 | 2017-05-19T21:08:36Z |
mmm a / include / simdjson / stage1_find_marks . h <nl> ppp b / include / simdjson / stage1_find_marks . h <nl> int find_structural_bits ( const char * buf , size_t len , simdjson : : ParsedJson & pj ) <nl> return find_structural_bits ( ( const uint8_t * ) buf , len , pj ) ; <nl> } <nl> <nl> - <nl> } / / namespace simdjson <nl> <nl> - <nl> - <nl> - <nl> - <nl> - <nl> - <nl> # endif <nl> mmm a / include / simdjson / stage1_find_marks_macros . h <nl> ppp b / include / simdjson / stage1_find_marks_macros . h <nl> <nl> return quote_mask ; \ <nl> } \ <nl> <nl> + / / Find structural bits in a 64 - byte chunk . <nl> + / / We need to compile that code for multiple architectures . However , target attributes can be used <nl> + / / only once by function definition . Huge macro seemed better than huge code duplication . <nl> + / / void FIND_STRUCTURAL_BITS_64 ( architecture T , <nl> + / / const uint8_t * buf , <nl> + / / size_t idx , <nl> + / / uint32_t * base_ptr , <nl> + / / uint32_t & base , <nl> + / / uint64_t & prev_iter_ends_odd_backslash , <nl> + / / uint64_t & prev_iter_inside_quote , <nl> + / / uint64_t & prev_iter_ends_pseudo_pred , <nl> + / / uint64_t & structurals , <nl> + / / uint64_t & error_mask , <nl> + / / utf8_checking_state < T > & utf8_state , flatten function ) <nl> + # define FIND_STRUCTURAL_BITS_64 ( T , \ <nl> + buf , \ <nl> + idx , \ <nl> + base_ptr , \ <nl> + base , \ <nl> + prev_iter_ends_odd_backslash , \ <nl> + prev_iter_inside_quote , \ <nl> + prev_iter_ends_pseudo_pred , \ <nl> + structurals , \ <nl> + error_mask , \ <nl> + utf8_state , \ <nl> + flat \ <nl> + ) { \ <nl> + simd_input < T > in = fill_input < T > ( buf ) ; \ <nl> + check_utf8 < T > ( in , utf8_state ) ; \ <nl> + / * detect odd sequences of backslashes * / \ <nl> + uint64_t odd_ends = find_odd_backslash_sequences < T > ( in , prev_iter_ends_odd_backslash ) ; \ <nl> + \ <nl> + / * detect insides of quote pairs ( " quote_mask " ) and also our quote_bits * / \ <nl> + / * themselves * / \ <nl> + uint64_t quote_bits ; \ <nl> + uint64_t quote_mask = find_quote_mask_and_bits < T > ( \ <nl> + in , odd_ends , prev_iter_inside_quote , quote_bits , error_mask ) ; \ <nl> + \ <nl> + / * take the previous iterations structural bits , not our current iteration , * / \ <nl> + / * and flatten * / \ <nl> + flat ( base_ptr , base , idx , structurals ) ; \ <nl> + \ <nl> + uint64_t whitespace ; \ <nl> + find_whitespace_and_structurals < T > ( in , whitespace , structurals ) ; \ <nl> + \ <nl> + / * fixup structurals to reflect quotes and add pseudo - structural characters * / \ <nl> + structurals = finalize_structurals ( structurals , whitespace , quote_mask , \ <nl> + quote_bits , prev_iter_ends_pseudo_pred ) ; \ <nl> + } \ <nl> <nl> <nl> / / We need to compile that code for multiple architectures . However , target attributes can be used <nl> / / only once by function definition . Huge macro seemed better than huge code duplication . <nl> - / / FIND_STRUCTURAL_BITS ( architecture T , const uint8_t * buf , size_t len , ParsedJson & pj ) <nl> + / / errorValues FIND_STRUCTURAL_BITS ( architecture T , const uint8_t * buf , size_t len , ParsedJson & pj , flatten functio ) <nl> # define FIND_STRUCTURAL_BITS ( T , buf , len , pj , flat ) { \ <nl> if ( len > pj . bytecapacity ) { \ <nl> std : : cerr < < " Your ParsedJson object only supports documents up to " \ <nl> <nl> } \ <nl> uint32_t * base_ptr = pj . structural_indexes ; \ <nl> uint32_t base = 0 ; \ <nl> - utf8_checking_state < T > state ; \ <nl> + utf8_checking_state < T > utf8_state ; \ <nl> \ <nl> / * we have padded the input out to 64 byte multiple with the remainder being * / \ <nl> / * zeros * / \ <nl> <nl> uint64_t error_mask = 0 ; / * for unescaped characters within strings ( ASCII code points < 0x20 ) * / \ <nl> \ <nl> for ( ; idx < lenminus64 ; idx + = 64 ) { \ <nl> - \ <nl> - simd_input < T > in = fill_input < T > ( buf + idx ) ; \ <nl> - check_utf8 < T > ( in , state ) ; \ <nl> - / * detect odd sequences of backslashes * / \ <nl> - uint64_t odd_ends = find_odd_backslash_sequences < T > ( \ <nl> - in , prev_iter_ends_odd_backslash ) ; \ <nl> - \ <nl> - / * detect insides of quote pairs ( " quote_mask " ) and also our quote_bits * / \ <nl> - / * themselves * / \ <nl> - uint64_t quote_bits ; \ <nl> - uint64_t quote_mask = find_quote_mask_and_bits < T > ( \ <nl> - in , odd_ends , prev_iter_inside_quote , quote_bits , error_mask ) ; \ <nl> - \ <nl> - / * take the previous iterations structural bits , not our current iteration , * / \ <nl> - / * and flatten * / \ <nl> - flat ( base_ptr , base , idx , structurals ) ; \ <nl> - \ <nl> - uint64_t whitespace ; \ <nl> - find_whitespace_and_structurals < T > ( in , whitespace , structurals ) ; \ <nl> - \ <nl> - / * fixup structurals to reflect quotes and add pseudo - structural characters * / \ <nl> - structurals = finalize_structurals ( structurals , whitespace , quote_mask , \ <nl> - quote_bits , prev_iter_ends_pseudo_pred ) ; \ <nl> + FIND_STRUCTURAL_BITS_64 ( T , & buf [ idx ] , idx , base_ptr , base , prev_iter_ends_odd_backslash , \ <nl> + prev_iter_inside_quote , prev_iter_ends_pseudo_pred , structurals , \ <nl> + error_mask , utf8_state , flat ) ; \ <nl> } \ <nl> - \ <nl> - / * / / / / / / / / / / / / / / * / \ <nl> - / * / we use a giant copy - paste which is ugly . * / \ <nl> - / * / but otherwise the string needs to be properly padded or else we * / \ <nl> - / * / risk invalidating the UTF - 8 checks . * / \ <nl> - / * / / / / / / / / / / * / \ <nl> + / * If we have a final chunk of less than 64 bytes , pad it to 64 with spaces * / \ <nl> + / * before processing it ( otherwise , we risk invalidating the UTF - 8 checks ) . * / \ <nl> if ( idx < len ) { \ <nl> uint8_t tmpbuf [ 64 ] ; \ <nl> memset ( tmpbuf , 0x20 , 64 ) ; \ <nl> memcpy ( tmpbuf , buf + idx , len - idx ) ; \ <nl> - simd_input < T > in = fill_input < T > ( tmpbuf ) ; \ <nl> - check_utf8 < T > ( in , state ) ; \ <nl> - \ <nl> - / * detect odd sequences of backslashes * / \ <nl> - uint64_t odd_ends = find_odd_backslash_sequences < T > ( \ <nl> - in , prev_iter_ends_odd_backslash ) ; \ <nl> - \ <nl> - / * detect insides of quote pairs ( " quote_mask " ) and also our quote_bits * / \ <nl> - / * themselves * / \ <nl> - uint64_t quote_bits ; \ <nl> - uint64_t quote_mask = find_quote_mask_and_bits < T > ( \ <nl> - in , odd_ends , prev_iter_inside_quote , quote_bits , error_mask ) ; \ <nl> - \ <nl> - / * take the previous iterations structural bits , not our current iteration , * / \ <nl> - / * and flatten * / \ <nl> - flat ( base_ptr , base , idx , structurals ) ; \ <nl> - \ <nl> - uint64_t whitespace ; \ <nl> - find_whitespace_and_structurals < T > ( in , whitespace , structurals ) ; \ <nl> - \ <nl> - / * fixup structurals to reflect quotes and add pseudo - structural characters * / \ <nl> - structurals = finalize_structurals ( structurals , whitespace , quote_mask , \ <nl> - quote_bits , prev_iter_ends_pseudo_pred ) ; \ <nl> + FIND_STRUCTURAL_BITS_64 ( T , & tmpbuf [ 0 ] , idx , base_ptr , base , prev_iter_ends_odd_backslash , \ <nl> + prev_iter_inside_quote , prev_iter_ends_pseudo_pred , structurals , \ <nl> + error_mask , utf8_state , flat ) ; \ <nl> idx + = 64 ; \ <nl> } \ <nl> \ <nl> <nl> } \ <nl> \ <nl> / * finally , flatten out the remaining structurals from the last iteration * / \ <nl> - flat ( base_ptr , base , idx , structurals ) ; \ <nl> + flat ( base_ptr , base , idx , structurals ) ; \ <nl> \ <nl> pj . n_structural_indexes = base ; \ <nl> / * a valid JSON file cannot have zero structural indexes - we should have * / \ <nl> <nl> if ( error_mask ) { \ <nl> return simdjson : : UNESCAPED_CHARS ; \ <nl> } \ <nl> - return check_utf8_errors < T > ( state ) ; \ <nl> + return check_utf8_errors < T > ( utf8_state ) ; \ <nl> } <nl> <nl> <nl> | Merging No duplicate tail ( PR ) ( ) | simdjson/simdjson | 5f20d3eb34d8f8a9e2a4ab48bd9b15404d8fade9 | 2019-07-29T18:11:42Z |
mmm a / Telegram / Resources / langs / lang . strings <nl> ppp b / Telegram / Resources / langs / lang . strings <nl> https : / / github . com / telegramdesktop / tdesktop / blob / master / LEGAL <nl> " lng_media_size_limit " = " Limit by size " ; <nl> " lng_media_size_up_to " = " up to { size } " ; <nl> " lng_media_chat_background " = " Chat background " ; <nl> + " lng_media_color_theme " = " Color theme " ; <nl> <nl> " lng_emoji_category1 " = " People " ; <nl> " lng_emoji_category2 " = " Nature " ; <nl> mmm a / Telegram / SourceFiles / data / data_document . cpp <nl> ppp b / Telegram / SourceFiles / data / data_document . cpp <nl> void DocumentData : : validateGoodThumbnail ( ) { <nl> if ( ! isVideoFile ( ) <nl> & & ! isAnimation ( ) <nl> & & ! isWallPaper ( ) <nl> + & & ! isTheme ( ) <nl> & & ( ! sticker ( ) | | ! sticker ( ) - > animated ) ) { <nl> _goodThumbnail = nullptr ; <nl> } else if ( ! _goodThumbnail & & hasRemoteLocation ( ) ) { <nl> bool DocumentData : : isGifv ( ) const { <nl> <nl> bool DocumentData : : isTheme ( ) const { <nl> return <nl> - _filename . endsWith ( <nl> + _mimeString = = qstr ( " application / x - tgtheme - tdesktop " ) <nl> + | | _filename . endsWith ( <nl> qstr ( " . tdesktop - theme " ) , <nl> Qt : : CaseInsensitive ) <nl> | | _filename . endsWith ( <nl> mmm a / Telegram / SourceFiles / data / data_document_good_thumbnail . cpp <nl> ppp b / Telegram / SourceFiles / data / data_document_good_thumbnail . cpp <nl> For license and copyright information please follow this link : <nl> # include " data / data_session . h " <nl> # include " data / data_document . h " <nl> # include " data / data_file_origin . h " <nl> + # include " data / data_cloud_themes . h " <nl> # include " media / clip / media_clip_reader . h " <nl> # include " lottie / lottie_animation . h " <nl> + # include " window / themes / window_theme_preview . h " <nl> # include " main / main_session . h " <nl> <nl> # include < QtCore / QBuffer > <nl> enum class FileType { <nl> Video , <nl> AnimatedSticker , <nl> WallPaper , <nl> + Theme , <nl> } ; <nl> <nl> QImage Prepare ( <nl> QImage Prepare ( <nl> return : : Media : : Clip : : PrepareForSending ( path , data ) . thumbnail ; <nl> } else if ( type = = FileType : : AnimatedSticker ) { <nl> return Lottie : : ReadThumbnail ( Lottie : : ReadContent ( data , path ) ) ; <nl> + } else if ( type = = FileType : : Theme ) { <nl> + return Window : : Theme : : GeneratePreview ( data , path ) ; <nl> } <nl> const auto validateSize = [ ] ( QSize size ) { <nl> return ( size . width ( ) + size . height ( ) ) < 10 ' 000 ; <nl> void GoodThumbSource : : generate ( base : : binary_guard & & guard ) { <nl> const auto data = _document - > data ( ) ; <nl> const auto type = _document - > isWallPaper ( ) <nl> ? FileType : : WallPaper <nl> + : _document - > isTheme ( ) <nl> + ? FileType : : Theme <nl> : _document - > sticker ( ) <nl> ? FileType : : AnimatedSticker <nl> : FileType : : Video ; <nl> void GoodThumbSource : : ready ( <nl> _document - > goodThumbnailCacheKey ( ) , <nl> Storage : : Cache : : Database : : TaggedValue { <nl> std : : move ( bytes ) , <nl> - Data : : kImageCacheTag } ) ; <nl> + kImageCacheTag } ) ; <nl> } <nl> Auth ( ) . downloaderTaskFinished ( ) . notify ( ) ; <nl> } ) ; <nl> } <nl> <nl> - void GoodThumbSource : : load ( Data : : FileOrigin origin ) { <nl> + void GoodThumbSource : : load ( FileOrigin origin ) { <nl> if ( loading ( ) | | _empty ) { <nl> return ; <nl> } <nl> void GoodThumbSource : : load ( Data : : FileOrigin origin ) { <nl> std : : move ( callback ) ) ; <nl> } <nl> <nl> - void GoodThumbSource : : loadEvenCancelled ( Data : : FileOrigin origin ) { <nl> + void GoodThumbSource : : loadEvenCancelled ( FileOrigin origin ) { <nl> _empty = false ; <nl> load ( origin ) ; <nl> } <nl> void GoodThumbSource : : unload ( ) { <nl> } <nl> <nl> void GoodThumbSource : : automaticLoad ( <nl> - Data : : FileOrigin origin , <nl> + FileOrigin origin , <nl> const HistoryItem * item ) { <nl> } <nl> <nl> void GoodThumbSource : : setDelayedStorageLocation ( <nl> const StorageImageLocation & location ) { <nl> } <nl> <nl> - void GoodThumbSource : : performDelayedLoad ( Data : : FileOrigin origin ) { <nl> + void GoodThumbSource : : performDelayedLoad ( FileOrigin origin ) { <nl> } <nl> <nl> bool GoodThumbSource : : isDelayedStorageImage ( ) const { <nl> mmm a / Telegram / SourceFiles / data / data_document_good_thumbnail . h <nl> ppp b / Telegram / SourceFiles / data / data_document_good_thumbnail . h <nl> class GoodThumbSource : public Images : : Source { <nl> public : <nl> explicit GoodThumbSource ( not_null < DocumentData * > document ) ; <nl> <nl> - void load ( Data : : FileOrigin origin ) override ; <nl> - void loadEvenCancelled ( Data : : FileOrigin origin ) override ; <nl> + void load ( FileOrigin origin ) override ; <nl> + void loadEvenCancelled ( FileOrigin origin ) override ; <nl> QImage takeLoaded ( ) override ; <nl> void unload ( ) override ; <nl> <nl> void automaticLoad ( <nl> - Data : : FileOrigin origin , <nl> + FileOrigin origin , <nl> const HistoryItem * item ) override ; <nl> void automaticLoadSettingsChanged ( ) override ; <nl> <nl> class GoodThumbSource : public Images : : Source { <nl> std : : optional < Storage : : Cache : : Key > cacheKey ( ) override ; <nl> void setDelayedStorageLocation ( <nl> const StorageImageLocation & location ) override ; <nl> - void performDelayedLoad ( Data : : FileOrigin origin ) override ; <nl> + void performDelayedLoad ( FileOrigin origin ) override ; <nl> bool isDelayedStorageImage ( ) const override ; <nl> void setImageBytes ( const QByteArray & bytes ) override ; <nl> <nl> mmm a / Telegram / SourceFiles / data / data_file_origin . cpp <nl> ppp b / Telegram / SourceFiles / data / data_file_origin . cpp <nl> struct FileReferenceAccumulator { <nl> if ( const auto document = data . vdocument ( ) ) { <nl> push ( * document ) ; <nl> } <nl> + if ( const auto documents = data . vdocuments ( ) ) { <nl> + push ( * documents ) ; <nl> + } <nl> if ( const auto photo = data . vphoto ( ) ) { <nl> push ( * photo ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / data / data_media_types . cpp <nl> ppp b / Telegram / SourceFiles / data / data_media_types . cpp <nl> For license and copyright information please follow this link : <nl> # include " history / view / media / history_view_call . h " <nl> # include " history / view / media / history_view_web_page . h " <nl> # include " history / view / media / history_view_poll . h " <nl> + # include " history / view / media / history_view_theme_document . h " <nl> # include " ui / image / image . h " <nl> # include " ui / image / image_source . h " <nl> # include " ui / text_options . h " <nl> std : : unique_ptr < HistoryView : : Media > MediaFile : : createView ( <nl> message , <nl> realParent , <nl> _document ) ; <nl> + } else if ( _document - > isTheme ( ) & & _document - > hasThumbnail ( ) ) { <nl> + return std : : make_unique < HistoryView : : ThemeDocument > ( <nl> + message , <nl> + _document ) ; <nl> } <nl> return std : : make_unique < HistoryView : : Document > ( message , _document ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / data / data_session . cpp <nl> ppp b / Telegram / SourceFiles / data / data_session . cpp <nl> void Session : : webpageApplyFields ( <nl> const auto pendingTill = TimeId ( 0 ) ; <nl> const auto photo = data . vphoto ( ) ; <nl> const auto document = data . vdocument ( ) ; <nl> + const auto lookupThemeDocument = [ & ] ( ) - > DocumentData * { <nl> + if ( const auto documents = data . vdocuments ( ) ) { <nl> + for ( const auto & document : documents - > v ) { <nl> + const auto processed = processDocument ( document ) ; <nl> + if ( processed - > isTheme ( ) ) { <nl> + return processed ; <nl> + } <nl> + } <nl> + } <nl> + return nullptr ; <nl> + } ; <nl> webpageApplyFields ( <nl> page , <nl> ParseWebPageType ( data ) , <nl> void Session : : webpageApplyFields ( <nl> qs ( data . vtitle ( ) . value_or_empty ( ) ) , <nl> description , <nl> photo ? processPhoto ( * photo ) . get ( ) : nullptr , <nl> - document ? processDocument ( * document ) . get ( ) : nullptr , <nl> + document ? processDocument ( * document ) . get ( ) : lookupThemeDocument ( ) , <nl> WebPageCollage ( data ) , <nl> data . vduration ( ) . value_or_empty ( ) , <nl> qs ( data . vauthor ( ) . value_or_empty ( ) ) , <nl> mmm a / Telegram / SourceFiles / data / data_web_page . cpp <nl> ppp b / Telegram / SourceFiles / data / data_web_page . cpp <nl> WebPageType ParseWebPageType ( const MTPDwebPage & page ) { <nl> return WebPageType : : Profile ; <nl> } else if ( type = = qstr ( " telegram_background " ) ) { <nl> return WebPageType : : WallPaper ; <nl> + } else if ( type = = qstr ( " telegram_theme " ) ) { <nl> + return WebPageType : : Theme ; <nl> } else if ( page . vcached_page ( ) ) { <nl> return WebPageType : : ArticleWithIV ; <nl> } else { <nl> mmm a / Telegram / SourceFiles / data / data_web_page . h <nl> ppp b / Telegram / SourceFiles / data / data_web_page . h <nl> enum class WebPageType { <nl> Video , <nl> Profile , <nl> WallPaper , <nl> + Theme , <nl> Article , <nl> ArticleWithIV , <nl> } ; <nl> mmm a / Telegram / SourceFiles / history / history . style <nl> ppp b / Telegram / SourceFiles / history / history . style <nl> maxVideoMessageSize : 240px ; <nl> maxSignatureSize : 144px ; <nl> maxWallPaperWidth : 160px ; <nl> maxWallPaperHeight : 240px ; <nl> + historyThemeSize : size ( 309px , 200px ) ; <nl> <nl> historyMinimalWidth : 380px ; <nl> <nl> mmm a / Telegram / SourceFiles / history / view / media / history_view_media_common . cpp <nl> ppp b / Telegram / SourceFiles / history / view / media / history_view_media_common . cpp <nl> For license and copyright information please follow this link : <nl> # include " history / view / media / history_view_document . h " <nl> # include " history / view / media / history_view_sticker . h " <nl> # include " history / view / media / history_view_video . h " <nl> - # include " history / view / media / history_view_wall_paper . h " <nl> + # include " history / view / media / history_view_theme_document . h " <nl> # include " styles / style_history . h " <nl> <nl> namespace HistoryView { <nl> std : : unique_ptr < Media > CreateAttach ( <nl> parent , <nl> parent - > data ( ) , <nl> document ) ; <nl> - } else if ( document - > isWallPaper ( ) ) { <nl> - return std : : make_unique < WallPaper > ( <nl> + } else if ( document - > isWallPaper ( ) | | document - > isTheme ( ) ) { <nl> + return std : : make_unique < ThemeDocument > ( <nl> parent , <nl> document , <nl> webpageUrl ) ; <nl> similarity index 84 % <nl> rename from Telegram / SourceFiles / history / view / media / history_view_wall_paper . cpp <nl> rename to Telegram / SourceFiles / history / view / media / history_view_theme_document . cpp <nl> mmm a / Telegram / SourceFiles / history / view / media / history_view_wall_paper . cpp <nl> ppp b / Telegram / SourceFiles / history / view / media / history_view_theme_document . cpp <nl> the official desktop application for the Telegram messaging service . <nl> For license and copyright information please follow this link : <nl> https : / / github . com / telegramdesktop / tdesktop / blob / master / LEGAL <nl> * / <nl> - # include " history / view / media / history_view_wall_paper . h " <nl> + # include " history / view / media / history_view_theme_document . h " <nl> <nl> # include " layout . h " <nl> # include " history / history_item . h " <nl> For license and copyright information please follow this link : <nl> <nl> namespace HistoryView { <nl> <nl> - WallPaper : : WallPaper ( <nl> + ThemeDocument : : ThemeDocument ( <nl> not_null < Element * > parent , <nl> not_null < DocumentData * > document , <nl> const QString & url ) <nl> : File ( parent , parent - > data ( ) ) <nl> , _data ( document ) { <nl> - Expects ( _data - > hasThumbnail ( ) ) ; <nl> + Expects ( _data - > hasThumbnail ( ) | | _data - > isTheme ( ) ) ; <nl> <nl> - fillPatternFieldsFrom ( url ) ; <nl> + if ( _data - > isWallPaper ( ) ) { <nl> + fillPatternFieldsFrom ( url ) ; <nl> + } <nl> <nl> - _data - > thumbnail ( ) - > load ( parent - > data ( ) - > fullId ( ) ) ; <nl> + _data - > loadThumbnail ( _parent - > data ( ) - > fullId ( ) ) ; <nl> setDocumentLinks ( _data , parent - > data ( ) ) ; <nl> setStatusSize ( FileStatusSizeReady , _data - > size , - 1 , 0 ) ; <nl> } <nl> <nl> - void WallPaper : : fillPatternFieldsFrom ( const QString & url ) { <nl> + void ThemeDocument : : fillPatternFieldsFrom ( const QString & url ) { <nl> const auto paramsPosition = url . indexOf ( ' ? ' ) ; <nl> if ( paramsPosition < 0 ) { <nl> return ; <nl> void WallPaper : : fillPatternFieldsFrom ( const QString & url ) { <nl> _background = paper . backgroundColor ( ) . value_or ( kDefaultBackground ) ; <nl> } <nl> <nl> - QSize WallPaper : : countOptimalSize ( ) { <nl> + QSize ThemeDocument : : countOptimalSize ( ) { <nl> + if ( _data - > isTheme ( ) ) { <nl> + return st : : historyThemeSize ; <nl> + } <nl> auto tw = ConvertScale ( _data - > thumbnail ( ) - > width ( ) ) ; <nl> auto th = ConvertScale ( _data - > thumbnail ( ) - > height ( ) ) ; <nl> if ( ! tw | | ! th ) { <nl> QSize WallPaper : : countOptimalSize ( ) { <nl> return { maxWidth , minHeight } ; <nl> } <nl> <nl> - QSize WallPaper : : countCurrentSize ( int newWidth ) { <nl> + QSize ThemeDocument : : countCurrentSize ( int newWidth ) { <nl> + if ( _data - > isTheme ( ) ) { <nl> + _pixw = st : : historyThemeSize . width ( ) ; <nl> + _pixh = st : : historyThemeSize . height ( ) ; <nl> + return st : : historyThemeSize ; <nl> + } <nl> auto tw = ConvertScale ( _data - > thumbnail ( ) - > width ( ) ) ; <nl> auto th = ConvertScale ( _data - > thumbnail ( ) - > height ( ) ) ; <nl> if ( ! tw | | ! th ) { <nl> QSize WallPaper : : countCurrentSize ( int newWidth ) { <nl> return { newWidth , newHeight } ; <nl> } <nl> <nl> - void WallPaper : : draw ( Painter & p , const QRect & r , TextSelection selection , crl : : time ms ) const { <nl> + void ThemeDocument : : draw ( Painter & p , const QRect & r , TextSelection selection , crl : : time ms ) const { <nl> if ( width ( ) < st : : msgPadding . left ( ) + st : : msgPadding . right ( ) + 1 ) return ; <nl> <nl> _data - > automaticLoad ( _realParent - > fullId ( ) , _parent - > data ( ) ) ; <nl> void WallPaper : : draw ( Painter & p , const QRect & r , TextSelection selection , crl : : t <nl> } <nl> } <nl> <nl> - void WallPaper : : validateThumbnail ( ) const { <nl> + void ThemeDocument : : validateThumbnail ( ) const { <nl> if ( _thumbnailGood > 0 ) { <nl> return ; <nl> } <nl> void WallPaper : : validateThumbnail ( ) const { <nl> good - > load ( { } ) ; <nl> } <nl> } <nl> - if ( _thumbnailGood > = 0 ) { <nl> + if ( _thumbnailGood > = 0 | | ! _data - > thumbnail ( ) ) { <nl> return ; <nl> } <nl> if ( _data - > thumbnail ( ) - > loaded ( ) ) { <nl> void WallPaper : : validateThumbnail ( ) const { <nl> } <nl> } <nl> <nl> - void WallPaper : : prepareThumbnailFrom ( <nl> + void ThemeDocument : : prepareThumbnailFrom ( <nl> not_null < Image * > image , <nl> int good ) const { <nl> Expects ( _thumbnailGood < = good ) ; <nl> <nl> + const auto isTheme = _data - > isTheme ( ) ; <nl> const auto isPattern = _data - > isPatternWallPaper ( ) ; <nl> auto options = Images : : Option : : Smooth <nl> | ( good > = 0 ? Images : : Option ( 0 ) : Images : : Option : : Blurred ) <nl> void WallPaper : : prepareThumbnailFrom ( <nl> ? Images : : Option : : TransparentBackground <nl> : Images : : Option ( 0 ) ) ; <nl> auto original = image - > original ( ) ; <nl> - auto tw = ConvertScale ( _data - > thumbnail ( ) - > width ( ) ) ; <nl> - auto th = ConvertScale ( _data - > thumbnail ( ) - > height ( ) ) ; <nl> + auto tw = isTheme ? _pixw : ConvertScale ( _data - > thumbnail ( ) - > width ( ) ) ; <nl> + auto th = isTheme ? _pixh : ConvertScale ( _data - > thumbnail ( ) - > height ( ) ) ; <nl> if ( ! tw | | ! th ) { <nl> tw = th = 1 ; <nl> } <nl> void WallPaper : : prepareThumbnailFrom ( <nl> _thumbnailGood = good ; <nl> } <nl> <nl> - TextState WallPaper : : textState ( QPoint point , StateRequest request ) const { <nl> + TextState ThemeDocument : : textState ( QPoint point , StateRequest request ) const { <nl> auto result = TextState ( _parent ) ; <nl> <nl> if ( width ( ) < st : : msgPadding . left ( ) + st : : msgPadding . right ( ) + 1 ) { <nl> TextState WallPaper : : textState ( QPoint point , StateRequest request ) const { <nl> return result ; <nl> } <nl> <nl> - float64 WallPaper : : dataProgress ( ) const { <nl> + float64 ThemeDocument : : dataProgress ( ) const { <nl> return _data - > progress ( ) ; <nl> } <nl> <nl> - bool WallPaper : : dataFinished ( ) const { <nl> + bool ThemeDocument : : dataFinished ( ) const { <nl> return ! _data - > loading ( ) <nl> & & ( ! _data - > uploading ( ) | | _data - > waitingForAlbum ( ) ) ; <nl> } <nl> <nl> - bool WallPaper : : dataLoaded ( ) const { <nl> + bool ThemeDocument : : dataLoaded ( ) const { <nl> return _data - > loaded ( ) ; <nl> } <nl> <nl> - bool WallPaper : : isReadyForOpen ( ) const { <nl> + bool ThemeDocument : : isReadyForOpen ( ) const { <nl> return _data - > loaded ( ) ; <nl> } <nl> <nl> - QString WallPaper : : additionalInfoString ( ) const { <nl> + QString ThemeDocument : : additionalInfoString ( ) const { <nl> / / This will force message info ( time ) to be displayed below <nl> / / this attachment in WebPage media . <nl> static auto result = QString ( " " ) ; <nl> similarity index 94 % <nl> rename from Telegram / SourceFiles / history / view / media / history_view_wall_paper . h <nl> rename to Telegram / SourceFiles / history / view / media / history_view_theme_document . h <nl> mmm a / Telegram / SourceFiles / history / view / media / history_view_wall_paper . h <nl> ppp b / Telegram / SourceFiles / history / view / media / history_view_theme_document . h <nl> For license and copyright information please follow this link : <nl> <nl> namespace HistoryView { <nl> <nl> - class WallPaper : public File { <nl> + class ThemeDocument : public File { <nl> public : <nl> - WallPaper ( <nl> + ThemeDocument ( <nl> not_null < Element * > parent , <nl> not_null < DocumentData * > document , <nl> const QString & url = QString ( ) ) ; <nl> class WallPaper : public File { <nl> int _pixh = 1 ; <nl> mutable QPixmap _thumbnail ; <nl> mutable int _thumbnailGood = - 1 ; / / - 1 inline , 0 thumbnail , 1 good <nl> + <nl> + / / For wallpaper documents . <nl> QColor _background ; <nl> int _intensity = 0 ; <nl> <nl> mmm a / Telegram / SourceFiles / history / view / media / history_view_web_page . cpp <nl> ppp b / Telegram / SourceFiles / history / view / media / history_view_web_page . cpp <nl> QSize WebPage : : countOptimalSize ( ) { <nl> _openl = previewOfHiddenUrl <nl> ? std : : make_shared < HiddenUrlClickHandler > ( _data - > url ) <nl> : std : : make_shared < UrlClickHandler > ( _data - > url , true ) ; <nl> - if ( _data - > document & & _data - > document - > isWallPaper ( ) ) { <nl> + if ( _data - > document <nl> + & & ( _data - > document - > isWallPaper ( ) <nl> + | | _data - > document - > isTheme ( ) ) ) { <nl> _openl = std : : make_shared < DocumentWrappedClickHandler > ( <nl> std : : move ( _openl ) , <nl> _data - > document , <nl> ClickHandlerPtr WebPage : : replaceAttachLink ( <nl> return link ; <nl> } <nl> if ( _data - > document ) { <nl> - if ( _data - > document - > isWallPaper ( ) ) { <nl> + if ( _data - > document - > isWallPaper ( ) | | _data - > document - > isTheme ( ) ) { <nl> return _openl ; <nl> } <nl> } else if ( _data - > photo ) { <nl> TextSelection WebPage : : adjustSelection ( TextSelection selection , TextSelectType t <nl> if ( ( ! _titleLines & & ! _descriptionLines ) | | selection . to < = _siteName . length ( ) ) { <nl> return _siteName . adjustSelection ( selection , type ) ; <nl> } <nl> - <nl> + <nl> auto titleSelection = _title . adjustSelection ( toTitleSelection ( selection ) , type ) ; <nl> if ( ( ! _siteNameLines & & ! _descriptionLines ) | | ( selection . from > = _siteName . length ( ) & & selection . to < = _description . length ( ) ) ) { <nl> return fromTitleSelection ( titleSelection ) ; <nl> void WebPage : : clickHandlerPressedChanged ( const ClickHandlerPtr & p , bool pressed ) <nl> bool WebPage : : enforceBubbleWidth ( ) const { <nl> return ( _attach ! = nullptr ) <nl> & & ( _data - > document ! = nullptr ) <nl> - & & _data - > document - > isWallPaper ( ) ; <nl> + & & ( _data - > document - > isWallPaper ( ) | | _data - > document - > isTheme ( ) ) ; <nl> } <nl> <nl> void WebPage : : playAnimation ( bool autoplay ) { <nl> int WebPage : : bottomInfoPadding ( ) const { <nl> QString WebPage : : displayedSiteName ( ) const { <nl> return ( _data - > document & & _data - > document - > isWallPaper ( ) ) <nl> ? tr : : lng_media_chat_background ( tr : : now ) <nl> + : ( _data - > document & & _data - > document - > isWallPaper ( ) ) <nl> + ? tr : : lng_media_color_theme ( tr : : now ) <nl> : _data - > siteName ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / media / view / media_view_overlay_widget . cpp <nl> ppp b / Telegram / SourceFiles / media / view / media_view_overlay_widget . cpp <nl> void OverlayWidget : : initThemePreview ( ) { <nl> const auto id = _themePreviewId = rand_value < uint64 > ( ) ; <nl> const auto weak = make_weak ( this ) ; <nl> crl : : async ( [ = , data = std : : move ( current ) ] ( ) mutable { <nl> - auto preview = GeneratePreview ( bytes , path , fields , std : : move ( data ) ) ; <nl> + auto preview = GeneratePreview ( <nl> + bytes , <nl> + path , <nl> + fields , <nl> + std : : move ( data ) , <nl> + Window : : Theme : : PreviewType : : Extended ) ; <nl> crl : : on_main ( weak , [ = , result = std : : move ( preview ) ] ( ) mutable { <nl> if ( id ! = _themePreviewId ) { <nl> return ; <nl> mmm a / Telegram / SourceFiles / storage / localimageloader . cpp <nl> ppp b / Telegram / SourceFiles / storage / localimageloader . cpp <nl> For license and copyright information please follow this link : <nl> # include " lang / lang_keys . h " <nl> # include " storage / file_download . h " <nl> # include " storage / storage_media_prepare . h " <nl> + # include " window / themes / window_theme_preview . h " <nl> # include " mainwidget . h " <nl> # include " mainwindow . h " <nl> # include " main / main_session . h " <nl> PreparedFileThumbnail PrepareFileThumbnail ( QImage & & original ) { <nl> return result ; <nl> } <nl> <nl> - PreparedFileThumbnail PrepareAnimatedStickerThumbnail ( <nl> - const QString & file , <nl> - const QByteArray & bytes ) { <nl> - return PrepareFileThumbnail ( <nl> - Lottie : : ReadThumbnail ( Lottie : : ReadContent ( bytes , file ) ) ) ; <nl> - } <nl> - <nl> bool FileThumbnailUploadRequired ( const QString & filemime , int32 filesize ) { <nl> constexpr auto kThumbnailUploadBySize = 5 * 1024 * 1024 ; <nl> const auto kThumbnailKnownMimes = { <nl> void FileLoadTask : : process ( ) { <nl> } <nl> <nl> thumbnail = PrepareFileThumbnail ( std : : move ( video - > thumbnail ) ) ; <nl> + } else if ( filemime = = qstr ( " application / x - tdesktop - theme " ) <nl> + | | filemime = = qstr ( " application / x - tgtheme - tdesktop " ) ) { <nl> + goodThumbnail = Window : : Theme : : GeneratePreview ( _content , _filepath ) ; <nl> + if ( ! goodThumbnail . isNull ( ) ) { <nl> + QBuffer buffer ( & goodThumbnailBytes ) ; <nl> + goodThumbnail . save ( & buffer , " JPG " , kThumbnailQuality ) ; <nl> + <nl> + thumbnail = PrepareFileThumbnail ( base : : duplicate ( goodThumbnail ) ) ; <nl> + } <nl> } <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / window / themes / window_theme_editor_box . cpp <nl> ppp b / Telegram / SourceFiles / window / themes / window_theme_editor_box . cpp <nl> SendMediaReady PrepareThemeMedia ( <nl> PreparedPhotoThumbs thumbnails ; <nl> QVector < MTPPhotoSize > sizes ; <nl> <nl> - / / const auto push = [ & ] ( const char * type , QImage & & image ) { <nl> - / / sizes . push_back ( MTP_photoSize ( <nl> - / / MTP_string ( type ) , <nl> - / / MTP_fileLocationToBeDeprecated ( MTP_long ( 0 ) , MTP_int ( 0 ) ) , <nl> - / / MTP_int ( image . width ( ) ) , <nl> - / / MTP_int ( image . height ( ) ) , MTP_int ( 0 ) ) ) ; <nl> - / / thumbnails . emplace ( type [ 0 ] , std : : move ( image ) ) ; <nl> - / / } ; <nl> - / / push ( " s " , scaled ( 320 ) ) ; <nl> + auto thumbnail = GeneratePreview ( content , QString ( ) ) . scaled ( <nl> + 320 , <nl> + 320 , <nl> + Qt : : KeepAspectRatio , <nl> + Qt : : SmoothTransformation ) ; <nl> + auto thumbnailBytes = QByteArray ( ) ; <nl> + { <nl> + QBuffer buffer ( & thumbnailBytes ) ; <nl> + thumbnail . save ( & buffer , " JPG " , 87 ) ; <nl> + } <nl> + <nl> + const auto push = [ & ] ( const char * type , QImage & & image ) { <nl> + sizes . push_back ( MTP_photoSize ( <nl> + MTP_string ( type ) , <nl> + MTP_fileLocationToBeDeprecated ( MTP_long ( 0 ) , MTP_int ( 0 ) ) , <nl> + MTP_int ( image . width ( ) ) , <nl> + MTP_int ( image . height ( ) ) , MTP_int ( 0 ) ) ) ; <nl> + thumbnails . emplace ( type [ 0 ] , std : : move ( image ) ) ; <nl> + } ; <nl> + push ( " s " , std : : move ( thumbnail ) ) ; <nl> <nl> const auto filename = File : : NameFromUserString ( name ) <nl> + qsl ( " . tdesktop - theme " ) ; <nl> SendMediaReady PrepareThemeMedia ( <nl> MTP_photoEmpty ( MTP_long ( 0 ) ) , <nl> thumbnails , <nl> document , <nl> - QByteArray ( ) , <nl> + thumbnailBytes , <nl> 0 ) ; <nl> } <nl> <nl> Fn < void ( ) > SavePreparedTheme ( <nl> Fn < void ( SaveErrorType , QString ) > fail ) { <nl> Expects ( window - > account ( ) . sessionExists ( ) ) ; <nl> <nl> - using Storage : : UploadedDocument ; <nl> + using Storage : : UploadedThumbDocument ; <nl> struct State { <nl> FullMsgId id ; <nl> bool generating = false ; <nl> Fn < void ( ) > SavePreparedTheme ( <nl> <nl> const auto creating = ! fields . id <nl> | | ( fields . createdBy ! = session - > userId ( ) ) ; <nl> + const auto oldDocumentId = creating ? 0 : fields . documentId ; <nl> const auto changed = ( parsed . background ! = originalParsed . background ) <nl> | | ( parsed . tiled ! = originalParsed . tiled ) <nl> | | PaletteChanged ( parsed . palette , originalParsed . palette , fields ) ; <nl> Fn < void ( ) > SavePreparedTheme ( <nl> } ) . send ( ) ; <nl> } ; <nl> <nl> - const auto uploadTheme = [ = ] ( const UploadedDocument & data ) { <nl> + const auto uploadTheme = [ = ] ( const UploadedThumbDocument & data ) { <nl> state - > requestId = api - > request ( MTPaccount_UploadTheme ( <nl> - MTP_flags ( 0 ) , <nl> + MTP_flags ( MTPaccount_UploadTheme : : Flag : : f_thumb ) , <nl> data . file , <nl> - MTPInputFile ( ) , / / thumb <nl> + data . thumb , <nl> MTP_string ( state - > filename ) , <nl> MTP_string ( " application / x - tgtheme - tdesktop " ) <nl> ) ) . done ( [ = ] ( const MTPDocument & result ) { <nl> Fn < void ( ) > SavePreparedTheme ( <nl> state - > filename = media . filename ; <nl> state - > themeContent = theme ; <nl> <nl> - session - > uploader ( ) . documentReady ( <nl> - ) | rpl : : filter ( [ = ] ( const UploadedDocument & data ) { <nl> + session - > uploader ( ) . thumbDocumentReady ( <nl> + ) | rpl : : filter ( [ = ] ( const UploadedThumbDocument & data ) { <nl> return data . fullId = = state - > id ; <nl> - } ) | rpl : : start_with_next ( [ = ] ( const UploadedDocument & data ) { <nl> + } ) | rpl : : start_with_next ( [ = ] ( const UploadedThumbDocument & data ) { <nl> uploadTheme ( data ) ; <nl> } , state - > lifetime ) ; <nl> <nl> mmm a / Telegram / SourceFiles / window / themes / window_theme_preview . cpp <nl> ppp b / Telegram / SourceFiles / window / themes / window_theme_preview . cpp <nl> QString fillLetters ( const QString & name ) { <nl> <nl> class Generator { <nl> public : <nl> - Generator ( const Instance & theme , CurrentData & & current ) ; <nl> + Generator ( <nl> + const Instance & theme , <nl> + CurrentData & & current , <nl> + PreviewType type ) ; <nl> <nl> - QImage generate ( ) ; <nl> + [ [ nodiscard ] ] QImage generate ( ) ; <nl> <nl> private : <nl> enum class Status { <nl> class Generator { <nl> Ui : : Text : : String replyText = { st : : msgMinWidth } ; <nl> } ; <nl> <nl> + [ [ nodiscard ] ] bool extended ( ) const ; <nl> void prepare ( ) ; <nl> <nl> void addRow ( QString name , int peerIndex , QString date , QString text ) ; <nl> class Generator { <nl> <nl> const Instance & _theme ; <nl> const style : : palette & _palette ; <nl> - CurrentData _current ; <nl> + const CurrentData _current ; <nl> + const PreviewType _type ; <nl> Painter * _p = nullptr ; <nl> <nl> QRect _rect ; <nl> class Generator { <nl> <nl> } ; <nl> <nl> + bool Generator : : extended ( ) const { <nl> + return ( _type = = PreviewType : : Extended ) ; <nl> + } <nl> + <nl> void Generator : : prepare ( ) { <nl> - _rect = QRect ( 0 , 0 , st : : themePreviewMargin . left ( ) + st : : themePreviewSize . width ( ) + st : : themePreviewMargin . right ( ) , st : : themePreviewMargin . top ( ) + st : : themePreviewSize . height ( ) + st : : themePreviewMargin . bottom ( ) ) ; <nl> - _inner = _rect . marginsRemoved ( st : : themePreviewMargin ) ; <nl> - _body = _inner . marginsRemoved ( QMargins ( 0 , Platform : : PreviewTitleHeight ( ) , 0 , 0 ) ) ; <nl> + const auto size = extended ( ) <nl> + ? QRect ( <nl> + QPoint ( ) , <nl> + st : : themePreviewSize ) . marginsAdded ( st : : themePreviewMargin ) . size ( ) <nl> + : st : : themePreviewSize ; <nl> + _rect = QRect ( QPoint ( ) , size ) ; <nl> + _inner = extended ( ) ? _rect . marginsRemoved ( st : : themePreviewMargin ) : _rect ; <nl> + _body = extended ( ) ? _inner . marginsRemoved ( QMargins ( 0 , Platform : : PreviewTitleHeight ( ) , 0 , 0 ) ) : _inner ; <nl> _dialogs = QRect ( _body . x ( ) , _body . y ( ) , st : : themePreviewDialogsWidth , _body . height ( ) ) ; <nl> _dialogsList = _dialogs . marginsRemoved ( QMargins ( 0 , st : : dialogsFilterPadding . y ( ) + st : : dialogsMenuToggle . height + st : : dialogsFilterPadding . y ( ) , 0 , st : : dialogsPadding . y ( ) ) ) ; <nl> _topBar = QRect ( _dialogs . x ( ) + _dialogs . width ( ) , _dialogs . y ( ) , _body . width ( ) - _dialogs . width ( ) , st : : topBarHeight ) ; <nl> void Generator : : generateData ( ) { <nl> _bubbles . back ( ) . replyText . setText ( st : : messageTextStyle , " Mark Twain said that " + QString ( ) + QChar ( 9757 ) + QChar ( 55356 ) + QChar ( 57339 ) , Ui : : DialogTextOptions ( ) ) ; <nl> } <nl> <nl> - Generator : : Generator ( const Instance & theme , CurrentData & & current ) <nl> + Generator : : Generator ( <nl> + const Instance & theme , <nl> + CurrentData & & current , <nl> + PreviewType type ) <nl> : _theme ( theme ) <nl> , _palette ( _theme . palette ) <nl> - , _current ( std : : move ( current ) ) { <nl> + , _current ( std : : move ( current ) ) <nl> + , _type ( type ) { <nl> } <nl> <nl> QImage Generator : : generate ( ) { <nl> QImage Generator : : generate ( ) { <nl> paintDialogs ( ) ; <nl> paintHistoryShadows ( ) ; <nl> } <nl> - Platform : : PreviewWindowFramePaint ( result , _palette , _body , _rect . width ( ) ) ; <nl> + if ( extended ( ) ) { <nl> + Platform : : PreviewWindowFramePaint ( result , _palette , _body , _rect . width ( ) ) ; <nl> + } <nl> <nl> return result ; <nl> } <nl> std : : unique_ptr < Preview > GeneratePreview ( <nl> const QByteArray & bytes , <nl> const QString & filepath , <nl> const Data : : CloudTheme & cloud , <nl> - CurrentData & & data ) { <nl> + CurrentData & & data , <nl> + PreviewType type ) { <nl> auto result = PreviewFromFile ( bytes , filepath , cloud ) ; <nl> if ( ! result ) { <nl> return nullptr ; <nl> } <nl> result - > preview = Generator ( <nl> result - > instance , <nl> - std : : move ( data ) <nl> + std : : move ( data ) , <nl> + type <nl> ) . generate ( ) ; <nl> return result ; <nl> } <nl> <nl> + QImage GeneratePreview ( <nl> + const QByteArray & bytes , <nl> + const QString & filepath ) { <nl> + const auto preview = GeneratePreview ( <nl> + bytes , <nl> + filepath , <nl> + Data : : CloudTheme ( ) , <nl> + CurrentData { Data : : ThemeWallPaper ( ) . id ( ) } , <nl> + PreviewType : : Normal ) ; <nl> + return preview ? preview - > preview : QImage ( ) ; <nl> + } <nl> + <nl> int DefaultPreviewTitleHeight ( ) { <nl> return st : : titleHeight ; <nl> } <nl> mmm a / Telegram / SourceFiles / window / themes / window_theme_preview . h <nl> ppp b / Telegram / SourceFiles / window / themes / window_theme_preview . h <nl> namespace Window { <nl> namespace Theme { <nl> <nl> struct CurrentData { <nl> - int32 backgroundId = 0 ; <nl> + WallPaperId backgroundId = 0 ; <nl> QImage backgroundImage ; <nl> bool backgroundTiled = false ; <nl> } ; <nl> <nl> + enum class PreviewType { <nl> + Normal , <nl> + Extended , <nl> + } ; <nl> + <nl> [ [ nodiscard ] ] QString CachedThemePath ( uint64 documentId ) ; <nl> <nl> std : : unique_ptr < Preview > PreviewFromFile ( <nl> std : : unique_ptr < Preview > GeneratePreview ( <nl> const QByteArray & bytes , <nl> const QString & filepath , <nl> const Data : : CloudTheme & cloud , <nl> - CurrentData & & data ) ; <nl> + CurrentData & & data , <nl> + PreviewType type ) ; <nl> + QImage GeneratePreview ( <nl> + const QByteArray & bytes , <nl> + const QString & filepath ) ; <nl> <nl> int DefaultPreviewTitleHeight ( ) ; <nl> void DefaultPreviewWindowFramePaint ( <nl> mmm a / Telegram / gyp / telegram_sources . txt <nl> ppp b / Telegram / gyp / telegram_sources . txt <nl> <nl> < ( src_loc ) / history / view / media / history_view_poll . cpp <nl> < ( src_loc ) / history / view / media / history_view_sticker . h <nl> < ( src_loc ) / history / view / media / history_view_sticker . cpp <nl> + < ( src_loc ) / history / view / media / history_view_theme_document . h <nl> + < ( src_loc ) / history / view / media / history_view_theme_document . cpp <nl> < ( src_loc ) / history / view / media / history_view_video . h <nl> < ( src_loc ) / history / view / media / history_view_video . cpp <nl> - < ( src_loc ) / history / view / media / history_view_wall_paper . h <nl> - < ( src_loc ) / history / view / media / history_view_wall_paper . cpp <nl> < ( src_loc ) / history / view / media / history_view_web_page . h <nl> < ( src_loc ) / history / view / media / history_view_web_page . cpp <nl> < ( src_loc ) / history / view / history_view_compose_controls . cpp <nl> | Generate previews for cloud theme links . | telegramdesktop/tdesktop | ee5423762a17aaea4f18f0fdc6ccad1372d794c6 | 2019-09-09T11:56:05Z |
mmm a / hphp / hack / src / hhbc / hhbc_ast . ml <nl> ppp b / hphp / hack / src / hhbc / hhbc_ast . ml <nl> type instruct_lit_const = <nl> | Int of int64 <nl> | Double of float <nl> | String of Litstr . id <nl> - | Array of int <nl> + | Array of int * Litstr . id * instruct_lit_const list <nl> | Vec of int ( * scalar vec id * ) <nl> | Dict of int ( * scalar dict id * ) <nl> | Keyset of int ( * scalar keyset id * ) <nl> mmm a / hphp / hack / src / hhbc / hhbc_from_nast . ml <nl> ppp b / hphp / hack / src / hhbc / hhbc_from_nast . ml <nl> let rec from_expr expr = <nl> emit_args_and_call args uargs ; <nl> instr ( IBasic PopR ) <nl> ] <nl> - <nl> + | A . Array es - > <nl> + let a_label = Label . get_next_data_label ( ) in <nl> + ( * We need to make sure everything is literal to use static construction * ) <nl> + let all_literal = List . for_all es <nl> + ~ f : ( function A . AFvalue e - > is_literal e <nl> + | A . AFkvalue ( k , v ) - > is_literal k & & is_literal v ) <nl> + in <nl> + if all_literal then begin <nl> + ( * Arrays can either contains values or key / value pairs * ) <nl> + let _ , es = <nl> + List . fold_left <nl> + es <nl> + ~ init : ( 0 , [ ] ) <nl> + ~ f : ( fun ( index , l ) x - > <nl> + ( index + 1 , match x with <nl> + | A . AFvalue e - > <nl> + literal_from_expr e : : Int ( Int64 . of_int index ) : : l <nl> + | A . AFkvalue ( k , v ) - > <nl> + literal_from_expr v : : literal_from_expr k : : l ) <nl> + ) <nl> + in <nl> + gather [ <nl> + instr ( ILitConst ( Array ( a_label , " a " , List . rev es ) ) ) ; <nl> + ] <nl> + end else <nl> + emit_nyi " non static arrays " <nl> | _ - > <nl> emit_nyi " expression " <nl> <nl> and emit_flavored_expr ( _ , expr_ as expr ) = <nl> | _ - > <nl> from_expr expr , Flavor_C <nl> <nl> + and is_literal expr = <nl> + match snd expr with <nl> + | A . Float _ <nl> + | A . String _ <nl> + | A . Int _ <nl> + | A . Null <nl> + | A . False <nl> + | A . True - > true <nl> + | _ - > false <nl> + <nl> + and literal_from_expr expr = <nl> + match snd expr with <nl> + | A . Float ( _ , litstr ) - > Double ( float_of_string litstr ) <nl> + | A . String ( _ , litstr ) - > String litstr <nl> + | A . Int ( _ , litstr ) - > Int ( Int64 . of_string litstr ) <nl> + | A . Null - > Null <nl> + | A . False - > False <nl> + | A . True - > True <nl> + | _ - > failwith " literal_from_expr - NYI " <nl> + <nl> and literal_from_named_expr expr = <nl> match snd expr with <nl> | N . Float ( _ , litstr ) - > Double ( float_of_string litstr ) <nl> and literal_from_named_expr expr = <nl> " Expected a literal expression in literal_from_named_expr , got % s " <nl> ( N . expr_to_string ( snd expr ) ) ) <nl> <nl> - and literals_from_named_exprs exprs = <nl> - List . map exprs literal_from_named_expr <nl> + and literals_from_named_exprs_with_index exprs = <nl> + List . rev @ @ snd @ @ <nl> + List . fold_left <nl> + exprs <nl> + ~ init : ( 0 , [ ] ) <nl> + ~ f : ( fun ( index , l ) e - > <nl> + ( index + 1 , literal_from_named_expr e : : Int ( Int64 . of_int index ) : : l ) ) <nl> <nl> ( * Emit code for an l - value , returning instructions and the location that <nl> * must be set . For now , this is just a local . * ) <nl> let from_fun_ : Nast . fun_ - > Hhas_function . t option = <nl> let from_functions nast_functions = <nl> Core . List . filter_map nast_functions from_fun_ <nl> <nl> + let from_attribute_base attribute_name arguments = <nl> + let attribute_arguments = literals_from_named_exprs_with_index arguments in <nl> + Hhas_attribute . make attribute_name attribute_arguments <nl> + <nl> let from_attribute : Nast . user_attribute - > Hhas_attribute . t = <nl> fun nast_attr - > <nl> let attribute_name = Litstr . to_string @ @ snd nast_attr . Nast . ua_name in <nl> - let attribute_arguments = literals_from_named_exprs nast_attr . Nast . ua_params in <nl> - Hhas_attribute . make attribute_name attribute_arguments <nl> + from_attribute_base attribute_name nast_attr . Nast . ua_params <nl> <nl> let from_attributes nast_attributes = <nl> ( * The list of attributes is reversed in the Nast . * ) <nl> mmm a / hphp / hack / src / hhbc / hhbc_hhas . ml <nl> ppp b / hphp / hack / src / hhbc / hhbc_hhas . ml <nl> let string_of_lit_const instruction = <nl> | True - > " True " <nl> | False - > " False " <nl> | Double d - > " Double " ^ string_of_float d <nl> + | Array ( i , _ , _ ) - > " Array @ A_ " ^ string_of_int i <nl> | _ - > failwith " unexpected literal kind in string_of_lit_const " <nl> <nl> let string_of_operator instruction = <nl> let add_fun_def buf fun_def = <nl> add_instruction_list buf 2 function_body ; <nl> B . add_string buf " } \ n " <nl> <nl> - let attribute_argument_to_string index argument = <nl> + let attribute_argument_to_string argument = <nl> let value = match argument with <nl> | Null - > " N " <nl> | Double f - > Printf . sprintf " d : % f " f <nl> let attribute_argument_to_string index argument = <nl> | True - > " i : 1 " <nl> | Int i - > " i : " ^ ( Int64 . to_string i ) <nl> | _ - > failwith " unexpected value in attribute_argument_to_string " in <nl> - Printf . sprintf " i : % d ; % s ; " index value <nl> + Printf . sprintf " % s ; " value <nl> <nl> let attribute_arguments_to_string arguments = <nl> - let rec aux index arguments acc = <nl> + let rec aux arguments acc = <nl> match arguments with <nl> - | h : : t - > aux ( index + 1 ) t ( acc ^ attribute_argument_to_string index h ) <nl> + | h : : t - > aux t ( acc ^ attribute_argument_to_string h ) <nl> | _ - > acc in <nl> - aux 0 arguments " " <nl> + aux arguments " " <nl> + <nl> + let attribute_to_string_helper ~ if_class_attribute name args = <nl> + let count = List . length args in <nl> + let count = <nl> + if count mod 2 = 0 then count / 2 <nl> + else failwith " attribute string should have even amount of arguments " <nl> + in <nl> + let arguments = attribute_arguments_to_string args in <nl> + let attribute_str = format_of_string @ @ <nl> + if if_class_attribute <nl> + then " \ " % s \ " ( \ " \ " \ " a : % n : { % s } \ " \ " \ " ) " <nl> + else " \ " \ " \ " % s : % n : { % s } \ " \ " \ " " <nl> + in <nl> + Printf . sprintf attribute_str name count arguments <nl> <nl> let attribute_to_string a = <nl> let name = Hhas_attribute . name a in <nl> let args = Hhas_attribute . arguments a in <nl> - let count = List . length args in <nl> - let arguments = attribute_arguments_to_string args in <nl> - Printf . sprintf " \ " % s \ " ( \ " \ " \ " a : % n : { % s } \ " \ " \ " ) " name count arguments <nl> + attribute_to_string_helper ~ if_class_attribute : true name args <nl> <nl> let method_attributes m = <nl> let user_attrs = Hhas_method . attributes m in <nl> let add_defcls buf classes = <nl> ( fun count _ - > B . add_string buf ( Printf . sprintf " DefCls % n \ n " count ) ) <nl> classes <nl> <nl> + let add_data_region buf functions = <nl> + let rec add_data_region_list buf instr = <nl> + List . iter ( add_data_region_aux buf ) instr <nl> + and add_data_region_aux buf = function <nl> + | ILitConst ( Array ( num , name , arguments ) ) - > <nl> + B . add_string buf " . adata A_ " ; <nl> + B . add_string buf @ @ string_of_int num ; <nl> + B . add_string buf " = " ; <nl> + B . add_string buf <nl> + @ @ attribute_to_string_helper ~ if_class_attribute : false name arguments ; <nl> + B . add_string buf " ; \ n " <nl> + | ITryFault ( _ , il , _ ) <nl> + | ITryCatch ( _ , il ) - > add_data_region_list buf il <nl> + | _ - > ( ) <nl> + and iter_aux buf fun_def = <nl> + let function_body = Hhas_function . body fun_def in <nl> + add_data_region_list buf function_body <nl> + in <nl> + List . iter ( iter_aux buf ) functions ; <nl> + B . add_string buf " \ n " <nl> + <nl> let add_top_level buf hhas_prog = <nl> let main_stmts = <nl> [ ILitConst ( Int Int64 . one ) <nl> let add_top_level buf hhas_prog = <nl> <nl> let add_program buf hhas_prog = <nl> B . add_string buf " # starts here \ n " ; <nl> + let functions = Hhas_program . functions hhas_prog in <nl> + add_data_region buf functions ; <nl> add_top_level buf hhas_prog ; <nl> - List . iter ( add_fun_def buf ) ( Hhas_program . functions hhas_prog ) ; <nl> + List . iter ( add_fun_def buf ) functions ; <nl> List . iter ( add_class_def buf ) ( Hhas_program . classes hhas_prog ) ; <nl> B . add_string buf " \ n # ends here \ n " <nl> <nl> mmm a / hphp / hack / src / hhbc / label . ml <nl> ppp b / hphp / hack / src / hhbc / label . ml <nl> <nl> <nl> type label = int <nl> <nl> + ( * Numbers for string label * ) <nl> let next_label = ref 0 <nl> <nl> let get_next_label ( ) = <nl> let get_next_label ( ) = <nl> <nl> let reset_label ( ) = <nl> next_label : = 0 <nl> + <nl> + ( * Numbers for array , map , dict , set , shape labels * ) <nl> + let next_data_label = ref 0 <nl> + <nl> + let get_next_data_label ( ) = <nl> + let current = ! next_data_label in <nl> + next_data_label : = current + 1 ; <nl> + current <nl> | Add static array construction , both only values and key / value pairs | facebook/hhvm | 73901cb6f3b7d38f74f202c6e93995adb7eb6939 | 2017-02-27T23:48:42Z |
mmm a / system / include / emscripten / bind . h <nl> ppp b / system / include / emscripten / bind . h <nl> <nl> # include < type_traits > <nl> # include < emscripten / val . h > <nl> # include < emscripten / wire . h > <nl> - # include " northstar / Pointer . h " <nl> <nl> namespace emscripten { <nl> enum class sharing_policy { <nl> namespace emscripten { <nl> } ; <nl> } ; <nl> <nl> - template < typename PointeeType > <nl> - struct smart_ptr_trait < northstar : : IntrusivePointer < PointeeType > > { <nl> - typedef northstar : : IntrusivePointer < PointeeType > PointerType ; <nl> - typedef typename PointerType : : element_type element_type ; <nl> - <nl> - static element_type * get ( const PointerType & ptr ) { <nl> - return ptr . get ( ) ; <nl> - } <nl> - <nl> - static northstar : : IntrusivePointer < PointeeType > * share ( PointeeType * p , internal : : EM_VAL v ) { <nl> - return new northstar : : IntrusivePointer < PointeeType > ( p ) ; <nl> - } <nl> - <nl> - static sharing_policy get_sharing_policy ( ) { <nl> - return sharing_policy : : INTRUSIVE ; <nl> - } <nl> - } ; <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / CLASSES <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> | Removed dependency on Northstar . | emscripten-core/emscripten | ebb2069d804f49b457f6a4349a3136703db60190 | 2013-04-18T17:08:08Z |
mmm a / src / dbg / x64_dbg . cpp <nl> ppp b / src / dbg / x64_dbg . cpp <nl> <nl> # include " x64_dbg . h " <nl> # include " msgqueue . h " <nl> # include " threading . h " <nl> + # include " watch . h " <nl> # include " plugin_loader . h " <nl> # include " _dbgfunctions . h " <nl> # include " debugger_commands . h " <nl> <nl> # include " datainst_helper . h " <nl> # include " error . h " <nl> # include " exception . h " <nl> + # include " historycontext . h " <nl> <nl> static MESSAGE_STACK * gMsgStack = 0 ; <nl> static HANDLE hCommandLoopThread = 0 ; <nl> static void registercommands ( ) <nl> dbgcmdnew ( " StopDebug \ 1stop \ 1dbgstop " , cbDebugStop , true ) ; / / stop debugger <nl> dbgcmdnew ( " AttachDebugger \ 1attach " , cbDebugAttach , false ) ; / / attach <nl> dbgcmdnew ( " DetachDebugger \ 1detach " , cbDebugDetach , true ) ; / / detach <nl> - dbgcmdnew ( " run \ 1go \ 1r \ 1g " , cbDebugRun , true ) ; / / unlock WAITID_RUN <nl> + dbgcmdnew ( " run \ 1go \ 1r \ 1g " , cbDebugRun2 , true ) ; / / unlock WAITID_RUN <nl> dbgcmdnew ( " erun \ 1egun \ 1er \ 1eg " , cbDebugErun , true ) ; / / run + skip first chance exceptions <nl> dbgcmdnew ( " pause " , cbDebugPause , true ) ; / / pause debugger <nl> dbgcmdnew ( " StepInto \ 1sti " , cbDebugStepInto , true ) ; / / StepInto <nl> static void registercommands ( ) <nl> dbgcmdnew ( " skip " , cbDebugSkip , true ) ; / / skip one instruction <nl> dbgcmdnew ( " RunToParty " , cbDebugRunToParty , true ) ; / / Run to code in a party <nl> dbgcmdnew ( " RunToUserCode \ 1rtu " , cbDebugRtu , true ) ; / / Run to user code <nl> + dbgcmdnew ( " InstrUndo " , cbInstrInstrUndo , true ) ; / / Instruction undo <nl> <nl> / / breakpoints <nl> dbgcmdnew ( " bplist " , cbDebugBplist , true ) ; / / breakpoint list <nl> static void registercommands ( ) <nl> <nl> dbgcmdnew ( " bpgoto " , cbDebugSetBPGoto , true ) ; <nl> <nl> + / / watch <nl> + dbgcmdnew ( " AddWatch " , cbAddWatch , true ) ; / / add watch <nl> + dbgcmdnew ( " DelWatch " , cbDelWatch , true ) ; / / delete watch <nl> + dbgcmdnew ( " CheckWatchdog " , cbWatchdog , true ) ; / / Watchdog <nl> + dbgcmdnew ( " SetWatchdog " , cbSetWatchdog , true ) ; / / Setup watchdog <nl> + dbgcmdnew ( " SetWatchName " , cbSetWatchName , true ) ; / / Set watch name <nl> + dbgcmdnew ( " SetWatchExpression " , cbSetWatchExpression , true ) ; / / Set watch expression <nl> + <nl> / / variables <nl> dbgcmdnew ( " varnew \ 1var " , cbInstrVar , false ) ; / / make a variable arg1 : name , [ arg2 : value ] <nl> dbgcmdnew ( " vardel " , cbInstrVarDel , false ) ; / / delete a variable , arg1 : variable name <nl> | instruction undo , watch view | x64dbg/x64dbg | 8504ac24f3082e44408d2f24191b6690e185254c | 2016-07-07T03:37:20Z |
mmm a / include / swift / AST / Decl . h <nl> ppp b / include / swift / AST / Decl . h <nl> class alignas ( 1 < < DeclAlignInBits ) Decl { <nl> / / / for instance , self . <nl> bool isUserAccessible ( ) const ; <nl> <nl> + / / / Determine if the decl can have a comment . If false , a comment will <nl> + / / / not be serialized . <nl> + bool canHaveComment ( ) const ; <nl> + <nl> DeclContext * getDeclContext ( ) const { <nl> if ( auto dc = Context . dyn_cast < DeclContext * > ( ) ) <nl> return dc ; <nl> mmm a / lib / AST / Decl . cpp <nl> ppp b / lib / AST / Decl . cpp <nl> bool Decl : : isUserAccessible ( ) const { <nl> return true ; <nl> } <nl> <nl> + bool Decl : : canHaveComment ( ) const { <nl> + return ! this - > hasClangNode ( ) & & <nl> + ( isa < ValueDecl > ( this ) | | isa < ExtensionDecl > ( this ) ) & & <nl> + ! isa < ParamDecl > ( this ) & & <nl> + ( ! isa < AbstractTypeParamDecl > ( this ) | | isa < AssociatedTypeDecl > ( this ) ) ; <nl> + } <nl> + <nl> Module * Decl : : getModuleContext ( ) const { <nl> return getDeclContext ( ) - > getParentModule ( ) ; <nl> } <nl> mmm a / lib / AST / RawComment . cpp <nl> ppp b / lib / AST / RawComment . cpp <nl> SingleRawComment : : SingleRawComment ( StringRef RawText , unsigned StartColumn ) <nl> : RawText ( RawText ) , Kind ( static_cast < unsigned > ( getCommentKind ( RawText ) ) ) , <nl> StartColumn ( StartColumn ) , StartLine ( 0 ) , EndLine ( 0 ) { } <nl> <nl> - static bool canHaveComment ( const Decl * D ) { <nl> - return ! D - > hasClangNode ( ) & & <nl> - ( isa < ValueDecl > ( D ) | | isa < ExtensionDecl > ( D ) ) & & <nl> - ! isa < ParamDecl > ( D ) & & <nl> - ( ! isa < AbstractTypeParamDecl > ( D ) | | isa < AssociatedTypeDecl > ( D ) ) ; <nl> - } <nl> - <nl> static void addCommentToList ( SmallVectorImpl < SingleRawComment > & Comments , <nl> const SingleRawComment & SRC ) { <nl> / / TODO : consider producing warnings when we decide not to merge comments . <nl> static RawComment toRawComment ( ASTContext & Context , CharSourceRange Range ) { <nl> } <nl> <nl> RawComment Decl : : getRawComment ( ) const { <nl> - if ( ! canHaveComment ( this ) ) <nl> + if ( ! this - > canHaveComment ( ) ) <nl> return RawComment ( ) ; <nl> <nl> / / Check the cache in ASTContext . <nl> static StringRef extractBriefComment ( ASTContext & Context , RawComment RC , <nl> const Decl * D ) { <nl> PrettyStackTraceDecl StackTrace ( " extracting brief comment for " , D ) ; <nl> <nl> - if ( ! canHaveComment ( D ) ) <nl> + if ( ! D - > canHaveComment ( ) ) <nl> return StringRef ( ) ; <nl> <nl> llvm : : markup : : MarkupContext MC ; <nl> static StringRef extractBriefComment ( ASTContext & Context , RawComment RC , <nl> } <nl> <nl> StringRef Decl : : getBriefComment ( ) const { <nl> - if ( ! canHaveComment ( this ) ) <nl> + if ( ! this - > canHaveComment ( ) ) <nl> return StringRef ( ) ; <nl> <nl> auto & Context = getASTContext ( ) ; <nl> mmm a / lib / Serialization / Serialization . cpp <nl> ppp b / lib / Serialization / Serialization . cpp <nl> static void writeDeclCommentTable ( <nl> if ( ! VD ) <nl> return true ; <nl> <nl> - / / Skip the decl if it does not have a comment . <nl> RawComment Raw = VD - > getRawComment ( ) ; <nl> - if ( Raw . Comments . empty ( ) & & ! GroupContext . isEnable ( ) ) <nl> - return true ; <nl> + / / When building the stdlib we intend to <nl> + / / serialize unusual comments . This situation is represented by <nl> + / / GroupContext . isEnable ( ) . In that case , we perform fewer serialization checks . <nl> + if ( ! GroupContext . isEnable ( ) ) { <nl> + / / Skip the decl if it cannot have a comment . <nl> + if ( ! VD - > canHaveComment ( ) ) { <nl> + return true ; <nl> + } <nl> + <nl> + / / Skip the decl if it does not have a comment . <nl> + if ( Raw . Comments . empty ( ) ) <nl> + return true ; <nl> + <nl> + / / Skip the decl if it ' s not visible to clients . <nl> + / / The use of getEffectiveAccess is unusual here ; <nl> + / / we want to take the testability state into account <nl> + / / and emit documentation if and only if they are visible to clients <nl> + / / ( which means public ordinarily , but public + internal when testing enabled ) . <nl> + if ( VD - > getEffectiveAccess ( ) ! = Accessibility : : Public ) <nl> + return true ; <nl> + } <nl> <nl> / / Compute USR . <nl> { <nl> mmm a / test / Inputs / comment_to_something_conversion . swift <nl> ppp b / test / Inputs / comment_to_something_conversion . swift <nl> <nl> / / <nl> / / Please keep this file in alphabetical order ! <nl> <nl> - @ objc class A000 { } <nl> + @ objc public class A000 { } <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> <nl> / / / Aaa . A010 . Bbb . <nl> - @ objc class A010_AttachToEntities { <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Class file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > A010_AttachToEntities < / Name > < USR > s : C14swift_ide_test21A010_AttachToEntities < / USR > < Declaration > @ objc class A010_AttachToEntities < / Declaration > < Abstract > < Para > Aaa . A010 . Bbb . < / Para > < / Abstract > < / Class > ] <nl> + @ objc public class A010_AttachToEntities { <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Class file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > A010_AttachToEntities < / Name > < USR > s : C14swift_ide_test21A010_AttachToEntities < / USR > < Declaration > @ objc public class A010_AttachToEntities < / Declaration > < Abstract > < Para > Aaa . A010 . Bbb . < / Para > < / Abstract > < / Class > ] <nl> <nl> / / / Aaa . init ( ) . <nl> - init ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > init ( ) < / Name > < USR > s : FC14swift_ide_test21A010_AttachToEntitiescFT_S0_ < / USR > < Declaration > init ( ) < / Declaration > < Abstract > < Para > Aaa . init ( ) . < / Para > < / Abstract > < / Function > ] <nl> + public init ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > init ( ) < / Name > < USR > s : FC14swift_ide_test21A010_AttachToEntitiescFT_S0_ < / USR > < Declaration > public init ( ) < / Declaration > < Abstract > < Para > Aaa . init ( ) . < / Para > < / Abstract > < / Function > ] <nl> <nl> / / / Aaa . subscript ( i : Int ) . <nl> - subscript ( i : Int ) - > Int { <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Other file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > subscript ( _ : ) < / Name > < USR > s : iC14swift_ide_test21A010_AttachToEntities9subscriptFSiSi < / USR > < Declaration > subscript ( i : Int ) - & gt ; Int { get set } < / Declaration > < Abstract > < Para > Aaa . subscript ( i : Int ) . < / Para > < / Abstract > < / Other > ] <nl> + public subscript ( i : Int ) - > Int { <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Other file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > subscript ( _ : ) < / Name > < USR > s : iC14swift_ide_test21A010_AttachToEntities9subscriptFSiSi < / USR > < Declaration > public subscript ( i : Int ) - & gt ; Int { get set } < / Declaration > < Abstract > < Para > Aaa . subscript ( i : Int ) . < / Para > < / Abstract > < / Other > ] <nl> get { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> return 0 <nl> subscript ( i : Int ) - > Int { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> <nl> / / / Aaa . v1 . <nl> - var v1 : Int = 0 <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Other file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > v1 < / Name > < USR > s : vC14swift_ide_test21A010_AttachToEntities2v1Si < / USR > < Declaration > var v1 : Int < / Declaration > < Abstract > < Para > Aaa . v1 . < / Para > < / Abstract > < / Other > ] <nl> + public var v1 : Int = 0 <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Other file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > v1 < / Name > < USR > s : vC14swift_ide_test21A010_AttachToEntities2v1Si < / USR > < Declaration > public var v1 : Int < / Declaration > < Abstract > < Para > Aaa . v1 . < / Para > < / Abstract > < / Other > ] <nl> <nl> / / / Aaa . v2 . <nl> - class var v2 : Int { return 0 } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Other file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > v2 < / Name > < USR > s : ZvC14swift_ide_test21A010_AttachToEntities2v2Si < / USR > < Declaration > class var v2 : Int { get } < / Declaration > < Abstract > < Para > Aaa . v2 . < / Para > < / Abstract > < / Other > ] <nl> + public class var v2 : Int { return 0 } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Other file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > v2 < / Name > < USR > s : ZvC14swift_ide_test21A010_AttachToEntities2v2Si < / USR > < Declaration > public class var v2 : Int { get } < / Declaration > < Abstract > < Para > Aaa . v2 . < / Para > < / Abstract > < / Other > ] <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> } <nl> <nl> / / / Aaa . A011 . <nl> - struct A011_AttachToEntities { <nl> + public struct A011_AttachToEntities { <nl> } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Class file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > A011_AttachToEntities < / Name > < USR > s : V14swift_ide_test21A011_AttachToEntities < / USR > < Declaration > struct A011_AttachToEntities < / Declaration > < Abstract > < Para > Aaa . A011 . < / Para > < / Abstract > < / Class > ] <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Class file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > A011_AttachToEntities < / Name > < USR > s : V14swift_ide_test21A011_AttachToEntities < / USR > < Declaration > public struct A011_AttachToEntities < / Declaration > < Abstract > < Para > Aaa . A011 . < / Para > < / Abstract > < / Class > ] <nl> <nl> / / / Aaa . A012 . <nl> - enum A012_AttachToEntities { <nl> + public enum A012_AttachToEntities { <nl> case A <nl> } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Other file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > A012_AttachToEntities < / Name > < USR > s : O14swift_ide_test21A012_AttachToEntities < / USR > < Declaration > enum A012_AttachToEntities < / Declaration > < Abstract > < Para > Aaa . A012 . < / Para > < / Abstract > < / Other > ] <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Other file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > A012_AttachToEntities < / Name > < USR > s : O14swift_ide_test21A012_AttachToEntities < / USR > < Declaration > public enum A012_AttachToEntities < / Declaration > < Abstract > < Para > Aaa . A012 . < / Para > < / Abstract > < / Other > ] <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> <nl> / / / Aaa . A013 . <nl> - @ objc protocol A013_AttachToEntities { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Class file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > A013_AttachToEntities < / Name > < USR > s : P14swift_ide_test21A013_AttachToEntities < / USR > < Declaration > @ objc protocol A013_AttachToEntities < / Declaration > < Abstract > < Para > Aaa . A013 . < / Para > < / Abstract > < / Class > ] <nl> + @ objc public protocol A013_AttachToEntities { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Class file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > A013_AttachToEntities < / Name > < USR > s : P14swift_ide_test21A013_AttachToEntities < / USR > < Declaration > @ objc public protocol A013_AttachToEntities < / Declaration > < Abstract > < Para > Aaa . A013 . < / Para > < / Abstract > < / Class > ] <nl> <nl> - @ objc class AutomaticLink { <nl> + @ objc public class AutomaticLink { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / And now for a URL . <nl> / / / <nl> / / / < http : / / developer . apple . com / swift / > <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test13AutomaticLink2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Abstract > < Para > And now for a URL . < / Para > < / Abstract > < Discussion > < Para > < Link href = " http : / / developer . apple . com / swift / " > http : / / developer . apple . com / swift / < / Link > < / Para > < / Discussion > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test13AutomaticLink2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Abstract > < Para > And now for a URL . < / Para > < / Abstract > < Discussion > < Para > < Link href = " http : / / developer . apple . com / swift / " > http : / / developer . apple . com / swift / < / Link > < / Para > < / Discussion > < / Function > ] <nl> } <nl> <nl> - @ objc class BlockQuote { <nl> + @ objc public class BlockQuote { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / Aaa . <nl> / / / <nl> / / / > Bbb . <nl> / / / <nl> / / / > Ccc . <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test10BlockQuote2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < Discussion > < Para > Bbb . < / Para > < Para > Ccc . < / Para > < / Discussion > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test10BlockQuote2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < Discussion > < Para > Bbb . < / Para > < Para > Ccc . < / Para > < / Discussion > < / Function > ] <nl> } <nl> <nl> - @ objc class ATXHeaders { <nl> + @ objc public class ATXHeaders { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / LEVEL ONE <nl> / / / = = = = = = = = = <nl> / / / <nl> / / / LEVEL TWO <nl> / / / mmmmmmmmm <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test10ATXHeaders2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Discussion > < rawHTML > < ! [ CDATA [ < h1 > ] ] > < / rawHTML > LEVEL ONE < rawHTML > < ! [ CDATA [ < / h1 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h2 > ] ] > < / rawHTML > LEVEL TWO < rawHTML > < ! [ CDATA [ < / h2 > ] ] > < / rawHTML > < / Discussion > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test10ATXHeaders2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Discussion > < rawHTML > < ! [ CDATA [ < h1 > ] ] > < / rawHTML > LEVEL ONE < rawHTML > < ! [ CDATA [ < / h1 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h2 > ] ] > < / rawHTML > LEVEL TWO < rawHTML > < ! [ CDATA [ < / h2 > ] ] > < / rawHTML > < / Discussion > < / Function > ] <nl> } <nl> <nl> - @ objc class Brief { <nl> + @ objc public class Brief { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / Aaa . <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test5Brief2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test5Brief2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < / Function > ] <nl> <nl> / / / Aaa . <nl> / / / <nl> / / / Bbb . <nl> - func f1 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f1 ( ) < / Name > < USR > s : FC14swift_ide_test5Brief2f1FT_T_ < / USR > < Declaration > func f1 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Function > ] <nl> + public func f1 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f1 ( ) < / Name > < USR > s : FC14swift_ide_test5Brief2f1FT_T_ < / USR > < Declaration > public func f1 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Function > ] <nl> <nl> / / / Aaa . <nl> / / / <nl> / / / > Bbb . <nl> - func f2 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f2 ( ) < / Name > < USR > s : FC14swift_ide_test5Brief2f2FT_T_ < / USR > < Declaration > func f2 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Function > ] <nl> + public func f2 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f2 ( ) < / Name > < USR > s : FC14swift_ide_test5Brief2f2FT_T_ < / USR > < Declaration > public func f2 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Function > ] <nl> <nl> / / / Aaa . <nl> / / / <nl> / / / Bbb . <nl> - func f3 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f3 ( ) < / Name > < USR > s : FC14swift_ide_test5Brief2f3FT_T_ < / USR > < Declaration > func f3 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Function > ] <nl> + public func f3 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f3 ( ) < / Name > < USR > s : FC14swift_ide_test5Brief2f3FT_T_ < / USR > < Declaration > public func f3 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Function > ] <nl> } <nl> <nl> - @ objc class CodeBlock { <nl> + @ objc public class CodeBlock { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / This is how you use this code . <nl> / / / <nl> / / / f0 ( ) / / WOW ! <nl> / / / f0 ( ) / / WOW ! <nl> / / / f0 ( ) / / WOW ! <nl> - func f0 ( ) { } <nl> - / / CHECK : DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test9CodeBlock2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Abstract > < Para > This is how you use this code . < / Para > < / Abstract > < Discussion > < CodeListing language = " swift " > < zCodeLineNumbered > < ! [ CDATA [ f0 ( ) / / WOW ! ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ f0 ( ) / / WOW ! ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ f0 ( ) / / WOW ! ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < / zCodeLineNumbered > < / CodeListing > < / Discussion > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test9CodeBlock2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Abstract > < Para > This is how you use this code . < / Para > < / Abstract > < Discussion > < CodeListing language = " swift " > < zCodeLineNumbered > < ! [ CDATA [ f0 ( ) / / WOW ! ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ f0 ( ) / / WOW ! ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ f0 ( ) / / WOW ! ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < / zCodeLineNumbered > < / CodeListing > < / Discussion > < / Function > ] <nl> } <nl> <nl> - @ objc class EmptyComments { <nl> + @ objc public class EmptyComments { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> <nl> / / / <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test13EmptyComments2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test13EmptyComments2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < / Function > ] <nl> <nl> / / / Aaa . <nl> - func f1 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f1 ( ) < / Name > < USR > s : FC14swift_ide_test13EmptyComments2f1FT_T_ < / USR > < Declaration > func f1 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < / Function > ] <nl> + public func f1 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f1 ( ) < / Name > < USR > s : FC14swift_ide_test13EmptyComments2f1FT_T_ < / USR > < Declaration > public func f1 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < / Function > ] <nl> <nl> / * * * / <nl> - func f2 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f2 ( ) < / Name > < USR > s : FC14swift_ide_test13EmptyComments2f2FT_T_ < / USR > < Declaration > func f2 ( ) < / Declaration > < / Function > ] <nl> + public func f2 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f2 ( ) < / Name > < USR > s : FC14swift_ide_test13EmptyComments2f2FT_T_ < / USR > < Declaration > public func f2 ( ) < / Declaration > < / Function > ] <nl> <nl> / * * <nl> * / <nl> - func f3 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f3 ( ) < / Name > < USR > s : FC14swift_ide_test13EmptyComments2f3FT_T_ < / USR > < Declaration > func f3 ( ) < / Declaration > < / Function > ] <nl> + public func f3 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f3 ( ) < / Name > < USR > s : FC14swift_ide_test13EmptyComments2f3FT_T_ < / USR > < Declaration > public func f3 ( ) < / Declaration > < / Function > ] <nl> <nl> / * * <nl> * Aaa . <nl> * / <nl> - func f4 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f4 ( ) < / Name > < USR > s : FC14swift_ide_test13EmptyComments2f4FT_T_ < / USR > < Declaration > func f4 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < / Function > ] <nl> + public func f4 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f4 ( ) < / Name > < USR > s : FC14swift_ide_test13EmptyComments2f4FT_T_ < / USR > < Declaration > public func f4 ( ) < / Declaration > < Abstract > < Para > Aaa . < / Para > < / Abstract > < / Function > ] <nl> } <nl> <nl> - @ objc class Emphasis { <nl> + @ objc public class Emphasis { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / Aaa * bbb * ccc . <nl> / / / Aaa _bbb_ ccc . <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test8Emphasis2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Abstract > < Para > Aaa < emphasis > bbb < / emphasis > ccc . Aaa < emphasis > bbb < / emphasis > ccc . < / Para > < / Abstract > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test8Emphasis2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Abstract > < Para > Aaa < emphasis > bbb < / emphasis > ccc . Aaa < emphasis > bbb < / emphasis > ccc . < / Para > < / Abstract > < / Function > ] <nl> } <nl> <nl> - @ objc class HasThrowingFunction { <nl> + @ objc public class HasThrowingFunction { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> <nl> / / / Might throw something . <nl> / / / <nl> / / / - parameter x : A number <nl> / / / - throws : An error if ` x = = 0 ` <nl> - @ objc func f1 ( x : Int ) / * throws * / { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f1 ( _ : ) < / Name > < USR > s : FC14swift_ide_test19HasThrowingFunction2f1FSiT_ < / USR > < Declaration > @ objc func f1 ( x : Int ) < / Declaration > < Abstract > < Para > Might throw something . < / Para > < / Abstract > < Parameters > < Parameter > < Name > x < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < / Parameters > < ThrowsDiscussion > < Para > An error if < codeVoice > x = = 0 < / codeVoice > < / Para > < / ThrowsDiscussion > < / Function > ] <nl> + @ objc public func f1 ( x : Int ) / * throws * / { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f1 ( _ : ) < / Name > < USR > s : FC14swift_ide_test19HasThrowingFunction2f1FSiT_ < / USR > < Declaration > @ objc public func f1 ( x : Int ) < / Declaration > < Abstract > < Para > Might throw something . < / Para > < / Abstract > < Parameters > < Parameter > < Name > x < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < / Parameters > < ThrowsDiscussion > < Para > An error if < codeVoice > x = = 0 < / codeVoice > < / Para > < / ThrowsDiscussion > < / Function > ] <nl> } <nl> <nl> - @ objc class HorizontalRules { <nl> + @ objc public class HorizontalRules { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / Briefly . <nl> / / / <nl> / / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> / / / <nl> / / / The end . <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test15HorizontalRules2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Abstract > < Para > Briefly . < / Para > < / Abstract > < Discussion > < rawHTML > < ! [ CDATA [ < hr / > ] ] > < / rawHTML > < Para > The end . < / Para > < / Discussion > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test15HorizontalRules2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Abstract > < Para > Briefly . < / Para > < / Abstract > < Discussion > < rawHTML > < ! [ CDATA [ < hr / > ] ] > < / rawHTML > < Para > The end . < / Para > < / Discussion > < / Function > ] <nl> } <nl> <nl> - @ objc class ImplicitNameLink { <nl> + @ objc public class ImplicitNameLink { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / [ Apple ] [ ] <nl> / / / <nl> / / / [ Apple ] : https : / / www . apple . com / <nl> - func f0 ( ) { } <nl> + public func f0 ( ) { } <nl> } <nl> <nl> - @ objc class InlineCode { <nl> + @ objc public class InlineCode { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / Aaa ` bbb ` ccc . <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test10InlineCode2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Abstract > < Para > Aaa < codeVoice > bbb < / codeVoice > ccc . < / Para > < / Abstract > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test10InlineCode2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Abstract > < Para > Aaa < codeVoice > bbb < / codeVoice > ccc . < / Para > < / Abstract > < / Function > ] <nl> } <nl> <nl> - @ objc class InlineLink { <nl> + @ objc public class InlineLink { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / Aaa [ bbb ] ( / path / to / something ) ccc . <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test10InlineLink2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Abstract > < Para > Aaa < Link href = " / path / to / something " > bbb < / Link > ccc . < / Para > < / Abstract > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test10InlineLink2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Abstract > < Para > Aaa < Link href = " / path / to / something " > bbb < / Link > ccc . < / Para > < / Abstract > < / Function > ] <nl> } <nl> <nl> / / / - parameter x : A number <nl> - @ objc class ParamAndReturns { <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Class file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > ParamAndReturns < / Name > < USR > s : C14swift_ide_test15ParamAndReturns < / USR > < Declaration > @ objc class ParamAndReturns < / Declaration > < Parameters > < Parameter > < Name > x < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < / Parameters > < / Class > ] <nl> + @ objc public class ParamAndReturns { <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Class file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > ParamAndReturns < / Name > < USR > s : C14swift_ide_test15ParamAndReturns < / USR > < Declaration > @ objc public class ParamAndReturns < / Declaration > < Parameters > < Parameter > < Name > x < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < / Parameters > < / Class > ] <nl> / / / Aaa . f0 . <nl> / / / <nl> / / / - parameter first : Bbb . <nl> / / / <nl> / / / - parameter second : Ccc . Ddd . <nl> / / / Eee . <nl> - func f0 ( first : Int , second : Double ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( _ : second : ) < / Name > < USR > s : FC14swift_ide_test15ParamAndReturns2f0FTSi6secondSd_T_ < / USR > < Declaration > func f0 ( first : Int , second : Double ) < / Declaration > < Abstract > < Para > Aaa . f0 . < / Para > < / Abstract > < Parameters > < Parameter > < Name > first < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Parameter > < Parameter > < Name > second < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Ccc . Ddd . Eee . < / Para > < / Discussion > < / Parameter > < / Parameters > < / Function > ] <nl> + public func f0 ( first : Int , second : Double ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( _ : second : ) < / Name > < USR > s : FC14swift_ide_test15ParamAndReturns2f0FTSi6secondSd_T_ < / USR > < Declaration > public func f0 ( first : Int , second : Double ) < / Declaration > < Abstract > < Para > Aaa . f0 . < / Para > < / Abstract > < Parameters > < Parameter > < Name > first < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Parameter > < Parameter > < Name > second < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Ccc . Ddd . Eee . < / Para > < / Discussion > < / Parameter > < / Parameters > < / Function > ] <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> <nl> func f0 ( first : Int , second : Double ) { } <nl> / / / <nl> / / / - returns : Ccc . <nl> / / / Ddd . <nl> - func f1 ( first : Int ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f1 ( _ : ) < / Name > < USR > s : FC14swift_ide_test15ParamAndReturns2f1FSiT_ < / USR > < Declaration > func f1 ( first : Int ) < / Declaration > < Abstract > < Para > Aaa . f1 . < / Para > < / Abstract > < Parameters > < Parameter > < Name > first < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Parameter > < / Parameters > < ResultDiscussion > < Para > Ccc . Ddd . < / Para > < / ResultDiscussion > < / Function > ] <nl> + public func f1 ( first : Int ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f1 ( _ : ) < / Name > < USR > s : FC14swift_ide_test15ParamAndReturns2f1FSiT_ < / USR > < Declaration > public func f1 ( first : Int ) < / Declaration > < Abstract > < Para > Aaa . f1 . < / Para > < / Abstract > < Parameters > < Parameter > < Name > first < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Parameter > < / Parameters > < ResultDiscussion > < Para > Ccc . Ddd . < / Para > < / ResultDiscussion > < / Function > ] <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> <nl> / / / Aaa . f2 . <nl> func f1 ( first : Int ) { } <nl> / / / <nl> / / / - parameter third : <nl> / / / Bbb . <nl> - func f2 ( first : Int , second : Double , third : Float ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f2 ( _ : second : third : ) < / Name > < USR > s : FC14swift_ide_test15ParamAndReturns2f2FTSi6secondSd5thirdSf_T_ < / USR > < Declaration > func f2 ( first : Int , second : Double , third : Float ) < / Declaration > < Abstract > < Para > Aaa . f2 . < / Para > < / Abstract > < Parameters > < Parameter > < Name > first < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > < / Para > < / Discussion > < / Parameter > < Parameter > < Name > second < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Aaa . < / Para > < / Discussion > < / Parameter > < Parameter > < Name > third < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Parameter > < / Parameters > < / Function > ] <nl> + public func f2 ( first : Int , second : Double , third : Float ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f2 ( _ : second : third : ) < / Name > < USR > s : FC14swift_ide_test15ParamAndReturns2f2FTSi6secondSd5thirdSf_T_ < / USR > < Declaration > public func f2 ( first : Int , second : Double , third : Float ) < / Declaration > < Abstract > < Para > Aaa . f2 . < / Para > < / Abstract > < Parameters > < Parameter > < Name > first < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > < / Para > < / Discussion > < / Parameter > < Parameter > < Name > second < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Aaa . < / Para > < / Discussion > < / Parameter > < Parameter > < Name > third < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Parameter > < / Parameters > < / Function > ] <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> func f2 ( first : Int , second : Double , third : Float ) { } <nl> / / / - parameter first : Bbb . <nl> / / / - parameter second : Ccc . <nl> / / / - parameter third : Ddd . <nl> - func f3 ( first : Int , second : Double , third : Float ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f3 ( _ : second : third : ) < / Name > < USR > s : FC14swift_ide_test15ParamAndReturns2f3FTSi6secondSd5thirdSf_T_ < / USR > < Declaration > func f3 ( first : Int , second : Double , third : Float ) < / Declaration > < Abstract > < Para > Aaa . f3 . < / Para > < / Abstract > < Parameters > < Parameter > < Name > first < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Parameter > < Parameter > < Name > second < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Ccc . < / Para > < / Discussion > < / Parameter > < Parameter > < Name > third < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Ddd . < / Para > < / Discussion > < / Parameter > < / Parameters > < / Function > ] <nl> + public func f3 ( first : Int , second : Double , third : Float ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f3 ( _ : second : third : ) < / Name > < USR > s : FC14swift_ide_test15ParamAndReturns2f3FTSi6secondSd5thirdSf_T_ < / USR > < Declaration > public func f3 ( first : Int , second : Double , third : Float ) < / Declaration > < Abstract > < Para > Aaa . f3 . < / Para > < / Abstract > < Parameters > < Parameter > < Name > first < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Bbb . < / Para > < / Discussion > < / Parameter > < Parameter > < Name > second < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Ccc . < / Para > < / Discussion > < / Parameter > < Parameter > < Name > third < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > Ddd . < / Para > < / Discussion > < / Parameter > < / Parameters > < / Function > ] <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> func f3 ( first : Int , second : Double , third : Float ) { } <nl> / / / <nl> / / / - returns : Eee . <nl> / / / Fff . <nl> - func f4 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f4 ( ) < / Name > < USR > s : FC14swift_ide_test15ParamAndReturns2f4FT_T_ < / USR > < Declaration > func f4 ( ) < / Declaration > < Abstract > < Para > Aaa . f4 . < / Para > < / Abstract > < ResultDiscussion > < Para > Eee . Fff . < / Para > < / ResultDiscussion > < / Function > ] <nl> + public func f4 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f4 ( ) < / Name > < USR > s : FC14swift_ide_test15ParamAndReturns2f4FT_T_ < / USR > < Declaration > public func f4 ( ) < / Declaration > < Abstract > < Para > Aaa . f4 . < / Para > < / Abstract > < ResultDiscussion > < Para > Eee . Fff . < / Para > < / ResultDiscussion > < / Function > ] <nl> } <nl> <nl> - @ objc class OrderedList { <nl> + @ objc public class OrderedList { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / 1 . Aaa . <nl> / / / <nl> / / / 2 . Bbb . <nl> / / / Ccc . <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test11OrderedList2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Discussion > < List - Number > < Item > < Para > Aaa . < / Para > < / Item > < Item > < Para > Bbb . Ccc . < / Para > < / Item > < / List - Number > < / Discussion > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test11OrderedList2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Discussion > < List - Number > < Item > < Para > Aaa . < / Para > < / Item > < Item > < Para > Bbb . Ccc . < / Para > < / Item > < / List - Number > < / Discussion > < / Function > ] <nl> } <nl> <nl> - @ objc class ParameterOutline { <nl> + @ objc public class ParameterOutline { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / - Parameters : <nl> / / / - x : A number <nl> func f0 ( ) { } <nl> / / / <nl> / / / - PARAMETERS : <nl> / / / - z : A number <nl> - func f0 ( x : Int , y : Int , z : Int ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( _ : y : z : ) < / Name > < USR > s : FC14swift_ide_test16ParameterOutline2f0FTSi1ySi1zSi_T_ < / USR > < Declaration > func f0 ( x : Int , y : Int , z : Int ) < / Declaration > < Parameters > < Parameter > < Name > x < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < Parameter > < Name > y < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < Parameter > < Name > z < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < / Parameters > < / Function > ] <nl> + public func f0 ( x : Int , y : Int , z : Int ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( _ : y : z : ) < / Name > < USR > s : FC14swift_ide_test16ParameterOutline2f0FTSi1ySi1zSi_T_ < / USR > < Declaration > public func f0 ( x : Int , y : Int , z : Int ) < / Declaration > < Parameters > < Parameter > < Name > x < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < Parameter > < Name > y < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < Parameter > < Name > z < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < / Parameters > < / Function > ] <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> } <nl> <nl> - @ objc class ParameterOutlineMiddle { <nl> + @ objc public class ParameterOutlineMiddle { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / - This line should remain . <nl> / / / - Parameters : <nl> func f0 ( x : Int , y : Int , z : Int ) { } <nl> / / / - y : A number <nl> / / / - This line should also remain . <nl> / / / - parameter z : A number <nl> - func f0 ( x : Int , y : Int , z : Int ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( _ : y : z : ) < / Name > < USR > s : FC14swift_ide_test22ParameterOutlineMiddle2f0FTSi1ySi1zSi_T_ < / USR > < Declaration > func f0 ( x : Int , y : Int , z : Int ) < / Declaration > < Parameters > < Parameter > < Name > x < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < Parameter > < Name > y < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < Parameter > < Name > z < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < / Parameters > < Discussion > < List - Bullet > < Item > < Para > This line should remain . < / Para > < / Item > < Item > < Para > This line should also remain . < / Para > < / Item > < / List - Bullet > < / Discussion > < / Function > ] <nl> + public func f0 ( x : Int , y : Int , z : Int ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( _ : y : z : ) < / Name > < USR > s : FC14swift_ide_test22ParameterOutlineMiddle2f0FTSi1ySi1zSi_T_ < / USR > < Declaration > public func f0 ( x : Int , y : Int , z : Int ) < / Declaration > < Parameters > < Parameter > < Name > x < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < Parameter > < Name > y < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < Parameter > < Name > z < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < / Parameters > < Discussion > < List - Bullet > < Item > < Para > This line should remain . < / Para > < / Item > < Item > < Para > This line should also remain . < / Para > < / Item > < / List - Bullet > < / Discussion > < / Function > ] <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> } <nl> <nl> - @ objc class ReferenceLink { <nl> + @ objc public class ReferenceLink { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / This is [ a reference link ] [ 1 ] . <nl> / / / <nl> func f0 ( x : Int , y : Int , z : Int ) { } <nl> } <nl> <nl> <nl> - @ objc class Returns { <nl> + @ objc public class Returns { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / - returns : A number <nl> - func f0 ( ) - > Int { <nl> + public func f0 ( ) - > Int { <nl> return 0 <nl> } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test7Returns2f0FT_Si < / USR > < Declaration > func f0 ( ) - & gt ; Int < / Declaration > < ResultDiscussion > < Para > A number < / Para > < / ResultDiscussion > < / Function > ] <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test7Returns2f0FT_Si < / USR > < Declaration > public func f0 ( ) - & gt ; Int < / Declaration > < ResultDiscussion > < Para > A number < / Para > < / ResultDiscussion > < / Function > ] <nl> } <nl> <nl> - @ objc class SeparateParameters { <nl> + @ objc public class SeparateParameters { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / - Parameter x : A number <nl> - func f0 ( x : Int , y : Int ) { } <nl> - / / CHECK : DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( _ : y : ) < / Name > < USR > s : FC14swift_ide_test18SeparateParameters2f0FTSi1ySi_T_ < / USR > < Declaration > func f0 ( x : Int , y : Int ) < / Declaration > < Parameters > < Parameter > < Name > x < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < / Parameters > < / Function > ] <nl> + public func f0 ( x : Int , y : Int ) { } <nl> + / / CHECK : DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( _ : y : ) < / Name > < USR > s : FC14swift_ide_test18SeparateParameters2f0FTSi1ySi_T_ < / USR > < Declaration > public func f0 ( x : Int , y : Int ) < / Declaration > < Parameters > < Parameter > < Name > x < / Name > < Direction isExplicit = " 0 " > in < / Direction > < Discussion > < Para > A number < / Para > < / Discussion > < / Parameter > < / Parameters > < / Function > ] <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> } <nl> <nl> - @ objc class SetextHeaders { <nl> + @ objc public class SetextHeaders { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / # LEVEL ONE <nl> / / / <nl> func f0 ( x : Int , y : Int , z : Int ) { } <nl> / / / # # # # # LEVEL FIVE <nl> / / / <nl> / / / # # # # # LEVEL SIX <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test13SetextHeaders2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Discussion > < rawHTML > < ! [ CDATA [ < h1 > ] ] > < / rawHTML > LEVEL ONE < rawHTML > < ! [ CDATA [ < / h1 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h2 > ] ] > < / rawHTML > LEVEL TWO < rawHTML > < ! [ CDATA [ < / h2 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h3 > ] ] > < / rawHTML > LEVEL THREE < rawHTML > < ! [ CDATA [ < / h3 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h4 > ] ] > < / rawHTML > LEVEL FOUR < rawHTML > < ! [ CDATA [ < / h4 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h5 > ] ] > < / rawHTML > LEVEL FIVE < rawHTML > < ! [ CDATA [ < / h5 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h5 > ] ] > < / rawHTML > LEVEL SIX < rawHTML > < ! [ CDATA [ < / h5 > ] ] > < / rawHTML > < / Discussion > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test13SetextHeaders2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Discussion > < rawHTML > < ! [ CDATA [ < h1 > ] ] > < / rawHTML > LEVEL ONE < rawHTML > < ! [ CDATA [ < / h1 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h2 > ] ] > < / rawHTML > LEVEL TWO < rawHTML > < ! [ CDATA [ < / h2 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h3 > ] ] > < / rawHTML > LEVEL THREE < rawHTML > < ! [ CDATA [ < / h3 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h4 > ] ] > < / rawHTML > LEVEL FOUR < rawHTML > < ! [ CDATA [ < / h4 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h5 > ] ] > < / rawHTML > LEVEL FIVE < rawHTML > < ! [ CDATA [ < / h5 > ] ] > < / rawHTML > < rawHTML > < ! [ CDATA [ < h5 > ] ] > < / rawHTML > LEVEL SIX < rawHTML > < ! [ CDATA [ < / h5 > ] ] > < / rawHTML > < / Discussion > < / Function > ] <nl> } <nl> <nl> - @ objc class StrongEmphasis { <nl> + @ objc public class StrongEmphasis { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / Aaa * * bbb * * ccc . <nl> / / / Aaa __bbb__ ccc . <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test14StrongEmphasis2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Abstract > < Para > Aaa < bold > bbb < / bold > ccc . Aaa < bold > bbb < / bold > ccc . < / Para > < / Abstract > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test14StrongEmphasis2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Abstract > < Para > Aaa < bold > bbb < / bold > ccc . Aaa < bold > bbb < / bold > ccc . < / Para > < / Abstract > < / Function > ] <nl> } <nl> <nl> - @ objc class UnorderedList { <nl> + @ objc public class UnorderedList { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / / / * Aaa . <nl> / / / <nl> func f0 ( x : Int , y : Int , z : Int ) { } <nl> / / / - Ddd . <nl> / / / - Eee . <nl> / / / - Fff . <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test13UnorderedList2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Discussion > < List - Bullet > < Item > < Para > Aaa . < / Para > < / Item > < Item > < Para > Bbb . Ccc . < / Para > < / Item > < / List - Bullet > < List - Bullet > < Item > < Para > Ddd . < / Para > < / Item > < Item > < Para > Eee . < / Para > < List - Bullet > < Item > < Para > Fff . < / Para > < / Item > < / List - Bullet > < / Item > < / List - Bullet > < / Discussion > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test13UnorderedList2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Discussion > < List - Bullet > < Item > < Para > Aaa . < / Para > < / Item > < Item > < Para > Bbb . Ccc . < / Para > < / Item > < / List - Bullet > < List - Bullet > < Item > < Para > Ddd . < / Para > < / Item > < Item > < Para > Eee . < / Para > < List - Bullet > < Item > < Para > Fff . < / Para > < / Item > < / List - Bullet > < / Item > < / List - Bullet > < / Discussion > < / Function > ] <nl> } <nl> <nl> - @ objc class IndentedBlockComment { <nl> + @ objc public class IndentedBlockComment { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> / * * <nl> Brief . <nl> func f0 ( x : Int , y : Int , z : Int ) { } <nl> / / var y = 2 <nl> var z = 3 <nl> * / <nl> - func f1 ( ) { } <nl> - / / CHECK : DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f1 ( ) < / Name > < USR > s : FC14swift_ide_test20IndentedBlockComment2f1FT_T_ < / USR > < Declaration > func f1 ( ) < / Declaration > < Abstract > < Para > Brief . < / Para > < / Abstract > < Discussion > < Para > First paragraph line . Second paragraph line . < / Para > < Para > Now for a code sample : < / Para > < CodeListing language = " swift " > < zCodeLineNumbered > < ! [ CDATA [ var x = 1 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ / / var y = 2 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ var z = 3 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < / zCodeLineNumbered > < / CodeListing > < / Discussion > < / Function > ] <nl> + public func f1 ( ) { } <nl> + / / CHECK : DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f1 ( ) < / Name > < USR > s : FC14swift_ide_test20IndentedBlockComment2f1FT_T_ < / USR > < Declaration > public func f1 ( ) < / Declaration > < Abstract > < Para > Brief . < / Para > < / Abstract > < Discussion > < Para > First paragraph line . Second paragraph line . < / Para > < Para > Now for a code sample : < / Para > < CodeListing language = " swift " > < zCodeLineNumbered > < ! [ CDATA [ var x = 1 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ / / var y = 2 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ var z = 3 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < / zCodeLineNumbered > < / CodeListing > < / Discussion > < / Function > ] <nl> / * * <nl> Hugely indented brief . <nl> <nl> func f0 ( x : Int , y : Int , z : Int ) { } <nl> / / var y = 2 <nl> var z = 3 <nl> * / <nl> - func f2 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f2 ( ) < / Name > < USR > s : FC14swift_ide_test20IndentedBlockComment2f2FT_T_ < / USR > < Declaration > func f2 ( ) < / Declaration > < Abstract > < Para > Hugely indented brief . < / Para > < / Abstract > < Discussion > < Para > First paragraph line . Second paragraph line . < / Para > < Para > Now for a code sample : < / Para > < CodeListing language = " swift " > < zCodeLineNumbered > < ! [ CDATA [ var x = 1 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ / / var y = 2 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ var z = 3 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < / zCodeLineNumbered > < / CodeListing > < / Discussion > < / Function > ] <nl> + public func f2 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f2 ( ) < / Name > < USR > s : FC14swift_ide_test20IndentedBlockComment2f2FT_T_ < / USR > < Declaration > public func f2 ( ) < / Declaration > < Abstract > < Para > Hugely indented brief . < / Para > < / Abstract > < Discussion > < Para > First paragraph line . Second paragraph line . < / Para > < Para > Now for a code sample : < / Para > < CodeListing language = " swift " > < zCodeLineNumbered > < ! [ CDATA [ var x = 1 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ / / var y = 2 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < ! [ CDATA [ var z = 3 ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < / zCodeLineNumbered > < / CodeListing > < / Discussion > < / Function > ] <nl> } <nl> <nl> - @ objc class MultiLineBrief { <nl> + @ objc public class MultiLineBrief { <nl> / / CHECK : { { . * } } DocCommentAsXML = none <nl> <nl> / / / Brief first line . <nl> / / / Brief after softbreak . <nl> / / / <nl> / / / Some paragraph text . <nl> - func f0 ( ) { } <nl> - / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test14MultiLineBrief2f0FT_T_ < / USR > < Declaration > func f0 ( ) < / Declaration > < Abstract > < Para > Brief first line . Brief after softbreak . < / Para > < / Abstract > < Discussion > < Para > Some paragraph text . < / Para > < / Discussion > < / Function > ] <nl> + public func f0 ( ) { } <nl> + / / CHECK : { { . * } } DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > f0 ( ) < / Name > < USR > s : FC14swift_ide_test14MultiLineBrief2f0FT_T_ < / USR > < Declaration > public func f0 ( ) < / Declaration > < Abstract > < Para > Brief first line . Brief after softbreak . < / Para > < / Abstract > < Discussion > < Para > Some paragraph text . < / Para > < / Discussion > < / Function > ] <nl> } <nl> <nl> / / / Brief . <nl> func f0 ( x : Int , y : Int , z : Int ) { } <nl> / / / ` ` ` <nl> / / / thisIsASwiftCodeExample ( ) <nl> / / / ` ` ` <nl> - func codeListingWithDefaultLanguage ( ) { } <nl> - / / CHECK : DocCommentAsXML = [ < Function file = " { { . * } } line = " { { . * } } " column = " { { . * } } " > < Name > codeListingWithDefaultLanguage ( ) < / Name > < USR > s : F14swift_ide_test30codeListingWithDefaultLanguageFT_T_ < / USR > < Declaration > func codeListingWithDefaultLanguage ( ) < / Declaration > < Abstract > < Para > Brief . < / Para > < / Abstract > < Discussion > < CodeListing language = " swift " > < zCodeLineNumbered > < ! [ CDATA [ thisIsASwiftCodeExample ( ) ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < / zCodeLineNumbered > < / CodeListing > < / Discussion > < / Function > ] CommentXMLValid <nl> + public func codeListingWithDefaultLanguage ( ) { } <nl> + / / CHECK : DocCommentAsXML = [ < Function file = " { { . * } } line = " { { . * } } " column = " { { . * } } " > < Name > codeListingWithDefaultLanguage ( ) < / Name > < USR > s : F14swift_ide_test30codeListingWithDefaultLanguageFT_T_ < / USR > < Declaration > public func codeListingWithDefaultLanguage ( ) < / Declaration > < Abstract > < Para > Brief . < / Para > < / Abstract > < Discussion > < CodeListing language = " swift " > < zCodeLineNumbered > < ! [ CDATA [ thisIsASwiftCodeExample ( ) ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < / zCodeLineNumbered > < / CodeListing > < / Discussion > < / Function > ] CommentXMLValid <nl> <nl> <nl> / / / Brief . <nl> func codeListingWithDefaultLanguage ( ) { } <nl> / / / ` ` ` c + + <nl> / / / Something : : Something : : create ( ) ; <nl> / / / ` ` ` <nl> - func codeListingWithOtherLanguage ( ) { } <nl> - / / CHECK : DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > codeListingWithOtherLanguage ( ) < / Name > < USR > s : F14swift_ide_test28codeListingWithOtherLanguageFT_T_ < / USR > < Declaration > func codeListingWithOtherLanguage ( ) < / Declaration > < Abstract > < Para > Brief . < / Para > < / Abstract > < Discussion > < CodeListing language = " c + + " > < zCodeLineNumbered > < ! [ CDATA [ Something : : Something : : create ( ) ; ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < / zCodeLineNumbered > < / CodeListing > < / Discussion > < / Function > ] <nl> + public func codeListingWithOtherLanguage ( ) { } <nl> + / / CHECK : DocCommentAsXML = [ < Function file = " { { . * } } " line = " { { . * } } " column = " { { . * } } " > < Name > codeListingWithOtherLanguage ( ) < / Name > < USR > s : F14swift_ide_test28codeListingWithOtherLanguageFT_T_ < / USR > < Declaration > public func codeListingWithOtherLanguage ( ) < / Declaration > < Abstract > < Para > Brief . < / Para > < / Abstract > < Discussion > < CodeListing language = " c + + " > < zCodeLineNumbered > < ! [ CDATA [ Something : : Something : : create ( ) ; ] ] > < / zCodeLineNumbered > < zCodeLineNumbered > < / zCodeLineNumbered > < / CodeListing > < / Discussion > < / Function > ] <nl> mmm a / test / PrintAsObjC / cdecl . swift <nl> ppp b / test / PrintAsObjC / cdecl . swift <nl> <nl> <nl> / / / What a nightmare ! <nl> @ _cdecl ( " block_nightmare " ) <nl> - func block_nightmare ( x : @ convention ( block ) Int - > Float ) <nl> + public func block_nightmare ( x : @ convention ( block ) Int - > Float ) <nl> - > @ convention ( block ) CChar - > Double { return { _ in 0 } } <nl> <nl> / / CHECK - LABEL : void foo_bar ( NSInteger x , NSInteger y ) ; <nl> mmm a / test / PrintAsObjC / enums . swift <nl> ppp b / test / PrintAsObjC / enums . swift <nl> import Foundation <nl> / / CHECK - NEXT : } ; <nl> <nl> / / / Foo : A feer , a female feer . <nl> - @ objc enum FooComments : Int { <nl> + @ objc public enum FooComments : Int { <nl> / / / Zim : A zeer , a female zeer . <nl> case Zim <nl> case Zang , Zung <nl> mmm a / test / Serialization / comments - framework . swift <nl> ppp b / test / Serialization / comments - framework . swift <nl> <nl> / / XFAIL : linux <nl> <nl> / / / first_decl_class_1 Aaa . <nl> - class first_decl_class_1 { <nl> + public class first_decl_class_1 { <nl> <nl> / / / decl_func_1 Aaa . <nl> - func decl_func_1 ( ) { } <nl> + public func decl_func_1 ( ) { } <nl> <nl> / * * <nl> * decl_func_3 Aaa . <nl> * / <nl> - func decl_func_2 ( ) { } <nl> + public func decl_func_2 ( ) { } <nl> <nl> / / / decl_func_3 Aaa . <nl> / * * Bbb . * / <nl> - func decl_func_3 ( ) { } <nl> + public func decl_func_3 ( ) { } <nl> } <nl> <nl> / / CHECK : Class / first_decl_class_1 RawComment = [ / / / first_decl_class_1 Aaa . \ n ] <nl> new file mode 100644 <nl> index 000000000000 . . e5d045c25ed2 <nl> mmm / dev / null <nl> ppp b / test / Serialization / comments - hidden . swift <nl> <nl> + / / Test the case when we compile normally <nl> + / / <nl> + / / RUN : rm - rf % t <nl> + / / RUN : mkdir % t <nl> + / / RUN : % target - swift - frontend - module - name comments - emit - module - emit - module - path % t / comments . swiftmodule - emit - module - doc - emit - module - doc - path % t / comments . swiftdoc % s <nl> + / / RUN : % target - swift - ide - test - print - module - comments - module - to - print = comments - source - filename % s - I % t > % t . normal . txt <nl> + / / RUN : FileCheck % s - check - prefix = NORMAL < % t . normal . txt <nl> + / / RUN : FileCheck % s - check - prefix = NORMAL - NEGATIVE < % t . normal . txt <nl> + <nl> + / / Test the case when we compile with - enable - testing <nl> + / / <nl> + / / RUN : rm - rf % t <nl> + / / RUN : mkdir % t <nl> + / / RUN : % target - swift - frontend - enable - testing - module - name comments - emit - module - emit - module - path % t / comments . swiftmodule - emit - module - doc - emit - module - doc - path % t / comments . swiftdoc % s <nl> + / / RUN : % target - swift - ide - test - print - module - comments - module - to - print = comments - source - filename % s - I % t > % t . testing . txt <nl> + / / RUN : FileCheck % s - check - prefix = TESTING < % t . testing . txt <nl> + / / RUN : FileCheck % s - check - prefix = TESTING - NEGATIVE < % t . testing . txt <nl> + <nl> + / / / PublicClass Documentation <nl> + public class PublicClass { <nl> + / / / Public Function Documentation <nl> + public func f_public ( ) { } <nl> + / / / Internal Function Documentation NotForNormal <nl> + internal func f_internal ( ) { } <nl> + / / / Private Function Documentation NotForNormal NotForTesting <nl> + private func f_private ( ) { } <nl> + } <nl> + <nl> + / / / InternalClass Documentation NotForNormal <nl> + internal class InternalClass { <nl> + / / / Internal Function Documentation NotForNormal <nl> + internal func f_internal ( ) { } <nl> + / / / Private Function Documentation NotForNormal NotForTesting <nl> + private func f_private ( ) { } <nl> + } <nl> + <nl> + / / / PrivateClass Documentation NotForNormal NotForTesting <nl> + private class PrivateClass { <nl> + / / / Private Function Documentation NotForNormal NotForTesting <nl> + private func f_private ( ) { } <nl> + } <nl> + <nl> + / / NORMAL - NEGATIVE - NOT : NotForNormal <nl> + / / NORMAL - NEGATIVE - NOT : NotForTesting <nl> + / / NORMAL : PublicClass Documentation <nl> + / / NORMAL : Public Function Documentation <nl> + <nl> + / / TESTING - NEGATIVE - NOT : NotForTesting <nl> + / / TESTING : InternalClass Documentation <nl> + / / TESTING : Internal Function Documentation <nl> + / / TESTING : PublicClass Documentation <nl> + / / TESTING : Public Function Documentation <nl> + / / TESTING : Internal Function Documentation <nl> + <nl> + <nl> mmm a / test / Serialization / comments . swift <nl> ppp b / test / Serialization / comments . swift <nl> <nl> / / BCANALYZER - NOT : UnknownCode <nl> <nl> / / / first_decl_generic_class_1 Aaa . <nl> - class first_decl_generic_class_1 < T > { <nl> + public class first_decl_generic_class_1 < T > { <nl> / / / deinit of first_decl_generic_class_1 Aaa . <nl> deinit { <nl> } <nl> } <nl> <nl> / / / first_decl_class_1 Aaa . <nl> - class first_decl_class_1 { <nl> + public class first_decl_class_1 { <nl> <nl> / / / decl_func_1 Aaa . <nl> - func decl_func_1 ( ) { } <nl> + public func decl_func_1 ( ) { } <nl> <nl> / * * <nl> * decl_func_3 Aaa . <nl> * / <nl> - func decl_func_2 ( ) { } <nl> + public func decl_func_2 ( ) { } <nl> <nl> / / / decl_func_3 Aaa . <nl> / * * Bbb . * / <nl> - func decl_func_3 ( ) { } <nl> + public func decl_func_3 ( ) { } <nl> } <nl> <nl> / / / Comment for bar1 <nl> | Merge pull request from drewcrawford / secret - squashed | apple/swift | 2ecb93b2f37d6cc6444afd9d8773a40943b1a711 | 2016-03-18T16:26:31Z |
mmm a / misc / benchmark_compile . py <nl> ppp b / misc / benchmark_compile . py <nl> <nl> import autograd . numpy as np <nl> from autograd import grad <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def grad_test ( tifunc , npfunc = None ) : <nl> if npfunc is None : <nl> npfunc = tifunc <nl> mmm a / python / taichi / lang / __init__ . py <nl> ppp b / python / taichi / lang / __init__ . py <nl> def test ( * args , * * kwargs ) : <nl> <nl> <nl> # test with all archs <nl> - def program_test ( func ) : <nl> + def all_archs ( func ) : <nl> import taichi as ti <nl> def test ( * args , * * kwargs ) : <nl> archs = [ x86_64 ] <nl> mmm a / tests / python / test_abs . py <nl> ppp b / tests / python / test_abs . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_abs ( ) : <nl> ti . reset ( ) <nl> ti . cfg . print_ir = True <nl> mmm a / tests / python / test_ad_basics . py <nl> ppp b / tests / python / test_ad_basics . py <nl> <nl> import autograd . numpy as np <nl> from autograd import grad <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def grad_test ( tifunc , npfunc = None ) : <nl> if npfunc is None : <nl> npfunc = tifunc <nl> mmm a / tests / python / test_arg_check . py <nl> ppp b / tests / python / test_arg_check . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_argument_error ( ) : <nl> x = ti . var ( ti . i32 ) <nl> <nl> mmm a / tests / python / test_arg_load . py <nl> ppp b / tests / python / test_arg_load . py <nl> <nl> import taichi as ti <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_arg_load ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . f32 ) <nl> def set_i64 ( v : ti . i64 ) : <nl> assert y [ None ] = = 2 . 5 <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_ext_arr ( ) : <nl> N = 128 <nl> x = ti . var ( ti . f32 ) <nl> mmm a / tests / python / test_basics . py <nl> ppp b / tests / python / test_basics . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_simple ( ) : <nl> x = ti . var ( ti . i32 ) <nl> <nl> def func ( ) : <nl> else : <nl> assert x [ i ] = = 0 <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_range_loops ( ) : <nl> x = ti . var ( ti . i32 ) <nl> <nl> def func ( ) : <nl> assert x [ i ] = = i + 123 <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_io ( ) : <nl> ti . cfg . arch = ti . cuda <nl> x = ti . var ( ti . i32 ) <nl> mmm a / tests / python / test_complex_kernels . py <nl> ppp b / tests / python / test_complex_kernels . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_complex_kernels_range ( ) : <nl> a = ti . var ( ti . f32 ) <nl> b = ti . var ( ti . f32 ) <nl> def add ( ) : <nl> assert a [ i ] = = i + 12 <nl> assert b [ i ] = = i + 7 <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_complex_kernels ( ) : <nl> return <nl> a = ti . var ( ti . f32 ) <nl> mmm a / tests / python / test_cond_grad . py <nl> ppp b / tests / python / test_cond_grad . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_cond_grad ( ) : <nl> x = ti . var ( ti . f32 ) <nl> y = ti . var ( ti . f32 ) <nl> mmm a / tests / python / test_kernel_template_mapper . py <nl> ppp b / tests / python / test_kernel_template_mapper . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_kernel_template_mapper ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . f32 ) <nl> mmm a / tests / python / test_kernel_templates . py <nl> ppp b / tests / python / test_kernel_templates . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_kernel_template_basic ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . f32 ) <nl> def inc2 ( z : ti . i32 , a : ti . template ( ) , b : ti . i32 ) : <nl> assert x [ i ] = = 12 <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_kernel_template_gradient ( ) : <nl> x = ti . global_var ( ti . f32 ) <nl> y = ti . global_var ( ti . f32 ) <nl> mmm a / tests / python / test_lang . py <nl> ppp b / tests / python / test_lang . py <nl> def inc ( ) : <nl> assert x [ 0 ] = = 1 <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_norm ( ) : <nl> val = ti . var ( ti . i32 ) <nl> f = ti . var ( ti . f32 ) <nl> def test2 ( ) : <nl> assert val [ i ] = = 96 + i <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_simple2 ( ) : <nl> val = ti . var ( ti . i32 ) <nl> f = ti . var ( ti . f32 ) <nl> mmm a / tests / python / test_linalg . py <nl> ppp b / tests / python / test_linalg . py <nl> <nl> import taichi as ti <nl> from pytest import approx <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_transpose ( ) : <nl> dim = 3 <nl> m = ti . Matrix ( dim , dim , ti . f32 ) <nl> def transpose ( ) : <nl> assert m ( j , i ) [ None ] = = approx ( i * 2 + j * 7 ) <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_polar_decomp ( ) : <nl> dim = 2 <nl> m = ti . Matrix ( dim , dim , ti . f32 ) <nl> def polar ( ) : <nl> assert D ( i , j ) [ None ] = = approx ( 0 , abs = 1e - 5 ) <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_matrix ( ) : <nl> x = ti . Matrix ( 2 , 2 , dt = ti . i32 ) <nl> <nl> mmm a / tests / python / test_loop_grad . py <nl> ppp b / tests / python / test_loop_grad . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_loop_grad ( ) : <nl> ti . set_gdb_trigger ( ) <nl> ti . cfg . print_ir = True <nl> def func ( ) : <nl> assert x . grad [ k , i ] = = 2 * * ( m - 1 - i ) <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_loop_grad_complex ( ) : <nl> return # This case is not supported yet <nl> x = ti . var ( ti . f32 ) <nl> mmm a / tests / python / test_loops . py <nl> ppp b / tests / python / test_loops . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_loops ( ) : <nl> x = ti . var ( ti . f32 ) <nl> y = ti . var ( ti . f32 ) <nl> def func ( ) : <nl> for i in range ( N / / 2 + 3 , N ) : <nl> assert x [ i ] = = abs ( y [ i ] ) <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_numpy_loops ( ) : <nl> x = ti . var ( ti . f32 ) <nl> y = ti . var ( ti . f32 ) <nl> def func ( ) : <nl> assert x [ i ] = = abs ( y [ i ] ) <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_nested_loops ( ) : <nl> # this may crash if any LLVM allocas are called in the loop body <nl> x = ti . var ( ti . i32 ) <nl> mmm a / tests / python / test_numpy . py <nl> ppp b / tests / python / test_numpy . py <nl> <nl> import taichi as ti <nl> import numpy as np <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_numpy ( ) : <nl> val = ti . var ( ti . i32 ) <nl> <nl> mmm a / tests / python / test_sparse_basics . py <nl> ppp b / tests / python / test_sparse_basics . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_bitmasked ( ) : <nl> ti . reset ( ) <nl> x = ti . var ( ti . f32 ) <nl> def func ( ) : <nl> func ( ) <nl> assert s [ None ] = = 256 <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_pointer ( ) : <nl> ti . reset ( ) <nl> ti . cfg . arch = ti . x86_64 <nl> def func ( ) : <nl> assert s [ None ] = = 256 <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_pointer2 ( ) : <nl> x = ti . var ( ti . f32 ) <nl> s = ti . var ( ti . i32 ) <nl> mmm a / tests / python / test_static . py <nl> ppp b / tests / python / test_static . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_static_if ( ) : <nl> for val in [ 0 , 1 ] : <nl> ti . reset ( ) <nl> mmm a / tests / python / test_stencils . py <nl> ppp b / tests / python / test_stencils . py <nl> <nl> import taichi as ti <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_simple ( ) : <nl> # Note : access simplification does not work in this case . Maybe worth fixing . <nl> x = ti . var ( ti . i32 ) <nl> mmm a / tests / python / test_struct . py <nl> ppp b / tests / python / test_struct . py <nl> <nl> import taichi as ti <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_linear ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . i32 ) <nl> def test_linear_repeated ( ) : <nl> test_linear ( ) <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_linear_nested ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . i32 ) <nl> def place ( ) : <nl> assert y [ i ] = = i + 123 <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_linear_nested_aos ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . i32 ) <nl> def place ( ) : <nl> assert y [ i ] = = i + 123 <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_2d_nested ( ) : <nl> x = ti . var ( ti . i32 ) <nl> <nl> mmm a / tests / python / test_struct_for . py <nl> ppp b / tests / python / test_struct_for . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_linear ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . i32 ) <nl> def fill ( ) : <nl> assert y [ i ] = = i * 2 <nl> <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_nested ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . i32 ) <nl> def fill ( ) : <nl> assert x [ i ] = = i <nl> assert y [ i ] = = i * 2 <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_nested2 ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . i32 ) <nl> def fill ( ) : <nl> assert x [ i ] = = i <nl> assert y [ i ] = = i * 2 <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_nested_2d ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . i32 ) <nl> def fill ( ) : <nl> for j in range ( n ) : <nl> assert x [ i , j ] = = i + j * 2 <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_nested_2d_more_nests ( ) : <nl> x = ti . var ( ti . i32 ) <nl> y = ti . var ( ti . i32 ) <nl> def fill ( ) : <nl> for j in range ( n ) : <nl> assert x [ i , j ] = = i + j * 2 <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_linear_k ( ) : <nl> x = ti . var ( ti . i32 ) <nl> <nl> mmm a / tests / python / test_while . py <nl> ppp b / tests / python / test_while . py <nl> <nl> import taichi as ti <nl> <nl> - @ ti . program_test <nl> + @ ti . all_archs <nl> def test_while ( ) : <nl> x = ti . var ( ti . f32 ) <nl> <nl> | program_test - > all_archs | taichi-dev/taichi | 36ee4fb38ccc849b7addd07126e0a22b8e7d7e11 | 2019-11-03T04:34:02Z |
mmm a / xbmc / guilib / D3DResource . cpp <nl> ppp b / xbmc / guilib / D3DResource . cpp <nl> void CD3DBuffer : : OnDestroyDevice ( bool fatal ) <nl> } <nl> <nl> ComPtr < ID3D11Device > pDevice = DX : : DeviceResources : : Get ( ) - > GetD3DDevice ( ) ; <nl> - ComPtr < ID3D11DeviceContext > pContext = DX : : DeviceResources : : Get ( ) - > GetD3DContext ( ) ; <nl> + ComPtr < ID3D11DeviceContext > pContext = DX : : DeviceResources : : Get ( ) - > GetImmediateContext ( ) ; <nl> <nl> if ( ! pDevice | | ! pContext | | ! m_buffer ) <nl> return ; <nl> mmm a / xbmc / rendering / dx / DeviceResources . cpp <nl> ppp b / xbmc / rendering / dx / DeviceResources . cpp <nl> void DX : : DeviceResources : : Release ( ) <nl> # endif <nl> } <nl> <nl> - void DX : : DeviceResources : : GetOutput ( IDXGIOutput * * pOutput ) const <nl> + void DX : : DeviceResources : : GetOutput ( IDXGIOutput * * ppOutput ) const <nl> { <nl> - m_swapChain - > GetContainingOutput ( pOutput ) ; <nl> + ComPtr < IDXGIOutput > pOutput ; <nl> + if ( FAILED ( m_swapChain - > GetContainingOutput ( pOutput . GetAddressOf ( ) ) ) | | ! pOutput ) <nl> + m_output . As ( & pOutput ) ; <nl> + * ppOutput = pOutput . Detach ( ) ; <nl> } <nl> <nl> void DX : : DeviceResources : : GetAdapterDesc ( DXGI_ADAPTER_DESC * desc ) const <nl> void DX : : DeviceResources : : GetDisplayMode ( DXGI_MODE_DESC * mode ) const <nl> DXGI_OUTPUT_DESC outDesc ; <nl> ComPtr < IDXGIOutput > pOutput ; <nl> <nl> - m_swapChain - > GetContainingOutput ( & pOutput ) ; <nl> + GetOutput ( pOutput . GetAddressOf ( ) ) ; <nl> pOutput - > GetDesc ( & outDesc ) ; <nl> <nl> DXGI_SWAP_CHAIN_DESC scDesc ; <nl> void DX : : DeviceResources : : GetDisplayMode ( DXGI_MODE_DESC * mode ) const <nl> int i = ( ( ( sDevMode . dmDisplayFrequency + 1 ) % 24 ) = = 0 | | ( ( sDevMode . dmDisplayFrequency + 1 ) % 30 ) = = 0 ) ? 1 : 0 ; <nl> mode - > RefreshRate . Numerator = ( sDevMode . dmDisplayFrequency + i ) * 1000 ; <nl> mode - > RefreshRate . Denominator = 1000 + i ; <nl> + if ( sDevMode . dmDisplayFlags & DM_INTERLACED ) <nl> + { <nl> + mode - > RefreshRate . Numerator * = 2 ; <nl> + mode - > ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST ; / / guessing <nl> + } <nl> + else <nl> + mode - > ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE ; <nl> } <nl> # endif <nl> } <nl> bool DX : : DeviceResources : : SetFullScreen ( bool fullscreen , RESOLUTION_INFO & res ) <nl> <nl> critical_section : : scoped_lock lock ( m_criticalSection ) ; <nl> <nl> - CLog : : Log ( LOGDEBUG , __FUNCTION__ " : switching to / from fullscreen ( % f x % f ) " , m_outputSize . Width , m_outputSize . Height ) ; <nl> + CLog : : LogF ( LOGDEBUG , " switching to / from fullscreen ( % f x % f ) " , m_outputSize . Width , m_outputSize . Height ) ; <nl> <nl> BOOL bFullScreen ; <nl> bool recreate = m_stereoEnabled ! = ( g_graphicsContext . GetStereoMode ( ) = = RENDER_STEREO_MODE_HARDWAREBASED ) ; <nl> bool DX : : DeviceResources : : SetFullScreen ( bool fullscreen , RESOLUTION_INFO & res ) <nl> m_swapChain - > GetFullscreenState ( & bFullScreen , nullptr ) ; <nl> if ( ! ! bFullScreen & & ! fullscreen ) <nl> { <nl> - CLog : : Log ( LOGDEBUG , __FUNCTION__ " : switching to windowed " ) ; <nl> + CLog : : LogF ( LOGDEBUG , " switching to windowed " ) ; <nl> recreate | = SUCCEEDED ( m_swapChain - > SetFullscreenState ( false , nullptr ) ) ; <nl> } <nl> else if ( fullscreen ) <nl> bool DX : : DeviceResources : : SetFullScreen ( bool fullscreen , RESOLUTION_INFO & res ) <nl> { <nl> DXGI_MODE_DESC currentMode ; <nl> GetDisplayMode ( & currentMode ) ; <nl> + DXGI_SWAP_CHAIN_DESC scDesc ; <nl> + m_swapChain - > GetDesc ( & scDesc ) ; <nl> + <nl> + bool is_interlaced = scDesc . BufferDesc . ScanlineOrdering > DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE ; <nl> + float refreshRate = res . fRefreshRate ; <nl> + if ( res . dwFlags & D3DPRESENTFLAG_INTERLACED ) <nl> + refreshRate * = 2 ; <nl> <nl> if ( currentMode . Width ! = res . iWidth <nl> | | currentMode . Height ! = res . iHeight <nl> - | | DX : : RationalToFloat ( currentMode . RefreshRate ) ! = res . fRefreshRate <nl> + | | DX : : RationalToFloat ( currentMode . RefreshRate ) ! = refreshRate <nl> + | | is_interlaced ! = ( res . dwFlags & D3DPRESENTFLAG_INTERLACED ? true : false ) <nl> / / force resolution change for stereo mode <nl> / / some drivers unable to create stereo swapchain if mode does not match @ 23 . 976 <nl> | | g_graphicsContext . GetStereoMode ( ) = = RENDER_STEREO_MODE_HARDWAREBASED ) <nl> { <nl> - CLog : : Log ( LOGDEBUG , __FUNCTION__ " : changing display mode to % dx % d @ % 0 . 3f " , res . iWidth , res . iHeight , res . fRefreshRate ) ; <nl> + CLog : : LogF ( LOGDEBUG , " changing display mode to % dx % d @ % 0 . 3f % s " , res . iWidth , res . iHeight , res . fRefreshRate , <nl> + res . dwFlags & D3DPRESENTFLAG_INTERLACED ? " i " : " " ) ; <nl> <nl> int refresh = static_cast < int > ( res . fRefreshRate ) ; <nl> int i = ( refresh + 1 ) % 24 = = 0 | | ( refresh + 1 ) % 30 = = 0 ? 1 : 0 ; <nl> bool DX : : DeviceResources : : SetFullScreen ( bool fullscreen , RESOLUTION_INFO & res ) <nl> currentMode . Height = res . iHeight ; <nl> currentMode . RefreshRate . Numerator = ( refresh + i ) * 1000 ; <nl> currentMode . RefreshRate . Denominator = 1000 + i ; <nl> - <nl> + if ( res . dwFlags & D3DPRESENTFLAG_INTERLACED ) <nl> + { <nl> + currentMode . RefreshRate . Numerator * = 2 ; <nl> + currentMode . ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST ; / / guessing ; <nl> + } <nl> recreate | = SUCCEEDED ( m_swapChain - > ResizeTarget ( & currentMode ) ) ; <nl> } <nl> } <nl> if ( ! bFullScreen ) <nl> { <nl> ComPtr < IDXGIOutput > pOutput ; <nl> - m_swapChain - > GetContainingOutput ( & pOutput ) ; <nl> + GetOutput ( pOutput . GetAddressOf ( ) ) ; <nl> <nl> - CLog : : Log ( LOGDEBUG , __FUNCTION__ " : switching to fullscreen " ) ; <nl> + CLog : : LogF ( LOGDEBUG , " switching to fullscreen " ) ; <nl> recreate | = SUCCEEDED ( m_swapChain - > SetFullscreenState ( true , pOutput . Get ( ) ) ) ; <nl> } <nl> } <nl> bool DX : : DeviceResources : : SetFullScreen ( bool fullscreen , RESOLUTION_INFO & res ) <nl> if ( recreate ) <nl> ResizeBuffers ( ) ; <nl> <nl> - CLog : : Log ( LOGDEBUG , __FUNCTION__ " : switching done . " ) ; <nl> + CLog : : LogF ( LOGDEBUG , " switching done . " ) ; <nl> <nl> return true ; <nl> } <nl> void DX : : DeviceResources : : CreateDeviceResources ( ) <nl> ComPtr < ID3D11Device > device ; <nl> ComPtr < ID3D11DeviceContext > context ; <nl> <nl> + D3D_DRIVER_TYPE drivertType = m_adapter ! = nullptr ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE ; <nl> HRESULT hr = D3D11CreateDevice ( <nl> - nullptr , / / Specify nullptr to use the default adapter . <nl> - D3D_DRIVER_TYPE_HARDWARE , / / Create a device using the hardware graphics driver . <nl> + m_adapter . Get ( ) , / / Create a device on specified adapter . <nl> + drivertType , / / Create a device using scepcified driver . <nl> nullptr , / / Should be 0 unless the driver is D3D_DRIVER_TYPE_SOFTWARE . <nl> creationFlags , / / Set debug and Direct2D compatibility flags . <nl> featureLevels , / / List of feature levels this app can support . <nl> void DX : : DeviceResources : : CreateDeviceResources ( ) <nl> hr = context . As ( & m_d3dContext ) ; CHECK_ERR ( ) ; <nl> hr = m_d3dDevice - > CreateDeferredContext1 ( 0 , & m_deferrContext ) ; CHECK_ERR ( ) ; <nl> <nl> - ComPtr < IDXGIDevice1 > dxgiDevice ; <nl> - ComPtr < IDXGIAdapter > adapter ; <nl> - hr = m_d3dDevice . As ( & dxgiDevice ) ; CHECK_ERR ( ) ; <nl> - hr = dxgiDevice - > GetAdapter ( & adapter ) ; CHECK_ERR ( ) ; <nl> - hr = adapter . As ( & m_adapter ) ; CHECK_ERR ( ) ; <nl> + if ( ! m_adapter ) <nl> + { <nl> + ComPtr < IDXGIDevice1 > dxgiDevice ; <nl> + ComPtr < IDXGIAdapter > adapter ; <nl> + hr = m_d3dDevice . As ( & dxgiDevice ) ; CHECK_ERR ( ) ; <nl> + hr = dxgiDevice - > GetAdapter ( & adapter ) ; CHECK_ERR ( ) ; <nl> + hr = adapter . As ( & m_adapter ) ; CHECK_ERR ( ) ; <nl> + } <nl> hr = m_adapter - > GetParent ( IID_PPV_ARGS ( & m_dxgiFactory ) ) ; CHECK_ERR ( ) ; <nl> <nl> DXGI_ADAPTER_DESC aDesc ; <nl> void DX : : DeviceResources : : ResizeBuffers ( ) <nl> bool bHWStereoEnabled = RENDER_STEREO_MODE_HARDWAREBASED = = g_graphicsContext . GetStereoMode ( ) ; <nl> bool windowed = true ; <nl> <nl> + DXGI_SWAP_CHAIN_DESC1 scDesc = { 0 } ; <nl> if ( m_swapChain ) <nl> { <nl> / / check if swapchain needs to be recreated <nl> - DXGI_SWAP_CHAIN_DESC1 scDesc = { 0 } ; <nl> m_swapChain - > GetDesc1 ( & scDesc ) ; <nl> if ( ( scDesc . Stereo = = TRUE ) ! = bHWStereoEnabled ) <nl> { <nl> void DX : : DeviceResources : : ResizeBuffers ( ) <nl> if ( m_swapChain ! = nullptr ) <nl> { <nl> / / If the swap chain already exists , resize it . <nl> + m_swapChain - > GetDesc1 ( & scDesc ) ; <nl> HRESULT hr = m_swapChain - > ResizeBuffers ( <nl> - 2 , / / Double - buffered swap chain . <nl> + scDesc . BufferCount , <nl> lround ( m_outputSize . Width ) , <nl> lround ( m_outputSize . Height ) , <nl> - DXGI_FORMAT_B8G8R8A8_UNORM , <nl> + scDesc . Format , <nl> 0 <nl> ) ; <nl> <nl> void DX : : DeviceResources : : OnDeviceRestored ( ) <nl> / / Recreate all device resources and set them back to the current state . <nl> void DX : : DeviceResources : : HandleDeviceLost ( bool removed ) <nl> { <nl> + bool backbuferExists = m_backBufferTex . Get ( ) ! = nullptr ; <nl> + <nl> OnDeviceLost ( removed ) ; <nl> if ( m_deviceNotify ! = nullptr ) <nl> m_deviceNotify - > OnDXDeviceLost ( ) ; <nl> <nl> - ReleaseBackBuffer ( ) ; <nl> - m_swapChain = nullptr ; <nl> + if ( backbuferExists ) <nl> + ReleaseBackBuffer ( ) ; <nl> <nl> + m_swapChain = nullptr ; <nl> CreateDeviceResources ( ) ; <nl> - CreateWindowSizeDependentResources ( ) ; <nl> + UpdateRenderTargetSize ( ) ; <nl> + ResizeBuffers ( ) ; <nl> + <nl> + if ( backbuferExists ) <nl> + CreateBackBuffer ( ) ; <nl> <nl> if ( m_deviceNotify ! = nullptr ) <nl> m_deviceNotify - > OnDXDeviceRestored ( ) ; <nl> OnDeviceRestored ( ) ; <nl> <nl> - KODI : : MESSAGING : : CApplicationMessenger : : GetInstance ( ) . PostMsg ( TMSG_EXECUTE_BUILT_IN , - 1 , - 1 , nullptr , " ReloadSkin " ) ; <nl> + if ( removed ) <nl> + KODI : : MESSAGING : : CApplicationMessenger : : GetInstance ( ) . PostMsg ( TMSG_EXECUTE_BUILT_IN , - 1 , - 1 , nullptr , " ReloadSkin " ) ; <nl> } <nl> <nl> bool DX : : DeviceResources : : Begin ( ) <nl> void DX : : DeviceResources : : ClearRenderTarget ( ID3D11RenderTargetView * pRTView , flo <nl> m_deferrContext - > ClearRenderTargetView ( pRTView , color ) ; <nl> } <nl> <nl> - void DX : : DeviceResources : : SetMonitor ( HMONITOR monitor ) const <nl> + void DX : : DeviceResources : : HandleOutputChange ( const std : : function < bool ( DXGI_OUTPUT_DESC ) > & cmpFunc ) <nl> { <nl> - HRESULT hr ; <nl> DXGI_ADAPTER_DESC currentDesc = { 0 } ; <nl> DXGI_ADAPTER_DESC foundDesc = { 0 } ; <nl> <nl> - ComPtr < IDXGIFactory1 > dxgiFactory ; <nl> - ComPtr < IDXGIAdapter1 > adapter ; <nl> - <nl> - if ( m_d3dDevice ) <nl> - { <nl> - ComPtr < IDXGIDevice1 > dxgiDevice ; <nl> - ComPtr < IDXGIAdapter > deviceAdapter ; <nl> - <nl> - hr = m_d3dDevice . As ( & dxgiDevice ) ; CHECK_ERR ( ) ; <nl> - dxgiDevice - > GetAdapter ( & deviceAdapter ) ; <nl> - deviceAdapter - > GetDesc ( & currentDesc ) ; <nl> - } <nl> + ComPtr < IDXGIFactory1 > factory ; <nl> + if ( m_adapter ) <nl> + m_adapter - > GetDesc ( & currentDesc ) ; <nl> <nl> - CreateDXGIFactory1 ( IID_IDXGIFactory1 , & dxgiFactory ) ; <nl> + CreateDXGIFactory1 ( IID_IDXGIFactory1 , & factory ) ; <nl> <nl> - int index = 0 ; <nl> - while ( true ) <nl> + ComPtr < IDXGIAdapter1 > adapter ; <nl> + for ( int i = 0 ; factory - > EnumAdapters1 ( i , adapter . ReleaseAndGetAddressOf ( ) ) ! = DXGI_ERROR_NOT_FOUND ; i + + ) <nl> { <nl> - hr = dxgiFactory - > EnumAdapters1 ( index + + , & adapter ) ; <nl> - if ( hr = = DXGI_ERROR_NOT_FOUND ) <nl> - break ; <nl> - <nl> - ComPtr < IDXGIOutput > output ; <nl> adapter - > GetDesc ( & foundDesc ) ; <nl> - <nl> - for ( int j = 0 ; adapter - > EnumOutputs ( j , & output ) ! = DXGI_ERROR_NOT_FOUND ; j + + ) <nl> + ComPtr < IDXGIOutput > output ; <nl> + for ( int j = 0 ; adapter - > EnumOutputs ( j , output . ReleaseAndGetAddressOf ( ) ) ! = DXGI_ERROR_NOT_FOUND ; j + + ) <nl> { <nl> DXGI_OUTPUT_DESC outputDesc ; <nl> output - > GetDesc ( & outputDesc ) ; <nl> - if ( outputDesc . Monitor = = monitor ) <nl> + if ( cmpFunc ( outputDesc ) ) <nl> { <nl> + output . As ( & m_output ) ; <nl> / / check if adapter is changed <nl> if ( currentDesc . AdapterLuid . HighPart ! = foundDesc . AdapterLuid . HighPart <nl> | | currentDesc . AdapterLuid . LowPart ! = foundDesc . AdapterLuid . LowPart ) <nl> { <nl> - CLog : : LogF ( LOGDEBUG , " selected % S adapter . " , foundDesc . Description ) ; <nl> - <nl> - / / adapter is changed , ( re ) init hooks into new driver <nl> + / / adapter is changed <nl> + m_adapter = adapter ; <nl> + CLog : : LogF ( LOGDEBUG , " selected ` % S ` adapter on % S . " , foundDesc . Description , outputDesc . DeviceName ) ; <nl> + / / ( re ) init hooks into new driver <nl> Windowing ( ) . InitHooks ( output . Get ( ) ) ; <nl> + / / recreate d3d11 device on new adapter <nl> + if ( m_d3dDevice ) <nl> + HandleDeviceLost ( false ) ; <nl> } <nl> return ; <nl> } <nl> void DX : : DeviceResources : : SetMonitor ( HMONITOR monitor ) const <nl> } <nl> } <nl> <nl> + void DX : : DeviceResources : : SetMonitor ( HMONITOR monitor ) <nl> + { <nl> + HandleOutputChange ( [ monitor ] ( DXGI_OUTPUT_DESC outputDesc ) { <nl> + return outputDesc . Monitor = = monitor ; <nl> + } ) ; <nl> + } <nl> + <nl> void DX : : DeviceResources : : RegisterDeviceNotify ( IDeviceNotify * deviceNotify ) <nl> { <nl> m_deviceNotify = deviceNotify ; <nl> HMONITOR DX : : DeviceResources : : GetMonitor ( ) const <nl> if ( m_swapChain ) <nl> { <nl> ComPtr < IDXGIOutput > output ; <nl> - HRESULT hr = m_swapChain - > GetContainingOutput ( & output ) ; RETURN_ERR ( nullptr ) ; <nl> + GetOutput ( output . GetAddressOf ( ) ) ; <nl> if ( output ) <nl> { <nl> DXGI_OUTPUT_DESC desc ; <nl> void DX : : DeviceResources : : SetWindow ( Windows : : UI : : Core : : CoreWindow ^ window ) <nl> auto coreWindow = Windows : : UI : : Core : : CoreWindow : : GetForCurrentThread ( ) ; <nl> m_logicalSize = Windows : : Foundation : : Size ( coreWindow - > Bounds . Width , coreWindow - > Bounds . Height ) ; <nl> m_dpi = Windows : : Graphics : : Display : : DisplayInformation : : GetForCurrentView ( ) - > LogicalDpi ; <nl> + SetWindowPos ( coreWindow - > Bounds ) ; <nl> } ) ; <nl> if ( dispatcher - > HasThreadAccess ) <nl> handler - > Invoke ( ) ; <nl> void DX : : DeviceResources : : SetWindow ( Windows : : UI : : Core : : CoreWindow ^ window ) <nl> CreateWindowSizeDependentResources ( ) ; <nl> } <nl> <nl> + void DX : : DeviceResources : : SetWindowPos ( Windows : : Foundation : : Rect rect ) <nl> + { <nl> + int centerX = rect . X + rect . Width / 2 ; <nl> + int centerY = rect . Y + rect . Height / 2 ; <nl> + <nl> + HandleOutputChange ( [ centerX , centerY ] ( DXGI_OUTPUT_DESC outputDesc ) { <nl> + / / DesktopCoordinates depends on the DPI of the desktop <nl> + return outputDesc . DesktopCoordinates . left < = centerX & & outputDesc . DesktopCoordinates . right > = centerX <nl> + & & outputDesc . DesktopCoordinates . top < = centerY & & outputDesc . DesktopCoordinates . bottom > = centerY ; <nl> + } ) ; <nl> + } <nl> + <nl> / / Call this method when the app suspends . It provides a hint to the driver that the app <nl> / / is entering an idle state and that temporary buffers can be reclaimed for use by other apps . <nl> void DX : : DeviceResources : : Trim ( ) const <nl> mmm a / xbmc / rendering / dx / DeviceResources . h <nl> ppp b / xbmc / rendering / dx / DeviceResources . h <nl> <nl> # include < dxgi1_2 . h > <nl> # include < easyhook / easyhook . h > <nl> # endif <nl> + # include < functional > <nl> # include < memory > <nl> <nl> # include " DirectXHelper . h " <nl> namespace DX <nl> D3D_FEATURE_LEVEL GetDeviceFeatureLevel ( ) const { return m_d3dFeatureLevel ; } <nl> CD3DTexture * GetBackBuffer ( ) { return & m_backBufferTex ; } <nl> <nl> - void GetOutput ( IDXGIOutput * * pOutput ) const ; <nl> + void GetOutput ( IDXGIOutput * * ppOutput ) const ; <nl> void GetAdapterDesc ( DXGI_ADAPTER_DESC * desc ) const ; <nl> void GetDisplayMode ( DXGI_MODE_DESC * mode ) const ; <nl> <nl> namespace DX <nl> bool IsStereoEnabled ( ) const { return m_stereoEnabled ; } <nl> void SetStereoIdx ( byte idx ) { m_backBufferTex . SetViewIdx ( idx ) ; } <nl> <nl> - void SetMonitor ( HMONITOR monitor ) const ; <nl> + void SetMonitor ( HMONITOR monitor ) ; <nl> HMONITOR GetMonitor ( ) const ; <nl> # if defined ( TARGET_WINDOWS_DESKTOP ) <nl> void SetWindow ( HWND window ) ; <nl> # elif defined ( TARGET_WINDOWS_STORE ) <nl> void Trim ( ) const ; <nl> void SetWindow ( Windows : : UI : : Core : : CoreWindow ^ window ) ; <nl> + void SetWindowPos ( Windows : : Foundation : : Rect rect ) ; <nl> # endif / / TARGET_WINDOWS_STORE <nl> <nl> private : <nl> namespace DX <nl> void UpdateRenderTargetSize ( ) ; <nl> void OnDeviceLost ( bool removed ) ; <nl> void OnDeviceRestored ( ) ; <nl> + void HandleOutputChange ( const std : : function < bool ( DXGI_OUTPUT_DESC ) > & cmpFunc ) ; <nl> <nl> HWND m_window { nullptr } ; <nl> # if defined ( TARGET_WINDOWS_STORE ) <nl> mmm a / xbmc / rendering / dx / RenderSystemDX . cpp <nl> ppp b / xbmc / rendering / dx / RenderSystemDX . cpp <nl> void CRenderSystemDX : : ResetScissors ( ) <nl> <nl> void CRenderSystemDX : : OnDXDeviceLost ( ) <nl> { <nl> - DestroyRenderSystem ( ) ; <nl> + CRenderSystemDX : : DestroyRenderSystem ( ) ; <nl> } <nl> <nl> void CRenderSystemDX : : OnDXDeviceRestored ( ) <nl> { <nl> - InitRenderSystem ( ) ; <nl> + CRenderSystemDX : : InitRenderSystem ( ) ; <nl> } <nl> <nl> void CRenderSystemDX : : SetStereoMode ( RENDER_STEREO_MODE mode , RENDER_STEREO_VIEW view ) <nl> mmm a / xbmc / windowing / win10 / WinSystemWin10 . cpp <nl> ppp b / xbmc / windowing / win10 / WinSystemWin10 . cpp <nl> bool CWinSystemWin10 : : CreateNewWindow ( const std : : string & name , bool fullScreen , <nl> AdjustWindow ( ) ; <nl> / / dispatch all events currently pending in the queue to show window ' s content <nl> / / and hide UWP splash , without this the Kodi ' s splash will not be shown <nl> - m_coreWindow - > Dispatcher - > ProcessEvents ( Windows : : UI : : Core : : CoreProcessEventsOption : : ProcessAllIfPresent ) ; <nl> + m_coreWindow - > Dispatcher - > ProcessEvents ( Windows : : UI : : Core : : CoreProcessEventsOption : : ProcessOneAndAllPending ) ; <nl> <nl> return true ; <nl> } <nl> mmm a / xbmc / windowing / win10 / WinSystemWin10DX . cpp <nl> ppp b / xbmc / windowing / win10 / WinSystemWin10DX . cpp <nl> bool CWinSystemWin10DX : : CreateNewWindow ( const std : : string & name , bool fullScreen <nl> return false ; <nl> <nl> m_deviceResources = DX : : DeviceResources : : Get ( ) ; <nl> + <nl> + bool created = CWinSystemWin10 : : CreateNewWindow ( name , fullScreen , res ) ; <nl> m_deviceResources - > SetWindow ( m_coreWindow . Get ( ) ) ; <nl> + created & = m_deviceResources - > HasValidDevice ( ) ; <nl> <nl> - bool created = CWinSystemWin10 : : CreateNewWindow ( name , fullScreen , res ) & & m_deviceResources - > HasValidDevice ( ) ; <nl> if ( created ) <nl> { <nl> CGenericTouchInputHandler : : GetInstance ( ) . RegisterHandler ( & CGenericTouchActionHandler : : GetInstance ( ) ) ; <nl> mmm a / xbmc / windowing / windows / WinEventsWin32 . cpp <nl> ppp b / xbmc / windowing / windows / WinEventsWin32 . cpp <nl> LRESULT CALLBACK CWinEventsWin32 : : WndProc ( HWND hWnd , UINT uMsg , WPARAM wParam , L <nl> newEvent . move . x = g_sizeMoveX ; <nl> newEvent . move . y = g_sizeMoveY ; <nl> <nl> + / / tell the device about new position <nl> + DX : : Windowing ( ) . OnMove ( newEvent . move . x , newEvent . move . y ) ; <nl> / / tell the application about new position <nl> if ( g_application . GetRenderGUI ( ) & & ! DX : : Windowing ( ) . IsAlteringWindow ( ) ) <nl> g_application . OnEvent ( newEvent ) ; <nl> LRESULT CALLBACK CWinEventsWin32 : : WndProc ( HWND hWnd , UINT uMsg , WPARAM wParam , L <nl> newEvent . move . y = g_sizeMoveY ; <nl> <nl> CLog : : Log ( LOGDEBUG , __FUNCTION__ " : window move event " ) ; <nl> + <nl> + / / tell the device about new position <nl> + DX : : Windowing ( ) . OnMove ( newEvent . move . x , newEvent . move . y ) ; <nl> if ( g_application . GetRenderGUI ( ) & & ! DX : : Windowing ( ) . IsAlteringWindow ( ) ) <nl> g_application . OnEvent ( newEvent ) ; <nl> } <nl> mmm a / xbmc / windowing / windows / WinSystemWin32 . cpp <nl> ppp b / xbmc / windowing / windows / WinSystemWin32 . cpp <nl> bool CWinSystemWin32 : : CreateNewWindow ( const std : : string & name , bool fullScreen , <nl> return false ; <nl> } <nl> <nl> + / / put the window at desired display <nl> + RECT screenRect = ScreenRect ( m_nScreen ) ; <nl> + m_nLeft = screenRect . left ; <nl> + m_nTop = screenRect . top ; <nl> + <nl> if ( state = = WINDOW_STATE_WINDOWED ) <nl> { <nl> - RECT newScreenRect = ScreenRect ( m_nScreen ) ; <nl> - m_nLeft = newScreenRect . left + ( ( newScreenRect . right - newScreenRect . left ) / 2 ) - ( m_nWidth / 2 ) ; <nl> - m_nTop = newScreenRect . top + ( ( newScreenRect . bottom - newScreenRect . top ) / 2 ) - ( m_nHeight / 2 ) ; <nl> + / / centering window at desktop <nl> + m_nLeft + = ( screenRect . right - screenRect . left ) / 2 - m_nWidth / 2 ; <nl> + m_nTop + = ( screenRect . bottom - screenRect . top ) / 2 - m_nHeight / 2 ; <nl> m_ValidWindowedPosition = true ; <nl> } <nl> <nl> bool CWinSystemWin32 : : SetFullScreen ( bool fullScreen , RESOLUTION_INFO & res , bool <nl> <nl> / / restoring native resolution on " old " display <nl> RestoreDesktopResolution ( m_nScreen ) ; <nl> + <nl> + / / notify about screen change ( it may require recreate rendering device ) <nl> + m_fRefreshRate = res . fRefreshRate ; / / use desired refresh for driver hook <nl> + OnScreenChange ( res . iScreen ) ; <nl> } <nl> <nl> m_bFullScreen = fullScreen ; <nl> mmm a / xbmc / windowing / windows / WinSystemWin32 . h <nl> ppp b / xbmc / windowing / windows / WinSystemWin32 . h <nl> class CWinSystemWin32 : public CWinSystemBase <nl> virtual void CreateBackBuffer ( ) = 0 ; <nl> virtual void ResizeDeviceBuffers ( ) = 0 ; <nl> virtual bool IsStereoEnabled ( ) = 0 ; <nl> + virtual void OnScreenChange ( int screen ) = 0 ; <nl> virtual void AdjustWindow ( bool forceResize = false ) ; <nl> void CenterCursor ( ) const ; <nl> <nl> mmm a / xbmc / windowing / windows / WinSystemWin32DX . cpp <nl> ppp b / xbmc / windowing / windows / WinSystemWin32DX . cpp <nl> bool CWinSystemWin32DX : : ResizeWindow ( int newWidth , int newHeight , int newLeft , i <nl> <nl> void CWinSystemWin32DX : : OnMove ( int x , int y ) <nl> { <nl> + / / do not handle moving at window creation because MonitorFromWindow <nl> + / / returns default system monitor in case of m_hWnd is null <nl> + if ( ! m_hWnd ) <nl> + return ; <nl> + <nl> HMONITOR newMonitor = MonitorFromWindow ( m_hWnd , MONITOR_DEFAULTTONEAREST ) ; <nl> const MONITOR_DETAILS * monitor = GetMonitor ( m_nScreen ) ; <nl> if ( newMonitor ! = monitor - > hMonitor ) <nl> bool CWinSystemWin32DX : : IsStereoEnabled ( ) <nl> return m_deviceResources - > IsStereoEnabled ( ) ; <nl> } <nl> <nl> + void CWinSystemWin32DX : : OnScreenChange ( int screen ) <nl> + { <nl> + const MONITOR_DETAILS * new_monitor = GetMonitor ( screen ) ; <nl> + const MONITOR_DETAILS * old_monitor = GetMonitor ( m_nScreen ) ; <nl> + if ( old_monitor - > hMonitor ! = new_monitor - > hMonitor ) <nl> + { <nl> + m_deviceResources - > SetMonitor ( new_monitor - > hMonitor ) ; <nl> + } <nl> + } <nl> + <nl> void CWinSystemWin32DX : : OnResize ( int width , int height ) <nl> { <nl> if ( ! m_IsAlteringWindow ) <nl> void CWinSystemWin32DX : : FixRefreshRateIfNecessary ( const D3D10DDIARG_CREATERESOUR <nl> float refreshRate = RATIONAL_TO_FLOAT ( pResource - > pPrimaryDesc - > ModeDesc . RefreshRate ) ; <nl> if ( refreshRate > 10 . 0f & & refreshRate < 300 . 0f ) <nl> { <nl> + / / interlaced <nl> + if ( pResource - > pPrimaryDesc - > ModeDesc . ScanlineOrdering > DXGI_DDI_MODE_SCANLINE_ORDER_PROGRESSIVE ) <nl> + refreshRate / = 2 ; <nl> + <nl> uint32_t refreshNum , refreshDen ; <nl> DX : : GetRefreshRatio ( floor ( m_fRefreshRate ) , & refreshNum , & refreshDen ) ; <nl> float diff = fabs ( refreshRate - static_cast < float > ( refreshNum ) / static_cast < float > ( refreshDen ) ) / refreshRate ; <nl> - CLog : : Log ( LOGDEBUG , __FUNCTION__ " : refreshRate : % 0 . 4f , desired : % 0 . 4f , deviation : % . 5f , fixRequired : % s " , <nl> - refreshRate , m_fRefreshRate , diff , ( diff > 0 . 0005 ) ? " true " : " false " ) ; <nl> - if ( diff > 0 . 0005 ) <nl> + CLog : : LogF ( LOGDEBUG , " refreshRate : % 0 . 4f , desired : % 0 . 4f , deviation : % . 5f , fixRequired : % s , % d " , <nl> + refreshRate , m_fRefreshRate , diff , ( diff > 0 . 0005 & & diff < 0 . 1 ) ? " yes " : " no " , pResource - > pPrimaryDesc - > Flags ) ; <nl> + if ( diff > 0 . 0005 & & diff < 0 . 1 ) <nl> { <nl> pResource - > pPrimaryDesc - > ModeDesc . RefreshRate . Numerator = refreshNum ; <nl> pResource - > pPrimaryDesc - > ModeDesc . RefreshRate . Denominator = refreshDen ; <nl> - CLog : : Log ( LOGDEBUG , __FUNCTION__ " : refreshRate fix applied - > % 0 . 3f " , RATIONAL_TO_FLOAT ( pResource - > pPrimaryDesc - > ModeDesc . RefreshRate ) ) ; <nl> + if ( pResource - > pPrimaryDesc - > ModeDesc . ScanlineOrdering > DXGI_DDI_MODE_SCANLINE_ORDER_PROGRESSIVE ) <nl> + pResource - > pPrimaryDesc - > ModeDesc . RefreshRate . Numerator * = 2 ; <nl> + CLog : : LogF ( LOGDEBUG , " refreshRate fix applied - > % 0 . 3f " , RATIONAL_TO_FLOAT ( pResource - > pPrimaryDesc - > ModeDesc . RefreshRate ) ) ; <nl> } <nl> } <nl> } <nl> mmm a / xbmc / windowing / windows / WinSystemWin32DX . h <nl> ppp b / xbmc / windowing / windows / WinSystemWin32DX . h <nl> class CWinSystemWin32DX : public CWinSystemWin32 , public CRenderSystemDX <nl> void CreateBackBuffer ( ) override ; <nl> void ResizeDeviceBuffers ( ) override ; <nl> bool IsStereoEnabled ( ) override ; <nl> + void OnScreenChange ( int screen ) override ; <nl> <nl> HMODULE m_hDriverModule ; <nl> TRACED_HOOK_HANDLE m_hHook ; <nl> | Merge pull request from afedchin / multigpu - fix | xbmc/xbmc | 3d8a20a735604c007f8b6d9e14419096faf47507 | 2018-02-07T09:28:44Z |
mmm a / tensorflow / compiler / mlir / xla / ir / lhlo_ops . td <nl> ppp b / tensorflow / compiler / mlir / xla / ir / lhlo_ops . td <nl> def LHLO_BufferOrTuple : AnyTypeOf < [ LHLO_Buffer , LHLO_TupleBuffer ] > ; <nl> / / XLA nullary op definitions . <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - class LHLO_Op < string mnemonic , list < OpTrait > traits > : Op < LHLO_Dialect , <nl> - mnemonic , traits > ; <nl> + class LHLO_Op < string mnemonic , list < OpTrait > traits > : <nl> + Op < LHLO_Dialect , mnemonic , <nl> + ! listconcat ( [ MemoryEffects < [ MemRead , MemWrite ] > ] , traits ) > ; <nl> <nl> def LHLO_ConstOp : LHLO_Op < " constant " , [ ] > , BASE_HLO_ConstOp { <nl> let arguments = ( ins <nl> ElementsAttr : $ value , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> def LHLO_IotaOp : LHLO_Op < " iota " , [ ] > , BASE_HLO_IotaOp { <nl> let arguments = ( ins I64Attr : $ iota_dimension , <nl> - LHLO_Buffer : $ output ) ; <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output ) ; <nl> } <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> def LHLO_IotaOp : LHLO_Op < " iota " , [ ] > , BASE_HLO_IotaOp { <nl> <nl> class LHLO_UnaryElementwiseOp < string mnemonic > : <nl> LHLO_Op < mnemonic , [ SameTypeOperands ] > { <nl> - let arguments = ( ins LHLO_Buffer : $ input , <nl> - LHLO_Buffer : $ output ) ; <nl> + let arguments = ( ins Arg < LHLO_Buffer , " " , [ MemRead ] > : $ input , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output ) ; <nl> } <nl> <nl> def LHLO_AbsOp : LHLO_UnaryElementwiseOp < " abs " > , BASE_HLO_AbsOp ; <nl> def LHLO_AbsOp : LHLO_UnaryElementwiseOp < " abs " > , BASE_HLO_AbsOp ; <nl> def LHLO_CeilOp : LHLO_UnaryElementwiseOp < " ceil " > , BASE_HLO_CeilOp ; <nl> <nl> def LHLO_ConvertOp : LHLO_Op < " convert " , [ SameOperandsShape ] > , BASE_HLO_ConvertOp { <nl> - let arguments = ( ins LHLO_Buffer : $ input , <nl> - LHLO_Buffer : $ output ) ; <nl> + let arguments = ( ins Arg < LHLO_Buffer , " " , [ MemRead ] > : $ input , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output ) ; <nl> } <nl> <nl> def LHLO_CosOp : LHLO_UnaryElementwiseOp < " cos " > , BASE_HLO_CosOp ; <nl> def LHLO_TanhOp : LHLO_UnaryElementwiseOp < " tanh " > , BASE_HLO_TanhOp ; <nl> class LHLO_BinaryElementwiseOp < string mnemonic , list < OpTrait > traits > : <nl> LHLO_Op < mnemonic , traits > { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ lhs , <nl> - LHLO_Buffer : $ rhs , <nl> - LHLO_Buffer : $ out , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ lhs , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ rhs , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ out , <nl> OptionalAttr < BroadcastDimAttr > : $ broadcast_dimensions <nl> ) ; <nl> } <nl> def LHLO_ReduceOp : LHLO_Op < " reduce " , [ <nl> SingleBlockImplicitTerminator < " TerminatorOp " > <nl> ] > , BASE_HLO_ReduceOp { <nl> let arguments = ( ins <nl> - Variadic < LHLO_BufferOrTuple > : $ operands , <nl> - Variadic < LHLO_BufferOrTuple > : $ init_values , <nl> - Variadic < LHLO_BufferOrTuple > : $ out , <nl> + Arg < Variadic < LHLO_BufferOrTuple > , " " , [ MemRead ] > : $ operands , <nl> + Arg < Variadic < LHLO_BufferOrTuple > , " " , [ MemRead ] > : $ init_values , <nl> + Arg < Variadic < LHLO_BufferOrTuple > , " " , [ MemWrite ] > : $ out , <nl> I64ElementsAttr : $ dimensions <nl> ) ; <nl> <nl> def LHLO_ReduceOp : LHLO_Op < " reduce " , [ <nl> } <nl> <nl> def LHLO_ReduceWindowOp : LHLO_Op < " reduce_window " , [ <nl> - NoSideEffect , <nl> SingleBlockImplicitTerminator < " TerminatorOp " > <nl> ] > , BASE_HLO_ReduceWindowOp { <nl> <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ init_value , <nl> - LHLO_Buffer : $ out , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ init_value , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ out , <nl> I64ElementsAttr : $ window_dimensions , <nl> / / If strides or dilations attributes are missing then the default value is <nl> / / one for each of the input dimensions . Similarly , padding values are zero <nl> def LHLO_ReduceWindowOp : LHLO_Op < " reduce_window " , [ <nl> <nl> def LHLO_GetTupleElementOp : LHLO_Op < " get_tuple_element " , [ ] > , BASE_HLO_GetTupleElementOp { <nl> let arguments = ( ins <nl> - LHLO_TupleBuffer : $ input , <nl> - LHLO_BufferOrTuple : $ out , <nl> + Arg < LHLO_TupleBuffer , " " , [ MemRead ] > : $ input , <nl> + Arg < LHLO_BufferOrTuple , " " , [ MemWrite ] > : $ out , <nl> I32Attr : $ index <nl> ) ; <nl> } <nl> <nl> def LHLO_TupleOp : LHLO_Op < " tuple " , [ ] > , BASE_HLO_TupleOp { <nl> let arguments = ( ins <nl> - Variadic < LHLO_BufferOrTuple > : $ val , <nl> - LHLO_TupleBuffer : $ out ) ; <nl> + Arg < Variadic < LHLO_BufferOrTuple > , " " , [ MemRead ] > : $ val , <nl> + Arg < LHLO_TupleBuffer , " " , [ MemWrite ] > : $ out ) ; <nl> } <nl> <nl> def LHLO_CompareOp : LHLO_Op < " compare " , [ ] > , BASE_HLO_CompareOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ lhs , <nl> - LHLO_Buffer : $ rhs , <nl> - LHLO_PredBuffer : $ out , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ lhs , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ rhs , <nl> + Arg < LHLO_PredBuffer , " " , [ MemWrite ] > : $ out , <nl> OptionalAttr < BroadcastDimAttr > : $ broadcast_dimensions , <nl> HLO_ComparisonDirectionAttr : $ comparison_direction <nl> ) ; <nl> def LHLO_SliceOp : LHLO_Op < <nl> " slice " , <nl> [ AllTypesMatch < [ " start_indices " , " limit_indices " , " strides " ] > ] > { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ output , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output , <nl> I64ElementsAttr : $ start_indices , <nl> I64ElementsAttr : $ limit_indices , <nl> I64ElementsAttr : $ strides <nl> def LHLO_SliceOp : LHLO_Op < <nl> <nl> def HLO_DynamicUpdateSliceOp : LHLO_Op < " dynamic - update - slice " , [ ] > { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ update , <nl> - LHLO_Buffer : $ output , <nl> - Variadic < LHLO_Buffer > : $ start_indices <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ update , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output , <nl> + Arg < Variadic < LHLO_Buffer > , " " , [ MemRead ] > : $ start_indices <nl> ) ; <nl> } <nl> <nl> def HLO_BatchNormInferenceOp : LHLO_Op < " batch_norm_inference " , [ ] > , <nl> BASE_HLO_BatchNormInferenceOp { <nl> <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ scale , <nl> - LHLO_Buffer : $ offset , <nl> - LHLO_Buffer : $ mean , <nl> - LHLO_Buffer : $ variance , <nl> - LHLO_Buffer : $ output , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ scale , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ offset , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ mean , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ variance , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output , <nl> F32Attr : $ epsilon , <nl> I64Attr : $ feature_index <nl> ) ; <nl> def HLO_BatchNormInferenceOp : LHLO_Op < " batch_norm_inference " , [ ] > , <nl> def LHLO_BroadcastOp : LHLO_Op < " broadcast " , <nl> [ ] > , BASE_HLO_BroadcastOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ output , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output , <nl> I64ElementsAttr : $ broadcast_sizes <nl> ) ; <nl> } <nl> def LHLO_BroadcastOp : LHLO_Op < " broadcast " , <nl> def LHLO_BroadcastInDimOp : LHLO_Op < " broadcast_in_dim " , <nl> [ ] > , BASE_HLO_BroadcastInDimOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ output , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output , <nl> BroadcastDimAttr : $ broadcast_dimensions <nl> ) ; <nl> } <nl> <nl> def LHLO_ClampOp : LHLO_Op < " clamp " , [ ] > , BASE_HLO_ClampOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ min , <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ max , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ min , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ max , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> def LHLO_ConcatenateOp : LHLO_Op < " concatenate " , [ ] > , BASE_HLO_ConcatenateOp { <nl> let arguments = ( ins <nl> - Variadic < LHLO_Buffer > : $ val , <nl> - LHLO_Buffer : $ output , <nl> + Arg < Variadic < LHLO_Buffer > , " " , [ MemRead ] > : $ val , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output , <nl> I64Attr : $ dimension <nl> ) ; <nl> } <nl> <nl> def LHLO_ConvOp : LHLO_Op < " conv " , [ ] > , BASE_HLO_ConvOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ lhs , <nl> - LHLO_Buffer : $ rhs , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ lhs , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ rhs , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> def LHLO_CopyOp : LHLO_Op < " copy " , [ ] > , BASE_HLO_CopyOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> def LHLO_DotOp : LHLO_Op < " dot " , [ ] > , BASE_HLO_DotOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ lhs , <nl> - LHLO_Buffer : $ rhs , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ lhs , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ rhs , <nl> HLO_PrecisionConfigAttr : $ precision_config , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> def LHLO_GatherOp : LHLO_Op < " gather " , [ ] > , BASE_HLO_GatherOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_IntBuffer : $ start_indices , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_IntBuffer , " " , [ MemRead ] > : $ start_indices , <nl> I64Attr : $ index_vector_dim , <nl> I64ElementsAttr : $ offset_dims , <nl> I64ElementsAttr : $ slice_sizes , <nl> I64ElementsAttr : $ collapsed_slice_dims , <nl> I64ElementsAttr : $ start_index_map , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> def LHLO_ReshapeOp : LHLO_Op < " reshape " , [ ] > , BASE_HLO_ReshapeOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> <nl> def LHLO_SelectOp : LHLO_Op < " select " , [ ] > , BASE_HLO_SelectOp { <nl> let arguments = ( ins <nl> - LHLO_PredBuffer : $ pred , <nl> - LHLO_Buffer : $ on_true , <nl> - LHLO_Buffer : $ on_false , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_PredBuffer , " " , [ MemRead ] > : $ pred , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ on_true , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ on_false , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> - def LHLO_SelectAndScatterOp : LHLO_Op < " select_and_scatter " , <nl> - [ NoSideEffect ] > , BASE_HLO_SelectAndScatterOp { <nl> + def LHLO_SelectAndScatterOp : LHLO_Op < " select_and_scatter " , [ ] > , <nl> + BASE_HLO_SelectAndScatterOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ source , <nl> - LHLO_Buffer : $ init_value , <nl> - LHLO_Buffer : $ out , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ source , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ init_value , <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ out , <nl> OptionalAttr < I64ElementsAttr > : $ window_dimensions , <nl> OptionalAttr < I64ElementsAttr > : $ window_strides , <nl> OptionalAttr < I64ElementsAttr > : $ padding <nl> def LHLO_SelectAndScatterOp : LHLO_Op < " select_and_scatter " , <nl> <nl> def LHLO_ReverseOp : LHLO_Op < " reverse " , [ ] > , BASE_HLO_ReverseOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> I64ElementsAttr : $ dimensions , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> def LHLO_PadOp : LHLO_Op < " pad " , [ ] > , BASE_HLO_PadOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> - LHLO_Buffer : $ padding_value , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ padding_value , <nl> I64ElementsAttr : $ edge_padding_low , <nl> I64ElementsAttr : $ edge_padding_high , <nl> I64ElementsAttr : $ interior_padding , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> def LHLO_TransposeOp : LHLO_Op < " transpose " , [ ] > , BASE_HLO_TransposeOp { <nl> let arguments = ( ins <nl> - LHLO_Buffer : $ operand , <nl> + Arg < LHLO_Buffer , " " , [ MemRead ] > : $ operand , <nl> I64ElementsAttr : $ permutation , <nl> - LHLO_Buffer : $ output <nl> + Arg < LHLO_Buffer , " " , [ MemWrite ] > : $ output <nl> ) ; <nl> } <nl> <nl> | Added support for SideEffects interfaces to LHLO operations . | tensorflow/tensorflow | 20981d2320f7b377f76b12700d49ec33dd3de36f | 2020-04-06T13:32:55Z |
mmm a / CONTRIBUTING . md <nl> ppp b / CONTRIBUTING . md <nl> class A { <nl> return & singleton_ ; <nl> } <nl> } ; <nl> - static_assert ( std : : is_same ( A * , decltype ( A : : singelton ( ) ) ) : : value , " hmm " ) ; <nl> + static_assert ( std : : is_same ( A * , decltype ( A : : singleton ( ) ) ) : : value , " hmm " ) ; <nl> ` ` ` <nl> <nl> * The compiler will run out of heap if you attempt to compile files that <nl> mmm a / caffe2 / python / serialized_test / README . md <nl> ppp b / caffe2 / python / serialized_test / README . md <nl> Major functionality lives in ` serialized_test_util . py ` <nl> <nl> If we ' d like to extend the test framework beyond that for operator tests , we can create a new subfolder for them inside ` caffe2 / python / serialized_test / data ` . <nl> <nl> - Note , we currently don ' t support using other hypothesis decorators on top of ` given_and_seeded ` . Hypothis has some handling to explicitly check that ` @ given ` is on the bottom of the decorator stack . <nl> + Note , we currently don ' t support using other hypothesis decorators on top of ` given_and_seeded ` . Hypothesis has some handling to explicitly check that ` @ given ` is on the bottom of the decorator stack . <nl> <nl> If there are multiple calls to assertReferenceChecks in a test function , we ' ll serialize and write the last one . The actual input checked may then differ if we refactor a test function that calls this multiple times , though the serialized test should still pass since we then use the serialized input to generate a dynamic output . <nl> mmm a / caffe2 / quantization / server / README . md <nl> ppp b / caffe2 / quantization / server / README . md <nl> Please use Int8 * op types because op types without Int8 prefix and DNNLOWP engin <nl> # # Quantization method <nl> <nl> The basic quantization method is similar to that used by gemmlowp ( https : / / github . com / google / gemmlowp / ) and TensorFlow Lite . <nl> - That is we use a linear quantizaion method where quantization and dequantization is a simple affine transformation ( plus rounding and saturation in quantization ) . Therefore , quantization bins are uniform . <nl> + That is we use a linear quantization method where quantization and dequantization is a simple affine transformation ( plus rounding and saturation in quantization ) . Therefore , quantization bins are uniform . <nl> Similar to gemmlowp , our quantized operators use asymmetric quantization by default but there ' s an option to use symmetric quantization ( this can be controlled globally using caffe2_dnnlowp_preserve_activation_sparsity and caffe2_dnnlowp_preserve_weight_sparsity gflags options or per - operator basis using preserve_activation_sparsity and preserve_weight_sparsity arguments ) . <nl> Unsigned 8 - bit integers are used for activations and signed 8 - bit integers are used for weights ( this design choice is mostly because int8 SIMD instructions in x86 has one input operand unsigned and the other input operand signed ) . <nl> We also support per - output - channel quantization similarly to gemmlowp ( Int8FC with DNNLOWP_ROWWISE engine ) . Note that only the weights can have multiple pairs of scale and zero_offset ( per output channel ) and activations can still have only one pair of scale and zero_offset . This is because if an activation has per - channel quantization , inner - products in a GEMM that multiplies the activation would require summing up numbers with different scales , which is significant overhead . <nl> The following quantized operators are currently implemented <nl> <nl> # # Differences from mobile quantization operators <nl> <nl> - The aim is Int8 * operators in caffe2 / operators / quantized ( primarily optimized for mobile processsors ) compatible with the operators in this directory , but there ' re a few minor differences we will soon to fix <nl> + The aim is Int8 * operators in caffe2 / operators / quantized ( primarily optimized for mobile processors ) compatible with the operators in this directory , but there ' re a few minor differences we will soon to fix <nl> <nl> * The implementation of Int8AveragePool in this directory can have different quantization parameters for its input and output . <nl> - * Int8Sum in caffe2 / operators / quantized assumes 2 input tensors while the implementation in this directory can work with arbitraty number of input tensors . <nl> + * Int8Sum in caffe2 / operators / quantized assumes 2 input tensors while the implementation in this directory can work with arbitrary number of input tensors . <nl> <nl> # # Extra functionality <nl> <nl> In fact , it ' s currently mandatory to set followed_by to Sigmoid and Tanh . This <nl> <nl> * Measure quantization error <nl> <nl> - To faciliate numerical debugging , setting measure_quantization_error argument will run a shadow copy of single - precision floating - point operator and reports the L2 error compared to quantized outputs . This can help identifying which operator introduces the biggest error to narrow down the numerical issues . <nl> + To facilitate numerical debugging , setting measure_quantization_error argument will run a shadow copy of single - precision floating - point operator and reports the L2 error compared to quantized outputs . This can help identifying which operator introduces the biggest error to narrow down the numerical issues . <nl> <nl> * Different precision <nl> <nl> | docs : minor spelling tweaks | pytorch/pytorch | d8260239a0a5b3e0de4e4cc3be5ec15df3bf220e | 2018-12-13T02:17:14Z |
mmm a / tensorflow / python / keras / layers / lstm_test . py <nl> ppp b / tensorflow / python / keras / layers / lstm_test . py <nl> def test_static_shape_inference_LSTM ( self ) : <nl> layer = keras . layers . LSTM ( units , return_sequences = True ) <nl> model . add ( layer ) <nl> outputs = model . layers [ - 1 ] . output <nl> - self . assertEqual ( outputs . get_shape ( ) . as_list ( ) , [ None , timesteps , units ] ) <nl> + self . assertEqual ( outputs . shape . as_list ( ) , [ None , timesteps , units ] ) <nl> <nl> def test_dynamic_behavior_LSTM ( self ) : <nl> num_samples = 2 <nl> | Replaced get_shape ( ) to shape . | tensorflow/tensorflow | b445b1c6f3f2ae73fa6e6fd05a0d0746a406af31 | 2019-03-17T02:38:39Z |
mmm a / cocos / ui / UIWebViewImpl - tizen . cpp <nl> ppp b / cocos / ui / UIWebViewImpl - tizen . cpp <nl> namespace cocos2d { <nl> ewk_view_url_set ( _ewkView , urlchar ) ; <nl> } <nl> <nl> + void WebViewImpl : : loadURL ( const std : : string & url , bool cleanCachedData ) { <nl> + this - > loadURL ( url ) ; <nl> + } <nl> + <nl> void WebViewImpl : : loadFile ( const std : : string & fileName ) { <nl> auto fileUtiles = FileUtils : : getInstance ( ) ; <nl> auto fileFullPath = fileUtiles - > fullPathForFilename ( fileName ) ; <nl> mmm a / cocos / ui / UIWebViewImpl - tizen . h <nl> ppp b / cocos / ui / UIWebViewImpl - tizen . h <nl> namespace cocos2d { <nl> void loadHTMLString ( const std : : string & string , const std : : string & baseURL ) ; <nl> <nl> void loadURL ( const std : : string & url ) ; <nl> + void loadURL ( const std : : string & url , bool cleanCachedData ) ; <nl> <nl> void loadFile ( const std : : string & fileName ) ; <nl> <nl> | Solve the compile error when building platform tizen . ( ) | cocos2d/cocos2d-x | f6f7b2157a36f47a73c77243637a74fea52573fa | 2017-01-19T01:43:23Z |
mmm a / VERSION <nl> ppp b / VERSION <nl> @ @ - 1 + 1 @ @ <nl> - 1 . 11 . 0 <nl> + 1 . 12 . 0 - dev <nl> mmm a / docs / root / intro / deprecated . rst <nl> ppp b / docs / root / intro / deprecated . rst <nl> The following features have been DEPRECATED and will be removed in the specified <nl> A logged warning is expected for each deprecated item that is in deprecation window . <nl> Deprecated items below are listed in chronological order . <nl> <nl> + Version 1 . 12 . 0 ( pending ) <nl> + = = = = = = = = = = = = = = = = = = = = = = = = <nl> + <nl> + <nl> Version 1 . 11 . 0 ( July 11 , 2019 ) <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> * The - - max - stats and - - max - obj - name - len flags no longer has any effect . <nl> mmm a / docs / root / intro / version_history . rst <nl> ppp b / docs / root / intro / version_history . rst <nl> <nl> Version history <nl> mmmmmmmmmmmmmmm <nl> <nl> + 1 . 12 . 0 ( pending ) <nl> + = = = = = = = = = = = = = = = = <nl> + <nl> 1 . 11 . 0 ( July 11 , 2019 ) <nl> = = = = = = = = = = = = = = = = = = = = = = <nl> * access log : added a new field for downstream TLS session ID to file and gRPC access logger . <nl> | release : kicking off 1 . 12 ( ) | envoyproxy/envoy | 2c2411e6790894f57aa3aa4b5ff6f7e8317e02b3 | 2019-07-11T19:15:20Z |
mmm a / examples / rigid_body . py <nl> ppp b / examples / rigid_body . py <nl> <nl> penalty = 1e4 <nl> damping = 0 . 2 <nl> <nl> + gradient_clip = 10 <nl> spring_omega = 30 <nl> <nl> n_springs = 4 <nl> def apply_spring_force ( t : ti . i32 ) : <nl> pos_a , _ , rela_a = to_world ( t , a , spring_offset_a [ i ] ) <nl> pos_b , _ , rela_b = to_world ( t , b , spring_offset_b [ i ] ) <nl> dist = pos_a - pos_b <nl> - length = dist . norm ( ) <nl> + length = dist . norm ( ) + 1e - 4 <nl> target_length = spring_length [ i ] + spring_actuation [ i ] * ti . sin ( <nl> spring_omega * t * dt + spring_phase [ i ] ) <nl> impulse = dt * ( length - target_length ) * spring_stiffness [ <nl> - i ] * ti . Vector . normalized ( dist ) <nl> + i ] / length * dist <nl> apply_impulse ( t , a , - impulse , pos_a ) <nl> apply_impulse ( t , b , impulse , pos_b ) <nl> <nl> def main ( ) : <nl> halfsize [ 2 ] = [ 0 . 03 , 0 . 03 ] <nl> <nl> l = 0 . 1 <nl> - s = 10 <nl> + s = 30 <nl> add_spring ( 0 , 0 , 1 , [ - 0 . 03 , 0 . 00 ] , [ 0 . 0 , 0 . 0 ] , l , s ) <nl> add_spring ( 1 , 0 , 1 , [ - 0 . 1 , 0 . 00 ] , [ - 0 . 0 , 0 . 0 ] , l , s ) <nl> add_spring ( 2 , 0 , 2 , [ 0 . 03 , 0 . 00 ] , [ - 0 . 0 , 0 . 0 ] , l , s ) <nl> def main ( ) : <nl> print ( halfsize . grad [ i ] [ d ] ) <nl> halfsize [ i ] [ d ] + = learning_rate * halfsize . grad [ i ] [ d ] <nl> ' ' ' <nl> + <nl> + def clip ( x ) : <nl> + return max ( min ( x , gradient_clip ) , - gradient_clip ) <nl> <nl> for i in range ( n_springs ) : <nl> print ( spring_actuation . grad [ i ] ) <nl> print ( spring_phase . grad [ i ] ) <nl> - spring_actuation [ i ] + = learning_rate * spring_actuation . grad [ i ] <nl> + spring_actuation [ i ] + = learning_rate * clip ( spring_actuation . grad [ i ] ) <nl> spring_actuation [ i ] = max ( min ( spring_actuation [ i ] , spring_length [ i ] * 0 . 5 ) , - spring_length [ i ] * 0 . 5 ) <nl> - spring_phase [ i ] + = learning_rate * spring_phase . grad [ i ] <nl> + spring_phase [ i ] + = learning_rate * clip ( spring_phase . grad [ i ] ) <nl> <nl> clear ( ) <nl> forward ( ' final ' ) <nl> | gradient clipping for stability | taichi-dev/taichi | c85e858325e6f40471a73972a4c5b298cda456fe | 2019-09-14T01:47:18Z |
mmm a / toolsrc / src / commands_integrate . cpp <nl> ppp b / toolsrc / src / commands_integrate . cpp <nl> namespace vcpkg : : Commands : : Integrate <nl> std : : error_code ec ; <nl> bool was_deleted = fs : : remove ( path , ec ) ; <nl> <nl> - if ( ec ) <nl> - { <nl> - System : : println ( System : : color : : error , " Error : Unable to remove user - wide integration : % d " , ec . message ( ) ) ; <nl> - exit ( EXIT_FAILURE ) ; <nl> - } <nl> + Checks : : check_exit ( VCPKG_LINE_INFO , ! ec , " Error : Unable to remove user - wide integration : % d " , ec . message ( ) ) ; <nl> <nl> if ( was_deleted ) <nl> { <nl> | Use Checks : : check_exit ( ) | microsoft/vcpkg | 3d978f8310285d3e136b794e2346158e8e72b005 | 2017-03-23T00:01:11Z |
mmm a / tensorflow / g3doc / api_docs / python / functions_and_classes / shard2 / tf . test . TestCase . md <nl> ppp b / tensorflow / g3doc / api_docs / python / functions_and_classes / shard2 / tf . test . TestCase . md <nl> then compares them using self . _AssertProtoEqual ( ) . <nl> <nl> - - - <nl> <nl> - # # # # ` tf . test . TestCase . assertProtoEqualsVersion ( expected , actual , producer = 17 , min_consumer = 0 ) ` { # TestCase . assertProtoEqualsVersion } <nl> + # # # # ` tf . test . TestCase . assertProtoEqualsVersion ( expected , actual , producer = 18 , min_consumer = 0 ) ` { # TestCase . assertProtoEqualsVersion } <nl> <nl> <nl> <nl> mmm a / tensorflow / g3doc / api_docs / python / test . md <nl> ppp b / tensorflow / g3doc / api_docs / python / test . md <nl> then compares them using self . _AssertProtoEqual ( ) . <nl> <nl> - - - <nl> <nl> - # # # # ` tf . test . TestCase . assertProtoEqualsVersion ( expected , actual , producer = 17 , min_consumer = 0 ) ` { # TestCase . assertProtoEqualsVersion } <nl> + # # # # ` tf . test . TestCase . assertProtoEqualsVersion ( expected , actual , producer = 18 , min_consumer = 0 ) ` { # TestCase . assertProtoEqualsVersion } <nl> <nl> <nl> <nl> | Update generated Python Op docs . | tensorflow/tensorflow | a0acc3fd35dc96335c8e00d32aa61e89c2362c9a | 2016-12-05T19:42:55Z |
mmm a / lib / SIL / SILLocation . cpp <nl> ppp b / lib / SIL / SILLocation . cpp <nl> InlinedLocation InlinedLocation : : getInlinedLocation ( SILLocation L ) { <nl> return InlinedLocation ( S ) ; <nl> if ( Pattern * P = L . getAsASTNode < Pattern > ( ) ) <nl> return InlinedLocation ( P ) ; <nl> + if ( Decl * D = L . getAsASTNode < Decl > ( ) ) <nl> + return InlinedLocation ( D ) ; <nl> <nl> if ( Optional < SILFileLocation > FileLoc = L . getAs < SILFileLocation > ( ) ) <nl> return InlinedLocation ( FileLoc . getValue ( ) . getFileLocation ( ) ) ; <nl> InlinedLocation InlinedLocation : : getInlinedLocation ( SILLocation L ) { <nl> return InlinedLocation ( InlinedLoc . getValue ( ) . getFileLocation ( ) ) ; <nl> } <nl> <nl> - / / If the body is auto - generated , the location might be wrapping a Decl . <nl> - if ( Decl * D = L . getAsASTNode < Decl > ( ) ) { <nl> - assert ( L . isAutoGenerated ( ) ) ; <nl> - InlinedLocation IL ( D ) ; <nl> - IL . markAutoGenerated ( ) ; <nl> - return IL ; <nl> - } <nl> - <nl> llvm_unreachable ( " Cannot construct Inlined loc from the given location . " ) ; <nl> } <nl> <nl> MandatoryInlinedLocation : : getMandatoryInlinedLocation ( SILLocation L ) { <nl> <nl> / / If the body is auto - generated , the location might be wrapping a Decl . <nl> if ( Decl * D = L . getAsASTNode < Decl > ( ) ) { <nl> - assert ( L . isAutoGenerated ( ) ) ; <nl> MandatoryInlinedLocation IL ( D ) ; <nl> IL . markAutoGenerated ( ) ; <nl> return IL ; <nl> | [ sil - inliner ] Removed invalid assert . | apple/swift | 90cbfb2e5765e5231c3b6113e492289f08a06f15 | 2013-12-23T06:00:54Z |
mmm a / util / python / BUILD <nl> ppp b / util / python / BUILD <nl> <nl> - licenses ( [ " restricted " ] ) <nl> + licenses ( [ " notice " ] ) # New BSD , Python Software Foundation <nl> <nl> package ( default_visibility = [ " / / visibility : public " ] ) <nl> <nl> | Fix license declaration for Python headers ( ) | tensorflow/tensorflow | 054b515feec0a3fca4cfb1f29adbf423c9027c3a | 2017-11-10T22:44:59Z |
mmm a / src / heap / heap . cc <nl> ppp b / src / heap / heap . cc <nl> bool Heap : : CollectGarbage ( AllocationSpace space , <nl> <nl> if ( collector = = MARK_COMPACTOR ) { <nl> size_t committed_memory_after = CommittedOldGenerationMemory ( ) ; <nl> - size_t used_memory_after = PromotedSpaceSizeOfObjects ( ) ; <nl> + size_t used_memory_after = OldGenerationSizeOfObjects ( ) ; <nl> MemoryReducer : : Event event ; <nl> event . type = MemoryReducer : : kMarkCompact ; <nl> event . time_ms = MonotonicallyIncreasingTimeInMs ( ) ; <nl> bool Heap : : PerformGarbageCollection ( <nl> / / GC . <nl> old_generation_allocation_counter_at_last_gc_ + = <nl> static_cast < size_t > ( promoted_objects_size_ ) ; <nl> - old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects ( ) ; <nl> + old_generation_size_at_last_gc_ = OldGenerationSizeOfObjects ( ) ; <nl> break ; <nl> case MINOR_MARK_COMPACTOR : <nl> MinorMarkCompact ( ) ; <nl> bool Heap : : PerformGarbageCollection ( <nl> double gc_speed = tracer ( ) - > CombinedMarkCompactSpeedInBytesPerMillisecond ( ) ; <nl> double mutator_speed = <nl> tracer ( ) - > CurrentOldGenerationAllocationThroughputInBytesPerMillisecond ( ) ; <nl> - size_t old_gen_size = PromotedSpaceSizeOfObjects ( ) ; <nl> + size_t old_gen_size = OldGenerationSizeOfObjects ( ) ; <nl> if ( collector = = MARK_COMPACTOR ) { <nl> / / Register the amount of external allocated memory . <nl> external_memory_at_last_mark_compact_ = external_memory_ ; <nl> void Heap : : CheckIneffectiveMarkCompact ( size_t old_generation_size , <nl> } <nl> <nl> bool Heap : : HasHighFragmentation ( ) { <nl> - size_t used = PromotedSpaceSizeOfObjects ( ) ; <nl> + size_t used = OldGenerationSizeOfObjects ( ) ; <nl> size_t committed = CommittedOldGenerationMemory ( ) ; <nl> return HasHighFragmentation ( used , committed ) ; <nl> } <nl> void Heap : : RecordStats ( HeapStats * stats , bool take_snapshot ) { <nl> } <nl> } <nl> <nl> - size_t Heap : : PromotedSpaceSizeOfObjects ( ) { <nl> + size_t Heap : : OldGenerationSizeOfObjects ( ) { <nl> PagedSpaces spaces ( this , PagedSpaces : : SpacesSpecifier : : kAllPagedSpaces ) ; <nl> size_t total = 0 ; <nl> for ( PagedSpace * space = spaces . next ( ) ; space ! = nullptr ; <nl> Heap : : IncrementalMarkingLimit Heap : : IncrementalMarkingLimitReached ( ) { <nl> if ( FLAG_stress_incremental_marking ) { <nl> return IncrementalMarkingLimit : : kHardLimit ; <nl> } <nl> - if ( PromotedSpaceSizeOfObjects ( ) < = <nl> + if ( OldGenerationSizeOfObjects ( ) < = <nl> IncrementalMarking : : kActivationThreshold ) { <nl> / / Incremental marking is disabled or it is too early to start . <nl> return IncrementalMarkingLimit : : kNoLimit ; <nl> Heap : : IncrementalMarkingLimit Heap : : IncrementalMarkingLimitReached ( ) { <nl> double gained_since_last_gc = <nl> PromotedSinceLastGC ( ) + <nl> ( external_memory_ - external_memory_at_last_mark_compact_ ) ; <nl> - double size_before_gc = PromotedTotalSize ( ) - gained_since_last_gc ; <nl> + double size_before_gc = <nl> + OldGenerationObjectsAndPromotedExternalMemorySize ( ) - <nl> + gained_since_last_gc ; <nl> double bytes_to_limit = old_generation_allocation_limit_ - size_before_gc ; <nl> if ( bytes_to_limit > 0 ) { <nl> double current_percent = ( gained_since_last_gc / bytes_to_limit ) * 100 . 0 ; <nl> mmm a / src / heap / heap . h <nl> ppp b / src / heap / heap . h <nl> class Heap { <nl> survived_since_last_expansion_ + = survived ; <nl> } <nl> <nl> - inline uint64_t PromotedTotalSize ( ) { <nl> - return PromotedSpaceSizeOfObjects ( ) + PromotedExternalMemorySize ( ) ; <nl> + inline uint64_t OldGenerationObjectsAndPromotedExternalMemorySize ( ) { <nl> + return OldGenerationSizeOfObjects ( ) + PromotedExternalMemorySize ( ) ; <nl> } <nl> <nl> inline void UpdateNewSpaceAllocationCounter ( ) ; <nl> class Heap { <nl> } <nl> <nl> size_t PromotedSinceLastGC ( ) { <nl> - size_t old_generation_size = PromotedSpaceSizeOfObjects ( ) ; <nl> + size_t old_generation_size = OldGenerationSizeOfObjects ( ) ; <nl> DCHECK_GE ( old_generation_size , old_generation_size_at_last_gc_ ) ; <nl> return old_generation_size - old_generation_size_at_last_gc_ ; <nl> } <nl> <nl> / / This is called by the sweeper when it discovers more free space <nl> - / / as expected at the end of the last GC . <nl> + / / than expected at the end of the preceding GC . <nl> void NotifyRefinedOldGenerationSize ( size_t decreased_bytes ) { <nl> if ( old_generation_size_at_last_gc_ ! = 0 ) { <nl> - / / PromotedSpaceSizeOfObjects ( ) is now smaller by | decreased_bytes | . <nl> - / / Adjust old_generation_size_at_last_gc_ too so that PromotedSinceLastGC <nl> - / / stay monotonically non - decreasing function . <nl> + / / OldGenerationSizeOfObjects ( ) is now smaller by | decreased_bytes | . <nl> + / / Adjust old_generation_size_at_last_gc_ too , so that PromotedSinceLastGC <nl> + / / continues to increase monotonically , rather than decreasing here . <nl> DCHECK_GE ( old_generation_size_at_last_gc_ , decreased_bytes ) ; <nl> old_generation_size_at_last_gc_ - = decreased_bytes ; <nl> } <nl> class Heap { <nl> <nl> int gc_count ( ) const { return gc_count_ ; } <nl> <nl> - / / Returns the size of objects residing in non new spaces . <nl> - size_t PromotedSpaceSizeOfObjects ( ) ; <nl> + / / Returns the size of objects residing in non - new spaces . <nl> + / / Excludes external memory held by those objects . <nl> + size_t OldGenerationSizeOfObjects ( ) ; <nl> <nl> / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> / / Prologue / epilogue callback methods . = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> class Heap { <nl> / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> <nl> inline size_t OldGenerationSpaceAvailable ( ) { <nl> - if ( old_generation_allocation_limit_ < = PromotedTotalSize ( ) ) return 0 ; <nl> + if ( old_generation_allocation_limit_ < = <nl> + OldGenerationObjectsAndPromotedExternalMemorySize ( ) ) <nl> + return 0 ; <nl> return old_generation_allocation_limit_ - <nl> - static_cast < size_t > ( PromotedTotalSize ( ) ) ; <nl> + static_cast < size_t > ( <nl> + OldGenerationObjectsAndPromotedExternalMemorySize ( ) ) ; <nl> } <nl> <nl> / / We allow incremental marking to overshoot the allocation limit for <nl> class Heap { <nl> / / This guards against too eager finalization in small heaps . <nl> / / The number is chosen based on v8 . browsing_mobile on Nexus 7v2 . <nl> size_t kMarginForSmallHeaps = 32u * MB ; <nl> - if ( old_generation_allocation_limit_ > = PromotedTotalSize ( ) ) return false ; <nl> - uint64_t overshoot = PromotedTotalSize ( ) - old_generation_allocation_limit_ ; <nl> + if ( old_generation_allocation_limit_ > = <nl> + OldGenerationObjectsAndPromotedExternalMemorySize ( ) ) <nl> + return false ; <nl> + uint64_t overshoot = OldGenerationObjectsAndPromotedExternalMemorySize ( ) - <nl> + old_generation_allocation_limit_ ; <nl> / / Overshoot margin is 50 % of allocation limit or half - way to the max heap <nl> / / with special handling of small heaps . <nl> uint64_t margin = <nl> mmm a / src / heap / incremental - marking . cc <nl> ppp b / src / heap / incremental - marking . cc <nl> void IncrementalMarking : : Deactivate ( ) { <nl> void IncrementalMarking : : Start ( GarbageCollectionReason gc_reason ) { <nl> if ( FLAG_trace_incremental_marking ) { <nl> int old_generation_size_mb = <nl> - static_cast < int > ( heap ( ) - > PromotedSpaceSizeOfObjects ( ) / MB ) ; <nl> + static_cast < int > ( heap ( ) - > OldGenerationSizeOfObjects ( ) / MB ) ; <nl> int old_generation_limit_mb = <nl> static_cast < int > ( heap ( ) - > old_generation_allocation_limit ( ) / MB ) ; <nl> heap ( ) - > isolate ( ) - > PrintWithTimestamp ( <nl> void IncrementalMarking : : Start ( GarbageCollectionReason gc_reason ) { <nl> heap_ - > tracer ( ) - > NotifyIncrementalMarkingStart ( ) ; <nl> <nl> start_time_ms_ = heap ( ) - > MonotonicallyIncreasingTimeInMs ( ) ; <nl> - initial_old_generation_size_ = heap_ - > PromotedSpaceSizeOfObjects ( ) ; <nl> + initial_old_generation_size_ = heap_ - > OldGenerationSizeOfObjects ( ) ; <nl> old_generation_allocation_counter_ = heap_ - > OldGenerationAllocationCounter ( ) ; <nl> bytes_allocated_ = 0 ; <nl> bytes_marked_ahead_of_schedule_ = 0 ; <nl> void IncrementalMarking : : Stop ( ) { <nl> if ( IsStopped ( ) ) return ; <nl> if ( FLAG_trace_incremental_marking ) { <nl> int old_generation_size_mb = <nl> - static_cast < int > ( heap ( ) - > PromotedSpaceSizeOfObjects ( ) / MB ) ; <nl> + static_cast < int > ( heap ( ) - > OldGenerationSizeOfObjects ( ) / MB ) ; <nl> int old_generation_limit_mb = <nl> static_cast < int > ( heap ( ) - > old_generation_allocation_limit ( ) / MB ) ; <nl> heap ( ) - > isolate ( ) - > PrintWithTimestamp ( <nl> size_t IncrementalMarking : : StepSizeToMakeProgress ( ) { <nl> size_t oom_slack = heap ( ) - > new_space ( ) - > Capacity ( ) + 64 * MB ; <nl> <nl> if ( ! heap ( ) - > CanExpandOldGeneration ( oom_slack ) ) { <nl> - return heap ( ) - > PromotedSpaceSizeOfObjects ( ) / kTargetStepCountAtOOM ; <nl> + return heap ( ) - > OldGenerationSizeOfObjects ( ) / kTargetStepCountAtOOM ; <nl> } <nl> <nl> size_t step_size = Max ( initial_old_generation_size_ / kTargetStepCount , <nl> mmm a / test / cctest / heap / test - heap . cc <nl> ppp b / test / cctest / heap / test - heap . cc <nl> UNINITIALIZED_TEST ( OutOfMemoryIneffectiveGC ) { <nl> heap - > CollectAllGarbage ( Heap : : kNoGCFlags , GarbageCollectionReason : : kTesting ) ; <nl> { <nl> HandleScope scope ( i_isolate ) ; <nl> - while ( heap - > PromotedSpaceSizeOfObjects ( ) < <nl> + while ( heap - > OldGenerationSizeOfObjects ( ) < <nl> heap - > MaxOldGenerationSize ( ) * 0 . 9 ) { <nl> factory - > NewFixedArray ( 100 , TENURED ) ; <nl> } <nl> | Rename PromotedSpaceSizeOfObjects ( ) to OldGenerationSizeOfObjects ( ) . | v8/v8 | ca3e146ecbaad449f6cdc8539d9f0c7920d2903d | 2018-05-04T11:15:18Z |
mmm a / em + + <nl> ppp b / em + + <nl> from tools import shared <nl> <nl> os . environ [ ' EMMAKEN_CXX ' ] = ' 1 ' <nl> exit ( subprocess . call ( [ shared . PYTHON , shared . EMCC ] + sys . argv [ 1 : ] ) ) <nl> + <nl> mmm a / em - config <nl> ppp b / em - config <nl> This is a helper tool which is designed to make it possible <nl> for other apps to read emscripten ' s configuration variables <nl> in a unified way . Usage : <nl> <nl> - em - config VAR_NAME <nl> + em - config VAR_NAME <nl> <nl> This tool prints the value of the variable to stdout if one <nl> is found , or exits with 1 if the variable does not exist . <nl> import os , sys , re <nl> from tools import shared <nl> <nl> if len ( sys . argv ) ! = 2 or \ <nl> - not re . match ( r " ^ [ \ w \ W_ ] [ \ w \ W_ \ d ] * $ " , sys . argv [ 1 ] ) or \ <nl> - not ( sys . argv [ 1 ] in dir ( shared ) ) : <nl> - print ' Usage : em - config VAR_NAME ' <nl> - exit ( 1 ) <nl> + not re . match ( r " ^ [ \ w \ W_ ] [ \ w \ W_ \ d ] * $ " , sys . argv [ 1 ] ) or \ <nl> + not ( sys . argv [ 1 ] in dir ( shared ) ) : <nl> + print ' Usage : em - config VAR_NAME ' <nl> + exit ( 1 ) <nl> <nl> print eval ( ' shared . ' + sys . argv [ 1 ] ) <nl> + <nl> mmm a / emar <nl> ppp b / emar <nl> from tools import shared <nl> <nl> DEBUG = os . environ . get ( ' EMCC_DEBUG ' ) <nl> if DEBUG = = " 0 " : <nl> - DEBUG = None <nl> + DEBUG = None <nl> <nl> newargs = [ shared . LLVM_AR ] + sys . argv [ 1 : ] <nl> <nl> if DEBUG : <nl> - print > > sys . stderr , ' emar : ' , sys . argv , ' = = > ' , newargs <nl> + print > > sys . stderr , ' emar : ' , sys . argv , ' = = > ' , newargs <nl> <nl> if len ( newargs ) > 2 : <nl> - subprocess . call ( newargs ) <nl> + subprocess . call ( newargs ) <nl> + <nl> mmm a / emcc . py <nl> ppp b / emcc . py <nl> <nl> + <nl> # necessary to work around process pool limitations on windows - the js optimizer will end up trying to import this . see issue 663 <nl> <nl> import tools . js_optimizer <nl> + <nl> mmm a / emmake <nl> ppp b / emmake <nl> <nl> This is a helper script . It runs make for you , setting <nl> the environment variables to use emcc and so forth . Usage : <nl> <nl> - emmake make [ FLAGS ] <nl> + emmake make [ FLAGS ] <nl> <nl> Note that if you ran configure with emconfigure , then <nl> the environment variables have already been detected <nl> try : <nl> shared . Building . make ( sys . argv [ 1 : ] ) <nl> except CalledProcessError , e : <nl> sys . exit ( e . returncode ) <nl> + <nl> mmm a / emranlib <nl> ppp b / emranlib <nl> emcc - ranlib helper script <nl> <nl> This script acts as a frontend replacement for ranlib . See emcc . <nl> ' ' ' <nl> + <nl> mmm a / emscons <nl> ppp b / emscons <nl> <nl> Wrapping the scons invocation , EMSCRIPTEN_TOOL_PATH is set in the process <nl> environment , and can be used to locate the emscripten SCons Tool . <nl> Example : <nl> - <nl> - # Load emscripten Tool <nl> - my_env = Environment ( tools = [ ' emscripten ' ] , toolpath = [ os . environ [ ' EMSCRIPTEN_TOOL_PATH ' ] ] ) <nl> + # Load emscripten Tool <nl> + my_env = Environment ( tools = [ ' emscripten ' ] , toolpath = [ os . environ [ ' EMSCRIPTEN_TOOL_PATH ' ] ] ) <nl> ' ' ' <nl> <nl> import os , subprocess , sys <nl> env = os . environ . copy ( ) <nl> env [ ' EMSCRIPTEN_TOOL_PATH ' ] = tool_path <nl> <nl> exit ( subprocess . call ( sys . argv [ 1 : ] , env = env ) ) <nl> + <nl> | Revert " * * all : hard tabs , trailing newlines * * " | emscripten-core/emscripten | 6e18468fa4a71f0d110c41baa8ebd2965f4c7254 | 2014-03-01T03:24:29Z |
mmm a / modules / highgui / src / cap_msmf . cpp <nl> ppp b / modules / highgui / src / cap_msmf . cpp <nl> long videoDevices : : initDevices ( IMFAttributes * pAttributes ) <nl> return hr ; <nl> } <nl> <nl> - size_t videoDevices : : getCount ( ) <nl> + unsigned int videoDevices : : getCount ( ) <nl> { <nl> return vds_Devices . size ( ) ; <nl> } <nl> | Merge pull request from asmorkalov : msmf_sizet_fix | opencv/opencv | 64837548609899fc58bcd0d5675651b048ba05de | 2013-08-05T06:26:39Z |
mmm a / src / code - stubs - hydrogen . cc <nl> ppp b / src / code - stubs - hydrogen . cc <nl> class CodeStubGraphBuilder : public CodeStubGraphBuilderBase { <nl> } ; <nl> <nl> <nl> + template < class Stub > <nl> + static Handle < Code > DoGenerateCode ( Stub * stub ) { <nl> + CodeStubGraphBuilder < Stub > builder ( stub ) ; <nl> + LChunk * chunk = OptimizeGraph ( builder . CreateGraph ( ) ) ; <nl> + return chunk - > Codegen ( Code : : COMPILED_STUB ) ; <nl> + } <nl> + <nl> + <nl> template < > <nl> HValue * CodeStubGraphBuilder < FastCloneShallowObjectStub > : : BuildCodeStub ( ) { <nl> Zone * zone = this - > zone ( ) ; <nl> HValue * CodeStubGraphBuilder < FastCloneShallowObjectStub > : : BuildCodeStub ( ) { <nl> <nl> <nl> Handle < Code > FastCloneShallowObjectStub : : GenerateCode ( ) { <nl> - CodeStubGraphBuilder < FastCloneShallowObjectStub > builder ( this ) ; <nl> - LChunk * chunk = OptimizeGraph ( builder . CreateGraph ( ) ) ; <nl> - return chunk - > Codegen ( Code : : COMPILED_STUB ) ; <nl> + return DoGenerateCode ( this ) ; <nl> } <nl> <nl> - <nl> template < > <nl> HValue * CodeStubGraphBuilder < KeyedLoadFastElementStub > : : BuildCodeStub ( ) { <nl> HInstruction * load = BuildUncheckedMonomorphicElementAccess ( <nl> HValue * CodeStubGraphBuilder < KeyedLoadFastElementStub > : : BuildCodeStub ( ) { <nl> <nl> <nl> Handle < Code > KeyedLoadFastElementStub : : GenerateCode ( ) { <nl> - CodeStubGraphBuilder < KeyedLoadFastElementStub > builder ( this ) ; <nl> - LChunk * chunk = OptimizeGraph ( builder . CreateGraph ( ) ) ; <nl> - return chunk - > Codegen ( Code : : COMPILED_STUB ) ; <nl> + return DoGenerateCode ( this ) ; <nl> } <nl> <nl> <nl> HValue * CodeStubGraphBuilder < ArrayNoArgumentConstructorStub > : : BuildCodeStub ( ) { <nl> <nl> <nl> Handle < Code > ArrayNoArgumentConstructorStub : : GenerateCode ( ) { <nl> - CodeStubGraphBuilder < ArrayNoArgumentConstructorStub > builder ( this ) ; <nl> - LChunk * chunk = OptimizeGraph ( builder . CreateGraph ( ) ) ; <nl> - return chunk - > Codegen ( Code : : COMPILED_STUB ) ; <nl> + return DoGenerateCode ( this ) ; <nl> } <nl> <nl> <nl> HValue * CodeStubGraphBuilder < ArraySingleArgumentConstructorStub > : : <nl> <nl> <nl> Handle < Code > TransitionElementsKindStub : : GenerateCode ( ) { <nl> - CodeStubGraphBuilder < TransitionElementsKindStub > builder ( this ) ; <nl> - LChunk * chunk = OptimizeGraph ( builder . CreateGraph ( ) ) ; <nl> - return chunk - > Codegen ( Code : : COMPILED_STUB ) ; <nl> + return DoGenerateCode ( this ) ; <nl> } <nl> <nl> <nl> Handle < Code > ArraySingleArgumentConstructorStub : : GenerateCode ( ) { <nl> - CodeStubGraphBuilder < ArraySingleArgumentConstructorStub > builder ( this ) ; <nl> - LChunk * chunk = OptimizeGraph ( builder . CreateGraph ( ) ) ; <nl> - return chunk - > Codegen ( Code : : COMPILED_STUB ) ; <nl> + return DoGenerateCode ( this ) ; <nl> } <nl> <nl> <nl> HValue * CodeStubGraphBuilder < ArrayNArgumentsConstructorStub > : : BuildCodeStub ( ) { <nl> <nl> <nl> Handle < Code > ArrayNArgumentsConstructorStub : : GenerateCode ( ) { <nl> - CodeStubGraphBuilder < ArrayNArgumentsConstructorStub > builder ( this ) ; <nl> - LChunk * chunk = OptimizeGraph ( builder . CreateGraph ( ) ) ; <nl> - return chunk - > Codegen ( Code : : COMPILED_STUB ) ; <nl> + return DoGenerateCode ( this ) ; <nl> } <nl> <nl> } } / / namespace v8 : : internal <nl> | Remove boilerplate code from HydrogenCodeStubs | v8/v8 | 110003ca2a4b373b6f97e3c0122ad3bc1694b436 | 2013-03-20T12:01:49Z |
new file mode 100644 <nl> index 00000000000 . . c53cdf3d0d4 <nl> mmm / dev / null <nl> ppp b / dbms / src / Columns / ColumnDecimal . cpp <nl> <nl> + / / # include < cstring > <nl> + # include < cmath > <nl> + <nl> + # include < Common / Exception . h > <nl> + # include < Common / Arena . h > <nl> + # include < Common / SipHash . h > <nl> + <nl> + # include < IO / WriteHelpers . h > <nl> + <nl> + # include < Columns / ColumnsCommon . h > <nl> + # include < Columns / ColumnDecimal . h > <nl> + # include < DataStreams / ColumnGathererStream . h > <nl> + <nl> + template < typename T > bool decimalLess ( T x , T y , UInt32 x_scale , UInt32 y_scale ) ; <nl> + <nl> + namespace DB <nl> + { <nl> + <nl> + namespace ErrorCodes <nl> + { <nl> + extern const int PARAMETER_OUT_OF_BOUND ; <nl> + extern const int SIZES_OF_COLUMNS_DOESNT_MATCH ; <nl> + } <nl> + <nl> + template < typename T > <nl> + int ColumnDecimal < T > : : compareAt ( size_t n , size_t m , const IColumn & rhs_ , int ) const <nl> + { <nl> + auto other = static_cast < const Self & > ( rhs_ ) ; <nl> + const T & a = data [ n ] ; <nl> + const T & b = static_cast < const Self & > ( rhs_ ) . data [ m ] ; <nl> + <nl> + return decimalLess < T > ( b , a , other . scale , scale ) ? 1 : ( decimalLess < T > ( a , b , scale , other . scale ) ? - 1 : 0 ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + StringRef ColumnDecimal < T > : : serializeValueIntoArena ( size_t n , Arena & arena , char const * & begin ) const <nl> + { <nl> + auto pos = arena . allocContinue ( sizeof ( T ) , begin ) ; <nl> + memcpy ( pos , & data [ n ] , sizeof ( T ) ) ; <nl> + return StringRef ( pos , sizeof ( T ) ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + const char * ColumnDecimal < T > : : deserializeAndInsertFromArena ( const char * pos ) <nl> + { <nl> + data . push_back ( * reinterpret_cast < const T * > ( pos ) ) ; <nl> + return pos + sizeof ( T ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + void ColumnDecimal < T > : : updateHashWithValue ( size_t n , SipHash & hash ) const <nl> + { <nl> + hash . update ( data [ n ] ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + void ColumnDecimal < T > : : getPermutation ( bool reverse , size_t limit , int , IColumn : : Permutation & res ) const <nl> + { <nl> + size_t s = data . size ( ) ; <nl> + res . resize ( s ) ; <nl> + for ( size_t i = 0 ; i < s ; + + i ) <nl> + res [ i ] = i ; <nl> + <nl> + if ( limit > = s ) <nl> + limit = 0 ; <nl> + <nl> + if ( limit ) <nl> + { <nl> + if ( reverse ) <nl> + std : : partial_sort ( res . begin ( ) , res . begin ( ) + limit , res . end ( ) , [ ] ( T a , T b ) { return a > b ; } ) ; <nl> + else <nl> + std : : partial_sort ( res . begin ( ) , res . begin ( ) + limit , res . end ( ) , [ ] ( T a , T b ) { return a < b ; } ) ; <nl> + } <nl> + else <nl> + { <nl> + if ( reverse ) <nl> + std : : sort ( res . begin ( ) , res . end ( ) , [ ] ( T a , T b ) { return a > b ; } ) ; <nl> + else <nl> + std : : sort ( res . begin ( ) , res . end ( ) , [ ] ( T a , T b ) { return a < b ; } ) ; <nl> + } <nl> + } <nl> + <nl> + template < typename T > <nl> + MutableColumnPtr ColumnDecimal < T > : : cloneResized ( size_t size ) const <nl> + { <nl> + auto res = this - > create ( 0 , scale ) ; <nl> + <nl> + if ( size > 0 ) <nl> + { <nl> + auto & new_col = static_cast < Self & > ( * res ) ; <nl> + new_col . data . resize ( size ) ; <nl> + <nl> + size_t count = std : : min ( this - > size ( ) , size ) ; <nl> + memcpy ( & new_col . data [ 0 ] , & data [ 0 ] , count * sizeof ( data [ 0 ] ) ) ; <nl> + <nl> + if ( size > count ) <nl> + memset ( static_cast < void * > ( & new_col . data [ count ] ) , static_cast < int > ( value_type ( ) ) , ( size - count ) * sizeof ( value_type ) ) ; <nl> + } <nl> + <nl> + return std : : move ( res ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + void ColumnDecimal < T > : : insertRangeFrom ( const IColumn & src , size_t start , size_t length ) <nl> + { <nl> + const ColumnDecimal & src_vec = static_cast < const ColumnDecimal & > ( src ) ; <nl> + <nl> + if ( start + length > src_vec . data . size ( ) ) <nl> + throw Exception ( " Parameters start = " <nl> + + toString ( start ) + " , length = " <nl> + + toString ( length ) + " are out of bound in ColumnVector < T > : : insertRangeFrom method " <nl> + " ( data . size ( ) = " + toString ( src_vec . data . size ( ) ) + " ) . " , <nl> + ErrorCodes : : PARAMETER_OUT_OF_BOUND ) ; <nl> + <nl> + size_t old_size = data . size ( ) ; <nl> + data . resize ( old_size + length ) ; <nl> + memcpy ( & data [ old_size ] , & src_vec . data [ start ] , length * sizeof ( data [ 0 ] ) ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + ColumnPtr ColumnDecimal < T > : : filter ( const IColumn : : Filter & filt , ssize_t result_size_hint ) const <nl> + { <nl> + size_t size = data . size ( ) ; <nl> + if ( size ! = filt . size ( ) ) <nl> + throw Exception ( " Size of filter doesn ' t match size of column . " , ErrorCodes : : SIZES_OF_COLUMNS_DOESNT_MATCH ) ; <nl> + <nl> + auto res = this - > create ( 0 , scale ) ; <nl> + Container & res_data = res - > getData ( ) ; <nl> + <nl> + if ( result_size_hint ) <nl> + res_data . reserve ( result_size_hint > 0 ? result_size_hint : size ) ; <nl> + <nl> + const UInt8 * filt_pos = & filt [ 0 ] ; <nl> + const UInt8 * filt_end = filt_pos + size ; <nl> + const T * data_pos = & data [ 0 ] ; <nl> + <nl> + while ( filt_pos < filt_end ) <nl> + { <nl> + if ( * filt_pos ) <nl> + res_data . push_back ( * data_pos ) ; <nl> + <nl> + + + filt_pos ; <nl> + + + data_pos ; <nl> + } <nl> + <nl> + return std : : move ( res ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + ColumnPtr ColumnDecimal < T > : : permute ( const IColumn : : Permutation & perm , size_t limit ) const <nl> + { <nl> + size_t size = data . size ( ) ; <nl> + <nl> + if ( limit = = 0 ) <nl> + limit = size ; <nl> + else <nl> + limit = std : : min ( size , limit ) ; <nl> + <nl> + if ( perm . size ( ) < limit ) <nl> + throw Exception ( " Size of permutation is less than required . " , ErrorCodes : : SIZES_OF_COLUMNS_DOESNT_MATCH ) ; <nl> + <nl> + auto res = this - > create ( limit , scale ) ; <nl> + typename Self : : Container & res_data = res - > getData ( ) ; <nl> + for ( size_t i = 0 ; i < limit ; + + i ) <nl> + res_data [ i ] = data [ perm [ i ] ] ; <nl> + <nl> + return std : : move ( res ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + ColumnPtr ColumnDecimal < T > : : index ( const IColumn & indexes , size_t limit ) const <nl> + { <nl> + return selectIndexImpl ( * this , indexes , limit ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + ColumnPtr ColumnDecimal < T > : : replicate ( const IColumn : : Offsets & offsets ) const <nl> + { <nl> + size_t size = data . size ( ) ; <nl> + if ( size ! = offsets . size ( ) ) <nl> + throw Exception ( " Size of offsets doesn ' t match size of column . " , ErrorCodes : : SIZES_OF_COLUMNS_DOESNT_MATCH ) ; <nl> + <nl> + auto res = this - > create ( 0 , scale ) ; <nl> + if ( 0 = = size ) <nl> + return res ; <nl> + <nl> + typename Self : : Container & res_data = res - > getData ( ) ; <nl> + res_data . reserve ( offsets . back ( ) ) ; <nl> + <nl> + IColumn : : Offset prev_offset = 0 ; <nl> + for ( size_t i = 0 ; i < size ; + + i ) <nl> + { <nl> + size_t size_to_replicate = offsets [ i ] - prev_offset ; <nl> + prev_offset = offsets [ i ] ; <nl> + <nl> + for ( size_t j = 0 ; j < size_to_replicate ; + + j ) <nl> + res_data . push_back ( data [ i ] ) ; <nl> + } <nl> + <nl> + return std : : move ( res ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + void ColumnDecimal < T > : : gather ( ColumnGathererStream & gatherer ) <nl> + { <nl> + gatherer . gather ( * this ) ; <nl> + } <nl> + <nl> + template < typename T > <nl> + void ColumnDecimal < T > : : getExtremes ( Field & min , Field & max ) const <nl> + { <nl> + if ( data . size ( ) = = 0 ) <nl> + { <nl> + min = typename NearestFieldType < T > : : Type ( 0 , scale ) ; <nl> + max = typename NearestFieldType < T > : : Type ( 0 , scale ) ; <nl> + return ; <nl> + } <nl> + <nl> + T cur_min = data [ 0 ] ; <nl> + T cur_max = data [ 0 ] ; <nl> + <nl> + for ( const T & x : data ) <nl> + { <nl> + if ( x < cur_min ) <nl> + cur_min = x ; <nl> + else if ( x > cur_max ) <nl> + cur_max = x ; <nl> + } <nl> + <nl> + min = typename NearestFieldType < T > : : Type ( cur_min , scale ) ; <nl> + max = typename NearestFieldType < T > : : Type ( cur_max , scale ) ; <nl> + } <nl> + <nl> + template class ColumnDecimal < Decimal32 > ; <nl> + template class ColumnDecimal < Decimal64 > ; <nl> + template class ColumnDecimal < Decimal128 > ; <nl> + } <nl> new file mode 100644 <nl> index 00000000000 . . f669f97fb18 <nl> mmm / dev / null <nl> ppp b / dbms / src / Columns / ColumnDecimal . h <nl> <nl> + # pragma once <nl> + <nl> + # include < cmath > <nl> + <nl> + # include < Columns / IColumn . h > <nl> + <nl> + <nl> + namespace DB <nl> + { <nl> + <nl> + namespace ErrorCodes <nl> + { <nl> + extern const int LOGICAL_ERROR ; <nl> + } <nl> + <nl> + / / / PaddedPODArray extended by Decimal scale <nl> + template < typename T > <nl> + class DecimalPaddedPODArray : public PaddedPODArray < T > <nl> + { <nl> + public : <nl> + using Base = PaddedPODArray < T > ; <nl> + using Base : : operator [ ] ; <nl> + <nl> + DecimalPaddedPODArray ( size_t size , UInt32 scale_ ) <nl> + : Base ( size ) , <nl> + scale ( scale_ ) <nl> + { } <nl> + <nl> + DecimalPaddedPODArray ( const DecimalPaddedPODArray & other ) <nl> + : Base ( other . begin ( ) , other . end ( ) ) , <nl> + scale ( other . scale ) <nl> + { } <nl> + <nl> + DecimalPaddedPODArray ( DecimalPaddedPODArray & & other ) <nl> + { <nl> + this - > swap ( other ) ; <nl> + std : : swap ( scale , other . scale ) ; <nl> + } <nl> + <nl> + DecimalPaddedPODArray & operator = ( DecimalPaddedPODArray & & other ) <nl> + { <nl> + this - > swap ( other ) ; <nl> + std : : swap ( scale , other . scale ) ; <nl> + return * this ; <nl> + } <nl> + <nl> + UInt32 getScale ( ) const { return scale ; } <nl> + <nl> + private : <nl> + UInt32 scale ; <nl> + } ; <nl> + <nl> + <nl> + / / / A ColumnVector for Decimals <nl> + template < typename T > <nl> + class ColumnDecimal final : public COWPtrHelper < IColumn , ColumnDecimal < T > > <nl> + { <nl> + private : <nl> + using Self = ColumnDecimal < T > ; <nl> + friend class COWPtrHelper < IColumn , Self > ; <nl> + <nl> + public : <nl> + using value_type = T ; <nl> + using Container = DecimalPaddedPODArray < value_type > ; <nl> + <nl> + private : <nl> + ColumnDecimal ( const size_t n , UInt32 scale_ ) <nl> + : data ( n , scale_ ) , <nl> + scale ( scale_ ) <nl> + { } <nl> + <nl> + ColumnDecimal ( const ColumnDecimal & src ) <nl> + : data ( src . data ) , <nl> + scale ( src . scale ) <nl> + { } <nl> + <nl> + public : <nl> + const char * getFamilyName ( ) const override { return TypeName < T > : : get ( ) ; } <nl> + <nl> + bool isNumeric ( ) const override { return false ; } <nl> + bool canBeInsideNullable ( ) const override { return false ; } <nl> + bool isFixedAndContiguous ( ) const override { return true ; } <nl> + size_t sizeOfValueIfFixed ( ) const override { return sizeof ( T ) ; } <nl> + <nl> + size_t size ( ) const override { return data . size ( ) ; } <nl> + size_t byteSize ( ) const override { return data . size ( ) * sizeof ( data [ 0 ] ) ; } <nl> + size_t allocatedBytes ( ) const override { return data . allocated_bytes ( ) ; } <nl> + void reserve ( size_t n ) override { data . reserve ( n ) ; } <nl> + <nl> + void insertFrom ( const IColumn & src , size_t n ) override { data . push_back ( static_cast < const Self & > ( src ) . getData ( ) [ n ] ) ; } <nl> + void insertData ( const char * pos , size_t / * length * / ) override { data . push_back ( * reinterpret_cast < const T * > ( pos ) ) ; } <nl> + void insertDefault ( ) override { data . push_back ( T ( ) ) ; } <nl> + void insert ( const Field & x ) override { data . push_back ( DB : : get < typename NearestFieldType < T > : : Type > ( x ) ) ; } <nl> + void insertRangeFrom ( const IColumn & src , size_t start , size_t length ) override ; <nl> + <nl> + void popBack ( size_t n ) override { data . resize_assume_reserved ( data . size ( ) - n ) ; } <nl> + <nl> + StringRef serializeValueIntoArena ( size_t n , Arena & arena , char const * & begin ) const override ; <nl> + const char * deserializeAndInsertFromArena ( const char * pos ) override ; <nl> + void updateHashWithValue ( size_t n , SipHash & hash ) const override ; <nl> + int compareAt ( size_t n , size_t m , const IColumn & rhs_ , int nan_direction_hint ) const override ; <nl> + void getPermutation ( bool reverse , size_t limit , int nan_direction_hint , IColumn : : Permutation & res ) const override ; <nl> + <nl> + MutableColumnPtr cloneResized ( size_t size ) const override ; <nl> + <nl> + Field operator [ ] ( size_t n ) const override { return DecimalField ( data [ n ] , scale ) ; } <nl> + <nl> + StringRef getRawData ( ) const override { return StringRef ( reinterpret_cast < const char * > ( data . data ( ) ) , data . size ( ) ) ; } <nl> + StringRef getDataAt ( size_t n ) const override { return StringRef ( reinterpret_cast < const char * > ( & data [ n ] ) , sizeof ( data [ n ] ) ) ; } <nl> + void get ( size_t n , Field & res ) const override { res = ( * this ) [ n ] ; } <nl> + bool getBool ( size_t n ) const override { return bool ( data [ n ] ) ; } <nl> + Int64 getInt ( size_t n ) const override { return Int64 ( data [ n ] * scale ) ; } <nl> + <nl> + ColumnPtr filter ( const IColumn : : Filter & filt , ssize_t result_size_hint ) const override ; <nl> + ColumnPtr permute ( const IColumn : : Permutation & perm , size_t limit ) const override ; <nl> + ColumnPtr index ( const IColumn & indexes , size_t limit ) const override ; <nl> + <nl> + template < typename Type > <nl> + ColumnPtr indexImpl ( const PaddedPODArray < Type > & indexes , size_t limit ) const ; <nl> + <nl> + ColumnPtr replicate ( const IColumn : : Offsets & offsets ) const override ; <nl> + void getExtremes ( Field & min , Field & max ) const override ; <nl> + <nl> + MutableColumns scatter ( IColumn : : ColumnIndex num_columns , const IColumn : : Selector & selector ) const override <nl> + { <nl> + return this - > template scatterImpl < Self > ( num_columns , selector ) ; <nl> + } <nl> + <nl> + void gather ( ColumnGathererStream & gatherer_stream ) override ; <nl> + <nl> + <nl> + void insert ( const T value ) { data . push_back ( value ) ; } <nl> + Container & getData ( ) { return data ; } <nl> + const Container & getData ( ) const { return data ; } <nl> + const T & getElement ( size_t n ) const { return data [ n ] ; } <nl> + T & getElement ( size_t n ) { return data [ n ] ; } <nl> + <nl> + protected : <nl> + Container data ; <nl> + UInt32 scale ; <nl> + } ; <nl> + <nl> + template < typename T > <nl> + template < typename Type > <nl> + ColumnPtr ColumnDecimal < T > : : indexImpl ( const PaddedPODArray < Type > & indexes , size_t limit ) const <nl> + { <nl> + size_t size = indexes . size ( ) ; <nl> + <nl> + if ( limit = = 0 ) <nl> + limit = size ; <nl> + else <nl> + limit = std : : min ( size , limit ) ; <nl> + <nl> + auto res = this - > create ( limit , scale ) ; <nl> + typename Self : : Container & res_data = res - > getData ( ) ; <nl> + for ( size_t i = 0 ; i < limit ; + + i ) <nl> + res_data [ i ] = data [ indexes [ i ] ] ; <nl> + <nl> + return std : : move ( res ) ; <nl> + } <nl> + <nl> + } <nl> mmm a / dbms / src / Columns / ColumnVector . cpp <nl> ppp b / dbms / src / Columns / ColumnVector . cpp <nl> void ColumnVector < T > : : getExtremes ( Field & min , Field & max ) const <nl> <nl> if ( size = = 0 ) <nl> { <nl> - if constexpr ( IsDecimalNumber < T > ) <nl> - { <nl> - min = typename NearestFieldType < T > : : Type ( 0 , data . getScale ( ) ) ; <nl> - max = typename NearestFieldType < T > : : Type ( 0 , data . getScale ( ) ) ; <nl> - } <nl> - else <nl> - { <nl> - min = typename NearestFieldType < T > : : Type ( 0 ) ; <nl> - max = typename NearestFieldType < T > : : Type ( 0 ) ; <nl> - } <nl> - <nl> + min = typename NearestFieldType < T > : : Type ( 0 ) ; <nl> + max = typename NearestFieldType < T > : : Type ( 0 ) ; <nl> return ; <nl> } <nl> <nl> void ColumnVector < T > : : getExtremes ( Field & min , Field & max ) const <nl> cur_max = x ; <nl> } <nl> <nl> - if constexpr ( IsDecimalNumber < T > ) <nl> - { <nl> - min = typename NearestFieldType < T > : : Type ( cur_min , data . getScale ( ) ) ; <nl> - max = typename NearestFieldType < T > : : Type ( cur_max , data . getScale ( ) ) ; <nl> - } <nl> - else <nl> - { <nl> - min = typename NearestFieldType < T > : : Type ( cur_min ) ; <nl> - max = typename NearestFieldType < T > : : Type ( cur_max ) ; <nl> - } <nl> + min = typename NearestFieldType < T > : : Type ( cur_min ) ; <nl> + max = typename NearestFieldType < T > : : Type ( cur_max ) ; <nl> } <nl> <nl> / / / Explicit template instantiations - to avoid code bloat in headers . <nl> template class ColumnVector < Int64 > ; <nl> template class ColumnVector < Int128 > ; <nl> template class ColumnVector < Float32 > ; <nl> template class ColumnVector < Float64 > ; <nl> - <nl> - template class ColumnVector < Decimal32 > ; <nl> - template class ColumnVector < Decimal64 > ; <nl> - template class ColumnVector < Decimal128 > ; <nl> } <nl> mmm a / dbms / src / Columns / ColumnVector . h <nl> ppp b / dbms / src / Columns / ColumnVector . h <nl> <nl> namespace DB <nl> { <nl> <nl> - namespace ErrorCodes <nl> - { <nl> - extern const int LOGICAL_ERROR ; <nl> - } <nl> - <nl> - <nl> / * * Stuff for comparing numbers . <nl> * Integer values are compared as usual . <nl> * Floating - point numbers are compared this way that NaNs always end up at the end <nl> template < > inline UInt64 unionCastToUInt64 ( Float32 x ) <nl> } <nl> <nl> <nl> - / / / PaddedPODArray extended by Decimal scale <nl> - template < typename T > <nl> - class DecimalPaddedPODArray : public PaddedPODArray < T > <nl> - { <nl> - public : <nl> - using Base = PaddedPODArray < T > ; <nl> - using Base : : operator [ ] ; <nl> - using Base : : Base ; <nl> - <nl> - DecimalPaddedPODArray ( std : : initializer_list < T > il ) <nl> - : DecimalPaddedPODArray ( std : : begin ( il ) , std : : end ( il ) ) <nl> - { } <nl> - <nl> - DecimalPaddedPODArray ( DecimalPaddedPODArray & & other ) <nl> - { <nl> - this - > swap ( other ) ; <nl> - std : : swap ( scale , other . scale ) ; <nl> - } <nl> - <nl> - DecimalPaddedPODArray & operator = ( DecimalPaddedPODArray & & other ) <nl> - { <nl> - this - > swap ( other ) ; <nl> - std : : swap ( scale , other . scale ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - void setScale ( UInt32 s ) { scale = s ; } <nl> - UInt32 getScale ( ) const { return scale ; } <nl> - <nl> - private : <nl> - UInt32 scale = DecimalField < Decimal32 > : : wrongScale ( ) ; <nl> - } ; <nl> - <nl> - <nl> / * * A template for columns that use a simple array to store . <nl> * / <nl> template < typename T > <nl> class ColumnVector final : public COWPtrHelper < IColumn , ColumnVector < T > > <nl> <nl> public : <nl> using value_type = T ; <nl> - using Container = std : : conditional_t < IsDecimalNumber < T > , DecimalPaddedPODArray < value_type > , PaddedPODArray < value_type > > ; <nl> + using Container = PaddedPODArray < value_type > ; <nl> <nl> private : <nl> ColumnVector ( ) { } <nl> class ColumnVector final : public COWPtrHelper < IColumn , ColumnVector < T > > <nl> <nl> Field operator [ ] ( size_t n ) const override <nl> { <nl> - if constexpr ( IsDecimalNumber < T > ) <nl> - { <nl> - UInt32 scale = data . getScale ( ) ; <nl> - if ( scale = = DecimalField < Decimal32 > : : wrongScale ( ) ) <nl> - throw Exception ( " Extracting Decimal field with unknown scale . Scale is lost . " , ErrorCodes : : LOGICAL_ERROR ) ; <nl> - return DecimalField ( data [ n ] , scale ) ; <nl> - } <nl> - else <nl> - return typename NearestFieldType < T > : : Type ( data [ n ] ) ; <nl> + return typename NearestFieldType < T > : : Type ( data [ n ] ) ; <nl> } <nl> <nl> void get ( size_t n , Field & res ) const override <nl> mmm a / dbms / src / Core / Field . h <nl> ppp b / dbms / src / Core / Field . h <nl> template < typename T > <nl> class DecimalField <nl> { <nl> public : <nl> - static constexpr UInt32 wrongScale ( ) { return std : : numeric_limits < UInt32 > : : max ( ) ; } <nl> - <nl> DecimalField ( T value , UInt32 scale_ ) <nl> : dec ( value ) , <nl> scale ( scale_ ) <nl> mmm a / dbms / src / DataTypes / DataTypesDecimal . cpp <nl> ppp b / dbms / src / DataTypes / DataTypesDecimal . cpp <nl> Field DataTypeDecimal < T > : : getDefault ( ) const <nl> template < typename T > <nl> MutableColumnPtr DataTypeDecimal < T > : : createColumn ( ) const <nl> { <nl> - auto column = ColumnType : : create ( ) ; <nl> - column - > getData ( ) . setScale ( scale ) ; <nl> - return column ; <nl> + return ColumnType : : create ( 0 , scale ) ; <nl> } <nl> <nl> <nl> mmm a / dbms / src / DataTypes / DataTypesDecimal . h <nl> ppp b / dbms / src / DataTypes / DataTypesDecimal . h <nl> <nl> # pragma once <nl> # include < common / likely . h > <nl> # include < Common / typeid_cast . h > <nl> - # include < Columns / ColumnVector . h > <nl> + # include < Columns / ColumnDecimal . h > <nl> # include < DataTypes / IDataType . h > <nl> # include < DataTypes / DataTypesNumber . h > <nl> <nl> class DataTypeDecimal final : public DataTypeSimpleSerialization <nl> { <nl> public : <nl> using FieldType = T ; <nl> - using ColumnType = ColumnVector < T > ; <nl> + using ColumnType = ColumnDecimal < T > ; <nl> <nl> static constexpr bool is_parametric = true ; <nl> <nl> mmm a / dbms / src / Functions / FunctionsArithmetic . h <nl> ppp b / dbms / src / Functions / FunctionsArithmetic . h <nl> <nl> # include < DataTypes / DataTypeInterval . h > <nl> # include < DataTypes / Native . h > <nl> # include < Columns / ColumnVector . h > <nl> + # include < Columns / ColumnDecimal . h > <nl> # include < Columns / ColumnConst . h > <nl> # include < Functions / IFunction . h > <nl> # include < Functions / FunctionHelpers . h > <nl> struct DecimalBinaryOperation <nl> using ResultType = ResultType_ ; <nl> using NativeResultType = typename NativeType < ResultType > : : Type ; <nl> using Op = Operation < NativeResultType , NativeResultType > ; <nl> - using ArrayA = typename ColumnVector < A > : : Container ; <nl> - using ArrayB = typename ColumnVector < B > : : Container ; <nl> - using ArrayC = typename ColumnVector < ResultType > : : Container ; <nl> + using ArrayA = std : : conditional_t < IsDecimalNumber < A > , typename ColumnDecimal < A > : : Container , typename ColumnVector < A > : : Container > ; <nl> + using ArrayB = std : : conditional_t < IsDecimalNumber < B > , typename ColumnDecimal < B > : : Container , typename ColumnVector < B > : : Container > ; <nl> + using ArrayC = typename ColumnDecimal < ResultType > : : Container ; <nl> using XOverflow = DecimalBinaryOperation < A , B , Operation , ResultType_ , ! _check_overflow > ; <nl> <nl> static constexpr bool is_plus_minus = std : : is_same_v < Operation < Int32 , Int32 > , PlusImpl < Int32 , Int32 > > | | <nl> class FunctionBinaryArithmetic : public IFunction <nl> using T0 = typename LeftDataType : : FieldType ; <nl> using T1 = typename RightDataType : : FieldType ; <nl> using ResultType = typename ResultDataType : : FieldType ; <nl> - using ColVecT0 = ColumnVector < T0 > ; <nl> - using ColVecT1 = ColumnVector < T1 > ; <nl> - using ColVecResult = ColumnVector < ResultType > ; <nl> + using ColVecT0 = std : : conditional_t < IsDecimalNumber < T0 > , ColumnDecimal < T0 > , ColumnVector < T0 > > ; <nl> + using ColVecT1 = std : : conditional_t < IsDecimalNumber < T1 > , ColumnDecimal < T1 > , ColumnVector < T1 > > ; <nl> + using ColVecResult = std : : conditional_t < IsDecimalNumber < ResultType > , ColumnDecimal < ResultType > , ColumnVector < ResultType > > ; <nl> <nl> / / / Decimal operations need scale . Operations are on result type . <nl> using OpImpl = std : : conditional_t < IsDecimal < ResultDataType > , <nl> class FunctionBinaryArithmetic : public IFunction <nl> } <nl> } <nl> <nl> - auto col_res = ColVecResult : : create ( ) ; <nl> + typename ColVecResult : : MutablePtr col_res = nullptr ; <nl> + if constexpr ( result_is_decimal ) <nl> + { <nl> + ResultDataType type = decimalResultType ( left , right , is_multiply , is_division ) ; <nl> + col_res = ColVecResult : : create ( 0 , type . getScale ( ) ) ; <nl> + } <nl> + else <nl> + col_res = ColVecResult : : create ( ) ; <nl> + <nl> auto & vec_res = col_res - > getData ( ) ; <nl> vec_res . resize ( block . rows ( ) ) ; <nl> + <nl> if ( auto col_left = checkAndGetColumnConst < ColVecT0 > ( col_left_raw ) ) <nl> { <nl> if ( auto col_right = checkAndGetColumn < ColVecT1 > ( col_right_raw ) ) <nl> class FunctionBinaryArithmetic : public IFunction <nl> if constexpr ( result_is_decimal ) <nl> { <nl> ResultDataType type = decimalResultType ( left , right , is_multiply , is_division ) ; <nl> - vec_res . setScale ( type . getScale ( ) ) ; <nl> <nl> typename ResultDataType : : FieldType scale_a = type . scaleFactorFor ( left , is_multiply ) ; <nl> typename ResultDataType : : FieldType scale_b = type . scaleFactorFor ( right , is_multiply | | is_division ) ; <nl> class FunctionBinaryArithmetic : public IFunction <nl> if constexpr ( result_is_decimal ) <nl> { <nl> ResultDataType type = decimalResultType ( left , right , is_multiply , is_division ) ; <nl> - vec_res . setScale ( type . getScale ( ) ) ; <nl> <nl> typename ResultDataType : : FieldType scale_a = type . scaleFactorFor ( left , is_multiply ) ; <nl> typename ResultDataType : : FieldType scale_b = type . scaleFactorFor ( right , is_multiply | | is_division ) ; <nl> class FunctionUnaryArithmetic : public IFunction <nl> { <nl> if constexpr ( allow_decimal ) <nl> { <nl> - if ( auto col = checkAndGetColumn < ColumnVector < T0 > > ( block . getByPosition ( arguments [ 0 ] ) . column . get ( ) ) ) <nl> + if ( auto col = checkAndGetColumn < ColumnDecimal < T0 > > ( block . getByPosition ( arguments [ 0 ] ) . column . get ( ) ) ) <nl> { <nl> - auto col_res = ColumnVector < typename Op < T0 > : : ResultType > : : create ( ) ; <nl> + auto col_res = ColumnDecimal < typename Op < T0 > : : ResultType > : : create ( 0 , type . getScale ( ) ) ; <nl> auto & vec_res = col_res - > getData ( ) ; <nl> vec_res . resize ( col - > getData ( ) . size ( ) ) ; <nl> UnaryOperationImpl < T0 , Op < T0 > > : : vector ( col - > getData ( ) , vec_res ) ; <nl> mmm a / dbms / src / Functions / FunctionsComparison . h <nl> ppp b / dbms / src / Functions / FunctionsComparison . h <nl> <nl> <nl> # include < Columns / ColumnsNumber . h > <nl> # include < Columns / ColumnConst . h > <nl> + # include < Columns / ColumnDecimal . h > <nl> # include < Columns / ColumnString . h > <nl> # include < Columns / ColumnFixedString . h > <nl> # include < Columns / ColumnTuple . h > <nl> class DecimalComparison <nl> public : <nl> using CompareInt = typename DecCompareInt < A , B > : : Type ; <nl> using Op = Operation < CompareInt , CompareInt > ; <nl> - using ColVecA = ColumnVector < A > ; <nl> - using ColVecB = ColumnVector < B > ; <nl> + using ColVecA = std : : conditional_t < IsDecimalNumber < A > , ColumnDecimal < A > , ColumnVector < A > > ; <nl> + using ColVecB = std : : conditional_t < IsDecimalNumber < B > , ColumnDecimal < B > , ColumnVector < B > > ; <nl> using ArrayA = typename ColVecA : : Container ; <nl> using ArrayB = typename ColVecB : : Container ; <nl> <nl> mmm a / dbms / src / Functions / FunctionsConversion . h <nl> ppp b / dbms / src / Functions / FunctionsConversion . h <nl> struct ConvertImpl <nl> { <nl> const ColumnWithTypeAndName & named_from = block . getByPosition ( arguments [ 0 ] ) ; <nl> <nl> - if ( const ColumnVector < FromFieldType > * col_from = checkAndGetColumn < ColumnVector < FromFieldType > > ( named_from . column . get ( ) ) ) <nl> + using ColVecFrom = std : : conditional_t < IsDecimalNumber < FromFieldType > , ColumnDecimal < FromFieldType > , ColumnVector < FromFieldType > > ; <nl> + using ColVecTo = std : : conditional_t < IsDecimalNumber < ToFieldType > , ColumnDecimal < ToFieldType > , ColumnVector < ToFieldType > > ; <nl> + <nl> + if ( const ColVecFrom * col_from = checkAndGetColumn < ColVecFrom > ( named_from . column . get ( ) ) ) <nl> { <nl> - auto col_to = ColumnVector < ToFieldType > : : create ( ) ; <nl> + typename ColVecTo : : MutablePtr col_to = nullptr ; <nl> if constexpr ( IsDecimal < ToDataType > ) <nl> { <nl> const ColumnWithTypeAndName & scale_column = block . getByPosition ( arguments [ 1 ] ) ; <nl> UInt32 scale = extractToDecimalScale ( scale_column ) ; <nl> - col_to - > getData ( ) . setScale ( scale ) ; <nl> + col_to = ColVecTo : : create ( 0 , scale ) ; <nl> } <nl> + else <nl> + col_to = ColVecTo : : create ( ) ; <nl> <nl> - const typename ColumnVector < FromFieldType > : : Container & vec_from = col_from - > getData ( ) ; <nl> - typename ColumnVector < ToFieldType > : : Container & vec_to = col_to - > getData ( ) ; <nl> + const auto & vec_from = col_from - > getData ( ) ; <nl> + auto & vec_to = col_to - > getData ( ) ; <nl> size_t size = vec_from . size ( ) ; <nl> vec_to . resize ( size ) ; <nl> <nl> struct ConvertThroughParsing <nl> <nl> static void execute ( Block & block , const ColumnNumbers & arguments , size_t result , size_t input_rows_count ) <nl> { <nl> + using ColVecTo = std : : conditional_t < IsDecimalNumber < ToFieldType > , ColumnDecimal < ToFieldType > , ColumnVector < ToFieldType > > ; <nl> + <nl> const DateLUTImpl * local_time_zone [ [ maybe_unused ] ] = nullptr ; <nl> const DateLUTImpl * utc_time_zone [ [ maybe_unused ] ] = nullptr ; <nl> <nl> struct ConvertThroughParsing <nl> ErrorCodes : : ILLEGAL_COLUMN ) ; <nl> <nl> size_t size = input_rows_count ; <nl> - auto col_to = ColumnVector < ToFieldType > : : create ( size ) ; <nl> - typename ColumnVector < ToFieldType > : : Container & vec_to = col_to - > getData ( ) ; <nl> + typename ColVecTo : : MutablePtr col_to = nullptr ; <nl> <nl> if constexpr ( IsDecimal < ToDataType > ) <nl> { <nl> const ColumnWithTypeAndName & scale_column = block . getByPosition ( arguments [ 1 ] ) ; <nl> UInt32 scale = extractToDecimalScale ( scale_column ) ; <nl> - vec_to . setScale ( scale ) ; <nl> + col_to = ColVecTo : : create ( size , scale ) ; <nl> ToDataType check_bounds_in_ctor ( ToDataType : : maxPrecision ( ) , scale ) ; <nl> } <nl> + else <nl> + col_to = ColVecTo : : create ( size ) ; <nl> + <nl> + typename ColVecTo : : Container & vec_to = col_to - > getData ( ) ; <nl> <nl> ColumnUInt8 : : MutablePtr col_null_map_to ; <nl> ColumnUInt8 : : Container * vec_null_map_to [ [ maybe_unused ] ] = nullptr ; <nl> new file mode 100644 <nl> index 00000000000 . . ec11144a206 <nl> mmm / dev / null <nl> ppp b / dbms / tests / queries / 0_stateless / 00700_decimal_in_keys . reference <nl> <nl> + 1 <nl> + 0 <nl> + 0 <nl> + 0 <nl> + 1 <nl> + 1 <nl> + 5 <nl> + 9 . 00000000 29 . 00000000 29 . 00000000 <nl> + 8 . 00000000 28 . 00000000 28 . 00000000 <nl> + 7 . 00000000 27 . 00000000 27 . 00000000 <nl> + 6 . 00000000 26 . 00000000 26 . 00000000 <nl> + 9 . 00000000 19 . 00000000 19 . 00000000 <nl> + 8 . 00000000 18 . 00000000 18 . 00000000 <nl> + 7 . 00000000 17 . 00000000 17 . 00000000 <nl> + 6 . 00000000 16 . 00000000 16 . 00000000 <nl> + 9 . 00000000 9 . 00000000 9 . 00000000 <nl> + 8 . 00000000 8 . 00000000 8 . 00000000 <nl> + 7 . 00000000 7 . 00000000 7 . 00000000 <nl> + 6 . 00000000 6 . 00000000 6 . 00000000 <nl> + 1 . 00000000 1 . 00000000 1 . 00000000 <nl> + 3 . 00000000 3 . 00000000 3 . 00000000 <nl> + 1 . 00000000 11 . 00000000 11 . 00000000 <nl> + 3 . 00000000 13 . 00000000 13 . 00000000 <nl> + 1 . 00000000 21 . 00000000 21 . 00000000 <nl> + 3 . 00000000 23 . 00000000 23 . 00000000 <nl> + 1 . 00000000 31 . 00000000 31 . 00000000 <nl> + 3 . 00000000 33 . 00000000 33 . 00000000 <nl> + 1 . 00000000 41 . 00000000 41 . 00000000 <nl> + 3 . 00000000 43 . 00000000 43 . 00000000 <nl> mmm a / dbms / tests / queries / 0_stateless / 00700_decimal_in_keys . sql <nl> ppp b / dbms / tests / queries / 0_stateless / 00700_decimal_in_keys . sql <nl> ENGINE = MergeTree <nl> PARTITION BY toInt32 ( d1 ) <nl> ORDER BY ( d2 , d3 ) ; <nl> <nl> + INSERT INTO test . decimal ( d1 , d2 , d3 ) VALUES ( 4 . 2 , 4 . 2 , 4 . 2 ) ; <nl> + <nl> + SELECT count ( ) FROM test . decimal WHERE d1 = toDecimal32 ( ' 4 . 2 ' , 1 ) ; <nl> + SELECT count ( ) FROM test . decimal WHERE d1 ! = toDecimal32 ( ' 4 . 2 ' , 2 ) ; <nl> + SELECT count ( ) FROM test . decimal WHERE d1 < toDecimal32 ( ' 4 . 2 ' , 3 ) ; <nl> + SELECT count ( ) FROM test . decimal WHERE d1 > toDecimal32 ( ' 4 . 2 ' , 4 ) ; <nl> + SELECT count ( ) FROM test . decimal WHERE d1 < = toDecimal32 ( ' 4 . 2 ' , 5 ) ; <nl> + SELECT count ( ) FROM test . decimal WHERE d1 > = toDecimal32 ( ' 4 . 2 ' , 6 ) ; <nl> + <nl> INSERT INTO test . decimal ( d1 , d2 , d3 ) <nl> SELECT toDecimal32 ( number % 10 , 8 ) , toDecimal64 ( number , 8 ) , toDecimal128 ( number , 8 ) FROM system . numbers LIMIT 50 ; <nl> <nl> SELECT count ( ) FROM test . decimal WHERE d1 = 1 ; <nl> mmmSELECT * FROM test . decimal WHERE d1 < = toDecimal32 ( 2 , 8 ) ORDER BY d2 DESC ; <nl> + SELECT * FROM test . decimal WHERE d1 > 5 AND d2 < 30 ORDER BY d2 DESC ; <nl> + SELECT * FROM test . decimal WHERE d1 IN ( 1 , 3 ) ORDER BY d2 ; <nl> <nl> DROP TABLE test . decimal ; <nl> | add special ColumnDecimal instead of ColumnVector < DecimalNN > CLICKHOUSE - 3765 | ClickHouse/ClickHouse | c86f2878ff59b5f1a8ef1ce5657362aed5aedb4d | 2018-08-27T16:16:16Z |
mmm a / src / compiler / analysis / variable_table . cpp <nl> ppp b / src / compiler / analysis / variable_table . cpp <nl> void VariableTable : : outputCPPGlobalVariablesGetIndex ( CodeGenerator & cg , <nl> " int64 prehash ) const { \ n " ) ; <nl> cg . printDeclareGlobals ( ) ; <nl> outputCPPJumpTable ( cg , ar , NULL , true , true , EitherStatic , JumpIndex ) ; <nl> - cg . printf ( " return m_data . parr ? ( m_data . parr - > getIndex ( s , prehash ) + % d ) " <nl> - " : % d ; \ n " , m_symbols . size ( ) , ArrayData : : invalid_index ) ; <nl> + cg . printf ( " return m_px ? ( m_px - > getIndex ( s , prehash ) + % d ) : % d ; \ n " , <nl> + m_symbols . size ( ) , ArrayData : : invalid_index ) ; <nl> cg . indentEnd ( " } \ n " ) ; <nl> } <nl> <nl> mmm a / src / runtime / base / type_array . cpp <nl> ppp b / src / runtime / base / type_array . cpp <nl> Array Array : : Create ( CVarRef name , CVarRef var ) { <nl> return ArrayData : : Create ( name . isString ( ) ? name . toKey ( ) : name , var ) ; <nl> } <nl> <nl> - Array : : Array ( ArrayData * data ) { <nl> - m_data . parr = data ; <nl> - if ( m_data . parr ) { <nl> - m_data . parr - > incRefCount ( ) ; <nl> - } <nl> - } <nl> + Array : : Array ( ArrayData * data ) : SmartPtr < ArrayData > ( data ) { } <nl> <nl> - Array : : Array ( CArrRef arr ) { <nl> - m_data . parr = arr . m_data . parr ; <nl> - if ( m_data . parr ) { <nl> - m_data . parr - > incRefCount ( ) ; <nl> - } <nl> - } <nl> + Array : : Array ( CArrRef arr ) : SmartPtr < ArrayData > ( arr . m_px ) { } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / operators <nl> <nl> Array & Array : : operator = ( ArrayData * data ) { <nl> - set ( data ) ; <nl> + SmartPtr < ArrayData > : : operator = ( data ) ; <nl> return * this ; <nl> } <nl> <nl> Array & Array : : operator = ( CArrRef arr ) { <nl> - set ( arr . m_data . parr ) ; <nl> + SmartPtr < ArrayData > : : operator = ( arr . m_px ) ; <nl> return * this ; <nl> } <nl> <nl> Array Array : : operator + ( CVarRef var ) const { <nl> } <nl> <nl> Array Array : : operator + ( CArrRef arr ) const { <nl> - return Array ( m_data . parr ) . operator + = ( arr ) ; <nl> + return Array ( m_px ) . operator + = ( arr ) ; <nl> } <nl> <nl> Array & Array : : operator + = ( CVarRef var ) { <nl> Array & Array : : merge ( CArrRef arr ) { <nl> } <nl> <nl> Array & Array : : mergeImpl ( CArrRef arr , ArrayData : : ArrayOp op ) { <nl> - if ( m_data . parr = = NULL | | arr . m_data . parr = = NULL ) { <nl> + if ( m_px = = NULL | | arr . m_px = = NULL ) { <nl> throw BadArrayMergeException ( ) ; <nl> } <nl> - if ( ! arr . m_data . parr - > empty ( ) ) { <nl> - if ( op ! = ArrayData : : Merge & & m_data . parr - > empty ( ) ) { <nl> - set ( arr . m_data . parr ) ; <nl> + if ( ! arr . m_px - > empty ( ) ) { <nl> + if ( op ! = ArrayData : : Merge & & m_px - > empty ( ) ) { <nl> + SmartPtr < ArrayData > : : operator = ( arr . m_px ) ; <nl> } else { <nl> - ArrayData * escalated = m_data . parr - > append ( arr . m_data . parr , op , <nl> - m_data . parr - > getCount ( ) > 1 ) ; <nl> + ArrayData * escalated = m_px - > append ( arr . m_px , op , m_px - > getCount ( ) > 1 ) ; <nl> if ( escalated ) { <nl> - setPtr ( escalated ) ; <nl> + SmartPtr < ArrayData > : : operator = ( escalated ) ; <nl> } <nl> } <nl> } else if ( op = = ArrayData : : Merge ) { <nl> - m_data . parr - > renumber ( ) ; <nl> + m_px - > renumber ( ) ; <nl> } <nl> return * this ; <nl> } <nl> <nl> Array Array : : slice ( int offset , int length , bool preserve_keys ) const { <nl> - if ( ! m_data . parr ) return Array ( ) ; <nl> - return ArrayUtil : : Slice ( m_data . parr , offset , length , preserve_keys ) ; <nl> + if ( m_px = = NULL ) return Array ( ) ; <nl> + return ArrayUtil : : Slice ( m_px , offset , length , preserve_keys ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / type conversions <nl> <nl> Object Array : : toObject ( ) const { <nl> - if ( m_data . parr ) { <nl> - return m_data . parr - > toObject ( ) ; <nl> + if ( m_px ) { <nl> + return m_px - > toObject ( ) ; <nl> } <nl> return Object ( NEW ( c_stdclass ) ( ) ) ; <nl> } <nl> Object Array : : toObject ( ) const { <nl> / / comparisons <nl> <nl> bool Array : : same ( CArrRef v2 ) const { <nl> - if ( m_data . parr = = NULL & & v2 . m_data . parr = = NULL ) return true ; <nl> - if ( m_data . parr & & v2 . m_data . parr ) { <nl> - return m_data . parr - > compare ( v2 . m_data . parr , true ) = = 0 ; <nl> + if ( m_px = = NULL & & v2 . get ( ) = = NULL ) return true ; <nl> + if ( m_px & & v2 . get ( ) ) { <nl> + return m_px - > compare ( v2 . get ( ) , true ) = = 0 ; <nl> } <nl> return false ; <nl> } <nl> bool Array : : same ( CObjRef v2 ) const { <nl> } <nl> <nl> bool Array : : equal ( CArrRef v2 ) const { <nl> - if ( m_data . parr = = NULL | | v2 . m_data . parr = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : equal ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> - return m_data . parr - > compare ( v2 . get ( ) , false ) = = 0 ; <nl> + return m_px - > compare ( v2 . get ( ) , false ) = = 0 ; <nl> } <nl> <nl> bool Array : : equal ( CObjRef v2 ) const { <nl> - if ( m_data . parr = = NULL | | v2 . get ( ) = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : more ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> return false ; <nl> } <nl> <nl> bool Array : : less ( CArrRef v2 , bool flip / * = false * / ) const { <nl> - if ( m_data . parr = = NULL | | v2 . m_data . parr = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : less ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> if ( flip ) { <nl> - return v2 . get ( ) - > compare ( m_data . parr , false ) > 0 ; <nl> + return v2 . get ( ) - > compare ( m_px , false ) > 0 ; <nl> } <nl> - return m_data . parr - > compare ( v2 . get ( ) , false ) < 0 ; <nl> + return m_px - > compare ( v2 . get ( ) , false ) < 0 ; <nl> } <nl> <nl> bool Array : : less ( CObjRef v2 ) const { <nl> - if ( m_data . parr = = NULL | | v2 . get ( ) = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : less ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> return false ; <nl> } <nl> <nl> bool Array : : less ( CVarRef v2 ) const { <nl> - if ( m_data . parr = = NULL | | v2 . isNull ( ) ) { <nl> + if ( m_px = = NULL | | v2 . isNull ( ) ) { <nl> return HPHP : : less ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> if ( v2 . getType ( ) = = KindOfArray ) { <nl> - return m_data . parr - > compare ( v2 . toArray ( ) . get ( ) , false ) < 0 ; <nl> + return m_px - > compare ( v2 . toArray ( ) . get ( ) , false ) < 0 ; <nl> } <nl> return v2 . more ( * this ) ; <nl> } <nl> <nl> bool Array : : more ( CArrRef v2 , bool flip / * = true * / ) const { <nl> - if ( m_data . parr = = NULL | | v2 . m_data . parr = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : more ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> if ( flip ) { <nl> - return v2 . get ( ) - > compare ( m_data . parr , false ) < 0 ; <nl> + return v2 . get ( ) - > compare ( m_px , false ) < 0 ; <nl> } <nl> - return m_data . parr - > compare ( v2 . get ( ) , false ) > 0 ; <nl> + return m_px - > compare ( v2 . get ( ) , false ) > 0 ; <nl> } <nl> <nl> bool Array : : more ( CObjRef v2 ) const { <nl> - if ( m_data . parr = = NULL | | v2 . get ( ) = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : more ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> return true ; <nl> } <nl> <nl> bool Array : : more ( CVarRef v2 ) const { <nl> - if ( m_data . parr = = NULL | | v2 . isNull ( ) ) { <nl> + if ( m_px = = NULL | | v2 . isNull ( ) ) { <nl> return HPHP : : more ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> if ( v2 . getType ( ) = = KindOfArray ) { <nl> - return v2 . toArray ( ) . get ( ) - > compare ( m_data . parr , false ) < 0 ; <nl> + return v2 . toArray ( ) . get ( ) - > compare ( m_px , false ) < 0 ; <nl> } <nl> return v2 . less ( * this ) ; <nl> } <nl> bool Array : : more ( CVarRef v2 ) const { <nl> / / iterator <nl> <nl> void Array : : escalate ( ) { <nl> - if ( m_data . parr ) { <nl> - SharedMap * mapShared = dynamic_cast < SharedMap * > ( m_data . parr ) ; <nl> + if ( m_px ) { <nl> + SharedMap * mapShared = dynamic_cast < SharedMap * > ( m_px ) ; <nl> if ( mapShared ) { <nl> - setPtr ( mapShared - > escalate ( ) ) ; <nl> + SmartPtr < ArrayData > : : operator = ( mapShared - > escalate ( ) ) ; <nl> return ; <nl> } <nl> if ( ! RuntimeOption : : UseZendArray ) { <nl> - VectorVariant * vecVariant = dynamic_cast < VectorVariant * > ( m_data . parr ) ; <nl> + VectorVariant * vecVariant = dynamic_cast < VectorVariant * > ( m_px ) ; <nl> if ( vecVariant ) { <nl> - setPtr ( NEW ( MapVariant ) ( vecVariant ) ) ; <nl> + SmartPtr < ArrayData > : : operator = ( NEW ( MapVariant ) ( vecVariant ) ) ; <nl> return ; <nl> } <nl> <nl> - ASSERT ( dynamic_cast < VectorVariant * > ( m_data . parr ) | | <nl> - dynamic_cast < MapVariant * > ( m_data . parr ) ) ; <nl> + ASSERT ( dynamic_cast < VectorVariant * > ( m_px ) | | <nl> + dynamic_cast < MapVariant * > ( m_px ) ) ; <nl> } <nl> } <nl> } <nl> void Array : : escalate ( ) { <nl> <nl> Variant Array : : rvalAt ( bool key , int64 prehash / * = - 1 * / , <nl> bool error / * = false * / ) const { <nl> - if ( m_data . parr ) return m_data . parr - > get ( key ? 1LL : 0LL , prehash , error ) ; <nl> + if ( m_px ) return m_px - > get ( key ? 1LL : 0LL , prehash , error ) ; <nl> return null_variant ; <nl> } <nl> <nl> Variant Array : : rvalAt ( char key , int64 prehash / * = - 1 * / , <nl> bool error / * = false * / ) const { <nl> - if ( m_data . parr ) return m_data . parr - > get ( ( int64 ) key , prehash , error ) ; <nl> + if ( m_px ) return m_px - > get ( ( int64 ) key , prehash , error ) ; <nl> return null_variant ; <nl> } <nl> <nl> Variant Array : : rvalAt ( short key , int64 prehash / * = - 1 * / , <nl> bool error / * = false * / ) const { <nl> - if ( m_data . parr ) return m_data . parr - > get ( ( int64 ) key , prehash , error ) ; <nl> + if ( m_px ) return m_px - > get ( ( int64 ) key , prehash , error ) ; <nl> return null_variant ; <nl> } <nl> <nl> Variant Array : : rvalAt ( int key , int64 prehash / * = - 1 * / , <nl> bool error / * = false * / ) const { <nl> - if ( m_data . parr ) return m_data . parr - > get ( ( int64 ) key , prehash , error ) ; <nl> + if ( m_px ) return m_px - > get ( ( int64 ) key , prehash , error ) ; <nl> return null_variant ; <nl> } <nl> <nl> Variant Array : : rvalAt ( int64 key , int64 prehash / * = - 1 * / , <nl> bool error / * = false * / ) const { <nl> - if ( m_data . parr ) return m_data . parr - > get ( key , prehash , error ) ; <nl> + if ( m_px ) return m_px - > get ( key , prehash , error ) ; <nl> return null_variant ; <nl> } <nl> <nl> Variant Array : : rvalAt ( ssize_t key , int64 prehash / * = - 1 * / , <nl> bool error / * = false * / ) const { <nl> - if ( m_data . parr ) return m_data . parr - > get ( ( int64 ) key , error ) ; <nl> + if ( m_px ) return m_px - > get ( ( int64 ) key , error ) ; <nl> return null_variant ; <nl> } <nl> <nl> Variant Array : : rvalAt ( double key , int64 prehash / * = - 1 * / , <nl> bool error / * = false * / ) const { <nl> - if ( m_data . parr ) return m_data . parr - > get ( ( int64 ) key , prehash , error ) ; <nl> + if ( m_px ) return m_px - > get ( ( int64 ) key , prehash , error ) ; <nl> return null_variant ; <nl> } <nl> <nl> Variant Array : : rvalAt ( litstr key , int64 prehash / * = - 1 * / , <nl> bool error / * = false * / , <nl> bool isString / * = false * / ) const { <nl> - if ( m_data . parr ) { <nl> - if ( isString ) return m_data . parr - > get ( key , prehash , error ) ; <nl> + if ( m_px ) { <nl> + if ( isString ) return m_px - > get ( key , prehash , error ) ; <nl> int64 n ; <nl> int len = strlen ( key ) ; <nl> if ( ! is_strictly_integer ( key , len , n ) ) { <nl> - return m_data . parr - > get ( key , prehash , error ) ; <nl> + return m_px - > get ( key , prehash , error ) ; <nl> } else { <nl> - return m_data . parr - > get ( n , prehash , error ) ; <nl> + return m_px - > get ( n , prehash , error ) ; <nl> } <nl> } <nl> return null_variant ; <nl> Variant Array : : rvalAt ( litstr key , int64 prehash / * = - 1 * / , <nl> Variant Array : : rvalAt ( CStrRef key , int64 prehash / * = - 1 * / , <nl> bool error / * = false * / , <nl> bool isString / * = false * / ) const { <nl> - if ( m_data . parr ) { <nl> - if ( isString ) return m_data . parr - > get ( key , prehash , error ) ; <nl> + if ( m_px ) { <nl> + if ( isString ) return m_px - > get ( key , prehash , error ) ; <nl> int64 n ; <nl> if ( ! key - > isStrictlyInteger ( n ) ) { <nl> - return m_data . parr - > get ( key , prehash , error ) ; <nl> + return m_px - > get ( key , prehash , error ) ; <nl> } else { <nl> - return m_data . parr - > get ( n , prehash , error ) ; <nl> + return m_px - > get ( n , prehash , error ) ; <nl> } <nl> } <nl> return null_variant ; <nl> Variant Array : : rvalAt ( CStrRef key , int64 prehash / * = - 1 * / , <nl> <nl> Variant Array : : rvalAt ( CVarRef key , int64 prehash / * = - 1 * / , <nl> bool error / * = false * / ) const { <nl> - if ( ! m_data . parr ) return null_variant ; <nl> + if ( ! m_px ) return null_variant ; <nl> switch ( key . m_type ) { <nl> case KindOfNull : <nl> - return m_data . parr - > get ( " " , prehash , error ) ; <nl> + return m_px - > get ( " " , prehash , error ) ; <nl> case KindOfBoolean : <nl> case KindOfByte : <nl> case KindOfInt16 : <nl> case KindOfInt32 : <nl> case KindOfInt64 : <nl> - return m_data . parr - > get ( key . m_data . num , prehash , error ) ; <nl> + return m_px - > get ( key . m_data . num , prehash , error ) ; <nl> case KindOfDouble : <nl> - return m_data . parr - > get ( ( int64 ) key . m_data . dbl , prehash , error ) ; <nl> + return m_px - > get ( ( int64 ) key . m_data . dbl , prehash , error ) ; <nl> case LiteralString : <nl> key . escalateString ( ) ; <nl> / / fall through <nl> case KindOfString : { <nl> int64 n ; <nl> if ( key . m_data . pstr - > isStrictlyInteger ( n ) ) { <nl> - return m_data . parr - > get ( n , prehash , error ) ; <nl> + return m_px - > get ( n , prehash , error ) ; <nl> } else { <nl> - return m_data . parr - > get ( String ( key . m_data . pstr ) , prehash , error ) ; <nl> + return m_px - > get ( String ( key . m_data . pstr ) , prehash , error ) ; <nl> } <nl> } <nl> case KindOfArray : <nl> Variant Array : : rvalAt ( CVarRef key , int64 prehash / * = - 1 * / , <nl> break ; <nl> case KindOfObject : <nl> if ( key . isResource ( ) ) { <nl> - return m_data . parr - > get ( key . toInt64 ( ) , prehash , error ) ; <nl> + return m_px - > get ( key . toInt64 ( ) , prehash , error ) ; <nl> } <nl> throw_bad_type_exception ( " Invalid type used as key " ) ; <nl> break ; <nl> void Array : : removeAll ( ) { <nl> } <nl> <nl> Variant Array : : append ( CVarRef v ) { <nl> - if ( ! m_data . parr ) { <nl> - setPtr ( ArrayData : : Create ( v ) ) ; <nl> + if ( ! m_px ) { <nl> + SmartPtr < ArrayData > : : operator = ( ArrayData : : Create ( v ) ) ; <nl> } else { <nl> if ( v . isContagious ( ) ) { <nl> escalate ( ) ; <nl> } <nl> - bool copy = ( m_data . parr - > getCount ( ) > 1 ) ; <nl> - ArrayData * escalated = m_data . parr - > append ( v , copy ) ; <nl> + ArrayData * escalated = m_px - > append ( v , ( m_px - > getCount ( ) > 1 ) ) ; <nl> if ( escalated ) { <nl> - setPtr ( escalated ) ; <nl> + SmartPtr < ArrayData > : : operator = ( escalated ) ; <nl> } <nl> } <nl> return v ; <nl> } <nl> <nl> Variant Array : : pop ( ) { <nl> - if ( m_data . parr ) { <nl> + if ( m_px ) { <nl> Variant ret ; <nl> - ArrayData * newarr = m_data . parr - > pop ( ret ) ; <nl> + ArrayData * newarr = m_px - > pop ( ret ) ; <nl> if ( newarr ) { <nl> - setPtr ( newarr ) ; <nl> + SmartPtr < ArrayData > : : operator = ( newarr ) ; <nl> } <nl> return ret ; <nl> } <nl> Variant Array : : pop ( ) { <nl> } <nl> <nl> Variant Array : : dequeue ( ) { <nl> - if ( m_data . parr ) { <nl> + if ( m_px ) { <nl> Variant ret ; <nl> - ArrayData * newarr = m_data . parr - > dequeue ( ret ) ; <nl> + ArrayData * newarr = m_px - > dequeue ( ret ) ; <nl> if ( newarr ) { <nl> - setPtr ( newarr ) ; <nl> + SmartPtr < ArrayData > : : operator = ( newarr ) ; <nl> } <nl> return ret ; <nl> } <nl> Variant Array : : dequeue ( ) { <nl> } <nl> <nl> void Array : : prepend ( CVarRef v ) { <nl> - if ( ! m_data . parr ) { <nl> + if ( ! m_px ) { <nl> operator = ( Create ( ) ) ; <nl> } <nl> - ASSERT ( m_data . parr ) ; <nl> + ASSERT ( m_px ) ; <nl> <nl> - ArrayData * newarr = m_data . parr - > prepend ( v , ( m_data . parr - > getCount ( ) > 1 ) ) ; <nl> + ArrayData * newarr = m_px - > prepend ( v , ( m_px - > getCount ( ) > 1 ) ) ; <nl> if ( newarr ) { <nl> - setPtr ( newarr ) ; <nl> + SmartPtr < ArrayData > : : operator = ( newarr ) ; <nl> } <nl> } <nl> <nl> void Array : : prepend ( CVarRef v ) { <nl> / / output functions <nl> <nl> void Array : : serialize ( VariableSerializer * serializer ) const { <nl> - if ( m_data . parr ) { <nl> - m_data . parr - > serialize ( serializer ) ; <nl> + if ( m_px ) { <nl> + m_px - > serialize ( serializer ) ; <nl> } else { <nl> serializer - > writeNull ( ) ; <nl> } <nl> void Array : : unserialize ( VariableUnserializer * unserializer ) { <nl> } <nl> <nl> void Array : : dump ( ) { <nl> - if ( m_data . parr ) { <nl> - m_data . parr - > dump ( ) ; <nl> + if ( m_px ) { <nl> + m_px - > dump ( ) ; <nl> } else { <nl> printf ( " ( null ) \ n " ) ; <nl> } <nl> void Array : : sort ( PFUNC_CMP cmp_func , bool by_key , bool renumber , <nl> for ( int i = 0 ; i < count ; i + + ) { <nl> ssize_t pos = opaque . positions [ indices [ i ] ] ; <nl> if ( renumber ) { <nl> - sorted . append ( m_data . parr - > getValue ( pos ) ) ; <nl> + sorted . append ( m_px - > getValue ( pos ) ) ; <nl> } else { <nl> - sorted . set ( m_data . parr - > getKey ( pos ) , m_data . parr - > getValue ( pos ) ) ; <nl> + sorted . set ( m_px - > getKey ( pos ) , m_px - > getValue ( pos ) ) ; <nl> } <nl> } <nl> operator = ( sorted ) ; <nl> mmm a / src / runtime / base / type_array . h <nl> ppp b / src / runtime / base / type_array . h <nl> <nl> # include < runtime / base / type_string . h > <nl> # include < runtime / base / hphp_value . h > <nl> <nl> - <nl> namespace HPHP { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> CVarRef ref ( CVarRef v ) ; <nl> * VectorVariant escalates to MapVariant when a string key is added , or when <nl> * an integer key that is out of range is added . <nl> * / <nl> - class Array : protected Value { <nl> + class Array : public SmartPtr < ArrayData > { <nl> public : <nl> - friend class Variant ; <nl> - <nl> / * * <nl> * Create an empty array or an array with one element . Note these are <nl> * different than those copying constructors that also take one value . <nl> class Array : protected Value { <nl> static Array Create ( CVarRef key , CVarRef value ) ; <nl> <nl> public : <nl> - Array ( ) { <nl> - m_data . parr = NULL ; <nl> - } <nl> - ~ Array ( ) { <nl> - if ( m_data . parr & & m_data . parr - > decRefCount ( ) = = 0 ) { <nl> - m_data . parr - > release ( ) ; <nl> - } <nl> - } <nl> + Array ( ) { } <nl> <nl> static const Array s_nullArray ; <nl> <nl> class Array : protected Value { <nl> Array ( ArrayData * data ) ; <nl> Array ( CArrRef arr ) ; <nl> <nl> - bool isNull ( ) const { <nl> - return m_data . parr = = NULL ; <nl> - } <nl> - <nl> - Array & set ( ArrayData * px ) { <nl> - if ( m_data . parr ! = px ) { <nl> - if ( m_data . parr & & m_data . parr - > decRefCount ( ) = = 0 ) { <nl> - m_data . parr - > release ( ) ; <nl> - } <nl> - m_data . parr = px ; <nl> - if ( m_data . parr ) { <nl> - m_data . parr - > incRefCount ( ) ; <nl> - } <nl> - } <nl> - return * this ; <nl> - } <nl> - <nl> - private : <nl> - Array & setPtr ( ArrayData * px ) { <nl> - ASSERT ( m_data . parr ! = px ) ; <nl> - ASSERT ( px ! = NULL ) ; <nl> - if ( m_data . parr & & m_data . parr - > decRefCount ( ) = = 0 ) { <nl> - m_data . parr - > release ( ) ; <nl> - } <nl> - m_data . parr = px ; <nl> - m_data . parr - > incRefCount ( ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - public : <nl> - Array & set ( const Array & src ) { <nl> - return set ( src . m_data . parr ) ; <nl> - } <nl> - <nl> - void reset ( ) { <nl> - if ( m_data . parr & & m_data . parr - > decRefCount ( ) = = 0 ) { <nl> - m_data . parr - > release ( ) ; <nl> - } <nl> - m_data . parr = NULL ; <nl> - } <nl> - <nl> - / * * <nl> - * Magic delegation . <nl> - * / <nl> - ArrayData * operator - > ( ) const { <nl> - if ( ! m_data . parr ) throw NullPointerException ( ) ; <nl> - return m_data . parr ; <nl> - } <nl> - <nl> - / * * <nl> - * Get the raw pointer . <nl> - * / <nl> - ArrayData * get ( ) const { <nl> - return m_data . parr ; <nl> - } <nl> - <nl> / * * <nl> * Informational <nl> * / <nl> bool empty ( ) const { <nl> - return m_data . parr = = NULL | | m_data . parr - > empty ( ) ; <nl> + return m_px = = NULL | | m_px - > empty ( ) ; <nl> } <nl> ssize_t size ( ) const { <nl> - return m_data . parr ? m_data . parr - > size ( ) : 0 ; <nl> + return m_px ? m_px - > size ( ) : 0 ; <nl> } <nl> ssize_t length ( ) const { <nl> - return m_data . parr ? m_data . parr - > size ( ) : 0 ; <nl> + return m_px ? m_px - > size ( ) : 0 ; <nl> + } <nl> + bool isNull ( ) const { <nl> + return m_px = = NULL ; <nl> } <nl> bool valueExists ( CVarRef search_value , bool strict = false ) const ; <nl> Variant key ( CVarRef search_value , bool strict = false ) const ; <nl> class Array : protected Value { <nl> * escalate ( ) will escalate me to become VectorVariant or MapVariant , so that <nl> * getValueRef ( ) can be called to take a reference to an array element . <nl> * / <nl> - ArrayIter begin ( const char * context = NULL ) const { return m_data . parr ; } <nl> + ArrayIter begin ( const char * context = NULL ) const { return m_px ; } <nl> void escalate ( ) ; <nl> <nl> / * * <nl> class Array : protected Value { <nl> / * * <nl> * Type conversions <nl> * / <nl> - bool toBoolean ( ) const { <nl> - return m_data . parr & & ! m_data . parr - > empty ( ) ; <nl> - } <nl> - char toByte ( ) const { <nl> - return ( m_data . parr & & ! m_data . parr - > empty ( ) ) ? 1 : 0 ; <nl> - } <nl> - short toInt16 ( ) const { <nl> - return ( m_data . parr & & ! m_data . parr - > empty ( ) ) ? 1 : 0 ; <nl> - } <nl> - int toInt32 ( ) const { <nl> - return ( m_data . parr & & ! m_data . parr - > empty ( ) ) ? 1 : 0 ; <nl> - } <nl> - int64 toInt64 ( ) const { <nl> - return ( m_data . parr & & ! m_data . parr - > empty ( ) ) ? 1 : 0 ; <nl> - } <nl> - double toDouble ( ) const { <nl> - return ( m_data . parr & & ! m_data . parr - > empty ( ) ) ? 1 . 0 : 0 . 0 ; <nl> - } <nl> - String toString ( ) const { <nl> - return m_data . parr ? " Array " : " " ; <nl> - } <nl> + bool toBoolean ( ) const { return m_px & & ! m_px - > empty ( ) ; } <nl> + char toByte ( ) const { return ( m_px & & ! m_px - > empty ( ) ) ? 1 : 0 ; } <nl> + short toInt16 ( ) const { return ( m_px & & ! m_px - > empty ( ) ) ? 1 : 0 ; } <nl> + int toInt32 ( ) const { return ( m_px & & ! m_px - > empty ( ) ) ? 1 : 0 ; } <nl> + int64 toInt64 ( ) const { return ( m_px & & ! m_px - > empty ( ) ) ? 1 : 0 ; } <nl> + double toDouble ( ) const { return ( m_px & & ! m_px - > empty ( ) ) ? 1 . 0 : 0 . 0 ; } <nl> + String toString ( ) const { return m_px ? " Array " : " " ; } <nl> Object toObject ( ) const ; <nl> <nl> / * * <nl> class Array : protected Value { <nl> const Variant operator [ ] ( CVarRef key ) const ; <nl> <nl> Variant & lval ( ) { <nl> - ASSERT ( m_data . parr ) ; <nl> + ASSERT ( m_px ) ; <nl> Variant * ret = NULL ; <nl> - ArrayData * escalated = m_data . parr - > lval ( ret , m_data . parr - > getCount ( ) > 1 ) ; <nl> + ArrayData * escalated = m_px - > lval ( ret , m_px - > getCount ( ) > 1 ) ; <nl> if ( escalated ) { <nl> - setPtr ( escalated ) ; <nl> + SmartPtr < ArrayData > : : operator = ( escalated ) ; <nl> } <nl> ASSERT ( ret ) ; <nl> return * ret ; <nl> } <nl> <nl> Variant & lval ( int64 key ) { <nl> - ASSERT ( m_data . parr ) ; <nl> + ASSERT ( m_px ) ; <nl> Variant * ret = NULL ; <nl> - ArrayData * escalated = <nl> - m_data . parr - > lval ( key , ret , m_data . parr - > getCount ( ) > 1 ) ; <nl> + ArrayData * escalated = m_px - > lval ( key , ret , m_px - > getCount ( ) > 1 ) ; <nl> if ( escalated ) { <nl> - setPtr ( escalated ) ; <nl> + SmartPtr < ArrayData > : : operator = ( escalated ) ; <nl> } <nl> ASSERT ( ret ) ; <nl> return * ret ; <nl> } <nl> <nl> Variant & lval ( CStrRef key ) { <nl> - ASSERT ( m_data . parr ) ; <nl> + ASSERT ( m_px ) ; <nl> Variant * ret = NULL ; <nl> - ArrayData * escalated = <nl> - m_data . parr - > lval ( key , ret , m_data . parr - > getCount ( ) > 1 ) ; <nl> + ArrayData * escalated = m_px - > lval ( key , ret , m_px - > getCount ( ) > 1 ) ; <nl> if ( escalated ) { <nl> - setPtr ( escalated ) ; <nl> + SmartPtr < ArrayData > : : operator = ( escalated ) ; <nl> } <nl> ASSERT ( ret ) ; <nl> return * ret ; <nl> class Array : protected Value { <nl> * / <nl> template < typename T > <nl> bool existsImpl ( const T & key , int64 prehash ) const { <nl> - if ( m_data . parr ) return m_data . parr - > exists ( key , prehash ) ; <nl> + if ( m_px ) return m_px - > exists ( key , prehash ) ; <nl> return false ; <nl> } <nl> bool exists ( bool key , int64 prehash = - 1 ) const { <nl> class Array : protected Value { <nl> <nl> template < typename T > <nl> void removeImpl ( const T & key , int64 prehash ) { <nl> - if ( m_data . parr ) { <nl> - ArrayData * escalated = <nl> - m_data . parr - > remove ( key , ( m_data . parr - > getCount ( ) > 1 ) , prehash ) ; <nl> + if ( m_px ) { <nl> + ArrayData * escalated = m_px - > remove ( key , ( m_px - > getCount ( ) > 1 ) , prehash ) ; <nl> if ( escalated ) { <nl> - setPtr ( escalated ) ; <nl> + SmartPtr < ArrayData > : : operator = ( escalated ) ; <nl> } <nl> } <nl> } <nl> class Array : protected Value { <nl> <nl> template < typename T > <nl> void weakRemove ( const T & key , int64 prehash = - 1 ) { <nl> - if ( m_data . parr ) remove ( key , prehash ) ; <nl> + if ( m_px ) remove ( key , prehash ) ; <nl> } <nl> <nl> void removeAll ( ) ; <nl> class Array : protected Value { <nl> void dump ( ) ; <nl> <nl> ArrayData * getArrayData ( ) const { <nl> - return m_data . parr ; <nl> + return m_px ; <nl> } <nl> <nl> void setStatic ( ) const { <nl> - if ( m_data . parr ) { <nl> - m_data . parr - > setStatic ( ) ; <nl> - m_data . parr - > onSetStatic ( ) ; <nl> + if ( m_px ) { <nl> + m_px - > setStatic ( ) ; <nl> + m_px - > onSetStatic ( ) ; <nl> } <nl> } <nl> <nl> class Array : protected Value { <nl> template < typename T > <nl> Variant & lvalAtImpl ( const T & key , int64 prehash = - 1 , <nl> bool checkExist = false ) { <nl> - if ( ! m_data . parr ) { <nl> - setPtr ( ArrayData : : Create ( ) ) ; <nl> + if ( ! m_px ) { <nl> + SmartPtr < ArrayData > : : operator = ( ArrayData : : Create ( ) ) ; <nl> } <nl> Variant * ret = NULL ; <nl> - ArrayData * escalated = m_data . parr - > lval ( key , ret , <nl> - m_data . parr - > getCount ( ) > 1 , <nl> - prehash , checkExist ) ; <nl> + ArrayData * escalated = <nl> + m_px - > lval ( key , ret , m_px - > getCount ( ) > 1 , prehash , checkExist ) ; <nl> if ( escalated ) { <nl> - setPtr ( escalated ) ; <nl> + SmartPtr < ArrayData > : : operator = ( escalated ) ; <nl> } <nl> ASSERT ( ret ) ; <nl> return * ret ; <nl> } <nl> + <nl> + static void compileTimeAssertions ( ) { <nl> + CT_ASSERT ( offsetof ( Array , m_px ) = = offsetof ( Value , m_data ) ) ; <nl> + } <nl> } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> class StaticArray : public Array { <nl> public : <nl> StaticArray ( ) { } <nl> StaticArray ( ArrayData * data ) : Array ( data ) { <nl> - m_data . parr - > setStatic ( ) ; <nl> - m_data . parr - > onSetStatic ( ) ; <nl> + m_px - > setStatic ( ) ; <nl> + m_px - > onSetStatic ( ) ; <nl> } <nl> ~ StaticArray ( ) { <nl> - / / prevent ~ Array from calling decRefCount after data is released <nl> - m_data . parr = NULL ; <nl> + / / prevent ~ SmartPtr from calling decRefCount after data is released <nl> + m_px = NULL ; <nl> } <nl> } ; <nl> <nl> mmm a / src / runtime / base / type_object . cpp <nl> ppp b / src / runtime / base / type_object . cpp <nl> const Object Object : : s_nullObject = Object ( ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - Object & Object : : operator = ( CVarRef var ) { <nl> - return operator = ( var . toObject ( ) ) ; <nl> - } <nl> - <nl> Array Object : : toArray ( ) const { <nl> - return m_data . pobj ? m_data . pobj - > o_toArray ( ) : Array ( ) ; <nl> + return m_px ? m_px - > o_toArray ( ) : Array ( ) ; <nl> } <nl> <nl> Variant Object : : toKey ( ) const { <nl> - if ( m_data . pobj ) { <nl> - if ( isResource ( ) ) { <nl> - return m_data . pobj - > o_toInt64 ( ) ; <nl> - } else { <nl> - return m_data . pobj - > t___tostring ( ) ; <nl> - } <nl> - } else { <nl> - return null_variant ; <nl> - } <nl> + return m_px ? ( isResource ( ) ? m_px - > o_toInt64 ( ) : m_px - > t___tostring ( ) ) <nl> + : String ( ) ; <nl> } <nl> <nl> bool Object : : equal ( CObjRef v2 ) const { <nl> - if ( m_data . pobj = = v2 . m_data . pobj ) <nl> + if ( m_px = = v2 . get ( ) ) <nl> return true ; <nl> - if ( ! m_data . pobj | | ! v2 . m_data . pobj ) <nl> + if ( ! m_px | | ! v2 . get ( ) ) <nl> return false ; <nl> if ( isResource ( ) | | v2 . isResource ( ) ) <nl> return false ; <nl> - return ( v2 . get ( ) - > o_isClass ( m_data . pobj - > o_getClassName ( ) ) & & <nl> + return ( v2 . get ( ) - > o_isClass ( m_px - > o_getClassName ( ) ) & & <nl> toArray ( ) . equal ( v2 . toArray ( ) ) ) ; <nl> } <nl> <nl> bool Object : : less ( CObjRef v2 ) const { <nl> - return m_data . pobj ! = v2 . m_data . pobj & & <nl> + return m_px ! = v2 . m_px & & <nl> toArray ( ) . less ( v2 . toArray ( ) ) ; <nl> } <nl> <nl> bool Object : : more ( CObjRef v2 ) const { <nl> - return m_data . pobj ! = v2 . m_data . pobj & & <nl> + return m_px ! = v2 . m_px & & <nl> toArray ( ) . more ( v2 . toArray ( ) ) ; <nl> } <nl> <nl> Variant Object : : o_get ( CStrRef propName , int64 hash / * = - 1 * / , <nl> bool error / * = true * / ) const { <nl> - if ( ! m_data . pobj ) throw NullPointerException ( ) ; <nl> - return m_data . pobj - > o_get ( propName , hash , error ) ; <nl> + if ( ! m_px ) throw NullPointerException ( ) ; <nl> + return m_px - > o_get ( propName , hash , error ) ; <nl> } <nl> <nl> ObjectOffset Object : : o_lval ( CStrRef propName , int64 hash / * = - 1 * / ) { <nl> - if ( ! m_data . pobj ) { <nl> + if ( ! m_px ) { <nl> operator = ( NEW ( c_stdclass ) ( ) ) ; <nl> } <nl> - return ObjectOffset ( m_data . pobj , propName , hash ) ; <nl> + return ObjectOffset ( m_px , propName , hash ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / output <nl> <nl> void Object : : serialize ( VariableSerializer * serializer ) const { <nl> - if ( m_data . pobj ) { <nl> - m_data . pobj - > serialize ( serializer ) ; <nl> + if ( m_px ) { <nl> + m_px - > serialize ( serializer ) ; <nl> } else { <nl> serializer - > writeNull ( ) ; <nl> } <nl> mmm a / src / runtime / base / type_object . h <nl> ppp b / src / runtime / base / type_object . h <nl> namespace HPHP { <nl> / * * <nl> * Object type wrapping around ObjectData to implement reference count . <nl> * / <nl> - class Object : protected Value { <nl> + class Object : public SmartPtr < ObjectData > { <nl> public : <nl> - friend class Variant ; <nl> - <nl> - Object ( ) { <nl> - m_data . pobj = NULL ; <nl> - } <nl> - ~ Object ( ) { <nl> - if ( m_data . pobj & & m_data . pobj - > decRefCount ( ) = = 0 ) { <nl> - m_data . pobj - > release ( ) ; <nl> - } <nl> - } <nl> + Object ( ) { } <nl> <nl> static const Object s_nullObject ; <nl> <nl> / * * <nl> * Constructors <nl> * / <nl> - Object ( ObjectData * data ) { <nl> - m_data . pobj = data ; <nl> - if ( m_data . pobj ) { <nl> - m_data . pobj - > incRefCount ( ) ; <nl> - } <nl> - } <nl> - <nl> + Object ( ObjectData * data ) : SmartPtr < ObjectData > ( data ) { } <nl> template < typename T > <nl> - Object ( T * data ) { <nl> + Object ( T * data ) : SmartPtr < ObjectData > ( ) { <nl> + / / Assert that casting does not adjust the ' this ' pointer <nl> + ASSERT ( ( void * ) dynamic_cast < ObjectData * > ( data ) = = ( void * ) data ) ; <nl> / / Performs a static_cast from T * to ObjectData * . This statement will <nl> / / cause a compile time failure if T is not a descendent of ObjectData <nl> / / in the inheritance hierarchy <nl> - m_data . pobj = static_cast < ObjectData * > ( data ) ; <nl> - / / Assert that casting does not adjust the ' this ' pointer <nl> - ASSERT ( ( void * ) dynamic_cast < ObjectData * > ( data ) = = ( void * ) data ) ; <nl> - if ( m_data . pobj ) m_data . pobj - > incRefCount ( ) ; <nl> - } <nl> - <nl> - Object ( CObjRef src ) { <nl> - m_data . pobj = src . m_data . pobj ; <nl> - if ( m_data . pobj ) { <nl> - m_data . pobj - > incRefCount ( ) ; <nl> - } <nl> - } <nl> - <nl> - bool isNull ( ) const { <nl> - return m_data . pobj = = NULL ; <nl> - } <nl> - <nl> - Object & set ( ObjectData * px ) { <nl> - if ( m_data . pobj ! = px ) { <nl> - if ( m_data . pobj & & m_data . pobj - > decRefCount ( ) = = 0 ) { <nl> - m_data . pobj - > release ( ) ; <nl> - } <nl> - m_data . pobj = px ; <nl> - if ( m_data . pobj ) { <nl> - m_data . pobj - > incRefCount ( ) ; <nl> - } <nl> - } <nl> - return * this ; <nl> - } <nl> - <nl> - private : <nl> - Object & setPtr ( ObjectData * px ) { <nl> - ASSERT ( m_data . pobj ! = px ) ; <nl> - ASSERT ( px ! = NULL ) ; <nl> - if ( m_data . pobj & & m_data . pobj - > decRefCount ( ) = = 0 ) { <nl> - m_data . pobj - > release ( ) ; <nl> - } <nl> - m_data . pobj = px ; <nl> - m_data . pobj - > incRefCount ( ) ; <nl> - return * this ; <nl> + SmartPtr < ObjectData > : : operator = ( static_cast < ObjectData * > ( data ) ) ; <nl> } <nl> <nl> - public : <nl> - Object & set ( const Object & src ) { <nl> - return set ( src . m_data . pobj ) ; <nl> - } <nl> - <nl> - void reset ( ) { <nl> - if ( m_data . pobj & & m_data . pobj - > decRefCount ( ) = = 0 ) { <nl> - m_data . pobj - > release ( ) ; <nl> - } <nl> - m_data . pobj = NULL ; <nl> - } <nl> - <nl> - / * * <nl> - * Magic delegation . <nl> - * / <nl> - ObjectData * operator - > ( ) const { <nl> - if ( ! m_data . pobj ) throw NullPointerException ( ) ; <nl> - return m_data . pobj ; <nl> - } <nl> - <nl> - / * * <nl> - * Get the raw pointer . <nl> - * / <nl> - ObjectData * get ( ) const { <nl> - return m_data . pobj ; <nl> - } <nl> - <nl> - / * * <nl> - * Operators <nl> - * / <nl> - Object & operator = ( ObjectData * data ) { <nl> - set ( data ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Object & operator = ( CObjRef obj ) { <nl> - set ( obj . m_data . pobj ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - Object & operator = ( CVarRef var ) ; <nl> + Object ( CObjRef src ) : SmartPtr < ObjectData > ( src . m_px ) { } <nl> <nl> / * * <nl> * Informational <nl> * / <nl> + bool isNull ( ) const { <nl> + return m_px = = NULL ; <nl> + } <nl> bool isResource ( ) const { <nl> - return m_data . pobj & & m_data . pobj - > isResource ( ) ; <nl> + return m_px & & m_px - > isResource ( ) ; <nl> } <nl> bool instanceof ( const char * s ) const { <nl> - return m_data . pobj & & m_data . pobj - > o_instanceof ( s ) ; <nl> + return m_px & & m_px - > o_instanceof ( s ) ; <nl> } <nl> <nl> / * * <nl> class Object : protected Value { <nl> T * getTyped ( bool nullOkay = false , bool badTypeOkay = false ) const { <nl> CT_ASSERT_DESCENDENT_OF_OBJECTDATA ( T ) ; <nl> <nl> - if ( ! m_data . pobj ) { <nl> + if ( ! m_px ) { <nl> if ( ! nullOkay ) { <nl> throw NullPointerException ( ) ; <nl> } <nl> return NULL ; <nl> } <nl> - ASSERT ( m_data . pobj ) ; <nl> <nl> - T * px = dynamic_cast < T * > ( m_data . pobj ) ; <nl> + T * px = dynamic_cast < T * > ( m_px ) ; <nl> / / Assert that casting does not adjust the ' this ' pointer <nl> - ASSERT ( px = = NULL | | ( void * ) px = = ( void * ) m_data . pobj ) ; <nl> + ASSERT ( px = = NULL | | ( void * ) px = = ( void * ) m_px ) ; <nl> if ( ! px & & ! badTypeOkay ) { <nl> - throw InvalidObjectTypeException ( m_data . pobj - > o_getClassName ( ) ) ; <nl> + throw InvalidObjectTypeException ( m_px - > o_getClassName ( ) ) ; <nl> } <nl> <nl> return px ; <nl> class Object : protected Value { <nl> / * * <nl> * Type conversions <nl> * / <nl> - bool toBoolean ( ) const { return m_data . pobj ; } <nl> - char toByte ( ) const { return m_data . pobj ? m_data . pobj - > o_toInt64 ( ) : 0 ; } <nl> - short toInt16 ( ) const { return m_data . pobj ? m_data . pobj - > o_toInt64 ( ) : 0 ; } <nl> - int toInt32 ( ) const { return m_data . pobj ? m_data . pobj - > o_toInt64 ( ) : 0 ; } <nl> - int64 toInt64 ( ) const { return m_data . pobj ? m_data . pobj - > o_toInt64 ( ) : 0 ; } <nl> - double toDouble ( ) const { return m_data . pobj ? m_data . pobj - > o_toInt64 ( ) : 0 ; } <nl> - String toString ( ) const { <nl> - return m_data . pobj ? m_data . pobj - > t___tostring ( ) : String ( ) ; <nl> - } <nl> + bool toBoolean ( ) const { return m_px ! = NULL ; } <nl> + char toByte ( ) const { return m_px ? m_px - > o_toInt64 ( ) : 0 ; } <nl> + short toInt16 ( ) const { return m_px ? m_px - > o_toInt64 ( ) : 0 ; } <nl> + int toInt32 ( ) const { return m_px ? m_px - > o_toInt64 ( ) : 0 ; } <nl> + int64 toInt64 ( ) const { return m_px ? m_px - > o_toInt64 ( ) : 0 ; } <nl> + double toDouble ( ) const { return m_px ? m_px - > o_toInt64 ( ) : 0 ; } <nl> + String toString ( ) const { return m_px ? m_px - > t___tostring ( ) : String ( ) ; } <nl> Array toArray ( ) const ; <nl> Variant toKey ( ) const ; <nl> <nl> / * * <nl> * Comparisons <nl> * / <nl> - bool same ( CObjRef v2 ) const { return m_data . pobj = = v2 . m_data . pobj ; } <nl> + bool same ( CObjRef v2 ) const { return m_px = = v2 . get ( ) ; } <nl> bool equal ( CObjRef v2 ) const ; <nl> bool less ( CObjRef v2 ) const ; <nl> bool more ( CObjRef v2 ) const ; <nl> class Object : protected Value { <nl> * / <nl> void serialize ( VariableSerializer * serializer ) const ; <nl> bool unserialize ( std : : istream & in ) ; <nl> + <nl> + private : <nl> + static void compileTimeAssertions ( ) { <nl> + CT_ASSERT ( offsetof ( Object , m_px ) = = offsetof ( Value , m_data ) ) ; <nl> + } <nl> } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / src / runtime / base / type_string . cpp <nl> ppp b / src / runtime / base / type_string . cpp <nl> String : : String ( int n ) { <nl> <nl> buf = ( char * ) malloc ( len + 1 ) ; <nl> memcpy ( buf , p , len + 1 ) ; / / including the null terminator . <nl> - m_data . pstr = NEW ( StringData ) ( buf , AttachString ) ; <nl> - m_data . pstr - > incRefCount ( ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( buf , AttachString ) ) ; <nl> } <nl> <nl> String : : String ( int64 n ) { <nl> String : : String ( int64 n ) { <nl> <nl> buf = ( char * ) malloc ( len + 1 ) ; <nl> memcpy ( buf , p , len + 1 ) ; / / including the null terminator . <nl> - m_data . pstr = NEW ( StringData ) ( buf , AttachString ) ; <nl> - m_data . pstr - > incRefCount ( ) ; <nl> + m_px = NEW ( StringData ) ( buf , AttachString ) ; <nl> + m_px - > incRefCount ( ) ; <nl> } <nl> <nl> String : : String ( double n ) { <nl> char * buf ; <nl> if ( n = = 0 . 0 ) n = 0 . 0 ; / / so to avoid " - 0 " output <nl> vspprintf ( & buf , 0 , " % . * G " , 14 , n ) ; <nl> - m_data . pstr = NEW ( StringData ) ( buf , AttachString ) ; <nl> - m_data . pstr - > incRefCount ( ) ; <nl> + m_px = NEW ( StringData ) ( buf , AttachString ) ; <nl> + m_px - > incRefCount ( ) ; <nl> } <nl> <nl> void String : : assign ( const char * data , StringDataMode mode ) { <nl> if ( data ) { <nl> - setPtr ( NEW ( StringData ) ( data , mode ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( data , mode ) ) ; <nl> } else { <nl> reset ( ) ; <nl> } <nl> void String : : assign ( const char * data , StringDataMode mode ) { <nl> <nl> void String : : assign ( const char * data , int len , StringDataMode mode ) { <nl> if ( data ) { <nl> - setPtr ( NEW ( StringData ) ( data , len , mode ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( data , len , mode ) ) ; <nl> } else { <nl> reset ( ) ; <nl> } <nl> String String : : substr ( int start , int length / * = 0x7FFFFFFF * / ) const { <nl> int String : : find ( char ch , int pos / * = 0 * / , <nl> bool caseSensitive / * = true * / ) const { <nl> if ( empty ( ) ) return - 1 ; <nl> - return string_find ( m_data . pstr - > data ( ) , m_data . pstr - > size ( ) , ch , pos , <nl> - caseSensitive ) ; <nl> + return string_find ( m_px - > data ( ) , m_px - > size ( ) , ch , pos , caseSensitive ) ; <nl> } <nl> <nl> int String : : find ( const char * s , int pos / * = 0 * / , <nl> int String : : find ( const char * s , int pos / * = 0 * / , <nl> if ( * s & & * ( s + 1 ) = = 0 ) { <nl> return find ( * s , pos , caseSensitive ) ; <nl> } <nl> - return string_find ( m_data . pstr - > data ( ) , m_data . pstr - > size ( ) , s , strlen ( s ) , <nl> + return string_find ( m_px - > data ( ) , m_px - > size ( ) , s , strlen ( s ) , <nl> pos , caseSensitive ) ; <nl> } <nl> <nl> int String : : find ( CStrRef s , int pos / * = 0 * / , <nl> if ( s . size ( ) = = 1 ) { <nl> return find ( * s . data ( ) , pos , caseSensitive ) ; <nl> } <nl> - return string_find ( m_data . pstr - > data ( ) , m_data . pstr - > size ( ) , s . data ( ) , <nl> - s . size ( ) , pos , caseSensitive ) ; <nl> + return string_find ( m_px - > data ( ) , m_px - > size ( ) , s . data ( ) , s . size ( ) , <nl> + pos , caseSensitive ) ; <nl> } <nl> <nl> int String : : rfind ( char ch , int pos / * = - 1 * / , <nl> bool caseSensitive / * = true * / ) const { <nl> if ( empty ( ) ) return - 1 ; <nl> - return string_rfind ( m_data . pstr - > data ( ) , m_data . pstr - > size ( ) , ch , pos , <nl> - caseSensitive ) ; <nl> + return string_rfind ( m_px - > data ( ) , m_px - > size ( ) , ch , pos , caseSensitive ) ; <nl> } <nl> <nl> int String : : rfind ( const char * s , int pos / * = - 1 * / , <nl> int String : : rfind ( const char * s , int pos / * = - 1 * / , <nl> if ( * s & & * ( s + 1 ) = = 0 ) { <nl> return rfind ( * s , pos , caseSensitive ) ; <nl> } <nl> - return string_rfind ( m_data . pstr - > data ( ) , m_data . pstr - > size ( ) , s , strlen ( s ) , <nl> + return string_rfind ( m_px - > data ( ) , m_px - > size ( ) , s , strlen ( s ) , <nl> pos , caseSensitive ) ; <nl> } <nl> <nl> int String : : rfind ( CStrRef s , int pos / * = - 1 * / , <nl> if ( s . size ( ) = = 1 ) { <nl> return rfind ( * s . data ( ) , pos , caseSensitive ) ; <nl> } <nl> - return string_rfind ( m_data . pstr - > data ( ) , m_data . pstr - > size ( ) , s . data ( ) , <nl> - s . size ( ) , pos , caseSensitive ) ; <nl> + return string_rfind ( m_px - > data ( ) , m_px - > size ( ) , s . data ( ) , s . size ( ) , <nl> + pos , caseSensitive ) ; <nl> } <nl> <nl> String String : : replace ( int start , int length , CStrRef replacement ) const { <nl> String String : : replace ( CStrRef search , CStrRef replacement , int & count , <nl> bool caseSensitive ) const { <nl> count = 0 ; <nl> if ( ! search . empty ( ) & & ! empty ( ) ) { <nl> - int len = m_data . pstr - > size ( ) ; <nl> - char * ret = string_replace ( m_data . pstr - > data ( ) , len , search . data ( ) , <nl> - search . size ( ) , replacement . data ( ) , <nl> - replacement . size ( ) , count , caseSensitive ) ; <nl> + int len = m_px - > size ( ) ; <nl> + char * ret = string_replace ( m_px - > data ( ) , len , search . data ( ) , search . size ( ) , <nl> + replacement . data ( ) , replacement . size ( ) , count , <nl> + caseSensitive ) ; <nl> if ( ret ) { <nl> return String ( ret , len , AttachString ) ; <nl> } <nl> char String : : charAt ( int pos ) const { <nl> <nl> String & String : : operator = ( litstr s ) { <nl> if ( s ) { <nl> - setPtr ( NEW ( StringData ) ( s , AttachLiteral ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( s , AttachLiteral ) ) ; <nl> } else { <nl> reset ( ) ; <nl> } <nl> String & String : : operator = ( litstr s ) { <nl> } <nl> <nl> String & String : : operator = ( StringData * data ) { <nl> - set ( data ) ; <nl> + SmartPtr < StringData > : : operator = ( data ) ; <nl> return * this ; <nl> } <nl> <nl> String & String : : operator = ( CStrRef str ) { <nl> - set ( str . m_data . pstr ) ; <nl> + SmartPtr < StringData > : : operator = ( str . m_px ) ; <nl> return * this ; <nl> } <nl> <nl> String & String : : operator = ( CVarRef var ) { <nl> String & String : : operator + = ( litstr s ) { <nl> if ( s & & * s ) { <nl> if ( empty ( ) ) { <nl> - setPtr ( NEW ( StringData ) ( s , AttachLiteral ) ) ; <nl> - } else if ( m_data . pstr - > getCount ( ) = = 1 ) { <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( s , AttachLiteral ) ) ; <nl> + } else if ( m_px - > getCount ( ) = = 1 ) { <nl> int len = strlen ( s ) ; <nl> - m_data . pstr - > append ( s , len ) ; <nl> + m_px - > append ( s , len ) ; <nl> } else { <nl> int len ; <nl> char * ret = string_concat ( data ( ) , size ( ) , s , strlen ( s ) , len ) ; <nl> - setPtr ( NEW ( StringData ) ( ret , len , AttachString ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( ret , len , AttachString ) ) ; <nl> } <nl> } <nl> return * this ; <nl> String & String : : operator + = ( litstr s ) { <nl> String & String : : operator + = ( CStrRef str ) { <nl> if ( ! str . empty ( ) ) { <nl> if ( empty ( ) ) { <nl> - set ( str . m_data . pstr ) ; <nl> - } else if ( m_data . pstr - > getCount ( ) = = 1 ) { <nl> - m_data . pstr - > append ( str . data ( ) , str . size ( ) ) ; <nl> + SmartPtr < StringData > : : operator = ( str . m_px ) ; <nl> + } else if ( m_px - > getCount ( ) = = 1 ) { <nl> + m_px - > append ( str . data ( ) , str . size ( ) ) ; <nl> } else { <nl> int len ; <nl> char * ret = string_concat ( data ( ) , size ( ) , str . data ( ) , str . size ( ) , len ) ; <nl> - setPtr ( NEW ( StringData ) ( ret , len , AttachString ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( ret , len , AttachString ) ) ; <nl> } <nl> } <nl> return * this ; <nl> String String : : operator ~ ( ) const { <nl> } <nl> <nl> String String : : operator | ( CStrRef v ) const { <nl> - return String ( m_data . pstr ) . operator | = ( v ) ; <nl> + return String ( m_px ) . operator | = ( v ) ; <nl> } <nl> <nl> String String : : operator & ( CStrRef v ) const { <nl> - return String ( m_data . pstr ) . operator & = ( v ) ; <nl> + return String ( m_px ) . operator & = ( v ) ; <nl> } <nl> <nl> String String : : operator ^ ( CStrRef v ) const { <nl> - return String ( m_data . pstr ) . operator ^ = ( v ) ; <nl> + return String ( m_px ) . operator ^ = ( v ) ; <nl> } <nl> <nl> String & String : : operator | = ( CStrRef v ) { <nl> String & String : : operator | = ( CStrRef v ) { <nl> if ( len2 > len1 ) { <nl> copy = string_duplicate ( s2 , len2 ) ; <nl> for ( int i = 0 ; i < len1 ; i + + ) copy [ i ] | = s1 [ i ] ; <nl> - setPtr ( NEW ( StringData ) ( copy , len2 , AttachString ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( copy , len2 , AttachString ) ) ; <nl> } else { <nl> copy = string_duplicate ( s1 , len1 ) ; <nl> for ( int i = 0 ; i < len2 ; i + + ) copy [ i ] | = s2 [ i ] ; <nl> - setPtr ( NEW ( StringData ) ( copy , len1 , AttachString ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( copy , len1 , AttachString ) ) ; <nl> } <nl> return * this ; <nl> } <nl> String & String : : operator & = ( CStrRef v ) { <nl> if ( len2 < len1 ) { <nl> copy = string_duplicate ( s2 , len2 ) ; <nl> for ( int i = 0 ; i < len2 ; i + + ) copy [ i ] & = s1 [ i ] ; <nl> - setPtr ( NEW ( StringData ) ( copy , len2 , AttachString ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( copy , len2 , AttachString ) ) ; <nl> } else { <nl> copy = string_duplicate ( s1 , len1 ) ; <nl> for ( int i = 0 ; i < len1 ; i + + ) copy [ i ] & = s2 [ i ] ; <nl> - setPtr ( NEW ( StringData ) ( copy , len1 , AttachString ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( copy , len1 , AttachString ) ) ; <nl> } <nl> return * this ; <nl> } <nl> String & String : : operator ^ = ( CStrRef v ) { <nl> if ( len2 < len1 ) { <nl> copy = string_duplicate ( s2 , len2 ) ; <nl> for ( int i = 0 ; i < len2 ; i + + ) copy [ i ] ^ = s1 [ i ] ; <nl> - setPtr ( NEW ( StringData ) ( copy , len2 , AttachString ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( copy , len2 , AttachString ) ) ; <nl> } else { <nl> copy = string_duplicate ( s1 , len1 ) ; <nl> for ( int i = 0 ; i < len1 ; i + + ) copy [ i ] ^ = s2 [ i ] ; <nl> - setPtr ( NEW ( StringData ) ( copy , len1 , AttachString ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( copy , len1 , AttachString ) ) ; <nl> } <nl> return * this ; <nl> } <nl> String & String : : operator ^ = ( CStrRef v ) { <nl> / / conversions <nl> <nl> Variant String : : toKey ( ) const { <nl> - if ( ! m_data . pstr ) return * this ; <nl> - ASSERT ( m_data . pstr ) ; <nl> + if ( ! m_px ) return * this ; <nl> int64 n = 0 ; <nl> - if ( m_data . pstr - > isStrictlyInteger ( n ) ) { <nl> + if ( m_px - > isStrictlyInteger ( n ) ) { <nl> return n ; <nl> } else { <nl> return * this ; <nl> bool String : : same ( litstr v2 ) const { <nl> } <nl> <nl> bool String : : same ( CStrRef v2 ) const { <nl> - if ( m_data . pstr = = NULL & & v2 . m_data . pstr = = NULL ) return true ; <nl> - if ( m_data . pstr & & v2 . m_data . pstr ) return equal ( v2 ) ; <nl> + if ( m_px = = NULL & & v2 . get ( ) = = NULL ) return true ; <nl> + if ( m_px & & v2 . get ( ) ) return equal ( v2 ) ; <nl> return false ; <nl> } <nl> <nl> bool String : : equal ( litstr v2 ) const { <nl> <nl> bool String : : equal ( CStrRef v2 ) const { <nl> if ( size ( ) ! = v2 . size ( ) ) return false ; <nl> - if ( m_data . pstr = = NULL & & v2 . m_data . pstr = = NULL ) return true ; <nl> - if ( m_data . pstr = = NULL ) return v2 . empty ( ) ; <nl> - if ( v2 . m_data . pstr = = NULL ) return empty ( ) ; <nl> - return m_data . pstr - > compare ( v2 . get ( ) ) = = 0 ; <nl> + if ( m_px = = NULL & & v2 . get ( ) = = NULL ) return true ; <nl> + if ( m_px = = NULL ) return v2 . empty ( ) ; <nl> + if ( v2 . get ( ) = = NULL ) return empty ( ) ; <nl> + return m_px - > compare ( v2 . get ( ) ) = = 0 ; <nl> } <nl> <nl> bool String : : equal ( CArrRef v2 ) const { <nl> - if ( ! m_data . pstr | | ! v2 . get ( ) ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : equal ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> return false ; <nl> } <nl> <nl> bool String : : equal ( CObjRef v2 ) const { <nl> - if ( m_data . pstr = = NULL | | v2 . get ( ) = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : equal ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> if ( v2 . isResource ( ) ) <nl> bool String : : less ( litstr v2 ) const { <nl> } <nl> <nl> bool String : : less ( CStrRef v2 ) const { <nl> - if ( m_data . pstr = = NULL & & v2 . m_data . pstr = = NULL ) return false ; <nl> - if ( m_data . pstr = = NULL ) return ! v2 . empty ( ) ; <nl> - if ( v2 . m_data . pstr = = NULL ) return empty ( ) ; <nl> - return m_data . pstr - > compare ( v2 . get ( ) ) < 0 ; <nl> + if ( m_px = = NULL & & v2 . get ( ) = = NULL ) return false ; <nl> + if ( m_px = = NULL ) return ! v2 . empty ( ) ; <nl> + if ( v2 . get ( ) = = NULL ) return empty ( ) ; <nl> + return m_px - > compare ( v2 . get ( ) ) < 0 ; <nl> } <nl> <nl> bool String : : less ( CArrRef v2 ) const { <nl> - if ( m_data . pstr = = NULL | | v2 . get ( ) = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : less ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> return true ; <nl> } <nl> <nl> bool String : : less ( CObjRef v2 ) const { <nl> - if ( m_data . pstr = = NULL | | v2 . get ( ) = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : less ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> return true ; <nl> bool String : : more ( litstr v2 ) const { <nl> } <nl> <nl> bool String : : more ( CStrRef v2 ) const { <nl> - if ( m_data . pstr = = NULL & & v2 . m_data . pstr = = NULL ) return false ; <nl> - if ( m_data . pstr = = NULL ) return v2 . empty ( ) ; <nl> - if ( v2 . m_data . pstr = = NULL ) return ! empty ( ) ; <nl> - return m_data . pstr - > compare ( v2 . get ( ) ) > 0 ; <nl> + if ( m_px = = NULL & & v2 . get ( ) = = NULL ) return false ; <nl> + if ( m_px = = NULL ) return v2 . empty ( ) ; <nl> + if ( v2 . get ( ) = = NULL ) return ! empty ( ) ; <nl> + return m_px - > compare ( v2 . get ( ) ) > 0 ; <nl> } <nl> <nl> bool String : : more ( CArrRef v2 ) const { <nl> - if ( m_data . pstr = = NULL | | v2 . get ( ) = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : more ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> return false ; <nl> } <nl> <nl> bool String : : more ( CObjRef v2 ) const { <nl> - if ( m_data . pstr = = NULL | | v2 . get ( ) = = NULL ) { <nl> + if ( m_px = = NULL | | v2 . get ( ) = = NULL ) { <nl> return HPHP : : more ( toBoolean ( ) , v2 . toBoolean ( ) ) ; <nl> } <nl> return false ; <nl> bool String : : operator < ( CVarRef v ) const { <nl> / / input / output <nl> <nl> void String : : serialize ( VariableSerializer * serializer ) const { <nl> - if ( m_data . pstr ) { <nl> - serializer - > write ( m_data . pstr - > data ( ) , m_data . pstr - > size ( ) ) ; <nl> + if ( m_px ) { <nl> + serializer - > write ( m_px - > data ( ) , m_px - > size ( ) ) ; <nl> } else { <nl> serializer - > writeNull ( ) ; <nl> } <nl> void String : : unserialize ( std : : istream & in , <nl> char * buf = ( char * ) malloc ( size + 1 ) ; <nl> in . read ( buf , size ) ; <nl> buf [ size ] = ' \ 0 ' ; <nl> - setPtr ( NEW ( StringData ) ( buf , size , AttachString ) ) ; <nl> + SmartPtr < StringData > : : operator = ( NEW ( StringData ) ( buf , size , AttachString ) ) ; <nl> <nl> in > > ch ; <nl> if ( ch ! = delimiter1 ) { <nl> void String : : unserialize ( std : : istream & in , <nl> / / debugging <nl> <nl> void String : : dump ( ) { <nl> - if ( m_data . pstr ) { <nl> - m_data . pstr - > dump ( ) ; <nl> + if ( m_px ) { <nl> + m_px - > dump ( ) ; <nl> } else { <nl> printf ( " ( null ) \ n " ) ; <nl> } <nl> void String : : dump ( ) { <nl> <nl> StaticString : : StaticString ( litstr s ) : m_data ( s ) { <nl> String : : operator = ( & m_data ) ; <nl> - String : : m_data . pstr - > setStatic ( ) ; <nl> + m_px - > setStatic ( ) ; <nl> } <nl> <nl> StaticString : : StaticString ( litstr s , int length ) <nl> : m_data ( s , length , AttachLiteral ) { <nl> String : : operator = ( & m_data ) ; <nl> - String : : m_data . pstr - > setStatic ( ) ; <nl> + m_px - > setStatic ( ) ; <nl> } <nl> <nl> StaticString : : StaticString ( std : : string s ) : m_data ( s . c_str ( ) , s . size ( ) , <nl> CopyString ) { <nl> String : : operator = ( & m_data ) ; <nl> - String : : m_data . pstr - > setStatic ( ) ; <nl> + m_px - > setStatic ( ) ; <nl> } <nl> <nl> <nl> StaticString : : StaticString ( const StaticString & str ) <nl> : m_data ( str . m_data . data ( ) , str . m_data . size ( ) , AttachLiteral ) { <nl> String : : operator = ( & m_data ) ; <nl> - String : : m_data . pstr - > setStatic ( ) ; <nl> + m_px - > setStatic ( ) ; <nl> } <nl> <nl> StaticString & StaticString : : operator = ( litstr s ) { <nl> mmm a / src / runtime / base / type_string . h <nl> ppp b / src / runtime / base / type_string . h <nl> namespace HPHP { <nl> * String type wrapping around StringData to implement copy - on - write and <nl> * literal string handling ( to avoid string copying ) . <nl> * / <nl> - class String : protected Value { <nl> - public : <nl> - friend class Variant ; <nl> + class String : public SmartPtr < StringData > { <nl> + public : <nl> + / / create a string from a character <nl> + static String FromChar ( char ch ) ; <nl> <nl> - String ( ) { <nl> - m_data . pstr = NULL ; <nl> - } <nl> - ~ String ( ) { <nl> - if ( m_data . pstr & & m_data . pstr - > decRefCount ( ) = = 0 ) { <nl> - m_data . pstr - > release ( ) ; <nl> - } <nl> - } <nl> + public : <nl> + String ( ) { } <nl> <nl> static const String s_nullString ; <nl> <nl> / * * <nl> * Constructors <nl> * / <nl> - String ( StringData * data ) { <nl> - m_data . pstr = data ; <nl> - if ( m_data . pstr ) { <nl> - m_data . pstr - > incRefCount ( ) ; <nl> - } <nl> - } <nl> + String ( StringData * data ) : SmartPtr < StringData > ( data ) { } <nl> String ( int n ) ; <nl> String ( int64 n ) ; <nl> String ( double n ) ; <nl> - String ( litstr s ) { <nl> - m_data . pstr = NEW ( StringData ) ( s , AttachLiteral ) ; <nl> - m_data . pstr - > incRefCount ( ) ; <nl> - } <nl> - String ( CStrRef str ) { <nl> - m_data . pstr = str . m_data . pstr ; <nl> - if ( m_data . pstr ) { <nl> - m_data . pstr - > incRefCount ( ) ; <nl> - } <nl> - } <nl> - <nl> - String ( const std : : string & s ) { <nl> - / / always make a copy <nl> - m_data . pstr = NEW ( StringData ) ( s . data ( ) , s . size ( ) , CopyString ) ; <nl> - m_data . pstr - > incRefCount ( ) ; <nl> - } <nl> - String ( const char * s , StringDataMode mode ) { <nl> - / / null - terminated string <nl> - m_data . pstr = s ? NEW ( StringData ) ( s , mode ) : NULL ; <nl> - if ( m_data . pstr ) { <nl> - m_data . pstr - > incRefCount ( ) ; <nl> - } <nl> - } <nl> - String ( const char * s , int length , StringDataMode mode ) { <nl> - / / binary string <nl> - m_data . pstr = s ? NEW ( StringData ) ( s , length , mode ) : NULL ; <nl> - if ( m_data . pstr ) { <nl> - m_data . pstr - > incRefCount ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / create a string from a character <nl> - static String FromChar ( char ch ) ; <nl> - <nl> - bool isNull ( ) const { return m_data . pstr = = NULL ; } <nl> - <nl> - String & set ( StringData * px ) { <nl> - if ( m_data . pstr ! = px ) { <nl> - if ( m_data . pstr & & m_data . pstr - > decRefCount ( ) = = 0 ) { <nl> - m_data . pstr - > release ( ) ; <nl> - } <nl> - m_data . pstr = px ; <nl> - if ( m_data . pstr ) { <nl> - m_data . pstr - > incRefCount ( ) ; <nl> - } <nl> - } <nl> - return * this ; <nl> - } <nl> - <nl> - private : <nl> - String & setPtr ( StringData * px ) { <nl> - ASSERT ( m_data . pstr ! = px ) ; <nl> - ASSERT ( px ! = NULL ) ; <nl> - if ( m_data . pstr & & m_data . pstr - > decRefCount ( ) = = 0 ) { <nl> - m_data . pstr - > release ( ) ; <nl> - } <nl> - m_data . pstr = px ; <nl> - m_data . pstr - > incRefCount ( ) ; <nl> - return * this ; <nl> - } <nl> - <nl> - public : <nl> - String & set ( const String & src ) { <nl> - return set ( src . m_data . pstr ) ; <nl> - } <nl> - <nl> - void reset ( ) { <nl> - if ( m_data . pstr & & m_data . pstr - > decRefCount ( ) = = 0 ) { <nl> - m_data . pstr - > release ( ) ; <nl> - } <nl> - m_data . pstr = NULL ; <nl> - } <nl> - <nl> - / * * <nl> - * Magic delegation . <nl> - * / <nl> - StringData * operator - > ( ) const { <nl> - if ( ! m_data . pstr ) throw NullPointerException ( ) ; <nl> - return m_data . pstr ; <nl> - } <nl> - <nl> - / * * <nl> - * Get the raw pointer . <nl> - * / <nl> - StringData * get ( ) const { <nl> - return m_data . pstr ; <nl> - } <nl> + String ( litstr s ) <nl> + : SmartPtr < StringData > ( NEW ( StringData ) ( s , AttachLiteral ) ) { } <nl> + String ( CStrRef str ) : SmartPtr < StringData > ( str . m_px ) { } <nl> <nl> + String ( const std : : string & s ) / / always make a copy <nl> + : SmartPtr < StringData > ( NEW ( StringData ) ( s . data ( ) , s . size ( ) , CopyString ) ) { } <nl> + String ( const char * s , StringDataMode mode ) / / null - terminated string <nl> + : SmartPtr < StringData > ( s ? NEW ( StringData ) ( s , mode ) : NULL ) { } <nl> + String ( const char * s , int length , StringDataMode mode ) / / binary string <nl> + : SmartPtr < StringData > ( s ? NEW ( StringData ) ( s , length , mode ) : NULL ) { } <nl> <nl> void assign ( const char * data , StringDataMode mode ) ; <nl> void assign ( const char * data , int len , StringDataMode mode ) ; <nl> class String : protected Value { <nl> * Informational <nl> * / <nl> operator const char * ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > data ( ) : " " ; <nl> + return m_px ? m_px - > data ( ) : " " ; <nl> } <nl> const char * data ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > data ( ) : " " ; <nl> + return m_px ? m_px - > data ( ) : " " ; <nl> } <nl> const char * c_str ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > data ( ) : " " ; <nl> + return m_px ? m_px - > data ( ) : " " ; <nl> } <nl> bool empty ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > empty ( ) : true ; <nl> + return m_px ? m_px - > empty ( ) : true ; <nl> } <nl> int size ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > size ( ) : 0 ; <nl> + return m_px ? m_px - > size ( ) : 0 ; <nl> } <nl> int length ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > size ( ) : 0 ; <nl> + return m_px ? m_px - > size ( ) : 0 ; <nl> + } <nl> + bool isNull ( ) const { <nl> + return m_px = = NULL ; <nl> } <nl> bool isNumeric ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > isNumeric ( ) : false ; <nl> + return m_px ? m_px - > isNumeric ( ) : false ; <nl> } <nl> bool isInteger ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > isInteger ( ) : false ; <nl> + return m_px ? m_px - > isInteger ( ) : false ; <nl> } <nl> bool isZero ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > isZero ( ) : false ; <nl> + return m_px ? m_px - > isZero ( ) : false ; <nl> } <nl> <nl> bool isValidVariableName ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > isValidVariableName ( ) : false ; <nl> + return m_px ? m_px - > isValidVariableName ( ) : false ; <nl> } <nl> bool isLiteral ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > isLiteral ( ) : true ; <nl> + return m_px ? m_px - > isLiteral ( ) : true ; <nl> } <nl> <nl> / * * <nl> class String : protected Value { <nl> / * * <nl> * Type conversions <nl> * / <nl> - bool toBoolean ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > toBoolean ( ) : false ; <nl> - } <nl> - char toByte ( ) const { <nl> - return m_data . pstr ? m_data . pstr - > toByte ( ) : false ; <nl> - } <nl> - short toInt16 ( ) const { return m_data . pstr ? m_data . pstr - > toInt16 ( ) : 0 ; } <nl> - int toInt32 ( ) const { return m_data . pstr ? m_data . pstr - > toInt32 ( ) : 0 ; } <nl> - int64 toInt64 ( ) const { return m_data . pstr ? m_data . pstr - > toInt64 ( ) : 0 ; } <nl> - double toDouble ( ) const { return m_data . pstr ? m_data . pstr - > toDouble ( ) : 0 ; } <nl> + bool toBoolean ( ) const { return m_px ? m_px - > toBoolean ( ) : false ; } <nl> + char toByte ( ) const { return m_px ? m_px - > toByte ( ) : false ; } <nl> + short toInt16 ( ) const { return m_px ? m_px - > toInt16 ( ) : 0 ; } <nl> + int toInt32 ( ) const { return m_px ? m_px - > toInt32 ( ) : 0 ; } <nl> + int64 toInt64 ( ) const { return m_px ? m_px - > toInt64 ( ) : 0 ; } <nl> + double toDouble ( ) const { return m_px ? m_px - > toDouble ( ) : 0 ; } <nl> Variant toKey ( ) const ; <nl> <nl> / * * <nl> class String : protected Value { <nl> <nl> private : <nl> StringOffset lvalAtImpl ( int key ) { <nl> - setPtr ( NEW ( StringData ) ( data ( ) , size ( ) , CopyString ) ) ; <nl> - return StringOffset ( m_data . pstr , key ) ; <nl> + SmartPtr < StringData > : : operator = <nl> + ( NEW ( StringData ) ( data ( ) , size ( ) , CopyString ) ) ; <nl> + return StringOffset ( m_px , key ) ; <nl> } <nl> <nl> String rvalAtImpl ( int key ) const { <nl> - if ( m_data . pstr ) { <nl> - return m_data . pstr - > getChar ( key ) ; <nl> + if ( m_px ) { <nl> + return m_px - > getChar ( key ) ; <nl> } <nl> return String ( ) ; <nl> } <nl> + <nl> + static void compileTimeAssertions ( ) { <nl> + CT_ASSERT ( offsetof ( String , m_px ) = = offsetof ( Value , m_data ) ) ; <nl> + } <nl> } ; <nl> <nl> struct zend_hash { <nl> class StaticString : public String { <nl> StaticString ( std : : string s ) ; <nl> StaticString ( const StaticString & str ) ; <nl> ~ StaticString ( ) { <nl> - / / prevent ~ String from calling decRefCount after data is released <nl> - String : : m_data . pstr = NULL ; <nl> + / / prevent ~ SmartPtr from calling decRefCount after data is released <nl> + m_px = NULL ; <nl> } <nl> StaticString & operator = ( litstr v ) ; <nl> private : <nl> mmm a / src / runtime / base / type_variant . cpp <nl> ppp b / src / runtime / base / type_variant . cpp <nl> IMPLEMENT_SMART_ALLOCATION_NOCALLBACKS ( Variant ) ; <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / private implementations <nl> <nl> - Variant : : Variant ( CStrRef v ) { <nl> - _count = 0 ; <nl> + Variant : : Variant ( CStrRef v ) : _count ( 0 ) , m_type ( KindOfString ) { <nl> StringData * s = v . get ( ) ; <nl> if ( s ) { <nl> m_data . pstr = s ; <nl> - m_type = KindOfString ; <nl> s - > incRefCount ( ) ; <nl> } else { <nl> m_data . num = 0 ; <nl> Variant : : Variant ( CStrRef v ) { <nl> } <nl> } <nl> <nl> - Variant : : Variant ( CArrRef v ) { <nl> - _count = 0 ; <nl> + Variant : : Variant ( CArrRef v ) : _count ( 0 ) , m_type ( KindOfArray ) { <nl> ArrayData * a = v . get ( ) ; <nl> if ( a ) { <nl> m_data . parr = a ; <nl> - m_type = KindOfArray ; <nl> a - > incRefCount ( ) ; <nl> } else { <nl> m_data . num = 0 ; <nl> Variant : : Variant ( CArrRef v ) { <nl> } <nl> } <nl> <nl> - Variant : : Variant ( CObjRef v ) { <nl> - _count = 0 ; <nl> + Variant : : Variant ( CObjRef v ) : _count ( 0 ) , m_type ( KindOfObject ) { <nl> ObjectData * o = v . get ( ) ; <nl> if ( o ) { <nl> m_data . pobj = o ; <nl> - m_type = KindOfObject ; <nl> o - > incRefCount ( ) ; <nl> } else { <nl> m_data . num = 0 ; <nl> Variant : : Variant ( CObjRef v ) { <nl> } <nl> } <nl> <nl> - Variant : : Variant ( StringData * v ) { <nl> - _count = 0 ; <nl> + Variant : : Variant ( StringData * v ) : _count ( 0 ) , m_type ( KindOfString ) { <nl> if ( v ) { <nl> m_data . pstr = v ; <nl> - m_type = KindOfString ; <nl> v - > incRefCount ( ) ; <nl> } else { <nl> m_data . num = 0 ; <nl> Variant : : Variant ( StringData * v ) { <nl> } <nl> } <nl> <nl> - Variant : : Variant ( ArrayData * v ) { <nl> - _count = 0 ; <nl> + Variant : : Variant ( ArrayData * v ) : _count ( 0 ) , m_type ( KindOfArray ) { <nl> if ( v ) { <nl> m_data . parr = v ; <nl> - m_type = KindOfArray ; <nl> v - > incRefCount ( ) ; <nl> } else { <nl> m_data . num = 0 ; <nl> Variant : : Variant ( ArrayData * v ) { <nl> } <nl> } <nl> <nl> - Variant : : Variant ( ObjectData * v ) { <nl> - _count = 0 ; <nl> + Variant : : Variant ( ObjectData * v ) : _count ( 0 ) , m_type ( KindOfObject ) { <nl> if ( v ) { <nl> m_data . pobj = v ; <nl> - m_type = KindOfObject ; <nl> v - > incRefCount ( ) ; <nl> } else { <nl> m_data . num = 0 ; <nl> Variant : : Variant ( ObjectData * v ) { <nl> } <nl> } <nl> <nl> - Variant : : Variant ( Variant * v ) { <nl> - _count = 0 ; <nl> + Variant : : Variant ( Variant * v ) : _count ( 0 ) , m_type ( KindOfVariant ) { <nl> if ( v ) { <nl> m_data . pvar = v ; <nl> - m_type = KindOfVariant ; <nl> } else { <nl> m_data . num = 0 ; <nl> m_type = KindOfNull ; <nl> } <nl> } <nl> <nl> - Variant : : Variant ( CVarRef v ) { <nl> + Variant : : Variant ( CVarRef v ) : _count ( 0 ) , m_type ( KindOfNull ) { <nl> m_data . num = 0 ; <nl> - _count = 0 ; <nl> - m_type = KindOfNull ; <nl> if ( v . isContagious ( ) ) { <nl> assignContagious ( v ) ; <nl> return ; <nl> mmm a / src / runtime / base / type_variant . h <nl> ppp b / src / runtime / base / type_variant . h <nl> namespace HPHP { <nl> <nl> # define null ( Variant ( ) ) <nl> <nl> - class Variant : protected TypedValue { <nl> + class Variant { <nl> public : <nl> friend class Array ; <nl> <nl> class Variant : protected TypedValue { <nl> * / <nl> IMPLEMENT_COUNTABLE_METHODS_NO_STATIC <nl> <nl> - Variant ( ) { <nl> - m_data . num = 1 ; / / uninitialized <nl> - _count = 0 ; <nl> - m_type = KindOfNull ; <nl> + Variant ( ) : _count ( 0 ) , m_type ( KindOfNull ) { <nl> + / / uninitialized <nl> + m_data . num = 1 ; <nl> } <nl> <nl> void destruct ( ) ; <nl> class Variant : protected TypedValue { <nl> * operator overloads . <nl> * / <nl> Variant ( CVarRef v ) ; <nl> - Variant ( bool v ) { <nl> - m_data . num = ( v ? 1 : 0 ) ; <nl> - _count = 0 ; <nl> - m_type = KindOfBoolean ; <nl> - } <nl> - Variant ( char v ) { <nl> - m_data . num = v ; <nl> - _count = 0 ; <nl> - m_type = KindOfByte ; <nl> - } <nl> - Variant ( short v ) { <nl> - m_data . num = v ; <nl> - _count = 0 ; <nl> - m_type = KindOfInt16 ; <nl> - } <nl> - Variant ( int v ) { <nl> - m_data . num = v ; <nl> - _count = 0 ; <nl> - m_type = KindOfInt32 ; <nl> - } <nl> - Variant ( int64 v ) { <nl> - m_data . num = v ; <nl> - _count = 0 ; <nl> - m_type = KindOfInt64 ; <nl> - } <nl> - Variant ( uint64 v ) { <nl> - m_data . num = v ; <nl> - _count = 0 ; <nl> - m_type = KindOfInt64 ; <nl> - } <nl> - Variant ( ssize_t v ) { <nl> - m_data . num = v ; <nl> - _count = 0 ; <nl> - m_type = KindOfInt64 ; <nl> - } <nl> - Variant ( double v ) { <nl> - m_data . dbl = v ; <nl> - _count = 0 ; <nl> - m_type = KindOfDouble ; <nl> - } <nl> - Variant ( litstr v ) { <nl> - m_data . str = v ; <nl> - _count = 0 ; <nl> - m_type = LiteralString ; <nl> - } <nl> + Variant ( bool v ) : _count ( 0 ) , m_type ( KindOfBoolean ) { m_data . num = ( v ? 1 : 0 ) ; } <nl> + Variant ( char v ) : _count ( 0 ) , m_type ( KindOfByte ) { m_data . num = v ; } <nl> + Variant ( short v ) : _count ( 0 ) , m_type ( KindOfInt16 ) { m_data . num = v ; } <nl> + Variant ( int v ) : _count ( 0 ) , m_type ( KindOfInt32 ) { m_data . num = v ; } <nl> + Variant ( int64 v ) : _count ( 0 ) , m_type ( KindOfInt64 ) { m_data . num = v ; } <nl> + Variant ( uint64 v ) : _count ( 0 ) , m_type ( KindOfInt64 ) { m_data . num = v ; } <nl> + Variant ( ssize_t v ) : _count ( 0 ) , m_type ( KindOfInt64 ) { m_data . num = v ; } <nl> + Variant ( double v ) : _count ( 0 ) , m_type ( KindOfDouble ) { m_data . dbl = v ; } <nl> + Variant ( litstr v ) : _count ( 0 ) , m_type ( LiteralString ) { m_data . str = v ; } <nl> <nl> Variant ( CStrRef v ) ; <nl> Variant ( CArrRef v ) ; <nl> class Variant : protected TypedValue { <nl> Variant ( Variant * v ) ; <nl> <nl> template < typename T > <nl> - Variant ( const SmartObject < T > & v ) { <nl> - m_data . num = 0 ; <nl> - _count = 0 ; <nl> - m_type = KindOfNull ; <nl> + Variant ( const SmartObject < T > & v ) : _count ( 0 ) , m_type ( KindOfNull ) { <nl> set ( v ) ; <nl> } <nl> <nl> class Variant : protected TypedValue { <nl> * / <nl> const String & asCStrRef ( ) const { <nl> ASSERT ( m_type = = KindOfString ) ; <nl> - return * static_cast < const String * > ( static_cast < const Value * > ( this ) ) ; <nl> + return * ( const String * ) ( this ) ; <nl> } <nl> <nl> String & asStrRef ( ) { <nl> ASSERT ( m_type = = KindOfString ) ; <nl> - return * static_cast < String * > ( static_cast < Value * > ( this ) ) ; <nl> + return * ( String * ) ( this ) ; <nl> } <nl> <nl> const Array & asCArrRef ( ) const { <nl> ASSERT ( m_type = = KindOfArray ) ; <nl> - return * static_cast < const Array * > ( static_cast < const Value * > ( this ) ) ; <nl> + return * ( const Array * ) ( this ) ; <nl> } <nl> <nl> Array & asArrRef ( ) { <nl> ASSERT ( m_type = = KindOfArray ) ; <nl> - return * static_cast < Array * > ( static_cast < Value * > ( this ) ) ; <nl> + return * ( Array * ) ( this ) ; <nl> } <nl> <nl> const Object & asCObjRef ( ) const { <nl> ASSERT ( m_type = = KindOfObject ) ; <nl> - return * static_cast < const Object * > ( static_cast < const Value * > ( this ) ) ; <nl> + return * ( const Object * ) ( this ) ; <nl> } <nl> <nl> Object & asObjRef ( ) { <nl> ASSERT ( m_type = = KindOfObject ) ; <nl> - return * static_cast < Object * > ( static_cast < Value * > ( this ) ) ; <nl> + return * ( Object * ) ( this ) ; <nl> } <nl> <nl> / * * <nl> class Variant : protected TypedValue { <nl> * Borrowing Countable : : _count for contagious bit , and this is okay , since <nl> * outer Variant never uses reference counting . <nl> * / <nl> - void setContagious ( ) const { <nl> - _count = - 1 ; <nl> - } <nl> - void clearContagious ( ) const { <nl> - _count = 0 ; <nl> - } <nl> - bool isContagious ( ) const { return _count = = - 1 ; } <nl> + void setContagious ( ) const { _count = - 1 ; } <nl> + void clearContagious ( ) const { _count = 0 ; } <nl> + bool isContagious ( ) const { return _count = = - 1 ; } <nl> <nl> / * * <nl> * Whether or not there are at least two variables that are strongly bound . <nl> class Variant : protected TypedValue { <nl> CVarRef set ( CStrRef key , CVarRef v , int64 prehash = - 1 , <nl> bool isString = false ) ; <nl> CVarRef set ( CVarRef key , CVarRef v , int64 prehash = - 1 ) ; <nl> + <nl> CVarRef append ( CVarRef v ) ; <nl> <nl> template < typename T > <nl> class Variant : protected TypedValue { <nl> bool isStatic ( ) const { return _count = = ( 1 < < 30 ) ; } <nl> void setStatic ( ) const ; <nl> <nl> + / * * <nl> + * The order of the data members is significant . The _count field must <nl> + * be exactly FAST_REFCOUNT_OFFSET bytes from the beginning of the object . <nl> + * / <nl> + private : <nl> + mutable union { <nl> + int64 num ; <nl> + double dbl ; <nl> + litstr str ; <nl> + StringData * pstr ; <nl> + ArrayData * parr ; <nl> + ObjectData * pobj ; <nl> + Variant * pvar ; / / shared data between strongly bound Variants <nl> + } m_data ; <nl> + protected : <nl> + mutable int _count ; <nl> private : <nl> + mutable DataType m_type ; <nl> + <nl> bool isPrimitive ( ) const { return m_type < = LiteralString ; } <nl> <nl> CVarRef set ( bool v ) ; <nl> class Variant : protected TypedValue { <nl> <nl> Variant refvalAtImpl ( CStrRef key , int64 prehash = - 1 , bool isString = false ) ; <nl> <nl> - # ifdef FAST_REFCOUNT_FOR_VARIANT <nl> + <nl> private : <nl> static void compileTimeAssertions ( ) { <nl> - CT_ASSERT ( offsetof ( Variant , _count ) = = FAST_REFCOUNT_OFFSET ) ; <nl> - } <nl> + CT_ASSERT ( offsetof ( Variant , m_data ) = = offsetof ( TypedValue , m_data ) ) ; <nl> + CT_ASSERT ( offsetof ( Variant , _count ) = = offsetof ( TypedValue , _count ) ) ; <nl> + CT_ASSERT ( offsetof ( Variant , m_type ) = = offsetof ( TypedValue , m_type ) ) ; <nl> + # ifdef FAST_REFCOUNT_FOR_VARIANT <nl> + CT_ASSERT ( offsetof ( Variant , _count ) = = FAST_REFCOUNT_OFFSET ) ; <nl> # endif <nl> + } <nl> } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> inline Variant operator / ( CVarRef v , double n ) { return Variant ( v ) / = n ; } <nl> <nl> template < typename T > <nl> CVarRef Array : : setImpl ( const T & key , CVarRef v , int64 prehash ) { <nl> - if ( ! m_data . parr ) { <nl> + if ( ! m_px ) { <nl> ArrayData * data = ArrayData : : Create ( key , v ) ; <nl> - setPtr ( data ) ; <nl> + SmartPtr < ArrayData > : : operator = ( data ) ; <nl> } else { <nl> if ( v . isContagious ( ) ) { <nl> escalate ( ) ; <nl> } <nl> ArrayData * escalated = <nl> - m_data . parr - > set ( key , v , ( m_data . parr - > getCount ( ) > 1 ) , prehash ) ; <nl> + m_px - > set ( key , v , ( m_px - > getCount ( ) > 1 ) , prehash ) ; <nl> if ( escalated ) { <nl> - setPtr ( escalated ) ; <nl> + SmartPtr < ArrayData > : : operator = ( escalated ) ; <nl> } <nl> } <nl> return v ; <nl> | Change String , Array , and Object classes to derive from SmartPtr < T > | facebook/hhvm | e9d37f8a8b2d6d911c44b39a0bc847fb58d7c3a1 | 2010-05-25T00:17:25Z |
mmm a / cocos / base / CCConsole . cpp <nl> ppp b / cocos / base / CCConsole . cpp <nl> void Console : : commandTouch ( int fd , const std : : string & args ) <nl> } <nl> } <nl> <nl> + static char invalid_filename_char [ ] = { ' : ' , ' / ' , ' \ \ ' , ' ? ' , ' % ' , ' * ' , ' < ' , ' > ' , ' " ' , ' | ' , ' \ r ' , ' \ n ' , ' \ t ' } ; <nl> + <nl> void Console : : commandUpload ( int fd ) <nl> { <nl> ssize_t n , rc ; <nl> void Console : : commandUpload ( int fd ) <nl> { <nl> if ( ( rc = recv ( fd , & c , 1 , 0 ) ) = = 1 ) <nl> { <nl> - * ptr + + = c ; <nl> + for ( char x : invalid_filename_char ) <nl> + { <nl> + if ( c = = x ) <nl> + { <nl> + const char err [ ] = " upload : invalid file name ! \ n " ; <nl> + send ( fd , err , sizeof ( err ) , 0 ) ; <nl> + return ; <nl> + } <nl> + } <nl> if ( c = = ' ' ) <nl> { <nl> break ; <nl> } <nl> + * ptr + + = c ; <nl> } <nl> else if ( rc = = 0 ) <nl> { <nl> bool Console : : parseCommand ( int fd ) <nl> } <nl> else <nl> { <nl> - const char err [ ] = " Unknown Command ! \ n " ; <nl> - sendPrompt ( fd ) ; <nl> + const char err [ ] = " upload : invalid args ! Type ' help ' for options \ n " ; <nl> send ( fd , err , sizeof ( err ) , 0 ) ; <nl> - return false ; <nl> + sendPrompt ( fd ) ; <nl> + return true ; <nl> <nl> } <nl> } <nl> bool Console : : parseCommand ( int fd ) <nl> const char err [ ] = " Unknown command . Type ' help ' for options \ n " ; <nl> send ( fd , err , sizeof ( err ) , 0 ) ; <nl> sendPrompt ( fd ) ; <nl> - return false ; <nl> + return true ; <nl> } <nl> <nl> auto it = _commands . find ( trim ( args [ 0 ] ) ) ; <nl> | Merge pull request from heliclei / fix - console - upload | cocos2d/cocos2d-x | 6208943cb1dd95b4a039f0e504d3476d76dfca25 | 2014-04-08T09:55:15Z |
mmm a / csharp / src / ProtocolBuffersLite . Test / TestProtos / UnittestImportPublicLite . cs <nl> ppp b / csharp / src / ProtocolBuffersLite . Test / TestProtos / UnittestImportPublicLite . cs <nl> public sealed partial class PublicImportMessageLite : pb : : GeneratedMessageLite < P <nl> # region Lite runtime methods <nl> public override int GetHashCode ( ) { <nl> int hash = GetType ( ) . GetHashCode ( ) ; <nl> - if ( hasE ) hash ^ = e_ . GetHashCode ( ) ; <nl> + if ( hasE ) { <nl> + hash ^ = e_ . GetHashCode ( ) ; <nl> + } <nl> return hash ; <nl> } <nl> <nl> | regenerated UnittestImportPublicLite | protocolbuffers/protobuf | 4083104aa4862e22aa5addbfaaa3a49ebbd2c4a0 | 2015-05-13T04:58:59Z |
mmm a / Examples / Evaluation / CNTKLibraryCSEvalCPUOnlyExamples / CNTKLibraryCSEvalExamples . cs <nl> ppp b / Examples / Evaluation / CNTKLibraryCSEvalCPUOnlyExamples / CNTKLibraryCSEvalExamples . cs <nl> public static void EvaluationSingleSequenceUsingSparse ( DeviceDescriptor device ) <nl> <nl> / / Get the index of each word in the sentence . <nl> string [ ] inputWords = inputSentence . Split ( ' ' ) ; <nl> - var seqLen = ( uint ) inputWords . Length ; <nl> + var seqLen = inputWords . Length ; <nl> / / For this example , only 1 non - zero value for each sample . <nl> var numNonZeroValues = seqLen * 1 ; <nl> var colStarts = new int [ seqLen + 1 ] ; <nl> public static void EvaluationSingleSequenceUsingSparse ( DeviceDescriptor device ) <nl> rowIndices [ count ] = nonZeroValueIndex ; <nl> colStarts [ count ] = count ; <nl> } <nl> - colStarts [ count ] = ( int ) numNonZeroValues ; <nl> + colStarts [ count ] = numNonZeroValues ; <nl> <nl> / / Create input value using OneHot vector data . <nl> - var inputValue = Value . CreateSequence < float > ( vocabSize , seqLen , colStarts , rowIndices , nonZeroValues , numNonZeroValues , device ) ; <nl> + var inputValue = Value . CreateSequence < float > ( vocabSize , seqLen , colStarts , rowIndices , nonZeroValues , device ) ; <nl> <nl> / / Build input data map . <nl> var inputDataMap = new Dictionary < Variable , Value > ( ) ; <nl> mmm a / bindings / csharp / Swig / cntk_cs . i <nl> ppp b / bindings / csharp / Swig / cntk_cs . i <nl> SWIG_STD_VECTOR_ENHANCED ( CNTK : : DeviceDescriptor ) <nl> } <nl> } <nl> <nl> - public uint MaskedCount <nl> + public int MaskedCount <nl> { <nl> get <nl> { <nl> - return _MaskedCount ( ) ; <nl> + return ( int ) _MaskedCount ( ) ; <nl> } <nl> } <nl> <nl> SWIG_STD_VECTOR_ENHANCED ( CNTK : : DeviceDescriptor ) <nl> } <nl> <nl> / / Create Value object from sparse input , for N - dimensional tensor . Only CreateSequence ( ) for now . <nl> - public static Value CreateSequence < T > ( NDShape sampleShape , uint sequenceLength , <nl> - int [ ] colStarts , int [ ] rowIndices , T [ ] nonZeroValues , uint numNonZeroValues , <nl> + public static Value CreateSequence < T > ( NDShape sampleShape , int sequenceLength , <nl> + int [ ] colStarts , int [ ] rowIndices , T [ ] nonZeroValues , <nl> bool sequenceStartFlag , <nl> DeviceDescriptor device , <nl> bool readOnly = false ) <nl> { <nl> + if ( nonZeroValues . Length ! = rowIndices . Length ) <nl> + { <nl> + throw new System . ArgumentException ( " The length of rowIndicies must be same as the length of nonZeroValues . " ) ; <nl> + } <nl> + if ( colStarts . Length ! = sequenceLength + 1 ) <nl> + { <nl> + throw new System . ArgumentException ( " The length of colStarts must be equal to ( sequenceLength + 1 ) " ) ; <nl> + } <nl> + uint numNonZeroValues = ( uint ) nonZeroValues . Length ; <nl> + <nl> if ( typeof ( T ) . Equals ( typeof ( float ) ) ) <nl> { <nl> - return Value . CreateSequenceFloat ( sampleShape , sequenceLength , colStarts , rowIndices , nonZeroValues as float [ ] , numNonZeroValues , sequenceStartFlag , device , readOnly ) ; <nl> + return Value . CreateSequenceFloat ( sampleShape , ( uint ) sequenceLength , colStarts , rowIndices , nonZeroValues as float [ ] , numNonZeroValues , sequenceStartFlag , device , readOnly ) ; <nl> } <nl> else if ( typeof ( T ) . Equals ( typeof ( double ) ) ) <nl> { <nl> - return Value . CreateSequenceDouble ( sampleShape , sequenceLength , colStarts , rowIndices , nonZeroValues as double [ ] , numNonZeroValues , sequenceStartFlag , device , readOnly ) ; <nl> + return Value . CreateSequenceDouble ( sampleShape , ( uint ) sequenceLength , colStarts , rowIndices , nonZeroValues as double [ ] , numNonZeroValues , sequenceStartFlag , device , readOnly ) ; <nl> } <nl> else <nl> { <nl> SWIG_STD_VECTOR_ENHANCED ( CNTK : : DeviceDescriptor ) <nl> } <nl> } <nl> <nl> - public static Value CreateSequence < T > ( NDShape sampleShape , uint sequenceLength , <nl> - int [ ] colStarts , int [ ] rowIndices , T [ ] nonZeroValues , uint numNonZeroValues , <nl> + public static Value CreateSequence < T > ( NDShape sampleShape , int sequenceLength , <nl> + int [ ] colStarts , int [ ] rowIndices , T [ ] nonZeroValues , <nl> DeviceDescriptor device , <nl> bool readOnly = false ) <nl> { <nl> - return Value . CreateSequence < T > ( sampleShape , sequenceLength , colStarts , rowIndices , nonZeroValues , numNonZeroValues , true , device , readOnly ) ; <nl> + return Value . CreateSequence < T > ( sampleShape , sequenceLength , colStarts , rowIndices , nonZeroValues , true , device , readOnly ) ; <nl> } <nl> <nl> / / Create Value object from sparse input , for 1D tensor . Only CreateSequence ( ) for now . <nl> - public static Value CreateSequence < T > ( uint dimension , uint sequenceLength , <nl> - int [ ] colStarts , int [ ] rowIndices , T [ ] nonZeroValues , uint numNonZeroValues , <nl> + public static Value CreateSequence < T > ( uint dimension , int sequenceLength , <nl> + int [ ] colStarts , int [ ] rowIndices , T [ ] nonZeroValues , <nl> bool sequenceStartFlag , <nl> DeviceDescriptor device , <nl> bool readOnly = false ) <nl> { <nl> + if ( nonZeroValues . Length ! = rowIndices . Length ) <nl> + { <nl> + throw new System . ArgumentException ( " The length of rowIndicies must be same as the length of nonZeroValues . " ) ; <nl> + } <nl> + if ( colStarts . Length ! = sequenceLength + 1 ) <nl> + { <nl> + throw new System . ArgumentException ( " The length of colStarts must be equal to ( sequenceLength + 1 ) " ) ; <nl> + } <nl> + uint numNonZeroValues = ( uint ) nonZeroValues . Length ; <nl> + <nl> if ( typeof ( T ) . Equals ( typeof ( float ) ) ) <nl> { <nl> - return Value . CreateSequenceFloat ( dimension , sequenceLength , colStarts , rowIndices , nonZeroValues as float [ ] , numNonZeroValues , sequenceStartFlag , device , readOnly ) ; <nl> + return Value . CreateSequenceFloat ( dimension , ( uint ) sequenceLength , colStarts , rowIndices , nonZeroValues as float [ ] , numNonZeroValues , sequenceStartFlag , device , readOnly ) ; <nl> } <nl> else if ( typeof ( T ) . Equals ( typeof ( double ) ) ) <nl> { <nl> - return Value . CreateSequenceDouble ( dimension , sequenceLength , colStarts , rowIndices , nonZeroValues as double [ ] , numNonZeroValues , sequenceStartFlag , device , readOnly ) ; <nl> + return Value . CreateSequenceDouble ( dimension , ( uint ) sequenceLength , colStarts , rowIndices , nonZeroValues as double [ ] , numNonZeroValues , sequenceStartFlag , device , readOnly ) ; <nl> } <nl> else <nl> { <nl> SWIG_STD_VECTOR_ENHANCED ( CNTK : : DeviceDescriptor ) <nl> } <nl> } <nl> <nl> - public static Value CreateSequence < T > ( uint dimension , uint sequenceLength , <nl> - int [ ] colStarts , int [ ] rowIndices , T [ ] nonZeroValues , uint numNonZeroValues , <nl> + public static Value CreateSequence < T > ( uint dimension , int sequenceLength , <nl> + int [ ] colStarts , int [ ] rowIndices , T [ ] nonZeroValues , <nl> DeviceDescriptor device , <nl> bool readOnly = false ) <nl> { <nl> - return Value . CreateSequence < T > ( dimension , sequenceLength , colStarts , rowIndices , nonZeroValues , numNonZeroValues , true , device , readOnly ) ; <nl> + return Value . CreateSequence < T > ( dimension , sequenceLength , colStarts , rowIndices , nonZeroValues , true , device , readOnly ) ; <nl> } <nl> <nl> / / Create value object from NDArrayView <nl> | remove numNonZeroValues from CreateSequence ; use int instead of uint if possible | microsoft/CNTK | ba4500a292e0af92c455fb7cde5c25b925d0e172 | 2017-03-27T07:42:43Z |
mmm a / platform / osx / os_osx . mm <nl> ppp b / platform / osx / os_osx . mm <nl> - ( BOOL ) canBecomeKeyWindow <nl> <nl> void OS_OSX : : warp_mouse_pos ( const Point2 & p_to ) { <nl> <nl> - / / not done , must be done <nl> + / / copied from windows impl with osx native calls <nl> + if ( mouse_mode = = MOUSE_MODE_CAPTURED ) { <nl> + mouse_x = p_to . x ; <nl> + mouse_y = p_to . y ; <nl> + } <nl> + else { / / set OS position <nl> + CGPoint lMouseWarpPos = { p_to . x , p_to . y } ; <nl> + <nl> + CGEventSourceRef lEventRef = CGEventSourceCreate ( kCGEventSourceStateCombinedSessionState ) ; <nl> + CGEventSourceSetLocalEventsSuppressionInterval ( lEventRef , 0 . 0 ) ; <nl> + CGAssociateMouseAndMouseCursorPosition ( false ) ; <nl> + CGWarpMouseCursorPosition ( lMouseWarpPos ) ; <nl> + CGAssociateMouseAndMouseCursorPosition ( true ) ; <nl> + } <nl> } <nl> <nl> Point2 OS_OSX : : get_mouse_pos ( ) const { <nl> | warp_mouse_pos for osx | godotengine/godot | 72558b617332a7e9499f4d40ba782f99a1789ead | 2014-09-25T18:48:38Z |
mmm a / include / swift / Driver / ExperimentalDependencyDriverGraph . h <nl> ppp b / include / swift / Driver / ExperimentalDependencyDriverGraph . h <nl> class ModuleDepGraph { <nl> emitExperimentalDependencyDotFileAfterEveryImport ) , <nl> currentPathIfTracing ( <nl> shouldTraceDependencies <nl> - ? llvm : : Optional < std : : vector < const ModuleDepGraphNode * > > ( std : : vector < const ModuleDepGraphNode * > ( ) ) <nl> + ? llvm : : Optional < std : : vector < const ModuleDepGraphNode * > > ( <nl> + std : : vector < const ModuleDepGraphNode * > ( ) ) <nl> : None ) , <nl> stats ( stats ) { <nl> assert ( verify ( ) & & " ModuleDepGraph should be fine when created " ) ; <nl> mmm a / lib / Driver / ExperimentalDependencyDriverGraph . cpp <nl> ppp b / lib / Driver / ExperimentalDependencyDriverGraph . cpp <nl> void ModuleDepGraph : : checkTransitiveClosureForCascading ( <nl> } ) ; <nl> if ( currentPathIfTracing . hasValue ( ) ) <nl> currentPathIfTracing - > pop_back ( ) ; <nl> - <nl> - size_t finalPathLength = <nl> - currentPathIfTracing . hasValue ( ) ? currentPathIfTracing - > size ( ) : 0 ; <nl> + <nl> + size_t finalPathLength = <nl> + currentPathIfTracing . hasValue ( ) ? currentPathIfTracing - > size ( ) : 0 ; <nl> assert ( initialPathLength = = finalPathLength & & " Should preserve path length " ) ; <nl> } <nl> <nl> bool ModuleDepGraph : : emitAndVerify ( DiagnosticEngine & diags ) { <nl> / / / Dump the path that led to \ p node . <nl> void ModuleDepGraph : : printPath ( raw_ostream & out , <nl> const driver : : Job * jobToBeBuilt ) const { <nl> - assert ( currentPathIfTracing . hasValue ( ) & & " Cannot print paths of paths weren ' t tracked . " ) ; <nl> + assert ( currentPathIfTracing . hasValue ( ) & & <nl> + " Cannot print paths of paths weren ' t tracked . " ) ; <nl> auto const swiftDepsToBeBuilt = getSwiftDeps ( jobToBeBuilt ) ; <nl> <nl> std : : for_each ( <nl> | Format | apple/swift | 89f77175d06750eccd7555d2fa66431eae6b60c0 | 2019-01-27T17:15:25Z |
mmm a / src / Storages / MergeTree / MergeTreeData . cpp <nl> ppp b / src / Storages / MergeTree / MergeTreeData . cpp <nl> bool isMetadataOnlyConversion ( const IDataType * from , const IDataType * to ) <nl> void MergeTreeData : : checkAlterIsPossible ( const AlterCommands & commands , const Settings & settings ) <nl> { <nl> / / / Check that needed transformations can be applied to the list of columns without considering type conversions . <nl> - StorageInMemoryMetadata metadata = getInMemoryMetadata ( ) ; <nl> - commands . apply ( metadata , global_context ) ; <nl> - if ( getSecondaryIndices ( ) . empty ( ) & & ! metadata . secondary_indices . empty ( ) & & <nl> + StorageInMemoryMetadata new_metadata = getInMemoryMetadata ( ) ; <nl> + commands . apply ( new_metadata , global_context ) ; <nl> + if ( getSecondaryIndices ( ) . empty ( ) & & ! new_metadata . secondary_indices . empty ( ) & & <nl> ! settings . allow_experimental_data_skipping_indices ) <nl> throw Exception ( " You must set the setting ` allow_experimental_data_skipping_indices ` to 1 " \ <nl> " before using data skipping indices . " , ErrorCodes : : BAD_ARGUMENTS ) ; <nl> void MergeTreeData : : checkAlterIsPossible ( const AlterCommands & commands , const S <nl> } <nl> } <nl> <nl> - setProperties ( metadata , / * only_check = * / true ) ; <nl> + setProperties ( new_metadata , / * only_check = * / true ) ; <nl> <nl> - setTTLExpressions ( metadata . columns , metadata . table_ttl , / * only_check = * / true ) ; <nl> + setTTLExpressions ( new_metadata . columns , new_metadata . table_ttl , / * only_check = * / true ) ; <nl> <nl> if ( hasSettingsChanges ( ) ) <nl> { <nl> <nl> const auto & current_changes = getSettingsChanges ( ) - > as < const ASTSetQuery & > ( ) . changes ; <nl> - const auto & new_changes = metadata . settings_changes - > as < const ASTSetQuery & > ( ) . changes ; <nl> + const auto & new_changes = new_metadata . settings_changes - > as < const ASTSetQuery & > ( ) . changes ; <nl> for ( const auto & changed_setting : new_changes ) <nl> { <nl> if ( MergeTreeSettings : : findIndex ( changed_setting . name ) = = MergeTreeSettings : : npos ) <nl> mmm a / src / Storages / StorageMaterializedView . cpp <nl> ppp b / src / Storages / StorageMaterializedView . cpp <nl> void StorageMaterializedView : : alter ( <nl> { <nl> lockStructureExclusively ( table_lock_holder , context . getCurrentQueryId ( ) , context . getSettingsRef ( ) . lock_acquire_timeout ) ; <nl> auto table_id = getStorageID ( ) ; <nl> - StorageInMemoryMetadata metadata = getInMemoryMetadata ( ) ; <nl> - params . apply ( metadata , context ) ; <nl> + StorageInMemoryMetadata new_metadata = getInMemoryMetadata ( ) ; <nl> + params . apply ( new_metadata , context ) ; <nl> <nl> / / / start modify query <nl> if ( context . getSettingsRef ( ) . allow_experimental_alter_materialized_view_structure ) <nl> { <nl> - const auto & new_select = metadata . select ; <nl> + const auto & new_select = new_metadata . select ; <nl> const auto & old_select = getSelectQuery ( ) ; <nl> <nl> DatabaseCatalog : : instance ( ) . updateDependency ( old_select . select_table_id , table_id , new_select . select_table_id , table_id ) ; <nl> void StorageMaterializedView : : alter ( <nl> } <nl> / / / end modify query <nl> <nl> - DatabaseCatalog : : instance ( ) . getDatabase ( table_id . database_name ) - > alterTable ( context , table_id , metadata ) ; <nl> - setColumns ( std : : move ( metadata . columns ) ) ; <nl> + DatabaseCatalog : : instance ( ) . getDatabase ( table_id . database_name ) - > alterTable ( context , table_id , new_metadata ) ; <nl> + setColumns ( std : : move ( new_metadata . columns ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / Storages / StorageReplicatedMergeTree . cpp <nl> ppp b / src / Storages / StorageReplicatedMergeTree . cpp <nl> void StorageReplicatedMergeTree : : createTableIfNotExists ( ) <nl> zookeeper - > createAncestors ( zookeeper_path ) ; <nl> <nl> / / / We write metadata of table so that the replicas can check table parameters with them . <nl> - String metadata = ReplicatedMergeTreeTableMetadata ( * this ) . toString ( ) ; <nl> + String metadata_str = ReplicatedMergeTreeTableMetadata ( * this ) . toString ( ) ; <nl> <nl> Coordination : : Requests ops ; <nl> ops . emplace_back ( zkutil : : makeCreateRequest ( zookeeper_path , " " , <nl> zkutil : : CreateMode : : Persistent ) ) ; <nl> - ops . emplace_back ( zkutil : : makeCreateRequest ( zookeeper_path + " / metadata " , metadata , <nl> + ops . emplace_back ( zkutil : : makeCreateRequest ( zookeeper_path + " / metadata " , metadata_str , <nl> zkutil : : CreateMode : : Persistent ) ) ; <nl> ops . emplace_back ( zkutil : : makeCreateRequest ( zookeeper_path + " / columns " , getColumns ( ) . toString ( ) , <nl> zkutil : : CreateMode : : Persistent ) ) ; <nl> | Gcc fixed | ClickHouse/ClickHouse | 75977bd939887daa55f320951b431f4392a0acb6 | 2020-06-09T21:22:01Z |
mmm a / tensorflow / compiler / xla / service / gpu / ir_emitter_unnested . cc <nl> ppp b / tensorflow / compiler / xla / service / gpu / ir_emitter_unnested . cc <nl> bool MayPreventVectorization ( const HloInstruction & hlo ) { <nl> return false ; <nl> } <nl> } else if ( hlo . opcode ( ) = = HloOpcode : : kReduce ) { <nl> - / / TODO : check if the to_apply ( ) attribute contain instruction <nl> + / / TODO : check if the to_apply ( ) attribute contains instruction <nl> / / that break LLVM vectorization . <nl> return false ; <nl> } <nl> static llvm : : Value * GetStartOffsetX ( const KernelMappingScheme & mapping_scheme , <nl> return b - > CreateMul ( thread_id_x , constant ( x_num_steps ) ) ; <nl> } <nl> <nl> - / / This function calls emit_elem_function ( ) x_num_steps times . If <nl> - / / vector_size = = 1 , then each element index passed to <nl> - / / emit_elem_function ( ) will be separated by step_x . If vector_size > 1 , <nl> - / / then it must be a multiple of x_num_steps . In that case , it <nl> + / / Calls ` emit_elem_function ( ) ` ` x_num_steps ` times . If <nl> + / / ` vector_size ` = = 1 , then each element index passed to <nl> + / / ` emit_elem_function ( ) ` will be separated by ` step_x ` . If ` vector_size ` > 1 , <nl> + / / then it must be a multiple of ` x_num_steps ` . In that case , it <nl> / / triggers a different indexing order that is vectorizable by <nl> - / / LLVM . It generates many groups of calls to emit_elem_function . Each <nl> - / / group is separated by step_x elements . Inside a group , elements <nl> - / / are consecutive . If check_x_tile_bounds is true , then it will check <nl> - / / if the element index is in bound compared to tile_width before <nl> - / / calling emit_elem_function . <nl> - static void Unroll ( <nl> + / / LLVM . It generates many groups of calls to ` emit_elem_function ` . Each <nl> + / / group is separated by ` step_x ` elements . Inside a group , elements <nl> + / / are consecutive . If ` check_x_tile_bounds ` is true , then it will check <nl> + / / if the element index is in bound compared to ` tile_width ` before <nl> + / / calling ` emit_elem_function ` . <nl> + static void UnrollInnerTileLoop ( <nl> bool check_x_tile_bounds , int64 x_num_steps , int64 step_x , <nl> int64 vector_size , const string & loop_name , KernelSupportLibrary * ksl , <nl> llvm : : Value * start_offset_x , llvm : : Value * y_loc , llvm : : Value * tile_width , <nl> void IrEmitterUnnested : : EmitTile ( <nl> / / <nl> / / TODO ( cheshire ) : Once ptxas is fixed and TF switches to it , remove the <nl> / / workaround . <nl> - ksl - > For ( loop_name + " _y_in_tile " , <nl> - / * start = * / constant ( 0 ) , <nl> - / * end = * / <nl> - ceil_of_ratio ( b_ . CreateSub ( tile_height , thread_id_info . thread_id_y ) , <nl> - num_threads_y ) , <nl> - / * step = * / constant ( 1 ) , [ & ] ( llvm : : Value * y_indvar ) { <nl> - llvm : : Value * y_loc = <nl> - b_ . CreateAdd ( thread_id_info . thread_id_y , <nl> - b_ . CreateMul ( y_indvar , num_threads_y ) ) ; <nl> - auto unroll = [ & ] ( bool check_x_tile_bounds ) { <nl> - return Unroll ( check_x_tile_bounds , x_num_steps , step_x , <nl> - vector_size , loop_name , ksl , start_offset_x , y_loc , <nl> - tile_width , source_idx , b_ , & emit_elem_function ) ; <nl> - } ; <nl> - <nl> - / / Only take this path when we unroll in a way vectorizable by <nl> - / / LLVM . Special case when the tile doesn ' t fit completely for even <nl> - / / row size . For odd row size every other row isn ' t aligned to the <nl> - / / vectorized size , so it can ' t be vectorized by LLVM . <nl> - if ( ! x_tile_fits & & <nl> - mapping_scheme . GetIndexingOrder ( ) = = kLinearStridedIndexingX ) { <nl> - ksl - > If ( loop_name + " _is_full_tile " , <nl> - / / For the last block , tile_width will be the number of <nl> - / / elements left . <nl> - b_ . CreateICmpEQ ( constant ( mapping_scheme . GetTileSizeX ( ) ) , <nl> - tile_width ) , <nl> - [ & ] { unroll ( / * check_x_tile_bounds = * / false ) ; } , <nl> - [ & ] { unroll ( / * check_x_tile_bounds = * / true ) ; } ) ; <nl> - } else { <nl> - unroll ( / * check_x_tile_bounds = * / ! x_tile_fits ) ; <nl> - } <nl> - } ) ; <nl> + ksl - > For ( <nl> + loop_name + " _y_in_tile " , <nl> + / * start = * / constant ( 0 ) , <nl> + / * end = * / <nl> + ceil_of_ratio ( b_ . CreateSub ( tile_height , thread_id_info . thread_id_y ) , <nl> + num_threads_y ) , <nl> + / * step = * / constant ( 1 ) , [ & ] ( llvm : : Value * y_indvar ) { <nl> + llvm : : Value * y_loc = b_ . CreateAdd ( <nl> + thread_id_info . thread_id_y , b_ . CreateMul ( y_indvar , num_threads_y ) ) ; <nl> + auto unrollInnerTileLoop = [ & ] ( bool check_x_tile_bounds ) { <nl> + return UnrollInnerTileLoop ( check_x_tile_bounds , x_num_steps , step_x , <nl> + vector_size , loop_name , ksl , <nl> + start_offset_x , y_loc , tile_width , <nl> + source_idx , b_ , & emit_elem_function ) ; <nl> + } ; <nl> + <nl> + / / Only take this path when we unroll in a way vectorizable by <nl> + / / LLVM . Special case when the tile doesn ' t fit completely for even <nl> + / / row size . For odd row size every other row isn ' t aligned to the <nl> + / / vectorized size , so it can ' t be vectorized by LLVM . <nl> + if ( ! x_tile_fits & & <nl> + mapping_scheme . GetIndexingOrder ( ) = = kLinearStridedIndexingX ) { <nl> + ksl - > If ( loop_name + " _is_full_tile " , <nl> + / / For the last block , tile_width will be the number of <nl> + / / elements left . <nl> + b_ . CreateICmpEQ ( constant ( mapping_scheme . GetTileSizeX ( ) ) , <nl> + tile_width ) , <nl> + [ & ] { unrollInnerTileLoop ( / * check_x_tile_bounds = * / false ) ; } , <nl> + [ & ] { unrollInnerTileLoop ( / * check_x_tile_bounds = * / true ) ; } ) ; <nl> + } else { <nl> + unrollInnerTileLoop ( / * check_x_tile_bounds = * / ! x_tile_fits ) ; <nl> + } <nl> + } ) ; <nl> } <nl> <nl> / / Emits code to process a tensor element in a tile for the given kCopy HLO that <nl> | NFC following code review . comment typo and rename unroll to unrollInnerTileLoop . | tensorflow/tensorflow | a13b9d4d58e311729de3a967d8c780a95f6691ae | 2020-04-01T17:01:49Z |
new file mode 100644 <nl> index 00000000000 . . dbcf5219c75 <nl> mmm / dev / null <nl> ppp b / ports / antlr4 / CONTROL <nl> <nl> + Source : antlr4 <nl> + Version : 4 . 6 <nl> + Description : ANother Tool for Language Recognition <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . d2e8a28dab0 <nl> mmm / dev / null <nl> ppp b / ports / antlr4 / crt_mt . patch <nl> <nl> + diff - - git a / runtime / antlr4cpp - vs2015 . vcxproj b / runtime / antlr4cpp - vs2015 . vcxproj <nl> + index 85fa3da . . 540f031 100644 <nl> + mmm a / runtime / antlr4cpp - vs2015 . vcxproj <nl> ppp + b / runtime / antlr4cpp - vs2015 . vcxproj <nl> + <nl> + < DisableSpecificWarnings > 4251 < / DisableSpecificWarnings > <nl> + < MultiProcessorCompilation > true < / MultiProcessorCompilation > <nl> + < MinimalRebuild > false < / MinimalRebuild > <nl> + + < RuntimeLibrary > MultiThreadedDebug < / RuntimeLibrary > <nl> + < / ClCompile > <nl> + < Link > <nl> + < SubSystem > Windows < / SubSystem > <nl> + <nl> + < DisableSpecificWarnings > 4251 < / DisableSpecificWarnings > <nl> + < MultiProcessorCompilation > true < / MultiProcessorCompilation > <nl> + < MinimalRebuild > false < / MinimalRebuild > <nl> + + < RuntimeLibrary > MultiThreadedDebug < / RuntimeLibrary > <nl> + < / ClCompile > <nl> + < Link > <nl> + < SubSystem > Windows < / SubSystem > <nl> + <nl> + < / ForcedIncludeFiles > <nl> + < DisableSpecificWarnings > 4251 < / DisableSpecificWarnings > <nl> + < MultiProcessorCompilation > true < / MultiProcessorCompilation > <nl> + + < RuntimeLibrary > MultiThreaded < / RuntimeLibrary > <nl> + < / ClCompile > <nl> + < Link > <nl> + < SubSystem > Windows < / SubSystem > <nl> + <nl> + < / ForcedIncludeFiles > <nl> + < DisableSpecificWarnings > 4251 < / DisableSpecificWarnings > <nl> + < MultiProcessorCompilation > true < / MultiProcessorCompilation > <nl> + + < RuntimeLibrary > MultiThreaded < / RuntimeLibrary > <nl> + < / ClCompile > <nl> + < Link > <nl> + < SubSystem > Windows < / SubSystem > <nl> new file mode 100644 <nl> index 00000000000 . . 8b11c95b07d <nl> mmm / dev / null <nl> ppp b / ports / antlr4 / portfile . cmake <nl> <nl> + include ( vcpkg_common_functions ) <nl> + set ( SOURCE_PATH $ { CURRENT_BUILDTREES_DIR } / src / runtime ) <nl> + <nl> + vcpkg_download_distfile ( ARCHIVE <nl> + URLS " http : / / www . antlr . org / download / antlr4 - cpp - runtime - 4 . 6 - source . zip " <nl> + FILENAME " antlr4 - cpp - runtime - 4 . 6 - source . zip " <nl> + SHA512 e123c2227e41ce80da5a3758725a018690ed70a4e10c23da26c966259e6bdafa192f4363f5a7e1181ef9a47bf3cc50d6b0ca7b26c8dd2b19222a7edf54de8de2 <nl> + ) <nl> + vcpkg_extract_source_archive ( $ { ARCHIVE } ) <nl> + <nl> + vcpkg_apply_patches ( <nl> + SOURCE_PATH $ { CURRENT_BUILDTREES_DIR } / src <nl> + PATCHES $ { CMAKE_CURRENT_LIST_DIR } / crt_mt . patch <nl> + ) <nl> + <nl> + if ( $ { VCPKG_LIBRARY_LINKAGE } STREQUAL static ) <nl> + set ( DEBUG_CONFIG " Debug Static " ) <nl> + set ( RELEASE_CONFIG " Release Static " ) <nl> + else ( ) <nl> + set ( DEBUG_CONFIG " Debug DLL " ) <nl> + set ( RELEASE_CONFIG " Release DLL " ) <nl> + endif ( ) <nl> + <nl> + vcpkg_build_msbuild ( <nl> + PROJECT_PATH $ { SOURCE_PATH } / antlr4cpp - vs2015 . vcxproj <nl> + DEBUG_CONFIGURATION $ { DEBUG_CONFIG } <nl> + RELEASE_CONFIGURATION $ { RELEASE_CONFIG } <nl> + ) <nl> + <nl> + file ( MAKE_DIRECTORY <nl> + $ { CURRENT_PACKAGES_DIR } / include ) <nl> + FILE ( COPY $ { SOURCE_PATH } / src / <nl> + DESTINATION $ { CURRENT_PACKAGES_DIR } / include <nl> + FILES_MATCHING PATTERN " * . h " ) <nl> + <nl> + file ( MAKE_DIRECTORY <nl> + $ { CURRENT_PACKAGES_DIR } / lib <nl> + $ { CURRENT_PACKAGES_DIR } / debug / lib ) <nl> + <nl> + file ( COPY $ { SOURCE_PATH } / bin / vs - 2015 / $ { TRIPLET_SYSTEM_ARCH } / $ { DEBUG_CONFIG } / antlr4 - runtime . lib <nl> + DESTINATION $ { CURRENT_PACKAGES_DIR } / debug / lib ) <nl> + file ( COPY $ { SOURCE_PATH } / bin / vs - 2015 / $ { TRIPLET_SYSTEM_ARCH } / $ { RELEASE_CONFIG } / antlr4 - runtime . lib <nl> + DESTINATION $ { CURRENT_PACKAGES_DIR } / lib ) <nl> + <nl> + if ( $ { VCPKG_LIBRARY_LINKAGE } STREQUAL static ) <nl> + vcpkg_apply_patches ( <nl> + SOURCE_PATH $ { CURRENT_PACKAGES_DIR } / include <nl> + PATCHES $ { CMAKE_CURRENT_LIST_DIR } / static . patch <nl> + ) <nl> + else ( ) <nl> + file ( MAKE_DIRECTORY <nl> + $ { CURRENT_PACKAGES_DIR } / bin <nl> + $ { CURRENT_PACKAGES_DIR } / debug / bin ) <nl> + <nl> + file ( COPY <nl> + $ { SOURCE_PATH } / bin / vs - 2015 / $ { TRIPLET_SYSTEM_ARCH } / $ { DEBUG_CONFIG } / antlr4 - runtime . dll <nl> + $ { SOURCE_PATH } / bin / vs - 2015 / $ { TRIPLET_SYSTEM_ARCH } / $ { DEBUG_CONFIG } / antlr4 - runtime . pdb <nl> + DESTINATION $ { CURRENT_PACKAGES_DIR } / debug / bin ) <nl> + file ( COPY <nl> + $ { SOURCE_PATH } / bin / vs - 2015 / $ { TRIPLET_SYSTEM_ARCH } / $ { RELEASE_CONFIG } / antlr4 - runtime . dll <nl> + $ { SOURCE_PATH } / bin / vs - 2015 / $ { TRIPLET_SYSTEM_ARCH } / $ { RELEASE_CONFIG } / antlr4 - runtime . pdb <nl> + DESTINATION $ { CURRENT_PACKAGES_DIR } / bin ) <nl> + endif ( ) <nl> + <nl> + <nl> + # license not exist in antlr folder . <nl> + vcpkg_download_distfile ( LICENSE <nl> + URLS https : / / raw . githubusercontent . com / antlr / antlr4 / master / LICENSE . txt <nl> + FILENAME " antlr4 - copyright " <nl> + SHA512 c72ae3d5c9f3f07160405b5ca44f01116a9602d82291d6cd218fcc5ec6e8baf985e4baa2acf3d621079585385708bd171c96ef44dd808e60c40a48bc1f56c9ae <nl> + ) <nl> + file ( INSTALL $ { LICENSE } DESTINATION $ { CURRENT_PACKAGES_DIR } / share / antlr4 RENAME copyright ) <nl> + <nl> + message ( STATUS " Installing done " ) <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . fb54c5ae402 <nl> mmm / dev / null <nl> ppp b / ports / antlr4 / static . patch <nl> <nl> pppmmm a / antlr4 - common . h <nl> ppp + b / antlr4 - common . h <nl> + <nl> + # include < bitset > <nl> + # include < condition_variable > <nl> + <nl> + + # define ANTLR4CPP_STATIC <nl> + / / Defines for the Guid class and other platform dependent stuff . <nl> + # ifdef _WIN32 <nl> + # pragma warning ( disable : 4250 ) / / Class inherits by dominance . <nl> | [ antlr4 ] initial commit | microsoft/vcpkg | 91f51a084fec588854ea784f3e8a829540664e43 | 2016-12-25T10:44:20Z |
mmm a / src / video_core / renderer_opengl / gl_shader_decompiler . cpp <nl> ppp b / src / video_core / renderer_opengl / gl_shader_decompiler . cpp <nl> class GLSLGenerator { <nl> * @ param value the code representing the value to assign . <nl> * / <nl> void SetDest ( u64 elem , const std : : string & reg , const std : : string & value , <nl> - u64 dest_num_components , u64 value_num_components ) { <nl> + u64 dest_num_components , u64 value_num_components , bool is_abs = false ) { <nl> std : : string swizzle = " . " ; <nl> swizzle + = " xyzw " [ elem ] ; <nl> <nl> std : : string dest = reg + ( dest_num_components ! = 1 ? swizzle : " " ) ; <nl> std : : string src = " ( " + value + " ) " + ( value_num_components ! = 1 ? swizzle : " " ) ; <nl> + src = is_abs ? " abs ( " + src + " ) " : src ; <nl> <nl> shader . AddLine ( dest + " = " + src + " ; " ) ; <nl> } <nl> class GLSLGenerator { <nl> <nl> switch ( OpCode : : GetInfo ( instr . opcode ) . type ) { <nl> case OpCode : : Type : : Arithmetic : { <nl> - ASSERT_MSG ( ! instr . alu . abs_d , " unimplemented " ) ; <nl> - <nl> std : : string dest = GetRegister ( instr . gpr0 ) ; <nl> std : : string op_a = instr . alu . negate_a ? " - " : " " ; <nl> op_a + = GetRegister ( instr . gpr8 ) ; <nl> class GLSLGenerator { <nl> } <nl> case OpCode : : Id : : MUFU : { <nl> switch ( instr . sub_op ) { <nl> + case SubOp : : Cos : <nl> + SetDest ( 0 , dest , " cos ( " + op_a + " ) " , 1 , 1 , instr . alu . abs_d ) ; <nl> + break ; <nl> + case SubOp : : Sin : <nl> + SetDest ( 0 , dest , " sin ( " + op_a + " ) " , 1 , 1 , instr . alu . abs_d ) ; <nl> + break ; <nl> + case SubOp : : Ex2 : <nl> + SetDest ( 0 , dest , " exp2 ( " + op_a + " ) " , 1 , 1 , instr . alu . abs_d ) ; <nl> + break ; <nl> + case SubOp : : Lg2 : <nl> + SetDest ( 0 , dest , " log2 ( " + op_a + " ) " , 1 , 1 , instr . alu . abs_d ) ; <nl> + break ; <nl> case SubOp : : Rcp : <nl> - SetDest ( 0 , dest , " 1 . 0 / " + op_a , 1 , 1 ) ; <nl> + SetDest ( 0 , dest , " 1 . 0 / " + op_a , 1 , 1 , instr . alu . abs_d ) ; <nl> + break ; <nl> + case SubOp : : Rsq : <nl> + SetDest ( 0 , dest , " inversesqrt ( " + op_a + " ) " , 1 , 1 , instr . alu . abs_d ) ; <nl> + break ; <nl> + case SubOp : : Min : <nl> + SetDest ( 0 , dest , " min ( " + op_a + " , " + op_b + " ) " , 1 , 1 , instr . alu . abs_d ) ; <nl> break ; <nl> default : <nl> LOG_ERROR ( HW_GPU , " Unhandled sub op : 0x % 02x " , ( int ) instr . sub_op . Value ( ) ) ; <nl> class GLSLGenerator { <nl> break ; <nl> } <nl> case OpCode : : Type : : Ffma : { <nl> - ASSERT_MSG ( ! instr . ffma . negate_b , " untested " ) ; <nl> - ASSERT_MSG ( ! instr . ffma . negate_c , " untested " ) ; <nl> - <nl> std : : string dest = GetRegister ( instr . gpr0 ) ; <nl> std : : string op_a = GetRegister ( instr . gpr8 ) ; <nl> std : : string op_b = instr . ffma . negate_b ? " - " : " " ; <nl> | gl_shader_decompiler : Implement several MUFU subops and abs_d . | yuzu-emu/yuzu | ef2d5ab0c1b75feb848f9987723edc35afb11ce6 | 2018-04-17T20:36:43Z |
mmm a / ports / winreg / CONTROL <nl> ppp b / ports / winreg / CONTROL <nl> <nl> Source : winreg <nl> - Version : 2 . 2 . 2 <nl> + Version : 2 . 2 . 3 <nl> Homepage : https : / / github . com / GiovanniDicanio / WinReg <nl> Description : High - level C + + wrapper around the Windows Registry C API . <nl> Supports : windows | uwp <nl> \ No newline at end of file <nl> mmm a / ports / winreg / portfile . cmake <nl> ppp b / ports / winreg / portfile . cmake <nl> vcpkg_fail_port_install ( ON_TARGET " linux " " osx " ) <nl> vcpkg_from_github ( <nl> OUT_SOURCE_PATH SOURCE_PATH <nl> REPO GiovanniDicanio / WinReg <nl> - REF 5102b656389aa2909ca69d74e8b694e8451d85b1 # v2 . 2 . 2 <nl> - SHA512 3f46eccf5bcc76c71848463ac898953bb8d7737200ea55900f064ad95da6953e643233f7faa5c3288fa42cbb599da62b324abaec3509dfa969430c464ac586fe <nl> + REF 1dfd91d80ec89d36236e41dd75f2c5ddb31093a1 # v2 . 2 . 3 <nl> + SHA512 5d43cd15f958411407ae636234c8e1c3d43d5dbd074b93d578245d75405fb2ec7a9d4924d7eb9141fc9ce42391846d22a2e3945e53bdf43fbd78ccbce397c03e <nl> HEAD_REF master <nl> ) <nl> <nl> | [ winreg ] Update to 2 . 2 . 3 ( ) | microsoft/vcpkg | 5c455605a5006c6782497b813d6bad1a7359f550 | 2020-04-27T13:58:55Z |
mmm a / frontend / js / templates / collectionsItemView . ejs <nl> ppp b / frontend / js / templates / collectionsItemView . ejs <nl> <nl> <nl> < div class = " pull - right " > <nl> < a href = " # collection / < % = attributes . id % > " > <nl> - < i class = " icon - info - sign " > < / i > <nl> + < i class = " icon - edit " > < / i > <nl> < / a > <nl> < / div > <nl> <nl> mmm a / frontend / js / views / collectionView . js <nl> ppp b / frontend / js / views / collectionView . js <nl> var collectionView = Backbone . View . extend ( { <nl> " click # unload - modified - collection " : " unloadCollection " <nl> } , <nl> hidden : function ( ) { <nl> - window . location . hash = " # " ; <nl> + window . location . hash = " # collection / " ; <nl> } , <nl> fillModal : function ( ) { <nl> this . myCollection = window . arangoCollectionsStore . get ( this . options . colId ) . attributes ; <nl> mmm a / frontend / js / views / collectionsView . js <nl> ppp b / frontend / js / views / collectionsView . js <nl> var collectionsView = Backbone . View . extend ( { <nl> <nl> $ ( ' . thumbnails ' , this . el ) . append ( ' < li class = " span3 " > < a href = " # new " class = " add " > < img id = " newCollection " src = " / _admin / html / img / plus_icon . png " class = " pull - left " > < / img > Add Collection < / a > < / li > ' ) ; <nl> $ ( ' # searchInput ' ) . val ( searchOptions . searchPhrase ) ; <nl> - $ ( ' # searchInput ' ) . focus ( ) ; <nl> + / / to discuss <nl> + / / $ ( ' # searchInput ' ) . focus ( ) ; <nl> var val = $ ( ' # searchInput ' ) . val ( ) ; <nl> $ ( ' # searchInput ' ) . val ( ' ' ) ; <nl> $ ( ' # searchInput ' ) . val ( val ) ; <nl> | popup bug fixed | arangodb/arangodb | 77766f95d4dffbd58754656348b62be58eefe128 | 2013-02-26T17:38:38Z |
similarity index 100 % <nl> rename from examples / imagenet . prototxt <nl> rename to models / imagenet . prototxt <nl> similarity index 100 % <nl> rename from examples / imagenet_deploy . prototxt <nl> rename to models / imagenet_deploy . prototxt <nl> similarity index 100 % <nl> rename from examples / imagenet_solver . prototxt <nl> rename to models / imagenet_solver . prototxt <nl> similarity index 100 % <nl> rename from examples / imagenet_val . prototxt <nl> rename to models / imagenet_val . prototxt <nl> similarity index 100 % <nl> rename from examples / lenet . prototxt <nl> rename to models / lenet . prototxt <nl> similarity index 100 % <nl> rename from examples / lenet_solver . prototxt <nl> rename to models / lenet_solver . prototxt <nl> similarity index 100 % <nl> rename from examples / lenet_test . prototxt <nl> rename to models / lenet_test . prototxt <nl> | file models | BVLC/caffe | 2ec698b2b3999d94f89d6cca24aafd17a1aed230 | 2014-02-26T20:37:45Z |
mmm a / fdbserver / LogSystemConfig . h <nl> ppp b / fdbserver / LogSystemConfig . h <nl> struct LogSystemConfig { <nl> std : : map < int8_t , int > allLocalities ; <nl> for ( auto & tLogSet : tLogs ) { <nl> for ( auto & tLog : tLogSet . tLogs ) { <nl> - if ( tLog . present ( ) & & tLogSet . locality > = 0 ) { <nl> - if ( tLog . interf ( ) . locality . dcId ( ) = = dcId ) { <nl> + if ( tLogSet . locality > = 0 ) { <nl> + if ( tLog . present ( ) & & tLog . interf ( ) . locality . dcId ( ) = = dcId ) { <nl> matchingLocalities [ tLogSet . locality ] + + ; <nl> } else { <nl> allLocalities [ tLogSet . locality ] + + ; <nl> struct LogSystemConfig { <nl> for ( auto & oldLog : oldTLogs ) { <nl> for ( auto & tLogSet : oldLog . tLogs ) { <nl> for ( auto & tLog : tLogSet . tLogs ) { <nl> - if ( tLog . present ( ) & & tLogSet . locality > = 0 ) { <nl> - if ( tLog . interf ( ) . locality . dcId ( ) = = dcId ) { <nl> + if ( tLogSet . locality > = 0 ) { <nl> + if ( tLog . present ( ) & & tLog . interf ( ) . locality . dcId ( ) = = dcId ) { <nl> matchingLocalities [ tLogSet . locality ] + + ; <nl> } else { <nl> allLocalities [ tLogSet . locality ] + + ; <nl> struct LogSystemConfig { <nl> if ( bestLoc ! = tagLocalityInvalid ) { <nl> return std : : make_pair ( bestLoc , secondLoc ) ; <nl> } <nl> - return std : : make_pair ( secondLocalityCount , thirdLocalityCount ) ; <nl> + return std : : make_pair ( secondLoc , thirdLoc ) ; <nl> } <nl> <nl> std : : vector < std : : pair < UID , NetworkAddress > > allSharedLogs ( ) const { <nl> | fix : getLocalityForDcId was returning counts rather than actual localities | apple/foundationdb | d600b0a51c7d0a0a0fe087631d742f902b515f66 | 2019-02-22T22:02:34Z |
mmm a / src / init . cpp <nl> ppp b / src / init . cpp <nl> class DummyWalletInit : public WalletInitInterface { <nl> bool ParameterInteraction ( ) override { return true ; } <nl> void RegisterRPC ( CRPCTable & ) override { } <nl> bool Verify ( ) override { return true ; } <nl> - bool Open ( ) override { return true ; } <nl> + bool Open ( ) override { LogPrintf ( " No wallet support compiled in ! \ n " ) ; return true ; } <nl> void Start ( CScheduler & scheduler ) override { } <nl> void Flush ( ) override { } <nl> void Stop ( ) override { } <nl> | added logging line back that was accidentally removed with | bitcoin/bitcoin | 23abfb7b7fea6923dc29a9ff1aa958dee83e3bd7 | 2018-04-09T19:21:25Z |
mmm a / docs / en / query_language / select . md <nl> ppp b / docs / en / query_language / select . md <nl> A table function may be specified instead of a table . For more information , see <nl> To execute a query , all the columns listed in the query are extracted from the appropriate table . Any columns not needed for the external query are thrown out of the subqueries . <nl> If a query does not list any columns ( for example , SELECT count ( ) FROM t ) , some column is extracted from the table anyway ( the smallest one is preferred ) , in order to calculate the number of rows . <nl> <nl> - The FINAL modifier can be used only for a SELECT from a CollapsingMergeTree table . When you specify FINAL , data is selected fully " collapsed " . Keep in mind that using FINAL leads to a selection that includes columns related to the primary key , in addition to the columns specified in the SELECT . Additionally , the query will be executed in a single stream , and data will be merged during query execution . This means that when using FINAL , the query is processed more slowly . In most cases , you should avoid using FINAL . For more information , see the section " CollapsingMergeTree engine " . <nl> + The FINAL modifier can be used only for a SELECT from ReplacingMergeTree , SummingMergeTree , AggregatingMergeTree , CollapsingMergeTree and VersionedCollapsingMergeTree tables . When you specify FINAL , data is selected fully " merged " . Keep in mind that using FINAL leads to a selection that includes columns related to the primary key , in addition to the columns specified in the SELECT . Additionally , the query will be executed in a single stream , and data will be merged during query execution . This means that when using FINAL , the query is processed more slowly . In most cases , you should avoid using FINAL . <nl> <nl> # # # SAMPLE Clause { # select - sample - clause } <nl> <nl> | Update select . md | ClickHouse/ClickHouse | fb1b8cf77855abaabe91aba92fc3cafc361a72c3 | 2019-09-03T02:21:32Z |
mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> static ImVec2 CalcSizeAutoFit ( ImGuiWindow * window ) <nl> if ( size_auto_fit_after_constraint . x < window - > SizeContents . x & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) & & ( flags & ImGuiWindowFlags_HorizontalScrollbar ) ) <nl> size_auto_fit . y + = style . ScrollbarSize ; <nl> if ( size_auto_fit_after_constraint . y < window - > SizeContents . y & & ! ( flags & ImGuiWindowFlags_NoScrollbar ) ) <nl> - size_auto_fit . x + = style . ScrollbarSize * 2 . 0f ; <nl> + size_auto_fit . x + = style . ScrollbarSize ; <nl> size_auto_fit . y = ImMax ( size_auto_fit . y - style . ItemSpacing . y , 0 . 0f ) ; <nl> } <nl> return size_auto_fit ; <nl> | Fixed auto - resize allocating too much space for scrollbar when SizeContents is bigger than maximum window size ( fixes c0547d358d746699f8d46a4996e49fdac8c55748 ) ( ) | ocornut/imgui | 2c7ba21417dbc82e277e223e556e5a29a0674798 | 2017-11-07T10:37:38Z |
mmm a / tensorflow / tools / ci_build / install / . bazelrc <nl> ppp b / tensorflow / tools / ci_build / install / . bazelrc <nl> startup - - batch <nl> # https : / / github . com / bazelbuild / bazel / issues / 418 <nl> build - - spawn_strategy = standalone - - genrule_strategy = standalone <nl> <nl> - # Force bazel output to use colors ( good for jenkins ) and print useful errors . <nl> - common - - color = yes - - verbose_failures <nl> - <nl> - # Configure tests - increase timeout , print errors and timeout warnings <nl> - test - - test_timeout = 3600 - - test_output = errors - - test_verbose_timeout_warnings <nl> + build - - color = yes - - verbose_failures <nl> + test - - color = yes - - verbose_failures - - test_timeout = 3600 - - test_output = errors - - test_verbose_timeout_warnings <nl> | ci_build : remove common section from . bazelrc | tensorflow/tensorflow | 4322ce2450d43268f1263bfdbc32013b54821826 | 2016-01-19T22:55:53Z |
mmm a / Core / Core . xcodeproj / project . pbxproj <nl> ppp b / Core / Core . xcodeproj / project . pbxproj <nl> <nl> <nl> / * Begin PBXFileReference section * / <nl> CB58B3FF23AB3035002457F1 / * Foundation . framework * / = { isa = PBXFileReference ; lastKnownFileType = wrapper . framework ; name = Foundation . framework ; path = Platforms / MacOSX . platform / Developer / SDKs / MacOSX10 . 15 . sdk / System / Library / Frameworks / Foundation . framework ; sourceTree = DEVELOPER_DIR ; } ; <nl> - CB9563D823AB2D9500ACCD39 / * libCore . a * / = { isa = PBXFileReference ; explicitFileType = archive . ar ; includeInIndex = 0 ; path = libCore . a ; sourceTree = BUILT_PRODUCTS_DIR ; } ; <nl> + CB9563D823AB2D9500ACCD39 / * libMMKVCore . a * / = { isa = PBXFileReference ; explicitFileType = archive . ar ; includeInIndex = 0 ; path = libMMKVCore . a ; sourceTree = BUILT_PRODUCTS_DIR ; } ; <nl> CB9563E423AB2E9100ACCD39 / * CodedInputData . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = CodedInputData . h ; sourceTree = " < group > " ; } ; <nl> CB9563EB23AB2E9100ACCD39 / * Checksum . h * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . c . h ; path = Checksum . h ; sourceTree = " < group > " ; } ; <nl> CB9563EC23AB2E9100ACCD39 / * MMKVMetaInfo . hpp * / = { isa = PBXFileReference ; fileEncoding = 4 ; lastKnownFileType = sourcecode . cpp . h ; path = MMKVMetaInfo . hpp ; sourceTree = " < group > " ; } ; <nl> <nl> CB9563D923AB2D9500ACCD39 / * Products * / = { <nl> isa = PBXGroup ; <nl> children = ( <nl> - CB9563D823AB2D9500ACCD39 / * libCore . a * / , <nl> + CB9563D823AB2D9500ACCD39 / * libMMKVCore . a * / , <nl> ) ; <nl> name = Products ; <nl> sourceTree = " < group > " ; <nl> <nl> / * End PBXGroup section * / <nl> <nl> / * Begin PBXNativeTarget section * / <nl> - CB9563D723AB2D9500ACCD39 / * Core * / = { <nl> + CB9563D723AB2D9500ACCD39 / * MMKVCore * / = { <nl> isa = PBXNativeTarget ; <nl> - buildConfigurationList = CB9563E123AB2D9500ACCD39 / * Build configuration list for PBXNativeTarget " Core " * / ; <nl> + buildConfigurationList = CB9563E123AB2D9500ACCD39 / * Build configuration list for PBXNativeTarget " MMKVCore " * / ; <nl> buildPhases = ( <nl> CB9563D423AB2D9500ACCD39 / * Sources * / , <nl> CB9563D523AB2D9500ACCD39 / * Frameworks * / , <nl> <nl> ) ; <nl> dependencies = ( <nl> ) ; <nl> - name = Core ; <nl> + name = MMKVCore ; <nl> productName = Core ; <nl> - productReference = CB9563D823AB2D9500ACCD39 / * libCore . a * / ; <nl> + productReference = CB9563D823AB2D9500ACCD39 / * libMMKVCore . a * / ; <nl> productType = " com . apple . product - type . library . static " ; <nl> } ; <nl> / * End PBXNativeTarget section * / <nl> <nl> projectDirPath = " " ; <nl> projectRoot = " " ; <nl> targets = ( <nl> - CB9563D723AB2D9500ACCD39 / * Core * / , <nl> + CB9563D723AB2D9500ACCD39 / * MMKVCore * / , <nl> ) ; <nl> } ; <nl> / * End PBXProject section * / <nl> <nl> defaultConfigurationIsVisible = 0 ; <nl> defaultConfigurationName = Release ; <nl> } ; <nl> - CB9563E123AB2D9500ACCD39 / * Build configuration list for PBXNativeTarget " Core " * / = { <nl> + CB9563E123AB2D9500ACCD39 / * Build configuration list for PBXNativeTarget " MMKVCore " * / = { <nl> isa = XCConfigurationList ; <nl> buildConfigurations = ( <nl> CB9563E223AB2D9500ACCD39 / * Debug * / , <nl> mmm a / iOS / MMKV / MMKV / libMMKV . mm <nl> ppp b / iOS / MMKV / MMKV / libMMKV . mm <nl> <nl> * / <nl> <nl> # import " MMKV . h " <nl> - # import < Core / MMKV . h > <nl> - # import < Core / MMKVLog . h > <nl> - # import < Core / ScopedLock . hpp > <nl> - # import < Core / ThreadLock . h > <nl> - # import < Core / openssl_md5 . h > <nl> + # import < MMKVCore / MMKV . h > <nl> + # import < MMKVCore / MMKVLog . h > <nl> + # import < MMKVCore / ScopedLock . hpp > <nl> + # import < MMKVCore / ThreadLock . h > <nl> + # import < MMKVCore / openssl_md5 . h > <nl> <nl> # if defined ( MMKV_IOS ) & & ! defined ( MMKV_IOS_EXTENSION ) <nl> # import < UIKit / UIKit . h > <nl> | Merge pull request from Tencent / dev | Tencent/MMKV | fa311a2816b551f3b654819bbac0a09f326f8409 | 2020-03-25T07:48:15Z |
mmm a / modules / planning / math / piecewise_jerk / BUILD <nl> ppp b / modules / planning / math / piecewise_jerk / BUILD <nl> cc_test ( <nl> name = " piecewise_jerk_problem_test " , <nl> size = " small " , <nl> srcs = [ <nl> - " piecewise_jerk_problem . cc " , <nl> + " piecewise_jerk_problem_test . cc " , <nl> ] , <nl> deps = [ <nl> " : piecewise_jerk_problem " , <nl> mmm a / modules / planning / math / piecewise_jerk / piecewise_jerk_problem_test . cc <nl> ppp b / modules / planning / math / piecewise_jerk / piecewise_jerk_problem_test . cc <nl> <nl> <nl> # define private public <nl> # define protected public <nl> - # include " modules / planning / math / piecewise_jerk / piesewise_jerk_problem . h " <nl> + # include " modules / planning / math / piecewise_jerk / piecewise_jerk_problem . h " <nl> <nl> namespace apollo { <nl> namespace planning { <nl> TEST ( PiecewiseJerkProblemTest , basic_test ) { <nl> std : : array < double , 5 > w = { 1 . 0 , 2 . 0 , 3 . 0 , 4 . 0 , 1 . 45 } ; <nl> double max_x_third_order_derivative = 1 . 25 ; <nl> <nl> - std : : unique_ptr < PiecewiseJerkProblem > fem_qp ( new PiecewiseJerkProblem ( <nl> - n , x_init , delta_s , w , max_x_third_order_derivative ) ) ; <nl> + std : : unique_ptr < PiecewiseJerkProblem > fem_qp ( new PiecewiseJerkProblem ( ) ) ; <nl> + fem_qp - > InitProblem ( n , delta_s , w , x_init ) ; <nl> <nl> fem_qp - > SetVariableBounds ( x_bounds ) ; <nl> fem_qp - > SetFirstOrderBounds ( - FLAGS_lateral_derivative_bound_default , <nl> FLAGS_lateral_derivative_bound_default ) ; <nl> fem_qp - > SetSecondOrderBounds ( - FLAGS_lateral_derivative_bound_default , <nl> FLAGS_lateral_derivative_bound_default ) ; <nl> + fem_qp - > SetThirdOrderBound ( max_x_third_order_derivative ) ; <nl> <nl> auto start_time = std : : chrono : : system_clock : : now ( ) ; <nl> EXPECT_TRUE ( fem_qp - > Optimize ( ) ) ; <nl> TEST ( PiecewiseJerkProblemTest , add_bounds_test ) { <nl> double delta_s = 0 . 5 ; <nl> size_t n = 400 ; <nl> std : : array < double , 5 > w = { 1 . 0 , 2 . 0 , 3 . 0 , 4 . 0 , 1 . 45 } ; <nl> - double max_x_third_order_derivative = 0 . 25 ; <nl> <nl> - std : : unique_ptr < PiecewiseJerkProblem > fem_qp ( new PiecewiseJerkProblem ( <nl> - n , delta_s , w , max_x_third_order_derivative , x_init ) ) ; <nl> + std : : unique_ptr < PiecewiseJerkProblem > fem_qp ( new PiecewiseJerkProblem ( ) ) ; <nl> + fem_qp - > InitProblem ( n , delta_s , w , x_init ) ; <nl> <nl> std : : vector < std : : tuple < double , double , double > > x_bounds ; <nl> for ( size_t i = 10 ; i < 20 ; + + i ) { <nl> TEST ( PiecewiseJerkProblemTest , derivative_constraint_test ) { <nl> std : : array < double , 5 > w = { 1 . 0 , 100 . 0 , 1000 . 0 , 1000 . 0 , 0 . 0 } ; <nl> double max_x_third_order_derivative = 2 . 0 ; <nl> <nl> - std : : unique_ptr < PiecewiseJerkProblem > fem_qp ( new PiecewiseJerkProblem ( <nl> - n , x_init , delta_s , w , max_x_third_order_derivative ) ) ; <nl> + std : : unique_ptr < PiecewiseJerkProblem > fem_qp ( new PiecewiseJerkProblem ( ) ) ; <nl> + fem_qp - > InitProblem ( n , delta_s , w , x_init ) ; <nl> <nl> fem_qp - > SetVariableBounds ( x_bounds ) ; <nl> fem_qp - > SetFirstOrderBounds ( - FLAGS_lateral_derivative_bound_default , <nl> FLAGS_lateral_derivative_bound_default ) ; <nl> fem_qp - > SetSecondOrderBounds ( - FLAGS_lateral_derivative_bound_default , <nl> FLAGS_lateral_derivative_bound_default ) ; <nl> + fem_qp - > SetThirdOrderBound ( max_x_third_order_derivative ) ; <nl> <nl> const double dx_max = std : : sqrt ( 0 . 5 ) / 15 . 0 ; <nl> std : : vector < std : : tuple < double , double , double > > dx_bounds ; <nl> | Planning : fix unit test for piecewise_jerk_problem | ApolloAuto/apollo | b01288ffb46f5114b028f04c6fa530878054f492 | 2019-04-23T04:00:30Z |
mmm a / . gitignore <nl> ppp b / . gitignore <nl> config . log <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / includes / dvdread / nav_types . h <nl> <nl> # / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / <nl> + / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / . auto / <nl> + / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / Makefile . in <nl> + / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / aclocal . m4 <nl> + / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / autom4te . cache / <nl> + / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / config . h . in ~ <nl> + / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / configure <nl> + / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / doc / Makefile . in <nl> + / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / src / Makefile . in <nl> + / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / src / dvdcss / Makefile . in <nl> + / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / test / Makefile . in <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / config . log <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / config . st <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / stamp - h1 <nl> config . log <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / configure . lineno <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / Makefile <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / config . status <nl> - <nl> - # / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / doc / <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / doc / Makefile <nl> - <nl> - # / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / src / <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / src / d <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / src / Makefile <nl> - <nl> - # / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / src / dvdcss / <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / src / dvdcss / Makefile <nl> - <nl> - # / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / test / <nl> / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdcss / test / Makefile <nl> <nl> # / xbmc / cores / dvdplayer / Codecs / libdvd / libdvdnav / <nl> | Fix . gitignore for libdvdcss section and add more entries for libdvdcss autogenerated files . | xbmc/xbmc | 5a8f3890276caba89db0f9e474dede62ae96fe58 | 2010-05-12T23:58:57Z |
mmm a / cocos2dx / shaders / CCGLProgram . cpp <nl> ppp b / cocos2dx / shaders / CCGLProgram . cpp <nl> GLint CCGLProgram : : getUniformLocationForName ( const char * name ) <nl> void CCGLProgram : : setUniformLocationWith1i ( GLint location , GLint i1 ) <nl> { <nl> bool updated = updateUniformLocation ( location , & i1 , sizeof ( i1 ) * 1 ) ; <nl> - <nl> - if ( updated ) <nl> + <nl> + if ( updated ) <nl> { <nl> glUniform1i ( ( GLint ) location , i1 ) ; <nl> } <nl> } <nl> <nl> + void CCGLProgram : : setUniformLocationWith2i ( GLint location , GLint i1 , GLint i2 ) <nl> + { <nl> + GLint ints [ 2 ] = { i1 , i2 } ; <nl> + bool updated = updateUniformLocation ( location , ints , sizeof ( ints ) ) ; <nl> + <nl> + if ( updated ) <nl> + { <nl> + glUniform2i ( ( GLint ) location , i1 , i2 ) ; <nl> + } <nl> + } <nl> + <nl> + void CCGLProgram : : setUniformLocationWith3i ( GLint location , GLint i1 , GLint i2 , GLint i3 ) <nl> + { <nl> + GLint ints [ 3 ] = { i1 , i2 , i3 } ; <nl> + bool updated = updateUniformLocation ( location , ints , sizeof ( ints ) ) ; <nl> + <nl> + if ( updated ) <nl> + { <nl> + glUniform3i ( ( GLint ) location , i1 , i2 , i3 ) ; <nl> + } <nl> + } <nl> + <nl> + void CCGLProgram : : setUniformLocationWith4i ( GLint location , GLint i1 , GLint i2 , GLint i3 , GLint i4 ) <nl> + { <nl> + GLint ints [ 4 ] = { i1 , i2 , i3 , i4 } ; <nl> + bool updated = updateUniformLocation ( location , ints , sizeof ( ints ) ) ; <nl> + <nl> + if ( updated ) <nl> + { <nl> + glUniform4i ( ( GLint ) location , i1 , i2 , i3 , i4 ) ; <nl> + } <nl> + } <nl> + <nl> + void CCGLProgram : : setUniformLocationWith2iv ( GLint location , GLint * ints , unsigned int numberOfArrays ) <nl> + { <nl> + bool updated = updateUniformLocation ( location , ints , sizeof ( int ) * 2 * numberOfArrays ) ; <nl> + <nl> + if ( updated ) <nl> + { <nl> + glUniform2iv ( ( GLint ) location , ( GLsizei ) numberOfArrays , ints ) ; <nl> + } <nl> + } <nl> + <nl> + void CCGLProgram : : setUniformLocationWith3iv ( GLint location , GLint * ints , unsigned int numberOfArrays ) <nl> + { <nl> + bool updated = updateUniformLocation ( location , ints , sizeof ( int ) * 3 * numberOfArrays ) ; <nl> + <nl> + if ( updated ) <nl> + { <nl> + glUniform3iv ( ( GLint ) location , ( GLsizei ) numberOfArrays , ints ) ; <nl> + } <nl> + } <nl> + <nl> + void CCGLProgram : : setUniformLocationWith4iv ( GLint location , GLint * ints , unsigned int numberOfArrays ) <nl> + { <nl> + bool updated = updateUniformLocation ( location , ints , sizeof ( int ) * 4 * numberOfArrays ) ; <nl> + <nl> + if ( updated ) <nl> + { <nl> + glUniform4iv ( ( GLint ) location , ( GLsizei ) numberOfArrays , ints ) ; <nl> + } <nl> + } <nl> + <nl> void CCGLProgram : : setUniformLocationWith1f ( GLint location , GLfloat f1 ) <nl> { <nl> bool updated = updateUniformLocation ( location , & f1 , sizeof ( f1 ) * 1 ) ; <nl> mmm a / cocos2dx / shaders / CCGLProgram . h <nl> ppp b / cocos2dx / shaders / CCGLProgram . h <nl> class CC_DLL CCGLProgram : public CCObject <nl> <nl> / * * calls glUniform1i only if the values are different than the previous call for this same shader program . * / <nl> void setUniformLocationWith1i ( GLint location , GLint i1 ) ; <nl> + <nl> + / * * calls glUniform2i only if the values are different than the previous call for this same shader program . * / <nl> + void setUniformLocationWith2i ( GLint location , GLint i1 , GLint i2 ) ; <nl> + <nl> + / * * calls glUniform3i only if the values are different than the previous call for this same shader program . * / <nl> + void setUniformLocationWith3i ( GLint location , GLint i1 , GLint i2 , GLint i3 ) ; <nl> + <nl> + / * * calls glUniform4i only if the values are different than the previous call for this same shader program . * / <nl> + void setUniformLocationWith4i ( GLint location , GLint i1 , GLint i2 , GLint i3 , GLint i4 ) ; <nl> + <nl> + / * * calls glUniform2iv only if the values are different than the previous call for this same shader program . * / <nl> + void setUniformLocationWith2iv ( GLint location , GLint * ints , unsigned int numberOfArrays ) ; <nl> + <nl> + / * * calls glUniform3iv only if the values are different than the previous call for this same shader program . * / <nl> + void setUniformLocationWith3iv ( GLint location , GLint * ints , unsigned int numberOfArrays ) ; <nl> + <nl> + / * * calls glUniform4iv only if the values are different than the previous call for this same shader program . * / <nl> + <nl> + void setUniformLocationWith4iv ( GLint location , GLint * ints , unsigned int numberOfArrays ) ; <nl> <nl> / * * calls glUniform1f only if the values are different than the previous call for this same shader program . * / <nl> void setUniformLocationWith1f ( GLint location , GLfloat f1 ) ; <nl> | Added support for setting integer uniforms | cocos2d/cocos2d-x | fd35ebd4d479aaa987b383db875bbc1e521c6a49 | 2013-03-26T18:20:38Z |
mmm a / src / wasm / wasm - module . cc <nl> ppp b / src / wasm / wasm - module . cc <nl> class InstantiationHelper { <nl> WasmSharedModuleData : : SetBreakpointsOnNewInstance ( <nl> compiled_module_ - > shared ( ) , instance ) ; <nl> <nl> - if ( FLAG_wasm_interpret_all ) { <nl> + if ( FLAG_wasm_interpret_all & & module_ - > is_wasm ( ) ) { <nl> Handle < WasmDebugInfo > debug_info = <nl> WasmInstanceObject : : GetOrCreateDebugInfo ( instance ) ; <nl> std : : vector < int > func_indexes ; <nl> new file mode 100644 <nl> index 00000000000 . . c6217b0b01a <nl> mmm / dev / null <nl> ppp b / test / mjsunit / regress / wasm / regression - 719175 . js <nl> <nl> + / / Copyright 2017 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 : - - validate - asm - - wasm - interpret - all <nl> + <nl> + function asm ( ) { <nl> + ' use asm ' ; <nl> + function f ( ) { <nl> + if ( 1 . 0 % 2 . 5 = = - 0 . 75 ) { <nl> + } <nl> + return 0 ; <nl> + } <nl> + return { f : f } ; <nl> + } <nl> + asm ( ) . f ( ) ; <nl> | [ wasm ] Don ' t try to interpret asm . js modules | v8/v8 | a68b75d05929b159ae8bbcdfecdcc3f32404a7da | 2017-05-17T09:38:06Z |
mmm a / include / swift / AST / ASTTypeIDZone . def <nl> ppp b / include / swift / AST / ASTTypeIDZone . def <nl> SWIFT_TYPEID ( BodyInitKindAndExpr ) <nl> SWIFT_TYPEID ( CtorInitializerKind ) <nl> SWIFT_TYPEID ( FunctionBuilderBodyPreCheck ) <nl> SWIFT_TYPEID ( GenericSignature ) <nl> - SWIFT_TYPEID ( ImplicitImport ) <nl> + SWIFT_TYPEID ( ImplicitImportList ) <nl> SWIFT_TYPEID ( ImplicitMemberAction ) <nl> SWIFT_TYPEID ( ParamSpecifier ) <nl> SWIFT_TYPEID ( PropertyWrapperBackingPropertyInfo ) <nl> mmm a / include / swift / AST / ASTTypeIDs . h <nl> ppp b / include / swift / AST / ASTTypeIDs . h <nl> class GenericTypeParamType ; <nl> class InfixOperatorDecl ; <nl> class IterableDeclContext ; <nl> class ModuleDecl ; <nl> - struct ImplicitImport ; <nl> + struct ImplicitImportList ; <nl> class NamedPattern ; <nl> class NominalTypeDecl ; <nl> class OperatorDecl ; <nl> mmm a / include / swift / AST / Import . h <nl> ppp b / include / swift / AST / Import . h <nl> enum class ImplicitStdlibKind { <nl> Stdlib <nl> } ; <nl> <nl> + / / / Represents unprocessed options for implicit imports . <nl> struct ImplicitImportInfo { <nl> / / / The implicit stdlib to import . <nl> ImplicitStdlibKind StdlibKind ; <nl> struct ImplicitImportInfo { <nl> ShouldImportUnderlyingModule ( false ) { } <nl> } ; <nl> <nl> + / / / Contains names of and pointers to modules that must be implicitly imported . <nl> + struct ImplicitImportList { <nl> + ArrayRef < ImplicitImport > imports ; <nl> + <nl> + friend bool operator = = ( const ImplicitImportList & lhs , <nl> + const ImplicitImportList & rhs ) { <nl> + return lhs . imports = = rhs . imports ; <nl> + } <nl> + } ; <nl> + <nl> + / / / A list of modules to implicitly import . <nl> + void simple_display ( llvm : : raw_ostream & out , <nl> + const ImplicitImportList & importList ) ; <nl> + <nl> } <nl> <nl> / / MARK : - DenseMapInfo <nl> mmm a / include / swift / AST / Module . h <nl> ppp b / include / swift / AST / Module . h <nl> namespace swift { <nl> class FuncDecl ; <nl> class InfixOperatorDecl ; <nl> class LinkLibrary ; <nl> - struct ImplicitImport ; <nl> class ModuleLoader ; <nl> class NominalTypeDecl ; <nl> class EnumElementDecl ; <nl> class ModuleDecl : public DeclContext , public TypeDecl { <nl> <nl> / / / Retrieve a list of modules that each file of this module implicitly <nl> / / / imports . <nl> - ArrayRef < ImplicitImport > getImplicitImports ( ) const ; <nl> + ImplicitImportList getImplicitImports ( ) const ; <nl> <nl> ArrayRef < FileUnit * > getFiles ( ) { <nl> assert ( ! Files . empty ( ) | | failedToLoad ( ) ) ; <nl> mmm a / include / swift / AST / TypeCheckRequests . h <nl> ppp b / include / swift / AST / TypeCheckRequests . h <nl> class SimpleDidSetRequest <nl> / / / of a given module . <nl> class ModuleImplicitImportsRequest <nl> : public SimpleRequest < ModuleImplicitImportsRequest , <nl> - ArrayRef < ImplicitImport > ( ModuleDecl * ) , <nl> + ImplicitImportList ( ModuleDecl * ) , <nl> RequestFlags : : Cached > { <nl> public : <nl> using SimpleRequest : : SimpleRequest ; <nl> class ModuleImplicitImportsRequest <nl> private : <nl> friend SimpleRequest ; <nl> <nl> - ArrayRef < ImplicitImport > <nl> - evaluate ( Evaluator & evaluator , ModuleDecl * module ) const ; <nl> + ImplicitImportList evaluate ( Evaluator & evaluator , ModuleDecl * module ) const ; <nl> <nl> public : <nl> / / Cached . <nl> mmm a / include / swift / AST / TypeCheckerTypeIDZone . def <nl> ppp b / include / swift / AST / TypeCheckerTypeIDZone . def <nl> SWIFT_REQUEST ( TypeChecker , ValidatePrecedenceGroupRequest , <nl> SWIFT_REQUEST ( TypeChecker , MangleLocalTypeDeclRequest , <nl> std : : string ( const TypeDecl * ) , Cached , NoLocationInfo ) <nl> SWIFT_REQUEST ( TypeChecker , ModuleImplicitImportsRequest , <nl> - ArrayRef < ImplicitImport > ( ModuleDecl * ) , Cached , NoLocationInfo ) <nl> + ImplicitImportList ( ModuleDecl * ) , Cached , NoLocationInfo ) <nl> SWIFT_REQUEST ( TypeChecker , NamingPatternRequest , <nl> NamedPattern * ( VarDecl * ) , SeparatelyCached , NoLocationInfo ) <nl> SWIFT_REQUEST ( TypeChecker , OpaqueReadOwnershipRequest , <nl> mmm a / lib / AST / Module . cpp <nl> ppp b / lib / AST / Module . cpp <nl> ModuleDecl : : ModuleDecl ( Identifier name , ASTContext & ctx , <nl> Bits . ModuleDecl . HasIncrementalInfo = 0 ; <nl> } <nl> <nl> - ArrayRef < ImplicitImport > ModuleDecl : : getImplicitImports ( ) const { <nl> + ImplicitImportList ModuleDecl : : getImplicitImports ( ) const { <nl> auto & evaluator = getASTContext ( ) . evaluator ; <nl> auto * mutableThis = const_cast < ModuleDecl * > ( this ) ; <nl> return evaluateOrDefault ( evaluator , ModuleImplicitImportsRequest { mutableThis } , <nl> { } ) ; <nl> } <nl> <nl> - <nl> void ModuleDecl : : addFile ( FileUnit & newFile ) { <nl> / / If this is a LoadedFile , make sure it loaded without error . <nl> assert ( ! ( isa < LoadedFile > ( newFile ) & & <nl> mmm a / lib / AST / TypeCheckRequests . cpp <nl> ppp b / lib / AST / TypeCheckRequests . cpp <nl> void swift : : simple_display ( llvm : : raw_ostream & out , <nl> simple_display ( out , import . Module ) ; <nl> } <nl> <nl> + void swift : : simple_display ( llvm : : raw_ostream & out , <nl> + const ImplicitImportList & importList ) { <nl> + llvm : : interleaveComma ( importList . imports , out , <nl> + [ & ] ( const auto & import ) { <nl> + simple_display ( out , import ) ; <nl> + } ) ; <nl> + } <nl> + <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - / / <nl> / / ResolveTypeRequest computation . <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - / / <nl> mmm a / lib / Sema / ImportResolution . cpp <nl> ppp b / lib / Sema / ImportResolution . cpp <nl> class ImportResolver final : public DeclVisitor < ImportResolver > { <nl> addImplicitImports ( ) ; <nl> } <nl> <nl> - void addImplicitImports ( ) { <nl> - / / TODO : Support cross - module imports . <nl> - for ( auto & import : SF . getParentModule ( ) - > getImplicitImports ( ) ) { <nl> - assert ( ! ( SF . Kind = = SourceFileKind : : SIL & & <nl> - import . Module - > isStdlibModule ( ) ) ) ; <nl> - ImportedModule importedMod { ImportPath : : Access ( ) , import . Module } ; <nl> - boundImports . emplace_back ( importedMod , import . Options ) ; <nl> - } <nl> - } <nl> + void addImplicitImports ( ) ; <nl> <nl> / / / Retrieve the finalized imports . <nl> ArrayRef < AttributedImport < ImportedModule > > getFinishedImports ( ) const { <nl> UnboundImport : : getTopLevelModule ( ModuleDecl * M , SourceFile & SF ) { <nl> / / MARK : Implicit imports <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> - ArrayRef < ImplicitImport > <nl> + ImplicitImportList <nl> ModuleImplicitImportsRequest : : evaluate ( Evaluator & evaluator , <nl> ModuleDecl * module ) const { <nl> SmallVector < ImplicitImport , 4 > imports ; <nl> ModuleImplicitImportsRequest : : evaluate ( Evaluator & evaluator , <nl> } <nl> } <nl> <nl> - return ctx . AllocateCopy ( imports ) ; <nl> + return { ctx . AllocateCopy ( imports ) } ; <nl> + } <nl> + <nl> + void ImportResolver : : addImplicitImports ( ) { <nl> + auto implicitImports = SF . getParentModule ( ) - > getImplicitImports ( ) ; <nl> + <nl> + / / TODO : Support cross - module imports . <nl> + for ( auto & import : implicitImports . imports ) { <nl> + assert ( ! ( SF . Kind = = SourceFileKind : : SIL & & <nl> + import . Module - > isStdlibModule ( ) ) ) ; <nl> + ImportedModule importedMod { ImportPath : : Access ( ) , import . Module } ; <nl> + boundImports . emplace_back ( importedMod , import . Options ) ; <nl> + } <nl> } <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> | [ NFC ] Add type for ModuleDecl : : getImplicitImports ( ) | apple/swift | d55c5bd549fa17769c23be9708c33c8de9ed0ef1 | 2020-10-10T01:58:03Z |
mmm a / include / swift / Basic / Statistics . def <nl> ppp b / include / swift / Basic / Statistics . def <nl> FRONTEND_STATISTIC ( AST , NumPrefixOperators ) <nl> / / / Number of precedence groups in the AST context . <nl> FRONTEND_STATISTIC ( AST , NumPrecedenceGroups ) <nl> <nl> + / / / Number of precedence groups in the AST context . <nl> + FRONTEND_STATISTIC ( AST , NumStoredPropertiesQueries ) <nl> + <nl> / / / Number of full function bodies parsed . <nl> FRONTEND_STATISTIC ( Parse , NumFunctionsParsed ) <nl> <nl> mmm a / lib / AST / Decl . cpp <nl> ppp b / lib / AST / Decl . cpp <nl> void NominalTypeDecl : : addExtension ( ExtensionDecl * extension ) { <nl> <nl> auto NominalTypeDecl : : getStoredProperties ( bool skipInaccessible ) const <nl> - > StoredPropertyRange { <nl> + / / This should be called at most once per SIL instruction that accesses a <nl> + / / VarDecl . <nl> + / / <nl> + / / FIXME : Once VarDecl itself caches its field index , it should be called at <nl> + / / most once per finalized VarDecl . <nl> + if ( getASTContext ( ) . Stats ) <nl> + getASTContext ( ) . Stats - > getFrontendCounters ( ) . NumStoredPropertiesQueries + + ; <nl> + <nl> / / Clang - imported classes never have stored properties . <nl> if ( hasClangNode ( ) & & isa < ClassDecl > ( this ) ) <nl> return StoredPropertyRange ( DeclRange ( nullptr , nullptr ) , <nl> new file mode 100644 <nl> index 000000000000 . . 073aa24ba72d <nl> mmm / dev / null <nl> ppp b / validation - test / compiler_scale / lazy_class_props . gyb <nl> <nl> + / / RUN : % scale - test - O - - begin 5 - - end 21 - - step 5 - - select NumStoredPropertiesQueries % s <nl> + / / REQUIRES : OS = macosx <nl> + / / REQUIRES : asserts <nl> + / / <nl> + / / Single file with many stored properties . <nl> + / / <nl> + / / Check that SIL passes don ' t exhibit cubic behavior by repeatedly <nl> + / / asking for all the stored properties ( if the <nl> + / / NumStoredPropertiesQueries stat scales quadratically , then the <nl> + / / behavior is cubic ) . <nl> + <nl> + public class LazyProperties { <nl> + % for i in range ( N ) : <nl> + public lazy var prop $ { i } : String = { return " $ { i } " } ( ) <nl> + % end <nl> + } <nl> | Add a scale - test for VarDecl : : getStoredProperties . | apple/swift | 8f84429565a3c660cd005629413b3779fa2633b8 | 2019-05-13T23:54:55Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.