| 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/IonCacheIRCompiler.h" |
| 8 |
#include "mozilla/Maybe.h" |
| 9 |
|
| 10 |
#include <algorithm> |
| 11 |
|
| 12 |
#include "jit/CacheIRCompiler.h" |
| 13 |
#include "jit/CacheIRWriter.h" |
| 14 |
#include "jit/IonIC.h" |
| 15 |
#include "jit/JitcodeMap.h" |
| 16 |
#include "jit/JitFrames.h" |
| 17 |
#include "jit/JitRuntime.h" |
| 18 |
#include "jit/JitZone.h" |
| 19 |
#include "jit/JSJitFrameIter.h" |
| 20 |
#include "jit/Linker.h" |
| 21 |
#include "jit/SharedICHelpers.h" |
| 22 |
#include "jit/VMFunctions.h" |
| 23 |
#include "proxy/DeadObjectProxy.h" |
| 24 |
#include "proxy/Proxy.h" |
| 25 |
#include "util/Memory.h" |
| 26 |
#include "vm/StaticStrings.h" |
| 27 |
|
| 28 |
#include "jit/JSJitFrameIter-inl.h" |
| 29 |
#include "jit/MacroAssembler-inl.h" |
| 30 |
#include "jit/VMFunctionList-inl.h" |
| 31 |
|
| 32 |
using namespace js; |
| 33 |
using namespace js::jit; |
| 34 |
|
| 35 |
using mozilla::Maybe; |
| 36 |
|
| 37 |
namespace JS { |
| 38 |
struct ExpandoAndGeneration; |
| 39 |
} |
| 40 |
|
| 41 |
using JS::ExpandoAndGeneration; |
| 42 |
|
| 43 |
namespace js { |
| 44 |
namespace jit { |
| 45 |
|
| 46 |
// IonCacheIRCompiler compiles CacheIR to IonIC native code. |
| 47 |
IonCacheIRCompiler::IonCacheIRCompiler(JSContext* cx, TempAllocator& alloc, |
| 48 |
const CacheIRWriter& writer, IonIC* ic, |
| 49 |
IonScript* ionScript, |
| 50 |
uint32_t stubDataOffset) |
| 51 |
: CacheIRCompiler(cx, alloc, writer, stubDataOffset, Mode::Ion, |
| 52 |
StubFieldPolicy::Constant), |
| 53 |
writer_(writer), |
| 54 |
ic_(ic), |
| 55 |
ionScript_(ionScript), |
| 56 |
savedLiveRegs_(false), |
| 57 |
localTracingSlots_(0), |
| 58 |
perfSpewer_(ic->pc()) { |
| 59 |
MOZ_ASSERT(ic_); |
| 60 |
MOZ_ASSERT(ionScript_); |
| 61 |
} |
| 62 |
|
| 63 |
template <typename T> |
| 64 |
T IonCacheIRCompiler::rawPointerStubField(uint32_t offset) { |
| 65 |
static_assert(sizeof(T) == sizeof(uintptr_t), "T must have pointer size"); |
| 66 |
return (T)readStubWord(offset, StubField::Type::RawPointer); |
| 67 |
} |
| 68 |
|
| 69 |
template <typename T> |
| 70 |
T IonCacheIRCompiler::rawInt64StubField(uint32_t offset) { |
| 71 |
static_assert(sizeof(T) == sizeof(int64_t), "T musthave int64 size"); |
| 72 |
return (T)readStubInt64(offset, StubField::Type::RawInt64); |
| 73 |
} |
| 74 |
|
| 75 |
template <typename Fn, Fn fn> |
| 76 |
void IonCacheIRCompiler::callVM(MacroAssembler& masm) { |
| 77 |
VMFunctionId id = VMFunctionToId<Fn, fn>::id; |
| 78 |
callVMInternal(masm, id); |
| 79 |
} |
| 80 |
|
| 81 |
void IonCacheIRCompiler::pushStubCodePointer() { |
| 82 |
stubJitCodeOffset_.emplace(masm.PushWithPatch(ImmPtr((void*)-1))); |
| 83 |
} |
| 84 |
|
| 85 |
// AutoSaveLiveRegisters must be used when we make a call that can GC. The |
| 86 |
// constructor ensures all live registers are stored on the stack (where the GC |
| 87 |
// expects them) and the destructor restores these registers. |
| 88 |
AutoSaveLiveRegisters::AutoSaveLiveRegisters(IonCacheIRCompiler& compiler) |
| 89 |
: compiler_(compiler) { |
| 90 |
MOZ_ASSERT(compiler_.liveRegs_.isSome()); |
| 91 |
MOZ_ASSERT(compiler_.ic_); |
| 92 |
compiler_.allocator.saveIonLiveRegisters( |
| 93 |
compiler_.masm, compiler_.liveRegs_.ref(), |
| 94 |
compiler_.ic_->scratchRegisterForEntryJump(), compiler_.ionScript_); |
| 95 |
compiler_.savedLiveRegs_ = true; |
| 96 |
} |
| 97 |
AutoSaveLiveRegisters::~AutoSaveLiveRegisters() { |
| 98 |
MOZ_ASSERT(compiler_.stubJitCodeOffset_.isSome(), |
| 99 |
"Must have pushed JitCode* pointer"); |
| 100 |
compiler_.allocator.restoreIonLiveRegisters(compiler_.masm, |
| 101 |
compiler_.liveRegs_.ref()); |
| 102 |
MOZ_ASSERT_IF(!compiler_.masm.oom(), compiler_.masm.framePushed() == |
| 103 |
compiler_.ionScript_->frameSize()); |
| 104 |
} |
| 105 |
|
| 106 |
} // namespace jit |
| 107 |
} // namespace js |
| 108 |
|
| 109 |
void CacheRegisterAllocator::saveIonLiveRegisters(MacroAssembler& masm, |
| 110 |
LiveRegisterSet liveRegs, |
| 111 |
Register scratch, |
| 112 |
IonScript* ionScript) { |
| 113 |
// We have to push all registers in liveRegs on the stack. It's possible we |
| 114 |
// stored other values in our live registers and stored operands on the |
| 115 |
// stack (where our live registers should go), so this requires some careful |
| 116 |
// work. Try to keep it simple by taking one small step at a time. |
| 117 |
|
| 118 |
// Step 1. Discard any dead operands so we can reuse their registers. |
| 119 |
freeDeadOperandLocations(masm); |
| 120 |
|
| 121 |
// Step 2. Figure out the size of our live regs. This is consistent with |
| 122 |
// the fact that we're using storeRegsInMask to generate the save code and |
| 123 |
// PopRegsInMask to generate the restore code. |
| 124 |
size_t sizeOfLiveRegsInBytes = |
| 125 |
MacroAssembler::PushRegsInMaskSizeInBytes(liveRegs); |
| 126 |
|
| 127 |
MOZ_ASSERT(sizeOfLiveRegsInBytes > 0); |
| 128 |
|
| 129 |
// Step 3. Ensure all non-input operands are on the stack. |
| 130 |
size_t numInputs = writer_.numInputOperands(); |
| 131 |
for (size_t i = numInputs; i < operandLocations_.length(); i++) { |
| 132 |
OperandLocation& loc = operandLocations_[i]; |
| 133 |
if (loc.isInRegister()) { |
| 134 |
spillOperandToStack(masm, &loc); |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
// Step 4. Restore the register state, but don't discard the stack as |
| 139 |
// non-input operands are stored there. |
| 140 |
restoreInputState(masm, /* shouldDiscardStack = */ false); |
| 141 |
|
| 142 |
// We just restored the input state, so no input operands should be stored |
| 143 |
// on the stack. |
| 144 |
#ifdef DEBUG |
| 145 |
for (size_t i = 0; i < numInputs; i++) { |
| 146 |
const OperandLocation& loc = operandLocations_[i]; |
| 147 |
MOZ_ASSERT(!loc.isOnStack()); |
| 148 |
} |
| 149 |
#endif |
| 150 |
|
| 151 |
// Step 5. At this point our register state is correct. Stack values, |
| 152 |
// however, may cover the space where we have to store the live registers. |
| 153 |
// Move them out of the way. |
| 154 |
|
| 155 |
bool hasOperandOnStack = false; |
| 156 |
for (size_t i = numInputs; i < operandLocations_.length(); i++) { |
| 157 |
OperandLocation& loc = operandLocations_[i]; |
| 158 |
if (!loc.isOnStack()) { |
| 159 |
continue; |
| 160 |
} |
| 161 |
|
| 162 |
hasOperandOnStack = true; |
| 163 |
|
| 164 |
size_t operandSize = loc.stackSizeInBytes(); |
| 165 |
size_t operandStackPushed = loc.stackPushed(); |
| 166 |
MOZ_ASSERT(operandSize > 0); |
| 167 |
MOZ_ASSERT(stackPushed_ >= operandStackPushed); |
| 168 |
MOZ_ASSERT(operandStackPushed >= operandSize); |
| 169 |
|
| 170 |
// If this operand doesn't cover the live register space, there's |
| 171 |
// nothing to do. |
| 172 |
if (operandStackPushed - operandSize >= sizeOfLiveRegsInBytes) { |
| 173 |
MOZ_ASSERT(stackPushed_ > sizeOfLiveRegsInBytes); |
| 174 |
continue; |
| 175 |
} |
| 176 |
|
| 177 |
// Reserve stack space for the live registers if needed. |
| 178 |
if (sizeOfLiveRegsInBytes > stackPushed_) { |
| 179 |
size_t extraBytes = sizeOfLiveRegsInBytes - stackPushed_; |
| 180 |
MOZ_ASSERT((extraBytes % sizeof(uintptr_t)) == 0); |
| 181 |
masm.subFromStackPtr(Imm32(extraBytes)); |
| 182 |
stackPushed_ += extraBytes; |
| 183 |
} |
| 184 |
|
| 185 |
// Push the operand below the live register space. |
| 186 |
if (loc.kind() == OperandLocation::PayloadStack) { |
| 187 |
masm.push( |
| 188 |
Address(masm.getStackPointer(), stackPushed_ - operandStackPushed)); |
| 189 |
stackPushed_ += operandSize; |
| 190 |
loc.setPayloadStack(stackPushed_, loc.payloadType()); |
| 191 |
continue; |
| 192 |
} |
| 193 |
MOZ_ASSERT(loc.kind() == OperandLocation::ValueStack); |
| 194 |
masm.pushValue( |
| 195 |
Address(masm.getStackPointer(), stackPushed_ - operandStackPushed)); |
| 196 |
stackPushed_ += operandSize; |
| 197 |
loc.setValueStack(stackPushed_); |
| 198 |
} |
| 199 |
|
| 200 |
// Step 6. If we have any operands on the stack, adjust their stackPushed |
| 201 |
// values to not include sizeOfLiveRegsInBytes (this simplifies code down |
| 202 |
// the line). Then push/store the live registers. |
| 203 |
if (hasOperandOnStack) { |
| 204 |
MOZ_ASSERT(stackPushed_ > sizeOfLiveRegsInBytes); |
| 205 |
stackPushed_ -= sizeOfLiveRegsInBytes; |
| 206 |
|
| 207 |
for (size_t i = numInputs; i < operandLocations_.length(); i++) { |
| 208 |
OperandLocation& loc = operandLocations_[i]; |
| 209 |
if (loc.isOnStack()) { |
| 210 |
loc.adjustStackPushed(-int32_t(sizeOfLiveRegsInBytes)); |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
size_t stackBottom = stackPushed_ + sizeOfLiveRegsInBytes; |
| 215 |
masm.storeRegsInMask(liveRegs, Address(masm.getStackPointer(), stackBottom), |
| 216 |
scratch); |
| 217 |
masm.setFramePushed(masm.framePushed() + sizeOfLiveRegsInBytes); |
| 218 |
} else { |
| 219 |
// If no operands are on the stack, discard the unused stack space. |
| 220 |
if (stackPushed_ > 0) { |
| 221 |
masm.addToStackPtr(Imm32(stackPushed_)); |
| 222 |
stackPushed_ = 0; |
| 223 |
} |
| 224 |
masm.PushRegsInMask(liveRegs); |
| 225 |
} |
| 226 |
freePayloadSlots_.clear(); |
| 227 |
freeValueSlots_.clear(); |
| 228 |
|
| 229 |
MOZ_ASSERT_IF(!masm.oom(), masm.framePushed() == ionScript->frameSize() + |
| 230 |
sizeOfLiveRegsInBytes); |
| 231 |
|
| 232 |
// Step 7. All live registers and non-input operands are stored on the stack |
| 233 |
// now, so at this point all registers except for the input registers are |
| 234 |
// available. |
| 235 |
availableRegs_.set() = GeneralRegisterSet::Not(inputRegisterSet()); |
| 236 |
availableRegsAfterSpill_.set() = GeneralRegisterSet(); |
| 237 |
|
| 238 |
// Step 8. We restored our input state, so we have to fix up aliased input |
| 239 |
// registers again. |
| 240 |
fixupAliasedInputs(masm); |
| 241 |
} |
| 242 |
|
| 243 |
void CacheRegisterAllocator::restoreIonLiveRegisters(MacroAssembler& masm, |
| 244 |
LiveRegisterSet liveRegs) { |
| 245 |
masm.PopRegsInMask(liveRegs); |
| 246 |
|
| 247 |
availableRegs_.set() = GeneralRegisterSet(); |
| 248 |
availableRegsAfterSpill_.set() = GeneralRegisterSet::All(); |
| 249 |
} |
| 250 |
|
| 251 |
static void* GetReturnAddressToIonCode(JSContext* cx) { |
| 252 |
JSJitFrameIter frame(cx->activation()->asJit()); |
| 253 |
MOZ_ASSERT(frame.type() == FrameType::Exit, |
| 254 |
"An exit frame is expected as update functions are called with a " |
| 255 |
"VMFunction."); |
| 256 |
|
| 257 |
void* returnAddr = frame.returnAddress(); |
| 258 |
#ifdef DEBUG |
| 259 |
++frame; |
| 260 |
MOZ_ASSERT(frame.isIonJS()); |
| 261 |
#endif |
| 262 |
return returnAddr; |
| 263 |
} |
| 264 |
|
| 265 |
// The AutoSaveLiveRegisters parameter is used to ensure registers were saved |
| 266 |
void IonCacheIRCompiler::enterStubFrame(MacroAssembler& masm, |
| 267 |
const AutoSaveLiveRegisters&) { |
| 268 |
MOZ_ASSERT(!enteredStubFrame_); |
| 269 |
pushStubCodePointer(); |
| 270 |
masm.PushFrameDescriptor(FrameType::IonJS); |
| 271 |
masm.Push(ImmPtr(GetReturnAddressToIonCode(cx_))); |
| 272 |
|
| 273 |
masm.Push(FramePointer); |
| 274 |
masm.moveStackPtrTo(FramePointer); |
| 275 |
|
| 276 |
enteredStubFrame_ = true; |
| 277 |
} |
| 278 |
|
| 279 |
void IonCacheIRCompiler::storeTracedValue(MacroAssembler& masm, |
| 280 |
ValueOperand value) { |
| 281 |
MOZ_ASSERT(localTracingSlots_ < 255); |
| 282 |
masm.Push(value); |
| 283 |
localTracingSlots_++; |
| 284 |
} |
| 285 |
|
| 286 |
void IonCacheIRCompiler::loadTracedValue(MacroAssembler& masm, |
| 287 |
uint8_t slotIndex, |
| 288 |
ValueOperand value) { |
| 289 |
MOZ_ASSERT(slotIndex <= localTracingSlots_); |
| 290 |
int32_t offset = IonICCallFrameLayout::LocallyTracedValueOffset + |
| 291 |
slotIndex * sizeof(Value); |
| 292 |
masm.loadValue(Address(FramePointer, -offset), value); |
| 293 |
} |
| 294 |
|
| 295 |
bool IonCacheIRCompiler::init() { |
| 296 |
if (!allocator.init()) { |
| 297 |
return false; |
| 298 |
} |
| 299 |
|
| 300 |
size_t numInputs = writer_.numInputOperands(); |
| 301 |
MOZ_ASSERT(numInputs == NumInputsForCacheKind(ic_->kind())); |
| 302 |
|
| 303 |
AllocatableGeneralRegisterSet available; |
| 304 |
|
| 305 |
switch (ic_->kind()) { |
| 306 |
case CacheKind::GetProp: |
| 307 |
case CacheKind::GetElem: { |
| 308 |
IonGetPropertyIC* ic = ic_->asGetPropertyIC(); |
| 309 |
ValueOperand output = ic->output(); |
| 310 |
|
| 311 |
available.add(output); |
| 312 |
|
| 313 |
liveRegs_.emplace(ic->liveRegs()); |
| 314 |
outputUnchecked_.emplace(output); |
| 315 |
|
| 316 |
MOZ_ASSERT(numInputs == 1 || numInputs == 2); |
| 317 |
|
| 318 |
allocator.initInputLocation(0, ic->value()); |
| 319 |
if (numInputs > 1) { |
| 320 |
allocator.initInputLocation(1, ic->id()); |
| 321 |
} |
| 322 |
break; |
| 323 |
} |
| 324 |
case CacheKind::GetPropSuper: |
| 325 |
case CacheKind::GetElemSuper: { |
| 326 |
IonGetPropSuperIC* ic = ic_->asGetPropSuperIC(); |
| 327 |
ValueOperand output = ic->output(); |
| 328 |
|
| 329 |
available.add(output); |
| 330 |
|
| 331 |
liveRegs_.emplace(ic->liveRegs()); |
| 332 |
outputUnchecked_.emplace(output); |
| 333 |
|
| 334 |
MOZ_ASSERT(numInputs == 2 || numInputs == 3); |
| 335 |
|
| 336 |
allocator.initInputLocation(0, ic->object(), JSVAL_TYPE_OBJECT); |
| 337 |
|
| 338 |
if (ic->kind() == CacheKind::GetPropSuper) { |
| 339 |
MOZ_ASSERT(numInputs == 2); |
| 340 |
allocator.initInputLocation(1, ic->receiver()); |
| 341 |
} else { |
| 342 |
MOZ_ASSERT(numInputs == 3); |
| 343 |
allocator.initInputLocation(1, ic->id()); |
| 344 |
allocator.initInputLocation(2, ic->receiver()); |
| 345 |
} |
| 346 |
break; |
| 347 |
} |
| 348 |
case CacheKind::SetProp: |
| 349 |
case CacheKind::SetElem: { |
| 350 |
IonSetPropertyIC* ic = ic_->asSetPropertyIC(); |
| 351 |
|
| 352 |
available.add(ic->temp()); |
| 353 |
|
| 354 |
liveRegs_.emplace(ic->liveRegs()); |
| 355 |
|
| 356 |
allocator.initInputLocation(0, ic->object(), JSVAL_TYPE_OBJECT); |
| 357 |
|
| 358 |
if (ic->kind() == CacheKind::SetProp) { |
| 359 |
MOZ_ASSERT(numInputs == 2); |
| 360 |
allocator.initInputLocation(1, ic->rhs()); |
| 361 |
} else { |
| 362 |
MOZ_ASSERT(numInputs == 3); |
| 363 |
allocator.initInputLocation(1, ic->id()); |
| 364 |
allocator.initInputLocation(2, ic->rhs()); |
| 365 |
} |
| 366 |
break; |
| 367 |
} |
| 368 |
case CacheKind::GetName: { |
| 369 |
IonGetNameIC* ic = ic_->asGetNameIC(); |
| 370 |
ValueOperand output = ic->output(); |
| 371 |
|
| 372 |
available.add(output); |
| 373 |
available.add(ic->temp()); |
| 374 |
|
| 375 |
liveRegs_.emplace(ic->liveRegs()); |
| 376 |
outputUnchecked_.emplace(output); |
| 377 |
|
| 378 |
MOZ_ASSERT(numInputs == 1); |
| 379 |
allocator.initInputLocation(0, ic->environment(), JSVAL_TYPE_OBJECT); |
| 380 |
break; |
| 381 |
} |
| 382 |
case CacheKind::BindName: { |
| 383 |
IonBindNameIC* ic = ic_->asBindNameIC(); |
| 384 |
Register output = ic->output(); |
| 385 |
|
| 386 |
available.add(output); |
| 387 |
available.add(ic->temp()); |
| 388 |
|
| 389 |
liveRegs_.emplace(ic->liveRegs()); |
| 390 |
outputUnchecked_.emplace( |
| 391 |
TypedOrValueRegister(MIRType::Object, AnyRegister(output))); |
| 392 |
|
| 393 |
MOZ_ASSERT(numInputs == 1); |
| 394 |
allocator.initInputLocation(0, ic->environment(), JSVAL_TYPE_OBJECT); |
| 395 |
break; |
| 396 |
} |
| 397 |
case CacheKind::GetIterator: { |
| 398 |
IonGetIteratorIC* ic = ic_->asGetIteratorIC(); |
| 399 |
Register output = ic->output(); |
| 400 |
|
| 401 |
available.add(output); |
| 402 |
available.add(ic->temp1()); |
| 403 |
available.add(ic->temp2()); |
| 404 |
|
| 405 |
liveRegs_.emplace(ic->liveRegs()); |
| 406 |
outputUnchecked_.emplace( |
| 407 |
TypedOrValueRegister(MIRType::Object, AnyRegister(output))); |
| 408 |
|
| 409 |
MOZ_ASSERT(numInputs == 1); |
| 410 |
allocator.initInputLocation(0, ic->value()); |
| 411 |
break; |
| 412 |
} |
| 413 |
case CacheKind::OptimizeSpreadCall: { |
| 414 |
auto* ic = ic_->asOptimizeSpreadCallIC(); |
| 415 |
ValueOperand output = ic->output(); |
| 416 |
|
| 417 |
available.add(output); |
| 418 |
available.add(ic->temp()); |
| 419 |
|
| 420 |
liveRegs_.emplace(ic->liveRegs()); |
| 421 |
outputUnchecked_.emplace(output); |
| 422 |
|
| 423 |
MOZ_ASSERT(numInputs == 1); |
| 424 |
allocator.initInputLocation(0, ic->value()); |
| 425 |
break; |
| 426 |
} |
| 427 |
case CacheKind::In: { |
| 428 |
IonInIC* ic = ic_->asInIC(); |
| 429 |
Register output = ic->output(); |
| 430 |
|
| 431 |
available.add(output); |
| 432 |
|
| 433 |
liveRegs_.emplace(ic->liveRegs()); |
| 434 |
outputUnchecked_.emplace( |
| 435 |
TypedOrValueRegister(MIRType::Boolean, AnyRegister(output))); |
| 436 |
|
| 437 |
MOZ_ASSERT(numInputs == 2); |
| 438 |
allocator.initInputLocation(0, ic->key()); |
| 439 |
allocator.initInputLocation( |
| 440 |
1, TypedOrValueRegister(MIRType::Object, AnyRegister(ic->object()))); |
| 441 |
break; |
| 442 |
} |
| 443 |
case CacheKind::HasOwn: { |
| 444 |
IonHasOwnIC* ic = ic_->asHasOwnIC(); |
| 445 |
Register output = ic->output(); |
| 446 |
|
| 447 |
available.add(output); |
| 448 |
|
| 449 |
liveRegs_.emplace(ic->liveRegs()); |
| 450 |
outputUnchecked_.emplace( |
| 451 |
TypedOrValueRegister(MIRType::Boolean, AnyRegister(output))); |
| 452 |
|
| 453 |
MOZ_ASSERT(numInputs == 2); |
| 454 |
allocator.initInputLocation(0, ic->id()); |
| 455 |
allocator.initInputLocation(1, ic->value()); |
| 456 |
break; |
| 457 |
} |
| 458 |
case CacheKind::CheckPrivateField: { |
| 459 |
IonCheckPrivateFieldIC* ic = ic_->asCheckPrivateFieldIC(); |
| 460 |
Register output = ic->output(); |
| 461 |
|
| 462 |
available.add(output); |
| 463 |
|
| 464 |
liveRegs_.emplace(ic->liveRegs()); |
| 465 |
outputUnchecked_.emplace( |
| 466 |
TypedOrValueRegister(MIRType::Boolean, AnyRegister(output))); |
| 467 |
|
| 468 |
MOZ_ASSERT(numInputs == 2); |
| 469 |
allocator.initInputLocation(0, ic->value()); |
| 470 |
allocator.initInputLocation(1, ic->id()); |
| 471 |
break; |
| 472 |
} |
| 473 |
case CacheKind::InstanceOf: { |
| 474 |
IonInstanceOfIC* ic = ic_->asInstanceOfIC(); |
| 475 |
Register output = ic->output(); |
| 476 |
available.add(output); |
| 477 |
liveRegs_.emplace(ic->liveRegs()); |
| 478 |
outputUnchecked_.emplace( |
| 479 |
TypedOrValueRegister(MIRType::Boolean, AnyRegister(output))); |
| 480 |
|
| 481 |
MOZ_ASSERT(numInputs == 2); |
| 482 |
allocator.initInputLocation(0, ic->lhs()); |
| 483 |
allocator.initInputLocation( |
| 484 |
1, TypedOrValueRegister(MIRType::Object, AnyRegister(ic->rhs()))); |
| 485 |
break; |
| 486 |
} |
| 487 |
case CacheKind::ToPropertyKey: { |
| 488 |
IonToPropertyKeyIC* ic = ic_->asToPropertyKeyIC(); |
| 489 |
ValueOperand output = ic->output(); |
| 490 |
|
| 491 |
available.add(output); |
| 492 |
|
| 493 |
liveRegs_.emplace(ic->liveRegs()); |
| 494 |
outputUnchecked_.emplace(TypedOrValueRegister(output)); |
| 495 |
|
| 496 |
MOZ_ASSERT(numInputs == 1); |
| 497 |
allocator.initInputLocation(0, ic->input()); |
| 498 |
break; |
| 499 |
} |
| 500 |
case CacheKind::UnaryArith: { |
| 501 |
IonUnaryArithIC* ic = ic_->asUnaryArithIC(); |
| 502 |
ValueOperand output = ic->output(); |
| 503 |
|
| 504 |
available.add(output); |
| 505 |
|
| 506 |
liveRegs_.emplace(ic->liveRegs()); |
| 507 |
outputUnchecked_.emplace(TypedOrValueRegister(output)); |
| 508 |
|
| 509 |
MOZ_ASSERT(numInputs == 1); |
| 510 |
allocator.initInputLocation(0, ic->input()); |
| 511 |
break; |
| 512 |
} |
| 513 |
case CacheKind::BinaryArith: { |
| 514 |
IonBinaryArithIC* ic = ic_->asBinaryArithIC(); |
| 515 |
ValueOperand output = ic->output(); |
| 516 |
|
| 517 |
available.add(output); |
| 518 |
|
| 519 |
liveRegs_.emplace(ic->liveRegs()); |
| 520 |
outputUnchecked_.emplace(TypedOrValueRegister(output)); |
| 521 |
|
| 522 |
MOZ_ASSERT(numInputs == 2); |
| 523 |
allocator.initInputLocation(0, ic->lhs()); |
| 524 |
allocator.initInputLocation(1, ic->rhs()); |
| 525 |
break; |
| 526 |
} |
| 527 |
case CacheKind::Compare: { |
| 528 |
IonCompareIC* ic = ic_->asCompareIC(); |
| 529 |
Register output = ic->output(); |
| 530 |
|
| 531 |
available.add(output); |
| 532 |
|
| 533 |
liveRegs_.emplace(ic->liveRegs()); |
| 534 |
outputUnchecked_.emplace( |
| 535 |
TypedOrValueRegister(MIRType::Boolean, AnyRegister(output))); |
| 536 |
|
| 537 |
MOZ_ASSERT(numInputs == 2); |
| 538 |
allocator.initInputLocation(0, ic->lhs()); |
| 539 |
allocator.initInputLocation(1, ic->rhs()); |
| 540 |
break; |
| 541 |
} |
| 542 |
case CacheKind::CloseIter: { |
| 543 |
IonCloseIterIC* ic = ic_->asCloseIterIC(); |
| 544 |
|
| 545 |
available.add(ic->temp()); |
| 546 |
|
| 547 |
liveRegs_.emplace(ic->liveRegs()); |
| 548 |
allocator.initInputLocation(0, ic->iter(), JSVAL_TYPE_OBJECT); |
| 549 |
break; |
| 550 |
} |
| 551 |
case CacheKind::OptimizeGetIterator: { |
| 552 |
auto* ic = ic_->asOptimizeGetIteratorIC(); |
| 553 |
Register output = ic->output(); |
| 554 |
|
| 555 |
available.add(output); |
| 556 |
available.add(ic->temp()); |
| 557 |
|
| 558 |
liveRegs_.emplace(ic->liveRegs()); |
| 559 |
outputUnchecked_.emplace( |
| 560 |
TypedOrValueRegister(MIRType::Boolean, AnyRegister(output))); |
| 561 |
|
| 562 |
MOZ_ASSERT(numInputs == 1); |
| 563 |
allocator.initInputLocation(0, ic->value()); |
| 564 |
break; |
| 565 |
} |
| 566 |
case CacheKind::Call: |
| 567 |
case CacheKind::TypeOf: |
| 568 |
case CacheKind::TypeOfEq: |
| 569 |
case CacheKind::ToBool: |
| 570 |
case CacheKind::LazyConstant: |
| 571 |
case CacheKind::NewArray: |
| 572 |
case CacheKind::NewObject: |
| 573 |
case CacheKind::Lambda: |
| 574 |
case CacheKind::GetImport: |
| 575 |
MOZ_CRASH("Unsupported IC"); |
| 576 |
} |
| 577 |
|
| 578 |
liveFloatRegs_ = LiveFloatRegisterSet(liveRegs_->fpus()); |
| 579 |
|
| 580 |
allocator.initAvailableRegs(available); |
| 581 |
allocator.initAvailableRegsAfterSpill(); |
| 582 |
return true; |
| 583 |
} |
| 584 |
|
| 585 |
JitCode* IonCacheIRCompiler::compile(IonICStub* stub) { |
| 586 |
AutoCreatedBy acb(masm, "IonCacheIRCompiler::compile"); |
| 587 |
|
| 588 |
masm.setFramePushed(ionScript_->frameSize()); |
| 589 |
if (cx_->runtime()->geckoProfiler().enabled()) { |
| 590 |
masm.enableProfilingInstrumentation(); |
| 591 |
} |
| 592 |
|
| 593 |
allocator.fixupAliasedInputs(masm); |
| 594 |
|
| 595 |
CacheIRReader reader(writer_); |
| 596 |
do { |
| 597 |
CacheOp op = reader.readOp(); |
| 598 |
perfSpewer_.recordInstruction(masm, op); |
| 599 |
switch (op) { |
| 600 |
#define DEFINE_OP(op, ...) \ |
| 601 |
case CacheOp::op: \ |
| 602 |
if (!emit##op(reader)) return nullptr; \ |
| 603 |
break; |
| 604 |
CACHE_IR_OPS(DEFINE_OP) |
| 605 |
#undef DEFINE_OP |
| 606 |
|
| 607 |
default: |
| 608 |
MOZ_CRASH("Invalid op"); |
| 609 |
} |
| 610 |
allocator.nextOp(); |
| 611 |
} while (reader.more()); |
| 612 |
|
| 613 |
masm.assumeUnreachable("Should have returned from IC"); |
| 614 |
|
| 615 |
// Done emitting the main IC code. Now emit the failure paths. |
| 616 |
for (size_t i = 0; i < failurePaths.length(); i++) { |
| 617 |
if (!emitFailurePath(i)) { |
| 618 |
return nullptr; |
| 619 |
} |
| 620 |
Register scratch = ic_->scratchRegisterForEntryJump(); |
| 621 |
CodeOffset offset = masm.movWithPatch(ImmWord(-1), scratch); |
| 622 |
masm.jump(Address(scratch, 0)); |
| 623 |
if (!nextCodeOffsets_.append(offset)) { |
| 624 |
return nullptr; |
| 625 |
} |
| 626 |
} |
| 627 |
|
| 628 |
Linker linker(masm); |
| 629 |
Rooted<JitCode*> newStubCode(cx_, linker.newCode(cx_, CodeKind::Ion)); |
| 630 |
if (!newStubCode) { |
| 631 |
cx_->recoverFromOutOfMemory(); |
| 632 |
return nullptr; |
| 633 |
} |
| 634 |
|
| 635 |
newStubCode->setLocalTracingSlots(localTracingSlots_); |
| 636 |
|
| 637 |
for (CodeOffset offset : nextCodeOffsets_) { |
| 638 |
Assembler::PatchDataWithValueCheck(CodeLocationLabel(newStubCode, offset), |
| 639 |
ImmPtr(stub->nextCodeRawPtr()), |
| 640 |
ImmPtr((void*)-1)); |
| 641 |
} |
| 642 |
if (stubJitCodeOffset_) { |
| 643 |
Assembler::PatchDataWithValueCheck( |
| 644 |
CodeLocationLabel(newStubCode, *stubJitCodeOffset_), |
| 645 |
ImmPtr(newStubCode.get()), ImmPtr((void*)-1)); |
| 646 |
} |
| 647 |
|
| 648 |
return newStubCode; |
| 649 |
} |
| 650 |
|
| 651 |
#ifdef DEBUG |
| 652 |
void IonCacheIRCompiler::assertFloatRegisterAvailable(FloatRegister reg) { |
| 653 |
switch (ic_->kind()) { |
| 654 |
case CacheKind::GetProp: |
| 655 |
case CacheKind::GetElem: |
| 656 |
case CacheKind::GetPropSuper: |
| 657 |
case CacheKind::GetElemSuper: |
| 658 |
case CacheKind::GetName: |
| 659 |
case CacheKind::BindName: |
| 660 |
case CacheKind::GetIterator: |
| 661 |
case CacheKind::In: |
| 662 |
case CacheKind::HasOwn: |
| 663 |
case CacheKind::CheckPrivateField: |
| 664 |
case CacheKind::InstanceOf: |
| 665 |
case CacheKind::UnaryArith: |
| 666 |
case CacheKind::ToPropertyKey: |
| 667 |
case CacheKind::OptimizeSpreadCall: |
| 668 |
case CacheKind::CloseIter: |
| 669 |
case CacheKind::OptimizeGetIterator: |
| 670 |
MOZ_CRASH("No float registers available"); |
| 671 |
case CacheKind::SetProp: |
| 672 |
case CacheKind::SetElem: |
| 673 |
// FloatReg0 is available per LIRGenerator::visitSetPropertyCache. |
| 674 |
MOZ_ASSERT(reg == FloatReg0); |
| 675 |
break; |
| 676 |
case CacheKind::BinaryArith: |
| 677 |
case CacheKind::Compare: |
| 678 |
// FloatReg0 and FloatReg1 are available per |
| 679 |
// LIRGenerator::visitBinaryCache. |
| 680 |
MOZ_ASSERT(reg == FloatReg0 || reg == FloatReg1); |
| 681 |
break; |
| 682 |
case CacheKind::Call: |
| 683 |
case CacheKind::TypeOf: |
| 684 |
case CacheKind::TypeOfEq: |
| 685 |
case CacheKind::ToBool: |
| 686 |
case CacheKind::LazyConstant: |
| 687 |
case CacheKind::NewArray: |
| 688 |
case CacheKind::NewObject: |
| 689 |
case CacheKind::Lambda: |
| 690 |
case CacheKind::GetImport: |
| 691 |
MOZ_CRASH("Unsupported IC"); |
| 692 |
} |
| 693 |
} |
| 694 |
#endif |
| 695 |
|
| 696 |
bool IonCacheIRCompiler::emitGuardShape(ObjOperandId objId, |
| 697 |
uint32_t shapeOffset) { |
| 698 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 699 |
Register obj = allocator.useRegister(masm, objId); |
| 700 |
Shape* shape = weakShapeStubField(shapeOffset); |
| 701 |
|
| 702 |
bool needSpectreMitigations = objectGuardNeedsSpectreMitigations(objId); |
| 703 |
|
| 704 |
Maybe<AutoScratchRegister> maybeScratch; |
| 705 |
if (needSpectreMitigations) { |
| 706 |
maybeScratch.emplace(allocator, masm); |
| 707 |
} |
| 708 |
|
| 709 |
FailurePath* failure; |
| 710 |
if (!addFailurePath(&failure)) { |
| 711 |
return false; |
| 712 |
} |
| 713 |
|
| 714 |
if (needSpectreMitigations) { |
| 715 |
masm.branchTestObjShape(Assembler::NotEqual, obj, shape, *maybeScratch, obj, |
| 716 |
failure->label()); |
| 717 |
} else { |
| 718 |
masm.branchTestObjShapeNoSpectreMitigations(Assembler::NotEqual, obj, shape, |
| 719 |
failure->label()); |
| 720 |
} |
| 721 |
|
| 722 |
return true; |
| 723 |
} |
| 724 |
|
| 725 |
bool IonCacheIRCompiler::emitGuardProto(ObjOperandId objId, |
| 726 |
uint32_t protoOffset) { |
| 727 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 728 |
Register obj = allocator.useRegister(masm, objId); |
| 729 |
JSObject* proto = weakObjectStubField(protoOffset); |
| 730 |
|
| 731 |
AutoScratchRegister scratch(allocator, masm); |
| 732 |
|
| 733 |
FailurePath* failure; |
| 734 |
if (!addFailurePath(&failure)) { |
| 735 |
return false; |
| 736 |
} |
| 737 |
|
| 738 |
masm.loadObjProto(obj, scratch); |
| 739 |
masm.branchPtr(Assembler::NotEqual, scratch, ImmGCPtr(proto), |
| 740 |
failure->label()); |
| 741 |
return true; |
| 742 |
} |
| 743 |
|
| 744 |
bool IonCacheIRCompiler::emitGuardCompartment(ObjOperandId objId, |
| 745 |
uint32_t globalOffset, |
| 746 |
uint32_t compartmentOffset) { |
| 747 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 748 |
Register obj = allocator.useRegister(masm, objId); |
| 749 |
JSObject* globalWrapper = objectStubField(globalOffset); |
| 750 |
JS::Compartment* compartment = compartmentStubField(compartmentOffset); |
| 751 |
AutoScratchRegister scratch(allocator, masm); |
| 752 |
|
| 753 |
FailurePath* failure; |
| 754 |
if (!addFailurePath(&failure)) { |
| 755 |
return false; |
| 756 |
} |
| 757 |
|
| 758 |
// Verify that the global wrapper is still valid, as |
| 759 |
// it is pre-requisite for doing the compartment check. |
| 760 |
masm.movePtr(ImmGCPtr(globalWrapper), scratch); |
| 761 |
Address handlerAddr(scratch, ProxyObject::offsetOfHandler()); |
| 762 |
masm.branchPtr(Assembler::Equal, handlerAddr, |
| 763 |
ImmPtr(&DeadObjectProxy::singleton), failure->label()); |
| 764 |
|
| 765 |
masm.branchTestObjCompartment(Assembler::NotEqual, obj, compartment, scratch, |
| 766 |
failure->label()); |
| 767 |
return true; |
| 768 |
} |
| 769 |
|
| 770 |
bool IonCacheIRCompiler::emitGuardAnyClass(ObjOperandId objId, |
| 771 |
uint32_t claspOffset) { |
| 772 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 773 |
Register obj = allocator.useRegister(masm, objId); |
| 774 |
AutoScratchRegister scratch(allocator, masm); |
| 775 |
|
| 776 |
const JSClass* clasp = classStubField(claspOffset); |
| 777 |
|
| 778 |
FailurePath* failure; |
| 779 |
if (!addFailurePath(&failure)) { |
| 780 |
return false; |
| 781 |
} |
| 782 |
|
| 783 |
if (objectGuardNeedsSpectreMitigations(objId)) { |
| 784 |
masm.branchTestObjClass(Assembler::NotEqual, obj, clasp, scratch, obj, |
| 785 |
failure->label()); |
| 786 |
} else { |
| 787 |
masm.branchTestObjClassNoSpectreMitigations(Assembler::NotEqual, obj, clasp, |
| 788 |
scratch, failure->label()); |
| 789 |
} |
| 790 |
|
| 791 |
return true; |
| 792 |
} |
| 793 |
|
| 794 |
bool IonCacheIRCompiler::emitGuardHasProxyHandler(ObjOperandId objId, |
| 795 |
uint32_t handlerOffset) { |
| 796 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 797 |
Register obj = allocator.useRegister(masm, objId); |
| 798 |
const void* handler = proxyHandlerStubField(handlerOffset); |
| 799 |
|
| 800 |
FailurePath* failure; |
| 801 |
if (!addFailurePath(&failure)) { |
| 802 |
return false; |
| 803 |
} |
| 804 |
|
| 805 |
Address handlerAddr(obj, ProxyObject::offsetOfHandler()); |
| 806 |
masm.branchPtr(Assembler::NotEqual, handlerAddr, ImmPtr(handler), |
| 807 |
failure->label()); |
| 808 |
return true; |
| 809 |
} |
| 810 |
|
| 811 |
bool IonCacheIRCompiler::emitGuardSpecificObject(ObjOperandId objId, |
| 812 |
uint32_t expectedOffset) { |
| 813 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 814 |
Register obj = allocator.useRegister(masm, objId); |
| 815 |
JSObject* expected = weakObjectStubField(expectedOffset); |
| 816 |
|
| 817 |
FailurePath* failure; |
| 818 |
if (!addFailurePath(&failure)) { |
| 819 |
return false; |
| 820 |
} |
| 821 |
|
| 822 |
masm.branchPtr(Assembler::NotEqual, obj, ImmGCPtr(expected), |
| 823 |
failure->label()); |
| 824 |
return true; |
| 825 |
} |
| 826 |
|
| 827 |
bool IonCacheIRCompiler::emitGuardSpecificFunction( |
| 828 |
ObjOperandId objId, uint32_t expectedOffset, uint32_t nargsAndFlagsOffset) { |
| 829 |
return emitGuardSpecificObject(objId, expectedOffset); |
| 830 |
} |
| 831 |
|
| 832 |
bool IonCacheIRCompiler::emitGuardSpecificAtom(StringOperandId strId, |
| 833 |
uint32_t expectedOffset) { |
| 834 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 835 |
Register str = allocator.useRegister(masm, strId); |
| 836 |
AutoScratchRegister scratch(allocator, masm); |
| 837 |
|
| 838 |
JSAtom* atom = &stringStubField(expectedOffset)->asAtom(); |
| 839 |
|
| 840 |
FailurePath* failure; |
| 841 |
if (!addFailurePath(&failure)) { |
| 842 |
return false; |
| 843 |
} |
| 844 |
|
| 845 |
LiveRegisterSet volatileRegs = liveVolatileRegs(); |
| 846 |
volatileRegs.takeUnchecked(scratch); |
| 847 |
|
| 848 |
masm.guardSpecificAtom(str, atom, scratch, volatileRegs, failure->label()); |
| 849 |
return true; |
| 850 |
} |
| 851 |
|
| 852 |
bool IonCacheIRCompiler::emitGuardSpecificSymbol(SymbolOperandId symId, |
| 853 |
uint32_t expectedOffset) { |
| 854 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 855 |
Register sym = allocator.useRegister(masm, symId); |
| 856 |
JS::Symbol* expected = symbolStubField(expectedOffset); |
| 857 |
|
| 858 |
FailurePath* failure; |
| 859 |
if (!addFailurePath(&failure)) { |
| 860 |
return false; |
| 861 |
} |
| 862 |
|
| 863 |
masm.branchPtr(Assembler::NotEqual, sym, ImmGCPtr(expected), |
| 864 |
failure->label()); |
| 865 |
return true; |
| 866 |
} |
| 867 |
|
| 868 |
bool IonCacheIRCompiler::emitGuardSpecificValue(ValOperandId valId, |
| 869 |
uint32_t expectedOffset) { |
| 870 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 871 |
ValueOperand val = allocator.useValueRegister(masm, valId); |
| 872 |
Value expected = valueStubField(expectedOffset); |
| 873 |
|
| 874 |
Maybe<AutoScratchRegister> maybeScratch; |
| 875 |
if (expected.isNaN()) { |
| 876 |
maybeScratch.emplace(allocator, masm); |
| 877 |
} |
| 878 |
|
| 879 |
FailurePath* failure; |
| 880 |
if (!addFailurePath(&failure)) { |
| 881 |
return false; |
| 882 |
} |
| 883 |
|
| 884 |
if (expected.isNaN()) { |
| 885 |
masm.branchTestNaNValue(Assembler::NotEqual, val, *maybeScratch, |
| 886 |
failure->label()); |
| 887 |
} else { |
| 888 |
masm.branchTestValue(Assembler::NotEqual, val, expected, failure->label()); |
| 889 |
} |
| 890 |
return true; |
| 891 |
} |
| 892 |
|
| 893 |
bool IonCacheIRCompiler::emitLoadValueResult(uint32_t valOffset) { |
| 894 |
MOZ_CRASH("Baseline-specific op"); |
| 895 |
} |
| 896 |
|
| 897 |
bool IonCacheIRCompiler::emitLoadFixedSlotResult(ObjOperandId objId, |
| 898 |
uint32_t offsetOffset) { |
| 899 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 900 |
AutoOutputRegister output(*this); |
| 901 |
Register obj = allocator.useRegister(masm, objId); |
| 902 |
int32_t offset = int32StubField(offsetOffset); |
| 903 |
masm.loadTypedOrValue(Address(obj, offset), output); |
| 904 |
return true; |
| 905 |
} |
| 906 |
|
| 907 |
bool IonCacheIRCompiler::emitLoadFixedSlotTypedResult(ObjOperandId objId, |
| 908 |
uint32_t offsetOffset, |
| 909 |
ValueType) { |
| 910 |
MOZ_CRASH("Call ICs not used in ion"); |
| 911 |
} |
| 912 |
|
| 913 |
bool IonCacheIRCompiler::emitLoadDynamicSlotResult(ObjOperandId objId, |
| 914 |
uint32_t offsetOffset) { |
| 915 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 916 |
AutoOutputRegister output(*this); |
| 917 |
Register obj = allocator.useRegister(masm, objId); |
| 918 |
int32_t offset = int32StubField(offsetOffset); |
| 919 |
|
| 920 |
AutoScratchRegisterMaybeOutput scratch(allocator, masm, output); |
| 921 |
masm.loadPtr(Address(obj, NativeObject::offsetOfSlots()), scratch); |
| 922 |
masm.loadTypedOrValue(Address(scratch, offset), output); |
| 923 |
return true; |
| 924 |
} |
| 925 |
|
| 926 |
bool IonCacheIRCompiler::emitCallScriptedGetterResult( |
| 927 |
ValOperandId receiverId, uint32_t getterOffset, bool sameRealm, |
| 928 |
uint32_t nargsAndFlagsOffset) { |
| 929 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 930 |
AutoSaveLiveRegisters save(*this); |
| 931 |
AutoOutputRegister output(*this); |
| 932 |
|
| 933 |
ValueOperand receiver = allocator.useValueRegister(masm, receiverId); |
| 934 |
|
| 935 |
JSFunction* target = &objectStubField(getterOffset)->as<JSFunction>(); |
| 936 |
AutoScratchRegister scratch(allocator, masm); |
| 937 |
|
| 938 |
MOZ_ASSERT(sameRealm == (cx_->realm() == target->realm())); |
| 939 |
|
| 940 |
allocator.discardStack(masm); |
| 941 |
|
| 942 |
uint32_t framePushedBefore = masm.framePushed(); |
| 943 |
|
| 944 |
enterStubFrame(masm, save); |
| 945 |
|
| 946 |
// The JitFrameLayout pushed below will be aligned to JitStackAlignment, |
| 947 |
// so we just have to make sure the stack is aligned after we push the |
| 948 |
// |this| + argument Values. |
| 949 |
uint32_t argSize = (target->nargs() + 1) * sizeof(Value); |
| 950 |
uint32_t padding = |
| 951 |
ComputeByteAlignment(masm.framePushed() + argSize, JitStackAlignment); |
| 952 |
MOZ_ASSERT(padding % sizeof(uintptr_t) == 0); |
| 953 |
MOZ_ASSERT(padding < JitStackAlignment); |
| 954 |
masm.reserveStack(padding); |
| 955 |
|
| 956 |
for (size_t i = 0; i < target->nargs(); i++) { |
| 957 |
masm.Push(UndefinedValue()); |
| 958 |
} |
| 959 |
masm.Push(receiver); |
| 960 |
|
| 961 |
if (!sameRealm) { |
| 962 |
masm.switchToRealm(target->realm(), scratch); |
| 963 |
} |
| 964 |
|
| 965 |
masm.movePtr(ImmGCPtr(target), scratch); |
| 966 |
|
| 967 |
masm.Push(scratch); |
| 968 |
masm.PushFrameDescriptorForJitCall(FrameType::IonICCall, /* argc = */ 0); |
| 969 |
|
| 970 |
// Check stack alignment. Add 2 * sizeof(uintptr_t) for the return address and |
| 971 |
// frame pointer pushed by the call/callee. |
| 972 |
MOZ_ASSERT( |
| 973 |
((masm.framePushed() + 2 * sizeof(uintptr_t)) % JitStackAlignment) == 0); |
| 974 |
|
| 975 |
MOZ_ASSERT(target->hasJitEntry()); |
| 976 |
masm.loadJitCodeRaw(scratch, scratch); |
| 977 |
masm.callJit(scratch); |
| 978 |
|
| 979 |
if (!sameRealm) { |
| 980 |
static_assert(!JSReturnOperand.aliases(ReturnReg), |
| 981 |
"ReturnReg available as scratch after scripted calls"); |
| 982 |
masm.switchToRealm(cx_->realm(), ReturnReg); |
| 983 |
} |
| 984 |
|
| 985 |
masm.storeCallResultValue(output); |
| 986 |
|
| 987 |
// Restore the frame pointer and stack pointer. |
| 988 |
masm.loadPtr(Address(FramePointer, 0), FramePointer); |
| 989 |
masm.freeStack(masm.framePushed() - framePushedBefore); |
| 990 |
return true; |
| 991 |
} |
| 992 |
|
| 993 |
#ifdef JS_PUNBOX64 |
| 994 |
template <typename IdType> |
| 995 |
bool IonCacheIRCompiler::emitCallScriptedProxyGetShared( |
| 996 |
ValOperandId targetId, ObjOperandId receiverId, ObjOperandId handlerId, |
| 997 |
ObjOperandId trapId, IdType id, uint32_t nargsAndFlags) { |
| 998 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 999 |
AutoSaveLiveRegisters save(*this); |
| 1000 |
AutoOutputRegister output(*this); |
| 1001 |
|
| 1002 |
ValueOperand target = allocator.useValueRegister(masm, targetId); |
| 1003 |
Register receiver = allocator.useRegister(masm, receiverId); |
| 1004 |
Register handler = allocator.useRegister(masm, handlerId); |
| 1005 |
Register callee = allocator.useRegister(masm, trapId); |
| 1006 |
ValueOperand idVal; |
| 1007 |
if constexpr (std::is_same_v<IdType, ValOperandId>) { |
| 1008 |
idVal = allocator.useValueRegister(masm, id); |
| 1009 |
} |
| 1010 |
size_t nargs = nargsAndFlags >> JSFunction::ArgCountShift; |
| 1011 |
|
| 1012 |
AutoScratchRegister scratch(allocator, masm); |
| 1013 |
AutoScratchRegister scratch2(allocator, masm); |
| 1014 |
ValueOperand scratchVal(scratch); |
| 1015 |
ValueOperand scratchVal2(scratch2); |
| 1016 |
|
| 1017 |
allocator.discardStack(masm); |
| 1018 |
|
| 1019 |
uint32_t framePushedBefore = masm.framePushed(); |
| 1020 |
|
| 1021 |
enterStubFrame(masm, save); |
| 1022 |
|
| 1023 |
// We need to keep the target around to potentially validate the proxy result |
| 1024 |
storeTracedValue(masm, target); |
| 1025 |
if constexpr (std::is_same_v<IdType, ValOperandId>) { |
| 1026 |
// Same for the id, assuming it's not baked in |
| 1027 |
storeTracedValue(masm, idVal); |
| 1028 |
} |
| 1029 |
uint32_t framePushedBeforeArgs = masm.framePushed(); |
| 1030 |
|
| 1031 |
// The JitFrameLayout pushed below will be aligned to JitStackAlignment, |
| 1032 |
// so we just have to make sure the stack is aligned after we push the |
| 1033 |
// |this| + argument Values. |
| 1034 |
uint32_t argSize = (std::max(nargs, (size_t)3) + 1) * sizeof(Value); |
| 1035 |
uint32_t padding = |
| 1036 |
ComputeByteAlignment(masm.framePushed() + argSize, JitStackAlignment); |
| 1037 |
MOZ_ASSERT(padding % sizeof(uintptr_t) == 0); |
| 1038 |
MOZ_ASSERT(padding < JitStackAlignment); |
| 1039 |
masm.reserveStack(padding); |
| 1040 |
|
| 1041 |
for (size_t i = 3; i < nargs; i++) { |
| 1042 |
masm.Push(UndefinedValue()); |
| 1043 |
} |
| 1044 |
|
| 1045 |
masm.tagValue(JSVAL_TYPE_OBJECT, receiver, scratchVal); |
| 1046 |
masm.Push(scratchVal); |
| 1047 |
|
| 1048 |
if constexpr (std::is_same_v<IdType, ValOperandId>) { |
| 1049 |
masm.Push(idVal); |
| 1050 |
} else { |
| 1051 |
masm.movePropertyKey(idStubField(id), scratch); |
| 1052 |
masm.tagValue(JSVAL_TYPE_STRING, scratch, scratchVal); |
| 1053 |
masm.Push(scratchVal); |
| 1054 |
} |
| 1055 |
|
| 1056 |
masm.Push(target); |
| 1057 |
|
| 1058 |
masm.tagValue(JSVAL_TYPE_OBJECT, handler, scratchVal); |
| 1059 |
masm.Push(scratchVal); |
| 1060 |
|
| 1061 |
masm.Push(callee); |
| 1062 |
masm.PushFrameDescriptorForJitCall(FrameType::IonICCall, /* argc = */ 3); |
| 1063 |
|
| 1064 |
// Check stack alignment. Add 2 * sizeof(uintptr_t) for the return address and |
| 1065 |
// frame pointer pushed by the call/callee. |
| 1066 |
MOZ_ASSERT( |
| 1067 |
((masm.framePushed() + 2 * sizeof(uintptr_t)) % JitStackAlignment) == 0); |
| 1068 |
|
| 1069 |
masm.loadJitCodeRaw(callee, scratch); |
| 1070 |
masm.callJit(scratch); |
| 1071 |
|
| 1072 |
masm.storeCallResultValue(output); |
| 1073 |
|
| 1074 |
Label success, end; |
| 1075 |
loadTracedValue(masm, 0, scratchVal); |
| 1076 |
masm.unboxObject(scratchVal, scratch); |
| 1077 |
masm.branchTestObjectNeedsProxyResultValidation(Assembler::Zero, scratch, |
| 1078 |
scratch2, &success); |
| 1079 |
|
| 1080 |
if constexpr (std::is_same_v<IdType, ValOperandId>) { |
| 1081 |
loadTracedValue(masm, 1, scratchVal2); |
| 1082 |
} else { |
| 1083 |
masm.moveValue(StringValue(idStubField(id).toString()), scratchVal2); |
| 1084 |
} |
| 1085 |
|
| 1086 |
uint32_t framePushedAfterCall = masm.framePushed(); |
| 1087 |
masm.freeStack(masm.framePushed() - framePushedBeforeArgs); |
| 1088 |
|
| 1089 |
masm.Push(output.valueReg()); |
| 1090 |
masm.Push(scratchVal2); |
| 1091 |
masm.Push(scratch); |
| 1092 |
|
| 1093 |
using Fn = bool (*)(JSContext*, HandleObject, HandleValue, HandleValue, |
| 1094 |
MutableHandleValue); |
| 1095 |
callVM<Fn, CheckProxyGetByValueResult>(masm); |
| 1096 |
|
| 1097 |
masm.storeCallResultValue(output); |
| 1098 |
|
| 1099 |
masm.jump(&end); |
| 1100 |
masm.bind(&success); |
| 1101 |
masm.setFramePushed(framePushedAfterCall); |
| 1102 |
|
| 1103 |
// Restore the frame pointer and stack pointer. |
| 1104 |
masm.loadPtr(Address(FramePointer, 0), FramePointer); |
| 1105 |
masm.freeStack(masm.framePushed() - framePushedBefore); |
| 1106 |
masm.bind(&end); |
| 1107 |
|
| 1108 |
return true; |
| 1109 |
} |
| 1110 |
|
| 1111 |
bool IonCacheIRCompiler::emitCallScriptedProxyGetResult( |
| 1112 |
ValOperandId targetId, ObjOperandId receiverId, ObjOperandId handlerId, |
| 1113 |
ObjOperandId trapId, uint32_t id, uint32_t nargsAndFlags) { |
| 1114 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1115 |
return emitCallScriptedProxyGetShared(targetId, receiverId, handlerId, trapId, |
| 1116 |
id, nargsAndFlags); |
| 1117 |
} |
| 1118 |
|
| 1119 |
bool IonCacheIRCompiler::emitCallScriptedProxyGetByValueResult( |
| 1120 |
ValOperandId targetId, ObjOperandId receiverId, ObjOperandId handlerId, |
| 1121 |
ValOperandId idId, ObjOperandId trapId, uint32_t nargsAndFlags) { |
| 1122 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1123 |
return emitCallScriptedProxyGetShared(targetId, receiverId, handlerId, trapId, |
| 1124 |
idId, nargsAndFlags); |
| 1125 |
} |
| 1126 |
#endif |
| 1127 |
|
| 1128 |
bool IonCacheIRCompiler::emitCallInlinedGetterResult( |
| 1129 |
ValOperandId receiverId, uint32_t getterOffset, uint32_t icScriptOffset, |
| 1130 |
bool sameRealm, uint32_t nargsAndFlagsOffset) { |
| 1131 |
MOZ_CRASH("Trial inlining not supported in Ion"); |
| 1132 |
} |
| 1133 |
|
| 1134 |
bool IonCacheIRCompiler::emitCallNativeGetterResult( |
| 1135 |
ValOperandId receiverId, uint32_t getterOffset, bool sameRealm, |
| 1136 |
uint32_t nargsAndFlagsOffset) { |
| 1137 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1138 |
AutoSaveLiveRegisters save(*this); |
| 1139 |
AutoOutputRegister output(*this); |
| 1140 |
|
| 1141 |
ValueOperand receiver = allocator.useValueRegister(masm, receiverId); |
| 1142 |
|
| 1143 |
JSFunction* target = &objectStubField(getterOffset)->as<JSFunction>(); |
| 1144 |
MOZ_ASSERT(target->isNativeFun()); |
| 1145 |
|
| 1146 |
AutoScratchRegisterMaybeOutput argJSContext(allocator, masm, output); |
| 1147 |
AutoScratchRegisterMaybeOutputType argUintN(allocator, masm, output); |
| 1148 |
AutoScratchRegister argVp(allocator, masm); |
| 1149 |
AutoScratchRegister scratch(allocator, masm); |
| 1150 |
|
| 1151 |
allocator.discardStack(masm); |
| 1152 |
|
| 1153 |
// Native functions have the signature: |
| 1154 |
// bool (*)(JSContext*, unsigned, Value* vp) |
| 1155 |
// Where vp[0] is space for an outparam, vp[1] is |this|, and vp[2] onward |
| 1156 |
// are the function arguments. |
| 1157 |
|
| 1158 |
// Construct vp array: |
| 1159 |
// Push receiver value for |this| |
| 1160 |
masm.Push(receiver); |
| 1161 |
// Push callee/outparam. |
| 1162 |
masm.Push(ObjectValue(*target)); |
| 1163 |
|
| 1164 |
// Preload arguments into registers. |
| 1165 |
masm.loadJSContext(argJSContext); |
| 1166 |
masm.move32(Imm32(0), argUintN); |
| 1167 |
masm.moveStackPtrTo(argVp.get()); |
| 1168 |
|
| 1169 |
// Push marking data for later use. |
| 1170 |
masm.Push(argUintN); |
| 1171 |
pushStubCodePointer(); |
| 1172 |
|
| 1173 |
if (!masm.icBuildOOLFakeExitFrame(GetReturnAddressToIonCode(cx_), save)) { |
| 1174 |
return false; |
| 1175 |
} |
| 1176 |
masm.enterFakeExitFrame(argJSContext, scratch, ExitFrameType::IonOOLNative); |
| 1177 |
|
| 1178 |
if (!sameRealm) { |
| 1179 |
masm.switchToRealm(target->realm(), scratch); |
| 1180 |
} |
| 1181 |
|
| 1182 |
// Construct and execute call. |
| 1183 |
masm.setupUnalignedABICall(scratch); |
| 1184 |
masm.passABIArg(argJSContext); |
| 1185 |
masm.passABIArg(argUintN); |
| 1186 |
masm.passABIArg(argVp); |
| 1187 |
masm.callWithABI(DynamicFunction<JSNative>(target->native()), |
| 1188 |
ABIType::General, |
| 1189 |
CheckUnsafeCallWithABI::DontCheckHasExitFrame); |
| 1190 |
|
| 1191 |
// Test for failure. |
| 1192 |
masm.branchIfFalseBool(ReturnReg, masm.exceptionLabel()); |
| 1193 |
|
| 1194 |
if (!sameRealm) { |
| 1195 |
masm.switchToRealm(cx_->realm(), ReturnReg); |
| 1196 |
} |
| 1197 |
|
| 1198 |
// Load the outparam vp[0] into output register(s). |
| 1199 |
Address outparam(masm.getStackPointer(), |
| 1200 |
IonOOLNativeExitFrameLayout::offsetOfResult()); |
| 1201 |
masm.loadValue(outparam, output.valueReg()); |
| 1202 |
|
| 1203 |
if (JitOptions.spectreJitToCxxCalls) { |
| 1204 |
masm.speculationBarrier(); |
| 1205 |
} |
| 1206 |
|
| 1207 |
masm.adjustStack(IonOOLNativeExitFrameLayout::Size(0)); |
| 1208 |
return true; |
| 1209 |
} |
| 1210 |
|
| 1211 |
bool IonCacheIRCompiler::emitCallDOMGetterResult(ObjOperandId objId, |
| 1212 |
uint32_t jitInfoOffset) { |
| 1213 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1214 |
AutoSaveLiveRegisters save(*this); |
| 1215 |
AutoOutputRegister output(*this); |
| 1216 |
|
| 1217 |
Register obj = allocator.useRegister(masm, objId); |
| 1218 |
|
| 1219 |
const JSJitInfo* info = rawPointerStubField<const JSJitInfo*>(jitInfoOffset); |
| 1220 |
|
| 1221 |
allocator.discardStack(masm); |
| 1222 |
enterStubFrame(masm, save); |
| 1223 |
|
| 1224 |
masm.Push(obj); |
| 1225 |
masm.Push(ImmPtr(info)); |
| 1226 |
|
| 1227 |
using Fn = |
| 1228 |
bool (*)(JSContext*, const JSJitInfo*, HandleObject, MutableHandleValue); |
| 1229 |
callVM<Fn, jit::CallDOMGetter>(masm); |
| 1230 |
|
| 1231 |
masm.storeCallResultValue(output); |
| 1232 |
return true; |
| 1233 |
} |
| 1234 |
|
| 1235 |
bool IonCacheIRCompiler::emitCallDOMSetter(ObjOperandId objId, |
| 1236 |
uint32_t jitInfoOffset, |
| 1237 |
ValOperandId rhsId) { |
| 1238 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1239 |
AutoSaveLiveRegisters save(*this); |
| 1240 |
|
| 1241 |
Register obj = allocator.useRegister(masm, objId); |
| 1242 |
ValueOperand val = allocator.useValueRegister(masm, rhsId); |
| 1243 |
|
| 1244 |
const JSJitInfo* info = rawPointerStubField<const JSJitInfo*>(jitInfoOffset); |
| 1245 |
|
| 1246 |
allocator.discardStack(masm); |
| 1247 |
enterStubFrame(masm, save); |
| 1248 |
|
| 1249 |
masm.Push(val); |
| 1250 |
masm.Push(obj); |
| 1251 |
masm.Push(ImmPtr(info)); |
| 1252 |
|
| 1253 |
using Fn = bool (*)(JSContext*, const JSJitInfo*, HandleObject, HandleValue); |
| 1254 |
callVM<Fn, jit::CallDOMSetter>(masm); |
| 1255 |
return true; |
| 1256 |
} |
| 1257 |
|
| 1258 |
bool IonCacheIRCompiler::emitProxyGetResult(ObjOperandId objId, |
| 1259 |
uint32_t idOffset) { |
| 1260 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1261 |
AutoSaveLiveRegisters save(*this); |
| 1262 |
AutoOutputRegister output(*this); |
| 1263 |
|
| 1264 |
Register obj = allocator.useRegister(masm, objId); |
| 1265 |
jsid id = idStubField(idOffset); |
| 1266 |
|
| 1267 |
// ProxyGetProperty(JSContext* cx, HandleObject proxy, HandleId id, |
| 1268 |
// MutableHandleValue vp) |
| 1269 |
AutoScratchRegisterMaybeOutput argJSContext(allocator, masm, output); |
| 1270 |
AutoScratchRegisterMaybeOutputType argProxy(allocator, masm, output); |
| 1271 |
AutoScratchRegister argId(allocator, masm); |
| 1272 |
AutoScratchRegister argVp(allocator, masm); |
| 1273 |
AutoScratchRegister scratch(allocator, masm); |
| 1274 |
|
| 1275 |
allocator.discardStack(masm); |
| 1276 |
|
| 1277 |
// Push stubCode for marking. |
| 1278 |
pushStubCodePointer(); |
| 1279 |
|
| 1280 |
// Push args on stack first so we can take pointers to make handles. |
| 1281 |
masm.Push(UndefinedValue()); |
| 1282 |
masm.moveStackPtrTo(argVp.get()); |
| 1283 |
|
| 1284 |
masm.Push(id, scratch); |
| 1285 |
masm.moveStackPtrTo(argId.get()); |
| 1286 |
|
| 1287 |
// Push the proxy. Also used as receiver. |
| 1288 |
masm.Push(obj); |
| 1289 |
masm.moveStackPtrTo(argProxy.get()); |
| 1290 |
|
| 1291 |
masm.loadJSContext(argJSContext); |
| 1292 |
|
| 1293 |
if (!masm.icBuildOOLFakeExitFrame(GetReturnAddressToIonCode(cx_), save)) { |
| 1294 |
return false; |
| 1295 |
} |
| 1296 |
masm.enterFakeExitFrame(argJSContext, scratch, ExitFrameType::IonOOLProxy); |
| 1297 |
|
| 1298 |
// Make the call. |
| 1299 |
using Fn = bool (*)(JSContext* cx, HandleObject proxy, HandleId id, |
| 1300 |
MutableHandleValue vp); |
| 1301 |
masm.setupUnalignedABICall(scratch); |
| 1302 |
masm.passABIArg(argJSContext); |
| 1303 |
masm.passABIArg(argProxy); |
| 1304 |
masm.passABIArg(argId); |
| 1305 |
masm.passABIArg(argVp); |
| 1306 |
masm.callWithABI<Fn, ProxyGetProperty>( |
| 1307 |
ABIType::General, CheckUnsafeCallWithABI::DontCheckHasExitFrame); |
| 1308 |
|
| 1309 |
// Test for failure. |
| 1310 |
masm.branchIfFalseBool(ReturnReg, masm.exceptionLabel()); |
| 1311 |
|
| 1312 |
// Load the outparam vp[0] into output register(s). |
| 1313 |
Address outparam(masm.getStackPointer(), |
| 1314 |
IonOOLProxyExitFrameLayout::offsetOfResult()); |
| 1315 |
masm.loadValue(outparam, output.valueReg()); |
| 1316 |
|
| 1317 |
// Spectre mitigation in case of speculative execution within C++ code. |
| 1318 |
if (JitOptions.spectreJitToCxxCalls) { |
| 1319 |
masm.speculationBarrier(); |
| 1320 |
} |
| 1321 |
|
| 1322 |
// masm.leaveExitFrame & pop locals |
| 1323 |
masm.adjustStack(IonOOLProxyExitFrameLayout::Size()); |
| 1324 |
return true; |
| 1325 |
} |
| 1326 |
|
| 1327 |
bool IonCacheIRCompiler::emitFrameIsConstructingResult() { |
| 1328 |
MOZ_CRASH("Baseline-specific op"); |
| 1329 |
} |
| 1330 |
|
| 1331 |
bool IonCacheIRCompiler::emitLoadConstantStringResult(uint32_t strOffset) { |
| 1332 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1333 |
MOZ_CRASH("not used in ion"); |
| 1334 |
} |
| 1335 |
|
| 1336 |
bool IonCacheIRCompiler::emitCompareStringResult(JSOp op, StringOperandId lhsId, |
| 1337 |
StringOperandId rhsId) { |
| 1338 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1339 |
AutoSaveLiveRegisters save(*this); |
| 1340 |
AutoOutputRegister output(*this); |
| 1341 |
|
| 1342 |
Register left = allocator.useRegister(masm, lhsId); |
| 1343 |
Register right = allocator.useRegister(masm, rhsId); |
| 1344 |
|
| 1345 |
allocator.discardStack(masm); |
| 1346 |
|
| 1347 |
Label slow, done; |
| 1348 |
MOZ_ASSERT(!output.hasValue()); |
| 1349 |
masm.compareStrings(op, left, right, output.typedReg().gpr(), &slow); |
| 1350 |
|
| 1351 |
masm.jump(&done); |
| 1352 |
masm.bind(&slow); |
| 1353 |
|
| 1354 |
enterStubFrame(masm, save); |
| 1355 |
|
| 1356 |
// Push the operands in reverse order for JSOp::Le and JSOp::Gt: |
| 1357 |
// - |left <= right| is implemented as |right >= left|. |
| 1358 |
// - |left > right| is implemented as |right < left|. |
| 1359 |
if (op == JSOp::Le || op == JSOp::Gt) { |
| 1360 |
masm.Push(left); |
| 1361 |
masm.Push(right); |
| 1362 |
} else { |
| 1363 |
masm.Push(right); |
| 1364 |
masm.Push(left); |
| 1365 |
} |
| 1366 |
|
| 1367 |
using Fn = bool (*)(JSContext*, HandleString, HandleString, bool*); |
| 1368 |
if (op == JSOp::Eq || op == JSOp::StrictEq) { |
| 1369 |
callVM<Fn, jit::StringsEqual<EqualityKind::Equal>>(masm); |
| 1370 |
} else if (op == JSOp::Ne || op == JSOp::StrictNe) { |
| 1371 |
callVM<Fn, jit::StringsEqual<EqualityKind::NotEqual>>(masm); |
| 1372 |
} else if (op == JSOp::Lt || op == JSOp::Gt) { |
| 1373 |
callVM<Fn, jit::StringsCompare<ComparisonKind::LessThan>>(masm); |
| 1374 |
} else { |
| 1375 |
MOZ_ASSERT(op == JSOp::Le || op == JSOp::Ge); |
| 1376 |
callVM<Fn, jit::StringsCompare<ComparisonKind::GreaterThanOrEqual>>(masm); |
| 1377 |
} |
| 1378 |
|
| 1379 |
masm.storeCallBoolResult(output.typedReg().gpr()); |
| 1380 |
masm.bind(&done); |
| 1381 |
return true; |
| 1382 |
} |
| 1383 |
|
| 1384 |
bool IonCacheIRCompiler::emitStoreFixedSlot(ObjOperandId objId, |
| 1385 |
uint32_t offsetOffset, |
| 1386 |
ValOperandId rhsId) { |
| 1387 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1388 |
Register obj = allocator.useRegister(masm, objId); |
| 1389 |
int32_t offset = int32StubField(offsetOffset); |
| 1390 |
ConstantOrRegister val = allocator.useConstantOrRegister(masm, rhsId); |
| 1391 |
AutoScratchRegister scratch(allocator, masm); |
| 1392 |
|
| 1393 |
Address slot(obj, offset); |
| 1394 |
EmitPreBarrier(masm, slot, MIRType::Value); |
| 1395 |
masm.storeConstantOrRegister(val, slot); |
| 1396 |
emitPostBarrierSlot(obj, val, scratch); |
| 1397 |
return true; |
| 1398 |
} |
| 1399 |
|
| 1400 |
bool IonCacheIRCompiler::emitStoreDynamicSlot(ObjOperandId objId, |
| 1401 |
uint32_t offsetOffset, |
| 1402 |
ValOperandId rhsId) { |
| 1403 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1404 |
Register obj = allocator.useRegister(masm, objId); |
| 1405 |
int32_t offset = int32StubField(offsetOffset); |
| 1406 |
ConstantOrRegister val = allocator.useConstantOrRegister(masm, rhsId); |
| 1407 |
AutoScratchRegister scratch(allocator, masm); |
| 1408 |
|
| 1409 |
masm.loadPtr(Address(obj, NativeObject::offsetOfSlots()), scratch); |
| 1410 |
Address slot(scratch, offset); |
| 1411 |
EmitPreBarrier(masm, slot, MIRType::Value); |
| 1412 |
masm.storeConstantOrRegister(val, slot); |
| 1413 |
emitPostBarrierSlot(obj, val, scratch); |
| 1414 |
return true; |
| 1415 |
} |
| 1416 |
|
| 1417 |
bool IonCacheIRCompiler::emitAddAndStoreSlotShared( |
| 1418 |
CacheOp op, ObjOperandId objId, uint32_t offsetOffset, ValOperandId rhsId, |
| 1419 |
uint32_t newShapeOffset, Maybe<uint32_t> numNewSlotsOffset) { |
| 1420 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1421 |
Register obj = allocator.useRegister(masm, objId); |
| 1422 |
int32_t offset = int32StubField(offsetOffset); |
| 1423 |
ConstantOrRegister val = allocator.useConstantOrRegister(masm, rhsId); |
| 1424 |
|
| 1425 |
AutoScratchRegister scratch1(allocator, masm); |
| 1426 |
|
| 1427 |
Maybe<AutoScratchRegister> scratch2; |
| 1428 |
if (op == CacheOp::AllocateAndStoreDynamicSlot) { |
| 1429 |
scratch2.emplace(allocator, masm); |
| 1430 |
} |
| 1431 |
|
| 1432 |
Shape* newShape = shapeStubField(newShapeOffset); |
| 1433 |
|
| 1434 |
if (op == CacheOp::AllocateAndStoreDynamicSlot) { |
| 1435 |
// We have to (re)allocate dynamic slots. Do this first, as it's the |
| 1436 |
// only fallible operation here. Note that growSlotsPure is |
| 1437 |
// fallible but does not GC. |
| 1438 |
|
| 1439 |
FailurePath* failure; |
| 1440 |
if (!addFailurePath(&failure)) { |
| 1441 |
return false; |
| 1442 |
} |
| 1443 |
|
| 1444 |
int32_t numNewSlots = int32StubField(*numNewSlotsOffset); |
| 1445 |
MOZ_ASSERT(numNewSlots > 0); |
| 1446 |
|
| 1447 |
LiveRegisterSet save = liveVolatileRegs(); |
| 1448 |
masm.PushRegsInMask(save); |
| 1449 |
|
| 1450 |
using Fn = bool (*)(JSContext* cx, NativeObject* obj, uint32_t newCount); |
| 1451 |
masm.setupUnalignedABICall(scratch1); |
| 1452 |
masm.loadJSContext(scratch1); |
| 1453 |
masm.passABIArg(scratch1); |
| 1454 |
masm.passABIArg(obj); |
| 1455 |
masm.move32(Imm32(numNewSlots), scratch2.ref()); |
| 1456 |
masm.passABIArg(scratch2.ref()); |
| 1457 |
masm.callWithABI<Fn, NativeObject::growSlotsPure>(); |
| 1458 |
masm.storeCallPointerResult(scratch1); |
| 1459 |
|
| 1460 |
LiveRegisterSet ignore; |
| 1461 |
ignore.add(scratch1); |
| 1462 |
masm.PopRegsInMaskIgnore(save, ignore); |
| 1463 |
|
| 1464 |
masm.branchIfFalseBool(scratch1, failure->label()); |
| 1465 |
} |
| 1466 |
|
| 1467 |
// Update the object's shape. |
| 1468 |
masm.storeObjShape(newShape, obj, |
| 1469 |
[](MacroAssembler& masm, const Address& addr) { |
| 1470 |
EmitPreBarrier(masm, addr, MIRType::Shape); |
| 1471 |
}); |
| 1472 |
|
| 1473 |
// Perform the store. No pre-barrier required since this is a new |
| 1474 |
// initialization. |
| 1475 |
if (op == CacheOp::AddAndStoreFixedSlot) { |
| 1476 |
Address slot(obj, offset); |
| 1477 |
masm.storeConstantOrRegister(val, slot); |
| 1478 |
} else { |
| 1479 |
MOZ_ASSERT(op == CacheOp::AddAndStoreDynamicSlot || |
| 1480 |
op == CacheOp::AllocateAndStoreDynamicSlot); |
| 1481 |
masm.loadPtr(Address(obj, NativeObject::offsetOfSlots()), scratch1); |
| 1482 |
Address slot(scratch1, offset); |
| 1483 |
masm.storeConstantOrRegister(val, slot); |
| 1484 |
} |
| 1485 |
|
| 1486 |
emitPostBarrierSlot(obj, val, scratch1); |
| 1487 |
|
| 1488 |
return true; |
| 1489 |
} |
| 1490 |
|
| 1491 |
bool IonCacheIRCompiler::emitAddAndStoreFixedSlot(ObjOperandId objId, |
| 1492 |
uint32_t offsetOffset, |
| 1493 |
ValOperandId rhsId, |
| 1494 |
uint32_t newShapeOffset) { |
| 1495 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1496 |
Maybe<uint32_t> numNewSlotsOffset = mozilla::Nothing(); |
| 1497 |
return emitAddAndStoreSlotShared(CacheOp::AddAndStoreFixedSlot, objId, |
| 1498 |
offsetOffset, rhsId, newShapeOffset, |
| 1499 |
numNewSlotsOffset); |
| 1500 |
} |
| 1501 |
|
| 1502 |
bool IonCacheIRCompiler::emitAddAndStoreDynamicSlot(ObjOperandId objId, |
| 1503 |
uint32_t offsetOffset, |
| 1504 |
ValOperandId rhsId, |
| 1505 |
uint32_t newShapeOffset) { |
| 1506 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1507 |
Maybe<uint32_t> numNewSlotsOffset = mozilla::Nothing(); |
| 1508 |
return emitAddAndStoreSlotShared(CacheOp::AddAndStoreDynamicSlot, objId, |
| 1509 |
offsetOffset, rhsId, newShapeOffset, |
| 1510 |
numNewSlotsOffset); |
| 1511 |
} |
| 1512 |
|
| 1513 |
bool IonCacheIRCompiler::emitAllocateAndStoreDynamicSlot( |
| 1514 |
ObjOperandId objId, uint32_t offsetOffset, ValOperandId rhsId, |
| 1515 |
uint32_t newShapeOffset, uint32_t numNewSlotsOffset) { |
| 1516 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1517 |
return emitAddAndStoreSlotShared(CacheOp::AllocateAndStoreDynamicSlot, objId, |
| 1518 |
offsetOffset, rhsId, newShapeOffset, |
| 1519 |
mozilla::Some(numNewSlotsOffset)); |
| 1520 |
} |
| 1521 |
|
| 1522 |
bool IonCacheIRCompiler::emitLoadStringCharResult(StringOperandId strId, |
| 1523 |
Int32OperandId indexId, |
| 1524 |
bool handleOOB) { |
| 1525 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1526 |
AutoOutputRegister output(*this); |
| 1527 |
Register str = allocator.useRegister(masm, strId); |
| 1528 |
Register index = allocator.useRegister(masm, indexId); |
| 1529 |
AutoScratchRegisterMaybeOutput scratch1(allocator, masm, output); |
| 1530 |
AutoScratchRegisterMaybeOutputType scratch2(allocator, masm, output); |
| 1531 |
AutoScratchRegister scratch3(allocator, masm); |
| 1532 |
|
| 1533 |
FailurePath* failure; |
| 1534 |
if (!addFailurePath(&failure)) { |
| 1535 |
return false; |
| 1536 |
} |
| 1537 |
|
| 1538 |
// Bounds check, load string char. |
| 1539 |
Label done; |
| 1540 |
Label loadFailed; |
| 1541 |
if (!handleOOB) { |
| 1542 |
masm.spectreBoundsCheck32(index, Address(str, JSString::offsetOfLength()), |
| 1543 |
scratch1, failure->label()); |
| 1544 |
masm.loadStringChar(str, index, scratch1, scratch2, scratch3, |
| 1545 |
failure->label()); |
| 1546 |
} else { |
| 1547 |
// Return the empty string for out-of-bounds access. |
| 1548 |
masm.movePtr(ImmGCPtr(cx_->runtime()->emptyString), scratch2); |
| 1549 |
|
| 1550 |
// This CacheIR op is always preceded by |LinearizeForCharAccess|, so we're |
| 1551 |
// guaranteed to see no nested ropes. |
| 1552 |
masm.spectreBoundsCheck32(index, Address(str, JSString::offsetOfLength()), |
| 1553 |
scratch1, &done); |
| 1554 |
masm.loadStringChar(str, index, scratch1, scratch2, scratch3, &loadFailed); |
| 1555 |
} |
| 1556 |
|
| 1557 |
// Load StaticString for this char. For larger code units perform a VM call. |
| 1558 |
Label vmCall; |
| 1559 |
masm.lookupStaticString(scratch1, scratch2, cx_->staticStrings(), &vmCall); |
| 1560 |
masm.jump(&done); |
| 1561 |
|
| 1562 |
if (handleOOB) { |
| 1563 |
masm.bind(&loadFailed); |
| 1564 |
masm.assumeUnreachable("loadStringChar can't fail for linear strings"); |
| 1565 |
} |
| 1566 |
|
| 1567 |
{ |
| 1568 |
masm.bind(&vmCall); |
| 1569 |
|
| 1570 |
// FailurePath and AutoSaveLiveRegisters don't get along very well. Both are |
| 1571 |
// modifying the stack and expect that no other stack manipulations are |
| 1572 |
// made. Therefore we need to use an ABI call instead of a VM call here. |
| 1573 |
|
| 1574 |
LiveRegisterSet volatileRegs = liveVolatileRegs(); |
| 1575 |
volatileRegs.takeUnchecked(scratch1); |
| 1576 |
volatileRegs.takeUnchecked(scratch2); |
| 1577 |
volatileRegs.takeUnchecked(scratch3); |
| 1578 |
volatileRegs.takeUnchecked(output); |
| 1579 |
masm.PushRegsInMask(volatileRegs); |
| 1580 |
|
| 1581 |
using Fn = JSLinearString* (*)(JSContext* cx, int32_t code); |
| 1582 |
masm.setupUnalignedABICall(scratch2); |
| 1583 |
masm.loadJSContext(scratch2); |
| 1584 |
masm.passABIArg(scratch2); |
| 1585 |
masm.passABIArg(scratch1); |
| 1586 |
masm.callWithABI<Fn, jit::StringFromCharCodeNoGC>(); |
| 1587 |
masm.storeCallPointerResult(scratch2); |
| 1588 |
|
| 1589 |
masm.PopRegsInMask(volatileRegs); |
| 1590 |
|
| 1591 |
masm.branchPtr(Assembler::Equal, scratch2, ImmWord(0), failure->label()); |
| 1592 |
} |
| 1593 |
|
| 1594 |
masm.bind(&done); |
| 1595 |
masm.tagValue(JSVAL_TYPE_STRING, scratch2, output.valueReg()); |
| 1596 |
return true; |
| 1597 |
} |
| 1598 |
|
| 1599 |
bool IonCacheIRCompiler::emitCallNativeSetter(ObjOperandId receiverId, |
| 1600 |
uint32_t setterOffset, |
| 1601 |
ValOperandId rhsId, |
| 1602 |
bool sameRealm, |
| 1603 |
uint32_t nargsAndFlagsOffset) { |
| 1604 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1605 |
AutoSaveLiveRegisters save(*this); |
| 1606 |
|
| 1607 |
Register receiver = allocator.useRegister(masm, receiverId); |
| 1608 |
JSFunction* target = &objectStubField(setterOffset)->as<JSFunction>(); |
| 1609 |
MOZ_ASSERT(target->isNativeFun()); |
| 1610 |
ConstantOrRegister val = allocator.useConstantOrRegister(masm, rhsId); |
| 1611 |
|
| 1612 |
AutoScratchRegister argJSContext(allocator, masm); |
| 1613 |
AutoScratchRegister argVp(allocator, masm); |
| 1614 |
AutoScratchRegister argUintN(allocator, masm); |
| 1615 |
#ifndef JS_CODEGEN_X86 |
| 1616 |
AutoScratchRegister scratch(allocator, masm); |
| 1617 |
#else |
| 1618 |
// Not enough registers on x86. |
| 1619 |
Register scratch = argUintN; |
| 1620 |
#endif |
| 1621 |
|
| 1622 |
allocator.discardStack(masm); |
| 1623 |
|
| 1624 |
// Set up the call: |
| 1625 |
// bool (*)(JSContext*, unsigned, Value* vp) |
| 1626 |
// vp[0] is callee/outparam |
| 1627 |
// vp[1] is |this| |
| 1628 |
// vp[2] is the value |
| 1629 |
|
| 1630 |
// Build vp and move the base into argVpReg. |
| 1631 |
masm.Push(val); |
| 1632 |
masm.Push(TypedOrValueRegister(MIRType::Object, AnyRegister(receiver))); |
| 1633 |
masm.Push(ObjectValue(*target)); |
| 1634 |
masm.moveStackPtrTo(argVp.get()); |
| 1635 |
|
| 1636 |
// Preload other regs. |
| 1637 |
masm.loadJSContext(argJSContext); |
| 1638 |
masm.move32(Imm32(1), argUintN); |
| 1639 |
|
| 1640 |
// Push marking data for later use. |
| 1641 |
masm.Push(argUintN); |
| 1642 |
pushStubCodePointer(); |
| 1643 |
|
| 1644 |
if (!masm.icBuildOOLFakeExitFrame(GetReturnAddressToIonCode(cx_), save)) { |
| 1645 |
return false; |
| 1646 |
} |
| 1647 |
masm.enterFakeExitFrame(argJSContext, scratch, ExitFrameType::IonOOLNative); |
| 1648 |
|
| 1649 |
if (!sameRealm) { |
| 1650 |
masm.switchToRealm(target->realm(), scratch); |
| 1651 |
} |
| 1652 |
|
| 1653 |
// Make the call. |
| 1654 |
masm.setupUnalignedABICall(scratch); |
| 1655 |
#ifdef JS_CODEGEN_X86 |
| 1656 |
// Reload argUintN because it was clobbered. |
| 1657 |
masm.move32(Imm32(1), argUintN); |
| 1658 |
#endif |
| 1659 |
masm.passABIArg(argJSContext); |
| 1660 |
masm.passABIArg(argUintN); |
| 1661 |
masm.passABIArg(argVp); |
| 1662 |
masm.callWithABI(DynamicFunction<JSNative>(target->native()), |
| 1663 |
ABIType::General, |
| 1664 |
CheckUnsafeCallWithABI::DontCheckHasExitFrame); |
| 1665 |
|
| 1666 |
// Test for failure. |
| 1667 |
masm.branchIfFalseBool(ReturnReg, masm.exceptionLabel()); |
| 1668 |
|
| 1669 |
if (!sameRealm) { |
| 1670 |
masm.switchToRealm(cx_->realm(), ReturnReg); |
| 1671 |
} |
| 1672 |
|
| 1673 |
masm.adjustStack(IonOOLNativeExitFrameLayout::Size(1)); |
| 1674 |
return true; |
| 1675 |
} |
| 1676 |
|
| 1677 |
bool IonCacheIRCompiler::emitCallScriptedSetter(ObjOperandId receiverId, |
| 1678 |
uint32_t setterOffset, |
| 1679 |
ValOperandId rhsId, |
| 1680 |
bool sameRealm, |
| 1681 |
uint32_t nargsAndFlagsOffset) { |
| 1682 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1683 |
AutoSaveLiveRegisters save(*this); |
| 1684 |
|
| 1685 |
Register receiver = allocator.useRegister(masm, receiverId); |
| 1686 |
JSFunction* target = &objectStubField(setterOffset)->as<JSFunction>(); |
| 1687 |
ConstantOrRegister val = allocator.useConstantOrRegister(masm, rhsId); |
| 1688 |
|
| 1689 |
MOZ_ASSERT(sameRealm == (cx_->realm() == target->realm())); |
| 1690 |
|
| 1691 |
AutoScratchRegister scratch(allocator, masm); |
| 1692 |
|
| 1693 |
allocator.discardStack(masm); |
| 1694 |
|
| 1695 |
uint32_t framePushedBefore = masm.framePushed(); |
| 1696 |
|
| 1697 |
enterStubFrame(masm, save); |
| 1698 |
|
| 1699 |
// The JitFrameLayout pushed below will be aligned to JitStackAlignment, |
| 1700 |
// so we just have to make sure the stack is aligned after we push the |
| 1701 |
// |this| + argument Values. |
| 1702 |
size_t numArgs = std::max<size_t>(1, target->nargs()); |
| 1703 |
uint32_t argSize = (numArgs + 1) * sizeof(Value); |
| 1704 |
uint32_t padding = |
| 1705 |
ComputeByteAlignment(masm.framePushed() + argSize, JitStackAlignment); |
| 1706 |
MOZ_ASSERT(padding % sizeof(uintptr_t) == 0); |
| 1707 |
MOZ_ASSERT(padding < JitStackAlignment); |
| 1708 |
masm.reserveStack(padding); |
| 1709 |
|
| 1710 |
for (size_t i = 1; i < target->nargs(); i++) { |
| 1711 |
masm.Push(UndefinedValue()); |
| 1712 |
} |
| 1713 |
masm.Push(val); |
| 1714 |
masm.Push(TypedOrValueRegister(MIRType::Object, AnyRegister(receiver))); |
| 1715 |
|
| 1716 |
if (!sameRealm) { |
| 1717 |
masm.switchToRealm(target->realm(), scratch); |
| 1718 |
} |
| 1719 |
|
| 1720 |
masm.movePtr(ImmGCPtr(target), scratch); |
| 1721 |
|
| 1722 |
masm.Push(scratch); |
| 1723 |
masm.PushFrameDescriptorForJitCall(FrameType::IonICCall, /* argc = */ 1); |
| 1724 |
|
| 1725 |
// Check stack alignment. Add 2 * sizeof(uintptr_t) for the return address and |
| 1726 |
// frame pointer pushed by the call/callee. |
| 1727 |
MOZ_ASSERT( |
| 1728 |
((masm.framePushed() + 2 * sizeof(uintptr_t)) % JitStackAlignment) == 0); |
| 1729 |
|
| 1730 |
MOZ_ASSERT(target->hasJitEntry()); |
| 1731 |
masm.loadJitCodeRaw(scratch, scratch); |
| 1732 |
masm.callJit(scratch); |
| 1733 |
|
| 1734 |
if (!sameRealm) { |
| 1735 |
masm.switchToRealm(cx_->realm(), ReturnReg); |
| 1736 |
} |
| 1737 |
|
| 1738 |
// Restore the frame pointer and stack pointer. |
| 1739 |
masm.loadPtr(Address(FramePointer, 0), FramePointer); |
| 1740 |
masm.freeStack(masm.framePushed() - framePushedBefore); |
| 1741 |
return true; |
| 1742 |
} |
| 1743 |
|
| 1744 |
bool IonCacheIRCompiler::emitCallInlinedSetter( |
| 1745 |
ObjOperandId receiverId, uint32_t setterOffset, ValOperandId rhsId, |
| 1746 |
uint32_t icScriptOffset, bool sameRealm, uint32_t nargsAndFlagsOffset) { |
| 1747 |
MOZ_CRASH("Trial inlining not supported in Ion"); |
| 1748 |
} |
| 1749 |
|
| 1750 |
bool IonCacheIRCompiler::emitCallSetArrayLength(ObjOperandId objId, bool strict, |
| 1751 |
ValOperandId rhsId) { |
| 1752 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1753 |
AutoSaveLiveRegisters save(*this); |
| 1754 |
|
| 1755 |
Register obj = allocator.useRegister(masm, objId); |
| 1756 |
ConstantOrRegister val = allocator.useConstantOrRegister(masm, rhsId); |
| 1757 |
|
| 1758 |
allocator.discardStack(masm); |
| 1759 |
enterStubFrame(masm, save); |
| 1760 |
|
| 1761 |
masm.Push(Imm32(strict)); |
| 1762 |
masm.Push(val); |
| 1763 |
masm.Push(obj); |
| 1764 |
|
| 1765 |
using Fn = bool (*)(JSContext*, HandleObject, HandleValue, bool); |
| 1766 |
callVM<Fn, jit::SetArrayLength>(masm); |
| 1767 |
return true; |
| 1768 |
} |
| 1769 |
|
| 1770 |
bool IonCacheIRCompiler::emitProxySet(ObjOperandId objId, uint32_t idOffset, |
| 1771 |
ValOperandId rhsId, bool strict) { |
| 1772 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1773 |
AutoSaveLiveRegisters save(*this); |
| 1774 |
|
| 1775 |
Register obj = allocator.useRegister(masm, objId); |
| 1776 |
ConstantOrRegister val = allocator.useConstantOrRegister(masm, rhsId); |
| 1777 |
jsid id = idStubField(idOffset); |
| 1778 |
|
| 1779 |
AutoScratchRegister scratch(allocator, masm); |
| 1780 |
|
| 1781 |
allocator.discardStack(masm); |
| 1782 |
enterStubFrame(masm, save); |
| 1783 |
|
| 1784 |
masm.Push(Imm32(strict)); |
| 1785 |
masm.Push(val); |
| 1786 |
masm.Push(id, scratch); |
| 1787 |
masm.Push(obj); |
| 1788 |
|
| 1789 |
using Fn = bool (*)(JSContext*, HandleObject, HandleId, HandleValue, bool); |
| 1790 |
callVM<Fn, ProxySetProperty>(masm); |
| 1791 |
return true; |
| 1792 |
} |
| 1793 |
|
| 1794 |
bool IonCacheIRCompiler::emitProxySetByValue(ObjOperandId objId, |
| 1795 |
ValOperandId idId, |
| 1796 |
ValOperandId rhsId, bool strict) { |
| 1797 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1798 |
AutoSaveLiveRegisters save(*this); |
| 1799 |
|
| 1800 |
Register obj = allocator.useRegister(masm, objId); |
| 1801 |
ConstantOrRegister idVal = allocator.useConstantOrRegister(masm, idId); |
| 1802 |
ConstantOrRegister val = allocator.useConstantOrRegister(masm, rhsId); |
| 1803 |
|
| 1804 |
allocator.discardStack(masm); |
| 1805 |
enterStubFrame(masm, save); |
| 1806 |
|
| 1807 |
masm.Push(Imm32(strict)); |
| 1808 |
masm.Push(val); |
| 1809 |
masm.Push(idVal); |
| 1810 |
masm.Push(obj); |
| 1811 |
|
| 1812 |
using Fn = bool (*)(JSContext*, HandleObject, HandleValue, HandleValue, bool); |
| 1813 |
callVM<Fn, ProxySetPropertyByValue>(masm); |
| 1814 |
return true; |
| 1815 |
} |
| 1816 |
|
| 1817 |
bool IonCacheIRCompiler::emitCallAddOrUpdateSparseElementHelper( |
| 1818 |
ObjOperandId objId, Int32OperandId idId, ValOperandId rhsId, bool strict) { |
| 1819 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1820 |
AutoSaveLiveRegisters save(*this); |
| 1821 |
|
| 1822 |
Register obj = allocator.useRegister(masm, objId); |
| 1823 |
Register id = allocator.useRegister(masm, idId); |
| 1824 |
ValueOperand val = allocator.useValueRegister(masm, rhsId); |
| 1825 |
|
| 1826 |
allocator.discardStack(masm); |
| 1827 |
enterStubFrame(masm, save); |
| 1828 |
|
| 1829 |
masm.Push(Imm32(strict)); |
| 1830 |
masm.Push(val); |
| 1831 |
masm.Push(id); |
| 1832 |
masm.Push(obj); |
| 1833 |
|
| 1834 |
using Fn = bool (*)(JSContext* cx, Handle<NativeObject*> obj, int32_t int_id, |
| 1835 |
HandleValue v, bool strict); |
| 1836 |
callVM<Fn, AddOrUpdateSparseElementHelper>(masm); |
| 1837 |
return true; |
| 1838 |
} |
| 1839 |
|
| 1840 |
bool IonCacheIRCompiler::emitMegamorphicSetElement(ObjOperandId objId, |
| 1841 |
ValOperandId idId, |
| 1842 |
ValOperandId rhsId, |
| 1843 |
bool strict) { |
| 1844 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1845 |
AutoSaveLiveRegisters save(*this); |
| 1846 |
|
| 1847 |
Register obj = allocator.useRegister(masm, objId); |
| 1848 |
ConstantOrRegister idVal = allocator.useConstantOrRegister(masm, idId); |
| 1849 |
ConstantOrRegister val = allocator.useConstantOrRegister(masm, rhsId); |
| 1850 |
|
| 1851 |
allocator.discardStack(masm); |
| 1852 |
enterStubFrame(masm, save); |
| 1853 |
|
| 1854 |
masm.Push(Imm32(strict)); |
| 1855 |
masm.Push(val); |
| 1856 |
masm.Push(idVal); |
| 1857 |
masm.Push(obj); |
| 1858 |
|
| 1859 |
using Fn = bool (*)(JSContext*, HandleObject, HandleValue, HandleValue, bool); |
| 1860 |
callVM<Fn, SetElementMegamorphic<false>>(masm); |
| 1861 |
return true; |
| 1862 |
} |
| 1863 |
|
| 1864 |
bool IonCacheIRCompiler::emitReturnFromIC() { |
| 1865 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1866 |
if (!savedLiveRegs_) { |
| 1867 |
allocator.restoreInputState(masm); |
| 1868 |
} |
| 1869 |
|
| 1870 |
uint8_t* rejoinAddr = ic_->rejoinAddr(ionScript_); |
| 1871 |
masm.jump(ImmPtr(rejoinAddr)); |
| 1872 |
return true; |
| 1873 |
} |
| 1874 |
|
| 1875 |
bool IonCacheIRCompiler::emitGuardDOMExpandoMissingOrGuardShape( |
| 1876 |
ValOperandId expandoId, uint32_t shapeOffset) { |
| 1877 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1878 |
ValueOperand val = allocator.useValueRegister(masm, expandoId); |
| 1879 |
Shape* shape = shapeStubField(shapeOffset); |
| 1880 |
|
| 1881 |
AutoScratchRegister objScratch(allocator, masm); |
| 1882 |
|
| 1883 |
FailurePath* failure; |
| 1884 |
if (!addFailurePath(&failure)) { |
| 1885 |
return false; |
| 1886 |
} |
| 1887 |
|
| 1888 |
Label done; |
| 1889 |
masm.branchTestUndefined(Assembler::Equal, val, &done); |
| 1890 |
|
| 1891 |
masm.debugAssertIsObject(val); |
| 1892 |
masm.unboxObject(val, objScratch); |
| 1893 |
// The expando object is not used in this case, so we don't need Spectre |
| 1894 |
// mitigations. |
| 1895 |
masm.branchTestObjShapeNoSpectreMitigations(Assembler::NotEqual, objScratch, |
| 1896 |
shape, failure->label()); |
| 1897 |
|
| 1898 |
masm.bind(&done); |
| 1899 |
return true; |
| 1900 |
} |
| 1901 |
|
| 1902 |
bool IonCacheIRCompiler::emitLoadDOMExpandoValueGuardGeneration( |
| 1903 |
ObjOperandId objId, uint32_t expandoAndGenerationOffset, |
| 1904 |
uint32_t generationOffset, ValOperandId resultId) { |
| 1905 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 1906 |
Register obj = allocator.useRegister(masm, objId); |
| 1907 |
ExpandoAndGeneration* expandoAndGeneration = |
| 1908 |
rawPointerStubField<ExpandoAndGeneration*>(expandoAndGenerationOffset); |
| 1909 |
uint64_t generation = rawInt64StubField<uint64_t>(generationOffset); |
| 1910 |
|
| 1911 |
ValueOperand output = allocator.defineValueRegister(masm, resultId); |
| 1912 |
|
| 1913 |
FailurePath* failure; |
| 1914 |
if (!addFailurePath(&failure)) { |
| 1915 |
return false; |
| 1916 |
} |
| 1917 |
|
| 1918 |
masm.loadDOMExpandoValueGuardGeneration(obj, output, expandoAndGeneration, |
| 1919 |
generation, failure->label()); |
| 1920 |
return true; |
| 1921 |
} |
| 1922 |
|
| 1923 |
void IonIC::attachCacheIRStub(JSContext* cx, const CacheIRWriter& writer, |
| 1924 |
CacheKind kind, IonScript* ionScript, |
| 1925 |
bool* attached) { |
| 1926 |
// We shouldn't GC or report OOM (or any other exception) here. |
| 1927 |
AutoAssertNoPendingException aanpe(cx); |
| 1928 |
JS::AutoCheckCannotGC nogc; |
| 1929 |
|
| 1930 |
MOZ_ASSERT(!*attached); |
| 1931 |
|
| 1932 |
// Do nothing if the IR generator failed or triggered a GC that invalidated |
| 1933 |
// the script. |
| 1934 |
if (writer.tooLarge()) { |
| 1935 |
cx->runtime()->setUseCounter(cx->global(), JSUseCounter::IC_STUB_TOO_LARGE); |
| 1936 |
return; |
| 1937 |
} |
| 1938 |
if (writer.oom()) { |
| 1939 |
cx->runtime()->setUseCounter(cx->global(), JSUseCounter::IC_STUB_OOM); |
| 1940 |
return; |
| 1941 |
} |
| 1942 |
MOZ_ASSERT(!writer.failed()); |
| 1943 |
|
| 1944 |
if (ionScript->invalidated()) { |
| 1945 |
return; |
| 1946 |
} |
| 1947 |
|
| 1948 |
JitZone* jitZone = cx->zone()->jitZone(); |
| 1949 |
|
| 1950 |
constexpr uint32_t stubDataOffset = sizeof(IonICStub); |
| 1951 |
static_assert(stubDataOffset % sizeof(uint64_t) == 0, |
| 1952 |
"Stub fields must be aligned"); |
| 1953 |
|
| 1954 |
// Try to reuse a previously-allocated CacheIRStubInfo. |
| 1955 |
CacheIRStubKey::Lookup lookup(kind, ICStubEngine::IonIC, writer.codeStart(), |
| 1956 |
writer.codeLength()); |
| 1957 |
CacheIRStubInfo* stubInfo = jitZone->getIonCacheIRStubInfo(lookup); |
| 1958 |
if (!stubInfo) { |
| 1959 |
// Allocate the shared CacheIRStubInfo. Note that the |
| 1960 |
// putIonCacheIRStubInfo call below will transfer ownership to |
| 1961 |
// the stub info HashSet, so we don't have to worry about freeing |
| 1962 |
// it below. |
| 1963 |
|
| 1964 |
// For Ion ICs, we don't track/use the makesGCCalls flag, so just pass true. |
| 1965 |
bool makesGCCalls = true; |
| 1966 |
stubInfo = CacheIRStubInfo::New(kind, ICStubEngine::IonIC, makesGCCalls, |
| 1967 |
stubDataOffset, writer); |
| 1968 |
if (!stubInfo) { |
| 1969 |
return; |
| 1970 |
} |
| 1971 |
|
| 1972 |
CacheIRStubKey key(stubInfo); |
| 1973 |
if (!jitZone->putIonCacheIRStubInfo(lookup, key)) { |
| 1974 |
return; |
| 1975 |
} |
| 1976 |
} |
| 1977 |
|
| 1978 |
MOZ_ASSERT(stubInfo); |
| 1979 |
|
| 1980 |
// Ensure we don't attach duplicate stubs. This can happen if a stub failed |
| 1981 |
// for some reason and the IR generator doesn't check for exactly the same |
| 1982 |
// conditions. |
| 1983 |
for (IonICStub* stub = firstStub_; stub; stub = stub->next()) { |
| 1984 |
if (stub->stubInfo() != stubInfo) { |
| 1985 |
continue; |
| 1986 |
} |
| 1987 |
if (!writer.stubDataEquals(stub->stubDataStart())) { |
| 1988 |
continue; |
| 1989 |
} |
| 1990 |
return; |
| 1991 |
} |
| 1992 |
|
| 1993 |
size_t bytesNeeded = stubInfo->stubDataOffset() + stubInfo->stubDataSize(); |
| 1994 |
|
| 1995 |
// Allocate the IonICStub in the JitZone's stub space. Ion stubs and |
| 1996 |
// CacheIRStubInfo instances for Ion stubs can be purged on GC. That's okay |
| 1997 |
// because the stub code is rooted separately when we make a VM call, and |
| 1998 |
// stub code should never access the IonICStub after making a VM call. The |
| 1999 |
// IonICStub::poison method poisons the stub to catch bugs in this area. |
| 2000 |
ICStubSpace* stubSpace = cx->zone()->jitZone()->stubSpace(); |
| 2001 |
void* newStubMem = stubSpace->alloc(bytesNeeded); |
| 2002 |
if (!newStubMem) { |
| 2003 |
return; |
| 2004 |
} |
| 2005 |
|
| 2006 |
IonICStub* newStub = |
| 2007 |
new (newStubMem) IonICStub(fallbackAddr(ionScript), stubInfo); |
| 2008 |
writer.copyStubData(newStub->stubDataStart()); |
| 2009 |
|
| 2010 |
TempAllocator temp(&cx->tempLifoAlloc()); |
| 2011 |
JitContext jctx(cx); |
| 2012 |
IonCacheIRCompiler compiler(cx, temp, writer, this, ionScript, |
| 2013 |
stubDataOffset); |
| 2014 |
if (!compiler.init()) { |
| 2015 |
return; |
| 2016 |
} |
| 2017 |
|
| 2018 |
JitCode* code = compiler.compile(newStub); |
| 2019 |
if (!code) { |
| 2020 |
return; |
| 2021 |
} |
| 2022 |
|
| 2023 |
// Record the stub code if perf spewer is enabled. |
| 2024 |
CacheKind stubKind = newStub->stubInfo()->kind(); |
| 2025 |
compiler.perfSpewer().saveProfile(cx, script(), code, |
| 2026 |
CacheKindNames[uint8_t(stubKind)]); |
| 2027 |
|
| 2028 |
// Add an entry to the profiler's code table, so that the profiler can |
| 2029 |
// identify this as Ion code. |
| 2030 |
if (ionScript->hasProfilingInstrumentation()) { |
| 2031 |
uint8_t* addr = rejoinAddr(ionScript); |
| 2032 |
auto entry = MakeJitcodeGlobalEntry<IonICEntry>(cx, code, code->raw(), |
| 2033 |
code->rawEnd(), addr); |
| 2034 |
if (!entry) { |
| 2035 |
cx->recoverFromOutOfMemory(); |
| 2036 |
return; |
| 2037 |
} |
| 2038 |
|
| 2039 |
auto* globalTable = cx->runtime()->jitRuntime()->getJitcodeGlobalTable(); |
| 2040 |
if (!globalTable->addEntry(std::move(entry))) { |
| 2041 |
return; |
| 2042 |
} |
| 2043 |
} |
| 2044 |
|
| 2045 |
attachStub(newStub, code); |
| 2046 |
*attached = true; |
| 2047 |
} |
| 2048 |
|
| 2049 |
bool IonCacheIRCompiler::emitCallStringObjectConcatResult(ValOperandId lhsId, |
| 2050 |
ValOperandId rhsId) { |
| 2051 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 2052 |
AutoSaveLiveRegisters save(*this); |
| 2053 |
AutoOutputRegister output(*this); |
| 2054 |
|
| 2055 |
ValueOperand lhs = allocator.useValueRegister(masm, lhsId); |
| 2056 |
ValueOperand rhs = allocator.useValueRegister(masm, rhsId); |
| 2057 |
|
| 2058 |
allocator.discardStack(masm); |
| 2059 |
|
| 2060 |
enterStubFrame(masm, save); |
| 2061 |
masm.Push(rhs); |
| 2062 |
masm.Push(lhs); |
| 2063 |
|
| 2064 |
using Fn = bool (*)(JSContext*, HandleValue, HandleValue, MutableHandleValue); |
| 2065 |
callVM<Fn, DoConcatStringObject>(masm); |
| 2066 |
|
| 2067 |
masm.storeCallResultValue(output); |
| 2068 |
return true; |
| 2069 |
} |
| 2070 |
|
| 2071 |
bool IonCacheIRCompiler::emitCloseIterScriptedResult(ObjOperandId iterId, |
| 2072 |
ObjOperandId calleeId, |
| 2073 |
CompletionKind kind, |
| 2074 |
uint32_t calleeNargs) { |
| 2075 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 2076 |
AutoSaveLiveRegisters save(*this); |
| 2077 |
|
| 2078 |
Register iter = allocator.useRegister(masm, iterId); |
| 2079 |
Register callee = allocator.useRegister(masm, calleeId); |
| 2080 |
|
| 2081 |
allocator.discardStack(masm); |
| 2082 |
|
| 2083 |
uint32_t framePushedBefore = masm.framePushed(); |
| 2084 |
|
| 2085 |
// Construct IonICCallFrameLayout. |
| 2086 |
enterStubFrame(masm, save); |
| 2087 |
|
| 2088 |
uint32_t stubFramePushed = masm.framePushed(); |
| 2089 |
|
| 2090 |
// The JitFrameLayout pushed below will be aligned to JitStackAlignment, |
| 2091 |
// so we just have to make sure the stack is aligned after we push |this| |
| 2092 |
// and |calleeNargs| undefined arguments. |
| 2093 |
uint32_t argSize = (calleeNargs + 1) * sizeof(Value); |
| 2094 |
uint32_t padding = |
| 2095 |
ComputeByteAlignment(masm.framePushed() + argSize, JitStackAlignment); |
| 2096 |
MOZ_ASSERT(padding % sizeof(uintptr_t) == 0); |
| 2097 |
MOZ_ASSERT(padding < JitStackAlignment); |
| 2098 |
masm.reserveStack(padding); |
| 2099 |
|
| 2100 |
for (uint32_t i = 0; i < calleeNargs; i++) { |
| 2101 |
masm.Push(UndefinedValue()); |
| 2102 |
} |
| 2103 |
masm.Push(TypedOrValueRegister(MIRType::Object, AnyRegister(iter))); |
| 2104 |
|
| 2105 |
masm.Push(callee); |
| 2106 |
masm.PushFrameDescriptorForJitCall(FrameType::IonICCall, /* argc = */ 0); |
| 2107 |
|
| 2108 |
masm.loadJitCodeRaw(callee, callee); |
| 2109 |
masm.callJit(callee); |
| 2110 |
|
| 2111 |
if (kind != CompletionKind::Throw) { |
| 2112 |
// Verify that the return value is an object. |
| 2113 |
Label success; |
| 2114 |
masm.branchTestObject(Assembler::Equal, JSReturnOperand, &success); |
| 2115 |
|
| 2116 |
// We can reuse the same stub frame, but we first have to pop the arguments |
| 2117 |
// from the previous call. |
| 2118 |
uint32_t framePushedAfterCall = masm.framePushed(); |
| 2119 |
masm.freeStack(masm.framePushed() - stubFramePushed); |
| 2120 |
|
| 2121 |
masm.push(Imm32(int32_t(CheckIsObjectKind::IteratorReturn))); |
| 2122 |
using Fn = bool (*)(JSContext*, CheckIsObjectKind); |
| 2123 |
callVM<Fn, ThrowCheckIsObject>(masm); |
| 2124 |
|
| 2125 |
masm.bind(&success); |
| 2126 |
masm.setFramePushed(framePushedAfterCall); |
| 2127 |
} |
| 2128 |
|
| 2129 |
// Restore the frame pointer and stack pointer. |
| 2130 |
masm.loadPtr(Address(FramePointer, 0), FramePointer); |
| 2131 |
masm.freeStack(masm.framePushed() - framePushedBefore); |
| 2132 |
return true; |
| 2133 |
} |
| 2134 |
|
| 2135 |
bool IonCacheIRCompiler::emitGuardFunctionScript(ObjOperandId funId, |
| 2136 |
uint32_t expectedOffset, |
| 2137 |
uint32_t nargsAndFlagsOffset) { |
| 2138 |
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); |
| 2139 |
|
| 2140 |
Register fun = allocator.useRegister(masm, funId); |
| 2141 |
AutoScratchRegister scratch(allocator, masm); |
| 2142 |
BaseScript* expected = weakBaseScriptStubField(expectedOffset); |
| 2143 |
|
| 2144 |
FailurePath* failure; |
| 2145 |
if (!addFailurePath(&failure)) { |
| 2146 |
return false; |
| 2147 |
} |
| 2148 |
|
| 2149 |
masm.loadPrivate(Address(fun, JSFunction::offsetOfJitInfoOrScript()), |
| 2150 |
scratch); |
| 2151 |
masm.branchPtr(Assembler::NotEqual, scratch, ImmGCPtr(expected), |
| 2152 |
failure->label()); |
| 2153 |
return true; |
| 2154 |
} |
| 2155 |
|
| 2156 |
bool IonCacheIRCompiler::emitCallScriptedFunction(ObjOperandId calleeId, |
| 2157 |
Int32OperandId argcId, |
| 2158 |
CallFlags flags, |
| 2159 |
uint32_t argcFixed) { |
| 2160 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2161 |
} |
| 2162 |
|
| 2163 |
bool IonCacheIRCompiler::emitCallBoundScriptedFunction(ObjOperandId calleeId, |
| 2164 |
ObjOperandId targetId, |
| 2165 |
Int32OperandId argcId, |
| 2166 |
CallFlags flags, |
| 2167 |
uint32_t numBoundArgs) { |
| 2168 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2169 |
} |
| 2170 |
|
| 2171 |
bool IonCacheIRCompiler::emitCallWasmFunction( |
| 2172 |
ObjOperandId calleeId, Int32OperandId argcId, CallFlags flags, |
| 2173 |
uint32_t argcFixed, uint32_t funcExportOffset, uint32_t instanceOffset) { |
| 2174 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2175 |
} |
| 2176 |
|
| 2177 |
#ifdef JS_SIMULATOR |
| 2178 |
bool IonCacheIRCompiler::emitCallNativeFunction(ObjOperandId calleeId, |
| 2179 |
Int32OperandId argcId, |
| 2180 |
CallFlags flags, |
| 2181 |
uint32_t argcFixed, |
| 2182 |
uint32_t targetOffset) { |
| 2183 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2184 |
} |
| 2185 |
|
| 2186 |
bool IonCacheIRCompiler::emitCallDOMFunction( |
| 2187 |
ObjOperandId calleeId, Int32OperandId argcId, ObjOperandId thisObjId, |
| 2188 |
CallFlags flags, uint32_t argcFixed, uint32_t targetOffset) { |
| 2189 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2190 |
} |
| 2191 |
|
| 2192 |
bool IonCacheIRCompiler::emitCallDOMFunctionWithAllocSite( |
| 2193 |
ObjOperandId calleeId, Int32OperandId argcId, ObjOperandId thisObjId, |
| 2194 |
CallFlags flags, uint32_t argcFixed, uint32_t siteOffset, |
| 2195 |
uint32_t targetOffset) { |
| 2196 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2197 |
} |
| 2198 |
#else |
| 2199 |
bool IonCacheIRCompiler::emitCallNativeFunction(ObjOperandId calleeId, |
| 2200 |
Int32OperandId argcId, |
| 2201 |
CallFlags flags, |
| 2202 |
uint32_t argcFixed, |
| 2203 |
bool ignoresReturnValue) { |
| 2204 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2205 |
} |
| 2206 |
|
| 2207 |
bool IonCacheIRCompiler::emitCallDOMFunction(ObjOperandId calleeId, |
| 2208 |
Int32OperandId argcId, |
| 2209 |
ObjOperandId thisObjId, |
| 2210 |
CallFlags flags, |
| 2211 |
uint32_t argcFixed) { |
| 2212 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2213 |
} |
| 2214 |
|
| 2215 |
bool IonCacheIRCompiler::emitCallDOMFunctionWithAllocSite( |
| 2216 |
ObjOperandId calleeId, Int32OperandId argcId, ObjOperandId thisObjId, |
| 2217 |
CallFlags flags, uint32_t argcFixed, uint32_t siteOffset) { |
| 2218 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2219 |
} |
| 2220 |
#endif |
| 2221 |
|
| 2222 |
bool IonCacheIRCompiler::emitCallClassHook(ObjOperandId calleeId, |
| 2223 |
Int32OperandId argcId, |
| 2224 |
CallFlags flags, uint32_t argcFixed, |
| 2225 |
uint32_t targetOffset) { |
| 2226 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2227 |
} |
| 2228 |
|
| 2229 |
bool IonCacheIRCompiler::emitCallInlinedFunction(ObjOperandId calleeId, |
| 2230 |
Int32OperandId argcId, |
| 2231 |
uint32_t icScriptOffset, |
| 2232 |
CallFlags flags, |
| 2233 |
uint32_t argcFixed) { |
| 2234 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2235 |
} |
| 2236 |
|
| 2237 |
bool IonCacheIRCompiler::emitBindFunctionResult(ObjOperandId targetId, |
| 2238 |
uint32_t argc, |
| 2239 |
uint32_t templateObjectOffset) { |
| 2240 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2241 |
} |
| 2242 |
|
| 2243 |
bool IonCacheIRCompiler::emitSpecializedBindFunctionResult( |
| 2244 |
ObjOperandId targetId, uint32_t argc, uint32_t templateObjectOffset) { |
| 2245 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2246 |
} |
| 2247 |
|
| 2248 |
bool IonCacheIRCompiler::emitLoadArgumentFixedSlot(ValOperandId resultId, |
| 2249 |
uint8_t slotIndex) { |
| 2250 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2251 |
} |
| 2252 |
|
| 2253 |
bool IonCacheIRCompiler::emitLoadArgumentDynamicSlot(ValOperandId resultId, |
| 2254 |
Int32OperandId argcId, |
| 2255 |
uint8_t slotIndex) { |
| 2256 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2257 |
} |
| 2258 |
|
| 2259 |
bool IonCacheIRCompiler::emitArrayJoinResult(ObjOperandId objId, |
| 2260 |
StringOperandId sepId) { |
| 2261 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2262 |
} |
| 2263 |
|
| 2264 |
bool IonCacheIRCompiler::emitPackedArraySliceResult( |
| 2265 |
uint32_t templateObjectOffset, ObjOperandId arrayId, Int32OperandId beginId, |
| 2266 |
Int32OperandId endId) { |
| 2267 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2268 |
} |
| 2269 |
|
| 2270 |
bool IonCacheIRCompiler::emitArgumentsSliceResult(uint32_t templateObjectOffset, |
| 2271 |
ObjOperandId argsId, |
| 2272 |
Int32OperandId beginId, |
| 2273 |
Int32OperandId endId) { |
| 2274 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2275 |
} |
| 2276 |
|
| 2277 |
bool IonCacheIRCompiler::emitIsArrayResult(ValOperandId inputId) { |
| 2278 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2279 |
} |
| 2280 |
|
| 2281 |
bool IonCacheIRCompiler::emitIsTypedArrayResult(ObjOperandId objId, |
| 2282 |
bool isPossiblyWrapped) { |
| 2283 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2284 |
} |
| 2285 |
|
| 2286 |
bool IonCacheIRCompiler::emitStringFromCharCodeResult(Int32OperandId codeId) { |
| 2287 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2288 |
} |
| 2289 |
|
| 2290 |
bool IonCacheIRCompiler::emitStringFromCodePointResult(Int32OperandId codeId) { |
| 2291 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2292 |
} |
| 2293 |
|
| 2294 |
bool IonCacheIRCompiler::emitMathRandomResult(uint32_t rngOffset) { |
| 2295 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2296 |
} |
| 2297 |
|
| 2298 |
bool IonCacheIRCompiler::emitReflectGetPrototypeOfResult(ObjOperandId objId) { |
| 2299 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2300 |
} |
| 2301 |
|
| 2302 |
bool IonCacheIRCompiler::emitHasClassResult(ObjOperandId objId, |
| 2303 |
uint32_t claspOffset) { |
| 2304 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2305 |
} |
| 2306 |
|
| 2307 |
bool IonCacheIRCompiler::emitHasShapeResult(ObjOperandId objId, |
| 2308 |
uint32_t shapeOffset) { |
| 2309 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2310 |
} |
| 2311 |
|
| 2312 |
bool IonCacheIRCompiler::emitSameValueResult(ValOperandId lhs, |
| 2313 |
ValOperandId rhs) { |
| 2314 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2315 |
} |
| 2316 |
|
| 2317 |
bool IonCacheIRCompiler::emitSetHasStringResult(ObjOperandId setId, |
| 2318 |
StringOperandId strId) { |
| 2319 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2320 |
} |
| 2321 |
|
| 2322 |
bool IonCacheIRCompiler::emitMapHasStringResult(ObjOperandId mapId, |
| 2323 |
StringOperandId strId) { |
| 2324 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2325 |
} |
| 2326 |
|
| 2327 |
bool IonCacheIRCompiler::emitMapGetStringResult(ObjOperandId mapId, |
| 2328 |
StringOperandId strId) { |
| 2329 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2330 |
} |
| 2331 |
|
| 2332 |
bool IonCacheIRCompiler::emitNewArrayObjectResult(uint32_t arrayLength, |
| 2333 |
uint32_t shapeOffset, |
| 2334 |
uint32_t siteOffset) { |
| 2335 |
MOZ_CRASH("NewArray ICs not used in ion"); |
| 2336 |
} |
| 2337 |
|
| 2338 |
bool IonCacheIRCompiler::emitNewPlainObjectResult(uint32_t numFixedSlots, |
| 2339 |
uint32_t numDynamicSlots, |
| 2340 |
gc::AllocKind allocKind, |
| 2341 |
uint32_t shapeOffset, |
| 2342 |
uint32_t siteOffset) { |
| 2343 |
MOZ_CRASH("NewObject ICs not used in ion"); |
| 2344 |
} |
| 2345 |
|
| 2346 |
bool IonCacheIRCompiler::emitNewFunctionCloneResult(uint32_t canonicalOffset, |
| 2347 |
gc::AllocKind allocKind, |
| 2348 |
uint32_t siteOffset) { |
| 2349 |
MOZ_CRASH("Lambda ICs not used in ion"); |
| 2350 |
} |
| 2351 |
|
| 2352 |
bool IonCacheIRCompiler::emitCallRegExpMatcherResult(ObjOperandId regexpId, |
| 2353 |
StringOperandId inputId, |
| 2354 |
Int32OperandId lastIndexId, |
| 2355 |
uint32_t stubOffset) { |
| 2356 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2357 |
} |
| 2358 |
|
| 2359 |
bool IonCacheIRCompiler::emitCallRegExpSearcherResult( |
| 2360 |
ObjOperandId regexpId, StringOperandId inputId, Int32OperandId lastIndexId, |
| 2361 |
uint32_t stubOffset) { |
| 2362 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2363 |
} |
| 2364 |
|
| 2365 |
bool IonCacheIRCompiler::emitRegExpBuiltinExecMatchResult( |
| 2366 |
ObjOperandId regexpId, StringOperandId inputId, uint32_t stubOffset) { |
| 2367 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2368 |
} |
| 2369 |
|
| 2370 |
bool IonCacheIRCompiler::emitRegExpBuiltinExecTestResult( |
| 2371 |
ObjOperandId regexpId, StringOperandId inputId, uint32_t stubOffset) { |
| 2372 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2373 |
} |
| 2374 |
|
| 2375 |
bool IonCacheIRCompiler::emitRegExpHasCaptureGroupsResult( |
| 2376 |
ObjOperandId regexpId, StringOperandId inputId) { |
| 2377 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2378 |
} |
| 2379 |
|
| 2380 |
bool IonCacheIRCompiler::emitLoadStringAtResult(StringOperandId strId, |
| 2381 |
Int32OperandId indexId, |
| 2382 |
bool handleOOB) { |
| 2383 |
MOZ_CRASH("Call ICs not used in ion"); |
| 2384 |
} |