5aead50245
This CL includes db26c89347 (patch set #1)
with fix (patch set #2):
* Include simulator.h explicitly where it is required as it is no
longer included implicitly through other header files.
Original review: https://codereview.chromium.org/2995803002/
When running on the simulator for arm/arm64, compare-and-swap operations
used in VM were synchronized with simulator using mutex.
It heavily impacts performance when doing parallel marking due to high
contention (see #30317).
This synchronization was implemented in order to make simulated
LDREX/STREX instructions aware of CAS performed in VM.
This CL drops this synchronization between VM and simulator:
CAS operations in VM become regular, and simulator remembers value loaded
with load-exclusive and performs CAS when doing store-exclusive to catch
any concurrent modifications.
Speeds up gen_snapshot of flutter benchmark complex_layout from 9.2s
to 8.0s on my MacBook.
R=asiva@google.com
Review-Url: https://codereview.chromium.org/2999853002 .
65 lines
2.0 KiB
C++
65 lines
2.0 KiB
C++
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef RUNTIME_VM_ATOMIC_H_
|
|
#define RUNTIME_VM_ATOMIC_H_
|
|
|
|
#include "platform/globals.h"
|
|
|
|
#include "vm/allocation.h"
|
|
|
|
namespace dart {
|
|
|
|
class AtomicOperations : public AllStatic {
|
|
public:
|
|
// Atomically fetch the value at p and increment the value at p.
|
|
// Returns the original value at p.
|
|
static uintptr_t FetchAndIncrement(uintptr_t* p);
|
|
static intptr_t FetchAndIncrement(intptr_t* p);
|
|
|
|
// Atomically increment the value at p by 'value'.
|
|
static void IncrementBy(intptr_t* p, intptr_t value);
|
|
static void IncrementInt64By(int64_t* p, int64_t value);
|
|
|
|
// Atomically fetch the value at p and decrement the value at p.
|
|
// Returns the original value at p.
|
|
static uintptr_t FetchAndDecrement(uintptr_t* p);
|
|
static intptr_t FetchAndDecrement(intptr_t* p);
|
|
|
|
// Atomically decrement the value at p by 'value'.
|
|
static void DecrementBy(intptr_t* p, intptr_t value);
|
|
|
|
// Atomically compare *ptr to old_value, and if equal, store new_value.
|
|
// Returns the original value at ptr.
|
|
static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value);
|
|
static uint32_t CompareAndSwapUint32(uint32_t* ptr,
|
|
uint32_t old_value,
|
|
uint32_t new_value);
|
|
|
|
// Performs a load of a word from 'ptr', but without any guarantees about
|
|
// memory order (i.e., no load barriers/fences).
|
|
template <typename T>
|
|
static T LoadRelaxed(T* ptr) {
|
|
return *static_cast<volatile T*>(ptr);
|
|
}
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#if defined(HOST_OS_ANDROID)
|
|
#include "vm/atomic_android.h"
|
|
#elif defined(HOST_OS_FUCHSIA)
|
|
#include "vm/atomic_fuchsia.h"
|
|
#elif defined(HOST_OS_LINUX)
|
|
#include "vm/atomic_linux.h"
|
|
#elif defined(HOST_OS_MACOS)
|
|
#include "vm/atomic_macos.h"
|
|
#elif defined(HOST_OS_WINDOWS)
|
|
#include "vm/atomic_win.h"
|
|
#else
|
|
#error Unknown target os.
|
|
#endif
|
|
|
|
#endif // RUNTIME_VM_ATOMIC_H_
|