V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
codegen-s390.cc
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #if V8_TARGET_ARCH_S390
6 
7 #include <memory>
8 
9 #include "src/codegen.h"
10 #include "src/macro-assembler.h"
11 #include "src/s390/simulator-s390.h"
12 
13 namespace v8 {
14 namespace internal {
15 
16 #define __ masm.
17 
18 UnaryMathFunction CreateSqrtFunction() {
19 #if defined(USE_SIMULATOR)
20  return nullptr;
21 #else
22  v8::PageAllocator* page_allocator = GetPlatformPageAllocator();
23  size_t allocated = 0;
24  byte* buffer = AllocatePage(page_allocator,
25  page_allocator->GetRandomMmapAddr(), &allocated);
26  if (buffer == nullptr) return nullptr;
27 
28  MacroAssembler masm(AssemblerOptions{}, buffer, static_cast<int>(allocated));
29 
30  __ MovFromFloatParameter(d0);
31  __ sqdbr(d0, d0);
32  __ MovToFloatResult(d0);
33  __ Ret();
34 
35  CodeDesc desc;
36  masm.GetCode(nullptr, &desc);
37  DCHECK(ABI_USES_FUNCTION_DESCRIPTORS ||
38  !RelocInfo::RequiresRelocationAfterCodegen(desc));
39 
40  Assembler::FlushICache(buffer, allocated);
41  CHECK(SetPermissions(page_allocator, buffer, allocated,
42  PageAllocator::kReadExecute));
43  return FUNCTION_CAST<UnaryMathFunction>(buffer);
44 #endif
45 }
46 
47 #undef __
48 
49 } // namespace internal
50 } // namespace v8
51 
52 #endif // V8_TARGET_ARCH_S390
virtual void * GetRandomMmapAddr()=0
Definition: libplatform.h:13