Skip to content

Commit 9645eaf

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Remove feature core_intrinsics
Reviewed By: bobyangyf Differential Revision: D41015779 fbshipit-source-id: 66a8171554e970a0e2f82ca4f57eac69730fcc46
1 parent 3038d68 commit 9645eaf

File tree

13 files changed

+50
-14
lines changed

13 files changed

+50
-14
lines changed

starlark/src/collections/alloca.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ use std::alloc::dealloc;
2020
use std::alloc::Layout;
2121
use std::cell::Cell;
2222
use std::cell::RefCell;
23-
use std::intrinsics::likely;
24-
use std::intrinsics::unlikely;
2523
use std::mem;
2624
use std::mem::MaybeUninit;
2725
use std::ptr;
2826
use std::slice;
2927

28+
use crate::hint::likely;
29+
use crate::hint::unlikely;
30+
3031
/// We'd love to use the real `alloca`, but don't want to blow through the stack space,
3132
/// so define our own wrapper.
3233
/// We use a single continuous buffer. When it needs upgrading, we double it and keep the old one around.

starlark/src/eval/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub(crate) mod bc;
2222
pub(crate) mod compiler;
2323
pub(crate) mod runtime;
2424

25-
use std::intrinsics::unlikely;
2625
use std::mem;
2726
use std::time::Instant;
2827

@@ -48,6 +47,7 @@ use crate::eval::compiler::scope::ScopeId;
4847
use crate::eval::compiler::Compiler;
4948
use crate::eval::runtime::arguments::ArgNames;
5049
use crate::eval::runtime::arguments::ArgumentsFull;
50+
use crate::hint::unlikely;
5151
use crate::syntax::ast::AstModule;
5252
use crate::syntax::DialectTypes;
5353
use crate::values::docs::DocString;

starlark/src/eval/runtime/arguments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
use std::intrinsics::unlikely;
1918
use std::iter;
2019
use std::marker::PhantomData;
2120

@@ -30,6 +29,7 @@ use crate::collections::Hashed;
3029
use crate::collections::SmallMap;
3130
use crate::collections::StarlarkHashValue;
3231
use crate::eval::runtime::params::ParametersSpec;
32+
use crate::hint::unlikely;
3333
use crate::values::dict::Dict;
3434
use crate::values::dict::DictRef;
3535
use crate::values::type_repr::StarlarkTypeRepr;

starlark/src/eval/runtime/call_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use std::fmt;
2828
use std::fmt::Debug;
2929
use std::fmt::Display;
30-
use std::intrinsics::unlikely;
3130

3231
use gazebo::prelude::*;
3332
use once_cell::sync::Lazy;
@@ -37,6 +36,7 @@ use crate::codemap::FileSpan;
3736
use crate::codemap::Span;
3837
use crate::errors::Frame;
3938
use crate::eval::runtime::inlined_frame::InlinedFrames;
39+
use crate::hint::unlikely;
4040
use crate::values::FrozenRef;
4141
use crate::values::Trace;
4242
use crate::values::Tracer;

starlark/src/eval/runtime/params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use std::cell::Cell;
2121
use std::cmp;
2222
use std::collections::HashMap;
23-
use std::intrinsics::unlikely;
2423

2524
use gazebo::coerce::coerce;
2625
use gazebo::coerce::Coerce;
@@ -36,6 +35,7 @@ use crate::eval::runtime::arguments::FunctionError;
3635
use crate::eval::runtime::arguments::ResolvedArgName;
3736
use crate::eval::Arguments;
3837
use crate::eval::Evaluator;
38+
use crate::hint::unlikely;
3939
use crate::values::dict::Dict;
4040
use crate::values::docs;
4141
use crate::values::docs::DocString;

starlark/src/hint.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
}

starlark/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
#![feature(box_syntax)]
353353
#![feature(const_mut_refs)]
354354
#![feature(const_type_id)]
355-
#![feature(core_intrinsics)]
355+
#![cfg_attr(fbcode_build, feature(core_intrinsics))]
356356
#![feature(generic_associated_types)]
357357
#![feature(maybe_uninit_slice)]
358358
#![feature(maybe_uninit_write_slice)]
@@ -411,6 +411,7 @@ mod private;
411411
pub mod read_line;
412412
mod sealed;
413413

414+
mod hint;
414415
mod stdlib;
415416
pub mod syntax;
416417
pub mod values;

starlark/src/stdlib/dict.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
//! Methods for the `dict` type.
1919
20-
use std::intrinsics::unlikely;
2120
use std::mem;
2221

2322
use crate as starlark;
2423
use crate::environment::MethodsBuilder;
24+
use crate::hint::unlikely;
2525
use crate::values::dict::Dict;
2626
use crate::values::dict::DictRef;
2727
use crate::values::none::NoneType;

starlark/src/values/recursive_repr_or_json_guard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
//! Detect recursion when doing `repr` or `to_json`.
1919
2020
use std::cell::Cell;
21-
use std::intrinsics::unlikely;
2221

2322
use crate::collections::SmallSet;
23+
use crate::hint::unlikely;
2424
use crate::values::layout::pointer::RawPointer;
2525
use crate::values::Value;
2626

starlark/src/values/stack_guard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
//! Guard to check we don't recurse too deeply with nested operations like Equals.
1919
2020
use std::cell::Cell;
21-
use std::intrinsics::unlikely;
2221

22+
use crate::hint::unlikely;
2323
use crate::values::error::ControlError;
2424

2525
// Maximum recursion level for comparison

0 commit comments

Comments
 (0)