| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 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/shared/Assembler-shared.h" |
| 8 |
|
| 9 |
#include "jit/JitSpewer.h" |
| 10 |
#include "vm/NativeObject.h" |
| 11 |
#include "wasm/WasmMemory.h" |
| 12 |
|
| 13 |
namespace js { |
| 14 |
|
| 15 |
namespace wasm { |
| 16 |
|
| 17 |
#ifdef DEBUG |
| 18 |
void MemoryAccessDesc::assertOffsetInGuardPages() const { |
| 19 |
MOZ_ASSERT(offset_ < (uint64_t)GetMaxOffsetGuardLimit(hugeMemory_)); |
| 20 |
} |
| 21 |
#endif |
| 22 |
|
| 23 |
} // namespace wasm |
| 24 |
|
| 25 |
namespace jit { |
| 26 |
|
| 27 |
void BaseObjectElementIndex::staticAssertions() { |
| 28 |
NativeObject::elementsSizeMustNotOverflow(); |
| 29 |
} |
| 30 |
|
| 31 |
void BaseObjectSlotIndex::staticAssertions() { |
| 32 |
NativeObject::slotsSizeMustNotOverflow(); |
| 33 |
} |
| 34 |
|
| 35 |
AssemblerShared::~AssemblerShared() { |
| 36 |
#ifdef DEBUG |
| 37 |
while (hasCreator()) { |
| 38 |
popCreator(); |
| 39 |
} |
| 40 |
#endif |
| 41 |
} |
| 42 |
|
| 43 |
#ifdef DEBUG |
| 44 |
void AssemblerShared::pushCreator(const char* who) { |
| 45 |
(void)creators_.append(who); |
| 46 |
JitSpewStart(JitSpew_Codegen, "# BEGIN creators: "); |
| 47 |
bool first = true; |
| 48 |
for (const char* str : creators_) { |
| 49 |
JitSpewCont(JitSpew_Codegen, "%s%s", first ? "" : "/", str); |
| 50 |
first = false; |
| 51 |
} |
| 52 |
JitSpewCont(JitSpew_Codegen, "\n"); |
| 53 |
} |
| 54 |
|
| 55 |
void AssemblerShared::popCreator() { |
| 56 |
JitSpewStart(JitSpew_Codegen, "# END creators: "); |
| 57 |
bool first = true; |
| 58 |
for (const char* str : creators_) { |
| 59 |
JitSpewCont(JitSpew_Codegen, "%s%s", first ? "" : "/", str); |
| 60 |
first = false; |
| 61 |
} |
| 62 |
JitSpewCont(JitSpew_Codegen, "\n"); |
| 63 |
if (creators_.empty()) { |
| 64 |
JitSpew(JitSpew_Codegen, " "); |
| 65 |
} |
| 66 |
MOZ_ASSERT(!creators_.empty()); |
| 67 |
creators_.popBack(); |
| 68 |
} |
| 69 |
|
| 70 |
bool AssemblerShared::hasCreator() const { |
| 71 |
// If you get failures of assertions of the form `MOZ_ASSERT(hasCreator())`, |
| 72 |
// what this means is that a `MacroAssembler` (or, really, anything that |
| 73 |
// inherits from `js::jit::AssemblerShared`) has emitted code or data from a |
| 74 |
// place, in the SM C++ hierarchy, that is not nested within an |
| 75 |
// `AutoCreatedBy` RAII scope. Consequently the emitted instructions/data |
| 76 |
// won't have any owner that is identifiable in the `IONFLAGS=codegen` |
| 77 |
// output. |
| 78 |
// |
| 79 |
// Fixing this is easy: work back up the crash stack and decide on a place |
| 80 |
// to put an `AutoCreatedBy` call. A bit of grepping for `AutoCreatedBy` |
| 81 |
// should make it obvious what to do. If in doubt, add `AutoCreatedBy` |
| 82 |
// calls liberally; "extra" ones are harmless. |
| 83 |
return !creators_.empty(); |
| 84 |
} |
| 85 |
#endif |
| 86 |
|
| 87 |
} // namespace jit |
| 88 |
|
| 89 |
} // namespace js |