Commit 93604c5a authored by John Xu's avatar John Xu Committed by V8 LUCI CQ

Upstream Cobalt changes in cpu

These are the changes Cobalt currently has in V8's cpu related code.
- Add missing Starboard CPU code
- Replace some V8_OS_WIN with V8_TARGET_OS_WIN, they are found when
  cross-compiling for Linux platforms on Windows

Bug: v8:10927
Change-Id: Id63ae8614cbe6fe0eb53df89060c8ca2c9969ef4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2963803
Commit-Queue: John Xu <johnx@google.com>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75318}
parent 2c2b2132
......@@ -4,7 +4,7 @@
#include "src/base/cpu.h"
#if defined(STARBOARD)
#if defined(V8_OS_STARBOARD)
#include "starboard/cpu_features.h"
#endif
......@@ -356,10 +356,9 @@ static bool HasListItem(const char* list, const char* item) {
#endif // V8_HOST_ARCH_ARM || V8_HOST_ARCH_ARM64 ||
// V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64
#if defined(STARBOARD)
#if defined(V8_OS_STARBOARD)
bool CPU::StarboardDetectCPU() {
#if (SB_API_VERSION >= 11)
SbCPUFeatures features;
if (!SbCPUFeaturesGet(&features)) {
return false;
......@@ -398,9 +397,6 @@ bool CPU::StarboardDetectCPU() {
}
return true;
#else // SB_API_VERSION >= 11
return false;
#endif
}
#endif
......@@ -450,7 +446,7 @@ CPU::CPU()
has_msa_(false) {
memcpy(vendor_, "Unknown", 8);
#if defined(STARBOARD)
#if defined(V8_OS_STARBOARD)
if (StarboardDetectCPU()) {
return;
}
......
......@@ -120,6 +120,9 @@ class V8_BASE_EXPORT CPU final {
bool has_msa() const { return has_msa_; }
private:
#if defined(V8_OS_STARBOARD)
bool StarboardDetectCPU();
#endif
char vendor_[13];
int stepping_;
int model_;
......
......@@ -10,6 +10,8 @@
#elif V8_OS_FREEBSD
#include <machine/sysarch.h> // for cache flushing
#include <sys/types.h>
#elif V8_OS_STARBOARD
#define __ARM_NR_cacheflush 0x0f0002
#else
#include <sys/syscall.h> // for cache flushing.
#endif
......
......@@ -1288,7 +1288,7 @@ void TurboAssembler::Claim(int64_t count, uint64_t unit_size) {
return;
}
DCHECK_EQ(size % 16, 0);
#if V8_OS_WIN
#if V8_TARGET_OS_WIN
while (size > kStackPageSize) {
Sub(sp, sp, kStackPageSize);
Str(xzr, MemOperand(sp));
......@@ -1310,7 +1310,7 @@ void TurboAssembler::Claim(const Register& count, uint64_t unit_size) {
}
AssertPositiveOrZero(count);
#if V8_OS_WIN
#if V8_TARGET_OS_WIN
// "Functions that allocate 4k or more worth of stack must ensure that each
// page prior to the final page is touched in order." Source:
// https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=vs-2019#stack
......
......@@ -209,6 +209,8 @@ int HandlerTable::LookupReturn(int pc_offset) {
bool operator==(const Iterator& other) const {
return index == other.index;
}
// GLIBCXX_DEBUG checks uses the <= comparator.
bool operator<=(const Iterator& other) { return index <= other.index; }
Iterator& operator++() {
index++;
return *this;
......
......@@ -333,7 +333,7 @@ void LiftoffAssembler::PatchPrepareStackFrame(int offset) {
#endif
PatchingAssembler patching_assembler(AssemblerOptions{},
buffer_start_ + offset, 1);
#if V8_OS_WIN
#if V8_TARGET_OS_WIN
if (frame_size > kStackPageSize) {
// Generate OOL code (at the end of the function, where the current
// assembler is pointing) to do the explicit stack limit check (see
......
......@@ -219,7 +219,7 @@ void LiftoffAssembler::PatchPrepareStackFrame(int offset) {
Assembler patching_assembler(
AssemblerOptions{},
ExternalAssemblerBuffer(buffer_start_ + offset, kAvailableSpace));
#if V8_OS_WIN
#if V8_TARGET_OS_WIN
if (frame_size > kStackPageSize) {
// Generate OOL code (at the end of the function, where the current
// assembler is pointing) to do the explicit stack limit check (see
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment