| 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/WarpCacheIRTranspiler.h" |
| 8 |
|
| 9 |
#include "mozilla/Casting.h" |
| 10 |
#include "mozilla/Maybe.h" |
| 11 |
|
| 12 |
#include "jsmath.h" |
| 13 |
|
| 14 |
#include "jit/AtomicOp.h" |
| 15 |
#include "jit/CacheIR.h" |
| 16 |
#include "jit/CacheIRCompiler.h" |
| 17 |
#include "jit/CacheIROpsGenerated.h" |
| 18 |
#include "jit/CacheIRReader.h" |
| 19 |
#include "jit/LIR.h" |
| 20 |
#include "jit/MIR-wasm.h" |
| 21 |
#include "jit/MIR.h" |
| 22 |
#include "jit/MIRGenerator.h" |
| 23 |
#include "jit/MIRGraph.h" |
| 24 |
#include "jit/WarpBuilder.h" |
| 25 |
#include "jit/WarpBuilderShared.h" |
| 26 |
#include "jit/WarpSnapshot.h" |
| 27 |
#include "js/ScalarType.h" // js::Scalar::Type |
| 28 |
#include "vm/BytecodeLocation.h" |
| 29 |
#include "vm/TypeofEqOperand.h" // TypeofEqOperand |
| 30 |
#include "wasm/WasmCode.h" |
| 31 |
|
| 32 |
#include "gc/ObjectKind-inl.h" |
| 33 |
#include "vm/NativeObject-inl.h" |
| 34 |
#include "wasm/WasmInstance-inl.h" |
| 35 |
|
| 36 |
using namespace js; |
| 37 |
using namespace js::jit; |
| 38 |
|
| 39 |
// The CacheIR transpiler generates MIR from Baseline CacheIR. |
| 40 |
class MOZ_RAII WarpCacheIRTranspiler : public WarpBuilderShared { |
| 41 |
WarpBuilder* builder_; |
| 42 |
BytecodeLocation loc_; |
| 43 |
const CacheIRStubInfo* stubInfo_; |
| 44 |
const uint8_t* stubData_; |
| 45 |
|
| 46 |
// Vector mapping OperandId to corresponding MDefinition. |
| 47 |
using MDefinitionStackVector = Vector<MDefinition*, 8, SystemAllocPolicy>; |
| 48 |
MDefinitionStackVector operands_; |
| 49 |
|
| 50 |
CallInfo* callInfo_; |
| 51 |
|
| 52 |
// Array mapping call arguments to OperandId. |
| 53 |
using ArgumentKindArray = |
| 54 |
mozilla::EnumeratedArray<ArgumentKind, OperandId, |
| 55 |
size_t(ArgumentKind::NumKinds)>; |
| 56 |
ArgumentKindArray argumentOperandIds_; |
| 57 |
|
| 58 |
void setArgumentId(ArgumentKind kind, OperandId id) { |
| 59 |
MOZ_ASSERT(kind != ArgumentKind::Callee); |
| 60 |
MOZ_ASSERT(!argumentOperandIds_[kind].valid()); |
| 61 |
argumentOperandIds_[kind] = id; |
| 62 |
} |
| 63 |
|
| 64 |
void updateArgumentsFromOperands(); |
| 65 |
|
| 66 |
#ifdef DEBUG |
| 67 |
// Used to assert that there is only one effectful instruction |
| 68 |
// per stub. And that this instruction has a resume point. |
| 69 |
MInstruction* effectful_ = nullptr; |
| 70 |
bool pushedResult_ = false; |
| 71 |
#endif |
| 72 |
|
| 73 |
inline void addUnchecked(MInstruction* ins) { |
| 74 |
current->add(ins); |
| 75 |
|
| 76 |
// If we have not set a more specific bailout kind, mark this instruction |
| 77 |
// as transpiled CacheIR. If one of these instructions bails out, we |
| 78 |
// expect to hit the baseline fallback stub and invalidate the Warp script |
| 79 |
// in tryAttach. |
| 80 |
if (ins->bailoutKind() == BailoutKind::Unknown) { |
| 81 |
ins->setBailoutKind(BailoutKind::TranspiledCacheIR); |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
inline void add(MInstruction* ins) { |
| 86 |
MOZ_ASSERT(!ins->isEffectful()); |
| 87 |
addUnchecked(ins); |
| 88 |
} |
| 89 |
|
| 90 |
inline void addEffectful(MInstruction* ins) { |
| 91 |
MOZ_ASSERT(ins->isEffectful()); |
| 92 |
MOZ_ASSERT(!effectful_, "Can only have one effectful instruction"); |
| 93 |
addUnchecked(ins); |
| 94 |
#ifdef DEBUG |
| 95 |
effectful_ = ins; |
| 96 |
#endif |
| 97 |
} |
| 98 |
|
| 99 |
// Bypasses all checks in addEffectful. Use with caution! |
| 100 |
inline void addEffectfulUnsafe(MInstruction* ins) { |
| 101 |
MOZ_ASSERT(ins->isEffectful()); |
| 102 |
addUnchecked(ins); |
| 103 |
} |
| 104 |
|
| 105 |
[[nodiscard]] bool resumeAfterUnchecked(MInstruction* ins) { |
| 106 |
return WarpBuilderShared::resumeAfter(ins, loc_); |
| 107 |
} |
| 108 |
[[nodiscard]] bool resumeAfter(MInstruction* ins) { |
| 109 |
MOZ_ASSERT(effectful_ == ins); |
| 110 |
return resumeAfterUnchecked(ins); |
| 111 |
} |
| 112 |
|
| 113 |
// CacheIR instructions writing to the IC's result register (the *Result |
| 114 |
// instructions) must call this to push the result onto the virtual stack. |
| 115 |
void pushResult(MDefinition* result) { |
| 116 |
MOZ_ASSERT(!pushedResult_, "Can't have more than one result"); |
| 117 |
current->push(result); |
| 118 |
#ifdef DEBUG |
| 119 |
pushedResult_ = true; |
| 120 |
#endif |
| 121 |
} |
| 122 |
|
| 123 |
MDefinition* getOperand(OperandId id) const { return operands_[id.id()]; } |
| 124 |
|
| 125 |
void setOperand(OperandId id, MDefinition* def) { operands_[id.id()] = def; } |
| 126 |
|
| 127 |
[[nodiscard]] bool defineOperand(OperandId id, MDefinition* def) { |
| 128 |
MOZ_ASSERT(id.id() == operands_.length()); |
| 129 |
return operands_.append(def); |
| 130 |
} |
| 131 |
|
| 132 |
uintptr_t readStubWord(uint32_t offset) { |
| 133 |
return stubInfo_->getStubRawWord(stubData_, offset); |
| 134 |
} |
| 135 |
|
| 136 |
Shape* shapeStubField(uint32_t offset) { |
| 137 |
return reinterpret_cast<Shape*>(readStubWord(offset)); |
| 138 |
} |
| 139 |
GetterSetter* getterSetterStubField(uint32_t offset) { |
| 140 |
return reinterpret_cast<GetterSetter*>(readStubWord(offset)); |
| 141 |
} |
| 142 |
const JSClass* classStubField(uint32_t offset) { |
| 143 |
return reinterpret_cast<const JSClass*>(readStubWord(offset)); |
| 144 |
} |
| 145 |
JSString* stringStubField(uint32_t offset) { |
| 146 |
return reinterpret_cast<JSString*>(readStubWord(offset)); |
| 147 |
} |
| 148 |
JS::Symbol* symbolStubField(uint32_t offset) { |
| 149 |
return reinterpret_cast<JS::Symbol*>(readStubWord(offset)); |
| 150 |
} |
| 151 |
BaseScript* baseScriptStubField(uint32_t offset) { |
| 152 |
return reinterpret_cast<BaseScript*>(readStubWord(offset)); |
| 153 |
} |
| 154 |
const JSJitInfo* jitInfoStubField(uint32_t offset) { |
| 155 |
return reinterpret_cast<const JSJitInfo*>(readStubWord(offset)); |
| 156 |
} |
| 157 |
JSNative jsnativeStubField(uint32_t offset) { |
| 158 |
return reinterpret_cast<JSNative>(readStubWord(offset)); |
| 159 |
} |
| 160 |
JS::ExpandoAndGeneration* expandoAndGenerationField(uint32_t offset) { |
| 161 |
return reinterpret_cast<JS::ExpandoAndGeneration*>(readStubWord(offset)); |
| 162 |
} |
| 163 |
const wasm::FuncExport* wasmFuncExportField(uint32_t offset) { |
| 164 |
return reinterpret_cast<const wasm::FuncExport*>(readStubWord(offset)); |
| 165 |
} |
| 166 |
NativeIteratorListHead* nativeIteratorListHeadStubField(uint32_t offset) { |
| 167 |
return reinterpret_cast<NativeIteratorListHead*>(readStubWord(offset)); |
| 168 |
} |
| 169 |
size_t* fuseStubField(uint32_t offset) { |
| 170 |
return reinterpret_cast<size_t*>(readStubWord(offset)); |
| 171 |
} |
| 172 |
gc::Heap allocSiteInitialHeapField(uint32_t offset) { |
| 173 |
uintptr_t word = readStubWord(offset); |
| 174 |
MOZ_ASSERT(word == uintptr_t(gc::Heap::Default) || |
| 175 |
word == uintptr_t(gc::Heap::Tenured)); |
| 176 |
return gc::Heap(word); |
| 177 |
} |
| 178 |
const void* rawPointerField(uint32_t offset) { |
| 179 |
return reinterpret_cast<const void*>(readStubWord(offset)); |
| 180 |
} |
| 181 |
jsid idStubField(uint32_t offset) { |
| 182 |
return jsid::fromRawBits(readStubWord(offset)); |
| 183 |
} |
| 184 |
int32_t int32StubField(uint32_t offset) { |
| 185 |
return static_cast<int32_t>(readStubWord(offset)); |
| 186 |
} |
| 187 |
uint32_t uint32StubField(uint32_t offset) { |
| 188 |
return static_cast<uint32_t>(readStubWord(offset)); |
| 189 |
} |
| 190 |
uint64_t uint64StubField(uint32_t offset) { |
| 191 |
return static_cast<uint64_t>(stubInfo_->getStubRawInt64(stubData_, offset)); |
| 192 |
} |
| 193 |
Value valueStubField(uint32_t offset) { |
| 194 |
uint64_t raw = |
| 195 |
static_cast<uint64_t>(stubInfo_->getStubRawInt64(stubData_, offset)); |
| 196 |
Value val = Value::fromRawBits(raw); |
| 197 |
MOZ_ASSERT_IF(val.isGCThing(), val.toGCThing()->isTenured()); |
| 198 |
return val; |
| 199 |
} |
| 200 |
double doubleStubField(uint32_t offset) { |
| 201 |
uint64_t raw = |
| 202 |
static_cast<uint64_t>(stubInfo_->getStubRawInt64(stubData_, offset)); |
| 203 |
return mozilla::BitwiseCast<double>(raw); |
| 204 |
} |
| 205 |
|
| 206 |
// This must only be called when the caller knows the object is tenured and |
| 207 |
// not a nursery index. |
| 208 |
JSObject* tenuredObjectStubField(uint32_t offset) { |
| 209 |
WarpObjectField field = WarpObjectField::fromData(readStubWord(offset)); |
| 210 |
return field.toObject(); |
| 211 |
} |
| 212 |
|
| 213 |
// Returns either MConstant or MNurseryIndex. See WarpObjectField. |
| 214 |
MInstruction* objectStubField(uint32_t offset); |
| 215 |
|
| 216 |
const JSClass* classForGuardClassKind(GuardClassKind kind); |
| 217 |
|
| 218 |
[[nodiscard]] bool emitGuardTo(ValOperandId inputId, MIRType type); |
| 219 |
|
| 220 |
[[nodiscard]] bool emitToString(OperandId inputId, StringOperandId resultId); |
| 221 |
|
| 222 |
template <typename T> |
| 223 |
[[nodiscard]] bool emitDoubleBinaryArithResult(NumberOperandId lhsId, |
| 224 |
NumberOperandId rhsId); |
| 225 |
|
| 226 |
template <typename T> |
| 227 |
[[nodiscard]] bool emitInt32BinaryArithResult(Int32OperandId lhsId, |
| 228 |
Int32OperandId rhsId); |
| 229 |
|
| 230 |
template <typename T> |
| 231 |
[[nodiscard]] bool emitBigIntBinaryArithResult(BigIntOperandId lhsId, |
| 232 |
BigIntOperandId rhsId); |
| 233 |
|
| 234 |
template <typename T> |
| 235 |
[[nodiscard]] bool emitBigIntBinaryArithEffectfulResult( |
| 236 |
BigIntOperandId lhsId, BigIntOperandId rhsId); |
| 237 |
|
| 238 |
template <typename T> |
| 239 |
[[nodiscard]] bool emitBigIntUnaryArithResult(BigIntOperandId inputId); |
| 240 |
|
| 241 |
template <typename T> |
| 242 |
[[nodiscard]] bool emitBigIntPtrBinaryArith(IntPtrOperandId lhsId, |
| 243 |
IntPtrOperandId rhsId, |
| 244 |
IntPtrOperandId resultId); |
| 245 |
|
| 246 |
[[nodiscard]] bool emitCompareResult(JSOp op, OperandId lhsId, |
| 247 |
OperandId rhsId, |
| 248 |
MCompare::CompareType compareType); |
| 249 |
|
| 250 |
[[nodiscard]] bool emitTruthyResult(OperandId inputId); |
| 251 |
|
| 252 |
[[nodiscard]] bool emitNewIteratorResult(MNewIterator::Type type, |
| 253 |
uint32_t templateObjectOffset); |
| 254 |
|
| 255 |
MInstruction* addBoundsCheck(MDefinition* index, MDefinition* length); |
| 256 |
|
| 257 |
[[nodiscard]] MInstruction* convertToBoolean(MDefinition* input); |
| 258 |
|
| 259 |
bool emitAddAndStoreSlotShared(MAddAndStoreSlot::Kind kind, |
| 260 |
ObjOperandId objId, uint32_t offsetOffset, |
| 261 |
ValOperandId rhsId, uint32_t newShapeOffset); |
| 262 |
|
| 263 |
MInstruction* emitTypedArrayLength(ArrayBufferViewKind viewKind, |
| 264 |
MDefinition* obj); |
| 265 |
|
| 266 |
MInstruction* emitDataViewLength(ArrayBufferViewKind viewKind, |
| 267 |
MDefinition* obj); |
| 268 |
|
| 269 |
void addDataViewData(ArrayBufferViewKind viewKind, MDefinition* obj, |
| 270 |
Scalar::Type type, MDefinition** offset, |
| 271 |
MInstruction** elements); |
| 272 |
|
| 273 |
[[nodiscard]] bool emitAtomicsBinaryOp( |
| 274 |
ObjOperandId objId, IntPtrOperandId indexId, uint32_t valueId, |
| 275 |
Scalar::Type elementType, bool forEffect, ArrayBufferViewKind viewKind, |
| 276 |
AtomicOp op); |
| 277 |
|
| 278 |
[[nodiscard]] bool emitLoadArgumentSlot(ValOperandId resultId, |
| 279 |
uint32_t slotIndex); |
| 280 |
|
| 281 |
// Calls are either Native (native function without a JitEntry), |
| 282 |
// a DOM Native (native function with a JitInfo OpType::Method), |
| 283 |
// or Scripted (scripted function or native function with a JitEntry). |
| 284 |
enum class CallKind { Native, DOM, Scripted }; |
| 285 |
|
| 286 |
[[nodiscard]] bool updateCallInfo(MDefinition* callee, CallFlags flags); |
| 287 |
|
| 288 |
[[nodiscard]] bool emitCallFunction( |
| 289 |
ObjOperandId calleeId, Int32OperandId argcId, |
| 290 |
mozilla::Maybe<ObjOperandId> thisObjId, CallFlags flags, CallKind kind, |
| 291 |
mozilla::Maybe<uint32_t> siteOffset = mozilla::Nothing()); |
| 292 |
[[nodiscard]] bool emitFunApplyArgsObj(WrappedFunction* wrappedTarget, |
| 293 |
CallFlags flags); |
| 294 |
|
| 295 |
MDefinition* convertWasmArg(MDefinition* arg, wasm::ValType::Kind kind); |
| 296 |
|
| 297 |
WrappedFunction* maybeWrappedFunction(MDefinition* callee, CallKind kind, |
| 298 |
uint16_t nargs, FunctionFlags flags); |
| 299 |
WrappedFunction* maybeCallTarget(MDefinition* callee, CallKind kind); |
| 300 |
|
| 301 |
bool maybeCreateThis(MDefinition* callee, CallFlags flags, CallKind kind); |
| 302 |
|
| 303 |
[[nodiscard]] bool emitCallGetterResult(CallKind kind, |
| 304 |
ValOperandId receiverId, |
| 305 |
uint32_t getterOffset, bool sameRealm, |
| 306 |
uint32_t nargsAndFlagsOffset); |
| 307 |
[[nodiscard]] bool emitCallSetter(CallKind kind, ObjOperandId receiverId, |
| 308 |
uint32_t setterOffset, ValOperandId rhsId, |
| 309 |
bool sameRealm, |
| 310 |
uint32_t nargsAndFlagsOffset); |
| 311 |
|
| 312 |
#ifndef JS_CODEGEN_X86 |
| 313 |
[[nodiscard]] bool emitCallScriptedProxyGetShared( |
| 314 |
MDefinition* target, MDefinition* receiver, MDefinition* handler, |
| 315 |
MDefinition* id, MDefinition* trapDef, WrappedFunction* trap); |
| 316 |
#endif |
| 317 |
|
| 318 |
CACHE_IR_TRANSPILER_GENERATED |
| 319 |
|
| 320 |
public: |
| 321 |
WarpCacheIRTranspiler(WarpBuilder* builder, BytecodeLocation loc, |
| 322 |
CallInfo* callInfo, const WarpCacheIR* cacheIRSnapshot) |
| 323 |
: WarpBuilderShared(builder->snapshot(), builder->mirGen(), |
| 324 |
builder->currentBlock()), |
| 325 |
builder_(builder), |
| 326 |
loc_(loc), |
| 327 |
stubInfo_(cacheIRSnapshot->stubInfo()), |
| 328 |
stubData_(cacheIRSnapshot->stubData()), |
| 329 |
callInfo_(callInfo) {} |
| 330 |
|
| 331 |
[[nodiscard]] bool transpile(std::initializer_list<MDefinition*> inputs); |
| 332 |
}; |
| 333 |
|
| 334 |
bool WarpCacheIRTranspiler::transpile( |
| 335 |
std::initializer_list<MDefinition*> inputs) { |
| 336 |
if (!operands_.append(inputs.begin(), inputs.end())) { |
| 337 |
return false; |
| 338 |
} |
| 339 |
|
| 340 |
CacheIRReader reader(stubInfo_); |
| 341 |
do { |
| 342 |
CacheOp op = reader.readOp(); |
| 343 |
switch (op) { |
| 344 |
#define DEFINE_OP(op, ...) \ |
| 345 |
case CacheOp::op: \ |
| 346 |
if (!emit##op(reader)) { \ |
| 347 |
return false; \ |
| 348 |
} \ |
| 349 |
break; |
| 350 |
CACHE_IR_TRANSPILER_OPS(DEFINE_OP) |
| 351 |
#undef DEFINE_OP |
| 352 |
|
| 353 |
default: |
| 354 |
fprintf(stderr, "Unsupported op: %s\n", CacheIROpNames[size_t(op)]); |
| 355 |
MOZ_CRASH("Unsupported op"); |
| 356 |
} |
| 357 |
} while (reader.more()); |
| 358 |
|
| 359 |
// Effectful instructions should have a resume point. We allow a limited |
| 360 |
// number of exceptions: |
| 361 |
// - MIonToWasmCall: Resumes after MInt64ToBigInt |
| 362 |
// - MLoadUnboxedScalar: Resumes after MInt64ToBigInt |
| 363 |
// - MAtomicTypedArrayElementBinop: Resumes after MInt64ToBigInt |
| 364 |
// - MAtomicExchangeTypedArrayElement: Resumes after MInt64ToBigInt |
| 365 |
// - MCompareExchangeTypedArrayElement: Resumes after MInt64ToBigInt |
| 366 |
// - MResizableTypedArrayLength: Resumes after MPostIntPtrConversion |
| 367 |
// - MResizableDataViewByteLength: Resumes after MPostIntPtrConversion |
| 368 |
// - MGrowableSharedArrayBufferByteLength: Resumes after MPostIntPtrConversion |
| 369 |
MOZ_ASSERT_IF(effectful_, |
| 370 |
effectful_->resumePoint() || effectful_->isIonToWasmCall() || |
| 371 |
effectful_->isLoadUnboxedScalar() || |
| 372 |
effectful_->isAtomicTypedArrayElementBinop() || |
| 373 |
effectful_->isAtomicExchangeTypedArrayElement() || |
| 374 |
effectful_->isCompareExchangeTypedArrayElement() || |
| 375 |
effectful_->isResizableTypedArrayLength() || |
| 376 |
effectful_->isResizableDataViewByteLength() || |
| 377 |
effectful_->isGrowableSharedArrayBufferByteLength()); |
| 378 |
return true; |
| 379 |
} |
| 380 |
|
| 381 |
MInstruction* WarpCacheIRTranspiler::objectStubField(uint32_t offset) { |
| 382 |
WarpObjectField field = WarpObjectField::fromData(readStubWord(offset)); |
| 383 |
|
| 384 |
if (field.isNurseryIndex()) { |
| 385 |
auto* ins = MNurseryObject::New(alloc(), field.toNurseryIndex()); |
| 386 |
add(ins); |
| 387 |
return ins; |
| 388 |
} |
| 389 |
|
| 390 |
auto* ins = MConstant::NewObject(alloc(), field.toObject()); |
| 391 |
add(ins); |
| 392 |
return ins; |
| 393 |
} |
| 394 |
|
| 395 |
bool WarpCacheIRTranspiler::emitGuardClass(ObjOperandId objId, |
| 396 |
GuardClassKind kind) { |
| 397 |
MDefinition* def = getOperand(objId); |
| 398 |
|
| 399 |
MInstruction* ins; |
| 400 |
if (kind == GuardClassKind::JSFunction) { |
| 401 |
ins = MGuardToFunction::New(alloc(), def); |
| 402 |
} else { |
| 403 |
const JSClass* classp = classForGuardClassKind(kind); |
| 404 |
ins = MGuardToClass::New(alloc(), def, classp); |
| 405 |
} |
| 406 |
|
| 407 |
add(ins); |
| 408 |
|
| 409 |
setOperand(objId, ins); |
| 410 |
return true; |
| 411 |
} |
| 412 |
|
| 413 |
bool WarpCacheIRTranspiler::emitGuardEitherClass(ObjOperandId objId, |
| 414 |
GuardClassKind kind1, |
| 415 |
GuardClassKind kind2) { |
| 416 |
MDefinition* def = getOperand(objId); |
| 417 |
|
| 418 |
// We don't yet need this case, so it's unsupported for now. |
| 419 |
MOZ_ASSERT(kind1 != GuardClassKind::JSFunction && |
| 420 |
kind2 != GuardClassKind::JSFunction); |
| 421 |
|
| 422 |
const JSClass* classp1 = classForGuardClassKind(kind1); |
| 423 |
const JSClass* classp2 = classForGuardClassKind(kind2); |
| 424 |
auto* ins = MGuardToEitherClass::New(alloc(), def, classp1, classp2); |
| 425 |
|
| 426 |
add(ins); |
| 427 |
|
| 428 |
setOperand(objId, ins); |
| 429 |
return true; |
| 430 |
} |
| 431 |
|
| 432 |
const JSClass* WarpCacheIRTranspiler::classForGuardClassKind( |
| 433 |
GuardClassKind kind) { |
| 434 |
switch (kind) { |
| 435 |
case GuardClassKind::Array: |
| 436 |
case GuardClassKind::PlainObject: |
| 437 |
case GuardClassKind::FixedLengthArrayBuffer: |
| 438 |
case GuardClassKind::ResizableArrayBuffer: |
| 439 |
case GuardClassKind::FixedLengthSharedArrayBuffer: |
| 440 |
case GuardClassKind::GrowableSharedArrayBuffer: |
| 441 |
case GuardClassKind::FixedLengthDataView: |
| 442 |
case GuardClassKind::ResizableDataView: |
| 443 |
case GuardClassKind::MappedArguments: |
| 444 |
case GuardClassKind::UnmappedArguments: |
| 445 |
case GuardClassKind::Set: |
| 446 |
case GuardClassKind::Map: |
| 447 |
case GuardClassKind::BoundFunction: |
| 448 |
case GuardClassKind::Date: |
| 449 |
return ClassFor(kind); |
| 450 |
case GuardClassKind::WindowProxy: |
| 451 |
return mirGen().runtime->maybeWindowProxyClass(); |
| 452 |
case GuardClassKind::JSFunction: |
| 453 |
break; |
| 454 |
} |
| 455 |
MOZ_CRASH("unexpected kind"); |
| 456 |
} |
| 457 |
|
| 458 |
bool WarpCacheIRTranspiler::emitGuardAnyClass(ObjOperandId objId, |
| 459 |
uint32_t claspOffset) { |
| 460 |
MDefinition* def = getOperand(objId); |
| 461 |
const JSClass* classp = classStubField(claspOffset); |
| 462 |
|
| 463 |
auto* ins = MGuardToClass::New(alloc(), def, classp); |
| 464 |
add(ins); |
| 465 |
|
| 466 |
setOperand(objId, ins); |
| 467 |
return true; |
| 468 |
} |
| 469 |
|
| 470 |
bool WarpCacheIRTranspiler::emitGuardShape(ObjOperandId objId, |
| 471 |
uint32_t shapeOffset) { |
| 472 |
MDefinition* def = getOperand(objId); |
| 473 |
|
| 474 |
// No read barrier is required because snapshot data is not weak and is traced |
| 475 |
// as part of IonCompileTask. |
| 476 |
Shape* shape = shapeStubField(shapeOffset); |
| 477 |
|
| 478 |
auto* ins = MGuardShape::New(alloc(), def, shape); |
| 479 |
add(ins); |
| 480 |
|
| 481 |
setOperand(objId, ins); |
| 482 |
return true; |
| 483 |
} |
| 484 |
|
| 485 |
template <auto FuseMember, CompilationDependency::Type DepType> |
| 486 |
struct RealmFuseDependency final : public CompilationDependency { |
| 487 |
RealmFuseDependency() : CompilationDependency(DepType) {} |
| 488 |
|
| 489 |
virtual bool registerDependency(JSContext* cx, HandleScript script) override { |
| 490 |
MOZ_ASSERT(checkDependency(cx)); |
| 491 |
|
| 492 |
return (cx->realm()->realmFuses.*FuseMember).addFuseDependency(cx, script); |
| 493 |
} |
| 494 |
|
| 495 |
virtual UniquePtr<CompilationDependency> clone() const override { |
| 496 |
return MakeUnique<RealmFuseDependency<FuseMember, DepType>>(); |
| 497 |
} |
| 498 |
|
| 499 |
virtual bool checkDependency(JSContext* cx) override { |
| 500 |
return (cx->realm()->realmFuses.*FuseMember).intact(); |
| 501 |
} |
| 502 |
|
| 503 |
virtual bool operator==(const CompilationDependency& dep) const override { |
| 504 |
return dep.type == type; |
| 505 |
} |
| 506 |
}; |
| 507 |
|
| 508 |
bool WarpCacheIRTranspiler::emitGuardFuse(RealmFuses::FuseIndex fuseIndex) { |
| 509 |
// Register a compilation dependency (for invalidating realm fuses) or add a |
| 510 |
// fuse guard (for other fuses). |
| 511 |
switch (fuseIndex) { |
| 512 |
case RealmFuses::FuseIndex::OptimizeGetIteratorFuse: { |
| 513 |
using Dependency = |
| 514 |
RealmFuseDependency<&RealmFuses::optimizeGetIteratorFuse, |
| 515 |
CompilationDependency::Type::GetIterator>; |
| 516 |
return mirGen().tracker.addDependency(Dependency()); |
| 517 |
} |
| 518 |
case RealmFuses::FuseIndex::OptimizeArraySpeciesFuse: { |
| 519 |
using Dependency = |
| 520 |
RealmFuseDependency<&RealmFuses::optimizeArraySpeciesFuse, |
| 521 |
CompilationDependency::Type::ArraySpecies>; |
| 522 |
return mirGen().tracker.addDependency(Dependency()); |
| 523 |
} |
| 524 |
case RealmFuses::FuseIndex::OptimizeRegExpPrototypeFuse: { |
| 525 |
using Dependency = |
| 526 |
RealmFuseDependency<&RealmFuses::optimizeRegExpPrototypeFuse, |
| 527 |
CompilationDependency::Type::RegExpPrototype>; |
| 528 |
return mirGen().tracker.addDependency(Dependency()); |
| 529 |
} |
| 530 |
case RealmFuses::FuseIndex::OptimizeStringPrototypeSymbolsFuse: { |
| 531 |
using Dependency = RealmFuseDependency< |
| 532 |
&RealmFuses::optimizeStringPrototypeSymbolsFuse, |
| 533 |
CompilationDependency::Type::StringPrototypeSymbols>; |
| 534 |
return mirGen().tracker.addDependency(Dependency()); |
| 535 |
} |
| 536 |
default: |
| 537 |
MOZ_ASSERT(!RealmFuses::isInvalidatingFuse(fuseIndex)); |
| 538 |
auto* ins = MGuardFuse::New(alloc(), fuseIndex); |
| 539 |
add(ins); |
| 540 |
return true; |
| 541 |
} |
| 542 |
} |
| 543 |
|
| 544 |
bool WarpCacheIRTranspiler::emitGuardMultipleShapes(ObjOperandId objId, |
| 545 |
uint32_t shapesOffset) { |
| 546 |
MDefinition* def = getOperand(objId); |
| 547 |
MInstruction* shapeList = objectStubField(shapesOffset); |
| 548 |
|
| 549 |
auto* ins = MGuardMultipleShapes::New(alloc(), def, shapeList); |
| 550 |
if (builder_->info().inlineScriptTree()->hasSharedICScript()) { |
| 551 |
ins->setBailoutKind(BailoutKind::MonomorphicInlinedStubFolding); |
| 552 |
} |
| 553 |
add(ins); |
| 554 |
|
| 555 |
setOperand(objId, ins); |
| 556 |
return true; |
| 557 |
} |
| 558 |
|
| 559 |
bool WarpCacheIRTranspiler::emitGuardNullProto(ObjOperandId objId) { |
| 560 |
MDefinition* def = getOperand(objId); |
| 561 |
|
| 562 |
auto* ins = MGuardNullProto::New(alloc(), def); |
| 563 |
add(ins); |
| 564 |
|
| 565 |
setOperand(objId, ins); |
| 566 |
return true; |
| 567 |
} |
| 568 |
|
| 569 |
bool WarpCacheIRTranspiler::emitGuardIsNativeObject(ObjOperandId objId) { |
| 570 |
MDefinition* obj = getOperand(objId); |
| 571 |
|
| 572 |
auto* ins = MGuardIsNativeObject::New(alloc(), obj); |
| 573 |
add(ins); |
| 574 |
|
| 575 |
setOperand(objId, ins); |
| 576 |
return true; |
| 577 |
} |
| 578 |
|
| 579 |
bool WarpCacheIRTranspiler::emitGuardIsProxy(ObjOperandId objId) { |
| 580 |
MDefinition* obj = getOperand(objId); |
| 581 |
|
| 582 |
auto* ins = MGuardIsProxy::New(alloc(), obj); |
| 583 |
add(ins); |
| 584 |
|
| 585 |
setOperand(objId, ins); |
| 586 |
return true; |
| 587 |
} |
| 588 |
|
| 589 |
bool WarpCacheIRTranspiler::emitGuardIsNotProxy(ObjOperandId objId) { |
| 590 |
MDefinition* obj = getOperand(objId); |
| 591 |
|
| 592 |
auto* ins = MGuardIsNotProxy::New(alloc(), obj); |
| 593 |
add(ins); |
| 594 |
|
| 595 |
setOperand(objId, ins); |
| 596 |
return true; |
| 597 |
} |
| 598 |
|
| 599 |
bool WarpCacheIRTranspiler::emitGuardIsNotDOMProxy(ObjOperandId objId) { |
| 600 |
MDefinition* obj = getOperand(objId); |
| 601 |
|
| 602 |
auto* ins = MGuardIsNotDOMProxy::New(alloc(), obj); |
| 603 |
add(ins); |
| 604 |
|
| 605 |
setOperand(objId, ins); |
| 606 |
return true; |
| 607 |
} |
| 608 |
|
| 609 |
bool WarpCacheIRTranspiler::emitGuardHasGetterSetter( |
| 610 |
ObjOperandId objId, uint32_t idOffset, uint32_t getterSetterOffset) { |
| 611 |
MDefinition* obj = getOperand(objId); |
| 612 |
jsid id = idStubField(idOffset); |
| 613 |
GetterSetter* gs = getterSetterStubField(getterSetterOffset); |
| 614 |
|
| 615 |
auto* ins = MGuardHasGetterSetter::New(alloc(), obj, id, gs); |
| 616 |
add(ins); |
| 617 |
|
| 618 |
setOperand(objId, ins); |
| 619 |
return true; |
| 620 |
} |
| 621 |
|
| 622 |
bool WarpCacheIRTranspiler::emitProxyGetResult(ObjOperandId objId, |
| 623 |
uint32_t idOffset) { |
| 624 |
MDefinition* obj = getOperand(objId); |
| 625 |
jsid id = idStubField(idOffset); |
| 626 |
|
| 627 |
auto* ins = MProxyGet::New(alloc(), obj, id); |
| 628 |
addEffectful(ins); |
| 629 |
|
| 630 |
pushResult(ins); |
| 631 |
return resumeAfter(ins); |
| 632 |
} |
| 633 |
|
| 634 |
bool WarpCacheIRTranspiler::emitProxyGetByValueResult(ObjOperandId objId, |
| 635 |
ValOperandId idId) { |
| 636 |
MDefinition* obj = getOperand(objId); |
| 637 |
MDefinition* id = getOperand(idId); |
| 638 |
|
| 639 |
auto* ins = MProxyGetByValue::New(alloc(), obj, id); |
| 640 |
addEffectful(ins); |
| 641 |
|
| 642 |
pushResult(ins); |
| 643 |
return resumeAfter(ins); |
| 644 |
} |
| 645 |
|
| 646 |
bool WarpCacheIRTranspiler::emitProxyHasPropResult(ObjOperandId objId, |
| 647 |
ValOperandId idId, |
| 648 |
bool hasOwn) { |
| 649 |
MDefinition* obj = getOperand(objId); |
| 650 |
MDefinition* id = getOperand(idId); |
| 651 |
|
| 652 |
auto* ins = MProxyHasProp::New(alloc(), obj, id, hasOwn); |
| 653 |
addEffectful(ins); |
| 654 |
|
| 655 |
pushResult(ins); |
| 656 |
return resumeAfter(ins); |
| 657 |
} |
| 658 |
|
| 659 |
bool WarpCacheIRTranspiler::emitProxySet(ObjOperandId objId, uint32_t idOffset, |
| 660 |
ValOperandId rhsId, bool strict) { |
| 661 |
MDefinition* obj = getOperand(objId); |
| 662 |
jsid id = idStubField(idOffset); |
| 663 |
MDefinition* rhs = getOperand(rhsId); |
| 664 |
|
| 665 |
auto* ins = MProxySet::New(alloc(), obj, rhs, id, strict); |
| 666 |
addEffectful(ins); |
| 667 |
|
| 668 |
return resumeAfter(ins); |
| 669 |
} |
| 670 |
|
| 671 |
bool WarpCacheIRTranspiler::emitProxySetByValue(ObjOperandId objId, |
| 672 |
ValOperandId idId, |
| 673 |
ValOperandId rhsId, |
| 674 |
bool strict) { |
| 675 |
MDefinition* obj = getOperand(objId); |
| 676 |
MDefinition* id = getOperand(idId); |
| 677 |
MDefinition* rhs = getOperand(rhsId); |
| 678 |
|
| 679 |
auto* ins = MProxySetByValue::New(alloc(), obj, id, rhs, strict); |
| 680 |
addEffectful(ins); |
| 681 |
|
| 682 |
return resumeAfter(ins); |
| 683 |
} |
| 684 |
|
| 685 |
bool WarpCacheIRTranspiler::emitCallSetArrayLength(ObjOperandId objId, |
| 686 |
bool strict, |
| 687 |
ValOperandId rhsId) { |
| 688 |
MDefinition* obj = getOperand(objId); |
| 689 |
MDefinition* rhs = getOperand(rhsId); |
| 690 |
|
| 691 |
auto* ins = MCallSetArrayLength::New(alloc(), obj, rhs, strict); |
| 692 |
addEffectful(ins); |
| 693 |
|
| 694 |
return resumeAfter(ins); |
| 695 |
} |
| 696 |
|
| 697 |
bool WarpCacheIRTranspiler::emitCallDOMGetterResult(ObjOperandId objId, |
| 698 |
uint32_t jitInfoOffset) { |
| 699 |
MDefinition* obj = getOperand(objId); |
| 700 |
const JSJitInfo* jitInfo = jitInfoStubField(jitInfoOffset); |
| 701 |
|
| 702 |
MInstruction* ins; |
| 703 |
if (jitInfo->isAlwaysInSlot) { |
| 704 |
ins = MGetDOMMember::New(alloc(), jitInfo, obj, nullptr, nullptr); |
| 705 |
} else { |
| 706 |
// TODO(post-Warp): realms, guard operands (movable?). |
| 707 |
ins = MGetDOMProperty::New(alloc(), jitInfo, DOMObjectKind::Native, |
| 708 |
(JS::Realm*)mirGen().realm->realmPtr(), obj, |
| 709 |
nullptr, nullptr); |
| 710 |
} |
| 711 |
|
| 712 |
if (!ins) { |
| 713 |
return false; |
| 714 |
} |
| 715 |
|
| 716 |
if (ins->isEffectful()) { |
| 717 |
addEffectful(ins); |
| 718 |
pushResult(ins); |
| 719 |
return resumeAfter(ins); |
| 720 |
} |
| 721 |
|
| 722 |
add(ins); |
| 723 |
pushResult(ins); |
| 724 |
return true; |
| 725 |
} |
| 726 |
|
| 727 |
bool WarpCacheIRTranspiler::emitCallDOMSetter(ObjOperandId objId, |
| 728 |
uint32_t jitInfoOffset, |
| 729 |
ValOperandId rhsId) { |
| 730 |
MDefinition* obj = getOperand(objId); |
| 731 |
const JSJitInfo* jitInfo = jitInfoStubField(jitInfoOffset); |
| 732 |
MDefinition* value = getOperand(rhsId); |
| 733 |
|
| 734 |
MOZ_ASSERT(jitInfo->type() == JSJitInfo::Setter); |
| 735 |
auto* set = |
| 736 |
MSetDOMProperty::New(alloc(), jitInfo->setter, DOMObjectKind::Native, |
| 737 |
(JS::Realm*)mirGen().realm->realmPtr(), obj, value); |
| 738 |
addEffectful(set); |
| 739 |
return resumeAfter(set); |
| 740 |
} |
| 741 |
|
| 742 |
bool WarpCacheIRTranspiler::emitLoadDOMExpandoValue(ObjOperandId objId, |
| 743 |
ValOperandId resultId) { |
| 744 |
MDefinition* proxy = getOperand(objId); |
| 745 |
|
| 746 |
auto* ins = MLoadDOMExpandoValue::New(alloc(), proxy); |
| 747 |
add(ins); |
| 748 |
|
| 749 |
return defineOperand(resultId, ins); |
| 750 |
} |
| 751 |
|
| 752 |
bool WarpCacheIRTranspiler::emitLoadDOMExpandoValueGuardGeneration( |
| 753 |
ObjOperandId objId, uint32_t expandoAndGenerationOffset, |
| 754 |
uint32_t generationOffset, ValOperandId resultId) { |
| 755 |
MDefinition* proxy = getOperand(objId); |
| 756 |
JS::ExpandoAndGeneration* expandoAndGeneration = |
| 757 |
expandoAndGenerationField(expandoAndGenerationOffset); |
| 758 |
uint64_t generation = uint64StubField(generationOffset); |
| 759 |
|
| 760 |
auto* ins = MLoadDOMExpandoValueGuardGeneration::New( |
| 761 |
alloc(), proxy, expandoAndGeneration, generation); |
| 762 |
add(ins); |
| 763 |
|
| 764 |
return defineOperand(resultId, ins); |
| 765 |
} |
| 766 |
|
| 767 |
bool WarpCacheIRTranspiler::emitLoadDOMExpandoValueIgnoreGeneration( |
| 768 |
ObjOperandId objId, ValOperandId resultId) { |
| 769 |
MDefinition* proxy = getOperand(objId); |
| 770 |
|
| 771 |
auto* ins = MLoadDOMExpandoValueIgnoreGeneration::New(alloc(), proxy); |
| 772 |
add(ins); |
| 773 |
|
| 774 |
return defineOperand(resultId, ins); |
| 775 |
} |
| 776 |
|
| 777 |
bool WarpCacheIRTranspiler::emitGuardDOMExpandoMissingOrGuardShape( |
| 778 |
ValOperandId expandoId, uint32_t shapeOffset) { |
| 779 |
MDefinition* expando = getOperand(expandoId); |
| 780 |
Shape* shape = shapeStubField(shapeOffset); |
| 781 |
|
| 782 |
auto* ins = MGuardDOMExpandoMissingOrGuardShape::New(alloc(), expando, shape); |
| 783 |
add(ins); |
| 784 |
|
| 785 |
setOperand(expandoId, ins); |
| 786 |
return true; |
| 787 |
} |
| 788 |
|
| 789 |
bool WarpCacheIRTranspiler::emitMegamorphicLoadSlotResult(ObjOperandId objId, |
| 790 |
uint32_t nameOffset) { |
| 791 |
MDefinition* obj = getOperand(objId); |
| 792 |
PropertyName* name = stringStubField(nameOffset)->asAtom().asPropertyName(); |
| 793 |
|
| 794 |
auto* ins = MMegamorphicLoadSlot::New(alloc(), obj, NameToId(name)); |
| 795 |
|
| 796 |
add(ins); |
| 797 |
pushResult(ins); |
| 798 |
return true; |
| 799 |
} |
| 800 |
|
| 801 |
bool WarpCacheIRTranspiler::emitMegamorphicLoadSlotPermissiveResult( |
| 802 |
ObjOperandId objId, uint32_t nameOffset) { |
| 803 |
MDefinition* obj = getOperand(objId); |
| 804 |
PropertyName* name = stringStubField(nameOffset)->asAtom().asPropertyName(); |
| 805 |
|
| 806 |
auto* ins = MMegamorphicLoadSlotPermissive::New(alloc(), obj, NameToId(name)); |
| 807 |
|
| 808 |
addEffectful(ins); |
| 809 |
pushResult(ins); |
| 810 |
return resumeAfter(ins); |
| 811 |
} |
| 812 |
|
| 813 |
bool WarpCacheIRTranspiler::emitMegamorphicLoadSlotByValueResult( |
| 814 |
ObjOperandId objId, ValOperandId idId) { |
| 815 |
MDefinition* obj = getOperand(objId); |
| 816 |
MDefinition* id = getOperand(idId); |
| 817 |
|
| 818 |
auto* ins = MMegamorphicLoadSlotByValue::New(alloc(), obj, id); |
| 819 |
|
| 820 |
add(ins); |
| 821 |
pushResult(ins); |
| 822 |
return true; |
| 823 |
} |
| 824 |
|
| 825 |
bool WarpCacheIRTranspiler::emitMegamorphicLoadSlotByValuePermissiveResult( |
| 826 |
ObjOperandId objId, ValOperandId idId) { |
| 827 |
MDefinition* obj = getOperand(objId); |
| 828 |
MDefinition* id = getOperand(idId); |
| 829 |
|
| 830 |
auto* ins = MMegamorphicLoadSlotByValuePermissive::New(alloc(), obj, id); |
| 831 |
|
| 832 |
addEffectful(ins); |
| 833 |
pushResult(ins); |
| 834 |
return resumeAfter(ins); |
| 835 |
} |
| 836 |
|
| 837 |
bool WarpCacheIRTranspiler::emitMegamorphicStoreSlot(ObjOperandId objId, |
| 838 |
uint32_t idOffset, |
| 839 |
ValOperandId rhsId, |
| 840 |
bool strict) { |
| 841 |
MDefinition* obj = getOperand(objId); |
| 842 |
jsid id = idStubField(idOffset); |
| 843 |
MDefinition* rhs = getOperand(rhsId); |
| 844 |
|
| 845 |
auto* ins = MMegamorphicStoreSlot::New(alloc(), obj, rhs, id, strict); |
| 846 |
addEffectful(ins); |
| 847 |
|
| 848 |
return resumeAfter(ins); |
| 849 |
} |
| 850 |
|
| 851 |
bool WarpCacheIRTranspiler::emitMegamorphicHasPropResult(ObjOperandId objId, |
| 852 |
ValOperandId idId, |
| 853 |
bool hasOwn) { |
| 854 |
MDefinition* obj = getOperand(objId); |
| 855 |
MDefinition* id = getOperand(idId); |
| 856 |
|
| 857 |
auto* ins = MMegamorphicHasProp::New(alloc(), obj, id, hasOwn); |
| 858 |
add(ins); |
| 859 |
|
| 860 |
pushResult(ins); |
| 861 |
return true; |
| 862 |
} |
| 863 |
|
| 864 |
bool WarpCacheIRTranspiler::emitSmallObjectVariableKeyHasOwnResult( |
| 865 |
StringOperandId idId, uint32_t propNamesOffset, uint32_t shapeOffset) { |
| 866 |
MDefinition* id = getOperand(idId); |
| 867 |
SharedShape* shape = &shapeStubField(shapeOffset)->asShared(); |
| 868 |
|
| 869 |
auto* ins = MSmallObjectVariableKeyHasProp::New(alloc(), id, shape); |
| 870 |
add(ins); |
| 871 |
|
| 872 |
pushResult(ins); |
| 873 |
return true; |
| 874 |
} |
| 875 |
|
| 876 |
bool WarpCacheIRTranspiler::emitMegamorphicSetElement(ObjOperandId objId, |
| 877 |
ValOperandId idId, |
| 878 |
ValOperandId rhsId, |
| 879 |
bool strict) { |
| 880 |
MDefinition* obj = getOperand(objId); |
| 881 |
MDefinition* id = getOperand(idId); |
| 882 |
MDefinition* rhs = getOperand(rhsId); |
| 883 |
|
| 884 |
auto* ins = MMegamorphicSetElement::New(alloc(), obj, id, rhs, strict); |
| 885 |
addEffectful(ins); |
| 886 |
|
| 887 |
return resumeAfter(ins); |
| 888 |
} |
| 889 |
|
| 890 |
bool WarpCacheIRTranspiler::emitObjectToIteratorResult( |
| 891 |
ObjOperandId objId, uint32_t enumeratorsAddrOffset) { |
| 892 |
MDefinition* obj = getOperand(objId); |
| 893 |
NativeIteratorListHead* enumeratorsAddr = |
| 894 |
nativeIteratorListHeadStubField(enumeratorsAddrOffset); |
| 895 |
|
| 896 |
auto* ins = MObjectToIterator::New(alloc(), obj, enumeratorsAddr); |
| 897 |
addEffectful(ins); |
| 898 |
pushResult(ins); |
| 899 |
if (!resumeAfter(ins)) { |
| 900 |
return false; |
| 901 |
} |
| 902 |
|
| 903 |
return true; |
| 904 |
} |
| 905 |
|
| 906 |
bool WarpCacheIRTranspiler::emitValueToIteratorResult(ValOperandId valId) { |
| 907 |
MDefinition* val = getOperand(valId); |
| 908 |
|
| 909 |
auto* ins = MValueToIterator::New(alloc(), val); |
| 910 |
addEffectful(ins); |
| 911 |
|
| 912 |
pushResult(ins); |
| 913 |
return resumeAfter(ins); |
| 914 |
} |
| 915 |
|
| 916 |
bool WarpCacheIRTranspiler::emitGuardIsNotArrayBufferMaybeShared( |
| 917 |
ObjOperandId objId) { |
| 918 |
MDefinition* obj = getOperand(objId); |
| 919 |
|
| 920 |
auto* ins = MGuardIsNotArrayBufferMaybeShared::New(alloc(), obj); |
| 921 |
add(ins); |
| 922 |
|
| 923 |
setOperand(objId, ins); |
| 924 |
return true; |
| 925 |
} |
| 926 |
|
| 927 |
bool WarpCacheIRTranspiler::emitGuardIsTypedArray(ObjOperandId objId) { |
| 928 |
MDefinition* obj = getOperand(objId); |
| 929 |
|
| 930 |
auto* ins = MGuardIsTypedArray::New(alloc(), obj); |
| 931 |
add(ins); |
| 932 |
|
| 933 |
setOperand(objId, ins); |
| 934 |
return true; |
| 935 |
} |
| 936 |
|
| 937 |
bool WarpCacheIRTranspiler::emitGuardIsFixedLengthTypedArray( |
| 938 |
ObjOperandId objId) { |
| 939 |
MDefinition* obj = getOperand(objId); |
| 940 |
|
| 941 |
auto* ins = MGuardIsFixedLengthTypedArray::New(alloc(), obj); |
| 942 |
add(ins); |
| 943 |
|
| 944 |
setOperand(objId, ins); |
| 945 |
return true; |
| 946 |
} |
| 947 |
|
| 948 |
bool WarpCacheIRTranspiler::emitGuardIsResizableTypedArray(ObjOperandId objId) { |
| 949 |
MDefinition* obj = getOperand(objId); |
| 950 |
|
| 951 |
auto* ins = MGuardIsResizableTypedArray::New(alloc(), obj); |
| 952 |
add(ins); |
| 953 |
|
| 954 |
setOperand(objId, ins); |
| 955 |
return true; |
| 956 |
} |
| 957 |
|
| 958 |
bool WarpCacheIRTranspiler::emitGuardHasProxyHandler(ObjOperandId objId, |
| 959 |
uint32_t handlerOffset) { |
| 960 |
MDefinition* obj = getOperand(objId); |
| 961 |
const void* handler = rawPointerField(handlerOffset); |
| 962 |
|
| 963 |
auto* ins = MGuardHasProxyHandler::New(alloc(), obj, handler); |
| 964 |
add(ins); |
| 965 |
|
| 966 |
setOperand(objId, ins); |
| 967 |
return true; |
| 968 |
} |
| 969 |
|
| 970 |
bool WarpCacheIRTranspiler::emitGuardProto(ObjOperandId objId, |
| 971 |
uint32_t protoOffset) { |
| 972 |
MDefinition* def = getOperand(objId); |
| 973 |
MDefinition* proto = objectStubField(protoOffset); |
| 974 |
|
| 975 |
auto* ins = MGuardProto::New(alloc(), def, proto); |
| 976 |
add(ins); |
| 977 |
|
| 978 |
setOperand(objId, ins); |
| 979 |
return true; |
| 980 |
} |
| 981 |
|
| 982 |
bool WarpCacheIRTranspiler::emitGuardDynamicSlotIsSpecificObject( |
| 983 |
ObjOperandId objId, ObjOperandId expectedId, uint32_t slotOffset) { |
| 984 |
size_t slotIndex = int32StubField(slotOffset); |
| 985 |
MDefinition* obj = getOperand(objId); |
| 986 |
MDefinition* expected = getOperand(expectedId); |
| 987 |
|
| 988 |
auto* slots = MSlots::New(alloc(), obj); |
| 989 |
add(slots); |
| 990 |
|
| 991 |
auto* load = MLoadDynamicSlot::New(alloc(), slots, slotIndex); |
| 992 |
add(load); |
| 993 |
|
| 994 |
auto* unbox = MUnbox::New(alloc(), load, MIRType::Object, MUnbox::Fallible); |
| 995 |
add(unbox); |
| 996 |
|
| 997 |
auto* guard = MGuardObjectIdentity::New(alloc(), unbox, expected, |
| 998 |
/* bailOnEquality = */ false); |
| 999 |
add(guard); |
| 1000 |
return true; |
| 1001 |
} |
| 1002 |
|
| 1003 |
bool WarpCacheIRTranspiler::emitLoadDynamicSlot(ValOperandId resultId, |
| 1004 |
ObjOperandId objId, |
| 1005 |
uint32_t slotOffset) { |
| 1006 |
size_t slotIndex = int32StubField(slotOffset); |
| 1007 |
MDefinition* obj = getOperand(objId); |
| 1008 |
|
| 1009 |
auto* slots = MSlots::New(alloc(), obj); |
| 1010 |
add(slots); |
| 1011 |
|
| 1012 |
auto* load = MLoadDynamicSlot::New(alloc(), slots, slotIndex); |
| 1013 |
add(load); |
| 1014 |
|
| 1015 |
return defineOperand(resultId, load); |
| 1016 |
} |
| 1017 |
|
| 1018 |
bool WarpCacheIRTranspiler::emitGuardDynamicSlotIsNotObject( |
| 1019 |
ObjOperandId objId, uint32_t slotOffset) { |
| 1020 |
size_t slotIndex = int32StubField(slotOffset); |
| 1021 |
MDefinition* obj = getOperand(objId); |
| 1022 |
|
| 1023 |
auto* slots = MSlots::New(alloc(), obj); |
| 1024 |
add(slots); |
| 1025 |
|
| 1026 |
auto* load = MLoadDynamicSlot::New(alloc(), slots, slotIndex); |
| 1027 |
add(load); |
| 1028 |
|
| 1029 |
auto* guard = MGuardIsNotObject::New(alloc(), load); |
| 1030 |
add(guard); |
| 1031 |
return true; |
| 1032 |
} |
| 1033 |
|
| 1034 |
bool WarpCacheIRTranspiler::emitGuardFixedSlotValue(ObjOperandId objId, |
| 1035 |
uint32_t offsetOffset, |
| 1036 |
uint32_t valOffset) { |
| 1037 |
MDefinition* obj = getOperand(objId); |
| 1038 |
|
| 1039 |
size_t offset = int32StubField(offsetOffset); |
| 1040 |
Value val = valueStubField(valOffset); |
| 1041 |
|
| 1042 |
uint32_t slotIndex = NativeObject::getFixedSlotIndexFromOffset(offset); |
| 1043 |
|
| 1044 |
auto* load = MLoadFixedSlot::New(alloc(), obj, slotIndex); |
| 1045 |
add(load); |
| 1046 |
|
| 1047 |
auto* guard = MGuardValue::New(alloc(), load, val); |
| 1048 |
add(guard); |
| 1049 |
return true; |
| 1050 |
} |
| 1051 |
|
| 1052 |
bool WarpCacheIRTranspiler::emitGuardDynamicSlotValue(ObjOperandId objId, |
| 1053 |
uint32_t offsetOffset, |
| 1054 |
uint32_t valOffset) { |
| 1055 |
MDefinition* obj = getOperand(objId); |
| 1056 |
|
| 1057 |
size_t offset = int32StubField(offsetOffset); |
| 1058 |
Value val = valueStubField(valOffset); |
| 1059 |
|
| 1060 |
size_t slotIndex = NativeObject::getDynamicSlotIndexFromOffset(offset); |
| 1061 |
|
| 1062 |
auto* slots = MSlots::New(alloc(), obj); |
| 1063 |
add(slots); |
| 1064 |
|
| 1065 |
auto* load = MLoadDynamicSlot::New(alloc(), slots, slotIndex); |
| 1066 |
add(load); |
| 1067 |
|
| 1068 |
auto* guard = MGuardValue::New(alloc(), load, val); |
| 1069 |
add(guard); |
| 1070 |
return true; |
| 1071 |
} |
| 1072 |
|
| 1073 |
bool WarpCacheIRTranspiler::emitLoadScriptedProxyHandler(ObjOperandId resultId, |
| 1074 |
ObjOperandId objId) { |
| 1075 |
MDefinition* obj = getOperand(objId); |
| 1076 |
|
| 1077 |
auto* load = MLoadScriptedProxyHandler::New(alloc(), obj); |
| 1078 |
add(load); |
| 1079 |
|
| 1080 |
return defineOperand(resultId, load); |
| 1081 |
} |
| 1082 |
|
| 1083 |
bool WarpCacheIRTranspiler::emitIdToStringOrSymbol(ValOperandId resultId, |
| 1084 |
ValOperandId idId) { |
| 1085 |
MDefinition* id = getOperand(idId); |
| 1086 |
|
| 1087 |
auto* ins = MIdToStringOrSymbol::New(alloc(), id); |
| 1088 |
add(ins); |
| 1089 |
|
| 1090 |
return defineOperand(resultId, ins); |
| 1091 |
} |
| 1092 |
|
| 1093 |
bool WarpCacheIRTranspiler::emitGuardSpecificAtom(StringOperandId strId, |
| 1094 |
uint32_t expectedOffset) { |
| 1095 |
MDefinition* str = getOperand(strId); |
| 1096 |
JSString* expected = stringStubField(expectedOffset); |
| 1097 |
|
| 1098 |
auto* ins = MGuardSpecificAtom::New(alloc(), str, &expected->asAtom()); |
| 1099 |
add(ins); |
| 1100 |
|
| 1101 |
setOperand(strId, ins); |
| 1102 |
return true; |
| 1103 |
} |
| 1104 |
|
| 1105 |
bool WarpCacheIRTranspiler::emitGuardSpecificSymbol(SymbolOperandId symId, |
| 1106 |
uint32_t expectedOffset) { |
| 1107 |
MDefinition* symbol = getOperand(symId); |
| 1108 |
JS::Symbol* expected = symbolStubField(expectedOffset); |
| 1109 |
|
| 1110 |
auto* ins = MGuardSpecificSymbol::New(alloc(), symbol, expected); |
| 1111 |
add(ins); |
| 1112 |
|
| 1113 |
setOperand(symId, ins); |
| 1114 |
return true; |
| 1115 |
} |
| 1116 |
|
| 1117 |
bool WarpCacheIRTranspiler::emitGuardSpecificInt32(Int32OperandId numId, |
| 1118 |
int32_t expected) { |
| 1119 |
MDefinition* num = getOperand(numId); |
| 1120 |
|
| 1121 |
auto* ins = MGuardSpecificInt32::New(alloc(), num, expected); |
| 1122 |
add(ins); |
| 1123 |
|
| 1124 |
setOperand(numId, ins); |
| 1125 |
return true; |
| 1126 |
} |
| 1127 |
|
| 1128 |
bool WarpCacheIRTranspiler::emitGuardSpecificValue(ValOperandId valId, |
| 1129 |
uint32_t expectedOffset) { |
| 1130 |
MDefinition* val = getOperand(valId); |
| 1131 |
Value expected = valueStubField(expectedOffset); |
| 1132 |
|
| 1133 |
auto* ins = MGuardValue::New(alloc(), val, expected); |
| 1134 |
add(ins); |
| 1135 |
|
| 1136 |
setOperand(valId, ins); |
| 1137 |
return true; |
| 1138 |
} |
| 1139 |
|
| 1140 |
bool WarpCacheIRTranspiler::emitGuardSpecificObject(ObjOperandId objId, |
| 1141 |
uint32_t expectedOffset) { |
| 1142 |
MDefinition* obj = getOperand(objId); |
| 1143 |
MDefinition* expected = objectStubField(expectedOffset); |
| 1144 |
|
| 1145 |
auto* ins = MGuardObjectIdentity::New(alloc(), obj, expected, |
| 1146 |
/* bailOnEquality = */ false); |
| 1147 |
add(ins); |
| 1148 |
|
| 1149 |
setOperand(objId, ins); |
| 1150 |
return true; |
| 1151 |
} |
| 1152 |
|
| 1153 |
bool WarpCacheIRTranspiler::emitGuardSpecificFunction( |
| 1154 |
ObjOperandId objId, uint32_t expectedOffset, uint32_t nargsAndFlagsOffset) { |
| 1155 |
MDefinition* obj = getOperand(objId); |
| 1156 |
MDefinition* expected = objectStubField(expectedOffset); |
| 1157 |
uint32_t nargsAndFlags = uint32StubField(nargsAndFlagsOffset); |
| 1158 |
|
| 1159 |
uint16_t nargs = nargsAndFlags >> 16; |
| 1160 |
FunctionFlags flags = FunctionFlags(uint16_t(nargsAndFlags)); |
| 1161 |
|
| 1162 |
auto* ins = MGuardSpecificFunction::New(alloc(), obj, expected, nargs, flags); |
| 1163 |
add(ins); |
| 1164 |
|
| 1165 |
setOperand(objId, ins); |
| 1166 |
return true; |
| 1167 |
} |
| 1168 |
|
| 1169 |
bool WarpCacheIRTranspiler::emitGuardFunctionScript( |
| 1170 |
ObjOperandId funId, uint32_t expectedOffset, uint32_t nargsAndFlagsOffset) { |
| 1171 |
MDefinition* fun = getOperand(funId); |
| 1172 |
BaseScript* expected = baseScriptStubField(expectedOffset); |
| 1173 |
uint32_t nargsAndFlags = uint32StubField(nargsAndFlagsOffset); |
| 1174 |
|
| 1175 |
uint16_t nargs = nargsAndFlags >> 16; |
| 1176 |
FunctionFlags flags = FunctionFlags(uint16_t(nargsAndFlags)); |
| 1177 |
|
| 1178 |
auto* ins = MGuardFunctionScript::New(alloc(), fun, expected, nargs, flags); |
| 1179 |
add(ins); |
| 1180 |
|
| 1181 |
setOperand(funId, ins); |
| 1182 |
return true; |
| 1183 |
} |
| 1184 |
|
| 1185 |
bool WarpCacheIRTranspiler::emitGuardStringToIndex(StringOperandId strId, |
| 1186 |
Int32OperandId resultId) { |
| 1187 |
MDefinition* str = getOperand(strId); |
| 1188 |
|
| 1189 |
auto* ins = MGuardStringToIndex::New(alloc(), str); |
| 1190 |
add(ins); |
| 1191 |
|
| 1192 |
return defineOperand(resultId, ins); |
| 1193 |
} |
| 1194 |
|
| 1195 |
bool WarpCacheIRTranspiler::emitGuardStringToInt32(StringOperandId strId, |
| 1196 |
Int32OperandId resultId) { |
| 1197 |
MDefinition* str = getOperand(strId); |
| 1198 |
|
| 1199 |
auto* ins = MGuardStringToInt32::New(alloc(), str); |
| 1200 |
add(ins); |
| 1201 |
|
| 1202 |
return defineOperand(resultId, ins); |
| 1203 |
} |
| 1204 |
|
| 1205 |
bool WarpCacheIRTranspiler::emitGuardStringToNumber(StringOperandId strId, |
| 1206 |
NumberOperandId resultId) { |
| 1207 |
MDefinition* str = getOperand(strId); |
| 1208 |
|
| 1209 |
auto* ins = MGuardStringToDouble::New(alloc(), str); |
| 1210 |
add(ins); |
| 1211 |
|
| 1212 |
return defineOperand(resultId, ins); |
| 1213 |
} |
| 1214 |
|
| 1215 |
bool WarpCacheIRTranspiler::emitGuardNoDenseElements(ObjOperandId objId) { |
| 1216 |
MDefinition* obj = getOperand(objId); |
| 1217 |
|
| 1218 |
auto* ins = MGuardNoDenseElements::New(alloc(), obj); |
| 1219 |
add(ins); |
| 1220 |
|
| 1221 |
setOperand(objId, ins); |
| 1222 |
return true; |
| 1223 |
} |
| 1224 |
|
| 1225 |
bool WarpCacheIRTranspiler::emitGuardFunctionHasJitEntry(ObjOperandId funId) { |
| 1226 |
MDefinition* fun = getOperand(funId); |
| 1227 |
uint16_t expectedFlags = FunctionFlags::HasJitEntryFlags(); |
| 1228 |
uint16_t unexpectedFlags = 0; |
| 1229 |
|
| 1230 |
auto* ins = |
| 1231 |
MGuardFunctionFlags::New(alloc(), fun, expectedFlags, unexpectedFlags); |
| 1232 |
add(ins); |
| 1233 |
|
| 1234 |
setOperand(funId, ins); |
| 1235 |
return true; |
| 1236 |
} |
| 1237 |
|
| 1238 |
bool WarpCacheIRTranspiler::emitGuardFunctionHasNoJitEntry(ObjOperandId funId) { |
| 1239 |
MDefinition* fun = getOperand(funId); |
| 1240 |
uint16_t expectedFlags = 0; |
| 1241 |
uint16_t unexpectedFlags = FunctionFlags::HasJitEntryFlags(); |
| 1242 |
|
| 1243 |
auto* ins = |
| 1244 |
MGuardFunctionFlags::New(alloc(), fun, expectedFlags, unexpectedFlags); |
| 1245 |
add(ins); |
| 1246 |
|
| 1247 |
setOperand(funId, ins); |
| 1248 |
return true; |
| 1249 |
} |
| 1250 |
|
| 1251 |
bool WarpCacheIRTranspiler::emitGuardFunctionIsNonBuiltinCtor( |
| 1252 |
ObjOperandId funId) { |
| 1253 |
MDefinition* fun = getOperand(funId); |
| 1254 |
|
| 1255 |
auto* ins = MGuardFunctionIsNonBuiltinCtor::New(alloc(), fun); |
| 1256 |
add(ins); |
| 1257 |
|
| 1258 |
setOperand(funId, ins); |
| 1259 |
return true; |
| 1260 |
} |
| 1261 |
|
| 1262 |
bool WarpCacheIRTranspiler::emitGuardFunctionIsConstructor(ObjOperandId funId) { |
| 1263 |
MDefinition* fun = getOperand(funId); |
| 1264 |
uint16_t expectedFlags = FunctionFlags::CONSTRUCTOR; |
| 1265 |
uint16_t unexpectedFlags = 0; |
| 1266 |
|
| 1267 |
auto* ins = |
| 1268 |
MGuardFunctionFlags::New(alloc(), fun, expectedFlags, unexpectedFlags); |
| 1269 |
add(ins); |
| 1270 |
|
| 1271 |
setOperand(funId, ins); |
| 1272 |
return true; |
| 1273 |
} |
| 1274 |
|
| 1275 |
bool WarpCacheIRTranspiler::emitGuardNotClassConstructor(ObjOperandId funId) { |
| 1276 |
MDefinition* fun = getOperand(funId); |
| 1277 |
|
| 1278 |
auto* ins = |
| 1279 |
MGuardFunctionKind::New(alloc(), fun, FunctionFlags::ClassConstructor, |
| 1280 |
/*bailOnEquality=*/true); |
| 1281 |
add(ins); |
| 1282 |
|
| 1283 |
setOperand(funId, ins); |
| 1284 |
return true; |
| 1285 |
} |
| 1286 |
|
| 1287 |
bool WarpCacheIRTranspiler::emitGuardArrayIsPacked(ObjOperandId arrayId) { |
| 1288 |
MDefinition* array = getOperand(arrayId); |
| 1289 |
|
| 1290 |
auto* ins = MGuardArrayIsPacked::New(alloc(), array); |
| 1291 |
add(ins); |
| 1292 |
|
| 1293 |
setOperand(arrayId, ins); |
| 1294 |
return true; |
| 1295 |
} |
| 1296 |
|
| 1297 |
bool WarpCacheIRTranspiler::emitGuardArgumentsObjectFlags(ObjOperandId objId, |
| 1298 |
uint8_t flags) { |
| 1299 |
MDefinition* obj = getOperand(objId); |
| 1300 |
|
| 1301 |
auto* ins = MGuardArgumentsObjectFlags::New(alloc(), obj, flags); |
| 1302 |
add(ins); |
| 1303 |
|
| 1304 |
setOperand(objId, ins); |
| 1305 |
return true; |
| 1306 |
} |
| 1307 |
|
| 1308 |
bool WarpCacheIRTranspiler::emitGuardObjectHasSameRealm(ObjOperandId objId) { |
| 1309 |
MDefinition* obj = getOperand(objId); |
| 1310 |
|
| 1311 |
auto* ins = MGuardObjectHasSameRealm::New(alloc(), obj); |
| 1312 |
add(ins); |
| 1313 |
|
| 1314 |
setOperand(objId, ins); |
| 1315 |
return true; |
| 1316 |
} |
| 1317 |
|
| 1318 |
bool WarpCacheIRTranspiler::emitGuardNonDoubleType(ValOperandId inputId, |
| 1319 |
ValueType type) { |
| 1320 |
switch (type) { |
| 1321 |
case ValueType::String: |
| 1322 |
case ValueType::Symbol: |
| 1323 |
case ValueType::BigInt: |
| 1324 |
case ValueType::Int32: |
| 1325 |
case ValueType::Boolean: |
| 1326 |
return emitGuardTo(inputId, MIRTypeFromValueType(JSValueType(type))); |
| 1327 |
case ValueType::Undefined: |
| 1328 |
return emitGuardIsUndefined(inputId); |
| 1329 |
case ValueType::Null: |
| 1330 |
return emitGuardIsNull(inputId); |
| 1331 |
case ValueType::Double: |
| 1332 |
case ValueType::Magic: |
| 1333 |
case ValueType::PrivateGCThing: |
| 1334 |
case ValueType::Object: |
| 1335 |
break; |
| 1336 |
} |
| 1337 |
|
| 1338 |
MOZ_CRASH("unexpected type"); |
| 1339 |
} |
| 1340 |
|
| 1341 |
bool WarpCacheIRTranspiler::emitGuardTo(ValOperandId inputId, MIRType type) { |
| 1342 |
MDefinition* def = getOperand(inputId); |
| 1343 |
if (def->type() == type) { |
| 1344 |
return true; |
| 1345 |
} |
| 1346 |
|
| 1347 |
auto* ins = MUnbox::New(alloc(), def, type, MUnbox::Fallible); |
| 1348 |
add(ins); |
| 1349 |
|
| 1350 |
setOperand(inputId, ins); |
| 1351 |
return true; |
| 1352 |
} |
| 1353 |
|
| 1354 |
bool WarpCacheIRTranspiler::emitGuardToObject(ValOperandId inputId) { |
| 1355 |
return emitGuardTo(inputId, MIRType::Object); |
| 1356 |
} |
| 1357 |
|
| 1358 |
bool WarpCacheIRTranspiler::emitGuardToString(ValOperandId inputId) { |
| 1359 |
return emitGuardTo(inputId, MIRType::String); |
| 1360 |
} |
| 1361 |
|
| 1362 |
bool WarpCacheIRTranspiler::emitGuardToSymbol(ValOperandId inputId) { |
| 1363 |
return emitGuardTo(inputId, MIRType::Symbol); |
| 1364 |
} |
| 1365 |
|
| 1366 |
bool WarpCacheIRTranspiler::emitGuardToBigInt(ValOperandId inputId) { |
| 1367 |
return emitGuardTo(inputId, MIRType::BigInt); |
| 1368 |
} |
| 1369 |
|
| 1370 |
bool WarpCacheIRTranspiler::emitGuardToBoolean(ValOperandId inputId) { |
| 1371 |
return emitGuardTo(inputId, MIRType::Boolean); |
| 1372 |
} |
| 1373 |
|
| 1374 |
bool WarpCacheIRTranspiler::emitGuardToInt32(ValOperandId inputId) { |
| 1375 |
return emitGuardTo(inputId, MIRType::Int32); |
| 1376 |
} |
| 1377 |
|
| 1378 |
bool WarpCacheIRTranspiler::emitGuardBooleanToInt32(ValOperandId inputId, |
| 1379 |
Int32OperandId resultId) { |
| 1380 |
if (!emitGuardTo(inputId, MIRType::Boolean)) { |
| 1381 |
return false; |
| 1382 |
} |
| 1383 |
|
| 1384 |
MDefinition* input = getOperand(inputId); |
| 1385 |
MOZ_ASSERT(input->type() == MIRType::Boolean); |
| 1386 |
|
| 1387 |
auto* ins = MBooleanToInt32::New(alloc(), input); |
| 1388 |
add(ins); |
| 1389 |
|
| 1390 |
return defineOperand(resultId, ins); |
| 1391 |
} |
| 1392 |
|
| 1393 |
bool WarpCacheIRTranspiler::emitGuardIsNumber(ValOperandId inputId) { |
| 1394 |
MDefinition* def = getOperand(inputId); |
| 1395 |
|
| 1396 |
// No guard needed when the input is already a number type. |
| 1397 |
if (IsNumberType(def->type())) { |
| 1398 |
return true; |
| 1399 |
} |
| 1400 |
|
| 1401 |
// MIRType::Double also implies int32 in Ion. |
| 1402 |
return emitGuardTo(inputId, MIRType::Double); |
| 1403 |
} |
| 1404 |
|
| 1405 |
bool WarpCacheIRTranspiler::emitGuardIsNullOrUndefined(ValOperandId inputId) { |
| 1406 |
MDefinition* input = getOperand(inputId); |
| 1407 |
if (input->type() == MIRType::Null || input->type() == MIRType::Undefined) { |
| 1408 |
return true; |
| 1409 |
} |
| 1410 |
|
| 1411 |
auto* ins = MGuardNullOrUndefined::New(alloc(), input); |
| 1412 |
add(ins); |
| 1413 |
|
| 1414 |
setOperand(inputId, ins); |
| 1415 |
return true; |
| 1416 |
} |
| 1417 |
|
| 1418 |
bool WarpCacheIRTranspiler::emitGuardIsNull(ValOperandId inputId) { |
| 1419 |
MDefinition* input = getOperand(inputId); |
| 1420 |
if (input->type() == MIRType::Null) { |
| 1421 |
return true; |
| 1422 |
} |
| 1423 |
|
| 1424 |
auto* ins = MGuardValue::New(alloc(), input, NullValue()); |
| 1425 |
add(ins); |
| 1426 |
setOperand(inputId, ins); |
| 1427 |
return true; |
| 1428 |
} |
| 1429 |
|
| 1430 |
bool WarpCacheIRTranspiler::emitGuardIsUndefined(ValOperandId inputId) { |
| 1431 |
MDefinition* input = getOperand(inputId); |
| 1432 |
if (input->type() == MIRType::Undefined) { |
| 1433 |
return true; |
| 1434 |
} |
| 1435 |
|
| 1436 |
auto* ins = MGuardValue::New(alloc(), input, UndefinedValue()); |
| 1437 |
add(ins); |
| 1438 |
setOperand(inputId, ins); |
| 1439 |
return true; |
| 1440 |
} |
| 1441 |
|
| 1442 |
bool WarpCacheIRTranspiler::emitGuardIsExtensible(ObjOperandId objId) { |
| 1443 |
MDefinition* obj = getOperand(objId); |
| 1444 |
|
| 1445 |
auto* ins = MGuardIsExtensible::New(alloc(), obj); |
| 1446 |
add(ins); |
| 1447 |
setOperand(objId, ins); |
| 1448 |
return true; |
| 1449 |
} |
| 1450 |
|
| 1451 |
bool WarpCacheIRTranspiler::emitGuardInt32IsNonNegative( |
| 1452 |
Int32OperandId indexId) { |
| 1453 |
MDefinition* index = getOperand(indexId); |
| 1454 |
|
| 1455 |
auto* ins = MGuardInt32IsNonNegative::New(alloc(), index); |
| 1456 |
add(ins); |
| 1457 |
setOperand(indexId, ins); |
| 1458 |
return true; |
| 1459 |
} |
| 1460 |
|
| 1461 |
bool WarpCacheIRTranspiler::emitGuardIndexIsNotDenseElement( |
| 1462 |
ObjOperandId objId, Int32OperandId indexId) { |
| 1463 |
MDefinition* obj = getOperand(objId); |
| 1464 |
MDefinition* index = getOperand(indexId); |
| 1465 |
|
| 1466 |
auto* ins = MGuardIndexIsNotDenseElement::New(alloc(), obj, index); |
| 1467 |
add(ins); |
| 1468 |
setOperand(indexId, ins); |
| 1469 |
return true; |
| 1470 |
} |
| 1471 |
|
| 1472 |
bool WarpCacheIRTranspiler::emitGuardIndexIsValidUpdateOrAdd( |
| 1473 |
ObjOperandId objId, Int32OperandId indexId) { |
| 1474 |
MDefinition* obj = getOperand(objId); |
| 1475 |
MDefinition* index = getOperand(indexId); |
| 1476 |
|
| 1477 |
auto* ins = MGuardIndexIsValidUpdateOrAdd::New(alloc(), obj, index); |
| 1478 |
add(ins); |
| 1479 |
setOperand(indexId, ins); |
| 1480 |
return true; |
| 1481 |
} |
| 1482 |
|
| 1483 |
bool WarpCacheIRTranspiler::emitCallAddOrUpdateSparseElementHelper( |
| 1484 |
ObjOperandId objId, Int32OperandId idId, ValOperandId rhsId, bool strict) { |
| 1485 |
MDefinition* obj = getOperand(objId); |
| 1486 |
MDefinition* id = getOperand(idId); |
| 1487 |
MDefinition* rhs = getOperand(rhsId); |
| 1488 |
|
| 1489 |
auto* ins = MCallAddOrUpdateSparseElement::New(alloc(), obj, id, rhs, strict); |
| 1490 |
addEffectful(ins); |
| 1491 |
|
| 1492 |
return resumeAfter(ins); |
| 1493 |
} |
| 1494 |
|
| 1495 |
bool WarpCacheIRTranspiler::emitGuardTagNotEqual(ValueTagOperandId lhsId, |
| 1496 |
ValueTagOperandId rhsId) { |
| 1497 |
MDefinition* lhs = getOperand(lhsId); |
| 1498 |
MDefinition* rhs = getOperand(rhsId); |
| 1499 |
|
| 1500 |
auto* ins = MGuardTagNotEqual::New(alloc(), lhs, rhs); |
| 1501 |
add(ins); |
| 1502 |
|
| 1503 |
return true; |
| 1504 |
} |
| 1505 |
|
| 1506 |
bool WarpCacheIRTranspiler::emitGuardToInt32Index(ValOperandId inputId, |
| 1507 |
Int32OperandId resultId) { |
| 1508 |
MDefinition* input = getOperand(inputId); |
| 1509 |
auto* ins = |
| 1510 |
MToNumberInt32::New(alloc(), input, IntConversionInputKind::NumbersOnly); |
| 1511 |
|
| 1512 |
// ToPropertyKey(-0) is "0", so we can silently convert -0 to 0 here. |
| 1513 |
ins->setNeedsNegativeZeroCheck(false); |
| 1514 |
add(ins); |
| 1515 |
|
| 1516 |
return defineOperand(resultId, ins); |
| 1517 |
} |
| 1518 |
|
| 1519 |
bool WarpCacheIRTranspiler::emitTruncateDoubleToUInt32( |
| 1520 |
NumberOperandId inputId, Int32OperandId resultId) { |
| 1521 |
MDefinition* input = getOperand(inputId); |
| 1522 |
auto* ins = MTruncateToInt32::New(alloc(), input); |
| 1523 |
add(ins); |
| 1524 |
|
| 1525 |
return defineOperand(resultId, ins); |
| 1526 |
} |
| 1527 |
|
| 1528 |
bool WarpCacheIRTranspiler::emitDoubleToUint8Clamped(NumberOperandId inputId, |
| 1529 |
Int32OperandId resultId) { |
| 1530 |
MDefinition* input = getOperand(inputId); |
| 1531 |
auto* ins = MClampToUint8::New(alloc(), input); |
| 1532 |
add(ins); |
| 1533 |
|
| 1534 |
return defineOperand(resultId, ins); |
| 1535 |
} |
| 1536 |
|
| 1537 |
bool WarpCacheIRTranspiler::emitGuardToInt32ModUint32(ValOperandId valId, |
| 1538 |
Int32OperandId resultId) { |
| 1539 |
MDefinition* input = getOperand(valId); |
| 1540 |
auto* ins = MTruncateToInt32::New(alloc(), input); |
| 1541 |
add(ins); |
| 1542 |
|
| 1543 |
return defineOperand(resultId, ins); |
| 1544 |
} |
| 1545 |
|
| 1546 |
bool WarpCacheIRTranspiler::emitGuardToUint8Clamped(ValOperandId valId, |
| 1547 |
Int32OperandId resultId) { |
| 1548 |
MDefinition* input = getOperand(valId); |
| 1549 |
auto* ins = MClampToUint8::New(alloc(), input); |
| 1550 |
add(ins); |
| 1551 |
|
| 1552 |
return defineOperand(resultId, ins); |
| 1553 |
} |
| 1554 |
|
| 1555 |
bool WarpCacheIRTranspiler::emitToString(OperandId inputId, |
| 1556 |
StringOperandId resultId) { |
| 1557 |
MDefinition* input = getOperand(inputId); |
| 1558 |
auto* ins = |
| 1559 |
MToString::New(alloc(), input, MToString::SideEffectHandling::Bailout); |
| 1560 |
add(ins); |
| 1561 |
|
| 1562 |
return defineOperand(resultId, ins); |
| 1563 |
} |
| 1564 |
|
| 1565 |
bool WarpCacheIRTranspiler::emitInt32ToIntPtr(Int32OperandId inputId, |
| 1566 |
IntPtrOperandId resultId) { |
| 1567 |
MDefinition* input = getOperand(inputId); |
| 1568 |
auto* ins = MInt32ToIntPtr::New(alloc(), input); |
| 1569 |
add(ins); |
| 1570 |
return defineOperand(resultId, ins); |
| 1571 |
} |
| 1572 |
|
| 1573 |
bool WarpCacheIRTranspiler::emitGuardNumberToIntPtrIndex( |
| 1574 |
NumberOperandId inputId, bool supportOOB, IntPtrOperandId resultId) { |
| 1575 |
MDefinition* input = getOperand(inputId); |
| 1576 |
auto* ins = MGuardNumberToIntPtrIndex::New(alloc(), input, supportOOB); |
| 1577 |
add(ins); |
| 1578 |
return defineOperand(resultId, ins); |
| 1579 |
} |
| 1580 |
|
| 1581 |
bool WarpCacheIRTranspiler::emitCallInt32ToString(Int32OperandId inputId, |
| 1582 |
StringOperandId resultId) { |
| 1583 |
return emitToString(inputId, resultId); |
| 1584 |
} |
| 1585 |
|
| 1586 |
bool WarpCacheIRTranspiler::emitCallNumberToString(NumberOperandId inputId, |
| 1587 |
StringOperandId resultId) { |
| 1588 |
return emitToString(inputId, resultId); |
| 1589 |
} |
| 1590 |
|
| 1591 |
bool WarpCacheIRTranspiler::emitInt32ToStringWithBaseResult( |
| 1592 |
Int32OperandId inputId, Int32OperandId baseId) { |
| 1593 |
MDefinition* input = getOperand(inputId); |
| 1594 |
MDefinition* base = getOperand(baseId); |
| 1595 |
|
| 1596 |
auto* guardedBase = MGuardInt32Range::New(alloc(), base, 2, 36); |
| 1597 |
add(guardedBase); |
| 1598 |
|
| 1599 |
// Use lower-case characters by default. |
| 1600 |
constexpr bool lower = true; |
| 1601 |
|
| 1602 |
auto* ins = MInt32ToStringWithBase::New(alloc(), input, guardedBase, lower); |
| 1603 |
add(ins); |
| 1604 |
|
| 1605 |
pushResult(ins); |
| 1606 |
return true; |
| 1607 |
} |
| 1608 |
|
| 1609 |
bool WarpCacheIRTranspiler::emitBooleanToString(BooleanOperandId inputId, |
| 1610 |
StringOperandId resultId) { |
| 1611 |
return emitToString(inputId, resultId); |
| 1612 |
} |
| 1613 |
|
| 1614 |
bool WarpCacheIRTranspiler::emitBooleanToNumber(BooleanOperandId inputId, |
| 1615 |
NumberOperandId resultId) { |
| 1616 |
MDefinition* input = getOperand(inputId); |
| 1617 |
|
| 1618 |
auto* ins = MToDouble::New(alloc(), input); |
| 1619 |
add(ins); |
| 1620 |
|
| 1621 |
return defineOperand(resultId, ins); |
| 1622 |
} |
| 1623 |
|
| 1624 |
bool WarpCacheIRTranspiler::emitStringToAtom(StringOperandId strId) { |
| 1625 |
MDefinition* str = getOperand(strId); |
| 1626 |
|
| 1627 |
auto* ins = MToHashableString::New(alloc(), str); |
| 1628 |
add(ins); |
| 1629 |
|
| 1630 |
setOperand(strId, ins); |
| 1631 |
return true; |
| 1632 |
} |
| 1633 |
|
| 1634 |
bool WarpCacheIRTranspiler::emitLoadInt32Result(Int32OperandId valId) { |
| 1635 |
MDefinition* val = getOperand(valId); |
| 1636 |
MOZ_ASSERT(val->type() == MIRType::Int32); |
| 1637 |
pushResult(val); |
| 1638 |
return true; |
| 1639 |
} |
| 1640 |
|
| 1641 |
bool WarpCacheIRTranspiler::emitLoadDoubleResult(NumberOperandId valId) { |
| 1642 |
MDefinition* val = getOperand(valId); |
| 1643 |
MOZ_ASSERT(IsNumberType(val->type())); |
| 1644 |
|
| 1645 |
if (val->type() != MIRType::Double) { |
| 1646 |
auto* ins = MToDouble::New(alloc(), val); |
| 1647 |
add(ins); |
| 1648 |
|
| 1649 |
val = ins; |
| 1650 |
} |
| 1651 |
|
| 1652 |
pushResult(val); |
| 1653 |
return true; |
| 1654 |
} |
| 1655 |
|
| 1656 |
bool WarpCacheIRTranspiler::emitLoadBigIntResult(BigIntOperandId valId) { |
| 1657 |
MDefinition* val = getOperand(valId); |
| 1658 |
MOZ_ASSERT(val->type() == MIRType::BigInt); |
| 1659 |
pushResult(val); |
| 1660 |
return true; |
| 1661 |
} |
| 1662 |
|
| 1663 |
bool WarpCacheIRTranspiler::emitLoadObjectResult(ObjOperandId objId) { |
| 1664 |
MDefinition* obj = getOperand(objId); |
| 1665 |
MOZ_ASSERT(obj->type() == MIRType::Object); |
| 1666 |
pushResult(obj); |
| 1667 |
return true; |
| 1668 |
} |
| 1669 |
|
| 1670 |
bool WarpCacheIRTranspiler::emitLoadStringResult(StringOperandId strId) { |
| 1671 |
MDefinition* str = getOperand(strId); |
| 1672 |
MOZ_ASSERT(str->type() == MIRType::String); |
| 1673 |
pushResult(str); |
| 1674 |
return true; |
| 1675 |
} |
| 1676 |
|
| 1677 |
bool WarpCacheIRTranspiler::emitLoadSymbolResult(SymbolOperandId symId) { |
| 1678 |
MDefinition* sym = getOperand(symId); |
| 1679 |
MOZ_ASSERT(sym->type() == MIRType::Symbol); |
| 1680 |
pushResult(sym); |
| 1681 |
return true; |
| 1682 |
} |
| 1683 |
|
| 1684 |
bool WarpCacheIRTranspiler::emitLoadUndefinedResult() { |
| 1685 |
pushResult(constant(UndefinedValue())); |
| 1686 |
return true; |
| 1687 |
} |
| 1688 |
|
| 1689 |
bool WarpCacheIRTranspiler::emitLoadBooleanResult(bool val) { |
| 1690 |
pushResult(constant(BooleanValue(val))); |
| 1691 |
return true; |
| 1692 |
} |
| 1693 |
|
| 1694 |
bool WarpCacheIRTranspiler::emitLoadInt32Constant(uint32_t valOffset, |
| 1695 |
Int32OperandId resultId) { |
| 1696 |
int32_t val = int32StubField(valOffset); |
| 1697 |
auto* valConst = constant(Int32Value(val)); |
| 1698 |
return defineOperand(resultId, valConst); |
| 1699 |
} |
| 1700 |
|
| 1701 |
bool WarpCacheIRTranspiler::emitLoadDoubleConstant(uint32_t valOffset, |
| 1702 |
NumberOperandId resultId) { |
| 1703 |
double val = doubleStubField(valOffset); |
| 1704 |
auto* valConst = constant(DoubleValue(val)); |
| 1705 |
return defineOperand(resultId, valConst); |
| 1706 |
} |
| 1707 |
|
| 1708 |
bool WarpCacheIRTranspiler::emitLoadBooleanConstant(bool val, |
| 1709 |
BooleanOperandId resultId) { |
| 1710 |
auto* valConst = constant(BooleanValue(val)); |
| 1711 |
return defineOperand(resultId, valConst); |
| 1712 |
} |
| 1713 |
|
| 1714 |
bool WarpCacheIRTranspiler::emitLoadUndefined(ValOperandId resultId) { |
| 1715 |
auto* valConst = constant(UndefinedValue()); |
| 1716 |
return defineOperand(resultId, valConst); |
| 1717 |
} |
| 1718 |
|
| 1719 |
bool WarpCacheIRTranspiler::emitLoadConstantString(uint32_t strOffset, |
| 1720 |
StringOperandId resultId) { |
| 1721 |
JSString* val = stringStubField(strOffset); |
| 1722 |
auto* valConst = constant(StringValue(val)); |
| 1723 |
return defineOperand(resultId, valConst); |
| 1724 |
} |
| 1725 |
|
| 1726 |
bool WarpCacheIRTranspiler::emitLoadConstantStringResult(uint32_t strOffset) { |
| 1727 |
JSString* val = stringStubField(strOffset); |
| 1728 |
auto* valConst = constant(StringValue(val)); |
| 1729 |
pushResult(valConst); |
| 1730 |
return true; |
| 1731 |
} |
| 1732 |
|
| 1733 |
bool WarpCacheIRTranspiler::emitLoadTypeOfObjectResult(ObjOperandId objId) { |
| 1734 |
MDefinition* obj = getOperand(objId); |
| 1735 |
auto* typeOf = MTypeOf::New(alloc(), obj); |
| 1736 |
add(typeOf); |
| 1737 |
|
| 1738 |
auto* ins = MTypeOfName::New(alloc(), typeOf); |
| 1739 |
add(ins); |
| 1740 |
pushResult(ins); |
| 1741 |
return true; |
| 1742 |
} |
| 1743 |
|
| 1744 |
bool WarpCacheIRTranspiler::emitLoadTypeOfEqObjectResult( |
| 1745 |
ObjOperandId objId, TypeofEqOperand operand) { |
| 1746 |
MDefinition* obj = getOperand(objId); |
| 1747 |
auto* typeOf = MTypeOf::New(alloc(), obj); |
| 1748 |
add(typeOf); |
| 1749 |
|
| 1750 |
auto* typeInt = MConstant::New(alloc(), Int32Value(operand.type())); |
| 1751 |
add(typeInt); |
| 1752 |
|
| 1753 |
auto* ins = MCompare::New(alloc(), typeOf, typeInt, operand.compareOp(), |
| 1754 |
MCompare::Compare_Int32); |
| 1755 |
add(ins); |
| 1756 |
pushResult(ins); |
| 1757 |
return true; |
| 1758 |
} |
| 1759 |
|
| 1760 |
bool WarpCacheIRTranspiler::emitLoadEnclosingEnvironment( |
| 1761 |
ObjOperandId objId, ObjOperandId resultId) { |
| 1762 |
MDefinition* env = getOperand(objId); |
| 1763 |
auto* ins = MEnclosingEnvironment::New(alloc(), env); |
| 1764 |
add(ins); |
| 1765 |
|
| 1766 |
return defineOperand(resultId, ins); |
| 1767 |
} |
| 1768 |
|
| 1769 |
bool WarpCacheIRTranspiler::emitLoadObject(ObjOperandId resultId, |
| 1770 |
uint32_t objOffset) { |
| 1771 |
MInstruction* ins = objectStubField(objOffset); |
| 1772 |
|
| 1773 |
return defineOperand(resultId, ins); |
| 1774 |
} |
| 1775 |
|
| 1776 |
bool WarpCacheIRTranspiler::emitLoadProtoObject(ObjOperandId resultId, |
| 1777 |
uint32_t objOffset, |
| 1778 |
ObjOperandId receiverObjId) { |
| 1779 |
MInstruction* ins = objectStubField(objOffset); |
| 1780 |
if (ins->isConstant()) { |
| 1781 |
MDefinition* receiverObj = getOperand(receiverObjId); |
| 1782 |
|
| 1783 |
ins = MConstantProto::New(alloc(), ins, receiverObj->skipObjectGuards()); |
| 1784 |
add(ins); |
| 1785 |
} |
| 1786 |
return defineOperand(resultId, ins); |
| 1787 |
} |
| 1788 |
|
| 1789 |
bool WarpCacheIRTranspiler::emitLoadProto(ObjOperandId objId, |
| 1790 |
ObjOperandId resultId) { |
| 1791 |
MDefinition* obj = getOperand(objId); |
| 1792 |
|
| 1793 |
auto* ins = MObjectStaticProto::New(alloc(), obj); |
| 1794 |
add(ins); |
| 1795 |
|
| 1796 |
return defineOperand(resultId, ins); |
| 1797 |
} |
| 1798 |
|
| 1799 |
bool WarpCacheIRTranspiler::emitLoadInstanceOfObjectResult( |
| 1800 |
ValOperandId lhsId, ObjOperandId protoId) { |
| 1801 |
MDefinition* lhs = getOperand(lhsId); |
| 1802 |
MDefinition* proto = getOperand(protoId); |
| 1803 |
|
| 1804 |
auto* instanceOf = MInstanceOf::New(alloc(), lhs, proto); |
| 1805 |
addEffectful(instanceOf); |
| 1806 |
|
| 1807 |
pushResult(instanceOf); |
| 1808 |
return resumeAfter(instanceOf); |
| 1809 |
} |
| 1810 |
|
| 1811 |
bool WarpCacheIRTranspiler::emitLoadValueTag(ValOperandId valId, |
| 1812 |
ValueTagOperandId resultId) { |
| 1813 |
MDefinition* val = getOperand(valId); |
| 1814 |
|
| 1815 |
auto* ins = MLoadValueTag::New(alloc(), val); |
| 1816 |
add(ins); |
| 1817 |
|
| 1818 |
return defineOperand(resultId, ins); |
| 1819 |
} |
| 1820 |
|
| 1821 |
bool WarpCacheIRTranspiler::emitLoadDynamicSlotResult(ObjOperandId objId, |
| 1822 |
uint32_t offsetOffset) { |
| 1823 |
int32_t offset = int32StubField(offsetOffset); |
| 1824 |
|
| 1825 |
MDefinition* obj = getOperand(objId); |
| 1826 |
size_t slotIndex = NativeObject::getDynamicSlotIndexFromOffset(offset); |
| 1827 |
|
| 1828 |
auto* slots = MSlots::New(alloc(), obj); |
| 1829 |
add(slots); |
| 1830 |
|
| 1831 |
auto* load = MLoadDynamicSlot::New(alloc(), slots, slotIndex); |
| 1832 |
add(load); |
| 1833 |
|
| 1834 |
pushResult(load); |
| 1835 |
return true; |
| 1836 |
} |
| 1837 |
|
| 1838 |
bool WarpCacheIRTranspiler::emitLoadFixedSlot(ValOperandId resultId, |
| 1839 |
ObjOperandId objId, |
| 1840 |
uint32_t offsetOffset) { |
| 1841 |
MDefinition* obj = getOperand(objId); |
| 1842 |
|
| 1843 |
size_t offset = int32StubField(offsetOffset); |
| 1844 |
uint32_t slotIndex = NativeObject::getFixedSlotIndexFromOffset(offset); |
| 1845 |
|
| 1846 |
auto* load = MLoadFixedSlot::New(alloc(), obj, slotIndex); |
| 1847 |
add(load); |
| 1848 |
|
| 1849 |
return defineOperand(resultId, load); |
| 1850 |
} |
| 1851 |
|
| 1852 |
bool WarpCacheIRTranspiler::emitLoadFixedSlotResult(ObjOperandId objId, |
| 1853 |
uint32_t offsetOffset) { |
| 1854 |
int32_t offset = int32StubField(offsetOffset); |
| 1855 |
|
| 1856 |
MDefinition* obj = getOperand(objId); |
| 1857 |
uint32_t slotIndex = NativeObject::getFixedSlotIndexFromOffset(offset); |
| 1858 |
|
| 1859 |
auto* load = MLoadFixedSlot::New(alloc(), obj, slotIndex); |
| 1860 |
add(load); |
| 1861 |
|
| 1862 |
pushResult(load); |
| 1863 |
return true; |
| 1864 |
} |
| 1865 |
|
| 1866 |
bool WarpCacheIRTranspiler::emitLoadFixedSlotTypedResult(ObjOperandId objId, |
| 1867 |
uint32_t offsetOffset, |
| 1868 |
ValueType type) { |
| 1869 |
int32_t offset = int32StubField(offsetOffset); |
| 1870 |
|
| 1871 |
MDefinition* obj = getOperand(objId); |
| 1872 |
uint32_t slotIndex = NativeObject::getFixedSlotIndexFromOffset(offset); |
| 1873 |
|
| 1874 |
auto* load = MLoadFixedSlot::New(alloc(), obj, slotIndex); |
| 1875 |
load->setResultType(MIRTypeFromValueType(JSValueType(type))); |
| 1876 |
add(load); |
| 1877 |
|
| 1878 |
pushResult(load); |
| 1879 |
return true; |
| 1880 |
} |
| 1881 |
|
| 1882 |
bool WarpCacheIRTranspiler::emitGuardIsNotUninitializedLexical( |
| 1883 |
ValOperandId valId) { |
| 1884 |
MDefinition* val = getOperand(valId); |
| 1885 |
|
| 1886 |
auto* lexicalCheck = MLexicalCheck::New(alloc(), val); |
| 1887 |
add(lexicalCheck); |
| 1888 |
|
| 1889 |
if (snapshot().bailoutInfo().failedLexicalCheck()) { |
| 1890 |
lexicalCheck->setNotMovable(); |
| 1891 |
} |
| 1892 |
|
| 1893 |
setOperand(valId, lexicalCheck); |
| 1894 |
return true; |
| 1895 |
} |
| 1896 |
|
| 1897 |
bool WarpCacheIRTranspiler::emitLoadInt32ArrayLengthResult(ObjOperandId objId) { |
| 1898 |
MDefinition* obj = getOperand(objId); |
| 1899 |
|
| 1900 |
auto* elements = MElements::New(alloc(), obj); |
| 1901 |
add(elements); |
| 1902 |
|
| 1903 |
auto* length = MArrayLength::New(alloc(), elements); |
| 1904 |
add(length); |
| 1905 |
|
| 1906 |
pushResult(length); |
| 1907 |
return true; |
| 1908 |
} |
| 1909 |
|
| 1910 |
bool WarpCacheIRTranspiler::emitLoadInt32ArrayLength(ObjOperandId objId, |
| 1911 |
Int32OperandId resultId) { |
| 1912 |
MDefinition* obj = getOperand(objId); |
| 1913 |
|
| 1914 |
auto* elements = MElements::New(alloc(), obj); |
| 1915 |
add(elements); |
| 1916 |
|
| 1917 |
auto* length = MArrayLength::New(alloc(), elements); |
| 1918 |
add(length); |
| 1919 |
|
| 1920 |
return defineOperand(resultId, length); |
| 1921 |
} |
| 1922 |
|
| 1923 |
bool WarpCacheIRTranspiler::emitLoadArgumentsObjectArgResult( |
| 1924 |
ObjOperandId objId, Int32OperandId indexId) { |
| 1925 |
MDefinition* obj = getOperand(objId); |
| 1926 |
MDefinition* index = getOperand(indexId); |
| 1927 |
|
| 1928 |
auto* load = MLoadArgumentsObjectArg::New(alloc(), obj, index); |
| 1929 |
add(load); |
| 1930 |
|
| 1931 |
pushResult(load); |
| 1932 |
return true; |
| 1933 |
} |
| 1934 |
|
| 1935 |
bool WarpCacheIRTranspiler::emitLoadArgumentsObjectArgHoleResult( |
| 1936 |
ObjOperandId objId, Int32OperandId indexId) { |
| 1937 |
MDefinition* obj = getOperand(objId); |
| 1938 |
MDefinition* index = getOperand(indexId); |
| 1939 |
|
| 1940 |
auto* load = MLoadArgumentsObjectArgHole::New(alloc(), obj, index); |
| 1941 |
add(load); |
| 1942 |
|
| 1943 |
pushResult(load); |
| 1944 |
return true; |
| 1945 |
} |
| 1946 |
|
| 1947 |
bool WarpCacheIRTranspiler::emitLoadArgumentsObjectArgExistsResult( |
| 1948 |
ObjOperandId objId, Int32OperandId indexId) { |
| 1949 |
MDefinition* obj = getOperand(objId); |
| 1950 |
MDefinition* index = getOperand(indexId); |
| 1951 |
|
| 1952 |
auto* ins = MInArgumentsObjectArg::New(alloc(), obj, index); |
| 1953 |
add(ins); |
| 1954 |
|
| 1955 |
pushResult(ins); |
| 1956 |
return true; |
| 1957 |
} |
| 1958 |
|
| 1959 |
bool WarpCacheIRTranspiler::emitLoadArgumentsObjectLengthResult( |
| 1960 |
ObjOperandId objId) { |
| 1961 |
MDefinition* obj = getOperand(objId); |
| 1962 |
|
| 1963 |
auto* length = MArgumentsObjectLength::New(alloc(), obj); |
| 1964 |
add(length); |
| 1965 |
|
| 1966 |
pushResult(length); |
| 1967 |
return true; |
| 1968 |
} |
| 1969 |
|
| 1970 |
bool WarpCacheIRTranspiler::emitLoadArgumentsObjectLength( |
| 1971 |
ObjOperandId objId, Int32OperandId resultId) { |
| 1972 |
MDefinition* obj = getOperand(objId); |
| 1973 |
|
| 1974 |
auto* length = MArgumentsObjectLength::New(alloc(), obj); |
| 1975 |
add(length); |
| 1976 |
|
| 1977 |
return defineOperand(resultId, length); |
| 1978 |
} |
| 1979 |
|
| 1980 |
bool WarpCacheIRTranspiler::emitLoadBoundFunctionNumArgs( |
| 1981 |
ObjOperandId objId, Int32OperandId resultId) { |
| 1982 |
MDefinition* obj = getOperand(objId); |
| 1983 |
|
| 1984 |
auto* numArgs = MBoundFunctionNumArgs::New(alloc(), obj); |
| 1985 |
add(numArgs); |
| 1986 |
|
| 1987 |
return defineOperand(resultId, numArgs); |
| 1988 |
} |
| 1989 |
|
| 1990 |
bool WarpCacheIRTranspiler::emitLoadBoundFunctionTarget(ObjOperandId objId, |
| 1991 |
ObjOperandId resultId) { |
| 1992 |
MDefinition* obj = getOperand(objId); |
| 1993 |
|
| 1994 |
auto* target = MLoadFixedSlotAndUnbox::New( |
| 1995 |
alloc(), obj, BoundFunctionObject::targetSlot(), MUnbox::Mode::Infallible, |
| 1996 |
MIRType::Object); |
| 1997 |
add(target); |
| 1998 |
|
| 1999 |
return defineOperand(resultId, target); |
| 2000 |
} |
| 2001 |
|
| 2002 |
bool WarpCacheIRTranspiler::emitLoadBoundFunctionArgument( |
| 2003 |
ObjOperandId objId, uint32_t index, ValOperandId resultId) { |
| 2004 |
MDefinition* obj = getOperand(objId); |
| 2005 |
|
| 2006 |
auto* boundArgs = MLoadFixedSlotAndUnbox::New( |
| 2007 |
alloc(), obj, BoundFunctionObject::firstInlineBoundArgSlot(), |
| 2008 |
MUnbox::Mode::Infallible, MIRType::Object); |
| 2009 |
add(boundArgs); |
| 2010 |
|
| 2011 |
auto* elements = MElements::New(alloc(), boundArgs); |
| 2012 |
add(elements); |
| 2013 |
|
| 2014 |
auto argIndex = constant(Int32Value(index)); |
| 2015 |
auto* load = MLoadElement::New(alloc(), elements, argIndex); |
| 2016 |
add(load); |
| 2017 |
|
| 2018 |
return defineOperand(resultId, load); |
| 2019 |
} |
| 2020 |
|
| 2021 |
bool WarpCacheIRTranspiler::emitGuardBoundFunctionIsConstructor( |
| 2022 |
ObjOperandId objId) { |
| 2023 |
MDefinition* obj = getOperand(objId); |
| 2024 |
|
| 2025 |
auto* guard = MGuardBoundFunctionIsConstructor::New(alloc(), obj); |
| 2026 |
add(guard); |
| 2027 |
|
| 2028 |
setOperand(objId, guard); |
| 2029 |
return true; |
| 2030 |
} |
| 2031 |
|
| 2032 |
bool WarpCacheIRTranspiler::emitGuardObjectIdentity(ObjOperandId obj1Id, |
| 2033 |
ObjOperandId obj2Id) { |
| 2034 |
MDefinition* obj1 = getOperand(obj1Id); |
| 2035 |
MDefinition* obj2 = getOperand(obj2Id); |
| 2036 |
|
| 2037 |
auto* guard = MGuardObjectIdentity::New(alloc(), obj1, obj2, |
| 2038 |
/* bailOnEquality = */ false); |
| 2039 |
add(guard); |
| 2040 |
return true; |
| 2041 |
} |
| 2042 |
|
| 2043 |
bool WarpCacheIRTranspiler::emitArrayFromArgumentsObjectResult( |
| 2044 |
ObjOperandId objId, uint32_t shapeOffset) { |
| 2045 |
MDefinition* obj = getOperand(objId); |
| 2046 |
Shape* shape = shapeStubField(shapeOffset); |
| 2047 |
MOZ_ASSERT(shape); |
| 2048 |
|
| 2049 |
auto* array = MArrayFromArgumentsObject::New(alloc(), obj, shape); |
| 2050 |
addEffectful(array); |
| 2051 |
|
| 2052 |
pushResult(array); |
| 2053 |
return resumeAfter(array); |
| 2054 |
} |
| 2055 |
|
| 2056 |
bool WarpCacheIRTranspiler::emitLoadFunctionLengthResult(ObjOperandId objId) { |
| 2057 |
MDefinition* obj = getOperand(objId); |
| 2058 |
|
| 2059 |
auto* length = MFunctionLength::New(alloc(), obj); |
| 2060 |
add(length); |
| 2061 |
|
| 2062 |
pushResult(length); |
| 2063 |
return true; |
| 2064 |
} |
| 2065 |
|
| 2066 |
bool WarpCacheIRTranspiler::emitLoadFunctionNameResult(ObjOperandId objId) { |
| 2067 |
MDefinition* obj = getOperand(objId); |
| 2068 |
|
| 2069 |
auto* name = MFunctionName::New(alloc(), obj); |
| 2070 |
add(name); |
| 2071 |
|
| 2072 |
pushResult(name); |
| 2073 |
return true; |
| 2074 |
} |
| 2075 |
|
| 2076 |
bool WarpCacheIRTranspiler::emitLoadArrayBufferByteLengthInt32Result( |
| 2077 |
ObjOperandId objId) { |
| 2078 |
MDefinition* obj = getOperand(objId); |
| 2079 |
|
| 2080 |
auto* length = MArrayBufferByteLength::New(alloc(), obj); |
| 2081 |
add(length); |
| 2082 |
|
| 2083 |
auto* lengthInt32 = MNonNegativeIntPtrToInt32::New(alloc(), length); |
| 2084 |
add(lengthInt32); |
| 2085 |
|
| 2086 |
pushResult(lengthInt32); |
| 2087 |
return true; |
| 2088 |
} |
| 2089 |
|
| 2090 |
bool WarpCacheIRTranspiler::emitLoadArrayBufferByteLengthDoubleResult( |
| 2091 |
ObjOperandId objId) { |
| 2092 |
MDefinition* obj = getOperand(objId); |
| 2093 |
|
| 2094 |
auto* length = MArrayBufferByteLength::New(alloc(), obj); |
| 2095 |
add(length); |
| 2096 |
|
| 2097 |
auto* lengthDouble = MIntPtrToDouble::New(alloc(), length); |
| 2098 |
add(lengthDouble); |
| 2099 |
|
| 2100 |
pushResult(lengthDouble); |
| 2101 |
return true; |
| 2102 |
} |
| 2103 |
|
| 2104 |
bool WarpCacheIRTranspiler::emitLoadArrayBufferViewLengthInt32Result( |
| 2105 |
ObjOperandId objId) { |
| 2106 |
MDefinition* obj = getOperand(objId); |
| 2107 |
|
| 2108 |
// Use a separate instruction for converting the length to Int32, so that we |
| 2109 |
// can fold the MArrayBufferViewLength instruction with length instructions |
| 2110 |
// added for bounds checks. |
| 2111 |
|
| 2112 |
auto* length = MArrayBufferViewLength::New(alloc(), obj); |
| 2113 |
add(length); |
| 2114 |
|
| 2115 |
auto* lengthInt32 = MNonNegativeIntPtrToInt32::New(alloc(), length); |
| 2116 |
add(lengthInt32); |
| 2117 |
|
| 2118 |
pushResult(lengthInt32); |
| 2119 |
return true; |
| 2120 |
} |
| 2121 |
|
| 2122 |
bool WarpCacheIRTranspiler::emitLoadArrayBufferViewLengthDoubleResult( |
| 2123 |
ObjOperandId objId) { |
| 2124 |
MDefinition* obj = getOperand(objId); |
| 2125 |
|
| 2126 |
auto* length = MArrayBufferViewLength::New(alloc(), obj); |
| 2127 |
add(length); |
| 2128 |
|
| 2129 |
auto* lengthDouble = MIntPtrToDouble::New(alloc(), length); |
| 2130 |
add(lengthDouble); |
| 2131 |
|
| 2132 |
pushResult(lengthDouble); |
| 2133 |
return true; |
| 2134 |
} |
| 2135 |
|
| 2136 |
bool WarpCacheIRTranspiler::emitLoadStringLengthResult(StringOperandId strId) { |
| 2137 |
MDefinition* str = getOperand(strId); |
| 2138 |
|
| 2139 |
auto* length = MStringLength::New(alloc(), str); |
| 2140 |
add(length); |
| 2141 |
|
| 2142 |
pushResult(length); |
| 2143 |
return true; |
| 2144 |
} |
| 2145 |
|
| 2146 |
MInstruction* WarpCacheIRTranspiler::addBoundsCheck(MDefinition* index, |
| 2147 |
MDefinition* length) { |
| 2148 |
MInstruction* check = MBoundsCheck::New(alloc(), index, length); |
| 2149 |
add(check); |
| 2150 |
|
| 2151 |
if (snapshot().bailoutInfo().failedBoundsCheck()) { |
| 2152 |
check->setNotMovable(); |
| 2153 |
} |
| 2154 |
|
| 2155 |
if (JitOptions.spectreIndexMasking) { |
| 2156 |
// Use a separate MIR instruction for the index masking. Doing this as |
| 2157 |
// part of MBoundsCheck would be unsound because bounds checks can be |
| 2158 |
// optimized or eliminated completely. Consider this: |
| 2159 |
// |
| 2160 |
// for (var i = 0; i < x; i++) |
| 2161 |
// res = arr[i]; |
| 2162 |
// |
| 2163 |
// If we can prove |x < arr.length|, we are able to eliminate the bounds |
| 2164 |
// check, but we should not get rid of the index masking because the |
| 2165 |
// |i < x| branch could still be mispredicted. |
| 2166 |
// |
| 2167 |
// Using a separate instruction lets us eliminate the bounds check |
| 2168 |
// without affecting the index masking. |
| 2169 |
check = MSpectreMaskIndex::New(alloc(), check, length); |
| 2170 |
add(check); |
| 2171 |
} |
| 2172 |
|
| 2173 |
return check; |
| 2174 |
} |
| 2175 |
|
| 2176 |
bool WarpCacheIRTranspiler::emitLoadDenseElementResult(ObjOperandId objId, |
| 2177 |
Int32OperandId indexId) { |
| 2178 |
MDefinition* obj = getOperand(objId); |
| 2179 |
MDefinition* index = getOperand(indexId); |
| 2180 |
|
| 2181 |
auto* elements = MElements::New(alloc(), obj); |
| 2182 |
add(elements); |
| 2183 |
|
| 2184 |
auto* length = MInitializedLength::New(alloc(), elements); |
| 2185 |
add(length); |
| 2186 |
|
| 2187 |
index = addBoundsCheck(index, length); |
| 2188 |
|
| 2189 |
auto* load = MLoadElement::New(alloc(), elements, index); |
| 2190 |
add(load); |
| 2191 |
|
| 2192 |
pushResult(load); |
| 2193 |
return true; |
| 2194 |
} |
| 2195 |
|
| 2196 |
bool WarpCacheIRTranspiler::emitLoadDenseElementHoleResult( |
| 2197 |
ObjOperandId objId, Int32OperandId indexId) { |
| 2198 |
MDefinition* obj = getOperand(objId); |
| 2199 |
MDefinition* index = getOperand(indexId); |
| 2200 |
|
| 2201 |
auto* elements = MElements::New(alloc(), obj); |
| 2202 |
add(elements); |
| 2203 |
|
| 2204 |
auto* length = MInitializedLength::New(alloc(), elements); |
| 2205 |
add(length); |
| 2206 |
|
| 2207 |
auto* load = MLoadElementHole::New(alloc(), elements, index, length); |
| 2208 |
add(load); |
| 2209 |
|
| 2210 |
pushResult(load); |
| 2211 |
return true; |
| 2212 |
} |
| 2213 |
|
| 2214 |
bool WarpCacheIRTranspiler::emitCallGetSparseElementResult( |
| 2215 |
ObjOperandId objId, Int32OperandId indexId) { |
| 2216 |
MDefinition* obj = getOperand(objId); |
| 2217 |
MDefinition* index = getOperand(indexId); |
| 2218 |
|
| 2219 |
auto* call = MCallGetSparseElement::New(alloc(), obj, index); |
| 2220 |
addEffectful(call); |
| 2221 |
|
| 2222 |
pushResult(call); |
| 2223 |
return resumeAfter(call); |
| 2224 |
} |
| 2225 |
|
| 2226 |
bool WarpCacheIRTranspiler::emitCallNativeGetElementResult( |
| 2227 |
ObjOperandId objId, Int32OperandId indexId) { |
| 2228 |
MDefinition* obj = getOperand(objId); |
| 2229 |
MDefinition* index = getOperand(indexId); |
| 2230 |
|
| 2231 |
auto* call = MCallNativeGetElement::New(alloc(), obj, index); |
| 2232 |
addEffectful(call); |
| 2233 |
|
| 2234 |
pushResult(call); |
| 2235 |
return resumeAfter(call); |
| 2236 |
} |
| 2237 |
|
| 2238 |
bool WarpCacheIRTranspiler::emitCallNativeGetElementSuperResult( |
| 2239 |
ObjOperandId objId, Int32OperandId indexId, ValOperandId receiverId) { |
| 2240 |
MDefinition* obj = getOperand(objId); |
| 2241 |
MDefinition* index = getOperand(indexId); |
| 2242 |
MDefinition* receiver = getOperand(receiverId); |
| 2243 |
|
| 2244 |
auto* call = MCallNativeGetElementSuper::New(alloc(), obj, index, receiver); |
| 2245 |
addEffectful(call); |
| 2246 |
|
| 2247 |
pushResult(call); |
| 2248 |
return resumeAfter(call); |
| 2249 |
} |
| 2250 |
|
| 2251 |
bool WarpCacheIRTranspiler::emitLoadDenseElementExistsResult( |
| 2252 |
ObjOperandId objId, Int32OperandId indexId) { |
| 2253 |
MDefinition* obj = getOperand(objId); |
| 2254 |
MDefinition* index = getOperand(indexId); |
| 2255 |
|
| 2256 |
// Get the elements vector. |
| 2257 |
auto* elements = MElements::New(alloc(), obj); |
| 2258 |
add(elements); |
| 2259 |
|
| 2260 |
auto* length = MInitializedLength::New(alloc(), elements); |
| 2261 |
add(length); |
| 2262 |
|
| 2263 |
// Check if id < initLength. |
| 2264 |
index = addBoundsCheck(index, length); |
| 2265 |
|
| 2266 |
// And check elem[id] is not a hole. |
| 2267 |
auto* guard = MGuardElementNotHole::New(alloc(), elements, index); |
| 2268 |
add(guard); |
| 2269 |
|
| 2270 |
pushResult(constant(BooleanValue(true))); |
| 2271 |
return true; |
| 2272 |
} |
| 2273 |
|
| 2274 |
bool WarpCacheIRTranspiler::emitLoadDenseElementHoleExistsResult( |
| 2275 |
ObjOperandId objId, Int32OperandId indexId) { |
| 2276 |
MDefinition* obj = getOperand(objId); |
| 2277 |
MDefinition* index = getOperand(indexId); |
| 2278 |
|
| 2279 |
// Get the elements vector. |
| 2280 |
auto* elements = MElements::New(alloc(), obj); |
| 2281 |
add(elements); |
| 2282 |
|
| 2283 |
auto* length = MInitializedLength::New(alloc(), elements); |
| 2284 |
add(length); |
| 2285 |
|
| 2286 |
// Check if id < initLength and elem[id] not a hole. |
| 2287 |
auto* ins = MInArray::New(alloc(), elements, index, length); |
| 2288 |
add(ins); |
| 2289 |
|
| 2290 |
pushResult(ins); |
| 2291 |
return true; |
| 2292 |
} |
| 2293 |
|
| 2294 |
bool WarpCacheIRTranspiler::emitCallObjectHasSparseElementResult( |
| 2295 |
ObjOperandId objId, Int32OperandId indexId) { |
| 2296 |
MDefinition* obj = getOperand(objId); |
| 2297 |
MDefinition* index = getOperand(indexId); |
| 2298 |
|
| 2299 |
auto* ins = MCallObjectHasSparseElement::New(alloc(), obj, index); |
| 2300 |
add(ins); |
| 2301 |
|
| 2302 |
pushResult(ins); |
| 2303 |
return true; |
| 2304 |
} |
| 2305 |
|
| 2306 |
MInstruction* WarpCacheIRTranspiler::emitTypedArrayLength( |
| 2307 |
ArrayBufferViewKind viewKind, MDefinition* obj) { |
| 2308 |
if (viewKind == ArrayBufferViewKind::FixedLength) { |
| 2309 |
auto* length = MArrayBufferViewLength::New(alloc(), obj); |
| 2310 |
add(length); |
| 2311 |
|
| 2312 |
return length; |
| 2313 |
} |
| 2314 |
|
| 2315 |
// Bounds check doesn't require a memory barrier. See IsValidIntegerIndex |
| 2316 |
// abstract operation which reads the underlying buffer byte length using |
| 2317 |
// "unordered" memory order. |
| 2318 |
auto barrier = MemoryBarrierRequirement::NotRequired; |
| 2319 |
|
| 2320 |
// Movable and removable because no memory barrier is needed. |
| 2321 |
auto* length = MResizableTypedArrayLength::New(alloc(), obj, barrier); |
| 2322 |
length->setMovable(); |
| 2323 |
length->setNotGuard(); |
| 2324 |
add(length); |
| 2325 |
|
| 2326 |
return length; |
| 2327 |
} |
| 2328 |
|
| 2329 |
bool WarpCacheIRTranspiler::emitLoadTypedArrayElementExistsResult( |
| 2330 |
ObjOperandId objId, IntPtrOperandId indexId, ArrayBufferViewKind viewKind) { |
| 2331 |
MDefinition* obj = getOperand(objId); |
| 2332 |
MDefinition* index = getOperand(indexId); |
| 2333 |
|
| 2334 |
auto* length = emitTypedArrayLength(viewKind, obj); |
| 2335 |
|
| 2336 |
// Unsigned comparison to catch negative indices. |
| 2337 |
auto* ins = MCompare::New(alloc(), index, length, JSOp::Lt, |
| 2338 |
MCompare::Compare_UIntPtr); |
| 2339 |
add(ins); |
| 2340 |
|
| 2341 |
pushResult(ins); |
| 2342 |
return true; |
| 2343 |
} |
| 2344 |
|
| 2345 |
static MIRType MIRTypeForArrayBufferViewRead(Scalar::Type arrayType, |
| 2346 |
bool forceDoubleForUint32) { |
| 2347 |
switch (arrayType) { |
| 2348 |
case Scalar::Int8: |
| 2349 |
case Scalar::Uint8: |
| 2350 |
case Scalar::Uint8Clamped: |
| 2351 |
case Scalar::Int16: |
| 2352 |
case Scalar::Uint16: |
| 2353 |
case Scalar::Int32: |
| 2354 |
return MIRType::Int32; |
| 2355 |
case Scalar::Uint32: |
| 2356 |
return forceDoubleForUint32 ? MIRType::Double : MIRType::Int32; |
| 2357 |
case Scalar::Float16: |
| 2358 |
case Scalar::Float32: |
| 2359 |
return MIRType::Float32; |
| 2360 |
case Scalar::Float64: |
| 2361 |
return MIRType::Double; |
| 2362 |
case Scalar::BigInt64: |
| 2363 |
case Scalar::BigUint64: |
| 2364 |
return MIRType::Int64; |
| 2365 |
default: |
| 2366 |
break; |
| 2367 |
} |
| 2368 |
MOZ_CRASH("Unknown typed array type"); |
| 2369 |
} |
| 2370 |
|
| 2371 |
bool WarpCacheIRTranspiler::emitLoadTypedArrayElementResult( |
| 2372 |
ObjOperandId objId, IntPtrOperandId indexId, Scalar::Type elementType, |
| 2373 |
bool handleOOB, bool forceDoubleForUint32, ArrayBufferViewKind viewKind) { |
| 2374 |
MDefinition* obj = getOperand(objId); |
| 2375 |
MDefinition* index = getOperand(indexId); |
| 2376 |
|
| 2377 |
auto* length = emitTypedArrayLength(viewKind, obj); |
| 2378 |
|
| 2379 |
if (!handleOOB) { |
| 2380 |
// MLoadTypedArrayElementHole does the bounds checking. |
| 2381 |
index = addBoundsCheck(index, length); |
| 2382 |
} |
| 2383 |
|
| 2384 |
auto* elements = MArrayBufferViewElements::New(alloc(), obj); |
| 2385 |
add(elements); |
| 2386 |
|
| 2387 |
if (handleOOB) { |
| 2388 |
auto* load = MLoadTypedArrayElementHole::New( |
| 2389 |
alloc(), elements, index, length, elementType, forceDoubleForUint32); |
| 2390 |
add(load); |
| 2391 |
|
| 2392 |
pushResult(load); |
| 2393 |
return true; |
| 2394 |
} |
| 2395 |
|
| 2396 |
auto* load = MLoadUnboxedScalar::New(alloc(), elements, index, elementType); |
| 2397 |
load->setResultType( |
| 2398 |
MIRTypeForArrayBufferViewRead(elementType, forceDoubleForUint32)); |
| 2399 |
add(load); |
| 2400 |
|
| 2401 |
MInstruction* result = load; |
| 2402 |
if (Scalar::isBigIntType(elementType)) { |
| 2403 |
result = MInt64ToBigInt::New(alloc(), load, |
| 2404 |
Scalar::isSignedIntType(elementType)); |
| 2405 |
add(result); |
| 2406 |
} |
| 2407 |
|
| 2408 |
pushResult(result); |
| 2409 |
return true; |
| 2410 |
} |
| 2411 |
|
| 2412 |
bool WarpCacheIRTranspiler::emitLinearizeForCharAccess( |
| 2413 |
StringOperandId strId, Int32OperandId indexId, StringOperandId resultId) { |
| 2414 |
MDefinition* str = getOperand(strId); |
| 2415 |
MDefinition* index = getOperand(indexId); |
| 2416 |
|
| 2417 |
auto* ins = MLinearizeForCharAccess::New(alloc(), str, index); |
| 2418 |
add(ins); |
| 2419 |
|
| 2420 |
return defineOperand(resultId, ins); |
| 2421 |
} |
| 2422 |
|
| 2423 |
bool WarpCacheIRTranspiler::emitLinearizeForCodePointAccess( |
| 2424 |
StringOperandId strId, Int32OperandId indexId, StringOperandId resultId) { |
| 2425 |
MDefinition* str = getOperand(strId); |
| 2426 |
MDefinition* index = getOperand(indexId); |
| 2427 |
|
| 2428 |
auto* ins = MLinearizeForCodePointAccess::New(alloc(), str, index); |
| 2429 |
add(ins); |
| 2430 |
|
| 2431 |
return defineOperand(resultId, ins); |
| 2432 |
} |
| 2433 |
|
| 2434 |
bool WarpCacheIRTranspiler::emitToRelativeStringIndex(Int32OperandId indexId, |
| 2435 |
StringOperandId strId, |
| 2436 |
Int32OperandId resultId) { |
| 2437 |
MDefinition* str = getOperand(strId); |
| 2438 |
MDefinition* index = getOperand(indexId); |
| 2439 |
|
| 2440 |
auto* length = MStringLength::New(alloc(), str); |
| 2441 |
add(length); |
| 2442 |
|
| 2443 |
auto* ins = MToRelativeStringIndex::New(alloc(), index, length); |
| 2444 |
add(ins); |
| 2445 |
|
| 2446 |
return defineOperand(resultId, ins); |
| 2447 |
} |
| 2448 |
|
| 2449 |
bool WarpCacheIRTranspiler::emitLoadStringCharResult(StringOperandId strId, |
| 2450 |
Int32OperandId indexId, |
| 2451 |
bool handleOOB) { |
| 2452 |
MDefinition* str = getOperand(strId); |
| 2453 |
MDefinition* index = getOperand(indexId); |
| 2454 |
|
| 2455 |
if (handleOOB) { |
| 2456 |
auto* charCode = MCharCodeAtOrNegative::New(alloc(), str, index); |
| 2457 |
add(charCode); |
| 2458 |
|
| 2459 |
auto* fromCharCode = MFromCharCodeEmptyIfNegative::New(alloc(), charCode); |
| 2460 |
add(fromCharCode); |
| 2461 |
|
| 2462 |
pushResult(fromCharCode); |
| 2463 |
return true; |
| 2464 |
} |
| 2465 |
|
| 2466 |
auto* length = MStringLength::New(alloc(), str); |
| 2467 |
add(length); |
| 2468 |
|
| 2469 |
index = addBoundsCheck(index, length); |
| 2470 |
|
| 2471 |
auto* charCode = MCharCodeAt::New(alloc(), str, index); |
| 2472 |
add(charCode); |
| 2473 |
|
| 2474 |
auto* fromCharCode = MFromCharCode::New(alloc(), charCode); |
| 2475 |
add(fromCharCode); |
| 2476 |
|
| 2477 |
pushResult(fromCharCode); |
| 2478 |
return true; |
| 2479 |
} |
| 2480 |
|
| 2481 |
bool WarpCacheIRTranspiler::emitLoadStringAtResult(StringOperandId strId, |
| 2482 |
Int32OperandId indexId, |
| 2483 |
bool handleOOB) { |
| 2484 |
MDefinition* str = getOperand(strId); |
| 2485 |
MDefinition* index = getOperand(indexId); |
| 2486 |
|
| 2487 |
if (handleOOB) { |
| 2488 |
auto* charCode = MCharCodeAtOrNegative::New(alloc(), str, index); |
| 2489 |
add(charCode); |
| 2490 |
|
| 2491 |
auto* fromCharCode = |
| 2492 |
MFromCharCodeUndefinedIfNegative::New(alloc(), charCode); |
| 2493 |
add(fromCharCode); |
| 2494 |
|
| 2495 |
pushResult(fromCharCode); |
| 2496 |
return true; |
| 2497 |
} |
| 2498 |
|
| 2499 |
auto* length = MStringLength::New(alloc(), str); |
| 2500 |
add(length); |
| 2501 |
|
| 2502 |
index = addBoundsCheck(index, length); |
| 2503 |
|
| 2504 |
auto* charCode = MCharCodeAt::New(alloc(), str, index); |
| 2505 |
add(charCode); |
| 2506 |
|
| 2507 |
auto* fromCharCode = MFromCharCode::New(alloc(), charCode); |
| 2508 |
add(fromCharCode); |
| 2509 |
|
| 2510 |
pushResult(fromCharCode); |
| 2511 |
return true; |
| 2512 |
} |
| 2513 |
|
| 2514 |
bool WarpCacheIRTranspiler::emitLoadStringCharCodeResult(StringOperandId strId, |
| 2515 |
Int32OperandId indexId, |
| 2516 |
bool handleOOB) { |
| 2517 |
MDefinition* str = getOperand(strId); |
| 2518 |
MDefinition* index = getOperand(indexId); |
| 2519 |
|
| 2520 |
if (handleOOB) { |
| 2521 |
auto* charCode = MCharCodeAtOrNegative::New(alloc(), str, index); |
| 2522 |
add(charCode); |
| 2523 |
|
| 2524 |
auto* ins = MNegativeToNaN::New(alloc(), charCode); |
| 2525 |
add(ins); |
| 2526 |
|
| 2527 |
pushResult(ins); |
| 2528 |
return true; |
| 2529 |
} |
| 2530 |
|
| 2531 |
auto* length = MStringLength::New(alloc(), str); |
| 2532 |
add(length); |
| 2533 |
|
| 2534 |
index = addBoundsCheck(index, length); |
| 2535 |
|
| 2536 |
auto* charCode = MCharCodeAt::New(alloc(), str, index); |
| 2537 |
add(charCode); |
| 2538 |
|
| 2539 |
pushResult(charCode); |
| 2540 |
return true; |
| 2541 |
} |
| 2542 |
|
| 2543 |
bool WarpCacheIRTranspiler::emitLoadStringCodePointResult( |
| 2544 |
StringOperandId strId, Int32OperandId indexId, bool handleOOB) { |
| 2545 |
MDefinition* str = getOperand(strId); |
| 2546 |
MDefinition* index = getOperand(indexId); |
| 2547 |
|
| 2548 |
if (handleOOB) { |
| 2549 |
auto* codePoint = MCodePointAtOrNegative::New(alloc(), str, index); |
| 2550 |
add(codePoint); |
| 2551 |
|
| 2552 |
auto* ins = MNegativeToUndefined::New(alloc(), codePoint); |
| 2553 |
add(ins); |
| 2554 |
|
| 2555 |
pushResult(ins); |
| 2556 |
return true; |
| 2557 |
} |
| 2558 |
|
| 2559 |
auto* length = MStringLength::New(alloc(), str); |
| 2560 |
add(length); |
| 2561 |
|
| 2562 |
index = addBoundsCheck(index, length); |
| 2563 |
|
| 2564 |
auto* codePoint = MCodePointAt::New(alloc(), str, index); |
| 2565 |
add(codePoint); |
| 2566 |
|
| 2567 |
pushResult(codePoint); |
| 2568 |
return true; |
| 2569 |
} |
| 2570 |
|
| 2571 |
bool WarpCacheIRTranspiler::emitNewMapObjectResult( |
| 2572 |
uint32_t templateObjectOffset) { |
| 2573 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 2574 |
|
| 2575 |
auto* obj = MNewMapObject::New(alloc(), templateObj); |
| 2576 |
addEffectful(obj); |
| 2577 |
|
| 2578 |
pushResult(obj); |
| 2579 |
return resumeAfter(obj); |
| 2580 |
} |
| 2581 |
|
| 2582 |
bool WarpCacheIRTranspiler::emitNewSetObjectResult( |
| 2583 |
uint32_t templateObjectOffset) { |
| 2584 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 2585 |
|
| 2586 |
auto* obj = MNewSetObject::New(alloc(), templateObj); |
| 2587 |
addEffectful(obj); |
| 2588 |
|
| 2589 |
pushResult(obj); |
| 2590 |
return resumeAfter(obj); |
| 2591 |
} |
| 2592 |
|
| 2593 |
bool WarpCacheIRTranspiler::emitNewMapObjectFromIterableResult( |
| 2594 |
uint32_t templateObjectOffset, ValOperandId iterableId) { |
| 2595 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 2596 |
MDefinition* iterable = getOperand(iterableId); |
| 2597 |
|
| 2598 |
auto* obj = MNewMapObjectFromIterable::New(alloc(), iterable, templateObj); |
| 2599 |
addEffectful(obj); |
| 2600 |
|
| 2601 |
pushResult(obj); |
| 2602 |
return resumeAfter(obj); |
| 2603 |
} |
| 2604 |
|
| 2605 |
bool WarpCacheIRTranspiler::emitNewSetObjectFromIterableResult( |
| 2606 |
uint32_t templateObjectOffset, ValOperandId iterableId) { |
| 2607 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 2608 |
MDefinition* iterable = getOperand(iterableId); |
| 2609 |
|
| 2610 |
auto* obj = MNewSetObjectFromIterable::New(alloc(), iterable, templateObj); |
| 2611 |
addEffectful(obj); |
| 2612 |
|
| 2613 |
pushResult(obj); |
| 2614 |
return resumeAfter(obj); |
| 2615 |
} |
| 2616 |
|
| 2617 |
bool WarpCacheIRTranspiler::emitNewStringObjectResult( |
| 2618 |
uint32_t templateObjectOffset, StringOperandId strId) { |
| 2619 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 2620 |
MDefinition* string = getOperand(strId); |
| 2621 |
|
| 2622 |
auto* obj = MNewStringObject::New(alloc(), string, templateObj); |
| 2623 |
addEffectful(obj); |
| 2624 |
|
| 2625 |
pushResult(obj); |
| 2626 |
return resumeAfter(obj); |
| 2627 |
} |
| 2628 |
|
| 2629 |
bool WarpCacheIRTranspiler::emitStringFromCharCodeResult( |
| 2630 |
Int32OperandId codeId) { |
| 2631 |
MDefinition* code = getOperand(codeId); |
| 2632 |
|
| 2633 |
auto* fromCharCode = MFromCharCode::New(alloc(), code); |
| 2634 |
add(fromCharCode); |
| 2635 |
|
| 2636 |
pushResult(fromCharCode); |
| 2637 |
return true; |
| 2638 |
} |
| 2639 |
|
| 2640 |
bool WarpCacheIRTranspiler::emitStringFromCodePointResult( |
| 2641 |
Int32OperandId codeId) { |
| 2642 |
MDefinition* code = getOperand(codeId); |
| 2643 |
|
| 2644 |
auto* fromCodePoint = MFromCodePoint::New(alloc(), code); |
| 2645 |
add(fromCodePoint); |
| 2646 |
|
| 2647 |
pushResult(fromCodePoint); |
| 2648 |
return true; |
| 2649 |
} |
| 2650 |
|
| 2651 |
bool WarpCacheIRTranspiler::emitStringIncludesResult( |
| 2652 |
StringOperandId strId, StringOperandId searchStrId) { |
| 2653 |
MDefinition* str = getOperand(strId); |
| 2654 |
MDefinition* searchStr = getOperand(searchStrId); |
| 2655 |
|
| 2656 |
auto* includes = MStringIncludes::New(alloc(), str, searchStr); |
| 2657 |
add(includes); |
| 2658 |
|
| 2659 |
pushResult(includes); |
| 2660 |
return true; |
| 2661 |
} |
| 2662 |
|
| 2663 |
bool WarpCacheIRTranspiler::emitStringIndexOfResult( |
| 2664 |
StringOperandId strId, StringOperandId searchStrId) { |
| 2665 |
MDefinition* str = getOperand(strId); |
| 2666 |
MDefinition* searchStr = getOperand(searchStrId); |
| 2667 |
|
| 2668 |
auto* indexOf = MStringIndexOf::New(alloc(), str, searchStr); |
| 2669 |
add(indexOf); |
| 2670 |
|
| 2671 |
pushResult(indexOf); |
| 2672 |
return true; |
| 2673 |
} |
| 2674 |
|
| 2675 |
bool WarpCacheIRTranspiler::emitStringLastIndexOfResult( |
| 2676 |
StringOperandId strId, StringOperandId searchStrId) { |
| 2677 |
MDefinition* str = getOperand(strId); |
| 2678 |
MDefinition* searchStr = getOperand(searchStrId); |
| 2679 |
|
| 2680 |
auto* lastIndexOf = MStringLastIndexOf::New(alloc(), str, searchStr); |
| 2681 |
add(lastIndexOf); |
| 2682 |
|
| 2683 |
pushResult(lastIndexOf); |
| 2684 |
return true; |
| 2685 |
} |
| 2686 |
|
| 2687 |
bool WarpCacheIRTranspiler::emitStringStartsWithResult( |
| 2688 |
StringOperandId strId, StringOperandId searchStrId) { |
| 2689 |
MDefinition* str = getOperand(strId); |
| 2690 |
MDefinition* searchStr = getOperand(searchStrId); |
| 2691 |
|
| 2692 |
auto* startsWith = MStringStartsWith::New(alloc(), str, searchStr); |
| 2693 |
add(startsWith); |
| 2694 |
|
| 2695 |
pushResult(startsWith); |
| 2696 |
return true; |
| 2697 |
} |
| 2698 |
|
| 2699 |
bool WarpCacheIRTranspiler::emitStringEndsWithResult( |
| 2700 |
StringOperandId strId, StringOperandId searchStrId) { |
| 2701 |
MDefinition* str = getOperand(strId); |
| 2702 |
MDefinition* searchStr = getOperand(searchStrId); |
| 2703 |
|
| 2704 |
auto* endsWith = MStringEndsWith::New(alloc(), str, searchStr); |
| 2705 |
add(endsWith); |
| 2706 |
|
| 2707 |
pushResult(endsWith); |
| 2708 |
return true; |
| 2709 |
} |
| 2710 |
|
| 2711 |
bool WarpCacheIRTranspiler::emitStringToLowerCaseResult(StringOperandId strId) { |
| 2712 |
MDefinition* str = getOperand(strId); |
| 2713 |
|
| 2714 |
auto* convert = |
| 2715 |
MStringConvertCase::New(alloc(), str, MStringConvertCase::LowerCase); |
| 2716 |
add(convert); |
| 2717 |
|
| 2718 |
pushResult(convert); |
| 2719 |
return true; |
| 2720 |
} |
| 2721 |
|
| 2722 |
bool WarpCacheIRTranspiler::emitStringToUpperCaseResult(StringOperandId strId) { |
| 2723 |
MDefinition* str = getOperand(strId); |
| 2724 |
|
| 2725 |
auto* convert = |
| 2726 |
MStringConvertCase::New(alloc(), str, MStringConvertCase::UpperCase); |
| 2727 |
add(convert); |
| 2728 |
|
| 2729 |
pushResult(convert); |
| 2730 |
return true; |
| 2731 |
} |
| 2732 |
|
| 2733 |
bool WarpCacheIRTranspiler::emitStringTrimResult(StringOperandId strId) { |
| 2734 |
MDefinition* str = getOperand(strId); |
| 2735 |
|
| 2736 |
auto* linear = MLinearizeString::New(alloc(), str); |
| 2737 |
add(linear); |
| 2738 |
|
| 2739 |
auto* start = MStringTrimStartIndex::New(alloc(), linear); |
| 2740 |
add(start); |
| 2741 |
|
| 2742 |
auto* end = MStringTrimEndIndex::New(alloc(), linear, start); |
| 2743 |
add(end); |
| 2744 |
|
| 2745 |
// Safe to truncate because both operands are positive and end >= start. |
| 2746 |
auto* length = MSub::New(alloc(), end, start, MIRType::Int32); |
| 2747 |
length->setTruncateKind(TruncateKind::Truncate); |
| 2748 |
add(length); |
| 2749 |
|
| 2750 |
auto* substr = MSubstr::New(alloc(), linear, start, length); |
| 2751 |
add(substr); |
| 2752 |
|
| 2753 |
pushResult(substr); |
| 2754 |
return true; |
| 2755 |
} |
| 2756 |
|
| 2757 |
bool WarpCacheIRTranspiler::emitStringTrimStartResult(StringOperandId strId) { |
| 2758 |
MDefinition* str = getOperand(strId); |
| 2759 |
|
| 2760 |
auto* linear = MLinearizeString::New(alloc(), str); |
| 2761 |
add(linear); |
| 2762 |
|
| 2763 |
auto* start = MStringTrimStartIndex::New(alloc(), linear); |
| 2764 |
add(start); |
| 2765 |
|
| 2766 |
auto* end = MStringLength::New(alloc(), linear); |
| 2767 |
add(end); |
| 2768 |
|
| 2769 |
// Safe to truncate because both operands are positive and end >= start. |
| 2770 |
auto* length = MSub::New(alloc(), end, start, MIRType::Int32); |
| 2771 |
length->setTruncateKind(TruncateKind::Truncate); |
| 2772 |
add(length); |
| 2773 |
|
| 2774 |
auto* substr = MSubstr::New(alloc(), linear, start, length); |
| 2775 |
add(substr); |
| 2776 |
|
| 2777 |
pushResult(substr); |
| 2778 |
return true; |
| 2779 |
} |
| 2780 |
|
| 2781 |
bool WarpCacheIRTranspiler::emitStringTrimEndResult(StringOperandId strId) { |
| 2782 |
MDefinition* str = getOperand(strId); |
| 2783 |
|
| 2784 |
auto* linear = MLinearizeString::New(alloc(), str); |
| 2785 |
add(linear); |
| 2786 |
|
| 2787 |
auto* start = constant(Int32Value(0)); |
| 2788 |
|
| 2789 |
auto* length = MStringTrimEndIndex::New(alloc(), linear, start); |
| 2790 |
add(length); |
| 2791 |
|
| 2792 |
auto* substr = MSubstr::New(alloc(), linear, start, length); |
| 2793 |
add(substr); |
| 2794 |
|
| 2795 |
pushResult(substr); |
| 2796 |
return true; |
| 2797 |
} |
| 2798 |
|
| 2799 |
bool WarpCacheIRTranspiler::emitStoreDynamicSlot(ObjOperandId objId, |
| 2800 |
uint32_t offsetOffset, |
| 2801 |
ValOperandId rhsId) { |
| 2802 |
int32_t offset = int32StubField(offsetOffset); |
| 2803 |
|
| 2804 |
MDefinition* obj = getOperand(objId); |
| 2805 |
size_t slotIndex = NativeObject::getDynamicSlotIndexFromOffset(offset); |
| 2806 |
MDefinition* rhs = getOperand(rhsId); |
| 2807 |
|
| 2808 |
auto* barrier = MPostWriteBarrier::New(alloc(), obj, rhs); |
| 2809 |
add(barrier); |
| 2810 |
|
| 2811 |
auto* slots = MSlots::New(alloc(), obj); |
| 2812 |
add(slots); |
| 2813 |
|
| 2814 |
auto* store = MStoreDynamicSlot::NewBarriered(alloc(), slots, slotIndex, rhs); |
| 2815 |
addEffectful(store); |
| 2816 |
return resumeAfter(store); |
| 2817 |
} |
| 2818 |
|
| 2819 |
bool WarpCacheIRTranspiler::emitStoreFixedSlot(ObjOperandId objId, |
| 2820 |
uint32_t offsetOffset, |
| 2821 |
ValOperandId rhsId) { |
| 2822 |
int32_t offset = int32StubField(offsetOffset); |
| 2823 |
|
| 2824 |
MDefinition* obj = getOperand(objId); |
| 2825 |
size_t slotIndex = NativeObject::getFixedSlotIndexFromOffset(offset); |
| 2826 |
MDefinition* rhs = getOperand(rhsId); |
| 2827 |
|
| 2828 |
auto* barrier = MPostWriteBarrier::New(alloc(), obj, rhs); |
| 2829 |
add(barrier); |
| 2830 |
|
| 2831 |
auto* store = MStoreFixedSlot::NewBarriered(alloc(), obj, slotIndex, rhs); |
| 2832 |
addEffectful(store); |
| 2833 |
return resumeAfter(store); |
| 2834 |
} |
| 2835 |
|
| 2836 |
bool WarpCacheIRTranspiler::emitStoreFixedSlotUndefinedResult( |
| 2837 |
ObjOperandId objId, uint32_t offsetOffset, ValOperandId rhsId) { |
| 2838 |
int32_t offset = int32StubField(offsetOffset); |
| 2839 |
|
| 2840 |
MDefinition* obj = getOperand(objId); |
| 2841 |
size_t slotIndex = NativeObject::getFixedSlotIndexFromOffset(offset); |
| 2842 |
MDefinition* rhs = getOperand(rhsId); |
| 2843 |
|
| 2844 |
auto* barrier = MPostWriteBarrier::New(alloc(), obj, rhs); |
| 2845 |
add(barrier); |
| 2846 |
|
| 2847 |
auto* store = MStoreFixedSlot::NewBarriered(alloc(), obj, slotIndex, rhs); |
| 2848 |
addEffectful(store); |
| 2849 |
|
| 2850 |
auto* undef = constant(UndefinedValue()); |
| 2851 |
pushResult(undef); |
| 2852 |
|
| 2853 |
return resumeAfter(store); |
| 2854 |
} |
| 2855 |
|
| 2856 |
bool WarpCacheIRTranspiler::emitAddAndStoreSlotShared( |
| 2857 |
MAddAndStoreSlot::Kind kind, ObjOperandId objId, uint32_t offsetOffset, |
| 2858 |
ValOperandId rhsId, uint32_t newShapeOffset) { |
| 2859 |
int32_t offset = int32StubField(offsetOffset); |
| 2860 |
Shape* shape = shapeStubField(newShapeOffset); |
| 2861 |
|
| 2862 |
MDefinition* obj = getOperand(objId); |
| 2863 |
MDefinition* rhs = getOperand(rhsId); |
| 2864 |
|
| 2865 |
auto* barrier = MPostWriteBarrier::New(alloc(), obj, rhs); |
| 2866 |
add(barrier); |
| 2867 |
|
| 2868 |
auto* addAndStore = |
| 2869 |
MAddAndStoreSlot::New(alloc(), obj, rhs, kind, offset, shape); |
| 2870 |
addEffectful(addAndStore); |
| 2871 |
|
| 2872 |
return resumeAfter(addAndStore); |
| 2873 |
} |
| 2874 |
|
| 2875 |
bool WarpCacheIRTranspiler::emitAddAndStoreFixedSlot(ObjOperandId objId, |
| 2876 |
uint32_t offsetOffset, |
| 2877 |
ValOperandId rhsId, |
| 2878 |
uint32_t newShapeOffset) { |
| 2879 |
return emitAddAndStoreSlotShared(MAddAndStoreSlot::Kind::FixedSlot, objId, |
| 2880 |
offsetOffset, rhsId, newShapeOffset); |
| 2881 |
} |
| 2882 |
|
| 2883 |
bool WarpCacheIRTranspiler::emitAddAndStoreDynamicSlot( |
| 2884 |
ObjOperandId objId, uint32_t offsetOffset, ValOperandId rhsId, |
| 2885 |
uint32_t newShapeOffset) { |
| 2886 |
return emitAddAndStoreSlotShared(MAddAndStoreSlot::Kind::DynamicSlot, objId, |
| 2887 |
offsetOffset, rhsId, newShapeOffset); |
| 2888 |
} |
| 2889 |
|
| 2890 |
bool WarpCacheIRTranspiler::emitAllocateAndStoreDynamicSlot( |
| 2891 |
ObjOperandId objId, uint32_t offsetOffset, ValOperandId rhsId, |
| 2892 |
uint32_t newShapeOffset, uint32_t numNewSlotsOffset) { |
| 2893 |
int32_t offset = int32StubField(offsetOffset); |
| 2894 |
Shape* shape = shapeStubField(newShapeOffset); |
| 2895 |
uint32_t numNewSlots = uint32StubField(numNewSlotsOffset); |
| 2896 |
|
| 2897 |
MDefinition* obj = getOperand(objId); |
| 2898 |
MDefinition* rhs = getOperand(rhsId); |
| 2899 |
|
| 2900 |
auto* barrier = MPostWriteBarrier::New(alloc(), obj, rhs); |
| 2901 |
add(barrier); |
| 2902 |
|
| 2903 |
auto* allocateAndStore = |
| 2904 |
MAllocateAndStoreSlot::New(alloc(), obj, rhs, offset, shape, numNewSlots); |
| 2905 |
addEffectful(allocateAndStore); |
| 2906 |
|
| 2907 |
return resumeAfter(allocateAndStore); |
| 2908 |
} |
| 2909 |
|
| 2910 |
bool WarpCacheIRTranspiler::emitAddSlotAndCallAddPropHook( |
| 2911 |
ObjOperandId objId, ValOperandId rhsId, uint32_t newShapeOffset) { |
| 2912 |
Shape* shape = shapeStubField(newShapeOffset); |
| 2913 |
MDefinition* obj = getOperand(objId); |
| 2914 |
MDefinition* rhs = getOperand(rhsId); |
| 2915 |
|
| 2916 |
auto* addProp = MAddSlotAndCallAddPropHook::New(alloc(), obj, rhs, shape); |
| 2917 |
addEffectful(addProp); |
| 2918 |
|
| 2919 |
return resumeAfter(addProp); |
| 2920 |
} |
| 2921 |
|
| 2922 |
bool WarpCacheIRTranspiler::emitStoreDenseElement(ObjOperandId objId, |
| 2923 |
Int32OperandId indexId, |
| 2924 |
ValOperandId rhsId) { |
| 2925 |
MDefinition* obj = getOperand(objId); |
| 2926 |
MDefinition* index = getOperand(indexId); |
| 2927 |
MDefinition* rhs = getOperand(rhsId); |
| 2928 |
|
| 2929 |
auto* elements = MElements::New(alloc(), obj); |
| 2930 |
add(elements); |
| 2931 |
|
| 2932 |
auto* length = MInitializedLength::New(alloc(), elements); |
| 2933 |
add(length); |
| 2934 |
|
| 2935 |
index = addBoundsCheck(index, length); |
| 2936 |
|
| 2937 |
auto* barrier = MPostWriteElementBarrier::New(alloc(), obj, rhs, index); |
| 2938 |
add(barrier); |
| 2939 |
|
| 2940 |
bool needsHoleCheck = true; |
| 2941 |
auto* store = MStoreElement::NewBarriered(alloc(), elements, index, rhs, |
| 2942 |
needsHoleCheck); |
| 2943 |
addEffectful(store); |
| 2944 |
return resumeAfter(store); |
| 2945 |
} |
| 2946 |
|
| 2947 |
bool WarpCacheIRTranspiler::emitStoreDenseElementHole(ObjOperandId objId, |
| 2948 |
Int32OperandId indexId, |
| 2949 |
ValOperandId rhsId, |
| 2950 |
bool handleAdd) { |
| 2951 |
MDefinition* obj = getOperand(objId); |
| 2952 |
MDefinition* index = getOperand(indexId); |
| 2953 |
MDefinition* rhs = getOperand(rhsId); |
| 2954 |
|
| 2955 |
auto* elements = MElements::New(alloc(), obj); |
| 2956 |
add(elements); |
| 2957 |
|
| 2958 |
MInstruction* store; |
| 2959 |
if (handleAdd) { |
| 2960 |
// TODO(post-Warp): Consider changing MStoreElementHole to match IC code. |
| 2961 |
store = MStoreElementHole::New(alloc(), obj, elements, index, rhs); |
| 2962 |
} else { |
| 2963 |
auto* length = MInitializedLength::New(alloc(), elements); |
| 2964 |
add(length); |
| 2965 |
|
| 2966 |
index = addBoundsCheck(index, length); |
| 2967 |
|
| 2968 |
auto* barrier = MPostWriteElementBarrier::New(alloc(), obj, rhs, index); |
| 2969 |
add(barrier); |
| 2970 |
|
| 2971 |
bool needsHoleCheck = false; |
| 2972 |
store = MStoreElement::NewBarriered(alloc(), elements, index, rhs, |
| 2973 |
needsHoleCheck); |
| 2974 |
} |
| 2975 |
addEffectful(store); |
| 2976 |
|
| 2977 |
return resumeAfter(store); |
| 2978 |
} |
| 2979 |
|
| 2980 |
bool WarpCacheIRTranspiler::emitStoreTypedArrayElement( |
| 2981 |
ObjOperandId objId, Scalar::Type elementType, IntPtrOperandId indexId, |
| 2982 |
uint32_t rhsId, bool handleOOB, ArrayBufferViewKind viewKind) { |
| 2983 |
MDefinition* obj = getOperand(objId); |
| 2984 |
MDefinition* index = getOperand(indexId); |
| 2985 |
MDefinition* rhs = getOperand(ValOperandId(rhsId)); |
| 2986 |
|
| 2987 |
auto* length = emitTypedArrayLength(viewKind, obj); |
| 2988 |
|
| 2989 |
if (!handleOOB) { |
| 2990 |
// MStoreTypedArrayElementHole does the bounds checking. |
| 2991 |
index = addBoundsCheck(index, length); |
| 2992 |
} |
| 2993 |
|
| 2994 |
auto* elements = MArrayBufferViewElements::New(alloc(), obj); |
| 2995 |
add(elements); |
| 2996 |
|
| 2997 |
MInstruction* store; |
| 2998 |
if (handleOOB) { |
| 2999 |
store = MStoreTypedArrayElementHole::New(alloc(), elements, length, index, |
| 3000 |
rhs, elementType); |
| 3001 |
} else { |
| 3002 |
store = |
| 3003 |
MStoreUnboxedScalar::New(alloc(), elements, index, rhs, elementType); |
| 3004 |
} |
| 3005 |
addEffectful(store); |
| 3006 |
return resumeAfter(store); |
| 3007 |
} |
| 3008 |
|
| 3009 |
MInstruction* WarpCacheIRTranspiler::emitDataViewLength( |
| 3010 |
ArrayBufferViewKind viewKind, MDefinition* obj) { |
| 3011 |
if (viewKind == ArrayBufferViewKind::FixedLength) { |
| 3012 |
auto* length = MArrayBufferViewLength::New(alloc(), obj); |
| 3013 |
add(length); |
| 3014 |
|
| 3015 |
return length; |
| 3016 |
} |
| 3017 |
|
| 3018 |
// Bounds check doesn't require a memory barrier. See GetViewValue and |
| 3019 |
// SetViewValue abstract operations which read the underlying buffer byte |
| 3020 |
// length using "unordered" memory order. |
| 3021 |
auto barrier = MemoryBarrierRequirement::NotRequired; |
| 3022 |
|
| 3023 |
// Movable and removable because no memory barrier is needed. |
| 3024 |
auto* length = MResizableDataViewByteLength::New(alloc(), obj, barrier); |
| 3025 |
length->setMovable(); |
| 3026 |
length->setNotGuard(); |
| 3027 |
add(length); |
| 3028 |
|
| 3029 |
return length; |
| 3030 |
} |
| 3031 |
|
| 3032 |
void WarpCacheIRTranspiler::addDataViewData(ArrayBufferViewKind viewKind, |
| 3033 |
MDefinition* obj, Scalar::Type type, |
| 3034 |
MDefinition** offset, |
| 3035 |
MInstruction** elements) { |
| 3036 |
auto* length = emitDataViewLength(viewKind, obj); |
| 3037 |
|
| 3038 |
// Adjust the length to account for accesses near the end of the dataview. |
| 3039 |
if (size_t byteSize = Scalar::byteSize(type); byteSize > 1) { |
| 3040 |
// To ensure |0 <= offset && offset + byteSize <= length|, first adjust the |
| 3041 |
// length by subtracting |byteSize - 1| (bailing out if that becomes |
| 3042 |
// negative). |
| 3043 |
length = MAdjustDataViewLength::New(alloc(), length, byteSize); |
| 3044 |
add(length); |
| 3045 |
} |
| 3046 |
|
| 3047 |
*offset = addBoundsCheck(*offset, length); |
| 3048 |
|
| 3049 |
*elements = MArrayBufferViewElements::New(alloc(), obj); |
| 3050 |
add(*elements); |
| 3051 |
} |
| 3052 |
|
| 3053 |
bool WarpCacheIRTranspiler::emitLoadDataViewValueResult( |
| 3054 |
ObjOperandId objId, IntPtrOperandId offsetId, |
| 3055 |
BooleanOperandId littleEndianId, Scalar::Type elementType, |
| 3056 |
bool forceDoubleForUint32, ArrayBufferViewKind viewKind) { |
| 3057 |
MDefinition* obj = getOperand(objId); |
| 3058 |
MDefinition* offset = getOperand(offsetId); |
| 3059 |
MDefinition* littleEndian = getOperand(littleEndianId); |
| 3060 |
|
| 3061 |
// Add bounds check and get the DataViewObject's elements. |
| 3062 |
MInstruction* elements; |
| 3063 |
addDataViewData(viewKind, obj, elementType, &offset, &elements); |
| 3064 |
|
| 3065 |
// Load the element. |
| 3066 |
MInstruction* load; |
| 3067 |
if (Scalar::byteSize(elementType) == 1) { |
| 3068 |
load = MLoadUnboxedScalar::New(alloc(), elements, offset, elementType); |
| 3069 |
} else { |
| 3070 |
load = MLoadDataViewElement::New(alloc(), elements, offset, littleEndian, |
| 3071 |
elementType); |
| 3072 |
} |
| 3073 |
add(load); |
| 3074 |
|
| 3075 |
MIRType knownType = |
| 3076 |
MIRTypeForArrayBufferViewRead(elementType, forceDoubleForUint32); |
| 3077 |
load->setResultType(knownType); |
| 3078 |
|
| 3079 |
MInstruction* result = load; |
| 3080 |
if (Scalar::isBigIntType(elementType)) { |
| 3081 |
result = MInt64ToBigInt::New(alloc(), load, |
| 3082 |
Scalar::isSignedIntType(elementType)); |
| 3083 |
add(result); |
| 3084 |
} |
| 3085 |
|
| 3086 |
pushResult(result); |
| 3087 |
return true; |
| 3088 |
} |
| 3089 |
|
| 3090 |
bool WarpCacheIRTranspiler::emitStoreDataViewValueResult( |
| 3091 |
ObjOperandId objId, IntPtrOperandId offsetId, uint32_t valueId, |
| 3092 |
BooleanOperandId littleEndianId, Scalar::Type elementType, |
| 3093 |
ArrayBufferViewKind viewKind) { |
| 3094 |
MDefinition* obj = getOperand(objId); |
| 3095 |
MDefinition* offset = getOperand(offsetId); |
| 3096 |
MDefinition* value = getOperand(ValOperandId(valueId)); |
| 3097 |
MDefinition* littleEndian = getOperand(littleEndianId); |
| 3098 |
|
| 3099 |
// Add bounds check and get the DataViewObject's elements. |
| 3100 |
MInstruction* elements; |
| 3101 |
addDataViewData(viewKind, obj, elementType, &offset, &elements); |
| 3102 |
|
| 3103 |
// Store the element. |
| 3104 |
MInstruction* store; |
| 3105 |
if (Scalar::byteSize(elementType) == 1) { |
| 3106 |
store = |
| 3107 |
MStoreUnboxedScalar::New(alloc(), elements, offset, value, elementType); |
| 3108 |
} else { |
| 3109 |
store = MStoreDataViewElement::New(alloc(), elements, offset, value, |
| 3110 |
littleEndian, elementType); |
| 3111 |
} |
| 3112 |
addEffectful(store); |
| 3113 |
|
| 3114 |
pushResult(constant(UndefinedValue())); |
| 3115 |
|
| 3116 |
return resumeAfter(store); |
| 3117 |
} |
| 3118 |
|
| 3119 |
bool WarpCacheIRTranspiler::emitInt32IncResult(Int32OperandId inputId) { |
| 3120 |
MDefinition* input = getOperand(inputId); |
| 3121 |
|
| 3122 |
auto* constOne = MConstant::New(alloc(), Int32Value(1)); |
| 3123 |
add(constOne); |
| 3124 |
|
| 3125 |
auto* ins = MAdd::New(alloc(), input, constOne, MIRType::Int32); |
| 3126 |
add(ins); |
| 3127 |
|
| 3128 |
pushResult(ins); |
| 3129 |
return true; |
| 3130 |
} |
| 3131 |
|
| 3132 |
bool WarpCacheIRTranspiler::emitDoubleIncResult(NumberOperandId inputId) { |
| 3133 |
MDefinition* input = getOperand(inputId); |
| 3134 |
|
| 3135 |
auto* constOne = MConstant::New(alloc(), DoubleValue(1.0)); |
| 3136 |
add(constOne); |
| 3137 |
|
| 3138 |
auto* ins = MAdd::New(alloc(), input, constOne, MIRType::Double); |
| 3139 |
add(ins); |
| 3140 |
|
| 3141 |
pushResult(ins); |
| 3142 |
return true; |
| 3143 |
} |
| 3144 |
|
| 3145 |
bool WarpCacheIRTranspiler::emitInt32DecResult(Int32OperandId inputId) { |
| 3146 |
MDefinition* input = getOperand(inputId); |
| 3147 |
|
| 3148 |
auto* constOne = MConstant::New(alloc(), Int32Value(1)); |
| 3149 |
add(constOne); |
| 3150 |
|
| 3151 |
auto* ins = MSub::New(alloc(), input, constOne, MIRType::Int32); |
| 3152 |
add(ins); |
| 3153 |
|
| 3154 |
pushResult(ins); |
| 3155 |
return true; |
| 3156 |
} |
| 3157 |
|
| 3158 |
bool WarpCacheIRTranspiler::emitDoubleDecResult(NumberOperandId inputId) { |
| 3159 |
MDefinition* input = getOperand(inputId); |
| 3160 |
|
| 3161 |
auto* constOne = MConstant::New(alloc(), DoubleValue(1.0)); |
| 3162 |
add(constOne); |
| 3163 |
|
| 3164 |
auto* ins = MSub::New(alloc(), input, constOne, MIRType::Double); |
| 3165 |
add(ins); |
| 3166 |
|
| 3167 |
pushResult(ins); |
| 3168 |
return true; |
| 3169 |
} |
| 3170 |
|
| 3171 |
bool WarpCacheIRTranspiler::emitInt32NegationResult(Int32OperandId inputId) { |
| 3172 |
MDefinition* input = getOperand(inputId); |
| 3173 |
|
| 3174 |
auto* constNegOne = MConstant::New(alloc(), Int32Value(-1)); |
| 3175 |
add(constNegOne); |
| 3176 |
|
| 3177 |
auto* ins = MMul::New(alloc(), input, constNegOne, MIRType::Int32); |
| 3178 |
add(ins); |
| 3179 |
|
| 3180 |
pushResult(ins); |
| 3181 |
return true; |
| 3182 |
} |
| 3183 |
|
| 3184 |
bool WarpCacheIRTranspiler::emitDoubleNegationResult(NumberOperandId inputId) { |
| 3185 |
MDefinition* input = getOperand(inputId); |
| 3186 |
|
| 3187 |
auto* constNegOne = MConstant::New(alloc(), DoubleValue(-1.0)); |
| 3188 |
add(constNegOne); |
| 3189 |
|
| 3190 |
auto* ins = MMul::New(alloc(), input, constNegOne, MIRType::Double); |
| 3191 |
add(ins); |
| 3192 |
|
| 3193 |
pushResult(ins); |
| 3194 |
return true; |
| 3195 |
} |
| 3196 |
|
| 3197 |
bool WarpCacheIRTranspiler::emitInt32NotResult(Int32OperandId inputId) { |
| 3198 |
MDefinition* input = getOperand(inputId); |
| 3199 |
|
| 3200 |
auto* ins = MBitNot::New(alloc(), input, MIRType::Int32); |
| 3201 |
add(ins); |
| 3202 |
|
| 3203 |
pushResult(ins); |
| 3204 |
return true; |
| 3205 |
} |
| 3206 |
|
| 3207 |
template <typename T> |
| 3208 |
bool WarpCacheIRTranspiler::emitDoubleBinaryArithResult(NumberOperandId lhsId, |
| 3209 |
NumberOperandId rhsId) { |
| 3210 |
MDefinition* lhs = getOperand(lhsId); |
| 3211 |
MDefinition* rhs = getOperand(rhsId); |
| 3212 |
|
| 3213 |
auto* ins = T::New(alloc(), lhs, rhs, MIRType::Double); |
| 3214 |
add(ins); |
| 3215 |
|
| 3216 |
pushResult(ins); |
| 3217 |
return true; |
| 3218 |
} |
| 3219 |
|
| 3220 |
bool WarpCacheIRTranspiler::emitDoubleAddResult(NumberOperandId lhsId, |
| 3221 |
NumberOperandId rhsId) { |
| 3222 |
return emitDoubleBinaryArithResult<MAdd>(lhsId, rhsId); |
| 3223 |
} |
| 3224 |
|
| 3225 |
bool WarpCacheIRTranspiler::emitDoubleSubResult(NumberOperandId lhsId, |
| 3226 |
NumberOperandId rhsId) { |
| 3227 |
return emitDoubleBinaryArithResult<MSub>(lhsId, rhsId); |
| 3228 |
} |
| 3229 |
|
| 3230 |
bool WarpCacheIRTranspiler::emitDoubleMulResult(NumberOperandId lhsId, |
| 3231 |
NumberOperandId rhsId) { |
| 3232 |
return emitDoubleBinaryArithResult<MMul>(lhsId, rhsId); |
| 3233 |
} |
| 3234 |
|
| 3235 |
bool WarpCacheIRTranspiler::emitDoubleDivResult(NumberOperandId lhsId, |
| 3236 |
NumberOperandId rhsId) { |
| 3237 |
return emitDoubleBinaryArithResult<MDiv>(lhsId, rhsId); |
| 3238 |
} |
| 3239 |
|
| 3240 |
bool WarpCacheIRTranspiler::emitDoubleModResult(NumberOperandId lhsId, |
| 3241 |
NumberOperandId rhsId) { |
| 3242 |
return emitDoubleBinaryArithResult<MMod>(lhsId, rhsId); |
| 3243 |
} |
| 3244 |
|
| 3245 |
bool WarpCacheIRTranspiler::emitDoublePowResult(NumberOperandId lhsId, |
| 3246 |
NumberOperandId rhsId) { |
| 3247 |
return emitDoubleBinaryArithResult<MPow>(lhsId, rhsId); |
| 3248 |
} |
| 3249 |
|
| 3250 |
template <typename T> |
| 3251 |
bool WarpCacheIRTranspiler::emitInt32BinaryArithResult(Int32OperandId lhsId, |
| 3252 |
Int32OperandId rhsId) { |
| 3253 |
MDefinition* lhs = getOperand(lhsId); |
| 3254 |
MDefinition* rhs = getOperand(rhsId); |
| 3255 |
|
| 3256 |
auto* ins = T::New(alloc(), lhs, rhs, MIRType::Int32); |
| 3257 |
add(ins); |
| 3258 |
|
| 3259 |
pushResult(ins); |
| 3260 |
return true; |
| 3261 |
} |
| 3262 |
|
| 3263 |
bool WarpCacheIRTranspiler::emitInt32AddResult(Int32OperandId lhsId, |
| 3264 |
Int32OperandId rhsId) { |
| 3265 |
return emitInt32BinaryArithResult<MAdd>(lhsId, rhsId); |
| 3266 |
} |
| 3267 |
|
| 3268 |
bool WarpCacheIRTranspiler::emitInt32SubResult(Int32OperandId lhsId, |
| 3269 |
Int32OperandId rhsId) { |
| 3270 |
return emitInt32BinaryArithResult<MSub>(lhsId, rhsId); |
| 3271 |
} |
| 3272 |
|
| 3273 |
bool WarpCacheIRTranspiler::emitInt32MulResult(Int32OperandId lhsId, |
| 3274 |
Int32OperandId rhsId) { |
| 3275 |
return emitInt32BinaryArithResult<MMul>(lhsId, rhsId); |
| 3276 |
} |
| 3277 |
|
| 3278 |
bool WarpCacheIRTranspiler::emitInt32DivResult(Int32OperandId lhsId, |
| 3279 |
Int32OperandId rhsId) { |
| 3280 |
return emitInt32BinaryArithResult<MDiv>(lhsId, rhsId); |
| 3281 |
} |
| 3282 |
|
| 3283 |
bool WarpCacheIRTranspiler::emitInt32ModResult(Int32OperandId lhsId, |
| 3284 |
Int32OperandId rhsId) { |
| 3285 |
return emitInt32BinaryArithResult<MMod>(lhsId, rhsId); |
| 3286 |
} |
| 3287 |
|
| 3288 |
bool WarpCacheIRTranspiler::emitInt32PowResult(Int32OperandId lhsId, |
| 3289 |
Int32OperandId rhsId) { |
| 3290 |
return emitInt32BinaryArithResult<MPow>(lhsId, rhsId); |
| 3291 |
} |
| 3292 |
|
| 3293 |
bool WarpCacheIRTranspiler::emitInt32BitOrResult(Int32OperandId lhsId, |
| 3294 |
Int32OperandId rhsId) { |
| 3295 |
return emitInt32BinaryArithResult<MBitOr>(lhsId, rhsId); |
| 3296 |
} |
| 3297 |
|
| 3298 |
bool WarpCacheIRTranspiler::emitInt32BitXorResult(Int32OperandId lhsId, |
| 3299 |
Int32OperandId rhsId) { |
| 3300 |
return emitInt32BinaryArithResult<MBitXor>(lhsId, rhsId); |
| 3301 |
} |
| 3302 |
|
| 3303 |
bool WarpCacheIRTranspiler::emitInt32BitAndResult(Int32OperandId lhsId, |
| 3304 |
Int32OperandId rhsId) { |
| 3305 |
return emitInt32BinaryArithResult<MBitAnd>(lhsId, rhsId); |
| 3306 |
} |
| 3307 |
|
| 3308 |
bool WarpCacheIRTranspiler::emitInt32LeftShiftResult(Int32OperandId lhsId, |
| 3309 |
Int32OperandId rhsId) { |
| 3310 |
return emitInt32BinaryArithResult<MLsh>(lhsId, rhsId); |
| 3311 |
} |
| 3312 |
|
| 3313 |
bool WarpCacheIRTranspiler::emitInt32RightShiftResult(Int32OperandId lhsId, |
| 3314 |
Int32OperandId rhsId) { |
| 3315 |
return emitInt32BinaryArithResult<MRsh>(lhsId, rhsId); |
| 3316 |
} |
| 3317 |
|
| 3318 |
bool WarpCacheIRTranspiler::emitInt32URightShiftResult(Int32OperandId lhsId, |
| 3319 |
Int32OperandId rhsId, |
| 3320 |
bool forceDouble) { |
| 3321 |
MDefinition* lhs = getOperand(lhsId); |
| 3322 |
MDefinition* rhs = getOperand(rhsId); |
| 3323 |
|
| 3324 |
MIRType specialization = forceDouble ? MIRType::Double : MIRType::Int32; |
| 3325 |
auto* ins = MUrsh::New(alloc(), lhs, rhs, specialization); |
| 3326 |
add(ins); |
| 3327 |
|
| 3328 |
pushResult(ins); |
| 3329 |
return true; |
| 3330 |
} |
| 3331 |
|
| 3332 |
template <typename T> |
| 3333 |
bool WarpCacheIRTranspiler::emitBigIntBinaryArithResult(BigIntOperandId lhsId, |
| 3334 |
BigIntOperandId rhsId) { |
| 3335 |
MDefinition* lhs = getOperand(lhsId); |
| 3336 |
MDefinition* rhs = getOperand(rhsId); |
| 3337 |
|
| 3338 |
auto* ins = T::New(alloc(), lhs, rhs); |
| 3339 |
add(ins); |
| 3340 |
|
| 3341 |
pushResult(ins); |
| 3342 |
return true; |
| 3343 |
} |
| 3344 |
|
| 3345 |
bool WarpCacheIRTranspiler::emitBigIntAddResult(BigIntOperandId lhsId, |
| 3346 |
BigIntOperandId rhsId) { |
| 3347 |
return emitBigIntBinaryArithResult<MBigIntAdd>(lhsId, rhsId); |
| 3348 |
} |
| 3349 |
|
| 3350 |
bool WarpCacheIRTranspiler::emitBigIntSubResult(BigIntOperandId lhsId, |
| 3351 |
BigIntOperandId rhsId) { |
| 3352 |
return emitBigIntBinaryArithResult<MBigIntSub>(lhsId, rhsId); |
| 3353 |
} |
| 3354 |
|
| 3355 |
bool WarpCacheIRTranspiler::emitBigIntMulResult(BigIntOperandId lhsId, |
| 3356 |
BigIntOperandId rhsId) { |
| 3357 |
return emitBigIntBinaryArithResult<MBigIntMul>(lhsId, rhsId); |
| 3358 |
} |
| 3359 |
|
| 3360 |
template <typename T> |
| 3361 |
bool WarpCacheIRTranspiler::emitBigIntBinaryArithEffectfulResult( |
| 3362 |
BigIntOperandId lhsId, BigIntOperandId rhsId) { |
| 3363 |
MDefinition* lhs = getOperand(lhsId); |
| 3364 |
MDefinition* rhs = getOperand(rhsId); |
| 3365 |
|
| 3366 |
auto* ins = T::New(alloc(), lhs, rhs); |
| 3367 |
|
| 3368 |
if (ins->isEffectful()) { |
| 3369 |
addEffectful(ins); |
| 3370 |
|
| 3371 |
pushResult(ins); |
| 3372 |
return resumeAfter(ins); |
| 3373 |
} |
| 3374 |
|
| 3375 |
add(ins); |
| 3376 |
|
| 3377 |
pushResult(ins); |
| 3378 |
return true; |
| 3379 |
} |
| 3380 |
|
| 3381 |
bool WarpCacheIRTranspiler::emitBigIntDivResult(BigIntOperandId lhsId, |
| 3382 |
BigIntOperandId rhsId) { |
| 3383 |
return emitBigIntBinaryArithEffectfulResult<MBigIntDiv>(lhsId, rhsId); |
| 3384 |
} |
| 3385 |
|
| 3386 |
bool WarpCacheIRTranspiler::emitBigIntModResult(BigIntOperandId lhsId, |
| 3387 |
BigIntOperandId rhsId) { |
| 3388 |
return emitBigIntBinaryArithEffectfulResult<MBigIntMod>(lhsId, rhsId); |
| 3389 |
} |
| 3390 |
|
| 3391 |
bool WarpCacheIRTranspiler::emitBigIntPowResult(BigIntOperandId lhsId, |
| 3392 |
BigIntOperandId rhsId) { |
| 3393 |
return emitBigIntBinaryArithEffectfulResult<MBigIntPow>(lhsId, rhsId); |
| 3394 |
} |
| 3395 |
|
| 3396 |
bool WarpCacheIRTranspiler::emitBigIntBitAndResult(BigIntOperandId lhsId, |
| 3397 |
BigIntOperandId rhsId) { |
| 3398 |
return emitBigIntBinaryArithResult<MBigIntBitAnd>(lhsId, rhsId); |
| 3399 |
} |
| 3400 |
|
| 3401 |
bool WarpCacheIRTranspiler::emitBigIntBitOrResult(BigIntOperandId lhsId, |
| 3402 |
BigIntOperandId rhsId) { |
| 3403 |
return emitBigIntBinaryArithResult<MBigIntBitOr>(lhsId, rhsId); |
| 3404 |
} |
| 3405 |
|
| 3406 |
bool WarpCacheIRTranspiler::emitBigIntBitXorResult(BigIntOperandId lhsId, |
| 3407 |
BigIntOperandId rhsId) { |
| 3408 |
return emitBigIntBinaryArithResult<MBigIntBitXor>(lhsId, rhsId); |
| 3409 |
} |
| 3410 |
|
| 3411 |
bool WarpCacheIRTranspiler::emitBigIntLeftShiftResult(BigIntOperandId lhsId, |
| 3412 |
BigIntOperandId rhsId) { |
| 3413 |
return emitBigIntBinaryArithResult<MBigIntLsh>(lhsId, rhsId); |
| 3414 |
} |
| 3415 |
|
| 3416 |
bool WarpCacheIRTranspiler::emitBigIntRightShiftResult(BigIntOperandId lhsId, |
| 3417 |
BigIntOperandId rhsId) { |
| 3418 |
return emitBigIntBinaryArithResult<MBigIntRsh>(lhsId, rhsId); |
| 3419 |
} |
| 3420 |
|
| 3421 |
template <typename T> |
| 3422 |
bool WarpCacheIRTranspiler::emitBigIntUnaryArithResult( |
| 3423 |
BigIntOperandId inputId) { |
| 3424 |
MDefinition* input = getOperand(inputId); |
| 3425 |
|
| 3426 |
auto* ins = T::New(alloc(), input); |
| 3427 |
add(ins); |
| 3428 |
|
| 3429 |
pushResult(ins); |
| 3430 |
return true; |
| 3431 |
} |
| 3432 |
|
| 3433 |
bool WarpCacheIRTranspiler::emitBigIntIncResult(BigIntOperandId inputId) { |
| 3434 |
return emitBigIntUnaryArithResult<MBigIntIncrement>(inputId); |
| 3435 |
} |
| 3436 |
|
| 3437 |
bool WarpCacheIRTranspiler::emitBigIntDecResult(BigIntOperandId inputId) { |
| 3438 |
return emitBigIntUnaryArithResult<MBigIntDecrement>(inputId); |
| 3439 |
} |
| 3440 |
|
| 3441 |
bool WarpCacheIRTranspiler::emitBigIntNegationResult(BigIntOperandId inputId) { |
| 3442 |
return emitBigIntUnaryArithResult<MBigIntNegate>(inputId); |
| 3443 |
} |
| 3444 |
|
| 3445 |
bool WarpCacheIRTranspiler::emitBigIntNotResult(BigIntOperandId inputId) { |
| 3446 |
return emitBigIntUnaryArithResult<MBigIntBitNot>(inputId); |
| 3447 |
} |
| 3448 |
|
| 3449 |
bool WarpCacheIRTranspiler::emitBigIntToIntPtr(BigIntOperandId inputId, |
| 3450 |
IntPtrOperandId resultId) { |
| 3451 |
MDefinition* input = getOperand(inputId); |
| 3452 |
|
| 3453 |
auto* ins = MBigIntToIntPtr::New(alloc(), input); |
| 3454 |
add(ins); |
| 3455 |
|
| 3456 |
return defineOperand(resultId, ins); |
| 3457 |
} |
| 3458 |
|
| 3459 |
bool WarpCacheIRTranspiler::emitIntPtrToBigIntResult(IntPtrOperandId inputId) { |
| 3460 |
MDefinition* input = getOperand(inputId); |
| 3461 |
|
| 3462 |
auto* ins = MIntPtrToBigInt::New(alloc(), input); |
| 3463 |
add(ins); |
| 3464 |
|
| 3465 |
pushResult(ins); |
| 3466 |
return true; |
| 3467 |
} |
| 3468 |
|
| 3469 |
template <typename T> |
| 3470 |
bool WarpCacheIRTranspiler::emitBigIntPtrBinaryArith(IntPtrOperandId lhsId, |
| 3471 |
IntPtrOperandId rhsId, |
| 3472 |
IntPtrOperandId resultId) { |
| 3473 |
MDefinition* lhs = getOperand(lhsId); |
| 3474 |
MDefinition* rhs = getOperand(rhsId); |
| 3475 |
|
| 3476 |
auto* ins = T::New(alloc(), lhs, rhs); |
| 3477 |
add(ins); |
| 3478 |
|
| 3479 |
return defineOperand(resultId, ins); |
| 3480 |
} |
| 3481 |
|
| 3482 |
bool WarpCacheIRTranspiler::emitBigIntPtrAdd(IntPtrOperandId lhsId, |
| 3483 |
IntPtrOperandId rhsId, |
| 3484 |
IntPtrOperandId resultId) { |
| 3485 |
return emitBigIntPtrBinaryArith<MBigIntPtrAdd>(lhsId, rhsId, resultId); |
| 3486 |
} |
| 3487 |
|
| 3488 |
bool WarpCacheIRTranspiler::emitBigIntPtrSub(IntPtrOperandId lhsId, |
| 3489 |
IntPtrOperandId rhsId, |
| 3490 |
IntPtrOperandId resultId) { |
| 3491 |
return emitBigIntPtrBinaryArith<MBigIntPtrSub>(lhsId, rhsId, resultId); |
| 3492 |
} |
| 3493 |
|
| 3494 |
bool WarpCacheIRTranspiler::emitBigIntPtrMul(IntPtrOperandId lhsId, |
| 3495 |
IntPtrOperandId rhsId, |
| 3496 |
IntPtrOperandId resultId) { |
| 3497 |
return emitBigIntPtrBinaryArith<MBigIntPtrMul>(lhsId, rhsId, resultId); |
| 3498 |
} |
| 3499 |
|
| 3500 |
bool WarpCacheIRTranspiler::emitBigIntPtrDiv(IntPtrOperandId lhsId, |
| 3501 |
IntPtrOperandId rhsId, |
| 3502 |
IntPtrOperandId resultId) { |
| 3503 |
return emitBigIntPtrBinaryArith<MBigIntPtrDiv>(lhsId, rhsId, resultId); |
| 3504 |
} |
| 3505 |
|
| 3506 |
bool WarpCacheIRTranspiler::emitBigIntPtrMod(IntPtrOperandId lhsId, |
| 3507 |
IntPtrOperandId rhsId, |
| 3508 |
IntPtrOperandId resultId) { |
| 3509 |
return emitBigIntPtrBinaryArith<MBigIntPtrMod>(lhsId, rhsId, resultId); |
| 3510 |
} |
| 3511 |
|
| 3512 |
bool WarpCacheIRTranspiler::emitBigIntPtrPow(IntPtrOperandId lhsId, |
| 3513 |
IntPtrOperandId rhsId, |
| 3514 |
IntPtrOperandId resultId) { |
| 3515 |
return emitBigIntPtrBinaryArith<MBigIntPtrPow>(lhsId, rhsId, resultId); |
| 3516 |
} |
| 3517 |
|
| 3518 |
bool WarpCacheIRTranspiler::emitBigIntPtrBitOr(IntPtrOperandId lhsId, |
| 3519 |
IntPtrOperandId rhsId, |
| 3520 |
IntPtrOperandId resultId) { |
| 3521 |
return emitBigIntPtrBinaryArith<MBigIntPtrBitOr>(lhsId, rhsId, resultId); |
| 3522 |
} |
| 3523 |
|
| 3524 |
bool WarpCacheIRTranspiler::emitBigIntPtrBitXor(IntPtrOperandId lhsId, |
| 3525 |
IntPtrOperandId rhsId, |
| 3526 |
IntPtrOperandId resultId) { |
| 3527 |
return emitBigIntPtrBinaryArith<MBigIntPtrBitXor>(lhsId, rhsId, resultId); |
| 3528 |
} |
| 3529 |
|
| 3530 |
bool WarpCacheIRTranspiler::emitBigIntPtrBitAnd(IntPtrOperandId lhsId, |
| 3531 |
IntPtrOperandId rhsId, |
| 3532 |
IntPtrOperandId resultId) { |
| 3533 |
return emitBigIntPtrBinaryArith<MBigIntPtrBitAnd>(lhsId, rhsId, resultId); |
| 3534 |
} |
| 3535 |
|
| 3536 |
bool WarpCacheIRTranspiler::emitBigIntPtrLeftShift(IntPtrOperandId lhsId, |
| 3537 |
IntPtrOperandId rhsId, |
| 3538 |
IntPtrOperandId resultId) { |
| 3539 |
return emitBigIntPtrBinaryArith<MBigIntPtrLsh>(lhsId, rhsId, resultId); |
| 3540 |
} |
| 3541 |
|
| 3542 |
bool WarpCacheIRTranspiler::emitBigIntPtrRightShift(IntPtrOperandId lhsId, |
| 3543 |
IntPtrOperandId rhsId, |
| 3544 |
IntPtrOperandId resultId) { |
| 3545 |
return emitBigIntPtrBinaryArith<MBigIntPtrRsh>(lhsId, rhsId, resultId); |
| 3546 |
} |
| 3547 |
|
| 3548 |
bool WarpCacheIRTranspiler::emitBigIntPtrInc(IntPtrOperandId inputId, |
| 3549 |
IntPtrOperandId resultId) { |
| 3550 |
MDefinition* input = getOperand(inputId); |
| 3551 |
|
| 3552 |
auto* constOne = MConstant::NewIntPtr(alloc(), 1); |
| 3553 |
add(constOne); |
| 3554 |
|
| 3555 |
auto* ins = MBigIntPtrAdd::New(alloc(), input, constOne); |
| 3556 |
add(ins); |
| 3557 |
|
| 3558 |
return defineOperand(resultId, ins); |
| 3559 |
} |
| 3560 |
|
| 3561 |
bool WarpCacheIRTranspiler::emitBigIntPtrDec(IntPtrOperandId inputId, |
| 3562 |
IntPtrOperandId resultId) { |
| 3563 |
MDefinition* input = getOperand(inputId); |
| 3564 |
|
| 3565 |
auto* constOne = MConstant::NewIntPtr(alloc(), 1); |
| 3566 |
add(constOne); |
| 3567 |
|
| 3568 |
auto* ins = MBigIntPtrSub::New(alloc(), input, constOne); |
| 3569 |
add(ins); |
| 3570 |
|
| 3571 |
return defineOperand(resultId, ins); |
| 3572 |
} |
| 3573 |
|
| 3574 |
bool WarpCacheIRTranspiler::emitBigIntPtrNegation(IntPtrOperandId inputId, |
| 3575 |
IntPtrOperandId resultId) { |
| 3576 |
MDefinition* input = getOperand(inputId); |
| 3577 |
|
| 3578 |
auto* constNegOne = MConstant::NewIntPtr(alloc(), -1); |
| 3579 |
add(constNegOne); |
| 3580 |
|
| 3581 |
auto* ins = MBigIntPtrMul::New(alloc(), input, constNegOne); |
| 3582 |
add(ins); |
| 3583 |
|
| 3584 |
return defineOperand(resultId, ins); |
| 3585 |
} |
| 3586 |
|
| 3587 |
bool WarpCacheIRTranspiler::emitBigIntPtrNot(IntPtrOperandId inputId, |
| 3588 |
IntPtrOperandId resultId) { |
| 3589 |
MDefinition* input = getOperand(inputId); |
| 3590 |
|
| 3591 |
auto* ins = MBigIntPtrBitNot::New(alloc(), input); |
| 3592 |
add(ins); |
| 3593 |
|
| 3594 |
return defineOperand(resultId, ins); |
| 3595 |
} |
| 3596 |
|
| 3597 |
bool WarpCacheIRTranspiler::emitConcatStringsResult(StringOperandId lhsId, |
| 3598 |
StringOperandId rhsId, |
| 3599 |
uint32_t stubOffset) { |
| 3600 |
MDefinition* lhs = getOperand(lhsId); |
| 3601 |
MDefinition* rhs = getOperand(rhsId); |
| 3602 |
|
| 3603 |
auto* ins = MConcat::New(alloc(), lhs, rhs); |
| 3604 |
add(ins); |
| 3605 |
|
| 3606 |
pushResult(ins); |
| 3607 |
return true; |
| 3608 |
} |
| 3609 |
|
| 3610 |
bool WarpCacheIRTranspiler::emitCompareResult( |
| 3611 |
JSOp op, OperandId lhsId, OperandId rhsId, |
| 3612 |
MCompare::CompareType compareType) { |
| 3613 |
MDefinition* lhs = getOperand(lhsId); |
| 3614 |
MDefinition* rhs = getOperand(rhsId); |
| 3615 |
|
| 3616 |
auto* ins = MCompare::New(alloc(), lhs, rhs, op, compareType); |
| 3617 |
add(ins); |
| 3618 |
|
| 3619 |
pushResult(ins); |
| 3620 |
return true; |
| 3621 |
} |
| 3622 |
|
| 3623 |
bool WarpCacheIRTranspiler::emitCompareInt32Result(JSOp op, |
| 3624 |
Int32OperandId lhsId, |
| 3625 |
Int32OperandId rhsId) { |
| 3626 |
return emitCompareResult(op, lhsId, rhsId, MCompare::Compare_Int32); |
| 3627 |
} |
| 3628 |
|
| 3629 |
bool WarpCacheIRTranspiler::emitCompareDoubleResult(JSOp op, |
| 3630 |
NumberOperandId lhsId, |
| 3631 |
NumberOperandId rhsId) { |
| 3632 |
return emitCompareResult(op, lhsId, rhsId, MCompare::Compare_Double); |
| 3633 |
} |
| 3634 |
|
| 3635 |
bool WarpCacheIRTranspiler::emitCompareObjectResult(JSOp op, ObjOperandId lhsId, |
| 3636 |
ObjOperandId rhsId) { |
| 3637 |
MOZ_ASSERT(IsEqualityOp(op)); |
| 3638 |
return emitCompareResult(op, lhsId, rhsId, MCompare::Compare_Object); |
| 3639 |
} |
| 3640 |
|
| 3641 |
bool WarpCacheIRTranspiler::emitCompareStringResult(JSOp op, |
| 3642 |
StringOperandId lhsId, |
| 3643 |
StringOperandId rhsId) { |
| 3644 |
return emitCompareResult(op, lhsId, rhsId, MCompare::Compare_String); |
| 3645 |
} |
| 3646 |
|
| 3647 |
bool WarpCacheIRTranspiler::emitCompareSymbolResult(JSOp op, |
| 3648 |
SymbolOperandId lhsId, |
| 3649 |
SymbolOperandId rhsId) { |
| 3650 |
MOZ_ASSERT(IsEqualityOp(op)); |
| 3651 |
return emitCompareResult(op, lhsId, rhsId, MCompare::Compare_Symbol); |
| 3652 |
} |
| 3653 |
|
| 3654 |
bool WarpCacheIRTranspiler::emitCompareBigIntResult(JSOp op, |
| 3655 |
BigIntOperandId lhsId, |
| 3656 |
BigIntOperandId rhsId) { |
| 3657 |
return emitCompareResult(op, lhsId, rhsId, MCompare::Compare_BigInt); |
| 3658 |
} |
| 3659 |
|
| 3660 |
bool WarpCacheIRTranspiler::emitCompareBigIntInt32Result(JSOp op, |
| 3661 |
BigIntOperandId lhsId, |
| 3662 |
Int32OperandId rhsId) { |
| 3663 |
return emitCompareResult(op, lhsId, rhsId, MCompare::Compare_BigInt_Int32); |
| 3664 |
} |
| 3665 |
|
| 3666 |
bool WarpCacheIRTranspiler::emitCompareBigIntNumberResult( |
| 3667 |
JSOp op, BigIntOperandId lhsId, NumberOperandId rhsId) { |
| 3668 |
return emitCompareResult(op, lhsId, rhsId, MCompare::Compare_BigInt_Double); |
| 3669 |
} |
| 3670 |
|
| 3671 |
bool WarpCacheIRTranspiler::emitCompareBigIntStringResult( |
| 3672 |
JSOp op, BigIntOperandId lhsId, StringOperandId rhsId) { |
| 3673 |
return emitCompareResult(op, lhsId, rhsId, MCompare::Compare_BigInt_String); |
| 3674 |
} |
| 3675 |
|
| 3676 |
bool WarpCacheIRTranspiler::emitCompareNullUndefinedResult( |
| 3677 |
JSOp op, bool isUndefined, ValOperandId inputId) { |
| 3678 |
MDefinition* input = getOperand(inputId); |
| 3679 |
|
| 3680 |
MOZ_ASSERT(IsEqualityOp(op)); |
| 3681 |
|
| 3682 |
// A previously emitted guard ensures that one side of the comparison |
| 3683 |
// is null or undefined. |
| 3684 |
MDefinition* cst = |
| 3685 |
isUndefined ? constant(UndefinedValue()) : constant(NullValue()); |
| 3686 |
auto compareType = |
| 3687 |
isUndefined ? MCompare::Compare_Undefined : MCompare::Compare_Null; |
| 3688 |
auto* ins = MCompare::New(alloc(), input, cst, op, compareType); |
| 3689 |
add(ins); |
| 3690 |
|
| 3691 |
pushResult(ins); |
| 3692 |
return true; |
| 3693 |
} |
| 3694 |
|
| 3695 |
bool WarpCacheIRTranspiler::emitCompareDoubleSameValueResult( |
| 3696 |
NumberOperandId lhsId, NumberOperandId rhsId) { |
| 3697 |
MDefinition* lhs = getOperand(lhsId); |
| 3698 |
MDefinition* rhs = getOperand(rhsId); |
| 3699 |
|
| 3700 |
auto* sameValue = MSameValueDouble::New(alloc(), lhs, rhs); |
| 3701 |
add(sameValue); |
| 3702 |
|
| 3703 |
pushResult(sameValue); |
| 3704 |
return true; |
| 3705 |
} |
| 3706 |
|
| 3707 |
bool WarpCacheIRTranspiler::emitSameValueResult(ValOperandId lhsId, |
| 3708 |
ValOperandId rhsId) { |
| 3709 |
MDefinition* lhs = getOperand(lhsId); |
| 3710 |
MDefinition* rhs = getOperand(rhsId); |
| 3711 |
|
| 3712 |
auto* sameValue = MSameValue::New(alloc(), lhs, rhs); |
| 3713 |
add(sameValue); |
| 3714 |
|
| 3715 |
pushResult(sameValue); |
| 3716 |
return true; |
| 3717 |
} |
| 3718 |
|
| 3719 |
bool WarpCacheIRTranspiler::emitIndirectTruncateInt32Result( |
| 3720 |
Int32OperandId valId) { |
| 3721 |
MDefinition* val = getOperand(valId); |
| 3722 |
MOZ_ASSERT(val->type() == MIRType::Int32); |
| 3723 |
|
| 3724 |
auto* truncate = |
| 3725 |
MLimitedTruncate::New(alloc(), val, TruncateKind::IndirectTruncate); |
| 3726 |
add(truncate); |
| 3727 |
|
| 3728 |
pushResult(truncate); |
| 3729 |
return true; |
| 3730 |
} |
| 3731 |
|
| 3732 |
bool WarpCacheIRTranspiler::emitMathHypot2NumberResult( |
| 3733 |
NumberOperandId firstId, NumberOperandId secondId) { |
| 3734 |
MDefinitionVector vector(alloc()); |
| 3735 |
if (!vector.reserve(2)) { |
| 3736 |
return false; |
| 3737 |
} |
| 3738 |
|
| 3739 |
vector.infallibleAppend(getOperand(firstId)); |
| 3740 |
vector.infallibleAppend(getOperand(secondId)); |
| 3741 |
|
| 3742 |
auto* ins = MHypot::New(alloc(), vector); |
| 3743 |
if (!ins) { |
| 3744 |
return false; |
| 3745 |
} |
| 3746 |
add(ins); |
| 3747 |
|
| 3748 |
pushResult(ins); |
| 3749 |
return true; |
| 3750 |
} |
| 3751 |
|
| 3752 |
bool WarpCacheIRTranspiler::emitMathHypot3NumberResult( |
| 3753 |
NumberOperandId firstId, NumberOperandId secondId, |
| 3754 |
NumberOperandId thirdId) { |
| 3755 |
MDefinitionVector vector(alloc()); |
| 3756 |
if (!vector.reserve(3)) { |
| 3757 |
return false; |
| 3758 |
} |
| 3759 |
|
| 3760 |
vector.infallibleAppend(getOperand(firstId)); |
| 3761 |
vector.infallibleAppend(getOperand(secondId)); |
| 3762 |
vector.infallibleAppend(getOperand(thirdId)); |
| 3763 |
|
| 3764 |
auto* ins = MHypot::New(alloc(), vector); |
| 3765 |
if (!ins) { |
| 3766 |
return false; |
| 3767 |
} |
| 3768 |
add(ins); |
| 3769 |
|
| 3770 |
pushResult(ins); |
| 3771 |
return true; |
| 3772 |
} |
| 3773 |
|
| 3774 |
bool WarpCacheIRTranspiler::emitMathHypot4NumberResult( |
| 3775 |
NumberOperandId firstId, NumberOperandId secondId, NumberOperandId thirdId, |
| 3776 |
NumberOperandId fourthId) { |
| 3777 |
MDefinitionVector vector(alloc()); |
| 3778 |
if (!vector.reserve(4)) { |
| 3779 |
return false; |
| 3780 |
} |
| 3781 |
|
| 3782 |
vector.infallibleAppend(getOperand(firstId)); |
| 3783 |
vector.infallibleAppend(getOperand(secondId)); |
| 3784 |
vector.infallibleAppend(getOperand(thirdId)); |
| 3785 |
vector.infallibleAppend(getOperand(fourthId)); |
| 3786 |
|
| 3787 |
auto* ins = MHypot::New(alloc(), vector); |
| 3788 |
if (!ins) { |
| 3789 |
return false; |
| 3790 |
} |
| 3791 |
add(ins); |
| 3792 |
|
| 3793 |
pushResult(ins); |
| 3794 |
return true; |
| 3795 |
} |
| 3796 |
|
| 3797 |
bool WarpCacheIRTranspiler::emitMathRandomResult(uint32_t rngOffset) { |
| 3798 |
#ifdef DEBUG |
| 3799 |
// CodeGenerator uses CompileRealm::addressOfRandomNumberGenerator. Assert it |
| 3800 |
// matches the RNG pointer stored in the stub field. |
| 3801 |
const void* rng = rawPointerField(rngOffset); |
| 3802 |
MOZ_ASSERT(rng == mirGen().realm->addressOfRandomNumberGenerator()); |
| 3803 |
#endif |
| 3804 |
|
| 3805 |
auto* ins = MRandom::New(alloc()); |
| 3806 |
addEffectful(ins); |
| 3807 |
|
| 3808 |
pushResult(ins); |
| 3809 |
return resumeAfter(ins); |
| 3810 |
} |
| 3811 |
|
| 3812 |
bool WarpCacheIRTranspiler::emitInt32MinMax(bool isMax, Int32OperandId firstId, |
| 3813 |
Int32OperandId secondId, |
| 3814 |
Int32OperandId resultId) { |
| 3815 |
MDefinition* first = getOperand(firstId); |
| 3816 |
MDefinition* second = getOperand(secondId); |
| 3817 |
|
| 3818 |
auto* ins = MMinMax::New(alloc(), first, second, MIRType::Int32, isMax); |
| 3819 |
add(ins); |
| 3820 |
|
| 3821 |
return defineOperand(resultId, ins); |
| 3822 |
} |
| 3823 |
|
| 3824 |
bool WarpCacheIRTranspiler::emitNumberMinMax(bool isMax, |
| 3825 |
NumberOperandId firstId, |
| 3826 |
NumberOperandId secondId, |
| 3827 |
NumberOperandId resultId) { |
| 3828 |
MDefinition* first = getOperand(firstId); |
| 3829 |
MDefinition* second = getOperand(secondId); |
| 3830 |
|
| 3831 |
auto* ins = MMinMax::New(alloc(), first, second, MIRType::Double, isMax); |
| 3832 |
add(ins); |
| 3833 |
|
| 3834 |
return defineOperand(resultId, ins); |
| 3835 |
} |
| 3836 |
|
| 3837 |
bool WarpCacheIRTranspiler::emitInt32MinMaxArrayResult(ObjOperandId arrayId, |
| 3838 |
bool isMax) { |
| 3839 |
MDefinition* array = getOperand(arrayId); |
| 3840 |
|
| 3841 |
auto* ins = MMinMaxArray::New(alloc(), array, MIRType::Int32, isMax); |
| 3842 |
add(ins); |
| 3843 |
|
| 3844 |
pushResult(ins); |
| 3845 |
return true; |
| 3846 |
} |
| 3847 |
|
| 3848 |
bool WarpCacheIRTranspiler::emitNumberMinMaxArrayResult(ObjOperandId arrayId, |
| 3849 |
bool isMax) { |
| 3850 |
MDefinition* array = getOperand(arrayId); |
| 3851 |
|
| 3852 |
auto* ins = MMinMaxArray::New(alloc(), array, MIRType::Double, isMax); |
| 3853 |
add(ins); |
| 3854 |
|
| 3855 |
pushResult(ins); |
| 3856 |
return true; |
| 3857 |
} |
| 3858 |
|
| 3859 |
bool WarpCacheIRTranspiler::emitMathAbsInt32Result(Int32OperandId inputId) { |
| 3860 |
MDefinition* input = getOperand(inputId); |
| 3861 |
|
| 3862 |
auto* ins = MAbs::New(alloc(), input, MIRType::Int32); |
| 3863 |
add(ins); |
| 3864 |
|
| 3865 |
pushResult(ins); |
| 3866 |
return true; |
| 3867 |
} |
| 3868 |
|
| 3869 |
bool WarpCacheIRTranspiler::emitMathAbsNumberResult(NumberOperandId inputId) { |
| 3870 |
MDefinition* input = getOperand(inputId); |
| 3871 |
|
| 3872 |
auto* ins = MAbs::New(alloc(), input, MIRType::Double); |
| 3873 |
add(ins); |
| 3874 |
|
| 3875 |
pushResult(ins); |
| 3876 |
return true; |
| 3877 |
} |
| 3878 |
|
| 3879 |
bool WarpCacheIRTranspiler::emitMathClz32Result(Int32OperandId inputId) { |
| 3880 |
MDefinition* input = getOperand(inputId); |
| 3881 |
|
| 3882 |
auto* ins = MClz::New(alloc(), input, MIRType::Int32); |
| 3883 |
add(ins); |
| 3884 |
|
| 3885 |
pushResult(ins); |
| 3886 |
return true; |
| 3887 |
} |
| 3888 |
|
| 3889 |
bool WarpCacheIRTranspiler::emitMathSignInt32Result(Int32OperandId inputId) { |
| 3890 |
MDefinition* input = getOperand(inputId); |
| 3891 |
|
| 3892 |
auto* ins = MSign::New(alloc(), input, MIRType::Int32); |
| 3893 |
add(ins); |
| 3894 |
|
| 3895 |
pushResult(ins); |
| 3896 |
return true; |
| 3897 |
} |
| 3898 |
|
| 3899 |
bool WarpCacheIRTranspiler::emitMathSignNumberResult(NumberOperandId inputId) { |
| 3900 |
MDefinition* input = getOperand(inputId); |
| 3901 |
|
| 3902 |
auto* ins = MSign::New(alloc(), input, MIRType::Double); |
| 3903 |
add(ins); |
| 3904 |
|
| 3905 |
pushResult(ins); |
| 3906 |
return true; |
| 3907 |
} |
| 3908 |
|
| 3909 |
bool WarpCacheIRTranspiler::emitMathSignNumberToInt32Result( |
| 3910 |
NumberOperandId inputId) { |
| 3911 |
MDefinition* input = getOperand(inputId); |
| 3912 |
|
| 3913 |
auto* ins = MSign::New(alloc(), input, MIRType::Int32); |
| 3914 |
add(ins); |
| 3915 |
|
| 3916 |
pushResult(ins); |
| 3917 |
return true; |
| 3918 |
} |
| 3919 |
|
| 3920 |
bool WarpCacheIRTranspiler::emitMathImulResult(Int32OperandId lhsId, |
| 3921 |
Int32OperandId rhsId) { |
| 3922 |
MDefinition* lhs = getOperand(lhsId); |
| 3923 |
MDefinition* rhs = getOperand(rhsId); |
| 3924 |
|
| 3925 |
auto* ins = MMul::New(alloc(), lhs, rhs, MIRType::Int32, MMul::Integer); |
| 3926 |
add(ins); |
| 3927 |
|
| 3928 |
pushResult(ins); |
| 3929 |
return true; |
| 3930 |
} |
| 3931 |
|
| 3932 |
bool WarpCacheIRTranspiler::emitMathFloorToInt32Result( |
| 3933 |
NumberOperandId inputId) { |
| 3934 |
MDefinition* input = getOperand(inputId); |
| 3935 |
|
| 3936 |
auto* ins = MFloor::New(alloc(), input); |
| 3937 |
add(ins); |
| 3938 |
|
| 3939 |
pushResult(ins); |
| 3940 |
return true; |
| 3941 |
} |
| 3942 |
|
| 3943 |
bool WarpCacheIRTranspiler::emitMathCeilToInt32Result(NumberOperandId inputId) { |
| 3944 |
MDefinition* input = getOperand(inputId); |
| 3945 |
|
| 3946 |
auto* ins = MCeil::New(alloc(), input); |
| 3947 |
add(ins); |
| 3948 |
|
| 3949 |
pushResult(ins); |
| 3950 |
return true; |
| 3951 |
} |
| 3952 |
|
| 3953 |
bool WarpCacheIRTranspiler::emitMathTruncToInt32Result( |
| 3954 |
NumberOperandId inputId) { |
| 3955 |
MDefinition* input = getOperand(inputId); |
| 3956 |
|
| 3957 |
auto* ins = MTrunc::New(alloc(), input); |
| 3958 |
add(ins); |
| 3959 |
|
| 3960 |
pushResult(ins); |
| 3961 |
return true; |
| 3962 |
} |
| 3963 |
|
| 3964 |
bool WarpCacheIRTranspiler::emitMathRoundToInt32Result( |
| 3965 |
NumberOperandId inputId) { |
| 3966 |
MDefinition* input = getOperand(inputId); |
| 3967 |
|
| 3968 |
auto* ins = MRound::New(alloc(), input); |
| 3969 |
add(ins); |
| 3970 |
|
| 3971 |
pushResult(ins); |
| 3972 |
return true; |
| 3973 |
} |
| 3974 |
|
| 3975 |
bool WarpCacheIRTranspiler::emitMathSqrtNumberResult(NumberOperandId inputId) { |
| 3976 |
MDefinition* input = getOperand(inputId); |
| 3977 |
|
| 3978 |
auto* ins = MSqrt::New(alloc(), input, MIRType::Double); |
| 3979 |
add(ins); |
| 3980 |
|
| 3981 |
pushResult(ins); |
| 3982 |
return true; |
| 3983 |
} |
| 3984 |
|
| 3985 |
bool WarpCacheIRTranspiler::emitMathFRoundNumberResult( |
| 3986 |
NumberOperandId inputId) { |
| 3987 |
MDefinition* input = getOperand(inputId); |
| 3988 |
|
| 3989 |
auto* ins = MToFloat32::New(alloc(), input); |
| 3990 |
add(ins); |
| 3991 |
|
| 3992 |
pushResult(ins); |
| 3993 |
return true; |
| 3994 |
} |
| 3995 |
|
| 3996 |
bool WarpCacheIRTranspiler::emitMathF16RoundNumberResult( |
| 3997 |
NumberOperandId inputId) { |
| 3998 |
MDefinition* input = getOperand(inputId); |
| 3999 |
|
| 4000 |
auto* ins = MToFloat16::New(alloc(), input); |
| 4001 |
add(ins); |
| 4002 |
|
| 4003 |
pushResult(ins); |
| 4004 |
return true; |
| 4005 |
} |
| 4006 |
|
| 4007 |
bool WarpCacheIRTranspiler::emitMathAtan2NumberResult(NumberOperandId yId, |
| 4008 |
NumberOperandId xId) { |
| 4009 |
MDefinition* y = getOperand(yId); |
| 4010 |
MDefinition* x = getOperand(xId); |
| 4011 |
|
| 4012 |
auto* ins = MAtan2::New(alloc(), y, x); |
| 4013 |
add(ins); |
| 4014 |
|
| 4015 |
pushResult(ins); |
| 4016 |
return true; |
| 4017 |
} |
| 4018 |
|
| 4019 |
bool WarpCacheIRTranspiler::emitMathFunctionNumberResult( |
| 4020 |
NumberOperandId inputId, UnaryMathFunction fun) { |
| 4021 |
MDefinition* input = getOperand(inputId); |
| 4022 |
|
| 4023 |
auto* ins = MMathFunction::New(alloc(), input, fun); |
| 4024 |
add(ins); |
| 4025 |
|
| 4026 |
pushResult(ins); |
| 4027 |
return true; |
| 4028 |
} |
| 4029 |
|
| 4030 |
bool WarpCacheIRTranspiler::emitMathFloorNumberResult(NumberOperandId inputId) { |
| 4031 |
MDefinition* input = getOperand(inputId); |
| 4032 |
|
| 4033 |
MInstruction* ins; |
| 4034 |
if (MNearbyInt::HasAssemblerSupport(RoundingMode::Down)) { |
| 4035 |
ins = MNearbyInt::New(alloc(), input, MIRType::Double, RoundingMode::Down); |
| 4036 |
} else { |
| 4037 |
ins = MMathFunction::New(alloc(), input, UnaryMathFunction::Floor); |
| 4038 |
} |
| 4039 |
add(ins); |
| 4040 |
|
| 4041 |
pushResult(ins); |
| 4042 |
return true; |
| 4043 |
} |
| 4044 |
|
| 4045 |
bool WarpCacheIRTranspiler::emitMathCeilNumberResult(NumberOperandId inputId) { |
| 4046 |
MDefinition* input = getOperand(inputId); |
| 4047 |
|
| 4048 |
MInstruction* ins; |
| 4049 |
if (MNearbyInt::HasAssemblerSupport(RoundingMode::Up)) { |
| 4050 |
ins = MNearbyInt::New(alloc(), input, MIRType::Double, RoundingMode::Up); |
| 4051 |
} else { |
| 4052 |
ins = MMathFunction::New(alloc(), input, UnaryMathFunction::Ceil); |
| 4053 |
} |
| 4054 |
add(ins); |
| 4055 |
|
| 4056 |
pushResult(ins); |
| 4057 |
return true; |
| 4058 |
} |
| 4059 |
|
| 4060 |
bool WarpCacheIRTranspiler::emitMathTruncNumberResult(NumberOperandId inputId) { |
| 4061 |
MDefinition* input = getOperand(inputId); |
| 4062 |
|
| 4063 |
MInstruction* ins; |
| 4064 |
if (MNearbyInt::HasAssemblerSupport(RoundingMode::TowardsZero)) { |
| 4065 |
ins = MNearbyInt::New(alloc(), input, MIRType::Double, |
| 4066 |
RoundingMode::TowardsZero); |
| 4067 |
} else { |
| 4068 |
ins = MMathFunction::New(alloc(), input, UnaryMathFunction::Trunc); |
| 4069 |
} |
| 4070 |
add(ins); |
| 4071 |
|
| 4072 |
pushResult(ins); |
| 4073 |
return true; |
| 4074 |
} |
| 4075 |
|
| 4076 |
bool WarpCacheIRTranspiler::emitNumberParseIntResult(StringOperandId strId, |
| 4077 |
Int32OperandId radixId) { |
| 4078 |
MDefinition* str = getOperand(strId); |
| 4079 |
MDefinition* radix = getOperand(radixId); |
| 4080 |
|
| 4081 |
auto* ins = MNumberParseInt::New(alloc(), str, radix); |
| 4082 |
add(ins); |
| 4083 |
|
| 4084 |
pushResult(ins); |
| 4085 |
return true; |
| 4086 |
} |
| 4087 |
|
| 4088 |
bool WarpCacheIRTranspiler::emitDoubleParseIntResult(NumberOperandId numId) { |
| 4089 |
MDefinition* num = getOperand(numId); |
| 4090 |
|
| 4091 |
auto* ins = MDoubleParseInt::New(alloc(), num); |
| 4092 |
add(ins); |
| 4093 |
|
| 4094 |
pushResult(ins); |
| 4095 |
return true; |
| 4096 |
} |
| 4097 |
|
| 4098 |
bool WarpCacheIRTranspiler::emitObjectToStringResult(ObjOperandId objId) { |
| 4099 |
MDefinition* obj = getOperand(objId); |
| 4100 |
|
| 4101 |
auto* ins = MObjectClassToString::New(alloc(), obj); |
| 4102 |
add(ins); |
| 4103 |
|
| 4104 |
pushResult(ins); |
| 4105 |
return true; |
| 4106 |
} |
| 4107 |
|
| 4108 |
bool WarpCacheIRTranspiler::emitReflectGetPrototypeOfResult( |
| 4109 |
ObjOperandId objId) { |
| 4110 |
MDefinition* obj = getOperand(objId); |
| 4111 |
|
| 4112 |
auto* ins = MGetPrototypeOf::New(alloc(), obj); |
| 4113 |
addEffectful(ins); |
| 4114 |
pushResult(ins); |
| 4115 |
|
| 4116 |
return resumeAfter(ins); |
| 4117 |
} |
| 4118 |
|
| 4119 |
bool WarpCacheIRTranspiler::emitArrayPush(ObjOperandId objId, |
| 4120 |
ValOperandId rhsId) { |
| 4121 |
MDefinition* obj = getOperand(objId); |
| 4122 |
MDefinition* value = getOperand(rhsId); |
| 4123 |
|
| 4124 |
auto* ins = MArrayPush::New(alloc(), obj, value); |
| 4125 |
addEffectful(ins); |
| 4126 |
pushResult(ins); |
| 4127 |
|
| 4128 |
return resumeAfter(ins); |
| 4129 |
} |
| 4130 |
|
| 4131 |
bool WarpCacheIRTranspiler::emitArrayJoinResult(ObjOperandId objId, |
| 4132 |
StringOperandId sepId) { |
| 4133 |
MDefinition* obj = getOperand(objId); |
| 4134 |
MDefinition* sep = getOperand(sepId); |
| 4135 |
|
| 4136 |
auto* join = MArrayJoin::New(alloc(), obj, sep); |
| 4137 |
addEffectful(join); |
| 4138 |
|
| 4139 |
pushResult(join); |
| 4140 |
return resumeAfter(join); |
| 4141 |
} |
| 4142 |
|
| 4143 |
bool WarpCacheIRTranspiler::emitObjectKeysResult(ObjOperandId objId) { |
| 4144 |
MDefinition* obj = getOperand(objId); |
| 4145 |
|
| 4146 |
auto* join = MObjectKeys::New(alloc(), obj); |
| 4147 |
addEffectful(join); |
| 4148 |
|
| 4149 |
pushResult(join); |
| 4150 |
return resumeAfter(join); |
| 4151 |
} |
| 4152 |
|
| 4153 |
bool WarpCacheIRTranspiler::emitPackedArrayPopResult(ObjOperandId arrayId) { |
| 4154 |
MDefinition* array = getOperand(arrayId); |
| 4155 |
|
| 4156 |
auto* ins = MArrayPopShift::New(alloc(), array, MArrayPopShift::Pop); |
| 4157 |
addEffectful(ins); |
| 4158 |
|
| 4159 |
pushResult(ins); |
| 4160 |
return resumeAfter(ins); |
| 4161 |
} |
| 4162 |
|
| 4163 |
bool WarpCacheIRTranspiler::emitPackedArrayShiftResult(ObjOperandId arrayId) { |
| 4164 |
MDefinition* array = getOperand(arrayId); |
| 4165 |
|
| 4166 |
auto* ins = MArrayPopShift::New(alloc(), array, MArrayPopShift::Shift); |
| 4167 |
addEffectful(ins); |
| 4168 |
|
| 4169 |
pushResult(ins); |
| 4170 |
return resumeAfter(ins); |
| 4171 |
} |
| 4172 |
|
| 4173 |
bool WarpCacheIRTranspiler::emitPackedArraySliceResult( |
| 4174 |
uint32_t templateObjectOffset, ObjOperandId arrayId, Int32OperandId beginId, |
| 4175 |
Int32OperandId endId) { |
| 4176 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 4177 |
|
| 4178 |
MDefinition* array = getOperand(arrayId); |
| 4179 |
MDefinition* begin = getOperand(beginId); |
| 4180 |
MDefinition* end = getOperand(endId); |
| 4181 |
|
| 4182 |
// TODO: support pre-tenuring. |
| 4183 |
gc::Heap heap = gc::Heap::Default; |
| 4184 |
|
| 4185 |
auto* ins = MArraySlice::New(alloc(), array, begin, end, templateObj, heap); |
| 4186 |
addEffectful(ins); |
| 4187 |
|
| 4188 |
pushResult(ins); |
| 4189 |
return resumeAfter(ins); |
| 4190 |
} |
| 4191 |
|
| 4192 |
bool WarpCacheIRTranspiler::emitArgumentsSliceResult( |
| 4193 |
uint32_t templateObjectOffset, ObjOperandId argsId, Int32OperandId beginId, |
| 4194 |
Int32OperandId endId) { |
| 4195 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 4196 |
|
| 4197 |
MDefinition* args = getOperand(argsId); |
| 4198 |
MDefinition* begin = getOperand(beginId); |
| 4199 |
MDefinition* end = getOperand(endId); |
| 4200 |
|
| 4201 |
// TODO: support pre-tenuring. |
| 4202 |
gc::Heap heap = gc::Heap::Default; |
| 4203 |
|
| 4204 |
auto* ins = |
| 4205 |
MArgumentsSlice::New(alloc(), args, begin, end, templateObj, heap); |
| 4206 |
addEffectful(ins); |
| 4207 |
|
| 4208 |
pushResult(ins); |
| 4209 |
return resumeAfter(ins); |
| 4210 |
} |
| 4211 |
|
| 4212 |
bool WarpCacheIRTranspiler::emitHasClassResult(ObjOperandId objId, |
| 4213 |
uint32_t claspOffset) { |
| 4214 |
MDefinition* obj = getOperand(objId); |
| 4215 |
const JSClass* clasp = classStubField(claspOffset); |
| 4216 |
|
| 4217 |
auto* hasClass = MHasClass::New(alloc(), obj, clasp); |
| 4218 |
add(hasClass); |
| 4219 |
|
| 4220 |
pushResult(hasClass); |
| 4221 |
return true; |
| 4222 |
} |
| 4223 |
|
| 4224 |
bool WarpCacheIRTranspiler::emitHasShapeResult(ObjOperandId objId, |
| 4225 |
uint32_t shapeOffset) { |
| 4226 |
MDefinition* obj = getOperand(objId); |
| 4227 |
Shape* shape = shapeStubField(shapeOffset); |
| 4228 |
|
| 4229 |
auto* hasShape = MHasShape::New(alloc(), obj, shape); |
| 4230 |
add(hasShape); |
| 4231 |
|
| 4232 |
pushResult(hasShape); |
| 4233 |
return true; |
| 4234 |
} |
| 4235 |
|
| 4236 |
bool WarpCacheIRTranspiler::emitCallRegExpMatcherResult( |
| 4237 |
ObjOperandId regexpId, StringOperandId inputId, Int32OperandId lastIndexId, |
| 4238 |
uint32_t stubOffset) { |
| 4239 |
MDefinition* regexp = getOperand(regexpId); |
| 4240 |
MDefinition* input = getOperand(inputId); |
| 4241 |
MDefinition* lastIndex = getOperand(lastIndexId); |
| 4242 |
|
| 4243 |
auto* matcher = MRegExpMatcher::New(alloc(), regexp, input, lastIndex); |
| 4244 |
addEffectful(matcher); |
| 4245 |
pushResult(matcher); |
| 4246 |
|
| 4247 |
return resumeAfter(matcher); |
| 4248 |
} |
| 4249 |
|
| 4250 |
bool WarpCacheIRTranspiler::emitCallRegExpSearcherResult( |
| 4251 |
ObjOperandId regexpId, StringOperandId inputId, Int32OperandId lastIndexId, |
| 4252 |
uint32_t stubOffset) { |
| 4253 |
MDefinition* regexp = getOperand(regexpId); |
| 4254 |
MDefinition* input = getOperand(inputId); |
| 4255 |
MDefinition* lastIndex = getOperand(lastIndexId); |
| 4256 |
|
| 4257 |
auto* searcher = MRegExpSearcher::New(alloc(), regexp, input, lastIndex); |
| 4258 |
addEffectful(searcher); |
| 4259 |
pushResult(searcher); |
| 4260 |
|
| 4261 |
return resumeAfter(searcher); |
| 4262 |
} |
| 4263 |
|
| 4264 |
bool WarpCacheIRTranspiler::emitRegExpSearcherLastLimitResult() { |
| 4265 |
auto* limit = MRegExpSearcherLastLimit::New(alloc()); |
| 4266 |
addEffectful(limit); |
| 4267 |
pushResult(limit); |
| 4268 |
|
| 4269 |
return resumeAfter(limit); |
| 4270 |
} |
| 4271 |
|
| 4272 |
bool WarpCacheIRTranspiler::emitRegExpBuiltinExecMatchResult( |
| 4273 |
ObjOperandId regexpId, StringOperandId inputId, uint32_t stubOffset) { |
| 4274 |
MDefinition* regexp = getOperand(regexpId); |
| 4275 |
MDefinition* input = getOperand(inputId); |
| 4276 |
|
| 4277 |
auto* ins = MRegExpExecMatch::New(alloc(), regexp, input); |
| 4278 |
addEffectful(ins); |
| 4279 |
pushResult(ins); |
| 4280 |
|
| 4281 |
return resumeAfter(ins); |
| 4282 |
} |
| 4283 |
|
| 4284 |
bool WarpCacheIRTranspiler::emitRegExpBuiltinExecTestResult( |
| 4285 |
ObjOperandId regexpId, StringOperandId inputId, uint32_t stubOffset) { |
| 4286 |
MDefinition* regexp = getOperand(regexpId); |
| 4287 |
MDefinition* input = getOperand(inputId); |
| 4288 |
|
| 4289 |
auto* ins = MRegExpExecTest::New(alloc(), regexp, input); |
| 4290 |
addEffectful(ins); |
| 4291 |
pushResult(ins); |
| 4292 |
|
| 4293 |
return resumeAfter(ins); |
| 4294 |
} |
| 4295 |
|
| 4296 |
bool WarpCacheIRTranspiler::emitRegExpHasCaptureGroupsResult( |
| 4297 |
ObjOperandId regexpId, StringOperandId inputId) { |
| 4298 |
MDefinition* regexp = getOperand(regexpId); |
| 4299 |
MDefinition* input = getOperand(inputId); |
| 4300 |
|
| 4301 |
auto* result = MRegExpHasCaptureGroups::New(alloc(), regexp, input); |
| 4302 |
addEffectful(result); |
| 4303 |
pushResult(result); |
| 4304 |
|
| 4305 |
return resumeAfter(result); |
| 4306 |
} |
| 4307 |
|
| 4308 |
MInstruction* WarpCacheIRTranspiler::convertToBoolean(MDefinition* input) { |
| 4309 |
// Convert to bool with the '!!' idiom. |
| 4310 |
// |
| 4311 |
// The FoldTests and GVN passes both specifically handle this pattern. If you |
| 4312 |
// change this code, make sure to update FoldTests and GVN, too. |
| 4313 |
|
| 4314 |
auto* resultInverted = MNot::New(alloc(), input); |
| 4315 |
add(resultInverted); |
| 4316 |
auto* result = MNot::New(alloc(), resultInverted); |
| 4317 |
add(result); |
| 4318 |
|
| 4319 |
return result; |
| 4320 |
} |
| 4321 |
|
| 4322 |
bool WarpCacheIRTranspiler::emitRegExpFlagResult(ObjOperandId regexpId, |
| 4323 |
int32_t flagsMask) { |
| 4324 |
MDefinition* regexp = getOperand(regexpId); |
| 4325 |
|
| 4326 |
auto* flags = MLoadFixedSlot::New(alloc(), regexp, RegExpObject::flagsSlot()); |
| 4327 |
flags->setResultType(MIRType::Int32); |
| 4328 |
add(flags); |
| 4329 |
|
| 4330 |
auto* mask = MConstant::New(alloc(), Int32Value(flagsMask)); |
| 4331 |
add(mask); |
| 4332 |
|
| 4333 |
auto* maskedFlag = MBitAnd::New(alloc(), flags, mask, MIRType::Int32); |
| 4334 |
add(maskedFlag); |
| 4335 |
|
| 4336 |
auto* result = convertToBoolean(maskedFlag); |
| 4337 |
|
| 4338 |
pushResult(result); |
| 4339 |
return true; |
| 4340 |
} |
| 4341 |
|
| 4342 |
bool WarpCacheIRTranspiler::emitCallSubstringKernelResult( |
| 4343 |
StringOperandId strId, Int32OperandId beginId, Int32OperandId lengthId) { |
| 4344 |
MDefinition* str = getOperand(strId); |
| 4345 |
MDefinition* begin = getOperand(beginId); |
| 4346 |
MDefinition* length = getOperand(lengthId); |
| 4347 |
|
| 4348 |
auto* substr = MSubstr::New(alloc(), str, begin, length); |
| 4349 |
add(substr); |
| 4350 |
|
| 4351 |
pushResult(substr); |
| 4352 |
return true; |
| 4353 |
} |
| 4354 |
|
| 4355 |
bool WarpCacheIRTranspiler::emitStringReplaceStringResult( |
| 4356 |
StringOperandId strId, StringOperandId patternId, |
| 4357 |
StringOperandId replacementId) { |
| 4358 |
MDefinition* str = getOperand(strId); |
| 4359 |
MDefinition* pattern = getOperand(patternId); |
| 4360 |
MDefinition* replacement = getOperand(replacementId); |
| 4361 |
|
| 4362 |
auto* replace = MStringReplace::New(alloc(), str, pattern, replacement); |
| 4363 |
add(replace); |
| 4364 |
|
| 4365 |
pushResult(replace); |
| 4366 |
return true; |
| 4367 |
} |
| 4368 |
|
| 4369 |
bool WarpCacheIRTranspiler::emitStringSplitStringResult( |
| 4370 |
StringOperandId strId, StringOperandId separatorId) { |
| 4371 |
MDefinition* str = getOperand(strId); |
| 4372 |
MDefinition* separator = getOperand(separatorId); |
| 4373 |
|
| 4374 |
auto* split = MStringSplit::New(alloc(), str, separator); |
| 4375 |
add(split); |
| 4376 |
|
| 4377 |
pushResult(split); |
| 4378 |
return true; |
| 4379 |
} |
| 4380 |
|
| 4381 |
bool WarpCacheIRTranspiler::emitGetFirstDollarIndexResult( |
| 4382 |
StringOperandId strId) { |
| 4383 |
MDefinition* str = getOperand(strId); |
| 4384 |
|
| 4385 |
auto* firstDollarIndex = MGetFirstDollarIndex::New(alloc(), str); |
| 4386 |
add(firstDollarIndex); |
| 4387 |
|
| 4388 |
pushResult(firstDollarIndex); |
| 4389 |
return true; |
| 4390 |
} |
| 4391 |
|
| 4392 |
bool WarpCacheIRTranspiler::emitIsArrayResult(ValOperandId inputId) { |
| 4393 |
MDefinition* value = getOperand(inputId); |
| 4394 |
|
| 4395 |
auto* isArray = MIsArray::New(alloc(), value); |
| 4396 |
addEffectful(isArray); |
| 4397 |
pushResult(isArray); |
| 4398 |
|
| 4399 |
return resumeAfter(isArray); |
| 4400 |
} |
| 4401 |
|
| 4402 |
bool WarpCacheIRTranspiler::emitIsObjectResult(ValOperandId inputId) { |
| 4403 |
MDefinition* value = getOperand(inputId); |
| 4404 |
|
| 4405 |
if (value->type() == MIRType::Object) { |
| 4406 |
pushResult(constant(BooleanValue(true))); |
| 4407 |
} else { |
| 4408 |
auto* isObject = MIsObject::New(alloc(), value); |
| 4409 |
add(isObject); |
| 4410 |
pushResult(isObject); |
| 4411 |
} |
| 4412 |
|
| 4413 |
return true; |
| 4414 |
} |
| 4415 |
|
| 4416 |
bool WarpCacheIRTranspiler::emitIsPackedArrayResult(ObjOperandId objId) { |
| 4417 |
MDefinition* obj = getOperand(objId); |
| 4418 |
|
| 4419 |
auto* isPackedArray = MIsPackedArray::New(alloc(), obj); |
| 4420 |
add(isPackedArray); |
| 4421 |
|
| 4422 |
pushResult(isPackedArray); |
| 4423 |
return true; |
| 4424 |
} |
| 4425 |
|
| 4426 |
bool WarpCacheIRTranspiler::emitIsCallableResult(ValOperandId inputId) { |
| 4427 |
MDefinition* value = getOperand(inputId); |
| 4428 |
|
| 4429 |
auto* isCallable = MIsCallable::New(alloc(), value); |
| 4430 |
add(isCallable); |
| 4431 |
|
| 4432 |
pushResult(isCallable); |
| 4433 |
return true; |
| 4434 |
} |
| 4435 |
|
| 4436 |
bool WarpCacheIRTranspiler::emitIsConstructorResult(ObjOperandId objId) { |
| 4437 |
MDefinition* obj = getOperand(objId); |
| 4438 |
|
| 4439 |
auto* isConstructor = MIsConstructor::New(alloc(), obj); |
| 4440 |
add(isConstructor); |
| 4441 |
|
| 4442 |
pushResult(isConstructor); |
| 4443 |
return true; |
| 4444 |
} |
| 4445 |
|
| 4446 |
bool WarpCacheIRTranspiler::emitIsCrossRealmArrayConstructorResult( |
| 4447 |
ObjOperandId objId) { |
| 4448 |
MDefinition* obj = getOperand(objId); |
| 4449 |
|
| 4450 |
auto* ins = MIsCrossRealmArrayConstructor::New(alloc(), obj); |
| 4451 |
add(ins); |
| 4452 |
|
| 4453 |
pushResult(ins); |
| 4454 |
return true; |
| 4455 |
} |
| 4456 |
|
| 4457 |
bool WarpCacheIRTranspiler::emitIsTypedArrayResult(ObjOperandId objId, |
| 4458 |
bool isPossiblyWrapped) { |
| 4459 |
MDefinition* obj = getOperand(objId); |
| 4460 |
|
| 4461 |
auto* ins = MIsTypedArray::New(alloc(), obj, isPossiblyWrapped); |
| 4462 |
if (isPossiblyWrapped) { |
| 4463 |
addEffectful(ins); |
| 4464 |
} else { |
| 4465 |
add(ins); |
| 4466 |
} |
| 4467 |
|
| 4468 |
pushResult(ins); |
| 4469 |
|
| 4470 |
if (isPossiblyWrapped) { |
| 4471 |
if (!resumeAfter(ins)) { |
| 4472 |
return false; |
| 4473 |
} |
| 4474 |
} |
| 4475 |
|
| 4476 |
return true; |
| 4477 |
} |
| 4478 |
|
| 4479 |
bool WarpCacheIRTranspiler::emitArrayBufferViewByteOffsetInt32Result( |
| 4480 |
ObjOperandId objId) { |
| 4481 |
MDefinition* obj = getOperand(objId); |
| 4482 |
|
| 4483 |
auto* byteOffset = MArrayBufferViewByteOffset::New(alloc(), obj); |
| 4484 |
add(byteOffset); |
| 4485 |
|
| 4486 |
auto* byteOffsetInt32 = MNonNegativeIntPtrToInt32::New(alloc(), byteOffset); |
| 4487 |
add(byteOffsetInt32); |
| 4488 |
|
| 4489 |
pushResult(byteOffsetInt32); |
| 4490 |
return true; |
| 4491 |
} |
| 4492 |
|
| 4493 |
bool WarpCacheIRTranspiler::emitArrayBufferViewByteOffsetDoubleResult( |
| 4494 |
ObjOperandId objId) { |
| 4495 |
MDefinition* obj = getOperand(objId); |
| 4496 |
|
| 4497 |
auto* byteOffset = MArrayBufferViewByteOffset::New(alloc(), obj); |
| 4498 |
add(byteOffset); |
| 4499 |
|
| 4500 |
auto* byteOffsetDouble = MIntPtrToDouble::New(alloc(), byteOffset); |
| 4501 |
add(byteOffsetDouble); |
| 4502 |
|
| 4503 |
pushResult(byteOffsetDouble); |
| 4504 |
return true; |
| 4505 |
} |
| 4506 |
|
| 4507 |
bool WarpCacheIRTranspiler:: |
| 4508 |
emitResizableTypedArrayByteOffsetMaybeOutOfBoundsInt32Result( |
| 4509 |
ObjOperandId objId) { |
| 4510 |
MDefinition* obj = getOperand(objId); |
| 4511 |
|
| 4512 |
auto* byteOffset = |
| 4513 |
MResizableTypedArrayByteOffsetMaybeOutOfBounds::New(alloc(), obj); |
| 4514 |
add(byteOffset); |
| 4515 |
|
| 4516 |
auto* byteOffsetInt32 = MNonNegativeIntPtrToInt32::New(alloc(), byteOffset); |
| 4517 |
add(byteOffsetInt32); |
| 4518 |
|
| 4519 |
pushResult(byteOffsetInt32); |
| 4520 |
return true; |
| 4521 |
} |
| 4522 |
|
| 4523 |
bool WarpCacheIRTranspiler:: |
| 4524 |
emitResizableTypedArrayByteOffsetMaybeOutOfBoundsDoubleResult( |
| 4525 |
ObjOperandId objId) { |
| 4526 |
MDefinition* obj = getOperand(objId); |
| 4527 |
|
| 4528 |
auto* byteOffset = |
| 4529 |
MResizableTypedArrayByteOffsetMaybeOutOfBounds::New(alloc(), obj); |
| 4530 |
add(byteOffset); |
| 4531 |
|
| 4532 |
auto* byteOffsetDouble = MIntPtrToDouble::New(alloc(), byteOffset); |
| 4533 |
add(byteOffsetDouble); |
| 4534 |
|
| 4535 |
pushResult(byteOffsetDouble); |
| 4536 |
return true; |
| 4537 |
} |
| 4538 |
|
| 4539 |
bool WarpCacheIRTranspiler::emitResizableTypedArrayLengthInt32Result( |
| 4540 |
ObjOperandId objId) { |
| 4541 |
MDefinition* obj = getOperand(objId); |
| 4542 |
|
| 4543 |
// Explicit |length| accesses are seq-consistent atomic loads. |
| 4544 |
auto barrier = MemoryBarrierRequirement::Required; |
| 4545 |
|
| 4546 |
auto* length = MResizableTypedArrayLength::New(alloc(), obj, barrier); |
| 4547 |
addEffectful(length); |
| 4548 |
|
| 4549 |
auto* lengthInt32 = MNonNegativeIntPtrToInt32::New(alloc(), length); |
| 4550 |
add(lengthInt32); |
| 4551 |
|
| 4552 |
auto* postConversion = MPostIntPtrConversion::New(alloc(), lengthInt32); |
| 4553 |
add(postConversion); |
| 4554 |
|
| 4555 |
pushResult(postConversion); |
| 4556 |
return resumeAfterUnchecked(postConversion); |
| 4557 |
} |
| 4558 |
|
| 4559 |
bool WarpCacheIRTranspiler::emitResizableTypedArrayLengthDoubleResult( |
| 4560 |
ObjOperandId objId) { |
| 4561 |
MDefinition* obj = getOperand(objId); |
| 4562 |
|
| 4563 |
// Explicit |length| accesses are seq-consistent atomic loads. |
| 4564 |
auto barrier = MemoryBarrierRequirement::Required; |
| 4565 |
|
| 4566 |
auto* length = MResizableTypedArrayLength::New(alloc(), obj, barrier); |
| 4567 |
addEffectful(length); |
| 4568 |
|
| 4569 |
auto* lengthDouble = MIntPtrToDouble::New(alloc(), length); |
| 4570 |
add(lengthDouble); |
| 4571 |
|
| 4572 |
auto* postConversion = MPostIntPtrConversion::New(alloc(), lengthDouble); |
| 4573 |
add(postConversion); |
| 4574 |
|
| 4575 |
pushResult(postConversion); |
| 4576 |
return resumeAfterUnchecked(postConversion); |
| 4577 |
} |
| 4578 |
|
| 4579 |
bool WarpCacheIRTranspiler::emitTypedArrayByteLengthInt32Result( |
| 4580 |
ObjOperandId objId) { |
| 4581 |
MDefinition* obj = getOperand(objId); |
| 4582 |
|
| 4583 |
auto* length = MArrayBufferViewLength::New(alloc(), obj); |
| 4584 |
add(length); |
| 4585 |
|
| 4586 |
auto* lengthInt32 = MNonNegativeIntPtrToInt32::New(alloc(), length); |
| 4587 |
add(lengthInt32); |
| 4588 |
|
| 4589 |
auto* size = MTypedArrayElementSize::New(alloc(), obj); |
| 4590 |
add(size); |
| 4591 |
|
| 4592 |
auto* mul = MMul::New(alloc(), lengthInt32, size, MIRType::Int32); |
| 4593 |
mul->setCanBeNegativeZero(false); |
| 4594 |
add(mul); |
| 4595 |
|
| 4596 |
pushResult(mul); |
| 4597 |
return true; |
| 4598 |
} |
| 4599 |
|
| 4600 |
bool WarpCacheIRTranspiler::emitTypedArrayByteLengthDoubleResult( |
| 4601 |
ObjOperandId objId) { |
| 4602 |
MDefinition* obj = getOperand(objId); |
| 4603 |
|
| 4604 |
auto* length = MArrayBufferViewLength::New(alloc(), obj); |
| 4605 |
add(length); |
| 4606 |
|
| 4607 |
auto* lengthDouble = MIntPtrToDouble::New(alloc(), length); |
| 4608 |
add(lengthDouble); |
| 4609 |
|
| 4610 |
auto* size = MTypedArrayElementSize::New(alloc(), obj); |
| 4611 |
add(size); |
| 4612 |
|
| 4613 |
auto* sizeDouble = MToDouble::New(alloc(), size); |
| 4614 |
add(sizeDouble); |
| 4615 |
|
| 4616 |
auto* mul = MMul::New(alloc(), lengthDouble, sizeDouble, MIRType::Double); |
| 4617 |
mul->setCanBeNegativeZero(false); |
| 4618 |
add(mul); |
| 4619 |
|
| 4620 |
pushResult(mul); |
| 4621 |
return true; |
| 4622 |
} |
| 4623 |
|
| 4624 |
bool WarpCacheIRTranspiler::emitResizableTypedArrayByteLengthInt32Result( |
| 4625 |
ObjOperandId objId) { |
| 4626 |
MDefinition* obj = getOperand(objId); |
| 4627 |
|
| 4628 |
// Explicit |byteLength| accesses are seq-consistent atomic loads. |
| 4629 |
auto barrier = MemoryBarrierRequirement::Required; |
| 4630 |
|
| 4631 |
auto* length = MResizableTypedArrayLength::New(alloc(), obj, barrier); |
| 4632 |
addEffectful(length); |
| 4633 |
|
| 4634 |
auto* lengthInt32 = MNonNegativeIntPtrToInt32::New(alloc(), length); |
| 4635 |
add(lengthInt32); |
| 4636 |
|
| 4637 |
auto* size = MTypedArrayElementSize::New(alloc(), obj); |
| 4638 |
add(size); |
| 4639 |
|
| 4640 |
auto* mul = MMul::New(alloc(), lengthInt32, size, MIRType::Int32); |
| 4641 |
mul->setCanBeNegativeZero(false); |
| 4642 |
add(mul); |
| 4643 |
|
| 4644 |
auto* postConversion = MPostIntPtrConversion::New(alloc(), mul); |
| 4645 |
add(postConversion); |
| 4646 |
|
| 4647 |
pushResult(postConversion); |
| 4648 |
return resumeAfterUnchecked(postConversion); |
| 4649 |
} |
| 4650 |
|
| 4651 |
bool WarpCacheIRTranspiler::emitResizableTypedArrayByteLengthDoubleResult( |
| 4652 |
ObjOperandId objId) { |
| 4653 |
MDefinition* obj = getOperand(objId); |
| 4654 |
|
| 4655 |
// Explicit |byteLength| accesses are seq-consistent atomic loads. |
| 4656 |
auto barrier = MemoryBarrierRequirement::Required; |
| 4657 |
|
| 4658 |
auto* length = MResizableTypedArrayLength::New(alloc(), obj, barrier); |
| 4659 |
addEffectful(length); |
| 4660 |
|
| 4661 |
auto* lengthDouble = MIntPtrToDouble::New(alloc(), length); |
| 4662 |
add(lengthDouble); |
| 4663 |
|
| 4664 |
auto* size = MTypedArrayElementSize::New(alloc(), obj); |
| 4665 |
add(size); |
| 4666 |
|
| 4667 |
auto* sizeDouble = MToDouble::New(alloc(), size); |
| 4668 |
add(sizeDouble); |
| 4669 |
|
| 4670 |
auto* mul = MMul::New(alloc(), lengthDouble, sizeDouble, MIRType::Double); |
| 4671 |
mul->setCanBeNegativeZero(false); |
| 4672 |
add(mul); |
| 4673 |
|
| 4674 |
auto* postConversion = MPostIntPtrConversion::New(alloc(), mul); |
| 4675 |
add(postConversion); |
| 4676 |
|
| 4677 |
pushResult(postConversion); |
| 4678 |
return resumeAfterUnchecked(postConversion); |
| 4679 |
} |
| 4680 |
|
| 4681 |
bool WarpCacheIRTranspiler::emitTypedArrayElementSizeResult( |
| 4682 |
ObjOperandId objId) { |
| 4683 |
MDefinition* obj = getOperand(objId); |
| 4684 |
|
| 4685 |
auto* ins = MTypedArrayElementSize::New(alloc(), obj); |
| 4686 |
add(ins); |
| 4687 |
|
| 4688 |
pushResult(ins); |
| 4689 |
return true; |
| 4690 |
} |
| 4691 |
|
| 4692 |
bool WarpCacheIRTranspiler::emitResizableDataViewByteLengthInt32Result( |
| 4693 |
ObjOperandId objId) { |
| 4694 |
MDefinition* obj = getOperand(objId); |
| 4695 |
|
| 4696 |
// Explicit |byteLength| accesses are seq-consistent atomic loads. |
| 4697 |
auto barrier = MemoryBarrierRequirement::Required; |
| 4698 |
|
| 4699 |
auto* length = MResizableDataViewByteLength::New(alloc(), obj, barrier); |
| 4700 |
addEffectful(length); |
| 4701 |
|
| 4702 |
auto* lengthInt32 = MNonNegativeIntPtrToInt32::New(alloc(), length); |
| 4703 |
add(lengthInt32); |
| 4704 |
|
| 4705 |
auto* postConversion = MPostIntPtrConversion::New(alloc(), lengthInt32); |
| 4706 |
add(postConversion); |
| 4707 |
|
| 4708 |
pushResult(postConversion); |
| 4709 |
return resumeAfterUnchecked(postConversion); |
| 4710 |
} |
| 4711 |
|
| 4712 |
bool WarpCacheIRTranspiler::emitResizableDataViewByteLengthDoubleResult( |
| 4713 |
ObjOperandId objId) { |
| 4714 |
MDefinition* obj = getOperand(objId); |
| 4715 |
|
| 4716 |
// Explicit |byteLength| accesses are seq-consistent atomic loads. |
| 4717 |
auto barrier = MemoryBarrierRequirement::Required; |
| 4718 |
|
| 4719 |
auto* length = MResizableDataViewByteLength::New(alloc(), obj, barrier); |
| 4720 |
addEffectful(length); |
| 4721 |
|
| 4722 |
auto* lengthDouble = MIntPtrToDouble::New(alloc(), length); |
| 4723 |
add(lengthDouble); |
| 4724 |
|
| 4725 |
auto* postConversion = MPostIntPtrConversion::New(alloc(), lengthDouble); |
| 4726 |
add(postConversion); |
| 4727 |
|
| 4728 |
pushResult(postConversion); |
| 4729 |
return resumeAfterUnchecked(postConversion); |
| 4730 |
} |
| 4731 |
|
| 4732 |
bool WarpCacheIRTranspiler::emitGrowableSharedArrayBufferByteLengthInt32Result( |
| 4733 |
ObjOperandId objId) { |
| 4734 |
MDefinition* obj = getOperand(objId); |
| 4735 |
|
| 4736 |
auto* length = MGrowableSharedArrayBufferByteLength::New(alloc(), obj); |
| 4737 |
addEffectful(length); |
| 4738 |
|
| 4739 |
auto* lengthInt32 = MNonNegativeIntPtrToInt32::New(alloc(), length); |
| 4740 |
add(lengthInt32); |
| 4741 |
|
| 4742 |
auto* postConversion = MPostIntPtrConversion::New(alloc(), lengthInt32); |
| 4743 |
add(postConversion); |
| 4744 |
|
| 4745 |
pushResult(postConversion); |
| 4746 |
return resumeAfterUnchecked(postConversion); |
| 4747 |
} |
| 4748 |
|
| 4749 |
bool WarpCacheIRTranspiler::emitGrowableSharedArrayBufferByteLengthDoubleResult( |
| 4750 |
ObjOperandId objId) { |
| 4751 |
MDefinition* obj = getOperand(objId); |
| 4752 |
|
| 4753 |
auto* length = MGrowableSharedArrayBufferByteLength::New(alloc(), obj); |
| 4754 |
addEffectful(length); |
| 4755 |
|
| 4756 |
auto* lengthDouble = MIntPtrToDouble::New(alloc(), length); |
| 4757 |
add(lengthDouble); |
| 4758 |
|
| 4759 |
auto* postConversion = MPostIntPtrConversion::New(alloc(), lengthDouble); |
| 4760 |
add(postConversion); |
| 4761 |
|
| 4762 |
pushResult(postConversion); |
| 4763 |
return resumeAfterUnchecked(postConversion); |
| 4764 |
} |
| 4765 |
|
| 4766 |
bool WarpCacheIRTranspiler::emitGuardHasAttachedArrayBuffer( |
| 4767 |
ObjOperandId objId) { |
| 4768 |
MDefinition* obj = getOperand(objId); |
| 4769 |
|
| 4770 |
auto* ins = MGuardHasAttachedArrayBuffer::New(alloc(), obj); |
| 4771 |
add(ins); |
| 4772 |
|
| 4773 |
setOperand(objId, ins); |
| 4774 |
return true; |
| 4775 |
} |
| 4776 |
|
| 4777 |
bool WarpCacheIRTranspiler::emitGuardResizableArrayBufferViewInBounds( |
| 4778 |
ObjOperandId objId) { |
| 4779 |
MDefinition* obj = getOperand(objId); |
| 4780 |
|
| 4781 |
auto* ins = MGuardResizableArrayBufferViewInBounds::New(alloc(), obj); |
| 4782 |
add(ins); |
| 4783 |
|
| 4784 |
setOperand(objId, ins); |
| 4785 |
return true; |
| 4786 |
} |
| 4787 |
|
| 4788 |
bool WarpCacheIRTranspiler::emitGuardResizableArrayBufferViewInBoundsOrDetached( |
| 4789 |
ObjOperandId objId) { |
| 4790 |
MDefinition* obj = getOperand(objId); |
| 4791 |
|
| 4792 |
auto* ins = |
| 4793 |
MGuardResizableArrayBufferViewInBoundsOrDetached::New(alloc(), obj); |
| 4794 |
add(ins); |
| 4795 |
|
| 4796 |
setOperand(objId, ins); |
| 4797 |
return true; |
| 4798 |
} |
| 4799 |
|
| 4800 |
bool WarpCacheIRTranspiler::emitIsTypedArrayConstructorResult( |
| 4801 |
ObjOperandId objId) { |
| 4802 |
MDefinition* obj = getOperand(objId); |
| 4803 |
|
| 4804 |
auto* ins = MIsTypedArrayConstructor::New(alloc(), obj); |
| 4805 |
add(ins); |
| 4806 |
|
| 4807 |
pushResult(ins); |
| 4808 |
return true; |
| 4809 |
} |
| 4810 |
|
| 4811 |
bool WarpCacheIRTranspiler::emitGetNextMapSetEntryForIteratorResult( |
| 4812 |
ObjOperandId iterId, ObjOperandId resultArrId, bool isMap) { |
| 4813 |
MDefinition* iter = getOperand(iterId); |
| 4814 |
MDefinition* resultArr = getOperand(resultArrId); |
| 4815 |
|
| 4816 |
MGetNextEntryForIterator::Mode mode = |
| 4817 |
isMap ? MGetNextEntryForIterator::Map : MGetNextEntryForIterator::Set; |
| 4818 |
auto* ins = MGetNextEntryForIterator::New(alloc(), iter, resultArr, mode); |
| 4819 |
addEffectful(ins); |
| 4820 |
pushResult(ins); |
| 4821 |
|
| 4822 |
return resumeAfter(ins); |
| 4823 |
} |
| 4824 |
|
| 4825 |
bool WarpCacheIRTranspiler::emitFrameIsConstructingResult() { |
| 4826 |
if (const CallInfo* callInfo = builder_->inlineCallInfo()) { |
| 4827 |
auto* ins = constant(BooleanValue(callInfo->constructing())); |
| 4828 |
pushResult(ins); |
| 4829 |
return true; |
| 4830 |
} |
| 4831 |
|
| 4832 |
auto* ins = MIsConstructing::New(alloc()); |
| 4833 |
add(ins); |
| 4834 |
pushResult(ins); |
| 4835 |
return true; |
| 4836 |
} |
| 4837 |
|
| 4838 |
bool WarpCacheIRTranspiler::emitNewIteratorResult( |
| 4839 |
MNewIterator::Type type, uint32_t templateObjectOffset) { |
| 4840 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 4841 |
|
| 4842 |
auto* templateConst = constant(ObjectValue(*templateObj)); |
| 4843 |
auto* iter = MNewIterator::New(alloc(), templateConst, type); |
| 4844 |
add(iter); |
| 4845 |
|
| 4846 |
pushResult(iter); |
| 4847 |
return true; |
| 4848 |
} |
| 4849 |
|
| 4850 |
bool WarpCacheIRTranspiler::emitNewArrayIteratorResult( |
| 4851 |
uint32_t templateObjectOffset) { |
| 4852 |
return emitNewIteratorResult(MNewIterator::ArrayIterator, |
| 4853 |
templateObjectOffset); |
| 4854 |
} |
| 4855 |
|
| 4856 |
bool WarpCacheIRTranspiler::emitNewStringIteratorResult( |
| 4857 |
uint32_t templateObjectOffset) { |
| 4858 |
return emitNewIteratorResult(MNewIterator::StringIterator, |
| 4859 |
templateObjectOffset); |
| 4860 |
} |
| 4861 |
|
| 4862 |
bool WarpCacheIRTranspiler::emitNewRegExpStringIteratorResult( |
| 4863 |
uint32_t templateObjectOffset) { |
| 4864 |
return emitNewIteratorResult(MNewIterator::RegExpStringIterator, |
| 4865 |
templateObjectOffset); |
| 4866 |
} |
| 4867 |
|
| 4868 |
bool WarpCacheIRTranspiler::emitObjectCreateResult( |
| 4869 |
uint32_t templateObjectOffset) { |
| 4870 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 4871 |
|
| 4872 |
auto* templateConst = constant(ObjectValue(*templateObj)); |
| 4873 |
|
| 4874 |
// TODO: support pre-tenuring. |
| 4875 |
gc::Heap heap = gc::Heap::Default; |
| 4876 |
auto* obj = |
| 4877 |
MNewObject::New(alloc(), templateConst, heap, MNewObject::ObjectCreate); |
| 4878 |
addEffectful(obj); |
| 4879 |
|
| 4880 |
pushResult(obj); |
| 4881 |
return resumeAfter(obj); |
| 4882 |
} |
| 4883 |
|
| 4884 |
bool WarpCacheIRTranspiler::emitNewArrayFromLengthResult( |
| 4885 |
uint32_t templateObjectOffset, Int32OperandId lengthId, |
| 4886 |
uint32_t siteOffset) { |
| 4887 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 4888 |
MDefinition* length = getOperand(lengthId); |
| 4889 |
gc::Heap heap = allocSiteInitialHeapField(siteOffset); |
| 4890 |
|
| 4891 |
if (length->isConstant()) { |
| 4892 |
int32_t lenInt32 = length->toConstant()->toInt32(); |
| 4893 |
if (lenInt32 >= 0 && |
| 4894 |
uint32_t(lenInt32) == templateObj->as<ArrayObject>().length()) { |
| 4895 |
uint32_t len = uint32_t(lenInt32); |
| 4896 |
auto* templateConst = constant(ObjectValue(*templateObj)); |
| 4897 |
|
| 4898 |
size_t inlineLength = |
| 4899 |
gc::GetGCKindSlots(templateObj->asTenured().getAllocKind()) - |
| 4900 |
ObjectElements::VALUES_PER_HEADER; |
| 4901 |
|
| 4902 |
MNewArray* obj; |
| 4903 |
if (len > inlineLength) { |
| 4904 |
obj = MNewArray::NewVM(alloc(), len, templateConst, heap); |
| 4905 |
} else { |
| 4906 |
obj = MNewArray::New(alloc(), len, templateConst, heap); |
| 4907 |
} |
| 4908 |
add(obj); |
| 4909 |
pushResult(obj); |
| 4910 |
return true; |
| 4911 |
} |
| 4912 |
} |
| 4913 |
|
| 4914 |
auto* obj = MNewArrayDynamicLength::New(alloc(), length, templateObj, heap); |
| 4915 |
addEffectful(obj); |
| 4916 |
pushResult(obj); |
| 4917 |
return resumeAfter(obj); |
| 4918 |
} |
| 4919 |
|
| 4920 |
bool WarpCacheIRTranspiler::emitNewTypedArrayFromLengthResult( |
| 4921 |
uint32_t templateObjectOffset, Int32OperandId lengthId) { |
| 4922 |
auto* templateObj = &tenuredObjectStubField(templateObjectOffset) |
| 4923 |
->as<FixedLengthTypedArrayObject>(); |
| 4924 |
MDefinition* length = getOperand(lengthId); |
| 4925 |
|
| 4926 |
// TODO: support pre-tenuring. |
| 4927 |
gc::Heap heap = gc::Heap::Default; |
| 4928 |
|
| 4929 |
if (length->isConstant()) { |
| 4930 |
int32_t len = length->toConstant()->toInt32(); |
| 4931 |
if (len > 0 && uint32_t(len) == templateObj->length()) { |
| 4932 |
auto* templateConst = constant(ObjectValue(*templateObj)); |
| 4933 |
auto* obj = MNewTypedArray::New(alloc(), templateConst, heap); |
| 4934 |
add(obj); |
| 4935 |
pushResult(obj); |
| 4936 |
return true; |
| 4937 |
} |
| 4938 |
} |
| 4939 |
|
| 4940 |
auto* obj = |
| 4941 |
MNewTypedArrayDynamicLength::New(alloc(), length, templateObj, heap); |
| 4942 |
addEffectful(obj); |
| 4943 |
pushResult(obj); |
| 4944 |
return resumeAfter(obj); |
| 4945 |
} |
| 4946 |
|
| 4947 |
bool WarpCacheIRTranspiler::emitNewTypedArrayFromArrayBufferResult( |
| 4948 |
uint32_t templateObjectOffset, ObjOperandId bufferId, |
| 4949 |
ValOperandId byteOffsetId, ValOperandId lengthId) { |
| 4950 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 4951 |
MDefinition* buffer = getOperand(bufferId); |
| 4952 |
MDefinition* byteOffset = getOperand(byteOffsetId); |
| 4953 |
MDefinition* length = getOperand(lengthId); |
| 4954 |
|
| 4955 |
// TODO: support pre-tenuring. |
| 4956 |
gc::Heap heap = gc::Heap::Default; |
| 4957 |
|
| 4958 |
auto* obj = MNewTypedArrayFromArrayBuffer::New(alloc(), buffer, byteOffset, |
| 4959 |
length, templateObj, heap); |
| 4960 |
addEffectful(obj); |
| 4961 |
|
| 4962 |
pushResult(obj); |
| 4963 |
return resumeAfter(obj); |
| 4964 |
} |
| 4965 |
|
| 4966 |
bool WarpCacheIRTranspiler::emitNewTypedArrayFromArrayResult( |
| 4967 |
uint32_t templateObjectOffset, ObjOperandId arrayId) { |
| 4968 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 4969 |
MDefinition* array = getOperand(arrayId); |
| 4970 |
|
| 4971 |
// TODO: support pre-tenuring. |
| 4972 |
gc::Heap heap = gc::Heap::Default; |
| 4973 |
|
| 4974 |
auto* obj = MNewTypedArrayFromArray::New(alloc(), array, templateObj, heap); |
| 4975 |
addEffectful(obj); |
| 4976 |
|
| 4977 |
pushResult(obj); |
| 4978 |
return resumeAfter(obj); |
| 4979 |
} |
| 4980 |
|
| 4981 |
bool WarpCacheIRTranspiler::emitAtomicsCompareExchangeResult( |
| 4982 |
ObjOperandId objId, IntPtrOperandId indexId, uint32_t expectedId, |
| 4983 |
uint32_t replacementId, Scalar::Type elementType, |
| 4984 |
ArrayBufferViewKind viewKind) { |
| 4985 |
MDefinition* obj = getOperand(objId); |
| 4986 |
MDefinition* index = getOperand(indexId); |
| 4987 |
MDefinition* expected = getOperand(ValOperandId(expectedId)); |
| 4988 |
MDefinition* replacement = getOperand(ValOperandId(replacementId)); |
| 4989 |
|
| 4990 |
auto* length = emitTypedArrayLength(viewKind, obj); |
| 4991 |
|
| 4992 |
index = addBoundsCheck(index, length); |
| 4993 |
|
| 4994 |
auto* elements = MArrayBufferViewElements::New(alloc(), obj); |
| 4995 |
add(elements); |
| 4996 |
|
| 4997 |
bool forceDoubleForUint32 = true; |
| 4998 |
MIRType knownType = |
| 4999 |
MIRTypeForArrayBufferViewRead(elementType, forceDoubleForUint32); |
| 5000 |
|
| 5001 |
auto* cas = MCompareExchangeTypedArrayElement::New( |
| 5002 |
alloc(), elements, index, elementType, expected, replacement); |
| 5003 |
cas->setResultType(knownType); |
| 5004 |
addEffectful(cas); |
| 5005 |
|
| 5006 |
MInstruction* result = cas; |
| 5007 |
if (Scalar::isBigIntType(elementType)) { |
| 5008 |
result = |
| 5009 |
MInt64ToBigInt::New(alloc(), cas, Scalar::isSignedIntType(elementType)); |
| 5010 |
|
| 5011 |
// Make non-movable so we can attach a resume point. |
| 5012 |
result->setNotMovable(); |
| 5013 |
|
| 5014 |
add(result); |
| 5015 |
} |
| 5016 |
|
| 5017 |
pushResult(result); |
| 5018 |
return resumeAfterUnchecked(result); |
| 5019 |
} |
| 5020 |
|
| 5021 |
bool WarpCacheIRTranspiler::emitAtomicsExchangeResult( |
| 5022 |
ObjOperandId objId, IntPtrOperandId indexId, uint32_t valueId, |
| 5023 |
Scalar::Type elementType, ArrayBufferViewKind viewKind) { |
| 5024 |
MDefinition* obj = getOperand(objId); |
| 5025 |
MDefinition* index = getOperand(indexId); |
| 5026 |
MDefinition* value = getOperand(ValOperandId(valueId)); |
| 5027 |
|
| 5028 |
auto* length = emitTypedArrayLength(viewKind, obj); |
| 5029 |
|
| 5030 |
index = addBoundsCheck(index, length); |
| 5031 |
|
| 5032 |
auto* elements = MArrayBufferViewElements::New(alloc(), obj); |
| 5033 |
add(elements); |
| 5034 |
|
| 5035 |
bool forceDoubleForUint32 = true; |
| 5036 |
MIRType knownType = |
| 5037 |
MIRTypeForArrayBufferViewRead(elementType, forceDoubleForUint32); |
| 5038 |
|
| 5039 |
auto* exchange = MAtomicExchangeTypedArrayElement::New( |
| 5040 |
alloc(), elements, index, value, elementType); |
| 5041 |
exchange->setResultType(knownType); |
| 5042 |
addEffectful(exchange); |
| 5043 |
|
| 5044 |
MInstruction* result = exchange; |
| 5045 |
if (Scalar::isBigIntType(elementType)) { |
| 5046 |
result = MInt64ToBigInt::New(alloc(), exchange, |
| 5047 |
Scalar::isSignedIntType(elementType)); |
| 5048 |
|
| 5049 |
// Make non-movable so we can attach a resume point. |
| 5050 |
result->setNotMovable(); |
| 5051 |
|
| 5052 |
add(result); |
| 5053 |
} |
| 5054 |
|
| 5055 |
pushResult(result); |
| 5056 |
return resumeAfterUnchecked(result); |
| 5057 |
} |
| 5058 |
|
| 5059 |
bool WarpCacheIRTranspiler::emitAtomicsBinaryOp( |
| 5060 |
ObjOperandId objId, IntPtrOperandId indexId, uint32_t valueId, |
| 5061 |
Scalar::Type elementType, bool forEffect, ArrayBufferViewKind viewKind, |
| 5062 |
AtomicOp op) { |
| 5063 |
MDefinition* obj = getOperand(objId); |
| 5064 |
MDefinition* index = getOperand(indexId); |
| 5065 |
MDefinition* value = getOperand(ValOperandId(valueId)); |
| 5066 |
|
| 5067 |
auto* length = emitTypedArrayLength(viewKind, obj); |
| 5068 |
|
| 5069 |
index = addBoundsCheck(index, length); |
| 5070 |
|
| 5071 |
auto* elements = MArrayBufferViewElements::New(alloc(), obj); |
| 5072 |
add(elements); |
| 5073 |
|
| 5074 |
bool forceDoubleForUint32 = true; |
| 5075 |
MIRType knownType = |
| 5076 |
MIRTypeForArrayBufferViewRead(elementType, forceDoubleForUint32); |
| 5077 |
|
| 5078 |
auto* binop = MAtomicTypedArrayElementBinop::New( |
| 5079 |
alloc(), op, elements, index, elementType, value, forEffect); |
| 5080 |
if (!forEffect) { |
| 5081 |
binop->setResultType(knownType); |
| 5082 |
} |
| 5083 |
addEffectful(binop); |
| 5084 |
|
| 5085 |
if (forEffect) { |
| 5086 |
pushResult(constant(UndefinedValue())); |
| 5087 |
return resumeAfter(binop); |
| 5088 |
} |
| 5089 |
|
| 5090 |
MInstruction* result = binop; |
| 5091 |
if (Scalar::isBigIntType(elementType)) { |
| 5092 |
result = MInt64ToBigInt::New(alloc(), binop, |
| 5093 |
Scalar::isSignedIntType(elementType)); |
| 5094 |
|
| 5095 |
// Make non-movable so we can attach a resume point. |
| 5096 |
result->setNotMovable(); |
| 5097 |
|
| 5098 |
add(result); |
| 5099 |
} |
| 5100 |
|
| 5101 |
pushResult(result); |
| 5102 |
return resumeAfterUnchecked(result); |
| 5103 |
} |
| 5104 |
|
| 5105 |
bool WarpCacheIRTranspiler::emitAtomicsAddResult( |
| 5106 |
ObjOperandId objId, IntPtrOperandId indexId, uint32_t valueId, |
| 5107 |
Scalar::Type elementType, bool forEffect, ArrayBufferViewKind viewKind) { |
| 5108 |
return emitAtomicsBinaryOp(objId, indexId, valueId, elementType, forEffect, |
| 5109 |
viewKind, AtomicOp::Add); |
| 5110 |
} |
| 5111 |
|
| 5112 |
bool WarpCacheIRTranspiler::emitAtomicsSubResult( |
| 5113 |
ObjOperandId objId, IntPtrOperandId indexId, uint32_t valueId, |
| 5114 |
Scalar::Type elementType, bool forEffect, ArrayBufferViewKind viewKind) { |
| 5115 |
return emitAtomicsBinaryOp(objId, indexId, valueId, elementType, forEffect, |
| 5116 |
viewKind, AtomicOp::Sub); |
| 5117 |
} |
| 5118 |
|
| 5119 |
bool WarpCacheIRTranspiler::emitAtomicsAndResult( |
| 5120 |
ObjOperandId objId, IntPtrOperandId indexId, uint32_t valueId, |
| 5121 |
Scalar::Type elementType, bool forEffect, ArrayBufferViewKind viewKind) { |
| 5122 |
return emitAtomicsBinaryOp(objId, indexId, valueId, elementType, forEffect, |
| 5123 |
viewKind, AtomicOp::And); |
| 5124 |
} |
| 5125 |
|
| 5126 |
bool WarpCacheIRTranspiler::emitAtomicsOrResult( |
| 5127 |
ObjOperandId objId, IntPtrOperandId indexId, uint32_t valueId, |
| 5128 |
Scalar::Type elementType, bool forEffect, ArrayBufferViewKind viewKind) { |
| 5129 |
return emitAtomicsBinaryOp(objId, indexId, valueId, elementType, forEffect, |
| 5130 |
viewKind, AtomicOp::Or); |
| 5131 |
} |
| 5132 |
|
| 5133 |
bool WarpCacheIRTranspiler::emitAtomicsXorResult( |
| 5134 |
ObjOperandId objId, IntPtrOperandId indexId, uint32_t valueId, |
| 5135 |
Scalar::Type elementType, bool forEffect, ArrayBufferViewKind viewKind) { |
| 5136 |
return emitAtomicsBinaryOp(objId, indexId, valueId, elementType, forEffect, |
| 5137 |
viewKind, AtomicOp::Xor); |
| 5138 |
} |
| 5139 |
|
| 5140 |
bool WarpCacheIRTranspiler::emitAtomicsLoadResult( |
| 5141 |
ObjOperandId objId, IntPtrOperandId indexId, Scalar::Type elementType, |
| 5142 |
ArrayBufferViewKind viewKind) { |
| 5143 |
MDefinition* obj = getOperand(objId); |
| 5144 |
MDefinition* index = getOperand(indexId); |
| 5145 |
|
| 5146 |
auto* length = emitTypedArrayLength(viewKind, obj); |
| 5147 |
|
| 5148 |
index = addBoundsCheck(index, length); |
| 5149 |
|
| 5150 |
auto* elements = MArrayBufferViewElements::New(alloc(), obj); |
| 5151 |
add(elements); |
| 5152 |
|
| 5153 |
bool forceDoubleForUint32 = true; |
| 5154 |
MIRType knownType = |
| 5155 |
MIRTypeForArrayBufferViewRead(elementType, forceDoubleForUint32); |
| 5156 |
|
| 5157 |
auto* load = MLoadUnboxedScalar::New(alloc(), elements, index, elementType, |
| 5158 |
MemoryBarrierRequirement::Required); |
| 5159 |
load->setResultType(knownType); |
| 5160 |
addEffectful(load); |
| 5161 |
|
| 5162 |
MInstruction* result = load; |
| 5163 |
if (Scalar::isBigIntType(elementType)) { |
| 5164 |
result = MInt64ToBigInt::New(alloc(), load, |
| 5165 |
Scalar::isSignedIntType(elementType)); |
| 5166 |
|
| 5167 |
// Make non-movable so we can attach a resume point. |
| 5168 |
result->setNotMovable(); |
| 5169 |
|
| 5170 |
add(result); |
| 5171 |
} |
| 5172 |
|
| 5173 |
pushResult(result); |
| 5174 |
return resumeAfterUnchecked(result); |
| 5175 |
} |
| 5176 |
|
| 5177 |
bool WarpCacheIRTranspiler::emitAtomicsStoreResult( |
| 5178 |
ObjOperandId objId, IntPtrOperandId indexId, uint32_t valueId, |
| 5179 |
Scalar::Type elementType, ArrayBufferViewKind viewKind) { |
| 5180 |
MDefinition* obj = getOperand(objId); |
| 5181 |
MDefinition* index = getOperand(indexId); |
| 5182 |
MDefinition* value = getOperand(ValOperandId(valueId)); |
| 5183 |
|
| 5184 |
auto* length = emitTypedArrayLength(viewKind, obj); |
| 5185 |
|
| 5186 |
index = addBoundsCheck(index, length); |
| 5187 |
|
| 5188 |
auto* elements = MArrayBufferViewElements::New(alloc(), obj); |
| 5189 |
add(elements); |
| 5190 |
|
| 5191 |
auto* store = |
| 5192 |
MStoreUnboxedScalar::New(alloc(), elements, index, value, elementType, |
| 5193 |
MemoryBarrierRequirement::Required); |
| 5194 |
addEffectful(store); |
| 5195 |
|
| 5196 |
pushResult(value); |
| 5197 |
return resumeAfter(store); |
| 5198 |
} |
| 5199 |
|
| 5200 |
bool WarpCacheIRTranspiler::emitAtomicsIsLockFreeResult( |
| 5201 |
Int32OperandId valueId) { |
| 5202 |
MDefinition* value = getOperand(valueId); |
| 5203 |
|
| 5204 |
auto* ilf = MAtomicIsLockFree::New(alloc(), value); |
| 5205 |
add(ilf); |
| 5206 |
|
| 5207 |
pushResult(ilf); |
| 5208 |
return true; |
| 5209 |
} |
| 5210 |
|
| 5211 |
bool WarpCacheIRTranspiler::emitAtomicsPauseResult() { |
| 5212 |
auto* ins = MAtomicPause::New(alloc()); |
| 5213 |
add(ins); |
| 5214 |
|
| 5215 |
pushResult(constant(UndefinedValue())); |
| 5216 |
return true; |
| 5217 |
} |
| 5218 |
|
| 5219 |
bool WarpCacheIRTranspiler::emitBigIntAsIntNResult(Int32OperandId bitsId, |
| 5220 |
BigIntOperandId bigIntId) { |
| 5221 |
MDefinition* bits = getOperand(bitsId); |
| 5222 |
MDefinition* bigInt = getOperand(bigIntId); |
| 5223 |
|
| 5224 |
auto* ins = MBigIntAsIntN::New(alloc(), bits, bigInt); |
| 5225 |
add(ins); |
| 5226 |
|
| 5227 |
pushResult(ins); |
| 5228 |
return true; |
| 5229 |
} |
| 5230 |
|
| 5231 |
bool WarpCacheIRTranspiler::emitBigIntAsUintNResult(Int32OperandId bitsId, |
| 5232 |
BigIntOperandId bigIntId) { |
| 5233 |
MDefinition* bits = getOperand(bitsId); |
| 5234 |
MDefinition* bigInt = getOperand(bigIntId); |
| 5235 |
|
| 5236 |
auto* ins = MBigIntAsUintN::New(alloc(), bits, bigInt); |
| 5237 |
add(ins); |
| 5238 |
|
| 5239 |
pushResult(ins); |
| 5240 |
return true; |
| 5241 |
} |
| 5242 |
|
| 5243 |
bool WarpCacheIRTranspiler::emitGuardToNonGCThing(ValOperandId inputId) { |
| 5244 |
MDefinition* def = getOperand(inputId); |
| 5245 |
if (IsNonGCThing(def->type())) { |
| 5246 |
return true; |
| 5247 |
} |
| 5248 |
|
| 5249 |
auto* ins = MGuardNonGCThing::New(alloc(), def); |
| 5250 |
add(ins); |
| 5251 |
|
| 5252 |
setOperand(inputId, ins); |
| 5253 |
return true; |
| 5254 |
} |
| 5255 |
|
| 5256 |
bool WarpCacheIRTranspiler::emitSetHasNonGCThingResult(ObjOperandId setId, |
| 5257 |
ValOperandId valId) { |
| 5258 |
MDefinition* set = getOperand(setId); |
| 5259 |
MDefinition* val = getOperand(valId); |
| 5260 |
|
| 5261 |
auto* hashValue = MToHashableNonGCThing::New(alloc(), val); |
| 5262 |
add(hashValue); |
| 5263 |
|
| 5264 |
auto* hash = MHashNonGCThing::New(alloc(), hashValue); |
| 5265 |
add(hash); |
| 5266 |
|
| 5267 |
auto* ins = MSetObjectHasNonBigInt::New(alloc(), set, hashValue, hash); |
| 5268 |
add(ins); |
| 5269 |
|
| 5270 |
pushResult(ins); |
| 5271 |
return true; |
| 5272 |
} |
| 5273 |
|
| 5274 |
bool WarpCacheIRTranspiler::emitSetHasStringResult(ObjOperandId setId, |
| 5275 |
StringOperandId strId) { |
| 5276 |
MDefinition* set = getOperand(setId); |
| 5277 |
MDefinition* str = getOperand(strId); |
| 5278 |
|
| 5279 |
auto* hashValue = MToHashableString::New(alloc(), str); |
| 5280 |
add(hashValue); |
| 5281 |
|
| 5282 |
auto* hash = MHashString::New(alloc(), hashValue); |
| 5283 |
add(hash); |
| 5284 |
|
| 5285 |
auto* ins = MSetObjectHasNonBigInt::New(alloc(), set, hashValue, hash); |
| 5286 |
add(ins); |
| 5287 |
|
| 5288 |
pushResult(ins); |
| 5289 |
return true; |
| 5290 |
} |
| 5291 |
|
| 5292 |
bool WarpCacheIRTranspiler::emitSetHasSymbolResult(ObjOperandId setId, |
| 5293 |
SymbolOperandId symId) { |
| 5294 |
MDefinition* set = getOperand(setId); |
| 5295 |
MDefinition* sym = getOperand(symId); |
| 5296 |
|
| 5297 |
auto* hash = MHashSymbol::New(alloc(), sym); |
| 5298 |
add(hash); |
| 5299 |
|
| 5300 |
auto* ins = MSetObjectHasNonBigInt::New(alloc(), set, sym, hash); |
| 5301 |
add(ins); |
| 5302 |
|
| 5303 |
pushResult(ins); |
| 5304 |
return true; |
| 5305 |
} |
| 5306 |
|
| 5307 |
bool WarpCacheIRTranspiler::emitSetHasBigIntResult(ObjOperandId setId, |
| 5308 |
BigIntOperandId bigIntId) { |
| 5309 |
MDefinition* set = getOperand(setId); |
| 5310 |
MDefinition* bigInt = getOperand(bigIntId); |
| 5311 |
|
| 5312 |
auto* hash = MHashBigInt::New(alloc(), bigInt); |
| 5313 |
add(hash); |
| 5314 |
|
| 5315 |
auto* ins = MSetObjectHasBigInt::New(alloc(), set, bigInt, hash); |
| 5316 |
add(ins); |
| 5317 |
|
| 5318 |
pushResult(ins); |
| 5319 |
return true; |
| 5320 |
} |
| 5321 |
|
| 5322 |
bool WarpCacheIRTranspiler::emitSetHasObjectResult(ObjOperandId setId, |
| 5323 |
ObjOperandId objId) { |
| 5324 |
MDefinition* set = getOperand(setId); |
| 5325 |
MDefinition* obj = getOperand(objId); |
| 5326 |
|
| 5327 |
auto* hash = MHashObject::New(alloc(), set, obj); |
| 5328 |
add(hash); |
| 5329 |
|
| 5330 |
auto* ins = MSetObjectHasNonBigInt::New(alloc(), set, obj, hash); |
| 5331 |
add(ins); |
| 5332 |
|
| 5333 |
pushResult(ins); |
| 5334 |
return true; |
| 5335 |
} |
| 5336 |
|
| 5337 |
bool WarpCacheIRTranspiler::emitSetHasResult(ObjOperandId setId, |
| 5338 |
ValOperandId valId) { |
| 5339 |
MDefinition* set = getOperand(setId); |
| 5340 |
MDefinition* val = getOperand(valId); |
| 5341 |
|
| 5342 |
#ifdef JS_PUNBOX64 |
| 5343 |
auto* hashValue = MToHashableValue::New(alloc(), val); |
| 5344 |
add(hashValue); |
| 5345 |
|
| 5346 |
auto* hash = MHashValue::New(alloc(), set, hashValue); |
| 5347 |
add(hash); |
| 5348 |
|
| 5349 |
auto* ins = MSetObjectHasValue::New(alloc(), set, hashValue, hash); |
| 5350 |
add(ins); |
| 5351 |
#else |
| 5352 |
auto* ins = MSetObjectHasValueVMCall::New(alloc(), set, val); |
| 5353 |
add(ins); |
| 5354 |
#endif |
| 5355 |
|
| 5356 |
pushResult(ins); |
| 5357 |
return true; |
| 5358 |
} |
| 5359 |
|
| 5360 |
bool WarpCacheIRTranspiler::emitSetDeleteResult(ObjOperandId setId, |
| 5361 |
ValOperandId keyId) { |
| 5362 |
MDefinition* set = getOperand(setId); |
| 5363 |
MDefinition* key = getOperand(keyId); |
| 5364 |
|
| 5365 |
auto* ins = MSetObjectDelete::New(alloc(), set, key); |
| 5366 |
addEffectful(ins); |
| 5367 |
|
| 5368 |
pushResult(ins); |
| 5369 |
return resumeAfter(ins); |
| 5370 |
} |
| 5371 |
|
| 5372 |
bool WarpCacheIRTranspiler::emitSetAddResult(ObjOperandId setId, |
| 5373 |
ValOperandId keyId) { |
| 5374 |
MDefinition* set = getOperand(setId); |
| 5375 |
MDefinition* key = getOperand(keyId); |
| 5376 |
|
| 5377 |
auto* ins = MSetObjectAdd::New(alloc(), set, key); |
| 5378 |
addEffectful(ins); |
| 5379 |
|
| 5380 |
pushResult(set); |
| 5381 |
return resumeAfter(ins); |
| 5382 |
} |
| 5383 |
|
| 5384 |
bool WarpCacheIRTranspiler::emitSetSizeResult(ObjOperandId setId) { |
| 5385 |
MDefinition* set = getOperand(setId); |
| 5386 |
|
| 5387 |
auto* ins = MSetObjectSize::New(alloc(), set); |
| 5388 |
add(ins); |
| 5389 |
|
| 5390 |
pushResult(ins); |
| 5391 |
return true; |
| 5392 |
} |
| 5393 |
|
| 5394 |
bool WarpCacheIRTranspiler::emitMapHasNonGCThingResult(ObjOperandId mapId, |
| 5395 |
ValOperandId valId) { |
| 5396 |
MDefinition* map = getOperand(mapId); |
| 5397 |
MDefinition* val = getOperand(valId); |
| 5398 |
|
| 5399 |
auto* hashValue = MToHashableNonGCThing::New(alloc(), val); |
| 5400 |
add(hashValue); |
| 5401 |
|
| 5402 |
auto* hash = MHashNonGCThing::New(alloc(), hashValue); |
| 5403 |
add(hash); |
| 5404 |
|
| 5405 |
auto* ins = MMapObjectHasNonBigInt::New(alloc(), map, hashValue, hash); |
| 5406 |
add(ins); |
| 5407 |
|
| 5408 |
pushResult(ins); |
| 5409 |
return true; |
| 5410 |
} |
| 5411 |
|
| 5412 |
bool WarpCacheIRTranspiler::emitMapHasStringResult(ObjOperandId mapId, |
| 5413 |
StringOperandId strId) { |
| 5414 |
MDefinition* map = getOperand(mapId); |
| 5415 |
MDefinition* str = getOperand(strId); |
| 5416 |
|
| 5417 |
auto* hashValue = MToHashableString::New(alloc(), str); |
| 5418 |
add(hashValue); |
| 5419 |
|
| 5420 |
auto* hash = MHashString::New(alloc(), hashValue); |
| 5421 |
add(hash); |
| 5422 |
|
| 5423 |
auto* ins = MMapObjectHasNonBigInt::New(alloc(), map, hashValue, hash); |
| 5424 |
add(ins); |
| 5425 |
|
| 5426 |
pushResult(ins); |
| 5427 |
return true; |
| 5428 |
} |
| 5429 |
|
| 5430 |
bool WarpCacheIRTranspiler::emitMapHasSymbolResult(ObjOperandId mapId, |
| 5431 |
SymbolOperandId symId) { |
| 5432 |
MDefinition* map = getOperand(mapId); |
| 5433 |
MDefinition* sym = getOperand(symId); |
| 5434 |
|
| 5435 |
auto* hash = MHashSymbol::New(alloc(), sym); |
| 5436 |
add(hash); |
| 5437 |
|
| 5438 |
auto* ins = MMapObjectHasNonBigInt::New(alloc(), map, sym, hash); |
| 5439 |
add(ins); |
| 5440 |
|
| 5441 |
pushResult(ins); |
| 5442 |
return true; |
| 5443 |
} |
| 5444 |
|
| 5445 |
bool WarpCacheIRTranspiler::emitMapHasBigIntResult(ObjOperandId mapId, |
| 5446 |
BigIntOperandId bigIntId) { |
| 5447 |
MDefinition* map = getOperand(mapId); |
| 5448 |
MDefinition* bigInt = getOperand(bigIntId); |
| 5449 |
|
| 5450 |
auto* hash = MHashBigInt::New(alloc(), bigInt); |
| 5451 |
add(hash); |
| 5452 |
|
| 5453 |
auto* ins = MMapObjectHasBigInt::New(alloc(), map, bigInt, hash); |
| 5454 |
add(ins); |
| 5455 |
|
| 5456 |
pushResult(ins); |
| 5457 |
return true; |
| 5458 |
} |
| 5459 |
|
| 5460 |
bool WarpCacheIRTranspiler::emitMapHasObjectResult(ObjOperandId mapId, |
| 5461 |
ObjOperandId objId) { |
| 5462 |
MDefinition* map = getOperand(mapId); |
| 5463 |
MDefinition* obj = getOperand(objId); |
| 5464 |
|
| 5465 |
auto* hash = MHashObject::New(alloc(), map, obj); |
| 5466 |
add(hash); |
| 5467 |
|
| 5468 |
auto* ins = MMapObjectHasNonBigInt::New(alloc(), map, obj, hash); |
| 5469 |
add(ins); |
| 5470 |
|
| 5471 |
pushResult(ins); |
| 5472 |
return true; |
| 5473 |
} |
| 5474 |
|
| 5475 |
bool WarpCacheIRTranspiler::emitMapHasResult(ObjOperandId mapId, |
| 5476 |
ValOperandId valId) { |
| 5477 |
MDefinition* map = getOperand(mapId); |
| 5478 |
MDefinition* val = getOperand(valId); |
| 5479 |
|
| 5480 |
#ifdef JS_PUNBOX64 |
| 5481 |
auto* hashValue = MToHashableValue::New(alloc(), val); |
| 5482 |
add(hashValue); |
| 5483 |
|
| 5484 |
auto* hash = MHashValue::New(alloc(), map, hashValue); |
| 5485 |
add(hash); |
| 5486 |
|
| 5487 |
auto* ins = MMapObjectHasValue::New(alloc(), map, hashValue, hash); |
| 5488 |
add(ins); |
| 5489 |
#else |
| 5490 |
auto* ins = MMapObjectHasValueVMCall::New(alloc(), map, val); |
| 5491 |
add(ins); |
| 5492 |
#endif |
| 5493 |
|
| 5494 |
pushResult(ins); |
| 5495 |
return true; |
| 5496 |
} |
| 5497 |
|
| 5498 |
bool WarpCacheIRTranspiler::emitMapGetNonGCThingResult(ObjOperandId mapId, |
| 5499 |
ValOperandId valId) { |
| 5500 |
MDefinition* map = getOperand(mapId); |
| 5501 |
MDefinition* val = getOperand(valId); |
| 5502 |
|
| 5503 |
auto* hashValue = MToHashableNonGCThing::New(alloc(), val); |
| 5504 |
add(hashValue); |
| 5505 |
|
| 5506 |
auto* hash = MHashNonGCThing::New(alloc(), hashValue); |
| 5507 |
add(hash); |
| 5508 |
|
| 5509 |
auto* ins = MMapObjectGetNonBigInt::New(alloc(), map, hashValue, hash); |
| 5510 |
add(ins); |
| 5511 |
|
| 5512 |
pushResult(ins); |
| 5513 |
return true; |
| 5514 |
} |
| 5515 |
|
| 5516 |
bool WarpCacheIRTranspiler::emitMapGetStringResult(ObjOperandId mapId, |
| 5517 |
StringOperandId strId) { |
| 5518 |
MDefinition* map = getOperand(mapId); |
| 5519 |
MDefinition* str = getOperand(strId); |
| 5520 |
|
| 5521 |
auto* hashValue = MToHashableString::New(alloc(), str); |
| 5522 |
add(hashValue); |
| 5523 |
|
| 5524 |
auto* hash = MHashString::New(alloc(), hashValue); |
| 5525 |
add(hash); |
| 5526 |
|
| 5527 |
auto* ins = MMapObjectGetNonBigInt::New(alloc(), map, hashValue, hash); |
| 5528 |
add(ins); |
| 5529 |
|
| 5530 |
pushResult(ins); |
| 5531 |
return true; |
| 5532 |
} |
| 5533 |
|
| 5534 |
bool WarpCacheIRTranspiler::emitMapGetSymbolResult(ObjOperandId mapId, |
| 5535 |
SymbolOperandId symId) { |
| 5536 |
MDefinition* map = getOperand(mapId); |
| 5537 |
MDefinition* sym = getOperand(symId); |
| 5538 |
|
| 5539 |
auto* hash = MHashSymbol::New(alloc(), sym); |
| 5540 |
add(hash); |
| 5541 |
|
| 5542 |
auto* ins = MMapObjectGetNonBigInt::New(alloc(), map, sym, hash); |
| 5543 |
add(ins); |
| 5544 |
|
| 5545 |
pushResult(ins); |
| 5546 |
return true; |
| 5547 |
} |
| 5548 |
|
| 5549 |
bool WarpCacheIRTranspiler::emitMapGetBigIntResult(ObjOperandId mapId, |
| 5550 |
BigIntOperandId bigIntId) { |
| 5551 |
MDefinition* map = getOperand(mapId); |
| 5552 |
MDefinition* bigInt = getOperand(bigIntId); |
| 5553 |
|
| 5554 |
auto* hash = MHashBigInt::New(alloc(), bigInt); |
| 5555 |
add(hash); |
| 5556 |
|
| 5557 |
auto* ins = MMapObjectGetBigInt::New(alloc(), map, bigInt, hash); |
| 5558 |
add(ins); |
| 5559 |
|
| 5560 |
pushResult(ins); |
| 5561 |
return true; |
| 5562 |
} |
| 5563 |
|
| 5564 |
bool WarpCacheIRTranspiler::emitMapGetObjectResult(ObjOperandId mapId, |
| 5565 |
ObjOperandId objId) { |
| 5566 |
MDefinition* map = getOperand(mapId); |
| 5567 |
MDefinition* obj = getOperand(objId); |
| 5568 |
|
| 5569 |
auto* hash = MHashObject::New(alloc(), map, obj); |
| 5570 |
add(hash); |
| 5571 |
|
| 5572 |
auto* ins = MMapObjectGetNonBigInt::New(alloc(), map, obj, hash); |
| 5573 |
add(ins); |
| 5574 |
|
| 5575 |
pushResult(ins); |
| 5576 |
return true; |
| 5577 |
} |
| 5578 |
|
| 5579 |
bool WarpCacheIRTranspiler::emitMapGetResult(ObjOperandId mapId, |
| 5580 |
ValOperandId valId) { |
| 5581 |
MDefinition* map = getOperand(mapId); |
| 5582 |
MDefinition* val = getOperand(valId); |
| 5583 |
|
| 5584 |
#ifdef JS_PUNBOX64 |
| 5585 |
auto* hashValue = MToHashableValue::New(alloc(), val); |
| 5586 |
add(hashValue); |
| 5587 |
|
| 5588 |
auto* hash = MHashValue::New(alloc(), map, hashValue); |
| 5589 |
add(hash); |
| 5590 |
|
| 5591 |
auto* ins = MMapObjectGetValue::New(alloc(), map, hashValue, hash); |
| 5592 |
add(ins); |
| 5593 |
#else |
| 5594 |
auto* ins = MMapObjectGetValueVMCall::New(alloc(), map, val); |
| 5595 |
add(ins); |
| 5596 |
#endif |
| 5597 |
|
| 5598 |
pushResult(ins); |
| 5599 |
return true; |
| 5600 |
} |
| 5601 |
|
| 5602 |
bool WarpCacheIRTranspiler::emitMapDeleteResult(ObjOperandId mapId, |
| 5603 |
ValOperandId keyId) { |
| 5604 |
MDefinition* map = getOperand(mapId); |
| 5605 |
MDefinition* key = getOperand(keyId); |
| 5606 |
|
| 5607 |
auto* ins = MMapObjectDelete::New(alloc(), map, key); |
| 5608 |
addEffectful(ins); |
| 5609 |
|
| 5610 |
pushResult(ins); |
| 5611 |
return resumeAfter(ins); |
| 5612 |
} |
| 5613 |
|
| 5614 |
bool WarpCacheIRTranspiler::emitMapSetResult(ObjOperandId mapId, |
| 5615 |
ValOperandId keyId, |
| 5616 |
ValOperandId valId) { |
| 5617 |
MDefinition* map = getOperand(mapId); |
| 5618 |
MDefinition* key = getOperand(keyId); |
| 5619 |
MDefinition* val = getOperand(valId); |
| 5620 |
|
| 5621 |
auto* ins = MMapObjectSet::New(alloc(), map, key, val); |
| 5622 |
addEffectful(ins); |
| 5623 |
|
| 5624 |
pushResult(map); |
| 5625 |
return resumeAfter(ins); |
| 5626 |
} |
| 5627 |
|
| 5628 |
bool WarpCacheIRTranspiler::emitMapSizeResult(ObjOperandId mapId) { |
| 5629 |
MDefinition* map = getOperand(mapId); |
| 5630 |
|
| 5631 |
auto* ins = MMapObjectSize::New(alloc(), map); |
| 5632 |
add(ins); |
| 5633 |
|
| 5634 |
pushResult(ins); |
| 5635 |
return true; |
| 5636 |
} |
| 5637 |
|
| 5638 |
bool WarpCacheIRTranspiler::emitDateFillLocalTimeSlots(ObjOperandId dateId) { |
| 5639 |
MDefinition* date = getOperand(dateId); |
| 5640 |
|
| 5641 |
// MDateFillLocalTimeSlots is effectful because it can store into fixed slots, |
| 5642 |
// but it's safe to repeat this action after a bailout, therefore it's okay to |
| 5643 |
// use |addEffectfulUnsafe|. |
| 5644 |
auto* ins = MDateFillLocalTimeSlots::New(alloc(), date); |
| 5645 |
addEffectfulUnsafe(ins); |
| 5646 |
|
| 5647 |
return true; |
| 5648 |
} |
| 5649 |
|
| 5650 |
bool WarpCacheIRTranspiler::emitDateHoursFromSecondsIntoYearResult( |
| 5651 |
ValOperandId secondsIntoYearId) { |
| 5652 |
MDefinition* secondsIntoYear = getOperand(secondsIntoYearId); |
| 5653 |
|
| 5654 |
auto* ins = MDateHoursFromSecondsIntoYear::New(alloc(), secondsIntoYear); |
| 5655 |
add(ins); |
| 5656 |
|
| 5657 |
pushResult(ins); |
| 5658 |
return true; |
| 5659 |
} |
| 5660 |
|
| 5661 |
bool WarpCacheIRTranspiler::emitDateMinutesFromSecondsIntoYearResult( |
| 5662 |
ValOperandId secondsIntoYearId) { |
| 5663 |
MDefinition* secondsIntoYear = getOperand(secondsIntoYearId); |
| 5664 |
|
| 5665 |
auto* ins = MDateMinutesFromSecondsIntoYear::New(alloc(), secondsIntoYear); |
| 5666 |
add(ins); |
| 5667 |
|
| 5668 |
pushResult(ins); |
| 5669 |
return true; |
| 5670 |
} |
| 5671 |
|
| 5672 |
bool WarpCacheIRTranspiler::emitDateSecondsFromSecondsIntoYearResult( |
| 5673 |
ValOperandId secondsIntoYearId) { |
| 5674 |
MDefinition* secondsIntoYear = getOperand(secondsIntoYearId); |
| 5675 |
|
| 5676 |
auto* ins = MDateSecondsFromSecondsIntoYear::New(alloc(), secondsIntoYear); |
| 5677 |
add(ins); |
| 5678 |
|
| 5679 |
pushResult(ins); |
| 5680 |
return true; |
| 5681 |
} |
| 5682 |
|
| 5683 |
bool WarpCacheIRTranspiler::emitTruthyResult(OperandId inputId) { |
| 5684 |
MDefinition* input = getOperand(inputId); |
| 5685 |
|
| 5686 |
auto* result = convertToBoolean(input); |
| 5687 |
|
| 5688 |
pushResult(result); |
| 5689 |
return true; |
| 5690 |
} |
| 5691 |
|
| 5692 |
bool WarpCacheIRTranspiler::emitLoadInt32TruthyResult(ValOperandId inputId) { |
| 5693 |
return emitTruthyResult(inputId); |
| 5694 |
} |
| 5695 |
|
| 5696 |
bool WarpCacheIRTranspiler::emitLoadDoubleTruthyResult( |
| 5697 |
NumberOperandId inputId) { |
| 5698 |
return emitTruthyResult(inputId); |
| 5699 |
} |
| 5700 |
|
| 5701 |
bool WarpCacheIRTranspiler::emitLoadStringTruthyResult( |
| 5702 |
StringOperandId inputId) { |
| 5703 |
return emitTruthyResult(inputId); |
| 5704 |
} |
| 5705 |
|
| 5706 |
bool WarpCacheIRTranspiler::emitLoadObjectTruthyResult(ObjOperandId inputId) { |
| 5707 |
return emitTruthyResult(inputId); |
| 5708 |
} |
| 5709 |
|
| 5710 |
bool WarpCacheIRTranspiler::emitLoadBigIntTruthyResult( |
| 5711 |
BigIntOperandId inputId) { |
| 5712 |
return emitTruthyResult(inputId); |
| 5713 |
} |
| 5714 |
|
| 5715 |
bool WarpCacheIRTranspiler::emitLoadValueTruthyResult(ValOperandId inputId) { |
| 5716 |
return emitTruthyResult(inputId); |
| 5717 |
} |
| 5718 |
|
| 5719 |
bool WarpCacheIRTranspiler::emitLoadOperandResult(ValOperandId inputId) { |
| 5720 |
MDefinition* input = getOperand(inputId); |
| 5721 |
pushResult(input); |
| 5722 |
return true; |
| 5723 |
} |
| 5724 |
|
| 5725 |
bool WarpCacheIRTranspiler::emitLoadWrapperTarget(ObjOperandId objId, |
| 5726 |
ObjOperandId resultId, |
| 5727 |
bool fallible) { |
| 5728 |
MDefinition* obj = getOperand(objId); |
| 5729 |
|
| 5730 |
auto* ins = MLoadWrapperTarget::New(alloc(), obj, fallible); |
| 5731 |
if (fallible) { |
| 5732 |
ins->setGuard(); |
| 5733 |
} |
| 5734 |
add(ins); |
| 5735 |
|
| 5736 |
return defineOperand(resultId, ins); |
| 5737 |
} |
| 5738 |
|
| 5739 |
// When we transpile a call, we may generate guards for some |
| 5740 |
// arguments. To make sure the call instruction depends on those |
| 5741 |
// guards, when the transpiler creates an operand for an argument, we |
| 5742 |
// register the OperandId of that argument in argumentIds_. (See |
| 5743 |
// emitLoadArgumentSlot.) Before generating the call, we update the |
| 5744 |
// CallInfo to use the appropriate value from operands_. |
| 5745 |
// Note: The callee is an explicit argument to the call op, and is |
| 5746 |
// tracked separately. |
| 5747 |
void WarpCacheIRTranspiler::updateArgumentsFromOperands() { |
| 5748 |
for (uint32_t i = 0; i < uint32_t(ArgumentKind::NumKinds); i++) { |
| 5749 |
ArgumentKind kind = ArgumentKind(i); |
| 5750 |
OperandId id = argumentOperandIds_[kind]; |
| 5751 |
if (id.valid()) { |
| 5752 |
switch (kind) { |
| 5753 |
case ArgumentKind::This: |
| 5754 |
callInfo_->setThis(getOperand(id)); |
| 5755 |
break; |
| 5756 |
case ArgumentKind::NewTarget: |
| 5757 |
callInfo_->setNewTarget(getOperand(id)); |
| 5758 |
break; |
| 5759 |
case ArgumentKind::Arg0: |
| 5760 |
callInfo_->setArg(0, getOperand(id)); |
| 5761 |
break; |
| 5762 |
case ArgumentKind::Arg1: |
| 5763 |
callInfo_->setArg(1, getOperand(id)); |
| 5764 |
break; |
| 5765 |
case ArgumentKind::Arg2: |
| 5766 |
callInfo_->setArg(2, getOperand(id)); |
| 5767 |
break; |
| 5768 |
case ArgumentKind::Arg3: |
| 5769 |
callInfo_->setArg(3, getOperand(id)); |
| 5770 |
break; |
| 5771 |
case ArgumentKind::Arg4: |
| 5772 |
callInfo_->setArg(4, getOperand(id)); |
| 5773 |
break; |
| 5774 |
case ArgumentKind::Arg5: |
| 5775 |
callInfo_->setArg(5, getOperand(id)); |
| 5776 |
break; |
| 5777 |
case ArgumentKind::Arg6: |
| 5778 |
callInfo_->setArg(6, getOperand(id)); |
| 5779 |
break; |
| 5780 |
case ArgumentKind::Arg7: |
| 5781 |
callInfo_->setArg(7, getOperand(id)); |
| 5782 |
break; |
| 5783 |
case ArgumentKind::Callee: |
| 5784 |
case ArgumentKind::NumKinds: |
| 5785 |
MOZ_CRASH("Unexpected argument kind"); |
| 5786 |
} |
| 5787 |
} |
| 5788 |
} |
| 5789 |
} |
| 5790 |
|
| 5791 |
bool WarpCacheIRTranspiler::emitLoadArgumentSlot(ValOperandId resultId, |
| 5792 |
uint32_t slotIndex) { |
| 5793 |
// Reverse of GetIndexOfArgument. |
| 5794 |
|
| 5795 |
// Layout: |
| 5796 |
// NewTarget | Args.. (reversed) | ThisValue | Callee |
| 5797 |
// 0 | ArgC .. Arg1 Arg0 (+1) | argc (+1) | argc + 1 (+ 1) |
| 5798 |
// ^ (if constructing) |
| 5799 |
|
| 5800 |
// NewTarget (optional) |
| 5801 |
if (callInfo_->constructing()) { |
| 5802 |
if (slotIndex == 0) { |
| 5803 |
setArgumentId(ArgumentKind::NewTarget, resultId); |
| 5804 |
return defineOperand(resultId, callInfo_->getNewTarget()); |
| 5805 |
} |
| 5806 |
|
| 5807 |
slotIndex -= 1; // Adjust slot index to match non-constructing calls. |
| 5808 |
} |
| 5809 |
|
| 5810 |
// Args.. |
| 5811 |
if (slotIndex < callInfo_->argc()) { |
| 5812 |
uint32_t arg = callInfo_->argc() - 1 - slotIndex; |
| 5813 |
ArgumentKind kind = ArgumentKindForArgIndex(arg); |
| 5814 |
MOZ_ASSERT(kind < ArgumentKind::NumKinds); |
| 5815 |
setArgumentId(kind, resultId); |
| 5816 |
return defineOperand(resultId, callInfo_->getArg(arg)); |
| 5817 |
} |
| 5818 |
|
| 5819 |
// ThisValue |
| 5820 |
if (slotIndex == callInfo_->argc()) { |
| 5821 |
setArgumentId(ArgumentKind::This, resultId); |
| 5822 |
return defineOperand(resultId, callInfo_->thisArg()); |
| 5823 |
} |
| 5824 |
|
| 5825 |
// Callee |
| 5826 |
MOZ_ASSERT(slotIndex == callInfo_->argc() + 1); |
| 5827 |
return defineOperand(resultId, callInfo_->callee()); |
| 5828 |
} |
| 5829 |
|
| 5830 |
bool WarpCacheIRTranspiler::emitLoadArgumentFixedSlot(ValOperandId resultId, |
| 5831 |
uint8_t slotIndex) { |
| 5832 |
return emitLoadArgumentSlot(resultId, slotIndex); |
| 5833 |
} |
| 5834 |
|
| 5835 |
bool WarpCacheIRTranspiler::emitLoadArgumentDynamicSlot(ValOperandId resultId, |
| 5836 |
Int32OperandId argcId, |
| 5837 |
uint8_t slotIndex) { |
| 5838 |
#ifdef DEBUG |
| 5839 |
MDefinition* argc = getOperand(argcId); |
| 5840 |
MOZ_ASSERT(argc->toConstant()->toInt32() == |
| 5841 |
static_cast<int32_t>(callInfo_->argc())); |
| 5842 |
#endif |
| 5843 |
|
| 5844 |
return emitLoadArgumentSlot(resultId, callInfo_->argc() + slotIndex); |
| 5845 |
} |
| 5846 |
|
| 5847 |
WrappedFunction* WarpCacheIRTranspiler::maybeWrappedFunction( |
| 5848 |
MDefinition* callee, CallKind kind, uint16_t nargs, FunctionFlags flags) { |
| 5849 |
MOZ_ASSERT(callee->isConstant() || callee->isNurseryObject()); |
| 5850 |
|
| 5851 |
// If this is a native without a JitEntry, WrappedFunction needs to know the |
| 5852 |
// target JSFunction. |
| 5853 |
// TODO: support nursery-allocated natives with WrappedFunction, maybe by |
| 5854 |
// storing the JSNative in the Baseline stub like flags/nargs. |
| 5855 |
bool isNative = flags.isNativeWithoutJitEntry(); |
| 5856 |
if (isNative && !callee->isConstant()) { |
| 5857 |
return nullptr; |
| 5858 |
} |
| 5859 |
|
| 5860 |
JSFunction* nativeTarget = nullptr; |
| 5861 |
if (isNative) { |
| 5862 |
nativeTarget = &callee->toConstant()->toObject().as<JSFunction>(); |
| 5863 |
} |
| 5864 |
|
| 5865 |
WrappedFunction* wrappedTarget = |
| 5866 |
new (alloc()) WrappedFunction(nativeTarget, nargs, flags); |
| 5867 |
MOZ_ASSERT_IF(kind == CallKind::Native || kind == CallKind::DOM, |
| 5868 |
wrappedTarget->isNativeWithoutJitEntry()); |
| 5869 |
MOZ_ASSERT_IF(kind == CallKind::Scripted, wrappedTarget->hasJitEntry()); |
| 5870 |
return wrappedTarget; |
| 5871 |
} |
| 5872 |
|
| 5873 |
WrappedFunction* WarpCacheIRTranspiler::maybeCallTarget(MDefinition* callee, |
| 5874 |
CallKind kind) { |
| 5875 |
// CacheIR emits the following for specialized calls: |
| 5876 |
// GuardSpecificFunction <callee> <func> .. |
| 5877 |
// Call(Native|Scripted)Function <callee> .. |
| 5878 |
// or: |
| 5879 |
// GuardClass <callee> .. |
| 5880 |
// GuardFunctionScript <callee> <script> .. |
| 5881 |
// CallScriptedFunction <callee> .. |
| 5882 |
// |
| 5883 |
// We can use the <func> JSFunction or <script> BaseScript to specialize this |
| 5884 |
// call. |
| 5885 |
if (callee->isGuardSpecificFunction()) { |
| 5886 |
auto* guard = callee->toGuardSpecificFunction(); |
| 5887 |
return maybeWrappedFunction(guard->expected(), kind, guard->nargs(), |
| 5888 |
guard->flags()); |
| 5889 |
} |
| 5890 |
if (callee->isGuardFunctionScript()) { |
| 5891 |
MOZ_ASSERT(kind == CallKind::Scripted); |
| 5892 |
auto* guard = callee->toGuardFunctionScript(); |
| 5893 |
WrappedFunction* wrappedTarget = new (alloc()) WrappedFunction( |
| 5894 |
/* nativeFun = */ nullptr, guard->nargs(), guard->flags()); |
| 5895 |
MOZ_ASSERT(wrappedTarget->hasJitEntry()); |
| 5896 |
return wrappedTarget; |
| 5897 |
} |
| 5898 |
return nullptr; |
| 5899 |
} |
| 5900 |
|
| 5901 |
// If it is possible to use MCall for this call, update callInfo_ to use |
| 5902 |
// the correct arguments. Otherwise, update the ArgFormat of callInfo_. |
| 5903 |
bool WarpCacheIRTranspiler::updateCallInfo(MDefinition* callee, |
| 5904 |
CallFlags flags) { |
| 5905 |
// The transpilation will add various guards to the callee. |
| 5906 |
// We replace the callee referenced by the CallInfo, so that |
| 5907 |
// the resulting call instruction depends on these guards. |
| 5908 |
callInfo_->setCallee(callee); |
| 5909 |
|
| 5910 |
// The transpilation may also add guards to other arguments. |
| 5911 |
// We replace those arguments in the CallInfo here. |
| 5912 |
updateArgumentsFromOperands(); |
| 5913 |
|
| 5914 |
switch (flags.getArgFormat()) { |
| 5915 |
case CallFlags::Standard: |
| 5916 |
MOZ_ASSERT(callInfo_->argFormat() == CallInfo::ArgFormat::Standard); |
| 5917 |
break; |
| 5918 |
case CallFlags::Spread: |
| 5919 |
MOZ_ASSERT(callInfo_->argFormat() == CallInfo::ArgFormat::Array); |
| 5920 |
break; |
| 5921 |
case CallFlags::FunCall: |
| 5922 |
// Note: We already changed the callee to the target |
| 5923 |
// function instead of the |call| function. |
| 5924 |
MOZ_ASSERT(!callInfo_->constructing()); |
| 5925 |
MOZ_ASSERT(callInfo_->argFormat() == CallInfo::ArgFormat::Standard); |
| 5926 |
|
| 5927 |
if (callInfo_->argc() == 0) { |
| 5928 |
// Special case for fun.call() with no arguments. |
| 5929 |
auto* undef = constant(UndefinedValue()); |
| 5930 |
callInfo_->setThis(undef); |
| 5931 |
} else { |
| 5932 |
// The first argument for |call| is the new this value. |
| 5933 |
callInfo_->setThis(callInfo_->getArg(0)); |
| 5934 |
|
| 5935 |
// Shift down all other arguments by removing the first. |
| 5936 |
callInfo_->removeArg(0); |
| 5937 |
} |
| 5938 |
break; |
| 5939 |
case CallFlags::FunApplyArgsObj: |
| 5940 |
MOZ_ASSERT(!callInfo_->constructing()); |
| 5941 |
MOZ_ASSERT(callInfo_->argFormat() == CallInfo::ArgFormat::Standard); |
| 5942 |
|
| 5943 |
callInfo_->setArgFormat(CallInfo::ArgFormat::FunApplyArgsObj); |
| 5944 |
break; |
| 5945 |
case CallFlags::FunApplyArray: { |
| 5946 |
MDefinition* argFunc = callInfo_->thisArg(); |
| 5947 |
MDefinition* argThis = callInfo_->getArg(0); |
| 5948 |
callInfo_->setCallee(argFunc); |
| 5949 |
callInfo_->setThis(argThis); |
| 5950 |
callInfo_->setArgFormat(CallInfo::ArgFormat::Array); |
| 5951 |
break; |
| 5952 |
} |
| 5953 |
case CallFlags::FunApplyNullUndefined: |
| 5954 |
// Note: We already changed the callee to the target |
| 5955 |
// function instead of the |apply| function. |
| 5956 |
MOZ_ASSERT(callInfo_->argc() == 2); |
| 5957 |
MOZ_ASSERT(!callInfo_->constructing()); |
| 5958 |
MOZ_ASSERT(callInfo_->argFormat() == CallInfo::ArgFormat::Standard); |
| 5959 |
callInfo_->setThis(callInfo_->getArg(0)); |
| 5960 |
callInfo_->getArg(1)->setImplicitlyUsedUnchecked(); |
| 5961 |
callInfo_->removeArg(1); |
| 5962 |
callInfo_->removeArg(0); |
| 5963 |
break; |
| 5964 |
default: |
| 5965 |
MOZ_CRASH("Unsupported arg format"); |
| 5966 |
} |
| 5967 |
return true; |
| 5968 |
} |
| 5969 |
|
| 5970 |
// Returns true if we are generating a call to CreateThisFromIon and |
| 5971 |
// must check its return value. |
| 5972 |
bool WarpCacheIRTranspiler::maybeCreateThis(MDefinition* callee, |
| 5973 |
CallFlags flags, CallKind kind) { |
| 5974 |
MOZ_ASSERT(kind != CallKind::DOM, "DOM functions are not constructors"); |
| 5975 |
MDefinition* thisArg = callInfo_->thisArg(); |
| 5976 |
|
| 5977 |
if (kind == CallKind::Native) { |
| 5978 |
// Native functions keep the is-constructing MagicValue as |this|. |
| 5979 |
// If one of the arguments uses spread syntax this can be a loop phi with |
| 5980 |
// MIRType::Value. |
| 5981 |
MOZ_ASSERT(thisArg->type() == MIRType::MagicIsConstructing || |
| 5982 |
thisArg->isPhi()); |
| 5983 |
return false; |
| 5984 |
} |
| 5985 |
MOZ_ASSERT(kind == CallKind::Scripted); |
| 5986 |
|
| 5987 |
if (thisArg->isNewPlainObject()) { |
| 5988 |
// We have already updated |this| based on MetaScriptedThisShape. We do |
| 5989 |
// not need to generate a check. |
| 5990 |
return false; |
| 5991 |
} |
| 5992 |
if (flags.needsUninitializedThis()) { |
| 5993 |
MConstant* uninit = constant(MagicValue(JS_UNINITIALIZED_LEXICAL)); |
| 5994 |
thisArg->setImplicitlyUsedUnchecked(); |
| 5995 |
callInfo_->setThis(uninit); |
| 5996 |
return false; |
| 5997 |
} |
| 5998 |
// See the Native case above. |
| 5999 |
MOZ_ASSERT(thisArg->type() == MIRType::MagicIsConstructing || |
| 6000 |
thisArg->isPhi()); |
| 6001 |
|
| 6002 |
auto* newTarget = unboxObjectInfallible(callInfo_->getNewTarget()); |
| 6003 |
auto* createThis = MCreateThis::New(alloc(), callee, newTarget); |
| 6004 |
add(createThis); |
| 6005 |
|
| 6006 |
thisArg->setImplicitlyUsedUnchecked(); |
| 6007 |
callInfo_->setThis(createThis); |
| 6008 |
|
| 6009 |
return true; |
| 6010 |
} |
| 6011 |
|
| 6012 |
bool WarpCacheIRTranspiler::emitCallFunction( |
| 6013 |
ObjOperandId calleeId, Int32OperandId argcId, |
| 6014 |
mozilla::Maybe<ObjOperandId> thisObjId, CallFlags flags, CallKind kind, |
| 6015 |
mozilla::Maybe<uint32_t> siteOffset) { |
| 6016 |
MDefinition* callee = getOperand(calleeId); |
| 6017 |
if (kind == CallKind::Scripted && callInfo_ && callInfo_->isInlined()) { |
| 6018 |
// We are transpiling to generate the correct guards. We also |
| 6019 |
// update the CallInfo to use the correct arguments. Code for the |
| 6020 |
// inlined function itself will be generated in |
| 6021 |
// WarpBuilder::buildInlinedCall. |
| 6022 |
if (!updateCallInfo(callee, flags)) { |
| 6023 |
return false; |
| 6024 |
} |
| 6025 |
if (callInfo_->constructing()) { |
| 6026 |
MOZ_ASSERT(flags.isConstructing()); |
| 6027 |
|
| 6028 |
// We call maybeCreateThis to update |this|, but inlined constructors |
| 6029 |
// never need a VM call. CallIRGenerator::getThisForScripted ensures that |
| 6030 |
// we don't attach a specialized stub unless we have a template object or |
| 6031 |
// know that the constructor needs uninitialized this. |
| 6032 |
MOZ_ALWAYS_FALSE(maybeCreateThis(callee, flags, CallKind::Scripted)); |
| 6033 |
mozilla::DebugOnly<MDefinition*> thisArg = callInfo_->thisArg(); |
| 6034 |
MOZ_ASSERT(thisArg->isNewPlainObject() || |
| 6035 |
thisArg->type() == MIRType::MagicUninitializedLexical); |
| 6036 |
} |
| 6037 |
|
| 6038 |
if (flags.getArgFormat() == CallFlags::FunCall) { |
| 6039 |
callInfo_->setInliningResumeMode(ResumeMode::InlinedFunCall); |
| 6040 |
} else { |
| 6041 |
MOZ_ASSERT(flags.getArgFormat() == CallFlags::Standard); |
| 6042 |
callInfo_->setInliningResumeMode(ResumeMode::InlinedStandardCall); |
| 6043 |
} |
| 6044 |
|
| 6045 |
switch (callInfo_->argFormat()) { |
| 6046 |
case CallInfo::ArgFormat::Standard: |
| 6047 |
break; |
| 6048 |
default: |
| 6049 |
MOZ_CRASH("Unsupported arg format"); |
| 6050 |
} |
| 6051 |
return true; |
| 6052 |
} |
| 6053 |
|
| 6054 |
#ifdef DEBUG |
| 6055 |
MDefinition* argc = getOperand(argcId); |
| 6056 |
MOZ_ASSERT(argc->toConstant()->toInt32() == |
| 6057 |
static_cast<int32_t>(callInfo_->argc())); |
| 6058 |
#endif |
| 6059 |
|
| 6060 |
if (!updateCallInfo(callee, flags)) { |
| 6061 |
return false; |
| 6062 |
} |
| 6063 |
|
| 6064 |
if (kind == CallKind::DOM) { |
| 6065 |
MOZ_ASSERT(flags.getArgFormat() == CallFlags::Standard); |
| 6066 |
// For DOM calls |this| has a class guard. |
| 6067 |
MDefinition* thisObj = getOperand(*thisObjId); |
| 6068 |
callInfo_->setThis(thisObj); |
| 6069 |
} |
| 6070 |
|
| 6071 |
WrappedFunction* wrappedTarget = maybeCallTarget(callee, kind); |
| 6072 |
|
| 6073 |
bool needsThisCheck = false; |
| 6074 |
if (callInfo_->constructing()) { |
| 6075 |
MOZ_ASSERT(flags.isConstructing()); |
| 6076 |
needsThisCheck = maybeCreateThis(callee, flags, kind); |
| 6077 |
if (needsThisCheck) { |
| 6078 |
wrappedTarget = nullptr; |
| 6079 |
} |
| 6080 |
} |
| 6081 |
|
| 6082 |
switch (callInfo_->argFormat()) { |
| 6083 |
case CallInfo::ArgFormat::Standard: { |
| 6084 |
gc::Heap initialHeap = gc::Heap::Default; |
| 6085 |
if (siteOffset) { |
| 6086 |
MOZ_ASSERT(kind == CallKind::DOM); |
| 6087 |
MOZ_ASSERT(readStubWord(*siteOffset) <= (uintptr_t)(gc::Heap::Tenured)); |
| 6088 |
initialHeap = static_cast<gc::Heap>(readStubWord(*siteOffset)); |
| 6089 |
} |
| 6090 |
MCall* call = makeCall(*callInfo_, needsThisCheck, wrappedTarget, |
| 6091 |
kind == CallKind::DOM, initialHeap); |
| 6092 |
if (!call) { |
| 6093 |
return false; |
| 6094 |
} |
| 6095 |
|
| 6096 |
if (flags.isSameRealm()) { |
| 6097 |
call->setNotCrossRealm(); |
| 6098 |
} |
| 6099 |
|
| 6100 |
if (call->isEffectful()) { |
| 6101 |
addEffectful(call); |
| 6102 |
pushResult(call); |
| 6103 |
return resumeAfter(call); |
| 6104 |
} |
| 6105 |
|
| 6106 |
MOZ_ASSERT(kind == CallKind::DOM); |
| 6107 |
add(call); |
| 6108 |
pushResult(call); |
| 6109 |
return true; |
| 6110 |
} |
| 6111 |
case CallInfo::ArgFormat::Array: { |
| 6112 |
MInstruction* call = makeSpreadCall(*callInfo_, needsThisCheck, |
| 6113 |
flags.isSameRealm(), wrappedTarget); |
| 6114 |
if (!call) { |
| 6115 |
return false; |
| 6116 |
} |
| 6117 |
addEffectful(call); |
| 6118 |
pushResult(call); |
| 6119 |
|
| 6120 |
return resumeAfter(call); |
| 6121 |
} |
| 6122 |
case CallInfo::ArgFormat::FunApplyArgsObj: { |
| 6123 |
return emitFunApplyArgsObj(wrappedTarget, flags); |
| 6124 |
} |
| 6125 |
} |
| 6126 |
MOZ_CRASH("unreachable"); |
| 6127 |
} |
| 6128 |
|
| 6129 |
bool WarpCacheIRTranspiler::emitFunApplyArgsObj(WrappedFunction* wrappedTarget, |
| 6130 |
CallFlags flags) { |
| 6131 |
MOZ_ASSERT(!callInfo_->constructing()); |
| 6132 |
|
| 6133 |
MDefinition* callee = callInfo_->thisArg(); |
| 6134 |
MDefinition* thisArg = callInfo_->getArg(0); |
| 6135 |
MDefinition* argsObj = callInfo_->getArg(1); |
| 6136 |
|
| 6137 |
MApplyArgsObj* apply = |
| 6138 |
MApplyArgsObj::New(alloc(), wrappedTarget, callee, argsObj, thisArg); |
| 6139 |
|
| 6140 |
if (flags.isSameRealm()) { |
| 6141 |
apply->setNotCrossRealm(); |
| 6142 |
} |
| 6143 |
if (callInfo_->ignoresReturnValue()) { |
| 6144 |
apply->setIgnoresReturnValue(); |
| 6145 |
} |
| 6146 |
|
| 6147 |
addEffectful(apply); |
| 6148 |
pushResult(apply); |
| 6149 |
|
| 6150 |
return resumeAfter(apply); |
| 6151 |
} |
| 6152 |
|
| 6153 |
#ifndef JS_SIMULATOR |
| 6154 |
bool WarpCacheIRTranspiler::emitCallNativeFunction(ObjOperandId calleeId, |
| 6155 |
Int32OperandId argcId, |
| 6156 |
CallFlags flags, |
| 6157 |
uint32_t argcFixed, |
| 6158 |
bool ignoresReturnValue) { |
| 6159 |
// Instead of ignoresReturnValue we use CallInfo::ignoresReturnValue. |
| 6160 |
return emitCallFunction(calleeId, argcId, mozilla::Nothing(), flags, |
| 6161 |
CallKind::Native); |
| 6162 |
} |
| 6163 |
|
| 6164 |
bool WarpCacheIRTranspiler::emitCallDOMFunction(ObjOperandId calleeId, |
| 6165 |
Int32OperandId argcId, |
| 6166 |
ObjOperandId thisObjId, |
| 6167 |
CallFlags flags, |
| 6168 |
uint32_t argcFixed) { |
| 6169 |
return emitCallFunction(calleeId, argcId, mozilla::Some(thisObjId), flags, |
| 6170 |
CallKind::DOM); |
| 6171 |
} |
| 6172 |
|
| 6173 |
bool WarpCacheIRTranspiler::emitCallDOMFunctionWithAllocSite( |
| 6174 |
ObjOperandId calleeId, Int32OperandId argcId, ObjOperandId thisObjId, |
| 6175 |
CallFlags flags, uint32_t argcFixed, uint32_t siteOffset) { |
| 6176 |
return emitCallFunction(calleeId, argcId, mozilla::Some(thisObjId), flags, |
| 6177 |
CallKind::DOM, mozilla::Some(siteOffset)); |
| 6178 |
} |
| 6179 |
#else |
| 6180 |
bool WarpCacheIRTranspiler::emitCallNativeFunction(ObjOperandId calleeId, |
| 6181 |
Int32OperandId argcId, |
| 6182 |
CallFlags flags, |
| 6183 |
uint32_t argcFixed, |
| 6184 |
uint32_t targetOffset) { |
| 6185 |
return emitCallFunction(calleeId, argcId, mozilla::Nothing(), flags, |
| 6186 |
CallKind::Native); |
| 6187 |
} |
| 6188 |
|
| 6189 |
bool WarpCacheIRTranspiler::emitCallDOMFunction( |
| 6190 |
ObjOperandId calleeId, Int32OperandId argcId, ObjOperandId thisObjId, |
| 6191 |
CallFlags flags, uint32_t argcFixed, uint32_t targetOffset) { |
| 6192 |
return emitCallFunction(calleeId, argcId, mozilla::Some(thisObjId), flags, |
| 6193 |
CallKind::DOM); |
| 6194 |
} |
| 6195 |
|
| 6196 |
bool WarpCacheIRTranspiler::emitCallDOMFunctionWithAllocSite( |
| 6197 |
ObjOperandId calleeId, Int32OperandId argcId, ObjOperandId thisObjId, |
| 6198 |
CallFlags flags, uint32_t argcFixed, uint32_t siteOffset, |
| 6199 |
uint32_t targetOffset) { |
| 6200 |
return emitCallFunction(calleeId, argcId, mozilla::Some(thisObjId), flags, |
| 6201 |
CallKind::DOM, mozilla::Some(siteOffset)); |
| 6202 |
} |
| 6203 |
#endif |
| 6204 |
|
| 6205 |
bool WarpCacheIRTranspiler::emitCallScriptedFunction(ObjOperandId calleeId, |
| 6206 |
Int32OperandId argcId, |
| 6207 |
CallFlags flags, |
| 6208 |
uint32_t argcFixed) { |
| 6209 |
return emitCallFunction(calleeId, argcId, mozilla::Nothing(), flags, |
| 6210 |
CallKind::Scripted); |
| 6211 |
} |
| 6212 |
|
| 6213 |
bool WarpCacheIRTranspiler::emitCallInlinedFunction(ObjOperandId calleeId, |
| 6214 |
Int32OperandId argcId, |
| 6215 |
uint32_t icScriptOffset, |
| 6216 |
CallFlags flags, |
| 6217 |
uint32_t argcFixed) { |
| 6218 |
return emitCallFunction(calleeId, argcId, mozilla::Nothing(), flags, |
| 6219 |
CallKind::Scripted); |
| 6220 |
} |
| 6221 |
|
| 6222 |
#ifdef JS_PUNBOX64 |
| 6223 |
bool WarpCacheIRTranspiler::emitCallScriptedProxyGetShared( |
| 6224 |
MDefinition* target, MDefinition* receiver, MDefinition* handler, |
| 6225 |
MDefinition* id, MDefinition* trapDef, WrappedFunction* trap) { |
| 6226 |
CallInfo callInfo(alloc(), /* constructing = */ false, |
| 6227 |
/* ignoresRval = */ false); |
| 6228 |
callInfo.initForProxyGet(trapDef, handler, target, id, receiver); |
| 6229 |
|
| 6230 |
MCall* call = makeCall(callInfo, /* needsThisCheck = */ false, trap); |
| 6231 |
if (!call) { |
| 6232 |
return false; |
| 6233 |
} |
| 6234 |
|
| 6235 |
addEffectful(call); |
| 6236 |
|
| 6237 |
if (!current->ensureHasSlots(3)) { |
| 6238 |
return false; |
| 6239 |
} |
| 6240 |
current->push(call); |
| 6241 |
current->push(id); |
| 6242 |
current->push(target); |
| 6243 |
|
| 6244 |
MResumePoint* resumePoint = |
| 6245 |
MResumePoint::New(alloc(), current, loc_.toRawBytecode(), |
| 6246 |
ResumeMode::ResumeAfterCheckProxyGetResult); |
| 6247 |
if (!resumePoint) { |
| 6248 |
return false; |
| 6249 |
} |
| 6250 |
call->setResumePoint(resumePoint); |
| 6251 |
|
| 6252 |
current->pop(); |
| 6253 |
current->pop(); |
| 6254 |
|
| 6255 |
MCheckScriptedProxyGetResult* check = |
| 6256 |
MCheckScriptedProxyGetResult::New(alloc(), target, id, call); |
| 6257 |
addEffectfulUnsafe(check); |
| 6258 |
|
| 6259 |
return resumeAfterUnchecked(check); |
| 6260 |
} |
| 6261 |
|
| 6262 |
bool WarpCacheIRTranspiler::emitCallScriptedProxyGetResult( |
| 6263 |
ValOperandId targetId, ObjOperandId receiverId, ObjOperandId handlerId, |
| 6264 |
ObjOperandId trapId, uint32_t idOffset, uint32_t nargsAndFlags) { |
| 6265 |
MDefinition* target = getOperand(targetId); |
| 6266 |
MDefinition* receiver = getOperand(receiverId); |
| 6267 |
MDefinition* handler = getOperand(handlerId); |
| 6268 |
MDefinition* trap = getOperand(trapId); |
| 6269 |
jsid id = idStubField(idOffset); |
| 6270 |
MDefinition* idDef = constant(StringValue(id.toAtom())); |
| 6271 |
WrappedFunction* wrappedTarget = maybeCallTarget(trap, CallKind::Scripted); |
| 6272 |
MOZ_RELEASE_ASSERT(wrappedTarget); |
| 6273 |
return emitCallScriptedProxyGetShared(target, receiver, handler, idDef, trap, |
| 6274 |
wrappedTarget); |
| 6275 |
} |
| 6276 |
|
| 6277 |
bool WarpCacheIRTranspiler::emitCallScriptedProxyGetByValueResult( |
| 6278 |
ValOperandId targetId, ObjOperandId receiverId, ObjOperandId handlerId, |
| 6279 |
ValOperandId idId, ObjOperandId trapId, uint32_t nargsAndFlags) { |
| 6280 |
MDefinition* target = getOperand(targetId); |
| 6281 |
MDefinition* receiver = getOperand(receiverId); |
| 6282 |
MDefinition* handler = getOperand(handlerId); |
| 6283 |
MDefinition* trap = getOperand(trapId); |
| 6284 |
MDefinition* idDef = getOperand(idId); |
| 6285 |
WrappedFunction* wrappedTarget = maybeCallTarget(trap, CallKind::Scripted); |
| 6286 |
MOZ_RELEASE_ASSERT(wrappedTarget); |
| 6287 |
return emitCallScriptedProxyGetShared(target, receiver, handler, idDef, trap, |
| 6288 |
wrappedTarget); |
| 6289 |
} |
| 6290 |
#endif |
| 6291 |
|
| 6292 |
bool WarpCacheIRTranspiler::emitCallClassHook(ObjOperandId calleeId, |
| 6293 |
Int32OperandId argcId, |
| 6294 |
CallFlags flags, |
| 6295 |
uint32_t argcFixed, |
| 6296 |
uint32_t targetOffset) { |
| 6297 |
MDefinition* callee = getOperand(calleeId); |
| 6298 |
JSNative target = jsnativeStubField(targetOffset); |
| 6299 |
|
| 6300 |
#ifdef DEBUG |
| 6301 |
MDefinition* argc = getOperand(argcId); |
| 6302 |
MOZ_ASSERT(argc->toConstant()->toInt32() == |
| 6303 |
static_cast<int32_t>(callInfo_->argc())); |
| 6304 |
#endif |
| 6305 |
|
| 6306 |
if (!updateCallInfo(callee, flags)) { |
| 6307 |
return false; |
| 6308 |
} |
| 6309 |
|
| 6310 |
MOZ_ASSERT(callInfo_->argFormat() == CallInfo::ArgFormat::Standard); |
| 6311 |
MOZ_ASSERT(flags.getArgFormat() == CallFlags::ArgFormat::Standard); |
| 6312 |
|
| 6313 |
// Callees can be from any realm. If this changes, we should update |
| 6314 |
// MCallClassHook::maybeCrossRealm. |
| 6315 |
MOZ_ASSERT(!flags.isSameRealm()); |
| 6316 |
|
| 6317 |
auto* call = MCallClassHook::New(alloc(), target, callInfo_->argc(), |
| 6318 |
callInfo_->constructing()); |
| 6319 |
if (!call) { |
| 6320 |
return false; |
| 6321 |
} |
| 6322 |
|
| 6323 |
if (callInfo_->ignoresReturnValue()) { |
| 6324 |
call->setIgnoresReturnValue(); |
| 6325 |
} |
| 6326 |
|
| 6327 |
call->initCallee(callInfo_->callee()); |
| 6328 |
call->addArg(0, callInfo_->thisArg()); |
| 6329 |
|
| 6330 |
for (uint32_t i = 0; i < callInfo_->argc(); i++) { |
| 6331 |
call->addArg(i + 1, callInfo_->getArg(i)); |
| 6332 |
} |
| 6333 |
|
| 6334 |
if (callInfo_->constructing()) { |
| 6335 |
call->addArg(1 + callInfo_->argc(), callInfo_->getNewTarget()); |
| 6336 |
} |
| 6337 |
|
| 6338 |
addEffectful(call); |
| 6339 |
pushResult(call); |
| 6340 |
|
| 6341 |
return resumeAfter(call); |
| 6342 |
} |
| 6343 |
|
| 6344 |
bool WarpCacheIRTranspiler::emitCallBoundScriptedFunction( |
| 6345 |
ObjOperandId calleeId, ObjOperandId targetId, Int32OperandId argcId, |
| 6346 |
CallFlags flags, uint32_t numBoundArgs) { |
| 6347 |
MDefinition* callee = getOperand(calleeId); |
| 6348 |
MDefinition* target = getOperand(targetId); |
| 6349 |
|
| 6350 |
MOZ_ASSERT(callInfo_->argFormat() == CallInfo::ArgFormat::Standard); |
| 6351 |
MOZ_ASSERT(callInfo_->constructing() == flags.isConstructing()); |
| 6352 |
|
| 6353 |
callInfo_->setCallee(target); |
| 6354 |
updateArgumentsFromOperands(); |
| 6355 |
|
| 6356 |
WrappedFunction* wrappedTarget = maybeCallTarget(target, CallKind::Scripted); |
| 6357 |
|
| 6358 |
bool needsThisCheck = false; |
| 6359 |
if (callInfo_->constructing()) { |
| 6360 |
callInfo_->setNewTarget(target); |
| 6361 |
needsThisCheck = maybeCreateThis(target, flags, CallKind::Scripted); |
| 6362 |
if (needsThisCheck) { |
| 6363 |
wrappedTarget = nullptr; |
| 6364 |
} |
| 6365 |
} else { |
| 6366 |
auto* thisv = MLoadFixedSlot::New(alloc(), callee, |
| 6367 |
BoundFunctionObject::boundThisSlot()); |
| 6368 |
add(thisv); |
| 6369 |
callInfo_->thisArg()->setImplicitlyUsedUnchecked(); |
| 6370 |
callInfo_->setThis(thisv); |
| 6371 |
} |
| 6372 |
|
| 6373 |
bool usingInlineBoundArgs = |
| 6374 |
numBoundArgs <= BoundFunctionObject::MaxInlineBoundArgs; |
| 6375 |
|
| 6376 |
MElements* elements = nullptr; |
| 6377 |
if (!usingInlineBoundArgs) { |
| 6378 |
auto* boundArgs = MLoadFixedSlot::New( |
| 6379 |
alloc(), callee, BoundFunctionObject::firstInlineBoundArgSlot()); |
| 6380 |
add(boundArgs); |
| 6381 |
auto* boundArgsObj = unboxObjectInfallible(boundArgs, IsMovable::Yes); |
| 6382 |
elements = MElements::New(alloc(), boundArgsObj); |
| 6383 |
add(elements); |
| 6384 |
} |
| 6385 |
|
| 6386 |
auto loadBoundArg = [&](size_t index) { |
| 6387 |
MInstruction* arg; |
| 6388 |
if (usingInlineBoundArgs) { |
| 6389 |
size_t slot = BoundFunctionObject::firstInlineBoundArgSlot() + index; |
| 6390 |
arg = MLoadFixedSlot::New(alloc(), callee, slot); |
| 6391 |
} else { |
| 6392 |
arg = MLoadElement::New(alloc(), elements, constant(Int32Value(index))); |
| 6393 |
} |
| 6394 |
add(arg); |
| 6395 |
return arg; |
| 6396 |
}; |
| 6397 |
if (!callInfo_->prependArgs(numBoundArgs, loadBoundArg)) { |
| 6398 |
return false; |
| 6399 |
} |
| 6400 |
|
| 6401 |
MCall* call = makeCall(*callInfo_, needsThisCheck, wrappedTarget); |
| 6402 |
if (!call) { |
| 6403 |
return false; |
| 6404 |
} |
| 6405 |
|
| 6406 |
if (flags.isSameRealm()) { |
| 6407 |
call->setNotCrossRealm(); |
| 6408 |
} |
| 6409 |
|
| 6410 |
addEffectful(call); |
| 6411 |
pushResult(call); |
| 6412 |
return resumeAfter(call); |
| 6413 |
} |
| 6414 |
|
| 6415 |
bool WarpCacheIRTranspiler::emitBindFunctionResult( |
| 6416 |
ObjOperandId targetId, uint32_t argc, uint32_t templateObjectOffset) { |
| 6417 |
MDefinition* target = getOperand(targetId); |
| 6418 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 6419 |
|
| 6420 |
MOZ_ASSERT(callInfo_->argc() == argc); |
| 6421 |
|
| 6422 |
auto* bound = MBindFunction::New(alloc(), target, argc, templateObj); |
| 6423 |
if (!bound) { |
| 6424 |
return false; |
| 6425 |
} |
| 6426 |
addEffectful(bound); |
| 6427 |
|
| 6428 |
for (uint32_t i = 0; i < argc; i++) { |
| 6429 |
bound->initArg(i, callInfo_->getArg(i)); |
| 6430 |
} |
| 6431 |
|
| 6432 |
pushResult(bound); |
| 6433 |
return resumeAfter(bound); |
| 6434 |
} |
| 6435 |
|
| 6436 |
bool WarpCacheIRTranspiler::emitSpecializedBindFunctionResult( |
| 6437 |
ObjOperandId targetId, uint32_t argc, uint32_t templateObjectOffset) { |
| 6438 |
MDefinition* target = getOperand(targetId); |
| 6439 |
JSObject* templateObj = tenuredObjectStubField(templateObjectOffset); |
| 6440 |
|
| 6441 |
MOZ_ASSERT(callInfo_->argc() == argc); |
| 6442 |
|
| 6443 |
auto* bound = MNewBoundFunction::New(alloc(), templateObj); |
| 6444 |
add(bound); |
| 6445 |
|
| 6446 |
size_t numBoundArgs = argc > 0 ? argc - 1 : 0; |
| 6447 |
MOZ_ASSERT(numBoundArgs <= BoundFunctionObject::MaxInlineBoundArgs); |
| 6448 |
|
| 6449 |
auto initSlot = [&](size_t slot, MDefinition* value) { |
| 6450 |
#ifdef DEBUG |
| 6451 |
// Assert we can elide the post write barrier. See also the comment in |
| 6452 |
// WarpBuilder::buildNamedLambdaEnv. |
| 6453 |
add(MAssertCanElidePostWriteBarrier::New(alloc(), bound, value)); |
| 6454 |
#endif |
| 6455 |
addUnchecked(MStoreFixedSlot::NewUnbarriered(alloc(), bound, slot, value)); |
| 6456 |
}; |
| 6457 |
|
| 6458 |
initSlot(BoundFunctionObject::targetSlot(), target); |
| 6459 |
if (argc > 0) { |
| 6460 |
initSlot(BoundFunctionObject::boundThisSlot(), callInfo_->getArg(0)); |
| 6461 |
} |
| 6462 |
for (size_t i = 0; i < numBoundArgs; i++) { |
| 6463 |
size_t slot = BoundFunctionObject::firstInlineBoundArgSlot() + i; |
| 6464 |
initSlot(slot, callInfo_->getArg(1 + i)); |
| 6465 |
} |
| 6466 |
|
| 6467 |
pushResult(bound); |
| 6468 |
return true; |
| 6469 |
} |
| 6470 |
|
| 6471 |
bool WarpCacheIRTranspiler::emitCallWasmFunction( |
| 6472 |
ObjOperandId calleeId, Int32OperandId argcId, CallFlags flags, |
| 6473 |
uint32_t argcFixed, uint32_t funcExportOffset, uint32_t instanceOffset) { |
| 6474 |
MDefinition* callee = getOperand(calleeId); |
| 6475 |
#ifdef DEBUG |
| 6476 |
MDefinition* argc = getOperand(argcId); |
| 6477 |
MOZ_ASSERT(argc->toConstant()->toInt32() == |
| 6478 |
static_cast<int32_t>(callInfo_->argc())); |
| 6479 |
#endif |
| 6480 |
JSObject* instanceObject = tenuredObjectStubField(instanceOffset); |
| 6481 |
auto* wasmInstanceObj = &instanceObject->as<WasmInstanceObject>(); |
| 6482 |
const wasm::FuncExport* funcExport = wasmFuncExportField(funcExportOffset); |
| 6483 |
const wasm::FuncType& sig = |
| 6484 |
wasmInstanceObj->instance().code().codeMeta().getFuncType( |
| 6485 |
funcExport->funcIndex()); |
| 6486 |
|
| 6487 |
if (!updateCallInfo(callee, flags)) { |
| 6488 |
return false; |
| 6489 |
} |
| 6490 |
|
| 6491 |
static_assert(wasm::MaxArgsForJitInlineCall <= MaxNumLInstructionOperands, |
| 6492 |
"arguments must fit in LIR operands"); |
| 6493 |
MOZ_ASSERT(sig.args().length() <= wasm::MaxArgsForJitInlineCall); |
| 6494 |
|
| 6495 |
MOZ_ASSERT(callInfo_->argFormat() == CallInfo::ArgFormat::Standard); |
| 6496 |
|
| 6497 |
auto* call = MIonToWasmCall::New(alloc(), wasmInstanceObj, *funcExport); |
| 6498 |
if (!call) { |
| 6499 |
return false; |
| 6500 |
} |
| 6501 |
|
| 6502 |
mozilla::Maybe<MDefinition*> undefined; |
| 6503 |
for (size_t i = 0; i < sig.args().length(); i++) { |
| 6504 |
if (!alloc().ensureBallast()) { |
| 6505 |
return false; |
| 6506 |
} |
| 6507 |
|
| 6508 |
MDefinition* arg; |
| 6509 |
if (i < callInfo_->argc()) { |
| 6510 |
arg = callInfo_->getArg(i); |
| 6511 |
} else { |
| 6512 |
if (!undefined) { |
| 6513 |
undefined.emplace(constant(UndefinedValue())); |
| 6514 |
} |
| 6515 |
arg = convertWasmArg(*undefined, sig.args()[i].kind()); |
| 6516 |
} |
| 6517 |
call->initArg(i, arg); |
| 6518 |
} |
| 6519 |
|
| 6520 |
addEffectful(call); |
| 6521 |
|
| 6522 |
// Add any post-function call conversions that are necessary. |
| 6523 |
MInstruction* postConversion = call; |
| 6524 |
const wasm::ValTypeVector& results = sig.results(); |
| 6525 |
MOZ_ASSERT(results.length() <= 1, "Multi-value returns not supported."); |
| 6526 |
if (results.length() == 0) { |
| 6527 |
// No results to convert. |
| 6528 |
} else { |
| 6529 |
switch (results[0].kind()) { |
| 6530 |
case wasm::ValType::I64: |
| 6531 |
// JS expects a BigInt from I64 types. |
| 6532 |
postConversion = |
| 6533 |
MInt64ToBigInt::New(alloc(), call, /* isSigned = */ true); |
| 6534 |
|
| 6535 |
// Make non-movable so we can attach a resume point. |
| 6536 |
postConversion->setNotMovable(); |
| 6537 |
|
| 6538 |
add(postConversion); |
| 6539 |
break; |
| 6540 |
default: |
| 6541 |
// No spectre.index_masking of i32 results required, as the generated |
| 6542 |
// stub takes care of that. |
| 6543 |
break; |
| 6544 |
} |
| 6545 |
} |
| 6546 |
|
| 6547 |
// The resume point has to be attached to the post-conversion instruction |
| 6548 |
// (if present) instead of to the call. This way, if the call triggers an |
| 6549 |
// invalidation bailout, we will have the BigInt value on the Baseline stack. |
| 6550 |
// Potential alternative solution: attach the resume point to the call and |
| 6551 |
// have bailouts turn the Int64 value into a BigInt, maybe with a recover |
| 6552 |
// instruction. |
| 6553 |
pushResult(postConversion); |
| 6554 |
return resumeAfterUnchecked(postConversion); |
| 6555 |
} |
| 6556 |
|
| 6557 |
MDefinition* WarpCacheIRTranspiler::convertWasmArg(MDefinition* arg, |
| 6558 |
wasm::ValType::Kind kind) { |
| 6559 |
// An invariant in this code is that any type conversion operation that has |
| 6560 |
// externally visible effects, such as invoking valueOf on an object argument, |
| 6561 |
// must bailout so that we don't have to worry about replaying effects during |
| 6562 |
// argument conversion. |
| 6563 |
MInstruction* conversion = nullptr; |
| 6564 |
switch (kind) { |
| 6565 |
case wasm::ValType::I32: |
| 6566 |
conversion = MTruncateToInt32::New(alloc(), arg); |
| 6567 |
break; |
| 6568 |
case wasm::ValType::I64: |
| 6569 |
conversion = MToInt64::New(alloc(), arg); |
| 6570 |
break; |
| 6571 |
case wasm::ValType::F32: |
| 6572 |
conversion = MToFloat32::New(alloc(), arg); |
| 6573 |
break; |
| 6574 |
case wasm::ValType::F64: |
| 6575 |
conversion = MToDouble::New(alloc(), arg); |
| 6576 |
break; |
| 6577 |
case wasm::ValType::V128: |
| 6578 |
MOZ_CRASH("Unexpected type for Wasm JitEntry"); |
| 6579 |
case wasm::ValType::Ref: |
| 6580 |
// Transform the JS representation into an AnyRef representation. |
| 6581 |
// The resulting type is MIRType::WasmAnyRef. These cases are all |
| 6582 |
// effect-free. |
| 6583 |
switch (arg->type()) { |
| 6584 |
case MIRType::Object: |
| 6585 |
conversion = MWasmAnyRefFromJSObject::New(alloc(), arg); |
| 6586 |
break; |
| 6587 |
case MIRType::String: |
| 6588 |
conversion = MWasmAnyRefFromJSString::New(alloc(), arg); |
| 6589 |
break; |
| 6590 |
case MIRType::Null: |
| 6591 |
arg->setImplicitlyUsedUnchecked(); |
| 6592 |
conversion = MWasmNullConstant::New(alloc(), wasm::MaybeRefType()); |
| 6593 |
break; |
| 6594 |
default: |
| 6595 |
conversion = MWasmAnyRefFromJSValue::New(alloc(), arg); |
| 6596 |
break; |
| 6597 |
} |
| 6598 |
break; |
| 6599 |
} |
| 6600 |
|
| 6601 |
add(conversion); |
| 6602 |
return conversion; |
| 6603 |
} |
| 6604 |
|
| 6605 |
bool WarpCacheIRTranspiler::emitGuardWasmArg(ValOperandId argId, |
| 6606 |
wasm::ValType::Kind kind) { |
| 6607 |
MDefinition* arg = getOperand(argId); |
| 6608 |
MDefinition* conversion = convertWasmArg(arg, kind); |
| 6609 |
|
| 6610 |
setOperand(argId, conversion); |
| 6611 |
return true; |
| 6612 |
} |
| 6613 |
|
| 6614 |
bool WarpCacheIRTranspiler::emitCallGetterResult(CallKind kind, |
| 6615 |
ValOperandId receiverId, |
| 6616 |
uint32_t getterOffset, |
| 6617 |
bool sameRealm, |
| 6618 |
uint32_t nargsAndFlagsOffset) { |
| 6619 |
MDefinition* receiver = getOperand(receiverId); |
| 6620 |
MDefinition* getter = objectStubField(getterOffset); |
| 6621 |
if (kind == CallKind::Scripted && callInfo_ && callInfo_->isInlined()) { |
| 6622 |
// We are transpiling to generate the correct guards. We also update the |
| 6623 |
// CallInfo to use the correct arguments. Code for the inlined getter |
| 6624 |
// itself will be generated in WarpBuilder::buildInlinedCall. |
| 6625 |
callInfo_->initForGetterCall(getter, receiver); |
| 6626 |
callInfo_->setInliningResumeMode(ResumeMode::InlinedAccessor); |
| 6627 |
|
| 6628 |
// Make sure there's enough room to push the arguments on the stack. |
| 6629 |
if (!current->ensureHasSlots(2)) { |
| 6630 |
return false; |
| 6631 |
} |
| 6632 |
|
| 6633 |
return true; |
| 6634 |
} |
| 6635 |
|
| 6636 |
uint32_t nargsAndFlags = uint32StubField(nargsAndFlagsOffset); |
| 6637 |
uint16_t nargs = nargsAndFlags >> 16; |
| 6638 |
FunctionFlags flags = FunctionFlags(uint16_t(nargsAndFlags)); |
| 6639 |
WrappedFunction* wrappedTarget = |
| 6640 |
maybeWrappedFunction(getter, kind, nargs, flags); |
| 6641 |
|
| 6642 |
bool ignoresRval = loc_.resultIsPopped(); |
| 6643 |
CallInfo callInfo(alloc(), /* constructing = */ false, ignoresRval); |
| 6644 |
callInfo.initForGetterCall(getter, receiver); |
| 6645 |
|
| 6646 |
MCall* call = makeCall(callInfo, /* needsThisCheck = */ false, wrappedTarget); |
| 6647 |
if (!call) { |
| 6648 |
return false; |
| 6649 |
} |
| 6650 |
|
| 6651 |
if (sameRealm) { |
| 6652 |
call->setNotCrossRealm(); |
| 6653 |
} |
| 6654 |
|
| 6655 |
addEffectful(call); |
| 6656 |
pushResult(call); |
| 6657 |
|
| 6658 |
return resumeAfter(call); |
| 6659 |
} |
| 6660 |
|
| 6661 |
bool WarpCacheIRTranspiler::emitCallScriptedGetterResult( |
| 6662 |
ValOperandId receiverId, uint32_t getterOffset, bool sameRealm, |
| 6663 |
uint32_t nargsAndFlagsOffset) { |
| 6664 |
return emitCallGetterResult(CallKind::Scripted, receiverId, getterOffset, |
| 6665 |
sameRealm, nargsAndFlagsOffset); |
| 6666 |
} |
| 6667 |
|
| 6668 |
bool WarpCacheIRTranspiler::emitCallInlinedGetterResult( |
| 6669 |
ValOperandId receiverId, uint32_t getterOffset, uint32_t icScriptOffset, |
| 6670 |
bool sameRealm, uint32_t nargsAndFlagsOffset) { |
| 6671 |
return emitCallGetterResult(CallKind::Scripted, receiverId, getterOffset, |
| 6672 |
sameRealm, nargsAndFlagsOffset); |
| 6673 |
} |
| 6674 |
|
| 6675 |
bool WarpCacheIRTranspiler::emitCallNativeGetterResult( |
| 6676 |
ValOperandId receiverId, uint32_t getterOffset, bool sameRealm, |
| 6677 |
uint32_t nargsAndFlagsOffset) { |
| 6678 |
return emitCallGetterResult(CallKind::Native, receiverId, getterOffset, |
| 6679 |
sameRealm, nargsAndFlagsOffset); |
| 6680 |
} |
| 6681 |
|
| 6682 |
bool WarpCacheIRTranspiler::emitCallSetter(CallKind kind, |
| 6683 |
ObjOperandId receiverId, |
| 6684 |
uint32_t setterOffset, |
| 6685 |
ValOperandId rhsId, bool sameRealm, |
| 6686 |
uint32_t nargsAndFlagsOffset) { |
| 6687 |
MDefinition* receiver = getOperand(receiverId); |
| 6688 |
MDefinition* setter = objectStubField(setterOffset); |
| 6689 |
MDefinition* rhs = getOperand(rhsId); |
| 6690 |
if (kind == CallKind::Scripted && callInfo_ && callInfo_->isInlined()) { |
| 6691 |
// We are transpiling to generate the correct guards. We also update the |
| 6692 |
// CallInfo to use the correct arguments. Code for the inlined setter |
| 6693 |
// itself will be generated in WarpBuilder::buildInlinedCall. |
| 6694 |
callInfo_->initForSetterCall(setter, receiver, rhs); |
| 6695 |
callInfo_->setInliningResumeMode(ResumeMode::InlinedAccessor); |
| 6696 |
|
| 6697 |
// Make sure there's enough room to push the arguments on the stack. |
| 6698 |
if (!current->ensureHasSlots(3)) { |
| 6699 |
return false; |
| 6700 |
} |
| 6701 |
|
| 6702 |
return true; |
| 6703 |
} |
| 6704 |
|
| 6705 |
uint32_t nargsAndFlags = uint32StubField(nargsAndFlagsOffset); |
| 6706 |
uint16_t nargs = nargsAndFlags >> 16; |
| 6707 |
FunctionFlags flags = FunctionFlags(uint16_t(nargsAndFlags)); |
| 6708 |
WrappedFunction* wrappedTarget = |
| 6709 |
maybeWrappedFunction(setter, kind, nargs, flags); |
| 6710 |
|
| 6711 |
CallInfo callInfo(alloc(), /* constructing = */ false, |
| 6712 |
/* ignoresReturnValue = */ true); |
| 6713 |
callInfo.initForSetterCall(setter, receiver, rhs); |
| 6714 |
|
| 6715 |
MCall* call = makeCall(callInfo, /* needsThisCheck = */ false, wrappedTarget); |
| 6716 |
if (!call) { |
| 6717 |
return false; |
| 6718 |
} |
| 6719 |
|
| 6720 |
if (sameRealm) { |
| 6721 |
call->setNotCrossRealm(); |
| 6722 |
} |
| 6723 |
|
| 6724 |
addEffectful(call); |
| 6725 |
return resumeAfter(call); |
| 6726 |
} |
| 6727 |
|
| 6728 |
bool WarpCacheIRTranspiler::emitCallScriptedSetter( |
| 6729 |
ObjOperandId receiverId, uint32_t setterOffset, ValOperandId rhsId, |
| 6730 |
bool sameRealm, uint32_t nargsAndFlagsOffset) { |
| 6731 |
return emitCallSetter(CallKind::Scripted, receiverId, setterOffset, rhsId, |
| 6732 |
sameRealm, nargsAndFlagsOffset); |
| 6733 |
} |
| 6734 |
|
| 6735 |
bool WarpCacheIRTranspiler::emitCallInlinedSetter( |
| 6736 |
ObjOperandId receiverId, uint32_t setterOffset, ValOperandId rhsId, |
| 6737 |
uint32_t icScriptOffset, bool sameRealm, uint32_t nargsAndFlagsOffset) { |
| 6738 |
return emitCallSetter(CallKind::Scripted, receiverId, setterOffset, rhsId, |
| 6739 |
sameRealm, nargsAndFlagsOffset); |
| 6740 |
} |
| 6741 |
|
| 6742 |
bool WarpCacheIRTranspiler::emitCallNativeSetter(ObjOperandId receiverId, |
| 6743 |
uint32_t setterOffset, |
| 6744 |
ValOperandId rhsId, |
| 6745 |
bool sameRealm, |
| 6746 |
uint32_t nargsAndFlagsOffset) { |
| 6747 |
return emitCallSetter(CallKind::Native, receiverId, setterOffset, rhsId, |
| 6748 |
sameRealm, nargsAndFlagsOffset); |
| 6749 |
} |
| 6750 |
|
| 6751 |
bool WarpCacheIRTranspiler::emitMetaScriptedThisShape( |
| 6752 |
uint32_t thisShapeOffset) { |
| 6753 |
SharedShape* shape = &shapeStubField(thisShapeOffset)->asShared(); |
| 6754 |
MOZ_ASSERT(shape->getObjectClass() == &PlainObject::class_); |
| 6755 |
|
| 6756 |
MConstant* shapeConst = MConstant::NewShape(alloc(), shape); |
| 6757 |
add(shapeConst); |
| 6758 |
|
| 6759 |
// TODO: support pre-tenuring. |
| 6760 |
gc::Heap heap = gc::Heap::Default; |
| 6761 |
|
| 6762 |
uint32_t numFixedSlots = shape->numFixedSlots(); |
| 6763 |
uint32_t numDynamicSlots = NativeObject::calculateDynamicSlots(shape); |
| 6764 |
gc::AllocKind kind = gc::GetGCObjectKind(numFixedSlots); |
| 6765 |
MOZ_ASSERT(gc::GetObjectFinalizeKind(&PlainObject::class_) == |
| 6766 |
gc::FinalizeKind::None); |
| 6767 |
MOZ_ASSERT(!IsFinalizedKind(kind)); |
| 6768 |
|
| 6769 |
auto* createThis = MNewPlainObject::New(alloc(), shapeConst, numFixedSlots, |
| 6770 |
numDynamicSlots, kind, heap); |
| 6771 |
add(createThis); |
| 6772 |
|
| 6773 |
callInfo_->thisArg()->setImplicitlyUsedUnchecked(); |
| 6774 |
callInfo_->setThis(createThis); |
| 6775 |
return true; |
| 6776 |
} |
| 6777 |
|
| 6778 |
bool WarpCacheIRTranspiler::emitReturnFromIC() { return true; } |
| 6779 |
|
| 6780 |
bool WarpCacheIRTranspiler::emitBailout() { |
| 6781 |
auto* bail = MBail::New(alloc()); |
| 6782 |
add(bail); |
| 6783 |
|
| 6784 |
return true; |
| 6785 |
} |
| 6786 |
|
| 6787 |
bool WarpCacheIRTranspiler::emitAssertPropertyLookup(ObjOperandId objId, |
| 6788 |
uint32_t idOffset, |
| 6789 |
uint32_t slotOffset) { |
| 6790 |
// We currently only emit checks in baseline. |
| 6791 |
return true; |
| 6792 |
} |
| 6793 |
|
| 6794 |
bool WarpCacheIRTranspiler::emitAssertFloat32Result(ValOperandId valId, |
| 6795 |
bool mustBeFloat32) { |
| 6796 |
MDefinition* val = getOperand(valId); |
| 6797 |
|
| 6798 |
auto* assert = MAssertFloat32::New(alloc(), val, mustBeFloat32); |
| 6799 |
addEffectful(assert); |
| 6800 |
|
| 6801 |
pushResult(constant(UndefinedValue())); |
| 6802 |
return resumeAfter(assert); |
| 6803 |
} |
| 6804 |
|
| 6805 |
bool WarpCacheIRTranspiler::emitAssertRecoveredOnBailoutResult( |
| 6806 |
ValOperandId valId, bool mustBeRecovered) { |
| 6807 |
MDefinition* val = getOperand(valId); |
| 6808 |
|
| 6809 |
// Don't assert for recovered instructions when recovering is disabled. |
| 6810 |
if (JitOptions.disableRecoverIns) { |
| 6811 |
pushResult(constant(UndefinedValue())); |
| 6812 |
return true; |
| 6813 |
} |
| 6814 |
|
| 6815 |
if (JitOptions.checkRangeAnalysis) { |
| 6816 |
// If we are checking the range of all instructions, then the guards |
| 6817 |
// inserted by Range Analysis prevent the use of recover instruction. Thus, |
| 6818 |
// we just disable these checks. |
| 6819 |
pushResult(constant(UndefinedValue())); |
| 6820 |
return true; |
| 6821 |
} |
| 6822 |
|
| 6823 |
auto* assert = MAssertRecoveredOnBailout::New(alloc(), val, mustBeRecovered); |
| 6824 |
addEffectfulUnsafe(assert); |
| 6825 |
current->push(assert); |
| 6826 |
|
| 6827 |
// Create an instruction sequence which implies that the argument of the |
| 6828 |
// assertRecoveredOnBailout function would be encoded at least in one |
| 6829 |
// Snapshot. |
| 6830 |
auto* nop = MNop::New(alloc()); |
| 6831 |
add(nop); |
| 6832 |
|
| 6833 |
auto* resumePoint = MResumePoint::New( |
| 6834 |
alloc(), nop->block(), loc_.toRawBytecode(), ResumeMode::ResumeAfter); |
| 6835 |
if (!resumePoint) { |
| 6836 |
return false; |
| 6837 |
} |
| 6838 |
nop->setResumePoint(resumePoint); |
| 6839 |
|
| 6840 |
auto* encode = MEncodeSnapshot::New(alloc()); |
| 6841 |
addEffectfulUnsafe(encode); |
| 6842 |
|
| 6843 |
current->pop(); |
| 6844 |
|
| 6845 |
pushResult(constant(UndefinedValue())); |
| 6846 |
return true; |
| 6847 |
} |
| 6848 |
|
| 6849 |
bool WarpCacheIRTranspiler::emitGuardNoAllocationMetadataBuilder( |
| 6850 |
uint32_t builderAddrOffset) { |
| 6851 |
// This is a no-op because we discard all JIT code when set an allocation |
| 6852 |
// metadata callback. |
| 6853 |
return true; |
| 6854 |
} |
| 6855 |
|
| 6856 |
bool WarpCacheIRTranspiler::emitNewPlainObjectResult(uint32_t numFixedSlots, |
| 6857 |
uint32_t numDynamicSlots, |
| 6858 |
gc::AllocKind allocKind, |
| 6859 |
uint32_t shapeOffset, |
| 6860 |
uint32_t siteOffset) { |
| 6861 |
Shape* shape = shapeStubField(shapeOffset); |
| 6862 |
gc::Heap heap = allocSiteInitialHeapField(siteOffset); |
| 6863 |
|
| 6864 |
auto* shapeConstant = MConstant::NewShape(alloc(), shape); |
| 6865 |
add(shapeConstant); |
| 6866 |
|
| 6867 |
auto* obj = MNewPlainObject::New(alloc(), shapeConstant, numFixedSlots, |
| 6868 |
numDynamicSlots, allocKind, heap); |
| 6869 |
add(obj); |
| 6870 |
|
| 6871 |
pushResult(obj); |
| 6872 |
return true; |
| 6873 |
} |
| 6874 |
|
| 6875 |
bool WarpCacheIRTranspiler::emitNewArrayObjectResult(uint32_t length, |
| 6876 |
uint32_t shapeOffset, |
| 6877 |
uint32_t siteOffset) { |
| 6878 |
Shape* shape = shapeStubField(shapeOffset); |
| 6879 |
gc::Heap heap = allocSiteInitialHeapField(siteOffset); |
| 6880 |
|
| 6881 |
auto* shapeConstant = MConstant::NewShape(alloc(), shape); |
| 6882 |
add(shapeConstant); |
| 6883 |
|
| 6884 |
auto* obj = MNewArrayObject::New(alloc(), shapeConstant, length, heap); |
| 6885 |
add(obj); |
| 6886 |
|
| 6887 |
pushResult(obj); |
| 6888 |
return true; |
| 6889 |
} |
| 6890 |
|
| 6891 |
bool WarpCacheIRTranspiler::emitNewFunctionCloneResult(uint32_t canonicalOffset, |
| 6892 |
gc::AllocKind allocKind, |
| 6893 |
uint32_t siteOffset) { |
| 6894 |
JSObject* fun = tenuredObjectStubField(canonicalOffset); |
| 6895 |
MOZ_ASSERT(fun->is<JSFunction>()); |
| 6896 |
|
| 6897 |
gc::Heap heap = allocSiteInitialHeapField(siteOffset); |
| 6898 |
|
| 6899 |
MDefinition* env = currentBlock()->environmentChain(); |
| 6900 |
|
| 6901 |
// The environment chain must be an object, but the MIR type can be Value when |
| 6902 |
// phis are involved. |
| 6903 |
if (env->type() != MIRType::Object) { |
| 6904 |
MOZ_ASSERT(env->type() == MIRType::Value); |
| 6905 |
auto* unbox = |
| 6906 |
MUnbox::New(alloc(), env, MIRType::Object, MUnbox::Infallible); |
| 6907 |
current->add(unbox); |
| 6908 |
env = unbox; |
| 6909 |
} |
| 6910 |
|
| 6911 |
MConstant* funConst = constant(ObjectValue(*fun)); |
| 6912 |
|
| 6913 |
auto* ins = MLambda::New(alloc(), env, funConst, heap); |
| 6914 |
addEffectful(ins); |
| 6915 |
pushResult(ins); |
| 6916 |
return resumeAfter(ins); |
| 6917 |
} |
| 6918 |
|
| 6919 |
bool WarpCacheIRTranspiler::emitCloseIterScriptedResult(ObjOperandId iterId, |
| 6920 |
ObjOperandId calleeId, |
| 6921 |
CompletionKind kind, |
| 6922 |
uint32_t calleeNargs) { |
| 6923 |
MDefinition* iter = getOperand(iterId); |
| 6924 |
MDefinition* callee = getOperand(calleeId); |
| 6925 |
|
| 6926 |
WrappedFunction* wrappedTarget = maybeCallTarget(callee, CallKind::Scripted); |
| 6927 |
MOZ_ASSERT(wrappedTarget); |
| 6928 |
MOZ_ASSERT(wrappedTarget->nargs() == calleeNargs); |
| 6929 |
MOZ_ASSERT(wrappedTarget->hasJitEntry()); |
| 6930 |
|
| 6931 |
bool constructing = false; |
| 6932 |
bool ignoresRval = false; |
| 6933 |
bool needsThisCheck = false; |
| 6934 |
CallInfo callInfo(alloc(), constructing, ignoresRval); |
| 6935 |
callInfo.initForCloseIter(iter, callee); |
| 6936 |
MCall* call = makeCall(callInfo, needsThisCheck, wrappedTarget); |
| 6937 |
if (!call) { |
| 6938 |
return false; |
| 6939 |
} |
| 6940 |
addEffectful(call); |
| 6941 |
if (kind == CompletionKind::Throw) { |
| 6942 |
return resumeAfter(call); |
| 6943 |
} |
| 6944 |
|
| 6945 |
// If we bail out here, after the call but before the CheckIsObj, we |
| 6946 |
// can't simply resume in the baseline interpreter. If we resume |
| 6947 |
// after the CloseIter, we won't check the return value. If we |
| 6948 |
// resume at the CloseIter, we will call the |return| method twice. |
| 6949 |
// Instead, we use a special resume mode that captures the |
| 6950 |
// intermediate value, and then checks that it's an object while |
| 6951 |
// bailing out. |
| 6952 |
current->push(call); |
| 6953 |
MResumePoint* resumePoint = |
| 6954 |
MResumePoint::New(alloc(), current, loc_.toRawBytecode(), |
| 6955 |
ResumeMode::ResumeAfterCheckIsObject); |
| 6956 |
if (!resumePoint) { |
| 6957 |
return false; |
| 6958 |
} |
| 6959 |
call->setResumePoint(resumePoint); |
| 6960 |
current->pop(); |
| 6961 |
|
| 6962 |
MCheckIsObj* check = MCheckIsObj::New( |
| 6963 |
alloc(), call, uint8_t(CheckIsObjectKind::IteratorReturn)); |
| 6964 |
addEffectfulUnsafe(check); |
| 6965 |
|
| 6966 |
return resumeAfterUnchecked(check); |
| 6967 |
} |
| 6968 |
|
| 6969 |
bool WarpCacheIRTranspiler::emitGuardGlobalGeneration( |
| 6970 |
uint32_t expectedOffset, uint32_t generationAddrOffset) { |
| 6971 |
uint32_t expected = uint32StubField(expectedOffset); |
| 6972 |
const void* generationAddr = rawPointerField(generationAddrOffset); |
| 6973 |
|
| 6974 |
auto guard = MGuardGlobalGeneration::New(alloc(), expected, generationAddr); |
| 6975 |
add(guard); |
| 6976 |
|
| 6977 |
return true; |
| 6978 |
} |
| 6979 |
|
| 6980 |
#ifdef FUZZING_JS_FUZZILLI |
| 6981 |
bool WarpCacheIRTranspiler::emitFuzzilliHashResult(ValOperandId valId) { |
| 6982 |
MDefinition* input = getOperand(valId); |
| 6983 |
|
| 6984 |
auto* hash = MFuzzilliHash::New(alloc(), input); |
| 6985 |
add(hash); |
| 6986 |
|
| 6987 |
auto* store = MFuzzilliHashStore::New(alloc(), hash); |
| 6988 |
addEffectful(store); |
| 6989 |
pushResult(constant(UndefinedValue())); |
| 6990 |
|
| 6991 |
return resumeAfter(store); |
| 6992 |
} |
| 6993 |
#endif |
| 6994 |
|
| 6995 |
static void MaybeSetImplicitlyUsed(uint32_t numInstructionIdsBefore, |
| 6996 |
MDefinition* input) { |
| 6997 |
// When building MIR from bytecode, for each MDefinition that's an operand to |
| 6998 |
// a bytecode instruction, we must either add an SSA use or set the |
| 6999 |
// ImplicitlyUsed flag on that definition. The ImplicitlyUsed flag prevents |
| 7000 |
// the backend from optimizing-out values that will be used by Baseline after |
| 7001 |
// a bailout. |
| 7002 |
// |
| 7003 |
// WarpBuilder uses WarpPoppedValueUseChecker to assert this invariant in |
| 7004 |
// debug builds. |
| 7005 |
// |
| 7006 |
// This function is responsible for setting the ImplicitlyUsed flag for an |
| 7007 |
// input when using the transpiler. It looks at the input's most recent use |
| 7008 |
// and if that's an instruction that was added while transpiling this JSOp |
| 7009 |
// (based on the MIR instruction id) we don't set the ImplicitlyUsed flag. |
| 7010 |
|
| 7011 |
if (input->isImplicitlyUsed()) { |
| 7012 |
// Nothing to do. |
| 7013 |
return; |
| 7014 |
} |
| 7015 |
|
| 7016 |
// If the most recent use of 'input' is an instruction we just added, there is |
| 7017 |
// nothing to do. |
| 7018 |
MDefinition* inputUse = input->maybeMostRecentlyAddedDefUse(); |
| 7019 |
if (inputUse && inputUse->id() >= numInstructionIdsBefore) { |
| 7020 |
return; |
| 7021 |
} |
| 7022 |
|
| 7023 |
// The transpiler didn't add a use for 'input'. |
| 7024 |
input->setImplicitlyUsed(); |
| 7025 |
} |
| 7026 |
|
| 7027 |
bool jit::TranspileCacheIRToMIR(WarpBuilder* builder, BytecodeLocation loc, |
| 7028 |
const WarpCacheIR* cacheIRSnapshot, |
| 7029 |
std::initializer_list<MDefinition*> inputs, |
| 7030 |
CallInfo* maybeCallInfo) { |
| 7031 |
uint32_t numInstructionIdsBefore = |
| 7032 |
builder->mirGen().graph().getNumInstructionIds(); |
| 7033 |
|
| 7034 |
WarpCacheIRTranspiler transpiler(builder, loc, maybeCallInfo, |
| 7035 |
cacheIRSnapshot); |
| 7036 |
if (!transpiler.transpile(inputs)) { |
| 7037 |
return false; |
| 7038 |
} |
| 7039 |
|
| 7040 |
for (MDefinition* input : inputs) { |
| 7041 |
MaybeSetImplicitlyUsed(numInstructionIdsBefore, input); |
| 7042 |
} |
| 7043 |
|
| 7044 |
if (maybeCallInfo) { |
| 7045 |
auto maybeSetFlag = [numInstructionIdsBefore](MDefinition* def) { |
| 7046 |
MaybeSetImplicitlyUsed(numInstructionIdsBefore, def); |
| 7047 |
}; |
| 7048 |
maybeCallInfo->forEachCallOperand(maybeSetFlag); |
| 7049 |
} |
| 7050 |
|
| 7051 |
return true; |
| 7052 |
} |