• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/isolate.h"
11 #include "src/macro-assembler.h"
12 #include "src/ppc/simulator-ppc.h"
13 
14 namespace v8 {
15 namespace internal {
16 
17 #define __ masm.
18 
CreateSqrtFunction(Isolate * isolate)19 UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) {
20 #if defined(USE_SIMULATOR)
21   return nullptr;
22 #else
23   size_t allocated = 0;
24   byte* buffer = AllocatePage(isolate->heap()->GetRandomMmapAddr(), &allocated);
25   if (buffer == nullptr) return nullptr;
26 
27   MacroAssembler masm(isolate, buffer, static_cast<int>(allocated),
28                       CodeObjectRequired::kNo);
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(isolate, &desc);
40   DCHECK(ABI_USES_FUNCTION_DESCRIPTORS ||
41          !RelocInfo::RequiresRelocationAfterCodegen(desc));
42 
43   Assembler::FlushICache(buffer, allocated);
44   CHECK(SetPermissions(buffer, allocated, PageAllocator::kReadExecute));
45   return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer);
46 #endif
47 }
48 
49 #undef __
50 
51 }  // namespace internal
52 }  // namespace v8
53 
54 #endif  // V8_TARGET_ARCH_PPC
55