codegen-s390.cc 1.31 KB
Newer Older
1 2 3 4 5 6
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if V8_TARGET_ARCH_S390

7 8
#include <memory>

9 10 11 12 13 14 15 16 17
#include "src/codegen.h"
#include "src/macro-assembler.h"
#include "src/s390/simulator-s390.h"

namespace v8 {
namespace internal {

#define __ masm.

18
UnaryMathFunction CreateSqrtFunction() {
19 20 21
#if defined(USE_SIMULATOR)
  return nullptr;
#else
22
  v8::PageAllocator* page_allocator = GetPlatformPageAllocator();
23
  size_t allocated = 0;
24
  byte* buffer = AllocatePage(page_allocator,
25
                              page_allocator->GetRandomMmapAddr(), &allocated);
26 27
  if (buffer == nullptr) return nullptr;

28
  MacroAssembler masm(AssemblerOptions{}, buffer, static_cast<int>(allocated));
29 30 31 32 33 34 35

  __ MovFromFloatParameter(d0);
  __ sqdbr(d0, d0);
  __ MovToFloatResult(d0);
  __ Ret();

  CodeDesc desc;
36
  masm.GetCode(nullptr, &desc);
37 38
  DCHECK(ABI_USES_FUNCTION_DESCRIPTORS ||
         !RelocInfo::RequiresRelocationAfterCodegen(desc));
39

40
  Assembler::FlushICache(buffer, allocated);
41 42
  CHECK(SetPermissions(page_allocator, buffer, allocated,
                       PageAllocator::kReadExecute));
43
  return FUNCTION_CAST<UnaryMathFunction>(buffer);
44 45 46 47 48 49 50 51 52
#endif
}

#undef __

}  // namespace internal
}  // namespace v8

#endif  // V8_TARGET_ARCH_S390