LCOV - code coverage report
Current view: top level - js/src/jit - Linker.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 24 31 77.4 %
Date: 2017-07-14 16:53:18 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: set ts=8 sts=4 et sw=4 tw=99:
       3             :  * This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "jit/Linker.h"
       8             : 
       9             : #include "gc/StoreBuffer-inl.h"
      10             : 
      11             : namespace js {
      12             : namespace jit {
      13             : 
      14             : template <AllowGC allowGC>
      15             : JitCode*
      16        4499 : Linker::newCode(JSContext* cx, CodeKind kind, bool hasPatchableBackedges /* = false */)
      17             : {
      18        4499 :     MOZ_ASSERT(masm.numSymbolicAccesses() == 0);
      19        4499 :     MOZ_ASSERT_IF(hasPatchableBackedges, kind == ION_CODE);
      20             : 
      21        8998 :     gc::AutoSuppressGC suppressGC(cx);
      22        4499 :     if (masm.oom())
      23           0 :         return fail(cx);
      24             : 
      25             :     ExecutablePool* pool;
      26        4499 :     size_t bytesNeeded = masm.bytesNeeded() + sizeof(JitCode*) + CodeAlignment;
      27        4499 :     if (bytesNeeded >= MAX_BUFFER_SIZE)
      28           0 :         return fail(cx);
      29             : 
      30             :     // ExecutableAllocator requires bytesNeeded to be word-size aligned.
      31        4499 :     bytesNeeded = AlignBytes(bytesNeeded, sizeof(void*));
      32             : 
      33             :     ExecutableAllocator& execAlloc = hasPatchableBackedges
      34           0 :                                      ? cx->runtime()->jitRuntime()->backedgeExecAlloc()
      35        4499 :                                      : cx->runtime()->jitRuntime()->execAlloc();
      36             : 
      37        4499 :     uint8_t* result = (uint8_t*)execAlloc.alloc(cx, bytesNeeded, &pool, kind);
      38        4499 :     if (!result)
      39           0 :         return fail(cx);
      40             : 
      41             :     // The JitCode pointer will be stored right before the code buffer.
      42        4499 :     uint8_t* codeStart = result + sizeof(JitCode*);
      43             : 
      44             :     // Bump the code up to a nice alignment.
      45        4499 :     codeStart = (uint8_t*)AlignBytes((uintptr_t)codeStart, CodeAlignment);
      46        4499 :     uint32_t headerSize = codeStart - result;
      47        4499 :     JitCode* code = JitCode::New<allowGC>(cx, codeStart, bytesNeeded - headerSize,
      48        4499 :                                           headerSize, pool, kind);
      49        4499 :     if (!code)
      50           0 :         return nullptr;
      51        4499 :     if (masm.oom())
      52           0 :         return fail(cx);
      53        4499 :     awjc.emplace(result, bytesNeeded);
      54        4499 :     code->copyFrom(masm);
      55        4499 :     masm.link(code);
      56        4499 :     if (masm.embedsNurseryPointers())
      57           0 :         cx->zone()->group()->storeBuffer().putWholeCell(code);
      58        4499 :     return code;
      59             : }
      60             : 
      61             : template JitCode* Linker::newCode<CanGC>(JSContext* cx, CodeKind kind, bool hasPatchableBackedges);
      62             : template JitCode* Linker::newCode<NoGC>(JSContext* cx, CodeKind kind, bool hasPatchableBackedges);
      63             : 
      64             : } // namespace jit
      65           9 : } // namespace js

Generated by: LCOV version 1.13