Commit 7322f0a3 authored by Zhi An Ng's avatar Zhi An Ng Committed by Commit Bot

[cleanup][wasm] Replace min/max with std::min/std::max

Clean up src/wasm and test/

Bug: v8:11074
Change-Id: I1b3d3475a0fbfafe75bb49acfd851f8bd5af5182
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2519183Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71025}
parent cc68080f
...@@ -137,8 +137,8 @@ static_assert(2 * kBitsPerGpRegCode >= kBitsPerFpRegCode, ...@@ -137,8 +137,8 @@ static_assert(2 * kBitsPerGpRegCode >= kBitsPerFpRegCode,
class LiftoffRegister { class LiftoffRegister {
static constexpr int needed_bits = static constexpr int needed_bits =
Max(kNeedI64RegPair || kNeedS128RegPair ? kBitsPerRegPair : 0, std::max(kNeedI64RegPair || kNeedS128RegPair ? kBitsPerRegPair : 0,
kBitsPerLiftoffRegCode); kBitsPerLiftoffRegCode);
using storage_t = std::conditional< using storage_t = std::conditional<
needed_bits <= 8, uint8_t, needed_bits <= 8, uint8_t,
std::conditional<needed_bits <= 16, uint16_t, uint32_t>::type>::type; std::conditional<needed_bits <= 16, uint16_t, uint32_t>::type>::type;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "src/base/memory.h" #include "src/base/memory.h"
#include "src/codegen/signature.h" #include "src/codegen/signature.h"
#include "src/flags/flags.h" #include "src/flags/flags.h"
#include "src/utils/utils.h"
#include "src/utils/vector.h" #include "src/utils/vector.h"
#include "src/wasm/wasm-opcodes.h" #include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-result.h" #include "src/wasm/wasm-result.h"
...@@ -482,7 +481,7 @@ class Decoder { ...@@ -482,7 +481,7 @@ class Decoder {
} }
} }
constexpr int sign_ext_shift = constexpr int sign_ext_shift =
is_signed ? Max(0, int{8 * sizeof(IntType)} - shift - 7) : 0; is_signed ? std::max(0, int{8 * sizeof(IntType)} - shift - 7) : 0;
// Perform sign extension. // Perform sign extension.
result = (result << sign_ext_shift) >> sign_ext_shift; result = (result << sign_ext_shift) >> sign_ext_shift;
if (trace && is_signed) { if (trace && is_signed) {
......
...@@ -17,7 +17,7 @@ template <typename InType, typename OutType, typename Iterable> ...@@ -17,7 +17,7 @@ template <typename InType, typename OutType, typename Iterable>
void TestExternalReference_ConvertOp( void TestExternalReference_ConvertOp(
BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref, BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref,
void (*wrapper)(Address), Iterable inputs) { void (*wrapper)(Address), Iterable inputs) {
constexpr size_t kBufferSize = Max(sizeof(InType), sizeof(OutType)); constexpr size_t kBufferSize = std::max(sizeof(InType), sizeof(OutType));
uint8_t buffer[kBufferSize] = {0}; uint8_t buffer[kBufferSize] = {0};
Address buffer_addr = reinterpret_cast<Address>(buffer); Address buffer_addr = reinterpret_cast<Address>(buffer);
...@@ -45,7 +45,7 @@ template <typename InType, typename OutType, typename Iterable> ...@@ -45,7 +45,7 @@ template <typename InType, typename OutType, typename Iterable>
void TestExternalReference_ConvertOpWithOutputAndReturn( void TestExternalReference_ConvertOpWithOutputAndReturn(
BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref, BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref,
int32_t (*wrapper)(Address), Iterable inputs) { int32_t (*wrapper)(Address), Iterable inputs) {
constexpr size_t kBufferSize = Max(sizeof(InType), sizeof(OutType)); constexpr size_t kBufferSize = std::max(sizeof(InType), sizeof(OutType));
uint8_t buffer[kBufferSize] = {0}; uint8_t buffer[kBufferSize] = {0};
Address buffer_addr = reinterpret_cast<Address>(buffer); Address buffer_addr = reinterpret_cast<Address>(buffer);
......
...@@ -361,7 +361,7 @@ UNINITIALIZED_TEST(ArrayBuffer_SemiSpaceCopyMultipleTasks) { ...@@ -361,7 +361,7 @@ UNINITIALIZED_TEST(ArrayBuffer_SemiSpaceCopyMultipleTasks) {
// Test allocates JSArrayBuffer on different pages before triggering a // Test allocates JSArrayBuffer on different pages before triggering a
// full GC that performs the semispace copy. If parallelized, this test // full GC that performs the semispace copy. If parallelized, this test
// ensures proper synchronization in TSAN configurations. // ensures proper synchronization in TSAN configurations.
FLAG_min_semi_space_size = Max(2 * Page::kPageSize / MB, 1); FLAG_min_semi_space_size = std::max(2 * Page::kPageSize / MB, 1);
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
......
...@@ -3740,7 +3740,7 @@ TEST(LargeObjectSlotRecording) { ...@@ -3740,7 +3740,7 @@ TEST(LargeObjectSlotRecording) {
FixedArray old_location = *lit; FixedArray old_location = *lit;
// Allocate a large object. // Allocate a large object.
int size = Max(1000000, kMaxRegularHeapObjectSize + KB); int size = std::max(1000000, kMaxRegularHeapObjectSize + KB);
CHECK_LT(kMaxRegularHeapObjectSize, size); CHECK_LT(kMaxRegularHeapObjectSize, size);
Handle<FixedArray> lo = Handle<FixedArray> lo =
isolate->factory()->NewFixedArray(size, AllocationType::kOld); isolate->factory()->NewFixedArray(size, AllocationType::kOld);
...@@ -5667,7 +5667,8 @@ TEST(Regress598319) { ...@@ -5667,7 +5667,8 @@ TEST(Regress598319) {
Isolate* isolate = heap->isolate(); Isolate* isolate = heap->isolate();
// The size of the array should be larger than kProgressBarScanningChunk. // The size of the array should be larger than kProgressBarScanningChunk.
const int kNumberOfObjects = Max(FixedArray::kMaxRegularLength + 1, 128 * KB); const int kNumberOfObjects =
std::max(FixedArray::kMaxRegularLength + 1, 128 * KB);
struct Arr { struct Arr {
Arr(Isolate* isolate, int number_of_objects) { Arr(Isolate* isolate, int number_of_objects) {
...@@ -6279,7 +6280,7 @@ TEST(RememberedSet_InsertInLargePage) { ...@@ -6279,7 +6280,7 @@ TEST(RememberedSet_InsertInLargePage) {
HandleScope scope(isolate); HandleScope scope(isolate);
// Allocate an object in Large space. // Allocate an object in Large space.
const int count = Max(FixedArray::kMaxRegularLength + 1, 128 * KB); const int count = std::max(FixedArray::kMaxRegularLength + 1, 128 * KB);
Handle<FixedArray> arr = factory->NewFixedArray(count, AllocationType::kOld); Handle<FixedArray> arr = factory->NewFixedArray(count, AllocationType::kOld);
CHECK(heap->lo_space()->Contains(*arr)); CHECK(heap->lo_space()->Contains(*arr));
CHECK_EQ(0, GetRememberedSetSize<OLD_TO_NEW>(*arr)); CHECK_EQ(0, GetRememberedSetSize<OLD_TO_NEW>(*arr));
......
...@@ -3868,7 +3868,8 @@ class WasmInterpreterInternals { ...@@ -3868,7 +3868,8 @@ class WasmInterpreterInternals {
size_t old_size = stack_limit_ - stack_.get(); size_t old_size = stack_limit_ - stack_.get();
size_t requested_size = size_t requested_size =
base::bits::RoundUpToPowerOfTwo64((sp_ - stack_.get()) + size); base::bits::RoundUpToPowerOfTwo64((sp_ - stack_.get()) + size);
size_t new_size = Max(size_t{8}, Max(2 * old_size, requested_size)); size_t new_size =
std::max(size_t{8}, std::max(2 * old_size, requested_size));
std::unique_ptr<StackValue[]> new_stack(new StackValue[new_size]); std::unique_ptr<StackValue[]> new_stack(new StackValue[new_size]);
if (old_size > 0) { if (old_size > 0) {
memcpy(new_stack.get(), stack_.get(), old_size * sizeof(*sp_)); memcpy(new_stack.get(), stack_.get(), old_size * sizeof(*sp_));
......
...@@ -14,7 +14,7 @@ namespace compiler { ...@@ -14,7 +14,7 @@ namespace compiler {
namespace { namespace {
constexpr int kMaxNumAllocatable = constexpr int kMaxNumAllocatable =
Max(Register::kNumRegisters, DoubleRegister::kNumRegisters); std::max(Register::kNumRegisters, DoubleRegister::kNumRegisters);
static std::array<int, kMaxNumAllocatable> kAllocatableCodes = static std::array<int, kMaxNumAllocatable> kAllocatableCodes =
base::make_array<kMaxNumAllocatable>( base::make_array<kMaxNumAllocatable>(
[](size_t i) { return static_cast<int>(i); }); [](size_t i) { return static_cast<int>(i); });
......
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