#reference #upstream

servo_arc

A fork of std::sync::Arc with some extra functionality and without weak references

5 releases (3 breaking)

0.4.0 Oct 22, 2024
0.3.0 Jun 21, 2023
0.2.0 Feb 20, 2023
0.1.1 Feb 22, 2018
0.1.0 Jan 12, 2018

#121 in Rust patterns

Download history 155041/week @ 2024-12-08 158149/week @ 2024-12-15 80479/week @ 2024-12-22 99801/week @ 2024-12-29 167098/week @ 2025-01-05 225505/week @ 2025-01-12 168389/week @ 2025-01-19 177157/week @ 2025-01-26 183156/week @ 2025-02-02 196495/week @ 2025-02-09 181469/week @ 2025-02-16 211351/week @ 2025-02-23 203662/week @ 2025-03-02 211365/week @ 2025-03-09 212599/week @ 2025-03-16 193226/week @ 2025-03-23

837,016 downloads per month
Used in 1,179 crates (4 directly)

MIT/Apache

42KB
759 lines

Stylo

This repo contains Servo’s downstream fork of Stylo.

The branches are as follows:

  • upstream has upstream mozilla-central filtered to the paths we care about (style.paths), but is otherwise unmodified
  • main has our downstream patches, plus the scripts and workflows for syncing with mozilla-central, to be rebased onto upstream

Building Servo against your local Stylo

Assuming your local servo and stylo directories are siblings, you can build servo against stylo by adding the following to servo/Cargo.toml:

[patch."https://github.com/servo/stylo"]
selectors = { path = "../stylo/selectors" }
servo_arc = { path = "../stylo/servo_arc" }
stylo_atoms = { path = "../stylo/stylo_atoms" }
style = { path = "../stylo/style" }
stylo_config = { path = "../stylo/stylo_config" }
stylo_dom = { path = "../stylo/stylo_dom" }
style_malloc_size_of = { path = "../stylo/malloc_size_of", package = "malloc_size_of" }
style_traits = { path = "../stylo/style_traits" }

Syncing upstream with mozilla-central

Start by generating a filtered copy of mozilla-central. This will cache the raw mozilla-central in _cache/upstream, storing the result in _filtered:

$ ./sync.sh _filtered

If _filtered already exists, you will need to delete it and try again:

$ rm -Rf _filtered

Now overwrite our upstream with those commits and push:

$ git fetch -f --progress ./_filtered master:upstream
$ git push -fu --progress origin upstream

Rebasing main onto upstream

Start by fetching upstream into your local repo:

$ git fetch -f origin upstream:upstream

In general, the filtering process is deterministic, yielding the same commit hashes each time, so we can rebase normally:

$ git rebase upstream

But if the filtering config changes or Mozilla moves to GitHub, the commit hashes on upstream may change. In this case, we need to tell git where the old upstream ends and our own commits start (notice the ~):

$ git log --pretty=\%H --grep='Servo initial downstream commit'
e62d7f0090941496e392e1dc91df103a38e3f488

$ git rebase --onto upstream e62d7f0090941496e392e1dc91df103a38e3f488~
Successfully rebased and updated refs/heads/main.

start-rebase.sh takes care of this automatically, but you should still use git rebase for subsequent steps like --continue and --abort:

$ ./start-rebase.sh upstream
$ ./start-rebase.sh upstream -i     # interactive
$ git rebase --continue             # not ./start-rebase.sh --continue
$ git rebase --abort                # not ./start-rebase.sh --abort

Or if we aren’t ready to rebase onto the tip of upstream:

$ ./start-rebase.sh upstream~10 -i

lib.rs:

Fork of Arc for Servo. This has the following advantages over std::sync::Arc:

  • We don't waste storage on the weak reference count.
  • We don't do extra RMU operations to handle the possibility of weak references.
  • We can experiment with arena allocation (todo).
  • We can add methods to support our custom use cases 1.
  • We have support for dynamically-sized types (see from_header_and_iter).
  • We have support for thin arcs to unsized types (see ThinArc).
  • We have support for references to static data, which don't do any refcounting.

Dependencies

~165KB