| 1 | // Copyright 2015 The Servo Project Developers. See the COPYRIGHT |
| 2 | // file at the top-level directory of this distribution. |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 5 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 6 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 7 | // option. This file may not be copied, modified, or distributed |
| 8 | // except according to those terms. |
| 9 | |
| 10 | // FIXME(rust-lang/rust#18153): generate these from an enum |
| 11 | pub const DYNAMIC_TAG: u8 = 0b_00; |
| 12 | pub const INLINE_TAG: u8 = 0b_01; // len in upper nybble |
| 13 | pub const STATIC_TAG: u8 = 0b_10; |
| 14 | pub const TAG_MASK: u64 = 0b_11; |
| 15 | pub const ENTRY_ALIGNMENT: usize = 4; // Multiples have TAG_MASK bits unset, available for tagging. |
| 16 | |
| 17 | pub const MAX_INLINE_LEN: usize = 7; |
| 18 | |
| 19 | pub const STATIC_SHIFT_BITS: usize = 32; |
| 20 | |
| 21 | pub fn pack_static(n: u32) -> u64 { |
| 22 | (STATIC_TAG as u64) | ((n as u64) << STATIC_SHIFT_BITS) |
| 23 | } |