V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
codegen-ppc.cc
1 // Copyright 2014 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_PPC
6 
7 #include <memory>
8 
9 #include "src/codegen.h"
10 #include "src/macro-assembler.h"
11 #include "src/ppc/simulator-ppc.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  // Called from C
31  __ function_descriptor();
32 
33  __ MovFromFloatParameter(d1);
34  __ fsqrt(d1, d1);
35  __ MovToFloatResult(d1);
36  __ Ret();
37 
38  CodeDesc desc;
39  masm.GetCode(nullptr, &desc);
40  DCHECK(ABI_USES_FUNCTION_DESCRIPTORS ||
41  !RelocInfo::RequiresRelocationAfterCodegen(desc));
42 
43  Assembler::FlushICache(buffer, allocated);
44  CHECK(SetPermissions(page_allocator, buffer, allocated,
45  PageAllocator::kReadExecute));
46  return FUNCTION_CAST<UnaryMathFunction>(buffer);
47 #endif
48 }
49 
50 #undef __
51 
52 } // namespace internal
53 } // namespace v8
54 
55 #endif // V8_TARGET_ARCH_PPC
virtual void * GetRandomMmapAddr()=0
Definition: libplatform.h:13