diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / src / mongo / db / commands / user_management_commands . cpp <nl> ppp b / src / mongo / db / commands / user_management_commands . cpp <nl> class CmdUsersInfo : public BasicCommand { <nl> / / to be stripped out <nl> BSONObjBuilder strippedUser ( usersArrayBuilder . subobjStart ( ) ) ; <nl> for ( const BSONElement & e : userDetails ) { <nl> - if ( ! args . showCredentials & & e . fieldNameStringData ( ) = = " credentials " ) { <nl> - continue ; <nl> - } <nl> - <nl> - if ( e . fieldNameStringData ( ) = = AuthorizationManager : : USER_ID_FIELD_NAME ) { <nl> + if ( ! args . showCredentials & & <nl> + ( e . fieldNameStringData ( ) = = " credentials " | | <nl> + e . fieldNameStringData ( ) = = AuthorizationManager : : USER_ID_FIELD_NAME ) ) { <nl> continue ; <nl> } <nl> <nl> | SERVER - 29182 : Ensure propagation of user ID in usersInfo | mongodb/mongo | ecfc54c1bcc110b95c6f5dfd71e99f27bcbafea3 | 2017-08-01T15:32:36Z |
mmm a / stdlib / public / runtime / HeapObject . cpp <nl> ppp b / stdlib / public / runtime / HeapObject . cpp <nl> using namespace swift ; <nl> # error " The runtime must be built with a compiler that supports swiftcall . " <nl> # endif <nl> <nl> - / / Check that the user isn ' t manually disabling SWIFTCALL . <nl> - # if defined ( SWIFT_USE_SWIFTCALL ) & & ! SWIFT_USE_SWIFTCALL <nl> - # error " SWIFT_USE_SWIFTCALL = 0 is not supported ; swiftcall must always be used . " <nl> - # endif <nl> - <nl> / / / Returns true if the pointer passed to a native retain or release is valid . <nl> / / / If false , the operation should immediately return . <nl> static inline bool isValidPointerForNativeRetain ( const void * p ) { <nl> | Merge pull request from compnerd / remove - SWIFT_USE_SWIFTCALL | apple/swift | 83c4df80453744833eada016c7601a110d98952d | 2018-02-04T17:53:27Z |
mmm a / lib / Zip / zip . cpp <nl> ppp b / lib / Zip / zip . cpp <nl> extern zipFile ZEXPORT zipOpen3 ( const void * pathname , int append , zipcharpc * gl <nl> return NULL ; <nl> } <nl> <nl> - memset ( & ziinit , 0 , sizeof ( zip64_internal ) ) ; <nl> + memset ( zi , 0 , sizeof ( zip64_internal ) ) ; <nl> <nl> / * now we add file in a zipfile * / <nl> # ifndef NO_ADDFILEINEXISTINGZIP <nl> | fix memset to null the proper pointer . | arangodb/arangodb | 220607e815d6bd7e9ff852baf9c0d9241a27552d | 2015-03-20T14:12:46Z |
mmm a / xbmc / video / VideoLibraryQueue . cpp <nl> ppp b / xbmc / video / VideoLibraryQueue . cpp <nl> void CVideoLibraryQueue : : StopLibraryScanning ( ) <nl> / / cancel all scanning jobs <nl> for ( VideoLibraryJobs : : const_iterator job = tmpScanningJobs . begin ( ) ; job ! = tmpScanningJobs . end ( ) ; + + job ) <nl> CancelJob ( * job ) ; <nl> + Refresh ( ) ; <nl> } <nl> <nl> void CVideoLibraryQueue : : CleanLibrary ( const std : : set < int > & paths / * = std : : set < int > ( ) * / , bool asynchronous / * = true * / , CGUIDialogProgressBarHandle * progressBar / * = NULL * / ) <nl> void CVideoLibraryQueue : : CleanLibrary ( const std : : set < int > & paths / * = std : : set < i <nl> <nl> delete cleaningJob ; <nl> m_cleaning = false ; <nl> + Refresh ( ) ; <nl> } <nl> } <nl> <nl> void CVideoLibraryQueue : : CleanLibraryModal ( const std : : set < int > & paths / * = std : : <nl> CVideoLibraryCleaningJob cleaningJob ( paths , true ) ; <nl> cleaningJob . DoWork ( ) ; <nl> m_cleaning = false ; <nl> + Refresh ( ) ; <nl> } <nl> <nl> void CVideoLibraryQueue : : MarkAsWatched ( const CFileItemPtr & item , bool watched ) <nl> bool CVideoLibraryQueue : : IsRunning ( ) const <nl> return CJobQueue : : IsProcessing ( ) | | m_cleaning ; <nl> } <nl> <nl> + void CVideoLibraryQueue : : Refresh ( ) <nl> + { <nl> + CUtil : : DeleteVideoDatabaseDirectoryCache ( ) ; <nl> + CGUIMessage msg ( GUI_MSG_NOTIFY_ALL , 0 , 0 , GUI_MSG_UPDATE ) ; <nl> + g_windowManager . SendThreadMessage ( msg ) ; <nl> + } <nl> + <nl> void CVideoLibraryQueue : : OnJobComplete ( unsigned int jobID , bool success , CJob * job ) <nl> { <nl> if ( success ) <nl> { <nl> if ( QueueEmpty ( ) ) <nl> - { <nl> - CUtil : : DeleteVideoDatabaseDirectoryCache ( ) ; <nl> - CGUIMessage msg ( GUI_MSG_NOTIFY_ALL , 0 , 0 , GUI_MSG_UPDATE ) ; <nl> - g_windowManager . SendThreadMessage ( msg ) ; <nl> - } <nl> + Refresh ( ) ; <nl> } <nl> <nl> { <nl> mmm a / xbmc / video / VideoLibraryQueue . h <nl> ppp b / xbmc / video / VideoLibraryQueue . h <nl> class CVideoLibraryQueue : protected CJobQueue <nl> / / implementation of IJobCallback <nl> virtual void OnJobComplete ( unsigned int jobID , bool success , CJob * job ) ; <nl> <nl> + / * ! <nl> + \ brief Notifies all to refresh the current listings . <nl> + * / <nl> + void Refresh ( ) ; <nl> + <nl> private : <nl> CVideoLibraryQueue ( ) ; <nl> CVideoLibraryQueue ( const CVideoLibraryQueue & ) ; <nl> | Merge pull request from mkortstiege / videoqueue_refresh | xbmc/xbmc | 09cb8a2acd3f74171f17e82fa01dfdb8cc1cd4fc | 2015-03-14T15:41:57Z |
mmm a / src / mongo / db / auth / authorization_manager . cpp <nl> ppp b / src / mongo / db / auth / authorization_manager . cpp <nl> namespace { <nl> <nl> AuthorizationManager : : AuthorizationManager ( AuthzManagerExternalState * externalState ) : <nl> _externalState ( externalState ) { <nl> - setAuthorizationVersion ( 1 ) ; <nl> + setAuthorizationVersion ( 2 ) ; <nl> } <nl> <nl> AuthorizationManager : : ~ AuthorizationManager ( ) { <nl> | SERVER - 9517 Make default authorization version 2 | mongodb/mongo | 1b8b6b67ce650b4a8ce5c8df53fe20bcf50ed16a | 2013-09-06T16:31:22Z |
mmm a / BUILD . gn <nl> ppp b / BUILD . gn <nl> source_set ( " v8_base " ) { <nl> " src / heap / mark - compact - inl . h " , <nl> " src / heap / mark - compact . cc " , <nl> " src / heap / mark - compact . h " , <nl> + " src / heap / memory - reducer . cc " , <nl> + " src / heap / memory - reducer . h " , <nl> " src / heap / objects - visiting - inl . h " , <nl> " src / heap / objects - visiting . cc " , <nl> " src / heap / objects - visiting . h " , <nl> mmm a / src / heap / gc - idle - time - handler . cc <nl> ppp b / src / heap / gc - idle - time - handler . cc <nl> void GCIdleTimeHandler : : HeapState : : Print ( ) { <nl> PrintF ( " contexts_disposal_rate = % f " , contexts_disposal_rate ) ; <nl> PrintF ( " size_of_objects = % " V8_PTR_PREFIX " d " , size_of_objects ) ; <nl> PrintF ( " incremental_marking_stopped = % d " , incremental_marking_stopped ) ; <nl> - PrintF ( " can_start_incremental_marking = % d " , can_start_incremental_marking ) ; <nl> PrintF ( " sweeping_in_progress = % d " , sweeping_in_progress ) ; <nl> PrintF ( " has_low_allocation_rate = % d " , has_low_allocation_rate ) ; <nl> PrintF ( " mark_compact_speed = % " V8_PTR_PREFIX " d " , <nl> bool GCIdleTimeHandler : : ShouldDoOverApproximateWeakClosure ( <nl> <nl> <nl> GCIdleTimeAction GCIdleTimeHandler : : NothingOrDone ( ) { <nl> - if ( idle_times_which_made_no_progress_per_mode_ > = <nl> - kMaxNoProgressIdleTimesPerMode ) { <nl> + if ( idle_times_which_made_no_progress_ > = kMaxNoProgressIdleTimes ) { <nl> return GCIdleTimeAction : : Done ( ) ; <nl> } else { <nl> - idle_times_which_made_no_progress_per_mode_ + + ; <nl> + idle_times_which_made_no_progress_ + + ; <nl> return GCIdleTimeAction : : Nothing ( ) ; <nl> } <nl> } <nl> <nl> <nl> - / / The idle time handler has three modes and transitions between them <nl> - / / as shown in the diagram : <nl> - / / <nl> - / / kReduceLatency mmm - - > kReduceMemory mmm - - > kDone <nl> - / / ^ ^ | | <nl> - / / | | | | <nl> - / / | + mmmmmmmmmmmmmmmmmm + | <nl> - / / | | <nl> - / / + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> - / / <nl> - / / In kReduceLatency mode the handler only starts incremental marking <nl> - / / if can_start_incremental_marking is false . <nl> - / / In kReduceMemory mode the handler can force a new GC cycle by starting <nl> - / / incremental marking even if can_start_incremental_marking is false . It can <nl> - / / cause at most X idle GCs . <nl> - / / In kDone mode the idle time handler does nothing . <nl> - / / <nl> - / / The initial mode is kReduceLatency . <nl> - / / <nl> - / / kReduceLatency = > kReduceMemory transition happens if there were Y <nl> - / / consecutive long idle notifications without any mutator GC . This is our <nl> - / / notion of " mutator is idle " . <nl> - / / <nl> - / / kReduceMemory = > kDone transition happens after X idle GCs . <nl> - / / <nl> - / / kReduceMemory = > kReduceLatency transition happens if N mutator GCs <nl> - / / were performed meaning that the mutator is active . <nl> - / / <nl> - / / kDone = > kReduceLatency transition happens if there were M mutator GCs or <nl> - / / context was disposed . <nl> - / / <nl> - / / X = kMaxIdleMarkCompacts <nl> - / / Y = kLongIdleNotificationsBeforeMutatorIsIdle <nl> - / / N = # ( idle GCs ) <nl> - / / M = kGCsBeforeMutatorIsActive <nl> - GCIdleTimeAction GCIdleTimeHandler : : Compute ( double idle_time_in_ms , <nl> - HeapState heap_state ) { <nl> - Mode next_mode = NextMode ( heap_state ) ; <nl> - <nl> - if ( next_mode ! = mode_ ) { <nl> - mode_ = next_mode ; <nl> - ResetCounters ( ) ; <nl> - } <nl> - <nl> - UpdateCounters ( idle_time_in_ms ) ; <nl> - <nl> - if ( mode_ = = kDone ) { <nl> - return GCIdleTimeAction : : Done ( ) ; <nl> - } else { <nl> - return Action ( idle_time_in_ms , heap_state , mode_ = = kReduceMemory ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> / / The following logic is implemented by the controller : <nl> / / ( 1 ) If we don ' t have any idle time , do nothing , unless a context was <nl> / / disposed , incremental marking is stopped , and the heap is small . Then do <nl> GCIdleTimeAction GCIdleTimeHandler : : Compute ( double idle_time_in_ms , <nl> / / we do nothing until the context disposal rate becomes lower . <nl> / / ( 3 ) If the new space is almost full and we can affort a scavenge or if the <nl> / / next scavenge will very likely take long , then a scavenge is performed . <nl> - / / ( 4 ) If there is currently no MarkCompact idle round going on , we start a <nl> - / / new idle round if enough garbage was created . Otherwise we do not perform <nl> - / / garbage collection to keep system utilization low . <nl> - / / ( 5 ) If incremental marking is done , we perform a full garbage collection <nl> - / / if we are allowed to still do full garbage collections during this idle <nl> - / / round or if we are not allowed to start incremental marking . Otherwise we <nl> - / / do not perform garbage collection to keep system utilization low . <nl> - / / ( 6 ) If sweeping is in progress and we received a large enough idle time <nl> + / / ( 4 ) If sweeping is in progress and we received a large enough idle time <nl> / / request , we finalize sweeping here . <nl> - / / ( 7 ) If incremental marking is in progress , we perform a marking step . Note , <nl> + / / ( 5 ) If incremental marking is in progress , we perform a marking step . Note , <nl> / / that this currently may trigger a full garbage collection . <nl> - GCIdleTimeAction GCIdleTimeHandler : : Action ( double idle_time_in_ms , <nl> - const HeapState & heap_state , <nl> - bool reduce_memory ) { <nl> + GCIdleTimeAction GCIdleTimeHandler : : Compute ( double idle_time_in_ms , <nl> + HeapState heap_state ) { <nl> if ( static_cast < int > ( idle_time_in_ms ) < = 0 ) { <nl> if ( heap_state . incremental_marking_stopped ) { <nl> if ( ShouldDoContextDisposalMarkCompact ( <nl> heap_state . contexts_disposed , <nl> heap_state . contexts_disposal_rate ) ) { <nl> - return GCIdleTimeAction : : FullGC ( false ) ; <nl> + return GCIdleTimeAction : : FullGC ( ) ; <nl> } <nl> } <nl> return GCIdleTimeAction : : Nothing ( ) ; <nl> GCIdleTimeAction GCIdleTimeHandler : : Action ( double idle_time_in_ms , <nl> return GCIdleTimeAction : : Scavenge ( ) ; <nl> } <nl> <nl> - if ( heap_state . incremental_marking_stopped & & reduce_memory ) { <nl> - if ( ShouldDoMarkCompact ( static_cast < size_t > ( idle_time_in_ms ) , <nl> - heap_state . size_of_objects , <nl> - heap_state . mark_compact_speed_in_bytes_per_ms ) ) { <nl> - return GCIdleTimeAction : : FullGC ( reduce_memory ) ; <nl> - } <nl> - } <nl> - <nl> if ( heap_state . sweeping_in_progress ) { <nl> if ( heap_state . sweeping_completed ) { <nl> return GCIdleTimeAction : : FinalizeSweeping ( ) ; <nl> GCIdleTimeAction GCIdleTimeHandler : : Action ( double idle_time_in_ms , <nl> } <nl> } <nl> <nl> - if ( ! FLAG_incremental_marking | | <nl> - ( heap_state . incremental_marking_stopped & & <nl> - ! heap_state . can_start_incremental_marking & & ! reduce_memory ) ) { <nl> - return NothingOrDone ( ) ; <nl> + if ( ! FLAG_incremental_marking | | heap_state . incremental_marking_stopped ) { <nl> + return GCIdleTimeAction : : Done ( ) ; <nl> } <nl> <nl> size_t step_size = EstimateMarkingStepSize ( <nl> static_cast < size_t > ( kIncrementalMarkingStepTimeInMs ) , <nl> heap_state . incremental_marking_speed_in_bytes_per_ms ) ; <nl> - return GCIdleTimeAction : : IncrementalMarking ( step_size , reduce_memory ) ; <nl> + return GCIdleTimeAction : : IncrementalMarking ( step_size ) ; <nl> } <nl> <nl> <nl> - void GCIdleTimeHandler : : UpdateCounters ( double idle_time_in_ms ) { <nl> - if ( mode_ = = kReduceLatency ) { <nl> - int gcs = scavenges_ + mark_compacts_ ; <nl> - if ( gcs > 0 ) { <nl> - / / There was a GC since the last notification . <nl> - long_idle_notifications_ = 0 ; <nl> - background_idle_notifications_ = 0 ; <nl> - } <nl> - idle_mark_compacts_ = 0 ; <nl> - mark_compacts_ = 0 ; <nl> - scavenges_ = 0 ; <nl> - if ( idle_time_in_ms > = kMinBackgroundIdleTime ) { <nl> - background_idle_notifications_ + + ; <nl> - } else if ( idle_time_in_ms > = kMinLongIdleTime ) { <nl> - long_idle_notifications_ + + ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - <nl> - void GCIdleTimeHandler : : ResetCounters ( ) { <nl> - long_idle_notifications_ = 0 ; <nl> - background_idle_notifications_ = 0 ; <nl> - idle_mark_compacts_ = 0 ; <nl> - mark_compacts_ = 0 ; <nl> - scavenges_ = 0 ; <nl> - idle_times_which_made_no_progress_per_mode_ = 0 ; <nl> - } <nl> - <nl> - <nl> - bool GCIdleTimeHandler : : IsMutatorActive ( int contexts_disposed , <nl> - int mark_compacts ) { <nl> - return contexts_disposed > 0 | | <nl> - mark_compacts > = kMarkCompactsBeforeMutatorIsActive ; <nl> - } <nl> - <nl> - <nl> - bool GCIdleTimeHandler : : IsMutatorIdle ( int long_idle_notifications , <nl> - int background_idle_notifications , <nl> - int mutator_gcs ) { <nl> - return mutator_gcs = = 0 & & <nl> - ( long_idle_notifications > = <nl> - kLongIdleNotificationsBeforeMutatorIsIdle | | <nl> - background_idle_notifications > = <nl> - kBackgroundIdleNotificationsBeforeMutatorIsIdle ) ; <nl> - } <nl> - <nl> - <nl> - GCIdleTimeHandler : : Mode GCIdleTimeHandler : : NextMode ( <nl> - const HeapState & heap_state ) { <nl> - DCHECK ( mark_compacts_ > = idle_mark_compacts_ ) ; <nl> - int mutator_gcs = scavenges_ + mark_compacts_ - idle_mark_compacts_ ; <nl> - switch ( mode_ ) { <nl> - case kDone : <nl> - DCHECK ( idle_mark_compacts_ = = 0 ) ; <nl> - if ( IsMutatorActive ( heap_state . contexts_disposed , mark_compacts_ ) ) { <nl> - return kReduceLatency ; <nl> - } <nl> - break ; <nl> - case kReduceLatency : <nl> - if ( IsMutatorIdle ( long_idle_notifications_ , <nl> - background_idle_notifications_ , mutator_gcs ) ) { <nl> - return kReduceMemory ; <nl> - } <nl> - break ; <nl> - case kReduceMemory : <nl> - if ( idle_mark_compacts_ > = kMaxIdleMarkCompacts | | <nl> - ( idle_mark_compacts_ > 0 & & ! next_gc_likely_to_collect_more_ ) ) { <nl> - return kDone ; <nl> - } <nl> - if ( mutator_gcs > idle_mark_compacts_ ) { <nl> - return kReduceLatency ; <nl> - } <nl> - break ; <nl> - } <nl> - return mode_ ; <nl> - } <nl> } <nl> } <nl> mmm a / src / heap / gc - idle - time - handler . h <nl> ppp b / src / heap / gc - idle - time - handler . h <nl> class GCIdleTimeAction { <nl> result . type = DONE ; <nl> result . parameter = 0 ; <nl> result . additional_work = false ; <nl> - result . reduce_memory = false ; <nl> return result ; <nl> } <nl> <nl> class GCIdleTimeAction { <nl> result . type = DO_NOTHING ; <nl> result . parameter = 0 ; <nl> result . additional_work = false ; <nl> - result . reduce_memory = false ; <nl> return result ; <nl> } <nl> <nl> - static GCIdleTimeAction IncrementalMarking ( intptr_t step_size , <nl> - bool reduce_memory ) { <nl> + static GCIdleTimeAction IncrementalMarking ( intptr_t step_size ) { <nl> GCIdleTimeAction result ; <nl> result . type = DO_INCREMENTAL_MARKING ; <nl> result . parameter = step_size ; <nl> result . additional_work = false ; <nl> - result . reduce_memory = reduce_memory ; <nl> return result ; <nl> } <nl> <nl> class GCIdleTimeAction { <nl> result . type = DO_SCAVENGE ; <nl> result . parameter = 0 ; <nl> result . additional_work = false ; <nl> - / / TODO ( ulan ) : add reduce_memory argument and shrink new space size if <nl> - / / reduce_memory = true . <nl> - result . reduce_memory = false ; <nl> return result ; <nl> } <nl> <nl> - static GCIdleTimeAction FullGC ( bool reduce_memory ) { <nl> + static GCIdleTimeAction FullGC ( ) { <nl> GCIdleTimeAction result ; <nl> result . type = DO_FULL_GC ; <nl> result . parameter = 0 ; <nl> result . additional_work = false ; <nl> - result . reduce_memory = reduce_memory ; <nl> return result ; <nl> } <nl> <nl> class GCIdleTimeAction { <nl> result . type = DO_FINALIZE_SWEEPING ; <nl> result . parameter = 0 ; <nl> result . additional_work = false ; <nl> - result . reduce_memory = false ; <nl> return result ; <nl> } <nl> <nl> class GCIdleTimeAction { <nl> GCIdleTimeActionType type ; <nl> intptr_t parameter ; <nl> bool additional_work ; <nl> - bool reduce_memory ; <nl> } ; <nl> <nl> <nl> class GCIdleTimeHandler { <nl> / / The maximum idle time when frames are rendered is 16 . 66ms . <nl> static const size_t kMaxFrameRenderingIdleTime = 17 ; <nl> <nl> + static const int kMinBackgroundIdleTime = 900 ; <nl> + <nl> / / We conservatively assume that in the next kTimeUntilNextIdleEvent ms <nl> / / no idle notification happens . <nl> static const size_t kTimeUntilNextIdleEvent = 100 ; <nl> class GCIdleTimeHandler { <nl> <nl> static const size_t kMinTimeForOverApproximatingWeakClosureInMs ; <nl> <nl> - / / The number of idle MarkCompact GCs to perform before transitioning to <nl> - / / the kDone mode . <nl> - static const int kMaxIdleMarkCompacts = 3 ; <nl> - <nl> - / / The number of mutator MarkCompact GCs before transitioning to the <nl> - / / kReduceLatency mode . <nl> - static const int kMarkCompactsBeforeMutatorIsActive = 1 ; <nl> - <nl> - / / Mutator is considered idle if <nl> - / / 1 ) there are N idle notification with time > = kMinBackgroundIdleTime , <nl> - / / 2 ) or there are M idle notifications with time > = kMinLongIdleTime <nl> - / / without any mutator GC in between . <nl> - / / Where N = kBackgroundIdleNotificationsBeforeMutatorIsIdle , <nl> - / / M = kLongIdleNotificationsBeforeMutatorIsIdle <nl> - static const int kMinLongIdleTime = kMaxFrameRenderingIdleTime + 1 ; <nl> - static const int kMinBackgroundIdleTime = 900 ; <nl> - static const int kBackgroundIdleNotificationsBeforeMutatorIsIdle = 2 ; <nl> - static const int kLongIdleNotificationsBeforeMutatorIsIdle = 50 ; <nl> / / Number of times we will return a Nothing action in the current mode <nl> / / despite having idle time available before we returning a Done action to <nl> / / ensure we don ' t keep scheduling idle tasks and making no progress . <nl> - static const int kMaxNoProgressIdleTimesPerMode = 10 ; <nl> + static const int kMaxNoProgressIdleTimes = 10 ; <nl> <nl> class HeapState { <nl> public : <nl> class GCIdleTimeHandler { <nl> double contexts_disposal_rate ; <nl> size_t size_of_objects ; <nl> bool incremental_marking_stopped ; <nl> - bool can_start_incremental_marking ; <nl> bool sweeping_in_progress ; <nl> bool sweeping_completed ; <nl> bool has_low_allocation_rate ; <nl> class GCIdleTimeHandler { <nl> size_t new_space_allocation_throughput_in_bytes_per_ms ; <nl> } ; <nl> <nl> - GCIdleTimeHandler ( ) <nl> - : idle_mark_compacts_ ( 0 ) , <nl> - mark_compacts_ ( 0 ) , <nl> - scavenges_ ( 0 ) , <nl> - long_idle_notifications_ ( 0 ) , <nl> - background_idle_notifications_ ( 0 ) , <nl> - idle_times_which_made_no_progress_per_mode_ ( 0 ) , <nl> - next_gc_likely_to_collect_more_ ( false ) , <nl> - mode_ ( kReduceLatency ) { } <nl> + GCIdleTimeHandler ( ) : idle_times_which_made_no_progress_ ( 0 ) { } <nl> <nl> GCIdleTimeAction Compute ( double idle_time_in_ms , HeapState heap_state ) ; <nl> <nl> - void NotifyIdleMarkCompact ( ) { + + idle_mark_compacts_ ; } <nl> - <nl> - void NotifyMarkCompact ( bool next_gc_likely_to_collect_more ) { <nl> - next_gc_likely_to_collect_more_ = next_gc_likely_to_collect_more ; <nl> - + + mark_compacts_ ; <nl> - } <nl> - <nl> - void NotifyScavenge ( ) { + + scavenges_ ; } <nl> + void ResetNoProgressCounter ( ) { idle_times_which_made_no_progress_ = 0 ; } <nl> <nl> static size_t EstimateMarkingStepSize ( size_t idle_time_in_ms , <nl> size_t marking_speed_in_bytes_per_ms ) ; <nl> class GCIdleTimeHandler { <nl> size_t scavenger_speed_in_bytes_per_ms , <nl> size_t new_space_allocation_throughput_in_bytes_per_ms ) ; <nl> <nl> - enum Mode { kReduceLatency , kReduceMemory , kDone } ; <nl> - <nl> - Mode mode ( ) { return mode_ ; } <nl> - <nl> private : <nl> - bool IsMutatorActive ( int contexts_disposed , int gcs ) ; <nl> - bool IsMutatorIdle ( int long_idle_notifications , <nl> - int background_idle_notifications , int gcs ) ; <nl> - void UpdateCounters ( double idle_time_in_ms ) ; <nl> - void ResetCounters ( ) ; <nl> - Mode NextMode ( const HeapState & heap_state ) ; <nl> - GCIdleTimeAction Action ( double idle_time_in_ms , const HeapState & heap_state , <nl> - bool reduce_memory ) ; <nl> GCIdleTimeAction NothingOrDone ( ) ; <nl> <nl> - int idle_mark_compacts_ ; <nl> - int mark_compacts_ ; <nl> - int scavenges_ ; <nl> - / / The number of long idle notifications with no GC happening <nl> - / / between the notifications . <nl> - int long_idle_notifications_ ; <nl> - / / The number of background idle notifications with no GC happening <nl> - / / between the notifications . <nl> - int background_idle_notifications_ ; <nl> - / / Idle notifications with no progress in the current mode . <nl> - int idle_times_which_made_no_progress_per_mode_ ; <nl> - <nl> - bool next_gc_likely_to_collect_more_ ; <nl> - <nl> - Mode mode_ ; <nl> + / / Idle notifications with no progress . <nl> + int idle_times_which_made_no_progress_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( GCIdleTimeHandler ) ; <nl> } ; <nl> mmm a / src / heap / heap . cc <nl> ppp b / src / heap / heap . cc <nl> <nl> # include " src / heap / gc - idle - time - handler . h " <nl> # include " src / heap / incremental - marking . h " <nl> # include " src / heap / mark - compact . h " <nl> + # include " src / heap / memory - reducer . h " <nl> # include " src / heap / objects - visiting - inl . h " <nl> # include " src / heap / objects - visiting . h " <nl> # include " src / heap / store - buffer . h " <nl> Heap : : Heap ( ) <nl> allocation_timeout_ ( 0 ) , <nl> # endif / / DEBUG <nl> old_generation_allocation_limit_ ( initial_old_generation_size_ ) , <nl> - idle_old_generation_allocation_limit_ ( <nl> - kMinimumOldGenerationAllocationLimit ) , <nl> old_gen_exhausted_ ( false ) , <nl> inline_allocation_disabled_ ( false ) , <nl> store_buffer_rebuilder_ ( store_buffer ( ) ) , <nl> Heap : : Heap ( ) <nl> store_buffer_ ( this ) , <nl> marking_ ( this ) , <nl> incremental_marking_ ( this ) , <nl> + memory_reducer_ ( this ) , <nl> full_codegen_bytes_generated_ ( 0 ) , <nl> crankshaft_codegen_bytes_generated_ ( 0 ) , <nl> new_space_allocation_counter_ ( 0 ) , <nl> bool Heap : : CollectGarbage ( GarbageCollector collector , const char * gc_reason , <nl> } <nl> <nl> bool next_gc_likely_to_collect_more = false ; <nl> + intptr_t committed_memory_before = 0 ; <nl> + <nl> + if ( collector = = MARK_COMPACTOR ) { <nl> + committed_memory_before = CommittedOldGenerationMemory ( ) ; <nl> + } <nl> <nl> { <nl> tracer ( ) - > Start ( collector , gc_reason , collector_reason ) ; <nl> bool Heap : : CollectGarbage ( GarbageCollector collector , const char * gc_reason , <nl> } <nl> <nl> if ( collector = = MARK_COMPACTOR ) { <nl> - gc_idle_time_handler_ . NotifyMarkCompact ( next_gc_likely_to_collect_more ) ; <nl> - } else { <nl> - gc_idle_time_handler_ . NotifyScavenge ( ) ; <nl> + intptr_t committed_memory_after = CommittedOldGenerationMemory ( ) ; <nl> + intptr_t used_memory_after = PromotedSpaceSizeOfObjects ( ) ; <nl> + MemoryReducer : : Event event ; <nl> + event . type = MemoryReducer : : kMarkCompact ; <nl> + event . time_ms = MonotonicallyIncreasingTimeInMs ( ) ; <nl> + / / Trigger one more GC if <nl> + / / - this GC decreased committed memory , <nl> + / / - there is high fragmentation , <nl> + / / - there are live detached contexts . <nl> + event . next_gc_likely_to_collect_more = <nl> + ( committed_memory_before - committed_memory_after ) > MB | | <nl> + HasHighFragmentation ( used_memory_after , committed_memory_after ) | | <nl> + ( detached_contexts ( ) - > length ( ) > 0 ) ; <nl> + memory_reducer_ . NotifyMarkCompact ( event ) ; <nl> } <nl> <nl> tracer ( ) - > Stop ( collector ) ; <nl> int Heap : : NotifyContextDisposed ( bool dependant_context ) { <nl> AgeInlineCaches ( ) ; <nl> set_retained_maps ( ArrayList : : cast ( empty_fixed_array ( ) ) ) ; <nl> tracer ( ) - > AddContextDisposalTime ( base : : OS : : TimeCurrentMillis ( ) ) ; <nl> + MemoryReducer : : Event event ; <nl> + event . type = MemoryReducer : : kContextDisposed ; <nl> + event . time_ms = MonotonicallyIncreasingTimeInMs ( ) ; <nl> + memory_reducer_ . NotifyContextDisposed ( event ) ; <nl> return + + contexts_disposed_ ; <nl> } <nl> <nl> <nl> + void Heap : : StartIdleIncrementalMarking ( ) { <nl> + gc_idle_time_handler_ . ResetNoProgressCounter ( ) ; <nl> + incremental_marking ( ) - > Start ( kReduceMemoryFootprintMask ) ; <nl> + } <nl> + <nl> + <nl> void Heap : : MoveElements ( FixedArray * array , int dst_index , int src_index , <nl> int len ) { <nl> if ( len = = 0 ) return ; <nl> bool Heap : : HasLowAllocationRate ( ) { <nl> } <nl> <nl> <nl> + bool Heap : : HasHighFragmentation ( ) { <nl> + intptr_t used = PromotedSpaceSizeOfObjects ( ) ; <nl> + intptr_t committed = CommittedOldGenerationMemory ( ) ; <nl> + return HasHighFragmentation ( used , committed ) ; <nl> + } <nl> + <nl> + <nl> + bool Heap : : HasHighFragmentation ( intptr_t used , intptr_t committed ) { <nl> + const intptr_t kSlack = 16 * MB ; <nl> + / / Fragmentation is high if committed > 2 * used + kSlack . <nl> + / / Rewrite the exression to avoid overflow . <nl> + return committed - used > used + kSlack ; <nl> + } <nl> + <nl> + <nl> void Heap : : ReduceNewSpaceSize ( ) { <nl> if ( ! FLAG_predictable & & HasLowAllocationRate ( ) ) { <nl> new_space_ . Shrink ( ) ; <nl> bool Heap : : TryFinalizeIdleIncrementalMarking ( <nl> static_cast < size_t > ( idle_time_in_ms ) , size_of_objects , <nl> final_incremental_mark_compact_speed_in_bytes_per_ms ) ) ) { <nl> CollectAllGarbage ( kNoGCFlags , " idle notification : finalize incremental " ) ; <nl> - gc_idle_time_handler_ . NotifyIdleMarkCompact ( ) ; <nl> return true ; <nl> } <nl> return false ; <nl> GCIdleTimeHandler : : HeapState Heap : : ComputeHeapState ( ) { <nl> heap_state . new_space_capacity = new_space_ . Capacity ( ) ; <nl> heap_state . new_space_allocation_throughput_in_bytes_per_ms = <nl> tracer ( ) - > NewSpaceAllocationThroughputInBytesPerMillisecond ( ) ; <nl> - heap_state . has_low_allocation_rate = HasLowAllocationRate ( ) ; <nl> - intptr_t limit = old_generation_allocation_limit_ ; <nl> - if ( heap_state . has_low_allocation_rate ) { <nl> - limit = idle_old_generation_allocation_limit_ ; <nl> - } <nl> - heap_state . can_start_incremental_marking = <nl> - incremental_marking ( ) - > CanBeActivated ( ) & & <nl> - HeapIsFullEnoughToStartIncrementalMarking ( limit ) & & <nl> - ! mark_compact_collector ( ) - > sweeping_in_progress ( ) ; <nl> return heap_state ; <nl> } <nl> <nl> bool Heap : : PerformIdleTimeAction ( GCIdleTimeAction action , <nl> result = true ; <nl> break ; <nl> case DO_INCREMENTAL_MARKING : { <nl> - if ( incremental_marking ( ) - > IsStopped ( ) ) { <nl> - incremental_marking ( ) - > Start ( <nl> - action . reduce_memory ? kReduceMemoryFootprintMask : kNoGCFlags ) ; <nl> - } <nl> + DCHECK ( ! incremental_marking ( ) - > IsStopped ( ) ) ; <nl> double remaining_idle_time_in_ms = 0 . 0 ; <nl> do { <nl> incremental_marking ( ) - > Step ( <nl> bool Heap : : PerformIdleTimeAction ( GCIdleTimeAction action , <nl> break ; <nl> } <nl> case DO_FULL_GC : { <nl> - if ( action . reduce_memory ) { <nl> - isolate_ - > compilation_cache ( ) - > Clear ( ) ; <nl> - } <nl> - if ( contexts_disposed_ ) { <nl> - HistogramTimerScope scope ( isolate_ - > counters ( ) - > gc_context ( ) ) ; <nl> - CollectAllGarbage ( kNoGCFlags , " idle notification : contexts disposed " ) ; <nl> - } else { <nl> - CollectAllGarbage ( kReduceMemoryFootprintMask , <nl> - " idle notification : finalize idle round " ) ; <nl> - } <nl> - gc_idle_time_handler_ . NotifyIdleMarkCompact ( ) ; <nl> + DCHECK ( contexts_disposed_ > 0 ) ; <nl> + HistogramTimerScope scope ( isolate_ - > counters ( ) - > gc_context ( ) ) ; <nl> + CollectAllGarbage ( kNoGCFlags , " idle notification : contexts disposed " ) ; <nl> break ; <nl> } <nl> case DO_SCAVENGE : <nl> void Heap : : SetOldGenerationAllocationLimit ( intptr_t old_gen_size , <nl> factor = kMinHeapGrowingFactor ; <nl> } <nl> <nl> - / / TODO ( hpayer ) : Investigate if idle_old_generation_allocation_limit_ is still <nl> - / / needed after taking the allocation rate for the old generation limit into <nl> - / / account . <nl> - double idle_factor = Min ( factor , kMaxHeapGrowingFactorIdle ) ; <nl> - <nl> old_generation_allocation_limit_ = <nl> CalculateOldGenerationAllocationLimit ( factor , old_gen_size ) ; <nl> - idle_old_generation_allocation_limit_ = <nl> - CalculateOldGenerationAllocationLimit ( idle_factor , old_gen_size ) ; <nl> <nl> if ( FLAG_trace_gc_verbose ) { <nl> - PrintIsolate ( <nl> - isolate_ , <nl> - " Grow : old size : % " V8_PTR_PREFIX " d KB , new limit : % " V8_PTR_PREFIX <nl> - " d KB ( % . 1f ) , new idle limit : % " V8_PTR_PREFIX " d KB ( % . 1f ) \ n " , <nl> - old_gen_size / KB , old_generation_allocation_limit_ / KB , factor , <nl> - idle_old_generation_allocation_limit_ / KB , idle_factor ) ; <nl> + PrintIsolate ( isolate_ , " Grow : old size : % " V8_PTR_PREFIX <nl> + " d KB , new limit : % " V8_PTR_PREFIX " d KB ( % . 1f ) \ n " , <nl> + old_gen_size / KB , old_generation_allocation_limit_ / KB , <nl> + factor ) ; <nl> } <nl> } <nl> <nl> mmm a / src / heap / heap . h <nl> ppp b / src / heap / heap . h <nl> <nl> # include " src / heap / gc - tracer . h " <nl> # include " src / heap / incremental - marking . h " <nl> # include " src / heap / mark - compact . h " <nl> + # include " src / heap / memory - reducer . h " <nl> # include " src / heap / objects - visiting . h " <nl> # include " src / heap / spaces . h " <nl> # include " src / heap / store - buffer . h " <nl> class Heap { <nl> / / Notify the heap that a context has been disposed . <nl> int NotifyContextDisposed ( bool dependant_context ) ; <nl> <nl> + / / Start incremental marking and ensure that idle time handler can perform <nl> + / / incremental steps . <nl> + void StartIdleIncrementalMarking ( ) ; <nl> + <nl> inline void increment_scan_on_scavenge_pages ( ) { <nl> scan_on_scavenge_pages_ + + ; <nl> if ( FLAG_gc_verbose ) { <nl> class Heap { <nl> / / An ArrayBuffer moved from new space to old space . <nl> void PromoteArrayBuffer ( Object * buffer ) ; <nl> <nl> + bool HasLowAllocationRate ( ) ; <nl> + bool HasHighFragmentation ( ) ; <nl> + bool HasHighFragmentation ( intptr_t used , intptr_t committed ) ; <nl> + <nl> protected : <nl> / / Methods made available to tests . <nl> <nl> class Heap { <nl> / / generation and on every allocation in large object space . <nl> intptr_t old_generation_allocation_limit_ ; <nl> <nl> - / / The allocation limit when there is > 16 . 66ms idle time in the idle time <nl> - / / handler . <nl> - intptr_t idle_old_generation_allocation_limit_ ; <nl> - <nl> / / Indicates that an allocation has failed in the old generation since the <nl> / / last GC . <nl> bool old_gen_exhausted_ ; <nl> class Heap { <nl> <nl> bool HasLowYoungGenerationAllocationRate ( ) ; <nl> bool HasLowOldGenerationAllocationRate ( ) ; <nl> - bool HasLowAllocationRate ( ) ; <nl> <nl> void ReduceNewSpaceSize ( ) ; <nl> <nl> class Heap { <nl> <nl> GCIdleTimeHandler gc_idle_time_handler_ ; <nl> <nl> + MemoryReducer memory_reducer_ ; <nl> + <nl> / / These two counters are monotomically increasing and never reset . <nl> size_t full_codegen_bytes_generated_ ; <nl> size_t crankshaft_codegen_bytes_generated_ ; <nl> new file mode 100644 <nl> index 00000000000 . . ff32809f9e0 <nl> mmm / dev / null <nl> ppp b / src / heap / memory - reducer . cc <nl> <nl> + / / Copyright 2015 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> + # include " src / heap / memory - reducer . h " <nl> + <nl> + # include " src / flags . h " <nl> + # include " src / heap / heap . h " <nl> + # include " src / utils . h " <nl> + # include " src / v8 . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + const int MemoryReducer : : kLongDelayMs = 5000 ; <nl> + const int MemoryReducer : : kShortDelayMs = 500 ; <nl> + const int MemoryReducer : : kMaxNumberOfGCs = 3 ; <nl> + <nl> + <nl> + void MemoryReducer : : TimerTask : : Run ( ) { <nl> + Heap * heap = memory_reducer_ - > heap ( ) ; <nl> + Event event ; <nl> + event . type = kTimer ; <nl> + event . time_ms = heap - > MonotonicallyIncreasingTimeInMs ( ) ; <nl> + event . low_allocation_rate = heap - > HasLowAllocationRate ( ) ; <nl> + event . can_start_incremental_gc = <nl> + heap - > incremental_marking ( ) - > IsStopped ( ) & & <nl> + heap - > incremental_marking ( ) - > CanBeActivated ( ) ; <nl> + memory_reducer_ - > NotifyTimer ( event ) ; <nl> + } <nl> + <nl> + <nl> + void MemoryReducer : : NotifyTimer ( const Event & event ) { <nl> + DCHECK_EQ ( kTimer , event . type ) ; <nl> + DCHECK_EQ ( kWait , state_ . action ) ; <nl> + state_ = Step ( state_ , event ) ; <nl> + if ( state_ . action = = kRun ) { <nl> + DCHECK ( heap ( ) - > incremental_marking ( ) - > IsStopped ( ) ) ; <nl> + DCHECK ( FLAG_incremental_marking ) ; <nl> + heap ( ) - > StartIdleIncrementalMarking ( ) ; <nl> + if ( FLAG_trace_gc_verbose ) { <nl> + PrintIsolate ( heap ( ) - > isolate ( ) , " Memory reducer : started GC # % d \ n " , <nl> + state_ . started_gcs ) ; <nl> + } <nl> + } else if ( state_ . action = = kWait ) { <nl> + / / Re - schedule the timer . <nl> + ScheduleTimer ( state_ . next_gc_start_ms - event . time_ms ) ; <nl> + if ( FLAG_trace_gc_verbose ) { <nl> + PrintIsolate ( heap ( ) - > isolate ( ) , " Memory reducer : waiting for % . f ms \ n " , <nl> + state_ . next_gc_start_ms - event . time_ms ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + <nl> + void MemoryReducer : : NotifyMarkCompact ( const Event & event ) { <nl> + DCHECK_EQ ( kMarkCompact , event . type ) ; <nl> + Action old_action = state_ . action ; <nl> + state_ = Step ( state_ , event ) ; <nl> + if ( old_action ! = kWait & & state_ . action = = kWait ) { <nl> + / / If we are transitioning to the WAIT state , start the timer . <nl> + ScheduleTimer ( state_ . next_gc_start_ms - event . time_ms ) ; <nl> + } <nl> + if ( old_action = = kRun ) { <nl> + if ( FLAG_trace_gc_verbose ) { <nl> + PrintIsolate ( heap ( ) - > isolate ( ) , " Memory reducer : finished GC # % d ( % s ) \ n " , <nl> + state_ . started_gcs , <nl> + state_ . action = = kWait ? " will do more " : " done " ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + <nl> + void MemoryReducer : : NotifyContextDisposed ( const Event & event ) { <nl> + DCHECK_EQ ( kContextDisposed , event . type ) ; <nl> + Action old_action = state_ . action ; <nl> + state_ = Step ( state_ , event ) ; <nl> + if ( old_action ! = kWait & & state_ . action = = kWait ) { <nl> + / / If we are transitioning to the WAIT state , start the timer . <nl> + ScheduleTimer ( state_ . next_gc_start_ms - event . time_ms ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / / For specification of this function see the comment for MemoryReducer class . <nl> + MemoryReducer : : State MemoryReducer : : Step ( const State & state , <nl> + const Event & event ) { <nl> + if ( ! FLAG_incremental_marking ) { <nl> + return State ( kDone , 0 , 0 ) ; <nl> + } <nl> + switch ( state . action ) { <nl> + case kDone : <nl> + if ( event . type = = kTimer ) { <nl> + return state ; <nl> + } else { <nl> + DCHECK ( event . type = = kContextDisposed | | event . type = = kMarkCompact ) ; <nl> + return State ( kWait , 0 , event . time_ms + kLongDelayMs ) ; <nl> + } <nl> + case kWait : <nl> + if ( event . type = = kContextDisposed ) { <nl> + return state ; <nl> + } else if ( event . type = = kTimer & & event . can_start_incremental_gc & & <nl> + event . low_allocation_rate ) { <nl> + if ( state . next_gc_start_ms < = event . time_ms ) { <nl> + return State ( kRun , state . started_gcs + 1 , 0 . 0 ) ; <nl> + } else { <nl> + return state ; <nl> + } <nl> + } else { <nl> + return State ( kWait , state . started_gcs , event . time_ms + kLongDelayMs ) ; <nl> + } <nl> + case kRun : <nl> + if ( event . type ! = kMarkCompact ) { <nl> + return state ; <nl> + } else { <nl> + if ( state . started_gcs < kMaxNumberOfGCs & & <nl> + ( event . next_gc_likely_to_collect_more | | state . started_gcs = = 1 ) ) { <nl> + return State ( kWait , state . started_gcs , event . time_ms + kShortDelayMs ) ; <nl> + } else { <nl> + return State ( kDone , 0 , 0 . 0 ) ; <nl> + } <nl> + } <nl> + } <nl> + UNREACHABLE ( ) ; <nl> + return State ( kDone , 0 , 0 ) ; / / Make the compiler happy . <nl> + } <nl> + <nl> + <nl> + void MemoryReducer : : ScheduleTimer ( double delay_ms ) { <nl> + DCHECK ( delay_ms > 0 ) ; <nl> + / / Leave some room for precision error in task scheduler . <nl> + const double kSlackMs = 100 ; <nl> + v8 : : Isolate * isolate = reinterpret_cast < v8 : : Isolate * > ( heap ( ) - > isolate ( ) ) ; <nl> + V8 : : GetCurrentPlatform ( ) - > CallDelayedOnForegroundThread ( <nl> + isolate , new MemoryReducer : : TimerTask ( this ) , <nl> + ( delay_ms + kSlackMs ) / 1000 . 0 ) ; <nl> + } <nl> + <nl> + } / / internal <nl> + } / / v8 <nl> new file mode 100644 <nl> index 00000000000 . . a9ba2980ad8 <nl> mmm / dev / null <nl> ppp b / src / heap / memory - reducer . h <nl> <nl> + / / Copyright 2015 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> + # ifndef V8_HEAP_memory_reducer_H <nl> + # define V8_HEAP_memory_reducer_H <nl> + <nl> + # include " include / v8 - platform . h " <nl> + # include " src / base / macros . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + class Heap ; <nl> + <nl> + <nl> + / / The goal of the MemoryReducer class is to detect transition of the mutator <nl> + / / from high allocation phase to low allocation phase and to collect potential <nl> + / / garbage created in the high allocation phase . <nl> + / / <nl> + / / The class implements an automaton with the following states and transitions . <nl> + / / <nl> + / / States : <nl> + / / - DONE <nl> + / / - WAIT < started_gcs > < next_gc_start_ms > <nl> + / / - RUN < started_gcs > <nl> + / / The < started_gcs > is an integer in range from 0 . . kMaxNumberOfGCs that stores <nl> + / / the number of GCs initiated by the MemoryReducer since it left the DONE <nl> + / / state . <nl> + / / The < next_gc_start_ms > is a double that stores the earliest time the next GC <nl> + / / can be initiated by the MemoryReducer . <nl> + / / The DONE state means that the MemoryReducer is not active . <nl> + / / The WAIT state means that the MemoryReducer is waiting for mutator allocation <nl> + / / rate to drop . The check for the allocation rate happens in the timer task <nl> + / / callback . <nl> + / / The RUN state means that the MemoryReducer started incremental marking and is <nl> + / / waiting for it to finish . Incremental marking steps are performed as usual <nl> + / / in the idle notification and in the mutator . <nl> + / / <nl> + / / Transitions : <nl> + / / DONE - > WAIT 0 ( now_ms + long_delay_ms ) happens : <nl> + / / - on context disposal , <nl> + / / - at the end of mark - compact GC initiated by the mutator . <nl> + / / This signals that there is potential garbage to be collected . <nl> + / / <nl> + / / WAIT n x - > WAIT n ( now_ms + long_delay_ms ) happens : <nl> + / / - on mark - compact GC initiated by the mutator , <nl> + / / - in the timer callback if the mutator allocation rate is high or <nl> + / / incremental GC is in progress . <nl> + / / <nl> + / / WAIT n x - > RUN ( n + 1 ) happens : <nl> + / / - in the timer callback if the mutator allocation rate is low <nl> + / / and now_ms > = x and there is no incremental GC in progress . <nl> + / / The MemoryReducer starts incremental marking on this transition . <nl> + / / <nl> + / / RUN n - > DONE happens : <nl> + / / - at end of the incremental GC initiated by the MemoryReducer if <nl> + / / ( n > 1 and there is no more garbage to be collected ) or <nl> + / / n = = kMaxNumberOfGCs . <nl> + / / RUN n - > WAIT n ( now_ms + short_delay_ms ) happens : <nl> + / / - at end of the incremental GC initiated by the MemoryReducer if <nl> + / / ( n = = 1 or there is more garbage to be collected ) and <nl> + / / n < kMaxNumberOfGCs . <nl> + / / <nl> + / / now_ms is the current time , long_delay_ms and short_delay_ms are constants . <nl> + class MemoryReducer { <nl> + public : <nl> + enum Action { kDone , kWait , kRun } ; <nl> + <nl> + struct State { <nl> + State ( Action action , int started_gcs , double next_gc_start_ms ) <nl> + : action ( action ) , <nl> + started_gcs ( started_gcs ) , <nl> + next_gc_start_ms ( next_gc_start_ms ) { } <nl> + Action action ; <nl> + int started_gcs ; <nl> + double next_gc_start_ms ; <nl> + } ; <nl> + <nl> + enum EventType { <nl> + kTimer , <nl> + kMarkCompact , <nl> + kContextDisposed , <nl> + } ; <nl> + <nl> + struct Event { <nl> + EventType type ; <nl> + double time_ms ; <nl> + bool low_allocation_rate ; <nl> + bool next_gc_likely_to_collect_more ; <nl> + bool can_start_incremental_gc ; <nl> + } ; <nl> + <nl> + explicit MemoryReducer ( Heap * heap ) : heap_ ( heap ) , state_ ( kDone , 0 , 0 . 0 ) { } <nl> + / / Callbacks . <nl> + void NotifyTimer ( const Event & event ) ; <nl> + void NotifyMarkCompact ( const Event & event ) ; <nl> + void NotifyScavenge ( const Event & event ) ; <nl> + void NotifyContextDisposed ( const Event & event ) ; <nl> + / / The step function that computes the next state from the current state and <nl> + / / the incoming event . <nl> + static State Step ( const State & state , const Event & event ) ; <nl> + / / Posts a timer task that will call NotifyTimer after the given delay . <nl> + void ScheduleTimer ( double delay_ms ) ; <nl> + <nl> + static const int kLongDelayMs ; <nl> + static const int kShortDelayMs ; <nl> + static const int kMaxNumberOfGCs ; <nl> + <nl> + Heap * heap ( ) { return heap_ ; } <nl> + <nl> + private : <nl> + class TimerTask : public v8 : : Task { <nl> + public : <nl> + explicit TimerTask ( MemoryReducer * memory_reducer ) <nl> + : memory_reducer_ ( memory_reducer ) { } <nl> + virtual ~ TimerTask ( ) { } <nl> + <nl> + private : <nl> + / / v8 : : Task overrides . <nl> + void Run ( ) override ; <nl> + MemoryReducer * memory_reducer_ ; <nl> + DISALLOW_COPY_AND_ASSIGN ( TimerTask ) ; <nl> + } ; <nl> + <nl> + Heap * heap_ ; <nl> + State state_ ; <nl> + <nl> + DISALLOW_COPY_AND_ASSIGN ( MemoryReducer ) ; <nl> + } ; <nl> + <nl> + } / / namespace internal <nl> + } / / namespace v8 <nl> + <nl> + # endif / / V8_HEAP_memory_reducer_H <nl> mmm a / test / cctest / test - api . cc <nl> ppp b / test / cctest / test - api . cc <nl> static void CreateGarbageInOldSpace ( ) { <nl> <nl> / / Test that idle notification can be handled and eventually collects garbage . <nl> TEST ( TestIdleNotification ) { <nl> + if ( ! i : : FLAG_incremental_marking ) return ; <nl> const intptr_t MB = 1024 * 1024 ; <nl> const double IdlePauseInSeconds = 1 . 0 ; <nl> LocalContext env ; <nl> TEST ( TestIdleNotification ) { <nl> CHECK_GT ( size_with_garbage , initial_size + MB ) ; <nl> bool finished = false ; <nl> for ( int i = 0 ; i < 200 & & ! finished ; i + + ) { <nl> + if ( i < 10 & & CcTest : : heap ( ) - > incremental_marking ( ) - > IsStopped ( ) ) { <nl> + CcTest : : heap ( ) - > StartIdleIncrementalMarking ( ) ; <nl> + } <nl> finished = env - > GetIsolate ( ) - > IdleNotificationDeadline ( <nl> ( v8 : : base : : TimeTicks : : HighResolutionNow ( ) . ToInternalValue ( ) / <nl> static_cast < double > ( v8 : : base : : Time : : kMicrosecondsPerSecond ) ) + <nl> mmm a / test / unittests / heap / gc - idle - time - handler - unittest . cc <nl> ppp b / test / unittests / heap / gc - idle - time - handler - unittest . cc <nl> class GCIdleTimeHandlerTest : public : : testing : : Test { <nl> result . contexts_disposal_rate = GCIdleTimeHandler : : kHighContextDisposalRate ; <nl> result . size_of_objects = kSizeOfObjects ; <nl> result . incremental_marking_stopped = false ; <nl> - result . can_start_incremental_marking = true ; <nl> result . sweeping_in_progress = false ; <nl> result . sweeping_completed = false ; <nl> result . mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed ; <nl> class GCIdleTimeHandlerTest : public : : testing : : Test { <nl> return result ; <nl> } <nl> <nl> - void TransitionToReduceMemoryMode ( <nl> - const GCIdleTimeHandler : : HeapState & heap_state ) { <nl> - handler ( ) - > NotifyScavenge ( ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceLatency , handler ( ) - > mode ( ) ) ; <nl> - double idle_time_ms = GCIdleTimeHandler : : kMinLongIdleTime ; <nl> - int limit = GCIdleTimeHandler : : kLongIdleNotificationsBeforeMutatorIsIdle ; <nl> - bool incremental = ! heap_state . incremental_marking_stopped | | <nl> - heap_state . can_start_incremental_marking ; <nl> - for ( int i = 0 ; i < limit ; i + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - if ( incremental ) { <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - } else { <nl> - EXPECT_TRUE ( DO_NOTHING = = action . type | | DONE = = action . type ) ; <nl> - } <nl> - } <nl> - handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceMemory , handler ( ) - > mode ( ) ) ; <nl> - } <nl> - <nl> - void TransitionToDoneMode ( const GCIdleTimeHandler : : HeapState & heap_state , <nl> - double idle_time_ms , <nl> - GCIdleTimeActionType expected ) { <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceMemory , handler ( ) - > mode ( ) ) ; <nl> - int limit = GCIdleTimeHandler : : kMaxIdleMarkCompacts ; <nl> - for ( int i = 0 ; i < limit ; i + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( expected , action . type ) ; <nl> - EXPECT_TRUE ( action . reduce_memory ) ; <nl> - handler ( ) - > NotifyMarkCompact ( true ) ; <nl> - handler ( ) - > NotifyIdleMarkCompact ( ) ; <nl> - } <nl> - handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kDone , handler ( ) - > mode ( ) ) ; <nl> - } <nl> - <nl> - void TransitionToReduceLatencyMode ( <nl> - const GCIdleTimeHandler : : HeapState & heap_state ) { <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kDone , handler ( ) - > mode ( ) ) ; <nl> - int limit = GCIdleTimeHandler : : kMarkCompactsBeforeMutatorIsActive ; <nl> - double idle_time_ms = GCIdleTimeHandler : : kMinLongIdleTime ; <nl> - for ( int i = 0 ; i < limit ; i + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DONE , action . type ) ; <nl> - handler ( ) - > NotifyMarkCompact ( true ) ; <nl> - } <nl> - handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceLatency , handler ( ) - > mode ( ) ) ; <nl> - } <nl> - <nl> static const size_t kSizeOfObjects = 100 * MB ; <nl> static const size_t kMarkCompactSpeed = 200 * KB ; <nl> static const size_t kMarkingSpeed = 200 * KB ; <nl> static const size_t kScavengeSpeed = 100 * KB ; <nl> static const size_t kNewSpaceCapacity = 1 * MB ; <nl> static const size_t kNewSpaceAllocationThroughput = 10 * KB ; <nl> - static const int kMaxNotifications = 1000 ; <nl> + static const int kMaxNotifications = 100 ; <nl> <nl> private : <nl> GCIdleTimeHandler handler_ ; <nl> TEST_F ( GCIdleTimeHandlerTest , ContextDisposeLowRate ) { <nl> heap_state . contexts_disposed = 1 ; <nl> heap_state . incremental_marking_stopped = true ; <nl> double idle_time_ms = 0 ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_NOTHING , action . type ) ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> + GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> + EXPECT_EQ ( DO_NOTHING , action . type ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , ContextDisposeHighRate ) { <nl> GCIdleTimeHandler : : kHighContextDisposalRate - 1 ; <nl> heap_state . incremental_marking_stopped = true ; <nl> double idle_time_ms = 0 ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_FULL_GC , action . type ) ; <nl> - heap_state . contexts_disposal_rate = 0 . 0 ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> + GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> + EXPECT_EQ ( DO_FULL_GC , action . type ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , AfterContextDisposeZeroIdleTime ) { <nl> heap_state . contexts_disposal_rate = 1 . 0 ; <nl> heap_state . incremental_marking_stopped = true ; <nl> double idle_time_ms = 0 ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_FULL_GC , action . type ) ; <nl> - heap_state . contexts_disposal_rate = 0 . 0 ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> + GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> + EXPECT_EQ ( DO_FULL_GC , action . type ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , AfterContextDisposeSmallIdleTime1 ) { <nl> heap_state . contexts_disposed = 1 ; <nl> heap_state . contexts_disposal_rate = <nl> GCIdleTimeHandler : : kHighContextDisposalRate ; <nl> - heap_state . incremental_marking_stopped = true ; <nl> size_t speed = heap_state . mark_compact_speed_in_bytes_per_ms ; <nl> double idle_time_ms = <nl> static_cast < double > ( heap_state . size_of_objects / speed - 1 ) ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - heap_state . contexts_disposal_rate = 0 . 0 ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> + GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> + EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , AfterContextDisposeSmallIdleTime2 ) { <nl> size_t speed = heap_state . mark_compact_speed_in_bytes_per_ms ; <nl> double idle_time_ms = <nl> static_cast < double > ( heap_state . size_of_objects / speed - 1 ) ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - heap_state . contexts_disposal_rate = 0 . 0 ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> + GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> + EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , IncrementalMarking1 ) { <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> size_t speed = heap_state . incremental_marking_speed_in_bytes_per_ms ; <nl> double idle_time_ms = 10 ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - EXPECT_GT ( speed * static_cast < size_t > ( idle_time_ms ) , <nl> - static_cast < size_t > ( action . parameter ) ) ; <nl> - EXPECT_LT ( 0 , action . parameter ) ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> + GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> + EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> + EXPECT_GT ( speed * static_cast < size_t > ( idle_time_ms ) , <nl> + static_cast < size_t > ( action . parameter ) ) ; <nl> + EXPECT_LT ( 0 , action . parameter ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , IncrementalMarking2 ) { <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> - heap_state . incremental_marking_stopped = true ; <nl> size_t speed = heap_state . incremental_marking_speed_in_bytes_per_ms ; <nl> double idle_time_ms = 10 ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - EXPECT_GT ( speed * static_cast < size_t > ( idle_time_ms ) , <nl> - static_cast < size_t > ( action . parameter ) ) ; <nl> - EXPECT_LT ( 0 , action . parameter ) ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> + GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> + EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> + EXPECT_GT ( speed * static_cast < size_t > ( idle_time_ms ) , <nl> + static_cast < size_t > ( action . parameter ) ) ; <nl> + EXPECT_LT ( 0 , action . parameter ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , NotEnoughTime ) { <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> size_t speed = heap_state . mark_compact_speed_in_bytes_per_ms ; <nl> double idle_time_ms = <nl> static_cast < double > ( heap_state . size_of_objects / speed - 1 ) ; <nl> GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_NOTHING , action . type ) ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> + EXPECT_EQ ( DONE , action . type ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , FinalizeSweeping ) { <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - heap_state . sweeping_in_progress = true ; <nl> - heap_state . sweeping_completed = true ; <nl> - double idle_time_ms = 10 . 0 ; <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_FINALIZE_SWEEPING , action . type ) ; <nl> - heap_state . sweeping_in_progress = false ; <nl> - heap_state . sweeping_completed = false ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> + heap_state . sweeping_in_progress = true ; <nl> + heap_state . sweeping_completed = true ; <nl> + double idle_time_ms = 10 . 0 ; <nl> + GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> + EXPECT_EQ ( DO_FINALIZE_SWEEPING , action . type ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , CannotFinalizeSweeping ) { <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - heap_state . sweeping_in_progress = true ; <nl> - heap_state . sweeping_completed = false ; <nl> - double idle_time_ms = 10 . 0 ; <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_NOTHING , action . type ) ; <nl> - heap_state . sweeping_in_progress = false ; <nl> - heap_state . sweeping_completed = false ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> + heap_state . sweeping_in_progress = true ; <nl> + heap_state . sweeping_completed = false ; <nl> + double idle_time_ms = 10 . 0 ; <nl> + GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> + EXPECT_EQ ( DO_NOTHING , action . type ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , Scavenge ) { <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> int idle_time_ms = 10 ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - heap_state . used_new_space_size = <nl> - heap_state . new_space_capacity - <nl> - ( kNewSpaceAllocationThroughput * idle_time_ms ) ; <nl> - GCIdleTimeAction action = <nl> - handler ( ) - > Compute ( static_cast < double > ( idle_time_ms ) , heap_state ) ; <nl> - EXPECT_EQ ( DO_SCAVENGE , action . type ) ; <nl> - heap_state . used_new_space_size = 0 ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> + heap_state . used_new_space_size = <nl> + heap_state . new_space_capacity - <nl> + ( kNewSpaceAllocationThroughput * idle_time_ms ) ; <nl> + GCIdleTimeAction action = <nl> + handler ( ) - > Compute ( static_cast < double > ( idle_time_ms ) , heap_state ) ; <nl> + EXPECT_EQ ( DO_SCAVENGE , action . type ) ; <nl> + heap_state . used_new_space_size = 0 ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , ScavengeAndDone ) { <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> int idle_time_ms = 10 ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - heap_state . incremental_marking_stopped = true ; <nl> - for ( int mode = 0 ; mode < 1 ; mode + + ) { <nl> - heap_state . used_new_space_size = <nl> - heap_state . new_space_capacity - <nl> - ( kNewSpaceAllocationThroughput * idle_time_ms ) ; <nl> - GCIdleTimeAction action = <nl> - handler ( ) - > Compute ( static_cast < double > ( idle_time_ms ) , heap_state ) ; <nl> - EXPECT_EQ ( DO_SCAVENGE , action . type ) ; <nl> - heap_state . used_new_space_size = 0 ; <nl> - action = handler ( ) - > Compute ( static_cast < double > ( idle_time_ms ) , heap_state ) ; <nl> - EXPECT_EQ ( DO_NOTHING , action . type ) ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - TEST_F ( GCIdleTimeHandlerTest , StopEventually1 ) { <nl> - GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> - heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - double idle_time_ms = GCIdleTimeHandler : : kMinLongIdleTime ; <nl> - bool stopped = false ; <nl> - for ( int i = 0 ; i < kMaxNotifications & & ! stopped ; i + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - if ( action . type = = DO_INCREMENTAL_MARKING | | action . type = = DO_FULL_GC ) { <nl> - handler ( ) - > NotifyMarkCompact ( true ) ; <nl> - handler ( ) - > NotifyIdleMarkCompact ( ) ; <nl> - } <nl> - if ( action . type = = DONE ) stopped = true ; <nl> - } <nl> - EXPECT_TRUE ( stopped ) ; <nl> - } <nl> - <nl> - <nl> - TEST_F ( GCIdleTimeHandlerTest , StopEventually2 ) { <nl> - GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> - heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - size_t speed = heap_state . mark_compact_speed_in_bytes_per_ms ; <nl> - double idle_time_ms = <nl> - static_cast < double > ( heap_state . size_of_objects / speed + 1 ) ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - TransitionToDoneMode ( heap_state , idle_time_ms , DO_FULL_GC ) ; <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DONE , action . type ) ; <nl> - } <nl> - <nl> - <nl> - TEST_F ( GCIdleTimeHandlerTest , StopEventually3 ) { <nl> - GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - double idle_time_ms = 10 ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - TransitionToDoneMode ( heap_state , idle_time_ms , DO_INCREMENTAL_MARKING ) ; <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> + heap_state . used_new_space_size = <nl> + heap_state . new_space_capacity - <nl> + ( kNewSpaceAllocationThroughput * idle_time_ms ) ; <nl> + GCIdleTimeAction action = <nl> + handler ( ) - > Compute ( static_cast < double > ( idle_time_ms ) , heap_state ) ; <nl> + EXPECT_EQ ( DO_SCAVENGE , action . type ) ; <nl> + heap_state . used_new_space_size = 0 ; <nl> + action = handler ( ) - > Compute ( static_cast < double > ( idle_time_ms ) , heap_state ) ; <nl> EXPECT_EQ ( DONE , action . type ) ; <nl> } <nl> <nl> <nl> - TEST_F ( GCIdleTimeHandlerTest , ContinueAfterStop1 ) { <nl> + TEST_F ( GCIdleTimeHandlerTest , DoNotStartIncrementalMarking ) { <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - size_t speed = heap_state . mark_compact_speed_in_bytes_per_ms ; <nl> - double idle_time_ms = <nl> - static_cast < double > ( heap_state . size_of_objects / speed + 1 ) ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - TransitionToDoneMode ( heap_state , idle_time_ms , DO_FULL_GC ) ; <nl> + double idle_time_ms = 10 . 0 ; <nl> GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> EXPECT_EQ ( DONE , action . type ) ; <nl> - TransitionToReduceLatencyMode ( heap_state ) ; <nl> - heap_state . can_start_incremental_marking = true ; <nl> - action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - EXPECT_FALSE ( action . reduce_memory ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceLatency , handler ( ) - > mode ( ) ) ; <nl> } <nl> <nl> <nl> - TEST_F ( GCIdleTimeHandlerTest , ContinueAfterStop2 ) { <nl> + TEST_F ( GCIdleTimeHandlerTest , ContinueAfterStop ) { <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - double idle_time_ms = 10 ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - TransitionToDoneMode ( heap_state , idle_time_ms , DO_INCREMENTAL_MARKING ) ; <nl> + double idle_time_ms = 10 . 0 ; <nl> GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> EXPECT_EQ ( DONE , action . type ) ; <nl> - TransitionToReduceLatencyMode ( heap_state ) ; <nl> - heap_state . can_start_incremental_marking = true ; <nl> + heap_state . incremental_marking_stopped = false ; <nl> action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - EXPECT_FALSE ( action . reduce_memory ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceLatency , handler ( ) - > mode ( ) ) ; <nl> } <nl> <nl> <nl> TEST_F ( GCIdleTimeHandlerTest , ZeroIdleTimeNothingToDo ) { <nl> TEST_F ( GCIdleTimeHandlerTest , SmallIdleTimeNothingToDo ) { <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> for ( int i = 0 ; i < kMaxNotifications ; i + + ) { <nl> GCIdleTimeAction action = handler ( ) - > Compute ( 10 , heap_state ) ; <nl> EXPECT_TRUE ( DO_NOTHING = = action . type | | DONE = = action . type ) ; <nl> TEST_F ( GCIdleTimeHandlerTest , SmallIdleTimeNothingToDo ) { <nl> } <nl> <nl> <nl> - TEST_F ( GCIdleTimeHandlerTest , StayInReduceLatencyModeBecauseOfScavenges ) { <nl> - GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> - heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - double idle_time_ms = GCIdleTimeHandler : : kMinLongIdleTime ; <nl> - int limit = GCIdleTimeHandler : : kLongIdleNotificationsBeforeMutatorIsIdle ; <nl> - for ( int i = 0 ; i < kMaxNotifications ; i + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_TRUE ( DO_NOTHING = = action . type | | DONE = = action . type ) ; <nl> - if ( ( i + 1 ) % limit = = 0 ) handler ( ) - > NotifyScavenge ( ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceLatency , handler ( ) - > mode ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - TEST_F ( GCIdleTimeHandlerTest , StayInReduceLatencyModeBecauseOfMarkCompacts ) { <nl> - GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> - heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - double idle_time_ms = GCIdleTimeHandler : : kMinLongIdleTime ; <nl> - int limit = GCIdleTimeHandler : : kLongIdleNotificationsBeforeMutatorIsIdle ; <nl> - for ( int i = 0 ; i < kMaxNotifications ; i + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_TRUE ( DO_NOTHING = = action . type | | DONE = = action . type ) ; <nl> - if ( ( i + 1 ) % limit = = 0 ) handler ( ) - > NotifyMarkCompact ( true ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceLatency , handler ( ) - > mode ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - TEST_F ( GCIdleTimeHandlerTest , ReduceMemoryToReduceLatency ) { <nl> - GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> - heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - double idle_time_ms = GCIdleTimeHandler : : kMinLongIdleTime ; <nl> - int limit = GCIdleTimeHandler : : kMaxIdleMarkCompacts ; <nl> - for ( int idle_gc = 0 ; idle_gc < limit ; idle_gc + + ) { <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - EXPECT_TRUE ( action . reduce_memory ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceMemory , handler ( ) - > mode ( ) ) ; <nl> - for ( int i = 0 ; i < idle_gc ; i + + ) { <nl> - action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - EXPECT_TRUE ( action . reduce_memory ) ; <nl> - / / ReduceMemory mode should tolerate one mutator GC per idle GC . <nl> - handler ( ) - > NotifyScavenge ( ) ; <nl> - / / Notify idle GC . <nl> - handler ( ) - > NotifyMarkCompact ( true ) ; <nl> - handler ( ) - > NotifyIdleMarkCompact ( ) ; <nl> - } <nl> - / / Transition to ReduceLatency mode after doing | idle_gc | idle GCs . <nl> - handler ( ) - > NotifyScavenge ( ) ; <nl> - action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_NOTHING , action . type ) ; <nl> - EXPECT_FALSE ( action . reduce_memory ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceLatency , handler ( ) - > mode ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - TEST_F ( GCIdleTimeHandlerTest , ReduceMemoryToDone ) { <nl> - GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> - heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> - double idle_time_ms = GCIdleTimeHandler : : kMinLongIdleTime ; <nl> - int limit = GCIdleTimeHandler : : kMaxIdleMarkCompacts ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - EXPECT_TRUE ( action . reduce_memory ) ; <nl> - for ( int i = 0 ; i < limit ; i + + ) { <nl> - action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - EXPECT_TRUE ( action . reduce_memory ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceMemory , handler ( ) - > mode ( ) ) ; <nl> - / / ReduceMemory mode should tolerate one mutator GC per idle GC . <nl> - handler ( ) - > NotifyScavenge ( ) ; <nl> - / / Notify idle GC . <nl> - handler ( ) - > NotifyMarkCompact ( true ) ; <nl> - handler ( ) - > NotifyIdleMarkCompact ( ) ; <nl> - } <nl> - action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DONE , action . type ) ; <nl> - } <nl> - <nl> - <nl> TEST_F ( GCIdleTimeHandlerTest , DoneIfNotMakingProgressOnSweeping ) { <nl> / / Regression test for crbug . com / 489323 . <nl> GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> <nl> / / Simulate sweeping being in - progress but not complete . <nl> heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> heap_state . sweeping_in_progress = true ; <nl> heap_state . sweeping_completed = false ; <nl> double idle_time_ms = 10 . 0 ; <nl> - for ( int i = 0 ; i < GCIdleTimeHandler : : kMaxNoProgressIdleTimesPerMode ; i + + ) { <nl> + for ( int i = 0 ; i < GCIdleTimeHandler : : kMaxNoProgressIdleTimes ; i + + ) { <nl> GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> EXPECT_EQ ( DO_NOTHING , action . type ) ; <nl> } <nl> TEST_F ( GCIdleTimeHandlerTest , DoneIfNotMakingProgressOnIncrementalMarking ) { <nl> <nl> / / Simulate incremental marking stopped and not eligible to start . <nl> heap_state . incremental_marking_stopped = true ; <nl> - heap_state . can_start_incremental_marking = false ; <nl> double idle_time_ms = 10 . 0 ; <nl> - for ( int i = 0 ; i < GCIdleTimeHandler : : kMaxNoProgressIdleTimesPerMode ; i + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_NOTHING , action . type ) ; <nl> - } <nl> - / / We should return DONE after not making progress for some time . <nl> + / / We should return DONE if we cannot start incremental marking . <nl> GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> EXPECT_EQ ( DONE , action . type ) ; <nl> } <nl> <nl> - <nl> - TEST_F ( GCIdleTimeHandlerTest , BackgroundReduceLatencyToReduceMemory ) { <nl> - GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> - heap_state . incremental_marking_stopped = false ; <nl> - heap_state . can_start_incremental_marking = true ; <nl> - double idle_time_ms = GCIdleTimeHandler : : kMinBackgroundIdleTime ; <nl> - handler ( ) - > NotifyScavenge ( ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceLatency , handler ( ) - > mode ( ) ) ; <nl> - int limit = <nl> - GCIdleTimeHandler : : kBackgroundIdleNotificationsBeforeMutatorIsIdle ; <nl> - for ( int i = 0 ; i < limit ; i + + ) { <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - } <nl> - handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceMemory , handler ( ) - > mode ( ) ) ; <nl> - } <nl> - <nl> - <nl> - TEST_F ( GCIdleTimeHandlerTest , SkipUselessGCs ) { <nl> - GCIdleTimeHandler : : HeapState heap_state = DefaultHeapState ( ) ; <nl> - heap_state . incremental_marking_stopped = false ; <nl> - heap_state . can_start_incremental_marking = true ; <nl> - TransitionToReduceMemoryMode ( heap_state ) ; <nl> - EXPECT_EQ ( GCIdleTimeHandler : : kReduceMemory , handler ( ) - > mode ( ) ) ; <nl> - double idle_time_ms = GCIdleTimeHandler : : kMinLongIdleTime ; <nl> - GCIdleTimeAction action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DO_INCREMENTAL_MARKING , action . type ) ; <nl> - handler ( ) - > NotifyMarkCompact ( false ) ; <nl> - handler ( ) - > NotifyIdleMarkCompact ( ) ; <nl> - action = handler ( ) - > Compute ( idle_time_ms , heap_state ) ; <nl> - EXPECT_EQ ( DONE , action . type ) ; <nl> - } <nl> - <nl> } / / namespace internal <nl> } / / namespace v8 <nl> new file mode 100644 <nl> index 00000000000 . . 7f6785d5093 <nl> mmm / dev / null <nl> ppp b / test / unittests / heap / memory - reducer - unittest . cc <nl> <nl> + / / Copyright 2014 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + # include < limits > <nl> + <nl> + # include " src / flags . h " <nl> + # include " src / heap / memory - reducer . h " <nl> + # include " testing / gtest / include / gtest / gtest . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + MemoryReducer : : State DoneState ( ) { <nl> + return MemoryReducer : : State ( MemoryReducer : : kDone , 0 , 0 . 0 ) ; <nl> + } <nl> + <nl> + <nl> + MemoryReducer : : State WaitState ( int started_gcs , double next_gc_start_ms ) { <nl> + return MemoryReducer : : State ( MemoryReducer : : kWait , started_gcs , <nl> + next_gc_start_ms ) ; <nl> + } <nl> + <nl> + <nl> + MemoryReducer : : State RunState ( int started_gcs , double next_gc_start_ms ) { <nl> + return MemoryReducer : : State ( MemoryReducer : : kRun , started_gcs , <nl> + next_gc_start_ms ) ; <nl> + } <nl> + <nl> + <nl> + MemoryReducer : : Event MarkCompactEvent ( double time_ms , <nl> + bool next_gc_likely_to_collect_more ) { <nl> + MemoryReducer : : Event event ; <nl> + event . type = MemoryReducer : : kMarkCompact ; <nl> + event . time_ms = time_ms ; <nl> + event . next_gc_likely_to_collect_more = next_gc_likely_to_collect_more ; <nl> + return event ; <nl> + } <nl> + <nl> + <nl> + MemoryReducer : : Event MarkCompactEventGarbageLeft ( double time_ms ) { <nl> + return MarkCompactEvent ( time_ms , true ) ; <nl> + } <nl> + <nl> + <nl> + MemoryReducer : : Event MarkCompactEventNoGarbageLeft ( double time_ms ) { <nl> + return MarkCompactEvent ( time_ms , false ) ; <nl> + } <nl> + <nl> + <nl> + MemoryReducer : : Event TimerEvent ( double time_ms , bool low_allocation_rate , <nl> + bool can_start_incremental_gc ) { <nl> + MemoryReducer : : Event event ; <nl> + event . type = MemoryReducer : : kTimer ; <nl> + event . time_ms = time_ms ; <nl> + event . low_allocation_rate = low_allocation_rate ; <nl> + event . can_start_incremental_gc = can_start_incremental_gc ; <nl> + return event ; <nl> + } <nl> + <nl> + <nl> + MemoryReducer : : Event TimerEventLowAllocationRate ( double time_ms ) { <nl> + return TimerEvent ( time_ms , true , true ) ; <nl> + } <nl> + <nl> + <nl> + MemoryReducer : : Event TimerEventHighAllocationRate ( double time_ms ) { <nl> + return TimerEvent ( time_ms , false , true ) ; <nl> + } <nl> + <nl> + <nl> + MemoryReducer : : Event TimerEventPendingGC ( double time_ms ) { <nl> + return TimerEvent ( time_ms , true , false ) ; <nl> + } <nl> + <nl> + <nl> + MemoryReducer : : Event ContextDisposedEvent ( double time_ms ) { <nl> + MemoryReducer : : Event event ; <nl> + event . type = MemoryReducer : : kContextDisposed ; <nl> + event . time_ms = time_ms ; <nl> + return event ; <nl> + } <nl> + <nl> + <nl> + TEST ( MemoryReducer , FromDoneToDone ) { <nl> + MemoryReducer : : State state0 ( DoneState ( ) ) , state1 ( DoneState ( ) ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , TimerEventLowAllocationRate ( 0 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kDone , state1 . action ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , TimerEventHighAllocationRate ( 0 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kDone , state1 . action ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , TimerEventPendingGC ( 0 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kDone , state1 . action ) ; <nl> + } <nl> + <nl> + <nl> + TEST ( MemoryReducer , FromDoneToWait ) { <nl> + if ( ! FLAG_incremental_marking ) return ; <nl> + <nl> + MemoryReducer : : State state0 ( DoneState ( ) ) , state1 ( DoneState ( ) ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , MarkCompactEventGarbageLeft ( 0 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kLongDelayMs , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( 0 , state1 . started_gcs ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , MarkCompactEventNoGarbageLeft ( 0 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kLongDelayMs , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( 0 , state1 . started_gcs ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , ContextDisposedEvent ( 0 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kLongDelayMs , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( 0 , state1 . started_gcs ) ; <nl> + } <nl> + <nl> + <nl> + TEST ( MemoryReducer , FromWaitToWait ) { <nl> + if ( ! FLAG_incremental_marking ) return ; <nl> + <nl> + MemoryReducer : : State state0 ( WaitState ( 2 , 1000 . 0 ) ) , state1 ( DoneState ( ) ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , ContextDisposedEvent ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( state0 . next_gc_start_ms , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( <nl> + state0 , TimerEventLowAllocationRate ( state0 . next_gc_start_ms - 1 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( state0 . next_gc_start_ms , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , TimerEventHighAllocationRate ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( 2000 + MemoryReducer : : kLongDelayMs , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , TimerEventPendingGC ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( 2000 + MemoryReducer : : kLongDelayMs , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , MarkCompactEventGarbageLeft ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( 2000 + MemoryReducer : : kLongDelayMs , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , MarkCompactEventNoGarbageLeft ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( 2000 + MemoryReducer : : kLongDelayMs , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + } <nl> + <nl> + <nl> + TEST ( MemoryReducer , FromWaitToRun ) { <nl> + if ( ! FLAG_incremental_marking ) return ; <nl> + <nl> + MemoryReducer : : State state0 ( WaitState ( 0 , 1000 . 0 ) ) , state1 ( DoneState ( ) ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( <nl> + state0 , TimerEventLowAllocationRate ( state0 . next_gc_start_ms + 1 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kRun , state1 . action ) ; <nl> + EXPECT_EQ ( 0 , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs + 1 , state1 . started_gcs ) ; <nl> + } <nl> + <nl> + <nl> + TEST ( MemoryReducer , FromRunToRun ) { <nl> + if ( ! FLAG_incremental_marking ) return ; <nl> + <nl> + MemoryReducer : : State state0 ( RunState ( 1 , 0 . 0 ) ) , state1 ( DoneState ( ) ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , TimerEventLowAllocationRate ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kRun , state1 . action ) ; <nl> + EXPECT_EQ ( state0 . next_gc_start_ms , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , TimerEventHighAllocationRate ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kRun , state1 . action ) ; <nl> + EXPECT_EQ ( state0 . next_gc_start_ms , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , TimerEventPendingGC ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kRun , state1 . action ) ; <nl> + EXPECT_EQ ( state0 . next_gc_start_ms , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , ContextDisposedEvent ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kRun , state1 . action ) ; <nl> + EXPECT_EQ ( state0 . next_gc_start_ms , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + } <nl> + <nl> + <nl> + TEST ( MemoryReducer , FromRunToDone ) { <nl> + if ( ! FLAG_incremental_marking ) return ; <nl> + <nl> + MemoryReducer : : State state0 ( RunState ( 2 , 0 . 0 ) ) , state1 ( DoneState ( ) ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , MarkCompactEventNoGarbageLeft ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kDone , state1 . action ) ; <nl> + EXPECT_EQ ( 0 , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( 0 , state1 . started_gcs ) ; <nl> + <nl> + state0 . started_gcs = MemoryReducer : : kMaxNumberOfGCs ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , MarkCompactEventGarbageLeft ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kDone , state1 . action ) ; <nl> + EXPECT_EQ ( 0 , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( 0 , state1 . started_gcs ) ; <nl> + } <nl> + <nl> + <nl> + TEST ( MemoryReducer , FromRunToWait ) { <nl> + if ( ! FLAG_incremental_marking ) return ; <nl> + <nl> + MemoryReducer : : State state0 ( RunState ( 2 , 0 . 0 ) ) , state1 ( DoneState ( ) ) ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , MarkCompactEventGarbageLeft ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( 2000 + MemoryReducer : : kShortDelayMs , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + <nl> + state0 . started_gcs = 1 ; <nl> + <nl> + state1 = MemoryReducer : : Step ( state0 , MarkCompactEventNoGarbageLeft ( 2000 ) ) ; <nl> + EXPECT_EQ ( MemoryReducer : : kWait , state1 . action ) ; <nl> + EXPECT_EQ ( 2000 + MemoryReducer : : kShortDelayMs , state1 . next_gc_start_ms ) ; <nl> + EXPECT_EQ ( state0 . started_gcs , state1 . started_gcs ) ; <nl> + } <nl> + <nl> + } / / namespace internal <nl> + } / / namespace v8 <nl> mmm a / test / unittests / unittests . gyp <nl> ppp b / test / unittests / unittests . gyp <nl> <nl> ' libplatform / task - queue - unittest . cc ' , <nl> ' libplatform / worker - thread - unittest . cc ' , <nl> ' heap / gc - idle - time - handler - unittest . cc ' , <nl> + ' heap / memory - reducer - unittest . cc ' , <nl> ' heap / heap - unittest . cc ' , <nl> ' run - all - unittests . cc ' , <nl> ' test - utils . h ' , <nl> mmm a / tools / gyp / v8 . gyp <nl> ppp b / tools / gyp / v8 . gyp <nl> <nl> ' . . / . . / src / heap - snapshot - generator - inl . h ' , <nl> ' . . / . . / src / heap - snapshot - generator . cc ' , <nl> ' . . / . . / src / heap - snapshot - generator . h ' , <nl> + ' . . / . . / src / heap / memory - reducer . cc ' , <nl> + ' . . / . . / src / heap / memory - reducer . h ' , <nl> ' . . / . . / src / heap / gc - idle - time - handler . cc ' , <nl> ' . . / . . / src / heap / gc - idle - time - handler . h ' , <nl> ' . . / . . / src / heap / gc - tracer . cc ' , <nl> | Reland " Replace reduce - memory mode in idle notification with delayed clean - up GC . " | v8/v8 | a7f62edb7114604cc6a58f261923530299155f80 | 2015-07-07T11:37:53Z |
mmm a / main / main . cpp <nl> ppp b / main / main . cpp <nl> Error Main : : setup ( const char * execpath , int argc , char * argv [ ] , bool p_second_ph <nl> <nl> auto_build_solutions = true ; <nl> editor = true ; <nl> + # ifdef DEBUG_METHODS_ENABLED <nl> + } else if ( I - > get ( ) = = " - - gdnative - generate - json - api " ) { <nl> + / / Register as an editor instance to use the GLES2 fallback automatically on hardware that doesn ' t support the GLES3 backend <nl> + editor = true ; <nl> + <nl> + / / We still pass it to the main arguments since the argument handling itself is not done in this function <nl> + main_args . push_back ( I - > get ( ) ) ; <nl> + # endif <nl> } else if ( I - > get ( ) = = " - - export " | | I - > get ( ) = = " - - export - debug " ) { / / Export project <nl> <nl> editor = true ; <nl> | Register as an editor instance when generating the GDNative API JSON | godotengine/godot | 3d61ca5696e7497df9344b828337104dd7ac3731 | 2019-08-23T22:09:52Z |
mmm a / libraries / chain / contracts / abi_serializer . cpp <nl> ppp b / libraries / chain / contracts / abi_serializer . cpp <nl> namespace eosio { namespace chain { namespace contracts { <nl> * The ABI vector may contain duplicates which would make it <nl> * an invalid ABI <nl> * / <nl> - for ( const auto & tt : typedefs ) <nl> FC_ASSERT ( typedefs . size ( ) = = abi . types . size ( ) ) ; <nl> FC_ASSERT ( structs . size ( ) = = abi . structs . size ( ) ) ; <nl> FC_ASSERT ( actions . size ( ) = = abi . actions . size ( ) ) ; <nl> | Fix for eos , forgot debug artifact | EOSIO/eos | 4b64bb6f1603f2f6f856e7dc0e7299ccb1d81d8a | 2018-04-05T21:31:26Z |
mmm a / src / handles . h <nl> ppp b / src / handles . h <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> + / / A Handle can be converted into a MaybeHandle . Converting a MaybeHandle <nl> + / / into a Handle requires checking that it does not point to NULL . This <nl> + / / ensures NULL checks before use . <nl> + <nl> + template < typename T > <nl> + class MaybeHandle { <nl> + public : <nl> + INLINE ( MaybeHandle ( ) ) : location_ ( NULL ) { } <nl> + <nl> + / / Constructor for handling automatic up casting from Handle . <nl> + / / Ex . Handle < JSArray > can be passed when MaybeHandle < Object > is expected . <nl> + template < class S > MaybeHandle ( Handle < S > handle ) { <nl> + # ifdef DEBUG <nl> + T * a = NULL ; <nl> + S * b = NULL ; <nl> + a = b ; / / Fake assignment to enforce type checks . <nl> + USE ( a ) ; <nl> + # endif <nl> + this - > location_ = reinterpret_cast < T * * > ( handle . location ( ) ) ; <nl> + } <nl> + <nl> + / / Constructor for handling automatic up casting . <nl> + / / Ex . MaybeHandle < JSArray > can be passed when Handle < Object > is expected . <nl> + template < class S > MaybeHandle ( MaybeHandle < S > maybe_handle ) { <nl> + # ifdef DEBUG <nl> + T * a = NULL ; <nl> + S * b = NULL ; <nl> + a = b ; / / Fake assignment to enforce type checks . <nl> + USE ( a ) ; <nl> + # endif <nl> + location_ = reinterpret_cast < T * * > ( maybe_handle . location_ ) ; <nl> + } <nl> + <nl> + INLINE ( Handle < T > ToHandleChecked ( ) ) { <nl> + CHECK ( location_ ! = NULL ) ; <nl> + return Handle < T > ( location_ ) ; <nl> + } <nl> + <nl> + INLINE ( bool ToHandle ( Handle < T > * out ) ) { <nl> + if ( location_ = = NULL ) { <nl> + * out = Handle < T > : : null ( ) ; <nl> + return false ; <nl> + } else { <nl> + * out = Handle < T > ( location_ ) ; <nl> + return true ; <nl> + } <nl> + } <nl> + <nl> + protected : <nl> + T * * location_ ; <nl> + <nl> + / / MaybeHandles of different classes are allowed to access each <nl> + / / other ' s location_ . <nl> + template < class S > friend class MaybeHandle ; <nl> + } ; <nl> + <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> / / A Handle provides a reference to an object that survives relocation by <nl> / / the garbage collector . <nl> class Handle { <nl> INLINE ( explicit Handle ( T * obj ) ) ; <nl> INLINE ( Handle ( T * obj , Isolate * isolate ) ) ; <nl> <nl> - INLINE ( Handle ( ) ) : location_ ( NULL ) { } <nl> + / / TODO ( yangguo ) : Values that contain empty handles should be declared as <nl> + / / MaybeHandle to force validation before being used as handles . <nl> + INLINE ( Handle ( ) ) : location_ ( NULL ) { } <nl> <nl> / / Constructor for handling automatic up casting . <nl> / / Ex . Handle < JSFunction > can be passed when Handle < Object > is expected . <nl> class Handle { <nl> return Handle < T > ( reinterpret_cast < T * * > ( that . location_ ) ) ; <nl> } <nl> <nl> + / / TODO ( yangguo ) : Values that contain empty handles should be declared as <nl> + / / MaybeHandle to force validation before being used as handles . <nl> static Handle < T > null ( ) { return Handle < T > ( ) ; } <nl> bool is_null ( ) const { return location_ = = NULL ; } <nl> <nl> mmm a / src / isolate . h <nl> ppp b / src / isolate . h <nl> typedef ZoneList < Handle < Object > > ZoneObjectList ; <nl> } \ <nl> } while ( false ) <nl> <nl> - # define RETURN_IF_EMPTY_HANDLE_VALUE ( isolate , call , value ) \ <nl> - do { \ <nl> - if ( ( call ) . is_null ( ) ) { \ <nl> - ASSERT ( ( isolate ) - > has_pending_exception ( ) ) ; \ <nl> - return ( value ) ; \ <nl> - } \ <nl> + # define RETURN_IF_EMPTY_HANDLE_VALUE ( isolate , call , value ) \ <nl> + do { \ <nl> + if ( ( call ) . is_null ( ) ) { \ <nl> + ASSERT ( ( isolate ) - > has_pending_exception ( ) ) ; \ <nl> + return ( value ) ; \ <nl> + } \ <nl> } while ( false ) <nl> <nl> # define CHECK_NOT_EMPTY_HANDLE ( isolate , call ) \ <nl> typedef ZoneList < Handle < Object > > ZoneObjectList ; <nl> CHECK ( ! ( call ) . is_null ( ) ) ; \ <nl> } while ( false ) <nl> <nl> - # define RETURN_IF_EMPTY_HANDLE ( isolate , call ) \ <nl> + # define RETURN_IF_EMPTY_HANDLE ( isolate , call ) \ <nl> RETURN_IF_EMPTY_HANDLE_VALUE ( isolate , call , Failure : : Exception ( ) ) <nl> <nl> + <nl> + / / Macros for MaybeHandle . <nl> + <nl> + # define RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION ( isolate , T ) \ <nl> + do { \ <nl> + Isolate * __isolate__ = ( isolate ) ; \ <nl> + if ( __isolate__ - > has_scheduled_exception ( ) ) { \ <nl> + __isolate__ - > PromoteScheduledException ( ) ; \ <nl> + return MaybeHandle < T > ( ) ; \ <nl> + } \ <nl> + } while ( false ) <nl> + <nl> + # define ASSIGN_RETURN_ON_EXCEPTION_VALUE ( isolate , dst , call , value ) \ <nl> + do { \ <nl> + if ( ! ( call ) . ToHandle ( & dst ) ) { \ <nl> + ASSERT ( ( isolate ) - > has_pending_exception ( ) ) ; \ <nl> + return value ; \ <nl> + } \ <nl> + } while ( false ) <nl> + <nl> + # define ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate , dst , call ) \ <nl> + ASSIGN_RETURN_ON_EXCEPTION_VALUE ( isolate , dst , call , Failure : : Exception ( ) ) <nl> + <nl> + # define ASSIGN_RETURN_ON_EXCEPTION ( isolate , dst , call , T ) \ <nl> + ASSIGN_RETURN_ON_EXCEPTION_VALUE ( isolate , dst , call , MaybeHandle < T > ( ) ) <nl> + <nl> + # define RETURN_ON_EXCEPTION_VALUE ( isolate , dst , call , value ) \ <nl> + do { \ <nl> + if ( call . is_null ( ) ) { \ <nl> + ASSERT ( ( isolate ) - > has_pending_exception ( ) ) ; \ <nl> + return value ; \ <nl> + } \ <nl> + } while ( false ) <nl> + <nl> + # define RETURN_FAILURE_ON_EXCEPTION ( isolate , call ) \ <nl> + RETURN_ON_EXCEPTION_VALUE ( isolate , dst , call , Failure : : Exception ( ) ) <nl> + <nl> + # define RETURN_ON_EXCEPTION ( isolate , call , T ) \ <nl> + RETURN_ON_EXCEPTION_VALUE ( \ <nl> + isolate , dst , call , MaybeHandle < T > : : Exception ( ) ) <nl> + <nl> + <nl> # define FOR_EACH_ISOLATE_ADDRESS_NAME ( C ) \ <nl> C ( Handler , handler ) \ <nl> C ( CEntryFP , c_entry_fp ) \ <nl> class Isolate { <nl> / / Exception throwing support . The caller should use the result <nl> / / of Throw ( ) as its return value . <nl> Failure * Throw ( Object * exception , MessageLocation * location = NULL ) ; <nl> + <nl> + template < typename T > <nl> + MUST_USE_RESULT MaybeHandle < T > Throw ( Handle < Object > exception , <nl> + MessageLocation * location = NULL ) { <nl> + Throw ( * exception , location ) ; <nl> + return MaybeHandle < T > ( ) ; <nl> + } <nl> + <nl> / / Re - throw an exception . This involves no error reporting since <nl> / / error reporting was handled when the exception was thrown <nl> / / originally . <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> static void FreezeDictionary ( Dictionary * dictionary ) { <nl> } <nl> <nl> <nl> - Handle < Object > JSObject : : Freeze ( Handle < JSObject > object ) { <nl> + MaybeHandle < Object > JSObject : : Freeze ( Handle < JSObject > object ) { <nl> / / Freezing sloppy arguments should be handled elsewhere . <nl> ASSERT ( ! object - > HasSloppyArgumentsElements ( ) ) ; <nl> ASSERT ( ! object - > map ( ) - > is_observed ( ) ) ; <nl> Handle < Object > JSObject : : Freeze ( Handle < JSObject > object ) { <nl> isolate - > factory ( ) - > undefined_value ( ) , <nl> v8 : : ACCESS_KEYS ) ) { <nl> isolate - > ReportFailedAccessCheckWrapper ( object , v8 : : ACCESS_KEYS ) ; <nl> - RETURN_HANDLE_IF_SCHEDULED_EXCEPTION ( isolate , Object ) ; <nl> + RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION ( isolate , Object ) ; <nl> return isolate - > factory ( ) - > false_value ( ) ; <nl> } <nl> <nl> Handle < Object > JSObject : : Freeze ( Handle < JSObject > object ) { <nl> isolate - > factory ( ) - > NewTypeError ( <nl> " cant_prevent_ext_external_array_elements " , <nl> HandleVector ( & object , 1 ) ) ; <nl> - isolate - > Throw ( * error ) ; <nl> - return Handle < Object > ( ) ; <nl> + return isolate - > Throw < Object > ( error ) ; <nl> } <nl> <nl> Handle < SeededNumberDictionary > new_element_dictionary ; <nl> mmm a / src / objects . h <nl> ppp b / src / objects . h <nl> class JSObject : public JSReceiver { <nl> static Handle < Object > PreventExtensions ( Handle < JSObject > object ) ; <nl> <nl> / / ES5 Object . freeze <nl> - static Handle < Object > Freeze ( Handle < JSObject > object ) ; <nl> + static MaybeHandle < Object > Freeze ( Handle < JSObject > object ) ; <nl> <nl> / / Called the first time an object is observed with ES7 Object . observe . <nl> static void SetObserved ( Handle < JSObject > object ) ; <nl> mmm a / src / runtime . cc <nl> ppp b / src / runtime . cc <nl> RUNTIME_FUNCTION ( MaybeObject * , Runtime_ObjectFreeze ) { <nl> HandleScope scope ( isolate ) ; <nl> ASSERT ( args . length ( ) = = 1 ) ; <nl> CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - Handle < Object > result = JSObject : : Freeze ( object ) ; <nl> - RETURN_IF_EMPTY_HANDLE ( isolate , result ) ; <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate , result , JSObject : : Freeze ( object ) ) ; <nl> return * result ; <nl> } <nl> <nl> mmm a / src / v8globals . h <nl> ppp b / src / v8globals . h <nl> class MemoryChunk ; <nl> class SeededNumberDictionary ; <nl> class UnseededNumberDictionary ; <nl> class NameDictionary ; <nl> + template < typename T > class MaybeHandle ; <nl> template < typename T > class Handle ; <nl> class Heap ; <nl> class HeapObject ; <nl> | Introduce MaybeHandle to police exception checking in handlified code . | v8/v8 | dc20bb49b0fd5f96b99fd3fb626fb1cd35499f95 | 2014-04-03T05:57:43Z |
mmm a / BUILD <nl> ppp b / BUILD <nl> grpc_cc_library ( <nl> ] , <nl> ) <nl> <nl> + grpc_cc_library ( <nl> + name = " grpc + + _alts " , <nl> + srcs = [ <nl> + " src / cpp / common / alts_context . cc " , <nl> + ] , <nl> + hdrs = [ <nl> + " include / grpcpp / alts_context . h " , <nl> + ] , <nl> + language = " c + + " , <nl> + standalone = True , <nl> + deps = [ <nl> + " grpc + + " , <nl> + " / / src / proto / grpc / gcp : alts_handshaker_cc_proto " , <nl> + ] , <nl> + ) <nl> + <nl> grpc_cc_library ( <nl> name = " grpc_csharp_ext " , <nl> srcs = [ <nl> mmm a / CMakeLists . txt <nl> ppp b / CMakeLists . txt <nl> protobuf_generate_grpc_cpp ( <nl> protobuf_generate_grpc_cpp ( <nl> src / proto / grpc / core / stats . proto <nl> ) <nl> + protobuf_generate_grpc_cpp ( <nl> + src / proto / grpc / gcp / altscontext . proto <nl> + ) <nl> + protobuf_generate_grpc_cpp ( <nl> + src / proto / grpc / gcp / transport_security_common . proto <nl> + ) <nl> protobuf_generate_grpc_cpp ( <nl> src / proto / grpc / health / v1 / health . proto <nl> ) <nl> if ( gRPC_BUILD_TESTS ) <nl> if ( _gRPC_PLATFORM_LINUX ) <nl> add_dependencies ( buildtests_cxx alts_concurrent_connectivity_test ) <nl> endif ( ) <nl> + add_dependencies ( buildtests_cxx alts_context_test ) <nl> add_dependencies ( buildtests_cxx alts_counter_test ) <nl> add_dependencies ( buildtests_cxx alts_crypt_test ) <nl> add_dependencies ( buildtests_cxx alts_crypter_test ) <nl> if ( gRPC_INSTALL ) <nl> ) <nl> endif ( ) <nl> <nl> + <nl> + if ( gRPC_BUILD_CODEGEN ) <nl> + add_library ( grpc + + _alts <nl> + $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / gcp / altscontext . pb . cc <nl> + $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / gcp / altscontext . grpc . pb . cc <nl> + $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / gcp / altscontext . pb . h <nl> + $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / gcp / altscontext . grpc . pb . h <nl> + $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / gcp / transport_security_common . pb . cc <nl> + $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / gcp / transport_security_common . grpc . pb . cc <nl> + $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / gcp / transport_security_common . pb . h <nl> + $ { _gRPC_PROTO_GENS_DIR } / src / proto / grpc / gcp / transport_security_common . grpc . pb . h <nl> + src / cpp / common / alts_context . cc <nl> + ) <nl> + <nl> + set_target_properties ( grpc + + _alts PROPERTIES <nl> + VERSION $ { gRPC_CPP_VERSION } <nl> + SOVERSION $ { gRPC_CPP_SOVERSION } <nl> + ) <nl> + <nl> + if ( WIN32 AND MSVC ) <nl> + set_target_properties ( grpc + + _alts PROPERTIES COMPILE_PDB_NAME " grpc + + _alts " <nl> + COMPILE_PDB_OUTPUT_DIRECTORY " $ { CMAKE_BINARY_DIR } " <nl> + ) <nl> + if ( gRPC_INSTALL ) <nl> + install ( FILES $ { CMAKE_CURRENT_BINARY_DIR } / grpc + + _alts . pdb <nl> + DESTINATION $ { gRPC_INSTALL_LIBDIR } OPTIONAL <nl> + ) <nl> + endif ( ) <nl> + endif ( ) <nl> + <nl> + target_include_directories ( grpc + + _alts <nl> + PUBLIC $ < INSTALL_INTERFACE : $ { gRPC_INSTALL_INCLUDEDIR } > $ < BUILD_INTERFACE : $ { CMAKE_CURRENT_SOURCE_DIR } / include > <nl> + PRIVATE <nl> + $ { CMAKE_CURRENT_SOURCE_DIR } <nl> + $ { _gRPC_ADDRESS_SORTING_INCLUDE_DIR } <nl> + $ { _gRPC_SSL_INCLUDE_DIR } <nl> + $ { _gRPC_UPB_GENERATED_DIR } <nl> + $ { _gRPC_UPB_GRPC_GENERATED_DIR } <nl> + $ { _gRPC_UPB_INCLUDE_DIR } <nl> + $ { _gRPC_ZLIB_INCLUDE_DIR } <nl> + $ { _gRPC_PROTO_GENS_DIR } <nl> + ) <nl> + target_link_libraries ( grpc + + _alts <nl> + $ { _gRPC_BASELIB_LIBRARIES } <nl> + $ { _gRPC_PROTOBUF_LIBRARIES } <nl> + $ { _gRPC_ALLTARGETS_LIBRARIES } <nl> + grpc + + <nl> + ) <nl> + <nl> + foreach ( _hdr <nl> + include / grpcpp / alts_context . h <nl> + include / grpcpp / impl / codegen / security / auth_context . h <nl> + ) <nl> + string ( REPLACE " include / " " " _path $ { _hdr } ) <nl> + get_filename_component ( _path $ { _path } PATH ) <nl> + install ( FILES $ { _hdr } <nl> + DESTINATION " $ { gRPC_INSTALL_INCLUDEDIR } / $ { _path } " <nl> + ) <nl> + endforeach ( ) <nl> + endif ( ) <nl> + <nl> + if ( gRPC_BUILD_CODEGEN ) <nl> + <nl> + if ( gRPC_INSTALL ) <nl> + install ( TARGETS grpc + + _alts EXPORT gRPCTargets <nl> + RUNTIME DESTINATION $ { gRPC_INSTALL_BINDIR } <nl> + LIBRARY DESTINATION $ { gRPC_INSTALL_LIBDIR } <nl> + ARCHIVE DESTINATION $ { gRPC_INSTALL_LIBDIR } <nl> + ) <nl> + endif ( ) <nl> + <nl> + endif ( ) <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> if ( gRPC_BUILD_CODEGEN ) <nl> endif ( ) <nl> endif ( ) <nl> if ( gRPC_BUILD_TESTS ) <nl> <nl> + add_executable ( alts_context_test <nl> + test / cpp / common / alts_context_test . cc <nl> + third_party / googletest / googletest / src / gtest - all . cc <nl> + third_party / googletest / googlemock / src / gmock - all . cc <nl> + ) <nl> + <nl> + target_include_directories ( alts_context_test <nl> + PRIVATE <nl> + $ { CMAKE_CURRENT_SOURCE_DIR } <nl> + $ { CMAKE_CURRENT_SOURCE_DIR } / include <nl> + $ { _gRPC_ADDRESS_SORTING_INCLUDE_DIR } <nl> + $ { _gRPC_SSL_INCLUDE_DIR } <nl> + $ { _gRPC_UPB_GENERATED_DIR } <nl> + $ { _gRPC_UPB_GRPC_GENERATED_DIR } <nl> + $ { _gRPC_UPB_INCLUDE_DIR } <nl> + $ { _gRPC_ZLIB_INCLUDE_DIR } <nl> + third_party / googletest / googletest / include <nl> + third_party / googletest / googletest <nl> + third_party / googletest / googlemock / include <nl> + third_party / googletest / googlemock <nl> + $ { _gRPC_PROTO_GENS_DIR } <nl> + ) <nl> + <nl> + target_link_libraries ( alts_context_test <nl> + $ { _gRPC_PROTOBUF_LIBRARIES } <nl> + $ { _gRPC_ALLTARGETS_LIBRARIES } <nl> + grpc + + _test_util <nl> + grpc_test_util <nl> + grpc + + _alts <nl> + grpc + + <nl> + grpc <nl> + gpr <nl> + grpc + + _test_config <nl> + $ { _gRPC_GFLAGS_LIBRARIES } <nl> + ) <nl> + <nl> + <nl> + endif ( ) <nl> + if ( gRPC_BUILD_TESTS ) <nl> + <nl> add_executable ( alts_counter_test <nl> test / core / tsi / alts / frame_protector / alts_counter_test . cc <nl> third_party / googletest / googletest / src / gtest - all . cc <nl> mmm a / Makefile <nl> ppp b / Makefile <nl> uri_fuzzer_test : $ ( BINDIR ) / $ ( CONFIG ) / uri_fuzzer_test <nl> uri_parser_test : $ ( BINDIR ) / $ ( CONFIG ) / uri_parser_test <nl> alarm_test : $ ( BINDIR ) / $ ( CONFIG ) / alarm_test <nl> alts_concurrent_connectivity_test : $ ( BINDIR ) / $ ( CONFIG ) / alts_concurrent_connectivity_test <nl> + alts_context_test : $ ( BINDIR ) / $ ( CONFIG ) / alts_context_test <nl> alts_counter_test : $ ( BINDIR ) / $ ( CONFIG ) / alts_counter_test <nl> alts_crypt_test : $ ( BINDIR ) / $ ( CONFIG ) / alts_crypt_test <nl> alts_crypter_test : $ ( BINDIR ) / $ ( CONFIG ) / alts_crypter_test <nl> static : static_c static_cxx <nl> <nl> static_c : pc_c pc_c_unsecure cache . mk $ ( LIBDIR ) / $ ( CONFIG ) / libaddress_sorting . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_cronet . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_unsecure . a $ ( LIBDIR ) / $ ( CONFIG ) / libupb . a <nl> <nl> - static_cxx : pc_cxx pc_cxx_unsecure cache . mk $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _error_details . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _reflection . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _unsecure . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpcpp_channelz . a <nl> + static_cxx : pc_cxx pc_cxx_unsecure cache . mk $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _error_details . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _reflection . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _unsecure . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpcpp_channelz . a <nl> <nl> static_csharp : static_c $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_csharp_ext . a <nl> <nl> shared : shared_c shared_cxx <nl> <nl> shared_c : pc_c pc_c_unsecure cache . mk $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) address_sorting $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) gpr $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc_cronet $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc_unsecure $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) upb $ ( SHARED_VERSION_CORE ) . $ ( SHARED_EXT_CORE ) <nl> - shared_cxx : pc_cxx pc_cxx_unsecure cache . mk $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _error_details $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _reflection $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _unsecure $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpcpp_channelz $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) <nl> + shared_cxx : pc_cxx pc_cxx_unsecure cache . mk $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _error_details $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _reflection $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _unsecure $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpcpp_channelz $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) <nl> <nl> shared_csharp : shared_c $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc_csharp_ext $ ( SHARED_VERSION_CSHARP ) . $ ( SHARED_EXT_CSHARP ) <nl> grpc_csharp_ext : shared_csharp <nl> ifeq ( $ ( EMBED_OPENSSL ) , true ) <nl> buildtests_cxx : privatelibs_cxx \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / alarm_test \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / alts_concurrent_connectivity_test \ <nl> + $ ( BINDIR ) / $ ( CONFIG ) / alts_context_test \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / alts_counter_test \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / alts_crypt_test \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / alts_crypter_test \ <nl> else <nl> buildtests_cxx : privatelibs_cxx \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / alarm_test \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / alts_concurrent_connectivity_test \ <nl> + $ ( BINDIR ) / $ ( CONFIG ) / alts_context_test \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / alts_counter_test \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / alts_crypt_test \ <nl> $ ( BINDIR ) / $ ( CONFIG ) / alts_crypter_test \ <nl> test_cxx : buildtests_cxx <nl> $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / alarm_test | | ( echo test alarm_test failed ; exit 1 ) <nl> $ ( E ) " [ RUN ] Testing alts_concurrent_connectivity_test " <nl> $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / alts_concurrent_connectivity_test | | ( echo test alts_concurrent_connectivity_test failed ; exit 1 ) <nl> + $ ( E ) " [ RUN ] Testing alts_context_test " <nl> + $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / alts_context_test | | ( echo test alts_context_test failed ; exit 1 ) <nl> $ ( E ) " [ RUN ] Testing alts_counter_test " <nl> $ ( Q ) $ ( BINDIR ) / $ ( CONFIG ) / alts_counter_test | | ( echo test alts_counter_test failed ; exit 1 ) <nl> $ ( E ) " [ RUN ] Testing alts_crypt_test " <nl> strip - static_cxx : static_cxx <nl> ifeq ( $ ( CONFIG ) , opt ) <nl> $ ( E ) " [ STRIP ] Stripping libgrpc + + . a " <nl> $ ( Q ) $ ( STRIP ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . a <nl> + $ ( E ) " [ STRIP ] Stripping libgrpc + + _alts . a " <nl> + $ ( Q ) $ ( STRIP ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a <nl> $ ( E ) " [ STRIP ] Stripping libgrpc + + _error_details . a " <nl> $ ( Q ) $ ( STRIP ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _error_details . a <nl> $ ( E ) " [ STRIP ] Stripping libgrpc + + _reflection . a " <nl> strip - shared_cxx : shared_cxx <nl> ifeq ( $ ( CONFIG ) , opt ) <nl> $ ( E ) " [ STRIP ] Stripping $ ( SHARED_PREFIX ) grpc + + $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) " <nl> $ ( Q ) $ ( STRIP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) <nl> + $ ( E ) " [ STRIP ] Stripping $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) " <nl> + $ ( Q ) $ ( STRIP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) <nl> $ ( E ) " [ STRIP ] Stripping $ ( SHARED_PREFIX ) grpc + + _error_details $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) " <nl> $ ( Q ) $ ( STRIP ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _error_details $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) <nl> $ ( E ) " [ STRIP ] Stripping $ ( SHARED_PREFIX ) grpc + + _reflection $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) " <nl> $ ( GENDIR ) / src / proto / grpc / core / stats . grpc . pb . cc : src / proto / grpc / core / stats . proto <nl> $ ( Q ) $ ( PROTOC ) - Ithird_party / protobuf / src - I . - - grpc_out = $ ( GENDIR ) - - plugin = protoc - gen - grpc = $ ( PROTOC_PLUGINS_DIR ) / grpc_cpp_plugin $ ( EXECUTABLE_SUFFIX ) $ < <nl> endif <nl> <nl> + ifeq ( $ ( NO_PROTOC ) , true ) <nl> + $ ( GENDIR ) / src / proto / grpc / gcp / altscontext . pb . cc : protoc_dep_error <nl> + $ ( GENDIR ) / src / proto / grpc / gcp / altscontext . grpc . pb . cc : protoc_dep_error <nl> + else <nl> + <nl> + $ ( GENDIR ) / src / proto / grpc / gcp / altscontext . pb . cc : src / proto / grpc / gcp / altscontext . proto $ ( PROTOBUF_DEP ) $ ( PROTOC_PLUGINS ) $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . pb . cc <nl> + $ ( E ) " [ PROTOC ] Generating protobuf CC file from $ < " <nl> + $ ( Q ) mkdir - p ` dirname $ @ ` <nl> + $ ( Q ) $ ( PROTOC ) - Ithird_party / protobuf / src - I . - - cpp_out = $ ( GENDIR ) $ < <nl> + <nl> + $ ( GENDIR ) / src / proto / grpc / gcp / altscontext . grpc . pb . cc : src / proto / grpc / gcp / altscontext . proto $ ( GENDIR ) / src / proto / grpc / gcp / altscontext . pb . cc $ ( PROTOBUF_DEP ) $ ( PROTOC_PLUGINS ) $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . pb . cc $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . grpc . pb . cc <nl> + $ ( E ) " [ GRPC ] Generating gRPC ' s protobuf service CC file from $ < " <nl> + $ ( Q ) mkdir - p ` dirname $ @ ` <nl> + $ ( Q ) $ ( PROTOC ) - Ithird_party / protobuf / src - I . - - grpc_out = $ ( GENDIR ) - - plugin = protoc - gen - grpc = $ ( PROTOC_PLUGINS_DIR ) / grpc_cpp_plugin $ ( EXECUTABLE_SUFFIX ) $ < <nl> + endif <nl> + <nl> + ifeq ( $ ( NO_PROTOC ) , true ) <nl> + $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . pb . cc : protoc_dep_error <nl> + $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . grpc . pb . cc : protoc_dep_error <nl> + else <nl> + <nl> + $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . pb . cc : src / proto / grpc / gcp / transport_security_common . proto $ ( PROTOBUF_DEP ) $ ( PROTOC_PLUGINS ) <nl> + $ ( E ) " [ PROTOC ] Generating protobuf CC file from $ < " <nl> + $ ( Q ) mkdir - p ` dirname $ @ ` <nl> + $ ( Q ) $ ( PROTOC ) - Ithird_party / protobuf / src - I . - - cpp_out = $ ( GENDIR ) $ < <nl> + <nl> + $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . grpc . pb . cc : src / proto / grpc / gcp / transport_security_common . proto $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . pb . cc $ ( PROTOBUF_DEP ) $ ( PROTOC_PLUGINS ) <nl> + $ ( E ) " [ GRPC ] Generating gRPC ' s protobuf service CC file from $ < " <nl> + $ ( Q ) mkdir - p ` dirname $ @ ` <nl> + $ ( Q ) $ ( PROTOC ) - Ithird_party / protobuf / src - I . - - grpc_out = $ ( GENDIR ) - - plugin = protoc - gen - grpc = $ ( PROTOC_PLUGINS_DIR ) / grpc_cpp_plugin $ ( EXECUTABLE_SUFFIX ) $ < <nl> + endif <nl> + <nl> ifeq ( $ ( NO_PROTOC ) , true ) <nl> $ ( GENDIR ) / src / proto / grpc / health / v1 / health . pb . cc : protoc_dep_error <nl> $ ( GENDIR ) / src / proto / grpc / health / v1 / health . grpc . pb . cc : protoc_dep_error <nl> install - static_cxx : static_cxx strip - static_cxx install - pkg - config_cxx <nl> $ ( E ) " [ INSTALL ] Installing libgrpc + + . a " <nl> $ ( Q ) $ ( INSTALL ) - d $ ( prefix ) / lib <nl> $ ( Q ) $ ( INSTALL ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . a $ ( prefix ) / lib / libgrpc + + . a <nl> + $ ( E ) " [ INSTALL ] Installing libgrpc + + _alts . a " <nl> + $ ( Q ) $ ( INSTALL ) - d $ ( prefix ) / lib <nl> + $ ( Q ) $ ( INSTALL ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a $ ( prefix ) / lib / libgrpc + + _alts . a <nl> $ ( E ) " [ INSTALL ] Installing libgrpc + + _error_details . a " <nl> $ ( Q ) $ ( INSTALL ) - d $ ( prefix ) / lib <nl> $ ( Q ) $ ( INSTALL ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _error_details . a $ ( prefix ) / lib / libgrpc + + _error_details . a <nl> ifeq ( $ ( SYSTEM ) , MINGW32 ) <nl> else ifneq ( $ ( SYSTEM ) , Darwin ) <nl> $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc + + $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( prefix ) / lib / libgrpc + + . so . 1 <nl> $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc + + $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( prefix ) / lib / libgrpc + + . so <nl> + endif <nl> + $ ( E ) " [ INSTALL ] Installing $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) " <nl> + $ ( Q ) $ ( INSTALL ) - d $ ( prefix ) / lib <nl> + $ ( Q ) $ ( INSTALL ) $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( prefix ) / lib / $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) <nl> + ifeq ( $ ( SYSTEM ) , MINGW32 ) <nl> + $ ( Q ) $ ( INSTALL ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts $ ( SHARED_VERSION_CPP ) - dll . a $ ( prefix ) / lib / libgrpc + + _alts . a <nl> + else ifneq ( $ ( SYSTEM ) , Darwin ) <nl> + $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( prefix ) / lib / libgrpc + + _alts . so . 1 <nl> + $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( prefix ) / lib / libgrpc + + _alts . so <nl> endif <nl> $ ( E ) " [ INSTALL ] Installing $ ( SHARED_PREFIX ) grpc + + _error_details $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) " <nl> $ ( Q ) $ ( INSTALL ) - d $ ( prefix ) / lib <nl> endif <nl> endif <nl> <nl> <nl> + LIBGRPC + + _ALTS_SRC = \ <nl> + $ ( GENDIR ) / src / proto / grpc / gcp / altscontext . pb . cc $ ( GENDIR ) / src / proto / grpc / gcp / altscontext . grpc . pb . cc \ <nl> + $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . pb . cc $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . grpc . pb . cc \ <nl> + src / cpp / common / alts_context . cc \ <nl> + <nl> + PUBLIC_HEADERS_CXX + = \ <nl> + include / grpcpp / alts_context . h \ <nl> + include / grpcpp / impl / codegen / security / auth_context . h \ <nl> + <nl> + LIBGRPC + + _ALTS_OBJS = $ ( addprefix $ ( OBJDIR ) / $ ( CONFIG ) / , $ ( addsuffix . o , $ ( basename $ ( LIBGRPC + + _ALTS_SRC ) ) ) ) <nl> + <nl> + <nl> + ifeq ( $ ( NO_SECURE ) , true ) <nl> + <nl> + # You can ' t build secure libraries if you don ' t have OpenSSL . <nl> + <nl> + $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a : openssl_dep_error <nl> + <nl> + $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) : openssl_dep_error <nl> + <nl> + else <nl> + <nl> + ifeq ( $ ( NO_PROTOBUF ) , true ) <nl> + <nl> + # You can ' t build a C + + library if you don ' t have protobuf - a bit overreached , but still okay . <nl> + <nl> + $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a : protobuf_dep_error <nl> + <nl> + $ ( LIBDIR ) / $ ( CONFIG ) / $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) : protobuf_dep_error <nl> + <nl> + else <nl> + <nl> + $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a : $ ( ZLIB_DEP ) $ ( OPENSSL_DEP ) $ ( CARES_DEP ) $ ( ADDRESS_SORTING_DEP ) $ ( UPB_DEP ) $ ( PROTOBUF_DEP ) $ ( LIBGRPC + + _ALTS_OBJS ) $ ( LIBGPR_OBJS ) $ ( ZLIB_MERGE_OBJS ) $ ( CARES_MERGE_OBJS ) $ ( ADDRESS_SORTING_MERGE_OBJS ) $ ( UPB_MERGE_OBJS ) <nl> + $ ( E ) " [ AR ] Creating $ @ " <nl> + $ ( Q ) mkdir - p ` dirname $ @ ` <nl> + $ ( Q ) rm - f $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a <nl> + $ ( Q ) $ ( AR ) $ ( AROPTS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a $ ( LIBGRPC + + _ALTS_OBJS ) $ ( LIBGPR_OBJS ) $ ( ZLIB_MERGE_OBJS ) $ ( CARES_MERGE_OBJS ) $ ( ADDRESS_SORTING_MERGE_OBJS ) $ ( UPB_MERGE_OBJS ) <nl> + ifeq ( $ ( SYSTEM ) , Darwin ) <nl> + $ ( Q ) ranlib - no_warning_for_no_symbols $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a <nl> + endif <nl> + <nl> + <nl> + <nl> + ifeq ( $ ( SYSTEM ) , MINGW32 ) <nl> + $ ( LIBDIR ) / $ ( CONFIG ) / grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) : $ ( LIBGRPC + + _ALTS_OBJS ) $ ( ZLIB_DEP ) $ ( CARES_DEP ) $ ( ADDRESS_SORTING_DEP ) $ ( UPB_DEP ) $ ( PROTOBUF_DEP ) $ ( LIBDIR ) / $ ( CONFIG ) / grpc + + $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( OPENSSL_DEP ) <nl> + $ ( E ) " [ LD ] Linking $ @ " <nl> + $ ( Q ) mkdir - p ` dirname $ @ ` <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - - output - def = $ ( LIBDIR ) / $ ( CONFIG ) / grpc + + _alts $ ( SHARED_VERSION_CPP ) . def - Wl , - - out - implib = $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts $ ( SHARED_VERSION_CPP ) - dll . a - o $ ( LIBDIR ) / $ ( CONFIG ) / grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBGRPC + + _ALTS_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( LDLIBSXX ) $ ( LDLIBS_PROTOBUF ) $ ( LDLIBS ) - lgrpc + + $ ( SHARED_VERSION_CPP ) - dll <nl> + else <nl> + $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) : $ ( LIBGRPC + + _ALTS_OBJS ) $ ( ZLIB_DEP ) $ ( CARES_DEP ) $ ( ADDRESS_SORTING_DEP ) $ ( UPB_DEP ) $ ( PROTOBUF_DEP ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . $ ( SHARED_EXT_CPP ) $ ( OPENSSL_DEP ) <nl> + $ ( E ) " [ LD ] Linking $ @ " <nl> + $ ( Q ) mkdir - p ` dirname $ @ ` <nl> + ifeq ( $ ( SYSTEM ) , Darwin ) <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - install_name $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) - dynamiclib - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBGRPC + + _ALTS_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( LDLIBSXX ) $ ( LDLIBS_PROTOBUF ) $ ( LDLIBS ) - lgrpc + + <nl> + else <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) - L $ ( LIBDIR ) / $ ( CONFIG ) - shared - Wl , - soname , libgrpc + + _alts . so . 1 - o $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBGRPC + + _ALTS_OBJS ) $ ( ZLIB_MERGE_LIBS ) $ ( CARES_MERGE_LIBS ) $ ( ADDRESS_SORTING_MERGE_LIBS ) $ ( UPB_MERGE_LIBS ) $ ( LDLIBSXX ) $ ( LDLIBS_PROTOBUF ) $ ( LDLIBS ) - lgrpc + + <nl> + $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts $ ( SHARED_VERSION_CPP ) . so . 1 <nl> + $ ( Q ) ln - sf $ ( SHARED_PREFIX ) grpc + + _alts $ ( SHARED_VERSION_CPP ) . $ ( SHARED_EXT_CPP ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts $ ( SHARED_VERSION_CPP ) . so <nl> + endif <nl> + endif <nl> + <nl> + endif <nl> + <nl> + endif <nl> + <nl> + ifneq ( $ ( NO_SECURE ) , true ) <nl> + ifneq ( $ ( NO_DEPS ) , true ) <nl> + - include $ ( LIBGRPC + + _ALTS_OBJS : . o = . dep ) <nl> + endif <nl> + endif <nl> + $ ( OBJDIR ) / $ ( CONFIG ) / src / cpp / common / alts_context . o : $ ( GENDIR ) / src / proto / grpc / gcp / altscontext . pb . cc $ ( GENDIR ) / src / proto / grpc / gcp / altscontext . grpc . pb . cc $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . pb . cc $ ( GENDIR ) / src / proto / grpc / gcp / transport_security_common . grpc . pb . cc <nl> + <nl> + <nl> LIBGRPC + + _CORE_STATS_SRC = \ <nl> $ ( GENDIR ) / src / proto / grpc / core / stats . pb . cc $ ( GENDIR ) / src / proto / grpc / core / stats . grpc . pb . cc \ <nl> src / cpp / util / core_stats . cc \ <nl> $ ( OBJDIR ) / $ ( CONFIG ) / test / core / tsi / alts / fake_handshaker / fake_handshaker_server . o : <nl> $ ( OBJDIR ) / $ ( CONFIG ) / test / core / tsi / alts / handshaker / alts_concurrent_connectivity_test . o : $ ( GENDIR ) / test / core / tsi / alts / fake_handshaker / handshaker . pb . cc $ ( GENDIR ) / test / core / tsi / alts / fake_handshaker / handshaker . grpc . pb . cc $ ( GENDIR ) / test / core / tsi / alts / fake_handshaker / transport_security_common . pb . cc $ ( GENDIR ) / test / core / tsi / alts / fake_handshaker / transport_security_common . grpc . pb . cc <nl> <nl> <nl> + ALTS_CONTEXT_TEST_SRC = \ <nl> + test / cpp / common / alts_context_test . cc \ <nl> + <nl> + ALTS_CONTEXT_TEST_OBJS = $ ( addprefix $ ( OBJDIR ) / $ ( CONFIG ) / , $ ( addsuffix . o , $ ( basename $ ( ALTS_CONTEXT_TEST_SRC ) ) ) ) <nl> + ifeq ( $ ( NO_SECURE ) , true ) <nl> + <nl> + # You can ' t build secure targets if you don ' t have OpenSSL . <nl> + <nl> + $ ( BINDIR ) / $ ( CONFIG ) / alts_context_test : openssl_dep_error <nl> + <nl> + else <nl> + <nl> + <nl> + <nl> + <nl> + ifeq ( $ ( NO_PROTOBUF ) , true ) <nl> + <nl> + # You can ' t build the protoc plugins or protobuf - enabled targets if you don ' t have protobuf 3 . 5 . 0 + . <nl> + <nl> + $ ( BINDIR ) / $ ( CONFIG ) / alts_context_test : protobuf_dep_error <nl> + <nl> + else <nl> + <nl> + $ ( BINDIR ) / $ ( CONFIG ) / alts_context_test : $ ( PROTOBUF_DEP ) $ ( ALTS_CONTEXT_TEST_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_config . a <nl> + $ ( E ) " [ LD ] Linking $ @ " <nl> + $ ( Q ) mkdir - p ` dirname $ @ ` <nl> + $ ( Q ) $ ( LDXX ) $ ( LDFLAGS ) $ ( ALTS_CONTEXT_TEST_OBJS ) $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_config . a $ ( LDLIBSXX ) $ ( LDLIBS_PROTOBUF ) $ ( LDLIBS ) $ ( LDLIBS_SECURE ) $ ( GTEST_LIB ) - o $ ( BINDIR ) / $ ( CONFIG ) / alts_context_test <nl> + <nl> + endif <nl> + <nl> + endif <nl> + <nl> + $ ( OBJDIR ) / $ ( CONFIG ) / test / cpp / common / alts_context_test . o : $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc_test_util . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _alts . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc . a $ ( LIBDIR ) / $ ( CONFIG ) / libgpr . a $ ( LIBDIR ) / $ ( CONFIG ) / libgrpc + + _test_config . a <nl> + <nl> + deps_alts_context_test : $ ( ALTS_CONTEXT_TEST_OBJS : . o = . dep ) <nl> + <nl> + ifneq ( $ ( NO_SECURE ) , true ) <nl> + ifneq ( $ ( NO_DEPS ) , true ) <nl> + - include $ ( ALTS_CONTEXT_TEST_OBJS : . o = . dep ) <nl> + endif <nl> + endif <nl> + <nl> + <nl> ALTS_COUNTER_TEST_SRC = \ <nl> test / core / tsi / alts / frame_protector / alts_counter_test . cc \ <nl> <nl> src / core / tsi / ssl_transport_security . cc : $ ( OPENSSL_DEP ) <nl> src / core / tsi / transport_security . cc : $ ( OPENSSL_DEP ) <nl> src / core / tsi / transport_security_grpc . cc : $ ( OPENSSL_DEP ) <nl> src / cpp / client / secure_credentials . cc : $ ( OPENSSL_DEP ) <nl> + src / cpp / common / alts_context . cc : $ ( OPENSSL_DEP ) <nl> src / cpp / common / auth_property_iterator . cc : $ ( OPENSSL_DEP ) <nl> src / cpp / common / secure_auth_context . cc : $ ( OPENSSL_DEP ) <nl> src / cpp / common / secure_channel_arguments . cc : $ ( OPENSSL_DEP ) <nl> mmm a / build . yaml <nl> ppp b / build . yaml <nl> libs : <nl> - grpc + + _codegen_proto <nl> - grpc + + _codegen_base_src <nl> secure : check <nl> + - name : grpc + + _alts <nl> + build : all <nl> + language : c + + <nl> + public_headers : <nl> + - include / grpcpp / alts_context . h <nl> + - include / grpcpp / impl / codegen / security / auth_context . h <nl> + src : <nl> + - src / proto / grpc / gcp / altscontext . proto <nl> + - src / proto / grpc / gcp / transport_security_common . proto <nl> + - src / cpp / common / alts_context . cc <nl> + deps : <nl> + - grpc + + <nl> + baselib : true <nl> - name : grpc + + _core_stats <nl> build : private <nl> language : c + + <nl> targets : <nl> - grpc + + _test_config <nl> platforms : <nl> - linux <nl> + - name : alts_context_test <nl> + build : test <nl> + language : c + + <nl> + src : <nl> + - test / cpp / common / alts_context_test . cc <nl> + deps : <nl> + - grpc + + _test_util <nl> + - grpc_test_util <nl> + - grpc + + _alts <nl> + - grpc + + <nl> + - grpc <nl> + - gpr <nl> + - grpc + + _test_config <nl> - name : alts_counter_test <nl> build : test <nl> language : c + + <nl> mmm a / grpc . gyp <nl> ppp b / grpc . gyp <nl> <nl> ' src / cpp / codegen / codegen_init . cc ' , <nl> ] , <nl> } , <nl> + { <nl> + ' target_name ' : ' grpc + + _alts ' , <nl> + ' type ' : ' static_library ' , <nl> + ' dependencies ' : [ <nl> + ' grpc + + ' , <nl> + ] , <nl> + ' sources ' : [ <nl> + ' src / proto / grpc / gcp / altscontext . proto ' , <nl> + ' src / proto / grpc / gcp / transport_security_common . proto ' , <nl> + ' src / cpp / common / alts_context . cc ' , <nl> + ] , <nl> + } , <nl> { <nl> ' target_name ' : ' grpc + + _core_stats ' , <nl> ' type ' : ' static_library ' , <nl> new file mode 100644 <nl> index 00000000000 . . ae4ce2bf69a <nl> mmm / dev / null <nl> ppp b / include / grpcpp / alts_context . h <nl> <nl> + / * <nl> + * <nl> + * Copyright 2019 gRPC authors . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * <nl> + * / <nl> + <nl> + # ifndef GRPCPP_ALTS_CONTEXT_H <nl> + # define GRPCPP_ALTS_CONTEXT_H <nl> + <nl> + # include < grpcpp / impl / codegen / security / auth_context . h > <nl> + # include < memory > <nl> + <nl> + namespace grpc { <nl> + <nl> + namespace gcp { <nl> + class AltsContext ; <nl> + } / / namespace gcp <nl> + <nl> + / / GetAltsContextFromAuthContext helps to get the AltsContext from AuthContext . <nl> + / / Please make sure the underlying protocol is ALTS before calling this <nl> + / / function . Otherwise a nullptr will be returned . <nl> + std : : unique_ptr < gcp : : AltsContext > GetAltsContextFromAuthContext ( <nl> + const AuthContext & auth_context ) ; <nl> + <nl> + } / / namespace grpc <nl> + <nl> + # endif / / GRPCPP_ALTS_CONTEXT_H <nl> new file mode 100644 <nl> index 00000000000 . . 5e41a8797a9 <nl> mmm / dev / null <nl> ppp b / src / cpp / common / alts_context . cc <nl> <nl> + / * <nl> + * <nl> + * Copyright 2019 gRPC authors . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * <nl> + * / <nl> + <nl> + # include < grpc / grpc_security . h > <nl> + # include < grpcpp / alts_context . h > <nl> + <nl> + # include " src / core / tsi / alts / handshaker / alts_tsi_handshaker . h " <nl> + # include " src / cpp / common / secure_auth_context . h " <nl> + # include " src / proto / grpc / gcp / altscontext . pb . h " <nl> + <nl> + namespace grpc { <nl> + std : : unique_ptr < gcp : : AltsContext > GetAltsContextFromAuthContext ( <nl> + const AuthContext & auth_context ) { <nl> + std : : vector < string_ref > ctx_vector = <nl> + auth_context . FindPropertyValues ( TSI_ALTS_CONTEXT ) ; <nl> + if ( ctx_vector . size ( ) ! = 1 ) { <nl> + gpr_log ( GPR_ERROR , " contains zero or more than one ALTS context . " ) ; <nl> + return nullptr ; <nl> + } <nl> + std : : unique_ptr < gcp : : AltsContext > uniq_ctx ( new gcp : : AltsContext ( ) ) ; <nl> + bool success = uniq_ctx . get ( ) - > ParseFromArray ( ctx_vector [ 0 ] . data ( ) , <nl> + ctx_vector [ 0 ] . size ( ) ) ; <nl> + if ( ! success ) { <nl> + gpr_log ( GPR_ERROR , " fails to parse ALTS context . " ) ; <nl> + return nullptr ; <nl> + } <nl> + return uniq_ctx ; <nl> + } <nl> + } / / namespace grpc <nl> mmm a / src / proto / grpc / gcp / BUILD <nl> ppp b / src / proto / grpc / gcp / BUILD <nl> proto_library ( <nl> ] , <nl> visibility = [ " / / visibility : public " ] , <nl> ) <nl> + <nl> + cc_proto_library ( <nl> + name = " alts_handshaker_cc_proto " , <nl> + visibility = [ " / / visibility : public " ] , <nl> + deps = [ <nl> + " alts_handshaker_proto " , <nl> + ] , <nl> + ) <nl> mmm a / test / cpp / common / BUILD <nl> ppp b / test / cpp / common / BUILD <nl> grpc_cc_test ( <nl> " / / test / cpp / util : test_util " , <nl> ] , <nl> ) <nl> + <nl> + grpc_cc_test ( <nl> + name = " alts_context_test " , <nl> + srcs = [ " alts_context_test . cc " ] , <nl> + external_deps = [ <nl> + " gtest " , <nl> + ] , <nl> + deps = [ <nl> + " / / : grpc + + _alts " , <nl> + " / / test / core / util : grpc_test_util " , <nl> + " / / test / cpp / util : test_util " , <nl> + ] , <nl> + ) <nl> new file mode 100644 <nl> index 00000000000 . . a3b77e2f1aa <nl> mmm / dev / null <nl> ppp b / test / cpp / common / alts_context_test . cc <nl> <nl> + / * <nl> + * <nl> + * Copyright 2019 gRPC authors . <nl> + * <nl> + * Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + * you may not use this file except in compliance with the License . <nl> + * You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , software <nl> + * distributed under the License is distributed on an " AS IS " BASIS , <nl> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + * See the License for the specific language governing permissions and <nl> + * limitations under the License . <nl> + * <nl> + * / <nl> + <nl> + # include < grpcpp / alts_context . h > <nl> + # include < grpcpp / security / auth_context . h > <nl> + <nl> + # include " src / core / tsi / alts / handshaker / alts_tsi_handshaker . h " <nl> + # include " src / cpp / common / secure_auth_context . h " <nl> + # include " src / proto / grpc / gcp / altscontext . pb . h " <nl> + # include " test / cpp / util / string_ref_helper . h " <nl> + <nl> + # include < gtest / gtest . h > <nl> + <nl> + using grpc : : testing : : ToString ; <nl> + <nl> + namespace grpc { <nl> + namespace { <nl> + <nl> + TEST ( AltsContextTest , EmptyAuthContext ) { <nl> + SecureAuthContext context ( nullptr ) ; <nl> + std : : unique_ptr < gcp : : AltsContext > alts_context = <nl> + GetAltsContextFromAuthContext ( context ) ; <nl> + EXPECT_EQ ( alts_context . get ( ) , nullptr ) ; <nl> + } <nl> + <nl> + TEST ( AltsContextTest , AuthContextWithMoreThanOneAltsContext ) { <nl> + grpc_core : : RefCountedPtr < grpc_auth_context > ctx = <nl> + grpc_core : : MakeRefCounted < grpc_auth_context > ( nullptr ) ; <nl> + SecureAuthContext context ( ctx . get ( ) ) ; <nl> + ctx . reset ( ) ; <nl> + context . AddProperty ( TSI_ALTS_CONTEXT , " context1 " ) ; <nl> + context . AddProperty ( TSI_ALTS_CONTEXT , " context2 " ) ; <nl> + std : : unique_ptr < gcp : : AltsContext > alts_context = <nl> + GetAltsContextFromAuthContext ( context ) ; <nl> + EXPECT_EQ ( alts_context . get ( ) , nullptr ) ; <nl> + } <nl> + <nl> + TEST ( AltsContextTest , AuthContextWithBadAltsContext ) { <nl> + grpc_core : : RefCountedPtr < grpc_auth_context > ctx = <nl> + grpc_core : : MakeRefCounted < grpc_auth_context > ( nullptr ) ; <nl> + SecureAuthContext context ( ctx . get ( ) ) ; <nl> + ctx . reset ( ) ; <nl> + context . AddProperty ( TSI_ALTS_CONTEXT , " bad context string serialization " ) ; <nl> + std : : unique_ptr < gcp : : AltsContext > alts_context = <nl> + GetAltsContextFromAuthContext ( context ) ; <nl> + EXPECT_EQ ( alts_context . get ( ) , nullptr ) ; <nl> + } <nl> + <nl> + TEST ( AltsContextTest , AuthContextWithGoodAltsContext ) { <nl> + grpc_core : : RefCountedPtr < grpc_auth_context > ctx = <nl> + grpc_core : : MakeRefCounted < grpc_auth_context > ( nullptr ) ; <nl> + SecureAuthContext context ( ctx . get ( ) ) ; <nl> + ctx . reset ( ) ; <nl> + std : : string expected_application_protocol ( " application protocol " ) ; <nl> + std : : string expected_record_protocol ( " record protocol " ) ; <nl> + std : : string expected_peer_id ( " peer " ) ; <nl> + std : : string expected_local_id ( " local " ) ; <nl> + gcp : : AltsContext expect_alts_ctx ; <nl> + expect_alts_ctx . set_application_protocol ( expected_application_protocol ) ; <nl> + expect_alts_ctx . set_record_protocol ( expected_record_protocol ) ; <nl> + expect_alts_ctx . set_peer_service_account ( expected_peer_id ) ; <nl> + expect_alts_ctx . set_local_service_account ( expected_local_id ) ; <nl> + std : : string serialized_alts_ctx ; <nl> + bool success = expect_alts_ctx . SerializeToString ( & serialized_alts_ctx ) ; <nl> + EXPECT_TRUE ( success ) ; <nl> + context . AddProperty ( TSI_ALTS_CONTEXT , serialized_alts_ctx ) ; <nl> + std : : unique_ptr < gcp : : AltsContext > alts_ctx = <nl> + GetAltsContextFromAuthContext ( context ) ; <nl> + EXPECT_EQ ( expected_application_protocol , alts_ctx - > application_protocol ( ) ) ; <nl> + EXPECT_EQ ( expected_record_protocol , alts_ctx - > record_protocol ( ) ) ; <nl> + EXPECT_EQ ( expected_peer_id , alts_ctx - > peer_service_account ( ) ) ; <nl> + EXPECT_EQ ( expected_local_id , alts_ctx - > local_service_account ( ) ) ; <nl> + } <nl> + <nl> + } / / namespace <nl> + } / / namespace grpc <nl> + <nl> + int main ( int argc , char * * argv ) { <nl> + : : testing : : InitGoogleTest ( & argc , argv ) ; <nl> + return RUN_ALL_TESTS ( ) ; <nl> + } <nl> mmm a / tools / run_tests / generated / tests . json <nl> ppp b / tools / run_tests / generated / tests . json <nl> <nl> ] , <nl> " uses_polling " : true <nl> } , <nl> + { <nl> + " args " : [ ] , <nl> + " benchmark " : false , <nl> + " ci_platforms " : [ <nl> + " linux " , <nl> + " mac " , <nl> + " posix " , <nl> + " windows " <nl> + ] , <nl> + " cpu_cost " : 1 . 0 , <nl> + " exclude_configs " : [ ] , <nl> + " exclude_iomgrs " : [ ] , <nl> + " flaky " : false , <nl> + " gtest " : false , <nl> + " language " : " c + + " , <nl> + " name " : " alts_context_test " , <nl> + " platforms " : [ <nl> + " linux " , <nl> + " mac " , <nl> + " posix " , <nl> + " windows " <nl> + ] , <nl> + " uses_polling " : true <nl> + } , <nl> { <nl> " args " : [ ] , <nl> " benchmark " : false , <nl> | Merge pull request from ZhenLian / zhen_alts_context_C + + _2 | grpc/grpc | 69112951f4e389b9bbb6da3e58529c28e0b515b4 | 2019-11-26T17:56:33Z |
mmm a / brightray / browser / inspectable_web_contents_impl . cc <nl> ppp b / brightray / browser / inspectable_web_contents_impl . cc <nl> <nl> # include " content / public / browser / host_zoom_map . h " <nl> # include " content / public / browser / render_frame_host . h " <nl> # include " content / public / browser / render_view_host . h " <nl> + # include " content / public / common / user_agent . h " <nl> # include " net / http / http_response_headers . h " <nl> # include " net / url_request / url_fetcher . h " <nl> # include " net / url_request / url_fetcher_response_writer . h " <nl> const double kPresetZoomFactors [ ] = { 0 . 25 , 0 . 333 , 0 . 5 , 0 . 666 , 0 . 75 , 0 . 9 , 1 . 0 , <nl> <nl> const char kChromeUIDevToolsURL [ ] = <nl> " chrome - devtools : / / devtools / bundled / inspector . html ? " <nl> + " remoteBase = % s & " <nl> " can_dock = % s & " <nl> " toolbarColor = rgba ( 223 , 223 , 223 , 1 ) & " <nl> " textColor = rgba ( 0 , 0 , 0 , 1 ) & " <nl> " experiments = true " ; <nl> + const char kChromeUIDevToolsRemoteFrontendBase [ ] = <nl> + " https : / / chrome - devtools - frontend . appspot . com / " ; <nl> + const char kChromeUIDevToolsRemoteFrontendPath [ ] = " serve_file " ; <nl> <nl> const char kDevToolsBoundsPref [ ] = " brightray . devtools . bounds " ; <nl> const char kDevToolsZoomPref [ ] = " brightray . devtools . zoom " ; <nl> double GetNextZoomLevel ( double level , bool out ) { <nl> return level ; <nl> } <nl> <nl> + GURL GetRemoteBaseURL ( ) { <nl> + return GURL ( base : : StringPrintf ( <nl> + " % s % s / % s / " , <nl> + kChromeUIDevToolsRemoteFrontendBase , <nl> + kChromeUIDevToolsRemoteFrontendPath , <nl> + content : : GetWebKitRevision ( ) . c_str ( ) ) ) ; <nl> + } <nl> + <nl> / / ResponseWriter mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> <nl> class ResponseWriter : public net : : URLFetcherResponseWriter { <nl> void InspectableWebContentsImpl : : ShowDevTools ( ) { <nl> web_contents_ - > GetMainFrame ( ) , this ) ) ; <nl> agent_host_ - > AttachClient ( this ) ; <nl> <nl> - GURL devtools_url ( base : : StringPrintf ( kChromeUIDevToolsURL , can_dock_ ? " true " : " " ) ) ; <nl> + GURL devtools_url ( base : : StringPrintf ( kChromeUIDevToolsURL , <nl> + GetRemoteBaseURL ( ) . spec ( ) . c_str ( ) , <nl> + can_dock_ ? " true " : " " ) ) ; <nl> devtools_web_contents_ - > GetController ( ) . LoadURL ( <nl> devtools_url , <nl> content : : Referrer ( ) , <nl> | Merge pull request from deepak1556 / remote_devtools_module_patch | electron/electron | c9956c2ae0e3bdc8658dc911b8e4acc2c239855c | 2015-10-01T09:02:56Z |
mmm a / tensorflow / core / kernels / cuda_sparse . cc <nl> ppp b / tensorflow / core / kernels / cuda_sparse . cc <nl> limitations under the License . <nl> # include < vector > <nl> <nl> # include " third_party / gpus / cuda / include / cusparse . h " <nl> + # include " third_party / gpus / cuda / include / library_types . h " <nl> # include " tensorflow / core / common_runtime / gpu / gpu_event_mgr . h " <nl> # include " tensorflow / core / framework / op_kernel . h " <nl> # include " tensorflow / core / framework / types . h " <nl> Status GpuSparse : : Initialize ( ) { <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> + # define TF_CALL_CUSPARSE_DTYPES ( m ) \ <nl> + m ( float , CUDA_R_32F ) m ( double , CUDA_R_64F ) \ <nl> + m ( std : : complex < float > , CUDA_C_32F ) m ( std : : complex < double > , CUDA_C_64F ) <nl> + <nl> / / Macro that specializes a sparse method for all 4 standard <nl> / / numeric types . <nl> / / TODO : reuse with cuda_solvers <nl> Status GpuSparse : : Csr2coo ( const int * csrRowPtr , int nnz , int m , <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> - Status GpuSparse : : CsrgeamNnz ( int m , int n , const cusparseMatDescr_t descrA , <nl> - int nnzA , const int * csrSortedRowPtrA , <nl> - const int * csrSortedColIndA , <nl> - const cusparseMatDescr_t descrB , int nnzB , <nl> - const int * csrSortedRowPtrB , <nl> - const int * csrSortedColIndB , <nl> - const cusparseMatDescr_t descrC , <nl> - int * csrSortedRowPtrC , int * nnzTotalDevHostPtr ) { <nl> + Status GpuSparse : : CsrgeamNnz ( <nl> + int m , int n , const cusparseMatDescr_t descrA , int nnzA , <nl> + const int * csrSortedRowPtrA , const int * csrSortedColIndA , <nl> + const cusparseMatDescr_t descrB , int nnzB , const int * csrSortedRowPtrB , <nl> + const int * csrSortedColIndB , const cusparseMatDescr_t descrC , <nl> + int * csrSortedRowPtrC , int * nnzTotalDevHostPtr , void * workspace ) { <nl> DCHECK ( initialized_ ) ; <nl> DCHECK ( nnzTotalDevHostPtr ! = nullptr ) ; <nl> + # if CUDA_VERSION > = 10000 <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseXcsrgeam2Nnz ( <nl> + * gpusparse_handle_ , m , n , descrA , nnzA , csrSortedRowPtrA , <nl> + csrSortedColIndA , descrB , nnzB , csrSortedRowPtrB , csrSortedColIndB , <nl> + descrC , csrSortedRowPtrC , nnzTotalDevHostPtr , workspace ) ) ; <nl> + # else <nl> TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseXcsrgeamNnz ( <nl> * gpusparse_handle_ , m , n , descrA , nnzA , csrSortedRowPtrA , <nl> csrSortedColIndA , descrB , nnzB , csrSortedRowPtrB , csrSortedColIndB , <nl> descrC , csrSortedRowPtrC , nnzTotalDevHostPtr ) ) ; <nl> + # endif <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> + # if CUDA_VERSION < 10020 <nl> + <nl> template < typename Scalar , typename SparseFnT > <nl> static inline Status CsrmmImpl ( <nl> SparseFnT op , OpKernelContext * context , cusparseHandle_t cusparse_handle , <nl> static inline Status CsrmmImpl ( <nl> <nl> TF_CALL_LAPACK_TYPES ( CSRMM_INSTANCE ) ; <nl> <nl> + # else <nl> + <nl> + # define SPMM_BUFFERSIZE_INSTANCE ( Scalar , dtype ) \ <nl> + template < > \ <nl> + Status GpuSparse : : SpMMBufferSize < Scalar > ( \ <nl> + cusparseOperation_t transA , cusparseOperation_t transB , \ <nl> + const Scalar * alpha , const cusparseSpMatDescr_t matA , \ <nl> + const gpusparseDnMatDescr_t matB , const Scalar * beta , \ <nl> + gpusparseDnMatDescr_t matC , cusparseSpMMAlg_t alg , size_t * bufferSize ) \ <nl> + const { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseSpMM_bufferSize ( \ <nl> + * gpusparse_handle_ , transA , transB , alpha , matA , matB , beta , matC , \ <nl> + dtype , alg , bufferSize ) ) ; \ <nl> + return Status : : OK ( ) ; \ <nl> + } <nl> + <nl> + TF_CALL_CUSPARSE_DTYPES ( SPMM_BUFFERSIZE_INSTANCE ) ; <nl> + <nl> + # define SPMM_INSTANCE ( Scalar , dtype ) \ <nl> + template < > \ <nl> + Status GpuSparse : : SpMM < Scalar > ( \ <nl> + cusparseOperation_t transA , cusparseOperation_t transB , \ <nl> + const Scalar * alpha , const cusparseSpMatDescr_t matA , \ <nl> + const gpusparseDnMatDescr_t matB , const Scalar * beta , \ <nl> + gpusparseDnMatDescr_t matC , cusparseSpMMAlg_t alg , int8 * buffer ) const { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseSpMM ( * gpusparse_handle_ , transA , \ <nl> + transB , alpha , matA , matB , beta , \ <nl> + matC , dtype , alg , buffer ) ) ; \ <nl> + return Status : : OK ( ) ; \ <nl> + } <nl> + <nl> + TF_CALL_CUSPARSE_DTYPES ( SPMM_INSTANCE ) ; <nl> + <nl> + # endif <nl> + <nl> + # if CUDA_VERSION < 10020 <nl> + <nl> template < typename Scalar , typename SparseFnT > <nl> static inline Status CsrmvImpl ( <nl> SparseFnT op , OpKernelContext * context , cusparseHandle_t cusparse_handle , <nl> static inline Status CsrmvImpl ( <nl> <nl> TF_CALL_LAPACK_TYPES ( CSRMV_INSTANCE ) ; <nl> <nl> + # else <nl> + <nl> + template < typename Scalar > <nl> + static inline Status CsrmvExImpl ( cudaDataType_t dtype , OpKernelContext * context , <nl> + cusparseHandle_t cusparse_handle , <nl> + cusparseOperation_t transA , int m , int n , <nl> + int nnz , const Scalar * alpha_host , <nl> + const Scalar * csrSortedValA , <nl> + const int * csrSortedRowPtrA , <nl> + const int * csrSortedColIndA , const Scalar * x , <nl> + const Scalar * beta_host , Scalar * y ) { <nl> + cusparseMatDescr_t descrA ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseCreateMatDescr ( & descrA ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseSetMatType ( descrA , CUSPARSE_MATRIX_TYPE_GENERAL ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseSetMatIndexBase ( descrA , CUSPARSE_INDEX_BASE_ZERO ) ) ; <nl> + / / CUSPARSE_ALG_MERGE_PATH algo only supports non - transpose matrix . <nl> + DCHECK ( transA = = CUSPARSE_OPERATION_NON_TRANSPOSE ) ; <nl> + <nl> + size_t bufferSize ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseCsrmvEx_bufferSize ( <nl> + cusparse_handle , CUSPARSE_ALG_MERGE_PATH , transA , m , n , nnz , alpha_host , <nl> + dtype , descrA , csrSortedValA , dtype , csrSortedRowPtrA , csrSortedColIndA , <nl> + x , dtype , beta_host , dtype , y , dtype , dtype , & bufferSize ) ) ; <nl> + <nl> + Tensor buffer ; <nl> + TF_RETURN_IF_ERROR ( context - > allocate_temp ( <nl> + DT_INT8 , TensorShape ( { static_cast < int64 > ( bufferSize ) } ) , & buffer ) ) ; <nl> + auto pBuffer = buffer . flat < int8 > ( ) ; <nl> + DCHECK ( pBuffer . data ( ) ! = nullptr ) ; <nl> + <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseCsrmvEx ( <nl> + cusparse_handle , CUSPARSE_ALG_MERGE_PATH , transA , m , n , nnz , alpha_host , <nl> + dtype , descrA , csrSortedValA , dtype , csrSortedRowPtrA , csrSortedColIndA , <nl> + x , dtype , beta_host , dtype , y , dtype , dtype , pBuffer . data ( ) ) ) ; <nl> + <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseDestroyMatDescr ( descrA ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + template < typename Scalar > <nl> + static inline Status SpMVImpl ( cudaDataType_t dtype , OpKernelContext * context , <nl> + cusparseHandle_t cusparse_handle , <nl> + cusparseOperation_t transA , int m , int n , int nnz , <nl> + const Scalar * alpha_host , <nl> + const Scalar * csrSortedValA , <nl> + const int * csrSortedRowPtrA , <nl> + const int * csrSortedColIndA , const Scalar * x , <nl> + const Scalar * beta_host , Scalar * y ) { <nl> + cusparseSpMatDescr_t matA ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseCreateCsr ( <nl> + & matA , m , n , nnz , const_cast < int * > ( csrSortedRowPtrA ) , <nl> + const_cast < int * > ( csrSortedColIndA ) , const_cast < Scalar * > ( csrSortedValA ) , <nl> + CUSPARSE_INDEX_32I , CUSPARSE_INDEX_32I , CUSPARSE_INDEX_BASE_ZERO , dtype ) ) ; <nl> + <nl> + cusparseDnVecDescr_t vecX , vecY ; <nl> + int sizeX = ( transA = = CUSPARSE_OPERATION_NON_TRANSPOSE ) ? n : m ; <nl> + int sizeY = ( transA = = CUSPARSE_OPERATION_NON_TRANSPOSE ) ? m : n ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseCreateDnVec ( & vecX , sizeX , const_cast < Scalar * > ( x ) , dtype ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseCreateDnVec ( & vecY , sizeY , y , dtype ) ) ; <nl> + <nl> + size_t bufferSize ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseSpMV_bufferSize ( <nl> + cusparse_handle , transA , alpha_host , matA , vecX , beta_host , vecY , dtype , <nl> + CUSPARSE_CSRMV_ALG1 , & bufferSize ) ) ; <nl> + <nl> + Tensor buffer ; <nl> + TF_RETURN_IF_ERROR ( context - > allocate_temp ( <nl> + DT_INT8 , TensorShape ( { static_cast < int64 > ( bufferSize ) } ) , & buffer ) ) ; <nl> + auto pBuffer = buffer . flat < int8 > ( ) ; <nl> + DCHECK ( pBuffer . data ( ) ! = nullptr ) ; <nl> + <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseSpMV ( cusparse_handle , transA , alpha_host , matA , vecX , beta_host , <nl> + vecY , dtype , CUSPARSE_CSRMV_ALG1 , pBuffer . data ( ) ) ) ; <nl> + <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseDestroyDnVec ( vecY ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseDestroyDnVec ( vecX ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseDestroySpMat ( matA ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + # define CSRMV_INSTANCE ( Scalar , cudaDataType ) \ <nl> + template < > \ <nl> + Status GpuSparse : : Csrmv < Scalar > ( \ <nl> + cusparseOperation_t transA , int m , int n , int nnz , \ <nl> + const Scalar * alpha_host , const Scalar * csrSortedValA , \ <nl> + const int * csrSortedRowPtrA , const int * csrSortedColIndA , \ <nl> + const Scalar * x , const Scalar * beta_host , Scalar * y ) const { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + if ( transA = = CUSPARSE_OPERATION_NON_TRANSPOSE ) { \ <nl> + return CsrmvExImpl ( cudaDataType , context_ , * gpusparse_handle_ , transA , \ <nl> + m , n , nnz , alpha_host , csrSortedValA , \ <nl> + csrSortedRowPtrA , csrSortedColIndA , x , beta_host , y ) ; \ <nl> + } else { \ <nl> + return SpMVImpl ( cudaDataType , context_ , * gpusparse_handle_ , transA , m , \ <nl> + n , nnz , alpha_host , csrSortedValA , csrSortedRowPtrA , \ <nl> + csrSortedColIndA , x , beta_host , y ) ; \ <nl> + } \ <nl> + } <nl> + <nl> + TF_CALL_CUSPARSE_DTYPES ( CSRMV_INSTANCE ) ; <nl> + <nl> + # endif / / CUDA_VERSION < 10020 <nl> + <nl> + # if CUDA_VERSION < 10000 <nl> + <nl> template < typename Scalar , typename SparseFnT > <nl> static inline Status CsrgeamImpl ( <nl> SparseFnT op , OpKernelContext * context , cusparseHandle_t cusparse_handle , <nl> static inline Status CsrgeamImpl ( <nl> const cusparseMatDescr_t descrB , int nnzB , const Scalar * csrSortedValB , \ <nl> const int * csrSortedRowPtrB , const int * csrSortedColIndB , \ <nl> const cusparseMatDescr_t descrC , Scalar * csrSortedValC , \ <nl> - int * csrSortedRowPtrC , int * csrSortedColIndC ) { \ <nl> + int * csrSortedRowPtrC , int * csrSortedColIndC , void * workspace ) { \ <nl> DCHECK ( initialized_ ) ; \ <nl> return CsrgeamImpl ( SPARSE_FN ( csrgeam , sparse_prefix ) , context_ , \ <nl> * gpusparse_handle_ , m , n , alpha , descrA , nnzA , \ <nl> static inline Status CsrgeamImpl ( <nl> csrSortedRowPtrC , csrSortedColIndC ) ; \ <nl> } <nl> <nl> + # else <nl> + <nl> + template < typename Scalar , typename SparseFnT > <nl> + static inline Status Csrgeam2Impl ( <nl> + SparseFnT op , OpKernelContext * context , cusparseHandle_t cusparse_handle , <nl> + int m , int n , const Scalar * alpha , const cusparseMatDescr_t descrA , <nl> + int nnzA , const Scalar * csrSortedValA , const int * csrSortedRowPtrA , <nl> + const int * csrSortedColIndA , const Scalar * beta , <nl> + const cusparseMatDescr_t descrB , int nnzB , const Scalar * csrSortedValB , <nl> + const int * csrSortedRowPtrB , const int * csrSortedColIndB , <nl> + const cusparseMatDescr_t descrC , Scalar * csrSortedValC , <nl> + int * csrSortedRowPtrC , int * csrSortedColIndC , void * workspace ) { <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( op ( <nl> + cusparse_handle , m , n , AsCudaComplex ( alpha ) , descrA , nnzA , <nl> + AsCudaComplex ( csrSortedValA ) , csrSortedRowPtrA , csrSortedColIndA , <nl> + AsCudaComplex ( beta ) , descrB , nnzB , AsCudaComplex ( csrSortedValB ) , <nl> + csrSortedRowPtrB , csrSortedColIndB , descrC , AsCudaComplex ( csrSortedValC ) , <nl> + csrSortedRowPtrC , csrSortedColIndC , workspace ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + # define CSRGEAM_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status GpuSparse : : Csrgeam < Scalar > ( \ <nl> + int m , int n , const Scalar * alpha , const cusparseMatDescr_t descrA , \ <nl> + int nnzA , const Scalar * csrSortedValA , const int * csrSortedRowPtrA , \ <nl> + const int * csrSortedColIndA , const Scalar * beta , \ <nl> + const cusparseMatDescr_t descrB , int nnzB , const Scalar * csrSortedValB , \ <nl> + const int * csrSortedRowPtrB , const int * csrSortedColIndB , \ <nl> + const cusparseMatDescr_t descrC , Scalar * csrSortedValC , \ <nl> + int * csrSortedRowPtrC , int * csrSortedColIndC , void * workspace ) { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + return Csrgeam2Impl ( SPARSE_FN ( csrgeam2 , sparse_prefix ) , context_ , \ <nl> + * gpusparse_handle_ , m , n , alpha , descrA , nnzA , \ <nl> + csrSortedValA , csrSortedRowPtrA , csrSortedColIndA , \ <nl> + beta , descrB , nnzB , csrSortedValB , csrSortedRowPtrB , \ <nl> + csrSortedColIndB , descrC , csrSortedValC , \ <nl> + csrSortedRowPtrC , csrSortedColIndC , workspace ) ; \ <nl> + } <nl> + <nl> + # endif <nl> + <nl> TF_CALL_LAPACK_TYPES ( CSRGEAM_INSTANCE ) ; <nl> <nl> + # if CUDA_VERSION < 10000 <nl> + <nl> + # define CSRGEAM_BUFFERSIZE_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status GpuSparse : : CsrgeamBufferSizeExt < Scalar > ( \ <nl> + int m , int n , const Scalar * alpha , const cusparseMatDescr_t descrA , \ <nl> + int nnzA , const Scalar * csrSortedValA , const int * csrSortedRowPtrA , \ <nl> + const int * csrSortedColIndA , const Scalar * beta , \ <nl> + const cusparseMatDescr_t descrB , int nnzB , const Scalar * csrSortedValB , \ <nl> + const int * csrSortedRowPtrB , const int * csrSortedColIndB , \ <nl> + const cusparseMatDescr_t descrC , Scalar * csrSortedValC , \ <nl> + int * csrSortedRowPtrC , int * csrSortedColIndC , size_t * bufferSize ) { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + * bufferSize = 0 ; \ <nl> + return Status : : OK ( ) ; \ <nl> + } <nl> + <nl> + # else <nl> + <nl> + template < typename Scalar , typename SparseFnT > <nl> + static inline Status CsrgeamBufferSizeExtImpl ( <nl> + SparseFnT op , OpKernelContext * context , cusparseHandle_t sparse_handle , <nl> + int m , int n , const Scalar * alpha , const cusparseMatDescr_t descrA , <nl> + int nnzA , const Scalar * csrSortedValA , const int * csrSortedRowPtrA , <nl> + const int * csrSortedColIndA , const Scalar * beta , <nl> + const cusparseMatDescr_t descrB , int nnzB , const Scalar * csrSortedValB , <nl> + const int * csrSortedRowPtrB , const int * csrSortedColIndB , <nl> + const cusparseMatDescr_t descrC , Scalar * csrSortedValC , <nl> + int * csrSortedRowPtrC , int * csrSortedColIndC , size_t * bufferSize ) { <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( op ( <nl> + sparse_handle , m , n , AsCudaComplex ( alpha ) , descrA , nnzA , <nl> + AsCudaComplex ( csrSortedValA ) , csrSortedRowPtrA , csrSortedColIndA , <nl> + AsCudaComplex ( beta ) , descrB , nnzB , AsCudaComplex ( csrSortedValB ) , <nl> + csrSortedRowPtrB , csrSortedColIndB , descrC , AsCudaComplex ( csrSortedValC ) , <nl> + csrSortedRowPtrC , csrSortedColIndC , bufferSize ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + # define CSRGEAM_BUFFERSIZE_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status GpuSparse : : CsrgeamBufferSizeExt < Scalar > ( \ <nl> + int m , int n , const Scalar * alpha , const cusparseMatDescr_t descrA , \ <nl> + int nnzA , const Scalar * csrSortedValA , const int * csrSortedRowPtrA , \ <nl> + const int * csrSortedColIndA , const Scalar * beta , \ <nl> + const cusparseMatDescr_t descrB , int nnzB , const Scalar * csrSortedValB , \ <nl> + const int * csrSortedRowPtrB , const int * csrSortedColIndB , \ <nl> + const cusparseMatDescr_t descrC , Scalar * csrSortedValC , \ <nl> + int * csrSortedRowPtrC , int * csrSortedColIndC , size_t * bufferSize ) { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + return CsrgeamBufferSizeExtImpl ( \ <nl> + SPARSE_FN ( csrgeam2_bufferSizeExt , sparse_prefix ) , context_ , \ <nl> + * gpusparse_handle_ , m , n , alpha , descrA , nnzA , csrSortedValA , \ <nl> + csrSortedRowPtrA , csrSortedColIndA , beta , descrB , nnzB , csrSortedValB , \ <nl> + csrSortedRowPtrB , csrSortedColIndB , descrC , csrSortedValC , \ <nl> + csrSortedRowPtrC , csrSortedColIndC , bufferSize ) ; \ <nl> + } <nl> + <nl> + # endif <nl> + <nl> + TF_CALL_LAPACK_TYPES ( CSRGEAM_BUFFERSIZE_INSTANCE ) ; <nl> + <nl> + # if CUDA_VERSION < 10000 <nl> + <nl> Status GpuSparse : : CsrgemmNnz ( <nl> cusparseOperation_t transA , cusparseOperation_t transB , int m , int k , int n , <nl> const cusparseMatDescr_t descrA , int nnzA , const int * csrSortedRowPtrA , <nl> static inline Status CsrgemmImpl ( <nl> <nl> TF_CALL_LAPACK_TYPES ( CSRGEMM_INSTANCE ) ; <nl> <nl> + # else <nl> + <nl> + template < typename T > <nl> + static const T * one_ptr ( ) { <nl> + static const T one = static_cast < T > ( 1 ) ; <nl> + return & one ; <nl> + } <nl> + <nl> + template < typename T > <nl> + static const T * null_ptr ( ) { <nl> + return nullptr ; <nl> + } <nl> + <nl> + # define CSRGEMM_BUFFERSIZE_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status GpuSparse : : CsrgemmBufferSize < Scalar > ( \ <nl> + int m , int n , int k , const cusparseMatDescr_t descrA , int nnzA , \ <nl> + const int * csrSortedRowPtrA , const int * csrSortedColIndA , \ <nl> + const cusparseMatDescr_t descrB , int nnzB , const int * csrSortedRowPtrB , \ <nl> + const int * csrSortedColIndB , csrgemm2Info_t info , \ <nl> + size_t * workspaceBytes ) { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( SPARSE_FN ( csrgemm2_bufferSizeExt , \ <nl> + sparse_prefix ) ( \ <nl> + * gpusparse_handle_ , m , n , k , AsCudaComplex ( one_ptr < Scalar > ( ) ) , descrA , \ <nl> + nnzA , csrSortedRowPtrA , csrSortedColIndA , descrB , nnzB , \ <nl> + csrSortedRowPtrB , csrSortedColIndB , AsCudaComplex ( null_ptr < Scalar > ( ) ) , \ <nl> + descrA , 0 , null_ptr < int > ( ) , null_ptr < int > ( ) , info , workspaceBytes ) ) ; \ <nl> + return Status : : OK ( ) ; \ <nl> + } <nl> + <nl> + TF_CALL_LAPACK_TYPES ( CSRGEMM_BUFFERSIZE_INSTANCE ) ; <nl> + <nl> + Status GpuSparse : : CsrgemmNnz ( <nl> + int m , int n , int k , const cusparseMatDescr_t descrA , int nnzA , <nl> + const int * csrSortedRowPtrA , const int * csrSortedColIndA , <nl> + const cusparseMatDescr_t descrB , int nnzB , const int * csrSortedRowPtrB , <nl> + const int * csrSortedColIndB , const cusparseMatDescr_t descrC , <nl> + int * csrSortedRowPtrC , int * nnzTotalDevHostPtr , csrgemm2Info_t info , <nl> + void * workspace ) { <nl> + DCHECK ( initialized_ ) ; <nl> + DCHECK ( nnzTotalDevHostPtr ! = nullptr ) ; <nl> + <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseXcsrgemm2Nnz ( <nl> + * gpusparse_handle_ , m , n , k , descrA , nnzA , csrSortedRowPtrA , <nl> + csrSortedColIndA , descrB , nnzB , csrSortedRowPtrB , csrSortedColIndB , <nl> + descrA , 0 , null_ptr < int > ( ) , null_ptr < int > ( ) , descrC , csrSortedRowPtrC , <nl> + nnzTotalDevHostPtr , info , workspace ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + template < typename Scalar , typename SparseFnT > <nl> + static inline Status CsrgemmImpl ( <nl> + SparseFnT op , OpKernelContext * context , cusparseHandle_t cusparse_handle , <nl> + int m , int n , int k , const cusparseMatDescr_t descrA , int nnzA , <nl> + const Scalar * csrSortedValA , const int * csrSortedRowPtrA , <nl> + const int * csrSortedColIndA , const cusparseMatDescr_t descrB , int nnzB , <nl> + const Scalar * csrSortedValB , const int * csrSortedRowPtrB , <nl> + const int * csrSortedColIndB , const cusparseMatDescr_t descrC , <nl> + Scalar * csrSortedValC , int * csrSortedRowPtrC , int * csrSortedColIndC , <nl> + const csrgemm2Info_t info , void * workspace ) { <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + op ( cusparse_handle , m , n , k , AsCudaComplex ( one_ptr < Scalar > ( ) ) , descrA , <nl> + nnzA , AsCudaComplex ( csrSortedValA ) , csrSortedRowPtrA , csrSortedColIndA , <nl> + descrB , nnzB , AsCudaComplex ( csrSortedValB ) , csrSortedRowPtrB , <nl> + csrSortedColIndB , AsCudaComplex ( null_ptr < Scalar > ( ) ) , descrA , 0 , <nl> + AsCudaComplex ( null_ptr < Scalar > ( ) ) , null_ptr < int > ( ) , null_ptr < int > ( ) , <nl> + descrC , AsCudaComplex ( csrSortedValC ) , csrSortedRowPtrC , <nl> + csrSortedColIndC , info , workspace ) ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + # define CSRGEMM_INSTANCE ( Scalar , sparse_prefix ) \ <nl> + template < > \ <nl> + Status GpuSparse : : Csrgemm < Scalar > ( \ <nl> + int m , int n , int k , const cusparseMatDescr_t descrA , int nnzA , \ <nl> + const Scalar * csrSortedValA , const int * csrSortedRowPtrA , \ <nl> + const int * csrSortedColIndA , const cusparseMatDescr_t descrB , int nnzB , \ <nl> + const Scalar * csrSortedValB , const int * csrSortedRowPtrB , \ <nl> + const int * csrSortedColIndB , const cusparseMatDescr_t descrC , \ <nl> + Scalar * csrSortedValC , int * csrSortedRowPtrC , int * csrSortedColIndC , \ <nl> + const csrgemm2Info_t info , void * workspace ) { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + return CsrgemmImpl ( SPARSE_FN ( csrgemm2 , sparse_prefix ) , context_ , \ <nl> + * gpusparse_handle_ , m , n , k , descrA , nnzA , \ <nl> + csrSortedValA , csrSortedRowPtrA , csrSortedColIndA , \ <nl> + descrB , nnzB , csrSortedValB , csrSortedRowPtrB , \ <nl> + csrSortedColIndB , descrC , csrSortedValC , \ <nl> + csrSortedRowPtrC , csrSortedColIndC , info , workspace ) ; \ <nl> + } <nl> + <nl> + TF_CALL_LAPACK_TYPES ( CSRGEMM_INSTANCE ) ; <nl> + <nl> + # endif / / CUDA_VERSION < 10000 <nl> + <nl> template < typename Scalar , typename BufferSizeFnT , typename SparseFnT > <nl> static inline Status Csru2csrImpl ( SparseFnT op , BufferSizeFnT buffer_size_op , <nl> OpKernelContext * context , <nl> static inline Status Csru2csrImpl ( SparseFnT op , BufferSizeFnT buffer_size_op , <nl> <nl> TF_CALL_LAPACK_TYPES ( CSRU2CSR_INSTANCE ) ; <nl> <nl> + # if CUDA_VERSION < 10010 <nl> + <nl> template < typename Scalar , typename SparseFnT > <nl> static inline Status Csr2cscImpl ( SparseFnT op , OpKernelContext * context , <nl> cusparseHandle_t cusparse_handle , int m , int n , <nl> static inline Status Csr2cscImpl ( SparseFnT op , OpKernelContext * context , <nl> <nl> TF_CALL_LAPACK_TYPES ( CSR2CSC_INSTANCE ) ; <nl> <nl> + # else <nl> + <nl> + template < typename Scalar > <nl> + static inline Status Csr2cscImpl ( cudaDataType_t dtype , OpKernelContext * context , <nl> + cusparseHandle_t cusparse_handle , int m , int n , <nl> + int nnz , const Scalar * csrVal , <nl> + const int * csrRowPtr , const int * csrColInd , <nl> + Scalar * cscVal , int * cscRowInd , int * cscColPtr , <nl> + const cusparseAction_t copyValues ) { <nl> + size_t bufferSize ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseCsr2cscEx2_bufferSize ( <nl> + cusparse_handle , m , n , nnz , AsCudaComplex ( csrVal ) , csrRowPtr , csrColInd , <nl> + AsCudaComplex ( cscVal ) , cscColPtr , cscRowInd , dtype , copyValues , <nl> + CUSPARSE_INDEX_BASE_ZERO , CUSPARSE_CSR2CSC_ALG2 , & bufferSize ) ) ; <nl> + <nl> + Tensor buffer ; <nl> + TF_RETURN_IF_ERROR ( context - > allocate_temp ( <nl> + DataTypeToEnum < Scalar > : : value , <nl> + TensorShape ( { static_cast < int64 > ( bufferSize ) } ) , & buffer ) ) ; <nl> + <nl> + DCHECK ( buffer . flat < Scalar > ( ) . data ( ) ! = nullptr ) ; <nl> + <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseCsr2cscEx2 ( cusparse_handle , m , n , nnz , AsCudaComplex ( csrVal ) , <nl> + csrRowPtr , csrColInd , AsCudaComplex ( cscVal ) , cscColPtr , <nl> + cscRowInd , dtype , copyValues , CUSPARSE_INDEX_BASE_ZERO , <nl> + CUSPARSE_CSR2CSC_ALG2 , buffer . flat < Scalar > ( ) . data ( ) ) ) ; <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + # define CSR2CSC_INSTANCE ( Scalar , cudaDataType ) \ <nl> + template < > \ <nl> + Status GpuSparse : : Csr2csc < Scalar > ( \ <nl> + int m , int n , int nnz , const Scalar * csrVal , const int * csrRowPtr , \ <nl> + const int * csrColInd , Scalar * cscVal , int * cscRowInd , int * cscColPtr , \ <nl> + const cusparseAction_t copyValues ) { \ <nl> + DCHECK ( initialized_ ) ; \ <nl> + return Csr2cscImpl ( cudaDataType , context_ , * gpusparse_handle_ , m , n , nnz , \ <nl> + csrVal , csrRowPtr , csrColInd , cscVal , cscRowInd , \ <nl> + cscColPtr , copyValues ) ; \ <nl> + } <nl> + <nl> + TF_CALL_CUSPARSE_DTYPES ( CSR2CSC_INSTANCE ) ; <nl> + <nl> + # endif / / CUDA_VERSION < 10010 <nl> + <nl> } / / namespace tensorflow <nl> <nl> # endif / / GOOGLE_CUDA <nl> mmm a / tensorflow / core / kernels / cuda_sparse . h <nl> ppp b / tensorflow / core / kernels / cuda_sparse . h <nl> limitations under the License . <nl> <nl> # if GOOGLE_CUDA <nl> <nl> + # include " third_party / gpus / cuda / include / cuda . h " <nl> # include " third_party / gpus / cuda / include / cusparse . h " <nl> <nl> using gpusparseStatus_t = cusparseStatus_t ; <nl> using gpusparseMatDescr_t = cusparseMatDescr_t ; <nl> using gpusparseAction_t = cusparseAction_t ; <nl> using gpusparseHandle_t = cusparseHandle_t ; <nl> using gpuStream_t = cudaStream_t ; <nl> + # if CUDA_VERSION > = 10020 <nl> + using gpusparseDnMatDescr_t = cusparseDnMatDescr_t ; <nl> + using gpusparseSpMatDescr_t = cusparseSpMatDescr_t ; <nl> + using gpusparseSpMMAlg_t = cusparseSpMMAlg_t ; <nl> + # endif <nl> <nl> # define GPUSPARSE ( postfix ) CUSPARSE_ # # postfix <nl> # define gpusparse ( postfix ) cusparse # # postfix <nl> class GpuSparse { <nl> / / http : / / docs . nvidia . com / cuda / cusparse / index . html # cusparse - lt - t - gt - coo2csr . <nl> Status Coo2csr ( const int * cooRowInd , int nnz , int m , int * csrRowPtr ) const ; <nl> <nl> + # if CUDA_VERSION < 10020 <nl> / / Sparse - dense matrix multiplication C = alpha * op ( A ) * op ( B ) + beta * C , <nl> / / where A is a sparse matrix in CSR format , B and C are dense tall <nl> / / matrices . This routine allows transposition of matrix B , which <nl> class GpuSparse { <nl> const int * csrSortedRowPtrA , const int * csrSortedColIndA , <nl> const Scalar * B , int ldb , const Scalar * beta_host , Scalar * C , <nl> int ldc ) const ; <nl> + # else <nl> + / / Workspace size query for sparse - dense matrix multiplication . Helper <nl> + / / function for SpMM which computes y = alpha * op ( A ) * op ( B ) + beta * C , <nl> + / / where A is a sparse matrix in CSR format , B and C are dense matricies in <nl> + / / column - major format . Returns needed workspace size in bytes . <nl> + template < typename Scalar > <nl> + Status SpMMBufferSize ( gpusparseOperation_t transA , <nl> + gpusparseOperation_t transB , const Scalar * alpha , <nl> + const gpusparseSpMatDescr_t matA , <nl> + const gpusparseDnMatDescr_t matB , const Scalar * beta , <nl> + gpusparseDnMatDescr_t matC , gpusparseSpMMAlg_t alg , <nl> + size_t * bufferSize ) const ; <nl> + <nl> + / / Sparse - dense matrix multiplication y = alpha * op ( A ) * op ( B ) + beta * C , <nl> + / / where A is a sparse matrix in CSR format , B and C are dense matricies in <nl> + / / column - major format . Buffer is assumed to be at least as large as the <nl> + / / workspace size returned by SpMMBufferSize ( ) . <nl> + / / <nl> + / / * * NOTE * * This is an in - place operation for data in C . <nl> + template < typename Scalar > <nl> + Status SpMM ( gpusparseOperation_t transA , gpusparseOperation_t transB , <nl> + const Scalar * alpha , const gpusparseSpMatDescr_t matA , <nl> + const gpusparseDnMatDescr_t matB , const Scalar * beta , <nl> + gpusparseDnMatDescr_t matC , gpusparseSpMMAlg_t alg , <nl> + int8 * buffer ) const ; <nl> + # endif <nl> <nl> / / Sparse - dense vector multiplication y = alpha * op ( A ) * x + beta * y , <nl> / / where A is a sparse matrix in CSR format , x and y are dense vectors . See : <nl> / / http : / / docs . nvidia . com / cuda / cusparse / index . html # cusparse - lt - t - gt - csrmv_mergepath <nl> / / <nl> / / * * NOTE * * This is an in - place operation for data in y . <nl> + # if CUDA_VERSION < 10020 <nl> template < typename Scalar > <nl> Status Csrmv ( gpusparseOperation_t transA , int m , int n , int nnz , <nl> const Scalar * alpha_host , const gpusparseMatDescr_t descrA , <nl> const Scalar * csrSortedValA , const int * csrSortedRowPtrA , <nl> const int * csrSortedColIndA , const Scalar * x , <nl> const Scalar * beta_host , Scalar * y ) const ; <nl> + # else <nl> + template < typename Scalar > <nl> + Status Csrmv ( gpusparseOperation_t transA , int m , int n , int nnz , <nl> + const Scalar * alpha_host , const Scalar * csrSortedValA , <nl> + const int * csrSortedRowPtrA , const int * csrSortedColIndA , <nl> + const Scalar * x , const Scalar * beta_host , Scalar * y ) const ; <nl> + # endif / / CUDA_VERSION < 10020 <nl> + <nl> + / / Computes workspace size for sparse - sparse matrix addition of matrices <nl> + / / stored in CSR format . <nl> + template < typename Scalar > <nl> + Status CsrgeamBufferSizeExt ( <nl> + int m , int n , const Scalar * alpha , const gpusparseMatDescr_t descrA , <nl> + int nnzA , const Scalar * csrSortedValA , const int * csrSortedRowPtrA , <nl> + const int * csrSortedColIndA , const Scalar * beta , <nl> + const gpusparseMatDescr_t descrB , int nnzB , const Scalar * csrSortedValB , <nl> + const int * csrSortedRowPtrB , const int * csrSortedColIndB , <nl> + const gpusparseMatDescr_t descrC , Scalar * csrSortedValC , <nl> + int * csrSortedRowPtrC , int * csrSortedColIndC , size_t * bufferSize ) ; <nl> <nl> / / Computes sparse - sparse matrix addition of matrices <nl> / / stored in CSR format . This is part one : calculate nnz of the <nl> class GpuSparse { <nl> const gpusparseMatDescr_t descrB , int nnzB , <nl> const int * csrSortedRowPtrB , const int * csrSortedColIndB , <nl> const gpusparseMatDescr_t descrC , int * csrSortedRowPtrC , <nl> - int * nnzTotalDevHostPtr ) ; <nl> + int * nnzTotalDevHostPtr , void * workspace ) ; <nl> <nl> / / Computes sparse - sparse matrix addition of matrices <nl> / / stored in CSR format . This is part two : perform sparse - sparse <nl> class GpuSparse { <nl> const Scalar * csrSortedValB , const int * csrSortedRowPtrB , <nl> const int * csrSortedColIndB , const gpusparseMatDescr_t descrC , <nl> Scalar * csrSortedValC , int * csrSortedRowPtrC , <nl> - int * csrSortedColIndC ) ; <nl> + int * csrSortedColIndC , void * workspace ) ; <nl> + <nl> + # if CUDA_VERSION > = 10000 <nl> + / / Computes sparse - sparse matrix multiplication of matrices <nl> + / / stored in CSR format . This is part zero : calculate required workspace <nl> + / / size . <nl> + template < typename Scalar > <nl> + Status CsrgemmBufferSize ( <nl> + int m , int n , int k , const gpusparseMatDescr_t descrA , int nnzA , <nl> + const int * csrSortedRowPtrA , const int * csrSortedColIndA , <nl> + const gpusparseMatDescr_t descrB , int nnzB , const int * csrSortedRowPtrB , <nl> + const int * csrSortedColIndB , csrgemm2Info_t info , size_t * workspaceBytes ) ; <nl> + # endif <nl> <nl> / / Computes sparse - sparse matrix multiplication of matrices <nl> / / stored in CSR format . This is part one : calculate nnz of the <nl> / / output . csrSortedRowPtrC must be preallocated on device with <nl> / / m + 1 entries . See : <nl> / / http : / / docs . nvidia . com / cuda / cusparse / index . html # cusparse - lt - t - gt - csrgemm . <nl> + # if CUDA_VERSION < 10000 <nl> Status CsrgemmNnz ( gpusparseOperation_t transA , gpusparseOperation_t transB , <nl> int m , int k , int n , const gpusparseMatDescr_t descrA , <nl> int nnzA , const int * csrSortedRowPtrA , <nl> class GpuSparse { <nl> const int * csrSortedRowPtrB , const int * csrSortedColIndB , <nl> const gpusparseMatDescr_t descrC , int * csrSortedRowPtrC , <nl> int * nnzTotalDevHostPtr ) ; <nl> + # else <nl> + Status CsrgemmNnz ( int m , int n , int k , const gpusparseMatDescr_t descrA , <nl> + int nnzA , const int * csrSortedRowPtrA , <nl> + const int * csrSortedColIndA , <nl> + const gpusparseMatDescr_t descrB , int nnzB , <nl> + const int * csrSortedRowPtrB , const int * csrSortedColIndB , <nl> + const gpusparseMatDescr_t descrC , int * csrSortedRowPtrC , <nl> + int * nnzTotalDevHostPtr , csrgemm2Info_t info , <nl> + void * workspace ) ; <nl> + # endif <nl> <nl> / / Computes sparse - sparse matrix matmul of matrices <nl> / / stored in CSR format . This is part two : perform sparse - sparse <nl> / / addition . csrValC and csrColIndC must be allocated on the device <nl> / / with nnzTotalDevHostPtr entries ( as calculated by CsrgemmNnz ) . See : <nl> / / http : / / docs . nvidia . com / cuda / cusparse / index . html # cusparse - lt - t - gt - csrgemm . <nl> + # if CUDA_VERSION < 10000 <nl> template < typename Scalar > <nl> Status Csrgemm ( gpusparseOperation_t transA , gpusparseOperation_t transB , <nl> int m , int k , int n , const gpusparseMatDescr_t descrA , <nl> class GpuSparse { <nl> const int * csrSortedColIndB , const gpusparseMatDescr_t descrC , <nl> Scalar * csrSortedValC , int * csrSortedRowPtrC , <nl> int * csrSortedColIndC ) ; <nl> + # else <nl> + template < typename Scalar > <nl> + Status Csrgemm ( int m , int n , int k , const gpusparseMatDescr_t descrA , <nl> + int nnzA , const Scalar * csrSortedValA , <nl> + const int * csrSortedRowPtrA , const int * csrSortedColIndA , <nl> + const gpusparseMatDescr_t descrB , int nnzB , <nl> + const Scalar * csrSortedValB , const int * csrSortedRowPtrB , <nl> + const int * csrSortedColIndB , const gpusparseMatDescr_t descrC , <nl> + Scalar * csrSortedValC , int * csrSortedRowPtrC , <nl> + int * csrSortedColIndC , const csrgemm2Info_t info , <nl> + void * workspace ) ; <nl> + # endif <nl> <nl> / / In - place reordering of unsorted CSR to sorted CSR . <nl> / / http : / / docs . nvidia . com / cuda / cusparse / index . html # cusparse - lt - t - gt - csru2csr <nl> mmm a / tensorflow / core / kernels / sparse / add_op . cc <nl> ppp b / tensorflow / core / kernels / sparse / add_op . cc <nl> class CSRSparseMatrixAddFunctor { <nl> const Device & d = ctx_ - > eigen_device < Device > ( ) ; <nl> set_zero ( d , c_row_ptr_t . flat < int32 > ( ) ) ; <nl> <nl> + size_t maxWorkspaceSize = 0 ; <nl> + for ( int i = 0 ; i < batch_size ; + + i ) { <nl> + ConstCSRComponent < T > a_comp { a . row_pointers_vec ( i ) , a . col_indices_vec ( i ) , <nl> + a . values_vec < T > ( i ) , a_dense_shape } ; <nl> + ConstCSRComponent < T > b_comp { b . row_pointers_vec ( i ) , b . col_indices_vec ( i ) , <nl> + b . values_vec < T > ( i ) , b_dense_shape } ; <nl> + <nl> + size_t thisWorkspaceSize ; <nl> + TF_RETURN_IF_ERROR ( <nl> + csr_geam . GetWorkspaceSize ( a_comp , b_comp , & thisWorkspaceSize ) ) ; <nl> + if ( thisWorkspaceSize > maxWorkspaceSize ) { <nl> + maxWorkspaceSize = thisWorkspaceSize ; <nl> + } <nl> + } <nl> + <nl> + Tensor temp ; <nl> + TF_RETURN_IF_ERROR ( ctx_ - > allocate_temp ( <nl> + DT_INT8 , TensorShape ( { static_cast < int64 > ( maxWorkspaceSize ) } ) , & temp ) ) ; <nl> + void * workspace = temp . flat < int8 > ( ) . data ( ) ; <nl> + <nl> for ( int i = 0 ; i < batch_size ; + + i ) { <nl> / / Calculate output sizes for all minibatch entries . <nl> / / Store in c_batch_ptr and update c_row_ptrs . <nl> class CSRSparseMatrixAddFunctor { <nl> TTypes < int32 > : : UnalignedVec c_row_ptr_i ( & c_row_ptr ( i * ( rows + 1 ) ) , <nl> rows + 1 ) ; <nl> int c_nnz_i ; <nl> - TF_RETURN_IF_ERROR ( <nl> - csr_geam . GetOutputStructure ( a_comp , b_comp , c_row_ptr_i , & c_nnz_i ) ) ; <nl> + TF_RETURN_IF_ERROR ( csr_geam . GetOutputStructure ( <nl> + a_comp , b_comp , c_row_ptr_i , & c_nnz_i , workspace ) ) ; <nl> c_batch_ptr ( i + 1 ) = c_batch_ptr ( i ) + c_nnz_i ; <nl> } <nl> <nl> class CSRSparseMatrixAddFunctor { <nl> CSRComponent < T > c_comp { c - > row_pointers_vec ( i ) , c - > col_indices_vec ( i ) , <nl> c - > values_vec < T > ( i ) , c_dense_shape_t . vec < int64 > ( ) } ; <nl> <nl> - TF_RETURN_IF_ERROR ( csr_geam . Compute ( a_comp , b_comp , & c_comp ) ) ; <nl> + TF_RETURN_IF_ERROR ( csr_geam . Compute ( a_comp , b_comp , & c_comp , workspace ) ) ; <nl> } <nl> <nl> return Status : : OK ( ) ; <nl> struct CSRSparseMatrixAdd < GPUDevice , T > <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> + Status GetWorkspaceSize ( const ConstCSRComponent < T > & a , <nl> + const ConstCSRComponent < T > & b , size_t * bufferSize ) { <nl> + DCHECK ( initialized_ ) ; <nl> + <nl> + const int m = a . row_ptr . size ( ) - 1 ; <nl> + DCHECK_EQ ( m , b . row_ptr . size ( ) - 1 ) ; <nl> + const int row_dim = a . dense_shape_host . size ( ) = = 2 ? 0 : 1 ; <nl> + DCHECK_EQ ( m , a . dense_shape_host ( row_dim ) ) ; <nl> + DCHECK_EQ ( m , b . dense_shape_host ( row_dim ) ) ; <nl> + const int nnzA = a . col_ind . size ( ) ; <nl> + const int nnzB = b . col_ind . size ( ) ; <nl> + <nl> + const int n = a . dense_shape_host ( row_dim + 1 ) ; <nl> + DCHECK_EQ ( n , b . dense_shape_host ( row_dim + 1 ) ) ; <nl> + T * null_T = nullptr ; <nl> + int * null_int = nullptr ; <nl> + <nl> + TF_RETURN_IF_ERROR ( cuda_sparse_ . CsrgeamBufferSizeExt ( <nl> + m , n , & alpha_ , descrA_ . descr ( ) , nnzA , a . values . data ( ) , a . row_ptr . data ( ) , <nl> + a . col_ind . data ( ) , & beta_ , descrB_ . descr ( ) , nnzB , b . values . data ( ) , <nl> + b . row_ptr . data ( ) , b . col_ind . data ( ) , descrC_ . descr ( ) , null_T , null_int , <nl> + null_int , bufferSize ) ) ; <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> Status GetOutputStructure ( const ConstCSRComponent < T > & a , <nl> const ConstCSRComponent < T > & b , <nl> TTypes < int32 > : : UnalignedVec c_row_ptr , <nl> - int * output_nnz ) { <nl> + int * output_nnz , void * workspace ) { <nl> DCHECK ( initialized_ ) ; <nl> <nl> const int m = a . row_ptr . size ( ) - 1 ; <nl> struct CSRSparseMatrixAdd < GPUDevice , T > <nl> TF_RETURN_IF_ERROR ( cuda_sparse_ . CsrgeamNnz ( <nl> m , n , descrA_ . descr ( ) , nnzA , a . row_ptr . data ( ) , a . col_ind . data ( ) , <nl> descrB_ . descr ( ) , nnzB , b . row_ptr . data ( ) , b . col_ind . data ( ) , <nl> - descrC_ . descr ( ) , c_row_ptr . data ( ) , output_nnz ) ) ; <nl> + descrC_ . descr ( ) , c_row_ptr . data ( ) , output_nnz , workspace ) ) ; <nl> <nl> if ( * output_nnz < 0 ) { <nl> return errors : : Internal ( <nl> struct CSRSparseMatrixAdd < GPUDevice , T > <nl> } <nl> <nl> Status Compute ( const ConstCSRComponent < T > & a , const ConstCSRComponent < T > & b , <nl> - CSRComponent < T > * c ) { <nl> + CSRComponent < T > * c , void * workspace ) { <nl> DCHECK ( initialized_ ) ; <nl> <nl> const int m = a . row_ptr . size ( ) - 1 ; <nl> struct CSRSparseMatrixAdd < GPUDevice , T > <nl> m , n , & alpha_ , descrA_ . descr ( ) , nnzA , a . values . data ( ) , a . row_ptr . data ( ) , <nl> a . col_ind . data ( ) , & beta_ , descrB_ . descr ( ) , nnzB , b . values . data ( ) , <nl> b . row_ptr . data ( ) , b . col_ind . data ( ) , descrC_ . descr ( ) , c - > values . data ( ) , <nl> - c - > row_ptr . data ( ) , c - > col_ind . data ( ) ) ) ; <nl> + c - > row_ptr . data ( ) , c - > col_ind . data ( ) , workspace ) ) ; <nl> <nl> return Status : : OK ( ) ; <nl> } <nl> mmm a / tensorflow / core / kernels / sparse / kernels . h <nl> ppp b / tensorflow / core / kernels / sparse / kernels . h <nl> struct CSRStructureModifyingFunctor { <nl> <nl> virtual Status Initialize ( ) = 0 ; <nl> <nl> + virtual Status GetWorkspaceSize ( const ConstCSRComponent < T > & a , <nl> + const ConstCSRComponent < T > & b , <nl> + size_t * bufferSize ) = 0 ; <nl> + <nl> virtual Status GetOutputStructure ( const ConstCSRComponent < T > & a , <nl> const ConstCSRComponent < T > & b , <nl> TTypes < int32 > : : UnalignedVec c_row_ptr , <nl> - int * output_nnz ) = 0 ; <nl> + int * output_nnz , void * workspace ) = 0 ; <nl> <nl> virtual Status Compute ( const ConstCSRComponent < T > & a , <nl> - const ConstCSRComponent < T > & b , CSRComponent < T > * c ) = 0 ; <nl> + const ConstCSRComponent < T > & b , CSRComponent < T > * c , <nl> + void * workspace ) = 0 ; <nl> } ; <nl> <nl> / / Calculates C = alpha * A + beta * B , where A and B are in CSR <nl> mmm a / tensorflow / core / kernels / sparse / mat_mul_op . cc <nl> ppp b / tensorflow / core / kernels / sparse / mat_mul_op . cc <nl> REGISTER_GPU ( complex128 ) <nl> <nl> namespace functor { <nl> <nl> + namespace { <nl> + <nl> + / / CUDADataType < T > : : type translates from a C + + type ( e . g . float ) to a <nl> + / / cudaDataType_t ( e . g . CUDA_R_32F ) . <nl> + template < typename T > <nl> + struct CUDADataType ; <nl> + <nl> + template < > <nl> + struct CUDADataType < Eigen : : half > { <nl> + static constexpr cudaDataType_t type = CUDA_R_16F ; <nl> + } ; <nl> + <nl> + template < > <nl> + struct CUDADataType < float > { <nl> + # if GOOGLE_CUDA <nl> + static constexpr cudaDataType_t type = CUDA_R_32F ; <nl> + # elif TENSORFLOW_USE_ROCM <nl> + static constexpr cudaDataType_t type = HIPBLAS_R_32F ; <nl> + # endif <nl> + } ; <nl> + <nl> + template < > <nl> + struct CUDADataType < std : : complex < float > > { <nl> + # if GOOGLE_CUDA <nl> + static constexpr cudaDataType_t type = CUDA_C_32F ; <nl> + # elif TENSORFLOW_USE_ROCM <nl> + static constexpr cudaDataType_t type = HIPBLAS_C_32F ; <nl> + # endif <nl> + } ; <nl> + <nl> + template < > <nl> + struct CUDADataType < double > { <nl> + # if GOOGLE_CUDA <nl> + static constexpr cudaDataType_t type = CUDA_R_64F ; <nl> + # elif TENSORFLOW_USE_ROCM <nl> + static constexpr cudaDataType_t type = HIPBLAS_R_64F ; <nl> + # endif <nl> + } ; <nl> + <nl> + template < > <nl> + struct CUDADataType < std : : complex < double > > { <nl> + # if GOOGLE_CUDA <nl> + static constexpr cudaDataType_t type = CUDA_C_64F ; <nl> + # elif TENSORFLOW_USE_ROCM <nl> + static constexpr cudaDataType_t type = HIPBLAS_C_64F ; <nl> + # endif <nl> + } ; <nl> + <nl> + } / / namespace <nl> + <nl> template < typename T > <nl> class CSRSparseMatrixMatMul < GPUDevice , T > { <nl> public : <nl> class CSRSparseMatrixMatMul < GPUDevice , T > { <nl> GpuSparse cuda_sparse ( ctx ) ; <nl> TF_RETURN_IF_ERROR ( cuda_sparse . Initialize ( ) ) ; <nl> { <nl> - / / Use Csrmm to calculate : <nl> + / / Use Csrmm / SpMM to calculate : <nl> / / C = alpha * op ( A ) * op ( B ) + beta * C <nl> / / where alpha = 1 . 0 , beta = 0 . 0 , A is sparse and B and C are dense . <nl> - / / Note that Csrmm assumes B and C are in column - major form ; so we <nl> + / / Note that Csrmm / Spmm assumes B and C are in column - major form ; so we <nl> / / use transB = = true , and manually transpose the output in place <nl> / / using blas < t > geam . <nl> / / TODO ( ebrevdo , rmlarsen ) : Add support for transposition and adjoint . <nl> class CSRSparseMatrixMatMul < GPUDevice , T > { <nl> const T alpha = 1 ; <nl> const T beta = 0 ; <nl> <nl> - / / transA must be non - transpose if transB is transpose ( cusparse <nl> - / / limitation ) . <nl> - const gpusparseOperation_t transA = GPUSPARSE ( OPERATION_NON_TRANSPOSE ) ; <nl> - <nl> - / / transB : b is row - major , and cusparse requires col - major b ( or <nl> - / / equivalently transB = = transpose ) . this version is actually more <nl> - / / efficient . <nl> - const gpusparseOperation_t transB = GPUSPARSE ( OPERATION_TRANSPOSE ) ; <nl> - <nl> - gpusparseMatDescr_t descrA ; <nl> - TF_RETURN_IF_GPUSPARSE_ERROR ( gpusparse ( CreateMatDescr ) ( & descrA ) ) ; <nl> - TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> - gpusparse ( SetMatType ) ( descrA , GPUSPARSE ( MATRIX_TYPE_GENERAL ) ) ) ; <nl> - TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> - gpusparse ( SetMatIndexBase ) ( descrA , GPUSPARSE ( INDEX_BASE_ZERO ) ) ) ; <nl> - <nl> / / A is ( m , k ) , Bt is ( ldb , k ) and Ct is ( ldc , n ) <nl> const int k = b . dimension ( 0 ) ; <nl> DCHECK_EQ ( k , a . dense_shape_host ( 1 ) ) ; <nl> class CSRSparseMatrixMatMul < GPUDevice , T > { <nl> / / op ( A ) = A and at least max ( 1 , k ) otherwise . <nl> const int ldc = m ; <nl> <nl> + / / transA must be non - transpose if transB is transpose ( cusparse <nl> + / / limitation ) . <nl> + # if GOOGLE_CUDA <nl> + const gpusparseOperation_t transA = CUSPARSE_OPERATION_NON_TRANSPOSE ; <nl> + # elif TENSORFLOW_USE_ROCM <nl> + const gpusparseOperation_t transA = HIPSPARSE_OPERATION_NON_TRANSPOSE ; <nl> + # endif <nl> + <nl> + / / transB : b is row - major , and cusparse requires col - major b ( or <nl> + / / equivalently transB = = transpose ) . this version is actually more <nl> + / / efficient . <nl> + # if GOOGLE_CUDA & & CUDA_VERSION > = 10020 <nl> + <nl> + const gpusparseOperation_t transB = CUSPARSE_OPERATION_TRANSPOSE ; <nl> + gpusparseSpMatDescr_t matA ; <nl> + gpusparseDnMatDescr_t matB , matC ; <nl> + <nl> + / / NOTE : the following APIs are not available in ROCM <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseCreateCsr ( <nl> + & matA , m , k , nnz , const_cast < int * > ( a . row_ptr . data ( ) ) , <nl> + const_cast < int * > ( a . col_ind . data ( ) ) , const_cast < T * > ( a . values . data ( ) ) , <nl> + CUSPARSE_INDEX_32I , CUSPARSE_INDEX_32I , CUSPARSE_INDEX_BASE_ZERO , <nl> + CUDADataType < T > : : type ) ) ; <nl> + <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseCreateDnMat ( & matB , n , k , ldb , const_cast < T * > ( b . data ( ) ) , <nl> + CUDADataType < T > : : type , CUSPARSE_ORDER_COL ) ) ; <nl> + <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseCreateDnMat ( & matC , m , n , ldc , c . data ( ) , CUDADataType < T > : : type , <nl> + CUSPARSE_ORDER_COL ) ) ; <nl> + <nl> + size_t bufferSize = 0 ; <nl> + TF_RETURN_IF_ERROR ( cuda_sparse . SpMMBufferSize ( <nl> + transA , transB , & alpha , matA , matB , & beta , matC , <nl> + CUSPARSE_MM_ALG_DEFAULT , & bufferSize ) ) ; <nl> + <nl> + Tensor buffer ; <nl> + TF_RETURN_IF_ERROR ( ctx - > allocate_temp ( <nl> + DT_INT8 , TensorShape ( { static_cast < int64 > ( bufferSize ) } ) , & buffer ) ) ; <nl> + DCHECK ( buffer . flat < int8 > ( ) . data ( ) ! = nullptr ) ; <nl> + <nl> + TF_RETURN_IF_ERROR ( cuda_sparse . SpMM ( transA , transB , & alpha , matA , matB , <nl> + & beta , matC , CUSPARSE_MM_ALG_DEFAULT , <nl> + buffer . flat < int8 > ( ) . data ( ) ) ) ; <nl> + <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseDestroyDnMat ( matB ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseDestroyDnMat ( matC ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseDestroySpMat ( matA ) ) ; <nl> + <nl> + # else <nl> + <nl> + # if GOOGLE_CUDA <nl> + <nl> + const gpusparseOperation_t transB = CUSPARSE_OPERATION_TRANSPOSE ; <nl> + <nl> + gpusparseMatDescr_t descrA ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseCreateMatDescr ( & descrA ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseSetMatType ( descrA , CUSPARSE_MATRIX_TYPE_GENERAL ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseSetMatIndexBase ( descrA , CUSPARSE_INDEX_BASE_ZERO ) ) ; <nl> + <nl> + # elif TENSORFLOW_USE_ROCM <nl> + <nl> + const gpusparseOperation_t transB = HIPSPARSE_OPERATION_TRANSPOSE ; <nl> + <nl> + gpusparseMatDescr_t descrA ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( hipsparseCreateMatDescr ( & descrA ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + hipsparseSetMatType ( descrA , HIPSPARSE_MATRIX_TYPE_GENERAL ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + hipsparseSetMatIndexBase ( descrA , HIPSPARSE_INDEX_BASE_ZERO ) ) ; <nl> + # endif / / GOOGLE_CUDA <nl> + <nl> TF_RETURN_IF_ERROR ( <nl> cuda_sparse . Csrmm ( transA , transB , m , n , k , nnz , & alpha , descrA , <nl> a . values . data ( ) , a . row_ptr . data ( ) , a . col_ind . data ( ) , <nl> b . data ( ) , ldb , & beta , c . data ( ) , ldc ) ) ; <nl> + <nl> + # endif / / GOOGLE_CUDA & & CUDA_VERSION > = 10020 <nl> } <nl> <nl> return Status : : OK ( ) ; <nl> class CSRSparseMatrixMatVec < GPUDevice , T > { <nl> const T alpha = 1 ; <nl> const T beta = 0 ; <nl> <nl> + # if GOOGLE_CUDA & & CUDA_VERSION < 10020 <nl> + gpusparseMatDescr_t descrA ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseCreateMatDescr ( & descrA ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseSetMatType ( descrA , CUSPARSE_MATRIX_TYPE_GENERAL ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> + cusparseSetMatIndexBase ( descrA , CUSPARSE_INDEX_BASE_ZERO ) ) ; <nl> + # elif TENSORFLOW_USE_ROCM <nl> gpusparseMatDescr_t descrA ; <nl> - TF_RETURN_IF_GPUSPARSE_ERROR ( gpusparse ( CreateMatDescr ) ( & descrA ) ) ; <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( hipsparseCreateMatDescr ( & descrA ) ) ; <nl> TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> - gpusparse ( SetMatType ) ( descrA , GPUSPARSE ( MATRIX_TYPE_GENERAL ) ) ) ; <nl> + hipsparseSetMatType ( descrA , HIPSPARSE_MATRIX_TYPE_GENERAL ) ) ; <nl> TF_RETURN_IF_GPUSPARSE_ERROR ( <nl> - gpusparse ( SetMatIndexBase ) ( descrA , GPUSPARSE ( INDEX_BASE_ZERO ) ) ) ; <nl> + hipsparseSetMatIndexBase ( descrA , HIPSPARSE_INDEX_BASE_ZERO ) ) ; <nl> + # endif / / GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl> <nl> const int m = a . dense_shape_host ( 0 ) ; <nl> const int n = a . dense_shape_host ( 1 ) ; <nl> const int nnz = a . values . size ( ) ; <nl> DCHECK_EQ ( nnz , a . col_ind . size ( ) ) ; <nl> + # if CUDA_VERSION > = 10020 <nl> + TF_RETURN_IF_ERROR ( cuda_sparse . Csrmv ( transA_ , m , n , nnz , & alpha , <nl> + a . values . data ( ) , a . row_ptr . data ( ) , <nl> + a . col_ind . data ( ) , x , & beta , y ) ) ; <nl> + # else <nl> TF_RETURN_IF_ERROR ( cuda_sparse . Csrmv ( transA_ , m , n , nnz , & alpha , descrA , <nl> a . values . data ( ) , a . row_ptr . data ( ) , <nl> a . col_ind . data ( ) , x , & beta , y ) ) ; <nl> + # endif <nl> } <nl> <nl> return Status : : OK ( ) ; <nl> mmm a / tensorflow / core / kernels / sparse / sparse_mat_mul_op . cc <nl> ppp b / tensorflow / core / kernels / sparse / sparse_mat_mul_op . cc <nl> class CSRSparseMatMulGPUOp : public OpKernel { <nl> } <nl> auto b_input_dense_shape = b_input_matrix - > dense_shape ( ) . vec < int64 > ( ) ; <nl> <nl> + # if CUDA_VERSION > = 10000 <nl> + size_t maxWorkspaceSize = 0 ; <nl> + for ( int i = 0 ; i < batch_size ; + + i ) { <nl> + / / Calculate maximum workspace size over batch . <nl> + ConstCSRComponent < T > a_comp { a_input_matrix - > row_pointers_vec ( i ) , <nl> + a_input_matrix - > col_indices_vec ( i ) , <nl> + a_input_matrix - > values_vec < T > ( i ) , <nl> + a_input_dense_shape } ; <nl> + ConstCSRComponent < T > b_comp { b_input_matrix - > row_pointers_vec ( i ) , <nl> + b_input_matrix - > col_indices_vec ( i ) , <nl> + b_input_matrix - > values_vec < T > ( i ) , <nl> + b_input_dense_shape } ; <nl> + size_t thisWorkspaceSize ; <nl> + OP_REQUIRES_OK ( <nl> + ctx , csr_gemm . GetWorkspaceSize ( a_comp , b_comp , & thisWorkspaceSize ) ) ; <nl> + if ( thisWorkspaceSize > maxWorkspaceSize ) { <nl> + maxWorkspaceSize = thisWorkspaceSize ; <nl> + } <nl> + } <nl> + <nl> + Tensor temp ; <nl> + OP_REQUIRES_OK ( <nl> + ctx , ctx - > allocate_temp ( <nl> + DT_INT8 , TensorShape ( { static_cast < int64 > ( maxWorkspaceSize ) } ) , <nl> + & temp ) ) ; <nl> + void * workspace = temp . flat < int8 > ( ) . data ( ) ; <nl> + # else <nl> + void * workspace = nullptr ; <nl> + # endif <nl> + <nl> for ( int i = 0 ; i < batch_size ; + + i ) { <nl> / / Calculate output sizes for all minibatch entries . <nl> / / Store in c_batch_ptr and update c_row_ptrs . <nl> class CSRSparseMatMulGPUOp : public OpKernel { <nl> rows + 1 ) ; <nl> <nl> int c_nnz_i ; <nl> - OP_REQUIRES_OK ( ctx , csr_gemm . GetOutputStructure ( a_comp , b_comp , <nl> - c_row_ptr_i , & c_nnz_i ) ) ; <nl> + OP_REQUIRES_OK ( ctx , <nl> + csr_gemm . GetOutputStructure ( a_comp , b_comp , c_row_ptr_i , <nl> + & c_nnz_i , workspace ) ) ; <nl> c_batch_ptr ( i + 1 ) = c_batch_ptr ( i ) + c_nnz_i ; <nl> } <nl> <nl> class CSRSparseMatMulGPUOp : public OpKernel { <nl> b_input_dense_shape } ; <nl> CSRComponent < T > c_comp { c . row_pointers_vec ( i ) , c . col_indices_vec ( i ) , <nl> c . values_vec < T > ( i ) , c_dense_shape } ; <nl> - OP_REQUIRES_OK ( ctx , csr_gemm . Compute ( a_comp , b_comp , & c_comp ) ) ; <nl> + OP_REQUIRES_OK ( ctx , csr_gemm . Compute ( a_comp , b_comp , & c_comp , workspace ) ) ; <nl> } <nl> <nl> Tensor c_t ( cpu_allocator ( ) , DT_VARIANT , TensorShape ( { } ) ) ; <nl> struct CSRSparseSparseMatrixMatMul < GPUDevice , T > <nl> initialized_ ( false ) , <nl> transpose_a_ ( transpose_a ) , <nl> adjoint_a_ ( adjoint_a ) , <nl> + # if CUDA_VERSION < 10000 <nl> transpose_b_ ( transpose_b ) { <nl> + # else <nl> + transpose_b_ ( transpose_b ) , <nl> + info_ ( nullptr ) { <nl> + # endif / / CUDA_VERSION < 10000 <nl> / / TODO ( ebrevdo ) : Figure out why transposed implementations crash cuSparse . <nl> transA_ = transpose_a <nl> ? ( adjoint_a ? GPUSPARSE ( OPERATION_TRANSPOSE ) <nl> struct CSRSparseSparseMatrixMatMul < GPUDevice , T > <nl> : GPUSPARSE ( OPERATION_NON_TRANSPOSE ) ; <nl> } <nl> <nl> + # if CUDA_VERSION > = 10000 <nl> + ~ CSRSparseSparseMatrixMatMul ( ) { <nl> + if ( initialized_ ) { <nl> + cusparseDestroyCsrgemm2Info ( info_ ) ; <nl> + } <nl> + } <nl> + # endif <nl> + <nl> Status Initialize ( ) { <nl> if ( adjoint_a_ & & transpose_a_ ) { <nl> return errors : : InvalidArgument ( <nl> struct CSRSparseSparseMatrixMatMul < GPUDevice , T > <nl> TF_RETURN_IF_ERROR ( descrA_ . Initialize ( ) ) ; <nl> TF_RETURN_IF_ERROR ( descrB_ . Initialize ( ) ) ; <nl> TF_RETURN_IF_ERROR ( descrC_ . Initialize ( ) ) ; <nl> + # if CUDA_VERSION > = 10000 <nl> + TF_RETURN_IF_GPUSPARSE_ERROR ( cusparseCreateCsrgemm2Info ( & info_ ) ) ; <nl> + # endif <nl> initialized_ = true ; <nl> return Status : : OK ( ) ; <nl> } <nl> <nl> + Status GetWorkspaceSize ( const ConstCSRComponent < T > & a , <nl> + const ConstCSRComponent < T > & b , size_t * bufferSize ) { <nl> + DCHECK ( initialized_ ) ; <nl> + const int m = <nl> + a . dense_shape_host ( a . dense_shape_host . size ( ) - ( transpose_a_ ? 1 : 2 ) ) ; <nl> + if ( ! transpose_a_ ) { <nl> + DCHECK_EQ ( m , a . row_ptr . size ( ) - 1 ) ; <nl> + } <nl> + const int k = <nl> + a . dense_shape_host ( a . dense_shape_host . size ( ) - ( transpose_a_ ? 2 : 1 ) ) ; <nl> + if ( ! transpose_b_ ) { <nl> + DCHECK_EQ ( k , b . row_ptr . size ( ) - 1 ) ; <nl> + } <nl> + const int nnzA = a . col_ind . size ( ) ; <nl> + const int nnzB = b . col_ind . size ( ) ; <nl> + <nl> + const int n = <nl> + b . dense_shape_host ( b . dense_shape_host . size ( ) - ( transpose_b_ ? 2 : 1 ) ) ; <nl> + <nl> + TF_RETURN_IF_ERROR ( cuda_sparse_ . CsrgemmBufferSize < T > ( <nl> + m , n , k , descrA_ . descr ( ) , nnzA , a . row_ptr . data ( ) , a . col_ind . data ( ) , <nl> + descrB_ . descr ( ) , nnzB , b . row_ptr . data ( ) , b . col_ind . data ( ) , info_ , <nl> + bufferSize ) ) ; <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> Status GetOutputStructure ( const ConstCSRComponent < T > & a , <nl> const ConstCSRComponent < T > & b , <nl> TTypes < int32 > : : UnalignedVec c_row_ptr , <nl> - int * output_nnz ) { <nl> + int * output_nnz , void * workspace ) { <nl> DCHECK ( initialized_ ) ; <nl> <nl> const int m = <nl> struct CSRSparseSparseMatrixMatMul < GPUDevice , T > <nl> <nl> * output_nnz = - 1 ; <nl> <nl> + # if CUDA_VERSION < 10000 <nl> TF_RETURN_IF_ERROR ( cuda_sparse_ . CsrgemmNnz ( <nl> transA_ , transB_ , m , n , k , descrA_ . descr ( ) , nnzA , a . row_ptr . data ( ) , <nl> a . col_ind . data ( ) , descrB_ . descr ( ) , nnzB , b . row_ptr . data ( ) , <nl> b . col_ind . data ( ) , descrC_ . descr ( ) , c_row_ptr . data ( ) , output_nnz ) ) ; <nl> + # else <nl> + TF_RETURN_IF_ERROR ( cuda_sparse_ . CsrgemmNnz ( <nl> + m , n , k , descrA_ . descr ( ) , nnzA , a . row_ptr . data ( ) , a . col_ind . data ( ) , <nl> + descrB_ . descr ( ) , nnzB , b . row_ptr . data ( ) , b . col_ind . data ( ) , <nl> + descrC_ . descr ( ) , c_row_ptr . data ( ) , output_nnz , info_ , workspace ) ) ; <nl> + # endif <nl> <nl> if ( * output_nnz < 0 ) { <nl> return errors : : Internal ( <nl> struct CSRSparseSparseMatrixMatMul < GPUDevice , T > <nl> } <nl> <nl> Status Compute ( const ConstCSRComponent < T > & a , const ConstCSRComponent < T > & b , <nl> - CSRComponent < T > * c ) { <nl> + CSRComponent < T > * c , void * workspace ) { <nl> DCHECK ( initialized_ ) ; <nl> <nl> const int m = <nl> struct CSRSparseSparseMatrixMatMul < GPUDevice , T > <nl> b . dense_shape_host ( b . dense_shape_host . size ( ) - ( transpose_b_ ? 2 : 1 ) ) ; <nl> DCHECK_EQ ( n , c - > dense_shape_host ( c - > dense_shape_host . size ( ) - 1 ) ) ; <nl> <nl> + # if CUDA_VERSION < 10000 <nl> TF_RETURN_IF_ERROR ( cuda_sparse_ . Csrgemm ( <nl> transA_ , transB_ , m , k , n , descrA_ . descr ( ) , nnzA , a . values . data ( ) , <nl> a . row_ptr . data ( ) , a . col_ind . data ( ) , descrB_ . descr ( ) , nnzB , <nl> b . values . data ( ) , b . row_ptr . data ( ) , b . col_ind . data ( ) , descrC_ . descr ( ) , <nl> c - > values . data ( ) , c - > row_ptr . data ( ) , c - > col_ind . data ( ) ) ) ; <nl> + # else <nl> + TF_RETURN_IF_ERROR ( cuda_sparse_ . Csrgemm ( <nl> + m , n , k , descrA_ . descr ( ) , nnzA , a . values . data ( ) , a . row_ptr . data ( ) , <nl> + a . col_ind . data ( ) , descrB_ . descr ( ) , nnzB , b . values . data ( ) , <nl> + b . row_ptr . data ( ) , b . col_ind . data ( ) , descrC_ . descr ( ) , c - > values . data ( ) , <nl> + c - > row_ptr . data ( ) , c - > col_ind . data ( ) , info_ , workspace ) ) ; <nl> + # endif <nl> <nl> / / TODO ( ebrevdo ) : Add a flag to CSRSparseMatrix whether matrix <nl> / / columns are sorted ? Above operation leads to unsorted columns . <nl> struct CSRSparseSparseMatrixMatMul < GPUDevice , T > <nl> GpuSparseMatrixDescriptor descrC_ ; <nl> gpusparseOperation_t transA_ ; <nl> gpusparseOperation_t transB_ ; <nl> + # if CUDA_VERSION > = 10000 <nl> + csrgemm2Info_t info_ ; <nl> + # endif <nl> } ; <nl> <nl> } / / namespace functor <nl> | Merge pull request from nluehr : cusparse_remove_deprecated | tensorflow/tensorflow | 10b96cd2141bf93ab7ae71784d87832fe29152d5 | 2020-05-06T18:05:02Z |
mmm a / build / Dockerfile <nl> ppp b / build / Dockerfile <nl> RUN adduser - - disabled - password - - gecos ' ' fdb & & chown - R fdb / opt & & chmod - R <nl> <nl> USER fdb <nl> <nl> - RUN cd / opt / & & wget http : / / downloads . sourceforge . net / project / boost / boost / 1 . 52 . 0 / boost_1_52_0 . tar . bz2 - qO - | tar - xj <nl> + # wget of bintray without forcing UTF - 8 encoding results in 403 Forbidden <nl> + RUN cd / opt / & & wget http : / / downloads . sourceforge . net / project / boost / boost / 1 . 52 . 0 / boost_1_52_0 . tar . bz2 & & \ <nl> + wget - - local - encoding = UTF - 8 https : / / dl . bintray . com / boostorg / release / 1 . 67 . 0 / source / boost_1_67_0 . tar . bz2 & & \ <nl> + echo ' 2684c972994ee57fc5632e03bf044746f6eb45d4920c343937a465fd67a5adba boost_1_67_0 . tar . bz2 ' | sha256sum - c - & & \ <nl> + tar - xjf boost_1_52_0 . tar . bz2 & & \ <nl> + tar - xjf boost_1_67_0 . tar . bz2 & & \ <nl> + rm boost_1_52_0 . tar . bz2 boost_1_67_0 . tar . bz2 <nl> <nl> USER root <nl> <nl> | Add boost - 1 . 67 . 0 to the Dockerfile alongside 1 . 52 . 0 | apple/foundationdb | 09aa1ce55b90766b9eda3dd7affa2370baa4b3d3 | 2019-01-08T01:17:09Z |
mmm a / include / nlohmann / detail / output / serializer . hpp <nl> ppp b / include / nlohmann / detail / output / serializer . hpp <nl> class serializer <nl> string_buffer [ bytes + + ] = detail : : binary_writer < BasicJsonType , char > : : to_char_type ( ' \ xBF ' ) ; <nl> string_buffer [ bytes + + ] = detail : : binary_writer < BasicJsonType , char > : : to_char_type ( ' \ xBD ' ) ; <nl> } <nl> + <nl> + / / write buffer and reset index ; there must be 13 bytes <nl> + / / left , as this is the maximal number of bytes to be <nl> + / / written ( " \ uxxxx \ uxxxx \ 0 " ) for one code point <nl> + if ( string_buffer . size ( ) - bytes < 13 ) <nl> + { <nl> + o - > write_characters ( string_buffer . data ( ) , bytes ) ; <nl> + bytes = 0 ; <nl> + } <nl> + <nl> bytes_after_last_accept = bytes ; <nl> } <nl> <nl> mmm a / single_include / nlohmann / json . hpp <nl> ppp b / single_include / nlohmann / json . hpp <nl> class serializer <nl> string_buffer [ bytes + + ] = detail : : binary_writer < BasicJsonType , char > : : to_char_type ( ' \ xBF ' ) ; <nl> string_buffer [ bytes + + ] = detail : : binary_writer < BasicJsonType , char > : : to_char_type ( ' \ xBD ' ) ; <nl> } <nl> + <nl> + / / write buffer and reset index ; there must be 13 bytes <nl> + / / left , as this is the maximal number of bytes to be <nl> + / / written ( " \ uxxxx \ uxxxx \ 0 " ) for one code point <nl> + if ( string_buffer . size ( ) - bytes < 13 ) <nl> + { <nl> + o - > write_characters ( string_buffer . data ( ) , bytes ) ; <nl> + bytes = 0 ; <nl> + } <nl> + <nl> bytes_after_last_accept = bytes ; <nl> } <nl> <nl> mmm a / test / Makefile <nl> ppp b / test / Makefile <nl> SOURCES = src / unit . cpp \ <nl> src / unit - items . cpp \ <nl> src / unit - iterators1 . cpp \ <nl> src / unit - iterators2 . cpp \ <nl> + src / unit - invalid - utf8 . cpp \ <nl> src / unit - merge_patch . cpp \ <nl> src / unit - json_patch . cpp \ <nl> src / unit - json_pointer . cpp \ <nl> new file mode 100644 <nl> index 000000000 . . 36f1ada00 <nl> mmm / dev / null <nl> ppp b / test / src / unit - invalid_utf8 . cpp <nl> <nl> + / * <nl> + __ _____ _____ _____ <nl> + __ | | __ | | | | JSON for Modern C + + ( test suite ) <nl> + | | | __ | | | | | | version 3 . 5 . 0 <nl> + | _____ | _____ | _____ | _ | ___ | https : / / github . com / nlohmann / json <nl> + <nl> + Licensed under the MIT License < http : / / opensource . org / licenses / MIT > . <nl> + SPDX - License - Identifier : MIT <nl> + Copyright ( c ) 2013 - 2018 Niels Lohmann < http : / / nlohmann . me > . <nl> + <nl> + Permission is hereby granted , free of charge , to any person obtaining a copy <nl> + of this software and associated documentation files ( the " Software " ) , to deal <nl> + in the Software without restriction , including without limitation the rights <nl> + to use , copy , modify , merge , publish , distribute , sublicense , and / or sell <nl> + copies of the Software , and to permit persons to whom the Software is <nl> + furnished to do so , subject to the following conditions : <nl> + <nl> + The above copyright notice and this permission notice shall be included in all <nl> + copies or substantial portions of the Software . <nl> + <nl> + THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR <nl> + IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , <nl> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE <nl> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER <nl> + LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , <nl> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE <nl> + SOFTWARE . <nl> + * / <nl> + <nl> + # include " catch . hpp " <nl> + # include < nlohmann / json . hpp > <nl> + using nlohmann : : json ; <nl> + <nl> + # include < fstream > <nl> + # include < sstream > <nl> + <nl> + TEST_CASE ( " INVALID - UTF8 " ) <nl> + { <nl> + SECTION ( " a bunch of - 1 , ensure_ascii = true " ) <nl> + { <nl> + json dump_test ; <nl> + std : : vector < char > data ( 300 , - 1 ) ; <nl> + std : : vector < std : : string > vec_string ( 300 , " \ \ ufffd " ) ; <nl> + std : : string s { data . data ( ) , data . size ( ) } ; <nl> + dump_test [ " 1 " ] = s ; <nl> + std : : ostringstream os ; <nl> + os < < " { \ " 1 \ " : \ " " ; <nl> + std : : copy ( vec_string . begin ( ) , vec_string . end ( ) , std : : ostream_iterator < std : : string > ( os ) ) ; <nl> + os < < " \ " } " ; <nl> + s = dump_test . dump ( - 1 , ' ' , true , nlohmann : : json : : error_handler_t : : replace ) ; <nl> + CHECK ( s = = os . str ( ) ) ; <nl> + } <nl> + SECTION ( " a bunch of - 2 , ensure_ascii = false " ) <nl> + { <nl> + json dump_test ; <nl> + std : : vector < char > data ( 500 , - 2 ) ; <nl> + std : : vector < std : : string > vec_string ( 500 , " \ xEF \ xBF \ xBD " ) ; <nl> + std : : string s { data . data ( ) , data . size ( ) } ; <nl> + dump_test [ " 1 " ] = s ; <nl> + std : : ostringstream os ; <nl> + os < < " { \ " 1 \ " : \ " " ; <nl> + std : : copy ( vec_string . begin ( ) , vec_string . end ( ) , std : : ostream_iterator < std : : string > ( os ) ) ; <nl> + os < < " \ " } " ; <nl> + s = dump_test . dump ( - 1 , ' ' , false , nlohmann : : json : : error_handler_t : : replace ) ; <nl> + CHECK ( s = = os . str ( ) ) ; <nl> + } <nl> + <nl> + } <nl> | flush buffer in serializer : : dump_escaped case UTF8_REJECT | nlohmann/json | 899bd94b43a223baaaddca3caec8feb4dc3861b1 | 2019-01-19T01:35:48Z |
mmm a / ChangeLog <nl> ppp b / ChangeLog <nl> <nl> + 2009 - 02 - 09 Tatsuhiro Tsujikawa < t - tujikawa @ users . sourceforge . net > <nl> + <nl> + Included fstream instead of iostream . <nl> + * test / SignatureTest . cc <nl> + <nl> 2009 - 02 - 08 Tatsuhiro Tsujikawa < t - tujikawa @ users . sourceforge . net > <nl> <nl> Removed # include < algorithm > <nl> mmm a / test / SignatureTest . cc <nl> ppp b / test / SignatureTest . cc <nl> <nl> # include " Signature . h " <nl> + <nl> + # include < fstream > <nl> + <nl> + # include < cppunit / extensions / HelperMacros . h > <nl> + <nl> # include " Exception . h " <nl> # include " File . h " <nl> - # include < iostream > <nl> - # include < cppunit / extensions / HelperMacros . h > <nl> <nl> namespace aria2 { <nl> <nl> | 2009 - 02 - 09 Tatsuhiro Tsujikawa < t - tujikawa @ users . sourceforge . net > | aria2/aria2 | abae62908fe0e3e02c0d09ba74c126ebaf5e5124 | 2009-02-09T12:45:07Z |
mmm a / src / wasm / module - instantiate . cc <nl> ppp b / src / wasm / module - instantiate . cc <nl> void InstanceBuilder : : WriteGlobalValue ( const WasmGlobal & global , <nl> TRACE ( " % lf " , num ) ; <nl> break ; <nl> } <nl> + case kWasmAnyRef : <nl> + case kWasmAnyFunc : <nl> + case kWasmExceptRef : { <nl> + tagged_globals_ - > set ( global . offset , * value - > GetRef ( ) ) ; <nl> + break ; <nl> + } <nl> default : <nl> UNREACHABLE ( ) ; <nl> } <nl> bool InstanceBuilder : : ProcessImportedWasmGlobalObject ( <nl> Handle < WasmInstanceObject > instance , int import_index , <nl> Handle < String > module_name , Handle < String > import_name , <nl> const WasmGlobal & global , Handle < WasmGlobalObject > global_object ) { <nl> - if ( global_object - > type ( ) ! = global . type ) { <nl> - ReportLinkError ( " imported global does not match the expected type " , <nl> + if ( global_object - > is_mutable ( ) ! = global . mutability ) { <nl> + ReportLinkError ( " imported global does not match the expected mutability " , <nl> import_index , module_name , import_name ) ; <nl> return false ; <nl> } <nl> - if ( global_object - > is_mutable ( ) ! = global . mutability ) { <nl> - ReportLinkError ( " imported global does not match the expected mutability " , <nl> + <nl> + bool is_sub_type = ValueTypes : : IsSubType ( global . type , global_object - > type ( ) ) ; <nl> + bool is_same_type = global_object - > type ( ) = = global . type ; <nl> + bool valid_type = global . mutability ? is_same_type : is_sub_type ; <nl> + <nl> + if ( ! valid_type ) { <nl> + ReportLinkError ( " imported global does not match the expected type " , <nl> import_index , module_name , import_name ) ; <nl> return false ; <nl> } <nl> mmm a / test / mjsunit / wasm / anyref - globals . js <nl> ppp b / test / mjsunit / wasm / anyref - globals . js <nl> function dummy_func ( ) { <nl> assertEquals ( obj2 , instance2 . exports . reexport2 . value ) ; <nl> assertEquals ( obj3 , instance2 . exports . reexport3 . value ) ; <nl> } ) ( ) ; <nl> + <nl> + ( function TestImportImmutableAnyFuncGlobalAsAnyRef ( ) { <nl> + print ( arguments . callee . name ) ; <nl> + let builder1 = new WasmModuleBuilder ( ) ; <nl> + const g3 = builder1 . addGlobal ( kWasmAnyFunc , true ) . exportAs ( " e3 " ) ; <nl> + builder1 . addGlobal ( kWasmAnyRef , false ) . exportAs ( " e1 " ) ; / / Dummy . <nl> + builder1 . addGlobal ( kWasmAnyFunc , false ) . exportAs ( " e2 " ) ; / / Dummy . <nl> + const instance1 = builder1 . instantiate ( ) ; <nl> + <nl> + let builder2 = new WasmModuleBuilder ( ) ; <nl> + const i1 = builder2 . addImportedGlobal ( ' exports ' , ' e1 ' , kWasmAnyRef , false ) ; <nl> + const i2 = builder2 . addImportedGlobal ( ' exports ' , ' e2 ' , kWasmAnyRef , false ) ; <nl> + builder2 . instantiate ( instance1 ) ; <nl> + } ) ( ) ; <nl> + <nl> + ( function TestImportMutableAnyFuncGlobalAsAnyRefFails ( ) { <nl> + print ( arguments . callee . name ) ; <nl> + let builder1 = new WasmModuleBuilder ( ) ; <nl> + const g3 = builder1 . addGlobal ( kWasmAnyFunc , true ) . exportAs ( " e3 " ) ; <nl> + builder1 . addGlobal ( kWasmAnyRef , true ) . exportAs ( " e1 " ) ; / / Dummy . <nl> + builder1 . addGlobal ( kWasmAnyFunc , true ) . exportAs ( " e2 " ) ; / / Dummy . <nl> + const instance1 = builder1 . instantiate ( ) ; <nl> + <nl> + let builder2 = new WasmModuleBuilder ( ) ; <nl> + const i1 = builder2 . addImportedGlobal ( ' exports ' , ' e1 ' , kWasmAnyRef , true ) ; <nl> + const i2 = builder2 . addImportedGlobal ( ' exports ' , ' e2 ' , kWasmAnyRef , true ) ; <nl> + assertThrows ( ( ) = > builder2 . instantiate ( instance1 ) , WebAssembly . LinkError ) ; <nl> + } ) ( ) ; <nl> | [ wasm ] Fix sub - typing of global imports | v8/v8 | 0b8d476aee5821b749ebaf3c45cbb860124f4449 | 2019-05-08T08:55:29Z |
mmm a / src / inspector / v8 - inspector - session - impl . cc <nl> ppp b / src / inspector / v8 - inspector - session - impl . cc <nl> void V8InspectorSessionImpl : : sendProtocolNotification ( <nl> m_channel - > sendNotification ( MessageBuffer : : create ( std : : move ( message ) ) ) ; <nl> } <nl> <nl> + void V8InspectorSessionImpl : : fallThrough ( int callId , const String16 & method , <nl> + const String16 & message ) { <nl> + / / There ' s no other layer to handle the command . <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + <nl> void V8InspectorSessionImpl : : flushProtocolNotifications ( ) { <nl> m_channel - > flushProtocolNotifications ( ) ; <nl> } <nl> void V8InspectorSessionImpl : : reportAllContexts ( V8RuntimeAgentImpl * agent ) { <nl> <nl> void V8InspectorSessionImpl : : dispatchProtocolMessage ( <nl> const StringView & message ) { <nl> - m_dispatcher . dispatch ( protocol : : StringUtil : : parseJSON ( message ) ) ; <nl> + int callId ; <nl> + String16 method ; <nl> + std : : unique_ptr < protocol : : Value > parsedMessage = <nl> + protocol : : StringUtil : : parseJSON ( message ) ; <nl> + if ( m_dispatcher . parseCommand ( parsedMessage . get ( ) , & callId , & method ) ) { <nl> + / / Pass empty string instead of the actual message to save on a conversion . <nl> + / / We ' re allowed to do so because fall - through is not implemented . <nl> + m_dispatcher . dispatch ( callId , method , std : : move ( parsedMessage ) , " " ) ; <nl> + } <nl> } <nl> <nl> std : : unique_ptr < StringBuffer > V8InspectorSessionImpl : : stateJSON ( ) { <nl> mmm a / src / inspector / v8 - inspector - session - impl . h <nl> ppp b / src / inspector / v8 - inspector - session - impl . h <nl> class V8InspectorSessionImpl : public V8InspectorSession , <nl> int callId , std : : unique_ptr < protocol : : Serializable > message ) override ; <nl> void sendProtocolNotification ( <nl> std : : unique_ptr < protocol : : Serializable > message ) override ; <nl> + void fallThrough ( int callId , const String16 & method , <nl> + const String16 & message ) override ; <nl> void flushProtocolNotifications ( ) override ; <nl> <nl> int m_contextGroupId ; <nl> mmm a / third_party / inspector_protocol / README . v8 <nl> ppp b / third_party / inspector_protocol / README . v8 <nl> Name : inspector protocol <nl> Short Name : inspector_protocol <nl> URL : https : / / chromium . googlesource . com / deps / inspector_protocol / <nl> Version : 0 <nl> - Revision : 0d4255502019144a5dec5669d7992165ae8924e7 <nl> + Revision : c22d4bd88fb7a39bc41c3b1adcdd733cc9b5e8ea <nl> License : BSD <nl> License File : LICENSE <nl> Security Critical : no <nl> mmm a / third_party / inspector_protocol / lib / DispatcherBase_cpp . template <nl> ppp b / third_party / inspector_protocol / lib / DispatcherBase_cpp . template <nl> DispatcherBase : : WeakPtr : : ~ WeakPtr ( ) <nl> m_dispatcher - > m_weakPtrs . erase ( this ) ; <nl> } <nl> <nl> - DispatcherBase : : Callback : : Callback ( std : : unique_ptr < DispatcherBase : : WeakPtr > backendImpl , int callId , int callbackId ) <nl> + DispatcherBase : : Callback : : Callback ( std : : unique_ptr < DispatcherBase : : WeakPtr > backendImpl , int callId , const String & method , const String & message ) <nl> : m_backendImpl ( std : : move ( backendImpl ) ) <nl> , m_callId ( callId ) <nl> - , m_callbackId ( callbackId ) { } <nl> + , m_method ( method ) <nl> + , m_message ( message ) { } <nl> <nl> DispatcherBase : : Callback : : ~ Callback ( ) = default ; <nl> <nl> void DispatcherBase : : Callback : : fallThroughIfActive ( ) <nl> { <nl> if ( ! m_backendImpl | | ! m_backendImpl - > get ( ) ) <nl> return ; <nl> - m_backendImpl - > get ( ) - > markFallThrough ( m_callbackId ) ; <nl> + m_backendImpl - > get ( ) - > channel ( ) - > fallThrough ( m_callId , m_method , m_message ) ; <nl> m_backendImpl = nullptr ; <nl> } <nl> <nl> DispatcherBase : : DispatcherBase ( FrontendChannel * frontendChannel ) <nl> - : m_frontendChannel ( frontendChannel ) <nl> - , m_lastCallbackId ( 0 ) <nl> - , m_lastCallbackFallThrough ( false ) { } <nl> + : m_frontendChannel ( frontendChannel ) { } <nl> <nl> DispatcherBase : : ~ DispatcherBase ( ) <nl> { <nl> clearFrontend ( ) ; <nl> } <nl> <nl> - int DispatcherBase : : nextCallbackId ( ) <nl> - { <nl> - m_lastCallbackFallThrough = false ; <nl> - return + + m_lastCallbackId ; <nl> - } <nl> - <nl> - void DispatcherBase : : markFallThrough ( int callbackId ) <nl> - { <nl> - DCHECK ( callbackId = = m_lastCallbackId ) ; <nl> - m_lastCallbackFallThrough = true ; <nl> - } <nl> - <nl> void DispatcherBase : : sendResponse ( int callId , const DispatchResponse & response , std : : unique_ptr < protocol : : DictionaryValue > result ) <nl> { <nl> if ( ! m_frontendChannel ) <nl> std : : unique_ptr < DispatcherBase : : WeakPtr > DispatcherBase : : weakPtr ( ) <nl> } <nl> <nl> UberDispatcher : : UberDispatcher ( FrontendChannel * frontendChannel ) <nl> - : m_frontendChannel ( frontendChannel ) <nl> - , m_fallThroughForNotFound ( false ) { } <nl> - <nl> - void UberDispatcher : : setFallThroughForNotFound ( bool fallThroughForNotFound ) <nl> - { <nl> - m_fallThroughForNotFound = fallThroughForNotFound ; <nl> - } <nl> + : m_frontendChannel ( frontendChannel ) { } <nl> <nl> void UberDispatcher : : registerBackend ( const String & name , std : : unique_ptr < protocol : : DispatcherBase > dispatcher ) <nl> { <nl> void UberDispatcher : : setupRedirects ( const std : : unordered_map < String , String > & re <nl> m_redirects [ pair . first ] = pair . second ; <nl> } <nl> <nl> - DispatchResponse : : Status UberDispatcher : : dispatch ( std : : unique_ptr < Value > parsedMessage , int * outCallId , String * outMethod ) <nl> - { <nl> + bool UberDispatcher : : parseCommand ( Value * parsedMessage , int * outCallId , String * outMethod ) { <nl> if ( ! parsedMessage ) { <nl> reportProtocolErrorTo ( m_frontendChannel , DispatchResponse : : kParseError , " Message must be a valid JSON " ) ; <nl> - return DispatchResponse : : kError ; <nl> + return false ; <nl> } <nl> - std : : unique_ptr < protocol : : DictionaryValue > messageObject = DictionaryValue : : cast ( std : : move ( parsedMessage ) ) ; <nl> + protocol : : DictionaryValue * messageObject = DictionaryValue : : cast ( parsedMessage ) ; <nl> if ( ! messageObject ) { <nl> reportProtocolErrorTo ( m_frontendChannel , DispatchResponse : : kInvalidRequest , " Message must be an object " ) ; <nl> - return DispatchResponse : : kError ; <nl> + return false ; <nl> } <nl> <nl> int callId = 0 ; <nl> protocol : : Value * callIdValue = messageObject - > get ( " id " ) ; <nl> bool success = callIdValue & & callIdValue - > asInteger ( & callId ) ; <nl> - if ( outCallId ) <nl> - * outCallId = callId ; <nl> if ( ! success ) { <nl> reportProtocolErrorTo ( m_frontendChannel , DispatchResponse : : kInvalidRequest , " Message must have integer ' id ' property " ) ; <nl> - return DispatchResponse : : kError ; <nl> + return false ; <nl> } <nl> + if ( outCallId ) <nl> + * outCallId = callId ; <nl> <nl> protocol : : Value * methodValue = messageObject - > get ( " method " ) ; <nl> String method ; <nl> success = methodValue & & methodValue - > asString ( & method ) ; <nl> - if ( outMethod ) <nl> - * outMethod = method ; <nl> if ( ! success ) { <nl> reportProtocolErrorTo ( m_frontendChannel , callId , DispatchResponse : : kInvalidRequest , " Message must have string ' method ' property " , nullptr ) ; <nl> - return DispatchResponse : : kError ; <nl> + return false ; <nl> } <nl> <nl> std : : unordered_map < String , String > : : iterator redirectIt = m_redirects . find ( method ) ; <nl> if ( redirectIt ! = m_redirects . end ( ) ) <nl> method = redirectIt - > second ; <nl> + if ( outMethod ) <nl> + * outMethod = method ; <nl> + return true ; <nl> + } <nl> <nl> + protocol : : DispatcherBase * UberDispatcher : : findDispatcher ( const String & method ) { <nl> size_t dotIndex = StringUtil : : find ( method , " . " ) ; <nl> - if ( dotIndex = = StringUtil : : kNotFound ) { <nl> - if ( m_fallThroughForNotFound ) <nl> - return DispatchResponse : : kFallThrough ; <nl> - reportProtocolErrorTo ( m_frontendChannel , callId , DispatchResponse : : kMethodNotFound , " ' " + method + " ' wasn ' t found " , nullptr ) ; <nl> - return DispatchResponse : : kError ; <nl> - } <nl> + if ( dotIndex = = StringUtil : : kNotFound ) <nl> + return nullptr ; <nl> String domain = StringUtil : : substring ( method , 0 , dotIndex ) ; <nl> auto it = m_dispatchers . find ( domain ) ; <nl> - if ( it = = m_dispatchers . end ( ) ) { <nl> - if ( m_fallThroughForNotFound ) <nl> - return DispatchResponse : : kFallThrough ; <nl> - reportProtocolErrorTo ( m_frontendChannel , callId , DispatchResponse : : kMethodNotFound , " ' " + method + " ' wasn ' t found " , nullptr ) ; <nl> - return DispatchResponse : : kError ; <nl> - } <nl> - return it - > second - > dispatch ( callId , method , std : : move ( messageObject ) ) ; <nl> + if ( it = = m_dispatchers . end ( ) ) <nl> + return nullptr ; <nl> + if ( ! it - > second - > canDispatch ( method ) ) <nl> + return nullptr ; <nl> + return it - > second . get ( ) ; <nl> } <nl> <nl> - bool UberDispatcher : : getCommandName ( const String & message , String * method , std : : unique_ptr < protocol : : DictionaryValue > * parsedMessage ) <nl> + bool UberDispatcher : : canDispatch ( const String & method ) <nl> { <nl> - std : : unique_ptr < protocol : : Value > value = StringUtil : : parseJSON ( message ) ; <nl> - if ( ! value ) { <nl> - reportProtocolErrorTo ( m_frontendChannel , DispatchResponse : : kParseError , " Message must be a valid JSON " ) ; <nl> - return false ; <nl> - } <nl> - <nl> - protocol : : DictionaryValue * object = DictionaryValue : : cast ( value . get ( ) ) ; <nl> - if ( ! object ) { <nl> - reportProtocolErrorTo ( m_frontendChannel , DispatchResponse : : kInvalidRequest , " Message must be an object " ) ; <nl> - return false ; <nl> - } <nl> + return ! ! findDispatcher ( method ) ; <nl> + } <nl> <nl> - if ( ! object - > getString ( " method " , method ) ) { <nl> - reportProtocolErrorTo ( m_frontendChannel , DispatchResponse : : kInvalidRequest , " Message must have string ' method ' property " ) ; <nl> - return false ; <nl> + void UberDispatcher : : dispatch ( int callId , const String & method , std : : unique_ptr < Value > parsedMessage , const String & rawMessage ) <nl> + { <nl> + protocol : : DispatcherBase * dispatcher = findDispatcher ( method ) ; <nl> + if ( ! dispatcher ) { <nl> + reportProtocolErrorTo ( m_frontendChannel , callId , DispatchResponse : : kMethodNotFound , " ' " + method + " ' wasn ' t found " , nullptr ) ; <nl> + return ; <nl> } <nl> - <nl> - parsedMessage - > reset ( DictionaryValue : : cast ( value . release ( ) ) ) ; <nl> - return true ; <nl> + std : : unique_ptr < protocol : : DictionaryValue > messageObject = DictionaryValue : : cast ( std : : move ( parsedMessage ) ) ; <nl> + dispatcher - > dispatch ( callId , method , rawMessage , std : : move ( messageObject ) ) ; <nl> } <nl> <nl> UberDispatcher : : ~ UberDispatcher ( ) = default ; <nl> mmm a / third_party / inspector_protocol / lib / DispatcherBase_h . template <nl> ppp b / third_party / inspector_protocol / lib / DispatcherBase_h . template <nl> public : <nl> enum Status { <nl> kSuccess = 0 , <nl> kError = 1 , <nl> - kFallThrough = 2 , <nl> - kAsync = 3 <nl> + kFallThrough = 2 <nl> } ; <nl> <nl> enum ErrorCode { <nl> public : <nl> <nl> class { { config . lib . export_macro } } Callback { <nl> public : <nl> - Callback ( std : : unique_ptr < WeakPtr > backendImpl , int callId , int callbackId ) ; <nl> + Callback ( std : : unique_ptr < WeakPtr > backendImpl , int callId , const String & method , const String & message ) ; <nl> virtual ~ Callback ( ) ; <nl> void dispose ( ) ; <nl> <nl> public : <nl> private : <nl> std : : unique_ptr < WeakPtr > m_backendImpl ; <nl> int m_callId ; <nl> - int m_callbackId ; <nl> + String m_method ; <nl> + String m_message ; <nl> } ; <nl> <nl> explicit DispatcherBase ( FrontendChannel * ) ; <nl> virtual ~ DispatcherBase ( ) ; <nl> <nl> - virtual DispatchResponse : : Status dispatch ( int callId , const String & method , std : : unique_ptr < protocol : : DictionaryValue > messageObject ) = 0 ; <nl> + virtual bool canDispatch ( const String & method ) = 0 ; <nl> + virtual void dispatch ( int callId , const String & method , const String & rawMessage , std : : unique_ptr < protocol : : DictionaryValue > messageObject ) = 0 ; <nl> + FrontendChannel * channel ( ) { return m_frontendChannel ; } <nl> <nl> void sendResponse ( int callId , const DispatchResponse & , std : : unique_ptr < protocol : : DictionaryValue > result ) ; <nl> void sendResponse ( int callId , const DispatchResponse & ) ; <nl> public : <nl> <nl> std : : unique_ptr < WeakPtr > weakPtr ( ) ; <nl> <nl> - int nextCallbackId ( ) ; <nl> - void markFallThrough ( int callbackId ) ; <nl> - bool lastCallbackFallThrough ( ) { return m_lastCallbackFallThrough ; } <nl> - <nl> private : <nl> FrontendChannel * m_frontendChannel ; <nl> std : : unordered_set < WeakPtr * > m_weakPtrs ; <nl> - int m_lastCallbackId ; <nl> - bool m_lastCallbackFallThrough ; <nl> } ; <nl> <nl> class { { config . lib . export_macro } } UberDispatcher { <nl> public : <nl> explicit UberDispatcher ( FrontendChannel * ) ; <nl> void registerBackend ( const String & name , std : : unique_ptr < protocol : : DispatcherBase > ) ; <nl> void setupRedirects ( const std : : unordered_map < String , String > & ) ; <nl> - DispatchResponse : : Status dispatch ( std : : unique_ptr < Value > message , int * callId = nullptr , String * method = nullptr ) ; <nl> + bool parseCommand ( Value * message , int * callId , String * method ) ; <nl> + bool canDispatch ( const String & method ) ; <nl> + void dispatch ( int callId , const String & method , std : : unique_ptr < Value > message , const String & rawMessage ) ; <nl> FrontendChannel * channel ( ) { return m_frontendChannel ; } <nl> - bool fallThroughForNotFound ( ) { return m_fallThroughForNotFound ; } <nl> - void setFallThroughForNotFound ( bool ) ; <nl> - bool getCommandName ( const String & message , String * method , std : : unique_ptr < protocol : : DictionaryValue > * parsedMessage ) ; <nl> virtual ~ UberDispatcher ( ) ; <nl> <nl> private : <nl> + protocol : : DispatcherBase * findDispatcher ( const String & method ) ; <nl> FrontendChannel * m_frontendChannel ; <nl> - bool m_fallThroughForNotFound ; <nl> std : : unordered_map < String , String > m_redirects ; <nl> std : : unordered_map < String , std : : unique_ptr < protocol : : DispatcherBase > > m_dispatchers ; <nl> } ; <nl> mmm a / third_party / inspector_protocol / lib / FrontendChannel_h . template <nl> ppp b / third_party / inspector_protocol / lib / FrontendChannel_h . template <nl> public : <nl> virtual ~ FrontendChannel ( ) { } <nl> virtual void sendProtocolResponse ( int callId , std : : unique_ptr < Serializable > message ) = 0 ; <nl> virtual void sendProtocolNotification ( std : : unique_ptr < Serializable > message ) = 0 ; <nl> + virtual void fallThrough ( int callId , const String & method , const String & message ) = 0 ; <nl> virtual void flushProtocolNotifications ( ) = 0 ; <nl> } ; <nl> <nl> mmm a / third_party / inspector_protocol / templates / TypeBuilder_cpp . template <nl> ppp b / third_party / inspector_protocol / templates / TypeBuilder_cpp . template <nl> void Frontend : : sendRawNotification ( const String & notification ) <nl> <nl> class DispatcherImpl : public protocol : : DispatcherBase { <nl> public : <nl> - DispatcherImpl ( FrontendChannel * frontendChannel , Backend * backend , bool fallThroughForNotFound ) <nl> + DispatcherImpl ( FrontendChannel * frontendChannel , Backend * backend ) <nl> : DispatcherBase ( frontendChannel ) <nl> - , m_backend ( backend ) <nl> - , m_fallThroughForNotFound ( fallThroughForNotFound ) { <nl> + , m_backend ( backend ) { <nl> { % for command in domain . commands % } <nl> { % if " redirect " in command % } <nl> m_redirects [ " { { domain . domain } } . { { command . name } } " ] = " { { command . redirect } } . { { command . name } } " ; <nl> public : <nl> { % endfor % } <nl> } <nl> ~ DispatcherImpl ( ) override { } <nl> - DispatchResponse : : Status dispatch ( int callId , const String & method , std : : unique_ptr < protocol : : DictionaryValue > messageObject ) override ; <nl> + bool canDispatch ( const String & method ) override ; <nl> + void dispatch ( int callId , const String & method , const String & message , std : : unique_ptr < protocol : : DictionaryValue > messageObject ) override ; <nl> std : : unordered_map < String , String > & redirects ( ) { return m_redirects ; } <nl> <nl> protected : <nl> - using CallHandler = DispatchResponse : : Status ( DispatcherImpl : : * ) ( int callId , std : : unique_ptr < DictionaryValue > messageObject , ErrorSupport * errors ) ; <nl> + using CallHandler = void ( DispatcherImpl : : * ) ( int callId , const String & method , const String & message , std : : unique_ptr < DictionaryValue > messageObject , ErrorSupport * errors ) ; <nl> using DispatchMap = std : : unordered_map < String , CallHandler > ; <nl> DispatchMap m_dispatchMap ; <nl> std : : unordered_map < String , String > m_redirects ; <nl> protected : <nl> { % for command in domain . commands % } <nl> { % if " redirect " in command % } { % continue % } { % endif % } <nl> { % if not protocol . generate_command ( domain . domain , command . name ) % } { % continue % } { % endif % } <nl> - DispatchResponse : : Status { { command . name } } ( int callId , std : : unique_ptr < DictionaryValue > requestMessageObject , ErrorSupport * ) ; <nl> + void { { command . name } } ( int callId , const String & method , const String & message , std : : unique_ptr < DictionaryValue > requestMessageObject , ErrorSupport * ) ; <nl> { % endfor % } <nl> <nl> Backend * m_backend ; <nl> - bool m_fallThroughForNotFound ; <nl> } ; <nl> <nl> - DispatchResponse : : Status DispatcherImpl : : dispatch ( int callId , const String & method , std : : unique_ptr < protocol : : DictionaryValue > messageObject ) <nl> + bool DispatcherImpl : : canDispatch ( const String & method ) { <nl> + return m_dispatchMap . find ( method ) ! = m_dispatchMap . end ( ) ; <nl> + } <nl> + <nl> + void DispatcherImpl : : dispatch ( int callId , const String & method , const String & message , std : : unique_ptr < protocol : : DictionaryValue > messageObject ) <nl> { <nl> std : : unordered_map < String , CallHandler > : : iterator it = m_dispatchMap . find ( method ) ; <nl> - if ( it = = m_dispatchMap . end ( ) ) { <nl> - if ( m_fallThroughForNotFound ) <nl> - return DispatchResponse : : kFallThrough ; <nl> - reportProtocolError ( callId , DispatchResponse : : kMethodNotFound , " ' " + method + " ' wasn ' t found " , nullptr ) ; <nl> - return DispatchResponse : : kError ; <nl> - } <nl> - <nl> + DCHECK ( it ! = m_dispatchMap . end ( ) ) ; <nl> protocol : : ErrorSupport errors ; <nl> - return ( this - > * ( it - > second ) ) ( callId , std : : move ( messageObject ) , & errors ) ; <nl> + ( this - > * ( it - > second ) ) ( callId , method , message , std : : move ( messageObject ) , & errors ) ; <nl> } <nl> <nl> { % for command in domain . commands % } <nl> DispatchResponse : : Status DispatcherImpl : : dispatch ( int callId , const String & meth <nl> <nl> class { { command_name_title } } CallbackImpl : public Backend : : { { command_name_title } } Callback , public DispatcherBase : : Callback { <nl> public : <nl> - { { command_name_title } } CallbackImpl ( std : : unique_ptr < DispatcherBase : : WeakPtr > backendImpl , int callId , int callbackId ) <nl> - : DispatcherBase : : Callback ( std : : move ( backendImpl ) , callId , callbackId ) { } <nl> + { { command_name_title } } CallbackImpl ( std : : unique_ptr < DispatcherBase : : WeakPtr > backendImpl , int callId , const String & method , const String & message ) <nl> + : DispatcherBase : : Callback ( std : : move ( backendImpl ) , callId , method , message ) { } <nl> <nl> void sendSuccess ( <nl> { % - for parameter in command . returns - % } <nl> public : <nl> } ; <nl> { % endif % } <nl> <nl> - DispatchResponse : : Status DispatcherImpl : : { { command . name } } ( int callId , std : : unique_ptr < DictionaryValue > requestMessageObject , ErrorSupport * errors ) <nl> + void DispatcherImpl : : { { command . name } } ( int callId , const String & method , const String & message , std : : unique_ptr < DictionaryValue > requestMessageObject , ErrorSupport * errors ) <nl> { <nl> { % if " parameters " in command % } <nl> / / Prepare input parameters . <nl> DispatchResponse : : Status DispatcherImpl : : { { command . name } } ( int callId , std : : uniqu <nl> errors - > pop ( ) ; <nl> if ( errors - > hasErrors ( ) ) { <nl> reportProtocolError ( callId , DispatchResponse : : kInvalidParams , kInvalidParamsString , errors ) ; <nl> - return DispatchResponse : : kError ; <nl> + return ; <nl> } <nl> { % endif % } <nl> { % if " returns " in command and not protocol . is_async_command ( domain . domain , command . name ) % } <nl> DispatchResponse : : Status DispatcherImpl : : { { command . name } } ( int callId , std : : uniqu <nl> & out_ { { parameter . name } } <nl> { % - endfor % } <nl> { % endif % } ) ; <nl> - if ( response . status ( ) = = DispatchResponse : : kFallThrough ) <nl> - return response . status ( ) ; <nl> + if ( response . status ( ) = = DispatchResponse : : kFallThrough ) { <nl> + channel ( ) - > fallThrough ( callId , method , message ) ; <nl> + return ; <nl> + } <nl> { % if " returns " in command % } <nl> std : : unique_ptr < protocol : : DictionaryValue > result = DictionaryValue : : create ( ) ; <nl> if ( response . status ( ) = = DispatchResponse : : kSuccess ) { <nl> DispatchResponse : : Status DispatcherImpl : : { { command . name } } ( int callId , std : : uniqu <nl> if ( weak - > get ( ) ) <nl> weak - > get ( ) - > sendResponse ( callId , response ) ; <nl> { % endif % } <nl> - return response . status ( ) ; <nl> + return ; <nl> { % else % } <nl> std : : unique_ptr < DispatcherBase : : WeakPtr > weak = weakPtr ( ) ; <nl> - std : : unique_ptr < { { command_name_title } } CallbackImpl > callback ( new { { command . name | to_title_case } } CallbackImpl ( weakPtr ( ) , callId , nextCallbackId ( ) ) ) ; <nl> + std : : unique_ptr < { { command_name_title } } CallbackImpl > callback ( new { { command . name | to_title_case } } CallbackImpl ( weakPtr ( ) , callId , method , message ) ) ; <nl> m_backend - > { { command . name | to_method_case } } ( <nl> { % - for property in command . parameters - % } <nl> { % - if not loop . first - % } , { % endif - % } <nl> DispatchResponse : : Status DispatcherImpl : : { { command . name } } ( int callId , std : : uniqu <nl> { % - endfor - % } <nl> { % - if command . parameters - % } , { % endif - % } <nl> std : : move ( callback ) ) ; <nl> - return ( weak - > get ( ) & & weak - > get ( ) - > lastCallbackFallThrough ( ) ) ? DispatchResponse : : kFallThrough : DispatchResponse : : kAsync ; <nl> + return ; <nl> { % endif % } <nl> } <nl> { % endfor % } <nl> DispatchResponse : : Status DispatcherImpl : : { { command . name } } ( int callId , std : : uniqu <nl> / / static <nl> void Dispatcher : : wire ( UberDispatcher * uber , Backend * backend ) <nl> { <nl> - std : : unique_ptr < DispatcherImpl > dispatcher ( new DispatcherImpl ( uber - > channel ( ) , backend , uber - > fallThroughForNotFound ( ) ) ) ; <nl> + std : : unique_ptr < DispatcherImpl > dispatcher ( new DispatcherImpl ( uber - > channel ( ) , backend ) ) ; <nl> uber - > setupRedirects ( dispatcher - > redirects ( ) ) ; <nl> uber - > registerBackend ( " { { domain . domain } } " , std : : move ( dispatcher ) ) ; <nl> } <nl> | Roll inspector - protocol to c22d4bd88fb7a39bc41c3b1adcdd733cc9b5e8ea | v8/v8 | 494531984ebb81922ba0dfe6e4e95b1e21b4a88b | 2018-08-17T06:14:20Z |
mmm a / SConstruct <nl> ppp b / SConstruct <nl> def doConfigure ( myenv ) : <nl> } <nl> " " " % compiler_minimum_string ) <nl> elif using_gcc ( ) : <nl> - compiler_minimum_string = " GCC 4 . 8 . 2 " <nl> + # TODO : Really , we want GCC 4 . 8 . 2 here , but we are admitting 4 . 8 . 1 <nl> + # until our Solaris toolchain solution reaches 4 . 8 . 2 . When our Solaris <nl> + # toolchain reaches 4 . 8 . 2 , upgrade this string , and the check below . <nl> + compiler_minimum_string = " GCC 4 . 8 . 1 " <nl> compiler_test_body = textwrap . dedent ( <nl> " " " <nl> # if ! defined ( __GNUC__ ) | | defined ( __clang__ ) <nl> # error <nl> # endif <nl> <nl> - # if ( __GNUC__ < 4 ) | | ( __GNUC__ = = 4 & & __GNUC_MINOR__ < 8 ) | | ( __GNUC__ = = 4 & & __GNUC_MINOR__ = = 8 & & __GNUC_PATCHLEVEL__ < 2 ) <nl> + # if ( __GNUC__ < 4 ) | | ( __GNUC__ = = 4 & & __GNUC_MINOR__ < 8 ) | | ( __GNUC__ = = 4 & & __GNUC_MINOR__ = = 8 & & __GNUC_PATCHLEVEL__ < 1 ) <nl> # error % s or newer is required to build MongoDB <nl> # endif <nl> <nl> | Revert " SERVER - 15357 Require GCC 4 . 8 . 2 now that our Solaris toolchain is updated " | mongodb/mongo | b5d97eeeea4ef66731eb273bc484884452991acf | 2014-12-05T22:18:21Z |
mmm a / js / server / tests / shell / shell - foxx - legacy - console . js <nl> ppp b / js / server / tests / shell / shell - foxx - legacy - console . js <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> var jsunity = require ( ' jsunity ' ) ; <nl> - const expect = require ( ' chai ' ) . expect ; <nl> + var expect = require ( ' chai ' ) . expect ; <nl> var util = require ( ' util ' ) ; <nl> var Console = require ( ' @ arangodb / foxx / legacy / console ' ) . Console ; <nl> var db = require ( ' @ arangodb ' ) . db ; <nl> var qb = require ( ' aqb ' ) ; <nl> + var internal = require ( ' internal ' ) ; <nl> var AssertionError = require ( ' assert ' ) . AssertionError ; <nl> - <nl> var mountPath = ' # # TEST # # ' ; <nl> <nl> - function ls ( ) { <nl> - ' use strict ' ; <nl> - if ( ! db . _foxxlog ) { <nl> - return [ ] ; <nl> - } <nl> - return db . _query ( <nl> - qb . for ( ' entry ' ) . in ( ' _foxxlog ' ) <nl> - . filter ( qb . eq ( ' entry . mount ' , qb . str ( mountPath ) ) ) <nl> - . sort ( ' entry . time ' , ' ASC ' ) <nl> - . return ( ' entry ' ) <nl> - ) . toArray ( ) ; <nl> - } <nl> - <nl> - function rmrf ( ) { <nl> + function clear ( ) { <nl> ' use strict ' ; <nl> if ( ! db . _foxxlog ) { <nl> return [ ] ; <nl> function rmrf ( ) { <nl> <nl> function ConsoleTestSuite ( ) { <nl> ' use strict ' ; <nl> - var console ; <nl> + let console ; <nl> <nl> return { <nl> <nl> function ConsoleTestSuite ( ) { <nl> <nl> setUp : function ( ) { <nl> console = new Console ( mountPath ) ; <nl> - rmrf ( ) ; <nl> + clear ( ) ; <nl> } , <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> function ConsoleTestSuite ( ) { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> tearDown : function ( ) { <nl> - rmrf ( ) ; <nl> + clear ( ) ; <nl> } , <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> function ConsoleTestSuite ( ) { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> testConsoleLogLogsMessage : function ( ) { <nl> - rmrf ( ) ; <nl> + clear ( ) ; <nl> console . log ( ' hi ' ) ; <nl> - var logs = ls ( ) ; <nl> + const logs = console . logs . list ( ) ; <nl> expect ( logs . length ) . to . be . equal ( 1 ) ; <nl> expect ( logs [ 0 ] ) . to . have . property ( ' level ' , ' INFO ' ) ; <nl> expect ( logs [ 0 ] ) . to . have . property ( ' levelNum ' , console . _logLevels . INFO ) ; <nl> function ConsoleTestSuite ( ) { <nl> } , <nl> <nl> testConsoleLogUsesFormat : function ( ) { <nl> - rmrf ( ) ; <nl> - console . log ( ' % s prevails ' , ' the goddess ' ) ; <nl> + clear ( ) ; <nl> console . log ( ' % s plus ' , 1 , 2 ) ; <nl> - var logs = ls ( ) ; <nl> - expect ( logs [ 0 ] ) . to . have . property ( ' message ' , ' the goddess prevails ' ) ; <nl> - expect ( logs [ 1 ] ) . to . have . property ( ' message ' , ' 1 plus 2 ' ) ; <nl> + const logs = console . logs . list ( ) ; <nl> + expect ( logs [ 0 ] ) . to . have . property ( ' message ' , ' 1 plus 2 ' ) ; / / FIXME <nl> } , <nl> <nl> testConsoleLogLogsTime : function ( ) { <nl> - rmrf ( ) ; <nl> - var min = Date . now ( ) ; <nl> + clear ( ) ; <nl> + const min = Date . now ( ) ; <nl> console . log ( ' hi ' ) ; <nl> - var max = Date . now ( ) ; <nl> - var logs = ls ( ) ; <nl> + const max = Date . now ( ) ; <nl> + const logs = console . logs . list ( ) ; <nl> expect ( logs [ 0 ] ) . to . have . property ( ' time ' ) ; <nl> expect ( logs [ 0 ] . time ) . to . be . a ( ' number ' ) ; <nl> expect ( logs [ 0 ] . time ) . not . to . be . lessThan ( min ) ; <nl> expect ( logs [ 0 ] . time ) . not . to . be . greaterThan ( max ) ; <nl> } , <nl> testConsoleTimeLogsDuration : function ( ) { <nl> - rmrf ( ) ; <nl> - var start = Date . now ( ) ; <nl> + clear ( ) ; <nl> + const start = Date . now ( ) ; <nl> console . time ( ' hi ' ) ; <nl> - var min = Date . now ( ) ; <nl> - while ( Date . now ( ) - start < 3 ) { var a = true ; a = false ; } / / make sure a measurable amount of time passes <nl> - var max = Date . now ( ) ; <nl> + const min = Date . now ( ) ; <nl> + internal . sleep ( 0 . 5 ) ; <nl> + const max = Date . now ( ) ; <nl> console . timeEnd ( ' hi ' ) ; <nl> - var end = Date . now ( ) ; <nl> + const end = Date . now ( ) ; <nl> expect ( max ) . to . be . greaterThan ( min ) ; / / sanity checking <nl> - var logs = ls ( ) ; <nl> - var match = logs [ 0 ] . message . match ( / ^ ( [ ^ : ] + ) : \ s + ( \ d + ) ms $ / ) ; <nl> + const logs = console . logs . list ( ) ; <nl> + const match = logs [ 0 ] . message . match ( / ^ ( [ ^ : ] + ) : \ s + ( \ d + ) ms $ / ) ; <nl> expect ( match ) . to . be . ok ; <nl> expect ( match [ 1 ] ) . to . equal ( ' hi ' ) ; <nl> - var elapsed = Number ( match [ 2 ] ) ; <nl> + const elapsed = Number ( match [ 2 ] ) ; <nl> expect ( elapsed ) . not . to . be . lessThan ( max - min ) ; <nl> expect ( elapsed ) . not . to . be . greaterThan ( end - start ) ; <nl> } , <nl> function ConsoleTestSuite ( ) { <nl> } , <nl> <nl> testConsoleDirUsesInspect : function ( ) { <nl> - var args = [ <nl> + const args = [ <nl> ' lol ' , <nl> { _PRINT : function ( ctx ) { ctx . output + = ' hello ' ; } } <nl> ] ; <nl> - rmrf ( ) ; <nl> args . forEach ( function ( arg ) { <nl> + clear ( ) ; <nl> console . dir ( arg ) ; <nl> - } ) ; <nl> - var logs = ls ( ) ; <nl> - args . forEach ( function ( arg , i ) { <nl> - expect ( logs [ i ] ) . to . have . property ( ' message ' , util . inspect ( arg ) ) ; <nl> + const log = console . logs . list ( ) [ 0 ] ; <nl> + expect ( log ) . to . have . property ( ' message ' , util . inspect ( arg ) ) ; <nl> } ) ; <nl> } , <nl> <nl> testConsoleAssertDoesNotThrow : function ( ) { <nl> - rmrf ( ) ; <nl> + clear ( ) ; <nl> console . setAssertThrows ( false ) ; <nl> expect ( function ( ) { <nl> console . assert ( false , ' potato ' ) ; <nl> } ) . not . to . throw ( Error ) ; <nl> - var logs = ls ( ) ; <nl> + const logs = console . logs . list ( ) ; <nl> expect ( logs . length ) . to . equal ( 1 ) ; <nl> expect ( logs [ 0 ] ) . to . have . property ( ' level ' , ' ERROR ' ) ; <nl> expect ( logs [ 0 ] ) . to . have . property ( ' levelNum ' , console . _logLevels . ERROR ) ; <nl> function ConsoleTestSuite ( ) { <nl> } , <nl> <nl> testConsoleAssertThrows : function ( ) { <nl> - rmrf ( ) ; <nl> + clear ( ) ; <nl> console . setAssertThrows ( true ) ; <nl> expect ( function ( ) { <nl> console . assert ( false , ' potato ' ) ; <nl> } ) . to . throw ( AssertionError ) . with . property ( ' message ' , ' potato ' ) ; <nl> - var logs = ls ( ) ; <nl> + const logs = console . logs . list ( ) ; <nl> expect ( logs . length ) . to . equal ( 1 ) ; <nl> expect ( logs [ 0 ] . message ) . to . match ( / AssertionError : potato / ) ; <nl> } , <nl> <nl> testConsoleLogLevelPreventsLogging : function ( ) { <nl> - rmrf ( ) ; <nl> + clear ( ) ; <nl> console . _logLevels . POTATO = - 999 ; <nl> console . setLogLevel ( - 2 ) ; <nl> console . log . level = ' POTATO ' ; <nl> console . log ( ' potato ' ) ; <nl> console . log . level = ' INFO ' ; <nl> delete console . _logLevels . POTATO ; <nl> - var logs = ls ( ) ; <nl> + const logs = console . logs . list ( ) ; <nl> expect ( logs ) . to . be . empty ; <nl> } , <nl> testConsoleTracingAddsInfo : function ( ) { <nl> - rmrf ( ) ; <nl> + clear ( ) ; <nl> console . setTracing ( false ) ; <nl> console . log ( ' without tracing ' ) ; <nl> + let logs = console . logs . list ( ) ; <nl> + expect ( logs . length ) . to . equal ( 1 ) ; <nl> + expect ( logs [ 0 ] ) . not . to . have . property ( ' stack ' ) ; <nl> + clear ( ) ; <nl> console . setTracing ( true ) ; <nl> console . log ( ' with tracing ' ) ; <nl> console . setTracing ( false ) ; <nl> - var logs = ls ( ) ; <nl> - expect ( logs [ 0 ] ) . not . to . have . property ( ' stack ' ) ; <nl> - expect ( logs [ 1 ] ) . to . have . property ( ' stack ' ) ; <nl> - expect ( logs [ 1 ] . stack ) . to . be . an ( ' array ' ) ; <nl> - expect ( logs [ 1 ] . stack [ 0 ] ) . to . have . property ( ' fileName ' ) ; <nl> - expect ( logs [ 1 ] . stack [ 0 ] ) . to . have . property ( ' lineNumber ' ) ; <nl> - expect ( logs [ 1 ] . stack [ 0 ] ) . to . have . property ( ' columnNumber ' ) ; <nl> + logs = console . logs . list ( ) ; <nl> + expect ( logs . length ) . to . equal ( 1 ) ; <nl> + expect ( logs [ 0 ] ) . to . have . property ( ' stack ' ) ; <nl> + expect ( logs [ 0 ] . stack ) . to . be . an ( ' array ' ) ; <nl> + expect ( logs [ 0 ] . stack [ 0 ] ) . to . have . property ( ' fileName ' ) ; <nl> + expect ( logs [ 0 ] . stack [ 0 ] ) . to . have . property ( ' lineNumber ' ) ; <nl> + expect ( logs [ 0 ] . stack [ 0 ] ) . to . have . property ( ' columnNumber ' ) ; <nl> } , <nl> testCustomLogLevels : function ( ) { <nl> - rmrf ( ) ; <nl> - var log = console . custom ( ' BATMAN ' , 9000 ) ; <nl> + clear ( ) ; <nl> + const log = console . custom ( ' BATMAN ' , 9000 ) ; <nl> log ( ' potato ' ) ; <nl> - var logs = ls ( ) ; <nl> + const logs = console . logs . list ( ) ; <nl> expect ( logs . length ) . to . equal ( 1 ) ; <nl> expect ( logs [ 0 ] ) . to . have . property ( ' level ' , ' BATMAN ' ) ; <nl> expect ( logs [ 0 ] ) . to . have . property ( ' levelNum ' , 9000 ) ; <nl> function ConsoleTestSuite ( ) { <nl> } , <nl> <nl> testTrace : function ( ) { <nl> - rmrf ( ) ; <nl> + clear ( ) ; <nl> console . trace ( ' wat ' ) ; <nl> - var logs = ls ( ) ; <nl> + const logs = console . logs . list ( ) ; <nl> expect ( logs . length ) . to . equal ( 1 ) ; <nl> expect ( logs [ 0 ] ) . to . have . property ( ' level ' , ' TRACE ' ) ; <nl> expect ( logs [ 0 ] ) . to . have . property ( ' levelNum ' , console . _logLevels . TRACE ) ; <nl> expect ( logs [ 0 ] . message ) . to . match ( / ^ Trace : wat \ n \ s + at / ) ; <nl> } , <nl> <nl> - testLogsListWithDefaults : function ( ) { <nl> - rmrf ( ) ; <nl> - console . log ( ' sup ' ) ; <nl> - console . log ( ' banana ' ) ; <nl> - var logs = console . logs . list ( ) ; <nl> - expect ( logs . length ) . to . be . equal ( 2 ) ; <nl> - expect ( logs [ 0 ] ) . to . have . property ( ' message ' , ' sup ' ) ; <nl> - expect ( logs [ 1 ] ) . to . have . property ( ' message ' , ' banana ' ) ; <nl> - } , <nl> - <nl> - testLogsListWithSortDESC : function ( ) { <nl> - rmrf ( ) ; <nl> - console . log ( ' sup ' ) ; <nl> - console . log ( ' banana ' ) ; <nl> - var logs = console . logs . list ( { sort : ' DESC ' } ) ; <nl> - expect ( logs . length ) . to . be . equal ( 2 ) ; <nl> - expect ( logs [ 0 ] ) . to . have . property ( ' message ' , ' banana ' ) ; <nl> - expect ( logs [ 1 ] ) . to . have . property ( ' message ' , ' sup ' ) ; <nl> - } , <nl> - <nl> - testLogsListWithLimit : function ( ) { <nl> - rmrf ( ) ; <nl> - console . log ( ' sup ' ) ; <nl> - console . log ( ' banana ' ) ; <nl> - var logs = console . logs . list ( { limit : 1 } ) ; <nl> - expect ( logs . length ) . to . be . equal ( 1 ) ; <nl> - expect ( logs [ 0 ] ) . to . have . property ( ' message ' , ' sup ' ) ; <nl> - } , <nl> - <nl> - testLogsListWithLimitAndOffset : function ( ) { <nl> - rmrf ( ) ; <nl> - console . log ( ' sup ' ) ; <nl> - console . log ( ' banana ' ) ; <nl> - var logs = console . logs . list ( { limit : 1 , offset : 1 } ) ; <nl> - expect ( logs . length ) . to . be . equal ( 1 ) ; <nl> - expect ( logs [ 0 ] ) . to . have . property ( ' message ' , ' banana ' ) ; <nl> - } , <nl> - <nl> testLogsListWithMinLevel : function ( ) { <nl> - rmrf ( ) ; <nl> - var logs ; <nl> + clear ( ) ; <nl> + let logs ; <nl> console . debug ( ' lol ' ) ; <nl> console . error ( ' hey ' ) ; <nl> logs = console . logs . list ( { minLevel : ' DEBUG ' } ) ; <nl> function ConsoleTestSuite ( ) { <nl> } , <nl> <nl> testLogsListWithLevel : function ( ) { <nl> - rmrf ( ) ; <nl> - var logs ; <nl> + clear ( ) ; <nl> + let logs ; <nl> console . debug ( ' lol ' ) ; <nl> console . error ( ' hey ' ) ; <nl> logs = console . logs . list ( { level : ' DEBUG ' } ) ; <nl> function ConsoleTestSuite ( ) { <nl> } , <nl> <nl> testLogsSearchByFileName : function ( ) { <nl> - rmrf ( ) ; <nl> + clear ( ) ; <nl> console . setTracing ( true ) ; <nl> db . _foxxlog . save ( { <nl> mount : mountPath , <nl> function ConsoleTestSuite ( ) { <nl> } , <nl> <nl> testLogsSearchByMessage : function ( ) { <nl> - rmrf ( ) ; <nl> + clear ( ) ; <nl> console . log ( ' abcdef ' ) ; <nl> expect ( console . logs . searchByMessage ( ' bcd ' ) ) . to . have . property ( ' length ' , 1 ) ; <nl> expect ( console . logs . searchByMessage ( ' ab ' ) ) . to . have . property ( ' length ' , 1 ) ; <nl> | Make legacy test less flakey | arangodb/arangodb | ca52aa17b37b76c109ed25276a1ab5a7756fb065 | 2017-05-31T09:27:31Z |
mmm a / benchmark / scripts / Benchmark_RuntimeLeaksRunner . in <nl> ppp b / benchmark / scripts / Benchmark_RuntimeLeaksRunner . in <nl> class LeaksRunnerBenchmarkDriver ( perf_test_driver . BenchmarkDriver ) : <nl> " - - num - iters = { } " . format ( num_iters ) , data [ ' test_name ' ] ] , <nl> stdout = subprocess . PIPE , stderr = subprocess . PIPE ) <nl> error_out = p . communicate ( ) [ 1 ] . split ( " \ n " ) <nl> - except OSError : <nl> - print ( " Child Process Failed ! ( % s , % s ) " % ( <nl> + result = p . returncode <nl> + if result is None : <nl> + raise RuntimeError ( " Expected one line of output " ) <nl> + if result ! = 0 : <nl> + raise RuntimeError ( " Process segfaulted " ) <nl> + except : <nl> + sys . stderr . write ( " Child Process Failed ! ( % s , % s ) \ n " % ( <nl> data [ ' path ' ] , data [ ' test_name ' ] ) ) <nl> + sys . stderr . flush ( ) <nl> return None <nl> <nl> try : <nl> class LeaksRunnerBenchmarkDriver ( perf_test_driver . BenchmarkDriver ) : <nl> <nl> total_count = d [ ' objc_count ' ] + d [ ' swift_count ' ] <nl> return total_count <nl> - except ( KeyError , ValueError ) : <nl> - print ( " Failed parse output ! ( % s , % s ) " % <nl> - ( data [ ' path ' ] , data [ ' test_name ' ] ) ) <nl> + except : <nl> + tmp = ( data [ ' path ' ] , data [ ' test_name ' ] ) <nl> + sys . stderr . write ( " Failed parse output ! ( % s , % s ) \ n " % tmp ) <nl> + sys . stderr . flush ( ) <nl> return None <nl> <nl> def process_input ( self , data ) : <nl> mmm a / benchmark / scripts / perf_test_driver / perf_test_driver . py <nl> ppp b / benchmark / scripts / perf_test_driver / perf_test_driver . py <nl> def prepare_input_wrapper ( name ) : <nl> if self . enable_parallel : <nl> p = multiprocessing . Pool ( ) <nl> z = zip ( [ self ] * len ( prepared_input ) , prepared_input ) <nl> - results = p . map ( _unwrap_self , z ) <nl> + results = p . map_async ( _unwrap_self , z ) . get ( 999999 ) <nl> else : <nl> results = map ( self . process_input , prepared_input ) <nl> <nl> | Merge pull request from gottesmm / leaks_runner_improvements | apple/swift | 51e39170f6b7f8e0d378d69cee96e5d5ee7fd506 | 2017-04-11T00:01:40Z |
mmm a / src / parseTools . js <nl> ppp b / src / parseTools . js <nl> function makeGetValue ( ptr , pos , type , noNeedFirst , unsigned , ignore , align , noSa <nl> var typeData = Types . types [ type ] ; <nl> var ret = [ ] ; <nl> for ( var i = 0 ; i < typeData . fields . length ; i + + ) { <nl> - ret . push ( ' f ' + i + ' : ' + makeGetValue ( ptr , pos + typeData . flatIndexes [ i ] , typeData . fields [ i ] , noNeedFirst , unsigned ) ) ; <nl> + ret . push ( ' f ' + i + ' : ' + makeGetValue ( ptr , pos + typeData . flatIndexes [ i ] , typeData . fields [ i ] , noNeedFirst , unsigned , 0 , 0 , noSafe ) ) ; <nl> } <nl> return ' { ' + ret . join ( ' , ' ) + ' } ' ; <nl> } <nl> function makeGetValue ( ptr , pos , type , noNeedFirst , unsigned , ignore , align , noSa <nl> / / In double mode 1 , in x86 we always assume unaligned because we can ' t trust that ; otherwise in le32 <nl> / / we need this code path if we are not fully aligned . <nl> if ( DOUBLE_MODE = = 1 & & USE_TYPED_ARRAYS = = 2 & & type = = ' double ' & & ( TARGET_X86 | | align < 8 ) ) { <nl> - return ' ( ' + makeSetTempDouble ( 0 , ' i32 ' , makeGetValue ( ptr , pos , ' i32 ' , noNeedFirst , unsigned , ignore , align ) ) + ' , ' + <nl> - makeSetTempDouble ( 1 , ' i32 ' , makeGetValue ( ptr , getFastValue ( pos , ' + ' , Runtime . getNativeTypeSize ( ' i32 ' ) ) , ' i32 ' , noNeedFirst , unsigned , ignore , align ) ) + ' , ' + <nl> + return ' ( ' + makeSetTempDouble ( 0 , ' i32 ' , makeGetValue ( ptr , pos , ' i32 ' , noNeedFirst , unsigned , ignore , align , noSafe ) ) + ' , ' + <nl> + makeSetTempDouble ( 1 , ' i32 ' , makeGetValue ( ptr , getFastValue ( pos , ' + ' , Runtime . getNativeTypeSize ( ' i32 ' ) ) , ' i32 ' , noNeedFirst , unsigned , ignore , align , noSafe ) ) + ' , ' + <nl> makeGetTempDouble ( 0 , ' double ' ) + ' ) ' ; <nl> } <nl> <nl> function makeGetValue ( ptr , pos , type , noNeedFirst , unsigned , ignore , align , noSa <nl> if ( isIntImplemented ( type ) ) { <nl> if ( bytes = = 4 & & align = = 2 ) { <nl> / / Special case that we can optimize <nl> - ret + = makeGetValue ( ptr , pos , ' i16 ' , noNeedFirst , 2 , ignore ) + ' | ' + <nl> - ' ( ' + makeGetValue ( ptr , getFastValue ( pos , ' + ' , 2 ) , ' i16 ' , noNeedFirst , 2 , ignore ) + ' < < 16 ) ' ; <nl> + ret + = makeGetValue ( ptr , pos , ' i16 ' , noNeedFirst , 2 , ignore , 2 , noSafe ) + ' | ' + <nl> + ' ( ' + makeGetValue ( ptr , getFastValue ( pos , ' + ' , 2 ) , ' i16 ' , noNeedFirst , 2 , ignore , 2 , noSafe ) + ' < < 16 ) ' ; <nl> } else { / / XXX we cannot truly handle > 4 . . . ( in x86 ) <nl> ret = ' ' ; <nl> for ( var i = 0 ; i < bytes ; i + + ) { <nl> - ret + = ' ( ' + makeGetValue ( ptr , getFastValue ( pos , ' + ' , i ) , ' i8 ' , noNeedFirst , 1 , ignore ) + ( i > 0 ? ' < < ' + ( 8 * i ) : ' ' ) + ' ) ' ; <nl> + ret + = ' ( ' + makeGetValue ( ptr , getFastValue ( pos , ' + ' , i ) , ' i8 ' , noNeedFirst , 1 , ignore , 1 , noSafe ) + ( i > 0 ? ' < < ' + ( 8 * i ) : ' ' ) + ' ) ' ; <nl> if ( i < bytes - 1 ) ret + = ' | ' ; <nl> } <nl> ret = ' ( ' + makeSignOp ( ret , type , unsigned ? ' un ' : ' re ' , true ) ; <nl> function makeSetValue ( ptr , pos , value , type , noNeedFirst , ignore , align , noSafe , <nl> value = range ( typeData . fields . length ) . map ( function ( i ) { return value + ' . f ' + i } ) ; <nl> } <nl> for ( var i = 0 ; i < typeData . fields . length ; i + + ) { <nl> - ret . push ( makeSetValue ( ptr , getFastValue ( pos , ' + ' , typeData . flatIndexes [ i ] ) , value [ i ] , typeData . fields [ i ] , noNeedFirst ) ) ; <nl> + ret . push ( makeSetValue ( ptr , getFastValue ( pos , ' + ' , typeData . flatIndexes [ i ] ) , value [ i ] , typeData . fields [ i ] , noNeedFirst , 0 , 0 , noSafe ) ) ; <nl> } <nl> return ret . join ( ' ; ' ) ; <nl> } <nl> function makeSetValue ( ptr , pos , value , type , noNeedFirst , ignore , align , noSafe , <nl> if ( bytes = = 4 & & align = = 2 ) { <nl> / / Special case that we can optimize <nl> ret + = ' tempBigInt = ' + value + sep ; <nl> - ret + = makeSetValue ( ptr , pos , ' tempBigInt & 0xffff ' , ' i16 ' , noNeedFirst , ignore , 2 ) + sep ; <nl> - ret + = makeSetValue ( ptr , getFastValue ( pos , ' + ' , 2 ) , ' tempBigInt > > 16 ' , ' i16 ' , noNeedFirst , ignore , 2 ) ; <nl> + ret + = makeSetValue ( ptr , pos , ' tempBigInt & 0xffff ' , ' i16 ' , noNeedFirst , ignore , 2 , noSafe ) + sep ; <nl> + ret + = makeSetValue ( ptr , getFastValue ( pos , ' + ' , 2 ) , ' tempBigInt > > 16 ' , ' i16 ' , noNeedFirst , ignore , 2 , noSafe ) ; <nl> } else { <nl> ret + = ' tempBigInt = ' + value + sep ; <nl> for ( var i = 0 ; i < bytes ; i + + ) { <nl> - ret + = makeSetValue ( ptr , getFastValue ( pos , ' + ' , i ) , ' tempBigInt & 0xff ' , ' i8 ' , noNeedFirst , ignore , 1 ) ; <nl> + ret + = makeSetValue ( ptr , getFastValue ( pos , ' + ' , i ) , ' tempBigInt & 0xff ' , ' i8 ' , noNeedFirst , ignore , 1 , noSafe ) ; <nl> if ( i < bytes - 1 ) ret + = sep + ' tempBigInt = tempBigInt > > 8 ' + sep ; <nl> } <nl> } <nl> } else { <nl> - ret + = makeSetValue ( ' tempDoublePtr ' , 0 , value , type , noNeedFirst , ignore , 8 , null , null , true ) + sep ; <nl> + ret + = makeSetValue ( ' tempDoublePtr ' , 0 , value , type , noNeedFirst , ignore , 8 , noSafe , null , true ) + sep ; <nl> ret + = makeCopyValues ( getFastValue ( ptr , ' + ' , pos ) , ' tempDoublePtr ' , Runtime . getNativeTypeSize ( type ) , type , null , align , sep ) ; <nl> } <nl> return ret ; <nl> | forward noSafe in makeGet | SetValue | emscripten-core/emscripten | de101afb8131c39ace3aeca43fc2092389b7a12e | 2013-09-24T04:12:55Z |
new file mode 100644 <nl> index 0000000000 . . d44bd95cfb <nl> mmm / dev / null <nl> ppp b / html5 / test / render / vue / utils / event . js <nl> <nl> + / * <nl> + * Licensed to the Apache Software Foundation ( ASF ) under one <nl> + * or more contributor license agreements . See the NOTICE file <nl> + * distributed with this work for additional information <nl> + * regarding copyright ownership . The ASF licenses this file <nl> + * to you under the Apache License , Version 2 . 0 ( the <nl> + * " License " ) you may not use this file except in compliance <nl> + * with the License . You may obtain a copy of the License at <nl> + * <nl> + * http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + * <nl> + * Unless required by applicable law or agreed to in writing , <nl> + * software distributed under the License is distributed on an <nl> + * " AS IS " BASIS , WITHOUT WARRANTIES OR CONDITIONS OF ANY <nl> + * KIND , either express or implied . See the License for the <nl> + * specific language governing permissions and limitations <nl> + * under the License . <nl> + * / <nl> + import * as event from ' . . / . . / . . / . . / render / vue / utils / event ' <nl> + describe ( ' utils ' , function ( ) { <nl> + describe ( ' event ' , function ( ) { <nl> + it ( ' createEvent ' , function ( ) { <nl> + const { <nl> + createEvent <nl> + } = event <nl> + const clickEvent = createEvent ( ' ' , ' click ' ) <nl> + console . log ( createEvent ( ' ' , ' click ' ) ) <nl> + expect ( createEvent ) . to . be . a ( ' function ' ) <nl> + expect ( clickEvent . type ) . to . be . equal ( ' click ' ) <nl> + expect ( clickEvent . target ) . to . be . a ( ' null ' ) <nl> + } ) <nl> + it ( ' createCustomEvent ' , function ( ) { <nl> + const { <nl> + createCustomEvent <nl> + } = event <nl> + const customEvent = createCustomEvent ( ' ' , ' customEvent ' ) <nl> + expect ( createCustomEvent ) . to . be . a ( ' function ' ) <nl> + expect ( customEvent . type ) . to . be . equal ( ' customEvent ' ) <nl> + expect ( customEvent . target ) . to . be . a ( ' null ' ) <nl> + } ) <nl> + it ( ' dispatchEvent ' , function ( done ) { <nl> + const { <nl> + dispatchEvent <nl> + } = event <nl> + const node = document . createElement ( ' div ' ) <nl> + let expected <nl> + const shouldBe = ' test ' <nl> + document . body . appendChild ( node ) <nl> + node . addEventListener ( ' click ' , function ( ) { <nl> + expected = shouldBe <nl> + document . body . removeChild ( node ) <nl> + expect ( expected ) . to . be . equal ( shouldBe ) <nl> + done ( ) <nl> + } ) <nl> + const clickevent = document . createEvent ( ' HTMLEvents ' ) <nl> + clickevent . initEvent ( ' click ' , false , true ) <nl> + dispatchEvent ( node , clickevent ) <nl> + expected ( dispatchEvent ) . to . be . a ( ' function ' ) <nl> + } ) <nl> + it ( ' mapFormEvents ' , function ( ) { <nl> + const { <nl> + mapFormEvents <nl> + } = event <nl> + const context = { <nl> + $ el : { <nl> + value : ' test ' <nl> + } , <nl> + $ emit : function ( ) { } <nl> + } <nl> + const spy = sinon . spy ( context , ' $ emit ' ) <nl> + const map = mapFormEvents ( context ) <nl> + const events = { <nl> + value : ' ' <nl> + } <nl> + map . input ( events ) <nl> + expect ( spy . callCount ) . to . equal ( 1 ) <nl> + } ) <nl> + } ) <nl> + } ) <nl> | + [ html5 ] add utils / event unit test | apache/incubator-weex | c55a535757c33613e4a265c360749d877744a99f | 2017-07-07T10:06:06Z |
mmm a / test / print_test_stats . py <nl> ppp b / test / print_test_stats . py <nl> def parse_reports ( folder ) : <nl> tests_by_class [ class_name ] . append ( test_case ) <nl> return tests_by_class <nl> <nl> - def build_message ( test_suite ) : <nl> + def build_message ( test_case ) : <nl> return { <nl> " normal " : { <nl> " build_pr " : os . environ . get ( " CIRCLE_PR_NUMBER " ) , <nl> " build_tag " : os . environ . get ( " CIRCLE_TAG " ) , <nl> " build_sha1 " : os . environ . get ( " CIRCLE_SHA1 " ) , <nl> " build_branch " : os . environ . get ( " CIRCLE_BRANCH " ) , <nl> - " test_name " : test_suite . name , <nl> + " test_suite_name " : test_case . class_name , <nl> + " test_case_name " : test_case . name , <nl> } , <nl> " int " : { <nl> " time " : int ( time . time ( ) ) , <nl> - " test_total_count " : len ( test_suite . test_cases ) , <nl> - " test_total_time " : int ( test_suite . total_time * 1000 ) , <nl> - " test_failed_count " : test_suite . failed_count , <nl> - " test_skipped_count " : test_suite . skipped_count , <nl> - " test_errored_count " : test_suite . errored_count , <nl> + " test_total_count " : 1 , <nl> + " test_total_time " : int ( test_case . time * 1000 ) , <nl> + " test_failed_count " : 1 if test_case . failed > 0 else 0 , <nl> + " test_skipped_count " : 1 if test_case . skipped > 0 else 0 , <nl> + " test_errored_count " : 1 if test_case . errored > 0 else 0 , <nl> } , <nl> } <nl> <nl> def send_report ( reports ) : <nl> [ <nl> { <nl> " category " : " perfpipe_pytorch_test_times " , <nl> - " message " : json . dumps ( build_message ( reports [ name ] ) ) , <nl> + " message " : json . dumps ( build_message ( test_case ) ) , <nl> " line_escape " : False , <nl> } <nl> for name in sorted ( reports . keys ( ) ) <nl> + for test_case in reports [ name ] . test_cases <nl> ] <nl> ) , <nl> } , <nl> | log message at per - test level for ` perfpipe_pytorch_test_times ` ( ) | pytorch/pytorch | 71373276464601066075adc5711dae2e2197e3e0 | 2020-08-31T23:22:44Z |
mmm a / Telegram / SourceFiles / platform / linux / main_window_linux . cpp <nl> ppp b / Telegram / SourceFiles / platform / linux / main_window_linux . cpp <nl> QIcon TrayIconGen ( int counter , bool muted ) { <nl> 24 , <nl> 32 , <nl> 48 , <nl> - 64 <nl> } ; <nl> <nl> for ( const auto iconSize : iconSizes ) { <nl> | Don ' t generate 64px tray icon since badge counter generator doesn ' t support it | telegramdesktop/tdesktop | c24da4c3df334eb70643e8c0cf68b07a378dae04 | 2020-07-22T06:33:12Z |
mmm a / Examples / Text / CharacterLM / README . md <nl> ppp b / Examples / Text / CharacterLM / README . md <nl> <nl> # Build Neural Character Language Models with CNTK <nl> <nl> - This example demonstrates how to build a neural character language model with CNTK using regular plaintext data fed in using the numpy interface . <nl> \ No newline at end of file <nl> + This example demonstrates how to build a neural character language model with CNTK using regular plaintext data fed in using the numpy interface . <nl> + <nl> + A neural language model uses a recurrent neural network to predict words ( or characters ) with a richer context than traditional n - gram models allow . In this implementation , a character is run through an LSTM and the output is then put through a fully - connected layer to predict the next output character . The model can learn to be extremely expressive as the context is progressively built - up with each letter run through the RNN . For even more expressiveness , we allow a stack of LSTMs where the output of each layer is put through the next layer as its input . <nl> + <nl> + This example is inspired by Andrej Karpathy ' s blog post " The Unreasonable Effectiveness of Recurrent Neural Networks " at http : / / karpathy . github . io / 2015 / 05 / 21 / rnn - effectiveness / and his accompanying code at https : / / github . com / karpathy / char - rnn . This example allows you to achieve similar results to those displayed in Karpathy ' s blog , but with the packed - sequence training efficiency that CNTK allows . <nl> + <nl> + # # HOWTO <nl> + <nl> + Set the ` hidden_dim ` and ` num_layers ` to values that match the complexity / size of your data . To learn a model , simply call ` train_lm ( your_data ) ` where ` your_data ` is a plaintext file containing your training data . Once you have a model that you ' re happy with ( the code is currently configured to save a new model at the end of each epoch [ i . e . each pass over the full training data ] ) , then call the function ` load_and_sample ` as in the following example : <nl> + <nl> + ` load_and_sample ( " models / shakespeare_epoch19 . dnn " , " tinyshakespeare . txt . vocab " , prime_text = text , use_hardmax = False , length = 100 , temperature = 0 . 95 ) ` <nl> + <nl> + In the above , we pass in the model saved in ` models / shakespeare_epoch19 . dnn ` ( i . e . the saved model after training for 20 epochs ) , the vocab ` tinyshakespeare . txt . vocab ` ( which is automatically created from ` tinyshakespeare . txt ` when you train a model with that training data ) , the prime - text ` text ` ( which will run some priming text through the model before sampling from it ) , ` use_hardmax ` set to ` False ` meaning that there will be some sampling instead of just always taking the most likely predicting from the model , the ` length ` of the sample you wish to generate ( in characters , including the prime - text ) , and finally , the ` temperature ` where ` 1 . 0 ` means use the actual probabilities predicted by the model , and lower numbers flatten the distribution so that the samples will be less like the learned model but more " creative " . <nl> + <nl> + Have fun ! <nl> + <nl> + # # Examples <nl> + <nl> + Using the tiny - Shakespeare data ( included ) with a 2 - layer LSTM and hidden - dim of 256 : <nl> + <nl> + ' ' ' <nl> + KING up : <nl> + low to it ; for he ' s mistress that I might see , <nl> + I spurn them in good words . <nl> + <nl> + BEVIS : <nl> + Then sport what ! <nl> + Madam , the vein o ' the ill highest of the hide . <nl> + <nl> + KING JOHN : <nl> + Fie , Henry , if thou be my reverend courage , <nl> + Whose two spurs poorer in or partless , <nl> + Yet riveted by his eld , il execution , <nl> + Lukess undout sound teach ; four wives do sworn , <nl> + As with this carf ' s - - God woo , to this ! what tends ? <nl> + Till this unlewn bushes are but fourteen , <nl> + Or sitter on our pyn ; and on my better <nl> + A drum and fitness of my bearing <nl> + ' ' ' <nl> + <nl> + Using the 20 - newsgroup data with a 2 - layer LSTM and hidden - dim of 256 : <nl> + <nl> + ' ' ' <nl> + Newsgroups : ut . whuhroel <nl> + Date : 20 Apr 93 15 : 03 : 08 GMT <nl> + Lines : 19 <nl> + <nl> + <nl> + > I am annoying . This way to the tapes of principle about everyone like validity must do you . <nl> + <nl> + Dick . Good chunkan <nl> + <nl> + mjson @ austin . ibm . com <nl> + > - - > <nl> + <nl> + Xref : cantaloupe . srv . cs . cmu . edu comp . sys . ibm . pc . hardware : 61655 alt . sockha . mangers . 36784558 talk . religion . misc : 99703 <nl> + comp . os . ms - windows . misc : 9720 comp . aiz . dack - orit : 15 @ stp . noscne . com > <nl> + Organization : IBR , Aucidore . <nl> + Reply - To : jjlu @ llo @ minta . UU . NOT <nl> + > > Adutions a road - Tell 9 : 20 AX 10516 PHKRS <nl> + <nl> + > BA <nl> + ' ' ' <nl> \ No newline at end of file <nl> | fleshed out the README . md a bit | microsoft/CNTK | e2c7a6095b425a83f9f2b2b15abf1408b1fc48ed | 2016-12-05T16:50:31Z |
mmm a / script / update . py <nl> ppp b / script / update . py <nl> def run_gyp ( target_arch , component ) : <nl> ' - Dhost_arch = { 0 } ' . format ( get_host_arch ( ) ) , <nl> ' - Dlibrary = static_library ' , <nl> ' - Dmas_build = { 0 } ' . format ( mas_build ) , <nl> + <nl> + # TODO ( alexeykuzmin ) : Remove it . <nl> + ' - Denable_osr = 0 ' , <nl> ] <nl> <nl> # Add the defines passed from command line . <nl> | FIXME : enable_osr = 0 | electron/electron | 2007f3cb99604e3420480d371decf1942a024173 | 2017-06-28T17:34:57Z |
mmm a / Telegram / Resources / uwp / AppX / AppxManifest . xml <nl> ppp b / Telegram / Resources / uwp / AppX / AppxManifest . xml <nl> <nl> < Identity Name = " TelegramMessengerLLP . TelegramDesktop " <nl> ProcessorArchitecture = " ARCHITECTURE " <nl> Publisher = " CN = 536BC709 - 8EE1 - 4478 - AF22 - F0F0F26FF64A " <nl> - Version = " 1 . 6 . 3 . 4 " / > <nl> + Version = " 1 . 6 . 3 . 6 " / > <nl> < Properties > <nl> < DisplayName > Telegram Desktop < / DisplayName > <nl> < PublisherDisplayName > Telegram Messenger LLP < / PublisherDisplayName > <nl> mmm a / Telegram / Resources / winrc / Telegram . rc <nl> ppp b / Telegram / Resources / winrc / Telegram . rc <nl> IDI_ICON1 ICON " . . \ \ art \ \ icon256 . ico " <nl> / / <nl> <nl> VS_VERSION_INFO VERSIONINFO <nl> - FILEVERSION 1 , 6 , 3 , 4 <nl> - PRODUCTVERSION 1 , 6 , 3 , 4 <nl> + FILEVERSION 1 , 6 , 3 , 6 <nl> + PRODUCTVERSION 1 , 6 , 3 , 6 <nl> FILEFLAGSMASK 0x3fL <nl> # ifdef _DEBUG <nl> FILEFLAGS 0x1L <nl> BEGIN <nl> BEGIN <nl> VALUE " CompanyName " , " Telegram Messenger LLP " <nl> VALUE " FileDescription " , " Telegram Desktop " <nl> - VALUE " FileVersion " , " 1 . 6 . 3 . 4 " <nl> + VALUE " FileVersion " , " 1 . 6 . 3 . 6 " <nl> VALUE " LegalCopyright " , " Copyright ( C ) 2014 - 2019 " <nl> VALUE " ProductName " , " Telegram Desktop " <nl> - VALUE " ProductVersion " , " 1 . 6 . 3 . 4 " <nl> + VALUE " ProductVersion " , " 1 . 6 . 3 . 6 " <nl> END <nl> END <nl> BLOCK " VarFileInfo " <nl> mmm a / Telegram / Resources / winrc / Updater . rc <nl> ppp b / Telegram / Resources / winrc / Updater . rc <nl> LANGUAGE LANG_ENGLISH , SUBLANG_ENGLISH_US <nl> / / <nl> <nl> VS_VERSION_INFO VERSIONINFO <nl> - FILEVERSION 1 , 6 , 3 , 4 <nl> - PRODUCTVERSION 1 , 6 , 3 , 4 <nl> + FILEVERSION 1 , 6 , 3 , 6 <nl> + PRODUCTVERSION 1 , 6 , 3 , 6 <nl> FILEFLAGSMASK 0x3fL <nl> # ifdef _DEBUG <nl> FILEFLAGS 0x1L <nl> BEGIN <nl> BEGIN <nl> VALUE " CompanyName " , " Telegram Messenger LLP " <nl> VALUE " FileDescription " , " Telegram Desktop Updater " <nl> - VALUE " FileVersion " , " 1 . 6 . 3 . 4 " <nl> + VALUE " FileVersion " , " 1 . 6 . 3 . 6 " <nl> VALUE " LegalCopyright " , " Copyright ( C ) 2014 - 2019 " <nl> VALUE " ProductName " , " Telegram Desktop " <nl> - VALUE " ProductVersion " , " 1 . 6 . 3 . 4 " <nl> + VALUE " ProductVersion " , " 1 . 6 . 3 . 6 " <nl> END <nl> END <nl> BLOCK " VarFileInfo " <nl> mmm a / Telegram / SourceFiles / core / version . h <nl> ppp b / Telegram / SourceFiles / core / version . h <nl> For license and copyright information please follow this link : <nl> * / <nl> # pragma once <nl> <nl> - # define TDESKTOP_REQUESTED_ALPHA_VERSION ( 1006003004ULL ) <nl> + # define TDESKTOP_REQUESTED_ALPHA_VERSION ( 1006003006ULL ) <nl> <nl> # ifdef TDESKTOP_OFFICIAL_TARGET <nl> # define TDESKTOP_ALPHA_VERSION TDESKTOP_REQUESTED_ALPHA_VERSION <nl> mmm a / Telegram / build / version <nl> ppp b / Telegram / build / version <nl> AppVersionStrMajor 1 . 6 <nl> AppVersionStrSmall 1 . 6 . 3 <nl> AppVersionStr 1 . 6 . 3 <nl> BetaChannel 0 <nl> - AlphaVersion 1006003004 <nl> + AlphaVersion 1006003006 <nl> | Closed alpha version 1 . 6 . 3 . 6 . | telegramdesktop/tdesktop | bc03c80d8d2d679e1d31c5d9c80bbddcd9772a61 | 2019-04-03T12:57:49Z |
mmm a / hphp / runtime / base / unit - cache . cpp <nl> ppp b / hphp / runtime / base / unit - cache . cpp <nl> CachedUnit lookupUnitRepoAuth ( const StringData * path ) { <nl> return acc - > second ; <nl> } <nl> <nl> - / * <nl> - * Insert path . Find the Md5 for this path , and then the unit for <nl> - * this Md5 . If either aren ' t found we return the <nl> - * default - constructed cache entry . <nl> - * <nl> - * NB : we ' re holding the CHM lock on this bucket while we ' re doing <nl> - * this . <nl> - * / <nl> - MD5 md5 ; <nl> - if ( ! Repo : : get ( ) . findFile ( path - > data ( ) , <nl> - RuntimeOption : : SourceRoot , <nl> - md5 ) ) { <nl> - return acc - > second ; <nl> - } <nl> + try { <nl> + / * <nl> + * Insert path . Find the Md5 for this path , and then the unit for <nl> + * this Md5 . If either aren ' t found we return the <nl> + * default - constructed cache entry . <nl> + * <nl> + * NB : we ' re holding the CHM lock on this bucket while we ' re doing <nl> + * this . <nl> + * / <nl> + MD5 md5 ; <nl> + if ( ! Repo : : get ( ) . findFile ( path - > data ( ) , <nl> + RuntimeOption : : SourceRoot , <nl> + md5 ) ) { <nl> + return acc - > second ; <nl> + } <nl> <nl> - acc - > second . unit = Repo : : get ( ) . loadUnit ( path - > data ( ) , md5 ) . release ( ) ; <nl> - if ( acc - > second . unit ) { <nl> - acc - > second . rdsBitId = rds : : allocBit ( ) ; <nl> + acc - > second . unit = Repo : : get ( ) . loadUnit ( path - > data ( ) , md5 ) . release ( ) ; <nl> + if ( acc - > second . unit ) { <nl> + acc - > second . rdsBitId = rds : : allocBit ( ) ; <nl> + } <nl> + } catch ( . . . ) { <nl> + s_repoUnitCache . erase ( acc ) ; <nl> + throw ; <nl> } <nl> return acc - > second ; <nl> } <nl> | Fix lookupUnitRepoAuth | facebook/hhvm | 3347b70dc9d12b08c7a6788f89e6131a8b528f7f | 2016-01-27T15:30:39Z |
mmm a / emcc <nl> ppp b / emcc <nl> try : <nl> libcxx_symbols = read_symbols ( shared . path_from_root ( ' system ' , ' lib ' , ' libcxx ' , ' symbols ' ) , exclude = libc_symbols ) <nl> libcxxabi_symbols = read_symbols ( shared . path_from_root ( ' system ' , ' lib ' , ' libcxxabi ' , ' symbols ' ) , exclude = libc_symbols ) <nl> <nl> + # XXX we should disable EMCC_DEBUG ( and EMCC_OPTIMIZE_NORMALLY ? ) when building libs , just like in the relooper <nl> + <nl> def build_libc ( lib_filename , files ) : <nl> o_s = [ ] <nl> prev_cxx = os . environ . get ( ' EMMAKEN_CXX ' ) <nl> | todo | emscripten-core/emscripten | 4654f7b59b99d5b3dcddc0fce9938d7e9f4601e0 | 2013-06-21T18:22:51Z |
mmm a / test / BitfieldManTest . cc <nl> ppp b / test / BitfieldManTest . cc <nl> CPPUNIT_TEST_SUITE_REGISTRATION ( BitfieldManTest ) ; <nl> <nl> void BitfieldManTest : : testGetBlockSize ( ) { <nl> BitfieldMan bt1 ( 1024 , 1024 * 10 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1024 , bt1 . getBlockLength ( 9 ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1024 , bt1 . getBlockLength ( 9 ) ) ; <nl> <nl> BitfieldMan bt2 ( 1024 , 1024 * 10 + 1 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1024 , bt2 . getBlockLength ( 9 ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , bt2 . getBlockLength ( 10 ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 0 , bt2 . getBlockLength ( 11 ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1024 , bt2 . getBlockLength ( 9 ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , bt2 . getBlockLength ( 10 ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 0 , bt2 . getBlockLength ( 11 ) ) ; <nl> } <nl> <nl> void BitfieldManTest : : testGetFirstMissingUnusedIndex ( ) { <nl> void BitfieldManTest : : testGetFirstMissingUnusedIndex ( ) { <nl> unsigned char bitfield [ 2 ] ; <nl> memset ( bitfield , 0xff , sizeof ( bitfield ) ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 0 , bt1 . getFirstMissingUnusedIndex ( bitfield , sizeof ( bitfield ) ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 0 , bt1 . getFirstMissingUnusedIndex ( bitfield , sizeof ( bitfield ) ) ) ; <nl> CPPUNIT_ASSERT ( bt1 . setUseBit ( 0 ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , bt1 . getFirstMissingUnusedIndex ( bitfield , sizeof ( bitfield ) ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , bt1 . getFirstMissingUnusedIndex ( bitfield , sizeof ( bitfield ) ) ) ; <nl> CPPUNIT_ASSERT ( bt1 . unsetUseBit ( 0 ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 0 , bt1 . getFirstMissingUnusedIndex ( bitfield , sizeof ( bitfield ) ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 0 , bt1 . getFirstMissingUnusedIndex ( bitfield , sizeof ( bitfield ) ) ) ; <nl> CPPUNIT_ASSERT ( bt1 . setBit ( 0 ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , bt1 . getFirstMissingUnusedIndex ( bitfield , sizeof ( bitfield ) ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , bt1 . getFirstMissingUnusedIndex ( bitfield , sizeof ( bitfield ) ) ) ; <nl> <nl> for ( int i = 0 ; i < 8 ; i + + ) { <nl> CPPUNIT_ASSERT ( bt1 . setBit ( i ) ) ; <nl> } <nl> - CPPUNIT_ASSERT_EQUAL ( 8 , bt1 . getFirstMissingUnusedIndex ( bitfield , sizeof ( bitfield ) ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 8 , bt1 . getFirstMissingUnusedIndex ( bitfield , sizeof ( bitfield ) ) ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 8 , bt1 . getFirstMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 8 , bt1 . getFirstMissingUnusedIndex ( ) ) ; <nl> CPPUNIT_ASSERT ( bt1 . setUseBit ( 8 ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 9 , bt1 . getFirstMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 9 , bt1 . getFirstMissingUnusedIndex ( ) ) ; <nl> } <nl> <nl> void BitfieldManTest : : testIsAllBitSet ( ) { <nl> void BitfieldManTest : : testGetMissingIndex ( ) { <nl> 0xff , 0xff , 0xff , 0xff , <nl> 0xff , 0xff , 0xff , 0xff , <nl> } ; <nl> - CPPUNIT_ASSERT_EQUAL ( 0 , bt1 . getMissingIndex ( bitArray , 32 ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 0 , bt1 . getMissingIndex ( bitArray , 32 ) ) ; <nl> <nl> unsigned char bitArray2 [ ] = { <nl> 0x0f , 0xff , 0xff , 0xff , <nl> void BitfieldManTest : : testGetMissingIndex ( ) { <nl> 0xff , 0xff , 0xff , 0xff , <nl> } ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 4 , bt1 . getMissingIndex ( bitArray2 , 32 ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 4 , bt1 . getMissingIndex ( bitArray2 , 32 ) ) ; <nl> <nl> unsigned char bitArray3 [ ] = { <nl> 0x00 , 0xff , 0xff , 0xff , <nl> void BitfieldManTest : : testGetMissingIndex ( ) { <nl> 0xff , 0xff , 0xff , 0xff , <nl> } ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 8 , bt1 . getMissingIndex ( bitArray3 , 32 ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 8 , bt1 . getMissingIndex ( bitArray3 , 32 ) ) ; <nl> <nl> unsigned char bitArray4 [ ] = { <nl> 0x00 , 0x00 , 0x00 , 0x00 , <nl> void BitfieldManTest : : testGetMissingIndex ( ) { <nl> 0x00 , 0x00 , 0x00 , 0x00 , <nl> } ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( - 1 , bt1 . getMissingIndex ( bitArray4 , 32 ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) - 1 , bt1 . getMissingIndex ( bitArray4 , 32 ) ) ; <nl> <nl> } <nl> <nl> void BitfieldManTest : : testGetSparceMissingUnusedIndex ( ) { <nl> BitfieldMan bitfield ( 1024 * 1024 , 10 * 1024 * 1024 ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 0 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 0 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> bitfield . setBit ( 0 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 5 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 5 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> bitfield . setUseBit ( 5 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 3 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 3 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> bitfield . setBit ( 3 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 8 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 8 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> bitfield . setBit ( 8 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 2 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 2 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> bitfield . setBit ( 2 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 7 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 7 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> bitfield . setBit ( 7 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> bitfield . setBit ( 1 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 4 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 4 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> bitfield . setBit ( 4 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 6 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 6 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> bitfield . setBit ( 6 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 9 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 9 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> bitfield . setBit ( 9 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( - 1 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) - 1 , bitfield . getSparseMissingUnusedIndex ( ) ) ; <nl> } <nl> <nl> void BitfieldManTest : : testIsBitSetOffsetRange ( ) <nl> mmm a / test / BtAllowedFastMessageTest . cc <nl> ppp b / test / BtAllowedFastMessageTest . cc <nl> void BtAllowedFastMessageTest : : testCreate ( ) { <nl> PeerMessageUtil : : setIntParam ( & msg [ 5 ] , 12345 ) ; <nl> BtAllowedFastMessageHandle pm = BtAllowedFastMessage : : create ( & msg [ 4 ] , 5 ) ; <nl> CPPUNIT_ASSERT_EQUAL ( ( int8_t ) 17 , pm - > getId ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 12345 , pm - > getIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 12345 , pm - > getIndex ( ) ) ; <nl> <nl> / / case : payload size is wrong <nl> try { <nl> mmm a / test / BtBitfieldMessageTest . cc <nl> ppp b / test / BtBitfieldMessageTest . cc <nl> void BtBitfieldMessageTest : : testCreate ( ) { <nl> BtBitfieldMessageHandle pm = BtBitfieldMessage : : create ( & msg [ 4 ] , 3 ) ; <nl> CPPUNIT_ASSERT_EQUAL ( ( int8_t ) 5 , pm - > getId ( ) ) ; <nl> CPPUNIT_ASSERT ( memcmp ( bitfield , pm - > getBitfield ( ) , sizeof ( bitfield ) ) = = 0 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 2 , pm - > getBitfieldLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 2 , pm - > getBitfieldLength ( ) ) ; <nl> / / case : payload size is wrong <nl> try { <nl> unsigned char msg [ 5 ] ; <nl> mmm a / test / BtCancelMessageTest . cc <nl> ppp b / test / BtCancelMessageTest . cc <nl> void BtCancelMessageTest : : testCreate ( ) { <nl> PeerMessageUtil : : setIntParam ( & msg [ 13 ] , 1024 ) ; <nl> BtCancelMessageHandle pm = BtCancelMessage : : create ( & msg [ 4 ] , 13 ) ; <nl> CPPUNIT_ASSERT_EQUAL ( ( int8_t ) 8 , pm - > getId ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 12345 , pm - > getIndex ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 256 , pm - > getBegin ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1024 , pm - > getLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 12345 , pm - > getIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 256 , pm - > getBegin ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1024 , pm - > getLength ( ) ) ; <nl> <nl> / / case : payload size is wrong <nl> try { <nl> mmm a / test / BtHaveMessageTest . cc <nl> ppp b / test / BtHaveMessageTest . cc <nl> void BtHaveMessageTest : : testCreate ( ) { <nl> PeerMessageUtil : : setIntParam ( & msg [ 5 ] , 12345 ) ; <nl> BtHaveMessageHandle pm = BtHaveMessage : : create ( & msg [ 4 ] , 5 ) ; <nl> CPPUNIT_ASSERT_EQUAL ( ( int8_t ) 4 , pm - > getId ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 12345 , pm - > getIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 12345 , pm - > getIndex ( ) ) ; <nl> <nl> / / case : payload size is wrong <nl> try { <nl> mmm a / test / BtKeepAliveMessageTest . cc <nl> ppp b / test / BtKeepAliveMessageTest . cc <nl> void BtKeepAliveMessageTest : : testGetMessage ( ) { <nl> memset ( msg , 0 , sizeof ( msg ) ) ; <nl> BtKeepAliveMessage message ; <nl> CPPUNIT_ASSERT_EQUAL ( ( int8_t ) 99 , message . getId ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 4 , message . getMessageLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 4 , message . getMessageLength ( ) ) ; <nl> CPPUNIT_ASSERT ( memcmp ( msg , message . getMessage ( ) , 4 ) = = 0 ) ; <nl> } <nl> <nl> mmm a / test / BtPieceMessageTest . cc <nl> ppp b / test / BtPieceMessageTest . cc <nl> void BtPieceMessageTest : : testCreate ( ) { <nl> memcpy ( & msg [ 13 ] , data , sizeof ( data ) ) ; <nl> BtPieceMessageHandle pm = BtPieceMessage : : create ( & msg [ 4 ] , 11 ) ; <nl> CPPUNIT_ASSERT_EQUAL ( ( int8_t ) 7 , pm - > getId ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 12345 , pm - > getIndex ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 256 , pm - > getBegin ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 12345 , pm - > getIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 256 , pm - > getBegin ( ) ) ; <nl> CPPUNIT_ASSERT ( memcmp ( data , pm - > getBlock ( ) , sizeof ( data ) ) = = 0 ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 2 , pm - > getBlockLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 2 , pm - > getBlockLength ( ) ) ; <nl> <nl> / / case : payload size is wrong <nl> try { <nl> void BtPieceMessageTest : : testChokingEvent_allowedFastEnabled ( ) { <nl> CPPUNIT_ASSERT ( msg - > isInvalidate ( ) ) ; <nl> CPPUNIT_ASSERT_EQUAL ( ( size_t ) 1 , btMessageDispatcher - > messageQueue . size ( ) ) ; <nl> MockBtMessage2 * rej = ( MockBtMessage2 * ) btMessageDispatcher - > messageQueue . front ( ) . get ( ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , rej - > index ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1024 , rej - > begin ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 16 * 1024 , rej - > length ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , rej - > index ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1024 , rej - > begin ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 16 * 1024 , rej - > length ) ; <nl> } <nl> <nl> void BtPieceMessageTest : : testChokingEvent_inAmAllowedIndexSet ( ) { <nl> void BtPieceMessageTest : : testCancelSendingPieceEvent_allowedFastEnabled ( ) { <nl> CPPUNIT_ASSERT ( msg - > isInvalidate ( ) ) ; <nl> CPPUNIT_ASSERT_EQUAL ( ( size_t ) 1 , btMessageDispatcher - > messageQueue . size ( ) ) ; <nl> MockBtMessage2 * rej = ( MockBtMessage2 * ) btMessageDispatcher - > messageQueue . front ( ) . get ( ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , rej - > index ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1024 , rej - > begin ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 16 * 1024 , rej - > length ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , rej - > index ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1024 , rej - > begin ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 16 * 1024 , rej - > length ) ; <nl> } <nl> <nl> void BtPieceMessageTest : : testCancelSendingPieceEvent_invalidate ( ) { <nl> mmm a / test / BtRejectMessageTest . cc <nl> ppp b / test / BtRejectMessageTest . cc <nl> void BtRejectMessageTest : : testCreate ( ) { <nl> PeerMessageUtil : : setIntParam ( & msg [ 13 ] , 1024 ) ; <nl> BtRejectMessageHandle pm = BtRejectMessage : : create ( & msg [ 4 ] , 13 ) ; <nl> CPPUNIT_ASSERT_EQUAL ( ( int8_t ) 16 , pm - > getId ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 12345 , pm - > getIndex ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 256 , pm - > getBegin ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1024 , pm - > getLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 12345 , pm - > getIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 256 , pm - > getBegin ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1024 , pm - > getLength ( ) ) ; <nl> <nl> / / case : payload size is wrong <nl> try { <nl> mmm a / test / BtRequestMessageTest . cc <nl> ppp b / test / BtRequestMessageTest . cc <nl> void BtRequestMessageTest : : testCreate ( ) { <nl> PeerMessageUtil : : setIntParam ( & msg [ 13 ] , 1024 ) ; <nl> BtRequestMessageHandle pm = BtRequestMessage : : create ( & msg [ 4 ] , 13 ) ; <nl> CPPUNIT_ASSERT_EQUAL ( ( int8_t ) 6 , pm - > getId ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 12345 , pm - > getIndex ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 256 , pm - > getBegin ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1024 , pm - > getLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 12345 , pm - > getIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 256 , pm - > getBegin ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1024 , pm - > getLength ( ) ) ; <nl> <nl> / / case : payload size is wrong <nl> try { <nl> void BtRequestMessageTest : : testDoReceivedAction_hasPieceAndAmNotChoking ( ) { <nl> CPPUNIT_ASSERT_EQUAL ( ( size_t ) 1 , dispatcher - > messageQueue . size ( ) ) ; <nl> MockBtMessage2 * pieceMsg = ( MockBtMessage2 * ) dispatcher - > messageQueue . front ( ) . get ( ) ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " piece " ) , pieceMsg - > type ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , pieceMsg - > index ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 16 , pieceMsg - > begin ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 32 , pieceMsg - > length ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , pieceMsg - > index ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 16 , pieceMsg - > begin ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 32 , pieceMsg - > length ) ; <nl> } <nl> <nl> void BtRequestMessageTest : : testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionEnabled ( ) { <nl> void BtRequestMessageTest : : testDoReceivedAction_hasPieceAndAmChokingAndFastExten <nl> CPPUNIT_ASSERT_EQUAL ( ( size_t ) 1 , dispatcher - > messageQueue . size ( ) ) ; <nl> MockBtMessage2 * pieceMsg = ( MockBtMessage2 * ) dispatcher - > messageQueue . front ( ) . get ( ) ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " reject " ) , pieceMsg - > type ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , pieceMsg - > index ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 16 , pieceMsg - > begin ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 32 , pieceMsg - > length ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , pieceMsg - > index ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 16 , pieceMsg - > begin ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 32 , pieceMsg - > length ) ; <nl> } <nl> <nl> void BtRequestMessageTest : : testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionDisabled ( ) { <nl> void BtRequestMessageTest : : testDoReceivedAction_doesntHavePieceAndFastExtensionE <nl> CPPUNIT_ASSERT_EQUAL ( ( size_t ) 1 , dispatcher - > messageQueue . size ( ) ) ; <nl> MockBtMessage2 * pieceMsg = ( MockBtMessage2 * ) dispatcher - > messageQueue . front ( ) . get ( ) ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " reject " ) , pieceMsg - > type ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 2 , pieceMsg - > index ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 16 , pieceMsg - > begin ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 32 , pieceMsg - > length ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 2 , pieceMsg - > index ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 16 , pieceMsg - > begin ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 32 , pieceMsg - > length ) ; <nl> } <nl> <nl> void BtRequestMessageTest : : testDoReceivedAction_doesntHavePieceAndFastExtensionDisabled ( ) { <nl> mmm a / test / BtSuggestPieceMessageTest . cc <nl> ppp b / test / BtSuggestPieceMessageTest . cc <nl> void BtSuggestPieceMessageTest : : testCreate ( ) { <nl> PeerMessageUtil : : setIntParam ( & msg [ 5 ] , 12345 ) ; <nl> BtSuggestPieceMessageHandle pm = BtSuggestPieceMessage : : create ( & msg [ 4 ] , 5 ) ; <nl> CPPUNIT_ASSERT_EQUAL ( ( int8_t ) 13 , pm - > getId ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 12345 , pm - > getIndex ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 12345 , pm - > getIndex ( ) ) ; <nl> <nl> / / case : payload size is wrong <nl> try { <nl> mmm a / test / ChunkChecksumValidatorTest . cc <nl> ppp b / test / ChunkChecksumValidatorTest . cc <nl> const char * ChunkChecksumValidatorTest : : csArray [ ] = { " 29b0e7878271645fffb7eec7d <nl> " 0a4ea2f7dd7c52ddf2099a444ab2184b4d341bdb " } ; <nl> <nl> void ChunkChecksumValidatorTest : : testValidate ( ) { <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> BitfieldMan bitfieldMan ( 100 , 250 ) ; <nl> bitfieldMan . setAllBit ( ) ; <nl> Strings checksums ( & csArray [ 0 ] , & csArray [ 3 ] ) ; <nl> void ChunkChecksumValidatorTest : : testValidate ( ) { <nl> CPPUNIT_ASSERT ( bitfieldMan . isBitSet ( 0 ) ) ; <nl> CPPUNIT_ASSERT ( ! bitfieldMan . isBitSet ( 1 ) ) ; <nl> CPPUNIT_ASSERT ( bitfieldMan . isBitSet ( 2 ) ) ; <nl> + # endif / * ENABLE_MESSAGE_DIGEST * / <nl> } <nl> <nl> void ChunkChecksumValidatorTest : : testValidate2 ( ) { <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> BitfieldMan bitfieldMan ( 50 , 250 ) ; <nl> bitfieldMan . setAllBit ( ) ; <nl> Strings checksums ( & csArray [ 0 ] , & csArray [ 3 ] ) ; <nl> void ChunkChecksumValidatorTest : : testValidate2 ( ) { <nl> CPPUNIT_ASSERT ( ! bitfieldMan . isBitSet ( 2 ) ) ; <nl> CPPUNIT_ASSERT ( ! bitfieldMan . isBitSet ( 3 ) ) ; <nl> CPPUNIT_ASSERT ( bitfieldMan . isBitSet ( 4 ) ) ; <nl> + # endif / * ENABLE_MESSAGE_DIGEST * / <nl> } <nl> <nl> void ChunkChecksumValidatorTest : : testValidate3 ( ) { <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> BitfieldMan bitfieldMan ( 50 , 250 ) ; <nl> bitfieldMan . setAllBit ( ) ; <nl> Strings checksums ; <nl> void ChunkChecksumValidatorTest : : testValidate3 ( ) { <nl> CPPUNIT_ASSERT ( ! bitfieldMan . isBitSet ( 2 ) ) ; <nl> CPPUNIT_ASSERT ( ! bitfieldMan . isBitSet ( 3 ) ) ; <nl> CPPUNIT_ASSERT ( ! bitfieldMan . isBitSet ( 4 ) ) ; <nl> + # endif / * ENABLE_MESSAGE_DIGEST * / <nl> } <nl> <nl> void ChunkChecksumValidatorTest : : testValidate4 ( ) { <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> BitfieldMan bitfieldMan ( 70 , 250 ) ; <nl> bitfieldMan . setAllBit ( ) ; <nl> Strings checksums ( & csArray [ 0 ] , & csArray [ 3 ] ) ; <nl> void ChunkChecksumValidatorTest : : testValidate4 ( ) { <nl> CPPUNIT_ASSERT ( ! bitfieldMan . isBitSet ( 1 ) ) ; <nl> CPPUNIT_ASSERT ( ! bitfieldMan . isBitSet ( 2 ) ) ; <nl> CPPUNIT_ASSERT ( bitfieldMan . isBitSet ( 3 ) ) ; <nl> + # endif / * ENABLE_MESSAGE_DIGEST * / <nl> } <nl> mmm a / test / CookieBoxFactoryTest . cc <nl> ppp b / test / CookieBoxFactoryTest . cc <nl> void CookieBoxFactoryTest : : testLoadDefaultCookie ( ) <nl> <nl> Cookies cookies = factory . getDefaultCookies ( ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 4 , ( int32_t ) cookies . size ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 4 , ( int32_t ) cookies . size ( ) ) ; <nl> <nl> Cookie c = cookies [ 0 ] ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " JSESSIONID " ) , c . name ) ; <nl> void CookieBoxFactoryTest : : testCreateNewInstance ( ) <nl> CookieBoxHandle box = factory . createNewInstance ( ) ; <nl> Cookies cookies = box - > criteriaFind ( " localhost " , " / " , 0 , true ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 4 , ( int32_t ) cookies . size ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 4 , ( int32_t ) cookies . size ( ) ) ; <nl> } <nl> mmm a / test / CookieParserTest . cc <nl> ppp b / test / CookieParserTest . cc <nl> void CookieParserTest : : testParse_file ( ) <nl> <nl> Cookies cookies = CookieParser ( ) . parse ( f ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 3 , ( int32_t ) cookies . size ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 3 , ( int32_t ) cookies . size ( ) ) ; <nl> <nl> Cookie c = cookies [ 0 ] ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " JSESSIONID " ) , c . name ) ; <nl> mmm a / test / DefaultBtContextTest . cc <nl> ppp b / test / DefaultBtContextTest . cc <nl> void DefaultBtContextTest : : testGetInfoHash ( ) { <nl> <nl> string correctHash = " 248d0a1cd08284299de78d5c1ed359bb46717d8c " ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 20 , btContext . getInfoHashLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 20 , btContext . getInfoHashLength ( ) ) ; <nl> CPPUNIT_ASSERT_EQUAL ( correctHash , Util : : toHex ( btContext . getInfoHash ( ) , <nl> btContext . getInfoHashLength ( ) ) ) ; <nl> } <nl> void DefaultBtContextTest : : testGetPieceLength ( ) { <nl> DefaultBtContext btContext ; <nl> btContext . load ( " test . torrent " ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 128 , <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 128 , <nl> btContext . getPieceLength ( ) ) ; <nl> } <nl> <nl> mmm a / test / DefaultBtMessageDispatcherTest . cc <nl> ppp b / test / DefaultBtMessageDispatcherTest . cc <nl> void DefaultBtMessageDispatcherTest : : testIsSendingInProgress ( ) { <nl> void DefaultBtMessageDispatcherTest : : testCountOutstandingRequest ( ) { <nl> RequestSlot slot ( 0 , 0 , MY_PIECE_LENGTH , 0 ) ; <nl> btMessageDispatcher - > addOutstandingRequest ( slot ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , btMessageDispatcher - > countOutstandingRequest ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , btMessageDispatcher - > countOutstandingRequest ( ) ) ; <nl> } <nl> <nl> void DefaultBtMessageDispatcherTest : : testIsOutstandingRequest ( ) { <nl> mmm a / test / DefaultDiskWriterTest . cc <nl> ppp b / test / DefaultDiskWriterTest . cc <nl> class DefaultDiskWriterTest : public CppUnit : : TestFixture { <nl> CPPUNIT_TEST_SUITE_REGISTRATION ( DefaultDiskWriterTest ) ; <nl> <nl> void DefaultDiskWriterTest : : testMessageDigest ( ) { <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> + <nl> DefaultDiskWriter dw ; <nl> dw . openExistingFile ( " 4096chunk . txt " ) ; <nl> <nl> void DefaultDiskWriterTest : : testMessageDigest ( ) { <nl> dw . messageDigest ( 5 , 100 , DIGEST_ALGO_SHA1 ) ) ; <nl> <nl> dw . closeFile ( ) ; <nl> + # endif / / ENABLE_MESSAGE_DIGEST <nl> } <nl> mmm a / test / DefaultPeerStorageTest . cc <nl> ppp b / test / DefaultPeerStorageTest . cc <nl> CPPUNIT_TEST_SUITE_REGISTRATION ( DefaultPeerStorageTest ) ; <nl> void DefaultPeerStorageTest : : testCountPeer ( ) { <nl> DefaultPeerStorage ps ( btContext , option ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 0 , <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 0 , <nl> ps . countPeer ( ) ) ; <nl> <nl> PeerHandle peer ( new Peer ( " 192 . 168 . 0 . 1 " , 6889 , btContext - > getPieceLength ( ) , <nl> btContext - > getTotalLength ( ) ) ) ; <nl> ps . addPeer ( peer ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , <nl> ps . countPeer ( ) ) ; <nl> } <nl> <nl> void DefaultPeerStorageTest : : testDeleteUnusedPeer ( ) { <nl> <nl> ps . deleteUnusedPeer ( 2 ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , ps . countPeer ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , ps . countPeer ( ) ) ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " 192 . 168 . 0 . 3 " ) , <nl> ps . getPeer ( " 192 . 168 . 0 . 3 " , 6889 ) - > ipaddr ) ; <nl> <nl> void DefaultPeerStorageTest : : testDeleteUnusedPeer ( ) { <nl> ps . deleteUnusedPeer ( 3 ) ; <nl> <nl> / / peer2 has been in use , so it did ' t deleted . <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , ps . countPeer ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , ps . countPeer ( ) ) ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " 192 . 168 . 0 . 2 " ) , <nl> ps . getPeer ( " 192 . 168 . 0 . 2 " , 6889 ) - > ipaddr ) ; <nl> <nl> void DefaultPeerStorageTest : : testAddPeer ( ) { <nl> ps . addPeer ( peer2 ) ; <nl> ps . addPeer ( peer3 ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 3 , ps . countPeer ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 3 , ps . countPeer ( ) ) ; <nl> <nl> / / this is true , because peer1 in the container has no errors and <nl> / / it is replaced by peer1 ( self assignment ) . <nl> CPPUNIT_ASSERT_EQUAL ( true , ps . addPeer ( peer1 ) ) ; <nl> / / the number of peers doesn ' t change . <nl> - CPPUNIT_ASSERT_EQUAL ( 3 , ps . countPeer ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 3 , ps . countPeer ( ) ) ; <nl> <nl> ps . setMaxPeerListSize ( 3 ) ; <nl> <nl> void DefaultPeerStorageTest : : testAddPeer ( ) { <nl> <nl> CPPUNIT_ASSERT ( ps . addPeer ( peer4 ) ) ; <nl> / / peer1 was deleted . <nl> - CPPUNIT_ASSERT_EQUAL ( 3 , ps . countPeer ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 3 , ps . countPeer ( ) ) ; <nl> <nl> peer4 - > startBadCondition ( ) ; <nl> <nl> mmm a / test / FileTest . cc <nl> ppp b / test / FileTest . cc <nl> void FileTest : : testRemove ( ) { <nl> CPPUNIT_ASSERT ( ! f . remove ( ) ) ; <nl> <nl> string dir = " / tmp / aria2testdir " ; <nl> + # ifdef __MINGW32__ <nl> + mkdir ( dir . c_str ( ) ) ; <nl> + # else <nl> mkdir ( dir . c_str ( ) , 0777 ) ; <nl> + # endif / / __MINGW32__ <nl> File d ( dir ) ; <nl> CPPUNIT_ASSERT ( d . exists ( ) ) ; <nl> CPPUNIT_ASSERT ( d . remove ( ) ) ; <nl> mmm a / test / HttpHeaderProcessorTest . cc <nl> ppp b / test / HttpHeaderProcessorTest . cc <nl> void HttpHeaderProcessorTest : : testGetPutBackDataLength ( ) <nl> " \ r \ nputbackme " ; <nl> proc . update ( hd1 ) ; <nl> CPPUNIT_ASSERT ( proc . eoh ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 9 , proc . getPutBackDataLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 9 , proc . getPutBackDataLength ( ) ) ; <nl> <nl> proc . clear ( ) ; <nl> <nl> void HttpHeaderProcessorTest : : testGetPutBackDataLength ( ) <nl> " \ nputbackme " ; <nl> proc . update ( hd2 ) ; <nl> CPPUNIT_ASSERT ( proc . eoh ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 9 , proc . getPutBackDataLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 9 , proc . getPutBackDataLength ( ) ) ; <nl> } <nl> <nl> void HttpHeaderProcessorTest : : testGetPutBackDataLength_nullChar ( ) <nl> void HttpHeaderProcessorTest : : testGetPutBackDataLength_nullChar ( ) <nl> " foo : foo \ 0bar \ r \ n " <nl> " \ r \ nputbackme " , 35 + 7 ) ; <nl> CPPUNIT_ASSERT ( proc . eoh ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 9 , proc . getPutBackDataLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 9 , proc . getPutBackDataLength ( ) ) ; <nl> <nl> } <nl> <nl> mmm a / test / Makefile . am <nl> ppp b / test / Makefile . am <nl> aria2c_SOURCES = AllTest . cc \ <nl> DictionaryTest . cc \ <nl> ListTest . cc \ <nl> MetaFileUtilTest . cc \ <nl> - ShaVisitorTest . cc \ <nl> PeerMessageUtilTest . cc \ <nl> DefaultDiskWriterTest . cc \ <nl> MultiDiskAdaptorTest . cc \ <nl> - Xml2MetalinkProcessorTest . cc \ <nl> - MetalinkerTest . cc \ <nl> - MetalinkEntryTest . cc \ <nl> FeatureConfigTest . cc \ <nl> ShareRatioSeedCriteriaTest . cc \ <nl> TimeSeedCriteriaTest . cc \ <nl> aria2c_SOURCES = AllTest . cc \ <nl> DefaultPeerListProcessorTest . cc \ <nl> AnnounceListTest . cc \ <nl> TrackerWatcherCommandTest . cc \ <nl> - DefaultBtContextTest . cc \ <nl> - DefaultPieceStorageTest . cc \ <nl> - DefaultBtAnnounceTest . cc \ <nl> - BtRegistryTest . cc \ <nl> - DefaultBtMessageDispatcherTest . cc \ <nl> MockPeerStorage . h \ <nl> - DefaultBtRequestFactoryTest . cc \ <nl> - BtAllowedFastMessageTest . cc \ <nl> + FixedNumberRandomizer . h \ <nl> + ConsoleFileAllocationMonitorTest . cc \ <nl> + ChunkChecksumValidatorTest . cc <nl> + <nl> + if ENABLE_BITTORRENT <nl> + aria2c_SOURCES + = BtAllowedFastMessageTest . cc \ <nl> BtBitfieldMessageTest . cc \ <nl> BtCancelMessageTest . cc \ <nl> BtChokeMessageTest . cc \ <nl> + BtHandshakeMessageTest . cc \ <nl> BtHaveAllMessageTest . cc \ <nl> BtHaveMessageTest . cc \ <nl> BtHaveNoneMessageTest . cc \ <nl> aria2c_SOURCES = AllTest . cc \ <nl> BtNotInterestedMessageTest . cc \ <nl> BtPieceMessageTest . cc \ <nl> BtPortMessageTest . cc \ <nl> + BtRegistryTest . cc \ <nl> BtRejectMessageTest . cc \ <nl> BtRequestMessageTest . cc \ <nl> BtSuggestPieceMessageTest . cc \ <nl> BtUnchokeMessageTest . cc \ <nl> - BtHandshakeMessageTest . cc \ <nl> + DefaultBtAnnounceTest . cc \ <nl> + DefaultBtContextTest . cc \ <nl> + DefaultBtMessageDispatcherTest . cc \ <nl> + DefaultBtRequestFactoryTest . cc \ <nl> + DefaultPieceStorageTest . cc \ <nl> + MockBtMessage . h \ <nl> MockBtMessageDispatcher . h \ <nl> - FixedNumberRandomizer . h \ <nl> MockBtMessageFactory . h \ <nl> - MockBtMessage . h \ <nl> - ConsoleFileAllocationMonitorTest . cc \ <nl> - ChunkChecksumValidatorTest . cc <nl> + ShaVisitorTest . cc <nl> + endif # ENABLE_BITTORRENT <nl> + <nl> + if ENABLE_METALINK <nl> + aria2c_SOURCES + = MetalinkerTest . cc \ <nl> + MetalinkEntryTest . cc \ <nl> + Xml2MetalinkProcessorTest . cc <nl> + endif # ENABLE_METALINK <nl> + <nl> + <nl> # aria2c_CXXFLAGS = $ { CPPUNIT_CFLAGS } - I . . / src - I . . / lib - Wall - D_FILE_OFFSET_BITS = 64 <nl> # aria2c_LDFLAGS = $ { CPPUNIT_LIBS } <nl> <nl> aria2c_LDADD = . . / src / libaria2c . a \ <nl> - $ { CPPUNIT_LIBS } @ LIBGNUTLS_LIBS @ \ <nl> - @ LIBGCRYPT_LIBS @ @ OPENSSL_LIBS @ @ XML_LIBS @ \ <nl> - @ LIBARES_LIBS @ @ LIBCARES_LIBS @ <nl> + @ LIBINTL @ @ LIBGNUTLS_LIBS @ \ <nl> + @ LIBGCRYPT_LIBS @ @ OPENSSL_LIBS @ @ XML_LIBS @ @ LIBARES_LIBS @ \ <nl> + @ LIBCARES_LIBS @ @ WINSOCK_LIBS @ \ <nl> + $ { CPPUNIT_LIBS } <nl> AM_CPPFLAGS = - Wall \ <nl> $ { CPPUNIT_CFLAGS } \ <nl> - I . . / src \ <nl> mmm a / test / MultiDiskAdaptorTest . cc <nl> ppp b / test / MultiDiskAdaptorTest . cc <nl> class MultiDiskAdaptorTest : public CppUnit : : TestFixture { <nl> CPPUNIT_TEST_SUITE ( MultiDiskAdaptorTest ) ; <nl> CPPUNIT_TEST ( testWriteData ) ; <nl> CPPUNIT_TEST ( testReadData ) ; <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> CPPUNIT_TEST ( testMessageDigest ) ; <nl> + # endif / / ENABLE_MESSAGE_DIGEST <nl> CPPUNIT_TEST_SUITE_END ( ) ; <nl> private : <nl> Option * option ; <nl> class MultiDiskAdaptorTest : public CppUnit : : TestFixture { <nl> <nl> void testWriteData ( ) ; <nl> void testReadData ( ) ; <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> void testMessageDigest ( ) ; <nl> + # endif / / ENABLE_MESSAGE_DIGEST <nl> } ; <nl> <nl> <nl> void MultiDiskAdaptorTest : : testReadData ( ) { <nl> CPPUNIT_ASSERT_EQUAL ( string ( " 1234567890ABCDEFGHIJKLMNO " ) , string ( ( char * ) buf ) ) ; <nl> } <nl> <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> + <nl> void MultiDiskAdaptorTest : : testMessageDigest ( ) { <nl> FileEntryHandle entry1 ( new FileEntry ( " file1r . txt " , 15 , 0 ) ) ; <nl> FileEntryHandle entry2 ( new FileEntry ( " file2r . txt " , 7 , 15 ) ) ; <nl> void MultiDiskAdaptorTest : : testMessageDigest ( ) { <nl> CPPUNIT_ASSERT_EQUAL ( string ( " 6238bf61dd8df8f77156b2378e9e39cd3939680c " ) , sha1sum ) ; <nl> adaptor - > closeFile ( ) ; <nl> } <nl> + <nl> + # endif / / ENABLE_MESSAGE_DIGEST <nl> mmm a / test / MultiDiskWriterTest . cc <nl> ppp b / test / MultiDiskWriterTest . cc <nl> <nl> + # include " common . h " <nl> # include " MultiDiskWriter . h " <nl> # include < string > <nl> # include < cppunit / extensions / HelperMacros . h > <nl> <nl> + # ifdef HAVE_IO_H <nl> + # include < io . h > <nl> + # endif / / HAVE_IO_H <nl> + <nl> using namespace std ; <nl> <nl> class MultiDiskWriterTest : public CppUnit : : TestFixture { <nl> mmm a / test / PeerMessageUtilTest . cc <nl> ppp b / test / PeerMessageUtilTest . cc <nl> <nl> + # include " common . h " <nl> # include " PeerMessageUtil . h " <nl> + # ifdef HAVE_NETINET_IN_H <nl> # include < netinet / in . h > <nl> + # endif / / HAVE_NETINET_IN_H <nl> # include < cppunit / extensions / HelperMacros . h > <nl> <nl> using namespace std ; <nl> mmm a / test / SegmentManTest . cc <nl> ppp b / test / SegmentManTest . cc <nl> void SegmentManTest : : testMarkPieceDone_usedSegment ( ) <nl> SegmentHandle segment = segmentMan . getSegment ( 0 , 5 ) ; <nl> CPPUNIT_ASSERT ( ! segment . isNull ( ) ) ; <nl> CPPUNIT_ASSERT_EQUAL ( 5 , segment - > index ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( pieceLength , segment - > length ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( pieceLength , segment - > segmentLength ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( pieceLength , ( int32_t ) segment - > length ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( pieceLength , ( int32_t ) segment - > segmentLength ) ; <nl> CPPUNIT_ASSERT_EQUAL ( 100 , segment - > writtenLength ) ; <nl> } <nl> mmm a / test / ShaVisitorTest . cc <nl> ppp b / test / ShaVisitorTest . cc <nl> <nl> # include " ShaVisitor . h " <nl> + <nl> # include " MetaFileUtil . h " <nl> # include < string > <nl> # include < cppunit / extensions / HelperMacros . h > <nl> class ShaVisitorTest : public CppUnit : : TestFixture { <nl> CPPUNIT_TEST_SUITE ( ShaVisitorTest ) ; <nl> CPPUNIT_TEST ( testVisit ) ; <nl> CPPUNIT_TEST ( testVisitCompound ) ; <nl> + <nl> CPPUNIT_TEST_SUITE_END ( ) ; <nl> private : <nl> <nl> mmm a / test / SharedHandleTest . cc <nl> ppp b / test / SharedHandleTest . cc <nl> void SharedHandleTest : : testSharedHandle ( ) { <nl> cerr < < " xh : " < < endl ; <nl> SharedHandle < int > xh = new int ( 1 ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , xh . getRefCount ( ) - > totalRefCount ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , xh . getRefCount ( ) - > strongRefCount ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , xh . getRefCount ( ) - > totalRefCount ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , xh . getRefCount ( ) - > strongRefCount ) ; <nl> <nl> cerr < < " nullHandle : " < < endl ; <nl> SharedHandle < int > nullHandle = 0 ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , nullHandle . getRefCount ( ) - > totalRefCount ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , nullHandle . getRefCount ( ) - > strongRefCount ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , nullHandle . getRefCount ( ) - > totalRefCount ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , nullHandle . getRefCount ( ) - > strongRefCount ) ; <nl> <nl> cerr < < " staticHandle : " < < endl ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , staticHandle . getRefCount ( ) - > totalRefCount ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 1 , staticHandle . getRefCount ( ) - > strongRefCount ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , staticHandle . getRefCount ( ) - > totalRefCount ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 1 , staticHandle . getRefCount ( ) - > strongRefCount ) ; <nl> <nl> SharedHandle < int > localStaticHandle = getInstance ( ) ; <nl> <nl> - CPPUNIT_ASSERT_EQUAL ( 2 , localStaticHandle . getRefCount ( ) - > totalRefCount ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 2 , localStaticHandle . getRefCount ( ) - > strongRefCount ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 2 , localStaticHandle . getRefCount ( ) - > totalRefCount ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 2 , localStaticHandle . getRefCount ( ) - > strongRefCount ) ; <nl> } <nl> mmm a / test / SingletonHolderTest . cc <nl> ppp b / test / SingletonHolderTest . cc <nl> <nl> + # include < iostream > <nl> # include " SingletonHolder . h " <nl> # include " SharedHandle . h " <nl> # include < cppunit / extensions / HelperMacros . h > <nl> mmm a / test / TimeSeedCriteriaTest . cc <nl> ppp b / test / TimeSeedCriteriaTest . cc <nl> <nl> # include " TimeSeedCriteria . h " <nl> <nl> # include < cppunit / extensions / HelperMacros . h > <nl> + # include < stdlib . h > <nl> <nl> class TimeSeedCriteriaTest : public CppUnit : : TestFixture { <nl> <nl> CPPUNIT_TEST_SUITE_REGISTRATION ( TimeSeedCriteriaTest ) ; <nl> <nl> void TimeSeedCriteriaTest : : testEvaluate ( ) { <nl> TimeSeedCriteria cri ( 1 ) ; <nl> + # ifdef HAVE_SLEEP <nl> sleep ( 1 ) ; <nl> + # else <nl> + _sleep ( 1 ) ; <nl> + # endif <nl> CPPUNIT_ASSERT ( cri . evaluate ( ) ) ; <nl> cri . reset ( ) ; <nl> cri . setDuration ( 10 ) ; <nl> mmm a / test / UtilTest . cc <nl> ppp b / test / UtilTest . cc <nl> class UtilTest : public CppUnit : : TestFixture { <nl> CPPUNIT_TEST ( testStartsWith ) ; <nl> / / may be moved to other helper class in the future . <nl> CPPUNIT_TEST ( testGetContentDispositionFilename ) ; <nl> + # ifdef ENABLE_BITTORRENT <nl> CPPUNIT_TEST ( testComputeFastSet ) ; <nl> + # endif <nl> CPPUNIT_TEST ( testRandomAlpha ) ; <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> CPPUNIT_TEST ( testFileChecksum ) ; <nl> + # endif <nl> CPPUNIT_TEST ( testToUpper ) ; <nl> CPPUNIT_TEST ( testToLower ) ; <nl> CPPUNIT_TEST ( testUrldecode ) ; <nl> class UtilTest : public CppUnit : : TestFixture { <nl> void testEndsWith ( ) ; <nl> void testReplace ( ) ; <nl> void testStartsWith ( ) ; <nl> + # ifdef ENABLE_BITTORRENT <nl> void testComputeFastSet ( ) ; <nl> + # endif <nl> / / may be moved to other helper class in the future . <nl> void testGetContentDispositionFilename ( ) ; <nl> void testRandomAlpha ( ) ; <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> void testFileChecksum ( ) ; <nl> + # endif <nl> void testToUpper ( ) ; <nl> void testToLower ( ) ; <nl> void testUrldecode ( ) ; <nl> class Printer { <nl> } <nl> } ; <nl> <nl> + # ifdef ENABLE_BITTORRENT <nl> + <nl> void UtilTest : : testComputeFastSet ( ) { <nl> string ipaddr = " 192 . 168 . 0 . 1 " ; <nl> unsigned char infoHash [ 20 ] ; <nl> void UtilTest : : testComputeFastSet ( ) { <nl> CPPUNIT_ASSERT ( equal ( fastSet . begin ( ) , fastSet . end ( ) , ansSet2 . begin ( ) ) ) ; <nl> } <nl> <nl> + # endif <nl> + <nl> void UtilTest : : testRandomAlpha ( ) { <nl> CPPUNIT_ASSERT_EQUAL ( string ( " rUopvKRn " ) , Util : : randomAlpha ( 8 ) ) ; <nl> } <nl> <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> + <nl> void UtilTest : : testFileChecksum ( ) { <nl> unsigned char buf [ 20 ] ; <nl> string filename = " 4096chunk . txt " ; <nl> void UtilTest : : testFileChecksum ( ) { <nl> md5 ) ; <nl> } <nl> <nl> + # endif <nl> + <nl> void UtilTest : : testToUpper ( ) { <nl> string src = " 608cabc0f2fa18c260cafd974516865c772363d5 " ; <nl> string upp = " 608CABC0F2FA18C260CAFD974516865C772363D5 " ; <nl> void UtilTest : : testUrldecode ( ) { <nl> } <nl> <nl> void UtilTest : : testCountBit ( ) { <nl> - CPPUNIT_ASSERT_EQUAL ( 32 , Util : : countBit ( UINT32_MAX ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 8 , Util : : countBit ( 255 ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 32 , Util : : countBit ( UINT32_MAX ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 8 , Util : : countBit ( 255 ) ) ; <nl> } <nl> <nl> void UtilTest : : testGetRealSize ( ) <nl> mmm a / test / Xml2MetalinkProcessorTest . cc <nl> ppp b / test / Xml2MetalinkProcessorTest . cc <nl> void Xml2MetalinkProcessorTest : : testParseFile ( ) { <nl> CPPUNIT_ASSERT_EQUAL ( string ( " 0 . 5 . 1 " ) , entry2 - > version ) ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " ja - JP " ) , entry2 - > language ) ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " Linux - m68k " ) , entry2 - > os ) ; <nl> + # ifdef ENABLE_MESSAGE_DIGEST <nl> CPPUNIT_ASSERT_EQUAL ( string ( " 4c255b0ed130f5ea880f0aa061c3da0487e251cc " ) , <nl> entry2 - > checksum - > getMessageDigest ( ) ) ; <nl> + # endif / / ENABLE_MESSAGE_DIGEST <nl> CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 2 , entry2 - > chunkChecksum - > countChecksum ( ) ) ; <nl> - CPPUNIT_ASSERT_EQUAL ( 262144 , entry2 - > chunkChecksum - > getChecksumLength ( ) ) ; <nl> + CPPUNIT_ASSERT_EQUAL ( ( int32_t ) 262144 , entry2 - > chunkChecksum - > getChecksumLength ( ) ) ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " 179463a88d79cbf0b1923991708aead914f26142 " ) , <nl> entry2 - > chunkChecksum - > getChecksum ( 0 ) ) ; <nl> CPPUNIT_ASSERT_EQUAL ( string ( " fecf8bc9a1647505fe16746f94e97a477597dbf3 " ) , <nl> | Merged Ross ' s patch to test code . | aria2/aria2 | 19ef788023f12ee4d6b628d0409bcb58920bedd1 | 2007-07-23T14:09:46Z |
mmm a / ports / range - v3 / CONTROL <nl> ppp b / ports / range - v3 / CONTROL <nl> <nl> Source : range - v3 <nl> - Version : 20151130 - vcpkg4 <nl> + Version : 20151130 - vcpkg5 <nl> Description : Range library for C + + 11 / 14 / 17 . <nl> mmm a / ports / range - v3 / portfile . cmake <nl> ppp b / ports / range - v3 / portfile . cmake <nl> include ( vcpkg_common_functions ) <nl> vcpkg_from_github ( <nl> OUT_SOURCE_PATH SOURCE_PATH <nl> REPO Microsoft / Range - V3 - VS2015 <nl> - REF 2695c779d52717b635e97352fed6b75d32eba7a4 <nl> - SHA512 a1dad795b15c8491963f75fb58097dd290203406038cb2790c66b7ebd854a42043a92cfa2fed30c125529c3aa8d0cfc05cf1d149c84e96eb1f865857ad87adeb <nl> + REF 423bcae5cf18948591361329784d3b12ef41711b <nl> + SHA512 c6756bc6b5131c4c0ffb96550fb40decf734fc8c30e3d51c5c2bf03aae4d7426de36e896a1abf0a200a49a3906d4b60c1cf52f43504554b64d89c91de3e92746 <nl> HEAD_REF master <nl> ) <nl> <nl> | Update Range - V3 - VS2015 . | microsoft/vcpkg | 3f43b56bd98f9567c05c458560e587e58d9a9776 | 2017-12-19T04:59:31Z |
mmm a / tests / nodeos_run_test . py <nl> ppp b / tests / nodeos_run_test . py <nl> def cmdError ( name , cmdCode = 0 , exitNow = False ) : <nl> # errorExit ( " mongo get messages by transaction id % s " % ( transId ) ) <nl> <nl> <nl> - Print ( " Request invalid block numbered % d . This will generate an extpected error message . " % ( currentBlockNum + 1000 ) ) <nl> + Print ( " Request invalid block numbered % d . This will generate an expected error message . " % ( currentBlockNum + 1000 ) ) <nl> block = node . getBlock ( currentBlockNum + 1000 , silentErrors = True , retry = False ) <nl> if block is not None : <nl> errorExit ( " ERROR : Received block where not expected " ) <nl> | Fix spelling mistake . | EOSIO/eos | 0d8a616eafc4c778d8213ecbf47a54be7afb5e65 | 2018-05-16T16:17:57Z |
mmm a / src / app / commands / cmd_duplicate_sprite . cpp <nl> ppp b / src / app / commands / cmd_duplicate_sprite . cpp <nl> <nl> # include " raster / sprite . h " <nl> # include " ui / ui . h " <nl> <nl> + # include " generated_duplicate_sprite . h " <nl> + <nl> # include < cstdio > <nl> <nl> namespace app { <nl> bool DuplicateSpriteCommand : : onEnabled ( Context * context ) <nl> <nl> void DuplicateSpriteCommand : : onExecute ( Context * context ) <nl> { <nl> - Widget * src_name , * dst_name , * flatten ; <nl> const ContextReader reader ( context ) ; <nl> const Document * document = reader . document ( ) ; <nl> <nl> - / * load the window widget * / <nl> - base : : UniquePtr < Window > window ( app : : load_widget < Window > ( " duplicate_sprite . xml " , " duplicate_sprite " ) ) ; <nl> - <nl> - src_name = window - > findChild ( " src_name " ) ; <nl> - dst_name = window - > findChild ( " dst_name " ) ; <nl> - flatten = window - > findChild ( " flatten " ) ; <nl> - <nl> + / / Load the window widget <nl> + app : : gen : : DuplicateSprite window ; <nl> std : : string fn = document - > filename ( ) ; <nl> std : : string ext = base : : get_file_extension ( fn ) ; <nl> - src_name - > setText ( base : : get_file_name ( fn ) ) ; <nl> - dst_name - > setText ( base : : get_file_title ( fn ) + " Copy " + ( ! ext . empty ( ) ? " . " + ext : " " ) ) ; <nl> + window . srcName ( ) - > setText ( base : : get_file_name ( fn ) ) ; <nl> + window . dstName ( ) - > setText ( base : : get_file_title ( fn ) + <nl> + " Copy " + ( ! ext . empty ( ) ? " . " + ext : " " ) ) ; <nl> <nl> if ( get_config_bool ( " DuplicateSprite " , " Flatten " , false ) ) <nl> - flatten - > setSelected ( true ) ; <nl> + window . flatten ( ) - > setSelected ( true ) ; <nl> <nl> / / Open the window <nl> - window - > openWindowInForeground ( ) ; <nl> + window . openWindowInForeground ( ) ; <nl> <nl> - if ( window - > getKiller ( ) = = window - > findChild ( " ok " ) ) { <nl> - set_config_bool ( " DuplicateSprite " , " Flatten " , flatten - > isSelected ( ) ) ; <nl> + if ( window . getKiller ( ) = = window . ok ( ) ) { <nl> + set_config_bool ( " DuplicateSprite " , " Flatten " , window . flatten ( ) - > isSelected ( ) ) ; <nl> <nl> / / Make a copy of the document <nl> Document * docCopy ; <nl> - if ( flatten - > isSelected ( ) ) <nl> + if ( window . flatten ( ) - > isSelected ( ) ) <nl> docCopy = document - > duplicate ( DuplicateWithFlattenLayers ) ; <nl> else <nl> docCopy = document - > duplicate ( DuplicateExactCopy ) ; <nl> <nl> - docCopy - > setFilename ( dst_name - > getText ( ) . c_str ( ) ) ; <nl> + docCopy - > setFilename ( window . dstName ( ) - > getText ( ) . c_str ( ) ) ; <nl> docCopy - > setContext ( context ) ; <nl> } <nl> } <nl> | Use generated widget app : : gen : : DuplicateSprite in DuplicateSpriteCommand | aseprite/aseprite | d11900cdef82c81f450b99817ae73c968005044f | 2014-08-11T09:55:51Z |
mmm a / tools / depends / target / ffmpeg / FFMPEG - VERSION <nl> ppp b / tools / depends / target / ffmpeg / FFMPEG - VERSION <nl> <nl> LIBNAME = ffmpeg <nl> BASE_URL = https : / / github . com / xbmc / FFmpeg / archive <nl> - VERSION = 2 . 8 . 4 - Jarvis - rc1 <nl> + VERSION = 2 . 8 . 4 - Jarvis - rc1 - mp3 <nl> ARCHIVE = $ ( LIBNAME ) - $ ( VERSION ) . tar . gz <nl> <nl> | FFmpeg : Bump to 2 . 8 . 4 - Jarvis - rc1 - mp3 | xbmc/xbmc | 5e4953218e862a1bea201e62e864664f1ac24ec8 | 2015-12-22T16:54:37Z |
mmm a / folly / dynamic - inl . h <nl> ppp b / folly / dynamic - inl . h <nl> inline dynamic : : dynamic ( Array & & r ) : type_ ( ARRAY ) { <nl> new ( & u_ . array ) Array ( std : : move ( r ) ) ; <nl> } <nl> <nl> - # define FOLLY_DYNAMIC_DEC_TYPEINFO ( T , str , val ) \ <nl> - template < > \ <nl> - struct dynamic : : TypeInfo < T > { \ <nl> - static constexpr const char * name = str ; \ <nl> - static constexpr dynamic : : Type type = val ; \ <nl> - } ; \ <nl> + # define FOLLY_DYNAMIC_DEC_TYPEINFO ( T , val ) \ <nl> + template < > \ <nl> + struct dynamic : : TypeInfo < T > { \ <nl> + static const char * const name ; \ <nl> + static constexpr dynamic : : Type type = val ; \ <nl> + } ; \ <nl> / / <nl> <nl> - FOLLY_DYNAMIC_DEC_TYPEINFO ( std : : nullptr_t , " null " , dynamic : : NULLT ) <nl> - FOLLY_DYNAMIC_DEC_TYPEINFO ( bool , " boolean " , dynamic : : BOOL ) <nl> - FOLLY_DYNAMIC_DEC_TYPEINFO ( std : : string , " string " , dynamic : : STRING ) <nl> - FOLLY_DYNAMIC_DEC_TYPEINFO ( dynamic : : Array , " array " , dynamic : : ARRAY ) <nl> - FOLLY_DYNAMIC_DEC_TYPEINFO ( double , " double " , dynamic : : DOUBLE ) <nl> - FOLLY_DYNAMIC_DEC_TYPEINFO ( int64_t , " int64 " , dynamic : : INT64 ) <nl> - FOLLY_DYNAMIC_DEC_TYPEINFO ( dynamic : : ObjectImpl , " object " , dynamic : : OBJECT ) <nl> + FOLLY_DYNAMIC_DEC_TYPEINFO ( std : : nullptr_t , dynamic : : NULLT ) <nl> + FOLLY_DYNAMIC_DEC_TYPEINFO ( bool , dynamic : : BOOL ) <nl> + FOLLY_DYNAMIC_DEC_TYPEINFO ( std : : string , dynamic : : STRING ) <nl> + FOLLY_DYNAMIC_DEC_TYPEINFO ( dynamic : : Array , dynamic : : ARRAY ) <nl> + FOLLY_DYNAMIC_DEC_TYPEINFO ( double , dynamic : : DOUBLE ) <nl> + FOLLY_DYNAMIC_DEC_TYPEINFO ( int64_t , dynamic : : INT64 ) <nl> + FOLLY_DYNAMIC_DEC_TYPEINFO ( dynamic : : ObjectImpl , dynamic : : OBJECT ) <nl> <nl> # undef FOLLY_DYNAMIC_DEC_TYPEINFO <nl> <nl> mmm a / folly / dynamic . cpp <nl> ppp b / folly / dynamic . cpp <nl> namespace folly { <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - # define FOLLY_DYNAMIC_DEF_TYPEINFO ( T ) \ <nl> - constexpr const char * dynamic : : TypeInfo < T > : : name ; \ <nl> - constexpr dynamic : : Type dynamic : : TypeInfo < T > : : type ; \ <nl> + # define FOLLY_DYNAMIC_DEF_TYPEINFO ( T , str ) \ <nl> + const char * const dynamic : : TypeInfo < T > : : name = str ; \ <nl> / / <nl> <nl> - FOLLY_DYNAMIC_DEF_TYPEINFO ( std : : nullptr_t ) <nl> - FOLLY_DYNAMIC_DEF_TYPEINFO ( bool ) <nl> - FOLLY_DYNAMIC_DEF_TYPEINFO ( std : : string ) <nl> - FOLLY_DYNAMIC_DEF_TYPEINFO ( dynamic : : Array ) <nl> - FOLLY_DYNAMIC_DEF_TYPEINFO ( double ) <nl> - FOLLY_DYNAMIC_DEF_TYPEINFO ( int64_t ) <nl> - FOLLY_DYNAMIC_DEF_TYPEINFO ( dynamic : : ObjectImpl ) <nl> + FOLLY_DYNAMIC_DEF_TYPEINFO ( std : : nullptr_t , " null " ) <nl> + FOLLY_DYNAMIC_DEF_TYPEINFO ( bool , " boolean " ) <nl> + FOLLY_DYNAMIC_DEF_TYPEINFO ( std : : string , " string " ) <nl> + FOLLY_DYNAMIC_DEF_TYPEINFO ( dynamic : : Array , " array " ) <nl> + FOLLY_DYNAMIC_DEF_TYPEINFO ( double , " double " ) <nl> + FOLLY_DYNAMIC_DEF_TYPEINFO ( int64_t , " int64 " ) <nl> + FOLLY_DYNAMIC_DEF_TYPEINFO ( dynamic : : ObjectImpl , " object " ) <nl> <nl> # undef FOLLY_DYNAMIC_DEF_TYPEINFO <nl> <nl> | fix duplicated symbols for dynamic : : TypeInfo members | facebook/folly | 2ca4c388cf1b92471bb5879e67dea1c6182aadaf | 2020-03-18T01:22:20Z |
mmm a / BUILD . gn <nl> ppp b / BUILD . gn <nl> v8_source_set ( " v8_base_without_compiler " ) { <nl> " src / profiler / tick - sample . h " , <nl> " src / profiler / tracing - cpu - profiler . cc " , <nl> " src / profiler / tracing - cpu - profiler . h " , <nl> - " src / regexp / jsregexp . cc " , <nl> - " src / regexp / jsregexp . h " , <nl> " src / regexp / property - sequences . cc " , <nl> " src / regexp / property - sequences . h " , <nl> " src / regexp / regexp - ast . cc " , <nl> v8_source_set ( " v8_base_without_compiler " ) { <nl> " src / regexp / regexp - stack . h " , <nl> " src / regexp / regexp - utils . cc " , <nl> " src / regexp / regexp - utils . h " , <nl> + " src / regexp / regexp . cc " , <nl> + " src / regexp / regexp . h " , <nl> " src / roots / roots - inl . h " , <nl> " src / roots / roots . cc " , <nl> " src / roots / roots . h " , <nl> mmm a / src / DEPS <nl> ppp b / src / DEPS <nl> include_rules = [ <nl> " + src / interpreter / interpreter . h " , <nl> " + src / interpreter / interpreter - generator . h " , <nl> " + src / interpreter / setup - interpreter . h " , <nl> + " - src / regexp " , <nl> + " + src / regexp / regexp . h " , <nl> + " + src / regexp / regexp - stack . h " , <nl> + " + src / regexp / regexp - utils . h " , <nl> " - src / trap - handler " , <nl> " + src / trap - handler / handler - inside - posix . h " , <nl> " + src / trap - handler / handler - inside - win . h " , <nl> mmm a / src / builtins / builtins - regexp - gen . cc <nl> ppp b / src / builtins / builtins - regexp - gen . cc <nl> <nl> # include " src / objects / js - regexp - string - iterator . h " <nl> # include " src / objects / js - regexp . h " <nl> # include " src / objects / regexp - match - info . h " <nl> - # include " src / regexp / regexp - macro - assembler . h " <nl> + # include " src / regexp / regexp . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> TNode < HeapObject > RegExpBuiltinsAssembler : : RegExpExecInternal ( <nl> / / We expect exactly one result since we force the called regexp to behave <nl> / / as non - global . <nl> TNode < IntPtrT > int_result = ChangeInt32ToIntPtr ( result ) ; <nl> + GotoIf ( <nl> + IntPtrEqual ( int_result , IntPtrConstant ( RegExp : : kInternalRegExpSuccess ) ) , <nl> + & if_success ) ; <nl> + GotoIf ( <nl> + IntPtrEqual ( int_result , IntPtrConstant ( RegExp : : kInternalRegExpFailure ) ) , <nl> + & if_failure ) ; <nl> GotoIf ( IntPtrEqual ( int_result , <nl> - IntPtrConstant ( NativeRegExpMacroAssembler : : SUCCESS ) ) , <nl> - & if_success ) ; <nl> - GotoIf ( IntPtrEqual ( int_result , <nl> - IntPtrConstant ( NativeRegExpMacroAssembler : : FAILURE ) ) , <nl> - & if_failure ) ; <nl> - GotoIf ( IntPtrEqual ( int_result , <nl> - IntPtrConstant ( NativeRegExpMacroAssembler : : EXCEPTION ) ) , <nl> + IntPtrConstant ( RegExp : : kInternalRegExpException ) ) , <nl> & if_exception ) ; <nl> <nl> - CSA_ASSERT ( this , <nl> - IntPtrEqual ( int_result , <nl> - IntPtrConstant ( NativeRegExpMacroAssembler : : RETRY ) ) ) ; <nl> + CSA_ASSERT ( this , IntPtrEqual ( int_result , <nl> + IntPtrConstant ( RegExp : : kInternalRegExpRetry ) ) ) ; <nl> Goto ( & runtime ) ; <nl> } <nl> <nl> TF_BUILTIN ( RegExpPrototypeExecSlow , RegExpBuiltinsAssembler ) { <nl> <nl> / / Fast path stub for ATOM regexps . String matching is done by StringIndexOf , <nl> / / and { match_info } is updated on success . <nl> - / / The slow path is implemented in RegExpImpl : : AtomExec . <nl> + / / The slow path is implemented in RegExp : : AtomExec . <nl> TF_BUILTIN ( RegExpExecAtom , RegExpBuiltinsAssembler ) { <nl> TNode < JSRegExp > regexp = CAST ( Parameter ( Descriptor : : kRegExp ) ) ; <nl> TNode < String > subject_string = CAST ( Parameter ( Descriptor : : kString ) ) ; <nl> mmm a / src / builtins / builtins - regexp . cc <nl> ppp b / src / builtins / builtins - regexp . cc <nl> <nl> # include " src / builtins / builtins . h " <nl> # include " src / logging / counters . h " <nl> # include " src / objects / objects - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> # include " src / regexp / regexp - utils . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / strings / string - builder - inl . h " <nl> <nl> namespace v8 { <nl> new file mode 100644 <nl> index 00000000000 . . f3715e6ad01 <nl> mmm / dev / null <nl> ppp b / src / codegen / DEPS <nl> <nl> + # Copyright 2019 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> + specific_include_rules = { <nl> + " external - reference . cc " : [ <nl> + " + src / regexp / regexp - macro - assembler - arch . h " , <nl> + ] , <nl> + } <nl> deleted file mode 100644 <nl> index 937c7456623 . . 00000000000 <nl> mmm a / src / codegen / ppc / code - stubs - ppc . cc <nl> ppp / dev / null <nl> <nl> - / / Copyright 2014 the V8 project authors . All rights reserved . <nl> - / / Use of this source code is governed by a BSD - style license that can be <nl> - / / found in the LICENSE file . <nl> - <nl> - # if V8_TARGET_ARCH_PPC <nl> - <nl> - # include " src / api / api - arguments - inl . h " <nl> - # include " src / base / bits . h " <nl> - # include " src / code - stubs . h " <nl> - # include " src / codegen / assembler - inl . h " <nl> - # include " src / codegen / macro - assembler . h " <nl> - # include " src / execution / frame - constants . h " <nl> - # include " src / execution / frames . h " <nl> - # include " src / execution / isolate . h " <nl> - # include " src / ic / ic . h " <nl> - # include " src / ic / stub - cache . h " <nl> - # include " src / init / bootstrapper . h " <nl> - # include " src / numbers / double . h " <nl> - # include " src / objects / api - callbacks . h " <nl> - # include " src / regexp / jsregexp . h " <nl> - # include " src / regexp / regexp - macro - assembler . h " <nl> - # include " src / runtime / runtime . h " <nl> - <nl> - namespace v8 { <nl> - namespace internal { } / / namespace internal <nl> - } / / namespace v8 <nl> - <nl> - # endif / / V8_TARGET_ARCH_PPC <nl> deleted file mode 100644 <nl> index f85c3099439 . . 00000000000 <nl> mmm a / src / codegen / s390 / code - stubs - s390 . cc <nl> ppp / dev / null <nl> <nl> - / / Copyright 2014 the V8 project authors . All rights reserved . <nl> - / / Use of this source code is governed by a BSD - style license that can be <nl> - / / found in the LICENSE file . <nl> - <nl> - # if V8_TARGET_ARCH_S390 <nl> - <nl> - # include " src / api / api - arguments - inl . h " <nl> - # include " src / base / bits . h " <nl> - # include " src / code - stubs . h " <nl> - # include " src / codegen / assembler - inl . h " <nl> - # include " src / codegen / macro - assembler . h " <nl> - # include " src / execution / frame - constants . h " <nl> - # include " src / execution / frames . h " <nl> - # include " src / execution / isolate . h " <nl> - # include " src / ic / ic . h " <nl> - # include " src / ic / stub - cache . h " <nl> - # include " src / init / bootstrapper . h " <nl> - # include " src / objects / api - callbacks . h " <nl> - # include " src / regexp / jsregexp . h " <nl> - # include " src / regexp / regexp - macro - assembler . h " <nl> - # include " src / runtime / runtime . h " <nl> - <nl> - namespace v8 { <nl> - namespace internal { } / / namespace internal <nl> - } / / namespace v8 <nl> - <nl> - # endif / / V8_TARGET_ARCH_S390 <nl> mmm a / src / diagnostics / objects - debug . cc <nl> ppp b / src / diagnostics / objects - debug . cc <nl> <nl> # include " src / objects / struct - inl . h " <nl> # include " src / objects / template - objects - inl . h " <nl> # include " src / objects / transitions - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / utils / ostreams . h " <nl> # include " src / wasm / wasm - objects - inl . h " <nl> # include " torque - generated / class - verifiers - tq . h " <nl> void JSRegExp : : JSRegExpVerify ( Isolate * isolate ) { <nl> break ; <nl> } <nl> case JSRegExp : : IRREGEXP : { <nl> - bool is_native = RegExpImpl : : UsesNativeRegExp ( ) ; <nl> + bool is_native = RegExp : : GeneratesNativeCode ( ) ; <nl> <nl> FixedArray arr = FixedArray : : cast ( data ( ) ) ; <nl> Object one_byte_data = arr . get ( JSRegExp : : kIrregexpLatin1CodeIndex ) ; <nl> mmm a / src / diagnostics / objects - printer . cc <nl> ppp b / src / diagnostics / objects - printer . cc <nl> <nl> # include " src / objects / struct - inl . h " <nl> # include " src / objects / template - objects - inl . h " <nl> # include " src / objects / transitions - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / utils / ostreams . h " <nl> # include " src / wasm / wasm - code - manager . h " <nl> # include " src / wasm / wasm - engine . h " <nl> mmm a / src / heap / heap . cc <nl> ppp b / src / heap / heap . cc <nl> <nl> # include " src / objects / shared - function - info . h " <nl> # include " src / objects / slots - atomic - inl . h " <nl> # include " src / objects / slots - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / snapshot / embedded / embedded - data . h " <nl> # include " src / snapshot / natives . h " <nl> # include " src / snapshot / serializer - common . h " <nl> mmm a / src / heap / setup - heap - internal . cc <nl> ppp b / src / heap / setup - heap - internal . cc <nl> <nl> # include " src / objects / stack - frame - info . h " <nl> # include " src / objects / string . h " <nl> # include " src / objects / template - objects - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / wasm / wasm - objects . h " <nl> <nl> namespace v8 { <nl> mmm a / src / objects / objects . cc <nl> ppp b / src / objects / objects . cc <nl> <nl> # include " src / objects / template - objects - inl . h " <nl> # include " src / objects / transitions - inl . h " <nl> # include " src / parsing / preparse - data . h " <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / strings / string - builder - inl . h " <nl> # include " src / strings / string - search . h " <nl> # include " src / strings / string - stream . h " <nl> MaybeHandle < JSRegExp > JSRegExp : : Initialize ( Handle < JSRegExp > regexp , <nl> ASSIGN_RETURN_ON_EXCEPTION ( isolate , escaped_source , <nl> EscapeRegExpSource ( isolate , source ) , JSRegExp ) ; <nl> <nl> - RETURN_ON_EXCEPTION ( <nl> - isolate , RegExpImpl : : Compile ( isolate , regexp , source , flags ) , JSRegExp ) ; <nl> + RETURN_ON_EXCEPTION ( isolate , RegExp : : Compile ( isolate , regexp , source , flags ) , <nl> + JSRegExp ) ; <nl> <nl> regexp - > set_source ( * escaped_source ) ; <nl> regexp - > set_flags ( Smi : : FromInt ( flags ) ) ; <nl> mmm a / src / parsing / scanner . h <nl> ppp b / src / parsing / scanner . h <nl> class V8_EXPORT_PRIVATE Scanner { <nl> / / Returns true if a pattern is scanned . <nl> bool ScanRegExpPattern ( ) ; <nl> / / Scans the input as regular expression flags . Returns the flags on success . <nl> - Maybe < RegExp : : Flags > ScanRegExpFlags ( ) ; <nl> + Maybe < v8 : : RegExp : : Flags > ScanRegExpFlags ( ) ; <nl> <nl> / / Scans the input as a template literal <nl> Token : : Value ScanTemplateContinuation ( ) { <nl> mmm a / src / regexp / regexp - compiler - tonode . cc <nl> ppp b / src / regexp / regexp - compiler - tonode . cc <nl> <nl> # include " src / regexp / regexp - compiler . h " <nl> <nl> # include " src / execution / isolate . h " <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / strings / unicode - inl . h " <nl> # include " src / utils / splay - tree - inl . h " <nl> # include " src / zone / zone - list - inl . h " <nl> mmm a / src / regexp / regexp - interpreter . cc <nl> ppp b / src / regexp / regexp - interpreter . cc <nl> <nl> # include " src / ast / ast . h " <nl> # include " src / base / small - vector . h " <nl> # include " src / objects / objects - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> # include " src / regexp / regexp - bytecodes . h " <nl> # include " src / regexp / regexp - macro - assembler . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / strings / unicode . h " <nl> # include " src / utils / utils . h " <nl> <nl> mmm a / src / regexp / regexp - interpreter . h <nl> ppp b / src / regexp / regexp - interpreter . h <nl> <nl> # ifndef V8_REGEXP_REGEXP_INTERPRETER_H_ <nl> # define V8_REGEXP_REGEXP_INTERPRETER_H_ <nl> <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> class V8_EXPORT_PRIVATE IrregexpInterpreter { <nl> public : <nl> - enum Result { RETRY = - 2 , EXCEPTION = - 1 , FAILURE = 0 , SUCCESS = 1 } ; <nl> - STATIC_ASSERT ( EXCEPTION = = static_cast < int > ( RegExpImpl : : RE_EXCEPTION ) ) ; <nl> - STATIC_ASSERT ( FAILURE = = static_cast < int > ( RegExpImpl : : RE_FAILURE ) ) ; <nl> - STATIC_ASSERT ( SUCCESS = = static_cast < int > ( RegExpImpl : : RE_SUCCESS ) ) ; <nl> + enum Result { <nl> + FAILURE = RegExp : : kInternalRegExpFailure , <nl> + SUCCESS = RegExp : : kInternalRegExpSuccess , <nl> + EXCEPTION = RegExp : : kInternalRegExpException , <nl> + RETRY = RegExp : : kInternalRegExpRetry , <nl> + } ; <nl> <nl> / / The caller is responsible for initializing registers before each call . <nl> static Result Match ( Isolate * isolate , Handle < ByteArray > code_array , <nl> mmm a / src / regexp / regexp - macro - assembler . h <nl> ppp b / src / regexp / regexp - macro - assembler . h <nl> <nl> <nl> # include " src / codegen / label . h " <nl> # include " src / regexp / regexp - ast . h " <nl> + # include " src / regexp / regexp . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> class NativeRegExpMacroAssembler : public RegExpMacroAssembler { <nl> / / FAILURE : Matching failed . <nl> / / SUCCESS : Matching succeeded , and the output array has been filled with <nl> / / capture positions . <nl> - enum Result { RETRY = - 2 , EXCEPTION = - 1 , FAILURE = 0 , SUCCESS = 1 } ; <nl> + enum Result { <nl> + FAILURE = RegExp : : kInternalRegExpFailure , <nl> + SUCCESS = RegExp : : kInternalRegExpSuccess , <nl> + EXCEPTION = RegExp : : kInternalRegExpException , <nl> + RETRY = RegExp : : kInternalRegExpRetry , <nl> + } ; <nl> <nl> NativeRegExpMacroAssembler ( Isolate * isolate , Zone * zone ) ; <nl> ~ NativeRegExpMacroAssembler ( ) override ; <nl> mmm a / src / regexp / regexp - parser . cc <nl> ppp b / src / regexp / regexp - parser . cc <nl> <nl> # include " src / execution / isolate . h " <nl> # include " src / heap / factory . h " <nl> # include " src / objects / objects - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> # include " src / regexp / property - sequences . h " <nl> # include " src / regexp / regexp - macro - assembler . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / strings / char - predicates - inl . h " <nl> # include " src / utils / ostreams . h " <nl> # include " src / utils / utils . h " <nl> mmm a / src / regexp / regexp - utils . cc <nl> ppp b / src / regexp / regexp - utils . cc <nl> <nl> # include " src / heap / factory . h " <nl> # include " src / objects / js - regexp - inl . h " <nl> # include " src / objects / objects - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> similarity index 84 % <nl> rename from src / regexp / jsregexp . cc <nl> rename to src / regexp / regexp . cc <nl> mmm a / src / regexp / jsregexp . cc <nl> ppp b / src / regexp / regexp . cc <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> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> <nl> # include " src / codegen / compilation - cache . h " <nl> # include " src / heap / heap - inl . h " <nl> namespace internal { <nl> <nl> using namespace regexp_compiler_constants ; / / NOLINT ( build / namespaces ) <nl> <nl> + class RegExpImpl final : public AllStatic { <nl> + public : <nl> + / / Returns a string representation of a regular expression . <nl> + / / Implements RegExp . prototype . toString , see ECMA - 262 section 15 . 10 . 6 . 4 . <nl> + / / This function calls the garbage collector if necessary . <nl> + static Handle < String > ToString ( Handle < Object > value ) ; <nl> + <nl> + / / Prepares a JSRegExp object with Irregexp - specific data . <nl> + static void IrregexpInitialize ( Isolate * isolate , Handle < JSRegExp > re , <nl> + Handle < String > pattern , JSRegExp : : Flags flags , <nl> + int capture_register_count ) ; <nl> + <nl> + static void AtomCompile ( Isolate * isolate , Handle < JSRegExp > re , <nl> + Handle < String > pattern , JSRegExp : : Flags flags , <nl> + Handle < String > match_pattern ) ; <nl> + <nl> + static int AtomExecRaw ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> + Handle < String > subject , int index , int32_t * output , <nl> + int output_size ) ; <nl> + <nl> + static Handle < Object > AtomExec ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> + Handle < String > subject , int index , <nl> + Handle < RegExpMatchInfo > last_match_info ) ; <nl> + <nl> + / / Execute a regular expression on the subject , starting from index . <nl> + / / If matching succeeds , return the number of matches . This can be larger <nl> + / / than one in the case of global regular expressions . <nl> + / / The captures and subcaptures are stored into the registers vector . <nl> + / / If matching fails , returns RE_FAILURE . <nl> + / / If execution fails , sets a pending exception and returns RE_EXCEPTION . <nl> + static int IrregexpExecRaw ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> + Handle < String > subject , int index , int32_t * output , <nl> + int output_size ) ; <nl> + <nl> + / / Execute an Irregexp bytecode pattern . <nl> + / / On a successful match , the result is a JSArray containing <nl> + / / captured positions . On a failure , the result is the null value . <nl> + / / Returns an empty handle in case of an exception . <nl> + V8_WARN_UNUSED_RESULT static MaybeHandle < Object > IrregexpExec ( <nl> + Isolate * isolate , Handle < JSRegExp > regexp , Handle < String > subject , <nl> + int index , Handle < RegExpMatchInfo > last_match_info ) ; <nl> + <nl> + static bool CompileIrregexp ( Isolate * isolate , Handle < JSRegExp > re , <nl> + Handle < String > sample_subject , bool is_one_byte ) ; <nl> + static inline bool EnsureCompiledIrregexp ( Isolate * isolate , <nl> + Handle < JSRegExp > re , <nl> + Handle < String > sample_subject , <nl> + bool is_one_byte ) ; <nl> + <nl> + / / Returns true on success , false on failure . <nl> + static bool Compile ( Isolate * isolate , Zone * zone , RegExpCompileData * input , <nl> + JSRegExp : : Flags flags , Handle < String > pattern , <nl> + Handle < String > sample_subject , bool is_one_byte ) ; <nl> + <nl> + / / For acting on the JSRegExp data FixedArray . <nl> + static int IrregexpMaxRegisterCount ( FixedArray re ) ; <nl> + static void SetIrregexpMaxRegisterCount ( FixedArray re , int value ) ; <nl> + static void SetIrregexpCaptureNameMap ( FixedArray re , <nl> + Handle < FixedArray > value ) ; <nl> + static int IrregexpNumberOfCaptures ( FixedArray re ) ; <nl> + static int IrregexpNumberOfRegisters ( FixedArray re ) ; <nl> + static ByteArray IrregexpByteCode ( FixedArray re , bool is_one_byte ) ; <nl> + static Code IrregexpNativeCode ( FixedArray re , bool is_one_byte ) ; <nl> + } ; <nl> + <nl> V8_WARN_UNUSED_RESULT <nl> static inline MaybeHandle < Object > ThrowRegExpException ( <nl> Isolate * isolate , Handle < JSRegExp > re , Handle < String > pattern , <nl> Handle < String > error_text ) { <nl> - THROW_NEW_ERROR ( isolate , NewSyntaxError ( MessageTemplate : : kMalformedRegExp , <nl> - pattern , error_text ) , <nl> - Object ) ; <nl> + THROW_NEW_ERROR ( <nl> + isolate , <nl> + NewSyntaxError ( MessageTemplate : : kMalformedRegExp , pattern , error_text ) , <nl> + Object ) ; <nl> } <nl> <nl> inline void ThrowRegExpException ( Isolate * isolate , Handle < JSRegExp > re , <nl> inline void ThrowRegExpException ( Isolate * isolate , Handle < JSRegExp > re , <nl> error_text ) ) ; <nl> } <nl> <nl> - <nl> - ContainedInLattice AddRange ( ContainedInLattice containment , <nl> - const int * ranges , <nl> - int ranges_length , <nl> - Interval new_range ) { <nl> + ContainedInLattice AddRange ( ContainedInLattice containment , const int * ranges , <nl> + int ranges_length , Interval new_range ) { <nl> DCHECK_EQ ( 1 , ranges_length & 1 ) ; <nl> DCHECK_EQ ( String : : kMaxCodePoint + 1 , ranges [ ranges_length - 1 ] ) ; <nl> if ( containment = = kLatticeUnknown ) return containment ; <nl> static bool HasFewDifferentCharacters ( Handle < String > pattern ) { <nl> <nl> / / Generic RegExp methods . Dispatches to implementation specific methods . <nl> <nl> - MaybeHandle < Object > RegExpImpl : : Compile ( Isolate * isolate , Handle < JSRegExp > re , <nl> - Handle < String > pattern , <nl> - JSRegExp : : Flags flags ) { <nl> + / / static <nl> + MaybeHandle < Object > RegExp : : Compile ( Isolate * isolate , Handle < JSRegExp > re , <nl> + Handle < String > pattern , <nl> + JSRegExp : : Flags flags ) { <nl> DCHECK ( pattern - > IsFlat ( ) ) ; <nl> <nl> Zone zone ( isolate - > allocator ( ) , ZONE_NAME ) ; <nl> MaybeHandle < Object > RegExpImpl : : Compile ( Isolate * isolate , Handle < JSRegExp > re , <nl> if ( parse_result . simple & & ! IgnoreCase ( flags ) & & ! IsSticky ( flags ) & & <nl> ! HasFewDifferentCharacters ( pattern ) ) { <nl> / / Parse - tree is a single atom that is equal to the pattern . <nl> - AtomCompile ( isolate , re , pattern , flags , pattern ) ; <nl> + RegExpImpl : : AtomCompile ( isolate , re , pattern , flags , pattern ) ; <nl> has_been_compiled = true ; <nl> } else if ( parse_result . tree - > IsAtom ( ) & & ! IsSticky ( flags ) & & <nl> parse_result . capture_count = = 0 ) { <nl> MaybeHandle < Object > RegExpImpl : : Compile ( Isolate * isolate , Handle < JSRegExp > re , <nl> isolate , atom_string , <nl> isolate - > factory ( ) - > NewStringFromTwoByte ( atom_pattern ) , Object ) ; <nl> if ( ! IgnoreCase ( atom - > flags ( ) ) & & ! HasFewDifferentCharacters ( atom_string ) ) { <nl> - AtomCompile ( isolate , re , pattern , flags , atom_string ) ; <nl> + RegExpImpl : : AtomCompile ( isolate , re , pattern , flags , atom_string ) ; <nl> has_been_compiled = true ; <nl> } <nl> } <nl> if ( ! has_been_compiled ) { <nl> - IrregexpInitialize ( isolate , re , pattern , flags , parse_result . capture_count ) ; <nl> + RegExpImpl : : IrregexpInitialize ( isolate , re , pattern , flags , <nl> + parse_result . capture_count ) ; <nl> } <nl> DCHECK ( re - > data ( ) . IsFixedArray ( ) ) ; <nl> / / Compilation succeeded so the data is set on the regexp <nl> MaybeHandle < Object > RegExpImpl : : Compile ( Isolate * isolate , Handle < JSRegExp > re , <nl> return re ; <nl> } <nl> <nl> - MaybeHandle < Object > RegExpImpl : : Exec ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> - Handle < String > subject , int index , <nl> - Handle < RegExpMatchInfo > last_match_info ) { <nl> + / / static <nl> + MaybeHandle < Object > RegExp : : Exec ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> + Handle < String > subject , int index , <nl> + Handle < RegExpMatchInfo > last_match_info ) { <nl> switch ( regexp - > TypeTag ( ) ) { <nl> case JSRegExp : : ATOM : <nl> - return AtomExec ( isolate , regexp , subject , index , last_match_info ) ; <nl> + return RegExpImpl : : AtomExec ( isolate , regexp , subject , index , <nl> + last_match_info ) ; <nl> case JSRegExp : : IRREGEXP : { <nl> - return IrregexpExec ( isolate , regexp , subject , index , last_match_info ) ; <nl> + return RegExpImpl : : IrregexpExec ( isolate , regexp , subject , index , <nl> + last_match_info ) ; <nl> } <nl> default : <nl> UNREACHABLE ( ) ; <nl> } <nl> } <nl> <nl> - <nl> / / RegExp Atom implementation : Simple string search using indexOf . <nl> <nl> void RegExpImpl : : AtomCompile ( Isolate * isolate , Handle < JSRegExp > re , <nl> int RegExpImpl : : AtomExecRaw ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> DCHECK_LT ( 0 , needle_len ) ; <nl> <nl> if ( index + needle_len > subject - > length ( ) ) { <nl> - return RegExpImpl : : RE_FAILURE ; <nl> + return RegExp : : RE_FAILURE ; <nl> } <nl> <nl> for ( int i = 0 ; i < output_size ; i + = 2 ) { <nl> int RegExpImpl : : AtomExecRaw ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> return i / 2 ; / / Return number of matches . <nl> } else { <nl> output [ i ] = index ; <nl> - output [ i + 1 ] = index + needle_len ; <nl> + output [ i + 1 ] = index + needle_len ; <nl> index + = needle_len ; <nl> } <nl> } <nl> Handle < Object > RegExpImpl : : AtomExec ( Isolate * isolate , Handle < JSRegExp > re , <nl> int res = <nl> AtomExecRaw ( isolate , re , subject , index , output_registers , kNumRegisters ) ; <nl> <nl> - if ( res = = RegExpImpl : : RE_FAILURE ) return isolate - > factory ( ) - > null_value ( ) ; <nl> + if ( res = = RegExp : : RE_FAILURE ) return isolate - > factory ( ) - > null_value ( ) ; <nl> <nl> - DCHECK_EQ ( res , RegExpImpl : : RE_SUCCESS ) ; <nl> + DCHECK_EQ ( res , RegExp : : RE_SUCCESS ) ; <nl> SealHandleScope shs ( isolate ) ; <nl> SetAtomLastCapture ( isolate , last_match_info , * subject , output_registers [ 0 ] , <nl> output_registers [ 1 ] ) ; <nl> return last_match_info ; <nl> } <nl> <nl> - <nl> / / Irregexp implementation . <nl> <nl> / / Ensures that the regexp object contains a compiled version of the <nl> void RegExpImpl : : IrregexpInitialize ( Isolate * isolate , Handle < JSRegExp > re , <nl> flags , capture_count ) ; <nl> } <nl> <nl> - int RegExpImpl : : IrregexpPrepare ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> - Handle < String > subject ) { <nl> + / / static <nl> + int RegExp : : IrregexpPrepare ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> + Handle < String > subject ) { <nl> DCHECK ( subject - > IsFlat ( ) ) ; <nl> <nl> / / Check representation of the underlying storage . <nl> bool is_one_byte = String : : IsOneByteRepresentationUnderneath ( * subject ) ; <nl> - if ( ! EnsureCompiledIrregexp ( isolate , regexp , subject , is_one_byte ) ) return - 1 ; <nl> + if ( ! RegExpImpl : : EnsureCompiledIrregexp ( isolate , regexp , subject , <nl> + is_one_byte ) ) { <nl> + return - 1 ; <nl> + } <nl> <nl> + DisallowHeapAllocation no_gc ; <nl> + FixedArray data = FixedArray : : cast ( regexp - > data ( ) ) ; <nl> if ( FLAG_regexp_interpret_all ) { <nl> / / Byte - code regexp needs space allocated for all its registers . <nl> / / The result captures are copied to the start of the registers array <nl> / / if the match succeeds . This way those registers are not clobbered <nl> / / when we set the last match info from last successful match . <nl> - return IrregexpNumberOfRegisters ( FixedArray : : cast ( regexp - > data ( ) ) ) + <nl> - ( IrregexpNumberOfCaptures ( FixedArray : : cast ( regexp - > data ( ) ) ) + 1 ) * 2 ; <nl> + return RegExpImpl : : IrregexpNumberOfRegisters ( data ) + <nl> + ( RegExpImpl : : IrregexpNumberOfCaptures ( data ) + 1 ) * 2 ; <nl> } else { <nl> / / Native regexp only needs room to output captures . Registers are handled <nl> / / internally . <nl> - return ( IrregexpNumberOfCaptures ( FixedArray : : cast ( regexp - > data ( ) ) ) + 1 ) * 2 ; <nl> + return ( RegExpImpl : : IrregexpNumberOfCaptures ( data ) + 1 ) * 2 ; <nl> } <nl> } <nl> <nl> int RegExpImpl : : IrregexpExecRaw ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> DCHECK ( res ! = NativeRegExpMacroAssembler : : EXCEPTION | | <nl> isolate - > has_pending_exception ( ) ) ; <nl> STATIC_ASSERT ( static_cast < int > ( NativeRegExpMacroAssembler : : SUCCESS ) = = <nl> - RE_SUCCESS ) ; <nl> + RegExp : : RE_SUCCESS ) ; <nl> STATIC_ASSERT ( static_cast < int > ( NativeRegExpMacroAssembler : : FAILURE ) = = <nl> - RE_FAILURE ) ; <nl> + RegExp : : RE_FAILURE ) ; <nl> STATIC_ASSERT ( static_cast < int > ( NativeRegExpMacroAssembler : : EXCEPTION ) = = <nl> - RE_EXCEPTION ) ; <nl> + RegExp : : RE_EXCEPTION ) ; <nl> return res ; <nl> } <nl> / / If result is RETRY , the string has changed representation , and we <nl> int RegExpImpl : : IrregexpExecRaw ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> / / the , potentially , different subject ( the string can switch between <nl> / / being internal and external , and even between being Latin1 and UC16 , <nl> / / but the characters are always the same ) . <nl> - IrregexpPrepare ( isolate , regexp , subject ) ; <nl> + RegExp : : IrregexpPrepare ( isolate , regexp , subject ) ; <nl> is_one_byte = String : : IsOneByteRepresentationUnderneath ( * subject ) ; <nl> } while ( true ) ; <nl> UNREACHABLE ( ) ; <nl> MaybeHandle < Object > RegExpImpl : : IrregexpExec ( <nl> PrintF ( " \ n \ nSubject string : ' % s ' \ n \ n " , subject - > ToCString ( ) . get ( ) ) ; <nl> } <nl> # endif <nl> - int required_registers = <nl> - RegExpImpl : : IrregexpPrepare ( isolate , regexp , subject ) ; <nl> + int required_registers = RegExp : : IrregexpPrepare ( isolate , regexp , subject ) ; <nl> if ( required_registers < 0 ) { <nl> / / Compiling failed with an exception . <nl> DCHECK ( isolate - > has_pending_exception ( ) ) ; <nl> MaybeHandle < Object > RegExpImpl : : IrregexpExec ( <nl> int res = <nl> RegExpImpl : : IrregexpExecRaw ( isolate , regexp , subject , previous_index , <nl> output_registers , required_registers ) ; <nl> - if ( res = = RE_SUCCESS ) { <nl> + if ( res = = RegExp : : RE_SUCCESS ) { <nl> int capture_count = <nl> IrregexpNumberOfCaptures ( FixedArray : : cast ( regexp - > data ( ) ) ) ; <nl> - return SetLastMatchInfo ( isolate , last_match_info , subject , capture_count , <nl> - output_registers ) ; <nl> + return RegExp : : SetLastMatchInfo ( isolate , last_match_info , subject , <nl> + capture_count , output_registers ) ; <nl> } <nl> - if ( res = = RE_EXCEPTION ) { <nl> + if ( res = = RegExp : : RE_EXCEPTION ) { <nl> DCHECK ( isolate - > has_pending_exception ( ) ) ; <nl> return MaybeHandle < Object > ( ) ; <nl> } <nl> - DCHECK ( res = = RE_FAILURE ) ; <nl> + DCHECK ( res = = RegExp : : RE_FAILURE ) ; <nl> return isolate - > factory ( ) - > null_value ( ) ; <nl> } <nl> <nl> - Handle < RegExpMatchInfo > RegExpImpl : : SetLastMatchInfo ( <nl> + / / static <nl> + Handle < RegExpMatchInfo > RegExp : : SetLastMatchInfo ( <nl> Isolate * isolate , Handle < RegExpMatchInfo > last_match_info , <nl> Handle < String > subject , int capture_count , int32_t * match ) { <nl> / / This is the only place where match infos can grow . If , after executing the <nl> Handle < RegExpMatchInfo > RegExpImpl : : SetLastMatchInfo ( <nl> return result ; <nl> } <nl> <nl> - void RegExpImpl : : DotPrintForTesting ( const char * label , RegExpNode * node , <nl> - bool ignore_case ) { <nl> + / / static <nl> + void RegExp : : DotPrintForTesting ( const char * label , RegExpNode * node , <nl> + bool ignore_case ) { <nl> DotPrinter : : DotPrint ( label , node , ignore_case ) ; <nl> } <nl> <nl> bool TooMuchRegExpCode ( Isolate * isolate , Handle < String > pattern ) { <nl> static constexpr size_t kRegExpCompiledLimit = 1 * MB ; <nl> <nl> Heap * heap = isolate - > heap ( ) ; <nl> - if ( pattern - > length ( ) > RegExpImpl : : kRegExpTooLargeToOptimize ) return true ; <nl> + if ( pattern - > length ( ) > RegExp : : kRegExpTooLargeToOptimize ) return true ; <nl> return ( isolate - > total_regexp_code_generated ( ) > kRegExpCompiledLimit & & <nl> heap - > CommittedMemoryExecutable ( ) > kRegExpExecutableMemoryLimit ) ; <nl> } <nl> <nl> } / / namespace <nl> <nl> - bool RegExpImpl : : CompileForTesting ( Isolate * isolate , Zone * zone , <nl> - RegExpCompileData * data , <nl> - JSRegExp : : Flags flags , <nl> - Handle < String > pattern , <nl> - Handle < String > sample_subject , <nl> - bool is_one_byte ) { <nl> - return Compile ( isolate , zone , data , flags , pattern , sample_subject , <nl> - is_one_byte ) ; <nl> + / / static <nl> + bool RegExp : : CompileForTesting ( Isolate * isolate , Zone * zone , <nl> + RegExpCompileData * data , JSRegExp : : Flags flags , <nl> + Handle < String > pattern , <nl> + Handle < String > sample_subject , <nl> + bool is_one_byte ) { <nl> + return RegExpImpl : : Compile ( isolate , zone , data , flags , pattern , <nl> + sample_subject , is_one_byte ) ; <nl> } <nl> <nl> bool RegExpImpl : : Compile ( Isolate * isolate , Zone * zone , RegExpCompileData * data , <nl> RegExpGlobalCache : : RegExpGlobalCache ( Handle < JSRegExp > regexp , <nl> / / There is no distinction between interpreted and native for atom regexps . <nl> interpreted = false ; <nl> } else { <nl> - registers_per_match_ = <nl> - RegExpImpl : : IrregexpPrepare ( isolate_ , regexp_ , subject_ ) ; <nl> + registers_per_match_ = RegExp : : IrregexpPrepare ( isolate_ , regexp_ , subject_ ) ; <nl> if ( registers_per_match_ < 0 ) { <nl> num_matches_ = - 1 ; / / Signal exception . <nl> return ; <nl> similarity index 62 % <nl> rename from src / regexp / jsregexp . h <nl> rename to src / regexp / regexp . h <nl> mmm a / src / regexp / jsregexp . h <nl> ppp b / src / regexp / regexp . h <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> - # ifndef V8_REGEXP_JSREGEXP_H_ <nl> - # define V8_REGEXP_JSREGEXP_H_ <nl> + # ifndef V8_REGEXP_REGEXP_H_ <nl> + # define V8_REGEXP_REGEXP_H_ <nl> <nl> # include " src / objects / js - regexp . h " <nl> <nl> struct RegExpCompileData { <nl> int register_count = 0 ; <nl> } ; <nl> <nl> - class RegExpImpl final : public AllStatic { <nl> + class RegExp final : public AllStatic { <nl> public : <nl> / / Whether the irregexp engine generates native code or interpreter bytecode . <nl> - static bool UsesNativeRegExp ( ) { return ! FLAG_regexp_interpret_all ; } <nl> + static bool GeneratesNativeCode ( ) { return ! FLAG_regexp_interpret_all ; } <nl> <nl> / / Parses the RegExp pattern and prepares the JSRegExp object with <nl> / / generic data and choice of implementation - as well as what <nl> class RegExpImpl final : public AllStatic { <nl> Isolate * isolate , Handle < JSRegExp > regexp , Handle < String > subject , <nl> int index , Handle < RegExpMatchInfo > last_match_info ) ; <nl> <nl> - enum IrregexpResult { RE_FAILURE = 0 , RE_SUCCESS = 1 , RE_EXCEPTION = - 1 } ; <nl> + / / Integral return values used throughout regexp code layers . <nl> + static constexpr int kInternalRegExpFailure = 0 ; <nl> + static constexpr int kInternalRegExpSuccess = 1 ; <nl> + static constexpr int kInternalRegExpException = - 1 ; <nl> + static constexpr int kInternalRegExpRetry = - 2 ; <nl> + <nl> + enum IrregexpResult { <nl> + RE_FAILURE = kInternalRegExpFailure , <nl> + RE_SUCCESS = kInternalRegExpSuccess , <nl> + RE_EXCEPTION = kInternalRegExpException , <nl> + } ; <nl> <nl> / / Prepare a RegExp for being executed one or more times ( using <nl> / / IrregexpExecOnce ) on the subject . <nl> class RegExpImpl final : public AllStatic { <nl> bool ignore_case ) ; <nl> <nl> static const int kRegExpTooLargeToOptimize = 20 * KB ; <nl> - <nl> - private : <nl> - / / Returns a string representation of a regular expression . <nl> - / / Implements RegExp . prototype . toString , see ECMA - 262 section 15 . 10 . 6 . 4 . <nl> - / / This function calls the garbage collector if necessary . <nl> - static Handle < String > ToString ( Handle < Object > value ) ; <nl> - <nl> - / / Prepares a JSRegExp object with Irregexp - specific data . <nl> - static void IrregexpInitialize ( Isolate * isolate , Handle < JSRegExp > re , <nl> - Handle < String > pattern , JSRegExp : : Flags flags , <nl> - int capture_register_count ) ; <nl> - <nl> - static void AtomCompile ( Isolate * isolate , Handle < JSRegExp > re , <nl> - Handle < String > pattern , JSRegExp : : Flags flags , <nl> - Handle < String > match_pattern ) ; <nl> - <nl> - static int AtomExecRaw ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> - Handle < String > subject , int index , int32_t * output , <nl> - int output_size ) ; <nl> - <nl> - static Handle < Object > AtomExec ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> - Handle < String > subject , int index , <nl> - Handle < RegExpMatchInfo > last_match_info ) ; <nl> - <nl> - / / Execute a regular expression on the subject , starting from index . <nl> - / / If matching succeeds , return the number of matches . This can be larger <nl> - / / than one in the case of global regular expressions . <nl> - / / The captures and subcaptures are stored into the registers vector . <nl> - / / If matching fails , returns RE_FAILURE . <nl> - / / If execution fails , sets a pending exception and returns RE_EXCEPTION . <nl> - static int IrregexpExecRaw ( Isolate * isolate , Handle < JSRegExp > regexp , <nl> - Handle < String > subject , int index , int32_t * output , <nl> - int output_size ) ; <nl> - <nl> - / / Execute an Irregexp bytecode pattern . <nl> - / / On a successful match , the result is a JSArray containing <nl> - / / captured positions . On a failure , the result is the null value . <nl> - / / Returns an empty handle in case of an exception . <nl> - V8_WARN_UNUSED_RESULT static MaybeHandle < Object > IrregexpExec ( <nl> - Isolate * isolate , Handle < JSRegExp > regexp , Handle < String > subject , <nl> - int index , Handle < RegExpMatchInfo > last_match_info ) ; <nl> - <nl> - static bool CompileIrregexp ( Isolate * isolate , Handle < JSRegExp > re , <nl> - Handle < String > sample_subject , bool is_one_byte ) ; <nl> - static inline bool EnsureCompiledIrregexp ( Isolate * isolate , <nl> - Handle < JSRegExp > re , <nl> - Handle < String > sample_subject , <nl> - bool is_one_byte ) ; <nl> - <nl> - / / Returns true on success , false on failure . <nl> - static bool Compile ( Isolate * isolate , Zone * zone , RegExpCompileData * input , <nl> - JSRegExp : : Flags flags , Handle < String > pattern , <nl> - Handle < String > sample_subject , bool is_one_byte ) ; <nl> - <nl> - / / For acting on the JSRegExp data FixedArray . <nl> - static int IrregexpMaxRegisterCount ( FixedArray re ) ; <nl> - static void SetIrregexpMaxRegisterCount ( FixedArray re , int value ) ; <nl> - static void SetIrregexpCaptureNameMap ( FixedArray re , <nl> - Handle < FixedArray > value ) ; <nl> - static int IrregexpNumberOfCaptures ( FixedArray re ) ; <nl> - static int IrregexpNumberOfRegisters ( FixedArray re ) ; <nl> - static ByteArray IrregexpByteCode ( FixedArray re , bool is_one_byte ) ; <nl> - static Code IrregexpNativeCode ( FixedArray re , bool is_one_byte ) ; <nl> - <nl> - friend class RegExpGlobalCache ; <nl> } ; <nl> <nl> / / Uses a special global mode of irregexp - generated code to perform a global <nl> class RegExpResultsCache final : public AllStatic { <nl> } / / namespace internal <nl> } / / namespace v8 <nl> <nl> - # endif / / V8_REGEXP_JSREGEXP_H_ <nl> + # endif / / V8_REGEXP_REGEXP_H_ <nl> mmm a / src / runtime / runtime - regexp . cc <nl> ppp b / src / runtime / runtime - regexp . cc <nl> <nl> # include " src / numbers / conversions - inl . h " <nl> # include " src / objects / js - array - inl . h " <nl> # include " src / objects / js - regexp - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> # include " src / regexp / regexp - utils . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / runtime / runtime - utils . h " <nl> # include " src / strings / string - builder - inl . h " <nl> # include " src / strings / string - search . h " <nl> V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalAtomRegExpWithString ( <nl> } <nl> <nl> int32_t match_indices [ ] = { indices - > back ( ) , indices - > back ( ) + pattern_len } ; <nl> - RegExpImpl : : SetLastMatchInfo ( isolate , last_match_info , subject , 0 , <nl> - match_indices ) ; <nl> + RegExp : : SetLastMatchInfo ( isolate , last_match_info , subject , 0 , match_indices ) ; <nl> <nl> TruncateRegexpIndicesList ( isolate ) ; <nl> <nl> V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalRegExpWithString ( <nl> JSRegExp : : Type typeTag = regexp - > TypeTag ( ) ; <nl> if ( typeTag = = JSRegExp : : IRREGEXP ) { <nl> / / Ensure the RegExp is compiled so we can access the capture - name map . <nl> - if ( RegExpImpl : : IrregexpPrepare ( isolate , regexp , subject ) = = - 1 ) { <nl> + if ( RegExp : : IrregexpPrepare ( isolate , regexp , subject ) = = - 1 ) { <nl> DCHECK ( isolate - > has_pending_exception ( ) ) ; <nl> return ReadOnlyRoots ( isolate ) . exception ( ) ; <nl> } <nl> V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalRegExpWithString ( <nl> builder . AddSubjectSlice ( prev , subject_length ) ; <nl> } <nl> <nl> - RegExpImpl : : SetLastMatchInfo ( isolate , last_match_info , subject , capture_count , <nl> - global_cache . LastSuccessfulMatch ( ) ) ; <nl> + RegExp : : SetLastMatchInfo ( isolate , last_match_info , subject , capture_count , <nl> + global_cache . LastSuccessfulMatch ( ) ) ; <nl> <nl> RETURN_RESULT_OR_FAILURE ( isolate , builder . ToString ( ) ) ; <nl> } <nl> V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalRegExpWithEmptyString ( <nl> <nl> if ( global_cache . HasException ( ) ) return ReadOnlyRoots ( isolate ) . exception ( ) ; <nl> <nl> - RegExpImpl : : SetLastMatchInfo ( isolate , last_match_info , subject , capture_count , <nl> - global_cache . LastSuccessfulMatch ( ) ) ; <nl> + RegExp : : SetLastMatchInfo ( isolate , last_match_info , subject , capture_count , <nl> + global_cache . LastSuccessfulMatch ( ) ) ; <nl> <nl> if ( prev < subject_length ) { <nl> / / Add substring subject [ prev ; length ] to answer string . <nl> RUNTIME_FUNCTION ( Runtime_RegExpExec ) { <nl> CHECK_LE ( 0 , index ) ; <nl> CHECK_GE ( subject - > length ( ) , index ) ; <nl> isolate - > counters ( ) - > regexp_entry_runtime ( ) - > Increment ( ) ; <nl> - RETURN_RESULT_OR_FAILURE ( isolate , RegExpImpl : : Exec ( isolate , regexp , subject , <nl> - index , last_match_info ) ) ; <nl> + RETURN_RESULT_OR_FAILURE ( <nl> + isolate , RegExp : : Exec ( isolate , regexp , subject , index , last_match_info ) ) ; <nl> } <nl> <nl> namespace { <nl> static Object SearchRegExpMultiple ( Isolate * isolate , Handle < String > subject , <nl> isolate - > factory ( ) - > CopyFixedArrayWithMap ( <nl> cached_fixed_array , isolate - > factory ( ) - > fixed_array_map ( ) ) ; <nl> JSArray : : SetContent ( result_array , copied_fixed_array ) ; <nl> - RegExpImpl : : SetLastMatchInfo ( isolate , last_match_array , subject , <nl> - capture_count , last_match ) ; <nl> + RegExp : : SetLastMatchInfo ( isolate , last_match_array , subject , <nl> + capture_count , last_match ) ; <nl> DeleteArray ( last_match ) ; <nl> return * result_array ; <nl> } <nl> static Object SearchRegExpMultiple ( Isolate * isolate , Handle < String > subject , <nl> subject_length ) ; <nl> } <nl> <nl> - RegExpImpl : : SetLastMatchInfo ( isolate , last_match_array , subject , <nl> - capture_count , <nl> - global_cache . LastSuccessfulMatch ( ) ) ; <nl> + RegExp : : SetLastMatchInfo ( isolate , last_match_array , subject , capture_count , <nl> + global_cache . LastSuccessfulMatch ( ) ) ; <nl> <nl> if ( subject_length > kMinLengthToCache ) { <nl> / / Store the last successful match into the array for caching . <nl> V8_WARN_UNUSED_RESULT MaybeHandle < String > RegExpReplace ( <nl> / / A lastIndex exceeding the string length always returns null ( signalling <nl> / / failure ) in RegExpBuiltinExec , thus we can skip the call . <nl> if ( last_index < = static_cast < uint32_t > ( string - > length ( ) ) ) { <nl> - ASSIGN_RETURN_ON_EXCEPTION ( isolate , match_indices_obj , <nl> - RegExpImpl : : Exec ( isolate , regexp , string , <nl> - last_index , last_match_info ) , <nl> - String ) ; <nl> + ASSIGN_RETURN_ON_EXCEPTION ( <nl> + isolate , match_indices_obj , <nl> + RegExp : : Exec ( isolate , regexp , string , last_index , last_match_info ) , <nl> + String ) ; <nl> } <nl> <nl> if ( match_indices_obj - > IsNull ( isolate ) ) { <nl> RUNTIME_FUNCTION ( Runtime_StringReplaceNonGlobalRegExpWithFunction ) { <nl> if ( last_index < = static_cast < uint32_t > ( subject - > length ( ) ) ) { <nl> ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> isolate , match_indices_obj , <nl> - RegExpImpl : : Exec ( isolate , regexp , subject , last_index , <nl> - last_match_info ) ) ; <nl> + RegExp : : Exec ( isolate , regexp , subject , last_index , last_match_info ) ) ; <nl> } <nl> <nl> if ( match_indices_obj - > IsNull ( isolate ) ) { <nl> mmm a / test / cctest / heap / test - heap . cc <nl> ppp b / test / cctest / heap / test - heap . cc <nl> <nl> # include " src / objects / objects - inl . h " <nl> # include " src / objects / slots . h " <nl> # include " src / objects / transitions . h " <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / snapshot / snapshot . h " <nl> # include " src / utils / ostreams . h " <nl> # include " test / cctest / cctest . h " <nl> TEST ( TestSizeOfRegExpCode ) { <nl> LocalContext context ; <nl> <nl> / / Adjust source below and this check to match <nl> - / / RegExpImple : : kRegExpTooLargeToOptimize . <nl> - CHECK_EQ ( i : : RegExpImpl : : kRegExpTooLargeToOptimize , 20 * KB ) ; <nl> + / / RegExp : : kRegExpTooLargeToOptimize . <nl> + CHECK_EQ ( i : : RegExp : : kRegExpTooLargeToOptimize , 20 * KB ) ; <nl> <nl> / / Compile a regexp that is much larger if we are using regexp optimizations . <nl> CompileRun ( <nl> mmm a / test / cctest / test - regexp . cc <nl> ppp b / test / cctest / test - regexp . cc <nl> <nl> # include " src / codegen / macro - assembler . h " <nl> # include " src / init / v8 . h " <nl> # include " src / objects / objects - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> # include " src / regexp / regexp - compiler . h " <nl> # include " src / regexp / regexp - interpreter . h " <nl> # include " src / regexp / regexp - macro - assembler - arch . h " <nl> # include " src / regexp / regexp - macro - assembler - irregexp . h " <nl> # include " src / regexp / regexp - parser . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " src / strings / char - predicates - inl . h " <nl> # include " src / strings / string - stream . h " <nl> # include " src / strings / unicode - inl . h " <nl> static RegExpNode * Compile ( const char * input , bool multiline , bool unicode , <nl> . ToHandleChecked ( ) ; <nl> Handle < String > sample_subject = <nl> isolate - > factory ( ) - > NewStringFromUtf8 ( CStrVector ( " " ) ) . ToHandleChecked ( ) ; <nl> - RegExpImpl : : CompileForTesting ( isolate , zone , & compile_data , flags , pattern , <nl> - sample_subject , is_one_byte ) ; <nl> + RegExp : : CompileForTesting ( isolate , zone , & compile_data , flags , pattern , <nl> + sample_subject , is_one_byte ) ; <nl> return compile_data . node ; <nl> } <nl> <nl> static void Execute ( const char * input , bool multiline , bool unicode , <nl> USE ( node ) ; <nl> # ifdef DEBUG <nl> if ( dot_output ) { <nl> - RegExpImpl : : DotPrintForTesting ( input , node , false ) ; <nl> + RegExp : : DotPrintForTesting ( input , node , false ) ; <nl> } <nl> # endif / / DEBUG <nl> } <nl> mmm a / test / fuzzer / regexp - builtins . cc <nl> ppp b / test / fuzzer / regexp - builtins . cc <nl> <nl> # include " include / v8 . h " <nl> # include " src / heap / factory . h " <nl> # include " src / objects / objects - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " test / fuzzer / fuzzer - support . h " <nl> <nl> / / This is a hexdump of test / fuzzer / regexp_builtins / mjsunit . js generated using <nl> mmm a / test / fuzzer / regexp . cc <nl> ppp b / test / fuzzer / regexp . cc <nl> <nl> # include " include / v8 . h " <nl> # include " src / heap / factory . h " <nl> # include " src / objects / objects - inl . h " <nl> - # include " src / regexp / jsregexp . h " <nl> + # include " src / regexp / regexp . h " <nl> # include " test / fuzzer / fuzzer - support . h " <nl> <nl> namespace i = v8 : : internal ; <nl> void Test ( v8 : : Isolate * isolate , i : : Handle < i : : JSRegExp > regexp , <nl> i : : Handle < i : : RegExpMatchInfo > results_array ) { <nl> v8 : : TryCatch try_catch ( isolate ) ; <nl> i : : Isolate * i_isolate = reinterpret_cast < i : : Isolate * > ( isolate ) ; <nl> - if ( i : : RegExpImpl : : Exec ( i_isolate , regexp , subject , 0 , results_array ) <nl> - . is_null ( ) ) { <nl> + if ( i : : RegExp : : Exec ( i_isolate , regexp , subject , 0 , results_array ) . is_null ( ) ) { <nl> i_isolate - > OptionalRescheduleException ( true ) ; <nl> } <nl> } <nl> | [ regexp ] Further narrow public API and restrict includes to regexp . h | v8/v8 | a8c62102e195ae6387742cdc40333decc85c8b95 | 2019-06-18T12:23:16Z |
mmm a / trunk / src / rtmp / srs_protocol_rtmp . cpp <nl> ppp b / trunk / src / rtmp / srs_protocol_rtmp . cpp <nl> SrsRtmpServer : : ~ SrsRtmpServer ( ) <nl> srs_freep ( hs_bytes ) ; <nl> } <nl> <nl> - SrsProtocol * SrsRtmpServer : : get_protocol ( ) <nl> - { <nl> - return protocol ; <nl> - } <nl> - <nl> void SrsRtmpServer : : set_recv_timeout ( int64_t timeout_us ) <nl> { <nl> protocol - > set_recv_timeout ( timeout_us ) ; <nl> mmm a / trunk / src / rtmp / srs_protocol_rtmp . hpp <nl> ppp b / trunk / src / rtmp / srs_protocol_rtmp . hpp <nl> class SrsRtmpClient <nl> public : <nl> SrsRtmpClient ( ISrsProtocolReaderWriter * skt ) ; <nl> virtual ~ SrsRtmpClient ( ) ; <nl> + / / protocol methods proxy <nl> public : <nl> + / * * <nl> + * set the recv timeout in us . <nl> + * if timeout , recv / send message return ERROR_SOCKET_TIMEOUT . <nl> + * / <nl> virtual void set_recv_timeout ( int64_t timeout_us ) ; <nl> + / * * <nl> + * set the send timeout in us . <nl> + * if timeout , recv / send message return ERROR_SOCKET_TIMEOUT . <nl> + * / <nl> virtual void set_send_timeout ( int64_t timeout_us ) ; <nl> + / * * <nl> + * get recv / send bytes . <nl> + * / <nl> virtual int64_t get_recv_bytes ( ) ; <nl> virtual int64_t get_send_bytes ( ) ; <nl> + / * * <nl> + * recv a RTMP message , which is bytes oriented . <nl> + * user can use decode_message to get the decoded RTMP packet . <nl> + * @ param pmsg , set the received message , <nl> + * always NULL if error , <nl> + * NULL for unknown packet but return success . <nl> + * never NULL if decode success . <nl> + * @ remark , drop message when msg is empty or payload length is empty . <nl> + * / <nl> virtual int recv_message ( SrsMessage * * pmsg ) ; <nl> + / * * <nl> + * decode bytes oriented RTMP message to RTMP packet , <nl> + * @ param ppacket , output decoded packet , <nl> + * always NULL if error , never NULL if success . <nl> + * @ return error when unknown packet , error when decode failed . <nl> + * / <nl> virtual int decode_message ( SrsMessage * msg , SrsPacket * * ppacket ) ; <nl> + / * * <nl> + * send the RTMP message and always free it . <nl> + * user must never free or use the msg after this method , <nl> + * for it will always free the msg . <nl> + * @ param msg , the msg to send out , never be NULL . <nl> + * @ param stream_id , the stream id of packet to send over , 0 for control message . <nl> + * / <nl> virtual int send_and_free_message ( SrsMessage * msg , int stream_id ) ; <nl> + / * * <nl> + * send the RTMP packet and always free it . <nl> + * user must never free or use the packet after this method , <nl> + * for it will always free the packet . <nl> + * @ param packet , the packet to send out , never be NULL . <nl> + * @ param stream_id , the stream id of packet to send over , 0 for control message . <nl> + * / <nl> virtual int send_and_free_packet ( SrsPacket * packet , int stream_id ) ; <nl> public : <nl> - / / try complex , then simple handshake . <nl> + / * * <nl> + * handshake with server , try complex , then simple handshake . <nl> + * / <nl> virtual int handshake ( ) ; <nl> - / / only use simple handshake <nl> + / * * <nl> + * only use simple handshake <nl> + * / <nl> virtual int simple_handshake ( ) ; <nl> - / / only use complex handshake <nl> + / * * <nl> + * only use complex handshake <nl> + * / <nl> virtual int complex_handshake ( ) ; <nl> - / / set req to use the original request of client : <nl> - / / pageUrl and swfUrl for refer antisuck . <nl> - / / args for edge to origin traverse auth , @ see SrsRequest . args <nl> + / * * <nl> + * set req to use the original request of client : <nl> + * pageUrl and swfUrl for refer antisuck . <nl> + * args for edge to origin traverse auth , @ see SrsRequest . args <nl> + * / <nl> virtual int connect_app ( std : : string app , std : : string tc_url , SrsRequest * req = NULL ) ; <nl> + / * * <nl> + * create a stream , then play / publish data over this stream . <nl> + * / <nl> virtual int create_stream ( int & stream_id ) ; <nl> + / * * <nl> + * start play stream . <nl> + * / <nl> virtual int play ( std : : string stream , int stream_id ) ; <nl> - / / flash publish schema : <nl> - / / connect - app = > create - stream = > flash - publish <nl> + / * * <nl> + * start publish stream . use flash publish workflow : <nl> + * connect - app = > create - stream = > flash - publish <nl> + * / <nl> virtual int publish ( std : : string stream , int stream_id ) ; <nl> - / / FMLE publish schema : <nl> - / / connect - app = > FMLE publish <nl> + / * * <nl> + * start publish stream . use FMLE publish workflow : <nl> + * connect - app = > FMLE publish <nl> + * / <nl> virtual int fmle_publish ( std : : string stream , int & stream_id ) ; <nl> public : <nl> / * * <nl> class SrsRtmpServer <nl> public : <nl> SrsRtmpServer ( ISrsProtocolReaderWriter * skt ) ; <nl> virtual ~ SrsRtmpServer ( ) ; <nl> + / / protocol methods proxy <nl> public : <nl> - virtual SrsProtocol * get_protocol ( ) ; <nl> + / * * <nl> + * set / get the recv timeout in us . <nl> + * if timeout , recv / send message return ERROR_SOCKET_TIMEOUT . <nl> + * / <nl> virtual void set_recv_timeout ( int64_t timeout_us ) ; <nl> virtual int64_t get_recv_timeout ( ) ; <nl> + / * * <nl> + * set / get the send timeout in us . <nl> + * if timeout , recv / send message return ERROR_SOCKET_TIMEOUT . <nl> + * / <nl> virtual void set_send_timeout ( int64_t timeout_us ) ; <nl> virtual int64_t get_send_timeout ( ) ; <nl> + / * * <nl> + * get recv / send bytes . <nl> + * / <nl> virtual int64_t get_recv_bytes ( ) ; <nl> virtual int64_t get_send_bytes ( ) ; <nl> + / * * <nl> + * recv a RTMP message , which is bytes oriented . <nl> + * user can use decode_message to get the decoded RTMP packet . <nl> + * @ param pmsg , set the received message , <nl> + * always NULL if error , <nl> + * NULL for unknown packet but return success . <nl> + * never NULL if decode success . <nl> + * @ remark , drop message when msg is empty or payload length is empty . <nl> + * / <nl> virtual int recv_message ( SrsMessage * * pmsg ) ; <nl> + / * * <nl> + * decode bytes oriented RTMP message to RTMP packet , <nl> + * @ param ppacket , output decoded packet , <nl> + * always NULL if error , never NULL if success . <nl> + * @ return error when unknown packet , error when decode failed . <nl> + * / <nl> virtual int decode_message ( SrsMessage * msg , SrsPacket * * ppacket ) ; <nl> + / * * <nl> + * send the RTMP message and always free it . <nl> + * user must never free or use the msg after this method , <nl> + * for it will always free the msg . <nl> + * @ param msg , the msg to send out , never be NULL . <nl> + * @ param stream_id , the stream id of packet to send over , 0 for control message . <nl> + * / <nl> virtual int send_and_free_message ( SrsMessage * msg , int stream_id ) ; <nl> + / * * <nl> + * send the RTMP packet and always free it . <nl> + * user must never free or use the packet after this method , <nl> + * for it will always free the packet . <nl> + * @ param packet , the packet to send out , never be NULL . <nl> + * @ param stream_id , the stream id of packet to send over , 0 for control message . <nl> + * / <nl> virtual int send_and_free_packet ( SrsPacket * packet , int stream_id ) ; <nl> public : <nl> + / * * <nl> + * handshake with client , try complex then simple . <nl> + * / <nl> virtual int handshake ( ) ; <nl> + / * * <nl> + * do connect app with client , to discovery tcUrl . <nl> + * / <nl> virtual int connect_app ( SrsRequest * req ) ; <nl> + / * * <nl> + * set ack size to client , client will send ack - size for each ack window <nl> + * / <nl> virtual int set_window_ack_size ( int ack_size ) ; <nl> / * * <nl> * @ type : The sender can mark this message hard ( 0 ) , soft ( 1 ) , or dynamic ( 2 ) <nl> class SrsRtmpServer <nl> * @ param server_ip the ip of server . <nl> * / <nl> virtual int response_connect_app ( SrsRequest * req , const char * server_ip = NULL ) ; <nl> + / * * <nl> + * reject the connect app request . <nl> + * / <nl> virtual void response_connect_reject ( SrsRequest * req , const char * desc ) ; <nl> + / * * <nl> + * response client the onBWDone message . <nl> + * / <nl> virtual int on_bw_done ( ) ; <nl> / * * <nl> * recv some message to identify the client . <nl> mmm a / trunk / src / utest / srs_utest_protocol . cpp <nl> ppp b / trunk / src / utest / srs_utest_protocol . cpp <nl> VOID TEST ( ProtocolStackTest , ProtocolPingFlow ) <nl> } <nl> } <nl> <nl> + / * * <nl> + * expect specified message <nl> + * / <nl> + VOID TEST ( ProtocolStackTest , ProtocolExcpectMessage ) <nl> + { <nl> + MockBufferIO bio ; <nl> + SrsProtocol proto ( & bio ) ; <nl> + <nl> + / / packet is SrsConnectAppPacket <nl> + char data [ ] = { <nl> + / / 12bytes header , 1byts chunk header , 11bytes msg heder <nl> + ( char ) 0x03 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x01 , ( char ) 0xa1 , ( char ) 0x14 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , <nl> + / / msg payload start <nl> + ( char ) 0x02 , ( char ) 0x00 , ( char ) 0x07 , ( char ) 0x63 , <nl> + ( char ) 0x6f , ( char ) 0x6e , ( char ) 0x6e , ( char ) 0x65 , ( char ) 0x63 , ( char ) 0x74 , ( char ) 0x00 , ( char ) 0x3f , ( char ) 0xf0 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x03 , <nl> + ( char ) 0x00 , ( char ) 0x03 , ( char ) 0x61 , ( char ) 0x70 , ( char ) 0x70 , ( char ) 0x02 , ( char ) 0x00 , ( char ) 0x04 , ( char ) 0x6c , ( char ) 0x69 , ( char ) 0x76 , ( char ) 0x65 , ( char ) 0x00 , ( char ) 0x08 , ( char ) 0x66 , ( char ) 0x6c , <nl> + ( char ) 0x61 , ( char ) 0x73 , ( char ) 0x68 , ( char ) 0x56 , ( char ) 0x65 , ( char ) 0x72 , ( char ) 0x02 , ( char ) 0x00 , ( char ) 0x0d , ( char ) 0x57 , ( char ) 0x49 , ( char ) 0x4e , ( char ) 0x20 , ( char ) 0x31 , ( char ) 0x32 , ( char ) 0x2c , <nl> + ( char ) 0x30 , ( char ) 0x2c , ( char ) 0x30 , ( char ) 0x2c , ( char ) 0x34 , ( char ) 0x31 , ( char ) 0x00 , ( char ) 0x06 , ( char ) 0x73 , ( char ) 0x77 , ( char ) 0x66 , ( char ) 0x55 , ( char ) 0x72 , ( char ) 0x6c , ( char ) 0x02 , ( char ) 0x00 , <nl> + ( char ) 0x51 , ( char ) 0x68 , ( char ) 0x74 , ( char ) 0x74 , ( char ) 0x70 , ( char ) 0x3a , ( char ) 0x2f , ( char ) 0x2f , ( char ) 0x77 , ( char ) 0x77 , ( char ) 0x77 , ( char ) 0x2e , ( char ) 0x6f , ( char ) 0x73 , ( char ) 0x73 , ( char ) 0x72 , <nl> + ( char ) 0x73 , ( char ) 0x2e , ( char ) 0x6e , ( char ) 0x65 , ( char ) 0x74 , ( char ) 0x3a , ( char ) 0x38 , ( char ) 0x30 , ( char ) 0x38 , ( char ) 0x35 , ( char ) 0x2f , ( char ) 0x70 , ( char ) 0x6c , ( char ) 0x61 , ( char ) 0x79 , ( char ) 0x65 , <nl> + ( char ) 0x72 , ( char ) 0x73 , ( char ) 0x2f , ( char ) 0x73 , ( char ) 0x72 , ( char ) 0x73 , ( char ) 0x5f , ( char ) 0x70 , ( char ) 0x6c , ( char ) 0x61 , ( char ) 0x79 , ( char ) 0x65 , ( char ) 0x72 , ( char ) 0x2f , ( char ) 0x72 , ( char ) 0x65 , <nl> + ( char ) 0x6c , ( char ) 0x65 , ( char ) 0x61 , ( char ) 0x73 , ( char ) 0x65 , ( char ) 0x2f , ( char ) 0x73 , ( char ) 0x72 , ( char ) 0x73 , ( char ) 0x5f , ( char ) 0x70 , ( char ) 0x6c , <nl> + ( char ) 0xC3 , / * next chunk . * / ( char ) 0x61 , ( char ) 0x79 , ( char ) 0x65 , ( char ) 0x72 , <nl> + ( char ) 0x2e , ( char ) 0x73 , ( char ) 0x77 , ( char ) 0x66 , ( char ) 0x3f , ( char ) 0x5f , ( char ) 0x76 , ( char ) 0x65 , ( char ) 0x72 , ( char ) 0x73 , ( char ) 0x69 , ( char ) 0x6f , ( char ) 0x6e , ( char ) 0x3d , ( char ) 0x31 , ( char ) 0x2e , <nl> + ( char ) 0x32 , ( char ) 0x33 , ( char ) 0x00 , ( char ) 0x05 , ( char ) 0x74 , ( char ) 0x63 , ( char ) 0x55 , ( char ) 0x72 , ( char ) 0x6c , ( char ) 0x02 , ( char ) 0x00 , ( char ) 0x14 , ( char ) 0x72 , ( char ) 0x74 , ( char ) 0x6d , ( char ) 0x70 , <nl> + ( char ) 0x3a , ( char ) 0x2f , ( char ) 0x2f , ( char ) 0x64 , ( char ) 0x65 , ( char ) 0x76 , ( char ) 0x3a , ( char ) 0x31 , ( char ) 0x39 , ( char ) 0x33 , ( char ) 0x35 , ( char ) 0x2f , ( char ) 0x6c , ( char ) 0x69 , ( char ) 0x76 , ( char ) 0x65 , <nl> + ( char ) 0x00 , ( char ) 0x04 , ( char ) 0x66 , ( char ) 0x70 , ( char ) 0x61 , ( char ) 0x64 , ( char ) 0x01 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x0c , ( char ) 0x63 , ( char ) 0x61 , ( char ) 0x70 , ( char ) 0x61 , ( char ) 0x62 , ( char ) 0x69 , <nl> + ( char ) 0x6c , ( char ) 0x69 , ( char ) 0x74 , ( char ) 0x69 , ( char ) 0x65 , ( char ) 0x73 , ( char ) 0x00 , ( char ) 0x40 , ( char ) 0x6d , ( char ) 0xe0 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , <nl> + ( char ) 0x0b , ( char ) 0x61 , ( char ) 0x75 , ( char ) 0x64 , ( char ) 0x69 , ( char ) 0x6f , ( char ) 0x43 , ( char ) 0x6f , ( char ) 0x64 , ( char ) 0x65 , ( char ) 0x63 , ( char ) 0x73 , ( char ) 0x00 , ( char ) 0x40 , ( char ) 0xab , ( char ) 0xee , <nl> + ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x0b , ( char ) 0x76 , ( char ) 0x69 , ( char ) 0x64 , ( char ) 0x65 , ( char ) 0x6f , ( char ) 0x43 , ( char ) 0x6f , ( char ) 0x64 , ( char ) 0x65 , <nl> + ( char ) 0x63 , ( char ) 0x73 , ( char ) 0x00 , ( char ) 0x40 , ( char ) 0x6f , ( char ) 0x80 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , <nl> + ( char ) 0xC3 , / * next chunk . * / ( char ) 0x0d , ( char ) 0x76 , ( char ) 0x69 , ( char ) 0x64 , <nl> + ( char ) 0x65 , ( char ) 0x6f , ( char ) 0x46 , ( char ) 0x75 , ( char ) 0x6e , ( char ) 0x63 , ( char ) 0x74 , ( char ) 0x69 , ( char ) 0x6f , ( char ) 0x6e , ( char ) 0x00 , ( char ) 0x3f , ( char ) 0xf0 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , <nl> + ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x07 , ( char ) 0x70 , ( char ) 0x61 , ( char ) 0x67 , ( char ) 0x65 , ( char ) 0x55 , ( char ) 0x72 , ( char ) 0x6c , ( char ) 0x02 , ( char ) 0x00 , ( char ) 0x62 , ( char ) 0x68 , <nl> + ( char ) 0x74 , ( char ) 0x74 , ( char ) 0x70 , ( char ) 0x3a , ( char ) 0x2f , ( char ) 0x2f , ( char ) 0x77 , ( char ) 0x77 , ( char ) 0x77 , ( char ) 0x2e , ( char ) 0x6f , ( char ) 0x73 , ( char ) 0x73 , ( char ) 0x72 , ( char ) 0x73 , ( char ) 0x2e , <nl> + ( char ) 0x6e , ( char ) 0x65 , ( char ) 0x74 , ( char ) 0x3a , ( char ) 0x38 , ( char ) 0x30 , ( char ) 0x38 , ( char ) 0x35 , ( char ) 0x2f , ( char ) 0x70 , ( char ) 0x6c , ( char ) 0x61 , ( char ) 0x79 , ( char ) 0x65 , ( char ) 0x72 , ( char ) 0x73 , <nl> + ( char ) 0x2f , ( char ) 0x73 , ( char ) 0x72 , ( char ) 0x73 , ( char ) 0x5f , ( char ) 0x70 , ( char ) 0x6c , ( char ) 0x61 , ( char ) 0x79 , ( char ) 0x65 , ( char ) 0x72 , ( char ) 0x2e , ( char ) 0x68 , ( char ) 0x74 , ( char ) 0x6d , ( char ) 0x6c , <nl> + ( char ) 0x3f , ( char ) 0x76 , ( char ) 0x68 , ( char ) 0x6f , ( char ) 0x73 , ( char ) 0x74 , ( char ) 0x3d , ( char ) 0x64 , ( char ) 0x65 , ( char ) 0x76 , ( char ) 0x26 , ( char ) 0x73 , ( char ) 0x74 , ( char ) 0x72 , ( char ) 0x65 , ( char ) 0x61 , <nl> + ( char ) 0x6d , ( char ) 0x3d , ( char ) 0x6c , ( char ) 0x69 , ( char ) 0x76 , ( char ) 0x65 , ( char ) 0x73 , ( char ) 0x74 , ( char ) 0x72 , ( char ) 0x65 , ( char ) 0x61 , ( char ) 0x6d , ( char ) 0x26 , ( char ) 0x73 , ( char ) 0x65 , ( char ) 0x72 , <nl> + ( char ) 0x76 , ( char ) 0x65 , ( char ) 0x72 , ( char ) 0x3d , ( char ) 0x64 , ( char ) 0x65 , ( char ) 0x76 , ( char ) 0x26 , ( char ) 0x70 , ( char ) 0x6f , ( char ) 0x72 , ( char ) 0x74 , <nl> + ( char ) 0xC3 , / * next chunk . * / ( char ) 0x3d , ( char ) 0x31 , ( char ) 0x39 , ( char ) 0x33 , <nl> + ( char ) 0x35 , ( char ) 0x00 , ( char ) 0x0e , ( char ) 0x6f , ( char ) 0x62 , ( char ) 0x6a , ( char ) 0x65 , ( char ) 0x63 , ( char ) 0x74 , ( char ) 0x45 , ( char ) 0x6e , ( char ) 0x63 , ( char ) 0x6f , ( char ) 0x64 , ( char ) 0x69 , ( char ) 0x6e , <nl> + ( char ) 0x67 , ( char ) 0x00 , ( char ) 0x40 , ( char ) 0x08 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x00 , ( char ) 0x09 <nl> + } ; <nl> + bio . in_buffer . append ( data , sizeof ( data ) ) ; <nl> + <nl> + SrsMessage * msg = NULL ; <nl> + SrsConnectAppPacket * pkt = NULL ; <nl> + ASSERT_TRUE ( ERROR_SUCCESS = = proto . expect_message < SrsConnectAppPacket > ( & msg , & pkt ) ) ; <nl> + SrsAutoFree ( SrsMessage , msg ) ; <nl> + SrsAutoFree ( SrsConnectAppPacket , pkt ) ; <nl> + ASSERT_TRUE ( NULL ! = pkt ) ; <nl> + } <nl> + <nl> VOID TEST ( ProtocolRTMPTest , RTMPRequest ) <nl> { <nl> SrsRequest req ; <nl> | refine rtmp client / server , add comments . | ossrs/srs | 047fb74889722ab0c65c3167830177415ee2fbc6 | 2014-07-12T01:01:34Z |
mmm a / tensorflow / compiler / tests / BUILD <nl> ppp b / tensorflow / compiler / tests / BUILD <nl> tf_xla_py_test ( <nl> <nl> tf_xla_py_test ( <nl> name = " cholesky_op_test " , <nl> - size = " small " , <nl> + size = " medium " , <nl> srcs = [ " cholesky_op_test . py " ] , <nl> tags = [ " optonly " ] , <nl> deps = [ <nl> tf_xla_py_test ( <nl> ] , <nl> ) <nl> <nl> + tf_xla_py_test ( <nl> + name = " qr_op_test " , <nl> + size = " medium " , <nl> + srcs = [ " qr_op_test . py " ] , <nl> + disabled_backends = [ <nl> + # Test is very slow on CPU . <nl> + " cpu " , <nl> + " cpu_ondemand " , <nl> + ] , <nl> + tags = [ " optonly " ] , <nl> + deps = [ <nl> + " : xla_test " , <nl> + " / / tensorflow / python : array_ops " , <nl> + " / / tensorflow / python : framework_for_generated_wrappers " , <nl> + " / / tensorflow / python : math_ops " , <nl> + " / / tensorflow / python : platform_test " , <nl> + " / / tensorflow / python : training " , <nl> + " @ absl_py / / absl / testing : parameterized " , <nl> + ] , <nl> + ) <nl> + <nl> tf_xla_py_test ( <nl> name = " random_ops_test " , <nl> size = " small " , <nl> new file mode 100644 <nl> index 0000000000000 . . 93752a21db4ab <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / tests / qr_op_test . py <nl> <nl> + # Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + # <nl> + # Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + # you may not use this file except in compliance with the License . <nl> + # You may obtain a copy of the License at <nl> + # <nl> + # http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + # <nl> + # Unless required by applicable law or agreed to in writing , software <nl> + # distributed under the License is distributed on an " AS IS " BASIS , <nl> + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + # See the License for the specific language governing permissions and <nl> + # limitations under the License . <nl> + # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = <nl> + " " " Tests for tensorflow . ops . math_ops . matrix_inverse . " " " <nl> + <nl> + from __future__ import absolute_import <nl> + from __future__ import division <nl> + from __future__ import print_function <nl> + <nl> + import itertools <nl> + <nl> + from absl . testing import parameterized <nl> + import numpy as np <nl> + <nl> + from tensorflow . compiler . tests import xla_test <nl> + from tensorflow . python . ops import array_ops <nl> + from tensorflow . python . ops import linalg_ops <nl> + from tensorflow . python . ops import math_ops <nl> + from tensorflow . python . platform import test <nl> + <nl> + <nl> + class QrOpTest ( xla_test . XLATestCase , parameterized . TestCase ) : <nl> + <nl> + def AdjustedNorm ( self , x ) : <nl> + " " " Computes the norm of matrices in ' x ' , adjusted for dimension and type . " " " <nl> + norm = np . linalg . norm ( x , axis = ( - 2 , - 1 ) ) <nl> + return norm / ( max ( x . shape [ - 2 : ] ) * np . finfo ( x . dtype ) . eps ) <nl> + <nl> + def CompareOrthogonal ( self , x , y , rank ) : <nl> + # We only compare the first ' rank ' orthogonal vectors since the <nl> + # remainder form an arbitrary orthonormal basis for the <nl> + # ( row - or column - ) null space , whose exact value depends on <nl> + # implementation details . Notice that since we check that the <nl> + # matrices of singular vectors are unitary elsewhere , we do <nl> + # implicitly test that the trailing vectors of x and y span the <nl> + # same space . <nl> + x = x [ . . . , 0 : rank ] <nl> + y = y [ . . . , 0 : rank ] <nl> + # Q is only unique up to sign ( complex phase factor for complex matrices ) , <nl> + # so we normalize the sign first . <nl> + sum_of_ratios = np . sum ( np . divide ( y , x ) , - 2 , keepdims = True ) <nl> + phases = np . divide ( sum_of_ratios , np . abs ( sum_of_ratios ) ) <nl> + x * = phases <nl> + self . assertTrue ( np . all ( self . AdjustedNorm ( x - y ) < 30 . 0 ) ) <nl> + <nl> + def CheckApproximation ( self , a , q , r ) : <nl> + # Tests that a ~ = q * r . <nl> + precision = self . AdjustedNorm ( a - np . matmul ( q , r ) ) <nl> + self . assertTrue ( np . all ( precision < 5 . 0 ) ) <nl> + <nl> + def CheckUnitary ( self , x ) : <nl> + # Tests that x [ . . . , : , : ] ^ H * x [ . . . , : , : ] is close to the identity . <nl> + xx = math_ops . matmul ( x , x , adjoint_a = True ) <nl> + identity = array_ops . matrix_band_part ( array_ops . ones_like ( xx ) , 0 , 0 ) <nl> + precision = self . AdjustedNorm ( xx . eval ( ) - identity . eval ( ) ) <nl> + self . assertTrue ( np . all ( precision < 5 . 0 ) ) <nl> + <nl> + def _test ( self , dtype , shape , full_matrices ) : <nl> + np . random . seed ( 1 ) <nl> + x_np = np . random . uniform ( <nl> + low = - 1 . 0 , high = 1 . 0 , size = np . prod ( shape ) ) . reshape ( shape ) . astype ( dtype ) <nl> + <nl> + with self . test_session ( ) as sess : <nl> + x_tf = array_ops . placeholder ( dtype ) <nl> + with self . test_scope ( ) : <nl> + q_tf , r_tf = linalg_ops . qr ( x_tf , full_matrices = full_matrices ) <nl> + q_tf_val , r_tf_val = sess . run ( [ q_tf , r_tf ] , feed_dict = { x_tf : x_np } ) <nl> + <nl> + q_dims = q_tf_val . shape <nl> + np_q = np . ndarray ( q_dims , dtype ) <nl> + np_q_reshape = np . reshape ( np_q , ( - 1 , q_dims [ - 2 ] , q_dims [ - 1 ] ) ) <nl> + new_first_dim = np_q_reshape . shape [ 0 ] <nl> + <nl> + x_reshape = np . reshape ( x_np , ( - 1 , x_np . shape [ - 2 ] , x_np . shape [ - 1 ] ) ) <nl> + for i in range ( new_first_dim ) : <nl> + if full_matrices : <nl> + np_q_reshape [ i , : , : ] , _ = np . linalg . qr ( <nl> + x_reshape [ i , : , : ] , mode = " complete " ) <nl> + else : <nl> + np_q_reshape [ i , : , : ] , _ = np . linalg . qr ( <nl> + x_reshape [ i , : , : ] , mode = " reduced " ) <nl> + np_q = np . reshape ( np_q_reshape , q_dims ) <nl> + self . CompareOrthogonal ( np_q , q_tf_val , min ( shape [ - 2 : ] ) ) <nl> + self . CheckApproximation ( x_np , q_tf_val , r_tf_val ) <nl> + self . CheckUnitary ( q_tf_val ) <nl> + <nl> + SIZES = [ 1 , 2 , 5 , 10 , 32 , 100 , 300 ] <nl> + DTYPES = [ np . float32 ] <nl> + PARAMS = itertools . product ( SIZES , SIZES , DTYPES ) <nl> + <nl> + @ parameterized . parameters ( * PARAMS ) <nl> + def testQR ( self , rows , cols , dtype ) : <nl> + # TODO ( b / 111317468 ) : implement full_matrices = False , test other types . <nl> + for full_matrices in [ True ] : <nl> + # Only tests the ( 3 , 2 ) case for small numbers of rows / columns . <nl> + for batch_dims in [ ( ) , ( 3 , ) ] + [ ( 3 , 2 ) ] * ( max ( rows , cols ) < 10 ) : <nl> + self . _test ( dtype , batch_dims + ( rows , cols ) , full_matrices ) <nl> + <nl> + <nl> + if __name__ = = " __main__ " : <nl> + test . main ( ) <nl> mmm a / tensorflow / compiler / tf2xla / kernels / BUILD <nl> ppp b / tensorflow / compiler / tf2xla / kernels / BUILD <nl> tf_kernel_library ( <nl> " pack_op . cc " , <nl> " pad_op . cc " , <nl> " pooling_ops . cc " , <nl> + " qr_op . cc " , <nl> " quantize_and_dequantize_op . cc " , <nl> " random_ops . cc " , <nl> " reduce_window_op . cc " , <nl> tf_kernel_library ( <nl> " / / tensorflow / compiler / tf2xla : xla_compiler " , <nl> " / / tensorflow / compiler / tf2xla / lib : batch_dot " , <nl> " / / tensorflow / compiler / tf2xla / lib : cholesky " , <nl> + " / / tensorflow / compiler / tf2xla / lib : qr " , <nl> " / / tensorflow / compiler / tf2xla / lib : random " , <nl> " / / tensorflow / compiler / tf2xla / lib : scatter " , <nl> " / / tensorflow / compiler / tf2xla / lib : triangular_solve " , <nl> new file mode 100644 <nl> index 0000000000000 . . de9068a640dc0 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / tf2xla / kernels / qr_op . cc <nl> <nl> + / * Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / compiler / tf2xla / lib / qr . h " <nl> + # include " tensorflow / compiler / tf2xla / xla_op_kernel . h " <nl> + # include " tensorflow / compiler / tf2xla / xla_op_registry . h " <nl> + <nl> + namespace tensorflow { <nl> + namespace { <nl> + <nl> + class QROp : public XlaOpKernel { <nl> + public : <nl> + explicit QROp ( OpKernelConstruction * ctx ) : XlaOpKernel ( ctx ) { <nl> + bool full_matrices ; <nl> + OP_REQUIRES_OK ( ctx , ctx - > GetAttr ( " full_matrices " , & full_matrices ) ) ; <nl> + OP_REQUIRES ( <nl> + ctx , full_matrices , <nl> + errors : : Unimplemented ( " full_matrices = False case of QR decomposition is " <nl> + " not implemented in TF / XLA " ) ) ; <nl> + } <nl> + void Compile ( XlaOpKernelContext * ctx ) override { <nl> + auto result = QRDecomposition ( ctx - > Input ( 0 ) ) ; <nl> + if ( ! result . ok ( ) ) { <nl> + ctx - > SetStatus ( result . status ( ) ) ; <nl> + return ; <nl> + } <nl> + ctx - > SetOutput ( 0 , result . ValueOrDie ( ) . q ) ; <nl> + ctx - > SetOutput ( 1 , result . ValueOrDie ( ) . r ) ; <nl> + } <nl> + } ; <nl> + <nl> + REGISTER_XLA_OP ( Name ( " Qr " ) . TypeConstraint ( " T " , kFloatTypes ) , QROp ) ; <nl> + <nl> + } / / namespace <nl> + } / / namespace tensorflow <nl> mmm a / tensorflow / compiler / tf2xla / lib / BUILD <nl> ppp b / tensorflow / compiler / tf2xla / lib / BUILD <nl> cc_library ( <nl> ] , <nl> ) <nl> <nl> + cc_library ( <nl> + name = " qr " , <nl> + srcs = [ " qr . cc " ] , <nl> + hdrs = [ " qr . h " ] , <nl> + deps = [ <nl> + " : batch_dot " , <nl> + " : util " , <nl> + " : while_loop " , <nl> + " / / tensorflow / compiler / xla : literal_util " , <nl> + " / / tensorflow / compiler / xla : shape_util " , <nl> + " / / tensorflow / compiler / xla : status_macros " , <nl> + " / / tensorflow / compiler / xla : statusor " , <nl> + " / / tensorflow / compiler / xla / client / lib : arithmetic " , <nl> + " / / tensorflow / compiler / xla / client / lib : constants " , <nl> + " / / tensorflow / compiler / xla / client / lib : math " , <nl> + " / / tensorflow / compiler / xla / client / lib : numeric " , <nl> + " / / tensorflow / compiler / xla / client / xla_client : xla_builder " , <nl> + " / / tensorflow / compiler / xla / client / xla_client : xla_computation " , <nl> + " / / tensorflow / core : lib " , <nl> + ] , <nl> + ) <nl> + <nl> cc_library ( <nl> name = " scatter " , <nl> srcs = [ " scatter . cc " ] , <nl> new file mode 100644 <nl> index 0000000000000 . . 9c8ac7af25e42 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / tf2xla / lib / qr . cc <nl> <nl> + / * Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # include " tensorflow / compiler / tf2xla / lib / qr . h " <nl> + <nl> + # include < memory > <nl> + # include < vector > <nl> + <nl> + # include " tensorflow / compiler / tf2xla / lib / batch_dot . h " <nl> + # include " tensorflow / compiler / tf2xla / lib / util . h " <nl> + # include " tensorflow / compiler / tf2xla / lib / while_loop . h " <nl> + # include " tensorflow / compiler / xla / client / lib / arithmetic . h " <nl> + # include " tensorflow / compiler / xla / client / lib / constants . h " <nl> + # include " tensorflow / compiler / xla / client / lib / math . h " <nl> + # include " tensorflow / compiler / xla / client / lib / numeric . h " <nl> + # include " tensorflow / compiler / xla / client / xla_client / xla_builder . h " <nl> + # include " tensorflow / compiler / xla / literal_util . h " <nl> + # include " tensorflow / compiler / xla / shape_util . h " <nl> + # include " tensorflow / compiler / xla / status_macros . h " <nl> + # include " tensorflow / compiler / xla / statusor . h " <nl> + # include " tensorflow / core / lib / core / errors . h " <nl> + <nl> + namespace tensorflow { <nl> + <nl> + namespace { <nl> + <nl> + / / Computes a Householder reflection of the form : <nl> + / / H = I - tau v v . T . <nl> + / / such that <nl> + / / H . ( x1 ) = ( x1 ) <nl> + / / ( x2 ) = ( x2 ) <nl> + / / ( . . . ) = ( . . . ) <nl> + / / ( xk ) = ( beta ) <nl> + / / ( . . . ) ( 0 ) <nl> + / / ( . . . ) ( 0 ) <nl> + / / Unlike the usual formulation , we allow the caller to supply ' k ' rather than <nl> + / / only providing the relevant part of ' x ' to maintain XLA ' s static shape <nl> + / / invariant . In addition , the implementation supports batching . <nl> + / / Pseudo - code , without batching : <nl> + / / alpha = x [ k ] <nl> + / / x_copy = np . copy ( x ) <nl> + / / x_copy [ : k + 1 ] = 0 <nl> + / / xnorm = norm2 ( x_copy ) <nl> + / / if xnorm = = 0 : <nl> + / / beta = alpha <nl> + / / tau = 0 <nl> + / / v = np . zeros_like ( x ) <nl> + / / else : <nl> + / / beta = - np . sign ( alpha ) * dlapy2 ( alpha , xnorm ) <nl> + / / tau = ( beta - alpha ) / beta <nl> + / / v = x / ( alpha - beta ) <nl> + / / v [ k ] = 1 <nl> + / / return ( v , tau , beta ) <nl> + / / TODO ( phawkins ) : LAPACK ' s xLARFG implementation has code for handling <nl> + / / overflows in the norm / beta calculations . Perhaps do the same here . <nl> + xla : : Status House ( xla : : XlaOp x , xla : : XlaOp k , gtl : : ArraySlice < int64 > batch_dims , <nl> + const int64 m , xla : : XlaOp * v , xla : : XlaOp * tau , <nl> + xla : : XlaOp * beta ) { <nl> + xla : : XlaBuilder * const builder = x . builder ( ) ; <nl> + TF_ASSIGN_OR_RETURN ( xla : : Shape x_shape , builder - > GetShape ( x ) ) ; <nl> + const xla : : PrimitiveType type = x_shape . element_type ( ) ; <nl> + <nl> + std : : vector < int64 > batch_dim_ids ( batch_dims . size ( ) ) ; <nl> + std : : iota ( batch_dim_ids . begin ( ) , batch_dim_ids . end ( ) , 0 ) ; <nl> + const int64 minor_dim = batch_dims . size ( ) ; <nl> + <nl> + xla : : XlaOp zero = xla : : ScalarLike ( x , 0 . 0 ) ; <nl> + xla : : XlaOp one = xla : : ScalarLike ( x , 1 . 0 ) ; <nl> + <nl> + / / alpha = x [ k ] <nl> + xla : : XlaOp alpha = <nl> + xla : : Reshape ( DynamicSliceInMinorDims ( x , { k } , { 1 } ) , batch_dims ) ; <nl> + <nl> + / / Compute x [ k + 1 : ] ( padded with zeros in elements 0 . . k ) <nl> + xla : : XlaOp iota = xla : : Iota ( builder , xla : : S32 , m ) ; <nl> + xla : : XlaOp x_after_k = <nl> + xla : : Mul ( x , xla : : ConvertElementType ( xla : : Gt ( iota , k ) , type ) , <nl> + / * broadcast_dimensions = * / { minor_dim } ) ; <nl> + <nl> + / / sigma = np . dot ( x [ k + 1 : ] , x [ k + 1 : ] ) <nl> + auto sigma = <nl> + xla : : Reduce ( x_after_k * x_after_k , zero , <nl> + xla : : CreateScalarAddComputation ( type , builder ) , { minor_dim } ) ; <nl> + / / mu = np . sqrt ( x [ k ] * x [ k ] + sigma ) <nl> + auto mu = xla : : Sqrt ( xla : : Square ( alpha ) + sigma ) ; <nl> + <nl> + auto sigma_is_zero = xla : : Eq ( sigma , zero ) ; <nl> + <nl> + * beta = xla : : Select ( sigma_is_zero , alpha , - xla : : Sign ( alpha ) * mu ) ; <nl> + * tau = xla : : Select ( sigma_is_zero , xla : : Broadcast ( zero , batch_dims ) , <nl> + ( * beta - alpha ) / * beta ) ; <nl> + auto divisor = xla : : Select ( sigma_is_zero , xla : : Broadcast ( one , batch_dims ) , <nl> + alpha - * beta ) ; <nl> + <nl> + auto e_k = xla : : Broadcast ( xla : : ConvertElementType ( xla : : Eq ( iota , k ) , type ) , <nl> + std : : vector < int64 > ( batch_dims . size ( ) , 1 ) ) ; <nl> + <nl> + / / Form v as [ 0 , 0 , . . . , 1 ] + + x [ k + 1 : ] / divisor <nl> + / / If sigma is zero , x [ k + 1 : ] is zero , so use any non - zero divisor . <nl> + * v = e_k + <nl> + xla : : Div ( x_after_k , divisor , / * broadcast_dimensions = * / batch_dim_ids ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + / / Householder QR decomposition . Algorithm 5 . 2 . 1 from Golub and Van <nl> + / / Loan " Matrix Computations " , 4th Edition . This is an unblocked implementation <nl> + / / used as an inner routine of the blocked implementation . <nl> + / / Algorithm is adapted slightly so the shapes inside the loop are static , at <nl> + / / the cost of some redundant computation . Since this is used as an inner block <nl> + / / kernel , accumulates the Householder transformations ( vs , taus ) rather than <nl> + / / the matrix q . <nl> + / / Equivalent Python code , without batching : <nl> + / / def qr ( a ) : <nl> + / / m = a . shape [ 0 ] <nl> + / / n = a . shape [ 1 ] <nl> + / / vs = np . zeros ( [ m , n ] ) <nl> + / / taus = np . zeros ( [ n ] ) <nl> + / / for j in xrange ( min ( m , n ) ) : <nl> + / / v , tau , beta = house ( a [ : , j ] , j ) <nl> + / / # Unusually , we apply the Householder transformation to the entirety of <nl> + / / # a , wasting FLOPs to maintain the static shape invariant that XLA <nl> + / / # requires . For columns that precede j this has no effect . <nl> + / / a [ : , : ] - = tau * np . dot ( v [ : , np . newaxis ] , <nl> + / / np . dot ( v [ np . newaxis , : ] , a [ : , : ] ) ) <nl> + / / # Form column j explicitly rather than relying on the precision of the <nl> + / / # Householder update . <nl> + / / a [ j , j ] = beta <nl> + / / a [ j + 1 : , j ] = np . zeros ( [ m - j - 1 ] , dtype = a . dtype ) <nl> + / / vs [ : , j ] = v <nl> + / / taus [ j ] = tau <nl> + / / return ( q , vs , taus ) <nl> + struct QRBlockResult { <nl> + / / The factored R value <nl> + xla : : XlaOp r ; <nl> + <nl> + / / Representation of the Householder matrices I - beta v v . T <nl> + xla : : XlaOp taus ; / / Shape : [ . . . , n ] <nl> + xla : : XlaOp vs ; / / Shape : [ . . . , m , n ] <nl> + } ; <nl> + xla : : StatusOr < QRBlockResult > QRBlock ( xla : : XlaOp a ) { <nl> + xla : : XlaBuilder * builder = a . builder ( ) ; <nl> + TF_ASSIGN_OR_RETURN ( xla : : Shape a_shape , builder - > GetShape ( a ) ) ; <nl> + const int num_dims = xla : : ShapeUtil : : Rank ( a_shape ) ; <nl> + if ( num_dims < 2 ) { <nl> + return errors : : InvalidArgument ( " Arguments to QR must have rank > = 2 : " , <nl> + num_dims ) ; <nl> + } <nl> + xla : : PrimitiveType type = a_shape . element_type ( ) ; <nl> + <nl> + const int64 m = xla : : ShapeUtil : : GetDimension ( a_shape , - 2 ) ; <nl> + const int64 n = xla : : ShapeUtil : : GetDimension ( a_shape , - 1 ) ; <nl> + <nl> + const int64 num_batch_dims = num_dims - 2 ; <nl> + std : : vector < int64 > batch_dims ( num_batch_dims ) ; <nl> + for ( int i = 0 ; i < num_batch_dims ; + + i ) { <nl> + batch_dims [ i ] = xla : : ShapeUtil : : GetDimension ( a_shape , i ) ; <nl> + } <nl> + <nl> + std : : vector < int64 > batch_dim_indices ( num_batch_dims ) ; <nl> + std : : iota ( batch_dim_indices . begin ( ) , batch_dim_indices . end ( ) , 0 ) ; <nl> + <nl> + auto qr_body_fn = <nl> + [ & ] ( xla : : XlaOp j , gtl : : ArraySlice < xla : : XlaOp > values , <nl> + xla : : XlaBuilder * builder ) - > xla : : StatusOr < std : : vector < xla : : XlaOp > > { <nl> + auto a = values [ 0 ] ; <nl> + auto vs = values [ 1 ] ; <nl> + auto taus = values [ 2 ] ; <nl> + <nl> + / / v , beta = house ( a [ : , j ] , j ) <nl> + auto x = DynamicSliceInMinorDims ( a , { j } , { 1 } ) ; <nl> + xla : : XlaOp v , tau , beta ; <nl> + TF_RETURN_IF_ERROR ( House ( xla : : Collapse ( x , { num_dims - 2 , num_dims - 1 } ) , j , <nl> + batch_dims , m , & v , & tau , & beta ) ) ; <nl> + <nl> + std : : vector < int64 > shape = batch_dims ; <nl> + shape . push_back ( 1 ) ; <nl> + shape . push_back ( m ) ; <nl> + auto v_broadcast = xla : : Reshape ( v , shape ) ; <nl> + / / a [ : , : ] - = tau * np . dot ( v [ : , np . newaxis ] , <nl> + / / np . dot ( v [ np . newaxis , : ] , a [ : , : ] ) ) <nl> + auto vva = BatchDot ( v_broadcast , a ) ; <nl> + vva = BatchDot ( v_broadcast , vva , / * transpose_x = * / true ) ; <nl> + a = a - xla : : Mul ( tau , vva , <nl> + / * broadcast_dimensions = * / batch_dim_indices ) ; <nl> + <nl> + / / It is more precise to populate column ' k ' explicitly , rather than <nl> + / / computing it implicitly by applying the Householder transformation . <nl> + / / a [ k , k ] = beta <nl> + / / a [ k + 1 : , k ] = np . zeros ( [ m - k - 1 ] , dtype = a . dtype ) <nl> + auto iota = xla : : Reshape ( xla : : Iota ( a . builder ( ) , xla : : S32 , m ) , { m , 1 } ) ; <nl> + auto predecessor_mask = xla : : ConvertElementType ( xla : : Lt ( iota , j ) , type ) ; <nl> + auto mask = xla : : Broadcast ( xla : : ConvertElementType ( xla : : Eq ( iota , j ) , type ) , <nl> + std : : vector < int64 > ( batch_dims . size ( ) , 1 ) ) ; <nl> + auto new_x = <nl> + xla : : Mul ( x , predecessor_mask , <nl> + / * broadcast_dimensions = * / { num_dims - 2 , num_dims - 1 } ) + <nl> + xla : : Mul ( beta , mask , / * broadcast_dimensions = * / batch_dim_indices ) ; <nl> + a = DynamicUpdateSliceInMinorDims ( a , new_x , { j } ) ; <nl> + <nl> + / / vs [ : , j ] = v <nl> + vs = DynamicUpdateSliceInMinorDims ( <nl> + vs , xla : : Reshape ( v , ConcatVectors ( batch_dims , { m , 1 } ) ) , { j } ) ; <nl> + / / taus [ j ] = tau <nl> + taus = DynamicUpdateSliceInMinorDims ( <nl> + taus , xla : : Reshape ( tau , ConcatVectors ( batch_dims , { 1 } ) ) , { j } ) ; <nl> + return std : : vector < xla : : XlaOp > { a , vs , taus } ; <nl> + } ; <nl> + <nl> + auto vs = xla : : Zeros ( builder , xla : : ShapeUtil : : MakeShape ( <nl> + type , ConcatVectors ( batch_dims , { m , n } ) ) ) ; <nl> + auto taus = xla : : Zeros ( <nl> + builder , xla : : ShapeUtil : : MakeShape ( type , ConcatVectors ( batch_dims , { n } ) ) ) ; <nl> + <nl> + TF_ASSIGN_OR_RETURN ( auto values , <nl> + XlaForEachIndex ( std : : min ( m , n ) , xla : : S32 , qr_body_fn , <nl> + { a , vs , taus } , " qr " , builder ) ) ; <nl> + <nl> + QRBlockResult result ; <nl> + result . r = values [ 0 ] ; <nl> + result . vs = values [ 1 ] ; <nl> + result . taus = values [ 2 ] ; <nl> + return result ; <nl> + } <nl> + <nl> + / / Computes W and Y such that I - WY is equivalent to the sequence of Householder <nl> + / / transformations given by vs and taus . <nl> + / / Golub and van Loan , " Matrix Computations " , algorithm 5 . 1 . 2 . <nl> + / / Y = np . zeros ( [ m , n ] ) <nl> + / / W = np . zeros ( [ m , n ] ) <nl> + / / Y [ : , 0 ] = vs [ : , 0 ] <nl> + / / W [ : , 0 ] = - taus [ 0 ] * vs [ : , 0 ] <nl> + / / for j in xrange ( 1 , n ) : <nl> + / / v = vs [ : , j ] <nl> + / / z = - taus [ j ] * v - taus [ j ] * np . dot ( W , np . dot ( Y . T , v ) ) <nl> + / / W [ : , j ] = z <nl> + / / Y [ : , j ] = v <nl> + / / return W <nl> + / / There is no need to return Y since at termination of the loop it is equal to <nl> + / / vs . <nl> + xla : : StatusOr < xla : : XlaOp > ComputeWYRepresentation ( <nl> + xla : : PrimitiveType type , gtl : : ArraySlice < int64 > batch_dims , xla : : XlaOp vs , <nl> + xla : : XlaOp taus , int64 m , int64 n ) { <nl> + std : : vector < int64 > batch_dim_indices ( batch_dims . size ( ) ) ; <nl> + std : : iota ( batch_dim_indices . begin ( ) , batch_dim_indices . end ( ) , 0 ) ; <nl> + int64 n_index = batch_dims . size ( ) + 1 ; <nl> + <nl> + auto body_fn = <nl> + [ & ] ( xla : : XlaOp j , gtl : : ArraySlice < xla : : XlaOp > values , <nl> + xla : : XlaBuilder * builder ) - > xla : : StatusOr < std : : vector < xla : : XlaOp > > { <nl> + auto w = values [ 0 ] ; <nl> + auto y = values [ 1 ] ; <nl> + const auto vs = values [ 2 ] ; <nl> + const auto taus = values [ 3 ] ; <nl> + <nl> + / / Want j values in range [ 1 , . . . n ) . <nl> + j = j + xla : : ConstantR0 < int32 > ( builder , 1 ) ; <nl> + / / vs has shape [ . . . , m , 1 ] <nl> + auto v = DynamicSliceInMinorDims ( vs , { j } , { 1 } ) ; <nl> + / / beta has shape [ . . . , 1 ] <nl> + auto beta = DynamicSliceInMinorDims ( taus , { j } , { 1 } ) ; <nl> + <nl> + / / yv has shape [ . . . , n , 1 ] <nl> + auto yv = BatchDot ( y , v , / * transpose_x = * / true ) ; <nl> + / / wyv has shape [ . . . , m , 1 ] <nl> + auto wyv = BatchDot ( w , yv ) ; <nl> + <nl> + auto z = xla : : Mul ( <nl> + - beta , v + wyv , <nl> + / * broadcast_dimensions = * / ConcatVectors ( batch_dim_indices , { n_index } ) ) ; <nl> + <nl> + w = DynamicUpdateSliceInMinorDims ( w , z , { j } ) ; <nl> + y = DynamicUpdateSliceInMinorDims ( y , v , { j } ) ; <nl> + <nl> + return std : : vector < xla : : XlaOp > { w , y , vs , taus } ; <nl> + } ; <nl> + <nl> + xla : : XlaBuilder * builder = vs . builder ( ) ; <nl> + auto w = xla : : Zeros ( builder , xla : : ShapeUtil : : MakeShape ( <nl> + type , ConcatVectors ( batch_dims , { m , n } ) ) ) ; <nl> + auto y = w ; <nl> + auto v = SliceInMinorDims ( vs , { 0 } , { 1 } ) ; <nl> + auto beta = SliceInMinorDims ( taus , { 0 } , { 1 } ) ; <nl> + y = UpdateSliceInMinorDims ( y , v , { 0 } ) ; <nl> + auto bv = xla : : Mul ( <nl> + - beta , v , <nl> + / * broadcast_dimensions = * / ConcatVectors ( batch_dim_indices , { n_index } ) ) ; <nl> + w = UpdateSliceInMinorDims ( w , bv , { 0 } ) ; <nl> + <nl> + TF_ASSIGN_OR_RETURN ( <nl> + auto values , XlaForEachIndex ( n - 1 , xla : : S32 , body_fn , { w , y , vs , taus } , <nl> + " wy " , builder ) ) ; <nl> + return values [ 0 ] ; <nl> + } <nl> + <nl> + } / / namespace <nl> + <nl> + / / Block Householder QR Factorization . Algorithm 5 . 2 . 2 of Golub and van Loan . <nl> + / / def qr_blocked ( a , block_size ) : <nl> + / / m = a . shape [ 0 ] <nl> + / / n = a . shape [ 1 ] <nl> + / / q = np . eye ( m ) <nl> + / / for i in xrange ( 0 , min ( m , n ) , block_size ) : <nl> + / / k = min ( block_size , min ( m , n ) - s ) <nl> + / / ( a , vs , taus ) = qr ( a [ i : , i : i + k ] ) <nl> + / / y = vs <nl> + / / w = ComputeWYRepresentation ( vs , taus , m - i , k ) <nl> + / / a [ i : , i + r : ] + = np . dot ( y , np . dot ( w . T , a [ i : , i + k : ] ) ) <nl> + / / q [ : , i : ] + = np . dot ( q [ : , i : ] , np . dot ( w , y . T ) ) <nl> + / / return ( q , a ) <nl> + / / TODO ( phawkins ) : consider using UT transformations ( in the form I - V U V ' ) <nl> + / / rather than WY transformations . <nl> + xla : : StatusOr < QRDecompositionResult > QRDecomposition ( xla : : XlaOp a , <nl> + int64 block_size ) { <nl> + xla : : XlaBuilder * builder = a . builder ( ) ; <nl> + TF_ASSIGN_OR_RETURN ( xla : : Shape a_shape , builder - > GetShape ( a ) ) ; <nl> + const int num_dims = xla : : ShapeUtil : : Rank ( a_shape ) ; <nl> + if ( num_dims < 2 ) { <nl> + return errors : : InvalidArgument ( " Arguments to QR must have rank > = 2 : " , <nl> + num_dims ) ; <nl> + } <nl> + xla : : PrimitiveType type = a_shape . element_type ( ) ; <nl> + <nl> + const int64 m = xla : : ShapeUtil : : GetDimension ( a_shape , - 2 ) ; <nl> + const int64 n = xla : : ShapeUtil : : GetDimension ( a_shape , - 1 ) ; <nl> + const int64 p = std : : min ( m , n ) ; <nl> + <nl> + if ( block_size < 1 ) { <nl> + return errors : : InvalidArgument ( <nl> + " block_size argument to QR must be > = 1 ; got " , block_size ) ; <nl> + } <nl> + <nl> + const int64 num_batch_dims = num_dims - 2 ; <nl> + std : : vector < int64 > batch_dims ( num_batch_dims ) ; <nl> + for ( int i = 0 ; i < num_batch_dims ; + + i ) { <nl> + batch_dims [ i ] = xla : : ShapeUtil : : GetDimension ( a_shape , i ) ; <nl> + } <nl> + <nl> + auto q = xla : : Broadcast ( xla : : IdentityMatrix ( builder , type , m , m ) , batch_dims ) ; <nl> + for ( int64 i = 0 ; i < p ; i + = block_size ) { <nl> + int64 k = std : : min ( block_size , p - i ) ; <nl> + <nl> + auto a_block = SliceInMinorDims ( a , { i , i } , { m , i + k } ) ; <nl> + TF_ASSIGN_OR_RETURN ( auto qr_block , QRBlock ( a_block ) ) ; <nl> + <nl> + a = UpdateSliceInMinorDims ( a , qr_block . r , { i , i } ) ; <nl> + <nl> + / / Compute the I - WY block representation of a product of Householder <nl> + / / matrices . <nl> + TF_ASSIGN_OR_RETURN ( auto w , <nl> + ComputeWYRepresentation ( type , batch_dims , qr_block . vs , <nl> + qr_block . taus , m - i , k ) ) ; <nl> + auto y = qr_block . vs ; <nl> + <nl> + / / a [ i : , i + k : ] + = np . dot ( Y , np . dot ( W . T , a [ i : , i + k : ] ) ) <nl> + auto a_panel = SliceInMinorDims ( a , { i , i + k } , { m , n } ) ; <nl> + auto a_update = BatchDot ( w , a_panel , / * transpose_x = * / true ) ; <nl> + a_update = BatchDot ( y , a_update ) ; <nl> + a_panel = a_panel + a_update ; <nl> + a = UpdateSliceInMinorDims ( a , a_panel , { i , i + k } ) ; <nl> + <nl> + / / q [ : , i : ] + = np . dot ( np . dot ( q [ : , i : ] , W ) , Y . T ) ) <nl> + auto q_panel = SliceInMinorDims ( q , { 0 , i } , { m , m } ) ; <nl> + auto q_update = BatchDot ( q_panel , w ) ; <nl> + q_update = <nl> + BatchDot ( q_update , y , / * transpose_x = * / false , / * transpose_y = * / true ) ; <nl> + q_panel = q_panel + q_update ; <nl> + q = UpdateSliceInMinorDims ( q , q_panel , { 0 , i } ) ; <nl> + } <nl> + QRDecompositionResult result ; <nl> + result . q = q ; <nl> + result . r = a ; <nl> + return result ; <nl> + } <nl> + <nl> + } / / namespace tensorflow <nl> new file mode 100644 <nl> index 0000000000000 . . 3aa6a9b075394 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / tf2xla / lib / qr . h <nl> <nl> + / * Copyright 2018 The TensorFlow Authors . All Rights Reserved . <nl> + <nl> + Licensed under the Apache License , Version 2 . 0 ( the " License " ) ; <nl> + you may not use this file except in compliance with the License . <nl> + You may obtain a copy of the License at <nl> + <nl> + http : / / www . apache . org / licenses / LICENSE - 2 . 0 <nl> + <nl> + Unless required by applicable law or agreed to in writing , software <nl> + distributed under the License is distributed on an " AS IS " BASIS , <nl> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied . <nl> + See the License for the specific language governing permissions and <nl> + limitations under the License . <nl> + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> + <nl> + # ifndef TENSORFLOW_COMPILER_TF2XLA_LIB_QR_H_ <nl> + # define TENSORFLOW_COMPILER_TF2XLA_LIB_QR_H_ <nl> + <nl> + # include " tensorflow / compiler / xla / client / xla_client / xla_builder . h " <nl> + <nl> + namespace tensorflow { <nl> + <nl> + / / Computes the QR decompositions of a batch of matrices . That is , <nl> + / / given a ( batched ) matrix a , computes an orthonormal matrix Q and an <nl> + / / upper - triangular matrix R such that a = QR . <nl> + / / ` a ` must be a ( batched ) matrix of size [ . . . , m , n ] . <nl> + / / The algorithm implements a blocked QR decomposition ; ` block_size ` is <nl> + / / the block size to use . <nl> + / / TODO ( phawkins ) : handle the complex case . <nl> + struct QRDecompositionResult { <nl> + xla : : XlaOp q ; <nl> + xla : : XlaOp r ; <nl> + } ; <nl> + <nl> + xla : : StatusOr < QRDecompositionResult > QRDecomposition ( xla : : XlaOp a , <nl> + int64 block_size = 128 ) ; <nl> + <nl> + } / / namespace tensorflow <nl> + <nl> + # endif / / TENSORFLOW_COMPILER_TF2XLA_LIB_QR_H_ <nl> mmm a / tensorflow / compiler / xla / client / lib / numeric . cc <nl> ppp b / tensorflow / compiler / xla / client / lib / numeric . cc <nl> XlaOp Iota ( XlaBuilder * builder , PrimitiveType type , int64 size ) { <nl> } <nl> } <nl> <nl> + XlaOp IdentityMatrix ( XlaBuilder * builder , PrimitiveType type , int64 m , <nl> + int64 n ) { <nl> + auto a = Iota ( builder , type , m ) ; <nl> + auto b = Iota ( builder , type , n ) ; <nl> + auto indicator = Eq ( a , Broadcast ( b , { m } ) , / * broadcast_dimensions = * / { 0 } ) ; <nl> + return ConvertElementType ( indicator , type ) ; <nl> + } <nl> + <nl> } / / namespace xla <nl> mmm a / tensorflow / compiler / xla / client / lib / numeric . h <nl> ppp b / tensorflow / compiler / xla / client / lib / numeric . h <nl> namespace xla { <nl> / / Returns a rank 1 tensor of ` type ` containing values [ 0 , 1 , 2 , . . . ] . <nl> XlaOp Iota ( XlaBuilder * builder , PrimitiveType type , int64 size ) ; <nl> <nl> + / / Returns an m x n matrix with 1s on the diagonal elements , zeros everywhere <nl> + / / else . <nl> + XlaOp IdentityMatrix ( XlaBuilder * builder , PrimitiveType type , int64 m , int64 n ) ; <nl> + <nl> } / / namespace xla <nl> <nl> # endif / / TENSORFLOW_COMPILER_XLA_CLIENT_LIB_NUMERIC_H_ <nl> | [ TF : XLA ] Add implementation of block Householder QR decomposition . | tensorflow/tensorflow | 6f207c867450a68e6d6e4179a85622741c93d710 | 2018-07-11T02:38:32Z |
mmm a / docs / SIL . rst <nl> ppp b / docs / SIL . rst <nl> reference - counted types , this can produce a different value from the operand <nl> if the block is copied from the stack to the heap . <nl> <nl> copy_block_without_escaping <nl> - ` ` ` ` ` ` ` ` ` ` <nl> + ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` <nl> : : <nl> <nl> sil - instruction : : ' copy_block_without_escaping ' sil - operand ' withoutEscaping ' sil - operand <nl> mmm a / lib / SILGen / SILGenApply . cpp <nl> ppp b / lib / SILGen / SILGenApply . cpp <nl> static RValue emitApplyAllocatingInitializer ( SILGenFunction & SGF , <nl> callee . emplace ( Callee : : forWitnessMethod ( <nl> SGF , selfMetaVal . getType ( ) . getSwiftRValueType ( ) , <nl> initRef , subs , loc ) ) ; <nl> + } else if ( getMethodDispatch ( ctor ) = = MethodDispatch : : Class ) { <nl> + callee . emplace ( Callee : : forClassMethod ( SGF , initRef , subs , loc ) ) ; <nl> } else { <nl> callee . emplace ( Callee : : forDirect ( SGF , initRef , subs , loc ) ) ; <nl> } <nl> static RValue emitApplyAllocatingInitializer ( SILGenFunction & SGF , <nl> / / For an inheritable initializer , determine whether we ' ll need to adjust the <nl> / / result type . <nl> bool requiresDowncast = false ; <nl> - if ( ctor - > isInheritable ( ) & & overriddenSelfType ) { <nl> + if ( ctor - > isRequired ( ) & & overriddenSelfType ) { <nl> CanType substResultType = substFormalType ; <nl> for ( unsigned i : range ( ctor - > getNumParameterLists ( ) ) ) { <nl> ( void ) i ; <nl> mmm a / lib / Sema / CSApply . cpp <nl> ppp b / lib / Sema / CSApply . cpp <nl> ConcreteDeclRef findNamedWitnessImpl ( <nl> <nl> / / For a type with dependent conformance , just return the requirement from <nl> / / the protocol . There are no protocol conformance tables . <nl> - if ( ! conformance - > isConcrete ( ) ) <nl> - return requirement ; <nl> + if ( ! conformance - > isConcrete ( ) ) { <nl> + auto subMap = SubstitutionMap : : getProtocolSubstitutions ( proto , type , <nl> + * conformance ) ; <nl> + SmallVector < Substitution , 2 > subs ; <nl> + proto - > getGenericSignature ( ) - > getSubstitutions ( subMap , subs ) ; <nl> + return ConcreteDeclRef ( tc . Context , requirement , subs ) ; <nl> + } <nl> + <nl> auto concrete = conformance - > getConcrete ( ) ; <nl> return concrete - > getWitnessDeclRef ( requirement , & tc ) ; <nl> } <nl> Expr * ExprRewriter : : convertLiteralInPlace ( Expr * literal , <nl> return nullptr ; <nl> <nl> / / Form a reference to the builtin conversion function . <nl> - / / FIXME : Bogus location info . <nl> - Expr * base = TypeExpr : : createImplicitHack ( literal - > getLoc ( ) , type , <nl> - tc . Context ) ; <nl> - <nl> - Expr * unresolvedDot = new ( tc . Context ) UnresolvedDotExpr ( <nl> - base , SourceLoc ( ) , <nl> - witness . getDecl ( ) - > getFullName ( ) , <nl> - DeclNameLoc ( base - > getEndLoc ( ) ) , <nl> - / * Implicit = * / true ) ; <nl> - ( void ) tc . typeCheckExpression ( unresolvedDot , dc ) ; <nl> - <nl> - cs . cacheExprTypes ( unresolvedDot ) ; <nl> - <nl> - ConcreteDeclRef builtinRef = unresolvedDot - > getReferencedDecl ( ) ; <nl> - if ( ! builtinRef ) { <nl> - tc . diagnose ( base - > getLoc ( ) , brokenBuiltinProtocolDiag ) ; <nl> - return nullptr ; <nl> - } <nl> <nl> / / Set the builtin initializer . <nl> if ( auto stringLiteral = dyn_cast < StringLiteralExpr > ( literal ) ) <nl> - stringLiteral - > setBuiltinInitializer ( builtinRef ) ; <nl> + stringLiteral - > setBuiltinInitializer ( witness ) ; <nl> else { <nl> cast < MagicIdentifierLiteralExpr > ( literal ) <nl> - - > setBuiltinInitializer ( builtinRef ) ; <nl> + - > setBuiltinInitializer ( witness ) ; <nl> } <nl> <nl> / / The literal expression has this type . <nl> Expr * ExprRewriter : : convertLiteralInPlace ( Expr * literal , <nl> if ( ! witness | | ! isa < AbstractFunctionDecl > ( witness . getDecl ( ) ) ) <nl> return nullptr ; <nl> <nl> - / / Form a reference to the conversion function . <nl> - / / FIXME : Bogus location info . <nl> - Expr * base = TypeExpr : : createImplicitHack ( literal - > getLoc ( ) , type , <nl> - tc . Context ) ; <nl> - <nl> - Expr * unresolvedDot = new ( tc . Context ) UnresolvedDotExpr ( <nl> - base , SourceLoc ( ) , <nl> - witness . getDecl ( ) - > getFullName ( ) , <nl> - DeclNameLoc ( base - > getEndLoc ( ) ) , <nl> - / * Implicit = * / true ) ; <nl> - ( void ) tc . typeCheckExpression ( unresolvedDot , dc ) ; <nl> - cs . cacheExprTypes ( unresolvedDot ) ; <nl> - <nl> - ConcreteDeclRef ref = unresolvedDot - > getReferencedDecl ( ) ; <nl> - if ( ! ref ) { <nl> - tc . diagnose ( base - > getLoc ( ) , brokenProtocolDiag ) ; <nl> - return nullptr ; <nl> - } <nl> - <nl> / / Set the initializer . <nl> if ( auto stringLiteral = dyn_cast < StringLiteralExpr > ( literal ) ) <nl> - stringLiteral - > setInitializer ( ref ) ; <nl> + stringLiteral - > setInitializer ( witness ) ; <nl> else <nl> - cast < MagicIdentifierLiteralExpr > ( literal ) - > setInitializer ( ref ) ; <nl> + cast < MagicIdentifierLiteralExpr > ( literal ) - > setInitializer ( witness ) ; <nl> <nl> / / The literal expression has this type . <nl> cs . setType ( literal , type ) ; <nl> mmm a / test / SILGen / generic_literals . swift <nl> ppp b / test / SILGen / generic_literals . swift <nl> <nl> / / RUN : % target - swift - emit - silgen - enable - sil - ownership % s | % FileCheck % s <nl> <nl> - / / CHECK - LABEL : sil hidden @ $ S16generic_literals0A14IntegerLiteral1xyx_ts013ExpressibleBycD0RzlF <nl> + / / CHECK - LABEL : sil hidden @ $ S16generic_literals0A14IntegerLiteral1xyx_ts013ExpressibleBycD0RzlF : $ @ convention ( thin ) < T where T : ExpressibleByIntegerLiteral > ( @ in_guaranteed T ) - > ( ) { <nl> func genericIntegerLiteral < T : ExpressibleByIntegerLiteral > ( x : T ) { <nl> var x = x <nl> / / CHECK : [ [ ADDR : % . * ] ] = alloc_stack $ T <nl> func genericIntegerLiteral < T : ExpressibleByIntegerLiteral > ( x : T ) { <nl> x = 17 <nl> } <nl> <nl> - / / CHECK - LABEL : sil hidden @ $ S16generic_literals0A15FloatingLiteral { { [ _0 - 9a - zA - Z ] * } } F <nl> + / / CHECK - LABEL : sil hidden @ $ S16generic_literals0A15FloatingLiteral1xyx_ts018ExpressibleByFloatD0RzlF : $ @ convention ( thin ) < T where T : ExpressibleByFloatLiteral > ( @ in_guaranteed T ) - > ( ) { <nl> func genericFloatingLiteral < T : ExpressibleByFloatLiteral > ( x : T ) { <nl> var x = x <nl> / / CHECK : [ [ TVAL : % . * ] ] = alloc_stack $ T <nl> func genericFloatingLiteral < T : ExpressibleByFloatLiteral > ( x : T ) { <nl> <nl> x = 2 . 5 <nl> } <nl> + <nl> + / / CHECK - LABEL : sil hidden @ $ S16generic_literals0A13StringLiteral1xyx_ts013ExpressibleBycD0RzlF : $ @ convention ( thin ) < T where T : ExpressibleByStringLiteral > ( @ in_guaranteed T ) - > ( ) { <nl> + <nl> + func genericStringLiteral < T : ExpressibleByStringLiteral > ( x : T ) { <nl> + var x = x <nl> + / / CHECK : [ [ LIT_VALUE : % . * ] ] = string_literal utf8 " hello " <nl> + / / CHECK : [ [ TSTR_META : % . * ] ] = metatype $ @ thick T . StringLiteralType . Type <nl> + / / CHECK : [ [ STR_VAL : % . * ] ] = alloc_stack $ T . StringLiteralType <nl> + / / CHECK : [ [ BUILTIN_CONV : % . * ] ] = witness_method $ T . StringLiteralType , # _ExpressibleByBuiltinStringLiteral . init ! allocator . 1 <nl> + / / CHECK : apply [ [ BUILTIN_CONV ] ] < T . StringLiteralType > ( [ [ STR_VAL ] ] , [ [ LIT_VALUE ] ] , { { . * } } , [ [ TSTR_META ] ] ) : $ @ convention ( witness_method : _ExpressibleByBuiltinStringLiteral ) < τ_0_0 where τ_0_0 : _ExpressibleByBuiltinStringLiteral > ( Builtin . RawPointer , Builtin . Word , Builtin . Int1 , @ thick τ_0_0 . Type ) - > @ out τ_0_0 <nl> + / / CHECK : [ [ TMETA : % . * ] ] = metatype $ @ thick T . Type <nl> + / / CHECK : [ [ TVAL : % . * ] ] = alloc_stack $ T <nl> + / / CHECK : [ [ CONV : % . * ] ] = witness_method $ T , # ExpressibleByStringLiteral . init ! allocator . 1 <nl> + / / CHECK : apply [ [ CONV ] ] < T > ( [ [ TVAL ] ] , [ [ STR_VAL ] ] , [ [ TMETA ] ] ) : $ @ convention ( witness_method : ExpressibleByStringLiteral ) < τ_0_0 where τ_0_0 : ExpressibleByStringLiteral > ( @ in τ_0_0 . StringLiteralType , @ thick τ_0_0 . Type ) - > @ out τ_0_0 <nl> + <nl> + x = " hello " <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 89d5c62caf2d <nl> mmm / dev / null <nl> ppp b / test / SILGen / literals . swift <nl> <nl> + / / RUN : % target - swift - emit - silgen - enable - sil - ownership % s | % FileCheck % s <nl> + <nl> + func takesOptionalFunction ( _ : ( ( ) - > ( ) ) ? ) { } <nl> + <nl> + struct CustomNull : ExpressibleByNilLiteral { <nl> + init ( nilLiteral : ( ) ) { } <nl> + } <nl> + <nl> + func takesANull ( _ : CustomNull ) { } <nl> + <nl> + / / CHECK - LABEL : sil hidden @ $ S8literals4testyyF : $ @ convention ( thin ) ( ) - > ( ) <nl> + func test ( ) { <nl> + / / CHECK : [ [ NIL : % . * ] ] = enum $ Optional < @ callee_guaranteed ( ) - > ( ) > , # Optional . none ! enumelt <nl> + / / CHECK : [ [ FN : % . * ] ] = function_ref @ $ S8literals21takesOptionalFunctionyyyycSgF <nl> + / / CHECK : apply [ [ FN ] ] ( [ [ NIL ] ] ) <nl> + _ = takesOptionalFunction ( nil ) <nl> + <nl> + / / CHECK : [ [ METATYPE : % . * ] ] = metatype $ @ thin CustomNull . Type <nl> + / / CHECK : [ [ NIL_FN : % . * ] ] = function_ref @ $ S8literals10CustomNullV10nilLiteralACyt_tcfC <nl> + / / CHECK : [ [ NIL : % . * ] ] = apply [ [ NIL_FN ] ] ( [ [ METATYPE ] ] ) <nl> + / / CHECK : [ [ FN : % . * ] ] = function_ref @ $ S8literals10takesANullyyAA10CustomNullVF <nl> + / / CHECK : apply [ [ FN ] ] ( [ [ NIL ] ] ) <nl> + _ = takesANull ( nil ) <nl> + } <nl> + <nl> + class CustomStringClass : ExpressibleByStringLiteral { <nl> + required init ( stringLiteral value : String ) { } <nl> + required init ( extendedGraphemeClusterLiteral value : String ) { } <nl> + required init ( unicodeScalarLiteral value : String ) { } <nl> + } <nl> + <nl> + class CustomStringSubclass : CustomStringClass { } <nl> + <nl> + / / CHECK - LABEL : sil hidden @ $ S8literals27returnsCustomStringSubclassAA0cdE0CyF : $ @ convention ( thin ) ( ) - > @ owned CustomStringSubclass <nl> + / / CHECK : [ [ METATYPE : % . * ] ] = metatype $ @ thick CustomStringSubclass . Type <nl> + / / CHECK : [ [ UPCAST : % . * ] ] = upcast [ [ METATYPE ] ] : $ @ thick CustomStringSubclass . Type to $ @ thick CustomStringClass . Type <nl> + / / CHECK : [ [ CTOR : % . * ] ] = class_method [ [ UPCAST ] ] : $ @ thick CustomStringClass . Type , # CustomStringClass . init ! allocator . 1 : ( CustomStringClass . Type ) - > ( String ) - > CustomStringClass , $ @ convention ( method ) ( @ owned String , @ thick CustomStringClass . Type ) - > @ owned CustomStringClass <nl> + / / CHECK : [ [ RESULT : % . * ] ] = apply [ [ CTOR ] ] ( { { % . * } } , [ [ UPCAST ] ] ) <nl> + / / CHECK : [ [ DOWNCAST : % . * ] ] = unchecked_ref_cast [ [ RESULT ] ] : $ CustomStringClass to $ CustomStringSubclass <nl> + / / CHECK : return [ [ DOWNCAST ] ] <nl> + func returnsCustomStringSubclass ( ) - > CustomStringSubclass { <nl> + return " hello world " <nl> + } <nl> deleted file mode 100644 <nl> index 638eb5793981 . . 000000000000 <nl> mmm a / test / SILGen / nil_literal . swift <nl> ppp / dev / null <nl> <nl> - <nl> - / / RUN : % target - swift - emit - silgen - enable - sil - ownership % s | % FileCheck % s <nl> - <nl> - func takesOptionalFunction ( _ : ( ( ) - > ( ) ) ? ) { } <nl> - <nl> - struct CustomNull : ExpressibleByNilLiteral { <nl> - init ( nilLiteral : ( ) ) { } <nl> - } <nl> - <nl> - func takesANull ( _ : CustomNull ) { } <nl> - <nl> - / / CHECK - LABEL : sil hidden @ $ S11nil_literal4testyyF : $ @ convention ( thin ) ( ) - > ( ) <nl> - func test ( ) { <nl> - / / CHECK : [ [ NIL : % . * ] ] = enum $ Optional < @ callee_guaranteed ( ) - > ( ) > , # Optional . none ! enumelt <nl> - / / CHECK : [ [ FN : % . * ] ] = function_ref @ $ S11nil_literal21takesOptionalFunctionyyyycSgF <nl> - / / CHECK : apply [ [ FN ] ] ( [ [ NIL ] ] ) <nl> - _ = takesOptionalFunction ( nil ) <nl> - <nl> - / / CHECK : [ [ METATYPE : % . * ] ] = metatype $ @ thin CustomNull . Type <nl> - / / CHECK : [ [ NIL_FN : % . * ] ] = function_ref @ $ S11nil_literal10CustomNullV0A7LiteralACyt_tcfC <nl> - / / CHECK : [ [ NIL : % . * ] ] = apply [ [ NIL_FN ] ] ( [ [ METATYPE ] ] ) <nl> - / / CHECK : [ [ FN : % . * ] ] = function_ref @ $ S11nil_literal10takesANullyyAA10CustomNullVF <nl> - / / CHECK : apply [ [ FN ] ] ( [ [ NIL ] ] ) <nl> - _ = takesANull ( nil ) <nl> - } <nl> | Merge pull request from slavapestov / simpler - string - literals | apple/swift | a8d831f5f5e2daa2dc9400ca88340e11141e636f | 2018-05-02T02:18:12Z |
mmm a / arangod / Aql / ModificationBlocks . h <nl> ppp b / arangod / Aql / ModificationBlocks . h <nl> <nl> # include " Utils / AqlTransaction . h " <nl> # include " VocBase / shaped - json . h " <nl> <nl> - struct TRI_df_marker_s ; <nl> + struct TRI_df_marker_t ; <nl> struct TRI_doc_mptr_t ; <nl> struct TRI_json_t ; <nl> <nl> class ModificationBlock : public ExecutionBlock { <nl> / / / @ brief constructs a master pointer from the marker passed <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - void constructMptr ( TRI_doc_mptr_t * , TRI_df_marker_s const * ) const ; <nl> + void constructMptr ( TRI_doc_mptr_t * , TRI_df_marker_t const * ) const ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief check whether a shard key value has changed <nl> mmm a / arangod / V8Server / V8VPackWrapper . h <nl> ppp b / arangod / V8Server / V8VPackWrapper . h <nl> <nl> <nl> # include < v8 . h > <nl> <nl> - struct TRI_df_marker_s ; <nl> + struct TRI_df_marker_t ; <nl> struct TRI_doc_mptr_t ; <nl> struct TRI_document_collection_t ; <nl> <nl> namespace V8VPackWrapper { <nl> <nl> v8 : : Handle < v8 : : Value > wrap ( v8 : : Isolate * , arangodb : : Transaction * , <nl> TRI_voc_cid_t cid , arangodb : : DocumentDitch * ditch , <nl> - struct TRI_df_marker_s const * ) ; <nl> + struct TRI_df_marker_t const * ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief wraps a VPackSlice <nl> mmm a / arangod / VocBase / cleanup . cpp <nl> ppp b / arangod / VocBase / cleanup . cpp <nl> <nl> # include " cleanup . h " <nl> # include " Basics / files . h " <nl> # include " Basics / Logger . h " <nl> - # include " Basics / tri - strings . h " <nl> + # include " Basics / ReadLocker . h " <nl> # include " Utils / CursorRepository . h " <nl> # include " VocBase / compactor . h " <nl> # include " VocBase / Ditch . h " <nl> mmm a / arangod / VocBase / datafile . cpp <nl> ppp b / arangod / VocBase / datafile . cpp <nl> char const * TRI_NameMarkerDatafile ( TRI_df_marker_t const * marker ) { <nl> return " header " ; <nl> case TRI_DF_MARKER_FOOTER : <nl> return " footer " ; <nl> + case TRI_DF_MARKER_PROLOGUE : <nl> + return " prologue " ; <nl> <nl> / / datafile markers <nl> case TRI_DOC_MARKER_KEY_DOCUMENT : <nl> mmm a / arangod / VocBase / datafile . h <nl> ppp b / arangod / VocBase / datafile . h <nl> struct TRI_datafile_t ; <nl> / / / @ brief state of the datafile <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef enum { <nl> + enum TRI_df_state_e { <nl> TRI_DF_STATE_CLOSED = 1 , / / datafile is closed <nl> TRI_DF_STATE_READ = 2 , / / datafile is opened read only <nl> TRI_DF_STATE_WRITE = 3 , / / datafile is opened read / append <nl> TRI_DF_STATE_OPEN_ERROR = 4 , / / an error has occurred while opening <nl> TRI_DF_STATE_WRITE_ERROR = 5 , / / an error has occurred while writing <nl> TRI_DF_STATE_RENAME_ERROR = 6 / / an error has occurred while renaming <nl> - } TRI_df_state_e ; <nl> + } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief type of the marker <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef enum { <nl> + enum TRI_df_marker_type_e { <nl> TRI_MARKER_MIN = 999 , / / not a real marker type , <nl> / / but used for bounds checking <nl> <nl> TRI_DF_MARKER_HEADER = 1000 , <nl> TRI_DF_MARKER_FOOTER = 1001 , <nl> + TRI_DF_MARKER_PROLOGUE = 1002 , <nl> <nl> TRI_DF_MARKER_BLANK = 1100 , <nl> <nl> typedef enum { <nl> TRI_MARKER_MAX / / again , this is not a real <nl> / / marker , but we use it for <nl> / / bounds checking <nl> - } TRI_df_marker_type_e ; <nl> + } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief storage type of the marker <nl> typedef uint32_t TRI_df_version_t ; <nl> / / / @ brief scan result <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef struct TRI_df_scan_s { <nl> + struct TRI_df_scan_t { <nl> TRI_voc_size_t _currentSize ; <nl> TRI_voc_size_t _maximalSize ; <nl> TRI_voc_size_t _endPosition ; <nl> typedef struct TRI_df_scan_s { <nl> <nl> uint32_t _status ; <nl> bool _isSealed ; <nl> - } TRI_df_scan_t ; <nl> + } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief scan result entry <nl> typedef struct TRI_df_scan_s { <nl> / / / 5 - CRC failed <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef struct TRI_df_scan_entry_s { <nl> + struct TRI_df_scan_entry_t { <nl> TRI_voc_size_t _position ; <nl> TRI_voc_size_t _size ; <nl> TRI_voc_size_t _realSize ; <nl> typedef struct TRI_df_scan_entry_s { <nl> char * _diagnosis ; <nl> char * _key ; <nl> char const * _typeName ; <nl> - } TRI_df_scan_entry_t ; <nl> + } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief datafile <nl> struct TRI_datafile_t { <nl> / / / and _crc the second . <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef struct TRI_df_marker_s { <nl> + struct TRI_df_marker_t { <nl> TRI_voc_size_t _size ; / / 4 bytes , must be supplied <nl> TRI_voc_crc_t _crc ; / / 4 bytes , will be generated <nl> <nl> typedef struct TRI_df_marker_s { <nl> # endif <nl> <nl> TRI_voc_tick_t _tick ; / / 8 bytes , will be generated <nl> - } TRI_df_marker_t ; <nl> + } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief datafile header marker <nl> typedef struct TRI_df_marker_s { <nl> / / / < / table > <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef struct TRI_df_header_marker_s { <nl> + struct TRI_df_header_marker_t { <nl> TRI_df_marker_t base ; / / 24 bytes <nl> <nl> TRI_df_version_t _version ; / / 4 bytes <nl> TRI_voc_size_t _maximalSize ; / / 4 bytes <nl> TRI_voc_tick_t _fid ; / / 8 bytes <nl> - } TRI_df_header_marker_t ; <nl> + } ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief datafile footer marker <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + struct TRI_df_prologue_marker_t { <nl> + TRI_df_marker_t base ; / / 24 bytes <nl> + <nl> + TRI_voc_tick_t _databaseId ; / / 8 bytes <nl> + TRI_voc_cid_t _collectionId ; / / 8 bytes <nl> + } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief datafile footer marker <nl> typedef struct TRI_df_header_marker_s { <nl> / / / contains a footer is sealed and read - only . <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef struct TRI_df_footer_marker_s { <nl> + struct TRI_df_footer_marker_t { <nl> TRI_df_marker_t base ; / / 24 bytes <nl> <nl> TRI_voc_size_t _maximalSize ; / / 4 bytes <nl> TRI_voc_size_t _totalSize ; / / 4 bytes <nl> - } TRI_df_footer_marker_t ; <nl> + } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief document datafile header marker <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef struct TRI_col_header_marker_s { <nl> + struct TRI_col_header_marker_t { <nl> TRI_df_marker_t base ; / / 24 bytes <nl> <nl> TRI_col_type_t _type ; / / 4 bytes <nl> typedef struct TRI_col_header_marker_s { <nl> # endif <nl> <nl> TRI_voc_cid_t _cid ; / / 8 bytes <nl> - } TRI_col_header_marker_t ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief datafile attribute marker <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - typedef struct TRI_df_attribute_marker_s { <nl> - TRI_df_marker_t base ; <nl> - <nl> - TRI_shape_aid_t _aid ; <nl> - TRI_shape_size_t _size ; <nl> - <nl> - / / char name [ ] <nl> - } TRI_df_attribute_marker_t ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief datafile shape marker <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - typedef struct TRI_df_shape_marker_s { <nl> - TRI_df_marker_t base ; <nl> - } TRI_df_shape_marker_t ; <nl> + } ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief document datafile marker with key <nl> typedef struct TRI_doc_deletion_key_marker_s { <nl> uint16_t _offsetKey ; <nl> } TRI_doc_deletion_key_marker_t ; <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief begin transaction marker <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - typedef struct TRI_doc_begin_transaction_marker_s { <nl> - TRI_df_marker_t base ; <nl> - <nl> - TRI_voc_tid_t _tid ; <nl> - uint32_t _numCollections ; <nl> - # ifdef TRI_PADDING_32 <nl> - char _padding_begin_marker [ 4 ] ; <nl> - # endif <nl> - } TRI_doc_begin_transaction_marker_t ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief commit transaction marker <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - typedef struct TRI_doc_commit_transaction_marker_s { <nl> - TRI_df_marker_t base ; <nl> - <nl> - TRI_voc_tid_t _tid ; <nl> - } TRI_doc_commit_transaction_marker_t ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief abort transaction marker <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - typedef struct TRI_doc_abort_transaction_marker_s { <nl> - TRI_df_marker_t base ; <nl> - <nl> - TRI_voc_tid_t _tid ; <nl> - } TRI_doc_abort_transaction_marker_t ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief prepare transaction marker <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - typedef struct TRI_doc_prepare_transaction_marker_s { <nl> - TRI_df_marker_t base ; <nl> - <nl> - TRI_voc_tid_t _tid ; <nl> - } TRI_doc_prepare_transaction_marker_t ; <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief creates a new datafile <nl> / / / <nl> mmm a / arangod / VocBase / document - collection . cpp <nl> ppp b / arangod / VocBase / document - collection . cpp <nl> <nl> # include " Basics / Logger . h " <nl> # include " Basics / tri - strings . h " <nl> # include " Basics / ThreadPool . h " <nl> + # include " Basics / WriteLocker . h " <nl> # include " Cluster / ServerState . h " <nl> # include " FulltextIndex / fulltext - index . h " <nl> # include " Indexes / EdgeIndex . h " <nl> mmm a / arangod / VocBase / replication - dump . cpp <nl> ppp b / arangod / VocBase / replication - dump . cpp <nl> static TRI_voc_cid_t GetCollectionFromWalMarker ( TRI_df_marker_t const * marker ) { <nl> if ( ! slice . isObject ( ) ) { <nl> return 0 ; <nl> } <nl> - VPackSlice const id = slice . get ( " id " ) ; <nl> + VPackSlice const id = slice . get ( " cid " ) ; <nl> if ( id . isString ( ) ) { <nl> return std : : stoull ( id . copyString ( ) ) ; <nl> } <nl> mmm a / arangod / VocBase / transaction . cpp <nl> ppp b / arangod / VocBase / transaction . cpp <nl> int TRI_AddOperationTransaction ( TRI_transaction_t * trx , <nl> bool & waitForSync ) { <nl> TRI_ASSERT ( operation . header ! = nullptr ) ; <nl> <nl> + TRI_document_collection_t * document = operation . document ; <nl> bool const isSingleOperationTransaction = IsSingleOperationTransaction ( trx ) ; <nl> <nl> / / upgrade the info for the transaction <nl> - if ( waitForSync | | operation . document - > _info . waitForSync ( ) ) { <nl> + if ( waitForSync | | document - > _info . waitForSync ( ) ) { <nl> trx - > _waitForSync = true ; <nl> } <nl> <nl> / / default is false <nl> waitForSync = false ; <nl> if ( isSingleOperationTransaction ) { <nl> - waitForSync | = operation . document - > _info . waitForSync ( ) ; <nl> + waitForSync | = document - > _info . waitForSync ( ) ; <nl> } <nl> <nl> TRI_IF_FAILURE ( " TransactionOperationNoSlot " ) { return TRI_ERROR_DEBUG ; } <nl> int TRI_AddOperationTransaction ( TRI_transaction_t * trx , <nl> TRI_voc_fid_t fid = 0 ; <nl> void const * position = nullptr ; <nl> <nl> - TRI_document_collection_t * document = operation . document ; <nl> - <nl> if ( operation . marker - > fid ( ) = = 0 ) { <nl> / / this is a " real " marker that must be written into the logfiles <nl> - / / No document or edge marker , just append it to the WAL : <nl> + / / just append it to the WAL : <nl> arangodb : : wal : : SlotInfoCopy slotInfo = <nl> arangodb : : wal : : LogfileManager : : instance ( ) - > allocateAndWrite ( <nl> + trx - > _vocbase - > _id , document - > _info . id ( ) , <nl> operation . marker - > mem ( ) , operation . marker - > size ( ) , false ) ; <nl> if ( slotInfo . errorCode ! = TRI_ERROR_NO_ERROR ) { <nl> / / some error occurred <nl> int TRI_AddOperationTransaction ( TRI_transaction_t * trx , <nl> if ( operation . type = = TRI_VOC_DOCUMENT_OPERATION_INSERT | | <nl> operation . type = = TRI_VOC_DOCUMENT_OPERATION_UPDATE ) { <nl> / / adjust the data position in the header <nl> - operation . header - > setDataPtr ( <nl> - position ) ; / / PROTECTED by ongoing trx from operation <nl> + operation . header - > setDataPtr ( position ) ; <nl> } <nl> <nl> TRI_IF_FAILURE ( " TransactionOperationAfterAdjust " ) { return TRI_ERROR_DEBUG ; } <nl> mmm a / arangod / VocBase / vocbase . cpp <nl> ppp b / arangod / VocBase / vocbase . cpp <nl> <nl> # include " Basics / threads . h " <nl> # include " Basics / Exceptions . h " <nl> # include " Basics / FileUtils . h " <nl> + # include " Basics / WriteLocker . h " <nl> # include " Utils / CollectionKeysRepository . h " <nl> # include " Utils / CursorRepository . h " <nl> # include " Utils / transactions . h " <nl> mmm a / arangod / Wal / CollectorThread . cpp <nl> ppp b / arangod / Wal / CollectorThread . cpp <nl> <nl> # include " VocBase / DatafileStatistics . h " <nl> # include " VocBase / document - collection . h " <nl> # include " VocBase / server . h " <nl> - # include " VocBase / VocShaper . h " <nl> # include " Wal / Logfile . h " <nl> # include " Wal / LogfileManager . h " <nl> <nl> static bool ScanMarker ( TRI_df_marker_t const * marker , void * data , <nl> break ; <nl> } <nl> <nl> - case TRI_WAL_MARKER_BEGIN_REMOTE_TRANSACTION : <nl> - case TRI_WAL_MARKER_COMMIT_REMOTE_TRANSACTION : { <nl> - break ; <nl> - } <nl> - <nl> - case TRI_WAL_MARKER_ABORT_REMOTE_TRANSACTION : { <nl> - transaction_remote_abort_marker_t const * m = <nl> - reinterpret_cast < transaction_remote_abort_marker_t const * > ( marker ) ; <nl> - / / note which abort markers we found <nl> - state - > handledTransactions . emplace ( m - > _transactionId ) ; <nl> - break ; <nl> - } <nl> - <nl> case TRI_WAL_MARKER_CREATE_COLLECTION : { <nl> VPackSlice const slice ( p + sizeof ( TRI_df_marker_t ) ) ; <nl> TRI_voc_tid_t cid = NumericValue < TRI_voc_cid_t > ( slice , " cid " ) ; <nl> static bool ScanMarker ( TRI_df_marker_t const * marker , void * data , <nl> <nl> case TRI_WAL_MARKER_CREATE_DATABASE : { <nl> VPackSlice const slice ( p + sizeof ( TRI_df_marker_t ) ) ; <nl> - TRI_voc_tick_t id = NumericValue < TRI_voc_tick_t > ( slice , " id " ) ; <nl> + TRI_voc_tick_t id = NumericValue < TRI_voc_tick_t > ( slice , " database " ) ; <nl> / / note that the database is now considered not dropped <nl> state - > droppedDatabases . erase ( id ) ; <nl> break ; <nl> static bool ScanMarker ( TRI_df_marker_t const * marker , void * data , <nl> <nl> case TRI_WAL_MARKER_DROP_DATABASE : { <nl> VPackSlice const slice ( p + sizeof ( TRI_df_marker_t ) ) ; <nl> - TRI_voc_tick_t id = NumericValue < TRI_voc_tick_t > ( slice , " id " ) ; <nl> + TRI_voc_tick_t id = NumericValue < TRI_voc_tick_t > ( slice , " database " ) ; <nl> / / note that the database was dropped and doesn ' t need to be collected <nl> state - > droppedDatabases . emplace ( id ) ; <nl> <nl> static bool ScanMarker ( TRI_df_marker_t const * marker , void * data , <nl> } <nl> break ; <nl> } <nl> + <nl> + case TRI_WAL_MARKER_BEGIN_REMOTE_TRANSACTION : <nl> + case TRI_WAL_MARKER_COMMIT_REMOTE_TRANSACTION : { <nl> + break ; <nl> + } <nl> + <nl> + case TRI_WAL_MARKER_ABORT_REMOTE_TRANSACTION : { <nl> + transaction_remote_abort_marker_t const * m = <nl> + reinterpret_cast < transaction_remote_abort_marker_t const * > ( marker ) ; <nl> + / / note which abort markers we found <nl> + state - > handledTransactions . emplace ( m - > _transactionId ) ; <nl> + break ; <nl> + } <nl> + <nl> <nl> default : { <nl> / / do nothing intentionally <nl> void CollectorThread : : initMarker ( TRI_df_marker_t * marker , <nl> TRI_ASSERT ( marker ! = nullptr ) ; <nl> <nl> marker - > _size = size ; <nl> - marker - > _type = ( TRI_df_marker_type_t ) type ; <nl> + marker - > _type = static_cast < TRI_df_marker_type_t > ( type ) ; <nl> marker - > _crc = 0 ; <nl> marker - > _tick = 0 ; <nl> } <nl> mmm a / arangod / Wal / CollectorThread . h <nl> ppp b / arangod / Wal / CollectorThread . h <nl> <nl> # include " Wal / Logfile . h " <nl> <nl> struct TRI_datafile_t ; <nl> - struct TRI_df_marker_s ; <nl> + struct TRI_df_marker_t ; <nl> struct TRI_document_collection_t ; <nl> struct TRI_server_t ; <nl> <nl> class CollectorThread : public Thread { <nl> / / / @ brief typedef key = > document marker <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef std : : unordered_map < std : : string , struct TRI_df_marker_s const * > <nl> + typedef std : : unordered_map < std : : string , struct TRI_df_marker_t const * > <nl> DocumentOperationsType ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief typedef for structural operation ( attributes , shapes ) markers <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - typedef std : : vector < struct TRI_df_marker_s const * > OperationsType ; <nl> + typedef std : : vector < struct TRI_df_marker_t const * > OperationsType ; <nl> <nl> public : <nl> void beginShutdown ( ) override final ; <nl> class CollectorThread : public Thread { <nl> / / / @ brief initialize a marker <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - void initMarker ( struct TRI_df_marker_s * , TRI_df_marker_type_e , <nl> + void initMarker ( struct TRI_df_marker_t * , TRI_df_marker_type_e , <nl> TRI_voc_size_t ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / arangod / Wal / Logfile . cpp <nl> ppp b / arangod / Wal / Logfile . cpp <nl> TRI_df_header_marker_t Logfile : : getHeaderMarker ( ) const { <nl> return header ; <nl> } <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief create a prologue marker <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + TRI_df_prologue_marker_t Logfile : : getPrologueMarker ( TRI_voc_tick_t databaseId , TRI_voc_cid_t collectionId ) const { <nl> + TRI_df_prologue_marker_t header ; <nl> + size_t const size = sizeof ( TRI_df_prologue_marker_t ) ; <nl> + TRI_InitMarkerDatafile ( ( char * ) & header , TRI_DF_MARKER_PROLOGUE , size ) ; <nl> + <nl> + header . _databaseId = databaseId ; <nl> + header . _collectionId = collectionId ; <nl> + <nl> + return header ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief create a footer marker <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / arangod / Wal / Logfile . h <nl> ppp b / arangod / Wal / Logfile . h <nl> <nl> # define ARANGOD_WAL_LOGFILE_H 1 <nl> <nl> # include " Basics / Common . h " <nl> - # include " Basics / ReadWriteLock . h " <nl> - # include " Basics / ReadLocker . h " <nl> - # include " Basics / WriteLocker . h " <nl> # include " Basics / Logger . h " <nl> # include " VocBase / datafile . h " <nl> - # include " VocBase / shaped - json . h " <nl> # include " VocBase / voc - types . h " <nl> # include " Wal / Marker . h " <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief number of cache buckets <nl> - / / / TODO : convert to a C + + 11 constexpr once Visual Studio supports it <nl> - / / / ( Visual Studio 2015 ? ) <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - # define LOGFILE_LEGEND_CACHE_BUCKETS 8 <nl> - <nl> namespace arangodb { <nl> namespace wal { <nl> <nl> class Logfile { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> TRI_df_header_marker_t getHeaderMarker ( ) const ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief create a prologue marker <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + TRI_df_prologue_marker_t getPrologueMarker ( TRI_voc_tick_t , TRI_voc_cid_t ) const ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief create a footer marker <nl> class Logfile { <nl> - - _users ; <nl> } <nl> <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief lookup a legend in the cache <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void * lookupLegend ( TRI_voc_cid_t cid , TRI_shape_sid_t sid ) { <nl> - CidSid cs ( cid , sid ) ; <nl> - <nl> - size_t const i = cs . hash ( ) % LOGFILE_LEGEND_CACHE_BUCKETS ; <nl> - <nl> - READ_LOCKER ( readLocker , _legendCacheLock [ i ] ) ; <nl> - <nl> - auto it = _legendCache [ i ] . find ( cs ) ; <nl> - <nl> - if ( it ! = _legendCache [ i ] . end ( ) ) { <nl> - return it - > second ; <nl> - } <nl> - return nullptr ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief cache a legend <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - void cacheLegend ( TRI_voc_cid_t cid , TRI_shape_sid_t sid , void * l ) { <nl> - CidSid cs ( cid , sid ) ; <nl> - <nl> - size_t const i = cs . hash ( ) % LOGFILE_LEGEND_CACHE_BUCKETS ; <nl> - <nl> - WRITE_LOCKER ( writeLocker , _legendCacheLock [ i ] ) ; <nl> - <nl> - auto it = _legendCache [ i ] . find ( cs ) ; <nl> - <nl> - if ( it = = _legendCache [ i ] . end ( ) ) { <nl> - _legendCache [ i ] . emplace ( cs , l ) ; <nl> - } <nl> - } <nl> - <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief the logfile id <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> class Logfile { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> std : : atomic < int64_t > _collectQueueSize ; <nl> - <nl> - private : <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief legend cache , key type with hash function <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - struct CidSid { <nl> - TRI_voc_cid_t cid ; <nl> - TRI_shape_sid_t sid ; <nl> - CidSid ( TRI_voc_cid_t c , TRI_shape_sid_t s ) : cid ( c ) , sid ( s ) { } <nl> - <nl> - size_t hash ( ) const { <nl> - CidSidHash h ; <nl> - return h ( this ) ; <nl> - } <nl> - <nl> - bool operator = = ( CidSid const & a ) const { <nl> - return this - > cid = = a . cid & & this - > sid = = a . sid ; <nl> - } <nl> - } ; <nl> - <nl> - struct CidSidHash { <nl> - size_t operator ( ) ( CidSid const & cs ) const { <nl> - return std : : hash < TRI_voc_cid_t > ( ) ( cs . cid ) ^ <nl> - std : : hash < TRI_shape_sid_t > ( ) ( cs . sid ) ; <nl> - } <nl> - <nl> - size_t operator ( ) ( CidSid const * cs ) const { <nl> - return std : : hash < TRI_voc_cid_t > ( ) ( cs - > cid ) ^ <nl> - std : : hash < TRI_shape_sid_t > ( ) ( cs - > sid ) ; <nl> - } <nl> - } ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief legend cache , split into buckets <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - std : : unordered_map < CidSid , void * , CidSidHash > <nl> - _legendCache [ LOGFILE_LEGEND_CACHE_BUCKETS ] ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief legend cache , locks , split into buckets <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - basics : : ReadWriteLock _legendCacheLock [ LOGFILE_LEGEND_CACHE_BUCKETS ] ; <nl> } ; <nl> } <nl> } <nl> mmm a / arangod / Wal / LogfileManager . cpp <nl> ppp b / arangod / Wal / LogfileManager . cpp <nl> LogfileManager : : LogfileManager ( TRI_server_t * server , std : : string * databasePath ) <nl> _allowOversizeEntries ( true ) , <nl> _ignoreLogfileErrors ( false ) , <nl> _ignoreRecoveryErrors ( false ) , <nl> - _suppressShapeInformation ( false ) , <nl> _allowWrites ( false ) , / / start in read - only mode <nl> _hasFoundLastTick ( false ) , <nl> _inRecovery ( true ) , <nl> void LogfileManager : : setupOptions ( <nl> " wal . reserve - logfiles " , & _reserveLogfiles , <nl> " maximum number of reserve logfiles to maintain " ) ( <nl> " wal . slots " , & _numberOfSlots , " number of logfile slots to use " ) ( <nl> - " wal . suppress - shape - information " , & _suppressShapeInformation , <nl> - " do not write shape information for markers ( saves a lot of disk space , " <nl> - " but effectively disables using the write - ahead log for replication ) " ) ( <nl> " wal . sync - interval " , & _syncInterval , <nl> " interval for automatic , non - requested disk syncs ( in milliseconds ) " ) ( <nl> " wal . throttle - when - pending " , & _throttleWhenPending , <nl> bool LogfileManager : : prepare ( ) { <nl> <nl> if ( _directory . empty ( ) ) { <nl> / / use global configuration variable <nl> - _directory = ( * _databasePath ) ; <nl> + _directory = * _databasePath ; <nl> <nl> if ( ! basics : : FileUtils : : isDirectory ( _directory ) ) { <nl> std : : string systemErrorStr ; <nl> SlotInfo LogfileManager : : allocate ( uint32_t size ) { <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief allocate space in a logfile for later writing , version for legends <nl> - / / / <nl> - / / / See explanations about legends in the corresponding allocateAndWrite <nl> - / / / convenience function . <nl> + / / / @ brief allocate space in a logfile for later writing <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - SlotInfo LogfileManager : : allocate ( uint32_t size , TRI_voc_cid_t cid , <nl> - TRI_shape_sid_t sid , uint32_t legendOffset , <nl> - void * & oldLegend ) { <nl> + SlotInfo LogfileManager : : allocate ( TRI_voc_tick_t databaseId , TRI_voc_cid_t collectionId , <nl> + uint32_t size ) { <nl> if ( ! _allowWrites ) { <nl> - / / no writes allowed <nl> - # ifdef ARANGODB_ENABLE_MAINTAINER_MODE <nl> - TRI_ASSERT ( false ) ; <nl> - # endif <nl> - <nl> + / / no writes allowed <nl> return SlotInfo ( TRI_ERROR_ARANGO_READ_ONLY ) ; <nl> } <nl> <nl> SlotInfo LogfileManager : : allocate ( uint32_t size , TRI_voc_cid_t cid , <nl> return SlotInfo ( TRI_ERROR_ARANGO_DOCUMENT_TOO_LARGE ) ; <nl> } <nl> <nl> - return _slots - > nextUnused ( size , cid , sid , legendOffset , oldLegend ) ; <nl> + return _slots - > nextUnused ( databaseId , collectionId , size ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief finalize a log entry <nl> + / / / @ brief write data into the logfile , using database id and collection id <nl> + / / / this is a convenience function that combines allocate , memcpy and finalize <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - void LogfileManager : : finalize ( SlotInfo & slotInfo , bool waitForSync ) { <nl> - _slots - > returnUsed ( slotInfo , waitForSync ) ; <nl> + SlotInfoCopy LogfileManager : : allocateAndWrite ( TRI_voc_tick_t databaseId , <nl> + TRI_voc_cid_t collectionId , <nl> + void * src , uint32_t size , <nl> + bool waitForSync ) { <nl> + SlotInfo slotInfo = allocate ( databaseId , collectionId , size ) ; <nl> + <nl> + if ( slotInfo . errorCode ! = TRI_ERROR_NO_ERROR ) { <nl> + return SlotInfoCopy ( slotInfo . errorCode ) ; <nl> + } <nl> + <nl> + TRI_ASSERT ( slotInfo . slot ! = nullptr ) ; <nl> + <nl> + try { <nl> + slotInfo . slot - > fill ( src , size ) ; <nl> + <nl> + / / we must copy the slotinfo because finalize ( ) will set its internal to 0 <nl> + / / again <nl> + SlotInfoCopy copy ( slotInfo . slot ) ; <nl> + <nl> + finalize ( slotInfo , waitForSync ) ; <nl> + return copy ; <nl> + } catch ( . . . ) { <nl> + / / if we don ' t return the slot we ' ll run into serious problems later <nl> + finalize ( slotInfo , false ) ; <nl> + <nl> + return SlotInfoCopy ( TRI_ERROR_INTERNAL ) ; <nl> + } <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> SlotInfoCopy LogfileManager : : allocateAndWrite ( void * src , uint32_t size , <nl> try { <nl> slotInfo . slot - > fill ( src , size ) ; <nl> <nl> - / / we must copy the slotinfo because finalize ( ) will set its internal to 0 <nl> + / / we must copy the slotinfo because finalize ( ) will set its internals to 0 <nl> / / again <nl> SlotInfoCopy copy ( slotInfo . slot ) ; <nl> <nl> SlotInfoCopy LogfileManager : : allocateAndWrite ( Marker const & marker , <nl> return allocateAndWrite ( marker . mem ( ) , marker . size ( ) , waitForSync ) ; <nl> } <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief finalize a log entry <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void LogfileManager : : finalize ( SlotInfo & slotInfo , bool waitForSync ) { <nl> + _slots - > returnUsed ( slotInfo , waitForSync ) ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief wait for the collector queue to get cleared for the given collection <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / arangod / Wal / LogfileManager . h <nl> ppp b / arangod / Wal / LogfileManager . h <nl> class LogfileManager : public rest : : ApplicationFeature { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> SlotInfo allocate ( uint32_t ) ; <nl> - <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief reserve space in a logfile , version for legends <nl> + / / / @ brief reserve space in a logfile <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - SlotInfo allocate ( uint32_t , TRI_voc_cid_t cid , TRI_shape_sid_t sid , <nl> - uint32_t legendOffset , void * & oldLegend ) ; <nl> + SlotInfo allocate ( TRI_voc_tick_t , TRI_voc_cid_t , uint32_t ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief finalize a log entry <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> void finalize ( SlotInfo & , bool ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief write data into the logfile , using database id and collection id <nl> + / / / this is a convenience function that combines allocate , memcpy and finalize <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + SlotInfoCopy allocateAndWrite ( TRI_voc_tick_t , TRI_voc_cid_t , void * , uint32_t , bool ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief write data into the logfile <nl> mmm a / arangod / Wal / RecoverState . cpp <nl> ppp b / arangod / Wal / RecoverState . cpp <nl> using namespace arangodb : : wal ; <nl> <nl> template < typename T > <nl> static inline T NumericValue ( VPackSlice const & slice , char const * attribute ) { <nl> + if ( ! slice . isObject ( ) ) { <nl> + LOG ( ERR ) < < " invalid value type when looking for attribute ' " < < attribute < < " ' : expecting object " ; <nl> + THROW_ARANGO_EXCEPTION ( TRI_ERROR_INTERNAL ) ; <nl> + } <nl> VPackSlice v = slice . get ( attribute ) ; <nl> if ( v . isString ( ) ) { <nl> return static_cast < T > ( std : : stoull ( v . copyString ( ) ) ) ; <nl> static inline T NumericValue ( VPackSlice const & slice , char const * attribute ) { <nl> if ( v . isNumber ( ) ) { <nl> return v . getNumber < T > ( ) ; <nl> } <nl> - return 0 ; <nl> + <nl> + LOG ( ERR ) < < " invalid value for attribute ' " < < attribute < < " ' " ; <nl> + THROW_ARANGO_EXCEPTION ( TRI_ERROR_INTERNAL ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> mmm a / arangod / Wal / Slots . cpp <nl> ppp b / arangod / Wal / Slots . cpp <nl> Slots : : Slots ( LogfileManager * logfileManager , size_t numberOfSlots , <nl> _lastAssignedTick ( 0 ) , <nl> _lastCommittedTick ( 0 ) , <nl> _lastCommittedDataTick ( 0 ) , <nl> - _numEvents ( 0 ) { <nl> + _numEvents ( 0 ) , <nl> + _lastDatabaseId ( 0 ) , <nl> + _lastCollectionId ( 0 ) { <nl> _slots = new Slot [ numberOfSlots ] ; <nl> } <nl> <nl> Slot : : TickType Slots : : lastCommittedTick ( ) { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> SlotInfo Slots : : nextUnused ( uint32_t size ) { <nl> + return nextUnused ( 0 , 0 , size ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief return the next unused slot <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + SlotInfo Slots : : nextUnused ( TRI_voc_tick_t databaseId , TRI_voc_cid_t collectionId , <nl> + uint32_t size ) { <nl> + static size_t const PrologueSize = sizeof ( TRI_df_prologue_marker_t ) ; <nl> + <nl> / / we need to use the aligned size for writing <nl> uint32_t alignedSize = TRI_DF_ALIGN_BLOCK ( size ) ; <nl> int iterations = 0 ; <nl> bool hasWaited = false ; <nl> + bool mustWritePrologue = false ; <nl> <nl> TRI_ASSERT ( size > 0 ) ; <nl> <nl> SlotInfo Slots : : nextUnused ( uint32_t size ) { <nl> - - _waiting ; <nl> } <nl> <nl> + if ( databaseId = = 0 & & collectionId = = 0 ) { <nl> + _lastDatabaseId = 0 ; <nl> + _lastCollectionId = 0 ; <nl> + } <nl> + else if ( ! mustWritePrologue & & <nl> + databaseId > 0 & & <nl> + collectionId > 0 & & <nl> + _lastDatabaseId ! = databaseId & & <nl> + _lastCollectionId ! = collectionId ) { <nl> + / / write a prologue <nl> + alignedSize + = PrologueSize ; <nl> + mustWritePrologue = true ; <nl> + } <nl> + <nl> / / cycle until we have a valid logfile <nl> while ( _logfile = = nullptr | | <nl> _logfile - > freeSize ( ) < static_cast < uint64_t > ( alignedSize ) ) { <nl> SlotInfo Slots : : nextUnused ( uint32_t size ) { <nl> return SlotInfo ( TRI_ERROR_INTERNAL ) ; <nl> } <nl> <nl> - / / only in this case we return a valid slot <nl> - slot - > setUsed ( static_cast < void * > ( mem ) , size , _logfile - > id ( ) , handout ( ) ) ; <nl> - <nl> - return SlotInfo ( slot ) ; <nl> - } <nl> - } <nl> - <nl> - / / if we get here , all slots are busy <nl> - CONDITION_LOCKER ( guard , _condition ) ; <nl> - if ( ! hasWaited ) { <nl> - + + _waiting ; <nl> - hasWaited = true ; <nl> - } <nl> - <nl> - bool mustWait ; <nl> - { <nl> - MUTEX_LOCKER ( mutexLocker , _lock ) ; <nl> - mustWait = ( _freeSlots = = 0 ) ; <nl> - } <nl> - <nl> - if ( mustWait ) { <nl> - guard . wait ( 10 * 1000 ) ; <nl> - } <nl> - } <nl> - <nl> - return SlotInfo ( TRI_ERROR_ARANGO_NO_JOURNAL ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief return the next unused slot , version for legends <nl> - / / / <nl> - / / / See explanations in arangod / Wal / LogfileManager . cpp in the <nl> - / / / corresponding allocateAndWrite method . <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - SlotInfo Slots : : nextUnused ( uint32_t size , TRI_voc_cid_t cid , <nl> - TRI_shape_sid_t sid , uint32_t legendOffset , <nl> - void * & oldLegend ) { <nl> - / / legendOffset 0 means no legend included <nl> - / / we need to use the aligned size for writing <nl> - uint32_t alignedSize = TRI_DF_ALIGN_BLOCK ( size ) ; <nl> - int iterations = 0 ; <nl> - bool hasWaited = false ; <nl> + if ( mustWritePrologue ) { <nl> + / / write prologue . . . <nl> <nl> - TRI_ASSERT ( size > 0 ) ; <nl> - <nl> - while ( + + iterations < 1000 ) { <nl> - { <nl> - MUTEX_LOCKER ( mutexLocker , _lock ) ; <nl> - <nl> - Slot * slot = & _slots [ _handoutIndex ] ; <nl> - TRI_ASSERT ( slot ! = nullptr ) ; <nl> - <nl> - if ( slot - > isUnused ( ) ) { <nl> - if ( hasWaited ) { <nl> - CONDITION_LOCKER ( guard , _condition ) ; <nl> - TRI_ASSERT ( _waiting > 0 ) ; <nl> - - - _waiting ; <nl> - } <nl> - <nl> - / / cycle until we have a valid logfile <nl> - while ( _logfile = = nullptr | | <nl> - _logfile - > freeSize ( ) < static_cast < uint64_t > ( alignedSize ) ) { <nl> - if ( _logfile ! = nullptr ) { <nl> - / / seal existing logfile by creating a footer marker <nl> - int res = writeFooter ( slot ) ; <nl> - <nl> - if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - return SlotInfo ( res ) ; <nl> - } <nl> - <nl> - / / advance to next slot <nl> - slot = & _slots [ _handoutIndex ] ; <nl> - _logfileManager - > setLogfileSealRequested ( _logfile ) ; <nl> - <nl> - _logfile = nullptr ; <nl> - } <nl> - <nl> - TRI_IF_FAILURE ( " LogfileManagerGetWriteableLogfile " ) { <nl> - return SlotInfo ( TRI_ERROR_ARANGO_NO_JOURNAL ) ; <nl> - } <nl> - <nl> - / / fetch the next free logfile ( this may create a new one ) <nl> - Logfile : : StatusType status ; <nl> - int res = newLogfile ( alignedSize , status ) ; <nl> + / / hand out the prologue slot and directly fill it <nl> + int res = writePrologue ( slot , databaseId , collectionId ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - if ( res ! = TRI_ERROR_ARANGO_NO_JOURNAL ) { <nl> - return SlotInfo ( res ) ; <nl> - } <nl> - <nl> - usleep ( 10 * 1000 ) ; <nl> - / / try again in next iteration <nl> - } else { <nl> - TRI_ASSERT ( _logfile ! = nullptr ) ; <nl> - <nl> - if ( status = = Logfile : : StatusType : : EMPTY ) { <nl> - / / initialize the empty logfile by writing a header marker <nl> - int res = writeHeader ( slot ) ; <nl> - <nl> - if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> - return SlotInfo ( res ) ; <nl> - } <nl> - <nl> - / / advance to next slot <nl> - slot = & _slots [ _handoutIndex ] ; <nl> - _logfileManager - > setLogfileOpen ( _logfile ) ; <nl> - } else { <nl> - TRI_ASSERT ( status = = Logfile : : StatusType : : OPEN ) ; <nl> - } <nl> + return SlotInfo ( res ) ; <nl> } <nl> - } <nl> - <nl> - / / if we get here , we got a free slot for the actual data . . . <nl> <nl> - / / Now sort out the legend business : <nl> - if ( legendOffset = = 0 ) { <nl> - void * legend = _logfile - > lookupLegend ( cid , sid ) ; <nl> - if ( nullptr = = legend ) { <nl> - / / Bad , we would need a legend for this marker <nl> - return SlotInfo ( TRI_ERROR_LEGEND_NOT_IN_WAL_FILE ) ; <nl> - } <nl> - oldLegend = legend ; <nl> - } <nl> - <nl> - char * mem = _logfile - > reserve ( alignedSize ) ; <nl> - <nl> - if ( mem = = nullptr ) { <nl> - return SlotInfo ( TRI_ERROR_INTERNAL ) ; <nl> - } <nl> + / / now return the slot <nl> + mem + = PrologueSize ; / / advance memory pointer <nl> + <nl> + / / use following slot for the actual data <nl> + slot = & _slots [ _handoutIndex ] ; <nl> <nl> - if ( legendOffset ! = 0 ) { <nl> - void * legend = static_cast < void * > ( mem + legendOffset ) ; <nl> - _logfile - > cacheLegend ( cid , sid , legend ) ; <nl> + / / note database and collection id for next time <nl> + _lastDatabaseId = databaseId ; <nl> + _lastCollectionId = collectionId ; <nl> } <nl> <nl> / / only in this case we return a valid slot <nl> int Slots : : closeLogfile ( Slot : : TickType & lastCommittedTick , bool & worked ) { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> int Slots : : writeHeader ( Slot * slot ) { <nl> - TRI_df_header_marker_t & & header = _logfile - > getHeaderMarker ( ) ; <nl> + TRI_df_header_marker_t header = _logfile - > getHeaderMarker ( ) ; <nl> + size_t const size = header . base . _size ; <nl> + <nl> + TRI_df_marker_t * mem = <nl> + reinterpret_cast < TRI_df_marker_t * > ( _logfile - > reserve ( size ) ) ; <nl> + TRI_ASSERT ( mem ! = nullptr ) ; <nl> + <nl> + slot - > setUsed ( static_cast < void * > ( mem ) , static_cast < uint32_t > ( size ) , <nl> + _logfile - > id ( ) , handout ( ) ) ; <nl> + slot - > fill ( & header . base , size ) ; <nl> + slot - > setReturned ( false ) ; / / no sync <nl> + <nl> + / / reset values for next write <nl> + _lastDatabaseId = 0 ; <nl> + _lastCollectionId = 0 ; <nl> + <nl> + return TRI_ERROR_NO_ERROR ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief write a prologue marker <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + int Slots : : writePrologue ( Slot * slot , TRI_voc_tick_t databaseId , TRI_voc_cid_t collectionId ) { <nl> + TRI_df_header_marker_t header = _logfile - > getHeaderMarker ( ) ; <nl> size_t const size = header . base . _size ; <nl> <nl> TRI_df_marker_t * mem = <nl> int Slots : : writeHeader ( Slot * slot ) { <nl> slot - > setUsed ( static_cast < void * > ( mem ) , static_cast < uint32_t > ( size ) , <nl> _logfile - > id ( ) , handout ( ) ) ; <nl> slot - > fill ( & header . base , size ) ; <nl> - slot - > setReturned ( false ) ; / / sync <nl> + slot - > setReturned ( false ) ; / / no sync <nl> <nl> return TRI_ERROR_NO_ERROR ; <nl> } <nl> int Slots : : writeHeader ( Slot * slot ) { <nl> int Slots : : writeFooter ( Slot * slot ) { <nl> TRI_ASSERT ( _logfile ! = nullptr ) ; <nl> <nl> - TRI_df_footer_marker_t & & footer = _logfile - > getFooterMarker ( ) ; <nl> + TRI_df_footer_marker_t footer = _logfile - > getFooterMarker ( ) ; <nl> size_t const size = footer . base . _size ; <nl> <nl> TRI_df_marker_t * mem = <nl> int Slots : : writeFooter ( Slot * slot ) { <nl> _logfile - > id ( ) , handout ( ) ) ; <nl> slot - > fill ( & footer . base , size ) ; <nl> slot - > setReturned ( true ) ; / / sync <nl> + <nl> + / / reset values for next write <nl> + _lastDatabaseId = 0 ; <nl> + _lastCollectionId = 0 ; <nl> <nl> return TRI_ERROR_NO_ERROR ; <nl> } <nl> mmm a / arangod / Wal / Slots . h <nl> ppp b / arangod / Wal / Slots . h <nl> class Slots { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> SlotInfo nextUnused ( uint32_t ) ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief return the next unused slot , version for legends <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> - SlotInfo nextUnused ( uint32_t size , TRI_voc_cid_t cid , TRI_shape_sid_t sid , <nl> - uint32_t legendIncluded , void * & oldLegend ) ; <nl> + <nl> + SlotInfo nextUnused ( TRI_voc_tick_t , TRI_voc_cid_t , uint32_t ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief return a used slot , allowing its synchronization <nl> class Slots { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> int writeHeader ( Slot * ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief writes a prologue for a document / remove marker <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + int writePrologue ( Slot * , TRI_voc_tick_t , TRI_voc_cid_t ) ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief write a footer marker <nl> class Slots { <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> uint64_t _numEvents ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief last written database id ( in prologue marker ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + TRI_voc_tick_t _lastDatabaseId ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief last written collection id ( in prologue marker ) <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + TRI_voc_cid_t _lastCollectionId ; <nl> } ; <nl> } <nl> } <nl> | write prologue markers for document & remove markers | arangodb/arangodb | 254f6b49b957b79be8bb69099d3864d182ca4ad3 | 2016-02-29T16:08:38Z |
mmm a / vsprojects / README . md <nl> ppp b / vsprojects / README . md <nl> Currently supported versions are Visual Studio 2013 ( our primary focus ) and 2010 <nl> # Building <nl> We are using [ NuGet ] ( http : / / www . nuget . org ) to pull zlib and openssl dependencies . <nl> If you don ' t have Visual Studio NuGet plugin installed , you ' ll need to <nl> - download nuget . exe from web and manually restore the NuGet packages . <nl> + download nuget . exe from the web and manually restore the NuGet packages . <nl> <nl> ` ` ` <nl> > REM Run from this directory . <nl> | fixed grammar in readme | grpc/grpc | 5508c2c2884e86e2e4727eec8276f48e29a7ff46 | 2015-04-21T02:20:51Z |
mmm a / doc / tutorials / calib3d / real_time_pose / real_time_pose . rst <nl> ppp b / doc / tutorials / calib3d / real_time_pose / real_time_pose . rst <nl> The following code is to get the model 3D points and its descriptors and then ca <nl> <nl> if ( fast_match ) <nl> { <nl> - rmatcher . robustMatch ( frame , good_matches , keypoints_scene , descriptors_model ) ; <nl> + rmatcher . fastRobustMatch ( frame , good_matches , keypoints_scene , descriptors_model ) ; <nl> } <nl> else <nl> { <nl> - rmatcher . fastRobustMatch ( frame , good_matches , keypoints_scene , descriptors_model ) ; <nl> + rmatcher . robustMatch ( frame , good_matches , keypoints_scene , descriptors_model ) ; <nl> } <nl> <nl> The following code corresponds to the * robustMatch ( ) * function which belongs to the * RobustMatcher * class . This function uses the given image to detect the keypoints and extract the descriptors , match using * 2 Nearest Neighbour * the extracted descriptors with the given model descriptors and vice versa . Then , is applied a ratio test to the two direction matches in order to remove these matches which its distance ratio between the first and second best match is larger than a given threshold . Finally , a symmetry test is applied in order the remove non symmetrical matches . <nl> The following code is how the * PnPProblem class * initialises its atributes : <nl> <nl> OpenCV provides four PnP methods : ITERATIVE , EPNP , P3P and ? . If we want a real time time application the more suitable methods are EPNP and P3P due to are faster than ITERATIVE finding a solution . Otherwise , EPNP and P3P are not robust especially in front of planar surfaces and sometimes the pose estimation seems to have like a mirror effect . Therefore , in this this tutorial is used ITERATIVE method due to the object to be detected has planar surfaces . <nl> <nl> - The OpenCV Ransac implementation wants you to provide three parameters : the maximum number of iterations until stop the algorithm , the maximum allowed distance between the observed and computed point projections to consider it an inlier and a threshold of minimum number of inliers found . You can tune these paramaters in order to improve your algorithm performance . Increasing the number of iterations you will have a more accurate solution , but will take more time to find a solution . Increasing the reprojection error will reduce the computation time , but your solution will be unaccurate . Decreasing the minimum number of inliers will reduce the computation time with high probability to obtain a bad solution . <nl> + The OpenCV Ransac implementation wants you to provide three parameters : the maximum number of iterations until stop the algorithm , the maximum allowed distance between the observed and computed point projections to consider it an inlier and the confidence to obtain a result . You can tune these paramaters in order to improve your algorithm performance . Increasing the number of iterations you will have a more accurate solution , but will take more time to find a solution . Increasing the reprojection error will reduce the computation time , but your solution will be unaccurate . Decreasing the confidence your arlgorithm will be faster , but the obtained solution will also be unaccurate . <nl> <nl> The following parameters works for this application : <nl> <nl> The following parameters works for this application : <nl> / / RANSAC parameters <nl> <nl> int iterationsCount = 500 ; / / number of Ransac iterations . <nl> - int reprojectionError = 2 . 0 ; / / maximum allowed distance to consider it an inlier . <nl> - int minInliersCount = 70 ; / / thresold of found inliers . <nl> + float reprojectionError = 2 . 0 ; / / maximum allowed distance to consider it an inlier . <nl> + float confidence = 0 . 95 ; / / ransac successful confidence . <nl> <nl> <nl> The following code corresponds to the * estimatePoseRANSAC ( ) * function which belongs to the * PnPProblem class * . This function estimates the rotation and translation matrix given a set of 2D / 3D correspondences , the desired PnP method to use , the output inliers container and the Ransac parameters : <nl> The following code corresponds to the * estimatePoseRANSAC ( ) * function which belo <nl> void PnPProblem : : estimatePoseRANSAC ( const std : : vector < cv : : Point3f > & list_points3d , / / list with model 3D coordinates <nl> const std : : vector < cv : : Point2f > & list_points2d , / / list with scene 2D coordinates <nl> int flags , cv : : Mat & inliers , int iterationsCount , / / PnP method ; inliers container <nl> - double reprojectionError , int minInliersCount ) / / Ransac parameters <nl> + float reprojectionError , float confidence ) / / Ransac parameters <nl> { <nl> cv : : Mat distCoeffs = cv : : Mat : : zeros ( 4 , 1 , CV_64FC1 ) ; / / vector of distortion coefficients <nl> cv : : Mat rvec = cv : : Mat : : zeros ( 3 , 1 , CV_64FC1 ) ; / / output rotation vector <nl> The following code corresponds to the * estimatePoseRANSAC ( ) * function which belo <nl> / / initial approximations of the rotation and translation vectors <nl> <nl> cv : : solvePnPRansac ( list_points3d , list_points2d , _A_matrix , distCoeffs , rvec , tvec , <nl> - useExtrinsicGuess , iterationsCount , reprojectionError , minInliersCount , <nl> + useExtrinsicGuess , iterationsCount , reprojectionError , confidence , <nl> inliers , flags ) ; <nl> <nl> Rodrigues ( rvec , _R_matrix ) ; / / converts Rotation Vector to Matrix <nl> The following videos are the results of pose estimation in real time using the e <nl> <nl> int iterationsCount = 500 ; / / number of Ransac iterations . <nl> int reprojectionError = 2 . 0 ; / / maximum allowed distance to consider it an inlier . <nl> - int minInliersCount = 70 ; / / thresold of found inliers . <nl> + float confidence = 0 . 95 ; / / ransac successful confidence . <nl> <nl> <nl> / / Kalman Filter parameters <nl> mmm a / modules / calib3d / doc / camera_calibration_and_3d_reconstruction . rst <nl> ppp b / modules / calib3d / doc / camera_calibration_and_3d_reconstruction . rst <nl> solvePnPRansac <nl> mmmmmmmmmmmmmmmmmm <nl> Finds an object pose from 3D - 2D point correspondences using the RANSAC scheme . <nl> <nl> - . . ocv : function : : void solvePnPRansac ( InputArray objectPoints , InputArray imagePoints , InputArray cameraMatrix , InputArray distCoeffs , OutputArray rvec , OutputArray tvec , bool useExtrinsicGuess = false , int iterationsCount = 100 , float reprojectionError = 8 . 0 , float confidence = 0 . 99 , OutputArray inliers = noArray ( ) , int flags = ITERATIVE ) <nl> + . . ocv : function : : bool solvePnPRansac ( InputArray objectPoints , InputArray imagePoints , InputArray cameraMatrix , InputArray distCoeffs , OutputArray rvec , OutputArray tvec , bool useExtrinsicGuess = false , int iterationsCount = 100 , float reprojectionError = 8 . 0 , float confidence = 0 . 99 , OutputArray inliers = noArray ( ) , int flags = ITERATIVE ) <nl> <nl> . . ocv : pyfunction : : cv2 . solvePnPRansac ( objectPoints , imagePoints , cameraMatrix , distCoeffs [ , rvec [ , tvec [ , useExtrinsicGuess [ , iterationsCount [ , reprojectionError [ , minInliersCount [ , inliers [ , flags ] ] ] ] ] ] ] ] ) - > rvec , tvec , inliers <nl> <nl> | Update Ransac documentation | opencv/opencv | 89246e1a4572f887b6b00218f249ab4d11040cd4 | 2014-07-09T08:59:00Z |
mmm a / src / rpcblockchain . cpp <nl> ppp b / src / rpcblockchain . cpp <nl> Object blockToJSON ( const CBlock & block , const CBlockIndex * blockindex ) <nl> result . push_back ( Pair ( " nonce " , ( boost : : uint64_t ) block . nNonce ) ) ; <nl> result . push_back ( Pair ( " bits " , HexBits ( block . nBits ) ) ) ; <nl> result . push_back ( Pair ( " difficulty " , GetDifficulty ( blockindex ) ) ) ; <nl> + result . push_back ( Pair ( " chainwork " , blockindex - > nChainWork . GetHex ( ) ) ) ; <nl> <nl> if ( blockindex - > pprev ) <nl> result . push_back ( Pair ( " previousblockhash " , blockindex - > pprev - > GetBlockHash ( ) . GetHex ( ) ) ) ; <nl> | Merge pull request from petertodd / getblock - chainwork | bitcoin/bitcoin | 750ae29664d0e1fd50df464790d8e6aaa666946a | 2013-08-25T02:45:50Z |
mmm a / bindings / go / fdb - go - install . sh <nl> ppp b / bindings / go / fdb - go - install . sh <nl> else <nl> <nl> if [ [ " $ { status } " - eq 0 ] ] ; then <nl> destdir = $ ( cd " $ { destdir } " & & pwd ) # Get absolute path of destination dir . <nl> - fdbdir = " $ { destdir } / foundation " <nl> + fdbdir = " $ { destdir } / foundationdb " <nl> <nl> if [ [ ! - d " $ { destdir } " ] ] ; then <nl> cmd = ( " mkdir " " - p " " $ { destdir } " ) <nl> | Merge pull request from seshness / fdb - go - install | apple/foundationdb | b7ec741f5fdc74c0f5dbe1e38c01aed95bee2a9b | 2018-04-25T05:25:42Z |
mmm a / . circleci / config . yml <nl> ppp b / . circleci / config . yml <nl> parameters : <nl> type : boolean <nl> default : false <nl> <nl> + run - linux - publish : <nl> + type : boolean <nl> + default : false <nl> + <nl> + run - macos - publish : <nl> + type : boolean <nl> + default : false <nl> + <nl> # The config expects the following environment variables to be set : <nl> # - " SLACK_WEBHOOK " Slack hook URL to send notifications . <nl> # <nl> steps - electron - ts - compile - for - doc - change : & steps - electron - ts - compile - for - doc - cha <nl> # Compile ts / js to verify doc change didn ' t break anything <nl> - * step - ts - compile <nl> <nl> - steps - electron - build - for - publish : & steps - electron - build - for - publish <nl> - steps : <nl> - - * step - checkout - electron <nl> - - * step - depot - tools - get <nl> - - * step - depot - tools - add - to - path <nl> - - * step - restore - brew - cache <nl> - - * step - get - more - space - on - mac <nl> - - * step - gclient - sync <nl> - - * step - setup - env - for - build <nl> - - * step - delete - git - directories <nl> - - * step - minimize - workspace - size - from - checkout <nl> - - * step - gn - gen - default <nl> - <nl> - # Electron app <nl> - - * step - electron - build <nl> - - * step - maybe - generate - breakpad - symbols <nl> - - * step - maybe - electron - dist - strip <nl> - - * step - electron - dist - build <nl> - - * step - electron - dist - store <nl> - - * step - maybe - zip - symbols <nl> - - * step - symbols - store <nl> - <nl> - # mksnapshot <nl> - - * step - mksnapshot - build <nl> - - * step - mksnapshot - store <nl> - <nl> - # chromedriver <nl> - - * step - electron - maybe - chromedriver - gn - gen <nl> - - * step - electron - chromedriver - build <nl> - - * step - electron - chromedriver - store <nl> - <nl> - # Node . js headers <nl> - - * step - nodejs - headers - build <nl> - - * step - nodejs - headers - store <nl> - <nl> - # ffmpeg <nl> - - * step - ffmpeg - gn - gen <nl> - - * step - ffmpeg - build <nl> - - * step - ffmpeg - store <nl> - <nl> - # hunspell <nl> - - * step - hunspell - build <nl> - - * step - hunspell - store <nl> - <nl> - # typescript defs <nl> - - * step - maybe - generate - typescript - defs <nl> - <nl> - # Publish <nl> - - * step - electron - publish <nl> - <nl> steps - chromedriver - build : & steps - chromedriver - build <nl> steps : <nl> - attach_workspace : <nl> commands : <nl> use - out - cache : <nl> type : boolean <nl> default : true <nl> + restore - src - cache : <nl> + type : boolean <nl> + default : true <nl> + preserve - vendor - dirs : <nl> + type : boolean <nl> + default : false <nl> steps : <nl> - when : <nl> condition : < < parameters . attach > > <nl> commands : <nl> - * step - get - more - space - on - mac <nl> - * step - generate - deps - hash <nl> - * step - touch - sync - done <nl> - - maybe - restore - portaled - src - cache <nl> + - when : <nl> + condition : < < parameters . restore - src - cache > > <nl> + steps : <nl> + - maybe - restore - portaled - src - cache <nl> - * step - maybe - restore - git - cache <nl> - * step - set - git - cache - path <nl> # This sync call only runs if . circle - sync - done is an EMPTY file <nl> - * step - gclient - sync <nl> # These next few steps reset Electron to the correct commit regardless of which cache was restored <nl> + - when : <nl> + condition : < < parameters . preserve - vendor - dirs > > <nl> + steps : <nl> + - run : <nl> + name : Preserve vendor dirs for release <nl> + command : | <nl> + mv src / electron / vendor / boto . <nl> + mv src / electron / vendor / requests . <nl> - run : <nl> name : Wipe Electron <nl> command : rm - rf src / electron <nl> - * step - checkout - electron <nl> - * step - run - electron - only - hooks <nl> + - when : <nl> + condition : < < parameters . preserve - vendor - dirs > > <nl> + steps : <nl> + - run : <nl> + name : Preserve vendor dirs for release <nl> + command : | <nl> + rm - rf src / electron / vendor / boto <nl> + rm - rf src / electron / vendor / requests <nl> + mv boto src / electron / vendor <nl> + mv requests src / electron / vendor / requests <nl> - * step - generate - deps - hash - cleanly <nl> - * step - mark - sync - done <nl> - * step - minimize - workspace - size - from - checkout <nl> commands : <nl> steps : <nl> - * step - save - out - cache <nl> <nl> - # Trigger tests on arm hardware if needed <nl> - - * step - maybe - trigger - arm - test <nl> + # Trigger tests on arm hardware if needed <nl> + - * step - maybe - trigger - arm - test <nl> <nl> - - * step - maybe - notify - slack - failure <nl> + - * step - maybe - notify - slack - failure <nl> + <nl> + electron - publish : <nl> + parameters : <nl> + attach : <nl> + type : boolean <nl> + default : false <nl> + checkout : <nl> + type : boolean <nl> + default : true <nl> + steps : <nl> + - when : <nl> + condition : < < parameters . attach > > <nl> + steps : <nl> + - attach_workspace : <nl> + at : . <nl> + - when : <nl> + condition : < < parameters . checkout > > <nl> + steps : <nl> + - * step - depot - tools - get <nl> + - * step - depot - tools - add - to - path <nl> + - * step - restore - brew - cache <nl> + - * step - get - more - space - on - mac <nl> + - when : <nl> + condition : < < parameters . checkout > > <nl> + steps : <nl> + - * step - checkout - electron <nl> + - * step - gclient - sync <nl> + - * step - delete - git - directories <nl> + - * step - minimize - workspace - size - from - checkout <nl> + - * step - fix - sync - on - mac <nl> + - * step - setup - env - for - build <nl> + - * step - gn - gen - default <nl> + <nl> + # Electron app <nl> + - * step - electron - build <nl> + - * step - show - sccache - stats <nl> + - * step - maybe - generate - breakpad - symbols <nl> + - * step - maybe - electron - dist - strip <nl> + - * step - electron - dist - build <nl> + - * step - electron - dist - store <nl> + - * step - maybe - zip - symbols <nl> + - * step - symbols - store <nl> + <nl> + # mksnapshot <nl> + - * step - mksnapshot - build <nl> + - * step - mksnapshot - store <nl> + <nl> + # chromedriver <nl> + - * step - electron - maybe - chromedriver - gn - gen <nl> + - * step - electron - chromedriver - build <nl> + - * step - electron - chromedriver - store <nl> + <nl> + # Node . js headers <nl> + - * step - nodejs - headers - build <nl> + - * step - nodejs - headers - store <nl> + <nl> + # ffmpeg <nl> + - * step - ffmpeg - gn - gen <nl> + - * step - ffmpeg - build <nl> + - * step - ffmpeg - store <nl> + <nl> + # hunspell <nl> + - * step - hunspell - build <nl> + - * step - hunspell - store <nl> + <nl> + # typescript defs <nl> + - * step - maybe - generate - typescript - defs <nl> + <nl> + # Publish <nl> + - * step - electron - publish <nl> <nl> # List of all jobs . <nl> jobs : <nl> jobs : <nl> < < : * steps - electron - ts - compile - for - doc - change <nl> <nl> # Layer 1 : Checkout . <nl> + linux - checkout : <nl> + < < : * machine - linux - 2xlarge <nl> + environment : <nl> + < < : * env - linux - 2xlarge <nl> + GCLIENT_EXTRA_ARGS : ' - - custom - var = checkout_arm = True - - custom - var = checkout_arm64 = True - - custom - var = checkout_boto = True - - custom - var = checkout_requests = True ' <nl> + steps : <nl> + - electron - build : <nl> + persist : false <nl> + build : false <nl> + checkout : true <nl> + persist - checkout : true <nl> + restore - src - cache : false <nl> + preserve - vendor - dirs : true <nl> + <nl> linux - checkout - fast : <nl> < < : * machine - linux - 2xlarge <nl> environment : <nl> jobs : <nl> checkout : true <nl> persist - checkout : true <nl> <nl> + mac - checkout : <nl> + < < : * machine - linux - 2xlarge <nl> + environment : <nl> + < < : * env - linux - 2xlarge <nl> + < < : * env - testing - build <nl> + < < : * env - macos - build <nl> + GCLIENT_EXTRA_ARGS : ' - - custom - var = checkout_mac = True - - custom - var = host_os = mac - - custom - var = checkout_boto = True - - custom - var = checkout_requests = True ' <nl> + steps : <nl> + - electron - build : <nl> + persist : false <nl> + build : false <nl> + checkout : true <nl> + persist - checkout : true <nl> + restore - src - cache : false <nl> + preserve - vendor - dirs : true <nl> + <nl> mac - checkout - fast : <nl> < < : * machine - linux - 2xlarge <nl> environment : <nl> jobs : <nl> < < : * env - release - build <nl> < < : * env - enable - sccache <nl> UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> - < < : * steps - electron - build - for - publish <nl> + steps : <nl> + - electron - publish : <nl> + attach : false <nl> + checkout : true <nl> + <nl> + linux - x64 - publish - skip - checkout : <nl> + < < : * machine - linux - 2xlarge <nl> + environment : <nl> + < < : * env - linux - 2xlarge - release <nl> + < < : * env - release - build <nl> + < < : * env - enable - sccache <nl> + UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> + steps : <nl> + - electron - publish : <nl> + attach : true <nl> + checkout : false <nl> <nl> linux - ia32 - testing : <nl> < < : * machine - linux - 2xlarge <nl> jobs : <nl> < < : * env - enable - sccache <nl> < < : * env - 32bit - release <nl> UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> - < < : * steps - electron - build - for - publish <nl> + steps : <nl> + - electron - publish : <nl> + attach : false <nl> + checkout : true <nl> + <nl> + linux - ia32 - publish - skip - checkout : <nl> + < < : * machine - linux - 2xlarge <nl> + environment : <nl> + < < : * env - linux - 2xlarge - release <nl> + < < : * env - ia32 <nl> + < < : * env - release - build <nl> + < < : * env - enable - sccache <nl> + < < : * env - 32bit - release <nl> + UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> + steps : <nl> + - electron - publish : <nl> + attach : true <nl> + checkout : false <nl> <nl> linux - arm - testing : <nl> < < : * machine - linux - 2xlarge <nl> jobs : <nl> < < : * env - 32bit - release <nl> GCLIENT_EXTRA_ARGS : ' - - custom - var = checkout_arm = True - - custom - var = checkout_boto = True - - custom - var = checkout_requests = True ' <nl> UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> - < < : * steps - electron - build - for - publish <nl> + steps : <nl> + - electron - publish : <nl> + attach : false <nl> + checkout : true <nl> + <nl> + linux - arm - publish - skip - checkout : <nl> + < < : * machine - linux - 2xlarge <nl> + environment : <nl> + < < : * env - linux - 2xlarge - release <nl> + < < : * env - arm <nl> + < < : * env - release - build <nl> + < < : * env - enable - sccache <nl> + < < : * env - 32bit - release <nl> + UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> + steps : <nl> + - electron - publish : <nl> + attach : true <nl> + checkout : false <nl> <nl> linux - arm64 - testing : <nl> < < : * machine - linux - 2xlarge <nl> jobs : <nl> < < : * env - enable - sccache <nl> GCLIENT_EXTRA_ARGS : ' - - custom - var = checkout_arm64 = True - - custom - var = checkout_boto = True - - custom - var = checkout_requests = True ' <nl> UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> - < < : * steps - electron - build - for - publish <nl> + steps : <nl> + - electron - publish : <nl> + attach : false <nl> + checkout : true <nl> + <nl> + linux - arm64 - publish - skip - checkout : <nl> + < < : * machine - linux - 2xlarge <nl> + environment : <nl> + < < : * env - linux - 2xlarge - release <nl> + < < : * env - arm64 <nl> + < < : * env - release - build <nl> + < < : * env - enable - sccache <nl> + UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> + steps : <nl> + - electron - publish : <nl> + attach : true <nl> + checkout : false <nl> <nl> osx - testing : <nl> < < : * machine - mac - large <nl> jobs : <nl> < < : * env - enable - sccache <nl> GCLIENT_EXTRA_ARGS : ' - - custom - var = checkout_boto = True - - custom - var = checkout_requests = True ' <nl> UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> - < < : * steps - electron - build - for - publish <nl> + steps : <nl> + - electron - publish : <nl> + attach : false <nl> + checkout : true <nl> + <nl> + osx - publish - skip - checkout : <nl> + < < : * machine - mac - large <nl> + environment : <nl> + < < : * env - mac - large - release <nl> + < < : * env - release - build <nl> + < < : * env - enable - sccache <nl> + UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> + steps : <nl> + - electron - publish : <nl> + attach : true <nl> + checkout : false <nl> <nl> mas - testing : <nl> < < : * machine - mac - large <nl> jobs : <nl> < < : * env - enable - sccache <nl> GCLIENT_EXTRA_ARGS : ' - - custom - var = checkout_boto = True - - custom - var = checkout_requests = True ' <nl> UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> - < < : * steps - electron - build - for - publish <nl> + steps : <nl> + - electron - publish : <nl> + attach : false <nl> + checkout : true <nl> + <nl> + mas - publish - skip - checkout : <nl> + < < : * machine - mac - large <nl> + environment : <nl> + < < : * env - mac - large - release <nl> + < < : * env - mas <nl> + < < : * env - release - build <nl> + < < : * env - enable - sccache <nl> + UPLOAD_TO_S3 : < < pipeline . parameters . upload - to - s3 > > <nl> + steps : <nl> + - electron - publish : <nl> + attach : true <nl> + checkout : false <nl> <nl> # Layer 3 : Tests . <nl> linux - x64 - unittests : <nl> workflows : <nl> # will need to be updated and there will most likely need to be changes to <nl> # sudowoodo <nl> <nl> + publish - linux : <nl> + when : < < pipeline . parameters . run - linux - publish > > <nl> + jobs : <nl> + - linux - checkout <nl> + - linux - x64 - publish - skip - checkout : <nl> + requires : <nl> + - linux - checkout <nl> + context : release - env <nl> + - linux - ia32 - publish - skip - checkout : <nl> + requires : <nl> + - linux - checkout <nl> + context : release - env <nl> + - linux - arm - publish - skip - checkout : <nl> + requires : <nl> + - linux - checkout <nl> + context : release - env <nl> + - linux - arm64 - publish - skip - checkout : <nl> + requires : <nl> + - linux - checkout <nl> + context : release - env <nl> + <nl> publish - x64 - linux : <nl> when : < < pipeline . parameters . run - linux - x64 - publish > > <nl> jobs : <nl> workflows : <nl> - mas - publish : <nl> context : release - env <nl> <nl> + publish - macos : <nl> + when : < < pipeline . parameters . run - macos - publish > > <nl> + jobs : <nl> + - mac - checkout <nl> + - osx - publish - skip - checkout : <nl> + requires : <nl> + - mac - checkout <nl> + - mas - publish - skip - checkout : <nl> + requires : <nl> + - mac - checkout <nl> + <nl> lint : <nl> when : < < pipeline . parameters . run - lint > > <nl> jobs : <nl> mmm a / script / release / ci - release - build . js <nl> ppp b / script / release / ci - release - build . js <nl> const circleCIJobs = [ <nl> ' osx - publish ' <nl> ] <nl> <nl> + const circleCIPublishWorkflows = [ <nl> + ' linux - publish ' , <nl> + ' macos - publish ' <nl> + ] <nl> + <nl> const vstsArmJobs = [ <nl> ' electron - arm - testing ' , <nl> ' electron - arm64 - testing ' , <nl> async function circleCIcall ( targetBranch , job , options ) { <nl> if ( workflowId = = = - 1 ) { <nl> return <nl> } <nl> - console . log ( ` CircleCI release build workflow running at https : / / circleci . com / workflow - run / $ { workflowId } for $ { job } . ` ) <nl> - const jobNumber = await getCircleCIJobNumber ( workflowId ) <nl> - if ( jobNumber = = = - 1 ) { <nl> - return <nl> + const workFlowUrl = ` https : / / circleci . com / workflow - run / $ { workflowId } ` <nl> + if ( options . runningPublishWorkflows ) { <nl> + console . log ( ` CircleCI release workflow request for $ { job } successful . Check $ { workFlowUrl } for status . ` ) <nl> + } else { <nl> + console . log ( ` CircleCI release build workflow running at https : / / circleci . com / workflow - run / $ { workflowId } for $ { job } . ` ) <nl> + const jobNumber = await getCircleCIJobNumber ( workflowId ) <nl> + if ( jobNumber = = = - 1 ) { <nl> + return <nl> + } <nl> + const jobUrl = ` https : / / circleci . com / gh / electron / electron / $ { jobNumber } ` <nl> + console . log ( ` CircleCI release build request for $ { job } successful . Check $ { jobUrl } for status . ` ) <nl> } <nl> - const jobUrl = ` https : / / circleci . com / gh / electron / electron / $ { jobNumber } ` <nl> - console . log ( ` CircleCI release build request for $ { job } successful . Check $ { jobUrl } for status . ` ) <nl> } catch ( err ) { <nl> console . log ( ' Error calling CircleCI : ' , err ) <nl> } <nl> function buildCircleCI ( targetBranch , options ) { <nl> assert ( circleCIJobs . includes ( options . job ) , ` Unknown CircleCI job name : $ { options . job } . Valid values are : $ { circleCIJobs } . ` ) <nl> circleCIcall ( targetBranch , options . job , options ) <nl> } else { <nl> - circleCIJobs . forEach ( ( job ) = > circleCIcall ( targetBranch , job , options ) ) <nl> + options . runningPublishWorkflows = true <nl> + circleCIPublishWorkflows . forEach ( ( job ) = > circleCIcall ( targetBranch , job , options ) ) <nl> } <nl> } <nl> <nl> | ci : Speed up release ( ) | electron/electron | 023a3ca7226fd9301b17dca5e5f7b5eb0afa4f6a | 2020-02-11T20:42:37Z |
mmm a / src / x64 / lithium - codegen - x64 . cc <nl> ppp b / src / x64 / lithium - codegen - x64 . cc <nl> void LCodeGen : : DoMathRound ( LMathRound * instr ) { <nl> const XMMRegister xmm_scratch = double_scratch0 ( ) ; <nl> Register output_reg = ToRegister ( instr - > result ( ) ) ; <nl> XMMRegister input_reg = ToDoubleRegister ( instr - > value ( ) ) ; <nl> + XMMRegister input_temp = ToDoubleRegister ( instr - > temp ( ) ) ; <nl> static int64_t one_half = V8_INT64_C ( 0x3FE0000000000000 ) ; / / 0 . 5 <nl> static int64_t minus_one_half = V8_INT64_C ( 0xBFE0000000000000 ) ; / / - 0 . 5 <nl> <nl> - Label done , round_to_zero , below_one_half , do_not_compensate , restore ; <nl> + Label done , round_to_zero , below_one_half ; <nl> Label : : Distance dist = DeoptEveryNTimes ( ) ? Label : : kFar : Label : : kNear ; <nl> __ movq ( kScratchRegister , one_half ) ; <nl> __ movq ( xmm_scratch , kScratchRegister ) ; <nl> void LCodeGen : : DoMathRound ( LMathRound * instr ) { <nl> <nl> / / CVTTSD2SI rounds towards zero , we use ceil ( x - ( - 0 . 5 ) ) and then <nl> / / compare and compensate . <nl> - __ movq ( kScratchRegister , input_reg ) ; / / Back up input_reg . <nl> - __ subsd ( input_reg , xmm_scratch ) ; <nl> - __ cvttsd2si ( output_reg , input_reg ) ; <nl> + __ movq ( input_temp , input_reg ) ; / / Do not alter input_reg . <nl> + __ subsd ( input_temp , xmm_scratch ) ; <nl> + __ cvttsd2si ( output_reg , input_temp ) ; <nl> / / Catch minint due to overflow , and to prevent overflow when compensating . <nl> __ cmpl ( output_reg , Immediate ( 0x80000000 ) ) ; <nl> __ RecordComment ( " D2I conversion overflow " ) ; <nl> DeoptimizeIf ( equal , instr - > environment ( ) ) ; <nl> <nl> __ Cvtlsi2sd ( xmm_scratch , output_reg ) ; <nl> - __ ucomisd ( input_reg , xmm_scratch ) ; <nl> - __ j ( equal , & restore , Label : : kNear ) ; <nl> + __ ucomisd ( xmm_scratch , input_temp ) ; <nl> + __ j ( equal , & done , dist ) ; <nl> __ subl ( output_reg , Immediate ( 1 ) ) ; <nl> / / No overflow because we already ruled out minint . <nl> - __ bind ( & restore ) ; <nl> - __ movq ( input_reg , kScratchRegister ) ; / / Restore input_reg . <nl> __ jmp ( & done , dist ) ; <nl> <nl> __ bind ( & round_to_zero ) ; <nl> mmm a / src / x64 / lithium - x64 . cc <nl> ppp b / src / x64 / lithium - x64 . cc <nl> LInstruction * LChunkBuilder : : DoMathFloor ( HUnaryMathOperation * instr ) { <nl> <nl> <nl> LInstruction * LChunkBuilder : : DoMathRound ( HUnaryMathOperation * instr ) { <nl> - LOperand * input = UseRegisterAtStart ( instr - > value ( ) ) ; <nl> - LMathRound * result = new ( zone ( ) ) LMathRound ( input ) ; <nl> + LOperand * input = UseRegister ( instr - > value ( ) ) ; <nl> + LOperand * temp = FixedTemp ( xmm4 ) ; <nl> + LMathRound * result = new ( zone ( ) ) LMathRound ( input , temp ) ; <nl> return AssignEnvironment ( DefineAsRegister ( result ) ) ; <nl> } <nl> <nl> mmm a / src / x64 / lithium - x64 . h <nl> ppp b / src / x64 / lithium - x64 . h <nl> class LMathFloor V8_FINAL : public LTemplateInstruction < 1 , 1 , 0 > { <nl> } ; <nl> <nl> <nl> - class LMathRound V8_FINAL : public LTemplateInstruction < 1 , 1 , 0 > { <nl> + class LMathRound V8_FINAL : public LTemplateInstruction < 1 , 1 , 1 > { <nl> public : <nl> - explicit LMathRound ( LOperand * value ) { <nl> + explicit LMathRound ( LOperand * value , LOperand * temp ) { <nl> inputs_ [ 0 ] = value ; <nl> + temps_ [ 0 ] = temp ; <nl> } <nl> <nl> LOperand * value ( ) { return inputs_ [ 0 ] ; } <nl> + LOperand * temp ( ) { return temps_ [ 0 ] ; } <nl> <nl> DECLARE_CONCRETE_INSTRUCTION ( MathRound , " math - round " ) <nl> DECLARE_HYDROGEN_ACCESSOR ( UnaryMathOperation ) <nl> new file mode 100644 <nl> index 00000000000 . . fc3715b65a3 <nl> mmm / dev / null <nl> ppp b / test / mjsunit / regress / regress - 351624 . js <nl> <nl> + / / Copyright 2014 the V8 project authors . All rights reserved . <nl> + / / Use of this source code is governed by a BSD - style license that can be <nl> + / / found in the LICENSE file . <nl> + <nl> + / / Flags : - - allow - natives - syntax <nl> + <nl> + var big = 1e10 ; <nl> + var backup = new Float64Array ( 1 ) ; <nl> + <nl> + function mult0 ( val ) { <nl> + var prod = val * big ; <nl> + backup [ 0 ] = prod ; <nl> + var rounded = Math . round ( prod ) ; <nl> + assertEquals ( prod , backup [ 0 ] ) ; <nl> + return rounded ; <nl> + } <nl> + <nl> + var count = 5 ; <nl> + for ( var i = 0 ; i < count ; i + + ) { <nl> + if ( i = = count - 1 ) % OptimizeFunctionOnNextCall ( mult0 ) ; <nl> + var result = mult0 ( - 1 ) ; <nl> + assertEquals ( result , - big ) ; <nl> + } <nl> | Correctly retain argument value when deopting from Math . round on x64 . | v8/v8 | 0f71a24f3a433e2b8a425f5a1e62b4ed0a2eb74b | 2014-03-13T13:57:21Z |
mmm a / dbms / src / DataStreams / DistinctBlockInputStream . cpp <nl> ppp b / dbms / src / DataStreams / DistinctBlockInputStream . cpp <nl> Block DistinctBlockInputStream : : readImpl ( ) <nl> / / / a block with some new records will be gotten . <nl> while ( 1 ) <nl> { <nl> + if ( no_more_rows ) <nl> + return Block ( ) ; <nl> + <nl> / / / Stop reading if we already reach the limit . <nl> if ( limit_hint & & data . getTotalRowCount ( ) > = limit_hint ) <nl> return Block ( ) ; <nl> Block DistinctBlockInputStream : : readImpl ( ) <nl> <nl> const ColumnRawPtrs column_ptrs ( getKeyColumns ( block ) ) ; <nl> if ( column_ptrs . empty ( ) ) <nl> + { <nl> + / / / Only constants . We need to return single row . <nl> + no_more_rows = true ; <nl> + for ( auto & elem : block ) <nl> + elem . column = elem . column - > cut ( 0 , 1 ) ; <nl> return block ; <nl> + } <nl> <nl> if ( data . empty ( ) ) <nl> data . init ( SetVariants : : chooseMethod ( column_ptrs , key_sizes ) ) ; <nl> Block DistinctBlockInputStream : : readImpl ( ) <nl> { <nl> case SetVariants : : Type : : EMPTY : <nl> break ; <nl> - # define M ( NAME ) \ <nl> + # define M ( NAME ) \ <nl> case SetVariants : : Type : : NAME : \ <nl> buildFilter ( * data . NAME , column_ptrs , filter , rows , data ) ; \ <nl> break ; <nl> - APPLY_FOR_SET_VARIANTS ( M ) <nl> - # undef M <nl> + APPLY_FOR_SET_VARIANTS ( M ) <nl> + # undef M <nl> } <nl> <nl> / / / Just go to the next block if there isn ' t any new record in the current one . <nl> Block DistinctBlockInputStream : : readImpl ( ) <nl> } <nl> } <nl> <nl> - size_t all_columns = block . columns ( ) ; <nl> - for ( size_t i = 0 ; i < all_columns ; + + i ) <nl> - block . safeGetByPosition ( i ) . column = block . safeGetByPosition ( i ) . column - > filter ( filter , - 1 ) ; <nl> + for ( auto & elem : block ) <nl> + elem . column = elem . column - > filter ( filter , - 1 ) ; <nl> <nl> return block ; <nl> } <nl> mmm a / dbms / src / DataStreams / DistinctBlockInputStream . h <nl> ppp b / dbms / src / DataStreams / DistinctBlockInputStream . h <nl> class DistinctBlockInputStream : public IProfilingBlockInputStream <nl> Sizes key_sizes ; <nl> size_t limit_hint ; <nl> <nl> + bool no_more_rows = false ; <nl> + <nl> / / / Restrictions on the maximum size of the output data . <nl> size_t max_rows ; <nl> size_t max_bytes ; <nl> | Fixed DISTINCT if all columns are constant [ # CLICKHOUSE - 3505 ] . | ClickHouse/ClickHouse | 7ee1c81d45ae9f02804a44d91dbac04256054431 | 2017-12-24T07:59:26Z |
mmm a / xbmc / peripherals / devices / PeripheralCecAdapter . cpp <nl> ppp b / xbmc / peripherals / devices / PeripheralCecAdapter . cpp <nl> void CPeripheralCecAdapter : : Process ( void ) <nl> <nl> CLog : : Log ( LOGDEBUG , " % s - connection to the CEC adapter opened " , __FUNCTION__ ) ; <nl> <nl> - / * get the vendor id directly after connecting , because the TV might be using a non - standard CEC implementation * / <nl> - m_cecAdapter - > GetDeviceVendorId ( CECDEVICE_TV ) ; <nl> - <nl> m_bIsReady = true ; <nl> CAnnouncementManager : : AddAnnouncer ( this ) ; <nl> <nl> - / / set correct physical address from peripheral settings <nl> - int iHdmiPort = GetSettingInt ( " cec_hdmi_port " ) ; <nl> - if ( iHdmiPort < = 0 | | iHdmiPort > 16 ) <nl> - iHdmiPort = 1 ; <nl> - m_cecAdapter - > SetPhysicalAddress ( ( uint16_t ) ( iHdmiPort < < 12 ) ) ; <nl> - <nl> - FlushLog ( ) ; <nl> - <nl> if ( GetSettingBool ( " cec_power_on_startup " ) ) <nl> { <nl> - cec_power_status status = m_cecAdapter - > GetDevicePowerStatus ( CECDEVICE_TV ) ; <nl> - if ( status = = CEC_POWER_STATUS_STANDBY | | <nl> - status = = CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY ) <nl> - PowerOnCecDevices ( CECDEVICE_TV ) ; <nl> + PowerOnCecDevices ( CECDEVICE_TV ) ; <nl> FlushLog ( ) ; <nl> } <nl> <nl> - m_cecAdapter - > SetActiveView ( ) ; <nl> + / * get the vendor id directly after connecting , because the TV might be using a non - standard CEC implementation * / <nl> + m_cecAdapter - > GetDeviceVendorId ( CECDEVICE_TV ) ; <nl> + <nl> + / / set correct physical address from peripheral settings <nl> + int iHdmiPort = GetSettingInt ( " cec_hdmi_port " ) ; <nl> + if ( iHdmiPort < = 0 | | iHdmiPort > 16 ) <nl> + iHdmiPort = 1 ; <nl> + m_cecAdapter - > SetPhysicalAddress ( ( uint16_t ) ( iHdmiPort < < 12 ) ) ; <nl> FlushLog ( ) ; <nl> <nl> if ( GetSettingBool ( " use_tv_menu_language " ) ) <nl> | cec : fixed - send the power up command as first command when powering up , as the spec describes | xbmc/xbmc | db7a8b7fa3ae4527e42771cc890847e87c7e5a74 | 2011-11-20T23:59:59Z |
mmm a / src / mongo / db / auth / authorization_manager . cpp <nl> ppp b / src / mongo / db / auth / authorization_manager . cpp <nl> namespace { <nl> clusterAdminRoleReadActions . addAction ( ActionType : : touch ) ; <nl> clusterAdminRoleReadActions . addAction ( ActionType : : unlock ) ; <nl> clusterAdminRoleReadActions . addAction ( ActionType : : unsetSharding ) ; <nl> + clusterAdminRoleReadActions . addAction ( ActionType : : writeBacksQueued ) ; <nl> <nl> clusterAdminRoleWriteActions . addAction ( ActionType : : addShard ) ; <nl> clusterAdminRoleWriteActions . addAction ( ActionType : : closeAllDatabases ) ; <nl> namespace { <nl> internalActions . addAction ( ActionType : : replSetGetRBID ) ; <nl> internalActions . addAction ( ActionType : : replSetHeartbeat ) ; <nl> internalActions . addAction ( ActionType : : writebacklisten ) ; <nl> - internalActions . addAction ( ActionType : : writeBacksQueued ) ; <nl> internalActions . addAction ( ActionType : : _migrateClone ) ; <nl> internalActions . addAction ( ActionType : : _recvChunkAbort ) ; <nl> internalActions . addAction ( ActionType : : _recvChunkCommit ) ; <nl> | SERVER - 9649 Make writeBacksQueued be granted by clusterAdmin | mongodb/mongo | 9a1b92102088670581bc0e8e522465b2a3d359e0 | 2013-05-10T17:00:48Z |
mmm a / s / server . cpp <nl> ppp b / s / server . cpp <nl> int _main ( int argc , char * argv [ ] ) { <nl> return 5 ; <nl> } <nl> <nl> - / / we either have a seeting were all process are in localhost or none is <nl> + / / we either have a setting where all processes are in localhost or none are <nl> for ( vector < string > : : const_iterator it = configdbs . begin ( ) ; it ! = configdbs . end ( ) ; + + it ) { <nl> try { <nl> <nl> | Another grammar fix . Minor commit . | mongodb/mongo | 911f80cd1dc9cdcb0343fe7cab2187e3b88430b6 | 2011-05-26T10:03:34Z |
mmm a / programs / cleos / main . cpp <nl> ppp b / programs / cleos / main . cpp <nl> int main ( int argc , char * * argv ) { <nl> if ( verbose_errors ) { <nl> elog ( " connect error : $ { e } " , ( " e " , e . to_detail_string ( ) ) ) ; <nl> } <nl> + return 1 ; <nl> } catch ( const fc : : exception & e ) { <nl> / / attempt to extract the error code if one is present <nl> if ( ! print_recognized_errors ( e , verbose_errors ) ) { <nl> | Fix return value when throws connection_exception in cleos | EOSIO/eos | afc614f75cd7d41a391e4db72847e3a0fe344236 | 2018-10-02T12:56:49Z |
mmm a / modules / core / src / matrix . cpp <nl> ppp b / modules / core / src / matrix . cpp <nl> void Mat : : create ( int d , const int * _sizes , int _type ) <nl> return ; <nl> } <nl> <nl> + int _sizes_backup [ CV_MAX_DIM ] ; / / # 5991 <nl> + if ( _sizes = = ( this - > size . p ) ) <nl> + { <nl> + for ( i = 0 ; i < d ; i + + ) <nl> + _sizes_backup [ i ] = _sizes [ i ] ; <nl> + _sizes = _sizes_backup ; <nl> + } <nl> + <nl> release ( ) ; <nl> if ( d = = 0 ) <nl> return ; <nl> void SparseMat : : create ( int d , const int * _sizes , int _type ) <nl> return ; <nl> } <nl> } <nl> + int _sizes_backup [ CV_MAX_DIM ] ; / / # 5991 <nl> + if ( _sizes = = hdr - > size ) <nl> + { <nl> + for ( i = 0 ; i < d ; i + + ) <nl> + _sizes_backup [ i ] = _sizes [ i ] ; <nl> + _sizes = _sizes_backup ; <nl> + } <nl> release ( ) ; <nl> flags = MAGIC_VAL | _type ; <nl> hdr = new Hdr ( d , _sizes , _type ) ; <nl> mmm a / modules / core / src / umatrix . cpp <nl> ppp b / modules / core / src / umatrix . cpp <nl> void UMat : : create ( int d , const int * _sizes , int _type , UMatUsageFlags _usageFlag <nl> return ; <nl> } <nl> <nl> + int _sizes_backup [ CV_MAX_DIM ] ; / / # 5991 <nl> + if ( _sizes = = ( this - > size . p ) ) <nl> + { <nl> + for ( i = 0 ; i < d ; i + + ) <nl> + _sizes_backup [ i ] = _sizes [ i ] ; <nl> + _sizes = _sizes_backup ; <nl> + } <nl> + <nl> release ( ) ; <nl> if ( d = = 0 ) <nl> return ; <nl> mmm a / modules / core / test / test_mat . cpp <nl> ppp b / modules / core / test / test_mat . cpp <nl> TEST ( Core_Mat_vector , copyTo_roi_row ) <nl> EXPECT_EQ ( 4 , ( int ) dst2 [ 3 ] ) ; <nl> EXPECT_EQ ( 5 , ( int ) dst2 [ 4 ] ) ; <nl> } <nl> + <nl> + TEST ( Mat , regression_5991 ) <nl> + { <nl> + int sz [ ] = { 2 , 3 , 2 } ; <nl> + Mat mat ( 3 , sz , CV_32F , Scalar ( 1 ) ) ; <nl> + ASSERT_NO_THROW ( mat . convertTo ( mat , CV_8U ) ) ; <nl> + EXPECT_EQ ( sz [ 0 ] , mat . size [ 0 ] ) ; <nl> + EXPECT_EQ ( sz [ 1 ] , mat . size [ 1 ] ) ; <nl> + EXPECT_EQ ( sz [ 2 ] , mat . size [ 2 ] ) ; <nl> + EXPECT_EQ ( 0 , cvtest : : norm ( mat , Mat ( 3 , sz , CV_8U , Scalar ( 1 ) ) , NORM_INF ) ) ; <nl> + } <nl> mmm a / modules / core / test / test_umat . cpp <nl> ppp b / modules / core / test / test_umat . cpp <nl> TEST ( UMat , testWrongLifetime_Mat ) <nl> } <nl> } <nl> <nl> + TEST ( UMat , DISABLED_regression_5991 ) <nl> + { <nl> + int sz [ ] = { 2 , 3 , 2 } ; <nl> + UMat mat ( 3 , sz , CV_32F , Scalar ( 1 ) ) ; <nl> + ASSERT_NO_THROW ( mat . convertTo ( mat , CV_8U ) ) ; <nl> + EXPECT_EQ ( sz [ 0 ] , mat . size [ 0 ] ) ; <nl> + EXPECT_EQ ( sz [ 1 ] , mat . size [ 1 ] ) ; <nl> + EXPECT_EQ ( sz [ 2 ] , mat . size [ 2 ] ) ; <nl> + EXPECT_EQ ( 0 , cvtest : : norm ( mat . getMat ( ACCESS_READ ) , Mat ( 3 , sz , CV_8U , Scalar ( 1 ) ) , NORM_INF ) ) ; <nl> + } <nl> + <nl> } } / / namespace cvtest : : ocl <nl> | Merge pull request from alalek : fix_5991 | opencv/opencv | 56c89e0a980d39d8ee41752e896f08a267396873 | 2016-02-04T09:54:27Z |
mmm a / x64_dbg_dbg / _exports . cpp <nl> ppp b / x64_dbg_dbg / _exports . cpp <nl> extern " C " DLL_EXPORT bool _dbg_addrinfoget ( duint addr , SEGMENTREG segment , ADDR <nl> len - - ; <nl> if ( len ) <nl> len + + ; <nl> - sprintf ( addrinfo - > comment , " % s : % u " , filename + len , line . LineNumber ) ; <nl> + sprintf_s ( addrinfo - > comment , " \ 1 % s : % u " , filename + len , line . LineNumber ) ; <nl> retval = true ; <nl> } <nl> else if ( ! bOnlyCipAutoComments | | addr = = GetContextDataEx ( hActiveThread , UE_CIP ) ) / / no line number <nl> extern " C " DLL_EXPORT bool _dbg_addrinfoget ( duint addr , SEGMENTREG segment , ADDR <nl> retval = true ; <nl> } <nl> } <nl> - comment . resize ( MAX_COMMENT_SIZE - 1 ) ; <nl> - strcpy_s ( addrinfo - > comment , comment . c_str ( ) ) ; <nl> + comment . resize ( MAX_COMMENT_SIZE - 2 ) ; <nl> + String fullComment = " \ 1 " ; <nl> + fullComment + = comment ; <nl> + strcpy_s ( addrinfo - > comment , fullComment . c_str ( ) ) ; <nl> } <nl> } <nl> } <nl> mmm a / x64_dbg_dbg / addrinfo . cpp <nl> ppp b / x64_dbg_dbg / addrinfo . cpp <nl> bool apienumexports ( uint base , EXPORTENUMCALLBACK cbEnum ) <nl> / / / comment functions <nl> bool commentset ( uint addr , const char * text , bool manual ) <nl> { <nl> - if ( ! DbgIsDebugging ( ) or ! memisvalidreadptr ( fdProcessInfo - > hProcess , addr ) or ! text or strlen ( text ) > = MAX_COMMENT_SIZE - 1 ) <nl> + if ( ! DbgIsDebugging ( ) or ! memisvalidreadptr ( fdProcessInfo - > hProcess , addr ) or ! text or text [ 0 ] = = ' \ 1 ' or strlen ( text ) > = MAX_COMMENT_SIZE - 1 ) <nl> return false ; <nl> if ( ! * text ) / / NOTE : delete when there is no text <nl> { <nl> | DBG : automatic comments will have a ' \ 1 ' character as prefix . | x64dbg/x64dbg | 842469eff40a21a9f6ec4b5a19bd67a22657e2fb | 2014-12-26T13:40:49Z |
mmm a / Telegram / SourceFiles / history / admin_log / history_admin_log_inner . cpp <nl> ppp b / Telegram / SourceFiles / history / admin_log / history_admin_log_inner . cpp <nl> void InnerWidget : : requestAdmins ( ) { <nl> } ) ; <nl> <nl> for ( auto [ user , canEdit ] : filtered ) { <nl> - _admins . push_back ( user ) ; <nl> + _admins . emplace_back ( user ) ; <nl> if ( canEdit ) { <nl> - _adminsCanEdit . push_back ( user ) ; <nl> + _adminsCanEdit . emplace_back ( user ) ; <nl> } <nl> } <nl> } ) ; <nl> void InnerWidget : : saveState ( not_null < SectionMemento * > memento ) { <nl> memento - > setAdminsCanEdit ( std : : move ( _adminsCanEdit ) ) ; <nl> memento - > setSearchQuery ( std : : move ( _searchQuery ) ) ; <nl> if ( ! _filterChanged ) { <nl> - memento - > setItems ( std : : move ( _items ) , std : : move ( _itemsByIds ) , _upLoaded , _downLoaded ) ; <nl> - memento - > setIdManager ( std : : move ( _idManager ) ) ; <nl> + memento - > setItems ( <nl> + base : : take ( _items ) , <nl> + base : : take ( _eventIds ) , <nl> + _upLoaded , <nl> + _downLoaded ) ; <nl> + memento - > setIdManager ( base : : take ( _idManager ) ) ; <nl> + base : : take ( _itemsByData ) ; <nl> } <nl> _upLoaded = _downLoaded = true ; / / Don ' t load or handle anything anymore . <nl> } <nl> void InnerWidget : : restoreState ( not_null < SectionMemento * > memento ) { <nl> _items = memento - > takeItems ( ) ; <nl> for ( auto & item : _items ) { <nl> item . refreshView ( this ) ; <nl> + _itemsByData . emplace ( item - > data ( ) , item . get ( ) ) ; <nl> } <nl> - _itemsByIds = memento - > takeItemsByIds ( ) ; <nl> + _eventIds = memento - > takeEventIds ( ) ; <nl> if ( auto manager = memento - > takeIdManager ( ) ) { <nl> _idManager = std : : move ( manager ) ; <nl> } <nl> void InnerWidget : : addEvents ( Direction direction , const QVector < MTPChannelAdminLo <nl> / / When loading items down we add them to a new vector and copy _items after them . <nl> auto newItemsForDownDirection = std : : vector < OwnedItem > ( ) ; <nl> auto oldItemsCount = _items . size ( ) ; <nl> - auto & addToItems = ( direction = = Direction : : Up ) ? _items : newItemsForDownDirection ; <nl> + auto & addToItems = ( direction = = Direction : : Up ) <nl> + ? _items <nl> + : newItemsForDownDirection ; <nl> addToItems . reserve ( oldItemsCount + events . size ( ) * 2 ) ; <nl> - for_const ( auto & event , events ) { <nl> - Assert ( event . type ( ) = = mtpc_channelAdminLogEvent ) ; <nl> - const auto & data = event . c_channelAdminLogEvent ( ) ; <nl> - const auto id = data . vid . v ; <nl> - if ( _itemsByIds . find ( id ) ! = _itemsByIds . cend ( ) ) { <nl> - continue ; <nl> - } <nl> + for ( const auto & event : events ) { <nl> + event . match ( [ & ] ( const MTPDchannelAdminLogEvent & data ) { <nl> + const auto id = data . vid . v ; <nl> + if ( _eventIds . find ( id ) ! = _eventIds . end ( ) ) { <nl> + return ; <nl> + } <nl> <nl> - auto count = 0 ; <nl> - const auto addOne = [ & ] ( OwnedItem item ) { <nl> - _itemsByIds . emplace ( id , item . get ( ) ) ; <nl> - _itemsByData . emplace ( item - > data ( ) , item . get ( ) ) ; <nl> - addToItems . push_back ( std : : move ( item ) ) ; <nl> - + + count ; <nl> - } ; <nl> - GenerateItems ( <nl> - this , <nl> - _history , <nl> - _idManager . get ( ) , <nl> - data , <nl> - addOne ) ; <nl> - if ( count > 1 ) { <nl> - / / Reverse the inner order of the added messages , because we load events <nl> - / / from bottom to top but inside one event they go from top to bottom . <nl> - auto full = addToItems . size ( ) ; <nl> - auto from = full - count ; <nl> - for ( auto i = 0 , toReverse = count / 2 ; i ! = toReverse ; + + i ) { <nl> - std : : swap ( addToItems [ from + i ] , addToItems [ full - i - 1 ] ) ; <nl> + auto count = 0 ; <nl> + const auto addOne = [ & ] ( OwnedItem item ) { <nl> + _eventIds . emplace ( id ) ; <nl> + _itemsByData . emplace ( item - > data ( ) , item . get ( ) ) ; <nl> + addToItems . push_back ( std : : move ( item ) ) ; <nl> + + + count ; <nl> + } ; <nl> + GenerateItems ( <nl> + this , <nl> + _history , <nl> + _idManager . get ( ) , <nl> + data , <nl> + addOne ) ; <nl> + if ( count > 1 ) { <nl> + / / Reverse the inner order of the added messages , because we load events <nl> + / / from bottom to top but inside one event they go from top to bottom . <nl> + auto full = addToItems . size ( ) ; <nl> + auto from = full - count ; <nl> + for ( auto i = 0 , toReverse = count / 2 ; i ! = toReverse ; + + i ) { <nl> + std : : swap ( addToItems [ from + i ] , addToItems [ full - i - 1 ] ) ; <nl> + } <nl> } <nl> - } <nl> + } ) ; <nl> } <nl> auto newItemsCount = _items . size ( ) + ( ( direction = = Direction : : Up ) ? 0 : newItemsForDownDirection . size ( ) ) ; <nl> if ( newItemsCount ! = oldItemsCount ) { <nl> void InnerWidget : : addEvents ( Direction direction , const QVector < MTPChannelAdminLo <nl> } <nl> <nl> void InnerWidget : : updateMinMaxIds ( ) { <nl> - if ( _itemsByIds . empty ( ) | | _filterChanged ) { <nl> + if ( _eventIds . empty ( ) | | _filterChanged ) { <nl> _maxId = _minId = 0 ; <nl> } else { <nl> - _maxId = ( - - _itemsByIds . end ( ) ) - > first ; <nl> - _minId = _itemsByIds . begin ( ) - > first ; <nl> + _maxId = * _eventIds . rbegin ( ) ; <nl> + _minId = * _eventIds . begin ( ) ; <nl> if ( _minId = = 1 ) { <nl> _upLoaded = true ; <nl> } <nl> void InnerWidget : : clearAfterFilterChange ( ) { <nl> _selectedText = TextSelection ( ) ; <nl> _filterChanged = false ; <nl> _items . clear ( ) ; <nl> - _itemsByIds . clear ( ) ; <nl> + _eventIds . clear ( ) ; <nl> + _itemsByData . clear ( ) ; <nl> _idManager = nullptr ; <nl> _idManager = _history - > adminLogIdManager ( ) ; <nl> updateEmptyText ( ) ; <nl> void InnerWidget : : suggestRestrictUser ( not_null < UserData * > user ) { <nl> auto weak = QPointer < InnerWidget > ( this ) ; <nl> auto weakBox = std : : make_shared < QPointer < EditRestrictedBox > > ( ) ; <nl> auto box = Box < EditRestrictedBox > ( _channel , user , hasAdminRights , currentRights ) ; <nl> - box - > setSaveCallback ( [ user , weak , weakBox ] ( const MTPChatBannedRights & oldRights , const MTPChatBannedRights & newRights ) { <nl> + box - > setSaveCallback ( [ = ] ( <nl> + const MTPChatBannedRights & oldRights , <nl> + const MTPChatBannedRights & newRights ) { <nl> if ( weak ) { <nl> weak - > restrictUser ( user , oldRights , newRights ) ; <nl> } <nl> void InnerWidget : : suggestRestrictUser ( not_null < UserData * > user ) { <nl> if ( base : : contains ( _admins , user ) ) { <nl> editRestrictions ( true , MTP_chatBannedRights ( MTP_flags ( 0 ) , MTP_int ( 0 ) ) ) ; <nl> } else { <nl> - request ( MTPchannels_GetParticipant ( _channel - > inputChannel , user - > inputUser ) ) . done ( [ = ] ( const MTPchannels_ChannelParticipant & result ) { <nl> + request ( MTPchannels_GetParticipant ( <nl> + _channel - > inputChannel , <nl> + user - > inputUser <nl> + ) ) . done ( [ = ] ( const MTPchannels_ChannelParticipant & result ) { <nl> Expects ( result . type ( ) = = mtpc_channels_channelParticipant ) ; <nl> <nl> auto & participant = result . c_channels_channelParticipant ( ) ; <nl> mmm a / Telegram / SourceFiles / history / admin_log / history_admin_log_inner . h <nl> ppp b / Telegram / SourceFiles / history / admin_log / history_admin_log_inner . h <nl> class InnerWidget final <nl> / / for each found userpic ( from the top to the bottom ) using enumerateItems ( ) method . <nl> / / <nl> / / Method has " bool ( * Method ) ( not_null < Element * > view , int userpicTop ) " signature <nl> - / / if it returns false the enumeration stops immidiately . <nl> + / / if it returns false the enumeration stops immediately . <nl> template < typename Method > <nl> void enumerateUserpics ( Method method ) ; <nl> <nl> class InnerWidget final <nl> / / for each found date element ( from the bottom to the top ) using enumerateItems ( ) method . <nl> / / <nl> / / Method has " bool ( * Method ) ( not_null < HistoryItem * > item , int itemtop , int dateTop ) " signature <nl> - / / if it returns false the enumeration stops immidiately . <nl> + / / if it returns false the enumeration stops immediately . <nl> template < typename Method > <nl> void enumerateDates ( Method method ) ; <nl> <nl> class InnerWidget final <nl> not_null < ChannelData * > _channel ; <nl> not_null < History * > _history ; <nl> std : : vector < OwnedItem > _items ; <nl> - std : : map < uint64 , not_null < Element * > > _itemsByIds ; <nl> - std : : map < not_null < HistoryItem * > , not_null < Element * > , std : : less < > > _itemsByData ; <nl> + std : : set < uint64 > _eventIds ; <nl> + std : : map < not_null < const HistoryItem * > , not_null < Element * > > _itemsByData ; <nl> int _itemsTop = 0 ; <nl> int _itemsWidth = 0 ; <nl> int _itemsHeight = 0 ; <nl> mmm a / Telegram / SourceFiles / history / admin_log / history_admin_log_section . h <nl> ppp b / Telegram / SourceFiles / history / admin_log / history_admin_log_section . h <nl> class SectionMemento : public Window : : SectionMemento { <nl> <nl> void setItems ( <nl> std : : vector < OwnedItem > & & items , <nl> - std : : map < uint64 , not_null < Element * > > & & itemsByIds , <nl> + std : : set < uint64 > & & eventIds , <nl> bool upLoaded , <nl> bool downLoaded ) { <nl> _items = std : : move ( items ) ; <nl> - _itemsByIds = std : : move ( itemsByIds ) ; <nl> + _eventIds = std : : move ( eventIds ) ; <nl> _upLoaded = upLoaded ; <nl> _downLoaded = downLoaded ; <nl> } <nl> class SectionMemento : public Window : : SectionMemento { <nl> std : : vector < OwnedItem > takeItems ( ) { <nl> return std : : move ( _items ) ; <nl> } <nl> - std : : map < uint64 , not_null < Element * > > takeItemsByIds ( ) { <nl> - return std : : move ( _itemsByIds ) ; <nl> + std : : set < uint64 > takeEventIds ( ) { <nl> + return std : : move ( _eventIds ) ; <nl> } <nl> std : : shared_ptr < LocalIdManager > takeIdManager ( ) { <nl> return std : : move ( _idManager ) ; <nl> class SectionMemento : public Window : : SectionMemento { <nl> std : : vector < not_null < UserData * > > _admins ; <nl> std : : vector < not_null < UserData * > > _adminsCanEdit ; <nl> std : : vector < OwnedItem > _items ; <nl> - std : : map < uint64 , not_null < Element * > > _itemsByIds ; <nl> + std : : set < uint64 > _eventIds ; <nl> bool _upLoaded = false ; <nl> bool _downLoaded = true ; <nl> std : : shared_ptr < LocalIdManager > _idManager ; <nl> | Fix crash in admin log events . | telegramdesktop/tdesktop | b236844c946f057aa0f38ee256c3e6f21b8ef3e7 | 2019-01-17T08:21:30Z |
mmm a / src / containers / half_intrusive_list . hpp <nl> ppp b / src / containers / half_intrusive_list . hpp <nl> class half_intrusive_list_t : private half_intrusive_list_half_node_t < T > { <nl> } <nl> <nl> T * next ( T * elem ) const { <nl> + guarantee ( elem - > in_a_list ( ) ) ; <nl> rassert ( elem - > next_ = = nullptr | | elem - > next_ - > prev_ = = elem ) ; <nl> rassert ( elem - > prev_ - > next_ = = elem ) ; <nl> - guarantee ( elem - > in_a_list ( ) ) ; <nl> half_intrusive_list_node_t < T > * p = elem ; <nl> return static_cast < T * > ( p - > next_ ) ; <nl> } <nl> | Reordered rasserts and guarantees in half_intrusive_list_t to catch errors in a better order . | rethinkdb/rethinkdb | e58ec7ea15ac685ef4c828cc060a1882183ad8bb | 2014-11-22T00:45:12Z |
mmm a / src / video_core / engines / shader_bytecode . h <nl> ppp b / src / video_core / engines / shader_bytecode . h <nl> union Instruction { <nl> BitField < 49 , 3 , PredCondition > cond ; <nl> } isetp ; <nl> <nl> + union { <nl> + BitField < 48 , 1 , u64 > is_signed ; <nl> + BitField < 49 , 3 , PredCondition > cond ; <nl> + } icmp ; <nl> + <nl> union { <nl> BitField < 0 , 3 , u64 > pred0 ; <nl> BitField < 3 , 3 , u64 > pred3 ; <nl> class OpCode { <nl> SEL_C , <nl> SEL_R , <nl> SEL_IMM , <nl> + ICMP_RC , <nl> + ICMP_R , <nl> + ICMP_CR , <nl> + ICMP_IMM , <nl> MUFU , / / Multi - Function Operator <nl> RRO_C , / / Range Reduction Operator <nl> RRO_R , <nl> class OpCode { <nl> INST ( " 0100110010100mmm " , Id : : SEL_C , Type : : ArithmeticInteger , " SEL_C " ) , <nl> INST ( " 0101110010100mmm " , Id : : SEL_R , Type : : ArithmeticInteger , " SEL_R " ) , <nl> INST ( " 0011100 - 10100mmm " , Id : : SEL_IMM , Type : : ArithmeticInteger , " SEL_IMM " ) , <nl> + INST ( " 010100110100mmm - " , Id : : ICMP_RC , Type : : ArithmeticInteger , " ICMP_RC " ) , <nl> + INST ( " 010110110100mmm - " , Id : : ICMP_R , Type : : ArithmeticInteger , " ICMP_R " ) , <nl> + INST ( " 010010110100mmm - " , Id : : ICMP_CR , Type : : ArithmeticInteger , " ICMP_CR " ) , <nl> + INST ( " 0011011 - 0100mmm - " , Id : : ICMP_IMM , Type : : ArithmeticInteger , " ICMP_IMM " ) , <nl> INST ( " 0101101111011mmm " , Id : : LEA_R2 , Type : : ArithmeticInteger , " LEA_R2 " ) , <nl> INST ( " 0101101111010mmm " , Id : : LEA_R1 , Type : : ArithmeticInteger , " LEA_R1 " ) , <nl> INST ( " 001101101101mmm - " , Id : : LEA_IMM , Type : : ArithmeticInteger , " LEA_IMM " ) , <nl> mmm a / src / video_core / shader / decode / arithmetic_integer . cpp <nl> ppp b / src / video_core / shader / decode / arithmetic_integer . cpp <nl> u32 ShaderIR : : DecodeArithmeticInteger ( NodeBlock & bb , u32 pc ) { <nl> SetRegister ( bb , instr . gpr0 , value ) ; <nl> break ; <nl> } <nl> + case OpCode : : Id : : ICMP_CR : <nl> + case OpCode : : Id : : ICMP_R : <nl> + case OpCode : : Id : : ICMP_RC : <nl> + case OpCode : : Id : : ICMP_IMM : { <nl> + const Node zero = Immediate ( 0 ) ; <nl> + <nl> + const auto [ op_b , test ] = [ & ] ( ) - > std : : pair < Node , Node > { <nl> + switch ( opcode - > get ( ) . GetId ( ) ) { <nl> + case OpCode : : Id : : ICMP_CR : <nl> + return { GetConstBuffer ( instr . cbuf34 . index , instr . cbuf34 . offset ) , <nl> + GetRegister ( instr . gpr39 ) } ; <nl> + case OpCode : : Id : : ICMP_R : <nl> + return { GetRegister ( instr . gpr20 ) , GetRegister ( instr . gpr39 ) } ; <nl> + case OpCode : : Id : : ICMP_RC : <nl> + return { GetRegister ( instr . gpr39 ) , <nl> + GetConstBuffer ( instr . cbuf34 . index , instr . cbuf34 . offset ) } ; <nl> + case OpCode : : Id : : ICMP_IMM : <nl> + return { Immediate ( instr . alu . GetSignedImm20_20 ( ) ) , GetRegister ( instr . gpr39 ) } ; <nl> + default : <nl> + UNREACHABLE ( ) ; <nl> + return { zero , zero } ; <nl> + } <nl> + } ( ) ; <nl> + const Node op_a = GetRegister ( instr . gpr8 ) ; <nl> + const Node comparison = <nl> + GetPredicateComparisonInteger ( instr . icmp . cond , instr . icmp . is_signed ! = 0 , test , zero ) ; <nl> + SetRegister ( bb , instr . gpr0 , Operation ( OperationCode : : Select , comparison , op_a , op_b ) ) ; <nl> + break ; <nl> + } <nl> case OpCode : : Id : : LOP_C : <nl> case OpCode : : Id : : LOP_R : <nl> case OpCode : : Id : : LOP_IMM : { <nl> | Merge pull request from FernandoS27 / icmp | yuzu-emu/yuzu | 9286976948f10d73e63a8b682c28f012221a2b03 | 2019-09-21T21:06:07Z |
mmm a / doc / aria2c . 1 <nl> ppp b / doc / aria2c . 1 <nl> Seed previously downloaded files without verifying piece hashes \ & . Default : <nl> . PP <nl> \ fB \ - \ - bt \ - tracker \ - interval \ fR = SEC <nl> . RS 4 <nl> - Set the interval in seconds between tracker requests \ & . This completely overrides interval value and aria2 just uses this value and ignores the minInterval and interval value in the response of tracker \ & . If <nl> + Set the interval in seconds between tracker requests \ & . This completely overrides interval value and aria2 just uses this value and ignores the min interval and interval value in the response of tracker \ & . If <nl> \ fI0 \ fR <nl> is set , aria2 determines interval based on the response of tracker and the download progress \ & . Default : <nl> \ fI0 \ fR <nl> mmm a / doc / aria2c . 1 . html <nl> ppp b / doc / aria2c . 1 . html <nl> < h3 id = " _bittorrent_specific_options " > BitTorrent Specific Options < / h3 > < div style <nl> < p > <nl> Set the interval in seconds between tracker requests . This <nl> completely overrides interval value and aria2 just uses this value <nl> - and ignores the minInterval and interval value in the response of <nl> + and ignores the min interval and interval value in the response of <nl> tracker . If < em > 0 < / em > is set , aria2 determines interval based on the <nl> response of tracker and the download progress . Default : < em > 0 < / em > <nl> < / p > <nl> < h2 id = " _copyright " > COPYRIGHT < / h2 > <nl> < / div > <nl> < div id = " footer " > <nl> < div id = " footer - text " > <nl> - Last updated 2009 - 03 - 22 00 : 13 : 56 JST <nl> + Last updated 2009 - 03 - 22 16 : 27 : 15 JST <nl> < / div > <nl> < / div > <nl> < / body > <nl> mmm a / doc / aria2c . 1 . txt <nl> ppp b / doc / aria2c . 1 . txt <nl> BitTorrent Specific Options <nl> * - - bt - tracker - interval * = SEC : : <nl> Set the interval in seconds between tracker requests . This <nl> completely overrides interval value and aria2 just uses this value <nl> - and ignores the minInterval and interval value in the response of <nl> + and ignores the min interval and interval value in the response of <nl> tracker . If ' 0 ' is set , aria2 determines interval based on the <nl> response of tracker and the download progress . Default : ' 0 ' <nl> <nl> mmm a / src / usage_text . h <nl> ppp b / src / usage_text . h <nl> _ ( " - - dry - run [ = true | false ] If true is given , aria2 just checks whether the <nl> _ ( " - - bt - tracker - interval = SEC Set the interval in seconds between tracker \ n " \ <nl> " requests . This completely overrides interval value \ n " \ <nl> " and aria2 just uses this value and ignores the \ n " \ <nl> - " minInterval and interval value in the response of \ n " \ <nl> + " min interval and interval value in the response of \ n " \ <nl> " tracker . If 0 is set , aria2 determines interval \ n " \ <nl> " based on the response of tracker and the download \ n " \ <nl> " progress . " ) <nl> | 2009 - 03 - 22 Tatsuhiro Tsujikawa < t - tujikawa @ users . sourceforge . net > | aria2/aria2 | 1e17795a840ea7336f4715fd823d378c3a1f4a69 | 2009-03-22T07:27:52Z |
mmm a / caffe2 / sgd / adagrad_op_gpu . cu <nl> ppp b / caffe2 / sgd / adagrad_op_gpu . cu <nl> <nl> # include < cub / block / block_reduce . cuh > <nl> - # include " caffe2 / sgd / adagrad_op . h " <nl> # include " caffe2 / core / common_gpu . h " <nl> # include " caffe2 / core / context_gpu . h " <nl> + # include " caffe2 / sgd / adagrad_op . h " <nl> <nl> namespace caffe2 { <nl> <nl> __global__ void SparseAdagradKernel ( <nl> const float * grad , <nl> const float * lr ) { <nl> const float LR = lr [ 0 ] ; <nl> - CUDA_1D_KERNEL_LOOP ( i , N ) <nl> - { <nl> + CUDA_1D_KERNEL_LOOP ( i , N ) { <nl> const size_t gradIdx = i ; <nl> const SIndex index = indices [ i / grad_slice_sz ] ; <nl> const size_t paramIdx = index * grad_slice_sz + ( i % grad_slice_sz ) ; <nl> __global__ void RowWiseSparseAdagradKernel ( <nl> const float * lr ) { <nl> typedef cub : : BlockReduce < float , CAFFE_CUDA_NUM_THREADS > BlockReduce ; <nl> __shared__ BlockReduce : : TempStorage temp_storage ; <nl> + int valid = min ( N , CAFFE_CUDA_NUM_THREADS ) ; <nl> / / in case gridDim is smaller than M <nl> for ( int i = blockIdx . x ; i < M ; i + = gridDim . x ) { <nl> const SIndex index = indices [ i ] ; <nl> __global__ void RowWiseSparseAdagradKernel ( <nl> const float x_ij = grad [ i * N + j ] ; <nl> sum_squares + = x_ij * x_ij ; <nl> } <nl> - float reduce_result = BlockReduce ( temp_storage ) . Sum ( sum_squares ) ; <nl> + float reduce_result = BlockReduce ( temp_storage ) . Sum ( sum_squares , valid ) ; <nl> if ( threadIdx . x = = 0 ) { <nl> row_sum_squares_avg = reduce_result / ( float ) N ; <nl> param_mom [ index ] + = row_sum_squares_avg ; <nl> bool RowWiseSparseAdagradOp < float , CUDAContext > : : DoRunWithType ( ) { <nl> auto GRAD_M = Input ( GRAD ) . dim32 ( 0 ) ; <nl> auto GRAD_N = N / GRAD_M ; <nl> <nl> + / / Cases with GRAND_N < 128 can have more swarms if number of threads is lower <nl> + int num_threads = CAFFE_CUDA_NUM_THREADS ; <nl> + if ( GRAD_N < num_threads ) { <nl> + num_threads = GRAD_N ; <nl> + } <nl> + <nl> / / each thread block will handle multiple rows of the input and output <nl> RowWiseSparseAdagradKernel < < < <nl> min ( GRAD_M , CAFFE_MAXIMUM_NUM_BLOCKS ) , <nl> - CAFFE_CUDA_NUM_THREADS , <nl> + num_threads , <nl> 0 , <nl> context_ . cuda_stream ( ) > > > ( <nl> GRAD_M , <nl> REGISTER_CUDA_OPERATOR ( SparseAdagrad , CUDASparseAdagradOp < float , CUDAContext > ) ; <nl> REGISTER_CUDA_OPERATOR ( <nl> RowWiseSparseAdagrad , <nl> RowWiseSparseAdagradOp < float , CUDAContext > ) ; <nl> - } <nl> + } / / namespace caffe2 <nl> | [ C2 ] Tiny changes to adagrad to make it slightly better . ( ) | pytorch/pytorch | 4460c8b034f8fd544ff9c271c4aa21698644d352 | 2020-02-25T07:02:17Z |
mmm a / arangod / MMFiles / MMFilesWalRecoverState . cpp <nl> ppp b / arangod / MMFiles / MMFilesWalRecoverState . cpp <nl> bool MMFilesWalRecoverState : : ReplayMarker ( TRI_df_marker_t const * marker , <nl> if ( vocbase ! = nullptr ) { <nl> / / remove already existing database <nl> / / TODO : how to signal a dropDatabase failure here ? <nl> - state - > databaseFeature - > dropDatabase ( databaseId , false , true , false ) ; <nl> + state - > databaseFeature - > dropDatabase ( databaseId , true , false ) ; <nl> } <nl> <nl> VPackSlice const nameSlice = payloadSlice . get ( " name " ) ; <nl> bool MMFilesWalRecoverState : : ReplayMarker ( TRI_df_marker_t const * marker , <nl> <nl> state - > releaseDatabase ( otherId ) ; <nl> / / TODO : how to signal a dropDatabase failure here ? <nl> - state - > databaseFeature - > dropDatabase ( nameString , false , true , false ) ; <nl> + state - > databaseFeature - > dropDatabase ( nameString , true , false ) ; <nl> } <nl> <nl> PersistentIndexFeature : : dropDatabase ( databaseId ) ; <nl> bool MMFilesWalRecoverState : : ReplayMarker ( TRI_df_marker_t const * marker , <nl> TRI_ERROR_ARANGO_DATABASE_NOT_FOUND ) ; <nl> * / <nl> int res = state - > databaseFeature - > createDatabase ( databaseId , nameString , <nl> - false , vocbase ) ; <nl> + vocbase ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> LOG_TOPIC ( WARN , arangodb : : Logger : : FIXME ) < < " cannot create database " < < databaseId < < " : " <nl> bool MMFilesWalRecoverState : : ReplayMarker ( TRI_df_marker_t const * marker , <nl> <nl> if ( vocbase ! = nullptr ) { <nl> / / ignore any potential error returned by this call <nl> - state - > databaseFeature - > dropDatabase ( databaseId , false , true , false ) ; <nl> + state - > databaseFeature - > dropDatabase ( databaseId , true , false ) ; <nl> } <nl> <nl> PersistentIndexFeature : : dropDatabase ( databaseId ) ; <nl> mmm a / arangod / RestServer / DatabaseFeature . cpp <nl> ppp b / arangod / RestServer / DatabaseFeature . cpp <nl> int DatabaseFeature : : createDatabaseCoordinator ( TRI_voc_tick_t id , <nl> <nl> / / / @ brief create a new database <nl> int DatabaseFeature : : createDatabase ( TRI_voc_tick_t id , std : : string const & name , <nl> - bool writeMarker , TRI_vocbase_t * & result ) { <nl> + TRI_vocbase_t * & result ) { <nl> result = nullptr ; <nl> <nl> if ( ! TRI_vocbase_t : : IsAllowedName ( false , name ) ) { <nl> int DatabaseFeature : : createDatabase ( TRI_voc_tick_t id , std : : string const & name , <nl> / / write marker into log <nl> int res = TRI_ERROR_NO_ERROR ; <nl> <nl> - if ( writeMarker ) { <nl> + if ( ! engine - > inRecovery ( ) ) { <nl> res = engine - > writeCreateMarker ( id , builder . slice ( ) ) ; <nl> } <nl> <nl> int DatabaseFeature : : dropDatabaseCoordinator ( TRI_voc_tick_t id , bool force ) { <nl> } <nl> <nl> / / / @ brief drop database <nl> - int DatabaseFeature : : dropDatabase ( std : : string const & name , bool writeMarker , <nl> - bool waitForDeletion , <nl> + int DatabaseFeature : : dropDatabase ( std : : string const & name , bool waitForDeletion , <nl> bool removeAppsDirectory ) { <nl> if ( name = = TRI_VOC_SYSTEM_DATABASE ) { <nl> / / prevent deletion of system database <nl> int DatabaseFeature : : dropDatabase ( std : : string const & name , bool writeMarker , <nl> arangodb : : aql : : PlanCache : : instance ( ) - > invalidate ( vocbase ) ; <nl> arangodb : : aql : : QueryCache : : instance ( ) - > invalidate ( vocbase ) ; <nl> <nl> - engine - > prepareDropDatabase ( vocbase , writeMarker , res ) ; <nl> + engine - > prepareDropDatabase ( vocbase , ! engine - > inRecovery ( ) , res ) ; <nl> } <nl> / / must not use the database after here , as it may now be <nl> / / deleted by the DatabaseManagerThread ! <nl> int DatabaseFeature : : dropDatabase ( std : : string const & name , bool writeMarker , <nl> } <nl> <nl> / / / @ brief drops an existing database <nl> - int DatabaseFeature : : dropDatabase ( TRI_voc_tick_t id , bool writeMarker , <nl> - bool waitForDeletion , <nl> + int DatabaseFeature : : dropDatabase ( TRI_voc_tick_t id , bool waitForDeletion , <nl> bool removeAppsDirectory ) { <nl> std : : string name ; <nl> <nl> int DatabaseFeature : : dropDatabase ( TRI_voc_tick_t id , bool writeMarker , <nl> } <nl> <nl> / / and call the regular drop function <nl> - return dropDatabase ( name , writeMarker , waitForDeletion , removeAppsDirectory ) ; <nl> + return dropDatabase ( name , waitForDeletion , removeAppsDirectory ) ; <nl> } <nl> <nl> std : : vector < TRI_voc_tick_t > DatabaseFeature : : getDatabaseIdsCoordinator ( <nl> mmm a / arangod / RestServer / DatabaseFeature . h <nl> ppp b / arangod / RestServer / DatabaseFeature . h <nl> class DatabaseFeature final : public application_features : : ApplicationFeature { <nl> std : : vector < std : : string > getDatabaseNamesForUser ( std : : string const & user ) ; <nl> <nl> int createDatabaseCoordinator ( TRI_voc_tick_t id , std : : string const & name , TRI_vocbase_t * & result ) ; <nl> - int createDatabase ( TRI_voc_tick_t id , std : : string const & name , bool writeMarker , TRI_vocbase_t * & result ) ; <nl> + int createDatabase ( TRI_voc_tick_t id , std : : string const & name , TRI_vocbase_t * & result ) ; <nl> int dropDatabaseCoordinator ( TRI_voc_tick_t id , bool force ) ; <nl> - int dropDatabase ( std : : string const & name , bool writeMarker , bool waitForDeletion , bool removeAppsDirectory ) ; <nl> - int dropDatabase ( TRI_voc_tick_t id , bool writeMarker , bool waitForDeletion , bool removeAppsDirectory ) ; <nl> + int dropDatabase ( std : : string const & name , bool waitForDeletion , bool removeAppsDirectory ) ; <nl> + int dropDatabase ( TRI_voc_tick_t id , bool waitForDeletion , bool removeAppsDirectory ) ; <nl> <nl> TRI_vocbase_t * useDatabaseCoordinator ( std : : string const & name ) ; <nl> TRI_vocbase_t * useDatabaseCoordinator ( TRI_voc_tick_t id ) ; <nl> mmm a / arangod / V8Server / v8 - vocbase . cpp <nl> ppp b / arangod / V8Server / v8 - vocbase . cpp <nl> static void JS_CreateDatabase ( v8 : : FunctionCallbackInfo < v8 : : Value > const & args ) { <nl> application_features : : ApplicationServer : : getFeature < DatabaseFeature > ( <nl> " Database " ) ; <nl> TRI_vocbase_t * database = nullptr ; <nl> - int res = databaseFeature - > createDatabase ( id , name , true , database ) ; <nl> + int res = databaseFeature - > createDatabase ( id , name , database ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> TRI_V8_THROW_EXCEPTION ( res ) ; <nl> static void JS_DropDatabase ( v8 : : FunctionCallbackInfo < v8 : : Value > const & args ) { <nl> DatabaseFeature * databaseFeature = <nl> application_features : : ApplicationServer : : getFeature < DatabaseFeature > ( <nl> " Database " ) ; <nl> - int res = databaseFeature - > dropDatabase ( name , true , false , true ) ; <nl> + int res = databaseFeature - > dropDatabase ( name , false , true ) ; <nl> <nl> if ( res ! = TRI_ERROR_NO_ERROR ) { <nl> TRI_V8_THROW_EXCEPTION ( res ) ; <nl> | Drop / Create Database in DBFeature does not expose writeMarker flag in it ' s API | arangodb/arangodb | 18700387a8600949eccbc8e3e412921fa2a860f9 | 2017-03-08T12:27:01Z |
mmm a / extensions / GUI / CCScrollView / CCScrollView . cpp <nl> ppp b / extensions / GUI / CCScrollView / CCScrollView . cpp <nl> void ScrollView : : addChild ( Node * child , int zOrder , int tag ) <nl> } <nl> } <nl> <nl> + void ScrollView : : beforeDraw ( ) <nl> + { <nl> + _beforeDrawCommand . init ( 0 , _vertexZ ) ; <nl> + _beforeDrawCommand . func = CC_CALLBACK_0 ( ScrollView : : onBeforeDraw , this ) ; <nl> + Director : : getInstance ( ) - > getRenderer ( ) - > addCommand ( & _beforeDrawCommand ) ; <nl> + } <nl> + <nl> / * * <nl> * clip this view so that outside of the visible bounds can be hidden . <nl> * / <nl> - void ScrollView : : beforeDraw ( ) <nl> + void ScrollView : : onBeforeDraw ( ) <nl> { <nl> if ( _clippingToBounds ) <nl> { <nl> void ScrollView : : beforeDraw ( ) <nl> } <nl> } <nl> <nl> + void ScrollView : : afterDraw ( ) <nl> + { <nl> + _afterDrawCommand . init ( 0 , _vertexZ ) ; <nl> + _afterDrawCommand . func = CC_CALLBACK_0 ( ScrollView : : onAfterDraw , this ) ; <nl> + Director : : getInstance ( ) - > getRenderer ( ) - > addCommand ( & _afterDrawCommand ) ; <nl> + } <nl> + <nl> / * * <nl> * retract what ' s done in beforeDraw so that there ' s no side effect to <nl> * other nodes . <nl> * / <nl> - void ScrollView : : afterDraw ( ) <nl> + void ScrollView : : onAfterDraw ( ) <nl> { <nl> if ( _clippingToBounds ) <nl> { <nl> mmm a / extensions / GUI / CCScrollView / CCScrollView . h <nl> ppp b / extensions / GUI / CCScrollView / CCScrollView . h <nl> class ScrollView : public Layer <nl> * clip this view so that outside of the visible bounds can be hidden . <nl> * / <nl> void beforeDraw ( ) ; <nl> + void onBeforeDraw ( ) ; <nl> / * * <nl> * retract what ' s done in beforeDraw so that there ' s no side effect to <nl> * other nodes . <nl> * / <nl> void afterDraw ( ) ; <nl> + void onAfterDraw ( ) ; <nl> / * * <nl> * Zoom handling <nl> * / <nl> class ScrollView : public Layer <nl> <nl> / * * Touch listener * / <nl> EventListenerTouchOneByOne * _touchListener ; <nl> + <nl> + CustomCommand _beforeDrawCommand ; <nl> + CustomCommand _afterDrawCommand ; <nl> } ; <nl> <nl> / / end of GUI group <nl> | Merge pull request from dumganhar / develop | cocos2d/cocos2d-x | f4256c6ee49c0b2dbc6ac5a6520972138b038129 | 2014-01-07T09:47:24Z |
mmm a / folly / CPortability . h <nl> ppp b / folly / CPortability . h <nl> <nl> # define FOLLY_DISABLE_ADDRESS_SANITIZER <nl> # endif <nl> <nl> + / * Define a convenience macro to test when thread sanitizer is being used <nl> + * across the different compilers ( e . g . clang , gcc ) * / <nl> + # if defined ( __clang__ ) <nl> + # if __has_feature ( thread_sanitizer ) <nl> + # define FOLLY_SANITIZE_THREAD 1 <nl> + # endif <nl> + # elif defined ( __GNUC__ ) & & __SANITIZE_THREAD__ <nl> + # define FOLLY_SANITIZE_THREAD 1 <nl> + # endif <nl> <nl> / * * <nl> * ASAN / MSAN / TSAN define pre - processor symbols : <nl> | folly : define FOLLY_SANITIZE_THREAD convenience macro for TSAN | facebook/folly | 0c620c8f910f407314ff19f4b44c770fe938fe36 | 2016-06-06T23:23:33Z |
mmm a / src / wallet / rpcwallet . cpp <nl> ppp b / src / wallet / rpcwallet . cpp <nl> UniValue getreceivedbyaddress ( const JSONRPCRequest & request ) <nl> + HelpExampleCli ( " getreceivedbyaddress " , " \ " 1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX \ " " ) + <nl> " \ nThe amount including unconfirmed transactions , zero confirmations \ n " <nl> + HelpExampleCli ( " getreceivedbyaddress " , " \ " 1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX \ " 0 " ) + <nl> - " \ nThe amount with at least 6 confirmation , very safe \ n " <nl> + " \ nThe amount with at least 6 confirmations \ n " <nl> + HelpExampleCli ( " getreceivedbyaddress " , " \ " 1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX \ " 6 " ) + <nl> " \ nAs a json rpc call \ n " <nl> + HelpExampleRpc ( " getreceivedbyaddress " , " \ " 1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX \ " , 6 " ) <nl> UniValue getreceivedbyaccount ( const JSONRPCRequest & request ) <nl> + HelpExampleCli ( " getreceivedbyaccount " , " \ " \ " " ) + <nl> " \ nAmount received at the tabby account including unconfirmed amounts with zero confirmations \ n " <nl> + HelpExampleCli ( " getreceivedbyaccount " , " \ " tabby \ " 0 " ) + <nl> - " \ nThe amount with at least 6 confirmation , very safe \ n " <nl> + " \ nThe amount with at least 6 confirmations \ n " <nl> + HelpExampleCli ( " getreceivedbyaccount " , " \ " tabby \ " 6 " ) + <nl> " \ nAs a json rpc call \ n " <nl> + HelpExampleRpc ( " getreceivedbyaccount " , " \ " tabby \ " , 6 " ) <nl> UniValue getbalance ( const JSONRPCRequest & request ) <nl> " \ nExamples : \ n " <nl> " \ nThe total amount in the wallet \ n " <nl> + HelpExampleCli ( " getbalance " , " " ) + <nl> - " \ nThe total amount in the wallet at least 5 blocks confirmed \ n " <nl> + " \ nThe total amount in the wallet at least 6 blocks confirmed \ n " <nl> + HelpExampleCli ( " getbalance " , " \ " * \ " 6 " ) + <nl> " \ nAs a json rpc call \ n " <nl> + HelpExampleRpc ( " getbalance " , " \ " * \ " , 6 " ) <nl> UniValue walletpassphrase ( const JSONRPCRequest & request ) <nl> " Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock \ n " <nl> " time that overrides the old one . \ n " <nl> " \ nExamples : \ n " <nl> - " \ nunlock the wallet for 60 seconds \ n " <nl> + " \ nUnlock the wallet for 60 seconds \ n " <nl> + HelpExampleCli ( " walletpassphrase " , " \ " my pass phrase \ " 60 " ) + <nl> " \ nLock the wallet again ( before 60 seconds ) \ n " <nl> + HelpExampleCli ( " walletlock " , " " ) + <nl> UniValue encryptwallet ( const JSONRPCRequest & request ) <nl> " \ nArguments : \ n " <nl> " 1 . \ " passphrase \ " ( string ) The pass phrase to encrypt the wallet with . It must be at least 1 character , but should be long . \ n " <nl> " \ nExamples : \ n " <nl> - " \ nEncrypt you wallet \ n " <nl> + " \ nEncrypt your wallet \ n " <nl> + HelpExampleCli ( " encryptwallet " , " \ " my pass phrase \ " " ) + <nl> " \ nNow set the passphrase to use the wallet , such as for signing or sending bitcoin \ n " <nl> + HelpExampleCli ( " walletpassphrase " , " \ " my pass phrase \ " " ) + <nl> - " \ nNow we can so something like sign \ n " <nl> + " \ nNow we can do something like sign \ n " <nl> + HelpExampleCli ( " signmessage " , " \ " address \ " \ " test message \ " " ) + <nl> " \ nNow lock the wallet again by removing the passphrase \ n " <nl> + HelpExampleCli ( " walletlock " , " " ) + <nl> | Fix misspellings and remove safety verbiage | bitcoin/bitcoin | a5ecaf1490be8d01ac6806785157230d30f77061 | 2017-07-19T20:50:26Z |
mmm a / src / bench / crypto_hash . cpp <nl> ppp b / src / bench / crypto_hash . cpp <nl> static void SHA256_32b ( benchmark : : State & state ) <nl> } <nl> } <nl> <nl> + static void SHA256D64_1024 ( benchmark : : State & state ) <nl> + { <nl> + std : : vector < uint8_t > in ( 64 * 1024 , 0 ) ; <nl> + while ( state . KeepRunning ( ) ) { <nl> + SHA256D64 ( in . data ( ) , in . data ( ) , 1024 ) ; <nl> + } <nl> + } <nl> + <nl> static void SHA512 ( benchmark : : State & state ) <nl> { <nl> uint8_t hash [ CSHA512 : : OUTPUT_SIZE ] ; <nl> BENCHMARK ( SHA512 , 330 ) ; <nl> <nl> BENCHMARK ( SHA256_32b , 4700 * 1000 ) ; <nl> BENCHMARK ( SipHash_32b , 40 * 1000 * 1000 ) ; <nl> + BENCHMARK ( SHA256D64_1024 , 7400 ) ; <nl> BENCHMARK ( FastRandom_32bit , 110 * 1000 * 1000 ) ; <nl> BENCHMARK ( FastRandom_1bit , 440 * 1000 * 1000 ) ; <nl> mmm a / src / crypto / sha256 . cpp <nl> ppp b / src / crypto / sha256 . cpp <nl> void Transform ( uint32_t * s , const unsigned char * chunk , size_t blocks ) <nl> } <nl> } <nl> <nl> + void TransformD64 ( unsigned char * out , const unsigned char * in ) <nl> + { <nl> + / / Transform 1 <nl> + uint32_t a = 0x6a09e667ul ; <nl> + uint32_t b = 0xbb67ae85ul ; <nl> + uint32_t c = 0x3c6ef372ul ; <nl> + uint32_t d = 0xa54ff53aul ; <nl> + uint32_t e = 0x510e527ful ; <nl> + uint32_t f = 0x9b05688cul ; <nl> + uint32_t g = 0x1f83d9abul ; <nl> + uint32_t h = 0x5be0cd19ul ; <nl> + <nl> + uint32_t w0 , w1 , w2 , w3 , w4 , w5 , w6 , w7 , w8 , w9 , w10 , w11 , w12 , w13 , w14 , w15 ; <nl> + <nl> + Round ( a , b , c , d , e , f , g , h , 0x428a2f98ul + ( w0 = ReadBE32 ( in + 0 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x71374491ul + ( w1 = ReadBE32 ( in + 4 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0xb5c0fbcful + ( w2 = ReadBE32 ( in + 8 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0xe9b5dba5ul + ( w3 = ReadBE32 ( in + 12 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x3956c25bul + ( w4 = ReadBE32 ( in + 16 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x59f111f1ul + ( w5 = ReadBE32 ( in + 20 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x923f82a4ul + ( w6 = ReadBE32 ( in + 24 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xab1c5ed5ul + ( w7 = ReadBE32 ( in + 28 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0xd807aa98ul + ( w8 = ReadBE32 ( in + 32 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x12835b01ul + ( w9 = ReadBE32 ( in + 36 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x243185beul + ( w10 = ReadBE32 ( in + 40 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x550c7dc3ul + ( w11 = ReadBE32 ( in + 44 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x72be5d74ul + ( w12 = ReadBE32 ( in + 48 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x80deb1feul + ( w13 = ReadBE32 ( in + 52 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x9bdc06a7ul + ( w14 = ReadBE32 ( in + 56 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xc19bf174ul + ( w15 = ReadBE32 ( in + 60 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0xe49b69c1ul + ( w0 + = sigma1 ( w14 ) + w9 + sigma0 ( w1 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0xefbe4786ul + ( w1 + = sigma1 ( w15 ) + w10 + sigma0 ( w2 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x0fc19dc6ul + ( w2 + = sigma1 ( w0 ) + w11 + sigma0 ( w3 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x240ca1ccul + ( w3 + = sigma1 ( w1 ) + w12 + sigma0 ( w4 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x2de92c6ful + ( w4 + = sigma1 ( w2 ) + w13 + sigma0 ( w5 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x4a7484aaul + ( w5 + = sigma1 ( w3 ) + w14 + sigma0 ( w6 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x5cb0a9dcul + ( w6 + = sigma1 ( w4 ) + w15 + sigma0 ( w7 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x76f988daul + ( w7 + = sigma1 ( w5 ) + w0 + sigma0 ( w8 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x983e5152ul + ( w8 + = sigma1 ( w6 ) + w1 + sigma0 ( w9 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0xa831c66dul + ( w9 + = sigma1 ( w7 ) + w2 + sigma0 ( w10 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0xb00327c8ul + ( w10 + = sigma1 ( w8 ) + w3 + sigma0 ( w11 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0xbf597fc7ul + ( w11 + = sigma1 ( w9 ) + w4 + sigma0 ( w12 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0xc6e00bf3ul + ( w12 + = sigma1 ( w10 ) + w5 + sigma0 ( w13 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0xd5a79147ul + ( w13 + = sigma1 ( w11 ) + w6 + sigma0 ( w14 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x06ca6351ul + ( w14 + = sigma1 ( w12 ) + w7 + sigma0 ( w15 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x14292967ul + ( w15 + = sigma1 ( w13 ) + w8 + sigma0 ( w0 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x27b70a85ul + ( w0 + = sigma1 ( w14 ) + w9 + sigma0 ( w1 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x2e1b2138ul + ( w1 + = sigma1 ( w15 ) + w10 + sigma0 ( w2 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x4d2c6dfcul + ( w2 + = sigma1 ( w0 ) + w11 + sigma0 ( w3 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x53380d13ul + ( w3 + = sigma1 ( w1 ) + w12 + sigma0 ( w4 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x650a7354ul + ( w4 + = sigma1 ( w2 ) + w13 + sigma0 ( w5 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x766a0abbul + ( w5 + = sigma1 ( w3 ) + w14 + sigma0 ( w6 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x81c2c92eul + ( w6 + = sigma1 ( w4 ) + w15 + sigma0 ( w7 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x92722c85ul + ( w7 + = sigma1 ( w5 ) + w0 + sigma0 ( w8 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0xa2bfe8a1ul + ( w8 + = sigma1 ( w6 ) + w1 + sigma0 ( w9 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0xa81a664bul + ( w9 + = sigma1 ( w7 ) + w2 + sigma0 ( w10 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0xc24b8b70ul + ( w10 + = sigma1 ( w8 ) + w3 + sigma0 ( w11 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0xc76c51a3ul + ( w11 + = sigma1 ( w9 ) + w4 + sigma0 ( w12 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0xd192e819ul + ( w12 + = sigma1 ( w10 ) + w5 + sigma0 ( w13 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0xd6990624ul + ( w13 + = sigma1 ( w11 ) + w6 + sigma0 ( w14 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0xf40e3585ul + ( w14 + = sigma1 ( w12 ) + w7 + sigma0 ( w15 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x106aa070ul + ( w15 + = sigma1 ( w13 ) + w8 + sigma0 ( w0 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x19a4c116ul + ( w0 + = sigma1 ( w14 ) + w9 + sigma0 ( w1 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x1e376c08ul + ( w1 + = sigma1 ( w15 ) + w10 + sigma0 ( w2 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x2748774cul + ( w2 + = sigma1 ( w0 ) + w11 + sigma0 ( w3 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x34b0bcb5ul + ( w3 + = sigma1 ( w1 ) + w12 + sigma0 ( w4 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x391c0cb3ul + ( w4 + = sigma1 ( w2 ) + w13 + sigma0 ( w5 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x4ed8aa4aul + ( w5 + = sigma1 ( w3 ) + w14 + sigma0 ( w6 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x5b9cca4ful + ( w6 + = sigma1 ( w4 ) + w15 + sigma0 ( w7 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x682e6ff3ul + ( w7 + = sigma1 ( w5 ) + w0 + sigma0 ( w8 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x748f82eeul + ( w8 + = sigma1 ( w6 ) + w1 + sigma0 ( w9 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x78a5636ful + ( w9 + = sigma1 ( w7 ) + w2 + sigma0 ( w10 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x84c87814ul + ( w10 + = sigma1 ( w8 ) + w3 + sigma0 ( w11 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x8cc70208ul + ( w11 + = sigma1 ( w9 ) + w4 + sigma0 ( w12 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x90befffaul + ( w12 + = sigma1 ( w10 ) + w5 + sigma0 ( w13 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0xa4506cebul + ( w13 + = sigma1 ( w11 ) + w6 + sigma0 ( w14 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0xbef9a3f7ul + ( w14 + sigma1 ( w12 ) + w7 + sigma0 ( w15 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xc67178f2ul + ( w15 + sigma1 ( w13 ) + w8 + sigma0 ( w0 ) ) ) ; <nl> + <nl> + a + = 0x6a09e667ul ; <nl> + b + = 0xbb67ae85ul ; <nl> + c + = 0x3c6ef372ul ; <nl> + d + = 0xa54ff53aul ; <nl> + e + = 0x510e527ful ; <nl> + f + = 0x9b05688cul ; <nl> + g + = 0x1f83d9abul ; <nl> + h + = 0x5be0cd19ul ; <nl> + <nl> + uint32_t t0 = a , t1 = b , t2 = c , t3 = d , t4 = e , t5 = f , t6 = g , t7 = h ; <nl> + <nl> + / / Transform 2 <nl> + Round ( a , b , c , d , e , f , g , h , 0xc28a2f98ul ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x71374491ul ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0xb5c0fbcful ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0xe9b5dba5ul ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x3956c25bul ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x59f111f1ul ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x923f82a4ul ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xab1c5ed5ul ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0xd807aa98ul ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x12835b01ul ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x243185beul ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x550c7dc3ul ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x72be5d74ul ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x80deb1feul ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x9bdc06a7ul ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xc19bf374ul ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x649b69c1ul ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0xf0fe4786ul ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x0fe1edc6ul ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x240cf254ul ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x4fe9346ful ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x6cc984beul ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x61b9411eul ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x16f988faul ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0xf2c65152ul ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0xa88e5a6dul ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0xb019fc65ul ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0xb9d99ec7ul ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x9a1231c3ul ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0xe70eeaa0ul ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0xfdb1232bul ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xc7353eb0ul ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x3069bad5ul ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0xcb976d5ful ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x5a0f118ful ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0xdc1eeefdul ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x0a35b689ul ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0xde0b7a04ul ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x58f4ca9dul ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xe15d5b16ul ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x007f3e86ul ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x37088980ul ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0xa507ea32ul ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x6fab9537ul ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x17406110ul ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x0d8cd6f1ul ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0xcdaa3b6dul ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xc0bbbe37ul ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x83613bdaul ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0xdb48a363ul ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x0b02e931ul ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x6fd15ca7ul ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x521afacaul ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x31338431ul ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x6ed41a95ul ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x6d437890ul ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0xc39c91f2ul ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x9eccabbdul ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0xb5c9a0e6ul ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x532fb63cul ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0xd2c741c6ul ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x07237ea3ul ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0xa4954b68ul ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x4c191d76ul ) ; <nl> + <nl> + w0 = t0 + a ; <nl> + w1 = t1 + b ; <nl> + w2 = t2 + c ; <nl> + w3 = t3 + d ; <nl> + w4 = t4 + e ; <nl> + w5 = t5 + f ; <nl> + w6 = t6 + g ; <nl> + w7 = t7 + h ; <nl> + <nl> + / / Transform 3 <nl> + a = 0x6a09e667ul ; <nl> + b = 0xbb67ae85ul ; <nl> + c = 0x3c6ef372ul ; <nl> + d = 0xa54ff53aul ; <nl> + e = 0x510e527ful ; <nl> + f = 0x9b05688cul ; <nl> + g = 0x1f83d9abul ; <nl> + h = 0x5be0cd19ul ; <nl> + <nl> + Round ( a , b , c , d , e , f , g , h , 0x428a2f98ul + w0 ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x71374491ul + w1 ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0xb5c0fbcful + w2 ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0xe9b5dba5ul + w3 ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x3956c25bul + w4 ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x59f111f1ul + w5 ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x923f82a4ul + w6 ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xab1c5ed5ul + w7 ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x5807aa98ul ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x12835b01ul ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x243185beul ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x550c7dc3ul ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x72be5d74ul ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x80deb1feul ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x9bdc06a7ul ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xc19bf274ul ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0xe49b69c1ul + ( w0 + = sigma0 ( w1 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0xefbe4786ul + ( w1 + = 0xa00000ul + sigma0 ( w2 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x0fc19dc6ul + ( w2 + = sigma1 ( w0 ) + sigma0 ( w3 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x240ca1ccul + ( w3 + = sigma1 ( w1 ) + sigma0 ( w4 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x2de92c6ful + ( w4 + = sigma1 ( w2 ) + sigma0 ( w5 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x4a7484aaul + ( w5 + = sigma1 ( w3 ) + sigma0 ( w6 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x5cb0a9dcul + ( w6 + = sigma1 ( w4 ) + 0x100ul + sigma0 ( w7 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x76f988daul + ( w7 + = sigma1 ( w5 ) + w0 + 0x11002000ul ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x983e5152ul + ( w8 = 0x80000000ul + sigma1 ( w6 ) + w1 ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0xa831c66dul + ( w9 = sigma1 ( w7 ) + w2 ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0xb00327c8ul + ( w10 = sigma1 ( w8 ) + w3 ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0xbf597fc7ul + ( w11 = sigma1 ( w9 ) + w4 ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0xc6e00bf3ul + ( w12 = sigma1 ( w10 ) + w5 ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0xd5a79147ul + ( w13 = sigma1 ( w11 ) + w6 ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x06ca6351ul + ( w14 = sigma1 ( w12 ) + w7 + 0x400022ul ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x14292967ul + ( w15 = 0x100ul + sigma1 ( w13 ) + w8 + sigma0 ( w0 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x27b70a85ul + ( w0 + = sigma1 ( w14 ) + w9 + sigma0 ( w1 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x2e1b2138ul + ( w1 + = sigma1 ( w15 ) + w10 + sigma0 ( w2 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x4d2c6dfcul + ( w2 + = sigma1 ( w0 ) + w11 + sigma0 ( w3 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x53380d13ul + ( w3 + = sigma1 ( w1 ) + w12 + sigma0 ( w4 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x650a7354ul + ( w4 + = sigma1 ( w2 ) + w13 + sigma0 ( w5 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x766a0abbul + ( w5 + = sigma1 ( w3 ) + w14 + sigma0 ( w6 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x81c2c92eul + ( w6 + = sigma1 ( w4 ) + w15 + sigma0 ( w7 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x92722c85ul + ( w7 + = sigma1 ( w5 ) + w0 + sigma0 ( w8 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0xa2bfe8a1ul + ( w8 + = sigma1 ( w6 ) + w1 + sigma0 ( w9 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0xa81a664bul + ( w9 + = sigma1 ( w7 ) + w2 + sigma0 ( w10 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0xc24b8b70ul + ( w10 + = sigma1 ( w8 ) + w3 + sigma0 ( w11 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0xc76c51a3ul + ( w11 + = sigma1 ( w9 ) + w4 + sigma0 ( w12 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0xd192e819ul + ( w12 + = sigma1 ( w10 ) + w5 + sigma0 ( w13 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0xd6990624ul + ( w13 + = sigma1 ( w11 ) + w6 + sigma0 ( w14 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0xf40e3585ul + ( w14 + = sigma1 ( w12 ) + w7 + sigma0 ( w15 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x106aa070ul + ( w15 + = sigma1 ( w13 ) + w8 + sigma0 ( w0 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x19a4c116ul + ( w0 + = sigma1 ( w14 ) + w9 + sigma0 ( w1 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x1e376c08ul + ( w1 + = sigma1 ( w15 ) + w10 + sigma0 ( w2 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x2748774cul + ( w2 + = sigma1 ( w0 ) + w11 + sigma0 ( w3 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x34b0bcb5ul + ( w3 + = sigma1 ( w1 ) + w12 + sigma0 ( w4 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x391c0cb3ul + ( w4 + = sigma1 ( w2 ) + w13 + sigma0 ( w5 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0x4ed8aa4aul + ( w5 + = sigma1 ( w3 ) + w14 + sigma0 ( w6 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0x5b9cca4ful + ( w6 + = sigma1 ( w4 ) + w15 + sigma0 ( w7 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0x682e6ff3ul + ( w7 + = sigma1 ( w5 ) + w0 + sigma0 ( w8 ) ) ) ; <nl> + Round ( a , b , c , d , e , f , g , h , 0x748f82eeul + ( w8 + = sigma1 ( w6 ) + w1 + sigma0 ( w9 ) ) ) ; <nl> + Round ( h , a , b , c , d , e , f , g , 0x78a5636ful + ( w9 + = sigma1 ( w7 ) + w2 + sigma0 ( w10 ) ) ) ; <nl> + Round ( g , h , a , b , c , d , e , f , 0x84c87814ul + ( w10 + = sigma1 ( w8 ) + w3 + sigma0 ( w11 ) ) ) ; <nl> + Round ( f , g , h , a , b , c , d , e , 0x8cc70208ul + ( w11 + = sigma1 ( w9 ) + w4 + sigma0 ( w12 ) ) ) ; <nl> + Round ( e , f , g , h , a , b , c , d , 0x90befffaul + ( w12 + = sigma1 ( w10 ) + w5 + sigma0 ( w13 ) ) ) ; <nl> + Round ( d , e , f , g , h , a , b , c , 0xa4506cebul + ( w13 + = sigma1 ( w11 ) + w6 + sigma0 ( w14 ) ) ) ; <nl> + Round ( c , d , e , f , g , h , a , b , 0xbef9a3f7ul + ( w14 + sigma1 ( w12 ) + w7 + sigma0 ( w15 ) ) ) ; <nl> + Round ( b , c , d , e , f , g , h , a , 0xc67178f2ul + ( w15 + sigma1 ( w13 ) + w8 + sigma0 ( w0 ) ) ) ; <nl> + <nl> + / / Output <nl> + WriteBE32 ( out + 0 , a + 0x6a09e667ul ) ; <nl> + WriteBE32 ( out + 4 , b + 0xbb67ae85ul ) ; <nl> + WriteBE32 ( out + 8 , c + 0x3c6ef372ul ) ; <nl> + WriteBE32 ( out + 12 , d + 0xa54ff53aul ) ; <nl> + WriteBE32 ( out + 16 , e + 0x510e527ful ) ; <nl> + WriteBE32 ( out + 20 , f + 0x9b05688cul ) ; <nl> + WriteBE32 ( out + 24 , g + 0x1f83d9abul ) ; <nl> + WriteBE32 ( out + 28 , h + 0x5be0cd19ul ) ; <nl> + } <nl> + <nl> } / / namespace sha256 <nl> <nl> typedef void ( * TransformType ) ( uint32_t * , const unsigned char * , size_t ) ; <nl> + typedef void ( * TransformD64Type ) ( unsigned char * , const unsigned char * ) ; <nl> + <nl> + template < TransformType tr > <nl> + void TransformD64Wrapper ( unsigned char * out , const unsigned char * in ) <nl> + { <nl> + uint32_t s [ 8 ] ; <nl> + static const unsigned char padding1 [ 64 ] = { <nl> + 0x80 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 0 <nl> + } ; <nl> + unsigned char buffer2 [ 64 ] = { <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0x80 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 <nl> + } ; <nl> + sha256 : : Initialize ( s ) ; <nl> + tr ( s , in , 1 ) ; <nl> + tr ( s , padding1 , 1 ) ; <nl> + WriteBE32 ( buffer2 + 0 , s [ 0 ] ) ; <nl> + WriteBE32 ( buffer2 + 4 , s [ 1 ] ) ; <nl> + WriteBE32 ( buffer2 + 8 , s [ 2 ] ) ; <nl> + WriteBE32 ( buffer2 + 12 , s [ 3 ] ) ; <nl> + WriteBE32 ( buffer2 + 16 , s [ 4 ] ) ; <nl> + WriteBE32 ( buffer2 + 20 , s [ 5 ] ) ; <nl> + WriteBE32 ( buffer2 + 24 , s [ 6 ] ) ; <nl> + WriteBE32 ( buffer2 + 28 , s [ 7 ] ) ; <nl> + sha256 : : Initialize ( s ) ; <nl> + tr ( s , buffer2 , 1 ) ; <nl> + WriteBE32 ( out + 0 , s [ 0 ] ) ; <nl> + WriteBE32 ( out + 4 , s [ 1 ] ) ; <nl> + WriteBE32 ( out + 8 , s [ 2 ] ) ; <nl> + WriteBE32 ( out + 12 , s [ 3 ] ) ; <nl> + WriteBE32 ( out + 16 , s [ 4 ] ) ; <nl> + WriteBE32 ( out + 20 , s [ 5 ] ) ; <nl> + WriteBE32 ( out + 24 , s [ 6 ] ) ; <nl> + WriteBE32 ( out + 28 , s [ 7 ] ) ; <nl> + } <nl> <nl> bool SelfTest ( TransformType tr ) { <nl> static const unsigned char in1 [ 65 ] = { 0 , 0x80 } ; <nl> bool SelfTest ( TransformType tr ) { <nl> } <nl> <nl> TransformType Transform = sha256 : : Transform ; <nl> - <nl> + TransformD64Type TransformD64 = sha256 : : TransformD64 ; <nl> } / / namespace <nl> <nl> std : : string SHA256AutoDetect ( ) <nl> std : : string SHA256AutoDetect ( ) <nl> uint32_t eax , ebx , ecx , edx ; <nl> if ( __get_cpuid ( 1 , & eax , & ebx , & ecx , & edx ) & & ( ecx > > 19 ) & 1 ) { <nl> Transform = sha256_sse4 : : Transform ; <nl> + TransformD64 = TransformD64Wrapper < sha256_sse4 : : Transform > ; <nl> assert ( SelfTest ( Transform ) ) ; <nl> return " sse4 " ; <nl> } <nl> CSHA256 & CSHA256 : : Reset ( ) <nl> sha256 : : Initialize ( s ) ; <nl> return * this ; <nl> } <nl> + <nl> + void SHA256D64 ( unsigned char * out , const unsigned char * in , size_t blocks ) <nl> + { <nl> + while ( blocks ) { <nl> + TransformD64 ( out , in ) ; <nl> + out + = 32 ; <nl> + in + = 64 ; <nl> + - - blocks ; <nl> + } <nl> + } <nl> mmm a / src / crypto / sha256 . h <nl> ppp b / src / crypto / sha256 . h <nl> class CSHA256 <nl> * / <nl> std : : string SHA256AutoDetect ( ) ; <nl> <nl> + / * * Compute multiple double - SHA256 ' s of 64 - byte blobs . <nl> + * output : pointer to a blocks * 32 byte output buffer <nl> + * input : pointer to a blocks * 64 byte input buffer <nl> + * blocks : the number of hashes to compute . <nl> + * / <nl> + void SHA256D64 ( unsigned char * output , const unsigned char * input , size_t blocks ) ; <nl> + <nl> # endif / / BITCOIN_CRYPTO_SHA256_H <nl> mmm a / src / test / crypto_tests . cpp <nl> ppp b / src / test / crypto_tests . cpp <nl> BOOST_AUTO_TEST_CASE ( countbits_tests ) <nl> } <nl> } <nl> <nl> + BOOST_AUTO_TEST_CASE ( sha256d64 ) <nl> + { <nl> + for ( int i = 0 ; i < = 32 ; + + i ) { <nl> + unsigned char in [ 64 * 32 ] ; <nl> + unsigned char out1 [ 32 * 32 ] , out2 [ 32 * 32 ] ; <nl> + for ( int j = 0 ; j < 64 * i ; + + j ) { <nl> + in [ j ] = InsecureRandBits ( 8 ) ; <nl> + } <nl> + for ( int j = 0 ; j < i ; + + j ) { <nl> + CHash256 ( ) . Write ( in + 64 * j , 64 ) . Finalize ( out1 + 32 * j ) ; <nl> + } <nl> + SHA256D64 ( out2 , in , i ) ; <nl> + BOOST_CHECK ( memcmp ( out1 , out2 , 32 * i ) = = 0 ) ; <nl> + } <nl> + } <nl> + <nl> BOOST_AUTO_TEST_SUITE_END ( ) <nl> | Specialized double sha256 for 64 byte inputs | bitcoin/bitcoin | d0c96328833127284574bfef26f96aa2e4afc91a | 2018-05-29T21:05:00Z |
mmm a / selfdrive / locationd / locationd . py <nl> ppp b / selfdrive / locationd / locationd . py <nl> def msg_from_state ( converter , calib_from_device , H , predicted_state , predicted_c <nl> # ned_vel_std = self . converter . ecef2ned ( fix_ecef + vel_ecef + vel_ecef_std ) - self . converter . ecef2ned ( fix_ecef + vel_ecef ) <nl> <nl> fix = messaging . log . LiveLocationKalman . new_message ( ) <nl> - fix . positionGeodetic . value = to_float ( fix_pos_geo ) <nl> - fix . positionGeodetic . std = to_float ( np . nan * np . zeros ( 3 ) ) <nl> - fix . positionGeodetic . valid = True <nl> - fix . positionECEF . value = to_float ( fix_ecef ) <nl> - fix . positionECEF . std = to_float ( fix_ecef_std ) <nl> - fix . positionECEF . valid = True <nl> - fix . velocityECEF . value = to_float ( vel_ecef ) <nl> - fix . velocityECEF . std = to_float ( vel_ecef_std ) <nl> - fix . velocityECEF . valid = True <nl> - fix . velocityNED . value = to_float ( ned_vel ) <nl> - fix . velocityNED . std = to_float ( np . nan * np . zeros ( 3 ) ) <nl> - fix . velocityNED . valid = True <nl> - fix . velocityDevice . value = to_float ( vel_device ) <nl> - fix . velocityDevice . std = to_float ( vel_device_std ) <nl> - fix . velocityDevice . valid = True <nl> - fix . accelerationDevice . value = to_float ( predicted_state [ States . ACCELERATION ] ) <nl> - fix . accelerationDevice . std = to_float ( predicted_std [ States . ACCELERATION_ERR ] ) <nl> - fix . accelerationDevice . valid = True <nl> - <nl> - fix . orientationECEF . value = to_float ( orientation_ecef ) <nl> - fix . orientationECEF . std = to_float ( orientation_ecef_std ) <nl> - fix . orientationECEF . valid = True <nl> - fix . calibratedOrientationECEF . value = to_float ( calibrated_orientation_ecef ) <nl> - fix . calibratedOrientationECEF . std = to_float ( np . nan * np . zeros ( 3 ) ) <nl> - fix . calibratedOrientationECEF . valid = True <nl> - fix . orientationNED . value = to_float ( orientation_ned ) <nl> - fix . orientationNED . std = to_float ( np . nan * np . zeros ( 3 ) ) <nl> - fix . orientationNED . valid = True <nl> - fix . angularVelocityDevice . value = to_float ( predicted_state [ States . ANGULAR_VELOCITY ] ) <nl> - fix . angularVelocityDevice . std = to_float ( predicted_std [ States . ANGULAR_VELOCITY_ERR ] ) <nl> - fix . angularVelocityDevice . valid = True <nl> - <nl> - fix . velocityCalibrated . value = to_float ( vel_calib ) <nl> - fix . velocityCalibrated . std = to_float ( vel_calib_std ) <nl> - fix . velocityCalibrated . valid = True <nl> - fix . angularVelocityCalibrated . value = to_float ( ang_vel_calib ) <nl> - fix . angularVelocityCalibrated . std = to_float ( ang_vel_calib_std ) <nl> - fix . angularVelocityCalibrated . valid = True <nl> - fix . accelerationCalibrated . value = to_float ( acc_calib ) <nl> - fix . accelerationCalibrated . std = to_float ( acc_calib_std ) <nl> - fix . accelerationCalibrated . valid = True <nl> + <nl> + # write measurements to msg <nl> + measurements = [ <nl> + # measurement field , value , std , valid <nl> + ( fix . positionGeodetic , fix_pos_geo , np . nan * np . zeros ( 3 ) , True ) , <nl> + ( fix . positionECEF , fix_ecef , fix_ecef_std , True ) , <nl> + ( fix . velocityECEF , vel_ecef , vel_ecef_std , True ) , <nl> + ( fix . velocityNED , ned_vel , np . nan * np . zeros ( 3 ) , True ) , <nl> + ( fix . velocityDevice , vel_device , vel_device_std , True ) , <nl> + ( fix . accelerationDevice , predicted_state [ States . ACCELERATION ] , predicted_std [ States . ACCELERATION_ERR ] , True ) , <nl> + ( fix . orientationECEF , orientation_ecef , orientation_ecef_std , True ) , <nl> + ( fix . calibratedOrientationECEF , calibrated_orientation_ecef , np . nan * np . zeros ( 3 ) , True ) , <nl> + ( fix . orientationNED , orientation_ned , np . nan * np . zeros ( 3 ) , True ) , <nl> + ( fix . angularVelocityDevice , predicted_state [ States . ANGULAR_VELOCITY ] , predicted_std [ States . ANGULAR_VELOCITY_ERR ] , True ) , <nl> + ( fix . velocityCalibrated , vel_calib , vel_calib_std , True ) , <nl> + ( fix . angularVelocityCalibrated , ang_vel_calib , ang_vel_calib_std , True ) , <nl> + ( fix . accelerationCalibrated , acc_calib , acc_calib_std , True ) , <nl> + ] <nl> + <nl> + for field , value , std , valid in measurements : <nl> + # TODO : can we write the lists faster ? <nl> + field . value = to_float ( value ) <nl> + field . std = to_float ( std ) <nl> + field . valid = valid <nl> + <nl> return fix <nl> <nl> def liveLocationMsg ( self ) : <nl> | Cleanup locationd msg building ( ) | commaai/openpilot | 1208ac424d06e03da9f83fc1fa1824df7e32f80d | 2020-08-03T21:58:15Z |
mmm a / Telegram / SourceFiles / pspecific_linux . cpp <nl> ppp b / Telegram / SourceFiles / pspecific_linux . cpp <nl> void psRegisterCustomScheme ( ) { <nl> s < < " Exec = " < < escapeShell ( cExeDir ( ) + cExeName ( ) ) < < " - - % u \ n " ; <nl> s < < " Icon = " < < icon < < " \ n " ; <nl> s < < " Terminal = false \ n " ; <nl> + s < < " StartupWMClass = Telegram " ; <nl> s < < " Type = Application \ n " ; <nl> s < < " Categories = Network ; \ n " ; <nl> s < < " MimeType = application / x - xdg - protocol - tg ; x - scheme - handler / tg ; \ n " ; <nl> | Merge pull request from kanishkablack / master | telegramdesktop/tdesktop | 3ac6d6d26c0632a69946ddcf44dd5648c4e8c060 | 2015-10-13T10:37:50Z |
mmm a / hphp / runtime / vm / jit / code - gen - x64 . cpp <nl> ppp b / hphp / runtime / vm / jit / code - gen - x64 . cpp <nl> const char * getContextName ( const Class * ctx ) { <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - template < class Then > <nl> - void ifNonPersistent ( Vout & v , Type ty , Vloc loc , Then then ) { <nl> - if ( ! ty . maybe ( TPersistent ) ) { <nl> - then ( v ) ; / / non - persistent check below will always succeed <nl> - return ; <nl> - } <nl> - <nl> - auto const sf = v . makeReg ( ) ; <nl> - v < < cmplim { 0 , loc . reg ( ) [ FAST_REFCOUNT_OFFSET ] , sf } ; <nl> - static_assert ( UncountedValue < 0 & & StaticValue < 0 , " " ) ; <nl> - ifThen ( v , CC_GE , sf , then ) ; <nl> - } <nl> - <nl> - template < class Then > <nl> - void ifRefCountedType ( Vout & v , Vout & vtaken , Type ty , Vloc loc , Then then ) { <nl> - if ( ! ty . maybe ( TCounted ) ) return ; <nl> - if ( ty . isKnownDataType ( ) ) { <nl> - if ( isRefcountedType ( ty . toDataType ( ) ) ) then ( v ) ; <nl> - return ; <nl> - } <nl> - auto const sf = v . makeReg ( ) ; <nl> - emitCmpTVType ( v , sf , KindOfRefCountThreshold , loc . reg ( 1 ) ) ; <nl> - unlikelyIfThen ( v , vtaken , CC_NLE , sf , then ) ; <nl> - } <nl> - <nl> - template < class Then > <nl> - void ifRefCountedNonPersistent ( Vout & v , Type ty , Vloc loc , Then then ) { <nl> - ifRefCountedType ( v , v , ty , loc , [ & ] ( Vout & v ) { <nl> - ifNonPersistent ( v , ty , loc , then ) ; <nl> - } ) ; <nl> - } <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> void debug_trashsp ( Vout & v ) { <nl> if ( RuntimeOption : : EvalHHIRGenerateAsserts ) { <nl> v < < syncvmsp { v . cns ( 0x42 ) } ; <nl> DELEGATE_OPCODE ( IsTypeMem ) <nl> DELEGATE_OPCODE ( IsNTypeMem ) <nl> DELEGATE_OPCODE ( IsScalarType ) <nl> <nl> + DELEGATE_OPCODE ( IncRef ) <nl> + DELEGATE_OPCODE ( IncRefCtx ) <nl> + DELEGATE_OPCODE ( DecRef ) <nl> + DELEGATE_OPCODE ( DecRefNZ ) <nl> + DELEGATE_OPCODE ( DbgAssertRefCount ) <nl> + <nl> DELEGATE_OPCODE ( BaseG ) <nl> DELEGATE_OPCODE ( PropX ) <nl> DELEGATE_OPCODE ( PropDX ) <nl> void CodeGenerator : : cgReqRetranslate ( IRInstruction * inst ) { <nl> } ; <nl> } <nl> <nl> - void CodeGenerator : : cgIncRef ( IRInstruction * inst ) { <nl> - / / This is redundant with a check in ifRefCountedNonPersistent , but we check <nl> - / / earlier to avoid emitting profiling code in this case . <nl> - auto const ty = inst - > src ( 0 ) - > type ( ) ; <nl> - if ( ! ty . maybe ( TCounted ) ) return ; <nl> - <nl> - folly : : Optional < rds : : Handle > profHandle ; <nl> - auto vtaken = & vmain ( ) ; <nl> - / / We profile generic IncRefs to see which ones are unlikely to see <nl> - / / refcounted values . <nl> - if ( RuntimeOption : : EvalHHIROutlineGenericIncDecRef & & ! ty . isKnownDataType ( ) ) { <nl> - auto const profileKey = <nl> - makeStaticString ( folly : : to < std : : string > ( " IncRefProfile - " , <nl> - ty . toString ( ) ) ) ; <nl> - TargetProfile < IncRefProfile > profile { <nl> - m_state . unit . context ( ) , inst - > marker ( ) , profileKey <nl> - } ; <nl> - if ( profile . profiling ( ) ) { <nl> - profHandle = profile . handle ( ) ; <nl> - } else if ( profile . optimizing ( ) ) { <nl> - auto const data = profile . data ( IncRefProfile : : reduce ) ; <nl> - if ( data . tryinc = = 0 ) { <nl> - FTRACE ( 3 , " Emitting cold IncRef for { } , { } \ n " , data , * inst ) ; <nl> - vtaken = & vcold ( ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - auto & v = vmain ( ) ; <nl> - auto const loc = srcLoc ( inst , 0 ) ; <nl> - ifRefCountedType ( v , * vtaken , ty , loc , [ & ] ( Vout & v ) { <nl> - if ( profHandle ) { <nl> - v < < incwm { rvmtl ( ) [ * profHandle + offsetof ( IncRefProfile , tryinc ) ] , <nl> - v . makeReg ( ) } ; <nl> - } <nl> - ifNonPersistent ( v , ty , loc , [ & ] ( Vout & v ) { <nl> - emitIncRef ( v , loc . reg ( ) ) ; <nl> - } ) ; <nl> - } ) ; <nl> - } <nl> - <nl> - void CodeGenerator : : cgIncRefCtx ( IRInstruction * inst ) { <nl> - auto const ty = inst - > src ( 0 ) - > type ( ) ; <nl> - <nl> - if ( ty < = TObj ) return cgIncRef ( inst ) ; <nl> - if ( ty < = TCctx | | ty < = TNullptr ) return ; <nl> - <nl> - auto const src = srcLoc ( inst , 0 ) . reg ( ) ; <nl> - auto & v = vmain ( ) ; <nl> - auto const sf = v . makeReg ( ) ; <nl> - <nl> - if ( ty . maybe ( TNullptr ) ) { <nl> - auto const shifted = v . makeReg ( ) ; <nl> - v < < shrqi { 1 , src , shifted , sf } ; <nl> - <nl> - ifThen ( v , CC_NBE , sf , [ & ] ( Vout & v ) { <nl> - auto const unshifted = v . makeReg ( ) ; <nl> - v < < shlqi { 1 , shifted , unshifted , v . makeReg ( ) } ; <nl> - emitIncRef ( v , unshifted ) ; <nl> - } ) ; <nl> - } else { <nl> - v < < testqi { 0x1 , src , sf } ; <nl> - ifThen ( v , CC_Z , sf , [ & ] ( Vout & v ) { emitIncRef ( v , src ) ; } ) ; <nl> - } <nl> - } <nl> - <nl> void CodeGenerator : : cgGenericRetDecRefs ( IRInstruction * inst ) { <nl> auto const rFp = srcLoc ( inst , 0 ) . reg ( ) ; <nl> auto const numLocals = getFunc ( inst - > marker ( ) ) - > numLocals ( ) ; <nl> void CodeGenerator : : cgGenericRetDecRefs ( IRInstruction * inst ) { <nl> args , v . makeTuple ( { } ) , fix , DestType : : None , false } ; <nl> } <nl> <nl> - / * <nl> - * Depending on the current translation kind , do nothing , profile , or collect <nl> - * profiling data for the current DecRef * instruction <nl> - * <nl> - * Returns true iff the release path for this DecRef should be put in cold <nl> - * code . <nl> - * / <nl> - float CodeGenerator : : decRefDestroyRate ( const IRInstruction * inst , <nl> - OptDecRefProfile & profile , <nl> - Type type ) { <nl> - auto const kind = m_state . unit . context ( ) . kind ; <nl> - / / Without profiling data , we assume destroy is unlikely . <nl> - if ( kind ! = TransKind : : Profile & & kind ! = TransKind : : Optimize ) return 0 . 0 ; <nl> - <nl> - auto const locId = inst - > extra < DecRef > ( ) - > locId ; <nl> - auto const profileKey = <nl> - makeStaticString ( folly : : to < std : : string > ( " DecRefProfile - " , <nl> - opcodeName ( inst - > op ( ) ) , <nl> - ' - ' , type . toString ( ) , <nl> - ' - ' , locId ) ) ; <nl> - profile . emplace ( m_state . unit . context ( ) , inst - > marker ( ) , profileKey ) ; <nl> - <nl> - auto & v = vmain ( ) ; <nl> - if ( profile - > profiling ( ) ) { <nl> - v < < incwm { rvmtl ( ) [ profile - > handle ( ) + offsetof ( DecRefProfile , hits ) ] , <nl> - v . makeReg ( ) } ; <nl> - } else if ( profile - > optimizing ( ) ) { <nl> - auto const data = profile - > data ( DecRefProfile : : reduce ) ; <nl> - if ( data . destroyRate ( ) ! = 0 . 0 & & data . destroyRate ( ) ! = 1 . 0 ) { <nl> - / / These are the only interesting cases where we could be doing better . <nl> - FTRACE ( 5 , " DecRefProfile : { } : { } { } \ n " , <nl> - data , inst - > marker ( ) . show ( ) , profileKey - > data ( ) ) ; <nl> - } <nl> - if ( data . destroyRate ( ) = = 0 . 0 ) { <nl> - emitIncStat ( v , Stats : : TC_DecRef_Profiled_0 ) ; <nl> - } else if ( data . destroyRate ( ) = = 1 . 0 ) { <nl> - emitIncStat ( v , Stats : : TC_DecRef_Profiled_100 ) ; <nl> - } <nl> - return data . destroyRate ( ) ; <nl> - } <nl> - <nl> - return 0 . 0 ; <nl> - } <nl> - <nl> - static CallSpec getDtorCallSpec ( DataType type ) { <nl> - switch ( type ) { <nl> - case KindOfString : <nl> - return CallSpec : : method ( & StringData : : release ) ; <nl> - case KindOfArray : <nl> - return CallSpec : : method ( & ArrayData : : release ) ; <nl> - case KindOfObject : <nl> - return CallSpec : : method ( <nl> - RuntimeOption : : EnableObjDestructCall <nl> - ? & ObjectData : : release <nl> - : & ObjectData : : releaseNoObjDestructCheck <nl> - ) ; <nl> - case KindOfResource : <nl> - return CallSpec : : method ( & ResourceHdr : : release ) ; <nl> - case KindOfRef : <nl> - return CallSpec : : method ( & RefData : : release ) ; <nl> - DT_UNCOUNTED_CASE : <nl> - case KindOfClass : <nl> - break ; <nl> - } <nl> - not_reached ( ) ; <nl> - } <nl> - <nl> - static CallSpec makeDtorCall ( Type ty , Vloc loc , ArgGroup & args ) { <nl> - static auto const TPackedArr = Type : : Array ( ArrayData : : kPackedKind ) ; <nl> - static auto const TVecArr = Type : : Array ( ArrayData : : kVecKind ) ; <nl> - static auto const TDictArr = Type : : Array ( ArrayData : : kDictKind ) ; <nl> - static auto const TMixedArr = Type : : Array ( ArrayData : : kMixedKind ) ; <nl> - static auto const TApcArr = Type : : Array ( ArrayData : : kApcKind ) ; <nl> - <nl> - if ( ty < = TPackedArr ) return CallSpec : : direct ( PackedArray : : Release ) ; <nl> - if ( ty < = TVecArr ) return CallSpec : : direct ( PackedArray : : Release ) ; <nl> - if ( ty < = TDictArr ) return CallSpec : : direct ( MixedArray : : Release ) ; <nl> - if ( ty < = TMixedArr ) return CallSpec : : direct ( MixedArray : : Release ) ; <nl> - if ( ty < = TApcArr ) return CallSpec : : direct ( APCLocalArray : : Release ) ; <nl> - if ( ty < = TArr ) return CallSpec : : array ( & g_array_funcs . release ) ; <nl> - <nl> - if ( ty < = TObj & & ty . clsSpec ( ) . cls ( ) ) { <nl> - auto cls = ty . clsSpec ( ) . cls ( ) ; <nl> - <nl> - / / These conditions must match what causes us to call cls - > instanceDtor ( ) <nl> - / / in ObjectData : : release ( ) . <nl> - if ( ( cls - > attrs ( ) & AttrNoOverride ) & & <nl> - ! cls - > getDtor ( ) & & cls - > instanceDtor ( ) ) { <nl> - args . immPtr ( cls ) ; <nl> - return CallSpec : : direct ( cls - > instanceDtor ( ) . get ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - return ty . isKnownDataType ( ) ? getDtorCallSpec ( ty . toDataType ( ) ) <nl> - : CallSpec : : destruct ( loc . reg ( 1 ) ) ; <nl> - } <nl> - <nl> - / * <nl> - * We ' ve tried a variety of tweaks to this and found the current state of <nl> - * things optimal , at least when measurements of the following factors were <nl> - * made : <nl> - * <nl> - * - whether to load the count into a register <nl> - * <nl> - * - whether to use if ( ! - - count ) release ( ) ; if we don ' t need a static check <nl> - * <nl> - * - whether to skip using the register and just emit - - count if we know <nl> - * its not static , and can ' t hit zero . <nl> - * <nl> - * The current scheme generates if ( ! - - count ) release ( ) for types that cannot <nl> - * possibly be static . For types that might be static , it generates a compare <nl> - * of the m_count field against 1 , followed by two conditional branches on the <nl> - * same flags . We make use of the invariant that count fields are never zero , <nl> - * and use a code sequence that looks like this : <nl> - * <nl> - * cmpl $ 1 , $ FAST_REFCOUNT_OFFSET ( % base ) <nl> - * je do_release / / call the destructor , usually in acold <nl> - * jl skip_dec / / count < 1 implies it ' s static <nl> - * decl $ FAST_REFCOUNT_OFFSET ( % base ) <nl> - * skip_dec : <nl> - * / / . . . . <nl> - * / <nl> - void CodeGenerator : : decRefImpl ( Vout & v , const IRInstruction * inst , <nl> - const OptDecRefProfile & profile , <nl> - bool unlikelyDestroy ) { <nl> - auto const ty = inst - > src ( 0 ) - > type ( ) ; <nl> - auto const base = srcLoc ( inst , 0 ) . reg ( 0 ) ; <nl> - <nl> - auto destroy = [ & ] ( Vout & v ) { <nl> - emitIncStat ( v , unlikelyDestroy ? Stats : : TC_DecRef_Normal_Destroy <nl> - : Stats : : TC_DecRef_Likely_Destroy ) ; <nl> - if ( profile & & profile - > profiling ( ) ) { <nl> - v < < incwm { rvmtl ( ) [ profile - > handle ( ) + offsetof ( DecRefProfile , destroy ) ] , <nl> - v . makeReg ( ) } ; <nl> - } <nl> - auto args = argGroup ( inst ) . reg ( base ) ; <nl> - auto const dtor = makeDtorCall ( ty , srcLoc ( inst , 0 ) , args ) ; <nl> - cgCallHelper ( v , dtor , kVoidDest , SyncOptions : : Sync , args ) ; <nl> - } ; <nl> - <nl> - emitIncStat ( v , unlikelyDestroy ? Stats : : TC_DecRef_Normal_Decl <nl> - : Stats : : TC_DecRef_Likely_Decl ) ; <nl> - <nl> - if ( profile & & profile - > profiling ( ) ) { <nl> - v < < incwm { rvmtl ( ) [ profile - > handle ( ) + offsetof ( DecRefProfile , trydec ) ] , <nl> - v . makeReg ( ) } ; <nl> - } <nl> - <nl> - if ( ! ty . maybe ( TPersistent ) ) { <nl> - auto const sf = emitDecRef ( v , base ) ; <nl> - ifThen ( v , vcold ( ) , CC_E , sf , destroy , unlikelyDestroy ) ; <nl> - return ; <nl> - } <nl> - <nl> - emitDecRefWork ( v , vcold ( ) , base , destroy , unlikelyDestroy ) ; <nl> - } <nl> - <nl> - void CodeGenerator : : emitDecRefTypeStat ( Vout & v , const IRInstruction * inst ) { <nl> - if ( ! Trace : : moduleEnabled ( Trace : : decreftype ) ) return ; <nl> - <nl> - auto category = makeStaticString ( inst - > is ( DecRef ) ? " DecRef " : " DecRefNZ " ) ; <nl> - auto key = makeStaticString ( inst - > src ( 0 ) - > type ( ) . unspecialize ( ) . toString ( ) ) ; <nl> - cgCallHelper ( <nl> - v , <nl> - CallSpec : : direct ( Stats : : incStatGrouped ) , <nl> - kVoidDest , <nl> - SyncOptions : : None , <nl> - argGroup ( inst ) <nl> - . immPtr ( category ) <nl> - . immPtr ( key ) <nl> - . imm ( 1 ) <nl> - ) ; <nl> - } <nl> - <nl> - void CodeGenerator : : cgDecRef ( IRInstruction * inst ) { <nl> - / / This is redundant with a check in ifRefCounted , but we check earlier to <nl> - / / avoid emitting profiling code in this case . <nl> - auto const ty = inst - > src ( 0 ) - > type ( ) ; <nl> - if ( ! ty . maybe ( TCounted ) ) return ; <nl> - <nl> - auto & v = vmain ( ) ; <nl> - emitDecRefTypeStat ( v , inst ) ; <nl> - OptDecRefProfile profile ; <nl> - auto const destroyRate = decRefDestroyRate ( inst , profile , ty ) ; <nl> - FTRACE ( 3 , " destroyPercent { : . 2 % } for { } \ n " , destroyRate , * inst ) ; <nl> - <nl> - auto const rData = srcLoc ( inst , 0 ) . reg ( 0 ) ; <nl> - auto const rType = srcLoc ( inst , 0 ) . reg ( 1 ) ; <nl> - if ( RuntimeOption : : EvalHHIROutlineGenericIncDecRef & & <nl> - profile & & profile - > optimizing ( ) & & ! ty . isKnownDataType ( ) ) { <nl> - auto const data = profile - > data ( DecRefProfile : : reduce ) ; <nl> - if ( data . trydec = = 0 ) { <nl> - / / This DecRef never saw a refcounted type during profiling , so call the <nl> - / / stub in cold , keeping only the type check in main . <nl> - FTRACE ( 3 , " Emitting partially outlined DecRef for { } , { } \ n " , data , * inst ) ; <nl> - auto const sf = v . makeReg ( ) ; <nl> - emitCmpTVType ( v , sf , KindOfRefCountThreshold , rType ) ; <nl> - unlikelyIfThen ( v , vcold ( ) , CC_NLE , sf , [ & ] ( Vout & v ) { <nl> - auto const stub = mcg - > ustubs ( ) . decRefGeneric ; <nl> - v < < copy2 { rData , rType , rarg ( 0 ) , rarg ( 1 ) } ; <nl> - v < < callfaststub { stub , makeFixup ( inst - > marker ( ) ) , arg_regs ( 2 ) } ; <nl> - } ) ; <nl> - return ; <nl> - } <nl> - } <nl> - <nl> - ifRefCountedType ( <nl> - v , v , ty , srcLoc ( inst , 0 ) , <nl> - [ & ] ( Vout & v ) { <nl> - decRefImpl ( <nl> - v , inst , profile , <nl> - destroyRate * 100 < RuntimeOption : : EvalJitUnlikelyDecRefPercent <nl> - ) ; <nl> - } <nl> - ) ; <nl> - } <nl> - <nl> - void CodeGenerator : : cgDecRefNZ ( IRInstruction * inst ) { <nl> - emitIncStat ( vmain ( ) , Stats : : TC_DecRef_NZ ) ; <nl> - emitDecRefTypeStat ( vmain ( ) , inst ) ; <nl> - auto const ty = inst - > src ( 0 ) - > type ( ) ; <nl> - ifRefCountedNonPersistent ( <nl> - vmain ( ) , ty , srcLoc ( inst , 0 ) , <nl> - [ & ] ( Vout & v ) { <nl> - auto const base = srcLoc ( inst , 0 ) . reg ( ) ; <nl> - emitDecRef ( v , base ) ; <nl> - } <nl> - ) ; <nl> - } <nl> - <nl> void CodeGenerator : : cgCufIterSpillFrame ( IRInstruction * inst ) { <nl> auto const extra = inst - > extra < CufIterSpillFrame > ( ) ; <nl> auto const nArgs = extra - > args ; <nl> void CodeGenerator : : cgDbgTraceCall ( IRInstruction * inst ) { <nl> ) ; <nl> } <nl> <nl> - void CodeGenerator : : cgDbgAssertRefCount ( IRInstruction * inst ) { <nl> - ifRefCountedType ( <nl> - vmain ( ) , vmain ( ) , inst - > src ( 0 ) - > type ( ) , srcLoc ( inst , 0 ) , <nl> - [ & ] ( Vout & v ) { <nl> - emitAssertRefCount ( v , srcLoc ( inst , 0 ) . reg ( ) ) ; <nl> - } <nl> - ) ; <nl> - } <nl> - <nl> void CodeGenerator : : cgDbgAssertType ( IRInstruction * inst ) { <nl> auto & v = vmain ( ) ; <nl> auto const sf = v . makeReg ( ) ; <nl> mmm a / hphp / runtime / vm / jit / code - gen - x64 . h <nl> ppp b / hphp / runtime / vm / jit / code - gen - x64 . h <nl> struct CodeGenerator { <nl> void emitInitObjProps ( const IRInstruction * inst , Vreg dstReg , <nl> const Class * cls , size_t nProps ) ; <nl> <nl> - void decRefImpl ( Vout & v , const IRInstruction * , const OptDecRefProfile & , bool ) ; <nl> - float decRefDestroyRate ( const IRInstruction * inst , <nl> - OptDecRefProfile & profile , Type type ) ; <nl> - void emitDecRefTypeStat ( Vout & v , const IRInstruction * ) ; <nl> - <nl> void cgPropImpl ( IRInstruction * ) ; <nl> void cgIssetEmptyPropImpl ( IRInstruction * ) ; <nl> void cgElemImpl ( IRInstruction * ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 5dbc9221d11 <nl> mmm / dev / null <nl> ppp b / hphp / runtime / vm / jit / irlower - refcount . cpp <nl> <nl> + / * <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | HipHop for PHP | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | Copyright ( c ) 2010 - 2016 Facebook , Inc . ( http : / / www . facebook . com ) | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + | This source file is subject to version 3 . 01 of the PHP license , | <nl> + | that is bundled with this package in the file LICENSE , and is | <nl> + | available through the world - wide - web at the following url : | <nl> + | http : / / www . php . net / license / 3_01 . txt | <nl> + | If you did not receive a copy of the PHP license and are unable to | <nl> + | obtain it through the world - wide - web , please send a note to | <nl> + | license @ php . net so we can mail you a copy immediately . | <nl> + + mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - + <nl> + * / <nl> + <nl> + # include " hphp / runtime / vm / jit / irlower - internal . h " <nl> + <nl> + # include " hphp / runtime / base / apc - local - array . h " <nl> + # include " hphp / runtime / base / array - data . h " <nl> + # include " hphp / runtime / base / countable . h " <nl> + # include " hphp / runtime / base / header - kind . h " <nl> + # include " hphp / runtime / base / mixed - array . h " <nl> + # include " hphp / runtime / base / packed - array . h " <nl> + # include " hphp / runtime / base / runtime - option . h " <nl> + # include " hphp / runtime / base / static - string - table . h " <nl> + # include " hphp / runtime / base / stats . h " <nl> + <nl> + # include " hphp / runtime / vm / jit / types . h " <nl> + # include " hphp / runtime / vm / jit / abi . h " <nl> + # include " hphp / runtime / vm / jit / arg - group . h " <nl> + # include " hphp / runtime / vm / jit / bc - marker . h " <nl> + # include " hphp / runtime / vm / jit / call - spec . h " <nl> + # include " hphp / runtime / vm / jit / code - gen - cf . h " <nl> + # include " hphp / runtime / vm / jit / code - gen - helpers . h " <nl> + # include " hphp / runtime / vm / jit / extra - data . h " <nl> + # include " hphp / runtime / vm / jit / ir - instruction . h " <nl> + # include " hphp / runtime / vm / jit / ir - opcode . h " <nl> + # include " hphp / runtime / vm / jit / ssa - tmp . h " <nl> + # include " hphp / runtime / vm / jit / target - profile . h " <nl> + # include " hphp / runtime / vm / jit / type . h " <nl> + # include " hphp / runtime / vm / jit / type - specialization . h " <nl> + # include " hphp / runtime / vm / jit / vasm - gen . h " <nl> + # include " hphp / runtime / vm / jit / vasm - instr . h " <nl> + # include " hphp / runtime / vm / jit / vasm - reg . h " <nl> + <nl> + # include " hphp / util / asm - x64 . h " <nl> + # include " hphp / util / trace . h " <nl> + <nl> + # include < folly / Format . h > <nl> + # include < folly / Optional . h > <nl> + <nl> + namespace HPHP { namespace jit { namespace irlower { <nl> + <nl> + TRACE_SET_MOD ( irlower ) ; <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + namespace { <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + template < class Then > <nl> + void ifNonPersistent ( Vout & v , Type ty , Vloc loc , Then then ) { <nl> + if ( ! ty . maybe ( TPersistent ) ) { <nl> + then ( v ) ; / / non - persistent check below will always succeed <nl> + return ; <nl> + } <nl> + <nl> + auto const sf = v . makeReg ( ) ; <nl> + v < < cmplim { 0 , loc . reg ( ) [ FAST_REFCOUNT_OFFSET ] , sf } ; <nl> + static_assert ( UncountedValue < 0 & & StaticValue < 0 , " " ) ; <nl> + ifThen ( v , CC_GE , sf , then ) ; <nl> + } <nl> + <nl> + template < class Then > <nl> + void ifRefCountedType ( Vout & v , Vout & vtaken , Type ty , Vloc loc , Then then ) { <nl> + if ( ! ty . maybe ( TCounted ) ) return ; <nl> + if ( ty . isKnownDataType ( ) ) { <nl> + if ( isRefcountedType ( ty . toDataType ( ) ) ) then ( v ) ; <nl> + return ; <nl> + } <nl> + auto const sf = v . makeReg ( ) ; <nl> + emitCmpTVType ( v , sf , KindOfRefCountThreshold , loc . reg ( 1 ) ) ; <nl> + unlikelyIfThen ( v , vtaken , CC_NLE , sf , then ) ; <nl> + } <nl> + <nl> + template < class Then > <nl> + void ifRefCountedNonPersistent ( Vout & v , Type ty , Vloc loc , Then then ) { <nl> + ifRefCountedType ( v , v , ty , loc , [ & ] ( Vout & v ) { <nl> + ifNonPersistent ( v , ty , loc , then ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + namespace { <nl> + <nl> + struct IncRefProfile { <nl> + std : : string toString ( ) const { <nl> + return folly : : sformat ( " tryinc : { : 4 } " , tryinc ) ; <nl> + } <nl> + <nl> + static void reduce ( IncRefProfile & a , const IncRefProfile & b ) { <nl> + a . tryinc + = b . tryinc ; <nl> + } <nl> + <nl> + / * <nl> + * The number of times this IncRef made it at least as far as the static <nl> + * check ( meaning it was given a refcounted DataType ) . <nl> + * / <nl> + uint16_t tryinc ; <nl> + } ; <nl> + <nl> + } <nl> + <nl> + void cgIncRef ( IRLS & env , const IRInstruction * inst ) { <nl> + / / This is redundant with a check in ifRefCountedNonPersistent , but we check <nl> + / / anyway to avoid emitting profiling code in this case . <nl> + auto const ty = inst - > src ( 0 ) - > type ( ) ; <nl> + if ( ! ty . maybe ( TCounted ) ) return ; <nl> + <nl> + folly : : Optional < rds : : Handle > profHandle ; <nl> + auto vtaken = & vmain ( env ) ; <nl> + <nl> + / / We profile generic IncRefs to see which ones are unlikely to see <nl> + / / refcounted values . <nl> + if ( RuntimeOption : : EvalHHIROutlineGenericIncDecRef & & <nl> + ! ty . isKnownDataType ( ) ) { <nl> + auto const profileKey = makeStaticString ( <nl> + folly : : to < std : : string > ( " IncRefProfile - " , ty . toString ( ) ) <nl> + ) ; <nl> + auto const profile = TargetProfile < IncRefProfile > { <nl> + env . unit . context ( ) , inst - > marker ( ) , profileKey <nl> + } ; <nl> + <nl> + if ( profile . profiling ( ) ) { <nl> + profHandle = profile . handle ( ) ; <nl> + } else if ( profile . optimizing ( ) ) { <nl> + auto const data = profile . data ( IncRefProfile : : reduce ) ; <nl> + if ( data . tryinc = = 0 ) { <nl> + FTRACE ( 3 , " irlower - inc - dec : Emitting cold IncRef for { } , { } \ n " , <nl> + data , * inst ) ; <nl> + vtaken = & vcold ( env ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + auto const loc = srcLoc ( env , inst , 0 ) ; <nl> + auto & v = vmain ( env ) ; <nl> + <nl> + ifRefCountedType ( v , * vtaken , ty , loc , [ & ] ( Vout & v ) { <nl> + if ( profHandle ) { <nl> + v < < incwm { rvmtl ( ) [ * profHandle + offsetof ( IncRefProfile , tryinc ) ] , <nl> + v . makeReg ( ) } ; <nl> + } <nl> + ifNonPersistent ( v , ty , loc , [ & ] ( Vout & v ) { <nl> + emitIncRef ( v , loc . reg ( ) ) ; <nl> + } ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + void cgIncRefCtx ( IRLS & env , const IRInstruction * inst ) { <nl> + auto const ty = inst - > src ( 0 ) - > type ( ) ; <nl> + <nl> + if ( ty < = TObj ) return cgIncRef ( env , inst ) ; <nl> + if ( ty < = TCctx | | ty < = TNullptr ) return ; <nl> + <nl> + auto const src = srcLoc ( env , inst , 0 ) . reg ( ) ; <nl> + auto & v = vmain ( env ) ; <nl> + <nl> + auto const sf = v . makeReg ( ) ; <nl> + <nl> + if ( ty . maybe ( TNullptr ) ) { <nl> + auto const shifted = v . makeReg ( ) ; <nl> + v < < shrqi { 1 , src , shifted , sf } ; <nl> + <nl> + ifThen ( v , CC_NBE , sf , [ & ] ( Vout & v ) { <nl> + auto const unshifted = v . makeReg ( ) ; <nl> + v < < shlqi { 1 , shifted , unshifted , v . makeReg ( ) } ; <nl> + emitIncRef ( v , unshifted ) ; <nl> + } ) ; <nl> + } else { <nl> + v < < testqi { 0x1 , src , sf } ; <nl> + ifThen ( v , CC_Z , sf , [ & ] ( Vout & v ) { emitIncRef ( v , src ) ; } ) ; <nl> + } <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + namespace { <nl> + <nl> + / * <nl> + * Profile for the type and release - frequency of a DecRef instruction . <nl> + * / <nl> + struct DecRefProfile { <nl> + float destroyRate ( ) const { <nl> + return hits ? float ( destroy ) / hits : 0 . 0 ; <nl> + } <nl> + <nl> + std : : string toString ( ) const { <nl> + return folly : : sformat ( " hits : { : 4 } trydec : { : 4 } , destroy : { : 4 } ( { : . 2 % } % ) " , <nl> + hits , trydec , destroy , destroyRate ( ) ) ; <nl> + } <nl> + <nl> + static void reduce ( DecRefProfile & a , const DecRefProfile & b ) { <nl> + a . hits + = b . hits ; <nl> + a . trydec + = b . trydec ; <nl> + a . destroy + = b . destroy ; <nl> + } <nl> + <nl> + / * <nl> + * The number of times this DecRef was executed . <nl> + * * / <nl> + uint16_t hits ; <nl> + / * <nl> + * The number of times this DecRef made it at least as far as the static <nl> + * check ( meaning it was given a refcounted DataType ) . <nl> + * / <nl> + uint16_t trydec ; <nl> + / * <nl> + * The number of times this DecRef went to zero and called destroy ( ) . <nl> + * / <nl> + uint16_t destroy ; <nl> + } ; <nl> + <nl> + using OptDecRefProfile = folly : : Optional < TargetProfile < DecRefProfile > > ; <nl> + <nl> + / * <nl> + * Depending on the current translation kind , do nothing , profile , or collect <nl> + * profiling data for the current DecRef instruction . <nl> + * <nl> + * Returns the frequency that the DecRef results in destruction . <nl> + * / <nl> + float decRefDestroyRate ( Vout & v , IRLS & env , const IRInstruction * inst , <nl> + OptDecRefProfile & profile , Type type ) { <nl> + auto const kind = env . unit . context ( ) . kind ; <nl> + <nl> + / / Without profiling data , we assume destroy is unlikely . <nl> + if ( kind ! = TransKind : : Profile & & <nl> + kind ! = TransKind : : Optimize ) return 0 . 0 ; <nl> + <nl> + auto const profileKey = makeStaticString ( folly : : to < std : : string > ( <nl> + " DecRefProfile - " , <nl> + opcodeName ( inst - > op ( ) ) , ' - ' , <nl> + type . toString ( ) , ' - ' , <nl> + inst - > extra < DecRef > ( ) - > locId <nl> + ) ) ; <nl> + profile . emplace ( env . unit . context ( ) , inst - > marker ( ) , profileKey ) ; <nl> + <nl> + if ( profile - > profiling ( ) ) { <nl> + v < < incwm { rvmtl ( ) [ profile - > handle ( ) + offsetof ( DecRefProfile , hits ) ] , <nl> + v . makeReg ( ) } ; <nl> + } else if ( profile - > optimizing ( ) ) { <nl> + auto const data = profile - > data ( DecRefProfile : : reduce ) ; <nl> + <nl> + if ( data . destroyRate ( ) = = 0 . 0 ) { <nl> + emitIncStat ( v , Stats : : TC_DecRef_Profiled_0 ) ; <nl> + } else if ( data . destroyRate ( ) = = 1 . 0 ) { <nl> + emitIncStat ( v , Stats : : TC_DecRef_Profiled_100 ) ; <nl> + } else { <nl> + / / Those are the only interesting cases where we could be doing better . <nl> + FTRACE ( 5 , " irlower - inc - dec : DecRefProfile < { } , { } > : { } \ n " , <nl> + inst - > marker ( ) . show ( ) , profileKey - > data ( ) , data ) ; <nl> + } <nl> + return data . destroyRate ( ) ; <nl> + } <nl> + <nl> + return 0 . 0 ; <nl> + } <nl> + <nl> + CallSpec getDtorCallSpec ( DataType type ) { <nl> + switch ( type ) { <nl> + case KindOfString : <nl> + return CallSpec : : method ( & StringData : : release ) ; <nl> + case KindOfArray : <nl> + return CallSpec : : method ( & ArrayData : : release ) ; <nl> + case KindOfObject : <nl> + return CallSpec : : method ( <nl> + RuntimeOption : : EnableObjDestructCall <nl> + ? & ObjectData : : release <nl> + : & ObjectData : : releaseNoObjDestructCheck <nl> + ) ; <nl> + case KindOfResource : <nl> + return CallSpec : : method ( & ResourceHdr : : release ) ; <nl> + case KindOfRef : <nl> + return CallSpec : : method ( & RefData : : release ) ; <nl> + DT_UNCOUNTED_CASE : <nl> + case KindOfClass : <nl> + break ; <nl> + } <nl> + always_assert ( false ) ; <nl> + } <nl> + <nl> + CallSpec makeDtorCall ( Type ty , Vloc loc , ArgGroup & args ) { <nl> + static auto const TPackedArr = Type : : Array ( ArrayData : : kPackedKind ) ; <nl> + static auto const TVecArr = Type : : Array ( ArrayData : : kVecKind ) ; <nl> + static auto const TDictArr = Type : : Array ( ArrayData : : kDictKind ) ; <nl> + static auto const TMixedArr = Type : : Array ( ArrayData : : kMixedKind ) ; <nl> + static auto const TAPCArr = Type : : Array ( ArrayData : : kApcKind ) ; <nl> + <nl> + if ( ty < = TPackedArr ) return CallSpec : : direct ( PackedArray : : Release ) ; <nl> + if ( ty < = TVecArr ) return CallSpec : : direct ( PackedArray : : Release ) ; <nl> + if ( ty < = TDictArr ) return CallSpec : : direct ( MixedArray : : Release ) ; <nl> + if ( ty < = TMixedArr ) return CallSpec : : direct ( MixedArray : : Release ) ; <nl> + if ( ty < = TAPCArr ) return CallSpec : : direct ( APCLocalArray : : Release ) ; <nl> + if ( ty < = TArr ) return CallSpec : : array ( & g_array_funcs . release ) ; <nl> + <nl> + if ( ty < = TObj & & ty . clsSpec ( ) . cls ( ) ) { <nl> + auto const cls = ty . clsSpec ( ) . cls ( ) ; <nl> + <nl> + / / These conditions must match the ones which cause us to call <nl> + / / cls - > instanceDtor ( ) in ObjectData : : release ( ) . <nl> + if ( ( cls - > attrs ( ) & AttrNoOverride ) & & <nl> + ! cls - > getDtor ( ) & & <nl> + cls - > instanceDtor ( ) ) { <nl> + args . immPtr ( cls ) ; <nl> + return CallSpec : : direct ( cls - > instanceDtor ( ) . get ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + return ty . isKnownDataType ( ) ? getDtorCallSpec ( ty . toDataType ( ) ) <nl> + : CallSpec : : destruct ( loc . reg ( 1 ) ) ; <nl> + } <nl> + <nl> + / * <nl> + * We ' ve tried a variety of tweaks to this and found the current state of <nl> + * things to be optimal , at least when measurements of the following factors <nl> + * were made : <nl> + * <nl> + * - whether to load the count into a register <nl> + * <nl> + * - whether to use ` if ( ! - - count ) release ( ) ; ' if we don ' t need a static check <nl> + * <nl> + * - whether to skip using the register and just emit - - count if we know <nl> + * its not static , and can ' t hit zero . <nl> + * <nl> + * The current scheme generates ` if ( ! - - count ) release ( ) ; ' for types that <nl> + * cannot possibly be static . For types that might be static , it generates a <nl> + * compare of the m_count field against 1 , followed by two conditional branches <nl> + * on the same flags . We make use of the invariant that count fields are never <nl> + * zero , and use a code sequence that looks like this : <nl> + * <nl> + * cmpl $ 1 , $ FAST_REFCOUNT_OFFSET ( % base ) <nl> + * je do_release / / call the destructor , usually in cold code <nl> + * jl skip_dec / / count < 1 implies it ' s static <nl> + * decl $ FAST_REFCOUNT_OFFSET ( % base ) <nl> + * skip_dec : <nl> + * / / . . . . <nl> + * / <nl> + void implDecRef ( Vout & v , IRLS & env , const IRInstruction * inst , <nl> + const OptDecRefProfile & profile , bool unlikelyDestroy ) { <nl> + auto const ty = inst - > src ( 0 ) - > type ( ) ; <nl> + auto const base = srcLoc ( env , inst , 0 ) . reg ( 0 ) ; <nl> + <nl> + auto const destroy = [ & ] ( Vout & v ) { <nl> + emitIncStat ( v , unlikelyDestroy ? Stats : : TC_DecRef_Normal_Destroy <nl> + : Stats : : TC_DecRef_Likely_Destroy ) ; <nl> + if ( profile & & profile - > profiling ( ) ) { <nl> + v < < incwm { rvmtl ( ) [ profile - > handle ( ) + offsetof ( DecRefProfile , destroy ) ] , <nl> + v . makeReg ( ) } ; <nl> + } <nl> + auto args = argGroup ( env , inst ) . reg ( base ) ; <nl> + auto const dtor = makeDtorCall ( ty , srcLoc ( env , inst , 0 ) , args ) ; <nl> + cgCallHelper ( v , env , dtor , kVoidDest , SyncOptions : : Sync , args ) ; <nl> + } ; <nl> + <nl> + emitIncStat ( v , unlikelyDestroy ? Stats : : TC_DecRef_Normal_Decl <nl> + : Stats : : TC_DecRef_Likely_Decl ) ; <nl> + if ( profile & & profile - > profiling ( ) ) { <nl> + v < < incwm { rvmtl ( ) [ profile - > handle ( ) + offsetof ( DecRefProfile , trydec ) ] , <nl> + v . makeReg ( ) } ; <nl> + } <nl> + <nl> + if ( ! ty . maybe ( TPersistent ) ) { <nl> + auto const sf = emitDecRef ( v , base ) ; <nl> + ifThen ( v , vcold ( env ) , CC_E , sf , destroy , unlikelyDestroy ) ; <nl> + return ; <nl> + } <nl> + <nl> + emitDecRefWork ( v , vcold ( env ) , base , destroy , unlikelyDestroy ) ; <nl> + } <nl> + <nl> + void emitDecRefTypeStat ( Vout & v , IRLS & env , const IRInstruction * inst ) { <nl> + if ( ! Trace : : moduleEnabled ( Trace : : decreftype ) ) return ; <nl> + <nl> + auto category = makeStaticString ( inst - > is ( DecRef ) ? " DecRef " : " DecRefNZ " ) ; <nl> + auto key = makeStaticString ( inst - > src ( 0 ) - > type ( ) . unspecialize ( ) . toString ( ) ) ; <nl> + <nl> + auto const args = argGroup ( env , inst ) <nl> + . immPtr ( category ) <nl> + . immPtr ( key ) <nl> + . imm ( 1 ) ; <nl> + <nl> + cgCallHelper ( v , env , CallSpec : : direct ( Stats : : incStatGrouped ) , <nl> + kVoidDest , SyncOptions : : None , args ) ; <nl> + } <nl> + <nl> + } <nl> + <nl> + void cgDecRef ( IRLS & env , const IRInstruction * inst ) { <nl> + / / This is redundant with a check in ifRefCounted , but we check anyway to <nl> + / / avoid emitting profiling code in this case . <nl> + auto const ty = inst - > src ( 0 ) - > type ( ) ; <nl> + if ( ! ty . maybe ( TCounted ) ) return ; <nl> + <nl> + auto & v = vmain ( env ) ; <nl> + <nl> + emitDecRefTypeStat ( v , env , inst ) ; <nl> + <nl> + OptDecRefProfile profile ; <nl> + auto const destroyRate = decRefDestroyRate ( v , env , inst , profile , ty ) ; <nl> + FTRACE ( 3 , " irlower - inc - dec : destroyPercent { : . 2 % } for { } \ n " , <nl> + destroyRate , * inst ) ; <nl> + <nl> + if ( RuntimeOption : : EvalHHIROutlineGenericIncDecRef & & <nl> + profile & & <nl> + profile - > optimizing ( ) & & <nl> + ! ty . isKnownDataType ( ) ) { <nl> + auto const data = profile - > data ( DecRefProfile : : reduce ) ; <nl> + if ( data . trydec = = 0 ) { <nl> + / / This DecRef never saw a refcounted type during profiling , so call the <nl> + / / stub in cold , keeping only the type check in main . <nl> + FTRACE ( 3 , " irlower - inc - dec : Emitting partially outlined DecRef " <nl> + " for { } , { } \ n " , data , * inst ) ; <nl> + <nl> + auto const data = srcLoc ( env , inst , 0 ) . reg ( 0 ) ; <nl> + auto const type = srcLoc ( env , inst , 0 ) . reg ( 1 ) ; <nl> + <nl> + auto const sf = v . makeReg ( ) ; <nl> + emitCmpTVType ( v , sf , KindOfRefCountThreshold , type ) ; <nl> + <nl> + unlikelyIfThen ( v , vcold ( env ) , CC_NLE , sf , [ & ] ( Vout & v ) { <nl> + auto const stub = mcg - > ustubs ( ) . decRefGeneric ; <nl> + v < < copy2 { data , type , rarg ( 0 ) , rarg ( 1 ) } ; <nl> + v < < callfaststub { stub , makeFixup ( inst - > marker ( ) ) , arg_regs ( 2 ) } ; <nl> + } ) ; <nl> + return ; <nl> + } <nl> + } <nl> + <nl> + ifRefCountedType ( v , v , ty , srcLoc ( env , inst , 0 ) , [ & ] ( Vout & v ) { <nl> + implDecRef ( <nl> + v , env , inst , profile , <nl> + destroyRate * 100 < RuntimeOption : : EvalJitUnlikelyDecRefPercent <nl> + ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + void cgDecRefNZ ( IRLS & env , const IRInstruction * inst ) { <nl> + auto & v = vmain ( env ) ; <nl> + <nl> + emitIncStat ( v , Stats : : TC_DecRef_NZ ) ; <nl> + emitDecRefTypeStat ( v , env , inst ) ; <nl> + <nl> + auto const src = srcLoc ( env , inst , 0 ) ; <nl> + auto const ty = inst - > src ( 0 ) - > type ( ) ; <nl> + <nl> + ifRefCountedNonPersistent ( v , ty , src , [ & ] ( Vout & v ) { <nl> + emitDecRef ( v , src . reg ( ) ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + void cgDbgAssertRefCount ( IRLS & env , const IRInstruction * inst ) { <nl> + auto const src = srcLoc ( env , inst , 0 ) ; <nl> + auto & v = vmain ( env ) ; <nl> + <nl> + ifRefCountedType ( v , v , inst - > src ( 0 ) - > type ( ) , src , [ & ] ( Vout & v ) { <nl> + emitAssertRefCount ( v , src . reg ( ) ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + } } } <nl> mmm a / hphp / runtime / vm / jit / target - profile . h <nl> ppp b / hphp / runtime / vm / jit / target - profile . h <nl> struct MethProfile { <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - struct IncRefProfile { <nl> - / * The number of times this IncRef made it at least as far as the static <nl> - * check ( meaning it was given a refcounted DataType . * / <nl> - uint16_t tryinc ; <nl> - <nl> - std : : string toString ( ) const { <nl> - return folly : : sformat ( " tryinc : { : 4 } " , tryinc ) ; <nl> - } <nl> - <nl> - static void reduce ( IncRefProfile & a , const IncRefProfile & b ) { <nl> - a . tryinc + = b . tryinc ; <nl> - } <nl> - } ; <nl> - <nl> - / * <nl> - * DecRefProfile is used to track which types go through DecRef instructions , <nl> - * and which ones arelikely go to zero . <nl> - * / <nl> - struct DecRefProfile { <nl> - / * The number of times this DecRef was executed . * / <nl> - uint16_t hits ; <nl> - <nl> - / * The number of times this DecRef made it at least as far as the static <nl> - * check ( meaning it was given a refcounted DataType . * / <nl> - uint16_t trydec ; <nl> - <nl> - / * The number of times this DecRef went to zero and called destroy ( ) . * / <nl> - uint16_t destroy ; <nl> - <nl> - float destroyRate ( ) const { <nl> - return hits ? float ( destroy ) / hits : 0 . 0 ; <nl> - } <nl> - <nl> - std : : string toString ( ) const { <nl> - return folly : : sformat ( " hits : { : 4 } trydec : { : 4 } , destroy : { : 4 } ( { : . 2 % } % ) " , <nl> - hits , trydec , destroy , destroyRate ( ) ) ; <nl> - } <nl> - <nl> - static void reduce ( DecRefProfile & a , const DecRefProfile & b ) { <nl> - a . hits + = b . hits ; <nl> - a . trydec + = b . trydec ; <nl> - a . destroy + = b . destroy ; <nl> - } <nl> - } ; <nl> - typedef folly : : Optional < TargetProfile < DecRefProfile > > OptDecRefProfile ; <nl> - <nl> - / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - <nl> / * <nl> * ArrayKindProfile profiles the distribution of the array kinds <nl> * observed for a given value . The array kinds currently tracked are <nl> mmm a / hphp / util / trace . h <nl> ppp b / hphp / util / trace . h <nl> namespace Trace { <nl> TM ( instancebits ) \ <nl> TM ( intercept ) \ <nl> TM ( interpOne ) \ <nl> + TM ( irlower ) \ <nl> TM ( jittime ) \ <nl> TM ( layout ) \ <nl> TM ( libxml ) \ <nl> | Migrate { Inc , Dec } Ref instructions to irlower | facebook/hhvm | b61fcf01938ee47177d38254194ce9de2a0bfe6e | 2016-06-21T14:45:09Z |
mmm a / modules / objdetect / src / softcascade . cpp <nl> ppp b / modules / objdetect / src / softcascade . cpp <nl> struct Decimate { <nl> <nl> } ; <nl> <nl> - / / # define USE_REFERENCE_VALUES <nl> + # define USE_REFERENCE_VALUES <nl> <nl> struct ChannelStorage <nl> { <nl> std : : vector < cv : : Mat > hog ; <nl> - cv : : Mat magnitude ; <nl> - cv : : Mat luv ; <nl> - <nl> int shrinkage ; <nl> <nl> enum { HOG_BINS = 6 , HOG_LUV_BINS = 10 } ; <nl> struct ChannelStorage <nl> <nl> # if defined USE_REFERENCE_VALUES <nl> cv : : FileStorage imgs ( " / home / kellan / testInts . xml " , cv : : FileStorage : : READ ) ; <nl> + char buff [ 33 ] ; <nl> # else <nl> - <nl> / / add gauss <nl> cv : : Mat gauss ; <nl> cv : : GaussianBlur ( colored , gauss , cv : : Size ( 3 , 3 ) , 0 , 0 ) ; <nl> struct ChannelStorage <nl> luvs . push_back ( sum ) ; <nl> } <nl> <nl> - / / calculate magnitude <nl> - static const float magnitudeScaling = 1 . f / sqrt ( 2 ) ; <nl> + / / convert to grey <nl> cv : : Mat grey ; <nl> cv : : cvtColor ( colored , grey , CV_RGB2GRAY ) ; <nl> <nl> - / / channels <nl> - cv : : FileStorage imgs ( " / home / kellan / testImgs . xml " , cv : : FileStorage : : READ ) ; <nl> - # endif <nl> + / / get derivative <nl> + cv : : Mat df_dx , df_dy , mag , angle ; <nl> + cv : : Sobel ( grey , df_dx , CV_32F , 1 , 0 ) ; <nl> + cv : : Sobel ( grey , df_dy , CV_32F , 0 , 1 ) ; <nl> <nl> - char buff [ 33 ] ; <nl> - for ( int i = 0 ; i < 7 ; + + i ) <nl> + / / normalize <nl> + df_dx / = 4 ; <nl> + df_dy / = 4 ; <nl> + <nl> + / / calculate magnitude <nl> + cv : : cartToPolar ( df_dx , df_dy , mag , angle , true ) ; <nl> + <nl> + / / normalize to avoid uchar overflow <nl> + static const float magnitudeScaling = 1 . f / sqrt ( 2 ) ; <nl> + mag * = magnitudeScaling ; <nl> + <nl> + / / convert to uchar <nl> + cv : : Mat saturatedMag ( grey . rows , grey . cols , CV_8UC1 ) , shrMag ; <nl> + for ( int y = 0 ; y < grey . rows ; + + y ) <nl> + { <nl> + float * rm = mag . ptr < float > ( y ) ; <nl> + uchar * mg = saturatedMag . ptr < uchar > ( y ) ; <nl> + for ( int x = 0 ; x < grey . cols ; + + x ) <nl> + { <nl> + mg [ x ] = cv : : saturate_cast < uchar > ( rm [ x ] ) ; <nl> + } <nl> + } <nl> + <nl> + / / srink and integrate <nl> + decimate ( saturatedMag , shrMag ) ; <nl> + cv : : integral ( shrMag , mag , cv : : noArray ( ) , CV_32S ) ; <nl> + <nl> + / / create hog channels <nl> + angle / = 60 ; <nl> + <nl> + std : : vector < cv : : Mat > hist ; <nl> + for ( int bin = 0 ; bin < 6 ; + + bin ) <nl> + { <nl> + hist . push_back ( cv : : Mat ( colored . rows , colored . cols , CV_8UC1 ) ) ; <nl> + } <nl> + <nl> + for ( int y = 0 ; y < saturatedMag . rows ; + + y ) <nl> + { <nl> + uchar * magnitude = saturatedMag . ptr < uchar > ( y ) ; <nl> + float * ang = angle . ptr < float > ( y ) ; <nl> + <nl> + for ( int x = 0 ; x < saturatedMag . cols ; + + x ) <nl> + { <nl> + hist [ ( int ) ang [ x ] ] . ptr < uchar > ( y ) [ x ] = magnitude [ x ] ; <nl> + } <nl> + } <nl> + <nl> + # endif <nl> + for ( int i = 0 ; i < 6 ; + + i ) <nl> { <nl> cv : : Mat channel , shrunk , sum ; <nl> - imgs [ std : : string ( " channel " ) + itoa ( i , buff , 10 ) ] > > channel ; <nl> <nl> # if defined USE_REFERENCE_VALUES <nl> + imgs [ std : : string ( " channel " ) + itoa ( i , buff , 10 ) ] > > channel ; <nl> hog . push_back ( channel ) ; <nl> # else <nl> - <nl> - decimate ( channel , shrunk ) ; <nl> - / / cv : : resize ( channel , shrunk , cv : : Size ( ) , 1 . f / shr , 1 . f / shr , cv : : INTER_AREA ) ; <nl> + decimate ( hist [ i ] , shrunk ) ; <nl> cv : : integral ( shrunk , sum , cv : : noArray ( ) , CV_32S ) ; <nl> - <nl> hog . push_back ( sum ) ; <nl> # endif <nl> } <nl> <nl> # if ! defined USE_REFERENCE_VALUES <nl> + hog . push_back ( mag ) ; <nl> hog . insert ( hog . end ( ) , luvs . begin ( ) , luvs . end ( ) ) ; <nl> CV_Assert ( hog . size ( ) = = 10 ) ; <nl> # endif <nl> / / exit ( 10 ) ; <nl> } <nl> - / / { <nl> - / / / / add gauss <nl> - / / cv : : Mat gauss ; <nl> - / / cv : : GaussianBlur ( colored , gauss , cv : : Size ( 3 , 3 ) , 0 , 0 ) ; <nl> - <nl> - / / colored = gauss ; <nl> - / / / / cv : : imshow ( " colored " , colored ) ; <nl> - <nl> - / / cv : : Mat _luv , shrLuv ; <nl> - / / cv : : cvtColor ( colored , _luv , CV_BGR2Luv ) ; <nl> - <nl> - / / / / cv : : imshow ( " _luv " , _luv ) ; <nl> - <nl> - / / cv : : resize ( _luv , shrLuv , cv : : Size ( ) , 1 . f / shr , 1 . f / shr , cv : : INTER_AREA ) ; <nl> - <nl> - / / / / cv : : imshow ( " shrLuv " , shrLuv ) ; <nl> - <nl> - / / cv : : integral ( shrLuv , luv ) ; <nl> - <nl> - / / / / cv : : imshow ( " luv " , luv ) ; <nl> - <nl> - / / std : : vector < cv : : Mat > splited ; <nl> - / / split ( luv , splited ) ; <nl> - <nl> - / / char buffer [ 33 ] ; <nl> - <nl> - / / for ( int i = 0 ; i < ( int ) splited . size ( ) ; i + + ) <nl> - / / { <nl> - / / / / cv : : imshow ( itoa ( i , buffer , 10 ) , splited [ i ] ) ; <nl> - / / } <nl> - <nl> - / / cv : : Mat grey ; <nl> - / / cv : : cvtColor ( colored , grey , CV_RGB2GRAY ) ; <nl> - <nl> - / / / / cv : : imshow ( " grey " , grey ) ; <nl> - <nl> - / / calcHistBins ( grey , magnitude , hog , HOG_BINS , shrinkage ) ; <nl> - <nl> - / / hog . insert ( hog . end ( ) , splited . begin ( ) , splited . end ( ) ) ; <nl> - / / } <nl> <nl> float get ( const int x , const int y , const int channel , const cv : : Rect & area ) const <nl> { <nl> | fix hog channels | opencv/opencv | 296aa8854c27b17a7e3cf4792b85fd256d94b55f | 2012-11-06T23:19:05Z |
mmm a / swoole_redis_coro . cc <nl> ppp b / swoole_redis_coro . cc <nl> static PHP_METHOD ( swoole_redis_coro , zAdd ) <nl> int argc = ZEND_NUM_ARGS ( ) ; <nl> SW_REDIS_COMMAND_CHECK <nl> SW_REDIS_COMMAND_ALLOC_ARGS_ARR <nl> + <nl> if ( zend_get_parameters_array ( ht , argc , z_args ) = = FAILURE ) <nl> { <nl> efree ( z_args ) ; <nl> static PHP_METHOD ( swoole_redis_coro , zAdd ) <nl> <nl> char buf [ 32 ] ; <nl> size_t buf_len ; <nl> - for ( j = k ; j < argc - 1 ; j + = 2 ) { <nl> - convert_to_double ( SW_REDIS_COMMAND_ARGS_REF ( z_args [ j ] ) ) ; buf_len = sw_snprintf ( buf , sizeof ( buf ) , " % f " , SW_REDIS_COMMAND_ARGS_DVAL ( z_args [ j ] ) ) ; <nl> - SW_REDIS_COMMAND_ARGV_FILL ( ( char * ) buf , buf_len ) <nl> + for ( j = k ; j < argc - 1 ; j + = 2 ) <nl> + { <nl> + buf_len = sw_snprintf ( buf , sizeof ( buf ) , " % f " , zval_get_double ( & z_args [ j ] ) ) ; <nl> + SW_REDIS_COMMAND_ARGV_FILL ( ( char * ) buf , buf_len ) <nl> SW_REDIS_COMMAND_ARGV_FILL_WITH_SERIALIZE ( SW_REDIS_COMMAND_ARGS_REF ( z_args [ j + 1 ] ) ) <nl> } <nl> efree ( z_args ) ; <nl> | fix | swoole/swoole-src | 21e04977659ca48e69f65bda097683eaef98f36e | 2019-01-16T06:48:14Z |
mmm a / lib / Frontend / DiagnosticVerifier . cpp <nl> ppp b / lib / Frontend / DiagnosticVerifier . cpp <nl> DiagnosticVerifier : : Result DiagnosticVerifier : : verifyFile ( unsigned BufferID ) { <nl> / / Verify educational notes <nl> for ( auto & foundName : FoundDiagnostic . EducationalNotes ) { <nl> llvm : : erase_if ( expectedNotes - > Names , <nl> - [ & ] ( std : : string item ) { return item = = foundName ; } ) ; <nl> + [ & ] ( StringRef item ) { return item . equals ( foundName ) ; } ) ; <nl> } <nl> <nl> if ( ! expectedNotes - > Names . empty ( ) ) { <nl> void DiagnosticVerifier : : handleDiagnostic ( SourceManager & SM , <nl> <nl> llvm : : SmallVector < std : : string , 1 > eduNotes ; <nl> for ( auto & notePath : Info . EducationalNotePaths ) { <nl> - eduNotes . push_back ( llvm : : sys : : path : : stem ( notePath ) ) ; <nl> + eduNotes . push_back ( llvm : : sys : : path : : stem ( notePath ) . str ( ) ) ; <nl> } <nl> <nl> llvm : : SmallString < 128 > message ; <nl> | [ DiagnosticVerifier ] Explicit convert a StringRef into a std : : string . | apple/swift | feb03ebcd796b5937f3f3debca4419484557a218 | 2020-04-11T16:29:58Z |
mmm a / dbms / src / Storages / MergeTree / MergeTreeIndexFullText . h <nl> ppp b / dbms / src / Storages / MergeTree / MergeTreeIndexFullText . h <nl> class MergeTreeIndexFullText : public IMergeTreeIndex <nl> size_t bloom_filter_hashes ; <nl> / / / Bloom filter seed . <nl> size_t seed ; <nl> - / / / Fucntion for selecting next token . <nl> + / / / Function for selecting next token . <nl> std : : unique_ptr < ITokenExtractor > token_extractor_func ; <nl> } ; <nl> <nl> mmm a / docs / en / query_language / create . md <nl> ppp b / docs / en / query_language / create . md <nl> CREATE TABLE [ IF NOT EXISTS ] [ db . ] table_name AS [ db2 . ] name2 [ ENGINE = engine ] <nl> Creates a table with the same structure as another table . You can specify a different engine for the table . If the engine is not specified , the same engine will be used as for the ` db2 . name2 ` table . <nl> <nl> ` ` ` sql <nl> - CREATE TABLE [ IF NOT EXISTS ] [ db . ] table_name AS table_fucntion ( ) <nl> + CREATE TABLE [ IF NOT EXISTS ] [ db . ] table_name AS table_function ( ) <nl> ` ` ` <nl> <nl> Creates a table with the structure and data returned by a [ table function ] ( table_functions / index . md ) . <nl> mmm a / docs / ru / query_language / create . md <nl> ppp b / docs / ru / query_language / create . md <nl> CREATE TABLE [ IF NOT EXISTS ] [ db . ] table_name AS [ db2 . ] name2 [ ENGINE = engine ] <nl> Создаёт таблицу с такой же структурой , как другая таблица . Можно указать другой движок для таблицы . Если движок не указан , то будет выбран такой же движок , как у таблицы ` db2 . name2 ` . <nl> <nl> ` ` ` sql <nl> - CREATE TABLE [ IF NOT EXISTS ] [ db . ] table_name AS table_fucntion ( ) <nl> + CREATE TABLE [ IF NOT EXISTS ] [ db . ] table_name AS table_function ( ) <nl> ` ` ` <nl> <nl> Создаёт таблицу с такой же структурой и данными , как результат соответствующей табличной функцией . <nl> | fix typos in docs and comment ( ) | ClickHouse/ClickHouse | a019e4509398301f1b4942510da5a611e0910e30 | 2019-10-20T04:43:54Z |
mmm a / src / app / commands / cmd_remove_layer . cpp <nl> ppp b / src / app / commands / cmd_remove_layer . cpp <nl> bool RemoveLayerCommand : : onEnabled ( Context * context ) <nl> { <nl> ContextWriter writer ( context ) ; <nl> Sprite * sprite ( writer . sprite ( ) ) ; <nl> - return sprite ; <nl> + return ( sprite ! = NULL ) ; <nl> } <nl> <nl> void RemoveLayerCommand : : onExecute ( Context * context ) <nl> | Fix compilation warning in cmd_remove_layer . cpp | aseprite/aseprite | 0caf41c5fdc7dbd27d355df489774de5fe24641f | 2014-03-22T02:00:31Z |
mmm a / doc / classes / PopupMenu . xml <nl> ppp b / doc / classes / PopupMenu . xml <nl> <nl> < description > <nl> < / description > <nl> < / method > <nl> - < method name = " set_item_statable " > <nl> + < method name = " set_item_multistate " > <nl> < return type = " void " > <nl> < / return > <nl> < argument index = " 0 " name = " idx " type = " int " > <nl> <nl> < description > <nl> < / description > <nl> < / method > <nl> - < method name = " toggle_item_statable " > <nl> + < method name = " toggle_item_multistate " > <nl> < return type = " void " > <nl> < / return > <nl> < argument index = " 0 " name = " idx " type = " int " > <nl> mmm a / editor / plugins / spatial_editor_plugin . cpp <nl> ppp b / editor / plugins / spatial_editor_plugin . cpp <nl> void SpatialEditor : : _menu_item_pressed ( int p_option ) { <nl> case MENU_VISIBILITY_SKELETON : { <nl> <nl> const int idx = view_menu - > get_popup ( ) - > get_item_index ( MENU_VISIBILITY_SKELETON ) ; <nl> - view_menu - > get_popup ( ) - > toggle_item_statable ( idx ) ; <nl> + view_menu - > get_popup ( ) - > toggle_item_multistate ( idx ) ; <nl> <nl> / / Change icon <nl> const int state = view_menu - > get_popup ( ) - > get_item_state ( idx ) ; <nl> SpatialEditor : : SpatialEditor ( EditorNode * p_editor ) { <nl> p - > add_shortcut ( ED_SHORTCUT ( " spatial_editor / settings " , TTR ( " Settings " ) ) , MENU_VIEW_CAMERA_SETTINGS ) ; <nl> <nl> p - > add_separator ( ) ; <nl> - p - > add_statable_item ( TTR ( " Skeleton Gizmo visibility " ) , 3 , 1 , MENU_VISIBILITY_SKELETON ) ; <nl> - p - > add_separator ( ) ; <nl> + p - > add_multistate_item ( TTR ( " Skeleton Gizmo visibility " ) , 3 , 1 , MENU_VISIBILITY_SKELETON ) ; <nl> <nl> p - > set_item_checked ( p - > get_item_index ( MENU_VIEW_ORIGIN ) , true ) ; <nl> p - > set_item_checked ( p - > get_item_index ( MENU_VIEW_GRID ) , true ) ; <nl> mmm a / scene / gui / popup_menu . cpp <nl> ppp b / scene / gui / popup_menu . cpp <nl> void PopupMenu : : add_check_shortcut ( const Ref < ShortCut > & p_shortcut , int p_ID , bo <nl> update ( ) ; <nl> } <nl> <nl> - void PopupMenu : : add_statable_item ( const String & p_label , int p_max_states , int p_default_state , int p_ID , uint32_t p_accel ) { <nl> + void PopupMenu : : add_multistate_item ( const String & p_label , int p_max_states , int p_default_state , int p_ID , uint32_t p_accel ) { <nl> <nl> Item item ; <nl> item . text = p_label ; <nl> void PopupMenu : : set_item_h_offset ( int p_idx , int p_offset ) { <nl> update ( ) ; <nl> } <nl> <nl> - void PopupMenu : : set_item_statable ( int p_idx , int p_state ) { <nl> + void PopupMenu : : set_item_multistate ( int p_idx , int p_state ) { <nl> <nl> ERR_FAIL_INDEX ( p_idx , items . size ( ) ) ; <nl> items [ p_idx ] . state = p_state ; <nl> update ( ) ; <nl> } <nl> <nl> - void PopupMenu : : toggle_item_statable ( int p_idx ) { <nl> + void PopupMenu : : toggle_item_multistate ( int p_idx ) { <nl> <nl> ERR_FAIL_INDEX ( p_idx , items . size ( ) ) ; <nl> if ( 0 > = items [ p_idx ] . max_states ) { <nl> void PopupMenu : : activate_item ( int p_item ) { <nl> if ( ! hide_on_checkable_item_selection | | ! pop - > is_hide_on_checkable_item_selection ( ) ) <nl> break ; <nl> } else if ( 0 < items [ p_item ] . max_states ) { <nl> - if ( ! hide_on_statable_item_selection | | ! pop - > is_hide_on_statable_item_selection ( ) ) <nl> + if ( ! hide_on_multistate_item_selection | | ! pop - > is_hide_on_multistate_item_selection ( ) ) <nl> break ; <nl> } else if ( ! hide_on_item_selection | | ! pop - > is_hide_on_item_selection ( ) ) <nl> break ; <nl> void PopupMenu : : activate_item ( int p_item ) { <nl> if ( ! hide_on_checkable_item_selection ) <nl> return ; <nl> } else if ( 0 < items [ p_item ] . max_states ) { <nl> - if ( ! hide_on_statable_item_selection ) <nl> + if ( ! hide_on_multistate_item_selection ) <nl> return ; <nl> } else if ( ! hide_on_item_selection ) <nl> return ; <nl> bool PopupMenu : : is_hide_on_checkable_item_selection ( ) const { <nl> return hide_on_checkable_item_selection ; <nl> } <nl> <nl> - void PopupMenu : : set_hide_on_statable_item_selection ( bool p_enabled ) { <nl> + void PopupMenu : : set_hide_on_multistate_item_selection ( bool p_enabled ) { <nl> <nl> - hide_on_statable_item_selection = p_enabled ; <nl> + hide_on_multistate_item_selection = p_enabled ; <nl> } <nl> <nl> - bool PopupMenu : : is_hide_on_statable_item_selection ( ) const { <nl> + bool PopupMenu : : is_hide_on_multistate_item_selection ( ) const { <nl> <nl> - return hide_on_statable_item_selection ; <nl> + return hide_on_multistate_item_selection ; <nl> } <nl> <nl> String PopupMenu : : get_tooltip ( const Point2 & p_pos ) const { <nl> void PopupMenu : : _bind_methods ( ) { <nl> ClassDB : : bind_method ( D_METHOD ( " set_item_as_checkable " , " idx " , " enable " ) , & PopupMenu : : set_item_as_checkable ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " set_item_tooltip " , " idx " , " tooltip " ) , & PopupMenu : : set_item_tooltip ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " set_item_shortcut " , " idx " , " shortcut " , " global " ) , & PopupMenu : : set_item_shortcut , DEFVAL ( false ) ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " set_item_statable " , " idx " , " state " ) , & PopupMenu : : set_item_statable ) ; <nl> + ClassDB : : bind_method ( D_METHOD ( " set_item_multistate " , " idx " , " state " ) , & PopupMenu : : set_item_multistate ) ; <nl> <nl> ClassDB : : bind_method ( D_METHOD ( " toggle_item_checked " , " idx " ) , & PopupMenu : : toggle_item_checked ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " toggle_item_statable " , " idx " ) , & PopupMenu : : toggle_item_statable ) ; <nl> + ClassDB : : bind_method ( D_METHOD ( " toggle_item_multistate " , " idx " ) , & PopupMenu : : toggle_item_multistate ) ; <nl> <nl> ClassDB : : bind_method ( D_METHOD ( " get_item_text " , " idx " ) , & PopupMenu : : get_item_text ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " get_item_icon " , " idx " ) , & PopupMenu : : get_item_icon ) ; <nl> void PopupMenu : : _bind_methods ( ) { <nl> ClassDB : : bind_method ( D_METHOD ( " set_hide_on_checkable_item_selection " , " enable " ) , & PopupMenu : : set_hide_on_checkable_item_selection ) ; <nl> ClassDB : : bind_method ( D_METHOD ( " is_hide_on_checkable_item_selection " ) , & PopupMenu : : is_hide_on_checkable_item_selection ) ; <nl> <nl> - ClassDB : : bind_method ( D_METHOD ( " set_hide_on_state_item_selection " , " enable " ) , & PopupMenu : : set_hide_on_statable_item_selection ) ; <nl> - ClassDB : : bind_method ( D_METHOD ( " is_hide_on_state_item_selection " ) , & PopupMenu : : is_hide_on_statable_item_selection ) ; <nl> + ClassDB : : bind_method ( D_METHOD ( " set_hide_on_state_item_selection " , " enable " ) , & PopupMenu : : set_hide_on_multistate_item_selection ) ; <nl> + ClassDB : : bind_method ( D_METHOD ( " is_hide_on_state_item_selection " ) , & PopupMenu : : is_hide_on_multistate_item_selection ) ; <nl> <nl> ClassDB : : bind_method ( D_METHOD ( " _submenu_timeout " ) , & PopupMenu : : _submenu_timeout ) ; <nl> <nl> PopupMenu : : PopupMenu ( ) { <nl> set_as_toplevel ( true ) ; <nl> set_hide_on_item_selection ( true ) ; <nl> set_hide_on_checkable_item_selection ( true ) ; <nl> - set_hide_on_statable_item_selection ( false ) ; <nl> + set_hide_on_multistate_item_selection ( false ) ; <nl> <nl> submenu_timer = memnew ( Timer ) ; <nl> submenu_timer - > set_wait_time ( 0 . 3 ) ; <nl> mmm a / scene / gui / popup_menu . h <nl> ppp b / scene / gui / popup_menu . h <nl> class PopupMenu : public Popup { <nl> bool invalidated_click ; <nl> bool hide_on_item_selection ; <nl> bool hide_on_checkable_item_selection ; <nl> - bool hide_on_statable_item_selection ; <nl> + bool hide_on_multistate_item_selection ; <nl> Vector2 moved ; <nl> <nl> Array _get_items ( ) const ; <nl> class PopupMenu : public Popup { <nl> void add_icon_check_shortcut ( const Ref < Texture > & p_icon , const Ref < ShortCut > & p_shortcut , int p_ID = - 1 , bool p_global = false ) ; <nl> void add_check_shortcut ( const Ref < ShortCut > & p_shortcut , int p_ID = - 1 , bool p_global = false ) ; <nl> <nl> - void add_statable_item ( const String & p_label , int p_max_states , int p_default_state , int p_ID = - 1 , uint32_t p_accel = 0 ) ; <nl> + void add_multistate_item ( const String & p_label , int p_max_states , int p_default_state , int p_ID = - 1 , uint32_t p_accel = 0 ) ; <nl> <nl> void set_item_text ( int p_idx , const String & p_text ) ; <nl> void set_item_icon ( int p_idx , const Ref < Texture > & p_icon ) ; <nl> class PopupMenu : public Popup { <nl> void set_item_tooltip ( int p_idx , const String & p_tooltip ) ; <nl> void set_item_shortcut ( int p_idx , const Ref < ShortCut > & p_shortcut , bool p_global = false ) ; <nl> void set_item_h_offset ( int p_idx , int p_offset ) ; <nl> - void set_item_statable ( int p_idx , int p_state ) ; <nl> - void toggle_item_statable ( int p_idx ) ; <nl> + void set_item_multistate ( int p_idx , int p_state ) ; <nl> + void toggle_item_multistate ( int p_idx ) ; <nl> <nl> void toggle_item_checked ( int p_idx ) ; <nl> <nl> class PopupMenu : public Popup { <nl> void set_hide_on_checkable_item_selection ( bool p_enabled ) ; <nl> bool is_hide_on_checkable_item_selection ( ) const ; <nl> <nl> - void set_hide_on_statable_item_selection ( bool p_enabled ) ; <nl> - bool is_hide_on_statable_item_selection ( ) const ; <nl> + void set_hide_on_multistate_item_selection ( bool p_enabled ) ; <nl> + bool is_hide_on_multistate_item_selection ( ) const ; <nl> <nl> PopupMenu ( ) ; <nl> ~ PopupMenu ( ) ; <nl> | Merge pull request from Noshyaar / pr | godotengine/godot | 56a44ca03e05a831e5c3c965a4675d53f82e7e6e | 2017-12-12T06:59:08Z |
mmm a / src / mongo / db / commands / txn_cmds . cpp <nl> ppp b / src / mongo / db / commands / txn_cmds . cpp <nl> <nl> # include " mongo / bson / bsonobj . h " <nl> # include " mongo / bson / bsonobjbuilder . h " <nl> # include " mongo / db / commands . h " <nl> - # include " mongo / db / commands / test_commands_enabled . h " <nl> # include " mongo / db / commands / txn_cmds_gen . h " <nl> # include " mongo / db / op_observer . h " <nl> # include " mongo / db / operation_context . h " <nl> class CmdCommitTxn : public BasicCommand { <nl> <nl> } commitTxn ; <nl> <nl> - class CmdPrepareTxn : public BasicCommand { <nl> - public : <nl> - CmdPrepareTxn ( ) : BasicCommand ( " prepareTransaction " ) { } <nl> - <nl> - AllowedOnSecondary secondaryAllowed ( ServiceContext * ) const override { <nl> - return AllowedOnSecondary : : kNever ; <nl> - } <nl> - <nl> - virtual bool adminOnly ( ) const { <nl> - return true ; <nl> - } <nl> - <nl> - bool supportsWriteConcern ( const BSONObj & cmd ) const override { <nl> - return true ; <nl> - } <nl> - <nl> - std : : string help ( ) const override { <nl> - return " Prepares a transaction . This is only expected to be called by mongos . " ; <nl> - } <nl> - <nl> - Status checkAuthForOperation ( OperationContext * opCtx , <nl> - const std : : string & dbname , <nl> - const BSONObj & cmdObj ) const override { <nl> - return Status : : OK ( ) ; <nl> - } <nl> - <nl> - bool run ( OperationContext * opCtx , <nl> - const std : : string & dbname , <nl> - const BSONObj & cmdObj , <nl> - BSONObjBuilder & result ) override { <nl> - auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> - uassert ( ErrorCodes : : CommandFailed , <nl> - " prepareTransaction must be run within a transaction " , <nl> - txnParticipant ) ; <nl> - <nl> - uassert ( ErrorCodes : : NoSuchTransaction , <nl> - " Transaction isn ' t in progress " , <nl> - txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> - <nl> - / / Add prepareTimestamp to the command response . <nl> - auto timestamp = txnParticipant - > prepareTransaction ( opCtx ) ; <nl> - result . append ( " prepareTimestamp " , timestamp ) ; <nl> - return true ; <nl> - } <nl> - } ; <nl> - <nl> - MONGO_REGISTER_TEST_COMMAND ( CmdPrepareTxn ) ; <nl> - <nl> class CmdAbortTxn : public BasicCommand { <nl> public : <nl> CmdAbortTxn ( ) : BasicCommand ( " abortTransaction " ) { } <nl> mmm a / src / mongo / db / s / SConscript <nl> ppp b / src / mongo / db / s / SConscript <nl> env . Library ( <nl> ] , <nl> ) <nl> <nl> - env . Library ( <nl> - target = ' sharded_transaction_types ' , <nl> - source = [ <nl> - env . Idlc ( ' prepare_transaction . idl ' ) [ 0 ] , <nl> - ] , <nl> - LIBDEPS = [ <nl> - ' $ BUILD_DIR / mongo / base ' , <nl> - ' $ BUILD_DIR / mongo / s / common_s ' , <nl> - ] , <nl> - ) <nl> - <nl> env . Library ( <nl> target = ' type_shard_identity ' , <nl> source = [ <nl> env . Library ( <nl> ' $ BUILD_DIR / mongo / s / commands / cluster_commands_helpers ' , <nl> ' $ BUILD_DIR / mongo / s / commands / shared_cluster_commands ' , <nl> ' balancer ' , <nl> - ' sharded_transaction_types ' , <nl> ' sharding_runtime_d ' , <nl> ] , <nl> ) <nl> deleted file mode 100644 <nl> index 5b1a78030ebf . . 000000000000 <nl> mmm a / src / mongo / db / s / prepare_transaction . idl <nl> ppp / dev / null <nl> <nl> - # Copyright ( C ) 2018 MongoDB Inc . <nl> - # <nl> - # This program is free software : you can redistribute it and / or modify <nl> - # it under the terms of the GNU Affero General Public License , version 3 , <nl> - # as published by the Free Software Foundation . <nl> - # <nl> - # This program is distributed in the hope that it will be useful , <nl> - # but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> - # GNU Affero General Public License for more details . <nl> - # <nl> - # You should have received a copy of the GNU Affero General Public License <nl> - # along with this program . If not , see < http : / / www . gnu . org / licenses / > . <nl> - # <nl> - <nl> - global : <nl> - cpp_namespace : " mongo " <nl> - <nl> - imports : <nl> - - " mongo / idl / basic_types . idl " <nl> - - " mongo / s / sharding_types . idl " <nl> - <nl> - commands : <nl> - prepareTransaction : <nl> - description : " Parser for the ' prepareTransaction ' command . " <nl> - strict : true <nl> - namespace : ignored <nl> - fields : <nl> - coordinator : <nl> - description : " The coordinator shard for this transaction . " <nl> - type : shard_id <nl> mmm a / src / mongo / db / s / txn_two_phase_commit_cmds . cpp <nl> ppp b / src / mongo / db / s / txn_two_phase_commit_cmds . cpp <nl> <nl> namespace mongo { <nl> namespace { <nl> <nl> + class CmdPrepareTxn : public BasicCommand { <nl> + public : <nl> + CmdPrepareTxn ( ) : BasicCommand ( " prepareTransaction " ) { } <nl> + <nl> + AllowedOnSecondary secondaryAllowed ( ServiceContext * ) const override { <nl> + return AllowedOnSecondary : : kNever ; <nl> + } <nl> + <nl> + virtual bool adminOnly ( ) const { <nl> + return true ; <nl> + } <nl> + <nl> + bool supportsWriteConcern ( const BSONObj & cmd ) const override { <nl> + return true ; <nl> + } <nl> + <nl> + std : : string help ( ) const override { <nl> + return " Prepares a transaction . This is only expected to be called by mongos . " ; <nl> + } <nl> + <nl> + Status checkAuthForOperation ( OperationContext * opCtx , <nl> + const std : : string & dbname , <nl> + const BSONObj & cmdObj ) const override { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + bool run ( OperationContext * opCtx , <nl> + const std : : string & dbname , <nl> + const BSONObj & cmdObj , <nl> + BSONObjBuilder & result ) override { <nl> + auto txnParticipant = TransactionParticipant : : get ( opCtx ) ; <nl> + uassert ( ErrorCodes : : CommandFailed , <nl> + " prepareTransaction must be run within a transaction " , <nl> + txnParticipant ) ; <nl> + <nl> + uassert ( ErrorCodes : : NoSuchTransaction , <nl> + " Transaction isn ' t in progress " , <nl> + txnParticipant - > inMultiDocumentTransaction ( ) ) ; <nl> + <nl> + / / Add prepareTimestamp to the command response . <nl> + auto timestamp = txnParticipant - > prepareTransaction ( opCtx ) ; <nl> + result . append ( " prepareTimestamp " , timestamp ) ; <nl> + return true ; <nl> + } <nl> + } prepareTransactionCmd ; <nl> + <nl> class VoteCommitTransactionCmd : public TypedCommand < VoteCommitTransactionCmd > { <nl> public : <nl> using Request = VoteCommitTransaction ; <nl> mmm a / src / mongo / db / s / txn_two_phase_commit_cmds . idl <nl> ppp b / src / mongo / db / s / txn_two_phase_commit_cmds . idl <nl> structs : <nl> type : shard_id <nl> <nl> commands : <nl> + prepareTransaction : <nl> + description : " Parser for the ' prepareTransaction ' command . " <nl> + strict : true <nl> + namespace : ignored <nl> + fields : <nl> + coordinator : <nl> + description : " The coordinator shard for this transaction . " <nl> + type : shard_id <nl> + <nl> voteCommitTransaction : <nl> description : " Parser for the ' voteCommitTransaction ' command . " <nl> namespace : ignored <nl> | SERVER - 36561 Move the prepareTransaction command into txn_two_phase_commit_cmds . cpp | mongodb/mongo | 7c317b85b1273a8d465479f2205eefedb42154c9 | 2018-08-09T20:06:04Z |
mmm a / src / core / grabber / include / grabber / device_grabber . hpp <nl> ppp b / src / core / grabber / include / grabber / device_grabber . hpp <nl> class device_grabber final : public pqrs : : dispatcher : : extra : : dispatcher_client { <nl> logger : : get_logger ( ) - > info ( " virtual_hid_device_service_client_ connect_failed : { 0 } " , error_code . message ( ) ) ; <nl> } ) ; <nl> <nl> - virtual_hid_device_service_client_ - > closed . connect ( [ this ] { <nl> + virtual_hid_device_service_client_ - > closed . connect ( [ ] { <nl> logger : : get_logger ( ) - > info ( " virtual_hid_device_service_client_ closed " ) ; <nl> <nl> - stop ( ) ; <nl> + / / Wait automatic reconnection . <nl> + / / <nl> + / / Note : <nl> + / / The following callback will be signaled by virtual_hid_device_service : : client . <nl> + / / - ` virtual_hid_keyboard_ready_callback ( false ) ` <nl> + / / - ` virtual_hid_pointing_ready_callback ( false ) ` <nl> } ) ; <nl> <nl> virtual_hid_device_service_client_ - > error_occurred . connect ( [ ] ( auto & & error_code ) { <nl> | Fix virtual_hid_device_service : : client : : closed handling at grabber | pqrs-org/Karabiner-Elements | 438d1627a4b48c03b3e609e41a03955dacc62227 | 2020-09-06T12:24:43Z |
mmm a / src / FilterTableHeader . cpp <nl> ppp b / src / FilterTableHeader . cpp <nl> FilterTableHeader : : FilterTableHeader ( QTableView * parent ) : <nl> / / Make sure to not automatically resize the columns according to the contents <nl> setSectionResizeMode ( QHeaderView : : Interactive ) ; <nl> <nl> + / / Highlight column headers of selected cells to emulate spreadsheet behaviour <nl> + setHighlightSections ( true ) ; <nl> + <nl> / / Do some connects : Basically just resize and reposition the input widgets whenever anything changes <nl> connect ( this , & FilterTableHeader : : sectionResized , this , & FilterTableHeader : : adjustPositions ) ; <nl> connect ( parent - > horizontalScrollBar ( ) , & QScrollBar : : valueChanged , this , & FilterTableHeader : : adjustPositions ) ; <nl> | Highlight column headers to emulate spreadsheet behaviour | sqlitebrowser/sqlitebrowser | 7541a8205024368d9f0bdab311e5c6de6e3f8aac | 2019-09-22T21:16:04Z |
mmm a / java / core / src / main / java / com / google / protobuf / AbstractMessage . java <nl> ppp b / java / core / src / main / java / com / google / protobuf / AbstractMessage . java <nl> public String toString ( ) { <nl> <nl> / * * <nl> * Used to support nested builders and called to mark this builder as clean . <nl> - * Clean builders will propagate the { @ link BuildParent # markDirty ( ) } event <nl> + * Clean builders will propagate the { @ link BuilderParent # markDirty ( ) } event <nl> * to their parent builders , while dirty builders will not , as their parents <nl> * should be dirty already . <nl> * <nl> mmm a / java / core / src / main / java / com / google / protobuf / ByteOutput . java <nl> ppp b / java / core / src / main / java / com / google / protobuf / ByteOutput . java <nl> <nl> * An output target for raw bytes . This interface provides semantics that support two types of <nl> * writing : <nl> * <nl> - * < p / > < b > Traditional write operations : < / b > <nl> + * < p > < b > Traditional write operations : < / b > <nl> * ( as defined by { @ link java . io . OutputStream } ) where the target method is responsible for either <nl> * copying the data or completing the write before returning from the method call . <nl> * <nl> - * < p / > < b > Lazy write operations : < / b > where the caller guarantees that it will never modify the <nl> + * < p > < b > Lazy write operations : < / b > where the caller guarantees that it will never modify the <nl> * provided buffer and it can therefore be considered immutable . The target method is free to <nl> * maintain a reference to the buffer beyond the scope of the method call ( e . g . until the write <nl> * operation completes ) . <nl> mmm a / java / core / src / main / java / com / google / protobuf / Internal . java <nl> ppp b / java / core / src / main / java / com / google / protobuf / Internal . java <nl> public V setValue ( V value ) { <nl> int getInt ( int index ) ; <nl> <nl> / * * <nl> - * Like { @ link # add ( Integer ) } but more efficient in that it doesn ' t box the element . <nl> + * Like { @ link # add ( Object ) } but more efficient in that it doesn ' t box the element . <nl> * / <nl> void addInt ( int element ) ; <nl> <nl> / * * <nl> - * Like { @ link # set ( int , Integer ) } but more efficient in that it doesn ' t box the element . <nl> + * Like { @ link # set ( int , Object ) } but more efficient in that it doesn ' t box the element . <nl> * / <nl> int setInt ( int index , int element ) ; <nl> <nl> public V setValue ( V value ) { <nl> boolean getBoolean ( int index ) ; <nl> <nl> / * * <nl> - * Like { @ link # add ( Boolean ) } but more efficient in that it doesn ' t box the element . <nl> + * Like { @ link # add ( Object ) } but more efficient in that it doesn ' t box the element . <nl> * / <nl> void addBoolean ( boolean element ) ; <nl> <nl> / * * <nl> - * Like { @ link # set ( int , Boolean ) } but more efficient in that it doesn ' t box the element . <nl> + * Like { @ link # set ( int , Object ) } but more efficient in that it doesn ' t box the element . <nl> * / <nl> boolean setBoolean ( int index , boolean element ) ; <nl> <nl> public V setValue ( V value ) { <nl> long getLong ( int index ) ; <nl> <nl> / * * <nl> - * Like { @ link # add ( Long ) } but more efficient in that it doesn ' t box the element . <nl> + * Like { @ link # add ( Object ) } but more efficient in that it doesn ' t box the element . <nl> * / <nl> void addLong ( long element ) ; <nl> <nl> / * * <nl> - * Like { @ link # set ( int , Long ) } but more efficient in that it doesn ' t box the element . <nl> + * Like { @ link # set ( int , Object ) } but more efficient in that it doesn ' t box the element . <nl> * / <nl> long setLong ( int index , long element ) ; <nl> <nl> public V setValue ( V value ) { <nl> double getDouble ( int index ) ; <nl> <nl> / * * <nl> - * Like { @ link # add ( Double ) } but more efficient in that it doesn ' t box the element . <nl> + * Like { @ link # add ( Object ) } but more efficient in that it doesn ' t box the element . <nl> * / <nl> void addDouble ( double element ) ; <nl> <nl> / * * <nl> - * Like { @ link # set ( int , Double ) } but more efficient in that it doesn ' t box the element . <nl> + * Like { @ link # set ( int , Object ) } but more efficient in that it doesn ' t box the element . <nl> * / <nl> double setDouble ( int index , double element ) ; <nl> <nl> public V setValue ( V value ) { <nl> float getFloat ( int index ) ; <nl> <nl> / * * <nl> - * Like { @ link # add ( Float ) } but more efficient in that it doesn ' t box the element . <nl> + * Like { @ link # add ( Object ) } but more efficient in that it doesn ' t box the element . <nl> * / <nl> void addFloat ( float element ) ; <nl> <nl> / * * <nl> - * Like { @ link # set ( int , Float ) } but more efficient in that it doesn ' t box the element . <nl> + * Like { @ link # set ( int , Object ) } but more efficient in that it doesn ' t box the element . <nl> * / <nl> float setFloat ( int index , float element ) ; <nl> <nl> mmm a / java / core / src / main / java / com / google / protobuf / Parser . java <nl> ppp b / java / core / src / main / java / com / google / protobuf / Parser . java <nl> <nl> * <nl> * < p > All methods may throw { @ link InvalidProtocolBufferException } . In the event of invalid data , <nl> * like an encoding error , the cause of the thrown exception will be { @ code null } . However , if an <nl> - * I / O problem occurs , an exception is thrown with an { @ link IOException } cause . <nl> + * I / O problem occurs , an exception is thrown with an { @ link java . io . IOException } cause . <nl> * <nl> * @ author liujisi @ google . com ( Pherl Liu ) <nl> * / <nl> mmm a / java / core / src / main / java / com / google / protobuf / TextFormatParseInfoTree . java <nl> ppp b / java / core / src / main / java / com / google / protobuf / TextFormatParseInfoTree . java <nl> <nl> * <nl> * < p > The locations of primary fields values are retrieved by { @ code getLocation } or <nl> * { @ code getLocations } . The locations of sub message values are within nested <nl> - * { @ code TextFormatParseInfoTree } s and are retrieve by { @ getNestedTree } or { code @ getNestedTrees } . <nl> + * { @ code TextFormatParseInfoTree } s and are retrieve by { @ code getNestedTree } or { @ code getNestedTrees } . <nl> * <nl> * < p > The { @ code TextFormatParseInfoTree } is created by a Builder . <nl> * / <nl> public Builder setLocation ( <nl> * Set for a sub message . <nl> * <nl> * < p > A new builder is created for a sub message . The builder that is returned is a new builder . <nl> - * The return is < emph > not < / emph > the invoked { @ code builder . getBuilderForSubMessageField } . <nl> + * The return is < em > not < / em > the invoked { @ code builder . getBuilderForSubMessageField } . <nl> * <nl> * @ param fieldDescriptor the field whose value is the submessage <nl> * @ return a new Builder for the sub message <nl> mmm a / java / pom . xml <nl> ppp b / java / pom . xml <nl> <nl> < id > release < / id > <nl> < build > <nl> < plugins > <nl> + < plugin > <nl> + < groupId > org . apache . maven . plugins < / groupId > <nl> + < artifactId > maven - source - plugin < / artifactId > <nl> + < version > 2 . 2 . 1 < / version > <nl> + < executions > <nl> + < execution > <nl> + < id > attach - sources < / id > <nl> + < goals > <nl> + < goal > jar - no - fork < / goal > <nl> + < / goals > <nl> + < / execution > <nl> + < / executions > <nl> + < / plugin > <nl> + < plugin > <nl> + < groupId > org . apache . maven . plugins < / groupId > <nl> + < artifactId > maven - javadoc - plugin < / artifactId > <nl> + < version > 2 . 9 . 1 < / version > <nl> + < executions > <nl> + < execution > <nl> + < id > attach - javadocs < / id > <nl> + < goals > <nl> + < goal > jar < / goal > <nl> + < / goals > <nl> + < / execution > <nl> + < / executions > <nl> + < / plugin > <nl> < plugin > <nl> < artifactId > maven - gpg - plugin < / artifactId > <nl> < version > 1 . 6 < / version > <nl> | Include javadoc / source in Java release packages . | protocolbuffers/protobuf | fa527024088bd3d8f3deb04aef47b4d0e2c84793 | 2016-07-18T22:59:09Z |
mmm a / Telegram / gyp / telegram_mac . gypi <nl> ppp b / Telegram / gyp / telegram_mac . gypi <nl> <nl> ' - lcrashpad_util ' , <nl> ' / usr / local / macold / lib / libz . a ' , <nl> ' / usr / local / macold / lib / libopenal . a ' , <nl> - ' / usr / local / iconv_old / lib / libiconv . a ' , <nl> - ' / usr / local / ffmpeg_old / lib / libavcodec . a ' , <nl> - ' / usr / local / ffmpeg_old / lib / libavformat . a ' , <nl> - ' / usr / local / ffmpeg_old / lib / libavutil . a ' , <nl> - ' / usr / local / ffmpeg_old / lib / libswscale . a ' , <nl> - ' / usr / local / ffmpeg_old / lib / libswresample . a ' , <nl> + ' / usr / local / macold / lib / libiconv . a ' , <nl> + ' / usr / local / macold / lib / libavcodec . a ' , <nl> + ' / usr / local / macold / lib / libavformat . a ' , <nl> + ' / usr / local / macold / lib / libavutil . a ' , <nl> + ' / usr / local / macold / lib / libswscale . a ' , <nl> + ' / usr / local / macold / lib / libswresample . a ' , <nl> ' / usr / local / macold / lib / libexif . a ' , <nl> ' / usr / local / macold / lib / libc + + . a ' , <nl> ' / usr / local / macold / lib / libc + + abi . a ' , <nl> | Link correct OS X 10 . 6 - 10 . 7 libraries . | telegramdesktop/tdesktop | 5ed698ac69c4bbb0e41e53d2c1a209ffd9a5ec60 | 2017-04-30T16:56:13Z |
mmm a / src / video_core / renderer_opengl / gl_rasterizer . cpp <nl> ppp b / src / video_core / renderer_opengl / gl_rasterizer . cpp <nl> void RasterizerOpenGL : : NotifyPicaRegisterChanged ( u32 id ) { <nl> SyncColorWriteMask ( ) ; <nl> break ; <nl> <nl> + / / Sync GL depth and stencil write mask <nl> + / / ( This is a dedicated combined depth / stencil write - enable register ) <nl> + case PICA_REG_INDEX ( framebuffer . allow_depth_stencil_write ) : <nl> + SyncDepthWriteMask ( ) ; <nl> + SyncStencilWriteMask ( ) ; <nl> + break ; <nl> + <nl> + / / Sync GL color write mask <nl> + / / ( This is a dedicated color write - enable register ) <nl> + case PICA_REG_INDEX ( framebuffer . allow_color_write ) : <nl> + SyncColorWriteMask ( ) ; <nl> + break ; <nl> + <nl> / / Logic op <nl> case PICA_REG_INDEX ( output_merger . logic_op ) : <nl> SyncLogicOp ( ) ; <nl> void RasterizerOpenGL : : SyncLogicOp ( ) { <nl> <nl> void RasterizerOpenGL : : SyncColorWriteMask ( ) { <nl> const auto & regs = Pica : : g_state . regs ; <nl> - state . color_mask . red_enabled = regs . output_merger . red_enable ; <nl> - state . color_mask . green_enabled = regs . output_merger . green_enable ; <nl> - state . color_mask . blue_enabled = regs . output_merger . blue_enable ; <nl> - state . color_mask . alpha_enabled = regs . output_merger . alpha_enable ; <nl> + <nl> + auto IsColorWriteEnabled = [ & ] ( u32 value ) { <nl> + return ( regs . framebuffer . allow_color_write ! = 0 & & value ! = 0 ) ? GL_TRUE : GL_FALSE ; <nl> + } ; <nl> + <nl> + state . color_mask . red_enabled = IsColorWriteEnabled ( regs . output_merger . red_enable ) ; <nl> + state . color_mask . green_enabled = IsColorWriteEnabled ( regs . output_merger . green_enable ) ; <nl> + state . color_mask . blue_enabled = IsColorWriteEnabled ( regs . output_merger . blue_enable ) ; <nl> + state . color_mask . alpha_enabled = IsColorWriteEnabled ( regs . output_merger . alpha_enable ) ; <nl> } <nl> <nl> void RasterizerOpenGL : : SyncStencilWriteMask ( ) { <nl> const auto & regs = Pica : : g_state . regs ; <nl> - state . stencil . write_mask = regs . output_merger . stencil_test . write_mask ; <nl> + state . stencil . write_mask = ( regs . framebuffer . allow_depth_stencil_write ! = 0 ) <nl> + ? static_cast < GLuint > ( regs . output_merger . stencil_test . write_mask ) <nl> + : 0 ; <nl> } <nl> <nl> void RasterizerOpenGL : : SyncDepthWriteMask ( ) { <nl> const auto & regs = Pica : : g_state . regs ; <nl> - state . depth . write_mask = regs . output_merger . depth_write_enable ? GL_TRUE : GL_FALSE ; <nl> + state . depth . write_mask = ( regs . framebuffer . allow_depth_stencil_write ! = 0 & & regs . output_merger . depth_write_enable ) <nl> + ? GL_TRUE <nl> + : GL_FALSE ; <nl> } <nl> <nl> void RasterizerOpenGL : : SyncStencilTest ( ) { <nl> | OpenGL : Respect buffer - write allow registers | yuzu-emu/yuzu | 35a92b40977f9d2ad4f37c0d93c6cd9bbc57d591 | 2016-04-08T20:57:11Z |
mmm a / lib / SIL / SILProfiler . cpp <nl> ppp b / lib / SIL / SILProfiler . cpp <nl> struct CoverageMapping : public ASTWalker { <nl> pushRegion ( E ) ; <nl> } <nl> <nl> - if ( auto * IE = dyn_cast < IfExpr > ( E ) ) { <nl> - CounterExpr & ThenCounter = assignCounter ( IE - > getThenExpr ( ) ) ; <nl> - assignCounter ( IE - > getElseExpr ( ) , <nl> - CounterExpr : : Sub ( getCurrentCounter ( ) , ThenCounter ) ) ; <nl> + / / If there isn ' t an active region , we may be visiting a default <nl> + / / initializer for a function argument . <nl> + if ( ! RegionStack . empty ( ) ) { <nl> + if ( auto * IE = dyn_cast < IfExpr > ( E ) ) { <nl> + CounterExpr & ThenCounter = assignCounter ( IE - > getThenExpr ( ) ) ; <nl> + assignCounter ( IE - > getElseExpr ( ) , <nl> + CounterExpr : : Sub ( getCurrentCounter ( ) , ThenCounter ) ) ; <nl> + } <nl> } <nl> <nl> if ( hasCounter ( E ) & & ! Parent . isNull ( ) ) <nl> new file mode 100644 <nl> index 000000000000 . . e18596fccad7 <nl> mmm / dev / null <nl> ppp b / test / Profiler / coverage_arg_ternary . swift <nl> <nl> + / / RUN : % target - swift - frontend - Xllvm - sil - full - demangle - profile - generate - profile - coverage - mapping - emit - sorted - sil - emit - sil - module - name coverage_arg_ternary % s | % FileCheck % s <nl> + <nl> + var s : String ? <nl> + <nl> + / / CHECK : sil_coverage_map { { . * } } " $ s20coverage_arg_ternary1f0B0ySSSg_tF " <nl> + / / CHECK - NEXT : [ [ @ LINE + 2 ] ] : 43 - > [ [ @ LINE + 2 ] ] : 45 : 0 <nl> + / / CHECK - NEXT : } <nl> + func f ( arg : String ? = s ! = nil ? s : nil ) { } <nl> | Merge pull request from vedantk / master | apple/swift | 31d63a384c33cda668560722a1ba8cee9831c532 | 2020-02-25T02:05:19Z |
mmm a / src / js - framework / lib / vm / __test__ / directive . js <nl> ppp b / src / js - framework / lib / vm / __test__ / directive . js <nl> describe ( ' bind events ' , ( ) = > { <nl> manager = null <nl> } ) <nl> / / - bind method to eventManager <nl> - it ( ' add event to manager ' , ( ) = > { <nl> + it ( ' add event to manager by type ' , ( ) = > { <nl> vm . _bindEvents ( el , { click : ' foo ' } ) <nl> expect ( manager . targets . length ) . equal ( 1 ) <nl> var target = manager . targets [ 0 ] <nl> describe ( ' bind events ' , ( ) = > { <nl> expect ( el . event . length ) . equal ( 1 ) <nl> expect ( el . event [ 0 ] ) . equal ( ' click ' ) <nl> } ) <nl> + / / - bind method to eventManager <nl> + it ( ' add event to manager by handler ' , ( ) = > { <nl> + vm . _bindEvents ( el , { click : function ( $ event ) { <nl> + this . foo ( this . a , $ event ) <nl> + } } ) <nl> + expect ( manager . targets . length ) . equal ( 1 ) <nl> + var target = manager . targets [ 0 ] <nl> + expect ( target ) . a ( ' object ' ) <nl> + expect ( target . el ) . equal ( el ) <nl> + expect ( target . events ) . a ( ' object ' ) <nl> + expect ( target . events . click ) . a ( ' function ' ) <nl> + expect ( el . event . length ) . equal ( 1 ) <nl> + expect ( el . event [ 0 ] ) . equal ( ' click ' ) <nl> + } ) <nl> / / - fireEvent to call method <nl> / / - with right event info <nl> - it ( ' fire event from manager ' , ( ) = > { <nl> + it ( ' fire event from manager by type ' , ( ) = > { <nl> var e = { } <nl> vm . _bindEvents ( el , { click : ' foo ' } ) <nl> manager . fire ( el , ' click ' , e ) <nl> describe ( ' bind events ' , ( ) = > { <nl> expect ( cb ) . calledOn ( vm ) <nl> expect ( cb ) . calledWith ( e ) <nl> } ) <nl> + / / - fireEvent to call method <nl> + / / - with right event info <nl> + it ( ' fire event from manager by handler ' , ( ) = > { <nl> + var e = { } <nl> + vm . _bindEvents ( el , { click : function ( $ event ) { <nl> + this . foo ( this . a , $ event ) <nl> + } } ) <nl> + manager . fire ( el , ' click ' , e ) <nl> + expect ( cb ) . calledOnce <nl> + expect ( cb ) . calledOn ( vm ) <nl> + expect ( cb ) . calledWith ( 1 , e ) <nl> + } ) <nl> } ) <nl> <nl> / / exports . _bindSubVm ( subVm , template ) <nl> mmm a / src / js - framework / lib / vm / directive . js <nl> ppp b / src / js - framework / lib / vm / directive . js <nl> export function _bindEvents ( el , events ) { <nl> let i = keys . length <nl> while ( i - - ) { <nl> const key = keys [ i ] <nl> - const handlerName = events [ key ] <nl> - this . _setEvent ( el , key , this [ handlerName ] ) <nl> + let handler = events [ key ] <nl> + if ( typeof handler = = = ' string ' ) { <nl> + handler = this [ handler ] <nl> + } <nl> + this . _setEvent ( el , key , handler ) <nl> } <nl> } <nl> <nl> | Merge pull request from alibaba / jsfm - evt - ext | apache/incubator-weex | d7e22cc54da33c2c60e701df8d3f43dde9c05999 | 2016-04-17T10:34:01Z |
mmm a / src / json - parser . h <nl> ppp b / src / json - parser . h <nl> class JsonParser BASE_EMBEDDED { <nl> inline Zone * zone ( ) const { return zone_ ; } <nl> <nl> static const int kInitialSpecialStringLength = 1024 ; <nl> + static const int kPretenureTreshold = 100 * 1024 ; <nl> <nl> <nl> private : <nl> class JsonParser BASE_EMBEDDED { <nl> int source_length_ ; <nl> Handle < SeqAsciiString > seq_source_ ; <nl> <nl> + PretenureFlag pretenure_ ; <nl> Isolate * isolate_ ; <nl> Factory * factory_ ; <nl> Handle < JSFunction > object_constructor_ ; <nl> Handle < Object > JsonParser < seq_ascii > : : ParseJson ( Handle < String > source , <nl> FlattenString ( source ) ; <nl> source_ = source ; <nl> source_length_ = source_ - > length ( ) ; <nl> + pretenure_ = ( source_length_ > = kPretenureTreshold ) ? TENURED : NOT_TENURED ; <nl> <nl> / / Optimized fast case where we only have ASCII characters . <nl> if ( seq_ascii ) { <nl> template < bool seq_ascii > <nl> Handle < Object > JsonParser < seq_ascii > : : ParseJsonObject ( ) { <nl> Handle < Object > prototype ; <nl> Handle < JSObject > json_object = <nl> - factory ( ) - > NewJSObject ( object_constructor ( ) ) ; <nl> + factory ( ) - > NewJSObject ( object_constructor ( ) , pretenure_ ) ; <nl> ASSERT_EQ ( c0_ , ' { ' ) ; <nl> <nl> AdvanceSkipWhitespace ( ) ; <nl> Handle < Object > JsonParser < seq_ascii > : : ParseJsonArray ( ) { <nl> AdvanceSkipWhitespace ( ) ; <nl> / / Allocate a fixed array with all the elements . <nl> Handle < FixedArray > fast_elements = <nl> - factory ( ) - > NewFixedArray ( elements . length ( ) ) ; <nl> + factory ( ) - > NewFixedArray ( elements . length ( ) , pretenure_ ) ; <nl> for ( int i = 0 , n = elements . length ( ) ; i < n ; i + + ) { <nl> fast_elements - > set ( i , * elements [ i ] ) ; <nl> } <nl> - return factory ( ) - > NewJSArrayWithElements ( fast_elements ) ; <nl> + return factory ( ) - > NewJSArrayWithElements ( <nl> + fast_elements , FAST_ELEMENTS , pretenure_ ) ; <nl> } <nl> <nl> <nl> Handle < Object > JsonParser < seq_ascii > : : ParseJsonNumber ( ) { <nl> buffer . Dispose ( ) ; <nl> } <nl> SkipWhitespace ( ) ; <nl> - return factory ( ) - > NewNumber ( number ) ; <nl> + return factory ( ) - > NewNumber ( number , pretenure_ ) ; <nl> } <nl> <nl> <nl> inline void SeqStringSet ( Handle < SeqAsciiString > seq_str , int i , uc32 c ) { <nl> } <nl> <nl> template < typename StringType > <nl> - inline Handle < StringType > NewRawString ( Factory * factory , int length ) ; <nl> + inline Handle < StringType > NewRawString ( Factory * factory , <nl> + int length , <nl> + PretenureFlag pretenure ) ; <nl> <nl> template < > <nl> - inline Handle < SeqTwoByteString > NewRawString ( Factory * factory , int length ) { <nl> - return factory - > NewRawTwoByteString ( length , NOT_TENURED ) ; <nl> + inline Handle < SeqTwoByteString > NewRawString ( Factory * factory , <nl> + int length , <nl> + PretenureFlag pretenure ) { <nl> + return factory - > NewRawTwoByteString ( length , pretenure ) ; <nl> } <nl> <nl> template < > <nl> - inline Handle < SeqAsciiString > NewRawString ( Factory * factory , int length ) { <nl> - return factory - > NewRawAsciiString ( length , NOT_TENURED ) ; <nl> + inline Handle < SeqAsciiString > NewRawString ( Factory * factory , <nl> + int length , <nl> + PretenureFlag pretenure ) { <nl> + return factory - > NewRawAsciiString ( length , pretenure ) ; <nl> } <nl> <nl> <nl> Handle < String > JsonParser < seq_ascii > : : SlowScanJsonString ( <nl> int count = end - start ; <nl> int max_length = count + source_length_ - position_ ; <nl> int length = Min ( max_length , Max ( kInitialSpecialStringLength , 2 * count ) ) ; <nl> - Handle < StringType > seq_str = NewRawString < StringType > ( factory ( ) , length ) ; <nl> + Handle < StringType > seq_str = <nl> + NewRawString < StringType > ( factory ( ) , length , pretenure_ ) ; <nl> / / Copy prefix into seq_str . <nl> SinkChar * dest = seq_str - > GetChars ( ) ; <nl> String : : WriteToFlat ( * prefix , dest , start , end ) ; <nl> Handle < String > JsonParser < seq_ascii > : : ScanJsonString ( ) { <nl> Handle < String > result ; <nl> if ( seq_ascii & & is_symbol ) { <nl> result = factory ( ) - > LookupAsciiSymbol ( seq_source_ , <nl> - beg_pos , <nl> - length ) ; <nl> + beg_pos , <nl> + length ) ; <nl> } else { <nl> - result = factory ( ) - > NewRawAsciiString ( length ) ; <nl> + result = factory ( ) - > NewRawAsciiString ( length , pretenure_ ) ; <nl> char * dest = SeqAsciiString : : cast ( * result ) - > GetChars ( ) ; <nl> String : : WriteToFlat ( * source_ , dest , beg_pos , position_ ) ; <nl> } <nl> | Pretenure JSON graph if the input string is larger than 100 * 1024 chars . | v8/v8 | 362e8cb02a07d7abf8ac5daf6376bd8c3b97ddb0 | 2012-10-23T08:06:28Z |
mmm a / Tests / EndToEndTests / ParallelTraining / AsynchronousSGD / testcases . yml <nl> ppp b / Tests / EndToEndTests / ParallelTraining / AsynchronousSGD / testcases . yml <nl> testCases : <nl> patterns : <nl> - ^ MPI Rank { { integer } } <nl> - Finished Epoch [ { { integer } } of { { integer } } ] <nl> - - CE = { { float , tolerance = 1 } } <nl> - - Err = { { float , tolerance = 1 } } <nl> + - CE = { { float , tolerance = 2 } } <nl> + - Err = { { float , tolerance = 2 } } <nl> <nl> Per - minibatch training results must match for each MPI Rank : <nl> patterns : <nl> - ^ MPI Rank { { integer } } <nl> - Epoch [ { { integer } } of { { integer } } ] - Minibatch [ { { integer } } - { { integer } } <nl> - " * { { integer } } ; " <nl> - - CE = { { float , tolerance = 1 } } <nl> - - Err = { { float , tolerance = 1 } } <nl> + - CE = { { float , tolerance = 2 } } <nl> + - Err = { { float , tolerance = 2 } } <nl> <nl> DataParallelASGD training parameters must match for each MPI Rank : <nl> patterns : <nl> | broaden fault tolerance for e2etest | microsoft/CNTK | 720c1f322fcb84f8f5bccbb9e76531315da7ff31 | 2017-04-18T12:01:31Z |
mmm a / benchmark / README . md <nl> ppp b / benchmark / README . md <nl> The following build options are available : <nl> <nl> The following build targets are available : <nl> <nl> - 1 . ` swift - benchmark - macosx - x86_64 ` <nl> - 2 . ` swift - benchmark - iphoneos - arm64 ` <nl> - 3 . ` swift - benchmark - iphoneos - armv7 ` <nl> - 4 . ` swift - benchmark - appletvos - arm64 ` <nl> - 5 . ` swift - benchmark - watchos - armv7k ` <nl> + * ` swift - benchmark - macosx - x86_64 ` <nl> + * ` swift - benchmark - iphoneos - arm64 ` <nl> + * ` swift - benchmark - iphoneos - armv7 ` <nl> + * ` swift - benchmark - appletvos - arm64 ` <nl> + * ` swift - benchmark - watchos - armv7k ` <nl> <nl> Build steps ( with example options ) : <nl> <nl> - 1 . ` $ cd benchmark ` <nl> - 2 . ` $ mkdir build ` <nl> - 3 . ` $ cd build ` <nl> - 4 . ` $ cmake . . / benchmark - G Ninja - DSWIFT_EXEC = [ path to built swiftc ] ` <nl> - 5 . ` $ ninja swift - benchmark - macosx - x86_64 ` <nl> + 1 . ` $ mkdir build ; cd build ` <nl> + 2 . ` $ cmake [ path to swift src ] / benchmark - G Ninja - DSWIFT_EXEC = [ path to built swiftc ] ` <nl> + 3 . ` $ ninja swift - benchmark - macosx - x86_64 ` <nl> <nl> Benchmark binaries are placed in ` bin ` . <nl> <nl> relative to the benchmark binary at the time it was executed <nl> For example , to benchmark against a locally built ` swiftc ` , including <nl> any standard library changes in that build , you might configure using : <nl> <nl> - cmake . . / benchmark - G Ninja - DSWIFT_EXEC = < src > / swift / build / swift - macosx - x86_64 / bin / swiftc <nl> + cmake < src > / benchmark - G Ninja - DSWIFT_EXEC = < build > / swift - macosx - x86_64 / bin / swiftc <nl> ninja swift - benchmark - iphoneos - arm64 <nl> <nl> To build against the installed Xcode , simply omit SWIFT_EXEC : <nl> <nl> - cmake . . / benchmark - G Ninja <nl> + cmake < src > / benchmark - G Ninja <nl> ninja swift - benchmark - iphoneos - arm64 <nl> <nl> In both examples above , to run the benchmarks on a device , the dynamic <nl> relative to ` swiftc ` . To benchmark against the target machine ' s <nl> installed libraries instead , enable <nl> ` SWIFT_BENCHMARK_USE_OS_LIBRARIES ` . <nl> <nl> - cmake . . / benchmark - G Ninja - DSWIFT_BENCHMARK_USE_OS_LIBRARIES = ON <nl> + cmake < src > / benchmark - G Ninja - DSWIFT_BENCHMARK_USE_OS_LIBRARIES = ON <nl> ninja swift - benchmark - iphoneos - arm64 <nl> <nl> This will reflect the performance of the Swift standard library <nl> | Merge pull request from atrick / fix - bench - docs | apple/swift | b7acc6d2ef4b7c26d423eba20ce706df5bd04537 | 2019-08-25T01:15:12Z |
mmm a / src / compiler / wasm - compiler . cc <nl> ppp b / src / compiler / wasm - compiler . cc <nl> Node * WasmGraphBuilder : : Simd8x16ShuffleOp ( const uint8_t shuffle [ 16 ] , <nl> V ( I32AtomicCompareExchange8U , CompareExchange , Uint8 ) \ <nl> V ( I32AtomicCompareExchange16U , CompareExchange , Uint16 ) <nl> <nl> - Node * WasmGraphBuilder : : AtomicOp ( wasm : : WasmOpcode opcode , <nl> - const NodeVector & inputs , <nl> + Node * WasmGraphBuilder : : AtomicOp ( wasm : : WasmOpcode opcode , Node * const * inputs , <nl> wasm : : WasmCodePosition position ) { <nl> Node * node ; <nl> switch ( opcode ) { <nl> mmm a / src / compiler / wasm - compiler . h <nl> ppp b / src / compiler / wasm - compiler . h <nl> class WasmGraphBuilder { <nl> <nl> Node * Simd8x16ShuffleOp ( const uint8_t shuffle [ 16 ] , Node * const * inputs ) ; <nl> <nl> - Node * AtomicOp ( wasm : : WasmOpcode opcode , const NodeVector & inputs , <nl> + Node * AtomicOp ( wasm : : WasmOpcode opcode , Node * const * inputs , <nl> wasm : : WasmCodePosition position ) ; <nl> <nl> bool has_simd ( ) const { return has_simd_ ; } <nl> mmm a / src / wasm / function - body - decoder - impl . h <nl> ppp b / src / wasm / function - body - decoder - impl . h <nl> <nl> # ifndef V8_WASM_FUNCTION_BODY_DECODER_IMPL_H_ <nl> # define V8_WASM_FUNCTION_BODY_DECODER_IMPL_H_ <nl> <nl> + / / Do only include this header for implementing new Interface of the <nl> + / / WasmFullDecoder . <nl> + <nl> + # include " src / bit - vector . h " <nl> # include " src / wasm / decoder . h " <nl> + # include " src / wasm / function - body - decoder . h " <nl> + # include " src / wasm / wasm - limits . h " <nl> + # include " src / wasm / wasm - module . h " <nl> # include " src / wasm / wasm - opcodes . h " <nl> <nl> namespace v8 { <nl> namespace wasm { <nl> struct WasmGlobal ; <nl> struct WasmException ; <nl> <nl> + # if DEBUG <nl> + # define TRACE ( . . . ) \ <nl> + do { \ <nl> + if ( FLAG_trace_wasm_decoder ) PrintF ( __VA_ARGS__ ) ; \ <nl> + } while ( false ) <nl> + # else <nl> + # define TRACE ( . . . ) <nl> + # endif <nl> + <nl> + / / Return the evaluation of ` condition ` if validate = = true , DCHECK <nl> + / / and always return true otherwise . <nl> + # define VALIDATE ( condition ) \ <nl> + ( validate ? ( condition ) : [ & ] { \ <nl> + DCHECK ( condition ) ; \ <nl> + return true ; \ <nl> + } ( ) ) <nl> + <nl> + / / Return the evaluation of ` condition ` if validate = = true , DCHECK that it ' s <nl> + / / false and always return false otherwise . <nl> + # define CHECK_ERROR ( condition ) \ <nl> + ( validate ? ( condition ) : [ & ] { \ <nl> + DCHECK ( ! ( condition ) ) ; \ <nl> + return false ; \ <nl> + } ( ) ) <nl> + <nl> / / Use this macro to check a condition if checked = = true , and DCHECK the <nl> / / condition otherwise . <nl> + / / TODO ( clemensh ) : Rename all " checked " to " validate " and replace <nl> + / / " CHECKED_COND " with " CHECK_ERROR " . <nl> # define CHECKED_COND ( cond ) \ <nl> ( checked ? ( cond ) : ( [ & ] { \ <nl> DCHECK ( cond ) ; \ <nl> return true ; \ <nl> } ) ( ) ) <nl> <nl> + # define CHECK_PROTOTYPE_OPCODE ( flag ) \ <nl> + if ( this - > module_ ! = nullptr & & this - > module_ - > is_asm_js ( ) ) { \ <nl> + this - > error ( " Opcode not supported for asmjs modules " ) ; \ <nl> + } \ <nl> + if ( ! FLAG_experimental_wasm_ # # flag ) { \ <nl> + this - > error ( " Invalid opcode ( enable with - - experimental - wasm - " # flag " ) " ) ; \ <nl> + break ; \ <nl> + } <nl> + <nl> + # define OPCODE_ERROR ( opcode , message ) \ <nl> + ( this - > errorf ( this - > pc_ , " % s : % s " , WasmOpcodes : : OpcodeName ( opcode ) , \ <nl> + ( message ) ) ) <nl> + <nl> + template < typename T > <nl> + Vector < T > vec2vec ( std : : vector < T > & vec ) { <nl> + return Vector < T > ( vec . data ( ) , vec . size ( ) ) ; <nl> + } <nl> + <nl> / / Helpers for decoding different kinds of operands which follow bytecodes . <nl> template < bool checked > <nl> struct LocalIndexOperand { <nl> struct BlockTypeOperand { <nl> return false ; <nl> } <nl> } <nl> + <nl> ValueType read_entry ( unsigned index ) { <nl> DCHECK_LT ( index , arity ) ; <nl> ValueType result ; <nl> - CHECK ( decode_local_type ( types [ index ] , & result ) ) ; <nl> + bool success = decode_local_type ( types [ index ] , & result ) ; <nl> + DCHECK ( success ) ; <nl> + USE ( success ) ; <nl> return result ; <nl> } <nl> } ; <nl> <nl> - struct Control ; <nl> template < bool checked > <nl> struct BreakDepthOperand { <nl> uint32_t depth ; <nl> - Control * target = nullptr ; <nl> unsigned length ; <nl> inline BreakDepthOperand ( Decoder * decoder , const byte * pc ) { <nl> depth = decoder - > read_u32v < checked > ( pc + 1 , & length , " break depth " ) ; <nl> class BranchTableIterator { <nl> } <nl> const byte * pc ( ) { return pc_ ; } <nl> <nl> - BranchTableIterator ( Decoder * decoder , BranchTableOperand < checked > & operand ) <nl> + BranchTableIterator ( Decoder * decoder , <nl> + const BranchTableOperand < checked > & operand ) <nl> : decoder_ ( decoder ) , <nl> start_ ( operand . start ) , <nl> pc_ ( operand . table ) , <nl> struct Simd8x16ShuffleOperand { <nl> } <nl> } ; <nl> <nl> + / / An entry on the value stack . <nl> + template < typename Interface > <nl> + struct AbstractValue { <nl> + const byte * pc ; <nl> + ValueType type ; <nl> + typename Interface : : IValue interface_data ; <nl> + <nl> + / / Named constructors . <nl> + static AbstractValue Unreachable ( const byte * pc ) { <nl> + return { pc , kWasmVar , Interface : : IValue : : Unreachable ( ) } ; <nl> + } <nl> + <nl> + static AbstractValue New ( const byte * pc , ValueType type ) { <nl> + return { pc , type , Interface : : IValue : : New ( ) } ; <nl> + } <nl> + } ; <nl> + <nl> + template < typename Interface > <nl> + struct AbstractMerge { <nl> + uint32_t arity ; <nl> + union { <nl> + AbstractValue < Interface > * array ; <nl> + AbstractValue < Interface > first ; <nl> + } vals ; / / Either multiple values or a single value . <nl> + <nl> + AbstractValue < Interface > & operator [ ] ( size_t i ) { <nl> + DCHECK_GT ( arity , i ) ; <nl> + return arity = = 1 ? vals . first : vals . array [ i ] ; <nl> + } <nl> + } ; <nl> + <nl> + enum ControlKind { <nl> + kControlIf , <nl> + kControlIfElse , <nl> + kControlBlock , <nl> + kControlLoop , <nl> + kControlTry , <nl> + kControlTryCatch <nl> + } ; <nl> + <nl> + / / An entry on the control stack ( i . e . if , block , loop , or try ) . <nl> + template < typename Interface > <nl> + struct AbstractControl { <nl> + const byte * pc ; <nl> + ControlKind kind ; <nl> + size_t stack_depth ; / / stack height at the beginning of the construct . <nl> + typename Interface : : IControl interface_data ; <nl> + bool unreachable ; / / The current block has been ended . <nl> + <nl> + / / Values merged into the end of this control construct . <nl> + AbstractMerge < Interface > merge ; <nl> + <nl> + inline bool is_if ( ) const { return is_onearmed_if ( ) | | is_if_else ( ) ; } <nl> + inline bool is_onearmed_if ( ) const { return kind = = kControlIf ; } <nl> + inline bool is_if_else ( ) const { return kind = = kControlIfElse ; } <nl> + inline bool is_block ( ) const { return kind = = kControlBlock ; } <nl> + inline bool is_loop ( ) const { return kind = = kControlLoop ; } <nl> + inline bool is_try ( ) const { return is_incomplete_try ( ) | | is_try_catch ( ) ; } <nl> + inline bool is_incomplete_try ( ) const { return kind = = kControlTry ; } <nl> + inline bool is_try_catch ( ) const { return kind = = kControlTryCatch ; } <nl> + <nl> + / / Named constructors . <nl> + static AbstractControl Block ( const byte * pc , size_t stack_depth ) { <nl> + return { pc , kControlBlock , stack_depth , Interface : : IControl : : Block ( ) , false , <nl> + { } } ; <nl> + } <nl> + <nl> + static AbstractControl If ( const byte * pc , size_t stack_depth ) { <nl> + return { pc , kControlIf , stack_depth , Interface : : IControl : : If ( ) , false , { } } ; <nl> + } <nl> + <nl> + static AbstractControl Loop ( const byte * pc , size_t stack_depth ) { <nl> + return { pc , kControlLoop , stack_depth , Interface : : IControl : : Loop ( ) , false , <nl> + { } } ; <nl> + } <nl> + <nl> + static AbstractControl Try ( const byte * pc , size_t stack_depth ) { <nl> + return { pc , kControlTry , stack_depth , Interface : : IControl : : Try ( ) , <nl> + false , { } } ; <nl> + } <nl> + } ; <nl> + <nl> + / / This is the list of callback functions that an interface for the <nl> + / / WasmFullDecoder should implement . <nl> + / / F ( Name , args . . . ) <nl> + # define INTERFACE_FUNCTIONS ( F ) \ <nl> + / * General : * / \ <nl> + F ( StartFunction ) \ <nl> + F ( StartFunctionBody , Control * block ) \ <nl> + F ( FinishFunction ) \ <nl> + / * Control : * / \ <nl> + F ( Block , Control * block ) \ <nl> + F ( Loop , Control * block ) \ <nl> + F ( Try , Control * block ) \ <nl> + F ( If , const Value & cond , Control * if_block ) \ <nl> + F ( FallThruTo , Control * c ) \ <nl> + F ( PopControl , const Control & block ) \ <nl> + F ( EndControl , Control * block ) \ <nl> + / * Instructions : * / \ <nl> + F ( UnOp , WasmOpcode opcode , FunctionSig * , const Value & value , Value * result ) \ <nl> + F ( BinOp , WasmOpcode opcode , FunctionSig * , const Value & lhs , \ <nl> + const Value & rhs , Value * result ) \ <nl> + F ( I32Const , Value * result , int32_t value ) \ <nl> + F ( I64Const , Value * result , int64_t value ) \ <nl> + F ( F32Const , Value * result , float value ) \ <nl> + F ( F64Const , Value * result , double value ) \ <nl> + F ( DoReturn , Vector < Value > values ) \ <nl> + F ( GetLocal , Value * result , const LocalIndexOperand < validate > & operand ) \ <nl> + F ( SetLocal , const Value & value , const LocalIndexOperand < validate > & operand ) \ <nl> + F ( TeeLocal , const Value & value , Value * result , \ <nl> + const LocalIndexOperand < validate > & operand ) \ <nl> + F ( GetGlobal , Value * result , const GlobalIndexOperand < validate > & operand ) \ <nl> + F ( SetGlobal , const Value & value , \ <nl> + const GlobalIndexOperand < validate > & operand ) \ <nl> + F ( Unreachable ) \ <nl> + F ( Select , const Value & cond , const Value & fval , const Value & tval , \ <nl> + Value * result ) \ <nl> + F ( BreakTo , Control * block ) \ <nl> + F ( BrIf , const Value & cond , Control * block ) \ <nl> + F ( BrTable , const BranchTableOperand < validate > & operand , const Value & key ) \ <nl> + F ( Else , Control * if_block ) \ <nl> + F ( LoadMem , ValueType type , MachineType mem_type , \ <nl> + const MemoryAccessOperand < validate > & operand , const Value & index , \ <nl> + Value * result ) \ <nl> + F ( StoreMem , ValueType type , MachineType mem_type , \ <nl> + const MemoryAccessOperand < validate > & operand , const Value & index , \ <nl> + const Value & value ) \ <nl> + F ( CurrentMemoryPages , Value * result ) \ <nl> + F ( GrowMemory , const Value & value , Value * result ) \ <nl> + F ( CallDirect , const CallFunctionOperand < validate > & operand , \ <nl> + const Value args [ ] , Value returns [ ] ) \ <nl> + F ( CallIndirect , const Value & index , \ <nl> + const CallIndirectOperand < validate > & operand , const Value args [ ] , \ <nl> + Value returns [ ] ) \ <nl> + F ( SimdOp , WasmOpcode opcode , Vector < Value > args , Value * result ) \ <nl> + F ( SimdLaneOp , WasmOpcode opcode , const SimdLaneOperand < validate > & operand , \ <nl> + const Vector < Value > inputs , Value * result ) \ <nl> + F ( SimdShiftOp , WasmOpcode opcode , const SimdShiftOperand < validate > & operand , \ <nl> + const Value & input , Value * result ) \ <nl> + F ( Simd8x16ShuffleOp , const Simd8x16ShuffleOperand < validate > & operand , \ <nl> + const Value & input0 , const Value & input1 , Value * result ) \ <nl> + F ( Throw , const ExceptionIndexOperand < validate > & ) \ <nl> + F ( Catch , const ExceptionIndexOperand < validate > & operand , Control * block ) \ <nl> + F ( AtomicOp , WasmOpcode opcode , Vector < Value > args , Value * result ) <nl> + <nl> + / / Generic Wasm bytecode decoder with utilities for decoding operands , <nl> + / / lengths , etc . <nl> + template < bool validate > <nl> + class WasmDecoder : public Decoder { <nl> + public : <nl> + WasmDecoder ( const WasmModule * module , FunctionSig * sig , const byte * start , <nl> + const byte * end , uint32_t buffer_offset = 0 ) <nl> + : Decoder ( start , end , buffer_offset ) , <nl> + module_ ( module ) , <nl> + sig_ ( sig ) , <nl> + local_types_ ( nullptr ) { } <nl> + const WasmModule * module_ ; <nl> + FunctionSig * sig_ ; <nl> + <nl> + ZoneVector < ValueType > * local_types_ ; <nl> + <nl> + size_t total_locals ( ) const { <nl> + return local_types_ = = nullptr ? 0 : local_types_ - > size ( ) ; <nl> + } <nl> + <nl> + static bool DecodeLocals ( Decoder * decoder , const FunctionSig * sig , <nl> + ZoneVector < ValueType > * type_list ) { <nl> + DCHECK_NOT_NULL ( type_list ) ; <nl> + DCHECK_EQ ( 0 , type_list - > size ( ) ) ; <nl> + / / Initialize from signature . <nl> + if ( sig ! = nullptr ) { <nl> + type_list - > assign ( sig - > parameters ( ) . begin ( ) , sig - > parameters ( ) . end ( ) ) ; <nl> + } <nl> + / / Decode local declarations , if any . <nl> + uint32_t entries = decoder - > consume_u32v ( " local decls count " ) ; <nl> + if ( decoder - > failed ( ) ) return false ; <nl> + <nl> + TRACE ( " local decls count : % u \ n " , entries ) ; <nl> + while ( entries - - > 0 & & decoder - > ok ( ) & & decoder - > more ( ) ) { <nl> + uint32_t count = decoder - > consume_u32v ( " local count " ) ; <nl> + if ( decoder - > failed ( ) ) return false ; <nl> + <nl> + if ( ( count + type_list - > size ( ) ) > kV8MaxWasmFunctionLocals ) { <nl> + decoder - > error ( decoder - > pc ( ) - 1 , " local count too large " ) ; <nl> + return false ; <nl> + } <nl> + byte code = decoder - > consume_u8 ( " local type " ) ; <nl> + if ( decoder - > failed ( ) ) return false ; <nl> + <nl> + ValueType type ; <nl> + switch ( code ) { <nl> + case kLocalI32 : <nl> + type = kWasmI32 ; <nl> + break ; <nl> + case kLocalI64 : <nl> + type = kWasmI64 ; <nl> + break ; <nl> + case kLocalF32 : <nl> + type = kWasmF32 ; <nl> + break ; <nl> + case kLocalF64 : <nl> + type = kWasmF64 ; <nl> + break ; <nl> + case kLocalS128 : <nl> + type = kWasmS128 ; <nl> + break ; <nl> + default : <nl> + decoder - > error ( decoder - > pc ( ) - 1 , " invalid local type " ) ; <nl> + return false ; <nl> + } <nl> + type_list - > insert ( type_list - > end ( ) , count , type ) ; <nl> + } <nl> + DCHECK ( decoder - > ok ( ) ) ; <nl> + return true ; <nl> + } <nl> + <nl> + static BitVector * AnalyzeLoopAssignment ( Decoder * decoder , const byte * pc , <nl> + int locals_count , Zone * zone ) { <nl> + if ( pc > = decoder - > end ( ) ) return nullptr ; <nl> + if ( * pc ! = kExprLoop ) return nullptr ; <nl> + <nl> + BitVector * assigned = new ( zone ) BitVector ( locals_count , zone ) ; <nl> + int depth = 0 ; <nl> + / / Iteratively process all AST nodes nested inside the loop . <nl> + while ( pc < decoder - > end ( ) & & decoder - > ok ( ) ) { <nl> + WasmOpcode opcode = static_cast < WasmOpcode > ( * pc ) ; <nl> + unsigned length = 1 ; <nl> + switch ( opcode ) { <nl> + case kExprLoop : <nl> + case kExprIf : <nl> + case kExprBlock : <nl> + case kExprTry : <nl> + length = OpcodeLength ( decoder , pc ) ; <nl> + depth + + ; <nl> + break ; <nl> + case kExprSetLocal : / / fallthru <nl> + case kExprTeeLocal : { <nl> + LocalIndexOperand < validate > operand ( decoder , pc ) ; <nl> + if ( assigned - > length ( ) > 0 & & <nl> + operand . index < static_cast < uint32_t > ( assigned - > length ( ) ) ) { <nl> + / / Unverified code might have an out - of - bounds index . <nl> + assigned - > Add ( operand . index ) ; <nl> + } <nl> + length = 1 + operand . length ; <nl> + break ; <nl> + } <nl> + case kExprEnd : <nl> + depth - - ; <nl> + break ; <nl> + default : <nl> + length = OpcodeLength ( decoder , pc ) ; <nl> + break ; <nl> + } <nl> + if ( depth < = 0 ) break ; <nl> + pc + = length ; <nl> + } <nl> + return decoder - > ok ( ) ? assigned : nullptr ; <nl> + } <nl> + <nl> + inline bool Validate ( const byte * pc , LocalIndexOperand < validate > & operand ) { <nl> + if ( VALIDATE ( operand . index < total_locals ( ) ) ) { <nl> + if ( local_types_ ) { <nl> + operand . type = local_types_ - > at ( operand . index ) ; <nl> + } else { <nl> + operand . type = kWasmStmt ; <nl> + } <nl> + return true ; <nl> + } <nl> + errorf ( pc + 1 , " invalid local index : % u " , operand . index ) ; <nl> + return false ; <nl> + } <nl> + <nl> + inline bool Validate ( const byte * pc , <nl> + ExceptionIndexOperand < validate > & operand ) { <nl> + if ( module_ ! = nullptr & & operand . index < module_ - > exceptions . size ( ) ) { <nl> + operand . exception = & module_ - > exceptions [ operand . index ] ; <nl> + return true ; <nl> + } <nl> + errorf ( pc + 1 , " Invalid exception index : % u " , operand . index ) ; <nl> + return false ; <nl> + } <nl> + <nl> + inline bool Validate ( const byte * pc , GlobalIndexOperand < validate > & operand ) { <nl> + if ( VALIDATE ( module_ ! = nullptr & & <nl> + operand . index < module_ - > globals . size ( ) ) ) { <nl> + operand . global = & module_ - > globals [ operand . index ] ; <nl> + operand . type = operand . global - > type ; <nl> + return true ; <nl> + } <nl> + errorf ( pc + 1 , " invalid global index : % u " , operand . index ) ; <nl> + return false ; <nl> + } <nl> + <nl> + inline bool Complete ( const byte * pc , CallFunctionOperand < validate > & operand ) { <nl> + if ( VALIDATE ( module_ ! = nullptr & & <nl> + operand . index < module_ - > functions . size ( ) ) ) { <nl> + operand . sig = module_ - > functions [ operand . index ] . sig ; <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + inline bool Validate ( const byte * pc , CallFunctionOperand < validate > & operand ) { <nl> + if ( Complete ( pc , operand ) ) { <nl> + return true ; <nl> + } <nl> + errorf ( pc + 1 , " invalid function index : % u " , operand . index ) ; <nl> + return false ; <nl> + } <nl> + <nl> + inline bool Complete ( const byte * pc , CallIndirectOperand < validate > & operand ) { <nl> + if ( VALIDATE ( module_ ! = nullptr & & <nl> + operand . index < module_ - > signatures . size ( ) ) ) { <nl> + operand . sig = module_ - > signatures [ operand . index ] ; <nl> + return true ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> + inline bool Validate ( const byte * pc , CallIndirectOperand < validate > & operand ) { <nl> + if ( CHECK_ERROR ( module_ = = nullptr | | module_ - > function_tables . empty ( ) ) ) { <nl> + error ( " function table has to exist to execute call_indirect " ) ; <nl> + return false ; <nl> + } <nl> + if ( Complete ( pc , operand ) ) { <nl> + return true ; <nl> + } <nl> + errorf ( pc + 1 , " invalid signature index : # % u " , operand . index ) ; <nl> + return false ; <nl> + } <nl> + <nl> + inline bool Validate ( const byte * pc , BreakDepthOperand < validate > & operand , <nl> + size_t control_depth ) { <nl> + if ( VALIDATE ( operand . depth < control_depth ) ) { <nl> + return true ; <nl> + } <nl> + errorf ( pc + 1 , " invalid break depth : % u " , operand . depth ) ; <nl> + return false ; <nl> + } <nl> + <nl> + bool Validate ( const byte * pc , BranchTableOperand < validate > & operand , <nl> + size_t block_depth ) { <nl> + if ( CHECK_ERROR ( operand . table_count > = kV8MaxWasmFunctionSize ) ) { <nl> + errorf ( pc + 1 , " invalid table count ( > max function size ) : % u " , <nl> + operand . table_count ) ; <nl> + return false ; <nl> + } <nl> + return checkAvailable ( operand . table_count ) ; <nl> + } <nl> + <nl> + inline bool Validate ( const byte * pc , WasmOpcode opcode , <nl> + SimdLaneOperand < validate > & operand ) { <nl> + uint8_t num_lanes = 0 ; <nl> + switch ( opcode ) { <nl> + case kExprF32x4ExtractLane : <nl> + case kExprF32x4ReplaceLane : <nl> + case kExprI32x4ExtractLane : <nl> + case kExprI32x4ReplaceLane : <nl> + num_lanes = 4 ; <nl> + break ; <nl> + case kExprI16x8ExtractLane : <nl> + case kExprI16x8ReplaceLane : <nl> + num_lanes = 8 ; <nl> + break ; <nl> + case kExprI8x16ExtractLane : <nl> + case kExprI8x16ReplaceLane : <nl> + num_lanes = 16 ; <nl> + break ; <nl> + default : <nl> + UNREACHABLE ( ) ; <nl> + break ; <nl> + } <nl> + if ( CHECK_ERROR ( operand . lane < 0 | | operand . lane > = num_lanes ) ) { <nl> + error ( pc_ + 2 , " invalid lane index " ) ; <nl> + return false ; <nl> + } else { <nl> + return true ; <nl> + } <nl> + } <nl> + <nl> + inline bool Validate ( const byte * pc , WasmOpcode opcode , <nl> + SimdShiftOperand < validate > & operand ) { <nl> + uint8_t max_shift = 0 ; <nl> + switch ( opcode ) { <nl> + case kExprI32x4Shl : <nl> + case kExprI32x4ShrS : <nl> + case kExprI32x4ShrU : <nl> + max_shift = 32 ; <nl> + break ; <nl> + case kExprI16x8Shl : <nl> + case kExprI16x8ShrS : <nl> + case kExprI16x8ShrU : <nl> + max_shift = 16 ; <nl> + break ; <nl> + case kExprI8x16Shl : <nl> + case kExprI8x16ShrS : <nl> + case kExprI8x16ShrU : <nl> + max_shift = 8 ; <nl> + break ; <nl> + default : <nl> + UNREACHABLE ( ) ; <nl> + break ; <nl> + } <nl> + if ( CHECK_ERROR ( operand . shift < 0 | | operand . shift > = max_shift ) ) { <nl> + error ( pc_ + 2 , " invalid shift amount " ) ; <nl> + return false ; <nl> + } else { <nl> + return true ; <nl> + } <nl> + } <nl> + <nl> + inline bool Validate ( const byte * pc , <nl> + Simd8x16ShuffleOperand < validate > & operand ) { <nl> + uint8_t max_lane = 0 ; <nl> + for ( uint32_t i = 0 ; i < kSimd128Size ; + + i ) <nl> + max_lane = std : : max ( max_lane , operand . shuffle [ i ] ) ; <nl> + / / Shuffle indices must be in [ 0 . . 31 ] for a 16 lane shuffle . <nl> + if ( CHECK_ERROR ( max_lane > 2 * kSimd128Size ) ) { <nl> + error ( pc_ + 2 , " invalid shuffle mask " ) ; <nl> + return false ; <nl> + } else { <nl> + return true ; <nl> + } <nl> + } <nl> + <nl> + static unsigned OpcodeLength ( Decoder * decoder , const byte * pc ) { <nl> + WasmOpcode opcode = static_cast < WasmOpcode > ( * pc ) ; <nl> + switch ( opcode ) { <nl> + # define DECLARE_OPCODE_CASE ( name , opcode , sig ) case kExpr # # name : <nl> + FOREACH_LOAD_MEM_OPCODE ( DECLARE_OPCODE_CASE ) <nl> + FOREACH_STORE_MEM_OPCODE ( DECLARE_OPCODE_CASE ) <nl> + # undef DECLARE_OPCODE_CASE <nl> + { <nl> + MemoryAccessOperand < validate > operand ( decoder , pc , UINT32_MAX ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + case kExprBr : <nl> + case kExprBrIf : { <nl> + BreakDepthOperand < validate > operand ( decoder , pc ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + case kExprSetGlobal : <nl> + case kExprGetGlobal : { <nl> + GlobalIndexOperand < validate > operand ( decoder , pc ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + <nl> + case kExprCallFunction : { <nl> + CallFunctionOperand < validate > operand ( decoder , pc ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + case kExprCallIndirect : { <nl> + CallIndirectOperand < validate > operand ( decoder , pc ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + <nl> + case kExprTry : <nl> + case kExprIf : / / fall through <nl> + case kExprLoop : <nl> + case kExprBlock : { <nl> + BlockTypeOperand < validate > operand ( decoder , pc ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + <nl> + case kExprThrow : <nl> + case kExprCatch : { <nl> + ExceptionIndexOperand < validate > operand ( decoder , pc ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + <nl> + case kExprSetLocal : <nl> + case kExprTeeLocal : <nl> + case kExprGetLocal : { <nl> + LocalIndexOperand < validate > operand ( decoder , pc ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + case kExprBrTable : { <nl> + BranchTableOperand < validate > operand ( decoder , pc ) ; <nl> + BranchTableIterator < validate > iterator ( decoder , operand ) ; <nl> + return 1 + iterator . length ( ) ; <nl> + } <nl> + case kExprI32Const : { <nl> + ImmI32Operand < validate > operand ( decoder , pc ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + case kExprI64Const : { <nl> + ImmI64Operand < validate > operand ( decoder , pc ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + case kExprGrowMemory : <nl> + case kExprMemorySize : { <nl> + MemoryIndexOperand < validate > operand ( decoder , pc ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + case kExprF32Const : <nl> + return 5 ; <nl> + case kExprF64Const : <nl> + return 9 ; <nl> + case kSimdPrefix : { <nl> + byte simd_index = decoder - > read_u8 < validate > ( pc + 1 , " simd_index " ) ; <nl> + WasmOpcode opcode = <nl> + static_cast < WasmOpcode > ( kSimdPrefix < < 8 | simd_index ) ; <nl> + switch ( opcode ) { <nl> + # define DECLARE_OPCODE_CASE ( name , opcode , sig ) case kExpr # # name : <nl> + FOREACH_SIMD_0_OPERAND_OPCODE ( DECLARE_OPCODE_CASE ) <nl> + # undef DECLARE_OPCODE_CASE <nl> + return 2 ; <nl> + # define DECLARE_OPCODE_CASE ( name , opcode , sig ) case kExpr # # name : <nl> + FOREACH_SIMD_1_OPERAND_OPCODE ( DECLARE_OPCODE_CASE ) <nl> + # undef DECLARE_OPCODE_CASE <nl> + return 3 ; <nl> + # define DECLARE_OPCODE_CASE ( name , opcode , sig ) case kExpr # # name : <nl> + FOREACH_SIMD_MEM_OPCODE ( DECLARE_OPCODE_CASE ) <nl> + # undef DECLARE_OPCODE_CASE <nl> + { <nl> + MemoryAccessOperand < validate > operand ( decoder , pc + 1 , UINT32_MAX ) ; <nl> + return 2 + operand . length ; <nl> + } <nl> + / / Shuffles require a byte per lane , or 16 immediate bytes . <nl> + case kExprS8x16Shuffle : <nl> + return 2 + kSimd128Size ; <nl> + default : <nl> + decoder - > error ( pc , " invalid SIMD opcode " ) ; <nl> + return 2 ; <nl> + } <nl> + } <nl> + default : <nl> + return 1 ; <nl> + } <nl> + } <nl> + <nl> + std : : pair < uint32_t , uint32_t > StackEffect ( const byte * pc ) { <nl> + WasmOpcode opcode = static_cast < WasmOpcode > ( * pc ) ; <nl> + / / Handle " simple " opcodes with a fixed signature first . <nl> + FunctionSig * sig = WasmOpcodes : : Signature ( opcode ) ; <nl> + if ( ! sig ) sig = WasmOpcodes : : AsmjsSignature ( opcode ) ; <nl> + if ( sig ) return { sig - > parameter_count ( ) , sig - > return_count ( ) } ; <nl> + if ( WasmOpcodes : : IsPrefixOpcode ( opcode ) ) { <nl> + opcode = static_cast < WasmOpcode > ( opcode < < 8 | * ( pc + 1 ) ) ; <nl> + } <nl> + <nl> + # define DECLARE_OPCODE_CASE ( name , opcode , sig ) case kExpr # # name : <nl> + / / clang - format off <nl> + switch ( opcode ) { <nl> + case kExprSelect : <nl> + return { 3 , 1 } ; <nl> + case kExprS128StoreMem : <nl> + FOREACH_STORE_MEM_OPCODE ( DECLARE_OPCODE_CASE ) <nl> + return { 2 , 0 } ; <nl> + case kExprS128LoadMem : <nl> + FOREACH_LOAD_MEM_OPCODE ( DECLARE_OPCODE_CASE ) <nl> + case kExprTeeLocal : <nl> + case kExprGrowMemory : <nl> + return { 1 , 1 } ; <nl> + case kExprSetLocal : <nl> + case kExprSetGlobal : <nl> + case kExprDrop : <nl> + case kExprBrIf : <nl> + case kExprBrTable : <nl> + case kExprIf : <nl> + return { 1 , 0 } ; <nl> + case kExprGetLocal : <nl> + case kExprGetGlobal : <nl> + case kExprI32Const : <nl> + case kExprI64Const : <nl> + case kExprF32Const : <nl> + case kExprF64Const : <nl> + case kExprMemorySize : <nl> + return { 0 , 1 } ; <nl> + case kExprCallFunction : { <nl> + CallFunctionOperand < validate > operand ( this , pc ) ; <nl> + CHECK ( Complete ( pc , operand ) ) ; <nl> + return { operand . sig - > parameter_count ( ) , operand . sig - > return_count ( ) } ; <nl> + } <nl> + case kExprCallIndirect : { <nl> + CallIndirectOperand < validate > operand ( this , pc ) ; <nl> + CHECK ( Complete ( pc , operand ) ) ; <nl> + / / Indirect calls pop an additional argument for the table index . <nl> + return { operand . sig - > parameter_count ( ) + 1 , <nl> + operand . sig - > return_count ( ) } ; <nl> + } <nl> + case kExprBr : <nl> + case kExprBlock : <nl> + case kExprLoop : <nl> + case kExprEnd : <nl> + case kExprElse : <nl> + case kExprNop : <nl> + case kExprReturn : <nl> + case kExprUnreachable : <nl> + return { 0 , 0 } ; <nl> + default : <nl> + V8_Fatal ( __FILE__ , __LINE__ , " unimplemented opcode : % x ( % s ) " , opcode , <nl> + WasmOpcodes : : OpcodeName ( opcode ) ) ; <nl> + return { 0 , 0 } ; <nl> + } <nl> + # undef DECLARE_OPCODE_CASE <nl> + / / clang - format on <nl> + } <nl> + } ; <nl> + <nl> + template < bool validate , typename Interface > <nl> + class WasmFullDecoder : public WasmDecoder < validate > { <nl> + using Value = AbstractValue < Interface > ; <nl> + using Control = AbstractControl < Interface > ; <nl> + using MergeValues = AbstractMerge < Interface > ; <nl> + <nl> + / / All Value and Control types should be trivially copyable for <nl> + / / performance . We push and pop them , and store them in local variables . <nl> + static_assert ( IS_TRIVIALLY_COPYABLE ( Value ) , <nl> + " all Value < . . . > types should be trivially copyable " ) ; <nl> + static_assert ( IS_TRIVIALLY_COPYABLE ( Control ) , <nl> + " all Control < . . . > types should be trivially copyable " ) ; <nl> + <nl> + public : <nl> + template < typename . . . InterfaceArgs > <nl> + WasmFullDecoder ( Zone * zone , const wasm : : WasmModule * module , <nl> + const FunctionBody & body , InterfaceArgs & & . . . interface_args ) <nl> + : WasmDecoder < validate > ( module , body . sig , body . start , body . end , <nl> + body . offset ) , <nl> + zone_ ( zone ) , <nl> + interface_ ( std : : forward < InterfaceArgs > ( interface_args ) . . . ) , <nl> + local_type_vec_ ( zone ) , <nl> + stack_ ( zone ) , <nl> + control_ ( zone ) , <nl> + last_end_found_ ( false ) { <nl> + this - > local_types_ = & local_type_vec_ ; <nl> + } <nl> + <nl> + Interface & interface ( ) { return interface_ ; } <nl> + <nl> + bool Decode ( ) { <nl> + DCHECK ( stack_ . empty ( ) ) ; <nl> + DCHECK ( control_ . empty ( ) ) ; <nl> + <nl> + if ( FLAG_wasm_code_fuzzer_gen_test ) { <nl> + PrintRawWasmCode ( this - > start_ , this - > end_ ) ; <nl> + } <nl> + base : : ElapsedTimer decode_timer ; <nl> + if ( FLAG_trace_wasm_decode_time ) { <nl> + decode_timer . Start ( ) ; <nl> + } <nl> + <nl> + if ( this - > end_ < this - > pc_ ) { <nl> + this - > error ( " function body end < start " ) ; <nl> + return false ; <nl> + } <nl> + <nl> + DCHECK_EQ ( 0 , this - > local_types_ - > size ( ) ) ; <nl> + WasmDecoder < validate > : : DecodeLocals ( this , this - > sig_ , this - > local_types_ ) ; <nl> + interface_ . StartFunction ( this ) ; <nl> + DecodeFunctionBody ( ) ; <nl> + if ( ! this - > failed ( ) ) interface_ . FinishFunction ( this ) ; <nl> + <nl> + if ( this - > failed ( ) ) return this - > TraceFailed ( ) ; <nl> + <nl> + if ( ! control_ . empty ( ) ) { <nl> + / / Generate a better error message whether the unterminated control <nl> + / / structure is the function body block or an innner structure . <nl> + if ( control_ . size ( ) > 1 ) { <nl> + this - > error ( control_ . back ( ) . pc , " unterminated control structure " ) ; <nl> + } else { <nl> + this - > error ( " function body must end with \ " end \ " opcode " ) ; <nl> + } <nl> + return TraceFailed ( ) ; <nl> + } <nl> + <nl> + if ( ! last_end_found_ ) { <nl> + this - > error ( " function body must end with \ " end \ " opcode " ) ; <nl> + return false ; <nl> + } <nl> + <nl> + if ( FLAG_trace_wasm_decode_time ) { <nl> + double ms = decode_timer . Elapsed ( ) . InMillisecondsF ( ) ; <nl> + PrintF ( " wasm - decode % s ( % 0 . 3f ms ) \ n \ n " , this - > ok ( ) ? " ok " : " failed " , ms ) ; <nl> + } else { <nl> + TRACE ( " wasm - decode % s \ n \ n " , this - > ok ( ) ? " ok " : " failed " ) ; <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + bool TraceFailed ( ) { <nl> + TRACE ( " wasm - error module + % - 6d func + % d : % s \ n \ n " , this - > error_offset_ , <nl> + this - > GetBufferRelativeOffset ( this - > error_offset_ ) , <nl> + this - > error_msg_ . c_str ( ) ) ; <nl> + return false ; <nl> + } <nl> + <nl> + const char * SafeOpcodeNameAt ( const byte * pc ) { <nl> + if ( pc > = this - > end_ ) return " < end > " ; <nl> + return WasmOpcodes : : OpcodeName ( static_cast < WasmOpcode > ( * pc ) ) ; <nl> + } <nl> + <nl> + inline Zone * zone ( ) const { return zone_ ; } <nl> + <nl> + inline uint32_t NumLocals ( ) { <nl> + return static_cast < uint32_t > ( local_type_vec_ . size ( ) ) ; <nl> + } <nl> + <nl> + inline ValueType GetLocalType ( uint32_t index ) { <nl> + return local_type_vec_ [ index ] ; <nl> + } <nl> + <nl> + inline wasm : : WasmCodePosition position ( ) { <nl> + int offset = static_cast < int > ( this - > pc_ - this - > start_ ) ; <nl> + DCHECK_EQ ( this - > pc_ - this - > start_ , offset ) ; / / overflows cannot happen <nl> + return offset ; <nl> + } <nl> + <nl> + inline uint32_t control_depth ( ) const { <nl> + return static_cast < uint32_t > ( control_ . size ( ) ) ; <nl> + } <nl> + <nl> + inline Control * control_at ( uint32_t depth ) { <nl> + DCHECK_GT ( control_ . size ( ) , depth ) ; <nl> + return & control_ [ control_ . size ( ) - depth - 1 ] ; <nl> + } <nl> + <nl> + inline uint32_t stack_size ( ) const { <nl> + return static_cast < uint32_t > ( stack_ . size ( ) ) ; <nl> + } <nl> + <nl> + inline Value * stack_value ( uint32_t depth ) { <nl> + DCHECK_GT ( stack_ . size ( ) , depth ) ; <nl> + return & stack_ [ stack_ . size ( ) - depth - 1 ] ; <nl> + } <nl> + <nl> + inline const Value & GetMergeValueFromStack ( Control * c , size_t i ) { <nl> + DCHECK_GT ( c - > merge . arity , i ) ; <nl> + DCHECK_GE ( stack_ . size ( ) , c - > merge . arity ) ; <nl> + return stack_ [ stack_ . size ( ) - c - > merge . arity + i ] ; <nl> + } <nl> + <nl> + private : <nl> + static constexpr size_t kErrorMsgSize = 128 ; <nl> + <nl> + Zone * zone_ ; <nl> + <nl> + Interface interface_ ; <nl> + <nl> + ZoneVector < ValueType > local_type_vec_ ; / / types of local variables . <nl> + ZoneVector < Value > stack_ ; / / stack of values . <nl> + ZoneVector < Control > control_ ; / / stack of blocks , loops , and ifs . <nl> + bool last_end_found_ ; <nl> + <nl> + bool CheckHasMemory ( ) { <nl> + if ( VALIDATE ( this - > module_ - > has_memory ) ) return true ; <nl> + this - > error ( this - > pc_ - 1 , " memory instruction with no memory " ) ; <nl> + return false ; <nl> + } <nl> + <nl> + / / Decodes the body of a function . <nl> + void DecodeFunctionBody ( ) { <nl> + TRACE ( " wasm - decode % p . . . % p ( module + % u , % d bytes ) \ n " , <nl> + reinterpret_cast < const void * > ( this - > start ( ) ) , <nl> + reinterpret_cast < const void * > ( this - > end ( ) ) , this - > pc_offset ( ) , <nl> + static_cast < int > ( this - > end ( ) - this - > start ( ) ) ) ; <nl> + <nl> + / / Set up initial function block . <nl> + { <nl> + auto * c = PushBlock ( ) ; <nl> + c - > merge . arity = static_cast < uint32_t > ( this - > sig_ - > return_count ( ) ) ; <nl> + <nl> + if ( c - > merge . arity = = 1 ) { <nl> + c - > merge . vals . first = Value : : New ( this - > pc_ , this - > sig_ - > GetReturn ( 0 ) ) ; <nl> + } else if ( c - > merge . arity > 1 ) { <nl> + c - > merge . vals . array = zone_ - > NewArray < Value > ( c - > merge . arity ) ; <nl> + for ( unsigned i = 0 ; i < c - > merge . arity ; i + + ) { <nl> + c - > merge . vals . array [ i ] = <nl> + Value : : New ( this - > pc_ , this - > sig_ - > GetReturn ( i ) ) ; <nl> + } <nl> + } <nl> + interface_ . StartFunctionBody ( this , c ) ; <nl> + } <nl> + <nl> + while ( this - > pc_ < this - > end_ ) { / / decoding loop . <nl> + unsigned len = 1 ; <nl> + WasmOpcode opcode = static_cast < WasmOpcode > ( * this - > pc_ ) ; <nl> + # if DEBUG <nl> + if ( FLAG_trace_wasm_decoder & & ! WasmOpcodes : : IsPrefixOpcode ( opcode ) ) { <nl> + TRACE ( " @ % - 8d # % - 20s | " , startrel ( this - > pc_ ) , <nl> + WasmOpcodes : : OpcodeName ( opcode ) ) ; <nl> + } <nl> + # endif <nl> + <nl> + FunctionSig * sig = WasmOpcodes : : Signature ( opcode ) ; <nl> + if ( sig ) { <nl> + BuildSimpleOperator ( opcode , sig ) ; <nl> + } else { <nl> + / / Complex bytecode . <nl> + switch ( opcode ) { <nl> + case kExprNop : <nl> + break ; <nl> + case kExprBlock : { <nl> + BlockTypeOperand < validate > operand ( this , this - > pc_ ) ; <nl> + auto * block = PushBlock ( ) ; <nl> + SetBlockType ( block , operand ) ; <nl> + len = 1 + operand . length ; <nl> + interface_ . Block ( this , block ) ; <nl> + break ; <nl> + } <nl> + case kExprRethrow : { <nl> + / / TODO ( kschimpf ) : Implement . <nl> + CHECK_PROTOTYPE_OPCODE ( eh ) ; <nl> + OPCODE_ERROR ( opcode , " not implemented yet " ) ; <nl> + break ; <nl> + } <nl> + case kExprThrow : { <nl> + CHECK_PROTOTYPE_OPCODE ( eh ) ; <nl> + ExceptionIndexOperand < true > operand ( this , this - > pc_ ) ; <nl> + len = 1 + operand . length ; <nl> + if ( ! this - > Validate ( this - > pc_ , operand ) ) break ; <nl> + if ( operand . exception - > sig - > parameter_count ( ) > 0 ) { <nl> + / / TODO ( kschimpf ) : Fix to pull values off stack and build throw . <nl> + OPCODE_ERROR ( opcode , " can ' t handle exceptions with values yet " ) ; <nl> + break ; <nl> + } <nl> + interface_ . Throw ( this , operand ) ; <nl> + / / TODO ( titzer ) : Throw should end control , but currently we build a <nl> + / / ( reachable ) runtime call instead of connecting it directly to <nl> + / / end . <nl> + / / EndControl ( ) ; <nl> + break ; <nl> + } <nl> + case kExprTry : { <nl> + CHECK_PROTOTYPE_OPCODE ( eh ) ; <nl> + BlockTypeOperand < validate > operand ( this , this - > pc_ ) ; <nl> + auto * try_block = PushTry ( ) ; <nl> + SetBlockType ( try_block , operand ) ; <nl> + len = 1 + operand . length ; <nl> + interface_ . Try ( this , try_block ) ; <nl> + break ; <nl> + } <nl> + case kExprCatch : { <nl> + / / TODO ( kschimpf ) : Fix to use type signature of exception . <nl> + CHECK_PROTOTYPE_OPCODE ( eh ) ; <nl> + ExceptionIndexOperand < true > operand ( this , this - > pc_ ) ; <nl> + len = 1 + operand . length ; <nl> + <nl> + if ( ! this - > Validate ( this - > pc_ , operand ) ) break ; <nl> + <nl> + if ( CHECK_ERROR ( control_ . empty ( ) ) ) { <nl> + this - > error ( " catch does not match any try " ) ; <nl> + break ; <nl> + } <nl> + <nl> + Control * c = & control_ . back ( ) ; <nl> + if ( CHECK_ERROR ( ! c - > is_try ( ) ) ) { <nl> + this - > error ( " catch does not match any try " ) ; <nl> + break ; <nl> + } <nl> + <nl> + if ( c - > is_try_catch ( ) ) { <nl> + OPCODE_ERROR ( opcode , " multiple catch blocks not implemented " ) ; <nl> + break ; <nl> + } <nl> + c - > kind = kControlTryCatch ; <nl> + FallThruTo ( c ) ; <nl> + stack_ . resize ( c - > stack_depth ) ; <nl> + <nl> + interface_ . Catch ( this , operand , c ) ; <nl> + break ; <nl> + } <nl> + case kExprCatchAll : { <nl> + / / TODO ( kschimpf ) : Implement . <nl> + CHECK_PROTOTYPE_OPCODE ( eh ) ; <nl> + OPCODE_ERROR ( opcode , " not implemented yet " ) ; <nl> + break ; <nl> + } <nl> + case kExprLoop : { <nl> + BlockTypeOperand < validate > operand ( this , this - > pc_ ) ; <nl> + / / The continue environment is the inner environment . <nl> + auto * block = PushLoop ( ) ; <nl> + SetBlockType ( & control_ . back ( ) , operand ) ; <nl> + len = 1 + operand . length ; <nl> + interface_ . Loop ( this , block ) ; <nl> + break ; <nl> + } <nl> + case kExprIf : { <nl> + / / Condition on top of stack . Split environments for branches . <nl> + BlockTypeOperand < validate > operand ( this , this - > pc_ ) ; <nl> + auto cond = Pop ( 0 , kWasmI32 ) ; <nl> + auto * if_block = PushIf ( ) ; <nl> + SetBlockType ( if_block , operand ) ; <nl> + interface_ . If ( this , cond , if_block ) ; <nl> + len = 1 + operand . length ; <nl> + break ; <nl> + } <nl> + case kExprElse : { <nl> + if ( CHECK_ERROR ( control_ . empty ( ) ) ) { <nl> + this - > error ( " else does not match any if " ) ; <nl> + break ; <nl> + } <nl> + Control * c = & control_ . back ( ) ; <nl> + if ( CHECK_ERROR ( ! c - > is_if ( ) ) ) { <nl> + this - > error ( this - > pc_ , " else does not match an if " ) ; <nl> + break ; <nl> + } <nl> + if ( c - > is_if_else ( ) ) { <nl> + this - > error ( this - > pc_ , " else already present for if " ) ; <nl> + break ; <nl> + } <nl> + c - > kind = kControlIfElse ; <nl> + FallThruTo ( c ) ; <nl> + stack_ . resize ( c - > stack_depth ) ; <nl> + interface_ . Else ( this , c ) ; <nl> + break ; <nl> + } <nl> + case kExprEnd : { <nl> + if ( CHECK_ERROR ( control_ . empty ( ) ) ) { <nl> + this - > error ( " end does not match any if , try , or block " ) ; <nl> + return ; <nl> + } <nl> + Control * c = & control_ . back ( ) ; <nl> + if ( c - > is_loop ( ) ) { <nl> + / / A loop just leaves the values on the stack . <nl> + TypeCheckFallThru ( c ) ; <nl> + if ( c - > unreachable ) PushEndValues ( c ) ; <nl> + PopControl ( c ) ; <nl> + break ; <nl> + } <nl> + if ( c - > is_onearmed_if ( ) ) { <nl> + / / End the true branch of a one - armed if . <nl> + if ( CHECK_ERROR ( ! c - > unreachable & & <nl> + stack_ . size ( ) ! = c - > stack_depth ) ) { <nl> + this - > error ( " end of if expected empty stack " ) ; <nl> + stack_ . resize ( c - > stack_depth ) ; <nl> + } <nl> + if ( CHECK_ERROR ( c - > merge . arity > 0 ) ) { <nl> + this - > error ( " non - void one - armed if " ) ; <nl> + } <nl> + } else if ( CHECK_ERROR ( c - > is_incomplete_try ( ) ) ) { <nl> + this - > error ( this - > pc_ , " missing catch in try " ) ; <nl> + break ; <nl> + } <nl> + FallThruTo ( c ) ; <nl> + PushEndValues ( c ) ; <nl> + <nl> + if ( control_ . size ( ) = = 1 ) { <nl> + / / If at the last ( implicit ) control , check we are at end . <nl> + if ( CHECK_ERROR ( this - > pc_ + 1 ! = this - > end_ ) ) { <nl> + this - > error ( this - > pc_ + 1 , " trailing code after function end " ) ; <nl> + break ; <nl> + } <nl> + last_end_found_ = true ; <nl> + if ( c - > unreachable ) { <nl> + TypeCheckFallThru ( c ) ; <nl> + } else { <nl> + / / The result of the block is the return value . <nl> + TRACE ( " @ % - 8d # xx : % - 20s | " , startrel ( this - > pc_ ) , <nl> + " ( implicit ) return " ) ; <nl> + DoReturn ( ) ; <nl> + TRACE ( " \ n " ) ; <nl> + } <nl> + } <nl> + PopControl ( c ) ; <nl> + break ; <nl> + } <nl> + case kExprSelect : { <nl> + auto cond = Pop ( 2 , kWasmI32 ) ; <nl> + auto fval = Pop ( ) ; <nl> + auto tval = Pop ( 0 , fval . type ) ; <nl> + auto * result = Push ( tval . type = = kWasmVar ? fval . type : tval . type ) ; <nl> + interface_ . Select ( this , cond , fval , tval , result ) ; <nl> + break ; <nl> + } <nl> + case kExprBr : { <nl> + BreakDepthOperand < validate > operand ( this , this - > pc_ ) ; <nl> + if ( VALIDATE ( this - > Validate ( this - > pc_ , operand , control_ . size ( ) ) & & <nl> + TypeCheckBreak ( operand . depth ) ) ) { <nl> + interface_ . BreakTo ( this , control_at ( operand . depth ) ) ; <nl> + } <nl> + len = 1 + operand . length ; <nl> + EndControl ( ) ; <nl> + break ; <nl> + } <nl> + case kExprBrIf : { <nl> + BreakDepthOperand < validate > operand ( this , this - > pc_ ) ; <nl> + auto cond = Pop ( 0 , kWasmI32 ) ; <nl> + if ( VALIDATE ( this - > ok ( ) & & <nl> + this - > Validate ( this - > pc_ , operand , control_ . size ( ) ) & & <nl> + TypeCheckBreak ( operand . depth ) ) ) { <nl> + interface_ . BrIf ( this , cond , control_at ( operand . depth ) ) ; <nl> + } <nl> + len = 1 + operand . length ; <nl> + break ; <nl> + } <nl> + case kExprBrTable : { <nl> + BranchTableOperand < validate > operand ( this , this - > pc_ ) ; <nl> + BranchTableIterator < validate > iterator ( this , operand ) ; <nl> + if ( ! this - > Validate ( this - > pc_ , operand , control_ . size ( ) ) ) break ; <nl> + auto key = Pop ( 0 , kWasmI32 ) ; <nl> + MergeValues * merge = nullptr ; <nl> + while ( iterator . has_next ( ) ) { <nl> + const uint32_t i = iterator . cur_index ( ) ; <nl> + const byte * pos = iterator . pc ( ) ; <nl> + uint32_t target = iterator . next ( ) ; <nl> + if ( CHECK_ERROR ( target > = control_ . size ( ) ) ) { <nl> + this - > error ( pos , " improper branch in br_table " ) ; <nl> + break ; <nl> + } <nl> + / / Check that label types match up . <nl> + static MergeValues loop_dummy = { 0 , { nullptr } } ; <nl> + Control * c = control_at ( target ) ; <nl> + MergeValues * current = c - > is_loop ( ) ? & loop_dummy : & c - > merge ; <nl> + if ( i = = 0 ) { <nl> + merge = current ; <nl> + } else if ( CHECK_ERROR ( merge - > arity ! = current - > arity ) ) { <nl> + this - > errorf ( pos , <nl> + " inconsistent arity in br_table target % d " <nl> + " ( previous was % u , this one % u ) " , <nl> + i , merge - > arity , current - > arity ) ; <nl> + } else if ( control_at ( 0 ) - > unreachable ) { <nl> + for ( uint32_t j = 0 ; VALIDATE ( this - > ok ( ) ) & & j < merge - > arity ; <nl> + + + j ) { <nl> + if ( CHECK_ERROR ( ( * merge ) [ j ] . type ! = ( * current ) [ j ] . type ) ) { <nl> + this - > errorf ( pos , <nl> + " type error in br_table target % d operand % d " <nl> + " ( previous expected % s , this one % s ) " , <nl> + i , j , WasmOpcodes : : TypeName ( ( * merge ) [ j ] . type ) , <nl> + WasmOpcodes : : TypeName ( ( * current ) [ j ] . type ) ) ; <nl> + } <nl> + } <nl> + } <nl> + bool valid = TypeCheckBreak ( target ) ; <nl> + if ( CHECK_ERROR ( ! valid ) ) break ; <nl> + } <nl> + if ( CHECK_ERROR ( this - > failed ( ) ) ) break ; <nl> + <nl> + if ( operand . table_count > 0 ) { <nl> + interface_ . BrTable ( this , operand , key ) ; <nl> + } else { <nl> + / / Only a default target . Do the equivalent of br . <nl> + BranchTableIterator < validate > iterator ( this , operand ) ; <nl> + const byte * pos = iterator . pc ( ) ; <nl> + uint32_t target = iterator . next ( ) ; <nl> + if ( CHECK_ERROR ( target > = control_ . size ( ) ) ) { <nl> + this - > error ( pos , " improper branch in br_table " ) ; <nl> + break ; <nl> + } <nl> + interface_ . BreakTo ( this , control_at ( target ) ) ; <nl> + } <nl> + len = 1 + iterator . length ( ) ; <nl> + EndControl ( ) ; <nl> + break ; <nl> + } <nl> + case kExprReturn : { <nl> + DoReturn ( ) ; <nl> + break ; <nl> + } <nl> + case kExprUnreachable : { <nl> + interface_ . Unreachable ( this ) ; <nl> + EndControl ( ) ; <nl> + break ; <nl> + } <nl> + case kExprI32Const : { <nl> + ImmI32Operand < validate > operand ( this , this - > pc_ ) ; <nl> + auto * value = Push ( kWasmI32 ) ; <nl> + interface_ . I32Const ( this , value , operand . value ) ; <nl> + len = 1 + operand . length ; <nl> + break ; <nl> + } <nl> + case kExprI64Const : { <nl> + ImmI64Operand < validate > operand ( this , this - > pc_ ) ; <nl> + auto * value = Push ( kWasmI64 ) ; <nl> + interface_ . I64Const ( this , value , operand . value ) ; <nl> + len = 1 + operand . length ; <nl> + break ; <nl> + } <nl> + case kExprF32Const : { <nl> + ImmF32Operand < validate > operand ( this , this - > pc_ ) ; <nl> + auto * value = Push ( kWasmF32 ) ; <nl> + interface_ . F32Const ( this , value , operand . value ) ; <nl> + len = 1 + operand . length ; <nl> + break ; <nl> + } <nl> + case kExprF64Const : { <nl> + ImmF64Operand < validate > operand ( this , this - > pc_ ) ; <nl> + auto * value = Push ( kWasmF64 ) ; <nl> + interface_ . F64Const ( this , value , operand . value ) ; <nl> + len = 1 + operand . length ; <nl> + break ; <nl> + } <nl> + case kExprGetLocal : { <nl> + LocalIndexOperand < validate > operand ( this , this - > pc_ ) ; <nl> + if ( ! this - > Validate ( this - > pc_ , operand ) ) break ; <nl> + auto * value = Push ( operand . type ) ; <nl> + interface_ . GetLocal ( this , value , operand ) ; <nl> + len = 1 + operand . length ; <nl> + break ; <nl> + } <nl> + case kExprSetLocal : { <nl> + LocalIndexOperand < validate > operand ( this , this - > pc_ ) ; <nl> + if ( ! this - > Validate ( this - > pc_ , operand ) ) break ; <nl> + auto value = Pop ( 0 , local_type_vec_ [ operand . index ] ) ; <nl> + interface_ . SetLocal ( this , value , operand ) ; <nl> + len = 1 + operand . length ; <nl> + break ; <nl> + } <nl> + case kExprTeeLocal : { <nl> + LocalIndexOperand < validate > operand ( this , this - > pc_ ) ; <nl> + if ( ! this - > Validate ( this - > pc_ , operand ) ) break ; <nl> + auto value = Pop ( 0 , local_type_vec_ [ operand . index ] ) ; <nl> + auto * result = Push ( value . type ) ; <nl> + interface_ . TeeLocal ( this , value , result , operand ) ; <nl> + len = 1 + operand . length ; <nl> + break ; <nl> + } <nl> + case kExprDrop : { <nl> + Pop ( ) ; <nl> + break ; <nl> + } <nl> + case kExprGetGlobal : { <nl> + GlobalIndexOperand < validate > operand ( this , this - > pc_ ) ; <nl> + len = 1 + operand . length ; <nl> + if ( ! this - > Validate ( this - > pc_ , operand ) ) break ; <nl> + auto * result = Push ( operand . type ) ; <nl> + interface_ . GetGlobal ( this , result , operand ) ; <nl> + break ; <nl> + } <nl> + case kExprSetGlobal : { <nl> + GlobalIndexOperand < validate > operand ( this , this - > pc_ ) ; <nl> + len = 1 + operand . length ; <nl> + if ( ! this - > Validate ( this - > pc_ , operand ) ) break ; <nl> + if ( CHECK_ERROR ( ! operand . global - > mutability ) ) { <nl> + this - > errorf ( this - > pc_ , " immutable global # % u cannot be assigned " , <nl> + operand . index ) ; <nl> + break ; <nl> + } <nl> + auto value = Pop ( 0 , operand . type ) ; <nl> + interface_ . SetGlobal ( this , value , operand ) ; <nl> + break ; <nl> + } <nl> + case kExprI32LoadMem8S : <nl> + len = DecodeLoadMem ( kWasmI32 , MachineType : : Int8 ( ) ) ; <nl> + break ; <nl> + case kExprI32LoadMem8U : <nl> + len = DecodeLoadMem ( kWasmI32 , MachineType : : Uint8 ( ) ) ; <nl> + break ; <nl> + case kExprI32LoadMem16S : <nl> + len = DecodeLoadMem ( kWasmI32 , MachineType : : Int16 ( ) ) ; <nl> + break ; <nl> + case kExprI32LoadMem16U : <nl> + len = DecodeLoadMem ( kWasmI32 , MachineType : : Uint16 ( ) ) ; <nl> + break ; <nl> + case kExprI32LoadMem : <nl> + len = DecodeLoadMem ( kWasmI32 , MachineType : : Int32 ( ) ) ; <nl> + break ; <nl> + case kExprI64LoadMem8S : <nl> + len = DecodeLoadMem ( kWasmI64 , MachineType : : Int8 ( ) ) ; <nl> + break ; <nl> + case kExprI64LoadMem8U : <nl> + len = DecodeLoadMem ( kWasmI64 , MachineType : : Uint8 ( ) ) ; <nl> + break ; <nl> + case kExprI64LoadMem16S : <nl> + len = DecodeLoadMem ( kWasmI64 , MachineType : : Int16 ( ) ) ; <nl> + break ; <nl> + case kExprI64LoadMem16U : <nl> + len = DecodeLoadMem ( kWasmI64 , MachineType : : Uint16 ( ) ) ; <nl> + break ; <nl> + case kExprI64LoadMem32S : <nl> + len = DecodeLoadMem ( kWasmI64 , MachineType : : Int32 ( ) ) ; <nl> + break ; <nl> + case kExprI64LoadMem32U : <nl> + len = DecodeLoadMem ( kWasmI64 , MachineType : : Uint32 ( ) ) ; <nl> + break ; <nl> + case kExprI64LoadMem : <nl> + len = DecodeLoadMem ( kWasmI64 , MachineType : : Int64 ( ) ) ; <nl> + break ; <nl> + case kExprF32LoadMem : <nl> + len = DecodeLoadMem ( kWasmF32 , MachineType : : Float32 ( ) ) ; <nl> + break ; <nl> + case kExprF64LoadMem : <nl> + len = DecodeLoadMem ( kWasmF64 , MachineType : : Float64 ( ) ) ; <nl> + break ; <nl> + case kExprI32StoreMem8 : <nl> + len = DecodeStoreMem ( kWasmI32 , MachineType : : Int8 ( ) ) ; <nl> + break ; <nl> + case kExprI32StoreMem16 : <nl> + len = DecodeStoreMem ( kWasmI32 , MachineType : : Int16 ( ) ) ; <nl> + break ; <nl> + case kExprI32StoreMem : <nl> + len = DecodeStoreMem ( kWasmI32 , MachineType : : Int32 ( ) ) ; <nl> + break ; <nl> + case kExprI64StoreMem8 : <nl> + len = DecodeStoreMem ( kWasmI64 , MachineType : : Int8 ( ) ) ; <nl> + break ; <nl> + case kExprI64StoreMem16 : <nl> + len = DecodeStoreMem ( kWasmI64 , MachineType : : Int16 ( ) ) ; <nl> + break ; <nl> + case kExprI64StoreMem32 : <nl> + len = DecodeStoreMem ( kWasmI64 , MachineType : : Int32 ( ) ) ; <nl> + break ; <nl> + case kExprI64StoreMem : <nl> + len = DecodeStoreMem ( kWasmI64 , MachineType : : Int64 ( ) ) ; <nl> + break ; <nl> + case kExprF32StoreMem : <nl> + len = DecodeStoreMem ( kWasmF32 , MachineType : : Float32 ( ) ) ; <nl> + break ; <nl> + case kExprF64StoreMem : <nl> + len = DecodeStoreMem ( kWasmF64 , MachineType : : Float64 ( ) ) ; <nl> + break ; <nl> + case kExprGrowMemory : { <nl> + if ( ! CheckHasMemory ( ) ) break ; <nl> + MemoryIndexOperand < validate > operand ( this , this - > pc_ ) ; <nl> + len = 1 + operand . length ; <nl> + DCHECK_NOT_NULL ( this - > module_ ) ; <nl> + if ( CHECK_ERROR ( ! this - > module_ - > is_wasm ( ) ) ) { <nl> + this - > error ( " grow_memory is not supported for asmjs modules " ) ; <nl> + break ; <nl> + } <nl> + auto value = Pop ( 0 , kWasmI32 ) ; <nl> + auto * result = Push ( kWasmI32 ) ; <nl> + interface_ . GrowMemory ( this , value , result ) ; <nl> + break ; <nl> + } <nl> + case kExprMemorySize : { <nl> + if ( ! CheckHasMemory ( ) ) break ; <nl> + MemoryIndexOperand < validate > operand ( this , this - > pc_ ) ; <nl> + auto * result = Push ( kWasmI32 ) ; <nl> + len = 1 + operand . length ; <nl> + interface_ . CurrentMemoryPages ( this , result ) ; <nl> + break ; <nl> + } <nl> + case kExprCallFunction : { <nl> + CallFunctionOperand < validate > operand ( this , this - > pc_ ) ; <nl> + len = 1 + operand . length ; <nl> + if ( ! this - > Validate ( this - > pc_ , operand ) ) break ; <nl> + / / TODO ( clemensh ) : Better memory management . <nl> + std : : vector < Value > args ; <nl> + PopArgs ( operand . sig , & args ) ; <nl> + auto * returns = PushReturns ( operand . sig ) ; <nl> + interface_ . CallDirect ( this , operand , args . data ( ) , returns ) ; <nl> + break ; <nl> + } <nl> + case kExprCallIndirect : { <nl> + CallIndirectOperand < validate > operand ( this , this - > pc_ ) ; <nl> + len = 1 + operand . length ; <nl> + if ( ! this - > Validate ( this - > pc_ , operand ) ) break ; <nl> + auto index = Pop ( 0 , kWasmI32 ) ; <nl> + / / TODO ( clemensh ) : Better memory management . <nl> + std : : vector < Value > args ; <nl> + PopArgs ( operand . sig , & args ) ; <nl> + auto * returns = PushReturns ( operand . sig ) ; <nl> + interface_ . CallIndirect ( this , index , operand , args . data ( ) , returns ) ; <nl> + break ; <nl> + } <nl> + case kSimdPrefix : { <nl> + CHECK_PROTOTYPE_OPCODE ( simd ) ; <nl> + len + + ; <nl> + byte simd_index = <nl> + this - > template read_u8 < validate > ( this - > pc_ + 1 , " simd index " ) ; <nl> + opcode = static_cast < WasmOpcode > ( opcode < < 8 | simd_index ) ; <nl> + TRACE ( " @ % - 4d # % - 20s | " , startrel ( this - > pc_ ) , <nl> + WasmOpcodes : : OpcodeName ( opcode ) ) ; <nl> + len + = DecodeSimdOpcode ( opcode ) ; <nl> + break ; <nl> + } <nl> + case kAtomicPrefix : { <nl> + CHECK_PROTOTYPE_OPCODE ( threads ) ; <nl> + len + + ; <nl> + byte atomic_index = <nl> + this - > template read_u8 < validate > ( this - > pc_ + 1 , " atomic index " ) ; <nl> + opcode = static_cast < WasmOpcode > ( opcode < < 8 | atomic_index ) ; <nl> + TRACE ( " @ % - 4d # % - 20s | " , startrel ( this - > pc_ ) , <nl> + WasmOpcodes : : OpcodeName ( opcode ) ) ; <nl> + len + = DecodeAtomicOpcode ( opcode ) ; <nl> + break ; <nl> + } <nl> + default : { <nl> + / / Deal with special asmjs opcodes . <nl> + if ( this - > module_ ! = nullptr & & this - > module_ - > is_asm_js ( ) ) { <nl> + sig = WasmOpcodes : : AsmjsSignature ( opcode ) ; <nl> + if ( sig ) { <nl> + BuildSimpleOperator ( opcode , sig ) ; <nl> + } <nl> + } else { <nl> + this - > error ( " Invalid opcode " ) ; <nl> + return ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + # if DEBUG <nl> + if ( FLAG_trace_wasm_decoder ) { <nl> + PrintF ( " " ) ; <nl> + for ( size_t i = 0 ; i < control_ . size ( ) ; + + i ) { <nl> + Control * c = & control_ [ i ] ; <nl> + switch ( c - > kind ) { <nl> + case kControlIf : <nl> + PrintF ( " I " ) ; <nl> + break ; <nl> + case kControlBlock : <nl> + PrintF ( " B " ) ; <nl> + break ; <nl> + case kControlLoop : <nl> + PrintF ( " L " ) ; <nl> + break ; <nl> + case kControlTry : <nl> + PrintF ( " T " ) ; <nl> + break ; <nl> + default : <nl> + break ; <nl> + } <nl> + PrintF ( " % u " , c - > merge . arity ) ; <nl> + if ( c - > unreachable ) PrintF ( " * " ) ; <nl> + } <nl> + PrintF ( " | " ) ; <nl> + for ( size_t i = 0 ; i < stack_ . size ( ) ; + + i ) { <nl> + auto & val = stack_ [ i ] ; <nl> + WasmOpcode opcode = static_cast < WasmOpcode > ( * val . pc ) ; <nl> + if ( WasmOpcodes : : IsPrefixOpcode ( opcode ) ) { <nl> + opcode = static_cast < WasmOpcode > ( opcode < < 8 | * ( val . pc + 1 ) ) ; <nl> + } <nl> + PrintF ( " % c @ % d : % s " , WasmOpcodes : : ShortNameOf ( val . type ) , <nl> + static_cast < int > ( val . pc - this - > start_ ) , <nl> + WasmOpcodes : : OpcodeName ( opcode ) ) ; <nl> + switch ( opcode ) { <nl> + case kExprI32Const : { <nl> + ImmI32Operand < validate > operand ( this , val . pc ) ; <nl> + PrintF ( " [ % d ] " , operand . value ) ; <nl> + break ; <nl> + } <nl> + case kExprGetLocal : { <nl> + LocalIndexOperand < validate > operand ( this , val . pc ) ; <nl> + PrintF ( " [ % u ] " , operand . index ) ; <nl> + break ; <nl> + } <nl> + case kExprSetLocal : / / fallthru <nl> + case kExprTeeLocal : { <nl> + LocalIndexOperand < validate > operand ( this , val . pc ) ; <nl> + PrintF ( " [ % u ] " , operand . index ) ; <nl> + break ; <nl> + } <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + PrintF ( " \ n " ) ; <nl> + } <nl> + # endif <nl> + this - > pc_ + = len ; <nl> + } / / end decode loop <nl> + if ( this - > pc_ > this - > end_ & & this - > ok ( ) ) this - > error ( " Beyond end of code " ) ; <nl> + } <nl> + <nl> + void EndControl ( ) { <nl> + DCHECK ( ! control_ . empty ( ) ) ; <nl> + auto * current = & control_ . back ( ) ; <nl> + stack_ . resize ( current - > stack_depth ) ; <nl> + current - > unreachable = true ; <nl> + interface_ . EndControl ( this , current ) ; <nl> + } <nl> + <nl> + void SetBlockType ( Control * c , BlockTypeOperand < validate > & operand ) { <nl> + c - > merge . arity = operand . arity ; <nl> + if ( c - > merge . arity = = 1 ) { <nl> + c - > merge . vals . first = Value : : New ( this - > pc_ , operand . read_entry ( 0 ) ) ; <nl> + } else if ( c - > merge . arity > 1 ) { <nl> + c - > merge . vals . array = zone_ - > NewArray < Value > ( c - > merge . arity ) ; <nl> + for ( unsigned i = 0 ; i < c - > merge . arity ; i + + ) { <nl> + c - > merge . vals . array [ i ] = Value : : New ( this - > pc_ , operand . read_entry ( i ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / TODO ( clemensh ) : Better memory management . <nl> + void PopArgs ( FunctionSig * sig , std : : vector < Value > * result ) { <nl> + DCHECK ( result - > empty ( ) ) ; <nl> + int count = static_cast < int > ( sig - > parameter_count ( ) ) ; <nl> + result - > resize ( count ) ; <nl> + for ( int i = count - 1 ; i > = 0 ; - - i ) { <nl> + ( * result ) [ i ] = Pop ( i , sig - > GetParam ( i ) ) ; <nl> + } <nl> + } <nl> + <nl> + ValueType GetReturnType ( FunctionSig * sig ) { <nl> + DCHECK_GE ( 1 , sig - > return_count ( ) ) ; <nl> + return sig - > return_count ( ) = = 0 ? kWasmStmt : sig - > GetReturn ( ) ; <nl> + } <nl> + <nl> + Control * PushBlock ( ) { <nl> + control_ . emplace_back ( Control : : Block ( this - > pc_ , stack_ . size ( ) ) ) ; <nl> + return & control_ . back ( ) ; <nl> + } <nl> + <nl> + Control * PushLoop ( ) { <nl> + control_ . emplace_back ( Control : : Loop ( this - > pc_ , stack_ . size ( ) ) ) ; <nl> + return & control_ . back ( ) ; <nl> + } <nl> + <nl> + Control * PushIf ( ) { <nl> + control_ . emplace_back ( Control : : If ( this - > pc_ , stack_ . size ( ) ) ) ; <nl> + return & control_ . back ( ) ; <nl> + } <nl> + <nl> + Control * PushTry ( ) { <nl> + control_ . emplace_back ( Control : : Try ( this - > pc_ , stack_ . size ( ) ) ) ; <nl> + / / current_catch_ = static_cast < int32_t > ( control_ . size ( ) - 1 ) ; <nl> + return & control_ . back ( ) ; <nl> + } <nl> + <nl> + void PopControl ( Control * c ) { <nl> + DCHECK_EQ ( c , & control_ . back ( ) ) ; <nl> + interface_ . PopControl ( this , * c ) ; <nl> + control_ . pop_back ( ) ; <nl> + } <nl> + <nl> + int DecodeLoadMem ( ValueType type , MachineType mem_type ) { <nl> + if ( ! CheckHasMemory ( ) ) return 0 ; <nl> + MemoryAccessOperand < validate > operand ( <nl> + this , this - > pc_ , ElementSizeLog2Of ( mem_type . representation ( ) ) ) ; <nl> + <nl> + auto index = Pop ( 0 , kWasmI32 ) ; <nl> + auto * result = Push ( type ) ; <nl> + interface_ . LoadMem ( this , type , mem_type , operand , index , result ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + <nl> + int DecodeStoreMem ( ValueType type , MachineType mem_type ) { <nl> + if ( ! CheckHasMemory ( ) ) return 0 ; <nl> + MemoryAccessOperand < validate > operand ( <nl> + this , this - > pc_ , ElementSizeLog2Of ( mem_type . representation ( ) ) ) ; <nl> + auto value = Pop ( 1 , type ) ; <nl> + auto index = Pop ( 0 , kWasmI32 ) ; <nl> + interface_ . StoreMem ( this , type , mem_type , operand , index , value ) ; <nl> + return 1 + operand . length ; <nl> + } <nl> + <nl> + int DecodePrefixedLoadMem ( ValueType type , MachineType mem_type ) { <nl> + if ( ! CheckHasMemory ( ) ) return 0 ; <nl> + MemoryAccessOperand < validate > operand ( <nl> + this , this - > pc_ + 1 , ElementSizeLog2Of ( mem_type . representation ( ) ) ) ; <nl> + <nl> + auto index = Pop ( 0 , kWasmI32 ) ; <nl> + auto * result = Push ( type ) ; <nl> + interface_ . LoadMem ( this , type , mem_type , operand , index , result ) ; <nl> + return operand . length ; <nl> + } <nl> + <nl> + int DecodePrefixedStoreMem ( ValueType type , MachineType mem_type ) { <nl> + if ( ! CheckHasMemory ( ) ) return 0 ; <nl> + MemoryAccessOperand < validate > operand ( <nl> + this , this - > pc_ + 1 , ElementSizeLog2Of ( mem_type . representation ( ) ) ) ; <nl> + auto value = Pop ( 1 , type ) ; <nl> + auto index = Pop ( 0 , kWasmI32 ) ; <nl> + interface_ . StoreMem ( this , type , mem_type , operand , index , value ) ; <nl> + return operand . length ; <nl> + } <nl> + <nl> + unsigned SimdExtractLane ( WasmOpcode opcode , ValueType type ) { <nl> + SimdLaneOperand < validate > operand ( this , this - > pc_ ) ; <nl> + if ( this - > Validate ( this - > pc_ , opcode , operand ) ) { <nl> + Value inputs [ ] = { Pop ( 0 , ValueType : : kSimd128 ) } ; <nl> + auto * result = Push ( type ) ; <nl> + interface_ . SimdLaneOp ( this , opcode , operand , ArrayVector ( inputs ) , result ) ; <nl> + } <nl> + return operand . length ; <nl> + } <nl> + <nl> + unsigned SimdReplaceLane ( WasmOpcode opcode , ValueType type ) { <nl> + SimdLaneOperand < validate > operand ( this , this - > pc_ ) ; <nl> + if ( this - > Validate ( this - > pc_ , opcode , operand ) ) { <nl> + Value inputs [ 2 ] ; <nl> + inputs [ 1 ] = Pop ( 1 , type ) ; <nl> + inputs [ 0 ] = Pop ( 0 , ValueType : : kSimd128 ) ; <nl> + auto * result = Push ( ValueType : : kSimd128 ) ; <nl> + interface_ . SimdLaneOp ( this , opcode , operand , ArrayVector ( inputs ) , result ) ; <nl> + } <nl> + return operand . length ; <nl> + } <nl> + <nl> + unsigned SimdShiftOp ( WasmOpcode opcode ) { <nl> + SimdShiftOperand < validate > operand ( this , this - > pc_ ) ; <nl> + if ( this - > Validate ( this - > pc_ , opcode , operand ) ) { <nl> + auto input = Pop ( 0 , ValueType : : kSimd128 ) ; <nl> + auto * result = Push ( ValueType : : kSimd128 ) ; <nl> + interface_ . SimdShiftOp ( this , opcode , operand , input , result ) ; <nl> + } <nl> + return operand . length ; <nl> + } <nl> + <nl> + unsigned Simd8x16ShuffleOp ( ) { <nl> + Simd8x16ShuffleOperand < validate > operand ( this , this - > pc_ ) ; <nl> + if ( this - > Validate ( this - > pc_ , operand ) ) { <nl> + auto input1 = Pop ( 1 , ValueType : : kSimd128 ) ; <nl> + auto input0 = Pop ( 0 , ValueType : : kSimd128 ) ; <nl> + auto * result = Push ( ValueType : : kSimd128 ) ; <nl> + interface_ . Simd8x16ShuffleOp ( this , operand , input0 , input1 , result ) ; <nl> + } <nl> + return 16 ; <nl> + } <nl> + <nl> + unsigned DecodeSimdOpcode ( WasmOpcode opcode ) { <nl> + unsigned len = 0 ; <nl> + switch ( opcode ) { <nl> + case kExprF32x4ExtractLane : { <nl> + len = SimdExtractLane ( opcode , ValueType : : kFloat32 ) ; <nl> + break ; <nl> + } <nl> + case kExprI32x4ExtractLane : <nl> + case kExprI16x8ExtractLane : <nl> + case kExprI8x16ExtractLane : { <nl> + len = SimdExtractLane ( opcode , ValueType : : kWord32 ) ; <nl> + break ; <nl> + } <nl> + case kExprF32x4ReplaceLane : { <nl> + len = SimdReplaceLane ( opcode , ValueType : : kFloat32 ) ; <nl> + break ; <nl> + } <nl> + case kExprI32x4ReplaceLane : <nl> + case kExprI16x8ReplaceLane : <nl> + case kExprI8x16ReplaceLane : { <nl> + len = SimdReplaceLane ( opcode , ValueType : : kWord32 ) ; <nl> + break ; <nl> + } <nl> + case kExprI32x4Shl : <nl> + case kExprI32x4ShrS : <nl> + case kExprI32x4ShrU : <nl> + case kExprI16x8Shl : <nl> + case kExprI16x8ShrS : <nl> + case kExprI16x8ShrU : <nl> + case kExprI8x16Shl : <nl> + case kExprI8x16ShrS : <nl> + case kExprI8x16ShrU : { <nl> + len = SimdShiftOp ( opcode ) ; <nl> + break ; <nl> + } <nl> + case kExprS8x16Shuffle : { <nl> + len = Simd8x16ShuffleOp ( ) ; <nl> + break ; <nl> + } <nl> + case kExprS128LoadMem : <nl> + len = DecodePrefixedLoadMem ( kWasmS128 , MachineType : : Simd128 ( ) ) ; <nl> + break ; <nl> + case kExprS128StoreMem : <nl> + len = DecodePrefixedStoreMem ( kWasmS128 , MachineType : : Simd128 ( ) ) ; <nl> + break ; <nl> + default : { <nl> + FunctionSig * sig = WasmOpcodes : : Signature ( opcode ) ; <nl> + if ( CHECK_ERROR ( sig = = nullptr ) ) { <nl> + this - > error ( " invalid simd opcode " ) ; <nl> + break ; <nl> + } <nl> + std : : vector < Value > args ; <nl> + PopArgs ( sig , & args ) ; <nl> + auto * result = <nl> + sig - > return_count ( ) = = 0 ? nullptr : Push ( GetReturnType ( sig ) ) ; <nl> + interface_ . SimdOp ( this , opcode , vec2vec ( args ) , result ) ; <nl> + } <nl> + } <nl> + return len ; <nl> + } <nl> + <nl> + unsigned DecodeAtomicOpcode ( WasmOpcode opcode ) { <nl> + unsigned len = 0 ; <nl> + FunctionSig * sig = WasmOpcodes : : AtomicSignature ( opcode ) ; <nl> + if ( sig ! = nullptr ) { <nl> + / / TODO ( clemensh ) : Better memory management here . <nl> + std : : vector < Value > args ( sig - > parameter_count ( ) ) ; <nl> + for ( int i = static_cast < int > ( sig - > parameter_count ( ) - 1 ) ; i > = 0 ; - - i ) { <nl> + args [ i ] = Pop ( i , sig - > GetParam ( i ) ) ; <nl> + } <nl> + auto * result = Push ( GetReturnType ( sig ) ) ; <nl> + interface_ . AtomicOp ( this , opcode , vec2vec ( args ) , result ) ; <nl> + } else { <nl> + this - > error ( " invalid atomic opcode " ) ; <nl> + } <nl> + return len ; <nl> + } <nl> + <nl> + void DoReturn ( ) { <nl> + / / TODO ( clemensh ) : Optimize memory usage here ( it will be mostly 0 or 1 <nl> + / / returned values ) . <nl> + int return_count = static_cast < int > ( this - > sig_ - > return_count ( ) ) ; <nl> + std : : vector < Value > values ( return_count ) ; <nl> + <nl> + / / Pop return values off the stack in reverse order . <nl> + for ( int i = return_count - 1 ; i > = 0 ; - - i ) { <nl> + values [ i ] = Pop ( i , this - > sig_ - > GetReturn ( i ) ) ; <nl> + } <nl> + <nl> + interface_ . DoReturn ( this , vec2vec ( values ) ) ; <nl> + EndControl ( ) ; <nl> + } <nl> + <nl> + inline Value * Push ( ValueType type ) { <nl> + DCHECK ( type ! = kWasmStmt ) ; <nl> + stack_ . push_back ( Value : : New ( this - > pc_ , type ) ) ; <nl> + return & stack_ . back ( ) ; <nl> + } <nl> + <nl> + void PushEndValues ( Control * c ) { <nl> + DCHECK_EQ ( c , & control_ . back ( ) ) ; <nl> + stack_ . resize ( c - > stack_depth ) ; <nl> + if ( c - > merge . arity = = 1 ) { <nl> + stack_ . push_back ( c - > merge . vals . first ) ; <nl> + } else { <nl> + for ( unsigned i = 0 ; i < c - > merge . arity ; i + + ) { <nl> + stack_ . push_back ( c - > merge . vals . array [ i ] ) ; <nl> + } <nl> + } <nl> + DCHECK_EQ ( c - > stack_depth + c - > merge . arity , stack_ . size ( ) ) ; <nl> + } <nl> + <nl> + Value * PushReturns ( FunctionSig * sig ) { <nl> + size_t return_count = sig - > return_count ( ) ; <nl> + if ( return_count = = 0 ) return nullptr ; <nl> + size_t old_size = stack_ . size ( ) ; <nl> + for ( size_t i = 0 ; i < return_count ; + + i ) { <nl> + Push ( sig - > GetReturn ( i ) ) ; <nl> + } <nl> + return stack_ . data ( ) + old_size ; <nl> + } <nl> + <nl> + Value Pop ( int index , ValueType expected ) { <nl> + auto val = Pop ( ) ; <nl> + if ( CHECK_ERROR ( val . type ! = expected & & val . type ! = kWasmVar & & <nl> + expected ! = kWasmVar ) ) { <nl> + this - > errorf ( val . pc , " % s [ % d ] expected type % s , found % s of type % s " , <nl> + SafeOpcodeNameAt ( this - > pc_ ) , index , <nl> + WasmOpcodes : : TypeName ( expected ) , SafeOpcodeNameAt ( val . pc ) , <nl> + WasmOpcodes : : TypeName ( val . type ) ) ; <nl> + } <nl> + return val ; <nl> + } <nl> + <nl> + Value Pop ( ) { <nl> + DCHECK ( ! control_ . empty ( ) ) ; <nl> + size_t limit = control_ . back ( ) . stack_depth ; <nl> + if ( stack_ . size ( ) < = limit ) { <nl> + / / Popping past the current control start in reachable code . <nl> + if ( CHECK_ERROR ( ! control_ . back ( ) . unreachable ) ) { <nl> + this - > errorf ( this - > pc_ , " % s found empty stack " , <nl> + SafeOpcodeNameAt ( this - > pc_ ) ) ; <nl> + } <nl> + return Value : : Unreachable ( this - > pc_ ) ; <nl> + } <nl> + auto val = stack_ . back ( ) ; <nl> + stack_ . pop_back ( ) ; <nl> + return val ; <nl> + } <nl> + <nl> + int startrel ( const byte * ptr ) { return static_cast < int > ( ptr - this - > start_ ) ; } <nl> + <nl> + bool TypeCheckBreak ( unsigned depth ) { <nl> + DCHECK ( validate ) ; / / Only call this for validation . <nl> + Control * c = control_at ( depth ) ; <nl> + if ( c - > is_loop ( ) ) { <nl> + / / This is the inner loop block , which does not have a value . <nl> + return true ; <nl> + } <nl> + size_t expected = control_ . back ( ) . stack_depth + c - > merge . arity ; <nl> + if ( stack_ . size ( ) < expected & & ! control_ . back ( ) . unreachable ) { <nl> + this - > errorf ( <nl> + this - > pc_ , <nl> + " expected at least % u values on the stack for br to @ % d , found % d " , <nl> + c - > merge . arity , startrel ( c - > pc ) , <nl> + static_cast < int > ( stack_ . size ( ) - c - > stack_depth ) ) ; <nl> + return false ; <nl> + } <nl> + <nl> + return TypeCheckMergeValues ( c ) ; <nl> + } <nl> + <nl> + void FallThruTo ( Control * c ) { <nl> + DCHECK_EQ ( c , & control_ . back ( ) ) ; <nl> + if ( ! TypeCheckFallThru ( c ) ) return ; <nl> + c - > unreachable = false ; <nl> + <nl> + interface_ . FallThruTo ( this , c ) ; <nl> + } <nl> + <nl> + bool TypeCheckMergeValues ( Control * c ) { <nl> + / / Typecheck the values left on the stack . <nl> + size_t avail = stack_ . size ( ) - c - > stack_depth ; <nl> + size_t start = avail > = c - > merge . arity ? 0 : c - > merge . arity - avail ; <nl> + for ( size_t i = start ; i < c - > merge . arity ; + + i ) { <nl> + auto & val = GetMergeValueFromStack ( c , i ) ; <nl> + auto & old = c - > merge [ i ] ; <nl> + if ( val . type ! = old . type & & val . type ! = kWasmVar ) { <nl> + this - > errorf ( <nl> + this - > pc_ , " type error in merge [ % zu ] ( expected % s , got % s ) " , i , <nl> + WasmOpcodes : : TypeName ( old . type ) , WasmOpcodes : : TypeName ( val . type ) ) ; <nl> + return false ; <nl> + } <nl> + } <nl> + <nl> + return true ; <nl> + } <nl> + <nl> + bool TypeCheckFallThru ( Control * c ) { <nl> + DCHECK_EQ ( c , & control_ . back ( ) ) ; <nl> + if ( ! validate ) return true ; <nl> + / / Fallthru must match arity exactly . <nl> + size_t expected = c - > stack_depth + c - > merge . arity ; <nl> + if ( stack_ . size ( ) ! = expected & & <nl> + ( stack_ . size ( ) > expected | | ! c - > unreachable ) ) { <nl> + this - > errorf ( this - > pc_ , <nl> + " expected % u elements on the stack for fallthru to @ % d " , <nl> + c - > merge . arity , startrel ( c - > pc ) ) ; <nl> + return false ; <nl> + } <nl> + <nl> + return TypeCheckMergeValues ( c ) ; <nl> + } <nl> + <nl> + virtual void onFirstError ( ) { <nl> + this - > end_ = this - > pc_ ; / / Terminate decoding loop . <nl> + TRACE ( " ! % s \ n " , this - > error_msg_ . c_str ( ) ) ; <nl> + } <nl> + <nl> + inline void BuildSimpleOperator ( WasmOpcode opcode , FunctionSig * sig ) { <nl> + switch ( sig - > parameter_count ( ) ) { <nl> + case 1 : { <nl> + auto val = Pop ( 0 , sig - > GetParam ( 0 ) ) ; <nl> + auto * ret = <nl> + sig - > return_count ( ) = = 0 ? nullptr : Push ( sig - > GetReturn ( 0 ) ) ; <nl> + interface_ . UnOp ( this , opcode , sig , val , ret ) ; <nl> + break ; <nl> + } <nl> + case 2 : { <nl> + auto rval = Pop ( 1 , sig - > GetParam ( 1 ) ) ; <nl> + auto lval = Pop ( 0 , sig - > GetParam ( 0 ) ) ; <nl> + auto * ret = <nl> + sig - > return_count ( ) = = 0 ? nullptr : Push ( sig - > GetReturn ( 0 ) ) ; <nl> + interface_ . BinOp ( this , opcode , sig , lval , rval , ret ) ; <nl> + break ; <nl> + } <nl> + default : <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + } <nl> + } ; <nl> + <nl> + template < bool decoder_validate , typename Interface > <nl> + class InterfaceTemplate { <nl> + public : <nl> + constexpr static bool validate = decoder_validate ; <nl> + using Decoder = WasmFullDecoder < validate , Interface > ; <nl> + using Control = AbstractControl < Interface > ; <nl> + using Value = AbstractValue < Interface > ; <nl> + using MergeValues = AbstractMerge < Interface > ; <nl> + } ; <nl> + <nl> + class EmptyInterface : public InterfaceTemplate < true , EmptyInterface > { <nl> + public : <nl> + struct IValue { <nl> + static IValue Unreachable ( ) { return { } ; } <nl> + static IValue New ( ) { return { } ; } <nl> + } ; <nl> + struct IControl { <nl> + static IControl Block ( ) { return { } ; } <nl> + static IControl If ( ) { return { } ; } <nl> + static IControl Loop ( ) { return { } ; } <nl> + static IControl Try ( ) { return { } ; } <nl> + } ; <nl> + <nl> + # define DEFINE_EMPTY_CALLBACK ( name , . . . ) \ <nl> + void name ( Decoder * decoder , # # __VA_ARGS__ ) { } <nl> + INTERFACE_FUNCTIONS ( DEFINE_EMPTY_CALLBACK ) <nl> + # undef DEFINE_EMPTY_CALLBACK <nl> + } ; <nl> + <nl> # undef CHECKED_COND <nl> + # undef VALIDATE <nl> + # undef CHECK_ERROR <nl> + # undef TRACE <nl> + # undef CHECK_PROTOTYPE_OPCODE <nl> + # undef PROTOTYPE_NOT_FUNCTIONAL <nl> <nl> } / / namespace wasm <nl> } / / namespace internal <nl> mmm a / src / wasm / function - body - decoder . cc <nl> ppp b / src / wasm / function - body - decoder . cc <nl> <nl> # include " src / signature . h " <nl> <nl> # include " src / base / platform / elapsed - timer . h " <nl> - # include " src / bit - vector . h " <nl> # include " src / flags . h " <nl> # include " src / handles . h " <nl> # include " src / objects - inl . h " <nl> namespace v8 { <nl> namespace internal { <nl> namespace wasm { <nl> <nl> - # if DEBUG <nl> - # define TRACE ( . . . ) \ <nl> - do { \ <nl> - if ( FLAG_trace_wasm_decoder ) PrintF ( __VA_ARGS__ ) ; \ <nl> - } while ( false ) <nl> - # else <nl> - # define TRACE ( . . . ) <nl> - # endif <nl> - <nl> - # define CHECK_PROTOTYPE_OPCODE ( flag ) \ <nl> - if ( module_ ! = nullptr & & module_ - > is_asm_js ( ) ) { \ <nl> - error ( " Opcode not supported for asmjs modules " ) ; \ <nl> - } \ <nl> - if ( ! FLAG_experimental_wasm_ # # flag ) { \ <nl> - error ( " Invalid opcode ( enable with - - experimental - wasm - " # flag " ) " ) ; \ <nl> - break ; \ <nl> - } <nl> - <nl> - # define OPCODE_ERROR ( opcode , message ) \ <nl> - ( errorf ( pc_ , " % s : % s " , WasmOpcodes : : OpcodeName ( opcode ) , ( message ) ) ) <nl> + namespace { <nl> <nl> / / An SsaEnv environment carries the current local variable renaming <nl> / / as well as the current effect and control dependency in the TF graph . <nl> struct SsaEnv { <nl> } <nl> } ; <nl> <nl> - / / An entry on the value stack . <nl> - struct Value { <nl> - const byte * pc ; <nl> - TFNode * node ; <nl> - ValueType type ; <nl> - } ; <nl> - <nl> - struct TryInfo : public ZoneObject { <nl> - SsaEnv * catch_env ; <nl> - TFNode * exception ; <nl> - size_t catch_count ; / / Number of catch blocks associated with the try . <nl> - <nl> - explicit TryInfo ( SsaEnv * c ) <nl> - : catch_env ( c ) , exception ( nullptr ) , catch_count ( 0 ) { } <nl> - } ; <nl> - <nl> - struct MergeValues { <nl> - uint32_t arity ; <nl> - union { <nl> - Value * array ; <nl> - Value first ; <nl> - } vals ; / / Either multiple values or a single value . <nl> - <nl> - Value & operator [ ] ( size_t i ) { <nl> - DCHECK_GT ( arity , i ) ; <nl> - return arity = = 1 ? vals . first : vals . array [ i ] ; <nl> - } <nl> - } ; <nl> - <nl> - static Value * NO_VALUE = nullptr ; <nl> - <nl> - enum ControlKind { kControlIf , kControlBlock , kControlLoop , kControlTry } ; <nl> - <nl> - / / An entry on the control stack ( i . e . if , block , loop ) . <nl> - struct Control { <nl> - const byte * pc ; <nl> - ControlKind kind ; <nl> - size_t stack_depth ; / / stack height at the beginning of the construct . <nl> - SsaEnv * end_env ; / / end environment for the construct . <nl> - SsaEnv * false_env ; / / false environment ( only for if ) . <nl> - TryInfo * try_info ; / / Information used for compiling try statements . <nl> - int32_t previous_catch ; / / The previous Control ( on the stack ) with a catch . <nl> - bool unreachable ; / / The current block has been ended . <nl> - <nl> - / / Values merged into the end of this control construct . <nl> - MergeValues merge ; <nl> - <nl> - inline bool is_if ( ) const { return kind = = kControlIf ; } <nl> - inline bool is_block ( ) const { return kind = = kControlBlock ; } <nl> - inline bool is_loop ( ) const { return kind = = kControlLoop ; } <nl> - inline bool is_try ( ) const { return kind = = kControlTry ; } <nl> - <nl> - / / Named constructors . <nl> - static Control Block ( const byte * pc , size_t stack_depth , SsaEnv * end_env , <nl> - int32_t previous_catch ) { <nl> - return { pc , kControlBlock , stack_depth , end_env , nullptr , <nl> - nullptr , previous_catch , false , { 0 , { NO_VALUE } } } ; <nl> - } <nl> - <nl> - static Control If ( const byte * pc , size_t stack_depth , SsaEnv * end_env , <nl> - SsaEnv * false_env , int32_t previous_catch ) { <nl> - return { pc , kControlIf , stack_depth , end_env , false_env , <nl> - nullptr , previous_catch , false , { 0 , { NO_VALUE } } } ; <nl> - } <nl> - <nl> - static Control Loop ( const byte * pc , size_t stack_depth , SsaEnv * end_env , <nl> - int32_t previous_catch ) { <nl> - return { pc , kControlLoop , stack_depth , end_env , nullptr , <nl> - nullptr , previous_catch , false , { 0 , { NO_VALUE } } } ; <nl> - } <nl> - <nl> - static Control Try ( const byte * pc , size_t stack_depth , SsaEnv * end_env , <nl> - Zone * zone , SsaEnv * catch_env , int32_t previous_catch ) { <nl> - DCHECK_NOT_NULL ( catch_env ) ; <nl> - TryInfo * try_info = new ( zone ) TryInfo ( catch_env ) ; <nl> - return { pc , kControlTry , stack_depth , end_env , nullptr , <nl> - try_info , previous_catch , false , { 0 , { NO_VALUE } } } ; <nl> - } <nl> - } ; <nl> - <nl> / / Macros that build nodes only if there is a graph and the current SSA <nl> / / environment is reachable from start . This avoids problems with malformed <nl> / / TF graphs when decoding inputs that have unreachable code . <nl> - # define BUILD ( func , . . . ) \ <nl> - ( build ( ) ? CheckForException ( builder_ - > func ( __VA_ARGS__ ) ) : nullptr ) <nl> - # define BUILD0 ( func ) ( build ( ) ? CheckForException ( builder_ - > func ( ) ) : nullptr ) <nl> + # define BUILD ( func , . . . ) \ <nl> + ( build ( decoder ) ? CheckForException ( decoder , builder_ - > func ( __VA_ARGS__ ) ) \ <nl> + : nullptr ) <nl> <nl> - / / Generic Wasm bytecode decoder with utilities for decoding operands , <nl> - / / lengths , etc . <nl> - class WasmDecoder : public Decoder { <nl> - public : <nl> - WasmDecoder ( const WasmModule * module , FunctionSig * sig , const byte * start , <nl> - const byte * end , uint32_t buffer_offset = 0 ) <nl> - : Decoder ( start , end , buffer_offset ) , <nl> - module_ ( module ) , <nl> - sig_ ( sig ) , <nl> - local_types_ ( nullptr ) { } <nl> - const WasmModule * module_ ; <nl> - FunctionSig * sig_ ; <nl> - <nl> - ZoneVector < ValueType > * local_types_ ; <nl> - <nl> - size_t total_locals ( ) const { <nl> - return local_types_ = = nullptr ? 0 : local_types_ - > size ( ) ; <nl> - } <nl> + constexpr uint32_t kNullCatch = static_cast < uint32_t > ( - 1 ) ; <nl> <nl> - static bool DecodeLocals ( Decoder * decoder , const FunctionSig * sig , <nl> - ZoneVector < ValueType > * type_list ) { <nl> - DCHECK_NOT_NULL ( type_list ) ; <nl> - DCHECK_EQ ( 0 , type_list - > size ( ) ) ; <nl> - / / Initialize from signature . <nl> - if ( sig ! = nullptr ) { <nl> - type_list - > assign ( sig - > parameters ( ) . begin ( ) , sig - > parameters ( ) . end ( ) ) ; <nl> - } <nl> - / / Decode local declarations , if any . <nl> - uint32_t entries = decoder - > consume_u32v ( " local decls count " ) ; <nl> - if ( decoder - > failed ( ) ) return false ; <nl> - <nl> - TRACE ( " local decls count : % u \ n " , entries ) ; <nl> - while ( entries - - > 0 & & decoder - > ok ( ) & & decoder - > more ( ) ) { <nl> - uint32_t count = decoder - > consume_u32v ( " local count " ) ; <nl> - if ( decoder - > failed ( ) ) return false ; <nl> - <nl> - if ( ( count + type_list - > size ( ) ) > kV8MaxWasmFunctionLocals ) { <nl> - decoder - > error ( decoder - > pc ( ) - 1 , " local count too large " ) ; <nl> - return false ; <nl> - } <nl> - byte code = decoder - > consume_u8 ( " local type " ) ; <nl> - if ( decoder - > failed ( ) ) return false ; <nl> - <nl> - ValueType type ; <nl> - switch ( code ) { <nl> - case kLocalI32 : <nl> - type = kWasmI32 ; <nl> - break ; <nl> - case kLocalI64 : <nl> - type = kWasmI64 ; <nl> - break ; <nl> - case kLocalF32 : <nl> - type = kWasmF32 ; <nl> - break ; <nl> - case kLocalF64 : <nl> - type = kWasmF64 ; <nl> - break ; <nl> - case kLocalS128 : <nl> - type = kWasmS128 ; <nl> - break ; <nl> - default : <nl> - decoder - > error ( decoder - > pc ( ) - 1 , " invalid local type " ) ; <nl> - return false ; <nl> - } <nl> - type_list - > insert ( type_list - > end ( ) , count , type ) ; <nl> - } <nl> - DCHECK ( decoder - > ok ( ) ) ; <nl> - return true ; <nl> - } <nl> + class WasmGraphBuildingInterface <nl> + : public InterfaceTemplate < true , WasmGraphBuildingInterface > { <nl> + public : <nl> + struct IValue { <nl> + TFNode * node ; <nl> <nl> - static BitVector * AnalyzeLoopAssignment ( Decoder * decoder , const byte * pc , <nl> - int locals_count , Zone * zone ) { <nl> - if ( pc > = decoder - > end ( ) ) return nullptr ; <nl> - if ( * pc ! = kExprLoop ) return nullptr ; <nl> - <nl> - BitVector * assigned = new ( zone ) BitVector ( locals_count , zone ) ; <nl> - int depth = 0 ; <nl> - / / Iteratively process all AST nodes nested inside the loop . <nl> - while ( pc < decoder - > end ( ) & & decoder - > ok ( ) ) { <nl> - WasmOpcode opcode = static_cast < WasmOpcode > ( * pc ) ; <nl> - unsigned length = 1 ; <nl> - switch ( opcode ) { <nl> - case kExprLoop : <nl> - case kExprIf : <nl> - case kExprBlock : <nl> - case kExprTry : <nl> - length = OpcodeLength ( decoder , pc ) ; <nl> - depth + + ; <nl> - break ; <nl> - case kExprSetLocal : / / fallthru <nl> - case kExprTeeLocal : { <nl> - LocalIndexOperand < true > operand ( decoder , pc ) ; <nl> - if ( assigned - > length ( ) > 0 & & <nl> - operand . index < static_cast < uint32_t > ( assigned - > length ( ) ) ) { <nl> - / / Unverified code might have an out - of - bounds index . <nl> - assigned - > Add ( operand . index ) ; <nl> - } <nl> - length = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprEnd : <nl> - depth - - ; <nl> - break ; <nl> - default : <nl> - length = OpcodeLength ( decoder , pc ) ; <nl> - break ; <nl> - } <nl> - if ( depth < = 0 ) break ; <nl> - pc + = length ; <nl> - } <nl> - return decoder - > ok ( ) ? assigned : nullptr ; <nl> - } <nl> + static IValue Unreachable ( ) { return { nullptr } ; } <nl> + static IValue New ( ) { return { nullptr } ; } <nl> + } ; <nl> <nl> - inline bool Validate ( const byte * pc , LocalIndexOperand < true > & operand ) { <nl> - if ( operand . index < total_locals ( ) ) { <nl> - if ( local_types_ ) { <nl> - operand . type = local_types_ - > at ( operand . index ) ; <nl> - } else { <nl> - operand . type = kWasmStmt ; <nl> - } <nl> - return true ; <nl> - } <nl> - errorf ( pc + 1 , " invalid local index : % u " , operand . index ) ; <nl> - return false ; <nl> - } <nl> + struct TryInfo : public ZoneObject { <nl> + SsaEnv * catch_env ; <nl> + TFNode * exception ; <nl> <nl> - inline bool Validate ( const byte * pc , ExceptionIndexOperand < true > & operand ) { <nl> - if ( module_ ! = nullptr & & operand . index < module_ - > exceptions . size ( ) ) { <nl> - operand . exception = & module_ - > exceptions [ operand . index ] ; <nl> - return true ; <nl> - } <nl> - errorf ( pc + 1 , " Invalid exception index : % u " , operand . index ) ; <nl> - return false ; <nl> - } <nl> + explicit TryInfo ( SsaEnv * c ) : catch_env ( c ) , exception ( nullptr ) { } <nl> + } ; <nl> <nl> - inline bool Validate ( const byte * pc , GlobalIndexOperand < true > & operand ) { <nl> - if ( module_ ! = nullptr & & operand . index < module_ - > globals . size ( ) ) { <nl> - operand . global = & module_ - > globals [ operand . index ] ; <nl> - operand . type = operand . global - > type ; <nl> - return true ; <nl> - } <nl> - errorf ( pc + 1 , " invalid global index : % u " , operand . index ) ; <nl> - return false ; <nl> - } <nl> + struct IControl { <nl> + SsaEnv * end_env ; / / end environment for the construct . <nl> + SsaEnv * false_env ; / / false environment ( only for if ) . <nl> + TryInfo * try_info ; / / information used for compiling try statements . <nl> + int32_t previous_catch ; / / previous Control ( on the stack ) with a catch . <nl> <nl> - inline bool Complete ( const byte * pc , CallFunctionOperand < true > & operand ) { <nl> - if ( module_ ! = nullptr & & operand . index < module_ - > functions . size ( ) ) { <nl> - operand . sig = module_ - > functions [ operand . index ] . sig ; <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> + static IControl Block ( ) { return { } ; } <nl> + static IControl If ( ) { return { } ; } <nl> + static IControl Loop ( ) { return { } ; } <nl> + static IControl Try ( ) { return { } ; } <nl> + } ; <nl> <nl> - inline bool Validate ( const byte * pc , CallFunctionOperand < true > & operand ) { <nl> - if ( Complete ( pc , operand ) ) { <nl> - return true ; <nl> - } <nl> - errorf ( pc + 1 , " invalid function index : % u " , operand . index ) ; <nl> - return false ; <nl> - } <nl> + explicit WasmGraphBuildingInterface ( TFBuilder * builder ) : builder_ ( builder ) { } <nl> <nl> - inline bool Complete ( const byte * pc , CallIndirectOperand < true > & operand ) { <nl> - if ( module_ ! = nullptr & & operand . index < module_ - > signatures . size ( ) ) { <nl> - operand . sig = module_ - > signatures [ operand . index ] ; <nl> - return true ; <nl> - } <nl> - return false ; <nl> - } <nl> + void StartFunction ( Decoder * decoder ) { <nl> + SsaEnv * ssa_env = <nl> + reinterpret_cast < SsaEnv * > ( decoder - > zone ( ) - > New ( sizeof ( SsaEnv ) ) ) ; <nl> + uint32_t env_count = decoder - > NumLocals ( ) ; <nl> + size_t size = sizeof ( TFNode * ) * env_count ; <nl> + ssa_env - > state = SsaEnv : : kReached ; <nl> + ssa_env - > locals = <nl> + size > 0 ? reinterpret_cast < TFNode * * > ( decoder - > zone ( ) - > New ( size ) ) <nl> + : nullptr ; <nl> <nl> - inline bool Validate ( const byte * pc , CallIndirectOperand < true > & operand ) { <nl> - if ( module_ = = nullptr | | module_ - > function_tables . empty ( ) ) { <nl> - error ( " function table has to exist to execute call_indirect " ) ; <nl> - return false ; <nl> + TFNode * start = <nl> + builder_ - > Start ( static_cast < int > ( decoder - > sig_ - > parameter_count ( ) + 1 ) ) ; <nl> + / / Initialize local variables . <nl> + uint32_t index = 0 ; <nl> + for ( ; index < decoder - > sig_ - > parameter_count ( ) ; + + index ) { <nl> + ssa_env - > locals [ index ] = builder_ - > Param ( index ) ; <nl> } <nl> - if ( Complete ( pc , operand ) ) { <nl> - return true ; <nl> + while ( index < env_count ) { <nl> + ValueType type = decoder - > GetLocalType ( index ) ; <nl> + TFNode * node = DefaultValue ( type ) ; <nl> + while ( index < env_count & & decoder - > GetLocalType ( index ) = = type ) { <nl> + / / Do a whole run of like - typed locals at a time . <nl> + ssa_env - > locals [ index + + ] = node ; <nl> + } <nl> } <nl> - errorf ( pc + 1 , " invalid signature index : # % u " , operand . index ) ; <nl> - return false ; <nl> + ssa_env - > control = start ; <nl> + ssa_env - > effect = start ; <nl> + SetEnv ( ssa_env ) ; <nl> } <nl> <nl> - inline bool Validate ( const byte * pc , BreakDepthOperand < true > & operand , <nl> - ZoneVector < Control > & control ) { <nl> - if ( operand . depth < control . size ( ) ) { <nl> - operand . target = & control [ control . size ( ) - operand . depth - 1 ] ; <nl> - return true ; <nl> - } <nl> - errorf ( pc + 1 , " invalid break depth : % u " , operand . depth ) ; <nl> - return false ; <nl> + void StartFunctionBody ( Decoder * decoder , Control * block ) { <nl> + SsaEnv * break_env = ssa_env_ ; <nl> + SetEnv ( Steal ( decoder - > zone ( ) , break_env ) ) ; <nl> + block - > interface_data . end_env = break_env ; <nl> } <nl> <nl> - bool Validate ( const byte * pc , BranchTableOperand < true > & operand , <nl> - size_t block_depth ) { <nl> - if ( operand . table_count > = kV8MaxWasmFunctionSize ) { <nl> - errorf ( pc + 1 , " invalid table count ( > max function size ) : % u " , <nl> - operand . table_count ) ; <nl> - return false ; <nl> - } <nl> - return checkAvailable ( operand . table_count ) ; <nl> + void FinishFunction ( Decoder * decoder ) { <nl> + builder_ - > PatchInStackCheckIfNeeded ( ) ; <nl> } <nl> <nl> - inline bool Validate ( const byte * pc , WasmOpcode opcode , <nl> - SimdLaneOperand < true > & operand ) { <nl> - uint8_t num_lanes = 0 ; <nl> - switch ( opcode ) { <nl> - case kExprF32x4ExtractLane : <nl> - case kExprF32x4ReplaceLane : <nl> - case kExprI32x4ExtractLane : <nl> - case kExprI32x4ReplaceLane : <nl> - num_lanes = 4 ; <nl> - break ; <nl> - case kExprI16x8ExtractLane : <nl> - case kExprI16x8ReplaceLane : <nl> - num_lanes = 8 ; <nl> - break ; <nl> - case kExprI8x16ExtractLane : <nl> - case kExprI8x16ReplaceLane : <nl> - num_lanes = 16 ; <nl> - break ; <nl> - default : <nl> - UNREACHABLE ( ) ; <nl> - break ; <nl> - } <nl> - if ( operand . lane < 0 | | operand . lane > = num_lanes ) { <nl> - error ( pc_ + 2 , " invalid lane index " ) ; <nl> - return false ; <nl> - } else { <nl> - return true ; <nl> - } <nl> + void Block ( Decoder * decoder , Control * block ) { <nl> + / / The break environment is the outer environment . <nl> + block - > interface_data . end_env = ssa_env_ ; <nl> + SetEnv ( Steal ( decoder - > zone ( ) , ssa_env_ ) ) ; <nl> } <nl> <nl> - inline bool Validate ( const byte * pc , WasmOpcode opcode , <nl> - SimdShiftOperand < true > & operand ) { <nl> - uint8_t max_shift = 0 ; <nl> - switch ( opcode ) { <nl> - case kExprI32x4Shl : <nl> - case kExprI32x4ShrS : <nl> - case kExprI32x4ShrU : <nl> - max_shift = 32 ; <nl> - break ; <nl> - case kExprI16x8Shl : <nl> - case kExprI16x8ShrS : <nl> - case kExprI16x8ShrU : <nl> - max_shift = 16 ; <nl> - break ; <nl> - case kExprI8x16Shl : <nl> - case kExprI8x16ShrS : <nl> - case kExprI8x16ShrU : <nl> - max_shift = 8 ; <nl> - break ; <nl> - default : <nl> - UNREACHABLE ( ) ; <nl> - break ; <nl> - } <nl> - if ( operand . shift < 0 | | operand . shift > = max_shift ) { <nl> - error ( pc_ + 2 , " invalid shift amount " ) ; <nl> - return false ; <nl> - } else { <nl> - return true ; <nl> - } <nl> + void Loop ( Decoder * decoder , Control * block ) { <nl> + SsaEnv * finish_try_env = Steal ( decoder - > zone ( ) , ssa_env_ ) ; <nl> + block - > interface_data . end_env = finish_try_env ; <nl> + / / The continue environment is the inner environment . <nl> + SetEnv ( PrepareForLoop ( decoder , finish_try_env ) ) ; <nl> + ssa_env_ - > SetNotMerged ( ) ; <nl> } <nl> <nl> - inline bool Validate ( const byte * pc , Simd8x16ShuffleOperand < true > & operand ) { <nl> - uint8_t max_lane = 0 ; <nl> - for ( uint32_t i = 0 ; i < kSimd128Size ; + + i ) <nl> - max_lane = std : : max ( max_lane , operand . shuffle [ i ] ) ; <nl> - / / Shuffle indices must be in [ 0 . . 31 ] for a 16 lane shuffle . <nl> - if ( max_lane > 2 * kSimd128Size ) { <nl> - error ( pc_ + 2 , " invalid shuffle mask " ) ; <nl> - return false ; <nl> - } else { <nl> - return true ; <nl> - } <nl> + void Try ( Decoder * decoder , Control * block ) { <nl> + SsaEnv * outer_env = ssa_env_ ; <nl> + SsaEnv * try_env = Steal ( decoder - > zone ( ) , outer_env ) ; <nl> + SsaEnv * catch_env = UnreachableEnv ( decoder - > zone ( ) ) ; <nl> + SetEnv ( try_env ) ; <nl> + TryInfo * try_info = new ( decoder - > zone ( ) ) TryInfo ( catch_env ) ; <nl> + block - > interface_data . end_env = outer_env ; <nl> + block - > interface_data . try_info = try_info ; <nl> + block - > interface_data . previous_catch = current_catch_ ; <nl> + current_catch_ = static_cast < int32_t > ( decoder - > control_depth ( ) - 1 ) ; <nl> } <nl> <nl> - static unsigned OpcodeLength ( Decoder * decoder , const byte * pc ) { <nl> - WasmOpcode opcode = static_cast < WasmOpcode > ( * pc ) ; <nl> - switch ( opcode ) { <nl> - # define DECLARE_OPCODE_CASE ( name , opcode , sig ) case kExpr # # name : <nl> - FOREACH_LOAD_MEM_OPCODE ( DECLARE_OPCODE_CASE ) <nl> - FOREACH_STORE_MEM_OPCODE ( DECLARE_OPCODE_CASE ) <nl> - # undef DECLARE_OPCODE_CASE <nl> - { <nl> - MemoryAccessOperand < true > operand ( decoder , pc , UINT32_MAX ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - case kExprBr : <nl> - case kExprBrIf : { <nl> - BreakDepthOperand < true > operand ( decoder , pc ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - case kExprSetGlobal : <nl> - case kExprGetGlobal : { <nl> - GlobalIndexOperand < true > operand ( decoder , pc ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - <nl> - case kExprCallFunction : { <nl> - CallFunctionOperand < true > operand ( decoder , pc ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - case kExprCallIndirect : { <nl> - CallIndirectOperand < true > operand ( decoder , pc ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - <nl> - case kExprTry : <nl> - case kExprIf : / / fall through <nl> - case kExprLoop : <nl> - case kExprBlock : { <nl> - BlockTypeOperand < true > operand ( decoder , pc ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - <nl> - case kExprThrow : <nl> - case kExprCatch : { <nl> - ExceptionIndexOperand < true > operand ( decoder , pc ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - <nl> - case kExprSetLocal : <nl> - case kExprTeeLocal : <nl> - case kExprGetLocal : { <nl> - LocalIndexOperand < true > operand ( decoder , pc ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - case kExprBrTable : { <nl> - BranchTableOperand < true > operand ( decoder , pc ) ; <nl> - BranchTableIterator < true > iterator ( decoder , operand ) ; <nl> - return 1 + iterator . length ( ) ; <nl> - } <nl> - case kExprI32Const : { <nl> - ImmI32Operand < true > operand ( decoder , pc ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - case kExprI64Const : { <nl> - ImmI64Operand < true > operand ( decoder , pc ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - case kExprGrowMemory : <nl> - case kExprMemorySize : { <nl> - MemoryIndexOperand < true > operand ( decoder , pc ) ; <nl> - return 1 + operand . length ; <nl> - } <nl> - case kExprF32Const : <nl> - return 5 ; <nl> - case kExprF64Const : <nl> - return 9 ; <nl> - case kSimdPrefix : { <nl> - byte simd_index = decoder - > read_u8 < true > ( pc + 1 , " simd_index " ) ; <nl> - WasmOpcode opcode = <nl> - static_cast < WasmOpcode > ( kSimdPrefix < < 8 | simd_index ) ; <nl> - switch ( opcode ) { <nl> - # define DECLARE_OPCODE_CASE ( name , opcode , sig ) case kExpr # # name : <nl> - FOREACH_SIMD_0_OPERAND_OPCODE ( DECLARE_OPCODE_CASE ) <nl> - # undef DECLARE_OPCODE_CASE <nl> - return 2 ; <nl> - # define DECLARE_OPCODE_CASE ( name , opcode , sig ) case kExpr # # name : <nl> - FOREACH_SIMD_1_OPERAND_OPCODE ( DECLARE_OPCODE_CASE ) <nl> - # undef DECLARE_OPCODE_CASE <nl> - return 3 ; <nl> - # define DECLARE_OPCODE_CASE ( name , opcode , sig ) case kExpr # # name : <nl> - FOREACH_SIMD_MEM_OPCODE ( DECLARE_OPCODE_CASE ) <nl> - # undef DECLARE_OPCODE_CASE <nl> - { <nl> - MemoryAccessOperand < true > operand ( decoder , pc + 1 , UINT32_MAX ) ; <nl> - return 2 + operand . length ; <nl> - } <nl> - / / Shuffles require a byte per lane , or 16 immediate bytes . <nl> - case kExprS8x16Shuffle : <nl> - return 2 + kSimd128Size ; <nl> - default : <nl> - decoder - > error ( pc , " invalid SIMD opcode " ) ; <nl> - return 2 ; <nl> - } <nl> - } <nl> - default : <nl> - return 1 ; <nl> - } <nl> + void If ( Decoder * decoder , const Value & cond , Control * if_block ) { <nl> + TFNode * if_true = nullptr ; <nl> + TFNode * if_false = nullptr ; <nl> + BUILD ( BranchNoHint , cond . interface_data . node , & if_true , & if_false ) ; <nl> + SsaEnv * end_env = ssa_env_ ; <nl> + SsaEnv * false_env = Split ( decoder , ssa_env_ ) ; <nl> + false_env - > control = if_false ; <nl> + SsaEnv * true_env = Steal ( decoder - > zone ( ) , ssa_env_ ) ; <nl> + true_env - > control = if_true ; <nl> + if_block - > interface_data . end_env = end_env ; <nl> + if_block - > interface_data . false_env = false_env ; <nl> + SetEnv ( true_env ) ; <nl> } <nl> <nl> - std : : pair < uint32_t , uint32_t > StackEffect ( const byte * pc ) { <nl> - WasmOpcode opcode = static_cast < WasmOpcode > ( * pc ) ; <nl> - / / Handle " simple " opcodes with a fixed signature first . <nl> - FunctionSig * sig = WasmOpcodes : : Signature ( opcode ) ; <nl> - if ( ! sig ) sig = WasmOpcodes : : AsmjsSignature ( opcode ) ; <nl> - if ( sig ) return { sig - > parameter_count ( ) , sig - > return_count ( ) } ; <nl> - if ( WasmOpcodes : : IsPrefixOpcode ( opcode ) ) { <nl> - opcode = static_cast < WasmOpcode > ( opcode < < 8 | * ( pc + 1 ) ) ; <nl> - } <nl> - <nl> - # define DECLARE_OPCODE_CASE ( name , opcode , sig ) case kExpr # # name : <nl> - / / clang - format off <nl> - switch ( opcode ) { <nl> - case kExprSelect : <nl> - return { 3 , 1 } ; <nl> - case kExprS128StoreMem : <nl> - FOREACH_STORE_MEM_OPCODE ( DECLARE_OPCODE_CASE ) <nl> - return { 2 , 0 } ; <nl> - case kExprS128LoadMem : <nl> - FOREACH_LOAD_MEM_OPCODE ( DECLARE_OPCODE_CASE ) <nl> - case kExprTeeLocal : <nl> - case kExprGrowMemory : <nl> - return { 1 , 1 } ; <nl> - case kExprSetLocal : <nl> - case kExprSetGlobal : <nl> - case kExprDrop : <nl> - case kExprBrIf : <nl> - case kExprBrTable : <nl> - case kExprIf : <nl> - return { 1 , 0 } ; <nl> - case kExprGetLocal : <nl> - case kExprGetGlobal : <nl> - case kExprI32Const : <nl> - case kExprI64Const : <nl> - case kExprF32Const : <nl> - case kExprF64Const : <nl> - case kExprMemorySize : <nl> - return { 0 , 1 } ; <nl> - case kExprCallFunction : { <nl> - CallFunctionOperand < true > operand ( this , pc ) ; <nl> - CHECK ( Complete ( pc , operand ) ) ; <nl> - return { operand . sig - > parameter_count ( ) , operand . sig - > return_count ( ) } ; <nl> - } <nl> - case kExprCallIndirect : { <nl> - CallIndirectOperand < true > operand ( this , pc ) ; <nl> - CHECK ( Complete ( pc , operand ) ) ; <nl> - / / Indirect calls pop an additional argument for the table index . <nl> - return { operand . sig - > parameter_count ( ) + 1 , <nl> - operand . sig - > return_count ( ) } ; <nl> - } <nl> - case kExprBr : <nl> - case kExprBlock : <nl> - case kExprLoop : <nl> - case kExprEnd : <nl> - case kExprElse : <nl> - case kExprNop : <nl> - case kExprReturn : <nl> - case kExprUnreachable : <nl> - return { 0 , 0 } ; <nl> - default : <nl> - V8_Fatal ( __FILE__ , __LINE__ , " unimplemented opcode : % x ( % s ) " , opcode , <nl> - WasmOpcodes : : OpcodeName ( opcode ) ) ; <nl> - return { 0 , 0 } ; <nl> - } <nl> - # undef DECLARE_OPCODE_CASE <nl> - / / clang - format on <nl> + void FallThruTo ( Decoder * decoder , Control * c ) { <nl> + MergeValuesInto ( decoder , c ) ; <nl> + SetEnv ( c - > interface_data . end_env ) ; <nl> } <nl> - } ; <nl> - <nl> - static const int32_t kNullCatch = - 1 ; <nl> - <nl> - / / The full wasm decoder for bytecode . Verifies bytecode and , optionally , <nl> - / / generates a TurboFan IR graph . <nl> - class WasmFullDecoder : public WasmDecoder { <nl> - public : <nl> - WasmFullDecoder ( Zone * zone , const wasm : : WasmModule * module , <nl> - const FunctionBody & body ) <nl> - : WasmFullDecoder ( zone , module , nullptr , body ) { } <nl> - <nl> - WasmFullDecoder ( Zone * zone , TFBuilder * builder , const FunctionBody & body ) <nl> - : WasmFullDecoder ( zone , builder - > module ( ) , builder , body ) { } <nl> - <nl> - bool Decode ( ) { <nl> - if ( FLAG_wasm_code_fuzzer_gen_test ) { <nl> - PrintRawWasmCode ( start_ , end_ ) ; <nl> - } <nl> - base : : ElapsedTimer decode_timer ; <nl> - if ( FLAG_trace_wasm_decode_time ) { <nl> - decode_timer . Start ( ) ; <nl> - } <nl> - stack_ . clear ( ) ; <nl> - control_ . clear ( ) ; <nl> - <nl> - if ( end_ < pc_ ) { <nl> - error ( " function body end < start " ) ; <nl> - return false ; <nl> - } <nl> <nl> - DCHECK_EQ ( 0 , local_types_ - > size ( ) ) ; <nl> - WasmDecoder : : DecodeLocals ( this , sig_ , local_types_ ) ; <nl> - InitSsaEnv ( ) ; <nl> - DecodeFunctionBody ( ) ; <nl> - FinishFunction ( ) ; <nl> - <nl> - if ( failed ( ) ) return TraceFailed ( ) ; <nl> - <nl> - if ( ! control_ . empty ( ) ) { <nl> - / / Generate a better error message whether the unterminated control <nl> - / / structure is the function body block or an innner structure . <nl> - if ( control_ . size ( ) > 1 ) { <nl> - error ( control_ . back ( ) . pc , " unterminated control structure " ) ; <nl> - } else { <nl> - error ( " function body must end with \ " end \ " opcode " ) ; <nl> - } <nl> - return TraceFailed ( ) ; <nl> + void PopControl ( Decoder * decoder , const Control & block ) { <nl> + if ( block . is_onearmed_if ( ) ) { <nl> + Goto ( decoder , block . interface_data . false_env , <nl> + block . interface_data . end_env ) ; <nl> + } else if ( block . is_try_catch ( ) ) { <nl> + SsaEnv * fallthru_ssa_env = ssa_env_ ; <nl> + DCHECK_NOT_NULL ( block . interface_data . try_info - > catch_env ) ; <nl> + SetEnv ( block . interface_data . try_info - > catch_env ) ; <nl> + BUILD ( Rethrow ) ; <nl> + / / TODO ( clemensh ) : Make this work again . <nl> + / / FallThruTo ( decoder , & block ) ; <nl> + SetEnv ( fallthru_ssa_env ) ; <nl> } <nl> - <nl> - if ( ! last_end_found_ ) { <nl> - error ( " function body must end with \ " end \ " opcode " ) ; <nl> - return false ; <nl> - } <nl> - <nl> - if ( FLAG_trace_wasm_decode_time ) { <nl> - double ms = decode_timer . Elapsed ( ) . InMillisecondsF ( ) ; <nl> - PrintF ( " wasm - decode % s ( % 0 . 3f ms ) \ n \ n " , ok ( ) ? " ok " : " failed " , ms ) ; <nl> - } else { <nl> - TRACE ( " wasm - decode % s \ n \ n " , ok ( ) ? " ok " : " failed " ) ; <nl> - } <nl> - <nl> - return true ; <nl> } <nl> <nl> - bool TraceFailed ( ) { <nl> - TRACE ( " wasm - error module + % - 6d func + % d : % s \ n \ n " , error_offset_ , <nl> - GetBufferRelativeOffset ( error_offset_ ) , error_msg_ . c_str ( ) ) ; <nl> - return false ; <nl> - } <nl> + void EndControl ( Decoder * decoder , Control * block ) { ssa_env_ - > Kill ( ) ; } <nl> <nl> - private : <nl> - WasmFullDecoder ( Zone * zone , const wasm : : WasmModule * module , <nl> - TFBuilder * builder , const FunctionBody & body ) <nl> - : WasmDecoder ( module , body . sig , body . start , body . end , body . offset ) , <nl> - zone_ ( zone ) , <nl> - builder_ ( builder ) , <nl> - local_type_vec_ ( zone ) , <nl> - stack_ ( zone ) , <nl> - control_ ( zone ) , <nl> - last_end_found_ ( false ) , <nl> - current_catch_ ( kNullCatch ) { <nl> - local_types_ = & local_type_vec_ ; <nl> + void UnOp ( Decoder * decoder , WasmOpcode opcode , FunctionSig * sig , <nl> + const Value & value , Value * result ) { <nl> + result - > interface_data . node = <nl> + BUILD ( Unop , opcode , value . interface_data . node , decoder - > position ( ) ) ; <nl> } <nl> <nl> - static const size_t kErrorMsgSize = 128 ; <nl> - <nl> - Zone * zone_ ; <nl> - TFBuilder * builder_ ; <nl> - <nl> - SsaEnv * ssa_env_ ; <nl> - <nl> - ZoneVector < ValueType > local_type_vec_ ; / / types of local variables . <nl> - ZoneVector < Value > stack_ ; / / stack of values . <nl> - ZoneVector < Control > control_ ; / / stack of blocks , loops , and ifs . <nl> - bool last_end_found_ ; <nl> - <nl> - int32_t current_catch_ ; <nl> - <nl> - TryInfo * current_try_info ( ) { return control_ [ current_catch_ ] . try_info ; } <nl> - <nl> - inline bool build ( ) { return builder_ & & ssa_env_ - > go ( ) ; } <nl> - <nl> - void InitSsaEnv ( ) { <nl> - TFNode * start = nullptr ; <nl> - SsaEnv * ssa_env = reinterpret_cast < SsaEnv * > ( zone_ - > New ( sizeof ( SsaEnv ) ) ) ; <nl> - size_t size = sizeof ( TFNode * ) * EnvironmentCount ( ) ; <nl> - ssa_env - > state = SsaEnv : : kReached ; <nl> - ssa_env - > locals = <nl> - size > 0 ? reinterpret_cast < TFNode * * > ( zone_ - > New ( size ) ) : nullptr ; <nl> - <nl> - if ( builder_ ) { <nl> - start = builder_ - > Start ( static_cast < int > ( sig_ - > parameter_count ( ) + 1 ) ) ; <nl> - / / Initialize local variables . <nl> - uint32_t index = 0 ; <nl> - while ( index < sig_ - > parameter_count ( ) ) { <nl> - ssa_env - > locals [ index ] = builder_ - > Param ( index ) ; <nl> - index + + ; <nl> - } <nl> - while ( index < local_type_vec_ . size ( ) ) { <nl> - ValueType type = local_type_vec_ [ index ] ; <nl> - TFNode * node = DefaultValue ( type ) ; <nl> - while ( index < local_type_vec_ . size ( ) & & <nl> - local_type_vec_ [ index ] = = type ) { <nl> - / / Do a whole run of like - typed locals at a time . <nl> - ssa_env - > locals [ index + + ] = node ; <nl> - } <nl> - } <nl> - } <nl> - ssa_env - > control = start ; <nl> - ssa_env - > effect = start ; <nl> - SetEnv ( " initial " , ssa_env ) ; <nl> + void BinOp ( Decoder * decoder , WasmOpcode opcode , FunctionSig * sig , <nl> + const Value & lhs , const Value & rhs , Value * result ) { <nl> + result - > interface_data . node = <nl> + BUILD ( Binop , opcode , lhs . interface_data . node , rhs . interface_data . node , <nl> + decoder - > position ( ) ) ; <nl> } <nl> <nl> - TFNode * DefaultValue ( ValueType type ) { <nl> - switch ( type ) { <nl> - case kWasmI32 : <nl> - return builder_ - > Int32Constant ( 0 ) ; <nl> - case kWasmI64 : <nl> - return builder_ - > Int64Constant ( 0 ) ; <nl> - case kWasmF32 : <nl> - return builder_ - > Float32Constant ( 0 ) ; <nl> - case kWasmF64 : <nl> - return builder_ - > Float64Constant ( 0 ) ; <nl> - case kWasmS128 : <nl> - return builder_ - > S128Zero ( ) ; <nl> - default : <nl> - UNREACHABLE ( ) ; <nl> - } <nl> + void I32Const ( Decoder * decoder , Value * result , int32_t value ) { <nl> + result - > interface_data . node = builder_ - > Int32Constant ( value ) ; <nl> } <nl> <nl> - bool CheckHasMemory ( ) { <nl> - if ( ! module_ - > has_memory ) { <nl> - error ( pc_ - 1 , " memory instruction with no memory " ) ; <nl> - } <nl> - return module_ - > has_memory ; <nl> + void I64Const ( Decoder * decoder , Value * result , int64_t value ) { <nl> + result - > interface_data . node = builder_ - > Int64Constant ( value ) ; <nl> } <nl> <nl> - template < bool check > <nl> - inline TFNode * GetExceptionTag ( ExceptionIndexOperand < check > & operand ) { <nl> - / / TODO ( kschimpf ) : Need to get runtime exception tag values . This <nl> - / / code only handles non - imported / exported exceptions . <nl> - return BUILD ( Int32Constant , operand . index ) ; <nl> + void F32Const ( Decoder * decoder , Value * result , float value ) { <nl> + result - > interface_data . node = builder_ - > Float32Constant ( value ) ; <nl> } <nl> <nl> - / / Decodes the body of a function . <nl> - void DecodeFunctionBody ( ) { <nl> - TRACE ( " wasm - decode % p . . . % p ( module + % u , % d bytes ) % s \ n " , <nl> - reinterpret_cast < const void * > ( start ( ) ) , <nl> - reinterpret_cast < const void * > ( end ( ) ) , pc_offset ( ) , <nl> - static_cast < int > ( end_ - start_ ) , builder_ ? " graph building " : " " ) ; <nl> - <nl> - { <nl> - / / Set up initial function block . <nl> - SsaEnv * break_env = ssa_env_ ; <nl> - SetEnv ( " initial env " , Steal ( break_env ) ) ; <nl> - PushBlock ( break_env ) ; <nl> - Control * c = & control_ . back ( ) ; <nl> - c - > merge . arity = static_cast < uint32_t > ( sig_ - > return_count ( ) ) ; <nl> - <nl> - if ( c - > merge . arity = = 1 ) { <nl> - c - > merge . vals . first = { pc_ , nullptr , sig_ - > GetReturn ( 0 ) } ; <nl> - } else if ( c - > merge . arity > 1 ) { <nl> - c - > merge . vals . array = zone_ - > NewArray < Value > ( c - > merge . arity ) ; <nl> - for ( unsigned i = 0 ; i < c - > merge . arity ; i + + ) { <nl> - c - > merge . vals . array [ i ] = { pc_ , nullptr , sig_ - > GetReturn ( i ) } ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - while ( pc_ < end_ ) { / / decoding loop . <nl> - unsigned len = 1 ; <nl> - WasmOpcode opcode = static_cast < WasmOpcode > ( * pc_ ) ; <nl> - # if DEBUG <nl> - if ( FLAG_trace_wasm_decoder & & ! WasmOpcodes : : IsPrefixOpcode ( opcode ) ) { <nl> - TRACE ( " @ % - 8d # % - 20s | " , startrel ( pc_ ) , <nl> - WasmOpcodes : : OpcodeName ( opcode ) ) ; <nl> - } <nl> - # endif <nl> - <nl> - FunctionSig * sig = WasmOpcodes : : Signature ( opcode ) ; <nl> - if ( sig ) { <nl> - BuildSimpleOperator ( opcode , sig ) ; <nl> - } else { <nl> - / / Complex bytecode . <nl> - switch ( opcode ) { <nl> - case kExprNop : <nl> - break ; <nl> - case kExprBlock : { <nl> - / / The break environment is the outer environment . <nl> - BlockTypeOperand < true > operand ( this , pc_ ) ; <nl> - SsaEnv * break_env = ssa_env_ ; <nl> - PushBlock ( break_env ) ; <nl> - SetEnv ( " block : start " , Steal ( break_env ) ) ; <nl> - SetBlockType ( & control_ . back ( ) , operand ) ; <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprRethrow : { <nl> - / / TODO ( kschimpf ) : Implement . <nl> - CHECK_PROTOTYPE_OPCODE ( eh ) ; <nl> - OPCODE_ERROR ( opcode , " not implemented yet " ) ; <nl> - break ; <nl> - } <nl> - case kExprThrow : { <nl> - CHECK_PROTOTYPE_OPCODE ( eh ) ; <nl> - ExceptionIndexOperand < true > operand ( this , pc_ ) ; <nl> - len = 1 + operand . length ; <nl> - if ( ! Validate ( pc_ , operand ) ) break ; <nl> - if ( operand . exception - > sig - > parameter_count ( ) > 0 ) { <nl> - / / TODO ( kschimpf ) : Fix to pull values off stack and build throw . <nl> - OPCODE_ERROR ( opcode , " can ' t handle exceptions with values yet " ) ; <nl> - break ; <nl> - } <nl> - BUILD ( Throw , GetExceptionTag ( operand ) ) ; <nl> - / / TODO ( titzer ) : Throw should end control , but currently we build a <nl> - / / ( reachable ) runtime call instead of connecting it directly to <nl> - / / end . <nl> - / / EndControl ( ) ; <nl> - break ; <nl> - } <nl> - case kExprTry : { <nl> - CHECK_PROTOTYPE_OPCODE ( eh ) ; <nl> - BlockTypeOperand < true > operand ( this , pc_ ) ; <nl> - SsaEnv * outer_env = ssa_env_ ; <nl> - SsaEnv * try_env = Steal ( outer_env ) ; <nl> - SsaEnv * catch_env = UnreachableEnv ( ) ; <nl> - PushTry ( outer_env , catch_env ) ; <nl> - SetEnv ( " try_catch : start " , try_env ) ; <nl> - SetBlockType ( & control_ . back ( ) , operand ) ; <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprCatch : { <nl> - / / TODO ( kschimpf ) : Fix to use type signature of exception . <nl> - CHECK_PROTOTYPE_OPCODE ( eh ) ; <nl> - ExceptionIndexOperand < true > operand ( this , pc_ ) ; <nl> - len = 1 + operand . length ; <nl> - <nl> - if ( ! Validate ( pc_ , operand ) ) break ; <nl> - <nl> - if ( control_ . empty ( ) ) { <nl> - error ( " catch does not match any try " ) ; <nl> - break ; <nl> - } <nl> - <nl> - Control * c = & control_ . back ( ) ; <nl> - DCHECK_NOT_NULL ( c - > try_info ) ; <nl> - <nl> - if ( ! c - > is_try ( ) ) { <nl> - error ( " catch does not match any try " ) ; <nl> - break ; <nl> - } <nl> - <nl> - if ( c - > try_info - > catch_count > 0 ) { <nl> - OPCODE_ERROR ( opcode , " multiple catch blocks not implemented " ) ; <nl> - break ; <nl> - } <nl> - + + c - > try_info - > catch_count ; <nl> - <nl> - FallThruTo ( c ) ; <nl> - stack_ . resize ( c - > stack_depth ) ; <nl> - <nl> - SsaEnv * catch_env = c - > try_info - > catch_env ; <nl> - SetEnv ( " catch : begin " , catch_env ) ; <nl> - <nl> - current_catch_ = c - > previous_catch ; <nl> - <nl> - / / Get the exception and see if wanted exception . <nl> - TFNode * exception_as_i32 = <nl> - BUILD ( Catch , c - > try_info - > exception , position ( ) ) ; <nl> - TFNode * exception_tag = GetExceptionTag ( operand ) ; <nl> - TFNode * compare_i32 = BUILD ( Binop , kExprI32Eq , exception_as_i32 , <nl> - exception_tag , position ( ) ) ; <nl> - TFNode * if_true = nullptr ; <nl> - TFNode * if_false = nullptr ; <nl> - BUILD ( BranchNoHint , compare_i32 , & if_true , & if_false ) ; <nl> - SsaEnv * end_env = ssa_env_ ; <nl> - SsaEnv * false_env = Split ( end_env ) ; <nl> - false_env - > control = if_false ; <nl> - SsaEnv * true_env = Steal ( ssa_env_ ) ; <nl> - true_env - > control = if_true ; <nl> - c - > try_info - > catch_env = false_env ; <nl> - SetEnv ( " Try : catch " , true_env ) ; <nl> - len = 1 + operand . length ; <nl> - / / TODO ( kschimpf ) : Add code to pop caught exception from isolate . <nl> - break ; <nl> - } <nl> - case kExprCatchAll : { <nl> - / / TODO ( kschimpf ) : Implement . <nl> - CHECK_PROTOTYPE_OPCODE ( eh ) ; <nl> - OPCODE_ERROR ( opcode , " not implemented yet " ) ; <nl> - break ; <nl> - } <nl> - case kExprLoop : { <nl> - BlockTypeOperand < true > operand ( this , pc_ ) ; <nl> - SsaEnv * finish_try_env = Steal ( ssa_env_ ) ; <nl> - / / The continue environment is the inner environment . <nl> - SsaEnv * loop_body_env = PrepareForLoop ( pc_ , finish_try_env ) ; <nl> - SetEnv ( " loop : start " , loop_body_env ) ; <nl> - ssa_env_ - > SetNotMerged ( ) ; <nl> - PushLoop ( finish_try_env ) ; <nl> - SetBlockType ( & control_ . back ( ) , operand ) ; <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprIf : { <nl> - / / Condition on top of stack . Split environments for branches . <nl> - BlockTypeOperand < true > operand ( this , pc_ ) ; <nl> - Value cond = Pop ( 0 , kWasmI32 ) ; <nl> - TFNode * if_true = nullptr ; <nl> - TFNode * if_false = nullptr ; <nl> - BUILD ( BranchNoHint , cond . node , & if_true , & if_false ) ; <nl> - SsaEnv * end_env = ssa_env_ ; <nl> - SsaEnv * false_env = Split ( ssa_env_ ) ; <nl> - false_env - > control = if_false ; <nl> - SsaEnv * true_env = Steal ( ssa_env_ ) ; <nl> - true_env - > control = if_true ; <nl> - PushIf ( end_env , false_env ) ; <nl> - SetEnv ( " if : true " , true_env ) ; <nl> - SetBlockType ( & control_ . back ( ) , operand ) ; <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprElse : { <nl> - if ( control_ . empty ( ) ) { <nl> - error ( " else does not match any if " ) ; <nl> - break ; <nl> - } <nl> - Control * c = & control_ . back ( ) ; <nl> - if ( ! c - > is_if ( ) ) { <nl> - error ( pc_ , " else does not match an if " ) ; <nl> - break ; <nl> - } <nl> - if ( c - > false_env = = nullptr ) { <nl> - error ( pc_ , " else already present for if " ) ; <nl> - break ; <nl> - } <nl> - FallThruTo ( c ) ; <nl> - stack_ . resize ( c - > stack_depth ) ; <nl> - / / Switch to environment for false branch . <nl> - SetEnv ( " if_else : false " , c - > false_env ) ; <nl> - c - > false_env = nullptr ; / / record that an else is already seen <nl> - break ; <nl> - } <nl> - case kExprEnd : { <nl> - if ( control_ . empty ( ) ) { <nl> - error ( " end does not match any if , try , or block " ) ; <nl> - return ; <nl> - } <nl> - const char * name = " block : end " ; <nl> - Control * c = & control_ . back ( ) ; <nl> - if ( c - > is_loop ( ) ) { <nl> - / / A loop just leaves the values on the stack . <nl> - TypeCheckFallThru ( c ) ; <nl> - if ( c - > unreachable ) PushEndValues ( c ) ; <nl> - PopControl ( ) ; <nl> - SetEnv ( " loop : end " , ssa_env_ ) ; <nl> - break ; <nl> - } <nl> - if ( c - > is_if ( ) ) { <nl> - if ( c - > false_env ! = nullptr ) { <nl> - / / End the true branch of a one - armed if . <nl> - Goto ( c - > false_env , c - > end_env ) ; <nl> - if ( ! c - > unreachable & & stack_ . size ( ) ! = c - > stack_depth ) { <nl> - error ( " end of if expected empty stack " ) ; <nl> - stack_ . resize ( c - > stack_depth ) ; <nl> - } <nl> - if ( c - > merge . arity > 0 ) { <nl> - error ( " non - void one - armed if " ) ; <nl> - } <nl> - name = " if : merge " ; <nl> - } else { <nl> - / / End the false branch of a two - armed if . <nl> - name = " if_else : merge " ; <nl> - } <nl> - } else if ( c - > is_try ( ) ) { <nl> - name = " try : end " ; <nl> - <nl> - / / validate that catch was seen . <nl> - if ( c - > try_info - > catch_count = = 0 ) { <nl> - error ( pc_ , " missing catch in try " ) ; <nl> - break ; <nl> - } <nl> - SsaEnv * fallthru_ssa_env = ssa_env_ ; <nl> - DCHECK_NOT_NULL ( c - > try_info - > catch_env ) ; <nl> - SetEnv ( " Catch fail " , c - > try_info - > catch_env ) ; <nl> - BUILD0 ( Rethrow ) ; <nl> - / / TODO ( karlschimpf ) : Why not use EndControl ( ) ? ( currently fails ) <nl> - FallThruTo ( c ) ; <nl> - SetEnv ( " Catch fallthru " , fallthru_ssa_env ) ; <nl> - } <nl> - FallThruTo ( c ) ; <nl> - SetEnv ( name , c - > end_env ) ; <nl> - PushEndValues ( c ) ; <nl> - <nl> - if ( control_ . size ( ) = = 1 ) { <nl> - / / If at the last ( implicit ) control , check we are at end . <nl> - if ( pc_ + 1 ! = end_ ) { <nl> - error ( pc_ + 1 , " trailing code after function end " ) ; <nl> - break ; <nl> - } <nl> - last_end_found_ = true ; <nl> - if ( ssa_env_ - > go ( ) ) { <nl> - / / The result of the block is the return value . <nl> - TRACE ( " @ % - 8d # xx : % - 20s | " , startrel ( pc_ ) , " ( implicit ) return " ) ; <nl> - DoReturn ( ) ; <nl> - TRACE ( " \ n " ) ; <nl> - } else { <nl> - TypeCheckFallThru ( c ) ; <nl> - } <nl> - } <nl> - PopControl ( ) ; <nl> - break ; <nl> - } <nl> - case kExprSelect : { <nl> - Value cond = Pop ( 2 , kWasmI32 ) ; <nl> - Value fval = Pop ( ) ; <nl> - Value tval = Pop ( 0 , fval . type ) ; <nl> - if ( build ( ) ) { <nl> - TFNode * controls [ 2 ] ; <nl> - builder_ - > BranchNoHint ( cond . node , & controls [ 0 ] , & controls [ 1 ] ) ; <nl> - TFNode * merge = builder_ - > Merge ( 2 , controls ) ; <nl> - TFNode * vals [ 2 ] = { tval . node , fval . node } ; <nl> - TFNode * phi = builder_ - > Phi ( tval . type , 2 , vals , merge ) ; <nl> - Push ( tval . type , phi ) ; <nl> - ssa_env_ - > control = merge ; <nl> - } else { <nl> - Push ( tval . type = = kWasmVar ? fval . type : tval . type , nullptr ) ; <nl> - } <nl> - break ; <nl> - } <nl> - case kExprBr : { <nl> - BreakDepthOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , operand , control_ ) ) { <nl> - BreakTo ( operand . depth ) ; <nl> - } <nl> - len = 1 + operand . length ; <nl> - EndControl ( ) ; <nl> - break ; <nl> - } <nl> - case kExprBrIf : { <nl> - BreakDepthOperand < true > operand ( this , pc_ ) ; <nl> - Value cond = Pop ( 0 , kWasmI32 ) ; <nl> - if ( ok ( ) & & Validate ( pc_ , operand , control_ ) ) { <nl> - SsaEnv * fenv = ssa_env_ ; <nl> - SsaEnv * tenv = Split ( fenv ) ; <nl> - fenv - > SetNotMerged ( ) ; <nl> - BUILD ( BranchNoHint , cond . node , & tenv - > control , & fenv - > control ) ; <nl> - ssa_env_ = tenv ; <nl> - BreakTo ( operand . depth ) ; <nl> - ssa_env_ = fenv ; <nl> - } <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprBrTable : { <nl> - BranchTableOperand < true > operand ( this , pc_ ) ; <nl> - BranchTableIterator < true > iterator ( this , operand ) ; <nl> - if ( Validate ( pc_ , operand , control_ . size ( ) ) ) { <nl> - Value key = Pop ( 0 , kWasmI32 ) ; <nl> - if ( failed ( ) ) break ; <nl> - <nl> - SsaEnv * break_env = ssa_env_ ; <nl> - if ( operand . table_count > 0 ) { <nl> - / / Build branches to the various blocks based on the table . <nl> - TFNode * sw = BUILD ( Switch , operand . table_count + 1 , key . node ) ; <nl> - <nl> - SsaEnv * copy = Steal ( break_env ) ; <nl> - ssa_env_ = copy ; <nl> - MergeValues * merge = nullptr ; <nl> - while ( ok ( ) & & iterator . has_next ( ) ) { <nl> - uint32_t i = iterator . cur_index ( ) ; <nl> - const byte * pos = iterator . pc ( ) ; <nl> - uint32_t target = iterator . next ( ) ; <nl> - if ( target > = control_ . size ( ) ) { <nl> - error ( pos , " improper branch in br_table " ) ; <nl> - break ; <nl> - } <nl> - ssa_env_ = Split ( copy ) ; <nl> - ssa_env_ - > control = ( i = = operand . table_count ) <nl> - ? BUILD ( IfDefault , sw ) <nl> - : BUILD ( IfValue , i , sw ) ; <nl> - BreakTo ( target ) ; <nl> - <nl> - / / Check that label types match up . <nl> - static MergeValues loop_dummy = { 0 , { nullptr } } ; <nl> - Control * c = & control_ [ control_ . size ( ) - target - 1 ] ; <nl> - MergeValues * current = c - > is_loop ( ) ? & loop_dummy : & c - > merge ; <nl> - if ( i = = 0 ) { <nl> - merge = current ; <nl> - } else if ( merge - > arity ! = current - > arity ) { <nl> - errorf ( pos , <nl> - " inconsistent arity in br_table target % d " <nl> - " ( previous was % u , this one % u ) " , <nl> - i , merge - > arity , current - > arity ) ; <nl> - } else if ( control_ . back ( ) . unreachable ) { <nl> - for ( uint32_t j = 0 ; ok ( ) & & j < merge - > arity ; + + j ) { <nl> - if ( ( * merge ) [ j ] . type ! = ( * current ) [ j ] . type ) { <nl> - errorf ( pos , <nl> - " type error in br_table target % d operand % d " <nl> - " ( previous expected % s , this one % s ) " , <nl> - i , j , WasmOpcodes : : TypeName ( ( * merge ) [ j ] . type ) , <nl> - WasmOpcodes : : TypeName ( ( * current ) [ j ] . type ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - if ( failed ( ) ) break ; <nl> - } else { <nl> - / / Only a default target . Do the equivalent of br . <nl> - const byte * pos = iterator . pc ( ) ; <nl> - uint32_t target = iterator . next ( ) ; <nl> - if ( target > = control_ . size ( ) ) { <nl> - error ( pos , " improper branch in br_table " ) ; <nl> - break ; <nl> - } <nl> - BreakTo ( target ) ; <nl> - } <nl> - / / br_table ends the control flow like br . <nl> - ssa_env_ = break_env ; <nl> - } <nl> - len = 1 + iterator . length ( ) ; <nl> - EndControl ( ) ; <nl> - break ; <nl> - } <nl> - case kExprReturn : { <nl> - DoReturn ( ) ; <nl> - break ; <nl> - } <nl> - case kExprUnreachable : { <nl> - BUILD ( Unreachable , position ( ) ) ; <nl> - EndControl ( ) ; <nl> - break ; <nl> - } <nl> - case kExprI32Const : { <nl> - ImmI32Operand < true > operand ( this , pc_ ) ; <nl> - Push ( kWasmI32 , BUILD ( Int32Constant , operand . value ) ) ; <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprI64Const : { <nl> - ImmI64Operand < true > operand ( this , pc_ ) ; <nl> - Push ( kWasmI64 , BUILD ( Int64Constant , operand . value ) ) ; <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprF32Const : { <nl> - ImmF32Operand < true > operand ( this , pc_ ) ; <nl> - Push ( kWasmF32 , BUILD ( Float32Constant , operand . value ) ) ; <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprF64Const : { <nl> - ImmF64Operand < true > operand ( this , pc_ ) ; <nl> - Push ( kWasmF64 , BUILD ( Float64Constant , operand . value ) ) ; <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprGetLocal : { <nl> - LocalIndexOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , operand ) ) { <nl> - if ( build ( ) ) { <nl> - Push ( operand . type , ssa_env_ - > locals [ operand . index ] ) ; <nl> - } else { <nl> - Push ( operand . type , nullptr ) ; <nl> - } <nl> - } <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprSetLocal : { <nl> - LocalIndexOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , operand ) ) { <nl> - Value val = Pop ( 0 , local_type_vec_ [ operand . index ] ) ; <nl> - if ( ssa_env_ - > locals ) ssa_env_ - > locals [ operand . index ] = val . node ; <nl> - } <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprTeeLocal : { <nl> - LocalIndexOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , operand ) ) { <nl> - Value val = Pop ( 0 , local_type_vec_ [ operand . index ] ) ; <nl> - if ( ssa_env_ - > locals ) ssa_env_ - > locals [ operand . index ] = val . node ; <nl> - Push ( val . type , val . node ) ; <nl> - } <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprDrop : { <nl> - Pop ( ) ; <nl> - break ; <nl> - } <nl> - case kExprGetGlobal : { <nl> - GlobalIndexOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , operand ) ) { <nl> - Push ( operand . type , BUILD ( GetGlobal , operand . index ) ) ; <nl> - } <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprSetGlobal : { <nl> - GlobalIndexOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , operand ) ) { <nl> - if ( operand . global - > mutability ) { <nl> - Value val = Pop ( 0 , operand . type ) ; <nl> - BUILD ( SetGlobal , operand . index , val . node ) ; <nl> - } else { <nl> - errorf ( pc_ , " immutable global # % u cannot be assigned " , <nl> - operand . index ) ; <nl> - } <nl> - } <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprI32LoadMem8S : <nl> - len = DecodeLoadMem ( kWasmI32 , MachineType : : Int8 ( ) ) ; <nl> - break ; <nl> - case kExprI32LoadMem8U : <nl> - len = DecodeLoadMem ( kWasmI32 , MachineType : : Uint8 ( ) ) ; <nl> - break ; <nl> - case kExprI32LoadMem16S : <nl> - len = DecodeLoadMem ( kWasmI32 , MachineType : : Int16 ( ) ) ; <nl> - break ; <nl> - case kExprI32LoadMem16U : <nl> - len = DecodeLoadMem ( kWasmI32 , MachineType : : Uint16 ( ) ) ; <nl> - break ; <nl> - case kExprI32LoadMem : <nl> - len = DecodeLoadMem ( kWasmI32 , MachineType : : Int32 ( ) ) ; <nl> - break ; <nl> - case kExprI64LoadMem8S : <nl> - len = DecodeLoadMem ( kWasmI64 , MachineType : : Int8 ( ) ) ; <nl> - break ; <nl> - case kExprI64LoadMem8U : <nl> - len = DecodeLoadMem ( kWasmI64 , MachineType : : Uint8 ( ) ) ; <nl> - break ; <nl> - case kExprI64LoadMem16S : <nl> - len = DecodeLoadMem ( kWasmI64 , MachineType : : Int16 ( ) ) ; <nl> - break ; <nl> - case kExprI64LoadMem16U : <nl> - len = DecodeLoadMem ( kWasmI64 , MachineType : : Uint16 ( ) ) ; <nl> - break ; <nl> - case kExprI64LoadMem32S : <nl> - len = DecodeLoadMem ( kWasmI64 , MachineType : : Int32 ( ) ) ; <nl> - break ; <nl> - case kExprI64LoadMem32U : <nl> - len = DecodeLoadMem ( kWasmI64 , MachineType : : Uint32 ( ) ) ; <nl> - break ; <nl> - case kExprI64LoadMem : <nl> - len = DecodeLoadMem ( kWasmI64 , MachineType : : Int64 ( ) ) ; <nl> - break ; <nl> - case kExprF32LoadMem : <nl> - len = DecodeLoadMem ( kWasmF32 , MachineType : : Float32 ( ) ) ; <nl> - break ; <nl> - case kExprF64LoadMem : <nl> - len = DecodeLoadMem ( kWasmF64 , MachineType : : Float64 ( ) ) ; <nl> - break ; <nl> - case kExprI32StoreMem8 : <nl> - len = DecodeStoreMem ( kWasmI32 , MachineType : : Int8 ( ) ) ; <nl> - break ; <nl> - case kExprI32StoreMem16 : <nl> - len = DecodeStoreMem ( kWasmI32 , MachineType : : Int16 ( ) ) ; <nl> - break ; <nl> - case kExprI32StoreMem : <nl> - len = DecodeStoreMem ( kWasmI32 , MachineType : : Int32 ( ) ) ; <nl> - break ; <nl> - case kExprI64StoreMem8 : <nl> - len = DecodeStoreMem ( kWasmI64 , MachineType : : Int8 ( ) ) ; <nl> - break ; <nl> - case kExprI64StoreMem16 : <nl> - len = DecodeStoreMem ( kWasmI64 , MachineType : : Int16 ( ) ) ; <nl> - break ; <nl> - case kExprI64StoreMem32 : <nl> - len = DecodeStoreMem ( kWasmI64 , MachineType : : Int32 ( ) ) ; <nl> - break ; <nl> - case kExprI64StoreMem : <nl> - len = DecodeStoreMem ( kWasmI64 , MachineType : : Int64 ( ) ) ; <nl> - break ; <nl> - case kExprF32StoreMem : <nl> - len = DecodeStoreMem ( kWasmF32 , MachineType : : Float32 ( ) ) ; <nl> - break ; <nl> - case kExprF64StoreMem : <nl> - len = DecodeStoreMem ( kWasmF64 , MachineType : : Float64 ( ) ) ; <nl> - break ; <nl> - case kExprGrowMemory : { <nl> - if ( ! CheckHasMemory ( ) ) break ; <nl> - MemoryIndexOperand < true > operand ( this , pc_ ) ; <nl> - DCHECK_NOT_NULL ( module_ ) ; <nl> - if ( module_ - > is_wasm ( ) ) { <nl> - Value val = Pop ( 0 , kWasmI32 ) ; <nl> - Push ( kWasmI32 , BUILD ( GrowMemory , val . node ) ) ; <nl> - } else { <nl> - error ( " grow_memory is not supported for asmjs modules " ) ; <nl> - } <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprMemorySize : { <nl> - if ( ! CheckHasMemory ( ) ) break ; <nl> - MemoryIndexOperand < true > operand ( this , pc_ ) ; <nl> - Push ( kWasmI32 , BUILD ( CurrentMemoryPages ) ) ; <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprCallFunction : { <nl> - CallFunctionOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , operand ) ) { <nl> - TFNode * * buffer = PopArgs ( operand . sig ) ; <nl> - TFNode * * rets = nullptr ; <nl> - BUILD ( CallDirect , operand . index , buffer , & rets , position ( ) ) ; <nl> - PushReturns ( operand . sig , rets ) ; <nl> - } <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kExprCallIndirect : { <nl> - CallIndirectOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , operand ) ) { <nl> - Value index = Pop ( 0 , kWasmI32 ) ; <nl> - TFNode * * buffer = PopArgs ( operand . sig ) ; <nl> - if ( buffer ) buffer [ 0 ] = index . node ; <nl> - TFNode * * rets = nullptr ; <nl> - BUILD ( CallIndirect , operand . index , buffer , & rets , position ( ) ) ; <nl> - PushReturns ( operand . sig , rets ) ; <nl> - } <nl> - len = 1 + operand . length ; <nl> - break ; <nl> - } <nl> - case kSimdPrefix : { <nl> - CHECK_PROTOTYPE_OPCODE ( simd ) ; <nl> - len + + ; <nl> - byte simd_index = read_u8 < true > ( pc_ + 1 , " simd index " ) ; <nl> - opcode = static_cast < WasmOpcode > ( opcode < < 8 | simd_index ) ; <nl> - TRACE ( " @ % - 4d # % - 20s | " , startrel ( pc_ ) , <nl> - WasmOpcodes : : OpcodeName ( opcode ) ) ; <nl> - len + = DecodeSimdOpcode ( opcode ) ; <nl> - break ; <nl> - } <nl> - case kAtomicPrefix : { <nl> - CHECK_PROTOTYPE_OPCODE ( threads ) ; <nl> - len + + ; <nl> - byte atomic_index = read_u8 < true > ( pc_ + 1 , " atomic index " ) ; <nl> - opcode = static_cast < WasmOpcode > ( opcode < < 8 | atomic_index ) ; <nl> - TRACE ( " @ % - 4d # % - 20s | " , startrel ( pc_ ) , <nl> - WasmOpcodes : : OpcodeName ( opcode ) ) ; <nl> - len + = DecodeAtomicOpcode ( opcode ) ; <nl> - break ; <nl> - } <nl> - default : { <nl> - / / Deal with special asmjs opcodes . <nl> - if ( module_ ! = nullptr & & module_ - > is_asm_js ( ) ) { <nl> - sig = WasmOpcodes : : AsmjsSignature ( opcode ) ; <nl> - if ( sig ) { <nl> - BuildSimpleOperator ( opcode , sig ) ; <nl> - } <nl> - } else { <nl> - error ( " Invalid opcode " ) ; <nl> - return ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> - # if DEBUG <nl> - if ( FLAG_trace_wasm_decoder ) { <nl> - PrintF ( " " ) ; <nl> - for ( size_t i = 0 ; i < control_ . size ( ) ; + + i ) { <nl> - Control * c = & control_ [ i ] ; <nl> - switch ( c - > kind ) { <nl> - case v8 : : internal : : wasm : : kControlIf : <nl> - PrintF ( " I " ) ; <nl> - break ; <nl> - case v8 : : internal : : wasm : : kControlBlock : <nl> - PrintF ( " B " ) ; <nl> - break ; <nl> - case v8 : : internal : : wasm : : kControlLoop : <nl> - PrintF ( " L " ) ; <nl> - break ; <nl> - case v8 : : internal : : wasm : : kControlTry : <nl> - PrintF ( " T " ) ; <nl> - break ; <nl> - default : <nl> - break ; <nl> - } <nl> - PrintF ( " % u " , c - > merge . arity ) ; <nl> - if ( c - > unreachable ) PrintF ( " * " ) ; <nl> - } <nl> - PrintF ( " | " ) ; <nl> - for ( size_t i = 0 ; i < stack_ . size ( ) ; + + i ) { <nl> - Value & val = stack_ [ i ] ; <nl> - WasmOpcode opcode = static_cast < WasmOpcode > ( * val . pc ) ; <nl> - if ( WasmOpcodes : : IsPrefixOpcode ( opcode ) ) { <nl> - opcode = static_cast < WasmOpcode > ( opcode < < 8 | * ( val . pc + 1 ) ) ; <nl> - } <nl> - PrintF ( " % c @ % d : % s " , WasmOpcodes : : ShortNameOf ( val . type ) , <nl> - static_cast < int > ( val . pc - start_ ) , <nl> - WasmOpcodes : : OpcodeName ( opcode ) ) ; <nl> - switch ( opcode ) { <nl> - case kExprI32Const : { <nl> - ImmI32Operand < true > operand ( this , val . pc ) ; <nl> - PrintF ( " [ % d ] " , operand . value ) ; <nl> - break ; <nl> - } <nl> - case kExprGetLocal : { <nl> - LocalIndexOperand < true > operand ( this , val . pc ) ; <nl> - PrintF ( " [ % u ] " , operand . index ) ; <nl> - break ; <nl> - } <nl> - case kExprSetLocal : / / fallthru <nl> - case kExprTeeLocal : { <nl> - LocalIndexOperand < true > operand ( this , val . pc ) ; <nl> - PrintF ( " [ % u ] " , operand . index ) ; <nl> - break ; <nl> - } <nl> - default : <nl> - break ; <nl> - } <nl> - if ( val . node = = nullptr ) PrintF ( " ? " ) ; <nl> - } <nl> - PrintF ( " \ n " ) ; <nl> - } <nl> - # endif <nl> - pc_ + = len ; <nl> - } / / end decode loop <nl> - if ( pc_ > end_ & & ok ( ) ) error ( " Beyond end of code " ) ; <nl> - } <nl> - <nl> - void FinishFunction ( ) { <nl> - if ( builder_ ) builder_ - > PatchInStackCheckIfNeeded ( ) ; <nl> + void F64Const ( Decoder * decoder , Value * result , double value ) { <nl> + result - > interface_data . node = builder_ - > Float64Constant ( value ) ; <nl> } <nl> <nl> - void EndControl ( ) { <nl> - ssa_env_ - > Kill ( SsaEnv : : kControlEnd ) ; <nl> - if ( ! control_ . empty ( ) ) { <nl> - stack_ . resize ( control_ . back ( ) . stack_depth ) ; <nl> - control_ . back ( ) . unreachable = true ; <nl> + void DoReturn ( Decoder * decoder , Vector < Value > values ) { <nl> + size_t num_values = values . size ( ) ; <nl> + TFNode * * buffer = GetNodes ( values ) ; <nl> + for ( size_t i = 0 ; i < num_values ; + + i ) { <nl> + buffer [ i ] = values [ i ] . interface_data . node ; <nl> } <nl> + BUILD ( Return , static_cast < unsigned > ( values . size ( ) ) , buffer ) ; <nl> } <nl> <nl> - void SetBlockType ( Control * c , BlockTypeOperand < true > & operand ) { <nl> - c - > merge . arity = operand . arity ; <nl> - if ( c - > merge . arity = = 1 ) { <nl> - c - > merge . vals . first = { pc_ , nullptr , operand . read_entry ( 0 ) } ; <nl> - } else if ( c - > merge . arity > 1 ) { <nl> - c - > merge . vals . array = zone_ - > NewArray < Value > ( c - > merge . arity ) ; <nl> - for ( unsigned i = 0 ; i < c - > merge . arity ; i + + ) { <nl> - c - > merge . vals . array [ i ] = { pc_ , nullptr , operand . read_entry ( i ) } ; <nl> - } <nl> - } <nl> + void GetLocal ( Decoder * decoder , Value * result , <nl> + const LocalIndexOperand < true > & operand ) { <nl> + if ( ! ssa_env_ - > locals ) return ; / / unreachable <nl> + result - > interface_data . node = ssa_env_ - > locals [ operand . index ] ; <nl> } <nl> <nl> - TFNode * * PopArgs ( FunctionSig * sig ) { <nl> - if ( build ( ) ) { <nl> - int count = static_cast < int > ( sig - > parameter_count ( ) ) ; <nl> - TFNode * * buffer = builder_ - > Buffer ( count + 1 ) ; <nl> - buffer [ 0 ] = nullptr ; / / reserved for code object or function index . <nl> - for ( int i = count - 1 ; i > = 0 ; i - - ) { <nl> - buffer [ i + 1 ] = Pop ( i , sig - > GetParam ( i ) ) . node ; <nl> - } <nl> - return buffer ; <nl> - } else { <nl> - int count = static_cast < int > ( sig - > parameter_count ( ) ) ; <nl> - for ( int i = count - 1 ; i > = 0 ; i - - ) { <nl> - Pop ( i , sig - > GetParam ( i ) ) ; <nl> - } <nl> - return nullptr ; <nl> - } <nl> + void SetLocal ( Decoder * decoder , const Value & value , <nl> + const LocalIndexOperand < true > & operand ) { <nl> + if ( ! ssa_env_ - > locals ) return ; / / unreachable <nl> + ssa_env_ - > locals [ operand . index ] = value . interface_data . node ; <nl> } <nl> <nl> - ValueType GetReturnType ( FunctionSig * sig ) { <nl> - return sig - > return_count ( ) = = 0 ? kWasmStmt : sig - > GetReturn ( ) ; <nl> + void TeeLocal ( Decoder * decoder , const Value & value , Value * result , <nl> + const LocalIndexOperand < true > & operand ) { <nl> + result - > interface_data . node = value . interface_data . node ; <nl> + if ( ! ssa_env_ - > locals ) return ; / / unreachable <nl> + ssa_env_ - > locals [ operand . index ] = value . interface_data . node ; <nl> } <nl> <nl> - void PushBlock ( SsaEnv * end_env ) { <nl> - control_ . emplace_back ( <nl> - Control : : Block ( pc_ , stack_ . size ( ) , end_env , current_catch_ ) ) ; <nl> + void GetGlobal ( Decoder * decoder , Value * result , <nl> + const GlobalIndexOperand < true > & operand ) { <nl> + result - > interface_data . node = BUILD ( GetGlobal , operand . index ) ; <nl> } <nl> <nl> - void PushLoop ( SsaEnv * end_env ) { <nl> - control_ . emplace_back ( <nl> - Control : : Loop ( pc_ , stack_ . size ( ) , end_env , current_catch_ ) ) ; <nl> + void SetGlobal ( Decoder * decoder , const Value & value , <nl> + const GlobalIndexOperand < true > & operand ) { <nl> + BUILD ( SetGlobal , operand . index , value . interface_data . node ) ; <nl> } <nl> <nl> - void PushIf ( SsaEnv * end_env , SsaEnv * false_env ) { <nl> - control_ . emplace_back ( <nl> - Control : : If ( pc_ , stack_ . size ( ) , end_env , false_env , current_catch_ ) ) ; <nl> + void Unreachable ( Decoder * decoder ) { <nl> + BUILD ( Unreachable , decoder - > position ( ) ) ; <nl> } <nl> <nl> - void PushTry ( SsaEnv * end_env , SsaEnv * catch_env ) { <nl> - control_ . emplace_back ( Control : : Try ( pc_ , stack_ . size ( ) , end_env , zone_ , <nl> - catch_env , current_catch_ ) ) ; <nl> - current_catch_ = static_cast < int32_t > ( control_ . size ( ) - 1 ) ; <nl> + void Select ( Decoder * decoder , const Value & cond , const Value & fval , <nl> + const Value & tval , Value * result ) { <nl> + TFNode * controls [ 2 ] ; <nl> + BUILD ( BranchNoHint , cond . interface_data . node , & controls [ 0 ] , & controls [ 1 ] ) ; <nl> + TFNode * merge = BUILD ( Merge , 2 , controls ) ; <nl> + TFNode * vals [ 2 ] = { tval . interface_data . node , fval . interface_data . node } ; <nl> + TFNode * phi = BUILD ( Phi , tval . type , 2 , vals , merge ) ; <nl> + result - > interface_data . node = phi ; <nl> + ssa_env_ - > control = merge ; <nl> } <nl> <nl> - void PopControl ( ) { control_ . pop_back ( ) ; } <nl> - <nl> - int DecodeLoadMem ( ValueType type , MachineType mem_type ) { <nl> - if ( ! CheckHasMemory ( ) ) return 0 ; <nl> - MemoryAccessOperand < true > operand ( <nl> - this , pc_ , ElementSizeLog2Of ( mem_type . representation ( ) ) ) ; <nl> - <nl> - Value index = Pop ( 0 , kWasmI32 ) ; <nl> - TFNode * node = BUILD ( LoadMem , type , mem_type , index . node , operand . offset , <nl> - operand . alignment , position ( ) ) ; <nl> - Push ( type , node ) ; <nl> - return 1 + operand . length ; <nl> + void BreakTo ( Decoder * decoder , Control * block ) { <nl> + if ( block - > is_loop ( ) ) { <nl> + Goto ( decoder , ssa_env_ , block - > interface_data . end_env ) ; <nl> + } else { <nl> + MergeValuesInto ( decoder , block ) ; <nl> + } <nl> + } <nl> + <nl> + void BrIf ( Decoder * decoder , const Value & cond , Control * block ) { <nl> + SsaEnv * fenv = ssa_env_ ; <nl> + SsaEnv * tenv = Split ( decoder , fenv ) ; <nl> + fenv - > SetNotMerged ( ) ; <nl> + BUILD ( BranchNoHint , cond . interface_data . node , & tenv - > control , <nl> + & fenv - > control ) ; <nl> + ssa_env_ = tenv ; <nl> + BreakTo ( decoder , block ) ; <nl> + ssa_env_ = fenv ; <nl> + } <nl> + <nl> + void BrTable ( Decoder * decoder , const BranchTableOperand < true > & operand , <nl> + const Value & key ) { <nl> + SsaEnv * break_env = ssa_env_ ; <nl> + / / Build branches to the various blocks based on the table . <nl> + TFNode * sw = <nl> + BUILD ( Switch , operand . table_count + 1 , key . interface_data . node ) ; <nl> + <nl> + SsaEnv * copy = Steal ( decoder - > zone ( ) , break_env ) ; <nl> + ssa_env_ = copy ; <nl> + BranchTableIterator < true > iterator ( decoder , operand ) ; <nl> + while ( iterator . has_next ( ) ) { <nl> + uint32_t i = iterator . cur_index ( ) ; <nl> + uint32_t target = iterator . next ( ) ; <nl> + ssa_env_ = Split ( decoder , copy ) ; <nl> + ssa_env_ - > control = ( i = = operand . table_count ) ? BUILD ( IfDefault , sw ) <nl> + : BUILD ( IfValue , i , sw ) ; <nl> + BreakTo ( decoder , decoder - > control_at ( target ) ) ; <nl> + } <nl> + DCHECK ( decoder - > ok ( ) ) ; <nl> + ssa_env_ = break_env ; <nl> } <nl> <nl> - int DecodeStoreMem ( ValueType type , MachineType mem_type ) { <nl> - if ( ! CheckHasMemory ( ) ) return 0 ; <nl> - MemoryAccessOperand < true > operand ( <nl> - this , pc_ , ElementSizeLog2Of ( mem_type . representation ( ) ) ) ; <nl> - Value val = Pop ( 1 , type ) ; <nl> - Value index = Pop ( 0 , kWasmI32 ) ; <nl> - BUILD ( StoreMem , mem_type , index . node , operand . offset , operand . alignment , <nl> - val . node , position ( ) , type ) ; <nl> - return 1 + operand . length ; <nl> + void Else ( Decoder * decoder , Control * if_block ) { <nl> + SetEnv ( if_block - > interface_data . false_env ) ; <nl> } <nl> <nl> - int DecodePrefixedLoadMem ( ValueType type , MachineType mem_type ) { <nl> - if ( ! CheckHasMemory ( ) ) return 0 ; <nl> - MemoryAccessOperand < true > operand ( <nl> - this , pc_ + 1 , ElementSizeLog2Of ( mem_type . representation ( ) ) ) ; <nl> - <nl> - Value index = Pop ( 0 , kWasmI32 ) ; <nl> - TFNode * node = BUILD ( LoadMem , type , mem_type , index . node , operand . offset , <nl> - operand . alignment , position ( ) ) ; <nl> - Push ( type , node ) ; <nl> - return operand . length ; <nl> + void LoadMem ( Decoder * decoder , ValueType type , MachineType mem_type , <nl> + const MemoryAccessOperand < true > & operand , const Value & index , <nl> + Value * result ) { <nl> + result - > interface_data . node = <nl> + BUILD ( LoadMem , type , mem_type , index . interface_data . node , <nl> + operand . offset , operand . alignment , decoder - > position ( ) ) ; <nl> } <nl> <nl> - int DecodePrefixedStoreMem ( ValueType type , MachineType mem_type ) { <nl> - if ( ! CheckHasMemory ( ) ) return 0 ; <nl> - MemoryAccessOperand < true > operand ( <nl> - this , pc_ + 1 , ElementSizeLog2Of ( mem_type . representation ( ) ) ) ; <nl> - Value val = Pop ( 1 , type ) ; <nl> - Value index = Pop ( 0 , kWasmI32 ) ; <nl> - BUILD ( StoreMem , mem_type , index . node , operand . offset , operand . alignment , <nl> - val . node , position ( ) , type ) ; <nl> - return operand . length ; <nl> + void StoreMem ( Decoder * decoder , ValueType type , MachineType mem_type , <nl> + const MemoryAccessOperand < true > & operand , const Value & index , <nl> + const Value & value ) { <nl> + BUILD ( StoreMem , mem_type , index . interface_data . node , operand . offset , <nl> + operand . alignment , value . interface_data . node , decoder - > position ( ) ) ; <nl> } <nl> <nl> - unsigned SimdExtractLane ( WasmOpcode opcode , ValueType type ) { <nl> - SimdLaneOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , opcode , operand ) ) { <nl> - compiler : : NodeVector inputs ( 1 , zone_ ) ; <nl> - inputs [ 0 ] = Pop ( 0 , ValueType : : kSimd128 ) . node ; <nl> - TFNode * node = BUILD ( SimdLaneOp , opcode , operand . lane , inputs . data ( ) ) ; <nl> - Push ( type , node ) ; <nl> - } <nl> - return operand . length ; <nl> + void CurrentMemoryPages ( Decoder * decoder , Value * result ) { <nl> + result - > interface_data . node = BUILD ( CurrentMemoryPages ) ; <nl> } <nl> <nl> - unsigned SimdReplaceLane ( WasmOpcode opcode , ValueType type ) { <nl> - SimdLaneOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , opcode , operand ) ) { <nl> - compiler : : NodeVector inputs ( 2 , zone_ ) ; <nl> - inputs [ 1 ] = Pop ( 1 , type ) . node ; <nl> - inputs [ 0 ] = Pop ( 0 , ValueType : : kSimd128 ) . node ; <nl> - TFNode * node = BUILD ( SimdLaneOp , opcode , operand . lane , inputs . data ( ) ) ; <nl> - Push ( ValueType : : kSimd128 , node ) ; <nl> - } <nl> - return operand . length ; <nl> + void GrowMemory ( Decoder * decoder , const Value & value , Value * result ) { <nl> + result - > interface_data . node = BUILD ( GrowMemory , value . interface_data . node ) ; <nl> } <nl> <nl> - unsigned SimdShiftOp ( WasmOpcode opcode ) { <nl> - SimdShiftOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , opcode , operand ) ) { <nl> - compiler : : NodeVector inputs ( 1 , zone_ ) ; <nl> - inputs [ 0 ] = Pop ( 0 , ValueType : : kSimd128 ) . node ; <nl> - TFNode * node = BUILD ( SimdShiftOp , opcode , operand . shift , inputs . data ( ) ) ; <nl> - Push ( ValueType : : kSimd128 , node ) ; <nl> - } <nl> - return operand . length ; <nl> + void CallDirect ( Decoder * decoder , const CallFunctionOperand < true > & operand , <nl> + const Value args [ ] , Value returns [ ] ) { <nl> + DoCall ( decoder , nullptr , operand , args , returns , false ) ; <nl> } <nl> <nl> - unsigned Simd8x16ShuffleOp ( ) { <nl> - Simd8x16ShuffleOperand < true > operand ( this , pc_ ) ; <nl> - if ( Validate ( pc_ , operand ) ) { <nl> - compiler : : NodeVector inputs ( 2 , zone_ ) ; <nl> - inputs [ 1 ] = Pop ( 1 , ValueType : : kSimd128 ) . node ; <nl> - inputs [ 0 ] = Pop ( 0 , ValueType : : kSimd128 ) . node ; <nl> - TFNode * node = BUILD ( Simd8x16ShuffleOp , operand . shuffle , inputs . data ( ) ) ; <nl> - Push ( ValueType : : kSimd128 , node ) ; <nl> - } <nl> - return 16 ; <nl> + void CallIndirect ( Decoder * decoder , const Value & index , <nl> + const CallIndirectOperand < true > & operand , <nl> + const Value args [ ] , Value returns [ ] ) { <nl> + DoCall ( decoder , index . interface_data . node , operand , args , returns , true ) ; <nl> } <nl> <nl> - unsigned DecodeSimdOpcode ( WasmOpcode opcode ) { <nl> - unsigned len = 0 ; <nl> - switch ( opcode ) { <nl> - case kExprF32x4ExtractLane : { <nl> - len = SimdExtractLane ( opcode , ValueType : : kFloat32 ) ; <nl> - break ; <nl> - } <nl> - case kExprI32x4ExtractLane : <nl> - case kExprI16x8ExtractLane : <nl> - case kExprI8x16ExtractLane : { <nl> - len = SimdExtractLane ( opcode , ValueType : : kWord32 ) ; <nl> - break ; <nl> - } <nl> - case kExprF32x4ReplaceLane : { <nl> - len = SimdReplaceLane ( opcode , ValueType : : kFloat32 ) ; <nl> - break ; <nl> - } <nl> - case kExprI32x4ReplaceLane : <nl> - case kExprI16x8ReplaceLane : <nl> - case kExprI8x16ReplaceLane : { <nl> - len = SimdReplaceLane ( opcode , ValueType : : kWord32 ) ; <nl> - break ; <nl> - } <nl> - case kExprI32x4Shl : <nl> - case kExprI32x4ShrS : <nl> - case kExprI32x4ShrU : <nl> - case kExprI16x8Shl : <nl> - case kExprI16x8ShrS : <nl> - case kExprI16x8ShrU : <nl> - case kExprI8x16Shl : <nl> - case kExprI8x16ShrS : <nl> - case kExprI8x16ShrU : { <nl> - len = SimdShiftOp ( opcode ) ; <nl> - break ; <nl> - } <nl> - case kExprS8x16Shuffle : { <nl> - len = Simd8x16ShuffleOp ( ) ; <nl> - break ; <nl> - } <nl> - case kExprS128LoadMem : <nl> - len = DecodePrefixedLoadMem ( kWasmS128 , MachineType : : Simd128 ( ) ) ; <nl> - break ; <nl> - case kExprS128StoreMem : <nl> - len = DecodePrefixedStoreMem ( kWasmS128 , MachineType : : Simd128 ( ) ) ; <nl> - break ; <nl> - default : { <nl> - FunctionSig * sig = WasmOpcodes : : Signature ( opcode ) ; <nl> - if ( sig ! = nullptr ) { <nl> - compiler : : NodeVector inputs ( sig - > parameter_count ( ) , zone_ ) ; <nl> - for ( size_t i = sig - > parameter_count ( ) ; i > 0 ; i - - ) { <nl> - Value val = Pop ( static_cast < int > ( i - 1 ) , sig - > GetParam ( i - 1 ) ) ; <nl> - inputs [ i - 1 ] = val . node ; <nl> - } <nl> - TFNode * node = BUILD ( SimdOp , opcode , inputs . data ( ) ) ; <nl> - Push ( GetReturnType ( sig ) , node ) ; <nl> - } else { <nl> - error ( " invalid simd opcode " ) ; <nl> - } <nl> - } <nl> - } <nl> - return len ; <nl> + void SimdOp ( Decoder * decoder , WasmOpcode opcode , Vector < Value > args , <nl> + Value * result ) { <nl> + TFNode * * inputs = GetNodes ( args ) ; <nl> + TFNode * node = BUILD ( SimdOp , opcode , inputs ) ; <nl> + if ( result ) result - > interface_data . node = node ; <nl> } <nl> <nl> - unsigned DecodeAtomicOpcode ( WasmOpcode opcode ) { <nl> - unsigned len = 0 ; <nl> - FunctionSig * sig = WasmOpcodes : : AtomicSignature ( opcode ) ; <nl> - if ( sig ! = nullptr ) { <nl> - compiler : : NodeVector inputs ( sig - > parameter_count ( ) , zone_ ) ; <nl> - for ( int i = static_cast < int > ( sig - > parameter_count ( ) - 1 ) ; i > = 0 ; - - i ) { <nl> - Value val = Pop ( i , sig - > GetParam ( i ) ) ; <nl> - inputs [ i ] = val . node ; <nl> - } <nl> - TFNode * node = BUILD ( AtomicOp , opcode , inputs , position ( ) ) ; <nl> - Push ( GetReturnType ( sig ) , node ) ; <nl> - } else { <nl> - error ( " invalid atomic opcode " ) ; <nl> - } <nl> - return len ; <nl> + void SimdLaneOp ( Decoder * decoder , WasmOpcode opcode , <nl> + const SimdLaneOperand < true > operand , Vector < Value > inputs , <nl> + Value * result ) { <nl> + TFNode * * nodes = GetNodes ( inputs ) ; <nl> + result - > interface_data . node = <nl> + BUILD ( SimdLaneOp , opcode , operand . lane , nodes ) ; <nl> } <nl> <nl> - void DoReturn ( ) { <nl> - int count = static_cast < int > ( sig_ - > return_count ( ) ) ; <nl> - TFNode * * buffer = nullptr ; <nl> - if ( build ( ) ) buffer = builder_ - > Buffer ( count ) ; <nl> - <nl> - / / Pop return values off the stack in reverse order . <nl> - for ( int i = count - 1 ; i > = 0 ; i - - ) { <nl> - Value val = Pop ( i , sig_ - > GetReturn ( i ) ) ; <nl> - if ( buffer ) buffer [ i ] = val . node ; <nl> - } <nl> - <nl> - BUILD ( Return , count , buffer ) ; <nl> - EndControl ( ) ; <nl> + void SimdShiftOp ( Decoder * decoder , WasmOpcode opcode , <nl> + const SimdShiftOperand < true > operand , const Value & input , <nl> + Value * result ) { <nl> + TFNode * inputs [ ] = { input . interface_data . node } ; <nl> + result - > interface_data . node = <nl> + BUILD ( SimdShiftOp , opcode , operand . shift , inputs ) ; <nl> } <nl> <nl> - void Push ( ValueType type , TFNode * node ) { <nl> - if ( type ! = kWasmStmt ) { <nl> - stack_ . push_back ( { pc_ , node , type } ) ; <nl> - } <nl> + void Simd8x16ShuffleOp ( Decoder * decoder , <nl> + const Simd8x16ShuffleOperand < true > & operand , <nl> + const Value & input0 , const Value & input1 , <nl> + Value * result ) { <nl> + TFNode * input_nodes [ ] = { input0 . interface_data . node , <nl> + input1 . interface_data . node } ; <nl> + result - > interface_data . node = <nl> + BUILD ( Simd8x16ShuffleOp , operand . shuffle , input_nodes ) ; <nl> } <nl> <nl> - void PushEndValues ( Control * c ) { <nl> - DCHECK_EQ ( c , & control_ . back ( ) ) ; <nl> - stack_ . resize ( c - > stack_depth ) ; <nl> - if ( c - > merge . arity = = 1 ) { <nl> - stack_ . push_back ( c - > merge . vals . first ) ; <nl> - } else { <nl> - for ( unsigned i = 0 ; i < c - > merge . arity ; i + + ) { <nl> - stack_ . push_back ( c - > merge . vals . array [ i ] ) ; <nl> - } <nl> - } <nl> - DCHECK_EQ ( c - > stack_depth + c - > merge . arity , stack_ . size ( ) ) ; <nl> + TFNode * GetExceptionTag ( Decoder * decoder , <nl> + const ExceptionIndexOperand < true > & operand ) { <nl> + / / TODO ( kschimpf ) : Need to get runtime exception tag values . This <nl> + / / code only handles non - imported / exported exceptions . <nl> + return BUILD ( Int32Constant , operand . index ) ; <nl> } <nl> <nl> - void PushReturns ( FunctionSig * sig , TFNode * * rets ) { <nl> - for ( size_t i = 0 ; i < sig - > return_count ( ) ; i + + ) { <nl> - / / When verifying only , then { rets } will be null , so push null . <nl> - Push ( sig - > GetReturn ( i ) , rets ? rets [ i ] : nullptr ) ; <nl> - } <nl> + void Throw ( Decoder * decoder , const ExceptionIndexOperand < true > & operand ) { <nl> + BUILD ( Throw , GetExceptionTag ( decoder , operand ) ) ; <nl> } <nl> <nl> - const char * SafeOpcodeNameAt ( const byte * pc ) { <nl> - if ( pc > = end_ ) return " < end > " ; <nl> - return WasmOpcodes : : OpcodeName ( static_cast < WasmOpcode > ( * pc ) ) ; <nl> - } <nl> + void Catch ( Decoder * decoder , const ExceptionIndexOperand < true > & operand , <nl> + Control * block ) { <nl> + DCHECK_NOT_NULL ( block - > interface_data . try_info ) ; <nl> + current_catch_ = block - > interface_data . previous_catch ; <nl> <nl> - Value Pop ( int index , ValueType expected ) { <nl> - Value val = Pop ( ) ; <nl> - if ( val . type ! = expected & & val . type ! = kWasmVar & & expected ! = kWasmVar ) { <nl> - errorf ( val . pc , " % s [ % d ] expected type % s , found % s of type % s " , <nl> - SafeOpcodeNameAt ( pc_ ) , index , WasmOpcodes : : TypeName ( expected ) , <nl> - SafeOpcodeNameAt ( val . pc ) , WasmOpcodes : : TypeName ( val . type ) ) ; <nl> - } <nl> - return val ; <nl> + / / Get the exception and see if wanted exception . <nl> + TFNode * exception_as_i32 = BUILD ( <nl> + Catch , block - > interface_data . try_info - > exception , decoder - > position ( ) ) ; <nl> + TFNode * exception_tag = GetExceptionTag ( decoder , operand ) ; <nl> + TFNode * compare_i32 = BUILD ( Binop , kExprI32Eq , exception_as_i32 , <nl> + exception_tag , decoder - > position ( ) ) ; <nl> + TFNode * if_true = nullptr ; <nl> + TFNode * if_false = nullptr ; <nl> + BUILD ( BranchNoHint , compare_i32 , & if_true , & if_false ) ; <nl> + SsaEnv * end_env = ssa_env_ ; <nl> + SsaEnv * false_env = Split ( decoder , end_env ) ; <nl> + false_env - > control = if_false ; <nl> + SsaEnv * true_env = Steal ( decoder - > zone ( ) , ssa_env_ ) ; <nl> + true_env - > control = if_true ; <nl> + block - > interface_data . try_info - > catch_env = false_env ; <nl> + SetEnv ( true_env ) ; <nl> + / / TODO ( kschimpf ) : Add code to pop caught exception from isolate . <nl> } <nl> <nl> - Value Pop ( ) { <nl> - size_t limit = control_ . empty ( ) ? 0 : control_ . back ( ) . stack_depth ; <nl> - if ( stack_ . size ( ) < = limit ) { <nl> - / / Popping past the current control start in reachable code . <nl> - Value val = { pc_ , nullptr , kWasmVar } ; <nl> - if ( ! control_ . back ( ) . unreachable ) { <nl> - errorf ( pc_ , " % s found empty stack " , SafeOpcodeNameAt ( pc_ ) ) ; <nl> - } <nl> - return val ; <nl> - } <nl> - Value val = stack_ . back ( ) ; <nl> - stack_ . pop_back ( ) ; <nl> - return val ; <nl> + void AtomicOp ( Decoder * decoder , WasmOpcode opcode , Vector < Value > args , <nl> + Value * result ) { <nl> + TFNode * * inputs = GetNodes ( args ) ; <nl> + TFNode * node = BUILD ( AtomicOp , opcode , inputs , decoder - > position ( ) ) ; <nl> + if ( result ) result - > interface_data . node = node ; <nl> } <nl> <nl> - int startrel ( const byte * ptr ) { return static_cast < int > ( ptr - start_ ) ; } <nl> - <nl> - void BreakTo ( unsigned depth ) { <nl> - Control * c = & control_ [ control_ . size ( ) - depth - 1 ] ; <nl> - if ( c - > is_loop ( ) ) { <nl> - / / This is the inner loop block , which does not have a value . <nl> - Goto ( ssa_env_ , c - > end_env ) ; <nl> - } else { <nl> - / / Merge the value ( s ) into the end of the block . <nl> - size_t expected = control_ . back ( ) . stack_depth + c - > merge . arity ; <nl> - if ( stack_ . size ( ) < expected & & ! control_ . back ( ) . unreachable ) { <nl> - errorf ( <nl> - pc_ , <nl> - " expected at least % u values on the stack for br to @ % d , found % d " , <nl> - c - > merge . arity , startrel ( c - > pc ) , <nl> - static_cast < int > ( stack_ . size ( ) - c - > stack_depth ) ) ; <nl> - return ; <nl> - } <nl> - MergeValuesInto ( c ) ; <nl> - } <nl> - } <nl> + private : <nl> + SsaEnv * ssa_env_ ; <nl> + TFBuilder * builder_ ; <nl> + uint32_t current_catch_ = kNullCatch ; <nl> <nl> - void FallThruTo ( Control * c ) { <nl> - DCHECK_EQ ( c , & control_ . back ( ) ) ; <nl> - / / Merge the value ( s ) into the end of the block . <nl> - size_t expected = c - > stack_depth + c - > merge . arity ; <nl> - if ( stack_ . size ( ) = = expected | | <nl> - ( stack_ . size ( ) < expected & & c - > unreachable ) ) { <nl> - MergeValuesInto ( c ) ; <nl> - c - > unreachable = false ; <nl> - return ; <nl> - } <nl> - errorf ( pc_ , " expected % u elements on the stack for fallthru to @ % d " , <nl> - c - > merge . arity , startrel ( c - > pc ) ) ; <nl> - } <nl> + bool build ( Decoder * decoder ) { return ssa_env_ - > go ( ) & & decoder - > ok ( ) ; } <nl> <nl> - inline Value & GetMergeValueFromStack ( Control * c , size_t i ) { <nl> - return stack_ [ stack_ . size ( ) - c - > merge . arity + i ] ; <nl> + TryInfo * current_try_info ( Decoder * decoder ) { <nl> + return decoder - > control_at ( decoder - > control_depth ( ) - 1 - current_catch_ ) <nl> + - > interface_data . try_info ; <nl> } <nl> <nl> - void TypeCheckFallThru ( Control * c ) { <nl> - DCHECK_EQ ( c , & control_ . back ( ) ) ; <nl> - / / Fallthru must match arity exactly . <nl> - int arity = static_cast < int > ( c - > merge . arity ) ; <nl> - if ( c - > stack_depth + arity < stack_ . size ( ) | | <nl> - ( c - > stack_depth + arity ! = stack_ . size ( ) & & ! c - > unreachable ) ) { <nl> - errorf ( pc_ , " expected % d elements on the stack for fallthru to @ % d " , <nl> - arity , startrel ( c - > pc ) ) ; <nl> - return ; <nl> - } <nl> - / / Typecheck the values left on the stack . <nl> - size_t avail = stack_ . size ( ) - c - > stack_depth ; <nl> - for ( size_t i = avail > = c - > merge . arity ? 0 : c - > merge . arity - avail ; <nl> - i < c - > merge . arity ; i + + ) { <nl> - Value & val = GetMergeValueFromStack ( c , i ) ; <nl> - Value & old = c - > merge [ i ] ; <nl> - if ( val . type ! = old . type ) { <nl> - errorf ( pc_ , " type error in merge [ % zu ] ( expected % s , got % s ) " , i , <nl> - WasmOpcodes : : TypeName ( old . type ) , <nl> - WasmOpcodes : : TypeName ( val . type ) ) ; <nl> - return ; <nl> - } <nl> + TFNode * * GetNodes ( Value * values , size_t count ) { <nl> + TFNode * * nodes = builder_ - > Buffer ( count ) ; <nl> + for ( size_t i = 0 ; i < count ; + + i ) { <nl> + nodes [ i ] = values [ i ] . interface_data . node ; <nl> } <nl> + return nodes ; <nl> } <nl> <nl> - void MergeValuesInto ( Control * c ) { <nl> - SsaEnv * target = c - > end_env ; <nl> - bool first = target - > state = = SsaEnv : : kUnreachable ; <nl> - bool reachable = ssa_env_ - > go ( ) ; <nl> - Goto ( ssa_env_ , target ) ; <nl> - <nl> - size_t avail = stack_ . size ( ) - control_ . back ( ) . stack_depth ; <nl> - for ( size_t i = avail > = c - > merge . arity ? 0 : c - > merge . arity - avail ; <nl> - i < c - > merge . arity ; i + + ) { <nl> - Value & val = GetMergeValueFromStack ( c , i ) ; <nl> - Value & old = c - > merge [ i ] ; <nl> - if ( val . type ! = old . type & & val . type ! = kWasmVar ) { <nl> - errorf ( pc_ , " type error in merge [ % zu ] ( expected % s , got % s ) " , i , <nl> - WasmOpcodes : : TypeName ( old . type ) , <nl> - WasmOpcodes : : TypeName ( val . type ) ) ; <nl> - return ; <nl> - } <nl> - if ( builder_ & & reachable ) { <nl> - DCHECK_NOT_NULL ( val . node ) ; <nl> - old . node = <nl> - first ? val . node : CreateOrMergeIntoPhi ( old . type , target - > control , <nl> - old . node , val . node ) ; <nl> - } <nl> - } <nl> + TFNode * * GetNodes ( Vector < Value > values ) { <nl> + return GetNodes ( values . start ( ) , values . size ( ) ) ; <nl> } <nl> <nl> - void SetEnv ( const char * reason , SsaEnv * env ) { <nl> + void SetEnv ( SsaEnv * env ) { <nl> # if DEBUG <nl> if ( FLAG_trace_wasm_decoder ) { <nl> char state = ' X ' ; <nl> class WasmFullDecoder : public WasmDecoder { <nl> break ; <nl> } <nl> } <nl> - PrintF ( " { set_env = % p , state = % c , reason = % s " , static_cast < void * > ( env ) , <nl> - state , reason ) ; <nl> + PrintF ( " { set_env = % p , state = % c " , static_cast < void * > ( env ) , state ) ; <nl> if ( env & & env - > control ) { <nl> PrintF ( " , control = " ) ; <nl> compiler : : WasmGraphBuilder : : PrintDebugName ( env - > control ) ; <nl> class WasmFullDecoder : public WasmDecoder { <nl> } <nl> # endif <nl> ssa_env_ = env ; <nl> - if ( builder_ ) { <nl> - builder_ - > set_control_ptr ( & env - > control ) ; <nl> - builder_ - > set_effect_ptr ( & env - > effect ) ; <nl> - } <nl> + builder_ - > set_control_ptr ( & env - > control ) ; <nl> + builder_ - > set_effect_ptr ( & env - > effect ) ; <nl> } <nl> <nl> - TFNode * CheckForException ( TFNode * node ) { <nl> - if ( node = = nullptr ) { <nl> - return nullptr ; <nl> - } <nl> + TFNode * CheckForException ( Decoder * decoder , TFNode * node ) { <nl> + if ( node = = nullptr ) return nullptr ; <nl> <nl> const bool inside_try_scope = current_catch_ ! = kNullCatch ; <nl> <nl> - if ( ! inside_try_scope ) { <nl> - return node ; <nl> - } <nl> + if ( ! inside_try_scope ) return node ; <nl> <nl> TFNode * if_success = nullptr ; <nl> TFNode * if_exception = nullptr ; <nl> class WasmFullDecoder : public WasmDecoder { <nl> return node ; <nl> } <nl> <nl> - SsaEnv * success_env = Steal ( ssa_env_ ) ; <nl> + SsaEnv * success_env = Steal ( decoder - > zone ( ) , ssa_env_ ) ; <nl> success_env - > control = if_success ; <nl> <nl> - SsaEnv * exception_env = Split ( success_env ) ; <nl> + SsaEnv * exception_env = Split ( decoder , success_env ) ; <nl> exception_env - > control = if_exception ; <nl> - TryInfo * try_info = current_try_info ( ) ; <nl> - Goto ( exception_env , try_info - > catch_env ) ; <nl> + TryInfo * try_info = current_try_info ( decoder ) ; <nl> + Goto ( decoder , exception_env , try_info - > catch_env ) ; <nl> TFNode * exception = try_info - > exception ; <nl> if ( exception = = nullptr ) { <nl> DCHECK_EQ ( SsaEnv : : kReached , try_info - > catch_env - > state ) ; <nl> class WasmFullDecoder : public WasmDecoder { <nl> try_info - > exception , if_exception ) ; <nl> } <nl> <nl> - SetEnv ( " if_success " , success_env ) ; <nl> + SetEnv ( success_env ) ; <nl> return node ; <nl> } <nl> <nl> - void Goto ( SsaEnv * from , SsaEnv * to ) { <nl> + TFNode * DefaultValue ( ValueType type ) { <nl> + switch ( type ) { <nl> + case kWasmI32 : <nl> + return builder_ - > Int32Constant ( 0 ) ; <nl> + case kWasmI64 : <nl> + return builder_ - > Int64Constant ( 0 ) ; <nl> + case kWasmF32 : <nl> + return builder_ - > Float32Constant ( 0 ) ; <nl> + case kWasmF64 : <nl> + return builder_ - > Float64Constant ( 0 ) ; <nl> + case kWasmS128 : <nl> + return builder_ - > S128Zero ( ) ; <nl> + default : <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + } <nl> + <nl> + void MergeValuesInto ( Decoder * decoder , Control * c ) { <nl> + if ( ! ssa_env_ - > go ( ) ) return ; <nl> + <nl> + SsaEnv * target = c - > interface_data . end_env ; <nl> + const bool first = target - > state = = SsaEnv : : kUnreachable ; <nl> + Goto ( decoder , ssa_env_ , target ) ; <nl> + <nl> + size_t avail = decoder - > stack_size ( ) - decoder - > control_at ( 0 ) - > stack_depth ; <nl> + size_t start = avail > = c - > merge . arity ? 0 : c - > merge . arity - avail ; <nl> + for ( size_t i = start ; i < c - > merge . arity ; + + i ) { <nl> + auto & val = decoder - > GetMergeValueFromStack ( c , i ) ; <nl> + auto & old = c - > merge [ i ] ; <nl> + DCHECK_NOT_NULL ( val . interface_data . node ) ; <nl> + / / TODO ( clemensh ) : Remove first . <nl> + DCHECK_EQ ( first , old . interface_data . node = = nullptr ) ; <nl> + DCHECK ( val . type = = old . type | | val . type = = kWasmVar ) ; <nl> + old . interface_data . node = <nl> + first ? val . interface_data . node <nl> + : CreateOrMergeIntoPhi ( old . type , target - > control , <nl> + old . interface_data . node , <nl> + val . interface_data . node ) ; <nl> + } <nl> + } <nl> + <nl> + void Goto ( Decoder * decoder , SsaEnv * from , SsaEnv * to ) { <nl> DCHECK_NOT_NULL ( to ) ; <nl> if ( ! from - > go ( ) ) return ; <nl> switch ( to - > state ) { <nl> class WasmFullDecoder : public WasmDecoder { <nl> } <nl> case SsaEnv : : kReached : { / / Create a new merge . <nl> to - > state = SsaEnv : : kMerged ; <nl> - if ( ! builder_ ) break ; <nl> / / Merge control . <nl> TFNode * controls [ ] = { to - > control , from - > control } ; <nl> TFNode * merge = builder_ - > Merge ( 2 , controls ) ; <nl> class WasmFullDecoder : public WasmDecoder { <nl> to - > effect = builder_ - > EffectPhi ( 2 , effects , merge ) ; <nl> } <nl> / / Merge SSA values . <nl> - for ( int i = EnvironmentCount ( ) - 1 ; i > = 0 ; i - - ) { <nl> + for ( int i = decoder - > NumLocals ( ) - 1 ; i > = 0 ; i - - ) { <nl> TFNode * a = to - > locals [ i ] ; <nl> TFNode * b = from - > locals [ i ] ; <nl> if ( a ! = b ) { <nl> TFNode * vals [ ] = { a , b } ; <nl> - to - > locals [ i ] = builder_ - > Phi ( local_type_vec_ [ i ] , 2 , vals , merge ) ; <nl> + to - > locals [ i ] = <nl> + builder_ - > Phi ( decoder - > GetLocalType ( i ) , 2 , vals , merge ) ; <nl> } <nl> } <nl> break ; <nl> } <nl> case SsaEnv : : kMerged : { <nl> - if ( ! builder_ ) break ; <nl> TFNode * merge = to - > control ; <nl> / / Extend the existing merge . <nl> builder_ - > AppendToMerge ( merge , from - > control ) ; <nl> class WasmFullDecoder : public WasmDecoder { <nl> to - > effect = builder_ - > EffectPhi ( count , effects , merge ) ; <nl> } <nl> / / Merge locals . <nl> - for ( int i = EnvironmentCount ( ) - 1 ; i > = 0 ; i - - ) { <nl> + for ( int i = decoder - > NumLocals ( ) - 1 ; i > = 0 ; i - - ) { <nl> TFNode * tnode = to - > locals [ i ] ; <nl> TFNode * fnode = from - > locals [ i ] ; <nl> if ( builder_ - > IsPhiWithMerge ( tnode , merge ) ) { <nl> class WasmFullDecoder : public WasmDecoder { <nl> } <nl> vals [ count - 1 ] = fnode ; <nl> to - > locals [ i ] = <nl> - builder_ - > Phi ( local_type_vec_ [ i ] , count , vals , merge ) ; <nl> + builder_ - > Phi ( decoder - > GetLocalType ( i ) , count , vals , merge ) ; <nl> } <nl> } <nl> break ; <nl> class WasmFullDecoder : public WasmDecoder { <nl> <nl> TFNode * CreateOrMergeIntoPhi ( ValueType type , TFNode * merge , TFNode * tnode , <nl> TFNode * fnode ) { <nl> - DCHECK_NOT_NULL ( builder_ ) ; <nl> if ( builder_ - > IsPhiWithMerge ( tnode , merge ) ) { <nl> builder_ - > AppendToPhi ( tnode , fnode ) ; <nl> } else if ( tnode ! = fnode ) { <nl> class WasmFullDecoder : public WasmDecoder { <nl> return tnode ; <nl> } <nl> <nl> - SsaEnv * PrepareForLoop ( const byte * pc , SsaEnv * env ) { <nl> - if ( ! builder_ ) return Split ( env ) ; <nl> - if ( ! env - > go ( ) ) return Split ( env ) ; <nl> + SsaEnv * PrepareForLoop ( Decoder * decoder , SsaEnv * env ) { <nl> + if ( ! env - > go ( ) ) return Split ( decoder , env ) ; <nl> env - > state = SsaEnv : : kMerged ; <nl> <nl> env - > control = builder_ - > Loop ( env - > control ) ; <nl> env - > effect = builder_ - > EffectPhi ( 1 , & env - > effect , env - > control ) ; <nl> builder_ - > Terminate ( env - > effect , env - > control ) ; <nl> - BitVector * assigned = AnalyzeLoopAssignment ( <nl> - this , pc , static_cast < int > ( total_locals ( ) ) , zone_ ) ; <nl> - if ( failed ( ) ) return env ; <nl> + BitVector * assigned = WasmDecoder < true > : : AnalyzeLoopAssignment ( <nl> + decoder , decoder - > pc ( ) , static_cast < int > ( decoder - > total_locals ( ) ) , <nl> + decoder - > zone ( ) ) ; <nl> + if ( decoder - > failed ( ) ) return env ; <nl> if ( assigned ! = nullptr ) { <nl> / / Only introduce phis for variables assigned in this loop . <nl> - for ( int i = EnvironmentCount ( ) - 1 ; i > = 0 ; i - - ) { <nl> + for ( int i = decoder - > NumLocals ( ) - 1 ; i > = 0 ; i - - ) { <nl> if ( ! assigned - > Contains ( i ) ) continue ; <nl> - env - > locals [ i ] = <nl> - builder_ - > Phi ( local_type_vec_ [ i ] , 1 , & env - > locals [ i ] , env - > control ) ; <nl> + env - > locals [ i ] = builder_ - > Phi ( decoder - > GetLocalType ( i ) , 1 , <nl> + & env - > locals [ i ] , env - > control ) ; <nl> } <nl> - SsaEnv * loop_body_env = Split ( env ) ; <nl> - builder_ - > StackCheck ( position ( ) , & ( loop_body_env - > effect ) , <nl> + SsaEnv * loop_body_env = Split ( decoder , env ) ; <nl> + builder_ - > StackCheck ( decoder - > position ( ) , & ( loop_body_env - > effect ) , <nl> & ( loop_body_env - > control ) ) ; <nl> return loop_body_env ; <nl> } <nl> <nl> / / Conservatively introduce phis for all local variables . <nl> - for ( int i = EnvironmentCount ( ) - 1 ; i > = 0 ; i - - ) { <nl> - env - > locals [ i ] = <nl> - builder_ - > Phi ( local_type_vec_ [ i ] , 1 , & env - > locals [ i ] , env - > control ) ; <nl> + for ( int i = decoder - > NumLocals ( ) - 1 ; i > = 0 ; i - - ) { <nl> + env - > locals [ i ] = builder_ - > Phi ( decoder - > GetLocalType ( i ) , 1 , <nl> + & env - > locals [ i ] , env - > control ) ; <nl> } <nl> <nl> - SsaEnv * loop_body_env = Split ( env ) ; <nl> - builder_ - > StackCheck ( position ( ) , & ( loop_body_env - > effect ) , <nl> - & ( loop_body_env - > control ) ) ; <nl> + SsaEnv * loop_body_env = Split ( decoder , env ) ; <nl> + builder_ - > StackCheck ( decoder - > position ( ) , & loop_body_env - > effect , <nl> + & loop_body_env - > control ) ; <nl> return loop_body_env ; <nl> } <nl> <nl> / / Create a complete copy of the { from } . <nl> - SsaEnv * Split ( SsaEnv * from ) { <nl> + SsaEnv * Split ( Decoder * decoder , SsaEnv * from ) { <nl> DCHECK_NOT_NULL ( from ) ; <nl> - SsaEnv * result = reinterpret_cast < SsaEnv * > ( zone_ - > New ( sizeof ( SsaEnv ) ) ) ; <nl> - size_t size = sizeof ( TFNode * ) * EnvironmentCount ( ) ; <nl> + SsaEnv * result = <nl> + reinterpret_cast < SsaEnv * > ( decoder - > zone ( ) - > New ( sizeof ( SsaEnv ) ) ) ; <nl> + size_t size = sizeof ( TFNode * ) * decoder - > NumLocals ( ) ; <nl> result - > control = from - > control ; <nl> result - > effect = from - > effect ; <nl> <nl> if ( from - > go ( ) ) { <nl> result - > state = SsaEnv : : kReached ; <nl> result - > locals = <nl> - size > 0 ? reinterpret_cast < TFNode * * > ( zone_ - > New ( size ) ) : nullptr ; <nl> + size > 0 ? reinterpret_cast < TFNode * * > ( decoder - > zone ( ) - > New ( size ) ) <nl> + : nullptr ; <nl> memcpy ( result - > locals , from - > locals , size ) ; <nl> } else { <nl> result - > state = SsaEnv : : kUnreachable ; <nl> class WasmFullDecoder : public WasmDecoder { <nl> <nl> / / Create a copy of { from } that steals its state and leaves { from } <nl> / / unreachable . <nl> - SsaEnv * Steal ( SsaEnv * from ) { <nl> + SsaEnv * Steal ( Zone * zone , SsaEnv * from ) { <nl> DCHECK_NOT_NULL ( from ) ; <nl> - if ( ! from - > go ( ) ) return UnreachableEnv ( ) ; <nl> - SsaEnv * result = reinterpret_cast < SsaEnv * > ( zone_ - > New ( sizeof ( SsaEnv ) ) ) ; <nl> + if ( ! from - > go ( ) ) return UnreachableEnv ( zone ) ; <nl> + SsaEnv * result = reinterpret_cast < SsaEnv * > ( zone - > New ( sizeof ( SsaEnv ) ) ) ; <nl> result - > state = SsaEnv : : kReached ; <nl> result - > locals = from - > locals ; <nl> result - > control = from - > control ; <nl> class WasmFullDecoder : public WasmDecoder { <nl> } <nl> <nl> / / Create an unreachable environment . <nl> - SsaEnv * UnreachableEnv ( ) { <nl> - SsaEnv * result = reinterpret_cast < SsaEnv * > ( zone_ - > New ( sizeof ( SsaEnv ) ) ) ; <nl> + SsaEnv * UnreachableEnv ( Zone * zone ) { <nl> + SsaEnv * result = reinterpret_cast < SsaEnv * > ( zone - > New ( sizeof ( SsaEnv ) ) ) ; <nl> result - > state = SsaEnv : : kUnreachable ; <nl> result - > control = nullptr ; <nl> result - > effect = nullptr ; <nl> class WasmFullDecoder : public WasmDecoder { <nl> return result ; <nl> } <nl> <nl> - int EnvironmentCount ( ) { <nl> - if ( builder_ ) return static_cast < int > ( local_type_vec_ . size ( ) ) ; <nl> - return 0 ; / / if we aren ' t building a graph , don ' t bother with SSA renaming . <nl> - } <nl> - <nl> - virtual void onFirstError ( ) { <nl> - end_ = pc_ ; / / Terminate decoding loop . <nl> - builder_ = nullptr ; / / Don ' t build any more nodes . <nl> - TRACE ( " ! % s \ n " , error_msg_ . c_str ( ) ) ; <nl> - } <nl> - <nl> - inline wasm : : WasmCodePosition position ( ) { <nl> - int offset = static_cast < int > ( pc_ - start_ ) ; <nl> - DCHECK_EQ ( pc_ - start_ , offset ) ; / / overflows cannot happen <nl> - return offset ; <nl> - } <nl> - <nl> - inline void BuildSimpleOperator ( WasmOpcode opcode , FunctionSig * sig ) { <nl> - TFNode * node ; <nl> - switch ( sig - > parameter_count ( ) ) { <nl> - case 1 : { <nl> - Value val = Pop ( 0 , sig - > GetParam ( 0 ) ) ; <nl> - node = BUILD ( Unop , opcode , val . node , position ( ) ) ; <nl> - break ; <nl> - } <nl> - case 2 : { <nl> - Value rval = Pop ( 1 , sig - > GetParam ( 1 ) ) ; <nl> - Value lval = Pop ( 0 , sig - > GetParam ( 0 ) ) ; <nl> - node = BUILD ( Binop , opcode , lval . node , rval . node , position ( ) ) ; <nl> - break ; <nl> - } <nl> - default : <nl> - UNREACHABLE ( ) ; <nl> - node = nullptr ; <nl> - break ; <nl> + template < typename Operand > <nl> + void DoCall ( WasmFullDecoder < true , WasmGraphBuildingInterface > * decoder , <nl> + TFNode * index_node , const Operand & operand , const Value args [ ] , <nl> + Value returns [ ] , bool is_indirect ) { <nl> + if ( ! build ( decoder ) ) return ; <nl> + int param_count = static_cast < int > ( operand . sig - > parameter_count ( ) ) ; <nl> + TFNode * * arg_nodes = builder_ - > Buffer ( param_count + 1 ) ; <nl> + TFNode * * return_nodes = nullptr ; <nl> + arg_nodes [ 0 ] = index_node ; <nl> + for ( int i = 0 ; i < param_count ; + + i ) { <nl> + arg_nodes [ i + 1 ] = args [ i ] . interface_data . node ; <nl> + } <nl> + if ( is_indirect ) { <nl> + builder_ - > CallIndirect ( operand . index , arg_nodes , & return_nodes , <nl> + decoder - > position ( ) ) ; <nl> + } else { <nl> + builder_ - > CallDirect ( operand . index , arg_nodes , & return_nodes , <nl> + decoder - > position ( ) ) ; <nl> + } <nl> + int return_count = static_cast < int > ( operand . sig - > return_count ( ) ) ; <nl> + for ( int i = 0 ; i < return_count ; + + i ) { <nl> + returns [ i ] . interface_data . node = return_nodes [ i ] ; <nl> } <nl> - Push ( GetReturnType ( sig ) , node ) ; <nl> } <nl> } ; <nl> <nl> + } / / namespace <nl> + <nl> bool DecodeLocalDecls ( BodyLocalDecls * decls , const byte * start , <nl> const byte * end ) { <nl> Decoder decoder ( start , end ) ; <nl> - if ( WasmDecoder : : DecodeLocals ( & decoder , nullptr , & decls - > type_list ) ) { <nl> + if ( WasmDecoder < true > : : DecodeLocals ( & decoder , nullptr , & decls - > type_list ) ) { <nl> DCHECK ( decoder . ok ( ) ) ; <nl> decls - > encoded_size = decoder . pc_offset ( ) ; <nl> return true ; <nl> DecodeResult VerifyWasmCode ( AccountingAllocator * allocator , <nl> const wasm : : WasmModule * module , <nl> FunctionBody & body ) { <nl> Zone zone ( allocator , ZONE_NAME ) ; <nl> - WasmFullDecoder decoder ( & zone , module , body ) ; <nl> + WasmFullDecoder < true , EmptyInterface > decoder ( & zone , module , body ) ; <nl> decoder . Decode ( ) ; <nl> return decoder . toResult ( nullptr ) ; <nl> } <nl> DecodeResult VerifyWasmCodeWithStats ( AccountingAllocator * allocator , <nl> DecodeResult BuildTFGraph ( AccountingAllocator * allocator , TFBuilder * builder , <nl> FunctionBody & body ) { <nl> Zone zone ( allocator , ZONE_NAME ) ; <nl> - WasmFullDecoder decoder ( & zone , builder , body ) ; <nl> + WasmFullDecoder < true , WasmGraphBuildingInterface > decoder ( <nl> + & zone , builder - > module ( ) , body , builder ) ; <nl> decoder . Decode ( ) ; <nl> return decoder . toResult ( nullptr ) ; <nl> } <nl> <nl> unsigned OpcodeLength ( const byte * pc , const byte * end ) { <nl> Decoder decoder ( pc , end ) ; <nl> - return WasmDecoder : : OpcodeLength ( & decoder , pc ) ; <nl> + return WasmDecoder < false > : : OpcodeLength ( & decoder , pc ) ; <nl> } <nl> <nl> std : : pair < uint32_t , uint32_t > StackEffect ( const WasmModule * module , <nl> FunctionSig * sig , const byte * pc , <nl> const byte * end ) { <nl> - WasmDecoder decoder ( module , sig , pc , end ) ; <nl> + WasmDecoder < false > decoder ( module , sig , pc , end ) ; <nl> return decoder . StackEffect ( pc ) ; <nl> } <nl> <nl> bool PrintRawWasmCode ( AccountingAllocator * allocator , const FunctionBody & body , <nl> const wasm : : WasmModule * module ) { <nl> OFStream os ( stdout ) ; <nl> Zone zone ( allocator , ZONE_NAME ) ; <nl> - WasmFullDecoder decoder ( & zone , module , body ) ; <nl> + WasmDecoder < false > decoder ( module , body . sig , body . start , body . end ) ; <nl> int line_nr = 0 ; <nl> <nl> / / Print the function signature . <nl> bool PrintRawWasmCode ( AccountingAllocator * allocator , const FunctionBody & body , <nl> + + line_nr ; <nl> unsigned control_depth = 0 ; <nl> for ( ; i . has_next ( ) ; i . next ( ) ) { <nl> - unsigned length = WasmDecoder : : OpcodeLength ( & decoder , i . pc ( ) ) ; <nl> + unsigned length = WasmDecoder < false > : : OpcodeLength ( & decoder , i . pc ( ) ) ; <nl> <nl> WasmOpcode opcode = i . current ( ) ; <nl> if ( opcode = = kExprElse ) control_depth - - ; <nl> bool PrintRawWasmCode ( AccountingAllocator * allocator , const FunctionBody & body , <nl> case kExprIf : <nl> case kExprBlock : <nl> case kExprTry : { <nl> - BlockTypeOperand < true > operand ( & i , i . pc ( ) ) ; <nl> + BlockTypeOperand < false > operand ( & i , i . pc ( ) ) ; <nl> os < < " / / @ " < < i . pc_offset ( ) ; <nl> for ( unsigned i = 0 ; i < operand . arity ; i + + ) { <nl> os < < " " < < WasmOpcodes : : TypeName ( operand . read_entry ( i ) ) ; <nl> bool PrintRawWasmCode ( AccountingAllocator * allocator , const FunctionBody & body , <nl> control_depth - - ; <nl> break ; <nl> case kExprBr : { <nl> - BreakDepthOperand < true > operand ( & i , i . pc ( ) ) ; <nl> + BreakDepthOperand < false > operand ( & i , i . pc ( ) ) ; <nl> os < < " / / depth = " < < operand . depth ; <nl> break ; <nl> } <nl> case kExprBrIf : { <nl> - BreakDepthOperand < true > operand ( & i , i . pc ( ) ) ; <nl> + BreakDepthOperand < false > operand ( & i , i . pc ( ) ) ; <nl> os < < " / / depth = " < < operand . depth ; <nl> break ; <nl> } <nl> case kExprBrTable : { <nl> - BranchTableOperand < true > operand ( & i , i . pc ( ) ) ; <nl> + BranchTableOperand < false > operand ( & i , i . pc ( ) ) ; <nl> os < < " / / entries = " < < operand . table_count ; <nl> break ; <nl> } <nl> case kExprCallIndirect : { <nl> - CallIndirectOperand < true > operand ( & i , i . pc ( ) ) ; <nl> + CallIndirectOperand < false > operand ( & i , i . pc ( ) ) ; <nl> os < < " / / sig # " < < operand . index ; <nl> if ( decoder . Complete ( i . pc ( ) , operand ) ) { <nl> os < < " : " < < * operand . sig ; <nl> bool PrintRawWasmCode ( AccountingAllocator * allocator , const FunctionBody & body , <nl> break ; <nl> } <nl> case kExprCallFunction : { <nl> - CallFunctionOperand < true > operand ( & i , i . pc ( ) ) ; <nl> + CallFunctionOperand < false > operand ( & i , i . pc ( ) ) ; <nl> os < < " / / function # " < < operand . index ; <nl> if ( decoder . Complete ( i . pc ( ) , operand ) ) { <nl> os < < " : " < < * operand . sig ; <nl> bool PrintRawWasmCode ( AccountingAllocator * allocator , const FunctionBody & body , <nl> BitVector * AnalyzeLoopAssignmentForTesting ( Zone * zone , size_t num_locals , <nl> const byte * start , const byte * end ) { <nl> Decoder decoder ( start , end ) ; <nl> - return WasmDecoder : : AnalyzeLoopAssignment ( & decoder , start , <nl> - static_cast < int > ( num_locals ) , zone ) ; <nl> + return WasmDecoder < true > : : AnalyzeLoopAssignment ( <nl> + & decoder , start , static_cast < int > ( num_locals ) , zone ) ; <nl> } <nl> <nl> # undef TRACE <nl> mmm a / test / mjsunit / wasm / exceptions . js <nl> ppp b / test / mjsunit / wasm / exceptions . js <nl> assertFalse ( test_throw = = = 0 ) ; <nl> assertEquals ( " object " , typeof test_throw . exports ) ; <nl> assertEquals ( " function " , typeof test_throw . exports . throw_if_param_not_zero ) ; <nl> <nl> + / * TODO ( kschimpf ) Convert these tests to work for the proposed exceptions . <nl> + <nl> / / Test expected behavior of throws <nl> assertEquals ( 1 , test_throw . exports . throw_if_param_not_zero ( 0 ) ) ; <nl> assertWasmThrows ( [ ] , function ( ) { test_throw . exports . throw_if_param_not_zero ( 10 ) } ) ; <nl> assertEquals ( " function " , typeof test_catch . exports . simple_throw_catch_to_0_1 ) ; <nl> assertEquals ( 0 , test_catch . exports . simple_throw_catch_to_0_1 ( 0 ) ) ; <nl> assertEquals ( 1 , test_catch . exports . simple_throw_catch_to_0_1 ( 1 ) ) ; <nl> <nl> - / * TODO ( kschimpf ) Convert these tests to work for the proposed exceptions . <nl> - <nl> / / The following methods do not attempt to catch the exception they raise . <nl> var test_throw = ( function ( ) { <nl> var builder = new WasmModuleBuilder ( ) ; <nl> mmm a / test / unittests / wasm / function - body - decoder - unittest . cc <nl> ppp b / test / unittests / wasm / function - body - decoder - unittest . cc <nl> class WasmOpcodeLengthTest : public TestWithZone { <nl> <nl> TEST_F ( WasmOpcodeLengthTest , Statements ) { <nl> EXPECT_LENGTH ( 1 , kExprNop ) ; <nl> - EXPECT_LENGTH ( 2 , kExprBlock ) ; <nl> - EXPECT_LENGTH ( 2 , kExprLoop ) ; <nl> - EXPECT_LENGTH ( 2 , kExprIf ) ; <nl> EXPECT_LENGTH ( 1 , kExprElse ) ; <nl> EXPECT_LENGTH ( 1 , kExprEnd ) ; <nl> EXPECT_LENGTH ( 1 , kExprSelect ) ; <nl> EXPECT_LENGTH ( 2 , kExprBr ) ; <nl> EXPECT_LENGTH ( 2 , kExprBrIf ) ; <nl> EXPECT_LENGTH ( 2 , kExprThrow ) ; <nl> - EXPECT_LENGTH ( 2 , kExprTry ) ; <nl> EXPECT_LENGTH ( 2 , kExprCatch ) ; <nl> + EXPECT_LENGTH_N ( 2 , kExprBlock , kLocalI32 ) ; <nl> + EXPECT_LENGTH_N ( 2 , kExprLoop , kLocalI32 ) ; <nl> + EXPECT_LENGTH_N ( 2 , kExprIf , kLocalI32 ) ; <nl> + EXPECT_LENGTH_N ( 2 , kExprTry , kLocalI32 ) ; <nl> } <nl> <nl> TEST_F ( WasmOpcodeLengthTest , MiscExpressions ) { <nl> | [ wasm ] Refactor function body decoder | v8/v8 | 6b4dc039a6cc017828325bab09c7d9fe2712b5e8 | 2017-08-29T10:07:57Z |
mmm a / tensorflow / python / BUILD <nl> ppp b / tensorflow / python / BUILD <nl> cc_library ( <nl> " / / tensorflow / core / util : abstract_stack_trace " , <nl> " / / third_party / python_runtime : headers " , # buildcleaner : keep <nl> " @ com_google_absl / / absl / base : core_headers " , <nl> + " @ com_google_absl / / absl / container : inlined_vector " , <nl> " @ com_google_absl / / absl / types : optional " , <nl> ] , <nl> ) <nl> mmm a / tensorflow / python / eager / pywrap_tfe_src . cc <nl> ppp b / tensorflow / python / eager / pywrap_tfe_src . cc <nl> void TFE_Py_ExecuteCancelable ( TFE_Context * ctx , const char * device_name , <nl> auto cleaner = tensorflow : : gtl : : MakeCleanup ( [ ctx , op ] { ReturnOp ( ctx , op ) ; } ) ; <nl> if ( ! out_status - > status . ok ( ) ) return ; <nl> <nl> - tensorflow : : unwrap ( op ) - > SetStackTrace ( tensorflow : : GetStackTrace ( ) ) ; <nl> + tensorflow : : unwrap ( op ) - > SetStackTrace ( tensorflow : : GetStackTrace ( <nl> + tensorflow : : StackTrace : : kDefaultStackTraceInitialSize ) ) ; <nl> <nl> for ( int i = 0 ; i < inputs - > size ( ) & & out_status - > status . ok ( ) ; + + i ) { <nl> TFE_OpAddInput ( op , inputs - > at ( i ) , out_status ) ; <nl> PyObject * TFE_Py_FastPathExecute_C ( PyObject * args ) { <nl> return nullptr ; <nl> } <nl> <nl> - tensorflow : : unwrap ( op ) - > SetStackTrace ( tensorflow : : GetStackTrace ( ) ) ; <nl> + tensorflow : : unwrap ( op ) - > SetStackTrace ( tensorflow : : GetStackTrace ( <nl> + tensorflow : : StackTrace : : kDefaultStackTraceInitialSize ) ) ; <nl> <nl> const tensorflow : : OpDef * op_def = tensorflow : : unwrap ( op ) - > OpDef ( ) ; <nl> if ( op_def = = nullptr ) return nullptr ; <nl> mmm a / tensorflow / python / util / stack_trace . cc <nl> ppp b / tensorflow / python / util / stack_trace . cc <nl> namespace tensorflow { <nl> <nl> std : : vector < StackFrame > StackTrace : : ToStackFrames ( ) const { <nl> std : : vector < StackFrame > result ; <nl> - result . reserve ( size_ ) ; <nl> + result . reserve ( code_objs_ . size ( ) ) ; <nl> <nl> - for ( int i = size_ - 1 ; i > = 0 ; - - i ) { <nl> + for ( int i = code_objs_ . size ( ) - 1 ; i > = 0 ; - - i ) { <nl> const char * file_name = GetPythonString ( code_objs_ [ i ] - > co_filename ) ; <nl> const int line_number = <nl> PyCode_Addr2Line ( code_objs_ [ i ] , last_instructions_ [ i ] ) ; <nl> mmm a / tensorflow / python / util / stack_trace . h <nl> ppp b / tensorflow / python / util / stack_trace . h <nl> limitations under the License . <nl> # include < frameobject . h > <nl> <nl> # include < array > <nl> + # include < limits > <nl> # include < sstream > <nl> # include < string > <nl> <nl> # include " absl / base / attributes . h " <nl> # include " absl / base / optimization . h " <nl> + # include " absl / container / inlined_vector . h " <nl> # include " absl / types / optional . h " <nl> # include " tensorflow / core / util / abstract_stack_trace . h " <nl> # include " tensorflow / python / lib / core / py_util . h " <nl> namespace tensorflow { <nl> / / A class for capturing Python stack trace . <nl> class StackTrace final { <nl> public : <nl> - static constexpr int kMaxDepth = 10 ; <nl> + static constexpr int kDefaultStackTraceInitialSize = 10 ; <nl> <nl> - StackTrace ( ) : size_ ( 0 ) { } <nl> + StackTrace ( ) { } <nl> <nl> / / Returns ` StackTrace ` object that captures the current Python stack trace . <nl> + / / ` limit ` determines how many stack frames at most are returned : set to - 1 <nl> + / / for " no limit " . <nl> / / Python GIL must be acquired beforehand . <nl> ABSL_MUST_USE_RESULT <nl> ABSL_ATTRIBUTE_HOT <nl> - static StackTrace Capture ( ) { <nl> + static StackTrace Capture ( int limit ) { <nl> DCheckPyGilState ( ) ; <nl> + if ( limit = = - 1 ) limit = std : : numeric_limits < int > : : max ( ) ; <nl> <nl> StackTrace result ; <nl> const PyFrameObject * frame = PyThreadState_GET ( ) - > frame ; <nl> int i = 0 ; <nl> - for ( ; i < kMaxDepth & & frame ! = nullptr ; frame = frame - > f_back , + + i ) { <nl> + for ( ; i < limit & & frame ! = nullptr ; frame = frame - > f_back , + + i ) { <nl> PyCodeObject * code_obj = frame - > f_code ; <nl> DCHECK ( code_obj ! = nullptr ) ; <nl> <nl> Py_INCREF ( code_obj ) ; <nl> - result . code_objs_ [ i ] = code_obj ; <nl> - result . last_instructions_ [ i ] = frame - > f_lasti ; <nl> + result . code_objs_ . push_back ( code_obj ) ; <nl> + result . last_instructions_ . push_back ( frame - > f_lasti ) ; <nl> } <nl> - result . size_ = i ; <nl> return result ; <nl> } <nl> <nl> class StackTrace final { <nl> ~ StackTrace ( ) { Clear ( ) ; } <nl> <nl> StackTrace ( StackTrace & & other ) { <nl> - code_objs_ = other . code_objs_ ; <nl> - last_instructions_ = other . last_instructions_ ; <nl> - size_ = other . size_ ; <nl> - other . size_ = 0 ; <nl> + code_objs_ = std : : move ( other . code_objs_ ) ; <nl> + last_instructions_ = std : : move ( other . last_instructions_ ) ; <nl> + other . code_objs_ = { } ; <nl> } <nl> <nl> / / Python GIL must be acquired beforehand . <nl> class StackTrace final { <nl> <nl> code_objs_ = other . code_objs_ ; <nl> last_instructions_ = other . last_instructions_ ; <nl> - size_ = other . size_ ; <nl> - other . size_ = 0 ; <nl> + other . code_objs_ = { } ; <nl> return * this ; <nl> } <nl> <nl> class StackTrace final { <nl> std : : vector < StackFrame > ToStackFrames ( ) const ; <nl> <nl> private : <nl> - std : : array < PyCodeObject * , kMaxDepth > code_objs_ ; <nl> - std : : array < int , kMaxDepth > last_instructions_ ; <nl> - int size_ ; <nl> + absl : : InlinedVector < PyCodeObject * , kDefaultStackTraceInitialSize > code_objs_ ; <nl> + absl : : InlinedVector < int , kDefaultStackTraceInitialSize > last_instructions_ ; <nl> <nl> / / Python GIL must be acquired beforehand . <nl> ABSL_ATTRIBUTE_HOT <nl> void Clear ( ) { <nl> DCheckPyGilState ( ) ; <nl> - for ( int i = 0 ; i < size_ ; + + i ) Py_DECREF ( code_objs_ [ i ] ) ; <nl> + for ( PyCodeObject * obj : code_objs_ ) Py_DECREF ( obj ) ; <nl> } <nl> <nl> StackTrace ( const StackTrace & ) = delete ; <nl> class StackTraceManager { <nl> / / Python GIL must be acquired beforehand . <nl> ABSL_MUST_USE_RESULT <nl> ABSL_ATTRIBUTE_HOT <nl> - int Capture ( ) { <nl> + int Capture ( int limit ) { <nl> DCheckPyGilState ( ) ; <nl> const int id = next_id_ + + ; <nl> const int index = id & ( kStackTraceCircularBufferSize - 1 ) ; <nl> - stack_traces_ [ index ] = StackTrace : : Capture ( ) ; <nl> + stack_traces_ [ index ] = StackTrace : : Capture ( limit ) ; <nl> return id ; <nl> } <nl> <nl> extern StackTraceManager * const stack_trace_manager ; <nl> / / Note that the actual stack trace is kept in a circular buffer for string <nl> / / conversion could fail if it ' s evicted before . <nl> / / Python GIL must be acquired beforehand . <nl> - inline AbstractStackTrace GetStackTrace ( ) { <nl> + inline AbstractStackTrace GetStackTrace ( int limit ) { <nl> DCheckPyGilState ( ) ; <nl> - return AbstractStackTrace ( stack_trace_manager - > Capture ( ) , [ ] ( int id ) { <nl> + return AbstractStackTrace ( stack_trace_manager - > Capture ( limit ) , [ ] ( int id ) { <nl> PyGILState_STATE gstate = PyGILState_Ensure ( ) ; <nl> std : : vector < StackFrame > result = <nl> stack_trace_manager - > Get ( id ) - > ToStackFrames ( ) ; <nl> | [ NFC ] Support unbounded stack traces in eager stack trace retrieval mechanism | tensorflow/tensorflow | dd62ec3d4bc170ae94f2b4549da69074b7680f74 | 2020-11-16T22:45:30Z |
deleted file mode 100644 <nl> index 60c6d0669 . . 000000000 <nl> mmm a / src / createtabledialog . cpp <nl> ppp / dev / null <nl> <nl> - # include " createtabledialog . h " <nl> - # include " ui_createtabledialog . h " <nl> - <nl> - CreateTableDialog : : CreateTableDialog ( QWidget * parent ) : <nl> - QDialog ( parent ) , <nl> - ui ( new Ui : : CreateTableDialog ) <nl> - { <nl> - ui - > setupUi ( this ) ; <nl> - } <nl> - <nl> - CreateTableDialog : : ~ CreateTableDialog ( ) <nl> - { <nl> - delete ui ; <nl> - } <nl> deleted file mode 100644 <nl> index cb382ba77 . . 000000000 <nl> mmm a / src / createtabledialog . h <nl> ppp / dev / null <nl> <nl> - # ifndef CREATETABLEDIALOG_H <nl> - # define CREATETABLEDIALOG_H <nl> - <nl> - # include < QDialog > <nl> - <nl> - namespace Ui { <nl> - class CreateTableDialog ; <nl> - } <nl> - <nl> - class CreateTableDialog : public QDialog <nl> - { <nl> - Q_OBJECT <nl> - <nl> - public : <nl> - explicit CreateTableDialog ( QWidget * parent = 0 ) ; <nl> - ~ CreateTableDialog ( ) ; <nl> - <nl> - private : <nl> - Ui : : CreateTableDialog * ui ; <nl> - } ; <nl> - <nl> - # endif / / CREATETABLEDIALOG_H <nl> deleted file mode 100644 <nl> index ae5aea942 . . 000000000 <nl> mmm a / src / createtabledialog . ui <nl> ppp / dev / null <nl> <nl> - < ? xml version = " 1 . 0 " encoding = " UTF - 8 " ? > <nl> - < ui version = " 4 . 0 " > <nl> - < class > CreateTableDialog < / class > <nl> - < widget class = " QDialog " name = " CreateTableDialog " > <nl> - < property name = " geometry " > <nl> - < rect > <nl> - < x > 0 < / x > <nl> - < y > 0 < / y > <nl> - < width > 466 < / width > <nl> - < height > 364 < / height > <nl> - < / rect > <nl> - < / property > <nl> - < property name = " windowTitle " > <nl> - < string > Dialog < / string > <nl> - < / property > <nl> - < layout class = " QVBoxLayout " name = " verticalLayout " > <nl> - < item > <nl> - < widget class = " QWidget " name = " widget " native = " true " > <nl> - < layout class = " QHBoxLayout " name = " horizontalLayout " > <nl> - < item > <nl> - < widget class = " QLabel " name = " labelTableName " > <nl> - < property name = " text " > <nl> - < string > Table name : < / string > <nl> - < / property > <nl> - < / widget > <nl> - < / item > <nl> - < item > <nl> - < widget class = " QLineEdit " name = " lineEditTableName " / > <nl> - < / item > <nl> - < / layout > <nl> - < / widget > <nl> - < / item > <nl> - < item > <nl> - < widget class = " QTableWidget " name = " tableWidget " / > <nl> - < / item > <nl> - < item > <nl> - < widget class = " QGroupBox " name = " groupBox " > <nl> - < property name = " title " > <nl> - < string > GroupBox < / string > <nl> - < / property > <nl> - < layout class = " QVBoxLayout " name = " verticalLayout_2 " > <nl> - < item > <nl> - < widget class = " QWidget " name = " widget_2 " native = " true " > <nl> - < layout class = " QHBoxLayout " name = " horizontalLayout_2 " > <nl> - < item > <nl> - < widget class = " QLabel " name = " labelFieldName " > <nl> - < property name = " text " > <nl> - < string > Field name : < / string > <nl> - < / property > <nl> - < / widget > <nl> - < / item > <nl> - < item > <nl> - < widget class = " QLineEdit " name = " lineEdit " / > <nl> - < / item > <nl> - < item > <nl> - < widget class = " QPushButton " name = " ButAddField " > <nl> - < property name = " maximumSize " > <nl> - < size > <nl> - < width > 35 < / width > <nl> - < height > 16777215 < / height > <nl> - < / size > <nl> - < / property > <nl> - < property name = " text " > <nl> - < string / > <nl> - < / property > <nl> - < property name = " icon " > <nl> - < iconset resource = " icons / icons . qrc " > <nl> - < normaloff > : / icons / add < / normaloff > : / icons / add < / iconset > <nl> - < / property > <nl> - < / widget > <nl> - < / item > <nl> - < / layout > <nl> - < / widget > <nl> - < / item > <nl> - < item > <nl> - < widget class = " QWidget " name = " widget_3 " native = " true " > <nl> - < layout class = " QHBoxLayout " name = " horizontalLayout_3 " > <nl> - < item > <nl> - < widget class = " QLabel " name = " labelDataType " > <nl> - < property name = " sizePolicy " > <nl> - < sizepolicy hsizetype = " Minimum " vsizetype = " Minimum " > <nl> - < horstretch > 0 < / horstretch > <nl> - < verstretch > 0 < / verstretch > <nl> - < / sizepolicy > <nl> - < / property > <nl> - < property name = " text " > <nl> - < string > Data type : < / string > <nl> - < / property > <nl> - < / widget > <nl> - < / item > <nl> - < item > <nl> - < widget class = " QComboBox " name = " comboBoxDataType " > <nl> - < property name = " sizePolicy " > <nl> - < sizepolicy hsizetype = " Expanding " vsizetype = " Fixed " > <nl> - < horstretch > 0 < / horstretch > <nl> - < verstretch > 0 < / verstretch > <nl> - < / sizepolicy > <nl> - < / property > <nl> - < item > <nl> - < property name = " text " > <nl> - < string > INTEGER < / string > <nl> - < / property > <nl> - < / item > <nl> - < item > <nl> - < property name = " text " > <nl> - < string > TEXT < / string > <nl> - < / property > <nl> - < / item > <nl> - < item > <nl> - < property name = " text " > <nl> - < string > REAL < / string > <nl> - < / property > <nl> - < / item > <nl> - < item > <nl> - < property name = " text " > <nl> - < string > BLOB < / string > <nl> - < / property > <nl> - < / item > <nl> - < / widget > <nl> - < / item > <nl> - < item > <nl> - < widget class = " QCheckBox " name = " checkBoxNotNull " > <nl> - < property name = " text " > <nl> - < string > Not NULL < / string > <nl> - < / property > <nl> - < / widget > <nl> - < / item > <nl> - < / layout > <nl> - < / widget > <nl> - < / item > <nl> - < / layout > <nl> - < / widget > <nl> - < / item > <nl> - < item > <nl> - < widget class = " QDialogButtonBox " name = " buttonBox " > <nl> - < property name = " orientation " > <nl> - < enum > Qt : : Horizontal < / enum > <nl> - < / property > <nl> - < property name = " standardButtons " > <nl> - < set > QDialogButtonBox : : Cancel | QDialogButtonBox : : Ok < / set > <nl> - < / property > <nl> - < / widget > <nl> - < / item > <nl> - < / layout > <nl> - < / widget > <nl> - < resources > <nl> - < include location = " icons / icons . qrc " / > <nl> - < / resources > <nl> - < connections > <nl> - < connection > <nl> - < sender > buttonBox < / sender > <nl> - < signal > accepted ( ) < / signal > <nl> - < receiver > CreateTableDialog < / receiver > <nl> - < slot > accept ( ) < / slot > <nl> - < hints > <nl> - < hint type = " sourcelabel " > <nl> - < x > 248 < / x > <nl> - < y > 254 < / y > <nl> - < / hint > <nl> - < hint type = " destinationlabel " > <nl> - < x > 157 < / x > <nl> - < y > 274 < / y > <nl> - < / hint > <nl> - < / hints > <nl> - < / connection > <nl> - < connection > <nl> - < sender > buttonBox < / sender > <nl> - < signal > rejected ( ) < / signal > <nl> - < receiver > CreateTableDialog < / receiver > <nl> - < slot > reject ( ) < / slot > <nl> - < hints > <nl> - < hint type = " sourcelabel " > <nl> - < x > 316 < / x > <nl> - < y > 260 < / y > <nl> - < / hint > <nl> - < hint type = " destinationlabel " > <nl> - < x > 286 < / x > <nl> - < y > 274 < / y > <nl> - < / hint > <nl> - < / hints > <nl> - < / connection > <nl> - < / connections > <nl> - < / ui > <nl> deleted file mode 100644 <nl> index e96a3f337 . . 000000000 <nl> mmm a / src / createtableform . cpp <nl> ppp / dev / null <nl> <nl> - # include " createtableform . h " <nl> - # include < QMessageBox > <nl> - # include " editfieldform . h " <nl> - / * <nl> - * Constructs a createTableForm as a child of ' parent ' , with the <nl> - * name ' name ' and widget flags set to ' f ' . <nl> - * <nl> - * The dialog will by default be modeless , unless you set ' modal ' to <nl> - * true to construct a modal dialog . <nl> - * / <nl> - createTableForm : : createTableForm ( DBBrowserDB * db , QWidget * parent , Qt : : WindowFlags fl ) <nl> - : QDialog ( parent , fl ) , <nl> - pdb ( db ) <nl> - { <nl> - setupUi ( this ) ; <nl> - <nl> - init ( ) ; <nl> - } <nl> - <nl> - / * <nl> - * Destroys the object and frees any allocated resources <nl> - * / <nl> - createTableForm : : ~ createTableForm ( ) <nl> - { <nl> - / / no need to delete child widgets , Qt does it all for us <nl> - } <nl> - <nl> - / * <nl> - * Sets the strings of the subwidgets using the current <nl> - * language . <nl> - * / <nl> - void createTableForm : : languageChange ( ) <nl> - { <nl> - retranslateUi ( this ) ; <nl> - } <nl> - <nl> - void createTableForm : : init ( ) <nl> - { <nl> - } <nl> - <nl> - / / * * Create The Table <nl> - void createTableForm : : confirmCreate ( ) <nl> - { <nl> - bool ok = true ; <nl> - QString tabname = tablenameLineEdit - > text ( ) ; <nl> - if ( tabname . isEmpty ( ) ) { <nl> - ok = false ; <nl> - statusBar - > showMessage ( " Please enter a name for the table " , 4000 ) ; <nl> - tablenameLineEdit - > setFocus ( ) ; <nl> - return ; <nl> - } <nl> - if ( tabname . contains ( " " ) > 0 ) { <nl> - ok = false ; <nl> - statusBar - > showMessage ( " Spaces are not allowed in the table name " , 4000 ) ; <nl> - tablenameLineEdit - > setFocus ( ) ; <nl> - return ; <nl> - } <nl> - <nl> - if ( treeWidget - > invisibleRootItem ( ) - > childCount ( ) = = 0 ) { <nl> - ok = false ; <nl> - statusBar - > showMessage ( " No fields defined " , 4000 ) ; <nl> - return ; <nl> - } <nl> - <nl> - / * check field names for empty or illegal names <nl> - TODO : move to add <nl> - <nl> - for ( int r = 0 ; r < fieldsTable - > numRows ( ) ; r + + ) { <nl> - QString rowname = fieldsTable - > text ( r , 0 ) ; <nl> - if ( rowname . isEmpty ( ) ) { <nl> - ok = false ; <nl> - QMessageBox : : warning ( this , applicationName , " Empty field names are not allowed " ) ; <nl> - break ; <nl> - } <nl> - if ( rowname . contains ( " " ) > 0 ) { <nl> - ok = false ; <nl> - QMessageBox : : warning ( this , applicationName , " Spaces are not allowed in the field names " ) ; <nl> - break ; <nl> - } <nl> - } * / <nl> - <nl> - if ( ! ok ) { <nl> - return ; <nl> - } <nl> - <nl> - if ( ok ) { <nl> - / / QString esc ( " \ " " ) ; <nl> - / / # TODO The colnames need to be escaped eg create table ' group ' <nl> - createStatement = " CREATE TABLE " ; <nl> - / / createStatement . append ( esc ) . append ( tabname ) . append ( esc ) ; <nl> - createStatement . append ( tabname ) ; <nl> - createStatement . append ( " ( " ) ; <nl> - for ( int i = 0 ; i < treeWidget - > invisibleRootItem ( ) - > childCount ( ) ; i + + ) { <nl> - QTreeWidgetItem * item = treeWidget - > invisibleRootItem ( ) - > child ( i ) ; <nl> - / / createStatement . append ( esc ) . append ( item - > text ( 0 ) ) . append ( esc ) ; <nl> - createStatement . append ( item - > text ( 0 ) ) ; <nl> - createStatement . append ( " " ) ; <nl> - createStatement . append ( item - > text ( 1 ) ) ; <nl> - if ( i < treeWidget - > invisibleRootItem ( ) - > childCount ( ) - 1 ) { <nl> - createStatement . append ( " , " ) ; <nl> - } <nl> - } <nl> - createStatement . append ( " ) ; " ) ; <nl> - accept ( ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void createTableForm : : addField ( ) <nl> - { <nl> - / / TODO maybe embedd locally <nl> - editFieldForm * addForm = new editFieldForm ( this ) ; <nl> - addForm - > setModal ( true ) ; <nl> - addForm - > setInitialValues ( pdb , true , QString ( " " ) , QString ( " " ) , QString ( " " ) ) ; <nl> - if ( addForm - > exec ( ) ) <nl> - { <nl> - QTreeWidgetItem * newItem = new QTreeWidgetItem ( ) ; <nl> - newItem - > setText ( 0 , addForm - > field_name ) ; <nl> - newItem - > setText ( 1 , addForm - > field_type ) ; <nl> - newItem - > setIcon ( 0 , QIcon ( " : / icons / field " ) ) ; <nl> - treeWidget - > addTopLevelItem ( newItem ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - void createTableForm : : deleteField ( ) <nl> - { <nl> - if ( ! treeWidget - > currentItem ( ) ) { <nl> - return ; <nl> - } <nl> - treeWidget - > invisibleRootItem ( ) - > removeChild ( treeWidget - > currentItem ( ) ) ; <nl> - } <nl> - <nl> - <nl> - void createTableForm : : fieldSelectionChanged ( ) <nl> - { <nl> - buttonDeleteField - > setEnabled ( treeWidget - > selectionModel ( ) - > hasSelection ( ) ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 4c1ba4f3d . . 000000000 <nl> mmm a / src / createtableform . h <nl> ppp / dev / null <nl> <nl> - # ifndef CREATETABLEFORM_H <nl> - # define CREATETABLEFORM_H <nl> - <nl> - # include < QtGui / QGroupBox > <nl> - # include < QtGui / QTreeWidget > <nl> - # include < QtGui / QApplication > <nl> - # include < QtGui / QDialog > <nl> - # include < QtGui / QHBoxLayout > <nl> - # include < QtGui / QLabel > <nl> - # include < QtGui / QLineEdit > <nl> - # include < QtGui / QPushButton > <nl> - # include < QtGui / QStatusBar > <nl> - # include < QtGui / QVBoxLayout > <nl> - <nl> - class DBBrowserDB ; <nl> - <nl> - class Ui_createTableForm <nl> - { <nl> - public : <nl> - QVBoxLayout * mainVBoxLayout ; <nl> - <nl> - QHBoxLayout * topTableLayout ; <nl> - <nl> - QGroupBox * groupBoxFields ; <nl> - QVBoxLayout * groupBoxLayout ; <nl> - QLabel * textLabel1 ; <nl> - QLineEdit * tablenameLineEdit ; <nl> - <nl> - QTreeWidget * treeWidget ; <nl> - <nl> - QHBoxLayout * fieldActionsButtonLayout ; <nl> - QPushButton * buttonAddField ; <nl> - QPushButton * buttonDeleteField ; <nl> - <nl> - QHBoxLayout * bottomButtonLayout ; <nl> - QPushButton * buttonCreate ; <nl> - QPushButton * buttonCancel ; <nl> - <nl> - QStatusBar * statusBar ; <nl> - <nl> - void setupUi ( QDialog * createTableForm ) <nl> - { <nl> - if ( createTableForm - > objectName ( ) . isEmpty ( ) ) { <nl> - createTableForm - > setObjectName ( QString : : fromUtf8 ( " createTableForm " ) ) ; <nl> - } <nl> - createTableForm - > setWindowIcon ( QIcon ( " : / icons / db_new " ) ) ; <nl> - <nl> - createTableForm - > resize ( 309 , 320 ) ; <nl> - <nl> - / / * * Main Layout <nl> - mainVBoxLayout = new QVBoxLayout ( createTableForm ) ; <nl> - mainVBoxLayout - > setSpacing ( 10 ) ; <nl> - mainVBoxLayout - > setContentsMargins ( 0 , 0 , 0 , 0 ) ; <nl> - mainVBoxLayout - > setObjectName ( QString : : fromUtf8 ( " vboxLayout " ) ) ; <nl> - <nl> - / / * * * * Top Table Box * * * * <nl> - topTableLayout = new QHBoxLayout ( ) ; <nl> - topTableLayout - > setSpacing ( 10 ) ; <nl> - topTableLayout - > setContentsMargins ( 10 , 10 , 10 , 10 ) ; <nl> - / / topTableLayout - > setObjectName ( QString : : fromUtf8 ( " hboxLayout " ) ) ; <nl> - textLabel1 = new QLabel ( createTableForm ) ; <nl> - / / textLabel1 - > setObjectName ( QString : : fromUtf8 ( " textLabel1 " ) ) ; <nl> - textLabel1 - > setWordWrap ( false ) ; <nl> - <nl> - topTableLayout - > addWidget ( textLabel1 ) ; <nl> - <nl> - tablenameLineEdit = new QLineEdit ( createTableForm ) ; <nl> - / / tablenameLineEdit - > setObjectName ( QString : : fromUtf8 ( " tablenameLineEdit " ) ) ; <nl> - <nl> - topTableLayout - > addWidget ( tablenameLineEdit ) ; <nl> - <nl> - <nl> - mainVBoxLayout - > addLayout ( topTableLayout ) ; <nl> - <nl> - / / * * * * Fields GroupBox <nl> - groupBoxFields = new QGroupBox ( createTableForm ) ; <nl> - groupBoxFields - > setObjectName ( QString : : fromUtf8 ( " groupBox1 " ) ) ; <nl> - groupBoxLayout = new QVBoxLayout ( ) ; <nl> - groupBoxFields - > setLayout ( groupBoxLayout ) ; <nl> - <nl> - treeWidget = new QTreeWidget ( ) ; <nl> - groupBoxLayout - > addWidget ( treeWidget ) ; <nl> - treeWidget - > headerItem ( ) - > setText ( 0 , QApplication : : translate ( " createTableForm " , " Field name " , 0 , QApplication : : UnicodeUTF8 ) ) ; <nl> - treeWidget - > headerItem ( ) - > setText ( 1 , QApplication : : translate ( " createTableForm " , " Field type " , 0 , QApplication : : UnicodeUTF8 ) ) ; <nl> - treeWidget - > setRootIsDecorated ( false ) ; <nl> - treeWidget - > setAlternatingRowColors ( true ) ; <nl> - <nl> - / / * * Field Action Buttons Box <nl> - fieldActionsButtonLayout = new QHBoxLayout ( ) ; <nl> - fieldActionsButtonLayout - > setSpacing ( 6 ) ; <nl> - fieldActionsButtonLayout - > setObjectName ( QString : : fromUtf8 ( " hboxLayout1 " ) ) ; <nl> - fieldActionsButtonLayout - > addStretch ( 10 ) ; / / force right <nl> - <nl> - / / * * * Delete Field Button <nl> - buttonDeleteField = new QPushButton ( groupBoxFields ) ; <nl> - buttonDeleteField - > setObjectName ( QString : : fromUtf8 ( " buttonDeleteField " ) ) ; <nl> - buttonDeleteField - > setEnabled ( false ) ; <nl> - buttonDeleteField - > setIcon ( QIcon ( " : / icons / field_delete " ) ) ; <nl> - fieldActionsButtonLayout - > addWidget ( buttonDeleteField ) ; <nl> - <nl> - / / * * * Add Field Button <nl> - buttonAddField = new QPushButton ( groupBoxFields ) ; <nl> - buttonAddField - > setObjectName ( QString : : fromUtf8 ( " buttonAddField " ) ) ; <nl> - buttonAddField - > setIcon ( QIcon ( " : / icons / field_add " ) ) ; <nl> - fieldActionsButtonLayout - > addWidget ( buttonAddField ) ; <nl> - <nl> - groupBoxLayout - > addLayout ( fieldActionsButtonLayout ) ; <nl> - <nl> - mainVBoxLayout - > addWidget ( groupBoxFields ) ; <nl> - <nl> - / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> - / / * * * Bottom Dialog action Buttons <nl> - bottomButtonLayout = new QHBoxLayout ( ) ; <nl> - bottomButtonLayout - > setSpacing ( 6 ) ; <nl> - / / bottomButtonLayout - > setObjectName ( QString : : fromUtf8 ( " hboxLayout2 " ) ) ; <nl> - bottomButtonLayout - > addStretch ( 10 ) ; / / force right <nl> - <nl> - / / * * Cancel Button <nl> - buttonCancel = new QPushButton ( createTableForm ) ; <nl> - / / buttonCancel - > setObjectName ( QString : : fromUtf8 ( " buttonCancel " ) ) ; <nl> - buttonCancel - > setIcon ( QIcon ( " : / icons / cancel " ) ) ; <nl> - bottomButtonLayout - > addWidget ( buttonCancel ) ; <nl> - <nl> - / / * * Create Button <nl> - buttonCreate = new QPushButton ( createTableForm ) ; <nl> - / / buttonCreate - > setObjectName ( QString : : fromUtf8 ( " buttonCreate " ) ) ; <nl> - buttonCreate - > setIcon ( QIcon ( " : / icons / save " ) ) ; <nl> - bottomButtonLayout - > addWidget ( buttonCreate ) ; <nl> - mainVBoxLayout - > addLayout ( bottomButtonLayout ) ; <nl> - <nl> - statusBar = new QStatusBar ( ) ; <nl> - mainVBoxLayout - > addWidget ( statusBar ) ; <nl> - <nl> - / / * * Setup <nl> - retranslateUi ( createTableForm ) ; <nl> - QObject : : connect ( buttonCancel , SIGNAL ( clicked ( ) ) , createTableForm , SLOT ( reject ( ) ) ) ; <nl> - QObject : : connect ( buttonCreate , SIGNAL ( clicked ( ) ) , createTableForm , SLOT ( confirmCreate ( ) ) ) ; <nl> - QObject : : connect ( buttonAddField , SIGNAL ( clicked ( ) ) , createTableForm , SLOT ( addField ( ) ) ) ; <nl> - QObject : : connect ( buttonDeleteField , SIGNAL ( clicked ( ) ) , createTableForm , SLOT ( deleteField ( ) ) ) ; <nl> - QObject : : connect ( treeWidget , SIGNAL ( itemSelectionChanged ( ) ) , createTableForm , SLOT ( fieldSelectionChanged ( ) ) ) ; <nl> - <nl> - QMetaObject : : connectSlotsByName ( createTableForm ) ; <nl> - } / / setupUi <nl> - <nl> - void retranslateUi ( QDialog * createTableForm ) <nl> - { <nl> - createTableForm - > setWindowTitle ( QApplication : : translate ( " createTableForm " , " Create Table " , 0 , QApplication : : UnicodeUTF8 ) ) ; <nl> - textLabel1 - > setText ( QApplication : : translate ( " createTableForm " , " Table name : " , 0 , QApplication : : UnicodeUTF8 ) ) ; <nl> - tablenameLineEdit - > setText ( QString ( ) ) ; <nl> - # ifndef QT_NO_TOOLTIP <nl> - tablenameLineEdit - > setProperty ( " toolTip " , QVariant ( QApplication : : translate ( " createTableForm " , " Enter the name for the new table " , 0 , QApplication : : UnicodeUTF8 ) ) ) ; <nl> - # endif / / QT_NO_TOOLTIP <nl> - # ifndef QT_NO_WHATSTHIS <nl> - tablenameLineEdit - > setProperty ( " whatsThis " , QVariant ( QApplication : : translate ( " createTableForm " , " Use this control to enter the name of the table to be created . " , 0 , QApplication : : UnicodeUTF8 ) ) ) ; <nl> - # endif / / QT_NO_WHATSTHIS <nl> - groupBoxFields - > setTitle ( QApplication : : translate ( " createTableForm " , " Define fields : " , 0 , QApplication : : UnicodeUTF8 ) ) ; <nl> - <nl> - buttonAddField - > setText ( QApplication : : translate ( " createTableForm " , " Add " , 0 , QApplication : : UnicodeUTF8 ) ) ; <nl> - # ifndef QT_NO_TOOLTIP <nl> - buttonAddField - > setProperty ( " toolTip " , QVariant ( QApplication : : translate ( " createTableForm " , " Add a new field definition " , 0 , QApplication : : UnicodeUTF8 ) ) ) ; <nl> - # endif / / QT_NO_TOOLTIP <nl> - # ifndef QT_NO_WHATSTHIS <nl> - buttonAddField - > setProperty ( " whatsThis " , QVariant ( QApplication : : translate ( " createTableForm " , " This button is used to add a new field definition to your table " , 0 , QApplication : : UnicodeUTF8 ) ) ) ; <nl> - # endif / / QT_NO_WHATSTHIS <nl> - buttonDeleteField - > setText ( QApplication : : translate ( " createTableForm " , " Delete " , 0 , QApplication : : UnicodeUTF8 ) ) ; <nl> - # ifndef QT_NO_TOOLTIP <nl> - buttonDeleteField - > setProperty ( " toolTip " , QVariant ( QApplication : : translate ( " createTableForm " , " Delete current field definition " , 0 , QApplication : : UnicodeUTF8 ) ) ) ; <nl> - # endif / / QT_NO_TOOLTIP <nl> - # ifndef QT_NO_WHATSTHIS <nl> - buttonDeleteField - > setProperty ( " whatsThis " , QVariant ( QApplication : : translate ( " createTableForm " , " This button is used to delete the currently selected field definition from your table " , 0 , QApplication : : UnicodeUTF8 ) ) ) ; <nl> - # endif / / QT_NO_WHATSTHIS <nl> - buttonCreate - > setText ( QApplication : : translate ( " createTableForm " , " Create " , 0 , QApplication : : UnicodeUTF8 ) ) ; <nl> - # ifndef QT_NO_TOOLTIP <nl> - buttonCreate - > setProperty ( " toolTip " , QVariant ( QApplication : : translate ( " createTableForm " , " Create the table " , 0 , QApplication : : UnicodeUTF8 ) ) ) ; <nl> - # endif / / QT_NO_TOOLTIP <nl> - buttonCancel - > setText ( QApplication : : translate ( " createTableForm " , " Cancel " , 0 , QApplication : : UnicodeUTF8 ) ) ; <nl> - # ifndef QT_NO_TOOLTIP <nl> - buttonCancel - > setProperty ( " toolTip " , QVariant ( QApplication : : translate ( " createTableForm " , " Cancel and close dialog box " , 0 , QApplication : : UnicodeUTF8 ) ) ) ; <nl> - # endif / / QT_NO_TOOLTIP <nl> - } / / retranslateUi <nl> - <nl> - } ; <nl> - <nl> - namespace Ui { <nl> - class createTableForm : public Ui_createTableForm { } ; <nl> - } / / namespace Ui <nl> - <nl> - class createTableForm : public QDialog , public Ui : : createTableForm <nl> - { <nl> - Q_OBJECT <nl> - <nl> - public : <nl> - createTableForm ( DBBrowserDB * db = 0 , QWidget * parent = 0 , Qt : : WindowFlags fl = Qt : : Window ) ; <nl> - ~ createTableForm ( ) ; <nl> - <nl> - QString createStatement ; <nl> - <nl> - public slots : <nl> - virtual void confirmCreate ( ) ; <nl> - virtual void addField ( ) ; <nl> - virtual void deleteField ( ) ; <nl> - virtual void fieldSelectionChanged ( ) ; <nl> - <nl> - protected slots : <nl> - virtual void languageChange ( ) ; <nl> - <nl> - private : <nl> - void init ( ) ; <nl> - DBBrowserDB * pdb ; <nl> - <nl> - } ; <nl> - <nl> - # endif / / CREATETABLEFORM_H <nl> mmm a / src / edittableform . cpp <nl> ppp b / src / edittableform . cpp <nl> void editTableForm : : setActiveTable ( DBBrowserDB * thedb , QString tableName ) <nl> { <nl> pdb = thedb ; <nl> curTable = tableName ; <nl> - populateFields ( ) ; <nl> + if ( curTable ! = " " ) <nl> + populateFields ( ) ; <nl> ui - > editTableName - > setText ( curTable ) ; <nl> + checkInput ( ) ; <nl> } <nl> <nl> void editTableForm : : populateFields ( ) <nl> void editTableForm : : populateFields ( ) <nl> <nl> void editTableForm : : accept ( ) <nl> { <nl> - / / Rename table if necessary <nl> - if ( ui - > editTableName - > text ( ) ! = curTable ) <nl> + / / Are we editing an already existing table or designing a new one ? In the first case there is a table name set , <nl> + / / in the latter the current table name is empty <nl> + if ( curTable = = " " ) <nl> { <nl> - QApplication : : setOverrideCursor ( Qt : : WaitCursor ) ; / / this might take time <nl> + / / Creation of new table <nl> + <nl> + / / Build SQL statement from what the use entered <nl> + QString sql = QString ( " CREATE TABLE ` % 1 ` ( " ) . arg ( ui - > editTableName - > text ( ) ) ; <nl> + for ( int i = 0 ; i < ui - > treeWidget - > topLevelItemCount ( ) ; i + + ) <nl> + sql . append ( QString ( " % 1 % 2 , " ) . arg ( ui - > treeWidget - > topLevelItem ( i ) - > text ( 0 ) ) . arg ( ui - > treeWidget - > topLevelItem ( i ) - > text ( 1 ) ) ) ; <nl> + sql . remove ( sql . count ( ) - 1 , 1 ) ; / / Remove last comma <nl> + sql . append ( " ) ; " ) ; <nl> + <nl> + / / Execute it <nl> modified = true ; <nl> - QString newName = ui - > editTableName - > text ( ) ; <nl> - QString sql = QString ( " ALTER TABLE ` % 1 ` RENAME TO ` % 2 ` " ) . arg ( curTable , newName ) ; <nl> if ( ! pdb - > executeSQL ( sql ) ) { <nl> - QApplication : : restoreOverrideCursor ( ) ; <nl> - QString error ( " Error renaming table . Message from database engine : \ n " ) ; <nl> + QString error ( " Error creating table . Message from database engine : \ n " ) ; <nl> error . append ( pdb - > lastErrorMessage ) . append ( " \ n \ n " ) . append ( sql ) ; <nl> QMessageBox : : warning ( this , QApplication : : applicationName ( ) , error ) ; <nl> - } else { <nl> - QApplication : : restoreOverrideCursor ( ) ; <nl> + return ; <nl> + } <nl> + } else { <nl> + / / Editing of old table <nl> + <nl> + / / Rename table if necessary <nl> + if ( ui - > editTableName - > text ( ) ! = curTable ) <nl> + { <nl> + QApplication : : setOverrideCursor ( Qt : : WaitCursor ) ; / / this might take time <nl> + modified = true ; <nl> + QString newName = ui - > editTableName - > text ( ) ; <nl> + QString sql = QString ( " ALTER TABLE ` % 1 ` RENAME TO ` % 2 ` " ) . arg ( curTable , newName ) ; <nl> + if ( ! pdb - > executeSQL ( sql ) ) { <nl> + QApplication : : restoreOverrideCursor ( ) ; <nl> + QString error ( " Error renaming table . Message from database engine : \ n " ) ; <nl> + error . append ( pdb - > lastErrorMessage ) . append ( " \ n \ n " ) . append ( sql ) ; <nl> + QMessageBox : : warning ( this , QApplication : : applicationName ( ) , error ) ; <nl> + return ; <nl> + } else { <nl> + QApplication : : restoreOverrideCursor ( ) ; <nl> + } <nl> } <nl> } <nl> + <nl> QDialog : : accept ( ) ; <nl> } <nl> <nl> void editTableForm : : editField ( ) <nl> QTreeWidgetItem * item = ui - > treeWidget - > currentItem ( ) ; <nl> editFieldForm * fieldForm = new editFieldForm ( this ) ; <nl> fieldForm - > setModal ( true ) ; <nl> - fieldForm - > setInitialValues ( pdb , false , curTable , item - > text ( 0 ) , item - > text ( 1 ) ) ; <nl> + fieldForm - > setInitialValues ( pdb , curTable = = " " , curTable , item - > text ( 0 ) , item - > text ( 1 ) ) ; <nl> if ( fieldForm - > exec ( ) ) <nl> { <nl> modified = true ; <nl> - / / do the sql rename here <nl> - / / qDebug ( fieldForm - > name + fieldForm - > type ) ; <nl> item - > setText ( 0 , fieldForm - > field_name ) ; <nl> item - > setText ( 1 , fieldForm - > field_type ) ; <nl> } <nl> void editTableForm : : addField ( ) <nl> addForm - > setInitialValues ( pdb , true , curTable , QString ( " " ) , QString ( " " ) ) ; <nl> if ( addForm - > exec ( ) ) <nl> { <nl> - modified = true ; <nl> - <nl> - QTreeWidgetItem * tbitem = new QTreeWidgetItem ( ) ; <nl> + QTreeWidgetItem * tbitem = new QTreeWidgetItem ( ui - > treeWidget ) ; <nl> tbitem - > setText ( 0 , addForm - > field_name ) ; <nl> - tbitem - > setText ( 1 , addForm - > field_name ) ; <nl> - / / do the sql creation here <nl> + tbitem - > setText ( 1 , addForm - > field_type ) ; <nl> modified = true ; <nl> - / / do the sql rename here <nl> - / / qDebug ( fieldForm - > name + fieldForm - > type ) ; <nl> - QString sql = " CREATE TEMPORARY TABLE TEMP_TABLE ( " ; <nl> + ui - > treeWidget - > addTopLevelItem ( tbitem ) ; <nl> <nl> } <nl> / / Q3ListViewItemIterator it ( fieldListView ) ; <nl> void editTableForm : : addField ( ) <nl> / / while ( it . current ( ) ) { <nl> / / item = it . current ( ) ; <nl> / / sql . append ( item - > text ( 0 ) ) ; <nl> - / / / sql . append ( " " ) ; <nl> + / / sql . append ( " " ) ; <nl> / / sql . append ( item - > text ( 1 ) ) ; <nl> / / if ( item - > nextSibling ( ) ! = 0 ) <nl> / / { <nl> mmm a / src / mainwindow . cpp <nl> ppp b / src / mainwindow . cpp <nl> <nl> # include < QStandardItemModel > <nl> # include < QDragEnterEvent > <nl> # include < QScrollBar > <nl> - # include " createtableform . h " <nl> # include " createindexform . h " <nl> # include " deletetableform . h " <nl> # include " deleteindexform . h " <nl> void MainWindow : : lookfor ( const QString & wfield , const QString & woperator , con <nl> QApplication : : restoreOverrideCursor ( ) ; <nl> } <nl> <nl> - <nl> void MainWindow : : showrecord ( int dec ) <nl> { <nl> updateTableView ( dec ) ; <nl> void MainWindow : : createTable ( ) <nl> QMessageBox : : information ( this , QApplication : : applicationName ( ) , " There is no database opened . Please open or create a new database file . " ) ; <nl> return ; <nl> } <nl> - createTableForm * tableForm = new createTableForm ( & db , this ) ; <nl> + <nl> + editTableForm * tableForm = new editTableForm ( this ) ; <nl> + tableForm - > setActiveTable ( & db , " " ) ; <nl> tableForm - > setModal ( true ) ; <nl> - if ( tableForm - > exec ( ) ) { <nl> - if ( ! db . executeSQL ( tableForm - > createStatement ) ) { <nl> - QString error = " Error : could not create the table . Message from database engine : " ; <nl> - error . append ( db . lastErrorMessage ) ; <nl> - QMessageBox : : warning ( this , QApplication : : applicationName ( ) , error ) ; <nl> - } else { <nl> - populateStructure ( ) ; <nl> - resetBrowser ( ) ; <nl> - } <nl> + if ( tableForm - > exec ( ) ) { <nl> + populateStructure ( ) ; <nl> + resetBrowser ( ) ; <nl> } <nl> } <nl> <nl> - <nl> void MainWindow : : createIndex ( ) <nl> { <nl> if ( ! db . isOpen ( ) ) { <nl> mmm a / src / src . pro <nl> ppp b / src / src . pro <nl> HEADERS + = \ <nl> sqlite_source / sqlite3 . h \ <nl> choosetableform . h \ <nl> createindexform . h \ <nl> - createtableform . h \ <nl> deleteindexform . h \ <nl> deletetableform . h \ <nl> editfieldform . h \ <nl> HEADERS + = \ <nl> importcsvform . h \ <nl> preferencesform . h \ <nl> mainwindow . h \ <nl> - createtabledialog . h \ <nl> SQLLogDock . h \ <nl> sqlitesyntaxhighlighter . h \ <nl> dialogabout . h <nl> SOURCES + = \ <nl> sqlite_source / sqlite3 . c \ <nl> choosetableform . cpp \ <nl> createindexform . cpp \ <nl> - createtableform . cpp \ <nl> deleteindexform . cpp \ <nl> deletetableform . cpp \ <nl> editfieldform . cpp \ <nl> SOURCES + = \ <nl> importcsvform . cpp \ <nl> preferencesform . cpp \ <nl> mainwindow . cpp \ <nl> - createtabledialog . cpp \ <nl> SQLLogDock . cpp \ <nl> sqlitesyntaxhighlighter . cpp \ <nl> dialogabout . cpp <nl> mac { <nl> RESOURCES + = icons / icons . qrc <nl> <nl> FORMS + = \ <nl> - createtabledialog . ui \ <nl> dialogabout . ui \ <nl> preferencesform . ui \ <nl> mainwindow . ui \ <nl> | Merge editTableForm and createTableForm | sqlitebrowser/sqlitebrowser | 43496c95498692069cc013caf7b0d211d8c5aefe | 2013-01-01T15:23:12Z |
mmm a / build . yaml <nl> ppp b / build . yaml <nl> node_modules : <nl> - src / node / src / client . js <nl> - src / node / src / common . js <nl> - src / node / src / credentials . js <nl> + - src / node / src / constants . js <nl> - src / node / src / grpc_extension . js <nl> - src / node / src / metadata . js <nl> - src / node / src / server . js <nl> | Update list of js files in build . yaml | grpc/grpc | 1ac096bada542e6ee19f9822a22dca36083580a5 | 2017-05-11T16:56:32Z |
deleted file mode 100644 <nl> index 2cb37cbd37 . . 0000000000 <nl> mmm a / vnpy / api / tap / vntap / include / brigand / functions / bitwise / shift_right . hpp <nl> ppp / dev / null <nl> <nl> - / * ! <nl> - @ file <nl> - <nl> - @ copyright Edouard Alligand and Joel Falcou 2015 - 2017 <nl> - ( See accompanying file LICENSE . md or copy at http : / / boost . org / LICENSE_1_0 . txt ) <nl> - * / <nl> - # ifndef BOOST_BRIGAND_FUNCTIONS_BITWISE_SHIFT_RIGHT_HPP <nl> - # define BOOST_BRIGAND_FUNCTIONS_BITWISE_SHIFT_RIGHT_HPP <nl> - <nl> - # include < brigand / types / integral_constant . hpp > <nl> - <nl> - namespace brigand <nl> - { <nl> - template < typename A , typename B > <nl> - struct shift_right : brigand : : integral_constant < typename A : : value_type , ( A : : value > > B : : value ) > { } ; <nl> - } <nl> - # endif <nl> | Delete shift_right . hpp | vnpy/vnpy | 3e5e5e6637c8aa5a92efd65f3e905e381cfc232f | 2020-03-06T06:52:39Z |
mmm a / src / core / hle / service / ldr / ldr . cpp <nl> ppp b / src / core / hle / service / ldr / ldr . cpp <nl> <nl> <nl> # include " common / alignment . h " <nl> # include " common / hex_util . h " <nl> + # include " common / scope_exit . h " <nl> # include " core / hle / ipc_helpers . h " <nl> + # include " core / hle / kernel / errors . h " <nl> + # include " core / hle / kernel / memory / page_table . h " <nl> + # include " core / hle / kernel / memory / system_control . h " <nl> # include " core / hle / kernel / process . h " <nl> # include " core / hle / service / ldr / ldr . h " <nl> # include " core / hle / service / service . h " <nl> # include " core / loader / nro . h " <nl> + # include " core / memory . h " <nl> <nl> namespace Service : : LDR { <nl> <nl> + constexpr ResultCode ERROR_INSUFFICIENT_ADDRESS_SPACE { ErrorModule : : RO , 2 } ; <nl> + <nl> constexpr ResultCode ERROR_INVALID_MEMORY_STATE { ErrorModule : : Loader , 51 } ; <nl> constexpr ResultCode ERROR_INVALID_NRO { ErrorModule : : Loader , 52 } ; <nl> constexpr ResultCode ERROR_INVALID_NRR { ErrorModule : : Loader , 53 } ; <nl> constexpr ResultCode ERROR_INVALID_NRO_ADDRESS { ErrorModule : : Loader , 84 } ; <nl> constexpr ResultCode ERROR_INVALID_NRR_ADDRESS { ErrorModule : : Loader , 85 } ; <nl> constexpr ResultCode ERROR_NOT_INITIALIZED { ErrorModule : : Loader , 87 } ; <nl> <nl> - constexpr u64 MAXIMUM_LOADED_RO = 0x40 ; <nl> + constexpr std : : size_t MAXIMUM_LOADED_RO { 0x40 } ; <nl> + constexpr std : : size_t MAXIMUM_MAP_RETRIES { 0x200 } ; <nl> + <nl> + struct NRRHeader { <nl> + u32_le magic ; <nl> + INSERT_PADDING_BYTES ( 12 ) ; <nl> + u64_le title_id_mask ; <nl> + u64_le title_id_pattern ; <nl> + INSERT_PADDING_BYTES ( 16 ) ; <nl> + std : : array < u8 , 0x100 > modulus ; <nl> + std : : array < u8 , 0x100 > signature_1 ; <nl> + std : : array < u8 , 0x100 > signature_2 ; <nl> + u64_le title_id ; <nl> + u32_le size ; <nl> + INSERT_PADDING_BYTES ( 4 ) ; <nl> + u32_le hash_offset ; <nl> + u32_le hash_count ; <nl> + INSERT_PADDING_BYTES ( 8 ) ; <nl> + } ; <nl> + static_assert ( sizeof ( NRRHeader ) = = 0x350 , " NRRHeader has incorrect size . " ) ; <nl> + <nl> + struct NROHeader { <nl> + INSERT_PADDING_WORDS ( 1 ) ; <nl> + u32_le mod_offset ; <nl> + INSERT_PADDING_WORDS ( 2 ) ; <nl> + u32_le magic ; <nl> + u32_le version ; <nl> + u32_le nro_size ; <nl> + u32_le flags ; <nl> + u32_le text_offset ; <nl> + u32_le text_size ; <nl> + u32_le ro_offset ; <nl> + u32_le ro_size ; <nl> + u32_le rw_offset ; <nl> + u32_le rw_size ; <nl> + u32_le bss_size ; <nl> + INSERT_PADDING_WORDS ( 1 ) ; <nl> + std : : array < u8 , 0x20 > build_id ; <nl> + INSERT_PADDING_BYTES ( 0x20 ) ; <nl> + } ; <nl> + static_assert ( sizeof ( NROHeader ) = = 0x80 , " NROHeader has invalid size . " ) ; <nl> + <nl> + using SHA256Hash = std : : array < u8 , 0x20 > ; <nl> + <nl> + struct NROInfo { <nl> + SHA256Hash hash { } ; <nl> + VAddr nro_address { } ; <nl> + std : : size_t nro_size { } ; <nl> + VAddr bss_address { } ; <nl> + std : : size_t bss_size { } ; <nl> + std : : size_t text_size { } ; <nl> + std : : size_t ro_size { } ; <nl> + std : : size_t data_size { } ; <nl> + VAddr src_addr { } ; <nl> + } ; <nl> <nl> class DebugMonitor final : public ServiceFramework < DebugMonitor > { <nl> public : <nl> class RelocatableObject final : public ServiceFramework < RelocatableObject > { <nl> { 0 , & RelocatableObject : : LoadNro , " LoadNro " } , <nl> { 1 , & RelocatableObject : : UnloadNro , " UnloadNro " } , <nl> { 2 , & RelocatableObject : : LoadNrr , " LoadNrr " } , <nl> - { 3 , & RelocatableObject : : UnloadNrr , " UnloadNrr " } , <nl> + { 3 , nullptr , " UnloadNrr " } , <nl> { 4 , & RelocatableObject : : Initialize , " Initialize " } , <nl> { 10 , nullptr , " LoadNrrEx " } , <nl> } ; <nl> class RelocatableObject final : public ServiceFramework < RelocatableObject > { <nl> rb . Push ( RESULT_SUCCESS ) ; <nl> } <nl> <nl> - void UnloadNrr ( Kernel : : HLERequestContext & ctx ) { <nl> - if ( ! initialized ) { <nl> - LOG_ERROR ( Service_LDR , " LDR : RO not initialized before use ! " ) ; <nl> - IPC : : ResponseBuilder rb { ctx , 2 } ; <nl> - rb . Push ( ERROR_NOT_INITIALIZED ) ; <nl> - return ; <nl> + bool ValidateRegionForMap ( Kernel : : Memory : : PageTable & page_table , VAddr start , <nl> + std : : size_t size ) const { <nl> + constexpr std : : size_t padding_size { 4 * Kernel : : Memory : : PageSize } ; <nl> + const auto start_info { page_table . QueryInfo ( start - 1 ) } ; <nl> + <nl> + if ( start_info . state ! = Kernel : : Memory : : MemoryState : : Free ) { <nl> + return { } ; <nl> } <nl> <nl> - struct Parameters { <nl> - u64_le process_id ; <nl> - u64_le nrr_address ; <nl> - } ; <nl> + if ( start_info . GetAddress ( ) > ( start - padding_size ) ) { <nl> + return { } ; <nl> + } <nl> <nl> - IPC : : RequestParser rp { ctx } ; <nl> - const auto [ process_id , nrr_address ] = rp . PopRaw < Parameters > ( ) ; <nl> + const auto end_info { page_table . QueryInfo ( start + size ) } ; <nl> <nl> - LOG_DEBUG ( Service_LDR , " called with process_id = { : 016X } , nrr_addr = { : 016X } " , process_id , <nl> - nrr_address ) ; <nl> + if ( end_info . state ! = Kernel : : Memory : : MemoryState : : Free ) { <nl> + return { } ; <nl> + } <nl> <nl> - if ( ! Common : : Is4KBAligned ( nrr_address ) ) { <nl> - LOG_ERROR ( Service_LDR , " NRR Address has invalid alignment ( actual { : 016X } ) ! " , <nl> - nrr_address ) ; <nl> - IPC : : ResponseBuilder rb { ctx , 2 } ; <nl> - rb . Push ( ERROR_INVALID_ALIGNMENT ) ; <nl> - return ; <nl> + return ( start + size + padding_size ) < = ( end_info . GetAddress ( ) + end_info . GetSize ( ) ) ; <nl> + } <nl> + <nl> + VAddr GetRandomMapRegion ( const Kernel : : Memory : : PageTable & page_table , std : : size_t size ) const { <nl> + VAddr addr { } ; <nl> + const std : : size_t end_pages { ( page_table . GetAliasCodeRegionSize ( ) - size ) > > <nl> + Kernel : : Memory : : PageBits } ; <nl> + do { <nl> + addr = page_table . GetAliasCodeRegionStart ( ) + <nl> + ( Kernel : : Memory : : SystemControl : : GenerateRandomRange ( 0 , end_pages ) <nl> + < < Kernel : : Memory : : PageBits ) ; <nl> + } while ( ! page_table . IsInsideAddressSpace ( addr , size ) | | <nl> + page_table . IsInsideHeapRegion ( addr , size ) | | <nl> + page_table . IsInsideAliasRegion ( addr , size ) ) ; <nl> + return addr ; <nl> + } <nl> + <nl> + ResultVal < VAddr > MapProcessCodeMemory ( Kernel : : Process * process , VAddr baseAddress , <nl> + u64 size ) const { <nl> + for ( int retry { } ; retry < MAXIMUM_MAP_RETRIES ; retry + + ) { <nl> + auto & page_table { process - > PageTable ( ) } ; <nl> + const VAddr addr { GetRandomMapRegion ( page_table , size ) } ; <nl> + const ResultCode result { page_table . MapProcessCodeMemory ( addr , baseAddress , size ) } ; <nl> + <nl> + if ( result = = Kernel : : ERR_INVALID_ADDRESS_STATE ) { <nl> + continue ; <nl> + } <nl> + <nl> + if ( result . IsError ( ) ) { <nl> + return result ; <nl> + } <nl> + <nl> + if ( ValidateRegionForMap ( page_table , addr , size ) ) { <nl> + return MakeResult < VAddr > ( addr ) ; <nl> + } <nl> } <nl> <nl> - const auto iter = nrr . find ( nrr_address ) ; <nl> - if ( iter = = nrr . end ( ) ) { <nl> - LOG_ERROR ( Service_LDR , <nl> - " Attempting to unload NRR which has not been loaded ! ( addr = { : 016X } ) " , <nl> - nrr_address ) ; <nl> - IPC : : ResponseBuilder rb { ctx , 2 } ; <nl> - rb . Push ( ERROR_INVALID_NRR_ADDRESS ) ; <nl> - return ; <nl> + return ERROR_INSUFFICIENT_ADDRESS_SPACE ; <nl> + } <nl> + <nl> + ResultVal < VAddr > MapNro ( Kernel : : Process * process , VAddr nro_addr , std : : size_t nro_size , <nl> + VAddr bss_addr , std : : size_t bss_size , std : : size_t size ) const { <nl> + <nl> + for ( int retry { } ; retry < MAXIMUM_MAP_RETRIES ; retry + + ) { <nl> + auto & page_table { process - > PageTable ( ) } ; <nl> + VAddr addr { } ; <nl> + <nl> + CASCADE_RESULT ( addr , MapProcessCodeMemory ( process , nro_addr , nro_size ) ) ; <nl> + <nl> + if ( bss_size ) { <nl> + auto block_guard = detail : : ScopeExit ( [ & ] { <nl> + page_table . UnmapProcessCodeMemory ( addr + nro_size , bss_addr , bss_size ) ; <nl> + page_table . UnmapProcessCodeMemory ( addr , nro_addr , nro_size ) ; <nl> + } ) ; <nl> + <nl> + const ResultCode result { <nl> + page_table . MapProcessCodeMemory ( addr + nro_size , bss_addr , bss_size ) } ; <nl> + <nl> + if ( result = = Kernel : : ERR_INVALID_ADDRESS_STATE ) { <nl> + continue ; <nl> + } <nl> + <nl> + if ( result . IsError ( ) ) { <nl> + return result ; <nl> + } <nl> + <nl> + block_guard . Cancel ( ) ; <nl> + } <nl> + <nl> + if ( ValidateRegionForMap ( page_table , addr , size ) ) { <nl> + return MakeResult < VAddr > ( addr ) ; <nl> + } <nl> } <nl> <nl> - nrr . erase ( iter ) ; <nl> - IPC : : ResponseBuilder rb { ctx , 2 } ; <nl> - rb . Push ( RESULT_SUCCESS ) ; <nl> + return ERROR_INSUFFICIENT_ADDRESS_SPACE ; <nl> + } <nl> + <nl> + ResultCode LoadNro ( Kernel : : Process * process , const NROHeader & nro_header , VAddr nro_addr , <nl> + VAddr start ) const { <nl> + const VAddr text_start { start + nro_header . text_offset } ; <nl> + const VAddr ro_start { start + nro_header . ro_offset } ; <nl> + const VAddr data_start { start + nro_header . rw_offset } ; <nl> + const VAddr bss_start { data_start + nro_header . rw_size } ; <nl> + const VAddr bss_end_addr { <nl> + Common : : AlignUp ( bss_start + nro_header . bss_size , Kernel : : Memory : : PageSize ) } ; <nl> + <nl> + auto CopyCode { [ & ] ( VAddr src_addr , VAddr dst_addr , u64 size ) { <nl> + std : : vector < u8 > source_data ( size ) ; <nl> + system . Memory ( ) . ReadBlock ( src_addr , source_data . data ( ) , source_data . size ( ) ) ; <nl> + system . Memory ( ) . WriteBlock ( dst_addr , source_data . data ( ) , source_data . size ( ) ) ; <nl> + } } ; <nl> + CopyCode ( nro_addr + nro_header . text_offset , text_start , nro_header . text_size ) ; <nl> + CopyCode ( nro_addr + nro_header . ro_offset , ro_start , nro_header . ro_size ) ; <nl> + CopyCode ( nro_addr + nro_header . rw_offset , data_start , nro_header . rw_size ) ; <nl> + <nl> + CASCADE_CODE ( process - > PageTable ( ) . SetCodeMemoryPermission ( <nl> + text_start , ro_start - text_start , Kernel : : Memory : : MemoryPermission : : ReadAndExecute ) ) ; <nl> + CASCADE_CODE ( process - > PageTable ( ) . SetCodeMemoryPermission ( <nl> + ro_start , data_start - ro_start , Kernel : : Memory : : MemoryPermission : : Read ) ) ; <nl> + <nl> + return process - > PageTable ( ) . SetCodeMemoryPermission ( <nl> + data_start , bss_end_addr - data_start , Kernel : : Memory : : MemoryPermission : : ReadAndWrite ) ; <nl> } <nl> <nl> void LoadNro ( Kernel : : HLERequestContext & ctx ) { <nl> class RelocatableObject final : public ServiceFramework < RelocatableObject > { <nl> return ; <nl> } <nl> <nl> - NROHeader header ; <nl> + / / Load and validate the NRO header <nl> + NROHeader header { } ; <nl> std : : memcpy ( & header , nro_data . data ( ) , sizeof ( NROHeader ) ) ; <nl> - <nl> if ( ! IsValidNRO ( header , nro_size , bss_size ) ) { <nl> LOG_ERROR ( Service_LDR , " NRO was invalid ! " ) ; <nl> IPC : : ResponseBuilder rb { ctx , 2 } ; <nl> class RelocatableObject final : public ServiceFramework < RelocatableObject > { <nl> return ; <nl> } <nl> <nl> - / / Load NRO as new executable module <nl> - auto * process = system . CurrentProcess ( ) ; <nl> - auto & vm_manager = process - > VMManager ( ) ; <nl> - auto map_address = vm_manager . FindFreeRegion ( nro_size + bss_size ) ; <nl> - <nl> - if ( ! map_address . Succeeded ( ) | | <nl> - * map_address + nro_size + bss_size > vm_manager . GetAddressSpaceEndAddress ( ) ) { <nl> - <nl> - LOG_ERROR ( Service_LDR , <nl> - " General error while allocation memory or no available memory to allocate ! " ) ; <nl> + / / Map memory for the NRO <nl> + const ResultVal < VAddr > map_result { MapNro ( system . CurrentProcess ( ) , nro_address , nro_size , <nl> + bss_address , bss_size , nro_size + bss_size ) } ; <nl> + if ( map_result . Failed ( ) ) { <nl> IPC : : ResponseBuilder rb { ctx , 2 } ; <nl> - rb . Push ( ERROR_INVALID_MEMORY_STATE ) ; <nl> - return ; <nl> + rb . Push ( map_result . Code ( ) ) ; <nl> } <nl> <nl> - / / Mark text and read - only region as ModuleCode <nl> - ASSERT ( vm_manager <nl> - . MirrorMemory ( * map_address , nro_address , header . text_size + header . ro_size , <nl> - Kernel : : MemoryState : : ModuleCode ) <nl> - . IsSuccess ( ) ) ; <nl> - / / Mark read / write region as ModuleCodeData , which is necessary if this region is used for <nl> - / / TransferMemory ( e . g . Final Fantasy VIII Remastered does this ) <nl> - ASSERT ( vm_manager <nl> - . MirrorMemory ( * map_address + header . rw_offset , nro_address + header . rw_offset , <nl> - header . rw_size , Kernel : : MemoryState : : ModuleCodeData ) <nl> - . IsSuccess ( ) ) ; <nl> - / / Revoke permissions from the old memory region <nl> - ASSERT ( vm_manager . ReprotectRange ( nro_address , nro_size , Kernel : : VMAPermission : : None ) <nl> - . IsSuccess ( ) ) ; <nl> - <nl> - if ( bss_size > 0 ) { <nl> - / / Mark BSS region as ModuleCodeData , which is necessary if this region is used for <nl> - / / TransferMemory ( e . g . Final Fantasy VIII Remastered does this ) <nl> - ASSERT ( vm_manager <nl> - . MirrorMemory ( * map_address + nro_size , bss_address , bss_size , <nl> - Kernel : : MemoryState : : ModuleCodeData ) <nl> - . IsSuccess ( ) ) ; <nl> - ASSERT ( vm_manager . ReprotectRange ( bss_address , bss_size , Kernel : : VMAPermission : : None ) <nl> - . IsSuccess ( ) ) ; <nl> + / / Load the NRO into the mapped memory <nl> + if ( const ResultCode result { <nl> + LoadNro ( system . CurrentProcess ( ) , header , nro_address , * map_result ) } ; <nl> + result . IsError ( ) ) { <nl> + IPC : : ResponseBuilder rb { ctx , 2 } ; <nl> + rb . Push ( map_result . Code ( ) ) ; <nl> } <nl> <nl> - vm_manager . ReprotectRange ( * map_address , header . text_size , <nl> - Kernel : : VMAPermission : : ReadExecute ) ; <nl> - vm_manager . ReprotectRange ( * map_address + header . ro_offset , header . ro_size , <nl> - Kernel : : VMAPermission : : Read ) ; <nl> - vm_manager . ReprotectRange ( * map_address + header . rw_offset , header . rw_size , <nl> - Kernel : : VMAPermission : : ReadWrite ) ; <nl> + / / Track the loaded NRO <nl> + nro . insert_or_assign ( * map_result , NROInfo { hash , * map_result , nro_size , bss_address , <nl> + bss_size , header . text_size , header . ro_size , <nl> + header . rw_size , nro_address } ) ; <nl> <nl> + / / Invalidate JIT caches for the newly mapped process code <nl> system . InvalidateCpuInstructionCaches ( ) ; <nl> <nl> - nro . insert_or_assign ( * map_address , <nl> - NROInfo { hash , nro_address , nro_size , bss_address , bss_size } ) ; <nl> - <nl> IPC : : ResponseBuilder rb { ctx , 4 } ; <nl> rb . Push ( RESULT_SUCCESS ) ; <nl> - rb . Push ( * map_address ) ; <nl> + rb . Push ( * map_result ) ; <nl> + } <nl> + <nl> + ResultCode UnmapNro ( const NROInfo & info ) { <nl> + / / Each region must be unmapped separately to validate memory state <nl> + auto & page_table { system . CurrentProcess ( ) - > PageTable ( ) } ; <nl> + CASCADE_CODE ( page_table . UnmapProcessCodeMemory ( info . nro_address + info . text_size + <nl> + info . ro_size + info . data_size , <nl> + info . bss_address , info . bss_size ) ) ; <nl> + CASCADE_CODE ( page_table . UnmapProcessCodeMemory ( <nl> + info . nro_address + info . text_size + info . ro_size , <nl> + info . src_addr + info . text_size + info . ro_size , info . data_size ) ) ; <nl> + CASCADE_CODE ( page_table . UnmapProcessCodeMemory ( <nl> + info . nro_address + info . text_size , info . src_addr + info . text_size , info . ro_size ) ) ; <nl> + CASCADE_CODE ( <nl> + page_table . UnmapProcessCodeMemory ( info . nro_address , info . src_addr , info . text_size ) ) ; <nl> + return RESULT_SUCCESS ; <nl> } <nl> <nl> void UnloadNro ( Kernel : : HLERequestContext & ctx ) { <nl> class RelocatableObject final : public ServiceFramework < RelocatableObject > { <nl> return ; <nl> } <nl> <nl> - auto & vm_manager = system . CurrentProcess ( ) - > VMManager ( ) ; <nl> - const auto & nro_info = iter - > second ; <nl> - <nl> - / / Unmap the mirrored memory <nl> - ASSERT ( <nl> - vm_manager . UnmapRange ( nro_address , nro_info . nro_size + nro_info . bss_size ) . IsSuccess ( ) ) ; <nl> - <nl> - / / Reprotect the source memory <nl> - ASSERT ( vm_manager <nl> - . ReprotectRange ( nro_info . nro_address , nro_info . nro_size , <nl> - Kernel : : VMAPermission : : ReadWrite ) <nl> - . IsSuccess ( ) ) ; <nl> - if ( nro_info . bss_size > 0 ) { <nl> - ASSERT ( vm_manager <nl> - . ReprotectRange ( nro_info . bss_address , nro_info . bss_size , <nl> - Kernel : : VMAPermission : : ReadWrite ) <nl> - . IsSuccess ( ) ) ; <nl> - } <nl> + const ResultCode result { UnmapNro ( iter - > second ) } ; <nl> <nl> system . InvalidateCpuInstructionCaches ( ) ; <nl> <nl> nro . erase ( iter ) ; <nl> + <nl> IPC : : ResponseBuilder rb { ctx , 2 } ; <nl> - rb . Push ( RESULT_SUCCESS ) ; <nl> + <nl> + rb . Push ( result ) ; <nl> } <nl> <nl> void Initialize ( Kernel : : HLERequestContext & ctx ) { <nl> class RelocatableObject final : public ServiceFramework < RelocatableObject > { <nl> } <nl> <nl> private : <nl> - using SHA256Hash = std : : array < u8 , 0x20 > ; <nl> - <nl> - struct NROHeader { <nl> - INSERT_PADDING_WORDS ( 1 ) ; <nl> - u32_le mod_offset ; <nl> - INSERT_PADDING_WORDS ( 2 ) ; <nl> - u32_le magic ; <nl> - u32_le version ; <nl> - u32_le nro_size ; <nl> - u32_le flags ; <nl> - u32_le text_offset ; <nl> - u32_le text_size ; <nl> - u32_le ro_offset ; <nl> - u32_le ro_size ; <nl> - u32_le rw_offset ; <nl> - u32_le rw_size ; <nl> - u32_le bss_size ; <nl> - INSERT_PADDING_WORDS ( 1 ) ; <nl> - std : : array < u8 , 0x20 > build_id ; <nl> - INSERT_PADDING_BYTES ( 0x20 ) ; <nl> - } ; <nl> - static_assert ( sizeof ( NROHeader ) = = 0x80 , " NROHeader has invalid size . " ) ; <nl> - <nl> - struct NRRHeader { <nl> - u32_le magic ; <nl> - INSERT_PADDING_BYTES ( 12 ) ; <nl> - u64_le title_id_mask ; <nl> - u64_le title_id_pattern ; <nl> - INSERT_PADDING_BYTES ( 16 ) ; <nl> - std : : array < u8 , 0x100 > modulus ; <nl> - std : : array < u8 , 0x100 > signature_1 ; <nl> - std : : array < u8 , 0x100 > signature_2 ; <nl> - u64_le title_id ; <nl> - u32_le size ; <nl> - INSERT_PADDING_BYTES ( 4 ) ; <nl> - u32_le hash_offset ; <nl> - u32_le hash_count ; <nl> - INSERT_PADDING_BYTES ( 8 ) ; <nl> - } ; <nl> - static_assert ( sizeof ( NRRHeader ) = = 0x350 , " NRRHeader has incorrect size . " ) ; <nl> - <nl> - struct NROInfo { <nl> - SHA256Hash hash ; <nl> - VAddr nro_address ; <nl> - u64 nro_size ; <nl> - VAddr bss_address ; <nl> - u64 bss_size ; <nl> - } ; <nl> - <nl> - bool initialized = false ; <nl> + bool initialized { } ; <nl> <nl> std : : map < VAddr , NROInfo > nro ; <nl> std : : map < VAddr , std : : vector < SHA256Hash > > nrr ; <nl> | service : ldr : Updates for new VMM . | yuzu-emu/yuzu | 37b79ebe854003d2ba1d08a4523fd8cab418d485 | 2020-04-17T04:59:35Z |
deleted file mode 100644 <nl> index c3ae667f048d . . 000000000000 <nl> mmm a / test / decl / protocol / recursive_requirement2 . swift <nl> ppp / dev / null <nl> <nl> - / / RUN : % swift - parse % s - verify <nl> - <nl> - protocol P { <nl> - typealias A : P <nl> - } <nl> - <nl> - struct X < T : P > { <nl> - } <nl> - <nl> - func f < T : P > ( ) { <nl> - let x = X < T . A > ( ) <nl> - } <nl> deleted file mode 100644 <nl> index c953770a7164 . . 000000000000 <nl> mmm a / test / decl / protocol / recursive_requirement3 . swift <nl> ppp / dev / null <nl> <nl> - / / RUN : % swift - parse % s - verify <nl> - <nl> - protocol PP { <nl> - typealias A : P = Self <nl> - } <nl> - <nl> - protocol P : PP { <nl> - typealias A = Self <nl> - } <nl> - <nl> - struct X < T : P > { <nl> - } <nl> - <nl> - struct Y : P { <nl> - typealias A = Y <nl> - } <nl> - <nl> - func f < T : P > ( ) { <nl> - let x = X < T . A > ( ) <nl> - } <nl> \ No newline at end of file <nl> deleted file mode 100644 <nl> index 0a42907902a3 . . 000000000000 <nl> mmm a / test / decl / protocol / recursive_requirement4 . swift <nl> ppp / dev / null <nl> <nl> - / / RUN : % swift - parse % s - verify <nl> - <nl> - protocol P0 { <nl> - typealias A : P = Self <nl> - } <nl> - <nl> - protocol P : P0 { } <nl> - <nl> - protocol DeclaredP : P0 , P { } <nl> - <nl> - struct Y : DeclaredP { <nl> - } <nl> - <nl> - struct X < T : P > { } <nl> - <nl> - func f < T : P > ( a : T ) { <nl> - let works = X < T . A > ( ) <nl> - } <nl> - <nl> - f ( Y ( ) ) <nl> | Remove unnecessary test files . | apple/swift | bc47406486e8f7781e19efc9364f9efa5d3436d7 | 2014-06-20T00:34:20Z |
mmm a / src / chainparams . cpp <nl> ppp b / src / chainparams . cpp <nl> class SigNetParams : public CChainParams { <nl> vSeeds . clear ( ) ; <nl> <nl> if ( ! args . IsArgSet ( " - signetchallenge " ) ) { <nl> - LogPrintf ( " Using default signet network \ n " ) ; <nl> bin = ParseHex ( " 512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae " ) ; <nl> vSeeds . emplace_back ( " 178 . 128 . 221 . 177 " ) ; <nl> vSeeds . emplace_back ( " 2a01 : 7c8 : d005 : 390 : : 5 " ) ; <nl> class SigNetParams : public CChainParams { <nl> h < < consensus . signet_challenge ; <nl> uint256 hash = h . GetHash ( ) ; <nl> memcpy ( pchMessageStart , hash . begin ( ) , 4 ) ; <nl> - LogPrintf ( " Signet derived magic ( message start ) : % s \ n " , HexStr ( { pchMessageStart , pchMessageStart + 4 } ) ) ; <nl> <nl> nDefaultPort = 38333 ; <nl> nPruneAfterHeight = 1000 ; <nl> mmm a / src / init . cpp <nl> ppp b / src / init . cpp <nl> <nl> # include < policy / fees . h > <nl> # include < policy / policy . h > <nl> # include < policy / settings . h > <nl> + # include < protocol . h > <nl> # include < rpc / blockchain . h > <nl> # include < rpc / register . h > <nl> # include < rpc / server . h > <nl> bool AppInitParameterInteraction ( const ArgsManager & args ) <nl> / / specified in default section of config file , but not overridden <nl> / / on the command line or in this network ' s section of the config file . <nl> std : : string network = args . GetChainName ( ) ; <nl> + if ( network = = CBaseChainParams : : SIGNET ) { <nl> + LogPrintf ( " Signet derived magic ( message start ) : % s \ n " , HexStr ( chainparams . MessageStart ( ) ) ) ; <nl> + } <nl> bilingual_str errors ; <nl> for ( const auto & arg : args . GetUnsuitableSectionOnlyArgs ( ) ) { <nl> errors + = strprintf ( _ ( " Config setting for % s only applied on % s network when in [ % s ] section . " ) + Untranslated ( " \ n " ) , arg , network , network ) ; <nl> mmm a / test / functional / feature_signet . py <nl> ppp b / test / functional / feature_signet . py <nl> def run_test ( self ) : <nl> <nl> assert_equal ( self . nodes [ 4 ] . submitblock ( signet_blocks [ 0 ] ) , ' bad - signet - blksig ' ) <nl> <nl> + self . log . info ( " test that signet logs the network magic on node start " ) <nl> + with self . nodes [ 0 ] . assert_debug_log ( [ " Signet derived magic ( message start ) " ] ) : <nl> + self . restart_node ( 0 ) <nl> + <nl> <nl> if __name__ = = ' __main__ ' : <nl> SignetBasicTest ( ) . main ( ) <nl> | signet : do not log signet startup messages for other chains | bitcoin/bitcoin | 6fccad7f711df330e461c1fab3f758d078345ed5 | 2020-10-01T09:25:42Z |
mmm a / docs / rql / src / jsonobject . yaml <nl> ppp b / docs / rql / src / jsonobject . yaml <nl> commands : <nl> <nl> io : <nl> - - r <nl> - - value <nl> + - value <nl> <nl> examples : <nl> - description : Get all users whose age is greater than 5 . <nl> commands : <nl> r . table ( ' marvel ' ) . get ( ' IronMan ' ) . merge ( <nl> r . table ( ' loadouts ' ) . get ( ' alienInvasionKit ' ) ) . run ( conn , callback ) <nl> <nl> + - description : < code > Merge < / code > can be used recursively to modify object within objects . <nl> + code : <nl> + py : | - <nl> + " r . expr ( { ' weapons ' : { ' spectacular graviton beam ' : { ' dmg ' : 10 , ' cooldown ' : 20 } } } ) . merge ( <nl> + { ' weapons ' : { ' spectacular graviton beam ' : { ' dmg ' : 10 } } } ) . run ( conn ) " <nl> + rb : | - <nl> + " r ( { : weapons = > { : spectacular_graviton_beam ' = > { : dmg = > 10 , : cooldown = > 20 } } } ) . merge ( <nl> + { : weapons = > { : spectacular_graviton_beam = > { : dmg = > 10 } } } ) . run ( conn ) " <nl> + js : | - <nl> + " r . expr ( { weapons : { spectacular_graviton_beam : { dmg : 10 , cooldown : 20 } } } ) . merge ( <nl> + { weapons : { spectacular_graviton_beam : { dmg : 10 } } } ) . run ( conn ) " <nl> + <nl> + - description : To replace a nested object with another object you can use the < code > literal < / code > keyword . <nl> + code : <nl> + py : | - <nl> + " r . expr ( { ' weapons ' : { ' spectacular graviton beam ' : { ' dmg ' : 10 , ' cooldown ' : 20 } } } ) . merge ( <nl> + { ' weapons ' : r . literal ( { ' repulsor rays ' : { ' dmg ' : 3 , ' cooldown ' : 0 } } ) } ) . run ( conn ) " <nl> + rb : | - <nl> + " r ( { : weapons = > { : spectacular_graviton_beam ' = > { : dmg = > 10 , : cooldown = > 20 } } } ) . merge ( <nl> + { : weapons = > r . literal ( { : repulsor_rays = > { : dmg = > 3 , : cooldown = > 0 } } ) } ) . run ( conn ) " <nl> + js : | - <nl> + " r . expr ( { weapons : { spectacular_graviton_beam : { dmg : 10 , cooldown : 20 } } } ) . merge ( <nl> + { weapons : r . literal ( { repulsor_rays : { dmg : 3 , : cooldown = > 0 } } ) } ) . run ( conn ) " <nl> + <nl> + - description : < code > Literal < / code > can be used to remove keys from an object as well . <nl> + code : <nl> + py : | - <nl> + " r . expr ( { ' weapons ' : { ' spectacular graviton beam ' : { ' dmg ' : 10 , ' cooldown ' : 20 } } } ) . merge ( <nl> + { ' weapons ' : { ' spectacular graviton beam ' : r . literal ( ) } } ) . run ( conn ) " <nl> + rb : | - <nl> + " r ( { : weapons = > { : spectacular_graviton_beam ' = > { : dmg = > 10 , : cooldown = > 20 } } } ) . merge ( <nl> + { : weapons = > { : spectacular_graviton_beam = > r . literal ( ) } } ) . run ( conn ) " <nl> + js : | - <nl> + " r . expr ( { weapons : { spectacular_graviton_beam : { dmg : 10 , cooldown : 20 } } } ) . merge ( <nl> + { weapons : { spectacular_graviton_beam : r . literal ( ) } } ) . run ( conn ) " <nl> + <nl> - tag : append <nl> section : jsonobject <nl> description : Append a value to an array . <nl> commands : <nl> io : <nl> - - sequence <nl> - sequence <nl> - - - singleSelection <nl> + - - singleSelection <nl> - value <nl> - - object <nl> - value <nl> commands : <nl> js : r . expr ( [ " Iron Man " , " Bruce " , " Spider - Man " ] ) . changeAt ( 1 , " Hulk " ) . run ( conn , callback ) <nl> py : r . expr ( [ " Iron Man " , " Bruce " , " Spider - Man " ] ) . change_at ( 1 , " Hulk " ) . run ( conn ) <nl> rb : r . expr ( [ " Iron Man " , " Bruce " , " Spider - Man " ] ) . change_at ( 1 , " Hulk " ) . run ( conn ) <nl> - <nl> + <nl> - tag : keys <nl> section : jsonobject <nl> description : Return an array containing all of the object ' s keys . <nl> mmm a / drivers / javascript / ast . coffee <nl> ppp b / drivers / javascript / ast . coffee <nl> class Desc extends RDBOp <nl> tt : " DESC " <nl> st : ' desc ' <nl> <nl> + class Literal extends RDBOp <nl> + tt : " LITERAL " <nl> + st : ' literal ' <nl> + <nl> class ISO8601 extends RDBOp <nl> tt : ' ISO8601 ' <nl> st : ' iso8601 ' <nl> rethinkdb . mod = ar ( a , b ) - > new Mod { } , a , b <nl> rethinkdb . typeOf = ar ( val ) - > new TypeOf { } , val <nl> rethinkdb . info = ar ( val ) - > new Info { } , val <nl> <nl> + rethinkdb . literal = varar 0 , 1 , ( args . . . ) - > new Literal { } , args . . . <nl> + <nl> rethinkdb . iso8601 = ar ( str ) - > new ISO8601 { } , str <nl> rethinkdb . epochTime = ar ( num ) - > new EpochTime { } , num <nl> rethinkdb . now = ar ( ) - > new Now { } <nl> mmm a / drivers / python / rethinkdb / __init__ . py <nl> ppp b / drivers / python / rethinkdb / __init__ . py <nl> <nl> # This file includes all public facing Python API functions <nl> <nl> from net import connect , Connection , Cursor , protobuf_implementation <nl> - from query import js , json , error , do , row , table , db , db_create , db_drop , db_list , table_create , table_drop , table_list , branch , count , sum , avg , asc , desc , eq , ne , le , ge , lt , gt , any , all , add , sub , mul , div , mod , type_of , info , time , monday , tuesday , wednesday , thursday , friday , saturday , sunday , january , february , march , april , may , june , july , august , september , october , november , december , iso8601 , epoch_time , now <nl> + from query import js , json , error , do , row , table , db , db_create , db_drop , db_list , table_create , table_drop , table_list , branch , count , sum , avg , asc , desc , eq , ne , le , ge , lt , gt , any , all , add , sub , mul , div , mod , type_of , info , time , monday , tuesday , wednesday , thursday , friday , saturday , sunday , january , february , march , april , may , june , july , august , september , october , november , december , iso8601 , epoch_time , now , literal <nl> from errors import RqlError , RqlClientError , RqlCompileError , RqlRuntimeError , RqlDriverError <nl> from ast import expr , exprJSON , RqlQuery <nl> mmm a / drivers / python / rethinkdb / ast . py <nl> ppp b / drivers / python / rethinkdb / ast . py <nl> class Asc ( RqlTopLevelQuery ) : <nl> class Desc ( RqlTopLevelQuery ) : <nl> tt = p . Term . DESC <nl> st = ' desc ' <nl> + <nl> + class Literal ( RqlTopLevelQuery ) : <nl> + tt = p . Term . LITERAL <nl> + st = ' literal ' <nl> mmm a / drivers / python / rethinkdb / query . py <nl> ppp b / drivers / python / rethinkdb / query . py <nl> <nl> from ast import * <nl> import ql2_pb2 as p <nl> import datetime <nl> - import pytz <nl> <nl> " " " <nl> All top level functions defined here are the starting points for RQL queries <nl> def epoch_time ( number ) : <nl> def now ( ) : <nl> return Now ( ) <nl> <nl> - # # Time enum values <nl> + # Time enum values <nl> monday = type ( ' ' , ( RqlTopLevelQuery , ) , { ' tt ' : p . Term . MONDAY } ) ( ) <nl> tuesday = type ( ' ' , ( RqlTopLevelQuery , ) , { ' tt ' : p . Term . TUESDAY } ) ( ) <nl> wednesday = type ( ' ' , ( RqlTopLevelQuery , ) , { ' tt ' : p . Term . WEDNESDAY } ) ( ) <nl> def now ( ) : <nl> october = type ( ' ' , ( RqlTopLevelQuery , ) , { ' tt ' : p . Term . OCTOBER } ) ( ) <nl> november = type ( ' ' , ( RqlTopLevelQuery , ) , { ' tt ' : p . Term . NOVEMBER } ) ( ) <nl> december = type ( ' ' , ( RqlTopLevelQuery , ) , { ' tt ' : p . Term . DECEMBER } ) ( ) <nl> + <nl> + # Merge values <nl> + def literal ( val = ( ) ) : <nl> + if val : <nl> + return Literal ( val ) <nl> + else : <nl> + return Literal ( ) <nl> mmm a / src / rdb_protocol / datum . cc <nl> ppp b / src / rdb_protocol / datum . cc <nl> <nl> # include " rdb_protocol / error . hpp " <nl> # include " rdb_protocol / proto_utils . hpp " <nl> # include " rdb_protocol / pseudo_time . hpp " <nl> + # include " rdb_protocol / pseudo_literal . hpp " <nl> # include " stl_utils . hpp " <nl> <nl> namespace ql { <nl> <nl> + const std : : set < std : : string > datum_t : : _allowed_pts = std : : set < std : : string > ( ) ; <nl> + <nl> const char * const datum_t : : reql_type_string = " $ reql_type $ " ; <nl> <nl> + std : : set < std : : string > datum_ptr_t : : default_allowed_ptypes = std : : set < std : : string > ( ) ; <nl> + <nl> datum_t : : datum_t ( type_t _type , bool _bool ) : type ( _type ) , r_bool ( _bool ) { <nl> r_sanity_check ( _type = = R_BOOL ) ; <nl> } <nl> int datum_t : : pseudo_cmp ( const datum_t & rhs ) const { <nl> rfail ( base_exc_t : : GENERIC , " Incomparable type % s . " , get_type_name ( ) . c_str ( ) ) ; <nl> } <nl> <nl> - void datum_t : : rcheck_is_ptype ( const std : : string s ) const { <nl> - rcheck ( is_ptype ( ) , base_exc_t : : GENERIC , <nl> - ( s = = " " <nl> - ? strprintf ( " Not a pseudotype : ` % s ` . " , trunc_print ( ) . c_str ( ) ) <nl> - : strprintf ( " Not a % s pseudotype : ` % s ` . " , <nl> - s . c_str ( ) , <nl> - trunc_print ( ) . c_str ( ) ) ) ) ; <nl> - } <nl> - <nl> - void datum_t : : maybe_sanitize_ptype ( ) { <nl> + void datum_t : : maybe_sanitize_ptype ( const std : : set < std : : string > & allowed_pts ) { <nl> if ( is_ptype ( ) ) { <nl> if ( get_reql_type ( ) = = pseudo : : time_string ) { <nl> pseudo : : sanitize_time ( this ) ; <nl> return ; <nl> } <nl> + if ( get_reql_type ( ) = = pseudo : : literal_string ) { <nl> + rcheck ( std_contains ( allowed_pts , pseudo : : literal_string ) , <nl> + base_exc_t : : GENERIC , <nl> + " Stray literal keyword found , literal can only be present inside " <nl> + " merge and cannot nest inside other literals . " ) ; <nl> + pseudo : : rcheck_literal_valid ( this ) ; <nl> + return ; <nl> + } <nl> rfail ( base_exc_t : : GENERIC , " Unknown $ reql_type $ ` % s ` . " , get_type_name ( ) . c_str ( ) ) ; <nl> } <nl> } <nl> <nl> + void datum_t : : rcheck_is_ptype ( const std : : string s ) const { <nl> + rcheck ( is_ptype ( ) , base_exc_t : : GENERIC , <nl> + ( s = = " " <nl> + ? strprintf ( " Not a pseudotype : ` % s ` . " , trunc_print ( ) . c_str ( ) ) <nl> + : strprintf ( " Not a % s pseudotype : ` % s ` . " , <nl> + s . c_str ( ) , <nl> + trunc_print ( ) . c_str ( ) ) ) ) ; <nl> + } <nl> + <nl> std : : string datum_t : : print_primary ( ) const { <nl> std : : string s ; <nl> switch ( get_type ( ) ) { <nl> MUST_USE bool datum_t : : delete_field ( const std : : string & key ) { <nl> } <nl> <nl> counted_t < const datum_t > datum_t : : merge ( counted_t < const datum_t > rhs ) const { <nl> + if ( get_type ( ) ! = R_OBJECT | | rhs - > get_type ( ) ! = R_OBJECT ) { return rhs ; } <nl> + <nl> datum_ptr_t d ( as_object ( ) ) ; <nl> const std : : map < std : : string , counted_t < const datum_t > > & rhs_obj = rhs - > as_object ( ) ; <nl> for ( auto it = rhs_obj . begin ( ) ; it ! = rhs_obj . end ( ) ; + + it ) { <nl> - UNUSED bool b = d . add ( it - > first , it - > second , CLOBBER ) ; <nl> + counted_t < const datum_t > sub_lhs = d - > get ( it - > first , NOTHROW ) ; <nl> + bool is_literal = it - > second - > is_ptype ( pseudo : : literal_string ) ; <nl> + <nl> + if ( it - > second - > get_type ( ) = = R_OBJECT & & sub_lhs & & ! is_literal ) { <nl> + UNUSED bool b = d . add ( it - > first , sub_lhs - > merge ( it - > second ) , CLOBBER ) ; <nl> + } else { <nl> + if ( is_literal ) { <nl> + counted_t < const datum_t > value = it - > second - > get ( pseudo : : value_key , NOTHROW ) ; <nl> + if ( value ) { <nl> + UNUSED bool b = d . add ( it - > first , value , CLOBBER ) ; <nl> + } else { <nl> + UNUSED bool b = d . delete_field ( it - > first ) ; <nl> + } <nl> + } else { <nl> + UNUSED bool b = d . add ( it - > first , it - > second , CLOBBER ) ; <nl> + } <nl> + } <nl> } <nl> return d . to_counted ( ) ; <nl> } <nl> void datum_t : : init_from_pb ( const Datum * d ) { <nl> strprintf ( " Duplicate key % s in object . " , key . c_str ( ) ) ) ; <nl> ( * r_object ) [ key ] = make_counted < datum_t > ( & ap - > val ( ) ) ; <nl> } <nl> - maybe_sanitize_ptype ( ) ; <nl> + std : : set < std : : string > allowed_ptypes = { pseudo : : literal_string } ; <nl> + maybe_sanitize_ptype ( allowed_ptypes ) ; <nl> } break ; <nl> default : unreachable ( ) ; <nl> } <nl> mmm a / src / rdb_protocol / datum . hpp <nl> ppp b / src / rdb_protocol / datum . hpp <nl> class datum_t : public slow_atomic_countable_t < datum_t > , public rcheckable_t { <nl> void array_to_str_key ( std : : string * str_out ) const ; <nl> <nl> int pseudo_cmp ( const datum_t & rhs ) const ; <nl> - void maybe_sanitize_ptype ( ) ; <nl> + static const std : : set < std : : string > _allowed_pts ; <nl> + void maybe_sanitize_ptype ( const std : : set < std : : string > & allowed_pts = _allowed_pts ) ; <nl> <nl> type_t type ; <nl> union { <nl> class datum_ptr_t { <nl> public : <nl> template < class . . . Args > <nl> datum_ptr_t ( Args . . . args ) : _p ( make_scoped < datum_t > ( args . . . ) ) { } <nl> - counted_t < const datum_t > to_counted ( ) { <nl> - ptr ( ) - > maybe_sanitize_ptype ( ) ; <nl> + counted_t < const datum_t > to_counted ( <nl> + const std : : set < std : : string > & allowed_ptypes = default_allowed_ptypes ) { <nl> + ptr ( ) - > maybe_sanitize_ptype ( allowed_ptypes ) ; <nl> return counted_t < const datum_t > ( _p . release ( ) ) ; <nl> } <nl> const datum_t * operator - > ( ) const { return const_ptr ( ) ; } <nl> class datum_ptr_t { <nl> return _p . get ( ) ; <nl> } <nl> scoped_ptr_t < datum_t > _p ; <nl> + <nl> + static std : : set < std : : string > default_allowed_ptypes ; <nl> } ; <nl> <nl> # ifndef NDEBUG <nl> mmm a / src / rdb_protocol / func . cc <nl> ppp b / src / rdb_protocol / func . cc <nl> archive_result_t wire_func_t : : rdb_deserialize ( read_stream_t * stream ) { <nl> func_term_t : : func_term_t ( env_t * env , protob_t < const Term > term ) <nl> : term_t ( env , term ) , func ( make_counted < func_t > ( env , term ) ) { } <nl> <nl> - counted_t < val_t > func_term_t : : eval_impl ( ) { <nl> + counted_t < val_t > func_term_t : : eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( func ) ; <nl> } <nl> <nl> mmm a / src / rdb_protocol / func . hpp <nl> ppp b / src / rdb_protocol / func . hpp <nl> class func_term_t : public term_t { <nl> func_term_t ( env_t * env , protob_t < const Term > term ) ; <nl> private : <nl> virtual bool is_deterministic_impl ( ) const ; <nl> - virtual counted_t < val_t > eval_impl ( ) ; <nl> + virtual counted_t < val_t > eval_impl ( eval_flags_t flags ) ; <nl> virtual const char * name ( ) const { return " func " ; } <nl> counted_t < func_t > func ; <nl> } ; <nl> mmm a / src / rdb_protocol / op . cc <nl> ppp b / src / rdb_protocol / op . cc <nl> op_term_t : : op_term_t ( env_t * env , protob_t < const Term > term , <nl> op_term_t : : ~ op_term_t ( ) { } <nl> <nl> size_t op_term_t : : num_args ( ) const { return args . size ( ) ; } <nl> - counted_t < val_t > op_term_t : : arg ( size_t i ) { <nl> + counted_t < val_t > op_term_t : : arg ( size_t i , eval_flags_t flags ) { <nl> rcheck ( i < num_args ( ) , base_exc_t : : NON_EXISTENCE , <nl> strprintf ( " Index out of range : % zu " , i ) ) ; <nl> - return args [ i ] - > eval ( ) ; <nl> + return args [ i ] - > eval ( flags ) ; <nl> } <nl> <nl> counted_t < val_t > op_term_t : : optarg ( const std : : string & key ) { <nl> mmm a / src / rdb_protocol / op . hpp <nl> ppp b / src / rdb_protocol / op . hpp <nl> class op_term_t : public term_t { <nl> virtual ~ op_term_t ( ) ; <nl> protected : <nl> size_t num_args ( ) const ; / / number of arguments <nl> - counted_t < val_t > arg ( size_t i ) ; / / returns argument ` i ` <nl> + counted_t < val_t > arg ( size_t i , eval_flags_t flags = NO_FLAGS ) ; / / returns argument ` i ` <nl> / / Tries to get an optional argument , returns ` counted_t < val_t > ( ) ` if not <nl> / / found . <nl> counted_t < val_t > optarg ( const std : : string & key ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 63c2cd67b19 <nl> mmm / dev / null <nl> ppp b / src / rdb_protocol / pseudo_literal . cc <nl> <nl> + # include " rdb_protocol / pseudo_literal . hpp " <nl> + <nl> + namespace ql { <nl> + namespace pseudo { <nl> + <nl> + const char * const literal_string = " LITERAL " ; <nl> + const char * const value_key = " value " ; <nl> + <nl> + <nl> + void rcheck_literal_valid ( const datum_t * lit ) { <nl> + for ( auto it = lit - > as_object ( ) . begin ( ) ; it ! = lit - > as_object ( ) . end ( ) ; + + it ) { <nl> + if ( it - > first = = datum_t : : reql_type_string ) { <nl> + r_sanity_check ( it - > second - > as_str ( ) = = literal_string ) ; <nl> + } else if ( it - > first = = value_key ) { <nl> + } else { <nl> + rfail_target ( lit , base_exc_t : : GENERIC , <nl> + " Invalid literal term with illegal key ` % s ` . " , <nl> + it - > first . c_str ( ) ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + } / / namespace pseudo <nl> + } / / namespace ql <nl> new file mode 100644 <nl> index 00000000000 . . 759db6c81a2 <nl> mmm / dev / null <nl> ppp b / src / rdb_protocol / pseudo_literal . hpp <nl> <nl> + / / Copyright 2010 - 2013 RethinkDB , all rights reserved . <nl> + # ifndef RDB_PROTOCOL_PSEUDO_LITERAL_HPP_ <nl> + # define RDB_PROTOCOL_PSEUDO_LITERAL_HPP_ <nl> + <nl> + # include " rdb_protocol / datum . hpp " <nl> + <nl> + namespace ql { <nl> + namespace pseudo { <nl> + extern const char * const literal_string ; <nl> + extern const char * const value_key ; <nl> + <nl> + void rcheck_literal_valid ( const datum_t * lit ) ; <nl> + <nl> + } / / namespace pseudo <nl> + } / / namespace ql <nl> + <nl> + # endif <nl> mmm a / src / rdb_protocol / ql2 . proto <nl> ppp b / src / rdb_protocol / ql2 . proto <nl> message Term { <nl> OCTOBER = 123 ; / / - > 10 <nl> NOVEMBER = 124 ; / / - > 11 <nl> DECEMBER = 125 ; / / - > 12 <nl> + <nl> + / / Indicates to MERGE to replace the other object rather than merge it . <nl> + LITERAL = 137 ; / / JSON - > Merging <nl> } <nl> optional TermType type = 1 ; <nl> <nl> mmm a / src / rdb_protocol / term . cc <nl> ppp b / src / rdb_protocol / term . cc <nl> counted_t < term_t > compile_term ( env_t * env , protob_t < const Term > t ) { <nl> case Term : : PLUCK : return make_pluck_term ( env , t ) ; <nl> case Term : : WITHOUT : return make_without_term ( env , t ) ; <nl> case Term : : MERGE : return make_merge_term ( env , t ) ; <nl> + case Term : : LITERAL : return make_literal_term ( env , t ) ; <nl> case Term : : BETWEEN : return make_between_term ( env , t ) ; <nl> case Term : : REDUCE : return make_reduce_term ( env , t ) ; <nl> case Term : : MAP : return make_map_term ( env , t ) ; <nl> void term_t : : prop_bt ( Term * t ) const { <nl> propagate_backtrace ( t , & get_src ( ) - > GetExtension ( ql2 : : extension : : backtrace ) ) ; <nl> } <nl> <nl> - counted_t < val_t > term_t : : eval ( ) { <nl> + counted_t < val_t > term_t : : eval ( eval_flags_t eval_flags ) { <nl> / / This is basically a hook for unit tests to change things mid - query <nl> DEBUG_ONLY_CODE ( env - > do_eval_callback ( ) ) ; <nl> DBG ( " EVALUATING % s ( % d ) : \ n " , name ( ) , is_deterministic ( ) ) ; <nl> counted_t < val_t > term_t : : eval ( ) { <nl> <nl> try { <nl> try { <nl> - counted_t < val_t > ret = eval_impl ( ) ; <nl> + counted_t < val_t > ret = eval_impl ( eval_flags ) ; <nl> DEC_DEPTH ; <nl> DBG ( " % s returned % s \ n " , name ( ) , ret - > print ( ) . c_str ( ) ) ; <nl> return ret ; <nl> mmm a / src / rdb_protocol / term . hpp <nl> ppp b / src / rdb_protocol / term . hpp <nl> class func_t ; <nl> class table_t ; <nl> class val_t ; <nl> <nl> + enum eval_flags_t { <nl> + NO_FLAGS = 0 , <nl> + LITERAL_OK = 1 , <nl> + } ; <nl> + <nl> class term_t : public single_threaded_countable_t < term_t > , public pb_rcheckable_t { <nl> public : <nl> explicit term_t ( env_t * _env , protob_t < const Term > _src ) ; <nl> virtual ~ term_t ( ) ; <nl> <nl> virtual const char * name ( ) const = 0 ; <nl> - counted_t < val_t > eval ( ) ; <nl> + counted_t < val_t > eval ( eval_flags_t eval_flags = NO_FLAGS ) ; <nl> <nl> / / Allocates a new value in the current environment . <nl> counted_t < val_t > new_val ( counted_t < const datum_t > d ) ; <nl> class term_t : public single_threaded_countable_t < term_t > , public pb_rcheckable_ <nl> env_t * env ; <nl> <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) = 0 ; <nl> + virtual counted_t < val_t > eval_impl ( eval_flags_t ) = 0 ; <nl> virtual bool is_deterministic_impl ( ) const = 0 ; <nl> protob_t < const Term > src ; <nl> } ; <nl> mmm a / src / rdb_protocol / term_walker . cc <nl> ppp b / src / rdb_protocol / term_walker . cc <nl> class term_walker_t { <nl> case Term : : PLUCK : <nl> case Term : : WITHOUT : <nl> case Term : : MERGE : <nl> + case Term : : LITERAL : <nl> case Term : : BETWEEN : <nl> case Term : : REDUCE : <nl> case Term : : MAP : <nl> class term_walker_t { <nl> case Term : : PLUCK : <nl> case Term : : WITHOUT : <nl> case Term : : MERGE : <nl> + case Term : : LITERAL : <nl> case Term : : BETWEEN : <nl> case Term : : ORDERBY : <nl> case Term : : DISTINCT : <nl> mmm a / src / rdb_protocol / terms / arith . cc <nl> ppp b / src / rdb_protocol / terms / arith . cc <nl> class arith_term_t : public op_term_t { <nl> guarantee ( namestr & & op ) ; <nl> } <nl> <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < const datum_t > acc = arg ( 0 ) - > as_datum ( ) ; <nl> for ( size_t i = 1 ; i < num_args ( ) ; + + i ) { <nl> acc = ( this - > * op ) ( acc , arg ( i ) - > as_datum ( ) ) ; <nl> class mod_term_t : public op_term_t { <nl> public : <nl> mod_term_t ( env_t * env , protob_t < const Term > term ) : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> int64_t i0 = arg ( 0 ) - > as_int ( ) ; <nl> int64_t i1 = arg ( 1 ) - > as_int ( ) ; <nl> rcheck ( i1 , base_exc_t : : GENERIC , " Cannot take a number modulo 0 . " ) ; <nl> mmm a / src / rdb_protocol / terms / arr . cc <nl> ppp b / src / rdb_protocol / terms / arr . cc <nl> class append_term_t : public pend_term_t { <nl> public : <nl> append_term_t ( env_t * env , protob_t < const Term > term ) : pend_term_t ( env , term ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return pend ( AP ) ; <nl> } <nl> virtual const char * name ( ) const { return " append " ; } <nl> class prepend_term_t : public pend_term_t { <nl> public : <nl> prepend_term_t ( env_t * env , protob_t < const Term > term ) : pend_term_t ( env , term ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return pend ( PRE ) ; <nl> } <nl> virtual const char * name ( ) const { return " prepend " ; } <nl> class nth_term_t : public op_term_t { <nl> public : <nl> nth_term_t ( env_t * env , protob_t < const Term > term ) : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > v = arg ( 0 ) ; <nl> int32_t n = arg ( 1 ) - > as_int < int32_t > ( ) ; <nl> if ( v - > get_type ( ) . is_convertible ( val_t : : type_t : : DATUM ) ) { <nl> class is_empty_term_t : public op_term_t { <nl> is_empty_term_t ( env_t * env , protob_t < const Term > term ) : <nl> op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> bool is_empty = ! arg ( 0 ) - > as_seq ( ) - > next ( ) . has ( ) ; <nl> return new_val ( make_counted < const datum_t > ( datum_t : : type_t : : R_BOOL , is_empty ) ) ; <nl> } <nl> class slice_term_t : public bounded_op_term_t { <nl> slice_term_t ( env_t * env , protob_t < const Term > term ) <nl> : bounded_op_term_t ( env , term , argspec_t ( 3 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > v = arg ( 0 ) ; <nl> int64_t fake_l = arg ( 1 ) - > as_int < int64_t > ( ) ; <nl> int64_t fake_r = arg ( 2 ) - > as_int < int64_t > ( ) ; <nl> class limit_term_t : public op_term_t { <nl> limit_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > v = arg ( 0 ) ; <nl> counted_t < table_t > t ; <nl> if ( v - > get_type ( ) . is_convertible ( val_t : : type_t : : SELECTION ) ) { <nl> class set_insert_term_t : public op_term_t { <nl> set_insert_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < const datum_t > arr = arg ( 0 ) - > as_datum ( ) ; <nl> counted_t < const datum_t > new_el = arg ( 1 ) - > as_datum ( ) ; <nl> std : : set < counted_t < const datum_t > > el_set ; <nl> class set_union_term_t : public op_term_t { <nl> set_union_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < const datum_t > arr1 = arg ( 0 ) - > as_datum ( ) ; <nl> counted_t < const datum_t > arr2 = arg ( 1 ) - > as_datum ( ) ; <nl> std : : set < counted_t < const datum_t > > el_set ; <nl> class set_intersection_term_t : public op_term_t { <nl> set_intersection_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < const datum_t > arr1 = arg ( 0 ) - > as_datum ( ) ; <nl> counted_t < const datum_t > arr2 = arg ( 1 ) - > as_datum ( ) ; <nl> std : : set < counted_t < const datum_t > > el_set ; <nl> class set_difference_term_t : public op_term_t { <nl> set_difference_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < const datum_t > arr1 = arg ( 0 ) - > as_datum ( ) ; <nl> counted_t < const datum_t > arr2 = arg ( 1 ) - > as_datum ( ) ; <nl> std : : set < counted_t < const datum_t > > el_set ; <nl> class at_term_t : public op_term_t { <nl> argspec_t argspec , index_method_t index_method ) <nl> : op_term_t ( env , term , argspec ) , index_method_ ( index_method ) { } <nl> virtual void modify ( size_t index , datum_ptr_t * array ) = 0 ; <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> datum_ptr_t arr ( arg ( 0 ) - > as_datum ( ) - > as_array ( ) ) ; <nl> size_t index ; <nl> if ( index_method_ = = ELEMENTS ) { <nl> class indexes_of_term_t : public op_term_t { <nl> public : <nl> indexes_of_term_t ( env_t * env , protob_t < const Term > term ) : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > v = arg ( 1 ) ; <nl> counted_t < func_t > fun ; <nl> if ( v - > get_type ( ) . is_convertible ( val_t : : type_t : : FUNC ) ) { <nl> class contains_term_t : public op_term_t { <nl> contains_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 , - 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < datum_stream_t > seq = arg ( 0 ) - > as_seq ( ) ; <nl> std : : vector < counted_t < const datum_t > > required_els ; <nl> std : : vector < counted_t < func_t > > required_funcs ; <nl> mmm a / src / rdb_protocol / terms / control . cc <nl> ppp b / src / rdb_protocol / terms / control . cc <nl> class all_term_t : public op_term_t { <nl> all_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 , - 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> for ( size_t i = 0 ; i < num_args ( ) ; + + i ) { <nl> counted_t < val_t > v = arg ( i ) ; <nl> if ( ! v - > as_bool ( ) | | i = = num_args ( ) - 1 ) { <nl> class any_term_t : public op_term_t { <nl> any_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 , - 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> for ( size_t i = 0 ; i < num_args ( ) ; + + i ) { <nl> counted_t < val_t > v = arg ( i ) ; <nl> if ( v - > as_bool ( ) ) { <nl> class branch_term_t : public op_term_t { <nl> public : <nl> branch_term_t ( env_t * env , protob_t < const Term > term ) : op_term_t ( env , term , argspec_t ( 3 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> bool b = arg ( 0 ) - > as_bool ( ) ; <nl> return b ? arg ( 1 ) : arg ( 2 ) ; <nl> } <nl> class branch_term_t : public op_term_t { <nl> class funcall_term_t : public op_term_t { <nl> public : <nl> funcall_term_t ( env_t * env , protob_t < const Term > term ) <nl> - : op_term_t ( env , term , argspec_t ( 1 , - 1 ) , optargspec_t ( { " _SHORTCUT_ " } ) ) { } <nl> + : op_term_t ( env , term , argspec_t ( 1 , - 1 ) , <nl> + optargspec_t ( { " _SHORTCUT_ " , " _EVAL_FLAGS_ " } ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( eval_flags_t ) { <nl> function_shortcut_t shortcut = CONSTANT_SHORTCUT ; <nl> + eval_flags_t flags = NO_FLAGS ; <nl> if ( counted_t < val_t > v = optarg ( " _SHORTCUT_ " ) ) { <nl> shortcut = static_cast < function_shortcut_t > ( v - > as_num ( ) ) ; <nl> } <nl> <nl> + if ( counted_t < val_t > v = optarg ( " _EVAL_FLAGS_ " ) ) { <nl> + flags = static_cast < eval_flags_t > ( v - > as_num ( ) ) ; <nl> + } <nl> + <nl> / * This switch exists just to make sure that we don ' t get a bogus value <nl> * for the shortcut . * / <nl> switch ( shortcut ) { <nl> class funcall_term_t : public op_term_t { <nl> rfail ( base_exc_t : : GENERIC , <nl> " Unrecognized value ` % d ` for _SHORTCUT_ argument . " , shortcut ) ; <nl> } <nl> - counted_t < func_t > f = arg ( 0 ) - > as_func ( shortcut ) ; <nl> + counted_t < func_t > f = arg ( 0 , flags ) - > as_func ( shortcut ) ; <nl> std : : vector < counted_t < const datum_t > > args ; <nl> for ( size_t i = 1 ; i < num_args ( ) ; + + i ) args . push_back ( arg ( i ) - > as_datum ( ) ) ; <nl> return f - > call ( args ) ; <nl> mmm a / src / rdb_protocol / terms / datum_terms . cc <nl> ppp b / src / rdb_protocol / terms / datum_terms . cc <nl> class datum_term_t : public term_t { <nl> } <nl> private : <nl> virtual bool is_deterministic_impl ( ) const { return true ; } <nl> - virtual counted_t < val_t > eval_impl ( ) { return raw_val ; } <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { return raw_val ; } <nl> virtual const char * name ( ) const { return " datum " ; } <nl> counted_t < val_t > raw_val ; <nl> } ; <nl> class constant_term_t : public op_term_t { <nl> double constant , const char * name ) <nl> : op_term_t ( env , t , argspec_t ( 0 ) ) , _constant ( constant ) , _name ( name ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( make_counted < const datum_t > ( _constant ) ) ; <nl> } <nl> virtual const char * name ( ) const { return _name ; } <nl> class make_array_term_t : public op_term_t { <nl> make_array_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 0 , - 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> datum_ptr_t acc ( datum_t : : R_ARRAY ) ; <nl> for ( size_t i = 0 ; i < num_args ( ) ; + + i ) { <nl> acc . add ( arg ( i ) - > as_datum ( ) ) ; <nl> class make_obj_term_t : public op_term_t { <nl> make_obj_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 0 ) , optargspec_t : : make_object ( ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( eval_flags_t flags ) { <nl> + bool literal_ok = flags & LITERAL_OK ; <nl> + eval_flags_t new_flags = literal_ok ? LITERAL_OK : NO_FLAGS ; <nl> datum_ptr_t acc ( datum_t : : R_OBJECT ) ; <nl> for ( auto it = optargs . begin ( ) ; it ! = optargs . end ( ) ; + + it ) { <nl> - bool dup = acc . add ( it - > first , it - > second - > eval ( ) - > as_datum ( ) ) ; <nl> + bool dup = acc . add ( it - > first , it - > second - > eval ( new_flags ) - > as_datum ( ) ) ; <nl> rcheck ( ! dup , base_exc_t : : GENERIC , <nl> strprintf ( " Duplicate key in object : % s . " , it - > first . c_str ( ) ) ) ; <nl> } <nl> mmm a / src / rdb_protocol / terms / db_table . cc <nl> ppp b / src / rdb_protocol / terms / db_table . cc <nl> class meta_write_op_t : public meta_op_t { <nl> directory_metadata = env - > directory_read_manager - > get_root_view ( ) ; <nl> } <nl> <nl> - virtual std : : string write_eval_impl ( ) = 0 ; <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> - std : : string op = write_eval_impl ( ) ; <nl> + virtual std : : string write_eval_impl ( eval_flags_t flags ) = 0 ; <nl> + virtual counted_t < val_t > eval_impl ( eval_flags_t flags ) { <nl> + std : : string op = write_eval_impl ( flags ) ; <nl> datum_ptr_t res ( datum_t : : R_OBJECT ) ; <nl> UNUSED bool b = res . add ( op , make_counted < datum_t > ( 1 . 0 ) ) ; <nl> return new_val ( res . to_counted ( ) ) ; <nl> class db_term_t : public meta_op_t { <nl> public : <nl> db_term_t ( env_t * env , protob_t < const Term > term ) : meta_op_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> name_string_t db_name = get_name ( arg ( 0 ) , this ) ; <nl> uuid_u uuid ; <nl> { <nl> class db_create_term_t : public meta_write_op_t { <nl> db_create_term_t ( env_t * env , protob_t < const Term > term ) : <nl> meta_write_op_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual std : : string write_eval_impl ( ) { <nl> + virtual std : : string write_eval_impl ( UNUSED eval_flags_t flags ) { <nl> name_string_t db_name = get_name ( arg ( 0 ) , this ) ; <nl> <nl> rethreading_metadata_accessor_t meta ( this ) ; <nl> class table_create_term_t : public meta_write_op_t { <nl> optargspec_t ( { " datacenter " , " primary_key " , <nl> " cache_size " , " durability " } ) ) { } <nl> private : <nl> - virtual std : : string write_eval_impl ( ) { <nl> + virtual std : : string write_eval_impl ( UNUSED eval_flags_t flags ) { <nl> uuid_u dc_id = nil_uuid ( ) ; <nl> if ( counted_t < val_t > v = optarg ( " datacenter " ) ) { <nl> name_string_t name = get_name ( v , this ) ; <nl> class db_drop_term_t : public meta_write_op_t { <nl> db_drop_term_t ( env_t * env , protob_t < const Term > term ) : <nl> meta_write_op_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual std : : string write_eval_impl ( ) { <nl> + virtual std : : string write_eval_impl ( UNUSED eval_flags_t flags ) { <nl> name_string_t db_name = get_name ( arg ( 0 ) , this ) ; <nl> <nl> rethreading_metadata_accessor_t meta ( this ) ; <nl> class table_drop_term_t : public meta_write_op_t { <nl> table_drop_term_t ( env_t * env , protob_t < const Term > term ) : <nl> meta_write_op_t ( env , term , argspec_t ( 1 , 2 ) ) { } <nl> private : <nl> - virtual std : : string write_eval_impl ( ) { <nl> + virtual std : : string write_eval_impl ( UNUSED eval_flags_t flags ) { <nl> uuid_u db_id ; <nl> name_string_t tbl_name ; <nl> if ( num_args ( ) = = 1 ) { <nl> class db_list_term_t : public meta_op_t { <nl> db_list_term_t ( env_t * env , protob_t < const Term > term ) : <nl> meta_op_t ( env , term , argspec_t ( 0 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> datum_ptr_t arr ( datum_t : : R_ARRAY ) ; <nl> std : : vector < std : : string > dbs ; <nl> { <nl> class table_list_term_t : public meta_op_t { <nl> table_list_term_t ( env_t * env , protob_t < const Term > term ) : <nl> meta_op_t ( env , term , argspec_t ( 0 , 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> datum_ptr_t arr ( datum_t : : R_ARRAY ) ; <nl> uuid_u db_id ; <nl> if ( num_args ( ) = = 0 ) { <nl> class table_term_t : public op_term_t { <nl> table_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 , 2 ) , optargspec_t ( { " use_outdated " } ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > t = optarg ( " use_outdated " ) ; <nl> bool use_outdated = t ? t - > as_bool ( ) : false ; <nl> counted_t < const db_t > db ; <nl> class get_term_t : public op_term_t { <nl> public : <nl> get_term_t ( env_t * env , protob_t < const Term > term ) : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < table_t > table = arg ( 0 ) - > as_table ( ) ; <nl> counted_t < const datum_t > pkey = arg ( 1 ) - > as_datum ( ) ; <nl> counted_t < const datum_t > row = table - > get_row ( pkey ) ; <nl> class get_all_term_t : public op_term_t { <nl> get_all_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 , - 1 ) , optargspec_t ( { " index " } ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < table_t > table = arg ( 0 ) - > as_table ( ) ; <nl> counted_t < val_t > index = optarg ( " index " ) ; <nl> if ( index & & index - > as_str ( ) ! = table - > get_pkey ( ) ) { <nl> mmm a / src / rdb_protocol / terms / error . cc <nl> ppp b / src / rdb_protocol / terms / error . cc <nl> class error_term_t : public op_term_t { <nl> error_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 0 , 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> if ( num_args ( ) = = 0 ) { <nl> rfail ( base_exc_t : : EMPTY_USER , " Empty ERROR term outside a default block . " ) ; <nl> } else { <nl> class default_term_t : public op_term_t { <nl> default_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < const datum_t > func_arg ; <nl> scoped_ptr_t < exc_t > err ; <nl> counted_t < val_t > v ; <nl> mmm a / src / rdb_protocol / terms / gmr . cc <nl> ppp b / src / rdb_protocol / terms / gmr . cc <nl> class gmr_term_t : public op_term_t { <nl> gmr_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 4 ) , optargspec_t ( { " base " } ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > baseval = optarg ( " base " ) ; <nl> counted_t < const datum_t > base = baseval . has ( ) ? <nl> baseval - > as_datum ( ) : <nl> mmm a / src / rdb_protocol / terms / js . cc <nl> ppp b / src / rdb_protocol / terms / js . cc <nl> class javascript_term_t : public op_term_t { <nl> : op_term_t ( env , term , argspec_t ( 1 ) , optargspec_t ( { " timeout " } ) ) { } <nl> private : <nl> <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> / / Optarg seems designed to take a default value as the second argument <nl> / / but nowhere else is this actually used . <nl> uint64_t timeout_ms = 5000 ; <nl> mmm a / src / rdb_protocol / terms / json . cc <nl> ppp b / src / rdb_protocol / terms / json . cc <nl> class json_term_t : public op_term_t { <nl> json_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> std : : string data = arg ( 0 ) - > as_str ( ) ; <nl> scoped_cJSON_t cjson ( cJSON_Parse ( data . c_str ( ) ) ) ; <nl> rcheck ( cjson . get ( ) ! = NULL , base_exc_t : : GENERIC , <nl> mmm a / src / rdb_protocol / terms / match . cc <nl> ppp b / src / rdb_protocol / terms / match . cc <nl> class match_term_t : public op_term_t { <nl> match_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> std : : string str = arg ( 0 ) - > as_str ( ) ; <nl> RE2 regexp ( arg ( 1 ) - > as_str ( ) ) ; <nl> if ( ! regexp . ok ( ) ) { <nl> mmm a / src / rdb_protocol / terms / obj . cc <nl> ppp b / src / rdb_protocol / terms / obj . cc <nl> class keys_term_t : public op_term_t { <nl> keys_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < const datum_t > d = arg ( 0 ) - > as_datum ( ) ; <nl> const std : : map < std : : string , counted_t < const datum_t > > & obj = d - > as_object ( ) ; <nl> datum_ptr_t arr ( datum_t : : R_ARRAY ) ; <nl> mmm a / src / rdb_protocol / terms / obj_or_seq . cc <nl> ppp b / src / rdb_protocol / terms / obj_or_seq . cc <nl> <nl> # include " rdb_protocol / op . hpp " <nl> # include " rdb_protocol / pathspec . hpp " <nl> # include " rdb_protocol / pb_utils . hpp " <nl> + # include " rdb_protocol / pseudo_literal . hpp " <nl> <nl> # pragma GCC diagnostic ignored " - Wshadow " <nl> <nl> class obj_or_seq_op_term_t : public op_term_t { <nl> } <nl> private : <nl> virtual counted_t < val_t > obj_eval ( counted_t < val_t > v0 ) = 0 ; <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > v0 = arg ( 0 ) ; <nl> counted_t < const datum_t > d ; <nl> <nl> class without_term_t : public obj_or_seq_op_term_t { <nl> virtual const char * name ( ) const { return " without " ; } <nl> } ; <nl> <nl> + class literal_term_t : public op_term_t { <nl> + public : <nl> + literal_term_t ( env_t * env , protob_t < const Term > term ) <nl> + : op_term_t ( env , term , argspec_t ( 0 , 1 ) ) { } <nl> + private : <nl> + virtual counted_t < val_t > eval_impl ( eval_flags_t flags ) { <nl> + rcheck ( flags & LITERAL_OK , base_exc_t : : GENERIC , <nl> + " Stray literal keyword found , literal can only be present inside merge " <nl> + " and cannot nest inside other literals . " ) ; <nl> + datum_ptr_t res ( datum_t : : R_OBJECT ) ; <nl> + bool clobber = res . add ( datum_t : : reql_type_string , <nl> + make_counted < const datum_t > ( pseudo : : literal_string ) ) ; <nl> + if ( num_args ( ) = = 1 ) { <nl> + clobber | = res . add ( pseudo : : value_key , arg ( 0 ) - > as_datum ( ) ) ; <nl> + } <nl> + <nl> + r_sanity_check ( ! clobber ) ; <nl> + std : : set < std : : string > permissible_ptypes ; <nl> + permissible_ptypes . insert ( pseudo : : literal_string ) ; <nl> + return new_val ( res . to_counted ( permissible_ptypes ) ) ; <nl> + } <nl> + virtual const char * name ( ) const { return " literal " ; } <nl> + } ; <nl> + <nl> class merge_term_t : public obj_or_seq_op_term_t { <nl> public : <nl> merge_term_t ( env_t * env , protob_t < const Term > term ) : <nl> class merge_term_t : public obj_or_seq_op_term_t { <nl> virtual counted_t < val_t > obj_eval ( counted_t < val_t > v0 ) { <nl> counted_t < const datum_t > d = v0 - > as_datum ( ) ; <nl> for ( size_t i = 1 ; i < num_args ( ) ; + + i ) { <nl> - d = d - > merge ( arg ( i ) - > as_datum ( ) ) ; <nl> + d = d - > merge ( arg ( i , LITERAL_OK ) - > as_datum ( ) ) ; <nl> } <nl> return new_val ( d ) ; <nl> } <nl> counted_t < term_t > make_pluck_term ( env_t * env , protob_t < const Term > term ) { <nl> counted_t < term_t > make_without_term ( env_t * env , protob_t < const Term > term ) { <nl> return make_counted < without_term_t > ( env , term ) ; <nl> } <nl> + counted_t < term_t > make_literal_term ( env_t * env , protob_t < const Term > term ) { <nl> + return make_counted < literal_term_t > ( env , term ) ; <nl> + } <nl> counted_t < term_t > make_merge_term ( env_t * env , protob_t < const Term > term ) { <nl> return make_counted < merge_term_t > ( env , term ) ; <nl> } <nl> mmm a / src / rdb_protocol / terms / pred . cc <nl> ppp b / src / rdb_protocol / terms / pred . cc <nl> class predicate_term_t : public op_term_t { <nl> guarantee ( namestr & & pred ) ; <nl> } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < const datum_t > lhs = arg ( 0 ) - > as_datum ( ) ; <nl> for ( size_t i = 1 ; i < num_args ( ) ; + + i ) { <nl> counted_t < const datum_t > rhs = arg ( i ) - > as_datum ( ) ; <nl> class not_term_t : public op_term_t { <nl> public : <nl> not_term_t ( env_t * env , protob_t < const Term > term ) : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val_bool ( ! arg ( 0 ) - > as_bool ( ) ) ; <nl> } <nl> virtual const char * name ( ) const { return " not " ; } <nl> mmm a / src / rdb_protocol / terms / random . cc <nl> ppp b / src / rdb_protocol / terms / random . cc <nl> class sample_term_t : public op_term_t { <nl> public : <nl> sample_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> int64_t num_int = arg ( 1 ) - > as_int ( ) ; <nl> rcheck ( num_int > = 0 , <nl> base_exc_t : : GENERIC , <nl> mmm a / src / rdb_protocol / terms / rewrites . cc <nl> ppp b / src / rdb_protocol / terms / rewrites . cc <nl> class rewrite_term_t : public term_t { <nl> <nl> private : <nl> virtual bool is_deterministic_impl ( ) const { return real - > is_deterministic ( ) ; } <nl> - virtual counted_t < val_t > eval_impl ( ) { return real - > eval ( ) ; } <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { return real - > eval ( ) ; } <nl> protob_t < const Term > in ; <nl> protob_t < Term > out ; <nl> <nl> class update_term_t : public rewrite_term_t { <nl> N2 ( EQ , NVAR ( new_row ) , NDATUM ( datum_t : : R_NULL ) ) , <nl> NVAR ( old_row ) , <nl> N2 ( MERGE , NVAR ( old_row ) , NVAR ( new_row ) ) ) , <nl> - N2 ( FUNCALL , * arg = in - > args ( 1 ) , NVAR ( old_row ) ) ) ) ) ; <nl> + N2 ( FUNCALL , * arg = in - > args ( 1 ) , NVAR ( old_row ) ) ; <nl> + OPT1 ( FUNCALL , " _EVAL_FLAGS_ " , <nl> + NDATUM ( static_cast < double > ( LITERAL_OK ) ) ) ) <nl> + OPT1 ( FUNCALL , " _EVAL_FLAGS_ " , <nl> + NDATUM ( static_cast < double > ( LITERAL_OK ) ) ) ) ) ; <nl> return out ; <nl> } <nl> virtual const char * name ( ) const { return " update " ; } <nl> mmm a / src / rdb_protocol / terms / seq . cc <nl> ppp b / src / rdb_protocol / terms / seq . cc <nl> class count_term_t : public op_term_t { <nl> count_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 , 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> if ( num_args ( ) = = 1 ) { <nl> return new_val ( arg ( 0 ) - > as_seq ( ) - > count ( ) ) ; <nl> } else if ( arg ( 1 ) - > get_type ( ) . is_convertible ( val_t : : type_t : : FUNC ) ) { <nl> class map_term_t : public op_term_t { <nl> map_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( arg ( 0 ) - > as_seq ( ) - > map ( arg ( 1 ) - > as_func ( ) ) ) ; <nl> } <nl> virtual const char * name ( ) const { return " map " ; } <nl> class concatmap_term_t : public op_term_t { <nl> concatmap_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( arg ( 0 ) - > as_seq ( ) - > concatmap ( arg ( 1 ) - > as_func ( ) ) ) ; <nl> } <nl> virtual const char * name ( ) const { return " concatmap " ; } <nl> class filter_term_t : public op_term_t { <nl> : op_term_t ( env , term , argspec_t ( 2 ) , optargspec_t ( { " default " } ) ) , <nl> default_filter_val ( lazy_literal_optarg ( " default " ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > v0 = arg ( 0 ) ; <nl> counted_t < val_t > v1 = arg ( 1 ) ; <nl> counted_t < func_t > f = v1 - > as_func ( CONSTANT_SHORTCUT ) ; <nl> class reduce_term_t : public op_term_t { <nl> reduce_term_t ( env_t * env , protob_t < const Term > term ) : <nl> op_term_t ( env , term , argspec_t ( 2 ) , optargspec_t ( { " base " } ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( arg ( 0 ) - > as_seq ( ) - > reduce ( optarg ( " base " ) , <nl> arg ( 1 ) - > as_func ( ) ) ) ; <nl> } <nl> class between_term_t : public bounded_op_term_t { <nl> between_term_t ( env_t * env , protob_t < const Term > term ) <nl> : bounded_op_term_t ( env , term , argspec_t ( 3 ) , optargspec_t ( { " index " } ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < table_t > tbl = arg ( 0 ) - > as_table ( ) ; <nl> counted_t < const datum_t > lb = arg ( 1 ) - > as_datum ( ) ; <nl> if ( lb - > get_type ( ) = = datum_t : : R_NULL ) { <nl> class union_term_t : public op_term_t { <nl> union_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 0 , - 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> std : : vector < counted_t < datum_stream_t > > streams ; <nl> for ( size_t i = 0 ; i < num_args ( ) ; + + i ) { <nl> streams . push_back ( arg ( i ) - > as_seq ( ) ) ; <nl> class zip_term_t : public op_term_t { <nl> zip_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( arg ( 0 ) - > as_seq ( ) - > zip ( ) ) ; <nl> } <nl> virtual const char * name ( ) const { return " zip " ; } <nl> mmm a / src / rdb_protocol / terms / sindex . cc <nl> ppp b / src / rdb_protocol / terms / sindex . cc <nl> class sindex_create_term_t : private env_t : : special_var_shadower_t , public op_te <nl> : env_t : : special_var_shadower_t ( env , env_t : : SINDEX_ERROR_VAR ) , <nl> op_term_t ( env , term , argspec_t ( 2 , 3 ) ) { } <nl> <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < table_t > table = arg ( 0 ) - > as_table ( ) ; <nl> counted_t < const datum_t > name_datum = arg ( 1 ) - > as_datum ( ) ; <nl> std : : string name = name_datum - > as_str ( ) ; <nl> class sindex_drop_term_t : public op_term_t { <nl> sindex_drop_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < table_t > table = arg ( 0 ) - > as_table ( ) ; <nl> std : : string name = arg ( 1 ) - > as_datum ( ) - > as_str ( ) ; <nl> bool success = table - > sindex_drop ( name ) ; <nl> class sindex_list_term_t : public op_term_t { <nl> sindex_list_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < table_t > table = arg ( 0 ) - > as_table ( ) ; <nl> <nl> return new_val ( table - > sindex_list ( ) ) ; <nl> mmm a / src / rdb_protocol / terms / sort . cc <nl> ppp b / src / rdb_protocol / terms / sort . cc <nl> class asc_term_t : public op_term_t { <nl> asc_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return arg ( 0 ) ; <nl> } <nl> virtual const char * name ( ) const { return " asc " ; } <nl> class desc_term_t : public op_term_t { <nl> desc_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return arg ( 0 ) ; <nl> } <nl> virtual const char * name ( ) const { return " desc " ; } <nl> class orderby_term_t : public op_term_t { <nl> std : : vector < std : : pair < order_direction_t , counted_t < func_t > > > comparisons ; <nl> } ; <nl> <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> std : : vector < std : : pair < order_direction_t , counted_t < func_t > > > comparisons ; <nl> scoped_ptr_t < datum_t > arr ( new datum_t ( datum_t : : R_ARRAY ) ) ; <nl> for ( size_t i = 1 ; i < num_args ( ) ; + + i ) { <nl> class distinct_term_t : public op_term_t { <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> static bool lt_cmp ( counted_t < const datum_t > l , counted_t < const datum_t > r ) { return * l < * r ; } <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> scoped_ptr_t < datum_stream_t > s ( <nl> new sort_datum_stream_t < bool ( * ) ( <nl> counted_t < const datum_t > , <nl> mmm a / src / rdb_protocol / terms / terms . hpp <nl> ppp b / src / rdb_protocol / terms / terms . hpp <nl> counted_t < term_t > make_get_field_term ( env_t * env , protob_t < const Term > term ) ; <nl> / / obj_or_seq . cc <nl> counted_t < term_t > make_pluck_term ( env_t * env , protob_t < const Term > term ) ; <nl> counted_t < term_t > make_without_term ( env_t * env , protob_t < const Term > term ) ; <nl> + counted_t < term_t > make_literal_term ( env_t * env , protob_t < const Term > term ) ; <nl> counted_t < term_t > make_merge_term ( env_t * env , protob_t < const Term > term ) ; <nl> counted_t < term_t > make_has_fields_term ( env_t * env , protob_t < const Term > term ) ; <nl> <nl> mmm a / src / rdb_protocol / terms / time . cc <nl> ppp b / src / rdb_protocol / terms / time . cc <nl> class iso8601_term_t : public op_term_t { <nl> iso8601_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > v = arg ( 0 ) ; <nl> return new_val ( pseudo : : iso8601_to_time ( v - > as_str ( ) , v . get ( ) ) ) ; <nl> } <nl> class to_iso8601_term_t : public op_term_t { <nl> to_iso8601_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( <nl> make_counted < const datum_t > ( <nl> pseudo : : time_to_iso8601 ( arg ( 0 ) - > as_ptype ( pseudo : : time_string ) ) ) ) ; <nl> class epoch_time_term_t : public op_term_t { <nl> epoch_time_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > v = arg ( 0 ) ; <nl> return new_val ( pseudo : : make_time ( v - > as_num ( ) ) ) ; <nl> } <nl> class to_epoch_time_term_t : public op_term_t { <nl> to_epoch_time_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( <nl> make_counted < const datum_t > ( <nl> pseudo : : time_to_epoch_time ( arg ( 0 ) - > as_ptype ( pseudo : : time_string ) ) ) ) ; <nl> class now_term_t : public op_term_t { <nl> now_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 0 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> / / This should never get called because we rewrite ` now ` calls to a <nl> / / constant so that they ' re deterministic . <nl> r_sanity_check ( false ) ; <nl> class in_timezone_term_t : public op_term_t { <nl> in_timezone_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( pseudo : : time_in_tz ( arg ( 0 ) - > as_ptype ( pseudo : : time_string ) , <nl> arg ( 1 ) - > as_datum ( ) ) ) ; <nl> } <nl> class during_term_t : public bounded_op_term_t { <nl> during_term_t ( env_t * env , protob_t < const Term > term ) <nl> : bounded_op_term_t ( env , term , argspec_t ( 3 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < const datum_t > t = arg ( 0 ) - > as_ptype ( pseudo : : time_string ) ; <nl> counted_t < const datum_t > lb = arg ( 1 ) - > as_ptype ( pseudo : : time_string ) ; <nl> counted_t < const datum_t > rb = arg ( 2 ) - > as_ptype ( pseudo : : time_string ) ; <nl> class date_term_t : public op_term_t { <nl> date_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( pseudo : : time_date ( arg ( 0 ) - > as_ptype ( pseudo : : time_string ) , this ) ) ; <nl> } <nl> virtual const char * name ( ) const { return " date " ; } <nl> class time_of_day_term_t : public op_term_t { <nl> time_of_day_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( pseudo : : time_of_day ( arg ( 0 ) - > as_ptype ( pseudo : : time_string ) ) ) ; <nl> } <nl> virtual const char * name ( ) const { return " time_of_day " ; } <nl> class timezone_term_t : public op_term_t { <nl> timezone_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( pseudo : : time_tz ( arg ( 0 ) - > as_ptype ( pseudo : : time_string ) ) ) ; <nl> } <nl> virtual const char * name ( ) const { return " timezone " ; } <nl> class portion_term_t : public op_term_t { <nl> pseudo : : time_component_t _component ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) , component ( _component ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> double d = pseudo : : time_portion ( arg ( 0 ) - > as_ptype ( pseudo : : time_string ) , component ) ; <nl> return new_val ( make_counted < const datum_t > ( d ) ) ; <nl> } <nl> class time_term_t : public op_term_t { <nl> time_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 3 , 7 ) ) { } <nl> private : <nl> - counted_t < val_t > eval_impl ( ) { <nl> + counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> if ( num_args ( ) ! = 3 & & num_args ( ) ! = 4 & & num_args ( ) ! = 6 & & num_args ( ) ! = 7 ) { <nl> rfail ( base_exc_t : : GENERIC , <nl> " Got % zu arguments to TIME ( expected 3 , 4 , 6 or 7 ) . " , num_args ( ) ) ; <nl> mmm a / src / rdb_protocol / terms / type_manip . cc <nl> ppp b / src / rdb_protocol / terms / type_manip . cc <nl> class coerce_term_t : public op_term_t { <nl> coerce_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > val = arg ( 0 ) ; <nl> val_t : : type_t opaque_start_type = val - > get_type ( ) ; <nl> int start_supertype = opaque_start_type . raw_type ; <nl> class typeof_term_t : public op_term_t { <nl> typeof_term_t ( env_t * env , protob_t < const Term > term ) <nl> : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < val_t > v = arg ( 0 ) ; <nl> if ( v - > get_type ( ) . raw_type = = val_t : : type_t : : DATUM ) { <nl> counted_t < const datum_t > d = v - > as_datum ( ) ; <nl> class info_term_t : public op_term_t { <nl> public : <nl> info_term_t ( env_t * env , protob_t < const Term > term ) : op_term_t ( env , term , argspec_t ( 1 ) ) { } <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( val_info ( arg ( 0 ) ) ) ; <nl> } <nl> <nl> mmm a / src / rdb_protocol / terms / var . cc <nl> ppp b / src / rdb_protocol / terms / var . cc <nl> class var_term_t : public op_term_t { <nl> } <nl> private : <nl> counted_t < const datum_t > * datum_val ; / / pointer to variable ' s slot in argument array <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( * datum_val ) ; <nl> } <nl> virtual const char * name ( ) const { return " var " ; } <nl> class implicit_var_term_t : public op_term_t { <nl> } <nl> private : <nl> counted_t < const datum_t > * datum_val ; <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> return new_val ( * datum_val ) ; <nl> } <nl> virtual const char * name ( ) const { return " implicit_var " ; } <nl> mmm a / src / rdb_protocol / terms / writes . cc <nl> ppp b / src / rdb_protocol / terms / writes . cc <nl> class insert_term_t : public op_term_t { <nl> } <nl> } <nl> <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> counted_t < table_t > t = arg ( 0 ) - > as_table ( ) ; <nl> counted_t < val_t > upsert_val = optarg ( " upsert " ) ; <nl> bool upsert = upsert_val . has ( ) ? upsert_val - > as_bool ( ) : false ; <nl> class replace_term_t : public op_term_t { <nl> optargspec_t ( { " non_atomic " , " durability " , " return_vals " } ) ) { } <nl> <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> bool nondet_ok = false ; <nl> if ( counted_t < val_t > v = optarg ( " non_atomic " ) ) { <nl> nondet_ok = v - > as_bool ( ) ; <nl> class foreach_term_t : public op_term_t { <nl> : op_term_t ( env , term , argspec_t ( 2 ) ) { } <nl> <nl> private : <nl> - virtual counted_t < val_t > eval_impl ( ) { <nl> + virtual counted_t < val_t > eval_impl ( UNUSED eval_flags_t flags ) { <nl> const char * fail_msg = " FOREACH expects one or more basic write queries . " ; <nl> <nl> counted_t < datum_stream_t > ds = arg ( 0 ) - > as_seq ( ) ; <nl> mmm a / test / rql_test / Makefile <nl> ppp b / test / rql_test / Makefile <nl> JS_DRIVER : = node_modules / rethinkdb / . <nl> . SILENT : <nl> <nl> $ ( JS_DRIVER ) : . . / . . / build / packages / js / . <nl> - test - d node_modules / rethinkdb / | | mkdir mode_modules <nl> + test - d node_modules / rethinkdb / | | mkdir - p node_modules <nl> npm install . . / . . / build / packages / js <nl> <nl> . PHONY : run <nl> mmm a / test / rql_test / src / mutation / update . yaml <nl> ppp b / test / rql_test / src / mutation / update . yaml <nl> tests : <nl> - cd : tbl . count ( ) <nl> ot : 100 <nl> <nl> + - py : tbl2 . insert ( [ { ' id ' : i , ' foo ' : { ' bar ' : i } } for i in xrange ( 100 ) ] ) <nl> + js : | <nl> + tbl2 . insert ( function ( ) { <nl> + var res = [ ] <nl> + for ( var i = 0 ; i < 100 ; i + + ) { <nl> + res . push ( { id : i , foo : { bar : i } } ) ; <nl> + } <nl> + return res ; <nl> + } ( ) ) <nl> + rb : tbl2 . insert ( ( 0 . . . 100 ) . map { | i | { : id = > i , : foo = > { : bar = > i } } } ) <nl> + ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 0 . 0 , ' unchanged ' : 0 . 0 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 100 } ) <nl> + <nl> + - cd : tbl2 . count ( ) <nl> + ot : 100 <nl> + <nl> # Identity <nl> - py : tbl . get ( 12 ) . update ( lambda row : row ) <nl> js : tbl . get ( 12 ) . update ( function ( row ) { return row ; } ) <nl> tests : <nl> - cd : tbl . get ( 12 ) <nl> ot : ( { ' id ' : 12 , ' a ' : 12 } ) <nl> <nl> + # undo the point update <nl> + - cd : tbl . get ( 12 ) . update ( { ' a ' : r . literal ( ) } ) <nl> + ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 1 , ' unchanged ' : 0 . 0 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> + <nl> # Update selection of table <nl> <nl> - py : tbl . between ( 10 , 20 ) . update ( lambda row : { ' a ' : row [ ' id ' ] } ) <nl> js : tbl . between ( 10 , 20 ) . update ( function ( row ) { return { ' a ' : row ( ' id ' ) } ; } ) <nl> rb : tbl . between ( 10 , 20 ) . update { | row | { : a = > row [ : id ] } } <nl> - ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 9 , ' unchanged ' : 1 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> + ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 10 , ' unchanged ' : 0 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> <nl> - py : tbl . filter ( lambda row : ( row [ ' id ' ] > = 10 ) & ( row [ ' id ' ] < 20 ) ) . update ( lambda row : { ' a ' : row [ ' id ' ] } ) <nl> js : tbl . filter ( function ( row ) { return row ( ' id ' ) . ge ( 10 ) . and ( row ( ' id ' ) . lt ( 20 ) ) } ) . update ( function ( row ) { return { ' a ' : row ( ' id ' ) } ; } ) <nl> tests : <nl> rb : tbl . filter { | row | ( row [ : id ] > = 10 ) . and ( row [ : id ] < 20 ) } . update { | row | { : b = > row [ : id ] } } <nl> ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 10 , ' unchanged ' : 0 . 0 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> <nl> + # now undo that update <nl> + - cd : tbl . between ( 10 , 20 ) . update ( { ' a ' : r . literal ( ) } ) <nl> + ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 10 , ' unchanged ' : 0 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> <nl> # trying to change pkey of a document <nl> - cd : tbl . get ( 1 ) . update ( { ' id ' : 2 , ' d ' : 1 } ) <nl> tests : <nl> - py : tbl . update ( lambda row : { ' a ' : row [ ' id ' ] } ) <nl> js : tbl . update ( function ( row ) { return { ' a ' : row ( ' id ' ) } ; } ) <nl> rb : tbl . update { | row | { : a = > row [ ' id ' ] } } <nl> - ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 90 , ' unchanged ' : 10 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> + ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 100 , ' unchanged ' : 0 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> + <nl> + # undo the update on the whole table <nl> + - cd : tbl . update ( { ' a ' : r . literal ( ) } ) <nl> + ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 100 , ' unchanged ' : 0 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> + <nl> + # recursive merge <nl> + - cd : tbl2 . update ( { ' foo ' : { ' bar ' : 2 } } ) <nl> + ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 99 , ' unchanged ' : 1 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> + <nl> + - cd : tbl2 . order_by ( ' id ' ) . nth ( 0 ) <nl> + ot : ( { ' id ' : 0 , ' foo ' : { ' bar ' : 2 } } ) <nl> + <nl> + - cd : tbl2 . update ( { ' foo ' : { ' buzz ' : 2 } } ) <nl> + ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 100 , ' unchanged ' : 0 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> + <nl> + - cd : tbl2 . order_by ( ' id ' ) . nth ( 0 ) <nl> + ot : ( { ' id ' : 0 , ' foo ' : { ' bar ' : 2 , ' buzz ' : 2 } } ) <nl> + <nl> + - cd : tbl2 . update ( { ' foo ' : r . literal ( 1 ) } ) <nl> + ot : ( { ' deleted ' : 0 . 0 , ' replaced ' : 100 , ' unchanged ' : 0 , ' errors ' : 0 . 0 , ' skipped ' : 0 . 0 , ' inserted ' : 0 . 0 } ) <nl> + <nl> + - cd : tbl2 . order_by ( ' id ' ) . nth ( 0 ) <nl> + ot : ( { ' id ' : 0 , ' foo ' : 1 } ) <nl> <nl> # clean up <nl> - cd : r . db ( ' test ' ) . table_drop ( ' test1 ' ) <nl> mmm a / test / rql_test / src / times / portions . yaml <nl> ppp b / test / rql_test / src / times / portions . yaml <nl> tests : <nl> js : ts . map ( r . time ( r . row . year ( ) , r . row . month ( ) , r . row . day ( ) , r . row . hours ( ) , r . row . minutes ( ) , r . row . seconds ( ) , r . row . timezone ( ) ) ) . union ( ts ) . map ( r . row . toISO8601 ( ) ) . distinct ( ) . count ( ) . sub ( ts . count ( ) ) <nl> ot : 0 <nl> - rb : ts . map { | x | [ x . day_of_week , x . day_of_year ] } <nl> - py : ts . map ( [ r . row . dayOfWeek ( ) , r . row . dayOfYear ( ) ] ) <nl> + cd : ts . map ( [ r . row . day_of_week ( ) , r . row . day_of_year ( ) ] ) <nl> ot : [ [ 2 , 211 ] , [ 2 , 211 ] , [ 2 , 211 ] , [ 5 , 97 ] ] <nl> mmm a / test / rql_test / src / transform / object . yaml <nl> ppp b / test / rql_test / src / transform / object . yaml <nl> tests : <nl> ot : ( { ' a ' : 1 , ' b ' : 2 , ' c ' : ' str ' , ' d ' : null , ' e ' : { ' f ' : ' buzz ' } } ) <nl> <nl> # # Merge <nl> + # obj = r . expr ( { ' a ' : 1 , ' b ' : 2 , ' c ' : " str " , ' d ' : null , ' e ' : { ' f ' : ' buzz ' } } ) <nl> <nl> - # add property <nl> + # complete replacement <nl> + - cd : " obj . merge ( 1 ) " <nl> + ot : 1 <nl> + <nl> + # add attr <nl> - cd : " obj . merge ( { ' e ' : - 2 } ) " <nl> ot : ( { ' a ' : 1 , ' b ' : 2 , ' c ' : ' str ' , ' d ' : null , ' e ' : - 2 } ) <nl> <nl> + # delete attr <nl> + - cd : " obj . merge ( { ' e ' : r . literal ( ) } ) " <nl> + ot : ( { ' a ' : 1 , ' b ' : 2 , ' c ' : ' str ' , ' d ' : null } ) <nl> + <nl> + # recursive merge <nl> + - cd : " obj . merge ( { ' e ' : { ' f ' : ' quux ' } } ) " <nl> + ot : ( { ' a ' : 1 , ' b ' : 2 , ' c ' : ' str ' , ' d ' : null , ' e ' : { ' f ' : ' quux ' } } ) <nl> + <nl> + - cd : " obj . merge ( { ' e ' : { ' g ' : ' quux ' } } ) " <nl> + ot : ( { ' a ' : 1 , ' b ' : 2 , ' c ' : ' str ' , ' d ' : null , ' e ' : { ' f ' : ' buzz ' , ' g ' : ' quux ' } } ) <nl> + <nl> + - cd : " obj . merge ( { ' e ' : r . literal ( { ' g ' : ' quux ' } ) } ) " <nl> + ot : ( { ' a ' : 1 , ' b ' : 2 , ' c ' : ' str ' , ' d ' : null , ' e ' : { ' g ' : ' quux ' } } ) <nl> + <nl> # overwrite <nl> - cd : " obj . merge ( { ' a ' : - 1 } ) " <nl> ot : ( { ' a ' : - 1 , ' b ' : 2 , ' c ' : ' str ' , ' d ' : null , ' e ' : { ' f ' : ' buzz ' } } ) <nl> <nl> + # errors <nl> + - cd : " r . literal ( ' foo ' ) " <nl> + ot : err ( " RqlRuntimeError " , " Stray literal keyword found , literal can only be present inside merge and cannot nest inside other literals . " , [ ] ) <nl> + <nl> + - cd : " obj . merge ( r . literal ( ' foo ' ) ) " <nl> + ot : err ( " RqlRuntimeError " , " Stray literal keyword found , literal can only be present inside merge and cannot nest inside other literals . " , [ ] ) <nl> + <nl> + - cd : " obj . merge ( { ' foo ' : r . literal ( r . literal ( ' foo ' ) ) } ) " <nl> + ot : err ( " RqlRuntimeError " , " Stray literal keyword found , literal can only be present inside merge and cannot nest inside other literals . " , [ ] ) <nl> + <nl> # # keys <nl> - cd : obj . keys ( ) <nl> ot : ( [ ' a ' , ' b ' , ' c ' , ' d ' , ' e ' ] ) <nl> | merged from github | rethinkdb/rethinkdb | beb0e4ae967fc51cb24455bf96754eb31a4b6eb3 | 2013-08-07T21:29:05Z |
mmm a / stdlib / Makefile <nl> ppp b / stdlib / Makefile <nl> include $ ( SWIFT_LEVEL ) / . . / . . / Makefile . config <nl> LIBRARYNAME : = swift_stdlib <nl> LINK_LIBS_IN_SHARED : = 1 <nl> SHARED_LIBRARY : = 1 <nl> - SWIFT_SOURCES : = Bool . swift FixedPoint . swift FloatingPoint . swift CTypes . swift \ <nl> - Misc . swift Enumeration . swift UnsafePointer . swift Slice . swift \ <nl> - String . swift Dictionary . swift Vector . swift Algorithm . swift \ <nl> + SWIFT_SOURCES : = Bool . swift FixedPoint . swift FloatingPoint . swift Object . swift \ <nl> + CTypes . swift Misc . swift Enumeration . swift UnsafePointer . swift \ <nl> + Slice . swift String . swift Dictionary . swift Vector . swift \ <nl> + Algorithm . swift \ <nl> Demangle . swift InputStream . swift OutputStream . swift \ <nl> CString . swift \ <nl> POSIX / Descriptor . swift POSIX / File . swift POSIX / Misc . swift <nl> new file mode 100644 <nl> index 000000000000 . . f903f7cc2bf2 <nl> mmm / dev / null <nl> ppp b / stdlib / Object . swift <nl> <nl> + / / FIXME - - add [ rootClass ] attribute <nl> + / / FIXME - - have non - rootClass classes default inherit from this via a typealias <nl> + / / SEE ALSO - - < rdar : / / problem / 12939349 > ER : class attribute : " rootClass " <nl> + <nl> + class Object : Equality { <nl> + } <nl> + <nl> + / / XXX - - this next line confuses and then crashes the compiler ? ! ? <nl> + / / typealias DefaultRootClass = Object <nl> + <nl> + func [ infix = 160 ] = = ( lhs : Object , rhs : Object ) - > Bool { <nl> + return _getBool ( Builtin . cmp_eq_RawPointer ( <nl> + Builtin . bridgeToRawPointer ( lhs ) , <nl> + Builtin . bridgeToRawPointer ( rhs ) <nl> + ) ) <nl> + } <nl> + <nl> + func [ infix = 160 ] ! = ( lhs : Object , rhs : Object ) - > Bool { <nl> + return _getBool ( Builtin . cmp_ne_RawPointer ( <nl> + Builtin . bridgeToRawPointer ( lhs ) , <nl> + Builtin . bridgeToRawPointer ( rhs ) <nl> + ) ) <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 64cac5ea56b3 <nl> mmm / dev / null <nl> ppp b / test / object . swift <nl> <nl> + / / RUN : % swift % s - i | FileCheck % s <nl> + <nl> + func test ( ) { <nl> + var d1 = new Dictionary <nl> + var d2 = new Dictionary <nl> + var d1_alias = d1 <nl> + if d1 ! = d2 { <nl> + println ( " good " ) <nl> + } <nl> + if d1 = = d1_alias { <nl> + println ( " also good " ) <nl> + } <nl> + } <nl> + <nl> + test ( ) <nl> + <nl> + / / CHECK : good <nl> + / / CHECK : also good <nl> new file mode 100644 <nl> index 000000000000 . . f903f7cc2bf2 <nl> mmm / dev / null <nl> ppp b / test / stdlib2 / Inputs / Object . swift <nl> <nl> + / / FIXME - - add [ rootClass ] attribute <nl> + / / FIXME - - have non - rootClass classes default inherit from this via a typealias <nl> + / / SEE ALSO - - < rdar : / / problem / 12939349 > ER : class attribute : " rootClass " <nl> + <nl> + class Object : Equality { <nl> + } <nl> + <nl> + / / XXX - - this next line confuses and then crashes the compiler ? ! ? <nl> + / / typealias DefaultRootClass = Object <nl> + <nl> + func [ infix = 160 ] = = ( lhs : Object , rhs : Object ) - > Bool { <nl> + return _getBool ( Builtin . cmp_eq_RawPointer ( <nl> + Builtin . bridgeToRawPointer ( lhs ) , <nl> + Builtin . bridgeToRawPointer ( rhs ) <nl> + ) ) <nl> + } <nl> + <nl> + func [ infix = 160 ] ! = ( lhs : Object , rhs : Object ) - > Bool { <nl> + return _getBool ( Builtin . cmp_ne_RawPointer ( <nl> + Builtin . bridgeToRawPointer ( lhs ) , <nl> + Builtin . bridgeToRawPointer ( rhs ) <nl> + ) ) <nl> + } <nl> | Enable ' = = ' and ' ! = ' for class references | apple/swift | ba7f0b0f2cfa78ae3431aa2f0ac74ca17bee4bfc | 2012-12-31T01:43:58Z |
mmm a / include / swift / AST / Decl . h <nl> ppp b / include / swift / AST / Decl . h <nl> class OneOfElementDecl : public ValueDecl { <nl> / / / <nl> / / / TODO : Should this be a special case of ElementRefDecl ? <nl> class ArgDecl : public ValueDecl { <nl> - public : <nl> / / FIXME : We don ' t have good location information for the function argument <nl> / / declaration . <nl> SourceLoc FuncLoc ; <nl> <nl> / / FIXME : Store the access path here . <nl> <nl> + public : <nl> ArgDecl ( SourceLoc FuncLoc , Identifier Name , Type Ty , DeclContext * DC ) <nl> : ValueDecl ( DeclKind : : Arg , DC , Name , Ty , 0 , DeclAttributes ( ) ) , <nl> FuncLoc ( FuncLoc ) { } <nl> <nl> - <nl> - SourceLoc getLocStart ( ) const { return FuncLoc ; } <nl> - <nl> + SourceLoc getFuncLoc ( ) const { return FuncLoc ; } <nl> + SourceLoc getLocStart ( ) const { return FuncLoc ; } <nl> <nl> / / Implement isa / cast / dyncast / etc . <nl> static bool classof ( const Decl * D ) { return D - > getKind ( ) = = DeclKind : : Arg ; } <nl> class ArgDecl : public ValueDecl { <nl> / / / with no name and two ElementRefDecls ( named A and B ) referring to elements <nl> / / / of the nameless vardecl . <nl> class ElementRefDecl : public ValueDecl { <nl> - public : <nl> VarDecl * VD ; <nl> SourceLoc NameLoc ; <nl> ArrayRef < unsigned > AccessPath ; <nl> <nl> + public : <nl> ElementRefDecl ( VarDecl * VD , SourceLoc NameLoc , Identifier Name , <nl> ArrayRef < unsigned > Path , Type Ty , DeclContext * DC ) <nl> : ValueDecl ( DeclKind : : ElementRef , DC , Name , Ty , 0 ) , VD ( VD ) , <nl> NameLoc ( NameLoc ) , AccessPath ( Path ) { <nl> } <nl> <nl> + VarDecl * getVarDecl ( ) const { return VD ; } <nl> + <nl> + ArrayRef < unsigned > getAccessPath ( ) const { return AccessPath ; } <nl> + <nl> / / / getTypeForPath - Given a type and an access path into it , return the <nl> / / / referenced element type . If the access path is invalid for the specified <nl> / / / type , this returns null . If the query goes into an unresolved ( dependent ) <nl> / / / part of the type , this returns DependentType . <nl> static Type getTypeForPath ( Type Ty , ArrayRef < unsigned > Path ) ; <nl> <nl> - <nl> + SourceLoc getNameLoc ( ) const { return NameLoc ; } <nl> SourceLoc getLocStart ( ) const { return NameLoc ; } <nl> <nl> / / Implement isa / cast / dyncast / etc . <nl> mmm a / lib / AST / Decl . cpp <nl> ppp b / lib / AST / Decl . cpp <nl> namespace { <nl> OS < < ' \ n ' ; <nl> OS . indent ( Indent + 2 ) ; <nl> OS < < " ( accesspath " ; <nl> - printDeclName ( ERD - > VD ) ; <nl> - for ( unsigned i = 0 , e = ERD - > AccessPath . size ( ) ; i ! = e ; + + i ) <nl> - OS < < " , " < < ERD - > AccessPath [ i ] ; <nl> + printDeclName ( ERD - > getVarDecl ( ) ) ; <nl> + for ( unsigned i = 0 , e = ERD - > getAccessPath ( ) . size ( ) ; i ! = e ; + + i ) <nl> + OS < < " , " < < ERD - > getAccessPath ( ) [ i ] ; <nl> <nl> OS < < " ) ) " ; <nl> } <nl> mmm a / lib / Sema / TypeCheckDecl . cpp <nl> ppp b / lib / Sema / TypeCheckDecl . cpp <nl> class DeclChecker : public DeclVisitor < DeclChecker > { <nl> / / simple . <nl> if ( ! ERD - > getType ( ) - > is < DependentType > ( ) ) return ; <nl> <nl> - if ( Type T = ElementRefDecl : : getTypeForPath ( ERD - > VD - > getType ( ) , <nl> - ERD - > AccessPath ) ) { <nl> + if ( Type T = ElementRefDecl : : getTypeForPath ( ERD - > getVarDecl ( ) - > getType ( ) , <nl> + ERD - > getAccessPath ( ) ) ) { <nl> ERD - > overwriteType ( T ) ; <nl> } else { <nl> TC . diagnose ( ERD - > getLocStart ( ) , diag : : invalid_index_in_element_ref , <nl> - ERD - > getName ( ) , ERD - > VD - > getType ( ) ) ; <nl> + ERD - > getName ( ) , ERD - > getVarDecl ( ) - > getType ( ) ) ; <nl> ERD - > overwriteType ( ErrorType : : get ( TC . Context ) ) ; <nl> } <nl> } <nl> | Finish getterizing Decl . h . | apple/swift | 94021a90bea84c5a0f938250e67ae2b8cf7c8c85 | 2011-11-18T01:29:31Z |
mmm a / tensorflow / tools / docs / parser . py <nl> ppp b / tensorflow / tools / docs / parser . py <nl> def _one_ref ( string , relative_path_to_root , duplicate_of , doc_index , index ) : <nl> link_text , string , relative_path_to_root , duplicate_of , index ) <nl> elif string . startswith ( ' tensorflow : : ' ) : # C + + symbol <nl> if string = = ' tensorflow : : ClientSession ' : <nl> - ret = ' CLIENT_SESSION_URL ' <nl> - elif string = = ' tensorflow : : Graph ' : <nl> - ret = ' GRAPH_URL ' <nl> + ret = ' class / tensorflow / client - session . md ' <nl> elif string = = ' tensorflow : : Scope ' : <nl> - ret = ' SCOPE_URL ' <nl> + ret = ' class / tensorflow / scope . md ' <nl> elif string = = ' tensorflow : : Status ' : <nl> - ret = ' STATUS_URL ' <nl> + ret = ' class / tensorflow / status . md ' <nl> elif string = = ' tensorflow : : ops : : Const ' : <nl> - ret = ' CONST_URL ' <nl> + ret = ' namespace / tensorflow / ops . md # const ' <nl> else : <nl> log_error ( ' Handle C + + reference " @ { % s } " ' % string ) <nl> return ' TODO_C + + : % s ' % string <nl> - return ' [ ` % s ` ] ( % s ) ' % ( link_text , os . path . join ( relative_path_to_root , ret ) ) <nl> + # TODO ( josh11b ) : Get rid of this hack ! <nl> + # Rewrite e . g . . . / . . / api_docs / python - > [ ' . . ' , ' . . ' , ' api_docs ' , ' cc ' , ret ] <nl> + cc_relative_path = relative_path_to_root . split ( ' / ' ) <nl> + cc_relative_path [ - 1 ] = ' cc ' <nl> + cc_relative_path . append ( ret ) <nl> + return ' [ ` % s ` ] ( % s ) ' % ( link_text , os . path . join ( * cc_relative_path ) ) <nl> # Error ! <nl> log_error ( ' Did not understand " @ { % s } " ' % string ) <nl> return ' ERROR : % s ' % string <nl> | Make @ { tensorflow : : . . . } work for a few C + + symbols | tensorflow/tensorflow | f58a8c06abb67f267fe1201366db2b49157ee106 | 2017-02-14T01:26:12Z |
mmm a / tensorflow / python / util / protobuf / compare . py <nl> ppp b / tensorflow / python / util / protobuf / compare . py <nl> def testXXX ( self ) : <nl> from __future__ import print_function <nl> <nl> import collections <nl> + import difflib <nl> <nl> import six <nl> <nl> def assertProtoEqual ( self , a , b , check_initialized = True , # pylint : disable = inva <nl> if normalize_numbers : <nl> NormalizeNumberFields ( pb ) <nl> <nl> - self . assertMultiLineEqual ( <nl> - text_format . MessageToString ( a , descriptor_pool = pool ) , <nl> - text_format . MessageToString ( b , descriptor_pool = pool ) , <nl> - msg = msg ) <nl> + a_str = text_format . MessageToString ( a , descriptor_pool = pool ) <nl> + b_str = text_format . MessageToString ( b , descriptor_pool = pool ) <nl> + <nl> + # Some Python versions would perform regular diff instead of multi - line <nl> + # diff if string is longer than 2 * * 16 . We substitute this behavior <nl> + # with a call to unified_diff instead to have easier - to - read diffs . <nl> + # For context , see : https : / / bugs . python . org / issue11763 . <nl> + if len ( a_str ) < 2 * * 16 and len ( b_str ) < 2 * * 16 : <nl> + self . assertMultiLineEqual ( a_str , b_str , msg = msg ) <nl> + else : <nl> + diff = ' \ n ' + ' ' . join ( difflib . unified_diff ( a_str . splitlines ( True ) , <nl> + b_str . splitlines ( True ) ) ) <nl> + self . fail ( ' % s : % s ' % ( msg , diff ) ) <nl> <nl> <nl> def NormalizeNumberFields ( pb ) : <nl> | Fix api_compatibility_test diff for large files . assertEqual might be applied | tensorflow/tensorflow | 29af23aeadd1d6fccbfa4223b58dad8f5b8df4f8 | 2018-10-05T23:52:24Z |
mmm a / hphp / hack / src / server / serverRevisionTracker . ml <nl> ppp b / hphp / hack / src / server / serverRevisionTracker . ml <nl> let check_changes start_t = <nl> else begin <nl> Hh_logger . log " Querying Mercurial for mergebase changes " ; <nl> Queue . iter begin fun hg_rev - > <nl> - let elapsed_t = ( Unix . gettimeofday ( ) ) - . start_t in <nl> + let current_t = Unix . gettimeofday ( ) in <nl> + let elapsed_t = current_t - . start_t in <nl> let timeout = max 0 ( int_of_float ( 30 . 0 - . elapsed_t ) ) in <nl> let future = Hashtbl . find mergebase_queries hg_rev in <nl> match Future . get ~ timeout future with <nl> | Error e - > <nl> let e = Future . error_to_string e in <nl> - HackEventLogger . check_mergebase_failed ( Future . start_t future ) e ; <nl> + HackEventLogger . check_mergebase_failed current_t e ; <nl> Hh_logger . log " ServerRevisionTracker : % s " e ; <nl> | Ok new_svn_rev - > <nl> - HackEventLogger . check_mergebase_success ( Future . start_t future ) ; <nl> + HackEventLogger . check_mergebase_success current_t ; <nl> match ! current_mergebase with <nl> | Some svn_rev when svn_rev < > new_svn_rev - > <nl> current_mergebase : = Some new_svn_rev ; <nl> | Adjust time taken logging for CHECK_MERGEBASE events | facebook/hhvm | cd47a9bb05a05a5b25d182aa0eab0d0058559d39 | 2018-09-25T02:29:33Z |
mmm a / src / init . cpp <nl> ppp b / src / init . cpp <nl> void SetupServerArgs ( ) <nl> # endif <nl> gArgs . AddArg ( " - prune = < n > " , strprintf ( " Reduce storage requirements by enabling pruning ( deleting ) of old blocks . This allows the pruneblockchain RPC to be called to delete specific blocks , and enables automatic pruning of old blocks if a target size in MiB is provided . This mode is incompatible with - txindex and - rescan . " <nl> " Warning : Reverting this setting requires re - downloading the entire blockchain . " <nl> - " ( default : 0 = disable pruning blocks , 1 = allow manual pruning via RPC , > % u = automatically prune block files to stay under the specified target size in MiB ) " , MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024 ) , false , OptionsCategory : : OPTIONS ) ; <nl> + " ( default : 0 = disable pruning blocks , 1 = allow manual pruning via RPC , > = % u = automatically prune block files to stay under the specified target size in MiB ) " , MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024 ) , false , OptionsCategory : : OPTIONS ) ; <nl> gArgs . AddArg ( " - reindex " , " Rebuild chain state and block index from the blk * . dat files on disk " , false , OptionsCategory : : OPTIONS ) ; <nl> gArgs . AddArg ( " - reindex - chainstate " , " Rebuild chain state from the currently indexed blocks " , false , OptionsCategory : : OPTIONS ) ; <nl> # ifndef WIN32 <nl> | - prune option - help output aligned with code | bitcoin/bitcoin | 312ff01ee533fab68348283200eb57e9956fdb34 | 2018-08-01T22:16:41Z |
mmm a / include / gtest / gtest - death - test . h <nl> ppp b / include / gtest / gtest - death - test . h <nl> GTEST_DECLARE_string_ ( death_test_style ) ; <nl> <nl> # if GTEST_HAS_DEATH_TEST <nl> <nl> + namespace internal { <nl> + <nl> + / / Returns a Boolean value indicating whether the caller is currently <nl> + / / executing in the context of the death test child process . Tools such as <nl> + / / Valgrind heap checkers may need this to modify their behavior in death <nl> + / / tests . IMPORTANT : This is an internal utility . Using it may break the <nl> + / / implementation of death tests . User code MUST NOT use it . <nl> + GTEST_API_ bool InDeathTestChild ( ) ; <nl> + <nl> + } / / namespace internal <nl> + <nl> / / The following macros are useful for writing death tests . <nl> <nl> / / Here ' s what happens when an ASSERT_DEATH * or EXPECT_DEATH * is <nl> mmm a / src / gtest - death - test . cc <nl> ppp b / src / gtest - death - test . cc <nl> GTEST_DEFINE_string_ ( <nl> " Indicates the file , line number , temporal index of " <nl> " the single death test to run , and a file descriptor to " <nl> " which a success code may be sent , all separated by " <nl> - " colons . This flag is specified if and only if the current " <nl> + " the ' | ' characters . This flag is specified if and only if the current " <nl> " process is a sub - process launched for running a thread - safe " <nl> " death test . FOR INTERNAL USE ONLY . " ) ; <nl> } / / namespace internal <nl> <nl> # if GTEST_HAS_DEATH_TEST <nl> <nl> + namespace internal { <nl> + <nl> + / / Valid only for fast death tests . Indicates the code is running in the <nl> + / / child process of a fast style death test . <nl> + static bool g_in_fast_death_test_child = false ; <nl> + <nl> + / / Returns a Boolean value indicating whether the caller is currently <nl> + / / executing in the context of the death test child process . Tools such as <nl> + / / Valgrind heap checkers may need this to modify their behavior in death <nl> + / / tests . IMPORTANT : This is an internal utility . Using it may break the <nl> + / / implementation of death tests . User code MUST NOT use it . <nl> + bool InDeathTestChild ( ) { <nl> + # if GTEST_OS_WINDOWS <nl> + <nl> + / / On Windows , death tests are thread - safe regardless of the value of the <nl> + / / death_test_style flag . <nl> + return ! GTEST_FLAG ( internal_run_death_test ) . empty ( ) ; <nl> + <nl> + # else <nl> + <nl> + if ( GTEST_FLAG ( death_test_style ) = = " threadsafe " ) <nl> + return ! GTEST_FLAG ( internal_run_death_test ) . empty ( ) ; <nl> + else <nl> + return g_in_fast_death_test_child ; <nl> + # endif <nl> + } <nl> + <nl> + } / / namespace internal <nl> + <nl> / / ExitedWithCode constructor . <nl> ExitedWithCode : : ExitedWithCode ( int exit_code ) : exit_code_ ( exit_code ) { <nl> } <nl> DeathTest : : TestRole NoExecDeathTest : : AssumeRole ( ) { <nl> / / Event forwarding to the listeners of event listener API mush be shut <nl> / / down in death test subprocesses . <nl> GetUnitTestImpl ( ) - > listeners ( ) - > SuppressEventForwarding ( ) ; <nl> + g_in_fast_death_test_child = true ; <nl> return EXECUTE_TEST ; <nl> } else { <nl> GTEST_DEATH_TEST_CHECK_SYSCALL_ ( close ( pipe_fd [ 1 ] ) ) ; <nl> mmm a / test / gtest - death - test_test . cc <nl> ppp b / test / gtest - death - test_test . cc <nl> using testing : : internal : : DeathTestFactory ; <nl> using testing : : internal : : FilePath ; <nl> using testing : : internal : : GetLastErrnoDescription ; <nl> using testing : : internal : : GetUnitTestImpl ; <nl> + using testing : : internal : : InDeathTestChild ; <nl> using testing : : internal : : ParseNaturalNumber ; <nl> using testing : : internal : : String ; <nl> <nl> TEST ( ConditionalDeathMacrosSyntaxDeathTest , SwitchStatement ) { <nl> # endif / / _MSC_VER <nl> } <nl> <nl> + TEST ( InDeathTestChildDeathTest , ReportsDeathTestCorrectlyInFastStyle ) { <nl> + testing : : GTEST_FLAG ( death_test_style ) = " fast " ; <nl> + EXPECT_FALSE ( InDeathTestChild ( ) ) ; <nl> + EXPECT_DEATH ( { <nl> + fprintf ( stderr , InDeathTestChild ( ) ? " Inside " : " Outside " ) ; <nl> + fflush ( stderr ) ; <nl> + _exit ( 1 ) ; <nl> + } , " Inside " ) ; <nl> + } <nl> + <nl> + TEST ( InDeathTestChildDeathTest , ReportsDeathTestCorrectlyInThreadSafeStyle ) { <nl> + testing : : GTEST_FLAG ( death_test_style ) = " threadsafe " ; <nl> + EXPECT_FALSE ( InDeathTestChild ( ) ) ; <nl> + EXPECT_DEATH ( { <nl> + fprintf ( stderr , InDeathTestChild ( ) ? " Inside " : " Outside " ) ; <nl> + fflush ( stderr ) ; <nl> + _exit ( 1 ) ; <nl> + } , " Inside " ) ; <nl> + } <nl> + <nl> / / Tests that a test case whose name ends with " DeathTest " works fine <nl> / / on Windows . <nl> TEST ( NotADeathTest , Test ) { <nl> | Adds support for detection of running in death test child processes . | google/googletest | 829402edcffe712ed4c79412ca020525cd8295ad | 2011-10-28T16:19:04Z |
mmm a / lib / IRGen / GenDecl . cpp <nl> ppp b / lib / IRGen / GenDecl . cpp <nl> static llvm : : GlobalVariable * createGOTEquivalent ( IRGenModule & IGM , <nl> <nl> if ( IGM . Triple . getObjectFormat ( ) = = llvm : : Triple : : COFF ) { <nl> if ( cast < llvm : : GlobalValue > ( global ) - > hasDLLImportStorageClass ( ) ) { <nl> + / / Add the user label prefix * prior * to the introduction of the linker <nl> + / / synthetic marker ` __imp_ ` . <nl> + / / Failure to do so will re - decorate the generated symbol and miss the <nl> + / / user label prefix , generating e . g . ` ___imp_ $ sBoW ` instead of <nl> + / / ` __imp__ $ sBoW ` . <nl> + if ( auto prefix = IGM . DataLayout . getGlobalPrefix ( ) ) <nl> + globalName = ( llvm : : Twine ( prefix ) + globalName ) . str ( ) ; <nl> + / / Indicate to LLVM that the symbol should not be re - decorated . <nl> llvm : : GlobalVariable * GV = <nl> new llvm : : GlobalVariable ( IGM . Module , global - > getType ( ) , <nl> / * Constant = * / true , <nl> - llvm : : GlobalValue : : ExternalLinkage , <nl> - nullptr , llvm : : Twine ( " __imp_ " ) + globalName ) ; <nl> + llvm : : GlobalValue : : ExternalLinkage , nullptr , <nl> + " \ 01__imp_ " + globalName ) ; <nl> GV - > setExternallyInitialized ( true ) ; <nl> return GV ; <nl> } <nl> mmm a / test / IRGen / class_resilience . swift <nl> ppp b / test / IRGen / class_resilience . swift <nl> <nl> / / - - field offset vector offset : <nl> / / CHECK - SAME : i32 0 , <nl> / / - - superclass : <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ s15resilient_class22ResilientOutsideParentCMn " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ s15resilient_class22ResilientOutsideParentCMn " <nl> / / - - singleton metadata initialization cache : <nl> / / CHECK - SAME : @ " $ s16class_resilience14ResilientChildCMl " <nl> / / - - resilient pattern : <nl> <nl> / / CHECK - SAME : i32 2 , <nl> / / CHECK - SAME : % swift . method_override_descriptor { <nl> / / - - base class : <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ s15resilient_class22ResilientOutsideParentCMn " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ s15resilient_class22ResilientOutsideParentCMn " <nl> / / - - base method : <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ s15resilient_class22ResilientOutsideParentC8getValueSiyFTq " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ s15resilient_class22ResilientOutsideParentC8getValueSiyFTq " <nl> / / - - implementation : <nl> / / CHECK - SAME : @ " $ s16class_resilience14ResilientChildC8getValueSiyF " <nl> / / CHECK - SAME : } <nl> / / CHECK - SAME : % swift . method_override_descriptor { <nl> / / - - base class : <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ s15resilient_class22ResilientOutsideParentCMn " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ s15resilient_class22ResilientOutsideParentCMn " <nl> / / - - base method : <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ s15resilient_class22ResilientOutsideParentCACycfCTq " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ s15resilient_class22ResilientOutsideParentCACycfCTq " <nl> / / - - implementation : <nl> / / CHECK - SAME : @ " $ s16class_resilience14ResilientChildCACycfC " <nl> / / CHECK - SAME : } <nl> mmm a / test / IRGen / dllimport . swift <nl> ppp b / test / IRGen / dllimport . swift <nl> public func g ( ) { <nl> / / CHECK - NO - OPT - DAG : declare dllimport void @ swift_deallocClassInstance ( % swift . refcounted * , i32 , i32 ) <nl> <nl> / / CHECK - OPT - DAG : declare dllimport % swift . refcounted * @ swift_retain ( % swift . refcounted * returned ) local_unnamed_addr <nl> - / / CHECK - OPT - DAG : @ " __imp_ $ s9dllexport1pMp " = external externally_initialized constant % swift . protocol * <nl> + / / CHECK - OPT - DAG : @ " \ 01__imp_ { { _ ? } } $ s9dllexport1pMp " = external externally_initialized constant % swift . protocol * <nl> / / CHECK - OPT - DAG : declare dllimport swiftcc i8 * @ " $ s9dllexport2ciAA1cCvau " ( ) <nl> / / CHECK - OPT - DAG : declare dllimport void @ swift_deallocClassInstance ( % swift . refcounted * , i32 , i32 ) <nl> / / CHECK - OPT - DAG : declare dllimport swiftcc % swift . refcounted * @ " $ s9dllexport1cCfd " ( % T9dllexport1cC * swiftself ) <nl> mmm a / test / IRGen / keypath_witness_overrides . swift <nl> ppp b / test / IRGen / keypath_witness_overrides . swift <nl> <nl> import protocol_overrides <nl> <nl> / / CHECK : @ keypath = private global <nl> - / / CHECK - SAME : % swift . method_descriptor * * @ " { { got . | __imp_ } } $ s18protocol_overrides14OriginalGetterPy7ElementQz5IndexQzcigTq " <nl> + / / CHECK - SAME : % swift . method_descriptor * * @ " { { got . | \ \ 01__imp__ ? } } $ s18protocol_overrides14OriginalGetterPy7ElementQz5IndexQzcigTq " <nl> public func getWritableKeyPath < OS : OverridesSetter > ( _ c : OS , index : OS . Index ) - > AnyKeyPath <nl> where OS . Index : Hashable { <nl> let keypath = \ OS . [ index ] <nl> mmm a / test / IRGen / keypaths . sil <nl> ppp b / test / IRGen / keypaths . sil <nl> sil_vtable C2 { } <nl> / / CHECK - SAME : < i32 0x8000_000c > , <nl> / / - - computed , get - only , identified by ( indirected ) function pointer , no args <nl> / / CHECK - SAME : < i32 0x0200_0002 > , <nl> - / / CHECK - SAME : @ { { got . | __imp_ } } k_id <nl> + / / CHECK - SAME : @ { { got . | " \ \ 01__imp__ ? } } k_id <nl> / / CHECK - SAME : void ( % TSi * , % T8keypaths1SV * ) * { { . * } } @ k_get { { . * } } <nl> <nl> / / - - % l : computed <nl> mmm a / test / IRGen / keypaths_external . sil <nl> ppp b / test / IRGen / keypaths_external . sil <nl> sil @ s_equals : $ @ convention ( thin ) < A : Hashable , B : Hashable > ( UnsafeRawPointer , <nl> sil @ s_hash : $ @ convention ( thin ) < A : Hashable , B : Hashable > ( UnsafeRawPointer ) - > Int <nl> <nl> / / - - % t <nl> - / / CHECK : [ [ KP_T : @ keypath ( \ . . * ) ? ] ] = private global < { { { . * } } } > < { { { . * } } i32 1 , { { . * } } @ " { { got . | __imp_ } } $ s23keypaths_external_other1GV1xxvpMV " <nl> + / / CHECK : [ [ KP_T : @ keypath ( \ . . * ) ? ] ] = private global < { { { . * } } } > < { { { . * } } i32 1 , { { . * } } @ " { { got . | \ \ 01__imp__ ? } } $ s23keypaths_external_other1GV1xxvpMV " <nl> / / CHECK - SAME : @ " symbolic x " <nl> / / - - computed get - only property , identified by indirect pointer <nl> / / CHECK - SAME : < i32 0x0208_0002 > <nl> <nl> / / - - % u <nl> - / / CHECK : [ [ KP_U : @ keypath ( \ . . * ) ? ] ] = private global < { { { . * } } } > < { { { . * } } i32 3 , { { . * } } @ " { { got . | __imp_ } } $ s23keypaths_external_other1GVyxqd__cSHRd__luipMV " <nl> + / / CHECK : [ [ KP_U : @ keypath ( \ . . * ) ? ] ] = private global < { { { . * } } } > < { { { . * } } i32 3 , { { . * } } @ " { { got . | \ \ 01__imp__ ? } } $ s23keypaths_external_other1GVyxqd__cSHRd__luipMV " <nl> / / CHECK - SAME : @ " symbolic q_ " <nl> / / CHECK - SAME : @ " symbolic x " <nl> / / CHECK - SAME : @ " get_witness_table <nl> mmm a / test / IRGen / property_descriptor . sil <nl> ppp b / test / IRGen / property_descriptor . sil <nl> sil_property # ExternalGeneric . rw < T : Comparable > ( <nl> / / CHECK : @ " $ s19property_descriptor15ExternalGenericV10computedROxvpMV " = <nl> / / - - 0x0108_0000 - computed , readonly , has arguments , identified by indirect <nl> / / CHECK - SAME : < { < i32 0x0208_0002 > , <nl> - / / CHECK - SAME : @ { { got . | __imp_ } } id_computed <nl> + / / CHECK - SAME : @ { { got . | " \ \ 01__imp__ ? } } id_computed <nl> / / CHECK - SAME : [ [ GET_COMPUTEDRO : @ keypath_get [ . 0 - 9 ] * ] ] { { ( \ . ptrauth ) ? } } <nl> / / CHECK - SAME : [ [ GET_ARG_LAYOUT_COMPUTEDRO : @ keypath_get_arg_layout [ . 0 - 9 ] * ] ] { { ( \ . ptrauth ) ? } } <nl> / / - - default witness table <nl> sil_property # ExternalGeneric . computedRO < T : Comparable > ( <nl> / / CHECK : @ " $ s19property_descriptor15ExternalGenericV10computedRWxvpMV " = <nl> / / - - 0x01c8_0000 - computed , settable , mutating , has arguments , indirect id <nl> / / CHECK - SAME : < { < i32 0x02c8_0002 > , <nl> - / / CHECK - SAME : @ { { got . | __imp_ } } id_computed <nl> + / / CHECK - SAME : @ { { got . | " \ \ 01__imp__ ? } } id_computed <nl> / / CHECK - SAME : [ [ GET_COMPUTEDRW : @ keypath_get [ . 0 - 9 ] * ] ] { { ( \ . ptrauth ) ? } } <nl> / / CHECK - SAME : [ [ SET_COMPUTEDRW : @ keypath_set [ . 0 - 9 ] * ] ] { { ( \ . ptrauth ) ? } } <nl> / / CHECK - SAME : [ [ GET_ARG_LAYOUT_COMPUTEDRW : @ keypath_get_arg_layout [ . 0 - 9 ] * ] ] { { ( \ . ptrauth ) ? } } <nl> sil_property # ExternalGeneric . computedRW < T : Comparable > ( <nl> / / CHECK : @ " $ s19property_descriptor15ExternalGenericVyxqd__cSHRd__luipMV " = <nl> / / - - 0x01c8_0000 - computed , settable , mutating , has arguments , indirect id <nl> / / CHECK - SAME : < { < i32 0x02c8_0002 > , <nl> - / / CHECK - SAME : @ { { got . | __imp_ } } id_computed <nl> + / / CHECK - SAME : @ { { got . | " \ \ 01__imp__ ? } } id_computed <nl> / / CHECK - SAME : [ [ GET_SUBSCRIPT : @ keypath_get [ . 0 - 9 ] * ] ] { { ( \ . ptrauth ) ? } } <nl> / / CHECK - SAME : [ [ SET_SUBSCRIPT : @ keypath_set [ . 0 - 9 ] * ] ] { { ( \ . ptrauth ) ? } } <nl> / / CHECK - SAME : [ [ GET_ARG_LAYOUT_SUBSCRIPT : @ keypath_get_arg_layout [ . 0 - 9 ] * ] ] { { ( \ . ptrauth ) ? } } <nl> mmm a / test / IRGen / protocol_conformance_records . swift <nl> ppp b / test / IRGen / protocol_conformance_records . swift <nl> public struct NativeGenericType < T > : Runcible { <nl> / / - - protocol descriptor <nl> / / CHECK - SAME : [ [ RUNCIBLE ] ] <nl> / / - - type metadata <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ sSiMn " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ sSiMn " <nl> / / - - witness table <nl> / / CHECK - SAME : @ " $ sSi28protocol_conformance_records8RuncibleAAWP " <nl> / / - - reserved <nl> extension Int : Runcible { <nl> / / - - protocol descriptor <nl> / / CHECK - SAME : [ [ RUNCIBLE ] ] <nl> / / - - nominal type descriptor <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ s16resilient_struct4SizeVMn " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ s16resilient_struct4SizeVMn " <nl> / / - - witness table <nl> / / CHECK - SAME : @ " $ s16resilient_struct4SizeV28protocol_conformance_records8RuncibleADWP " <nl> / / - - reserved <nl> extension NativeGenericType : Spoon where T : Spoon { <nl> / / Retroactive conformance <nl> / / CHECK - LABEL : @ " $ sSi18resilient_protocol22OtherResilientProtocol0B20_conformance_recordsMc " = { { dllexport | protected | } } constant <nl> / / - - protocol descriptor <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ s18resilient_protocol22OtherResilientProtocolMp " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ s18resilient_protocol22OtherResilientProtocolMp " <nl> / / - - nominal type descriptor <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ sSiMn " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ sSiMn " <nl> / / - - witness table pattern <nl> / / CHECK - SAME : i32 0 , <nl> / / - - flags <nl> mmm a / test / IRGen / protocol_resilience . sil <nl> ppp b / test / IRGen / protocol_resilience . sil <nl> protocol InternalProtocol { <nl> / / CHECK - SAME : i32 3 , <nl> <nl> / / - - type metadata for associated type <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ s1T18resilient_protocol24ProtocolWithRequirementsPTl " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ s1T18resilient_protocol24ProtocolWithRequirementsPTl " <nl> / / CHECK - SAME : @ " symbolic Si " <nl> <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ s18resilient_protocol24ProtocolWithRequirementsP5firstyyFTq " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ s18resilient_protocol24ProtocolWithRequirementsP5firstyyFTq " <nl> / / CHECK - SAME : @ firstWitness <nl> <nl> - / / CHECK - SAME : @ " { { got . | __imp_ } } $ s18resilient_protocol24ProtocolWithRequirementsP6secondyyFTq " <nl> + / / CHECK - SAME : @ " { { got . | \ \ 01__imp__ ? } } $ s18resilient_protocol24ProtocolWithRequirementsP6secondyyFTq " <nl> / / CHECK - SAME : @ secondWitness <nl> <nl> / / - - number of witness table entries <nl> mmm a / test / IRGen / protocol_resilience_descriptors . swift <nl> ppp b / test / IRGen / protocol_resilience_descriptors . swift <nl> import resilient_protocol <nl> / / Resilient witness tables <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> / / CHECK - USAGE - LABEL : $ s31protocol_resilience_descriptors34ConformsToProtocolWithRequirementsVyxG010resilient_A00fgH0AAMc " = <nl> - / / CHECK - USAGE - SAME : { { got . | __imp_ } } $ s1T18resilient_protocol24ProtocolWithRequirementsPTl <nl> + / / CHECK - USAGE - SAME : { { got . | \ \ 01__imp__ ? } } $ s1T18resilient_protocol24ProtocolWithRequirementsPTl <nl> / / CHECK - USAGE - SAME : @ " symbolic x " <nl> public struct ConformsToProtocolWithRequirements < Element > <nl> : ProtocolWithRequirements { <nl> | Merge pull request from compnerd / decoration | apple/swift | b317763bc6cd6fbc4b934199a6966d73f10ce604 | 2020-12-07T22:20:32Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.