File tree Expand file tree Collapse file tree 13 files changed +50
-14
lines changed Expand file tree Collapse file tree 13 files changed +50
-14
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,14 @@ use std::alloc::dealloc;
20
20
use std:: alloc:: Layout ;
21
21
use std:: cell:: Cell ;
22
22
use std:: cell:: RefCell ;
23
- use std:: intrinsics:: likely;
24
- use std:: intrinsics:: unlikely;
25
23
use std:: mem;
26
24
use std:: mem:: MaybeUninit ;
27
25
use std:: ptr;
28
26
use std:: slice;
29
27
28
+ use crate :: hint:: likely;
29
+ use crate :: hint:: unlikely;
30
+
30
31
/// We'd love to use the real `alloca`, but don't want to blow through the stack space,
31
32
/// so define our own wrapper.
32
33
/// We use a single continuous buffer. When it needs upgrading, we double it and keep the old one around.
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ pub(crate) mod bc;
22
22
pub ( crate ) mod compiler;
23
23
pub ( crate ) mod runtime;
24
24
25
- use std:: intrinsics:: unlikely;
26
25
use std:: mem;
27
26
use std:: time:: Instant ;
28
27
@@ -48,6 +47,7 @@ use crate::eval::compiler::scope::ScopeId;
48
47
use crate :: eval:: compiler:: Compiler ;
49
48
use crate :: eval:: runtime:: arguments:: ArgNames ;
50
49
use crate :: eval:: runtime:: arguments:: ArgumentsFull ;
50
+ use crate :: hint:: unlikely;
51
51
use crate :: syntax:: ast:: AstModule ;
52
52
use crate :: syntax:: DialectTypes ;
53
53
use crate :: values:: docs:: DocString ;
Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- use std:: intrinsics:: unlikely;
19
18
use std:: iter;
20
19
use std:: marker:: PhantomData ;
21
20
@@ -30,6 +29,7 @@ use crate::collections::Hashed;
30
29
use crate :: collections:: SmallMap ;
31
30
use crate :: collections:: StarlarkHashValue ;
32
31
use crate :: eval:: runtime:: params:: ParametersSpec ;
32
+ use crate :: hint:: unlikely;
33
33
use crate :: values:: dict:: Dict ;
34
34
use crate :: values:: dict:: DictRef ;
35
35
use crate :: values:: type_repr:: StarlarkTypeRepr ;
Original file line number Diff line number Diff line change 27
27
use std:: fmt;
28
28
use std:: fmt:: Debug ;
29
29
use std:: fmt:: Display ;
30
- use std:: intrinsics:: unlikely;
31
30
32
31
use gazebo:: prelude:: * ;
33
32
use once_cell:: sync:: Lazy ;
@@ -37,6 +36,7 @@ use crate::codemap::FileSpan;
37
36
use crate :: codemap:: Span ;
38
37
use crate :: errors:: Frame ;
39
38
use crate :: eval:: runtime:: inlined_frame:: InlinedFrames ;
39
+ use crate :: hint:: unlikely;
40
40
use crate :: values:: FrozenRef ;
41
41
use crate :: values:: Trace ;
42
42
use crate :: values:: Tracer ;
Original file line number Diff line number Diff line change 20
20
use std:: cell:: Cell ;
21
21
use std:: cmp;
22
22
use std:: collections:: HashMap ;
23
- use std:: intrinsics:: unlikely;
24
23
25
24
use gazebo:: coerce:: coerce;
26
25
use gazebo:: coerce:: Coerce ;
@@ -36,6 +35,7 @@ use crate::eval::runtime::arguments::FunctionError;
36
35
use crate :: eval:: runtime:: arguments:: ResolvedArgName ;
37
36
use crate :: eval:: Arguments ;
38
37
use crate :: eval:: Evaluator ;
38
+ use crate :: hint:: unlikely;
39
39
use crate :: values:: dict:: Dict ;
40
40
use crate :: values:: docs;
41
41
use crate :: values:: docs:: DocString ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2018 The Starlark in Rust Authors.
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ // TODO(nga): also enable if cargo build and nightly.
19
+ #[ cfg( fbcode_build) ]
20
+ pub ( crate ) use std:: intrinsics:: likely;
21
+ #[ cfg( fbcode_build) ]
22
+ pub ( crate ) use std:: intrinsics:: unlikely;
23
+
24
+ #[ cfg( not( fbcode_build) ) ]
25
+ #[ inline]
26
+ pub ( crate ) fn likely ( b : bool ) -> bool {
27
+ b
28
+ }
29
+
30
+ #[ cfg( not( fbcode_build) ) ]
31
+ #[ inline]
32
+ pub ( crate ) fn unlikely ( b : bool ) -> bool {
33
+ b
34
+ }
Original file line number Diff line number Diff line change 352
352
#![ feature( box_syntax) ]
353
353
#![ feature( const_mut_refs) ]
354
354
#![ feature( const_type_id) ]
355
- #![ feature( core_intrinsics) ]
355
+ #![ cfg_attr ( fbcode_build , feature( core_intrinsics) ) ]
356
356
#![ feature( generic_associated_types) ]
357
357
#![ feature( maybe_uninit_slice) ]
358
358
#![ feature( maybe_uninit_write_slice) ]
@@ -411,6 +411,7 @@ mod private;
411
411
pub mod read_line;
412
412
mod sealed;
413
413
414
+ mod hint;
414
415
mod stdlib;
415
416
pub mod syntax;
416
417
pub mod values;
Original file line number Diff line number Diff line change 17
17
18
18
//! Methods for the `dict` type.
19
19
20
- use std:: intrinsics:: unlikely;
21
20
use std:: mem;
22
21
23
22
use crate as starlark;
24
23
use crate :: environment:: MethodsBuilder ;
24
+ use crate :: hint:: unlikely;
25
25
use crate :: values:: dict:: Dict ;
26
26
use crate :: values:: dict:: DictRef ;
27
27
use crate :: values:: none:: NoneType ;
Original file line number Diff line number Diff line change 18
18
//! Detect recursion when doing `repr` or `to_json`.
19
19
20
20
use std:: cell:: Cell ;
21
- use std:: intrinsics:: unlikely;
22
21
23
22
use crate :: collections:: SmallSet ;
23
+ use crate :: hint:: unlikely;
24
24
use crate :: values:: layout:: pointer:: RawPointer ;
25
25
use crate :: values:: Value ;
26
26
Original file line number Diff line number Diff line change 18
18
//! Guard to check we don't recurse too deeply with nested operations like Equals.
19
19
20
20
use std:: cell:: Cell ;
21
- use std:: intrinsics:: unlikely;
22
21
22
+ use crate :: hint:: unlikely;
23
23
use crate :: values:: error:: ControlError ;
24
24
25
25
// Maximum recursion level for comparison
You can’t perform that action at this time.
0 commit comments