Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
bss_relocs.cc
Go to the documentation of this file.
1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include "vm/bss_relocs.h"
6#include "vm/native_symbol.h"
7#include "vm/runtime_entry.h"
8#include "vm/thread.h"
9
10namespace dart {
11
13 uword new_value,
14 uword* bss_start) {
15 std::atomic<uword>* slot = reinterpret_cast<std::atomic<uword>*>(
16 &bss_start[BSS::RelocationIndex(relocation)]);
17 uword old_value = slot->load(std::memory_order_relaxed);
18 // FullSnapshotReader::ReadProgramSnapshot, and thus BSS::Initialize, can
19 // get called multiple times for the same isolate in different threads, though
20 // the initialized value will be consistent and thus change only once. Avoid
21 // calling compare_exchange_strong unless we actually need to change the
22 // value, to avoid spurious read/write races by TSAN.
23 if (old_value == new_value) return;
24 if (!slot->compare_exchange_strong(old_value, new_value,
25 std::memory_order_relaxed)) {
26 RELEASE_ASSERT(old_value == new_value);
27 }
28}
29
30void BSS::Initialize(Thread* current, uword* bss_start, bool vm) {
31 // TODO(https://dartbug.com/52579): Remove.
33 reinterpret_cast<uword>(DLRT_GetFfiCallbackMetadata),
34 bss_start);
36 reinterpret_cast<uword>(DLRT_ExitTemporaryIsolate),
37 bss_start);
38}
39
40} // namespace dart
#define RELEASE_ASSERT(cond)
Definition assert.h:327
static constexpr intptr_t RelocationIndex(Relocation reloc)
Definition bss_relocs.h:33
static void Initialize(Thread *current, uword *bss, bool vm)
Definition bss_relocs.cc:30
static void InitializeBSSEntry(BSS::Relocation relocation, uword new_value, uword *bss_start)
Definition bss_relocs.cc:12
Thread * DLRT_GetFfiCallbackMetadata(FfiCallbackMetadata::Trampoline trampoline, uword *out_entry_point, uword *out_trampoline_type)
uintptr_t uword
Definition globals.h:501
void DLRT_ExitTemporaryIsolate()