diff
stringlengths
41
2.03M
msg
stringlengths
1
1.5k
repo
stringlengths
5
40
sha
stringlengths
40
40
time
stringlengths
20
20
mmm a / caffe2 / operators / gather_ranges_to_dense_op . cc <nl> ppp b / caffe2 / operators / gather_ranges_to_dense_op . cc <nl> are sorted by the corresponding KEY . <nl> . Input ( 2 , " KEY " , " Tensor of rank 1 and type int64 . " ) <nl> . Output ( 0 , " OUTPUT " , " 1 - D tensor of size sum of range lengths " ) <nl> . Arg ( " lengths " , " Expected lengths for ranges " ) <nl> + . Arg ( <nl> + " min_observation " , <nl> + " The number of observations needed before deciding that the ratio of " <nl> + " empty ranges or mismatched ranges is alarming . " ) <nl> + . Arg ( <nl> + " max_empty_ratio " , <nl> + " An crital log is triggered when ratio of empty ranges exceeds this . " ) <nl> + . Arg ( <nl> + " max_mismatched_ratio " , <nl> + " An error is raised when ratio of mismatched ranges exceeds this . " ) <nl> . TensorInferenceFunction ( [ ] ( const OperatorDef & def , <nl> const vector < TensorShape > & in ) { <nl> ArgumentHelper helper ( def ) ; <nl> mmm a / caffe2 / operators / gather_ranges_to_dense_op . h <nl> ppp b / caffe2 / operators / gather_ranges_to_dense_op . h <nl> class GatherRangesToDenseOp final : public Operator < Context > { <nl> template < class . . . Args > <nl> explicit GatherRangesToDenseOp ( Args & & . . . args ) <nl> : Operator < Context > ( std : : forward < Args > ( args ) . . . ) , <nl> - lengths_ ( this - > template GetRepeatedArgument < int > ( " lengths " ) ) { <nl> + lengths_ ( this - > template GetRepeatedArgument < int > ( " lengths " ) ) , <nl> + minObservation_ ( <nl> + this - > template GetSingleArgument < int > ( " min_observation " , 10000 ) ) , <nl> + maxEmptyRatio_ ( <nl> + this - > template GetSingleArgument < float > ( " max_empty_ratio " , 0 . 3 ) ) , <nl> + maxMismatchedRatio_ ( this - > template GetSingleArgument < float > ( <nl> + " max_mismatched_ratio " , <nl> + 0 . 01 ) ) { <nl> CAFFE_ENFORCE_GT ( lengths_ . size ( ) , 0 , " There has to be at least one length " ) ; <nl> for ( auto length : lengths_ ) { <nl> CAFFE_ENFORCE_GT ( length , 0 , " Each length should be positive " ) ; <nl> } <nl> + CAFFE_ENFORCE_GT ( <nl> + minObservation_ , 0 , " The number of observations is at least 1 " ) ; <nl> + / / Initialize the empty and mismatch counter . <nl> + for ( int i = 0 ; i < OutputSize ( ) ; + + i ) { <nl> + emptyRanges_ . push_back ( 0 ) ; <nl> + mismatchedRanges_ . push_back ( 0 ) ; <nl> + } <nl> + } <nl> + <nl> + ~ GatherRangesToDenseOp ( ) noexcept override { <nl> + LOG ( INFO ) < < " In GatherRangesToDenseOp : \ n " <nl> + < < " Lifetime empty ranges for each feature is " < < emptyRanges_ <nl> + < < " . \ n " <nl> + < < " Lifetime mismatched ranges for each feature is " <nl> + < < mismatchedRanges_ < < " . \ n " <nl> + < < " After " < < totalRanges_ < < " examples " ; <nl> } <nl> <nl> bool RunOnDevice ( ) override { <nl> class GatherRangesToDenseOp final : public Operator < Context > { <nl> for ( int j = 0 ; j < OutputSize ( ) ; + + j ) { <nl> auto rangeStart = rangesData [ rangesDataOffset + + ] ; <nl> auto rangeLength = rangesData [ rangesDataOffset + + ] ; <nl> + <nl> if ( rangeLength = = 0 ) { <nl> / / empty range , will be filled with zeros <nl> + emptyRanges_ [ j ] + + ; <nl> + continue ; <nl> + } <nl> + if ( rangeLength ! = lengths_ [ j ] ) { <nl> + / / Range lengths missmatch for output # , will be filled with zeros <nl> + / / Note , empty ranges are not counted as mismatched because empty <nl> + / / are more common and more tolerable . <nl> + mismatchedRanges_ [ j ] + + ; <nl> continue ; <nl> } <nl> - CAFFE_ENFORCE_EQ ( <nl> - rangeLength , <nl> - lengths_ [ j ] , <nl> - " Range lengths missmatch for output # " , <nl> - j ) ; <nl> <nl> if ( InputSize ( ) = = 2 ) { <nl> context_ . CopyItemsSameDevice ( <nl> class GatherRangesToDenseOp final : public Operator < Context > { <nl> } <nl> } <nl> } <nl> + <nl> CAFFE_ENFORCE_EQ ( rangesDataOffset , ranges . numel ( ) ) ; <nl> <nl> + / / Check whether the empty and mismatch ratio exceeded the threshold . <nl> + totalRanges_ + = batchSize ; <nl> + if ( totalRanges_ > = minObservation_ ) { <nl> + for ( int j = 0 ; j < OutputSize ( ) ; + + j ) { <nl> + CAFFE_ENFORCE_GT ( <nl> + totalRanges_ * maxMismatchedRatio_ , <nl> + mismatchedRanges_ [ j ] , <nl> + " Ratio of range length mismatch for feature at index " , <nl> + j , <nl> + " is " , <nl> + ( static_cast < double > ( mismatchedRanges_ [ j ] ) / <nl> + static_cast < double > ( totalRanges_ ) ) , <nl> + " ( " , <nl> + mismatchedRanges_ [ j ] , <nl> + " / " , <nl> + totalRanges_ , <nl> + " ) which exceeds " , <nl> + maxMismatchedRatio_ ) ; <nl> + if ( totalRanges_ * maxEmptyRatio_ < = emptyRanges_ [ j ] ) { <nl> + LOG ( ERROR ) < < " Ratio of empty range for feature at index " < < j <nl> + < < " is " <nl> + < < ( static_cast < double > ( emptyRanges_ [ j ] ) / <nl> + static_cast < double > ( totalRanges_ ) ) <nl> + < < " ( " < < emptyRanges_ [ j ] < < " / " < < totalRanges_ <nl> + < < " ) which exceeds " < < maxEmptyRatio_ ; <nl> + } <nl> + } <nl> + } <nl> + <nl> return true ; <nl> } <nl> <nl> class GatherRangesToDenseOp final : public Operator < Context > { <nl> <nl> private : <nl> vector < int > lengths_ ; <nl> + int totalRanges_ = 0 ; <nl> + vector < int > emptyRanges_ ; <nl> + vector < int > mismatchedRanges_ ; <nl> + / / To avoid false alarm due to insufficient sample ( e . g . , first batch being <nl> + / / empty and causing 100 % to be empty ) , use a threshold to ensure enough <nl> + / / samples are gathered before decideding whether there is an alarm or not . <nl> + int minObservation_ = 0 ; <nl> + float maxEmptyRatio_ = 0 ; <nl> + float maxMismatchedRatio_ = 0 ; <nl> } ; <nl> <nl> } / / namespace caffe2 <nl> mmm a / caffe2 / python / operator_test / gather_ranges_op_test . py <nl> ppp b / caffe2 / python / operator_test / gather_ranges_op_test . py <nl> <nl> - from __future__ import absolute_import <nl> - from __future__ import division <nl> - from __future__ import print_function <nl> - from __future__ import unicode_literals <nl> + from __future__ import absolute_import , division , print_function , unicode_literals <nl> <nl> - from caffe2 . python import core , workspace <nl> - from hypothesis import given <nl> - from hypothesis import strategies as st <nl> import caffe2 . python . hypothesis_test_util as hu <nl> import caffe2 . python . serialized_test . serialized_test_util as serial <nl> import numpy as np <nl> + from caffe2 . python import core , workspace <nl> + from hypothesis import given , strategies as st <nl> <nl> <nl> def batched_boarders_and_data ( <nl> def _tensor_splits ( draw ) : <nl> ) <nl> <nl> <nl> + @ st . composite <nl> + def _bad_tensor_splits ( draw ) : <nl> + lengths = draw ( st . lists ( st . integers ( 4 , 6 ) , min_size = 4 , max_size = 4 ) ) <nl> + batch_size = 4 <nl> + element_pairs = [ <nl> + ( batch , r ) for batch in range ( batch_size ) for r in range ( len ( lengths ) ) <nl> + ] <nl> + perm = draw ( st . permutations ( element_pairs ) ) <nl> + ranges = [ [ ( 0 , 0 ) ] * len ( lengths ) for _ in range ( batch_size ) ] <nl> + offset = 0 <nl> + <nl> + # Inject some bad samples depending on the batch . <nl> + # Batch 2 : length is set to 0 . This way , 25 % of the samples are empty . <nl> + # Batch 0 - 1 : length is set to half the original length . This way , 50 % of the <nl> + # samples are of mismatched length . <nl> + for pair in perm : <nl> + if pair [ 0 ] = = 2 : <nl> + length = 0 <nl> + elif pair [ 0 ] < = 1 : <nl> + length = lengths [ pair [ 1 ] ] / / 2 <nl> + else : <nl> + length = lengths [ pair [ 1 ] ] <nl> + ranges [ pair [ 0 ] ] [ pair [ 1 ] ] = ( offset , length ) <nl> + offset + = length <nl> + <nl> + data = draw ( <nl> + st . lists ( <nl> + st . floats ( min_value = - 1 . 0 , max_value = 1 . 0 ) , min_size = offset , max_size = offset <nl> + ) <nl> + ) <nl> + <nl> + key = draw ( st . permutations ( range ( offset ) ) ) <nl> + <nl> + return ( <nl> + np . array ( data ) . astype ( np . float32 ) , <nl> + np . array ( ranges ) , <nl> + np . array ( lengths ) , <nl> + np . array ( key ) . astype ( np . int64 ) , <nl> + ) <nl> + <nl> + <nl> def gather_ranges ( data , ranges ) : <nl> lengths = [ ] <nl> output = [ ] <nl> def test_shape_and_type_inference ( self ) : <nl> self . assertEqual ( shapes [ " lengths_output " ] , [ 3 ] ) <nl> self . assertEqual ( types [ " lengths_output " ] , core . DataType . INT32 ) <nl> <nl> + @ given ( tensor_splits = _bad_tensor_splits ( ) , * * hu . gcs_cpu_only ) <nl> + def test_empty_range_check ( self , tensor_splits , gc , dc ) : <nl> + data , ranges , lengths , key = tensor_splits <nl> + <nl> + workspace . FeedBlob ( " data " , data ) <nl> + workspace . FeedBlob ( " ranges " , ranges ) <nl> + workspace . FeedBlob ( " key " , key ) <nl> + <nl> + def getOpWithThreshold ( <nl> + min_observation = 2 , max_empty_ratio = 0 . 3 , max_mismatched_ratio = 0 . 6 <nl> + ) : <nl> + return core . CreateOperator ( <nl> + " GatherRangesToDense " , <nl> + [ " data " , " ranges " , " key " ] , <nl> + [ " X_ { } " . format ( i ) for i in range ( len ( lengths ) ) ] , <nl> + lengths = lengths , <nl> + min_observation = min_observation , <nl> + max_empty_ratio = max_empty_ratio , <nl> + max_mismatched_ratio = max_mismatched_ratio , <nl> + ) <nl> + <nl> + workspace . RunOperatorOnce ( getOpWithThreshold ( ) ) <nl> + <nl> + # A critical log should be triggered by this setting . <nl> + workspace . RunOperatorOnce ( getOpWithThreshold ( max_empty_ratio = 0 . 2 ) ) <nl> + <nl> + with self . assertRaises ( RuntimeError ) : <nl> + workspace . RunOperatorOnce ( getOpWithThreshold ( max_mismatched_ratio = 0 . 4 ) ) <nl> + <nl> + workspace . RunOperatorOnce ( <nl> + getOpWithThreshold ( <nl> + max_empty_ratio = 0 . 2 , max_mismatched_ratio = 0 . 4 , min_observation = 5 <nl> + ) <nl> + ) <nl> + <nl> <nl> if __name__ = = " __main__ " : <nl> import unittest <nl> + <nl> unittest . main ( ) <nl>
Tolerate small amount of embedding corruptions
pytorch/pytorch
06bb74ce96f80856ded884282c17777f61fd3212
2019-10-21T23:23:25Z
mmm a / xbmc / guilib / GUIControl . cpp <nl> ppp b / xbmc / guilib / GUIControl . cpp <nl> using namespace std ; <nl> <nl> CGUIControl : : CGUIControl ( ) <nl> { <nl> - m_hasProcessed = false ; <nl> + m_hasRendered = false ; <nl> m_bHasFocus = false ; <nl> m_controlID = 0 ; <nl> m_parentID = 0 ; <nl> CGUIControl : : CGUIControl ( int parentID , int controlID , float posX , float posY , fl <nl> ControlType = GUICONTROL_UNKNOWN ; <nl> m_bInvalidated = true ; <nl> m_bAllocated = false ; <nl> - m_hasProcessed = false ; <nl> + m_hasRendered = false ; <nl> m_parentControl = NULL ; <nl> m_hasCamera = false ; <nl> m_pushedUpdates = false ; <nl> CGUIControl : : ~ CGUIControl ( void ) <nl> <nl> void CGUIControl : : AllocResources ( ) <nl> { <nl> - m_hasProcessed = false ; <nl> + m_hasRendered = false ; <nl> m_bInvalidated = true ; <nl> m_bAllocated = true ; <nl> } <nl> void CGUIControl : : FreeResources ( bool immediately ) <nl> } <nl> m_bAllocated = false ; <nl> } <nl> - m_hasProcessed = false ; <nl> + m_hasRendered = false ; <nl> } <nl> <nl> void CGUIControl : : DynamicResourceAlloc ( bool bOnOff ) <nl> void CGUIControl : : Process ( unsigned int currentTime , CDirtyRegionList & dirtyregio <nl> { <nl> / / update our render region <nl> m_renderRegion = g_graphicsContext . generateAABB ( CalcRenderRegion ( ) ) ; <nl> - m_hasProcessed = true ; <nl> } <nl> <nl> / / the main render routine . <nl> void CGUIControl : : DoRender ( ) <nl> <nl> void CGUIControl : : Render ( ) <nl> { <nl> + m_hasRendered = true ; <nl> } <nl> <nl> bool CGUIControl : : OnAction ( const CAction & action ) <nl> void CGUIControl : : ResetAnimations ( ) <nl> bool CGUIControl : : CheckAnimation ( ANIMATION_TYPE animType ) <nl> { <nl> / / rule out the animations we shouldn ' t perform <nl> - if ( ! IsVisible ( ) | | ! HasProcessed ( ) ) <nl> - { / / hidden or never processed - don ' t allow exit or entry animations for this control <nl> + if ( ! IsVisible ( ) | | ! HasRendered ( ) ) <nl> + { / / hidden or never rendered - don ' t allow exit or entry animations for this control <nl> if ( animType = = ANIM_TYPE_WINDOW_CLOSE ) <nl> { / / could be animating a ( delayed ) window open anim , so reset it <nl> ResetAnimation ( ANIM_TYPE_WINDOW_OPEN ) ; <nl> bool CGUIControl : : Animate ( unsigned int currentTime ) <nl> for ( unsigned int i = 0 ; i < m_animations . size ( ) ; i + + ) <nl> { <nl> CAnimation & anim = m_animations [ i ] ; <nl> - anim . Animate ( currentTime , HasProcessed ( ) | | visible = = DELAYED ) ; <nl> + anim . Animate ( currentTime , HasRendered ( ) | | visible = = DELAYED ) ; <nl> / / Update the control states ( such as visibility ) <nl> UpdateStates ( anim . GetType ( ) , anim . GetProcess ( ) , anim . GetState ( ) ) ; <nl> / / and render the animation effect <nl>
revert part of 60b0ee01a47a134a002594ab746b2e52efb0d2b7 that somehow snuck in
xbmc/xbmc
ed808027fa5031be94ebb11609b456649a769bda
2013-01-08T03:41:43Z
mmm a / modules / imgproc / src / imgwarp . cpp <nl> ppp b / modules / imgproc / src / imgwarp . cpp <nl> resizeNN ( const Mat & src , Mat & dst , double fx , double fy ) <nl> <nl> for ( x = 0 ; x < dsize . width ; x + + ) <nl> { <nl> - int sx = saturate_cast < int > ( x * ifx ) ; <nl> + int sx = cvFloor ( x * ifx ) ; <nl> x_ofs [ x ] = std : : min ( sx , ssize . width - 1 ) * pix_size ; <nl> } <nl> <nl> for ( y = 0 ; y < dsize . height ; y + + ) <nl> { <nl> uchar * D = dst . data + dst . step * y ; <nl> - int sy = std : : min ( saturate_cast < int > ( y * ify ) , ssize . height - 1 ) ; <nl> + int sy = std : : min ( cvFloor ( y * ify ) , ssize . height - 1 ) ; <nl> const uchar * S = src . data + src . step * sy ; <nl> <nl> switch ( pix_size ) <nl>
fixed incorrect output of resize ( . . . scalex , scaley , INTER_NEAREST ) when scalex and scaley are even integers ( ticket )
opencv/opencv
6be2a79fb9047eff85a9317022a1edd24cc2bb7c
2011-06-03T13:25:44Z
mmm a / xbmc / Application . cpp <nl> ppp b / xbmc / Application . cpp <nl> void CApplication : : FrameMove ( bool processEvents , bool processGUI ) <nl> m_skipGuiRender = true ; <nl> # endif <nl> <nl> + if ( g_advancedSettings . m_guiSmartRedraw & & m_guiRefreshTimer . IsTimePast ( ) ) <nl> + { <nl> + g_windowManager . SendMessage ( GUI_MSG_REFRESH_TIMER , 0 , 0 ) ; <nl> + m_guiRefreshTimer . Set ( 500 ) ; <nl> + } <nl> + <nl> if ( ! m_bStop ) <nl> { <nl> if ( ! m_skipGuiRender ) <nl> void CApplication : : ProcessSlow ( ) <nl> <nl> m_ServiceManager - > GetActiveAE ( ) . GarbageCollect ( ) ; <nl> <nl> - g_windowManager . SendMessage ( GUI_MSG_REFRESH_TIMER , 0 , 0 ) ; <nl> - <nl> / / if we don ' t render the gui there ' s no reason to start the screensaver . <nl> / / that way the screensaver won ' t kick in if we maximize the XBMC window <nl> / / after the screensaver start time . <nl> mmm a / xbmc / Application . h <nl> ppp b / xbmc / Application . h <nl> namespace PLAYLIST <nl> # include " utils / Stopwatch . h " <nl> # include " windowing / OSScreenSaver . h " <nl> # include " windowing / XBMC_events . h " <nl> + # include " threads / SystemClock . h " <nl> # include " threads / Thread . h " <nl> <nl> # include " ApplicationPlayer . h " <nl> class CApplication : public CXBApplicationEx , public IPlayerCallback , public IMs <nl> CStopWatch m_navigationTimer ; <nl> CStopWatch m_slowTimer ; <nl> CStopWatch m_shutdownTimer ; <nl> + XbmcThreads : : EndTime m_guiRefreshTimer ; <nl> <nl> bool m_bInhibitIdleShutdown ; <nl> <nl>
move gui refresh from ProcessSlow to FrameMove
xbmc/xbmc
c872856080e4c4e9a4c014dadad7e9f573d9b9cf
2018-01-22T13:35:24Z
mmm a / BUILD . gn <nl> ppp b / BUILD . gn <nl> source_set ( " v8_base " ) { <nl> " src / rewriter . h " , <nl> " src / runtime - profiler . cc " , <nl> " src / runtime - profiler . h " , <nl> + " src / runtime / runtime - api . cc " , <nl> + " src / runtime / runtime - array . cc " , <nl> " src / runtime / runtime - classes . cc " , <nl> " src / runtime / runtime - collections . cc " , <nl> " src / runtime / runtime - compiler . cc " , <nl> - " src / runtime / runtime - i18n . cc " , <nl> " src / runtime / runtime - date . cc " , <nl> " src / runtime / runtime - debug . cc " , <nl> " src / runtime / runtime - function . cc " , <nl> " src / runtime / runtime - generator . cc " , <nl> + " src / runtime / runtime - i18n . cc " , <nl> + " src / runtime / runtime - internal . cc " , <nl> " src / runtime / runtime - json . cc " , <nl> " src / runtime / runtime - literals . cc " , <nl> " src / runtime / runtime - liveedit . cc " , <nl> " src / runtime / runtime - maths . cc " , <nl> " src / runtime / runtime - numbers . cc " , <nl> + " src / runtime / runtime - object . cc " , <nl> " src / runtime / runtime - observe . cc " , <nl> " src / runtime / runtime - proxy . cc " , <nl> " src / runtime / runtime - regexp . cc " , <nl> mmm a / src / macros . py <nl> ppp b / src / macros . py <nl> <nl> macro OVERRIDE_CAPTURE ( override , index ) = ( ( override ) [ ( index ) ] ) ; <nl> <nl> # PropertyDescriptor return value indices - must match <nl> - # PropertyDescriptorIndices in runtime . cc . <nl> + # PropertyDescriptorIndices in runtime - object . cc . <nl> const IS_ACCESSOR_INDEX = 0 ; <nl> const VALUE_INDEX = 1 ; <nl> const GETTER_INDEX = 2 ; <nl> new file mode 100644 <nl> index 00000000000 . . 740832e9c97 <nl> mmm / dev / null <nl> ppp b / src / runtime / runtime - api . 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 " src / v8 . h " <nl> + <nl> + # include " src / arguments . h " <nl> + # include " src / bootstrapper . h " <nl> + # include " src / runtime / runtime . h " <nl> + # include " src / runtime / runtime - utils . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_CreateApiFunction ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( FunctionTemplateInfo , data , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , prototype , 1 ) ; <nl> + return * isolate - > factory ( ) - > CreateApiFunction ( data , prototype ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_IsTemplate ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , arg , 0 ) ; <nl> + bool result = arg - > IsObjectTemplateInfo ( ) | | arg - > IsFunctionTemplateInfo ( ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( result ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_GetTemplateField ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_CHECKED ( HeapObject , templ , 0 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( index , 1 ) ; <nl> + int offset = index * kPointerSize + HeapObject : : kHeaderSize ; <nl> + InstanceType type = templ - > map ( ) - > instance_type ( ) ; <nl> + RUNTIME_ASSERT ( type = = FUNCTION_TEMPLATE_INFO_TYPE | | <nl> + type = = OBJECT_TEMPLATE_INFO_TYPE ) ; <nl> + RUNTIME_ASSERT ( offset > 0 ) ; <nl> + if ( type = = FUNCTION_TEMPLATE_INFO_TYPE ) { <nl> + RUNTIME_ASSERT ( offset < FunctionTemplateInfo : : kSize ) ; <nl> + } else { <nl> + RUNTIME_ASSERT ( offset < ObjectTemplateInfo : : kSize ) ; <nl> + } <nl> + return * HeapObject : : RawField ( templ , offset ) ; <nl> + } <nl> + <nl> + <nl> + / / Transform getter or setter into something DefineAccessor can handle . <nl> + static Handle < Object > InstantiateAccessorComponent ( Isolate * isolate , <nl> + Handle < Object > component ) { <nl> + if ( component - > IsUndefined ( ) ) return isolate - > factory ( ) - > undefined_value ( ) ; <nl> + Handle < FunctionTemplateInfo > info = <nl> + Handle < FunctionTemplateInfo > : : cast ( component ) ; <nl> + return Utils : : OpenHandle ( * Utils : : ToLocal ( info ) - > GetFunction ( ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_DefineApiAccessorProperty ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 5 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , name , 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , getter , 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , setter , 3 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( attribute , 4 ) ; <nl> + RUNTIME_ASSERT ( getter - > IsUndefined ( ) | | getter - > IsFunctionTemplateInfo ( ) ) ; <nl> + RUNTIME_ASSERT ( setter - > IsUndefined ( ) | | setter - > IsFunctionTemplateInfo ( ) ) ; <nl> + RUNTIME_ASSERT ( PropertyDetails : : AttributesField : : is_valid ( <nl> + static_cast < PropertyAttributes > ( attribute ) ) ) ; <nl> + RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , JSObject : : DefineAccessor ( <nl> + object , name , InstantiateAccessorComponent ( isolate , getter ) , <nl> + InstantiateAccessorComponent ( isolate , setter ) , <nl> + static_cast < PropertyAttributes > ( attribute ) ) ) ; <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_AddPropertyForTemplate ) { <nl> + HandleScope scope ( isolate ) ; <nl> + RUNTIME_ASSERT ( args . length ( ) = = 4 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , key , 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( unchecked_attributes , 3 ) ; <nl> + RUNTIME_ASSERT ( <nl> + ( unchecked_attributes & ~ ( READ_ONLY | DONT_ENUM | DONT_DELETE ) ) = = 0 ) ; <nl> + / / Compute attributes . <nl> + PropertyAttributes attributes = <nl> + static_cast < PropertyAttributes > ( unchecked_attributes ) ; <nl> + <nl> + # ifdef DEBUG <nl> + bool duplicate ; <nl> + if ( key - > IsName ( ) ) { <nl> + LookupIterator it ( object , Handle < Name > : : cast ( key ) , <nl> + LookupIterator : : OWN_SKIP_INTERCEPTOR ) ; <nl> + Maybe < PropertyAttributes > maybe = JSReceiver : : GetPropertyAttributes ( & it ) ; <nl> + DCHECK ( maybe . has_value ) ; <nl> + duplicate = it . IsFound ( ) ; <nl> + } else { <nl> + uint32_t index = 0 ; <nl> + RUNTIME_ASSERT ( key - > ToArrayIndex ( & index ) ) ; <nl> + Maybe < bool > maybe = JSReceiver : : HasOwnElement ( object , index ) ; <nl> + if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> + duplicate = maybe . value ; <nl> + } <nl> + if ( duplicate ) { <nl> + Handle < Object > args [ 1 ] = { key } ; <nl> + THROW_NEW_ERROR_RETURN_FAILURE ( <nl> + isolate , <nl> + NewTypeError ( " duplicate_template_property " , HandleVector ( args , 1 ) ) ) ; <nl> + } <nl> + # endif <nl> + <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , <nl> + Runtime : : DefineObjectProperty ( object , key , value , attributes ) ) ; <nl> + return * result ; <nl> + } <nl> + } <nl> + } / / namespace v8 : : internal <nl> new file mode 100644 <nl> index 00000000000 . . 939898edfa3 <nl> mmm / dev / null <nl> ppp b / src / runtime / runtime - array . 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 " src / v8 . h " <nl> + <nl> + # include " src / arguments . h " <nl> + # include " src / runtime / runtime . h " <nl> + # include " src / runtime / runtime - utils . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_FinishArrayPrototypeSetup ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSArray , prototype , 0 ) ; <nl> + Object * length = prototype - > length ( ) ; <nl> + RUNTIME_ASSERT ( length - > IsSmi ( ) & & Smi : : cast ( length ) - > value ( ) = = 0 ) ; <nl> + RUNTIME_ASSERT ( prototype - > HasFastSmiOrObjectElements ( ) ) ; <nl> + / / This is necessary to enable fast checks for absence of elements <nl> + / / on Array . prototype and below . <nl> + prototype - > set_elements ( isolate - > heap ( ) - > empty_fixed_array ( ) ) ; <nl> + return Smi : : FromInt ( 0 ) ; <nl> + } <nl> + <nl> + <nl> + static void InstallBuiltin ( Isolate * isolate , Handle < JSObject > holder , <nl> + const char * name , Builtins : : Name builtin_name ) { <nl> + Handle < String > key = isolate - > factory ( ) - > InternalizeUtf8String ( name ) ; <nl> + Handle < Code > code ( isolate - > builtins ( ) - > builtin ( builtin_name ) ) ; <nl> + Handle < JSFunction > optimized = <nl> + isolate - > factory ( ) - > NewFunctionWithoutPrototype ( key , code ) ; <nl> + optimized - > shared ( ) - > DontAdaptArguments ( ) ; <nl> + JSObject : : AddProperty ( holder , key , optimized , NONE ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_SpecialArrayFunctions ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 0 ) ; <nl> + Handle < JSObject > holder = <nl> + isolate - > factory ( ) - > NewJSObject ( isolate - > object_function ( ) ) ; <nl> + <nl> + InstallBuiltin ( isolate , holder , " pop " , Builtins : : kArrayPop ) ; <nl> + InstallBuiltin ( isolate , holder , " push " , Builtins : : kArrayPush ) ; <nl> + InstallBuiltin ( isolate , holder , " shift " , Builtins : : kArrayShift ) ; <nl> + InstallBuiltin ( isolate , holder , " unshift " , Builtins : : kArrayUnshift ) ; <nl> + InstallBuiltin ( isolate , holder , " slice " , Builtins : : kArraySlice ) ; <nl> + InstallBuiltin ( isolate , holder , " splice " , Builtins : : kArraySplice ) ; <nl> + InstallBuiltin ( isolate , holder , " concat " , Builtins : : kArrayConcat ) ; <nl> + <nl> + return * holder ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_TransitionElementsKind ) { <nl> + HandleScope scope ( isolate ) ; <nl> + RUNTIME_ASSERT ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSArray , array , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Map , map , 1 ) ; <nl> + JSObject : : TransitionElementsKind ( array , map - > elements_kind ( ) ) ; <nl> + return * array ; <nl> + } <nl> + <nl> + <nl> + / / Push an object unto an array of objects if it is not already in the <nl> + / / array . Returns true if the element was pushed on the stack and <nl> + / / false otherwise . <nl> + RUNTIME_FUNCTION ( Runtime_PushIfAbsent ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSArray , array , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , element , 1 ) ; <nl> + RUNTIME_ASSERT ( array - > HasFastSmiOrObjectElements ( ) ) ; <nl> + int length = Smi : : cast ( array - > length ( ) ) - > value ( ) ; <nl> + FixedArray * elements = FixedArray : : cast ( array - > elements ( ) ) ; <nl> + for ( int i = 0 ; i < length ; i + + ) { <nl> + if ( elements - > get ( i ) = = * element ) return isolate - > heap ( ) - > false_value ( ) ; <nl> + } <nl> + <nl> + / / Strict not needed . Used for cycle detection in Array join implementation . <nl> + RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , JSObject : : SetFastElement ( array , length , element , SLOPPY , true ) ) ; <nl> + return isolate - > heap ( ) - > true_value ( ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * A simple visitor visits every element of Array ' s . <nl> + * The backend storage can be a fixed array for fast elements case , <nl> + * or a dictionary for sparse array . Since Dictionary is a subtype <nl> + * of FixedArray , the class can be used by both fast and slow cases . <nl> + * The second parameter of the constructor , fast_elements , specifies <nl> + * whether the storage is a FixedArray or Dictionary . <nl> + * <nl> + * An index limit is used to deal with the situation that a result array <nl> + * length overflows 32 - bit non - negative integer . <nl> + * / <nl> + class ArrayConcatVisitor { <nl> + public : <nl> + ArrayConcatVisitor ( Isolate * isolate , Handle < FixedArray > storage , <nl> + bool fast_elements ) <nl> + : isolate_ ( isolate ) , <nl> + storage_ ( Handle < FixedArray > : : cast ( <nl> + isolate - > global_handles ( ) - > Create ( * storage ) ) ) , <nl> + index_offset_ ( 0u ) , <nl> + fast_elements_ ( fast_elements ) , <nl> + exceeds_array_limit_ ( false ) { } <nl> + <nl> + ~ ArrayConcatVisitor ( ) { clear_storage ( ) ; } <nl> + <nl> + void visit ( uint32_t i , Handle < Object > elm ) { <nl> + if ( i > JSObject : : kMaxElementCount - index_offset_ ) { <nl> + exceeds_array_limit_ = true ; <nl> + return ; <nl> + } <nl> + uint32_t index = index_offset_ + i ; <nl> + <nl> + if ( fast_elements_ ) { <nl> + if ( index < static_cast < uint32_t > ( storage_ - > length ( ) ) ) { <nl> + storage_ - > set ( index , * elm ) ; <nl> + return ; <nl> + } <nl> + / / Our initial estimate of length was foiled , possibly by <nl> + / / getters on the arrays increasing the length of later arrays <nl> + / / during iteration . <nl> + / / This shouldn ' t happen in anything but pathological cases . <nl> + SetDictionaryMode ( ) ; <nl> + / / Fall - through to dictionary mode . <nl> + } <nl> + DCHECK ( ! fast_elements_ ) ; <nl> + Handle < SeededNumberDictionary > dict ( <nl> + SeededNumberDictionary : : cast ( * storage_ ) ) ; <nl> + Handle < SeededNumberDictionary > result = <nl> + SeededNumberDictionary : : AtNumberPut ( dict , index , elm ) ; <nl> + if ( ! result . is_identical_to ( dict ) ) { <nl> + / / Dictionary needed to grow . <nl> + clear_storage ( ) ; <nl> + set_storage ( * result ) ; <nl> + } <nl> + } <nl> + <nl> + void increase_index_offset ( uint32_t delta ) { <nl> + if ( JSObject : : kMaxElementCount - index_offset_ < delta ) { <nl> + index_offset_ = JSObject : : kMaxElementCount ; <nl> + } else { <nl> + index_offset_ + = delta ; <nl> + } <nl> + / / If the initial length estimate was off ( see special case in visit ( ) ) , <nl> + / / but the array blowing the limit didn ' t contain elements beyond the <nl> + / / provided - for index range , go to dictionary mode now . <nl> + if ( fast_elements_ & & <nl> + index_offset_ > <nl> + static_cast < uint32_t > ( FixedArrayBase : : cast ( * storage_ ) - > length ( ) ) ) { <nl> + SetDictionaryMode ( ) ; <nl> + } <nl> + } <nl> + <nl> + bool exceeds_array_limit ( ) { return exceeds_array_limit_ ; } <nl> + <nl> + Handle < JSArray > ToArray ( ) { <nl> + Handle < JSArray > array = isolate_ - > factory ( ) - > NewJSArray ( 0 ) ; <nl> + Handle < Object > length = <nl> + isolate_ - > factory ( ) - > NewNumber ( static_cast < double > ( index_offset_ ) ) ; <nl> + Handle < Map > map = JSObject : : GetElementsTransitionMap ( <nl> + array , fast_elements_ ? FAST_HOLEY_ELEMENTS : DICTIONARY_ELEMENTS ) ; <nl> + array - > set_map ( * map ) ; <nl> + array - > set_length ( * length ) ; <nl> + array - > set_elements ( * storage_ ) ; <nl> + return array ; <nl> + } <nl> + <nl> + private : <nl> + / / Convert storage to dictionary mode . <nl> + void SetDictionaryMode ( ) { <nl> + DCHECK ( fast_elements_ ) ; <nl> + Handle < FixedArray > current_storage ( * storage_ ) ; <nl> + Handle < SeededNumberDictionary > slow_storage ( <nl> + SeededNumberDictionary : : New ( isolate_ , current_storage - > length ( ) ) ) ; <nl> + uint32_t current_length = static_cast < uint32_t > ( current_storage - > length ( ) ) ; <nl> + for ( uint32_t i = 0 ; i < current_length ; i + + ) { <nl> + HandleScope loop_scope ( isolate_ ) ; <nl> + Handle < Object > element ( current_storage - > get ( i ) , isolate_ ) ; <nl> + if ( ! element - > IsTheHole ( ) ) { <nl> + Handle < SeededNumberDictionary > new_storage = <nl> + SeededNumberDictionary : : AtNumberPut ( slow_storage , i , element ) ; <nl> + if ( ! new_storage . is_identical_to ( slow_storage ) ) { <nl> + slow_storage = loop_scope . CloseAndEscape ( new_storage ) ; <nl> + } <nl> + } <nl> + } <nl> + clear_storage ( ) ; <nl> + set_storage ( * slow_storage ) ; <nl> + fast_elements_ = false ; <nl> + } <nl> + <nl> + inline void clear_storage ( ) { <nl> + GlobalHandles : : Destroy ( Handle < Object > : : cast ( storage_ ) . location ( ) ) ; <nl> + } <nl> + <nl> + inline void set_storage ( FixedArray * storage ) { <nl> + storage_ = <nl> + Handle < FixedArray > : : cast ( isolate_ - > global_handles ( ) - > Create ( storage ) ) ; <nl> + } <nl> + <nl> + Isolate * isolate_ ; <nl> + Handle < FixedArray > storage_ ; / / Always a global handle . <nl> + / / Index after last seen index . Always less than or equal to <nl> + / / JSObject : : kMaxElementCount . <nl> + uint32_t index_offset_ ; <nl> + bool fast_elements_ : 1 ; <nl> + bool exceeds_array_limit_ : 1 ; <nl> + } ; <nl> + <nl> + <nl> + static uint32_t EstimateElementCount ( Handle < JSArray > array ) { <nl> + uint32_t length = static_cast < uint32_t > ( array - > length ( ) - > Number ( ) ) ; <nl> + int element_count = 0 ; <nl> + switch ( array - > GetElementsKind ( ) ) { <nl> + case FAST_SMI_ELEMENTS : <nl> + case FAST_HOLEY_SMI_ELEMENTS : <nl> + case FAST_ELEMENTS : <nl> + case FAST_HOLEY_ELEMENTS : { <nl> + / / Fast elements can ' t have lengths that are not representable by <nl> + / / a 32 - bit signed integer . <nl> + DCHECK ( static_cast < int32_t > ( FixedArray : : kMaxLength ) > = 0 ) ; <nl> + int fast_length = static_cast < int > ( length ) ; <nl> + Handle < FixedArray > elements ( FixedArray : : cast ( array - > elements ( ) ) ) ; <nl> + for ( int i = 0 ; i < fast_length ; i + + ) { <nl> + if ( ! elements - > get ( i ) - > IsTheHole ( ) ) element_count + + ; <nl> + } <nl> + break ; <nl> + } <nl> + case FAST_DOUBLE_ELEMENTS : <nl> + case FAST_HOLEY_DOUBLE_ELEMENTS : { <nl> + / / Fast elements can ' t have lengths that are not representable by <nl> + / / a 32 - bit signed integer . <nl> + DCHECK ( static_cast < int32_t > ( FixedDoubleArray : : kMaxLength ) > = 0 ) ; <nl> + int fast_length = static_cast < int > ( length ) ; <nl> + if ( array - > elements ( ) - > IsFixedArray ( ) ) { <nl> + DCHECK ( FixedArray : : cast ( array - > elements ( ) ) - > length ( ) = = 0 ) ; <nl> + break ; <nl> + } <nl> + Handle < FixedDoubleArray > elements ( <nl> + FixedDoubleArray : : cast ( array - > elements ( ) ) ) ; <nl> + for ( int i = 0 ; i < fast_length ; i + + ) { <nl> + if ( ! elements - > is_the_hole ( i ) ) element_count + + ; <nl> + } <nl> + break ; <nl> + } <nl> + case DICTIONARY_ELEMENTS : { <nl> + Handle < SeededNumberDictionary > dictionary ( <nl> + SeededNumberDictionary : : cast ( array - > elements ( ) ) ) ; <nl> + int capacity = dictionary - > Capacity ( ) ; <nl> + for ( int i = 0 ; i < capacity ; i + + ) { <nl> + Handle < Object > key ( dictionary - > KeyAt ( i ) , array - > GetIsolate ( ) ) ; <nl> + if ( dictionary - > IsKey ( * key ) ) { <nl> + element_count + + ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case SLOPPY_ARGUMENTS_ELEMENTS : <nl> + # define TYPED_ARRAY_CASE ( Type , type , TYPE , ctype , size ) \ <nl> + case EXTERNAL_ # # TYPE # # _ELEMENTS : \ <nl> + case TYPE # # _ELEMENTS : <nl> + <nl> + TYPED_ARRAYS ( TYPED_ARRAY_CASE ) <nl> + # undef TYPED_ARRAY_CASE <nl> + / / External arrays are always dense . <nl> + return length ; <nl> + } <nl> + / / As an estimate , we assume that the prototype doesn ' t contain any <nl> + / / inherited elements . <nl> + return element_count ; <nl> + } <nl> + <nl> + <nl> + template < class ExternalArrayClass , class ElementType > <nl> + static void IterateExternalArrayElements ( Isolate * isolate , <nl> + Handle < JSObject > receiver , <nl> + bool elements_are_ints , <nl> + bool elements_are_guaranteed_smis , <nl> + ArrayConcatVisitor * visitor ) { <nl> + Handle < ExternalArrayClass > array ( <nl> + ExternalArrayClass : : cast ( receiver - > elements ( ) ) ) ; <nl> + uint32_t len = static_cast < uint32_t > ( array - > length ( ) ) ; <nl> + <nl> + DCHECK ( visitor ! = NULL ) ; <nl> + if ( elements_are_ints ) { <nl> + if ( elements_are_guaranteed_smis ) { <nl> + for ( uint32_t j = 0 ; j < len ; j + + ) { <nl> + HandleScope loop_scope ( isolate ) ; <nl> + Handle < Smi > e ( Smi : : FromInt ( static_cast < int > ( array - > get_scalar ( j ) ) ) , <nl> + isolate ) ; <nl> + visitor - > visit ( j , e ) ; <nl> + } <nl> + } else { <nl> + for ( uint32_t j = 0 ; j < len ; j + + ) { <nl> + HandleScope loop_scope ( isolate ) ; <nl> + int64_t val = static_cast < int64_t > ( array - > get_scalar ( j ) ) ; <nl> + if ( Smi : : IsValid ( static_cast < intptr_t > ( val ) ) ) { <nl> + Handle < Smi > e ( Smi : : FromInt ( static_cast < int > ( val ) ) , isolate ) ; <nl> + visitor - > visit ( j , e ) ; <nl> + } else { <nl> + Handle < Object > e = <nl> + isolate - > factory ( ) - > NewNumber ( static_cast < ElementType > ( val ) ) ; <nl> + visitor - > visit ( j , e ) ; <nl> + } <nl> + } <nl> + } <nl> + } else { <nl> + for ( uint32_t j = 0 ; j < len ; j + + ) { <nl> + HandleScope loop_scope ( isolate ) ; <nl> + Handle < Object > e = isolate - > factory ( ) - > NewNumber ( array - > get_scalar ( j ) ) ; <nl> + visitor - > visit ( j , e ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + <nl> + / / Used for sorting indices in a List < uint32_t > . <nl> + static int compareUInt32 ( const uint32_t * ap , const uint32_t * bp ) { <nl> + uint32_t a = * ap ; <nl> + uint32_t b = * bp ; <nl> + return ( a = = b ) ? 0 : ( a < b ) ? - 1 : 1 ; <nl> + } <nl> + <nl> + <nl> + static void CollectElementIndices ( Handle < JSObject > object , uint32_t range , <nl> + List < uint32_t > * indices ) { <nl> + Isolate * isolate = object - > GetIsolate ( ) ; <nl> + ElementsKind kind = object - > GetElementsKind ( ) ; <nl> + switch ( kind ) { <nl> + case FAST_SMI_ELEMENTS : <nl> + case FAST_ELEMENTS : <nl> + case FAST_HOLEY_SMI_ELEMENTS : <nl> + case FAST_HOLEY_ELEMENTS : { <nl> + Handle < FixedArray > elements ( FixedArray : : cast ( object - > elements ( ) ) ) ; <nl> + uint32_t length = static_cast < uint32_t > ( elements - > length ( ) ) ; <nl> + if ( range < length ) length = range ; <nl> + for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> + if ( ! elements - > get ( i ) - > IsTheHole ( ) ) { <nl> + indices - > Add ( i ) ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case FAST_HOLEY_DOUBLE_ELEMENTS : <nl> + case FAST_DOUBLE_ELEMENTS : { <nl> + if ( object - > elements ( ) - > IsFixedArray ( ) ) { <nl> + DCHECK ( object - > elements ( ) - > length ( ) = = 0 ) ; <nl> + break ; <nl> + } <nl> + Handle < FixedDoubleArray > elements ( <nl> + FixedDoubleArray : : cast ( object - > elements ( ) ) ) ; <nl> + uint32_t length = static_cast < uint32_t > ( elements - > length ( ) ) ; <nl> + if ( range < length ) length = range ; <nl> + for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> + if ( ! elements - > is_the_hole ( i ) ) { <nl> + indices - > Add ( i ) ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case DICTIONARY_ELEMENTS : { <nl> + Handle < SeededNumberDictionary > dict ( <nl> + SeededNumberDictionary : : cast ( object - > elements ( ) ) ) ; <nl> + uint32_t capacity = dict - > Capacity ( ) ; <nl> + for ( uint32_t j = 0 ; j < capacity ; j + + ) { <nl> + HandleScope loop_scope ( isolate ) ; <nl> + Handle < Object > k ( dict - > KeyAt ( j ) , isolate ) ; <nl> + if ( dict - > IsKey ( * k ) ) { <nl> + DCHECK ( k - > IsNumber ( ) ) ; <nl> + uint32_t index = static_cast < uint32_t > ( k - > Number ( ) ) ; <nl> + if ( index < range ) { <nl> + indices - > Add ( index ) ; <nl> + } <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + # define TYPED_ARRAY_CASE ( Type , type , TYPE , ctype , size ) \ <nl> + case TYPE # # _ELEMENTS : \ <nl> + case EXTERNAL_ # # TYPE # # _ELEMENTS : <nl> + <nl> + TYPED_ARRAYS ( TYPED_ARRAY_CASE ) <nl> + # undef TYPED_ARRAY_CASE <nl> + { <nl> + uint32_t length = static_cast < uint32_t > ( <nl> + FixedArrayBase : : cast ( object - > elements ( ) ) - > length ( ) ) ; <nl> + if ( range < = length ) { <nl> + length = range ; <nl> + / / We will add all indices , so we might as well clear it first <nl> + / / and avoid duplicates . <nl> + indices - > Clear ( ) ; <nl> + } <nl> + for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> + indices - > Add ( i ) ; <nl> + } <nl> + if ( length = = range ) return ; / / All indices accounted for already . <nl> + break ; <nl> + } <nl> + case SLOPPY_ARGUMENTS_ELEMENTS : { <nl> + MaybeHandle < Object > length_obj = <nl> + Object : : GetProperty ( object , isolate - > factory ( ) - > length_string ( ) ) ; <nl> + double length_num = length_obj . ToHandleChecked ( ) - > Number ( ) ; <nl> + uint32_t length = static_cast < uint32_t > ( DoubleToInt32 ( length_num ) ) ; <nl> + ElementsAccessor * accessor = object - > GetElementsAccessor ( ) ; <nl> + for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> + if ( accessor - > HasElement ( object , object , i ) ) { <nl> + indices - > Add ( i ) ; <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + } <nl> + <nl> + PrototypeIterator iter ( isolate , object ) ; <nl> + if ( ! iter . IsAtEnd ( ) ) { <nl> + / / The prototype will usually have no inherited element indices , <nl> + / / but we have to check . <nl> + CollectElementIndices ( <nl> + Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) , range , <nl> + indices ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * A helper function that visits elements of a JSArray in numerical <nl> + * order . <nl> + * <nl> + * The visitor argument called for each existing element in the array <nl> + * with the element index and the element ' s value . <nl> + * Afterwards it increments the base - index of the visitor by the array <nl> + * length . <nl> + * Returns false if any access threw an exception , otherwise true . <nl> + * / <nl> + static bool IterateElements ( Isolate * isolate , Handle < JSArray > receiver , <nl> + ArrayConcatVisitor * visitor ) { <nl> + uint32_t length = static_cast < uint32_t > ( receiver - > length ( ) - > Number ( ) ) ; <nl> + switch ( receiver - > GetElementsKind ( ) ) { <nl> + case FAST_SMI_ELEMENTS : <nl> + case FAST_ELEMENTS : <nl> + case FAST_HOLEY_SMI_ELEMENTS : <nl> + case FAST_HOLEY_ELEMENTS : { <nl> + / / Run through the elements FixedArray and use HasElement and GetElement <nl> + / / to check the prototype for missing elements . <nl> + Handle < FixedArray > elements ( FixedArray : : cast ( receiver - > elements ( ) ) ) ; <nl> + int fast_length = static_cast < int > ( length ) ; <nl> + DCHECK ( fast_length < = elements - > length ( ) ) ; <nl> + for ( int j = 0 ; j < fast_length ; j + + ) { <nl> + HandleScope loop_scope ( isolate ) ; <nl> + Handle < Object > element_value ( elements - > get ( j ) , isolate ) ; <nl> + if ( ! element_value - > IsTheHole ( ) ) { <nl> + visitor - > visit ( j , element_value ) ; <nl> + } else { <nl> + Maybe < bool > maybe = JSReceiver : : HasElement ( receiver , j ) ; <nl> + if ( ! maybe . has_value ) return false ; <nl> + if ( maybe . value ) { <nl> + / / Call GetElement on receiver , not its prototype , or getters won ' t <nl> + / / have the correct receiver . <nl> + ASSIGN_RETURN_ON_EXCEPTION_VALUE ( <nl> + isolate , element_value , <nl> + Object : : GetElement ( isolate , receiver , j ) , false ) ; <nl> + visitor - > visit ( j , element_value ) ; <nl> + } <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case FAST_HOLEY_DOUBLE_ELEMENTS : <nl> + case FAST_DOUBLE_ELEMENTS : { <nl> + / / Empty array is FixedArray but not FixedDoubleArray . <nl> + if ( length = = 0 ) break ; <nl> + / / Run through the elements FixedArray and use HasElement and GetElement <nl> + / / to check the prototype for missing elements . <nl> + if ( receiver - > elements ( ) - > IsFixedArray ( ) ) { <nl> + DCHECK ( receiver - > elements ( ) - > length ( ) = = 0 ) ; <nl> + break ; <nl> + } <nl> + Handle < FixedDoubleArray > elements ( <nl> + FixedDoubleArray : : cast ( receiver - > elements ( ) ) ) ; <nl> + int fast_length = static_cast < int > ( length ) ; <nl> + DCHECK ( fast_length < = elements - > length ( ) ) ; <nl> + for ( int j = 0 ; j < fast_length ; j + + ) { <nl> + HandleScope loop_scope ( isolate ) ; <nl> + if ( ! elements - > is_the_hole ( j ) ) { <nl> + double double_value = elements - > get_scalar ( j ) ; <nl> + Handle < Object > element_value = <nl> + isolate - > factory ( ) - > NewNumber ( double_value ) ; <nl> + visitor - > visit ( j , element_value ) ; <nl> + } else { <nl> + Maybe < bool > maybe = JSReceiver : : HasElement ( receiver , j ) ; <nl> + if ( ! maybe . has_value ) return false ; <nl> + if ( maybe . value ) { <nl> + / / Call GetElement on receiver , not its prototype , or getters won ' t <nl> + / / have the correct receiver . <nl> + Handle < Object > element_value ; <nl> + ASSIGN_RETURN_ON_EXCEPTION_VALUE ( <nl> + isolate , element_value , <nl> + Object : : GetElement ( isolate , receiver , j ) , false ) ; <nl> + visitor - > visit ( j , element_value ) ; <nl> + } <nl> + } <nl> + } <nl> + break ; <nl> + } <nl> + case DICTIONARY_ELEMENTS : { <nl> + Handle < SeededNumberDictionary > dict ( receiver - > element_dictionary ( ) ) ; <nl> + List < uint32_t > indices ( dict - > Capacity ( ) / 2 ) ; <nl> + / / Collect all indices in the object and the prototypes less <nl> + / / than length . This might introduce duplicates in the indices list . <nl> + CollectElementIndices ( receiver , length , & indices ) ; <nl> + indices . Sort ( & compareUInt32 ) ; <nl> + int j = 0 ; <nl> + int n = indices . length ( ) ; <nl> + while ( j < n ) { <nl> + HandleScope loop_scope ( isolate ) ; <nl> + uint32_t index = indices [ j ] ; <nl> + Handle < Object > element ; <nl> + ASSIGN_RETURN_ON_EXCEPTION_VALUE ( <nl> + isolate , element , Object : : GetElement ( isolate , receiver , index ) , <nl> + false ) ; <nl> + visitor - > visit ( index , element ) ; <nl> + / / Skip to next different index ( i . e . , omit duplicates ) . <nl> + do { <nl> + j + + ; <nl> + } while ( j < n & & indices [ j ] = = index ) ; <nl> + } <nl> + break ; <nl> + } <nl> + case EXTERNAL_UINT8_CLAMPED_ELEMENTS : { <nl> + Handle < ExternalUint8ClampedArray > pixels ( <nl> + ExternalUint8ClampedArray : : cast ( receiver - > elements ( ) ) ) ; <nl> + for ( uint32_t j = 0 ; j < length ; j + + ) { <nl> + Handle < Smi > e ( Smi : : FromInt ( pixels - > get_scalar ( j ) ) , isolate ) ; <nl> + visitor - > visit ( j , e ) ; <nl> + } <nl> + break ; <nl> + } <nl> + case EXTERNAL_INT8_ELEMENTS : { <nl> + IterateExternalArrayElements < ExternalInt8Array , int8_t > ( <nl> + isolate , receiver , true , true , visitor ) ; <nl> + break ; <nl> + } <nl> + case EXTERNAL_UINT8_ELEMENTS : { <nl> + IterateExternalArrayElements < ExternalUint8Array , uint8_t > ( <nl> + isolate , receiver , true , true , visitor ) ; <nl> + break ; <nl> + } <nl> + case EXTERNAL_INT16_ELEMENTS : { <nl> + IterateExternalArrayElements < ExternalInt16Array , int16_t > ( <nl> + isolate , receiver , true , true , visitor ) ; <nl> + break ; <nl> + } <nl> + case EXTERNAL_UINT16_ELEMENTS : { <nl> + IterateExternalArrayElements < ExternalUint16Array , uint16_t > ( <nl> + isolate , receiver , true , true , visitor ) ; <nl> + break ; <nl> + } <nl> + case EXTERNAL_INT32_ELEMENTS : { <nl> + IterateExternalArrayElements < ExternalInt32Array , int32_t > ( <nl> + isolate , receiver , true , false , visitor ) ; <nl> + break ; <nl> + } <nl> + case EXTERNAL_UINT32_ELEMENTS : { <nl> + IterateExternalArrayElements < ExternalUint32Array , uint32_t > ( <nl> + isolate , receiver , true , false , visitor ) ; <nl> + break ; <nl> + } <nl> + case EXTERNAL_FLOAT32_ELEMENTS : { <nl> + IterateExternalArrayElements < ExternalFloat32Array , float > ( <nl> + isolate , receiver , false , false , visitor ) ; <nl> + break ; <nl> + } <nl> + case EXTERNAL_FLOAT64_ELEMENTS : { <nl> + IterateExternalArrayElements < ExternalFloat64Array , double > ( <nl> + isolate , receiver , false , false , visitor ) ; <nl> + break ; <nl> + } <nl> + default : <nl> + UNREACHABLE ( ) ; <nl> + break ; <nl> + } <nl> + visitor - > increase_index_offset ( length ) ; <nl> + return true ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * Array : : concat implementation . <nl> + * See ECMAScript 262 , 15 . 4 . 4 . 4 . <nl> + * TODO ( 581 ) : Fix non - compliance for very large concatenations and update to <nl> + * following the ECMAScript 5 specification . <nl> + * / <nl> + RUNTIME_FUNCTION ( Runtime_ArrayConcat ) { <nl> + HandleScope handle_scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSArray , arguments , 0 ) ; <nl> + int argument_count = static_cast < int > ( arguments - > length ( ) - > Number ( ) ) ; <nl> + RUNTIME_ASSERT ( arguments - > HasFastObjectElements ( ) ) ; <nl> + Handle < FixedArray > elements ( FixedArray : : cast ( arguments - > elements ( ) ) ) ; <nl> + <nl> + / / Pass 1 : estimate the length and number of elements of the result . <nl> + / / The actual length can be larger if any of the arguments have getters <nl> + / / that mutate other arguments ( but will otherwise be precise ) . <nl> + / / The number of elements is precise if there are no inherited elements . <nl> + <nl> + ElementsKind kind = FAST_SMI_ELEMENTS ; <nl> + <nl> + uint32_t estimate_result_length = 0 ; <nl> + uint32_t estimate_nof_elements = 0 ; <nl> + for ( int i = 0 ; i < argument_count ; i + + ) { <nl> + HandleScope loop_scope ( isolate ) ; <nl> + Handle < Object > obj ( elements - > get ( i ) , isolate ) ; <nl> + uint32_t length_estimate ; <nl> + uint32_t element_estimate ; <nl> + if ( obj - > IsJSArray ( ) ) { <nl> + Handle < JSArray > array ( Handle < JSArray > : : cast ( obj ) ) ; <nl> + length_estimate = static_cast < uint32_t > ( array - > length ( ) - > Number ( ) ) ; <nl> + if ( length_estimate ! = 0 ) { <nl> + ElementsKind array_kind = <nl> + GetPackedElementsKind ( array - > map ( ) - > elements_kind ( ) ) ; <nl> + if ( IsMoreGeneralElementsKindTransition ( kind , array_kind ) ) { <nl> + kind = array_kind ; <nl> + } <nl> + } <nl> + element_estimate = EstimateElementCount ( array ) ; <nl> + } else { <nl> + if ( obj - > IsHeapObject ( ) ) { <nl> + if ( obj - > IsNumber ( ) ) { <nl> + if ( IsMoreGeneralElementsKindTransition ( kind , FAST_DOUBLE_ELEMENTS ) ) { <nl> + kind = FAST_DOUBLE_ELEMENTS ; <nl> + } <nl> + } else if ( IsMoreGeneralElementsKindTransition ( kind , FAST_ELEMENTS ) ) { <nl> + kind = FAST_ELEMENTS ; <nl> + } <nl> + } <nl> + length_estimate = 1 ; <nl> + element_estimate = 1 ; <nl> + } <nl> + / / Avoid overflows by capping at kMaxElementCount . <nl> + if ( JSObject : : kMaxElementCount - estimate_result_length < length_estimate ) { <nl> + estimate_result_length = JSObject : : kMaxElementCount ; <nl> + } else { <nl> + estimate_result_length + = length_estimate ; <nl> + } <nl> + if ( JSObject : : kMaxElementCount - estimate_nof_elements < element_estimate ) { <nl> + estimate_nof_elements = JSObject : : kMaxElementCount ; <nl> + } else { <nl> + estimate_nof_elements + = element_estimate ; <nl> + } <nl> + } <nl> + <nl> + / / If estimated number of elements is more than half of length , a <nl> + / / fixed array ( fast case ) is more time and space - efficient than a <nl> + / / dictionary . <nl> + bool fast_case = ( estimate_nof_elements * 2 ) > = estimate_result_length ; <nl> + <nl> + if ( fast_case & & kind = = FAST_DOUBLE_ELEMENTS ) { <nl> + Handle < FixedArrayBase > storage = <nl> + isolate - > factory ( ) - > NewFixedDoubleArray ( estimate_result_length ) ; <nl> + int j = 0 ; <nl> + bool failure = false ; <nl> + if ( estimate_result_length > 0 ) { <nl> + Handle < FixedDoubleArray > double_storage = <nl> + Handle < FixedDoubleArray > : : cast ( storage ) ; <nl> + for ( int i = 0 ; i < argument_count ; i + + ) { <nl> + Handle < Object > obj ( elements - > get ( i ) , isolate ) ; <nl> + if ( obj - > IsSmi ( ) ) { <nl> + double_storage - > set ( j , Smi : : cast ( * obj ) - > value ( ) ) ; <nl> + j + + ; <nl> + } else if ( obj - > IsNumber ( ) ) { <nl> + double_storage - > set ( j , obj - > Number ( ) ) ; <nl> + j + + ; <nl> + } else { <nl> + JSArray * array = JSArray : : cast ( * obj ) ; <nl> + uint32_t length = static_cast < uint32_t > ( array - > length ( ) - > Number ( ) ) ; <nl> + switch ( array - > map ( ) - > elements_kind ( ) ) { <nl> + case FAST_HOLEY_DOUBLE_ELEMENTS : <nl> + case FAST_DOUBLE_ELEMENTS : { <nl> + / / Empty array is FixedArray but not FixedDoubleArray . <nl> + if ( length = = 0 ) break ; <nl> + FixedDoubleArray * elements = <nl> + FixedDoubleArray : : cast ( array - > elements ( ) ) ; <nl> + for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> + if ( elements - > is_the_hole ( i ) ) { <nl> + / / TODO ( jkummerow / verwaest ) : We could be a bit more clever <nl> + / / here : Check if there are no elements / getters on the <nl> + / / prototype chain , and if so , allow creation of a holey <nl> + / / result array . <nl> + / / Same thing below ( holey smi case ) . <nl> + failure = true ; <nl> + break ; <nl> + } <nl> + double double_value = elements - > get_scalar ( i ) ; <nl> + double_storage - > set ( j , double_value ) ; <nl> + j + + ; <nl> + } <nl> + break ; <nl> + } <nl> + case FAST_HOLEY_SMI_ELEMENTS : <nl> + case FAST_SMI_ELEMENTS : { <nl> + FixedArray * elements ( FixedArray : : cast ( array - > elements ( ) ) ) ; <nl> + for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> + Object * element = elements - > get ( i ) ; <nl> + if ( element - > IsTheHole ( ) ) { <nl> + failure = true ; <nl> + break ; <nl> + } <nl> + int32_t int_value = Smi : : cast ( element ) - > value ( ) ; <nl> + double_storage - > set ( j , int_value ) ; <nl> + j + + ; <nl> + } <nl> + break ; <nl> + } <nl> + case FAST_HOLEY_ELEMENTS : <nl> + case FAST_ELEMENTS : <nl> + DCHECK_EQ ( 0 , length ) ; <nl> + break ; <nl> + default : <nl> + UNREACHABLE ( ) ; <nl> + } <nl> + } <nl> + if ( failure ) break ; <nl> + } <nl> + } <nl> + if ( ! failure ) { <nl> + Handle < JSArray > array = isolate - > factory ( ) - > NewJSArray ( 0 ) ; <nl> + Smi * length = Smi : : FromInt ( j ) ; <nl> + Handle < Map > map ; <nl> + map = JSObject : : GetElementsTransitionMap ( array , kind ) ; <nl> + array - > set_map ( * map ) ; <nl> + array - > set_length ( length ) ; <nl> + array - > set_elements ( * storage ) ; <nl> + return * array ; <nl> + } <nl> + / / In case of failure , fall through . <nl> + } <nl> + <nl> + Handle < FixedArray > storage ; <nl> + if ( fast_case ) { <nl> + / / The backing storage array must have non - existing elements to preserve <nl> + / / holes across concat operations . <nl> + storage = <nl> + isolate - > factory ( ) - > NewFixedArrayWithHoles ( estimate_result_length ) ; <nl> + } else { <nl> + / / TODO ( 126 ) : move 25 % pre - allocation logic into Dictionary : : Allocate <nl> + uint32_t at_least_space_for = <nl> + estimate_nof_elements + ( estimate_nof_elements > > 2 ) ; <nl> + storage = Handle < FixedArray > : : cast ( <nl> + SeededNumberDictionary : : New ( isolate , at_least_space_for ) ) ; <nl> + } <nl> + <nl> + ArrayConcatVisitor visitor ( isolate , storage , fast_case ) ; <nl> + <nl> + for ( int i = 0 ; i < argument_count ; i + + ) { <nl> + Handle < Object > obj ( elements - > get ( i ) , isolate ) ; <nl> + if ( obj - > IsJSArray ( ) ) { <nl> + Handle < JSArray > array = Handle < JSArray > : : cast ( obj ) ; <nl> + if ( ! IterateElements ( isolate , array , & visitor ) ) { <nl> + return isolate - > heap ( ) - > exception ( ) ; <nl> + } <nl> + } else { <nl> + visitor . visit ( 0 , obj ) ; <nl> + visitor . increase_index_offset ( 1 ) ; <nl> + } <nl> + } <nl> + <nl> + if ( visitor . exceeds_array_limit ( ) ) { <nl> + THROW_NEW_ERROR_RETURN_FAILURE ( <nl> + isolate , <nl> + NewRangeError ( " invalid_array_length " , HandleVector < Object > ( NULL , 0 ) ) ) ; <nl> + } <nl> + return * visitor . ToArray ( ) ; <nl> + } <nl> + <nl> + <nl> + / / Moves all own elements of an object , that are below a limit , to positions <nl> + / / starting at zero . All undefined values are placed after non - undefined values , <nl> + / / and are followed by non - existing element . Does not change the length <nl> + / / property . <nl> + / / Returns the number of non - undefined elements collected . <nl> + / / Returns - 1 if hole removal is not supported by this method . <nl> + RUNTIME_FUNCTION ( Runtime_RemoveArrayHoles ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + CONVERT_NUMBER_CHECKED ( uint32_t , limit , Uint32 , args [ 1 ] ) ; <nl> + return * JSObject : : PrepareElementsForSort ( object , limit ) ; <nl> + } <nl> + <nl> + <nl> + / / Move contents of argument 0 ( an array ) to argument 1 ( an array ) <nl> + RUNTIME_FUNCTION ( Runtime_MoveArrayContents ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSArray , from , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSArray , to , 1 ) ; <nl> + JSObject : : ValidateElements ( from ) ; <nl> + JSObject : : ValidateElements ( to ) ; <nl> + <nl> + Handle < FixedArrayBase > new_elements ( from - > elements ( ) ) ; <nl> + ElementsKind from_kind = from - > GetElementsKind ( ) ; <nl> + Handle < Map > new_map = JSObject : : GetElementsTransitionMap ( to , from_kind ) ; <nl> + JSObject : : SetMapAndElements ( to , new_map , new_elements ) ; <nl> + to - > set_length ( from - > length ( ) ) ; <nl> + <nl> + JSObject : : ResetElements ( from ) ; <nl> + from - > set_length ( Smi : : FromInt ( 0 ) ) ; <nl> + <nl> + JSObject : : ValidateElements ( to ) ; <nl> + return * to ; <nl> + } <nl> + <nl> + <nl> + / / How many elements does this object / array have ? <nl> + RUNTIME_FUNCTION ( Runtime_EstimateNumberOfElements ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSArray , array , 0 ) ; <nl> + Handle < FixedArrayBase > elements ( array - > elements ( ) , isolate ) ; <nl> + SealHandleScope shs ( isolate ) ; <nl> + if ( elements - > IsDictionary ( ) ) { <nl> + int result = <nl> + Handle < SeededNumberDictionary > : : cast ( elements ) - > NumberOfElements ( ) ; <nl> + return Smi : : FromInt ( result ) ; <nl> + } else { <nl> + DCHECK ( array - > length ( ) - > IsSmi ( ) ) ; <nl> + / / For packed elements , we know the exact number of elements <nl> + int length = elements - > length ( ) ; <nl> + ElementsKind kind = array - > GetElementsKind ( ) ; <nl> + if ( IsFastPackedElementsKind ( kind ) ) { <nl> + return Smi : : FromInt ( length ) ; <nl> + } <nl> + / / For holey elements , take samples from the buffer checking for holes <nl> + / / to generate the estimate . <nl> + const int kNumberOfHoleCheckSamples = 97 ; <nl> + int increment = ( length < kNumberOfHoleCheckSamples ) <nl> + ? 1 <nl> + : static_cast < int > ( length / kNumberOfHoleCheckSamples ) ; <nl> + ElementsAccessor * accessor = array - > GetElementsAccessor ( ) ; <nl> + int holes = 0 ; <nl> + for ( int i = 0 ; i < length ; i + = increment ) { <nl> + if ( ! accessor - > HasElement ( array , array , i , elements ) ) { <nl> + + + holes ; <nl> + } <nl> + } <nl> + int estimate = static_cast < int > ( ( kNumberOfHoleCheckSamples - holes ) / <nl> + kNumberOfHoleCheckSamples * length ) ; <nl> + return Smi : : FromInt ( estimate ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / / Returns an array that tells you where in the [ 0 , length ) interval an array <nl> + / / might have elements . Can either return an array of keys ( positive integers <nl> + / / or undefined ) or a number representing the positive length of an interval <nl> + / / starting at index 0 . <nl> + / / Intervals can span over some keys that are not in the object . <nl> + RUNTIME_FUNCTION ( Runtime_GetArrayKeys ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , array , 0 ) ; <nl> + CONVERT_NUMBER_CHECKED ( uint32_t , length , Uint32 , args [ 1 ] ) ; <nl> + if ( array - > elements ( ) - > IsDictionary ( ) ) { <nl> + Handle < FixedArray > keys = isolate - > factory ( ) - > empty_fixed_array ( ) ; <nl> + for ( PrototypeIterator iter ( isolate , array , <nl> + PrototypeIterator : : START_AT_RECEIVER ) ; <nl> + ! iter . IsAtEnd ( ) ; iter . Advance ( ) ) { <nl> + if ( PrototypeIterator : : GetCurrent ( iter ) - > IsJSProxy ( ) | | <nl> + JSObject : : cast ( * PrototypeIterator : : GetCurrent ( iter ) ) <nl> + - > HasIndexedInterceptor ( ) ) { <nl> + / / Bail out if we find a proxy or interceptor , likely not worth <nl> + / / collecting keys in that case . <nl> + return * isolate - > factory ( ) - > NewNumberFromUint ( length ) ; <nl> + } <nl> + Handle < JSObject > current = <nl> + Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) ; <nl> + Handle < FixedArray > current_keys = <nl> + isolate - > factory ( ) - > NewFixedArray ( current - > NumberOfOwnElements ( NONE ) ) ; <nl> + current - > GetOwnElementKeys ( * current_keys , NONE ) ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , keys , FixedArray : : UnionOfKeys ( keys , current_keys ) ) ; <nl> + } <nl> + / / Erase any keys > = length . <nl> + / / TODO ( adamk ) : Remove this step when the contract of % GetArrayKeys <nl> + / / is changed to let this happen on the JS side . <nl> + for ( int i = 0 ; i < keys - > length ( ) ; i + + ) { <nl> + if ( NumberToUint32 ( keys - > get ( i ) ) > = length ) keys - > set_undefined ( i ) ; <nl> + } <nl> + return * isolate - > factory ( ) - > NewJSArrayWithElements ( keys ) ; <nl> + } else { <nl> + RUNTIME_ASSERT ( array - > HasFastSmiOrObjectElements ( ) | | <nl> + array - > HasFastDoubleElements ( ) ) ; <nl> + uint32_t actual_length = static_cast < uint32_t > ( array - > elements ( ) - > length ( ) ) ; <nl> + return * isolate - > factory ( ) - > NewNumberFromUint ( Min ( actual_length , length ) ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + static Object * ArrayConstructorCommon ( Isolate * isolate , <nl> + Handle < JSFunction > constructor , <nl> + Handle < AllocationSite > site , <nl> + Arguments * caller_args ) { <nl> + Factory * factory = isolate - > factory ( ) ; <nl> + <nl> + bool holey = false ; <nl> + bool can_use_type_feedback = true ; <nl> + if ( caller_args - > length ( ) = = 1 ) { <nl> + Handle < Object > argument_one = caller_args - > at < Object > ( 0 ) ; <nl> + if ( argument_one - > IsSmi ( ) ) { <nl> + int value = Handle < Smi > : : cast ( argument_one ) - > value ( ) ; <nl> + if ( value < 0 | | value > = JSObject : : kInitialMaxFastElementArray ) { <nl> + / / the array is a dictionary in this case . <nl> + can_use_type_feedback = false ; <nl> + } else if ( value ! = 0 ) { <nl> + holey = true ; <nl> + } <nl> + } else { <nl> + / / Non - smi length argument produces a dictionary <nl> + can_use_type_feedback = false ; <nl> + } <nl> + } <nl> + <nl> + Handle < JSArray > array ; <nl> + if ( ! site . is_null ( ) & & can_use_type_feedback ) { <nl> + ElementsKind to_kind = site - > GetElementsKind ( ) ; <nl> + if ( holey & & ! IsFastHoleyElementsKind ( to_kind ) ) { <nl> + to_kind = GetHoleyElementsKind ( to_kind ) ; <nl> + / / Update the allocation site info to reflect the advice alteration . <nl> + site - > SetElementsKind ( to_kind ) ; <nl> + } <nl> + <nl> + / / We should allocate with an initial map that reflects the allocation site <nl> + / / advice . Therefore we use AllocateJSObjectFromMap instead of passing <nl> + / / the constructor . <nl> + Handle < Map > initial_map ( constructor - > initial_map ( ) , isolate ) ; <nl> + if ( to_kind ! = initial_map - > elements_kind ( ) ) { <nl> + initial_map = Map : : AsElementsKind ( initial_map , to_kind ) ; <nl> + } <nl> + <nl> + / / If we don ' t care to track arrays of to_kind ElementsKind , then <nl> + / / don ' t emit a memento for them . <nl> + Handle < AllocationSite > allocation_site ; <nl> + if ( AllocationSite : : GetMode ( to_kind ) = = TRACK_ALLOCATION_SITE ) { <nl> + allocation_site = site ; <nl> + } <nl> + <nl> + array = Handle < JSArray > : : cast ( factory - > NewJSObjectFromMap ( <nl> + initial_map , NOT_TENURED , true , allocation_site ) ) ; <nl> + } else { <nl> + array = Handle < JSArray > : : cast ( factory - > NewJSObject ( constructor ) ) ; <nl> + <nl> + / / We might need to transition to holey <nl> + ElementsKind kind = constructor - > initial_map ( ) - > elements_kind ( ) ; <nl> + if ( holey & & ! IsFastHoleyElementsKind ( kind ) ) { <nl> + kind = GetHoleyElementsKind ( kind ) ; <nl> + JSObject : : TransitionElementsKind ( array , kind ) ; <nl> + } <nl> + } <nl> + <nl> + factory - > NewJSArrayStorage ( array , 0 , 0 , DONT_INITIALIZE_ARRAY_ELEMENTS ) ; <nl> + <nl> + ElementsKind old_kind = array - > GetElementsKind ( ) ; <nl> + RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , ArrayConstructInitializeElements ( array , caller_args ) ) ; <nl> + if ( ! site . is_null ( ) & & <nl> + ( old_kind ! = array - > GetElementsKind ( ) | | ! can_use_type_feedback ) ) { <nl> + / / The arguments passed in caused a transition . This kind of complexity <nl> + / / can ' t be dealt with in the inlined hydrogen array constructor case . <nl> + / / We must mark the allocationsite as un - inlinable . <nl> + site - > SetDoNotInlineCall ( ) ; <nl> + } <nl> + return * array ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_ArrayConstructor ) { <nl> + HandleScope scope ( isolate ) ; <nl> + / / If we get 2 arguments then they are the stub parameters ( constructor , type <nl> + / / info ) . If we get 4 , then the first one is a pointer to the arguments <nl> + / / passed by the caller , and the last one is the length of the arguments <nl> + / / passed to the caller ( redundant , but useful to check on the deoptimizer <nl> + / / with an assert ) . <nl> + Arguments empty_args ( 0 , NULL ) ; <nl> + bool no_caller_args = args . length ( ) = = 2 ; <nl> + DCHECK ( no_caller_args | | args . length ( ) = = 4 ) ; <nl> + int parameters_start = no_caller_args ? 0 : 1 ; <nl> + Arguments * caller_args = <nl> + no_caller_args ? & empty_args : reinterpret_cast < Arguments * > ( args [ 0 ] ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSFunction , constructor , parameters_start ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , type_info , parameters_start + 1 ) ; <nl> + # ifdef DEBUG <nl> + if ( ! no_caller_args ) { <nl> + CONVERT_SMI_ARG_CHECKED ( arg_count , parameters_start + 2 ) ; <nl> + DCHECK ( arg_count = = caller_args - > length ( ) ) ; <nl> + } <nl> + # endif <nl> + <nl> + Handle < AllocationSite > site ; <nl> + if ( ! type_info . is_null ( ) & & <nl> + * type_info ! = isolate - > heap ( ) - > undefined_value ( ) ) { <nl> + site = Handle < AllocationSite > : : cast ( type_info ) ; <nl> + DCHECK ( ! site - > SitePointsToLiteral ( ) ) ; <nl> + } <nl> + <nl> + return ArrayConstructorCommon ( isolate , constructor , site , caller_args ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_InternalArrayConstructor ) { <nl> + HandleScope scope ( isolate ) ; <nl> + Arguments empty_args ( 0 , NULL ) ; <nl> + bool no_caller_args = args . length ( ) = = 1 ; <nl> + DCHECK ( no_caller_args | | args . length ( ) = = 3 ) ; <nl> + int parameters_start = no_caller_args ? 0 : 1 ; <nl> + Arguments * caller_args = <nl> + no_caller_args ? & empty_args : reinterpret_cast < Arguments * > ( args [ 0 ] ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSFunction , constructor , parameters_start ) ; <nl> + # ifdef DEBUG <nl> + if ( ! no_caller_args ) { <nl> + CONVERT_SMI_ARG_CHECKED ( arg_count , parameters_start + 1 ) ; <nl> + DCHECK ( arg_count = = caller_args - > length ( ) ) ; <nl> + } <nl> + # endif <nl> + return ArrayConstructorCommon ( isolate , constructor , <nl> + Handle < AllocationSite > : : null ( ) , caller_args ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_NormalizeElements ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , array , 0 ) ; <nl> + RUNTIME_ASSERT ( ! array - > HasExternalArrayElements ( ) & & <nl> + ! array - > HasFixedTypedArrayElements ( ) ) ; <nl> + JSObject : : NormalizeElements ( array ) ; <nl> + return * array ; <nl> + } <nl> + <nl> + <nl> + / / TODO ( dcarney ) : remove this function when TurboFan supports it . <nl> + / / Takes the object to be iterated over and the result of GetPropertyNamesFast <nl> + / / Returns pair ( cache_array , cache_type ) . <nl> + RUNTIME_FUNCTION_RETURN_PAIR ( Runtime_ForInInit ) { <nl> + SealHandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + / / This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs . <nl> + / / Not worth creating a macro atm as this function should be removed . <nl> + if ( ! args [ 0 ] - > IsJSReceiver ( ) | | ! args [ 1 ] - > IsObject ( ) ) { <nl> + Object * error = isolate - > ThrowIllegalOperation ( ) ; <nl> + return MakePair ( error , isolate - > heap ( ) - > undefined_value ( ) ) ; <nl> + } <nl> + Handle < JSReceiver > object = args . at < JSReceiver > ( 0 ) ; <nl> + Handle < Object > cache_type = args . at < Object > ( 1 ) ; <nl> + if ( cache_type - > IsMap ( ) ) { <nl> + / / Enum cache case . <nl> + if ( Map : : EnumLengthBits : : decode ( Map : : cast ( * cache_type ) - > bit_field3 ( ) ) = = <nl> + 0 ) { <nl> + / / 0 length enum . <nl> + / / Can ' t handle this case in the graph builder , <nl> + / / so transform it into the empty fixed array case . <nl> + return MakePair ( isolate - > heap ( ) - > empty_fixed_array ( ) , Smi : : FromInt ( 1 ) ) ; <nl> + } <nl> + return MakePair ( object - > map ( ) - > instance_descriptors ( ) - > GetEnumCache ( ) , <nl> + * cache_type ) ; <nl> + } else { <nl> + / / FixedArray case . <nl> + Smi * new_cache_type = Smi : : FromInt ( object - > IsJSProxy ( ) ? 0 : 1 ) ; <nl> + return MakePair ( * Handle < FixedArray > : : cast ( cache_type ) , new_cache_type ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / / TODO ( dcarney ) : remove this function when TurboFan supports it . <nl> + RUNTIME_FUNCTION ( Runtime_ForInCacheArrayLength ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , cache_type , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( FixedArray , array , 1 ) ; <nl> + int length = 0 ; <nl> + if ( cache_type - > IsMap ( ) ) { <nl> + length = Map : : cast ( * cache_type ) - > EnumLength ( ) ; <nl> + } else { <nl> + DCHECK ( cache_type - > IsSmi ( ) ) ; <nl> + length = array - > length ( ) ; <nl> + } <nl> + return Smi : : FromInt ( length ) ; <nl> + } <nl> + <nl> + <nl> + / / TODO ( dcarney ) : remove this function when TurboFan supports it . <nl> + / / Takes ( the object to be iterated over , <nl> + / / cache_array from ForInInit , <nl> + / / cache_type from ForInInit , <nl> + / / the current index ) <nl> + / / Returns pair ( array [ index ] , needs_filtering ) . <nl> + RUNTIME_FUNCTION_RETURN_PAIR ( Runtime_ForInNext ) { <nl> + SealHandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 4 ) ; <nl> + int32_t index ; <nl> + / / This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs . <nl> + / / Not worth creating a macro atm as this function should be removed . <nl> + if ( ! args [ 0 ] - > IsJSReceiver ( ) | | ! args [ 1 ] - > IsFixedArray ( ) | | <nl> + ! args [ 2 ] - > IsObject ( ) | | ! args [ 3 ] - > ToInt32 ( & index ) ) { <nl> + Object * error = isolate - > ThrowIllegalOperation ( ) ; <nl> + return MakePair ( error , isolate - > heap ( ) - > undefined_value ( ) ) ; <nl> + } <nl> + Handle < JSReceiver > object = args . at < JSReceiver > ( 0 ) ; <nl> + Handle < FixedArray > array = args . at < FixedArray > ( 1 ) ; <nl> + Handle < Object > cache_type = args . at < Object > ( 2 ) ; <nl> + / / Figure out first if a slow check is needed for this object . <nl> + bool slow_check_needed = false ; <nl> + if ( cache_type - > IsMap ( ) ) { <nl> + if ( object - > map ( ) ! = Map : : cast ( * cache_type ) ) { <nl> + / / Object transitioned . Need slow check . <nl> + slow_check_needed = true ; <nl> + } <nl> + } else { <nl> + / / No slow check needed for proxies . <nl> + slow_check_needed = Smi : : cast ( * cache_type ) - > value ( ) = = 1 ; <nl> + } <nl> + return MakePair ( array - > get ( index ) , <nl> + isolate - > heap ( ) - > ToBoolean ( slow_check_needed ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_IsArray ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( obj - > IsJSArray ( ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_HasCachedArrayIndex ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + return isolate - > heap ( ) - > false_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_GetCachedArrayIndex ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_FastOneByteArrayJoin ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + } <nl> + } / / namespace v8 : : internal <nl> mmm a / src / runtime / runtime - debug . cc <nl> ppp b / src / runtime / runtime - debug . cc <nl> RUNTIME_FUNCTION ( RuntimeReference_DebugIsActive ) { <nl> SealHandleScope shs ( isolate ) ; <nl> return Smi : : FromInt ( isolate - > debug ( ) - > is_active ( ) ) ; <nl> } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_DebugBreakInOptimizedCode ) { <nl> + UNIMPLEMENTED ( ) ; <nl> + return NULL ; <nl> + } <nl> } <nl> } / / namespace v8 : : internal <nl> new file mode 100644 <nl> index 00000000000 . . 8a5ad2e48fe <nl> mmm / dev / null <nl> ppp b / src / runtime / runtime - internal . 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 " src / v8 . h " <nl> + <nl> + # include " src / arguments . h " <nl> + # include " src / bootstrapper . h " <nl> + # include " src / debug . h " <nl> + # include " src / runtime / runtime . h " <nl> + # include " src / runtime / runtime - utils . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_CheckIsBootstrapping ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 0 ) ; <nl> + RUNTIME_ASSERT ( isolate - > bootstrapper ( ) - > IsActive ( ) ) ; <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_Throw ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + <nl> + return isolate - > Throw ( args [ 0 ] ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_ReThrow ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + <nl> + return isolate - > ReThrow ( args [ 0 ] ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_PromoteScheduledException ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 0 ) ; <nl> + return isolate - > PromoteScheduledException ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_ThrowReferenceError ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , name , 0 ) ; <nl> + THROW_NEW_ERROR_RETURN_FAILURE ( <nl> + isolate , NewReferenceError ( " not_defined " , HandleVector ( & name , 1 ) ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_PromiseRejectEvent ) { <nl> + DCHECK ( args . length ( ) = = 3 ) ; <nl> + HandleScope scope ( isolate ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , promise , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , value , 1 ) ; <nl> + CONVERT_BOOLEAN_ARG_CHECKED ( debug_event , 2 ) ; <nl> + if ( debug_event ) isolate - > debug ( ) - > OnPromiseReject ( promise , value ) ; <nl> + Handle < Symbol > key = isolate - > factory ( ) - > promise_has_handler_symbol ( ) ; <nl> + / / Do not report if we actually have a handler . <nl> + if ( JSObject : : GetDataProperty ( promise , key ) - > IsUndefined ( ) ) { <nl> + isolate - > ReportPromiseReject ( promise , value , <nl> + v8 : : kPromiseRejectWithNoHandler ) ; <nl> + } <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_PromiseRevokeReject ) { <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + HandleScope scope ( isolate ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , promise , 0 ) ; <nl> + Handle < Symbol > key = isolate - > factory ( ) - > promise_has_handler_symbol ( ) ; <nl> + / / At this point , no revocation has been issued before <nl> + RUNTIME_ASSERT ( JSObject : : GetDataProperty ( promise , key ) - > IsUndefined ( ) ) ; <nl> + isolate - > ReportPromiseReject ( promise , Handle < Object > ( ) , <nl> + v8 : : kPromiseHandlerAddedAfterReject ) ; <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_PromiseHasHandlerSymbol ) { <nl> + DCHECK ( args . length ( ) = = 0 ) ; <nl> + return isolate - > heap ( ) - > promise_has_handler_symbol ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_StackGuard ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 0 ) ; <nl> + <nl> + / / First check if this is a real stack overflow . <nl> + StackLimitCheck check ( isolate ) ; <nl> + if ( check . JsHasOverflowed ( ) ) { <nl> + return isolate - > StackOverflow ( ) ; <nl> + } <nl> + <nl> + return isolate - > stack_guard ( ) - > HandleInterrupts ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_Interrupt ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 0 ) ; <nl> + return isolate - > stack_guard ( ) - > HandleInterrupts ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_AllocateInNewSpace ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( size , 0 ) ; <nl> + RUNTIME_ASSERT ( IsAligned ( size , kPointerSize ) ) ; <nl> + RUNTIME_ASSERT ( size > 0 ) ; <nl> + RUNTIME_ASSERT ( size < = Page : : kMaxRegularHeapObjectSize ) ; <nl> + return * isolate - > factory ( ) - > NewFillerObject ( size , false , NEW_SPACE ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_AllocateInTargetSpace ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( size , 0 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( flags , 1 ) ; <nl> + RUNTIME_ASSERT ( IsAligned ( size , kPointerSize ) ) ; <nl> + RUNTIME_ASSERT ( size > 0 ) ; <nl> + RUNTIME_ASSERT ( size < = Page : : kMaxRegularHeapObjectSize ) ; <nl> + bool double_align = AllocateDoubleAlignFlag : : decode ( flags ) ; <nl> + AllocationSpace space = AllocateTargetSpace : : decode ( flags ) ; <nl> + return * isolate - > factory ( ) - > NewFillerObject ( size , double_align , space ) ; <nl> + } <nl> + <nl> + <nl> + / / Collect the raw data for a stack trace . Returns an array of 4 <nl> + / / element segments each containing a receiver , function , code and <nl> + / / native code offset . <nl> + RUNTIME_FUNCTION ( Runtime_CollectStackTrace ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , error_object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , caller , 1 ) ; <nl> + <nl> + if ( ! isolate - > bootstrapper ( ) - > IsActive ( ) ) { <nl> + / / Optionally capture a more detailed stack trace for the message . <nl> + isolate - > CaptureAndSetDetailedStackTrace ( error_object ) ; <nl> + / / Capture a simple stack trace for the stack property . <nl> + isolate - > CaptureAndSetSimpleStackTrace ( error_object , caller ) ; <nl> + } <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_GetFromCache ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + / / This is only called from codegen , so checks might be more lax . <nl> + CONVERT_ARG_CHECKED ( JSFunctionResultCache , cache , 0 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , key , 1 ) ; <nl> + <nl> + { <nl> + DisallowHeapAllocation no_alloc ; <nl> + <nl> + int finger_index = cache - > finger_index ( ) ; <nl> + Object * o = cache - > get ( finger_index ) ; <nl> + if ( o = = key ) { <nl> + / / The fastest case : hit the same place again . <nl> + return cache - > get ( finger_index + 1 ) ; <nl> + } <nl> + <nl> + for ( int i = finger_index - 2 ; i > = JSFunctionResultCache : : kEntriesIndex ; <nl> + i - = 2 ) { <nl> + o = cache - > get ( i ) ; <nl> + if ( o = = key ) { <nl> + cache - > set_finger_index ( i ) ; <nl> + return cache - > get ( i + 1 ) ; <nl> + } <nl> + } <nl> + <nl> + int size = cache - > size ( ) ; <nl> + DCHECK ( size < = cache - > length ( ) ) ; <nl> + <nl> + for ( int i = size - 2 ; i > finger_index ; i - = 2 ) { <nl> + o = cache - > get ( i ) ; <nl> + if ( o = = key ) { <nl> + cache - > set_finger_index ( i ) ; <nl> + return cache - > get ( i + 1 ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + / / There is no value in the cache . Invoke the function and cache result . <nl> + HandleScope scope ( isolate ) ; <nl> + <nl> + Handle < JSFunctionResultCache > cache_handle ( cache ) ; <nl> + Handle < Object > key_handle ( key , isolate ) ; <nl> + Handle < Object > value ; <nl> + { <nl> + Handle < JSFunction > factory ( JSFunction : : cast ( <nl> + cache_handle - > get ( JSFunctionResultCache : : kFactoryIndex ) ) ) ; <nl> + / / TODO ( antonm ) : consider passing a receiver when constructing a cache . <nl> + Handle < JSObject > receiver ( isolate - > global_proxy ( ) ) ; <nl> + / / This handle is nor shared , nor used later , so it ' s safe . <nl> + Handle < Object > argv [ ] = { key_handle } ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , value , <nl> + Execution : : Call ( isolate , factory , receiver , arraysize ( argv ) , argv ) ) ; <nl> + } <nl> + <nl> + # ifdef VERIFY_HEAP <nl> + if ( FLAG_verify_heap ) { <nl> + cache_handle - > JSFunctionResultCacheVerify ( ) ; <nl> + } <nl> + # endif <nl> + <nl> + / / Function invocation may have cleared the cache . Reread all the data . <nl> + int finger_index = cache_handle - > finger_index ( ) ; <nl> + int size = cache_handle - > size ( ) ; <nl> + <nl> + / / If we have spare room , put new data into it , otherwise evict post finger <nl> + / / entry which is likely to be the least recently used . <nl> + int index = - 1 ; <nl> + if ( size < cache_handle - > length ( ) ) { <nl> + cache_handle - > set_size ( size + JSFunctionResultCache : : kEntrySize ) ; <nl> + index = size ; <nl> + } else { <nl> + index = finger_index + JSFunctionResultCache : : kEntrySize ; <nl> + if ( index = = cache_handle - > length ( ) ) { <nl> + index = JSFunctionResultCache : : kEntriesIndex ; <nl> + } <nl> + } <nl> + <nl> + DCHECK ( index % 2 = = 0 ) ; <nl> + DCHECK ( index > = JSFunctionResultCache : : kEntriesIndex ) ; <nl> + DCHECK ( index < cache_handle - > length ( ) ) ; <nl> + <nl> + cache_handle - > set ( index , * key_handle ) ; <nl> + cache_handle - > set ( index + 1 , * value ) ; <nl> + cache_handle - > set_finger_index ( index ) ; <nl> + <nl> + # ifdef VERIFY_HEAP <nl> + if ( FLAG_verify_heap ) { <nl> + cache_handle - > JSFunctionResultCacheVerify ( ) ; <nl> + } <nl> + # endif <nl> + <nl> + return * value ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_MessageGetStartPosition ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( JSMessageObject , message , 0 ) ; <nl> + return Smi : : FromInt ( message - > start_position ( ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_MessageGetScript ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( JSMessageObject , message , 0 ) ; <nl> + return message - > script ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_IS_VAR ) { <nl> + UNREACHABLE ( ) ; / / implemented as macro in the parser <nl> + return NULL ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_GetFromCache ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( id , 0 ) ; <nl> + args [ 0 ] = isolate - > native_context ( ) - > jsfunction_result_caches ( ) - > get ( id ) ; <nl> + return __RT_impl_Runtime_GetFromCache ( args , isolate ) ; <nl> + } <nl> + } <nl> + } / / namespace v8 : : internal <nl> mmm a / src / runtime / runtime - numbers . cc <nl> ppp b / src / runtime / runtime - numbers . cc <nl> <nl> # include " src / v8 . h " <nl> <nl> # include " src / arguments . h " <nl> + # include " src / bootstrapper . h " <nl> # include " src / codegen . h " <nl> # include " src / misc - intrinsics . h " <nl> # include " src / runtime / runtime . h " <nl> RUNTIME_FUNCTION ( Runtime_SmiLexicographicCompare ) { <nl> } <nl> <nl> <nl> + RUNTIME_FUNCTION ( Runtime_GetRootNaN ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 0 ) ; <nl> + RUNTIME_ASSERT ( isolate - > bootstrapper ( ) - > IsActive ( ) ) ; <nl> + return isolate - > heap ( ) - > nan_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_MaxSmi ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 0 ) ; <nl> + return Smi : : FromInt ( Smi : : kMaxValue ) ; <nl> + } <nl> + <nl> + <nl> RUNTIME_FUNCTION ( RuntimeReference_NumberToString ) { <nl> SealHandleScope shs ( isolate ) ; <nl> return __RT_impl_Runtime_NumberToStringRT ( args , isolate ) ; <nl> new file mode 100644 <nl> index 00000000000 . . 3868011e4fa <nl> mmm / dev / null <nl> ppp b / src / runtime / runtime - object . 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 " src / v8 . h " <nl> + <nl> + # include " src / arguments . h " <nl> + # include " src / bootstrapper . h " <nl> + # include " src / debug . h " <nl> + # include " src / runtime / runtime . h " <nl> + # include " src / runtime / runtime - utils . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + / / Returns a single character string where first character equals <nl> + / / string - > Get ( index ) . <nl> + static Handle < Object > GetCharAt ( Handle < String > string , uint32_t index ) { <nl> + if ( index < static_cast < uint32_t > ( string - > length ( ) ) ) { <nl> + Factory * factory = string - > GetIsolate ( ) - > factory ( ) ; <nl> + return factory - > LookupSingleCharacterStringFromCode ( <nl> + String : : Flatten ( string ) - > Get ( index ) ) ; <nl> + } <nl> + return Execution : : CharAt ( string , index ) ; <nl> + } <nl> + <nl> + <nl> + MaybeHandle < Object > Runtime : : GetElementOrCharAt ( Isolate * isolate , <nl> + Handle < Object > object , <nl> + uint32_t index ) { <nl> + / / Handle [ ] indexing on Strings <nl> + if ( object - > IsString ( ) ) { <nl> + Handle < Object > result = GetCharAt ( Handle < String > : : cast ( object ) , index ) ; <nl> + if ( ! result - > IsUndefined ( ) ) return result ; <nl> + } <nl> + <nl> + / / Handle [ ] indexing on String objects <nl> + if ( object - > IsStringObjectWithCharacterAt ( index ) ) { <nl> + Handle < JSValue > js_value = Handle < JSValue > : : cast ( object ) ; <nl> + Handle < Object > result = <nl> + GetCharAt ( Handle < String > ( String : : cast ( js_value - > value ( ) ) ) , index ) ; <nl> + if ( ! result - > IsUndefined ( ) ) return result ; <nl> + } <nl> + <nl> + Handle < Object > result ; <nl> + if ( object - > IsString ( ) | | object - > IsNumber ( ) | | object - > IsBoolean ( ) ) { <nl> + PrototypeIterator iter ( isolate , object ) ; <nl> + return Object : : GetElement ( isolate , PrototypeIterator : : GetCurrent ( iter ) , <nl> + index ) ; <nl> + } else { <nl> + return Object : : GetElement ( isolate , object , index ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + MaybeHandle < Name > Runtime : : ToName ( Isolate * isolate , Handle < Object > key ) { <nl> + if ( key - > IsName ( ) ) { <nl> + return Handle < Name > : : cast ( key ) ; <nl> + } else { <nl> + Handle < Object > converted ; <nl> + ASSIGN_RETURN_ON_EXCEPTION ( isolate , converted , <nl> + Execution : : ToString ( isolate , key ) , Name ) ; <nl> + return Handle < Name > : : cast ( converted ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + MaybeHandle < Object > Runtime : : HasObjectProperty ( Isolate * isolate , <nl> + Handle < JSReceiver > object , <nl> + Handle < Object > key ) { <nl> + Maybe < bool > maybe ; <nl> + / / Check if the given key is an array index . <nl> + uint32_t index ; <nl> + if ( key - > ToArrayIndex ( & index ) ) { <nl> + maybe = JSReceiver : : HasElement ( object , index ) ; <nl> + } else { <nl> + / / Convert the key to a name - possibly by calling back into JavaScript . <nl> + Handle < Name > name ; <nl> + ASSIGN_RETURN_ON_EXCEPTION ( isolate , name , ToName ( isolate , key ) , Object ) ; <nl> + <nl> + maybe = JSReceiver : : HasProperty ( object , name ) ; <nl> + } <nl> + <nl> + if ( ! maybe . has_value ) return MaybeHandle < Object > ( ) ; <nl> + return isolate - > factory ( ) - > ToBoolean ( maybe . value ) ; <nl> + } <nl> + <nl> + <nl> + MaybeHandle < Object > Runtime : : GetObjectProperty ( Isolate * isolate , <nl> + Handle < Object > object , <nl> + Handle < Object > key ) { <nl> + if ( object - > IsUndefined ( ) | | object - > IsNull ( ) ) { <nl> + Handle < Object > args [ 2 ] = { key , object } ; <nl> + THROW_NEW_ERROR ( isolate , NewTypeError ( " non_object_property_load " , <nl> + HandleVector ( args , 2 ) ) , <nl> + Object ) ; <nl> + } <nl> + <nl> + / / Check if the given key is an array index . <nl> + uint32_t index ; <nl> + if ( key - > ToArrayIndex ( & index ) ) { <nl> + return GetElementOrCharAt ( isolate , object , index ) ; <nl> + } <nl> + <nl> + / / Convert the key to a name - possibly by calling back into JavaScript . <nl> + Handle < Name > name ; <nl> + ASSIGN_RETURN_ON_EXCEPTION ( isolate , name , ToName ( isolate , key ) , Object ) ; <nl> + <nl> + / / Check if the name is trivially convertible to an index and get <nl> + / / the element if so . <nl> + if ( name - > AsArrayIndex ( & index ) ) { <nl> + return GetElementOrCharAt ( isolate , object , index ) ; <nl> + } else { <nl> + return Object : : GetProperty ( object , name ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + MaybeHandle < Object > Runtime : : SetObjectProperty ( Isolate * isolate , <nl> + Handle < Object > object , <nl> + Handle < Object > key , <nl> + Handle < Object > value , <nl> + StrictMode strict_mode ) { <nl> + if ( object - > IsUndefined ( ) | | object - > IsNull ( ) ) { <nl> + Handle < Object > args [ 2 ] = { key , object } ; <nl> + THROW_NEW_ERROR ( isolate , NewTypeError ( " non_object_property_store " , <nl> + HandleVector ( args , 2 ) ) , <nl> + Object ) ; <nl> + } <nl> + <nl> + if ( object - > IsJSProxy ( ) ) { <nl> + Handle < Object > name_object ; <nl> + if ( key - > IsSymbol ( ) ) { <nl> + name_object = key ; <nl> + } else { <nl> + ASSIGN_RETURN_ON_EXCEPTION ( isolate , name_object , <nl> + Execution : : ToString ( isolate , key ) , Object ) ; <nl> + } <nl> + Handle < Name > name = Handle < Name > : : cast ( name_object ) ; <nl> + return Object : : SetProperty ( Handle < JSProxy > : : cast ( object ) , name , value , <nl> + strict_mode ) ; <nl> + } <nl> + <nl> + / / Check if the given key is an array index . <nl> + uint32_t index ; <nl> + if ( key - > ToArrayIndex ( & index ) ) { <nl> + / / TODO ( verwaest ) : Support non - JSObject receivers . <nl> + if ( ! object - > IsJSObject ( ) ) return value ; <nl> + Handle < JSObject > js_object = Handle < JSObject > : : cast ( object ) ; <nl> + <nl> + / / In Firefox / SpiderMonkey , Safari and Opera you can access the characters <nl> + / / of a string using [ ] notation . We need to support this too in <nl> + / / JavaScript . <nl> + / / In the case of a String object we just need to redirect the assignment to <nl> + / / the underlying string if the index is in range . Since the underlying <nl> + / / string does nothing with the assignment then we can ignore such <nl> + / / assignments . <nl> + if ( js_object - > IsStringObjectWithCharacterAt ( index ) ) { <nl> + return value ; <nl> + } <nl> + <nl> + JSObject : : ValidateElements ( js_object ) ; <nl> + if ( js_object - > HasExternalArrayElements ( ) | | <nl> + js_object - > HasFixedTypedArrayElements ( ) ) { <nl> + if ( ! value - > IsNumber ( ) & & ! value - > IsUndefined ( ) ) { <nl> + ASSIGN_RETURN_ON_EXCEPTION ( isolate , value , <nl> + Execution : : ToNumber ( isolate , value ) , Object ) ; <nl> + } <nl> + } <nl> + <nl> + MaybeHandle < Object > result = JSObject : : SetElement ( <nl> + js_object , index , value , NONE , strict_mode , true , SET_PROPERTY ) ; <nl> + JSObject : : ValidateElements ( js_object ) ; <nl> + <nl> + return result . is_null ( ) ? result : value ; <nl> + } <nl> + <nl> + if ( key - > IsName ( ) ) { <nl> + Handle < Name > name = Handle < Name > : : cast ( key ) ; <nl> + if ( name - > AsArrayIndex ( & index ) ) { <nl> + / / TODO ( verwaest ) : Support non - JSObject receivers . <nl> + if ( ! object - > IsJSObject ( ) ) return value ; <nl> + Handle < JSObject > js_object = Handle < JSObject > : : cast ( object ) ; <nl> + if ( js_object - > HasExternalArrayElements ( ) ) { <nl> + if ( ! value - > IsNumber ( ) & & ! value - > IsUndefined ( ) ) { <nl> + ASSIGN_RETURN_ON_EXCEPTION ( <nl> + isolate , value , Execution : : ToNumber ( isolate , value ) , Object ) ; <nl> + } <nl> + } <nl> + return JSObject : : SetElement ( js_object , index , value , NONE , strict_mode , <nl> + true , SET_PROPERTY ) ; <nl> + } else { <nl> + if ( name - > IsString ( ) ) name = String : : Flatten ( Handle < String > : : cast ( name ) ) ; <nl> + return Object : : SetProperty ( object , name , value , strict_mode ) ; <nl> + } <nl> + } <nl> + <nl> + / / Call - back into JavaScript to convert the key to a string . <nl> + Handle < Object > converted ; <nl> + ASSIGN_RETURN_ON_EXCEPTION ( isolate , converted , <nl> + Execution : : ToString ( isolate , key ) , Object ) ; <nl> + Handle < String > name = Handle < String > : : cast ( converted ) ; <nl> + <nl> + if ( name - > AsArrayIndex ( & index ) ) { <nl> + / / TODO ( verwaest ) : Support non - JSObject receivers . <nl> + if ( ! object - > IsJSObject ( ) ) return value ; <nl> + Handle < JSObject > js_object = Handle < JSObject > : : cast ( object ) ; <nl> + return JSObject : : SetElement ( js_object , index , value , NONE , strict_mode , <nl> + true , SET_PROPERTY ) ; <nl> + } <nl> + return Object : : SetProperty ( object , name , value , strict_mode ) ; <nl> + } <nl> + <nl> + <nl> + MaybeHandle < Object > Runtime : : DefineObjectProperty ( Handle < JSObject > js_object , <nl> + Handle < Object > key , <nl> + Handle < Object > value , <nl> + PropertyAttributes attr ) { <nl> + Isolate * isolate = js_object - > GetIsolate ( ) ; <nl> + / / Check if the given key is an array index . <nl> + uint32_t index ; <nl> + if ( key - > ToArrayIndex ( & index ) ) { <nl> + / / In Firefox / SpiderMonkey , Safari and Opera you can access the characters <nl> + / / of a string using [ ] notation . We need to support this too in <nl> + / / JavaScript . <nl> + / / In the case of a String object we just need to redirect the assignment to <nl> + / / the underlying string if the index is in range . Since the underlying <nl> + / / string does nothing with the assignment then we can ignore such <nl> + / / assignments . <nl> + if ( js_object - > IsStringObjectWithCharacterAt ( index ) ) { <nl> + return value ; <nl> + } <nl> + <nl> + return JSObject : : SetElement ( js_object , index , value , attr , SLOPPY , false , <nl> + DEFINE_PROPERTY ) ; <nl> + } <nl> + <nl> + if ( key - > IsName ( ) ) { <nl> + Handle < Name > name = Handle < Name > : : cast ( key ) ; <nl> + if ( name - > AsArrayIndex ( & index ) ) { <nl> + return JSObject : : SetElement ( js_object , index , value , attr , SLOPPY , false , <nl> + DEFINE_PROPERTY ) ; <nl> + } else { <nl> + if ( name - > IsString ( ) ) name = String : : Flatten ( Handle < String > : : cast ( name ) ) ; <nl> + return JSObject : : SetOwnPropertyIgnoreAttributes ( js_object , name , value , <nl> + attr ) ; <nl> + } <nl> + } <nl> + <nl> + / / Call - back into JavaScript to convert the key to a string . <nl> + Handle < Object > converted ; <nl> + ASSIGN_RETURN_ON_EXCEPTION ( isolate , converted , <nl> + Execution : : ToString ( isolate , key ) , Object ) ; <nl> + Handle < String > name = Handle < String > : : cast ( converted ) ; <nl> + <nl> + if ( name - > AsArrayIndex ( & index ) ) { <nl> + return JSObject : : SetElement ( js_object , index , value , attr , SLOPPY , false , <nl> + DEFINE_PROPERTY ) ; <nl> + } else { <nl> + return JSObject : : SetOwnPropertyIgnoreAttributes ( js_object , name , value , <nl> + attr ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + MaybeHandle < Object > Runtime : : DeleteObjectProperty ( Isolate * isolate , <nl> + Handle < JSReceiver > receiver , <nl> + Handle < Object > key , <nl> + JSReceiver : : DeleteMode mode ) { <nl> + / / Check if the given key is an array index . <nl> + uint32_t index ; <nl> + if ( key - > ToArrayIndex ( & index ) ) { <nl> + / / In Firefox / SpiderMonkey , Safari and Opera you can access the <nl> + / / characters of a string using [ ] notation . In the case of a <nl> + / / String object we just need to redirect the deletion to the <nl> + / / underlying string if the index is in range . Since the <nl> + / / underlying string does nothing with the deletion , we can ignore <nl> + / / such deletions . <nl> + if ( receiver - > IsStringObjectWithCharacterAt ( index ) ) { <nl> + return isolate - > factory ( ) - > true_value ( ) ; <nl> + } <nl> + <nl> + return JSReceiver : : DeleteElement ( receiver , index , mode ) ; <nl> + } <nl> + <nl> + Handle < Name > name ; <nl> + if ( key - > IsName ( ) ) { <nl> + name = Handle < Name > : : cast ( key ) ; <nl> + } else { <nl> + / / Call - back into JavaScript to convert the key to a string . <nl> + Handle < Object > converted ; <nl> + ASSIGN_RETURN_ON_EXCEPTION ( isolate , converted , <nl> + Execution : : ToString ( isolate , key ) , Object ) ; <nl> + name = Handle < String > : : cast ( converted ) ; <nl> + } <nl> + <nl> + if ( name - > IsString ( ) ) name = String : : Flatten ( Handle < String > : : cast ( name ) ) ; <nl> + return JSReceiver : : DeleteProperty ( receiver , name , mode ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_GetPrototype ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , obj , 0 ) ; <nl> + / / We don ' t expect access checks to be needed on JSProxy objects . <nl> + DCHECK ( ! obj - > IsAccessCheckNeeded ( ) | | obj - > IsJSObject ( ) ) ; <nl> + PrototypeIterator iter ( isolate , obj , PrototypeIterator : : START_AT_RECEIVER ) ; <nl> + do { <nl> + if ( PrototypeIterator : : GetCurrent ( iter ) - > IsAccessCheckNeeded ( ) & & <nl> + ! isolate - > MayNamedAccess ( <nl> + Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) , <nl> + isolate - > factory ( ) - > proto_string ( ) , v8 : : ACCESS_GET ) ) { <nl> + isolate - > ReportFailedAccessCheck ( <nl> + Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) , <nl> + v8 : : ACCESS_GET ) ; <nl> + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + iter . AdvanceIgnoringProxies ( ) ; <nl> + if ( PrototypeIterator : : GetCurrent ( iter ) - > IsJSProxy ( ) ) { <nl> + return * PrototypeIterator : : GetCurrent ( iter ) ; <nl> + } <nl> + } while ( ! iter . IsAtEnd ( PrototypeIterator : : END_AT_NON_HIDDEN ) ) ; <nl> + return * PrototypeIterator : : GetCurrent ( iter ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_InternalSetPrototype ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , prototype , 1 ) ; <nl> + DCHECK ( ! obj - > IsAccessCheckNeeded ( ) ) ; <nl> + DCHECK ( ! obj - > map ( ) - > is_observed ( ) ) ; <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , JSObject : : SetPrototype ( obj , prototype , false ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_SetPrototype ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , prototype , 1 ) ; <nl> + if ( obj - > IsAccessCheckNeeded ( ) & & <nl> + ! isolate - > MayNamedAccess ( obj , isolate - > factory ( ) - > proto_string ( ) , <nl> + v8 : : ACCESS_SET ) ) { <nl> + isolate - > ReportFailedAccessCheck ( obj , v8 : : ACCESS_SET ) ; <nl> + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + if ( obj - > map ( ) - > is_observed ( ) ) { <nl> + Handle < Object > old_value = <nl> + Object : : GetPrototypeSkipHiddenPrototypes ( isolate , obj ) ; <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , JSObject : : SetPrototype ( obj , prototype , true ) ) ; <nl> + <nl> + Handle < Object > new_value = <nl> + Object : : GetPrototypeSkipHiddenPrototypes ( isolate , obj ) ; <nl> + if ( ! new_value - > SameValue ( * old_value ) ) { <nl> + JSObject : : EnqueueChangeRecord ( <nl> + obj , " setPrototype " , isolate - > factory ( ) - > proto_string ( ) , old_value ) ; <nl> + } <nl> + return * result ; <nl> + } <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , JSObject : : SetPrototype ( obj , prototype , true ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_IsInPrototypeChain ) { <nl> + HandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + / / See ECMA - 262 , section 15 . 3 . 5 . 3 , page 88 ( steps 5 - 8 ) . <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , O , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , V , 1 ) ; <nl> + PrototypeIterator iter ( isolate , V , PrototypeIterator : : START_AT_RECEIVER ) ; <nl> + while ( true ) { <nl> + iter . AdvanceIgnoringProxies ( ) ; <nl> + if ( iter . IsAtEnd ( ) ) return isolate - > heap ( ) - > false_value ( ) ; <nl> + if ( iter . IsAtEnd ( O ) ) return isolate - > heap ( ) - > true_value ( ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / / Enumerator used as indices into the array returned from GetOwnProperty <nl> + enum PropertyDescriptorIndices { <nl> + IS_ACCESSOR_INDEX , <nl> + VALUE_INDEX , <nl> + GETTER_INDEX , <nl> + SETTER_INDEX , <nl> + WRITABLE_INDEX , <nl> + ENUMERABLE_INDEX , <nl> + CONFIGURABLE_INDEX , <nl> + DESCRIPTOR_SIZE <nl> + } ; <nl> + <nl> + <nl> + MUST_USE_RESULT static MaybeHandle < Object > GetOwnProperty ( Isolate * isolate , <nl> + Handle < JSObject > obj , <nl> + Handle < Name > name ) { <nl> + Heap * heap = isolate - > heap ( ) ; <nl> + Factory * factory = isolate - > factory ( ) ; <nl> + <nl> + PropertyAttributes attrs ; <nl> + uint32_t index = 0 ; <nl> + Handle < Object > value ; <nl> + MaybeHandle < AccessorPair > maybe_accessors ; <nl> + / / TODO ( verwaest ) : Unify once indexed properties can be handled by the <nl> + / / LookupIterator . <nl> + if ( name - > AsArrayIndex ( & index ) ) { <nl> + / / Get attributes . <nl> + Maybe < PropertyAttributes > maybe = <nl> + JSReceiver : : GetOwnElementAttribute ( obj , index ) ; <nl> + if ( ! maybe . has_value ) return MaybeHandle < Object > ( ) ; <nl> + attrs = maybe . value ; <nl> + if ( attrs = = ABSENT ) return factory - > undefined_value ( ) ; <nl> + <nl> + / / Get AccessorPair if present . <nl> + maybe_accessors = JSObject : : GetOwnElementAccessorPair ( obj , index ) ; <nl> + <nl> + / / Get value if not an AccessorPair . <nl> + if ( maybe_accessors . is_null ( ) ) { <nl> + ASSIGN_RETURN_ON_EXCEPTION ( <nl> + isolate , value , Runtime : : GetElementOrCharAt ( isolate , obj , index ) , <nl> + Object ) ; <nl> + } <nl> + } else { <nl> + / / Get attributes . <nl> + LookupIterator it ( obj , name , LookupIterator : : HIDDEN ) ; <nl> + Maybe < PropertyAttributes > maybe = JSObject : : GetPropertyAttributes ( & it ) ; <nl> + if ( ! maybe . has_value ) return MaybeHandle < Object > ( ) ; <nl> + attrs = maybe . value ; <nl> + if ( attrs = = ABSENT ) return factory - > undefined_value ( ) ; <nl> + <nl> + / / Get AccessorPair if present . <nl> + if ( it . state ( ) = = LookupIterator : : ACCESSOR & & <nl> + it . GetAccessors ( ) - > IsAccessorPair ( ) ) { <nl> + maybe_accessors = Handle < AccessorPair > : : cast ( it . GetAccessors ( ) ) ; <nl> + } <nl> + <nl> + / / Get value if not an AccessorPair . <nl> + if ( maybe_accessors . is_null ( ) ) { <nl> + ASSIGN_RETURN_ON_EXCEPTION ( isolate , value , Object : : GetProperty ( & it ) , <nl> + Object ) ; <nl> + } <nl> + } <nl> + DCHECK ( ! isolate - > has_pending_exception ( ) ) ; <nl> + Handle < FixedArray > elms = factory - > NewFixedArray ( DESCRIPTOR_SIZE ) ; <nl> + elms - > set ( ENUMERABLE_INDEX , heap - > ToBoolean ( ( attrs & DONT_ENUM ) = = 0 ) ) ; <nl> + elms - > set ( CONFIGURABLE_INDEX , heap - > ToBoolean ( ( attrs & DONT_DELETE ) = = 0 ) ) ; <nl> + elms - > set ( IS_ACCESSOR_INDEX , heap - > ToBoolean ( ! maybe_accessors . is_null ( ) ) ) ; <nl> + <nl> + Handle < AccessorPair > accessors ; <nl> + if ( maybe_accessors . ToHandle ( & accessors ) ) { <nl> + Handle < Object > getter ( accessors - > GetComponent ( ACCESSOR_GETTER ) , isolate ) ; <nl> + Handle < Object > setter ( accessors - > GetComponent ( ACCESSOR_SETTER ) , isolate ) ; <nl> + elms - > set ( GETTER_INDEX , * getter ) ; <nl> + elms - > set ( SETTER_INDEX , * setter ) ; <nl> + } else { <nl> + elms - > set ( WRITABLE_INDEX , heap - > ToBoolean ( ( attrs & READ_ONLY ) = = 0 ) ) ; <nl> + elms - > set ( VALUE_INDEX , * value ) ; <nl> + } <nl> + <nl> + return factory - > NewJSArrayWithElements ( elms ) ; <nl> + } <nl> + <nl> + <nl> + / / Returns an array with the property description : <nl> + / / if args [ 1 ] is not a property on args [ 0 ] <nl> + / / returns undefined <nl> + / / if args [ 1 ] is a data property on args [ 0 ] <nl> + / / [ false , value , Writeable , Enumerable , Configurable ] <nl> + / / if args [ 1 ] is an accessor on args [ 0 ] <nl> + / / [ true , GetFunction , SetFunction , Enumerable , Configurable ] <nl> + RUNTIME_FUNCTION ( Runtime_GetOwnProperty ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , name , 1 ) ; <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate , result , <nl> + GetOwnProperty ( isolate , obj , name ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_PreventExtensions ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate , result , <nl> + JSObject : : PreventExtensions ( obj ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_IsExtensible ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( JSObject , obj , 0 ) ; <nl> + if ( obj - > IsJSGlobalProxy ( ) ) { <nl> + PrototypeIterator iter ( isolate , obj ) ; <nl> + if ( iter . IsAtEnd ( ) ) return isolate - > heap ( ) - > false_value ( ) ; <nl> + DCHECK ( iter . GetCurrent ( ) - > IsJSGlobalObject ( ) ) ; <nl> + obj = JSObject : : cast ( iter . GetCurrent ( ) ) ; <nl> + } <nl> + return isolate - > heap ( ) - > ToBoolean ( obj - > map ( ) - > is_extensible ( ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_DisableAccessChecks ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( HeapObject , object , 0 ) ; <nl> + Handle < Map > old_map ( object - > map ( ) ) ; <nl> + bool needs_access_checks = old_map - > is_access_check_needed ( ) ; <nl> + if ( needs_access_checks ) { <nl> + / / Copy map so it won ' t interfere constructor ' s initial map . <nl> + Handle < Map > new_map = Map : : Copy ( old_map ) ; <nl> + new_map - > set_is_access_check_needed ( false ) ; <nl> + JSObject : : MigrateToMap ( Handle < JSObject > : : cast ( object ) , new_map ) ; <nl> + } <nl> + return isolate - > heap ( ) - > ToBoolean ( needs_access_checks ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_EnableAccessChecks ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + Handle < Map > old_map ( object - > map ( ) ) ; <nl> + RUNTIME_ASSERT ( ! old_map - > is_access_check_needed ( ) ) ; <nl> + / / Copy map so it won ' t interfere constructor ' s initial map . <nl> + Handle < Map > new_map = Map : : Copy ( old_map ) ; <nl> + new_map - > set_is_access_check_needed ( true ) ; <nl> + JSObject : : MigrateToMap ( object , new_map ) ; <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_OptimizeObjectForAddingMultipleProperties ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( properties , 1 ) ; <nl> + / / Conservative upper limit to prevent fuzz tests from going OOM . <nl> + RUNTIME_ASSERT ( properties < = 100000 ) ; <nl> + if ( object - > HasFastProperties ( ) & & ! object - > IsJSGlobalProxy ( ) ) { <nl> + JSObject : : NormalizeProperties ( object , KEEP_INOBJECT_PROPERTIES , properties ) ; <nl> + } <nl> + return * object ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_ObjectFreeze ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + <nl> + / / % ObjectFreeze is a fast path and these cases are handled elsewhere . <nl> + RUNTIME_ASSERT ( ! object - > HasSloppyArgumentsElements ( ) & & <nl> + ! object - > map ( ) - > is_observed ( ) & & ! object - > IsJSProxy ( ) ) ; <nl> + <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate , result , JSObject : : Freeze ( object ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_GetProperty ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , key , 1 ) ; <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , Runtime : : GetObjectProperty ( isolate , object , key ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + MUST_USE_RESULT static MaybeHandle < Object > TransitionElements ( <nl> + Handle < Object > object , ElementsKind to_kind , Isolate * isolate ) { <nl> + HandleScope scope ( isolate ) ; <nl> + if ( ! object - > IsJSObject ( ) ) { <nl> + isolate - > ThrowIllegalOperation ( ) ; <nl> + return MaybeHandle < Object > ( ) ; <nl> + } <nl> + ElementsKind from_kind = <nl> + Handle < JSObject > : : cast ( object ) - > map ( ) - > elements_kind ( ) ; <nl> + if ( Map : : IsValidElementsTransition ( from_kind , to_kind ) ) { <nl> + JSObject : : TransitionElementsKind ( Handle < JSObject > : : cast ( object ) , to_kind ) ; <nl> + return object ; <nl> + } <nl> + isolate - > ThrowIllegalOperation ( ) ; <nl> + return MaybeHandle < Object > ( ) ; <nl> + } <nl> + <nl> + <nl> + / / KeyedGetProperty is called from KeyedLoadIC : : GenerateGeneric . <nl> + RUNTIME_FUNCTION ( Runtime_KeyedGetProperty ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , receiver_obj , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , key_obj , 1 ) ; <nl> + <nl> + / / Fast cases for getting named properties of the receiver JSObject <nl> + / / itself . <nl> + / / <nl> + / / The global proxy objects has to be excluded since LookupOwn on <nl> + / / the global proxy object can return a valid result even though the <nl> + / / global proxy object never has properties . This is the case <nl> + / / because the global proxy object forwards everything to its hidden <nl> + / / prototype including own lookups . <nl> + / / <nl> + / / Additionally , we need to make sure that we do not cache results <nl> + / / for objects that require access checks . <nl> + if ( receiver_obj - > IsJSObject ( ) ) { <nl> + if ( ! receiver_obj - > IsJSGlobalProxy ( ) & & <nl> + ! receiver_obj - > IsAccessCheckNeeded ( ) & & key_obj - > IsName ( ) ) { <nl> + DisallowHeapAllocation no_allocation ; <nl> + Handle < JSObject > receiver = Handle < JSObject > : : cast ( receiver_obj ) ; <nl> + Handle < Name > key = Handle < Name > : : cast ( key_obj ) ; <nl> + if ( receiver - > HasFastProperties ( ) ) { <nl> + / / Attempt to use lookup cache . <nl> + Handle < Map > receiver_map ( receiver - > map ( ) , isolate ) ; <nl> + KeyedLookupCache * keyed_lookup_cache = isolate - > keyed_lookup_cache ( ) ; <nl> + int index = keyed_lookup_cache - > Lookup ( receiver_map , key ) ; <nl> + if ( index ! = - 1 ) { <nl> + / / Doubles are not cached , so raw read the value . <nl> + return receiver - > RawFastPropertyAt ( <nl> + FieldIndex : : ForKeyedLookupCacheIndex ( * receiver_map , index ) ) ; <nl> + } <nl> + / / Lookup cache miss . Perform lookup and update the cache if <nl> + / / appropriate . <nl> + LookupIterator it ( receiver , key , LookupIterator : : OWN ) ; <nl> + if ( it . state ( ) = = LookupIterator : : DATA & & <nl> + it . property_details ( ) . type ( ) = = FIELD ) { <nl> + FieldIndex field_index = it . GetFieldIndex ( ) ; <nl> + / / Do not track double fields in the keyed lookup cache . Reading <nl> + / / double values requires boxing . <nl> + if ( ! it . representation ( ) . IsDouble ( ) ) { <nl> + keyed_lookup_cache - > Update ( receiver_map , key , <nl> + field_index . GetKeyedLookupCacheIndex ( ) ) ; <nl> + } <nl> + AllowHeapAllocation allow_allocation ; <nl> + return * JSObject : : FastPropertyAt ( receiver , it . representation ( ) , <nl> + field_index ) ; <nl> + } <nl> + } else { <nl> + / / Attempt dictionary lookup . <nl> + NameDictionary * dictionary = receiver - > property_dictionary ( ) ; <nl> + int entry = dictionary - > FindEntry ( key ) ; <nl> + if ( ( entry ! = NameDictionary : : kNotFound ) & & <nl> + ( dictionary - > DetailsAt ( entry ) . type ( ) = = NORMAL ) ) { <nl> + Object * value = dictionary - > ValueAt ( entry ) ; <nl> + if ( ! receiver - > IsGlobalObject ( ) ) return value ; <nl> + value = PropertyCell : : cast ( value ) - > value ( ) ; <nl> + if ( ! value - > IsTheHole ( ) ) return value ; <nl> + / / If value is the hole ( meaning , absent ) do the general lookup . <nl> + } <nl> + } <nl> + } else if ( key_obj - > IsSmi ( ) ) { <nl> + / / JSObject without a name key . If the key is a Smi , check for a <nl> + / / definite out - of - bounds access to elements , which is a strong indicator <nl> + / / that subsequent accesses will also call the runtime . Proactively <nl> + / / transition elements to FAST_ * _ELEMENTS to avoid excessive boxing of <nl> + / / doubles for those future calls in the case that the elements would <nl> + / / become FAST_DOUBLE_ELEMENTS . <nl> + Handle < JSObject > js_object = Handle < JSObject > : : cast ( receiver_obj ) ; <nl> + ElementsKind elements_kind = js_object - > GetElementsKind ( ) ; <nl> + if ( IsFastDoubleElementsKind ( elements_kind ) ) { <nl> + Handle < Smi > key = Handle < Smi > : : cast ( key_obj ) ; <nl> + if ( key - > value ( ) > = js_object - > elements ( ) - > length ( ) ) { <nl> + if ( IsFastHoleyElementsKind ( elements_kind ) ) { <nl> + elements_kind = FAST_HOLEY_ELEMENTS ; <nl> + } else { <nl> + elements_kind = FAST_ELEMENTS ; <nl> + } <nl> + RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , TransitionElements ( js_object , elements_kind , isolate ) ) ; <nl> + } <nl> + } else { <nl> + DCHECK ( IsFastSmiOrObjectElementsKind ( elements_kind ) | | <nl> + ! IsFastElementsKind ( elements_kind ) ) ; <nl> + } <nl> + } <nl> + } else if ( receiver_obj - > IsString ( ) & & key_obj - > IsSmi ( ) ) { <nl> + / / Fast case for string indexing using [ ] with a smi index . <nl> + Handle < String > str = Handle < String > : : cast ( receiver_obj ) ; <nl> + int index = args . smi_at ( 1 ) ; <nl> + if ( index > = 0 & & index < str - > length ( ) ) { <nl> + return * GetCharAt ( str , index ) ; <nl> + } <nl> + } <nl> + <nl> + / / Fall back to GetObjectProperty . <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , <nl> + Runtime : : GetObjectProperty ( isolate , receiver_obj , key_obj ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_AddNamedProperty ) { <nl> + HandleScope scope ( isolate ) ; <nl> + RUNTIME_ASSERT ( args . length ( ) = = 4 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( unchecked_attributes , 3 ) ; <nl> + RUNTIME_ASSERT ( <nl> + ( unchecked_attributes & ~ ( READ_ONLY | DONT_ENUM | DONT_DELETE ) ) = = 0 ) ; <nl> + / / Compute attributes . <nl> + PropertyAttributes attributes = <nl> + static_cast < PropertyAttributes > ( unchecked_attributes ) ; <nl> + <nl> + # ifdef DEBUG <nl> + uint32_t index = 0 ; <nl> + DCHECK ( ! key - > ToArrayIndex ( & index ) ) ; <nl> + LookupIterator it ( object , key , LookupIterator : : OWN_SKIP_INTERCEPTOR ) ; <nl> + Maybe < PropertyAttributes > maybe = JSReceiver : : GetPropertyAttributes ( & it ) ; <nl> + if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> + RUNTIME_ASSERT ( ! it . IsFound ( ) ) ; <nl> + # endif <nl> + <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , <nl> + JSObject : : SetOwnPropertyIgnoreAttributes ( object , key , value , attributes ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_SetProperty ) { <nl> + HandleScope scope ( isolate ) ; <nl> + RUNTIME_ASSERT ( args . length ( ) = = 4 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , key , 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> + CONVERT_STRICT_MODE_ARG_CHECKED ( strict_mode_arg , 3 ) ; <nl> + StrictMode strict_mode = strict_mode_arg ; <nl> + <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , <nl> + Runtime : : SetObjectProperty ( isolate , object , key , value , strict_mode ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + / / Adds an element to an array . <nl> + / / This is used to create an indexed data property into an array . <nl> + RUNTIME_FUNCTION ( Runtime_AddElement ) { <nl> + HandleScope scope ( isolate ) ; <nl> + RUNTIME_ASSERT ( args . length ( ) = = 4 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , key , 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( unchecked_attributes , 3 ) ; <nl> + RUNTIME_ASSERT ( <nl> + ( unchecked_attributes & ~ ( READ_ONLY | DONT_ENUM | DONT_DELETE ) ) = = 0 ) ; <nl> + / / Compute attributes . <nl> + PropertyAttributes attributes = <nl> + static_cast < PropertyAttributes > ( unchecked_attributes ) ; <nl> + <nl> + uint32_t index = 0 ; <nl> + key - > ToArrayIndex ( & index ) ; <nl> + <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , JSObject : : SetElement ( object , index , value , attributes , <nl> + SLOPPY , false , DEFINE_PROPERTY ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_DeleteProperty ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 3 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> + CONVERT_STRICT_MODE_ARG_CHECKED ( strict_mode , 2 ) ; <nl> + JSReceiver : : DeleteMode delete_mode = strict_mode = = STRICT <nl> + ? JSReceiver : : STRICT_DELETION <nl> + : JSReceiver : : NORMAL_DELETION ; <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , JSReceiver : : DeleteProperty ( object , key , delete_mode ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + static Object * HasOwnPropertyImplementation ( Isolate * isolate , <nl> + Handle < JSObject > object , <nl> + Handle < Name > key ) { <nl> + Maybe < bool > maybe = JSReceiver : : HasOwnProperty ( object , key ) ; <nl> + if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> + if ( maybe . value ) return isolate - > heap ( ) - > true_value ( ) ; <nl> + / / Handle hidden prototypes . If there ' s a hidden prototype above this thing <nl> + / / then we have to check it for properties , because they are supposed to <nl> + / / look like they are on this object . <nl> + PrototypeIterator iter ( isolate , object ) ; <nl> + if ( ! iter . IsAtEnd ( ) & & <nl> + Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) <nl> + - > map ( ) <nl> + - > is_hidden_prototype ( ) ) { <nl> + / / TODO ( verwaest ) : The recursion is not necessary for keys that are array <nl> + / / indices . Removing this . <nl> + return HasOwnPropertyImplementation ( <nl> + isolate , Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) , <nl> + key ) ; <nl> + } <nl> + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> + return isolate - > heap ( ) - > false_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_HasOwnProperty ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , object , 0 ) <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> + <nl> + uint32_t index ; <nl> + const bool key_is_array_index = key - > AsArrayIndex ( & index ) ; <nl> + <nl> + / / Only JS objects can have properties . <nl> + if ( object - > IsJSObject ( ) ) { <nl> + Handle < JSObject > js_obj = Handle < JSObject > : : cast ( object ) ; <nl> + / / Fast case : either the key is a real named property or it is not <nl> + / / an array index and there are no interceptors or hidden <nl> + / / prototypes . <nl> + Maybe < bool > maybe = JSObject : : HasRealNamedProperty ( js_obj , key ) ; <nl> + if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> + DCHECK ( ! isolate - > has_pending_exception ( ) ) ; <nl> + if ( maybe . value ) { <nl> + return isolate - > heap ( ) - > true_value ( ) ; <nl> + } <nl> + Map * map = js_obj - > map ( ) ; <nl> + if ( ! key_is_array_index & & ! map - > has_named_interceptor ( ) & & <nl> + ! HeapObject : : cast ( map - > prototype ( ) ) - > map ( ) - > is_hidden_prototype ( ) ) { <nl> + return isolate - > heap ( ) - > false_value ( ) ; <nl> + } <nl> + / / Slow case . <nl> + return HasOwnPropertyImplementation ( isolate , Handle < JSObject > ( js_obj ) , <nl> + Handle < Name > ( key ) ) ; <nl> + } else if ( object - > IsString ( ) & & key_is_array_index ) { <nl> + / / Well , there is one exception : Handle [ ] on strings . <nl> + Handle < String > string = Handle < String > : : cast ( object ) ; <nl> + if ( index < static_cast < uint32_t > ( string - > length ( ) ) ) { <nl> + return isolate - > heap ( ) - > true_value ( ) ; <nl> + } <nl> + } <nl> + return isolate - > heap ( ) - > false_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_HasProperty ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , receiver , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> + <nl> + Maybe < bool > maybe = JSReceiver : : HasProperty ( receiver , key ) ; <nl> + if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( maybe . value ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_HasElement ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , receiver , 0 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( index , 1 ) ; <nl> + <nl> + Maybe < bool > maybe = JSReceiver : : HasElement ( receiver , index ) ; <nl> + if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( maybe . value ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_IsPropertyEnumerable ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> + <nl> + Maybe < PropertyAttributes > maybe = <nl> + JSReceiver : : GetOwnPropertyAttributes ( object , key ) ; <nl> + if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> + if ( maybe . value = = ABSENT ) maybe . value = DONT_ENUM ; <nl> + return isolate - > heap ( ) - > ToBoolean ( ( maybe . value & DONT_ENUM ) = = 0 ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_GetPropertyNames ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , object , 0 ) ; <nl> + Handle < JSArray > result ; <nl> + <nl> + isolate - > counters ( ) - > for_in ( ) - > Increment ( ) ; <nl> + Handle < FixedArray > elements ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , elements , <nl> + JSReceiver : : GetKeys ( object , JSReceiver : : INCLUDE_PROTOS ) ) ; <nl> + return * isolate - > factory ( ) - > NewJSArrayWithElements ( elements ) ; <nl> + } <nl> + <nl> + <nl> + / / Returns either a FixedArray as Runtime_GetPropertyNames , <nl> + / / or , if the given object has an enum cache that contains <nl> + / / all enumerable properties of the object and its prototypes <nl> + / / have none , the map of the object . This is used to speed up <nl> + / / the check for deletions during a for - in . <nl> + RUNTIME_FUNCTION ( Runtime_GetPropertyNamesFast ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + <nl> + CONVERT_ARG_CHECKED ( JSReceiver , raw_object , 0 ) ; <nl> + <nl> + if ( raw_object - > IsSimpleEnum ( ) ) return raw_object - > map ( ) ; <nl> + <nl> + HandleScope scope ( isolate ) ; <nl> + Handle < JSReceiver > object ( raw_object ) ; <nl> + Handle < FixedArray > content ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , content , <nl> + JSReceiver : : GetKeys ( object , JSReceiver : : INCLUDE_PROTOS ) ) ; <nl> + <nl> + / / Test again , since cache may have been built by preceding call . <nl> + if ( object - > IsSimpleEnum ( ) ) return object - > map ( ) ; <nl> + <nl> + return * content ; <nl> + } <nl> + <nl> + <nl> + / / Find the length of the prototype chain that is to be handled as one . If a <nl> + / / prototype object is hidden it is to be viewed as part of the the object it <nl> + / / is prototype for . <nl> + static int OwnPrototypeChainLength ( JSObject * obj ) { <nl> + int count = 1 ; <nl> + for ( PrototypeIterator iter ( obj - > GetIsolate ( ) , obj ) ; <nl> + ! iter . IsAtEnd ( PrototypeIterator : : END_AT_NON_HIDDEN ) ; iter . Advance ( ) ) { <nl> + count + + ; <nl> + } <nl> + return count ; <nl> + } <nl> + <nl> + <nl> + / / Return the names of the own named properties . <nl> + / / args [ 0 ] : object <nl> + / / args [ 1 ] : PropertyAttributes as int <nl> + RUNTIME_FUNCTION ( Runtime_GetOwnPropertyNames ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + if ( ! args [ 0 ] - > IsJSObject ( ) ) { <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( filter_value , 1 ) ; <nl> + PropertyAttributes filter = static_cast < PropertyAttributes > ( filter_value ) ; <nl> + <nl> + / / Skip the global proxy as it has no properties and always delegates to the <nl> + / / real global object . <nl> + if ( obj - > IsJSGlobalProxy ( ) ) { <nl> + / / Only collect names if access is permitted . <nl> + if ( obj - > IsAccessCheckNeeded ( ) & & <nl> + ! isolate - > MayNamedAccess ( obj , isolate - > factory ( ) - > undefined_value ( ) , <nl> + v8 : : ACCESS_KEYS ) ) { <nl> + isolate - > ReportFailedAccessCheck ( obj , v8 : : ACCESS_KEYS ) ; <nl> + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> + return * isolate - > factory ( ) - > NewJSArray ( 0 ) ; <nl> + } <nl> + PrototypeIterator iter ( isolate , obj ) ; <nl> + obj = Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) ; <nl> + } <nl> + <nl> + / / Find the number of objects making up this . <nl> + int length = OwnPrototypeChainLength ( * obj ) ; <nl> + <nl> + / / Find the number of own properties for each of the objects . <nl> + ScopedVector < int > own_property_count ( length ) ; <nl> + int total_property_count = 0 ; <nl> + { <nl> + PrototypeIterator iter ( isolate , obj , PrototypeIterator : : START_AT_RECEIVER ) ; <nl> + for ( int i = 0 ; i < length ; i + + ) { <nl> + DCHECK ( ! iter . IsAtEnd ( ) ) ; <nl> + Handle < JSObject > jsproto = <nl> + Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) ; <nl> + / / Only collect names if access is permitted . <nl> + if ( jsproto - > IsAccessCheckNeeded ( ) & & <nl> + ! isolate - > MayNamedAccess ( jsproto , <nl> + isolate - > factory ( ) - > undefined_value ( ) , <nl> + v8 : : ACCESS_KEYS ) ) { <nl> + isolate - > ReportFailedAccessCheck ( jsproto , v8 : : ACCESS_KEYS ) ; <nl> + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> + return * isolate - > factory ( ) - > NewJSArray ( 0 ) ; <nl> + } <nl> + int n ; <nl> + n = jsproto - > NumberOfOwnProperties ( filter ) ; <nl> + own_property_count [ i ] = n ; <nl> + total_property_count + = n ; <nl> + iter . Advance ( ) ; <nl> + } <nl> + } <nl> + <nl> + / / Allocate an array with storage for all the property names . <nl> + Handle < FixedArray > names = <nl> + isolate - > factory ( ) - > NewFixedArray ( total_property_count ) ; <nl> + <nl> + / / Get the property names . <nl> + int next_copy_index = 0 ; <nl> + int hidden_strings = 0 ; <nl> + { <nl> + PrototypeIterator iter ( isolate , obj , PrototypeIterator : : START_AT_RECEIVER ) ; <nl> + for ( int i = 0 ; i < length ; i + + ) { <nl> + DCHECK ( ! iter . IsAtEnd ( ) ) ; <nl> + Handle < JSObject > jsproto = <nl> + Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) ; <nl> + jsproto - > GetOwnPropertyNames ( * names , next_copy_index , filter ) ; <nl> + if ( i > 0 ) { <nl> + / / Names from hidden prototypes may already have been added <nl> + / / for inherited function template instances . Count the duplicates <nl> + / / and stub them out ; the final copy pass at the end ignores holes . <nl> + for ( int j = next_copy_index ; <nl> + j < next_copy_index + own_property_count [ i ] ; j + + ) { <nl> + Object * name_from_hidden_proto = names - > get ( j ) ; <nl> + for ( int k = 0 ; k < next_copy_index ; k + + ) { <nl> + if ( names - > get ( k ) ! = isolate - > heap ( ) - > hidden_string ( ) ) { <nl> + Object * name = names - > get ( k ) ; <nl> + if ( name_from_hidden_proto = = name ) { <nl> + names - > set ( j , isolate - > heap ( ) - > hidden_string ( ) ) ; <nl> + hidden_strings + + ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + } <nl> + next_copy_index + = own_property_count [ i ] ; <nl> + <nl> + / / Hidden properties only show up if the filter does not skip strings . <nl> + if ( ( filter & STRING ) = = 0 & & JSObject : : HasHiddenProperties ( jsproto ) ) { <nl> + hidden_strings + + ; <nl> + } <nl> + iter . Advance ( ) ; <nl> + } <nl> + } <nl> + <nl> + / / Filter out name of hidden properties object and <nl> + / / hidden prototype duplicates . <nl> + if ( hidden_strings > 0 ) { <nl> + Handle < FixedArray > old_names = names ; <nl> + names = isolate - > factory ( ) - > NewFixedArray ( names - > length ( ) - hidden_strings ) ; <nl> + int dest_pos = 0 ; <nl> + for ( int i = 0 ; i < total_property_count ; i + + ) { <nl> + Object * name = old_names - > get ( i ) ; <nl> + if ( name = = isolate - > heap ( ) - > hidden_string ( ) ) { <nl> + hidden_strings - - ; <nl> + continue ; <nl> + } <nl> + names - > set ( dest_pos + + , name ) ; <nl> + } <nl> + DCHECK_EQ ( 0 , hidden_strings ) ; <nl> + } <nl> + <nl> + return * isolate - > factory ( ) - > NewJSArrayWithElements ( names ) ; <nl> + } <nl> + <nl> + <nl> + / / Return the names of the own indexed properties . <nl> + / / args [ 0 ] : object <nl> + RUNTIME_FUNCTION ( Runtime_GetOwnElementNames ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + if ( ! args [ 0 ] - > IsJSObject ( ) ) { <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> + <nl> + int n = obj - > NumberOfOwnElements ( static_cast < PropertyAttributes > ( NONE ) ) ; <nl> + Handle < FixedArray > names = isolate - > factory ( ) - > NewFixedArray ( n ) ; <nl> + obj - > GetOwnElementKeys ( * names , static_cast < PropertyAttributes > ( NONE ) ) ; <nl> + return * isolate - > factory ( ) - > NewJSArrayWithElements ( names ) ; <nl> + } <nl> + <nl> + <nl> + / / Return information on whether an object has a named or indexed interceptor . <nl> + / / args [ 0 ] : object <nl> + RUNTIME_FUNCTION ( Runtime_GetInterceptorInfo ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + if ( ! args [ 0 ] - > IsJSObject ( ) ) { <nl> + return Smi : : FromInt ( 0 ) ; <nl> + } <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> + <nl> + int result = 0 ; <nl> + if ( obj - > HasNamedInterceptor ( ) ) result | = 2 ; <nl> + if ( obj - > HasIndexedInterceptor ( ) ) result | = 1 ; <nl> + <nl> + return Smi : : FromInt ( result ) ; <nl> + } <nl> + <nl> + <nl> + / / Return property names from named interceptor . <nl> + / / args [ 0 ] : object <nl> + RUNTIME_FUNCTION ( Runtime_GetNamedInterceptorPropertyNames ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> + <nl> + if ( obj - > HasNamedInterceptor ( ) ) { <nl> + Handle < JSObject > result ; <nl> + if ( JSObject : : GetKeysForNamedInterceptor ( obj , obj ) . ToHandle ( & result ) ) { <nl> + return * result ; <nl> + } <nl> + } <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + / / Return element names from indexed interceptor . <nl> + / / args [ 0 ] : object <nl> + RUNTIME_FUNCTION ( Runtime_GetIndexedInterceptorElementNames ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> + <nl> + if ( obj - > HasIndexedInterceptor ( ) ) { <nl> + Handle < JSObject > result ; <nl> + if ( JSObject : : GetKeysForIndexedInterceptor ( obj , obj ) . ToHandle ( & result ) ) { <nl> + return * result ; <nl> + } <nl> + } <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_OwnKeys ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( JSObject , raw_object , 0 ) ; <nl> + Handle < JSObject > object ( raw_object ) ; <nl> + <nl> + if ( object - > IsJSGlobalProxy ( ) ) { <nl> + / / Do access checks before going to the global object . <nl> + if ( object - > IsAccessCheckNeeded ( ) & & <nl> + ! isolate - > MayNamedAccess ( object , isolate - > factory ( ) - > undefined_value ( ) , <nl> + v8 : : ACCESS_KEYS ) ) { <nl> + isolate - > ReportFailedAccessCheck ( object , v8 : : ACCESS_KEYS ) ; <nl> + RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> + return * isolate - > factory ( ) - > NewJSArray ( 0 ) ; <nl> + } <nl> + <nl> + PrototypeIterator iter ( isolate , object ) ; <nl> + / / If proxy is detached we simply return an empty array . <nl> + if ( iter . IsAtEnd ( ) ) return * isolate - > factory ( ) - > NewJSArray ( 0 ) ; <nl> + object = Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) ; <nl> + } <nl> + <nl> + Handle < FixedArray > contents ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , contents , JSReceiver : : GetKeys ( object , JSReceiver : : OWN_ONLY ) ) ; <nl> + <nl> + / / Some fast paths through GetKeysInFixedArrayFor reuse a cached <nl> + / / property array and since the result is mutable we have to create <nl> + / / a fresh clone on each invocation . <nl> + int length = contents - > length ( ) ; <nl> + Handle < FixedArray > copy = isolate - > factory ( ) - > NewFixedArray ( length ) ; <nl> + for ( int i = 0 ; i < length ; i + + ) { <nl> + Object * entry = contents - > get ( i ) ; <nl> + if ( entry - > IsString ( ) ) { <nl> + copy - > set ( i , entry ) ; <nl> + } else { <nl> + DCHECK ( entry - > IsNumber ( ) ) ; <nl> + HandleScope scope ( isolate ) ; <nl> + Handle < Object > entry_handle ( entry , isolate ) ; <nl> + Handle < Object > entry_str = <nl> + isolate - > factory ( ) - > NumberToString ( entry_handle ) ; <nl> + copy - > set ( i , * entry_str ) ; <nl> + } <nl> + } <nl> + return * isolate - > factory ( ) - > NewJSArrayWithElements ( copy ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_ToFastProperties ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , object , 0 ) ; <nl> + if ( object - > IsJSObject ( ) & & ! object - > IsGlobalObject ( ) ) { <nl> + JSObject : : MigrateSlowToFast ( Handle < JSObject > : : cast ( object ) , 0 ) ; <nl> + } <nl> + return * object ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_ToBool ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , object , 0 ) ; <nl> + <nl> + return isolate - > heap ( ) - > ToBoolean ( object - > BooleanValue ( ) ) ; <nl> + } <nl> + <nl> + <nl> + / / Returns the type string of a value ; see ECMA - 262 , 11 . 4 . 3 ( p 47 ) . <nl> + / / Possible optimizations : put the type string into the oddballs . <nl> + RUNTIME_FUNCTION ( Runtime_Typeof ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> + if ( obj - > IsNumber ( ) ) return isolate - > heap ( ) - > number_string ( ) ; <nl> + HeapObject * heap_obj = HeapObject : : cast ( obj ) ; <nl> + <nl> + / / typeof an undetectable object is ' undefined ' <nl> + if ( heap_obj - > map ( ) - > is_undetectable ( ) ) { <nl> + return isolate - > heap ( ) - > undefined_string ( ) ; <nl> + } <nl> + <nl> + InstanceType instance_type = heap_obj - > map ( ) - > instance_type ( ) ; <nl> + if ( instance_type < FIRST_NONSTRING_TYPE ) { <nl> + return isolate - > heap ( ) - > string_string ( ) ; <nl> + } <nl> + <nl> + switch ( instance_type ) { <nl> + case ODDBALL_TYPE : <nl> + if ( heap_obj - > IsTrue ( ) | | heap_obj - > IsFalse ( ) ) { <nl> + return isolate - > heap ( ) - > boolean_string ( ) ; <nl> + } <nl> + if ( heap_obj - > IsNull ( ) ) { <nl> + return isolate - > heap ( ) - > object_string ( ) ; <nl> + } <nl> + DCHECK ( heap_obj - > IsUndefined ( ) ) ; <nl> + return isolate - > heap ( ) - > undefined_string ( ) ; <nl> + case SYMBOL_TYPE : <nl> + return isolate - > heap ( ) - > symbol_string ( ) ; <nl> + case JS_FUNCTION_TYPE : <nl> + case JS_FUNCTION_PROXY_TYPE : <nl> + return isolate - > heap ( ) - > function_string ( ) ; <nl> + default : <nl> + / / For any kind of object not handled above , the spec rule for <nl> + / / host objects gives that it is okay to return " object " <nl> + return isolate - > heap ( ) - > object_string ( ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_Booleanize ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , value_raw , 0 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( token_raw , 1 ) ; <nl> + intptr_t value = reinterpret_cast < intptr_t > ( value_raw ) ; <nl> + Token : : Value token = static_cast < Token : : Value > ( token_raw ) ; <nl> + switch ( token ) { <nl> + case Token : : EQ : <nl> + case Token : : EQ_STRICT : <nl> + return isolate - > heap ( ) - > ToBoolean ( value = = 0 ) ; <nl> + case Token : : NE : <nl> + case Token : : NE_STRICT : <nl> + return isolate - > heap ( ) - > ToBoolean ( value ! = 0 ) ; <nl> + case Token : : LT : <nl> + return isolate - > heap ( ) - > ToBoolean ( value < 0 ) ; <nl> + case Token : : GT : <nl> + return isolate - > heap ( ) - > ToBoolean ( value > 0 ) ; <nl> + case Token : : LTE : <nl> + return isolate - > heap ( ) - > ToBoolean ( value < = 0 ) ; <nl> + case Token : : GTE : <nl> + return isolate - > heap ( ) - > ToBoolean ( value > = 0 ) ; <nl> + default : <nl> + / / This should only happen during natives fuzzing . <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_NewStringWrapper ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( String , value , 0 ) ; <nl> + return * Object : : ToObject ( isolate , value ) . ToHandleChecked ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_AllocateHeapNumber ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 0 ) ; <nl> + return * isolate - > factory ( ) - > NewHeapNumber ( 0 ) ; <nl> + } <nl> + <nl> + <nl> + static Object * Runtime_NewObjectHelper ( Isolate * isolate , <nl> + Handle < Object > constructor , <nl> + Handle < AllocationSite > site ) { <nl> + / / If the constructor isn ' t a proper function we throw a type error . <nl> + if ( ! constructor - > IsJSFunction ( ) ) { <nl> + Vector < Handle < Object > > arguments = HandleVector ( & constructor , 1 ) ; <nl> + THROW_NEW_ERROR_RETURN_FAILURE ( isolate , <nl> + NewTypeError ( " not_constructor " , arguments ) ) ; <nl> + } <nl> + <nl> + Handle < JSFunction > function = Handle < JSFunction > : : cast ( constructor ) ; <nl> + <nl> + / / If function should not have prototype , construction is not allowed . In this <nl> + / / case generated code bailouts here , since function has no initial_map . <nl> + if ( ! function - > should_have_prototype ( ) & & ! function - > shared ( ) - > bound ( ) ) { <nl> + Vector < Handle < Object > > arguments = HandleVector ( & constructor , 1 ) ; <nl> + THROW_NEW_ERROR_RETURN_FAILURE ( isolate , <nl> + NewTypeError ( " not_constructor " , arguments ) ) ; <nl> + } <nl> + <nl> + Debug * debug = isolate - > debug ( ) ; <nl> + / / Handle stepping into constructors if step into is active . <nl> + if ( debug - > StepInActive ( ) ) { <nl> + debug - > HandleStepIn ( function , Handle < Object > : : null ( ) , 0 , true ) ; <nl> + } <nl> + <nl> + if ( function - > has_initial_map ( ) ) { <nl> + if ( function - > initial_map ( ) - > instance_type ( ) = = JS_FUNCTION_TYPE ) { <nl> + / / The ' Function ' function ignores the receiver object when <nl> + / / called using ' new ' and creates a new JSFunction object that <nl> + / / is returned . The receiver object is only used for error <nl> + / / reporting if an error occurs when constructing the new <nl> + / / JSFunction . Factory : : NewJSObject ( ) should not be used to <nl> + / / allocate JSFunctions since it does not properly initialize <nl> + / / the shared part of the function . Since the receiver is <nl> + / / ignored anyway , we use the global object as the receiver <nl> + / / instead of a new JSFunction object . This way , errors are <nl> + / / reported the same way whether or not ' Function ' is called <nl> + / / using ' new ' . <nl> + return isolate - > global_proxy ( ) ; <nl> + } <nl> + } <nl> + <nl> + / / The function should be compiled for the optimization hints to be <nl> + / / available . <nl> + Compiler : : EnsureCompiled ( function , CLEAR_EXCEPTION ) ; <nl> + <nl> + Handle < JSObject > result ; <nl> + if ( site . is_null ( ) ) { <nl> + result = isolate - > factory ( ) - > NewJSObject ( function ) ; <nl> + } else { <nl> + result = isolate - > factory ( ) - > NewJSObjectWithMemento ( function , site ) ; <nl> + } <nl> + <nl> + isolate - > counters ( ) - > constructed_objects ( ) - > Increment ( ) ; <nl> + isolate - > counters ( ) - > constructed_objects_runtime ( ) - > Increment ( ) ; <nl> + <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_NewObject ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , constructor , 0 ) ; <nl> + return Runtime_NewObjectHelper ( isolate , constructor , <nl> + Handle < AllocationSite > : : null ( ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_NewObjectWithAllocationSite ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , constructor , 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , feedback , 0 ) ; <nl> + Handle < AllocationSite > site ; <nl> + if ( feedback - > IsAllocationSite ( ) ) { <nl> + / / The feedback can be an AllocationSite or undefined . <nl> + site = Handle < AllocationSite > : : cast ( feedback ) ; <nl> + } <nl> + return Runtime_NewObjectHelper ( isolate , constructor , site ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_FinalizeInstanceSize ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSFunction , function , 0 ) ; <nl> + function - > CompleteInobjectSlackTracking ( ) ; <nl> + <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_GlobalProxy ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , global , 0 ) ; <nl> + if ( ! global - > IsJSGlobalObject ( ) ) return isolate - > heap ( ) - > null_value ( ) ; <nl> + return JSGlobalObject : : cast ( global ) - > global_proxy ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_IsAttachedGlobal ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , global , 0 ) ; <nl> + if ( ! global - > IsJSGlobalObject ( ) ) return isolate - > heap ( ) - > false_value ( ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( <nl> + ! JSGlobalObject : : cast ( global ) - > IsDetached ( ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_LookupAccessor ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 3 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , receiver , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , name , 1 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( flag , 2 ) ; <nl> + AccessorComponent component = flag = = 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER ; <nl> + if ( ! receiver - > IsJSObject ( ) ) return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , <nl> + JSObject : : GetAccessor ( Handle < JSObject > : : cast ( receiver ) , name , component ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_LoadMutableDouble ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Smi , index , 1 ) ; <nl> + RUNTIME_ASSERT ( ( index - > value ( ) & 1 ) = = 1 ) ; <nl> + FieldIndex field_index = <nl> + FieldIndex : : ForLoadByFieldIndex ( object - > map ( ) , index - > value ( ) ) ; <nl> + if ( field_index . is_inobject ( ) ) { <nl> + RUNTIME_ASSERT ( field_index . property_index ( ) < <nl> + object - > map ( ) - > inobject_properties ( ) ) ; <nl> + } else { <nl> + RUNTIME_ASSERT ( field_index . outobject_array_index ( ) < <nl> + object - > properties ( ) - > length ( ) ) ; <nl> + } <nl> + Handle < Object > raw_value ( object - > RawFastPropertyAt ( field_index ) , isolate ) ; <nl> + RUNTIME_ASSERT ( raw_value - > IsMutableHeapNumber ( ) ) ; <nl> + return * Object : : WrapForRead ( isolate , raw_value , Representation : : Double ( ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_TryMigrateInstance ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , object , 0 ) ; <nl> + if ( ! object - > IsJSObject ( ) ) return Smi : : FromInt ( 0 ) ; <nl> + Handle < JSObject > js_object = Handle < JSObject > : : cast ( object ) ; <nl> + if ( ! js_object - > map ( ) - > is_deprecated ( ) ) return Smi : : FromInt ( 0 ) ; <nl> + / / This call must not cause lazy deopts , because it ' s called from deferred <nl> + / / code where we can ' t handle lazy deopts for lack of a suitable bailout <nl> + / / ID . So we just try migration and signal failure if necessary , <nl> + / / which will also trigger a deopt . <nl> + if ( ! JSObject : : TryMigrateInstance ( js_object ) ) return Smi : : FromInt ( 0 ) ; <nl> + return * object ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( Runtime_IsJSGlobalProxy ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( obj - > IsJSGlobalProxy ( ) ) ; <nl> + } <nl> + <nl> + <nl> + static bool IsValidAccessor ( Handle < Object > obj ) { <nl> + return obj - > IsUndefined ( ) | | obj - > IsSpecFunction ( ) | | obj - > IsNull ( ) ; <nl> + } <nl> + <nl> + <nl> + / / Implements part of 8 . 12 . 9 DefineOwnProperty . <nl> + / / There are 3 cases that lead here : <nl> + / / Step 4b - define a new accessor property . <nl> + / / Steps 9c & 12 - replace an existing data property with an accessor property . <nl> + / / Step 12 - update an existing accessor property with an accessor or generic <nl> + / / descriptor . <nl> + RUNTIME_FUNCTION ( Runtime_DefineAccessorPropertyUnchecked ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 5 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> + RUNTIME_ASSERT ( ! obj - > IsNull ( ) ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , name , 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , getter , 2 ) ; <nl> + RUNTIME_ASSERT ( IsValidAccessor ( getter ) ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , setter , 3 ) ; <nl> + RUNTIME_ASSERT ( IsValidAccessor ( setter ) ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( unchecked , 4 ) ; <nl> + RUNTIME_ASSERT ( ( unchecked & ~ ( READ_ONLY | DONT_ENUM | DONT_DELETE ) ) = = 0 ) ; <nl> + PropertyAttributes attr = static_cast < PropertyAttributes > ( unchecked ) ; <nl> + <nl> + bool fast = obj - > HasFastProperties ( ) ; <nl> + RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , JSObject : : DefineAccessor ( obj , name , getter , setter , attr ) ) ; <nl> + if ( fast ) JSObject : : MigrateSlowToFast ( obj , 0 ) ; <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + <nl> + <nl> + / / Implements part of 8 . 12 . 9 DefineOwnProperty . <nl> + / / There are 3 cases that lead here : <nl> + / / Step 4a - define a new data property . <nl> + / / Steps 9b & 12 - replace an existing accessor property with a data property . <nl> + / / Step 12 - update an existing data property with a data or generic <nl> + / / descriptor . <nl> + RUNTIME_FUNCTION ( Runtime_DefineDataPropertyUnchecked ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 4 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , js_object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , name , 1 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Object , obj_value , 2 ) ; <nl> + CONVERT_SMI_ARG_CHECKED ( unchecked , 3 ) ; <nl> + RUNTIME_ASSERT ( ( unchecked & ~ ( READ_ONLY | DONT_ENUM | DONT_DELETE ) ) = = 0 ) ; <nl> + PropertyAttributes attr = static_cast < PropertyAttributes > ( unchecked ) ; <nl> + <nl> + LookupIterator it ( js_object , name , LookupIterator : : OWN_SKIP_INTERCEPTOR ) ; <nl> + if ( it . IsFound ( ) & & it . state ( ) = = LookupIterator : : ACCESS_CHECK ) { <nl> + if ( ! isolate - > MayNamedAccess ( js_object , name , v8 : : ACCESS_SET ) ) { <nl> + return isolate - > heap ( ) - > undefined_value ( ) ; <nl> + } <nl> + it . Next ( ) ; <nl> + } <nl> + <nl> + / / Take special care when attributes are different and there is already <nl> + / / a property . <nl> + if ( it . state ( ) = = LookupIterator : : ACCESSOR ) { <nl> + / / Use IgnoreAttributes version since a readonly property may be <nl> + / / overridden and SetProperty does not allow this . <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , <nl> + JSObject : : SetOwnPropertyIgnoreAttributes ( <nl> + js_object , name , obj_value , attr , JSObject : : DONT_FORCE_FIELD ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + Handle < Object > result ; <nl> + ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> + isolate , result , <nl> + Runtime : : DefineObjectProperty ( js_object , name , obj_value , attr ) ) ; <nl> + return * result ; <nl> + } <nl> + <nl> + <nl> + / / Return property without being observable by accessors or interceptors . <nl> + RUNTIME_FUNCTION ( Runtime_GetDataProperty ) { <nl> + HandleScope scope ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> + CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> + return * JSObject : : GetDataProperty ( object , key ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_ValueOf ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> + if ( ! obj - > IsJSValue ( ) ) return obj ; <nl> + return JSValue : : cast ( obj ) - > value ( ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_SetValueOf ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , value , 1 ) ; <nl> + if ( ! obj - > IsJSValue ( ) ) return value ; <nl> + JSValue : : cast ( obj ) - > set_value ( value ) ; <nl> + return value ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_ObjectEquals ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 2 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj1 , 0 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj2 , 1 ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( obj1 = = obj2 ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_IsObject ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> + if ( ! obj - > IsHeapObject ( ) ) return isolate - > heap ( ) - > false_value ( ) ; <nl> + if ( obj - > IsNull ( ) ) return isolate - > heap ( ) - > true_value ( ) ; <nl> + if ( obj - > IsUndetectableObject ( ) ) return isolate - > heap ( ) - > false_value ( ) ; <nl> + Map * map = HeapObject : : cast ( obj ) - > map ( ) ; <nl> + bool is_non_callable_spec_object = <nl> + map - > instance_type ( ) > = FIRST_NONCALLABLE_SPEC_OBJECT_TYPE & & <nl> + map - > instance_type ( ) < = LAST_NONCALLABLE_SPEC_OBJECT_TYPE ; <nl> + return isolate - > heap ( ) - > ToBoolean ( is_non_callable_spec_object ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_IsUndetectableObject ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( obj - > IsUndetectableObject ( ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_IsSpecObject ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> + return isolate - > heap ( ) - > ToBoolean ( obj - > IsSpecObject ( ) ) ; <nl> + } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_ClassOf ) { <nl> + SealHandleScope shs ( isolate ) ; <nl> + DCHECK ( args . length ( ) = = 1 ) ; <nl> + CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> + if ( ! obj - > IsJSReceiver ( ) ) return isolate - > heap ( ) - > null_value ( ) ; <nl> + return JSReceiver : : cast ( obj ) - > class_name ( ) ; <nl> + } <nl> + } <nl> + } / / namespace v8 : : internal <nl> mmm a / src / runtime / runtime - strings . cc <nl> ppp b / src / runtime / runtime - strings . cc <nl> RUNTIME_FUNCTION ( RuntimeReference_StringAdd ) { <nl> SealHandleScope shs ( isolate ) ; <nl> return __RT_impl_Runtime_StringAdd ( args , isolate ) ; <nl> } <nl> + <nl> + <nl> + RUNTIME_FUNCTION ( RuntimeReference_IsStringWrapperSafeForDefaultValueOf ) { <nl> + UNIMPLEMENTED ( ) ; <nl> + return NULL ; <nl> + } <nl> } <nl> } / / namespace v8 : : internal <nl> mmm a / src / runtime / runtime . cc <nl> ppp b / src / runtime / runtime . 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 < stdlib . h > <nl> - # include < limits > <nl> - <nl> # include " src / v8 . h " <nl> <nl> - # include " src / accessors . h " <nl> - # include " src / api . h " <nl> - # include " src / arguments . h " <nl> - # include " src / bailout - reason . h " <nl> - # include " src / base / cpu . h " <nl> - # include " src / base / platform / platform . h " <nl> - # include " src / bootstrapper . h " <nl> - # include " src / conversions . h " <nl> - # include " src / global - handles . h " <nl> - # include " src / isolate - inl . h " <nl> - # include " src / prototype . h " <nl> # include " src / runtime / runtime . h " <nl> # include " src / runtime / runtime - utils . h " <nl> - # include " src / utils . h " <nl> - <nl> <nl> namespace v8 { <nl> namespace internal { <nl> namespace internal { <nl> ObjectPair Runtime_ # # name ( int args_length , Object * * args_object , \ <nl> Isolate * isolate ) ; <nl> <nl> + / / Reference implementation for inlined runtime functions . Only used when the <nl> + / / compiler does not support a certain intrinsic . Don ' t optimize these , but <nl> + / / implement the intrinsic in the respective compiler instead . <nl> + / / TODO ( mstarzinger ) : These are place - holder stubs for TurboFan and will <nl> + / / eventually all have a C + + implementation and this macro will be gone . <nl> # define I ( name , number_of_args , result_size ) \ <nl> Object * RuntimeReference_ # # name ( int args_length , Object * * args_object , \ <nl> Isolate * isolate ) ; <nl> INLINE_FUNCTION_LIST ( I ) <nl> # undef P <nl> <nl> <nl> - MUST_USE_RESULT static MaybeHandle < Object > TransitionElements ( <nl> - Handle < Object > object , ElementsKind to_kind , Isolate * isolate ) { <nl> - HandleScope scope ( isolate ) ; <nl> - if ( ! object - > IsJSObject ( ) ) { <nl> - isolate - > ThrowIllegalOperation ( ) ; <nl> - return MaybeHandle < Object > ( ) ; <nl> - } <nl> - ElementsKind from_kind = <nl> - Handle < JSObject > : : cast ( object ) - > map ( ) - > elements_kind ( ) ; <nl> - if ( Map : : IsValidElementsTransition ( from_kind , to_kind ) ) { <nl> - JSObject : : TransitionElementsKind ( Handle < JSObject > : : cast ( object ) , to_kind ) ; <nl> - return object ; <nl> - } <nl> - isolate - > ThrowIllegalOperation ( ) ; <nl> - return MaybeHandle < Object > ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_GetPrototype ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , obj , 0 ) ; <nl> - / / We don ' t expect access checks to be needed on JSProxy objects . <nl> - DCHECK ( ! obj - > IsAccessCheckNeeded ( ) | | obj - > IsJSObject ( ) ) ; <nl> - PrototypeIterator iter ( isolate , obj , PrototypeIterator : : START_AT_RECEIVER ) ; <nl> - do { <nl> - if ( PrototypeIterator : : GetCurrent ( iter ) - > IsAccessCheckNeeded ( ) & & <nl> - ! isolate - > MayNamedAccess ( <nl> - Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) , <nl> - isolate - > factory ( ) - > proto_string ( ) , v8 : : ACCESS_GET ) ) { <nl> - isolate - > ReportFailedAccessCheck ( <nl> - Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) , <nl> - v8 : : ACCESS_GET ) ; <nl> - RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - iter . AdvanceIgnoringProxies ( ) ; <nl> - if ( PrototypeIterator : : GetCurrent ( iter ) - > IsJSProxy ( ) ) { <nl> - return * PrototypeIterator : : GetCurrent ( iter ) ; <nl> - } <nl> - } while ( ! iter . IsAtEnd ( PrototypeIterator : : END_AT_NON_HIDDEN ) ) ; <nl> - return * PrototypeIterator : : GetCurrent ( iter ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_InternalSetPrototype ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , prototype , 1 ) ; <nl> - DCHECK ( ! obj - > IsAccessCheckNeeded ( ) ) ; <nl> - DCHECK ( ! obj - > map ( ) - > is_observed ( ) ) ; <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , JSObject : : SetPrototype ( obj , prototype , false ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_SetPrototype ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , prototype , 1 ) ; <nl> - if ( obj - > IsAccessCheckNeeded ( ) & & <nl> - ! isolate - > MayNamedAccess ( obj , isolate - > factory ( ) - > proto_string ( ) , <nl> - v8 : : ACCESS_SET ) ) { <nl> - isolate - > ReportFailedAccessCheck ( obj , v8 : : ACCESS_SET ) ; <nl> - RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - if ( obj - > map ( ) - > is_observed ( ) ) { <nl> - Handle < Object > old_value = <nl> - Object : : GetPrototypeSkipHiddenPrototypes ( isolate , obj ) ; <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , JSObject : : SetPrototype ( obj , prototype , true ) ) ; <nl> - <nl> - Handle < Object > new_value = <nl> - Object : : GetPrototypeSkipHiddenPrototypes ( isolate , obj ) ; <nl> - if ( ! new_value - > SameValue ( * old_value ) ) { <nl> - JSObject : : EnqueueChangeRecord ( <nl> - obj , " setPrototype " , isolate - > factory ( ) - > proto_string ( ) , old_value ) ; <nl> - } <nl> - return * result ; <nl> - } <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , JSObject : : SetPrototype ( obj , prototype , true ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_IsInPrototypeChain ) { <nl> - HandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - / / See ECMA - 262 , section 15 . 3 . 5 . 3 , page 88 ( steps 5 - 8 ) . <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , O , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , V , 1 ) ; <nl> - PrototypeIterator iter ( isolate , V , PrototypeIterator : : START_AT_RECEIVER ) ; <nl> - while ( true ) { <nl> - iter . AdvanceIgnoringProxies ( ) ; <nl> - if ( iter . IsAtEnd ( ) ) return isolate - > heap ( ) - > false_value ( ) ; <nl> - if ( iter . IsAtEnd ( O ) ) return isolate - > heap ( ) - > true_value ( ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / / Enumerator used as indices into the array returned from GetOwnProperty <nl> - enum PropertyDescriptorIndices { <nl> - IS_ACCESSOR_INDEX , <nl> - VALUE_INDEX , <nl> - GETTER_INDEX , <nl> - SETTER_INDEX , <nl> - WRITABLE_INDEX , <nl> - ENUMERABLE_INDEX , <nl> - CONFIGURABLE_INDEX , <nl> - DESCRIPTOR_SIZE <nl> - } ; <nl> - <nl> - <nl> - MUST_USE_RESULT static MaybeHandle < Object > GetOwnProperty ( Isolate * isolate , <nl> - Handle < JSObject > obj , <nl> - Handle < Name > name ) { <nl> - Heap * heap = isolate - > heap ( ) ; <nl> - Factory * factory = isolate - > factory ( ) ; <nl> - <nl> - PropertyAttributes attrs ; <nl> - uint32_t index = 0 ; <nl> - Handle < Object > value ; <nl> - MaybeHandle < AccessorPair > maybe_accessors ; <nl> - / / TODO ( verwaest ) : Unify once indexed properties can be handled by the <nl> - / / LookupIterator . <nl> - if ( name - > AsArrayIndex ( & index ) ) { <nl> - / / Get attributes . <nl> - Maybe < PropertyAttributes > maybe = <nl> - JSReceiver : : GetOwnElementAttribute ( obj , index ) ; <nl> - if ( ! maybe . has_value ) return MaybeHandle < Object > ( ) ; <nl> - attrs = maybe . value ; <nl> - if ( attrs = = ABSENT ) return factory - > undefined_value ( ) ; <nl> - <nl> - / / Get AccessorPair if present . <nl> - maybe_accessors = JSObject : : GetOwnElementAccessorPair ( obj , index ) ; <nl> - <nl> - / / Get value if not an AccessorPair . <nl> - if ( maybe_accessors . is_null ( ) ) { <nl> - ASSIGN_RETURN_ON_EXCEPTION ( <nl> - isolate , value , Runtime : : GetElementOrCharAt ( isolate , obj , index ) , <nl> - Object ) ; <nl> - } <nl> - } else { <nl> - / / Get attributes . <nl> - LookupIterator it ( obj , name , LookupIterator : : HIDDEN ) ; <nl> - Maybe < PropertyAttributes > maybe = JSObject : : GetPropertyAttributes ( & it ) ; <nl> - if ( ! maybe . has_value ) return MaybeHandle < Object > ( ) ; <nl> - attrs = maybe . value ; <nl> - if ( attrs = = ABSENT ) return factory - > undefined_value ( ) ; <nl> - <nl> - / / Get AccessorPair if present . <nl> - if ( it . state ( ) = = LookupIterator : : ACCESSOR & & <nl> - it . GetAccessors ( ) - > IsAccessorPair ( ) ) { <nl> - maybe_accessors = Handle < AccessorPair > : : cast ( it . GetAccessors ( ) ) ; <nl> - } <nl> - <nl> - / / Get value if not an AccessorPair . <nl> - if ( maybe_accessors . is_null ( ) ) { <nl> - ASSIGN_RETURN_ON_EXCEPTION ( isolate , value , Object : : GetProperty ( & it ) , <nl> - Object ) ; <nl> - } <nl> - } <nl> - DCHECK ( ! isolate - > has_pending_exception ( ) ) ; <nl> - Handle < FixedArray > elms = factory - > NewFixedArray ( DESCRIPTOR_SIZE ) ; <nl> - elms - > set ( ENUMERABLE_INDEX , heap - > ToBoolean ( ( attrs & DONT_ENUM ) = = 0 ) ) ; <nl> - elms - > set ( CONFIGURABLE_INDEX , heap - > ToBoolean ( ( attrs & DONT_DELETE ) = = 0 ) ) ; <nl> - elms - > set ( IS_ACCESSOR_INDEX , heap - > ToBoolean ( ! maybe_accessors . is_null ( ) ) ) ; <nl> - <nl> - Handle < AccessorPair > accessors ; <nl> - if ( maybe_accessors . ToHandle ( & accessors ) ) { <nl> - Handle < Object > getter ( accessors - > GetComponent ( ACCESSOR_GETTER ) , isolate ) ; <nl> - Handle < Object > setter ( accessors - > GetComponent ( ACCESSOR_SETTER ) , isolate ) ; <nl> - elms - > set ( GETTER_INDEX , * getter ) ; <nl> - elms - > set ( SETTER_INDEX , * setter ) ; <nl> - } else { <nl> - elms - > set ( WRITABLE_INDEX , heap - > ToBoolean ( ( attrs & READ_ONLY ) = = 0 ) ) ; <nl> - elms - > set ( VALUE_INDEX , * value ) ; <nl> - } <nl> - <nl> - return factory - > NewJSArrayWithElements ( elms ) ; <nl> - } <nl> - <nl> - <nl> - / / Returns an array with the property description : <nl> - / / if args [ 1 ] is not a property on args [ 0 ] <nl> - / / returns undefined <nl> - / / if args [ 1 ] is a data property on args [ 0 ] <nl> - / / [ false , value , Writeable , Enumerable , Configurable ] <nl> - / / if args [ 1 ] is an accessor on args [ 0 ] <nl> - / / [ true , GetFunction , SetFunction , Enumerable , Configurable ] <nl> - RUNTIME_FUNCTION ( Runtime_GetOwnProperty ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , name , 1 ) ; <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate , result , <nl> - GetOwnProperty ( isolate , obj , name ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_PreventExtensions ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate , result , <nl> - JSObject : : PreventExtensions ( obj ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_IsExtensible ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( JSObject , obj , 0 ) ; <nl> - if ( obj - > IsJSGlobalProxy ( ) ) { <nl> - PrototypeIterator iter ( isolate , obj ) ; <nl> - if ( iter . IsAtEnd ( ) ) return isolate - > heap ( ) - > false_value ( ) ; <nl> - DCHECK ( iter . GetCurrent ( ) - > IsJSGlobalObject ( ) ) ; <nl> - obj = JSObject : : cast ( iter . GetCurrent ( ) ) ; <nl> - } <nl> - return isolate - > heap ( ) - > ToBoolean ( obj - > map ( ) - > is_extensible ( ) ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_CreateApiFunction ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( FunctionTemplateInfo , data , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , prototype , 1 ) ; <nl> - return * isolate - > factory ( ) - > CreateApiFunction ( data , prototype ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_IsTemplate ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , arg , 0 ) ; <nl> - bool result = arg - > IsObjectTemplateInfo ( ) | | arg - > IsFunctionTemplateInfo ( ) ; <nl> - return isolate - > heap ( ) - > ToBoolean ( result ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_GetTemplateField ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_CHECKED ( HeapObject , templ , 0 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( index , 1 ) ; <nl> - int offset = index * kPointerSize + HeapObject : : kHeaderSize ; <nl> - InstanceType type = templ - > map ( ) - > instance_type ( ) ; <nl> - RUNTIME_ASSERT ( type = = FUNCTION_TEMPLATE_INFO_TYPE | | <nl> - type = = OBJECT_TEMPLATE_INFO_TYPE ) ; <nl> - RUNTIME_ASSERT ( offset > 0 ) ; <nl> - if ( type = = FUNCTION_TEMPLATE_INFO_TYPE ) { <nl> - RUNTIME_ASSERT ( offset < FunctionTemplateInfo : : kSize ) ; <nl> - } else { <nl> - RUNTIME_ASSERT ( offset < ObjectTemplateInfo : : kSize ) ; <nl> - } <nl> - return * HeapObject : : RawField ( templ , offset ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_DisableAccessChecks ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( HeapObject , object , 0 ) ; <nl> - Handle < Map > old_map ( object - > map ( ) ) ; <nl> - bool needs_access_checks = old_map - > is_access_check_needed ( ) ; <nl> - if ( needs_access_checks ) { <nl> - / / Copy map so it won ' t interfere constructor ' s initial map . <nl> - Handle < Map > new_map = Map : : Copy ( old_map ) ; <nl> - new_map - > set_is_access_check_needed ( false ) ; <nl> - JSObject : : MigrateToMap ( Handle < JSObject > : : cast ( object ) , new_map ) ; <nl> - } <nl> - return isolate - > heap ( ) - > ToBoolean ( needs_access_checks ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_EnableAccessChecks ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - Handle < Map > old_map ( object - > map ( ) ) ; <nl> - RUNTIME_ASSERT ( ! old_map - > is_access_check_needed ( ) ) ; <nl> - / / Copy map so it won ' t interfere constructor ' s initial map . <nl> - Handle < Map > new_map = Map : : Copy ( old_map ) ; <nl> - new_map - > set_is_access_check_needed ( true ) ; <nl> - JSObject : : MigrateToMap ( object , new_map ) ; <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_OptimizeObjectForAddingMultipleProperties ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( properties , 1 ) ; <nl> - / / Conservative upper limit to prevent fuzz tests from going OOM . <nl> - RUNTIME_ASSERT ( properties < = 100000 ) ; <nl> - if ( object - > HasFastProperties ( ) & & ! object - > IsJSGlobalProxy ( ) ) { <nl> - JSObject : : NormalizeProperties ( object , KEEP_INOBJECT_PROPERTIES , properties ) ; <nl> - } <nl> - return * object ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_FinishArrayPrototypeSetup ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSArray , prototype , 0 ) ; <nl> - Object * length = prototype - > length ( ) ; <nl> - RUNTIME_ASSERT ( length - > IsSmi ( ) & & Smi : : cast ( length ) - > value ( ) = = 0 ) ; <nl> - RUNTIME_ASSERT ( prototype - > HasFastSmiOrObjectElements ( ) ) ; <nl> - / / This is necessary to enable fast checks for absence of elements <nl> - / / on Array . prototype and below . <nl> - prototype - > set_elements ( isolate - > heap ( ) - > empty_fixed_array ( ) ) ; <nl> - return Smi : : FromInt ( 0 ) ; <nl> - } <nl> - <nl> - <nl> - static void InstallBuiltin ( Isolate * isolate , Handle < JSObject > holder , <nl> - const char * name , Builtins : : Name builtin_name ) { <nl> - Handle < String > key = isolate - > factory ( ) - > InternalizeUtf8String ( name ) ; <nl> - Handle < Code > code ( isolate - > builtins ( ) - > builtin ( builtin_name ) ) ; <nl> - Handle < JSFunction > optimized = <nl> - isolate - > factory ( ) - > NewFunctionWithoutPrototype ( key , code ) ; <nl> - optimized - > shared ( ) - > DontAdaptArguments ( ) ; <nl> - JSObject : : AddProperty ( holder , key , optimized , NONE ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_SpecialArrayFunctions ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 0 ) ; <nl> - Handle < JSObject > holder = <nl> - isolate - > factory ( ) - > NewJSObject ( isolate - > object_function ( ) ) ; <nl> - <nl> - InstallBuiltin ( isolate , holder , " pop " , Builtins : : kArrayPop ) ; <nl> - InstallBuiltin ( isolate , holder , " push " , Builtins : : kArrayPush ) ; <nl> - InstallBuiltin ( isolate , holder , " shift " , Builtins : : kArrayShift ) ; <nl> - InstallBuiltin ( isolate , holder , " unshift " , Builtins : : kArrayUnshift ) ; <nl> - InstallBuiltin ( isolate , holder , " slice " , Builtins : : kArraySlice ) ; <nl> - InstallBuiltin ( isolate , holder , " splice " , Builtins : : kArraySplice ) ; <nl> - InstallBuiltin ( isolate , holder , " concat " , Builtins : : kArrayConcat ) ; <nl> - <nl> - return * holder ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_ObjectFreeze ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - <nl> - / / % ObjectFreeze is a fast path and these cases are handled elsewhere . <nl> - RUNTIME_ASSERT ( ! object - > HasSloppyArgumentsElements ( ) & & <nl> - ! object - > map ( ) - > is_observed ( ) & & ! object - > IsJSProxy ( ) ) ; <nl> - <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( isolate , result , JSObject : : Freeze ( object ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - / / Returns a single character string where first character equals <nl> - / / string - > Get ( index ) . <nl> - static Handle < Object > GetCharAt ( Handle < String > string , uint32_t index ) { <nl> - if ( index < static_cast < uint32_t > ( string - > length ( ) ) ) { <nl> - Factory * factory = string - > GetIsolate ( ) - > factory ( ) ; <nl> - return factory - > LookupSingleCharacterStringFromCode ( <nl> - String : : Flatten ( string ) - > Get ( index ) ) ; <nl> - } <nl> - return Execution : : CharAt ( string , index ) ; <nl> - } <nl> - <nl> - <nl> - MaybeHandle < Object > Runtime : : GetElementOrCharAt ( Isolate * isolate , <nl> - Handle < Object > object , <nl> - uint32_t index ) { <nl> - / / Handle [ ] indexing on Strings <nl> - if ( object - > IsString ( ) ) { <nl> - Handle < Object > result = GetCharAt ( Handle < String > : : cast ( object ) , index ) ; <nl> - if ( ! result - > IsUndefined ( ) ) return result ; <nl> - } <nl> - <nl> - / / Handle [ ] indexing on String objects <nl> - if ( object - > IsStringObjectWithCharacterAt ( index ) ) { <nl> - Handle < JSValue > js_value = Handle < JSValue > : : cast ( object ) ; <nl> - Handle < Object > result = <nl> - GetCharAt ( Handle < String > ( String : : cast ( js_value - > value ( ) ) ) , index ) ; <nl> - if ( ! result - > IsUndefined ( ) ) return result ; <nl> - } <nl> - <nl> - Handle < Object > result ; <nl> - if ( object - > IsString ( ) | | object - > IsNumber ( ) | | object - > IsBoolean ( ) ) { <nl> - PrototypeIterator iter ( isolate , object ) ; <nl> - return Object : : GetElement ( isolate , PrototypeIterator : : GetCurrent ( iter ) , <nl> - index ) ; <nl> - } else { <nl> - return Object : : GetElement ( isolate , object , index ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - MaybeHandle < Name > Runtime : : ToName ( Isolate * isolate , Handle < Object > key ) { <nl> - if ( key - > IsName ( ) ) { <nl> - return Handle < Name > : : cast ( key ) ; <nl> - } else { <nl> - Handle < Object > converted ; <nl> - ASSIGN_RETURN_ON_EXCEPTION ( isolate , converted , <nl> - Execution : : ToString ( isolate , key ) , Name ) ; <nl> - return Handle < Name > : : cast ( converted ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - MaybeHandle < Object > Runtime : : HasObjectProperty ( Isolate * isolate , <nl> - Handle < JSReceiver > object , <nl> - Handle < Object > key ) { <nl> - Maybe < bool > maybe ; <nl> - / / Check if the given key is an array index . <nl> - uint32_t index ; <nl> - if ( key - > ToArrayIndex ( & index ) ) { <nl> - maybe = JSReceiver : : HasElement ( object , index ) ; <nl> - } else { <nl> - / / Convert the key to a name - possibly by calling back into JavaScript . <nl> - Handle < Name > name ; <nl> - ASSIGN_RETURN_ON_EXCEPTION ( isolate , name , ToName ( isolate , key ) , Object ) ; <nl> - <nl> - maybe = JSReceiver : : HasProperty ( object , name ) ; <nl> - } <nl> - <nl> - if ( ! maybe . has_value ) return MaybeHandle < Object > ( ) ; <nl> - return isolate - > factory ( ) - > ToBoolean ( maybe . value ) ; <nl> - } <nl> - <nl> - <nl> - MaybeHandle < Object > Runtime : : GetObjectProperty ( Isolate * isolate , <nl> - Handle < Object > object , <nl> - Handle < Object > key ) { <nl> - if ( object - > IsUndefined ( ) | | object - > IsNull ( ) ) { <nl> - Handle < Object > args [ 2 ] = { key , object } ; <nl> - THROW_NEW_ERROR ( isolate , NewTypeError ( " non_object_property_load " , <nl> - HandleVector ( args , 2 ) ) , <nl> - Object ) ; <nl> - } <nl> - <nl> - / / Check if the given key is an array index . <nl> - uint32_t index ; <nl> - if ( key - > ToArrayIndex ( & index ) ) { <nl> - return GetElementOrCharAt ( isolate , object , index ) ; <nl> - } <nl> - <nl> - / / Convert the key to a name - possibly by calling back into JavaScript . <nl> - Handle < Name > name ; <nl> - ASSIGN_RETURN_ON_EXCEPTION ( isolate , name , ToName ( isolate , key ) , Object ) ; <nl> - <nl> - / / Check if the name is trivially convertible to an index and get <nl> - / / the element if so . <nl> - if ( name - > AsArrayIndex ( & index ) ) { <nl> - return GetElementOrCharAt ( isolate , object , index ) ; <nl> - } else { <nl> - return Object : : GetProperty ( object , name ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_GetProperty ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , key , 1 ) ; <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , Runtime : : GetObjectProperty ( isolate , object , key ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - / / KeyedGetProperty is called from KeyedLoadIC : : GenerateGeneric . <nl> - RUNTIME_FUNCTION ( Runtime_KeyedGetProperty ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , receiver_obj , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , key_obj , 1 ) ; <nl> - <nl> - / / Fast cases for getting named properties of the receiver JSObject <nl> - / / itself . <nl> - / / <nl> - / / The global proxy objects has to be excluded since LookupOwn on <nl> - / / the global proxy object can return a valid result even though the <nl> - / / global proxy object never has properties . This is the case <nl> - / / because the global proxy object forwards everything to its hidden <nl> - / / prototype including own lookups . <nl> - / / <nl> - / / Additionally , we need to make sure that we do not cache results <nl> - / / for objects that require access checks . <nl> - if ( receiver_obj - > IsJSObject ( ) ) { <nl> - if ( ! receiver_obj - > IsJSGlobalProxy ( ) & & <nl> - ! receiver_obj - > IsAccessCheckNeeded ( ) & & key_obj - > IsName ( ) ) { <nl> - DisallowHeapAllocation no_allocation ; <nl> - Handle < JSObject > receiver = Handle < JSObject > : : cast ( receiver_obj ) ; <nl> - Handle < Name > key = Handle < Name > : : cast ( key_obj ) ; <nl> - if ( receiver - > HasFastProperties ( ) ) { <nl> - / / Attempt to use lookup cache . <nl> - Handle < Map > receiver_map ( receiver - > map ( ) , isolate ) ; <nl> - KeyedLookupCache * keyed_lookup_cache = isolate - > keyed_lookup_cache ( ) ; <nl> - int index = keyed_lookup_cache - > Lookup ( receiver_map , key ) ; <nl> - if ( index ! = - 1 ) { <nl> - / / Doubles are not cached , so raw read the value . <nl> - return receiver - > RawFastPropertyAt ( <nl> - FieldIndex : : ForKeyedLookupCacheIndex ( * receiver_map , index ) ) ; <nl> - } <nl> - / / Lookup cache miss . Perform lookup and update the cache if <nl> - / / appropriate . <nl> - LookupIterator it ( receiver , key , LookupIterator : : OWN ) ; <nl> - if ( it . state ( ) = = LookupIterator : : DATA & & <nl> - it . property_details ( ) . type ( ) = = FIELD ) { <nl> - FieldIndex field_index = it . GetFieldIndex ( ) ; <nl> - / / Do not track double fields in the keyed lookup cache . Reading <nl> - / / double values requires boxing . <nl> - if ( ! it . representation ( ) . IsDouble ( ) ) { <nl> - keyed_lookup_cache - > Update ( receiver_map , key , <nl> - field_index . GetKeyedLookupCacheIndex ( ) ) ; <nl> - } <nl> - AllowHeapAllocation allow_allocation ; <nl> - return * JSObject : : FastPropertyAt ( receiver , it . representation ( ) , <nl> - field_index ) ; <nl> - } <nl> - } else { <nl> - / / Attempt dictionary lookup . <nl> - NameDictionary * dictionary = receiver - > property_dictionary ( ) ; <nl> - int entry = dictionary - > FindEntry ( key ) ; <nl> - if ( ( entry ! = NameDictionary : : kNotFound ) & & <nl> - ( dictionary - > DetailsAt ( entry ) . type ( ) = = NORMAL ) ) { <nl> - Object * value = dictionary - > ValueAt ( entry ) ; <nl> - if ( ! receiver - > IsGlobalObject ( ) ) return value ; <nl> - value = PropertyCell : : cast ( value ) - > value ( ) ; <nl> - if ( ! value - > IsTheHole ( ) ) return value ; <nl> - / / If value is the hole ( meaning , absent ) do the general lookup . <nl> - } <nl> - } <nl> - } else if ( key_obj - > IsSmi ( ) ) { <nl> - / / JSObject without a name key . If the key is a Smi , check for a <nl> - / / definite out - of - bounds access to elements , which is a strong indicator <nl> - / / that subsequent accesses will also call the runtime . Proactively <nl> - / / transition elements to FAST_ * _ELEMENTS to avoid excessive boxing of <nl> - / / doubles for those future calls in the case that the elements would <nl> - / / become FAST_DOUBLE_ELEMENTS . <nl> - Handle < JSObject > js_object = Handle < JSObject > : : cast ( receiver_obj ) ; <nl> - ElementsKind elements_kind = js_object - > GetElementsKind ( ) ; <nl> - if ( IsFastDoubleElementsKind ( elements_kind ) ) { <nl> - Handle < Smi > key = Handle < Smi > : : cast ( key_obj ) ; <nl> - if ( key - > value ( ) > = js_object - > elements ( ) - > length ( ) ) { <nl> - if ( IsFastHoleyElementsKind ( elements_kind ) ) { <nl> - elements_kind = FAST_HOLEY_ELEMENTS ; <nl> - } else { <nl> - elements_kind = FAST_ELEMENTS ; <nl> - } <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , TransitionElements ( js_object , elements_kind , isolate ) ) ; <nl> - } <nl> - } else { <nl> - DCHECK ( IsFastSmiOrObjectElementsKind ( elements_kind ) | | <nl> - ! IsFastElementsKind ( elements_kind ) ) ; <nl> - } <nl> - } <nl> - } else if ( receiver_obj - > IsString ( ) & & key_obj - > IsSmi ( ) ) { <nl> - / / Fast case for string indexing using [ ] with a smi index . <nl> - Handle < String > str = Handle < String > : : cast ( receiver_obj ) ; <nl> - int index = args . smi_at ( 1 ) ; <nl> - if ( index > = 0 & & index < str - > length ( ) ) { <nl> - return * GetCharAt ( str , index ) ; <nl> - } <nl> - } <nl> - <nl> - / / Fall back to GetObjectProperty . <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , <nl> - Runtime : : GetObjectProperty ( isolate , receiver_obj , key_obj ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - static bool IsValidAccessor ( Handle < Object > obj ) { <nl> - return obj - > IsUndefined ( ) | | obj - > IsSpecFunction ( ) | | obj - > IsNull ( ) ; <nl> - } <nl> - <nl> - <nl> - / / Transform getter or setter into something DefineAccessor can handle . <nl> - static Handle < Object > InstantiateAccessorComponent ( Isolate * isolate , <nl> - Handle < Object > component ) { <nl> - if ( component - > IsUndefined ( ) ) return isolate - > factory ( ) - > undefined_value ( ) ; <nl> - Handle < FunctionTemplateInfo > info = <nl> - Handle < FunctionTemplateInfo > : : cast ( component ) ; <nl> - return Utils : : OpenHandle ( * Utils : : ToLocal ( info ) - > GetFunction ( ) ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_DefineApiAccessorProperty ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 5 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , name , 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , getter , 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , setter , 3 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( attribute , 4 ) ; <nl> - RUNTIME_ASSERT ( getter - > IsUndefined ( ) | | getter - > IsFunctionTemplateInfo ( ) ) ; <nl> - RUNTIME_ASSERT ( setter - > IsUndefined ( ) | | setter - > IsFunctionTemplateInfo ( ) ) ; <nl> - RUNTIME_ASSERT ( PropertyDetails : : AttributesField : : is_valid ( <nl> - static_cast < PropertyAttributes > ( attribute ) ) ) ; <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , JSObject : : DefineAccessor ( <nl> - object , name , InstantiateAccessorComponent ( isolate , getter ) , <nl> - InstantiateAccessorComponent ( isolate , setter ) , <nl> - static_cast < PropertyAttributes > ( attribute ) ) ) ; <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - / / Implements part of 8 . 12 . 9 DefineOwnProperty . <nl> - / / There are 3 cases that lead here : <nl> - / / Step 4b - define a new accessor property . <nl> - / / Steps 9c & 12 - replace an existing data property with an accessor property . <nl> - / / Step 12 - update an existing accessor property with an accessor or generic <nl> - / / descriptor . <nl> - RUNTIME_FUNCTION ( Runtime_DefineAccessorPropertyUnchecked ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 5 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> - RUNTIME_ASSERT ( ! obj - > IsNull ( ) ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , name , 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , getter , 2 ) ; <nl> - RUNTIME_ASSERT ( IsValidAccessor ( getter ) ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , setter , 3 ) ; <nl> - RUNTIME_ASSERT ( IsValidAccessor ( setter ) ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( unchecked , 4 ) ; <nl> - RUNTIME_ASSERT ( ( unchecked & ~ ( READ_ONLY | DONT_ENUM | DONT_DELETE ) ) = = 0 ) ; <nl> - PropertyAttributes attr = static_cast < PropertyAttributes > ( unchecked ) ; <nl> - <nl> - bool fast = obj - > HasFastProperties ( ) ; <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , JSObject : : DefineAccessor ( obj , name , getter , setter , attr ) ) ; <nl> - if ( fast ) JSObject : : MigrateSlowToFast ( obj , 0 ) ; <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - / / Implements part of 8 . 12 . 9 DefineOwnProperty . <nl> - / / There are 3 cases that lead here : <nl> - / / Step 4a - define a new data property . <nl> - / / Steps 9b & 12 - replace an existing accessor property with a data property . <nl> - / / Step 12 - update an existing data property with a data or generic <nl> - / / descriptor . <nl> - RUNTIME_FUNCTION ( Runtime_DefineDataPropertyUnchecked ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 4 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , js_object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , name , 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , obj_value , 2 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( unchecked , 3 ) ; <nl> - RUNTIME_ASSERT ( ( unchecked & ~ ( READ_ONLY | DONT_ENUM | DONT_DELETE ) ) = = 0 ) ; <nl> - PropertyAttributes attr = static_cast < PropertyAttributes > ( unchecked ) ; <nl> - <nl> - LookupIterator it ( js_object , name , LookupIterator : : OWN_SKIP_INTERCEPTOR ) ; <nl> - if ( it . IsFound ( ) & & it . state ( ) = = LookupIterator : : ACCESS_CHECK ) { <nl> - if ( ! isolate - > MayNamedAccess ( js_object , name , v8 : : ACCESS_SET ) ) { <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - it . Next ( ) ; <nl> - } <nl> - <nl> - / / Take special care when attributes are different and there is already <nl> - / / a property . <nl> - if ( it . state ( ) = = LookupIterator : : ACCESSOR ) { <nl> - / / Use IgnoreAttributes version since a readonly property may be <nl> - / / overridden and SetProperty does not allow this . <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , <nl> - JSObject : : SetOwnPropertyIgnoreAttributes ( <nl> - js_object , name , obj_value , attr , JSObject : : DONT_FORCE_FIELD ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , <nl> - Runtime : : DefineObjectProperty ( js_object , name , obj_value , attr ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - / / Return property without being observable by accessors or interceptors . <nl> - RUNTIME_FUNCTION ( Runtime_GetDataProperty ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> - return * JSObject : : GetDataProperty ( object , key ) ; <nl> - } <nl> - <nl> - <nl> - MaybeHandle < Object > Runtime : : SetObjectProperty ( Isolate * isolate , <nl> - Handle < Object > object , <nl> - Handle < Object > key , <nl> - Handle < Object > value , <nl> - StrictMode strict_mode ) { <nl> - if ( object - > IsUndefined ( ) | | object - > IsNull ( ) ) { <nl> - Handle < Object > args [ 2 ] = { key , object } ; <nl> - THROW_NEW_ERROR ( isolate , NewTypeError ( " non_object_property_store " , <nl> - HandleVector ( args , 2 ) ) , <nl> - Object ) ; <nl> - } <nl> - <nl> - if ( object - > IsJSProxy ( ) ) { <nl> - Handle < Object > name_object ; <nl> - if ( key - > IsSymbol ( ) ) { <nl> - name_object = key ; <nl> - } else { <nl> - ASSIGN_RETURN_ON_EXCEPTION ( isolate , name_object , <nl> - Execution : : ToString ( isolate , key ) , Object ) ; <nl> - } <nl> - Handle < Name > name = Handle < Name > : : cast ( name_object ) ; <nl> - return Object : : SetProperty ( Handle < JSProxy > : : cast ( object ) , name , value , <nl> - strict_mode ) ; <nl> - } <nl> - <nl> - / / Check if the given key is an array index . <nl> - uint32_t index ; <nl> - if ( key - > ToArrayIndex ( & index ) ) { <nl> - / / TODO ( verwaest ) : Support non - JSObject receivers . <nl> - if ( ! object - > IsJSObject ( ) ) return value ; <nl> - Handle < JSObject > js_object = Handle < JSObject > : : cast ( object ) ; <nl> - <nl> - / / In Firefox / SpiderMonkey , Safari and Opera you can access the characters <nl> - / / of a string using [ ] notation . We need to support this too in <nl> - / / JavaScript . <nl> - / / In the case of a String object we just need to redirect the assignment to <nl> - / / the underlying string if the index is in range . Since the underlying <nl> - / / string does nothing with the assignment then we can ignore such <nl> - / / assignments . <nl> - if ( js_object - > IsStringObjectWithCharacterAt ( index ) ) { <nl> - return value ; <nl> - } <nl> - <nl> - JSObject : : ValidateElements ( js_object ) ; <nl> - if ( js_object - > HasExternalArrayElements ( ) | | <nl> - js_object - > HasFixedTypedArrayElements ( ) ) { <nl> - if ( ! value - > IsNumber ( ) & & ! value - > IsUndefined ( ) ) { <nl> - ASSIGN_RETURN_ON_EXCEPTION ( isolate , value , <nl> - Execution : : ToNumber ( isolate , value ) , Object ) ; <nl> - } <nl> - } <nl> - <nl> - MaybeHandle < Object > result = JSObject : : SetElement ( <nl> - js_object , index , value , NONE , strict_mode , true , SET_PROPERTY ) ; <nl> - JSObject : : ValidateElements ( js_object ) ; <nl> - <nl> - return result . is_null ( ) ? result : value ; <nl> - } <nl> - <nl> - if ( key - > IsName ( ) ) { <nl> - Handle < Name > name = Handle < Name > : : cast ( key ) ; <nl> - if ( name - > AsArrayIndex ( & index ) ) { <nl> - / / TODO ( verwaest ) : Support non - JSObject receivers . <nl> - if ( ! object - > IsJSObject ( ) ) return value ; <nl> - Handle < JSObject > js_object = Handle < JSObject > : : cast ( object ) ; <nl> - if ( js_object - > HasExternalArrayElements ( ) ) { <nl> - if ( ! value - > IsNumber ( ) & & ! value - > IsUndefined ( ) ) { <nl> - ASSIGN_RETURN_ON_EXCEPTION ( <nl> - isolate , value , Execution : : ToNumber ( isolate , value ) , Object ) ; <nl> - } <nl> - } <nl> - return JSObject : : SetElement ( js_object , index , value , NONE , strict_mode , <nl> - true , SET_PROPERTY ) ; <nl> - } else { <nl> - if ( name - > IsString ( ) ) name = String : : Flatten ( Handle < String > : : cast ( name ) ) ; <nl> - return Object : : SetProperty ( object , name , value , strict_mode ) ; <nl> - } <nl> - } <nl> - <nl> - / / Call - back into JavaScript to convert the key to a string . <nl> - Handle < Object > converted ; <nl> - ASSIGN_RETURN_ON_EXCEPTION ( isolate , converted , <nl> - Execution : : ToString ( isolate , key ) , Object ) ; <nl> - Handle < String > name = Handle < String > : : cast ( converted ) ; <nl> - <nl> - if ( name - > AsArrayIndex ( & index ) ) { <nl> - / / TODO ( verwaest ) : Support non - JSObject receivers . <nl> - if ( ! object - > IsJSObject ( ) ) return value ; <nl> - Handle < JSObject > js_object = Handle < JSObject > : : cast ( object ) ; <nl> - return JSObject : : SetElement ( js_object , index , value , NONE , strict_mode , <nl> - true , SET_PROPERTY ) ; <nl> - } <nl> - return Object : : SetProperty ( object , name , value , strict_mode ) ; <nl> - } <nl> - <nl> - <nl> - MaybeHandle < Object > Runtime : : DefineObjectProperty ( Handle < JSObject > js_object , <nl> - Handle < Object > key , <nl> - Handle < Object > value , <nl> - PropertyAttributes attr ) { <nl> - Isolate * isolate = js_object - > GetIsolate ( ) ; <nl> - / / Check if the given key is an array index . <nl> - uint32_t index ; <nl> - if ( key - > ToArrayIndex ( & index ) ) { <nl> - / / In Firefox / SpiderMonkey , Safari and Opera you can access the characters <nl> - / / of a string using [ ] notation . We need to support this too in <nl> - / / JavaScript . <nl> - / / In the case of a String object we just need to redirect the assignment to <nl> - / / the underlying string if the index is in range . Since the underlying <nl> - / / string does nothing with the assignment then we can ignore such <nl> - / / assignments . <nl> - if ( js_object - > IsStringObjectWithCharacterAt ( index ) ) { <nl> - return value ; <nl> - } <nl> - <nl> - return JSObject : : SetElement ( js_object , index , value , attr , SLOPPY , false , <nl> - DEFINE_PROPERTY ) ; <nl> - } <nl> - <nl> - if ( key - > IsName ( ) ) { <nl> - Handle < Name > name = Handle < Name > : : cast ( key ) ; <nl> - if ( name - > AsArrayIndex ( & index ) ) { <nl> - return JSObject : : SetElement ( js_object , index , value , attr , SLOPPY , false , <nl> - DEFINE_PROPERTY ) ; <nl> - } else { <nl> - if ( name - > IsString ( ) ) name = String : : Flatten ( Handle < String > : : cast ( name ) ) ; <nl> - return JSObject : : SetOwnPropertyIgnoreAttributes ( js_object , name , value , <nl> - attr ) ; <nl> - } <nl> - } <nl> - <nl> - / / Call - back into JavaScript to convert the key to a string . <nl> - Handle < Object > converted ; <nl> - ASSIGN_RETURN_ON_EXCEPTION ( isolate , converted , <nl> - Execution : : ToString ( isolate , key ) , Object ) ; <nl> - Handle < String > name = Handle < String > : : cast ( converted ) ; <nl> - <nl> - if ( name - > AsArrayIndex ( & index ) ) { <nl> - return JSObject : : SetElement ( js_object , index , value , attr , SLOPPY , false , <nl> - DEFINE_PROPERTY ) ; <nl> - } else { <nl> - return JSObject : : SetOwnPropertyIgnoreAttributes ( js_object , name , value , <nl> - attr ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - MaybeHandle < Object > Runtime : : DeleteObjectProperty ( Isolate * isolate , <nl> - Handle < JSReceiver > receiver , <nl> - Handle < Object > key , <nl> - JSReceiver : : DeleteMode mode ) { <nl> - / / Check if the given key is an array index . <nl> - uint32_t index ; <nl> - if ( key - > ToArrayIndex ( & index ) ) { <nl> - / / In Firefox / SpiderMonkey , Safari and Opera you can access the <nl> - / / characters of a string using [ ] notation . In the case of a <nl> - / / String object we just need to redirect the deletion to the <nl> - / / underlying string if the index is in range . Since the <nl> - / / underlying string does nothing with the deletion , we can ignore <nl> - / / such deletions . <nl> - if ( receiver - > IsStringObjectWithCharacterAt ( index ) ) { <nl> - return isolate - > factory ( ) - > true_value ( ) ; <nl> - } <nl> - <nl> - return JSReceiver : : DeleteElement ( receiver , index , mode ) ; <nl> - } <nl> - <nl> - Handle < Name > name ; <nl> - if ( key - > IsName ( ) ) { <nl> - name = Handle < Name > : : cast ( key ) ; <nl> - } else { <nl> - / / Call - back into JavaScript to convert the key to a string . <nl> - Handle < Object > converted ; <nl> - ASSIGN_RETURN_ON_EXCEPTION ( isolate , converted , <nl> - Execution : : ToString ( isolate , key ) , Object ) ; <nl> - name = Handle < String > : : cast ( converted ) ; <nl> - } <nl> - <nl> - if ( name - > IsString ( ) ) name = String : : Flatten ( Handle < String > : : cast ( name ) ) ; <nl> - return JSReceiver : : DeleteProperty ( receiver , name , mode ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_AddNamedProperty ) { <nl> - HandleScope scope ( isolate ) ; <nl> - RUNTIME_ASSERT ( args . length ( ) = = 4 ) ; <nl> - <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( unchecked_attributes , 3 ) ; <nl> - RUNTIME_ASSERT ( <nl> - ( unchecked_attributes & ~ ( READ_ONLY | DONT_ENUM | DONT_DELETE ) ) = = 0 ) ; <nl> - / / Compute attributes . <nl> - PropertyAttributes attributes = <nl> - static_cast < PropertyAttributes > ( unchecked_attributes ) ; <nl> - <nl> - # ifdef DEBUG <nl> - uint32_t index = 0 ; <nl> - DCHECK ( ! key - > ToArrayIndex ( & index ) ) ; <nl> - LookupIterator it ( object , key , LookupIterator : : OWN_SKIP_INTERCEPTOR ) ; <nl> - Maybe < PropertyAttributes > maybe = JSReceiver : : GetPropertyAttributes ( & it ) ; <nl> - if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> - RUNTIME_ASSERT ( ! it . IsFound ( ) ) ; <nl> - # endif <nl> - <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , <nl> - JSObject : : SetOwnPropertyIgnoreAttributes ( object , key , value , attributes ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_AddPropertyForTemplate ) { <nl> - HandleScope scope ( isolate ) ; <nl> - RUNTIME_ASSERT ( args . length ( ) = = 4 ) ; <nl> - <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , key , 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( unchecked_attributes , 3 ) ; <nl> - RUNTIME_ASSERT ( <nl> - ( unchecked_attributes & ~ ( READ_ONLY | DONT_ENUM | DONT_DELETE ) ) = = 0 ) ; <nl> - / / Compute attributes . <nl> - PropertyAttributes attributes = <nl> - static_cast < PropertyAttributes > ( unchecked_attributes ) ; <nl> - <nl> - # ifdef DEBUG <nl> - bool duplicate ; <nl> - if ( key - > IsName ( ) ) { <nl> - LookupIterator it ( object , Handle < Name > : : cast ( key ) , <nl> - LookupIterator : : OWN_SKIP_INTERCEPTOR ) ; <nl> - Maybe < PropertyAttributes > maybe = JSReceiver : : GetPropertyAttributes ( & it ) ; <nl> - DCHECK ( maybe . has_value ) ; <nl> - duplicate = it . IsFound ( ) ; <nl> - } else { <nl> - uint32_t index = 0 ; <nl> - RUNTIME_ASSERT ( key - > ToArrayIndex ( & index ) ) ; <nl> - Maybe < bool > maybe = JSReceiver : : HasOwnElement ( object , index ) ; <nl> - if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> - duplicate = maybe . value ; <nl> - } <nl> - if ( duplicate ) { <nl> - Handle < Object > args [ 1 ] = { key } ; <nl> - THROW_NEW_ERROR_RETURN_FAILURE ( <nl> - isolate , <nl> - NewTypeError ( " duplicate_template_property " , HandleVector ( args , 1 ) ) ) ; <nl> - } <nl> - # endif <nl> - <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , <nl> - Runtime : : DefineObjectProperty ( object , key , value , attributes ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_SetProperty ) { <nl> - HandleScope scope ( isolate ) ; <nl> - RUNTIME_ASSERT ( args . length ( ) = = 4 ) ; <nl> - <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , key , 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> - CONVERT_STRICT_MODE_ARG_CHECKED ( strict_mode_arg , 3 ) ; <nl> - StrictMode strict_mode = strict_mode_arg ; <nl> - <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , <nl> - Runtime : : SetObjectProperty ( isolate , object , key , value , strict_mode ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - / / Adds an element to an array . <nl> - / / This is used to create an indexed data property into an array . <nl> - RUNTIME_FUNCTION ( Runtime_AddElement ) { <nl> - HandleScope scope ( isolate ) ; <nl> - RUNTIME_ASSERT ( args . length ( ) = = 4 ) ; <nl> - <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , key , 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , value , 2 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( unchecked_attributes , 3 ) ; <nl> - RUNTIME_ASSERT ( <nl> - ( unchecked_attributes & ~ ( READ_ONLY | DONT_ENUM | DONT_DELETE ) ) = = 0 ) ; <nl> - / / Compute attributes . <nl> - PropertyAttributes attributes = <nl> - static_cast < PropertyAttributes > ( unchecked_attributes ) ; <nl> - <nl> - uint32_t index = 0 ; <nl> - key - > ToArrayIndex ( & index ) ; <nl> - <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , JSObject : : SetElement ( object , index , value , attributes , <nl> - SLOPPY , false , DEFINE_PROPERTY ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_TransitionElementsKind ) { <nl> - HandleScope scope ( isolate ) ; <nl> - RUNTIME_ASSERT ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSArray , array , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Map , map , 1 ) ; <nl> - JSObject : : TransitionElementsKind ( array , map - > elements_kind ( ) ) ; <nl> - return * array ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_DeleteProperty ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 3 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> - CONVERT_STRICT_MODE_ARG_CHECKED ( strict_mode , 2 ) ; <nl> - JSReceiver : : DeleteMode delete_mode = strict_mode = = STRICT <nl> - ? JSReceiver : : STRICT_DELETION <nl> - : JSReceiver : : NORMAL_DELETION ; <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , JSReceiver : : DeleteProperty ( object , key , delete_mode ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - static Object * HasOwnPropertyImplementation ( Isolate * isolate , <nl> - Handle < JSObject > object , <nl> - Handle < Name > key ) { <nl> - Maybe < bool > maybe = JSReceiver : : HasOwnProperty ( object , key ) ; <nl> - if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> - if ( maybe . value ) return isolate - > heap ( ) - > true_value ( ) ; <nl> - / / Handle hidden prototypes . If there ' s a hidden prototype above this thing <nl> - / / then we have to check it for properties , because they are supposed to <nl> - / / look like they are on this object . <nl> - PrototypeIterator iter ( isolate , object ) ; <nl> - if ( ! iter . IsAtEnd ( ) & & <nl> - Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) <nl> - - > map ( ) <nl> - - > is_hidden_prototype ( ) ) { <nl> - / / TODO ( verwaest ) : The recursion is not necessary for keys that are array <nl> - / / indices . Removing this . <nl> - return HasOwnPropertyImplementation ( <nl> - isolate , Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) , <nl> - key ) ; <nl> - } <nl> - RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> - return isolate - > heap ( ) - > false_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_HasOwnProperty ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , object , 0 ) <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> - <nl> - uint32_t index ; <nl> - const bool key_is_array_index = key - > AsArrayIndex ( & index ) ; <nl> - <nl> - / / Only JS objects can have properties . <nl> - if ( object - > IsJSObject ( ) ) { <nl> - Handle < JSObject > js_obj = Handle < JSObject > : : cast ( object ) ; <nl> - / / Fast case : either the key is a real named property or it is not <nl> - / / an array index and there are no interceptors or hidden <nl> - / / prototypes . <nl> - Maybe < bool > maybe = JSObject : : HasRealNamedProperty ( js_obj , key ) ; <nl> - if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> - DCHECK ( ! isolate - > has_pending_exception ( ) ) ; <nl> - if ( maybe . value ) { <nl> - return isolate - > heap ( ) - > true_value ( ) ; <nl> - } <nl> - Map * map = js_obj - > map ( ) ; <nl> - if ( ! key_is_array_index & & ! map - > has_named_interceptor ( ) & & <nl> - ! HeapObject : : cast ( map - > prototype ( ) ) - > map ( ) - > is_hidden_prototype ( ) ) { <nl> - return isolate - > heap ( ) - > false_value ( ) ; <nl> - } <nl> - / / Slow case . <nl> - return HasOwnPropertyImplementation ( isolate , Handle < JSObject > ( js_obj ) , <nl> - Handle < Name > ( key ) ) ; <nl> - } else if ( object - > IsString ( ) & & key_is_array_index ) { <nl> - / / Well , there is one exception : Handle [ ] on strings . <nl> - Handle < String > string = Handle < String > : : cast ( object ) ; <nl> - if ( index < static_cast < uint32_t > ( string - > length ( ) ) ) { <nl> - return isolate - > heap ( ) - > true_value ( ) ; <nl> - } <nl> - } <nl> - return isolate - > heap ( ) - > false_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_HasProperty ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , receiver , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> - <nl> - Maybe < bool > maybe = JSReceiver : : HasProperty ( receiver , key ) ; <nl> - if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> - return isolate - > heap ( ) - > ToBoolean ( maybe . value ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_HasElement ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , receiver , 0 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( index , 1 ) ; <nl> - <nl> - Maybe < bool > maybe = JSReceiver : : HasElement ( receiver , index ) ; <nl> - if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> - return isolate - > heap ( ) - > ToBoolean ( maybe . value ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_IsPropertyEnumerable ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , key , 1 ) ; <nl> - <nl> - Maybe < PropertyAttributes > maybe = <nl> - JSReceiver : : GetOwnPropertyAttributes ( object , key ) ; <nl> - if ( ! maybe . has_value ) return isolate - > heap ( ) - > exception ( ) ; <nl> - if ( maybe . value = = ABSENT ) maybe . value = DONT_ENUM ; <nl> - return isolate - > heap ( ) - > ToBoolean ( ( maybe . value & DONT_ENUM ) = = 0 ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_GetPropertyNames ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , object , 0 ) ; <nl> - Handle < JSArray > result ; <nl> - <nl> - isolate - > counters ( ) - > for_in ( ) - > Increment ( ) ; <nl> - Handle < FixedArray > elements ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , elements , <nl> - JSReceiver : : GetKeys ( object , JSReceiver : : INCLUDE_PROTOS ) ) ; <nl> - return * isolate - > factory ( ) - > NewJSArrayWithElements ( elements ) ; <nl> - } <nl> - <nl> - <nl> - / / Returns either a FixedArray as Runtime_GetPropertyNames , <nl> - / / or , if the given object has an enum cache that contains <nl> - / / all enumerable properties of the object and its prototypes <nl> - / / have none , the map of the object . This is used to speed up <nl> - / / the check for deletions during a for - in . <nl> - RUNTIME_FUNCTION ( Runtime_GetPropertyNamesFast ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - <nl> - CONVERT_ARG_CHECKED ( JSReceiver , raw_object , 0 ) ; <nl> - <nl> - if ( raw_object - > IsSimpleEnum ( ) ) return raw_object - > map ( ) ; <nl> - <nl> - HandleScope scope ( isolate ) ; <nl> - Handle < JSReceiver > object ( raw_object ) ; <nl> - Handle < FixedArray > content ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , content , <nl> - JSReceiver : : GetKeys ( object , JSReceiver : : INCLUDE_PROTOS ) ) ; <nl> - <nl> - / / Test again , since cache may have been built by preceding call . <nl> - if ( object - > IsSimpleEnum ( ) ) return object - > map ( ) ; <nl> - <nl> - return * content ; <nl> - } <nl> - <nl> - <nl> - / / Find the length of the prototype chain that is to be handled as one . If a <nl> - / / prototype object is hidden it is to be viewed as part of the the object it <nl> - / / is prototype for . <nl> - static int OwnPrototypeChainLength ( JSObject * obj ) { <nl> - int count = 1 ; <nl> - for ( PrototypeIterator iter ( obj - > GetIsolate ( ) , obj ) ; <nl> - ! iter . IsAtEnd ( PrototypeIterator : : END_AT_NON_HIDDEN ) ; iter . Advance ( ) ) { <nl> - count + + ; <nl> - } <nl> - return count ; <nl> - } <nl> - <nl> - <nl> - / / Return the names of the own named properties . <nl> - / / args [ 0 ] : object <nl> - / / args [ 1 ] : PropertyAttributes as int <nl> - RUNTIME_FUNCTION ( Runtime_GetOwnPropertyNames ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - if ( ! args [ 0 ] - > IsJSObject ( ) ) { <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( filter_value , 1 ) ; <nl> - PropertyAttributes filter = static_cast < PropertyAttributes > ( filter_value ) ; <nl> - <nl> - / / Skip the global proxy as it has no properties and always delegates to the <nl> - / / real global object . <nl> - if ( obj - > IsJSGlobalProxy ( ) ) { <nl> - / / Only collect names if access is permitted . <nl> - if ( obj - > IsAccessCheckNeeded ( ) & & <nl> - ! isolate - > MayNamedAccess ( obj , isolate - > factory ( ) - > undefined_value ( ) , <nl> - v8 : : ACCESS_KEYS ) ) { <nl> - isolate - > ReportFailedAccessCheck ( obj , v8 : : ACCESS_KEYS ) ; <nl> - RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> - return * isolate - > factory ( ) - > NewJSArray ( 0 ) ; <nl> - } <nl> - PrototypeIterator iter ( isolate , obj ) ; <nl> - obj = Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) ; <nl> - } <nl> - <nl> - / / Find the number of objects making up this . <nl> - int length = OwnPrototypeChainLength ( * obj ) ; <nl> - <nl> - / / Find the number of own properties for each of the objects . <nl> - ScopedVector < int > own_property_count ( length ) ; <nl> - int total_property_count = 0 ; <nl> - { <nl> - PrototypeIterator iter ( isolate , obj , PrototypeIterator : : START_AT_RECEIVER ) ; <nl> - for ( int i = 0 ; i < length ; i + + ) { <nl> - DCHECK ( ! iter . IsAtEnd ( ) ) ; <nl> - Handle < JSObject > jsproto = <nl> - Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) ; <nl> - / / Only collect names if access is permitted . <nl> - if ( jsproto - > IsAccessCheckNeeded ( ) & & <nl> - ! isolate - > MayNamedAccess ( jsproto , <nl> - isolate - > factory ( ) - > undefined_value ( ) , <nl> - v8 : : ACCESS_KEYS ) ) { <nl> - isolate - > ReportFailedAccessCheck ( jsproto , v8 : : ACCESS_KEYS ) ; <nl> - RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> - return * isolate - > factory ( ) - > NewJSArray ( 0 ) ; <nl> - } <nl> - int n ; <nl> - n = jsproto - > NumberOfOwnProperties ( filter ) ; <nl> - own_property_count [ i ] = n ; <nl> - total_property_count + = n ; <nl> - iter . Advance ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / Allocate an array with storage for all the property names . <nl> - Handle < FixedArray > names = <nl> - isolate - > factory ( ) - > NewFixedArray ( total_property_count ) ; <nl> - <nl> - / / Get the property names . <nl> - int next_copy_index = 0 ; <nl> - int hidden_strings = 0 ; <nl> - { <nl> - PrototypeIterator iter ( isolate , obj , PrototypeIterator : : START_AT_RECEIVER ) ; <nl> - for ( int i = 0 ; i < length ; i + + ) { <nl> - DCHECK ( ! iter . IsAtEnd ( ) ) ; <nl> - Handle < JSObject > jsproto = <nl> - Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) ; <nl> - jsproto - > GetOwnPropertyNames ( * names , next_copy_index , filter ) ; <nl> - if ( i > 0 ) { <nl> - / / Names from hidden prototypes may already have been added <nl> - / / for inherited function template instances . Count the duplicates <nl> - / / and stub them out ; the final copy pass at the end ignores holes . <nl> - for ( int j = next_copy_index ; <nl> - j < next_copy_index + own_property_count [ i ] ; j + + ) { <nl> - Object * name_from_hidden_proto = names - > get ( j ) ; <nl> - for ( int k = 0 ; k < next_copy_index ; k + + ) { <nl> - if ( names - > get ( k ) ! = isolate - > heap ( ) - > hidden_string ( ) ) { <nl> - Object * name = names - > get ( k ) ; <nl> - if ( name_from_hidden_proto = = name ) { <nl> - names - > set ( j , isolate - > heap ( ) - > hidden_string ( ) ) ; <nl> - hidden_strings + + ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - } <nl> - next_copy_index + = own_property_count [ i ] ; <nl> - <nl> - / / Hidden properties only show up if the filter does not skip strings . <nl> - if ( ( filter & STRING ) = = 0 & & JSObject : : HasHiddenProperties ( jsproto ) ) { <nl> - hidden_strings + + ; <nl> - } <nl> - iter . Advance ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / Filter out name of hidden properties object and <nl> - / / hidden prototype duplicates . <nl> - if ( hidden_strings > 0 ) { <nl> - Handle < FixedArray > old_names = names ; <nl> - names = isolate - > factory ( ) - > NewFixedArray ( names - > length ( ) - hidden_strings ) ; <nl> - int dest_pos = 0 ; <nl> - for ( int i = 0 ; i < total_property_count ; i + + ) { <nl> - Object * name = old_names - > get ( i ) ; <nl> - if ( name = = isolate - > heap ( ) - > hidden_string ( ) ) { <nl> - hidden_strings - - ; <nl> - continue ; <nl> - } <nl> - names - > set ( dest_pos + + , name ) ; <nl> - } <nl> - DCHECK_EQ ( 0 , hidden_strings ) ; <nl> - } <nl> - <nl> - return * isolate - > factory ( ) - > NewJSArrayWithElements ( names ) ; <nl> - } <nl> - <nl> - <nl> - / / Return the names of the own indexed properties . <nl> - / / args [ 0 ] : object <nl> - RUNTIME_FUNCTION ( Runtime_GetOwnElementNames ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - if ( ! args [ 0 ] - > IsJSObject ( ) ) { <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> - <nl> - int n = obj - > NumberOfOwnElements ( static_cast < PropertyAttributes > ( NONE ) ) ; <nl> - Handle < FixedArray > names = isolate - > factory ( ) - > NewFixedArray ( n ) ; <nl> - obj - > GetOwnElementKeys ( * names , static_cast < PropertyAttributes > ( NONE ) ) ; <nl> - return * isolate - > factory ( ) - > NewJSArrayWithElements ( names ) ; <nl> - } <nl> - <nl> - <nl> - / / Return information on whether an object has a named or indexed interceptor . <nl> - / / args [ 0 ] : object <nl> - RUNTIME_FUNCTION ( Runtime_GetInterceptorInfo ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - if ( ! args [ 0 ] - > IsJSObject ( ) ) { <nl> - return Smi : : FromInt ( 0 ) ; <nl> - } <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> - <nl> - int result = 0 ; <nl> - if ( obj - > HasNamedInterceptor ( ) ) result | = 2 ; <nl> - if ( obj - > HasIndexedInterceptor ( ) ) result | = 1 ; <nl> - <nl> - return Smi : : FromInt ( result ) ; <nl> - } <nl> - <nl> - <nl> - / / Return property names from named interceptor . <nl> - / / args [ 0 ] : object <nl> - RUNTIME_FUNCTION ( Runtime_GetNamedInterceptorPropertyNames ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> - <nl> - if ( obj - > HasNamedInterceptor ( ) ) { <nl> - Handle < JSObject > result ; <nl> - if ( JSObject : : GetKeysForNamedInterceptor ( obj , obj ) . ToHandle ( & result ) ) { <nl> - return * result ; <nl> - } <nl> - } <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - / / Return element names from indexed interceptor . <nl> - / / args [ 0 ] : object <nl> - RUNTIME_FUNCTION ( Runtime_GetIndexedInterceptorElementNames ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , obj , 0 ) ; <nl> - <nl> - if ( obj - > HasIndexedInterceptor ( ) ) { <nl> - Handle < JSObject > result ; <nl> - if ( JSObject : : GetKeysForIndexedInterceptor ( obj , obj ) . ToHandle ( & result ) ) { <nl> - return * result ; <nl> - } <nl> - } <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_OwnKeys ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( JSObject , raw_object , 0 ) ; <nl> - Handle < JSObject > object ( raw_object ) ; <nl> - <nl> - if ( object - > IsJSGlobalProxy ( ) ) { <nl> - / / Do access checks before going to the global object . <nl> - if ( object - > IsAccessCheckNeeded ( ) & & <nl> - ! isolate - > MayNamedAccess ( object , isolate - > factory ( ) - > undefined_value ( ) , <nl> - v8 : : ACCESS_KEYS ) ) { <nl> - isolate - > ReportFailedAccessCheck ( object , v8 : : ACCESS_KEYS ) ; <nl> - RETURN_FAILURE_IF_SCHEDULED_EXCEPTION ( isolate ) ; <nl> - return * isolate - > factory ( ) - > NewJSArray ( 0 ) ; <nl> - } <nl> - <nl> - PrototypeIterator iter ( isolate , object ) ; <nl> - / / If proxy is detached we simply return an empty array . <nl> - if ( iter . IsAtEnd ( ) ) return * isolate - > factory ( ) - > NewJSArray ( 0 ) ; <nl> - object = Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) ; <nl> - } <nl> - <nl> - Handle < FixedArray > contents ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , contents , JSReceiver : : GetKeys ( object , JSReceiver : : OWN_ONLY ) ) ; <nl> - <nl> - / / Some fast paths through GetKeysInFixedArrayFor reuse a cached <nl> - / / property array and since the result is mutable we have to create <nl> - / / a fresh clone on each invocation . <nl> - int length = contents - > length ( ) ; <nl> - Handle < FixedArray > copy = isolate - > factory ( ) - > NewFixedArray ( length ) ; <nl> - for ( int i = 0 ; i < length ; i + + ) { <nl> - Object * entry = contents - > get ( i ) ; <nl> - if ( entry - > IsString ( ) ) { <nl> - copy - > set ( i , entry ) ; <nl> - } else { <nl> - DCHECK ( entry - > IsNumber ( ) ) ; <nl> - HandleScope scope ( isolate ) ; <nl> - Handle < Object > entry_handle ( entry , isolate ) ; <nl> - Handle < Object > entry_str = <nl> - isolate - > factory ( ) - > NumberToString ( entry_handle ) ; <nl> - copy - > set ( i , * entry_str ) ; <nl> - } <nl> - } <nl> - return * isolate - > factory ( ) - > NewJSArrayWithElements ( copy ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_ToFastProperties ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , object , 0 ) ; <nl> - if ( object - > IsJSObject ( ) & & ! object - > IsGlobalObject ( ) ) { <nl> - JSObject : : MigrateSlowToFast ( Handle < JSObject > : : cast ( object ) , 0 ) ; <nl> - } <nl> - return * object ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_ToBool ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , object , 0 ) ; <nl> - <nl> - return isolate - > heap ( ) - > ToBoolean ( object - > BooleanValue ( ) ) ; <nl> - } <nl> - <nl> - <nl> - / / Returns the type string of a value ; see ECMA - 262 , 11 . 4 . 3 ( p 47 ) . <nl> - / / Possible optimizations : put the type string into the oddballs . <nl> - RUNTIME_FUNCTION ( Runtime_Typeof ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> - if ( obj - > IsNumber ( ) ) return isolate - > heap ( ) - > number_string ( ) ; <nl> - HeapObject * heap_obj = HeapObject : : cast ( obj ) ; <nl> - <nl> - / / typeof an undetectable object is ' undefined ' <nl> - if ( heap_obj - > map ( ) - > is_undetectable ( ) ) { <nl> - return isolate - > heap ( ) - > undefined_string ( ) ; <nl> - } <nl> - <nl> - InstanceType instance_type = heap_obj - > map ( ) - > instance_type ( ) ; <nl> - if ( instance_type < FIRST_NONSTRING_TYPE ) { <nl> - return isolate - > heap ( ) - > string_string ( ) ; <nl> - } <nl> - <nl> - switch ( instance_type ) { <nl> - case ODDBALL_TYPE : <nl> - if ( heap_obj - > IsTrue ( ) | | heap_obj - > IsFalse ( ) ) { <nl> - return isolate - > heap ( ) - > boolean_string ( ) ; <nl> - } <nl> - if ( heap_obj - > IsNull ( ) ) { <nl> - return isolate - > heap ( ) - > object_string ( ) ; <nl> - } <nl> - DCHECK ( heap_obj - > IsUndefined ( ) ) ; <nl> - return isolate - > heap ( ) - > undefined_string ( ) ; <nl> - case SYMBOL_TYPE : <nl> - return isolate - > heap ( ) - > symbol_string ( ) ; <nl> - case JS_FUNCTION_TYPE : <nl> - case JS_FUNCTION_PROXY_TYPE : <nl> - return isolate - > heap ( ) - > function_string ( ) ; <nl> - default : <nl> - / / For any kind of object not handled above , the spec rule for <nl> - / / host objects gives that it is okay to return " object " <nl> - return isolate - > heap ( ) - > object_string ( ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_Booleanize ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , value_raw , 0 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( token_raw , 1 ) ; <nl> - intptr_t value = reinterpret_cast < intptr_t > ( value_raw ) ; <nl> - Token : : Value token = static_cast < Token : : Value > ( token_raw ) ; <nl> - switch ( token ) { <nl> - case Token : : EQ : <nl> - case Token : : EQ_STRICT : <nl> - return isolate - > heap ( ) - > ToBoolean ( value = = 0 ) ; <nl> - case Token : : NE : <nl> - case Token : : NE_STRICT : <nl> - return isolate - > heap ( ) - > ToBoolean ( value ! = 0 ) ; <nl> - case Token : : LT : <nl> - return isolate - > heap ( ) - > ToBoolean ( value < 0 ) ; <nl> - case Token : : GT : <nl> - return isolate - > heap ( ) - > ToBoolean ( value > 0 ) ; <nl> - case Token : : LTE : <nl> - return isolate - > heap ( ) - > ToBoolean ( value < = 0 ) ; <nl> - case Token : : GTE : <nl> - return isolate - > heap ( ) - > ToBoolean ( value > = 0 ) ; <nl> - default : <nl> - / / This should only happen during natives fuzzing . <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_NewStringWrapper ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( String , value , 0 ) ; <nl> - return * Object : : ToObject ( isolate , value ) . ToHandleChecked ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_AllocateHeapNumber ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 0 ) ; <nl> - return * isolate - > factory ( ) - > NewHeapNumber ( 0 ) ; <nl> - } <nl> - <nl> - <nl> - static Object * Runtime_NewObjectHelper ( Isolate * isolate , <nl> - Handle < Object > constructor , <nl> - Handle < AllocationSite > site ) { <nl> - / / If the constructor isn ' t a proper function we throw a type error . <nl> - if ( ! constructor - > IsJSFunction ( ) ) { <nl> - Vector < Handle < Object > > arguments = HandleVector ( & constructor , 1 ) ; <nl> - THROW_NEW_ERROR_RETURN_FAILURE ( isolate , <nl> - NewTypeError ( " not_constructor " , arguments ) ) ; <nl> - } <nl> - <nl> - Handle < JSFunction > function = Handle < JSFunction > : : cast ( constructor ) ; <nl> - <nl> - / / If function should not have prototype , construction is not allowed . In this <nl> - / / case generated code bailouts here , since function has no initial_map . <nl> - if ( ! function - > should_have_prototype ( ) & & ! function - > shared ( ) - > bound ( ) ) { <nl> - Vector < Handle < Object > > arguments = HandleVector ( & constructor , 1 ) ; <nl> - THROW_NEW_ERROR_RETURN_FAILURE ( isolate , <nl> - NewTypeError ( " not_constructor " , arguments ) ) ; <nl> - } <nl> - <nl> - Debug * debug = isolate - > debug ( ) ; <nl> - / / Handle stepping into constructors if step into is active . <nl> - if ( debug - > StepInActive ( ) ) { <nl> - debug - > HandleStepIn ( function , Handle < Object > : : null ( ) , 0 , true ) ; <nl> - } <nl> - <nl> - if ( function - > has_initial_map ( ) ) { <nl> - if ( function - > initial_map ( ) - > instance_type ( ) = = JS_FUNCTION_TYPE ) { <nl> - / / The ' Function ' function ignores the receiver object when <nl> - / / called using ' new ' and creates a new JSFunction object that <nl> - / / is returned . The receiver object is only used for error <nl> - / / reporting if an error occurs when constructing the new <nl> - / / JSFunction . Factory : : NewJSObject ( ) should not be used to <nl> - / / allocate JSFunctions since it does not properly initialize <nl> - / / the shared part of the function . Since the receiver is <nl> - / / ignored anyway , we use the global object as the receiver <nl> - / / instead of a new JSFunction object . This way , errors are <nl> - / / reported the same way whether or not ' Function ' is called <nl> - / / using ' new ' . <nl> - return isolate - > global_proxy ( ) ; <nl> - } <nl> - } <nl> - <nl> - / / The function should be compiled for the optimization hints to be <nl> - / / available . <nl> - Compiler : : EnsureCompiled ( function , CLEAR_EXCEPTION ) ; <nl> - <nl> - Handle < JSObject > result ; <nl> - if ( site . is_null ( ) ) { <nl> - result = isolate - > factory ( ) - > NewJSObject ( function ) ; <nl> - } else { <nl> - result = isolate - > factory ( ) - > NewJSObjectWithMemento ( function , site ) ; <nl> - } <nl> - <nl> - isolate - > counters ( ) - > constructed_objects ( ) - > Increment ( ) ; <nl> - isolate - > counters ( ) - > constructed_objects_runtime ( ) - > Increment ( ) ; <nl> - <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_NewObject ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , constructor , 0 ) ; <nl> - return Runtime_NewObjectHelper ( isolate , constructor , <nl> - Handle < AllocationSite > : : null ( ) ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_NewObjectWithAllocationSite ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , constructor , 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , feedback , 0 ) ; <nl> - Handle < AllocationSite > site ; <nl> - if ( feedback - > IsAllocationSite ( ) ) { <nl> - / / The feedback can be an AllocationSite or undefined . <nl> - site = Handle < AllocationSite > : : cast ( feedback ) ; <nl> - } <nl> - return Runtime_NewObjectHelper ( isolate , constructor , site ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_FinalizeInstanceSize ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSFunction , function , 0 ) ; <nl> - function - > CompleteInobjectSlackTracking ( ) ; <nl> - <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_CheckIsBootstrapping ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 0 ) ; <nl> - RUNTIME_ASSERT ( isolate - > bootstrapper ( ) - > IsActive ( ) ) ; <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_GetRootNaN ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 0 ) ; <nl> - RUNTIME_ASSERT ( isolate - > bootstrapper ( ) - > IsActive ( ) ) ; <nl> - return isolate - > heap ( ) - > nan_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_Throw ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - <nl> - return isolate - > Throw ( args [ 0 ] ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_ReThrow ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - <nl> - return isolate - > ReThrow ( args [ 0 ] ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_PromoteScheduledException ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 0 ) ; <nl> - return isolate - > PromoteScheduledException ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_ThrowReferenceError ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , name , 0 ) ; <nl> - THROW_NEW_ERROR_RETURN_FAILURE ( <nl> - isolate , NewReferenceError ( " not_defined " , HandleVector ( & name , 1 ) ) ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_PromiseRejectEvent ) { <nl> - DCHECK ( args . length ( ) = = 3 ) ; <nl> - HandleScope scope ( isolate ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , promise , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , value , 1 ) ; <nl> - CONVERT_BOOLEAN_ARG_CHECKED ( debug_event , 2 ) ; <nl> - if ( debug_event ) isolate - > debug ( ) - > OnPromiseReject ( promise , value ) ; <nl> - Handle < Symbol > key = isolate - > factory ( ) - > promise_has_handler_symbol ( ) ; <nl> - / / Do not report if we actually have a handler . <nl> - if ( JSObject : : GetDataProperty ( promise , key ) - > IsUndefined ( ) ) { <nl> - isolate - > ReportPromiseReject ( promise , value , <nl> - v8 : : kPromiseRejectWithNoHandler ) ; <nl> - } <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_PromiseRevokeReject ) { <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - HandleScope scope ( isolate ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , promise , 0 ) ; <nl> - Handle < Symbol > key = isolate - > factory ( ) - > promise_has_handler_symbol ( ) ; <nl> - / / At this point , no revocation has been issued before <nl> - RUNTIME_ASSERT ( JSObject : : GetDataProperty ( promise , key ) - > IsUndefined ( ) ) ; <nl> - isolate - > ReportPromiseReject ( promise , Handle < Object > ( ) , <nl> - v8 : : kPromiseHandlerAddedAfterReject ) ; <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_PromiseHasHandlerSymbol ) { <nl> - DCHECK ( args . length ( ) = = 0 ) ; <nl> - return isolate - > heap ( ) - > promise_has_handler_symbol ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_StackGuard ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 0 ) ; <nl> - <nl> - / / First check if this is a real stack overflow . <nl> - StackLimitCheck check ( isolate ) ; <nl> - if ( check . JsHasOverflowed ( ) ) { <nl> - return isolate - > StackOverflow ( ) ; <nl> - } <nl> - <nl> - return isolate - > stack_guard ( ) - > HandleInterrupts ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_Interrupt ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 0 ) ; <nl> - return isolate - > stack_guard ( ) - > HandleInterrupts ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_GlobalProxy ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , global , 0 ) ; <nl> - if ( ! global - > IsJSGlobalObject ( ) ) return isolate - > heap ( ) - > null_value ( ) ; <nl> - return JSGlobalObject : : cast ( global ) - > global_proxy ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_IsAttachedGlobal ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , global , 0 ) ; <nl> - if ( ! global - > IsJSGlobalObject ( ) ) return isolate - > heap ( ) - > false_value ( ) ; <nl> - return isolate - > heap ( ) - > ToBoolean ( <nl> - ! JSGlobalObject : : cast ( global ) - > IsDetached ( ) ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_AllocateInNewSpace ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( size , 0 ) ; <nl> - RUNTIME_ASSERT ( IsAligned ( size , kPointerSize ) ) ; <nl> - RUNTIME_ASSERT ( size > 0 ) ; <nl> - RUNTIME_ASSERT ( size < = Page : : kMaxRegularHeapObjectSize ) ; <nl> - return * isolate - > factory ( ) - > NewFillerObject ( size , false , NEW_SPACE ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_AllocateInTargetSpace ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( size , 0 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( flags , 1 ) ; <nl> - RUNTIME_ASSERT ( IsAligned ( size , kPointerSize ) ) ; <nl> - RUNTIME_ASSERT ( size > 0 ) ; <nl> - RUNTIME_ASSERT ( size < = Page : : kMaxRegularHeapObjectSize ) ; <nl> - bool double_align = AllocateDoubleAlignFlag : : decode ( flags ) ; <nl> - AllocationSpace space = AllocateTargetSpace : : decode ( flags ) ; <nl> - return * isolate - > factory ( ) - > NewFillerObject ( size , double_align , space ) ; <nl> - } <nl> - <nl> - <nl> - / / Push an object unto an array of objects if it is not already in the <nl> - / / array . Returns true if the element was pushed on the stack and <nl> - / / false otherwise . <nl> - RUNTIME_FUNCTION ( Runtime_PushIfAbsent ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSArray , array , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , element , 1 ) ; <nl> - RUNTIME_ASSERT ( array - > HasFastSmiOrObjectElements ( ) ) ; <nl> - int length = Smi : : cast ( array - > length ( ) ) - > value ( ) ; <nl> - FixedArray * elements = FixedArray : : cast ( array - > elements ( ) ) ; <nl> - for ( int i = 0 ; i < length ; i + + ) { <nl> - if ( elements - > get ( i ) = = * element ) return isolate - > heap ( ) - > false_value ( ) ; <nl> - } <nl> - <nl> - / / Strict not needed . Used for cycle detection in Array join implementation . <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , JSObject : : SetFastElement ( array , length , element , SLOPPY , true ) ) ; <nl> - return isolate - > heap ( ) - > true_value ( ) ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * A simple visitor visits every element of Array ' s . <nl> - * The backend storage can be a fixed array for fast elements case , <nl> - * or a dictionary for sparse array . Since Dictionary is a subtype <nl> - * of FixedArray , the class can be used by both fast and slow cases . <nl> - * The second parameter of the constructor , fast_elements , specifies <nl> - * whether the storage is a FixedArray or Dictionary . <nl> - * <nl> - * An index limit is used to deal with the situation that a result array <nl> - * length overflows 32 - bit non - negative integer . <nl> - * / <nl> - class ArrayConcatVisitor { <nl> - public : <nl> - ArrayConcatVisitor ( Isolate * isolate , Handle < FixedArray > storage , <nl> - bool fast_elements ) <nl> - : isolate_ ( isolate ) , <nl> - storage_ ( Handle < FixedArray > : : cast ( <nl> - isolate - > global_handles ( ) - > Create ( * storage ) ) ) , <nl> - index_offset_ ( 0u ) , <nl> - fast_elements_ ( fast_elements ) , <nl> - exceeds_array_limit_ ( false ) { } <nl> - <nl> - ~ ArrayConcatVisitor ( ) { clear_storage ( ) ; } <nl> - <nl> - void visit ( uint32_t i , Handle < Object > elm ) { <nl> - if ( i > JSObject : : kMaxElementCount - index_offset_ ) { <nl> - exceeds_array_limit_ = true ; <nl> - return ; <nl> - } <nl> - uint32_t index = index_offset_ + i ; <nl> - <nl> - if ( fast_elements_ ) { <nl> - if ( index < static_cast < uint32_t > ( storage_ - > length ( ) ) ) { <nl> - storage_ - > set ( index , * elm ) ; <nl> - return ; <nl> - } <nl> - / / Our initial estimate of length was foiled , possibly by <nl> - / / getters on the arrays increasing the length of later arrays <nl> - / / during iteration . <nl> - / / This shouldn ' t happen in anything but pathological cases . <nl> - SetDictionaryMode ( ) ; <nl> - / / Fall - through to dictionary mode . <nl> - } <nl> - DCHECK ( ! fast_elements_ ) ; <nl> - Handle < SeededNumberDictionary > dict ( <nl> - SeededNumberDictionary : : cast ( * storage_ ) ) ; <nl> - Handle < SeededNumberDictionary > result = <nl> - SeededNumberDictionary : : AtNumberPut ( dict , index , elm ) ; <nl> - if ( ! result . is_identical_to ( dict ) ) { <nl> - / / Dictionary needed to grow . <nl> - clear_storage ( ) ; <nl> - set_storage ( * result ) ; <nl> - } <nl> - } <nl> - <nl> - void increase_index_offset ( uint32_t delta ) { <nl> - if ( JSObject : : kMaxElementCount - index_offset_ < delta ) { <nl> - index_offset_ = JSObject : : kMaxElementCount ; <nl> - } else { <nl> - index_offset_ + = delta ; <nl> - } <nl> - / / If the initial length estimate was off ( see special case in visit ( ) ) , <nl> - / / but the array blowing the limit didn ' t contain elements beyond the <nl> - / / provided - for index range , go to dictionary mode now . <nl> - if ( fast_elements_ & & <nl> - index_offset_ > <nl> - static_cast < uint32_t > ( FixedArrayBase : : cast ( * storage_ ) - > length ( ) ) ) { <nl> - SetDictionaryMode ( ) ; <nl> - } <nl> - } <nl> - <nl> - bool exceeds_array_limit ( ) { return exceeds_array_limit_ ; } <nl> - <nl> - Handle < JSArray > ToArray ( ) { <nl> - Handle < JSArray > array = isolate_ - > factory ( ) - > NewJSArray ( 0 ) ; <nl> - Handle < Object > length = <nl> - isolate_ - > factory ( ) - > NewNumber ( static_cast < double > ( index_offset_ ) ) ; <nl> - Handle < Map > map = JSObject : : GetElementsTransitionMap ( <nl> - array , fast_elements_ ? FAST_HOLEY_ELEMENTS : DICTIONARY_ELEMENTS ) ; <nl> - array - > set_map ( * map ) ; <nl> - array - > set_length ( * length ) ; <nl> - array - > set_elements ( * storage_ ) ; <nl> - return array ; <nl> - } <nl> - <nl> - private : <nl> - / / Convert storage to dictionary mode . <nl> - void SetDictionaryMode ( ) { <nl> - DCHECK ( fast_elements_ ) ; <nl> - Handle < FixedArray > current_storage ( * storage_ ) ; <nl> - Handle < SeededNumberDictionary > slow_storage ( <nl> - SeededNumberDictionary : : New ( isolate_ , current_storage - > length ( ) ) ) ; <nl> - uint32_t current_length = static_cast < uint32_t > ( current_storage - > length ( ) ) ; <nl> - for ( uint32_t i = 0 ; i < current_length ; i + + ) { <nl> - HandleScope loop_scope ( isolate_ ) ; <nl> - Handle < Object > element ( current_storage - > get ( i ) , isolate_ ) ; <nl> - if ( ! element - > IsTheHole ( ) ) { <nl> - Handle < SeededNumberDictionary > new_storage = <nl> - SeededNumberDictionary : : AtNumberPut ( slow_storage , i , element ) ; <nl> - if ( ! new_storage . is_identical_to ( slow_storage ) ) { <nl> - slow_storage = loop_scope . CloseAndEscape ( new_storage ) ; <nl> - } <nl> - } <nl> - } <nl> - clear_storage ( ) ; <nl> - set_storage ( * slow_storage ) ; <nl> - fast_elements_ = false ; <nl> - } <nl> - <nl> - inline void clear_storage ( ) { <nl> - GlobalHandles : : Destroy ( Handle < Object > : : cast ( storage_ ) . location ( ) ) ; <nl> - } <nl> - <nl> - inline void set_storage ( FixedArray * storage ) { <nl> - storage_ = <nl> - Handle < FixedArray > : : cast ( isolate_ - > global_handles ( ) - > Create ( storage ) ) ; <nl> - } <nl> - <nl> - Isolate * isolate_ ; <nl> - Handle < FixedArray > storage_ ; / / Always a global handle . <nl> - / / Index after last seen index . Always less than or equal to <nl> - / / JSObject : : kMaxElementCount . <nl> - uint32_t index_offset_ ; <nl> - bool fast_elements_ : 1 ; <nl> - bool exceeds_array_limit_ : 1 ; <nl> - } ; <nl> - <nl> - <nl> - static uint32_t EstimateElementCount ( Handle < JSArray > array ) { <nl> - uint32_t length = static_cast < uint32_t > ( array - > length ( ) - > Number ( ) ) ; <nl> - int element_count = 0 ; <nl> - switch ( array - > GetElementsKind ( ) ) { <nl> - case FAST_SMI_ELEMENTS : <nl> - case FAST_HOLEY_SMI_ELEMENTS : <nl> - case FAST_ELEMENTS : <nl> - case FAST_HOLEY_ELEMENTS : { <nl> - / / Fast elements can ' t have lengths that are not representable by <nl> - / / a 32 - bit signed integer . <nl> - DCHECK ( static_cast < int32_t > ( FixedArray : : kMaxLength ) > = 0 ) ; <nl> - int fast_length = static_cast < int > ( length ) ; <nl> - Handle < FixedArray > elements ( FixedArray : : cast ( array - > elements ( ) ) ) ; <nl> - for ( int i = 0 ; i < fast_length ; i + + ) { <nl> - if ( ! elements - > get ( i ) - > IsTheHole ( ) ) element_count + + ; <nl> - } <nl> - break ; <nl> - } <nl> - case FAST_DOUBLE_ELEMENTS : <nl> - case FAST_HOLEY_DOUBLE_ELEMENTS : { <nl> - / / Fast elements can ' t have lengths that are not representable by <nl> - / / a 32 - bit signed integer . <nl> - DCHECK ( static_cast < int32_t > ( FixedDoubleArray : : kMaxLength ) > = 0 ) ; <nl> - int fast_length = static_cast < int > ( length ) ; <nl> - if ( array - > elements ( ) - > IsFixedArray ( ) ) { <nl> - DCHECK ( FixedArray : : cast ( array - > elements ( ) ) - > length ( ) = = 0 ) ; <nl> - break ; <nl> - } <nl> - Handle < FixedDoubleArray > elements ( <nl> - FixedDoubleArray : : cast ( array - > elements ( ) ) ) ; <nl> - for ( int i = 0 ; i < fast_length ; i + + ) { <nl> - if ( ! elements - > is_the_hole ( i ) ) element_count + + ; <nl> - } <nl> - break ; <nl> - } <nl> - case DICTIONARY_ELEMENTS : { <nl> - Handle < SeededNumberDictionary > dictionary ( <nl> - SeededNumberDictionary : : cast ( array - > elements ( ) ) ) ; <nl> - int capacity = dictionary - > Capacity ( ) ; <nl> - for ( int i = 0 ; i < capacity ; i + + ) { <nl> - Handle < Object > key ( dictionary - > KeyAt ( i ) , array - > GetIsolate ( ) ) ; <nl> - if ( dictionary - > IsKey ( * key ) ) { <nl> - element_count + + ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - case SLOPPY_ARGUMENTS_ELEMENTS : <nl> - # define TYPED_ARRAY_CASE ( Type , type , TYPE , ctype , size ) \ <nl> - case EXTERNAL_ # # TYPE # # _ELEMENTS : \ <nl> - case TYPE # # _ELEMENTS : <nl> - <nl> - TYPED_ARRAYS ( TYPED_ARRAY_CASE ) <nl> - # undef TYPED_ARRAY_CASE <nl> - / / External arrays are always dense . <nl> - return length ; <nl> - } <nl> - / / As an estimate , we assume that the prototype doesn ' t contain any <nl> - / / inherited elements . <nl> - return element_count ; <nl> - } <nl> - <nl> - <nl> - template < class ExternalArrayClass , class ElementType > <nl> - static void IterateExternalArrayElements ( Isolate * isolate , <nl> - Handle < JSObject > receiver , <nl> - bool elements_are_ints , <nl> - bool elements_are_guaranteed_smis , <nl> - ArrayConcatVisitor * visitor ) { <nl> - Handle < ExternalArrayClass > array ( <nl> - ExternalArrayClass : : cast ( receiver - > elements ( ) ) ) ; <nl> - uint32_t len = static_cast < uint32_t > ( array - > length ( ) ) ; <nl> - <nl> - DCHECK ( visitor ! = NULL ) ; <nl> - if ( elements_are_ints ) { <nl> - if ( elements_are_guaranteed_smis ) { <nl> - for ( uint32_t j = 0 ; j < len ; j + + ) { <nl> - HandleScope loop_scope ( isolate ) ; <nl> - Handle < Smi > e ( Smi : : FromInt ( static_cast < int > ( array - > get_scalar ( j ) ) ) , <nl> - isolate ) ; <nl> - visitor - > visit ( j , e ) ; <nl> - } <nl> - } else { <nl> - for ( uint32_t j = 0 ; j < len ; j + + ) { <nl> - HandleScope loop_scope ( isolate ) ; <nl> - int64_t val = static_cast < int64_t > ( array - > get_scalar ( j ) ) ; <nl> - if ( Smi : : IsValid ( static_cast < intptr_t > ( val ) ) ) { <nl> - Handle < Smi > e ( Smi : : FromInt ( static_cast < int > ( val ) ) , isolate ) ; <nl> - visitor - > visit ( j , e ) ; <nl> - } else { <nl> - Handle < Object > e = <nl> - isolate - > factory ( ) - > NewNumber ( static_cast < ElementType > ( val ) ) ; <nl> - visitor - > visit ( j , e ) ; <nl> - } <nl> - } <nl> - } <nl> - } else { <nl> - for ( uint32_t j = 0 ; j < len ; j + + ) { <nl> - HandleScope loop_scope ( isolate ) ; <nl> - Handle < Object > e = isolate - > factory ( ) - > NewNumber ( array - > get_scalar ( j ) ) ; <nl> - visitor - > visit ( j , e ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - <nl> - / / Used for sorting indices in a List < uint32_t > . <nl> - static int compareUInt32 ( const uint32_t * ap , const uint32_t * bp ) { <nl> - uint32_t a = * ap ; <nl> - uint32_t b = * bp ; <nl> - return ( a = = b ) ? 0 : ( a < b ) ? - 1 : 1 ; <nl> - } <nl> - <nl> - <nl> - static void CollectElementIndices ( Handle < JSObject > object , uint32_t range , <nl> - List < uint32_t > * indices ) { <nl> - Isolate * isolate = object - > GetIsolate ( ) ; <nl> - ElementsKind kind = object - > GetElementsKind ( ) ; <nl> - switch ( kind ) { <nl> - case FAST_SMI_ELEMENTS : <nl> - case FAST_ELEMENTS : <nl> - case FAST_HOLEY_SMI_ELEMENTS : <nl> - case FAST_HOLEY_ELEMENTS : { <nl> - Handle < FixedArray > elements ( FixedArray : : cast ( object - > elements ( ) ) ) ; <nl> - uint32_t length = static_cast < uint32_t > ( elements - > length ( ) ) ; <nl> - if ( range < length ) length = range ; <nl> - for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> - if ( ! elements - > get ( i ) - > IsTheHole ( ) ) { <nl> - indices - > Add ( i ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - case FAST_HOLEY_DOUBLE_ELEMENTS : <nl> - case FAST_DOUBLE_ELEMENTS : { <nl> - if ( object - > elements ( ) - > IsFixedArray ( ) ) { <nl> - DCHECK ( object - > elements ( ) - > length ( ) = = 0 ) ; <nl> - break ; <nl> - } <nl> - Handle < FixedDoubleArray > elements ( <nl> - FixedDoubleArray : : cast ( object - > elements ( ) ) ) ; <nl> - uint32_t length = static_cast < uint32_t > ( elements - > length ( ) ) ; <nl> - if ( range < length ) length = range ; <nl> - for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> - if ( ! elements - > is_the_hole ( i ) ) { <nl> - indices - > Add ( i ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - case DICTIONARY_ELEMENTS : { <nl> - Handle < SeededNumberDictionary > dict ( <nl> - SeededNumberDictionary : : cast ( object - > elements ( ) ) ) ; <nl> - uint32_t capacity = dict - > Capacity ( ) ; <nl> - for ( uint32_t j = 0 ; j < capacity ; j + + ) { <nl> - HandleScope loop_scope ( isolate ) ; <nl> - Handle < Object > k ( dict - > KeyAt ( j ) , isolate ) ; <nl> - if ( dict - > IsKey ( * k ) ) { <nl> - DCHECK ( k - > IsNumber ( ) ) ; <nl> - uint32_t index = static_cast < uint32_t > ( k - > Number ( ) ) ; <nl> - if ( index < range ) { <nl> - indices - > Add ( index ) ; <nl> - } <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - # define TYPED_ARRAY_CASE ( Type , type , TYPE , ctype , size ) \ <nl> - case TYPE # # _ELEMENTS : \ <nl> - case EXTERNAL_ # # TYPE # # _ELEMENTS : <nl> - <nl> - TYPED_ARRAYS ( TYPED_ARRAY_CASE ) <nl> - # undef TYPED_ARRAY_CASE <nl> - { <nl> - uint32_t length = static_cast < uint32_t > ( <nl> - FixedArrayBase : : cast ( object - > elements ( ) ) - > length ( ) ) ; <nl> - if ( range < = length ) { <nl> - length = range ; <nl> - / / We will add all indices , so we might as well clear it first <nl> - / / and avoid duplicates . <nl> - indices - > Clear ( ) ; <nl> - } <nl> - for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> - indices - > Add ( i ) ; <nl> - } <nl> - if ( length = = range ) return ; / / All indices accounted for already . <nl> - break ; <nl> - } <nl> - case SLOPPY_ARGUMENTS_ELEMENTS : { <nl> - MaybeHandle < Object > length_obj = <nl> - Object : : GetProperty ( object , isolate - > factory ( ) - > length_string ( ) ) ; <nl> - double length_num = length_obj . ToHandleChecked ( ) - > Number ( ) ; <nl> - uint32_t length = static_cast < uint32_t > ( DoubleToInt32 ( length_num ) ) ; <nl> - ElementsAccessor * accessor = object - > GetElementsAccessor ( ) ; <nl> - for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> - if ( accessor - > HasElement ( object , object , i ) ) { <nl> - indices - > Add ( i ) ; <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - } <nl> - <nl> - PrototypeIterator iter ( isolate , object ) ; <nl> - if ( ! iter . IsAtEnd ( ) ) { <nl> - / / The prototype will usually have no inherited element indices , <nl> - / / but we have to check . <nl> - CollectElementIndices ( <nl> - Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) , range , <nl> - indices ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * A helper function that visits elements of a JSArray in numerical <nl> - * order . <nl> - * <nl> - * The visitor argument called for each existing element in the array <nl> - * with the element index and the element ' s value . <nl> - * Afterwards it increments the base - index of the visitor by the array <nl> - * length . <nl> - * Returns false if any access threw an exception , otherwise true . <nl> - * / <nl> - static bool IterateElements ( Isolate * isolate , Handle < JSArray > receiver , <nl> - ArrayConcatVisitor * visitor ) { <nl> - uint32_t length = static_cast < uint32_t > ( receiver - > length ( ) - > Number ( ) ) ; <nl> - switch ( receiver - > GetElementsKind ( ) ) { <nl> - case FAST_SMI_ELEMENTS : <nl> - case FAST_ELEMENTS : <nl> - case FAST_HOLEY_SMI_ELEMENTS : <nl> - case FAST_HOLEY_ELEMENTS : { <nl> - / / Run through the elements FixedArray and use HasElement and GetElement <nl> - / / to check the prototype for missing elements . <nl> - Handle < FixedArray > elements ( FixedArray : : cast ( receiver - > elements ( ) ) ) ; <nl> - int fast_length = static_cast < int > ( length ) ; <nl> - DCHECK ( fast_length < = elements - > length ( ) ) ; <nl> - for ( int j = 0 ; j < fast_length ; j + + ) { <nl> - HandleScope loop_scope ( isolate ) ; <nl> - Handle < Object > element_value ( elements - > get ( j ) , isolate ) ; <nl> - if ( ! element_value - > IsTheHole ( ) ) { <nl> - visitor - > visit ( j , element_value ) ; <nl> - } else { <nl> - Maybe < bool > maybe = JSReceiver : : HasElement ( receiver , j ) ; <nl> - if ( ! maybe . has_value ) return false ; <nl> - if ( maybe . value ) { <nl> - / / Call GetElement on receiver , not its prototype , or getters won ' t <nl> - / / have the correct receiver . <nl> - ASSIGN_RETURN_ON_EXCEPTION_VALUE ( <nl> - isolate , element_value , <nl> - Object : : GetElement ( isolate , receiver , j ) , false ) ; <nl> - visitor - > visit ( j , element_value ) ; <nl> - } <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - case FAST_HOLEY_DOUBLE_ELEMENTS : <nl> - case FAST_DOUBLE_ELEMENTS : { <nl> - / / Empty array is FixedArray but not FixedDoubleArray . <nl> - if ( length = = 0 ) break ; <nl> - / / Run through the elements FixedArray and use HasElement and GetElement <nl> - / / to check the prototype for missing elements . <nl> - if ( receiver - > elements ( ) - > IsFixedArray ( ) ) { <nl> - DCHECK ( receiver - > elements ( ) - > length ( ) = = 0 ) ; <nl> - break ; <nl> - } <nl> - Handle < FixedDoubleArray > elements ( <nl> - FixedDoubleArray : : cast ( receiver - > elements ( ) ) ) ; <nl> - int fast_length = static_cast < int > ( length ) ; <nl> - DCHECK ( fast_length < = elements - > length ( ) ) ; <nl> - for ( int j = 0 ; j < fast_length ; j + + ) { <nl> - HandleScope loop_scope ( isolate ) ; <nl> - if ( ! elements - > is_the_hole ( j ) ) { <nl> - double double_value = elements - > get_scalar ( j ) ; <nl> - Handle < Object > element_value = <nl> - isolate - > factory ( ) - > NewNumber ( double_value ) ; <nl> - visitor - > visit ( j , element_value ) ; <nl> - } else { <nl> - Maybe < bool > maybe = JSReceiver : : HasElement ( receiver , j ) ; <nl> - if ( ! maybe . has_value ) return false ; <nl> - if ( maybe . value ) { <nl> - / / Call GetElement on receiver , not its prototype , or getters won ' t <nl> - / / have the correct receiver . <nl> - Handle < Object > element_value ; <nl> - ASSIGN_RETURN_ON_EXCEPTION_VALUE ( <nl> - isolate , element_value , <nl> - Object : : GetElement ( isolate , receiver , j ) , false ) ; <nl> - visitor - > visit ( j , element_value ) ; <nl> - } <nl> - } <nl> - } <nl> - break ; <nl> - } <nl> - case DICTIONARY_ELEMENTS : { <nl> - Handle < SeededNumberDictionary > dict ( receiver - > element_dictionary ( ) ) ; <nl> - List < uint32_t > indices ( dict - > Capacity ( ) / 2 ) ; <nl> - / / Collect all indices in the object and the prototypes less <nl> - / / than length . This might introduce duplicates in the indices list . <nl> - CollectElementIndices ( receiver , length , & indices ) ; <nl> - indices . Sort ( & compareUInt32 ) ; <nl> - int j = 0 ; <nl> - int n = indices . length ( ) ; <nl> - while ( j < n ) { <nl> - HandleScope loop_scope ( isolate ) ; <nl> - uint32_t index = indices [ j ] ; <nl> - Handle < Object > element ; <nl> - ASSIGN_RETURN_ON_EXCEPTION_VALUE ( <nl> - isolate , element , Object : : GetElement ( isolate , receiver , index ) , <nl> - false ) ; <nl> - visitor - > visit ( index , element ) ; <nl> - / / Skip to next different index ( i . e . , omit duplicates ) . <nl> - do { <nl> - j + + ; <nl> - } while ( j < n & & indices [ j ] = = index ) ; <nl> - } <nl> - break ; <nl> - } <nl> - case EXTERNAL_UINT8_CLAMPED_ELEMENTS : { <nl> - Handle < ExternalUint8ClampedArray > pixels ( <nl> - ExternalUint8ClampedArray : : cast ( receiver - > elements ( ) ) ) ; <nl> - for ( uint32_t j = 0 ; j < length ; j + + ) { <nl> - Handle < Smi > e ( Smi : : FromInt ( pixels - > get_scalar ( j ) ) , isolate ) ; <nl> - visitor - > visit ( j , e ) ; <nl> - } <nl> - break ; <nl> - } <nl> - case EXTERNAL_INT8_ELEMENTS : { <nl> - IterateExternalArrayElements < ExternalInt8Array , int8_t > ( <nl> - isolate , receiver , true , true , visitor ) ; <nl> - break ; <nl> - } <nl> - case EXTERNAL_UINT8_ELEMENTS : { <nl> - IterateExternalArrayElements < ExternalUint8Array , uint8_t > ( <nl> - isolate , receiver , true , true , visitor ) ; <nl> - break ; <nl> - } <nl> - case EXTERNAL_INT16_ELEMENTS : { <nl> - IterateExternalArrayElements < ExternalInt16Array , int16_t > ( <nl> - isolate , receiver , true , true , visitor ) ; <nl> - break ; <nl> - } <nl> - case EXTERNAL_UINT16_ELEMENTS : { <nl> - IterateExternalArrayElements < ExternalUint16Array , uint16_t > ( <nl> - isolate , receiver , true , true , visitor ) ; <nl> - break ; <nl> - } <nl> - case EXTERNAL_INT32_ELEMENTS : { <nl> - IterateExternalArrayElements < ExternalInt32Array , int32_t > ( <nl> - isolate , receiver , true , false , visitor ) ; <nl> - break ; <nl> - } <nl> - case EXTERNAL_UINT32_ELEMENTS : { <nl> - IterateExternalArrayElements < ExternalUint32Array , uint32_t > ( <nl> - isolate , receiver , true , false , visitor ) ; <nl> - break ; <nl> - } <nl> - case EXTERNAL_FLOAT32_ELEMENTS : { <nl> - IterateExternalArrayElements < ExternalFloat32Array , float > ( <nl> - isolate , receiver , false , false , visitor ) ; <nl> - break ; <nl> - } <nl> - case EXTERNAL_FLOAT64_ELEMENTS : { <nl> - IterateExternalArrayElements < ExternalFloat64Array , double > ( <nl> - isolate , receiver , false , false , visitor ) ; <nl> - break ; <nl> - } <nl> - default : <nl> - UNREACHABLE ( ) ; <nl> - break ; <nl> - } <nl> - visitor - > increase_index_offset ( length ) ; <nl> - return true ; <nl> - } <nl> - <nl> - <nl> - / * * <nl> - * Array : : concat implementation . <nl> - * See ECMAScript 262 , 15 . 4 . 4 . 4 . <nl> - * TODO ( 581 ) : Fix non - compliance for very large concatenations and update to <nl> - * following the ECMAScript 5 specification . <nl> - * / <nl> - RUNTIME_FUNCTION ( Runtime_ArrayConcat ) { <nl> - HandleScope handle_scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSArray , arguments , 0 ) ; <nl> - int argument_count = static_cast < int > ( arguments - > length ( ) - > Number ( ) ) ; <nl> - RUNTIME_ASSERT ( arguments - > HasFastObjectElements ( ) ) ; <nl> - Handle < FixedArray > elements ( FixedArray : : cast ( arguments - > elements ( ) ) ) ; <nl> - <nl> - / / Pass 1 : estimate the length and number of elements of the result . <nl> - / / The actual length can be larger if any of the arguments have getters <nl> - / / that mutate other arguments ( but will otherwise be precise ) . <nl> - / / The number of elements is precise if there are no inherited elements . <nl> - <nl> - ElementsKind kind = FAST_SMI_ELEMENTS ; <nl> - <nl> - uint32_t estimate_result_length = 0 ; <nl> - uint32_t estimate_nof_elements = 0 ; <nl> - for ( int i = 0 ; i < argument_count ; i + + ) { <nl> - HandleScope loop_scope ( isolate ) ; <nl> - Handle < Object > obj ( elements - > get ( i ) , isolate ) ; <nl> - uint32_t length_estimate ; <nl> - uint32_t element_estimate ; <nl> - if ( obj - > IsJSArray ( ) ) { <nl> - Handle < JSArray > array ( Handle < JSArray > : : cast ( obj ) ) ; <nl> - length_estimate = static_cast < uint32_t > ( array - > length ( ) - > Number ( ) ) ; <nl> - if ( length_estimate ! = 0 ) { <nl> - ElementsKind array_kind = <nl> - GetPackedElementsKind ( array - > map ( ) - > elements_kind ( ) ) ; <nl> - if ( IsMoreGeneralElementsKindTransition ( kind , array_kind ) ) { <nl> - kind = array_kind ; <nl> - } <nl> - } <nl> - element_estimate = EstimateElementCount ( array ) ; <nl> - } else { <nl> - if ( obj - > IsHeapObject ( ) ) { <nl> - if ( obj - > IsNumber ( ) ) { <nl> - if ( IsMoreGeneralElementsKindTransition ( kind , FAST_DOUBLE_ELEMENTS ) ) { <nl> - kind = FAST_DOUBLE_ELEMENTS ; <nl> - } <nl> - } else if ( IsMoreGeneralElementsKindTransition ( kind , FAST_ELEMENTS ) ) { <nl> - kind = FAST_ELEMENTS ; <nl> - } <nl> - } <nl> - length_estimate = 1 ; <nl> - element_estimate = 1 ; <nl> - } <nl> - / / Avoid overflows by capping at kMaxElementCount . <nl> - if ( JSObject : : kMaxElementCount - estimate_result_length < length_estimate ) { <nl> - estimate_result_length = JSObject : : kMaxElementCount ; <nl> - } else { <nl> - estimate_result_length + = length_estimate ; <nl> - } <nl> - if ( JSObject : : kMaxElementCount - estimate_nof_elements < element_estimate ) { <nl> - estimate_nof_elements = JSObject : : kMaxElementCount ; <nl> - } else { <nl> - estimate_nof_elements + = element_estimate ; <nl> - } <nl> - } <nl> - <nl> - / / If estimated number of elements is more than half of length , a <nl> - / / fixed array ( fast case ) is more time and space - efficient than a <nl> - / / dictionary . <nl> - bool fast_case = ( estimate_nof_elements * 2 ) > = estimate_result_length ; <nl> - <nl> - if ( fast_case & & kind = = FAST_DOUBLE_ELEMENTS ) { <nl> - Handle < FixedArrayBase > storage = <nl> - isolate - > factory ( ) - > NewFixedDoubleArray ( estimate_result_length ) ; <nl> - int j = 0 ; <nl> - bool failure = false ; <nl> - if ( estimate_result_length > 0 ) { <nl> - Handle < FixedDoubleArray > double_storage = <nl> - Handle < FixedDoubleArray > : : cast ( storage ) ; <nl> - for ( int i = 0 ; i < argument_count ; i + + ) { <nl> - Handle < Object > obj ( elements - > get ( i ) , isolate ) ; <nl> - if ( obj - > IsSmi ( ) ) { <nl> - double_storage - > set ( j , Smi : : cast ( * obj ) - > value ( ) ) ; <nl> - j + + ; <nl> - } else if ( obj - > IsNumber ( ) ) { <nl> - double_storage - > set ( j , obj - > Number ( ) ) ; <nl> - j + + ; <nl> - } else { <nl> - JSArray * array = JSArray : : cast ( * obj ) ; <nl> - uint32_t length = static_cast < uint32_t > ( array - > length ( ) - > Number ( ) ) ; <nl> - switch ( array - > map ( ) - > elements_kind ( ) ) { <nl> - case FAST_HOLEY_DOUBLE_ELEMENTS : <nl> - case FAST_DOUBLE_ELEMENTS : { <nl> - / / Empty array is FixedArray but not FixedDoubleArray . <nl> - if ( length = = 0 ) break ; <nl> - FixedDoubleArray * elements = <nl> - FixedDoubleArray : : cast ( array - > elements ( ) ) ; <nl> - for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> - if ( elements - > is_the_hole ( i ) ) { <nl> - / / TODO ( jkummerow / verwaest ) : We could be a bit more clever <nl> - / / here : Check if there are no elements / getters on the <nl> - / / prototype chain , and if so , allow creation of a holey <nl> - / / result array . <nl> - / / Same thing below ( holey smi case ) . <nl> - failure = true ; <nl> - break ; <nl> - } <nl> - double double_value = elements - > get_scalar ( i ) ; <nl> - double_storage - > set ( j , double_value ) ; <nl> - j + + ; <nl> - } <nl> - break ; <nl> - } <nl> - case FAST_HOLEY_SMI_ELEMENTS : <nl> - case FAST_SMI_ELEMENTS : { <nl> - FixedArray * elements ( FixedArray : : cast ( array - > elements ( ) ) ) ; <nl> - for ( uint32_t i = 0 ; i < length ; i + + ) { <nl> - Object * element = elements - > get ( i ) ; <nl> - if ( element - > IsTheHole ( ) ) { <nl> - failure = true ; <nl> - break ; <nl> - } <nl> - int32_t int_value = Smi : : cast ( element ) - > value ( ) ; <nl> - double_storage - > set ( j , int_value ) ; <nl> - j + + ; <nl> - } <nl> - break ; <nl> - } <nl> - case FAST_HOLEY_ELEMENTS : <nl> - case FAST_ELEMENTS : <nl> - DCHECK_EQ ( 0 , length ) ; <nl> - break ; <nl> - default : <nl> - UNREACHABLE ( ) ; <nl> - } <nl> - } <nl> - if ( failure ) break ; <nl> - } <nl> - } <nl> - if ( ! failure ) { <nl> - Handle < JSArray > array = isolate - > factory ( ) - > NewJSArray ( 0 ) ; <nl> - Smi * length = Smi : : FromInt ( j ) ; <nl> - Handle < Map > map ; <nl> - map = JSObject : : GetElementsTransitionMap ( array , kind ) ; <nl> - array - > set_map ( * map ) ; <nl> - array - > set_length ( length ) ; <nl> - array - > set_elements ( * storage ) ; <nl> - return * array ; <nl> - } <nl> - / / In case of failure , fall through . <nl> - } <nl> - <nl> - Handle < FixedArray > storage ; <nl> - if ( fast_case ) { <nl> - / / The backing storage array must have non - existing elements to preserve <nl> - / / holes across concat operations . <nl> - storage = <nl> - isolate - > factory ( ) - > NewFixedArrayWithHoles ( estimate_result_length ) ; <nl> - } else { <nl> - / / TODO ( 126 ) : move 25 % pre - allocation logic into Dictionary : : Allocate <nl> - uint32_t at_least_space_for = <nl> - estimate_nof_elements + ( estimate_nof_elements > > 2 ) ; <nl> - storage = Handle < FixedArray > : : cast ( <nl> - SeededNumberDictionary : : New ( isolate , at_least_space_for ) ) ; <nl> - } <nl> - <nl> - ArrayConcatVisitor visitor ( isolate , storage , fast_case ) ; <nl> - <nl> - for ( int i = 0 ; i < argument_count ; i + + ) { <nl> - Handle < Object > obj ( elements - > get ( i ) , isolate ) ; <nl> - if ( obj - > IsJSArray ( ) ) { <nl> - Handle < JSArray > array = Handle < JSArray > : : cast ( obj ) ; <nl> - if ( ! IterateElements ( isolate , array , & visitor ) ) { <nl> - return isolate - > heap ( ) - > exception ( ) ; <nl> - } <nl> - } else { <nl> - visitor . visit ( 0 , obj ) ; <nl> - visitor . increase_index_offset ( 1 ) ; <nl> - } <nl> - } <nl> - <nl> - if ( visitor . exceeds_array_limit ( ) ) { <nl> - THROW_NEW_ERROR_RETURN_FAILURE ( <nl> - isolate , <nl> - NewRangeError ( " invalid_array_length " , HandleVector < Object > ( NULL , 0 ) ) ) ; <nl> - } <nl> - return * visitor . ToArray ( ) ; <nl> - } <nl> - <nl> - <nl> - / / Moves all own elements of an object , that are below a limit , to positions <nl> - / / starting at zero . All undefined values are placed after non - undefined values , <nl> - / / and are followed by non - existing element . Does not change the length <nl> - / / property . <nl> - / / Returns the number of non - undefined elements collected . <nl> - / / Returns - 1 if hole removal is not supported by this method . <nl> - RUNTIME_FUNCTION ( Runtime_RemoveArrayHoles ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - CONVERT_NUMBER_CHECKED ( uint32_t , limit , Uint32 , args [ 1 ] ) ; <nl> - return * JSObject : : PrepareElementsForSort ( object , limit ) ; <nl> - } <nl> - <nl> - <nl> - / / Move contents of argument 0 ( an array ) to argument 1 ( an array ) <nl> - RUNTIME_FUNCTION ( Runtime_MoveArrayContents ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSArray , from , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSArray , to , 1 ) ; <nl> - JSObject : : ValidateElements ( from ) ; <nl> - JSObject : : ValidateElements ( to ) ; <nl> - <nl> - Handle < FixedArrayBase > new_elements ( from - > elements ( ) ) ; <nl> - ElementsKind from_kind = from - > GetElementsKind ( ) ; <nl> - Handle < Map > new_map = JSObject : : GetElementsTransitionMap ( to , from_kind ) ; <nl> - JSObject : : SetMapAndElements ( to , new_map , new_elements ) ; <nl> - to - > set_length ( from - > length ( ) ) ; <nl> - <nl> - JSObject : : ResetElements ( from ) ; <nl> - from - > set_length ( Smi : : FromInt ( 0 ) ) ; <nl> - <nl> - JSObject : : ValidateElements ( to ) ; <nl> - return * to ; <nl> - } <nl> - <nl> - <nl> - / / How many elements does this object / array have ? <nl> - RUNTIME_FUNCTION ( Runtime_EstimateNumberOfElements ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSArray , array , 0 ) ; <nl> - Handle < FixedArrayBase > elements ( array - > elements ( ) , isolate ) ; <nl> - SealHandleScope shs ( isolate ) ; <nl> - if ( elements - > IsDictionary ( ) ) { <nl> - int result = <nl> - Handle < SeededNumberDictionary > : : cast ( elements ) - > NumberOfElements ( ) ; <nl> - return Smi : : FromInt ( result ) ; <nl> - } else { <nl> - DCHECK ( array - > length ( ) - > IsSmi ( ) ) ; <nl> - / / For packed elements , we know the exact number of elements <nl> - int length = elements - > length ( ) ; <nl> - ElementsKind kind = array - > GetElementsKind ( ) ; <nl> - if ( IsFastPackedElementsKind ( kind ) ) { <nl> - return Smi : : FromInt ( length ) ; <nl> - } <nl> - / / For holey elements , take samples from the buffer checking for holes <nl> - / / to generate the estimate . <nl> - const int kNumberOfHoleCheckSamples = 97 ; <nl> - int increment = ( length < kNumberOfHoleCheckSamples ) <nl> - ? 1 <nl> - : static_cast < int > ( length / kNumberOfHoleCheckSamples ) ; <nl> - ElementsAccessor * accessor = array - > GetElementsAccessor ( ) ; <nl> - int holes = 0 ; <nl> - for ( int i = 0 ; i < length ; i + = increment ) { <nl> - if ( ! accessor - > HasElement ( array , array , i , elements ) ) { <nl> - + + holes ; <nl> - } <nl> - } <nl> - int estimate = static_cast < int > ( ( kNumberOfHoleCheckSamples - holes ) / <nl> - kNumberOfHoleCheckSamples * length ) ; <nl> - return Smi : : FromInt ( estimate ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / / Returns an array that tells you where in the [ 0 , length ) interval an array <nl> - / / might have elements . Can either return an array of keys ( positive integers <nl> - / / or undefined ) or a number representing the positive length of an interval <nl> - / / starting at index 0 . <nl> - / / Intervals can span over some keys that are not in the object . <nl> - RUNTIME_FUNCTION ( Runtime_GetArrayKeys ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , array , 0 ) ; <nl> - CONVERT_NUMBER_CHECKED ( uint32_t , length , Uint32 , args [ 1 ] ) ; <nl> - if ( array - > elements ( ) - > IsDictionary ( ) ) { <nl> - Handle < FixedArray > keys = isolate - > factory ( ) - > empty_fixed_array ( ) ; <nl> - for ( PrototypeIterator iter ( isolate , array , <nl> - PrototypeIterator : : START_AT_RECEIVER ) ; <nl> - ! iter . IsAtEnd ( ) ; iter . Advance ( ) ) { <nl> - if ( PrototypeIterator : : GetCurrent ( iter ) - > IsJSProxy ( ) | | <nl> - JSObject : : cast ( * PrototypeIterator : : GetCurrent ( iter ) ) <nl> - - > HasIndexedInterceptor ( ) ) { <nl> - / / Bail out if we find a proxy or interceptor , likely not worth <nl> - / / collecting keys in that case . <nl> - return * isolate - > factory ( ) - > NewNumberFromUint ( length ) ; <nl> - } <nl> - Handle < JSObject > current = <nl> - Handle < JSObject > : : cast ( PrototypeIterator : : GetCurrent ( iter ) ) ; <nl> - Handle < FixedArray > current_keys = <nl> - isolate - > factory ( ) - > NewFixedArray ( current - > NumberOfOwnElements ( NONE ) ) ; <nl> - current - > GetOwnElementKeys ( * current_keys , NONE ) ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , keys , FixedArray : : UnionOfKeys ( keys , current_keys ) ) ; <nl> - } <nl> - / / Erase any keys > = length . <nl> - / / TODO ( adamk ) : Remove this step when the contract of % GetArrayKeys <nl> - / / is changed to let this happen on the JS side . <nl> - for ( int i = 0 ; i < keys - > length ( ) ; i + + ) { <nl> - if ( NumberToUint32 ( keys - > get ( i ) ) > = length ) keys - > set_undefined ( i ) ; <nl> - } <nl> - return * isolate - > factory ( ) - > NewJSArrayWithElements ( keys ) ; <nl> - } else { <nl> - RUNTIME_ASSERT ( array - > HasFastSmiOrObjectElements ( ) | | <nl> - array - > HasFastDoubleElements ( ) ) ; <nl> - uint32_t actual_length = static_cast < uint32_t > ( array - > elements ( ) - > length ( ) ) ; <nl> - return * isolate - > factory ( ) - > NewNumberFromUint ( Min ( actual_length , length ) ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_LookupAccessor ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 3 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSReceiver , receiver , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Name , name , 1 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( flag , 2 ) ; <nl> - AccessorComponent component = flag = = 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER ; <nl> - if ( ! receiver - > IsJSObject ( ) ) return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - Handle < Object > result ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , result , <nl> - JSObject : : GetAccessor ( Handle < JSObject > : : cast ( receiver ) , name , component ) ) ; <nl> - return * result ; <nl> - } <nl> - <nl> - <nl> - / / Collect the raw data for a stack trace . Returns an array of 4 <nl> - / / element segments each containing a receiver , function , code and <nl> - / / native code offset . <nl> - RUNTIME_FUNCTION ( Runtime_CollectStackTrace ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , error_object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , caller , 1 ) ; <nl> - <nl> - if ( ! isolate - > bootstrapper ( ) - > IsActive ( ) ) { <nl> - / / Optionally capture a more detailed stack trace for the message . <nl> - isolate - > CaptureAndSetDetailedStackTrace ( error_object ) ; <nl> - / / Capture a simple stack trace for the stack property . <nl> - isolate - > CaptureAndSetSimpleStackTrace ( error_object , caller ) ; <nl> - } <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_LoadMutableDouble ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , object , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Smi , index , 1 ) ; <nl> - RUNTIME_ASSERT ( ( index - > value ( ) & 1 ) = = 1 ) ; <nl> - FieldIndex field_index = <nl> - FieldIndex : : ForLoadByFieldIndex ( object - > map ( ) , index - > value ( ) ) ; <nl> - if ( field_index . is_inobject ( ) ) { <nl> - RUNTIME_ASSERT ( field_index . property_index ( ) < <nl> - object - > map ( ) - > inobject_properties ( ) ) ; <nl> - } else { <nl> - RUNTIME_ASSERT ( field_index . outobject_array_index ( ) < <nl> - object - > properties ( ) - > length ( ) ) ; <nl> - } <nl> - Handle < Object > raw_value ( object - > RawFastPropertyAt ( field_index ) , isolate ) ; <nl> - RUNTIME_ASSERT ( raw_value - > IsMutableHeapNumber ( ) ) ; <nl> - return * Object : : WrapForRead ( isolate , raw_value , Representation : : Double ( ) ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_TryMigrateInstance ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , object , 0 ) ; <nl> - if ( ! object - > IsJSObject ( ) ) return Smi : : FromInt ( 0 ) ; <nl> - Handle < JSObject > js_object = Handle < JSObject > : : cast ( object ) ; <nl> - if ( ! js_object - > map ( ) - > is_deprecated ( ) ) return Smi : : FromInt ( 0 ) ; <nl> - / / This call must not cause lazy deopts , because it ' s called from deferred <nl> - / / code where we can ' t handle lazy deopts for lack of a suitable bailout <nl> - / / ID . So we just try migration and signal failure if necessary , <nl> - / / which will also trigger a deopt . <nl> - if ( ! JSObject : : TryMigrateInstance ( js_object ) ) return Smi : : FromInt ( 0 ) ; <nl> - return * object ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_GetFromCache ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - / / This is only called from codegen , so checks might be more lax . <nl> - CONVERT_ARG_CHECKED ( JSFunctionResultCache , cache , 0 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , key , 1 ) ; <nl> - <nl> - { <nl> - DisallowHeapAllocation no_alloc ; <nl> - <nl> - int finger_index = cache - > finger_index ( ) ; <nl> - Object * o = cache - > get ( finger_index ) ; <nl> - if ( o = = key ) { <nl> - / / The fastest case : hit the same place again . <nl> - return cache - > get ( finger_index + 1 ) ; <nl> - } <nl> - <nl> - for ( int i = finger_index - 2 ; i > = JSFunctionResultCache : : kEntriesIndex ; <nl> - i - = 2 ) { <nl> - o = cache - > get ( i ) ; <nl> - if ( o = = key ) { <nl> - cache - > set_finger_index ( i ) ; <nl> - return cache - > get ( i + 1 ) ; <nl> - } <nl> - } <nl> - <nl> - int size = cache - > size ( ) ; <nl> - DCHECK ( size < = cache - > length ( ) ) ; <nl> - <nl> - for ( int i = size - 2 ; i > finger_index ; i - = 2 ) { <nl> - o = cache - > get ( i ) ; <nl> - if ( o = = key ) { <nl> - cache - > set_finger_index ( i ) ; <nl> - return cache - > get ( i + 1 ) ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - / / There is no value in the cache . Invoke the function and cache result . <nl> - HandleScope scope ( isolate ) ; <nl> - <nl> - Handle < JSFunctionResultCache > cache_handle ( cache ) ; <nl> - Handle < Object > key_handle ( key , isolate ) ; <nl> - Handle < Object > value ; <nl> - { <nl> - Handle < JSFunction > factory ( JSFunction : : cast ( <nl> - cache_handle - > get ( JSFunctionResultCache : : kFactoryIndex ) ) ) ; <nl> - / / TODO ( antonm ) : consider passing a receiver when constructing a cache . <nl> - Handle < JSObject > receiver ( isolate - > global_proxy ( ) ) ; <nl> - / / This handle is nor shared , nor used later , so it ' s safe . <nl> - Handle < Object > argv [ ] = { key_handle } ; <nl> - ASSIGN_RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , value , <nl> - Execution : : Call ( isolate , factory , receiver , arraysize ( argv ) , argv ) ) ; <nl> - } <nl> - <nl> - # ifdef VERIFY_HEAP <nl> - if ( FLAG_verify_heap ) { <nl> - cache_handle - > JSFunctionResultCacheVerify ( ) ; <nl> - } <nl> - # endif <nl> - <nl> - / / Function invocation may have cleared the cache . Reread all the data . <nl> - int finger_index = cache_handle - > finger_index ( ) ; <nl> - int size = cache_handle - > size ( ) ; <nl> - <nl> - / / If we have spare room , put new data into it , otherwise evict post finger <nl> - / / entry which is likely to be the least recently used . <nl> - int index = - 1 ; <nl> - if ( size < cache_handle - > length ( ) ) { <nl> - cache_handle - > set_size ( size + JSFunctionResultCache : : kEntrySize ) ; <nl> - index = size ; <nl> - } else { <nl> - index = finger_index + JSFunctionResultCache : : kEntrySize ; <nl> - if ( index = = cache_handle - > length ( ) ) { <nl> - index = JSFunctionResultCache : : kEntriesIndex ; <nl> - } <nl> - } <nl> - <nl> - DCHECK ( index % 2 = = 0 ) ; <nl> - DCHECK ( index > = JSFunctionResultCache : : kEntriesIndex ) ; <nl> - DCHECK ( index < cache_handle - > length ( ) ) ; <nl> - <nl> - cache_handle - > set ( index , * key_handle ) ; <nl> - cache_handle - > set ( index + 1 , * value ) ; <nl> - cache_handle - > set_finger_index ( index ) ; <nl> - <nl> - # ifdef VERIFY_HEAP <nl> - if ( FLAG_verify_heap ) { <nl> - cache_handle - > JSFunctionResultCacheVerify ( ) ; <nl> - } <nl> - # endif <nl> - <nl> - return * value ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_MessageGetStartPosition ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( JSMessageObject , message , 0 ) ; <nl> - return Smi : : FromInt ( message - > start_position ( ) ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_MessageGetScript ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( JSMessageObject , message , 0 ) ; <nl> - return message - > script ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_IS_VAR ) { <nl> - UNREACHABLE ( ) ; / / implemented as macro in the parser <nl> - return NULL ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_IsJSGlobalProxy ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> - return isolate - > heap ( ) - > ToBoolean ( obj - > IsJSGlobalProxy ( ) ) ; <nl> - } <nl> - <nl> - <nl> - static Object * ArrayConstructorCommon ( Isolate * isolate , <nl> - Handle < JSFunction > constructor , <nl> - Handle < AllocationSite > site , <nl> - Arguments * caller_args ) { <nl> - Factory * factory = isolate - > factory ( ) ; <nl> - <nl> - bool holey = false ; <nl> - bool can_use_type_feedback = true ; <nl> - if ( caller_args - > length ( ) = = 1 ) { <nl> - Handle < Object > argument_one = caller_args - > at < Object > ( 0 ) ; <nl> - if ( argument_one - > IsSmi ( ) ) { <nl> - int value = Handle < Smi > : : cast ( argument_one ) - > value ( ) ; <nl> - if ( value < 0 | | value > = JSObject : : kInitialMaxFastElementArray ) { <nl> - / / the array is a dictionary in this case . <nl> - can_use_type_feedback = false ; <nl> - } else if ( value ! = 0 ) { <nl> - holey = true ; <nl> - } <nl> - } else { <nl> - / / Non - smi length argument produces a dictionary <nl> - can_use_type_feedback = false ; <nl> - } <nl> - } <nl> - <nl> - Handle < JSArray > array ; <nl> - if ( ! site . is_null ( ) & & can_use_type_feedback ) { <nl> - ElementsKind to_kind = site - > GetElementsKind ( ) ; <nl> - if ( holey & & ! IsFastHoleyElementsKind ( to_kind ) ) { <nl> - to_kind = GetHoleyElementsKind ( to_kind ) ; <nl> - / / Update the allocation site info to reflect the advice alteration . <nl> - site - > SetElementsKind ( to_kind ) ; <nl> - } <nl> - <nl> - / / We should allocate with an initial map that reflects the allocation site <nl> - / / advice . Therefore we use AllocateJSObjectFromMap instead of passing <nl> - / / the constructor . <nl> - Handle < Map > initial_map ( constructor - > initial_map ( ) , isolate ) ; <nl> - if ( to_kind ! = initial_map - > elements_kind ( ) ) { <nl> - initial_map = Map : : AsElementsKind ( initial_map , to_kind ) ; <nl> - } <nl> - <nl> - / / If we don ' t care to track arrays of to_kind ElementsKind , then <nl> - / / don ' t emit a memento for them . <nl> - Handle < AllocationSite > allocation_site ; <nl> - if ( AllocationSite : : GetMode ( to_kind ) = = TRACK_ALLOCATION_SITE ) { <nl> - allocation_site = site ; <nl> - } <nl> - <nl> - array = Handle < JSArray > : : cast ( factory - > NewJSObjectFromMap ( <nl> - initial_map , NOT_TENURED , true , allocation_site ) ) ; <nl> - } else { <nl> - array = Handle < JSArray > : : cast ( factory - > NewJSObject ( constructor ) ) ; <nl> - <nl> - / / We might need to transition to holey <nl> - ElementsKind kind = constructor - > initial_map ( ) - > elements_kind ( ) ; <nl> - if ( holey & & ! IsFastHoleyElementsKind ( kind ) ) { <nl> - kind = GetHoleyElementsKind ( kind ) ; <nl> - JSObject : : TransitionElementsKind ( array , kind ) ; <nl> - } <nl> - } <nl> - <nl> - factory - > NewJSArrayStorage ( array , 0 , 0 , DONT_INITIALIZE_ARRAY_ELEMENTS ) ; <nl> - <nl> - ElementsKind old_kind = array - > GetElementsKind ( ) ; <nl> - RETURN_FAILURE_ON_EXCEPTION ( <nl> - isolate , ArrayConstructInitializeElements ( array , caller_args ) ) ; <nl> - if ( ! site . is_null ( ) & & <nl> - ( old_kind ! = array - > GetElementsKind ( ) | | ! can_use_type_feedback ) ) { <nl> - / / The arguments passed in caused a transition . This kind of complexity <nl> - / / can ' t be dealt with in the inlined hydrogen array constructor case . <nl> - / / We must mark the allocationsite as un - inlinable . <nl> - site - > SetDoNotInlineCall ( ) ; <nl> - } <nl> - return * array ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_ArrayConstructor ) { <nl> - HandleScope scope ( isolate ) ; <nl> - / / If we get 2 arguments then they are the stub parameters ( constructor , type <nl> - / / info ) . If we get 4 , then the first one is a pointer to the arguments <nl> - / / passed by the caller , and the last one is the length of the arguments <nl> - / / passed to the caller ( redundant , but useful to check on the deoptimizer <nl> - / / with an assert ) . <nl> - Arguments empty_args ( 0 , NULL ) ; <nl> - bool no_caller_args = args . length ( ) = = 2 ; <nl> - DCHECK ( no_caller_args | | args . length ( ) = = 4 ) ; <nl> - int parameters_start = no_caller_args ? 0 : 1 ; <nl> - Arguments * caller_args = <nl> - no_caller_args ? & empty_args : reinterpret_cast < Arguments * > ( args [ 0 ] ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSFunction , constructor , parameters_start ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , type_info , parameters_start + 1 ) ; <nl> - # ifdef DEBUG <nl> - if ( ! no_caller_args ) { <nl> - CONVERT_SMI_ARG_CHECKED ( arg_count , parameters_start + 2 ) ; <nl> - DCHECK ( arg_count = = caller_args - > length ( ) ) ; <nl> - } <nl> - # endif <nl> - <nl> - Handle < AllocationSite > site ; <nl> - if ( ! type_info . is_null ( ) & & <nl> - * type_info ! = isolate - > heap ( ) - > undefined_value ( ) ) { <nl> - site = Handle < AllocationSite > : : cast ( type_info ) ; <nl> - DCHECK ( ! site - > SitePointsToLiteral ( ) ) ; <nl> - } <nl> - <nl> - return ArrayConstructorCommon ( isolate , constructor , site , caller_args ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_InternalArrayConstructor ) { <nl> - HandleScope scope ( isolate ) ; <nl> - Arguments empty_args ( 0 , NULL ) ; <nl> - bool no_caller_args = args . length ( ) = = 1 ; <nl> - DCHECK ( no_caller_args | | args . length ( ) = = 3 ) ; <nl> - int parameters_start = no_caller_args ? 0 : 1 ; <nl> - Arguments * caller_args = <nl> - no_caller_args ? & empty_args : reinterpret_cast < Arguments * > ( args [ 0 ] ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSFunction , constructor , parameters_start ) ; <nl> - # ifdef DEBUG <nl> - if ( ! no_caller_args ) { <nl> - CONVERT_SMI_ARG_CHECKED ( arg_count , parameters_start + 1 ) ; <nl> - DCHECK ( arg_count = = caller_args - > length ( ) ) ; <nl> - } <nl> - # endif <nl> - return ArrayConstructorCommon ( isolate , constructor , <nl> - Handle < AllocationSite > : : null ( ) , caller_args ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_NormalizeElements ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( JSObject , array , 0 ) ; <nl> - RUNTIME_ASSERT ( ! array - > HasExternalArrayElements ( ) & & <nl> - ! array - > HasFixedTypedArrayElements ( ) ) ; <nl> - JSObject : : NormalizeElements ( array ) ; <nl> - return * array ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( Runtime_MaxSmi ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 0 ) ; <nl> - return Smi : : FromInt ( Smi : : kMaxValue ) ; <nl> - } <nl> - <nl> - <nl> - / / TODO ( dcarney ) : remove this function when TurboFan supports it . <nl> - / / Takes the object to be iterated over and the result of GetPropertyNamesFast <nl> - / / Returns pair ( cache_array , cache_type ) . <nl> - RUNTIME_FUNCTION_RETURN_PAIR ( Runtime_ForInInit ) { <nl> - SealHandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - / / This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs . <nl> - / / Not worth creating a macro atm as this function should be removed . <nl> - if ( ! args [ 0 ] - > IsJSReceiver ( ) | | ! args [ 1 ] - > IsObject ( ) ) { <nl> - Object * error = isolate - > ThrowIllegalOperation ( ) ; <nl> - return MakePair ( error , isolate - > heap ( ) - > undefined_value ( ) ) ; <nl> - } <nl> - Handle < JSReceiver > object = args . at < JSReceiver > ( 0 ) ; <nl> - Handle < Object > cache_type = args . at < Object > ( 1 ) ; <nl> - if ( cache_type - > IsMap ( ) ) { <nl> - / / Enum cache case . <nl> - if ( Map : : EnumLengthBits : : decode ( Map : : cast ( * cache_type ) - > bit_field3 ( ) ) = = <nl> - 0 ) { <nl> - / / 0 length enum . <nl> - / / Can ' t handle this case in the graph builder , <nl> - / / so transform it into the empty fixed array case . <nl> - return MakePair ( isolate - > heap ( ) - > empty_fixed_array ( ) , Smi : : FromInt ( 1 ) ) ; <nl> - } <nl> - return MakePair ( object - > map ( ) - > instance_descriptors ( ) - > GetEnumCache ( ) , <nl> - * cache_type ) ; <nl> - } else { <nl> - / / FixedArray case . <nl> - Smi * new_cache_type = Smi : : FromInt ( object - > IsJSProxy ( ) ? 0 : 1 ) ; <nl> - return MakePair ( * Handle < FixedArray > : : cast ( cache_type ) , new_cache_type ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / / TODO ( dcarney ) : remove this function when TurboFan supports it . <nl> - RUNTIME_FUNCTION ( Runtime_ForInCacheArrayLength ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( Object , cache_type , 0 ) ; <nl> - CONVERT_ARG_HANDLE_CHECKED ( FixedArray , array , 1 ) ; <nl> - int length = 0 ; <nl> - if ( cache_type - > IsMap ( ) ) { <nl> - length = Map : : cast ( * cache_type ) - > EnumLength ( ) ; <nl> - } else { <nl> - DCHECK ( cache_type - > IsSmi ( ) ) ; <nl> - length = array - > length ( ) ; <nl> - } <nl> - return Smi : : FromInt ( length ) ; <nl> - } <nl> - <nl> - <nl> - / / TODO ( dcarney ) : remove this function when TurboFan supports it . <nl> - / / Takes ( the object to be iterated over , <nl> - / / cache_array from ForInInit , <nl> - / / cache_type from ForInInit , <nl> - / / the current index ) <nl> - / / Returns pair ( array [ index ] , needs_filtering ) . <nl> - RUNTIME_FUNCTION_RETURN_PAIR ( Runtime_ForInNext ) { <nl> - SealHandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 4 ) ; <nl> - int32_t index ; <nl> - / / This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs . <nl> - / / Not worth creating a macro atm as this function should be removed . <nl> - if ( ! args [ 0 ] - > IsJSReceiver ( ) | | ! args [ 1 ] - > IsFixedArray ( ) | | <nl> - ! args [ 2 ] - > IsObject ( ) | | ! args [ 3 ] - > ToInt32 ( & index ) ) { <nl> - Object * error = isolate - > ThrowIllegalOperation ( ) ; <nl> - return MakePair ( error , isolate - > heap ( ) - > undefined_value ( ) ) ; <nl> - } <nl> - Handle < JSReceiver > object = args . at < JSReceiver > ( 0 ) ; <nl> - Handle < FixedArray > array = args . at < FixedArray > ( 1 ) ; <nl> - Handle < Object > cache_type = args . at < Object > ( 2 ) ; <nl> - / / Figure out first if a slow check is needed for this object . <nl> - bool slow_check_needed = false ; <nl> - if ( cache_type - > IsMap ( ) ) { <nl> - if ( object - > map ( ) ! = Map : : cast ( * cache_type ) ) { <nl> - / / Object transitioned . Need slow check . <nl> - slow_check_needed = true ; <nl> - } <nl> - } else { <nl> - / / No slow check needed for proxies . <nl> - slow_check_needed = Smi : : cast ( * cache_type ) - > value ( ) = = 1 ; <nl> - } <nl> - return MakePair ( array - > get ( index ) , <nl> - isolate - > heap ( ) - > ToBoolean ( slow_check_needed ) ) ; <nl> - } <nl> - <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - / / Reference implementation for inlined runtime functions . Only used when the <nl> - / / compiler does not support a certain intrinsic . Don ' t optimize these , but <nl> - / / implement the intrinsic in the respective compiler instead . <nl> - <nl> - / / TODO ( mstarzinger ) : These are place - holder stubs for TurboFan and will <nl> - / / eventually all have a C + + implementation and this macro will be gone . <nl> - # define U ( name ) \ <nl> - RUNTIME_FUNCTION ( RuntimeReference_ # # name ) { \ <nl> - UNIMPLEMENTED ( ) ; \ <nl> - return NULL ; \ <nl> - } <nl> - <nl> - U ( IsStringWrapperSafeForDefaultValueOf ) <nl> - U ( DebugBreakInOptimizedCode ) <nl> - <nl> - # undef U <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_IsArray ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> - return isolate - > heap ( ) - > ToBoolean ( obj - > IsJSArray ( ) ) ; <nl> - } <nl> - <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_ValueOf ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> - if ( ! obj - > IsJSValue ( ) ) return obj ; <nl> - return JSValue : : cast ( obj ) - > value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_SetValueOf ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , value , 1 ) ; <nl> - if ( ! obj - > IsJSValue ( ) ) return value ; <nl> - JSValue : : cast ( obj ) - > set_value ( value ) ; <nl> - return value ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_ObjectEquals ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj1 , 0 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj2 , 1 ) ; <nl> - return isolate - > heap ( ) - > ToBoolean ( obj1 = = obj2 ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_IsObject ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> - if ( ! obj - > IsHeapObject ( ) ) return isolate - > heap ( ) - > false_value ( ) ; <nl> - if ( obj - > IsNull ( ) ) return isolate - > heap ( ) - > true_value ( ) ; <nl> - if ( obj - > IsUndetectableObject ( ) ) return isolate - > heap ( ) - > false_value ( ) ; <nl> - Map * map = HeapObject : : cast ( obj ) - > map ( ) ; <nl> - bool is_non_callable_spec_object = <nl> - map - > instance_type ( ) > = FIRST_NONCALLABLE_SPEC_OBJECT_TYPE & & <nl> - map - > instance_type ( ) < = LAST_NONCALLABLE_SPEC_OBJECT_TYPE ; <nl> - return isolate - > heap ( ) - > ToBoolean ( is_non_callable_spec_object ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_IsUndetectableObject ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> - return isolate - > heap ( ) - > ToBoolean ( obj - > IsUndetectableObject ( ) ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_IsSpecObject ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> - return isolate - > heap ( ) - > ToBoolean ( obj - > IsSpecObject ( ) ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_HasCachedArrayIndex ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - return isolate - > heap ( ) - > false_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_GetCachedArrayIndex ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_FastOneByteArrayJoin ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - return isolate - > heap ( ) - > undefined_value ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_ClassOf ) { <nl> - SealHandleScope shs ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 1 ) ; <nl> - CONVERT_ARG_CHECKED ( Object , obj , 0 ) ; <nl> - if ( ! obj - > IsJSReceiver ( ) ) return isolate - > heap ( ) - > null_value ( ) ; <nl> - return JSReceiver : : cast ( obj ) - > class_name ( ) ; <nl> - } <nl> - <nl> - <nl> - RUNTIME_FUNCTION ( RuntimeReference_GetFromCache ) { <nl> - HandleScope scope ( isolate ) ; <nl> - DCHECK ( args . length ( ) = = 2 ) ; <nl> - CONVERT_SMI_ARG_CHECKED ( id , 0 ) ; <nl> - args [ 0 ] = isolate - > native_context ( ) - > jsfunction_result_caches ( ) - > get ( id ) ; <nl> - return __RT_impl_Runtime_GetFromCache ( args , isolate ) ; <nl> - } <nl> - <nl> - <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> - / / Implementation of Runtime <nl> - <nl> # define F ( name , number_of_args , result_size ) \ <nl> { \ <nl> Runtime : : k # # name , Runtime : : RUNTIME , # name , FUNCTION_ADDR ( Runtime_ # # name ) , \ <nl> mmm a / tools / gyp / v8 . gyp <nl> ppp b / tools / gyp / v8 . gyp <nl> <nl> ' . . / . . / src / rewriter . h ' , <nl> ' . . / . . / src / runtime - profiler . cc ' , <nl> ' . . / . . / src / runtime - profiler . h ' , <nl> + ' . . / . . / src / runtime / runtime - api . cc ' , <nl> + ' . . / . . / src / runtime / runtime - array . cc ' , <nl> ' . . / . . / src / runtime / runtime - classes . cc ' , <nl> ' . . / . . / src / runtime / runtime - collections . cc ' , <nl> ' . . / . . / src / runtime / runtime - compiler . cc ' , <nl> <nl> ' . . / . . / src / runtime / runtime - function . cc ' , <nl> ' . . / . . / src / runtime / runtime - generator . cc ' , <nl> ' . . / . . / src / runtime / runtime - i18n . cc ' , <nl> + ' . . / . . / src / runtime / runtime - internal . cc ' , <nl> ' . . / . . / src / runtime / runtime - json . cc ' , <nl> ' . . / . . / src / runtime / runtime - literals . cc ' , <nl> ' . . / . . / src / runtime / runtime - liveedit . cc ' , <nl> ' . . / . . / src / runtime / runtime - maths . cc ' , <nl> ' . . / . . / src / runtime / runtime - numbers . cc ' , <nl> + ' . . / . . / src / runtime / runtime - object . cc ' , <nl> ' . . / . . / src / runtime / runtime - observe . cc ' , <nl> ' . . / . . / src / runtime / runtime - proxy . cc ' , <nl> ' . . / . . / src / runtime / runtime - regexp . cc ' , <nl>
Split off remaining runtime functions in runtime . cc .
v8/v8
ba6e17c4940cfcb988f53fec806d8cec77e29967
2014-10-10T14:59:53Z
mmm a / lib / AST / Type . cpp <nl> ppp b / lib / AST / Type . cpp <nl> bool TypeBase : : isUninhabited ( ) { <nl> / / Empty enum declarations are uninhabited <nl> if ( auto nominalDecl = getAnyNominal ( ) ) <nl> if ( auto enumDecl = dyn_cast < EnumDecl > ( nominalDecl ) ) <nl> - if ( enumDecl - > getAllElements ( ) . empty ( ) ) <nl> + / / Objective - C enums may be allowed to hold any value representable by <nl> + / / the underlying type , but only if they come from clang . <nl> + if ( enumDecl - > getAllElements ( ) . empty ( ) & & <nl> + ! ( enumDecl - > isObjC ( ) & & enumDecl - > hasClangNode ( ) ) ) <nl> return true ; <nl> return false ; <nl> } <nl> mmm a / lib / IRGen / GenEnum . cpp <nl> ppp b / lib / IRGen / GenEnum . cpp <nl> namespace { <nl> std : : move ( WithNoPayload ) ) <nl> { <nl> assert ( ElementsWithPayload . empty ( ) ) ; <nl> - assert ( ! ElementsWithNoPayload . empty ( ) ) ; <nl> } <nl> <nl> bool needsPayloadSizeInMetadata ( ) const override { return false ; } <nl> namespace { <nl> std : : move ( WithNoPayload ) ) <nl> { <nl> assert ( ElementsWithPayload . empty ( ) ) ; <nl> - assert ( ! ElementsWithNoPayload . empty ( ) ) ; <nl> } <nl> <nl> TypeInfo * completeEnumTypeLayout ( TypeConverter & TC , <nl> mmm a / test / ClangImporter / Inputs / custom - modules / cxx_interop . h <nl> ppp b / test / ClangImporter / Inputs / custom - modules / cxx_interop . h <nl> class Methods2 { <nl> public : <nl> int SimpleMethod ( int ) ; <nl> } ; <nl> + <nl> + enum __attribute__ ( ( enum_extensibility ( open ) ) ) OpenEmptyEnum : char { } ; <nl> new file mode 100644 <nl> index 000000000000 . . 73ecea81def5 <nl> mmm / dev / null <nl> ppp b / test / ClangImporter / enum - cxx . swift <nl> <nl> + / / RUN : % target - swift - frontend - emit - ir - primary - file % s - I % S / Inputs / custom - modules - module - cache - path % t - enable - cxx - interop - o - | % FileCheck % s <nl> + <nl> + import CXXInterop <nl> + <nl> + / / CHECK - LABEL : define hidden swiftcc i8 @ " $ s4main19testEmptyEnumImport5values4Int8VSo04OpencD0V_tF " ( i8 ) <nl> + / / CHECK : % 1 = call swiftcc i8 @ " $ sSo13OpenEmptyEnumV8rawValues4Int8Vvg " ( i8 % 0 ) <nl> + / / CHECK : ret i8 % 1 <nl> + func testEmptyEnumImport ( value : OpenEmptyEnum ) - > Int8 { <nl> + / / Should still compile even though the enum is uninhabited in c + + . <nl> + return value . rawValue <nl> + } <nl>
[ C + + Interop ] Uninhabitted enums are still possible . ( )
apple/swift
64d0c426ffecd1d0598116605e69c9ab907876e5
2019-08-05T22:52:04Z
mmm a / src / compiler / js - heap - broker . cc <nl> ppp b / src / compiler / js - heap - broker . cc <nl> MapRef NativeContextRef : : GetFunctionMapFromIndex ( const JSHeapBroker * broker , <nl> return get ( broker , index ) . AsMap ( ) ; <nl> } <nl> <nl> + bool ObjectRef : : BooleanValue ( const JSHeapBroker * broker ) { <nl> + AllowHandleDereference allow_handle_dereference ; <nl> + return object < Object > ( ) - > BooleanValue ( broker - > isolate ( ) ) ; <nl> + } <nl> + <nl> } / / namespace compiler <nl> } / / namespace internal <nl> } / / namespace v8 <nl> mmm a / src / compiler / js - heap - broker . h <nl> ppp b / src / compiler / js - heap - broker . h <nl> class ObjectRef { <nl> <nl> OddballType oddball_type ( const JSHeapBroker * broker ) const ; <nl> <nl> - StringRef TypeOf ( const JSHeapBroker * broker ) const ; <nl> - <nl> bool IsSmi ( ) const ; <nl> int AsSmi ( ) const ; <nl> <nl> class ObjectRef { <nl> HEAP_BROKER_OBJECT_LIST ( HEAP_AS_METHOD_DECL ) <nl> # undef HEAP_AS_METHOD_DECL <nl> <nl> + StringRef TypeOf ( const JSHeapBroker * broker ) const ; <nl> + bool BooleanValue ( const JSHeapBroker * broker ) ; <nl> + <nl> private : <nl> Handle < Object > object_ ; <nl> } ; <nl> mmm a / src / compiler / pipeline . cc <nl> ppp b / src / compiler / pipeline . cc <nl> struct TypedLoweringPhase { <nl> TypedOptimization typed_optimization ( & graph_reducer , data - > dependencies ( ) , <nl> data - > jsgraph ( ) , <nl> data - > js_heap_broker ( ) ) ; <nl> - SimplifiedOperatorReducer simple_reducer ( & graph_reducer , data - > jsgraph ( ) ) ; <nl> + SimplifiedOperatorReducer simple_reducer ( & graph_reducer , data - > jsgraph ( ) , <nl> + data - > js_heap_broker ( ) ) ; <nl> CheckpointElimination checkpoint_elimination ( & graph_reducer ) ; <nl> CommonOperatorReducer common_reducer ( data - > isolate ( ) , & graph_reducer , <nl> data - > graph ( ) , data - > common ( ) , <nl> struct EarlyOptimizationPhase { <nl> data - > jsgraph ( ) - > Dead ( ) ) ; <nl> DeadCodeElimination dead_code_elimination ( & graph_reducer , data - > graph ( ) , <nl> data - > common ( ) , temp_zone ) ; <nl> - SimplifiedOperatorReducer simple_reducer ( & graph_reducer , data - > jsgraph ( ) ) ; <nl> + SimplifiedOperatorReducer simple_reducer ( & graph_reducer , data - > jsgraph ( ) , <nl> + data - > js_heap_broker ( ) ) ; <nl> RedundancyElimination redundancy_elimination ( & graph_reducer , temp_zone ) ; <nl> ValueNumberingReducer value_numbering ( temp_zone , data - > graph ( ) - > zone ( ) ) ; <nl> MachineOperatorReducer machine_reducer ( data - > jsgraph ( ) ) ; <nl> mmm a / src / compiler / simplified - operator - reducer . cc <nl> ppp b / src / compiler / simplified - operator - reducer . cc <nl> Decision DecideObjectIsSmi ( Node * const input ) { <nl> <nl> } / / namespace <nl> <nl> - SimplifiedOperatorReducer : : SimplifiedOperatorReducer ( Editor * editor , <nl> - JSGraph * jsgraph ) <nl> - : AdvancedReducer ( editor ) , jsgraph_ ( jsgraph ) { } <nl> + SimplifiedOperatorReducer : : SimplifiedOperatorReducer ( <nl> + Editor * editor , JSGraph * jsgraph , const JSHeapBroker * js_heap_broker ) <nl> + : AdvancedReducer ( editor ) , <nl> + jsgraph_ ( jsgraph ) , <nl> + js_heap_broker_ ( js_heap_broker ) { } <nl> <nl> SimplifiedOperatorReducer : : ~ SimplifiedOperatorReducer ( ) { } <nl> <nl> <nl> Reduction SimplifiedOperatorReducer : : Reduce ( Node * node ) { <nl> + DisallowHeapAllocation no_heap_allocation ; <nl> + DisallowHandleAllocation no_handle_allocation ; <nl> + DisallowHandleDereference no_handle_dereference ; <nl> + DisallowCodeDependencyChange no_dependency_change ; <nl> + <nl> switch ( node - > opcode ( ) ) { <nl> case IrOpcode : : kBooleanNot : { <nl> + / / TODO ( neis ) : Provide HeapObjectRefMatcher ? <nl> HeapObjectMatcher m ( node - > InputAt ( 0 ) ) ; <nl> if ( m . Is ( factory ( ) - > true_value ( ) ) ) return ReplaceBoolean ( false ) ; <nl> if ( m . Is ( factory ( ) - > false_value ( ) ) ) return ReplaceBoolean ( true ) ; <nl> Reduction SimplifiedOperatorReducer : : Reduce ( Node * node ) { <nl> } <nl> case IrOpcode : : kChangeTaggedToBit : { <nl> HeapObjectMatcher m ( node - > InputAt ( 0 ) ) ; <nl> - if ( m . HasValue ( ) ) return ReplaceInt32 ( m . Value ( ) - > BooleanValue ( isolate ( ) ) ) ; <nl> + if ( m . HasValue ( ) ) { <nl> + HeapObjectRef object ( m . Value ( ) ) ; <nl> + return ReplaceInt32 ( object . BooleanValue ( js_heap_broker ( ) ) ) ; <nl> + } <nl> if ( m . IsChangeBitToTagged ( ) ) return Replace ( m . InputAt ( 0 ) ) ; <nl> break ; <nl> } <nl> mmm a / src / compiler / simplified - operator - reducer . h <nl> ppp b / src / compiler / simplified - operator - reducer . h <nl> class SimplifiedOperatorBuilder ; <nl> class V8_EXPORT_PRIVATE SimplifiedOperatorReducer final <nl> : public NON_EXPORTED_BASE ( AdvancedReducer ) { <nl> public : <nl> - SimplifiedOperatorReducer ( Editor * editor , JSGraph * jsgraph ) ; <nl> + SimplifiedOperatorReducer ( Editor * editor , JSGraph * jsgraph , <nl> + const JSHeapBroker * js_heap_broker ) ; <nl> ~ SimplifiedOperatorReducer ( ) final ; <nl> <nl> const char * reducer_name ( ) const override { <nl> class V8_EXPORT_PRIVATE SimplifiedOperatorReducer final <nl> Factory * factory ( ) const ; <nl> Graph * graph ( ) const ; <nl> Isolate * isolate ( ) const ; <nl> - JSGraph * jsgraph ( ) const { return jsgraph_ ; } <nl> MachineOperatorBuilder * machine ( ) const ; <nl> SimplifiedOperatorBuilder * simplified ( ) const ; <nl> <nl> + JSGraph * jsgraph ( ) const { return jsgraph_ ; } <nl> + const JSHeapBroker * js_heap_broker ( ) const { return js_heap_broker_ ; } <nl> + <nl> JSGraph * const jsgraph_ ; <nl> + const JSHeapBroker * const js_heap_broker_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( SimplifiedOperatorReducer ) ; <nl> } ; <nl> mmm a / test / unittests / compiler / simplified - operator - reducer - unittest . cc <nl> ppp b / test / unittests / compiler / simplified - operator - reducer - unittest . cc <nl> class SimplifiedOperatorReducerTest : public GraphTest { <nl> <nl> protected : <nl> Reduction Reduce ( Node * node ) { <nl> + JSHeapBroker js_heap_broker ( isolate ( ) ) ; <nl> MachineOperatorBuilder machine ( zone ( ) ) ; <nl> JSOperatorBuilder javascript ( zone ( ) ) ; <nl> JSGraph jsgraph ( isolate ( ) , graph ( ) , common ( ) , & javascript , simplified ( ) , <nl> & machine ) ; <nl> GraphReducer graph_reducer ( zone ( ) , graph ( ) ) ; <nl> - SimplifiedOperatorReducer reducer ( & graph_reducer , & jsgraph ) ; <nl> + SimplifiedOperatorReducer reducer ( & graph_reducer , & jsgraph , <nl> + & js_heap_broker ) ; <nl> return reducer . Reduce ( node ) ; <nl> } <nl> <nl>
[ turbofan ] Brokerize simplified operator reducer .
v8/v8
686212895197fd89069770de85e6a736015e19ec
2018-07-10T07:34:09Z
mmm a / tensorflow / compiler / mlir / tensorflow / ir / tf_generated_ops . td <nl> ppp b / tensorflow / compiler / mlir / tensorflow / ir / tf_generated_ops . td <nl> This is the opposite of ` pack ` . <nl> let verifier = [ { return Verify ( * this ) ; } ] ; <nl> } <nl> <nl> + def TF_UnsortedSegmentMaxOp : TF_Op < " UnsortedSegmentMax " , [ NoSideEffect ] > { <nl> + let summary = " Computes the maximum along segments of a tensor . " ; <nl> + <nl> + let description = [ { <nl> + Read <nl> + [ the section on segmentation ] ( https : / / tensorflow . org / api_docs / python / tf / math # Segmentation ) <nl> + for an explanation of segments . <nl> + <nl> + This operator is similar to the unsorted segment sum operator found <nl> + [ ( here ) ] ( . . / . . / . . / api_docs / python / math_ops . md # UnsortedSegmentSum ) . <nl> + Instead of computing the sum over segments , it computes the maximum such that : <nl> + <nl> + \ \ ( output_i = \ max_ { j . . . } data [ j . . . ] \ \ ) where max is over tuples ` j . . . ` such <nl> + that ` segment_ids [ j . . . ] = = i ` . <nl> + <nl> + If the maximum is empty for a given segment ID ` i ` , it outputs the smallest <nl> + possible value for the specific numeric type , <nl> + ` output [ i ] = numeric_limits < T > : : lowest ( ) ` . <nl> + <nl> + If the given segment ID ` i ` is negative , then the corresponding value is <nl> + dropped , and will not be included in the result . <nl> + <nl> + < div style = " width : 70 % ; margin : auto ; margin - bottom : 10px ; margin - top : 20px ; " > <nl> + < img style = " width : 100 % " src = " https : / / www . tensorflow . org / images / UnsortedSegmentMax . png " alt > <nl> + < / div > <nl> + <nl> + For example : <nl> + <nl> + ` ` ` python <nl> + c = tf . constant ( [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] , [ 4 , 3 , 2 , 1 ] ] ) <nl> + tf . unsorted_segment_max ( c , tf . constant ( [ 0 , 1 , 0 ] ) , num_segments = 2 ) <nl> + # = = > [ [ 4 , 3 , 3 , 4 ] , <nl> + # [ 5 , 6 , 7 , 8 ] ] <nl> + ` ` ` <nl> + } ] ; <nl> + <nl> + let arguments = ( ins <nl> + TF_IntOrFpTensor : $ data , <nl> + TF_I32OrI64Tensor : $ segment_ids , <nl> + TF_I32OrI64Tensor : $ num_segments <nl> + ) ; <nl> + <nl> + let results = ( outs <nl> + TF_IntOrFpTensor : $ output <nl> + ) ; <nl> + <nl> + TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr < 1 > ; <nl> + TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr < 0 > ; <nl> + TF_DerivedOperandTypeAttr Tnumsegments = TF_DerivedOperandTypeAttr < 2 > ; <nl> + <nl> + let verifier = [ { return VerifyUnsortedSegmentReduction ( * this ) ; } ] ; <nl> + } <nl> + <nl> + def TF_UnsortedSegmentMinOp : TF_Op < " UnsortedSegmentMin " , [ NoSideEffect ] > { <nl> + let summary = " Computes the minimum along segments of a tensor . " ; <nl> + <nl> + let description = [ { <nl> + Read <nl> + [ the section on segmentation ] ( https : / / tensorflow . org / api_docs / python / tf / math # Segmentation ) <nl> + for an explanation of segments . <nl> + <nl> + This operator is similar to the unsorted segment sum operator found <nl> + [ ( here ) ] ( . . / . . / . . / api_docs / python / math_ops . md # UnsortedSegmentSum ) . <nl> + Instead of computing the sum over segments , it computes the minimum such that : <nl> + <nl> + \ \ ( output_i = \ min_ { j . . . } data_ [ j . . . ] \ \ ) where min is over tuples ` j . . . ` such <nl> + that ` segment_ids [ j . . . ] = = i ` . <nl> + <nl> + If the minimum is empty for a given segment ID ` i ` , it outputs the largest <nl> + possible value for the specific numeric type , <nl> + ` output [ i ] = numeric_limits < T > : : max ( ) ` . <nl> + <nl> + For example : <nl> + <nl> + ` ` ` python <nl> + c = tf . constant ( [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] , [ 4 , 3 , 2 , 1 ] ] ) <nl> + tf . unsorted_segment_min ( c , tf . constant ( [ 0 , 1 , 0 ] ) , num_segments = 2 ) <nl> + # = = > [ [ 1 , 2 , 2 , 1 ] , <nl> + # [ 5 , 6 , 7 , 8 ] ] <nl> + ` ` ` <nl> + <nl> + If the given segment ID ` i ` is negative , then the corresponding value is <nl> + dropped , and will not be included in the result . <nl> + } ] ; <nl> + <nl> + let arguments = ( ins <nl> + TF_IntOrFpTensor : $ data , <nl> + TF_I32OrI64Tensor : $ segment_ids , <nl> + TF_I32OrI64Tensor : $ num_segments <nl> + ) ; <nl> + <nl> + let results = ( outs <nl> + TF_IntOrFpTensor : $ output <nl> + ) ; <nl> + <nl> + TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr < 1 > ; <nl> + TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr < 0 > ; <nl> + TF_DerivedOperandTypeAttr Tnumsegments = TF_DerivedOperandTypeAttr < 2 > ; <nl> + <nl> + let verifier = [ { return VerifyUnsortedSegmentReduction ( * this ) ; } ] ; <nl> + } <nl> + <nl> + def TF_UnsortedSegmentProdOp : TF_Op < " UnsortedSegmentProd " , [ NoSideEffect ] > { <nl> + let summary = " Computes the product along segments of a tensor . " ; <nl> + <nl> + let description = [ { <nl> + Read <nl> + [ the section on segmentation ] ( https : / / tensorflow . org / api_docs / python / tf / math # Segmentation ) <nl> + for an explanation of segments . <nl> + <nl> + This operator is similar to the unsorted segment sum operator found <nl> + [ ( here ) ] ( . . / . . / . . / api_docs / python / math_ops . md # UnsortedSegmentSum ) . <nl> + Instead of computing the sum over segments , it computes the product of all <nl> + entries belonging to a segment such that : <nl> + <nl> + \ \ ( output_i = \ prod_ { j . . . } data [ j . . . ] \ \ ) where the product is over tuples <nl> + ` j . . . ` such that ` segment_ids [ j . . . ] = = i ` . <nl> + <nl> + For example : <nl> + <nl> + ` ` ` python <nl> + c = tf . constant ( [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] , [ 4 , 3 , 2 , 1 ] ] ) <nl> + tf . unsorted_segment_prod ( c , tf . constant ( [ 0 , 1 , 0 ] ) , num_segments = 2 ) <nl> + # = = > [ [ 4 , 6 , 6 , 4 ] , <nl> + # [ 5 , 6 , 7 , 8 ] ] <nl> + ` ` ` <nl> + <nl> + If there is no entry for a given segment ID ` i ` , it outputs 1 . <nl> + <nl> + If the given segment ID ` i ` is negative , then the corresponding value is <nl> + dropped , and will not be included in the result . <nl> + } ] ; <nl> + <nl> + let arguments = ( ins <nl> + TensorOf < [ BF16 , F16 , F32 , F64 , I16 , I32 , I64 , I8 , TF_Complex128 , TF_Complex64 , TF_Qint32 , TF_Qint8 , TF_Quint8 , TF_Uint16 , TF_Uint32 , TF_Uint64 , TF_Uint8 ] > : $ data , <nl> + TF_I32OrI64Tensor : $ segment_ids , <nl> + TF_I32OrI64Tensor : $ num_segments <nl> + ) ; <nl> + <nl> + let results = ( outs <nl> + TensorOf < [ BF16 , F16 , F32 , F64 , I16 , I32 , I64 , I8 , TF_Complex128 , TF_Complex64 , TF_Qint32 , TF_Qint8 , TF_Quint8 , TF_Uint16 , TF_Uint32 , TF_Uint64 , TF_Uint8 ] > : $ output <nl> + ) ; <nl> + <nl> + TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr < 1 > ; <nl> + TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr < 0 > ; <nl> + TF_DerivedOperandTypeAttr Tnumsegments = TF_DerivedOperandTypeAttr < 2 > ; <nl> + <nl> + let verifier = [ { return VerifyUnsortedSegmentReduction ( * this ) ; } ] ; <nl> + } <nl> + <nl> + def TF_UnsortedSegmentSumOp : TF_Op < " UnsortedSegmentSum " , [ NoSideEffect ] > { <nl> + let summary = " Computes the sum along segments of a tensor . " ; <nl> + <nl> + let description = [ { <nl> + Read <nl> + [ the section on segmentation ] ( https : / / tensorflow . org / api_docs / python / tf / math # Segmentation ) <nl> + for an explanation of segments . <nl> + <nl> + Computes a tensor such that <nl> + \ \ ( output [ i ] = \ sum_ { j . . . } data [ j . . . ] \ \ ) where the sum is over tuples ` j . . . ` such <nl> + that ` segment_ids [ j . . . ] = = i ` . Unlike ` SegmentSum ` , ` segment_ids ` <nl> + need not be sorted and need not cover all values in the full <nl> + range of valid values . <nl> + <nl> + If the sum is empty for a given segment ID ` i ` , ` output [ i ] = 0 ` . <nl> + If the given segment ID ` i ` is negative , the value is dropped and will not be <nl> + added to the sum of the segment . <nl> + <nl> + ` num_segments ` should equal the number of distinct segment IDs . <nl> + <nl> + < div style = " width : 70 % ; margin : auto ; margin - bottom : 10px ; margin - top : 20px ; " > <nl> + < img style = " width : 100 % " src = " https : / / www . tensorflow . org / images / UnsortedSegmentSum . png " alt > <nl> + < / div > <nl> + <nl> + ` ` ` python <nl> + c = tf . constant ( [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] , [ 4 , 3 , 2 , 1 ] ] ) <nl> + tf . unsorted_segment_sum ( c , tf . constant ( [ 0 , 1 , 0 ] ) , num_segments = 2 ) <nl> + # = = > [ [ 5 , 5 , 5 , 5 ] , <nl> + # [ 5 , 6 , 7 , 8 ] ] <nl> + ` ` ` <nl> + } ] ; <nl> + <nl> + let arguments = ( ins <nl> + TensorOf < [ BF16 , F16 , F32 , F64 , I16 , I32 , I64 , I8 , TF_Complex128 , TF_Complex64 , TF_Qint32 , TF_Qint8 , TF_Quint8 , TF_Uint16 , TF_Uint32 , TF_Uint64 , TF_Uint8 ] > : $ data , <nl> + TF_I32OrI64Tensor : $ segment_ids , <nl> + TF_I32OrI64Tensor : $ num_segments <nl> + ) ; <nl> + <nl> + let results = ( outs <nl> + TensorOf < [ BF16 , F16 , F32 , F64 , I16 , I32 , I64 , I8 , TF_Complex128 , TF_Complex64 , TF_Qint32 , TF_Qint8 , TF_Quint8 , TF_Uint16 , TF_Uint32 , TF_Uint64 , TF_Uint8 ] > : $ output <nl> + ) ; <nl> + <nl> + TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr < 1 > ; <nl> + TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr < 0 > ; <nl> + TF_DerivedOperandTypeAttr Tnumsegments = TF_DerivedOperandTypeAttr < 2 > ; <nl> + <nl> + let verifier = [ { return VerifyUnsortedSegmentReduction ( * this ) ; } ] ; <nl> + } <nl> + <nl> def TF_VariableShapeOp : TF_Op < " VariableShape " , [ ] > { <nl> let summary = " Returns the shape of the variable pointed to by ` resource ` . " ; <nl> <nl> mmm a / tensorflow / compiler / mlir / tensorflow / ir / tf_ops . cc <nl> ppp b / tensorflow / compiler / mlir / tensorflow / ir / tf_ops . cc <nl> static LogicalResult Verify ( UnpackOp op ) { <nl> return success ( ) ; <nl> } <nl> <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + / / Unsorted segment reduction ops <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> + <nl> + template < class Op > <nl> + static LogicalResult VerifyUnsortedSegmentReduction ( Op op ) { <nl> + if ( ! HasRankAtMost ( op . num_segments ( ) , 0 ) ) <nl> + return op . emitOpError ( " number of segments should be a 0 - D tensor " ) ; <nl> + <nl> + auto data_type = op . data ( ) - > getType ( ) . template dyn_cast < RankedTensorType > ( ) ; <nl> + auto segment_ids_type = <nl> + op . segment_ids ( ) - > getType ( ) . template dyn_cast < RankedTensorType > ( ) ; <nl> + if ( data_type & & segment_ids_type ) { <nl> + if ( data_type . getRank ( ) < segment_ids_type . getRank ( ) ) <nl> + return op . emitOpError ( <nl> + " requires segment ids rank to be less than or equal to data ' s rank " ) ; <nl> + <nl> + int index = 0 ; <nl> + for ( auto shape_pair : <nl> + llvm : : zip_first ( segment_ids_type . getShape ( ) , data_type . getShape ( ) ) ) { <nl> + int64_t segment_id_dim = std : : get < 0 > ( shape_pair ) ; <nl> + int64_t data_dim = std : : get < 1 > ( shape_pair ) ; <nl> + if ( ! ShapedType : : isDynamic ( segment_id_dim ) & & <nl> + ! ShapedType : : isDynamic ( data_dim ) & & segment_id_dim ! = data_dim ) <nl> + return op . emitOpError ( <nl> + " requires segment ids shape to be a prefix of data shape , " <nl> + " but dimension # " ) <nl> + < < index < < " differs : " < < segment_id_dim < < " vs . " <nl> + < < data_dim ; <nl> + + + index ; <nl> + } <nl> + } <nl> + <nl> + DenseIntElementsAttr num_segments_attr ; <nl> + if ( matchPattern ( op . num_segments ( ) , m_Constant ( & num_segments_attr ) ) ) { <nl> + int64_t num_segments = ( * num_segments_attr . begin ( ) ) . getSExtValue ( ) ; <nl> + if ( num_segments < 0 ) <nl> + return op . emitOpError ( " num of segments cannot be negative " ) ; <nl> + } <nl> + <nl> + return success ( ) ; <nl> + } <nl> + <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> / / VariableShapeOp <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> mmm a / tensorflow / compiler / mlir / tensorflow / tests / tf - ops . mlir <nl> ppp b / tensorflow / compiler / mlir / tensorflow / tests / tf - ops . mlir <nl> func @ testAxisDim ( % input : tensor < 2x6xf32 > ) { <nl> % 0 : 2 = " tf . Unpack " ( % input ) { axis = - 1 } : ( tensor < 2x6xf32 > ) - > ( tensor < 6xf32 > , tensor < 6xf32 > ) <nl> return <nl> } <nl> + <nl> + / / mmm - - <nl> + <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + / / tf . UnsortedSegment { Max | Min | Prod | Sum } <nl> + / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> + <nl> + / / CHECK - LABEL : unsortedSegmentReduction <nl> + func @ unsortedSegmentReduction ( % data : tensor < ? x10x8xf32 > , % segment_ids : tensor < 7x ? xi32 > , % num_segments : tensor < i32 > ) { <nl> + / / CHECK : tf . UnsortedSegmentMin <nl> + % 0 = " tf . UnsortedSegmentMin " ( % data , % segment_ids , % num_segments ) : ( tensor < ? x10x8xf32 > , tensor < 7x ? xi32 > , tensor < i32 > ) - > ( tensor < ? x8xf32 > ) <nl> + return <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + func @ unsortedSegmentReduction ( % data : tensor < 7x10x8xf32 > , % segment_ids : tensor < 7x10xi32 > , % num_segments : tensor < 2x3xi32 > ) { <nl> + / / expected - error @ + 1 { { number of segments should be a 0 - D tensor } } <nl> + % 0 = " tf . UnsortedSegmentMax " ( % data , % segment_ids , % num_segments ) : ( tensor < 7x10x8xf32 > , tensor < 7x10xi32 > , tensor < 2x3xi32 > ) - > ( tensor < ? x8xf32 > ) <nl> + return <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + func @ unsortedSegmentReduction ( % data : tensor < 7x10x8xf32 > , % segment_ids : tensor < 7x9xi32 > , % num_segments : tensor < i32 > ) { <nl> + / / expected - error @ + 1 { { requires segment ids shape to be a prefix of data shape , but dimension # 1 differs : 9 vs . 10 } } <nl> + % 0 = " tf . UnsortedSegmentProd " ( % data , % segment_ids , % num_segments ) : ( tensor < 7x10x8xf32 > , tensor < 7x9xi32 > , tensor < i32 > ) - > ( tensor < ? x8xf32 > ) <nl> + return <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + func @ unsortedSegmentReduction ( % data : tensor < 7x10x8xf32 > , % segment_ids : tensor < 7x10x8x1xi32 > , % num_segments : tensor < i32 > ) { <nl> + / / expected - error @ + 1 { { requires segment ids rank to be less than or equal to data ' s rank } } <nl> + % 0 = " tf . UnsortedSegmentSum " ( % data , % segment_ids , % num_segments ) : ( tensor < 7x10x8xf32 > , tensor < 7x10x8x1xi32 > , tensor < i32 > ) - > ( tensor < ? x8xf32 > ) <nl> + return <nl> + } <nl> + <nl> + / / mmm - - <nl> + <nl> + func @ unsortedSegmentReduction ( % data : tensor < 7x10x8xf32 > , % segment_ids : tensor < 7x10xi32 > ) { <nl> + % num_segments = " tf . Const " ( ) { value = dense < - 5 > : tensor < i32 > } : ( ) - > ( tensor < i32 > ) <nl> + / / expected - error @ + 1 { { num of segments cannot be negative } } <nl> + % 0 = " tf . UnsortedSegmentSum " ( % data , % segment_ids , % num_segments ) : ( tensor < 7x10x8xf32 > , tensor < 7x10xi32 > , tensor < i32 > ) - > ( tensor < ? x8xf32 > ) <nl> + return <nl> + } <nl>
Add ODS definition for unsorted segment reduction ops
tensorflow/tensorflow
8d9eede09a6192efd4b5e0c916ffa8225b9eb2e5
2019-12-12T19:52:58Z
mmm a / BUILD . gn <nl> ppp b / BUILD . gn <nl> source_set ( " v8_base " ) { <nl> " src / compiler / register - allocator . h " , <nl> " src / compiler / register - allocator - verifier . cc " , <nl> " src / compiler / register - allocator - verifier . h " , <nl> - " src / compiler / register - configuration . cc " , <nl> - " src / compiler / register - configuration . h " , <nl> " src / compiler / representation - change . h " , <nl> " src / compiler / schedule . cc " , <nl> " src / compiler / schedule . h " , <nl> source_set ( " v8_base " ) { <nl> " src / regexp / regexp - macro - assembler . h " , <nl> " src / regexp / regexp - stack . cc " , <nl> " src / regexp / regexp - stack . h " , <nl> + " src / register - configuration . cc " , <nl> + " src / register - configuration . h " , <nl> " src / runtime - profiler . cc " , <nl> " src / runtime - profiler . h " , <nl> " src / runtime / runtime - array . cc " , <nl> mmm a / src / arm / assembler - arm - inl . h <nl> ppp b / src / arm / assembler - arm - inl . h <nl> namespace internal { <nl> bool CpuFeatures : : SupportsCrankshaft ( ) { return IsSupported ( VFP3 ) ; } <nl> <nl> <nl> - int Register : : NumAllocatableRegisters ( ) { <nl> - return kMaxNumAllocatableRegisters ; <nl> - } <nl> - <nl> - <nl> - int DwVfpRegister : : NumRegisters ( ) { <nl> + int DoubleRegister : : NumRegisters ( ) { <nl> return CpuFeatures : : IsSupported ( VFP32DREGS ) ? 32 : 16 ; <nl> } <nl> <nl> <nl> - int DwVfpRegister : : NumReservedRegisters ( ) { <nl> - return kNumReservedRegisters ; <nl> - } <nl> - <nl> - <nl> - int DwVfpRegister : : NumAllocatableRegisters ( ) { <nl> - return NumRegisters ( ) - kNumReservedRegisters ; <nl> - } <nl> - <nl> - <nl> - / / static <nl> - int DwVfpRegister : : NumAllocatableAliasedRegisters ( ) { <nl> - return LowDwVfpRegister : : kMaxNumLowRegisters - kNumReservedRegisters ; <nl> - } <nl> - <nl> - <nl> - int DwVfpRegister : : ToAllocationIndex ( DwVfpRegister reg ) { <nl> - DCHECK ( ! reg . is ( kDoubleRegZero ) ) ; <nl> - DCHECK ( ! reg . is ( kScratchDoubleReg ) ) ; <nl> - if ( reg . code ( ) > kDoubleRegZero . code ( ) ) { <nl> - return reg . code ( ) - kNumReservedRegisters ; <nl> - } <nl> - return reg . code ( ) ; <nl> - } <nl> - <nl> - <nl> - DwVfpRegister DwVfpRegister : : FromAllocationIndex ( int index ) { <nl> - DCHECK ( index > = 0 & & index < NumAllocatableRegisters ( ) ) ; <nl> - DCHECK ( kScratchDoubleReg . code ( ) - kDoubleRegZero . code ( ) = = <nl> - kNumReservedRegisters - 1 ) ; <nl> - if ( index > = kDoubleRegZero . code ( ) ) { <nl> - return from_code ( index + kNumReservedRegisters ) ; <nl> - } <nl> - return from_code ( index ) ; <nl> - } <nl> - <nl> - <nl> void RelocInfo : : apply ( intptr_t delta ) { <nl> if ( RelocInfo : : IsInternalReference ( rmode_ ) ) { <nl> / / absolute code pointer inside code object moves with the code object . <nl> mmm a / src / arm / assembler - arm . cc <nl> ppp b / src / arm / assembler - arm . cc <nl> void CpuFeatures : : PrintFeatures ( ) { <nl> } <nl> <nl> <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / Implementation of DwVfpRegister <nl> - <nl> - const char * DwVfpRegister : : AllocationIndexToString ( int index ) { <nl> - DCHECK ( index > = 0 & & index < NumAllocatableRegisters ( ) ) ; <nl> - DCHECK ( kScratchDoubleReg . code ( ) - kDoubleRegZero . code ( ) = = <nl> - kNumReservedRegisters - 1 ) ; <nl> - if ( index > = kDoubleRegZero . code ( ) ) index + = kNumReservedRegisters ; <nl> - return VFPRegisters : : Name ( index , true ) ; <nl> - } <nl> - <nl> - <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / Implementation of RelocInfo <nl> <nl> NeonListOperand : : NeonListOperand ( DoubleRegister base , int registers_count ) { <nl> / / str ( r , MemOperand ( sp , 4 , NegPreIndex ) , al ) instruction ( aka push ( r ) ) <nl> / / register r is not encoded . <nl> const Instr kPushRegPattern = <nl> - al | B26 | 4 | NegPreIndex | kRegister_sp_Code * B16 ; <nl> + al | B26 | 4 | NegPreIndex | Register : : kCode_sp * B16 ; <nl> / / ldr ( r , MemOperand ( sp , 4 , PostIndex ) , al ) instruction ( aka pop ( r ) ) <nl> / / register r is not encoded . <nl> const Instr kPopRegPattern = <nl> - al | B26 | L | 4 | PostIndex | kRegister_sp_Code * B16 ; <nl> + al | B26 | L | 4 | PostIndex | Register : : kCode_sp * B16 ; <nl> / / ldr rd , [ pc , # offset ] <nl> const Instr kLdrPCImmedMask = 15 * B24 | 7 * B20 | 15 * B16 ; <nl> - const Instr kLdrPCImmedPattern = 5 * B24 | L | kRegister_pc_Code * B16 ; <nl> + const Instr kLdrPCImmedPattern = 5 * B24 | L | Register : : kCode_pc * B16 ; <nl> / / ldr rd , [ pp , # offset ] <nl> const Instr kLdrPpImmedMask = 15 * B24 | 7 * B20 | 15 * B16 ; <nl> - const Instr kLdrPpImmedPattern = 5 * B24 | L | kRegister_r8_Code * B16 ; <nl> + const Instr kLdrPpImmedPattern = 5 * B24 | L | Register : : kCode_r8 * B16 ; <nl> / / ldr rd , [ pp , rn ] <nl> const Instr kLdrPpRegMask = 15 * B24 | 7 * B20 | 15 * B16 ; <nl> - const Instr kLdrPpRegPattern = 7 * B24 | L | kRegister_r8_Code * B16 ; <nl> + const Instr kLdrPpRegPattern = 7 * B24 | L | Register : : kCode_r8 * B16 ; <nl> / / vldr dd , [ pc , # offset ] <nl> const Instr kVldrDPCMask = 15 * B24 | 3 * B20 | 15 * B16 | 15 * B8 ; <nl> - const Instr kVldrDPCPattern = 13 * B24 | L | kRegister_pc_Code * B16 | 11 * B8 ; <nl> + const Instr kVldrDPCPattern = 13 * B24 | L | Register : : kCode_pc * B16 | 11 * B8 ; <nl> / / vldr dd , [ pp , # offset ] <nl> const Instr kVldrDPpMask = 15 * B24 | 3 * B20 | 15 * B16 | 15 * B8 ; <nl> - const Instr kVldrDPpPattern = 13 * B24 | L | kRegister_r8_Code * B16 | 11 * B8 ; <nl> + const Instr kVldrDPpPattern = 13 * B24 | L | Register : : kCode_r8 * B16 | 11 * B8 ; <nl> / / blxcc rm <nl> const Instr kBlxRegMask = <nl> 15 * B24 | 15 * B20 | 15 * B16 | 15 * B12 | 15 * B8 | 15 * B4 ; <nl> const Instr kAndBicFlip = 0xe * B21 ; <nl> <nl> / / A mask for the Rd register for push , pop , ldr , str instructions . <nl> const Instr kLdrRegFpOffsetPattern = <nl> - al | B26 | L | Offset | kRegister_fp_Code * B16 ; <nl> + al | B26 | L | Offset | Register : : kCode_fp * B16 ; <nl> const Instr kStrRegFpOffsetPattern = <nl> - al | B26 | Offset | kRegister_fp_Code * B16 ; <nl> + al | B26 | Offset | Register : : kCode_fp * B16 ; <nl> const Instr kLdrRegFpNegOffsetPattern = <nl> - al | B26 | L | NegOffset | kRegister_fp_Code * B16 ; <nl> + al | B26 | L | NegOffset | Register : : kCode_fp * B16 ; <nl> const Instr kStrRegFpNegOffsetPattern = <nl> - al | B26 | NegOffset | kRegister_fp_Code * B16 ; <nl> + al | B26 | NegOffset | Register : : kCode_fp * B16 ; <nl> const Instr kLdrStrInstrTypeMask = 0xffff0000 ; <nl> <nl> <nl> Instr Assembler : : SetAddRegisterImmediateOffset ( Instr instr , int offset ) { <nl> <nl> Register Assembler : : GetRd ( Instr instr ) { <nl> Register reg ; <nl> - reg . code_ = Instruction : : RdValue ( instr ) ; <nl> + reg . reg_code = Instruction : : RdValue ( instr ) ; <nl> return reg ; <nl> } <nl> <nl> <nl> Register Assembler : : GetRn ( Instr instr ) { <nl> Register reg ; <nl> - reg . code_ = Instruction : : RnValue ( instr ) ; <nl> + reg . reg_code = Instruction : : RnValue ( instr ) ; <nl> return reg ; <nl> } <nl> <nl> <nl> Register Assembler : : GetRm ( Instr instr ) { <nl> Register reg ; <nl> - reg . code_ = Instruction : : RmValue ( instr ) ; <nl> + reg . reg_code = Instruction : : RmValue ( instr ) ; <nl> return reg ; <nl> } <nl> <nl> mmm a / src / arm / assembler - arm . h <nl> ppp b / src / arm / assembler - arm . h <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> + / / clang - format off <nl> + # define GENERAL_REGISTERS ( V ) \ <nl> + V ( r0 ) V ( r1 ) V ( r2 ) V ( r3 ) V ( r4 ) V ( r5 ) V ( r6 ) V ( r7 ) \ <nl> + V ( r8 ) V ( r9 ) V ( r10 ) V ( fp ) V ( ip ) V ( sp ) V ( lr ) V ( pc ) <nl> + <nl> + # define ALLOCATABLE_GENERAL_REGISTERS ( V ) \ <nl> + V ( r0 ) V ( r1 ) V ( r2 ) V ( r3 ) V ( r4 ) V ( r5 ) V ( r6 ) V ( r7 ) V ( r8 ) <nl> + <nl> + # define DOUBLE_REGISTERS ( V ) \ <nl> + V ( d0 ) V ( d1 ) V ( d2 ) V ( d3 ) V ( d4 ) V ( d5 ) V ( d6 ) V ( d7 ) \ <nl> + V ( d8 ) V ( d9 ) V ( d10 ) V ( d11 ) V ( d12 ) V ( d13 ) V ( d14 ) V ( d15 ) \ <nl> + V ( d16 ) V ( d17 ) V ( d18 ) V ( d19 ) V ( d20 ) V ( d21 ) V ( d22 ) V ( d23 ) \ <nl> + V ( d24 ) V ( d25 ) V ( d26 ) V ( d27 ) V ( d28 ) V ( d29 ) V ( d30 ) V ( d31 ) <nl> + <nl> + # define ALLOCATABLE_DOUBLE_REGISTERS ( V ) \ <nl> + V ( d0 ) V ( d1 ) V ( d2 ) V ( d3 ) V ( d4 ) V ( d5 ) V ( d6 ) V ( d7 ) \ <nl> + V ( d8 ) V ( d9 ) V ( d10 ) V ( d11 ) V ( d12 ) V ( d13 ) \ <nl> + V ( d16 ) V ( d17 ) V ( d18 ) V ( d19 ) V ( d20 ) V ( d21 ) V ( d22 ) V ( d23 ) \ <nl> + V ( d24 ) V ( d25 ) V ( d26 ) V ( d27 ) V ( d28 ) V ( d29 ) V ( d30 ) V ( d31 ) <nl> + <nl> + # define ALLOCATABLE_NO_VFP32_DOUBLE_REGISTERS ( V ) \ <nl> + V ( d0 ) V ( d1 ) V ( d2 ) V ( d3 ) V ( d4 ) V ( d5 ) V ( d6 ) V ( d7 ) \ <nl> + V ( d8 ) V ( d9 ) V ( d10 ) V ( d11 ) V ( d12 ) V ( d13 ) \ <nl> + / / clang - format on <nl> + <nl> / / CPU Registers . <nl> / / <nl> / / 1 ) We would prefer to use an enum , but enum values are assignment - <nl> namespace internal { <nl> / / mode . This way we get the compile - time error checking in debug mode <nl> / / and best performance in optimized code . <nl> <nl> - / / These constants are used in several locations , including static initializers <nl> - const int kRegister_no_reg_Code = - 1 ; <nl> - const int kRegister_r0_Code = 0 ; <nl> - const int kRegister_r1_Code = 1 ; <nl> - const int kRegister_r2_Code = 2 ; <nl> - const int kRegister_r3_Code = 3 ; <nl> - const int kRegister_r4_Code = 4 ; <nl> - const int kRegister_r5_Code = 5 ; <nl> - const int kRegister_r6_Code = 6 ; <nl> - const int kRegister_r7_Code = 7 ; <nl> - const int kRegister_r8_Code = 8 ; <nl> - const int kRegister_r9_Code = 9 ; <nl> - const int kRegister_r10_Code = 10 ; <nl> - const int kRegister_fp_Code = 11 ; <nl> - const int kRegister_ip_Code = 12 ; <nl> - const int kRegister_sp_Code = 13 ; <nl> - const int kRegister_lr_Code = 14 ; <nl> - const int kRegister_pc_Code = 15 ; <nl> - <nl> - / / Core register <nl> struct Register { <nl> - static const int kNumRegisters = 16 ; <nl> - static const int kMaxNumAllocatableRegisters = <nl> - FLAG_enable_embedded_constant_pool ? 8 : 9 ; <nl> - static const int kSizeInBytes = 4 ; <nl> - <nl> - inline static int NumAllocatableRegisters ( ) ; <nl> - <nl> - static int ToAllocationIndex ( Register reg ) { <nl> - DCHECK ( reg . code ( ) < kMaxNumAllocatableRegisters ) ; <nl> - return reg . code ( ) ; <nl> - } <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + GENERAL_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> <nl> - static Register FromAllocationIndex ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - return from_code ( index ) ; <nl> - } <nl> - <nl> - static const char * AllocationIndexToString ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - const char * const names [ ] = { <nl> - " r0 " , <nl> - " r1 " , <nl> - " r2 " , <nl> - " r3 " , <nl> - " r4 " , <nl> - " r5 " , <nl> - " r6 " , <nl> - " r7 " , <nl> - " r8 " , <nl> - } ; <nl> - if ( FLAG_enable_embedded_constant_pool & & ( index > = 7 ) ) { <nl> - return names [ index + 1 ] ; <nl> - } <nl> - return names [ index ] ; <nl> - } <nl> + static const int kNumRegisters = Code : : kAfterLast ; <nl> <nl> static Register from_code ( int code ) { <nl> - Register r = { code } ; <nl> + DCHECK ( code > = 0 ) ; <nl> + DCHECK ( code < kNumRegisters ) ; <nl> + Register r = { code } ; <nl> return r ; <nl> } <nl> - <nl> - bool is_valid ( ) const { return 0 < = code_ & & code_ < kNumRegisters ; } <nl> - bool is ( Register reg ) const { return code_ = = reg . code_ ; } <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < kNumRegisters ; } <nl> + bool is ( Register reg ) const { return reg_code = = reg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> } <nl> - <nl> void set_code ( int code ) { <nl> - code_ = code ; <nl> + reg_code = code ; <nl> DCHECK ( is_valid ( ) ) ; <nl> } <nl> <nl> / / Unfortunately we can ' t make this private in a struct . <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> - const Register no_reg = { kRegister_no_reg_Code } ; <nl> - <nl> - const Register r0 = { kRegister_r0_Code } ; <nl> - const Register r1 = { kRegister_r1_Code } ; <nl> - const Register r2 = { kRegister_r2_Code } ; <nl> - const Register r3 = { kRegister_r3_Code } ; <nl> - const Register r4 = { kRegister_r4_Code } ; <nl> - const Register r5 = { kRegister_r5_Code } ; <nl> - const Register r6 = { kRegister_r6_Code } ; <nl> - / / Used as context register . <nl> - const Register r7 = { kRegister_r7_Code } ; <nl> - / / Used as constant pool pointer register if FLAG_enable_embedded_constant_pool . <nl> - const Register r8 = { kRegister_r8_Code } ; <nl> - / / Used as lithium codegen scratch register . <nl> - const Register r9 = { kRegister_r9_Code } ; <nl> - / / Used as roots register . <nl> - const Register r10 = { kRegister_r10_Code } ; <nl> - const Register fp = { kRegister_fp_Code } ; <nl> - const Register ip = { kRegister_ip_Code } ; <nl> - const Register sp = { kRegister_sp_Code } ; <nl> - const Register lr = { kRegister_lr_Code } ; <nl> - const Register pc = { kRegister_pc_Code } ; <nl> + / / r7 : context register <nl> + / / r8 : constant pool pointer register if FLAG_enable_embedded_constant_pool . <nl> + / / r9 : lithium scratch <nl> + # define DECLARE_REGISTER ( R ) const Register R = { Register : : kCode_ # # R } ; <nl> + GENERAL_REGISTERS ( DECLARE_REGISTER ) <nl> + # undef DECLARE_REGISTER <nl> + const Register no_reg = { Register : : kCode_no_reg } ; <nl> <nl> / / Single word VFP register . <nl> struct SwVfpRegister { <nl> static const int kSizeInBytes = 4 ; <nl> - bool is_valid ( ) const { return 0 < = code_ & & code_ < 32 ; } <nl> - bool is ( SwVfpRegister reg ) const { return code_ = = reg . code_ ; } <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < 32 ; } <nl> + bool is ( SwVfpRegister reg ) const { return reg_code = = reg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> } <nl> void split_code ( int * vm , int * m ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - * m = code_ & 0x1 ; <nl> - * vm = code_ > > 1 ; <nl> + * m = reg_code & 0x1 ; <nl> + * vm = reg_code > > 1 ; <nl> } <nl> <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> <nl> / / Double word VFP register . <nl> - struct DwVfpRegister { <nl> - static const int kMaxNumRegisters = 32 ; <nl> + struct DoubleRegister { <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + DOUBLE_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> + <nl> + static const int kMaxNumRegisters = Code : : kAfterLast ; <nl> + <nl> + inline static int NumRegisters ( ) ; <nl> + <nl> / / A few double registers are reserved : one as a scratch register and one to <nl> / / hold 0 . 0 , that does not fit in the immediate field of vmov instructions . <nl> / / d14 : 0 . 0 <nl> / / d15 : scratch register . <nl> - static const int kNumReservedRegisters = 2 ; <nl> - static const int kMaxNumAllocatableRegisters = kMaxNumRegisters - <nl> - kNumReservedRegisters ; <nl> static const int kSizeInBytes = 8 ; <nl> <nl> - / / Note : the number of registers can be different at snapshot and run - time . <nl> - / / Any code included in the snapshot must be able to run both with 16 or 32 <nl> - / / registers . <nl> - inline static int NumRegisters ( ) ; <nl> - inline static int NumReservedRegisters ( ) ; <nl> - inline static int NumAllocatableRegisters ( ) ; <nl> - <nl> - / / TODO ( turbofan ) : This is a temporary work - around required because our <nl> - / / register allocator does not yet support the aliasing of single / double <nl> - / / registers on ARM . <nl> - inline static int NumAllocatableAliasedRegisters ( ) ; <nl> - <nl> - inline static int ToAllocationIndex ( DwVfpRegister reg ) ; <nl> - static const char * AllocationIndexToString ( int index ) ; <nl> - inline static DwVfpRegister FromAllocationIndex ( int index ) ; <nl> - <nl> - static DwVfpRegister from_code ( int code ) { <nl> - DwVfpRegister r = { code } ; <nl> - return r ; <nl> - } <nl> - <nl> - bool is_valid ( ) const { <nl> - return 0 < = code_ & & code_ < kMaxNumRegisters ; <nl> - } <nl> - bool is ( DwVfpRegister reg ) const { return code_ = = reg . code_ ; } <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < kMaxNumRegisters ; } <nl> + bool is ( DoubleRegister reg ) const { return reg_code = = reg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> + } <nl> + <nl> + static DoubleRegister from_code ( int code ) { <nl> + DoubleRegister r = { code } ; <nl> + return r ; <nl> } <nl> void split_code ( int * vm , int * m ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - * m = ( code_ & 0x10 ) > > 4 ; <nl> - * vm = code_ & 0x0F ; <nl> + * m = ( reg_code & 0x10 ) > > 4 ; <nl> + * vm = reg_code & 0x0F ; <nl> } <nl> <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> <nl> - typedef DwVfpRegister DoubleRegister ; <nl> + typedef DoubleRegister DwVfpRegister ; <nl> <nl> <nl> / / Double word VFP register d0 - 15 . <nl> struct LowDwVfpRegister { <nl> public : <nl> static const int kMaxNumLowRegisters = 16 ; <nl> operator DwVfpRegister ( ) const { <nl> - DwVfpRegister r = { code_ } ; <nl> + DwVfpRegister r = { reg_code } ; <nl> return r ; <nl> } <nl> static LowDwVfpRegister from_code ( int code ) { <nl> struct LowDwVfpRegister { <nl> } <nl> <nl> bool is_valid ( ) const { <nl> - return 0 < = code_ & & code_ < kMaxNumLowRegisters ; <nl> + return 0 < = reg_code & & reg_code < kMaxNumLowRegisters ; <nl> } <nl> - bool is ( DwVfpRegister reg ) const { return code_ = = reg . code_ ; } <nl> - bool is ( LowDwVfpRegister reg ) const { return code_ = = reg . code_ ; } <nl> + bool is ( DwVfpRegister reg ) const { return reg_code = = reg . reg_code ; } <nl> + bool is ( LowDwVfpRegister reg ) const { return reg_code = = reg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> SwVfpRegister low ( ) const { <nl> SwVfpRegister reg ; <nl> - reg . code_ = code_ * 2 ; <nl> + reg . reg_code = reg_code * 2 ; <nl> <nl> DCHECK ( reg . is_valid ( ) ) ; <nl> return reg ; <nl> } <nl> SwVfpRegister high ( ) const { <nl> SwVfpRegister reg ; <nl> - reg . code_ = ( code_ * 2 ) + 1 ; <nl> + reg . reg_code = ( reg_code * 2 ) + 1 ; <nl> <nl> DCHECK ( reg . is_valid ( ) ) ; <nl> return reg ; <nl> } <nl> <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> <nl> struct QwNeonRegister { <nl> } <nl> <nl> bool is_valid ( ) const { <nl> - return ( 0 < = code_ ) & & ( code_ < kMaxNumRegisters ) ; <nl> + return ( 0 < = reg_code ) & & ( reg_code < kMaxNumRegisters ) ; <nl> } <nl> - bool is ( QwNeonRegister reg ) const { return code_ = = reg . code_ ; } <nl> + bool is ( QwNeonRegister reg ) const { return reg_code = = reg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> void split_code ( int * vm , int * m ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - int encoded_code = code_ < < 1 ; <nl> + int encoded_code = reg_code < < 1 ; <nl> * m = ( encoded_code & 0x10 ) > > 4 ; <nl> * vm = encoded_code & 0x0F ; <nl> } <nl> <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> <nl> const QwNeonRegister q15 = { 15 } ; <nl> <nl> / / Coprocessor register <nl> struct CRegister { <nl> - bool is_valid ( ) const { return 0 < = code_ & & code_ < 16 ; } <nl> - bool is ( CRegister creg ) const { return code_ = = creg . code_ ; } <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < 16 ; } <nl> + bool is ( CRegister creg ) const { return reg_code = = creg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> } <nl> <nl> / / Unfortunately we can ' t make this private in a struct . <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> <nl> mmm a / src / arm / constants - arm . cc <nl> ppp b / src / arm / constants - arm . cc <nl> const Registers : : RegisterAlias Registers : : aliases_ [ ] = { <nl> } ; <nl> <nl> <nl> - const char * Registers : : Name ( int reg ) { <nl> - const char * result ; <nl> - if ( ( 0 < = reg ) & & ( reg < kNumRegisters ) ) { <nl> - result = names_ [ reg ] ; <nl> - } else { <nl> - result = " noreg " ; <nl> - } <nl> - return result ; <nl> - } <nl> - <nl> - <nl> / / Support for VFP registers s0 to s31 ( d0 to d15 ) and d16 - d31 . <nl> / / Note that " sN : sM " is the same as " dN / 2 " up to d15 . <nl> / / These register names are defined in a way to match the native disassembler <nl> mmm a / src / arm / deoptimizer - arm . cc <nl> ppp b / src / arm / deoptimizer - arm . cc <nl> <nl> # include " src / codegen . h " <nl> # include " src / deoptimizer . h " <nl> # include " src / full - codegen / full - codegen . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / safepoint - table . h " <nl> <nl> namespace v8 { <nl> void Deoptimizer : : FillInputFrame ( Address tos , JavaScriptFrame * frame ) { <nl> } <nl> input_ - > SetRegister ( sp . code ( ) , reinterpret_cast < intptr_t > ( frame - > sp ( ) ) ) ; <nl> input_ - > SetRegister ( fp . code ( ) , reinterpret_cast < intptr_t > ( frame - > fp ( ) ) ) ; <nl> - for ( int i = 0 ; i < DoubleRegister : : NumAllocatableRegisters ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < DoubleRegister : : kMaxNumRegisters ; i + + ) { <nl> input_ - > SetDoubleRegister ( i , 0 . 0 ) ; <nl> } <nl> <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> / / Everything but pc , lr and ip which will be saved but not restored . <nl> RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip . bit ( ) ; <nl> <nl> - const int kDoubleRegsSize = <nl> - kDoubleSize * DwVfpRegister : : kMaxNumAllocatableRegisters ; <nl> + const int kDoubleRegsSize = kDoubleSize * DwVfpRegister : : kMaxNumRegisters ; <nl> <nl> / / Save all allocatable VFP registers before messing with them . <nl> DCHECK ( kDoubleRegZero . code ( ) = = 14 ) ; <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> / / Check CPU flags for number of registers , setting the Z condition flag . <nl> __ CheckFor32DRegs ( ip ) ; <nl> <nl> - / / Push registers d0 - d13 , and possibly d16 - d31 , on the stack . <nl> + / / Push registers d0 - d15 , and possibly d16 - d31 , on the stack . <nl> / / If d16 - d31 are not pushed , decrease the stack pointer instead . <nl> __ vstm ( db_w , sp , d16 , d31 , ne ) ; <nl> __ sub ( sp , sp , Operand ( 16 * kDoubleSize ) , LeaveCC , eq ) ; <nl> - __ vstm ( db_w , sp , d0 , d13 ) ; <nl> + __ vstm ( db_w , sp , d0 , d15 ) ; <nl> <nl> / / Push all 16 registers ( needed to populate FrameDescription : : registers_ ) . <nl> / / TODO ( 1588 ) Note that using pc with stm is deprecated , so we should perhaps <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> / / Copy VFP registers to <nl> / / double_registers_ [ DoubleRegister : : kMaxNumAllocatableRegisters ] <nl> int double_regs_offset = FrameDescription : : double_registers_offset ( ) ; <nl> - for ( int i = 0 ; i < DwVfpRegister : : kMaxNumAllocatableRegisters ; + + i ) { <nl> - int dst_offset = i * kDoubleSize + double_regs_offset ; <nl> - int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + int dst_offset = code * kDoubleSize + double_regs_offset ; <nl> + int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize ; <nl> __ vldr ( d0 , sp , src_offset ) ; <nl> __ vstr ( d0 , r1 , dst_offset ) ; <nl> } <nl> mmm a / src / arm / disasm - arm . cc <nl> ppp b / src / arm / disasm - arm . cc <nl> const char * NameConverter : : NameOfConstant ( byte * addr ) const { <nl> <nl> <nl> const char * NameConverter : : NameOfCPURegister ( int reg ) const { <nl> - return v8 : : internal : : Registers : : Name ( reg ) ; <nl> + return v8 : : internal : : Register : : from_code ( reg ) . ToString ( ) ; <nl> } <nl> <nl> <nl> mmm a / src / arm / lithium - arm . cc <nl> ppp b / src / arm / lithium - arm . cc <nl> LPlatformChunk * LChunkBuilder : : Build ( ) { <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( Register reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , <nl> - Register : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( DoubleRegister reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , <nl> - DoubleRegister : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) <nl> + LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / arm / lithium - codegen - arm . cc <nl> ppp b / src / arm / lithium - codegen - arm . cc <nl> void LCodeGen : : SaveCallerDoubles ( ) { <nl> BitVector * doubles = chunk ( ) - > allocated_double_registers ( ) ; <nl> BitVector : : Iterator save_iterator ( doubles ) ; <nl> while ( ! save_iterator . Done ( ) ) { <nl> - __ vstr ( DwVfpRegister : : FromAllocationIndex ( save_iterator . Current ( ) ) , <nl> + __ vstr ( DoubleRegister : : from_code ( save_iterator . Current ( ) ) , <nl> MemOperand ( sp , count * kDoubleSize ) ) ; <nl> save_iterator . Advance ( ) ; <nl> count + + ; <nl> void LCodeGen : : RestoreCallerDoubles ( ) { <nl> BitVector : : Iterator save_iterator ( doubles ) ; <nl> int count = 0 ; <nl> while ( ! save_iterator . Done ( ) ) { <nl> - __ vldr ( DwVfpRegister : : FromAllocationIndex ( save_iterator . Current ( ) ) , <nl> - MemOperand ( sp , count * kDoubleSize ) ) ; <nl> + __ vldr ( DoubleRegister : : from_code ( save_iterator . Current ( ) ) , <nl> + MemOperand ( sp , count * kDoubleSize ) ) ; <nl> save_iterator . Advance ( ) ; <nl> count + + ; <nl> } <nl> bool LCodeGen : : GenerateSafepointTable ( ) { <nl> } <nl> <nl> <nl> - Register LCodeGen : : ToRegister ( int index ) const { <nl> - return Register : : FromAllocationIndex ( index ) ; <nl> + Register LCodeGen : : ToRegister ( int code ) const { <nl> + return Register : : from_code ( code ) ; <nl> } <nl> <nl> <nl> - DwVfpRegister LCodeGen : : ToDoubleRegister ( int index ) const { <nl> - return DwVfpRegister : : FromAllocationIndex ( index ) ; <nl> + DwVfpRegister LCodeGen : : ToDoubleRegister ( int code ) const { <nl> + return DwVfpRegister : : from_code ( code ) ; <nl> } <nl> <nl> <nl> mmm a / src / arm / macro - assembler - arm . cc <nl> ppp b / src / arm / macro - assembler - arm . cc <nl> <nl> # include " src / codegen . h " <nl> # include " src / cpu - profiler . h " <nl> # include " src / debug / debug . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / runtime / runtime . h " <nl> <nl> # include " src / arm / macro - assembler - arm . h " <nl> MemOperand MacroAssembler : : SafepointRegistersAndDoublesSlot ( Register reg ) { <nl> / / Number of d - regs not known at snapshot time . <nl> DCHECK ( ! serializer_enabled ( ) ) ; <nl> / / General purpose registers are pushed last on the stack . <nl> - int doubles_size = DwVfpRegister : : NumAllocatableRegisters ( ) * kDoubleSize ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + int doubles_size = config - > num_allocatable_double_registers ( ) * kDoubleSize ; <nl> int register_offset = SafepointRegisterStackIndex ( reg . code ( ) ) * kPointerSize ; <nl> return MemOperand ( sp , doubles_size + register_offset ) ; <nl> } <nl> Register GetRegisterThatIsNotOneOf ( Register reg1 , <nl> if ( reg5 . is_valid ( ) ) regs | = reg5 . bit ( ) ; <nl> if ( reg6 . is_valid ( ) ) regs | = reg6 . bit ( ) ; <nl> <nl> - for ( int i = 0 ; i < Register : : NumAllocatableRegisters ( ) ; i + + ) { <nl> - Register candidate = Register : : FromAllocationIndex ( i ) ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_general_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableGeneralCode ( i ) ; <nl> + Register candidate = Register : : from_code ( code ) ; <nl> if ( regs & candidate . bit ( ) ) continue ; <nl> return candidate ; <nl> } <nl> mmm a / src / arm / macro - assembler - arm . h <nl> ppp b / src / arm / macro - assembler - arm . h <nl> namespace v8 { <nl> namespace internal { <nl> <nl> / / Give alias names to registers for calling conventions . <nl> - const Register kReturnRegister0 = { kRegister_r0_Code } ; <nl> - const Register kReturnRegister1 = { kRegister_r1_Code } ; <nl> - const Register kJSFunctionRegister = { kRegister_r1_Code } ; <nl> - const Register kContextRegister = { kRegister_r7_Code } ; <nl> - const Register kInterpreterAccumulatorRegister = { kRegister_r0_Code } ; <nl> - const Register kInterpreterRegisterFileRegister = { kRegister_r4_Code } ; <nl> - const Register kInterpreterBytecodeOffsetRegister = { kRegister_r5_Code } ; <nl> - const Register kInterpreterBytecodeArrayRegister = { kRegister_r6_Code } ; <nl> - const Register kInterpreterDispatchTableRegister = { kRegister_r8_Code } ; <nl> - const Register kRuntimeCallFunctionRegister = { kRegister_r1_Code } ; <nl> - const Register kRuntimeCallArgCountRegister = { kRegister_r0_Code } ; <nl> + const Register kReturnRegister0 = { Register : : kCode_r0 } ; <nl> + const Register kReturnRegister1 = { Register : : kCode_r1 } ; <nl> + const Register kJSFunctionRegister = { Register : : kCode_r1 } ; <nl> + const Register kContextRegister = { Register : : kCode_r7 } ; <nl> + const Register kInterpreterAccumulatorRegister = { Register : : kCode_r0 } ; <nl> + const Register kInterpreterRegisterFileRegister = { Register : : kCode_r4 } ; <nl> + const Register kInterpreterBytecodeOffsetRegister = { Register : : kCode_r5 } ; <nl> + const Register kInterpreterBytecodeArrayRegister = { Register : : kCode_r6 } ; <nl> + const Register kInterpreterDispatchTableRegister = { Register : : kCode_r8 } ; <nl> + const Register kRuntimeCallFunctionRegister = { Register : : kCode_r1 } ; <nl> + const Register kRuntimeCallArgCountRegister = { Register : : kCode_r0 } ; <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> / / Static helper functions <nl> inline MemOperand FieldMemOperand ( Register object , int offset ) { <nl> <nl> <nl> / / Give alias names to registers <nl> - const Register cp = { kRegister_r7_Code } ; / / JavaScript context pointer . <nl> - const Register pp = { kRegister_r8_Code } ; / / Constant pool pointer . <nl> - const Register kRootRegister = { kRegister_r10_Code } ; / / Roots array pointer . <nl> + const Register cp = { Register : : kCode_r7 } ; / / JavaScript context pointer . <nl> + const Register pp = { Register : : kCode_r8 } ; / / Constant pool pointer . <nl> + const Register kRootRegister = { Register : : kCode_r10 } ; / / Roots array pointer . <nl> <nl> / / Flags used for AllocateHeapNumber <nl> enum TaggingMode { <nl> mmm a / src / arm / simulator - arm . cc <nl> ppp b / src / arm / simulator - arm . cc <nl> void ArmDebugger : : Debug ( ) { <nl> if ( strcmp ( arg1 , " all " ) = = 0 ) { <nl> for ( int i = 0 ; i < kNumRegisters ; i + + ) { <nl> value = GetRegisterValue ( i ) ; <nl> - PrintF ( " % 3s : 0x % 08x % 10d " , Registers : : Name ( i ) , value , value ) ; <nl> + PrintF ( " % 3s : 0x % 08x % 10d " , Register : : from_code ( i ) . ToString ( ) , <nl> + value , value ) ; <nl> if ( ( argc = = 3 & & strcmp ( arg2 , " fp " ) = = 0 ) & & <nl> i < 8 & & <nl> ( i % 2 ) = = 0 ) { <nl> mmm a / src / arm64 / assembler - arm64 . cc <nl> ppp b / src / arm64 / assembler - arm64 . cc <nl> <nl> # include " src / arm64 / frames - arm64 . h " <nl> # include " src / base / bits . h " <nl> # include " src / base / cpu . h " <nl> + # include " src / register - configuration . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> bool RelocInfo : : IsInConstantPool ( ) { <nl> Register GetAllocatableRegisterThatIsNotOneOf ( Register reg1 , Register reg2 , <nl> Register reg3 , Register reg4 ) { <nl> CPURegList regs ( reg1 , reg2 , reg3 , reg4 ) ; <nl> - for ( int i = 0 ; i < Register : : NumAllocatableRegisters ( ) ; i + + ) { <nl> - Register candidate = Register : : FromAllocationIndex ( i ) ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + Register candidate = Register : : from_code ( code ) ; <nl> if ( regs . IncludesAliasOf ( candidate ) ) continue ; <nl> return candidate ; <nl> } <nl> mmm a / src / arm64 / assembler - arm64 . h <nl> ppp b / src / arm64 / assembler - arm64 . h <nl> namespace internal { <nl> <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / Registers . <nl> - # define REGISTER_CODE_LIST ( R ) \ <nl> - R ( 0 ) R ( 1 ) R ( 2 ) R ( 3 ) R ( 4 ) R ( 5 ) R ( 6 ) R ( 7 ) \ <nl> - R ( 8 ) R ( 9 ) R ( 10 ) R ( 11 ) R ( 12 ) R ( 13 ) R ( 14 ) R ( 15 ) \ <nl> - R ( 16 ) R ( 17 ) R ( 18 ) R ( 19 ) R ( 20 ) R ( 21 ) R ( 22 ) R ( 23 ) \ <nl> - R ( 24 ) R ( 25 ) R ( 26 ) R ( 27 ) R ( 28 ) R ( 29 ) R ( 30 ) R ( 31 ) <nl> - <nl> + / / clang - format off <nl> + # define GENERAL_REGISTER_CODE_LIST ( R ) \ <nl> + R ( 0 ) R ( 1 ) R ( 2 ) R ( 3 ) R ( 4 ) R ( 5 ) R ( 6 ) R ( 7 ) \ <nl> + R ( 8 ) R ( 9 ) R ( 10 ) R ( 11 ) R ( 12 ) R ( 13 ) R ( 14 ) R ( 15 ) \ <nl> + R ( 16 ) R ( 17 ) R ( 18 ) R ( 19 ) R ( 20 ) R ( 21 ) R ( 22 ) R ( 23 ) \ <nl> + R ( 24 ) R ( 25 ) R ( 26 ) R ( 27 ) R ( 28 ) R ( 29 ) R ( 30 ) R ( 31 ) <nl> + <nl> + # define GENERAL_REGISTERS ( R ) \ <nl> + R ( x0 ) R ( x1 ) R ( x2 ) R ( x3 ) R ( x4 ) R ( x5 ) R ( x6 ) R ( x7 ) \ <nl> + R ( x8 ) R ( x9 ) R ( x10 ) R ( x11 ) R ( x12 ) R ( x13 ) R ( x14 ) R ( x15 ) \ <nl> + R ( x16 ) R ( x17 ) R ( x18 ) R ( x19 ) R ( x20 ) R ( x21 ) R ( x22 ) R ( x23 ) \ <nl> + R ( x24 ) R ( x25 ) R ( x26 ) R ( x27 ) R ( x28 ) R ( x29 ) R ( x30 ) R ( x31 ) <nl> + <nl> + # define ALLOCATABLE_GENERAL_REGISTERS ( R ) \ <nl> + R ( x0 ) R ( x1 ) R ( x2 ) R ( x3 ) R ( x4 ) R ( x5 ) R ( x6 ) R ( x7 ) \ <nl> + R ( x8 ) R ( x9 ) R ( x10 ) R ( x11 ) R ( x12 ) R ( x13 ) R ( x14 ) R ( x15 ) \ <nl> + R ( x18 ) R ( x19 ) R ( x20 ) R ( x21 ) R ( x22 ) R ( x23 ) R ( x24 ) R ( x27 ) <nl> + <nl> + # define DOUBLE_REGISTERS ( R ) \ <nl> + R ( d0 ) R ( d1 ) R ( d2 ) R ( d3 ) R ( d4 ) R ( d5 ) R ( d6 ) R ( d7 ) \ <nl> + R ( d8 ) R ( d9 ) R ( d10 ) R ( d11 ) R ( d12 ) R ( d13 ) R ( d14 ) R ( d15 ) \ <nl> + R ( d16 ) R ( d17 ) R ( d18 ) R ( d19 ) R ( d20 ) R ( d21 ) R ( d22 ) R ( d23 ) \ <nl> + R ( d24 ) R ( d25 ) R ( d26 ) R ( d27 ) R ( d28 ) R ( d29 ) R ( d30 ) R ( d31 ) <nl> + <nl> + # define ALLOCATABLE_DOUBLE_REGISTERS ( R ) \ <nl> + R ( d0 ) R ( d1 ) R ( d2 ) R ( d3 ) R ( d4 ) R ( d5 ) R ( d6 ) R ( d7 ) \ <nl> + R ( d8 ) R ( d9 ) R ( d10 ) R ( d11 ) R ( d12 ) R ( d13 ) R ( d14 ) R ( d16 ) \ <nl> + R ( d17 ) R ( d18 ) R ( d19 ) R ( d20 ) R ( d21 ) R ( d22 ) R ( d23 ) R ( d24 ) \ <nl> + R ( d25 ) R ( d26 ) R ( d27 ) R ( d28 ) <nl> + / / clang - format on <nl> <nl> static const int kRegListSizeInBits = sizeof ( RegList ) * kBitsPerByte ; <nl> <nl> struct FPRegister ; <nl> <nl> <nl> struct CPURegister { <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + GENERAL_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> + <nl> enum RegisterType { <nl> / / The kInvalid value is used to detect uninitialized static instances , <nl> / / which are always zero - initialized before any constructors are called . <nl> struct Register : public CPURegister { <nl> DCHECK ( IsValidOrNone ( ) ) ; <nl> } <nl> <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> bool IsValid ( ) const { <nl> DCHECK ( IsRegister ( ) | | IsNone ( ) ) ; <nl> return IsValidRegister ( ) ; <nl> struct Register : public CPURegister { <nl> / / A few of them may be unused for now . <nl> <nl> static const int kNumRegisters = kNumberOfRegisters ; <nl> + STATIC_ASSERT ( kNumRegisters = = Code : : kAfterLast ) ; <nl> static int NumRegisters ( ) { return kNumRegisters ; } <nl> <nl> / / We allow crankshaft to use the following registers : <nl> struct Register : public CPURegister { <nl> / / - " low range " <nl> / / - " high range " <nl> / / - " context " <nl> - static const unsigned kAllocatableLowRangeBegin = 0 ; <nl> - static const unsigned kAllocatableLowRangeEnd = 15 ; <nl> - static const unsigned kAllocatableHighRangeBegin = 18 ; <nl> - static const unsigned kAllocatableHighRangeEnd = 24 ; <nl> - static const unsigned kAllocatableContext = 27 ; <nl> - <nl> - / / Gap between low and high ranges . <nl> - static const int kAllocatableRangeGapSize = <nl> - ( kAllocatableHighRangeBegin - kAllocatableLowRangeEnd ) - 1 ; <nl> - <nl> - static const int kMaxNumAllocatableRegisters = <nl> - ( kAllocatableLowRangeEnd - kAllocatableLowRangeBegin + 1 ) + <nl> - ( kAllocatableHighRangeEnd - kAllocatableHighRangeBegin + 1 ) + 1 ; / / cp <nl> - static int NumAllocatableRegisters ( ) { return kMaxNumAllocatableRegisters ; } <nl> - <nl> - / / Return true if the register is one that crankshaft can allocate . <nl> - bool IsAllocatable ( ) const { <nl> - return ( ( reg_code = = kAllocatableContext ) | | <nl> - ( reg_code < = kAllocatableLowRangeEnd ) | | <nl> - ( ( reg_code > = kAllocatableHighRangeBegin ) & & <nl> - ( reg_code < = kAllocatableHighRangeEnd ) ) ) ; <nl> - } <nl> - <nl> - static Register FromAllocationIndex ( unsigned index ) { <nl> - DCHECK ( index < static_cast < unsigned > ( NumAllocatableRegisters ( ) ) ) ; <nl> - / / cp is the last allocatable register . <nl> - if ( index = = ( static_cast < unsigned > ( NumAllocatableRegisters ( ) - 1 ) ) ) { <nl> - return from_code ( kAllocatableContext ) ; <nl> - } <nl> - <nl> - / / Handle low and high ranges . <nl> - return ( index < = kAllocatableLowRangeEnd ) <nl> - ? from_code ( index ) <nl> - : from_code ( index + kAllocatableRangeGapSize ) ; <nl> - } <nl> - <nl> - static const char * AllocationIndexToString ( int index ) { <nl> - DCHECK ( ( index > = 0 ) & & ( index < NumAllocatableRegisters ( ) ) ) ; <nl> - DCHECK ( ( kAllocatableLowRangeBegin = = 0 ) & & <nl> - ( kAllocatableLowRangeEnd = = 15 ) & & <nl> - ( kAllocatableHighRangeBegin = = 18 ) & & <nl> - ( kAllocatableHighRangeEnd = = 24 ) & & <nl> - ( kAllocatableContext = = 27 ) ) ; <nl> - const char * const names [ ] = { <nl> - " x0 " , " x1 " , " x2 " , " x3 " , " x4 " , <nl> - " x5 " , " x6 " , " x7 " , " x8 " , " x9 " , <nl> - " x10 " , " x11 " , " x12 " , " x13 " , " x14 " , <nl> - " x15 " , " x18 " , " x19 " , " x20 " , " x21 " , <nl> - " x22 " , " x23 " , " x24 " , " x27 " , <nl> - } ; <nl> - return names [ index ] ; <nl> - } <nl> - <nl> - static int ToAllocationIndex ( Register reg ) { <nl> - DCHECK ( reg . IsAllocatable ( ) ) ; <nl> - unsigned code = reg . code ( ) ; <nl> - if ( code = = kAllocatableContext ) { <nl> - return NumAllocatableRegisters ( ) - 1 ; <nl> - } <nl> - <nl> - return ( code < = kAllocatableLowRangeEnd ) <nl> - ? code <nl> - : code - kAllocatableRangeGapSize ; <nl> - } <nl> <nl> static Register from_code ( int code ) { <nl> / / Always return an X register . <nl> struct Register : public CPURegister { <nl> <nl> <nl> struct FPRegister : public CPURegister { <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + DOUBLE_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> + <nl> static FPRegister Create ( unsigned code , unsigned size ) { <nl> return FPRegister ( <nl> CPURegister : : Create ( code , size , CPURegister : : kFPRegister ) ) ; <nl> struct FPRegister : public CPURegister { <nl> DCHECK ( IsValidOrNone ( ) ) ; <nl> } <nl> <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> bool IsValid ( ) const { <nl> DCHECK ( IsFPRegister ( ) | | IsNone ( ) ) ; <nl> return IsValidFPRegister ( ) ; <nl> struct FPRegister : public CPURegister { <nl> <nl> / / Start of V8 compatibility section mmmmmmmmmmmmmmmmmmmmm <nl> static const int kMaxNumRegisters = kNumberOfFPRegisters ; <nl> + STATIC_ASSERT ( kMaxNumRegisters = = Code : : kAfterLast ) ; <nl> <nl> / / Crankshaft can use all the FP registers except : <nl> / / - d15 which is used to keep the 0 double value <nl> / / - d30 which is used in crankshaft as a double scratch register <nl> / / - d31 which is used in the MacroAssembler as a double scratch register <nl> - static const unsigned kAllocatableLowRangeBegin = 0 ; <nl> - static const unsigned kAllocatableLowRangeEnd = 14 ; <nl> - static const unsigned kAllocatableHighRangeBegin = 16 ; <nl> - static const unsigned kAllocatableHighRangeEnd = 28 ; <nl> - <nl> - static const RegList kAllocatableFPRegisters = 0x1fff7fff ; <nl> - <nl> - / / Gap between low and high ranges . <nl> - static const int kAllocatableRangeGapSize = <nl> - ( kAllocatableHighRangeBegin - kAllocatableLowRangeEnd ) - 1 ; <nl> - <nl> - static const int kMaxNumAllocatableRegisters = <nl> - ( kAllocatableLowRangeEnd - kAllocatableLowRangeBegin + 1 ) + <nl> - ( kAllocatableHighRangeEnd - kAllocatableHighRangeBegin + 1 ) ; <nl> - static int NumAllocatableRegisters ( ) { return kMaxNumAllocatableRegisters ; } <nl> - <nl> - / / TODO ( turbofan ) : Proper float32 support . <nl> - static int NumAllocatableAliasedRegisters ( ) { <nl> - return NumAllocatableRegisters ( ) ; <nl> - } <nl> - <nl> - / / Return true if the register is one that crankshaft can allocate . <nl> - bool IsAllocatable ( ) const { <nl> - return ( Bit ( ) & kAllocatableFPRegisters ) ! = 0 ; <nl> - } <nl> - <nl> - static FPRegister FromAllocationIndex ( unsigned int index ) { <nl> - DCHECK ( index < static_cast < unsigned > ( NumAllocatableRegisters ( ) ) ) ; <nl> - <nl> - return ( index < = kAllocatableLowRangeEnd ) <nl> - ? from_code ( index ) <nl> - : from_code ( index + kAllocatableRangeGapSize ) ; <nl> - } <nl> - <nl> - static const char * AllocationIndexToString ( int index ) { <nl> - DCHECK ( ( index > = 0 ) & & ( index < NumAllocatableRegisters ( ) ) ) ; <nl> - DCHECK ( ( kAllocatableLowRangeBegin = = 0 ) & & <nl> - ( kAllocatableLowRangeEnd = = 14 ) & & <nl> - ( kAllocatableHighRangeBegin = = 16 ) & & <nl> - ( kAllocatableHighRangeEnd = = 28 ) ) ; <nl> - const char * const names [ ] = { <nl> - " d0 " , " d1 " , " d2 " , " d3 " , " d4 " , " d5 " , " d6 " , " d7 " , <nl> - " d8 " , " d9 " , " d10 " , " d11 " , " d12 " , " d13 " , " d14 " , <nl> - " d16 " , " d17 " , " d18 " , " d19 " , " d20 " , " d21 " , " d22 " , " d23 " , <nl> - " d24 " , " d25 " , " d26 " , " d27 " , " d28 " <nl> - } ; <nl> - return names [ index ] ; <nl> - } <nl> - <nl> - static int ToAllocationIndex ( FPRegister reg ) { <nl> - DCHECK ( reg . IsAllocatable ( ) ) ; <nl> - unsigned code = reg . code ( ) ; <nl> - <nl> - return ( code < = kAllocatableLowRangeEnd ) <nl> - ? code <nl> - : code - kAllocatableRangeGapSize ; <nl> - } <nl> - <nl> static FPRegister from_code ( int code ) { <nl> / / Always return a D register . <nl> return FPRegister : : Create ( code , kDRegSizeInBits ) ; <nl> INITIALIZE_REGISTER ( Register , no_reg , 0 , 0 , CPURegister : : kNoRegister ) ; <nl> kWRegSizeInBits , CPURegister : : kRegister ) ; \ <nl> INITIALIZE_REGISTER ( Register , x # # N , N , \ <nl> kXRegSizeInBits , CPURegister : : kRegister ) ; <nl> - REGISTER_CODE_LIST ( DEFINE_REGISTERS ) <nl> + GENERAL_REGISTER_CODE_LIST ( DEFINE_REGISTERS ) <nl> # undef DEFINE_REGISTERS <nl> <nl> INITIALIZE_REGISTER ( Register , wcsp , kSPRegInternalCode , kWRegSizeInBits , <nl> INITIALIZE_REGISTER ( Register , csp , kSPRegInternalCode , kXRegSizeInBits , <nl> kSRegSizeInBits , CPURegister : : kFPRegister ) ; \ <nl> INITIALIZE_REGISTER ( FPRegister , d # # N , N , \ <nl> kDRegSizeInBits , CPURegister : : kFPRegister ) ; <nl> - REGISTER_CODE_LIST ( DEFINE_FPREGISTERS ) <nl> + GENERAL_REGISTER_CODE_LIST ( DEFINE_FPREGISTERS ) <nl> # undef DEFINE_FPREGISTERS <nl> <nl> # undef INITIALIZE_REGISTER <nl> mmm a / src / arm64 / constants - arm64 . h <nl> ppp b / src / arm64 / constants - arm64 . h <nl> const unsigned kDoubleExponentBias = 1023 ; <nl> const unsigned kFloatMantissaBits = 23 ; <nl> const unsigned kFloatExponentBits = 8 ; <nl> <nl> - # define REGISTER_CODE_LIST ( R ) \ <nl> - R ( 0 ) R ( 1 ) R ( 2 ) R ( 3 ) R ( 4 ) R ( 5 ) R ( 6 ) R ( 7 ) \ <nl> - R ( 8 ) R ( 9 ) R ( 10 ) R ( 11 ) R ( 12 ) R ( 13 ) R ( 14 ) R ( 15 ) \ <nl> - R ( 16 ) R ( 17 ) R ( 18 ) R ( 19 ) R ( 20 ) R ( 21 ) R ( 22 ) R ( 23 ) \ <nl> - R ( 24 ) R ( 25 ) R ( 26 ) R ( 27 ) R ( 28 ) R ( 29 ) R ( 30 ) R ( 31 ) <nl> - <nl> # define INSTRUCTION_FIELDS_LIST ( V_ ) \ <nl> / * Register fields * / \ <nl> V_ ( Rd , 4 , 0 , Bits ) / * Destination register . * / \ <nl> mmm a / src / arm64 / deoptimizer - arm64 . cc <nl> ppp b / src / arm64 / deoptimizer - arm64 . cc <nl> <nl> # include " src / codegen . h " <nl> # include " src / deoptimizer . h " <nl> # include " src / full - codegen / full - codegen . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / safepoint - table . h " <nl> <nl> <nl> void Deoptimizer : : FillInputFrame ( Address tos , JavaScriptFrame * frame ) { <nl> input_ - > SetRegister ( jssp . code ( ) , reinterpret_cast < intptr_t > ( frame - > sp ( ) ) ) ; <nl> input_ - > SetRegister ( fp . code ( ) , reinterpret_cast < intptr_t > ( frame - > fp ( ) ) ) ; <nl> <nl> - for ( int i = 0 ; i < DoubleRegister : : NumAllocatableRegisters ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < DoubleRegister : : kMaxNumRegisters ; i + + ) { <nl> input_ - > SetDoubleRegister ( i , 0 . 0 ) ; <nl> } <nl> <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> / / in the input frame . <nl> <nl> / / Save all allocatable floating point registers . <nl> - CPURegList saved_fp_registers ( CPURegister : : kFPRegister , kDRegSizeInBits , <nl> - FPRegister : : kAllocatableFPRegisters ) ; <nl> + CPURegList saved_fp_registers ( <nl> + CPURegister : : kFPRegister , kDRegSizeInBits , <nl> + RegisterConfiguration : : ArchDefault ( ) - > allocatable_double_codes_mask ( ) ) ; <nl> __ PushCPURegList ( saved_fp_registers ) ; <nl> <nl> / / We save all the registers expcept jssp , sp and lr . <nl> mmm a / src / arm64 / lithium - arm64 . cc <nl> ppp b / src / arm64 / lithium - arm64 . cc <nl> const char * LArithmeticT : : Mnemonic ( ) const { <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( Register reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , <nl> - Register : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( DoubleRegister reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , <nl> - DoubleRegister : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) <nl> + LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / arm64 / lithium - codegen - arm64 . cc <nl> ppp b / src / arm64 / lithium - codegen - arm64 . cc <nl> void LCodeGen : : SaveCallerDoubles ( ) { <nl> while ( ! iterator . Done ( ) ) { <nl> / / TODO ( all ) : Is this supposed to save just the callee - saved doubles ? It <nl> / / looks like it ' s saving all of them . <nl> - FPRegister value = FPRegister : : FromAllocationIndex ( iterator . Current ( ) ) ; <nl> + FPRegister value = FPRegister : : from_code ( iterator . Current ( ) ) ; <nl> __ Poke ( value , count * kDoubleSize ) ; <nl> iterator . Advance ( ) ; <nl> count + + ; <nl> void LCodeGen : : RestoreCallerDoubles ( ) { <nl> while ( ! iterator . Done ( ) ) { <nl> / / TODO ( all ) : Is this supposed to restore just the callee - saved doubles ? It <nl> / / looks like it ' s restoring all of them . <nl> - FPRegister value = FPRegister : : FromAllocationIndex ( iterator . Current ( ) ) ; <nl> + FPRegister value = FPRegister : : from_code ( iterator . Current ( ) ) ; <nl> __ Peek ( value , count * kDoubleSize ) ; <nl> iterator . Advance ( ) ; <nl> count + + ; <nl> void LCodeGen : : EnsureSpaceForLazyDeopt ( int space_needed ) { <nl> Register LCodeGen : : ToRegister ( LOperand * op ) const { <nl> / / TODO ( all ) : support zero register results , as ToRegister32 . <nl> DCHECK ( ( op ! = NULL ) & & op - > IsRegister ( ) ) ; <nl> - return Register : : FromAllocationIndex ( op - > index ( ) ) ; <nl> + return Register : : from_code ( op - > index ( ) ) ; <nl> } <nl> <nl> <nl> Smi * LCodeGen : : ToSmi ( LConstantOperand * op ) const { <nl> <nl> DoubleRegister LCodeGen : : ToDoubleRegister ( LOperand * op ) const { <nl> DCHECK ( ( op ! = NULL ) & & op - > IsDoubleRegister ( ) ) ; <nl> - return DoubleRegister : : FromAllocationIndex ( op - > index ( ) ) ; <nl> + return DoubleRegister : : from_code ( op - > index ( ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / arm64 / macro - assembler - arm64 . cc <nl> ppp b / src / arm64 / macro - assembler - arm64 . cc <nl> <nl> # include " src / codegen . h " <nl> # include " src / cpu - profiler . h " <nl> # include " src / debug / debug . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / runtime / runtime . h " <nl> <nl> # include " src / arm64 / frames - arm64 . h " <nl> void MacroAssembler : : PushSafepointRegisters ( ) { <nl> <nl> void MacroAssembler : : PushSafepointRegistersAndDoubles ( ) { <nl> PushSafepointRegisters ( ) ; <nl> - PushCPURegList ( CPURegList ( CPURegister : : kFPRegister , kDRegSizeInBits , <nl> - FPRegister : : kAllocatableFPRegisters ) ) ; <nl> + PushCPURegList ( CPURegList ( <nl> + CPURegister : : kFPRegister , kDRegSizeInBits , <nl> + RegisterConfiguration : : ArchDefault ( ) - > allocatable_double_codes_mask ( ) ) ) ; <nl> } <nl> <nl> <nl> void MacroAssembler : : PopSafepointRegistersAndDoubles ( ) { <nl> - PopCPURegList ( CPURegList ( CPURegister : : kFPRegister , kDRegSizeInBits , <nl> - FPRegister : : kAllocatableFPRegisters ) ) ; <nl> + PopCPURegList ( CPURegList ( <nl> + CPURegister : : kFPRegister , kDRegSizeInBits , <nl> + RegisterConfiguration : : ArchDefault ( ) - > allocatable_double_codes_mask ( ) ) ) ; <nl> PopSafepointRegisters ( ) ; <nl> } <nl> <nl> mmm a / src / arm64 / simulator - arm64 . h <nl> ppp b / src / arm64 / simulator - arm64 . h <nl> <nl> # include " src / globals . h " <nl> # include " src / utils . h " <nl> <nl> - # define REGISTER_CODE_LIST ( R ) \ <nl> - R ( 0 ) R ( 1 ) R ( 2 ) R ( 3 ) R ( 4 ) R ( 5 ) R ( 6 ) R ( 7 ) \ <nl> - R ( 8 ) R ( 9 ) R ( 10 ) R ( 11 ) R ( 12 ) R ( 13 ) R ( 14 ) R ( 15 ) \ <nl> - R ( 16 ) R ( 17 ) R ( 18 ) R ( 19 ) R ( 20 ) R ( 21 ) R ( 22 ) R ( 23 ) \ <nl> - R ( 24 ) R ( 25 ) R ( 26 ) R ( 27 ) R ( 28 ) R ( 29 ) R ( 30 ) R ( 31 ) <nl> - <nl> namespace v8 { <nl> namespace internal { <nl> <nl> mmm a / src / arm64 / utils - arm64 . h <nl> ppp b / src / arm64 / utils - arm64 . h <nl> <nl> <nl> # include " src / arm64 / constants - arm64 . h " <nl> <nl> - # define REGISTER_CODE_LIST ( R ) \ <nl> - R ( 0 ) R ( 1 ) R ( 2 ) R ( 3 ) R ( 4 ) R ( 5 ) R ( 6 ) R ( 7 ) \ <nl> - R ( 8 ) R ( 9 ) R ( 10 ) R ( 11 ) R ( 12 ) R ( 13 ) R ( 14 ) R ( 15 ) \ <nl> - R ( 16 ) R ( 17 ) R ( 18 ) R ( 19 ) R ( 20 ) R ( 21 ) R ( 22 ) R ( 23 ) \ <nl> - R ( 24 ) R ( 25 ) R ( 26 ) R ( 27 ) R ( 28 ) R ( 29 ) R ( 30 ) R ( 31 ) <nl> - <nl> namespace v8 { <nl> namespace internal { <nl> <nl> mmm a / src / assembler . cc <nl> ppp b / src / assembler . cc <nl> <nl> # include " src / regexp / jsregexp . h " <nl> # include " src / regexp / regexp - macro - assembler . h " <nl> # include " src / regexp / regexp - stack . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / runtime / runtime . h " <nl> # include " src / simulator . h " / / For flushing instruction cache . <nl> # include " src / snapshot / serialize . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / Common register code . <nl> + <nl> + const char * Register : : ToString ( ) { <nl> + / / This is the mapping of allocation indices to registers . <nl> + DCHECK ( reg_code > = 0 & & reg_code < kNumRegisters ) ; <nl> + return RegisterConfiguration : : ArchDefault ( ) - > GetGeneralRegisterName ( reg_code ) ; <nl> + } <nl> + <nl> + <nl> + bool Register : : IsAllocatable ( ) const { <nl> + return ( ( 1 < < reg_code ) & <nl> + RegisterConfiguration : : ArchDefault ( ) <nl> + - > allocatable_general_codes_mask ( ) ) ! = 0 ; <nl> + } <nl> + <nl> + <nl> + const char * DoubleRegister : : ToString ( ) { <nl> + / / This is the mapping of allocation indices to registers . <nl> + DCHECK ( reg_code > = 0 & & reg_code < kMaxNumRegisters ) ; <nl> + return RegisterConfiguration : : ArchDefault ( ) - > GetDoubleRegisterName ( reg_code ) ; <nl> + } <nl> + <nl> + <nl> + bool DoubleRegister : : IsAllocatable ( ) const { <nl> + return ( ( 1 < < reg_code ) & <nl> + RegisterConfiguration : : ArchDefault ( ) <nl> + - > allocatable_double_codes_mask ( ) ) ! = 0 ; <nl> + } <nl> + <nl> + <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / Common double constants . <nl> <nl> mmm a / src / assembler . h <nl> ppp b / src / assembler . h <nl> class ConstantPoolBuilder BASE_EMBEDDED { <nl> PerTypeEntryInfo info_ [ ConstantPoolEntry : : NUMBER_OF_TYPES ] ; <nl> } ; <nl> <nl> - <nl> } } / / namespace v8 : : internal <nl> <nl> # endif / / V8_ASSEMBLER_H_ <nl> mmm a / src / compiler / c - linkage . cc <nl> ppp b / src / compiler / c - linkage . cc <nl> namespace compiler { <nl> <nl> namespace { <nl> LinkageLocation regloc ( Register reg ) { <nl> - return LinkageLocation : : ForRegister ( Register : : ToAllocationIndex ( reg ) ) ; <nl> + return LinkageLocation : : ForRegister ( reg . code ( ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / compiler / code - generator - impl . h <nl> ppp b / src / compiler / code - generator - impl . h <nl> class InstructionOperandConverter { <nl> } <nl> <nl> Register ToRegister ( InstructionOperand * op ) { <nl> - return Register : : FromAllocationIndex ( RegisterOperand : : cast ( op ) - > index ( ) ) ; <nl> + return RegisterOperand : : cast ( op ) - > GetRegister ( ) ; <nl> } <nl> <nl> DoubleRegister ToDoubleRegister ( InstructionOperand * op ) { <nl> - return DoubleRegister : : FromAllocationIndex ( <nl> - DoubleRegisterOperand : : cast ( op ) - > index ( ) ) ; <nl> + return DoubleRegisterOperand : : cast ( op ) - > GetDoubleRegister ( ) ; <nl> } <nl> <nl> Constant ToConstant ( InstructionOperand * op ) { <nl> mmm a / src / compiler / code - generator . cc <nl> ppp b / src / compiler / code - generator . cc <nl> void CodeGenerator : : RecordSafepoint ( ReferenceMap * references , <nl> index - = stackSlotToSpillSlotDelta ; <nl> safepoint . DefinePointerSlot ( index , zone ( ) ) ; <nl> } else if ( operand . IsRegister ( ) & & ( kind & Safepoint : : kWithRegisters ) ) { <nl> - Register reg = <nl> - Register : : FromAllocationIndex ( RegisterOperand : : cast ( operand ) . index ( ) ) ; <nl> + Register reg = RegisterOperand : : cast ( operand ) . GetRegister ( ) ; <nl> safepoint . DefinePointerRegister ( reg , zone ( ) ) ; <nl> } <nl> } <nl> mmm a / src / compiler / graph - visualizer . cc <nl> ppp b / src / compiler / graph - visualizer . cc <nl> void GraphC1Visualizer : : PrintLiveRange ( LiveRange * range , const char * type , <nl> os_ < < vreg < < " : " < < range - > relative_id ( ) < < " " < < type ; <nl> if ( range - > HasRegisterAssigned ( ) ) { <nl> AllocatedOperand op = AllocatedOperand : : cast ( range - > GetAssignedOperand ( ) ) ; <nl> - int assigned_reg = op . index ( ) ; <nl> if ( op . IsDoubleRegister ( ) ) { <nl> - os_ < < " \ " " < < DoubleRegister : : AllocationIndexToString ( assigned_reg ) <nl> - < < " \ " " ; <nl> + DoubleRegister assigned_reg = op . GetDoubleRegister ( ) ; <nl> + os_ < < " \ " " < < assigned_reg . ToString ( ) < < " \ " " ; <nl> } else { <nl> DCHECK ( op . IsRegister ( ) ) ; <nl> - os_ < < " \ " " < < Register : : AllocationIndexToString ( assigned_reg ) < < " \ " " ; <nl> + Register assigned_reg = op . GetRegister ( ) ; <nl> + os_ < < " \ " " < < assigned_reg . ToString ( ) < < " \ " " ; <nl> } <nl> } else if ( range - > spilled ( ) ) { <nl> auto top = range - > TopLevel ( ) ; <nl> mmm a / src / compiler / instruction - selector - impl . h <nl> ppp b / src / compiler / instruction - selector - impl . h <nl> class OperandGenerator { <nl> <nl> InstructionOperand DefineAsFixed ( Node * node , Register reg ) { <nl> return Define ( node , UnallocatedOperand ( UnallocatedOperand : : FIXED_REGISTER , <nl> - Register : : ToAllocationIndex ( reg ) , <nl> - GetVReg ( node ) ) ) ; <nl> + reg . code ( ) , GetVReg ( node ) ) ) ; <nl> } <nl> <nl> InstructionOperand DefineAsFixed ( Node * node , DoubleRegister reg ) { <nl> return Define ( node , <nl> UnallocatedOperand ( UnallocatedOperand : : FIXED_DOUBLE_REGISTER , <nl> - DoubleRegister : : ToAllocationIndex ( reg ) , <nl> - GetVReg ( node ) ) ) ; <nl> + reg . code ( ) , GetVReg ( node ) ) ) ; <nl> } <nl> <nl> InstructionOperand DefineAsConstant ( Node * node ) { <nl> class OperandGenerator { <nl> <nl> InstructionOperand UseFixed ( Node * node , Register reg ) { <nl> return Use ( node , UnallocatedOperand ( UnallocatedOperand : : FIXED_REGISTER , <nl> - Register : : ToAllocationIndex ( reg ) , <nl> - GetVReg ( node ) ) ) ; <nl> + reg . code ( ) , GetVReg ( node ) ) ) ; <nl> } <nl> <nl> InstructionOperand UseFixed ( Node * node , DoubleRegister reg ) { <nl> return Use ( node , <nl> UnallocatedOperand ( UnallocatedOperand : : FIXED_DOUBLE_REGISTER , <nl> - DoubleRegister : : ToAllocationIndex ( reg ) , <nl> - GetVReg ( node ) ) ) ; <nl> + reg . code ( ) , GetVReg ( node ) ) ) ; <nl> } <nl> <nl> InstructionOperand UseImmediate ( Node * node ) { <nl> class OperandGenerator { <nl> } <nl> <nl> InstructionOperand TempRegister ( Register reg ) { <nl> - return UnallocatedOperand ( UnallocatedOperand : : FIXED_REGISTER , <nl> - Register : : ToAllocationIndex ( reg ) , <nl> + return UnallocatedOperand ( UnallocatedOperand : : FIXED_REGISTER , reg . code ( ) , <nl> InstructionOperand : : kInvalidVirtualRegister ) ; <nl> } <nl> <nl> mmm a / src / compiler / instruction . cc <nl> ppp b / src / compiler / instruction . cc <nl> std : : ostream & operator < < ( std : : ostream & os , <nl> case UnallocatedOperand : : NONE : <nl> return os ; <nl> case UnallocatedOperand : : FIXED_REGISTER : <nl> - return os < < " ( = " < < conf - > general_register_name ( <nl> - unalloc - > fixed_register_index ( ) ) < < " ) " ; <nl> + return os < < " ( = " <nl> + < < conf - > GetGeneralRegisterName ( <nl> + unalloc - > fixed_register_index ( ) ) <nl> + < < " ) " ; <nl> case UnallocatedOperand : : FIXED_DOUBLE_REGISTER : <nl> - return os < < " ( = " < < conf - > double_register_name ( <nl> - unalloc - > fixed_register_index ( ) ) < < " ) " ; <nl> + return os < < " ( = " <nl> + < < conf - > GetDoubleRegisterName ( <nl> + unalloc - > fixed_register_index ( ) ) <nl> + < < " ) " ; <nl> case UnallocatedOperand : : MUST_HAVE_REGISTER : <nl> return os < < " ( R ) " ; <nl> case UnallocatedOperand : : MUST_HAVE_SLOT : <nl> std : : ostream & operator < < ( std : : ostream & os , <nl> os < < " [ double_stack : " < < DoubleStackSlotOperand : : cast ( op ) . index ( ) ; <nl> break ; <nl> case AllocatedOperand : : REGISTER : <nl> - os < < " [ " <nl> - < < conf - > general_register_name ( RegisterOperand : : cast ( op ) . index ( ) ) <nl> + os < < " [ " < < RegisterOperand : : cast ( op ) . GetRegister ( ) . ToString ( ) <nl> < < " | R " ; <nl> break ; <nl> case AllocatedOperand : : DOUBLE_REGISTER : <nl> - os < < " [ " <nl> - < < conf - > double_register_name ( <nl> - DoubleRegisterOperand : : cast ( op ) . index ( ) ) < < " | R " ; <nl> + os < < " [ " < < DoubleRegisterOperand : : cast ( op ) . GetRegister ( ) . ToString ( ) <nl> + < < " | R " ; <nl> break ; <nl> } <nl> switch ( allocated . machine_type ( ) ) { <nl> mmm a / src / compiler / instruction . h <nl> ppp b / src / compiler / instruction . h <nl> <nl> # include " src / compiler / frame . h " <nl> # include " src / compiler / instruction - codes . h " <nl> # include " src / compiler / opcodes . h " <nl> - # include " src / compiler / register - configuration . h " <nl> # include " src / compiler / source - position . h " <nl> + # include " src / macro - assembler . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / zone - allocator . h " <nl> <nl> namespace v8 { <nl> class AllocatedOperand : public InstructionOperand { <nl> } <nl> <nl> int index ( ) const { <nl> + DCHECK ( STACK_SLOT = = allocated_kind ( ) | | <nl> + DOUBLE_STACK_SLOT = = allocated_kind ( ) ) ; <nl> return static_cast < int64_t > ( value_ ) > > IndexField : : kShift ; <nl> } <nl> <nl> + Register GetRegister ( ) const { <nl> + DCHECK ( REGISTER = = allocated_kind ( ) | | DOUBLE_REGISTER = = allocated_kind ( ) ) ; <nl> + return Register : : from_code ( static_cast < int64_t > ( value_ ) > > <nl> + IndexField : : kShift ) ; <nl> + } <nl> + <nl> + DoubleRegister GetDoubleRegister ( ) const { <nl> + DCHECK ( REGISTER = = allocated_kind ( ) | | DOUBLE_REGISTER = = allocated_kind ( ) ) ; <nl> + return DoubleRegister : : from_code ( static_cast < int64_t > ( value_ ) > > <nl> + IndexField : : kShift ) ; <nl> + } <nl> + <nl> AllocatedKind allocated_kind ( ) const { <nl> return AllocatedKindField : : decode ( value_ ) ; <nl> } <nl> mmm a / src / compiler / linkage . cc <nl> ppp b / src / compiler / linkage . cc <nl> namespace compiler { <nl> <nl> namespace { <nl> LinkageLocation regloc ( Register reg ) { <nl> - return LinkageLocation : : ForRegister ( Register : : ToAllocationIndex ( reg ) ) ; <nl> + return LinkageLocation : : ForRegister ( reg . code ( ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / compiler / pipeline . cc <nl> ppp b / src / compiler / pipeline . cc <nl> <nl> # include " src / compiler / verifier . h " <nl> # include " src / compiler / zone - pool . h " <nl> # include " src / ostreams . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / type - info . h " <nl> # include " src / utils . h " <nl> <nl> mmm a / src / compiler / pipeline . h <nl> ppp b / src / compiler / pipeline . h <nl> <nl> <nl> namespace v8 { <nl> namespace internal { <nl> + <nl> + class RegisterConfiguration ; <nl> + <nl> namespace compiler { <nl> <nl> class CallDescriptor ; <nl> class Graph ; <nl> class InstructionSequence ; <nl> class Linkage ; <nl> class PipelineData ; <nl> - class RegisterConfiguration ; <nl> class Schedule ; <nl> <nl> class Pipeline { <nl> mmm a / src / compiler / register - allocator - verifier . cc <nl> ppp b / src / compiler / register - allocator - verifier . cc <nl> void RegisterAllocatorVerifier : : CheckConstraint ( <nl> return ; <nl> case kFixedRegister : <nl> CHECK ( op - > IsRegister ( ) ) ; <nl> - CHECK_EQ ( RegisterOperand : : cast ( op ) - > index ( ) , constraint - > value_ ) ; <nl> + CHECK_EQ ( RegisterOperand : : cast ( op ) - > GetDoubleRegister ( ) . code ( ) , <nl> + constraint - > value_ ) ; <nl> return ; <nl> case kDoubleRegister : <nl> CHECK ( op - > IsDoubleRegister ( ) ) ; <nl> return ; <nl> case kFixedDoubleRegister : <nl> CHECK ( op - > IsDoubleRegister ( ) ) ; <nl> - CHECK_EQ ( DoubleRegisterOperand : : cast ( op ) - > index ( ) , constraint - > value_ ) ; <nl> + CHECK_EQ ( DoubleRegisterOperand : : cast ( op ) - > GetDoubleRegister ( ) . code ( ) , <nl> + constraint - > value_ ) ; <nl> return ; <nl> case kFixedSlot : <nl> CHECK ( op - > IsStackSlot ( ) ) ; <nl> mmm a / src / compiler / register - allocator . cc <nl> ppp b / src / compiler / register - allocator . cc <nl> void RemoveElement ( ZoneVector < LiveRange * > * v , LiveRange * range ) { <nl> <nl> <nl> int GetRegisterCount ( const RegisterConfiguration * cfg , RegisterKind kind ) { <nl> - return kind = = DOUBLE_REGISTERS ? cfg - > num_aliased_double_registers ( ) <nl> + return kind = = DOUBLE_REGISTERS ? cfg - > num_double_registers ( ) <nl> : cfg - > num_general_registers ( ) ; <nl> } <nl> <nl> <nl> + int GetAllocatableRegisterCount ( const RegisterConfiguration * cfg , <nl> + RegisterKind kind ) { <nl> + return kind = = DOUBLE_REGISTERS <nl> + ? cfg - > num_allocatable_aliased_double_registers ( ) <nl> + : cfg - > num_allocatable_general_registers ( ) ; <nl> + } <nl> + <nl> + <nl> + const int * GetAllocatableRegisterCodes ( const RegisterConfiguration * cfg , <nl> + RegisterKind kind ) { <nl> + return kind = = DOUBLE_REGISTERS ? cfg - > allocatable_double_codes ( ) <nl> + : cfg - > allocatable_general_codes ( ) ; <nl> + } <nl> + <nl> + <nl> const InstructionBlock * GetContainingLoop ( const InstructionSequence * sequence , <nl> const InstructionBlock * block ) { <nl> auto index = block - > loop_header ( ) ; <nl> Instruction * GetLastInstruction ( InstructionSequence * code , <nl> } <nl> <nl> <nl> - bool IsOutputRegisterOf ( Instruction * instr , int index ) { <nl> + bool IsOutputRegisterOf ( Instruction * instr , Register reg ) { <nl> for ( size_t i = 0 ; i < instr - > OutputCount ( ) ; i + + ) { <nl> auto output = instr - > OutputAt ( i ) ; <nl> if ( output - > IsRegister ( ) & & <nl> - RegisterOperand : : cast ( output ) - > index ( ) = = index ) { <nl> + RegisterOperand : : cast ( output ) - > GetRegister ( ) . is ( reg ) ) { <nl> return true ; <nl> } <nl> } <nl> bool IsOutputRegisterOf ( Instruction * instr , int index ) { <nl> } <nl> <nl> <nl> - bool IsOutputDoubleRegisterOf ( Instruction * instr , int index ) { <nl> + bool IsOutputDoubleRegisterOf ( Instruction * instr , DoubleRegister reg ) { <nl> for ( size_t i = 0 ; i < instr - > OutputCount ( ) ; i + + ) { <nl> auto output = instr - > OutputAt ( i ) ; <nl> if ( output - > IsDoubleRegister ( ) & & <nl> - DoubleRegisterOperand : : cast ( output ) - > index ( ) = = index ) { <nl> + DoubleRegisterOperand : : cast ( output ) - > GetDoubleRegister ( ) . is ( reg ) ) { <nl> return true ; <nl> } <nl> } <nl> bool UsePosition : : HasHint ( ) const { <nl> } <nl> <nl> <nl> - bool UsePosition : : HintRegister ( int * register_index ) const { <nl> + bool UsePosition : : HintRegister ( int * register_code ) const { <nl> if ( hint_ = = nullptr ) return false ; <nl> switch ( HintTypeField : : decode ( flags_ ) ) { <nl> case UsePositionHintType : : kNone : <nl> bool UsePosition : : HintRegister ( int * register_index ) const { <nl> auto use_pos = reinterpret_cast < UsePosition * > ( hint_ ) ; <nl> int assigned_register = AssignedRegisterField : : decode ( use_pos - > flags_ ) ; <nl> if ( assigned_register = = kUnassignedRegister ) return false ; <nl> - * register_index = assigned_register ; <nl> + * register_code = assigned_register ; <nl> return true ; <nl> } <nl> case UsePositionHintType : : kOperand : { <nl> auto operand = reinterpret_cast < InstructionOperand * > ( hint_ ) ; <nl> - int assigned_register = AllocatedOperand : : cast ( operand ) - > index ( ) ; <nl> - * register_index = assigned_register ; <nl> + int assigned_register = <nl> + operand - > IsRegister ( ) <nl> + ? RegisterOperand : : cast ( operand ) - > GetRegister ( ) . code ( ) <nl> + : DoubleRegisterOperand : : cast ( operand ) <nl> + - > GetDoubleRegister ( ) <nl> + . code ( ) ; <nl> + * register_code = assigned_register ; <nl> return true ; <nl> } <nl> case UsePositionHintType : : kPhi : { <nl> auto phi = reinterpret_cast < RegisterAllocationData : : PhiMapValue * > ( hint_ ) ; <nl> int assigned_register = phi - > assigned_register ( ) ; <nl> if ( assigned_register = = kUnassignedRegister ) return false ; <nl> - * register_index = assigned_register ; <nl> + * register_code = assigned_register ; <nl> return true ; <nl> } <nl> } <nl> RegisterAllocationData : : RegisterAllocationData ( <nl> debug_name_ ( debug_name ) , <nl> config_ ( config ) , <nl> phi_map_ ( allocation_zone ( ) ) , <nl> + allocatable_codes_ ( this - > config ( ) - > num_general_registers ( ) , - 1 , <nl> + allocation_zone ( ) ) , <nl> + allocatable_double_codes_ ( this - > config ( ) - > num_double_registers ( ) , - 1 , <nl> + allocation_zone ( ) ) , <nl> live_in_sets_ ( code - > InstructionBlockCount ( ) , nullptr , allocation_zone ( ) ) , <nl> live_out_sets_ ( code - > InstructionBlockCount ( ) , nullptr , allocation_zone ( ) ) , <nl> live_ranges_ ( code - > VirtualRegisterCount ( ) * 2 , nullptr , <nl> RegisterAllocationData : : RegisterAllocationData ( <nl> assigned_registers_ = new ( code_zone ( ) ) <nl> BitVector ( this - > config ( ) - > num_general_registers ( ) , code_zone ( ) ) ; <nl> assigned_double_registers_ = new ( code_zone ( ) ) <nl> - BitVector ( this - > config ( ) - > num_aliased_double_registers ( ) , code_zone ( ) ) ; <nl> + BitVector ( this - > config ( ) - > num_double_registers ( ) , code_zone ( ) ) ; <nl> this - > frame ( ) - > SetAllocatedRegisters ( assigned_registers_ ) ; <nl> this - > frame ( ) - > SetAllocatedDoubleRegisters ( assigned_double_registers_ ) ; <nl> } <nl> TopLevelLiveRange * LiveRangeBuilder : : FixedLiveRangeFor ( int index ) { <nl> <nl> <nl> TopLevelLiveRange * LiveRangeBuilder : : FixedDoubleLiveRangeFor ( int index ) { <nl> - DCHECK ( index < config ( ) - > num_aliased_double_registers ( ) ) ; <nl> + DCHECK ( index < config ( ) - > num_double_registers ( ) ) ; <nl> auto result = data ( ) - > fixed_double_live_ranges ( ) [ index ] ; <nl> if ( result = = nullptr ) { <nl> result = data ( ) - > NewLiveRange ( FixedDoubleLiveRangeID ( index ) , kRepFloat64 ) ; <nl> TopLevelLiveRange * LiveRangeBuilder : : LiveRangeFor ( InstructionOperand * operand ) { <nl> return data ( ) - > GetOrCreateLiveRangeFor ( <nl> ConstantOperand : : cast ( operand ) - > virtual_register ( ) ) ; <nl> } else if ( operand - > IsRegister ( ) ) { <nl> - return FixedLiveRangeFor ( RegisterOperand : : cast ( operand ) - > index ( ) ) ; <nl> + return FixedLiveRangeFor ( <nl> + RegisterOperand : : cast ( operand ) - > GetRegister ( ) . code ( ) ) ; <nl> } else if ( operand - > IsDoubleRegister ( ) ) { <nl> return FixedDoubleLiveRangeFor ( <nl> - DoubleRegisterOperand : : cast ( operand ) - > index ( ) ) ; <nl> + DoubleRegisterOperand : : cast ( operand ) - > GetDoubleRegister ( ) . code ( ) ) ; <nl> } else { <nl> return nullptr ; <nl> } <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> } <nl> <nl> if ( instr - > ClobbersRegisters ( ) ) { <nl> - for ( int i = 0 ; i < config ( ) - > num_general_registers ( ) ; + + i ) { <nl> - if ( ! IsOutputRegisterOf ( instr , i ) ) { <nl> - auto range = FixedLiveRangeFor ( i ) ; <nl> + for ( int i = 0 ; i < config ( ) - > num_allocatable_general_registers ( ) ; + + i ) { <nl> + int code = config ( ) - > GetAllocatableGeneralCode ( i ) ; <nl> + if ( ! IsOutputRegisterOf ( instr , Register : : from_code ( code ) ) ) { <nl> + auto range = FixedLiveRangeFor ( code ) ; <nl> range - > AddUseInterval ( curr_position , curr_position . End ( ) , <nl> allocation_zone ( ) ) ; <nl> } <nl> void LiveRangeBuilder : : ProcessInstructions ( const InstructionBlock * block , <nl> } <nl> <nl> if ( instr - > ClobbersDoubleRegisters ( ) ) { <nl> - for ( int i = 0 ; i < config ( ) - > num_aliased_double_registers ( ) ; + + i ) { <nl> - if ( ! IsOutputDoubleRegisterOf ( instr , i ) ) { <nl> - auto range = FixedDoubleLiveRangeFor ( i ) ; <nl> + for ( int i = 0 ; i < config ( ) - > num_allocatable_aliased_double_registers ( ) ; <nl> + + + i ) { <nl> + int code = config ( ) - > GetAllocatableDoubleCode ( i ) ; <nl> + if ( ! IsOutputDoubleRegisterOf ( instr , DoubleRegister : : from_code ( code ) ) ) { <nl> + auto range = FixedDoubleLiveRangeFor ( code ) ; <nl> range - > AddUseInterval ( curr_position , curr_position . End ( ) , <nl> allocation_zone ( ) ) ; <nl> } <nl> RegisterAllocator : : RegisterAllocator ( RegisterAllocationData * data , <nl> RegisterKind kind ) <nl> : data_ ( data ) , <nl> mode_ ( kind ) , <nl> - num_registers_ ( GetRegisterCount ( data - > config ( ) , kind ) ) { } <nl> + num_registers_ ( GetRegisterCount ( data - > config ( ) , kind ) ) , <nl> + num_allocatable_registers_ ( <nl> + GetAllocatableRegisterCount ( data - > config ( ) , kind ) ) , <nl> + allocatable_register_codes_ ( <nl> + GetAllocatableRegisterCodes ( data - > config ( ) , kind ) ) { } <nl> <nl> <nl> LiveRange * RegisterAllocator : : SplitRangeAt ( LiveRange * range , <nl> const ZoneVector < TopLevelLiveRange * > & RegisterAllocator : : GetFixedRegisters ( ) <nl> } <nl> <nl> <nl> - const char * RegisterAllocator : : RegisterName ( int allocation_index ) const { <nl> + const char * RegisterAllocator : : RegisterName ( int register_code ) const { <nl> if ( mode ( ) = = GENERAL_REGISTERS ) { <nl> - return data ( ) - > config ( ) - > general_register_name ( allocation_index ) ; <nl> + return data ( ) - > config ( ) - > GetGeneralRegisterName ( register_code ) ; <nl> } else { <nl> - return data ( ) - > config ( ) - > double_register_name ( allocation_index ) ; <nl> + return data ( ) - > config ( ) - > GetDoubleRegisterName ( register_code ) ; <nl> } <nl> } <nl> <nl> bool LinearScanAllocator : : TryAllocateFreeReg ( LiveRange * current ) { <nl> for ( auto cur_active : active_live_ranges ( ) ) { <nl> free_until_pos [ cur_active - > assigned_register ( ) ] = <nl> LifetimePosition : : GapFromInstructionIndex ( 0 ) ; <nl> + TRACE ( " Register % s is free until pos % d ( 1 ) \ n " , <nl> + RegisterName ( cur_active - > assigned_register ( ) ) , <nl> + LifetimePosition : : GapFromInstructionIndex ( 0 ) . value ( ) ) ; <nl> } <nl> <nl> for ( auto cur_inactive : inactive_live_ranges ( ) ) { <nl> bool LinearScanAllocator : : TryAllocateFreeReg ( LiveRange * current ) { <nl> if ( ! next_intersection . IsValid ( ) ) continue ; <nl> int cur_reg = cur_inactive - > assigned_register ( ) ; <nl> free_until_pos [ cur_reg ] = Min ( free_until_pos [ cur_reg ] , next_intersection ) ; <nl> + TRACE ( " Register % s is free until pos % d ( 2 ) \ n " , RegisterName ( cur_reg ) , <nl> + Min ( free_until_pos [ cur_reg ] , next_intersection ) . value ( ) ) ; <nl> } <nl> <nl> int hint_register ; <nl> bool LinearScanAllocator : : TryAllocateFreeReg ( LiveRange * current ) { <nl> } <nl> <nl> / / Find the register which stays free for the longest time . <nl> - int reg = 0 ; <nl> - for ( int i = 1 ; i < num_registers ( ) ; + + i ) { <nl> - if ( free_until_pos [ i ] > free_until_pos [ reg ] ) { <nl> - reg = i ; <nl> + int reg = allocatable_register_code ( 0 ) ; <nl> + for ( int i = 1 ; i < num_alloctable_registers ( ) ; + + i ) { <nl> + int code = allocatable_register_code ( i ) ; <nl> + if ( free_until_pos [ code ] > free_until_pos [ reg ] ) { <nl> + reg = code ; <nl> } <nl> } <nl> <nl> void LinearScanAllocator : : AllocateBlockedReg ( LiveRange * current ) { <nl> } <nl> } <nl> <nl> - int reg = 0 ; <nl> - for ( int i = 1 ; i < num_registers ( ) ; + + i ) { <nl> - if ( use_pos [ i ] > use_pos [ reg ] ) { <nl> - reg = i ; <nl> + int reg = allocatable_register_code ( 0 ) ; <nl> + for ( int i = 1 ; i < num_alloctable_registers ( ) ; + + i ) { <nl> + int code = allocatable_register_code ( i ) ; <nl> + if ( use_pos [ code ] > use_pos [ reg ] ) { <nl> + reg = code ; <nl> } <nl> } <nl> <nl> mmm a / src / compiler / register - allocator . h <nl> ppp b / src / compiler / register - allocator . h <nl> <nl> <nl> # include " src / compiler / instruction . h " <nl> # include " src / ostreams . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / zone - containers . h " <nl> <nl> namespace v8 { <nl> class UsePosition final : public ZoneObject { <nl> void set_next ( UsePosition * next ) { next_ = next ; } <nl> <nl> / / For hinting only . <nl> - void set_assigned_register ( int register_index ) { <nl> - flags_ = AssignedRegisterField : : update ( flags_ , register_index ) ; <nl> + void set_assigned_register ( int register_code ) { <nl> + flags_ = AssignedRegisterField : : update ( flags_ , register_code ) ; <nl> } <nl> <nl> UsePositionHintType hint_type ( ) const { <nl> return HintTypeField : : decode ( flags_ ) ; <nl> } <nl> bool HasHint ( ) const ; <nl> - bool HintRegister ( int * register_index ) const ; <nl> + bool HintRegister ( int * register_code ) const ; <nl> void ResolveHint ( UsePosition * use_pos ) ; <nl> bool IsResolved ( ) const { <nl> return hint_type ( ) ! = UsePositionHintType : : kUnresolved ; <nl> class RegisterAllocationData final : public ZoneObject { <nl> <nl> / / For hinting . <nl> int assigned_register ( ) const { return assigned_register_ ; } <nl> - void set_assigned_register ( int register_index ) { <nl> + void set_assigned_register ( int register_code ) { <nl> DCHECK_EQ ( assigned_register_ , kUnassignedRegister ) ; <nl> - assigned_register_ = register_index ; <nl> + assigned_register_ = register_code ; <nl> } <nl> void UnsetAssignedRegister ( ) { assigned_register_ = kUnassignedRegister ; } <nl> <nl> class RegisterAllocationData final : public ZoneObject { <nl> const char * const debug_name_ ; <nl> const RegisterConfiguration * const config_ ; <nl> PhiMap phi_map_ ; <nl> + ZoneVector < int > allocatable_codes_ ; <nl> + ZoneVector < int > allocatable_double_codes_ ; <nl> ZoneVector < BitVector * > live_in_sets_ ; <nl> ZoneVector < BitVector * > live_out_sets_ ; <nl> ZoneVector < TopLevelLiveRange * > live_ranges_ ; <nl> class RegisterAllocator : public ZoneObject { <nl> InstructionSequence * code ( ) const { return data ( ) - > code ( ) ; } <nl> RegisterKind mode ( ) const { return mode_ ; } <nl> int num_registers ( ) const { return num_registers_ ; } <nl> + int num_alloctable_registers ( ) const { return num_allocatable_registers_ ; } <nl> + int allocatable_register_code ( int allocatable_index ) const { <nl> + return allocatable_register_codes_ [ allocatable_index ] ; <nl> + } <nl> <nl> Zone * allocation_zone ( ) const { return data ( ) - > allocation_zone ( ) ; } <nl> <nl> class RegisterAllocator : public ZoneObject { <nl> RegisterAllocationData * const data_ ; <nl> const RegisterKind mode_ ; <nl> const int num_registers_ ; <nl> + int num_allocatable_registers_ ; <nl> + const int * allocatable_register_codes_ ; <nl> <nl> DISALLOW_COPY_AND_ASSIGN ( RegisterAllocator ) ; <nl> } ; <nl> deleted file mode 100644 <nl> index ebe6cfe23c3 . . 00000000000 <nl> mmm a / src / compiler / register - configuration . 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> - # include " src / compiler / register - configuration . h " <nl> - # include " src / globals . h " <nl> - # include " src / macro - assembler . h " <nl> - <nl> - namespace v8 { <nl> - namespace internal { <nl> - namespace compiler { <nl> - <nl> - namespace { <nl> - <nl> - STATIC_ASSERT ( RegisterConfiguration : : kMaxGeneralRegisters > = <nl> - Register : : kNumRegisters ) ; <nl> - STATIC_ASSERT ( RegisterConfiguration : : kMaxDoubleRegisters > = <nl> - DoubleRegister : : kMaxNumRegisters ) ; <nl> - <nl> - class ArchDefaultRegisterConfiguration : public RegisterConfiguration { <nl> - public : <nl> - ArchDefaultRegisterConfiguration ( ) <nl> - : RegisterConfiguration ( Register : : kMaxNumAllocatableRegisters , <nl> - # if V8_TARGET_ARCH_X87 <nl> - 1 , <nl> - 1 , <nl> - # else <nl> - DoubleRegister : : NumAllocatableRegisters ( ) , <nl> - DoubleRegister : : NumAllocatableAliasedRegisters ( ) , <nl> - # endif <nl> - general_register_name_table_ , <nl> - double_register_name_table_ ) { <nl> - DCHECK_EQ ( Register : : kMaxNumAllocatableRegisters , <nl> - Register : : NumAllocatableRegisters ( ) ) ; <nl> - for ( int i = 0 ; i < Register : : kMaxNumAllocatableRegisters ; + + i ) { <nl> - general_register_name_table_ [ i ] = Register : : AllocationIndexToString ( i ) ; <nl> - } <nl> - DCHECK_GE ( DoubleRegister : : kMaxNumAllocatableRegisters , <nl> - DoubleRegister : : NumAllocatableRegisters ( ) ) ; <nl> - for ( int i = 0 ; i < DoubleRegister : : NumAllocatableRegisters ( ) ; + + i ) { <nl> - double_register_name_table_ [ i ] = <nl> - DoubleRegister : : AllocationIndexToString ( i ) ; <nl> - } <nl> - } <nl> - <nl> - const char * <nl> - general_register_name_table_ [ Register : : kMaxNumAllocatableRegisters ] ; <nl> - const char * <nl> - double_register_name_table_ [ DoubleRegister : : kMaxNumAllocatableRegisters ] ; <nl> - } ; <nl> - <nl> - <nl> - static base : : LazyInstance < ArchDefaultRegisterConfiguration > : : type <nl> - kDefaultRegisterConfiguration = LAZY_INSTANCE_INITIALIZER ; <nl> - <nl> - } / / namespace <nl> - <nl> - <nl> - const RegisterConfiguration * RegisterConfiguration : : ArchDefault ( ) { <nl> - return & kDefaultRegisterConfiguration . Get ( ) ; <nl> - } <nl> - <nl> - RegisterConfiguration : : RegisterConfiguration ( <nl> - int num_general_registers , int num_double_registers , <nl> - int num_aliased_double_registers , const char * const * general_register_names , <nl> - const char * const * double_register_names ) <nl> - : num_general_registers_ ( num_general_registers ) , <nl> - num_double_registers_ ( num_double_registers ) , <nl> - num_aliased_double_registers_ ( num_aliased_double_registers ) , <nl> - general_register_names_ ( general_register_names ) , <nl> - double_register_names_ ( double_register_names ) { } <nl> - <nl> - <nl> - } / / namespace compiler <nl> - } / / namespace internal <nl> - } / / namespace v8 <nl> deleted file mode 100644 <nl> index f0d58735ba7 . . 00000000000 <nl> mmm a / src / compiler / register - configuration . h <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> - # ifndef V8_COMPILER_REGISTER_CONFIGURATION_H_ <nl> - # define V8_COMPILER_REGISTER_CONFIGURATION_H_ <nl> - <nl> - # include " src / base / macros . h " <nl> - <nl> - namespace v8 { <nl> - namespace internal { <nl> - namespace compiler { <nl> - <nl> - / / An architecture independent representation of the sets of registers available <nl> - / / for instruction creation . <nl> - class RegisterConfiguration { <nl> - public : <nl> - / / Architecture independent maxes . <nl> - static const int kMaxGeneralRegisters = 32 ; <nl> - static const int kMaxDoubleRegisters = 32 ; <nl> - <nl> - static const RegisterConfiguration * ArchDefault ( ) ; <nl> - <nl> - RegisterConfiguration ( int num_general_registers , int num_double_registers , <nl> - int num_aliased_double_registers , <nl> - const char * const * general_register_name , <nl> - const char * const * double_register_name ) ; <nl> - <nl> - int num_general_registers ( ) const { return num_general_registers_ ; } <nl> - int num_double_registers ( ) const { return num_double_registers_ ; } <nl> - int num_aliased_double_registers ( ) const { <nl> - return num_aliased_double_registers_ ; <nl> - } <nl> - <nl> - const char * general_register_name ( int offset ) const { <nl> - DCHECK ( offset > = 0 & & offset < kMaxGeneralRegisters ) ; <nl> - return general_register_names_ [ offset ] ; <nl> - } <nl> - const char * double_register_name ( int offset ) const { <nl> - DCHECK ( offset > = 0 & & offset < kMaxDoubleRegisters ) ; <nl> - return double_register_names_ [ offset ] ; <nl> - } <nl> - <nl> - private : <nl> - const int num_general_registers_ ; <nl> - const int num_double_registers_ ; <nl> - const int num_aliased_double_registers_ ; <nl> - const char * const * general_register_names_ ; <nl> - const char * const * double_register_names_ ; <nl> - } ; <nl> - <nl> - } / / namespace compiler <nl> - } / / namespace internal <nl> - } / / namespace v8 <nl> - <nl> - # endif / / V8_COMPILER_REGISTER_CONFIGURATION_H_ <nl> mmm a / src / deoptimizer . cc <nl> ppp b / src / deoptimizer . cc <nl> void Translation : : StoreBoolRegister ( Register reg ) { <nl> <nl> void Translation : : StoreDoubleRegister ( DoubleRegister reg ) { <nl> buffer_ - > Add ( DOUBLE_REGISTER , zone ( ) ) ; <nl> - buffer_ - > Add ( DoubleRegister : : ToAllocationIndex ( reg ) , zone ( ) ) ; <nl> + buffer_ - > Add ( reg . code ( ) , zone ( ) ) ; <nl> } <nl> <nl> <nl> TranslatedValue TranslatedState : : CreateNextTranslatedValue ( <nl> double value = registers - > GetDoubleRegister ( input_reg ) ; <nl> if ( trace_file ! = nullptr ) { <nl> PrintF ( trace_file , " % e ; % s ( bool ) " , value , <nl> - DoubleRegister : : AllocationIndexToString ( input_reg ) ) ; <nl> + DoubleRegister : : from_code ( input_reg ) . ToString ( ) ) ; <nl> } <nl> return TranslatedValue : : NewDouble ( this , value ) ; <nl> } <nl> mmm a / src / frames . cc <nl> ppp b / src / frames . cc <nl> <nl> # include " src / deoptimizer . h " <nl> # include " src / frames - inl . h " <nl> # include " src / full - codegen / full - codegen . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / safepoint - table . h " <nl> # include " src / scopeinfo . h " <nl> # include " src / string - stream . h " <nl> void StandardFrame : : IterateCompiledFrame ( ObjectVisitor * v ) const { <nl> if ( safepoint_entry . has_doubles ( ) ) { <nl> / / Number of doubles not known at snapshot time . <nl> DCHECK ( ! isolate ( ) - > serializer_enabled ( ) ) ; <nl> - parameters_base + = DoubleRegister : : NumAllocatableRegisters ( ) * <nl> - kDoubleSize / kPointerSize ; <nl> + parameters_base + = RegisterConfiguration : : ArchDefault ( ) <nl> + - > num_allocatable_double_registers ( ) * <nl> + kDoubleSize / kPointerSize ; <nl> } <nl> <nl> / / Visit the registers that contain pointers if any . <nl> mmm a / src / hydrogen . cc <nl> ppp b / src / hydrogen . cc <nl> void HTracer : : TraceLiveRange ( LiveRange * range , const char * type , <nl> int assigned_reg = op - > index ( ) ; <nl> if ( op - > IsDoubleRegister ( ) ) { <nl> trace_ . Add ( " \ " % s \ " " , <nl> - DoubleRegister : : AllocationIndexToString ( assigned_reg ) ) ; <nl> + DoubleRegister : : from_code ( assigned_reg ) . ToString ( ) ) ; <nl> } else { <nl> DCHECK ( op - > IsRegister ( ) ) ; <nl> - trace_ . Add ( " \ " % s \ " " , Register : : AllocationIndexToString ( assigned_reg ) ) ; <nl> + trace_ . Add ( " \ " % s \ " " , Register : : from_code ( assigned_reg ) . ToString ( ) ) ; <nl> } <nl> } else if ( range - > IsSpilled ( ) ) { <nl> LOperand * op = range - > TopLevel ( ) - > GetSpillOperand ( ) ; <nl> mmm a / src / ia32 / assembler - ia32 . h <nl> ppp b / src / ia32 / assembler - ia32 . h <nl> <nl> # include " src / assembler . h " <nl> # include " src / compiler . h " <nl> # include " src / isolate . h " <nl> + # include " src / utils . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> + # define GENERAL_REGISTERS ( V ) \ <nl> + V ( eax ) \ <nl> + V ( ecx ) \ <nl> + V ( edx ) \ <nl> + V ( ebx ) \ <nl> + V ( esp ) \ <nl> + V ( ebp ) \ <nl> + V ( esi ) \ <nl> + V ( edi ) <nl> + <nl> + # define ALLOCATABLE_GENERAL_REGISTERS ( V ) \ <nl> + V ( eax ) \ <nl> + V ( ecx ) \ <nl> + V ( edx ) \ <nl> + V ( ebx ) \ <nl> + V ( esi ) \ <nl> + V ( edi ) <nl> + <nl> + # define DOUBLE_REGISTERS ( V ) \ <nl> + V ( xmm0 ) \ <nl> + V ( xmm1 ) \ <nl> + V ( xmm2 ) \ <nl> + V ( xmm3 ) \ <nl> + V ( xmm4 ) \ <nl> + V ( xmm5 ) \ <nl> + V ( xmm6 ) \ <nl> + V ( xmm7 ) <nl> + <nl> + # define ALLOCATABLE_DOUBLE_REGISTERS ( V ) \ <nl> + V ( xmm1 ) \ <nl> + V ( xmm2 ) \ <nl> + V ( xmm3 ) \ <nl> + V ( xmm4 ) \ <nl> + V ( xmm5 ) \ <nl> + V ( xmm6 ) \ <nl> + V ( xmm7 ) <nl> + <nl> / / CPU Registers . <nl> / / <nl> / / 1 ) We would prefer to use an enum , but enum values are assignment - <nl> namespace internal { <nl> / / and best performance in optimized code . <nl> / / <nl> struct Register { <nl> - static const int kMaxNumAllocatableRegisters = 6 ; <nl> - static int NumAllocatableRegisters ( ) { <nl> - return kMaxNumAllocatableRegisters ; <nl> - } <nl> - static const int kNumRegisters = 8 ; <nl> - <nl> - static inline const char * AllocationIndexToString ( int index ) ; <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + GENERAL_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> <nl> - static inline int ToAllocationIndex ( Register reg ) ; <nl> - <nl> - static inline Register FromAllocationIndex ( int index ) ; <nl> + static const int kNumRegisters = Code : : kAfterLast ; <nl> <nl> static Register from_code ( int code ) { <nl> DCHECK ( code > = 0 ) ; <nl> DCHECK ( code < kNumRegisters ) ; <nl> - Register r = { code } ; <nl> + Register r = { code } ; <nl> return r ; <nl> } <nl> - bool is_valid ( ) const { return 0 < = code_ & & code_ < kNumRegisters ; } <nl> - bool is ( Register reg ) const { return code_ = = reg . code_ ; } <nl> - / / eax , ebx , ecx and edx are byte registers , the rest are not . <nl> - bool is_byte_register ( ) const { return code_ < = 3 ; } <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < kNumRegisters ; } <nl> + bool is ( Register reg ) const { return reg_code = = reg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> } <nl> <nl> + bool is_byte_register ( ) const { return reg_code < = 3 ; } <nl> + <nl> / / Unfortunately we can ' t make this private in a struct . <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> - const int kRegister_eax_Code = 0 ; <nl> - const int kRegister_ecx_Code = 1 ; <nl> - const int kRegister_edx_Code = 2 ; <nl> - const int kRegister_ebx_Code = 3 ; <nl> - const int kRegister_esp_Code = 4 ; <nl> - const int kRegister_ebp_Code = 5 ; <nl> - const int kRegister_esi_Code = 6 ; <nl> - const int kRegister_edi_Code = 7 ; <nl> - const int kRegister_no_reg_Code = - 1 ; <nl> - <nl> - const Register eax = { kRegister_eax_Code } ; <nl> - const Register ecx = { kRegister_ecx_Code } ; <nl> - const Register edx = { kRegister_edx_Code } ; <nl> - const Register ebx = { kRegister_ebx_Code } ; <nl> - const Register esp = { kRegister_esp_Code } ; <nl> - const Register ebp = { kRegister_ebp_Code } ; <nl> - const Register esi = { kRegister_esi_Code } ; <nl> - const Register edi = { kRegister_edi_Code } ; <nl> - const Register no_reg = { kRegister_no_reg_Code } ; <nl> - <nl> - <nl> - inline const char * Register : : AllocationIndexToString ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - / / This is the mapping of allocation indices to registers . <nl> - const char * const kNames [ ] = { " eax " , " ecx " , " edx " , " ebx " , " esi " , " edi " } ; <nl> - return kNames [ index ] ; <nl> - } <nl> - <nl> - <nl> - inline int Register : : ToAllocationIndex ( Register reg ) { <nl> - DCHECK ( reg . is_valid ( ) & & ! reg . is ( esp ) & & ! reg . is ( ebp ) ) ; <nl> - return ( reg . code ( ) > = 6 ) ? reg . code ( ) - 2 : reg . code ( ) ; <nl> - } <nl> - <nl> - <nl> - inline Register Register : : FromAllocationIndex ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - return ( index > = 4 ) ? from_code ( index + 2 ) : from_code ( index ) ; <nl> - } <nl> - <nl> <nl> - struct XMMRegister { <nl> - static const int kMaxNumAllocatableRegisters = 7 ; <nl> - static const int kMaxNumRegisters = 8 ; <nl> - static int NumAllocatableRegisters ( ) { <nl> - return kMaxNumAllocatableRegisters ; <nl> - } <nl> + # define DECLARE_REGISTER ( R ) const Register R = { Register : : kCode_ # # R } ; <nl> + GENERAL_REGISTERS ( DECLARE_REGISTER ) <nl> + # undef DECLARE_REGISTER <nl> + const Register no_reg = { Register : : kCode_no_reg } ; <nl> <nl> - / / TODO ( turbofan ) : Proper support for float32 . <nl> - static int NumAllocatableAliasedRegisters ( ) { <nl> - return NumAllocatableRegisters ( ) ; <nl> - } <nl> <nl> - static int ToAllocationIndex ( XMMRegister reg ) { <nl> - DCHECK ( reg . code ( ) ! = 0 ) ; <nl> - return reg . code ( ) - 1 ; <nl> - } <nl> + struct DoubleRegister { <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + DOUBLE_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> <nl> - static XMMRegister FromAllocationIndex ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - return from_code ( index + 1 ) ; <nl> - } <nl> + static const int kMaxNumRegisters = Code : : kAfterLast ; <nl> <nl> - static XMMRegister from_code ( int code ) { <nl> - XMMRegister result = { code } ; <nl> + static DoubleRegister from_code ( int code ) { <nl> + DoubleRegister result = { code } ; <nl> return result ; <nl> } <nl> <nl> - bool is_valid ( ) const { <nl> - return 0 < = code_ & & code_ < kMaxNumRegisters ; <nl> - } <nl> + bool IsAllocatable ( ) const ; <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < kMaxNumRegisters ; } <nl> <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> <nl> - bool is ( XMMRegister reg ) const { return code_ = = reg . code_ ; } <nl> + bool is ( DoubleRegister reg ) const { return reg_code = = reg . reg_code ; } <nl> <nl> - static const char * AllocationIndexToString ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - const char * const names [ ] = { <nl> - " xmm1 " , <nl> - " xmm2 " , <nl> - " xmm3 " , <nl> - " xmm4 " , <nl> - " xmm5 " , <nl> - " xmm6 " , <nl> - " xmm7 " <nl> - } ; <nl> - return names [ index ] ; <nl> - } <nl> + const char * ToString ( ) ; <nl> <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> + # define DECLARE_REGISTER ( R ) \ <nl> + const DoubleRegister R = { DoubleRegister : : kCode_ # # R } ; <nl> + DOUBLE_REGISTERS ( DECLARE_REGISTER ) <nl> + # undef DECLARE_REGISTER <nl> + const DoubleRegister no_double_reg = { DoubleRegister : : kCode_no_reg } ; <nl> <nl> - typedef XMMRegister DoubleRegister ; <nl> - <nl> - <nl> - const XMMRegister xmm0 = { 0 } ; <nl> - const XMMRegister xmm1 = { 1 } ; <nl> - const XMMRegister xmm2 = { 2 } ; <nl> - const XMMRegister xmm3 = { 3 } ; <nl> - const XMMRegister xmm4 = { 4 } ; <nl> - const XMMRegister xmm5 = { 5 } ; <nl> - const XMMRegister xmm6 = { 6 } ; <nl> - const XMMRegister xmm7 = { 7 } ; <nl> - const XMMRegister no_xmm_reg = { - 1 } ; <nl> - <nl> + typedef DoubleRegister XMMRegister ; <nl> <nl> enum Condition { <nl> / / any value < 0 is considered no_condition <nl> mmm a / src / ia32 / code - stubs - ia32 . h <nl> ppp b / src / ia32 / code - stubs - ia32 . h <nl> class RecordWriteStub : public PlatformCodeStub { <nl> Register GetRegThatIsNotEcxOr ( Register r1 , <nl> Register r2 , <nl> Register r3 ) { <nl> - for ( int i = 0 ; i < Register : : NumAllocatableRegisters ( ) ; i + + ) { <nl> - Register candidate = Register : : FromAllocationIndex ( i ) ; <nl> - if ( candidate . is ( ecx ) ) continue ; <nl> - if ( candidate . is ( r1 ) ) continue ; <nl> - if ( candidate . is ( r2 ) ) continue ; <nl> - if ( candidate . is ( r3 ) ) continue ; <nl> - return candidate ; <nl> + for ( int i = 0 ; i < Register : : kNumRegisters ; i + + ) { <nl> + Register candidate = Register : : from_code ( i ) ; <nl> + if ( candidate . IsAllocatable ( ) ) { <nl> + if ( candidate . is ( ecx ) ) continue ; <nl> + if ( candidate . is ( r1 ) ) continue ; <nl> + if ( candidate . is ( r2 ) ) continue ; <nl> + if ( candidate . is ( r3 ) ) continue ; <nl> + return candidate ; <nl> + } <nl> } <nl> UNREACHABLE ( ) ; <nl> return no_reg ; <nl> mmm a / src / ia32 / deoptimizer - ia32 . cc <nl> ppp b / src / ia32 / deoptimizer - ia32 . cc <nl> <nl> # include " src / deoptimizer . h " <nl> # include " src / full - codegen / full - codegen . h " <nl> # include " src / ia32 / frames - ia32 . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / safepoint - table . h " <nl> <nl> namespace v8 { <nl> void Deoptimizer : : FillInputFrame ( Address tos , JavaScriptFrame * frame ) { <nl> } <nl> input_ - > SetRegister ( esp . code ( ) , reinterpret_cast < intptr_t > ( frame - > sp ( ) ) ) ; <nl> input_ - > SetRegister ( ebp . code ( ) , reinterpret_cast < intptr_t > ( frame - > fp ( ) ) ) ; <nl> - for ( int i = 0 ; i < XMMRegister : : kMaxNumAllocatableRegisters ; i + + ) { <nl> + for ( int i = 0 ; i < XMMRegister : : kMaxNumRegisters ; i + + ) { <nl> input_ - > SetDoubleRegister ( i , 0 . 0 ) ; <nl> } <nl> <nl> void Deoptimizer : : SetPlatformCompiledStubRegisters ( <nl> <nl> <nl> void Deoptimizer : : CopyDoubleRegisters ( FrameDescription * output_frame ) { <nl> - for ( int i = 0 ; i < XMMRegister : : kMaxNumAllocatableRegisters ; + + i ) { <nl> + for ( int i = 0 ; i < XMMRegister : : kMaxNumRegisters ; + + i ) { <nl> double double_value = input_ - > GetDoubleRegister ( i ) ; <nl> output_frame - > SetDoubleRegister ( i , double_value ) ; <nl> } <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> / / Save all general purpose registers before messing with them . <nl> const int kNumberOfRegisters = Register : : kNumRegisters ; <nl> <nl> - const int kDoubleRegsSize = kDoubleSize * <nl> - XMMRegister : : kMaxNumAllocatableRegisters ; <nl> + const int kDoubleRegsSize = kDoubleSize * XMMRegister : : kMaxNumRegisters ; <nl> __ sub ( esp , Immediate ( kDoubleRegsSize ) ) ; <nl> - for ( int i = 0 ; i < XMMRegister : : kMaxNumAllocatableRegisters ; + + i ) { <nl> - XMMRegister xmm_reg = XMMRegister : : FromAllocationIndex ( i ) ; <nl> - int offset = i * kDoubleSize ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + XMMRegister xmm_reg = XMMRegister : : from_code ( code ) ; <nl> + int offset = code * kDoubleSize ; <nl> __ movsd ( Operand ( esp , offset ) , xmm_reg ) ; <nl> } <nl> <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> <nl> int double_regs_offset = FrameDescription : : double_registers_offset ( ) ; <nl> / / Fill in the double input registers . <nl> - for ( int i = 0 ; i < XMMRegister : : kMaxNumAllocatableRegisters ; + + i ) { <nl> - int dst_offset = i * kDoubleSize + double_regs_offset ; <nl> - int src_offset = i * kDoubleSize ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + int dst_offset = code * kDoubleSize + double_regs_offset ; <nl> + int src_offset = code * kDoubleSize ; <nl> __ movsd ( xmm0 , Operand ( esp , src_offset ) ) ; <nl> __ movsd ( Operand ( ebx , dst_offset ) , xmm0 ) ; <nl> } <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> __ j ( below , & outer_push_loop ) ; <nl> <nl> / / In case of a failed STUB , we have to restore the XMM registers . <nl> - for ( int i = 0 ; i < XMMRegister : : kMaxNumAllocatableRegisters ; + + i ) { <nl> - XMMRegister xmm_reg = XMMRegister : : FromAllocationIndex ( i ) ; <nl> - int src_offset = i * kDoubleSize + double_regs_offset ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + XMMRegister xmm_reg = XMMRegister : : from_code ( code ) ; <nl> + int src_offset = code * kDoubleSize + double_regs_offset ; <nl> __ movsd ( xmm_reg , Operand ( ebx , src_offset ) ) ; <nl> } <nl> <nl> mmm a / src / ia32 / lithium - codegen - ia32 . cc <nl> ppp b / src / ia32 / lithium - codegen - ia32 . cc <nl> void LCodeGen : : SaveCallerDoubles ( ) { <nl> BitVector : : Iterator save_iterator ( doubles ) ; <nl> while ( ! save_iterator . Done ( ) ) { <nl> __ movsd ( MemOperand ( esp , count * kDoubleSize ) , <nl> - XMMRegister : : FromAllocationIndex ( save_iterator . Current ( ) ) ) ; <nl> + XMMRegister : : from_code ( save_iterator . Current ( ) ) ) ; <nl> save_iterator . Advance ( ) ; <nl> count + + ; <nl> } <nl> void LCodeGen : : RestoreCallerDoubles ( ) { <nl> BitVector : : Iterator save_iterator ( doubles ) ; <nl> int count = 0 ; <nl> while ( ! save_iterator . Done ( ) ) { <nl> - __ movsd ( XMMRegister : : FromAllocationIndex ( save_iterator . Current ( ) ) , <nl> - MemOperand ( esp , count * kDoubleSize ) ) ; <nl> + __ movsd ( XMMRegister : : from_code ( save_iterator . Current ( ) ) , <nl> + MemOperand ( esp , count * kDoubleSize ) ) ; <nl> save_iterator . Advance ( ) ; <nl> count + + ; <nl> } <nl> bool LCodeGen : : GenerateSafepointTable ( ) { <nl> } <nl> <nl> <nl> - Register LCodeGen : : ToRegister ( int index ) const { <nl> - return Register : : FromAllocationIndex ( index ) ; <nl> + Register LCodeGen : : ToRegister ( int code ) const { <nl> + return Register : : from_code ( code ) ; <nl> } <nl> <nl> <nl> - XMMRegister LCodeGen : : ToDoubleRegister ( int index ) const { <nl> - return XMMRegister : : FromAllocationIndex ( index ) ; <nl> + XMMRegister LCodeGen : : ToDoubleRegister ( int code ) const { <nl> + return XMMRegister : : from_code ( code ) ; <nl> } <nl> <nl> <nl> mmm a / src / ia32 / lithium - gap - resolver - ia32 . cc <nl> ppp b / src / ia32 / lithium - gap - resolver - ia32 . cc <nl> <nl> <nl> # include " src / ia32 / lithium - codegen - ia32 . h " <nl> # include " src / ia32 / lithium - gap - resolver - ia32 . h " <nl> + # include " src / register - configuration . h " <nl> <nl> namespace v8 { <nl> namespace internal { <nl> int LGapResolver : : CountSourceUses ( LOperand * operand ) { <nl> <nl> <nl> Register LGapResolver : : GetFreeRegisterNot ( Register reg ) { <nl> - int skip_index = reg . is ( no_reg ) ? - 1 : Register : : ToAllocationIndex ( reg ) ; <nl> - for ( int i = 0 ; i < Register : : NumAllocatableRegisters ( ) ; + + i ) { <nl> - if ( source_uses_ [ i ] = = 0 & & destination_uses_ [ i ] > 0 & & i ! = skip_index ) { <nl> - return Register : : FromAllocationIndex ( i ) ; <nl> + int skip_index = reg . is ( no_reg ) ? - 1 : reg . code ( ) ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_general_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableGeneralCode ( i ) ; <nl> + if ( source_uses_ [ code ] = = 0 & & destination_uses_ [ code ] > 0 & & <nl> + code ! = skip_index ) { <nl> + return Register : : from_code ( code ) ; <nl> } <nl> } <nl> return no_reg ; <nl> Register LGapResolver : : GetFreeRegisterNot ( Register reg ) { <nl> bool LGapResolver : : HasBeenReset ( ) { <nl> if ( ! moves_ . is_empty ( ) ) return false ; <nl> if ( spilled_register_ > = 0 ) return false ; <nl> - <nl> - for ( int i = 0 ; i < Register : : NumAllocatableRegisters ( ) ; + + i ) { <nl> - if ( source_uses_ [ i ] ! = 0 ) return false ; <nl> - if ( destination_uses_ [ i ] ! = 0 ) return false ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_general_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableGeneralCode ( i ) ; <nl> + if ( source_uses_ [ code ] ! = 0 ) return false ; <nl> + if ( destination_uses_ [ code ] ! = 0 ) return false ; <nl> } <nl> return true ; <nl> } <nl> void LGapResolver : : Verify ( ) { <nl> <nl> void LGapResolver : : Finish ( ) { <nl> if ( spilled_register_ > = 0 ) { <nl> - __ pop ( Register : : FromAllocationIndex ( spilled_register_ ) ) ; <nl> + __ pop ( Register : : from_code ( spilled_register_ ) ) ; <nl> spilled_register_ = - 1 ; <nl> } <nl> moves_ . Rewind ( 0 ) ; <nl> void LGapResolver : : Finish ( ) { <nl> <nl> void LGapResolver : : EnsureRestored ( LOperand * operand ) { <nl> if ( operand - > IsRegister ( ) & & operand - > index ( ) = = spilled_register_ ) { <nl> - __ pop ( Register : : FromAllocationIndex ( spilled_register_ ) ) ; <nl> + __ pop ( Register : : from_code ( spilled_register_ ) ) ; <nl> spilled_register_ = - 1 ; <nl> } <nl> } <nl> void LGapResolver : : EnsureRestored ( LOperand * operand ) { <nl> Register LGapResolver : : EnsureTempRegister ( ) { <nl> / / 1 . We may have already spilled to create a temp register . <nl> if ( spilled_register_ > = 0 ) { <nl> - return Register : : FromAllocationIndex ( spilled_register_ ) ; <nl> + return Register : : from_code ( spilled_register_ ) ; <nl> } <nl> <nl> / / 2 . We may have a free register that we can use without spilling . <nl> Register LGapResolver : : EnsureTempRegister ( ) { <nl> <nl> / / 3 . Prefer to spill a register that is not used in any remaining move <nl> / / because it will not need to be restored until the end . <nl> - for ( int i = 0 ; i < Register : : NumAllocatableRegisters ( ) ; + + i ) { <nl> - if ( source_uses_ [ i ] = = 0 & & destination_uses_ [ i ] = = 0 ) { <nl> - Register scratch = Register : : FromAllocationIndex ( i ) ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_general_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableGeneralCode ( i ) ; <nl> + if ( source_uses_ [ code ] = = 0 & & destination_uses_ [ code ] = = 0 ) { <nl> + Register scratch = Register : : from_code ( code ) ; <nl> __ push ( scratch ) ; <nl> - spilled_register_ = i ; <nl> + spilled_register_ = code ; <nl> return scratch ; <nl> } <nl> } <nl> <nl> / / 4 . Use an arbitrary register . Register 0 is as arbitrary as any other . <nl> - Register scratch = Register : : FromAllocationIndex ( 0 ) ; <nl> + spilled_register_ = config - > GetAllocatableGeneralCode ( 0 ) ; <nl> + Register scratch = Register : : from_code ( spilled_register_ ) ; <nl> __ push ( scratch ) ; <nl> - spilled_register_ = 0 ; <nl> return scratch ; <nl> } <nl> <nl> mmm a / src / ia32 / lithium - gap - resolver - ia32 . h <nl> ppp b / src / ia32 / lithium - gap - resolver - ia32 . h <nl> class LGapResolver final BASE_EMBEDDED { <nl> ZoneList < LMoveOperands > moves_ ; <nl> <nl> / / Source and destination use counts for the general purpose registers . <nl> - int source_uses_ [ Register : : kMaxNumAllocatableRegisters ] ; <nl> - int destination_uses_ [ Register : : kMaxNumAllocatableRegisters ] ; <nl> + int source_uses_ [ Register : : kNumRegisters ] ; <nl> + int destination_uses_ [ DoubleRegister : : kMaxNumRegisters ] ; <nl> <nl> / / If we had to spill on demand , the currently spilled register ' s <nl> / / allocation index . <nl> mmm a / src / ia32 / lithium - ia32 . cc <nl> ppp b / src / ia32 / lithium - ia32 . cc <nl> LPlatformChunk * LChunkBuilder : : Build ( ) { <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( Register reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , <nl> - Register : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( XMMRegister reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , <nl> - XMMRegister : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) <nl> + LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / ia32 / macro - assembler - ia32 . h <nl> ppp b / src / ia32 / macro - assembler - ia32 . h <nl> namespace v8 { <nl> namespace internal { <nl> <nl> / / Give alias names to registers for calling conventions . <nl> - const Register kReturnRegister0 = { kRegister_eax_Code } ; <nl> - const Register kReturnRegister1 = { kRegister_edx_Code } ; <nl> - const Register kJSFunctionRegister = { kRegister_edi_Code } ; <nl> - const Register kContextRegister = { kRegister_esi_Code } ; <nl> - const Register kInterpreterAccumulatorRegister = { kRegister_eax_Code } ; <nl> - const Register kInterpreterRegisterFileRegister = { kRegister_edx_Code } ; <nl> - const Register kInterpreterBytecodeOffsetRegister = { kRegister_ecx_Code } ; <nl> - const Register kInterpreterBytecodeArrayRegister = { kRegister_edi_Code } ; <nl> - const Register kInterpreterDispatchTableRegister = { kRegister_ebx_Code } ; <nl> - const Register kRuntimeCallFunctionRegister = { kRegister_ebx_Code } ; <nl> - const Register kRuntimeCallArgCountRegister = { kRegister_eax_Code } ; <nl> + const Register kReturnRegister0 = { Register : : kCode_eax } ; <nl> + const Register kReturnRegister1 = { Register : : kCode_edx } ; <nl> + const Register kJSFunctionRegister = { Register : : kCode_edi } ; <nl> + const Register kContextRegister = { Register : : kCode_esi } ; <nl> + const Register kInterpreterAccumulatorRegister = { Register : : kCode_eax } ; <nl> + const Register kInterpreterRegisterFileRegister = { Register : : kCode_edx } ; <nl> + const Register kInterpreterBytecodeOffsetRegister = { Register : : kCode_ecx } ; <nl> + const Register kInterpreterBytecodeArrayRegister = { Register : : kCode_edi } ; <nl> + const Register kInterpreterDispatchTableRegister = { Register : : kCode_ebx } ; <nl> + const Register kRuntimeCallFunctionRegister = { Register : : kCode_ebx } ; <nl> + const Register kRuntimeCallArgCountRegister = { Register : : kCode_eax } ; <nl> <nl> / / Spill slots used by interpreter dispatch calling convention . <nl> const int kInterpreterContextSpillSlot = - 1 ; <nl> mmm a / src / lithium - allocator . cc <nl> ppp b / src / lithium - allocator . cc <nl> <nl> # include " src / hydrogen . h " <nl> # include " src / lithium - inl . h " <nl> # include " src / lithium - allocator - inl . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / string - stream . h " <nl> <nl> namespace v8 { <nl> void LAllocator : : AddInitialIntervals ( HBasicBlock * block , <nl> <nl> <nl> int LAllocator : : FixedDoubleLiveRangeID ( int index ) { <nl> - return - index - 1 - Register : : kMaxNumAllocatableRegisters ; <nl> + return - index - 1 - Register : : kNumRegisters ; <nl> } <nl> <nl> <nl> LOperand * LAllocator : : AllocateFixed ( LUnallocated * operand , <nl> <nl> <nl> LiveRange * LAllocator : : FixedLiveRangeFor ( int index ) { <nl> - DCHECK ( index < Register : : kMaxNumAllocatableRegisters ) ; <nl> + DCHECK ( index < Register : : kNumRegisters ) ; <nl> LiveRange * result = fixed_live_ranges_ [ index ] ; <nl> if ( result = = NULL ) { <nl> result = new ( zone ( ) ) LiveRange ( FixedLiveRangeID ( index ) , chunk ( ) - > zone ( ) ) ; <nl> LiveRange * LAllocator : : FixedLiveRangeFor ( int index ) { <nl> <nl> <nl> LiveRange * LAllocator : : FixedDoubleLiveRangeFor ( int index ) { <nl> - DCHECK ( index < DoubleRegister : : NumAllocatableRegisters ( ) ) ; <nl> + DCHECK ( index < DoubleRegister : : kMaxNumRegisters ) ; <nl> LiveRange * result = fixed_double_live_ranges_ [ index ] ; <nl> if ( result = = NULL ) { <nl> result = new ( zone ( ) ) LiveRange ( FixedDoubleLiveRangeID ( index ) , <nl> void LAllocator : : ProcessInstructions ( HBasicBlock * block , BitVector * live ) { <nl> } <nl> <nl> if ( instr - > ClobbersRegisters ( ) ) { <nl> - for ( int i = 0 ; i < Register : : kMaxNumAllocatableRegisters ; + + i ) { <nl> - if ( output = = NULL | | ! output - > IsRegister ( ) | | <nl> - output - > index ( ) ! = i ) { <nl> - LiveRange * range = FixedLiveRangeFor ( i ) ; <nl> - range - > AddUseInterval ( curr_position , <nl> - curr_position . InstructionEnd ( ) , <nl> - zone ( ) ) ; <nl> + for ( int i = 0 ; i < Register : : kNumRegisters ; + + i ) { <nl> + if ( Register : : from_code ( i ) . IsAllocatable ( ) ) { <nl> + if ( output = = NULL | | ! output - > IsRegister ( ) | | <nl> + output - > index ( ) ! = i ) { <nl> + LiveRange * range = FixedLiveRangeFor ( i ) ; <nl> + range - > AddUseInterval ( curr_position , <nl> + curr_position . InstructionEnd ( ) , zone ( ) ) ; <nl> + } <nl> } <nl> } <nl> } <nl> <nl> if ( instr - > ClobbersDoubleRegisters ( isolate ( ) ) ) { <nl> - for ( int i = 0 ; i < DoubleRegister : : NumAllocatableRegisters ( ) ; + + i ) { <nl> - if ( output = = NULL | | ! output - > IsDoubleRegister ( ) | | <nl> - output - > index ( ) ! = i ) { <nl> - LiveRange * range = FixedDoubleLiveRangeFor ( i ) ; <nl> - range - > AddUseInterval ( curr_position , <nl> - curr_position . InstructionEnd ( ) , <nl> - zone ( ) ) ; <nl> + for ( int i = 0 ; i < DoubleRegister : : kMaxNumRegisters ; + + i ) { <nl> + if ( DoubleRegister : : from_code ( i ) . IsAllocatable ( ) ) { <nl> + if ( output = = NULL | | ! output - > IsDoubleRegister ( ) | | <nl> + output - > index ( ) ! = i ) { <nl> + LiveRange * range = FixedDoubleLiveRangeFor ( i ) ; <nl> + range - > AddUseInterval ( curr_position , <nl> + curr_position . InstructionEnd ( ) , zone ( ) ) ; <nl> + } <nl> } <nl> } <nl> } <nl> bool LAllocator : : Allocate ( LChunk * chunk ) { <nl> DCHECK ( chunk_ = = NULL ) ; <nl> chunk_ = static_cast < LPlatformChunk * > ( chunk ) ; <nl> assigned_registers_ = <nl> - new ( chunk - > zone ( ) ) BitVector ( Register : : NumAllocatableRegisters ( ) , <nl> - chunk - > zone ( ) ) ; <nl> - assigned_double_registers_ = <nl> - new ( chunk - > zone ( ) ) BitVector ( DoubleRegister : : NumAllocatableRegisters ( ) , <nl> - chunk - > zone ( ) ) ; <nl> + new ( chunk - > zone ( ) ) BitVector ( Register : : kNumRegisters , chunk - > zone ( ) ) ; <nl> + assigned_double_registers_ = new ( chunk - > zone ( ) ) <nl> + BitVector ( DoubleRegister : : kMaxNumRegisters , chunk - > zone ( ) ) ; <nl> MeetRegisterConstraints ( ) ; <nl> if ( ! AllocationOk ( ) ) return false ; <nl> ResolvePhis ( ) ; <nl> void LAllocator : : PopulatePointerMaps ( ) { <nl> <nl> void LAllocator : : AllocateGeneralRegisters ( ) { <nl> LAllocatorPhase phase ( " L_Allocate general registers " , this ) ; <nl> - num_registers_ = Register : : NumAllocatableRegisters ( ) ; <nl> + num_registers_ = <nl> + RegisterConfiguration : : ArchDefault ( ) - > num_allocatable_general_registers ( ) ; <nl> + allocatable_register_codes_ = <nl> + RegisterConfiguration : : ArchDefault ( ) - > allocatable_general_codes ( ) ; <nl> mode_ = GENERAL_REGISTERS ; <nl> AllocateRegisters ( ) ; <nl> } <nl> void LAllocator : : AllocateGeneralRegisters ( ) { <nl> <nl> void LAllocator : : AllocateDoubleRegisters ( ) { <nl> LAllocatorPhase phase ( " L_Allocate double registers " , this ) ; <nl> - num_registers_ = DoubleRegister : : NumAllocatableRegisters ( ) ; <nl> + num_registers_ = <nl> + RegisterConfiguration : : ArchDefault ( ) - > num_allocatable_double_registers ( ) ; <nl> + allocatable_register_codes_ = <nl> + RegisterConfiguration : : ArchDefault ( ) - > allocatable_double_codes ( ) ; <nl> mode_ = DOUBLE_REGISTERS ; <nl> AllocateRegisters ( ) ; <nl> } <nl> void LAllocator : : AllocateRegisters ( ) { <nl> DCHECK ( inactive_live_ranges_ . is_empty ( ) ) ; <nl> <nl> if ( mode_ = = DOUBLE_REGISTERS ) { <nl> - for ( int i = 0 ; i < DoubleRegister : : NumAllocatableRegisters ( ) ; + + i ) { <nl> + for ( int i = 0 ; i < fixed_double_live_ranges_ . length ( ) ; + + i ) { <nl> LiveRange * current = fixed_double_live_ranges_ . at ( i ) ; <nl> if ( current ! = NULL ) { <nl> AddToInactive ( current ) ; <nl> void LAllocator : : AllocateRegisters ( ) { <nl> <nl> const char * LAllocator : : RegisterName ( int allocation_index ) { <nl> if ( mode_ = = GENERAL_REGISTERS ) { <nl> - return Register : : AllocationIndexToString ( allocation_index ) ; <nl> + return Register : : from_code ( allocation_index ) . ToString ( ) ; <nl> } else { <nl> - return DoubleRegister : : AllocationIndexToString ( allocation_index ) ; <nl> + return DoubleRegister : : from_code ( allocation_index ) . ToString ( ) ; <nl> } <nl> } <nl> <nl> void LAllocator : : InactiveToActive ( LiveRange * range ) { <nl> } <nl> <nl> <nl> - / / TryAllocateFreeReg and AllocateBlockedReg assume this <nl> - / / when allocating local arrays . <nl> - STATIC_ASSERT ( DoubleRegister : : kMaxNumAllocatableRegisters > = <nl> - Register : : kMaxNumAllocatableRegisters ) ; <nl> - <nl> - <nl> bool LAllocator : : TryAllocateFreeReg ( LiveRange * current ) { <nl> - LifetimePosition free_until_pos [ DoubleRegister : : kMaxNumAllocatableRegisters ] ; <nl> + DCHECK ( DoubleRegister : : kMaxNumRegisters > = Register : : kNumRegisters ) ; <nl> + <nl> + LifetimePosition free_until_pos [ DoubleRegister : : kMaxNumRegisters ] ; <nl> <nl> - for ( int i = 0 ; i < num_registers_ ; i + + ) { <nl> + for ( int i = 0 ; i < DoubleRegister : : kMaxNumRegisters ; i + + ) { <nl> free_until_pos [ i ] = LifetimePosition : : MaxPosition ( ) ; <nl> } <nl> <nl> bool LAllocator : : TryAllocateFreeReg ( LiveRange * current ) { <nl> } <nl> <nl> / / Find the register which stays free for the longest time . <nl> - int reg = 0 ; <nl> + int reg = allocatable_register_codes_ [ 0 ] ; <nl> for ( int i = 1 ; i < RegisterCount ( ) ; + + i ) { <nl> - if ( free_until_pos [ i ] . Value ( ) > free_until_pos [ reg ] . Value ( ) ) { <nl> - reg = i ; <nl> + int code = allocatable_register_codes_ [ i ] ; <nl> + if ( free_until_pos [ code ] . Value ( ) > free_until_pos [ reg ] . Value ( ) ) { <nl> + reg = code ; <nl> } <nl> } <nl> <nl> void LAllocator : : AllocateBlockedReg ( LiveRange * current ) { <nl> } <nl> <nl> <nl> - LifetimePosition use_pos [ DoubleRegister : : kMaxNumAllocatableRegisters ] ; <nl> - LifetimePosition block_pos [ DoubleRegister : : kMaxNumAllocatableRegisters ] ; <nl> + LifetimePosition use_pos [ DoubleRegister : : kMaxNumRegisters ] ; <nl> + LifetimePosition block_pos [ DoubleRegister : : kMaxNumRegisters ] ; <nl> <nl> - for ( int i = 0 ; i < num_registers_ ; i + + ) { <nl> + for ( int i = 0 ; i < DoubleRegister : : kMaxNumRegisters ; i + + ) { <nl> use_pos [ i ] = block_pos [ i ] = LifetimePosition : : MaxPosition ( ) ; <nl> } <nl> <nl> void LAllocator : : AllocateBlockedReg ( LiveRange * current ) { <nl> } <nl> } <nl> <nl> - int reg = 0 ; <nl> + int reg = allocatable_register_codes_ [ 0 ] ; <nl> for ( int i = 1 ; i < RegisterCount ( ) ; + + i ) { <nl> - if ( use_pos [ i ] . Value ( ) > use_pos [ reg ] . Value ( ) ) { <nl> - reg = i ; <nl> + int code = allocatable_register_codes_ [ i ] ; <nl> + if ( use_pos [ code ] . Value ( ) > use_pos [ reg ] . Value ( ) ) { <nl> + reg = code ; <nl> } <nl> } <nl> <nl> mmm a / src / lithium - allocator . h <nl> ppp b / src / lithium - allocator . h <nl> class LAllocator BASE_EMBEDDED { <nl> ZoneList < LiveRange * > live_ranges_ ; <nl> <nl> / / Lists of live ranges <nl> - EmbeddedVector < LiveRange * , Register : : kMaxNumAllocatableRegisters > <nl> - fixed_live_ranges_ ; <nl> - EmbeddedVector < LiveRange * , DoubleRegister : : kMaxNumAllocatableRegisters > <nl> + EmbeddedVector < LiveRange * , Register : : kNumRegisters > fixed_live_ranges_ ; <nl> + EmbeddedVector < LiveRange * , DoubleRegister : : kMaxNumRegisters > <nl> fixed_double_live_ranges_ ; <nl> ZoneList < LiveRange * > unhandled_live_ranges_ ; <nl> ZoneList < LiveRange * > active_live_ranges_ ; <nl> class LAllocator BASE_EMBEDDED { <nl> <nl> RegisterKind mode_ ; <nl> int num_registers_ ; <nl> + const int * allocatable_register_codes_ ; <nl> <nl> BitVector * assigned_registers_ ; <nl> BitVector * assigned_double_registers_ ; <nl> mmm a / src / lithium . cc <nl> ppp b / src / lithium . cc <nl> void LOperand : : PrintTo ( StringStream * stream ) { <nl> break ; <nl> case LUnallocated : : FIXED_REGISTER : { <nl> int reg_index = unalloc - > fixed_register_index ( ) ; <nl> - if ( reg_index < 0 | | <nl> - reg_index > = Register : : kMaxNumAllocatableRegisters ) { <nl> + if ( reg_index < 0 | | reg_index > = Register : : kNumRegisters ) { <nl> stream - > Add ( " ( = invalid_reg # % d ) " , reg_index ) ; <nl> } else { <nl> const char * register_name = <nl> - Register : : AllocationIndexToString ( reg_index ) ; <nl> + Register : : from_code ( reg_index ) . ToString ( ) ; <nl> stream - > Add ( " ( = % s ) " , register_name ) ; <nl> } <nl> break ; <nl> } <nl> case LUnallocated : : FIXED_DOUBLE_REGISTER : { <nl> int reg_index = unalloc - > fixed_register_index ( ) ; <nl> - if ( reg_index < 0 | | <nl> - reg_index > = DoubleRegister : : kMaxNumAllocatableRegisters ) { <nl> + if ( reg_index < 0 | | reg_index > = DoubleRegister : : kMaxNumRegisters ) { <nl> stream - > Add ( " ( = invalid_double_reg # % d ) " , reg_index ) ; <nl> } else { <nl> const char * double_register_name = <nl> - DoubleRegister : : AllocationIndexToString ( reg_index ) ; <nl> + DoubleRegister : : from_code ( reg_index ) . ToString ( ) ; <nl> stream - > Add ( " ( = % s ) " , double_register_name ) ; <nl> } <nl> break ; <nl> void LOperand : : PrintTo ( StringStream * stream ) { <nl> break ; <nl> case REGISTER : { <nl> int reg_index = index ( ) ; <nl> - if ( reg_index < 0 | | reg_index > = Register : : kMaxNumAllocatableRegisters ) { <nl> + if ( reg_index < 0 | | reg_index > = Register : : kNumRegisters ) { <nl> stream - > Add ( " ( = invalid_reg # % d | R ) " , reg_index ) ; <nl> } else { <nl> - stream - > Add ( " [ % s | R ] " , Register : : AllocationIndexToString ( reg_index ) ) ; <nl> + stream - > Add ( " [ % s | R ] " , Register : : from_code ( reg_index ) . ToString ( ) ) ; <nl> } <nl> break ; <nl> } <nl> case DOUBLE_REGISTER : { <nl> int reg_index = index ( ) ; <nl> - if ( reg_index < 0 | | <nl> - reg_index > = DoubleRegister : : kMaxNumAllocatableRegisters ) { <nl> + if ( reg_index < 0 | | reg_index > = DoubleRegister : : kMaxNumRegisters ) { <nl> stream - > Add ( " ( = invalid_double_reg # % d | R ) " , reg_index ) ; <nl> } else { <nl> - stream - > Add ( " [ % s | R ] " , <nl> - DoubleRegister : : AllocationIndexToString ( reg_index ) ) ; <nl> + stream - > Add ( " [ % s | R ] " , DoubleRegister : : from_code ( reg_index ) . ToString ( ) ) ; <nl> } <nl> break ; <nl> } <nl> mmm a / src / mips / assembler - mips - inl . h <nl> ppp b / src / mips / assembler - mips - inl . h <nl> bool Operand : : is_reg ( ) const { <nl> } <nl> <nl> <nl> - int Register : : NumAllocatableRegisters ( ) { <nl> - return kMaxNumAllocatableRegisters ; <nl> - } <nl> - <nl> - <nl> - int DoubleRegister : : NumRegisters ( ) { <nl> - return FPURegister : : kMaxNumRegisters ; <nl> - } <nl> - <nl> - <nl> - int DoubleRegister : : NumAllocatableRegisters ( ) { <nl> - return FPURegister : : kMaxNumAllocatableRegisters ; <nl> - } <nl> - <nl> - <nl> - int DoubleRegister : : NumAllocatableAliasedRegisters ( ) { <nl> - return NumAllocatableRegisters ( ) ; <nl> - } <nl> - <nl> - <nl> - int FPURegister : : ToAllocationIndex ( FPURegister reg ) { <nl> - DCHECK ( reg . code ( ) % 2 = = 0 ) ; <nl> - DCHECK ( reg . code ( ) / 2 < kMaxNumAllocatableRegisters ) ; <nl> - DCHECK ( reg . is_valid ( ) ) ; <nl> - DCHECK ( ! reg . is ( kDoubleRegZero ) ) ; <nl> - DCHECK ( ! reg . is ( kLithiumScratchDouble ) ) ; <nl> - return ( reg . code ( ) / 2 ) ; <nl> - } <nl> - <nl> - <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / RelocInfo . <nl> <nl> mmm a / src / mips / assembler - mips . cc <nl> ppp b / src / mips / assembler - mips . cc <nl> static unsigned CpuFeaturesImpliedByCompiler ( ) { <nl> } <nl> <nl> <nl> - const char * DoubleRegister : : AllocationIndexToString ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - const char * const names [ ] = { <nl> - " f0 " , <nl> - " f2 " , <nl> - " f4 " , <nl> - " f6 " , <nl> - " f8 " , <nl> - " f10 " , <nl> - " f12 " , <nl> - " f14 " , <nl> - " f16 " , <nl> - " f18 " , <nl> - " f20 " , <nl> - " f22 " , <nl> - " f24 " , <nl> - " f26 " <nl> - } ; <nl> - return names [ index ] ; <nl> - } <nl> - <nl> - <nl> void CpuFeatures : : ProbeImpl ( bool cross_compile ) { <nl> supported_ | = CpuFeaturesImpliedByCompiler ( ) ; <nl> <nl> MemOperand : : MemOperand ( Register rm , int32_t unit , int32_t multiplier , <nl> static const int kNegOffset = 0x00008000 ; <nl> / / addiu ( sp , sp , 4 ) aka Pop ( ) operation or part of Pop ( r ) <nl> / / operations as post - increment of sp . <nl> - const Instr kPopInstruction = ADDIU | ( kRegister_sp_Code < < kRsShift ) <nl> - | ( kRegister_sp_Code < < kRtShift ) <nl> - | ( kPointerSize & kImm16Mask ) ; / / NOLINT <nl> + const Instr kPopInstruction = ADDIU | ( Register : : kCode_sp < < kRsShift ) | <nl> + ( Register : : kCode_sp < < kRtShift ) | <nl> + ( kPointerSize & kImm16Mask ) ; / / NOLINT <nl> / / addiu ( sp , sp , - 4 ) part of Push ( r ) operation as pre - decrement of sp . <nl> - const Instr kPushInstruction = ADDIU | ( kRegister_sp_Code < < kRsShift ) <nl> - | ( kRegister_sp_Code < < kRtShift ) <nl> - | ( - kPointerSize & kImm16Mask ) ; / / NOLINT <nl> + const Instr kPushInstruction = ADDIU | ( Register : : kCode_sp < < kRsShift ) | <nl> + ( Register : : kCode_sp < < kRtShift ) | <nl> + ( - kPointerSize & kImm16Mask ) ; / / NOLINT <nl> / / sw ( r , MemOperand ( sp , 0 ) ) <nl> - const Instr kPushRegPattern = SW | ( kRegister_sp_Code < < kRsShift ) <nl> - | ( 0 & kImm16Mask ) ; / / NOLINT <nl> + const Instr kPushRegPattern = <nl> + SW | ( Register : : kCode_sp < < kRsShift ) | ( 0 & kImm16Mask ) ; / / NOLINT <nl> / / lw ( r , MemOperand ( sp , 0 ) ) <nl> - const Instr kPopRegPattern = LW | ( kRegister_sp_Code < < kRsShift ) <nl> - | ( 0 & kImm16Mask ) ; / / NOLINT <nl> + const Instr kPopRegPattern = <nl> + LW | ( Register : : kCode_sp < < kRsShift ) | ( 0 & kImm16Mask ) ; / / NOLINT <nl> <nl> - const Instr kLwRegFpOffsetPattern = LW | ( kRegister_fp_Code < < kRsShift ) <nl> - | ( 0 & kImm16Mask ) ; / / NOLINT <nl> + const Instr kLwRegFpOffsetPattern = <nl> + LW | ( Register : : kCode_fp < < kRsShift ) | ( 0 & kImm16Mask ) ; / / NOLINT <nl> <nl> - const Instr kSwRegFpOffsetPattern = SW | ( kRegister_fp_Code < < kRsShift ) <nl> - | ( 0 & kImm16Mask ) ; / / NOLINT <nl> + const Instr kSwRegFpOffsetPattern = <nl> + SW | ( Register : : kCode_fp < < kRsShift ) | ( 0 & kImm16Mask ) ; / / NOLINT <nl> <nl> - const Instr kLwRegFpNegOffsetPattern = LW | ( kRegister_fp_Code < < kRsShift ) <nl> - | ( kNegOffset & kImm16Mask ) ; / / NOLINT <nl> + const Instr kLwRegFpNegOffsetPattern = LW | ( Register : : kCode_fp < < kRsShift ) | <nl> + ( kNegOffset & kImm16Mask ) ; / / NOLINT <nl> <nl> - const Instr kSwRegFpNegOffsetPattern = SW | ( kRegister_fp_Code < < kRsShift ) <nl> - | ( kNegOffset & kImm16Mask ) ; / / NOLINT <nl> + const Instr kSwRegFpNegOffsetPattern = SW | ( Register : : kCode_fp < < kRsShift ) | <nl> + ( kNegOffset & kImm16Mask ) ; / / NOLINT <nl> / / A mask for the Rt register for push , pop , lw , sw instructions . <nl> const Instr kRtMask = kRtFieldMask ; <nl> const Instr kLwSwInstrTypeMask = 0xffe00000 ; <nl> void Assembler : : CodeTargetAlign ( ) { <nl> <nl> Register Assembler : : GetRtReg ( Instr instr ) { <nl> Register rt ; <nl> - rt . code_ = ( instr & kRtFieldMask ) > > kRtShift ; <nl> + rt . reg_code = ( instr & kRtFieldMask ) > > kRtShift ; <nl> return rt ; <nl> } <nl> <nl> <nl> Register Assembler : : GetRsReg ( Instr instr ) { <nl> Register rs ; <nl> - rs . code_ = ( instr & kRsFieldMask ) > > kRsShift ; <nl> + rs . reg_code = ( instr & kRsFieldMask ) > > kRsShift ; <nl> return rs ; <nl> } <nl> <nl> <nl> Register Assembler : : GetRdReg ( Instr instr ) { <nl> Register rd ; <nl> - rd . code_ = ( instr & kRdFieldMask ) > > kRdShift ; <nl> + rd . reg_code = ( instr & kRdFieldMask ) > > kRdShift ; <nl> return rd ; <nl> } <nl> <nl> void Assembler : : movn ( Register rd , Register rs , Register rt ) { <nl> <nl> void Assembler : : movt ( Register rd , Register rs , uint16_t cc ) { <nl> Register rt ; <nl> - rt . code_ = ( cc & 0x0007 ) < < 2 | 1 ; <nl> + rt . reg_code = ( cc & 0x0007 ) < < 2 | 1 ; <nl> GenInstrRegister ( SPECIAL , rs , rt , rd , 0 , MOVCI ) ; <nl> } <nl> <nl> <nl> void Assembler : : movf ( Register rd , Register rs , uint16_t cc ) { <nl> Register rt ; <nl> - rt . code_ = ( cc & 0x0007 ) < < 2 | 0 ; <nl> + rt . reg_code = ( cc & 0x0007 ) < < 2 | 0 ; <nl> GenInstrRegister ( SPECIAL , rs , rt , rd , 0 , MOVCI ) ; <nl> } <nl> <nl> void Assembler : : movz_d ( FPURegister fd , FPURegister fs , Register rt ) { <nl> void Assembler : : movt_s ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> DCHECK ( IsMipsArchVariant ( kMips32r2 ) ) ; <nl> FPURegister ft ; <nl> - ft . code_ = ( cc & 0x0007 ) < < 2 | 1 ; <nl> + ft . reg_code = ( cc & 0x0007 ) < < 2 | 1 ; <nl> GenInstrRegister ( COP1 , S , ft , fs , fd , MOVF ) ; <nl> } <nl> <nl> void Assembler : : movt_s ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> void Assembler : : movt_d ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> DCHECK ( IsMipsArchVariant ( kMips32r2 ) ) ; <nl> FPURegister ft ; <nl> - ft . code_ = ( cc & 0x0007 ) < < 2 | 1 ; <nl> + ft . reg_code = ( cc & 0x0007 ) < < 2 | 1 ; <nl> GenInstrRegister ( COP1 , D , ft , fs , fd , MOVF ) ; <nl> } <nl> <nl> void Assembler : : movt_d ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> void Assembler : : movf_s ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> DCHECK ( IsMipsArchVariant ( kMips32r2 ) ) ; <nl> FPURegister ft ; <nl> - ft . code_ = ( cc & 0x0007 ) < < 2 | 0 ; <nl> + ft . reg_code = ( cc & 0x0007 ) < < 2 | 0 ; <nl> GenInstrRegister ( COP1 , S , ft , fs , fd , MOVF ) ; <nl> } <nl> <nl> void Assembler : : movf_s ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> void Assembler : : movf_d ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> DCHECK ( IsMipsArchVariant ( kMips32r2 ) ) ; <nl> FPURegister ft ; <nl> - ft . code_ = ( cc & 0x0007 ) < < 2 | 0 ; <nl> + ft . reg_code = ( cc & 0x0007 ) < < 2 | 0 ; <nl> GenInstrRegister ( COP1 , D , ft , fs , fd , MOVF ) ; <nl> } <nl> <nl> mmm a / src / mips / assembler - mips . h <nl> ppp b / src / mips / assembler - mips . h <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> + / / clang - format off <nl> + # define GENERAL_REGISTERS ( V ) \ <nl> + V ( zero_reg ) V ( at ) V ( v0 ) V ( v1 ) V ( a0 ) V ( a1 ) V ( a2 ) V ( a3 ) \ <nl> + V ( t0 ) V ( t1 ) V ( t2 ) V ( t3 ) V ( t4 ) V ( t5 ) V ( t6 ) V ( t7 ) \ <nl> + V ( s0 ) V ( s1 ) V ( s2 ) V ( s3 ) V ( s4 ) V ( s5 ) V ( s6 ) V ( s7 ) V ( t8 ) V ( t9 ) \ <nl> + V ( k0 ) V ( k1 ) V ( gp ) V ( sp ) V ( fp ) V ( ra ) <nl> + <nl> + # define ALLOCATABLE_GENERAL_REGISTERS ( V ) \ <nl> + V ( v0 ) V ( v1 ) V ( a0 ) V ( a1 ) V ( a2 ) V ( a3 ) \ <nl> + V ( t0 ) V ( t1 ) V ( t2 ) V ( t3 ) V ( t4 ) V ( t5 ) V ( t6 ) V ( s7 ) <nl> + <nl> + # define DOUBLE_REGISTERS ( V ) \ <nl> + V ( f0 ) V ( f1 ) V ( f2 ) V ( f3 ) V ( f4 ) V ( f5 ) V ( f6 ) V ( f7 ) \ <nl> + V ( f8 ) V ( f9 ) V ( f10 ) V ( f11 ) V ( f12 ) V ( f13 ) V ( f14 ) V ( f15 ) \ <nl> + V ( f16 ) V ( f17 ) V ( f18 ) V ( f19 ) V ( f20 ) V ( f21 ) V ( f22 ) V ( f23 ) \ <nl> + V ( f24 ) V ( f25 ) V ( f26 ) V ( f27 ) V ( f28 ) V ( f29 ) V ( f30 ) V ( f31 ) <nl> + <nl> + # define ALLOCATABLE_DOUBLE_REGISTERS ( V ) \ <nl> + V ( f0 ) V ( f2 ) V ( f4 ) V ( f6 ) V ( f8 ) V ( f10 ) V ( f12 ) V ( f14 ) \ <nl> + V ( f16 ) V ( f18 ) V ( f20 ) V ( f22 ) V ( f24 ) V ( f26 ) <nl> + / / clang - format on <nl> + <nl> / / CPU Registers . <nl> / / <nl> / / 1 ) We would prefer to use an enum , but enum values are assignment - <nl> namespace internal { <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / Implementation of Register and FPURegister . <nl> <nl> - / / Core register . <nl> struct Register { <nl> - static const int kNumRegisters = v8 : : internal : : kNumRegisters ; <nl> - static const int kMaxNumAllocatableRegisters = 14 ; / / v0 through t6 and cp . <nl> - static const int kSizeInBytes = 4 ; <nl> static const int kCpRegister = 23 ; / / cp ( s7 ) is the 23rd register . <nl> <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + GENERAL_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> + <nl> + static const int kNumRegisters = Code : : kAfterLast ; <nl> + <nl> # if defined ( V8_TARGET_LITTLE_ENDIAN ) <nl> static const int kMantissaOffset = 0 ; <nl> static const int kExponentOffset = 4 ; <nl> struct Register { <nl> # error Unknown endianness <nl> # endif <nl> <nl> - inline static int NumAllocatableRegisters ( ) ; <nl> - <nl> - static int ToAllocationIndex ( Register reg ) { <nl> - DCHECK ( ( reg . code ( ) - 2 ) < ( kMaxNumAllocatableRegisters - 1 ) | | <nl> - reg . is ( from_code ( kCpRegister ) ) ) ; <nl> - return reg . is ( from_code ( kCpRegister ) ) ? <nl> - kMaxNumAllocatableRegisters - 1 : / / Return last index for ' cp ' . <nl> - reg . code ( ) - 2 ; / / zero_reg and ' at ' are skipped . <nl> - } <nl> - <nl> - static Register FromAllocationIndex ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - return index = = kMaxNumAllocatableRegisters - 1 ? <nl> - from_code ( kCpRegister ) : / / Last index is always the ' cp ' register . <nl> - from_code ( index + 2 ) ; / / zero_reg and ' at ' are skipped . <nl> - } <nl> - <nl> - static const char * AllocationIndexToString ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - const char * const names [ ] = { <nl> - " v0 " , <nl> - " v1 " , <nl> - " a0 " , <nl> - " a1 " , <nl> - " a2 " , <nl> - " a3 " , <nl> - " t0 " , <nl> - " t1 " , <nl> - " t2 " , <nl> - " t3 " , <nl> - " t4 " , <nl> - " t5 " , <nl> - " t6 " , <nl> - " s7 " , <nl> - } ; <nl> - return names [ index ] ; <nl> - } <nl> <nl> static Register from_code ( int code ) { <nl> - Register r = { code } ; <nl> + DCHECK ( code > = 0 ) ; <nl> + DCHECK ( code < kNumRegisters ) ; <nl> + Register r = { code } ; <nl> return r ; <nl> } <nl> - <nl> - bool is_valid ( ) const { return 0 < = code_ & & code_ < kNumRegisters ; } <nl> - bool is ( Register reg ) const { return code_ = = reg . code_ ; } <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < kNumRegisters ; } <nl> + bool is ( Register reg ) const { return reg_code = = reg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> } <nl> <nl> / / Unfortunately we can ' t make this private in a struct . <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> - # define REGISTER ( N , C ) \ <nl> - const int kRegister_ # # N # # _Code = C ; \ <nl> - const Register N = { C } <nl> - <nl> - REGISTER ( no_reg , - 1 ) ; <nl> - / / Always zero . <nl> - REGISTER ( zero_reg , 0 ) ; <nl> - / / at : Reserved for synthetic instructions . <nl> - REGISTER ( at , 1 ) ; <nl> - / / v0 , v1 : Used when returning multiple values from subroutines . <nl> - REGISTER ( v0 , 2 ) ; <nl> - REGISTER ( v1 , 3 ) ; <nl> - / / a0 - a4 : Used to pass non - FP parameters . <nl> - REGISTER ( a0 , 4 ) ; <nl> - REGISTER ( a1 , 5 ) ; <nl> - REGISTER ( a2 , 6 ) ; <nl> - REGISTER ( a3 , 7 ) ; <nl> - / / t0 - t9 : Can be used without reservation , act as temporary registers and are <nl> - / / allowed to be destroyed by subroutines . <nl> - REGISTER ( t0 , 8 ) ; <nl> - REGISTER ( t1 , 9 ) ; <nl> - REGISTER ( t2 , 10 ) ; <nl> - REGISTER ( t3 , 11 ) ; <nl> - REGISTER ( t4 , 12 ) ; <nl> - REGISTER ( t5 , 13 ) ; <nl> - REGISTER ( t6 , 14 ) ; <nl> - REGISTER ( t7 , 15 ) ; <nl> - / / s0 - s7 : Subroutine register variables . Subroutines that write to these <nl> - / / registers must restore their values before exiting so that the caller can <nl> - / / expect the values to be preserved . <nl> - REGISTER ( s0 , 16 ) ; <nl> - REGISTER ( s1 , 17 ) ; <nl> - REGISTER ( s2 , 18 ) ; <nl> - REGISTER ( s3 , 19 ) ; <nl> - REGISTER ( s4 , 20 ) ; <nl> - REGISTER ( s5 , 21 ) ; <nl> - REGISTER ( s6 , 22 ) ; <nl> - REGISTER ( s7 , 23 ) ; <nl> - REGISTER ( t8 , 24 ) ; <nl> - REGISTER ( t9 , 25 ) ; <nl> - / / k0 , k1 : Reserved for system calls and interrupt handlers . <nl> - REGISTER ( k0 , 26 ) ; <nl> - REGISTER ( k1 , 27 ) ; <nl> - / / gp : Reserved . <nl> - REGISTER ( gp , 28 ) ; <nl> - / / sp : Stack pointer . <nl> - REGISTER ( sp , 29 ) ; <nl> - / / fp : Frame pointer . <nl> - REGISTER ( fp , 30 ) ; <nl> - / / ra : Return address pointer . <nl> - REGISTER ( ra , 31 ) ; <nl> - <nl> - # undef REGISTER <nl> + / / s7 : context register <nl> + / / s3 : lithium scratch <nl> + / / s4 : lithium scratch2 <nl> + # define DECLARE_REGISTER ( R ) const Register R = { Register : : kCode_ # # R } ; <nl> + GENERAL_REGISTERS ( DECLARE_REGISTER ) <nl> + # undef DECLARE_REGISTER <nl> + const Register no_reg = { Register : : kCode_no_reg } ; <nl> <nl> <nl> int ToNumber ( Register reg ) ; <nl> int ToNumber ( Register reg ) ; <nl> Register ToRegister ( int num ) ; <nl> <nl> / / Coprocessor register . <nl> - struct FPURegister { <nl> - static const int kMaxNumRegisters = v8 : : internal : : kNumFPURegisters ; <nl> - <nl> - / / TODO ( plind ) : Warning , inconsistent numbering here . kNumFPURegisters refers <nl> - / / to number of 32 - bit FPU regs , but kNumAllocatableRegisters refers to <nl> - / / number of Double regs ( 64 - bit regs , or FPU - reg - pairs ) . <nl> + struct DoubleRegister { <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + DOUBLE_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> <nl> - / / A few double registers are reserved : one as a scratch register and one to <nl> - / / hold 0 . 0 . <nl> - / / f28 : 0 . 0 <nl> - / / f30 : scratch register . <nl> - static const int kNumReservedRegisters = 2 ; <nl> - static const int kMaxNumAllocatableRegisters = kMaxNumRegisters / 2 - <nl> - kNumReservedRegisters ; <nl> + static const int kMaxNumRegisters = Code : : kAfterLast ; <nl> <nl> inline static int NumRegisters ( ) ; <nl> - inline static int NumAllocatableRegisters ( ) ; <nl> - <nl> - / / TODO ( turbofan ) : Proper support for float32 . <nl> - inline static int NumAllocatableAliasedRegisters ( ) ; <nl> <nl> - inline static int ToAllocationIndex ( FPURegister reg ) ; <nl> - static const char * AllocationIndexToString ( int index ) ; <nl> - <nl> - static FPURegister FromAllocationIndex ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - return from_code ( index * 2 ) ; <nl> - } <nl> - <nl> - static FPURegister from_code ( int code ) { <nl> - FPURegister r = { code } ; <nl> - return r ; <nl> - } <nl> + / / TODO ( plind ) : Warning , inconsistent numbering here . kNumFPURegisters refers <nl> + / / to number of 32 - bit FPU regs , but kNumAllocatableRegisters refers to <nl> + / / number of Double regs ( 64 - bit regs , or FPU - reg - pairs ) . <nl> <nl> - bool is_valid ( ) const { return 0 < = code_ & & code_ < kMaxNumRegisters ; } <nl> - bool is ( FPURegister creg ) const { return code_ = = creg . code_ ; } <nl> - FPURegister low ( ) const { <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < kMaxNumRegisters ; } <nl> + bool is ( DoubleRegister reg ) const { return reg_code = = reg . reg_code ; } <nl> + DoubleRegister low ( ) const { <nl> / / Find low reg of a Double - reg pair , which is the reg itself . <nl> - DCHECK ( code_ % 2 = = 0 ) ; / / Specified Double reg must be even . <nl> - FPURegister reg ; <nl> - reg . code_ = code_ ; <nl> + DCHECK ( reg_code % 2 = = 0 ) ; / / Specified Double reg must be even . <nl> + DoubleRegister reg ; <nl> + reg . reg_code = reg_code ; <nl> DCHECK ( reg . is_valid ( ) ) ; <nl> return reg ; <nl> } <nl> - FPURegister high ( ) const { <nl> + DoubleRegister high ( ) const { <nl> / / Find high reg of a Doubel - reg pair , which is reg + 1 . <nl> - DCHECK ( code_ % 2 = = 0 ) ; / / Specified Double reg must be even . <nl> - FPURegister reg ; <nl> - reg . code_ = code_ + 1 ; <nl> + DCHECK ( reg_code % 2 = = 0 ) ; / / Specified Double reg must be even . <nl> + DoubleRegister reg ; <nl> + reg . reg_code = reg_code + 1 ; <nl> DCHECK ( reg . is_valid ( ) ) ; <nl> return reg ; <nl> } <nl> <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> + } <nl> + <nl> + static DoubleRegister from_code ( int code ) { <nl> + DoubleRegister r = { code } ; <nl> + return r ; <nl> } <nl> void setcode ( int f ) { <nl> - code_ = f ; <nl> + reg_code = f ; <nl> DCHECK ( is_valid ( ) ) ; <nl> } <nl> / / Unfortunately we can ' t make this private in a struct . <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> + / / A few double registers are reserved : one as a scratch register and one to <nl> + / / hold 0 . 0 . <nl> + / / f28 : 0 . 0 <nl> + / / f30 : scratch register . <nl> + <nl> / / V8 now supports the O32 ABI , and the FPU Registers are organized as 32 <nl> / / 32 - bit registers , f0 through f31 . When used as ' double ' they are used <nl> / / in pairs , starting with the even numbered register . So a double operation <nl> struct FPURegister { <nl> / / but it is not in common use . Someday we will want to support this in v8 . ) <nl> <nl> / / For O32 ABI , Floats and Doubles refer to same set of 32 32 - bit registers . <nl> - typedef FPURegister DoubleRegister ; <nl> - typedef FPURegister FloatRegister ; <nl> - <nl> - const FPURegister no_freg = { - 1 } ; <nl> - <nl> - const FPURegister f0 = { 0 } ; / / Return value in hard float mode . <nl> - const FPURegister f1 = { 1 } ; <nl> - const FPURegister f2 = { 2 } ; <nl> - const FPURegister f3 = { 3 } ; <nl> - const FPURegister f4 = { 4 } ; <nl> - const FPURegister f5 = { 5 } ; <nl> - const FPURegister f6 = { 6 } ; <nl> - const FPURegister f7 = { 7 } ; <nl> - const FPURegister f8 = { 8 } ; <nl> - const FPURegister f9 = { 9 } ; <nl> - const FPURegister f10 = { 10 } ; <nl> - const FPURegister f11 = { 11 } ; <nl> - const FPURegister f12 = { 12 } ; / / Arg 0 in hard float mode . <nl> - const FPURegister f13 = { 13 } ; <nl> - const FPURegister f14 = { 14 } ; / / Arg 1 in hard float mode . <nl> - const FPURegister f15 = { 15 } ; <nl> - const FPURegister f16 = { 16 } ; <nl> - const FPURegister f17 = { 17 } ; <nl> - const FPURegister f18 = { 18 } ; <nl> - const FPURegister f19 = { 19 } ; <nl> - const FPURegister f20 = { 20 } ; <nl> - const FPURegister f21 = { 21 } ; <nl> - const FPURegister f22 = { 22 } ; <nl> - const FPURegister f23 = { 23 } ; <nl> - const FPURegister f24 = { 24 } ; <nl> - const FPURegister f25 = { 25 } ; <nl> - const FPURegister f26 = { 26 } ; <nl> - const FPURegister f27 = { 27 } ; <nl> - const FPURegister f28 = { 28 } ; <nl> - const FPURegister f29 = { 29 } ; <nl> - const FPURegister f30 = { 30 } ; <nl> - const FPURegister f31 = { 31 } ; <nl> + typedef DoubleRegister FPURegister ; <nl> + typedef DoubleRegister FloatRegister ; <nl> + <nl> + const DoubleRegister no_freg = { - 1 } ; <nl> + <nl> + const DoubleRegister f0 = { 0 } ; / / Return value in hard float mode . <nl> + const DoubleRegister f1 = { 1 } ; <nl> + const DoubleRegister f2 = { 2 } ; <nl> + const DoubleRegister f3 = { 3 } ; <nl> + const DoubleRegister f4 = { 4 } ; <nl> + const DoubleRegister f5 = { 5 } ; <nl> + const DoubleRegister f6 = { 6 } ; <nl> + const DoubleRegister f7 = { 7 } ; <nl> + const DoubleRegister f8 = { 8 } ; <nl> + const DoubleRegister f9 = { 9 } ; <nl> + const DoubleRegister f10 = { 10 } ; <nl> + const DoubleRegister f11 = { 11 } ; <nl> + const DoubleRegister f12 = { 12 } ; / / Arg 0 in hard float mode . <nl> + const DoubleRegister f13 = { 13 } ; <nl> + const DoubleRegister f14 = { 14 } ; / / Arg 1 in hard float mode . <nl> + const DoubleRegister f15 = { 15 } ; <nl> + const DoubleRegister f16 = { 16 } ; <nl> + const DoubleRegister f17 = { 17 } ; <nl> + const DoubleRegister f18 = { 18 } ; <nl> + const DoubleRegister f19 = { 19 } ; <nl> + const DoubleRegister f20 = { 20 } ; <nl> + const DoubleRegister f21 = { 21 } ; <nl> + const DoubleRegister f22 = { 22 } ; <nl> + const DoubleRegister f23 = { 23 } ; <nl> + const DoubleRegister f24 = { 24 } ; <nl> + const DoubleRegister f25 = { 25 } ; <nl> + const DoubleRegister f26 = { 26 } ; <nl> + const DoubleRegister f27 = { 27 } ; <nl> + const DoubleRegister f28 = { 28 } ; <nl> + const DoubleRegister f29 = { 29 } ; <nl> + const DoubleRegister f30 = { 30 } ; <nl> + const DoubleRegister f31 = { 31 } ; <nl> <nl> / / Register aliases . <nl> / / cp is assumed to be a callee saved register . <nl> const FPURegister f31 = { 31 } ; <nl> / / FPU ( coprocessor 1 ) control registers . <nl> / / Currently only FCSR ( # 31 ) is implemented . <nl> struct FPUControlRegister { <nl> - bool is_valid ( ) const { return code_ = = kFCSRRegister ; } <nl> - bool is ( FPUControlRegister creg ) const { return code_ = = creg . code_ ; } <nl> + bool is_valid ( ) const { return reg_code = = kFCSRRegister ; } <nl> + bool is ( FPUControlRegister creg ) const { return reg_code = = creg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> } <nl> void setcode ( int f ) { <nl> - code_ = f ; <nl> + reg_code = f ; <nl> DCHECK ( is_valid ( ) ) ; <nl> } <nl> / / Unfortunately we can ' t make this private in a struct . <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> const FPUControlRegister no_fpucreg = { kInvalidFPUControlRegister } ; <nl> mmm a / src / mips / deoptimizer - mips . cc <nl> ppp b / src / mips / deoptimizer - mips . cc <nl> <nl> # include " src / codegen . h " <nl> # include " src / deoptimizer . h " <nl> # include " src / full - codegen / full - codegen . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / safepoint - table . h " <nl> <nl> namespace v8 { <nl> void Deoptimizer : : FillInputFrame ( Address tos , JavaScriptFrame * frame ) { <nl> } <nl> input_ - > SetRegister ( sp . code ( ) , reinterpret_cast < intptr_t > ( frame - > sp ( ) ) ) ; <nl> input_ - > SetRegister ( fp . code ( ) , reinterpret_cast < intptr_t > ( frame - > fp ( ) ) ) ; <nl> - for ( int i = 0 ; i < DoubleRegister : : NumAllocatableRegisters ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < DoubleRegister : : kMaxNumRegisters ; i + + ) { <nl> input_ - > SetDoubleRegister ( i , 0 . 0 ) ; <nl> } <nl> <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> RegList restored_regs = kJSCallerSaved | kCalleeSaved ; <nl> RegList saved_regs = restored_regs | sp . bit ( ) | ra . bit ( ) ; <nl> <nl> - const int kDoubleRegsSize = <nl> - kDoubleSize * FPURegister : : kMaxNumAllocatableRegisters ; <nl> + const int kDoubleRegsSize = kDoubleSize * DoubleRegister : : kMaxNumRegisters ; <nl> <nl> / / Save all FPU registers before messing with them . <nl> __ Subu ( sp , sp , Operand ( kDoubleRegsSize ) ) ; <nl> - for ( int i = 0 ; i < FPURegister : : kMaxNumAllocatableRegisters ; + + i ) { <nl> - FPURegister fpu_reg = FPURegister : : FromAllocationIndex ( i ) ; <nl> - int offset = i * kDoubleSize ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + const DoubleRegister fpu_reg = DoubleRegister : : from_code ( code ) ; <nl> + int offset = code * kDoubleSize ; <nl> __ sdc1 ( fpu_reg , MemOperand ( sp , offset ) ) ; <nl> } <nl> <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> int double_regs_offset = FrameDescription : : double_registers_offset ( ) ; <nl> / / Copy FPU registers to <nl> / / double_registers_ [ DoubleRegister : : kNumAllocatableRegisters ] <nl> - for ( int i = 0 ; i < FPURegister : : NumAllocatableRegisters ( ) ; + + i ) { <nl> - int dst_offset = i * kDoubleSize + double_regs_offset ; <nl> - int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + int dst_offset = code * kDoubleSize + double_regs_offset ; <nl> + int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize ; <nl> __ ldc1 ( f0 , MemOperand ( sp , src_offset ) ) ; <nl> __ sdc1 ( f0 , MemOperand ( a1 , dst_offset ) ) ; <nl> } <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> __ BranchShort ( & outer_push_loop , lt , t0 , Operand ( a1 ) ) ; <nl> <nl> __ lw ( a1 , MemOperand ( a0 , Deoptimizer : : input_offset ( ) ) ) ; <nl> - for ( int i = 0 ; i < FPURegister : : kMaxNumAllocatableRegisters ; + + i ) { <nl> - const FPURegister fpu_reg = FPURegister : : FromAllocationIndex ( i ) ; <nl> - int src_offset = i * kDoubleSize + double_regs_offset ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + const DoubleRegister fpu_reg = DoubleRegister : : from_code ( code ) ; <nl> + int src_offset = code * kDoubleSize + double_regs_offset ; <nl> __ ldc1 ( fpu_reg , MemOperand ( a1 , src_offset ) ) ; <nl> } <nl> <nl> mmm a / src / mips / lithium - codegen - mips . cc <nl> ppp b / src / mips / lithium - codegen - mips . cc <nl> void LCodeGen : : SaveCallerDoubles ( ) { <nl> BitVector * doubles = chunk ( ) - > allocated_double_registers ( ) ; <nl> BitVector : : Iterator save_iterator ( doubles ) ; <nl> while ( ! save_iterator . Done ( ) ) { <nl> - __ sdc1 ( DoubleRegister : : FromAllocationIndex ( save_iterator . Current ( ) ) , <nl> + __ sdc1 ( DoubleRegister : : from_code ( save_iterator . Current ( ) ) , <nl> MemOperand ( sp , count * kDoubleSize ) ) ; <nl> save_iterator . Advance ( ) ; <nl> count + + ; <nl> void LCodeGen : : RestoreCallerDoubles ( ) { <nl> BitVector : : Iterator save_iterator ( doubles ) ; <nl> int count = 0 ; <nl> while ( ! save_iterator . Done ( ) ) { <nl> - __ ldc1 ( DoubleRegister : : FromAllocationIndex ( save_iterator . Current ( ) ) , <nl> + __ ldc1 ( DoubleRegister : : from_code ( save_iterator . Current ( ) ) , <nl> MemOperand ( sp , count * kDoubleSize ) ) ; <nl> save_iterator . Advance ( ) ; <nl> count + + ; <nl> bool LCodeGen : : GenerateSafepointTable ( ) { <nl> <nl> <nl> Register LCodeGen : : ToRegister ( int index ) const { <nl> - return Register : : FromAllocationIndex ( index ) ; <nl> + return Register : : from_code ( index ) ; <nl> } <nl> <nl> <nl> DoubleRegister LCodeGen : : ToDoubleRegister ( int index ) const { <nl> - return DoubleRegister : : FromAllocationIndex ( index ) ; <nl> + return DoubleRegister : : from_code ( index ) ; <nl> } <nl> <nl> <nl> mmm a / src / mips / lithium - mips . cc <nl> ppp b / src / mips / lithium - mips . cc <nl> LPlatformChunk * LChunkBuilder : : Build ( ) { <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( Register reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , <nl> - Register : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( DoubleRegister reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , <nl> - DoubleRegister : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) <nl> + LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / mips / macro - assembler - mips . cc <nl> ppp b / src / mips / macro - assembler - mips . cc <nl> <nl> # include " src / cpu - profiler . h " <nl> # include " src / debug / debug . h " <nl> # include " src / mips / macro - assembler - mips . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / runtime / runtime . h " <nl> <nl> namespace v8 { <nl> MemOperand MacroAssembler : : SafepointRegisterSlot ( Register reg ) { <nl> MemOperand MacroAssembler : : SafepointRegistersAndDoublesSlot ( Register reg ) { <nl> UNIMPLEMENTED_MIPS ( ) ; <nl> / / General purpose registers are pushed last on the stack . <nl> - int doubles_size = FPURegister : : NumAllocatableRegisters ( ) * kDoubleSize ; <nl> + int doubles_size = DoubleRegister : : kMaxNumRegisters * kDoubleSize ; <nl> int register_offset = SafepointRegisterStackIndex ( reg . code ( ) ) * kPointerSize ; <nl> return MemOperand ( sp , doubles_size + register_offset ) ; <nl> } <nl> void MacroAssembler : : CopyFields ( Register dst , <nl> / / Find a temp register in temps list . <nl> for ( int i = 0 ; i < kNumRegisters ; i + + ) { <nl> if ( ( temps & ( 1 < < i ) ) ! = 0 ) { <nl> - tmp . code_ = i ; <nl> + tmp . reg_code = i ; <nl> break ; <nl> } <nl> } <nl> Register GetRegisterThatIsNotOneOf ( Register reg1 , <nl> if ( reg5 . is_valid ( ) ) regs | = reg5 . bit ( ) ; <nl> if ( reg6 . is_valid ( ) ) regs | = reg6 . bit ( ) ; <nl> <nl> - for ( int i = 0 ; i < Register : : NumAllocatableRegisters ( ) ; i + + ) { <nl> - Register candidate = Register : : FromAllocationIndex ( i ) ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_general_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableGeneralCode ( i ) ; <nl> + Register candidate = Register : : from_code ( code ) ; <nl> if ( regs & candidate . bit ( ) ) continue ; <nl> return candidate ; <nl> } <nl> mmm a / src / mips / macro - assembler - mips . h <nl> ppp b / src / mips / macro - assembler - mips . h <nl> namespace v8 { <nl> namespace internal { <nl> <nl> / / Give alias names to registers for calling conventions . <nl> - const Register kReturnRegister0 = { kRegister_v0_Code } ; <nl> - const Register kReturnRegister1 = { kRegister_v1_Code } ; <nl> - const Register kJSFunctionRegister = { kRegister_a1_Code } ; <nl> + const Register kReturnRegister0 = { Register : : kCode_v0 } ; <nl> + const Register kReturnRegister1 = { Register : : kCode_v1 } ; <nl> + const Register kJSFunctionRegister = { Register : : kCode_a1 } ; <nl> const Register kContextRegister = { Register : : kCpRegister } ; <nl> - const Register kInterpreterAccumulatorRegister = { kRegister_v0_Code } ; <nl> - const Register kInterpreterRegisterFileRegister = { kRegister_t3_Code } ; <nl> - const Register kInterpreterBytecodeOffsetRegister = { kRegister_t4_Code } ; <nl> - const Register kInterpreterBytecodeArrayRegister = { kRegister_t5_Code } ; <nl> - const Register kInterpreterDispatchTableRegister = { kRegister_t6_Code } ; <nl> - const Register kRuntimeCallFunctionRegister = { kRegister_a1_Code } ; <nl> - const Register kRuntimeCallArgCountRegister = { kRegister_a0_Code } ; <nl> + const Register kInterpreterAccumulatorRegister = { Register : : kCode_v0 } ; <nl> + const Register kInterpreterRegisterFileRegister = { Register : : kCode_t3 } ; <nl> + const Register kInterpreterBytecodeOffsetRegister = { Register : : kCode_t4 } ; <nl> + const Register kInterpreterBytecodeArrayRegister = { Register : : kCode_t5 } ; <nl> + const Register kInterpreterDispatchTableRegister = { Register : : kCode_t6 } ; <nl> + const Register kRuntimeCallFunctionRegister = { Register : : kCode_a1 } ; <nl> + const Register kRuntimeCallArgCountRegister = { Register : : kCode_a0 } ; <nl> <nl> / / Forward declaration . <nl> class JumpTarget ; <nl> mmm a / src / mips64 / assembler - mips64 - inl . h <nl> ppp b / src / mips64 / assembler - mips64 - inl . h <nl> bool Operand : : is_reg ( ) const { <nl> } <nl> <nl> <nl> - int Register : : NumAllocatableRegisters ( ) { <nl> - return kMaxNumAllocatableRegisters ; <nl> - } <nl> - <nl> - <nl> - int DoubleRegister : : NumRegisters ( ) { <nl> - return FPURegister : : kMaxNumRegisters ; <nl> - } <nl> - <nl> - <nl> - int DoubleRegister : : NumAllocatableRegisters ( ) { <nl> - return FPURegister : : kMaxNumAllocatableRegisters ; <nl> - } <nl> - <nl> - <nl> - int DoubleRegister : : NumAllocatableAliasedRegisters ( ) { <nl> - return NumAllocatableRegisters ( ) ; <nl> - } <nl> - <nl> - <nl> - int FPURegister : : ToAllocationIndex ( FPURegister reg ) { <nl> - DCHECK ( reg . code ( ) % 2 = = 0 ) ; <nl> - DCHECK ( reg . code ( ) / 2 < kMaxNumAllocatableRegisters ) ; <nl> - DCHECK ( reg . is_valid ( ) ) ; <nl> - DCHECK ( ! reg . is ( kDoubleRegZero ) ) ; <nl> - DCHECK ( ! reg . is ( kLithiumScratchDouble ) ) ; <nl> - return ( reg . code ( ) / 2 ) ; <nl> - } <nl> - <nl> - <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / RelocInfo . <nl> <nl> mmm a / src / mips64 / assembler - mips64 . cc <nl> ppp b / src / mips64 / assembler - mips64 . cc <nl> static unsigned CpuFeaturesImpliedByCompiler ( ) { <nl> } <nl> <nl> <nl> - const char * DoubleRegister : : AllocationIndexToString ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - const char * const names [ ] = { <nl> - " f0 " , <nl> - " f2 " , <nl> - " f4 " , <nl> - " f6 " , <nl> - " f8 " , <nl> - " f10 " , <nl> - " f12 " , <nl> - " f14 " , <nl> - " f16 " , <nl> - " f18 " , <nl> - " f20 " , <nl> - " f22 " , <nl> - " f24 " , <nl> - " f26 " <nl> - } ; <nl> - return names [ index ] ; <nl> - } <nl> - <nl> - <nl> void CpuFeatures : : ProbeImpl ( bool cross_compile ) { <nl> supported_ | = CpuFeaturesImpliedByCompiler ( ) ; <nl> <nl> MemOperand : : MemOperand ( Register rm , int32_t unit , int32_t multiplier , <nl> static const int kNegOffset = 0x00008000 ; <nl> / / daddiu ( sp , sp , 8 ) aka Pop ( ) operation or part of Pop ( r ) <nl> / / operations as post - increment of sp . <nl> - const Instr kPopInstruction = DADDIU | ( kRegister_sp_Code < < kRsShift ) <nl> - | ( kRegister_sp_Code < < kRtShift ) <nl> - | ( kPointerSize & kImm16Mask ) ; / / NOLINT <nl> + const Instr kPopInstruction = DADDIU | ( Register : : kCode_sp < < kRsShift ) | <nl> + ( Register : : kCode_sp < < kRtShift ) | <nl> + ( kPointerSize & kImm16Mask ) ; / / NOLINT <nl> / / daddiu ( sp , sp , - 8 ) part of Push ( r ) operation as pre - decrement of sp . <nl> - const Instr kPushInstruction = DADDIU | ( kRegister_sp_Code < < kRsShift ) <nl> - | ( kRegister_sp_Code < < kRtShift ) <nl> - | ( - kPointerSize & kImm16Mask ) ; / / NOLINT <nl> + const Instr kPushInstruction = DADDIU | ( Register : : kCode_sp < < kRsShift ) | <nl> + ( Register : : kCode_sp < < kRtShift ) | <nl> + ( - kPointerSize & kImm16Mask ) ; / / NOLINT <nl> / / sd ( r , MemOperand ( sp , 0 ) ) <nl> - const Instr kPushRegPattern = SD | ( kRegister_sp_Code < < kRsShift ) <nl> - | ( 0 & kImm16Mask ) ; / / NOLINT <nl> + const Instr kPushRegPattern = <nl> + SD | ( Register : : kCode_sp < < kRsShift ) | ( 0 & kImm16Mask ) ; / / NOLINT <nl> / / ld ( r , MemOperand ( sp , 0 ) ) <nl> - const Instr kPopRegPattern = LD | ( kRegister_sp_Code < < kRsShift ) <nl> - | ( 0 & kImm16Mask ) ; / / NOLINT <nl> + const Instr kPopRegPattern = <nl> + LD | ( Register : : kCode_sp < < kRsShift ) | ( 0 & kImm16Mask ) ; / / NOLINT <nl> <nl> - const Instr kLwRegFpOffsetPattern = LW | ( kRegister_fp_Code < < kRsShift ) <nl> - | ( 0 & kImm16Mask ) ; / / NOLINT <nl> + const Instr kLwRegFpOffsetPattern = <nl> + LW | ( Register : : kCode_fp < < kRsShift ) | ( 0 & kImm16Mask ) ; / / NOLINT <nl> <nl> - const Instr kSwRegFpOffsetPattern = SW | ( kRegister_fp_Code < < kRsShift ) <nl> - | ( 0 & kImm16Mask ) ; / / NOLINT <nl> + const Instr kSwRegFpOffsetPattern = <nl> + SW | ( Register : : kCode_fp < < kRsShift ) | ( 0 & kImm16Mask ) ; / / NOLINT <nl> <nl> - const Instr kLwRegFpNegOffsetPattern = LW | ( kRegister_fp_Code < < kRsShift ) <nl> - | ( kNegOffset & kImm16Mask ) ; / / NOLINT <nl> + const Instr kLwRegFpNegOffsetPattern = LW | ( Register : : kCode_fp < < kRsShift ) | <nl> + ( kNegOffset & kImm16Mask ) ; / / NOLINT <nl> <nl> - const Instr kSwRegFpNegOffsetPattern = SW | ( kRegister_fp_Code < < kRsShift ) <nl> - | ( kNegOffset & kImm16Mask ) ; / / NOLINT <nl> + const Instr kSwRegFpNegOffsetPattern = SW | ( Register : : kCode_fp < < kRsShift ) | <nl> + ( kNegOffset & kImm16Mask ) ; / / NOLINT <nl> / / A mask for the Rt register for push , pop , lw , sw instructions . <nl> const Instr kRtMask = kRtFieldMask ; <nl> const Instr kLwSwInstrTypeMask = 0xffe00000 ; <nl> void Assembler : : CodeTargetAlign ( ) { <nl> <nl> Register Assembler : : GetRtReg ( Instr instr ) { <nl> Register rt ; <nl> - rt . code_ = ( instr & kRtFieldMask ) > > kRtShift ; <nl> + rt . reg_code = ( instr & kRtFieldMask ) > > kRtShift ; <nl> return rt ; <nl> } <nl> <nl> <nl> Register Assembler : : GetRsReg ( Instr instr ) { <nl> Register rs ; <nl> - rs . code_ = ( instr & kRsFieldMask ) > > kRsShift ; <nl> + rs . reg_code = ( instr & kRsFieldMask ) > > kRsShift ; <nl> return rs ; <nl> } <nl> <nl> <nl> Register Assembler : : GetRdReg ( Instr instr ) { <nl> Register rd ; <nl> - rd . code_ = ( instr & kRdFieldMask ) > > kRdShift ; <nl> + rd . reg_code = ( instr & kRdFieldMask ) > > kRdShift ; <nl> return rd ; <nl> } <nl> <nl> void Assembler : : movn ( Register rd , Register rs , Register rt ) { <nl> <nl> void Assembler : : movt ( Register rd , Register rs , uint16_t cc ) { <nl> Register rt ; <nl> - rt . code_ = ( cc & 0x0007 ) < < 2 | 1 ; <nl> + rt . reg_code = ( cc & 0x0007 ) < < 2 | 1 ; <nl> GenInstrRegister ( SPECIAL , rs , rt , rd , 0 , MOVCI ) ; <nl> } <nl> <nl> <nl> void Assembler : : movf ( Register rd , Register rs , uint16_t cc ) { <nl> Register rt ; <nl> - rt . code_ = ( cc & 0x0007 ) < < 2 | 0 ; <nl> + rt . reg_code = ( cc & 0x0007 ) < < 2 | 0 ; <nl> GenInstrRegister ( SPECIAL , rs , rt , rd , 0 , MOVCI ) ; <nl> } <nl> <nl> void Assembler : : movz_d ( FPURegister fd , FPURegister fs , Register rt ) { <nl> void Assembler : : movt_s ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> DCHECK ( kArchVariant = = kMips64r2 ) ; <nl> FPURegister ft ; <nl> - ft . code_ = ( cc & 0x0007 ) < < 2 | 1 ; <nl> + ft . reg_code = ( cc & 0x0007 ) < < 2 | 1 ; <nl> GenInstrRegister ( COP1 , S , ft , fs , fd , MOVF ) ; <nl> } <nl> <nl> void Assembler : : movt_s ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> void Assembler : : movt_d ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> DCHECK ( kArchVariant = = kMips64r2 ) ; <nl> FPURegister ft ; <nl> - ft . code_ = ( cc & 0x0007 ) < < 2 | 1 ; <nl> + ft . reg_code = ( cc & 0x0007 ) < < 2 | 1 ; <nl> GenInstrRegister ( COP1 , D , ft , fs , fd , MOVF ) ; <nl> } <nl> <nl> void Assembler : : movt_d ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> void Assembler : : movf_s ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> DCHECK ( kArchVariant = = kMips64r2 ) ; <nl> FPURegister ft ; <nl> - ft . code_ = ( cc & 0x0007 ) < < 2 | 0 ; <nl> + ft . reg_code = ( cc & 0x0007 ) < < 2 | 0 ; <nl> GenInstrRegister ( COP1 , S , ft , fs , fd , MOVF ) ; <nl> } <nl> <nl> void Assembler : : movf_s ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> void Assembler : : movf_d ( FPURegister fd , FPURegister fs , uint16_t cc ) { <nl> DCHECK ( kArchVariant = = kMips64r2 ) ; <nl> FPURegister ft ; <nl> - ft . code_ = ( cc & 0x0007 ) < < 2 | 0 ; <nl> + ft . reg_code = ( cc & 0x0007 ) < < 2 | 0 ; <nl> GenInstrRegister ( COP1 , D , ft , fs , fd , MOVF ) ; <nl> } <nl> <nl> mmm a / src / mips64 / assembler - mips64 . h <nl> ppp b / src / mips64 / assembler - mips64 . h <nl> <nl> namespace v8 { <nl> namespace internal { <nl> <nl> + / / clang - format off <nl> + # define GENERAL_REGISTERS ( V ) \ <nl> + V ( zero_reg ) V ( at ) V ( v0 ) V ( v1 ) V ( a0 ) V ( a1 ) V ( a2 ) V ( a3 ) \ <nl> + V ( a4 ) V ( a5 ) V ( a6 ) V ( a7 ) V ( t0 ) V ( t1 ) V ( t2 ) V ( t3 ) \ <nl> + V ( s0 ) V ( s1 ) V ( s2 ) V ( s3 ) V ( s4 ) V ( s5 ) V ( s6 ) V ( s7 ) V ( t8 ) V ( t9 ) \ <nl> + V ( k0 ) V ( k1 ) V ( gp ) V ( sp ) V ( fp ) V ( ra ) <nl> + <nl> + # define ALLOCATABLE_GENERAL_REGISTERS ( V ) \ <nl> + V ( v0 ) V ( v1 ) V ( a0 ) V ( a1 ) V ( a2 ) V ( a3 ) \ <nl> + V ( a4 ) V ( a5 ) V ( a6 ) V ( a7 ) V ( t0 ) V ( t1 ) V ( t2 ) V ( s7 ) <nl> + <nl> + # define DOUBLE_REGISTERS ( V ) \ <nl> + V ( f0 ) V ( f1 ) V ( f2 ) V ( f3 ) V ( f4 ) V ( f5 ) V ( f6 ) V ( f7 ) \ <nl> + V ( f8 ) V ( f9 ) V ( f10 ) V ( f11 ) V ( f12 ) V ( f13 ) V ( f14 ) V ( f15 ) \ <nl> + V ( f16 ) V ( f17 ) V ( f18 ) V ( f19 ) V ( f20 ) V ( f21 ) V ( f22 ) V ( f23 ) \ <nl> + V ( f24 ) V ( f25 ) V ( f26 ) V ( f27 ) V ( f28 ) V ( f29 ) V ( f30 ) V ( f31 ) <nl> + <nl> + # define ALLOCATABLE_DOUBLE_REGISTERS ( V ) \ <nl> + V ( f0 ) V ( f2 ) V ( f4 ) V ( f6 ) V ( f8 ) V ( f10 ) V ( f12 ) V ( f14 ) \ <nl> + V ( f16 ) V ( f18 ) V ( f20 ) V ( f22 ) V ( f24 ) V ( f26 ) <nl> + / / clang - format on <nl> + <nl> / / CPU Registers . <nl> / / <nl> / / 1 ) We would prefer to use an enum , but enum values are assignment - <nl> namespace internal { <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / Implementation of Register and FPURegister . <nl> <nl> - / / Core register . <nl> struct Register { <nl> - static const int kNumRegisters = v8 : : internal : : kNumRegisters ; <nl> - static const int kMaxNumAllocatableRegisters = 14 ; / / v0 through t2 and cp . <nl> - static const int kSizeInBytes = 8 ; <nl> static const int kCpRegister = 23 ; / / cp ( s7 ) is the 23rd register . <nl> <nl> - inline static int NumAllocatableRegisters ( ) ; <nl> - <nl> - static int ToAllocationIndex ( Register reg ) { <nl> - DCHECK ( ( reg . code ( ) - 2 ) < ( kMaxNumAllocatableRegisters - 1 ) | | <nl> - reg . is ( from_code ( kCpRegister ) ) ) ; <nl> - return reg . is ( from_code ( kCpRegister ) ) ? <nl> - kMaxNumAllocatableRegisters - 1 : / / Return last index for ' cp ' . <nl> - reg . code ( ) - 2 ; / / zero_reg and ' at ' are skipped . <nl> - } <nl> - <nl> - static Register FromAllocationIndex ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - return index = = kMaxNumAllocatableRegisters - 1 ? <nl> - from_code ( kCpRegister ) : / / Last index is always the ' cp ' register . <nl> - from_code ( index + 2 ) ; / / zero_reg and ' at ' are skipped . <nl> - } <nl> - <nl> - static const char * AllocationIndexToString ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - const char * const names [ ] = { <nl> - " v0 " , <nl> - " v1 " , <nl> - " a0 " , <nl> - " a1 " , <nl> - " a2 " , <nl> - " a3 " , <nl> - " a4 " , <nl> - " a5 " , <nl> - " a6 " , <nl> - " a7 " , <nl> - " t0 " , <nl> - " t1 " , <nl> - " t2 " , <nl> - " s7 " , <nl> - } ; <nl> - return names [ index ] ; <nl> - } <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + GENERAL_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> + <nl> + static const int kNumRegisters = Code : : kAfterLast ; <nl> <nl> static Register from_code ( int code ) { <nl> + DCHECK ( code > = 0 ) ; <nl> + DCHECK ( code < kNumRegisters ) ; <nl> Register r = { code } ; <nl> return r ; <nl> } <nl> <nl> - bool is_valid ( ) const { return 0 < = code_ & & code_ < kNumRegisters ; } <nl> - bool is ( Register reg ) const { return code_ = = reg . code_ ; } <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < kNumRegisters ; } <nl> + bool is ( Register reg ) const { return reg_code = = reg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> } <nl> <nl> / / Unfortunately we can ' t make this private in a struct . <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> - # define REGISTER ( N , C ) \ <nl> - const int kRegister_ # # N # # _Code = C ; \ <nl> - const Register N = { C } <nl> - <nl> - REGISTER ( no_reg , - 1 ) ; <nl> - / / Always zero . <nl> - REGISTER ( zero_reg , 0 ) ; <nl> - / / at : Reserved for synthetic instructions . <nl> - REGISTER ( at , 1 ) ; <nl> - / / v0 , v1 : Used when returning multiple values from subroutines . <nl> - REGISTER ( v0 , 2 ) ; <nl> - REGISTER ( v1 , 3 ) ; <nl> - / / a0 - a4 : Used to pass non - FP parameters . <nl> - REGISTER ( a0 , 4 ) ; <nl> - REGISTER ( a1 , 5 ) ; <nl> - REGISTER ( a2 , 6 ) ; <nl> - REGISTER ( a3 , 7 ) ; <nl> - / / a4 - a7 t0 - t3 : Can be used without reservation , act as temporary registers <nl> - / / and are allowed to be destroyed by subroutines . <nl> - REGISTER ( a4 , 8 ) ; <nl> - REGISTER ( a5 , 9 ) ; <nl> - REGISTER ( a6 , 10 ) ; <nl> - REGISTER ( a7 , 11 ) ; <nl> - REGISTER ( t0 , 12 ) ; <nl> - REGISTER ( t1 , 13 ) ; <nl> - REGISTER ( t2 , 14 ) ; <nl> - REGISTER ( t3 , 15 ) ; <nl> - / / s0 - s7 : Subroutine register variables . Subroutines that write to these <nl> - / / registers must restore their values before exiting so that the caller can <nl> - / / expect the values to be preserved . <nl> - REGISTER ( s0 , 16 ) ; <nl> - REGISTER ( s1 , 17 ) ; <nl> - REGISTER ( s2 , 18 ) ; <nl> - REGISTER ( s3 , 19 ) ; <nl> - REGISTER ( s4 , 20 ) ; <nl> - REGISTER ( s5 , 21 ) ; <nl> - REGISTER ( s6 , 22 ) ; <nl> - REGISTER ( s7 , 23 ) ; <nl> - REGISTER ( t8 , 24 ) ; <nl> - REGISTER ( t9 , 25 ) ; <nl> - / / k0 , k1 : Reserved for system calls and interrupt handlers . <nl> - REGISTER ( k0 , 26 ) ; <nl> - REGISTER ( k1 , 27 ) ; <nl> - / / gp : Reserved . <nl> - REGISTER ( gp , 28 ) ; <nl> - / / sp : Stack pointer . <nl> - REGISTER ( sp , 29 ) ; <nl> - / / fp : Frame pointer . <nl> - REGISTER ( fp , 30 ) ; <nl> - / / ra : Return address pointer . <nl> - REGISTER ( ra , 31 ) ; <nl> - <nl> - # undef REGISTER <nl> + / / s7 : context register <nl> + / / s3 : lithium scratch <nl> + / / s4 : lithium scratch2 <nl> + # define DECLARE_REGISTER ( R ) const Register R = { Register : : kCode_ # # R } ; <nl> + GENERAL_REGISTERS ( DECLARE_REGISTER ) <nl> + # undef DECLARE_REGISTER <nl> + const Register no_reg = { Register : : kCode_no_reg } ; <nl> <nl> <nl> int ToNumber ( Register reg ) ; <nl> int ToNumber ( Register reg ) ; <nl> Register ToRegister ( int num ) ; <nl> <nl> / / Coprocessor register . <nl> - struct FPURegister { <nl> - static const int kMaxNumRegisters = v8 : : internal : : kNumFPURegisters ; <nl> - <nl> - / / TODO ( plind ) : Warning , inconsistent numbering here . kNumFPURegisters refers <nl> - / / to number of 32 - bit FPU regs , but kNumAllocatableRegisters refers to <nl> - / / number of Double regs ( 64 - bit regs , or FPU - reg - pairs ) . <nl> + struct DoubleRegister { <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + DOUBLE_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> <nl> - / / A few double registers are reserved : one as a scratch register and one to <nl> - / / hold 0 . 0 . <nl> - / / f28 : 0 . 0 <nl> - / / f30 : scratch register . <nl> - static const int kNumReservedRegisters = 2 ; <nl> - static const int kMaxNumAllocatableRegisters = kMaxNumRegisters / 2 - <nl> - kNumReservedRegisters ; <nl> + static const int kMaxNumRegisters = Code : : kAfterLast ; <nl> <nl> inline static int NumRegisters ( ) ; <nl> - inline static int NumAllocatableRegisters ( ) ; <nl> - <nl> - / / TODO ( turbofan ) : Proper support for float32 . <nl> - inline static int NumAllocatableAliasedRegisters ( ) ; <nl> - <nl> - inline static int ToAllocationIndex ( FPURegister reg ) ; <nl> - static const char * AllocationIndexToString ( int index ) ; <nl> <nl> - static FPURegister FromAllocationIndex ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - return from_code ( index * 2 ) ; <nl> - } <nl> - <nl> - static FPURegister from_code ( int code ) { <nl> - FPURegister r = { code } ; <nl> - return r ; <nl> - } <nl> + / / TODO ( plind ) : Warning , inconsistent numbering here . kNumFPURegisters refers <nl> + / / to number of 32 - bit FPU regs , but kNumAllocatableRegisters refers to <nl> + / / number of Double regs ( 64 - bit regs , or FPU - reg - pairs ) . <nl> <nl> - bool is_valid ( ) const { return 0 < = code_ & & code_ < kMaxNumRegisters ; } <nl> - bool is ( FPURegister creg ) const { return code_ = = creg . code_ ; } <nl> - FPURegister low ( ) const { <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < kMaxNumRegisters ; } <nl> + bool is ( DoubleRegister reg ) const { return reg_code = = reg . reg_code ; } <nl> + DoubleRegister low ( ) const { <nl> / / TODO ( plind ) : Create DCHECK for FR = 0 mode . This usage suspect for FR = 1 . <nl> / / Find low reg of a Double - reg pair , which is the reg itself . <nl> - DCHECK ( code_ % 2 = = 0 ) ; / / Specified Double reg must be even . <nl> - FPURegister reg ; <nl> - reg . code_ = code_ ; <nl> + DCHECK ( reg_code % 2 = = 0 ) ; / / Specified Double reg must be even . <nl> + DoubleRegister reg ; <nl> + reg . reg_code = reg_code ; <nl> DCHECK ( reg . is_valid ( ) ) ; <nl> return reg ; <nl> } <nl> - FPURegister high ( ) const { <nl> + DoubleRegister high ( ) const { <nl> / / TODO ( plind ) : Create DCHECK for FR = 0 mode . This usage illegal in FR = 1 . <nl> / / Find high reg of a Doubel - reg pair , which is reg + 1 . <nl> - DCHECK ( code_ % 2 = = 0 ) ; / / Specified Double reg must be even . <nl> - FPURegister reg ; <nl> - reg . code_ = code_ + 1 ; <nl> + DCHECK ( reg_code % 2 = = 0 ) ; / / Specified Double reg must be even . <nl> + DoubleRegister reg ; <nl> + reg . reg_code = reg_code + 1 ; <nl> DCHECK ( reg . is_valid ( ) ) ; <nl> return reg ; <nl> } <nl> <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> + } <nl> + <nl> + static DoubleRegister from_code ( int code ) { <nl> + DoubleRegister r = { code } ; <nl> + return r ; <nl> } <nl> void setcode ( int f ) { <nl> - code_ = f ; <nl> + reg_code = f ; <nl> DCHECK ( is_valid ( ) ) ; <nl> } <nl> / / Unfortunately we can ' t make this private in a struct . <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> + / / A few double registers are reserved : one as a scratch register and one to <nl> + / / hold 0 . 0 . <nl> + / / f28 : 0 . 0 <nl> + / / f30 : scratch register . <nl> + <nl> / / V8 now supports the O32 ABI , and the FPU Registers are organized as 32 <nl> / / 32 - bit registers , f0 through f31 . When used as ' double ' they are used <nl> / / in pairs , starting with the even numbered register . So a double operation <nl> struct FPURegister { <nl> / / but it is not in common use . Someday we will want to support this in v8 . ) <nl> <nl> / / For O32 ABI , Floats and Doubles refer to same set of 32 32 - bit registers . <nl> - typedef FPURegister DoubleRegister ; <nl> - typedef FPURegister FloatRegister ; <nl> - <nl> - const FPURegister no_freg = { - 1 } ; <nl> - <nl> - const FPURegister f0 = { 0 } ; / / Return value in hard float mode . <nl> - const FPURegister f1 = { 1 } ; <nl> - const FPURegister f2 = { 2 } ; <nl> - const FPURegister f3 = { 3 } ; <nl> - const FPURegister f4 = { 4 } ; <nl> - const FPURegister f5 = { 5 } ; <nl> - const FPURegister f6 = { 6 } ; <nl> - const FPURegister f7 = { 7 } ; <nl> - const FPURegister f8 = { 8 } ; <nl> - const FPURegister f9 = { 9 } ; <nl> - const FPURegister f10 = { 10 } ; <nl> - const FPURegister f11 = { 11 } ; <nl> - const FPURegister f12 = { 12 } ; / / Arg 0 in hard float mode . <nl> - const FPURegister f13 = { 13 } ; <nl> - const FPURegister f14 = { 14 } ; / / Arg 1 in hard float mode . <nl> - const FPURegister f15 = { 15 } ; <nl> - const FPURegister f16 = { 16 } ; <nl> - const FPURegister f17 = { 17 } ; <nl> - const FPURegister f18 = { 18 } ; <nl> - const FPURegister f19 = { 19 } ; <nl> - const FPURegister f20 = { 20 } ; <nl> - const FPURegister f21 = { 21 } ; <nl> - const FPURegister f22 = { 22 } ; <nl> - const FPURegister f23 = { 23 } ; <nl> - const FPURegister f24 = { 24 } ; <nl> - const FPURegister f25 = { 25 } ; <nl> - const FPURegister f26 = { 26 } ; <nl> - const FPURegister f27 = { 27 } ; <nl> - const FPURegister f28 = { 28 } ; <nl> - const FPURegister f29 = { 29 } ; <nl> - const FPURegister f30 = { 30 } ; <nl> - const FPURegister f31 = { 31 } ; <nl> + typedef DoubleRegister FPURegister ; <nl> + typedef DoubleRegister FloatRegister ; <nl> + <nl> + const DoubleRegister no_freg = { - 1 } ; <nl> + <nl> + const DoubleRegister f0 = { 0 } ; / / Return value in hard float mode . <nl> + const DoubleRegister f1 = { 1 } ; <nl> + const DoubleRegister f2 = { 2 } ; <nl> + const DoubleRegister f3 = { 3 } ; <nl> + const DoubleRegister f4 = { 4 } ; <nl> + const DoubleRegister f5 = { 5 } ; <nl> + const DoubleRegister f6 = { 6 } ; <nl> + const DoubleRegister f7 = { 7 } ; <nl> + const DoubleRegister f8 = { 8 } ; <nl> + const DoubleRegister f9 = { 9 } ; <nl> + const DoubleRegister f10 = { 10 } ; <nl> + const DoubleRegister f11 = { 11 } ; <nl> + const DoubleRegister f12 = { 12 } ; / / Arg 0 in hard float mode . <nl> + const DoubleRegister f13 = { 13 } ; <nl> + const DoubleRegister f14 = { 14 } ; / / Arg 1 in hard float mode . <nl> + const DoubleRegister f15 = { 15 } ; <nl> + const DoubleRegister f16 = { 16 } ; <nl> + const DoubleRegister f17 = { 17 } ; <nl> + const DoubleRegister f18 = { 18 } ; <nl> + const DoubleRegister f19 = { 19 } ; <nl> + const DoubleRegister f20 = { 20 } ; <nl> + const DoubleRegister f21 = { 21 } ; <nl> + const DoubleRegister f22 = { 22 } ; <nl> + const DoubleRegister f23 = { 23 } ; <nl> + const DoubleRegister f24 = { 24 } ; <nl> + const DoubleRegister f25 = { 25 } ; <nl> + const DoubleRegister f26 = { 26 } ; <nl> + const DoubleRegister f27 = { 27 } ; <nl> + const DoubleRegister f28 = { 28 } ; <nl> + const DoubleRegister f29 = { 29 } ; <nl> + const DoubleRegister f30 = { 30 } ; <nl> + const DoubleRegister f31 = { 31 } ; <nl> <nl> / / Register aliases . <nl> / / cp is assumed to be a callee saved register . <nl> const FPURegister f31 = { 31 } ; <nl> / / FPU ( coprocessor 1 ) control registers . <nl> / / Currently only FCSR ( # 31 ) is implemented . <nl> struct FPUControlRegister { <nl> - bool is_valid ( ) const { return code_ = = kFCSRRegister ; } <nl> - bool is ( FPUControlRegister creg ) const { return code_ = = creg . code_ ; } <nl> + bool is_valid ( ) const { return reg_code = = kFCSRRegister ; } <nl> + bool is ( FPUControlRegister creg ) const { return reg_code = = creg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return 1 < < code_ ; <nl> + return 1 < < reg_code ; <nl> } <nl> void setcode ( int f ) { <nl> - code_ = f ; <nl> + reg_code = f ; <nl> DCHECK ( is_valid ( ) ) ; <nl> } <nl> / / Unfortunately we can ' t make this private in a struct . <nl> - int code_ ; <nl> + int reg_code ; <nl> } ; <nl> <nl> const FPUControlRegister no_fpucreg = { kInvalidFPUControlRegister } ; <nl> mmm a / src / mips64 / deoptimizer - mips64 . cc <nl> ppp b / src / mips64 / deoptimizer - mips64 . cc <nl> <nl> # include " src / codegen . h " <nl> # include " src / deoptimizer . h " <nl> # include " src / full - codegen / full - codegen . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / safepoint - table . h " <nl> <nl> namespace v8 { <nl> void Deoptimizer : : FillInputFrame ( Address tos , JavaScriptFrame * frame ) { <nl> } <nl> input_ - > SetRegister ( sp . code ( ) , reinterpret_cast < intptr_t > ( frame - > sp ( ) ) ) ; <nl> input_ - > SetRegister ( fp . code ( ) , reinterpret_cast < intptr_t > ( frame - > fp ( ) ) ) ; <nl> - for ( int i = 0 ; i < DoubleRegister : : NumAllocatableRegisters ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < DoubleRegister : : kMaxNumRegisters ; i + + ) { <nl> input_ - > SetDoubleRegister ( i , 0 . 0 ) ; <nl> } <nl> <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> RegList restored_regs = kJSCallerSaved | kCalleeSaved ; <nl> RegList saved_regs = restored_regs | sp . bit ( ) | ra . bit ( ) ; <nl> <nl> - const int kDoubleRegsSize = <nl> - kDoubleSize * FPURegister : : kMaxNumAllocatableRegisters ; <nl> + const int kDoubleRegsSize = kDoubleSize * DoubleRegister : : kMaxNumRegisters ; <nl> <nl> / / Save all FPU registers before messing with them . <nl> __ Dsubu ( sp , sp , Operand ( kDoubleRegsSize ) ) ; <nl> - for ( int i = 0 ; i < FPURegister : : kMaxNumAllocatableRegisters ; + + i ) { <nl> - FPURegister fpu_reg = FPURegister : : FromAllocationIndex ( i ) ; <nl> - int offset = i * kDoubleSize ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + const DoubleRegister fpu_reg = DoubleRegister : : from_code ( code ) ; <nl> + int offset = code * kDoubleSize ; <nl> __ sdc1 ( fpu_reg , MemOperand ( sp , offset ) ) ; <nl> } <nl> <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> int double_regs_offset = FrameDescription : : double_registers_offset ( ) ; <nl> / / Copy FPU registers to <nl> / / double_registers_ [ DoubleRegister : : kNumAllocatableRegisters ] <nl> - for ( int i = 0 ; i < FPURegister : : NumAllocatableRegisters ( ) ; + + i ) { <nl> - int dst_offset = i * kDoubleSize + double_regs_offset ; <nl> - int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + int dst_offset = code * kDoubleSize + double_regs_offset ; <nl> + int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize ; <nl> __ ldc1 ( f0 , MemOperand ( sp , src_offset ) ) ; <nl> __ sdc1 ( f0 , MemOperand ( a1 , dst_offset ) ) ; <nl> } <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> __ BranchShort ( & outer_push_loop , lt , a4 , Operand ( a1 ) ) ; <nl> <nl> __ ld ( a1 , MemOperand ( a0 , Deoptimizer : : input_offset ( ) ) ) ; <nl> - for ( int i = 0 ; i < FPURegister : : kMaxNumAllocatableRegisters ; + + i ) { <nl> - const FPURegister fpu_reg = FPURegister : : FromAllocationIndex ( i ) ; <nl> - int src_offset = i * kDoubleSize + double_regs_offset ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + const DoubleRegister fpu_reg = DoubleRegister : : from_code ( code ) ; <nl> + int src_offset = code * kDoubleSize + double_regs_offset ; <nl> __ ldc1 ( fpu_reg , MemOperand ( a1 , src_offset ) ) ; <nl> } <nl> <nl> mmm a / src / mips64 / lithium - codegen - mips64 . cc <nl> ppp b / src / mips64 / lithium - codegen - mips64 . cc <nl> void LCodeGen : : SaveCallerDoubles ( ) { <nl> BitVector * doubles = chunk ( ) - > allocated_double_registers ( ) ; <nl> BitVector : : Iterator save_iterator ( doubles ) ; <nl> while ( ! save_iterator . Done ( ) ) { <nl> - __ sdc1 ( DoubleRegister : : FromAllocationIndex ( save_iterator . Current ( ) ) , <nl> + __ sdc1 ( DoubleRegister : : from_code ( save_iterator . Current ( ) ) , <nl> MemOperand ( sp , count * kDoubleSize ) ) ; <nl> save_iterator . Advance ( ) ; <nl> count + + ; <nl> void LCodeGen : : RestoreCallerDoubles ( ) { <nl> BitVector : : Iterator save_iterator ( doubles ) ; <nl> int count = 0 ; <nl> while ( ! save_iterator . Done ( ) ) { <nl> - __ ldc1 ( DoubleRegister : : FromAllocationIndex ( save_iterator . Current ( ) ) , <nl> + __ ldc1 ( DoubleRegister : : from_code ( save_iterator . Current ( ) ) , <nl> MemOperand ( sp , count * kDoubleSize ) ) ; <nl> save_iterator . Advance ( ) ; <nl> count + + ; <nl> bool LCodeGen : : GenerateSafepointTable ( ) { <nl> <nl> <nl> Register LCodeGen : : ToRegister ( int index ) const { <nl> - return Register : : FromAllocationIndex ( index ) ; <nl> + return Register : : from_code ( index ) ; <nl> } <nl> <nl> <nl> DoubleRegister LCodeGen : : ToDoubleRegister ( int index ) const { <nl> - return DoubleRegister : : FromAllocationIndex ( index ) ; <nl> + return DoubleRegister : : from_code ( index ) ; <nl> } <nl> <nl> <nl> mmm a / src / mips64 / lithium - mips64 . cc <nl> ppp b / src / mips64 / lithium - mips64 . cc <nl> LPlatformChunk * LChunkBuilder : : Build ( ) { <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( Register reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , <nl> - Register : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( DoubleRegister reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , <nl> - DoubleRegister : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) <nl> + LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / mips64 / macro - assembler - mips64 . cc <nl> ppp b / src / mips64 / macro - assembler - mips64 . cc <nl> <nl> # include " src / cpu - profiler . h " <nl> # include " src / debug / debug . h " <nl> # include " src / mips64 / macro - assembler - mips64 . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / runtime / runtime . h " <nl> <nl> namespace v8 { <nl> MemOperand MacroAssembler : : SafepointRegisterSlot ( Register reg ) { <nl> MemOperand MacroAssembler : : SafepointRegistersAndDoublesSlot ( Register reg ) { <nl> UNIMPLEMENTED_MIPS ( ) ; <nl> / / General purpose registers are pushed last on the stack . <nl> - int doubles_size = FPURegister : : NumAllocatableRegisters ( ) * kDoubleSize ; <nl> + int doubles_size = DoubleRegister : : kMaxNumRegisters * kDoubleSize ; <nl> int register_offset = SafepointRegisterStackIndex ( reg . code ( ) ) * kPointerSize ; <nl> return MemOperand ( sp , doubles_size + register_offset ) ; <nl> } <nl> void MacroAssembler : : CopyFields ( Register dst , <nl> / / Find a temp register in temps list . <nl> for ( int i = 0 ; i < kNumRegisters ; i + + ) { <nl> if ( ( temps & ( 1 < < i ) ) ! = 0 ) { <nl> - tmp . code_ = i ; <nl> + tmp . reg_code = i ; <nl> break ; <nl> } <nl> } <nl> Register GetRegisterThatIsNotOneOf ( Register reg1 , <nl> if ( reg5 . is_valid ( ) ) regs | = reg5 . bit ( ) ; <nl> if ( reg6 . is_valid ( ) ) regs | = reg6 . bit ( ) ; <nl> <nl> - for ( int i = 0 ; i < Register : : NumAllocatableRegisters ( ) ; i + + ) { <nl> - Register candidate = Register : : FromAllocationIndex ( i ) ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_general_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableGeneralCode ( i ) ; <nl> + Register candidate = Register : : from_code ( code ) ; <nl> if ( regs & candidate . bit ( ) ) continue ; <nl> return candidate ; <nl> } <nl> mmm a / src / mips64 / macro - assembler - mips64 . h <nl> ppp b / src / mips64 / macro - assembler - mips64 . h <nl> namespace v8 { <nl> namespace internal { <nl> <nl> / / Give alias names to registers for calling conventions . <nl> - const Register kReturnRegister0 = { kRegister_v0_Code } ; <nl> - const Register kReturnRegister1 = { kRegister_v1_Code } ; <nl> - const Register kJSFunctionRegister = { kRegister_a1_Code } ; <nl> - const Register kContextRegister = { kRegister_s7_Code } ; <nl> - const Register kInterpreterAccumulatorRegister = { kRegister_v0_Code } ; <nl> - const Register kInterpreterRegisterFileRegister = { kRegister_a7_Code } ; <nl> - const Register kInterpreterBytecodeOffsetRegister = { kRegister_t0_Code } ; <nl> - const Register kInterpreterBytecodeArrayRegister = { kRegister_t1_Code } ; <nl> - const Register kInterpreterDispatchTableRegister = { kRegister_t2_Code } ; <nl> - const Register kRuntimeCallFunctionRegister = { kRegister_a1_Code } ; <nl> - const Register kRuntimeCallArgCountRegister = { kRegister_a0_Code } ; <nl> + const Register kReturnRegister0 = { Register : : kCode_v0 } ; <nl> + const Register kReturnRegister1 = { Register : : kCode_v1 } ; <nl> + const Register kJSFunctionRegister = { Register : : kCode_a1 } ; <nl> + const Register kContextRegister = { Register : : kCpRegister } ; <nl> + const Register kInterpreterAccumulatorRegister = { Register : : kCode_v0 } ; <nl> + const Register kInterpreterRegisterFileRegister = { Register : : kCode_a7 } ; <nl> + const Register kInterpreterBytecodeOffsetRegister = { Register : : kCode_t0 } ; <nl> + const Register kInterpreterBytecodeArrayRegister = { Register : : kCode_t1 } ; <nl> + const Register kInterpreterDispatchTableRegister = { Register : : kCode_t2 } ; <nl> + const Register kRuntimeCallFunctionRegister = { Register : : kCode_a1 } ; <nl> + const Register kRuntimeCallArgCountRegister = { Register : : kCode_a0 } ; <nl> <nl> / / Forward declaration . <nl> class JumpTarget ; <nl> mmm a / src / objects . cc <nl> ppp b / src / objects . cc <nl> void DeoptimizationInputData : : DeoptimizationInputDataPrint ( <nl> <nl> case Translation : : DOUBLE_REGISTER : { <nl> int reg_code = iterator . Next ( ) ; <nl> - os < < " { input = " < < DoubleRegister : : AllocationIndexToString ( reg_code ) <nl> + os < < " { input = " < < DoubleRegister : : from_code ( reg_code ) . ToString ( ) <nl> < < " } " ; <nl> break ; <nl> } <nl> new file mode 100644 <nl> index 00000000000 . . 9b1c951f838 <nl> mmm / dev / null <nl> ppp b / src / register - configuration . 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 " src / register - configuration . h " <nl> + # include " src / globals . h " <nl> + # include " src / macro - assembler . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + namespace { <nl> + <nl> + # define REGISTER_COUNT ( R ) 1 + <nl> + static const int kMaxAllocatableGeneralRegisterCount = <nl> + ALLOCATABLE_GENERAL_REGISTERS ( REGISTER_COUNT ) 0 ; <nl> + static const int kMaxAllocatableDoubleRegisterCount = <nl> + ALLOCATABLE_DOUBLE_REGISTERS ( REGISTER_COUNT ) 0 ; <nl> + <nl> + static const char * const kGeneralRegisterNames [ ] = { <nl> + # define REGISTER_NAME ( R ) # R , <nl> + GENERAL_REGISTERS ( REGISTER_NAME ) <nl> + # undef REGISTER_NAME <nl> + } ; <nl> + <nl> + static const char * const kDoubleRegisterNames [ ] = { <nl> + # define REGISTER_NAME ( R ) # R , <nl> + DOUBLE_REGISTERS ( REGISTER_NAME ) <nl> + # undef REGISTER_NAME <nl> + } ; <nl> + <nl> + STATIC_ASSERT ( RegisterConfiguration : : kMaxGeneralRegisters > = <nl> + Register : : kNumRegisters ) ; <nl> + STATIC_ASSERT ( RegisterConfiguration : : kMaxDoubleRegisters > = <nl> + DoubleRegister : : kMaxNumRegisters ) ; <nl> + <nl> + class ArchDefaultRegisterConfiguration : public RegisterConfiguration { <nl> + public : <nl> + ArchDefaultRegisterConfiguration ( ) <nl> + : RegisterConfiguration ( <nl> + Register : : kNumRegisters , DoubleRegister : : kMaxNumRegisters , <nl> + # if V8_TARGET_ARCH_IA32 <nl> + kMaxAllocatableGeneralRegisterCount , <nl> + kMaxAllocatableDoubleRegisterCount , <nl> + kMaxAllocatableDoubleRegisterCount , <nl> + # elif V8_TARGET_ARCH_X87 <nl> + kMaxAllocatableGeneralRegisterCount , 1 , 1 , <nl> + # elif V8_TARGET_ARCH_X64 <nl> + kMaxAllocatableGeneralRegisterCount , <nl> + kMaxAllocatableDoubleRegisterCount , <nl> + kMaxAllocatableDoubleRegisterCount , <nl> + # elif V8_TARGET_ARCH_ARM <nl> + FLAG_enable_embedded_constant_pool <nl> + ? ( kMaxAllocatableGeneralRegisterCount - 1 ) <nl> + : kMaxAllocatableGeneralRegisterCount , <nl> + CpuFeatures : : IsSupported ( VFP32DREGS ) <nl> + ? kMaxAllocatableDoubleRegisterCount <nl> + : ( ALLOCATABLE_NO_VFP32_DOUBLE_REGISTERS ( REGISTER_COUNT ) 0 ) , <nl> + ALLOCATABLE_NO_VFP32_DOUBLE_REGISTERS ( REGISTER_COUNT ) 0 , <nl> + # elif V8_TARGET_ARCH_ARM64 <nl> + kMaxAllocatableGeneralRegisterCount , <nl> + kMaxAllocatableDoubleRegisterCount , <nl> + kMaxAllocatableDoubleRegisterCount , <nl> + # elif V8_TARGET_ARCH_MIPS <nl> + kMaxAllocatableGeneralRegisterCount , <nl> + kMaxAllocatableDoubleRegisterCount , <nl> + kMaxAllocatableDoubleRegisterCount , <nl> + # elif V8_TARGET_ARCH_MIPS64 <nl> + kMaxAllocatableGeneralRegisterCount , <nl> + kMaxAllocatableDoubleRegisterCount , <nl> + kMaxAllocatableDoubleRegisterCount , <nl> + # else <nl> + GetAllocatableGeneralRegisterCount ( ) , <nl> + GetAllocatableDoubleRegisterCount ( ) , <nl> + GetAllocatableAliasedDoubleRegisterCount ( ) , <nl> + # endif <nl> + GetAllocatableGeneralCodes ( ) , GetAllocatableDoubleCodes ( ) , <nl> + kGeneralRegisterNames , kDoubleRegisterNames ) { <nl> + } <nl> + <nl> + const char * general_register_name_table_ [ Register : : kNumRegisters ] ; <nl> + const char * double_register_name_table_ [ DoubleRegister : : kMaxNumRegisters ] ; <nl> + <nl> + private : <nl> + friend struct Register ; <nl> + friend struct DoubleRegister ; <nl> + <nl> + static const int * GetAllocatableGeneralCodes ( ) { <nl> + # define REGISTER_CODE ( R ) Register : : kCode_ # # R , <nl> + static const int general_codes [ ] = { <nl> + ALLOCATABLE_GENERAL_REGISTERS ( REGISTER_CODE ) } ; <nl> + # undef REGISTER_CODE <nl> + return general_codes ; <nl> + } <nl> + <nl> + static const int * GetAllocatableDoubleCodes ( ) { <nl> + # define REGISTER_CODE ( R ) DoubleRegister : : kCode_ # # R , <nl> + static const int double_codes [ ] = { <nl> + ALLOCATABLE_DOUBLE_REGISTERS ( REGISTER_CODE ) } ; <nl> + # undef REGISTER_CODE <nl> + return double_codes ; <nl> + } <nl> + } ; <nl> + <nl> + <nl> + static base : : LazyInstance < ArchDefaultRegisterConfiguration > : : type <nl> + kDefaultRegisterConfiguration = LAZY_INSTANCE_INITIALIZER ; <nl> + <nl> + } / / namespace <nl> + <nl> + <nl> + const RegisterConfiguration * RegisterConfiguration : : ArchDefault ( ) { <nl> + return & kDefaultRegisterConfiguration . Get ( ) ; <nl> + } <nl> + <nl> + RegisterConfiguration : : RegisterConfiguration ( <nl> + int num_general_registers , int num_double_registers , <nl> + int num_allocatable_general_registers , int num_allocatable_double_registers , <nl> + int num_allocatable_aliased_double_registers , <nl> + const int * allocatable_general_codes , const int * allocatable_double_codes , <nl> + const char * const * general_register_names , <nl> + const char * const * double_register_names ) <nl> + : num_general_registers_ ( num_general_registers ) , <nl> + num_double_registers_ ( num_double_registers ) , <nl> + num_allocatable_general_registers_ ( num_allocatable_general_registers ) , <nl> + num_allocatable_double_registers_ ( num_allocatable_double_registers ) , <nl> + num_allocatable_aliased_double_registers_ ( <nl> + num_allocatable_aliased_double_registers ) , <nl> + allocatable_general_codes_mask_ ( 0 ) , <nl> + allocatable_double_codes_mask_ ( 0 ) , <nl> + allocatable_general_codes_ ( allocatable_general_codes ) , <nl> + allocatable_double_codes_ ( allocatable_double_codes ) , <nl> + general_register_names_ ( general_register_names ) , <nl> + double_register_names_ ( double_register_names ) { <nl> + for ( int i = 0 ; i < num_allocatable_general_registers_ ; + + i ) { <nl> + allocatable_general_codes_mask_ | = ( 1 < < allocatable_general_codes_ [ i ] ) ; <nl> + } <nl> + for ( int i = 0 ; i < num_allocatable_double_registers_ ; + + i ) { <nl> + allocatable_double_codes_mask_ | = ( 1 < < allocatable_double_codes_ [ i ] ) ; <nl> + } <nl> + } <nl> + <nl> + # undef REGISTER_COUNT <nl> + <nl> + } / / namespace internal <nl> + } / / namespace v8 <nl> new file mode 100644 <nl> index 00000000000 . . f12bc7c07c6 <nl> mmm / dev / null <nl> ppp b / src / register - configuration . h <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> + # ifndef V8_COMPILER_REGISTER_CONFIGURATION_H_ <nl> + # define V8_COMPILER_REGISTER_CONFIGURATION_H_ <nl> + <nl> + # include " src / base / macros . h " <nl> + <nl> + namespace v8 { <nl> + namespace internal { <nl> + <nl> + / / An architecture independent representation of the sets of registers available <nl> + / / for instruction creation . <nl> + class RegisterConfiguration { <nl> + public : <nl> + / / Architecture independent maxes . <nl> + static const int kMaxGeneralRegisters = 32 ; <nl> + static const int kMaxDoubleRegisters = 32 ; <nl> + <nl> + static const RegisterConfiguration * ArchDefault ( ) ; <nl> + <nl> + RegisterConfiguration ( int num_general_registers , int num_double_registers , <nl> + int num_allocatable_general_registers , <nl> + int num_allocatable_double_registers , <nl> + int num_allocatable_aliased_double_registers , <nl> + const int * allocatable_general_codes , <nl> + const int * allocatable_double_codes , <nl> + char const * const * general_names , <nl> + char const * const * double_names ) ; <nl> + <nl> + int num_general_registers ( ) const { return num_general_registers_ ; } <nl> + int num_double_registers ( ) const { return num_double_registers_ ; } <nl> + int num_allocatable_general_registers ( ) const { <nl> + return num_allocatable_general_registers_ ; <nl> + } <nl> + int num_allocatable_double_registers ( ) const { <nl> + return num_allocatable_double_registers_ ; <nl> + } <nl> + / / TODO ( turbofan ) : This is a temporary work - around required because our <nl> + / / register allocator does not yet support the aliasing of single / double <nl> + / / registers on ARM . <nl> + int num_allocatable_aliased_double_registers ( ) const { <nl> + return num_allocatable_aliased_double_registers_ ; <nl> + } <nl> + int32_t allocatable_general_codes_mask ( ) const { <nl> + return allocatable_general_codes_mask_ ; <nl> + } <nl> + int32_t allocatable_double_codes_mask ( ) const { <nl> + return allocatable_double_codes_mask_ ; <nl> + } <nl> + int GetAllocatableGeneralCode ( int index ) const { <nl> + return allocatable_general_codes_ [ index ] ; <nl> + } <nl> + int GetAllocatableDoubleCode ( int index ) const { <nl> + return allocatable_double_codes_ [ index ] ; <nl> + } <nl> + const char * GetGeneralRegisterName ( int code ) const { <nl> + return general_register_names_ [ code ] ; <nl> + } <nl> + const char * GetDoubleRegisterName ( int code ) const { <nl> + return double_register_names_ [ code ] ; <nl> + } <nl> + const int * allocatable_general_codes ( ) const { <nl> + return allocatable_general_codes_ ; <nl> + } <nl> + const int * allocatable_double_codes ( ) const { <nl> + return allocatable_double_codes_ ; <nl> + } <nl> + <nl> + private : <nl> + const int num_general_registers_ ; <nl> + const int num_double_registers_ ; <nl> + int num_allocatable_general_registers_ ; <nl> + int num_allocatable_double_registers_ ; <nl> + int num_allocatable_aliased_double_registers_ ; <nl> + int32_t allocatable_general_codes_mask_ ; <nl> + int32_t allocatable_double_codes_mask_ ; <nl> + const int * allocatable_general_codes_ ; <nl> + const int * allocatable_double_codes_ ; <nl> + char const * const * general_register_names_ ; <nl> + char const * const * double_register_names_ ; <nl> + } ; <nl> + <nl> + } / / namespace internal <nl> + } / / namespace v8 <nl> + <nl> + # endif / / V8_COMPILER_REGISTER_CONFIGURATION_H_ <nl> mmm a / src / x64 / assembler - x64 . cc <nl> ppp b / src / x64 / assembler - x64 . cc <nl> void CpuFeatures : : PrintFeatures ( ) { <nl> } <nl> <nl> <nl> - / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - / / Register constants . <nl> - <nl> - const int <nl> - Register : : kRegisterCodeByAllocationIndex [ kMaxNumAllocatableRegisters ] = { <nl> - / / rax , rbx , rdx , rcx , rsi , rdi , r8 , r9 , r11 , r12 , r14 , r15 <nl> - 0 , 3 , 2 , 1 , 6 , 7 , 8 , 9 , 11 , 12 , 14 , 15 <nl> - } ; <nl> - <nl> - const int Register : : kAllocationIndexByRegisterCode [ kNumRegisters ] = { <nl> - 0 , 3 , 2 , 1 , - 1 , - 1 , 4 , 5 , 6 , 7 , - 1 , 8 , 9 , - 1 , 10 , 11 <nl> - } ; <nl> - <nl> - <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> / / Implementation of Operand <nl> <nl> mmm a / src / x64 / assembler - x64 . h <nl> ppp b / src / x64 / assembler - x64 . h <nl> namespace internal { <nl> <nl> / / Utility functions <nl> <nl> + # define GENERAL_REGISTERS ( V ) \ <nl> + V ( rax ) \ <nl> + V ( rcx ) \ <nl> + V ( rdx ) \ <nl> + V ( rbx ) \ <nl> + V ( rsp ) \ <nl> + V ( rbp ) \ <nl> + V ( rsi ) \ <nl> + V ( rdi ) \ <nl> + V ( r8 ) \ <nl> + V ( r9 ) \ <nl> + V ( r10 ) \ <nl> + V ( r11 ) \ <nl> + V ( r12 ) \ <nl> + V ( r13 ) \ <nl> + V ( r14 ) \ <nl> + V ( r15 ) <nl> + <nl> + # define ALLOCATABLE_GENERAL_REGISTERS ( V ) \ <nl> + V ( rax ) \ <nl> + V ( rbx ) \ <nl> + V ( rdx ) \ <nl> + V ( rcx ) \ <nl> + V ( rsi ) \ <nl> + V ( rdi ) \ <nl> + V ( r8 ) \ <nl> + V ( r9 ) \ <nl> + V ( r11 ) \ <nl> + V ( r12 ) \ <nl> + V ( r14 ) \ <nl> + V ( r15 ) <nl> + <nl> + <nl> / / CPU Registers . <nl> / / <nl> / / 1 ) We would prefer to use an enum , but enum values are assignment - <nl> namespace internal { <nl> / / mode . This way we get the compile - time error checking in debug mode <nl> / / and best performance in optimized code . <nl> / / <nl> - <nl> struct Register { <nl> - / / The non - allocatable registers are : <nl> - / / rsp - stack pointer <nl> - / / rbp - frame pointer <nl> - / / r10 - fixed scratch register <nl> - / / r13 - root register <nl> - static const int kMaxNumAllocatableRegisters = 12 ; <nl> - static int NumAllocatableRegisters ( ) { <nl> - return kMaxNumAllocatableRegisters ; <nl> - } <nl> - static const int kNumRegisters = 16 ; <nl> - <nl> - static int ToAllocationIndex ( Register reg ) { <nl> - return kAllocationIndexByRegisterCode [ reg . code ( ) ] ; <nl> - } <nl> - <nl> - static Register FromAllocationIndex ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - Register result = { kRegisterCodeByAllocationIndex [ index ] } ; <nl> - return result ; <nl> - } <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + GENERAL_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> <nl> - static const char * AllocationIndexToString ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - const char * const names [ ] = { <nl> - " rax " , <nl> - " rbx " , <nl> - " rdx " , <nl> - " rcx " , <nl> - " rsi " , <nl> - " rdi " , <nl> - " r8 " , <nl> - " r9 " , <nl> - " r11 " , <nl> - " r12 " , <nl> - " r14 " , <nl> - " r15 " <nl> - } ; <nl> - return names [ index ] ; <nl> - } <nl> + static const int kNumRegisters = Code : : kAfterLast ; <nl> <nl> static Register from_code ( int code ) { <nl> - Register r = { code } ; <nl> + DCHECK ( code > = 0 ) ; <nl> + DCHECK ( code < kNumRegisters ) ; <nl> + Register r = { code } ; <nl> return r ; <nl> } <nl> - bool is_valid ( ) const { return 0 < = code_ & & code_ < kNumRegisters ; } <nl> - bool is ( Register reg ) const { return code_ = = reg . code_ ; } <nl> - / / rax , rbx , rcx and rdx are byte registers , the rest are not . <nl> - bool is_byte_register ( ) const { return code_ < = 3 ; } <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < kNumRegisters ; } <nl> + bool is ( Register reg ) const { return reg_code = = reg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> int bit ( ) const { <nl> - return 1 < < code_ ; <nl> + DCHECK ( is_valid ( ) ) ; <nl> + return 1 < < reg_code ; <nl> } <nl> <nl> + bool is_byte_register ( ) const { return reg_code < = 3 ; } <nl> / / Return the high bit of the register code as a 0 or 1 . Used often <nl> / / when constructing the REX prefix byte . <nl> - int high_bit ( ) const { <nl> - return code_ > > 3 ; <nl> - } <nl> + int high_bit ( ) const { return reg_code > > 3 ; } <nl> / / Return the 3 low bits of the register code . Used when encoding registers <nl> / / in modR / M , SIB , and opcode bytes . <nl> - int low_bits ( ) const { <nl> - return code_ & 0x7 ; <nl> - } <nl> + int low_bits ( ) const { return reg_code & 0x7 ; } <nl> <nl> / / Unfortunately we can ' t make this private in a struct when initializing <nl> / / by assignment . <nl> - int code_ ; <nl> - <nl> - private : <nl> - static const int kRegisterCodeByAllocationIndex [ kMaxNumAllocatableRegisters ] ; <nl> - static const int kAllocationIndexByRegisterCode [ kNumRegisters ] ; <nl> + int reg_code ; <nl> } ; <nl> <nl> - const int kRegister_rax_Code = 0 ; <nl> - const int kRegister_rcx_Code = 1 ; <nl> - const int kRegister_rdx_Code = 2 ; <nl> - const int kRegister_rbx_Code = 3 ; <nl> - const int kRegister_rsp_Code = 4 ; <nl> - const int kRegister_rbp_Code = 5 ; <nl> - const int kRegister_rsi_Code = 6 ; <nl> - const int kRegister_rdi_Code = 7 ; <nl> - const int kRegister_r8_Code = 8 ; <nl> - const int kRegister_r9_Code = 9 ; <nl> - const int kRegister_r10_Code = 10 ; <nl> - const int kRegister_r11_Code = 11 ; <nl> - const int kRegister_r12_Code = 12 ; <nl> - const int kRegister_r13_Code = 13 ; <nl> - const int kRegister_r14_Code = 14 ; <nl> - const int kRegister_r15_Code = 15 ; <nl> - const int kRegister_no_reg_Code = - 1 ; <nl> - <nl> - const Register rax = { kRegister_rax_Code } ; <nl> - const Register rcx = { kRegister_rcx_Code } ; <nl> - const Register rdx = { kRegister_rdx_Code } ; <nl> - const Register rbx = { kRegister_rbx_Code } ; <nl> - const Register rsp = { kRegister_rsp_Code } ; <nl> - const Register rbp = { kRegister_rbp_Code } ; <nl> - const Register rsi = { kRegister_rsi_Code } ; <nl> - const Register rdi = { kRegister_rdi_Code } ; <nl> - const Register r8 = { kRegister_r8_Code } ; <nl> - const Register r9 = { kRegister_r9_Code } ; <nl> - const Register r10 = { kRegister_r10_Code } ; <nl> - const Register r11 = { kRegister_r11_Code } ; <nl> - const Register r12 = { kRegister_r12_Code } ; <nl> - const Register r13 = { kRegister_r13_Code } ; <nl> - const Register r14 = { kRegister_r14_Code } ; <nl> - const Register r15 = { kRegister_r15_Code } ; <nl> - const Register no_reg = { kRegister_no_reg_Code } ; <nl> + <nl> + # define DECLARE_REGISTER ( R ) const Register R = { Register : : kCode_ # # R } ; <nl> + GENERAL_REGISTERS ( DECLARE_REGISTER ) <nl> + # undef DECLARE_REGISTER <nl> + const Register no_reg = { Register : : kCode_no_reg } ; <nl> + <nl> <nl> # ifdef _WIN64 <nl> / / Windows calling convention <nl> - const Register arg_reg_1 = { kRegister_rcx_Code } ; <nl> - const Register arg_reg_2 = { kRegister_rdx_Code } ; <nl> - const Register arg_reg_3 = { kRegister_r8_Code } ; <nl> - const Register arg_reg_4 = { kRegister_r9_Code } ; <nl> + const Register arg_reg_1 = { Register : : kCode_rcx } ; <nl> + const Register arg_reg_2 = { Register : : kCode_rdx } ; <nl> + const Register arg_reg_3 = { Register : : kCode_r8 } ; <nl> + const Register arg_reg_4 = { Register : : kCode_r9 } ; <nl> # else <nl> / / AMD64 calling convention <nl> - const Register arg_reg_1 = { kRegister_rdi_Code } ; <nl> - const Register arg_reg_2 = { kRegister_rsi_Code } ; <nl> - const Register arg_reg_3 = { kRegister_rdx_Code } ; <nl> - const Register arg_reg_4 = { kRegister_rcx_Code } ; <nl> + const Register arg_reg_1 = { Register : : kCode_rdi } ; <nl> + const Register arg_reg_2 = { Register : : kCode_rsi } ; <nl> + const Register arg_reg_3 = { Register : : kCode_rdx } ; <nl> + const Register arg_reg_4 = { Register : : kCode_rcx } ; <nl> # endif / / _WIN64 <nl> <nl> - struct XMMRegister { <nl> - static const int kMaxNumRegisters = 16 ; <nl> - static const int kMaxNumAllocatableRegisters = 15 ; <nl> - static int NumAllocatableRegisters ( ) { <nl> - return kMaxNumAllocatableRegisters ; <nl> - } <nl> - <nl> - / / TODO ( turbofan ) : Proper support for float32 . <nl> - static int NumAllocatableAliasedRegisters ( ) { <nl> - return NumAllocatableRegisters ( ) ; <nl> - } <nl> - <nl> - static int ToAllocationIndex ( XMMRegister reg ) { <nl> - DCHECK ( reg . code ( ) ! = 0 ) ; <nl> - return reg . code ( ) - 1 ; <nl> - } <nl> <nl> - static XMMRegister FromAllocationIndex ( int index ) { <nl> - DCHECK ( 0 < = index & & index < kMaxNumAllocatableRegisters ) ; <nl> - XMMRegister result = { index + 1 } ; <nl> + # define DOUBLE_REGISTERS ( V ) \ <nl> + V ( xmm0 ) \ <nl> + V ( xmm1 ) \ <nl> + V ( xmm2 ) \ <nl> + V ( xmm3 ) \ <nl> + V ( xmm4 ) \ <nl> + V ( xmm5 ) \ <nl> + V ( xmm6 ) \ <nl> + V ( xmm7 ) \ <nl> + V ( xmm8 ) \ <nl> + V ( xmm9 ) \ <nl> + V ( xmm10 ) \ <nl> + V ( xmm11 ) \ <nl> + V ( xmm12 ) \ <nl> + V ( xmm13 ) \ <nl> + V ( xmm14 ) \ <nl> + V ( xmm15 ) <nl> + <nl> + # define ALLOCATABLE_DOUBLE_REGISTERS ( V ) \ <nl> + V ( xmm1 ) \ <nl> + V ( xmm2 ) \ <nl> + V ( xmm3 ) \ <nl> + V ( xmm4 ) \ <nl> + V ( xmm5 ) \ <nl> + V ( xmm6 ) \ <nl> + V ( xmm7 ) \ <nl> + V ( xmm8 ) \ <nl> + V ( xmm9 ) \ <nl> + V ( xmm10 ) \ <nl> + V ( xmm11 ) \ <nl> + V ( xmm12 ) \ <nl> + V ( xmm13 ) \ <nl> + V ( xmm14 ) \ <nl> + V ( xmm15 ) <nl> + <nl> + <nl> + struct DoubleRegister { <nl> + enum Code { <nl> + # define REGISTER_CODE ( R ) kCode_ # # R , <nl> + DOUBLE_REGISTERS ( REGISTER_CODE ) <nl> + # undef REGISTER_CODE <nl> + kAfterLast , <nl> + kCode_no_reg = - 1 <nl> + } ; <nl> + <nl> + static const int kMaxNumRegisters = Code : : kAfterLast ; <nl> + <nl> + static DoubleRegister from_code ( int code ) { <nl> + DoubleRegister result = { code } ; <nl> return result ; <nl> } <nl> <nl> - static const char * AllocationIndexToString ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - const char * const names [ ] = { <nl> - " xmm1 " , <nl> - " xmm2 " , <nl> - " xmm3 " , <nl> - " xmm4 " , <nl> - " xmm5 " , <nl> - " xmm6 " , <nl> - " xmm7 " , <nl> - " xmm8 " , <nl> - " xmm9 " , <nl> - " xmm10 " , <nl> - " xmm11 " , <nl> - " xmm12 " , <nl> - " xmm13 " , <nl> - " xmm14 " , <nl> - " xmm15 " <nl> - } ; <nl> - return names [ index ] ; <nl> - } <nl> - <nl> - static XMMRegister from_code ( int code ) { <nl> - DCHECK ( code > = 0 ) ; <nl> - DCHECK ( code < kMaxNumRegisters ) ; <nl> - XMMRegister r = { code } ; <nl> - return r ; <nl> - } <nl> - bool is_valid ( ) const { return 0 < = code_ & & code_ < kMaxNumRegisters ; } <nl> - bool is ( XMMRegister reg ) const { return code_ = = reg . code_ ; } <nl> + const char * ToString ( ) ; <nl> + bool IsAllocatable ( ) const ; <nl> + bool is_valid ( ) const { return 0 < = reg_code & & reg_code < kMaxNumRegisters ; } <nl> + bool is ( DoubleRegister reg ) const { return reg_code = = reg . reg_code ; } <nl> int code ( ) const { <nl> DCHECK ( is_valid ( ) ) ; <nl> - return code_ ; <nl> + return reg_code ; <nl> } <nl> <nl> / / Return the high bit of the register code as a 0 or 1 . Used often <nl> / / when constructing the REX prefix byte . <nl> - int high_bit ( ) const { <nl> - return code_ > > 3 ; <nl> - } <nl> + int high_bit ( ) const { return reg_code > > 3 ; } <nl> / / Return the 3 low bits of the register code . Used when encoding registers <nl> / / in modR / M , SIB , and opcode bytes . <nl> - int low_bits ( ) const { <nl> - return code_ & 0x7 ; <nl> - } <nl> + int low_bits ( ) const { return reg_code & 0x7 ; } <nl> <nl> - int code_ ; <nl> + / / Unfortunately we can ' t make this private in a struct when initializing <nl> + / / by assignment . <nl> + int reg_code ; <nl> } ; <nl> <nl> - const XMMRegister xmm0 = { 0 } ; <nl> - const XMMRegister xmm1 = { 1 } ; <nl> - const XMMRegister xmm2 = { 2 } ; <nl> - const XMMRegister xmm3 = { 3 } ; <nl> - const XMMRegister xmm4 = { 4 } ; <nl> - const XMMRegister xmm5 = { 5 } ; <nl> - const XMMRegister xmm6 = { 6 } ; <nl> - const XMMRegister xmm7 = { 7 } ; <nl> - const XMMRegister xmm8 = { 8 } ; <nl> - const XMMRegister xmm9 = { 9 } ; <nl> - const XMMRegister xmm10 = { 10 } ; <nl> - const XMMRegister xmm11 = { 11 } ; <nl> - const XMMRegister xmm12 = { 12 } ; <nl> - const XMMRegister xmm13 = { 13 } ; <nl> - const XMMRegister xmm14 = { 14 } ; <nl> - const XMMRegister xmm15 = { 15 } ; <nl> - <nl> - <nl> - typedef XMMRegister DoubleRegister ; <nl> <nl> + # define DECLARE_REGISTER ( R ) \ <nl> + const DoubleRegister R = { DoubleRegister : : kCode_ # # R } ; <nl> + DOUBLE_REGISTERS ( DECLARE_REGISTER ) <nl> + # undef DECLARE_REGISTER <nl> + const DoubleRegister no_double_reg = { DoubleRegister : : kCode_no_reg } ; <nl> + <nl> + <nl> + typedef DoubleRegister XMMRegister ; <nl> <nl> enum Condition { <nl> / / any value < 0 is considered no_condition <nl> mmm a / src / x64 / code - stubs - x64 . h <nl> ppp b / src / x64 / code - stubs - x64 . h <nl> class RecordWriteStub : public PlatformCodeStub { <nl> Register GetRegThatIsNotRcxOr ( Register r1 , <nl> Register r2 , <nl> Register r3 ) { <nl> - for ( int i = 0 ; i < Register : : NumAllocatableRegisters ( ) ; i + + ) { <nl> - Register candidate = Register : : FromAllocationIndex ( i ) ; <nl> - if ( candidate . is ( rcx ) ) continue ; <nl> - if ( candidate . is ( r1 ) ) continue ; <nl> - if ( candidate . is ( r2 ) ) continue ; <nl> - if ( candidate . is ( r3 ) ) continue ; <nl> - return candidate ; <nl> + for ( int i = 0 ; i < Register : : kNumRegisters ; i + + ) { <nl> + Register candidate = Register : : from_code ( i ) ; <nl> + if ( candidate . IsAllocatable ( ) ) { <nl> + if ( candidate . is ( rcx ) ) continue ; <nl> + if ( candidate . is ( r1 ) ) continue ; <nl> + if ( candidate . is ( r2 ) ) continue ; <nl> + if ( candidate . is ( r3 ) ) continue ; <nl> + return candidate ; <nl> + } <nl> } <nl> UNREACHABLE ( ) ; <nl> return no_reg ; <nl> mmm a / src / x64 / deoptimizer - x64 . cc <nl> ppp b / src / x64 / deoptimizer - x64 . cc <nl> <nl> # include " src / codegen . h " <nl> # include " src / deoptimizer . h " <nl> # include " src / full - codegen / full - codegen . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / safepoint - table . h " <nl> <nl> namespace v8 { <nl> void Deoptimizer : : FillInputFrame ( Address tos , JavaScriptFrame * frame ) { <nl> } <nl> input_ - > SetRegister ( rsp . code ( ) , reinterpret_cast < intptr_t > ( frame - > sp ( ) ) ) ; <nl> input_ - > SetRegister ( rbp . code ( ) , reinterpret_cast < intptr_t > ( frame - > fp ( ) ) ) ; <nl> - for ( int i = 0 ; i < DoubleRegister : : NumAllocatableRegisters ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < DoubleRegister : : kMaxNumRegisters ; i + + ) { <nl> input_ - > SetDoubleRegister ( i , 0 . 0 ) ; <nl> } <nl> <nl> void Deoptimizer : : SetPlatformCompiledStubRegisters ( <nl> <nl> <nl> void Deoptimizer : : CopyDoubleRegisters ( FrameDescription * output_frame ) { <nl> - for ( int i = 0 ; i < XMMRegister : : NumAllocatableRegisters ( ) ; + + i ) { <nl> + for ( int i = 0 ; i < XMMRegister : : kMaxNumRegisters ; + + i ) { <nl> double double_value = input_ - > GetDoubleRegister ( i ) ; <nl> output_frame - > SetDoubleRegister ( i , double_value ) ; <nl> } <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> / / Save all general purpose registers before messing with them . <nl> const int kNumberOfRegisters = Register : : kNumRegisters ; <nl> <nl> - const int kDoubleRegsSize = kDoubleSize * <nl> - XMMRegister : : NumAllocatableRegisters ( ) ; <nl> + const int kDoubleRegsSize = kDoubleSize * XMMRegister : : kMaxNumRegisters ; <nl> __ subp ( rsp , Immediate ( kDoubleRegsSize ) ) ; <nl> <nl> - for ( int i = 0 ; i < XMMRegister : : NumAllocatableRegisters ( ) ; + + i ) { <nl> - XMMRegister xmm_reg = XMMRegister : : FromAllocationIndex ( i ) ; <nl> - int offset = i * kDoubleSize ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + XMMRegister xmm_reg = XMMRegister : : from_code ( code ) ; <nl> + int offset = code * kDoubleSize ; <nl> __ movsd ( Operand ( rsp , offset ) , xmm_reg ) ; <nl> } <nl> <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> <nl> / / Fill in the double input registers . <nl> int double_regs_offset = FrameDescription : : double_registers_offset ( ) ; <nl> - for ( int i = 0 ; i < XMMRegister : : NumAllocatableRegisters ( ) ; i + + ) { <nl> + for ( int i = 0 ; i < XMMRegister : : kMaxNumRegisters ; i + + ) { <nl> int dst_offset = i * kDoubleSize + double_regs_offset ; <nl> __ popq ( Operand ( rbx , dst_offset ) ) ; <nl> } <nl> void Deoptimizer : : TableEntryGenerator : : Generate ( ) { <nl> __ cmpp ( rax , rdx ) ; <nl> __ j ( below , & outer_push_loop ) ; <nl> <nl> - for ( int i = 0 ; i < XMMRegister : : NumAllocatableRegisters ( ) ; + + i ) { <nl> - XMMRegister xmm_reg = XMMRegister : : FromAllocationIndex ( i ) ; <nl> - int src_offset = i * kDoubleSize + double_regs_offset ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + int code = config - > GetAllocatableDoubleCode ( i ) ; <nl> + XMMRegister xmm_reg = XMMRegister : : from_code ( code ) ; <nl> + int src_offset = code * kDoubleSize + double_regs_offset ; <nl> __ movsd ( xmm_reg , Operand ( rbx , src_offset ) ) ; <nl> } <nl> <nl> mmm a / src / x64 / lithium - codegen - x64 . cc <nl> ppp b / src / x64 / lithium - codegen - x64 . cc <nl> void LCodeGen : : SaveCallerDoubles ( ) { <nl> BitVector : : Iterator save_iterator ( doubles ) ; <nl> while ( ! save_iterator . Done ( ) ) { <nl> __ movsd ( MemOperand ( rsp , count * kDoubleSize ) , <nl> - XMMRegister : : FromAllocationIndex ( save_iterator . Current ( ) ) ) ; <nl> + XMMRegister : : from_code ( save_iterator . Current ( ) ) ) ; <nl> save_iterator . Advance ( ) ; <nl> count + + ; <nl> } <nl> void LCodeGen : : RestoreCallerDoubles ( ) { <nl> BitVector : : Iterator save_iterator ( doubles ) ; <nl> int count = 0 ; <nl> while ( ! save_iterator . Done ( ) ) { <nl> - __ movsd ( XMMRegister : : FromAllocationIndex ( save_iterator . Current ( ) ) , <nl> + __ movsd ( XMMRegister : : from_code ( save_iterator . Current ( ) ) , <nl> MemOperand ( rsp , count * kDoubleSize ) ) ; <nl> save_iterator . Advance ( ) ; <nl> count + + ; <nl> bool LCodeGen : : GenerateSafepointTable ( ) { <nl> <nl> <nl> Register LCodeGen : : ToRegister ( int index ) const { <nl> - return Register : : FromAllocationIndex ( index ) ; <nl> + return Register : : from_code ( index ) ; <nl> } <nl> <nl> <nl> XMMRegister LCodeGen : : ToDoubleRegister ( int index ) const { <nl> - return XMMRegister : : FromAllocationIndex ( index ) ; <nl> + return XMMRegister : : from_code ( index ) ; <nl> } <nl> <nl> <nl> mmm a / src / x64 / lithium - x64 . cc <nl> ppp b / src / x64 / lithium - x64 . cc <nl> LPlatformChunk * LChunkBuilder : : Build ( ) { <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( Register reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , <nl> - Register : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> LUnallocated * LChunkBuilder : : ToUnallocated ( XMMRegister reg ) { <nl> - return new ( zone ( ) ) LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , <nl> - XMMRegister : : ToAllocationIndex ( reg ) ) ; <nl> + return new ( zone ( ) ) <nl> + LUnallocated ( LUnallocated : : FIXED_DOUBLE_REGISTER , reg . code ( ) ) ; <nl> } <nl> <nl> <nl> mmm a / src / x64 / macro - assembler - x64 . cc <nl> ppp b / src / x64 / macro - assembler - x64 . cc <nl> <nl> # include " src / cpu - profiler . h " <nl> # include " src / debug / debug . h " <nl> # include " src / heap / heap . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / x64 / assembler - x64 . h " <nl> # include " src / x64 / macro - assembler - x64 . h " <nl> <nl> void MacroAssembler : : GetBuiltinEntry ( Register target , <nl> } <nl> <nl> <nl> - # define REG ( Name ) { kRegister_ # # Name # # _Code } <nl> + # define REG ( Name ) \ <nl> + { Register : : kCode_ # # Name } <nl> <nl> static const Register saved_regs [ ] = { <nl> REG ( rax ) , REG ( rcx ) , REG ( rdx ) , REG ( rbx ) , REG ( rbp ) , REG ( rsi ) , REG ( rdi ) , REG ( r8 ) , <nl> void MacroAssembler : : EnterExitFrameEpilogue ( int arg_stack_space , <nl> # endif <nl> / / Optionally save all XMM registers . <nl> if ( save_doubles ) { <nl> - int space = XMMRegister : : kMaxNumAllocatableRegisters * kDoubleSize + <nl> - arg_stack_space * kRegisterSize ; <nl> + int space = XMMRegister : : kMaxNumRegisters * kDoubleSize + <nl> + arg_stack_space * kRegisterSize ; <nl> subp ( rsp , Immediate ( space ) ) ; <nl> int offset = - 2 * kPointerSize ; <nl> - for ( int i = 0 ; i < XMMRegister : : NumAllocatableRegisters ( ) ; i + + ) { <nl> - XMMRegister reg = XMMRegister : : FromAllocationIndex ( i ) ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + DoubleRegister reg = <nl> + DoubleRegister : : from_code ( config - > GetAllocatableDoubleCode ( i ) ) ; <nl> movsd ( Operand ( rbp , offset - ( ( i + 1 ) * kDoubleSize ) ) , reg ) ; <nl> } <nl> } else if ( arg_stack_space > 0 ) { <nl> void MacroAssembler : : LeaveExitFrame ( bool save_doubles ) { <nl> / / r15 : argv <nl> if ( save_doubles ) { <nl> int offset = - 2 * kPointerSize ; <nl> - for ( int i = 0 ; i < XMMRegister : : NumAllocatableRegisters ( ) ; i + + ) { <nl> - XMMRegister reg = XMMRegister : : FromAllocationIndex ( i ) ; <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( int i = 0 ; i < config - > num_allocatable_double_registers ( ) ; + + i ) { <nl> + DoubleRegister reg = <nl> + DoubleRegister : : from_code ( config - > GetAllocatableDoubleCode ( i ) ) ; <nl> movsd ( reg , Operand ( rbp , offset - ( ( i + 1 ) * kDoubleSize ) ) ) ; <nl> } <nl> } <nl> mmm a / src / x64 / macro - assembler - x64 . h <nl> ppp b / src / x64 / macro - assembler - x64 . h <nl> namespace v8 { <nl> namespace internal { <nl> <nl> / / Give alias names to registers for calling conventions . <nl> - const Register kReturnRegister0 = { kRegister_rax_Code } ; <nl> - const Register kReturnRegister1 = { kRegister_rdx_Code } ; <nl> - const Register kJSFunctionRegister = { kRegister_rdi_Code } ; <nl> - const Register kContextRegister = { kRegister_rsi_Code } ; <nl> - const Register kInterpreterAccumulatorRegister = { kRegister_rax_Code } ; <nl> - const Register kInterpreterRegisterFileRegister = { kRegister_r11_Code } ; <nl> - const Register kInterpreterBytecodeOffsetRegister = { kRegister_r12_Code } ; <nl> - const Register kInterpreterBytecodeArrayRegister = { kRegister_r14_Code } ; <nl> - const Register kInterpreterDispatchTableRegister = { kRegister_r15_Code } ; <nl> - const Register kRuntimeCallFunctionRegister = { kRegister_rbx_Code } ; <nl> - const Register kRuntimeCallArgCountRegister = { kRegister_rax_Code } ; <nl> + const Register kReturnRegister0 = { Register : : kCode_rax } ; <nl> + const Register kReturnRegister1 = { Register : : kCode_rdx } ; <nl> + const Register kJSFunctionRegister = { Register : : kCode_rdi } ; <nl> + const Register kContextRegister = { Register : : kCode_rsi } ; <nl> + const Register kInterpreterAccumulatorRegister = { Register : : kCode_rax } ; <nl> + const Register kInterpreterRegisterFileRegister = { Register : : kCode_r11 } ; <nl> + const Register kInterpreterBytecodeOffsetRegister = { Register : : kCode_r12 } ; <nl> + const Register kInterpreterBytecodeArrayRegister = { Register : : kCode_r14 } ; <nl> + const Register kInterpreterDispatchTableRegister = { Register : : kCode_r15 } ; <nl> + const Register kRuntimeCallFunctionRegister = { Register : : kCode_rbx } ; <nl> + const Register kRuntimeCallArgCountRegister = { Register : : kCode_rax } ; <nl> <nl> / / Default scratch register used by MacroAssembler ( and other code that needs <nl> / / a spare register ) . The register isn ' t callee save , and not used by the <nl> mmm a / src / x87 / assembler - x87 . h <nl> ppp b / src / x87 / assembler - x87 . h <nl> struct Register { <nl> <nl> static inline const char * AllocationIndexToString ( int index ) ; <nl> <nl> - static inline int ToAllocationIndex ( Register reg ) ; <nl> - <nl> - static inline Register FromAllocationIndex ( int index ) ; <nl> - <nl> static Register from_code ( int code ) { <nl> DCHECK ( code > = 0 ) ; <nl> DCHECK ( code < kNumRegisters ) ; <nl> inline const char * Register : : AllocationIndexToString ( int index ) { <nl> } <nl> <nl> <nl> - inline int Register : : ToAllocationIndex ( Register reg ) { <nl> - DCHECK ( reg . is_valid ( ) & & ! reg . is ( esp ) & & ! reg . is ( ebp ) ) ; <nl> - return ( reg . code ( ) > = 6 ) ? reg . code ( ) - 2 : reg . code ( ) ; <nl> - } <nl> - <nl> - <nl> - inline Register Register : : FromAllocationIndex ( int index ) { <nl> - DCHECK ( index > = 0 & & index < kMaxNumAllocatableRegisters ) ; <nl> - return ( index > = 4 ) ? from_code ( index + 2 ) : from_code ( index ) ; <nl> - } <nl> - <nl> - <nl> struct X87Register { <nl> static const int kMaxNumAllocatableRegisters = 6 ; <nl> static const int kMaxNumRegisters = 8 ; <nl> mmm a / test / cctest / compiler / test - gap - resolver . cc <nl> ppp b / test / cctest / compiler / test - gap - resolver . cc <nl> class InterpreterState { <nl> AllocatedOperand : : AllocatedKind kind ; <nl> int index ; <nl> if ( ! is_constant ) { <nl> - index = AllocatedOperand : : cast ( op ) . index ( ) ; <nl> + if ( op . IsRegister ( ) ) { <nl> + index = AllocatedOperand : : cast ( op ) . GetRegister ( ) . code ( ) ; <nl> + } else if ( op . IsDoubleRegister ( ) ) { <nl> + index = AllocatedOperand : : cast ( op ) . GetDoubleRegister ( ) . code ( ) ; <nl> + } else { <nl> + index = AllocatedOperand : : cast ( op ) . index ( ) ; <nl> + } <nl> kind = AllocatedOperand : : cast ( op ) . allocated_kind ( ) ; <nl> } else { <nl> index = ConstantOperand : : cast ( op ) . virtual_register ( ) ; <nl> class InterpreterState { <nl> return ConstantOperand ( key . index ) ; <nl> } <nl> return AllocatedOperand ( <nl> - key . kind , InstructionSequence : : DefaultRepresentation ( ) , key . index ) ; <nl> + key . kind , <nl> + v8 : : internal : : compiler : : InstructionSequence : : DefaultRepresentation ( ) , <nl> + key . index ) ; <nl> } <nl> <nl> friend std : : ostream & operator < < ( std : : ostream & os , <nl> mmm a / test / cctest / compiler / test - run - native - calls . cc <nl> ppp b / test / cctest / compiler / test - run - native - calls . cc <nl> <nl> # include " src / compiler / linkage . h " <nl> # include " src / compiler / machine - type . h " <nl> # include " src / compiler / raw - machine - assembler . h " <nl> + # include " src / register - configuration . h " <nl> <nl> # include " test / cctest / cctest . h " <nl> # include " test / cctest / compiler / codegen - tester . h " <nl> typedef double float64 ; <nl> / / to select a representative set . <nl> class Pairs { <nl> public : <nl> - Pairs ( int max_pairs , int range ) <nl> + Pairs ( int max_pairs , int range , const int * codes ) <nl> : range_ ( range ) , <nl> + codes_ ( codes ) , <nl> max_pairs_ ( std : : min ( max_pairs , range_ * range_ ) ) , <nl> counter_ ( 0 ) { } <nl> <nl> class Pairs { <nl> do { <nl> / / Find the next pair . <nl> if ( exhaustive ( ) ) { <nl> - * r0 = counter_ % range_ ; <nl> - * r1 = counter_ / range_ ; <nl> + * r0 = codes_ [ counter_ % range_ ] ; <nl> + * r1 = codes_ [ counter_ / range_ ] ; <nl> } else { <nl> / / Try each integer at least once for both r0 and r1 . <nl> int index = counter_ / 2 ; <nl> if ( counter_ & 1 ) { <nl> - * r0 = index % range_ ; <nl> - * r1 = index / range_ ; <nl> + * r0 = codes_ [ index % range_ ] ; <nl> + * r1 = codes_ [ index / range_ ] ; <nl> } else { <nl> - * r1 = index % range_ ; <nl> - * r0 = index / range_ ; <nl> + * r1 = codes_ [ index % range_ ] ; <nl> + * r0 = codes_ [ index / range_ ] ; <nl> } <nl> } <nl> counter_ + + ; <nl> - if ( same_is_ok ) break ; <nl> - if ( * r0 = = * r1 ) { <nl> - if ( counter_ > = max_pairs_ ) { <nl> - / / For the last hurrah , reg # 0 with reg # n - 1 <nl> - * r0 = 0 ; <nl> - * r1 = range_ - 1 ; <nl> - break ; <nl> - } <nl> + if ( ( same_is_ok ) | | ( * r0 ! = * r1 ) ) break ; <nl> + if ( counter_ = = max_pairs_ ) { <nl> + / / For the last hurrah , reg # 0 with reg # n - 1 <nl> + * r0 = codes_ [ 0 ] ; <nl> + * r1 = codes_ [ range_ - 1 ] ; <nl> + break ; <nl> } <nl> } while ( true ) ; <nl> - <nl> - DCHECK ( * r0 > = 0 & & * r0 < range_ ) ; <nl> - DCHECK ( * r1 > = 0 & & * r1 < range_ ) ; <nl> } <nl> <nl> private : <nl> int range_ ; <nl> + const int * codes_ ; <nl> int max_pairs_ ; <nl> int counter_ ; <nl> bool exhaustive ( ) { return max_pairs_ = = ( range_ * range_ ) ; } <nl> class Pairs { <nl> / / Pairs of general purpose registers . <nl> class RegisterPairs : public Pairs { <nl> public : <nl> - RegisterPairs ( ) : Pairs ( 100 , Register : : kMaxNumAllocatableRegisters ) { } <nl> + RegisterPairs ( ) <nl> + : Pairs ( <nl> + 100 , RegisterConfiguration : : ArchDefault ( ) <nl> + - > num_allocatable_general_registers ( ) , <nl> + RegisterConfiguration : : ArchDefault ( ) - > allocatable_general_codes ( ) ) { <nl> + } <nl> } ; <nl> <nl> <nl> class RegisterPairs : public Pairs { <nl> class Float32RegisterPairs : public Pairs { <nl> public : <nl> Float32RegisterPairs ( ) <nl> - : Pairs ( 100 , DoubleRegister : : NumAllocatableAliasedRegisters ( ) ) { } <nl> + : Pairs ( <nl> + 100 , RegisterConfiguration : : ArchDefault ( ) <nl> + - > num_allocatable_aliased_double_registers ( ) , <nl> + RegisterConfiguration : : ArchDefault ( ) - > allocatable_double_codes ( ) ) { } <nl> } ; <nl> <nl> <nl> class Float32RegisterPairs : public Pairs { <nl> class Float64RegisterPairs : public Pairs { <nl> public : <nl> Float64RegisterPairs ( ) <nl> - : Pairs ( 100 , DoubleRegister : : NumAllocatableAliasedRegisters ( ) ) { } <nl> + : Pairs ( <nl> + 100 , RegisterConfiguration : : ArchDefault ( ) <nl> + - > num_allocatable_aliased_double_registers ( ) , <nl> + RegisterConfiguration : : ArchDefault ( ) - > allocatable_double_codes ( ) ) { } <nl> } ; <nl> <nl> <nl> static void Test_RunInt32SubWithRet ( int retreg ) { <nl> <nl> <nl> / / Separate tests for parallelization . <nl> - # define TEST_INT32_SUB_WITH_RET ( x ) \ <nl> - TEST ( Run_Int32Sub_all_allocatable_pairs_ # # x ) { \ <nl> - if ( Register : : kMaxNumAllocatableRegisters > x ) Test_RunInt32SubWithRet ( x ) ; \ <nl> + # define TEST_INT32_SUB_WITH_RET ( x ) \ <nl> + TEST ( Run_Int32Sub_all_allocatable_pairs_ # # x ) { \ <nl> + if ( x < Register : : kNumRegisters & & \ <nl> + Register : : from_code ( x ) . IsAllocatable ( ) ) { \ <nl> + Test_RunInt32SubWithRet ( x ) ; \ <nl> + } \ <nl> } <nl> <nl> <nl> TEST ( Run_CopyTwentyInt32_all_allocatable_pairs ) { <nl> while ( pairs . More ( ) ) { <nl> Zone zone ; <nl> int parray [ 2 ] ; <nl> - int rarray [ ] = { 0 } ; <nl> + int rarray [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableGeneralCode ( 0 ) } ; <nl> pairs . Next ( & parray [ 0 ] , & parray [ 1 ] , false ) ; <nl> Allocator params ( parray , 2 , nullptr , 0 ) ; <nl> Allocator rets ( rarray , 1 , nullptr , 0 ) ; <nl> static int32_t Compute_Int32_WeightedSum ( CallDescriptor * desc , int32_t * input ) { <nl> static void Test_Int32_WeightedSum_of_size ( int count ) { <nl> if ( DISABLE_NATIVE_STACK_PARAMS ) return ; <nl> Int32Signature sig ( count ) ; <nl> - for ( int p0 = 0 ; p0 < Register : : kMaxNumAllocatableRegisters ; p0 + + ) { <nl> - Zone zone ; <nl> + for ( int p0 = 0 ; p0 < Register : : kNumRegisters ; p0 + + ) { <nl> + if ( Register : : from_code ( p0 ) . IsAllocatable ( ) ) { <nl> + Zone zone ; <nl> <nl> - int parray [ ] = { p0 } ; <nl> - int rarray [ ] = { 0 } ; <nl> - Allocator params ( parray , 1 , nullptr , 0 ) ; <nl> - Allocator rets ( rarray , 1 , nullptr , 0 ) ; <nl> - RegisterConfig config ( params , rets ) ; <nl> - CallDescriptor * desc = config . Create ( & zone , & sig ) ; <nl> - Run_Computation < int32_t > ( desc , Build_Int32_WeightedSum , <nl> - Compute_Int32_WeightedSum , 257 + count ) ; <nl> + int parray [ ] = { p0 } ; <nl> + int rarray [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableGeneralCode ( 0 ) } ; <nl> + Allocator params ( parray , 1 , nullptr , 0 ) ; <nl> + Allocator rets ( rarray , 1 , nullptr , 0 ) ; <nl> + RegisterConfig config ( params , rets ) ; <nl> + CallDescriptor * desc = config . Create ( & zone , & sig ) ; <nl> + Run_Computation < int32_t > ( desc , Build_Int32_WeightedSum , <nl> + Compute_Int32_WeightedSum , 257 + count ) ; <nl> + } <nl> } <nl> } <nl> <nl> template < int which > <nl> void Test_Int32_Select ( ) { <nl> if ( DISABLE_NATIVE_STACK_PARAMS ) return ; <nl> <nl> - int parray [ ] = { 0 } ; <nl> - int rarray [ ] = { 0 } ; <nl> + int parray [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableGeneralCode ( 0 ) } ; <nl> + int rarray [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableGeneralCode ( 0 ) } ; <nl> Allocator params ( parray , 1 , nullptr , 0 ) ; <nl> Allocator rets ( rarray , 1 , nullptr , 0 ) ; <nl> RegisterConfig config ( params , rets ) ; <nl> TEST_INT32_SELECT ( 63 ) <nl> <nl> <nl> TEST ( Int64Select_registers ) { <nl> - if ( Register : : kMaxNumAllocatableRegisters < 2 ) return ; <nl> + if ( RegisterConfiguration : : ArchDefault ( ) <nl> + - > num_allocatable_general_registers ( ) < 2 ) <nl> + return ; <nl> if ( kPointerSize < 8 ) return ; / / TODO ( titzer ) : int64 on 32 - bit platforms <nl> <nl> - int rarray [ ] = { 0 } ; <nl> + int rarray [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableGeneralCode ( 0 ) } ; <nl> ArgsBuffer < int64_t > : : Sig sig ( 2 ) ; <nl> <nl> RegisterPairs pairs ; <nl> TEST ( Int64Select_registers ) { <nl> <nl> <nl> TEST ( Float32Select_registers ) { <nl> - if ( RegisterConfiguration : : ArchDefault ( ) - > num_double_registers ( ) < 2 ) return ; <nl> + if ( RegisterConfiguration : : ArchDefault ( ) - > num_allocatable_double_registers ( ) < <nl> + 2 ) { <nl> + return ; <nl> + } <nl> <nl> - int rarray [ ] = { 0 } ; <nl> + int rarray [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableDoubleCode ( 0 ) } ; <nl> ArgsBuffer < float32 > : : Sig sig ( 2 ) ; <nl> <nl> Float32RegisterPairs pairs ; <nl> TEST ( Float32Select_registers ) { <nl> <nl> <nl> TEST ( Float64Select_registers ) { <nl> - if ( RegisterConfiguration : : ArchDefault ( ) - > num_double_registers ( ) < 2 ) return ; <nl> - <nl> - int rarray [ ] = { 0 } ; <nl> + if ( RegisterConfiguration : : ArchDefault ( ) - > num_allocatable_double_registers ( ) < <nl> + 2 ) <nl> + return ; <nl> + if ( RegisterConfiguration : : ArchDefault ( ) <nl> + - > num_allocatable_general_registers ( ) < 2 ) <nl> + return ; <nl> + int rarray [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableDoubleCode ( 0 ) } ; <nl> ArgsBuffer < float64 > : : Sig sig ( 2 ) ; <nl> <nl> Float64RegisterPairs pairs ; <nl> TEST ( Float64Select_registers ) { <nl> <nl> TEST ( Float32Select_stack_params_return_reg ) { <nl> if ( DISABLE_NATIVE_STACK_PARAMS ) return ; <nl> - int rarray [ ] = { 0 } ; <nl> + int rarray [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableDoubleCode ( 0 ) } ; <nl> Allocator params ( nullptr , 0 , nullptr , 0 ) ; <nl> Allocator rets ( nullptr , 0 , rarray , 1 ) ; <nl> RegisterConfig config ( params , rets ) ; <nl> TEST ( Float32Select_stack_params_return_reg ) { <nl> <nl> TEST ( Float64Select_stack_params_return_reg ) { <nl> if ( DISABLE_NATIVE_STACK_PARAMS ) return ; <nl> - int rarray [ ] = { 0 } ; <nl> + int rarray [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableDoubleCode ( 0 ) } ; <nl> Allocator params ( nullptr , 0 , nullptr , 0 ) ; <nl> Allocator rets ( nullptr , 0 , rarray , 1 ) ; <nl> RegisterConfig config ( params , rets ) ; <nl> static void Build_Select_With_Call ( CallDescriptor * desc , <nl> TEST ( Float64StackParamsToStackParams ) { <nl> if ( DISABLE_NATIVE_STACK_PARAMS ) return ; <nl> <nl> - int rarray [ ] = { 0 } ; <nl> + int rarray [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableDoubleCode ( 0 ) } ; <nl> Allocator params ( nullptr , 0 , nullptr , 0 ) ; <nl> Allocator rets ( nullptr , 0 , rarray , 1 ) ; <nl> <nl> void MixedParamTest ( int start ) { <nl> const int num_params = static_cast < int > ( arraysize ( types ) - start ) ; <nl> <nl> / / Build call descriptor <nl> - int parray [ ] = { 0 , 1 } ; <nl> - int rarray [ ] = { 0 } ; <nl> - Allocator palloc ( parray , 2 , parray , 2 ) ; <nl> - Allocator ralloc ( rarray , 1 , rarray , 1 ) ; <nl> + int parray_gp [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableGeneralCode ( 0 ) , <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableGeneralCode ( 1 ) } ; <nl> + int rarray_gp [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableGeneralCode ( 0 ) } ; <nl> + int parray_fp [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableDoubleCode ( 0 ) , <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableDoubleCode ( 1 ) } ; <nl> + int rarray_fp [ ] = { <nl> + RegisterConfiguration : : ArchDefault ( ) - > GetAllocatableDoubleCode ( 0 ) } ; <nl> + Allocator palloc ( parray_gp , 2 , parray_fp , 2 ) ; <nl> + Allocator ralloc ( rarray_gp , 1 , rarray_fp , 1 ) ; <nl> RegisterConfig config ( palloc , ralloc ) ; <nl> <nl> for ( int which = 0 ; which < num_params ; which + + ) { <nl> mmm a / test / cctest / test - code - stubs - arm . cc <nl> ppp b / test / cctest / test - code - stubs - arm . cc <nl> ConvertDToIFunc MakeConvertDToIFuncTrampoline ( Isolate * isolate , <nl> / / Save registers make sure they don ' t get clobbered . <nl> int source_reg_offset = kDoubleSize ; <nl> int reg_num = 0 ; <nl> - for ( ; reg_num < Register : : NumAllocatableRegisters ( ) ; + + reg_num ) { <nl> + for ( ; reg_num < Register : : kNumRegisters ; + + reg_num ) { <nl> Register reg = Register : : from_code ( reg_num ) ; <nl> - if ( ! reg . is ( destination_reg ) ) { <nl> - __ push ( reg ) ; <nl> - source_reg_offset + = kPointerSize ; <nl> + if ( reg . IsAllocatable ( ) ) { <nl> + if ( ! reg . is ( destination_reg ) ) { <nl> + __ push ( reg ) ; <nl> + source_reg_offset + = kPointerSize ; <nl> + } <nl> } <nl> } <nl> <nl> ConvertDToIFunc MakeConvertDToIFuncTrampoline ( Isolate * isolate , <nl> / / Make sure no registers have been unexpectedly clobbered <nl> for ( - - reg_num ; reg_num > = 0 ; - - reg_num ) { <nl> Register reg = Register : : from_code ( reg_num ) ; <nl> - if ( ! reg . is ( destination_reg ) ) { <nl> - __ ldr ( ip , MemOperand ( sp , 0 ) ) ; <nl> - __ cmp ( reg , ip ) ; <nl> - __ Assert ( eq , kRegisterWasClobbered ) ; <nl> - __ add ( sp , sp , Operand ( kPointerSize ) ) ; <nl> + if ( reg . IsAllocatable ( ) ) { <nl> + if ( ! reg . is ( destination_reg ) ) { <nl> + __ ldr ( ip , MemOperand ( sp , 0 ) ) ; <nl> + __ cmp ( reg , ip ) ; <nl> + __ Assert ( eq , kRegisterWasClobbered ) ; <nl> + __ add ( sp , sp , Operand ( kPointerSize ) ) ; <nl> + } <nl> } <nl> } <nl> <nl> mmm a / test / cctest / test - code - stubs - arm64 . cc <nl> ppp b / test / cctest / test - code - stubs - arm64 . cc <nl> ConvertDToIFunc MakeConvertDToIFuncTrampoline ( Isolate * isolate , <nl> / / Save registers make sure they don ' t get clobbered . <nl> int source_reg_offset = kDoubleSize ; <nl> int reg_num = 0 ; <nl> - for ( ; reg_num < Register : : NumAllocatableRegisters ( ) ; + + reg_num ) { <nl> + for ( ; reg_num < Register : : kNumRegisters ; + + reg_num ) { <nl> Register reg = Register : : from_code ( reg_num ) ; <nl> - if ( ! reg . is ( destination_reg ) ) { <nl> - queue . Queue ( reg ) ; <nl> - source_reg_offset + = kPointerSize ; <nl> + if ( reg . IsAllocatable ( ) ) { <nl> + if ( ! reg . is ( destination_reg ) ) { <nl> + queue . Queue ( reg ) ; <nl> + source_reg_offset + = kPointerSize ; <nl> + } <nl> } <nl> } <nl> / / Re - push the double argument . <nl> ConvertDToIFunc MakeConvertDToIFuncTrampoline ( Isolate * isolate , <nl> / / / / Make sure no registers have been unexpectedly clobbered <nl> for ( - - reg_num ; reg_num > = 0 ; - - reg_num ) { <nl> Register reg = Register : : from_code ( reg_num ) ; <nl> - if ( ! reg . is ( destination_reg ) ) { <nl> - __ Pop ( ip0 ) ; <nl> - __ cmp ( reg , ip0 ) ; <nl> - __ Assert ( eq , kRegisterWasClobbered ) ; <nl> + if ( reg . IsAllocatable ( ) ) { <nl> + if ( ! reg . is ( destination_reg ) ) { <nl> + __ Pop ( ip0 ) ; <nl> + __ cmp ( reg , ip0 ) ; <nl> + __ Assert ( eq , kRegisterWasClobbered ) ; <nl> + } <nl> } <nl> } <nl> <nl> mmm a / test / cctest / test - code - stubs - ia32 . cc <nl> ppp b / test / cctest / test - code - stubs - ia32 . cc <nl> ConvertDToIFunc MakeConvertDToIFuncTrampoline ( Isolate * isolate , <nl> int param_offset = 7 * kPointerSize ; <nl> / / Save registers make sure they don ' t get clobbered . <nl> int reg_num = 0 ; <nl> - for ( ; reg_num < Register : : NumAllocatableRegisters ( ) ; + + reg_num ) { <nl> - Register reg = Register : : FromAllocationIndex ( reg_num ) ; <nl> - if ( ! reg . is ( esp ) & & ! reg . is ( ebp ) & & ! reg . is ( destination_reg ) ) { <nl> - __ push ( reg ) ; <nl> - param_offset + = kPointerSize ; <nl> + for ( ; reg_num < Register : : kNumRegisters ; + + reg_num ) { <nl> + Register reg = Register : : from_code ( reg_num ) ; <nl> + if ( reg . IsAllocatable ( ) ) { <nl> + if ( ! reg . is ( esp ) & & ! reg . is ( ebp ) & & ! reg . is ( destination_reg ) ) { <nl> + __ push ( reg ) ; <nl> + param_offset + = kPointerSize ; <nl> + } <nl> } <nl> } <nl> <nl> ConvertDToIFunc MakeConvertDToIFuncTrampoline ( Isolate * isolate , <nl> <nl> / / Make sure no registers have been unexpectedly clobbered <nl> for ( - - reg_num ; reg_num > = 0 ; - - reg_num ) { <nl> - Register reg = Register : : FromAllocationIndex ( reg_num ) ; <nl> - if ( ! reg . is ( esp ) & & ! reg . is ( ebp ) & & ! reg . is ( destination_reg ) ) { <nl> - __ cmp ( reg , MemOperand ( esp , 0 ) ) ; <nl> - __ Assert ( equal , kRegisterWasClobbered ) ; <nl> - __ add ( esp , Immediate ( kPointerSize ) ) ; <nl> + Register reg = Register : : from_code ( reg_num ) ; <nl> + if ( reg . IsAllocatable ( ) ) { <nl> + if ( ! reg . is ( esp ) & & ! reg . is ( ebp ) & & ! reg . is ( destination_reg ) ) { <nl> + __ cmp ( reg , MemOperand ( esp , 0 ) ) ; <nl> + __ Assert ( equal , kRegisterWasClobbered ) ; <nl> + __ add ( esp , Immediate ( kPointerSize ) ) ; <nl> + } <nl> } <nl> } <nl> <nl> mmm a / test / cctest / test - code - stubs - mips . cc <nl> ppp b / test / cctest / test - code - stubs - mips . cc <nl> <nl> # include " src / factory . h " <nl> # include " src / macro - assembler . h " <nl> # include " src / mips / constants - mips . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / simulator . h " <nl> # include " test / cctest / cctest . h " <nl> # include " test / cctest / test - code - stubs . h " <nl> ConvertDToIFunc MakeConvertDToIFuncTrampoline ( Isolate * isolate , <nl> / / Save registers make sure they don ' t get clobbered . <nl> int source_reg_offset = kDoubleSize ; <nl> int reg_num = 2 ; <nl> - for ( ; reg_num < Register : : NumAllocatableRegisters ( ) ; + + reg_num ) { <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( ; reg_num < config - > num_allocatable_general_registers ( ) ; + + reg_num ) { <nl> Register reg = Register : : from_code ( reg_num ) ; <nl> if ( ! reg . is ( destination_reg ) ) { <nl> __ push ( reg ) ; <nl> mmm a / test / cctest / test - code - stubs - mips64 . cc <nl> ppp b / test / cctest / test - code - stubs - mips64 . cc <nl> <nl> # include " src / factory . h " <nl> # include " src / macro - assembler . h " <nl> # include " src / mips64 / constants - mips64 . h " <nl> + # include " src / register - configuration . h " <nl> # include " src / simulator . h " <nl> # include " test / cctest / cctest . h " <nl> # include " test / cctest / test - code - stubs . h " <nl> ConvertDToIFunc MakeConvertDToIFuncTrampoline ( Isolate * isolate , <nl> / / Save registers make sure they don ' t get clobbered . <nl> int source_reg_offset = kDoubleSize ; <nl> int reg_num = 2 ; <nl> - for ( ; reg_num < Register : : NumAllocatableRegisters ( ) ; + + reg_num ) { <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> + for ( ; reg_num < config - > num_allocatable_general_registers ( ) ; + + reg_num ) { <nl> Register reg = Register : : from_code ( reg_num ) ; <nl> if ( ! reg . is ( destination_reg ) ) { <nl> __ push ( reg ) ; <nl> mmm a / test / cctest / test - code - stubs - x64 . cc <nl> ppp b / test / cctest / test - code - stubs - x64 . cc <nl> <nl> # include " src / code - stubs . h " <nl> # include " src / factory . h " <nl> # include " src / macro - assembler . h " <nl> + # include " src / register - configuration . h " <nl> # include " test / cctest / cctest . h " <nl> # include " test / cctest / test - code - stubs . h " <nl> <nl> ConvertDToIFunc MakeConvertDToIFuncTrampoline ( Isolate * isolate , <nl> __ pushq ( rsi ) ; <nl> __ pushq ( rdi ) ; <nl> <nl> + <nl> + const RegisterConfiguration * config = RegisterConfiguration : : ArchDefault ( ) ; <nl> if ( ! source_reg . is ( rsp ) ) { <nl> / / The argument we pass to the stub is not a heap number , but instead <nl> / / stack - allocated and offset - wise made to look like a heap number for <nl> / / the stub . We create that " heap number " after pushing all allocatable <nl> / / registers . <nl> int double_argument_slot = <nl> - ( Register : : NumAllocatableRegisters ( ) - 1 ) * kPointerSize + kDoubleSize ; <nl> + ( config - > num_allocatable_general_registers ( ) - 1 ) * kPointerSize + <nl> + kDoubleSize ; <nl> __ leaq ( source_reg , MemOperand ( rsp , - double_argument_slot - offset ) ) ; <nl> } <nl> <nl> / / Save registers make sure they don ' t get clobbered . <nl> int reg_num = 0 ; <nl> - for ( ; reg_num < Register : : NumAllocatableRegisters ( ) ; + + reg_num ) { <nl> - Register reg = Register : : FromAllocationIndex ( reg_num ) ; <nl> + for ( ; reg_num < config - > num_allocatable_general_registers ( ) ; + + reg_num ) { <nl> + Register reg = <nl> + Register : : from_code ( config - > GetAllocatableGeneralCode ( reg_num ) ) ; <nl> if ( ! reg . is ( rsp ) & & ! reg . is ( rbp ) & & ! reg . is ( destination_reg ) ) { <nl> __ pushq ( reg ) ; <nl> } <nl> ConvertDToIFunc MakeConvertDToIFuncTrampoline ( Isolate * isolate , <nl> <nl> / / Make sure no registers have been unexpectedly clobbered <nl> for ( - - reg_num ; reg_num > = 0 ; - - reg_num ) { <nl> - Register reg = Register : : FromAllocationIndex ( reg_num ) ; <nl> + Register reg = <nl> + Register : : from_code ( config - > GetAllocatableGeneralCode ( reg_num ) ) ; <nl> if ( ! reg . is ( rsp ) & & ! reg . is ( rbp ) & & ! reg . is ( destination_reg ) ) { <nl> __ cmpq ( reg , MemOperand ( rsp , 0 ) ) ; <nl> __ Assert ( equal , kRegisterWasClobbered ) ; <nl> mmm a / test / unittests / compiler / instruction - selector - unittest . cc <nl> ppp b / test / unittests / compiler / instruction - selector - unittest . cc <nl> bool InstructionSelectorTest : : Stream : : IsFixed ( const InstructionOperand * operand , <nl> if ( ! operand - > IsUnallocated ( ) ) return false ; <nl> const UnallocatedOperand * unallocated = UnallocatedOperand : : cast ( operand ) ; <nl> if ( ! unallocated - > HasFixedRegisterPolicy ( ) ) return false ; <nl> - const int index = Register : : ToAllocationIndex ( reg ) ; <nl> - return unallocated - > fixed_register_index ( ) = = index ; <nl> + return unallocated - > fixed_register_index ( ) = = reg . code ( ) ; <nl> } <nl> <nl> <nl> mmm a / test / unittests / compiler / instruction - sequence - unittest . cc <nl> ppp b / test / unittests / compiler / instruction - sequence - unittest . cc <nl> static char register_names_ [ 10 * ( RegisterConfiguration : : kMaxGeneralRegisters + <nl> RegisterConfiguration : : kMaxDoubleRegisters ) ] ; <nl> <nl> <nl> + namespace { <nl> + static int allocatable_codes [ InstructionSequenceTest : : kDefaultNRegs ] = { <nl> + 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 } ; <nl> + static int allocatable_double_codes [ InstructionSequenceTest : : kDefaultNRegs ] = { <nl> + 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 } ; <nl> + } <nl> + <nl> + <nl> static void InitializeRegisterNames ( ) { <nl> char * loc = register_names_ ; <nl> for ( int i = 0 ; i < RegisterConfiguration : : kMaxGeneralRegisters ; + + i ) { <nl> void InstructionSequenceTest : : SetNumRegs ( int num_general_registers , <nl> RegisterConfiguration * InstructionSequenceTest : : config ( ) { <nl> if ( config_ . is_empty ( ) ) { <nl> config_ . Reset ( new RegisterConfiguration ( <nl> - num_general_registers_ , num_double_registers_ , num_double_registers_ , <nl> - general_register_names_ , double_register_names_ ) ) ; <nl> + num_general_registers_ , num_double_registers_ , num_general_registers_ , <nl> + num_double_registers_ , num_double_registers_ , allocatable_codes , <nl> + allocatable_double_codes , general_register_names_ , <nl> + double_register_names_ ) ) ; <nl> } <nl> return config_ . get ( ) ; <nl> } <nl> mmm a / test / unittests / compiler / instruction - sequence - unittest . h <nl> ppp b / test / unittests / compiler / instruction - sequence - unittest . h <nl> namespace compiler { <nl> <nl> class InstructionSequenceTest : public TestWithIsolateAndZone { <nl> public : <nl> - static const int kDefaultNRegs = 4 ; <nl> + static const int kDefaultNRegs = 8 ; <nl> static const int kNoValue = kMinInt ; <nl> <nl> typedef RpoNumber Rpo ; <nl> mmm a / test / unittests / compiler / register - allocator - unittest . cc <nl> ppp b / test / unittests / compiler / register - allocator - unittest . cc <nl> bool AllocatedOperandMatches ( <nl> const AllocatedOperand & op , <nl> const InstructionSequenceTest : : TestOperand & test_op ) { <nl> return AreOperandsOfSameType ( op , test_op ) & & <nl> - ( op . index ( ) = = test_op . value_ | | <nl> + ( ( op . IsRegister ( ) ? op . GetRegister ( ) . code ( ) : op . index ( ) ) = = <nl> + test_op . value_ | | <nl> test_op . value_ = = InstructionSequenceTest : : kNoValue ) ; <nl> } <nl> <nl> mmm a / tools / gyp / v8 . gyp <nl> ppp b / tools / gyp / v8 . gyp <nl> <nl> ' . . / . . / src / compiler / register - allocator . h ' , <nl> ' . . / . . / src / compiler / register - allocator - verifier . cc ' , <nl> ' . . / . . / src / compiler / register - allocator - verifier . h ' , <nl> - ' . . / . . / src / compiler / register - configuration . cc ' , <nl> - ' . . / . . / src / compiler / register - configuration . h ' , <nl> ' . . / . . / src / compiler / representation - change . h ' , <nl> ' . . / . . / src / compiler / schedule . cc ' , <nl> ' . . / . . / src / compiler / schedule . h ' , <nl> <nl> ' . . / . . / src / regexp / regexp - macro - assembler . h ' , <nl> ' . . / . . / src / regexp / regexp - stack . cc ' , <nl> ' . . / . . / src / regexp / regexp - stack . h ' , <nl> + ' . . / . . / src / register - configuration . cc ' , <nl> + ' . . / . . / src / register - configuration . h ' , <nl> ' . . / . . / src / rewriter . cc ' , <nl> ' . . / . . / src / rewriter . h ' , <nl> ' . . / . . / src / runtime - profiler . cc ' , <nl>
Remove register index / code indirection
v8/v8
80bc6f6e11f79524e3f1ad05579583adfd5f18b2
2015-09-24T12:53:13Z
mmm a / filament / src / materials / bloomUpsample . mat <nl> ppp b / filament / src / materials / bloomUpsample . mat <nl> fragment { <nl> void postProcess ( inout PostProcessInputs postProcess ) { <nl> float lod = materialParams . level ; <nl> highp vec2 uv = variable_vertex . xy ; <nl> + <nl> + # if defined ( TARGET_MOBILE ) <nl> + highp float du = materialParams . resolution . z ; <nl> + highp float dv = materialParams . resolution . w ; <nl> + vec3 c ; <nl> + c = textureLod ( materialParams_source , uv + vec2 ( - du , - dv ) , lod ) . rgb ; <nl> + c + = textureLod ( materialParams_source , uv + vec2 ( du , - dv ) , lod ) . rgb ; <nl> + c + = textureLod ( materialParams_source , uv + vec2 ( du , dv ) , lod ) . rgb ; <nl> + c + = textureLod ( materialParams_source , uv + vec2 ( - du , dv ) , lod ) . rgb ; <nl> + postProcess . color . rgb = c * 0 . 25 ; <nl> + # else <nl> highp float du = 2 . 0 * materialParams . resolution . z ; <nl> highp float dv = 2 . 0 * materialParams . resolution . w ; <nl> - <nl> - vec3 c0 = 4 . 0 * textureLod ( materialParams_source , uv , lod ) . rgb ; <nl> - c0 + = textureLod ( materialParams_source , uv + vec2 ( - du , - dv ) , lod ) . rgb ; <nl> + vec3 c0 , c1 ; <nl> + c0 = textureLod ( materialParams_source , uv + vec2 ( - du , - dv ) , lod ) . rgb ; <nl> c0 + = textureLod ( materialParams_source , uv + vec2 ( du , - dv ) , lod ) . rgb ; <nl> c0 + = textureLod ( materialParams_source , uv + vec2 ( du , dv ) , lod ) . rgb ; <nl> c0 + = textureLod ( materialParams_source , uv + vec2 ( - du , dv ) , lod ) . rgb ; <nl> - <nl> - vec3 c1 = textureLod ( materialParams_source , uv + vec2 ( - du , 0 . 0 ) , lod ) . rgb ; <nl> + c0 + = 4 . 0 * textureLod ( materialParams_source , uv , lod ) . rgb ; <nl> + c1 = textureLod ( materialParams_source , uv + vec2 ( - du , 0 . 0 ) , lod ) . rgb ; <nl> c1 + = textureLod ( materialParams_source , uv + vec2 ( 0 . 0 , - dv ) , lod ) . rgb ; <nl> c1 + = textureLod ( materialParams_source , uv + vec2 ( du , 0 . 0 ) , lod ) . rgb ; <nl> c1 + = textureLod ( materialParams_source , uv + vec2 ( 0 . 0 , dv ) , lod ) . rgb ; <nl> - <nl> postProcess . color . rgb = ( c0 + 2 . 0 * c1 ) * ( 1 . 0 / 16 . 0 ) ; <nl> + # endif <nl> } <nl> } <nl>
On mobile , use a more efficient up - sampler
google/filament
87fe48225f69f3d197dfa5b63997ef0035b3b25d
2020-02-14T01:40:55Z
mmm a / SConstruct <nl> ppp b / SConstruct <nl> AddOption ( " - - sharedclient " , <nl> action = " store " , <nl> help = " build a libmongoclient . so / . dll " ) <nl> <nl> + AddOption ( " - - smokedbprefix " , <nl> + dest = " smokedbprefix " , <nl> + action = " store " , <nl> + help = " prefix to dbpath et al . for smoke tests " ) <nl> + <nl> # mmm environment setup mmm <nl> <nl> def removeIfInList ( lst , thing ) : <nl> elif not onlyServer : <nl> <nl> testEnv . Alias ( " dummySmokeSideEffect " , [ ] , [ ] ) <nl> <nl> + if GetOption ( ' smokedbprefix ' ) is not None : <nl> + smokeDbPrefix = GetOption ( ' smokedbprefix ' ) <nl> + else : <nl> + smokeDbPrefix = ' ' <nl> + <nl> def addSmoketest ( name , deps , actions ) : <nl> if type ( actions ) = = type ( list ( ) ) : <nl> actions = [ testSetup ] + actions <nl> def ensureDir ( name ) : <nl> Exit ( 1 ) <nl> <nl> def ensureTestDirs ( ) : <nl> - ensureDir ( " / tmp / unittest / " ) <nl> - ensureDir ( " / data / " ) <nl> - ensureDir ( " / data / db / " ) <nl> + ensureDir ( smokeDbPrefix + " / tmp / unittest / " ) <nl> + ensureDir ( smokeDbPrefix + " / data / " ) <nl> + ensureDir ( smokeDbPrefix + " / data / db / " ) <nl> <nl> def testSetup ( env , target , source ) : <nl> ensureTestDirs ( ) <nl> <nl> if len ( COMMAND_LINE_TARGETS ) = = 1 and str ( COMMAND_LINE_TARGETS [ 0 ] ) = = " test " : <nl> - ensureDir ( " / tmp / unittest / " ) ; <nl> + ensureDir ( smokeDbPrefix + " / tmp / unittest / " ) ; <nl> <nl> addSmoketest ( " smoke " , [ add_exe ( " test " ) ] , [ test [ 0 ] . abspath ] ) <nl> addSmoketest ( " smokePerf " , [ " perftest " ] , [ perftest [ 0 ] . abspath ] ) <nl> def startMongodWithArgs ( * args ) : <nl> mongodForTestsPort = " 32000 " <nl> import os <nl> ensureTestDirs ( ) <nl> - dirName = " / data / db / sconsTests / " <nl> + dirName = smokeDbPrefix + " / data / db / sconsTests / " <nl> ensureDir ( dirName ) <nl> from subprocess import Popen <nl> mongodForTests = Popen ( [ mongod [ 0 ] . abspath , " - - port " , mongodForTestsPort , <nl>
Add a - - smokedbprefix option for SERVER - 1128
mongodb/mongo
1928de9fa0482c52f8fcc2f8cb3ff2281a6895a1
2010-05-17T18:59:27Z
mmm a / extensions / network / HttpClient . cpp <nl> ppp b / extensions / network / HttpClient . cpp <nl> <nl> <nl> # include " curl / curl . h " <nl> <nl> + # include " platform / CCFileUtils . h " <nl> + <nl> NS_CC_EXT_BEGIN <nl> <nl> static std : : mutex s_requestQueueMutex ; <nl> static unsigned long s_asyncRequestCount = 0 ; <nl> typedef int int32_t ; <nl> # endif <nl> <nl> - static bool need_quit = false ; <nl> + static bool s_need_quit = false ; <nl> <nl> static Array * s_requestQueue = NULL ; <nl> static Array * s_responseQueue = NULL ; <nl> static char s_errorBuffer [ CURL_ERROR_SIZE ] ; <nl> <nl> typedef size_t ( * write_callback ) ( void * ptr , size_t size , size_t nmemb , void * stream ) ; <nl> <nl> + static std : : string s_cookieFilename = " " ; <nl> + <nl> / / Callback function used by libcurl for collect response data <nl> static size_t writeData ( void * ptr , size_t size , size_t nmemb , void * stream ) <nl> { <nl> static void networkThread ( void ) <nl> <nl> while ( true ) <nl> { <nl> - if ( need_quit ) <nl> + if ( s_need_quit ) <nl> { <nl> break ; <nl> } <nl> class CURLRaii <nl> if ( ! setOption ( CURLOPT_HTTPHEADER , _headers ) ) <nl> return false ; <nl> } <nl> + if ( ! s_cookieFilename . empty ( ) ) { <nl> + if ( ! setOption ( CURLOPT_COOKIEFILE , s_cookieFilename . c_str ( ) ) ) { <nl> + return false ; <nl> + } <nl> + if ( ! setOption ( CURLOPT_COOKIEJAR , s_cookieFilename . c_str ( ) ) ) { <nl> + return false ; <nl> + } <nl> + } <nl> <nl> return setOption ( CURLOPT_URL , request - > getUrl ( ) ) <nl> & & setOption ( CURLOPT_WRITEFUNCTION , callback ) <nl> class CURLRaii <nl> if ( CURLE_OK ! = curl_easy_perform ( _curl ) ) <nl> return false ; <nl> CURLcode code = curl_easy_getinfo ( _curl , CURLINFO_RESPONSE_CODE , responseCode ) ; <nl> - if ( code ! = CURLE_OK | | * responseCode ! = 200 ) <nl> + if ( code ! = CURLE_OK | | * responseCode ! = 200 ) { <nl> + CCLOGERROR ( " Curl curl_easy_getinfo failed : % s " , curl_easy_strerror ( code ) ) ; <nl> return false ; <nl> - <nl> + } <nl> / / Get some mor data . <nl> <nl> return true ; <nl> void HttpClient : : destroyInstance ( ) <nl> s_pHttpClient - > release ( ) ; <nl> } <nl> <nl> + void HttpClient : : enableCookies ( const char * cookieFile ) { <nl> + if ( cookieFile ) { <nl> + s_cookieFilename = std : : string ( cookieFile ) ; <nl> + } <nl> + else { <nl> + s_cookieFilename = ( FileUtils : : sharedFileUtils ( ) - > getWritablePath ( ) + " cookieFile . txt " ) ; <nl> + } <nl> + } <nl> + <nl> HttpClient : : HttpClient ( ) <nl> : _timeoutForConnect ( 30 ) <nl> , _timeoutForRead ( 60 ) <nl> HttpClient : : HttpClient ( ) <nl> <nl> HttpClient : : ~ HttpClient ( ) <nl> { <nl> - need_quit = true ; <nl> + s_need_quit = true ; <nl> <nl> if ( s_requestQueue ! = NULL ) { <nl> s_SleepCondition . notify_one ( ) ; <nl> bool HttpClient : : lazyInitThreadSemphore ( ) <nl> auto t = std : : thread ( & networkThread ) ; <nl> t . detach ( ) ; <nl> <nl> - need_quit = false ; <nl> + s_need_quit = false ; <nl> } <nl> <nl> return true ; <nl> mmm a / extensions / network / HttpClient . h <nl> ppp b / extensions / network / HttpClient . h <nl> class HttpClient : public Object <nl> <nl> / * * Relase the shared instance * * / <nl> static void destroyInstance ( ) ; <nl> + <nl> + / * * Enable cookie support . * * / <nl> + static void enableCookies ( const char * cookieFile ) ; <nl> <nl> / * * <nl> * Add a get request to task queue <nl>
issue : Adding cookie support for HttpClient
cocos2d/cocos2d-x
3f5727584858108cb8c9ce81c8a12513822e5fec
2013-07-10T03:37:39Z
mmm a / hphp / runtime / base / server / upload . cpp <nl> ppp b / hphp / runtime / base / server / upload . cpp <nl> void rfc1867PostHandler ( Transport * transport , <nl> } <nl> } <nl> <nl> - if ( cancel_upload ) { <nl> + if ( cancel_upload & & cancel_upload ! = UPLOAD_ERROR_C ) { <nl> if ( temp_filename ) { <nl> if ( cancel_upload ! = UPLOAD_ERROR_E ) { / * file creation failed * / <nl> unlink ( temp_filename ) ; <nl> void rfc1867PostHandler ( Transport * transport , <nl> s = nullptr ; <nl> <nl> / * Possible Content - Type : * / <nl> - if ( cancel_upload | | <nl> + if ( ( cancel_upload & & cancel_upload ! = UPLOAD_ERROR_C ) | | <nl> ! ( cd = php_mime_get_hdr_value ( header , " Content - Type " ) ) ) { <nl> cd = " " ; <nl> } else { <nl>
Keep the uploaded data when a partial upload error occurs
facebook/hhvm
7398db609777b63038f1193bbdeb7697254d35e9
2013-06-10T17:14:13Z
mmm a / src / core / mem_map_funcs . cpp <nl> ppp b / src / core / mem_map_funcs . cpp <nl> void Write64 ( const u32 addr , const u64 data ) { <nl> <nl> void WriteBlock ( const u32 addr , const u8 * data , const int size ) { <nl> int offset = 0 ; <nl> - while ( offset < ( size & ~ 3 ) ) <nl> - Write32 ( addr + offset , * ( u32 * ) & data [ offset + = 4 ] ) ; <nl> + while ( offset < ( size & ~ 3 ) ) { <nl> + Write32 ( addr + offset , * ( u32 * ) & data [ offset ] ) ; <nl> + offset + = 4 ; <nl> + } <nl> <nl> - if ( size & 2 ) <nl> - Write16 ( addr + offset , * ( u16 * ) & data [ offset + = 2 ] ) ; <nl> + if ( size & 2 ) { <nl> + Write16 ( addr + offset , * ( u16 * ) & data [ offset ] ) ; <nl> + offset + = 2 ; <nl> + } <nl> <nl> if ( size & 1 ) <nl> Write8 ( addr + offset , data [ offset ] ) ; <nl>
Core : Fix undefined behavior in mem_map_funcs ' WriteBlock function
yuzu-emu/yuzu
da18671166e096dc375da5c547c3be38de0493fb
2014-08-17T18:23:54Z
mmm a / SConstruct <nl> ppp b / SConstruct <nl> platform_list = [ ] # list of platforms <nl> platform_opts = { } # options for each platform <nl> platform_flags = { } # flags for each platform <nl> <nl> - <nl> active_platforms = [ ] <nl> active_platform_ids = [ ] <nl> platform_exporters = [ ] <nl> platform_arg = ARGUMENTS . get ( " platform " , False ) <nl> if ( os . name = = " posix " ) : <nl> pass <nl> elif ( os . name = = " nt " ) : <nl> - if ( os . getenv ( " VSINSTALLDIR " ) = = None or platform_arg = = " android " ) : <nl> + if ( not methods . msvc_is_detected ( ) or platform_arg = = " android " ) : <nl> custom_tools = [ ' mingw ' ] <nl> <nl> env_base = Environment ( tools = custom_tools ) ; <nl> mmm a / drivers / builtin_openssl2 / SCsub <nl> ppp b / drivers / builtin_openssl2 / SCsub <nl> if " platform " in env and env [ " platform " ] = = " winrt " : <nl> <nl> # Workaround for compilation error with GCC / Clang when - Werror is too greedy ( GH - 4517 ) <nl> import os <nl> - if not ( os . name = = " nt " and os . getenv ( " VSINSTALLDIR " ) ! = None ) : # not Windows and not MSVC <nl> + import methods <nl> + if not ( os . name = = " nt " and methods . msvc_is_detected ( ) ) : # not Windows and not MSVC <nl> env_drivers . Append ( CFLAGS = [ " - Wno - error = implicit - function - declaration " ] ) <nl> <nl> env_drivers . add_source_files ( env . drivers_sources , openssl_sources ) <nl> mmm a / methods . py <nl> ppp b / methods . py <nl> def detect_visual_c_compiler_version ( tools_env ) : <nl> <nl> return vc_chosen_compiler_str <nl> <nl> + def msvc_is_detected ( ) : <nl> + # looks for VisualStudio env variable <nl> + # or for Visual C + + Build Tools ( which is a standalone MSVC ) <nl> + return os . getenv ( " VSINSTALLDIR " ) or os . getenv ( " VS100COMNTOOLS " ) or os . getenv ( " VS110COMNTOOLS " ) or os . getenv ( " VS120COMNTOOLS " ) or os . getenv ( " VS140COMNTOOLS " ) ; <nl> + <nl> + <nl> def precious_program ( env , program , sources , * * args ) : <nl> program = env . ProgramOriginal ( program , sources , * * args ) <nl> env . Precious ( program ) <nl> mmm a / platform / windows / detect . py <nl> ppp b / platform / windows / detect . py <nl> <nl> # <nl> - # tested on | Windows native | Linux cross - compilation <nl> - # mmmmmmmmmmmmmmmmmmmmmmmm + mmmmmmmmmmmmmmmmmm - + mmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> - # MSVS C + + 2010 Express | WORKS | n / a <nl> - # Mingw - w64 | WORKS | WORKS <nl> - # Mingw - w32 | WORKS | WORKS <nl> - # MinGW | WORKS | untested <nl> + # tested on | Windows native | Linux cross - compilation <nl> + # mmmmmmmmmmmmmmmmmmmmmmmmmmm - + mmmmmmmmmmmmmmmmmm - + mmmmmmmmmmmmmmmmmmmmmmmmmmm <nl> + # MSVS C + + 2010 Express | WORKS | n / a <nl> + # Visual C + + Build Tools 2015 | WORKS | n / a <nl> + # Mingw - w64 | WORKS | WORKS <nl> + # Mingw - w32 | WORKS | WORKS <nl> + # MinGW | WORKS | untested <nl> # <nl> # # # # # <nl> # Notes about MSVS C + + : <nl> <nl> # - MSVC2010 - Express compiles to 32bits only . <nl> # <nl> # # # # # <nl> + # Note about Visual C + + Build Tools : <nl> + # <nl> + # - Visual C + + Build Tools is the standalone MSVC compiler : <nl> + # http : / / landinghub . visualstudio . com / visual - cpp - build - tools <nl> + # <nl> + # # # # # <nl> # Notes about Mingw - w64 and Mingw - w32 under Windows : <nl> # <nl> # - both can be installed using the official installer : <nl> <nl> <nl> # # # # # <nl> # TODO : <nl> - # <nl> + # <nl> # - finish to cleanup this script to remove all the remains of previous hacks and workarounds <nl> # - make it work with the Windows7 SDK that is supposed to enable 64bits compilation for MSVC2010 - Express <nl> # - confirm it works well with other Visual Studio versions . <nl> def can_build ( ) : <nl> <nl> if ( os . name = = " nt " ) : <nl> # building natively on windows ! <nl> - if ( os . getenv ( " VSINSTALLDIR " ) ) : <nl> + if ( methods . msvc_is_detected ( ) ) : <nl> return True <nl> else : <nl> print ( " \ nMSVC not detected , attempting Mingw . " ) <nl> def configure ( env ) : <nl> <nl> env . Append ( CPPPATH = [ ' # platform / windows ' ] ) <nl> env [ ' is_mingw ' ] = False <nl> - if ( os . name = = " nt " and os . getenv ( " VSINSTALLDIR " ) ! = None ) : <nl> + if ( os . name = = " nt " and methods . msvc_is_detected ( ) ) : <nl> # build using visual studio <nl> env [ ' ENV ' ] [ ' TMP ' ] = os . environ [ ' TMP ' ] <nl> env . Append ( CPPPATH = [ ' # platform / windows / include ' ] ) <nl>
scons detects standalone MSVC on Windows
godotengine/godot
663d4ee7de9741e4e55255908fbecd8582097ae3
2016-09-16T09:17:57Z
mmm a / docs / LangRef . html <nl> ppp b / docs / LangRef . html <nl> < h4 id = " expr - assign " > Assignment operator < / h4 > <nl> <nl> < pre class = " example " > <nl> / / Not valid Swift code <nl> - operator infix = { <nl> + infix operator = { <nl> precedence 90 <nl> associativity right <nl> } <nl> < h4 id = " expr - ternary " > Ternary operator < / h4 > <nl> <nl> < pre class = " example " > <nl> / / Not valid Swift code <nl> - operator infix ? . . . : { <nl> + infix operator ? . . . : { <nl> precedence 100 <nl> associativity right <nl> } <nl> < h4 id = " expr - cast " > Cast operators < / h4 > <nl> <nl> < pre class = " example " > <nl> / / Not valid Swift code <nl> - operator infix as { <nl> + infix operator as { <nl> precedence 95 <nl> associativity none <nl> } <nl> mmm a / include / swift / AST / Decl . h <nl> ppp b / include / swift / AST / Decl . h <nl> class OperatorDecl : public Decl { <nl> / / / Declares the behavior of an infix operator . For example : <nl> / / / <nl> / / / \ code <nl> - / / / operator infix / + / { <nl> + / / / infix operator / + / { <nl> / / / associativity left <nl> / / / precedence 123 <nl> / / / } <nl> / / / \ endcode <nl> class InfixOperatorDecl : public OperatorDecl { <nl> - SourceLoc InfixLoc , <nl> - AssociativityLoc , AssociativityValueLoc , <nl> + SourceLoc AssociativityLoc , AssociativityValueLoc , <nl> PrecedenceLoc , PrecedenceValueLoc ; <nl> <nl> public : <nl> InfixOperatorDecl ( DeclContext * DC , <nl> SourceLoc OperatorLoc , <nl> - SourceLoc InfixLoc , <nl> Identifier Name , <nl> SourceLoc NameLoc , <nl> SourceLoc LBraceLoc , <nl> class InfixOperatorDecl : public OperatorDecl { <nl> NameLoc , <nl> LBraceLoc , <nl> RBraceLoc ) , <nl> - InfixLoc ( InfixLoc ) , <nl> AssociativityLoc ( AssociativityLoc ) , <nl> AssociativityValueLoc ( AssociativityValueLoc ) , <nl> PrecedenceLoc ( PrecedenceLoc ) , <nl> class InfixOperatorDecl : public OperatorDecl { <nl> } <nl> } <nl> <nl> - SourceLoc getInfixLoc ( ) const { return InfixLoc ; } <nl> SourceLoc getAssociativityLoc ( ) const { return AssociativityLoc ; } <nl> SourceLoc getAssociativityValueLoc ( ) const { return AssociativityValueLoc ; } <nl> SourceLoc getPrecedenceLoc ( ) const { return PrecedenceLoc ; } <nl> class InfixOperatorDecl : public OperatorDecl { <nl> / / / Declares the behavior of a prefix operator . For example : <nl> / / / <nl> / / / \ code <nl> - / / / operator prefix / + / { } <nl> + / / / prefix operator / + / { } <nl> / / / \ endcode <nl> class PrefixOperatorDecl : public OperatorDecl { <nl> - SourceLoc PrefixLoc ; <nl> public : <nl> - PrefixOperatorDecl ( DeclContext * DC , <nl> - SourceLoc OperatorLoc , <nl> - SourceLoc PrefixLoc , <nl> - Identifier Name , <nl> - SourceLoc NameLoc , <nl> - SourceLoc LBraceLoc , <nl> + PrefixOperatorDecl ( DeclContext * DC , SourceLoc OperatorLoc , Identifier Name , <nl> + SourceLoc NameLoc , SourceLoc LBraceLoc , <nl> SourceLoc RBraceLoc ) <nl> : OperatorDecl ( DeclKind : : PrefixOperator , DC , <nl> - OperatorLoc , <nl> - Name , <nl> - NameLoc , <nl> - LBraceLoc , <nl> - RBraceLoc ) , <nl> - PrefixLoc ( PrefixLoc ) { } <nl> - <nl> - SourceLoc getPrefixLoc ( ) const { return PrefixLoc ; } <nl> - <nl> + OperatorLoc , Name , NameLoc , LBraceLoc , RBraceLoc ) { } <nl> + <nl> / / / True if this decl ' s attributes conflict with those declared by another <nl> / / / PrefixOperatorDecl . <nl> bool conflictsWith ( PrefixOperatorDecl * other ) { <nl> class PrefixOperatorDecl : public OperatorDecl { <nl> / / / Declares the behavior of a postfix operator . For example : <nl> / / / <nl> / / / \ code <nl> - / / / operator postfix / + / { } <nl> + / / / postfix operator / + / { } <nl> / / / \ endcode <nl> class PostfixOperatorDecl : public OperatorDecl { <nl> - SourceLoc PostfixLoc ; <nl> public : <nl> - PostfixOperatorDecl ( DeclContext * DC , <nl> - SourceLoc OperatorLoc , <nl> - SourceLoc PostfixLoc , <nl> - Identifier Name , <nl> - SourceLoc NameLoc , <nl> - SourceLoc LBraceLoc , <nl> + PostfixOperatorDecl ( DeclContext * DC , SourceLoc OperatorLoc , Identifier Name , <nl> + SourceLoc NameLoc , SourceLoc LBraceLoc , <nl> SourceLoc RBraceLoc ) <nl> - : OperatorDecl ( DeclKind : : PostfixOperator , DC , <nl> - OperatorLoc , <nl> - Name , <nl> - NameLoc , <nl> - LBraceLoc , <nl> - RBraceLoc ) , <nl> - PostfixLoc ( PostfixLoc ) { } <nl> + : OperatorDecl ( DeclKind : : PostfixOperator , DC , OperatorLoc , Name , <nl> + NameLoc , LBraceLoc , RBraceLoc ) { } <nl> <nl> - SourceLoc getPostfixLoc ( ) const { return PostfixLoc ; } <nl> - <nl> / / / True if this decl ' s attributes conflict with those declared by another <nl> / / / PostfixOperatorDecl . <nl> bool conflictsWith ( PostfixOperatorDecl * other ) { <nl> mmm a / include / swift / AST / DiagnosticsParse . def <nl> ppp b / include / swift / AST / DiagnosticsParse . def <nl> ERROR ( opened_destructor_expected_rparen , attribute_parsing , none , <nl> ERROR ( destructor_params , decl_parsing , none , <nl> " deinitializer does not have a parameter clause " , ( ) ) <nl> <nl> + <nl> + / / FIXME : Remove this . <nl> + ERROR ( operator_fixity_moved , decl_parsing , PointsToFirstBadToken , <nl> + " % 0 moved to before the ' operator ' declaration " , ( StringRef ) ) <nl> + <nl> + <nl> / / Operator <nl> ERROR ( operator_decl_inner_scope , decl_parsing , none , <nl> " ' operator ' may only be declared at file scope " , ( ) ) <nl> ERROR ( expected_operator_name_after_operator , decl_parsing , PointsToFirstBadToken , <nl> - " expected operator name after fixity in ' operator ' declaration " , ( ) ) <nl> + " expected operator name in operator declaration " , ( ) ) <nl> + ERROR ( operator_decl_no_fixity , decl_parsing , none , <nl> + " operator must be declared as ' prefix ' , ' postfix ' , or ' infix ' " , ( ) ) <nl> ERROR ( expected_lbrace_after_operator , decl_parsing , PointsToFirstBadToken , <nl> " expected ' { ' after operator name in ' operator ' declaration " , ( ) ) <nl> ERROR ( expected_operator_attribute , decl_parsing , none , <nl> mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> ERROR ( broken_int_hashable_conformance , sema_tcd , none , <nl> ERROR ( broken_int_integer_literal_convertible_conformance , sema_tcd , none , <nl> " Int type is broken : does not conform to IntegerLiteralConvertible " , ( ) ) <nl> ERROR ( broken_equatable_eq_operator , sema_tcd , none , <nl> - " Equatable protocol is broken : no operator infix declaration for ' = = ' " , ( ) ) <nl> + " Equatable protocol is broken : no infix operator declaration for ' = = ' " , ( ) ) <nl> <nl> / / Dynamic Self <nl> ERROR ( dynamic_self_non_method , sema_tcd , none , <nl> mmm a / include / swift / Parse / Parser . h <nl> ppp b / include / swift / Parse / Parser . h <nl> class Parser { <nl> ParserResult < OperatorDecl > parseDeclOperator ( ParseDeclOptions Flags , <nl> DeclAttributes & Attributes ) ; <nl> ParserResult < OperatorDecl > parseDeclPrefixOperator ( SourceLoc OperatorLoc , <nl> - SourceLoc PrefixLoc , <nl> Identifier Name , <nl> SourceLoc NameLoc ) ; <nl> ParserResult < OperatorDecl > parseDeclPostfixOperator ( SourceLoc OperatorLoc , <nl> - SourceLoc PostfixLoc , <nl> Identifier Name , <nl> SourceLoc NameLoc ) ; <nl> ParserResult < OperatorDecl > parseDeclInfixOperator ( SourceLoc OperatorLoc , <nl> - SourceLoc InfixLoc , <nl> Identifier Name , <nl> SourceLoc NameLoc ) ; <nl> <nl> mmm a / lib / AST / ASTPrinter . cpp <nl> ppp b / lib / AST / ASTPrinter . cpp <nl> void PrintAST : : visitDestructorDecl ( DestructorDecl * decl ) { <nl> } <nl> <nl> void PrintAST : : visitInfixOperatorDecl ( InfixOperatorDecl * decl ) { <nl> - Printer < < " operator infix " ; <nl> + Printer < < " infix operator " ; <nl> recordDeclLoc ( decl ) ; <nl> Printer . printName ( decl - > getName ( ) ) ; <nl> Printer < < " { " ; <nl> void PrintAST : : visitInfixOperatorDecl ( InfixOperatorDecl * decl ) { <nl> } <nl> <nl> void PrintAST : : visitPrefixOperatorDecl ( PrefixOperatorDecl * decl ) { <nl> - Printer < < " operator prefix " ; <nl> + Printer < < " prefix operator " ; <nl> recordDeclLoc ( decl ) ; <nl> Printer . printName ( decl - > getName ( ) ) ; <nl> Printer < < " { " ; <nl> void PrintAST : : visitPrefixOperatorDecl ( PrefixOperatorDecl * decl ) { <nl> } <nl> <nl> void PrintAST : : visitPostfixOperatorDecl ( PostfixOperatorDecl * decl ) { <nl> - Printer < < " operator postfix " ; <nl> + Printer < < " postfix operator " ; <nl> recordDeclLoc ( decl ) ; <nl> Printer . printName ( decl - > getName ( ) ) ; <nl> Printer < < " { " ; <nl> mmm a / lib / IDE / SyntaxModel . cpp <nl> ppp b / lib / IDE / SyntaxModel . cpp <nl> bool ModelASTWalker : : walkToDeclPre ( Decl * D ) { <nl> if ( ! passNonTokenNode ( { SyntaxNodeKind : : Keyword , <nl> CharSourceRange ( OperD - > getOperatorLoc ( ) , strlen ( " operator " ) ) } ) ) <nl> return false ; <nl> - <nl> - if ( auto Infix = dyn_cast < InfixOperatorDecl > ( D ) ) { <nl> - if ( ! passNonTokenNode ( { SyntaxNodeKind : : Keyword , <nl> - CharSourceRange ( Infix - > getInfixLoc ( ) , strlen ( " infix " ) ) } ) ) <nl> - return false ; <nl> - } else if ( auto Prefix = dyn_cast < PrefixOperatorDecl > ( D ) ) { <nl> - if ( ! passNonTokenNode ( { SyntaxNodeKind : : Keyword , <nl> - CharSourceRange ( Prefix - > getPrefixLoc ( ) , strlen ( " prefix " ) ) } ) ) <nl> - return false ; <nl> - } else if ( auto Postfix = dyn_cast < PostfixOperatorDecl > ( D ) ) { <nl> - if ( ! passNonTokenNode ( { SyntaxNodeKind : : Keyword , <nl> - CharSourceRange ( Postfix - > getPostfixLoc ( ) , strlen ( " postfix " ) ) } ) ) <nl> - return false ; <nl> - } <nl> } <nl> <nl> return true ; <nl> mmm a / lib / Parse / ParseDecl . cpp <nl> ppp b / lib / Parse / ParseDecl . cpp <nl> Parser : : parseDeclOperator ( ParseDeclOptions Flags , DeclAttributes & Attributes ) { <nl> <nl> if ( Attributes . hasNonVirtualAttributes ( ) ) <nl> diagnose ( Attributes . AtLoc , diag : : operator_attributes ) ; <nl> - <nl> - auto kind = llvm : : StringSwitch < Optional < DeclKind > > ( Tok . getText ( ) ) <nl> - . Case ( " prefix " , DeclKind : : PrefixOperator ) <nl> - . Case ( " postfix " , DeclKind : : PostfixOperator ) <nl> - . Case ( " infix " , DeclKind : : InfixOperator ) <nl> - . Default ( Nothing ) ; <nl> - <nl> - assert ( kind & & " no fixity after ' operator ' ? ! " ) ; <nl> <nl> - SourceLoc KindLoc = consumeToken ( tok : : identifier ) ; <nl> + / / Check to see if this is declared with the old syntax to help with migration <nl> + / / FIXME : Remove this . <nl> + if ( Tok . is ( tok : : identifier ) ) { <nl> + DeclAttribute * attr = nullptr ; <nl> + if ( Tok . getText ( ) = = " infix " ) <nl> + attr = new ( Context ) InfixAttr ( / * implicit * / false ) ; <nl> + else if ( Tok . getText ( ) = = " postfix " ) <nl> + attr = new ( Context ) PostfixAttr ( / * implicit * / false ) ; <nl> + else if ( Tok . getText ( ) = = " prefix " ) <nl> + attr = new ( Context ) PrefixAttr ( / * implicit * / false ) ; <nl> + <nl> + if ( attr ) { <nl> + diagnose ( Tok , diag : : operator_fixity_moved , Tok . getText ( ) ) <nl> + . fixItInsert ( OperatorLoc , Tok . getText ( ) . str ( ) + " " ) <nl> + . fixItRemove ( Tok . getLoc ( ) ) ; <nl> + <nl> + Attributes . add ( attr ) ; <nl> + consumeToken ( tok : : identifier ) ; <nl> + } <nl> + } <nl> <nl> if ( ! Tok . isAnyOperator ( ) & & ! Tok . is ( tok : : exclaim_postfix ) ) { <nl> diagnose ( Tok , diag : : expected_operator_name_after_operator ) ; <nl> Parser : : parseDeclOperator ( ParseDeclOptions Flags , DeclAttributes & Attributes ) { <nl> } <nl> <nl> ParserResult < OperatorDecl > Result ; <nl> - switch ( * kind ) { <nl> - case DeclKind : : PrefixOperator : <nl> - Result = parseDeclPrefixOperator ( OperatorLoc , KindLoc , Name , NameLoc ) ; <nl> - break ; <nl> - case DeclKind : : PostfixOperator : <nl> - Result = parseDeclPostfixOperator ( OperatorLoc , KindLoc , Name , NameLoc ) ; <nl> - break ; <nl> - case DeclKind : : InfixOperator : <nl> - Result = parseDeclInfixOperator ( OperatorLoc , KindLoc , Name , NameLoc ) ; <nl> - break ; <nl> - default : <nl> - llvm_unreachable ( " impossible " ) ; <nl> + if ( Attributes . hasAttribute < PrefixAttr > ( ) ) <nl> + Result = parseDeclPrefixOperator ( OperatorLoc , Name , NameLoc ) ; <nl> + else if ( Attributes . hasAttribute < PostfixAttr > ( ) ) <nl> + Result = parseDeclPostfixOperator ( OperatorLoc , Name , NameLoc ) ; <nl> + else { <nl> + if ( ! Attributes . hasAttribute < InfixAttr > ( ) ) <nl> + diagnose ( OperatorLoc , diag : : operator_decl_no_fixity ) ; <nl> + Result = parseDeclInfixOperator ( OperatorLoc , Name , NameLoc ) ; <nl> } <nl> - <nl> + <nl> if ( Tok . is ( tok : : r_brace ) ) <nl> consumeToken ( ) ; <nl> <nl> Parser : : parseDeclOperator ( ParseDeclOptions Flags , DeclAttributes & Attributes ) { <nl> } <nl> <nl> ParserResult < OperatorDecl > <nl> - Parser : : parseDeclPrefixOperator ( SourceLoc OperatorLoc , SourceLoc PrefixLoc , <nl> - Identifier Name , SourceLoc NameLoc ) { <nl> + Parser : : parseDeclPrefixOperator ( SourceLoc OperatorLoc , Identifier Name , <nl> + SourceLoc NameLoc ) { <nl> SourceLoc LBraceLoc = consumeToken ( tok : : l_brace ) ; <nl> <nl> while ( ! Tok . is ( tok : : r_brace ) ) { <nl> Parser : : parseDeclPrefixOperator ( SourceLoc OperatorLoc , SourceLoc PrefixLoc , <nl> SourceLoc RBraceLoc = Tok . getLoc ( ) ; <nl> <nl> return makeParserResult ( <nl> - new ( Context ) PrefixOperatorDecl ( CurDeclContext , OperatorLoc , PrefixLoc , <nl> + new ( Context ) PrefixOperatorDecl ( CurDeclContext , OperatorLoc , <nl> Name , NameLoc , LBraceLoc , RBraceLoc ) ) ; <nl> } <nl> <nl> ParserResult < OperatorDecl > <nl> - Parser : : parseDeclPostfixOperator ( SourceLoc OperatorLoc , SourceLoc PostfixLoc , <nl> + Parser : : parseDeclPostfixOperator ( SourceLoc OperatorLoc , <nl> Identifier Name , SourceLoc NameLoc ) { <nl> SourceLoc LBraceLoc = consumeToken ( tok : : l_brace ) ; <nl> <nl> Parser : : parseDeclPostfixOperator ( SourceLoc OperatorLoc , SourceLoc PostfixLoc , <nl> <nl> return makeParserResult ( <nl> new ( Context ) PostfixOperatorDecl ( CurDeclContext , OperatorLoc , <nl> - PostfixLoc , Name , NameLoc , LBraceLoc , <nl> - RBraceLoc ) ) ; <nl> + Name , NameLoc , LBraceLoc , RBraceLoc ) ) ; <nl> } <nl> <nl> ParserResult < OperatorDecl > <nl> - Parser : : parseDeclInfixOperator ( SourceLoc OperatorLoc , SourceLoc InfixLoc , <nl> - Identifier Name , SourceLoc NameLoc ) { <nl> + Parser : : parseDeclInfixOperator ( SourceLoc OperatorLoc , Identifier Name , <nl> + SourceLoc NameLoc ) { <nl> SourceLoc LBraceLoc = consumeToken ( tok : : l_brace ) ; <nl> <nl> / / Initialize InfixData with default attributes : <nl> Parser : : parseDeclInfixOperator ( SourceLoc OperatorLoc , SourceLoc InfixLoc , <nl> SourceLoc RBraceLoc = Tok . getLoc ( ) ; <nl> <nl> return makeParserResult ( new ( Context ) InfixOperatorDecl ( <nl> - CurDeclContext , OperatorLoc , InfixLoc , Name , NameLoc , LBraceLoc , <nl> + CurDeclContext , OperatorLoc , Name , NameLoc , LBraceLoc , <nl> AssociativityLoc , AssociativityValueLoc , PrecedenceLoc , <nl> PrecedenceValueLoc , RBraceLoc , InfixData ( precedence , associativity ) ) ) ; <nl> } <nl> mmm a / lib / Sema / TypeCheckAttr . cpp <nl> ppp b / lib / Sema / TypeCheckAttr . cpp <nl> void AttributeChecker : : visitFinalAttr ( FinalAttr * attr ) { <nl> } <nl> } <nl> <nl> + / / / Return true if this is a builtin operator that cannot be defined in user <nl> + / / / code . <nl> + static bool isBuiltinOperator ( StringRef name , DeclAttribute * attr ) { <nl> + return ( ( isa < PrefixAttr > ( attr ) & & name = = " & " ) | | / / prefix & <nl> + ( isa < PostfixAttr > ( attr ) & & name = = " ! " ) | | / / postfix ! <nl> + ( isa < PostfixAttr > ( attr ) & & name = = " ? " ) ) ; / / postfix ? <nl> + } <nl> + <nl> void AttributeChecker : : checkOperatorAttribute ( DeclAttribute * attr ) { <nl> - / / Operators may only be defined as functions . <nl> + / / Check out the operator attributes . They may be attached to an operator <nl> + / / declaration or a function . <nl> + if ( auto * OD = dyn_cast < OperatorDecl > ( D ) ) { <nl> + / / Reject attempts to define builtin operators . <nl> + if ( isBuiltinOperator ( OD - > getName ( ) . str ( ) , attr ) ) { <nl> + TC . diagnose ( D - > getStartLoc ( ) , diag : : redefining_builtin_operator , <nl> + attr - > getAttrName ( ) , OD - > getName ( ) . str ( ) ) ; <nl> + attr - > setInvalid ( ) ; <nl> + return ; <nl> + } <nl> + <nl> + / / Otherwise , the attribute is always ok on an operator . <nl> + return ; <nl> + } <nl> + <nl> + / / Operators implementations may only be defined as functions . <nl> auto * FD = dyn_cast < FuncDecl > ( D ) ; <nl> if ( ! FD ) { <nl> TC . diagnose ( D - > getLoc ( ) , diag : : operator_not_func ) ; <nl> void AttributeChecker : : checkOperatorAttribute ( DeclAttribute * attr ) { <nl> } <nl> <nl> / / Reject attempts to define builtin operators . <nl> - if ( ( isa < PrefixAttr > ( attr ) & & FD - > getName ( ) . str ( ) = = " & " ) | | / / prefix & <nl> - ( isa < PostfixAttr > ( attr ) & & FD - > getName ( ) . str ( ) = = " ! " ) | | / / postfix ! <nl> - ( isa < PostfixAttr > ( attr ) & & FD - > getName ( ) . str ( ) = = " ? " ) ) { / / postfix ? <nl> + if ( isBuiltinOperator ( FD - > getName ( ) . str ( ) , attr ) ) { <nl> TC . diagnose ( D - > getStartLoc ( ) , diag : : redefining_builtin_operator , <nl> attr - > getAttrName ( ) , FD - > getName ( ) . str ( ) ) ; <nl> attr - > setInvalid ( ) ; <nl> mmm a / lib / Serialization / Deserialization . cpp <nl> ppp b / lib / Serialization / Deserialization . cpp <nl> Decl * ModuleFile : : getDecl ( DeclID DID , Optional < DeclContext * > ForcedContext ) { <nl> <nl> decls_block : : PrefixOperatorLayout : : readRecord ( scratch , nameID , contextID ) ; <nl> declOrOffset = new ( ctx ) PrefixOperatorDecl ( getDeclContext ( contextID ) , <nl> - SourceLoc ( ) , SourceLoc ( ) , <nl> + SourceLoc ( ) , <nl> getIdentifier ( nameID ) , <nl> SourceLoc ( ) , SourceLoc ( ) , <nl> SourceLoc ( ) ) ; <nl> Decl * ModuleFile : : getDecl ( DeclID DID , Optional < DeclContext * > ForcedContext ) { <nl> <nl> decls_block : : PostfixOperatorLayout : : readRecord ( scratch , nameID , contextID ) ; <nl> declOrOffset = new ( ctx ) PostfixOperatorDecl ( getDeclContext ( contextID ) , <nl> - SourceLoc ( ) , SourceLoc ( ) , <nl> + SourceLoc ( ) , <nl> getIdentifier ( nameID ) , <nl> SourceLoc ( ) , SourceLoc ( ) , <nl> SourceLoc ( ) ) ; <nl> Decl * ModuleFile : : getDecl ( DeclID DID , Optional < DeclContext * > ForcedContext ) { <nl> InfixData infixData ( precedence , associativity . getValue ( ) ) ; <nl> <nl> declOrOffset = new ( ctx ) InfixOperatorDecl ( getDeclContext ( contextID ) , <nl> - SourceLoc ( ) , SourceLoc ( ) , <nl> + SourceLoc ( ) , <nl> getIdentifier ( nameID ) , <nl> SourceLoc ( ) , SourceLoc ( ) , <nl> SourceLoc ( ) , SourceLoc ( ) , <nl> mmm a / stdlib / core / Policy . swift <nl> ppp b / stdlib / core / Policy . swift <nl> func ~ = < T : Equatable > ( a : T , b : T ) - > Bool { <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> / / Standard postfix operators . <nl> - operator postfix + + { } <nl> - operator postfix - - { } <nl> + postfix operator + + { } <nl> + postfix operator - - { } <nl> <nl> / / Optional < T > unwrapping operator is built into the compiler as a part of <nl> / / postfix expression grammar . <nl> / / <nl> - / / operator postfix ! { } <nl> + / / postfix operator ! { } <nl> <nl> / / Standard prefix operators . <nl> - operator prefix + + { } <nl> - operator prefix - - { } <nl> - operator prefix ! { } <nl> - operator prefix ~ { } <nl> - operator prefix + { } <nl> - operator prefix - { } <nl> + prefix operator + + { } <nl> + prefix operator - - { } <nl> + prefix operator ! { } <nl> + prefix operator ~ { } <nl> + prefix operator + { } <nl> + prefix operator - { } <nl> <nl> / / Standard infix operators . <nl> <nl> / / " Exponentiative " <nl> <nl> - operator infix < < { associativity none precedence 160 } <nl> - operator infix > > { associativity none precedence 160 } <nl> + infix operator < < { associativity none precedence 160 } <nl> + infix operator > > { associativity none precedence 160 } <nl> <nl> / / " Multiplicative " <nl> <nl> - operator infix * { associativity left precedence 150 } <nl> - operator infix & * { associativity left precedence 150 } <nl> - operator infix / { associativity left precedence 150 } <nl> - operator infix & / { associativity left precedence 150 } <nl> - operator infix % { associativity left precedence 150 } <nl> - operator infix & % { associativity left precedence 150 } <nl> - operator infix & { associativity left precedence 150 } <nl> + infix operator * { associativity left precedence 150 } <nl> + infix operator & * { associativity left precedence 150 } <nl> + infix operator / { associativity left precedence 150 } <nl> + infix operator & / { associativity left precedence 150 } <nl> + infix operator % { associativity left precedence 150 } <nl> + infix operator & % { associativity left precedence 150 } <nl> + infix operator & { associativity left precedence 150 } <nl> <nl> / / " Additive " <nl> <nl> - operator infix + { associativity left precedence 140 } <nl> - operator infix & + { associativity left precedence 140 } <nl> - operator infix - { associativity left precedence 140 } <nl> - operator infix & - { associativity left precedence 140 } <nl> - operator infix | { associativity left precedence 140 } <nl> - operator infix ^ { associativity left precedence 140 } <nl> + infix operator + { associativity left precedence 140 } <nl> + infix operator & + { associativity left precedence 140 } <nl> + infix operator - { associativity left precedence 140 } <nl> + infix operator & - { associativity left precedence 140 } <nl> + infix operator | { associativity left precedence 140 } <nl> + infix operator ^ { associativity left precedence 140 } <nl> <nl> / / FIXME : is this the right precedence level for " . . . " ? <nl> - operator infix . . . { associativity none precedence 135 } <nl> - operator infix . . < { associativity none precedence 135 } <nl> + infix operator . . . { associativity none precedence 135 } <nl> + infix operator . . < { associativity none precedence 135 } <nl> <nl> / / The cast operators ' as ' and ' is ' are hardcoded as if they had the <nl> / / following attributes : <nl> - / / operator infix as { associativity none precedence 132 } <nl> + / / infix operator as { associativity none precedence 132 } <nl> <nl> / / " Comparative " <nl> <nl> - operator infix < { associativity none precedence 130 } <nl> - operator infix < = { associativity none precedence 130 } <nl> - operator infix > { associativity none precedence 130 } <nl> - operator infix > = { associativity none precedence 130 } <nl> - operator infix = = { associativity none precedence 130 } <nl> - operator infix ! = { associativity none precedence 130 } <nl> - operator infix = = = { associativity none precedence 130 } <nl> - operator infix ! = = { associativity none precedence 130 } <nl> + infix operator < { associativity none precedence 130 } <nl> + infix operator < = { associativity none precedence 130 } <nl> + infix operator > { associativity none precedence 130 } <nl> + infix operator > = { associativity none precedence 130 } <nl> + infix operator = = { associativity none precedence 130 } <nl> + infix operator ! = { associativity none precedence 130 } <nl> + infix operator = = = { associativity none precedence 130 } <nl> + infix operator ! = = { associativity none precedence 130 } <nl> / / FIXME : ~ = will be built into the compiler . <nl> - operator infix ~ = { associativity none precedence 130 } <nl> + infix operator ~ = { associativity none precedence 130 } <nl> <nl> / / " Conjunctive " <nl> <nl> - operator infix & & { associativity left precedence 120 } <nl> + infix operator & & { associativity left precedence 120 } <nl> <nl> / / " Disjunctive " <nl> <nl> - operator infix | | { associativity left precedence 110 } <nl> + infix operator | | { associativity left precedence 110 } <nl> <nl> <nl> / / User - defined ternary operators are not supported . The ? : operator is <nl> operator infix | | { associativity left precedence 110 } <nl> <nl> / / User - defined assignment operators are not supported . The = operator is <nl> / / hardcoded as if it had the following attributes : <nl> - / / operator infix = { associativity right precedence 90 } <nl> + / / infix operator = { associativity right precedence 90 } <nl> <nl> / / Compound <nl> <nl> - operator infix * = { associativity right precedence 90 } <nl> - operator infix / = { associativity right precedence 90 } <nl> - operator infix % = { associativity right precedence 90 } <nl> - operator infix + = { associativity right precedence 90 } <nl> - operator infix - = { associativity right precedence 90 } <nl> - operator infix < < = { associativity right precedence 90 } <nl> - operator infix > > = { associativity right precedence 90 } <nl> - operator infix & = { associativity right precedence 90 } <nl> - operator infix ^ = { associativity right precedence 90 } <nl> - operator infix | = { associativity right precedence 90 } <nl> + infix operator * = { associativity right precedence 90 } <nl> + infix operator / = { associativity right precedence 90 } <nl> + infix operator % = { associativity right precedence 90 } <nl> + infix operator + = { associativity right precedence 90 } <nl> + infix operator - = { associativity right precedence 90 } <nl> + infix operator < < = { associativity right precedence 90 } <nl> + infix operator > > = { associativity right precedence 90 } <nl> + infix operator & = { associativity right precedence 90 } <nl> + infix operator ^ = { associativity right precedence 90 } <nl> + infix operator | = { associativity right precedence 90 } <nl> <nl> / / Workaround for < rdar : / / problem / 14011860 > SubTLF : Default <nl> / / implementations in protocols . Library authors should ensure <nl> operator infix | = { associativity right precedence 90 } <nl> / / test / Prototypes / GenericDispatch . swift for a fully documented <nl> / / example of how this operator is used , and how its use can be hidden <nl> / / from users . <nl> - operator infix ~ > { associativity left precedence 255 } <nl> + infix operator ~ > { associativity left precedence 255 } <nl> mmm a / test / Constraints / array_literal . swift <nl> ppp b / test / Constraints / array_literal . swift <nl> class Dict < K , V > : ArrayLiteralConvertible { <nl> class func convertFromArrayLiteral ( elements : ( K , V ) . . . ) - > Dict < K , V > { } <nl> } <nl> <nl> - operator infix = > { } <nl> + infix operator = > { } <nl> <nl> func = > < K , V > ( k : K , v : V ) - > ( K , V ) { return ( k , v ) } <nl> <nl> mmm a / test / Constraints / associated_self_types . swift <nl> ppp b / test / Constraints / associated_self_types . swift <nl> <nl> protocol P : CollectionType { <nl> init ( ) <nl> } <nl> - operator postfix ~ > > { } <nl> + postfix operator ~ > > { } <nl> <nl> postfix func ~ > > < _Self : SequenceType , A : P where _Self . Generator . Element = = A . Generator . Element > ( _ : _Self ) - > A { <nl> return A ( ) <nl> mmm a / test / Constraints / diag_ambiguities . swift <nl> ppp b / test / Constraints / diag_ambiguities . swift <nl> func f1 ( i : Int32 ) { } / / expected - note { { found this candidate } } <nl> <nl> f1 ( 0 ) / / expected - error { { ambiguous use of ' f1 ' } } <nl> <nl> - operator infix ppp { } <nl> + infix operator ppp { } <nl> <nl> func ppp ( i : Int , d : Double ) { } / / expected - note { { found this candidate } } <nl> func ppp ( d : Double , i : Int ) { } / / expected - note { { found this candidate } } <nl> mmm a / test / Constraints / diagnostics . swift <nl> ppp b / test / Constraints / diagnostics . swift <nl> i . wobble ( ) / / expected - error { { Int ' does not have a member named ' wobble ' } } <nl> / / Does not conform to protocol . <nl> / / FIXME : f5 ( i ) <nl> <nl> - operator infix * * * * { <nl> + infix operator * * * * { <nl> associativity left <nl> precedence 200 <nl> } <nl> operator infix * * * * { <nl> func * * * * ( _ : Int , _ : String ) { } / / expected - note { { in initialization of parameter ' _ ' } } <nl> i * * * * i / / expected - error { { ' Int ' is not convertible to ' String ' } } <nl> <nl> - operator infix * * * ~ { <nl> + infix operator * * * ~ { <nl> associativity left <nl> precedence 200 <nl> } <nl> mmm a / test / Constraints / generic_protocol_witness . swift <nl> ppp b / test / Constraints / generic_protocol_witness . swift <nl> <nl> / / RUN : % swift - parse - verify % s <nl> <nl> - operator infix • { } <nl> + infix operator • { } <nl> <nl> protocol Runcible { func runce ( ) } <nl> protocol Fungible { func funge ( ) } <nl> mmm a / test / Constraints / generics . swift <nl> ppp b / test / Constraints / generics . swift <nl> <nl> / / RUN : % swift - parse - verify % s <nl> <nl> - operator infix ppp { } <nl> + infix operator ppp { } <nl> <nl> protocol ConcatToAnything { <nl> func ppp < T > ( lhs : Self , other : T ) <nl> protocol BinaryMethodWorkaround { <nl> protocol Squigglable : BinaryMethodWorkaround { <nl> } <nl> <nl> - operator infix ~ ~ ~ { } <nl> + infix operator ~ ~ ~ { } <nl> <nl> func ~ ~ ~ < T : Squigglable where T . MySelf = = T > ( lhs : T , rhs : T ) - > Bool { <nl> return true <nl> mmm a / test / DebugInfo / autoclosure . swift <nl> ppp b / test / DebugInfo / autoclosure . swift <nl> func get_truth ( input : Int ) - > Int { <nl> <nl> <nl> / / Since this is an autoclosure test , don ' t use & & , which is transparent . <nl> - operator infix & & & & & { <nl> + infix operator & & & & & { <nl> associativity left <nl> precedence 120 <nl> } <nl> mmm a / test / Generics / associated_types . swift <nl> ppp b / test / Generics / associated_types . swift <nl> struct S1 : P1 { <nl> func foo ( ) - > X { } <nl> } <nl> <nl> - operator prefix % { } <nl> + prefix operator % { } <nl> <nl> protocol P2 { <nl> typealias Assoc2 <nl> struct S4 < T > : P3 , P4 { <nl> takeP4 ( S4 < Int > ( ) ) <nl> <nl> / / < rdar : / / problem / 14680393 > <nl> - operator infix ~ > { precedence 255 } <nl> + infix operator ~ > { precedence 255 } <nl> <nl> protocol P5 { } <nl> <nl> mmm a / test / Generics / deduction . swift <nl> ppp b / test / Generics / deduction . swift <nl> func testGetVectorSize ( vi : MyVector < Int > , vf : MyVector < Float > ) { <nl> } <nl> <nl> / / < rdar : / / problem / 15104554 > <nl> - operator postfix < * > { } <nl> + postfix operator < * > { } <nl> <nl> protocol MetaFunction { <nl> typealias Result <nl> mmm a / test / Generics / slice_test . swift <nl> ppp b / test / Generics / slice_test . swift <nl> <nl> <nl> import Swift <nl> <nl> - operator infix < { <nl> + infix operator < { <nl> associativity none <nl> precedence 170 <nl> } <nl> <nl> - operator infix = = { <nl> + infix operator = = { <nl> associativity none <nl> precedence 160 <nl> } <nl> <nl> - operator infix ! = { <nl> + infix operator ! = { <nl> associativity none <nl> precedence 160 <nl> } <nl> mmm a / test / IDE / Inputs / foo_swift_module . printed . comments . txt <nl> ppp b / test / IDE / Inputs / foo_swift_module . printed . comments . txt <nl> <nl> <nl> - operator infix % % % { <nl> + infix operator % % % { <nl> } <nl> <nl> func % % % ( lhs : Int , rhs : Int ) - > Int <nl> mmm a / test / IDE / Inputs / foo_swift_module . swift <nl> ppp b / test / IDE / Inputs / foo_swift_module . swift <nl> <nl> - operator infix % % % { <nl> + infix operator % % % { <nl> associativity left <nl> precedence 200 <nl> } <nl> mmm a / test / IDE / coloring . swift <nl> ppp b / test / IDE / coloring . swift <nl> class MySubClass : MyCls { <nl> convenience init ( a : Int ) { } <nl> } <nl> <nl> - / / CHECK : < kw > operator < / kw > < kw > infix < / kw > ~ ~ { <nl> - operator infix ~ ~ { } <nl> - / / CHECK : < kw > operator < / kw > < kw > prefix < / kw > * ~ ~ { <nl> - operator prefix * ~ ~ { } <nl> - / / CHECK : < kw > operator < / kw > < kw > postfix < / kw > ~ ~ * { <nl> - operator postfix ~ ~ * { } <nl> + / / CHECK : infix < kw > operator < / kw > ~ ~ { <nl> + infix operator ~ ~ { } <nl> + / / CHECK : prefix < kw > operator < / kw > * ~ ~ { <nl> + prefix operator * ~ ~ { } <nl> + / / CHECK : postfix < kw > operator < / kw > ~ ~ * { <nl> + postfix operator ~ ~ * { } <nl> <nl> / / FIXME : blah . <nl> / / FIXME : blah blah <nl> mmm a / test / IDE / print_ast_tc_decls . swift <nl> ppp b / test / IDE / print_ast_tc_decls . swift <nl> enum d2400_EnumDeclWithValues2 : Double { <nl> / / = = = mmm Custom operator printing . <nl> / / = = = mmm <nl> <nl> - operator postfix < * > { } <nl> + postfix operator < * > { } <nl> <nl> - / / PASS_2500 - LABEL : { { ^ } } operator postfix < * > { { { $ } } <nl> + / / PASS_2500 - LABEL : { { ^ } } postfix operator < * > { { { $ } } <nl> / / PASS_2500 - NEXT : { { ^ } } } { { $ } } <nl> <nl> protocol d2600_ProtocolWithOperator1 { <nl> protocol d2600_ProtocolWithOperator1 { <nl> / / PASS_2500 - NEXT : { { ^ } } } { { $ } } <nl> <nl> struct d2601_TestAssignment { } <nl> - operator infix % % % { } <nl> + infix operator % % % { } <nl> @ assignment func % % % ( inout lhs : d2601_TestAssignment , rhs : d2601_TestAssignment ) - > Int { <nl> return 0 <nl> } <nl> mmm a / test / IRGen / builtins . swift <nl> ppp b / test / IRGen / builtins . swift <nl> import Swift <nl> typealias Int = Builtin . Int32 <nl> typealias Bool = Builtin . Int1 <nl> <nl> - operator infix * { <nl> + infix operator * { <nl> associativity left <nl> precedence 200 <nl> } <nl> - operator infix / { <nl> + infix operator / { <nl> associativity left <nl> precedence 200 <nl> } <nl> - operator infix % { <nl> + infix operator % { <nl> associativity left <nl> precedence 200 <nl> } <nl> <nl> - operator infix + { <nl> + infix operator + { <nl> associativity left <nl> precedence 190 <nl> } <nl> - operator infix - { <nl> + infix operator - { <nl> associativity left <nl> precedence 190 <nl> } <nl> <nl> - operator infix < < { <nl> + infix operator < < { <nl> associativity none <nl> precedence 180 <nl> } <nl> - operator infix > > { <nl> + infix operator > > { <nl> associativity none <nl> precedence 180 <nl> } <nl> <nl> - operator infix . . . { <nl> + infix operator . . . { <nl> associativity none <nl> precedence 175 <nl> } <nl> <nl> - operator infix < { <nl> + infix operator < { <nl> associativity none <nl> precedence 170 <nl> } <nl> - operator infix < = { <nl> + infix operator < = { <nl> associativity none <nl> precedence 170 <nl> } <nl> - operator infix > { <nl> + infix operator > { <nl> associativity none <nl> precedence 170 <nl> } <nl> - operator infix > = { <nl> + infix operator > = { <nl> associativity none <nl> precedence 170 <nl> } <nl> <nl> - operator infix = = { <nl> + infix operator = = { <nl> associativity none <nl> precedence 160 <nl> } <nl> - operator infix ! = { <nl> + infix operator ! = { <nl> associativity none <nl> precedence 160 <nl> } <nl> mmm a / test / IRGen / partial_apply_generic . swift <nl> ppp b / test / IRGen / partial_apply_generic . swift <nl> <nl> <nl> / / FIXME : This should be a SIL test , but we can ' t parse generic types yet . <nl> <nl> - operator infix ~ > { precedence 255 } <nl> + infix operator ~ > { precedence 255 } <nl> <nl> func ~ > < Target , Args , Result > ( <nl> target : Target , <nl> mmm a / test / Interpreter / bool_as_generic . swift <nl> ppp b / test / Interpreter / bool_as_generic . swift <nl> <nl> / / < rdar : / / problem / 13986638 > Missing Bool metadata when Bool is used as a generic <nl> / / parameter or existential value <nl> <nl> - operator prefix ! ! { } <nl> - operator infix & & & { } <nl> + prefix operator ! ! { } <nl> + infix operator & & & { } <nl> <nl> prefix func ! ! < T : BooleanType > ( x : T ) - > Bool { <nl> return x . getLogicValue ( ) <nl> mmm a / test / Interpreter / tuples . swift <nl> ppp b / test / Interpreter / tuples . swift <nl> <nl> <nl> typealias Interval = ( lo : Int , hi : Int ) <nl> <nl> - operator infix < + > { } <nl> - operator infix < - > { } <nl> - operator infix < + > = { } <nl> + infix operator < + > { } <nl> + infix operator < - > { } <nl> + infix operator < + > = { } <nl> <nl> func < + > ( a : Interval , b : Interval ) - > Interval { <nl> return ( a . lo + b . lo , a . hi + b . hi ) <nl> mmm a / test / NameBinding / Inputs / tilde_tilde_high_precedence . swift <nl> ppp b / test / NameBinding / Inputs / tilde_tilde_high_precedence . swift <nl> <nl> / / Part of operators . swift multi - file test . <nl> <nl> - operator infix ~ ~ { <nl> + infix operator ~ ~ { <nl> associativity none <nl> precedence 200 <nl> } <nl> mmm a / test / NameBinding / Inputs / tilde_tilde_low_precedence . swift <nl> ppp b / test / NameBinding / Inputs / tilde_tilde_low_precedence . swift <nl> <nl> / / Part of operators . swift multi - file test . <nl> <nl> - operator infix ~ ~ { <nl> + infix operator ~ ~ { <nl> associativity none <nl> precedence 5 <nl> } <nl> public func ~ ~ ( x : Int , y : Int ) - > Bool { <nl> return x < y <nl> } <nl> <nl> - operator infix ~ ~ ~ { <nl> + infix operator ~ ~ ~ { <nl> associativity none <nl> precedence 5 <nl> } <nl> mmm a / test / NameBinding / name - binding . swift <nl> ppp b / test / NameBinding / name - binding . swift <nl> func func3 ( ) { <nl> <nl> struct a_struct { var x : Int } <nl> <nl> - operator infix * * * { <nl> + infix operator * * * { <nl> associativity left <nl> precedence 97 <nl> } <nl> var qualifiedvalue : Int = themodule . importedtype <nl> var qualifiedtype : themodule . x_ty = 5 <nl> <nl> <nl> - operator prefix ppp { } <nl> - operator postfix ppp { } <nl> + prefix operator ppp { } <nl> + postfix operator ppp { } <nl> <nl> - operator prefix + + { } <nl> - operator postfix + + { } <nl> + prefix operator + + { } <nl> + postfix operator + + { } <nl> <nl> @ assignment prefix func ppp ( inout a : Int ) { a + = 2 } <nl> @ assignment postfix func ppp ( inout a : Int ) { a + = 2 } <nl> mmm a / test / Parse / if_expr . swift <nl> ppp b / test / Parse / if_expr . swift <nl> func telescoping_if ( x : Bool , y : Int ) - > Int { <nl> } <nl> <nl> / / Operator with precedence above ? : <nl> - operator infix + > > { <nl> + infix operator + > > { <nl> associativity left <nl> precedence 110 <nl> } <nl> <nl> / / Operator with precedence below ? : <nl> - operator infix + < < { <nl> + infix operator + < < { <nl> associativity left <nl> precedence 90 <nl> } <nl> <nl> / / Operator with precedence equal to ? : <nl> - operator infix + = = { <nl> + infix operator + = = { <nl> associativity right <nl> precedence 100 <nl> } <nl> mmm a / test / Parse / matching_patterns . swift <nl> ppp b / test / Parse / matching_patterns . swift <nl> case NonNominal ( ) : / / expected - error { { non - nominal type ' NonNominal ' cannot be us <nl> <nl> var t = ( 1 , 2 , 3 ) <nl> <nl> - operator prefix ppp { } <nl> - operator infix ppp { } <nl> + prefix operator ppp { } <nl> + infix operator ppp { } <nl> prefix func ppp ( x : ( Int , Int , Int ) ) - > ( Int , Int , Int ) { return x } <nl> func ppp ( x : ( Int , Int , Int ) , y : ( Int , Int , Int ) ) - > ( Int , Int , Int ) { <nl> return ( x . 0 + y . 0 , x . 1 + y . 1 , x . 2 + y . 2 ) <nl> mmm a / test / Parse / operator_decl . swift <nl> ppp b / test / Parse / operator_decl . swift <nl> <nl> / / RUN : % swift - parse - verify % s <nl> <nl> - operator prefix ppp { } <nl> - operator postfix ppp { } <nl> - operator infix ppp { } <nl> - operator infix ppp = { <nl> + prefix operator ppp { } <nl> + postfix operator ppp { } <nl> + infix operator ppp { } <nl> + infix operator ppp = { <nl> associativity right <nl> } <nl> - operator infix * * * { <nl> + infix operator * * * { <nl> precedence 123 <nl> } <nl> - operator infix mmm { <nl> + infix operator mmm { <nl> precedence 123 <nl> associativity left <nl> } <nl> - operator infix > > > { <nl> + infix operator > > > { <nl> precedence 123 <nl> associativity right <nl> } <nl> - operator infix & & & { <nl> + infix operator & & & { <nl> associativity none <nl> precedence 123 <nl> } <nl> <nl> <nl> - operator prefix / / expected - error { { expected operator name after fixity in ' operator ' declaration } } <nl> + prefix operator / / expected - error { { expected operator name in operator declaration } } <nl> <nl> - operator prefix % % + / / expected - error { { expected ' { ' after operator name in ' operator ' declaration } } <nl> + ; <nl> + prefix operator % % + / / expected - error { { expected ' { ' after operator name in ' operator ' declaration } } <nl> <nl> - operator prefix % % / { <nl> + prefix operator % % / { <nl> + / / expected - error { { expected operator attribute identifier in ' operator ' declaration body } } <nl> } <nl> <nl> <nl> - operator prefix % % % { <nl> + prefix operator % % % { <nl> associativity none / / expected - error { { ' associativity ' is not a valid prefix operator attribute } } <nl> } <nl> - operator postfix % % % { <nl> + postfix operator % % % { <nl> associativity none / / expected - error { { ' associativity ' is not a valid postfix operator attribute } } <nl> } <nl> <nl> - operator infix ! ! ! { <nl> + infix operator ! ! ! { <nl> associativity none <nl> associativity left / / expected - error { { ' associativity ' for infix operator declared multiple times } } <nl> } <nl> <nl> - operator infix ^ ^ ^ { <nl> + infix operator ^ ^ ^ { <nl> precedence 22 <nl> precedence 44 / / expected - error { { ' precedence ' for infix operator declared multiple times } } <nl> } <nl> <nl> - operator infix = = = { <nl> + infix operator = = = { <nl> associativity free / / expected - error { { ' free ' is not a valid infix operator associativity } } <nl> } <nl> <nl> - operator infix ! = = { <nl> + infix operator ! = = { <nl> associativity 123 / / expected - error { { expected identifier after ' associativity ' in ' operator ' declaration body } } <nl> } <nl> <nl> - operator infix ! ! = { <nl> + infix operator ! ! = { <nl> precedence blah / / expected - error { { expected integer literal after ' precedence ' in ' operator ' declaration body } } <nl> } <nl> <nl> - operator infix ! < > { <nl> + infix operator ! < > { <nl> runcibility 12 / / expected - error { { ' runcibility ' is not a valid infix operator attribute } } <nl> } <nl> <nl> class Foo { <nl> - operator infix | | | { } / / expected - error { { ' operator ' may only be declared at file scope } } <nl> + infix operator | | | { } / / expected - error { { ' operator ' may only be declared at file scope } } <nl> } <nl> <nl> <nl> / / rdar : / / 14690497 <nl> - operator infix ~ > { precedence 99999 } / / expected - error { { ' precedence ' must be in the range of 0 to 255 } } <nl> + infix operator ~ > { precedence 99999 } / / expected - error { { ' precedence ' must be in the range of 0 to 255 } } <nl> <nl> mmm a / test / Parse / operators . swift <nl> ppp b / test / Parse / operators . swift <nl> <nl> <nl> / / This disables importing the stdlib intentionally . <nl> <nl> - operator infix = = { <nl> + infix operator = = { <nl> associativity left <nl> precedence 110 <nl> } <nl> <nl> - operator infix & { <nl> + infix operator & { <nl> associativity left <nl> precedence 150 <nl> } <nl> <nl> - operator infix = > { <nl> + infix operator = > { <nl> associativity right <nl> precedence 100 <nl> } <nl> func test1 ( ) { <nl> Man ( ) = = Five ( ) = > TheDevil ( ) = = Six ( ) = > God ( ) = = Seven ( ) <nl> } <nl> <nl> - operator postfix * ! * { } <nl> - operator prefix * ! * { } <nl> + postfix operator * ! * { } <nl> + prefix operator * ! * { } <nl> <nl> struct LOOK { } <nl> struct LOOKBang { <nl> func test2 ( ) { <nl> LOOK ( ) * ! * . exclaim ( ) <nl> <nl> <nl> - operator prefix ^ { } <nl> - operator infix ^ { } <nl> - operator postfix ^ { } <nl> + prefix operator ^ { } <nl> + infix operator ^ { } <nl> + postfix operator ^ { } <nl> <nl> postfix func ^ ( x : God ) - > TheDevil { } <nl> prefix func ^ ( x : TheDevil ) - > God { } <nl> var _ : God = Man ( ) ^ ( ) / / expected - error { { ' Man ' is not convertible to ' TheDevil ' <nl> <nl> func & ( x : Man , y : Man ) - > Man { return x } / / forgive amp_prefix token <nl> <nl> - operator prefix ⚽ ️ { } <nl> + prefix operator ⚽ ️ { } <nl> <nl> prefix func ⚽ ️ ( x : Man ) { } <nl> mmm a / test / Prototypes / TextFormatting . swift <nl> ppp b / test / Prototypes / TextFormatting . swift <nl> <nl> <nl> / / FIXME : Workaround for < rdar : / / problem / 14011860 > SubTLF : Default <nl> / / implementations in protocols . <nl> - operator infix ~ > { precedence 255 } <nl> + infix operator ~ > { precedence 255 } <nl> <nl> / / / \ brief A thing into which we can stream text <nl> protocol XOutputStream { <nl> mmm a / test / SILGen / apply_abstraction_nested . swift <nl> ppp b / test / SILGen / apply_abstraction_nested . swift <nl> <nl> / / RUN : % swift - emit - silgen % s | FileCheck % s <nl> - operator infix ~ > { precedence 255 associativity left } <nl> + infix operator ~ > { precedence 255 associativity left } <nl> <nl> protocol P { } <nl> <nl> mmm a / test / SILGen / mangling . swift <nl> ppp b / test / SILGen / mangling . swift <nl> func r13757744 ( # x : Int . . . ) { } <nl> / / < rdar : / / problem / 13757750 > Prefix , postfix , and infix operators need <nl> / / distinct manglings . <nl> <nl> - operator prefix + - { } <nl> - operator postfix + - { } <nl> - operator infix + - { } <nl> + prefix operator + - { } <nl> + postfix operator + - { } <nl> + infix operator + - { } <nl> <nl> / / CHECK - LABEL : sil @ _TF8manglingop2psU__FQ_T_ <nl> prefix func + - < T > ( a : T ) { } <nl> prefix func + - < T > ( _ : ( a : T , b : T ) ) { } <nl> / / CHECK - LABEL : sil @ _TF8manglingoP2psU__FT1aQ_1bQ__T_ <nl> postfix func + - < T > ( _ : ( a : T , b : T ) ) { } <nl> <nl> - operator infix « + » { } <nl> + infix operator « + » { } <nl> <nl> / / CHECK - LABEL : sil @ _TF8manglingXoi7p_qcaDcFTSiSi_Si <nl> func « + » ( a : Int , b : Int ) - > Int { return a + b } <nl> mmm a / test / SILGen / witness_tables . swift <nl> ppp b / test / SILGen / witness_tables . swift <nl> struct Arg { } <nl> <nl> @ objc class ObjCClass { } <nl> <nl> - operator infix < ~ > { } <nl> + infix operator < ~ > { } <nl> <nl> protocol AssocReqt { <nl> func requiredMethod ( ) <nl> mmm a / test / SILGen / witnesses . swift <nl> ppp b / test / SILGen / witnesses . swift <nl> <nl> / / RUN : % swift - emit - silgen % s | FileCheck % s <nl> <nl> - operator infix < ~ > { } <nl> + infix operator < ~ > { } <nl> <nl> func archetype_method < T : X > ( var # x : T , var # y : T ) - > T { <nl> return x . selfTypes ( x : y ) <nl> mmm a / test / SILPasses / allocbox_to_stack_with_false . swift <nl> ppp b / test / SILPasses / allocbox_to_stack_with_false . swift <nl> func g ( ) { <nl> <nl> / / Verify we don ' t crash on this . <nl> / / rdar : / / 15595118 <nl> - operator infix ~ > { precedence 255 } <nl> + infix operator ~ > { precedence 255 } <nl> protocol Target { } <nl> func ~ > < Target1 > ( inout x : Int , f : ( inout _ : Int , _ : Target ) - > Target ) - > ( Target ) - > Target { <nl> return { f ( & x , $ 0 ) } <nl> mmm a / test / SILPasses / mandatory_inlining . swift <nl> ppp b / test / SILPasses / mandatory_inlining . swift <nl> func call_curried ( x : Int , y : Int ) - > Int { <nl> / / CHECK : = apply <nl> / / CHECK : return <nl> <nl> - operator infix & & & { <nl> + infix operator & & & { <nl> associativity left <nl> precedence 120 <nl> } <nl> <nl> - operator infix | | | { <nl> + infix operator | | | { <nl> associativity left <nl> precedence 110 <nl> } <nl> mmm a / test / Serialization / Inputs / def_operator . swift <nl> ppp b / test / Serialization / Inputs / def_operator . swift <nl> <nl> - operator prefix ~ ~ ~ { } <nl> - operator postfix ^ ^ { } <nl> + prefix operator ~ ~ ~ { } <nl> + postfix operator ^ ^ { } <nl> <nl> - operator infix * - { <nl> + infix operator * - { <nl> associativity left <nl> precedence 50 <nl> } <nl> <nl> - operator infix - * { <nl> + infix operator - * { <nl> associativity right <nl> precedence 40 <nl> } <nl> <nl> - operator infix * - * { <nl> + infix operator * - * { <nl> associativity none <nl> precedence 10 <nl> } <nl> mmm a / test / Serialization / Inputs / has_generic_witness . swift <nl> ppp b / test / Serialization / Inputs / has_generic_witness . swift <nl> public struct BasStruct : Bassable { <nl> } <nl> <nl> <nl> - operator prefix ~ ~ ~ { } <nl> + prefix operator ~ ~ ~ { } <nl> <nl> public protocol _CyclicAssociatedType { <nl> typealias Assoc = CyclicImpl <nl> mmm a / test / Serialization / Inputs / struct_with_operators . swift <nl> ppp b / test / Serialization / Inputs / struct_with_operators . swift <nl> public struct SpecialInt { <nl> public init ( ) { } <nl> } <nl> <nl> - operator prefix ppp { } <nl> - operator postfix ppp { } <nl> + prefix operator ppp { } <nl> + postfix operator ppp { } <nl> <nl> prefix public func ppp ( inout base : SpecialInt ) { <nl> base . value + = 2 <nl> mmm a / test / attr / attr_assignment . swift <nl> ppp b / test / attr / attr_assignment . swift <nl> <nl> / / RUN : % swift % s - verify <nl> <nl> / / Assignment operators <nl> - operator infix + - { <nl> + infix operator + - { <nl> precedence 90 <nl> associativity left <nl> } <nl> mmm a / test / decl / func / arg_rename . swift <nl> ppp b / test / decl / func / arg_rename . swift <nl> class X { <nl> } <nl> <nl> / / Operators never have keyword arguments . <nl> - operator infix ppp { } <nl> + infix operator ppp { } <nl> func ppp ( # lhs : Int , / / expected - error { { operator cannot have keyword arguments } } { { 10 - 11 = } } <nl> rhs x : Int ) - > Int { / / expected - error { { operator cannot have keyword arguments } } { { 10 - 14 = } } <nl> return lhs + x <nl> mmm a / test / decl / func / functions . swift <nl> ppp b / test / decl / func / functions . swift <nl> <nl> / / RUN : % swift % s - verify <nl> <nl> - operator infix = = = = { } <nl> - operator infix < < < < { } <nl> - operator infix < > < > { } <nl> + infix operator = = = = { } <nl> + infix operator < < < < { } <nl> + infix operator < > < > { } <nl> <nl> / / < rdar : / / problem / 13782566 > <nl> / / Check that func op < T > ( ) parses without a space between the name and the <nl> mmm a / test / decl / operator / operators . swift <nl> ppp b / test / decl / operator / operators . swift <nl> <nl> / / RUN : % swift % s - verify <nl> <nl> - operator infix % % % { } <nl> - operator infix % % % % { } <nl> + infix operator % % % { } <nl> + infix operator % % % % { } <nl> <nl> func % % % ( ) { } / / expected - error { { operators must have one or two arguments } } <nl> func % % % % ( a : Int , b : Int , c : Int ) { } / / expected - error { { operators must have one or two arguments } } <nl> func + ( lhs : X , rhs : X ) - > X { } / / okay <nl> <nl> func ppp ( lhs : X , rhs : X ) - > X { } / / expected - error { { operator implementation without matching operator declaration } } <nl> <nl> - operator infix ppp + { <nl> + infix operator ppp + { <nl> precedence 195 <nl> associativity left <nl> } <nl> func test ( ) { <nl> useInt ( x = y ) / / expected - error { { ' ( ) ' is not convertible to ' Int ' } } <nl> } <nl> <nl> - operator prefix ~ ~ { } <nl> - operator postfix ~ ~ { } <nl> - operator infix ~ ~ { } <nl> + prefix operator ~ ~ { } <nl> + postfix operator ~ ~ { } <nl> + infix operator ~ ~ { } <nl> <nl> postfix func foo ( x : Int ) { } / / expected - error { { ' postfix ' requires a function with an operator identifier } } <nl> postfix func ~ ~ ( x : Int ) - > Float { return Float ( x ) } <nl> func test_postfix ( x : Int ) { <nl> ~ ~ x ~ ~ <nl> } <nl> <nl> - operator prefix ~ ~ ~ { } / / expected - note 2 { { prefix operator found here } } <nl> + prefix operator ~ ~ ~ { } / / expected - note 2 { { prefix operator found here } } <nl> <nl> / / Unary operators require a prefix or postfix attribute <nl> func ~ ~ ~ ( x : Float ) { } / / expected - error { { prefix unary operator missing ' prefix ' attribute } } { { 1 - 1 = prefix } } <nl> func errors ( ) { <nl> * / + / / expected - error { { unexpected end of block comment } } <nl> } <nl> <nl> - operator prefix . . . { } <nl> + prefix operator . . . { } <nl> <nl> prefix func . . . ( arg : Int ) - > Int { return arg } <nl> func resyncParser ( ) { } <nl> <nl> / / Operator decl refs ( < op > ) <nl> <nl> - operator infix + - + { } <nl> - operator prefix + - + { } <nl> + infix operator + - + { } <nl> + prefix operator + - + { } <nl> <nl> - operator prefix - + - { } <nl> - operator postfix - + - { } <nl> + prefix operator - + - { } <nl> + postfix operator - + - { } <nl> <nl> - operator infix + - + = { } <nl> + infix operator + - + = { } <nl> <nl> infix func + - + ( x : Int , y : Int ) - > Int { } <nl> prefix func + - + ( x : Int ) - > Int { } <nl> var f6_s : f6_S <nl> var junk = f6_s [ + ] <nl> <nl> / / Unicode operator names <nl> - operator infix ☃ { } <nl> - operator infix ☃ ⃠ { } / / Operators can contain ( but not start with ) combining characters <nl> + infix operator ☃ { } <nl> + infix operator ☃ ⃠ { } / / Operators can contain ( but not start with ) combining characters <nl> <nl> func ☃ ( x : Int , y : Int ) - > Bool { return x = = y } <nl> func ☃ ⃠ ( x : Int , y : Int ) - > Bool { return x ! = y } <nl> postfix prefix func + + ( x : Int ) { } / / expected - error { { attribute ' postfix ' cannot <nl> / / Don ' t allow one to define a postfix ' ! ' ; it ' s built into the <nl> / / language . <nl> / / FIXME : Ban these on operator decls . <nl> - operator postfix ! { } <nl> - operator prefix & { } <nl> + postfix operator ! { } <nl> + prefix operator & { } <nl> <nl> postfix func ! ( x : Int ) { } / / expected - error { { cannot declare a custom postfix ' ! ' operator } } <nl> postfix func ! ( x : Int8 ) { } / / expected - error { { cannot declare a custom postfix ' ! ' operator } } <nl> mmm a / test / decl / protocol / protocols . swift <nl> ppp b / test / decl / protocol / protocols . swift <nl> protocol Eq { <nl> extension Int : Eq { } <nl> <nl> / / Matching prefix / postfix . <nl> - operator prefix < > { } <nl> - operator postfix < > { } <nl> + prefix operator < > { } <nl> + postfix operator < > { } <nl> <nl> protocol IndexValue { <nl> prefix func < > ( max : Self ) - > Int <nl> mmm a / test / decl / protocol / req / func . swift <nl> ppp b / test / decl / protocol / req / func . swift <nl> struct X2z : P2 { / / expected - error { { type ' X2z ' does not conform to protocol ' P2 <nl> } <nl> <nl> / / Protocol with prefix unary function <nl> - operator prefix ~ ~ { } <nl> + prefix operator ~ ~ { } <nl> <nl> protocol P3 { <nl> typealias Assoc : P1 <nl> struct X3z : P3 { / / expected - error { { type ' X3z ' does not conform to protocol ' P3 <nl> postfix func ~ ~ ( _ : X3z ) - > X1a { } / / expected - note { { candidate is postfix , not prefix as required } } expected - note { { candidate has non - matching type ' ( X3z ) - > X1a ' } } <nl> <nl> / / Protocol with postfix unary function <nl> - operator postfix ~ ~ { } <nl> + postfix operator ~ ~ { } <nl> protocol P4 { <nl> typealias Assoc : P1 <nl> postfix func ~ ~ ( _ : Self ) - > Assoc / / expected - note { { protocol requires function ' ~ ~ ' with type ' X4z - > Assoc ' } } <nl> func f ( args : T1 ) { <nl> <nl> f ( T0 ( 1 , " Hi " ) ) <nl> <nl> - operator infix ~ > > { precedence 255 } <nl> + infix operator ~ > > { precedence 255 } <nl> <nl> func ~ > > ( x : Int , args : T0 ) { println ( " T0 " ) } <nl> func ~ > > ( x : Int , args : T1 ) { println ( " T1 " ) } <nl> protocol P7 { <nl> struct X7 : P7 { } <nl> <nl> / / Selecting the most specialized witness . <nl> - operator prefix % % % { } <nl> + prefix operator % % % { } <nl> <nl> protocol P8 { <nl> func foo ( ) <nl> mmm a / test / expr / expressions . swift <nl> ppp b / test / expr / expressions . swift <nl> func basictest ( ) { <nl> } <nl> <nl> / / Infix operators and attribute lists . <nl> - operator infix % % { <nl> + infix operator % % { <nl> associativity left <nl> precedence 2 <nl> } <nl> func foo1 ( a : Int , b : Int ) - > Int { } <nl> func foo2 ( a : Int ) - > ( b : Int ) - > Int { } <nl> func foo3 ( a : Int = 2 , b : Int = 3 ) { } <nl> <nl> - operator prefix ^ ^ { } <nl> + prefix operator ^ ^ { } <nl> <nl> prefix func ^ ^ ( a : Int ) - > Int { <nl> return a + 1 <nl> func magic_literals ( ) { <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - = = = / / <nl> <nl> <nl> - operator infix + - + = { } <nl> + infix operator + - + = { } <nl> @ assignment func + - + = ( inout x : Int , y : Int ) - > Int { return 0 } <nl> <nl> func lvalue_processing ( ) { <nl> mmm a / test / stdlib / Algorithm . swift <nl> ppp b / test / stdlib / Algorithm . swift <nl> testSplit ( ) <nl> / / FIXME : Until < rdar : / / problem / 13985164 > is fixed , we can ' t build <nl> / / generic algorithms that work on Sequences , so need a lightweight <nl> / / way to get Streams out of them . <nl> - operator prefix ^ { } <nl> + prefix operator ^ { } <nl> prefix func ^ ( x : [ Int ] ) - > Array < Int > . Generator <nl> { return x . generate ( ) } <nl> <nl> struct VecIntStream : GeneratorType , SequenceType { <nl> var value : Array < Int > . Generator <nl> } <nl> <nl> - operator prefix ^ ^ { } <nl> + prefix operator ^ ^ { } <nl> prefix func ^ ^ ( x : [ Int ] ) - > VecIntStream <nl> { <nl> var result = Array < Int > ( ) <nl>
Change " operator infix " to " infix operator " for consistency with the rest of the declaration
apple/swift
57cd2506ffe5df92dbfc00eb919c4d9baf88a09b
2014-07-14T16:39:10Z
mmm a / tensorflow / python / framework / errors_test . py <nl> ppp b / tensorflow / python / framework / errors_test . py <nl> <nl> class ErrorsTest ( test . TestCase ) : <nl> <nl> def _CountReferences ( self , typeof ) : <nl> - return len ( [ o for o in gc . get_objects ( ) if isinstance ( o , typeof ) ] ) <nl> + " " " Count number of references to objects of type | typeof | . " " " <nl> + objs = gc . get_objects ( ) <nl> + ref_count = 0 <nl> + for o in objs : <nl> + try : <nl> + if isinstance ( o , typeof ) : <nl> + ref_count + = 1 <nl> + # Certain versions of python keeps a weakref to deleted objects . <nl> + except ReferenceError : <nl> + pass <nl> + return ref_count <nl> <nl> def testUniqueClassForEachErrorCode ( self ) : <nl> for error_code , exc_type in [ <nl>
Handle weakref under python3 / macosx in refcount test .
tensorflow/tensorflow
2f7ba0747dd7583f428937f9c8fd2970fe3fdeae
2017-09-26T03:57:58Z
new file mode 100644 <nl> index 00000000000 . . eb437f3c233 <nl> mmm / dev / null <nl> ppp b / docker / docker - python / Dockerfile . mxnet . python . cpu <nl> <nl> + # - * - mode : dockerfile - * - <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> + # Dockerfile to build MXNet for CPU <nl> + <nl> + FROM ubuntu : 16 . 04 <nl> + <nl> + RUN apt - get update <nl> + RUN apt - get install - y wget python gcc <nl> + RUN wget https : / / bootstrap . pypa . io / get - pip . py <nl> + RUN python get - pip . py <nl> + <nl> + RUN pip install mxnet <nl> new file mode 100644 <nl> index 00000000000 . . 043932ff7c8 <nl> mmm / dev / null <nl> ppp b / docker / docker - python / Dockerfile . mxnet . python . cpu . mkl <nl> <nl> + # - * - mode : dockerfile - * - <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> + # Dockerfile to build MXNet CPU with MKL <nl> + <nl> + FROM ubuntu : 16 . 04 <nl> + <nl> + RUN apt - get update <nl> + RUN apt - get install - y wget python gcc <nl> + RUN wget https : / / bootstrap . pypa . io / get - pip . py <nl> + RUN python get - pip . py <nl> + <nl> + RUN pip install mxnet - mkl <nl> new file mode 100644 <nl> index 00000000000 . . 8c83ece434a <nl> mmm / dev / null <nl> ppp b / docker / docker - python / Dockerfile . mxnet . python . gpu . cu80 <nl> <nl> + # - * - mode : dockerfile - * - <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> + # Dockerfile to build MXNet for GPU <nl> + <nl> + FROM nvidia / cuda : 8 . 0 - cudnn5 - devel <nl> + <nl> + RUN apt - get update <nl> + RUN apt - get install - y wget python gcc <nl> + RUN wget https : / / bootstrap . pypa . io / get - pip . py <nl> + RUN python get - pip . py <nl> + <nl> + RUN pip install mxnet - cu80 <nl> new file mode 100644 <nl> index 00000000000 . . a057c1d20cb <nl> mmm / dev / null <nl> ppp b / docker / docker - python / Dockerfile . mxnet . python . gpu . cu80 . mkl <nl> <nl> + # - * - mode : dockerfile - * - <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> + # Dockerfile to build MXNet for GPU with MKL <nl> + <nl> + FROM nvidia / cuda : 8 . 0 - cudnn5 - devel <nl> + <nl> + RUN apt - get update <nl> + RUN apt - get install - y wget python gcc <nl> + RUN wget https : / / bootstrap . pypa . io / get - pip . py <nl> + RUN python get - pip . py <nl> + <nl> + RUN pip install mxnet - cu80mkl <nl> new file mode 100644 <nl> index 00000000000 . . 1e3d9869ac6 <nl> mmm / dev / null <nl> ppp b / docker / docker - python / Dockerfile . mxnet . python . gpu . cu90 <nl> <nl> + # - * - mode : dockerfile - * - <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> + # Dockerfile to build MXNet for GPU <nl> + <nl> + FROM nvidia / cuda : 9 . 0 - cudnn7 - devel <nl> + <nl> + RUN apt - get update <nl> + RUN apt - get install - y wget python gcc <nl> + RUN wget https : / / bootstrap . pypa . io / get - pip . py <nl> + RUN python get - pip . py <nl> + <nl> + RUN pip install mxnet - cu90 <nl> new file mode 100644 <nl> index 00000000000 . . d82abd7cf52 <nl> mmm / dev / null <nl> ppp b / docker / docker - python / Dockerfile . mxnet . python . gpu . cu90 . mkl <nl> <nl> + # - * - mode : dockerfile - * - <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> + # Dockerfile to build MXNet for GPU with MKL <nl> + <nl> + FROM nvidia / cuda : 9 . 0 - cudnn7 - devel <nl> + <nl> + RUN apt - get update <nl> + RUN apt - get install - y wget python gcc <nl> + RUN wget https : / / bootstrap . pypa . io / get - pip . py <nl> + RUN python get - pip . py <nl> + <nl> + RUN pip install mxnet - cu90mkl <nl> new file mode 100644 <nl> index 00000000000 . . ba5c54a2a2a <nl> mmm / dev / null <nl> ppp b / docker / docker - python / Dockerfile . mxnet . python . gpu . cu92 <nl> <nl> + # - * - mode : dockerfile - * - <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> + # Dockerfile to build MXNet for GPU <nl> + <nl> + FROM nvidia / cuda : 9 . 2 - cudnn7 - devel <nl> + <nl> + RUN apt - get update <nl> + RUN apt - get install - y wget python gcc <nl> + RUN wget https : / / bootstrap . pypa . io / get - pip . py <nl> + RUN python get - pip . py <nl> + <nl> + RUN pip install mxnet - cu92 <nl> new file mode 100644 <nl> index 00000000000 . . 96a943980b5 <nl> mmm / dev / null <nl> ppp b / docker / docker - python / Dockerfile . mxnet . python . gpu . cu92 . mkl <nl> <nl> + # - * - mode : dockerfile - * - <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> + # Dockerfile to build MXNet for GPU with MKL <nl> + <nl> + FROM nvidia / cuda : 9 . 2 - cudnn7 - devel <nl> + <nl> + RUN apt - get update <nl> + RUN apt - get install - y wget python gcc <nl> + RUN wget https : / / bootstrap . pypa . io / get - pip . py <nl> + RUN python get - pip . py <nl> + <nl> + RUN pip install mxnet - cu92mkl <nl> new file mode 100644 <nl> index 00000000000 . . f806d5d6f45 <nl> mmm / dev / null <nl> ppp b / docker / docker - python / README . md <nl> <nl> + # Release Python Docker Images for MXNet <nl> + <nl> + The ` docker - python ` directory can be used to release mxnet python docker images to dockerhub after any mxnet release . <nl> + It uses the appropriate pip binaries to build different docker images as - <nl> + * cpu <nl> + * cpu_mkl <nl> + * latest ( same as cpu ) <nl> + * gpu_cu90 <nl> + * gpu_cu90_mkl <nl> + * gpu ( same as gpu_cu90 ) <nl> + * gpu_cu80 <nl> + * gpu_cu80_mkl <nl> + * gpu_cu92 <nl> + * gpu_cu92_mkl <nl> + <nl> + <nl> + * * Note : If you want to use a different pip binary ( specific mxnet or cuda version , etc ) , you can edit the last line of the cpu or gpu dockerfile as required . <nl> + <nl> + Refer : https : / / pypi . org / project / mxnet / <nl> + <nl> + # # # Usage <nl> + ` . / build_python_dockerfile . sh < mxnet_version > < path_to_cloned_mxnet_repo > ` <nl> + <nl> + For example : <nl> + ` . / build_python_dockerfile . sh 1 . 3 . 0 ~ / build - docker / incubator - mxnet ` <nl> + <nl> + * * Note : The build script picks up the latest pip binaries . This means it uses the latest released mxnet version . The version specified as a parameter to the script is only used to tag the built image correctly . <nl> + <nl> + # # # Tests run <nl> + * [ test_conv . py ] ( https : / / github . com / apache / incubator - mxnet / blob / master / tests / python / train / test_conv . py ) <nl> + * [ train_mnist . py ] ( https : / / github . com / apache / incubator - mxnet / blob / master / example / image - classification / train_mnist . py ) <nl> + * [ test_mxnet . py ] ( https : / / github . com / apache / incubator - mxnet / blob / master / docker / docker - python / test_mxnet . py ) : This script is used to make sure that the docker image builds the expected mxnet version . That is , the version picked by pip is the same as as the version passed as a parameter . <nl> + <nl> + # # # Dockerhub Credentials <nl> + Dockerhub credentials will be required to push images at the end of this script . <nl> + Credentials can be provided in the following ways : <nl> + * * * Interactive Login : * * Run the script as is and it will ask you for credentials interactively . <nl> + * * * Be Already Logged in : * * Login to the mxnet dockerhub account before you run the build script and the script will complete build , test and push . <nl> + * * * Set Environment Variables : * * Set the following environment variables which the script will pick up to login to dockerhub at runtime - <nl> + * $ MXNET_DOCKERHUB_PASSWORD <nl> + * $ MXNET_DOCKERHUB_USERNAME <nl> new file mode 100755 <nl> index 00000000000 . . 24a44c28970 <nl> mmm / dev / null <nl> ppp b / docker / docker - python / build_python_dockerfile . sh <nl> <nl> + # ! / usr / bin / env bash <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> + set - e <nl> + <nl> + # Check Params <nl> + programname = $ 0 <nl> + <nl> + function usage { <nl> + echo " usage : $ programname [ version ] [ path ] " <nl> + echo " [ version ] Mxnet Version to build " <nl> + echo " [ path ] Path to MXNet repository ( to run tests ) " <nl> + echo " " <nl> + exit 1 <nl> + } <nl> + <nl> + if [ $ # - le 1 ] | | [ $ # - ge 3 ] <nl> + then <nl> + usage <nl> + exit 1 <nl> + fi <nl> + <nl> + # Two params provided <nl> + echo " Building Docker Images for Apache MXNet ( Incubating ) v $ 1 " <nl> + mxnet_version = " $ { 1 } " <nl> + test_dir = " $ { 2 } " <nl> + <nl> + docker_build_image ( ) { <nl> + echo " Building docker image mxnet / python : $ { 1 } " <nl> + docker build - t mxnet / python : $ { 1 } - f $ { 2 } . <nl> + } <nl> + <nl> + docker_tag_image ( ) { <nl> + docker tag mxnet / python : $ { 1 } mxnet / python : $ { 2 } <nl> + } <nl> + <nl> + docker_test_image_cpu ( ) { <nl> + echo " Running tests on mxnet / python : $ { 1 } " <nl> + docker run - v $ { test_dir } : / mxnet mxnet / python : $ { 1 } bash - c " python / mxnet / docker / docker - python / test_mxnet . py $ { mxnet_version } " <nl> + docker run - v $ { test_dir } : / mxnet mxnet / python : $ { 1 } bash - c " python / mxnet / tests / python / train / test_conv . py " <nl> + docker run - v $ { test_dir } : / mxnet mxnet / python : $ { 1 } bash - c " python / mxnet / example / image - classification / train_mnist . py " <nl> + } <nl> + <nl> + docker_test_image_gpu ( ) { <nl> + echo " Running tests on mxnet / python : $ { 1 } " <nl> + nvidia - docker run - v $ { test_dir } : / mxnet mxnet / python : $ { 1 } bash - c " python / mxnet / docker / docker - python / test_mxnet . py $ { mxnet_version } " <nl> + nvidia - docker run - v $ { test_dir } : / mxnet mxnet / python : $ { 1 } bash - c " python / mxnet / tests / python / train / test_conv . py - - gpu " <nl> + nvidia - docker run - v $ { test_dir } : / mxnet mxnet / python : $ { 1 } bash - c " python / mxnet / example / image - classification / train_mnist . py - - gpus 2 " <nl> + } <nl> + <nl> + # if both $ MXNET_DOCKERHUB_PASSWORD and $ MXNET_DOCKERHUB_USERNAME environment variables are set , docker will automatically login <nl> + # if env variables are not set , login will be interactive . <nl> + docker_account_login ( ) { <nl> + if [ [ - z $ MXNET_DOCKERHUB_PASSWORD ] ] | | [ [ - z $ MXNET_DOCKERHUB_USERNAME ] ] ; then <nl> + docker login <nl> + else <nl> + echo $ MXNET_DOCKERHUB_PASSWORD | docker login - u $ MXNET_DOCKERHUB_USERNAME - - password - stdin <nl> + fi <nl> + } <nl> + <nl> + docker_account_logout ( ) { <nl> + docker logout <nl> + } <nl> + <nl> + docker_push_image ( ) { <nl> + docker push mxnet / python : $ { 1 } <nl> + } <nl> + <nl> + <nl> + # Build and Test dockerfiles - CPU <nl> + docker_build_image " $ { mxnet_version } _cpu " " Dockerfile . mxnet . python . cpu " <nl> + docker_test_image_cpu " $ { mxnet_version } _cpu " <nl> + <nl> + docker_build_image " $ { mxnet_version } _cpu_mkl " " Dockerfile . mxnet . python . cpu . mkl " <nl> + docker_test_image_cpu " $ { mxnet_version } _cpu_mkl " <nl> + <nl> + docker_tag_image " $ { mxnet_version } _cpu " " latest " <nl> + docker_test_image_cpu " latest " <nl> + <nl> + <nl> + # Build and Test dockerfiles - GPU <nl> + docker_build_image " $ { mxnet_version } _gpu_cu90 " " Dockerfile . mxnet . python . gpu . cu90 " <nl> + docker_test_image_gpu " $ { mxnet_version } _gpu_cu90 " <nl> + <nl> + docker_build_image " $ { mxnet_version } _gpu_cu90_mkl " " Dockerfile . mxnet . python . gpu . cu90 . mkl " <nl> + docker_test_image_gpu " $ { mxnet_version } _gpu_cu90_mkl " <nl> + <nl> + docker_tag_image " $ { mxnet_version } _gpu_cu90 " " gpu " <nl> + docker_test_image_gpu " gpu " <nl> + <nl> + docker_build_image " $ { mxnet_version } _gpu_cu80 " " Dockerfile . mxnet . python . gpu . cu80 " <nl> + docker_test_image_gpu " $ { mxnet_version } _gpu_cu80 " <nl> + <nl> + docker_build_image " $ { mxnet_version } _gpu_cu80_mkl " " Dockerfile . mxnet . python . gpu . cu80 . mkl " <nl> + docker_test_image_gpu " $ { mxnet_version } _gpu_cu80_mkl " <nl> + <nl> + docker_build_image " $ { mxnet_version } _gpu_cu92 " " Dockerfile . mxnet . python . gpu . cu92 " <nl> + docker_test_image_gpu " $ { mxnet_version } _gpu_cu92 " <nl> + <nl> + docker_build_image " $ { mxnet_version } _gpu_cu92_mkl " " Dockerfile . mxnet . python . gpu . cu92 . mkl " <nl> + docker_test_image_gpu " $ { mxnet_version } _gpu_cu92_mkl " <nl> + <nl> + <nl> + # Push dockerfiles <nl> + echo " All images were successfully built . Now login to dockerhub and push images " <nl> + docker_account_login <nl> + <nl> + docker_push_image " $ { mxnet_version } _cpu " <nl> + docker_push_image " $ { mxnet_version } _cpu_mkl " <nl> + docker_push_image " latest " <nl> + docker_push_image " $ { mxnet_version } _gpu_cu90 " <nl> + docker_push_image " $ { mxnet_version } _gpu_cu90_mkl " <nl> + docker_push_image " gpu " <nl> + docker_push_image " $ { mxnet_version } _gpu_cu80 " <nl> + docker_push_image " $ { mxnet_version } _gpu_cu80_mkl " <nl> + docker_push_image " $ { mxnet_version } _gpu_cu92 " <nl> + docker_push_image " $ { mxnet_version } _gpu_cu92_mkl " <nl> + <nl> + docker_account_logout <nl> + <nl> + echo " Successfully Built , Tested and Pushed all Images to Dockerhub . Link : https : / / hub . docker . com / r / mxnet / python / tags / " <nl> new file mode 100644 <nl> index 00000000000 . . 65720583272 <nl> mmm / dev / null <nl> ppp b / docker / docker - python / test_mxnet . py <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> + # This checks that the version of mxnet imported matches the parameter passed to the build script . <nl> + import mxnet as mx <nl> + import sys <nl> + <nl> + pip_version = mx . __version__ <nl> + expected_version = sys . argv [ 1 ] <nl> + <nl> + if pip_version ! = expected_version : <nl> + raise ValueError ( " ERROR : Incorrect pip version . Please check the parameter passed or pip binary used . " ) <nl>
[ MXNET - 951 ] Python dockerfiles built on pip binaries and build / release script ( )
apache/incubator-mxnet
063139d6ee12e5b54ebe6f79faddf6cda9ba0897
2018-09-29T04:36:08Z
mmm a / hphp / hack / src / errors / error_codes . ml <nl> ppp b / hphp / hack / src / errors / error_codes . ml <nl> module Typing = struct <nl> type t = <nl> | AbstractClassFinalDEPRECATED [ @ value 4001 ] <nl> | UninstantiableClass <nl> - | AnonymousRecursive <nl> - | AnonymousRecursiveCall <nl> + | AnonymousRecursiveDEPRECATED <nl> + | AnonymousRecursiveCallDEPRECATED <nl> | ArrayAccess <nl> | ArrayAppend <nl> | ArrayCast <nl> mmm a / hphp / hack / src / errors / errors . ml <nl> ppp b / hphp / hack / src / errors / errors . ml <nl> let nullable_cast pos ty ty_pos = <nl> ( ty_pos , " This is " ^ ty ) ; <nl> ] <nl> <nl> - let anonymous_recursive pos = <nl> - add <nl> - ( Typing . err_code Typing . AnonymousRecursive ) <nl> - pos <nl> - " Anonymous functions cannot be recursive " <nl> - <nl> let static_outside_class pos = <nl> add <nl> ( Typing . err_code Typing . StaticOutsideClass ) <nl> let typing_too_few_args required actual pos pos_def = <nl> ( pos_def , " Definition is here " ) ; <nl> ] <nl> <nl> - let anonymous_recursive_call pos = <nl> - add <nl> - ( Typing . err_code Typing . AnonymousRecursiveCall ) <nl> - pos <nl> - " recursive call to anonymous function " <nl> - <nl> let bad_call pos ty = <nl> add <nl> ( Typing . err_code Typing . BadCall ) <nl> mmm a / hphp / hack / src / errors / errors . mli <nl> ppp b / hphp / hack / src / errors / errors . mli <nl> val array_cast : Pos . t - > unit <nl> <nl> val string_cast : Pos . t - > string - > unit <nl> <nl> - val anonymous_recursive : Pos . t - > unit <nl> - <nl> val static_outside_class : Pos . t - > unit <nl> <nl> val self_outside_class : Pos . t - > unit <nl> val typing_too_many_args : int - > int - > Pos . t - > Pos . t - > unit <nl> <nl> val typing_too_few_args : int - > int - > Pos . t - > Pos . t - > unit <nl> <nl> - val anonymous_recursive_call : Pos . t - > unit <nl> - <nl> val bad_call : Pos . t - > string - > unit <nl> <nl> val extend_final : Pos . t - > Pos . t - > string - > unit <nl> mmm a / hphp / hack / src / hh_single_type_check . ml <nl> ppp b / hphp / hack / src / hh_single_type_check . ml <nl> let parse_options ( ) = <nl> let error_format = ref Errors . Context in <nl> let forbid_nullable_cast = ref false in <nl> let deregister_attributes = ref None in <nl> - let disallow_ambiguous_lambda = ref None in <nl> let disallow_array_typehint = ref None in <nl> let disallow_array_literal = ref None in <nl> let dynamic_view = ref None in <nl> let auto_namespace_map = ref None in <nl> let unsafe_rx = ref ( Some false ) in <nl> let log_inference_constraints = ref None in <nl> - let new_inference_lambda = ref ( Some false ) in <nl> let timeout = ref None in <nl> let disallow_invalid_arraykey = ref None in <nl> let disallow_byref_dynamic_calls = ref ( Some false ) in <nl> let parse_options ( ) = <nl> ( " - - forbid_nullable_cast " , <nl> Arg . Set forbid_nullable_cast , <nl> " Forbid casting from nullable values . " ) ; <nl> - ( " - - disallow - ambiguous - lambda " , <nl> - Arg . Unit ( set_bool disallow_ambiguous_lambda ) , <nl> - " Disallow definition of lambdas that require use - site checking . " ) ; <nl> ( " - - disallow - array - typehint " , <nl> Arg . Unit ( set_bool disallow_array_typehint ) , <nl> " Disallow usage of array typehints . " ) ; <nl> let parse_options ( ) = <nl> ( " - - log - inference - constraints " , <nl> Arg . Unit ( set_bool log_inference_constraints ) , <nl> " Log inference constraints to Scuba . " ) ; <nl> - ( " - - new - inference - lambda " , <nl> - Arg . Unit ( set_bool new_inference_lambda ) , <nl> - " Type inference of unannotated lambdas by constraint generation . " ) ; <nl> ( " - - timeout " , <nl> Arg . Int ( fun secs - > timeout : = Some secs ) , <nl> " Timeout in seconds for checking a function or a class . " ) ; <nl> let parse_options ( ) = <nl> GlobalOptions . make <nl> ? tco_unsafe_rx : ! unsafe_rx <nl> ? po_deregister_php_stdlib : ! deregister_attributes <nl> - ? tco_disallow_ambiguous_lambda : ! disallow_ambiguous_lambda <nl> ? tco_disallow_array_typehint : ! disallow_array_typehint <nl> ? tco_disallow_array_literal : ! disallow_array_literal <nl> ? tco_dynamic_view : ! dynamic_view <nl> ? tco_log_inference_constraints : ! log_inference_constraints <nl> - ? tco_new_inference_lambda : ! new_inference_lambda <nl> ? tco_timeout : ! timeout <nl> ? tco_disallow_invalid_arraykey : ! disallow_invalid_arraykey <nl> ? po_auto_namespace_map : ! auto_namespace_map <nl> mmm a / hphp / hack / src / options / globalOptions . ml <nl> ppp b / hphp / hack / src / options / globalOptions . ml <nl> type t = { <nl> po_disable_static_closures : bool ; <nl> po_allow_goto : bool ; <nl> tco_log_inference_constraints : bool ; <nl> - tco_disallow_ambiguous_lambda : bool ; <nl> tco_disallow_array_typehint : bool ; <nl> tco_disallow_array_literal : bool ; <nl> tco_language_feature_logging : bool ; <nl> tco_unsafe_rx : bool ; <nl> tco_disallow_scrutinee_case_value_type_mismatch : bool ; <nl> - tco_new_inference_lambda : bool ; <nl> tco_timeout : int ; <nl> tco_disallow_invalid_arraykey : bool ; <nl> tco_disallow_byref_dynamic_calls : bool ; <nl> let default = <nl> po_disable_static_closures = false ; <nl> po_allow_goto = true ; <nl> tco_log_inference_constraints = false ; <nl> - tco_disallow_ambiguous_lambda = false ; <nl> tco_disallow_array_typehint = false ; <nl> tco_disallow_array_literal = false ; <nl> tco_language_feature_logging = false ; <nl> tco_unsafe_rx = true ; <nl> tco_disallow_scrutinee_case_value_type_mismatch = false ; <nl> - tco_new_inference_lambda = false ; <nl> tco_timeout = 0 ; <nl> tco_disallow_invalid_arraykey = false ; <nl> tco_disallow_byref_dynamic_calls = false ; <nl> let make <nl> default . so_remote_worker_vfs_checkout_threshold ) <nl> ? so_naming_sqlite_path <nl> ? ( po_auto_namespace_map = default . po_auto_namespace_map ) <nl> - ? ( tco_disallow_ambiguous_lambda = default . tco_disallow_ambiguous_lambda ) <nl> ? ( tco_disallow_array_typehint = default . tco_disallow_array_typehint ) <nl> ? ( tco_disallow_array_literal = default . tco_disallow_array_literal ) <nl> ? ( tco_language_feature_logging = default . tco_language_feature_logging ) <nl> ? ( tco_unsafe_rx = default . tco_unsafe_rx ) <nl> ? ( tco_disallow_scrutinee_case_value_type_mismatch = <nl> default . tco_disallow_scrutinee_case_value_type_mismatch ) <nl> - ? ( tco_new_inference_lambda = default . tco_new_inference_lambda ) <nl> ? ( tco_timeout = default . tco_timeout ) <nl> ? ( tco_disallow_invalid_arraykey = default . tco_disallow_invalid_arraykey ) <nl> ? ( tco_disallow_byref_dynamic_calls = <nl> let make <nl> po_disable_static_closures ; <nl> po_allow_goto ; <nl> tco_log_inference_constraints ; <nl> - tco_disallow_ambiguous_lambda ; <nl> tco_disallow_array_typehint ; <nl> tco_disallow_array_literal ; <nl> tco_language_feature_logging ; <nl> tco_unsafe_rx ; <nl> tco_disallow_scrutinee_case_value_type_mismatch ; <nl> - tco_new_inference_lambda ; <nl> tco_timeout ; <nl> tco_disallow_invalid_arraykey ; <nl> tco_disallow_byref_dynamic_calls ; <nl> let po_disallow_execution_operator t = t . po_disallow_execution_operator <nl> <nl> let po_disallow_toplevel_requires t = t . po_disallow_toplevel_requires <nl> <nl> - let tco_disallow_ambiguous_lambda t = t . tco_disallow_ambiguous_lambda <nl> - <nl> let tco_disallow_array_typehint t = t . tco_disallow_array_typehint <nl> <nl> let tco_disallow_array_literal t = t . tco_disallow_array_literal <nl> let tco_unsafe_rx t = t . tco_unsafe_rx <nl> let tco_disallow_scrutinee_case_value_type_mismatch t = <nl> t . tco_disallow_scrutinee_case_value_type_mismatch <nl> <nl> - let tco_new_inference_lambda t = t . tco_new_inference_lambda <nl> - <nl> let tco_timeout t = t . tco_timeout <nl> <nl> let tco_disallow_invalid_arraykey t = t . tco_disallow_invalid_arraykey <nl> mmm a / hphp / hack / src / options / globalOptions . mli <nl> ppp b / hphp / hack / src / options / globalOptions . mli <nl> type t = { <nl> po_allow_goto : bool ; <nl> ( * Print types of size bigger than 1000 after performing a type union . * ) <nl> tco_log_inference_constraints : bool ; <nl> - ( * <nl> - * Flag to disallow any lambda that has to be checked using the legacy <nl> - * per - use technique <nl> - * ) <nl> - tco_disallow_ambiguous_lambda : bool ; <nl> ( * <nl> * Flag to disallow array typehints <nl> * ) <nl> type t = { <nl> * of a switch expression are reported as type errors . <nl> * ) <nl> tco_disallow_scrutinee_case_value_type_mismatch : bool ; <nl> - ( * <nl> - * Constraint - based type inference for lambdas <nl> - * ) <nl> - tco_new_inference_lambda : bool ; <nl> ( * <nl> * If non - zero , give up type checking a class or function after this many seconds <nl> * ) <nl> val make : <nl> ? so_remote_worker_vfs_checkout_threshold : int - > <nl> ? so_naming_sqlite_path : string - > <nl> ? po_auto_namespace_map : ( string * string ) list - > <nl> - ? tco_disallow_ambiguous_lambda : bool - > <nl> ? tco_disallow_array_typehint : bool - > <nl> ? tco_disallow_array_literal : bool - > <nl> ? tco_language_feature_logging : bool - > <nl> ? tco_unsafe_rx : bool - > <nl> ? tco_disallow_scrutinee_case_value_type_mismatch : bool - > <nl> - ? tco_new_inference_lambda : bool - > <nl> ? tco_timeout : int - > <nl> ? tco_disallow_invalid_arraykey : bool - > <nl> ? tco_disallow_byref_dynamic_calls : bool - > <nl> val po_codegen : t - > bool <nl> <nl> val tco_log_inference_constraints : t - > bool <nl> <nl> - val tco_disallow_ambiguous_lambda : t - > bool <nl> - <nl> val tco_disallow_array_typehint : t - > bool <nl> <nl> val tco_disallow_array_literal : t - > bool <nl> val tco_unsafe_rx : t - > bool <nl> <nl> val tco_disallow_scrutinee_case_value_type_mismatch : t - > bool <nl> <nl> - val tco_new_inference_lambda : t - > bool <nl> - <nl> val tco_timeout : t - > int <nl> <nl> val tco_disallow_invalid_arraykey : t - > bool <nl> mmm a / hphp / hack / src / options / typecheckerOptions . ml <nl> ppp b / hphp / hack / src / options / typecheckerOptions . ml <nl> <nl> <nl> type t = GlobalOptions . t [ @ @ deriving show ] <nl> <nl> - let disallow_ambiguous_lambda = GlobalOptions . tco_disallow_ambiguous_lambda <nl> - <nl> let defer_class_declaration_threshold = <nl> GlobalOptions . tco_defer_class_declaration_threshold <nl> <nl> let dynamic_view = GlobalOptions . tco_dynamic_view <nl> let disallow_scrutinee_case_value_type_mismatch = <nl> GlobalOptions . tco_disallow_scrutinee_case_value_type_mismatch <nl> <nl> - let new_inference_lambda = GlobalOptions . tco_new_inference_lambda <nl> - <nl> let timeout = GlobalOptions . tco_timeout <nl> <nl> let disallow_invalid_arraykey = GlobalOptions . tco_disallow_invalid_arraykey <nl> mmm a / hphp / hack / src / oxidized / gen / error_codes . rs <nl> ppp b / hphp / hack / src / oxidized / gen / error_codes . rs <nl> <nl> / / This source code is licensed under the MIT license found in the <nl> / / LICENSE file in the " hack " directory of this source tree . <nl> / / <nl> - / / @ generated SignedSource < < 5a1fb15dfba7b33bd51c2256e6694be9 > > <nl> + / / @ generated SignedSource < < 0ecc7fa29391c2c20e1878225a4b6490 > > <nl> / / <nl> / / To regenerate this file , run : <nl> / / hphp / hack / src / oxidized / regen . sh <nl> pub enum NastCheck { <nl> pub enum Typing { <nl> AbstractClassFinalDEPRECATED = 4001 , <nl> UninstantiableClass , <nl> - AnonymousRecursive , <nl> - AnonymousRecursiveCall , <nl> + AnonymousRecursiveDEPRECATED , <nl> + AnonymousRecursiveCallDEPRECATED , <nl> ArrayAccess , <nl> ArrayAppend , <nl> ArrayCast , <nl> mmm a / hphp / hack / src / oxidized / gen / global_options . rs <nl> ppp b / hphp / hack / src / oxidized / gen / global_options . rs <nl> <nl> / / This source code is licensed under the MIT license found in the <nl> / / LICENSE file in the " hack " directory of this source tree . <nl> / / <nl> - / / @ generated SignedSource < < c50e51bd434e0feb87162f8024f2257e > > <nl> + / / @ generated SignedSource < < a5055d71b630e0ead9ce1c63528cbdcf > > <nl> / / <nl> / / To regenerate this file , run : <nl> / / hphp / hack / src / oxidized / regen . sh <nl> pub struct GlobalOptions { <nl> pub po_disable_static_closures : bool , <nl> pub po_allow_goto : bool , <nl> pub tco_log_inference_constraints : bool , <nl> - pub tco_disallow_ambiguous_lambda : bool , <nl> pub tco_disallow_array_typehint : bool , <nl> pub tco_disallow_array_literal : bool , <nl> pub tco_language_feature_logging : bool , <nl> pub tco_unsafe_rx : bool , <nl> pub tco_disallow_scrutinee_case_value_type_mismatch : bool , <nl> - pub tco_new_inference_lambda : bool , <nl> pub tco_timeout : isize , <nl> pub tco_disallow_invalid_arraykey : bool , <nl> pub tco_disallow_byref_dynamic_calls : bool , <nl> mmm a / hphp / hack / src / oxidized / gen / typing_defs . rs <nl> ppp b / hphp / hack / src / oxidized / gen / typing_defs . rs <nl> <nl> / / This source code is licensed under the MIT license found in the <nl> / / LICENSE file in the " hack " directory of this source tree . <nl> / / <nl> - / / @ generated SignedSource < < 4686850d5d68e0b09438ff69d98a5531 > > <nl> + / / @ generated SignedSource < < 8b88a787366f347a9fd2283e8c1731df > > <nl> / / <nl> / / To regenerate this file , run : <nl> / / hphp / hack / src / oxidized / regen . sh <nl> pub enum DeserializationError { <nl> WrongPhase ( String ) , <nl> / / / The specific type or some component thereof is not one that we support <nl> / / / deserializing , usually because not enough information was serialized to be <nl> - / / / able to deserialize it again . For example , lambda types ( ` Tanon ` ) contain a <nl> - / / / reference to an identifier ( ` Ident . t ` ) , which is not serialized . <nl> + / / / able to deserialize it again . <nl> NotSupported ( String ) , <nl> / / / The input JSON was invalid for some reason . <nl> DeserializationError ( String ) , <nl> mmm a / hphp / hack / src / oxidized / gen / typing_defs_core . rs <nl> ppp b / hphp / hack / src / oxidized / gen / typing_defs_core . rs <nl> <nl> / / This source code is licensed under the MIT license found in the <nl> / / LICENSE file in the " hack " directory of this source tree . <nl> / / <nl> - / / @ generated SignedSource < < a4844e263b5d53c8113cb88766ad1f8d > > <nl> + / / @ generated SignedSource < < dabec6000882d56f9cfd8439fda67a98 > > <nl> / / <nl> / / To regenerate this file , run : <nl> / / hphp / hack / src / oxidized / regen . sh <nl> pub enum Ty_ { <nl> / / / All the primitive types : int , string , void , etc . <nl> Tprim ( aast : : Tprim ) , <nl> / / / A wrapper around fun_type , which contains the full type information for a <nl> - / / / function , method , lambda , etc . Note that lambdas have an additional layer <nl> - / / / of indirection before you get to Tfun - - see Tanon below . <nl> + / / / function , method , lambda , etc . <nl> Tfun ( FunType < Ty > ) , <nl> / / / Tuple , with ordered list of the types of the elements of the tuple . <nl> Ttuple ( Vec < Ty > ) , <nl> mmm a / hphp / hack / src / oxidized / manual / global_options_impl . rs <nl> ppp b / hphp / hack / src / oxidized / manual / global_options_impl . rs <nl> impl Default for GlobalOptions { <nl> po_disable_static_closures : false , <nl> po_allow_goto : false , <nl> tco_log_inference_constraints : false , <nl> - tco_disallow_ambiguous_lambda : false , <nl> tco_disallow_array_typehint : false , <nl> tco_disallow_array_literal : false , <nl> tco_language_feature_logging : false , <nl> tco_unsafe_rx : false , <nl> tco_disallow_scrutinee_case_value_type_mismatch : false , <nl> - tco_new_inference_lambda : false , <nl> tco_timeout : 0 , <nl> tco_disallow_invalid_arraykey : false , <nl> tco_disallow_byref_dynamic_calls : false , <nl> mmm a / hphp / hack / src / server / codemodTypePrinter . ml <nl> ppp b / hphp / hack / src / server / codemodTypePrinter . ml <nl> let rec print_ty_exn ? ( allow_nothing = false ) ty = <nl> | Terr <nl> | Tvar _ <nl> | Tdependent _ <nl> - | Tanon _ <nl> | Tunion _ <nl> | Tintersection _ <nl> | Tobject <nl> mmm a / hphp / hack / src / server / serverConfig . ml <nl> ppp b / hphp / hack / src / server / serverConfig . ml <nl> let load config_filename options = <nl> ? po_deregister_php_stdlib : ( bool_opt " deregister_php_stdlib " config ) <nl> ? po_allow_goto : ( Option . map ~ f : not ( bool_opt " disallow_goto " config ) ) <nl> ? po_disable_static_closures : ( bool_opt " disable_static_closures " config ) <nl> - ? tco_disallow_ambiguous_lambda : <nl> - ( bool_opt " disallow_ambiguous_lambda " config ) <nl> ? tco_disallow_array_typehint : ( bool_opt " disallow_array_typehint " config ) <nl> ? tco_disallow_array_literal : ( bool_opt " disallow_array_literal " config ) <nl> ? tco_defer_class_declaration_threshold : <nl> let load config_filename options = <nl> ? tco_unsafe_rx : ( bool_opt " unsafe_rx " config ) <nl> ? tco_disallow_scrutinee_case_value_type_mismatch : <nl> ( bool_opt " disallow_scrutinee_case_value_type_mismatch " config ) <nl> - ? tco_new_inference_lambda : ( bool_opt " new_inference_lambda " config ) <nl> ? tco_timeout : ( int_opt " timeout " config ) <nl> ? tco_disallow_invalid_arraykey : <nl> ( bool_opt " disallow_invalid_arraykey " config ) <nl> mmm a / hphp / hack / src / typing / dune <nl> ppp b / hphp / hack / src / typing / dune <nl> <nl> typing_extends <nl> typing_exts <nl> typing_inheritance <nl> - typing_lambda_ambiguous <nl> typing_lenv <nl> typing_memoize <nl> typing_regex <nl> mmm a / hphp / hack / src / typing / pp_type . ml <nl> ppp b / hphp / hack / src / typing / pp_type . ml <nl> and pp_ty_ : type a . Format . formatter - > a ty_ - > unit = <nl> Format . fprintf fmt " , @ " ; <nl> pp_ty fmt a1 ; <nl> Format . fprintf fmt " @ ] ) " <nl> - | Tanon ( a0 , a1 ) - > <nl> - Format . fprintf fmt " ( @ [ < 2 > Tanon ( @ , " ; <nl> - pp_fun_arity fmt a0 ; <nl> - Format . fprintf fmt " , @ " ; <nl> - Ident . pp fmt a1 ; <nl> - Format . fprintf fmt " @ , ) ) @ ] " <nl> | Tunion tyl - > <nl> Format . fprintf fmt " ( @ [ < 2 > Tunion @ " ; <nl> pp_ty_list fmt tyl <nl> mmm a / hphp / hack / src / typing / tast_check / basic_reactivity_check . ml <nl> ppp b / hphp / hack / src / typing / tast_check / basic_reactivity_check . ml <nl> let rec is_byval_collection_or_string_or_any_type env ty = <nl> | Tprim _ <nl> | Tobject <nl> | Tfun _ <nl> - | Tanon _ <nl> | Tvar _ <nl> | Tpu _ <nl> | Tpu_type_access _ - > <nl> mmm a / hphp / hack / src / typing / tast_check / discarded_awaitable_check . ml <nl> ppp b / hphp / hack / src / typing / tast_check / discarded_awaitable_check . ml <nl> let rec enforce_not_awaitable env p ty = <nl> | Tdependent _ <nl> | Tclass _ <nl> | Ttuple _ <nl> - | Tanon _ <nl> | Tobject <nl> | Tshape _ <nl> | Tdynamic <nl> mmm a / hphp / hack / src / typing / tast_check / invalid_index_check . ml <nl> ppp b / hphp / hack / src / typing / tast_check / invalid_index_check . ml <nl> let rec array_get ~ array_pos ~ expr_pos ~ index_pos env array_ty index_ty = <nl> | Tfun _ <nl> | Tvar _ <nl> | Tclass _ <nl> - | Tanon ( _ , _ ) <nl> | Ttuple _ <nl> | Tshape _ <nl> | Tobject <nl> mmm a / hphp / hack / src / typing / tast_check / string_cast_check . ml <nl> ppp b / hphp / hack / src / typing / tast_check / string_cast_check . ml <nl> let rec is_stringish env ty = <nl> | Tarraykind _ <nl> | Tvar _ <nl> | Ttuple _ <nl> - | Tanon ( _ , _ ) <nl> | Tfun _ <nl> | Tshape _ <nl> | Tpu_type_access _ - > <nl> mmm a / hphp / hack / src / typing / tast_check / switch_check . ml <nl> ppp b / hphp / hack / src / typing / tast_check / switch_check . ml <nl> let rec check_exhaustiveness_ env pos ty caselist enum_coming_from_unresolved = <nl> | Tnewtype _ <nl> | Tdependent _ <nl> | Ttuple _ <nl> - | Tanon ( _ , _ ) <nl> | Tobject <nl> | Tshape _ <nl> | Tdynamic - > <nl> mmm a / hphp / hack / src / typing / tast_check / type_serialization_identity_check . ml <nl> ppp b / hphp / hack / src / typing / tast_check / type_serialization_identity_check . ml <nl> let rec strip_ty ty = <nl> | Tobject - > ty <nl> | Tprim _ - > ty <nl> | Tvar _ - > ty <nl> - | Tanon _ - > ty <nl> | Tgeneric _ - > ty <nl> | Tarraykind AKempty - > ty <nl> | Tarraykind ( AKdarray ( ty1 , ty2 ) ) - > <nl> mmm a / hphp / hack / src / typing / tast_env . ml <nl> ppp b / hphp / hack / src / typing / tast_env . ml <nl> let def_env ctx d = <nl> <nl> let set_ppl_lambda env = { env with Typing_env_types . inside_ppl_class = false } <nl> <nl> - let get_anonymous_lambda_types env id = <nl> - match Typing_env . get_anonymous env id with <nl> - | Some { Typing_env_types . counter = ftys ; _ } - > <nl> - let ( untyped , typed ) = ! ftys in <nl> - untyped @ typed <nl> - | _ - > [ ] <nl> - <nl> let typing_env_as_tast_env env = env <nl> <nl> let tast_env_as_typing_env env = env <nl> mmm a / hphp / hack / src / typing / tast_env . mli <nl> ppp b / hphp / hack / src / typing / tast_env . mli <nl> val restore_pu_enum_env : env - > Tast . pu_enum - > env <nl> If you are using { ! Tast_visitor } , you should have no need of this . * ) <nl> val set_ppl_lambda : env - > env <nl> <nl> - val get_anonymous_lambda_types : env - > int - > Tast . ty list <nl> - <nl> val typing_env_as_tast_env : Typing_env_types . env - > env <nl> <nl> val tast_env_as_typing_env : env - > Typing_env_types . env <nl> mmm a / hphp / hack / src / typing / tast_expand . ml <nl> ppp b / hphp / hack / src / typing / tast_expand . ml <nl> module MakeType = Typing_make_type <nl> <nl> ( * Eliminate residue of type inference : <nl> * 1 . Tvars are replaced ( deep ) by the expanded type <nl> - * 2 . Tanon is replaced by a Tfun function type <nl> - * 3 . Singleton unions are eliminated <nl> + * 2 . Singleton unions are eliminated <nl> * TODO TAST : <nl> * Transform completely unconstrained types to Tmixed <nl> * Consider using a fresh datatype for TAST types . <nl> let expand_ty ? var_hook ? pos env ty = <nl> then <nl> Errors . unresolved_type_variable pos ; <nl> mk ( p , Tvar v ) ) <nl> - ( * TODO TAST : replace with Tfun type * ) <nl> - | ( p , Tanon ( x , y ) ) - > mk ( p , Tanon ( x , y ) ) <nl> | ( p , Terr ) - > MakeType . err p <nl> ( * TODO ( T36532263 ) see if that needs updating * ) <nl> | ( p , Tpu ( base , enum ) ) - > mk ( p , Tpu ( exp_ty base , enum ) ) <nl> mmm a / hphp / hack / src / typing / tast_utils . ml <nl> ppp b / hphp / hack / src / typing / tast_utils . ml <nl> let rec type_non_nullable env ty = <nl> | Tfun _ <nl> | Ttuple _ <nl> | Tshape _ <nl> - | Tanon _ <nl> | Tobject <nl> | Tclass _ <nl> | Tarraykind _ - > <nl> let rec truthiness env ty = <nl> | Tobject <nl> | Tfun _ <nl> | Ttuple _ <nl> - | Tanon _ - > <nl> - Always_truthy <nl> | Tpu _ <nl> | Tpu_type_access _ - > <nl> ( * TODO ( T36532263 ) check if that ' s ok * ) Unknown <nl> let rec find_sketchy_types env acc ty = <nl> | Ttuple _ <nl> | Tshape _ <nl> | Tvar _ <nl> - | Tanon _ <nl> | Tarraykind _ - > <nl> acc <nl> | Tpu _ - > acc <nl> mmm a / hphp / hack / src / typing / type_mapper_generic . ml <nl> ppp b / hphp / hack / src / typing / type_mapper_generic . ml <nl> class type [ ' env ] type_mapper_type = <nl> <nl> method on_terr : ' env - > Reason . t - > ' env * locl_ty <nl> <nl> - method on_tanon : <nl> - ' env - > Reason . t - > locl_fun_arity - > Ident . t - > ' env * locl_ty <nl> - <nl> method on_tprim : ' env - > Reason . t - > Aast . tprim - > ' env * locl_ty <nl> <nl> method on_tarraykind_akempty : ' env - > Reason . t - > ' env * locl_ty <nl> class [ ' env ] shallow_type_mapper : [ ' env ] type_mapper_type = <nl> <nl> method on_terr env r = ( env , mk ( r , Terr ) ) <nl> <nl> - method on_tanon env r fun_arity id = ( env , mk ( r , Tanon ( fun_arity , id ) ) ) <nl> - <nl> method on_tprim env r p = ( env , mk ( r , Tprim p ) ) <nl> <nl> method on_tarraykind_akempty env r = ( env , mk ( r , Tarraykind AKempty ) ) <nl> class [ ' env ] shallow_type_mapper : [ ' env ] type_mapper_type = <nl> | Tnonnull - > this # on_tnonnull env r <nl> | Tany _ - > this # on_tany env r <nl> | Terr - > this # on_terr env r <nl> - | Tanon ( fun_arity , id ) - > this # on_tanon env r fun_arity id <nl> | Tprim p - > this # on_tprim env r p <nl> | Tarraykind AKempty - > this # on_tarraykind_akempty env r <nl> | Tarraykind ( AKvarray tv ) - > this # on_tarraykind_akvarray env r tv <nl> mmm a / hphp / hack / src / typing / type_visitor . ml <nl> ppp b / hphp / hack / src / typing / type_visitor . ml <nl> class type [ ' a ] locl_type_visitor_type = <nl> <nl> method on_tintersection : ' a - > Reason . t - > locl_ty list - > ' a <nl> <nl> - method on_tanon : ' a - > Reason . t - > locl_fun_arity - > Ident . t - > ' a <nl> - <nl> method on_tunion : ' a - > Reason . t - > locl_ty list - > ' a <nl> <nl> method on_tintersection : ' a - > Reason . t - > locl_ty list - > ' a <nl> class virtual [ ' a ] locl_type_visitor : [ ' a ] locl_type_visitor_type = <nl> <nl> method on_ttuple acc _ tyl = List . fold_left tyl ~ f : this # on_type ~ init : acc <nl> <nl> - method on_tanon acc _ _ _ = acc <nl> - <nl> method on_tunion acc _ tyl = List . fold_left tyl ~ f : this # on_type ~ init : acc <nl> <nl> method on_tintersection acc _ tyl = <nl> class virtual [ ' a ] locl_type_visitor : [ ' a ] locl_type_visitor_type = <nl> | Tnewtype ( x , tyl , ty ) - > this # on_tnewtype acc r x tyl ty <nl> | Tdependent ( x , ty ) - > this # on_tdependent acc r x ty <nl> | Ttuple tyl - > this # on_ttuple acc r tyl <nl> - | Tanon ( arity , id ) - > this # on_tanon acc r arity id <nl> | Tunion tyl - > this # on_tunion acc r tyl <nl> | Tintersection tyl - > this # on_tintersection acc r tyl <nl> | Tobject - > this # on_tobject acc r <nl> mmm a / hphp / hack / src / typing / typing . ml <nl> ppp b / hphp / hack / src / typing / typing . ml <nl> and fun_def ctx f : <nl> Aast . f_static = f . f_static ; <nl> } <nl> in <nl> - let ( env , global_inference_env ) = Env . extract_global_inference_env env in <nl> - ( Typing_lambda_ambiguous . suggest_fun_def env fundef , <nl> - ( pos , global_inference_env ) ) ) <nl> + let ( _env , global_inference_env ) = Env . extract_global_inference_env env in <nl> + ( fundef , ( pos , global_inference_env ) ) ) <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * function used to type closures , functions and methods * ) <nl> and expr_ <nl> let env = Env . set_env_reactive env reactivity in <nl> let old_inside_ppl_class = env . inside_ppl_class in <nl> let env = { env with inside_ppl_class = false } in <nl> - let ft = { ft with ft_reactive = reactivity } in <nl> - let ( is_coroutine , _counter , _ , anon ) = <nl> - anon_make env p f ft idl is_anon outer <nl> + let is_coroutine = Ast_defs . ( equal_fun_kind f . f_fun_kind FCoroutine ) in <nl> + let ft = <nl> + { ft with ft_reactive = reactivity ; ft_is_coroutine = is_coroutine } <nl> in <nl> - let ft = { ft with ft_is_coroutine = is_coroutine } in <nl> - let ( env , tefun , ty ) = anon ? ret_ty env ft . ft_params ft . ft_arity in <nl> + let ( env , tefun , ty ) = anon_make ? ret_ty env p f ft idl is_anon in <nl> let env = Env . set_env_reactive env old_reactivity in <nl> let env = { env with inside_ppl_class = old_inside_ppl_class } in <nl> let inferred_ty = <nl> and expr_ <nl> env <nl> FL . Lambda . non_strict_unknown_params ; <nl> check_body_under_known_params env declared_ft <nl> - ) else if <nl> - ( * If new_inference_lambda is enabled , check lambda using constraints * ) <nl> - TypecheckerOptions . new_inference_lambda ( Env . get_tcopt env ) <nl> - then ( <nl> + ) else ( <nl> Typing_log . increment_feature_count <nl> env <nl> FL . Lambda . fresh_tyvar_params ; <nl> and expr_ <nl> env <nl> ~ ret_ty : declared_ft . ft_ret . et_type <nl> declared_ft <nl> - ( * Legacy lambda inference * ) <nl> - ) else ( <nl> - Typing_log . increment_feature_count env FL . Lambda . unknown_params ; <nl> - <nl> - ( * check for recursive function calls * ) <nl> - let reactivity = <nl> - fun_reactivity env . decl_env f . f_user_attributes f . f_params <nl> - in <nl> - let old_reactivity = env_reactivity env in <nl> - let env = Env . set_env_reactive env reactivity in <nl> - let ( is_coroutine , counter , pos , anon ) = <nl> - anon_make env p f declared_ft idl is_anon outer <nl> - in <nl> - let ( env , tefun , _ , anon_id ) = <nl> - Errors . try_with_error <nl> - ( fun ( ) - > <nl> - let ( _ , tefun , ty ) = <nl> - anon env declared_ft . ft_params declared_ft . ft_arity <nl> - in <nl> - let anon_fun = <nl> - { <nl> - rx = reactivity ; <nl> - typecheck = anon ; <nl> - is_coroutine ; <nl> - counter ; <nl> - pos ; <nl> - } <nl> - in <nl> - let ( env , anon_id ) = Env . add_anonymous env anon_fun in <nl> - ( env , tefun , ty , anon_id ) ) <nl> - ( fun ( ) - > <nl> - ( * If the anonymous function declaration has errors itself , silence <nl> - them in any subsequent usages . * ) <nl> - let anon_ign ? el : _ ? ret_ty : _ env fun_params = <nl> - Errors . ignore_ ( fun ( ) - > anon env fun_params ) <nl> - in <nl> - let ( _ , tefun , ty ) = <nl> - anon_ign env declared_ft . ft_params declared_ft . ft_arity <nl> - in <nl> - let anon_fun = <nl> - { <nl> - rx = reactivity ; <nl> - typecheck = anon ; <nl> - is_coroutine ; <nl> - counter ; <nl> - pos ; <nl> - } <nl> - in <nl> - let ( env , anon_id ) = Env . add_anonymous env anon_fun in <nl> - ( env , tefun , ty , anon_id ) ) <nl> - in <nl> - let env = Env . set_env_reactive env old_reactivity in <nl> - let anon_ty = <nl> - mk ( Reason . Rwitness p , Tanon ( declared_ft . ft_arity , anon_id ) ) <nl> - in <nl> - let ( ( ep , _efun_ty ) , efun ) = tefun in <nl> - let tefun = ( ( ep , anon_ty ) , efun ) in <nl> - ( env , tefun , anon_ty ) <nl> ) <nl> ) <nl> end <nl> and stash_conts_for_anon env p is_anon captured f = <nl> ( env , tfun , result ) <nl> <nl> ( * Make a type - checking function for an anonymous function . * ) <nl> - and anon_make tenv lambda_pos f ft idl is_anon outer = <nl> - let anon_lenv = tenv . lenv in <nl> - let is_typing_self = ref false in <nl> + ( * Here ret_ty should include Awaitable wrapper * ) <nl> + ( * TODO : ? el is never set ; so we need to fix variadic use of lambda * ) <nl> + and anon_make ? el ? ret_ty env lambda_pos f ft idl is_anon = <nl> + let anon_lenv = env . lenv in <nl> let nb = Nast . assert_named_body f . f_body in <nl> - let is_coroutine = Ast_defs . ( equal_fun_kind f . f_fun_kind FCoroutine ) in <nl> - ( is_coroutine , <nl> - ref ( [ ] , [ ] ) , <nl> - lambda_pos , <nl> - ( * Here ret_ty should include Awaitable wrapper * ) <nl> - fun ? el ? ret_ty env supplied_params supplied_arity - > <nl> - if ! is_typing_self then ( <nl> - Errors . anonymous_recursive lambda_pos ; <nl> - expr_error env ( Reason . Rwitness lambda_pos ) outer <nl> - ) else ( <nl> - is_typing_self : = true ; <nl> - Env . anon anon_lenv env ( fun env - > <nl> - stash_conts_for_anon env lambda_pos is_anon idl ( fun env - > <nl> - let env = Env . clear_params env in <nl> - let make_variadic_arg env varg tyl = <nl> - let remaining_types = <nl> - ( * It ' s possible the variadic arg will capture the variadic <nl> - * parameter of the supplied arity ( if arity is Fvariadic ) <nl> - * and additional supplied params . <nl> - * <nl> - * For example in cases such as : <nl> - * lambda1 = ( int $ a , string . . . $ c ) = = > { } ; <nl> - * lambda1 ( 1 , " hello " , . . . $ y ) ; ( where $ y is a variadic string ) <nl> - * lambda1 ( 1 , " hello " , " world " ) ; <nl> - * then . . . $ c will contain " hello " and everything in $ y in the first <nl> - * example , and " hello " and " world " in the second example . <nl> - * <nl> - * To account for a mismatch in arity , we take the remaining supplied <nl> - * parameters and return a list of all their types . We ' ll use this <nl> - * to create a union type when creating the typed variadic arg . <nl> - * ) <nl> - let remaining_params = <nl> - List . drop supplied_params ( List . length f . f_params ) <nl> - in <nl> - List . map <nl> - ~ f : ( fun param - > param . fp_type . et_type ) <nl> - remaining_params <nl> - in <nl> - let r = Reason . Rvar_param varg . param_pos in <nl> - let union = Tunion ( tyl @ remaining_types ) in <nl> - let ( env , t_param ) = <nl> - anon_bind_variadic env varg ( mk ( r , union ) ) <nl> - in <nl> - ( env , Aast . FVvariadicArg t_param ) <nl> - in <nl> - let ( env , t_variadic ) = <nl> - match ( f . f_variadic , supplied_arity ) with <nl> - | ( FVvariadicArg arg , Fvariadic ( _ , variadic ) ) - > <nl> - make_variadic_arg env arg [ variadic . fp_type . et_type ] <nl> - | ( FVvariadicArg arg , Fstandard _ ) - > <nl> - make_variadic_arg env arg [ ] <nl> - | ( FVellipsis pos , _ ) - > ( env , Aast . FVellipsis pos ) <nl> - | ( _ , _ ) - > ( env , Aast . FVnonVariadic ) <nl> - in <nl> - let params = ref f . f_params in <nl> - let ( env , t_params ) = <nl> - List . fold_left <nl> - ~ f : ( anon_bind_param params ) <nl> - ~ init : ( env , [ ] ) <nl> - ( List . map supplied_params ( fun x - > x . fp_type . et_type ) ) <nl> - in <nl> - let env = <nl> - List . fold_left ~ f : anon_bind_opt_param ~ init : env ! params <nl> - in <nl> - let env = <nl> - List . fold_left ~ f : anon_check_param ~ init : env f . f_params <nl> - in <nl> - let env = <nl> - match el with <nl> - | None - > <nl> - ( * iter2_shortest <nl> + Env . anon anon_lenv env ( fun env - > <nl> + stash_conts_for_anon env lambda_pos is_anon idl ( fun env - > <nl> + let env = Env . clear_params env in <nl> + let make_variadic_arg env varg tyl = <nl> + let remaining_types = <nl> + ( * It ' s possible the variadic arg will capture the variadic <nl> + * parameter of the supplied arity ( if arity is Fvariadic ) <nl> + * and additional supplied params . <nl> + * <nl> + * For example in cases such as : <nl> + * lambda1 = ( int $ a , string . . . $ c ) = = > { } ; <nl> + * lambda1 ( 1 , " hello " , . . . $ y ) ; ( where $ y is a variadic string ) <nl> + * lambda1 ( 1 , " hello " , " world " ) ; <nl> + * then . . . $ c will contain " hello " and everything in $ y in the first <nl> + * example , and " hello " and " world " in the second example . <nl> + * <nl> + * To account for a mismatch in arity , we take the remaining supplied <nl> + * parameters and return a list of all their types . We ' ll use this <nl> + * to create a union type when creating the typed variadic arg . <nl> + * ) <nl> + let remaining_params = <nl> + List . drop ft . ft_params ( List . length f . f_params ) <nl> + in <nl> + List . map ~ f : ( fun param - > param . fp_type . et_type ) remaining_params <nl> + in <nl> + let r = Reason . Rvar_param varg . param_pos in <nl> + let union = Tunion ( tyl @ remaining_types ) in <nl> + let ( env , t_param ) = anon_bind_variadic env varg ( mk ( r , union ) ) in <nl> + ( env , Aast . FVvariadicArg t_param ) <nl> + in <nl> + let ( env , t_variadic ) = <nl> + match ( f . f_variadic , ft . ft_arity ) with <nl> + | ( FVvariadicArg arg , Fvariadic ( _ , variadic ) ) - > <nl> + make_variadic_arg env arg [ variadic . fp_type . et_type ] <nl> + | ( FVvariadicArg arg , Fstandard _ ) - > make_variadic_arg env arg [ ] <nl> + | ( FVellipsis pos , _ ) - > ( env , Aast . FVellipsis pos ) <nl> + | ( _ , _ ) - > ( env , Aast . FVnonVariadic ) <nl> + in <nl> + let params = ref f . f_params in <nl> + let ( env , t_params ) = <nl> + List . fold_left <nl> + ~ f : ( anon_bind_param params ) <nl> + ~ init : ( env , [ ] ) <nl> + ( List . map ft . ft_params ( fun x - > x . fp_type . et_type ) ) <nl> + in <nl> + let env = List . fold_left ~ f : anon_bind_opt_param ~ init : env ! params in <nl> + let env = List . fold_left ~ f : anon_check_param ~ init : env f . f_params in <nl> + let env = <nl> + match el with <nl> + | None - > <nl> + ( * iter2_shortest <nl> Unify . unify_param_modes <nl> ft . ft_params <nl> supplied_params ; * ) <nl> - env <nl> - | Some x - > <nl> - let var_param = <nl> - match f . f_variadic with <nl> - | FVellipsis pos - > <nl> - let param = <nl> - TUtils . default_fun_param <nl> - ~ pos <nl> - ( mk <nl> - ( Reason . Rvar_param pos , Typing_defs . make_tany ( ) ) ) <nl> - in <nl> - Some param <nl> - | _ - > None <nl> - in <nl> - let rec iter l1 l2 = <nl> - match ( l1 , l2 , var_param ) with <nl> - | ( _ , [ ] , _ ) - > ( ) <nl> - | ( [ ] , _ , None ) - > ( ) <nl> - | ( [ ] , x2 : : rl2 , Some def1 ) - > <nl> - param_modes ~ is_variadic : true def1 x2 ; <nl> - iter [ ] rl2 <nl> - | ( x1 : : rl1 , x2 : : rl2 , _ ) - > <nl> - param_modes x1 x2 ; <nl> - iter rl1 rl2 <nl> - in <nl> - iter ft . ft_params x ; <nl> - wfold_left2 inout_write_back env ft . ft_params x <nl> - in <nl> - let env = Env . set_fn_kind env f . f_fun_kind in <nl> - let decl_ty = <nl> - Option . map <nl> - ~ f : ( Decl_hint . hint env . decl_env ) <nl> - ( hint_of_type_hint f . f_ret ) <nl> - in <nl> - let ( env , hret ) = <nl> - match decl_ty with <nl> - | None - > <nl> - ( * Do we have a contextual return type ? * ) <nl> - begin <nl> - match ret_ty with <nl> - | None - > <nl> - let ( env , ret_ty ) = Env . fresh_type env lambda_pos in <nl> - ( env , Typing_return . wrap_awaitable env lambda_pos ret_ty ) <nl> - | Some ret_ty - > <nl> - ( * We might need to force it to be Awaitable if it is a type variable * ) <nl> - Typing_return . force_awaitable env lambda_pos ret_ty <nl> - end <nl> - | Some ret - > <nl> - ( * If a ' this ' type appears it needs to be compatible with the <nl> - * late static type <nl> - * ) <nl> - let ety_env = <nl> - { <nl> - ( Phase . env_with_self env ) with <nl> - from_class = Some CIstatic ; <nl> - } <nl> - in <nl> - Typing_return . make_return_type <nl> - ( Phase . localize ~ ety_env ) <nl> - env <nl> - ret <nl> - in <nl> - let env = <nl> - Env . set_return <nl> - env <nl> - ( Typing_return . make_info <nl> - f . f_fun_kind <nl> - [ ] <nl> - env <nl> - ~ is_explicit : ( Option . is_some ret_ty ) <nl> - hret <nl> - decl_ty ) <nl> - in <nl> - let local_tpenv = Env . get_tpenv env in <nl> - ( * Outer pipe variables aren ' t available in closures . Note that <nl> - * locals are restored by Env . anon after processing the closure <nl> - * ) <nl> - let env = <nl> - Env . unset_local <nl> - env <nl> - ( Local_id . make_unscoped SN . SpecialIdents . dollardollar ) <nl> - in <nl> - let ( env , tb ) = block env nb . fb_ast in <nl> - let implicit_return = LEnv . has_next env in <nl> - let env = <nl> - if ( not implicit_return ) | | Nast . named_body_is_unsafe nb then <nl> - env <nl> - else <nl> - fun_implicit_return env lambda_pos hret f . f_fun_kind <nl> - in <nl> - is_typing_self : = false ; <nl> - let annotation = <nl> - if Nast . named_body_is_unsafe nb then <nl> - Tast . HasUnsafeBlocks <nl> - else <nl> - Tast . NoUnsafeBlocks <nl> - in <nl> - let ( env , tparams ) = List . map_env env f . f_tparams type_param in <nl> - let ( env , user_attributes ) = <nl> - List . map_env env f . f_user_attributes user_attribute <nl> - in <nl> - let tfun_ = <nl> - { <nl> - Aast . f_annotation = Env . save local_tpenv env ; <nl> - Aast . f_span = f . f_span ; <nl> - Aast . f_mode = f . f_mode ; <nl> - Aast . f_ret = ( hret , hint_of_type_hint f . f_ret ) ; <nl> - Aast . f_name = f . f_name ; <nl> - Aast . f_tparams = tparams ; <nl> - Aast . f_where_constraints = f . f_where_constraints ; <nl> - Aast . f_fun_kind = f . f_fun_kind ; <nl> - Aast . f_file_attributes = [ ] ; <nl> - Aast . f_user_attributes = user_attributes ; <nl> - Aast . f_body = <nl> - { Aast . fb_ast = tb ; fb_annotation = annotation } ; <nl> - Aast . f_params = t_params ; <nl> - Aast . f_variadic = t_variadic ; <nl> - ( * TODO TAST : Variadic efuns * ) <nl> - Aast . f_external = f . f_external ; <nl> - Aast . f_namespace = f . f_namespace ; <nl> - Aast . f_doc_comment = f . f_doc_comment ; <nl> - Aast . f_static = f . f_static ; <nl> - } <nl> - in <nl> - let ty = mk ( Reason . Rwitness lambda_pos , Tfun ft ) in <nl> - let te = <nl> - Tast . make_typed_expr <nl> - lambda_pos <nl> - ty <nl> - ( if is_anon then <nl> - Aast . Efun ( tfun_ , idl ) <nl> - else <nl> - Aast . Lfun ( tfun_ , idl ) ) <nl> - in <nl> - let env = Env . set_tyvar_variance env ty in <nl> - ( env , te , hret ) ) ) <nl> - ( * stash_conts_for_anon * ) <nl> - ( * Env . anon * ) <nl> - ) ) <nl> + env <nl> + | Some x - > <nl> + let var_param = <nl> + match f . f_variadic with <nl> + | FVellipsis pos - > <nl> + let param = <nl> + TUtils . default_fun_param <nl> + ~ pos <nl> + ( mk ( Reason . Rvar_param pos , Typing_defs . make_tany ( ) ) ) <nl> + in <nl> + Some param <nl> + | _ - > None <nl> + in <nl> + let rec iter l1 l2 = <nl> + match ( l1 , l2 , var_param ) with <nl> + | ( _ , [ ] , _ ) - > ( ) <nl> + | ( [ ] , _ , None ) - > ( ) <nl> + | ( [ ] , x2 : : rl2 , Some def1 ) - > <nl> + param_modes ~ is_variadic : true def1 x2 ; <nl> + iter [ ] rl2 <nl> + | ( x1 : : rl1 , x2 : : rl2 , _ ) - > <nl> + param_modes x1 x2 ; <nl> + iter rl1 rl2 <nl> + in <nl> + iter ft . ft_params x ; <nl> + wfold_left2 inout_write_back env ft . ft_params x <nl> + in <nl> + let env = Env . set_fn_kind env f . f_fun_kind in <nl> + let decl_ty = <nl> + Option . map <nl> + ~ f : ( Decl_hint . hint env . decl_env ) <nl> + ( hint_of_type_hint f . f_ret ) <nl> + in <nl> + let ( env , hret ) = <nl> + match decl_ty with <nl> + | None - > <nl> + ( * Do we have a contextual return type ? * ) <nl> + begin <nl> + match ret_ty with <nl> + | None - > <nl> + let ( env , ret_ty ) = Env . fresh_type env lambda_pos in <nl> + ( env , Typing_return . wrap_awaitable env lambda_pos ret_ty ) <nl> + | Some ret_ty - > <nl> + ( * We might need to force it to be Awaitable if it is a type variable * ) <nl> + Typing_return . force_awaitable env lambda_pos ret_ty <nl> + end <nl> + | Some ret - > <nl> + ( * If a ' this ' type appears it needs to be compatible with the <nl> + * late static type <nl> + * ) <nl> + let ety_env = <nl> + { ( Phase . env_with_self env ) with from_class = Some CIstatic } <nl> + in <nl> + Typing_return . make_return_type ( Phase . localize ~ ety_env ) env ret <nl> + in <nl> + let env = <nl> + Env . set_return <nl> + env <nl> + ( Typing_return . make_info <nl> + f . f_fun_kind <nl> + [ ] <nl> + env <nl> + ~ is_explicit : ( Option . is_some ret_ty ) <nl> + hret <nl> + decl_ty ) <nl> + in <nl> + let local_tpenv = Env . get_tpenv env in <nl> + ( * Outer pipe variables aren ' t available in closures . Note that <nl> + * locals are restored by Env . anon after processing the closure <nl> + * ) <nl> + let env = <nl> + Env . unset_local <nl> + env <nl> + ( Local_id . make_unscoped SN . SpecialIdents . dollardollar ) <nl> + in <nl> + let ( env , tb ) = block env nb . fb_ast in <nl> + let implicit_return = LEnv . has_next env in <nl> + let env = <nl> + if ( not implicit_return ) | | Nast . named_body_is_unsafe nb then <nl> + env <nl> + else <nl> + fun_implicit_return env lambda_pos hret f . f_fun_kind <nl> + in <nl> + let annotation = <nl> + if Nast . named_body_is_unsafe nb then <nl> + Tast . HasUnsafeBlocks <nl> + else <nl> + Tast . NoUnsafeBlocks <nl> + in <nl> + let ( env , tparams ) = List . map_env env f . f_tparams type_param in <nl> + let ( env , user_attributes ) = <nl> + List . map_env env f . f_user_attributes user_attribute <nl> + in <nl> + let tfun_ = <nl> + { <nl> + Aast . f_annotation = Env . save local_tpenv env ; <nl> + Aast . f_span = f . f_span ; <nl> + Aast . f_mode = f . f_mode ; <nl> + Aast . f_ret = ( hret , hint_of_type_hint f . f_ret ) ; <nl> + Aast . f_name = f . f_name ; <nl> + Aast . f_tparams = tparams ; <nl> + Aast . f_where_constraints = f . f_where_constraints ; <nl> + Aast . f_fun_kind = f . f_fun_kind ; <nl> + Aast . f_file_attributes = [ ] ; <nl> + Aast . f_user_attributes = user_attributes ; <nl> + Aast . f_body = { Aast . fb_ast = tb ; fb_annotation = annotation } ; <nl> + Aast . f_params = t_params ; <nl> + Aast . f_variadic = t_variadic ; <nl> + ( * TODO TAST : Variadic efuns * ) <nl> + Aast . f_external = f . f_external ; <nl> + Aast . f_namespace = f . f_namespace ; <nl> + Aast . f_doc_comment = f . f_doc_comment ; <nl> + Aast . f_static = f . f_static ; <nl> + } <nl> + in <nl> + let ty = mk ( Reason . Rwitness lambda_pos , Tfun ft ) in <nl> + let te = <nl> + Tast . make_typed_expr <nl> + lambda_pos <nl> + ty <nl> + ( if is_anon then <nl> + Aast . Efun ( tfun_ , idl ) <nl> + else <nl> + Aast . Lfun ( tfun_ , idl ) ) <nl> + in <nl> + let env = Env . set_tyvar_variance env ty in <nl> + ( env , te , hret ) ) ) <nl> + <nl> + ( * stash_conts_for_anon * ) <nl> + ( * Env . anon * ) <nl> <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * End of anonymous functions . * ) <nl> and call_parent_construct pos env el unpacked_element = <nl> | Tgeneric _ <nl> | Tnewtype _ <nl> | Tdependent ( _ , _ ) <nl> - | Tanon ( _ , _ ) <nl> | Tunion _ <nl> | Tintersection _ <nl> | Tobject <nl> and dispatch_call <nl> in <nl> match get_node ety with <nl> | Tfun { ft_is_coroutine = true ; _ } - > ( env , Some true ) <nl> - | Tanon ( _ , id ) - > <nl> - ( env , <nl> - Some <nl> - ( Option . value_map <nl> - ( Env . get_anonymous env id ) <nl> - ~ default : false <nl> - ~ f : ( fun ty_ - > ty_ . is_coroutine ) ) ) <nl> | Tunion ts <nl> | Tintersection ts - > <nl> are_coroutines env ts <nl> and class_get_ <nl> ( env , ( member_ty , tal ) ) ) ) <nl> | ( _ , <nl> ( Tvar _ | Tnonnull | Tarraykind _ | Toption _ | Tprim _ | Tfun _ <nl> - | Ttuple _ <nl> - | Tanon ( _ , _ ) <nl> - | Tobject | Tshape _ | Tpu _ | Tpu_type_access _ ) ) - > <nl> + | Ttuple _ | Tobject | Tshape _ | Tpu _ | Tpu_type_access _ ) ) - > <nl> ( * should never happen ; static_class_id takes care of these * ) <nl> ( env , ( mk ( Reason . Rnone , Typing_utils . tany env ) , [ ] ) ) <nl> <nl> and class_id_for_new ~ exact p env cid explicit_targs = <nl> | Tnewtype _ <nl> | Tdependent ( _ , _ ) <nl> | Ttuple _ <nl> - | Tanon ( _ , _ ) <nl> | Tunion _ <nl> | Tintersection _ <nl> | Tobject <nl> and static_class_id ? ( exact = Nonexact ) ~ check_constraints p env tal = <nl> | Tshape _ <nl> | Tvar _ <nl> | Tdynamic <nl> - | Tanon ( _ , _ ) <nl> | Tunion _ <nl> | Tintersection _ <nl> | Tgeneric _ <nl> and static_class_id ? ( exact = Nonexact ) ~ check_constraints p env tal = <nl> ( env , err_witness env p ) <nl> | ( _ , <nl> ( Tany _ | Tnonnull | Tarraykind _ | Toption _ | Tprim _ | Tfun _ <nl> - | Ttuple _ | Tnewtype _ | Tdependent _ <nl> - | Tanon ( _ , _ ) <nl> - | Tobject | Tshape _ | Tpu _ | Tpu_type_access _ ) ) - > <nl> + | Ttuple _ | Tnewtype _ | Tdependent _ | Tobject | Tshape _ | Tpu _ <nl> + | Tpu_type_access _ ) ) - > <nl> Errors . expected_class <nl> ~ suffix : ( " , but got " ^ Typing_print . error env base_ty ) <nl> p ; <nl> and call <nl> TR . get_adjusted_return_type env method_call_info ft . ft_ret . et_type <nl> in <nl> ( env , ( tel , typed_unpack_element , ret_ty ) ) <nl> - | ( r2 , Tanon ( arity , id ) ) - > <nl> - let ( env , tel , tyl ) = exprs env el in <nl> - let expr_for_unpacked_expr_list env = function <nl> - | None - > ( env , None , None , Pos . none ) <nl> - | Some ( ( pos , _ ) as e ) - > <nl> - let ( env , te , ety ) = expr env e in <nl> - ( env , Some te , Some ety , pos ) <nl> - in <nl> - let append_tuple_types tyl ty = <nl> - match ty with <nl> - | Some ty - > <nl> - begin <nl> - match get_node ty with <nl> - | Ttuple tuple_tyl - > tyl @ tuple_tyl <nl> - | _ - > tyl <nl> - end <nl> - | _ - > tyl <nl> - in <nl> - let determine_arity env min_arity pos = function <nl> - | None - > ( env , Fstandard ( min_arity , min_arity ) ) <nl> - | Some ety - > <nl> - ( * We need to figure out the underlying type of the unpacked expr type . <nl> - * <nl> - * For example , assume the call is : <nl> - * $ lambda ( . . . $ y ) ; <nl> - * where $ y is a variadic or collection of strings . <nl> - * <nl> - * $ y may have the type Tarraykind or Traversable , however we need to <nl> - * pass Fvariadic a param of type string . <nl> - * <nl> - * Assuming $ y has type Tarraykind , in order to get the underlying type <nl> - * we create a fresh_type ( ) , wrap it in a Traversable and make that <nl> - * Traversable a super type of the expr type ( Tarraykind ) . This way <nl> - * we can infer the underlying type and create the correct param for <nl> - * Fvariadic . <nl> - * ) <nl> - let ( env , ty ) = Env . fresh_type env pos in <nl> - let destructure_ty = <nl> - MakeType . simple_variadic_splat <nl> - ( Reason . Runpack_param ( get_pos ety , Reason . to_pos r2 , 0 ) ) <nl> - ty <nl> - in <nl> - let env = <nl> - SubType . sub_type_i <nl> - env <nl> - ( LoclType ety ) <nl> - destructure_ty <nl> - Errors . unify_error <nl> - in <nl> - let param = <nl> - { <nl> - fp_pos = pos ; <nl> - fp_name = None ; <nl> - fp_type = MakeType . unenforced ty ; <nl> - fp_kind = FPnormal ; <nl> - fp_accept_disposable = false ; <nl> - fp_mutability = None ; <nl> - fp_rx_annotation = None ; <nl> - } <nl> - in <nl> - ( env , Fvariadic ( min_arity , param ) ) <nl> - in <nl> - let ( env , typed_unpack_element , uety_opt , uepos ) = <nl> - expr_for_unpacked_expr_list env unpacked_element <nl> - in <nl> - let tyl = append_tuple_types tyl uety_opt in <nl> - let ( env , call_arity ) = <nl> - determine_arity env ( List . length tyl ) uepos uety_opt <nl> - in <nl> - let anon = Env . get_anonymous env id in <nl> - let fpos = Reason . to_pos r2 in <nl> - ( match anon with <nl> - | None - > <nl> - Errors . anonymous_recursive_call pos ; <nl> - ( env , ( tel , typed_unpack_element , err_witness env pos ) ) <nl> - | Some <nl> - { <nl> - rx = reactivity ; <nl> - is_coroutine ; <nl> - counter = ftys ; <nl> - typecheck = anon ; <nl> - _ ; <nl> - } - > <nl> - let ( ) = <nl> - check_arity pos fpos ( Typing_defs . arity_min call_arity ) arity <nl> - in <nl> - let tyl = List . map tyl TUtils . default_fun_param in <nl> - let ( env , _ , ty ) = anon ~ el env tyl call_arity in <nl> - let fty = <nl> - mk <nl> - ( Reason . Rlambda_use pos , <nl> - Tfun <nl> - { <nl> - ft_is_coroutine = is_coroutine ; <nl> - ft_arity = arity ; <nl> - ft_tparams = ( [ ] , FTKtparams ) ; <nl> - ft_where_constraints = [ ] ; <nl> - ft_params = tyl ; <nl> - ft_ret = MakeType . unenforced ty ; <nl> - ft_reactive = reactivity ; <nl> - ( * TODO : record proper async lambda information * ) <nl> - ft_fun_kind = Ast_defs . FSync ; <nl> - ft_return_disposable = false ; <nl> - ft_mutability = None ; <nl> - ft_returns_mutable = false ; <nl> - ft_returns_void_to_rx = false ; <nl> - } ) <nl> - in <nl> - ftys : = TUtils . add_function_type env fty ! ftys ; <nl> - ( env , ( tel , typed_unpack_element , ty ) ) ) <nl> | _ - > <nl> bad_call env pos efty ; <nl> let env = call_untyped_unpack env ( get_pos efty ) unpacked_element in <nl> and condition <nl> | ( _ , <nl> ( Terr | Tany _ | Tnonnull | Tarraykind _ | Toption _ | Tdynamic <nl> | Tprim _ | Tvar _ | Tfun _ | Tgeneric _ | Tnewtype _ | Tdependent _ <nl> - | Tclass _ | Ttuple _ <nl> - | Tanon ( _ , _ ) <nl> - | Tunion _ | Tintersection _ | Tobject | Tshape _ | Tpu _ <nl> - | Tpu_type_access _ ) ) - > <nl> + | Tclass _ | Ttuple _ | Tunion _ | Tintersection _ | Tobject | Tshape _ <nl> + | Tpu _ | Tpu_type_access _ ) ) - > <nl> condition_nullity ~ nonnull : tparamet env te ) <nl> | Aast . Binop ( ( ( Ast_defs . Diff | Ast_defs . Diff2 ) as op ) , e1 , e2 ) - > <nl> let op = <nl> and condition <nl> in <nl> env <nl> | Aast . Call ( Cnormal , ( ( p , _ ) , Aast . Id ( _ , f ) ) , _ , [ lv ] , None ) <nl> - when tparamet & & ( <nl> - String . equal f SN . StdlibFunctions . is_array | | <nl> - String . equal f SN . StdlibFunctions . is_php_array <nl> - ) - > <nl> + when tparamet <nl> + & & ( String . equal f SN . StdlibFunctions . is_array <nl> + | | String . equal f SN . StdlibFunctions . is_php_array ) - > <nl> is_array env ` PHPArray p f lv <nl> | Aast . Call <nl> ( Cnormal , <nl> and class_for_refinement env p reason ivar_pos ivar_ty hint_ty = <nl> ( env , mk ( reason , Ttuple tyl ) ) <nl> | ( _ , <nl> ( Tany _ | Tprim _ | Toption _ | Ttuple _ | Tnonnull | Tshape _ | Tvar _ <nl> - | Tgeneric _ | Tnewtype _ | Tdependent _ | Tarraykind _ | Tanon _ <nl> - | Tunion _ | Tintersection _ | Tobject | Terr | Tfun _ | Tdynamic | Tpu _ <nl> + | Tgeneric _ | Tnewtype _ | Tdependent _ | Tarraykind _ | Tunion _ <nl> + | Tintersection _ | Tobject | Terr | Tfun _ | Tdynamic | Tpu _ <nl> | Tpu_type_access _ ) ) - > <nl> ( env , hint_ty ) <nl> <nl> and method_def env cls m = <nl> } <nl> in <nl> let ( env , global_inference_env ) = Env . extract_global_inference_env env in <nl> - let env = Env . log_env_change " method_def " initial_env env in <nl> - ( Typing_lambda_ambiguous . suggest_method_def env method_def , <nl> - ( pos , global_inference_env ) ) ) <nl> + let _env = Env . log_env_change " method_def " initial_env env in <nl> + ( method_def , ( pos , global_inference_env ) ) ) <nl> <nl> and typedef_def ctx typedef = <nl> let env = EnvFromDef . typedef_env ctx typedef in <nl> and class_get_pu_ env cty name = <nl> | Tprim _ <nl> | Tfun _ <nl> | Ttuple _ <nl> - | Tanon ( _ , _ ) <nl> | Tobject <nl> | Tshape _ - > <nl> ( env , None ) <nl> mmm a / hphp / hack / src / typing / typing_array_access . ml <nl> ppp b / hphp / hack / src / typing / typing_array_access . ml <nl> let rec array_get <nl> | Tprim _ <nl> | Tfun _ <nl> | Tclass _ <nl> - | Tanon _ <nl> | Tgeneric _ <nl> | Tnewtype _ <nl> | Tdependent _ <nl> let assign_array_append ~ array_pos ~ expr_pos ur env ty1 ty2 = <nl> ( env , ty1 ) <nl> | ( _ , <nl> ( Tnonnull | Tarraykind _ | Toption _ | Tprim _ | Tvar _ | Tfun _ <nl> - | Tclass _ | Ttuple _ | Tanon _ | Tshape _ | Tunion _ <nl> - | Tintersection _ | Tgeneric _ | Tnewtype _ | Tdependent _ | Tpu _ <nl> - | Tpu_type_access _ ) ) - > <nl> + | Tclass _ | Ttuple _ | Tshape _ | Tunion _ | Tintersection _ <nl> + | Tgeneric _ | Tnewtype _ | Tdependent _ | Tpu _ | Tpu_type_access _ <nl> + ) ) - > <nl> error_assign_array_append env expr_pos ty1 ) <nl> <nl> let widen_for_assign_array_get ~ expr_pos index_expr env ty = <nl> let assign_array_get ~ array_pos ~ expr_pos ur env ty1 key tkey ty2 = <nl> | Tvar _ <nl> | Tfun _ <nl> | Tclass _ <nl> - | Tanon _ <nl> | Tpu _ <nl> | Tpu_type_access _ - > <nl> Errors . array_access <nl> mmm a / hphp / hack / src / typing / typing_async . ml <nl> ppp b / hphp / hack / src / typing / typing_async . ml <nl> let overload_extract_from_awaitable env ~ p opt_ty_maybe = <nl> | Tdependent _ <nl> | Tclass _ <nl> | Ttuple _ <nl> - | Tanon ( _ , _ ) <nl> | Tobject <nl> | Tshape _ <nl> | Tpu _ <nl> let overload_extract_from_awaitable env ~ p opt_ty_maybe = <nl> | Tdependent _ <nl> | Tclass _ <nl> | Ttuple _ <nl> - | Tanon _ <nl> | Tintersection _ <nl> | Toption _ <nl> | Tunion _ <nl> mmm a / hphp / hack / src / typing / typing_defs . ml <nl> ppp b / hphp / hack / src / typing / typing_defs . ml <nl> type deserialization_error = <nl> | Not_supported of string <nl> ( * * The specific type or some component thereof is not one that we support <nl> deserializing , usually because not enough information was serialized to be <nl> - able to deserialize it again . For example , lambda types ( ` Tanon ` ) contain a <nl> - reference to an identifier ( ` Ident . t ` ) , which is not serialized . * ) <nl> + able to deserialize it again . * ) <nl> | Deserialization_error of string <nl> ( * * The input JSON was invalid for some reason . * ) <nl> <nl> let is_union_or_inter_type ( ty : locl_ty ) = <nl> | Tnewtype _ <nl> | Tdependent _ <nl> | Tgeneric _ <nl> - | Tanon _ <nl> | Tclass _ <nl> | Tarraykind _ - > <nl> false <nl> let ty_con_ordinal ty_ = <nl> | Tnewtype _ - > 10 <nl> | Tgeneric _ - > 11 <nl> | Tdependent _ - > 12 <nl> - | Tanon _ - > 13 <nl> - | Tunion _ - > 14 <nl> - | Tintersection _ - > 15 <nl> - | Tobject - > 16 <nl> - | Tclass _ - > 17 <nl> - | Tarraykind _ - > 18 <nl> - | Tpu _ - > 19 <nl> - | Tpu_type_access _ - > 20 <nl> + | Tunion _ - > 13 <nl> + | Tintersection _ - > 14 <nl> + | Tobject - > 15 <nl> + | Tclass _ - > 16 <nl> + | Tarraykind _ - > 17 <nl> + | Tpu _ - > 18 <nl> + | Tpu_type_access _ - > 19 <nl> <nl> ( * Ordinal value for type constructor , for decl types * ) <nl> let decl_ty_con_ordinal ty_ = <nl> let rec ty__compare ? ( normalize_lists = false ) ty_1 ty_2 = <nl> | n - > n <nl> end <nl> | ( Tvar v1 , Tvar v2 ) - > compare v1 v2 <nl> - | ( Tanon ( _ , id1 ) , Tanon ( _ , id2 ) ) - > compare id1 id2 <nl> | _ - > ty_con_ordinal ty_1 - ty_con_ordinal ty_2 <nl> and shape_field_type_compare sft1 sft2 = <nl> match ty_compare sft1 . sft_ty sft2 . sft_ty with <nl> mmm a / hphp / hack / src / typing / typing_defs_core . ml <nl> ppp b / hphp / hack / src / typing / typing_defs_core . ml <nl> and _ ty_ = <nl> ( * * All the primitive types : int , string , void , etc . * ) <nl> | Tfun : ' phase ty fun_type - > ' phase ty_ <nl> ( * * A wrapper around fun_type , which contains the full type information for a <nl> - * function , method , lambda , etc . Note that lambdas have an additional layer <nl> - * of indirection before you get to Tfun - - see Tanon below . * ) <nl> + * function , method , lambda , etc . * ) <nl> | Ttuple : ' phase ty list - > ' phase ty_ <nl> ( * * Tuple , with ordered list of the types of the elements of the tuple . * ) <nl> | Tshape : shape_kind * ' phase shape_field_type Nast . ShapeMap . t - > ' phase ty_ <nl> and _ ty_ = <nl> * ) <nl> | Tdependent : dependent_type * locl_ty - > locl_phase ty_ <nl> ( * * see dependent_type * ) <nl> - | Tanon : locl_fun_arity * Ident . t - > locl_phase ty_ <nl> - ( * * An anonymous function , including the fun arity , and the identifier to <nl> - * type the body of the function . ( The actual closure is stored in <nl> - * Typing_env . env . genv . anons ) * ) <nl> | Tunion : ' phase ty list - > ' phase ty_ <nl> ( * * Union type . <nl> * The values that are members of this type are the union of the values <nl> mmm a / hphp / hack / src / typing / typing_defs_core . mli <nl> ppp b / hphp / hack / src / typing / typing_defs_core . mli <nl> and _ ty_ = <nl> ( * All the primitive types : int , string , void , etc . * ) <nl> | Tprim : Aast . tprim - > ' phase ty_ <nl> ( * A wrapper around fun_type , which contains the full type information for a <nl> - * function , method , lambda , etc . Note that lambdas have an additional layer <nl> - * of indirection before you get to Tfun - - see Tanon below . * ) <nl> + * function , method , lambda , etc . * ) <nl> | Tfun : ' phase ty fun_type - > ' phase ty_ <nl> ( * Tuple , with ordered list of the types of the elements of the tuple . * ) <nl> | Ttuple : ' phase ty list - > ' phase ty_ <nl> and _ ty_ = <nl> | Tnewtype : string * locl_ty list * locl_ty - > locl_phase ty_ <nl> ( * see dependent_type * ) <nl> | Tdependent : dependent_type * locl_ty - > locl_phase ty_ <nl> - ( * An anonymous function , including the fun arity , and the identifier to <nl> - * type the body of the function . ( The actual closure is stored in <nl> - * Typing_env . env . genv . anons ) * ) <nl> - | Tanon : locl_fun_arity * Ident . t - > locl_phase ty_ <nl> ( * Union type . <nl> * The values that are members of this type are the union of the values <nl> * that are members of the components of the union . <nl> mmm a / hphp / hack / src / typing / typing_dependent_type . ml <nl> ppp b / hphp / hack / src / typing / typing_dependent_type . ml <nl> module ExprDepTy = struct <nl> ( env , mk ( r , Tintersection tyl ) ) <nl> ( * TODO ( T36532263 ) check if this is legal * ) <nl> | ( _ , <nl> - ( Tanon _ | Tobject | Tnonnull | Tprim _ | Tshape _ | Ttuple _ <nl> - | Tdynamic | Tarraykind _ | Tfun _ | Tany _ | Tvar _ | Terr | Tpu _ <nl> + ( Tobject | Tnonnull | Tprim _ | Tshape _ | Ttuple _ | Tdynamic <nl> + | Tarraykind _ | Tfun _ | Tany _ | Tvar _ | Terr | Tpu _ <nl> | Tpu_type_access _ ) ) - > <nl> ( env , ty ) <nl> in <nl> mmm a / hphp / hack / src / typing / typing_enum . ml <nl> ppp b / hphp / hack / src / typing / typing_enum . ml <nl> let check_valid_array_key_type f_fail ~ allow_any env p t = <nl> | Tdependent _ <nl> | Tclass _ <nl> | Ttuple _ <nl> - | Tanon _ <nl> | Tfun _ <nl> | Tunion _ <nl> | Tobject <nl> mmm a / hphp / hack / src / typing / typing_env . ml <nl> ppp b / hphp / hack / src / typing / typing_env . ml <nl> let empty ? ( mode = FileInfo . Mstrict ) ctx file ~ droot = <nl> parent = None ; <nl> fun_kind = Ast_defs . FSync ; <nl> fun_mutable = None ; <nl> - anons = IMap . empty ; <nl> file ; <nl> } ; <nl> global_tpenv = TPEnv . empty ; <nl> let set_fn_kind env fn_type = <nl> <nl> let set_inside_ppl_class env inside_ppl_class = { env with inside_ppl_class } <nl> <nl> - let add_anonymous env x = <nl> - let genv = env . genv in <nl> - let anon_id = Ident . tmp ( ) in <nl> - let genv = { genv with anons = IMap . add anon_id x genv . anons } in <nl> - ( { env with genv } , anon_id ) <nl> - <nl> - let get_anonymous env x = IMap . find_opt x env . genv . anons <nl> - <nl> let set_self env self_id self_ty = <nl> let genv = env . genv in <nl> let genv = { genv with self = Some ( self_id , self_ty ) } in <nl> let set_allow_solve_globals env flag = <nl> wrap_inference_env_call_env env ( fun env - > <nl> Inf . set_allow_solve_globals env flag ) <nl> <nl> - let iter_anonymous env f = <nl> - IMap . iter <nl> - ( fun _id { counter = ftys ; pos ; _ } - > <nl> - let ( untyped , typed ) = ! ftys in <nl> - f pos ( untyped @ typed ) ) <nl> - env . genv . anons <nl> - <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> ( * Locals * ) <nl> ( * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ) <nl> and get_tyvars_i env ( ty : internal_type ) = <nl> | Terr <nl> | Tdynamic <nl> | Tobject <nl> - | Tprim _ <nl> - | Tanon _ - > <nl> + | Tprim _ - > <nl> ( env , ISet . empty , ISet . empty ) <nl> | Toption ty - > get_tyvars env ty <nl> | Ttuple tyl <nl> mmm a / hphp / hack / src / typing / typing_env . mli <nl> ppp b / hphp / hack / src / typing / typing_env . mli <nl> val set_fn_kind : env - > Ast_defs . fun_kind - > env <nl> <nl> val set_inside_ppl_class : env - > bool - > env <nl> <nl> - val add_anonymous : env - > anon - > env * int <nl> - <nl> - val get_anonymous : env - > int - > anon option <nl> - <nl> - val iter_anonymous : env - > ( Pos . t - > locl_ty list - > unit ) - > unit <nl> - <nl> val set_self : env - > string - > locl_ty - > env <nl> <nl> val set_parent : env - > string - > decl_ty - > env <nl> mmm a / hphp / hack / src / typing / typing_env_types . ml <nl> ppp b / hphp / hack / src / typing / typing_env_types . ml <nl> let show_genv _ = " < genv > " <nl> <nl> let pp_genv _ _ = Printf . printf " % s \ n " " < genv > " <nl> <nl> - let show_anon _ = " < anon > " <nl> - <nl> - let pp_anon _ _ = Printf . printf " % s \ n " " < anon > " <nl> - <nl> let show_tfun _ = " < tfun > " <nl> <nl> let pp_tfun _ _ = Printf . printf " % s \ n " " < tfun > " <nl> and genv = { <nl> fun_kind : Ast_defs . fun_kind ; <nl> val_kind : Typing_defs . val_kind ; <nl> fun_mutable : param_mutability option ; <nl> - anons : anon IMap . t ; <nl> file : Relative_path . t ; <nl> } <nl> <nl> - ( * A type - checker for an anonymous function <nl> - * Parameters are <nl> - * - the environment <nl> - * - types of the parameters under which the body should be checked <nl> - * - the arity of the function <nl> - * - the expected return type of the body ( optional ) <nl> - * ) <nl> - and anon_log = locl_ty list * locl_ty list <nl> - <nl> - and anon = { <nl> - rx : reactivity ; <nl> - is_coroutine : Aast . is_coroutine ; <nl> - counter : anon_log ref ; <nl> - pos : Pos . t ; <nl> - typecheck : <nl> - ? el : Nast . expr list - > <nl> - ? ret_ty : locl_ty - > <nl> - env - > <nl> - locl_fun_params - > <nl> - locl_fun_arity - > <nl> - env * Tast . expr * locl_ty ; <nl> - } <nl> - <nl> let env_reactivity env = env . lenv . local_reactive <nl> mmm a / hphp / hack / src / typing / typing_env_types . mli <nl> ppp b / hphp / hack / src / typing / typing_env_types . mli <nl> and genv = { <nl> fun_kind : Ast_defs . fun_kind ; <nl> val_kind : Typing_defs . val_kind ; <nl> fun_mutable : param_mutability option ; <nl> - anons : anon IMap . t ; <nl> file : Relative_path . t ; <nl> } <nl> <nl> - ( * A type - checker for an anonymous function <nl> - * Parameters are <nl> - * - the environment <nl> - * - types of the parameters under which the body should be checked <nl> - * - the arity of the function <nl> - * - the expected return type of the body ( optional ) <nl> - * ) <nl> - and anon_log = locl_ty list * locl_ty list <nl> - <nl> - and anon = { <nl> - rx : reactivity ; <nl> - is_coroutine : Aast . is_coroutine ; <nl> - counter : anon_log ref ; <nl> - pos : Pos . t ; <nl> - typecheck : <nl> - ? el : Nast . expr list - > <nl> - ? ret_ty : locl_ty - > <nl> - env - > <nl> - locl_fun_params - > <nl> - locl_fun_arity - > <nl> - env * Tast . expr * locl_ty ; <nl> - } <nl> - <nl> val env_reactivity : env - > reactivity <nl> mmm a / hphp / hack / src / typing / typing_equality_check . ml <nl> ppp b / hphp / hack / src / typing / typing_equality_check . ml <nl> let rec assert_nontrivial p bop env ty1 ty2 = <nl> | ( ( _ , <nl> ( Terr | Tany _ | Tnonnull | Tarraykind _ | Tprim _ | Toption _ <nl> | Tdynamic | Tvar _ | Tfun _ | Tgeneric _ | Tnewtype _ | Tdependent _ <nl> - | Tclass _ | Ttuple _ <nl> - | Tanon ( _ , _ ) <nl> - | Tunion _ | Tintersection _ | Tobject | Tshape _ | Tpu _ <nl> - | Tpu_type_access _ ) ) , <nl> + | Tclass _ | Ttuple _ | Tunion _ | Tintersection _ | Tobject <nl> + | Tshape _ | Tpu _ | Tpu_type_access _ ) ) , <nl> _ ) - > <nl> ( ) ) <nl> <nl> deleted file mode 100644 <nl> index 312f2567450 . . 00000000000 <nl> mmm a / hphp / hack / src / typing / typing_lambda_ambiguous . ml <nl> ppp / dev / null <nl> <nl> - ( * <nl> - * Copyright ( c ) 2017 , Facebook , Inc . <nl> - * All rights reserved . <nl> - * <nl> - * This source code is licensed under the MIT license found in the <nl> - * LICENSE file in the " hack " directory of this source tree . <nl> - * <nl> - * ) <nl> - <nl> - open Hh_prelude <nl> - open Typing_defs <nl> - module Env = Typing_env <nl> - module Reason = Typing_reason <nl> - module FL = FeatureLogging <nl> - module Tast = Aast <nl> - <nl> - let log_anonymous env = <nl> - let found = ref false in <nl> - Env . iter_anonymous env ( fun pos ftys - > <nl> - let n = List . length ftys in <nl> - if n > 0 then found : = true ; <nl> - if GlobalOptions . tco_language_feature_logging ( Env . get_tcopt env ) then <nl> - Measure . sample ( FL . Lambda . unknown_params_with_uses n ) 1 . 0 ; <nl> - if <nl> - TypecheckerOptions . disallow_ambiguous_lambda ( Env . get_tcopt env ) <nl> - & & n > 0 <nl> - then <nl> - Errors . ambiguous_lambda <nl> - pos <nl> - ( List . map ftys ( fun fty - > <nl> - ( get_pos fty , Typing_print . full_strip_ns env fty ) ) ) <nl> - else <nl> - ( ) ) ; <nl> - ! found <nl> - <nl> - let make_suggest_ty tys = <nl> - mk <nl> - ( Reason . Rnone , <nl> - Tnewtype ( " HackSuggest " , tys , Typing_make_type . mixed Reason . none ) ) <nl> - <nl> - let visitor = <nl> - object <nl> - inherit Tast_visitor . endo as super <nl> - <nl> - method ! on_expr env x = <nl> - let on_fun pos id f = <nl> - let ftys = Tast_env . get_anonymous_lambda_types env id in <nl> - if List . is_empty ftys then <nl> - None <nl> - else <nl> - let newty = make_suggest_ty ftys in <nl> - ( * If we have a single type , propagate types onto parameters * ) <nl> - let ( newty , f ) = <nl> - match ftys with <nl> - | [ funty ] - > <nl> - begin <nl> - match get_node funty with <nl> - | Tfun { ft_params ; _ } - > <nl> - let rec add_types tfun_params efun_params = <nl> - match ( tfun_params , efun_params ) with <nl> - | ( _ , [ ] ) - > [ ] <nl> - | ( { fp_type ; _ } : : tfun_params , <nl> - ( { Tast . param_annotation = ( pos , _ ) ; _ } as param ) <nl> - : : params ) <nl> - when Option . is_none <nl> - ( Tast . hint_of_type_hint param . Tast . param_type_hint ) <nl> - - > <nl> - { <nl> - param with <nl> - Tast . param_annotation = <nl> - ( pos , make_suggest_ty [ fp_type . et_type ] ) ; <nl> - } <nl> - : : add_types tfun_params params <nl> - | ( _ : : tfun_params , param : : params ) - > <nl> - param : : add_types tfun_params params <nl> - | ( [ ] , _ ) - > efun_params <nl> - in <nl> - let f_params = add_types ft_params f . Tast . f_params in <nl> - ( ( pos , newty ) , { f with Tast . f_params } ) <nl> - | _ - > ( ( pos , newty ) , f ) <nl> - end <nl> - | _ - > ( ( pos , newty ) , f ) <nl> - in <nl> - Some ( newty , f ) <nl> - in <nl> - let result = <nl> - match x with <nl> - | ( ( pos , ty ) , Tast . Efun ( f , ids ) ) - > <nl> - begin <nl> - match get_node ty with <nl> - | Tanon ( _anon_arity , id ) - > <nl> - begin <nl> - match on_fun pos id f with <nl> - | None - > x <nl> - | Some ( newty , f ) - > ( newty , Tast . Efun ( f , ids ) ) <nl> - end <nl> - | _ - > x <nl> - end <nl> - | ( ( pos , ty ) , Tast . Lfun ( f , ids ) ) - > <nl> - begin <nl> - match get_node ty with <nl> - | Tanon ( _anon_arity , id ) - > <nl> - begin <nl> - match on_fun pos id f with <nl> - | None - > x <nl> - | Some ( newty , f ) - > ( newty , Tast . Lfun ( f , ids ) ) <nl> - end <nl> - | _ - > x <nl> - end <nl> - | _ - > x <nl> - in <nl> - super # on_expr env result <nl> - end <nl> - <nl> - ( * Add HackSuggest types to legacy lambdas * ) <nl> - let suggest_fun_def env tast = <nl> - let found_anon = log_anonymous env in <nl> - if found_anon then <nl> - let tastenv = Tast_env . typing_env_as_tast_env env in <nl> - visitor # on_fun_ tastenv tast <nl> - else <nl> - tast <nl> - <nl> - let suggest_method_def env tast = <nl> - let found_anon = log_anonymous env in <nl> - if found_anon then <nl> - let tastenv = Tast_env . typing_env_as_tast_env env in <nl> - visitor # on_method_ tastenv tast <nl> - else <nl> - tast <nl> mmm a / hphp / hack / src / typing / typing_log . ml <nl> ppp b / hphp / hack / src / typing / typing_log . ml <nl> let genv_as_value env genv = <nl> val_kind ; <nl> fun_kind ; <nl> fun_mutable ; <nl> - anons = _ ; <nl> file = _ ; <nl> } = <nl> genv <nl> mmm a / hphp / hack / src / typing / typing_memoize . ml <nl> ppp b / hphp / hack / src / typing / typing_memoize . ml <nl> let check_param : env - > Nast . fun_param - > unit = <nl> ( ) <nl> | Tfun _ <nl> | Tvar _ <nl> - | Tanon _ <nl> | Tobject - > <nl> error ty <nl> in <nl> mmm a / hphp / hack / src / typing / typing_print . ml <nl> ppp b / hphp / hack / src / typing / typing_print . ml <nl> module Full = struct <nl> ( * Don ' t strip_ns here ! We want the FULL type , including the initial slash . <nl> * ) <nl> | Ttuple tyl - > ttuple k tyl <nl> - | Tanon ( _ , id ) - > <nl> - begin <nl> - match Env . get_anonymous env id with <nl> - | Some { rx = Reactive _ ; is_coroutine = true ; _ } - > <nl> - text " [ coroutine rx fun ] " <nl> - | Some { rx = Nonreactive ; is_coroutine = true ; _ } - > <nl> - text " [ coroutine fun ] " <nl> - | Some { rx = Reactive _ ; is_coroutine = false ; _ } - > text " [ rx fun ] " <nl> - | _ - > text " [ fun ] " <nl> - end <nl> | Tunion [ ] - > text " nothing " <nl> | Tunion tyl when TypecheckerOptions . like_type_hints ( Env . get_tcopt env ) - > <nl> let tyl = <nl> module ErrorString = struct <nl> end <nl> | Tprim tp - > tprim tp <nl> | Tvar _ - > " some value " <nl> - | Tanon _ - > " a function " <nl> | Tfun _ - > " a function " <nl> | Tgeneric s when DependentKind . is_generic_dep_ty s - > <nl> " the expression dependent type " ^ s <nl> module Json = struct <nl> let param fp = obj @ @ callconv fp . fp_kind @ typ fp . fp_type . et_type in <nl> let params fps = [ ( " params " , JSON_Array ( List . map fps param ) ) ] in <nl> obj @ @ fun_kind @ params ft . ft_params @ result ft . ft_ret . et_type <nl> - | Tanon _ - > obj @ @ kind " anon " <nl> | Tarraykind ( AKvarray_or_darray ( ty1 , ty2 ) ) - > <nl> obj @ @ kind " varray_or_darray " @ args [ ty1 ; ty2 ] <nl> | Tarraykind ( AKdarray ( ty1 , ty2 ) ) - > obj @ @ kind " darray " @ args [ ty1 ; ty2 ] <nl> module Json = struct <nl> ft_returns_mutable = false ; <nl> ft_returns_void_to_rx = false ; <nl> } ) <nl> - | " anon " - > <nl> - not_supported <nl> - ~ message : " Cannot deserialize lambda expression type " <nl> - ~ keytrace <nl> | _ - > <nl> deserialization_error <nl> ~ message : <nl> mmm a / hphp / hack / src / typing / typing_solver . ml <nl> ppp b / hphp / hack / src / typing / typing_solver . ml <nl> let rec freshen_inside_ty env ty = <nl> | Tdynamic <nl> | Tobject <nl> | Tprim _ <nl> - | Tanon _ <nl> | Tgeneric _ <nl> | Tdependent _ - > <nl> default ( ) <nl> let unsolved_invariant_tyvars_under_union_and_intersection env ty = <nl> let rec find_tyvars ( env , tyvars ) ty = <nl> let ( env , ty ) = Env . expand_type env ty in <nl> match deref ty with <nl> - | ( r , Tvar v ) - > <nl> - let tyvars = <nl> - if <nl> - Env . get_tyvar_appears_invariantly env v <nl> - | | TypecheckerOptions . new_inference_lambda ( Env . get_tcopt env ) <nl> - then <nl> - ( r , v ) : : tyvars <nl> - else <nl> - tyvars <nl> - in <nl> - ( env , tyvars ) <nl> + | ( r , Tvar v ) - > ( env , ( r , v ) : : tyvars ) <nl> | ( _ , Toption ty ) - > find_tyvars ( env , tyvars ) ty <nl> | ( _ , Tunion tyl ) <nl> | ( _ , Tintersection tyl ) - > <nl> let unsolved_invariant_tyvars_under_union_and_intersection env ty = <nl> | ( _ , <nl> ( Terr | Tany _ | Tdynamic | Tnonnull | Tprim _ | Tclass _ | Tobject <nl> | Tgeneric _ | Tnewtype _ | Tdependent _ | Tarraykind _ | Ttuple _ <nl> - | Tshape _ | Tfun _ | Tanon _ | Tpu _ | Tpu_type_access _ ) ) - > <nl> + | Tshape _ | Tfun _ | Tpu _ | Tpu_type_access _ ) ) - > <nl> ( env , tyvars ) <nl> in <nl> find_tyvars ( env , [ ] ) ty <nl> mmm a / hphp / hack / src / typing / typing_subtype . ml <nl> ppp b / hphp / hack / src / typing / typing_subtype . ml <nl> and simplify_subtype_i <nl> * ) <nl> | ( ( _ , <nl> ( Tdynamic | Tprim _ | Tnonnull | Tfun _ | Ttuple _ | Tshape _ <nl> - | Tanon _ | Tobject | Tclass _ | Tarraykind _ | Tany _ | Terr <nl> - | Tpu _ | Tpu_type_access _ ) ) , <nl> + | Tobject | Tclass _ | Tarraykind _ | Tany _ | Terr | Tpu _ <nl> + | Tpu_type_access _ ) ) , <nl> _ ) - > <nl> simplify_subtype ~ subtype_env ~ this_ty lty_sub arg_ty_super env ) <nl> ) <nl> and simplify_subtype_i <nl> Nast . ( <nl> ( Tint | Tbool | Tfloat | Tstring | Tresource | Tnum <nl> | Tarraykey | Tnoreturn | Tatom _ ) ) <nl> - | Tnonnull | Tfun _ | Ttuple _ | Tshape _ | Tanon _ | Tobject <nl> - | Tclass _ | Tarraykind _ | Tpu _ | Tpu_type_access _ ) ) - > <nl> + | Tnonnull | Tfun _ | Ttuple _ | Tshape _ | Tobject | Tclass _ <nl> + | Tarraykind _ | Tpu _ | Tpu_type_access _ ) ) - > <nl> valid ( ) <nl> | _ - > default_subtype env ) ) <nl> | ( _ , Tdynamic ) - > <nl> and simplify_subtype_i <nl> | Tclass _ - > <nl> valid ( ) <nl> | _ - > default_subtype env ) ) <nl> - | ( _ , Tanon ( _ , id_super ) ) - > <nl> - ( match ety_sub with <nl> - | ConstraintType _ - > default_subtype env <nl> - | LoclType lty - > <nl> - ( match get_node lty with <nl> - | Tanon ( _ , id_sub ) when Ident . equal id_sub id_super - > valid ( ) <nl> - | _ - > default_subtype env ) ) <nl> | ( r_super , Tany _ ) - > <nl> ( match ety_sub with <nl> | ConstraintType cty - > <nl> and simplify_subtype_i <nl> r_super <nl> ft_super <nl> env <nl> - | ( r_sub , Tanon ( anon_arity , id ) ) - > <nl> - begin <nl> - match Env . get_anonymous env id with <nl> - | None - > <nl> - invalid_with ( fun ( ) - > <nl> - Errors . anonymous_recursive_call ( Reason . to_pos r_sub ) ) <nl> - | Some <nl> - { <nl> - rx = reactivity ; <nl> - is_coroutine ; <nl> - counter = ftys ; <nl> - typecheck = anon ; <nl> - _ ; <nl> - } - > <nl> - let p_super = Reason . to_pos r_super in <nl> - let p_sub = Reason . to_pos r_sub in <nl> - ( * Add function type to set of types seen so far * ) <nl> - ftys : = TUtils . add_function_type env ty_super ! ftys ; <nl> - ( env , TL . valid ) <nl> - | > check_with <nl> - ( Aast . equal_is_coroutine <nl> - is_coroutine <nl> - ft_super . ft_is_coroutine ) <nl> - ( fun ( ) - > <nl> - Errors . coroutinness_mismatch <nl> - ft_super . ft_is_coroutine <nl> - p_super <nl> - p_sub <nl> - subtype_env . on_error ) <nl> - | > check_with <nl> - ( check_anon_arity <nl> - ~ ellipsis_is_variadic : true <nl> - anon_arity <nl> - ft_super . ft_arity ) <nl> - ( fun ( ) - > <nl> - Errors . fun_arity_mismatch <nl> - p_super <nl> - p_sub <nl> - subtype_env . on_error ) <nl> - | > fun ( env , prop ) - > <nl> - let ( env , _ , ret ) = <nl> - anon env ft_super . ft_params ft_super . ft_arity <nl> - in <nl> - ( env , prop ) <nl> - & & & ( fun env - > <nl> - if TypecheckerOptions . unsafe_rx ( Env . get_tcopt env ) then <nl> - ( env , TL . valid ) <nl> - else <nl> - simplify_subtype_reactivity <nl> - ~ subtype_env <nl> - p_sub <nl> - reactivity <nl> - p_super <nl> - ft_super . ft_reactive <nl> - env ) <nl> - & & & simplify_subtype <nl> - ~ subtype_env <nl> - ~ this_ty <nl> - ret <nl> - ft_super . ft_ret . et_type <nl> - end <nl> | _ - > default_subtype env ) ) <nl> | ( _ , Ttuple tyl_super ) - > <nl> ( match ety_sub with <nl> and simplify_subtype_variance <nl> end <nl> & & & simplify_subtype_variance cid variance_reifiedl childrenl superl <nl> <nl> - and check_anon_arity ~ ellipsis_is_variadic anon_arity func_arity : bool = <nl> - match ( anon_arity , func_arity ) with <nl> - | ( Fellipsis ( a_min , _ ) , Fvariadic ( f_min , _ ) ) when ellipsis_is_variadic - > <nl> - ( * we want to allow use the " . . . " syntax in the declaration of <nl> - * anonymous function types to match named variadic arguments <nl> - * of the " . . . $ args " form as well as unnamed ones * ) <nl> - Int . equal a_min f_min <nl> - | ( Fvariadic ( a_min , _ ) , Fstandard ( f_min , _ ) ) <nl> - | ( Fvariadic ( a_min , _ ) , Fvariadic ( f_min , _ ) ) <nl> - | ( Fellipsis ( a_min , _ ) , Fstandard ( f_min , _ ) ) <nl> - | ( Fellipsis ( a_min , _ ) , Fellipsis ( f_min , _ ) ) - > <nl> - a_min < = f_min <nl> - | ( Fstandard ( a_min , a_max ) , Fstandard ( f_min , f_max ) ) - > <nl> - Int . equal a_min f_min & & Int . equal a_max f_max <nl> - | ( _ , _ ) - > false <nl> - <nl> and simplify_subtype_params <nl> ~ ( subtype_env : subtype_env ) <nl> ? ( is_method : bool = false ) <nl> mmm a / hphp / hack / src / typing / typing_taccess . ml <nl> ppp b / hphp / hack / src / typing / typing_taccess . ml <nl> let rec expand ctx env root = <nl> | Tpu_type_access ( base , _ , _ , _ ) - > <nl> let pos = get_pos base in <nl> raise_error ( fun _ - > Errors . pu_expansion pos ) <nl> - | Tanon _ <nl> | Tobject <nl> | Tnonnull <nl> | Tprim _ <nl> mmm a / hphp / hack / src / typing / typing_union . ml <nl> ppp b / hphp / hack / src / typing / typing_union . ml <nl> and simplify_union_ env ty1 ty2 r = <nl> | ( ( _ , Tfun ft1 ) , ( _ , Tfun ft2 ) ) - > <nl> let ( env , ft ) = union_funs env ft1 ft2 in <nl> ( env , Some ( mk ( r , Tfun ft ) ) ) <nl> - | ( ( _ , Tanon ( _ , id1 ) ) , ( _ , Tanon ( _ , id2 ) ) ) when Ident . equal id1 id2 - > <nl> - ( env , Some ty1 ) <nl> ( * TODO with Tclass , union type arguments if covariant * ) <nl> | ( ( _ , <nl> ( ( Tarraykind _ | Tprim _ | Tdynamic | Tgeneric _ | Tnewtype _ <nl> - | Tdependent _ | Tclass _ | Ttuple _ | Tanon _ | Tfun _ | Tobject <nl> - | Tshape _ | Terr <nl> + | Tdependent _ | Tclass _ | Ttuple _ | Tfun _ | Tobject | Tshape _ <nl> + | Terr <nl> | Tvar _ <nl> ( * If T cannot be null , ` union T nonnull = nonnull ` . However , it ' s hard <nl> * to say whether a given T can be null - e . g . opaque newtypes , dependent <nl> mmm a / hphp / hack / src / typing / typing_utils . ml <nl> ppp b / hphp / hack / src / typing / typing_utils . ml <nl> let rec class_get_pu_ env cty name = <nl> | Tprim _ <nl> | Tfun _ <nl> | Ttuple _ <nl> - | Tanon ( _ , _ ) <nl> | Tobject <nl> | Tshape _ - > <nl> ( env , None ) <nl> mmm a / hphp / hack / src / typing / typing_xhp . ml <nl> ppp b / hphp / hack / src / typing / typing_xhp . ml <nl> let rec walk_and_gather_xhp_ ~ env ~ pos cty = <nl> | Tvar _ <nl> | Tfun _ <nl> | Ttuple _ <nl> - | Tanon ( _ , _ ) <nl> | Tobject <nl> | Tshape _ - > <nl> ( env , [ ] , [ cty ] ) <nl> mmm a / hphp / hack / test / dumpsymbolinfo / dune <nl> ppp b / hphp / hack / test / dumpsymbolinfo / dune <nl> <nl> ( glob_files % { project_root } / test / dumpsymbolinfo / * . php ) <nl> ( glob_files % { project_root } / test / dumpsymbolinfo / * . exp ) ) <nl> ( action ( run % { project_root } / test / verify . py % { project_root } / test / dumpsymbolinfo <nl> - - - program % { exe : . . / . . / src / hh_single_type_check . exe } <nl> - - - flags - - new - inference - lambda ) ) ) <nl> + - - program % { exe : . . / . . / src / hh_single_type_check . exe } ) ) ) <nl> <nl> ( alias <nl> ( name runtest ) <nl> mmm a / hphp / hack / test / dynamic_view / dune <nl> ppp b / hphp / hack / test / dynamic_view / dune <nl> <nl> ( glob_files % { project_root } / test / dynamic_view / HH_FLAGS ) ) <nl> ( action ( run % { project_root } / test / verify . py % { project_root } / test / dynamic_view <nl> - - program % { exe : . . / . . / src / hh_single_type_check . exe } <nl> - - - flags - - new - inference - lambda <nl> + - - flags <nl> - - error - format raw ) ) ) <nl> <nl> ( alias <nl> mmm a / hphp / hack / test / errors / error_map . ml <nl> ppp b / hphp / hack / test / errors / error_map . ml <nl> PhpLambdaDisallowed = 3084 <nl> Typing Errors : <nl> AbstractClassFinalDEPRECATED = 4001 <nl> UninstantiableClass = 4002 <nl> - AnonymousRecursive = 4003 <nl> - AnonymousRecursiveCall = 4004 <nl> + AnonymousRecursiveDEPRECATED = 4003 <nl> + AnonymousRecursiveCallDEPRECATED = 4004 <nl> ArrayAccess = 4005 <nl> ArrayAppend = 4006 <nl> ArrayCast = 4007 <nl> mmm a / hphp / hack / test / integration_ml / test_infer_type . ml <nl> ppp b / hphp / hack / test / integration_ml / test_infer_type . ml <nl> let loop_assignment_cases = <nl> ( ( " loop_assignment . php " , 14 , 9 ) , " ( int | string ) " ) ; <nl> ] <nl> <nl> - let lambda1 = <nl> - " < ? hh / / strict <nl> - function test_lambda1 ( ) : void { <nl> - $ s = ' foo ' ; <nl> - $ f = $ n = = > { return $ n . $ s . ' \ \ n ' ; } ; <nl> - / / ^ 4 : 3 ^ 4 : 29 <nl> - $ x = $ f ( 4 ) ; <nl> - / / ^ 6 : 3 ^ 6 : 8 <nl> - $ y = $ f ( ' bar ' ) ; <nl> - / / ^ 8 : 3 ^ 8 : 11 <nl> - } <nl> - " <nl> - <nl> - let lambda_cases = <nl> - [ <nl> - ( ( " lambda1 . php " , 4 , 3 ) , " [ fun ] " ) ; <nl> - ( ( " lambda1 . php " , 4 , 29 ) , " string " ) ; <nl> - ( ( " lambda1 . php " , 6 , 3 ) , " string " ) ; <nl> - ( ( " lambda1 . php " , 6 , 8 ) , " [ fun ] " ) ; <nl> - ( ( " lambda1 . php " , 6 , 11 ) , " int " ) ; <nl> - ( ( " lambda1 . php " , 8 , 3 ) , " string " ) ; <nl> - ( ( " lambda1 . php " , 8 , 8 ) , " [ fun ] " ) ; <nl> - ( ( " lambda1 . php " , 8 , 11 ) , " string " ) ; <nl> - ] <nl> - <nl> let callback = <nl> " < ? hh / / strict <nl> function test_callback ( ( function ( int ) : string ) $ cb ) : void { <nl> function lambda_param ( ) : void { <nl> <nl> let lambda_param_cases = <nl> [ <nl> - ( ( " lambda_param . php " , 4 , 9 ) , " _ " ) ; <nl> + ( ( " lambda_param . php " , 4 , 9 ) , " mixed " ) ; <nl> ( ( " lambda_param . php " , 6 , 14 ) , " int " ) ; <nl> - ( ( " lambda_param . php " , 4 , 12 ) , " [ fun ] " ) ; <nl> + ( ( " lambda_param . php " , 4 , 12 ) , " ( function ( mixed $ s ) : int ) " ) ; <nl> ( ( " lambda_param . php " , 6 , 17 ) , " ( function ( int $ x ) : num ) " ) ; <nl> ] <nl> <nl> let files = <nl> ( " MyPair . php " , mypair ) ; <nl> ( " test_mypair . php " , test_mypair ) ; <nl> ( " loop_assignment . php " , loop_assignment ) ; <nl> - ( " lambda1 . php " , lambda1 ) ; <nl> ( " callback . php " , callback ) ; <nl> ( " nullthrows . php " , nullthrows ) ; <nl> ( " nullvec . php " , nullvec ) ; <nl> let cases = <nl> @ class_A_cases <nl> @ test_mypair_cases <nl> @ loop_assignment_cases <nl> - @ lambda_cases <nl> @ callback_cases <nl> @ nullthrows_cases <nl> @ nullvec_cases <nl> mmm a / hphp / hack / test / tast / dune <nl> ppp b / hphp / hack / test / tast / dune <nl> <nl> ( glob_files % { project_root } / test / tast / xhp_modifier / * . php ) <nl> ( glob_files % { project_root } / test / tast / xhp_modifier / * . exp ) ) <nl> ( action ( run % { project_root } / test / verify . py % { project_root } / test / tast <nl> - - - program % { exe : . . / . . / src / hh_single_type_check . exe } <nl> - - - flags - - new - inference - lambda ) ) ) <nl> + - - program % { exe : . . / . . / src / hh_single_type_check . exe } ) ) ) <nl> <nl> ( alias <nl> ( name runtest ) <nl> mmm a / hphp / hack / test / typecheck / HH_FLAGS <nl> ppp b / hphp / hack / test / typecheck / HH_FLAGS <nl> <nl> - - max - errors 1 <nl> - - disallow - discarded - nullable - awaitables <nl> mmmnew - inference - lambda <nl> mmm a / hphp / hack / test / typecheck / control_flow / HH_FLAGS <nl> ppp b / hphp / hack / test / typecheck / control_flow / HH_FLAGS <nl> @ @ - 1 + 0 , 0 @ @ <nl> mmmnew - inference - lambda <nl> mmm a / hphp / hack / test / typecheck / inout / HH_FLAGS <nl> ppp b / hphp / hack / test / typecheck / inout / HH_FLAGS <nl> @ @ - 1 + 0 , 0 @ @ <nl> mmmnew - inference - lambda <nl> mmm a / hphp / hack / test / typecheck / lambda / HH_FLAGS <nl> ppp b / hphp / hack / test / typecheck / lambda / HH_FLAGS <nl> @ @ - 1 + 0 , 0 @ @ <nl> mmmnew - inference - lambda <nl> similarity index 100 % <nl> rename from hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_ambiguous . php <nl> rename to hphp / hack / test / typecheck / lambda / lambda_ambiguous . php <nl> similarity index 100 % <nl> rename from hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_ambiguous . php . exp <nl> rename to hphp / hack / test / typecheck / lambda / lambda_ambiguous . php . exp <nl> similarity index 100 % <nl> rename from hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_ambiguous . php . legacy . exp <nl> rename to hphp / hack / test / typecheck / lambda / lambda_ambiguous . php . legacy . exp <nl> similarity index 100 % <nl> rename from hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_as_param . php <nl> rename to hphp / hack / test / typecheck / lambda / lambda_as_param . php <nl> similarity index 100 % <nl> rename from hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_as_param . php . exp <nl> rename to hphp / hack / test / typecheck / lambda / lambda_as_param . php . exp <nl> similarity index 100 % <nl> rename from hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_as_param . php . legacy . exp <nl> rename to hphp / hack / test / typecheck / lambda / lambda_as_param . php . legacy . exp <nl> mmm a / hphp / hack / test / typecheck / lambda / lambda_contextual / HH_FLAGS <nl> ppp b / hphp / hack / test / typecheck / lambda / lambda_contextual / HH_FLAGS <nl> @ @ - 1 + 0 , 0 @ @ <nl> mmmdisallow - ambiguous - lambda <nl> deleted file mode 100644 <nl> index e69de29bb2d . . 00000000000 <nl> deleted file mode 100644 <nl> index 94977e3395b . . 00000000000 <nl> mmm a / hphp / hack / test / typecheck / lambda / lambda_legacy / bad_pos_bug . php <nl> ppp / dev / null <nl> <nl> - / / / / file1 . php <nl> - < ? hh <nl> - / / Copyright ( c ) Facebook , Inc . and its affiliates . All Rights Reserved . <nl> - <nl> - interface I { } <nl> - class C { } <nl> - interface J { } <nl> - function foo ( <nl> - ) : void { <nl> - $ p = ( / * I * / $ _vc , C $ x ) = = > { } ; <nl> - $ ret = Map { <nl> - ' A ' = > <nl> - bar ( dict [ ' B ' = > 0 ] ) , <nl> - ' C ' = > $ p , <nl> - } ; <nl> - } <nl> - <nl> - / / / / file2 . php <nl> - < ? hh <nl> - function bar <nl> - < T2 as I , T as J > ( <nl> - dict < string , mixed > $ a <nl> - ) : ( function ( T2 , T ) : Awaitable < void > ) { <nl> - throw new Exception ( " A " ) ; <nl> - } <nl> deleted file mode 100644 <nl> index aa5a46658d1 . . 00000000000 <nl> mmm a / hphp / hack / test / typecheck / lambda / lambda_legacy / bad_pos_bug . php . exp <nl> ppp / dev / null <nl> <nl> - File " bad_pos_bug . php - - file1 . php " , line 9 , characters 22 - 22 : <nl> - Invalid argument ( Typing [ 4323 ] ) <nl> - File " bad_pos_bug . php - - file2 . php " , line 3 , characters 18 - 18 : <nl> - Some type constraint ( s ) are violated here <nl> - File " bad_pos_bug . php - - file2 . php " , line 3 , characters 13 - 13 : <nl> - T is a constrained type parameter <nl> - File " bad_pos_bug . php - - file1 . php " , line 9 , characters 22 - 22 : <nl> - Expected C <nl> - File " bad_pos_bug . php - - file2 . php " , line 3 , characters 18 - 18 : <nl> - But got J <nl> deleted file mode 100644 <nl> index 41101a904a2 . . 00000000000 <nl> mmm a / hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_two_uses . php <nl> ppp / dev / null <nl> <nl> - < ? hh / / strict <nl> - / / Copyright 2004 - present Facebook . All Rights Reserved . <nl> - <nl> - class C { <nl> - public function foo ( ) : int { <nl> - return 3 ; <nl> - } <nl> - } <nl> - class D { <nl> - public function foo ( ) : float { <nl> - return 3 . 2 ; <nl> - } <nl> - } <nl> - function test_two_uses ( ) : void { <nl> - $ f = $ x = = > $ x - > foo ( ) + 1 ; <nl> - $ a = $ f ( new C ( ) ) ; <nl> - $ b = $ f ( new D ( ) ) ; <nl> - $ c = $ f ( new C ( ) ) ; <nl> - } <nl> deleted file mode 100644 <nl> index 4269126fceb . . 00000000000 <nl> mmm a / hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_two_uses . php . exp <nl> ppp / dev / null <nl> @ @ - 1 + 0 , 0 @ @ <nl> - No errors <nl> deleted file mode 100644 <nl> index 99ed792a010 . . 00000000000 <nl> mmm a / hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_two_uses . php . legacy . exp <nl> ppp / dev / null <nl> <nl> - File " lambda_two_uses . php " , line 15 , characters 8 - 27 : <nl> - Lambda has parameter types that could not be determined at definition site . ( Typing [ 4222 ] ) <nl> - File " lambda_two_uses . php " , line 15 , characters 8 - 27 : <nl> - 2 distinct use types were determined : please add type hints to lambda parameters . <nl> - File " lambda_two_uses . php " , line 17 , characters 8 - 18 : <nl> - This use has type ( function ( D ) : float ) <nl> - File " lambda_two_uses . php " , line 18 , characters 8 - 18 : <nl> - This use has type ( function ( C ) : int ) <nl> similarity index 100 % <nl> rename from hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_tany . php <nl> rename to hphp / hack / test / typecheck / lambda / lambda_tany . php <nl> similarity index 100 % <nl> rename from hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_tany . php . exp <nl> rename to hphp / hack / test / typecheck / lambda / lambda_tany . php . exp <nl> similarity index 100 % <nl> rename from hphp / hack / test / typecheck / lambda / lambda_legacy / lambda_tany . php . legacy . exp <nl> rename to hphp / hack / test / typecheck / lambda / lambda_tany . php . legacy . exp <nl> mmm a / hphp / hack / test / typecheck / lambda / variadics / HH_FLAGS <nl> ppp b / hphp / hack / test / typecheck / lambda / variadics / HH_FLAGS <nl> @ @ - 1 + 0 , 0 @ @ <nl> mmmnew - inference - lambda <nl> mmm a / hphp / hack / test / typecheck / new_inference / HH_FLAGS <nl> ppp b / hphp / hack / test / typecheck / new_inference / HH_FLAGS <nl> <nl> - - disallow - invalid - arraykey <nl> - - hh - log - level prop 1 <nl> mmmnew - inference - lambda <nl> mmm a / hphp / hack / test / typecheck / splat / HH_FLAGS <nl> ppp b / hphp / hack / test / typecheck / splat / HH_FLAGS <nl> @ @ - 1 + 0 , 0 @ @ <nl> mmmnew - inference - lambda <nl>
Enable new_inference_lambda by default , remove all logic for Tanon
facebook/hhvm
81d3d4d9601bcbcbdfbd35e2cc14b95391f46cf9
2020-02-12T14:20:54Z
mmm a / caffe2 / operators / roi_align_rotated_op . cc <nl> ppp b / caffe2 / operators / roi_align_rotated_op . cc <nl> C10_EXPORT_CAFFE2_OP_TO_C10_CPU ( <nl> " bool aligned " <nl> " ) - > Tensor " , <nl> RoIAlignRotatedOpFloatCPU ) ; <nl> + <nl> + C10_EXPORT_CAFFE2_OP_TO_C10_CPU ( <nl> + RoIAlignRotated2 , <nl> + " __caffe2 : : RoIAlignRotated ( " <nl> + " Tensor features , " <nl> + " Tensor rois , " <nl> + " str order , " <nl> + " float spatial_scale , " <nl> + " int pooled_h , " <nl> + " int pooled_w , " <nl> + " int sampling_ratio , " <nl> + " bool aligned " <nl> + " ) - > Tensor " , <nl> + RoIAlignRotatedOpFloatCPU ) ; <nl> / / clang - format on <nl>
[ 7 ] add missing roi_align_rotated op to lite interpreter ( )
pytorch/pytorch
2d023fe6a7a6c849b6992bfe80157d161201f828
2020-03-27T14:26:02Z
mmm a / tests / tests / MotionStreakTest / MotionStreakTest . cpp <nl> ppp b / tests / tests / MotionStreakTest / MotionStreakTest . cpp <nl> void MotionStreakTest1 : : onEnter ( ) <nl> CCActionInterval * motion = CCMoveBy : : actionWithDuration ( 2 , CCPointMake ( 100 , 0 ) ) ; <nl> m_root - > runAction ( CCRepeatForever : : actionWithAction ( ( CCActionInterval * ) ( CCSequence : : actions ( motion , motion - > reverse ( ) , NULL ) ) ) ) ; <nl> m_root - > runAction ( action1 ) ; <nl> + <nl> + CCActionInterval * colorAction = CCRepeatForever : : actionWithAction ( ( CCActionInterval * ) CCSequence : : actions ( <nl> + CCTintTo : : actionWithDuration ( 0 . 2f , 255 , 0 , 0 ) , <nl> + CCTintTo : : actionWithDuration ( 0 . 2f , 0 , 255 , 0 ) , <nl> + CCTintTo : : actionWithDuration ( 0 . 2f , 0 , 0 , 255 ) , <nl> + CCTintTo : : actionWithDuration ( 0 . 2f , 0 , 255 , 255 ) , <nl> + CCTintTo : : actionWithDuration ( 0 . 2f , 255 , 255 , 0 ) , <nl> + CCTintTo : : actionWithDuration ( 0 . 2f , 255 , 0 , 255 ) , <nl> + CCTintTo : : actionWithDuration ( 0 . 2f , 255 , 255 , 255 ) , <nl> + NULL ) ) ; <nl> + <nl> + m_streak - > runAction ( colorAction ) ; <nl> + <nl> + / / weak ref <nl> + streak = m_streak ; <nl> } <nl> <nl> void MotionStreakTest1 : : onUpdate ( ccTime delta ) <nl> void MotionStreakTest2 : : onEnter ( ) <nl> addChild ( m_streak ) ; <nl> <nl> m_streak - > setPosition ( CCPointMake ( s . width / 2 , s . height / 2 ) ) ; <nl> + <nl> + / / weak ref <nl> + streak = m_streak ; <nl> } <nl> <nl> void MotionStreakTest2 : : ccTouchesMoved ( CCSet * touches , CCEvent * event ) <nl> void MotionStreakTest : : onEnter ( ) <nl> item3 - > setPosition ( CCPointMake ( s . width / 2 + 100 , 30 ) ) ; <nl> <nl> addChild ( menu , 1 ) ; <nl> + <nl> + CCMenuItemToggle * itemMode = CCMenuItemToggle : : itemWithTarget ( this , menu_selector ( MotionStreakTest : : modeCallback ) , <nl> + CCMenuItemFont : : itemWithString ( " Fast " ) , <nl> + CCMenuItemFont : : itemWithString ( " Slow " ) , <nl> + NULL ) ; <nl> + <nl> + CCMenu * menuMode = CCMenu : : menuWithItems ( itemMode , NULL ) ; <nl> + addChild ( menuMode ) ; <nl> + <nl> + menuMode - > setPosition ( ccp ( 30 , 65 ) ) ; <nl> + } <nl> + <nl> + void MotionStreakTest : : modeCallback ( CCObject * pSender ) <nl> + { <nl> + bool fastMode = streak - > getIsFastMode ( ) ; <nl> + streak - > setIsFastMode ( ! fastMode ) ; <nl> } <nl> <nl> void MotionStreakTest : : restartCallback ( CCObject * pSender ) <nl> mmm a / tests / tests / MotionStreakTest / MotionStreakTest . h <nl> ppp b / tests / tests / MotionStreakTest / MotionStreakTest . h <nl> class MotionStreakTest : public CCLayer <nl> void restartCallback ( CCObject * pSender ) ; <nl> void nextCallback ( CCObject * pSender ) ; <nl> void backCallback ( CCObject * pSender ) ; <nl> + void modeCallback ( CCObject * pSender ) ; <nl> + protected : <nl> + CCMotionStreak * streak ; <nl> } ; <nl> <nl> class MotionStreakTest1 : public MotionStreakTest <nl>
issue : MotionStreakTest
cocos2d/cocos2d-x
6b7716770e16fbc20b732b1bd63ac869f78e575c
2012-03-22T06:32:32Z
mmm a / xbmc / peripherals / devices / PeripheralCecAdapter . cpp <nl> ppp b / xbmc / peripherals / devices / PeripheralCecAdapter . cpp <nl> void CPeripheralCecAdapter : : OnTvStandby ( void ) <nl> case LOCALISED_ID_STOP : <nl> KODI : : MESSAGING : : CApplicationMessenger : : GetInstance ( ) . PostMsg ( TMSG_MEDIA_STOP ) ; <nl> break ; <nl> + case LOCALISED_ID_IGNORE : <nl> + break ; <nl> default : <nl> CLog : : Log ( LOGERROR , " % s - Unexpected [ standby_pc_on_tv_standby ] setting value " , __FUNCTION__ ) ; <nl> break ; <nl>
Fixed error " Unexpected [ standby_pc_on_tv_standby ] setting value
xbmc/xbmc
fdc004c8e7ad1669b3b83746c30bd4448d2950a9
2019-03-10T10:00:18Z
mmm a / Makefile <nl> ppp b / Makefile <nl> CXX = $ ( CXX_ $ ( CONFIG ) ) <nl> LD = $ ( LD_ $ ( CONFIG ) ) <nl> LDXX = $ ( LDXX_ $ ( CONFIG ) ) <nl> AR = ar <nl> + ifeq ( $ ( SYSTEM ) , Linux ) <nl> STRIP = strip - - strip - unneeded <nl> + else <nl> + ifeq ( $ ( SYSTEM ) , Darwin ) <nl> + STRIP = strip - x <nl> + else <nl> + STRIP = strip <nl> + endif <nl> + endif <nl> INSTALL = install <nl> RM = rm - f <nl> <nl> mmm a / templates / Makefile . template <nl> ppp b / templates / Makefile . template <nl> CXX = $ ( CXX_ $ ( CONFIG ) ) <nl> LD = $ ( LD_ $ ( CONFIG ) ) <nl> LDXX = $ ( LDXX_ $ ( CONFIG ) ) <nl> AR = ar <nl> + ifeq ( $ ( SYSTEM ) , Linux ) <nl> STRIP = strip - - strip - unneeded <nl> + else <nl> + ifeq ( $ ( SYSTEM ) , Darwin ) <nl> + STRIP = strip - x <nl> + else <nl> + STRIP = strip <nl> + endif <nl> + endif <nl> INSTALL = install <nl> RM = rm - f <nl> <nl>
Merge pull request from nicolasnoble / macos - make - install
grpc/grpc
3a718b2cd9bd6496328fbedcafc514db689eecc9
2015-02-27T07:08:10Z
mmm a / tensorflow / python / kernel_tests / extract_image_patches_grad_test . py <nl> ppp b / tensorflow / python / kernel_tests / extract_image_patches_grad_test . py <nl> def testGradient ( self ) : <nl> <nl> err = gradient_checker . compute_gradient_error ( in_val , in_shape , <nl> out_val , out_shape ) <nl> - <nl> - print ( ' extract_image_patches gradient err : % . 4e ' % err ) <nl> self . assertLess ( err , 1e - 4 ) <nl> <nl> @ test_util . run_deprecated_v1 <nl> def _VariableShapeGradient ( self , test_shape_pattern ) : <nl> <nl> err = gradient_checker . compute_gradient_error ( in_val , in_shape , <nl> out_val , out_shape ) <nl> - <nl> - print ( ' extract_image_patches gradient err : % . 4e ' % err ) <nl> self . assertLess ( err , 1e - 4 ) <nl> <nl> @ test_util . run_deprecated_v1 <nl>
Remove debug print from unit test
tensorflow/tensorflow
5b587208fa1f293d69d3694301691ab4c49d217c
2019-06-18T22:37:03Z
mmm a / setup . py <nl> ppp b / setup . py <nl> <nl> elif ' win32 ' in sys . platform : <nl> EXTRA_ENV_COMPILE_ARGS + = ' - D_PYTHON_MSVC ' <nl> elif " linux " in sys . platform : <nl> - EXTRA_ENV_COMPILE_ARGS + = ' - std = c + + 11 - fvisibility = hidden - fno - wrapv ' <nl> + EXTRA_ENV_COMPILE_ARGS + = ' - std = c + + 11 - std = gnu99 - fvisibility = hidden - fno - wrapv ' <nl> elif " darwin " in sys . platform : <nl> EXTRA_ENV_COMPILE_ARGS + = ' - fvisibility = hidden - fno - wrapv ' <nl> <nl> mmm a / src / boringssl / gen_build_yaml . py <nl> ppp b / src / boringssl / gen_build_yaml . py <nl> def WriteFiles ( self , files , asm_outputs ) : <nl> { <nl> ' name ' : ' boringssl_ % s ' % os . path . basename ( test [ 0 ] ) , <nl> ' args ' : [ map_testarg ( arg ) for arg in test [ 1 : ] ] , <nl> - ' exclude_configs ' : [ ' asan ' ] , <nl> + ' exclude_configs ' : [ ' asan ' , ' ubsan ' ] , <nl> ' ci_platforms ' : [ ' linux ' , ' mac ' , ' posix ' , ' windows ' ] , <nl> ' platforms ' : [ ' linux ' , ' mac ' , ' posix ' , ' windows ' ] , <nl> ' flaky ' : False , <nl> mmm a / src / core / ext / transport / chttp2 / transport / chttp2_transport . c <nl> ppp b / src / core / ext / transport / chttp2 / transport / chttp2_transport . c <nl> static void incoming_byte_stream_update_flow_control ( grpc_exec_ctx * exec_ctx , <nl> add_max_recv_bytes ) ; <nl> if ( ( int64_t ) s - > incoming_window_delta + ( int64_t ) initial_window_size - <nl> ( int64_t ) s - > announce_window > <nl> - 2 * ( int64_t ) initial_window_size ) { <nl> + ( int64_t ) initial_window_size / 2 ) { <nl> write_type = GRPC_CHTTP2_STREAM_WRITE_PIGGYBACK ; <nl> } <nl> grpc_chttp2_become_writable ( exec_ctx , t , s , write_type , <nl> mmm a / src / core / ext / transport / chttp2 / transport / parsing . c <nl> ppp b / src / core / ext / transport / chttp2 / transport / parsing . c <nl> static grpc_error * update_incoming_window ( grpc_exec_ctx * exec_ctx , <nl> <nl> GRPC_CHTTP2_FLOW_DEBIT_STREAM_INCOMING_WINDOW_DELTA ( " parse " , t , s , <nl> incoming_frame_size ) ; <nl> - if ( ( int64_t ) s - > incoming_window_delta - ( int64_t ) s - > announce_window < = 0 ) { <nl> + if ( ( int64_t ) s - > incoming_window_delta - ( int64_t ) s - > announce_window < = <nl> + - ( int64_t ) t - > settings [ GRPC_SENT_SETTINGS ] <nl> + [ GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE ] / <nl> + 2 ) { <nl> grpc_chttp2_become_writable ( exec_ctx , t , s , <nl> GRPC_CHTTP2_STREAM_WRITE_INITIATE_UNCOVERED , <nl> " window - update - required " ) ; <nl> mmm a / src / python / grpcio / commands . py <nl> ppp b / src / python / grpcio / commands . py <nl> def build_extensions ( self ) : <nl> stderr = subprocess . PIPE ) <nl> make_out , make_err = make_process . communicate ( ) <nl> if make_out and make_process . returncode ! = 0 : <nl> - sys . stdout . write ( make_out + ' \ n ' ) <nl> + sys . stdout . write ( str ( make_out ) + ' \ n ' ) <nl> if make_err : <nl> - sys . stderr . write ( make_err + ' \ n ' ) <nl> + sys . stderr . write ( str ( make_err ) + ' \ n ' ) <nl> if make_process . returncode ! = 0 : <nl> raise Exception ( " make command failed ! " ) <nl> <nl> mmm a / test / core / end2end / cq_verifier . c <nl> ppp b / test / core / end2end / cq_verifier . c <nl> struct cq_verifier { <nl> } ; <nl> <nl> cq_verifier * cq_verifier_create ( grpc_completion_queue * cq ) { <nl> - cq_verifier * v = gpr_malloc ( sizeof ( cq_verifier ) ) ; <nl> + cq_verifier * v = ( cq_verifier * ) gpr_malloc ( sizeof ( cq_verifier ) ) ; <nl> v - > cq = cq ; <nl> v - > first_expectation = NULL ; <nl> return v ; <nl> void cq_verify_empty ( cq_verifier * v ) { cq_verify_empty_timeout ( v , 1 ) ; } <nl> <nl> static void add ( cq_verifier * v , const char * file , int line , <nl> grpc_completion_type type , void * tag , bool success ) { <nl> - expectation * e = gpr_malloc ( sizeof ( expectation ) ) ; <nl> + expectation * e = ( expectation * ) gpr_malloc ( sizeof ( expectation ) ) ; <nl> e - > type = type ; <nl> e - > file = file ; <nl> e - > line = line ; <nl> mmm a / test / core / end2end / fake_resolver . c <nl> ppp b / test / core / end2end / fake_resolver . c <nl> struct grpc_fake_resolver_response_generator { <nl> grpc_fake_resolver_response_generator * <nl> grpc_fake_resolver_response_generator_create ( ) { <nl> grpc_fake_resolver_response_generator * generator = <nl> - gpr_zalloc ( sizeof ( * generator ) ) ; <nl> + ( grpc_fake_resolver_response_generator * ) gpr_zalloc ( sizeof ( * generator ) ) ; <nl> gpr_ref_init ( & generator - > refcount , 1 ) ; <nl> return generator ; <nl> } <nl> void grpc_fake_resolver_response_generator_unref ( <nl> <nl> static void set_response_cb ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> - grpc_fake_resolver_response_generator * generator = arg ; <nl> + grpc_fake_resolver_response_generator * generator = <nl> + ( grpc_fake_resolver_response_generator * ) arg ; <nl> fake_resolver * r = generator - > resolver ; <nl> if ( r - > next_results ! = NULL ) { <nl> grpc_channel_args_destroy ( exec_ctx , r - > next_results ) ; <nl> void grpc_fake_resolver_response_generator_set_response ( <nl> } <nl> <nl> static void * response_generator_arg_copy ( void * p ) { <nl> - return grpc_fake_resolver_response_generator_ref ( p ) ; <nl> + return grpc_fake_resolver_response_generator_ref ( <nl> + ( grpc_fake_resolver_response_generator * ) p ) ; <nl> } <nl> <nl> static void response_generator_arg_destroy ( grpc_exec_ctx * exec_ctx , void * p ) { <nl> - grpc_fake_resolver_response_generator_unref ( p ) ; <nl> + grpc_fake_resolver_response_generator_unref ( <nl> + ( grpc_fake_resolver_response_generator * ) p ) ; <nl> } <nl> <nl> static int response_generator_cmp ( void * a , void * b ) { return GPR_ICMP ( a , b ) ; } <nl> grpc_fake_resolver_get_response_generator ( const grpc_channel_args * args ) { <nl> const grpc_arg * arg = <nl> grpc_channel_args_find ( args , GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR ) ; <nl> if ( arg = = NULL | | arg - > type ! = GRPC_ARG_POINTER ) return NULL ; <nl> - return arg - > value . pointer . p ; <nl> + return ( grpc_fake_resolver_response_generator * ) arg - > value . pointer . p ; <nl> } <nl> <nl> / / <nl> static void fake_resolver_factory_unref ( grpc_resolver_factory * factory ) { } <nl> static grpc_resolver * fake_resolver_create ( grpc_exec_ctx * exec_ctx , <nl> grpc_resolver_factory * factory , <nl> grpc_resolver_args * args ) { <nl> - fake_resolver * r = gpr_zalloc ( sizeof ( * r ) ) ; <nl> + fake_resolver * r = ( fake_resolver * ) gpr_zalloc ( sizeof ( * r ) ) ; <nl> r - > channel_args = grpc_channel_args_copy ( args - > args ) ; <nl> grpc_resolver_init ( & r - > base , & fake_resolver_vtable , args - > combiner ) ; <nl> grpc_fake_resolver_response_generator * response_generator = <nl> mmm a / test / core / end2end / fixtures / http_proxy_fixture . c <nl> ppp b / test / core / end2end / fixtures / http_proxy_fixture . c <nl> static void proxy_connection_failed ( grpc_exec_ctx * exec_ctx , <nl> / / Callback for writing proxy data to the client . <nl> static void on_client_write_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> - proxy_connection * conn = arg ; <nl> + proxy_connection * conn = ( proxy_connection * ) arg ; <nl> if ( error ! = GRPC_ERROR_NONE ) { <nl> proxy_connection_failed ( exec_ctx , conn , true / * is_client * / , <nl> " HTTP proxy client write " , error ) ; <nl> static void on_client_write_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> / / Callback for writing proxy data to the backend server . <nl> static void on_server_write_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> - proxy_connection * conn = arg ; <nl> + proxy_connection * conn = ( proxy_connection * ) arg ; <nl> if ( error ! = GRPC_ERROR_NONE ) { <nl> proxy_connection_failed ( exec_ctx , conn , false / * is_client * / , <nl> " HTTP proxy server write " , error ) ; <nl> static void on_server_write_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> / / the backend server . <nl> static void on_client_read_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> - proxy_connection * conn = arg ; <nl> + proxy_connection * conn = ( proxy_connection * ) arg ; <nl> if ( error ! = GRPC_ERROR_NONE ) { <nl> proxy_connection_failed ( exec_ctx , conn , true / * is_client * / , <nl> " HTTP proxy client read " , error ) ; <nl> static void on_client_read_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> / / proxied to the client . <nl> static void on_server_read_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> - proxy_connection * conn = arg ; <nl> + proxy_connection * conn = ( proxy_connection * ) arg ; <nl> if ( error ! = GRPC_ERROR_NONE ) { <nl> proxy_connection_failed ( exec_ctx , conn , false / * is_client * / , <nl> " HTTP proxy server read " , error ) ; <nl> static void on_server_read_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> / / Callback to write the HTTP response for the CONNECT request . <nl> static void on_write_response_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> - proxy_connection * conn = arg ; <nl> + proxy_connection * conn = ( proxy_connection * ) arg ; <nl> if ( error ! = GRPC_ERROR_NONE ) { <nl> proxy_connection_failed ( exec_ctx , conn , true / * is_client * / , <nl> " HTTP proxy write response " , error ) ; <nl> static void on_write_response_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> / / CONNECT request . <nl> static void on_server_connect_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> - proxy_connection * conn = arg ; <nl> + proxy_connection * conn = ( proxy_connection * ) arg ; <nl> if ( error ! = GRPC_ERROR_NONE ) { <nl> / / TODO ( roth ) : Technically , in this case , we should handle the error <nl> / / by returning an HTTP response to the client indicating that the <nl> static void on_server_connect_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> / / which will cause the client connection to be dropped . <nl> static void on_read_request_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> - proxy_connection * conn = arg ; <nl> + proxy_connection * conn = ( proxy_connection * ) arg ; <nl> gpr_log ( GPR_DEBUG , " on_read_request_done : % p % s " , conn , <nl> grpc_error_string ( error ) ) ; <nl> if ( error ! = GRPC_ERROR_NONE ) { <nl> static void on_accept ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_endpoint * endpoint , grpc_pollset * accepting_pollset , <nl> grpc_tcp_server_acceptor * acceptor ) { <nl> gpr_free ( acceptor ) ; <nl> - grpc_end2end_http_proxy * proxy = arg ; <nl> + grpc_end2end_http_proxy * proxy = ( grpc_end2end_http_proxy * ) arg ; <nl> / / Instantiate proxy_connection . <nl> - proxy_connection * conn = gpr_zalloc ( sizeof ( * conn ) ) ; <nl> + proxy_connection * conn = ( proxy_connection * ) gpr_zalloc ( sizeof ( * conn ) ) ; <nl> gpr_ref ( & proxy - > users ) ; <nl> conn - > client_endpoint = endpoint ; <nl> conn - > proxy = proxy ; <nl> static void on_accept ( grpc_exec_ctx * exec_ctx , void * arg , <nl> / / <nl> <nl> static void thread_main ( void * arg ) { <nl> - grpc_end2end_http_proxy * proxy = arg ; <nl> + grpc_end2end_http_proxy * proxy = ( grpc_end2end_http_proxy * ) arg ; <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> do { <nl> gpr_ref ( & proxy - > users ) ; <nl> static void thread_main ( void * arg ) { <nl> <nl> grpc_end2end_http_proxy * grpc_end2end_http_proxy_create ( void ) { <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> - grpc_end2end_http_proxy * proxy = gpr_malloc ( sizeof ( * proxy ) ) ; <nl> + grpc_end2end_http_proxy * proxy = <nl> + ( grpc_end2end_http_proxy * ) gpr_malloc ( sizeof ( * proxy ) ) ; <nl> memset ( proxy , 0 , sizeof ( * proxy ) ) ; <nl> gpr_ref_init ( & proxy - > users , 1 ) ; <nl> / / Construct proxy address . <nl> grpc_end2end_http_proxy * grpc_end2end_http_proxy_create ( void ) { <nl> GPR_ASSERT ( error = = GRPC_ERROR_NONE ) ; <nl> GPR_ASSERT ( port = = proxy_port ) ; <nl> / / Start server . <nl> - proxy - > pollset = gpr_zalloc ( grpc_pollset_size ( ) ) ; <nl> + proxy - > pollset = ( grpc_pollset * ) gpr_zalloc ( grpc_pollset_size ( ) ) ; <nl> grpc_pollset_init ( proxy - > pollset , & proxy - > mu ) ; <nl> grpc_tcp_server_start ( & exec_ctx , proxy - > server , & proxy - > pollset , 1 , on_accept , <nl> proxy ) ; <nl> grpc_end2end_http_proxy * grpc_end2end_http_proxy_create ( void ) { <nl> <nl> static void destroy_pollset ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> - grpc_pollset * pollset = arg ; <nl> + grpc_pollset * pollset = ( grpc_pollset * ) arg ; <nl> grpc_pollset_destroy ( pollset ) ; <nl> gpr_free ( pollset ) ; <nl> } <nl> mmm a / test / core / security / oauth2_utils . c <nl> ppp b / test / core / security / oauth2_utils . c <nl> static void on_oauth2_response ( grpc_exec_ctx * exec_ctx , void * user_data , <nl> grpc_credentials_md * md_elems , size_t num_md , <nl> grpc_credentials_status status , <nl> const char * error_details ) { <nl> - oauth2_request * request = user_data ; <nl> + oauth2_request * request = ( oauth2_request * ) user_data ; <nl> char * token = NULL ; <nl> grpc_slice token_slice ; <nl> if ( status = = GRPC_CREDENTIALS_ERROR ) { <nl> static void on_oauth2_response ( grpc_exec_ctx * exec_ctx , void * user_data , <nl> } else { <nl> GPR_ASSERT ( num_md = = 1 ) ; <nl> token_slice = md_elems [ 0 ] . value ; <nl> - token = gpr_malloc ( GRPC_SLICE_LENGTH ( token_slice ) + 1 ) ; <nl> + token = ( char * ) gpr_malloc ( GRPC_SLICE_LENGTH ( token_slice ) + 1 ) ; <nl> memcpy ( token , GRPC_SLICE_START_PTR ( token_slice ) , <nl> GRPC_SLICE_LENGTH ( token_slice ) ) ; <nl> token [ GRPC_SLICE_LENGTH ( token_slice ) ] = ' \ 0 ' ; <nl> char * grpc_test_fetch_oauth2_token_with_credentials ( <nl> grpc_closure do_nothing_closure ; <nl> grpc_auth_metadata_context null_ctx = { " " , " " , NULL , NULL } ; <nl> <nl> - grpc_pollset * pollset = gpr_zalloc ( grpc_pollset_size ( ) ) ; <nl> + grpc_pollset * pollset = ( grpc_pollset * ) gpr_zalloc ( grpc_pollset_size ( ) ) ; <nl> grpc_pollset_init ( pollset , & request . mu ) ; <nl> request . pops = grpc_polling_entity_create_from_pollset ( pollset ) ; <nl> request . is_done = 0 ; <nl> mmm a / test / cpp / microbenchmarks / bm_call_create . cc <nl> ppp b / test / cpp / microbenchmarks / bm_call_create . cc <nl> static void BM_IsolatedFilter ( benchmark : : State & state ) { <nl> } <nl> <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> - size_t channel_size = grpc_channel_stack_size ( & filters [ 0 ] , filters . size ( ) ) ; <nl> + size_t channel_size = grpc_channel_stack_size ( <nl> + filters . size ( ) = = 0 ? NULL : & filters [ 0 ] , filters . size ( ) ) ; <nl> grpc_channel_stack * channel_stack = <nl> static_cast < grpc_channel_stack * > ( gpr_zalloc ( channel_size ) ) ; <nl> GPR_ASSERT ( GRPC_LOG_IF_ERROR ( <nl> mmm a / tools / run_tests / generated / tests . json <nl> ppp b / tools / run_tests / generated / tests . json <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> <nl> " cpu_cost " : 1 . 0 , <nl> " defaults " : " boringssl " , <nl> " exclude_configs " : [ <nl> - " asan " <nl> + " asan " , <nl> + " ubsan " <nl> ] , <nl> " flaky " : false , <nl> " language " : " c + + " , <nl> mmm a / tools / ubsan_suppressions . txt <nl> ppp b / tools / ubsan_suppressions . txt <nl> nonnull - attribute : CBB_add_bytes <nl> nonnull - attribute : rsa_blinding_get <nl> nonnull - attribute : ssl_copy_key_material <nl> alignment : CRYPTO_cbc128_encrypt <nl> + nonnull - attribute : google : : protobuf : : DescriptorBuilder : : BuildFileImpl <nl> + nonnull - attribute : google : : protobuf : : TextFormat : : Printer : : TextGenerator : : Write <nl> <nl>
Merge github . com : grpc / grpc into write_completion
grpc/grpc
bf15d98a564b5ef3bfe540f63ba787312f12fe1d
2017-05-10T20:39:02Z
mmm a / src / qt / test / addressbooktests . cpp <nl> ppp b / src / qt / test / addressbooktests . cpp <nl> void AddressBookTests : : addressBookTests ( ) <nl> / / and fails to handle returned nulls <nl> / / ( https : / / bugreports . qt . io / browse / QTBUG - 49686 ) . <nl> QWARN ( " Skipping AddressBookTests on mac build with ' minimal ' platform set due to Qt bugs . To run AppTests , invoke " <nl> - " with ' test_bitcoin - qt - platform cocoa ' on mac , or else use a linux or windows build . " ) ; <nl> + " with ' QT_QPA_PLATFORM = cocoa test_bitcoin - qt ' on mac , or else use a linux or windows build . " ) ; <nl> return ; <nl> } <nl> # endif <nl> mmm a / src / qt / test / apptests . cpp <nl> ppp b / src / qt / test / apptests . cpp <nl> void AppTests : : appTests ( ) <nl> / / and fails to handle returned nulls <nl> / / ( https : / / bugreports . qt . io / browse / QTBUG - 49686 ) . <nl> QWARN ( " Skipping AppTests on mac build with ' minimal ' platform set due to Qt bugs . To run AppTests , invoke " <nl> - " with ' test_bitcoin - qt - platform cocoa ' on mac , or else use a linux or windows build . " ) ; <nl> + " with ' QT_QPA_PLATFORM = cocoa test_bitcoin - qt ' on mac , or else use a linux or windows build . " ) ; <nl> return ; <nl> } <nl> # endif <nl> mmm a / src / qt / test / test_main . cpp <nl> ppp b / src / qt / test / test_main . cpp <nl> int main ( int argc , char * argv [ ] ) <nl> # if defined ( WIN32 ) <nl> _putenv_s ( " QT_QPA_PLATFORM " , " minimal " ) ; <nl> # else <nl> - setenv ( " QT_QPA_PLATFORM " , " minimal " , 0 ) ; <nl> + setenv ( " QT_QPA_PLATFORM " , " minimal " , / * overwrite * / 0 ) ; <nl> # endif <nl> <nl> / / Don ' t remove this , it ' s needed to access <nl> mmm a / src / qt / test / wallettests . cpp <nl> ppp b / src / qt / test / wallettests . cpp <nl> void BumpFee ( TransactionView & view , const uint256 & txid , bool expectDisabled , st <nl> / / <nl> / / This also requires overriding the default minimal Qt platform : <nl> / / <nl> - / / src / qt / test / test_bitcoin - qt - platform xcb # Linux <nl> - / / src / qt / test / test_bitcoin - qt - platform windows # Windows <nl> - / / src / qt / test / test_bitcoin - qt - platform cocoa # macOS <nl> + / / QT_QPA_PLATFORM = xcb src / qt / test / test_bitcoin - qt # Linux <nl> + / / QT_QPA_PLATFORM = windows src / qt / test / test_bitcoin - qt # Windows <nl> + / / QT_QPA_PLATFORM = cocoa src / qt / test / test_bitcoin - qt # macOS <nl> void TestGUI ( ) <nl> { <nl> / / Set up wallet and chain with 105 blocks ( 5 mature blocks for spending ) . <nl> void WalletTests : : walletTests ( ) <nl> / / and fails to handle returned nulls <nl> / / ( https : / / bugreports . qt . io / browse / QTBUG - 49686 ) . <nl> QWARN ( " Skipping WalletTests on mac build with ' minimal ' platform set due to Qt bugs . To run AppTests , invoke " <nl> - " with ' test_bitcoin - qt - platform cocoa ' on mac , or else use a linux or windows build . " ) ; <nl> + " with ' QT_QPA_PLATFORM = cocoa test_bitcoin - qt ' on mac , or else use a linux or windows build . " ) ; <nl> return ; <nl> } <nl> # endif <nl>
doc : Explain QT_QPA_PLATFORM for gui tests
bitcoin/bitcoin
faccf5f9c899c40d4da5792629d0714249a4616b
2019-10-01T20:06:23Z
mmm a / brightray / browser / url_request_context_getter . cc <nl> ppp b / brightray / browser / url_request_context_getter . cc <nl> net : : URLRequestContext * URLRequestContextGetter : : GetURLRequestContext ( ) { <nl> std : : unique_ptr < net : : CookieStore > cookie_store = <nl> content : : CreateCookieStore ( cookie_config ) ; <nl> storage_ - > set_cookie_store ( std : : move ( cookie_store ) ) ; <nl> - storage_ - > set_channel_id_service ( base : : WrapUnique ( <nl> - new net : : ChannelIDService ( new net : : DefaultChannelIDStore ( nullptr ) , <nl> - base : : WorkerPool : : GetTaskRunner ( true ) ) ) ) ; <nl> + storage_ - > set_channel_id_service ( base : : MakeUnique < net : : ChannelIDService > ( <nl> + new net : : DefaultChannelIDStore ( nullptr ) ) ) ; <nl> <nl> std : : string accept_lang = l10n_util : : GetApplicationLocale ( " " ) ; <nl> storage_ - > set_http_user_agent_settings ( base : : WrapUnique ( <nl> net : : URLRequestContext * URLRequestContextGetter : : GetURLRequestContext ( ) { <nl> it ! = protocol_interceptors_ . rend ( ) ; <nl> + + it ) { <nl> top_job_factory . reset ( new net : : URLRequestInterceptingJobFactory ( <nl> - std : : move ( top_job_factory ) , base : : WrapUnique ( * it ) ) ) ; <nl> + std : : move ( top_job_factory ) , std : : move ( * it ) ) ) ; <nl> } <nl> - protocol_interceptors_ . weak_clear ( ) ; <nl> + protocol_interceptors_ . clear ( ) ; <nl> <nl> storage_ - > set_job_factory ( std : : move ( top_job_factory ) ) ; <nl> } <nl>
base : : WrapUnique has changed its API
electron/electron
bbd474966884c4eb998e43c8ff8db32d619b99f6
2017-04-17T07:16:02Z
mmm a / platform / android / export / export . cpp <nl> ppp b / platform / android / export / export . cpp <nl> class EditorExportAndroid : public EditorExportPlatform { <nl> <nl> Vector < String > string_table ; <nl> <nl> - String version_name = p_preset - > get ( " version / name " ) ; <nl> + String package_name = p_preset - > get ( " package / name " ) ; <nl> <nl> / / printf ( " stirng block len : % i \ n " , string_block_len ) ; <nl> / / printf ( " stirng count : % i \ n " , string_count ) ; <nl> class EditorExportAndroid : public EditorExportPlatform { <nl> <nl> if ( str = = " godot - project - name " ) { <nl> / / project name <nl> - str = get_project_name ( version_name ) ; <nl> + str = get_project_name ( package_name ) ; <nl> <nl> } else { <nl> <nl> class EditorExportAndroid : public EditorExportPlatform { <nl> if ( GlobalConfig : : get_singleton ( ) - > has ( prop ) ) { <nl> str = GlobalConfig : : get_singleton ( ) - > get ( prop ) ; <nl> } else { <nl> - str = get_project_name ( version_name ) ; <nl> + str = get_project_name ( package_name ) ; <nl> } <nl> } <nl> } <nl>
Merge pull request from volzhs / fix - android - app - name
godotengine/godot
6674c556ae531a161b4d9c11076864db83965a18
2017-03-24T21:52:25Z
mmm a / dlib / svm / assignment_function . h <nl> ppp b / dlib / svm / assignment_function . h <nl> namespace dlib <nl> { <nl> public : <nl> <nl> - typedef typename feature_extractor : : lhs_type lhs_type ; <nl> - typedef typename feature_extractor : : rhs_type rhs_type ; <nl> + typedef typename feature_extractor : : lhs_element lhs_element ; <nl> + typedef typename feature_extractor : : rhs_element rhs_element ; <nl> <nl> <nl> - typedef std : : pair < std : : vector < lhs_type > , std : : vector < rhs_type > > sample_type ; <nl> + typedef std : : pair < std : : vector < lhs_element > , std : : vector < rhs_element > > sample_type ; <nl> <nl> typedef std : : vector < long > label_type ; <nl> typedef label_type result_type ; <nl> namespace dlib <nl> ) const { return force_assignment ; } <nl> <nl> result_type operator ( ) ( <nl> - const std : : vector < lhs_type > & lhs , <nl> - const std : : vector < rhs_type > & rhs <nl> + const std : : vector < lhs_element > & lhs , <nl> + const std : : vector < rhs_element > & rhs <nl> ) const <nl> / * ! <nl> ensures <nl> mmm a / dlib / svm / structural_assignment_trainer . h <nl> ppp b / dlib / svm / structural_assignment_trainer . h <nl> namespace dlib <nl> class structural_assignment_trainer <nl> { <nl> public : <nl> - typedef typename feature_extractor : : lhs_type lhs_type ; <nl> - typedef typename feature_extractor : : rhs_type rhs_type ; <nl> + typedef typename feature_extractor : : lhs_element lhs_element ; <nl> + typedef typename feature_extractor : : rhs_element rhs_element ; <nl> <nl> - typedef std : : pair < std : : vector < lhs_type > , std : : vector < rhs_type > > sample_type ; <nl> + typedef std : : pair < std : : vector < lhs_element > , std : : vector < rhs_element > > sample_type ; <nl> <nl> typedef std : : vector < long > label_type ; <nl> <nl> mmm a / dlib / svm / structural_svm_assignment_problem . h <nl> ppp b / dlib / svm / structural_svm_assignment_problem . h <nl> namespace dlib <nl> typedef matrix < double , 0 , 1 > matrix_type ; <nl> typedef typename feature_extractor : : feature_vector_type feature_vector_type ; <nl> <nl> - typedef typename feature_extractor : : lhs_type lhs_type ; <nl> - typedef typename feature_extractor : : rhs_type rhs_type ; <nl> + typedef typename feature_extractor : : lhs_element lhs_element ; <nl> + typedef typename feature_extractor : : rhs_element rhs_element ; <nl> <nl> <nl> - typedef std : : pair < std : : vector < lhs_type > , std : : vector < rhs_type > > sample_type ; <nl> + typedef std : : pair < std : : vector < lhs_element > , std : : vector < rhs_element > > sample_type ; <nl> <nl> typedef std : : vector < long > label_type ; <nl> <nl>
renamed some things
davisking/dlib
82230b59b6e190be4bba6b4207f1ca1f93b44e32
2011-12-03T23:25:20Z
mmm a / tensorflow / python / training / adam . py <nl> ppp b / tensorflow / python / training / adam . py <nl> def __init__ ( self , learning_rate = 0 . 001 , beta1 = 0 . 9 , beta2 = 0 . 999 , epsilon = 1e - 8 , <nl> general . For example , when training an Inception network on ImageNet a <nl> current good choice is 1 . 0 or 0 . 1 . <nl> <nl> - Note that in dense implement of this algorithm , m_t , v_t and variable will <nl> - update even if g is zero , but in sparse implement , m_t , v_t and variable <nl> + Note that in dense implement of this algorithm , m_t , v_t and variable will <nl> + update even if g is zero , but in sparse implement , m_t , v_t and variable <nl> will not update in iterations g is zero . <nl> <nl> Args : <nl> def _apply_sparse ( self , grad , var ) : <nl> m_t = state_ops . assign ( m , m * beta1_t , <nl> use_locking = self . _use_locking ) <nl> m_t = state_ops . scatter_add ( m_t , grad . indices , m_scaled_g_values , <nl> - use_locking = self . _use_locking ) <nl> + use_locking = self . _use_locking ) <nl> # v_t = beta2 * v + ( 1 - beta2 ) * ( g_t * g_t ) <nl> v = self . get_slot ( var , " v " ) <nl> v_scaled_g_values = ( grad . values * grad . values ) * ( 1 - beta2_t ) <nl> v_t = state_ops . assign ( v , v * beta2_t , use_locking = self . _use_locking ) <nl> v_t = state_ops . scatter_add ( v_t , grad . indices , v_scaled_g_values , <nl> - use_locking = self . _use_locking ) <nl> + use_locking = self . _use_locking ) <nl> v_sqrt = math_ops . sqrt ( v_t ) <nl> var_update = state_ops . assign_sub ( var , <nl> lr * m_t / ( v_sqrt + epsilon_t ) , <nl>
Cosmetic fixes .
tensorflow/tensorflow
4e1bb23975b30850e92b92b94eb04fec506c6058
2017-01-30T16:51:43Z
new file mode 100644 <nl> index 0000000000 . . 288fb8c68c <nl> Binary files / dev / null and b / src / Icons / skin / delete_perm22 . png differ <nl> mmm a / src / icons . qrc <nl> ppp b / src / icons . qrc <nl> <nl> < file > Icons / magnet . png < / file > <nl> < file > Icons / slow . png < / file > <nl> < file > Icons / L . gif < / file > <nl> + < file > Icons / skin / delete_perm22 . png < / file > <nl> < file > Icons / skin / seeding . png < / file > <nl> < file > Icons / skin / splash . png < / file > <nl> < file > Icons / skin / preview . png < / file > <nl>
Added missing icon
qbittorrent/qBittorrent
9b0dd39d9d0a2afb07f1b69b05775eaf023673aa
2010-08-15T07:23:37Z
deleted file mode 100644 <nl> index baa12d61474 . . 00000000000 <nl> mmm a / hphp / test / slow / inout - loop - 2 . php . skipif <nl> ppp / dev / null <nl> <nl> - < ? hh <nl> - < < __EntryPoint > > function main ( ) : void { <nl> - if ( ini_get ( ' hhvm . allow_object_destructors ' ) ! = = ' 1 ' ) { <nl> - die ( " cannot run test with destructors disabled " ) ; <nl> - } <nl> - } <nl>
Delete obsolete skipif : the test no longer has a destructor .
facebook/hhvm
daeba7591626c3488c59fe5efb77e38486218586
2019-06-25T21:02:01Z
mmm a / test / Interpreter / SDK / GLKit . swift <nl> ppp b / test / Interpreter / SDK / GLKit . swift <nl> <nl> <nl> / / NOTE : Clang used to miscompile GLKit functions on i386 . rdar : / / problem / 19184403 <nl> <nl> + / / On i386 , it seems to work optimized mode , but fails in non - optimized . <nl> + / / rdar : / / problem / 26392402 <nl> + / / UNSUPPORTED : i386 <nl> / / REQUIRES : objc_interop <nl> <nl> import GLKit <nl>
Mark the Interpreter / SDK / GLKit . swift test as UNSUPPORTED on i386 to appease the CI bots .
apple/swift
1e8463b2ed8e528f30c14fa491c66f914e448a15
2016-05-20T20:15:11Z
mmm a / AUTHORS <nl> ppp b / AUTHORS <nl> a license to everyone to use it as detailed in LICENSE . ) <nl> * Reinier de Blois < rddeblois @ gmail . com > <nl> * Yuichi Nishiwaki < yuichi . nishiwaki @ gmail . com > <nl> * Jérôme Bernard < jerome . bernard @ ercom . fr > ( copyright owned by Ercom ) <nl> + * Fábio Santos < fabiosantosart @ gmail . com > <nl> <nl>
add self to AUTHORS
emscripten-core/emscripten
86cc3750f336ef6ca9a412bcd0bcc18aa952c67d
2015-04-21T22:12:25Z
mmm a / cocos / 2d / CCSprite . cpp <nl> ppp b / cocos / 2d / CCSprite . cpp <nl> void Sprite : : setTextureRect ( const Rect & rect , bool rotated , const Size & untrimme <nl> <nl> void Sprite : : debugDraw ( bool on ) <nl> { <nl> + if ( _batchNode ) { <nl> + log ( " Sprite doesn ' t support denbug draw when using SpriteBatchNode " ) ; <nl> + return ; <nl> + } <nl> DrawNode * draw = getChildByName < DrawNode * > ( " debugDraw " ) ; <nl> if ( on ) <nl> { <nl>
add IF - CASE to fix debug draw under SpriteBatchNode .
cocos2d/cocos2d-x
aaa5793b861ffe672168dcf71a2c3e34debe2423
2015-08-03T02:47:58Z
mmm a / Telegram / SourceFiles / chat_helpers / stickers . cpp <nl> ppp b / Telegram / SourceFiles / chat_helpers / stickers . cpp <nl> auto LottieFromDocument ( <nl> if ( const auto baseKey = document - > bigFileBaseCacheKey ( ) ) { <nl> return LottieCachedFromContent ( <nl> std : : forward < Method > ( method ) , <nl> - * baseKey , <nl> + baseKey , <nl> keyShift , <nl> & document - > session ( ) , <nl> Lottie : : ReadContent ( data , filepath ) , <nl> bool HasLottieThumbnail ( <nl> if ( ! media - > loaded ( ) ) { <nl> return false ; <nl> } <nl> - return document - > bigFileBaseCacheKey ( ) . has_value ( ) ; <nl> + return document - > bigFileBaseCacheKey ( ) . valid ( ) ; <nl> } <nl> return false ; <nl> } <nl> std : : unique_ptr < Lottie : : SinglePlayer > LottieThumbnail ( <nl> } ; <nl> return LottieCachedFromContent ( <nl> method , <nl> - * baseKey , <nl> + baseKey , <nl> uint8 ( sizeTag ) , <nl> & document - > session ( ) , <nl> content , <nl> mmm a / Telegram / SourceFiles / chat_helpers / stickers_emoji_pack . cpp <nl> ppp b / Telegram / SourceFiles / chat_helpers / stickers_emoji_pack . cpp <nl> class ImageSource : public Images : : Source { <nl> <nl> const StorageImageLocation & location ( ) override ; <nl> void refreshFileReference ( const QByteArray & data ) override ; <nl> - std : : optional < Storage : : Cache : : Key > cacheKey ( ) override ; <nl> + Storage : : Cache : : Key cacheKey ( ) override ; <nl> void setDelayedStorageLocation ( <nl> const StorageImageLocation & location ) override ; <nl> void performDelayedLoad ( Data : : FileOrigin origin ) override ; <nl> const StorageImageLocation & ImageSource : : location ( ) { <nl> void ImageSource : : refreshFileReference ( const QByteArray & data ) { <nl> } <nl> <nl> - std : : optional < Storage : : Cache : : Key > ImageSource : : cacheKey ( ) { <nl> - return std : : nullopt ; <nl> + Storage : : Cache : : Key ImageSource : : cacheKey ( ) { <nl> + return { } ; <nl> } <nl> <nl> void ImageSource : : setDelayedStorageLocation ( <nl> mmm a / Telegram / SourceFiles / data / data_document . cpp <nl> ppp b / Telegram / SourceFiles / data / data_document . cpp <nl> void DocumentData : : updateThumbnails ( <nl> loadThumbnail ( origin ) ; <nl> } <nl> if ( ! thumbnail . bytes . isEmpty ( ) ) { <nl> - / / # TODO optimize put to cache <nl> + owner ( ) . cache ( ) . putIfEmpty ( <nl> + _thumbnailLocation . file ( ) . cacheKey ( ) , <nl> + Storage : : Cache : : Database : : TaggedValue ( <nl> + base : : duplicate ( thumbnail . bytes ) , <nl> + Data : : kImageCacheTag ) ) ; <nl> } <nl> } <nl> } <nl> PhotoData * DocumentData : : goodThumbnailPhoto ( ) const { <nl> return _goodThumbnailPhoto ; <nl> } <nl> <nl> - auto DocumentData : : bigFileBaseCacheKey ( ) const <nl> - - > std : : optional < Storage : : Cache : : Key > { <nl> - if ( hasRemoteLocation ( ) ) { <nl> - return StorageFileLocation ( <nl> + Storage : : Cache : : Key DocumentData : : bigFileBaseCacheKey ( ) const { <nl> + return hasRemoteLocation ( ) <nl> + ? StorageFileLocation ( <nl> _dc , <nl> session ( ) . userId ( ) , <nl> MTP_inputDocumentFileLocation ( <nl> MTP_long ( id ) , <nl> MTP_long ( _access ) , <nl> MTP_bytes ( _fileReference ) , <nl> - MTP_string ( ) ) ) . bigFileBaseCacheKey ( ) ; <nl> - } <nl> - return std : : nullopt ; <nl> + MTP_string ( ) ) ) . bigFileBaseCacheKey ( ) <nl> + : Storage : : Cache : : Key ( ) ; <nl> } <nl> <nl> bool DocumentData : : saveToCache ( ) const { <nl> bool DocumentData : : saveToCache ( ) const { <nl> } <nl> <nl> void DocumentData : : unload ( ) { <nl> - / / Forget thumb only when image cache limit exceeds . <nl> - / / <nl> - / / Also , you can ' t unload ( ) images that you don ' t own <nl> - / / from the destructor , because they ' re already destroyed . <nl> - / / <nl> - / / _thumbnail - > unload ( ) ; <nl> _replyPreview = nullptr ; <nl> } <nl> <nl> void DocumentData : : refreshFileReference ( const QByteArray & value ) { <nl> _thumbnailLocation . refreshFileReference ( value ) ; <nl> } <nl> <nl> - void DocumentData : : refreshStickerThumbFileReference ( ) { <nl> - / / # TODO optimize <nl> - / / if ( _thumbnailLoader ) { <nl> - / / _thumbnailLocation . refreshFileReference ( <nl> - / / _thumbnailLoader - > fileReference ( ) ) ; <nl> - / / } <nl> - } <nl> - <nl> QString DocumentData : : filename ( ) const { <nl> return _filename ; <nl> } <nl> mmm a / Telegram / SourceFiles / data / data_document . h <nl> ppp b / Telegram / SourceFiles / data / data_document . h <nl> class DocumentData final { <nl> void setGoodThumbnailPhoto ( not_null < PhotoData * > photo ) ; <nl> [ [ nodiscard ] ] PhotoData * goodThumbnailPhoto ( ) const ; <nl> <nl> - [ [ nodiscard ] ] auto bigFileBaseCacheKey ( ) const <nl> - - > std : : optional < Storage : : Cache : : Key > ; <nl> + [ [ nodiscard ] ] Storage : : Cache : : Key bigFileBaseCacheKey ( ) const ; <nl> <nl> void setRemoteLocation ( <nl> int32 dc , <nl> class DocumentData final { <nl> [ [ nodiscard ] ] MTPInputDocument mtpInput ( ) const ; <nl> [ [ nodiscard ] ] QByteArray fileReference ( ) const ; <nl> void refreshFileReference ( const QByteArray & value ) ; <nl> - void refreshStickerThumbFileReference ( ) ; <nl> <nl> / / When we have some client - side generated document <nl> / / ( for example for displaying an external inline bot result ) <nl> mmm a / Telegram / SourceFiles / data / data_photo . cpp <nl> ppp b / Telegram / SourceFiles / data / data_photo . cpp <nl> void PhotoData : : collectLocalData ( not_null < PhotoData * > local ) { <nl> const auto copyImage = [ & ] ( const ImagePtr & src , const ImagePtr & dst ) { <nl> if ( const auto from = src - > cacheKey ( ) ) { <nl> if ( const auto to = dst - > cacheKey ( ) ) { <nl> - _owner - > cache ( ) . copyIfEmpty ( * from , * to ) ; <nl> + _owner - > cache ( ) . copyIfEmpty ( from , to ) ; <nl> } <nl> } <nl> } ; <nl> mmm a / Telegram / SourceFiles / media / streaming / media_streaming_loader . h <nl> ppp b / Telegram / SourceFiles / media / streaming / media_streaming_loader . h <nl> class Loader { <nl> public : <nl> static constexpr auto kPartSize = 128 * 1024 ; <nl> <nl> - [ [ nodiscard ] ] virtual auto baseCacheKey ( ) const <nl> - - > std : : optional < Storage : : Cache : : Key > = 0 ; <nl> + [ [ nodiscard ] ] virtual Storage : : Cache : : Key baseCacheKey ( ) const = 0 ; <nl> [ [ nodiscard ] ] virtual int size ( ) const = 0 ; <nl> <nl> virtual void load ( int offset ) = 0 ; <nl> mmm a / Telegram / SourceFiles / media / streaming / media_streaming_loader_local . cpp <nl> ppp b / Telegram / SourceFiles / media / streaming / media_streaming_loader_local . cpp <nl> LoaderLocal : : LoaderLocal ( std : : unique_ptr < QIODevice > device ) <nl> } <nl> } <nl> <nl> - std : : optional < Storage : : Cache : : Key > LoaderLocal : : baseCacheKey ( ) const { <nl> - return std : : nullopt ; <nl> + Storage : : Cache : : Key LoaderLocal : : baseCacheKey ( ) const { <nl> + return { } ; <nl> } <nl> <nl> int LoaderLocal : : size ( ) const { <nl> mmm a / Telegram / SourceFiles / media / streaming / media_streaming_loader_local . h <nl> ppp b / Telegram / SourceFiles / media / streaming / media_streaming_loader_local . h <nl> class LoaderLocal : public Loader , public base : : has_weak_ptr { <nl> public : <nl> LoaderLocal ( std : : unique_ptr < QIODevice > device ) ; <nl> <nl> - [ [ nodiscard ] ] auto baseCacheKey ( ) const <nl> - - > std : : optional < Storage : : Cache : : Key > override ; <nl> + [ [ nodiscard ] ] Storage : : Cache : : Key baseCacheKey ( ) const override ; <nl> [ [ nodiscard ] ] int size ( ) const override ; <nl> <nl> void load ( int offset ) override ; <nl> mmm a / Telegram / SourceFiles / media / streaming / media_streaming_loader_mtproto . cpp <nl> ppp b / Telegram / SourceFiles / media / streaming / media_streaming_loader_mtproto . cpp <nl> LoaderMtproto : : LoaderMtproto ( <nl> , _api ( api ( ) . instance ( ) ) { <nl> } <nl> <nl> - std : : optional < Storage : : Cache : : Key > LoaderMtproto : : baseCacheKey ( ) const { <nl> + Storage : : Cache : : Key LoaderMtproto : : baseCacheKey ( ) const { <nl> return location ( ) . data . get < StorageFileLocation > ( ) . bigFileBaseCacheKey ( ) ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / media / streaming / media_streaming_loader_mtproto . h <nl> ppp b / Telegram / SourceFiles / media / streaming / media_streaming_loader_mtproto . h <nl> class LoaderMtproto : public Loader , public Storage : : DownloadMtprotoTask { <nl> int size , <nl> Data : : FileOrigin origin ) ; <nl> <nl> - [ [ nodiscard ] ] auto baseCacheKey ( ) const <nl> - - > std : : optional < Storage : : Cache : : Key > override ; <nl> + [ [ nodiscard ] ] Storage : : Cache : : Key baseCacheKey ( ) const override ; <nl> [ [ nodiscard ] ] int size ( ) const override ; <nl> <nl> void load ( int offset ) override ; <nl> mmm a / Telegram / SourceFiles / media / streaming / media_streaming_reader . cpp <nl> ppp b / Telegram / SourceFiles / media / streaming / media_streaming_reader . cpp <nl> void Reader : : refreshLoaderPriority ( ) { <nl> } <nl> <nl> bool Reader : : isRemoteLoader ( ) const { <nl> - return _loader - > baseCacheKey ( ) . has_value ( ) ; <nl> + return _loader - > baseCacheKey ( ) . valid ( ) ; <nl> } <nl> <nl> std : : shared_ptr < Reader : : CacheHelper > Reader : : InitCacheHelper ( <nl> - std : : optional < Storage : : Cache : : Key > baseKey ) { <nl> + Storage : : Cache : : Key baseKey ) { <nl> if ( ! baseKey ) { <nl> return nullptr ; <nl> } <nl> - return std : : make_shared < Reader : : CacheHelper > ( * baseKey ) ; <nl> + return std : : make_shared < Reader : : CacheHelper > ( baseKey ) ; <nl> } <nl> <nl> / / 0 is for headerData , slice index = sliceNumber - 1 . <nl> mmm a / Telegram / SourceFiles / media / streaming / media_streaming_reader . h <nl> ppp b / Telegram / SourceFiles / media / streaming / media_streaming_reader . h <nl> class Reader final : public base : : has_weak_ptr { <nl> void refreshLoaderPriority ( ) ; <nl> <nl> static std : : shared_ptr < CacheHelper > InitCacheHelper ( <nl> - std : : optional < Storage : : Cache : : Key > baseKey ) ; <nl> + Storage : : Cache : : Key baseKey ) ; <nl> <nl> const std : : unique_ptr < Loader > _loader ; <nl> Storage : : Cache : : Database * const _cache = nullptr ; <nl> mmm a / Telegram / SourceFiles / storage / localstorage . cpp <nl> ppp b / Telegram / SourceFiles / storage / localstorage . cpp <nl> void _writeStickerSets ( FileKey & stickersKey , CheckSet checkSet , const Stickers : : <nl> } <nl> <nl> for ( const auto sticker : set . stickers ) { <nl> - sticker - > refreshStickerThumbFileReference ( ) ; <nl> size + = Serialize : : Document : : sizeInStream ( sticker ) ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / ui / image / image . cpp <nl> ppp b / Telegram / SourceFiles / ui / image / image . cpp <nl> void Image : : loadEvenCancelled ( Data : : FileOrigin origin ) { <nl> } <nl> } <nl> <nl> - std : : optional < Storage : : Cache : : Key > Image : : cacheKey ( ) const { <nl> + Storage : : Cache : : Key Image : : cacheKey ( ) const { <nl> return _source - > cacheKey ( ) ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / ui / image / image . h <nl> ppp b / Telegram / SourceFiles / ui / image / image . h <nl> class Source { <nl> <nl> virtual const StorageImageLocation & location ( ) = 0 ; <nl> virtual void refreshFileReference ( const QByteArray & data ) = 0 ; <nl> - virtual std : : optional < Storage : : Cache : : Key > cacheKey ( ) = 0 ; <nl> + virtual Storage : : Cache : : Key cacheKey ( ) = 0 ; <nl> virtual void setDelayedStorageLocation ( <nl> const StorageImageLocation & location ) = 0 ; <nl> virtual void performDelayedLoad ( Data : : FileOrigin origin ) = 0 ; <nl> class Image final { <nl> void refreshFileReference ( const QByteArray & data ) { <nl> _source - > refreshFileReference ( data ) ; <nl> } <nl> - std : : optional < Storage : : Cache : : Key > cacheKey ( ) const ; <nl> + Storage : : Cache : : Key cacheKey ( ) const ; <nl> QByteArray bytesForCache ( ) const { <nl> return _source - > bytesForCache ( ) ; <nl> } <nl> mmm a / Telegram / SourceFiles / ui / image / image_location . cpp <nl> ppp b / Telegram / SourceFiles / ui / image / image_location . cpp <nl> DownloadLocation DownloadLocation : : convertToModern ( <nl> return DownloadLocation { file . convertToModern ( type , id , accessHash ) } ; <nl> } <nl> <nl> + Storage : : Cache : : Key DownloadLocation : : cacheKey ( ) const { <nl> + return data . match ( [ ] ( const GeoPointLocation & data ) { <nl> + return Data : : GeoPointCacheKey ( data ) ; <nl> + } , [ ] ( const StorageFileLocation & data ) { <nl> + return data . valid ( ) <nl> + ? data . cacheKey ( ) <nl> + : Storage : : Cache : : Key ( ) ; <nl> + } , [ ] ( const WebFileLocation & data ) { <nl> + return data . isNull ( ) <nl> + ? Storage : : Cache : : Key ( ) <nl> + : Data : : WebDocumentCacheKey ( data ) ; <nl> + } , [ ] ( const PlainUrlLocation & data ) { <nl> + return data . url . isEmpty ( ) <nl> + ? Storage : : Cache : : Key ( ) <nl> + : Data : : UrlCacheKey ( data . url ) ; <nl> + } , [ ] ( const InMemoryLocation & data ) { <nl> + return Storage : : Cache : : Key ( ) ; <nl> + } ) ; <nl> + } <nl> + <nl> bool DownloadLocation : : valid ( ) const { <nl> return data . match ( [ ] ( const GeoPointLocation & data ) { <nl> return true ; <nl> mmm a / Telegram / SourceFiles / ui / image / image_location . h <nl> ppp b / Telegram / SourceFiles / ui / image / image_location . h <nl> class DownloadLocation { <nl> uint64 id , <nl> uint64 accessHash ) const ; <nl> <nl> + [ [ nodiscard ] ] Storage : : Cache : : Key cacheKey ( ) const ; <nl> [ [ nodiscard ] ] bool valid ( ) const ; <nl> [ [ nodiscard ] ] QByteArray fileReference ( ) const ; <nl> bool refreshFileReference ( const QByteArray & data ) ; <nl> mmm a / Telegram / SourceFiles / ui / image / image_source . cpp <nl> ppp b / Telegram / SourceFiles / ui / image / image_source . cpp <nl> const StorageImageLocation & ImageSource : : location ( ) { <nl> void ImageSource : : refreshFileReference ( const QByteArray & data ) { <nl> } <nl> <nl> - std : : optional < Storage : : Cache : : Key > ImageSource : : cacheKey ( ) { <nl> - return std : : nullopt ; <nl> + Storage : : Cache : : Key ImageSource : : cacheKey ( ) { <nl> + return Storage : : Cache : : Key ( ) ; <nl> } <nl> <nl> void ImageSource : : setDelayedStorageLocation ( <nl> const StorageImageLocation & LocalFileSource : : location ( ) { <nl> void LocalFileSource : : refreshFileReference ( const QByteArray & data ) { <nl> } <nl> <nl> - std : : optional < Storage : : Cache : : Key > LocalFileSource : : cacheKey ( ) { <nl> - return std : : nullopt ; <nl> + Storage : : Cache : : Key LocalFileSource : : cacheKey ( ) { <nl> + return Storage : : Cache : : Key ( ) ; <nl> } <nl> <nl> void LocalFileSource : : setDelayedStorageLocation ( <nl> const StorageImageLocation & StorageSource : : location ( ) { <nl> return _location ; <nl> } <nl> <nl> - std : : optional < Storage : : Cache : : Key > StorageSource : : cacheKey ( ) { <nl> + Storage : : Cache : : Key StorageSource : : cacheKey ( ) { <nl> return _location . valid ( ) <nl> - ? base : : make_optional ( _location . file ( ) . cacheKey ( ) ) <nl> - : std : : nullopt ; <nl> + ? _location . file ( ) . cacheKey ( ) <nl> + : Storage : : Cache : : Key ( ) ; <nl> } <nl> <nl> int StorageSource : : width ( ) { <nl> WebCachedSource : : WebCachedSource ( <nl> , _size ( size ) { <nl> } <nl> <nl> - std : : optional < Storage : : Cache : : Key > WebCachedSource : : cacheKey ( ) { <nl> + Storage : : Cache : : Key WebCachedSource : : cacheKey ( ) { <nl> return _location . isNull ( ) <nl> - ? std : : nullopt <nl> - : base : : make_optional ( Data : : WebDocumentCacheKey ( _location ) ) ; <nl> + ? Storage : : Cache : : Key ( ) <nl> + : Data : : WebDocumentCacheKey ( _location ) ; <nl> } <nl> <nl> int WebCachedSource : : width ( ) { <nl> GeoPointSource : : GeoPointSource ( const GeoPointLocation & location ) <nl> : _location ( location ) { <nl> } <nl> <nl> - std : : optional < Storage : : Cache : : Key > GeoPointSource : : cacheKey ( ) { <nl> + Storage : : Cache : : Key GeoPointSource : : cacheKey ( ) { <nl> return Data : : GeoPointCacheKey ( _location ) ; <nl> } <nl> <nl> WebUrlSource : : WebUrlSource ( const QString & url , int width , int height ) <nl> , _height ( height ) { <nl> } <nl> <nl> - std : : optional < Storage : : Cache : : Key > WebUrlSource : : cacheKey ( ) { <nl> + Storage : : Cache : : Key WebUrlSource : : cacheKey ( ) { <nl> return Data : : UrlCacheKey ( _url ) ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / ui / image / image_source . h <nl> ppp b / Telegram / SourceFiles / ui / image / image_source . h <nl> class ImageSource : public Source { <nl> <nl> const StorageImageLocation & location ( ) override ; <nl> void refreshFileReference ( const QByteArray & data ) override ; <nl> - std : : optional < Storage : : Cache : : Key > cacheKey ( ) override ; <nl> + Storage : : Cache : : Key cacheKey ( ) override ; <nl> void setDelayedStorageLocation ( <nl> const StorageImageLocation & location ) override ; <nl> void performDelayedLoad ( Data : : FileOrigin origin ) override ; <nl> class LocalFileSource : public Source { <nl> <nl> const StorageImageLocation & location ( ) override ; <nl> void refreshFileReference ( const QByteArray & data ) override ; <nl> - std : : optional < Storage : : Cache : : Key > cacheKey ( ) override ; <nl> + Storage : : Cache : : Key cacheKey ( ) override ; <nl> void setDelayedStorageLocation ( <nl> const StorageImageLocation & location ) override ; <nl> void performDelayedLoad ( Data : : FileOrigin origin ) override ; <nl> class StorageSource : public RemoteSource { <nl> int size ) ; <nl> <nl> const StorageImageLocation & location ( ) override ; <nl> - std : : optional < Storage : : Cache : : Key > cacheKey ( ) override ; <nl> + Storage : : Cache : : Key cacheKey ( ) override ; <nl> <nl> void refreshFileReference ( const QByteArray & data ) override ; <nl> <nl> class WebCachedSource : public RemoteSource { <nl> int height , <nl> int size = 0 ) ; <nl> <nl> - std : : optional < Storage : : Cache : : Key > cacheKey ( ) override ; <nl> + Storage : : Cache : : Key cacheKey ( ) override ; <nl> <nl> int width ( ) override ; <nl> int height ( ) override ; <nl> class GeoPointSource : public RemoteSource { <nl> public : <nl> GeoPointSource ( const GeoPointLocation & location ) ; <nl> <nl> - std : : optional < Storage : : Cache : : Key > cacheKey ( ) override ; <nl> + Storage : : Cache : : Key cacheKey ( ) override ; <nl> <nl> int width ( ) override ; <nl> int height ( ) override ; <nl> class WebUrlSource : public RemoteSource { <nl> explicit WebUrlSource ( const QString & url , QSize box = QSize ( ) ) ; <nl> WebUrlSource ( const QString & url , int width , int height ) ; <nl> <nl> - std : : optional < Storage : : Cache : : Key > cacheKey ( ) override ; <nl> + Storage : : Cache : : Key cacheKey ( ) override ; <nl> <nl> int width ( ) override ; <nl> int height ( ) override ; <nl> mmm a / Telegram / lib_storage <nl> ppp b / Telegram / lib_storage <nl> @ @ - 1 + 1 @ @ <nl> - Subproject commit 57027c7d6c071f0d958576a530c7c0411d8d4274 <nl> + Subproject commit df60834eac1545201682b2b55444c5ef61a170d2 <nl>
Use empty Storage : : Cache : : Key as nullopt .
telegramdesktop/tdesktop
fb322b5fc5389ff5e7123d0af1bf0a06a7c20584
2020-06-01T14:09:31Z
mmm a / platform / android / dir_access_jandroid . cpp <nl> ppp b / platform / android / dir_access_jandroid . cpp <nl> void DirAccessJAndroid : : list_dir_end ( ) { <nl> return ; <nl> <nl> JNIEnv * env = ThreadAndroid : : get_env ( ) ; <nl> - env - > CallObjectMethod ( io , _dir_close , id ) ; <nl> + env - > CallVoidMethod ( io , _dir_close , id ) ; <nl> id = 0 ; <nl> <nl> <nl> Error DirAccessJAndroid : : change_dir ( String p_dir ) { <nl> if ( res < = 0 ) <nl> return ERR_INVALID_PARAMETER ; <nl> <nl> - env - > CallObjectMethod ( io , _dir_close , res ) ; <nl> + env - > CallVoidMethod ( io , _dir_close , res ) ; <nl> <nl> current_dir = new_dir ; <nl> <nl>
Fix crash on android 6 . 0 . 1 , fixes
godotengine/godot
4cb14ae7d6bea5e656a71fce37a2409e7eb73cad
2016-01-12T06:27:56Z
mmm a / Marlin / language_el - gr . h <nl> ppp b / Marlin / language_el - gr . h <nl> <nl> # ifndef LANGUAGE_EL_GR_H <nl> # define LANGUAGE_EL_GR_H <nl> <nl> - / / # define MAPPER_CECF <nl> - / / # define DISPLAY_CHARSET_ISO10646_GREEK <nl> + # define MAPPER_CECF <nl> + # define DISPLAY_CHARSET_ISO10646_GREEK <nl> <nl> # define WELCOME_MSG MACHINE_NAME " έτοιμο . " <nl> # define MSG_SD_INSERTED " Εισαγωγή κάρτας " <nl>
Activate font and mapper for el - gr
MarlinFirmware/Marlin
75fdcc14b7875ae06b9870555cf487bbc11b6cc1
2016-11-26T01:30:37Z
mmm a / ports / ffmpeg / CONTROL <nl> ppp b / ports / ffmpeg / CONTROL <nl> <nl> Source : ffmpeg <nl> Version : 4 . 2 <nl> - Port - Version : 17 <nl> + Port - Version : 18 <nl> Build - Depends : zlib <nl> Homepage : https : / / ffmpeg . org <nl> Description : a library to decode , encode , transcode , mux , demux , stream , filter and play pretty much anything that humans and machines have created . <nl> FFmpeg is the leading multimedia framework , able to decode , encode , transcode , mux , demux , stream , filter and play pretty much anything that humans and machines have created . It supports the most obscure ancient formats up to the cutting edge . No matter if they were designed by some standards committee , the community or a corporation . It is also highly portable : FFmpeg compiles , runs , and passes our testing infrastructure FATE across Linux , Mac OS X , Microsoft Windows , the BSDs , Solaris , etc . under a wide variety of build environments , machine architectures , and configurations . <nl> - Default - Features : avresample <nl> + Default - Features : avresample , avcodec , avformat , avdevice , avfilter , swresample , swscale <nl> <nl> Feature : ffmpeg <nl> Description : build the ffmpeg . exe application <nl> Description : upgrade ( L ) GPL to version 3 <nl> Feature : avresample <nl> Description : Libav audio resampling library support in ffmpeg <nl> <nl> + Feature : avcodec <nl> + Description : Codec support in ffmpeg <nl> + <nl> + Feature : avformat <nl> + Description : Format support in ffmpeg <nl> + <nl> + Feature : avdevice <nl> + Description : Device support in ffmpeg <nl> + <nl> + Feature : avfilter <nl> + Description : Filter support in ffmpeg <nl> + <nl> + Feature : swresample <nl> + Description : Swresample support in ffmpeg <nl> + <nl> + Feature : swscale <nl> + Description : Swscale support in ffmpeg <nl> + <nl> Feature : nvcodec <nl> Build - Depends : ffnvcodec , cuda <nl> Description : Hardware accelerated codecs <nl> mmm a / ports / ffmpeg / FindFFMPEG . cmake . in <nl> ppp b / ports / ffmpeg / FindFFMPEG . cmake . in <nl> if ( APPLE ) <nl> list ( APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS $ { VT_UNIT } $ { AT_UNIT } $ { SEC_UNIT } $ { CF_UNIT } $ { CM_UNIT } $ { CV_UNIT } $ { Iconv_LIBRARIES } ) <nl> endif ( ) <nl> <nl> - FFMPEG_FIND ( libavcodec avcodec avcodec . h ) <nl> - FFMPEG_FIND ( libavdevice avdevice avdevice . h ) <nl> - FFMPEG_FIND ( libavfilter avfilter avfilter . h ) <nl> - FFMPEG_FIND ( libavformat avformat avformat . h ) <nl> + if ( @ ENABLE_AVCODEC @ ) <nl> + FFMPEG_FIND ( libavcodec avcodec avcodec . h ) <nl> + endif ( ) <nl> + if ( @ ENABLE_AVDEVICE @ ) <nl> + FFMPEG_FIND ( libavdevice avdevice avdevice . h ) <nl> + endif ( ) <nl> + if ( @ ENABLE_AVFILTER @ ) <nl> + FFMPEG_FIND ( libavfilter avfilter avfilter . h ) <nl> + endif ( ) <nl> + if ( @ ENABLE_AVFORMAT @ ) <nl> + FFMPEG_FIND ( libavformat avformat avformat . h ) <nl> + endif ( ) <nl> if ( @ ENABLE_AVRESAMPLE @ ) <nl> FFMPEG_FIND ( libavresample avresample avresample . h ) <nl> endif ( ) <nl> FFMPEG_FIND ( libavutil avutil avutil . h ) <nl> - FFMPEG_FIND ( libswresample swresample swresample . h ) <nl> - FFMPEG_FIND ( libswscale swscale swscale . h ) <nl> - <nl> - if ( FFMPEG_libavcodec_FOUND AND FFMPEG_libavdevice_FOUND AND FFMPEG_libavfilter_FOUND AND FFMPEG_libavformat_FOUND AND FFMPEG_libavutil_FOUND AND FFMPEG_libswresample_FOUND AND FFMPEG_libswscale_FOUND AND FFMPEG_libzlib_FOUND ) <nl> - list ( APPEND FFMPEG_INCLUDE_DIRS $ { FFMPEG_libavformat_INCLUDE_DIRS } $ { FFMPEG_libavdevice_INCLUDE_DIRS } $ { FFMPEG_libavcodec_INCLUDE_DIRS } $ { FFMPEG_libavutil_INCLUDE_DIRS } $ { FFMPEG_libswscale_INCLUDE_DIRS } ) <nl> + if ( @ ENABLE_SWRESAMPLE @ ) <nl> + FFMPEG_FIND ( libswresample swresample swresample . h ) <nl> + endif ( ) <nl> + if ( @ ENABLE_SWSCALE @ ) <nl> + FFMPEG_FIND ( libswscale swscale swscale . h ) <nl> + endif ( @ ENABLE_SWSCALE @ ) <nl> + <nl> + if ( FFMPEG_libavutil_FOUND AND FFMPEG_libzlib_FOUND ) <nl> + list ( APPEND FFMPEG_INCLUDE_DIRS $ { FFMPEG_libavutil_INCLUDE_DIRS } ) <nl> + if ( FFMPEG_libavcodec_FOUND ) <nl> + list ( APPEND FFMPEG_INCLUDE_DIRS $ { FFMPEG_libavcodec_INCLUDE_DIRS } ) <nl> + endif ( ) <nl> + if ( FFMPEG_libavdevice_FOUND ) <nl> + list ( APPEND FFMPEG_INCLUDE_DIRS $ { FFMPEG_libavdevice_INCLUDE_DIRS } ) <nl> + endif ( ) <nl> + if ( FFMPEG_libavformat_FOUND ) <nl> + list ( APPEND FFMPEG_INCLUDE_DIRS $ { FFMPEG_libavformat_INCLUDE_DIRS } ) <nl> + endif ( ) <nl> + if ( FFMPEG_libswscale_FOUND ) <nl> + list ( APPEND FFMPEG_INCLUDE_DIRS $ { FFMPEG_libswscale_INCLUDE_DIRS } ) <nl> + endif ( ) <nl> list ( REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS ) <nl> list ( REMOVE_DUPLICATES FFMPEG_LIBRARY_DIRS ) <nl> <nl> - set ( FFMPEG_libavcodec_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> - set ( FFMPEG_libavdevice_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> - set ( FFMPEG_libavfilter_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> - set ( FFMPEG_libavformat_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> + if ( FFMPEG_libavcodec_FOUND ) <nl> + set ( FFMPEG_libavcodec_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> + endif ( ) <nl> + if ( FFMPEG_libavdevice_FOUND ) <nl> + set ( FFMPEG_libavdevice_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> + endif ( ) <nl> + if ( FFMPEG_libavfilter_FOUND ) <nl> + set ( FFMPEG_libavfilter_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> + endif ( ) <nl> + if ( FFMPEG_libavformat_FOUND ) <nl> + set ( FFMPEG_libavformat_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> + endif ( ) <nl> if ( FFMPEG_libavresample_FOUND ) <nl> set ( FFMPEG_libavresample_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> endif ( ) <nl> set ( FFMPEG_libavutil_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> - set ( FFMPEG_libswresample_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> - set ( FFMPEG_libswscale_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> + if ( FFMPEG_libswresample_FOUND ) <nl> + set ( FFMPEG_libswresample_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> + endif ( ) <nl> + if ( FFMPEG_libswscale_FOUND ) <nl> + set ( FFMPEG_libswscale_VERSION " $ { FFMPEG_VERSION } " CACHE STRING " " ) <nl> + endif ( ) <nl> <nl> list ( APPEND FFMPEG_LIBRARIES <nl> $ { FFMPEG_libavdevice_LIBRARY } <nl> mmm a / ports / ffmpeg / portfile . cmake <nl> ppp b / ports / ffmpeg / portfile . cmake <nl> if ( " avresample " IN_LIST FEATURES ) <nl> set ( ENABLE_AVRESAMPLE ON ) # necessary for configuring FFMPEG CMake Module <nl> endif ( ) <nl> <nl> + if ( " avcodec " IN_LIST FEATURES ) <nl> + set ( OPTIONS " $ { OPTIONS } - - enable - avcodec " ) <nl> + set ( ENABLE_AVCODEC ON ) <nl> + else ( ) <nl> + set ( OPTIONS " $ { OPTIONS } - - disable - avcodec " ) <nl> + set ( ENABLE_AVCODEC OFF ) <nl> + endif ( ) <nl> + <nl> + if ( " avdevice " IN_LIST FEATURES ) <nl> + set ( OPTIONS " $ { OPTIONS } - - enable - avdevice " ) <nl> + set ( ENABLE_AVDEVICE ON ) <nl> + else ( ) <nl> + set ( OPTIONS " $ { OPTIONS } - - disable - avdevice " ) <nl> + set ( ENABLE_AVDEVICE OFF ) <nl> + endif ( ) <nl> + <nl> + if ( " avformat " IN_LIST FEATURES ) <nl> + set ( OPTIONS " $ { OPTIONS } - - enable - avformat " ) <nl> + set ( ENABLE_AVFORMAT ON ) <nl> + else ( ) <nl> + set ( OPTIONS " $ { OPTIONS } - - disable - avformat " ) <nl> + set ( ENABLE_AVFORMAT OFF ) <nl> + endif ( ) <nl> + <nl> + if ( " avfilter " IN_LIST FEATURES ) <nl> + set ( OPTIONS " $ { OPTIONS } - - enable - avfilter " ) <nl> + set ( ENABLE_AVFILTER ON ) <nl> + else ( ) <nl> + set ( OPTIONS " $ { OPTIONS } - - disable - avfilter " ) <nl> + set ( ENABLE_AVFILTER OFF ) <nl> + endif ( ) <nl> + <nl> + if ( " swresample " IN_LIST FEATURES ) <nl> + set ( OPTIONS " $ { OPTIONS } - - enable - swresample " ) <nl> + set ( ENABLE_SWRESAMPLE ON ) <nl> + else ( ) <nl> + set ( OPTIONS " $ { OPTIONS } - - disable - swresample " ) <nl> + set ( ENABLE_SWRESAMPLE OFF ) <nl> + endif ( ) <nl> + <nl> + if ( " swscale " IN_LIST FEATURES ) <nl> + set ( OPTIONS " $ { OPTIONS } - - enable - swscale " ) <nl> + set ( ENABLE_SWSCALE ON ) <nl> + else ( ) <nl> + set ( OPTIONS " $ { OPTIONS } - - disable - swscale " ) <nl> + set ( ENABLE_SWSCALE OFF ) <nl> + endif ( ) <nl> + <nl> if ( VCPKG_TARGET_IS_OSX ) <nl> set ( OPTIONS " $ { OPTIONS } - - disable - vdpau " ) # disable vdpau in OSX <nl> endif ( ) <nl>
[ ffmpeg ] Some libraries in ffmpeg can be optional ( )
microsoft/vcpkg
234f7e45430eda4f1f68ff75cabe11435e8b8190
2020-08-14T17:01:01Z
mmm a / bench / serializer - bench / Makefile <nl> ppp b / bench / serializer - bench / Makefile <nl> <nl> DEBUG ? = 0 <nl> CXXFLAGS = - Wall - pg - g - DUSE_UCONTEXT - DNDEBUG = 1 <nl> - LDFLAGS = - Wall - rdynamic - lrt - laio - pg - g - lgsl - lgslcblas - lgtest <nl> + LDFLAGS = - Wall - rdynamic - lrt - laio - pg - g - lgsl - lgslcblas - lgtest - lprotoc <nl> OBJDIR : = . . / . . / build / release / obj <nl> <nl> serializer - bench : main . cc Makefile <nl>
Add protoc library dependency to serializer bench makefile
rethinkdb/rethinkdb
fa3e7027cb1a5a1ae02a68f668fb969422b23fdf
2011-05-26T02:13:34Z
mmm a / src / compiler / js - context - specialization . cc <nl> ppp b / src / compiler / js - context - specialization . cc <nl> <nl> <nl> # include " src / compiler / common - operator . h " <nl> # include " src / compiler / generic - node - inl . h " <nl> + # include " src / compiler / graph - inl . h " <nl> # include " src / compiler / js - context - specialization . h " <nl> # include " src / compiler / js - operator . h " <nl> # include " src / compiler / node - aux - data - inl . h " <nl> namespace compiler { <nl> <nl> / / TODO ( titzer ) : factor this out to a common routine with js - typed - lowering . <nl> static void ReplaceEffectfulWithValue ( Node * node , Node * value ) { <nl> - Node * effect = NodeProperties : : GetEffectInput ( node ) ; <nl> + Node * effect = NULL ; <nl> + if ( OperatorProperties : : HasEffectInput ( node - > op ( ) ) ) { <nl> + effect = NodeProperties : : GetEffectInput ( node ) ; <nl> + } <nl> <nl> / / Requires distinguishing between value and effect edges . <nl> UseIter iter = node - > uses ( ) . begin ( ) ; <nl> while ( iter ! = node - > uses ( ) . end ( ) ) { <nl> if ( NodeProperties : : IsEffectEdge ( iter . edge ( ) ) ) { <nl> + DCHECK_NE ( NULL , effect ) ; <nl> iter = iter . UpdateToAndIncrement ( effect ) ; <nl> } else { <nl> iter = iter . UpdateToAndIncrement ( value ) ; <nl> static void ReplaceEffectfulWithValue ( Node * node , Node * value ) { <nl> } <nl> <nl> <nl> - void JSContextSpecializer : : SpecializeToContext ( ) { <nl> - ValueMatcher < Handle < Context > > match ( context_ ) ; <nl> - <nl> - / / Iterate over all uses of the context and try to replace { LoadContext } <nl> - / / nodes with their values from the constant context . <nl> - UseIter iter = match . node ( ) - > uses ( ) . begin ( ) ; <nl> - while ( iter ! = match . node ( ) - > uses ( ) . end ( ) ) { <nl> - Node * use = * iter ; <nl> - if ( use - > opcode ( ) = = IrOpcode : : kJSLoadContext ) { <nl> - Reduction r = ReduceJSLoadContext ( use ) ; <nl> - if ( r . Changed ( ) & & r . replacement ( ) ! = use ) { <nl> - ReplaceEffectfulWithValue ( use , r . replacement ( ) ) ; <nl> + class ContextSpecializationVisitor : public NullNodeVisitor { <nl> + public : <nl> + explicit ContextSpecializationVisitor ( JSContextSpecializer * spec ) <nl> + : spec_ ( spec ) { } <nl> + <nl> + GenericGraphVisit : : Control Post ( Node * node ) { <nl> + switch ( node - > opcode ( ) ) { <nl> + case IrOpcode : : kJSLoadContext : { <nl> + Reduction r = spec_ - > ReduceJSLoadContext ( node ) ; <nl> + if ( r . Changed ( ) & & r . replacement ( ) ! = node ) { <nl> + ReplaceEffectfulWithValue ( node , r . replacement ( ) ) ; <nl> + } <nl> + break ; <nl> + } <nl> + case IrOpcode : : kJSStoreContext : { <nl> + Reduction r = spec_ - > ReduceJSStoreContext ( node ) ; <nl> + if ( r . Changed ( ) & & r . replacement ( ) ! = node ) { <nl> + ReplaceEffectfulWithValue ( node , r . replacement ( ) ) ; <nl> + } <nl> + break ; <nl> } <nl> + default : <nl> + break ; <nl> } <nl> - + + iter ; <nl> + return GenericGraphVisit : : CONTINUE ; <nl> } <nl> + <nl> + private : <nl> + JSContextSpecializer * spec_ ; <nl> + } ; <nl> + <nl> + <nl> + void JSContextSpecializer : : SpecializeToContext ( ) { <nl> + ReplaceEffectfulWithValue ( context_ , jsgraph_ - > Constant ( info_ - > context ( ) ) ) ; <nl> + <nl> + ContextSpecializationVisitor visitor ( this ) ; <nl> + jsgraph_ - > graph ( ) - > VisitNodeInputsFromEnd ( & visitor ) ; <nl> } <nl> <nl> <nl> Reduction JSContextSpecializer : : ReduceJSLoadContext ( Node * node ) { <nl> DCHECK_EQ ( IrOpcode : : kJSLoadContext , node - > opcode ( ) ) ; <nl> <nl> - ContextAccess access = <nl> - static_cast < Operator1 < ContextAccess > * > ( node - > op ( ) ) - > parameter ( ) ; <nl> + ValueMatcher < Handle < Context > > match ( NodeProperties : : GetValueInput ( node , 0 ) ) ; <nl> + / / If the context is not constant , no reduction can occur . <nl> + if ( ! match . HasValue ( ) ) { <nl> + return Reducer : : NoChange ( ) ; <nl> + } <nl> + <nl> + ContextAccess access = OpParameter < ContextAccess > ( node ) ; <nl> <nl> / / Find the right parent context . <nl> - Context * context = * info_ - > context ( ) ; <nl> + Context * context = * match . Value ( ) ; <nl> for ( int i = access . depth ( ) ; i > 0 ; - - i ) { <nl> context = context - > previous ( ) ; <nl> } <nl> Reduction JSContextSpecializer : : ReduceJSLoadContext ( Node * node ) { <nl> / / before the function to which it belongs has initialized the slot . <nl> / / We must be conservative and check if the value in the slot is currently the <nl> / / hole or undefined . If it is neither of these , then it must be initialized . <nl> - if ( value - > IsUndefined ( ) | | value - > IsTheHole ( ) ) return Reducer : : NoChange ( ) ; <nl> + if ( value - > IsUndefined ( ) | | value - > IsTheHole ( ) ) { <nl> + return Reducer : : NoChange ( ) ; <nl> + } <nl> <nl> / / Success . The context load can be replaced with the constant . <nl> / / TODO ( titzer ) : record the specialization for sharing code across multiple <nl> / / contexts that have the same value in the corresponding context slot . <nl> return Reducer : : Replace ( jsgraph_ - > Constant ( value ) ) ; <nl> } <nl> + <nl> + <nl> + Reduction JSContextSpecializer : : ReduceJSStoreContext ( Node * node ) { <nl> + DCHECK_EQ ( IrOpcode : : kJSStoreContext , node - > opcode ( ) ) ; <nl> + <nl> + ValueMatcher < Handle < Context > > match ( NodeProperties : : GetValueInput ( node , 0 ) ) ; <nl> + / / If the context is not constant , no reduction can occur . <nl> + if ( ! match . HasValue ( ) ) { <nl> + return Reducer : : NoChange ( ) ; <nl> + } <nl> + <nl> + ContextAccess access = OpParameter < ContextAccess > ( node ) ; <nl> + <nl> + / / The access does not have to look up a parent , nothing to fold . <nl> + if ( access . depth ( ) = = 0 ) { <nl> + return Reducer : : NoChange ( ) ; <nl> + } <nl> + <nl> + / / Find the right parent context . <nl> + Context * context = * match . Value ( ) ; <nl> + for ( int i = access . depth ( ) ; i > 0 ; - - i ) { <nl> + context = context - > previous ( ) ; <nl> + } <nl> + <nl> + Operator * op = jsgraph_ - > javascript ( ) - > StoreContext ( 0 , access . index ( ) ) ; <nl> + node - > set_op ( op ) ; <nl> + Handle < Object > new_context_handle = Handle < Object > ( context , info_ - > isolate ( ) ) ; <nl> + node - > ReplaceInput ( 0 , jsgraph_ - > Constant ( new_context_handle ) ) ; <nl> + <nl> + return Reducer : : Changed ( node ) ; <nl> + } <nl> } <nl> } <nl> } / / namespace v8 : : internal : : compiler <nl> mmm a / src / compiler / js - context - specialization . h <nl> ppp b / src / compiler / js - context - specialization . h <nl> namespace internal { <nl> namespace compiler { <nl> <nl> / / Specializes a given JSGraph to a given context , potentially constant folding <nl> - / / some { LoadContext } nodes . <nl> + / / some { LoadContext } nodes or strength reducing some { StoreContext } nodes . <nl> class JSContextSpecializer { <nl> public : <nl> JSContextSpecializer ( CompilationInfo * info , JSGraph * jsgraph , Node * context ) <nl> class JSContextSpecializer { <nl> <nl> void SpecializeToContext ( ) ; <nl> Reduction ReduceJSLoadContext ( Node * node ) ; <nl> + Reduction ReduceJSStoreContext ( Node * node ) ; <nl> <nl> private : <nl> CompilationInfo * info_ ; <nl> mmm a / test / cctest / compiler / test - js - context - specialization . cc <nl> ppp b / test / cctest / compiler / test - js - context - specialization . cc <nl> TEST ( ReduceJSLoadContext ) { <nl> <nl> / / Make a context and initialize it a bit for this test . <nl> Handle < Context > native = t . factory ( ) - > NewNativeContext ( ) ; <nl> - Handle < Context > ctx1 = t . factory ( ) - > NewNativeContext ( ) ; <nl> - Handle < Context > ctx2 = t . factory ( ) - > NewNativeContext ( ) ; <nl> - ctx2 - > set_previous ( * ctx1 ) ; <nl> - ctx1 - > set_previous ( * native ) ; <nl> + Handle < Context > subcontext1 = t . factory ( ) - > NewNativeContext ( ) ; <nl> + Handle < Context > subcontext2 = t . factory ( ) - > NewNativeContext ( ) ; <nl> + subcontext2 - > set_previous ( * subcontext1 ) ; <nl> + subcontext1 - > set_previous ( * native ) ; <nl> Handle < Object > expected = t . factory ( ) - > InternalizeUtf8String ( " gboy ! " ) ; <nl> const int slot = Context : : GLOBAL_OBJECT_INDEX ; <nl> native - > set ( slot , * expected ) ; <nl> <nl> Node * const_context = t . jsgraph ( ) - > Constant ( native ) ; <nl> + Node * deep_const_context = t . jsgraph ( ) - > Constant ( subcontext2 ) ; <nl> Node * param_context = t . NewNode ( t . common ( ) - > Parameter ( 0 ) , start ) ; <nl> JSContextSpecializer spec ( t . info ( ) , t . jsgraph ( ) , const_context ) ; <nl> <nl> { <nl> / / Mutable slot , constant context , depth = 0 = > do nothing . <nl> - t . info ( ) - > SetContext ( native ) ; <nl> Node * load = t . NewNode ( t . javascript ( ) - > LoadContext ( 0 , 0 , false ) , <nl> - const_context , start , start ) ; <nl> + const_context , const_context , start ) ; <nl> Reduction r = spec . ReduceJSLoadContext ( load ) ; <nl> CHECK ( ! r . Changed ( ) ) ; <nl> } <nl> <nl> { <nl> / / Mutable slot , non - constant context , depth = 0 = > do nothing . <nl> - t . info ( ) - > SetContext ( native ) ; <nl> Node * load = t . NewNode ( t . javascript ( ) - > LoadContext ( 0 , 0 , false ) , <nl> - param_context , start , start ) ; <nl> + param_context , param_context , start ) ; <nl> Reduction r = spec . ReduceJSLoadContext ( load ) ; <nl> CHECK ( ! r . Changed ( ) ) ; <nl> } <nl> <nl> { <nl> - / / Mutable slot , non - constant context , depth > 0 = > fold - in parent context . <nl> - t . info ( ) - > SetContext ( ctx2 ) ; <nl> + / / Mutable slot , constant context , depth > 0 = > fold - in parent context . <nl> Node * load = t . NewNode ( <nl> t . javascript ( ) - > LoadContext ( 2 , Context : : GLOBAL_EVAL_FUN_INDEX , false ) , <nl> - param_context , start , start ) ; <nl> + deep_const_context , deep_const_context , start ) ; <nl> Reduction r = spec . ReduceJSLoadContext ( load ) ; <nl> CHECK ( r . Changed ( ) ) ; <nl> - CHECK_EQ ( IrOpcode : : kHeapConstant , r . replacement ( ) - > InputAt ( 0 ) - > opcode ( ) ) ; <nl> - ValueMatcher < Handle < Context > > match ( r . replacement ( ) - > InputAt ( 0 ) ) ; <nl> + Node * new_context_input = NodeProperties : : GetValueInput ( r . replacement ( ) , 0 ) ; <nl> + CHECK_EQ ( IrOpcode : : kHeapConstant , new_context_input - > opcode ( ) ) ; <nl> + ValueMatcher < Handle < Context > > match ( new_context_input ) ; <nl> CHECK_EQ ( * native , * match . Value ( ) ) ; <nl> ContextAccess access = static_cast < Operator1 < ContextAccess > * > ( <nl> r . replacement ( ) - > op ( ) ) - > parameter ( ) ; <nl> TEST ( ReduceJSLoadContext ) { <nl> } <nl> <nl> { <nl> - / / Immutable slot , constant context = > specialize . <nl> - t . info ( ) - > SetContext ( native ) ; <nl> + / / Immutable slot , constant context , depth = 0 = > specialize . <nl> Node * load = t . NewNode ( t . javascript ( ) - > LoadContext ( 0 , slot , true ) , <nl> - const_context , start , start ) ; <nl> + const_context , const_context , start ) ; <nl> Reduction r = spec . ReduceJSLoadContext ( load ) ; <nl> CHECK ( r . Changed ( ) ) ; <nl> CHECK ( r . replacement ( ) ! = load ) ; <nl> TEST ( ReduceJSLoadContext ) { <nl> CHECK_EQ ( * expected , * match . Value ( ) ) ; <nl> } <nl> <nl> + / / TODO ( titzer ) : test with other kinds of contexts , e . g . a function context . <nl> + / / TODO ( sigurds ) : test that loads below create context are not optimized <nl> + } <nl> + <nl> + <nl> + TEST ( ReduceJSStoreContext ) { <nl> + ContextSpecializationTester t ; <nl> + <nl> + Node * start = t . NewNode ( t . common ( ) - > Start ( 0 ) ) ; <nl> + t . graph ( ) - > SetStart ( start ) ; <nl> + <nl> + / / Make a context and initialize it a bit for this test . <nl> + Handle < Context > native = t . factory ( ) - > NewNativeContext ( ) ; <nl> + Handle < Context > subcontext1 = t . factory ( ) - > NewNativeContext ( ) ; <nl> + Handle < Context > subcontext2 = t . factory ( ) - > NewNativeContext ( ) ; <nl> + subcontext2 - > set_previous ( * subcontext1 ) ; <nl> + subcontext1 - > set_previous ( * native ) ; <nl> + Handle < Object > expected = t . factory ( ) - > InternalizeUtf8String ( " gboy ! " ) ; <nl> + const int slot = Context : : GLOBAL_OBJECT_INDEX ; <nl> + native - > set ( slot , * expected ) ; <nl> + <nl> + Node * const_context = t . jsgraph ( ) - > Constant ( native ) ; <nl> + Node * deep_const_context = t . jsgraph ( ) - > Constant ( subcontext2 ) ; <nl> + Node * param_context = t . NewNode ( t . common ( ) - > Parameter ( 0 ) , start ) ; <nl> + JSContextSpecializer spec ( t . info ( ) , t . jsgraph ( ) , const_context ) ; <nl> + <nl> { <nl> - / / Immutable slot , non - constant context = > specialize . <nl> - t . info ( ) - > SetContext ( native ) ; <nl> - Node * load = t . NewNode ( t . javascript ( ) - > LoadContext ( 0 , slot , true ) , <nl> - param_context , start , start ) ; <nl> - Reduction r = spec . ReduceJSLoadContext ( load ) ; <nl> - CHECK ( r . Changed ( ) ) ; <nl> - CHECK ( r . replacement ( ) ! = load ) ; <nl> + / / Mutable slot , constant context , depth = 0 = > do nothing . <nl> + Node * load = t . NewNode ( t . javascript ( ) - > StoreContext ( 0 , 0 ) , const_context , <nl> + const_context , start ) ; <nl> + Reduction r = spec . ReduceJSStoreContext ( load ) ; <nl> + CHECK ( ! r . Changed ( ) ) ; <nl> + } <nl> <nl> - ValueMatcher < Handle < Object > > match ( r . replacement ( ) ) ; <nl> - CHECK ( match . HasValue ( ) ) ; <nl> - CHECK_EQ ( * expected , * match . Value ( ) ) ; <nl> + { <nl> + / / Mutable slot , non - constant context , depth = 0 = > do nothing . <nl> + Node * load = t . NewNode ( t . javascript ( ) - > StoreContext ( 0 , 0 ) , param_context , <nl> + param_context , start ) ; <nl> + Reduction r = spec . ReduceJSStoreContext ( load ) ; <nl> + CHECK ( ! r . Changed ( ) ) ; <nl> } <nl> <nl> - / / TODO ( titzer ) : test with other kinds of contexts , e . g . a function context . <nl> - / / TODO ( sigurds ) : test that loads below create context are not optimized <nl> + { <nl> + / / Immutable slot , constant context , depth = 0 = > do nothing . <nl> + Node * load = t . NewNode ( t . javascript ( ) - > StoreContext ( 0 , slot ) , const_context , <nl> + const_context , start ) ; <nl> + Reduction r = spec . ReduceJSStoreContext ( load ) ; <nl> + CHECK ( ! r . Changed ( ) ) ; <nl> + } <nl> + <nl> + { <nl> + / / Mutable slot , constant context , depth > 0 = > fold - in parent context . <nl> + Node * load = t . NewNode ( <nl> + t . javascript ( ) - > StoreContext ( 2 , Context : : GLOBAL_EVAL_FUN_INDEX ) , <nl> + deep_const_context , deep_const_context , start ) ; <nl> + Reduction r = spec . ReduceJSStoreContext ( load ) ; <nl> + CHECK ( r . Changed ( ) ) ; <nl> + Node * new_context_input = NodeProperties : : GetValueInput ( r . replacement ( ) , 0 ) ; <nl> + CHECK_EQ ( IrOpcode : : kHeapConstant , new_context_input - > opcode ( ) ) ; <nl> + ValueMatcher < Handle < Context > > match ( new_context_input ) ; <nl> + CHECK_EQ ( * native , * match . Value ( ) ) ; <nl> + ContextAccess access = static_cast < Operator1 < ContextAccess > * > ( <nl> + r . replacement ( ) - > op ( ) ) - > parameter ( ) ; <nl> + CHECK_EQ ( Context : : GLOBAL_EVAL_FUN_INDEX , access . index ( ) ) ; <nl> + CHECK_EQ ( 0 , access . depth ( ) ) ; <nl> + CHECK_EQ ( false , access . immutable ( ) ) ; <nl> + } <nl> } <nl> <nl> <nl> TEST ( SpecializeToContext ) { <nl> { <nl> / / Check that SpecializeToContext ( ) replaces values and forwards effects <nl> / / correctly , and folds values from constant and non - constant contexts <nl> - Node * effect_in = t . NewNode ( t . common ( ) - > Start ( 0 ) ) ; <nl> + Node * effect_in = start ; <nl> Node * load = t . NewNode ( t . javascript ( ) - > LoadContext ( 0 , slot , true ) , <nl> - const_context , const_context , effect_in , start ) ; <nl> + const_context , const_context , effect_in ) ; <nl> <nl> <nl> Node * value_use = t . ChangeTaggedToInt32 ( load ) ; <nl> Node * other_load = t . NewNode ( t . javascript ( ) - > LoadContext ( 0 , slot , true ) , <nl> - param_context , param_context , load , start ) ; <nl> + param_context , param_context , load ) ; <nl> Node * effect_use = other_load ; <nl> Node * other_use = t . ChangeTaggedToInt32 ( other_load ) ; <nl> <nl> + Node * add = t . NewNode ( t . javascript ( ) - > Add ( ) , value_use , other_use , <nl> + param_context , other_load , start ) ; <nl> + <nl> + Node * ret = t . NewNode ( t . common ( ) - > Return ( ) , add , effect_use , start ) ; <nl> + Node * end = t . NewNode ( t . common ( ) - > End ( ) , ret ) ; <nl> + USE ( end ) ; <nl> + t . graph ( ) - > SetEnd ( end ) ; <nl> + <nl> / / Double check the above graph is what we expect , or the test is broken . <nl> CheckEffectInput ( effect_in , load ) ; <nl> CheckEffectInput ( load , effect_use ) ; <nl>
Update and extend context specialization .
v8/v8
055fe8c3e9954793f1216302163b16795139069c
2014-08-08T11:05:31Z
mmm a / docs / docs / imaging . xml <nl> ppp b / docs / docs / imaging . xml <nl> <nl> <nl> < p > <nl> Note that you can do the reverse conversion , from dlib to OpenCV , <nl> - using the < a href = " # toMat " > toMat < / a > routine . Also note that you <nl> - have to # include OpenCV ' s header before you # include dlib / opencv . h . <nl> + using the < a href = " # toMat " > toMat < / a > routine . <nl> < / p > <nl> < / description > <nl> <nl> <nl> This is done by setting up the Mat object to point to the same memory as the dlib image . <nl> < p > <nl> Note that you can do the reverse conversion , from OpenCV to dlib , <nl> - using the < a href = " # cv_image " > cv_image < / a > object . Also note that you <nl> - have to # include OpenCV ' s header before you # include dlib / opencv . h . <nl> + using the < a href = " # cv_image " > cv_image < / a > object . <nl> < / p > <nl> < / description > <nl> <nl>
updated docs
davisking/dlib
bb352454f514f8756cfe170f9728e5c929db8852
2014-10-12T17:18:53Z
mmm a / examples / objective - c / helloworld / HelloWorld . podspec <nl> ppp b / examples / objective - c / helloworld / HelloWorld . podspec <nl> Pod : : Spec . new do | s | <nl> s . version = " 0 . 0 . 1 " <nl> s . license = " New BSD " <nl> <nl> - s . ios . deployment_target = " 6 . 0 " <nl> - s . osx . deployment_target = " 10 . 8 " <nl> + s . ios . deployment_target = " 7 . 1 " <nl> + s . osx . deployment_target = " 10 . 9 " <nl> <nl> # Base directory where the . proto files are . <nl> src = " . . / . . / protos " <nl> <nl> - # Directory where the generated files will be place . <nl> + # Directory where the generated files will be placed . <nl> dir = " Pods / " + s . name <nl> <nl> # Run protoc with the Objective - C and gRPC plugins to generate protocol messages and gRPC clients . <nl> Pod : : Spec . new do | s | <nl> ms . source_files = " # { dir } / * . pbobjc . { h , m } " , " # { dir } / * * / * . pbobjc . { h , m } " <nl> ms . header_mappings_dir = dir <nl> ms . requires_arc = false <nl> - ms . dependency " Protobuf " , " ~ > 3 . 0 . 0 - alpha - 3 " <nl> + ms . dependency " Protobuf " , " ~ > 3 . 0 . 0 - alpha - 4 " <nl> end <nl> <nl> s . subspec " Services " do | ss | <nl> ss . source_files = " # { dir } / * . pbrpc . { h , m } " , " # { dir } / * * / * . pbrpc . { h , m } " <nl> ss . header_mappings_dir = dir <nl> ss . requires_arc = true <nl> - ss . dependency " gRPC " , " ~ > 0 . 6 " <nl> + ss . dependency " gRPC " , " ~ > 0 . 11 " <nl> ss . dependency " # { s . name } / Messages " <nl> end <nl> end <nl> mmm a / examples / objective - c / helloworld / Podfile <nl> ppp b / examples / objective - c / helloworld / Podfile <nl> <nl> source ' https : / / github . com / CocoaPods / Specs . git ' <nl> platform : ios , ' 8 . 0 ' <nl> <nl> + pod ' Protobuf ' , : path = > " . . / . . / . . / third_party / protobuf " <nl> + pod ' gRPC ' , : path = > " . . / . . / . . " <nl> + <nl> target ' HelloWorld ' do <nl> # Depend on the generated HelloWorld library . <nl> pod ' HelloWorld ' , : path = > ' . ' <nl>
Fix example pod files
grpc/grpc
dfe91b547162f1cbedf13a780d9aaff439ac7137
2015-10-13T01:20:20Z
mmm a / tensorflow / tensorboard / components / vz - histogram - timeseries / vz - histogram - timeseries . html <nl> ppp b / tensorflow / tensorboard / components / vz - histogram - timeseries / vz - histogram - timeseries . html <nl> <nl> <nl> var svg = d3 . select ( svgNode ) <nl> <nl> - var svgTransition = svg . transition ( ) . duration ( duration ) <nl> - . attr ( " width " , outerWidth ) <nl> - . attr ( " height " , outerHeight ) ; <nl> + var svgTransition = svg . transition ( ) . duration ( duration ) ; <nl> <nl> var g = svg . select ( " g " ) <nl> . classed ( " small " , function ( ) { return ( width > 0 & & width < = 150 ) ; } ) <nl>
Stop having the vz - histogram - timeseries modify its own svg width / height .
tensorflow/tensorflow
3fb9963830f3249f4c81d2558aa8b1b89f8796fa
2016-08-30T23:16:35Z
mmm a / tensorflow / python / kernel_tests / BUILD <nl> ppp b / tensorflow / python / kernel_tests / BUILD <nl> tf_py_test ( <nl> " / / tensorflow / python : math_ops " , <nl> " / / tensorflow / python : framework_for_generated_wrappers " , <nl> ] , <nl> + tags = [ " no_windows_gpu " ] , <nl> ) <nl> <nl> tf_py_test ( <nl>
Disable bincount_op_test on windows gpu .
tensorflow/tensorflow
fd4540ab3ccf7346c5e53d17b58ab76884a49799
2019-03-05T21:33:45Z
mmm a / lib / SILOptimizer / Utils / ConstantFolding . cpp <nl> ppp b / lib / SILOptimizer / Utils / ConstantFolding . cpp <nl> <nl> # include " swift / SIL / SILBuilder . h " <nl> # include " swift / SILOptimizer / Utils / CastOptimizer . h " <nl> # include " swift / SILOptimizer / Utils / Local . h " <nl> + # include " swift / SIL / InstructionUtils . h " <nl> # include " llvm / ADT / APFloat . h " <nl> # include " llvm / ADT / APSInt . h " <nl> # include " llvm / ADT / Statistic . h " <nl> static bool <nl> constantFoldGlobalStringTablePointerBuiltin ( BuiltinInst * bi , <nl> bool enableDiagnostics ) { <nl> / / Look through string initializer to extract the string_literal instruction . <nl> - SILValue builtinOperand = bi - > getOperand ( 0 ) ; <nl> + / / <nl> + / / We allow for a single borrow to be stripped here if we are here in <nl> + / / [ ossa ] . The begin borrow occurs b / c SILGen treats builtins as having <nl> + / / arguments with a + 0 convention ( implying a borrow ) . <nl> + SILValue builtinOperand = stripBorrow ( bi - > getOperand ( 0 ) ) ; <nl> SILFunction * caller = bi - > getFunction ( ) ; <nl> <nl> FullApplySite stringInitSite = FullApplySite : : isa ( builtinOperand ) ; <nl> mmm a / test / SILOptimizer / diagnostic_constant_propagation . swift <nl> ppp b / test / SILOptimizer / diagnostic_constant_propagation . swift <nl> <nl> / / RUN : % target - swift - frontend - emit - sil - primary - file % s - o / dev / null - verify <nl> + / / RUN : % target - swift - frontend - emit - sil - enable - ownership - stripping - after - serialization - primary - file % s - o / dev / null - verify <nl> / / <nl> / / These are tests for diagnostics produced by constant propagation pass . <nl> / / Due to the change in the implementation of Integer initializers some of the <nl>
[ global - string - table ] Fix for ownership .
apple/swift
534781ef8c565932fe6988a77d6c6a42bf5c7a95
2019-10-02T04:18:39Z
mmm a / tests / common . sh <nl> ppp b / tests / common . sh <nl> function build_sketches ( ) <nl> local build_arg = $ 3 <nl> local build_dir = build . tmp <nl> mkdir - p $ build_dir <nl> - rm - rf $ build_dir / * <nl> local build_cmd = " python tools / build . py - b generic - v - k - p $ PWD / $ build_dir $ build_arg " <nl> local sketches = $ ( find $ srcpath - name * . ino ) <nl> print_size_info > size . log <nl> export ARDUINO_IDE_PATH = $ arduino <nl> for sketch in $ sketches ; do <nl> + rm - rf $ build_dir / * <nl> local sketchdir = $ ( dirname $ sketch ) <nl> local sketchdirname = $ ( basename $ sketchdir ) <nl> local sketchname = $ ( basename $ sketch ) <nl>
Clean build directory after each sketch
esp8266/Arduino
aded314bded27ba41a4d613d0937b70bbfac3f68
2016-03-28T12:03:51Z
mmm a / tools / ldb_cmd_test . cc <nl> ppp b / tools / ldb_cmd_test . cc <nl> TEST_F ( LdbCmdTest , HexToString ) { <nl> auto actual = rocksdb : : LDBCommand : : HexToString ( inPair . first ) ; <nl> auto expected = inPair . second ; <nl> for ( unsigned int i = 0 ; i < actual . length ( ) ; i + + ) { <nl> - EXPECT_EQ ( expected [ i ] , static_cast < int > ( actual [ i ] ) ) ; <nl> + EXPECT_EQ ( expected [ i ] , static_cast < int > ( ( signed char ) actual [ i ] ) ) ; <nl> } <nl> auto reverse = rocksdb : : LDBCommand : : StringToHex ( actual ) ; <nl> EXPECT_STRCASEEQ ( inPair . first . c_str ( ) , reverse . c_str ( ) ) ; <nl>
cast to signed char in ldb_cmd_test for ppc64le
facebook/rocksdb
1f6f7e3e89fe68c603389a8363e07da1ea27f4d3
2016-12-12T22:39:18Z
mmm a / src / embind / embind . js <nl> ppp b / src / embind / embind . js <nl> function __embind_register_struct_field ( <nl> } ) ; <nl> } <nl> <nl> - function RegisteredPointer ( name , rawType , registeredClass , pointeeType , Handle , isSmartPointer , rawGetPointee , rawConstructor , rawDestructor ) { <nl> + function RegisteredPointer ( name , rawType , registeredClass , pointeeType , Handle , isConst , isSmartPointer , rawGetPointee , rawConstructor , rawDestructor ) { <nl> this . name = name ; <nl> this . rawType = rawType ; <nl> this . registeredClass = registeredClass ; <nl> this . pointeeType = pointeeType ; <nl> this . Handle = Handle ; / / < - - I think I can kill this <nl> + this . isConst = isConst ; <nl> this . isSmartPointer = isSmartPointer ; <nl> this . rawGetPointee = rawGetPointee ; <nl> this . rawConstructor = rawConstructor ; <nl> function __embind_register_class ( <nl> registeredClass , <nl> undefined , <nl> Handle , <nl> + false , <nl> false ) ; <nl> type . pointeeType = type ; / / : ( <nl> registerType ( rawType , type ) ; <nl> function __embind_register_class ( <nl> registeredClass , <nl> type , <nl> Handle , <nl> + false , <nl> false ) ) ; <nl> <nl> / / todo : implement const pointers ( no modification Javascript side ) <nl> function __embind_register_class ( <nl> registeredClass , <nl> type , <nl> Handle , <nl> + true , <nl> false ) ) ; <nl> <nl> type . constructor = createNamedFunction ( name , function ( ) { <nl> function __embind_register_class_function ( <nl> methodName , <nl> argCount , <nl> rawArgTypesAddr , <nl> + isConst , <nl> rawInvoker , <nl> memberFunctionSize , <nl> memberFunction <nl> function __embind_register_class_function ( <nl> } <nl> <nl> var ptr = validateThis ( this , classType , humanName ) ; <nl> + if ( ! isConst & & this . $ $ . registeredPointer . isConst ) { <nl> + throwBindingError ( ' Cannot call non - const method ' + humanName + ' on const reference ' ) ; <nl> + } <nl> <nl> var destructors = [ ] ; <nl> var args = new Array ( argCount + 1 ) ; <nl> function __embind_register_smart_ptr ( <nl> pointeeType . registeredClass , <nl> pointeeType , <nl> Handle , <nl> + false , <nl> true , <nl> rawGetPointee , <nl> rawConstructor , <nl> mmm a / system / include / emscripten / bind . h <nl> ppp b / system / include / emscripten / bind . h <nl> namespace emscripten { <nl> const char * methodName , <nl> unsigned argCount , <nl> TYPEID argTypes [ ] , <nl> + bool isConst , <nl> GenericFunction invoker , <nl> size_t memberFunctionSize , <nl> void * memberFunction ) ; <nl> namespace emscripten { <nl> methodName , <nl> args . count , <nl> args . types , <nl> + false , <nl> reinterpret_cast < GenericFunction > ( & MethodInvoker < ClassType , ReturnType , Args . . . > : : invoke ) , <nl> sizeof ( memberFunction ) , <nl> & memberFunction ) ; <nl> namespace emscripten { <nl> methodName , <nl> args . count , <nl> args . types , <nl> + true , <nl> reinterpret_cast < GenericFunction > ( & ConstMethodInvoker < ClassType , ReturnType , Args . . . > : : invoke ) , <nl> sizeof ( memberFunction ) , <nl> & memberFunction ) ; <nl> namespace emscripten { <nl> methodName , <nl> args . count , <nl> args . types , <nl> + false , <nl> reinterpret_cast < GenericFunction > ( & FunctionInvoker < ClassType , ReturnType , Args . . . > : : invoke ) , <nl> sizeof ( function ) , <nl> & function ) ; <nl> namespace emscripten { <nl> methodName , <nl> args . count , <nl> args . types , <nl> + true , <nl> reinterpret_cast < GenericFunction > ( & FunctionInvoker < ClassType , ReturnType , Args . . . > : : invoke ) , <nl> sizeof ( function ) , <nl> & function ) ; <nl>
Throw an error if calling non - const methods on const objects .
emscripten-core/emscripten
8a58711ab61ba62e10c87e7a1d873c38ff0757e0
2013-04-12T11:25:35Z
mmm a / CHANGELOG <nl> ppp b / CHANGELOG <nl> v1 . 1 . 0 ( XXXX - XX - XX ) <nl> <nl> * fixed issue # 309 : renamed stub " import " button from web interface <nl> <nl> + * fixed issue # 307 : added WaitForSync column in collections list in in web interface <nl> + <nl> * fixed issue # 306 : naming in web interface <nl> <nl> * fixed issue # 304 : do not clear AQL query text input when switching tabs in <nl> mmm a / html / admin / index . html <nl> ppp b / html / admin / index . html <nl> <nl> < th > Name < / th > <nl> < th > Type < / th > <nl> < th > Status < / th > <nl> + < th > WaitForSync < / th > <nl> < th > Datafile Sizes < / th > <nl> < th > Number of Documents < / th > <nl> < / tr > <nl> mmm a / html / admin / js / master . js <nl> ppp b / html / admin / js / master . js <nl> var collectionTable = $ ( ' # collectionsTableID ' ) . dataTable ( { <nl> " bAutoWidth " : false , <nl> " iDisplayLength " : - 1 , <nl> " bJQueryUI " : true , <nl> - " aoColumns " : [ { " sWidth " : " 150px " , " bSortable " : false , " sClass " : " leftCell " } , { " sWidth " : " 200px " } , { " sWidth " : " 200px " } , { " sWidth " : " 150px " } , null , { " sWidth " : " 200px " } , { " sWidth " : " 200px " , " sClass " : " rightCell " } ] , <nl> - " aoColumnDefs " : [ { " sClass " : " alignRight " , " aTargets " : [ 5 , 6 ] } ] , <nl> + " aoColumns " : [ { " sWidth " : " 150px " , " bSortable " : false , " sClass " : " leftCell " } , { " sWidth " : " 200px " } , { " sWidth " : " 200px " } , { " sWidth " : " 150px " } , null , { " sWidth " : " 100px " } , { " sWidth " : " 200px " } , { " sWidth " : " 200px " , " sClass " : " rightCell " } ] , <nl> + " aoColumnDefs " : [ { " sClass " : " alignRight " , " aTargets " : [ 6 , 7 ] } ] , <nl> " oLanguage " : { " sEmptyTable " : " No collections " } <nl> } ) ; <nl> <nl> function drawCollectionsTable ( ) { <nl> else if ( tempStatus = = 2 ) { <nl> tempStatus = " unloaded " ; <nl> items . push ( [ ' < button class = " enabled " id = " delete " > < img src = " / _admin / html / media / icons / round_minus_icon16 . png " width = " 16 " height = " 16 " > < / button > < button class = " enabled " id = " load " > < img src = " / _admin / html / media / icons / connect_icon16 . png " width = " 16 " height = " 16 " > < / button > < button > < img src = " / _admin / html / media / icons / zoom_icon16_nofunction . png " width = " 16 " height = " 16 " class = " nofunction " > < / img > < / button > < button > < img src = " / _admin / html / media / icons / doc_edit_icon16_nofunction . png " width = " 16 " height = " 16 " class = " nofunction " > < / img > < / button > ' , <nl> - val . id , val . name , collectionType ( val ) , tempStatus , " - " , " - " ] ) ; <nl> + val . id , val . name , collectionType ( val ) , tempStatus , " " , " - " , " - " ] ) ; <nl> } <nl> else if ( tempStatus = = 3 ) { <nl> tempStatus = " < font color = \ " green \ " > loaded < / font > " ; <nl> var alive ; <nl> var size ; <nl> + var waitForSync ; <nl> <nl> $ . ajax ( { <nl> type : " GET " , <nl> function drawCollectionsTable ( ) { <nl> success : function ( data ) { <nl> size = data . figures . journals . fileSize + data . figures . datafiles . fileSize ; <nl> alive = data . figures . alive . count ; <nl> + waitForSync = data . waitForSync ; <nl> } , <nl> error : function ( data ) { <nl> } <nl> } ) ; <nl> <nl> items . push ( [ ' < button class = " enabled " id = " delete " > < img src = " / _admin / html / media / icons / round_minus_icon16 . png " width = " 16 " height = " 16 " title = " Delete " > < / button > < button class = " enabled " id = " unload " > < img src = " / _admin / html / media / icons / not_connected_icon16 . png " width = " 16 " height = " 16 " title = " Unload " > < / button > < button class = " enabled " id = " showdocs " > < img src = " / _admin / html / media / icons / zoom_icon16 . png " width = " 16 " height = " 16 " title = " Show Documents " > < / button > < button class = " enabled " id = " edit " title = " Edit " > < img src = " / _admin / html / media / icons / doc_edit_icon16 . png " width = " 16 " height = " 16 " > < / button > ' , <nl> - val . id , val . name , collectionType ( val ) , tempStatus , bytesToSize ( size ) , alive ] ) ; <nl> + val . id , val . name , collectionType ( val ) , tempStatus , waitForSync ? " yes " : " no " , bytesToSize ( size ) , alive ] ) ; <nl> } <nl> else if ( tempStatus = = 4 ) { <nl> tempStatus = " in the process of being unloaded " ; <nl> items . push ( [ ' < button id = " delete " > < img src = " / _admin / html / media / icons / round_minus_icon16_nofunction . png " class = " nofunction " width = " 16 " height = " 16 " > < / button > < button class = " enabled " id = " load " > < img src = " / _admin / html / media / icons / connect_icon16 . png " width = " 16 " height = " 16 " > < / button > < button > < img src = " / _admin / html / media / icons / zoom_icon16_nofunction . png " width = " 16 " height = " 16 " class = " nofunction " > < / img > < / button > < button > < img src = " / _admin / html / media / icons / doc_edit_icon16_nofunction . png " width = " 16 " height = " 16 " class = " nofunction " > < / img > < / button > ' , <nl> - val . id , val . name , collectionType ( val ) , tempStatus , " - " , " - " ] ) ; <nl> + val . id , val . name , collectionType ( val ) , tempStatus , " " , " - " , " - " ] ) ; <nl> } <nl> else if ( tempStatus = = 5 ) { <nl> tempStatus = " deleted " ; <nl> - items . push ( [ " " , val . id , val . name , collectionType ( val ) , tempStatus , " - " , " - " ] ) ; <nl> + items . push ( [ " " , val . id , val . name , collectionType ( val ) , tempStatus , " " , " - " , " - " ] ) ; <nl> } <nl> / * else { <nl> tempStatus = " corrupted " ; <nl>
issue
arangodb/arangodb
634f20ed4eb611ad486b7df3972095845fa3f0c9
2012-12-01T00:26:37Z
mmm a / src / pprint / pprint . cc <nl> ppp b / src / pprint / pprint . cc <nl> class document_visitor_t { <nl> virtual void operator ( ) ( const nest_t & ) const = 0 ; <nl> } ; <nl> <nl> - class document_t { <nl> - public : <nl> - virtual ~ document_t ( ) { } <nl> - virtual unsigned int width ( ) const = 0 ; <nl> - virtual void visit ( const document_visitor_t & v ) const = 0 ; <nl> - } ; <nl> - <nl> struct text_t : public document_t { <nl> std : : string text ; <nl> <nl> mmm a / src / pprint / pprint . hpp <nl> ppp b / src / pprint / pprint . hpp <nl> <nl> <nl> namespace pprint { <nl> <nl> - class document_t ; <nl> + class document_visitor_t ; <nl> + class document_t { <nl> + public : <nl> + virtual ~ document_t ( ) { } <nl> + virtual unsigned int width ( ) const = 0 ; <nl> + virtual void visit ( const document_visitor_t & v ) const = 0 ; <nl> + virtual std : : string str ( ) const = 0 ; <nl> + } ; <nl> + <nl> typedef std : : shared_ptr < const document_t > doc_handle_t ; <nl> <nl> / / textual element <nl>
Expose ` document_t ` so we can use ` str ` .
rethinkdb/rethinkdb
f95196fbe9d8006bfb87fb147a254c8fff722132
2015-02-11T06:59:59Z
mmm a / tensorflow / core / framework / api_def . proto <nl> ppp b / tensorflow / core / framework / api_def . proto <nl> option cc_enable_arenas = true ; <nl> option java_outer_classname = " ApiDefProtos " ; <nl> option java_multiple_files = true ; <nl> option java_package = " org . tensorflow . framework " ; <nl> - option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / framework " ; <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / api_def_go_proto " ; <nl> import " tensorflow / core / framework / attr_value . proto " ; <nl> <nl> / / Used to specify and override the default API & behavior in the <nl> mmm a / tensorflow / core / framework / op_def . proto <nl> ppp b / tensorflow / core / framework / op_def . proto <nl> option cc_enable_arenas = true ; <nl> option java_outer_classname = " OpDefProtos " ; <nl> option java_multiple_files = true ; <nl> option java_package = " org . tensorflow . framework " ; <nl> - option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / framework " ; <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / op_def_go_proto " ; <nl> import " tensorflow / core / framework / attr_value . proto " ; <nl> import " tensorflow / core / framework / types . proto " ; <nl> <nl> mmm a / tensorflow / core / framework / tensor_shape . proto <nl> ppp b / tensorflow / core / framework / tensor_shape . proto <nl> option cc_enable_arenas = true ; <nl> option java_outer_classname = " TensorShapeProtos " ; <nl> option java_multiple_files = true ; <nl> option java_package = " org . tensorflow . framework " ; <nl> - option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / framework " ; <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / tensor_shape_go_proto " ; <nl> <nl> package tensorflow ; <nl> <nl> mmm a / tensorflow / core / framework / types . proto <nl> ppp b / tensorflow / core / framework / types . proto <nl> option cc_enable_arenas = true ; <nl> option java_outer_classname = " TypesProtos " ; <nl> option java_multiple_files = true ; <nl> option java_package = " org . tensorflow . framework " ; <nl> - option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / framework " ; <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / types_go_proto " ; <nl> <nl> / / ( = = suppress_warning documentation - presence = = ) <nl> / / LINT . IfChange <nl> mmm a / tensorflow / core / protobuf / autotuning . proto <nl> ppp b / tensorflow / core / protobuf / autotuning . proto <nl> package tensorflow ; <nl> import " google / protobuf / any . proto " ; <nl> import " google / protobuf / duration . proto " ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> message CudnnVersion { <nl> int32 major = 1 ; <nl> int32 minor = 2 ; <nl> mmm a / tensorflow / core / protobuf / bfc_memory_map . proto <nl> ppp b / tensorflow / core / protobuf / bfc_memory_map . proto <nl> syntax = " proto3 " ; <nl> <nl> package tensorflow ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> / / Some of the data from AllocatorStats <nl> message MemAllocatorStats { <nl> int64 num_allocs = 1 ; <nl> message MemAllocatorStats { <nl> int64 peak_bytes_in_use = 3 ; <nl> int64 largest_alloc_size = 4 ; <nl> float fragmentation_metric = 5 ; <nl> - } ; <nl> + } <nl> <nl> message MemChunk { <nl> uint64 address = 1 ; <nl> message MemChunk { <nl> uint64 action_count = 7 ; <nl> bool in_use = 8 ; <nl> uint64 step_id = 9 ; <nl> - } ; <nl> + } <nl> <nl> message BinSummary { <nl> int32 bin = 1 ; <nl> message MemoryDump { <nl> repeated MemChunk chunk = 3 ; <nl> repeated SnapShot snap_shot = 4 ; <nl> MemAllocatorStats stats = 5 ; <nl> - } ; <nl> + } <nl> mmm a / tensorflow / core / protobuf / conv_autotuning . proto <nl> ppp b / tensorflow / core / protobuf / conv_autotuning . proto <nl> package tensorflow ; <nl> <nl> import " tensorflow / stream_executor / dnn . proto " ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> / / A convolution . Currently it ' s only used for logging . In the future , we may <nl> / / want to use it in the API as well . <nl> message ConvolutionProto { <nl> mmm a / tensorflow / core / protobuf / debug_event . proto <nl> ppp b / tensorflow / core / protobuf / debug_event . proto <nl> option java_outer_classname = " DebugEventProtos " ; <nl> option java_multiple_files = true ; <nl> option java_package = " org . tensorflow . util " ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> / / Available modes for extracting debugging information from a Tensor . <nl> / / TODO ( cais ) : Document the detailed column names and semantics in a separate <nl> / / markdown file once the implementation settles . <nl> mmm a / tensorflow / core / protobuf / device_filters . proto <nl> ppp b / tensorflow / core / protobuf / device_filters . proto <nl> option java_outer_classname = " DeviceFiltersProtos " ; <nl> option java_multiple_files = true ; <nl> option java_package = " org . tensorflow . distruntime " ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> / / This file contains protos to be used when defining a TensorFlow <nl> / / cluster . <nl> / / <nl> mmm a / tensorflow / core / protobuf / eager_service . proto <nl> ppp b / tensorflow / core / protobuf / eager_service . proto <nl> import " tensorflow / core / framework / versions . proto " ; <nl> import " tensorflow / core / protobuf / remote_tensor_handle . proto " ; <nl> import " tensorflow / core / protobuf / tensorflow_server . proto " ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> / / A proto representation of an eager operation . <nl> message Operation { <nl> / / A unique identifier for the operation . Set by the client so that the client <nl> mmm a / tensorflow / core / protobuf / graph_debug_info . proto <nl> ppp b / tensorflow / core / protobuf / graph_debug_info . proto <nl> option java_outer_classname = " GraphDebugInfoProtos " ; <nl> option java_multiple_files = true ; <nl> option java_package = " org . tensorflow . framework " ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> message GraphDebugInfo { <nl> / / This represents a file / line location in the source code . <nl> message FileLineCol { <nl> mmm a / tensorflow / core / protobuf / remote_tensor_handle . proto <nl> ppp b / tensorflow / core / protobuf / remote_tensor_handle . proto <nl> option java_outer_classname = " RemoteTensorHandleProtos " ; <nl> option java_multiple_files = true ; <nl> option java_package = " org . tensorflow . framework " ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> message ResourceDtypeAndShape { <nl> DataType dtype = 1 ; <nl> TensorShapeProto shape = 2 ; <nl> mmm a / tensorflow / core / protobuf / replay_log . proto <nl> ppp b / tensorflow / core / protobuf / replay_log . proto <nl> import " tensorflow / core / protobuf / master . proto " ; <nl> <nl> option cc_enable_arenas = true ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> / / Records the creation of a new replay session . We record the device listing <nl> / / here to capture the state of the cluster . <nl> message NewReplaySession { <nl> mmm a / tensorflow / core / protobuf / saved_object_graph . proto <nl> ppp b / tensorflow / core / protobuf / saved_object_graph . proto <nl> <nl> syntax = " proto3 " ; <nl> <nl> - import " tensorflow / core / protobuf / trackable_object_graph . proto " ; <nl> - import " tensorflow / core / protobuf / struct . proto " ; <nl> + package tensorflow ; <nl> + <nl> import " tensorflow / core / framework / tensor_shape . proto " ; <nl> import " tensorflow / core / framework / types . proto " ; <nl> - import " tensorflow / core / framework / versions . proto " ; <nl> import " tensorflow / core / framework / variable . proto " ; <nl> + import " tensorflow / core / framework / versions . proto " ; <nl> + import " tensorflow / core / protobuf / struct . proto " ; <nl> + import " tensorflow / core / protobuf / trackable_object_graph . proto " ; <nl> <nl> option cc_enable_arenas = true ; <nl> <nl> - package tensorflow ; <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> <nl> / / A SavedObjectGraph is part of object - based SavedModels in TF 2 . 0 . It <nl> / / describes the directed graph of Python objects ( or equivalent in other <nl> message SavedObject { <nl> / / graph . <nl> / / <nl> / / Note : currently only valid if kind = = " user_object " . <nl> - repeated TrackableObjectGraph . TrackableObject . ObjectReference <nl> - children = 1 ; <nl> + repeated TrackableObjectGraph . TrackableObject . ObjectReference children = 1 ; <nl> <nl> / / Removed when forking SavedObject from TrackableObjectGraph . <nl> reserved " attributes " ; <nl> mmm a / tensorflow / core / protobuf / struct . proto <nl> ppp b / tensorflow / core / protobuf / struct . proto <nl> syntax = " proto3 " ; <nl> <nl> package tensorflow ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> import " tensorflow / core / framework / tensor_shape . proto " ; <nl> import " tensorflow / core / framework / types . proto " ; <nl> <nl> mmm a / tensorflow / core / protobuf / trace_events . proto <nl> ppp b / tensorflow / core / protobuf / trace_events . proto <nl> option java_outer_classname = " TraceEventsProtos " ; <nl> option java_multiple_files = true ; <nl> option java_package = " org . tensorflow . framework " ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> / / A ' Trace ' contains metadata for the individual traces of a system . <nl> message Trace { <nl> / / The devices that this trace has information about . Maps from device_id to <nl> mmm a / tensorflow / core / protobuf / trackable_object_graph . proto <nl> ppp b / tensorflow / core / protobuf / trackable_object_graph . proto <nl> <nl> syntax = " proto3 " ; <nl> <nl> + package tensorflow ; <nl> + <nl> option cc_enable_arenas = true ; <nl> <nl> - package tensorflow ; <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> <nl> / / A TensorBundle addition which saves extra information about the objects which <nl> / / own variables , allowing for more robust checkpoint loading into modified <nl> mmm a / tensorflow / core / protobuf / transport_options . proto <nl> ppp b / tensorflow / core / protobuf / transport_options . proto <nl> syntax = " proto3 " ; <nl> <nl> package tensorflow ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " ; <nl> + <nl> / / Extra data needed on a non - RDMA RecvBufResponse . <nl> message RecvBufRespExtra { <nl> repeated bytes tensor_content = 1 ; <nl> - } ; <nl> + } <nl> mmm a / tensorflow / go / genop / generate . sh <nl> ppp b / tensorflow / go / genop / generate . sh <nl> fi <nl> # Ensure that protoc - gen - go is available in $ PATH <nl> # Since $ { PROTOC } will require it . <nl> export PATH = $ PATH : $ { GOPATH } / bin <nl> - mkdir - p . / internal / proto <nl> - $ { PROTOC } \ <nl> - - I $ { TF_DIR } \ <nl> - - - go_out = . / internal / proto \ <nl> - $ { TF_DIR } / tensorflow / core / framework / * . proto <nl> + mkdir - p . . / vendor <nl> + for FILE in $ { TF_DIR } / tensorflow / core / framework / * . proto \ <nl> + $ { TF_DIR } / tensorflow / core / protobuf / * . proto \ <nl> + $ { TF_DIR } / tensorflow / stream_executor / * . proto ; do <nl> + $ { PROTOC } \ <nl> + - I $ { TF_DIR } \ <nl> + - - go_out = . . / vendor \ <nl> + $ FILE <nl> + done <nl> mmm a / tensorflow / go / genop / internal / api_def_map . go <nl> ppp b / tensorflow / go / genop / internal / api_def_map . go <nl> import ( <nl> " unsafe " <nl> <nl> " github . com / golang / protobuf / proto " <nl> - adpb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core / framework / api_def_go_proto " <nl> - odpb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core / framework / op_def_go_proto " <nl> + adpb " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / api_def_go_proto " <nl> + odpb " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / op_def_go_proto " <nl> ) <nl> <nl> / / Encapsulates a collection of API definitions . <nl> mmm a / tensorflow / go / genop / internal / genop . go <nl> ppp b / tensorflow / go / genop / internal / genop . go <nl> import ( <nl> " unsafe " <nl> <nl> " github . com / golang / protobuf / proto " <nl> - adpb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core / framework / api_def_go_proto " <nl> - odpb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core / framework / op_def_go_proto " <nl> + adpb " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / api_def_go_proto " <nl> + odpb " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / op_def_go_proto " <nl> ) <nl> <nl> / / GenerateFunctionsForRegisteredOps writes a Go source code file to w <nl> mmm a / tensorflow / go / genop / internal / genop_test . go <nl> ppp b / tensorflow / go / genop / internal / genop_test . go <nl> import ( <nl> " testing " <nl> <nl> " github . com / golang / protobuf / proto " <nl> - adpb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core / framework / api_def_go_proto " <nl> - odpb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core / framework / op_def_go_proto " <nl> + adpb " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / api_def_go_proto " <nl> + odpb " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / op_def_go_proto " <nl> ) <nl> <nl> / / Creates an ApiDef based on opdef and applies overrides <nl> mmm a / tensorflow / go / saved_model . go <nl> ppp b / tensorflow / go / saved_model . go <nl> import ( <nl> <nl> " github . com / golang / protobuf / proto " <nl> <nl> - tfpb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core " <nl> + tfpb " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " <nl> ) <nl> <nl> / / # include < stdlib . h > <nl> mmm a / tensorflow / go / signature . go <nl> ppp b / tensorflow / go / signature . go <nl> limitations under the License . <nl> <nl> package tensorflow <nl> <nl> - import tfpb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core " <nl> + import tfpb " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " <nl> <nl> / / # include " tensorflow / c / c_api . h " <nl> import " C " <nl> mmm a / tensorflow / go / signature_test . go <nl> ppp b / tensorflow / go / signature_test . go <nl> import ( <nl> " fmt " <nl> " testing " <nl> <nl> - tspb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core / framework / tensor_shape_go_proto " <nl> - typb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core / framework / types_go_proto " <nl> - tfpb " github . com / tensorflow / tensorflow / tensorflow / go / genop / internal / proto / github . com / tensorflow / tensorflow / tensorflow / go / core " <nl> + tspb " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / tensor_shape_go_proto " <nl> + typb " github . com / tensorflow / tensorflow / tensorflow / go / core / framework / types_go_proto " <nl> + tfpb " github . com / tensorflow / tensorflow / tensorflow / go / core / protobuf " <nl> ) <nl> <nl> func TestSignatureFromProto ( t * testing . T ) { <nl> mmm a / tensorflow / stream_executor / dnn . proto <nl> ppp b / tensorflow / stream_executor / dnn . proto <nl> syntax = " proto3 " ; <nl> <nl> package stream_executor . dnn ; <nl> <nl> + option go_package = " github . com / tensorflow / tensorflow / tensorflow / go / stream_executor " ; <nl> + <nl> / / Specifies the data type used by an operation . <nl> enum DataType { <nl> kFloat = 0 ; <nl>
Merge pull request from jhseu : go_fix
tensorflow/tensorflow
70e675ebcf44a86a1a7b0b0070bfc116e26e3a32
2020-02-04T01:45:49Z
mmm a / README . md <nl> ppp b / README . md <nl> For previous versions , please read : <nl> <nl> # # V3 changes <nl> <nl> + * v3 . 0 , 2020 - 01 - 05 , For [ # 460 ] [ bug # 460 ] , fix ipv6 hostport parsing bug . 3 . 0 . 94 <nl> * v3 . 0 , 2020 - 01 - 05 , For [ # 460 ] [ bug # 460 ] , fix ipv6 intranet address filter bug . 3 . 0 . 93 <nl> * v3 . 0 , 2020 - 01 - 05 , For [ # 1543 ] [ bug # 1543 ] , use getpeername to retrieve client ip . 3 . 0 . 92 <nl> * v3 . 0 , 2020 - 01 - 02 , For [ # 1042 ] [ bug # 1042 ] , improve test coverage for config . 3 . 0 . 91 <nl> mmm a / trunk / src / core / srs_core . hpp <nl> ppp b / trunk / src / core / srs_core . hpp <nl> <nl> / / The version config . <nl> # define VERSION_MAJOR 3 <nl> # define VERSION_MINOR 0 <nl> - # define VERSION_REVISION 93 <nl> + # define VERSION_REVISION 94 <nl> <nl> / / The macros generated by configure script . <nl> # include < srs_auto_headers . hpp > <nl> mmm a / trunk / src / kernel / srs_kernel_utility . cpp <nl> ppp b / trunk / src / kernel / srs_kernel_utility . cpp <nl> string srs_dns_resolve ( string host , int & family ) <nl> return string ( shost ) ; <nl> } <nl> <nl> - void srs_parse_hostport ( const string & hostport , string & host , int & port ) <nl> + void srs_parse_hostport ( string hostport , string & host , int & port ) <nl> { <nl> - const size_t pos = hostport . rfind ( " : " ) ; / / Look for " : " from the end , to work with IPv6 . <nl> - if ( pos ! = std : : string : : npos ) { <nl> - const string p = hostport . substr ( pos + 1 ) ; <nl> - if ( ( pos > = 1 ) & & <nl> - ( hostport [ 0 ] = = ' [ ' ) & & <nl> - ( hostport [ pos - 1 ] = = ' ] ' ) ) { <nl> - / / Handle IPv6 in RFC 2732 format , e . g . [ 3ffe : dead : beef : : 1 ] : 1935 <nl> - host = hostport . substr ( 1 , pos - 2 ) ; <nl> - } else { <nl> - / / Handle IP address <nl> - host = hostport . substr ( 0 , pos ) ; <nl> + / / No host or port . <nl> + if ( hostport . empty ( ) ) { <nl> + return ; <nl> + } <nl> + <nl> + size_t pos = string : : npos ; <nl> + <nl> + / / Host only for ipv4 . <nl> + if ( ( pos = hostport . rfind ( " : " ) ) = = string : : npos ) { <nl> + host = hostport ; <nl> + return ; <nl> + } <nl> + <nl> + / / For ipv4 ( only one colon ) , host : port . <nl> + if ( hostport . find ( " : " ) = = pos ) { <nl> + host = hostport . substr ( 0 , pos ) ; <nl> + string p = hostport . substr ( pos + 1 ) ; <nl> + if ( ! p . empty ( ) ) { <nl> + port = : : atoi ( p . c_str ( ) ) ; <nl> } <nl> - port = : : atoi ( p . c_str ( ) ) ; <nl> - } else { <nl> + return ; <nl> + } <nl> + <nl> + / / Host only for ipv6 . <nl> + if ( hostport . at ( 0 ) ! = ' [ ' | | ( pos = hostport . rfind ( " ] : " ) ) = = string : : npos ) { <nl> host = hostport ; <nl> + return ; <nl> + } <nl> + <nl> + / / For ipv6 , [ host ] : port . <nl> + host = hostport . substr ( 1 , pos - 1 ) ; <nl> + string p = hostport . substr ( pos + 2 ) ; <nl> + if ( ! p . empty ( ) ) { <nl> + port = : : atoi ( p . c_str ( ) ) ; <nl> } <nl> } <nl> <nl>
For , fix ipv6 hostport parsing bug . 3 . 0 . 94
ossrs/srs
b794c9e4ecab4c4362d4675ce1b01e1ad4f5cb53
2020-01-05T14:16:21Z
mmm a / src / x64 / stub - cache - x64 . cc <nl> ppp b / src / x64 / stub - cache - x64 . cc <nl> Handle < Code > CallStubCompiler : : CompileMathFloorCall ( <nl> / / - - . . . <nl> / / - - rsp [ ( argc + 1 ) * 4 ] : receiver <nl> / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> - <nl> - if ( ! CpuFeatures : : IsSupported ( SSE2 ) ) { <nl> - return Handle < Code > : : null ( ) ; <nl> - } <nl> - <nl> - CpuFeatureScope use_sse2 ( masm ( ) , SSE2 ) ; <nl> - <nl> const int argc = arguments ( ) . immediate ( ) ; <nl> <nl> / / If the object is not a JSObject or we got an unexpected number of <nl>
Unnecessay SSE2 check on x64
v8/v8
fa2ad975ed11faa018e39e493e12f3169d065dff
2013-09-12T09:47:02Z
mmm a / xbmc / interfaces / legacy / InfoTagVideo . cpp <nl> ppp b / xbmc / interfaces / legacy / InfoTagVideo . cpp <nl> namespace XBMCAddon <nl> return infoTag - > m_strPath ; <nl> } <nl> <nl> + String InfoTagVideo : : getFilenameAndPath ( ) <nl> + { <nl> + return infoTag - > m_strFileNameAndPath ; <nl> + } <nl> + <nl> String InfoTagVideo : : getIMDBNumber ( ) <nl> { <nl> return infoTag - > GetUniqueID ( ) ; <nl> mmm a / xbmc / interfaces / legacy / InfoTagVideo . h <nl> ppp b / xbmc / interfaces / legacy / InfoTagVideo . h <nl> namespace XBMCAddon <nl> String getPath ( ) ; <nl> # endif <nl> <nl> + # ifdef DOXYGEN_SHOULD_USE_THIS <nl> + / / / <nl> + / / / \ ingroup python_InfoTagVideo <nl> + / / / @ brief \ python_func { getFilenameAndPath ( ) } <nl> + / / / To get the full path with filename where the video is stored . <nl> + / / / <nl> + / / / @ return [ string ] File name and Path <nl> + / / / <nl> + / / / <nl> + / / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / / @ python_v19 New function added . <nl> + / / / <nl> + getFilenameAndPath ( ) ; <nl> + # else <nl> + String getFilenameAndPath ( ) ; <nl> + # endif <nl> + <nl> # ifdef DOXYGEN_SHOULD_USE_THIS <nl> / / / <nl> / / / \ ingroup python_InfoTagVideo <nl>
Expose listitem filename and path from xbmcgui . ListItem . getVideoInfoTag
xbmc/xbmc
d127e2cb84b3ab21e83602d7f97ee5719e7b8de5
2020-08-28T10:51:52Z
mmm a / drivers / coreaudio / audio_driver_coreaudio . cpp <nl> ppp b / drivers / coreaudio / audio_driver_coreaudio . cpp <nl> OSStatus AudioDriverCoreAudio : : input_callback ( void * inRefCon , <nl> } <nl> } <nl> } else { <nl> - ERR_PRINT ( ( " AudioUnitRender failed , code : " + itos ( result ) ) . utf8 ( ) . get_data ( ) ) ; <nl> + ERR_PRINTS ( " AudioUnitRender failed , code : " + itos ( result ) ) ; <nl> } <nl> <nl> ad - > unlock ( ) ; <nl> void AudioDriverCoreAudio : : start ( ) { <nl> if ( ! active ) { <nl> OSStatus result = AudioOutputUnitStart ( audio_unit ) ; <nl> if ( result ! = noErr ) { <nl> - ERR_PRINT ( ( " AudioOutputUnitStart failed , code : " + itos ( result ) ) . utf8 ( ) . get_data ( ) ) ; <nl> + ERR_PRINTS ( " AudioOutputUnitStart failed , code : " + itos ( result ) ) ; <nl> } else { <nl> active = true ; <nl> } <nl> void AudioDriverCoreAudio : : stop ( ) { <nl> if ( active ) { <nl> OSStatus result = AudioOutputUnitStop ( audio_unit ) ; <nl> if ( result ! = noErr ) { <nl> - ERR_PRINT ( ( " AudioOutputUnitStop failed , code : " + itos ( result ) ) . utf8 ( ) . get_data ( ) ) ; <nl> + ERR_PRINTS ( " AudioOutputUnitStop failed , code : " + itos ( result ) ) ; <nl> } else { <nl> active = false ; <nl> } <nl> mmm a / drivers / coremidi / core_midi . cpp <nl> ppp b / drivers / coremidi / core_midi . cpp <nl> Error MIDIDriverCoreMidi : : open ( ) { <nl> OSStatus result = MIDIClientCreate ( name , NULL , NULL , & client ) ; <nl> CFRelease ( name ) ; <nl> if ( result ! = noErr ) { <nl> - ERR_PRINTS ( " MIDIClientCreate failed : " + String ( GetMacOSStatusErrorString ( result ) ) ) ; <nl> + ERR_PRINTS ( " MIDIClientCreate failed , code : " + itos ( result ) ) ; <nl> return ERR_CANT_OPEN ; <nl> } <nl> <nl> result = MIDIInputPortCreate ( client , CFSTR ( " Godot Input " ) , MIDIDriverCoreMidi : : read , ( void * ) this , & port_in ) ; <nl> if ( result ! = noErr ) { <nl> - ERR_PRINTS ( " MIDIInputPortCreate failed : " + String ( GetMacOSStatusErrorString ( result ) ) ) ; <nl> + ERR_PRINTS ( " MIDIInputPortCreate failed , code : " + itos ( result ) ) ; <nl> return ERR_CANT_OPEN ; <nl> } <nl> <nl> Error MIDIDriverCoreMidi : : open ( ) { <nl> for ( int i = 0 ; i < sources ; i + + ) { <nl> <nl> MIDIEndpointRef source = MIDIGetSource ( i ) ; <nl> - if ( source ! = NULL ) { <nl> + if ( source ) { <nl> MIDIPortConnectSource ( port_in , source , ( void * ) this ) ; <nl> connected_sources . insert ( i , source ) ; <nl> } <nl>
Fix CoreMidi warnings
godotengine/godot
cb99a15064e04371c527db4b1e8f9c08d4f33b65
2018-10-04T19:23:59Z
new file mode 100644 <nl> index 000000000000 . . bfc9ef71a156 <nl> mmm / dev / null <nl> ppp b / jstests / aggregation / expressions / indexof_array . js <nl> <nl> + / / In SERVER - 8951 , $ indexOfArray was introduced . In this file , we test the correctness and error <nl> + / / cases of the expression . <nl> + load ( " jstests / aggregation / extras / utils . js " ) ; / / For assertErrorCode and testExpression . <nl> + <nl> + ( function ( ) { <nl> + " use strict " ; <nl> + <nl> + var coll = db . indexofarray ; <nl> + coll . drop ( ) ; <nl> + <nl> + / / Insert a dummy document to ensure something flows through the pipeline . <nl> + assert . writeOK ( coll . insert ( { } ) ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 ] } , 1 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 ] , 4 ] } , - 1 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 , 2 , 1 ] , 2 , 2 ] } , 3 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 , 4 , 5 ] , 4 , 0 , 3 ] } , - 1 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 , 1 ] } , 1 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 , 0 , 10 ] } , 1 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 , 2 , 1 , 2 , 3 ] , 2 , 2 , 4 ] } , 3 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ null , 2 ] } , null ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 , 3 ] } , - 1 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 , 3 , 1 ] } , - 1 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 , 3 , 3 ] } , - 1 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 , 3 , 5 ] } , - 1 ) ; <nl> + <nl> + testExpression ( coll , { $ indexOfArray : [ [ ] , 1 ] } , - 1 ) ; <nl> + <nl> + var pipeline = { <nl> + $ project : { <nl> + output : { <nl> + $ indexOfArray : [ " string " , " s " ] , <nl> + } <nl> + } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40090 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 , " bad " ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40096 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 , 0 , " bad " ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40096 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 , - 1 ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40097 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfArray : [ [ 1 , 2 , 3 ] , 2 , 1 , - 1 ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40097 ) ; <nl> + } ( ) ) ; <nl> new file mode 100644 <nl> index 000000000000 . . ac3cefda790c <nl> mmm / dev / null <nl> ppp b / jstests / aggregation / expressions / indexof_bytes . js <nl> <nl> + / / In SERVER - 8951 , $ indexOfBytes was introduced . In this file , we test the correctness and error <nl> + / / cases of the expression . <nl> + load ( " jstests / aggregation / extras / utils . js " ) ; / / For assertErrorCode and testExpression . <nl> + <nl> + ( function ( ) { <nl> + " use strict " ; <nl> + <nl> + function testExpressionBytes ( coll , expression , result , shouldTestEquivalence = true ) { <nl> + testExpression ( coll , expression , result ) ; <nl> + <nl> + if ( shouldTestEquivalence ) { <nl> + / / If we are specifying a starting or ending index for the search , we should be able to <nl> + / / achieve equivalent behavior using $ substrBytes . <nl> + var indexOfSpec = expression [ " $ indexOfBytes " ] ; <nl> + var input = indexOfSpec [ 0 ] ; <nl> + var token = indexOfSpec [ 1 ] ; <nl> + var start = indexOfSpec . length > 2 ? indexOfSpec [ 2 ] : 0 ; <nl> + / / Use $ strLenBytes because JavaScript ' s length property is based off of UTF - 16 , not the <nl> + / / actual number of bytes . <nl> + var end = indexOfSpec . length > 3 ? indexOfSpec [ 3 ] : { <nl> + $ strLenBytes : input <nl> + } ; <nl> + <nl> + var substrExpr = { <nl> + $ indexOfBytes : [ { $ substrBytes : [ input , start , { $ subtract : [ end , start ] } ] } , token ] <nl> + } ; <nl> + <nl> + / / Since the new expression takes the index with respect to a shortened string , the <nl> + / / output index will differ from the index with respect to the full length string , <nl> + / / unless the output is - 1 . <nl> + var substrResult = ( result = = = - 1 ) ? - 1 : result - start ; <nl> + <nl> + testExpression ( coll , substrExpr , substrResult ) ; <nl> + } <nl> + } <nl> + <nl> + var coll = db . indexofbytes ; <nl> + coll . drop ( ) ; <nl> + <nl> + / / Insert a dummy document so something flows through the pipeline . <nl> + assert . writeOK ( coll . insert ( { } ) ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc " , " b " ] } , 1 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abcba " , " b " ] } , 1 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc " , " d " ] } , - 1 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abcba " , " b " , 2 ] } , 3 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abcde " , " d " , 0 , 2 ] } , - 1 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc " , " b " , 1 ] } , 1 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc " , " b " , 0 , 10 ] } , 1 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abcbabc " , " b " , 2 , 4 ] } , 3 ) ; <nl> + <nl> + / / $ strLenBytes does not accept null as an input . <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ null , " b " ] } , null , false ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc " , " b " , 3 ] } , - 1 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc " , " b " , 3 , 1 ] } , - 1 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc " , " b " , 3 , 5 ] } , - 1 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " " , " " ] } , - 1 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " " , " " ] } , 0 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " " , " " ] } , 0 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc " , " " , 3 ] } , 3 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc " , " " , 1 ] } , 1 ) ; <nl> + <nl> + / / Test with multi - byte tokens . <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abcde " , " de " ] } , 3 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abcde " , " def " ] } , - 1 ) ; <nl> + <nl> + / / Test with non - ASCII characters . Some tests do not test equivalence using $ substrBytes because <nl> + / / $ substrBytes disallows taking a substring that begins or ends in the middle of a UTF - 8 <nl> + / / encoding of a character . <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " a ∫ ∫ b " , " b " ] } , 7 ) ; <nl> + <nl> + / / $ substrBytes would attempt to take the substring from the middle of a UTF - 8 <nl> + / / encoding of a character . <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " a ∫ ∫ b " , " b " , 6 ] } , 7 , false ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc ∫ ba " , " ∫ " ] } , 3 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " ∫ ∫ ∫ " , " a " ] } , - 1 ) ; <nl> + <nl> + / / $ substrBytes would attempt to take the substring from the middle of a UTF - 8 <nl> + / / encoding of a character . <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " ab ∫ c " , " c " , 0 , 3 ] } , - 1 , false ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc ∫ b ∫ " , " b ∫ " ] } , 6 ) ; <nl> + <nl> + / / Test with embedded null bytes . <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc \ 0d " , " d " ] } , 4 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc \ 0 " , " \ 0 " ] } , 3 ) ; <nl> + <nl> + testExpressionBytes ( coll , { $ indexOfBytes : [ " abc \ 0d \ 0 " , " d " , 5 , 6 ] } , - 1 ) ; <nl> + <nl> + / / Error cases . <nl> + <nl> + var pipeline = { <nl> + $ project : { <nl> + output : { <nl> + $ indexOfBytes : [ 3 , " s " ] , <nl> + } <nl> + } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40091 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { <nl> + output : { <nl> + $ indexOfBytes : [ " s " , 3 ] , <nl> + } <nl> + } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40092 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfBytes : [ " abc " , " b " , " bad " ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40096 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfBytes : [ " abc " , " b " , 0 , " bad " ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40096 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfBytes : [ " abc " , " b " , - 1 ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40097 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfBytes : [ " abc " , " b " , 1 , - 1 ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40097 ) ; <nl> + } ( ) ) ; <nl> new file mode 100644 <nl> index 000000000000 . . 20b9534b0505 <nl> mmm / dev / null <nl> ppp b / jstests / aggregation / expressions / indexof_codepoints . js <nl> <nl> + / / In SERVER - 8951 , $ indexOfCP was introduced . In this file , we test the correctness and error <nl> + / / cases of the expression . <nl> + load ( " jstests / aggregation / extras / utils . js " ) ; / / For assertErrorCode and testExpression . <nl> + <nl> + ( function ( ) { <nl> + " use strict " ; <nl> + <nl> + function testExpressionCodePoints ( coll , expression , result , shouldTestEquivalence = true ) { <nl> + testExpression ( coll , expression , result ) ; <nl> + <nl> + var indexOfSpec = expression [ " $ indexOfCP " ] ; <nl> + if ( shouldTestEquivalence ) { <nl> + / / If we are specifying a starting or ending index for the search , we should be able to <nl> + / / achieve equivalent behavior using $ substrCP . <nl> + var input = indexOfSpec [ 0 ] ; <nl> + var token = indexOfSpec [ 1 ] ; <nl> + var start = indexOfSpec . length > 2 ? indexOfSpec [ 2 ] : 0 ; <nl> + var end = indexOfSpec . length > 3 ? indexOfSpec [ 3 ] : { <nl> + $ strLenCP : input <nl> + } ; <nl> + <nl> + var substrExpr = { <nl> + $ indexOfCP : [ { $ substrCP : [ input , start , { $ subtract : [ end , start ] } ] } , token ] <nl> + } ; <nl> + <nl> + / / Since the new expression takes the index with respect to a shortened string , the <nl> + / / output index will differ from the index with respect to the full length string , <nl> + / / unless the output is - 1 . <nl> + var substrResult = ( result = = = - 1 ) ? - 1 : result - start ; <nl> + <nl> + testExpression ( coll , substrExpr , substrResult ) ; <nl> + } <nl> + } <nl> + <nl> + var coll = db . indexofcp ; <nl> + coll . drop ( ) ; <nl> + <nl> + / / Insert a dummy document so something flows through the pipeline . <nl> + assert . writeOK ( coll . insert ( { } ) ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " ∫ aƒ " , " ƒ " ] } , 2 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " a ∫ c " , " d " ] } , - 1 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " ∫ b ∫ ba " , " b " , 2 ] } , 3 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " ab ∫ de " , " d " , 0 , 3 ] } , - 1 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " ab ∫ de " , " d " , 0 , 4 ] } , 3 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " øøc " , " ø " , 1 ] } , 1 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " øƒc " , " ƒ " , 0 , 10 ] } , 1 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " abcbabc " , " b " , 2 , 4 ] } , 3 ) ; <nl> + <nl> + / / $ strLenCP does not accept null as an input . <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ null , " √ " ] } , null , false ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " abc " , " b " , 3 ] } , - 1 ) ; <nl> + <nl> + / / We are intentionally testing specifying an end index before the start index , which is why we <nl> + / / cannot use $ substrCP in checking for equivalence . <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " a √ cb " , " b " , 3 , 1 ] } , - 1 , false ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " a ∫ b " , " b " , 3 , 5 ] } , - 1 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " " , " ∫ " ] } , - 1 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " " , " " ] } , 0 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " " , " " ] } , 0 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " abc " , " " , 1 ] } , 1 ) ; <nl> + <nl> + / / Test with multi - byte tokens . <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " abcƒe " , " ƒe " ] } , 3 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " ∫ aeøø " , " øøø " ] } , - 1 ) ; <nl> + <nl> + / / Test with embedded null bytes . <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " ab ∫ \ 0d " , " d " ] } , 4 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " øbc \ 0 " , " \ 0 " ] } , 3 ) ; <nl> + <nl> + testExpressionCodePoints ( coll , { $ indexOfCP : [ " πbƒ \ 0d \ 0 " , " d " , 5 , 6 ] } , - 1 ) ; <nl> + <nl> + / / Error cases . <nl> + <nl> + var pipeline = { <nl> + $ project : { <nl> + output : { <nl> + $ indexOfCP : [ 3 , " s " ] , <nl> + } <nl> + } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40093 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { <nl> + output : { <nl> + $ indexOfCP : [ " s " , 3 ] , <nl> + } <nl> + } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40094 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfCP : [ " abc " , " b " , " bad " ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40096 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfCP : [ " abc " , " b " , 0 , " bad " ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40096 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfCP : [ " abc " , " b " , - 1 ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40097 ) ; <nl> + <nl> + pipeline = { <nl> + $ project : { output : { $ indexOfCP : [ " abc " , " b " , 1 , - 1 ] } } <nl> + } ; <nl> + assertErrorCode ( coll , pipeline , 40097 ) ; <nl> + } ( ) ) ; <nl> mmm a / jstests / aggregation / extras / utils . js <nl> ppp b / jstests / aggregation / extras / utils . js <nl> function testExpression ( coll , expression , result ) { <nl> <nl> var res = coll . aggregate ( { $ project : { output : expression } } ) . toArray ( ) ; <nl> <nl> - assert . eq ( res . length , 1 ) ; <nl> - assert . eq ( res [ 0 ] . output , result ) ; <nl> + assert . eq ( res . length , 1 , tojson ( res ) ) ; <nl> + assert . eq ( res [ 0 ] . output , result , tojson ( res ) ) ; <nl> } <nl> <nl> / * <nl> mmm a / src / mongo / db / pipeline / expression . cpp <nl> ppp b / src / mongo / db / pipeline / expression . cpp <nl> intrusive_ptr < Expression > Expression : : parseOperand ( BSONElement exprElement , <nl> } <nl> } <nl> <nl> + namespace { <nl> + / * * <nl> + * UTF - 8 multi - byte code points consist of one leading byte of the form 11xxxxxx , and potentially <nl> + * many continuation bytes of the form 10xxxxxx . This method checks whether ' charByte ' is a <nl> + * continuation byte . <nl> + * / <nl> + bool isContinuationByte ( char charByte ) { <nl> + return ( charByte & 0xc0 ) = = 0x80 ; <nl> + } <nl> + <nl> + / * * <nl> + * UTF - 8 multi - byte code points consist of one leading byte of the form 11xxxxxx , and potentially <nl> + * many continuation bytes of the form 10xxxxxx . This method checks whether ' charByte ' is a leading <nl> + * byte . <nl> + * / <nl> + bool isLeadingByte ( char charByte ) { <nl> + return ( charByte & 0xc0 ) = = 0xc0 ; <nl> + } <nl> + <nl> + / * * <nl> + * UTF - 8 single - byte code points are of the form 0xxxxxxx . This method checks whether ' charByte ' is <nl> + * a single - byte code point . <nl> + * / <nl> + bool isSingleByte ( char charByte ) { <nl> + return ( charByte & 0x80 ) = = 0x0 ; <nl> + } <nl> + <nl> + size_t getCodePointLength ( char charByte ) { <nl> + if ( isSingleByte ( charByte ) ) { <nl> + return 1 ; <nl> + } <nl> + <nl> + invariant ( isLeadingByte ( charByte ) ) ; <nl> + <nl> + / / In UTF - 8 , the number of leading ones is the number of bytes the code point takes up . <nl> + return countLeadingZeros64 ( ~ ( uint64_t ( charByte ) < < ( 64 - 8 ) ) ) ; <nl> + } <nl> + } / / namespace <nl> <nl> / * mmmmmmmmmmmmmmmmmmmmm - - ExpressionAbs mmmmmmmmmmmmmmmmmmmmmmmmmmm - * / <nl> <nl> const char * ExpressionIn : : getOpName ( ) const { <nl> return " $ in " ; <nl> } <nl> <nl> + / * mmmmmmmmmmmmmmmmmmmmm - - ExpressionIndexOfArray mmmmmmmmmmmmmmmmmm * / <nl> + <nl> + namespace { <nl> + <nl> + void uassertIfNotIntegralAndNonNegative ( Value val , <nl> + StringData expressionName , <nl> + StringData argumentName ) { <nl> + uassert ( 40096 , <nl> + str : : stream ( ) < < expressionName < < " requires an integral " < < argumentName <nl> + < < " , found a value of type : " < < typeName ( val . getType ( ) ) <nl> + < < " , with value : " < < val . toString ( ) , <nl> + val . integral ( ) ) ; <nl> + uassert ( 40097 , <nl> + str : : stream ( ) < < expressionName < < " requires a nonnegative " < < argumentName <nl> + < < " , found : " < < val . toString ( ) , <nl> + val . coerceToInt ( ) > = 0 ) ; <nl> + } <nl> + <nl> + } / / namespace <nl> + <nl> + Value ExpressionIndexOfArray : : evaluateInternal ( Variables * vars ) const { <nl> + Value arrayArg = vpOperand [ 0 ] - > evaluateInternal ( vars ) ; <nl> + <nl> + if ( arrayArg . nullish ( ) ) { <nl> + return Value ( BSONNULL ) ; <nl> + } <nl> + <nl> + uassert ( 40090 , <nl> + str : : stream ( ) < < " $ indexOfArray requires an array as a first argument , found : " <nl> + < < typeName ( arrayArg . getType ( ) ) , <nl> + arrayArg . isArray ( ) ) ; <nl> + <nl> + std : : vector < Value > array = arrayArg . getArray ( ) ; <nl> + <nl> + Value searchItem = vpOperand [ 1 ] - > evaluateInternal ( vars ) ; <nl> + <nl> + size_t startIndex = 0 ; <nl> + if ( vpOperand . size ( ) > 2 ) { <nl> + Value startIndexArg = vpOperand [ 2 ] - > evaluateInternal ( vars ) ; <nl> + uassertIfNotIntegralAndNonNegative ( startIndexArg , getOpName ( ) , " starting index " ) ; <nl> + startIndex = static_cast < size_t > ( startIndexArg . coerceToInt ( ) ) ; <nl> + } <nl> + <nl> + size_t endIndex = array . size ( ) ; <nl> + if ( vpOperand . size ( ) > 3 ) { <nl> + Value endIndexArg = vpOperand [ 3 ] - > evaluateInternal ( vars ) ; <nl> + uassertIfNotIntegralAndNonNegative ( endIndexArg , getOpName ( ) , " ending index " ) ; <nl> + / / Don ' t let ' endIndex ' exceed the length of the array . <nl> + endIndex = std : : min ( array . size ( ) , static_cast < size_t > ( endIndexArg . coerceToInt ( ) ) ) ; <nl> + } <nl> + <nl> + for ( size_t i = startIndex ; i < endIndex ; i + + ) { <nl> + if ( array [ i ] = = searchItem ) { <nl> + return Value ( static_cast < int > ( i ) ) ; <nl> + } <nl> + } <nl> + <nl> + return Value ( - 1 ) ; <nl> + } <nl> + <nl> + REGISTER_EXPRESSION ( indexOfArray , ExpressionIndexOfArray : : parse ) ; <nl> + const char * ExpressionIndexOfArray : : getOpName ( ) const { <nl> + return " $ indexOfArray " ; <nl> + } <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmm - - ExpressionIndexOfBytes mmmmmmmmmmmmmmmmmm * / <nl> + <nl> + namespace { <nl> + <nl> + bool stringHasTokenAtIndex ( size_t index , const std : : string & input , const std : : string & token ) { <nl> + if ( token . size ( ) + index > input . size ( ) ) { <nl> + return false ; <nl> + } <nl> + return input . compare ( index , token . size ( ) , token ) = = 0 ; <nl> + } <nl> + <nl> + } / / namespace <nl> + <nl> + Value ExpressionIndexOfBytes : : evaluateInternal ( Variables * vars ) const { <nl> + Value stringArg = vpOperand [ 0 ] - > evaluateInternal ( vars ) ; <nl> + <nl> + if ( stringArg . nullish ( ) ) { <nl> + return Value ( BSONNULL ) ; <nl> + } <nl> + <nl> + uassert ( 40091 , <nl> + str : : stream ( ) < < " $ indexOfBytes requires a string as the first argument , found : " <nl> + < < typeName ( stringArg . getType ( ) ) , <nl> + stringArg . getType ( ) = = String ) ; <nl> + const std : : string & input = stringArg . getString ( ) ; <nl> + <nl> + Value tokenArg = vpOperand [ 1 ] - > evaluateInternal ( vars ) ; <nl> + uassert ( 40092 , <nl> + str : : stream ( ) < < " $ indexOfBytes requires a string as the second argument , found : " <nl> + < < typeName ( tokenArg . getType ( ) ) , <nl> + tokenArg . getType ( ) = = String ) ; <nl> + const std : : string & token = tokenArg . getString ( ) ; <nl> + <nl> + size_t startIndex = 0 ; <nl> + if ( vpOperand . size ( ) > 2 ) { <nl> + Value startIndexArg = vpOperand [ 2 ] - > evaluateInternal ( vars ) ; <nl> + uassertIfNotIntegralAndNonNegative ( startIndexArg , getOpName ( ) , " starting index " ) ; <nl> + startIndex = static_cast < size_t > ( startIndexArg . coerceToInt ( ) ) ; <nl> + } <nl> + <nl> + size_t endIndex = input . size ( ) ; <nl> + if ( vpOperand . size ( ) > 3 ) { <nl> + Value endIndexArg = vpOperand [ 3 ] - > evaluateInternal ( vars ) ; <nl> + uassertIfNotIntegralAndNonNegative ( endIndexArg , getOpName ( ) , " ending index " ) ; <nl> + / / Don ' t let ' endIndex ' exceed the length of the string . <nl> + endIndex = std : : min ( input . size ( ) , static_cast < size_t > ( endIndexArg . coerceToInt ( ) ) ) ; <nl> + } <nl> + <nl> + if ( startIndex > input . length ( ) | | endIndex < startIndex ) { <nl> + return Value ( - 1 ) ; <nl> + } <nl> + <nl> + size_t position = input . substr ( 0 , endIndex ) . find ( token , startIndex ) ; <nl> + if ( position = = std : : string : : npos ) { <nl> + return Value ( - 1 ) ; <nl> + } <nl> + <nl> + return Value ( static_cast < int > ( position ) ) ; <nl> + } <nl> + <nl> + REGISTER_EXPRESSION ( indexOfBytes , ExpressionIndexOfBytes : : parse ) ; <nl> + const char * ExpressionIndexOfBytes : : getOpName ( ) const { <nl> + return " $ indexOfBytes " ; <nl> + } <nl> + <nl> + / * mmmmmmmmmmmmmmmmmmmmm - - ExpressionIndexOfCP mmmmmmmmmmmmmmmmmmmmm * / <nl> + <nl> + Value ExpressionIndexOfCP : : evaluateInternal ( Variables * vars ) const { <nl> + Value stringArg = vpOperand [ 0 ] - > evaluateInternal ( vars ) ; <nl> + <nl> + if ( stringArg . nullish ( ) ) { <nl> + return Value ( BSONNULL ) ; <nl> + } <nl> + <nl> + uassert ( 40093 , <nl> + str : : stream ( ) < < " $ indexOfCP requires a string as the first argument , found : " <nl> + < < typeName ( stringArg . getType ( ) ) , <nl> + stringArg . getType ( ) = = String ) ; <nl> + const std : : string & input = stringArg . getString ( ) ; <nl> + <nl> + Value tokenArg = vpOperand [ 1 ] - > evaluateInternal ( vars ) ; <nl> + uassert ( 40094 , <nl> + str : : stream ( ) < < " $ indexOfCP requires a string as the second argument , found : " <nl> + < < typeName ( tokenArg . getType ( ) ) , <nl> + tokenArg . getType ( ) = = String ) ; <nl> + const std : : string & token = tokenArg . getString ( ) ; <nl> + <nl> + size_t startCodePointIndex = 0 ; <nl> + if ( vpOperand . size ( ) > 2 ) { <nl> + Value startIndexArg = vpOperand [ 2 ] - > evaluateInternal ( vars ) ; <nl> + uassertIfNotIntegralAndNonNegative ( startIndexArg , getOpName ( ) , " starting index " ) ; <nl> + startCodePointIndex = static_cast < size_t > ( startIndexArg . coerceToInt ( ) ) ; <nl> + } <nl> + <nl> + / / Compute the length ( in code points ) of the input , and convert ' startCodePointIndex ' to a byte <nl> + / / index . <nl> + size_t codePointLength = 0 ; <nl> + size_t startByteIndex = 0 ; <nl> + for ( size_t byteIx = 0 ; byteIx < input . size ( ) ; + + codePointLength ) { <nl> + if ( codePointLength = = startCodePointIndex ) { <nl> + / / We have determined the byte at which our search will start . <nl> + startByteIndex = byteIx ; <nl> + } <nl> + <nl> + uassert ( <nl> + 40095 , " $ indexOfCP found bad UTF - 8 in the input " , ! isContinuationByte ( input [ byteIx ] ) ) ; <nl> + byteIx + = getCodePointLength ( input [ byteIx ] ) ; <nl> + } <nl> + <nl> + size_t endCodePointIndex = codePointLength ; <nl> + if ( vpOperand . size ( ) > 3 ) { <nl> + Value endIndexArg = vpOperand [ 3 ] - > evaluateInternal ( vars ) ; <nl> + uassertIfNotIntegralAndNonNegative ( endIndexArg , getOpName ( ) , " ending index " ) ; <nl> + <nl> + / / Don ' t let ' endCodePointIndex ' exceed the number of code points in the string . <nl> + endCodePointIndex = <nl> + std : : min ( codePointLength , static_cast < size_t > ( endIndexArg . coerceToInt ( ) ) ) ; <nl> + } <nl> + <nl> + if ( startByteIndex = = 0 & & input . empty ( ) & & token . empty ( ) ) { <nl> + / / If we are finding the index of " " in the string " " , the below loop will not loop , so we <nl> + / / need a special case for this . <nl> + return Value ( 0 ) ; <nl> + } <nl> + <nl> + / / We must keep track of which byte , and which code point , we are examining , being careful not <nl> + / / to overflow either the length of the string or the ending code point . <nl> + <nl> + size_t currentCodePointIndex = startCodePointIndex ; <nl> + for ( size_t byteIx = startByteIndex ; currentCodePointIndex < endCodePointIndex ; <nl> + + + currentCodePointIndex ) { <nl> + if ( stringHasTokenAtIndex ( byteIx , input , token ) ) { <nl> + return Value ( static_cast < int > ( currentCodePointIndex ) ) ; <nl> + } <nl> + byteIx + = getCodePointLength ( input [ byteIx ] ) ; <nl> + } <nl> + <nl> + return Value ( - 1 ) ; <nl> + } <nl> + <nl> + REGISTER_EXPRESSION ( indexOfCP , ExpressionIndexOfCP : : parse ) ; <nl> + const char * ExpressionIndexOfCP : : getOpName ( ) const { <nl> + return " $ indexOfCP " ; <nl> + } <nl> + <nl> / * mmmmmmmmmmmmmmmmmmmmm - - ExpressionLn mmmmmmmmmmmmmmmmmmmmmmmmmmm - * / <nl> <nl> Value ExpressionLn : : evaluateNumericArg ( const Value & numericArg ) const { <nl> const char * ExpressionSize : : getOpName ( ) const { <nl> <nl> / * mmmmmmmmmmmmmmmmmmmmm - - ExpressionSplit mmmmmmmmmmmmmmmmmmmmmmmmmmm * / <nl> <nl> - namespace { <nl> - <nl> - bool stringHasTokenAtIndex ( size_t index , const std : : string & input , const std : : string & token ) { <nl> - if ( token . size ( ) + index > input . size ( ) ) { <nl> - return false ; <nl> - } <nl> - <nl> - return input . compare ( index , token . size ( ) , token ) = = 0 ; <nl> - } <nl> - <nl> - } / / namespace <nl> - <nl> Value ExpressionSplit : : evaluateInternal ( Variables * vars ) const { <nl> Value inputArg = vpOperand [ 0 ] - > evaluateInternal ( vars ) ; <nl> Value separatorArg = vpOperand [ 1 ] - > evaluateInternal ( vars ) ; <nl> const char * ExpressionStrcasecmp : : getOpName ( ) const { <nl> return " $ strcasecmp " ; <nl> } <nl> <nl> - namespace { <nl> - / * * <nl> - * UTF - 8 multi - byte code points consist of one leading byte of the form 11xxxxxx , and potentially <nl> - * many continuation bytes of the form 10xxxxxx . This method checks whether ' charByte ' is a <nl> - * continuation byte . <nl> - * / <nl> - bool isContinuationByte ( char charByte ) { <nl> - return ( charByte & 0xc0 ) = = 0x80 ; <nl> - } <nl> - <nl> - / * * <nl> - * UTF - 8 multi - byte code points consist of one leading byte of the form 11xxxxxx , and potentially <nl> - * many continuation bytes of the form 10xxxxxx . This method checks whether ' charByte ' is a leading <nl> - * byte . <nl> - * / <nl> - bool isLeadingByte ( char charByte ) { <nl> - return ( charByte & 0xc0 ) = = 0xc0 ; <nl> - } <nl> - <nl> - / * * <nl> - * UTF - 8 single - byte code points are of the form 0xxxxxxx . This method checks whether ' charByte ' is <nl> - * a single - byte code point . <nl> - * / <nl> - bool isSingleByte ( char charByte ) { <nl> - return ( charByte & 0x80 ) = = 0x0 ; <nl> - } <nl> - <nl> - size_t getCodePointLength ( char charByte ) { <nl> - if ( isSingleByte ( charByte ) ) { <nl> - return 1 ; <nl> - } <nl> - <nl> - invariant ( isLeadingByte ( charByte ) ) ; <nl> - <nl> - / / In UTF - 8 , the number of leading ones is the number of bytes the code point takes up . <nl> - return countLeadingZeros64 ( ~ ( uint64_t ( charByte ) < < ( 64 - 8 ) ) ) ; <nl> - } <nl> - } / / namespace <nl> - <nl> / * mmmmmmmmmmmmmmmmmmmmm - - ExpressionSubstrBytes mmmmmmmmmmmmmmmmmmmmmmmmmmm - * / <nl> <nl> Value ExpressionSubstrBytes : : evaluateInternal ( Variables * vars ) const { <nl> mmm a / src / mongo / db / pipeline / expression . h <nl> ppp b / src / mongo / db / pipeline / expression . h <nl> class ExpressionIn final : public ExpressionFixedArity < ExpressionIn , 2 > { <nl> } ; <nl> <nl> <nl> + class ExpressionIndexOfArray final : public ExpressionRangedArity < ExpressionIndexOfArray , 2 , 4 > { <nl> + public : <nl> + Value evaluateInternal ( Variables * vars ) const final ; <nl> + const char * getOpName ( ) const final ; <nl> + } ; <nl> + <nl> + <nl> + class ExpressionIndexOfBytes final : public ExpressionRangedArity < ExpressionIndexOfBytes , 2 , 4 > { <nl> + public : <nl> + Value evaluateInternal ( Variables * vars ) const final ; <nl> + const char * getOpName ( ) const final ; <nl> + } ; <nl> + <nl> + <nl> + / * * <nl> + * Implements indexOf behavior for strings with UTF - 8 encoding . <nl> + * / <nl> + class ExpressionIndexOfCP final : public ExpressionRangedArity < ExpressionIndexOfCP , 2 , 4 > { <nl> + public : <nl> + Value evaluateInternal ( Variables * vars ) const final ; <nl> + const char * getOpName ( ) const final ; <nl> + } ; <nl> + <nl> + <nl> class ExpressionLet final : public Expression { <nl> public : <nl> boost : : intrusive_ptr < Expression > optimize ( ) final ; <nl>
SERVER - 8951 Aggregation now supports the indexOfArray , indexOfBytes , and indexOfCP expressions .
mongodb/mongo
7ae631410d8ffe71c74f96d5ab5dd408764b7858
2016-04-29T21:17:43Z
mmm a / tensorflow / core / grappler / costs / virtual_scheduler . cc <nl> ppp b / tensorflow / core / grappler / costs / virtual_scheduler . cc <nl> Status VirtualScheduler : : Init ( const GrapplerItem * item ) { <nl> <nl> / / Get the nodes that would run to output fetch_nodes . <nl> bool ill_formed = false ; <nl> + std : : unordered_map < string , const NodeDef * > name_to_node ; <nl> const std : : vector < const NodeDef * > fetch_fanin_nodes = <nl> - ComputeTransitiveFanin ( graph , fetch_nodes , & ill_formed ) ; <nl> + ComputeTransitiveFanin ( graph , fetch_nodes , name_to_node , & ill_formed ) ; <nl> if ( ill_formed ) { <nl> return errors : : InvalidArgument ( <nl> " Ill formed graph or invalid set of fetch nodes specified " ) ; <nl> } <nl> <nl> - / / TODO ( dyoon ) : this is a bit inefficient as name_to_node is already built in <nl> - / / ComputeTransitiveFanin ( ) . <nl> / / Once ComputeTransitiveFanin is complete , only the nodes that can be reached <nl> / / from the fetch nodes are scheduled . So the scheduled nodes should be <nl> / / exactly the same as those executed for real . One possible discrepancy could <nl> / / be the control flow nodes , where tf only executes one path . <nl> - std : : unordered_map < string , const NodeDef * > name_to_node ; <nl> - for ( const auto & node : fetch_fanin_nodes ) { <nl> - name_to_node [ node - > name ( ) ] = node ; <nl> - } <nl> <nl> / / Traverses the graph to record _Send nodes . <nl> / / TODO ( dyoon ) : Instead of identifying _Send node here manually , add _Send <nl> mmm a / tensorflow / core / grappler / grappler_item . cc <nl> ppp b / tensorflow / core / grappler / grappler_item . cc <nl> std : : vector < const NodeDef * > ComputeTransitiveFanin ( <nl> CHECK ( ! ill_formed ) ; <nl> return result ; <nl> } <nl> - <nl> } / / end namespace grappler <nl> } / / end namespace tensorflow <nl> mmm a / tensorflow / core / grappler / grappler_item . h <nl> ppp b / tensorflow / core / grappler / grappler_item . h <nl> std : : vector < const NodeDef * > ComputeTransitiveFanin ( <nl> const GraphDef & graph , const std : : vector < string > & terminal_nodes , <nl> bool * ill_formed ) ; <nl> <nl> + / / Return the transitive fanin of a set of terminal nodes . Sets ' ill_formed ' to <nl> + / / true if one of the node is missing in the graph , or some node inputs don ' t <nl> + / / exist . Sets name_to_fanin_node for name to fanin nodes map . <nl> + std : : vector < const NodeDef * > ComputeTransitiveFanin ( <nl> + const GraphDef & graph , const std : : vector < string > & terminal_nodes , <nl> + std : : unordered_map < string , const NodeDef * > & name_to_fanin_node , <nl> + bool * ill_formed ) ; <nl> + <nl> } / / end namespace grappler <nl> } / / end namespace tensorflow <nl> <nl>
a small optimize for get name_to_node directly from ComputeTransitiveFanin
tensorflow/tensorflow
efa4c54ceb007e55ce7a842f08ba6639f6f920c6
2019-10-19T12:52:00Z
mmm a / lib / IRGen / GenOpaque . cpp <nl> ppp b / lib / IRGen / GenOpaque . cpp <nl> <nl> # include " llvm / Support / raw_ostream . h " <nl> # include " llvm / IR / DerivedTypes . h " <nl> <nl> + # include " FixedTypeInfo . h " <nl> # include " IRGenFunction . h " <nl> # include " IRGenModule . h " <nl> # include " ProtocolInfo . h " <nl> void irgen : : emitDestroyCall ( IRGenFunction & IGF , llvm : : Value * metadata , <nl> <nl> Address irgen : : emitAllocateValueInBuffer ( IRGenFunction & IGF , SILType type , <nl> Address buffer ) { <nl> - auto * size = emitLoadOfSize ( IGF , type ) ; <nl> - auto * alignMask = emitLoadOfAlignmentMask ( IGF , type ) ; <nl> - / / TODO : check whether we fit in the inline value buffer . <nl> - auto valueAddr = IGF . emitAllocRawCall ( size , alignMask , " outline . ValueBuffer " ) ; <nl> - IGF . Builder . CreateStore ( <nl> - valueAddr , <nl> - Address ( IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , <nl> - valueAddr - > getType ( ) - > getPointerTo ( ) ) , <nl> - Alignment ( 1 ) ) ) ; <nl> - valueAddr = <nl> - IGF . Builder . CreateBitCast ( valueAddr , IGF . IGM . getStoragePointerType ( type ) ) ; <nl> - return Address ( valueAddr , Alignment ( 1 ) ) ; <nl> - <nl> - } <nl> - <nl> - Address irgen : : emitProjectValueInBuffer ( IRGenFunction & IGF , <nl> - SILType type , <nl> - Address buffer ) { <nl> - / / TODO : check whether we fit in the inline value buffer . <nl> - auto ptr = IGF . Builder . CreateLoad ( Address ( <nl> - IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , IGF . IGM . Int8PtrPtrTy ) , <nl> - Alignment ( 1 ) ) ) ; <nl> - auto valueAddr = <nl> - IGF . Builder . CreateBitCast ( ptr , IGF . IGM . getStoragePointerType ( type ) ) ; <nl> - return Address ( valueAddr , Alignment ( 1 ) ) ; <nl> + / / Handle FixedSize types . <nl> + auto & IGM = IGF . IGM ; <nl> + auto storagePtrTy = IGM . getStoragePointerType ( type ) ; <nl> + if ( auto * fixedTI = dyn_cast < FixedTypeInfo > ( & IGF . getTypeInfo ( type ) ) ) { <nl> + auto packing = fixedTI - > getFixedPacking ( IGM ) ; <nl> + <nl> + / / Inline representation . <nl> + if ( packing = = FixedPacking : : OffsetZero ) { <nl> + return Address ( <nl> + IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , storagePtrTy ) , <nl> + buffer . getAlignment ( ) ) ; <nl> + } <nl> + <nl> + / / Outline representation . <nl> + assert ( packing = = FixedPacking : : Allocate & & " Expect non dynamic packing " ) ; <nl> + auto size = fixedTI - > getStaticSize ( IGM ) ; <nl> + auto alignMask = fixedTI - > getStaticAlignmentMask ( IGM ) ; <nl> + auto valueAddr = <nl> + IGF . emitAllocRawCall ( size , alignMask , " outline . ValueBuffer " ) ; <nl> + IGF . Builder . CreateStore ( <nl> + valueAddr , <nl> + Address ( IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , <nl> + valueAddr - > getType ( ) - > getPointerTo ( ) ) , <nl> + buffer . getAlignment ( ) ) ) ; <nl> + return Address ( IGF . Builder . CreateBitCast ( valueAddr , storagePtrTy ) , <nl> + buffer . getAlignment ( ) ) ; <nl> + } <nl> + <nl> + / / Dynamic packing . <nl> + llvm : : Value * isInline = emitLoadOfIsInline ( IGF , type ) ; <nl> + auto * outlineBB = IGF . createBasicBlock ( " outline . allocateValueInBuffer " ) ; <nl> + auto * doneBB = IGF . createBasicBlock ( " done " ) ; <nl> + llvm : : Value * addressInline , * addressOutline ; <nl> + auto * origBB = IGF . Builder . GetInsertBlock ( ) ; <nl> + addressInline = IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , storagePtrTy ) ; <nl> + IGF . Builder . CreateCondBr ( isInline , doneBB , outlineBB ) ; <nl> + <nl> + IGF . Builder . emitBlock ( outlineBB ) ; <nl> + { <nl> + ConditionalDominanceScope scope ( IGF ) ; <nl> + auto * size = emitLoadOfSize ( IGF , type ) ; <nl> + auto * alignMask = emitLoadOfAlignmentMask ( IGF , type ) ; <nl> + auto valueAddr = <nl> + IGF . emitAllocRawCall ( size , alignMask , " outline . ValueBuffer " ) ; <nl> + IGF . Builder . CreateStore ( <nl> + valueAddr , <nl> + Address ( IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , <nl> + valueAddr - > getType ( ) - > getPointerTo ( ) ) , <nl> + Alignment ( 1 ) ) ) ; <nl> + addressOutline = IGF . Builder . CreateBitCast ( valueAddr , storagePtrTy ) ; <nl> + IGF . Builder . CreateBr ( doneBB ) ; <nl> + } <nl> + <nl> + IGF . Builder . emitBlock ( doneBB ) ; <nl> + auto * addressOfValue = IGF . Builder . CreatePHI ( storagePtrTy , 2 ) ; <nl> + addressOfValue - > addIncoming ( addressInline , origBB ) ; <nl> + addressOfValue - > addIncoming ( addressOutline , outlineBB ) ; <nl> + <nl> + return Address ( addressOfValue , Alignment ( 1 ) ) ; <nl> + } <nl> + <nl> + Address irgen : : emitProjectValueInBuffer ( IRGenFunction & IGF , SILType type , <nl> + Address buffer ) { <nl> + / / Handle FixedSize types . <nl> + auto & IGM = IGF . IGM ; <nl> + auto storagePtrTy = IGM . getStoragePointerType ( type ) ; <nl> + if ( auto * fixedTI = dyn_cast < FixedTypeInfo > ( & IGF . getTypeInfo ( type ) ) ) { <nl> + auto packing = fixedTI - > getFixedPacking ( IGM ) ; <nl> + <nl> + / / Inline representation . <nl> + if ( packing = = FixedPacking : : OffsetZero ) { <nl> + return Address ( <nl> + IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , storagePtrTy ) , <nl> + buffer . getAlignment ( ) ) ; <nl> + } <nl> + <nl> + / / Outline representation . <nl> + assert ( packing = = FixedPacking : : Allocate & & " Expect non dynamic packing " ) ; <nl> + auto valueAddr = IGF . Builder . CreateLoad ( <nl> + Address ( IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , <nl> + storagePtrTy - > getPointerTo ( ) ) , <nl> + buffer . getAlignment ( ) ) ) ; <nl> + return Address ( IGF . Builder . CreateBitCast ( valueAddr , storagePtrTy ) , <nl> + buffer . getAlignment ( ) ) ; <nl> + } <nl> + <nl> + / / Dynamic packing . <nl> + llvm : : Value * isInline = emitLoadOfIsInline ( IGF , type ) ; <nl> + auto * outlineBB = IGF . createBasicBlock ( " outline . projectValueInBuffer " ) ; <nl> + auto * doneBB = IGF . createBasicBlock ( " done " ) ; <nl> + llvm : : Value * addressInline , * addressOutline ; <nl> + auto * origBB = IGF . Builder . GetInsertBlock ( ) ; <nl> + addressInline = IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , storagePtrTy ) ; <nl> + <nl> + IGF . Builder . CreateCondBr ( isInline , doneBB , outlineBB ) ; <nl> + <nl> + IGF . Builder . emitBlock ( outlineBB ) ; <nl> + { <nl> + auto ptr = IGF . Builder . CreateLoad ( <nl> + Address ( IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , <nl> + storagePtrTy - > getPointerTo ( ) ) , <nl> + Alignment ( 1 ) ) ) ; <nl> + addressOutline = IGF . Builder . CreateBitCast ( ptr , storagePtrTy ) ; <nl> + IGF . Builder . CreateBr ( doneBB ) ; <nl> + } <nl> + <nl> + IGF . Builder . emitBlock ( doneBB ) ; <nl> + auto * addressOfValue = IGF . Builder . CreatePHI ( storagePtrTy , 2 ) ; <nl> + addressOfValue - > addIncoming ( addressInline , origBB ) ; <nl> + addressOfValue - > addIncoming ( addressOutline , outlineBB ) ; <nl> + <nl> + return Address ( addressOfValue , Alignment ( 1 ) ) ; <nl> } <nl> <nl> void irgen : : emitDeallocateValueInBuffer ( IRGenFunction & IGF , <nl> SILType type , <nl> Address buffer ) { <nl> - auto * size = emitLoadOfSize ( IGF , type ) ; <nl> - auto * alignMask = emitLoadOfAlignmentMask ( IGF , type ) ; <nl> - auto * ptr = IGF . Builder . CreateLoad ( Address ( <nl> - IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , IGF . IGM . Int8PtrPtrTy ) , <nl> - Alignment ( 1 ) ) ) ; <nl> - / / TODO : check whether we fit in the inline value buffer . <nl> - IGF . emitDeallocRawCall ( ptr , size , alignMask ) ; <nl> + / / Handle FixedSize types . <nl> + auto & IGM = IGF . IGM ; <nl> + if ( auto * fixedTI = dyn_cast < FixedTypeInfo > ( & IGF . getTypeInfo ( type ) ) ) { <nl> + auto packing = fixedTI - > getFixedPacking ( IGM ) ; <nl> + <nl> + / / Inline representation . <nl> + if ( packing = = FixedPacking : : OffsetZero ) <nl> + return ; <nl> + <nl> + / / Outline representation . <nl> + assert ( packing = = FixedPacking : : Allocate & & " Expect non dynamic packing " ) ; <nl> + auto size = fixedTI - > getStaticSize ( IGM ) ; <nl> + auto alignMask = fixedTI - > getStaticAlignmentMask ( IGM ) ; <nl> + auto * ptr = IGF . Builder . CreateLoad ( Address ( <nl> + IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , IGM . Int8PtrPtrTy ) , <nl> + buffer . getAlignment ( ) ) ) ; <nl> + IGF . emitDeallocRawCall ( ptr , size , alignMask ) ; <nl> + return ; <nl> + } <nl> + <nl> + / / Dynamic packing . <nl> + llvm : : Value * isInline = emitLoadOfIsInline ( IGF , type ) ; <nl> + auto * outlineBB = IGF . createBasicBlock ( " outline . projectValueInBuffer " ) ; <nl> + auto * doneBB = IGF . createBasicBlock ( " done " ) ; <nl> + <nl> + IGF . Builder . CreateCondBr ( isInline , doneBB , outlineBB ) ; <nl> + <nl> + IGF . Builder . emitBlock ( outlineBB ) ; <nl> + { <nl> + ConditionalDominanceScope scope ( IGF ) ; <nl> + auto * size = emitLoadOfSize ( IGF , type ) ; <nl> + auto * alignMask = emitLoadOfAlignmentMask ( IGF , type ) ; <nl> + auto * ptr = IGF . Builder . CreateLoad ( Address ( <nl> + IGF . Builder . CreateBitCast ( buffer . getAddress ( ) , IGM . Int8PtrPtrTy ) , <nl> + buffer . getAlignment ( ) ) ) ; <nl> + IGF . emitDeallocRawCall ( ptr , size , alignMask ) ; <nl> + IGF . Builder . CreateBr ( doneBB ) ; <nl> + } <nl> + <nl> + IGF . Builder . emitBlock ( doneBB ) ; <nl> } <nl> mmm a / stdlib / public / runtime / Casting . cpp <nl> ppp b / stdlib / public / runtime / Casting . cpp <nl> static void unwrapExistential ( OpaqueValue * src , <nl> auto opaqueContainer = reinterpret_cast < OpaqueExistentialContainer * > ( src ) ; <nl> srcCapturedType = opaqueContainer - > Type ; <nl> srcValue = srcType - > projectValue ( src ) ; <nl> - canTake = false ; <nl> + / / Can ' t take out of possibly shared existential boxes . <nl> + canTake = ( src = = srcValue ) ; <nl> + assert ( canTake = = srcCapturedType - > getValueWitnesses ( ) - > isValueInline ( ) & & <nl> + " Only inline storage is take - able " ) ; <nl> # else <nl> auto opaqueContainer = reinterpret_cast < OpaqueExistentialContainer * > ( src ) ; <nl> srcCapturedType = opaqueContainer - > Type ; <nl> static bool _dynamicCastFromExistential ( OpaqueValue * dest , <nl> } else { <nl> # ifdef SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS <nl> assert ( ! isOutOfLine & & <nl> - srcType - > getRepresentation ( ) ! = <nl> - ExistentialTypeRepresentation : : Opaque & & <nl> - " Should only see inline represenations and no opaque existential " ) ; <nl> + " Should only see inline represenations of existentials " ) ; <nl> # else <nl> / / swift_dynamicCast took or destroyed the value as per the original request <nl> / / We may still have an opaque existential container to deallocate . <nl> mmm a / stdlib / public / runtime / Metadata . cpp <nl> ppp b / stdlib / public / runtime / Metadata . cpp <nl> ExistentialTypeMetadata : : mayTakeValue ( const OpaqueValue * container ) const { <nl> / / Opaque existential containers uniquely own their contained value . <nl> case ExistentialTypeRepresentation : : Opaque : <nl> # ifdef SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS <nl> + { <nl> / / We can ' t take from a shared existential box without checking uniqueness . <nl> - return false ; <nl> + auto * opaque = <nl> + reinterpret_cast < const OpaqueExistentialContainer * > ( container ) ; <nl> + auto * vwt = opaque - > Type - > getValueWitnesses ( ) ; <nl> + return vwt - > isValueInline ( ) ; <nl> + } <nl> # else <nl> return true ; <nl> # endif <nl>
Merge pull request from aschwaighofer / cow_existentials_runtime_valuebuffer
apple/swift
d7065f19f8e47aa91fa336174f963741b9daa0e8
2017-03-21T20:05:29Z
mmm a / CHANGELOG <nl> ppp b / CHANGELOG <nl> <nl> v2 . 2 . 0 ( XXXX - XX - XX ) <nl> mmmmmmmmmmmmmmmmmm - <nl> <nl> + * fixed datafile debugger <nl> + <nl> * fixed check - version for empty directory <nl> <nl> * moved try / catch block to the top of routing chain <nl> mmm a / arangod / V8Server / v8 - vocbase . cpp <nl> ppp b / arangod / V8Server / v8 - vocbase . cpp <nl> static v8 : : Handle < v8 : : Value > JS_DatafileScanVocbaseCol ( v8 : : Arguments const & arg <nl> <nl> o - > Set ( v8 : : String : : New ( " position " ) , v8 : : Number : : New ( entry - > _position ) ) ; <nl> o - > Set ( v8 : : String : : New ( " size " ) , v8 : : Number : : New ( entry - > _size ) ) ; <nl> + o - > Set ( v8 : : String : : New ( " realSize " ) , v8 : : Number : : New ( entry - > _realSize ) ) ; <nl> o - > Set ( v8 : : String : : New ( " tick " ) , V8TickId ( entry - > _tick ) ) ; <nl> o - > Set ( v8 : : String : : New ( " type " ) , v8 : : Number : : New ( ( int ) entry - > _type ) ) ; <nl> o - > Set ( v8 : : String : : New ( " status " ) , v8 : : Number : : New ( ( int ) entry - > _status ) ) ; <nl> mmm a / arangod / VocBase / datafile . cpp <nl> ppp b / arangod / VocBase / datafile . cpp <nl> static TRI_df_scan_t ScanDatafile ( TRI_datafile_t const * datafile ) { <nl> <nl> entry . _position = ( TRI_voc_size_t ) ( ptr - datafile - > _data ) ; <nl> entry . _size = marker - > _size ; <nl> + entry . _realSize = TRI_DF_ALIGN_BLOCK ( marker - > _size ) ; <nl> entry . _tick = marker - > _tick ; <nl> entry . _type = marker - > _type ; <nl> entry . _status = 1 ; <nl> mmm a / arangod / VocBase / datafile . h <nl> ppp b / arangod / VocBase / datafile . h <nl> TRI_df_scan_t ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief scan result entry <nl> + / / / <nl> + / / / status : <nl> + / / / 1 - entry ok <nl> + / / / 2 - empty entry <nl> + / / / 3 - empty size <nl> + / / / 4 - size too small <nl> + / / / 5 - CRC failed <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> typedef struct TRI_df_scan_entry_s { <nl> TRI_voc_size_t _position ; <nl> TRI_voc_size_t _size ; <nl> + TRI_voc_size_t _realSize ; <nl> TRI_voc_tick_t _tick ; <nl> <nl> TRI_df_marker_type_t _type ; <nl> mmm a / js / server / arango - dfdb . js <nl> ppp b / js / server / arango - dfdb . js <nl> function QueryWipeDatafile ( collection , type , datafile , scan , lastGoodPos ) { <nl> <nl> var entry = entries [ lastGoodPos ] ; <nl> <nl> - WipeDatafile ( collection , type , datafile , entry . position + entry . size ) ; <nl> + WipeDatafile ( collection , type , datafile , entry . position + entry . realSize ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> function PrintEntries ( entries , amount ) { <nl> case 5 : s = " FAILED ( crc mismatch ) " ; break ; <nl> } <nl> <nl> - printf ( " % d : status % s type % d size % d , tick % s \ n " , i , s , entry . type , entry . size , entry . tick ) ; <nl> + printf ( " % d : status % s type % d size % d , tick % s \ n " , i , s , entry . type , entry . realSize , entry . tick ) ; <nl> } <nl> } <nl> <nl> function DeepCheckDatafile ( collection , type , datafile , scan ) { <nl> } <nl> <nl> if ( ! stillGood ) { <nl> - printf ( " Last good position : % d \ n " , lastGood . position + lastGood . size ) ; <nl> + printf ( " Last good position : % d \ n " , lastGood . position + lastGood . realSize ) ; <nl> printf ( " \ n " ) ; <nl> <nl> QueryWipeDatafile ( collection , type , datafile , scan , lastGoodPos ) ; <nl> function CheckDatafile ( collection , type , datafile , issues , details ) { <nl> break ; <nl> <nl> case 3 : <nl> - statusMessage = " FATAL ( reached corrupt marker ) " ; <nl> + statusMessage = " FATAL ( reached corrupted marker ) " ; <nl> color = internal . COLORS . COLOR_RED ; <nl> break ; <nl> <nl> function main ( argv ) { <nl> printf ( " Prints details ( Y / N ) ? " ) ; <nl> <nl> var details = false ; <nl> + <nl> while ( true ) { <nl> line = console . getline ( ) ; <nl> + <nl> if ( line = = = " " ) { <nl> printf ( " Exiting . Please wait . \ n " ) ; <nl> return ; <nl> function main ( argv ) { <nl> if ( line = = = " yes " | | line = = = " YES " | | line = = = " y " | | line = = = " Y " ) { <nl> details = true ; <nl> } <nl> + <nl> break ; <nl> } <nl> <nl>
fixed datafile debugger
arangodb/arangodb
f794ee83685ef8dc38c0c4b0271b5434209f2e2d
2014-06-17T07:22:56Z
mmm a / fdbrpc / LoadBalance . actor . h <nl> ppp b / fdbrpc / LoadBalance . actor . h <nl> Future < REPLY_TYPE ( Request ) > loadBalance ( <nl> if ( now ( ) - g_network - > networkMetrics . newestAlternativesFailure > FLOW_KNOBS - > ALTERNATIVES_FAILURE_RESET_TIME ) { <nl> g_network - > networkMetrics . oldestAlternativesFailure = now ( ) ; <nl> } <nl> - <nl> - double delay = std : : max ( std : : min ( ( now ( ) - g_network - > networkMetrics . oldestAlternativesFailure ) * FLOW_KNOBS - > ALTERNATIVES_FAILURE_DELAY_RATIO , FLOW_KNOBS - > ALTERNATIVES_FAILURE_MAX_DELAY ) , FLOW_KNOBS - > ALTERNATIVES_FAILURE_MIN_DELAY ) ; <nl> + double elapsed = now ( ) - g_network - > networkMetrics . oldestAlternativesFailure ; <nl> + double delay = std : : min ( elapsed * FLOW_KNOBS - > ALTERNATIVES_FAILURE_DELAY_RATIO , FLOW_KNOBS - > ALTERNATIVES_FAILURE_MAX_DELAY ) ; <nl> + delay = std : : max ( delay , std : : min ( elapsed * FLOW_KNOBS - > ALTERNATIVES_FAILURE_SLOW_DELAY_RATIO , FLOW_KNOBS - > ALTERNATIVES_FAILURE_SLOW_MAX_DELAY ) ) ; <nl> + delay = std : : max ( delay , FLOW_KNOBS - > ALTERNATIVES_FAILURE_MIN_DELAY ) ; <nl> <nl> / / Making this SevWarn means a lot of clutter <nl> if ( now ( ) - g_network - > networkMetrics . newestAlternativesFailure > 1 | | deterministicRandom ( ) - > random01 ( ) < 0 . 01 ) { <nl> mmm a / flow / Knobs . cpp <nl> ppp b / flow / Knobs . cpp <nl> FlowKnobs : : FlowKnobs ( bool randomize , bool isSimulated ) { <nl> init ( SECOND_REQUEST_BUDGET_GROWTH , 0 . 05 ) ; <nl> init ( SECOND_REQUEST_MAX_BUDGET , 100 . 0 ) ; <nl> init ( ALTERNATIVES_FAILURE_RESET_TIME , 5 . 0 ) ; <nl> - init ( ALTERNATIVES_FAILURE_MAX_DELAY , 1 . 0 ) ; <nl> init ( ALTERNATIVES_FAILURE_MIN_DELAY , 0 . 05 ) ; <nl> init ( ALTERNATIVES_FAILURE_DELAY_RATIO , 0 . 2 ) ; <nl> + init ( ALTERNATIVES_FAILURE_MAX_DELAY , 1 . 0 ) ; <nl> + init ( ALTERNATIVES_FAILURE_SLOW_DELAY_RATIO , 0 . 04 ) ; <nl> + init ( ALTERNATIVES_FAILURE_SLOW_MAX_DELAY , 30 . 0 ) ; <nl> init ( FUTURE_VERSION_INITIAL_BACKOFF , 1 . 0 ) ; <nl> init ( FUTURE_VERSION_MAX_BACKOFF , 8 . 0 ) ; <nl> init ( FUTURE_VERSION_BACKOFF_GROWTH , 2 . 0 ) ; <nl> mmm a / flow / Knobs . h <nl> ppp b / flow / Knobs . h <nl> class FlowKnobs : public Knobs { <nl> double SECOND_REQUEST_BUDGET_GROWTH ; <nl> double SECOND_REQUEST_MAX_BUDGET ; <nl> double ALTERNATIVES_FAILURE_RESET_TIME ; <nl> - double ALTERNATIVES_FAILURE_MAX_DELAY ; <nl> double ALTERNATIVES_FAILURE_MIN_DELAY ; <nl> double ALTERNATIVES_FAILURE_DELAY_RATIO ; <nl> + double ALTERNATIVES_FAILURE_MAX_DELAY ; <nl> + double ALTERNATIVES_FAILURE_SLOW_DELAY_RATIO ; <nl> + double ALTERNATIVES_FAILURE_SLOW_MAX_DELAY ; <nl> double FUTURE_VERSION_INITIAL_BACKOFF ; <nl> double FUTURE_VERSION_MAX_BACKOFF ; <nl> double FUTURE_VERSION_BACKOFF_GROWTH ; <nl>
The delay for all_alteratives_failed can scale all the way up to 30 . 0 at a much slow time ratio
apple/foundationdb
5f7d3498eaff5f203fe177c6768039d7e963103a
2019-08-09T19:35:19Z
mmm a / src / video_core / renderer_opengl / gl_stream_buffer . h <nl> ppp b / src / video_core / renderer_opengl / gl_stream_buffer . h <nl> <nl> / / Licensed under GPLv2 or any later version <nl> / / Refer to the license . txt file included . <nl> <nl> + # pragma once <nl> + <nl> # include < tuple > <nl> # include < glad / glad . h > <nl> # include " common / common_types . h " <nl>
gl_stream_buffer : Add missing header guard
yuzu-emu/yuzu
93a4097e9d4aab5765f6ca9d68200016f79466f8
2018-08-21T03:25:08Z
mmm a / shaders / src / light_indirect . fs <nl> ppp b / shaders / src / light_indirect . fs <nl> vec3 isEvaluateIBL ( const PixelParams pixel , vec3 n , vec3 v , float NoV ) { <nl> const float K = 4 . 0 ; <nl> <nl> / / IMPORTANT : Keep numSample = 1 < < numSampleBits <nl> - const uint numSamples = IBL_INTEGRATION_IMPORTANCE_SAMPLING_COUNT ; <nl> + const uint numSamples = uint ( IBL_INTEGRATION_IMPORTANCE_SAMPLING_COUNT ) ; <nl> const uint numSampleBits = uint ( log2 ( float ( numSamples ) ) ) ; <nl> const float invNumSamples = 1 . 0 / float ( numSamples ) ; <nl> <nl> vec3 indirectSpecular = vec3 ( 0 . 0 ) ; <nl> - for ( uint i = 0 ; i < numSamples ; i + + ) { <nl> + for ( uint i = 0u ; i < numSamples ; i + + ) { <nl> / / Compute Hammersley sequence <nl> / / TODO : these should come from uniforms <nl> / / TODO : we should do this with logical bit operations <nl> uint t = i ; <nl> - uint bits = 0 ; <nl> - for ( uint j = 0 ; j < numSampleBits ; j + + ) { <nl> - bits = bits * 2 + ( t - ( 2 * ( t / 2 ) ) ) ; <nl> - t / = 2 ; <nl> + uint bits = 0u ; <nl> + for ( uint j = 0u ; j < numSampleBits ; j + + ) { <nl> + bits = bits * 2u + ( t - ( 2u * ( t / 2u ) ) ) ; <nl> + t / = 2u ; <nl> } <nl> vec2 u = vec2 ( float ( i ) , float ( bits ) ) * invNumSamples ; <nl> <nl>
Fix importance sampling for OpenGLES targets
google/filament
66d97bc9c0a3451e6820f6a5daadf29075fa8882
2018-09-18T02:41:05Z
mmm a / src / heap / heap - inl . h <nl> ppp b / src / heap / heap - inl . h <nl> AlwaysAllocateScope : : ~ AlwaysAllocateScope ( ) { <nl> } <nl> <nl> <nl> - GCCallbacksScope : : GCCallbacksScope ( Heap * heap ) : heap_ ( heap ) { <nl> - heap_ - > gc_callbacks_depth_ + + ; <nl> - } <nl> - <nl> - <nl> - GCCallbacksScope : : ~ GCCallbacksScope ( ) { heap_ - > gc_callbacks_depth_ - - ; } <nl> - <nl> - <nl> - bool GCCallbacksScope : : CheckReenter ( ) { <nl> - return heap_ - > gc_callbacks_depth_ = = 1 ; <nl> - } <nl> - <nl> - <nl> void VerifyPointersVisitor : : VisitPointers ( Object * * start , Object * * end ) { <nl> for ( Object * * current = start ; current < end ; current + + ) { <nl> if ( ( * current ) - > IsHeapObject ( ) ) { <nl> mmm a / src / heap / heap . cc <nl> ppp b / src / heap / heap . cc <nl> void Heap : : PreprocessStackTraces ( ) { <nl> } <nl> <nl> <nl> + class GCCallbacksScope { <nl> + public : <nl> + explicit GCCallbacksScope ( Heap * heap ) : heap_ ( heap ) { <nl> + heap_ - > gc_callbacks_depth_ + + ; <nl> + } <nl> + ~ GCCallbacksScope ( ) { heap_ - > gc_callbacks_depth_ - - ; } <nl> + <nl> + bool CheckReenter ( ) { return heap_ - > gc_callbacks_depth_ = = 1 ; } <nl> + <nl> + private : <nl> + Heap * heap_ ; <nl> + } ; <nl> + <nl> + <nl> void Heap : : HandleGCRequest ( ) { <nl> if ( incremental_marking ( ) - > request_type ( ) = = <nl> IncrementalMarking : : COMPLETE_MARKING ) { <nl> mmm a / src / heap / heap . h <nl> ppp b / src / heap / heap . h <nl> class AlwaysAllocateScope { <nl> } ; <nl> <nl> <nl> - class GCCallbacksScope { <nl> - public : <nl> - explicit inline GCCallbacksScope ( Heap * heap ) ; <nl> - inline ~ GCCallbacksScope ( ) ; <nl> - <nl> - inline bool CheckReenter ( ) ; <nl> - <nl> - private : <nl> - Heap * heap_ ; <nl> - } ; <nl> - <nl> - <nl> / / Visitor class to verify interior pointers in spaces that do not contain <nl> / / or care about intergenerational references . All heap object pointers have to <nl> / / point into the heap to a location that has a map pointer at its first word . <nl>
[ heap ] Prevent leakage of GCCallbacksScope outside of heap .
v8/v8
0faceaec7fb961738d9ee9a36b5080a91c8a5abc
2015-09-08T17:14:27Z
mmm a / arangod / Cluster / ClusterFeature . cpp <nl> ppp b / arangod / Cluster / ClusterFeature . cpp <nl> using namespace arangodb : : options ; <nl> <nl> ClusterFeature : : ClusterFeature ( application_features : : ApplicationServer * server ) <nl> : ApplicationFeature ( server , " Cluster " ) , <nl> - _username ( " root " ) , <nl> _unregisterOnShutdown ( false ) , <nl> _enableCluster ( false ) , <nl> _heartbeatThread ( nullptr ) , <nl> void ClusterFeature : : collectOptions ( std : : shared_ptr < ProgramOptions > options ) { <nl> options - > addOption ( " - - cluster . my - address " , " this server ' s endpoint " , <nl> new StringParameter ( & _myAddress ) ) ; <nl> <nl> - options - > addOption ( " - - cluster . username " , <nl> - " username used for cluster - internal communication " , <nl> - new StringParameter ( & _username ) ) ; <nl> - <nl> - options - > addOption ( " - - cluster . password " , <nl> - " password used for cluster - internal communication " , <nl> - new StringParameter ( & _password ) ) ; <nl> - <nl> options - > addOption ( " - - cluster . data - path " , <nl> " path to cluster database directory " , <nl> new StringParameter ( & _dataPath ) ) ; <nl> mmm a / arangod / Cluster / ClusterFeature . h <nl> ppp b / arangod / Cluster / ClusterFeature . h <nl> class ClusterFeature : public application_features : : ApplicationFeature { <nl> std : : string _myId ; <nl> std : : string _myRole ; <nl> std : : string _myAddress ; <nl> - std : : string _username ; <nl> - std : : string _password ; <nl> std : : string _dataPath ; <nl> std : : string _logPath ; <nl> std : : string _arangodPath ; <nl>
remove - - cluster . password and username
arangodb/arangodb
8ac79712a0cc499f731be2b291af3d0b7f4457d2
2016-11-17T14:29:23Z
mmm a / modules / highgui / src / cap_dc1394_v2 . cpp <nl> ppp b / modules / highgui / src / cap_dc1394_v2 . cpp <nl> bool CvCaptureCAM_DC1394_v2_CPP : : startCapture ( ) <nl> return false ; <nl> if ( isoSpeed > 0 ) <nl> { <nl> + / / if capable set operation mode to 1394b for iso speeds above 400 <nl> + if ( isoSpeed > 400 & & dcCam - > bmode_capable = = DC1394_TRUE ) <nl> + { <nl> + dc1394_video_set_operation_mode ( dcCam , DC1394_OPERATION_MODE_1394B ) ; <nl> + } <nl> code = dc1394_video_set_iso_speed ( dcCam , <nl> isoSpeed < = 100 ? DC1394_ISO_SPEED_100 : <nl> isoSpeed < = 200 ? DC1394_ISO_SPEED_200 : <nl>
dc1394 - 2 : support for operation mode 1394b added
opencv/opencv
e32700cf8f92b04fa2b0112281c1f369428b6584
2013-06-27T13:05:32Z
mmm a / libraries / DNSServer / src / DNSServer . cpp <nl> ppp b / libraries / DNSServer / src / DNSServer . cpp <nl> <nl> # include " DNSServer . h " <nl> # include < lwip / def . h > <nl> # include < Arduino . h > <nl> + # include < memory > <nl> <nl> # ifdef DEBUG_ESP_PORT <nl> # define DEBUG_OUTPUT DEBUG_ESP_PORT <nl> <nl> # define DEBUG_OUTPUT Serial <nl> # endif <nl> <nl> + # define DNS_HEADER_SIZE sizeof ( DNSHeader ) <nl> + <nl> DNSServer : : DNSServer ( ) <nl> { <nl> _ttl = lwip_htonl ( 60 ) ; <nl> void DNSServer : : stop ( ) <nl> void DNSServer : : downcaseAndRemoveWwwPrefix ( String & domainName ) <nl> { <nl> domainName . toLowerCase ( ) ; <nl> - domainName . replace ( " www . " , " " ) ; <nl> + if ( domainName . startsWith ( " www . " ) ) <nl> + domainName . remove ( 0 , 4 ) ; <nl> } <nl> <nl> - void DNSServer : : processNextRequest ( ) <nl> + void DNSServer : : respondToRequest ( uint8_t * buffer , size_t length ) <nl> { <nl> - size_t packetSize = _udp . parsePacket ( ) ; <nl> + DNSHeader * dnsHeader ; <nl> + uint8_t * query , * start ; <nl> + const char * matchString ; <nl> + size_t remaining , labelLength , queryLength ; <nl> + uint16_t qtype , qclass ; <nl> + <nl> + dnsHeader = ( DNSHeader * ) buffer ; <nl> <nl> - if ( packetSize > = sizeof ( DNSHeader ) ) <nl> - { <nl> - uint8_t * buffer = reinterpret_cast < uint8_t * > ( malloc ( packetSize ) ) ; <nl> - if ( buffer = = NULL ) return ; <nl> + / / Must be a query for us to do anything with it <nl> + if ( dnsHeader - > QR ! = DNS_QR_QUERY ) <nl> + return ; <nl> <nl> - _udp . read ( buffer , packetSize ) ; <nl> + / / If operation is anything other than query , we don ' t do it <nl> + if ( dnsHeader - > OPCode ! = DNS_OPCODE_QUERY ) <nl> + return replyWithError ( dnsHeader , DNSReplyCode : : NotImplemented ) ; <nl> + <nl> + / / Only support requests containing single queries - everything else <nl> + / / is badly defined <nl> + if ( dnsHeader - > QDCount ! = lwip_htons ( 1 ) ) <nl> + return replyWithError ( dnsHeader , DNSReplyCode : : FormError ) ; <nl> + <nl> + / / We must return a FormError in the case of a non - zero ARCount to <nl> + / / be minimally compatible with EDNS resolvers <nl> + if ( dnsHeader - > ANCount ! = 0 | | dnsHeader - > NSCount ! = 0 <nl> + | | dnsHeader - > ARCount ! = 0 ) <nl> + return replyWithError ( dnsHeader , DNSReplyCode : : FormError ) ; <nl> + <nl> + / / Even if we ' re not going to use the query , we need to parse it <nl> + / / so we can check the address type that ' s being queried <nl> + <nl> + query = start = buffer + DNS_HEADER_SIZE ; <nl> + remaining = length - DNS_HEADER_SIZE ; <nl> + while ( remaining ! = 0 & & * start ! = 0 ) { <nl> + labelLength = * start ; <nl> + if ( labelLength + 1 > remaining ) <nl> + return replyWithError ( dnsHeader , DNSReplyCode : : FormError ) ; <nl> + remaining - = ( labelLength + 1 ) ; <nl> + start + = ( labelLength + 1 ) ; <nl> + } <nl> <nl> - DNSHeader * dnsHeader = reinterpret_cast < DNSHeader * > ( buffer ) ; <nl> + / / 1 octet labelLength , 2 octet qtype , 2 octet qclass <nl> + if ( remaining < 5 ) <nl> + return replyWithError ( dnsHeader , DNSReplyCode : : FormError ) ; <nl> <nl> - if ( dnsHeader - > QR = = DNS_QR_QUERY & & <nl> - dnsHeader - > OPCode = = DNS_OPCODE_QUERY & & <nl> - requestIncludesOnlyOneQuestion ( dnsHeader ) & & <nl> - ( _domainName = = " * " | | getDomainNameWithoutWwwPrefix ( buffer , packetSize ) = = _domainName ) <nl> - ) <nl> - { <nl> - replyWithIP ( buffer , packetSize ) ; <nl> - } <nl> - else if ( dnsHeader - > QR = = DNS_QR_QUERY ) <nl> - { <nl> - replyWithCustomCode ( buffer , packetSize ) ; <nl> + start + = 1 ; / / Skip the 0 length label that we found above <nl> + <nl> + memcpy ( & qtype , start , sizeof ( qtype ) ) ; <nl> + start + = 2 ; <nl> + memcpy ( & qclass , start , sizeof ( qclass ) ) ; <nl> + start + = 2 ; <nl> + <nl> + queryLength = start - query ; <nl> + <nl> + if ( qclass ! = lwip_htons ( DNS_QCLASS_ANY ) <nl> + & & qclass ! = lwip_htons ( DNS_QCLASS_IN ) ) <nl> + return replyWithError ( dnsHeader , DNSReplyCode : : NonExistentDomain , <nl> + query , queryLength ) ; <nl> + <nl> + if ( qtype ! = lwip_htons ( DNS_QTYPE_A ) <nl> + & & qtype ! = lwip_htons ( DNS_QTYPE_ANY ) ) <nl> + return replyWithError ( dnsHeader , DNSReplyCode : : NonExistentDomain , <nl> + query , queryLength ) ; <nl> + <nl> + / / If we have no domain name configured , just return an error <nl> + if ( _domainName = = " " ) <nl> + return replyWithError ( dnsHeader , _errorReplyCode , <nl> + query , queryLength ) ; <nl> + <nl> + / / If we ' re running with a wildcard we can just return a result now <nl> + if ( _domainName = = " * " ) <nl> + return replyWithIP ( dnsHeader , query , queryLength ) ; <nl> + <nl> + matchString = _domainName . c_str ( ) ; <nl> + <nl> + start = query ; <nl> + <nl> + / / If there ' s a leading ' www ' , skip it <nl> + if ( * start = = 3 & & strncasecmp ( " www " , ( char * ) start + 1 , 3 ) = = 0 ) <nl> + start + = 4 ; <nl> + <nl> + while ( * start ! = 0 ) { <nl> + labelLength = * start ; <nl> + start + = 1 ; <nl> + while ( labelLength > 0 ) { <nl> + if ( tolower ( * start ) ! = * matchString ) <nl> + return replyWithError ( dnsHeader , _errorReplyCode , <nl> + query , queryLength ) ; <nl> + + + start ; <nl> + + + matchString ; <nl> + - - labelLength ; <nl> } <nl> + if ( * start = = 0 & & * matchString = = ' \ 0 ' ) <nl> + return replyWithIP ( dnsHeader , query , queryLength ) ; <nl> <nl> - free ( buffer ) ; <nl> + if ( * matchString ! = ' . ' ) <nl> + return replyWithError ( dnsHeader , _errorReplyCode , <nl> + query , queryLength ) ; <nl> + + + matchString ; <nl> } <nl> - } <nl> <nl> - bool DNSServer : : requestIncludesOnlyOneQuestion ( const DNSHeader * dnsHeader ) <nl> - { <nl> - return lwip_ntohs ( dnsHeader - > QDCount ) = = 1 & & <nl> - dnsHeader - > ANCount = = 0 & & <nl> - dnsHeader - > NSCount = = 0 & & <nl> - dnsHeader - > ARCount = = 0 ; <nl> + return replyWithError ( dnsHeader , _errorReplyCode , <nl> + query , queryLength ) ; <nl> } <nl> <nl> - String DNSServer : : getDomainNameWithoutWwwPrefix ( const uint8_t * buffer , size_t packetSize ) <nl> + void DNSServer : : processNextRequest ( ) <nl> { <nl> - String parsedDomainName ; <nl> - <nl> - const uint8_t * pos = buffer + sizeof ( DNSHeader ) ; <nl> - const uint8_t * end = buffer + packetSize ; <nl> - <nl> - / / to minimize reallocations due to concats below <nl> - / / we reserve enough space that a median or average domain <nl> - / / name size cold be easily contained without a reallocation <nl> - / / - max size would be 253 , in 2013 , average is 11 and max was 42 <nl> - / / <nl> - parsedDomainName . reserve ( 32 ) ; <nl> - <nl> - uint8_t labelLength = * pos ; <nl> - <nl> - while ( true ) <nl> - { <nl> - if ( labelLength = = 0 ) <nl> - { <nl> - / / no more labels <nl> - downcaseAndRemoveWwwPrefix ( parsedDomainName ) ; <nl> - return parsedDomainName ; <nl> - } <nl> + size_t currentPacketSize ; <nl> <nl> - / / append next label <nl> - for ( int i = 0 ; i < labelLength & & pos < end ; i + + ) <nl> - { <nl> - pos + + ; <nl> - parsedDomainName + = static_cast < char > ( * pos ) ; <nl> - } <nl> + currentPacketSize = _udp . parsePacket ( ) ; <nl> + if ( currentPacketSize = = 0 ) <nl> + return ; <nl> <nl> - if ( pos > = end ) <nl> - { <nl> - / / malformed packet , return an empty domain name <nl> - parsedDomainName = " " ; <nl> - return parsedDomainName ; <nl> - } <nl> - else <nl> - { <nl> - / / next label <nl> - pos + + ; <nl> - labelLength = * pos ; <nl> - <nl> - / / if there is another label , add delimiter <nl> - if ( labelLength ! = 0 ) <nl> - { <nl> - parsedDomainName + = " . " ; <nl> - } <nl> - } <nl> - } <nl> + / / The DNS RFC requires that DNS packets be less than 512 bytes in size , <nl> + / / so just discard them if they are larger <nl> + if ( currentPacketSize > MAX_DNS_PACKETSIZE ) <nl> + return ; <nl> + <nl> + / / If the packet size is smaller than the DNS header , then someone is <nl> + / / messing with us <nl> + if ( currentPacketSize < DNS_HEADER_SIZE ) <nl> + return ; <nl> + <nl> + std : : unique_ptr < uint8_t [ ] > buffer ( new ( std : : nothrow ) uint8_t [ currentPacketSize ] ) ; <nl> + <nl> + if ( buffer = = NULL ) <nl> + return ; <nl> + <nl> + _udp . read ( buffer . get ( ) , currentPacketSize ) ; <nl> + respondToRequest ( buffer . get ( ) , currentPacketSize ) ; <nl> + } <nl> + <nl> + void DNSServer : : writeNBOShort ( uint16_t value ) <nl> + { <nl> + _udp . write ( ( unsigned char * ) & value , 2 ) ; <nl> } <nl> <nl> - void DNSServer : : replyWithIP ( uint8_t * buffer , size_t packetSize ) <nl> + void DNSServer : : replyWithIP ( DNSHeader * dnsHeader , <nl> + unsigned char * query , <nl> + size_t queryLength ) <nl> { <nl> - DNSHeader * dnsHeader = reinterpret_cast < DNSHeader * > ( buffer ) ; <nl> + uint16_t value ; <nl> <nl> dnsHeader - > QR = DNS_QR_RESPONSE ; <nl> - dnsHeader - > ANCount = dnsHeader - > QDCount ; <nl> - dnsHeader - > QDCount = dnsHeader - > QDCount ; <nl> - / / dnsHeader - > RA = 1 ; <nl> + dnsHeader - > QDCount = lwip_htons ( 1 ) ; <nl> + dnsHeader - > ANCount = lwip_htons ( 1 ) ; <nl> + dnsHeader - > NSCount = 0 ; <nl> + dnsHeader - > ARCount = 0 ; <nl> <nl> _udp . beginPacket ( _udp . remoteIP ( ) , _udp . remotePort ( ) ) ; <nl> - _udp . write ( buffer , packetSize ) ; <nl> + _udp . write ( ( unsigned char * ) dnsHeader , sizeof ( DNSHeader ) ) ; <nl> + _udp . write ( query , queryLength ) ; <nl> + <nl> + / / Rather than restate the name here , we use a pointer to the name contained <nl> + / / in the query section . Pointers have the top two bits set . <nl> + value = 0xC000 | DNS_HEADER_SIZE ; <nl> + writeNBOShort ( lwip_htons ( value ) ) ; <nl> <nl> - _udp . write ( ( uint8_t ) 192 ) ; / / answer name is a pointer <nl> - _udp . write ( ( uint8_t ) 12 ) ; / / pointer to offset at 0x00c <nl> + / / Answer is type A ( an IPv4 address ) <nl> + writeNBOShort ( lwip_htons ( DNS_QTYPE_A ) ) ; <nl> <nl> - _udp . write ( ( uint8_t ) 0 ) ; / / 0x0001 answer is type A query ( host address ) <nl> - _udp . write ( ( uint8_t ) 1 ) ; <nl> + / / Answer is in the Internet Class <nl> + writeNBOShort ( lwip_htons ( DNS_QCLASS_IN ) ) ; <nl> <nl> - _udp . write ( ( uint8_t ) 0 ) ; / / 0x0001 answer is class IN ( internet address ) <nl> - _udp . write ( ( uint8_t ) 1 ) ; <nl> - <nl> + / / Output TTL ( already NBO ) <nl> _udp . write ( ( unsigned char * ) & _ttl , 4 ) ; <nl> <nl> / / Length of RData is 4 bytes ( because , in this case , RData is IPv4 ) <nl> - _udp . write ( ( uint8_t ) 0 ) ; <nl> - _udp . write ( ( uint8_t ) 4 ) ; <nl> + writeNBOShort ( lwip_htons ( sizeof ( _resolvedIP ) ) ) ; <nl> _udp . write ( _resolvedIP , sizeof ( _resolvedIP ) ) ; <nl> _udp . endPacket ( ) ; <nl> - <nl> - # ifdef DEBUG_ESP_DNS <nl> - DEBUG_OUTPUT . printf ( " DNS responds : % s for % s \ n " , <nl> - IPAddress ( _resolvedIP ) . toString ( ) . c_str ( ) , getDomainNameWithoutWwwPrefix ( buffer , packetSize ) . c_str ( ) ) ; <nl> - # endif <nl> } <nl> <nl> - void DNSServer : : replyWithCustomCode ( uint8_t * buffer , size_t packetSize ) <nl> + void DNSServer : : replyWithError ( DNSHeader * dnsHeader , <nl> + DNSReplyCode rcode , <nl> + unsigned char * query , <nl> + size_t queryLength ) <nl> { <nl> - if ( packetSize < sizeof ( DNSHeader ) ) <nl> - { <nl> - return ; <nl> - } <nl> - <nl> - DNSHeader * dnsHeader = reinterpret_cast < DNSHeader * > ( buffer ) ; <nl> - <nl> dnsHeader - > QR = DNS_QR_RESPONSE ; <nl> - dnsHeader - > RCode = ( unsigned char ) _errorReplyCode ; <nl> - dnsHeader - > QDCount = 0 ; <nl> + dnsHeader - > RCode = ( unsigned char ) rcode ; <nl> + if ( query ) <nl> + dnsHeader - > QDCount = lwip_htons ( 1 ) ; <nl> + else <nl> + dnsHeader - > QDCount = 0 ; <nl> + dnsHeader - > ANCount = 0 ; <nl> + dnsHeader - > NSCount = 0 ; <nl> + dnsHeader - > ARCount = 0 ; <nl> <nl> _udp . beginPacket ( _udp . remoteIP ( ) , _udp . remotePort ( ) ) ; <nl> - _udp . write ( buffer , sizeof ( DNSHeader ) ) ; <nl> + _udp . write ( ( unsigned char * ) dnsHeader , sizeof ( DNSHeader ) ) ; <nl> + if ( query ! = NULL ) <nl> + _udp . write ( query , queryLength ) ; <nl> _udp . endPacket ( ) ; <nl> } <nl> + <nl> + void DNSServer : : replyWithError ( DNSHeader * dnsHeader , <nl> + DNSReplyCode rcode ) <nl> + { <nl> + replyWithError ( dnsHeader , rcode , NULL , 0 ) ; <nl> + } <nl> mmm a / libraries / DNSServer / src / DNSServer . h <nl> ppp b / libraries / DNSServer / src / DNSServer . h <nl> <nl> # define DNS_QR_RESPONSE 1 <nl> # define DNS_OPCODE_QUERY 0 <nl> <nl> + # define DNS_QCLASS_IN 1 <nl> + # define DNS_QCLASS_ANY 255 <nl> + <nl> + # define DNS_QTYPE_A 1 <nl> + # define DNS_QTYPE_ANY 255 <nl> + <nl> # define MAX_DNSNAME_LENGTH 253 <nl> + # define MAX_DNS_PACKETSIZE 512 <nl> <nl> enum class DNSReplyCode <nl> { <nl> class DNSServer <nl> DNSReplyCode _errorReplyCode ; <nl> <nl> void downcaseAndRemoveWwwPrefix ( String & domainName ) ; <nl> - String getDomainNameWithoutWwwPrefix ( const uint8_t * buffer , size_t packetSize ) ; <nl> - bool requestIncludesOnlyOneQuestion ( const DNSHeader * dnsHeader ) ; <nl> - void replyWithIP ( uint8_t * buffer , size_t packetSize ) ; <nl> - void replyWithCustomCode ( uint8_t * buffer , size_t packetSize ) ; <nl> + void replyWithIP ( DNSHeader * dnsHeader , <nl> + unsigned char * query , <nl> + size_t queryLength ) ; <nl> + void replyWithError ( DNSHeader * dnsHeader , <nl> + DNSReplyCode rcode , <nl> + unsigned char * query , <nl> + size_t queryLength ) ; <nl> + void replyWithError ( DNSHeader * dnsHeader , <nl> + DNSReplyCode rcode ) ; <nl> + void respondToRequest ( uint8_t * buffer , size_t length ) ; <nl> + void writeNBOShort ( uint16_t value ) ; <nl> } ; <nl> - # endif <nl> \ No newline at end of file <nl> + # endif <nl>
Rework DNSServer to be more robust ( )
esp8266/Arduino
eaac1e8b248b3d84fcc2e8658e26091db78587ad
2019-01-05T15:47:00Z
mmm a / include / caffe / loss_layers . hpp <nl> ppp b / include / caffe / loss_layers . hpp <nl> class SigmoidCrossEntropyLossLayer : public LossLayer < Dtype > { <nl> / / / @ copydoc SigmoidCrossEntropyLossLayer <nl> virtual void Forward_cpu ( const vector < Blob < Dtype > * > & bottom , <nl> const vector < Blob < Dtype > * > & top ) ; <nl> - virtual void Forward_gpu ( const vector < Blob < Dtype > * > & bottom , <nl> - const vector < Blob < Dtype > * > & top ) ; <nl> <nl> / * * <nl> * @ brief Computes the sigmoid cross - entropy loss error gradient w . r . t . the <nl> mmm a / src / caffe / layers / sigmoid_cross_entropy_loss_layer . cpp <nl> ppp b / src / caffe / layers / sigmoid_cross_entropy_loss_layer . cpp <nl> void SigmoidCrossEntropyLossLayer < Dtype > : : Backward_cpu ( <nl> } <nl> <nl> # ifdef CPU_ONLY <nl> - STUB_GPU ( SigmoidCrossEntropyLossLayer ) ; <nl> + STUB_GPU_BACKWARD ( SigmoidCrossEntropyLossLayer , Backward ) ; <nl> # endif <nl> <nl> INSTANTIATE_CLASS ( SigmoidCrossEntropyLossLayer ) ; <nl> mmm a / src / caffe / layers / sigmoid_cross_entropy_loss_layer . cu <nl> ppp b / src / caffe / layers / sigmoid_cross_entropy_loss_layer . cu <nl> <nl> <nl> namespace caffe { <nl> <nl> - template < typename Dtype > <nl> - void SigmoidCrossEntropyLossLayer < Dtype > : : Forward_gpu ( <nl> - const vector < Blob < Dtype > * > & bottom , const vector < Blob < Dtype > * > & top ) { <nl> - / / The forward pass computes the sigmoid outputs . <nl> - sigmoid_bottom_vec_ [ 0 ] = bottom [ 0 ] ; <nl> - sigmoid_layer_ - > Forward ( sigmoid_bottom_vec_ , sigmoid_top_vec_ ) ; <nl> - / / Compute the loss ( negative log likelihood ) <nl> - const int count = bottom [ 0 ] - > count ( ) ; <nl> - const int num = bottom [ 0 ] - > num ( ) ; <nl> - / / Stable version of loss computation from input data <nl> - const Dtype * input_data = bottom [ 0 ] - > cpu_data ( ) ; <nl> - const Dtype * target = bottom [ 1 ] - > cpu_data ( ) ; <nl> - Dtype loss = 0 ; <nl> - for ( int i = 0 ; i < count ; + + i ) { <nl> - loss - = input_data [ i ] * ( target [ i ] - ( input_data [ i ] > = 0 ) ) - <nl> - log ( 1 + exp ( input_data [ i ] - 2 * input_data [ i ] * ( input_data [ i ] > = 0 ) ) ) ; <nl> - } <nl> - top [ 0 ] - > mutable_cpu_data ( ) [ 0 ] = loss / num ; <nl> - } <nl> - <nl> template < typename Dtype > <nl> void SigmoidCrossEntropyLossLayer < Dtype > : : Backward_gpu ( <nl> const vector < Blob < Dtype > * > & top , const vector < bool > & propagate_down , <nl> void SigmoidCrossEntropyLossLayer < Dtype > : : Backward_gpu ( <nl> } <nl> } <nl> <nl> - INSTANTIATE_LAYER_GPU_FUNCS ( SigmoidCrossEntropyLossLayer ) ; <nl> + INSTANTIATE_LAYER_GPU_BACKWARD ( SigmoidCrossEntropyLossLayer ) ; <nl> <nl> <nl> } / / namespace caffe <nl>
remove bogus implementation of SigmoidCrossEntropyLossLayer : : Forward_gpu
BVLC/caffe
6153231594b98c0933be21685708282bc6160b6c
2015-05-14T22:55:07Z
mmm a / docker / test / performance - comparison / download . sh <nl> ppp b / docker / test / performance - comparison / download . sh <nl> function download <nl> fi <nl> done <nl> <nl> - # Might have the same version on left and right ( for testing ) . <nl> + # Might have the same version on left and right ( for testing ) - - in this case we just copy <nl> + # already downloaded ' right ' to the ' left . There is the third case when we don ' t have to <nl> + # download anything , for example in some manual runs . In this case , SHAs are not set . <nl> if ! [ " $ left_sha " = " $ right_sha " ] <nl> then <nl> wget - nv - nd - c " $ left_path " - O - | tar - C left - - strip - components = 1 - zxv & <nl> - else <nl> + elif [ " $ right_sha " ! = " " ] <nl> + then <nl> mkdir left | | : <nl> - cp - a right / * left & <nl> + cp - an right / * left & <nl> fi <nl> <nl> for dataset_name in $ datasets <nl> mmm a / docker / test / performance - comparison / manual - run . sh <nl> ppp b / docker / test / performance - comparison / manual - run . sh <nl> function download <nl> mkdir left right db0 | | : <nl> <nl> " $ script_dir / download . sh " | | : & <nl> - cp - vP " $ repo_dir " / . . / build - gcc9 - rel / programs / clickhouse * right & <nl> - cp - vP " $ repo_dir " / . . / build - clang10 - rel / programs / clickhouse * left & <nl> + cp - nvP " $ repo_dir " / . . / build - gcc9 - rel / programs / clickhouse * left & <nl> + cp - nvP " $ repo_dir " / . . / build - clang10 - rel / programs / clickhouse * right & <nl> wait <nl> } <nl> <nl> function configure <nl> { <nl> # Test files <nl> - cp - av " $ repo_dir / tests / performance " right <nl> - cp - av " $ repo_dir / tests / performance " left <nl> + cp - nav " $ repo_dir / tests / performance " right <nl> + cp - nav " $ repo_dir / tests / performance " left <nl> <nl> # Configs <nl> - cp - av " $ script_dir / config " right <nl> - cp - av " $ script_dir / config " left <nl> - cp - av " $ repo_dir " / programs / server / config * right / config <nl> - cp - av " $ repo_dir " / programs / server / user * right / config <nl> - cp - av " $ repo_dir " / programs / server / config * left / config <nl> - cp - av " $ repo_dir " / programs / server / user * left / config <nl> + cp - nav " $ script_dir / config " right <nl> + cp - nav " $ script_dir / config " left <nl> + cp - nav " $ repo_dir " / programs / server / config * right / config <nl> + cp - nav " $ repo_dir " / programs / server / user * right / config <nl> + cp - nav " $ repo_dir " / programs / server / config * left / config <nl> + cp - nav " $ repo_dir " / programs / server / user * left / config <nl> <nl> tree left <nl> } <nl>
performance comparison
ClickHouse/ClickHouse
7547b850d6b84a9e5ef5b83c31062821359e46c6
2020-08-11T14:14:24Z
mmm a / Source / CNTKv2LibraryDll / API / CNTKLibrary . h <nl> ppp b / Source / CNTKv2LibraryDll / API / CNTKLibrary . h <nl> namespace CNTK <nl> { <nl> CNTK_API static const std : : wstring StaticAxisNamePrefix ; <nl> static const size_t SentinelStaticAxisIndexValueForDynamicAxes = SIZE_MAX ; <nl> + static const size_t SentinelStaticAxisIndexValueForAllStaticAxes = SIZE_MAX - 1 ; <nl> <nl> class UniqueDynamicAxesNames <nl> { <nl> namespace CNTK <nl> } <nl> <nl> / / / <nl> - / / / Static Axis object representing the default dynamic axis . <nl> + / / / Axis object representing the default dynamic axis . <nl> / / / <nl> CNTK_API static const Axis & DefaultDynamicAxis ( ) ; <nl> <nl> / / / <nl> - / / / Static Axis object representing the batch axis . <nl> + / / / Axis object representing the batch axis . <nl> / / / <nl> CNTK_API static const Axis & DefaultBatchAxis ( ) ; <nl> <nl> + / / / <nl> + / / / Axis object representing all the static axes of an operand <nl> + / / / <nl> + CNTK_API static const Axis & AllStaticAxes ( ) ; <nl> + <nl> / / / <nl> / / / Returns a new unique Dynamic axis <nl> / / / <nl> namespace CNTK <nl> } ; <nl> <nl> / / / <nl> - / / / Instantiate the CNTK buil - in test format minibatch source <nl> + / / / Instantiate the CNTK built - in test format minibatch source <nl> / / / <nl> inline MinibatchSourcePtr TextFormatMinibatchSource ( const std : : wstring & dataFilePath , const std : : vector < StreamConfiguration > & streamConfigs , size_t epochSize = SIZE_MAX ) <nl> { <nl> mmm a / Source / CNTKv2LibraryDll / Common . cpp <nl> ppp b / Source / CNTKv2LibraryDll / Common . cpp <nl> namespace CNTK <nl> return s_defaultBatchAxis ; <nl> } <nl> <nl> + / * static * / const Axis & Axis : : AllStaticAxes ( ) <nl> + { <nl> + static const Axis s_allStaticAxes ( SentinelStaticAxisIndexValueForAllStaticAxes ) ; <nl> + return s_allStaticAxes ; <nl> + } <nl> + <nl> / * static * / Axis Axis : : NewUniqueDynamicAxis ( const std : : wstring & axisNamePrefix , bool isOrderedDynamicAxis / * = true * / ) <nl> { <nl> return Axis ( s_uniqueDynamicAxisNames . NewUniqueDynamicAxisName ( axisNamePrefix ) , isOrderedDynamicAxis ) ; <nl> mmm a / Source / CNTKv2LibraryDll / Function . cpp <nl> ppp b / Source / CNTKv2LibraryDll / Function . cpp <nl> namespace CNTK <nl> for ( size_t i = 0 ; i < inputs [ 0 ] . Shape ( ) . Rank ( ) ; + + i ) <nl> reductionAxes . push_back ( i ) ; <nl> <nl> - outputShape = ReductionOpOutputShape ( op , predictionShape , reductionAxes ) ; <nl> + outputShape = ReductionOpOutputShape ( op , predictionShape , reductionAxes , / * preserveReductionAxes = * / false ) ; <nl> break ; <nl> } <nl> case PrimitiveOpType : : PastValue : <nl> namespace CNTK <nl> { <nl> assert ( inputs . size ( ) = = 1 ) ; <nl> auto reductionAxis = functionConfig [ PrimitiveFunction : : AttributeNameAxis ] . Value < Axis > ( ) ; <nl> - std : : vector < size_t > reductionAxes = { reductionAxis . StaticAxisIndex ( ) } ; <nl> - <nl> - outputShape = ReductionOpOutputShape ( op , inputs [ 0 ] . Shape ( ) , reductionAxes ) ; <nl> + if ( reductionAxis = = Axis : : AllStaticAxes ( ) ) <nl> + outputShape = { } ; <nl> + else <nl> + { <nl> + std : : vector < size_t > reductionAxes = { reductionAxis . StaticAxisIndex ( ) } ; <nl> + outputShape = ReductionOpOutputShape ( op , inputs [ 0 ] . Shape ( ) , reductionAxes , / * preserveReductionAxes = * / true ) ; <nl> + } <nl> break ; <nl> } <nl> case PrimitiveOpType : : BatchNormalization : <nl> namespace CNTK <nl> if ( inputs [ 0 ] . DynamicAxes ( ) . empty ( ) | | inputs [ 1 ] . DynamicAxes ( ) . empty ( ) | | inputs [ 2 ] . DynamicAxes ( ) . empty ( ) ) <nl> InvalidArgument ( " ScatterPacked requires all its operands to have dynamic axes " ) ; <nl> <nl> - if ( inputs [ 1 ] . Shape ( ) . Rank ( ) ! = 1 ) <nl> - InvalidArgument ( " ScatterPacked requires the packedIndex operand to be a scalar sequence " ) ; <nl> - <nl> outputShape = inputs [ 0 ] . Shape ( ) ; <nl> break ; <nl> } <nl> namespace CNTK <nl> newDynamicAxes . push_back ( operandAxis ) ; <nl> } <nl> <nl> - return Internal : : Gather ( operand , flags , newDynamicAxes ) ; <nl> + return Internal : : Gather ( operand , flags , newDynamicAxes , name ) ; <nl> } <nl> <nl> FunctionPtr Dropout ( const Variable & operand , double dropoutRate , const std : : wstring & name / * = L " " * / ) <nl> namespace CNTK <nl> Constant meanVar ( mean ) ; <nl> Constant invStdDevVar ( invStdDev ) ; <nl> <nl> - return ElementTimes ( Minus ( operand , meanVar ) , invStdDevVar ) ; <nl> + return ElementTimes ( Minus ( operand , meanVar ) , invStdDevVar , name ) ; <nl> } <nl> <nl> FunctionPtr Convolution ( const Variable & convolutionMap , <nl> namespace CNTK <nl> std : : copy ( currentFunctionOutputs . begin ( ) , currentFunctionOutputs . end ( ) , std : : back_inserter ( inputs ) ) ; <nl> } <nl> <nl> - return Internal : : Combine ( inputs ) ; <nl> + return Internal : : Combine ( inputs , name ) ; <nl> } <nl> <nl> namespace Sequence <nl> namespace CNTK <nl> FunctionPtr IsFirst ( const Variable & operand , const std : : wstring & name / * = L " " * / ) <nl> { <nl> VerifyIsSequence ( operand ) ; <nl> - return Internal : : IsWithin ( operand , 1 ) ; <nl> + return Internal : : IsWithin ( operand , 1 , name ) ; <nl> } <nl> <nl> FunctionPtr IsLast ( const Variable & operand , const std : : wstring & name / * = L " " * / ) <nl> { <nl> VerifyIsSequence ( operand ) ; <nl> - return Internal : : IsWithin ( operand , - 1 ) ; <nl> + return Internal : : IsWithin ( operand , - 1 , name ) ; <nl> } <nl> <nl> FunctionPtr First ( const Variable & operand , const std : : wstring & name / * = L " " * / ) <nl> { <nl> VerifyIsSequence ( operand ) ; <nl> - return Slice ( operand , operand . DynamicAxes ( ) [ 0 ] , 0 , 1 ) ; <nl> + return Slice ( operand , operand . DynamicAxes ( ) [ 0 ] , 0 , 1 , name ) ; <nl> } <nl> <nl> FunctionPtr Last ( const Variable & operand , const std : : wstring & name / * = L " " * / ) <nl> { <nl> VerifyIsSequence ( operand ) ; <nl> - return Slice ( operand , operand . DynamicAxes ( ) [ 0 ] , - 1 , 0 ) ; <nl> + return Slice ( operand , operand . DynamicAxes ( ) [ 0 ] , - 1 , 0 , name ) ; <nl> } <nl> <nl> std : : vector < Axis > WhereOpDynamicAxes ( const Variable & operand ) <nl> namespace CNTK <nl> } <nl> else <nl> { <nl> - auto rowSliceFunc = Internal : : Slice ( operand , Axis ( 0 ) , 0 , 1 ) ; <nl> - auto result = Minus ( rowSliceFunc , rowSliceFunc ) ; <nl> - <nl> - / / Reduce away all but the static axis 0 <nl> - for ( size_t i = 1 ; i < result - > Output ( ) . Shape ( ) . Rank ( ) ; + + i ) <nl> - result = ReduceSum ( result , Axis ( i ) ) ; <nl> - <nl> - return result ; <nl> + auto reduceAllStaticAxesFunc = Internal : : ReduceElements ( operand , PrimitiveFunction : : InternalSumReductionOpName , Axis : : AllStaticAxes ( ) ) ; <nl> + return Minus ( reduceAllStaticAxesFunc , reduceAllStaticAxesFunc ) ; <nl> } <nl> } <nl> <nl> namespace CNTK <nl> <nl> FunctionPtr Gather ( const Variable & operand , const Variable & condition , const std : : vector < Axis > & newDynamicAxes , const std : : wstring & name / * = L " " * / ) <nl> { <nl> - return Internal : : GatherPacked ( operand , Internal : : PackedIndex ( / * layout of * / operand , Where ( condition , newDynamicAxes ) ) ) ; <nl> + return Internal : : GatherPacked ( operand , Internal : : PackedIndex ( / * layout of * / operand , Where ( condition , newDynamicAxes ) ) , name ) ; <nl> } <nl> <nl> FunctionPtr Scatter ( const Variable & operand , const Variable & condition , const std : : vector < Axis > & newDynamicAxes , const std : : wstring & name / * = L " " * / ) <nl> { <nl> - return Internal : : ScatterPacked ( operand , Internal : : PackedIndex ( / * layout of * / condition , Where ( condition , newDynamicAxes ) ) , / * layout of * / condition ) ; <nl> + return Internal : : ScatterPacked ( operand , Internal : : PackedIndex ( / * layout of * / condition , Where ( condition , newDynamicAxes ) ) , / * layout of * / condition , name ) ; <nl> } <nl> <nl> FunctionPtr Slice ( const Variable & operand , const Axis & axis , int beginIndex , int endIndex , const std : : wstring & name / * = L " " * / ) <nl> namespace CNTK <nl> { <nl> using namespace std : : placeholders ; <nl> <nl> - if ( axis . IsStaticAxis ( ) ) <nl> + if ( axis . IsStaticAxis ( ) | | ( axis = = Axis : : AllStaticAxes ( ) ) ) <nl> { <nl> auto additionalProperties = Dictionary ( ) ; <nl> additionalProperties [ PrimitiveFunction : : AttributeNameAxis ] = axis ; <nl> namespace CNTK <nl> auto cumulativeSumFunction = reductionFunctor ( prevAccumulatedValuesFunction , operand ) ; <nl> cumulativeSumFunction - > ReplacePlaceholders ( { { cumulativeSumFunctionPlaceholder , cumulativeSumFunction } } ) ; <nl> <nl> - return CNTK : : Slice ( cumulativeSumFunction , axis , - 1 , 0 ) ; <nl> + return CNTK : : Slice ( cumulativeSumFunction , axis , - 1 , 0 , name ) ; <nl> } <nl> } <nl> } <nl> mmm a / Source / CNTKv2LibraryDll / Function . h <nl> ppp b / Source / CNTKv2LibraryDll / Function . h <nl> namespace CNTK <nl> return leftOperandShape . SubShape ( 0 , outputRank ) . AppendShape ( rightOperandShape . SubShape ( numReductionAxes ) ) ; <nl> } <nl> <nl> - static NDShape ReductionOpOutputShape ( PrimitiveOpType op , const NDShape & operandShape , const std : : vector < size_t > & reductionAxes ) <nl> + static NDShape ReductionOpOutputShape ( PrimitiveOpType op , const NDShape & operandShape , const std : : vector < size_t > & reductionAxes , bool preserveReductionAxes ) <nl> { <nl> if ( reductionAxes . size ( ) > operandShape . Rank ( ) ) <nl> RuntimeError ( " The number of reduction axes % d exceeds the rank in the operand shape % S of the reduction operation % s " , ( int ) reductionAxes . size ( ) , AsStringForErrorReporting ( operandShape ) . c_str ( ) , PrimitiveOpTypeName ( op ) ) ; <nl> <nl> - size_t numOutputAxes = operandShape . Rank ( ) - reductionAxes . size ( ) ; <nl> + size_t numOutputAxes = operandShape . Rank ( ) - ( preserveReductionAxes ? 0 : reductionAxes . size ( ) ) ; <nl> std : : vector < size_t > outputDims ( numOutputAxes ) ; <nl> for ( size_t i = 0 , j = 0 ; i < operandShape . Rank ( ) ; + + i ) <nl> { <nl> / / Skip axes being reduced over <nl> if ( std : : find ( reductionAxes . begin ( ) , reductionAxes . end ( ) , i ) ! = reductionAxes . end ( ) ) <nl> - continue ; <nl> - <nl> - outputDims [ j + + ] = operandShape [ i ] ; <nl> + { <nl> + if ( preserveReductionAxes ) <nl> + outputDims [ j + + ] = 1 ; <nl> + } <nl> + else <nl> + outputDims [ j + + ] = operandShape [ i ] ; <nl> } <nl> <nl> return NDShape ( std : : move ( outputDims ) ) ; <nl> mmm a / Source / CNTKv2LibraryDll / Utils . h <nl> ppp b / Source / CNTKv2LibraryDll / Utils . h <nl> namespace CNTK <nl> } <nl> } <nl> <nl> + static size_t const CNTKInternalIdxValueForAllStaticAxes = 0 ; <nl> inline Axis AsAxis ( size_t CNTKInternalAxisIdx ) <nl> { <nl> - if ( CNTKInternalAxisIdx = = 0 ) <nl> - LogicError ( " CNTK internal axis indices must be > 0 " ) ; <nl> + if ( CNTKInternalAxisIdx = = CNTKInternalIdxValueForAllStaticAxes ) <nl> + return Axis : : AllStaticAxes ( ) ; <nl> <nl> return Axis ( CNTKInternalAxisIdx - 1 ) ; <nl> } <nl> <nl> inline int AsCNTKInternalAxisIdx ( const Axis & axis ) <nl> { <nl> + if ( axis = = Axis : : AllStaticAxes ( ) ) <nl> + return CNTKInternalIdxValueForAllStaticAxes ; <nl> + <nl> if ( ! axis . IsStaticAxis ( ) ) <nl> LogicError ( " Only Axis that represent static indices can be converted to a CNTK internal axis index " ) ; <nl> <nl> mmm a / Tests / UnitTests / V2LibraryTests / Common . h <nl> ppp b / Tests / UnitTests / V2LibraryTests / Common . h <nl> inline void PrintTrainingProgress ( const CNTK : : Trainer & trainer , size_t minibatch <nl> <nl> inline std : : vector < size_t > GetStrides ( const CNTK : : NDShape & shape ) <nl> { <nl> + if ( shape . Rank ( ) = = 0 ) <nl> + return std : : vector < size_t > ( ) ; <nl> + <nl> std : : vector < size_t > strides ( shape . Rank ( ) - 1 ) ; <nl> size_t totalSize = 1 ; <nl> for ( size_t i = 0 ; i < shape . Rank ( ) - 1 ; + + i ) <nl> inline CNTK : : NDShape UnflattenedShape ( size_t flatennedIdx , const std : : vector < siz <nl> <nl> inline size_t FlattenedIndex ( const CNTK : : NDShape & shape , const std : : vector < size_t > & strides ) <nl> { <nl> + if ( shape . Rank ( ) = = 0 ) <nl> + return 0 ; <nl> + <nl> size_t flattenedIdx = shape [ 0 ] ; <nl> for ( int i = 0 ; i < strides . size ( ) ; + + i ) <nl> flattenedIdx + = shape [ i + 1 ] * strides [ i ] ; <nl> mmm a / Tests / UnitTests / V2LibraryTests / FunctionTests . cpp <nl> ppp b / Tests / UnitTests / V2LibraryTests / FunctionTests . cpp <nl> <nl> <nl> using namespace CNTK ; <nl> <nl> - void TestReduceSum ( const DeviceDescriptor & device ) <nl> + void TestReduceSum ( size_t sampleRank , const DeviceDescriptor & device ) <nl> { <nl> size_t numSequences = 7 ; <nl> size_t maxAllowedSequenceLength = 11 ; <nl> - size_t dim = 23 ; <nl> + size_t maxDimSize = 23 ; <nl> + NDShape inputShape ( sampleRank ) ; <nl> + for ( size_t i = 0 ; i < sampleRank ; + + i ) <nl> + inputShape [ i ] = ( rand ( ) % maxDimSize ) + 1 ; <nl> <nl> auto sequenceLengths = GenerateSequenceLengths ( numSequences , maxAllowedSequenceLength ) ; <nl> - auto sequences = GenerateSequences < float > ( sequenceLengths , { dim } ) ; <nl> - ValuePtr sequencesValue = Value : : Create ( { dim } , sequences , device , true ) ; <nl> + auto sequences = GenerateSequences < float > ( sequenceLengths , inputShape ) ; <nl> + ValuePtr sequencesValue = Value : : Create ( inputShape , sequences , device , true ) ; <nl> <nl> / / Test ReduceSum along a static axis <nl> { <nl> - auto testReduceSum = [ & sequences , & sequenceLengths , dim , sequencesValue , device ] ( bool reduceAll ) <nl> + auto testReduceSum = [ & sequences , & sequenceLengths , inputShape , sequencesValue , device ] ( int reductionAxis ) <nl> { <nl> - size_t maxActualSequenceLength = sequencesValue - > Shape ( ) [ 1 ] ; <nl> - size_t numSequences = sequencesValue - > Shape ( ) [ 2 ] ; <nl> + size_t maxActualSequenceLength = sequencesValue - > Shape ( ) [ inputShape . Rank ( ) ] ; <nl> + size_t numSequences = sequencesValue - > Shape ( ) [ inputShape . Rank ( ) + 1 ] ; <nl> <nl> - auto inputVar = InputVariable ( { dim } , DataType : : Float , L " input " ) ; <nl> + auto inputVar = InputVariable ( inputShape , DataType : : Float , L " input " ) ; <nl> FunctionPtr reduceSumFunc ; <nl> <nl> + bool reduceAll = ( reductionAxis < 0 ) ; <nl> if ( reduceAll ) <nl> reduceSumFunc = ReduceSum ( inputVar ) ; <nl> else <nl> - reduceSumFunc = ReduceSum ( inputVar , Axis ( 0 ) ) ; <nl> + reduceSumFunc = ReduceSum ( inputVar , Axis ( reductionAxis ) ) ; <nl> <nl> - NDShape outputShape ; <nl> - if ( reduceAll ) <nl> - outputShape = { } ; <nl> - else <nl> - outputShape = reduceSumFunc - > Output ( ) . Shape ( ) . AppendShape ( { maxActualSequenceLength , numSequences } ) ; <nl> + NDShape outputShape = reduceSumFunc - > Output ( ) . Shape ( ) ; <nl> + NDShape outputDataShape = outputShape ; <nl> + if ( ! reduceAll ) <nl> + outputDataShape = outputDataShape . AppendShape ( { maxActualSequenceLength , numSequences } ) ; <nl> <nl> - std : : vector < float > outputData ( outputShape . TotalSize ( ) ) ; <nl> - ValuePtr outputValue = MakeSharedObject < Value > ( MakeSharedObject < NDArrayView > ( outputShape , outputData , false ) , reduceAll ? nullptr : sequencesValue - > Mask ( ) - > DeepClone ( ) ) ; <nl> + std : : vector < float > outputData ( outputDataShape . TotalSize ( ) ) ; <nl> + ValuePtr outputValue = MakeSharedObject < Value > ( MakeSharedObject < NDArrayView > ( outputDataShape , outputData , false ) , reduceAll ? nullptr : sequencesValue - > Mask ( ) - > DeepClone ( ) ) ; <nl> <nl> std : : unordered_map < Variable , ValuePtr > outputs = { { reduceSumFunc - > Output ( ) , outputValue } } ; <nl> reduceSumFunc - > Forward ( { { inputVar , sequencesValue } } , outputs , device ) ; <nl> <nl> - std : : vector < float > expectedPerFrameTotals ( maxActualSequenceLength * numSequences , 0 . 0f ) ; <nl> + std : : vector < size_t > inputShapeStrides = GetStrides ( inputShape ) ; <nl> + std : : vector < size_t > outputShapeStrides = GetStrides ( outputShape ) ; <nl> + <nl> + std : : vector < float > expectedPerFrameTotals ( outputShape . TotalSize ( ) * maxActualSequenceLength * numSequences , 0 . 0f ) ; <nl> float expectedTotal = 0 . 0f ; <nl> for ( size_t i = 0 ; i < numSequences ; + + i ) <nl> { <nl> size_t currentSequenceLength = sequenceLengths [ i ] ; <nl> for ( size_t j = 0 ; j < currentSequenceLength ; + + j ) <nl> { <nl> - for ( size_t k = 0 ; k < dim ; + + k ) <nl> + for ( size_t k = 0 ; k < inputShape . TotalSize ( ) ; + + k ) <nl> { <nl> - float value = sequences [ i ] [ ( j * dim ) + k ] ; <nl> - expectedPerFrameTotals [ ( i * maxActualSequenceLength ) + j ] + = value ; <nl> + auto inputIdx = UnflattenedShape ( k , inputShapeStrides ) ; <nl> + auto outputIdx = inputIdx ; <nl> + if ( ! reduceAll ) <nl> + outputIdx [ reductionAxis ] = 0 ; <nl> + else <nl> + outputIdx = { } ; <nl> + <nl> + auto flatOutputIdx = FlattenedIndex ( outputIdx , outputShapeStrides ) ; <nl> + float value = sequences [ i ] [ ( j * inputShape . TotalSize ( ) ) + k ] ; <nl> + expectedPerFrameTotals [ ( ( ( i * maxActualSequenceLength ) + j ) * outputShape . TotalSize ( ) ) + flatOutputIdx ] + = value ; <nl> expectedTotal + = value ; <nl> } <nl> } <nl> void TestReduceSum ( const DeviceDescriptor & device ) <nl> FloatingPointVectorCompare ( outputData , expectedPerFrameTotals , " testReduceSum : Forward prop results do not match expected results " ) ; <nl> } ; <nl> <nl> - testReduceSum ( true ) ; <nl> - testReduceSum ( false ) ; <nl> + / / Reduce over all axes <nl> + testReduceSum ( - 1 ) ; <nl> + <nl> + int reductionAxis = 0 ; <nl> + testReduceSum ( reductionAxis ) ; <nl> + <nl> + if ( reductionAxis < ( inputShape . Rank ( ) - 1 ) ) <nl> + reductionAxis + + ; <nl> + <nl> + testReduceSum ( reductionAxis ) ; <nl> + <nl> + if ( reductionAxis < ( inputShape . Rank ( ) - 1 ) ) <nl> + reductionAxis + + ; <nl> + <nl> + testReduceSum ( reductionAxis ) ; <nl> } <nl> <nl> / / Test ReduceSum along a dynamic axis <nl> { <nl> - auto testReduceSum = [ & sequences , & sequenceLengths , dim , sequencesValue , device ] ( const Axis & axis ) <nl> + auto testReduceSum = [ & sequences , & sequenceLengths , inputShape , sequencesValue , device ] ( const Axis & axis ) <nl> { <nl> if ( axis . IsStaticAxis ( ) ) <nl> RuntimeError ( " Called the dynamic axis ReduceSum test with a static axis " ) ; <nl> <nl> - size_t maxActualSequenceLength = sequencesValue - > Shape ( ) [ 1 ] ; <nl> - size_t numSequences = sequencesValue - > Shape ( ) [ 2 ] ; <nl> + size_t maxActualSequenceLength = sequencesValue - > Shape ( ) [ inputShape . Rank ( ) ] ; <nl> + size_t numSequences = sequencesValue - > Shape ( ) [ inputShape . Rank ( ) + 1 ] ; <nl> <nl> - auto inputVar = InputVariable ( { dim } , DataType : : Float , L " input " ) ; <nl> + auto inputVar = InputVariable ( { inputShape } , DataType : : Float , L " input " ) ; <nl> FunctionPtr reduceSumFunc = ReduceSum ( inputVar , axis ) ; <nl> <nl> NDShape maskShape = { ( ( axis = = Axis : : DefaultBatchAxis ( ) ) ? maxActualSequenceLength : 1 ) , ( ( axis = = Axis : : DefaultBatchAxis ( ) ) ? 1 : numSequences ) } ; <nl> - NDShape outputShape = reduceSumFunc - > Output ( ) . Shape ( ) . AppendShape ( maskShape ) ; <nl> + NDShape outputShape = reduceSumFunc - > Output ( ) . Shape ( ) ; <nl> + auto outputDataShape = outputShape . AppendShape ( maskShape ) ; <nl> <nl> - std : : vector < float > outputData ( outputShape . TotalSize ( ) ) ; <nl> + std : : vector < float > outputData ( outputDataShape . TotalSize ( ) ) ; <nl> auto maskPtr = MakeSharedObject < NDMask > ( maskShape , device ) ; <nl> - ValuePtr outputValue = MakeSharedObject < Value > ( MakeSharedObject < NDArrayView > ( outputShape , outputData , false ) , maskPtr ) ; <nl> + ValuePtr outputValue = MakeSharedObject < Value > ( MakeSharedObject < NDArrayView > ( outputDataShape , outputData , false ) , maskPtr ) ; <nl> <nl> std : : unordered_map < Variable , ValuePtr > outputs = { { reduceSumFunc - > Output ( ) , outputValue } } ; <nl> reduceSumFunc - > Forward ( { { inputVar , sequencesValue } } , outputs , device ) ; <nl> <nl> - std : : vector < float > expectedTotals ( outputShape . TotalSize ( ) , 0 . 0f ) ; <nl> + std : : vector < float > expectedTotals ( outputDataShape . TotalSize ( ) , 0 . 0f ) ; <nl> for ( size_t i = 0 ; i < numSequences ; + + i ) <nl> { <nl> size_t currentSequenceLength = sequenceLengths [ i ] ; <nl> for ( size_t j = 0 ; j < currentSequenceLength ; + + j ) <nl> { <nl> - for ( size_t k = 0 ; k < dim ; + + k ) <nl> + for ( size_t k = 0 ; k < inputShape . TotalSize ( ) ; + + k ) <nl> { <nl> - float value = sequences [ i ] [ ( j * dim ) + k ] ; <nl> + float value = sequences [ i ] [ ( j * inputShape . TotalSize ( ) ) + k ] ; <nl> if ( axis = = Axis : : DefaultBatchAxis ( ) ) <nl> - expectedTotals [ ( j * dim ) + k ] + = value ; <nl> + expectedTotals [ ( j * inputShape . TotalSize ( ) ) + k ] + = value ; <nl> else <nl> - expectedTotals [ ( i * dim ) + k ] + = value ; ; <nl> + expectedTotals [ ( i * inputShape . TotalSize ( ) ) + k ] + = value ; <nl> } <nl> } <nl> } <nl> void FunctionTests ( ) <nl> TestSlice ( 1 , DeviceDescriptor : : GPUDevice ( 0 ) ) ; <nl> # endif <nl> <nl> - TestReduceSum ( DeviceDescriptor : : CPUDevice ( ) ) ; <nl> + TestReduceSum ( 1 , DeviceDescriptor : : CPUDevice ( ) ) ; <nl> # ifndef CPUONLY <nl> - TestReduceSum ( DeviceDescriptor : : GPUDevice ( 0 ) ) ; <nl> + TestReduceSum ( 2 , DeviceDescriptor : : GPUDevice ( 0 ) ) ; <nl> # endif <nl> <nl> TestRecurrentFunctionCloning ( ) ; <nl> mmm a / Tests / UnitTests / V2LibraryTests / TruncatedLSTMAcousticModel . cpp <nl> ppp b / Tests / UnitTests / V2LibraryTests / TruncatedLSTMAcousticModel . cpp <nl> void TrainTruncatedLSTMAcousticModelClassifer ( const DeviceDescriptor & device , bo <nl> prediction = predictionVar ; <nl> } <nl> <nl> - const size_t numTrainingSamples = 81920 ; <nl> + const size_t numTrainingSamples = 20480 ; <nl> const size_t truncationLength = 20 ; <nl> Dictionary truncatedModeConfig ; <nl> truncatedModeConfig [ L " truncated " ] = true ; <nl> void TrainTruncatedLSTMAcousticModelClassifer ( const DeviceDescriptor & device , bo <nl> featureStreamInfo = minibatchSource - > StreamInfo ( features ) ; <nl> auto labelStreamInfo = minibatchSource - > StreamInfo ( labels ) ; <nl> <nl> - double learningRatePerSample = 0 . 025 ; <nl> - size_t momentumTimeConstant = 256 ; <nl> - double momentumPerSample = std : : exp ( - 1 . 0 / momentumTimeConstant ) ; <nl> - Trainer trainer ( classifierOutput , trainingLoss , prediction , { MomentumSGDLearner ( classifierOutput - > Parameters ( ) , learningRatePerSample , momentumPerSample ) } ) ; <nl> + double learningRatePerSample = 0 . 000781 ; <nl> + auto learner = MomentumSGDLearner ( classifierOutput - > Parameters ( ) , learningRatePerSample , 0 . 0 ) ; <nl> + Trainer trainer ( classifierOutput , trainingLoss , prediction , { learner } ) ; <nl> <nl> size_t outputFrequencyInMinibatches = 1 ; <nl> for ( size_t i = 0 ; true ; i + + ) <nl>
CNTK v2 library : Fixed a bug in > 1D reductions and minor bugs in applying the name attribute to primitive functions in the Function graph APIs
microsoft/CNTK
0dc5f9c9af275c8bec6d76efc1d24606004e3d49
2016-09-28T05:25:31Z
mmm a / CHANGELOG . txt <nl> ppp b / CHANGELOG . txt <nl> Other Changes : <nl> - Drag and Drop : Added ImGuiDragDropFlags_SourceAutoExpirePayload flag to force payload to expire if the source stops being submitted . ( # 1725 , # 143 ) . <nl> - IsItemHovered ( ) : Added ImGuiHoveredFlags_AllowWhenDisabled flag to query hovered status on disabled items . ( # 1940 , # 211 ) <nl> - Selectable : Added ImGuiSelectableFlags_Disabled flag in the public API . ( # 211 ) <nl> + - Misc ; Added optional misc / stl / imgui_stl . h wrapper to use with STL types ( e . g . InputText with std : : string ) . ( # 2006 , # 1443 , # 1008 ) <nl> - Misc : Added IMGUI_VERSION_NUM for easy compile - time testing . ( # 2025 ) <nl> - Misc : Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor . ( # 1913 , 1914 ) [ @ aiekick , @ ocornut ] <nl> - Misc : Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors . <nl> mmm a / imgui . cpp <nl> ppp b / imgui . cpp <nl> static bool InputTextFilterCharacter ( unsigned int * p_char , ImGuiInputTextFlags f <nl> / / This is so we can easily call InputText ( ) on static arrays using ARRAYSIZE ( ) and to match <nl> / / Note that in std : : string world , capacity ( ) would omit 1 byte used by the zero - terminator . <nl> / / - When active , hold on a privately held copy of the text ( and apply back to ' buf ' ) . So changing ' buf ' while the InputText is active has no effect . <nl> - / / FIXME : Rather messy function partly because we are doing UTF8 > u16 > UTF8 conversions on the go to more easily handle stb_textedit calls . Ideally we should stay in UTF - 8 all the time . See https : / / github . com / nothings / stb / issues / 188 <nl> + / / - If you want to use ImGui : : InputText ( ) with std : : string , see misc / stl / imgui_stl . h <nl> + / / ( FIXME : Rather messy function partly because we are doing UTF8 > u16 > UTF8 conversions on the go to more easily handle stb_textedit calls . Ideally we should stay in UTF - 8 all the time . See https : / / github . com / nothings / stb / issues / 188 ) <nl> bool ImGui : : InputTextEx ( const char * label , char * buf , int buf_size , const ImVec2 & size_arg , ImGuiInputTextFlags flags , ImGuiInputTextCallback callback , void * callback_user_data ) <nl> { <nl> ImGuiWindow * window = GetCurrentWindow ( ) ; <nl> mmm a / imgui . h <nl> ppp b / imgui . h <nl> namespace ImGui <nl> IMGUI_API bool DragScalarN ( const char * label , ImGuiDataType data_type , void * v , int components , float v_speed , const void * v_min = NULL , const void * v_max = NULL , const char * format = NULL , float power = 1 . 0f ) ; <nl> <nl> / / Widgets : Input with Keyboard <nl> + / / If you want to use InputText ( ) with a dynamic string type such as std : : string or your own , see misc / stl / imgui_stl . h <nl> IMGUI_API bool InputText ( const char * label , char * buf , size_t buf_size , ImGuiInputTextFlags flags = 0 , ImGuiInputTextCallback callback = NULL , void * user_data = NULL ) ; <nl> IMGUI_API bool InputTextMultiline ( const char * label , char * buf , size_t buf_size , const ImVec2 & size = ImVec2 ( 0 , 0 ) , ImGuiInputTextFlags flags = 0 , ImGuiInputTextCallback callback = NULL , void * user_data = NULL ) ; <nl> IMGUI_API bool InputFloat ( const char * label , float * v , float step = 0 . 0f , float step_fast = 0 . 0f , const char * format = " % . 3f " , ImGuiInputTextFlags extra_flags = 0 ) ; <nl> enum ImGuiInputTextFlags_ <nl> ImGuiInputTextFlags_Password = 1 < < 15 , / / Password mode , display all characters as ' * ' <nl> ImGuiInputTextFlags_NoUndoRedo = 1 < < 16 , / / Disable undo / redo . Note that input text owns the text data while active , if you want to provide your own undo / redo stack you need e . g . to call ClearActiveID ( ) . <nl> ImGuiInputTextFlags_CharsScientific = 1 < < 17 , / / Allow 0123456789 . + - * / eE ( Scientific notation input ) <nl> - ImGuiInputTextFlags_CallbackResize = 1 < < 18 , / / Allow buffer capacity resize + notify when the string wants to be resized ( for string types which hold a cache of their Size ) <nl> + ImGuiInputTextFlags_CallbackResize = 1 < < 18 , / / Allow buffer capacity resize + notify when the string wants to be resized ( for string types which hold a cache of their Size ) ( see misc / stl / imgui_stl . h for an example of using this ) <nl> / / [ Internal ] <nl> ImGuiInputTextFlags_Multiline = 1 < < 20 / / For internal use by InputTextMultiline ( ) <nl> } ; <nl> mmm a / imgui_demo . cpp <nl> ppp b / imgui_demo . cpp <nl> void ImGui : : ShowDemoWindow ( bool * p_open ) <nl> static char str0 [ 128 ] = " Hello , world ! " ; <nl> static int i0 = 123 ; <nl> ImGui : : InputText ( " input text " , str0 , IM_ARRAYSIZE ( str0 ) ) ; <nl> - ImGui : : SameLine ( ) ; ShowHelpMarker ( " Hold SHIFT or use mouse to select text . \ n " " CTRL + Left / Right to word jump . \ n " " CTRL + A or double - click to select all . \ n " " CTRL + X , CTRL + C , CTRL + V clipboard . \ n " " CTRL + Z , CTRL + Y undo / redo . \ n " " ESCAPE to revert . \ n " ) ; <nl> + ImGui : : SameLine ( ) ; ShowHelpMarker ( " USER : \ nHold SHIFT or use mouse to select text . \ n " " CTRL + Left / Right to word jump . \ n " " CTRL + A or double - click to select all . \ n " " CTRL + X , CTRL + C , CTRL + V clipboard . \ n " " CTRL + Z , CTRL + Y undo / redo . \ n " " ESCAPE to revert . \ n \ nPROGRAMMER : \ nYou can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText ( ) to a dynamic string type . See misc / stl / imgui_stl . h for an example ( this is not demonstrated in imgui_demo . cpp ) . " ) ; <nl> <nl> ImGui : : InputInt ( " input int " , & i0 ) ; <nl> ImGui : : SameLine ( ) ; ShowHelpMarker ( " You can apply arithmetic operators + , * , / on numerical values . \ n e . g . [ 100 ] , input \ ' * 2 \ ' , result becomes [ 200 ] \ nUse + - to subtract . \ n " ) ; <nl> void ImGui : : ShowDemoWindow ( bool * p_open ) <nl> " label : \ n " <nl> " \ tlock cmpxchg8b eax \ n " ; <nl> <nl> - ImGui : : PushStyleVar ( ImGuiStyleVar_FramePadding , ImVec2 ( 0 , 0 ) ) ; <nl> + ShowHelpMarker ( " You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline ( ) to a dynamic string type . See misc / stl / imgui_stl . h for an example . ( This is not demonstrated in imgui_demo . cpp ) " ) ; <nl> ImGui : : Checkbox ( " Read - only " , & read_only ) ; <nl> - ImGui : : PopStyleVar ( ) ; <nl> - ImGui : : InputTextMultiline ( " # # source " , text , IM_ARRAYSIZE ( text ) , ImVec2 ( - 1 . 0f , ImGui : : GetTextLineHeight ( ) * 16 ) , ImGuiInputTextFlags_AllowTabInput | ( read_only ? ImGuiInputTextFlags_ReadOnly : 0 ) ) ; <nl> + ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput | ( read_only ? ImGuiInputTextFlags_ReadOnly : 0 ) ; <nl> + ImGui : : InputTextMultiline ( " # # source " , text , IM_ARRAYSIZE ( text ) , ImVec2 ( - 1 . 0f , ImGui : : GetTextLineHeight ( ) * 16 ) , flags ) ; <nl> ImGui : : TreePop ( ) ; <nl> } <nl> <nl> new file mode 100644 <nl> index 0000000000 . . c504e98ae4 <nl> mmm / dev / null <nl> ppp b / misc / stl / imgui_stl . cpp <nl> <nl> + / / imgui_stl . cpp <nl> + / / Wrappers for STL types ( std : : string , etc . ) <nl> + / / This is also an example of how you may wrap your own similar types . <nl> + <nl> + # include " imgui . h " <nl> + # include " imgui_stl . h " <nl> + <nl> + struct InputTextCallback_UserData <nl> + { <nl> + std : : string * Str ; <nl> + ImGuiInputTextCallback ChainCallback ; <nl> + void * ChainCallbackUserData ; <nl> + } ; <nl> + <nl> + static int InputTextCallback ( ImGuiInputTextCallbackData * data ) <nl> + { <nl> + InputTextCallback_UserData * user_data = ( InputTextCallback_UserData * ) data - > UserData ; <nl> + if ( data - > EventFlag = = ImGuiInputTextFlags_CallbackResize ) <nl> + { <nl> + / / Resize string callback <nl> + std : : string * str = user_data - > Str ; <nl> + IM_ASSERT ( data - > Buf = = str - > c_str ( ) ) ; <nl> + str - > resize ( data - > BufTextLen ) ; <nl> + data - > Buf = ( char * ) str - > c_str ( ) ; <nl> + } <nl> + else if ( user_data - > ChainCallback ) <nl> + { <nl> + / / Forward to user callback , if any <nl> + data - > UserData = user_data - > ChainCallbackUserData ; <nl> + return user_data - > ChainCallback ( data ) ; <nl> + } <nl> + return 0 ; <nl> + } <nl> + <nl> + bool ImGui : : InputText ( const char * label , std : : string * str , ImGuiInputTextFlags flags , ImGuiInputTextCallback callback , void * user_data ) <nl> + { <nl> + flags | = ImGuiInputTextFlags_CallbackResize ; <nl> + <nl> + InputTextCallback_UserData cb_user_data ; <nl> + cb_user_data . Str = str ; <nl> + cb_user_data . ChainCallback = callback ; <nl> + cb_user_data . ChainCallbackUserData = user_data ; <nl> + return InputText ( label , ( char * ) str - > c_str ( ) , str - > capacity ( ) + 1 , flags , InputTextCallback , & cb_user_data ) ; <nl> + } <nl> + <nl> + bool ImGui : : InputTextMultiline ( const char * label , std : : string * str , const ImVec2 & size , ImGuiInputTextFlags flags , ImGuiInputTextCallback callback , void * user_data ) <nl> + { <nl> + flags | = ImGuiInputTextFlags_CallbackResize ; <nl> + <nl> + InputTextCallback_UserData cb_user_data ; <nl> + cb_user_data . Str = str ; <nl> + cb_user_data . ChainCallback = callback ; <nl> + cb_user_data . ChainCallbackUserData = user_data ; <nl> + return InputTextMultiline ( label , ( char * ) str - > c_str ( ) , str - > capacity ( ) + 1 , size , flags , InputTextCallback , & cb_user_data ) ; <nl> + } <nl> new file mode 100644 <nl> index 0000000000 . . 1d7747c7aa <nl> mmm / dev / null <nl> ppp b / misc / stl / imgui_stl . h <nl> <nl> + / / imgui_stl . h <nl> + / / Wrappers for STL types ( std : : string , etc . ) <nl> + / / This is also an example of how you may wrap your own similar types . <nl> + <nl> + / / Changelog : <nl> + / / - v0 . 10 : Initial version . Added InputText ( ) / InputTextMultiline ( ) calls with std : : string <nl> + <nl> + # pragma once <nl> + <nl> + # include < string > <nl> + <nl> + namespace ImGui <nl> + { <nl> + / / ImGui : : InputText ( ) with std : : string <nl> + / / Because text input needs dynamic resizing , we need to setup a callback to grow the capacity <nl> + IMGUI_API bool InputText ( const char * label , std : : string * str , ImGuiInputTextFlags flags = 0 , ImGuiInputTextCallback callback = NULL , void * user_data = NULL ) ; <nl> + IMGUI_API bool InputTextMultiline ( const char * label , std : : string * str , const ImVec2 & size = ImVec2 ( 0 , 0 ) , ImGuiInputTextFlags flags = 0 , ImGuiInputTextCallback callback = NULL , void * user_data = NULL ) ; <nl> + } <nl>
Added optional misc / stl / imgui_stl . h wrapper to use with STL types ( e . g . InputText with std : : string ) . ( , , , )
ocornut/imgui
ea9f5d7600220e10fbd044e914e6b00d7b863234
2018-08-22T11:25:08Z
mmm a / js / apps / system / _admin / aardvark / APP / frontend / js / views / queryView . js <nl> ppp b / js / apps / system / _admin / aardvark / APP / frontend / js / views / queryView . js <nl> <nl> return ; <nl> } <nl> <nl> + this . lastSentQueryString = this . aqlEditor . getValue ( ) ; <nl> + <nl> this . $ ( this . outputDiv ) . prepend ( this . outputTemplate . render ( { <nl> counter : this . outputCounter , <nl> type : ' Explain ' <nl> <nl> $ ( ' # outputEditorWrapper ' + this . outputCounter ) . hide ( ) ; <nl> $ ( ' # outputEditorWrapper ' + this . outputCounter ) . show ( ' fast ' ) ; <nl> <nl> + this . lastSentQueryString = this . aqlEditor . getValue ( ) ; <nl> + <nl> this . renderQueryResultBox ( this . outputCounter , selected ) ; <nl> } , <nl> <nl> <nl> <nl> renderQueryResult : function ( data , counter , cached ) { <nl> var self = this ; <nl> - var outputEditor = ace . edit ( ' outputEditor ' + counter ) ; <nl> <nl> - / / handle explain query case <nl> - if ( ! data . msg ) { <nl> - / / handle usual query <nl> - var result = self . analyseQuery ( data . result ) ; <nl> - / / console . log ( ' Using ' + result . defaultType + ' as data format . ' ) ; <nl> - if ( result . defaultType = = = ' table ' ) { <nl> - $ ( ' # outputEditorWrapper ' + counter + ' . arangoToolbarTop ' ) . after ( <nl> - ' < div id = " outputTable ' + counter + ' " class = " outputTable " > < / div > ' <nl> - ) ; <nl> - $ ( ' # outputTable ' + counter ) . show ( ) ; <nl> - self . renderOutputTable ( result , counter ) ; <nl> + if ( window . location . hash = = = ' # queries ' ) { <nl> + var outputEditor = ace . edit ( ' outputEditor ' + counter ) ; <nl> + <nl> + / / handle explain query case <nl> + if ( ! data . msg ) { <nl> + / / handle usual query <nl> + var result = self . analyseQuery ( data . result ) ; <nl> + / / console . log ( ' Using ' + result . defaultType + ' as data format . ' ) ; <nl> + if ( result . defaultType = = = ' table ' ) { <nl> + $ ( ' # outputEditorWrapper ' + counter + ' . arangoToolbarTop ' ) . after ( <nl> + ' < div id = " outputTable ' + counter + ' " class = " outputTable " > < / div > ' <nl> + ) ; <nl> + $ ( ' # outputTable ' + counter ) . show ( ) ; <nl> + self . renderOutputTable ( result , counter ) ; <nl> <nl> - / / apply max height for table output dynamically <nl> - var maxHeight = $ ( ' . centralRow ' ) . height ( ) - 250 ; <nl> - $ ( ' . outputEditorWrapper . tableWrapper ' ) . css ( ' max - height ' , maxHeight ) ; <nl> + / / apply max height for table output dynamically <nl> + var maxHeight = $ ( ' . centralRow ' ) . height ( ) - 250 ; <nl> + $ ( ' . outputEditorWrapper . tableWrapper ' ) . css ( ' max - height ' , maxHeight ) ; <nl> <nl> - $ ( ' # outputEditor ' + counter ) . hide ( ) ; <nl> - } else if ( result . defaultType = = = ' graph ' ) { <nl> - $ ( ' # outputEditorWrapper ' + counter + ' . arangoToolbarTop ' ) . after ( ' < div id = " outputGraph ' + counter + ' " > < / div > ' ) ; <nl> - $ ( ' # outputGraph ' + counter ) . show ( ) ; <nl> - self . renderOutputGraph ( result , counter ) ; <nl> + $ ( ' # outputEditor ' + counter ) . hide ( ) ; <nl> + } else if ( result . defaultType = = = ' graph ' ) { <nl> + $ ( ' # outputEditorWrapper ' + counter + ' . arangoToolbarTop ' ) . after ( ' < div id = " outputGraph ' + counter + ' " > < / div > ' ) ; <nl> + $ ( ' # outputGraph ' + counter ) . show ( ) ; <nl> + self . renderOutputGraph ( result , counter ) ; <nl> <nl> - $ ( ' # outputEditor ' + counter ) . hide ( ) ; <nl> - } <nl> + $ ( ' # outputEditor ' + counter ) . hide ( ) ; <nl> + } <nl> + <nl> + / / add active class to choosen display method <nl> + $ ( ' # ' + result . defaultType + ' - switch ' ) . addClass ( ' active ' ) . css ( ' display ' , ' inline ' ) ; <nl> <nl> - / / add active class to choosen display method <nl> - $ ( ' # ' + result . defaultType + ' - switch ' ) . addClass ( ' active ' ) . css ( ' display ' , ' inline ' ) ; <nl> + var appendSpan = function ( value , icon , css ) { <nl> + if ( ! css ) { <nl> + css = ' ' ; <nl> + } <nl> + $ ( ' # outputEditorWrapper ' + counter + ' . arangoToolbarTop . pull - left ' ) . append ( <nl> + ' < span class = " ' + css + ' " > < i class = " fa ' + icon + ' " > < / i > < i class = " iconText " > ' + value + ' < / i > < / span > ' <nl> + ) ; <nl> + } ; <nl> <nl> - var appendSpan = function ( value , icon , css ) { <nl> - if ( ! css ) { <nl> - css = ' ' ; <nl> + var time = ' - ' ; <nl> + if ( data & & data . extra & & data . extra . stats ) { <nl> + time = data . extra . stats . executionTime . toFixed ( 3 ) + ' s ' ; <nl> } <nl> - $ ( ' # outputEditorWrapper ' + counter + ' . arangoToolbarTop . pull - left ' ) . append ( <nl> - ' < span class = " ' + css + ' " > < i class = " fa ' + icon + ' " > < / i > < i class = " iconText " > ' + value + ' < / i > < / span > ' <nl> + appendSpan ( <nl> + data . result . length + ' elements ' , ' fa - calculator ' <nl> ) ; <nl> - } ; <nl> - <nl> - var time = ' - ' ; <nl> - if ( data & & data . extra & & data . extra . stats ) { <nl> - time = data . extra . stats . executionTime . toFixed ( 3 ) + ' s ' ; <nl> - } <nl> - appendSpan ( <nl> - data . result . length + ' elements ' , ' fa - calculator ' <nl> - ) ; <nl> - appendSpan ( time , ' fa - clock - o ' ) ; <nl> + appendSpan ( time , ' fa - clock - o ' ) ; <nl> <nl> - if ( data . extra ) { <nl> - if ( data . extra . profile ) { <nl> - appendSpan ( ' ' , ' fa - caret - down ' ) ; <nl> - self . appendProfileDetails ( counter , data . extra . profile ) ; <nl> - } <nl> + if ( data . extra ) { <nl> + if ( data . extra . profile ) { <nl> + appendSpan ( ' ' , ' fa - caret - down ' ) ; <nl> + self . appendProfileDetails ( counter , data . extra . profile ) ; <nl> + } <nl> <nl> - if ( data . extra . stats ) { <nl> - if ( data . extra . stats . writesExecuted > 0 | | data . extra . stats . writesIgnored > 0 ) { <nl> - appendSpan ( <nl> - data . extra . stats . writesExecuted + ' writes ' , ' fa - check - circle positive ' <nl> - ) ; <nl> - if ( data . extra . stats . writesIgnored = = = 0 ) { <nl> + if ( data . extra . stats ) { <nl> + if ( data . extra . stats . writesExecuted > 0 | | data . extra . stats . writesIgnored > 0 ) { <nl> appendSpan ( <nl> - data . extra . stats . writesIgnored + ' writes ignored ' , ' fa - check - circle positive ' , ' additional ' <nl> - ) ; <nl> - } else { <nl> - appendSpan ( <nl> - data . extra . stats . writesIgnored + ' writes ignored ' , ' fa - exclamation - circle warning ' , ' additional ' <nl> + data . extra . stats . writesExecuted + ' writes ' , ' fa - check - circle positive ' <nl> ) ; <nl> + if ( data . extra . stats . writesIgnored = = = 0 ) { <nl> + appendSpan ( <nl> + data . extra . stats . writesIgnored + ' writes ignored ' , ' fa - check - circle positive ' , ' additional ' <nl> + ) ; <nl> + } else { <nl> + appendSpan ( <nl> + data . extra . stats . writesIgnored + ' writes ignored ' , ' fa - exclamation - circle warning ' , ' additional ' <nl> + ) ; <nl> + } <nl> } <nl> } <nl> } <nl> } <nl> - } <nl> <nl> - $ ( ' # outputEditorWrapper ' + counter + ' . pull - left # spinner ' ) . remove ( ) ; <nl> - $ ( ' # outputEditorWrapper ' + counter + ' # cancelCurrentQuery ' ) . remove ( ) ; <nl> + $ ( ' # outputEditorWrapper ' + counter + ' . pull - left # spinner ' ) . remove ( ) ; <nl> + $ ( ' # outputEditorWrapper ' + counter + ' # cancelCurrentQuery ' ) . remove ( ) ; <nl> <nl> - self . warningsFunc ( data , outputEditor ) ; <nl> - window . progressView . hide ( ) ; <nl> + self . warningsFunc ( data , outputEditor ) ; <nl> + window . progressView . hide ( ) ; <nl> <nl> - $ ( ' # outputEditorWrapper ' + counter + ' . switchAce ' ) . show ( ) ; <nl> - $ ( ' # outputEditorWrapper ' + counter + ' . fa - close ' ) . show ( ) ; <nl> - $ ( ' # outputEditor ' + counter ) . css ( ' opacity ' , ' 1 ' ) ; <nl> + $ ( ' # outputEditorWrapper ' + counter + ' . switchAce ' ) . show ( ) ; <nl> + $ ( ' # outputEditorWrapper ' + counter + ' . fa - close ' ) . show ( ) ; <nl> + $ ( ' # outputEditor ' + counter ) . css ( ' opacity ' , ' 1 ' ) ; <nl> <nl> - if ( ! data . msg ) { <nl> - $ ( ' # outputEditorWrapper ' + counter + ' # downloadQueryResult ' ) . show ( ) ; <nl> - $ ( ' # outputEditorWrapper ' + counter + ' # copy2aqlEditor ' ) . show ( ) ; <nl> - } <nl> + if ( ! data . msg ) { <nl> + $ ( ' # outputEditorWrapper ' + counter + ' # downloadQueryResult ' ) . show ( ) ; <nl> + $ ( ' # outputEditorWrapper ' + counter + ' # copy2aqlEditor ' ) . show ( ) ; <nl> + } <nl> <nl> - self . setEditorAutoHeight ( outputEditor ) ; <nl> - self . deselect ( outputEditor ) ; <nl> + self . setEditorAutoHeight ( outputEditor ) ; <nl> + self . deselect ( outputEditor ) ; <nl> <nl> - / / when finished send a delete req to api ( free db space ) <nl> - if ( data . id ) { <nl> - $ . ajax ( { <nl> - url : arangoHelper . databaseUrl ( ' / _api / cursor / ' + encodeURIComponent ( data . id ) ) , <nl> - type : ' DELETE ' <nl> - } ) ; <nl> - } <nl> + / / when finished send a delete req to api ( free db space ) <nl> + if ( data . id ) { <nl> + $ . ajax ( { <nl> + url : arangoHelper . databaseUrl ( ' / _api / cursor / ' + encodeURIComponent ( data . id ) ) , <nl> + type : ' DELETE ' <nl> + } ) ; <nl> + } <nl> <nl> - if ( ! cached ) { <nl> - / / cache the query <nl> - self . cachedQueries [ counter ] = data ; <nl> + if ( ! cached ) { <nl> + / / cache the query <nl> + self . cachedQueries [ counter ] = data ; <nl> <nl> - / / cache the original sent aql string <nl> - this . cachedQueries [ counter ] . sentQuery = self . aqlEditor . getValue ( ) ; <nl> - } <nl> + / / cache the original sent aql string <nl> + this . cachedQueries [ counter ] . sentQuery = self . aqlEditor . getValue ( ) ; <nl> + } <nl> + <nl> + if ( data . msg ) { <nl> + $ ( ' # outputEditorWrapper ' + counter + ' . toolbarType ' ) . html ( ' Explain ' ) ; <nl> + outputEditor . setValue ( data . msg , 1 ) ; <nl> + } <nl> + } else { <nl> + / / if result comes in when view is not active <nl> + / / store the data into cachedQueries obj <nl> + self . cachedQueries [ counter ] = data ; <nl> + self . cachedQueries [ counter ] . sentQuery = self . lastSentQueryString ; <nl> <nl> - if ( data . msg ) { <nl> - $ ( ' # outputEditorWrapper ' + counter + ' . toolbarType ' ) . html ( ' Explain ' ) ; <nl> - outputEditor . setValue ( data . msg , 1 ) ; <nl> + arangoHelper . arangoNotification ( ' Query finished ' , ' Return to queries view to see the result . ' ) ; <nl> } <nl> } , <nl> <nl>
aql editor now handles queries running in the background
arangodb/arangodb
226875acaf31819217e3390a4b616ee952d83c7d
2016-09-29T13:51:56Z
mmm a / stdlib / public / runtime / Casting . cpp <nl> ppp b / stdlib / public / runtime / Casting . cpp <nl> static bool _dynamicCastToExistentialMetatype ( OpaqueValue * dest , <nl> case MetadataKind : : Opaque : <nl> case MetadataKind : : Struct : <nl> case MetadataKind : : Tuple : <nl> - if ( flags & DynamicCastFlags : : Unconditional ) { <nl> - swift_dynamicCastFailure ( srcType , targetType ) ; <nl> - } <nl> - return false ; <nl> + return _fail ( src , srcType , targetType , flags ) ; <nl> } <nl> _failCorruptType ( srcType ) ; <nl> } <nl> new file mode 100644 <nl> index 000000000000 . . ea3fd201668b <nl> mmm / dev / null <nl> ppp b / test / 1_stdlib / Casts . swift <nl> <nl> + / / Casts . swift - Tests for conversion between types . <nl> + / / <nl> + / / This source file is part of the Swift . org open source project <nl> + / / <nl> + / / Copyright ( c ) 2014 - 2015 Apple Inc . and the Swift project authors <nl> + / / Licensed under Apache License v2 . 0 with Runtime Library Exception <nl> + / / <nl> + / / See http : / / swift . org / LICENSE . txt for license information <nl> + / / See http : / / swift . org / CONTRIBUTORS . txt for the list of Swift project authors <nl> + / / <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / / <nl> + / / / Contains tests for conversions between types which shouldn ' t trap . <nl> + / / / <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - <nl> + / / RUN : % target - run - stdlib - swift <nl> + / / REQUIRES : executable_test <nl> + <nl> + import StdlibUnittest <nl> + <nl> + let CastsTests = TestSuite ( " Casts " ) <nl> + <nl> + / / Test for SR - 426 : missing release for some types after failed conversion <nl> + class DeinitTester { <nl> + private let onDeinit : ( ) - > ( ) <nl> + <nl> + init ( onDeinit : ( ) - > ( ) ) { <nl> + self . onDeinit = onDeinit <nl> + } <nl> + deinit { <nl> + onDeinit ( ) <nl> + } <nl> + } <nl> + <nl> + func testFailedTupleCast ( onDeinit : ( ) - > ( ) ) { <nl> + / / This function is to establish a scope for t to <nl> + / / be deallocated at the end of . <nl> + let t : Any = ( 1 , DeinitTester ( onDeinit : onDeinit ) ) <nl> + _ = t is Any . Type <nl> + } <nl> + <nl> + CastsTests . test ( " No leak for failed tuple casts " ) { <nl> + var deinitRan = false <nl> + testFailedTupleCast { <nl> + deinitRan = true <nl> + } <nl> + expectTrue ( deinitRan ) <nl> + } <nl> + <nl> + runAllTests ( ) <nl> \ No newline at end of file <nl>
Merge pull request from jder / fix - existential - cast - leak
apple/swift
f91dd6fa609bfd6e3bec877d0499012318b008b1
2016-01-08T09:44:35Z
mmm a / stdlib / public / core / FloatingPointTypes . swift . gyb <nl> ppp b / stdlib / public / core / FloatingPointTypes . swift . gyb <nl> extension $ { Self } : _ExpressibleByBuiltinIntegerLiteral , ExpressibleByIntegerLit <nl> } <nl> } <nl> <nl> + % if bits ! = 80 : <nl> # if ! os ( Windows ) & & ( arch ( i386 ) | | arch ( x86_64 ) ) <nl> + % end <nl> <nl> % builtinFloatLiteralBits = 80 <nl> extension $ { Self } : _ExpressibleByBuiltinFloatLiteral { <nl> extension $ { Self } : _ExpressibleByBuiltinFloatLiteral { <nl> } <nl> } <nl> <nl> + % if bits ! = 80 : <nl> # else <nl> <nl> % builtinFloatLiteralBits = 64 <nl> extension $ { Self } : _ExpressibleByBuiltinFloatLiteral { <nl> } <nl> <nl> # endif <nl> + % end <nl> <nl> extension $ { Self } : Hashable { <nl> / / / The number ' s hash value . <nl> extension $ { Self } { <nl> % srcBits = src_type . bits <nl> % That = src_type . stdlib_name <nl> <nl> - % if srcBits = = 80 : <nl> + % if ( srcBits = = 80 ) and ( bits ! = 80 ) : <nl> # if ! os ( Windows ) & & ( arch ( i386 ) | | arch ( x86_64 ) ) <nl> % end <nl> <nl> extension $ { Self } { <nl> } <nl> } <nl> <nl> - % if srcBits = = 80 : <nl> + % if ( srcBits = = 80 ) and ( bits ! = 80 ) : <nl> # endif <nl> % end <nl> % end <nl> extension $ { Self } { <nl> } <nl> <nl> % if bits = = 80 : <nl> + # else <nl> + <nl> + $ { SelfDocComment } <nl> + @ _fixed_layout <nl> + @ available ( * , unavailable , message : " Float80 is only available on non - Windows x86 targets . " ) <nl> + public struct $ { Self } { <nl> + / / / Creates a value initialized to zero . <nl> + @ _inlineable / / FIXME ( sil - serialize - all ) <nl> + @ _transparent <nl> + public init ( ) { <nl> + fatalError ( " $ { Self } is not available " ) <nl> + } <nl> + } <nl> + <nl> # endif <nl> % end <nl> % end # for bits in all_floating_point_types <nl>
Merge pull request from Dante - Broggi / master
apple/swift
ceba366a0798c9e09de162f3b0fd5d0a561e448d
2018-01-04T19:41:01Z
mmm a / Makefile . include . in <nl> ppp b / Makefile . include . in <nl> GEN_DEPS = \ <nl> <nl> % . o : % . cc <nl> @ rm - f $ @ <nl> - $ ( SILENT_CC ) $ ( CXX ) - MF $ * . d - MD - c $ ( CXXFLAGS ) $ ( DEFINES ) $ ( INCLUDES ) $ < - o $ @ \ <nl> + $ ( SILENT_CPP ) $ ( CXX ) - MF $ * . d - MD - c $ ( CXXFLAGS ) $ ( DEFINES ) $ ( INCLUDES ) $ < - o $ @ \ <nl> & & $ ( GEN_DEPS ) <nl> <nl> % . o : % . c <nl> GEN_DEPS = \ <nl> <nl> % . o : % . C <nl> @ rm - f $ @ <nl> - $ ( SILENT_CC ) $ ( CC ) - MF $ * . d - MD - c $ ( CFLAGS ) $ ( DEFINES ) $ ( INCLUDES ) $ < - o $ @ \ <nl> + $ ( SILENT_CPP ) $ ( CXX ) - MF $ * . d - MD - c $ ( CFLAGS ) $ ( DEFINES ) $ ( INCLUDES ) $ < - o $ @ \ <nl> & & $ ( GEN_DEPS ) <nl> <nl> % . o : % . S <nl>
Use and display the correct compilers
xbmc/xbmc
05e6b240512cb4565edb0f8981bffcd781a54fe9
2011-07-28T06:27:35Z
mmm a / src / mongo / executor / connection_pool_test . cpp <nl> ppp b / src / mongo / executor / connection_pool_test . cpp <nl> class ConnectionPoolTest : public unittest : : Test { <nl> void dropConnectionsTest ( std : : shared_ptr < ConnectionPool > const & pool , Ptr t ) ; <nl> <nl> private : <nl> - std : : shared_ptr < OutOfLineExecutor > _executor = InlineCountingExecutor : : make ( ) ; <nl> + std : : shared_ptr < OutOfLineExecutor > _executor = InlineQueuedCountingExecutor : : make ( ) ; <nl> std : : shared_ptr < ConnectionPool > _pool ; <nl> } ; <nl> <nl> mmm a / src / mongo / util / executor_test_util . h <nl> ppp b / src / mongo / util / executor_test_util . h <nl> namespace mongo { <nl> / * * <nl> * An " OutOfLineExecutor " that actually runs on the same thread of execution <nl> * This executor is not thread - safe , and accessing it by multiple threads is prohibited . <nl> - * Multi - threaded accesses to instances of " InlineCountingExecutor " result in undefined behavior . <nl> + * Multi - threaded accesses to instances of " InlineQueuedCountingExecutor " result in undefined <nl> + * behavior . <nl> * / <nl> - class InlineCountingExecutor : public OutOfLineExecutor { <nl> + class InlineQueuedCountingExecutor : public OutOfLineExecutor { <nl> public : <nl> void schedule ( Task task ) override { <nl> / / Add the task to our queue <nl> class InlineCountingExecutor : public OutOfLineExecutor { <nl> } <nl> <nl> static auto make ( ) { <nl> - return std : : make_shared < InlineCountingExecutor > ( ) ; <nl> + return std : : make_shared < InlineQueuedCountingExecutor > ( ) ; <nl> } <nl> <nl> bool inSchedule ; <nl> class InlineCountingExecutor : public OutOfLineExecutor { <nl> std : : atomic < uint32_t > tasksRun { 0 } ; / / NOLINT <nl> } ; <nl> <nl> + class InlineRecursiveCountingExecutor final : public OutOfLineExecutor { <nl> + public : <nl> + void schedule ( Task task ) noexcept override { <nl> + / / Relaxed to avoid adding synchronization where there otherwise wouldn ' t be . That would <nl> + / / cause a false negative from TSAN . <nl> + tasksRun . fetch_add ( 1 , std : : memory_order_relaxed ) ; <nl> + task ( Status : : OK ( ) ) ; <nl> + } <nl> + <nl> + static auto make ( ) { <nl> + return std : : make_shared < InlineRecursiveCountingExecutor > ( ) ; <nl> + } <nl> + <nl> + std : : atomic < int32_t > tasksRun { 0 } ; / / NOLINT <nl> + } ; <nl> + <nl> class RejectingExecutor final : public OutOfLineExecutor { <nl> public : <nl> void schedule ( Task task ) noexcept override { <nl> mmm a / src / mongo / util / future_test_executor_future . cpp <nl> ppp b / src / mongo / util / future_test_executor_future . cpp <nl> namespace { <nl> TEST ( Executor_Future , Success_getAsync ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> auto pf = makePromiseFuture < void > ( ) ; <nl> ExecutorFuture < void > ( exec ) . thenRunOn ( exec ) . getAsync ( <nl> [ outside = std : : move ( pf . promise ) ] ( Status status ) mutable { <nl> TEST ( Executor_Future , Reject_getAsync ) { <nl> TEST ( Executor_Future , Success_then ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> ASSERT_EQ ( std : : move ( fut ) . thenRunOn ( exec ) . then ( [ ] ( ) { return 3 ; } ) . get ( ) , <nl> 3 ) ; <nl> ASSERT_EQ ( exec - > tasksRun . load ( ) , 1 ) ; <nl> TEST ( Executor_Future , Reject_then ) { <nl> <nl> TEST ( Executor_Future , Fail_then ) { <nl> FUTURE_FAIL_TEST < void > ( [ ] ( / * Future < void > * / auto & & fut ) { <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> ASSERT_EQ ( std : : move ( fut ) <nl> . thenRunOn ( exec ) <nl> . then ( [ ] ( ) { <nl> TEST ( Executor_Future , Fail_then ) { <nl> TEST ( Executor_Future , Success_onError ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { return 3 ; } , <nl> [ ] ( / * Future < int > * / auto & & fut ) { <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> ASSERT_EQ ( std : : move ( fut ) <nl> . thenRunOn ( exec ) <nl> . onError ( [ ] ( Status & & ) { <nl> TEST ( Executor_Future , Success_onError ) { <nl> <nl> TEST ( Executor_Future , Fail_onErrorSimple ) { <nl> FUTURE_FAIL_TEST < int > ( [ ] ( / * Future < int > * / auto & & fut ) { <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> ASSERT_EQ ( std : : move ( fut ) <nl> . thenRunOn ( exec ) <nl> . onError ( [ ] ( Status s ) { <nl> TEST ( Executor_Future , Fail_onErrorSimple ) { <nl> <nl> TEST ( Executor_Future , Fail_onErrorCode_OtherCode ) { <nl> FUTURE_FAIL_TEST < void > ( [ ] ( / * Future < void > * / auto & & fut ) { <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> ASSERT_EQ ( <nl> std : : move ( fut ) <nl> . thenRunOn ( exec ) <nl> TEST ( Executor_Future , Fail_onErrorCode_OtherCode ) { <nl> TEST ( Executor_Future , Success_then_onError_onError_then ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> ASSERT_EQ ( <nl> std : : move ( fut ) <nl> . thenRunOn ( exec ) <nl> TEST ( Executor_Future , Success_reject_recoverToFallback ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> auto rejecter = RejectingExecutor : : make ( ) ; <nl> - auto accepter = InlineCountingExecutor : : make ( ) ; <nl> + auto accepter = InlineQueuedCountingExecutor : : make ( ) ; <nl> <nl> auto res = std : : move ( fut ) <nl> . thenRunOn ( rejecter ) <nl> mmm a / src / mongo / util / future_test_shared_future . cpp <nl> ppp b / src / mongo / util / future_test_shared_future . cpp <nl> TEST ( SharedFuture_Void , isReady_share_TSAN_OK ) { <nl> TEST ( SharedFuture , ModificationsArePrivate ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { return 1 ; } , <nl> [ ] ( / * Future < int > * / auto & & fut ) { <nl> - const auto exec = InlineCountingExecutor : : make ( ) ; <nl> + const auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> const auto shared = std : : move ( fut ) . share ( ) ; <nl> <nl> const auto checkFunc = [ ] ( int & & i ) { <nl> MONGO_COMPILER_NOINLINE void useALotOfStackSpace ( ) { <nl> TEST ( SharedFuture , NoStackOverflow_Call ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> - const auto exec = InlineCountingExecutor : : make ( ) ; <nl> + const auto exec = InlineRecursiveCountingExecutor : : make ( ) ; <nl> const auto shared = std : : move ( fut ) . share ( ) ; <nl> <nl> std : : vector < SemiFuture < void > > collector ; <nl> TEST ( SharedFuture , NoStackOverflow_Call ) { <nl> TEST ( SharedFuture , NoStackOverflow_Destruction ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> - const auto exec = InlineCountingExecutor : : make ( ) ; <nl> + const auto exec = InlineRecursiveCountingExecutor : : make ( ) ; <nl> const auto shared = std : : move ( fut ) . share ( ) ; <nl> <nl> std : : vector < SemiFuture < void > > collector ; <nl> TEST ( SharedFuture , ThenChaining_Sync ) { <nl> FUTURE_SUCCESS_TEST ( <nl> [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> - const auto exec = InlineCountingExecutor : : make ( ) ; <nl> + const auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> <nl> auto res = std : : move ( fut ) . then ( [ ] { return SharedSemiFuture ( 1 ) ; } ) ; <nl> <nl> TEST ( SharedFuture , ThenChaining_Async ) { <nl> FUTURE_SUCCESS_TEST ( <nl> [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> - const auto exec = InlineCountingExecutor : : make ( ) ; <nl> + const auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> <nl> auto res = std : : move ( fut ) . then ( [ ] { return async ( [ ] { return 1 ; } ) . share ( ) ; } ) ; <nl> <nl> TEST ( SharedFuture , ThenChaining_Async ) { <nl> TEST ( SharedFuture , ThenChaining_Async_DoubleShare ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> - const auto exec = InlineCountingExecutor : : make ( ) ; <nl> + const auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> <nl> auto res = std : : move ( fut ) . share ( ) . thenRunOn ( exec ) . then ( <nl> [ ] { return async ( [ ] { return 1 ; } ) . share ( ) ; } ) ; <nl> TEST ( SharedFuture , ThenChaining_Async_DoubleShare ) { <nl> TEST ( SharedFuture , AddChild_ThenRunOn_Get ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> - const auto exec = InlineCountingExecutor : : make ( ) ; <nl> + const auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> auto shared = std : : move ( fut ) . share ( ) ; <nl> auto fut2 = shared . thenRunOn ( exec ) . then ( [ ] { } ) ; <nl> shared . get ( ) ; <nl> TEST ( SharedFuture , AddChild_Split_Get ) { <nl> TEST ( SharedFuture , InterruptedGet_AddChild_Get ) { <nl> FUTURE_SUCCESS_TEST ( [ ] { } , <nl> [ ] ( / * Future < void > * / auto & & fut ) { <nl> - const auto exec = InlineCountingExecutor : : make ( ) ; <nl> + const auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> DummyInterruptable dummyInterruptable ; <nl> <nl> auto shared = std : : move ( fut ) . share ( ) ; <nl> TEST ( SharedFuture , ConcurrentTest_OneSharedFuture ) { <nl> <nl> for ( int i = 0 ; i < nThreads ; i + + ) { <nl> threads [ i ] = stdx : : thread ( [ i , & shared ] { <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> if ( i % 5 = = 0 ) { <nl> / / just wait directly on shared . <nl> shared . get ( ) ; <nl> TEST ( SharedFuture , ConcurrentTest_ManySharedFutures ) { <nl> for ( int i = 0 ; i < nThreads ; i + + ) { <nl> threads [ i ] = stdx : : thread ( [ i , & promise ] { <nl> auto shared = promise . getFuture ( ) ; <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> <nl> if ( i % 5 = = 0 ) { <nl> / / just wait directly on shared . <nl> mmm a / src / mongo / util / future_test_utils . h <nl> ppp b / src / mongo / util / future_test_utils . h <nl> void FUTURE_SUCCESS_TEST ( const CompletionFunc & completion , const TestFunc & test ) <nl> } <nl> <nl> if constexpr ( doExecutorFuture ) { / / immediate executor future <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> test ( Future < CompletionType > : : makeReady ( completion ( ) ) . thenRunOn ( exec ) ) ; <nl> } <nl> } <nl> void FUTURE_SUCCESS_TEST ( const CompletionFunc & completion , const TestFunc & test ) <nl> <nl> if constexpr ( doExecutorFuture ) { / / immediate executor future <nl> completion ( ) ; <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> test ( Future < CompletionType > : : makeReady ( ) . thenRunOn ( exec ) ) ; <nl> } <nl> } <nl> void FUTURE_FAIL_TEST ( const TestFunc & test ) { <nl> } ) ) ; <nl> } <nl> if constexpr ( doExecutorFuture ) { / / immediate executor future <nl> - auto exec = InlineCountingExecutor : : make ( ) ; <nl> + auto exec = InlineQueuedCountingExecutor : : make ( ) ; <nl> test ( Future < CompletionType > : : makeReady ( failStatus ( ) ) . thenRunOn ( exec ) ) ; <nl> } <nl> } <nl> mmm a / src / mongo / util / out_of_line_executor_test . cpp <nl> ppp b / src / mongo / util / out_of_line_executor_test . cpp <nl> TEST ( ExecutorTest , RejectingExecutor ) { <nl> } <nl> } <nl> <nl> - TEST ( ExecutorTest , InlineCountingExecutor ) { <nl> + TEST ( ExecutorTest , InlineQueuedCountingExecutor ) { <nl> / / Verify that the executor accepts every time and keeps an accurate count . <nl> - const auto execA = InlineCountingExecutor : : make ( ) ; <nl> - const auto execB = InlineCountingExecutor : : make ( ) ; <nl> + const auto execA = InlineQueuedCountingExecutor : : make ( ) ; <nl> + const auto execB = InlineQueuedCountingExecutor : : make ( ) ; <nl> + <nl> + / / Using prime numbers so there is no chance of multiple traps <nl> + static constexpr size_t kCountA = 1013 ; <nl> + static constexpr size_t kCountB = 1511 ; <nl> + <nl> + / / Schedule kCountA tasks one at a time . <nl> + for ( size_t i = 0 ; i < kCountA ; + + i ) { <nl> + execA - > schedule ( [ & ] ( Status status ) { <nl> + ASSERT_OK ( status ) ; <nl> + ASSERT_EQ ( execA - > tasksRun . load ( ) , ( i + 1 ) ) ; <nl> + } ) ; <nl> + } <nl> + <nl> + { <nl> + / / Schedule kCountB tasks recursively . <nl> + size_t i = 0 ; <nl> + std : : function < void ( Status ) > recurseExec ; <nl> + bool inTask = false ; <nl> + <nl> + recurseExec = [ & ] ( Status status ) { <nl> + ASSERT ( ! std : : exchange ( inTask , true ) ) ; <nl> + ASSERT_OK ( status ) ; <nl> + <nl> + auto tasksRun = execB - > tasksRun . load ( ) ; <nl> + ASSERT_EQ ( tasksRun , + + i ) ; <nl> + if ( tasksRun < kCountB ) { <nl> + execB - > schedule ( recurseExec ) ; <nl> + } <nl> + <nl> + ASSERT ( std : : exchange ( inTask , false ) ) ; <nl> + } ; <nl> + <nl> + execB - > schedule ( recurseExec ) ; <nl> + } <nl> + <nl> + / / Verify that running executors together didn ' t change the expected counts . <nl> + ASSERT_EQ ( execA - > tasksRun . load ( ) , kCountA ) ; <nl> + ASSERT_EQ ( execB - > tasksRun . load ( ) , kCountB ) ; <nl> + } <nl> + <nl> + TEST ( ExecutorTest , InlineRecursiveCountingExecutor ) { <nl> + / / Verify that the executor accepts every time and keeps an accurate count . <nl> + const auto execA = InlineRecursiveCountingExecutor : : make ( ) ; <nl> + const auto execB = InlineRecursiveCountingExecutor : : make ( ) ; <nl> <nl> / / Using prime numbers so there is no chance of multiple traps <nl> static constexpr size_t kCountA = 1013 ; <nl> DEATH_TEST ( ExecutorTest , <nl> <nl> TEST ( ExecutorTest , GuaranteedExecutor_MainInvalid_FallbackAccepts ) { <nl> / / If we only have a fallback , then everything runs on it . <nl> - const auto countExec = InlineCountingExecutor : : make ( ) ; <nl> + const auto countExec = InlineQueuedCountingExecutor : : make ( ) ; <nl> const auto gwarExec = makeGuaranteedExecutor ( { } , countExec ) ; <nl> <nl> static constexpr size_t kCount = 1000 ; <nl> DEATH_TEST ( ExecutorTest , <nl> TEST ( ExecutorTest , GuaranteedExecutor_MainRejects_FallbackAccepts ) { <nl> / / If the main rejects and the fallback accepts , then run on the fallback . <nl> const auto rejectExec = RejectingExecutor : : make ( ) ; <nl> - const auto countExec = InlineCountingExecutor : : make ( ) ; <nl> + const auto countExec = InlineQueuedCountingExecutor : : make ( ) ; <nl> const auto gwarExec = makeGuaranteedExecutor ( rejectExec , countExec ) ; <nl> <nl> static constexpr size_t kCount = 1000 ; <nl> TEST ( ExecutorTest , GuaranteedExecutor_MainRejects_FallbackAccepts ) { <nl> <nl> TEST ( ExecutorTest , GuaranteedExecutor_MainAccepts_FallbackInvalid ) { <nl> / / If the main accepts and we don ' t have a fallback , then run on the main . <nl> - const auto countExec = InlineCountingExecutor : : make ( ) ; <nl> + const auto countExec = InlineQueuedCountingExecutor : : make ( ) ; <nl> const auto gwarExec = makeGuaranteedExecutor ( countExec , { } ) ; <nl> <nl> static constexpr size_t kCount = 1000 ; <nl> TEST ( ExecutorTest , GuaranteedExecutor_MainAccepts_FallbackInvalid ) { <nl> <nl> TEST ( ExecutorTest , GuaranteedExecutor_MainAccepts_FallbackRejects ) { <nl> / / If the main accepts and the fallback would reject , then run on the main . <nl> - const auto countExec = InlineCountingExecutor : : make ( ) ; <nl> + const auto countExec = InlineQueuedCountingExecutor : : make ( ) ; <nl> const auto rejectExec = RejectingExecutor : : make ( ) ; <nl> const auto gwarExec = makeGuaranteedExecutor ( countExec , rejectExec ) ; <nl> <nl> TEST ( ExecutorTest , GuaranteedExecutor_MainAccepts_FallbackRejects ) { <nl> <nl> TEST ( ExecutorTest , GuaranteedExecutor_MainAccepts_FallbackAccepts ) { <nl> / / If both executor accepts , then run on the main . <nl> - const auto countExecA = InlineCountingExecutor : : make ( ) ; <nl> - const auto countExecB = InlineCountingExecutor : : make ( ) ; <nl> + const auto countExecA = InlineQueuedCountingExecutor : : make ( ) ; <nl> + const auto countExecB = InlineQueuedCountingExecutor : : make ( ) ; <nl> const auto gwarExec = makeGuaranteedExecutor ( countExecA , countExecB ) ; <nl> <nl> static constexpr size_t kCount = 1000 ; <nl>
SERVER - 49371 Revived original recursive ICE and applied to stack overflow tests
mongodb/mongo
77ce2860da66ab9924c0668c76fae564eb7c7dfc
2020-08-07T01:27:25Z
mmm a / include / swift / AST / DiagnosticsSema . def <nl> ppp b / include / swift / AST / DiagnosticsSema . def <nl> ERROR ( throw_in_nonexhaustive_catch , none , <nl> " error is not handled because the enclosing catch is not exhaustive " , ( ) ) <nl> <nl> ERROR ( throwing_call_in_illegal_context , none , <nl> - " call can throw , but errors cannot be thrown out of % 0 " , <nl> - ( StringRef ) ) <nl> + " call can throw , but errors cannot be thrown out of " <nl> + " % select { < < ERROR > > | a default argument | a property initializer | a global variable initializer | an enum case raw value | a catch pattern | a catch guard expression | a defer body } 0 " , <nl> + ( unsigned ) ) <nl> ERROR ( throw_in_illegal_context , none , <nl> - " errors cannot be thrown out of % 0 " , ( StringRef ) ) <nl> + " errors cannot be thrown out of " <nl> + " % select { < < ERROR > > | a default argument | a property initializer | a global variable initializer | an enum case raw value | a catch pattern | a catch guard expression | a defer body } 0 " , <nl> + ( unsigned ) ) <nl> <nl> ERROR ( throwing_operator_without_try , none , <nl> " operator can throw but expression is not marked with ' try ' " , ( ) ) <nl> mmm a / lib / Sema / TypeCheckEffects . cpp <nl> ppp b / lib / Sema / TypeCheckEffects . cpp <nl> class Context { <nl> <nl> static void diagnoseThrowInIllegalContext ( DiagnosticEngine & Diags , <nl> ASTNode node , <nl> - StringRef description ) { <nl> + Kind kind ) { <nl> if ( auto * e = node . dyn_cast < Expr * > ( ) ) { <nl> if ( isa < ApplyExpr > ( e ) ) { <nl> Diags . diagnose ( e - > getLoc ( ) , diag : : throwing_call_in_illegal_context , <nl> - description ) ; <nl> + static_cast < unsigned > ( kind ) ) ; <nl> return ; <nl> } <nl> } <nl> <nl> Diags . diagnose ( node . getStartLoc ( ) , diag : : throw_in_illegal_context , <nl> - description ) ; <nl> + static_cast < unsigned > ( kind ) ) ; <nl> } <nl> <nl> static void maybeAddRethrowsNote ( DiagnosticEngine & Diags , SourceLoc loc , <nl> class Context { <nl> return ; <nl> <nl> case Kind : : EnumElementInitializer : <nl> - diagnoseThrowInIllegalContext ( Diags , E , " an enum case raw value " ) ; <nl> - return ; <nl> - <nl> case Kind : : GlobalVarInitializer : <nl> - diagnoseThrowInIllegalContext ( Diags , E , " a global variable initializer " ) ; <nl> - return ; <nl> - <nl> case Kind : : IVarInitializer : <nl> - diagnoseThrowInIllegalContext ( Diags , E , " a property initializer " ) ; <nl> - return ; <nl> - <nl> case Kind : : DefaultArgument : <nl> - diagnoseThrowInIllegalContext ( Diags , E , " a default argument " ) ; <nl> - return ; <nl> - <nl> case Kind : : CatchPattern : <nl> - diagnoseThrowInIllegalContext ( Diags , E , " a catch pattern " ) ; <nl> - return ; <nl> - <nl> case Kind : : CatchGuard : <nl> - diagnoseThrowInIllegalContext ( Diags , E , " a catch guard expression " ) ; <nl> - return ; <nl> case Kind : : DeferBody : <nl> - diagnoseThrowInIllegalContext ( Diags , E , " a defer body " ) ; <nl> + diagnoseThrowInIllegalContext ( Diags , E , getKind ( ) ) ; <nl> return ; <nl> + <nl> } <nl> llvm_unreachable ( " bad context kind " ) ; <nl> } <nl>
[ Effects handling ] Move " illegal context " strings into diagnostic text .
apple/swift
462e37bbf527d6436f6b44f59862ae178603c618
2020-08-11T05:26:51Z
mmm a / src / main . cpp <nl> ppp b / src / main . cpp <nl> void ThreadScriptCheck ( ) { <nl> <nl> bool ConnectBlock ( CBlock & block , CValidationState & state , CBlockIndex * pindex , CCoinsViewCache & view , bool fJustCheck ) <nl> { <nl> + AssertLockHeld ( cs_main ) ; <nl> / / Check it again in case a previous version let a bad block in <nl> if ( ! CheckBlock ( block , state , ! fJustCheck , ! fJustCheck ) ) <nl> return false ; <nl>
Add missing AssertLockHeld in ConnectBlock
bitcoin/bitcoin
b39a07dc42ab6ba746a25206969fb81913146f1f
2014-04-23T07:07:18Z
mmm a / include / swift / AST / ASTPrinter . h <nl> ppp b / include / swift / AST / ASTPrinter . h <nl> class ASTPrinter { <nl> / / / \ param T the original \ c Type being referenced . May be null . <nl> / / / \ param RefTo the \ c TypeDecl this is considered a reference to . <nl> / / / \ param Name the name to be printed . <nl> - virtual void printTypeRef ( Type T , const TypeDecl * RefTo , Identifier Name ) ; <nl> + / / / \ param NameContext the \ c PrintNameContext which this type is being <nl> + / / / printed in , used to determine how to escape type names . <nl> + virtual void printTypeRef ( <nl> + Type T , const TypeDecl * RefTo , Identifier Name , <nl> + PrintNameContext NameContext = PrintNameContext : : Normal ) ; <nl> <nl> / / / Called when printing the referenced name of a module . <nl> virtual void printModuleRef ( ModuleEntity Mod , Identifier Name ) ; <nl> mmm a / lib / AST / ASTPrinter . cpp <nl> ppp b / lib / AST / ASTPrinter . cpp <nl> void ASTPrinter : : printEscapedStringLiteral ( StringRef str ) { <nl> printTextImpl ( escapeBuf . str ( ) ) ; <nl> } <nl> <nl> - void ASTPrinter : : printTypeRef ( Type T , const TypeDecl * RefTo , Identifier Name ) { <nl> - PrintNameContext Context = PrintNameContext : : Normal ; <nl> + void ASTPrinter : : printTypeRef ( Type T , const TypeDecl * RefTo , Identifier Name , <nl> + PrintNameContext Context ) { <nl> if ( isa < GenericTypeParamDecl > ( RefTo ) ) { <nl> Context = PrintNameContext : : GenericParameter ; <nl> } else if ( T & & T - > is < DynamicSelfType > ( ) ) { <nl> class TypePrinter : public TypeVisitor < TypePrinter > { <nl> } <nl> <nl> template < typename T > <nl> - void printTypeDeclName ( T * Ty ) { <nl> + void printTypeDeclName ( <nl> + T * Ty , PrintNameContext NameContext = PrintNameContext : : Normal ) { <nl> TypeDecl * TD = Ty - > getDecl ( ) ; <nl> - Printer . printTypeRef ( Ty , TD , TD - > getName ( ) ) ; <nl> + Printer . printTypeRef ( Ty , TD , TD - > getName ( ) , NameContext ) ; <nl> } <nl> <nl> / / FIXME : we should have a callback that would tell us <nl> class TypePrinter : public TypeVisitor < TypePrinter > { <nl> TypePrinter ( ASTPrinter & Printer , const PrintOptions & PO ) <nl> : Printer ( Printer ) , Options ( PO ) { } <nl> <nl> + template < typename T > <nl> + void printQualifiedType ( T * Ty ) { <nl> + PrintNameContext NameContext = PrintNameContext : : Normal ; <nl> + <nl> + / / If we printed a parent type or a module qualification , let the printer <nl> + / / know we ' re printing a type member so it escapes ` Type ` and ` Protocol ` . <nl> + if ( auto parent = Ty - > getParent ( ) ) { <nl> + visitParentType ( parent ) ; <nl> + Printer < < " . " ; <nl> + NameContext = PrintNameContext : : TypeMember ; <nl> + } else if ( shouldPrintFullyQualified ( Ty ) ) { <nl> + printModuleContext ( Ty ) ; <nl> + NameContext = PrintNameContext : : TypeMember ; <nl> + } <nl> + <nl> + printTypeDeclName ( Ty , NameContext ) ; <nl> + } <nl> + <nl> void visit ( Type T ) { <nl> Printer . printTypePre ( TypeLoc : : withoutLoc ( T ) ) ; <nl> SWIFT_DEFER { Printer . printTypePost ( TypeLoc : : withoutLoc ( T ) ) ; } ; <nl> class TypePrinter : public TypeVisitor < TypePrinter > { <nl> return ; <nl> } <nl> <nl> - if ( auto parent = T - > getParent ( ) ) { <nl> - visit ( parent ) ; <nl> - Printer < < " . " ; <nl> - } else if ( shouldPrintFullyQualified ( T ) ) { <nl> - printModuleContext ( T ) ; <nl> - } <nl> - <nl> - printTypeDeclName ( T ) ; <nl> + printQualifiedType ( T ) ; <nl> printGenericArgs ( T - > getInnermostGenericArgs ( ) ) ; <nl> } <nl> <nl> class TypePrinter : public TypeVisitor < TypePrinter > { <nl> } <nl> <nl> void visitUnboundGenericType ( UnboundGenericType * T ) { <nl> - if ( auto ParentType = T - > getParent ( ) ) { <nl> - visit ( ParentType ) ; <nl> - Printer < < " . " ; <nl> - } else if ( shouldPrintFullyQualified ( T ) ) { <nl> - printModuleContext ( T ) ; <nl> - } <nl> - printTypeDeclName ( T ) ; <nl> + printQualifiedType ( T ) ; <nl> } <nl> <nl> void visitBoundGenericType ( BoundGenericType * T ) { <nl> class TypePrinter : public TypeVisitor < TypePrinter > { <nl> return ; <nl> } <nl> } <nl> - if ( auto ParentType = T - > getParent ( ) ) { <nl> - visit ( ParentType ) ; <nl> - Printer < < " . " ; <nl> - } else if ( shouldPrintFullyQualified ( T ) ) { <nl> - printModuleContext ( T ) ; <nl> - } <nl> - <nl> - printTypeDeclName ( T ) ; <nl> + printQualifiedType ( T ) ; <nl> printGenericArgs ( T - > getGenericArgs ( ) ) ; <nl> } <nl> <nl> class TypePrinter : public TypeVisitor < TypePrinter > { <nl> } <nl> <nl> void visitEnumType ( EnumType * T ) { <nl> - if ( auto ParentType = T - > getParent ( ) ) { <nl> - visitParentType ( ParentType ) ; <nl> - Printer < < " . " ; <nl> - } else if ( shouldPrintFullyQualified ( T ) ) { <nl> - printModuleContext ( T ) ; <nl> - } <nl> - <nl> - printTypeDeclName ( T ) ; <nl> + printQualifiedType ( T ) ; <nl> } <nl> <nl> void visitStructType ( StructType * T ) { <nl> - if ( auto ParentType = T - > getParent ( ) ) { <nl> - visitParentType ( ParentType ) ; <nl> - Printer < < " . " ; <nl> - } else if ( shouldPrintFullyQualified ( T ) ) { <nl> - printModuleContext ( T ) ; <nl> - } <nl> - <nl> - printTypeDeclName ( T ) ; <nl> + printQualifiedType ( T ) ; <nl> } <nl> <nl> void visitClassType ( ClassType * T ) { <nl> - if ( auto ParentType = T - > getParent ( ) ) { <nl> - visitParentType ( ParentType ) ; <nl> - Printer < < " . " ; <nl> - } else if ( shouldPrintFullyQualified ( T ) ) { <nl> - printModuleContext ( T ) ; <nl> - } <nl> - <nl> - printTypeDeclName ( T ) ; <nl> + printQualifiedType ( T ) ; <nl> } <nl> <nl> void visitAnyMetatypeType ( AnyMetatypeType * T ) { <nl> class TypePrinter : public TypeVisitor < TypePrinter > { <nl> } <nl> <nl> void visitProtocolType ( ProtocolType * T ) { <nl> - if ( shouldPrintFullyQualified ( T ) ) { <nl> - printModuleContext ( T ) ; <nl> - } <nl> - <nl> - printTypeDeclName ( T ) ; <nl> + printQualifiedType ( T ) ; <nl> } <nl> <nl> void visitProtocolCompositionType ( ProtocolCompositionType * T ) { <nl> mmm a / lib / IDE / ModuleInterfacePrinting . cpp <nl> ppp b / lib / IDE / ModuleInterfacePrinting . cpp <nl> class ClangCommentPrinter : public ASTPrinter { <nl> void printTypePost ( const TypeLoc & TL ) override { <nl> return OtherPrinter . printTypePost ( TL ) ; <nl> } <nl> - void printTypeRef ( Type T , const TypeDecl * TD , Identifier Name ) override { <nl> - return OtherPrinter . printTypeRef ( T , TD , Name ) ; <nl> + void printTypeRef ( Type T , const TypeDecl * TD , Identifier Name , <nl> + PrintNameContext NameContext ) override { <nl> + return OtherPrinter . printTypeRef ( T , TD , Name , NameContext ) ; <nl> } <nl> void printModuleRef ( ModuleEntity Mod , Identifier Name ) override { <nl> return OtherPrinter . printModuleRef ( Mod , Name ) ; <nl> new file mode 100644 <nl> index 000000000000 . . a4e9c76dbd58 <nl> mmm / dev / null <nl> ppp b / test / ParseableInterface / top - level - Type - and - Protocol . swift <nl> <nl> + / / RUN : % empty - directory ( % t ) <nl> + <nl> + / / RUN : % target - swift - frontend - typecheck - emit - module - interface - path % t / MyModule . swiftinterface - enable - library - evolution % s - module - name MyModule <nl> + / / RUN : % FileCheck % s < % t / MyModule . swiftinterface <nl> + <nl> + / / RUN : % target - swift - frontend - compile - module - from - interface % t / MyModule . swiftinterface - o % t / MyModule . swiftmodule <nl> + <nl> + / / CHECK : public struct Type { <nl> + / / CHECK - NEXT : } <nl> + public struct Type { } <nl> + <nl> + / / CHECK : public protocol Protocol { <nl> + / / CHECK - NEXT : } <nl> + public protocol Protocol { } <nl> + <nl> + / / CHECK : public func usesType ( _ x : MyModule . ` Type ` ) <nl> + public func usesType ( _ x : Type ) { } <nl> + <nl> + / / CHECK : public func genericProtocol < T > ( _ x : T ) where T : MyModule . ` Protocol ` <nl> + public func genericProtocol < T : Protocol > ( _ x : T ) { } <nl> + <nl> + / / CHECK : public func existentialProtocol ( _ x : MyModule . ` Protocol ` ) <nl> + public func existentialProtocol ( _ x : Protocol ) { } <nl> + <nl> + / / CHECK : public struct Parent { <nl> + public struct Parent { <nl> + / / CHECK : public struct ` Type ` { <nl> + public struct ` Type ` { <nl> + / / CHECK : public struct ` Protocol ` { <nl> + / / CHECK - NEXT : } <nl> + public struct ` Protocol ` { } <nl> + / / CHECK - NEXT : } <nl> + } <nl> + / / CHECK : public struct ` Protocol ` { <nl> + / / CHECK - NEXT : } <nl> + public struct ` Protocol ` { } <nl> + / / CHECK - NEXT : } <nl> + } <nl> + <nl> + / / CHECK : public func usesNestedType ( _ x : MyModule . Parent . ` Type ` ) <nl> + public func usesNestedType ( _ x : Parent . ` Type ` ) { } <nl> + <nl> + / / CHECK : public func usesNestedTypeProtocol ( _ x : MyModule . Parent . ` Type ` . ` Protocol ` ) <nl> + public func usesNestedTypeProtocol ( _ x : Parent . ` Type ` . ` Protocol ` ) { } <nl> + <nl> + / / CHECK : public func usesNestedProtocol ( _ x : MyModule . Parent . ` Protocol ` ) <nl> + public func usesNestedProtocol ( _ x : Parent . ` Protocol ` ) { } <nl> mmm a / tools / SourceKit / lib / SwiftLang / SwiftDocSupport . cpp <nl> ppp b / tools / SourceKit / lib / SwiftLang / SwiftDocSupport . cpp <nl> class AnnotatingPrinter : public StreamPrinter { <nl> deinitDefaultMapToUse ( D ) ; <nl> } <nl> <nl> - void printTypeRef ( Type T , const TypeDecl * TD , Identifier Name ) override { <nl> + void printTypeRef ( <nl> + Type T , const TypeDecl * TD , Identifier Name , <nl> + PrintNameContext NameContext = PrintNameContext : : Normal ) override { <nl> unsigned StartOffset = OS . tell ( ) ; <nl> References . emplace_back ( TD , StartOffset , Name . str ( ) . size ( ) ) ; <nl> - StreamPrinter : : printTypeRef ( T , TD , Name ) ; <nl> + StreamPrinter : : printTypeRef ( T , TD , Name , NameContext ) ; <nl> } <nl> } ; <nl> <nl> mmm a / tools / SourceKit / lib / SwiftLang / SwiftEditorInterfaceGen . cpp <nl> ppp b / tools / SourceKit / lib / SwiftLang / SwiftEditorInterfaceGen . cpp <nl> class AnnotatingPrinter : public StreamPrinter { <nl> } <nl> } <nl> <nl> - void printTypeRef ( Type T , const TypeDecl * TD , Identifier Name ) override { <nl> + void printTypeRef ( <nl> + Type T , const TypeDecl * TD , Identifier Name , <nl> + PrintNameContext NameContext = PrintNameContext : : Normal ) override { <nl> unsigned StartOffset = OS . tell ( ) ; <nl> Info . References . emplace_back ( TD , StartOffset , Name . str ( ) . size ( ) ) ; <nl> - StreamPrinter : : printTypeRef ( T , TD , Name ) ; <nl> + StreamPrinter : : printTypeRef ( T , TD , Name , NameContext ) ; <nl> } <nl> <nl> void printModuleRef ( ModuleEntity Mod , Identifier Name ) override { <nl> mmm a / tools / SourceKit / lib / SwiftLang / SwiftSourceDocInfo . cpp <nl> ppp b / tools / SourceKit / lib / SwiftLang / SwiftSourceDocInfo . cpp <nl> class AnnotatedDeclarationPrinter : public XMLEscapingPrinter { <nl> : XMLEscapingPrinter ( OS ) { } <nl> <nl> private : <nl> - void printTypeRef ( Type T , const TypeDecl * TD , Identifier Name ) override { <nl> + void printTypeRef ( <nl> + Type T , const TypeDecl * TD , Identifier Name , <nl> + PrintNameContext NameContext = PrintNameContext : : Normal ) override { <nl> printXML ( " < Type usr = \ " " ) ; <nl> SwiftLangSupport : : printUSR ( TD , OS ) ; <nl> printXML ( " \ " > " ) ; <nl> - StreamPrinter : : printTypeRef ( T , TD , Name ) ; <nl> + StreamPrinter : : printTypeRef ( T , TD , Name , NameContext ) ; <nl> printXML ( " < / Type > " ) ; <nl> } <nl> } ; <nl> class FullyAnnotatedDeclarationPrinter final : public XMLEscapingPrinter { <nl> closeTag ( tag ) ; <nl> } <nl> <nl> - void printTypeRef ( Type T , const TypeDecl * TD , Identifier name ) override { <nl> + void printTypeRef ( <nl> + Type T , const TypeDecl * TD , Identifier name , <nl> + PrintNameContext NameContext = PrintNameContext : : Normal ) override { <nl> auto tag = getTagForDecl ( TD , / * isRef = * / true ) ; <nl> openTagWithUSRForDecl ( tag , TD ) ; <nl> insideRef = true ; <nl> - XMLEscapingPrinter : : printTypeRef ( T , TD , name ) ; <nl> + XMLEscapingPrinter : : printTypeRef ( T , TD , name , NameContext ) ; <nl> insideRef = false ; <nl> closeTag ( tag ) ; <nl> } <nl> mmm a / tools / swift - ide - test / swift - ide - test . cpp <nl> ppp b / tools / swift - ide - test / swift - ide - test . cpp <nl> class AnnotatingPrinter : public StreamPrinter { <nl> OS < < " < / synthesized > " ; <nl> } <nl> <nl> - void printTypeRef ( Type T , const TypeDecl * TD , Identifier Name ) override { <nl> + void printTypeRef ( <nl> + Type T , const TypeDecl * TD , Identifier Name , <nl> + PrintNameContext NameContext = PrintNameContext : : Normal ) override { <nl> OS < < " < ref : " < < Decl : : getKindName ( TD - > getKind ( ) ) < < ' > ' ; <nl> - StreamPrinter : : printTypeRef ( T , TD , Name ) ; <nl> + StreamPrinter : : printTypeRef ( T , TD , Name , NameContext ) ; <nl> OS < < " < / ref > " ; <nl> } <nl> void printModuleRef ( ModuleEntity Mod , Identifier Name ) override { <nl>
Merge remote - tracking branch ' origin / master ' into master - next
apple/swift
42faf0057967b36686d59cc82fb9bf47670e220a
2019-09-11T20:57:43Z
mmm a / tensorflow / contrib / estimator / python / estimator / dnn_with_layer_annotations . py <nl> ppp b / tensorflow / contrib / estimator / python / estimator / dnn_with_layer_annotations . py <nl> def input_layer_with_layer_annotations ( features , <nl> weight_collections = None , <nl> trainable = True , <nl> cols_to_vars = None , <nl> + scope = None , <nl> cols_to_output_tensors = None ) : <nl> " " " Returns a dense ` Tensor ` as input layer based on given ` feature_columns ` . <nl> <nl> def input_layer_with_layer_annotations ( features , <nl> ' some_variable : 0 ' shape = ( 5 , 10 ) , < tf . Variable ' some_variable : 1 ' <nl> shape = ( 5 , 10 ) ] } If a column creates no variables , its value will be an <nl> empty list . <nl> + scope : A name or variable scope to use <nl> cols_to_output_tensors : If not ` None ` , must be a dictionary that will be <nl> filled with a mapping from ' _FeatureColumn ' to the associated output <nl> ` Tensor ` s . <nl> def input_layer_with_layer_annotations ( features , <nl> weight_collections = weight_collections , <nl> trainable = trainable , <nl> cols_to_vars = cols_to_vars , <nl> + scope = scope , <nl> cols_to_output_tensors = local_cols_to_output_tensors ) <nl> <nl> if cols_to_output_tensors is not None : <nl> def DNNClassifierWithLayerAnnotations ( # pylint : disable = invalid - name <nl> <nl> def _model_fn ( features , labels , mode , config ) : <nl> with _monkey_patch ( <nl> - feature_column_lib , ' input_layer ' , <nl> - make_input_layer_with_layer_annotations ( feature_column_lib . input_layer , <nl> - mode ) ) : <nl> + feature_column_lib , ' _internal_input_layer ' , <nl> + make_input_layer_with_layer_annotations ( <nl> + feature_column_lib . _internal_input_layer , mode ) ) : # pylint : disable = protected - access <nl> return original . model_fn ( features , labels , mode , config ) <nl> <nl> return estimator . Estimator ( <nl> def DNNRegressorWithLayerAnnotations ( # pylint : disable = invalid - name <nl> <nl> def _model_fn ( features , labels , mode , config ) : <nl> with _monkey_patch ( <nl> - feature_column_lib , ' input_layer ' , <nl> - make_input_layer_with_layer_annotations ( feature_column_lib . input_layer , <nl> - mode ) ) : <nl> + feature_column_lib , ' _internal_input_layer ' , <nl> + make_input_layer_with_layer_annotations ( <nl> + feature_column_lib . _internal_input_layer , mode ) ) : # pylint : disable = protected - access <nl> return original . model_fn ( features , labels , mode , config ) <nl> <nl> return estimator . Estimator ( <nl> mmm a / tensorflow / python / estimator / BUILD <nl> ppp b / tensorflow / python / estimator / BUILD <nl> py_library ( <nl> " : prediction_keys " , <nl> " / / tensorflow : tensorflow_py_no_contrib " , <nl> " / / third_party / py / numpy " , <nl> + " @ absl_py / / absl / testing : parameterized " , <nl> " @ six_archive / / : six " , <nl> ] , <nl> ) <nl> py_test ( <nl> " : pandas_io " , <nl> " : prediction_keys " , <nl> " / / tensorflow : tensorflow_py_no_contrib " , <nl> + " @ absl_py / / absl / testing : parameterized " , <nl> " @ six_archive / / : six " , <nl> ] , <nl> ) <nl> mmm a / tensorflow / python / estimator / canned / dnn . py <nl> ppp b / tensorflow / python / estimator / canned / dnn . py <nl> <nl> from tensorflow . python . estimator import model_fn <nl> from tensorflow . python . estimator . canned import head as head_lib <nl> from tensorflow . python . estimator . canned import optimizers <nl> - from tensorflow . python . feature_column import feature_column as feature_column_lib <nl> + from tensorflow . python . feature_column import feature_column <nl> + from tensorflow . python . feature_column import feature_column_v2 <nl> + from tensorflow . python . keras . engine import training <nl> from tensorflow . python . layers import core as core_layers <nl> from tensorflow . python . layers import normalization <nl> from tensorflow . python . ops import init_ops <nl> def _add_hidden_layer_summary ( value , tag ) : <nl> summary . histogram ( ' % s / activation ' % tag , value ) <nl> <nl> <nl> - def _dnn_logit_fn_builder ( units , hidden_units , feature_columns , activation_fn , <nl> - dropout , input_layer_partitioner , batch_norm ) : <nl> + def _dnn_logit_fn_builder ( units , <nl> + hidden_units , <nl> + feature_columns , <nl> + activation_fn , <nl> + dropout , <nl> + input_layer_partitioner , <nl> + batch_norm , <nl> + shared_state_manager = None ) : <nl> " " " Function builder for a dnn logit_fn . <nl> <nl> Args : <nl> def _dnn_logit_fn_builder ( units , hidden_units , feature_columns , activation_fn , <nl> coordinate . <nl> input_layer_partitioner : Partitioner for input layer . <nl> batch_norm : Whether to use batch normalization after each hidden layer . <nl> + shared_state_manager : A SharedEmbeddingStateManager object to hold the <nl> + shared state for SharedEmbeddingColumn ' s . <nl> <nl> Returns : <nl> A logit_fn ( see below ) . <nl> def dnn_logit_fn ( features , mode ) : <nl> A ` Tensor ` representing the logits , or a list of ` Tensor ` ' s representing <nl> multiple logits in the MultiHead case . <nl> " " " <nl> - is_training = mode = = model_fn . ModeKeys . TRAIN <nl> - with variable_scope . variable_scope ( <nl> - ' input_from_feature_columns ' , <nl> - values = tuple ( six . itervalues ( features ) ) , <nl> - partitioner = input_layer_partitioner ) : <nl> - net = feature_column_lib . input_layer ( <nl> - features = features , feature_columns = feature_columns ) <nl> + dnn_model = _DNNModel ( <nl> + units , <nl> + hidden_units , <nl> + feature_columns , <nl> + activation_fn , <nl> + dropout , <nl> + input_layer_partitioner , <nl> + batch_norm , <nl> + shared_state_manager , <nl> + name = ' dnn ' ) <nl> + return dnn_model ( features , mode ) <nl> + <nl> + return dnn_logit_fn <nl> + <nl> + <nl> + class _DNNModel ( training . Model ) : <nl> + " " " A DNN Model . " " " <nl> + <nl> + def __init__ ( self , <nl> + units , <nl> + hidden_units , <nl> + feature_columns , <nl> + activation_fn , <nl> + dropout , <nl> + input_layer_partitioner , <nl> + batch_norm , <nl> + shared_state_manager , <nl> + name = None , <nl> + * * kwargs ) : <nl> + super ( _DNNModel , self ) . __init__ ( name = name , * * kwargs ) <nl> + <nl> + if feature_column_v2 . is_feature_column_v2 ( feature_columns ) : <nl> + input_layer = feature_column_v2 . FeatureLayer ( <nl> + feature_columns = feature_columns , <nl> + name = ' input_layer ' , <nl> + shared_state_manager = shared_state_manager ) <nl> + else : <nl> + with variable_scope . variable_scope ( ' input_from_feature_columns ' ) : <nl> + input_layer = feature_column . InputLayer ( <nl> + feature_columns = feature_columns , name = ' input_layer ' ) <nl> + <nl> + self . _input_layer = self . _add_layers ( [ input_layer ] ) [ 0 ] <nl> + <nl> + self . _dropout = dropout <nl> + self . _batch_norm = batch_norm <nl> + <nl> + hidden_layers = [ ] <nl> + dropout_layers = [ ] <nl> + batch_norm_layers = [ ] <nl> for layer_id , num_hidden_units in enumerate ( hidden_units ) : <nl> - with variable_scope . variable_scope ( <nl> - ' hiddenlayer_ % d ' % layer_id , values = ( net , ) ) as hidden_layer_scope : <nl> - net = core_layers . dense ( <nl> - net , <nl> - units = num_hidden_units , <nl> - activation = activation_fn , <nl> - kernel_initializer = init_ops . glorot_uniform_initializer ( ) , <nl> - name = hidden_layer_scope ) <nl> - if dropout is not None and is_training : <nl> - net = core_layers . dropout ( net , rate = dropout , training = True ) <nl> - if batch_norm : <nl> - # TODO ( hjm ) : In future , if this becomes popular , we can enable <nl> - # customization of the batch normalization params by accepting a <nl> - # list of ` BatchNormalization ` instances as ` batch_norm ` . <nl> - net = normalization . batch_normalization ( <nl> - net , <nl> - # The default momentum 0 . 99 actually crashes on certain <nl> - # problem , so here we use 0 . 999 , which is the default of <nl> - # tf . contrib . layers . batch_norm . <nl> - momentum = 0 . 999 , <nl> - training = is_training , <nl> - name = ' batchnorm_ % d ' % layer_id ) <nl> - _add_hidden_layer_summary ( net , hidden_layer_scope . name ) <nl> - <nl> - with variable_scope . variable_scope ( ' logits ' , values = ( net , ) ) as logits_scope : <nl> - logits = core_layers . dense ( <nl> - net , <nl> - units = units , <nl> - activation = None , <nl> + hidden_layer = core_layers . Dense ( <nl> + units = num_hidden_units , <nl> + activation = activation_fn , <nl> kernel_initializer = init_ops . glorot_uniform_initializer ( ) , <nl> - name = logits_scope ) <nl> - _add_hidden_layer_summary ( logits , logits_scope . name ) <nl> - <nl> + name = ' hiddenlayer_ % d ' % layer_id ) <nl> + hidden_layers . append ( hidden_layer ) <nl> + if self . _dropout is not None : <nl> + dropout_layer = core_layers . Dropout ( rate = dropout ) <nl> + dropout_layers . append ( dropout_layer ) <nl> + if self . _batch_norm : <nl> + batch_norm_layer = normalization . BatchNormalization ( <nl> + # The default momentum 0 . 99 actually crashes on certain <nl> + # problem , so here we use 0 . 999 , which is the default of <nl> + # tf . contrib . layers . batch_norm . <nl> + momentum = 0 . 999 , <nl> + trainable = True , <nl> + name = ' hiddenlayer_ % d / batchnorm_ % d ' % ( layer_id , layer_id ) ) <nl> + batch_norm_layers . append ( batch_norm_layer ) <nl> + <nl> + self . _hidden_layers = self . _add_layers ( hidden_layers ) <nl> + if self . _dropout is not None : <nl> + self . _dropout_layers = self . _add_layers ( dropout_layers ) <nl> + if self . _batch_norm : <nl> + self . _batch_norm_layers = self . _add_layers ( batch_norm_layers ) <nl> + <nl> + self . _logits_layer = core_layers . Dense ( <nl> + units = units , <nl> + activation = None , <nl> + kernel_initializer = init_ops . glorot_uniform_initializer ( ) , <nl> + name = ' logits ' ) <nl> + <nl> + def call ( self , features , mode ) : <nl> + is_training = mode = = model_fn . ModeKeys . TRAIN <nl> + with variable_scope . variable_scope ( ' input_from_feature_columns ' ) : <nl> + net = self . _input_layer ( features ) <nl> + for i in range ( len ( self . _hidden_layers ) ) : <nl> + net = self . _hidden_layers [ i ] ( net ) <nl> + if self . _dropout is not None and is_training : <nl> + net = self . _dropout_layers [ i ] ( net ) <nl> + if self . _batch_norm : <nl> + net = self . _batch_norm_layers [ i ] ( net , training = is_training ) <nl> + _add_hidden_layer_summary ( net , self . _hidden_layers [ i ] . name ) <nl> + <nl> + logits = self . _logits_layer ( net ) <nl> + _add_hidden_layer_summary ( logits , self . _logits_layer . name ) <nl> return logits <nl> <nl> - return dnn_logit_fn <nl> + def _add_layers ( self , layers ) : <nl> + # " Magic " required for keras . Model classes to track all the variables in <nl> + # a list of layers . Layer objects . <nl> + # TODO ( ashankar ) : Figure out API so user code doesn ' t have to do this . <nl> + for layer in layers : <nl> + setattr ( self , layer . name , layer ) <nl> + return layers <nl> <nl> <nl> def _dnn_model_fn ( features , <nl> def _dnn_model_fn ( features , <nl> input_layer_partitioner = None , <nl> config = None , <nl> use_tpu = False , <nl> - batch_norm = False ) : <nl> + batch_norm = False , <nl> + shared_state_manager = None ) : <nl> " " " Deep Neural Net model_fn . <nl> <nl> Args : <nl> def _dnn_model_fn ( features , <nl> use_tpu : Whether to make a DNN model able to run on TPU . Will make function <nl> return a ` _TPUEstimatorSpec ` instance and disable variable partitioning . <nl> batch_norm : Whether to use batch normalization after each hidden layer . <nl> + shared_state_manager : A SharedEmbeddingStateManager object to hold the <nl> + shared state for SharedEmbeddingColumn ' s . <nl> <nl> Returns : <nl> An ` EstimatorSpec ` instance . <nl> def _dnn_model_fn ( features , <nl> activation_fn = activation_fn , <nl> dropout = dropout , <nl> input_layer_partitioner = input_layer_partitioner , <nl> - batch_norm = batch_norm ) <nl> + batch_norm = batch_norm , <nl> + shared_state_manager = shared_state_manager ) <nl> logits = logit_fn ( features = features , mode = mode ) <nl> <nl> if use_tpu : <nl> def __init__ ( <nl> " " " <nl> head = head_lib . _binary_logistic_or_multi_class_head ( # pylint : disable = protected - access <nl> n_classes , weight_column , label_vocabulary , loss_reduction ) <nl> + <nl> + shared_state_manager = feature_column_v2 . maybe_create_shared_state_manager ( <nl> + feature_columns ) <nl> + <nl> def _model_fn ( features , labels , mode , config ) : <nl> " " " Call the defined shared _dnn_model_fn . " " " <nl> return _dnn_model_fn ( <nl> def _model_fn ( features , labels , mode , config ) : <nl> dropout = dropout , <nl> input_layer_partitioner = input_layer_partitioner , <nl> config = config , <nl> - batch_norm = batch_norm ) <nl> + batch_norm = batch_norm , <nl> + shared_state_manager = shared_state_manager ) <nl> <nl> super ( DNNClassifier , self ) . __init__ ( <nl> model_fn = _model_fn , model_dir = model_dir , config = config , <nl> def __init__ ( <nl> batch_norm : Whether to use batch normalization after each hidden layer . <nl> " " " <nl> <nl> + shared_state_manager = None <nl> + if feature_column_v2 . is_feature_column_v2 ( feature_columns ) : <nl> + shared_state_manager = feature_column_v2 . SharedEmbeddingStateManager ( ) <nl> + <nl> def _model_fn ( features , labels , mode , config ) : <nl> " " " Call the defined shared _dnn_model_fn . " " " <nl> return _dnn_model_fn ( <nl> def _model_fn ( features , labels , mode , config ) : <nl> labels = labels , <nl> mode = mode , <nl> head = head_lib . _regression_head ( # pylint : disable = protected - access <nl> - label_dimension = label_dimension , weight_column = weight_column , <nl> + label_dimension = label_dimension , <nl> + weight_column = weight_column , <nl> loss_reduction = loss_reduction ) , <nl> hidden_units = hidden_units , <nl> feature_columns = tuple ( feature_columns or [ ] ) , <nl> def _model_fn ( features , labels , mode , config ) : <nl> dropout = dropout , <nl> input_layer_partitioner = input_layer_partitioner , <nl> config = config , <nl> - batch_norm = batch_norm ) <nl> + batch_norm = batch_norm , <nl> + shared_state_manager = shared_state_manager ) <nl> <nl> super ( DNNRegressor , self ) . __init__ ( <nl> model_fn = _model_fn , model_dir = model_dir , config = config , <nl> mmm a / tensorflow / python / estimator / canned / dnn_linear_combined . py <nl> ppp b / tensorflow / python / estimator / canned / dnn_linear_combined . py <nl> <nl> from tensorflow . python . estimator . canned import head as head_lib <nl> from tensorflow . python . estimator . canned import linear <nl> from tensorflow . python . estimator . canned import optimizers <nl> + from tensorflow . python . feature_column import feature_column_v2 <nl> from tensorflow . python . framework import ops <nl> from tensorflow . python . ops import control_flow_ops <nl> from tensorflow . python . ops import nn <nl> def _dnn_linear_combined_model_fn ( features , <nl> max_partitions = num_ps_replicas , <nl> min_slice_size = 64 < < 20 ) ) <nl> <nl> + shared_state_manager = feature_column_v2 . maybe_create_shared_state_manager ( <nl> + list ( linear_feature_columns ) + list ( dnn_feature_columns ) ) <nl> + <nl> # Build DNN Logits . <nl> dnn_parent_scope = ' dnn ' <nl> <nl> def _dnn_linear_combined_model_fn ( features , <nl> activation_fn = dnn_activation_fn , <nl> dropout = dnn_dropout , <nl> input_layer_partitioner = input_layer_partitioner , <nl> - batch_norm = batch_norm ) <nl> + batch_norm = batch_norm , <nl> + shared_state_manager = shared_state_manager ) <nl> dnn_logits = dnn_logit_fn ( features = features , mode = mode ) <nl> <nl> linear_parent_scope = ' linear ' <nl> mmm a / tensorflow / python / estimator / canned / dnn_test . py <nl> ppp b / tensorflow / python / estimator / canned / dnn_test . py <nl> <nl> import shutil <nl> import tempfile <nl> <nl> + from absl . testing import parameterized <nl> import numpy as np <nl> import six <nl> <nl> <nl> from tensorflow . python . estimator . inputs import numpy_io <nl> from tensorflow . python . estimator . inputs import pandas_io <nl> from tensorflow . python . feature_column import feature_column <nl> + from tensorflow . python . feature_column import feature_column_v2 <nl> from tensorflow . python . framework import dtypes <nl> from tensorflow . python . framework import ops <nl> from tensorflow . python . ops import data_flow_ops <nl> def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> dnn_testing_utils . BaseDNNModelFnTest . __init__ ( self , dnn . _dnn_model_fn ) <nl> <nl> <nl> + class DNNModelFnV2Test ( dnn_testing_utils . BaseDNNModelFnTest , test . TestCase ) : <nl> + <nl> + def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> + test . TestCase . __init__ ( self , methodName ) <nl> + dnn_testing_utils . BaseDNNModelFnTest . __init__ ( <nl> + self , dnn . _dnn_model_fn , is_fc_v2 = True ) <nl> + <nl> + <nl> class DNNLogitFnTest ( dnn_testing_utils . BaseDNNLogitFnTest , test . TestCase ) : <nl> <nl> def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> dnn . _dnn_logit_fn_builder ) <nl> <nl> <nl> + class DNNLogitFnV2Test ( dnn_testing_utils . BaseDNNLogitFnTest , test . TestCase ) : <nl> + <nl> + def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> + test . TestCase . __init__ ( self , methodName ) <nl> + dnn_testing_utils . BaseDNNLogitFnTest . __init__ ( <nl> + self , dnn . _dnn_logit_fn_builder , is_fc_v2 = True ) <nl> + <nl> + <nl> class DNNWarmStartingTest ( dnn_testing_utils . BaseDNNWarmStartingTest , <nl> test . TestCase ) : <nl> <nl> def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> _dnn_regressor_fn ) <nl> <nl> <nl> + class DNNWarmStartingV2Test ( dnn_testing_utils . BaseDNNWarmStartingTest , <nl> + test . TestCase ) : <nl> + <nl> + def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> + test . TestCase . __init__ ( self , methodName ) <nl> + dnn_testing_utils . BaseDNNWarmStartingTest . __init__ ( <nl> + self , _dnn_classifier_fn , _dnn_regressor_fn , is_fc_v2 = True ) <nl> + <nl> + <nl> class DNNClassifierEvaluateTest ( <nl> dnn_testing_utils . BaseDNNClassifierEvaluateTest , test . TestCase ) : <nl> <nl> def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> self , _dnn_classifier_fn ) <nl> <nl> <nl> + class DNNClassifierEvaluateV2Test ( <nl> + dnn_testing_utils . BaseDNNClassifierEvaluateTest , test . TestCase ) : <nl> + <nl> + def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> + test . TestCase . __init__ ( self , methodName ) <nl> + dnn_testing_utils . BaseDNNClassifierEvaluateTest . __init__ ( <nl> + self , _dnn_classifier_fn , is_fc_v2 = True ) <nl> + <nl> + <nl> class DNNClassifierPredictTest ( <nl> dnn_testing_utils . BaseDNNClassifierPredictTest , test . TestCase ) : <nl> <nl> def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> self , _dnn_classifier_fn ) <nl> <nl> <nl> + class DNNClassifierPredictV2Test ( dnn_testing_utils . BaseDNNClassifierPredictTest , <nl> + test . TestCase ) : <nl> + <nl> + def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> + test . TestCase . __init__ ( self , methodName ) <nl> + dnn_testing_utils . BaseDNNClassifierPredictTest . __init__ ( <nl> + self , _dnn_classifier_fn , is_fc_v2 = True ) <nl> + <nl> + <nl> class DNNClassifierTrainTest ( <nl> dnn_testing_utils . BaseDNNClassifierTrainTest , test . TestCase ) : <nl> <nl> def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> self , _dnn_classifier_fn ) <nl> <nl> <nl> + class DNNClassifierTrainV2Test ( dnn_testing_utils . BaseDNNClassifierTrainTest , <nl> + test . TestCase ) : <nl> + <nl> + def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> + test . TestCase . __init__ ( self , methodName ) <nl> + dnn_testing_utils . BaseDNNClassifierTrainTest . __init__ ( <nl> + self , _dnn_classifier_fn , is_fc_v2 = True ) <nl> + <nl> + <nl> def _dnn_regressor_fn ( * args , * * kwargs ) : <nl> return dnn . DNNRegressor ( * args , * * kwargs ) <nl> <nl> def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> self , _dnn_regressor_fn ) <nl> <nl> <nl> + class DNNRegressorEvaluateV2Test ( dnn_testing_utils . BaseDNNRegressorEvaluateTest , <nl> + test . TestCase ) : <nl> + <nl> + def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> + test . TestCase . __init__ ( self , methodName ) <nl> + dnn_testing_utils . BaseDNNRegressorEvaluateTest . __init__ ( <nl> + self , _dnn_regressor_fn , is_fc_v2 = True ) <nl> + <nl> + <nl> class DNNRegressorPredictTest ( <nl> dnn_testing_utils . BaseDNNRegressorPredictTest , test . TestCase ) : <nl> <nl> def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> self , _dnn_regressor_fn ) <nl> <nl> <nl> + class DNNRegressorPredictV2Test ( dnn_testing_utils . BaseDNNRegressorPredictTest , <nl> + test . TestCase ) : <nl> + <nl> + def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> + test . TestCase . __init__ ( self , methodName ) <nl> + dnn_testing_utils . BaseDNNRegressorPredictTest . __init__ ( <nl> + self , _dnn_regressor_fn , is_fc_v2 = True ) <nl> + <nl> + <nl> class DNNRegressorTrainTest ( <nl> dnn_testing_utils . BaseDNNRegressorTrainTest , test . TestCase ) : <nl> <nl> def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> self , _dnn_regressor_fn ) <nl> <nl> <nl> + class DNNRegressorTrainV2Test ( dnn_testing_utils . BaseDNNRegressorTrainTest , <nl> + test . TestCase ) : <nl> + <nl> + def __init__ ( self , methodName = ' runTest ' ) : # pylint : disable = invalid - name <nl> + test . TestCase . __init__ ( self , methodName ) <nl> + dnn_testing_utils . BaseDNNRegressorTrainTest . __init__ ( <nl> + self , _dnn_regressor_fn , is_fc_v2 = True ) <nl> + <nl> + <nl> def _queue_parsed_features ( feature_map ) : <nl> tensors_to_enqueue = [ ] <nl> keys = [ ] <nl> def _queue_parsed_features ( feature_map ) : <nl> return { keys [ i ] : dequeued_tensors [ i ] for i in range ( len ( dequeued_tensors ) ) } <nl> <nl> <nl> - class DNNRegressorIntegrationTest ( test . TestCase ) : <nl> + @ parameterized . parameters ( ( True , ) , ( False , ) ) <nl> + class DNNRegressorIntegrationTest ( test . TestCase , parameterized . TestCase ) : <nl> <nl> def setUp ( self ) : <nl> self . _model_dir = tempfile . mkdtemp ( ) <nl> def tearDown ( self ) : <nl> writer_cache . FileWriterCache . clear ( ) <nl> shutil . rmtree ( self . _model_dir ) <nl> <nl> - def _test_complete_flow ( <nl> - self , train_input_fn , eval_input_fn , predict_input_fn , input_dimension , <nl> - label_dimension , batch_size ) : <nl> + def _test_complete_flow ( self , train_input_fn , eval_input_fn , predict_input_fn , <nl> + input_dimension , label_dimension , batch_size , <nl> + is_fc_v2 ) : <nl> feature_columns = [ <nl> feature_column . numeric_column ( ' x ' , shape = ( input_dimension , ) ) ] <nl> + if is_fc_v2 : <nl> + feature_columns = [ <nl> + feature_column_v2 . numeric_column ( ' x ' , shape = ( input_dimension , ) ) <nl> + ] <nl> + <nl> est = dnn . DNNRegressor ( <nl> hidden_units = ( 2 , 2 ) , <nl> feature_columns = feature_columns , <nl> def _test_complete_flow ( <nl> self . assertAllEqual ( ( batch_size , label_dimension ) , predictions . shape ) <nl> <nl> # EXPORT <nl> - feature_spec = feature_column . make_parse_example_spec ( feature_columns ) <nl> + if is_fc_v2 : <nl> + feature_spec = feature_column_v2 . make_parse_example_spec ( feature_columns ) <nl> + else : <nl> + feature_spec = feature_column . make_parse_example_spec ( feature_columns ) <nl> serving_input_receiver_fn = export . build_parsing_serving_input_receiver_fn ( <nl> feature_spec ) <nl> export_dir = est . export_savedmodel ( tempfile . mkdtemp ( ) , <nl> serving_input_receiver_fn ) <nl> self . assertTrue ( gfile . Exists ( export_dir ) ) <nl> <nl> - def test_numpy_input_fn ( self ) : <nl> + def test_numpy_input_fn ( self , is_fc_v2 ) : <nl> " " " Tests complete flow with numpy_input_fn . " " " <nl> label_dimension = 2 <nl> batch_size = 10 <nl> def test_numpy_input_fn ( self ) : <nl> predict_input_fn = predict_input_fn , <nl> input_dimension = label_dimension , <nl> label_dimension = label_dimension , <nl> - batch_size = batch_size ) <nl> + batch_size = batch_size , <nl> + is_fc_v2 = is_fc_v2 ) <nl> <nl> - def test_pandas_input_fn ( self ) : <nl> + def test_pandas_input_fn ( self , is_fc_v2 ) : <nl> " " " Tests complete flow with pandas_input_fn . " " " <nl> if not HAS_PANDAS : <nl> return <nl> def test_pandas_input_fn ( self ) : <nl> predict_input_fn = predict_input_fn , <nl> input_dimension = label_dimension , <nl> label_dimension = label_dimension , <nl> - batch_size = batch_size ) <nl> + batch_size = batch_size , <nl> + is_fc_v2 = is_fc_v2 ) <nl> <nl> - def test_input_fn_from_parse_example ( self ) : <nl> + def test_input_fn_from_parse_example ( self , is_fc_v2 ) : <nl> " " " Tests complete flow with input_fn constructed from parse_example . " " " <nl> label_dimension = 2 <nl> batch_size = 10 <nl> def _predict_input_fn ( ) : <nl> predict_input_fn = _predict_input_fn , <nl> input_dimension = label_dimension , <nl> label_dimension = label_dimension , <nl> - batch_size = batch_size ) <nl> + batch_size = batch_size , <nl> + is_fc_v2 = is_fc_v2 ) <nl> <nl> <nl> + @ parameterized . parameters ( ( True , ) , ( False , ) ) <nl> class DNNClassifierIntegrationTest ( test . TestCase ) : <nl> <nl> def setUp ( self ) : <nl> def tearDown ( self ) : <nl> def _as_label ( self , data_in_float ) : <nl> return np . rint ( data_in_float ) . astype ( np . int64 ) <nl> <nl> - def _test_complete_flow ( <nl> - self , train_input_fn , eval_input_fn , predict_input_fn , input_dimension , <nl> - n_classes , batch_size ) : <nl> + def _test_complete_flow ( self , train_input_fn , eval_input_fn , predict_input_fn , <nl> + input_dimension , n_classes , batch_size , is_fc_v2 ) : <nl> feature_columns = [ <nl> feature_column . numeric_column ( ' x ' , shape = ( input_dimension , ) ) ] <nl> + if is_fc_v2 : <nl> + feature_columns = [ <nl> + feature_column_v2 . numeric_column ( ' x ' , shape = ( input_dimension , ) ) <nl> + ] <nl> + <nl> est = dnn . DNNClassifier ( <nl> hidden_units = ( 2 , 2 ) , <nl> feature_columns = feature_columns , <nl> def _test_complete_flow ( <nl> self . assertAllEqual ( ( batch_size , n_classes ) , predicted_proba . shape ) <nl> <nl> # EXPORT <nl> - feature_spec = feature_column . make_parse_example_spec ( feature_columns ) <nl> + if is_fc_v2 : <nl> + feature_spec = feature_column_v2 . make_parse_example_spec ( feature_columns ) <nl> + else : <nl> + feature_spec = feature_column . make_parse_example_spec ( feature_columns ) <nl> serving_input_receiver_fn = export . build_parsing_serving_input_receiver_fn ( <nl> feature_spec ) <nl> export_dir = est . export_savedmodel ( tempfile . mkdtemp ( ) , <nl> serving_input_receiver_fn ) <nl> self . assertTrue ( gfile . Exists ( export_dir ) ) <nl> <nl> - def test_numpy_input_fn ( self ) : <nl> + def test_numpy_input_fn ( self , is_fc_v2 ) : <nl> " " " Tests complete flow with numpy_input_fn . " " " <nl> n_classes = 3 <nl> input_dimension = 2 <nl> def test_numpy_input_fn ( self ) : <nl> predict_input_fn = predict_input_fn , <nl> input_dimension = input_dimension , <nl> n_classes = n_classes , <nl> - batch_size = batch_size ) <nl> + batch_size = batch_size , <nl> + is_fc_v2 = is_fc_v2 ) <nl> <nl> - def test_pandas_input_fn ( self ) : <nl> + def test_pandas_input_fn ( self , is_fc_v2 ) : <nl> " " " Tests complete flow with pandas_input_fn . " " " <nl> if not HAS_PANDAS : <nl> return <nl> def test_pandas_input_fn ( self ) : <nl> predict_input_fn = predict_input_fn , <nl> input_dimension = input_dimension , <nl> n_classes = n_classes , <nl> - batch_size = batch_size ) <nl> + batch_size = batch_size , <nl> + is_fc_v2 = is_fc_v2 ) <nl> <nl> - def test_input_fn_from_parse_example ( self ) : <nl> + def test_input_fn_from_parse_example ( self , is_fc_v2 ) : <nl> " " " Tests complete flow with input_fn constructed from parse_example . " " " <nl> input_dimension = 2 <nl> n_classes = 3 <nl> def _predict_input_fn ( ) : <nl> predict_input_fn = _predict_input_fn , <nl> input_dimension = input_dimension , <nl> n_classes = n_classes , <nl> - batch_size = batch_size ) <nl> + batch_size = batch_size , <nl> + is_fc_v2 = is_fc_v2 ) <nl> <nl> <nl> if __name__ = = ' __main__ ' : <nl> mmm a / tensorflow / python / estimator / canned / dnn_testing_utils . py <nl> ppp b / tensorflow / python / estimator / canned / dnn_testing_utils . py <nl> <nl> from tensorflow . python . estimator . canned import prediction_keys <nl> from tensorflow . python . estimator . inputs import numpy_io <nl> from tensorflow . python . feature_column import feature_column <nl> + from tensorflow . python . feature_column import feature_column_v2 <nl> from tensorflow . python . framework import constant_op <nl> from tensorflow . python . framework import dtypes <nl> from tensorflow . python . framework import ops <nl> def create_checkpoint ( weights_and_biases , <nl> weights_and_biases : Iterable of tuples of weight and bias values . <nl> global_step : Initial global step to save in checkpoint . <nl> model_dir : Directory into which checkpoint is saved . <nl> + batch_norm_vars : Variables used for batch normalization . <nl> " " " <nl> weights , biases = zip ( * weights_and_biases ) <nl> if batch_norm_vars : <nl> def _minimize ( loss , global_step = None , var_list = None ) : <nl> class BaseDNNModelFnTest ( object ) : <nl> " " " Tests that _dnn_model_fn passes expected logits to mock head . " " " <nl> <nl> - def __init__ ( self , dnn_model_fn ) : <nl> + def __init__ ( self , dnn_model_fn , is_fc_v2 = False ) : <nl> self . _dnn_model_fn = dnn_model_fn <nl> + self . _is_fc_v2 = is_fc_v2 <nl> <nl> def setUp ( self ) : <nl> self . _model_dir = tempfile . mkdtemp ( ) <nl> def _test_logits ( self , mode , hidden_units , logits_dimension , inputs , <nl> " " " Tests that the expected logits are passed to mock head . " " " <nl> with ops . Graph ( ) . as_default ( ) : <nl> training_util . create_global_step ( ) <nl> + age_column = feature_column . numeric_column ( <nl> + ' age ' , shape = np . array ( inputs ) . shape [ 1 : ] ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( <nl> + ' age ' , shape = np . array ( inputs ) . shape [ 1 : ] ) <nl> head = mock_head ( <nl> self , <nl> hidden_units = hidden_units , <nl> def _test_logits ( self , mode , hidden_units , logits_dimension , inputs , <nl> mode = mode , <nl> head = head , <nl> hidden_units = hidden_units , <nl> - feature_columns = [ <nl> - feature_column . numeric_column ( <nl> - ' age ' , shape = np . array ( inputs ) . shape [ 1 : ] ) <nl> - ] , <nl> + feature_columns = [ age_column ] , <nl> optimizer = mock_optimizer ( self , hidden_units ) ) <nl> with monitored_session . MonitoredTrainingSession ( <nl> checkpoint_dir = self . _model_dir ) as sess : <nl> def test_multi_feature_column_multi_dim_logits ( self ) : <nl> inputs = ( [ [ 10 . ] ] , [ [ 8 . ] ] ) <nl> expected_logits = [ [ - 0 . 48 , 0 . 48 , 0 . 39 ] ] <nl> <nl> + feature_columns = [ <nl> + feature_column . numeric_column ( ' age ' ) , <nl> + feature_column . numeric_column ( ' height ' ) <nl> + ] <nl> + if self . _is_fc_v2 : <nl> + feature_columns = [ <nl> + feature_column_v2 . numeric_column ( ' age ' ) , <nl> + feature_column_v2 . numeric_column ( ' height ' ) <nl> + ] <nl> + <nl> for mode in [ <nl> model_fn . ModeKeys . TRAIN , model_fn . ModeKeys . EVAL , <nl> model_fn . ModeKeys . PREDICT <nl> def test_multi_feature_column_multi_dim_logits ( self ) : <nl> mode = mode , <nl> head = head , <nl> hidden_units = hidden_units , <nl> - feature_columns = [ <nl> - feature_column . numeric_column ( ' age ' ) , <nl> - feature_column . numeric_column ( ' height ' ) <nl> - ] , <nl> + feature_columns = feature_columns , <nl> optimizer = mock_optimizer ( self , hidden_units ) ) <nl> with monitored_session . MonitoredTrainingSession ( <nl> checkpoint_dir = self . _model_dir ) as sess : <nl> def test_features_tensor_raises_value_error ( self ) : <nl> class BaseDNNLogitFnTest ( object ) : <nl> " " " Tests correctness of logits calculated from _dnn_logit_fn_builder . " " " <nl> <nl> - def __init__ ( self , dnn_logit_fn_builder ) : <nl> + def __init__ ( self , dnn_logit_fn_builder , is_fc_v2 = False ) : <nl> self . _dnn_logit_fn_builder = dnn_logit_fn_builder <nl> + self . _is_fc_v2 = is_fc_v2 <nl> <nl> def setUp ( self ) : <nl> self . _model_dir = tempfile . mkdtemp ( ) <nl> def _test_logits ( self , <nl> training_util . create_global_step ( ) <nl> # Use a variable scope here with ' dnn ' , emulating the dnn model_fn , so <nl> # the checkpoint naming is shared . <nl> + age_column = feature_column . numeric_column ( <nl> + ' age ' , shape = np . array ( inputs ) . shape [ 1 : ] ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( <nl> + ' age ' , shape = np . array ( inputs ) . shape [ 1 : ] ) <nl> + <nl> with variable_scope . variable_scope ( ' dnn ' ) : <nl> input_layer_partitioner = ( <nl> partitioned_variables . min_max_variable_partitioner ( <nl> def _test_logits ( self , <nl> logit_fn = self . _dnn_logit_fn_builder ( <nl> units = logits_dimension , <nl> hidden_units = hidden_units , <nl> - feature_columns = [ <nl> - feature_column . numeric_column ( <nl> - ' age ' , shape = np . array ( inputs ) . shape [ 1 : ] ) <nl> - ] , <nl> + feature_columns = [ age_column ] , <nl> activation_fn = nn . relu , <nl> dropout = None , <nl> input_layer_partitioner = input_layer_partitioner , <nl> def test_multi_feature_column_multi_dim_logits ( self ) : <nl> inputs = ( [ [ 10 . ] ] , [ [ 8 . ] ] ) <nl> expected_logits = [ [ - 0 . 48 , 0 . 48 , 0 . 39 ] ] <nl> <nl> + feature_columns = [ <nl> + feature_column . numeric_column ( ' age ' ) , <nl> + feature_column . numeric_column ( ' height ' ) <nl> + ] <nl> + if self . _is_fc_v2 : <nl> + feature_columns = [ <nl> + feature_column_v2 . numeric_column ( ' age ' ) , <nl> + feature_column_v2 . numeric_column ( ' height ' ) <nl> + ] <nl> + <nl> for mode in [ <nl> model_fn . ModeKeys . TRAIN , model_fn . ModeKeys . EVAL , <nl> model_fn . ModeKeys . PREDICT <nl> def test_multi_feature_column_multi_dim_logits ( self ) : <nl> logit_fn = self . _dnn_logit_fn_builder ( <nl> units = logits_dimension , <nl> hidden_units = hidden_units , <nl> - feature_columns = [ <nl> - feature_column . numeric_column ( ' age ' ) , <nl> - feature_column . numeric_column ( ' height ' ) <nl> - ] , <nl> + feature_columns = feature_columns , <nl> activation_fn = nn . relu , <nl> dropout = None , <nl> input_layer_partitioner = input_layer_partitioner , <nl> def test_multi_feature_column_multi_dim_logits ( self ) : <nl> <nl> class BaseDNNWarmStartingTest ( object ) : <nl> <nl> - def __init__ ( self , _dnn_classifier_fn , _dnn_regressor_fn ) : <nl> + def __init__ ( self , _dnn_classifier_fn , _dnn_regressor_fn , is_fc_v2 = False ) : <nl> self . _dnn_classifier_fn = _dnn_classifier_fn <nl> self . _dnn_regressor_fn = _dnn_regressor_fn <nl> + self . _is_fc_v2 = is_fc_v2 <nl> <nl> def setUp ( self ) : <nl> # Create a directory to save our old checkpoint and vocabularies to . <nl> def test_classifier_basic_warm_starting ( self ) : <nl> feature_column . categorical_column_with_vocabulary_list ( <nl> ' city ' , vocabulary_list = [ ' Mountain View ' , ' Palo Alto ' ] ) , <nl> dimension = 5 ) <nl> + if self . _is_fc_v2 : <nl> + city = feature_column_v2 . embedding_column ( <nl> + feature_column_v2 . categorical_column_with_vocabulary_list ( <nl> + ' city ' , vocabulary_list = [ ' Mountain View ' , ' Palo Alto ' ] ) , <nl> + dimension = 5 ) <nl> <nl> # Create a DNNClassifier and train to save a checkpoint . <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> def test_regressor_basic_warm_starting ( self ) : <nl> feature_column . categorical_column_with_vocabulary_list ( <nl> ' city ' , vocabulary_list = [ ' Mountain View ' , ' Palo Alto ' ] ) , <nl> dimension = 5 ) <nl> + if self . _is_fc_v2 : <nl> + city = feature_column_v2 . embedding_column ( <nl> + feature_column_v2 . categorical_column_with_vocabulary_list ( <nl> + ' city ' , vocabulary_list = [ ' Mountain View ' , ' Palo Alto ' ] ) , <nl> + dimension = 5 ) <nl> <nl> # Create a DNNRegressor and train to save a checkpoint . <nl> dnn_regressor = self . _dnn_regressor_fn ( <nl> def test_warm_starting_selective_variables ( self ) : <nl> feature_column . categorical_column_with_vocabulary_list ( <nl> ' city ' , vocabulary_list = [ ' Mountain View ' , ' Palo Alto ' ] ) , <nl> dimension = 5 ) <nl> + if self . _is_fc_v2 : <nl> + city = feature_column_v2 . embedding_column ( <nl> + feature_column_v2 . categorical_column_with_vocabulary_list ( <nl> + ' city ' , vocabulary_list = [ ' Mountain View ' , ' Palo Alto ' ] ) , <nl> + dimension = 5 ) <nl> <nl> # Create a DNNClassifier and train to save a checkpoint . <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> def test_warm_starting_with_vocab_remapping_and_partitioning ( self ) : <nl> vocabulary_file = vocab_file , <nl> vocabulary_size = len ( vocab_list ) ) , <nl> dimension = 2 ) <nl> + if self . _is_fc_v2 : <nl> + occupation = feature_column_v2 . embedding_column ( <nl> + feature_column_v2 . categorical_column_with_vocabulary_file ( <nl> + ' occupation ' , <nl> + vocabulary_file = vocab_file , <nl> + vocabulary_size = len ( vocab_list ) ) , <nl> + dimension = 2 ) <nl> <nl> # Create a DNNClassifier and train to save a checkpoint . <nl> partitioner = partitioned_variables . fixed_size_partitioner ( num_shards = 2 ) <nl> def test_warm_starting_with_vocab_remapping_and_partitioning ( self ) : <nl> vocabulary_file = new_vocab_file , <nl> vocabulary_size = len ( new_vocab_list ) ) , <nl> dimension = 2 ) <nl> + if self . _is_fc_v2 : <nl> + new_occupation = feature_column_v2 . embedding_column ( <nl> + feature_column_v2 . categorical_column_with_vocabulary_file ( <nl> + ' occupation ' , <nl> + vocabulary_file = new_vocab_file , <nl> + vocabulary_size = len ( new_vocab_list ) ) , <nl> + dimension = 2 ) <nl> # We can create our VocabInfo object from the new and old occupation <nl> # FeatureColumn ' s . <nl> occupation_vocab_info = estimator . VocabInfo ( <nl> def test_warm_starting_with_naming_change ( self ) : <nl> feature_column . categorical_column_with_vocabulary_list ( <nl> ' locality ' , vocabulary_list = [ ' Mountain View ' , ' Palo Alto ' ] ) , <nl> dimension = 5 ) <nl> + if self . _is_fc_v2 : <nl> + locality = feature_column_v2 . embedding_column ( <nl> + feature_column_v2 . categorical_column_with_vocabulary_list ( <nl> + ' locality ' , vocabulary_list = [ ' Mountain View ' , ' Palo Alto ' ] ) , <nl> + dimension = 5 ) <nl> <nl> # Create a DNNClassifier and train to save a checkpoint . <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> def test_warm_starting_with_naming_change ( self ) : <nl> feature_column . categorical_column_with_vocabulary_list ( <nl> ' city ' , vocabulary_list = [ ' Mountain View ' , ' Palo Alto ' ] ) , <nl> dimension = 5 ) <nl> + if self . _is_fc_v2 : <nl> + city = feature_column_v2 . embedding_column ( <nl> + feature_column_v2 . categorical_column_with_vocabulary_list ( <nl> + ' city ' , vocabulary_list = [ ' Mountain View ' , ' Palo Alto ' ] ) , <nl> + dimension = 5 ) <nl> warm_started_dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = [ 256 , 128 ] , <nl> feature_columns = [ city ] , <nl> def test_warm_starting_with_naming_change ( self ) : <nl> <nl> class BaseDNNClassifierEvaluateTest ( object ) : <nl> <nl> - def __init__ ( self , dnn_classifier_fn ) : <nl> + def __init__ ( self , dnn_classifier_fn , is_fc_v2 = False ) : <nl> self . _dnn_classifier_fn = dnn_classifier_fn <nl> + self . _is_fc_v2 = is_fc_v2 <nl> <nl> def setUp ( self ) : <nl> self . _model_dir = tempfile . mkdtemp ( ) <nl> def test_one_dim ( self ) : <nl> ( ( [ [ . 6 , . 5 ] ] , [ . 1 , - . 1 ] ) , ( [ [ 1 . , . 8 ] , [ - . 8 , - 1 . ] ] , [ . 2 , - . 2 ] ) , <nl> ( [ [ - 1 . ] , [ 1 . ] ] , [ . 3 ] ) , ) , global_step , self . _model_dir ) <nl> <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> - feature_columns = [ feature_column . numeric_column ( ' age ' ) ] , <nl> + feature_columns = [ age_column ] , <nl> model_dir = self . _model_dir ) <nl> def _input_fn ( ) : <nl> # batch_size = 2 , one false label , and one true . <nl> def test_multi_dim ( self ) : <nl> . 0 ] ) , ) , global_step , self . _model_dir ) <nl> n_classes = 3 <nl> <nl> + age_column = feature_column . numeric_column ( ' age ' , shape = [ 2 ] ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' , shape = [ 2 ] ) <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> - feature_columns = [ feature_column . numeric_column ( ' age ' , shape = [ 2 ] ) ] , <nl> + feature_columns = [ age_column ] , <nl> n_classes = n_classes , <nl> model_dir = self . _model_dir ) <nl> def _input_fn ( ) : <nl> def test_float_labels ( self ) : <nl> ( ( [ [ . 6 , . 5 ] ] , [ . 1 , - . 1 ] ) , ( [ [ 1 . , . 8 ] , [ - . 8 , - 1 . ] ] , [ . 2 , - . 2 ] ) , <nl> ( [ [ - 1 . ] , [ 1 . ] ] , [ . 3 ] ) , ) , global_step , self . _model_dir ) <nl> <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> - feature_columns = [ feature_column . numeric_column ( ' age ' ) ] , <nl> + feature_columns = [ age_column ] , <nl> model_dir = self . _model_dir ) <nl> def _input_fn ( ) : <nl> # batch_size = 2 , one false label , and one true . <nl> def test_multi_dim_weights ( self ) : <nl> global_step , self . _model_dir ) <nl> n_classes = 3 <nl> <nl> + age_column = feature_column . numeric_column ( ' age ' , shape = [ 2 ] ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' , shape = [ 2 ] ) <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> - feature_columns = [ feature_column . numeric_column ( ' age ' , shape = [ 2 ] ) ] , <nl> + feature_columns = [ age_column ] , <nl> n_classes = n_classes , <nl> weight_column = ' w ' , <nl> model_dir = self . _model_dir ) <nl> def _input_fn ( ) : <nl> <nl> class BaseDNNRegressorEvaluateTest ( object ) : <nl> <nl> - def __init__ ( self , dnn_regressor_fn ) : <nl> + def __init__ ( self , dnn_regressor_fn , is_fc_v2 = False ) : <nl> self . _dnn_regressor_fn = dnn_regressor_fn <nl> + self . _is_fc_v2 = is_fc_v2 <nl> <nl> def setUp ( self ) : <nl> self . _model_dir = tempfile . mkdtemp ( ) <nl> def test_one_dim ( self ) : <nl> ( ( [ [ . 6 , . 5 ] ] , [ . 1 , - . 1 ] ) , ( [ [ 1 . , . 8 ] , [ - . 8 , - 1 . ] ] , [ . 2 , - . 2 ] ) , <nl> ( [ [ - 1 . ] , [ 1 . ] ] , [ . 3 ] ) , ) , global_step , self . _model_dir ) <nl> <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> dnn_regressor = self . _dnn_regressor_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> - feature_columns = [ feature_column . numeric_column ( ' age ' ) ] , <nl> + feature_columns = [ age_column ] , <nl> model_dir = self . _model_dir ) <nl> def _input_fn ( ) : <nl> return { ' age ' : [ [ 10 . ] ] } , [ [ 1 . ] ] <nl> def test_multi_dim ( self ) : <nl> . 0 ] ) , ) , global_step , self . _model_dir ) <nl> label_dimension = 3 <nl> <nl> + age_column = feature_column . numeric_column ( ' age ' , shape = [ 2 ] ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' , shape = [ 2 ] ) <nl> dnn_regressor = self . _dnn_regressor_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> - feature_columns = [ feature_column . numeric_column ( ' age ' , shape = [ 2 ] ) ] , <nl> + feature_columns = [ age_column ] , <nl> label_dimension = label_dimension , <nl> model_dir = self . _model_dir ) <nl> def _input_fn ( ) : <nl> def test_multi_dim_weights ( self ) : <nl> global_step , self . _model_dir ) <nl> label_dimension = 3 <nl> <nl> + age_column = feature_column . numeric_column ( ' age ' , shape = [ 2 ] ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' , shape = [ 2 ] ) <nl> dnn_regressor = self . _dnn_regressor_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> - feature_columns = [ feature_column . numeric_column ( ' age ' , shape = [ 2 ] ) ] , <nl> + feature_columns = [ age_column ] , <nl> label_dimension = label_dimension , <nl> weight_column = ' w ' , <nl> model_dir = self . _model_dir ) <nl> def _input_fn ( ) : <nl> <nl> class BaseDNNClassifierPredictTest ( object ) : <nl> <nl> - def __init__ ( self , dnn_classifier_fn ) : <nl> + def __init__ ( self , dnn_classifier_fn , is_fc_v2 = False ) : <nl> self . _dnn_classifier_fn = dnn_classifier_fn <nl> + self . _is_fc_v2 = is_fc_v2 <nl> <nl> def setUp ( self ) : <nl> self . _model_dir = tempfile . mkdtemp ( ) <nl> def _test_one_dim ( self , label_vocabulary , label_output_fn ) : <nl> global_step = 0 , <nl> model_dir = self . _model_dir ) <nl> <nl> + x_column = feature_column . numeric_column ( ' x ' ) <nl> + if self . _is_fc_v2 : <nl> + x_column = feature_column_v2 . numeric_column ( ' x ' ) <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> label_vocabulary = label_vocabulary , <nl> - feature_columns = ( feature_column . numeric_column ( ' x ' ) , ) , <nl> + feature_columns = ( x_column , ) , <nl> model_dir = self . _model_dir ) <nl> input_fn = numpy_io . numpy_input_fn ( <nl> x = { ' x ' : np . array ( [ [ 10 . ] ] ) } , batch_size = 1 , shuffle = False ) <nl> def _test_multi_dim_with_3_classes ( self , label_vocabulary , label_output_fn ) : <nl> global_step = 0 , <nl> model_dir = self . _model_dir ) <nl> <nl> + x_column = feature_column . numeric_column ( ' x ' , shape = ( 2 , ) ) <nl> + if self . _is_fc_v2 : <nl> + x_column = feature_column_v2 . numeric_column ( ' x ' , shape = ( 2 , ) ) <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> - feature_columns = ( feature_column . numeric_column ( ' x ' , shape = ( 2 , ) ) , ) , <nl> + feature_columns = ( x_column , ) , <nl> label_vocabulary = label_vocabulary , <nl> n_classes = 3 , <nl> model_dir = self . _model_dir ) <nl> def test_multi_dim_with_3_classes_and_label_vocab ( self ) : <nl> <nl> class BaseDNNRegressorPredictTest ( object ) : <nl> <nl> - def __init__ ( self , dnn_regressor_fn ) : <nl> + def __init__ ( self , dnn_regressor_fn , is_fc_v2 = False ) : <nl> self . _dnn_regressor_fn = dnn_regressor_fn <nl> + self . _is_fc_v2 = is_fc_v2 <nl> <nl> def setUp ( self ) : <nl> self . _model_dir = tempfile . mkdtemp ( ) <nl> def test_one_dim ( self ) : <nl> global_step = 0 , <nl> model_dir = self . _model_dir ) <nl> <nl> + x_column = feature_column . numeric_column ( ' x ' ) <nl> + if self . _is_fc_v2 : <nl> + x_column = feature_column_v2 . numeric_column ( ' x ' ) <nl> dnn_regressor = self . _dnn_regressor_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> - feature_columns = ( feature_column . numeric_column ( ' x ' ) , ) , <nl> + feature_columns = ( x_column , ) , <nl> model_dir = self . _model_dir ) <nl> input_fn = numpy_io . numpy_input_fn ( <nl> x = { ' x ' : np . array ( [ [ 10 . ] ] ) } , batch_size = 1 , shuffle = False ) <nl> def test_multi_dim ( self ) : <nl> [ . 3 , - . 3 , <nl> . 0 ] ) , ) , 100 , self . _model_dir ) <nl> <nl> + x_column = feature_column . numeric_column ( ' x ' , shape = ( 2 , ) ) <nl> + if self . _is_fc_v2 : <nl> + x_column = feature_column_v2 . numeric_column ( ' x ' , shape = ( 2 , ) ) <nl> dnn_regressor = self . _dnn_regressor_fn ( <nl> hidden_units = ( 2 , 2 ) , <nl> - feature_columns = ( feature_column . numeric_column ( ' x ' , shape = ( 2 , ) ) , ) , <nl> + feature_columns = ( x_column , ) , <nl> label_dimension = 3 , <nl> model_dir = self . _model_dir ) <nl> input_fn = numpy_io . numpy_input_fn ( <nl> def _assert_simple_summary ( testcase , expected_values , actual_summary ) : <nl> <nl> class BaseDNNClassifierTrainTest ( object ) : <nl> <nl> - def __init__ ( self , dnn_classifier_fn ) : <nl> + def __init__ ( self , dnn_classifier_fn , is_fc_v2 = False ) : <nl> self . _dnn_classifier_fn = dnn_classifier_fn <nl> + self . _is_fc_v2 = is_fc_v2 <nl> <nl> def setUp ( self ) : <nl> self . _model_dir = tempfile . mkdtemp ( ) <nl> def tearDown ( self ) : <nl> shutil . rmtree ( self . _model_dir ) <nl> <nl> def test_from_scratch_with_default_optimizer_binary ( self ) : <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> hidden_units = ( 2 , 2 ) <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = hidden_units , <nl> - feature_columns = ( feature_column . numeric_column ( ' age ' ) , ) , <nl> + feature_columns = ( age_column , ) , <nl> model_dir = self . _model_dir ) <nl> <nl> # Train for a few steps , then validate final checkpoint . <nl> def test_from_scratch_with_default_optimizer_binary ( self ) : <nl> output_units = 1 , model_dir = self . _model_dir ) <nl> <nl> def test_from_scratch_with_default_optimizer_multi_class ( self ) : <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> hidden_units = ( 2 , 2 ) <nl> n_classes = 3 <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = hidden_units , <nl> - feature_columns = ( feature_column . numeric_column ( ' age ' ) , ) , <nl> + feature_columns = ( age_column , ) , <nl> n_classes = n_classes , <nl> model_dir = self . _model_dir ) <nl> <nl> def test_from_scratch_with_default_optimizer_multi_class ( self ) : <nl> output_units = n_classes , model_dir = self . _model_dir ) <nl> <nl> def test_from_scratch_validate_summary ( self ) : <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> hidden_units = ( 2 , 2 ) <nl> opt = mock_optimizer ( <nl> self , hidden_units = hidden_units ) <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = hidden_units , <nl> - feature_columns = ( feature_column . numeric_column ( ' age ' ) , ) , <nl> + feature_columns = ( age_column , ) , <nl> optimizer = opt , <nl> model_dir = self . _model_dir ) <nl> self . assertEqual ( 0 , opt . minimize . call_count ) <nl> def test_from_scratch_validate_summary ( self ) : <nl> self . assertIn ( metric_keys . MetricKeys . LOSS_MEAN , summary_keys ) <nl> <nl> def test_binary_classification ( self ) : <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> base_global_step = 100 <nl> hidden_units = ( 2 , 2 ) <nl> create_checkpoint ( <nl> def test_binary_classification ( self ) : <nl> self , hidden_units = hidden_units , expected_loss = expected_loss ) <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = hidden_units , <nl> - feature_columns = ( feature_column . numeric_column ( ' age ' ) , ) , <nl> + feature_columns = ( age_column , ) , <nl> optimizer = opt , <nl> model_dir = self . _model_dir ) <nl> self . assertEqual ( 0 , opt . minimize . call_count ) <nl> def test_binary_classification ( self ) : <nl> hidden_units = hidden_units , output_units = 1 , model_dir = self . _model_dir ) <nl> <nl> def test_binary_classification_float_labels ( self ) : <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> base_global_step = 100 <nl> hidden_units = ( 2 , 2 ) <nl> create_checkpoint ( <nl> def test_binary_classification_float_labels ( self ) : <nl> self , hidden_units = hidden_units , expected_loss = expected_loss ) <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> hidden_units = hidden_units , <nl> - feature_columns = ( feature_column . numeric_column ( ' age ' ) , ) , <nl> + feature_columns = ( age_column , ) , <nl> optimizer = opt , <nl> model_dir = self . _model_dir ) <nl> self . assertEqual ( 0 , opt . minimize . call_count ) <nl> def test_binary_classification_float_labels ( self ) : <nl> self . assertEqual ( 1 , opt . minimize . call_count ) <nl> <nl> def test_multi_class ( self ) : <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> n_classes = 3 <nl> base_global_step = 100 <nl> hidden_units = ( 2 , 2 ) <nl> def test_multi_class ( self ) : <nl> dnn_classifier = self . _dnn_classifier_fn ( <nl> n_classes = n_classes , <nl> hidden_units = hidden_units , <nl> - feature_columns = ( feature_column . numeric_column ( ' age ' ) , ) , <nl> + feature_columns = ( age_column , ) , <nl> optimizer = opt , <nl> model_dir = self . _model_dir ) <nl> self . assertEqual ( 0 , opt . minimize . call_count ) <nl> def test_multi_class ( self ) : <nl> <nl> class BaseDNNRegressorTrainTest ( object ) : <nl> <nl> - def __init__ ( self , dnn_regressor_fn ) : <nl> + def __init__ ( self , dnn_regressor_fn , is_fc_v2 = False ) : <nl> self . _dnn_regressor_fn = dnn_regressor_fn <nl> + self . _is_fc_v2 = is_fc_v2 <nl> <nl> def setUp ( self ) : <nl> self . _model_dir = tempfile . mkdtemp ( ) <nl> def tearDown ( self ) : <nl> shutil . rmtree ( self . _model_dir ) <nl> <nl> def test_from_scratch_with_default_optimizer ( self ) : <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> hidden_units = ( 2 , 2 ) <nl> dnn_regressor = self . _dnn_regressor_fn ( <nl> hidden_units = hidden_units , <nl> - feature_columns = ( feature_column . numeric_column ( ' age ' ) , ) , <nl> + feature_columns = ( age_column , ) , <nl> model_dir = self . _model_dir ) <nl> <nl> # Train for a few steps , then validate final checkpoint . <nl> def test_from_scratch_with_default_optimizer ( self ) : <nl> output_units = 1 , model_dir = self . _model_dir ) <nl> <nl> def test_from_scratch ( self ) : <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> hidden_units = ( 2 , 2 ) <nl> opt = mock_optimizer ( self , hidden_units = hidden_units ) <nl> dnn_regressor = self . _dnn_regressor_fn ( <nl> hidden_units = hidden_units , <nl> - feature_columns = ( feature_column . numeric_column ( ' age ' ) , ) , <nl> + feature_columns = ( age_column , ) , <nl> optimizer = opt , <nl> model_dir = self . _model_dir ) <nl> self . assertEqual ( 0 , opt . minimize . call_count ) <nl> def test_from_scratch ( self ) : <nl> <nl> def test_one_dim ( self ) : <nl> " " " Asserts train loss for one - dimensional input and logits . " " " <nl> + age_column = feature_column . numeric_column ( ' age ' ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( ' age ' ) <nl> base_global_step = 100 <nl> hidden_units = ( 2 , 2 ) <nl> create_checkpoint ( <nl> def test_one_dim ( self ) : <nl> self , hidden_units = hidden_units , expected_loss = expected_loss ) <nl> dnn_regressor = self . _dnn_regressor_fn ( <nl> hidden_units = hidden_units , <nl> - feature_columns = ( feature_column . numeric_column ( ' age ' ) , ) , <nl> + feature_columns = ( age_column , ) , <nl> optimizer = opt , <nl> model_dir = self . _model_dir ) <nl> self . assertEqual ( 0 , opt . minimize . call_count ) <nl> def test_multi_dim ( self ) : <nl> # See that test for calculation of logits . <nl> # logits = [ [ - 0 . 48 , 0 . 48 , 0 . 39 ] ] <nl> # loss = ( 1 + 0 . 48 ) ^ 2 + ( - 1 - 0 . 48 ) ^ 2 + ( 0 . 5 - 0 . 39 ) ^ 2 = 4 . 3929 <nl> + age_column = feature_column . numeric_column ( ' age ' , shape = [ input_dimension ] ) <nl> + if self . _is_fc_v2 : <nl> + age_column = feature_column_v2 . numeric_column ( <nl> + ' age ' , shape = [ input_dimension ] ) <nl> + <nl> expected_loss = 4 . 3929 <nl> opt = mock_optimizer ( <nl> self , hidden_units = hidden_units , expected_loss = expected_loss ) <nl> dnn_regressor = self . _dnn_regressor_fn ( <nl> hidden_units = hidden_units , <nl> - feature_columns = [ <nl> - feature_column . numeric_column ( ' age ' , shape = [ input_dimension ] ) ] , <nl> + feature_columns = [ age_column ] , <nl> label_dimension = label_dimension , <nl> optimizer = opt , <nl> model_dir = self . _model_dir ) <nl> mmm a / tensorflow / python / feature_column / feature_column . py <nl> ppp b / tensorflow / python / feature_column / feature_column . py <nl> def __init__ ( self , <nl> feature_columns , <nl> weight_collections = None , <nl> trainable = True , <nl> - cols_to_vars = None ) : <nl> + cols_to_vars = None , <nl> + name = ' feature_column_input_layer ' ) : <nl> " " " See ` input_layer ` . " " " <nl> <nl> self . _feature_columns = feature_columns <nl> self . _weight_collections = weight_collections <nl> self . _trainable = trainable <nl> self . _cols_to_vars = cols_to_vars <nl> + self . _name = name <nl> self . _input_layer_template = template . make_template ( <nl> - ' feature_column_input_layer ' , <nl> - _internal_input_layer , <nl> - create_scope_now_ = True ) <nl> + self . _name , _internal_input_layer , create_scope_now_ = True ) <nl> self . _scope = self . _input_layer_template . variable_scope <nl> <nl> def __call__ ( self , features ) : <nl> def __call__ ( self , features ) : <nl> cols_to_vars = None , <nl> scope = self . _scope ) <nl> <nl> + @ property <nl> + def name ( self ) : <nl> + return self . _name <nl> + <nl> @ property <nl> def non_trainable_variables ( self ) : <nl> return self . _input_layer_template . non_trainable_variables <nl> mmm a / tensorflow / python / feature_column / feature_column_v2 . py <nl> ppp b / tensorflow / python / feature_column / feature_column_v2 . py <nl> def input_layer ( features , feature_columns , . . . ) : <nl> pass <nl> <nl> <nl> + def is_feature_column_v2 ( feature_columns ) : <nl> + " " " Returns True if all feature columns are V2 . " " " <nl> + for feature_column in feature_columns : <nl> + if not isinstance ( feature_column , FeatureColumn ) : <nl> + return False <nl> + return True <nl> + <nl> + <nl> def _create_weighted_sum ( column , <nl> transformation_cache , <nl> state_manager , <nl> def get_variable ( self , feature_column , name ) : <nl> return self . _var_dict [ name ] <nl> <nl> <nl> + def maybe_create_shared_state_manager ( feature_columns ) : <nl> + if is_feature_column_v2 ( feature_columns ) : <nl> + return SharedEmbeddingStateManager ( ) <nl> + return None <nl> + <nl> + <nl> class SharedEmbeddingColumn ( <nl> DenseColumn , SequenceDenseColumn , <nl> collections . namedtuple ( <nl>
Getting DNNModel to work with the new feature columns .
tensorflow/tensorflow
9fe177881224571aff0c267593f747f5fd7a2967
2018-09-19T02:43:44Z
mmm a / xbmc / video / VideoInfoScanner . cpp <nl> ppp b / xbmc / video / VideoInfoScanner . cpp <nl> namespace VIDEO <nl> CStdString name = URIUtils : : GetFileName ( items [ i ] - > GetPath ( ) ) ; <nl> URIUtils : : RemoveExtension ( name ) ; <nl> if ( name = = " season - all " ) <nl> - art . insert ( make_pair ( - 1 , items [ i ] - > GetPath ( ) ) ) ; <nl> + art [ - 1 ] = items [ i ] - > GetPath ( ) ; <nl> else if ( name = = " season - specials " ) <nl> - art . insert ( make_pair ( 0 , items [ i ] - > GetPath ( ) ) ) ; <nl> + art [ 0 ] = items [ i ] - > GetPath ( ) ; <nl> else if ( reg . RegFind ( name ) > - 1 ) <nl> { <nl> char * seasonStr = reg . GetReplaceString ( " \ \ 1 " ) ; <nl> int season = atoi ( seasonStr ) ; <nl> free ( seasonStr ) ; <nl> <nl> - art . insert ( make_pair ( season , items [ i ] - > GetPath ( ) ) ) ; <nl> + art [ season ] = items [ i ] - > GetPath ( ) ; <nl> } <nl> } <nl> } <nl>
local season art was not correctly overriding the scraper art . Takes care of part of
xbmc/xbmc
70205b08fcae1fffbcb28d6eaa9c189262ea087e
2012-10-11T08:36:46Z
mmm a / tensorflow / compiler / xla / service / BUILD <nl> ppp b / tensorflow / compiler / xla / service / BUILD <nl> load ( <nl> " tf_proto_library_py " , <nl> ) <nl> load ( " / / tensorflow : tensorflow . bzl " , " tf_cc_test " ) <nl> + load ( <nl> + " / / tensorflow / core / platform : default / cuda_build_defs . bzl " , <nl> + " if_cuda_is_configured " , <nl> + ) <nl> + load ( <nl> + " @ local_config_rocm / / rocm : build_defs . bzl " , <nl> + " if_rocm_is_configured " , <nl> + ) <nl> <nl> package ( <nl> default_visibility = [ " : friends " ] , <nl> cc_library ( <nl> name = " gpu_plugin " , <nl> deps = [ <nl> " : service " , <nl> + " / / tensorflow / compiler / xla / service / gpu : gpu_compiler " , <nl> " / / tensorflow / compiler / xla / service / gpu : gpu_transfer_manager " , <nl> - " / / tensorflow / compiler / xla / service / gpu : nvptx_compiler " , <nl> " / / tensorflow / core : stream_executor_no_cuda " , <nl> + ] + if_cuda_is_configured ( [ <nl> " / / tensorflow / core / platform / default / build_config : stream_executor_cuda " , <nl> - ] , <nl> + ] ) + if_rocm_is_configured ( [ <nl> + " / / tensorflow / core / platform / default / build_config : stream_executor_rocm " , <nl> + ] ) , <nl> ) <nl> <nl> cc_library ( <nl> mmm a / tensorflow / compiler / xla / service / gpu / BUILD <nl> ppp b / tensorflow / compiler / xla / service / gpu / BUILD <nl> load ( <nl> " / / tensorflow / core / platform : default / build_config_root . bzl " , <nl> " tf_cuda_tests_tags " , <nl> ) <nl> - load ( " / / tensorflow : tensorflow . bzl " , " tf_cc_test " , " tf_copts " , " tf_cuda_library " ) <nl> + load ( <nl> + " / / tensorflow : tensorflow . bzl " , <nl> + " tf_cc_test " , <nl> + " tf_copts " , <nl> + " tf_cuda_library " , <nl> + ) <nl> load ( " @ local_config_cuda / / cuda : build_defs . bzl " , " if_cuda " ) <nl> + load ( <nl> + " / / tensorflow / core / platform : default / cuda_build_defs . bzl " , <nl> + " if_cuda_is_configured " , <nl> + ) <nl> + load ( <nl> + " @ local_config_rocm / / rocm : build_defs . bzl " , <nl> + " if_rocm_is_configured " , <nl> + ) <nl> <nl> package ( <nl> default_visibility = [ " : friends " ] , <nl> tf_cc_test ( <nl> cc_library ( <nl> name = " gpu_executable " , <nl> srcs = [ <nl> - " cholesky_thunk . cc " , <nl> " collective_permute_thunk . cc " , <nl> " conditional_thunk . cc " , <nl> " convolution_thunk . cc " , <nl> cc_library ( <nl> " triangular_solve_thunk . cc " , <nl> " tuple_thunk . cc " , <nl> " while_thunk . cc " , <nl> - ] , <nl> + ] + if_cuda_is_configured ( [ <nl> + " cholesky_thunk . cc " , <nl> + ] ) , <nl> hdrs = [ <nl> - " cholesky_thunk . h " , <nl> " collective_permute_thunk . h " , <nl> " conditional_thunk . h " , <nl> " convolution_thunk . h " , <nl> cc_library ( <nl> " triangular_solve_thunk . h " , <nl> " tuple_thunk . h " , <nl> " while_thunk . h " , <nl> - ] , <nl> + ] + if_cuda_is_configured ( [ <nl> + " cholesky_thunk . h " , <nl> + ] ) , <nl> deps = [ <nl> " : backend_configs " , <nl> " : buffer_allocations " , <nl> " : cudnn_conv_runner " , <nl> - " : cusolver_context " , <nl> " : gpu_debug_info_manager " , <nl> " : gpu_types " , <nl> " : hlo_execution_profiler " , <nl> cc_library ( <nl> " / / tensorflow / core : lib " , <nl> " / / tensorflow / core : lib_internal " , <nl> " / / tensorflow / core : stream_executor_no_cuda " , <nl> - " / / tensorflow / core / platform / default / build_config : cublas_plugin " , <nl> - " / / tensorflow / core / platform / default / build_config : cudnn_plugin " , <nl> - " / / tensorflow / core / platform / default / build_config : cufft_plugin " , <nl> - " / / tensorflow / core / platform / default / build_config : stream_executor_cuda " , # build_cleaner : keep <nl> " / / tensorflow / core / profiler / lib : traceme " , <nl> " / / tensorflow / stream_executor " , <nl> " / / tensorflow / stream_executor : blas " , <nl> " / / tensorflow / stream_executor : device_memory " , <nl> " / / tensorflow / stream_executor : device_memory_allocator " , <nl> " / / tensorflow / stream_executor : kernel " , <nl> - " / / tensorflow / stream_executor / cuda : cuda_stream " , <nl> " / / tensorflow / stream_executor / gpu : gpu_stream " , <nl> " @ com_google_absl / / absl / algorithm : container " , <nl> " @ com_google_absl / / absl / base : core_headers " , <nl> cc_library ( <nl> " @ com_google_absl / / absl / strings : str_format " , <nl> " @ com_google_absl / / absl / types : optional " , <nl> " @ com_google_absl / / absl / types : span " , <nl> + ] + if_cuda_is_configured ( [ <nl> + " : cusolver_context " , <nl> + " / / tensorflow / stream_executor / cuda : cuda_stream " , <nl> + " / / tensorflow / core / platform / default / build_config : cublas_plugin " , <nl> + " / / tensorflow / core / platform / default / build_config : cudnn_plugin " , <nl> + " / / tensorflow / core / platform / default / build_config : cufft_plugin " , <nl> + " / / tensorflow / core / platform / default / build_config : stream_executor_cuda " , # build_cleaner : keep <nl> " @ local_config_cuda / / cuda : cuda_headers " , <nl> - ] , <nl> + ] ) + if_rocm_is_configured ( [ <nl> + " / / tensorflow / core / platform / default / build_config : stream_executor_rocm " , <nl> + " @ local_config_rocm / / rocm : rocm_headers " , <nl> + ] ) , <nl> ) <nl> <nl> cc_library ( <nl> cc_library ( <nl> ) <nl> <nl> cc_library ( <nl> - name = " nvptx_compiler_impl " , <nl> - srcs = [ " nvptx_compiler . cc " ] , <nl> - hdrs = [ " nvptx_compiler . h " ] , <nl> + name = " gpu_compiler " , <nl> + deps = if_cuda_is_configured ( [ <nl> + " : nvptx_compiler " , <nl> + ] ) + if_rocm_is_configured ( [ <nl> + " : amdgpu_compiler " , <nl> + ] ) , <nl> + alwayslink = True , # Contains compiler registration <nl> + ) <nl> + <nl> + cc_library ( <nl> + name = " gpu_compiler_impl " , <nl> + srcs = [ <nl> + " gpu_compiler . cc " , <nl> + ] , <nl> + hdrs = [ <nl> + " gpu_compiler . h " , <nl> + ] , <nl> deps = [ <nl> " : cudnn_batchnorm_rewriter " , <nl> " : cudnn_conv_algorithm_picker " , <nl> - " : cudnn_conv_pad_for_tensor_cores " , <nl> " : cudnn_conv_padding_legalization " , <nl> " : cudnn_conv_rewriter " , <nl> - " : cudnn_fused_conv_rewriter " , <nl> - " : cusolver_rewriter " , <nl> " : fusion_merger " , <nl> - " : gemm_algorithm_picker " , <nl> - " : gemm_rewriter " , <nl> " : gpu_constants " , <nl> " : gpu_copy_insertion " , <nl> " : gpu_executable " , <nl> cc_library ( <nl> " / / tensorflow / compiler / xla / service : zero_sized_hlo_elimination " , <nl> " / / tensorflow / compiler / xla / service / gpu / llvm_gpu_backend " , <nl> " / / tensorflow / compiler / xla / service / llvm_ir : llvm_util " , <nl> - " / / tensorflow / core : cuda_libdevice_path " , <nl> " / / tensorflow / core : lib " , <nl> " / / tensorflow / core : lib_internal " , <nl> " / / tensorflow / core : regexp_internal " , <nl> " / / tensorflow / core : stream_executor_no_cuda " , <nl> " / / tensorflow / core / profiler / lib : traceme " , <nl> " / / tensorflow / stream_executor : stream_executor_headers " , <nl> - " / / tensorflow / stream_executor / cuda : cuda_diagnostics " , <nl> - " / / tensorflow / stream_executor / cuda : ptxas_utils " , <nl> " @ com_google_absl / / absl / container : node_hash_map " , <nl> " @ com_google_absl / / absl / memory " , <nl> " @ com_google_absl / / absl / strings " , <nl> cc_library ( <nl> <nl> cc_library ( <nl> name = " nvptx_compiler " , <nl> - srcs = [ " nvptx_compiler_registration . cc " ] , <nl> - deps = [ " : nvptx_compiler_impl " ] , <nl> + srcs = if_cuda_is_configured ( [ <nl> + " nvptx_compiler_registration . cc " , <nl> + ] ) , <nl> + deps = if_cuda_is_configured ( [ <nl> + " nvptx_compiler_impl " , <nl> + ] ) , <nl> alwayslink = True , # Contains compiler registration <nl> ) <nl> <nl> + cc_library ( <nl> + name = " nvptx_compiler_impl " , <nl> + srcs = if_cuda_is_configured ( [ <nl> + " nvptx_compiler . cc " , <nl> + ] ) , <nl> + hdrs = if_cuda_is_configured ( [ <nl> + " nvptx_compiler . h " , <nl> + ] ) , <nl> + deps = [ <nl> + " @ com_google_absl / / absl / memory " , <nl> + " @ com_google_absl / / absl / container : node_hash_map " , <nl> + " @ com_google_absl / / absl / strings " , <nl> + " @ com_google_absl / / absl / types : optional " , <nl> + " @ com_google_absl / / absl / types : span " , <nl> + " @ llvm / / : core " , <nl> + " / / tensorflow / compiler / xla : protobuf_util " , <nl> + " / / tensorflow / compiler / xla : status_macros " , <nl> + " / / tensorflow / compiler / xla : statusor " , <nl> + " / / tensorflow / compiler / xla : types " , <nl> + " / / tensorflow / compiler / xla : util " , <nl> + " / / tensorflow / compiler / xla / service : algebraic_simplifier " , <nl> + " / / tensorflow / compiler / xla / service : batchnorm_expander " , <nl> + " / / tensorflow / compiler / xla / service : buffer_assignment " , <nl> + " / / tensorflow / compiler / xla / service : call_inliner " , <nl> + " / / tensorflow / compiler / xla / service : conditional_simplifier " , <nl> + " / / tensorflow / compiler / xla / service : convolution_group_converter " , <nl> + " / / tensorflow / compiler / xla / service : dot_decomposer " , <nl> + " / / tensorflow / compiler / xla / service : dump " , <nl> + " / / tensorflow / compiler / xla / service : dynamic_index_splitter " , <nl> + " / / tensorflow / compiler / xla / service : executable " , <nl> + " / / tensorflow / compiler / xla / service : flatten_call_graph " , <nl> + " / / tensorflow / compiler / xla / service : hlo " , <nl> + " / / tensorflow / compiler / xla / service : hlo_constant_folding " , <nl> + " / / tensorflow / compiler / xla / service : hlo_cse " , <nl> + " / / tensorflow / compiler / xla / service : hlo_dataflow_analysis " , <nl> + " / / tensorflow / compiler / xla / service : hlo_dce " , <nl> + " / / tensorflow / compiler / xla / service : hlo_element_type_converter " , <nl> + " / / tensorflow / compiler / xla / service : hlo_get_dimension_size_rewriter " , <nl> + " / / tensorflow / compiler / xla / service : hlo_pass " , <nl> + " / / tensorflow / compiler / xla / service : hlo_pass_pipeline " , <nl> + " / / tensorflow / compiler / xla / service : hlo_proto " , <nl> + " / / tensorflow / compiler / xla / service : hlo_proto_util " , <nl> + " / / tensorflow / compiler / xla / service : hlo_subcomputation_unification " , <nl> + " / / tensorflow / compiler / xla / service : hlo_verifier " , <nl> + " / / tensorflow / compiler / xla / service : llvm_compiler " , <nl> + " / / tensorflow / compiler / xla / service : mem_wasted_on_passthrough_params " , <nl> + " / / tensorflow / compiler / xla / service : reduce_precision_insertion " , <nl> + " / / tensorflow / compiler / xla / service : reshape_mover " , <nl> + " / / tensorflow / compiler / xla / service : rng_expander " , <nl> + " / / tensorflow / compiler / xla / service : slice_sinker " , <nl> + " / / tensorflow / compiler / xla / service : slow_operation_alarm " , <nl> + " / / tensorflow / compiler / xla / service : sort_simplifier " , <nl> + " / / tensorflow / compiler / xla / service : stable_sort_expander " , <nl> + " / / tensorflow / compiler / xla / service : transpose_folding " , <nl> + " / / tensorflow / compiler / xla / service : tuple_simplifier " , <nl> + " / / tensorflow / compiler / xla / service : while_loop_constant_sinking " , <nl> + " / / tensorflow / compiler / xla / service : while_loop_simplifier " , <nl> + " / / tensorflow / compiler / xla / service : while_loop_trip_count_annotator " , <nl> + " / / tensorflow / compiler / xla / service : zero_sized_hlo_elimination " , <nl> + " / / tensorflow / compiler / xla / service / gpu / llvm_gpu_backend " , <nl> + " / / tensorflow / compiler / xla / service / llvm_ir : llvm_util " , <nl> + " / / tensorflow / core : lib " , <nl> + " / / tensorflow / core : lib_internal " , <nl> + " / / tensorflow / core : regexp_internal " , <nl> + " / / tensorflow / core : stream_executor_no_cuda " , <nl> + " / / tensorflow / core / profiler / lib : traceme " , <nl> + " / / tensorflow / stream_executor : stream_executor_headers " , <nl> + ] + if_cuda_is_configured ( [ <nl> + " : cudnn_batchnorm_rewriter " , <nl> + " : cudnn_conv_algorithm_picker " , <nl> + " : cudnn_conv_padding_legalization " , <nl> + " : cudnn_conv_rewriter " , <nl> + " : cudnn_conv_pad_for_tensor_cores " , <nl> + " : cudnn_fused_conv_rewriter " , <nl> + " : cusolver_rewriter " , <nl> + " : fusion_merger " , <nl> + " : gemm_algorithm_picker " , <nl> + " : gemm_rewriter " , <nl> + " : gpu_compiler_impl " , <nl> + " : gpu_constants " , <nl> + " : gpu_copy_insertion " , <nl> + " : gpu_executable " , <nl> + " : gpu_hlo_schedule " , <nl> + " : gpu_hlo_support_checker " , <nl> + " : gpu_layout_assignment " , <nl> + " : gpu_sanitize_constant_names " , <nl> + " : gpu_scatter_expander " , <nl> + " : instruction_fusion " , <nl> + " : ir_emitter " , <nl> + " : ir_emission_utils " , <nl> + " : multi_output_fusion " , <nl> + " : partition_assignment " , <nl> + " : stream_assignment " , <nl> + " : stream_executor_util " , <nl> + " : target_constants " , <nl> + " / / tensorflow / core : cuda_libdevice_path " , <nl> + " / / tensorflow / stream_executor / cuda : cuda_diagnostics " , <nl> + " / / tensorflow / stream_executor / cuda : ptxas_utils " , <nl> + ] ) , <nl> + ) <nl> + <nl> + cc_library ( <nl> + name = " amdgpu_compiler " , <nl> + srcs = if_rocm_is_configured ( [ <nl> + " amdgpu_compiler_registration . cc " , <nl> + ] ) , <nl> + deps = if_rocm_is_configured ( [ <nl> + " amdgpu_compiler_impl " , <nl> + ] ) , <nl> + alwayslink = True , # Contains compiler registration <nl> + ) <nl> + <nl> + cc_library ( <nl> + name = " amdgpu_compiler_impl " , <nl> + srcs = if_rocm_is_configured ( [ <nl> + # TODO ( whchung @ gmail . com ) : enable in the subsequent PR . <nl> + # " amdgpu_compiler . cc " , <nl> + ] ) , <nl> + hdrs = if_rocm_is_configured ( [ <nl> + # TODO ( whchung @ gmail . com ) : enable in the subsequent PR . <nl> + # " amdgpu_compiler . h " <nl> + ] ) , <nl> + deps = if_rocm_is_configured ( [ <nl> + # TODO ( whchung @ gmail . com ) : Enable these after pending PRs get merged . <nl> + # " : gpu_compiler_impl " , <nl> + # " : miopen_conv_algorithm_picker " , <nl> + # " / / tensorflow / core : rocm_rocdl_path " , <nl> + ] ) , <nl> + ) <nl> + <nl> cc_library ( <nl> name = " cudnn_batchnorm_rewriter " , <nl> srcs = [ " cudnn_batchnorm_rewriter . cc " ] , <nl> new file mode 100644 <nl> index 0000000000000 . . bcf3c54c4f016 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / xla / service / gpu / gpu_compiler . cc <nl> <nl> + / * Copyright 2017 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 / xla / service / gpu / gpu_compiler . h " <nl> + <nl> + # include < stdlib . h > <nl> + <nl> + # include < atomic > <nl> + # include < functional > <nl> + # include < mutex > / / NOLINT ( build / c + + 11 ) : only using std : : call_once , not mutex . <nl> + # include < utility > <nl> + <nl> + # include " absl / memory / memory . h " <nl> + # include " absl / strings / numbers . h " <nl> + # include " absl / strings / str_cat . h " <nl> + # include " llvm / IR / DiagnosticInfo . h " <nl> + # include " llvm / IR / DiagnosticPrinter . h " <nl> + # include " llvm / IR / LLVMContext . h " <nl> + # include " llvm / IR / Module . h " <nl> + # include " llvm / IR / Verifier . h " <nl> + # include " tensorflow / compiler / xla / protobuf_util . h " <nl> + # include " tensorflow / compiler / xla / service / algebraic_simplifier . h " <nl> + # include " tensorflow / compiler / xla / service / batchnorm_expander . h " <nl> + # include " tensorflow / compiler / xla / service / buffer_assignment . h " <nl> + # include " tensorflow / compiler / xla / service / call_inliner . h " <nl> + # include " tensorflow / compiler / xla / service / conditional_simplifier . h " <nl> + # include " tensorflow / compiler / xla / service / convolution_group_converter . h " <nl> + # include " tensorflow / compiler / xla / service / dot_decomposer . h " <nl> + # include " tensorflow / compiler / xla / service / dump . h " <nl> + # include " tensorflow / compiler / xla / service / dynamic_index_splitter . h " <nl> + # include " tensorflow / compiler / xla / service / flatten_call_graph . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / cudnn_batchnorm_rewriter . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / fusion_merger . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_constants . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_copy_insertion . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_executable . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_hlo_schedule . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_hlo_support_checker . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_layout_assignment . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_sanitize_constant_names . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_scatter_expander . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / instruction_fusion . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / ir_emission_utils . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / ir_emitter_context . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / ir_emitter_unnested . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / llvm_gpu_backend / gpu_backend_lib . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / multi_output_fusion . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / partition_assignment . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / stream_assignment . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / stream_executor_util . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / target_constants . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / thunk_schedule . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / variadic_op_splitter . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_computation . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_constant_folding . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_cse . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_dataflow_analysis . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_dce . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_element_type_converter . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_get_dimension_size_rewriter . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_instruction . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_pass_fix . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_pass_pipeline . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_proto_util . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_subcomputation_unification . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_verifier . h " <nl> + # include " tensorflow / compiler / xla / service / llvm_ir / llvm_util . h " <nl> + # include " tensorflow / compiler / xla / service / mem_wasted_on_passthrough_params . h " <nl> + # include " tensorflow / compiler / xla / service / reduce_precision_insertion . h " <nl> + # include " tensorflow / compiler / xla / service / reshape_mover . h " <nl> + # include " tensorflow / compiler / xla / service / rng_expander . h " <nl> + # include " tensorflow / compiler / xla / service / slice_sinker . h " <nl> + # include " tensorflow / compiler / xla / service / slow_operation_alarm . h " <nl> + # include " tensorflow / compiler / xla / service / sort_simplifier . h " <nl> + # include " tensorflow / compiler / xla / service / stable_sort_expander . h " <nl> + # include " tensorflow / compiler / xla / service / transpose_folding . h " <nl> + # include " tensorflow / compiler / xla / service / tuple_simplifier . h " <nl> + # include " tensorflow / compiler / xla / service / while_loop_constant_sinking . h " <nl> + # include " tensorflow / compiler / xla / service / while_loop_simplifier . h " <nl> + # include " tensorflow / compiler / xla / service / while_loop_trip_count_annotator . h " <nl> + # include " tensorflow / compiler / xla / service / zero_sized_hlo_elimination . h " <nl> + # include " tensorflow / compiler / xla / status_macros . h " <nl> + # include " tensorflow / compiler / xla / types . h " <nl> + # include " tensorflow / compiler / xla / util . h " <nl> + # include " tensorflow / core / lib / core / status . h " <nl> + # include " tensorflow / core / lib / gtl / cleanup . h " <nl> + # include " tensorflow / core / lib / io / path . h " <nl> + # include " tensorflow / core / platform / env . h " <nl> + # include " tensorflow / core / platform / logging . h " <nl> + # include " tensorflow / core / platform / regexp . h " <nl> + # include " tensorflow / core / platform / stream_executor_no_cuda . h " <nl> + # include " tensorflow / core / platform / subprocess . h " <nl> + # include " tensorflow / core / platform / tracing . h " <nl> + # include " tensorflow / core / profiler / lib / traceme . h " <nl> + <nl> + namespace xla { <nl> + namespace gpu { <nl> + <nl> + GpuCompiler : : GpuCompiler ( se : : Platform : : Id platform_id , <nl> + const char * target_triple , const char * data_layout ) <nl> + : platform_id_ ( platform_id ) , <nl> + target_triple_ ( target_triple ) , <nl> + data_layout_ ( data_layout ) , <nl> + pointer_size_ ( llvm : : DataLayout ( data_layout ) <nl> + . getPointerSize ( 0 / * default address space * / ) ) { } <nl> + <nl> + / / Runs optimization passes on the given HLO module . <nl> + Status GpuCompiler : : OptimizeHloModule ( <nl> + HloModule * hlo_module , se : : StreamExecutor * stream_exec , <nl> + se : : DeviceMemoryAllocator * device_allocator ) { <nl> + { <nl> + HloPassPipeline pipeline ( " optimization " ) ; <nl> + pipeline . AddInvariantChecker < HloVerifier > ( / * layout_sensitive = * / false , <nl> + / * allow_mixed_precision = * / false ) ; <nl> + <nl> + / / Expand random number generation . <nl> + pipeline . AddPass < RngExpander > ( ) ; <nl> + <nl> + / / Remove zero - sized HLO from the input so that other passes don ' t have to <nl> + / / handle it . <nl> + pipeline . AddPass < ZeroSizedHloElimination > ( ) ; <nl> + <nl> + pipeline . AddPass < GpuScatterExpander > ( ) ; <nl> + <nl> + pipeline . AddPass < DynamicIndexSplitter > ( ) ; <nl> + pipeline . AddPass < GpuHloSupportChecker > ( ) ; <nl> + ReducePrecisionInsertion : : AddPasses ( <nl> + & pipeline , hlo_module - > config ( ) . debug_options ( ) , <nl> + ReducePrecisionInsertion : : PassTiming : : BEFORE_OPTIMIZATION ) ; <nl> + <nl> + / / TODO ( b / 64094172 ) : make Call work on GPU instead of inlining . <nl> + pipeline . AddPass < CallInliner > ( ) ; <nl> + auto cost_model = [ ] ( HloInstruction * conv ) { <nl> + / / We need a cost model for GPUs . Currently , do nothing . <nl> + return false ; <nl> + } ; <nl> + pipeline . AddPass < DotDecomposer > ( ) ; <nl> + pipeline . AddPass < ConvolutionGroupConverter > ( <nl> + cost_model , <nl> + / * convert_batch_groups_only = * / true ) ; <nl> + / / Expand the sort op to support stable sorting if required . <nl> + pipeline . AddPass < StableSortExpander > ( ) ; <nl> + / / Convert BF16 operations to F32 operations so that the GPU backend can <nl> + / / support BF16 operations without directly implementing a BF16 lowering for <nl> + / / most ops . <nl> + pipeline . AddPass < HloElementTypeConverter > ( BF16 , F32 ) ; <nl> + <nl> + { <nl> + auto & pass = <nl> + pipeline . AddPass < HloPassFix < HloPassPipeline > > ( " simplification " ) ; <nl> + pass . AddInvariantChecker < HloVerifier > ( / * layout_sensitive = * / false , <nl> + / * allow_mixed_precision = * / false ) ; <nl> + <nl> + / / If cudnn batchnorms are enabled , rewrite batchnorm HLOs to cudnn calls <nl> + / / where possible . Not every batchnorm op can be implemented as a call to <nl> + / / cudnn , so decompose any remaining batchnorm ops into a soup of HLOs . <nl> + if ( hlo_module - > config ( ) . debug_options ( ) . xla_gpu_use_cudnn_batchnorm ( ) ) { <nl> + pass . AddPass < CudnnBatchNormRewriter > ( ) ; <nl> + } <nl> + pass . AddPass < BatchNormExpander > ( <nl> + / * rewrite_training_op = * / true , <nl> + / * rewrite_inference_op = * / true , <nl> + / * rewrite_grad_op = * / true ) ; <nl> + <nl> + pipeline . AddPass < HloGetDimensionSizeRewriter > ( ) ; <nl> + <nl> + / / BatchNormExpander can create zero - sized ops , so zero - sized HLO <nl> + / / elimination has to come after that pass . <nl> + pipeline . AddPass < ZeroSizedHloElimination > ( ) ; <nl> + <nl> + AlgebraicSimplifierOptions options ; <nl> + pass . AddPass < AlgebraicSimplifier > ( options ) ; <nl> + pass . AddPass < SortSimplifier > ( ) ; <nl> + pass . AddPass < TupleSimplifier > ( ) ; <nl> + pass . AddPass < WhileLoopConstantSinking > ( ) ; <nl> + pass . AddPass < WhileLoopSimplifier > ( ) ; <nl> + <nl> + / / TODO ( b / 134075051 ) : Re - enable after b / 134075051 is fixed . <nl> + / / pass . AddPass < SliceSinker > ( ) ; <nl> + <nl> + pass . AddPass < HloDCE > ( ) ; <nl> + pass . AddPass < ReshapeMover > ( ) ; <nl> + pass . AddPass < HloConstantFolding > ( ) ; <nl> + pass . AddPass < ConditionalSimplifier > ( ) ; <nl> + } <nl> + <nl> + pipeline . AddPass < TransposeFolding > ( <nl> + [ ] ( const HloInstruction & dot , <nl> + const TransposeFolding : : OperandIndices & candidate_operands ) { <nl> + return IsMatrixMultiplication ( dot ) <nl> + ? candidate_operands <nl> + : TransposeFolding : : OperandIndices { } ; <nl> + } , <nl> + TransposeFolding : : NeverFoldTranspose ) ; <nl> + pipeline . AddPass < HloCSE > ( / * is_layout_sensitive = * / false ) ; <nl> + pipeline . AddPass < HloDCE > ( ) ; <nl> + <nl> + / / Run WhileLoopTripCountAnnotator at the end of the simplification <nl> + / / pipeline , before layout assignment and fusion . This pass does some <nl> + / / pattern - matching on while bodies / conditions , and this is where the HLO is <nl> + / / " nicest " . <nl> + / / <nl> + / / It ' s important that we don ' t make semantic changes ( e . g . unrolling ) to <nl> + / / any ` while ` loops after this point , because otherwise the trip - count <nl> + / / annotations added by this pass may not be correct after the <nl> + / / modifications . <nl> + pipeline . AddPass < WhileLoopTripCountAnnotator > ( ) ; <nl> + TF_RETURN_IF_ERROR ( pipeline . Run ( hlo_module ) . status ( ) ) ; <nl> + } <nl> + <nl> + / / Run target - specific HLO optimization passes for convolution <nl> + / / canonicalization . <nl> + TF_RETURN_IF_ERROR ( OptimizeHloConvolutionCanonicalization ( <nl> + hlo_module , stream_exec , device_allocator ) ) ; <nl> + <nl> + { <nl> + / / Run layout assignment in a separate pipeline from <nl> + / / " post - layout - assignment " because we want everything after layout <nl> + / / assignment to have a layout - sensitive invariant - checker , but <nl> + / / HloPassPipeline also runs its invariant checker before any passes are <nl> + / / run , meaning , the pipeline that contains layout assignment cannot contain <nl> + / / a layout - sensitive verifier ! <nl> + HloPassPipeline pipeline ( " layout assignment " ) ; <nl> + pipeline . AddPass < GpuLayoutAssignment > ( <nl> + hlo_module - > mutable_entry_computation_layout ( ) , <nl> + LayoutAssignment : : InstructionCanChangeLayout , stream_exec ) ; <nl> + TF_RETURN_IF_ERROR ( pipeline . Run ( hlo_module ) . status ( ) ) ; <nl> + } <nl> + <nl> + / / Run target - specific HLO optimization passes after layout assignment . <nl> + TF_RETURN_IF_ERROR ( OptimizeHloPostLayoutAssignment ( hlo_module , stream_exec , <nl> + device_allocator ) ) ; <nl> + <nl> + { <nl> + HloPassFix < HloPassPipeline > fusion ( " fusion " ) ; <nl> + / / We try to split variadic ops with many parameters into several such ops <nl> + / / to avoid exceeding the parameter space . <nl> + fusion . AddPass < VariadicOpSplitter > ( ) ; <nl> + / * TODO ( b / 117531509 ) : Use LayoutAssignment : : InstructionCanChangeLayout after <nl> + * fixing the ticket . * / <nl> + fusion . AddInvariantChecker < HloVerifier > ( <nl> + / * layout_sensitive = * / true , <nl> + / * allow_mixed_precision = * / false , <nl> + LayoutAssignment : : InstructionCanChangeLayout ) ; <nl> + fusion . AddPass < GpuInstructionFusion > ( / * may_duplicate = * / false ) ; <nl> + fusion . AddPass < GpuInstructionFusion > ( / * may_duplicate = * / true ) ; <nl> + fusion . AddPass < FusionMerger > ( ) ; <nl> + fusion . AddPass < GpuMultiOutputFusion > ( ) ; <nl> + fusion . AddPass < HloCSE > ( / * is_layout_sensitive = * / true , <nl> + / * only_fusion_computations = * / true ) ; <nl> + fusion . AddPass < HloDCE > ( ) ; <nl> + TF_RETURN_IF_ERROR ( fusion . Run ( hlo_module ) . status ( ) ) ; <nl> + <nl> + HloPassPipeline reduce_pipeline ( " reduce - precision " ) ; <nl> + / * TODO ( b / 117531509 ) : Use LayoutAssignment : : InstructionCanChangeLayout after <nl> + * fixing the ticket . * / <nl> + reduce_pipeline . AddInvariantChecker < HloVerifier > ( <nl> + / * is_layout_sensitive = * / true , / * allow_mixed_precision = * / false , <nl> + LayoutAssignment : : InstructionCanChangeLayout ) ; <nl> + ReducePrecisionInsertion : : AddPasses ( <nl> + & reduce_pipeline , hlo_module - > config ( ) . debug_options ( ) , <nl> + ReducePrecisionInsertion : : PassTiming : : AFTER_FUSION ) ; <nl> + StatusOr < bool > reduce_result = reduce_pipeline . Run ( hlo_module ) ; <nl> + TF_RETURN_IF_ERROR ( reduce_result . status ( ) ) ; <nl> + <nl> + if ( reduce_result . ValueOrDie ( ) ) { <nl> + / / Do another fusion pass , with the expectation that we may be able to <nl> + / / fuse the new ReducePrecision operations . <nl> + TF_RETURN_IF_ERROR ( fusion . Run ( hlo_module ) . status ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + / / Modifies the given HLO module so that it will be accepted by IrEmitter . <nl> + / / Unlike optimization passes , the passes are necessary for correctness . <nl> + Status GpuCompiler : : PrepareHloModuleForIrEmitting ( HloModule * hlo_module ) { <nl> + / / In some cases , we have to place the result of an instruction in a temporary <nl> + / / buffer . For instance , the buffer that holds an external parameter is <nl> + / / assumed immutable at this point , and should not be reused for output <nl> + / / ( b / 27180329 ) . Therefore , in that case , we set the output to be a copy of <nl> + / / the parameter . <nl> + HloPassPipeline pipeline ( " GPU - ir - emit - prepare " ) ; <nl> + / * TODO ( b / 117531509 ) : Use LayoutAssignment : : InstructionCanChangeLayout after <nl> + * fixing the ticket . * / <nl> + pipeline . AddInvariantChecker < HloVerifier > ( <nl> + / * layout_sensitive = * / true , <nl> + / * allow_mixed_precision = * / false , <nl> + LayoutAssignment : : InstructionCanChangeLayout ) ; <nl> + <nl> + / / Copy insertion should be performed immediately before IR emission to avoid <nl> + / / inserting unnecessary copies ( later pass adds an instruction which <nl> + / / materializes the value ) or missing a necessary copy ( later pass removes an <nl> + / / instruction which materializes a value ) . DCE must be run immediately before <nl> + / / ( and sometime after ) copy insertion , to avoid dead code from interfering <nl> + / / with the rewrites . <nl> + pipeline . AddPass < HloDCE > ( ) ; <nl> + pipeline . AddPass < FlattenCallGraph > ( ) ; <nl> + / / The following pass LOGs memory waste . Add it when VLOGing is enabled only . <nl> + if ( VLOG_IS_ON ( 2 ) ) { <nl> + pipeline . AddPass < MemWastedOnPassthroughParams > ( ) ; <nl> + } <nl> + pipeline . AddPass < GpuCopyInsertion > ( GetCanShareBuffer ( ) ) ; <nl> + pipeline . AddPass < GpuSanitizeConstantNames > ( ) ; <nl> + return pipeline . Run ( hlo_module ) . status ( ) ; <nl> + } <nl> + <nl> + StatusOr < std : : unique_ptr < HloModule > > GpuCompiler : : RunHloPasses ( <nl> + std : : unique_ptr < HloModule > module , se : : StreamExecutor * stream_exec , <nl> + se : : DeviceMemoryAllocator * device_allocator ) { <nl> + / / We dump the post - optimization HLO in RunBackend so no need to dump it here . <nl> + XLA_SCOPED_LOGGING_TIMER ( " GpuCompiler : : RunHloPasses " ) ; <nl> + tensorflow : : profiler : : TraceMe activity ( <nl> + [ & ] { return absl : : StrCat ( " HLO Transforms : " , module - > name ( ) ) ; } , <nl> + tensorflow : : profiler : : TraceMeLevel : : kInfo ) ; <nl> + TF_RETURN_IF_ERROR ( <nl> + OptimizeHloModule ( module . get ( ) , stream_exec , device_allocator ) ) ; <nl> + <nl> + TF_RETURN_IF_ERROR ( PrepareHloModuleForIrEmitting ( module . get ( ) ) ) ; <nl> + <nl> + return std : : move ( module ) ; <nl> + } <nl> + <nl> + StatusOr < std : : unique_ptr < Executable > > GpuCompiler : : RunBackend ( <nl> + std : : unique_ptr < HloModule > module , se : : StreamExecutor * stream_exec , <nl> + se : : DeviceMemoryAllocator * device_allocator ) { <nl> + XLA_SCOPED_LOGGING_TIMER ( " GpuCompiler : : RunBackend " ) ; <nl> + auto slow_compile_alarm = SlowCompilationAlarm ( ) ; <nl> + <nl> + TF_RET_CHECK ( stream_exec ! = nullptr ) ; <nl> + <nl> + llvm : : LLVMContext llvm_context ; <nl> + std : : string buffer ; <nl> + llvm : : raw_string_ostream error ( buffer ) ; <nl> + llvm : : DiagnosticPrinterRawOStream printer ( error ) ; <nl> + auto DiagnosticHandler = [ ] ( const llvm : : DiagnosticInfo & diag_info , <nl> + void * Context ) { <nl> + auto printer = static_cast < llvm : : DiagnosticPrinterRawOStream * > ( Context ) ; <nl> + diag_info . print ( * printer ) ; <nl> + } ; <nl> + llvm_context . setDiagnosticHandlerCallBack ( DiagnosticHandler , & printer ) ; <nl> + <nl> + llvm : : Module llvm_module ( module - > name ( ) . c_str ( ) , llvm_context ) ; <nl> + / / Set the target triple and the data layout . <nl> + llvm_module . setTargetTriple ( target_triple_ ) ; <nl> + llvm_module . setDataLayout ( data_layout_ ) ; <nl> + <nl> + / / Determine the HLO schedule , which is an ordering of HLO instructions . This <nl> + / / is used by buffer assignment to enable buffer reuse , and the same ordering <nl> + / / must also be used to determine the thunk launch schedule . <nl> + std : : unique_ptr < StreamAssignment > stream_assignment = AssignStreams ( * module ) ; <nl> + TF_ASSIGN_OR_RETURN ( <nl> + std : : unique_ptr < GpuHloSchedule > hlo_schedule , <nl> + GpuHloSchedule : : Build ( * module , * stream_assignment , pointer_size_ ) ) ; <nl> + <nl> + / / Run buffer analysis on the HLO graph . This analysis figures out which <nl> + / / temporary buffers are required to run the computation . <nl> + TF_ASSIGN_OR_RETURN ( <nl> + std : : unique_ptr < BufferAssignment > buffer_assignment , <nl> + BufferAssigner : : Run ( <nl> + module . get ( ) , hlo_schedule - > ConsumeHloOrdering ( ) , <nl> + BufferSizeBytesFunction ( ) , <nl> + / * color_alignment = * / <nl> + [ ] ( LogicalBuffer : : Color ) { return kXlaAllocatedBufferAlignBytes ; } , <nl> + / * allocate_buffers_for_constants = * / true , <nl> + / * colorer = * / BufferAssigner : : DefaultColorer ( ) , <nl> + / * must_not_live_out = * / { } , GetCanShareBuffer ( ) ) ) ; <nl> + DumpHloModuleIfEnabled ( * module , * buffer_assignment , " after_optimizations " ) ; <nl> + <nl> + IrEmitterContext ir_emitter_context ( <nl> + module . get ( ) , buffer_assignment . get ( ) , stream_exec - > platform ( ) , <nl> + & stream_exec - > GetDeviceDescription ( ) , & llvm_module ) ; <nl> + <nl> + HloComputation * entry_computation = module - > entry_computation ( ) ; <nl> + IrEmitterUnnested ir_emitter ( module - > config ( ) , entry_computation , <nl> + & ir_emitter_context ) ; <nl> + <nl> + TF_RETURN_IF_ERROR ( ir_emitter . EmitConstantGlobals ( ) ) ; <nl> + <nl> + { <nl> + XLA_SCOPED_LOGGING_TIMER ( " GpuCompiler : : RunBackend - IR emission " ) ; <nl> + TF_RETURN_IF_ERROR ( entry_computation - > Accept ( & ir_emitter ) ) ; <nl> + } <nl> + <nl> + if ( user_pre_optimization_hook_ ) { <nl> + user_pre_optimization_hook_ ( llvm_module ) ; <nl> + } <nl> + string ir_module_string_before_opt ; <nl> + const bool embed_ir_in_executable = <nl> + module - > config ( ) . debug_options ( ) . xla_embed_ir_in_executable ( ) ; <nl> + if ( embed_ir_in_executable ) { <nl> + ir_module_string_before_opt = llvm_ir : : DumpModuleToString ( llvm_module ) ; <nl> + } <nl> + <nl> + llvm_ir : : DumpIrIfEnabled ( * module , llvm_module , / * optimized = * / false ) ; <nl> + <nl> + { <nl> + XLA_SCOPED_LOGGING_TIMER ( " GpuCompiler : : RunBackend - Running LLVM verifier " ) ; <nl> + <nl> + std : : string err ; <nl> + llvm : : raw_string_ostream err_stream ( err ) ; <nl> + <nl> + / / verifyModule ( ) returns true if the module is broken . <nl> + TF_RET_CHECK ( ! llvm : : verifyModule ( llvm_module , & err_stream ) ) <nl> + < < " Invalid LLVM IR before optimizations : \ n " <nl> + < < err_stream . str ( ) <nl> + < < " \ nThis probably indicates a bug in the HLO - > LLVM IR lowering . " <nl> + " Rerun with - - xla_dump_to to get the IR . " ; <nl> + } <nl> + <nl> + GpuVersion gpu_version = GetGpuVersion ( stream_exec ) ; <nl> + <nl> + using BackendCompileResult = std : : pair < std : : string , std : : vector < uint8 > > ; <nl> + TF_ASSIGN_OR_RETURN ( BackendCompileResult backend_result , <nl> + CompileTargetBinary ( module . get ( ) , & llvm_module , <nl> + gpu_version , stream_exec ) ) ; <nl> + <nl> + auto thunk_schedule = absl : : make_unique < ThunkSchedule > ( <nl> + ir_emitter . ConsumeThunkSequence ( ) , std : : move ( stream_assignment ) , <nl> + hlo_schedule - > ThunkLaunchOrder ( ) ) ; <nl> + if ( DumpingEnabledForHloModule ( * module ) ) { <nl> + DumpToFileInDirOrStdout ( * module , " thunk_schedule " , <nl> + thunk_schedule - > ToString ( ) ) ; <nl> + } <nl> + <nl> + std : : unique_ptr < HloProfileIndexMap > profile_index_map ; <nl> + std : : unique_ptr < HloProfilePrinterData > profile_printer ; <nl> + <nl> + if ( module - > config ( ) . hlo_profiling_enabled ( ) | | VLOG_IS_ON ( 1 ) ) { <nl> + HloCostAnalysis cost_analysis ( ShapeSizeBytesFunction ( ) ) ; <nl> + cost_analysis . set_bytes_per_second ( <nl> + stream_exec - > GetDeviceDescription ( ) . memory_bandwidth ( ) ) ; <nl> + TF_RETURN_IF_ERROR ( module - > entry_computation ( ) - > Accept ( & cost_analysis ) ) ; <nl> + VLOG ( 1 ) < < " HLO memory read + written : " <nl> + < < tensorflow : : strings : : HumanReadableNumBytes ( <nl> + cost_analysis . bytes_accessed ( ) ) ; <nl> + if ( module - > config ( ) . hlo_profiling_enabled ( ) ) { <nl> + profile_index_map = absl : : make_unique < HloProfileIndexMap > ( * module ) ; <nl> + profile_printer = CreateHloProfilePrinterData ( <nl> + * profile_index_map , cost_analysis , entry_computation - > name ( ) ) ; <nl> + } <nl> + } <nl> + <nl> + auto * gpu_executable = new GpuExecutable ( <nl> + backend_result . first , backend_result . second , gpu_version , <nl> + std : : move ( thunk_schedule ) , std : : move ( module ) , <nl> + std : : move ( buffer_assignment ) , std : : move ( profile_printer ) , <nl> + std : : move ( profile_index_map ) ) ; <nl> + if ( embed_ir_in_executable ) { <nl> + DCHECK_NE ( " " , ir_module_string_before_opt ) ; <nl> + gpu_executable - > set_ir_module_string ( ir_module_string_before_opt ) ; <nl> + } <nl> + return std : : unique_ptr < Executable > ( gpu_executable ) ; <nl> + } <nl> + <nl> + StatusOr < std : : vector < std : : unique_ptr < AotCompilationResult > > > <nl> + GpuCompiler : : CompileAheadOfTime ( std : : unique_ptr < HloModuleGroup > module_group , <nl> + const AotCompilationOptions & options ) { <nl> + return Unimplemented ( " not yet implemented : GpuCompiler : : CompileAheadOfTime " ) ; <nl> + } <nl> + <nl> + } / / namespace gpu <nl> + } / / namespace xla <nl> new file mode 100644 <nl> index 0000000000000 . . 901d994d4ad80 <nl> mmm / dev / null <nl> ppp b / tensorflow / compiler / xla / service / gpu / gpu_compiler . h <nl> <nl> + / * Copyright 2017 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_XLA_SERVICE_GPU_GPU_COMPILER_H_ <nl> + # define TENSORFLOW_COMPILER_XLA_SERVICE_GPU_GPU_COMPILER_H_ <nl> + <nl> + # include < memory > <nl> + # include < string > <nl> + # include < vector > <nl> + <nl> + # include " tensorflow / compiler / xla / service / executable . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_executable . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_dataflow_analysis . h " <nl> + # include " tensorflow / compiler / xla / service / hlo_module . h " <nl> + # include " tensorflow / compiler / xla / service / llvm_compiler . h " <nl> + # include " tensorflow / compiler / xla / statusor . h " <nl> + # include " tensorflow / compiler / xla / types . h " <nl> + # include " tensorflow / core / lib / hash / hash . h " <nl> + # include " tensorflow / core / platform / macros . h " <nl> + # include " tensorflow / core / platform / stream_executor_no_cuda . h " <nl> + # include " tensorflow / core / platform / thread_annotations . h " <nl> + # include " tensorflow / stream_executor / stream_executor_pimpl . h " <nl> + <nl> + namespace xla { <nl> + namespace gpu { <nl> + <nl> + / / The GPU compiler generates efficient GPU executables . <nl> + class GpuCompiler : public LLVMCompiler { <nl> + public : <nl> + GpuCompiler ( se : : Platform : : Id platform_id , const char * target_triple , <nl> + const char * data_layout ) ; <nl> + ~ GpuCompiler ( ) override { } <nl> + <nl> + / / Bring in <nl> + / / StatusOr < std : : vector < std : : unique_ptr < Executable > > > Compile ( <nl> + / / std : : vector < std : : unique_ptr < HloModule > > modules , <nl> + / / std : : vector < std : : vector < se : : StreamExecutor * > > <nl> + / / stream_execs ) <nl> + using LLVMCompiler : : Compile ; <nl> + <nl> + StatusOr < std : : unique_ptr < HloModule > > RunHloPasses ( <nl> + std : : unique_ptr < HloModule > module , se : : StreamExecutor * stream_exec , <nl> + se : : DeviceMemoryAllocator * device_allocator ) override ; <nl> + <nl> + Status OptimizeHloModule ( HloModule * hlo_module , <nl> + se : : StreamExecutor * stream_exec , <nl> + se : : DeviceMemoryAllocator * device_allocator ) ; <nl> + <nl> + virtual Status OptimizeHloConvolutionCanonicalization ( <nl> + HloModule * hlo_module , se : : StreamExecutor * stream_exec , <nl> + se : : DeviceMemoryAllocator * device_allocator ) = 0 ; <nl> + <nl> + virtual Status OptimizeHloPostLayoutAssignment ( <nl> + HloModule * hlo_module , se : : StreamExecutor * stream_exec , <nl> + se : : DeviceMemoryAllocator * device_allocator ) = 0 ; <nl> + <nl> + virtual HloDataflowAnalysis : : CanShareBuffer GetCanShareBuffer ( ) { <nl> + return <nl> + [ ] ( const HloInstruction * , const HloInstruction * , <nl> + const ShapeIndex & ) - > absl : : optional < bool > { return absl : : nullopt ; } ; <nl> + } <nl> + <nl> + virtual GpuVersion GetGpuVersion ( se : : StreamExecutor * stream_exec ) = 0 ; <nl> + <nl> + virtual StatusOr < std : : pair < std : : string , std : : vector < uint8 > > > <nl> + CompileTargetBinary ( const HloModule * hlo_module , llvm : : Module * llvm_module , <nl> + GpuVersion gpu_version , <nl> + se : : StreamExecutor * stream_exec ) = 0 ; <nl> + <nl> + Status PrepareHloModuleForIrEmitting ( HloModule * hlo_module ) ; <nl> + <nl> + StatusOr < std : : unique_ptr < Executable > > RunBackend ( <nl> + std : : unique_ptr < HloModule > module , se : : StreamExecutor * stream_exec , <nl> + se : : DeviceMemoryAllocator * device_allocator ) override ; <nl> + <nl> + StatusOr < std : : vector < std : : unique_ptr < AotCompilationResult > > > <nl> + CompileAheadOfTime ( std : : unique_ptr < HloModuleGroup > module_group , <nl> + AotCompilationOptions const & options ) override ; <nl> + <nl> + se : : Platform : : Id PlatformId ( ) const override { return platform_id_ ; } <nl> + <nl> + HloCostAnalysis : : ShapeSizeFunction ShapeSizeBytesFunction ( ) const override { <nl> + / / Capture just the pointer size , not the entire GpuCompiler object . <nl> + int64 pointer_size = pointer_size_ ; <nl> + return [ pointer_size ] ( const Shape & shape ) { <nl> + return ShapeUtil : : ByteSizeOf ( shape , pointer_size ) ; <nl> + } ; <nl> + } <nl> + <nl> + private : <nl> + se : : Platform : : Id platform_id_ ; <nl> + <nl> + / / The triple that represents our target . <nl> + const char * target_triple_ ; <nl> + <nl> + / / The data layout of the emitted module . <nl> + const char * data_layout_ ; <nl> + <nl> + / / The size in bytes of a pointer . Used by ShapeSizeBytesFunction . <nl> + const int64 pointer_size_ ; <nl> + <nl> + TF_DISALLOW_COPY_AND_ASSIGN ( GpuCompiler ) ; <nl> + } ; <nl> + <nl> + } / / namespace gpu <nl> + } / / namespace xla <nl> + <nl> + # endif / / TENSORFLOW_COMPILER_XLA_SERVICE_GPU_GPU_COMPILER_H_ <nl> mmm a / tensorflow / compiler / xla / service / gpu / nvptx_compiler . cc <nl> ppp b / tensorflow / compiler / xla / service / gpu / nvptx_compiler . cc <nl> limitations under the License . <nl> # include " tensorflow / compiler / xla / service / gpu / fusion_merger . h " <nl> # include " tensorflow / compiler / xla / service / gpu / gemm_algorithm_picker . h " <nl> # include " tensorflow / compiler / xla / service / gpu / gemm_rewriter . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_compiler . h " <nl> # include " tensorflow / compiler / xla / service / gpu / gpu_constants . h " <nl> # include " tensorflow / compiler / xla / service / gpu / gpu_copy_insertion . h " <nl> # include " tensorflow / compiler / xla / service / gpu / gpu_executable . h " <nl> limitations under the License . <nl> # include " tensorflow / compiler / xla / service / gpu / stream_executor_util . h " <nl> # include " tensorflow / compiler / xla / service / gpu / target_constants . h " <nl> # include " tensorflow / compiler / xla / service / gpu / thunk_schedule . h " <nl> - # include " tensorflow / compiler / xla / service / gpu / variadic_op_splitter . h " <nl> # include " tensorflow / compiler / xla / service / hlo . pb . h " <nl> # include " tensorflow / compiler / xla / service / hlo_computation . h " <nl> # include " tensorflow / compiler / xla / service / hlo_constant_folding . h " <nl> limitations under the License . <nl> # include " tensorflow / compiler / xla / service / reshape_mover . h " <nl> # include " tensorflow / compiler / xla / service / rng_expander . h " <nl> # include " tensorflow / compiler / xla / service / slice_sinker . h " <nl> - # include " tensorflow / compiler / xla / service / slow_operation_alarm . h " <nl> # include " tensorflow / compiler / xla / service / sort_simplifier . h " <nl> # include " tensorflow / compiler / xla / service / stable_sort_expander . h " <nl> # include " tensorflow / compiler / xla / service / transpose_folding . h " <nl> string GetLibdeviceDir ( const HloModuleConfig & hlo_module_config ) { <nl> return " . " ; <nl> } <nl> <nl> + } / / namespace <nl> + <nl> + Status NVPTXCompiler : : OptimizeHloConvolutionCanonicalization ( <nl> + HloModule * hlo_module , se : : StreamExecutor * stream_exec , <nl> + se : : DeviceMemoryAllocator * device_allocator ) { <nl> + / / Convert convolutions into CustomCalls to cudnn , then canonicalize them <nl> + / / ( CudnnConvPaddingLegalization ) . Also expand cuSolver calls . <nl> + HloPassPipeline pipeline ( " conv_canonicalization " ) ; <nl> + pipeline . AddInvariantChecker < HloVerifier > ( / * layout_sensitive = * / false , <nl> + / * allow_mixed_precision = * / false ) ; <nl> + pipeline . AddPass < CusolverRewriter > ( ) ; <nl> + pipeline . AddPass < CudnnConvRewriter > ( ) ; <nl> + pipeline . AddPass < CudnnFusedConvRewriter > ( ) ; <nl> + pipeline . AddPass < CudnnConvPaddingLegalization > ( ) ; <nl> + if ( IsVoltaOrLater ( * stream_exec ) ) { <nl> + pipeline . AddPass < CudnnConvPadForTensorCores > ( ) ; <nl> + / / CudnnConvPadForTensorCores leaves behind unnecessary <nl> + / / tuple / get - tuple - element pairs that TupleSimplifier fixes . <nl> + pipeline . AddPass < TupleSimplifier > ( ) ; <nl> + } <nl> + / / CudnnConvRewriter , CudnnConvPaddingLegalization and <nl> + / / CudnnConvPadForTensorCores may add instructions which can be simplified <nl> + / / by constant folding . <nl> + pipeline . AddPass < HloConstantFolding > ( ) ; <nl> + TF_RETURN_IF_ERROR ( pipeline . Run ( hlo_module ) . status ( ) ) ; <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + Status NVPTXCompiler : : OptimizeHloPostLayoutAssignment ( <nl> + HloModule * hlo_module , se : : StreamExecutor * stream_exec , <nl> + se : : DeviceMemoryAllocator * device_allocator ) { <nl> + HloPassPipeline pipeline ( " post - layout_assignment " ) ; <nl> + / * TODO ( b / 117531509 ) : Use LayoutAssignment : : InstructionCanChangeLayout after <nl> + * fixing the ticket . * / <nl> + pipeline . AddInvariantChecker < HloVerifier > ( <nl> + / * layout_sensitive = * / true , <nl> + / * allow_mixed_precision = * / false , <nl> + LayoutAssignment : : InstructionCanChangeLayout ) ; <nl> + <nl> + / / The LayoutAssignment pass may leave behind kCopy instructions which are <nl> + / / duplicate or NOPs , so remove them with algebraic simplification and CSE . <nl> + AlgebraicSimplifierOptions options ; <nl> + options . set_is_layout_sensitive ( true ) ; <nl> + pipeline . AddPass < HloPassFix < AlgebraicSimplifier > > ( options ) ; <nl> + <nl> + / / Rewrite GEMMs into custom calls . <nl> + pipeline . AddPass < GemmRewriter > ( ) ; <nl> + <nl> + / / Choose the fastest algorithm for each conv . <nl> + / / <nl> + / / We pick the algorithm before fusion so we can generate better HLO . After <nl> + / / CudnnConvRewriter , our convolutions are CustomCalls which return a <nl> + / / tuple ( conv_result , scratch_memory ) , and the each conv uses 0 bytes of <nl> + / / scratch : <nl> + / / <nl> + / / customcall = ( f32 [ . . . ] , f32 [ 0 ] ) <nl> + / / return gte ( customcall , 0 ) <nl> + / / <nl> + / / The algorithm picker then chooses the best algorithm , and potentially <nl> + / / increases the scratch space . It replaces customcall with new_tuple , <nl> + / / giving us the following : <nl> + / / <nl> + / / new_customcall = ( f32 [ . . . ] , f32 [ N ] ) <nl> + / / new_tuple = tuple ( gte ( new_customcall , 0 ) , constant f32 [ 0 ] ) <nl> + / / return gte ( new_tuple , 0 ) <nl> + / / <nl> + / / The new tuple and gte instructions then be simplified away , because <nl> + / / nobody is expected to use the scratch value . <nl> + / / <nl> + / / However , if we were to run CudnnConvAlgorithmPicker after fusion <nl> + / / the gte ( customcall , 0 ) would probably already be into a fusion node . We <nl> + / / can ' t simplify across HloComputation boundaries , so in this case we <nl> + / / wouldn ' t be able to simplify away the new_tuple bits . <nl> + pipeline . AddPass < CudnnConvAlgorithmPicker > ( stream_exec , device_allocator ) ; <nl> + <nl> + / / Find the fastest algorithm for GEMMs . <nl> + pipeline . AddPass < GemmAlgorithmPicker > ( stream_exec , device_allocator ) ; <nl> + <nl> + / / Clean up new_tuple described above . <nl> + pipeline . AddPass < TupleSimplifier > ( ) ; <nl> + <nl> + pipeline . AddPass < HloCSE > ( / * is_layout_sensitive = * / true ) ; <nl> + TF_RETURN_IF_ERROR ( pipeline . Run ( hlo_module ) . status ( ) ) ; <nl> + <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + namespace { <nl> absl : : optional < bool > CanShareBufferHint ( const HloInstruction * user , <nl> const HloInstruction * operand , <nl> const ShapeIndex & user_index ) { <nl> bool MaybeLoadPtxFromFile ( const HloModule * module , std : : string * ptx ) { <nl> <nl> } / / namespace <nl> <nl> - / / Runs optimization passes on the given HLO module . <nl> - Status impl : : OptimizeHloModule ( HloModule * hlo_module , <nl> - se : : StreamExecutor * stream_exec , <nl> - se : : DeviceMemoryAllocator * device_allocator ) { <nl> - { <nl> - HloPassPipeline pipeline ( " optimization " ) ; <nl> - pipeline . AddInvariantChecker < HloVerifier > ( / * layout_sensitive = * / false , <nl> - / * allow_mixed_precision = * / false ) ; <nl> - <nl> - / / Expand random number generation . <nl> - pipeline . AddPass < RngExpander > ( ) ; <nl> - <nl> - / / Remove zero - sized HLO from the input so that other passes don ' t have to <nl> - / / handle it . <nl> - pipeline . AddPass < ZeroSizedHloElimination > ( ) ; <nl> - <nl> - pipeline . AddPass < GpuScatterExpander > ( ) ; <nl> - <nl> - pipeline . AddPass < DynamicIndexSplitter > ( ) ; <nl> - pipeline . AddPass < GpuHloSupportChecker > ( ) ; <nl> - ReducePrecisionInsertion : : AddPasses ( <nl> - & pipeline , hlo_module - > config ( ) . debug_options ( ) , <nl> - ReducePrecisionInsertion : : PassTiming : : BEFORE_OPTIMIZATION ) ; <nl> - <nl> - / / TODO ( b / 64094172 ) : make Call work on GPU instead of inlining . <nl> - pipeline . AddPass < CallInliner > ( ) ; <nl> - auto cost_model = [ ] ( HloInstruction * conv ) { <nl> - / / We need a cost model for GPUs . Currently , do nothing . <nl> - return false ; <nl> - } ; <nl> - pipeline . AddPass < DotDecomposer > ( ) ; <nl> - pipeline . AddPass < ConvolutionGroupConverter > ( <nl> - cost_model , <nl> - / * convert_batch_groups_only = * / true ) ; <nl> - / / Expand the sort op to support stable sorting if required . <nl> - pipeline . AddPass < StableSortExpander > ( ) ; <nl> - / / Convert BF16 operations to F32 operations so that the GPU backend can <nl> - / / support BF16 operations without directly implementing a BF16 lowering for <nl> - / / most ops . <nl> - pipeline . AddPass < HloElementTypeConverter > ( BF16 , F32 ) ; <nl> - <nl> - { <nl> - auto & pass = <nl> - pipeline . AddPass < HloPassFix < HloPassPipeline > > ( " simplification " ) ; <nl> - pass . AddInvariantChecker < HloVerifier > ( / * layout_sensitive = * / false , <nl> - / * allow_mixed_precision = * / false ) ; <nl> - <nl> - / / If cudnn batchnorms are enabled , rewrite batchnorm HLOs to cudnn calls <nl> - / / where possible . Not every batchnorm op can be implemented as a call to <nl> - / / cudnn , so decompose any remaining batchnorm ops into a soup of HLOs . <nl> - if ( hlo_module - > config ( ) . debug_options ( ) . xla_gpu_use_cudnn_batchnorm ( ) ) { <nl> - pass . AddPass < CudnnBatchNormRewriter > ( ) ; <nl> - } <nl> - pass . AddPass < BatchNormExpander > ( <nl> - / * rewrite_training_op = * / true , <nl> - / * rewrite_inference_op = * / true , <nl> - / * rewrite_grad_op = * / true ) ; <nl> - <nl> - pipeline . AddPass < HloGetDimensionSizeRewriter > ( ) ; <nl> - <nl> - / / BatchNormExpander can create zero - sized ops , so zero - sized HLO <nl> - / / elimination has to come after that pass . <nl> - pipeline . AddPass < ZeroSizedHloElimination > ( ) ; <nl> - <nl> - AlgebraicSimplifierOptions options ; <nl> - pass . AddPass < AlgebraicSimplifier > ( options ) ; <nl> - pass . AddPass < SortSimplifier > ( ) ; <nl> - pass . AddPass < TupleSimplifier > ( ) ; <nl> - pass . AddPass < WhileLoopConstantSinking > ( ) ; <nl> - pass . AddPass < WhileLoopSimplifier > ( ) ; <nl> - <nl> - / / TODO ( b / 134075051 ) : Re - enable after b / 134075051 is fixed . <nl> - / / pass . AddPass < SliceSinker > ( ) ; <nl> - <nl> - pass . AddPass < HloDCE > ( ) ; <nl> - pass . AddPass < ReshapeMover > ( ) ; <nl> - pass . AddPass < HloConstantFolding > ( ) ; <nl> - pass . AddPass < ConditionalSimplifier > ( ) ; <nl> - } <nl> - <nl> - pipeline . AddPass < TransposeFolding > ( <nl> - [ ] ( const HloInstruction & dot , <nl> - const TransposeFolding : : OperandIndices & candidate_operands ) { <nl> - return IsMatrixMultiplication ( dot ) <nl> - ? candidate_operands <nl> - : TransposeFolding : : OperandIndices { } ; <nl> - } , <nl> - TransposeFolding : : NeverFoldTranspose ) ; <nl> - pipeline . AddPass < HloCSE > ( / * is_layout_sensitive = * / false ) ; <nl> - pipeline . AddPass < HloDCE > ( ) ; <nl> - <nl> - / / Run WhileLoopTripCountAnnotator at the end of the simplification <nl> - / / pipeline , before layout assignment and fusion . This pass does some <nl> - / / pattern - matching on while bodies / conditions , and this is where the HLO is <nl> - / / " nicest " . <nl> - / / <nl> - / / It ' s important that we don ' t make semantic changes ( e . g . unrolling ) to <nl> - / / any ` while ` loops after this point , because otherwise the trip - count <nl> - / / annotations added by this pass may not be correct after the <nl> - / / modifications . <nl> - pipeline . AddPass < WhileLoopTripCountAnnotator > ( ) ; <nl> - TF_RETURN_IF_ERROR ( pipeline . Run ( hlo_module ) . status ( ) ) ; <nl> - } <nl> - <nl> - { <nl> - / / Convert convolutions into CustomCalls to cudnn , then canonicalize them <nl> - / / ( CudnnConvPaddingLegalization ) . Also expand cuSolver calls . <nl> - HloPassPipeline pipeline ( " conv_canonicalization " ) ; <nl> - pipeline . AddInvariantChecker < HloVerifier > ( / * layout_sensitive = * / false , <nl> - / * allow_mixed_precision = * / false ) ; <nl> - pipeline . AddPass < CusolverRewriter > ( ) ; <nl> - pipeline . AddPass < CudnnConvRewriter > ( ) ; <nl> - pipeline . AddPass < CudnnFusedConvRewriter > ( ) ; <nl> - pipeline . AddPass < CudnnConvPaddingLegalization > ( ) ; <nl> - if ( IsVoltaOrLater ( * stream_exec ) ) { <nl> - pipeline . AddPass < CudnnConvPadForTensorCores > ( ) ; <nl> - / / CudnnConvPadForTensorCores leaves behind unnecessary <nl> - / / tuple / get - tuple - element pairs that TupleSimplifier fixes . <nl> - pipeline . AddPass < TupleSimplifier > ( ) ; <nl> - } <nl> - / / CudnnConvRewriter , CudnnConvPaddingLegalization and <nl> - / / CudnnConvPadForTensorCores may add instructions which can be simplified <nl> - / / by constant folding . <nl> - pipeline . AddPass < HloConstantFolding > ( ) ; <nl> - TF_RETURN_IF_ERROR ( pipeline . Run ( hlo_module ) . status ( ) ) ; <nl> - } <nl> - <nl> - { <nl> - / / Run layout assignment in a separate pipeline from <nl> - / / " post - layout - assignment " because we want everything after layout <nl> - / / assignment to have a layout - sensitive invariant - checker , but <nl> - / / HloPassPipeline also runs its invariant checker before any passes are <nl> - / / run , meaning , the pipeline that contains layout assignment cannot contain <nl> - / / a layout - sensitive verifier ! <nl> - HloPassPipeline pipeline ( " layout assignment " ) ; <nl> - pipeline . AddPass < GpuLayoutAssignment > ( <nl> - hlo_module - > mutable_entry_computation_layout ( ) , <nl> - LayoutAssignment : : InstructionCanChangeLayout , stream_exec ) ; <nl> - TF_RETURN_IF_ERROR ( pipeline . Run ( hlo_module ) . status ( ) ) ; <nl> - } <nl> - <nl> - { <nl> - HloPassPipeline pipeline ( " post - layout_assignment " ) ; <nl> - / * TODO ( b / 117531509 ) : Use LayoutAssignment : : InstructionCanChangeLayout after <nl> - * fixing the ticket . * / <nl> - pipeline . AddInvariantChecker < HloVerifier > ( <nl> - / * layout_sensitive = * / true , <nl> - / * allow_mixed_precision = * / false , <nl> - LayoutAssignment : : InstructionCanChangeLayout ) ; <nl> - <nl> - / / The LayoutAssignment pass may leave behind kCopy instructions which are <nl> - / / duplicate or NOPs , so remove them with algebraic simplification and CSE . <nl> - AlgebraicSimplifierOptions options ; <nl> - options . set_is_layout_sensitive ( true ) ; <nl> - pipeline . AddPass < HloPassFix < AlgebraicSimplifier > > ( options ) ; <nl> - <nl> - / / Rewrite GEMMs into custom calls . <nl> - pipeline . AddPass < GemmRewriter > ( ) ; <nl> - <nl> - / / Choose the fastest algorithm for each conv . <nl> - / / <nl> - / / We pick the algorithm before fusion so we can generate better HLO . After <nl> - / / CudnnConvRewriter , our convolutions are CustomCalls which return a <nl> - / / tuple ( conv_result , scratch_memory ) , and the each conv uses 0 bytes of <nl> - / / scratch : <nl> - / / <nl> - / / customcall = ( f32 [ . . . ] , f32 [ 0 ] ) <nl> - / / return gte ( customcall , 0 ) <nl> - / / <nl> - / / The algorithm picker then chooses the best algorithm , and potentially <nl> - / / increases the scratch space . It replaces customcall with new_tuple , <nl> - / / giving us the following : <nl> - / / <nl> - / / new_customcall = ( f32 [ . . . ] , f32 [ N ] ) <nl> - / / new_tuple = tuple ( gte ( new_customcall , 0 ) , constant f32 [ 0 ] ) <nl> - / / return gte ( new_tuple , 0 ) <nl> - / / <nl> - / / The new tuple and gte instructions then be simplified away , because <nl> - / / nobody is expected to use the scratch value . <nl> - / / <nl> - / / However , if we were to run CudnnConvAlgorithmPicker after fusion <nl> - / / the gte ( customcall , 0 ) would probably already be into a fusion node . We <nl> - / / can ' t simplify across HloComputation boundaries , so in this case we <nl> - / / wouldn ' t be able to simplify away the new_tuple bits . <nl> - pipeline . AddPass < CudnnConvAlgorithmPicker > ( stream_exec , device_allocator ) ; <nl> - <nl> - / / Find the fastest algorithm for GEMMs . <nl> - pipeline . AddPass < GemmAlgorithmPicker > ( stream_exec , device_allocator ) ; <nl> - <nl> - / / Clean up new_tuple described above . <nl> - pipeline . AddPass < TupleSimplifier > ( ) ; <nl> - <nl> - pipeline . AddPass < HloCSE > ( / * is_layout_sensitive = * / true ) ; <nl> - TF_RETURN_IF_ERROR ( pipeline . Run ( hlo_module ) . status ( ) ) ; <nl> - } <nl> - <nl> - { <nl> - HloPassFix < HloPassPipeline > fusion ( " fusion " ) ; <nl> - / / We try to split variadic ops with many parameters into several such ops <nl> - / / to avoid exceeding the parameter space . <nl> - fusion . AddPass < VariadicOpSplitter > ( ) ; <nl> - / * TODO ( b / 117531509 ) : Use LayoutAssignment : : InstructionCanChangeLayout after <nl> - * fixing the ticket . * / <nl> - fusion . AddInvariantChecker < HloVerifier > ( <nl> - / * layout_sensitive = * / true , <nl> - / * allow_mixed_precision = * / false , <nl> - LayoutAssignment : : InstructionCanChangeLayout ) ; <nl> - fusion . AddPass < GpuInstructionFusion > ( / * may_duplicate = * / false ) ; <nl> - fusion . AddPass < GpuInstructionFusion > ( / * may_duplicate = * / true ) ; <nl> - fusion . AddPass < FusionMerger > ( ) ; <nl> - fusion . AddPass < GpuMultiOutputFusion > ( ) ; <nl> - fusion . AddPass < HloCSE > ( / * is_layout_sensitive = * / true , <nl> - / * only_fusion_computations = * / true ) ; <nl> - fusion . AddPass < HloDCE > ( ) ; <nl> - TF_RETURN_IF_ERROR ( fusion . Run ( hlo_module ) . status ( ) ) ; <nl> - <nl> - HloPassPipeline reduce_pipeline ( " reduce - precision " ) ; <nl> - / * TODO ( b / 117531509 ) : Use LayoutAssignment : : InstructionCanChangeLayout after <nl> - * fixing the ticket . * / <nl> - reduce_pipeline . AddInvariantChecker < HloVerifier > ( <nl> - / * is_layout_sensitive = * / true , / * allow_mixed_precision = * / false , <nl> - LayoutAssignment : : InstructionCanChangeLayout ) ; <nl> - ReducePrecisionInsertion : : AddPasses ( <nl> - & reduce_pipeline , hlo_module - > config ( ) . debug_options ( ) , <nl> - ReducePrecisionInsertion : : PassTiming : : AFTER_FUSION ) ; <nl> - StatusOr < bool > reduce_result = reduce_pipeline . Run ( hlo_module ) ; <nl> - TF_RETURN_IF_ERROR ( reduce_result . status ( ) ) ; <nl> - <nl> - if ( reduce_result . ValueOrDie ( ) ) { <nl> - / / Do another fusion pass , with the expectation that we may be able to <nl> - / / fuse the new ReducePrecision operations . <nl> - TF_RETURN_IF_ERROR ( fusion . Run ( hlo_module ) . status ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - return Status : : OK ( ) ; <nl> - } <nl> - <nl> - / / Modifies the given HLO module so that it will be accepted by IrEmitter . <nl> - / / Unlike optimization passes , the passes are necessary for correctness . <nl> - Status impl : : PrepareHloModuleForIrEmitting ( HloModule * hlo_module ) { <nl> - / / In some cases , we have to place the result of an instruction in a temporary <nl> - / / buffer . For instance , the buffer that holds an external parameter is <nl> - / / assumed immutable at this point , and should not be reused for output <nl> - / / ( b / 27180329 ) . Therefore , in that case , we set the output to be a copy of <nl> - / / the parameter . <nl> - HloPassPipeline pipeline ( " GPU - ir - emit - prepare " ) ; <nl> - / * TODO ( b / 117531509 ) : Use LayoutAssignment : : InstructionCanChangeLayout after <nl> - * fixing the ticket . * / <nl> - pipeline . AddInvariantChecker < HloVerifier > ( <nl> - / * layout_sensitive = * / true , <nl> - / * allow_mixed_precision = * / false , <nl> - LayoutAssignment : : InstructionCanChangeLayout ) ; <nl> - <nl> - / / Copy insertion should be performed immediately before IR emission to avoid <nl> - / / inserting unnecessary copies ( later pass adds an instruction which <nl> - / / materializes the value ) or missing a necessary copy ( later pass removes an <nl> - / / instruction which materializes a value ) . DCE must be run immediately before <nl> - / / ( and sometime after ) copy insertion , to avoid dead code from interfering <nl> - / / with the rewrites . <nl> - pipeline . AddPass < HloDCE > ( ) ; <nl> - pipeline . AddPass < FlattenCallGraph > ( ) ; <nl> - / / The following pass LOGs memory waste . Add it when VLOGing is enabled only . <nl> - if ( VLOG_IS_ON ( 2 ) ) { <nl> - pipeline . AddPass < MemWastedOnPassthroughParams > ( ) ; <nl> - } <nl> - pipeline . AddPass < GpuCopyInsertion > ( & CanShareBufferHint ) ; <nl> - pipeline . AddPass < GpuSanitizeConstantNames > ( ) ; <nl> - return pipeline . Run ( hlo_module ) . status ( ) ; <nl> - } <nl> - <nl> NVPTXCompiler : : NVPTXCompiler ( ) <nl> - : pointer_size_ ( llvm : : DataLayout ( nvptx : : kDataLayout ) <nl> - . getPointerSize ( 0 / * default address space * / ) ) { } <nl> - <nl> - StatusOr < std : : unique_ptr < HloModule > > NVPTXCompiler : : RunHloPasses ( <nl> - std : : unique_ptr < HloModule > module , se : : StreamExecutor * stream_exec , <nl> - se : : DeviceMemoryAllocator * device_allocator ) { <nl> - / / We dump the post - optimization HLO in RunBackend so no need to dump it here . <nl> - XLA_SCOPED_LOGGING_TIMER ( " NVPTXCompiler : : RunHloPasses " ) ; <nl> - tensorflow : : profiler : : TraceMe activity ( <nl> - [ & ] { return absl : : StrCat ( " HLO Transforms : " , module - > name ( ) ) ; } , <nl> - tensorflow : : profiler : : TraceMeLevel : : kInfo ) ; <nl> - TF_RETURN_IF_ERROR ( <nl> - impl : : OptimizeHloModule ( module . get ( ) , stream_exec , device_allocator ) ) ; <nl> + : GpuCompiler ( stream_executor : : cuda : : kCudaPlatformId , nvptx : : kTargetTriple , <nl> + nvptx : : kDataLayout ) { } <nl> <nl> - TF_RETURN_IF_ERROR ( impl : : PrepareHloModuleForIrEmitting ( module . get ( ) ) ) ; <nl> - <nl> - return std : : move ( module ) ; <nl> + HloDataflowAnalysis : : CanShareBuffer NVPTXCompiler : : GetCanShareBuffer ( ) { <nl> + return & CanShareBufferHint ; <nl> } <nl> <nl> - StatusOr < std : : unique_ptr < Executable > > NVPTXCompiler : : RunBackend ( <nl> - std : : unique_ptr < HloModule > module , se : : StreamExecutor * stream_exec , <nl> - se : : DeviceMemoryAllocator * device_allocator ) { <nl> - XLA_SCOPED_LOGGING_TIMER ( " NVPTXCompiler : : RunBackend " ) ; <nl> - auto slow_compile_alarm = SlowCompilationAlarm ( ) ; <nl> - <nl> - TF_RET_CHECK ( stream_exec ! = nullptr ) ; <nl> - <nl> - llvm : : LLVMContext llvm_context ; <nl> - std : : string buffer ; <nl> - llvm : : raw_string_ostream error ( buffer ) ; <nl> - llvm : : DiagnosticPrinterRawOStream printer ( error ) ; <nl> - auto DiagnosticHandler = [ ] ( const llvm : : DiagnosticInfo & diag_info , <nl> - void * Context ) { <nl> - auto printer = static_cast < llvm : : DiagnosticPrinterRawOStream * > ( Context ) ; <nl> - diag_info . print ( * printer ) ; <nl> - } ; <nl> - llvm_context . setDiagnosticHandlerCallBack ( DiagnosticHandler , & printer ) ; <nl> - <nl> - llvm : : Module llvm_module ( module - > name ( ) . c_str ( ) , llvm_context ) ; <nl> - / / Set the target triple and the data layout . <nl> - llvm_module . setTargetTriple ( nvptx : : kTargetTriple ) ; <nl> - llvm_module . setDataLayout ( nvptx : : kDataLayout ) ; <nl> - <nl> - / / Determine the HLO schedule , which is an ordering of HLO instructions . This <nl> - / / is used by buffer assignment to enable buffer reuse , and the same ordering <nl> - / / must also be used to determine the thunk launch schedule . <nl> - std : : unique_ptr < StreamAssignment > stream_assignment = AssignStreams ( * module ) ; <nl> - TF_ASSIGN_OR_RETURN ( <nl> - std : : unique_ptr < GpuHloSchedule > hlo_schedule , <nl> - GpuHloSchedule : : Build ( * module , * stream_assignment , pointer_size_ ) ) ; <nl> - <nl> - / / Run buffer analysis on the HLO graph . This analysis figures out which <nl> - / / temporary buffers are required to run the computation . <nl> - TF_ASSIGN_OR_RETURN ( <nl> - std : : unique_ptr < BufferAssignment > buffer_assignment , <nl> - BufferAssigner : : Run ( <nl> - module . get ( ) , hlo_schedule - > ConsumeHloOrdering ( ) , <nl> - BufferSizeBytesFunction ( ) , <nl> - / * color_alignment = * / <nl> - [ ] ( LogicalBuffer : : Color ) { return kXlaAllocatedBufferAlignBytes ; } , <nl> - / * allocate_buffers_for_constants = * / true , <nl> - / * colorer = * / BufferAssigner : : DefaultColorer ( ) , <nl> - / * must_not_live_out = * / { } , & CanShareBufferHint ) ) ; <nl> - DumpHloModuleIfEnabled ( * module , * buffer_assignment , " after_optimizations " ) ; <nl> - <nl> - IrEmitterContext ir_emitter_context ( <nl> - module . get ( ) , buffer_assignment . get ( ) , stream_exec - > platform ( ) , <nl> - & stream_exec - > GetDeviceDescription ( ) , & llvm_module ) ; <nl> - <nl> - HloComputation * entry_computation = module - > entry_computation ( ) ; <nl> - IrEmitterUnnested ir_emitter ( module - > config ( ) , entry_computation , <nl> - & ir_emitter_context ) ; <nl> - <nl> - TF_RETURN_IF_ERROR ( ir_emitter . EmitConstantGlobals ( ) ) ; <nl> - <nl> - { <nl> - XLA_SCOPED_LOGGING_TIMER ( " NVPTXCompiler : : RunBackend - IR emission " ) ; <nl> - TF_RETURN_IF_ERROR ( entry_computation - > Accept ( & ir_emitter ) ) ; <nl> - } <nl> - <nl> - if ( user_pre_optimization_hook_ ) { <nl> - user_pre_optimization_hook_ ( llvm_module ) ; <nl> - } <nl> - string ir_module_string_before_opt ; <nl> - const bool embed_ir_in_executable = <nl> - module - > config ( ) . debug_options ( ) . xla_embed_ir_in_executable ( ) ; <nl> - if ( embed_ir_in_executable ) { <nl> - ir_module_string_before_opt = llvm_ir : : DumpModuleToString ( llvm_module ) ; <nl> + GpuVersion NVPTXCompiler : : GetGpuVersion ( se : : StreamExecutor * stream_exec ) { <nl> + int cc_major , cc_minor ; <nl> + if ( ! stream_exec - > GetDeviceDescription ( ) . cuda_compute_capability ( & cc_major , <nl> + & cc_minor ) ) { <nl> + LOG ( WARNING ) <nl> + < < " Couldn ' t get compute capability for device ; assuming sm_20 . " ; <nl> + cc_major = 2 ; <nl> + cc_minor = 0 ; <nl> } <nl> <nl> - llvm_ir : : DumpIrIfEnabled ( * module , llvm_module , / * optimized = * / false ) ; <nl> - <nl> - { <nl> - XLA_SCOPED_LOGGING_TIMER ( <nl> - " NVPTXCompiler : : RunBackend - Running LLVM verifier " ) ; <nl> - <nl> - std : : string err ; <nl> - llvm : : raw_string_ostream err_stream ( err ) ; <nl> + return std : : make_pair ( cc_major , cc_minor ) ; <nl> + } <nl> <nl> - / / verifyModule ( ) returns true if the module is broken . <nl> - TF_RET_CHECK ( ! llvm : : verifyModule ( llvm_module , & err_stream ) ) <nl> - < < " Invalid LLVM IR before optimizations : \ n " <nl> - < < err_stream . str ( ) <nl> - < < " \ nThis probably indicates a bug in the HLO - > LLVM IR lowering . " <nl> - " Rerun with - - xla_dump_to to get the IR . " ; <nl> - } <nl> + StatusOr < std : : pair < std : : string , std : : vector < uint8 > > > <nl> + NVPTXCompiler : : CompileTargetBinary ( const HloModule * module , <nl> + llvm : : Module * llvm_module , <nl> + GpuVersion gpu_version , <nl> + se : : StreamExecutor * stream_exec ) { <nl> + std : : pair < int , int > compute_capability = <nl> + absl : : get < std : : pair < int , int > > ( gpu_version ) ; <nl> <nl> std : : string libdevice_dir ; <nl> { <nl> StatusOr < std : : unique_ptr < Executable > > NVPTXCompiler : : RunBackend ( <nl> } <nl> VLOG ( 2 ) < < " Libdevice dir = " < < libdevice_dir < < " \ n " ; <nl> <nl> - int cc_major , cc_minor ; <nl> - if ( ! stream_exec - > GetDeviceDescription ( ) . cuda_compute_capability ( & cc_major , <nl> - & cc_minor ) ) { <nl> - LOG ( WARNING ) <nl> - < < " Couldn ' t get compute capability for device ; assuming sm_20 . " ; <nl> - cc_major = 2 ; <nl> - cc_minor = 0 ; <nl> - } <nl> - <nl> - std : : string ptx ; <nl> - <nl> - if ( ! MaybeLoadPtxFromFile ( module . get ( ) , & ptx ) ) { <nl> - XLA_SCOPED_LOGGING_TIMER ( " NVPTXCompiler : : RunBackend - CompileToPtx " ) ; <nl> + string ptx ; <nl> + if ( ! MaybeLoadPtxFromFile ( module , & ptx ) ) { <nl> + XLA_SCOPED_LOGGING_TIMER ( <nl> + " NVPTXCompiler : : CompileTargetBinary - CompileToPtx " ) ; <nl> TF_ASSIGN_OR_RETURN ( <nl> - ptx , nvptx : : CompileToPtx ( & llvm_module , <nl> - std : : pair < int , int > { cc_major , cc_minor } , <nl> - module - > config ( ) , libdevice_dir ) ) ; <nl> + ptx , nvptx : : CompileToPtx ( llvm_module , gpu_version , module - > config ( ) , <nl> + libdevice_dir ) ) ; <nl> } <nl> <nl> - llvm_ir : : DumpIrIfEnabled ( * module , llvm_module , / * optimized = * / true ) ; <nl> + llvm_ir : : DumpIrIfEnabled ( * module , * llvm_module , / * optimized = * / true ) ; <nl> <nl> if ( user_post_optimization_hook_ ) { <nl> - user_post_optimization_hook_ ( llvm_module ) ; <nl> + user_post_optimization_hook_ ( * llvm_module ) ; <nl> } <nl> / / Write PTX to IR dump directory , if IR dumping was requested . <nl> if ( DumpingEnabledForHloModule ( * module ) ) { <nl> DumpToFileInDirOrStdout ( * module , " ptx " , ptx ) ; <nl> } <nl> <nl> - const std : : vector < uint8 > cubin = CompilePtxOrGetCachedResult ( <nl> - stream_exec , ptx , cc_major , cc_minor , module - > config ( ) ) ; <nl> - <nl> - auto thunk_schedule = absl : : make_unique < ThunkSchedule > ( <nl> - ir_emitter . ConsumeThunkSequence ( ) , std : : move ( stream_assignment ) , <nl> - hlo_schedule - > ThunkLaunchOrder ( ) ) ; <nl> - if ( DumpingEnabledForHloModule ( * module ) ) { <nl> - DumpToFileInDirOrStdout ( * module , " thunk_schedule " , <nl> - thunk_schedule - > ToString ( ) ) ; <nl> - } <nl> - <nl> - std : : unique_ptr < HloProfileIndexMap > profile_index_map ; <nl> - std : : unique_ptr < HloProfilePrinterData > profile_printer ; <nl> - <nl> - if ( module - > config ( ) . hlo_profiling_enabled ( ) | | VLOG_IS_ON ( 1 ) ) { <nl> - HloCostAnalysis cost_analysis ( ShapeSizeBytesFunction ( ) ) ; <nl> - cost_analysis . set_bytes_per_second ( <nl> - stream_exec - > GetDeviceDescription ( ) . memory_bandwidth ( ) ) ; <nl> - TF_RETURN_IF_ERROR ( module - > entry_computation ( ) - > Accept ( & cost_analysis ) ) ; <nl> - VLOG ( 1 ) < < " HLO memory read + written : " <nl> - < < tensorflow : : strings : : HumanReadableNumBytes ( <nl> - cost_analysis . bytes_accessed ( ) ) ; <nl> - if ( module - > config ( ) . hlo_profiling_enabled ( ) ) { <nl> - profile_index_map = absl : : make_unique < HloProfileIndexMap > ( * module ) ; <nl> - profile_printer = CreateHloProfilePrinterData ( <nl> - * profile_index_map , cost_analysis , entry_computation - > name ( ) ) ; <nl> - } <nl> - } <nl> + std : : vector < uint8 > cubin = <nl> + CompilePtxOrGetCachedResult ( stream_exec , ptx , compute_capability . first , <nl> + compute_capability . second , module - > config ( ) ) ; <nl> <nl> - auto * gpu_executable = new GpuExecutable ( <nl> - ptx , cubin , std : : make_pair ( cc_major , cc_minor ) , std : : move ( thunk_schedule ) , <nl> - std : : move ( module ) , std : : move ( buffer_assignment ) , <nl> - std : : move ( profile_printer ) , std : : move ( profile_index_map ) ) ; <nl> - if ( embed_ir_in_executable ) { <nl> - DCHECK_NE ( " " , ir_module_string_before_opt ) ; <nl> - gpu_executable - > set_ir_module_string ( ir_module_string_before_opt ) ; <nl> - } <nl> - return std : : unique_ptr < Executable > ( gpu_executable ) ; <nl> + return std : : pair < std : : string , std : : vector < uint8 > > ( std : : move ( ptx ) , <nl> + std : : move ( cubin ) ) ; <nl> } <nl> <nl> std : : vector < uint8 > NVPTXCompiler : : CompilePtxOrGetCachedResult ( <nl> std : : vector < uint8 > NVPTXCompiler : : CompilePtxOrGetCachedResult ( <nl> return cache_value - > cubin_data ; <nl> } <nl> <nl> - StatusOr < std : : vector < std : : unique_ptr < AotCompilationResult > > > <nl> - NVPTXCompiler : : CompileAheadOfTime ( std : : unique_ptr < HloModuleGroup > module_group , <nl> - const AotCompilationOptions & options ) { <nl> - return Unimplemented ( <nl> - " not yet implemented : NVPTXCompiler : : CompileAheadOfTime " ) ; <nl> - } <nl> - <nl> - se : : Platform : : Id NVPTXCompiler : : PlatformId ( ) const { <nl> - return se : : cuda : : kCudaPlatformId ; <nl> - } <nl> - <nl> } / / namespace gpu <nl> } / / namespace xla <nl> mmm a / tensorflow / compiler / xla / service / gpu / nvptx_compiler . h <nl> ppp b / tensorflow / compiler / xla / service / gpu / nvptx_compiler . h <nl> limitations under the License . <nl> # include " absl / container / node_hash_map . h " <nl> # include " absl / types / optional . h " <nl> # include " absl / types / span . h " <nl> - # include " tensorflow / compiler / xla / service / executable . h " <nl> - # include " tensorflow / compiler / xla / service / hlo_module . h " <nl> - # include " tensorflow / compiler / xla / service / llvm_compiler . h " <nl> + # include " tensorflow / compiler / xla / service / gpu / gpu_compiler . h " <nl> # include " tensorflow / compiler / xla / statusor . h " <nl> - # include " tensorflow / compiler / xla / types . h " <nl> # include " tensorflow / core / lib / hash / hash . h " <nl> - # include " tensorflow / core / platform / macros . h " <nl> # include " tensorflow / core / platform / mutex . h " <nl> - # include " tensorflow / core / platform / stream_executor_no_cuda . h " <nl> - # include " tensorflow / core / platform / thread_annotations . h " <nl> - # include " tensorflow / stream_executor / stream_executor_pimpl . h " <nl> <nl> namespace xla { <nl> namespace gpu { <nl> <nl> - / / Temporarily expose the optimization pipeline for the GPU backend for reuse <nl> - / / in the MLIR GPU backend . <nl> - / / TODO ( b / 137624192 ) : Remove once MLIR backend uses tailored optimizations . <nl> - namespace impl { <nl> - <nl> - Status OptimizeHloModule ( HloModule * hlo_module , se : : StreamExecutor * stream_exec , <nl> - se : : DeviceMemoryAllocator * device_allocator ) ; <nl> - Status PrepareHloModuleForIrEmitting ( HloModule * hlo_module ) ; <nl> - <nl> - } / / namespace impl <nl> - <nl> - / / The GPU compiler generates efficient GPU executables . <nl> - class NVPTXCompiler : public LLVMCompiler { <nl> + / / NVPTXCompiler generates efficient GPU executables for NVPTX target . <nl> + class NVPTXCompiler : public GpuCompiler { <nl> public : <nl> NVPTXCompiler ( ) ; <nl> ~ NVPTXCompiler ( ) override { } <nl> <nl> - / / Bring in <nl> - / / StatusOr < std : : vector < std : : unique_ptr < Executable > > > Compile ( <nl> - / / std : : vector < std : : unique_ptr < HloModule > > modules , <nl> - / / std : : vector < std : : vector < se : : StreamExecutor * > > <nl> - / / stream_execs ) <nl> - using LLVMCompiler : : Compile ; <nl> - <nl> - StatusOr < std : : unique_ptr < HloModule > > RunHloPasses ( <nl> - std : : unique_ptr < HloModule > module , se : : StreamExecutor * stream_exec , <nl> + Status OptimizeHloConvolutionCanonicalization ( <nl> + HloModule * hlo_module , se : : StreamExecutor * stream_exec , <nl> se : : DeviceMemoryAllocator * device_allocator ) override ; <nl> <nl> - StatusOr < std : : unique_ptr < Executable > > RunBackend ( <nl> - std : : unique_ptr < HloModule > module , se : : StreamExecutor * stream_exec , <nl> + Status OptimizeHloPostLayoutAssignment ( <nl> + HloModule * hlo_module , se : : StreamExecutor * stream_exec , <nl> se : : DeviceMemoryAllocator * device_allocator ) override ; <nl> <nl> - StatusOr < std : : vector < std : : unique_ptr < AotCompilationResult > > > <nl> - CompileAheadOfTime ( std : : unique_ptr < HloModuleGroup > module_group , <nl> - AotCompilationOptions const & options ) override ; <nl> + HloDataflowAnalysis : : CanShareBuffer GetCanShareBuffer ( ) override ; <nl> <nl> - se : : Platform : : Id PlatformId ( ) const override ; <nl> + GpuVersion GetGpuVersion ( se : : StreamExecutor * stream_exec ) override ; <nl> <nl> - HloCostAnalysis : : ShapeSizeFunction ShapeSizeBytesFunction ( ) const override { <nl> - / / Capture just the pointer size , not the entire NVPTXCompiler object . <nl> - int64 pointer_size = pointer_size_ ; <nl> - return [ pointer_size ] ( const Shape & shape ) { <nl> - return ShapeUtil : : ByteSizeOf ( shape , pointer_size ) ; <nl> - } ; <nl> - } <nl> + StatusOr < std : : pair < std : : string , std : : vector < uint8 > > > CompileTargetBinary ( <nl> + const HloModule * hlo_module , llvm : : Module * llvm_module , <nl> + GpuVersion gpu_version , se : : StreamExecutor * stream_exec ) override ; <nl> <nl> private : <nl> - / / The size in bytes of a pointer . Used by ShapeSizeBytesFunction . <nl> - const int64 pointer_size_ ; <nl> - <nl> tensorflow : : mutex mutex_ ; <nl> <nl> / / When compiling an HLO module , we need to find a path to the nvvm libdevice <nl> mmm a / tensorflow / compiler / xla / tests / BUILD <nl> ppp b / tensorflow / compiler / xla / tests / BUILD <nl> tf_cc_test ( <nl> " / / tensorflow / compiler / xla / service : llvm_compiler " , <nl> " / / tensorflow / compiler / xla / service : platform_util " , <nl> " / / tensorflow / compiler / xla / service / cpu : cpu_compiler " , <nl> - " / / tensorflow / compiler / xla / service / gpu : nvptx_compiler " , <nl> " / / tensorflow / compiler / xla / service / gpu : nvptx_compiler_impl " , <nl> " / / tensorflow / core : test " , <nl> " / / tensorflow / core : test_main " , <nl>
Merge pull request from ROCmSoftwarePlatform : google_upstream_xla_amdgpu_frontend
tensorflow/tensorflow
eecba4e35c630e09733636f70448bf42839c0af7
2019-08-09T13:50:59Z
mmm a / tensorflow / python / data / kernel_tests / matching_files_dataset_op_test . py <nl> ppp b / tensorflow / python / data / kernel_tests / matching_files_dataset_op_test . py <nl> def testNestedDirectories ( self ) : <nl> dataset = MatchingFilesDataset ( patterns ) <nl> with self . cached_session ( ) as sess : <nl> next_element = dataset . make_one_shot_iterator ( ) . get_next ( ) <nl> - expected_filenames = [ compat . as_bytes ( file ) <nl> - for file in filenames if file . endswith ( ' . txt ' ) ] <nl> + expected_filenames = [ compat . as_bytes ( filename ) <nl> + for filename in filenames if filename . endswith ( ' . txt ' ) ] <nl> actual_filenames = [ ] <nl> while True : <nl> try : <nl>
Rename the variable name from to to avoid the built - in
tensorflow/tensorflow
ce2e925493cead88de6546ad2754d953694d91c3
2018-10-08T21:59:13Z
mmm a / docs / WindowsBuild . md <nl> ppp b / docs / WindowsBuild . md <nl> git clone https : / / github . com / apple / swift - corelibs - libdispatch toolchain / swift - co <nl> git clone https : / / github . com / apple / swift - corelibs - foundation toolchain / swift - corelibs - foundation <nl> git clone https : / / github . com / apple / swift - corelibs - xctest toolchain / swift - corelibs - xctest <nl> git clone https : / / github . com / apple / swift - llbuild toolchain / llbuild <nl> - git clone - c core . autocrlf = input https : / / github . com / apple / swift - package - manager toolchain / swift - package - manager <nl> + git clone https : / / github . com / apple / swift - tools - support - core toolchain / swift - tools - support - core <nl> + git clone - c core . autocrlf = input https : / / github . com / apple / swift - package - manager toolchain / swiftpm <nl> git clone https : / / github . com / compnerd / windows - swift windows - swift <nl> ` ` ` <nl> <nl> path S : \ b \ llbuild \ bin ; % PATH % <nl> # # Build swift - tools - core - support <nl> <nl> ` ` ` cmd <nl> - md S : \ b \ tsc <nl> cmake - B S : \ b \ tsc - G Ninja - S S : \ toolchain \ swift - tools - support - core - DCMAKE_BUILD_TYPE = RelWithDebInfo - DCMAKE_C_COMPILER = cl - DCMAKE_Swift_COMPILER = S : / b / toolchain / bin / swiftc . exe - DFoundation_DIR = S : / b / foundation / cmake / modules - Ddispatch_DIR = S : / b / libdispatch / cmake / modules <nl> ninja - C S : \ b \ tsc <nl> ` ` ` <nl> ninja - C S : \ b \ tsc <nl> # # Build swift - package - manager <nl> <nl> ` ` ` cmd <nl> - md S : \ b \ spm <nl> - cd S : \ b \ spm <nl> - C : \ Python27 \ python . exe S : \ swift - package - manager \ Utilities \ bootstrap - - foundation S : \ b \ foundation - - libdispatch - build - dir S : \ b \ libdispatch - - libdispatch - source - dir S : \ swift - corelibs - libdispatch - - llbuild - build - dir S : \ b \ llbuild - - llbuild - source - dir S : \ llbuild - - sqlite - build - dir S : \ b \ sqlite - - sqlite - source - dir S : \ sqlite - amalgamation - 3270200 <nl> + cmake - B S : \ b \ spm - G Ninja - S S : \ toolchain \ swiftpm - DCMAKE_BUILD_TYPE = RelWithDebInfo - DCMAKE_C_COMPILER = S : / b / toolchain / bin / clang - cl . exe - DCMAKE_CXX_COMPILER = S : / b / toolchain / bin / clang - cl . exe - DCMAKE_Swift_COMPILER = S : / b / toolchain / bin / swiftc . exe - DUSE_VENDORED_TSC = YES - DFoundation_DIR = S : / b / foundation / cmake / modules - Ddispatch_DIR = S : / b / libdispatch / cmake / modules - DLLBuild_DIR = S : / b / llbuild / cmake / modules <nl> + ninja - C S : \ b \ spm <nl> ` ` ` <nl> <nl> # # Install the Swift toolchain on Windows <nl>
docs : Update WindowsBuild . md
apple/swift
87cc554d5b040c991e77b2b3fc4de92c0dcc4c63
2019-12-11T23:43:12Z
mmm a / src / fileio / dmlcio / s3_filesys . cc <nl> ppp b / src / fileio / dmlcio / s3_filesys . cc <nl> void ListObjects ( const URI & path , <nl> ASSERT_TRUE ( curl_easy_setopt ( curl , CURLOPT_WRITEDATA , & result ) = = CURLE_OK ) ; <nl> set_curl_options ( curl ) ; <nl> ASSERT_TRUE ( curl_easy_setopt ( curl , CURLOPT_NOSIGNAL , 1 ) = = CURLE_OK ) ; <nl> - ASSERT_TRUE ( curl_easy_perform ( curl ) = = CURLE_OK ) ; <nl> + CURLcode performret = curl_easy_perform ( curl ) ; <nl> + ASSERT_EQ ( performret , CURLE_OK ) ; <nl> curl_slist_free_all ( slist ) ; <nl> curl_easy_cleanup ( curl ) ; <nl> / / parse xml <nl> mmm a / src / fileio / set_curl_options . cpp <nl> ppp b / src / fileio / set_curl_options . cpp <nl> <nl> * / <nl> # include < fileio / fileio_constants . hpp > <nl> # include < logger / assertions . hpp > <nl> + # include < fileio / fs_utils . hpp > <nl> extern " C " { <nl> # include < curl / curl . h > <nl> } <nl> void set_curl_options ( void * ecurl ) { <nl> using turi : : fileio : : get_alternative_ssl_cert_file ; <nl> using turi : : fileio : : insecure_ssl_cert_checks ; <nl> if ( ! get_alternative_ssl_cert_dir ( ) . empty ( ) ) { <nl> - ASSERT_EQ ( curl_easy_setopt ( ( CURL * ) ecurl , CURLOPT_CAPATH , get_alternative_ssl_cert_dir ( ) . c_str ( ) ) , CURLE_OK ) ; <nl> + if ( get_file_status ( get_alternative_ssl_cert_file ( ) ) = = file_status : : DIRECTORY ) { <nl> + ASSERT_EQ ( curl_easy_setopt ( ( CURL * ) ecurl , CURLOPT_CAPATH , get_alternative_ssl_cert_dir ( ) . c_str ( ) ) , CURLE_OK ) ; <nl> + } <nl> } <nl> if ( ! get_alternative_ssl_cert_file ( ) . empty ( ) ) { <nl> - ASSERT_EQ ( curl_easy_setopt ( ( CURL * ) ecurl , CURLOPT_CAINFO , get_alternative_ssl_cert_file ( ) . c_str ( ) ) , CURLE_OK ) ; <nl> + if ( get_file_status ( get_alternative_ssl_cert_file ( ) ) = = file_status : : REGULAR_FILE ) { <nl> + ASSERT_EQ ( curl_easy_setopt ( ( CURL * ) ecurl , CURLOPT_CAINFO , get_alternative_ssl_cert_file ( ) . c_str ( ) ) , CURLE_OK ) ; <nl> + } <nl> } <nl> if ( insecure_ssl_cert_checks ( ) ) { <nl> ASSERT_EQ ( curl_easy_setopt ( ( CURL * ) ecurl , CURLOPT_SSL_VERIFYPEER , 0l ) , CURLE_OK ) ; <nl> mmm a / test / fileio / fs . cpp <nl> ppp b / test / fileio / fs . cpp <nl> <nl> # include < boost / program_options . hpp > <nl> # include < regex > <nl> # include < boost / algorithm / string . hpp > <nl> + # include < globals / globals . hpp > <nl> # include < fileio / fs_utils . hpp > <nl> # include < fileio / sanitize_url . hpp > <nl> # include < fileio / general_fstream . hpp > <nl> int main ( int argc , char * * argv ) { <nl> print_help ( argv ) ; <nl> return 0 ; <nl> } <nl> - <nl> + turi : : globals : : initialize_globals_from_environment ( argv [ 0 ] ) ; <nl> std : : string command = argv [ 1 ] ; <nl> if ( command = = " cp " & & argc = = 4 ) { <nl> std : : string srcpath = argv [ 2 ] ; <nl>
Set curl certificate options only if the paths are valid .
apple/turicreate
548ffe9bc59e1ab2b9352ccdbe43af284f38c7f2
2018-01-18T22:34:23Z
mmm a / src / js / math . js <nl> ppp b / src / js / math . js <nl> function MathTrunc ( x ) { <nl> return x ; <nl> } <nl> <nl> - / / ES6 draft 09 - 27 - 13 , section 20 . 2 . 2 . 33 . <nl> - function MathTanh ( x ) { <nl> - x = TO_NUMBER ( x ) ; <nl> - / / Idempotent for + / - 0 . <nl> - if ( x = = = 0 ) return x ; <nl> - / / Returns + / - 1 for + / - Infinity . <nl> - if ( ! NUMBER_IS_FINITE ( x ) ) return MathSign ( x ) ; <nl> - var exp1 = MathExp ( x ) ; <nl> - var exp2 = MathExp ( - x ) ; <nl> - return ( exp1 - exp2 ) / ( exp1 + exp2 ) ; <nl> - } <nl> - <nl> / / ES6 draft 09 - 27 - 13 , section 20 . 2 . 2 . 5 . <nl> function MathAsinh ( x ) { <nl> x = TO_NUMBER ( x ) ; <nl> utils . InstallFunctions ( GlobalMath , DONT_ENUM , [ <nl> " imul " , MathImul , <nl> " sign " , MathSign , <nl> " trunc " , MathTrunc , <nl> - " tanh " , MathTanh , <nl> " asinh " , MathAsinh , <nl> " acosh " , MathAcosh , <nl> " atanh " , MathAtanh , <nl> mmm a / src / third_party / fdlibm / fdlibm . js <nl> ppp b / src / third_party / fdlibm / fdlibm . js <nl> function MathCosh ( x ) { <nl> return INFINITY ; <nl> } <nl> <nl> + / / ES6 draft 09 - 27 - 13 , section 20 . 2 . 2 . 33 . <nl> + / / Math . tanh ( x ) <nl> + / / Method : <nl> + / / x - x <nl> + / / e - e <nl> + / / 0 . tanh ( x ) is defined to be mmmmmmmmm - - <nl> + / / x - x <nl> + / / e + e <nl> + / / 1 . reduce x to non - negative by tanh ( - x ) = - tanh ( x ) . <nl> + / / 2 . 0 < = x < = 2 * * - 55 : tanh ( x ) : = x * ( one + x ) <nl> + / / - t <nl> + / / 2 * * - 55 < x < = 1 : tanh ( x ) : = mmm - - ; t = expm1 ( - 2x ) <nl> + / / t + 2 <nl> + / / 2 <nl> + / / 1 < = x < = 22 . 0 : tanh ( x ) : = 1 - mmm - - ; t = expm1 ( 2x ) <nl> + / / t + 2 <nl> + / / 22 . 0 < x < = INF : tanh ( x ) : = 1 . <nl> + / / <nl> + / / Special cases : <nl> + / / tanh ( NaN ) is NaN ; <nl> + / / only tanh ( 0 ) = 0 is exact for finite argument . <nl> + / / <nl> + <nl> + define TWO_M55 = 2 . 77555756156289135105e - 17 ; / / 2 ^ - 55 , empty lower half <nl> + <nl> + function MathTanh ( x ) { <nl> + x = x * 1 ; / / Convert to number . <nl> + / / x is Infinity or NaN <nl> + if ( ! NUMBER_IS_FINITE ( x ) ) { <nl> + if ( x > 0 ) return 1 ; <nl> + if ( x < 0 ) return - 1 ; <nl> + return x ; <nl> + } <nl> + <nl> + var ax = MathAbs ( x ) ; <nl> + var z ; <nl> + / / | x | < 22 <nl> + if ( ax < 22 ) { <nl> + if ( ax < TWO_M55 ) { <nl> + / / | x | < 2 ^ - 55 , tanh ( small ) = small . <nl> + return x ; <nl> + } <nl> + if ( ax > = 1 ) { <nl> + / / | x | > = 1 <nl> + var t = MathExpm1 ( 2 * ax ) ; <nl> + z = 1 - 2 / ( t + 2 ) ; <nl> + } else { <nl> + var t = MathExpm1 ( - 2 * ax ) ; <nl> + z = - t / ( t + 2 ) ; <nl> + } <nl> + } else { <nl> + / / | x | > 22 , return + / - 1 <nl> + z = 1 ; <nl> + } <nl> + return ( x > = 0 ) ? z : - z ; <nl> + } <nl> + <nl> / / ES6 draft 09 - 27 - 13 , section 20 . 2 . 2 . 21 . <nl> / / Return the base 10 logarithm of x <nl> / / <nl> utils . InstallFunctions ( GlobalMath , DONT_ENUM , [ <nl> " tan " , MathTan , <nl> " sinh " , MathSinh , <nl> " cosh " , MathCosh , <nl> + " tanh " , MathTanh , <nl> " log10 " , MathLog10 , <nl> " log2 " , MathLog2 , <nl> " log1p " , MathLog1p , <nl> mmm a / test / mjsunit / es6 / math - hyperbolic . js <nl> ppp b / test / mjsunit / es6 / math - hyperbolic . js <nl> assertEquals ( 1 . 7976931348621744e308 , Math . cosh ( - 710 . 4758600739439 ) ) ; <nl> / / Overflow . <nl> assertEquals ( Infinity , Math . cosh ( 710 . 475860073944 ) ) ; <nl> assertEquals ( Infinity , Math . cosh ( - 710 . 475860073944 ) ) ; <nl> + <nl> + / / Implementation - specific tests for tanh . <nl> + / / Case | x | < 2 ^ - 55 <nl> + var two_56 = Math . pow ( 2 , - 56 ) ; <nl> + assertEquals ( two_56 , Math . tanh ( two_56 ) ) ; <nl> + assertEquals ( - two_56 , Math . tanh ( - two_56 ) ) ; <nl> + / / Case | x | < 1 <nl> + assertEquals ( 0 . 6 , Math . tanh ( Math . LN2 ) ) ; <nl> + assertEquals ( - 0 . 6 , Math . tanh ( - Math . LN2 ) ) ; <nl> + / / Case 1 < | x | < 22 <nl> + assertEquals ( 15 / 17 , Math . tanh ( 2 * Math . LN2 ) ) ; <nl> + assertEquals ( - 15 / 17 , Math . tanh ( - 2 * Math . LN2 ) ) ; <nl> + / / Case | x | > 22 <nl> + assertEquals ( 1 , Math . tanh ( 100 ) ) ; <nl> + assertEquals ( - 1 , Math . tanh ( - 100 ) ) ; <nl> + / / Test against overflow <nl> + assertEquals ( 1 , Math . tanh ( 1e300 ) ) ; <nl> + assertEquals ( - 1 , Math . tanh ( - 1e300 ) ) ; <nl>
Implement Math . tanh using fdlibm port .
v8/v8
47c9e1c904050f82c4e527c5f86fc287856cdd3c
2015-10-16T12:56:37Z
mmm a / MachineLearning / cn / ComputationNetwork . h <nl> ppp b / MachineLearning / cn / ComputationNetwork . h <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> newNode = new SigmoidNode < ElemType > ( fstream , modelVersion , m_deviceId , nodeName ) ; <nl> else if ( nodeType = = TanhNode < ElemType > : : TypeName ( ) ) <nl> newNode = new TanhNode < ElemType > ( fstream , modelVersion , m_deviceId , nodeName ) ; <nl> + else if ( nodeType = = ExpNode < ElemType > : : TypeName ( ) ) <nl> + newNode = new ExpNode < ElemType > ( fstream , modelVersion , m_deviceId , nodeName ) ; <nl> else if ( nodeType = = LogNode < ElemType > : : TypeName ( ) ) <nl> newNode = new LogNode < ElemType > ( fstream , modelVersion , m_deviceId , nodeName ) ; <nl> else if ( nodeType = = CosineNode < ElemType > : : TypeName ( ) ) <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> newNode = new SigmoidNode < ElemType > ( m_deviceId , nodeName ) ; <nl> else if ( nodeType = = TanhNode < ElemType > : : TypeName ( ) ) <nl> newNode = new TanhNode < ElemType > ( m_deviceId , nodeName ) ; <nl> + else if ( nodeType = = ExpNode < ElemType > : : TypeName ( ) ) <nl> + newNode = new ExpNode < ElemType > ( m_deviceId , nodeName ) ; <nl> else if ( nodeType = = LogNode < ElemType > : : TypeName ( ) ) <nl> newNode = new LogNode < ElemType > ( m_deviceId , nodeName ) ; <nl> else if ( nodeType = = CosineNode < ElemType > : : TypeName ( ) ) <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> return newNode ; <nl> } <nl> <nl> - ComputationNodePtr Log ( const ComputationNodePtr a , const std : : wstring nodeName = L " " ) <nl> + ComputationNodePtr Exp ( const ComputationNodePtr a , const std : : wstring nodeName = L " " ) <nl> + { <nl> + ComputationNodePtr newNode ( new ExpNode < ElemType > ( m_deviceId , nodeName ) ) ; <nl> + newNode - > AttachInputs ( a ) ; <nl> + AddNodeToNet ( newNode ) ; <nl> + return newNode ; <nl> + } <nl> + <nl> + ComputationNodePtr Log ( const ComputationNodePtr a , const std : : wstring nodeName = L " " ) <nl> { <nl> ComputationNodePtr newNode ( new LogNode < ElemType > ( m_deviceId , nodeName ) ) ; <nl> newNode - > AttachInputs ( a ) ; <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> <nl> void ClearCalcOrderCaches ( ) <nl> { <nl> + for ( std : : map < const ComputationNodePtr , std : : list < ComputationNodePtr > > : : iterator it = m_cacheEvalOrders . begin ( ) ; it ! = m_cacheEvalOrders . end ( ) ; + + it ) <nl> + { <nl> + for ( auto iter2 = m_cacheEvalOrders [ it - > first ] . begin ( ) ; iter2 ! = m_cacheEvalOrders [ it - > first ] . end ( ) ; iter2 + + ) <nl> + { <nl> + ( * iter2 ) - > clearCache ( ) ; <nl> + } <nl> + } <nl> m_cacheEvalOrders . clear ( ) ; <nl> m_cacheGradientCalcOrders . clear ( ) ; <nl> } <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> void FormRecurentLoops ( const ComputationNodePtr rootNode ) <nl> { <nl> std : : vector < ComputationNodePtr > sourceLoopNodes ; <nl> + <nl> getStrongSCC ( rootNode ) ; <nl> std : : list < ComputationNodePtr > & nodes = GetEvalOrder ( rootNode , sourceLoopNodes ) ; <nl> std : : list < ComputationNodePtr > nodesForGrad ; <nl> mmm a / MachineLearning / cn / ComputationNode . h <nl> ppp b / MachineLearning / cn / ComputationNode . h <nl> namespace Microsoft { namespace MSR { namespace CNTK { <nl> m_indexInLoop = index ; <nl> } <nl> <nl> + void clearCache ( ) <nl> + { <nl> + m_loopId = - 1 ; <nl> + m_visitedOrder = - 1 ; <nl> + m_index = - 1 ; <nl> + m_lowlink = - 1 ; <nl> + m_indexInLoop = 0 ; <nl> + m_visited = false ; <nl> + m_inStack = false ; <nl> + } <nl> size_t GetIndex ( ) <nl> { <nl> return m_index ; <nl> mmm a / MachineLearning / cn / NetworkDescriptionLanguage . cpp <nl> ppp b / MachineLearning / cn / NetworkDescriptionLanguage . cpp <nl> bool CheckFunction ( std : : string & p_nodeType , bool * allowUndeterminedVariable ) <nl> ret = true ; <nl> else if ( EqualInsensitive ( nodeType , TanhNode < ElemType > : : TypeName ( ) ) ) <nl> ret = true ; <nl> + else if ( EqualInsensitive ( nodeType , ExpNode < ElemType > : : TypeName ( ) ) ) <nl> + ret = true ; <nl> else if ( EqualInsensitive ( nodeType , LogNode < ElemType > : : TypeName ( ) ) ) <nl> ret = true ; <nl> else if ( EqualInsensitive ( nodeType , CosineNode < ElemType > : : TypeName ( ) , L " Cos " ) ) <nl> mmm a / MachineLearning / cn / PTaskGraphBuilder . cpp <nl> ppp b / MachineLearning / cn / PTaskGraphBuilder . cpp <nl> void PTaskGraphBuilder < ElemType > : : CreateTaskDescriptorsForComputationNodes ( ) <nl> opName = = ElementTimesNode < ElemType > : : TypeName ( ) | | <nl> opName = = DiagTimesNode < ElemType > : : TypeName ( ) | | <nl> opName = = DropoutNode < ElemType > : : TypeName ( ) | | <nl> + opName = = ExpNode < ElemType > : : TypeName ( ) | | <nl> opName = = LogNode < ElemType > : : TypeName ( ) | | <nl> opName = = CosineNode < ElemType > : : TypeName ( ) | | <nl> opName = = MinusNode < ElemType > : : TypeName ( ) | | <nl>
Merge remote - tracking branch ' origin / master ' into linux - gcc
microsoft/CNTK
d873d8b82d257e3a2ca818d00c4ab7aa42d84c59
2015-01-23T20:35:11Z
mmm a / cocos2dx / base_nodes / CCNode . cpp <nl> ppp b / cocos2dx / base_nodes / CCNode . cpp <nl> void Node : : associateEventListener ( EventListener * listener ) <nl> <nl> void Node : : dissociateEventListener ( EventListener * listener ) <nl> { <nl> - auto foundIter = _eventlisteners . find ( listener ) ; <nl> - if ( foundIter ! = _eventlisteners . end ( ) ) <nl> - { <nl> - ( * foundIter ) - > _type = " " ; <nl> - _eventlisteners . erase ( listener ) ; <nl> - } <nl> + _eventlisteners . erase ( listener ) ; <nl> } <nl> <nl> void Node : : removeAllEventListeners ( ) <nl>
Don ' t set listener type to " " when dissociateEventListener .
cocos2d/cocos2d-x
c22315a19c5f73a30a079527b21dde84cbadaf77
2013-09-20T06:36:15Z
mmm a / web / samples / CMakeLists . txt <nl> ppp b / web / samples / CMakeLists . txt <nl> foreach ( NAME $ { HTML_FILES } ) <nl> list ( APPEND DEMO_ASSETS $ { SERVER_DIR } / $ { NAME } ) <nl> endforeach ( ) <nl> <nl> - set ( TEXTURE_FILES floor_ao_roughness_metallic . png floor_basecolor . png floor_normal . png ) <nl> + set ( TEXTURE_FILES floor_ao_roughness_metallic . png floor_basecolor . jpg floor_normal . png ) <nl> foreach ( NAME $ { TEXTURE_FILES } ) <nl> add_custom_command ( <nl> OUTPUT $ { SERVER_DIR } / $ { NAME } <nl> mmm a / web / samples / parquet . html <nl> ppp b / web / samples / parquet . html <nl> <nl> ' parquet . filamat ' , <nl> ' shader_ball . filamesh ' , <nl> ' floor_ao_roughness_metallic . png ' , <nl> - ' floor_basecolor . png ' , <nl> + ' floor_basecolor . jpg ' , <nl> ' floor_normal . png ' , <nl> iblfile , skyfile <nl> ] , ( ) = > { <nl> <nl> Filament . WrapMode . REPEAT ) ; <nl> <nl> const ao = engine . createTextureFromPng ( ' floor_ao_roughness_metallic . png ' ) ; <nl> - const basecolor = engine . createTextureFromPng ( ' floor_basecolor . png ' , { ' srgb ' : true } ) ; <nl> + const basecolor = engine . createTextureFromJpeg ( ' floor_basecolor . jpg ' , { ' srgb ' : true } ) ; <nl> const normal = engine . createTextureFromPng ( ' floor_normal . png ' ) ; <nl> matinstance . setTextureParameter ( ' aoRoughnessMetallic ' , ao , sampler ) <nl> matinstance . setTextureParameter ( ' baseColor ' , basecolor , sampler ) <nl> new file mode 100644 <nl> index 000000000 . . 7333a714d <nl> Binary files / dev / null and b / web / samples / textures / floor_basecolor . jpg differ <nl>
Exercise JPG decoding in web samples .
google/filament
491d16a4e52d0ad7061af1e316950ca66286b156
2020-01-21T20:58:46Z
mmm a / imgui_draw . cpp <nl> ppp b / imgui_draw . cpp <nl> void ImGui : : StyleColorsDark ( ImGuiStyle * dst ) <nl> colors [ ImGuiCol_HeaderHovered ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 0 . 80f ) ; <nl> colors [ ImGuiCol_HeaderActive ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 1 . 00f ) ; <nl> colors [ ImGuiCol_Separator ] = colors [ ImGuiCol_Border ] ; / / ImVec4 ( 0 . 61f , 0 . 61f , 0 . 61f , 1 . 00f ) ; <nl> - colors [ ImGuiCol_SeparatorHovered ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 0 . 78f ) ; <nl> - colors [ ImGuiCol_SeparatorActive ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 1 . 00f ) ; <nl> + colors [ ImGuiCol_SeparatorHovered ] = ImVec4 ( 0 . 10f , 0 . 40f , 0 . 75f , 0 . 78f ) ; <nl> + colors [ ImGuiCol_SeparatorActive ] = ImVec4 ( 0 . 10f , 0 . 40f , 0 . 75f , 1 . 00f ) ; <nl> colors [ ImGuiCol_ResizeGrip ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 0 . 25f ) ; <nl> colors [ ImGuiCol_ResizeGripHovered ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 0 . 67f ) ; <nl> colors [ ImGuiCol_ResizeGripActive ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 0 . 95f ) ; <nl> void ImGui : : StyleColorsLight ( ImGuiStyle * dst ) <nl> / / colors [ ImGuiCol_TextActive ] = ImVec4 ( 1 . 00f , 1 . 00f , 0 . 00f , 1 . 00f ) ; <nl> colors [ ImGuiCol_WindowBg ] = ImVec4 ( 0 . 94f , 0 . 94f , 0 . 94f , 1 . 00f ) ; <nl> colors [ ImGuiCol_ChildBg ] = ImVec4 ( 0 . 00f , 0 . 00f , 0 . 00f , 0 . 00f ) ; <nl> - colors [ ImGuiCol_PopupBg ] = ImVec4 ( 1 . 00f , 1 . 00f , 1 . 00f , 0 . 94f ) ; <nl> + colors [ ImGuiCol_PopupBg ] = ImVec4 ( 1 . 00f , 1 . 00f , 1 . 00f , 0 . 98f ) ; <nl> colors [ ImGuiCol_Border ] = ImVec4 ( 0 . 00f , 0 . 00f , 0 . 00f , 0 . 30f ) ; <nl> colors [ ImGuiCol_BorderShadow ] = ImVec4 ( 0 . 00f , 0 . 00f , 0 . 00f , 0 . 00f ) ; <nl> colors [ ImGuiCol_FrameBg ] = ImVec4 ( 1 . 00f , 1 . 00f , 1 . 00f , 1 . 00f ) ; <nl> void ImGui : : StyleColorsLight ( ImGuiStyle * dst ) <nl> colors [ ImGuiCol_HeaderHovered ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 0 . 80f ) ; <nl> colors [ ImGuiCol_HeaderActive ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 1 . 00f ) ; <nl> colors [ ImGuiCol_Separator ] = ImVec4 ( 0 . 39f , 0 . 39f , 0 . 39f , 1 . 00f ) ; <nl> - colors [ ImGuiCol_SeparatorHovered ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 0 . 78f ) ; <nl> - colors [ ImGuiCol_SeparatorActive ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 1 . 00f ) ; <nl> + colors [ ImGuiCol_SeparatorHovered ] = ImVec4 ( 0 . 14f , 0 . 44f , 0 . 80f , 0 . 78f ) ; <nl> + colors [ ImGuiCol_SeparatorActive ] = ImVec4 ( 0 . 14f , 0 . 44f , 0 . 80f , 1 . 00f ) ; <nl> colors [ ImGuiCol_ResizeGrip ] = ImVec4 ( 0 . 80f , 0 . 80f , 0 . 80f , 0 . 56f ) ; <nl> colors [ ImGuiCol_ResizeGripHovered ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 0 . 67f ) ; <nl> colors [ ImGuiCol_ResizeGripActive ] = ImVec4 ( 0 . 26f , 0 . 59f , 0 . 98f , 0 . 95f ) ; <nl>
Style : Tweaks Dark and Light styles . ( )
ocornut/imgui
aea3fe41b9a3dea659b92f50215be2b6b104bb68
2017-11-30T22:15:55Z
mmm a / docs / apollo_2 . 5_technical_tutorial . md <nl> ppp b / docs / apollo_2 . 5_technical_tutorial . md <nl> <nl> # # Overview <nl> > Learn Apollo basic concepts and Apollo 2 . 5 quick start <nl> <nl> - - [ Apollo 2 . 5 quick start ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_2_5_quick_start . md " Apollo 2 . 5 quick start " ) <nl> + * [ Apollo 2 . 5 quick start ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_2_5_quick_start . md " Apollo 2 . 5 quick start " ) <nl> <nl> # # Hardware system installation <nl> > Learn the procedure of Apollo 2 . 5 hardware system installation <nl> <nl> - - [ Apollo 2 . 5 hardware system installation guide ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_2_5_hardware_system_installation_guide_v1 . md " Apollo 2 . 5 hardware system installation guide " ) <nl> + * [ Apollo 2 . 5 hardware system installation guide ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_2_5_hardware_system_installation_guide_v1 . md " Apollo 2 . 5 hardware system installation guide " ) <nl> <nl> # # Calibration <nl> > Learn the process of the calibration service <nl> <nl> - - [ Calibration guide between LiDAR and INS ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_1_5_lidar_calibration_guide . md " Calibration guide between LiDAR and INS " ) <nl> - - [ Guide for Camera - to - Camera calibration , Camera - to - LiDAR calibration , Radar - to - Camera calibration , IMU - to - Vehicle calibration ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_2_0_sensor_calibration_guide . md " Guide for Camera - to - Camera Calibration , Camera - to - LiDAR Calibration , Radar - to - Camera Calibration , IMU - to - Vehicle Calibration " ) <nl> - - [ Multiple - LiDAR GNSS calibration guide ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / multiple_lidar_gnss_calibration_guide . md " Multiple - LiDAR GNSS calibration guide " ) <nl> - - [ Apollo coordination ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / coordination . pdf " Apollo coordination " ) <nl> + * [ Calibration guide between LiDAR and INS ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_1_5_lidar_calibration_guide . md " Calibration guide between LiDAR and INS " ) <nl> + * [ Guide for Camera - to - Camera calibration , Camera - to - LiDAR calibration , Radar - to - Camera calibration , IMU - to - Vehicle calibration ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_2_0_sensor_calibration_guide . md " Guide for Camera - to - Camera Calibration , Camera - to - LiDAR Calibration , Radar - to - Camera Calibration , IMU - to - Vehicle Calibration " ) <nl> + * [ Multiple - LiDAR GNSS calibration guide ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / multiple_lidar_gnss_calibration_guide . md " Multiple - LiDAR GNSS calibration guide " ) <nl> + * [ Apollo coordination ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / coordination . pdf " Apollo coordination " ) <nl> <nl> <nl> # # Software installation <nl> > Learn the procedure of Apollo 2 . 5 software system installation <nl> <nl> - - [ Apollo software installation guide ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_software_installation_guide . md " Apollo software installation guide " ) <nl> - - [ How to Debug a Dreamview Start Problem ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_debug_dreamview_start_problem . md ) <nl> - - [ Run offline demo ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / demo_guide / README . md " Run offline demo " ) <nl> + * [ Apollo software installation guide ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_software_installation_guide . md " Apollo software installation guide " ) <nl> + * [ How to Debug a Dreamview Start Problem ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_debug_dreamview_start_problem . md ) <nl> + * [ Run offline demo ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / demo_guide / README . md " Run offline demo " ) <nl> <nl> <nl> # # Software architecture and principles <nl> > Learn Apollo software architecture and principles of core modules <nl> <nl> - - [ Apollo software architecture ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / Apollo_2 . 0_Software_Architecture . md " Apollo software architecture " ) <nl> - - [ 3D Obstacle Perception ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / 3d_obstacle_perception . md ) <nl> - - [ Apollo 2 . 5 Perception ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / perception_apollo_2 . 5 . md ) <nl> - - [ QP - Spline - Path Optimizer ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / qp_spline_path_optimizer . md ) <nl> - - [ QP - Spline - ST - Speed Optimizer ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / qp_spline_st_speed_optimizer . md ) <nl> - - [ Reference Line Smoother ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / reference_line_smoother . md ) <nl> - - [ Traffic Light Perception ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / traffic_light . md ) <nl> + * [ Apollo software architecture ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / Apollo_2 . 0_Software_Architecture . md " Apollo software architecture " ) <nl> + * [ 3D Obstacle Perception ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / 3d_obstacle_perception . md ) <nl> + * [ Apollo 2 . 5 Perception ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / perception_apollo_2 . 5 . md ) <nl> + * [ QP - Spline - Path Optimizer ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / qp_spline_path_optimizer . md ) <nl> + * [ QP - Spline - ST - Speed Optimizer ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / qp_spline_st_speed_optimizer . md ) <nl> + * [ Reference Line Smoother ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / reference_line_smoother . md ) <nl> + * [ Traffic Light Perception ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / traffic_light . md ) <nl> <nl> <nl> # # Software modules and extension <nl> > Learn Apollo software modules and extension <nl> <nl> - - [ Canbus module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / canbus / README . md ) <nl> - - [ Common module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / common / README . md ) <nl> - - [ Control module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / control / README . md ) <nl> - - [ Data module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / data / README . md ) <nl> - - [ Localization module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / localization / README . md ) <nl> - - [ Perception module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / perception / README . md ) <nl> - - [ Planning module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / planning / README . md ) <nl> - - [ Prediction module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / prediction / README . md ) <nl> - - [ Routing module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / routing / README . md ) <nl> - <nl> - - [ How to Add a New GPS Receiver ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_gps_receiver . md " How to add a new GPS Receiver " ) <nl> - - [ How to Add a New CAN Card ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_new_can_card . md " How to Add a New CAN Card " ) <nl> - - [ How to Add a New Control Algorithm ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_new_control_algorithm . md " How to Add a New Control Algorithm " ) <nl> - - [ How to Add a New Evaluator in Prediction Module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_new_evaluator_in_prediction_module . md ) <nl> - - [ How to Add a New Predictor in Prediction Module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_new_predictor_in_prediction_module . md ) <nl> - - [ How to Add a New Vehicle ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_new_vehicle . md ) <nl> - - [ How to Add a New External Dependency ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_an_external_dependency . md ) <nl> + * [ Canbus module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / canbus / README . md ) <nl> + * [ Common module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / common / README . md ) <nl> + * [ Control module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / control / README . md ) <nl> + * [ Data module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / data / README . md ) <nl> + * [ Localization module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / localization / README . md ) <nl> + * [ Perception module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / perception / README . md ) <nl> + * [ Planning module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / planning / README . md ) <nl> + * [ Prediction module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / prediction / README . md ) <nl> + * [ Routing module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / modules / routing / README . md ) <nl> + <nl> + * [ How to Add a New GPS Receiver ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_gps_receiver . md " How to add a new GPS Receiver " ) <nl> + * [ How to Add a New CAN Card ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_new_can_card . md " How to Add a New CAN Card " ) <nl> + * [ How to Add a New Control Algorithm ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_new_control_algorithm . md " How to Add a New Control Algorithm " ) <nl> + * [ How to Add a New Evaluator in Prediction Module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_new_evaluator_in_prediction_module . md ) <nl> + * [ How to Add a New Predictor in Prediction Module ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_new_predictor_in_prediction_module . md ) <nl> + * [ How to Add a New Vehicle ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_a_new_vehicle . md ) <nl> + * [ How to Add a New External Dependency ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_add_an_external_dependency . md ) <nl> <nl> <nl> # # Developer - Friendliness <nl> > Learn Apollo developer tools <nl> <nl> - - [ Apollo 2 . 5 map collection guide ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_2_5_map_collection_guide . md " Apollo 2 . 5 map collection guide " ) <nl> - - [ How to build and debug Apollo in VSCode ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_build_and_debug_apollo_in_vscode_cn . md " How to build and debug Apollo in VSCode " ) <nl> - - [ How to use Apollo 2 . 5 navigation mode ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_use_apollo_2 . 5_navigation_mode_cn . md " [ How to use Apollo 2 . 5 navigation mode " ) <nl> - - [ Introduction of Dreamview ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / dreamview_usage_table . md " Introduction of Dreamview " ) <nl> + * [ Apollo 2 . 5 map collection guide ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / quickstart / apollo_2_5_map_collection_guide . md " Apollo 2 . 5 map collection guide " ) <nl> + * [ How to build and debug Apollo in VSCode ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_build_and_debug_apollo_in_vscode_cn . md " How to build and debug Apollo in VSCode " ) <nl> + * [ How to use Apollo 2 . 5 navigation mode ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / howto / how_to_use_apollo_2 . 5_navigation_mode_cn . md " [ How to use Apollo 2 . 5 navigation mode " ) <nl> + * [ Introduction of Dreamview ] ( https : / / github . com / ApolloAuto / apollo / blob / master / docs / specs / dreamview_usage_table . md " Introduction of Dreamview " ) <nl> <nl> <nl>
Update apollo_2 . 5_technical_tutorial . md
ApolloAuto/apollo
74db7022d95a9208136f43940a460043addbfb66
2018-05-03T05:35:17Z
mmm a / cd / Jenkinsfile_release_job <nl> ppp b / cd / Jenkinsfile_release_job <nl> pipeline { <nl> parameters { <nl> / / Release parameters <nl> string ( defaultValue : " Generic release job " , description : " Optional Job name " , name : " RELEASE_JOB_NAME " ) <nl> - string ( defaultValue : " " , description : " Job Type e . g . binary_release / static , python / docker , runtime_images , etc . " , name : ' RELEASE_JOB_TYPE ' ) <nl> + choice ( choices : [ " mxnet_lib / static " ] , description : " Pipeline to build " , name : " RELEASE_JOB_TYPE " ) <nl> string ( defaultValue : " cpu , mkl , cu80 , cu80mkl , cu90 , cu90mkl , cu92 , cu92mkl , cu100 , cu100mkl " , description : " Comma separated list of variants " , name : " MXNET_VARIANTS " ) <nl> booleanParam ( defaultValue : false , description : ' Whether this is a release build or not ' , name : " RELEASE_BUILD " ) <nl> } <nl>
Updates job type parameter to dropdown
apache/incubator-mxnet
749492fb7f646a6b2055193b69f855939bc94bd5
2019-08-30T02:52:54Z
mmm a / modules / mono / editor / GodotTools / GodotTools / Ides / Rider / RiderPathLocator . cs <nl> ppp b / modules / mono / editor / GodotTools / GodotTools / Ides / Rider / RiderPathLocator . cs <nl> private static string GetRelativePathToBuildTxt ( ) <nl> <nl> private static void CollectPathsFromRegistry ( string registryKey , List < string > installPaths ) <nl> { <nl> + using ( var key = Registry . CurrentUser . OpenSubKey ( registryKey ) ) <nl> + { <nl> + CollectPathsFromRegistry ( installPaths , key ) ; <nl> + } <nl> using ( var key = Registry . LocalMachine . OpenSubKey ( registryKey ) ) <nl> { <nl> - if ( key = = null ) return ; <nl> - foreach ( var subkeyName in key . GetSubKeyNames ( ) . Where ( a = > a . Contains ( " Rider " ) ) ) <nl> + CollectPathsFromRegistry ( installPaths , key ) ; <nl> + } <nl> + } <nl> + <nl> + private static void CollectPathsFromRegistry ( List < string > installPaths , RegistryKey key ) <nl> + { <nl> + if ( key = = null ) return ; <nl> + foreach ( var subkeyName in key . GetSubKeyNames ( ) . Where ( a = > a . Contains ( " Rider " ) ) ) <nl> + { <nl> + using ( var subkey = key . OpenSubKey ( subkeyName ) ) <nl> { <nl> - using ( var subkey = key . OpenSubKey ( subkeyName ) ) <nl> - { <nl> - var folderObject = subkey ? . GetValue ( " InstallLocation " ) ; <nl> - if ( folderObject = = null ) continue ; <nl> - var folder = folderObject . ToString ( ) ; <nl> - var possiblePath = Path . Combine ( folder , @ " bin \ rider64 . exe " ) ; <nl> - if ( File . Exists ( possiblePath ) ) <nl> - installPaths . Add ( possiblePath ) ; <nl> - } <nl> + var folderObject = subkey ? . GetValue ( " InstallLocation " ) ; <nl> + if ( folderObject = = null ) continue ; <nl> + var folder = folderObject . ToString ( ) ; <nl> + var possiblePath = Path . Combine ( folder , @ " bin \ rider64 . exe " ) ; <nl> + if ( File . Exists ( possiblePath ) ) <nl> + installPaths . Add ( possiblePath ) ; <nl> } <nl> } <nl> } <nl>
On Windows find Rider installed for CurrentUser
godotengine/godot
c95e20a089b7ef1bcc2bd0955bbb7504fdd5729f
2020-02-28T20:34:20Z
mmm a / tests / restarting / from_7 . 0 . 0 / SnapIncrementalRestore - 1 . toml <nl> ppp b / tests / restarting / from_7 . 0 . 0 / SnapIncrementalRestore - 1 . toml <nl> <nl> - [ [ test ] ] <nl> - testTitle = ' PresetValue ' <nl> - clearAfterTest = false <nl> - <nl> - [ [ test . workload ] ] <nl> - testName = ' SimpleAtomicAdd ' <nl> - initialize = true <nl> - initialValue = 0 <nl> - iterations = 0 <nl> - <nl> [ [ test ] ] <nl> testTitle = ' SubmitBackup ' <nl> simBackupAgents = ' BackupToFile ' <nl>
remove preset value in test spec
apple/foundationdb
176fbd6a16012cce3d8c7b9c56b981e9eef66e2d
2020-09-28T21:37:17Z
mmm a / docs / api / browser - window . md <nl> ppp b / docs / api / browser - window . md <nl> Removes focus from the window . <nl> <nl> Returns a boolean , whether the window is focused . <nl> <nl> + # # # # ` win . isDestroyed ( ) ` <nl> + <nl> + Returns a boolean , whether the window is destroyed . <nl> + <nl> # # # # ` win . show ( ) ` <nl> <nl> Shows and gives focus to the window . <nl> mmm a / docs / api / web - contents . md <nl> ppp b / docs / api / web - contents . md <nl> Emitted when the cursor ' s type changes . The ` type ` parameter can be ` default ` , <nl> ` not - allowed ` , ` zoom - in ` , ` zoom - out ` , ` grab ` , ` grabbing ` , ` custom ` . <nl> <nl> If the ` type ` parameter is ` custom ` , the ` image ` parameter will hold the custom <nl> - cursor image in a ` NativeImage ` , and ` scale ` , ` size ` and ` hotspot ` will hold <nl> + cursor image in a ` NativeImage ` , and ` scale ` , ` size ` and ` hotspot ` will hold <nl> additional information about the custom cursor . <nl> <nl> # # # # Event : ' context - menu ' <nl> console . log ( currentURL ) <nl> <nl> Returns the title of the current web page . <nl> <nl> + # # # # ` contents . isDestroyed ( ) ` <nl> + <nl> + Returns a Boolean , whether the web page is destroyed . <nl> + <nl> # # # # ` contents . isFocused ( ) ` <nl> <nl> Returns a Boolean , whether the web page is focused . <nl>
Mark isDestroyed as public on BrowserWindow / WebContents
electron/electron
05ab7d39ad06d19dc5a1581118ee551bc5be612a
2016-08-03T21:58:22Z
mmm a / src / video_core / renderer_opengl / gl_rasterizer_cache . cpp <nl> ppp b / src / video_core / renderer_opengl / gl_rasterizer_cache . cpp <nl> <nl> # include " video_core / engines / maxwell_3d . h " <nl> # include " video_core / renderer_opengl / gl_rasterizer_cache . h " <nl> # include " video_core / renderer_opengl / gl_state . h " <nl> + # include " video_core / textures / decoders . h " <nl> # include " video_core / utils . h " <nl> # include " video_core / video_core . h " <nl> <nl> struct FormatTuple { <nl> GLint internal_format ; <nl> GLenum format ; <nl> GLenum type ; <nl> + bool compressed ; <nl> + / / How many pixels in the original texture are equivalent to one pixel in the compressed <nl> + / / texture . <nl> + u32 compression_factor ; <nl> } ; <nl> <nl> - static constexpr std : : array < FormatTuple , 5 > fb_format_tuples = { { <nl> - { GL_RGBA8 , GL_RGBA , GL_UNSIGNED_INT_8_8_8_8 } , / / RGBA8 <nl> - { GL_RGB8 , GL_BGR , GL_UNSIGNED_BYTE } , / / RGB8 <nl> - { GL_RGB5_A1 , GL_RGBA , GL_UNSIGNED_SHORT_5_5_5_1 } , / / RGB5A1 <nl> - { GL_RGB565 , GL_RGB , GL_UNSIGNED_SHORT_5_6_5 } , / / RGB565 <nl> - { GL_RGBA4 , GL_RGBA , GL_UNSIGNED_SHORT_4_4_4_4 } , / / RGBA4 <nl> + static constexpr std : : array < FormatTuple , 1 > fb_format_tuples = { { <nl> + { GL_RGBA8 , GL_RGBA , GL_UNSIGNED_INT_8_8_8_8 , false , 1 } , / / RGBA8 <nl> } } ; <nl> <nl> - static constexpr std : : array < FormatTuple , 4 > depth_format_tuples = { { <nl> - { GL_DEPTH_COMPONENT16 , GL_DEPTH_COMPONENT , GL_UNSIGNED_SHORT } , / / D16 <nl> - { } , <nl> - { GL_DEPTH_COMPONENT24 , GL_DEPTH_COMPONENT , GL_UNSIGNED_INT } , / / D24 <nl> - { GL_DEPTH24_STENCIL8 , GL_DEPTH_STENCIL , GL_UNSIGNED_INT_24_8 } , / / D24S8 <nl> + static constexpr std : : array < FormatTuple , 2 > tex_format_tuples = { { <nl> + { GL_RGBA8 , GL_RGBA , GL_UNSIGNED_INT_8_8_8_8 , false , 1 } , / / RGBA8 <nl> + { GL_COMPRESSED_RGB_S3TC_DXT1_EXT , GL_RGB , GL_UNSIGNED_INT_8_8_8_8 , true , 16 } , / / DXT1 <nl> } } ; <nl> <nl> - static constexpr FormatTuple tex_tuple = { GL_RGBA8 , GL_RGBA , GL_UNSIGNED_BYTE } ; <nl> - <nl> static const FormatTuple & GetFormatTuple ( PixelFormat pixel_format ) { <nl> const SurfaceType type = SurfaceParams : : GetFormatType ( pixel_format ) ; <nl> if ( type = = SurfaceType : : Color ) { <nl> ASSERT ( static_cast < size_t > ( pixel_format ) < fb_format_tuples . size ( ) ) ; <nl> return fb_format_tuples [ static_cast < unsigned int > ( pixel_format ) ] ; <nl> } else if ( type = = SurfaceType : : Depth | | type = = SurfaceType : : DepthStencil ) { <nl> - size_t tuple_idx = static_cast < size_t > ( pixel_format ) - 14 ; <nl> - ASSERT ( tuple_idx < depth_format_tuples . size ( ) ) ; <nl> - return depth_format_tuples [ tuple_idx ] ; <nl> + / / TODO ( Subv ) : Implement depth formats <nl> + ASSERT_MSG ( false , " Unimplemented " ) ; <nl> + } else if ( type = = SurfaceType : : Texture ) { <nl> + ASSERT ( static_cast < size_t > ( pixel_format ) < tex_format_tuples . size ( ) ) ; <nl> + return tex_format_tuples [ static_cast < unsigned int > ( pixel_format ) ] ; <nl> } <nl> - return tex_tuple ; <nl> + <nl> + UNREACHABLE ( ) ; <nl> + return { } ; <nl> } <nl> <nl> template < typename Map , typename Interval > <nl> static void MortonCopy ( u32 stride , u32 height , u8 * gl_buffer , VAddr base , VAddr <nl> Memory : : GetPointer ( base ) , gl_buffer , morton_to_gl ) ; <nl> } <nl> <nl> - static constexpr std : : array < void ( * ) ( u32 , u32 , u8 * , VAddr , VAddr , VAddr ) , 18 > morton_to_gl_fns = { <nl> + static constexpr std : : array < void ( * ) ( u32 , u32 , u8 * , VAddr , VAddr , VAddr ) , 2 > morton_to_gl_fns = { <nl> MortonCopy < true , PixelFormat : : RGBA8 > , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> + MortonCopy < true , PixelFormat : : DXT1 > , <nl> } ; <nl> <nl> - static constexpr std : : array < void ( * ) ( u32 , u32 , u8 * , VAddr , VAddr , VAddr ) , 18 > gl_to_morton_fns = { <nl> + static constexpr std : : array < void ( * ) ( u32 , u32 , u8 * , VAddr , VAddr , VAddr ) , 2 > gl_to_morton_fns = { <nl> MortonCopy < false , PixelFormat : : RGBA8 > , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> - nullptr , <nl> + MortonCopy < false , PixelFormat : : DXT1 > , <nl> } ; <nl> <nl> / / Allocate an uninitialized texture of appropriate size and format for the surface <nl> Surface RasterizerCacheOpenGL : : GetSurface ( const SurfaceParams & params , ScaleMatc <nl> if ( expandable ! = nullptr & & expandable - > res_scale > target_res_scale ) { <nl> target_res_scale = expandable - > res_scale ; <nl> } <nl> - / / Keep res_scale when reinterpreting d24s8 - > rgba8 <nl> - if ( params . pixel_format = = PixelFormat : : RGBA8 ) { <nl> - find_params . pixel_format = PixelFormat : : D24S8 ; <nl> - expandable = FindMatch < MatchFlags : : Expand | MatchFlags : : Invalid > ( <nl> - surface_cache , find_params , match_res_scale ) ; <nl> - if ( expandable ! = nullptr & & expandable - > res_scale > target_res_scale ) { <nl> - target_res_scale = expandable - > res_scale ; <nl> - } <nl> - } <nl> } <nl> SurfaceParams new_params = params ; <nl> new_params . res_scale = target_res_scale ; <nl> void RasterizerCacheOpenGL : : ValidateSurface ( const Surface & surface , VAddr addr , <nl> continue ; <nl> } <nl> <nl> - / / D24S8 to RGBA8 <nl> - if ( surface - > pixel_format = = PixelFormat : : RGBA8 ) { <nl> - params . pixel_format = PixelFormat : : D24S8 ; <nl> - Surface reinterpret_surface = <nl> - FindMatch < MatchFlags : : Copy > ( surface_cache , params , ScaleMatch : : Ignore , interval ) ; <nl> - if ( reinterpret_surface ! = nullptr ) { <nl> - ASSERT ( reinterpret_surface - > pixel_format = = PixelFormat : : D24S8 ) ; <nl> - <nl> - SurfaceInterval convert_interval = params . GetCopyableInterval ( reinterpret_surface ) ; <nl> - SurfaceParams convert_params = surface - > FromInterval ( convert_interval ) ; <nl> - auto src_rect = reinterpret_surface - > GetScaledSubRect ( convert_params ) ; <nl> - auto dest_rect = surface - > GetScaledSubRect ( convert_params ) ; <nl> - <nl> - ConvertD24S8toABGR ( reinterpret_surface - > texture . handle , src_rect , <nl> - surface - > texture . handle , dest_rect ) ; <nl> - <nl> - surface - > invalid_regions . erase ( convert_interval ) ; <nl> - continue ; <nl> - } <nl> - } <nl> - <nl> / / Load data from Switch memory <nl> FlushRegion ( params . addr , params . size ) ; <nl> surface - > LoadGLBuffer ( params . addr , params . end ) ; <nl>
GL : Remove remaining references to 3DS - specific pixel formats
yuzu-emu/yuzu
73eaef9c05891fe2d1d6af184d3256b9027d1158
2018-04-07T02:44:42Z
new file mode 100644 <nl> index 00000000000 . . 8439ea8e6f4 <nl> mmm / dev / null <nl> ppp b / ports / cartographer / CONTROL <nl> <nl> + Source : cartographer <nl> + Version : 0 . 3 . 0 - 3 <nl> + Build - Depends : ceres [ eigensparse ] , gflags , glog , lua , cairo , boost - iostreams , gtest , protobuf <nl> + Description : Google 2D & 3D SLAM package <nl> new file mode 100644 <nl> index 00000000000 . . 19694b704f5 <nl> mmm / dev / null <nl> ppp b / ports / cartographer / fix - find - packages . patch <nl> <nl> + CMakeLists . txt | 45 ppppppppppppppppppppp + mmmmmmmmmmmmmmm - <nl> + cartographer / common / math . h | 4 ppp - <nl> + cartographer / common / thread_pool . cc | 2 + - <nl> + cmake / functions . cmake | 10 ppp + mmm - - <nl> + 4 files changed , 35 insertions ( + ) , 26 deletions ( - ) <nl> + <nl> pppmmm a / CMakeLists . txt <nl> ppp + b / CMakeLists . txt <nl> + option ( BUILD_GRPC " build Cartographer gRPC support " false ) <nl> + set ( GRPC_PLUGIN_PATH " / usr / local / bin / grpc_cpp_plugin " ) <nl> + <nl> + include ( " $ { PROJECT_SOURCE_DIR } / cmake / functions . cmake " ) <nl> + - google_initialize_cartographer_project ( ) <nl> + - google_enable_testing ( ) <nl> + + # google_initialize_cartographer_project ( ) <nl> + + # google_enable_testing ( ) <nl> + <nl> + find_package ( Boost REQUIRED COMPONENTS iostreams ) <nl> + find_package ( Ceres REQUIRED COMPONENTS SparseLinearAlgebraLibrary ) <nl> + find_package ( Eigen3 REQUIRED ) <nl> + - find_package ( LuaGoogle REQUIRED ) <nl> + + find_package ( Lua REQUIRED ) <nl> + find_package ( Protobuf 3 . 0 . 0 REQUIRED ) <nl> + + find_package ( glog REQUIRED ) <nl> + + find_package ( gflags REQUIRED ) <nl> + <nl> + - include ( FindPkgConfig ) <nl> + - PKG_SEARCH_MODULE ( CAIRO REQUIRED cairo > = 1 . 12 . 16 ) <nl> + - <nl> + + # include ( FindPkgConfig ) <nl> + + # PKG_SEARCH_MODULE ( CAIRO REQUIRED cairo > = 1 . 12 . 16 ) <nl> + + if ( CMAKE_BUILD_TYPE STREQUAL Debug ) <nl> + + set ( CAIRO_LIB_SUFFIX d ) <nl> + + endif ( ) <nl> + + find_library ( CAIRO_LIBRARY cairo $ { CAIRO_LIB_SUFFIX } ) <nl> + # Only build the documentation if we can find Sphinx . <nl> + find_package ( Sphinx ) <nl> + if ( SPHINX_FOUND ) <nl> + configure_file ( <nl> + $ { PROJECT_SOURCE_DIR } / cartographer / common / config . h . cmake <nl> + $ { PROJECT_BINARY_DIR } / cartographer / common / config . h ) <nl> + <nl> + - google_binary ( cartographer_autogenerate_ground_truth <nl> + - SRCS <nl> + - cartographer / ground_truth / autogenerate_ground_truth_main . cc <nl> + - ) <nl> + - <nl> + - google_binary ( cartographer_compute_relations_metrics <nl> + - SRCS <nl> + - cartographer / ground_truth / compute_relations_metrics_main . cc <nl> + - ) <nl> + + # google_binary ( cartographer_autogenerate_ground_truth <nl> + + # SRCS <nl> + + # cartographer / ground_truth / autogenerate_ground_truth_main . cc <nl> + + # ) <nl> + + # <nl> + + # google_binary ( cartographer_compute_relations_metrics <nl> + + # SRCS <nl> + + # cartographer / ground_truth / compute_relations_metrics_main . cc <nl> + + # ) <nl> + <nl> + if ( $ { BUILD_GRPC } ) <nl> + google_binary ( cartographer_grpc_server <nl> + foreach ( ABS_FIL $ { ALL_TESTS } ) <nl> + get_filename_component ( FIL_WE $ { REL_FIL } NAME_WE ) <nl> + # Replace slashes as required for CMP0037 . <nl> + string ( REPLACE " / " " . " TEST_TARGET_NAME " $ { DIR } / $ { FIL_WE } " ) <nl> + - google_test ( " $ { TEST_TARGET_NAME } " $ { ABS_FIL } ) <nl> + + # google_test ( " $ { TEST_TARGET_NAME } " $ { ABS_FIL } ) <nl> + if ( $ { BUILD_GRPC } ) <nl> + target_link_libraries ( " $ { TEST_TARGET_NAME } " PUBLIC grpc + + ) <nl> + endif ( ) <nl> + target_include_directories ( $ { PROJECT_NAME } SYSTEM PUBLIC <nl> + target_link_libraries ( $ { PROJECT_NAME } PUBLIC $ { Boost_LIBRARIES } ) <nl> + <nl> + # We expect find_package ( Ceres ) to have located these for us . <nl> + - target_link_libraries ( $ { PROJECT_NAME } PUBLIC glog ) <nl> + - target_link_libraries ( $ { PROJECT_NAME } PUBLIC gflags ) <nl> + + # target_link_libraries ( $ { PROJECT_NAME } PUBLIC glog ) <nl> + + # target_link_libraries ( $ { PROJECT_NAME } PUBLIC gflags ) <nl> + + target_link_libraries ( $ { PROJECT_NAME } PUBLIC $ { CAIRO_LIBRARY } ) <nl> + <nl> + target_include_directories ( $ { PROJECT_NAME } SYSTEM PUBLIC <nl> + " $ { CAIRO_INCLUDE_DIRS } " ) <nl> + target_include_directories ( $ { PROJECT_NAME } SYSTEM PUBLIC <nl> + $ { PROTOBUF_INCLUDE_DIR } ) <nl> + # TODO ( hrapp ) : This should not explicitly list pthread and use <nl> + # PROTOBUF_LIBRARIES , but that failed on first try . <nl> + - target_link_libraries ( $ { PROJECT_NAME } PUBLIC $ { PROTOBUF_LIBRARY } pthread ) <nl> + + # target_link_libraries ( $ { PROJECT_NAME } PUBLIC $ { PROTOBUF_LIBRARY } pthread ) <nl> + + target_link_libraries ( $ { PROJECT_NAME } PUBLIC $ { PROTOBUF_LIBRARY } ) <nl> + if ( $ { BUILD_GRPC } ) <nl> + target_link_libraries ( $ { PROJECT_NAME } PUBLIC grpc + + ) <nl> + endif ( ) <nl> pppmmm a / cartographer / common / math . h <nl> ppp + b / cartographer / common / math . h <nl> + <nl> + <nl> + # ifndef CARTOGRAPHER_COMMON_MATH_H_ <nl> + # define CARTOGRAPHER_COMMON_MATH_H_ <nl> + - <nl> + + # ifndef M_PI <nl> + + # define M_PI 3 . 14159265358979323846 <nl> + + # endif <nl> + # include < cmath > <nl> + # include < vector > <nl> + <nl> pppmmm a / cartographer / common / thread_pool . cc <nl> ppp + b / cartographer / common / thread_pool . cc <nl> + <nl> + <nl> + # include " cartographer / common / thread_pool . h " <nl> + <nl> + - # include < unistd . h > <nl> + + / / # include < unistd . h > <nl> + # include < algorithm > <nl> + # include < chrono > <nl> + # include < numeric > <nl> pppmmm a / cmake / functions . cmake <nl> ppp + b / cmake / functions . cmake <nl> + macro ( google_initialize_cartographer_project ) <nl> + set ( LIST_FILES_CMD " find $ { PROJECT_SOURCE_DIR } / - not - iwholename ' * . git * ' | sort | sed ' s / ^ / # / ' " ) <nl> + set ( FILES_LIST_PATH " $ { PROJECT_BINARY_DIR } / AllFiles . cmake " ) <nl> + set ( DETECT_CHANGES_CMD " bash " " - c " " $ { LIST_FILES_CMD } | diff - N - q $ { FILES_LIST_PATH } - | | $ { LIST_FILES_CMD } > $ { FILES_LIST_PATH } " ) <nl> + - add_custom_target ( $ { PROJECT_NAME } _detect_changes ALL <nl> + - COMMAND $ { DETECT_CHANGES_CMD } <nl> + - VERBATIM <nl> + - ) <nl> + + # add_custom_target ( $ { PROJECT_NAME } _detect_changes ALL <nl> + + # COMMAND $ { DETECT_CHANGES_CMD } <nl> + + # VERBATIM <nl> + + # ) <nl> + if ( NOT EXISTS $ { FILES_LIST_PATH } ) <nl> + - execute_process ( COMMAND $ { DETECT_CHANGES_CMD } ) <nl> + + # execute_process ( COMMAND $ { DETECT_CHANGES_CMD } ) <nl> + endif ( ) <nl> + include ( $ { FILES_LIST_PATH } ) <nl> + endmacro ( ) <nl> new file mode 100644 <nl> index 00000000000 . . 49ca1b4b23b <nl> mmm / dev / null <nl> ppp b / ports / cartographer / portfile . cmake <nl> <nl> + include ( vcpkg_common_functions ) <nl> + <nl> + vcpkg_from_github ( <nl> + OUT_SOURCE_PATH SOURCE_PATH <nl> + REPO googlecartographer / cartographer <nl> + REF a7ed7e224f98b396762c865b81b62dc3abea2e81 <nl> + SHA512 2ab167c1c314591b4916baf70b8ad92ae542986c3578319d2454c904adae10f8027bc696579d6e2864d3606a6711563b82438e847527cad4ab0c2bd603a63eb7 <nl> + HEAD_REF master <nl> + ) <nl> + <nl> + vcpkg_apply_patches ( <nl> + SOURCE_PATH $ { SOURCE_PATH } <nl> + PATCHES <nl> + $ { CMAKE_CURRENT_LIST_DIR } / fix - find - packages . patch <nl> + ) <nl> + <nl> + vcpkg_configure_cmake ( <nl> + SOURCE_PATH $ { SOURCE_PATH } <nl> + OPTIONS <nl> + - DGFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION = OFF <nl> + - DGLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION = OFF <nl> + - Dgtest_disable_pthreads = ON <nl> + - DCMAKE_USE_PTHREADS_INIT = OFF <nl> + - DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS = ON <nl> + OPTIONS_DEBUG <nl> + - DFORCE_DEBUG_BUILD = True <nl> + ) <nl> + <nl> + vcpkg_install_cmake ( ) <nl> + <nl> + vcpkg_copy_pdbs ( ) <nl> + <nl> + # Clean <nl> + file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / debug / include ) <nl> + file ( REMOVE_RECURSE $ { CURRENT_PACKAGES_DIR } / debug / share ) <nl> + <nl> + # Handle copyright of cartographer <nl> + file ( COPY $ { SOURCE_PATH } / LICENSE DESTINATION $ { CURRENT_PACKAGES_DIR } / share / cartographer ) <nl> + file ( RENAME $ { CURRENT_PACKAGES_DIR } / share / cartographer / LICENSE $ { CURRENT_PACKAGES_DIR } / share / cartographer / copyright ) <nl>
port for google cartographer ( )
microsoft/vcpkg
d6ff55a735c40a642564fdd472f907ddf8a9b859
2018-02-19T14:46:02Z
mmm a / src / heap / mark - compact . cc <nl> ppp b / src / heap / mark - compact . cc <nl> class RememberedSetUpdatingItem : public UpdatingItem { <nl> <nl> void UpdateUntypedPointers ( ) { <nl> if ( chunk_ - > slot_set < OLD_TO_NEW , AccessMode : : NON_ATOMIC > ( ) ! = nullptr ) { <nl> + InvalidatedSlotsFilter filter = InvalidatedSlotsFilter : : OldToNew ( chunk_ ) ; <nl> RememberedSet < OLD_TO_NEW > : : Iterate ( <nl> chunk_ , <nl> - [ this ] ( MaybeObjectSlot slot ) { <nl> + [ this , & filter ] ( MaybeObjectSlot slot ) { <nl> + CHECK ( filter . IsValid ( slot . address ( ) ) ) ; <nl> return CheckAndUpdateOldToNewSlot ( slot ) ; <nl> } , <nl> SlotSet : : PREFREE_EMPTY_BUCKETS ) ; <nl> mmm a / src / heap / scavenger . cc <nl> ppp b / src / heap / scavenger . cc <nl> void Scavenger : : AddPageToSweeperIfNecessary ( MemoryChunk * page ) { <nl> <nl> void Scavenger : : ScavengePage ( MemoryChunk * page ) { <nl> CodePageMemoryModificationScope memory_modification_scope ( page ) ; <nl> + InvalidatedSlotsFilter filter = InvalidatedSlotsFilter : : OldToNew ( page ) ; <nl> RememberedSet < OLD_TO_NEW > : : Iterate ( <nl> page , <nl> - [ this ] ( MaybeObjectSlot addr ) { <nl> - return CheckAndScavengeObject ( heap_ , addr ) ; <nl> + [ this , & filter ] ( MaybeObjectSlot slot ) { <nl> + CHECK ( filter . IsValid ( slot . address ( ) ) ) ; <nl> + return CheckAndScavengeObject ( heap_ , slot ) ; <nl> } , <nl> SlotSet : : KEEP_EMPTY_BUCKETS ) ; <nl> <nl>
[ heap ] Ensure that all old - to - new slots are valid
v8/v8
eaa0bb4cb407167323cf9179d97eae2f0de56170
2019-09-09T08:44:25Z
mmm a / lib / Sema / TypeCheckAccess . cpp <nl> ppp b / lib / Sema / TypeCheckAccess . cpp <nl> void AccessControlChecker : : check ( Decl * D ) { <nl> return false ; <nl> Type ty = inherited . getType ( ) ; <nl> if ( ty - > is < ProtocolCompositionType > ( ) ) <nl> - ty = ty - > getExistentialLayout ( ) . superclass ; <nl> + if ( auto superclass = ty - > getExistentialLayout ( ) . superclass ) <nl> + ty = superclass ; <nl> return ty - > getAnyNominal ( ) = = superclassDecl ; <nl> } ) ; <nl> / / Sanity check : we couldn ' t find the superclass for whatever reason <nl> void UsableFromInlineChecker : : check ( Decl * D ) { <nl> return false ; <nl> Type ty = inherited . getType ( ) ; <nl> if ( ty - > is < ProtocolCompositionType > ( ) ) <nl> - ty = ty - > getExistentialLayout ( ) . superclass ; <nl> + if ( auto superclass = ty - > getExistentialLayout ( ) . superclass ) <nl> + ty = superclass ; <nl> return ty - > getAnyNominal ( ) = = superclassDecl ; <nl> } ) ; <nl> / / Sanity check : we couldn ' t find the superclass for whatever reason <nl> mmm a / test / decl / inherit / inherit . swift <nl> ppp b / test / decl / inherit / inherit . swift <nl> <nl> - / / RUN : % target - typecheck - verify - swift <nl> + / / RUN : % target - typecheck - verify - swift - swift - version 5 <nl> <nl> - class A { } <nl> - protocol P { } <nl> + public class A { } <nl> + public protocol P { } <nl> + public protocol P1 { } <nl> <nl> / / Duplicate inheritance <nl> class B : A , A { } / / expected - error { { duplicate inheritance from ' A ' } } { { 12 - 15 = } } <nl> class C : B , A { } / / expected - error { { multiple inheritance from classes ' B ' and <nl> / / Superclass in the wrong position <nl> class D : P , A { } / / expected - error { { superclass ' A ' must appear first in the inheritance clause } } { { 12 - 15 = } } { { 11 - 11 = A , } } <nl> <nl> + / / SR - 8160 <nl> + class D1 : Any , A { } / / expected - error { { superclass ' A ' must appear first in the inheritance clause } } { { 15 - 18 = } } { { 12 - 12 = A , } } <nl> + <nl> + class D2 : P & P1 , A { } / / expected - error { { superclass ' A ' must appear first in the inheritance clause } } { { 18 - 21 = } } { { 12 - 12 = A , } } <nl> + <nl> + @ usableFromInline <nl> + class D3 : Any , A { } / / expected - error { { superclass ' A ' must appear first in the inheritance clause } } { { 15 - 18 = } } { { 12 - 12 = A , } } <nl> + <nl> + @ usableFromInline <nl> + class D4 : P & P1 , A { } / / expected - error { { superclass ' A ' must appear first in the inheritance clause } } { { 18 - 21 = } } { { 12 - 12 = A , } } <nl> + <nl> / / Struct inheriting a class <nl> struct S : A { } / / expected - error { { non - class type ' S ' cannot inherit from class ' A ' } } <nl> <nl>
[ Sema ] Don ' t crash on a null superclass in a protocol composition when checking access
apple/swift
40fada7f8241b00a78838e1e54ae4cbecea9b949
2018-07-02T18:29:17Z
mmm a / dbms / include / DB / Storages / MergeTree / MergeTreeData . h <nl> ppp b / dbms / include / DB / Storages / MergeTree / MergeTreeData . h <nl> class MergeTreeData : public ITableDeclaration <nl> / * * Возвращает копию списка , чтобы снаружи можно было не заботиться о блокировках . <nl> * / <nl> DataParts getDataParts ( ) ; <nl> + DataParts getAllDataParts ( ) ; <nl> <nl> / * * Возвращает кусок с указанным именем или кусок , покрывающий его . Если такого нет , возвращает nullptr . <nl> * Если including_inactive , просматриваются также неактивные куски ( all_data_parts ) . <nl> mmm a / dbms / src / Storages / MergeTree / MergeTreeData . cpp <nl> ppp b / dbms / src / Storages / MergeTree / MergeTreeData . cpp <nl> void MergeTreeData : : renameAndDetachPart ( DataPartPtr part , const String & prefix ) <nl> { <nl> Poco : : ScopedLock < Poco : : FastMutex > lock ( data_parts_mutex ) ; <nl> Poco : : ScopedLock < Poco : : FastMutex > lock_all ( all_data_parts_mutex ) ; <nl> - all_data_parts . erase ( part ) ; <nl> - if ( ! data_parts . erase ( part ) ) <nl> + if ( ! all_data_parts . erase ( part ) ) <nl> throw Exception ( " No such data part " , ErrorCodes : : NO_SUCH_DATA_PART ) ; <nl> + data_parts . erase ( part ) ; <nl> part - > renameAddPrefix ( prefix ) ; <nl> } <nl> <nl> MergeTreeData : : DataParts MergeTreeData : : getDataParts ( ) <nl> return data_parts ; <nl> } <nl> <nl> + MergeTreeData : : DataParts MergeTreeData : : getAllDataParts ( ) <nl> + { <nl> + Poco : : ScopedLock < Poco : : FastMutex > lock ( all_data_parts_mutex ) ; <nl> + <nl> + return all_data_parts ; <nl> + } <nl> + <nl> MergeTreeData : : DataPartPtr MergeTreeData : : getContainingPart ( const String & part_name , bool including_inactive ) <nl> { <nl> MutableDataPartPtr tmp_part ( new DataPart ( * this ) ) ; <nl> mmm a / dbms / src / Storages / StorageReplicatedMergeTree . cpp <nl> ppp b / dbms / src / Storages / StorageReplicatedMergeTree . cpp <nl> void StorageReplicatedMergeTree : : checkParts ( ) <nl> Strings expected_parts_vec = zookeeper . getChildren ( replica_path + " / parts " ) ; <nl> NameSet expected_parts ( expected_parts_vec . begin ( ) , expected_parts_vec . end ( ) ) ; <nl> <nl> - MergeTreeData : : DataParts parts = data . getDataParts ( ) ; <nl> + MergeTreeData : : DataParts parts = data . getAllDataParts ( ) ; <nl> <nl> MergeTreeData : : DataParts unexpected_parts ; <nl> for ( const auto & part : parts ) <nl> void StorageReplicatedMergeTree : : checkParts ( ) <nl> throw Exception ( " Not found " + toString ( expected_parts . size ( ) ) <nl> + " parts ( including " + missing_name + " ) in table " + data . getTableName ( ) , <nl> ErrorCodes : : NOT_FOUND_EXPECTED_DATA_PART ) ; <nl> + LOG_ERROR ( log , " Ignoring missing local part " < < missing_name < < " because part " < < containing - > name < < " exists " ) ; <nl> if ( unexpected_parts . count ( containing ) ) <nl> { <nl> parts_to_add . push_back ( containing ) ; <nl> void StorageReplicatedMergeTree : : checkParts ( ) <nl> expected_parts . size ( ) > 20 ) <nl> { <nl> throw Exception ( " The local set of parts of table " + data . getTableName ( ) + " doesn ' t look like the set of parts in ZooKeeper . " <nl> - " There are " + toString ( unexpected_parts . size ( ) ) + " unexpected parts , " <nl> + " There are " + toString ( unexpected_parts . size ( ) ) + " unexpected parts , " <nl> + toString ( parts_to_add . size ( ) ) + " unexpectedly merged parts , " <nl> + toString ( expected_parts . size ( ) ) + " unexpectedly obsolete parts " , <nl> ErrorCodes : : TOO_MANY_UNEXPECTED_DATA_PARTS ) ; <nl> void StorageReplicatedMergeTree : : checkParts ( ) <nl> / / / Добавим в ZK информацию о кусках , покрывающих недостающие куски . <nl> for ( MergeTreeData : : DataPartPtr part : parts_to_add ) <nl> { <nl> + LOG_ERROR ( log , " Adding unexpected local part to ZooKeeper : " < < part - > name ) ; <nl> zkutil : : Ops ops ; <nl> checkPartAndAddToZooKeeper ( part , ops ) ; <nl> zookeeper . multi ( ops ) ; <nl>
Merge
ClickHouse/ClickHouse
524f376b2d3e5d93b8e4398a91500f150eae20a3
2014-04-09T16:32:40Z