| 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 |
/* |
| 8 |
* JavaScript "portable baseline interpreter": an interpreter that is |
| 9 |
* capable of running ICs, but without any native code. |
| 10 |
* |
| 11 |
* See the [SMDOC] in vm/PortableBaselineInterpret.h for a high-level |
| 12 |
* overview. |
| 13 |
*/ |
| 14 |
|
| 15 |
#include "vm/PortableBaselineInterpret.h" |
| 16 |
|
| 17 |
#include "mozilla/Maybe.h" |
| 18 |
#include <algorithm> |
| 19 |
|
| 20 |
#include "fdlibm.h" |
| 21 |
#include "jsapi.h" |
| 22 |
|
| 23 |
#include "builtin/DataViewObject.h" |
| 24 |
#include "builtin/MapObject.h" |
| 25 |
#include "builtin/Object.h" |
| 26 |
#include "builtin/RegExp.h" |
| 27 |
#include "builtin/String.h" |
| 28 |
#include "debugger/DebugAPI.h" |
| 29 |
#include "jit/BaselineFrame.h" |
| 30 |
#include "jit/BaselineIC.h" |
| 31 |
#include "jit/BaselineJIT.h" |
| 32 |
#include "jit/CacheIR.h" |
| 33 |
#include "jit/CacheIRCompiler.h" |
| 34 |
#include "jit/CacheIRReader.h" |
| 35 |
#include "jit/JitFrames.h" |
| 36 |
#include "jit/JitScript.h" |
| 37 |
#include "jit/JSJitFrameIter.h" |
| 38 |
#include "jit/VMFunctions.h" |
| 39 |
#include "proxy/DeadObjectProxy.h" |
| 40 |
#include "proxy/DOMProxy.h" |
| 41 |
#include "util/Unicode.h" |
| 42 |
#include "vm/AsyncFunction.h" |
| 43 |
#include "vm/AsyncIteration.h" |
| 44 |
#include "vm/DateObject.h" |
| 45 |
#include "vm/EnvironmentObject.h" |
| 46 |
#include "vm/EqualityOperations.h" |
| 47 |
#include "vm/GeneratorObject.h" |
| 48 |
#include "vm/Interpreter.h" |
| 49 |
#include "vm/Iteration.h" |
| 50 |
#include "vm/JitActivation.h" |
| 51 |
#include "vm/JSObject.h" |
| 52 |
#include "vm/JSScript.h" |
| 53 |
#include "vm/Opcodes.h" |
| 54 |
#include "vm/PlainObject.h" |
| 55 |
#include "vm/Shape.h" |
| 56 |
#include "vm/TypeofEqOperand.h" // TypeofEqOperand |
| 57 |
#include "vm/WrapperObject.h" |
| 58 |
|
| 59 |
#include "debugger/DebugAPI-inl.h" |
| 60 |
#include "jit/BaselineFrame-inl.h" |
| 61 |
#include "jit/JitScript-inl.h" |
| 62 |
#include "vm/EnvironmentObject-inl.h" |
| 63 |
#include "vm/Interpreter-inl.h" |
| 64 |
#include "vm/JSScript-inl.h" |
| 65 |
#include "vm/PlainObject-inl.h" |
| 66 |
|
| 67 |
namespace js { |
| 68 |
namespace pbl { |
| 69 |
|
| 70 |
using namespace js::jit; |
| 71 |
|
| 72 |
/* |
| 73 |
* Debugging: enable `TRACE_INTERP` for an extremely detailed dump of |
| 74 |
* what PBL is doing at every opcode step. |
| 75 |
*/ |
| 76 |
|
| 77 |
// #define TRACE_INTERP |
| 78 |
|
| 79 |
#ifdef TRACE_INTERP |
| 80 |
# define TRACE_PRINTF(...) \ |
| 81 |
do { \ |
| 82 |
printf(__VA_ARGS__); \ |
| 83 |
fflush(stdout); \ |
| 84 |
} while (0) |
| 85 |
#else |
| 86 |
# define TRACE_PRINTF(...) \ |
| 87 |
do { \ |
| 88 |
} while (0) |
| 89 |
#endif |
| 90 |
|
| 91 |
#define PBL_HYBRID_ICS_DEFAULT true |
| 92 |
|
| 93 |
// Whether we are using the "hybrid" strategy for ICs (see the [SMDOC] |
| 94 |
// in PortableBaselineInterpret.h for more). This is currently a |
| 95 |
// constant, but may become configurable in the future. |
| 96 |
static const bool kHybridICsInterp = PBL_HYBRID_ICS_DEFAULT; |
| 97 |
|
| 98 |
// Whether to compile interpreter dispatch loops using computed gotos |
| 99 |
// or direct switches. |
| 100 |
#if !defined(__wasi__) && !defined(TRACE_INTERP) |
| 101 |
# define ENABLE_COMPUTED_GOTO_DISPATCH |
| 102 |
#endif |
| 103 |
|
| 104 |
// Whether to compile in interrupt checks in the main interpreter loop. |
| 105 |
#ifndef __wasi__ |
| 106 |
// On WASI, with a single thread, there is no possibility for an |
| 107 |
// interrupt to come asynchronously. |
| 108 |
# define ENABLE_INTERRUPT_CHECKS |
| 109 |
#endif |
| 110 |
|
| 111 |
// Whether to compile in coverage counting in the main interpreter loop. |
| 112 |
#ifndef __wasi__ |
| 113 |
# define ENABLE_COVERAGE |
| 114 |
#endif |
| 115 |
|
| 116 |
/* |
| 117 |
* ----------------------------------------------- |
| 118 |
* Stack handling |
| 119 |
* ----------------------------------------------- |
| 120 |
*/ |
| 121 |
|
| 122 |
// Large enough for an exit frame. |
| 123 |
static const size_t kStackMargin = 1024; |
| 124 |
|
| 125 |
/* |
| 126 |
* A 64-bit value on the auxiliary stack. May either be a raw uint64_t |
| 127 |
* or a `Value` (JS NaN-boxed value). |
| 128 |
*/ |
| 129 |
struct StackVal { |
| 130 |
uint64_t value; |
| 131 |
|
| 132 |
explicit StackVal(uint64_t v) : value(v) {} |
| 133 |
explicit StackVal(const Value& v) : value(v.asRawBits()) {} |
| 134 |
|
| 135 |
uint64_t asUInt64() const { return value; } |
| 136 |
Value asValue() const { return Value::fromRawBits(value); } |
| 137 |
}; |
| 138 |
|
| 139 |
/* |
| 140 |
* A native-pointer-sized value on the auxiliary stack. This is |
| 141 |
* separate from the above because we support running on 32-bit |
| 142 |
* systems as well! May either be a `void*` (or cast to a |
| 143 |
* `CalleeToken`, which is a typedef for a `void*`), or a `uint32_t`, |
| 144 |
* which always fits in a native pointer width on our supported |
| 145 |
* platforms. (See static_assert below.) |
| 146 |
*/ |
| 147 |
struct StackValNative { |
| 148 |
static_assert(sizeof(uintptr_t) >= sizeof(uint32_t), |
| 149 |
"Must be at least a 32-bit system to use PBL."); |
| 150 |
|
| 151 |
uintptr_t value; |
| 152 |
|
| 153 |
explicit StackValNative(void* v) : value(reinterpret_cast<uintptr_t>(v)) {} |
| 154 |
explicit StackValNative(uint32_t v) : value(v) {} |
| 155 |
|
| 156 |
void* asVoidPtr() const { return reinterpret_cast<void*>(value); } |
| 157 |
CalleeToken asCalleeToken() const { |
| 158 |
return reinterpret_cast<CalleeToken>(value); |
| 159 |
} |
| 160 |
}; |
| 161 |
|
| 162 |
// Assert that the stack alignment is no more than the size of a |
| 163 |
// StackValNative -- we rely on this when setting up call frames. |
| 164 |
static_assert(JitStackAlignment <= sizeof(StackValNative)); |
| 165 |
|
| 166 |
#define PUSH(val) *--sp = (val) |
| 167 |
#define POP() (*sp++) |
| 168 |
#define POPN(n) sp += (n) |
| 169 |
|
| 170 |
#define PUSHNATIVE(val) \ |
| 171 |
do { \ |
| 172 |
StackValNative* nativeSP = reinterpret_cast<StackValNative*>(sp); \ |
| 173 |
*--nativeSP = (val); \ |
| 174 |
sp = reinterpret_cast<StackVal*>(nativeSP); \ |
| 175 |
} while (0) |
| 176 |
#define POPNNATIVE(n) \ |
| 177 |
sp = reinterpret_cast<StackVal*>(reinterpret_cast<StackValNative*>(sp) + (n)) |
| 178 |
|
| 179 |
/* |
| 180 |
* Helper class to manage the auxiliary stack and push/pop frames. |
| 181 |
*/ |
| 182 |
struct Stack { |
| 183 |
StackVal* fp; |
| 184 |
StackVal* base; |
| 185 |
StackVal* top; |
| 186 |
StackVal* unwindingSP; |
| 187 |
StackVal* unwindingFP; |
| 188 |
|
| 189 |
explicit Stack(PortableBaselineStack& pbs) |
| 190 |
: fp(reinterpret_cast<StackVal*>(pbs.top)), |
| 191 |
base(reinterpret_cast<StackVal*>(pbs.base)), |
| 192 |
top(reinterpret_cast<StackVal*>(pbs.top)), |
| 193 |
unwindingSP(nullptr), |
| 194 |
unwindingFP(nullptr) {} |
| 195 |
|
| 196 |
MOZ_ALWAYS_INLINE bool check(StackVal* sp, size_t size, bool margin = true) { |
| 197 |
return reinterpret_cast<uintptr_t>(base) + size + |
| 198 |
(margin ? kStackMargin : 0) <= |
| 199 |
reinterpret_cast<uintptr_t>(sp); |
| 200 |
} |
| 201 |
|
| 202 |
[[nodiscard]] MOZ_ALWAYS_INLINE StackVal* allocate(StackVal* sp, |
| 203 |
size_t size) { |
| 204 |
if (!check(sp, size, false)) { |
| 205 |
return nullptr; |
| 206 |
} |
| 207 |
sp = reinterpret_cast<StackVal*>(reinterpret_cast<uintptr_t>(sp) - size); |
| 208 |
return sp; |
| 209 |
} |
| 210 |
|
| 211 |
uint32_t frameSize(StackVal* sp, BaselineFrame* curFrame) const { |
| 212 |
return sizeof(StackVal) * (reinterpret_cast<StackVal*>(fp) - sp); |
| 213 |
} |
| 214 |
|
| 215 |
[[nodiscard]] MOZ_ALWAYS_INLINE BaselineFrame* pushFrame(StackVal* sp, |
| 216 |
JSContext* cx, |
| 217 |
JSObject* envChain) { |
| 218 |
TRACE_PRINTF("pushFrame: sp = %p fp = %p\n", sp, fp); |
| 219 |
if (sp == base) { |
| 220 |
return nullptr; |
| 221 |
} |
| 222 |
PUSHNATIVE(StackValNative(fp)); |
| 223 |
fp = sp; |
| 224 |
TRACE_PRINTF("pushFrame: new fp = %p\n", fp); |
| 225 |
|
| 226 |
BaselineFrame* frame = |
| 227 |
reinterpret_cast<BaselineFrame*>(allocate(sp, BaselineFrame::Size())); |
| 228 |
if (!frame) { |
| 229 |
return nullptr; |
| 230 |
} |
| 231 |
|
| 232 |
frame->setFlags(BaselineFrame::Flags::RUNNING_IN_INTERPRETER); |
| 233 |
frame->setEnvironmentChain(envChain); |
| 234 |
JSScript* script = frame->script(); |
| 235 |
frame->setICScript(script->jitScript()->icScript()); |
| 236 |
frame->setInterpreterFieldsForPrologue(script); |
| 237 |
#ifdef DEBUG |
| 238 |
frame->setDebugFrameSize(0); |
| 239 |
#endif |
| 240 |
return frame; |
| 241 |
} |
| 242 |
|
| 243 |
StackVal* popFrame() { |
| 244 |
StackVal* newTOS = |
| 245 |
reinterpret_cast<StackVal*>(reinterpret_cast<StackValNative*>(fp) + 1); |
| 246 |
fp = reinterpret_cast<StackVal*>( |
| 247 |
reinterpret_cast<StackValNative*>(fp)->asVoidPtr()); |
| 248 |
MOZ_ASSERT(fp); |
| 249 |
TRACE_PRINTF("popFrame: fp = %p\n", fp); |
| 250 |
return newTOS; |
| 251 |
} |
| 252 |
|
| 253 |
void setFrameSize(StackVal* sp, BaselineFrame* prevFrame) { |
| 254 |
#ifdef DEBUG |
| 255 |
MOZ_ASSERT(fp != nullptr); |
| 256 |
uintptr_t frameSize = |
| 257 |
reinterpret_cast<uintptr_t>(fp) - reinterpret_cast<uintptr_t>(sp); |
| 258 |
MOZ_ASSERT(reinterpret_cast<uintptr_t>(fp) >= |
| 259 |
reinterpret_cast<uintptr_t>(sp)); |
| 260 |
TRACE_PRINTF("pushExitFrame: fp = %p cur() = %p -> frameSize = %d\n", fp, |
| 261 |
sp, int(frameSize)); |
| 262 |
MOZ_ASSERT(frameSize >= BaselineFrame::Size()); |
| 263 |
prevFrame->setDebugFrameSize(frameSize); |
| 264 |
#endif |
| 265 |
} |
| 266 |
|
| 267 |
[[nodiscard]] MOZ_ALWAYS_INLINE StackVal* pushExitFrame( |
| 268 |
StackVal* sp, BaselineFrame* prevFrame) { |
| 269 |
uint8_t* prevFP = |
| 270 |
reinterpret_cast<uint8_t*>(prevFrame) + BaselineFrame::Size(); |
| 271 |
TRACE_PRINTF( |
| 272 |
"pushExitFrame: prevFrame = %p sp = %p BaselineFrame::Size() = %d -> " |
| 273 |
"computed prevFP = %p actual fp = %p\n", |
| 274 |
prevFrame, sp, int(BaselineFrame::Size()), prevFP, fp); |
| 275 |
MOZ_ASSERT(reinterpret_cast<StackVal*>(prevFP) == fp); |
| 276 |
setFrameSize(sp, prevFrame); |
| 277 |
|
| 278 |
if (!check(sp, sizeof(StackVal) * 4, false)) { |
| 279 |
return nullptr; |
| 280 |
} |
| 281 |
|
| 282 |
PUSHNATIVE(StackValNative( |
| 283 |
MakeFrameDescriptorForJitCall(FrameType::BaselineJS, 0))); |
| 284 |
PUSHNATIVE(StackValNative(nullptr)); // fake return address. |
| 285 |
PUSHNATIVE(StackValNative(prevFP)); |
| 286 |
StackVal* exitFP = sp; |
| 287 |
fp = exitFP; |
| 288 |
TRACE_PRINTF(" -> fp = %p\n", fp); |
| 289 |
PUSHNATIVE(StackValNative(uint32_t(ExitFrameType::Bare))); |
| 290 |
return exitFP; |
| 291 |
} |
| 292 |
|
| 293 |
void popExitFrame(StackVal* fp) { |
| 294 |
StackVal* prevFP = reinterpret_cast<StackVal*>( |
| 295 |
reinterpret_cast<StackValNative*>(fp)->asVoidPtr()); |
| 296 |
MOZ_ASSERT(prevFP); |
| 297 |
this->fp = prevFP; |
| 298 |
TRACE_PRINTF("popExitFrame: fp -> %p\n", fp); |
| 299 |
} |
| 300 |
|
| 301 |
BaselineFrame* frameFromFP() { |
| 302 |
return reinterpret_cast<BaselineFrame*>(reinterpret_cast<uintptr_t>(fp) - |
| 303 |
BaselineFrame::Size()); |
| 304 |
} |
| 305 |
|
| 306 |
static HandleValue handle(StackVal* sp) { |
| 307 |
return HandleValue::fromMarkedLocation(reinterpret_cast<Value*>(sp)); |
| 308 |
} |
| 309 |
static MutableHandleValue handleMut(StackVal* sp) { |
| 310 |
return MutableHandleValue::fromMarkedLocation(reinterpret_cast<Value*>(sp)); |
| 311 |
} |
| 312 |
}; |
| 313 |
|
| 314 |
/* |
| 315 |
* ----------------------------------------------- |
| 316 |
* Interpreter state |
| 317 |
* ----------------------------------------------- |
| 318 |
*/ |
| 319 |
|
| 320 |
struct ICRegs { |
| 321 |
static const int kMaxICVals = 16; |
| 322 |
// Values can be split across two OR'd halves: unboxed bits and |
| 323 |
// tags. We mostly rely on the CacheIRWriter/Reader typed OperandId |
| 324 |
// system to ensure "type safety" in CacheIR w.r.t. unboxing: the |
| 325 |
// existence of an ObjOperandId implies that the value is unboxed, |
| 326 |
// so `icVals` contains a pointer (reinterpret-casted to a |
| 327 |
// `uint64_t`) and `icTags` contains the tag bits. An operator that |
| 328 |
// requires a tagged Value can OR the two together (this corresponds |
| 329 |
// to `useValueRegister` rather than `useRegister` in the native |
| 330 |
// baseline compiler). |
| 331 |
uint64_t icVals[kMaxICVals]; |
| 332 |
uint64_t icTags[kMaxICVals]; // Shifted tags. |
| 333 |
int extraArgs; |
| 334 |
}; |
| 335 |
|
| 336 |
struct State { |
| 337 |
RootedValue value0; |
| 338 |
RootedValue value1; |
| 339 |
RootedValue value2; |
| 340 |
RootedValue value3; |
| 341 |
RootedValue res; |
| 342 |
RootedObject obj0; |
| 343 |
RootedObject obj1; |
| 344 |
RootedObject obj2; |
| 345 |
RootedString str0; |
| 346 |
RootedString str1; |
| 347 |
RootedString str2; |
| 348 |
RootedScript script0; |
| 349 |
Rooted<PropertyName*> name0; |
| 350 |
Rooted<jsid> id0; |
| 351 |
Rooted<JSAtom*> atom0; |
| 352 |
RootedFunction fun0; |
| 353 |
Rooted<Scope*> scope0; |
| 354 |
|
| 355 |
explicit State(JSContext* cx) |
| 356 |
: value0(cx), |
| 357 |
value1(cx), |
| 358 |
value2(cx), |
| 359 |
value3(cx), |
| 360 |
res(cx), |
| 361 |
obj0(cx), |
| 362 |
obj1(cx), |
| 363 |
obj2(cx), |
| 364 |
str0(cx), |
| 365 |
str1(cx), |
| 366 |
str2(cx), |
| 367 |
script0(cx), |
| 368 |
name0(cx), |
| 369 |
id0(cx), |
| 370 |
atom0(cx), |
| 371 |
fun0(cx), |
| 372 |
scope0(cx) {} |
| 373 |
}; |
| 374 |
|
| 375 |
/* |
| 376 |
* ----------------------------------------------- |
| 377 |
* RAII helpers for pushing exit frames. |
| 378 |
* |
| 379 |
* (See [SMDOC] in PortableBaselineInterpret.h for more.) |
| 380 |
* ----------------------------------------------- |
| 381 |
*/ |
| 382 |
|
| 383 |
class VMFrameManager { |
| 384 |
JSContext* cx; |
| 385 |
BaselineFrame* frame; |
| 386 |
friend class VMFrame; |
| 387 |
|
| 388 |
public: |
| 389 |
VMFrameManager(JSContext*& cx_, BaselineFrame* frame_) |
| 390 |
: cx(cx_), frame(frame_) { |
| 391 |
// Once the manager exists, we need to create an exit frame to |
| 392 |
// have access to the cx (unless the caller promises it is not |
| 393 |
// calling into the rest of the runtime). |
| 394 |
cx_ = nullptr; |
| 395 |
} |
| 396 |
|
| 397 |
void switchToFrame(BaselineFrame* frame) { this->frame = frame; } |
| 398 |
|
| 399 |
// Provides the JSContext, but *only* if no calls into the rest of |
| 400 |
// the runtime (that may invoke a GC or stack walk) occur. Avoids |
| 401 |
// the overhead of pushing an exit frame. |
| 402 |
JSContext* cxForLocalUseOnly() const { return cx; } |
| 403 |
}; |
| 404 |
|
| 405 |
class VMFrame { |
| 406 |
JSContext* cx; |
| 407 |
Stack& stack; |
| 408 |
StackVal* exitFP; |
| 409 |
void* prevSavedStack; |
| 410 |
|
| 411 |
public: |
| 412 |
VMFrame(VMFrameManager& mgr, Stack& stack_, StackVal* sp) |
| 413 |
: cx(mgr.cx), stack(stack_) { |
| 414 |
exitFP = stack.pushExitFrame(sp, mgr.frame); |
| 415 |
if (!exitFP) { |
| 416 |
return; |
| 417 |
} |
| 418 |
cx->activation()->asJit()->setJSExitFP(reinterpret_cast<uint8_t*>(exitFP)); |
| 419 |
prevSavedStack = cx->portableBaselineStack().top; |
| 420 |
cx->portableBaselineStack().top = reinterpret_cast<void*>(spBelowFrame()); |
| 421 |
} |
| 422 |
|
| 423 |
StackVal* spBelowFrame() { |
| 424 |
return reinterpret_cast<StackVal*>(reinterpret_cast<uintptr_t>(exitFP) - |
| 425 |
sizeof(StackValNative)); |
| 426 |
} |
| 427 |
|
| 428 |
~VMFrame() { |
| 429 |
stack.popExitFrame(exitFP); |
| 430 |
cx->portableBaselineStack().top = prevSavedStack; |
| 431 |
} |
| 432 |
|
| 433 |
JSContext* getCx() const { return cx; } |
| 434 |
operator JSContext*() const { return cx; } |
| 435 |
|
| 436 |
bool success() const { return exitFP != nullptr; } |
| 437 |
}; |
| 438 |
|
| 439 |
#define PUSH_EXIT_FRAME_OR_RET(value, init_sp) \ |
| 440 |
VMFrame cx(ctx.frameMgr, ctx.stack, init_sp); \ |
| 441 |
if (!cx.success()) { \ |
| 442 |
return value; \ |
| 443 |
} \ |
| 444 |
StackVal* sp = cx.spBelowFrame(); /* shadow the definition */ \ |
| 445 |
(void)sp; /* avoid unused-variable warnings */ |
| 446 |
|
| 447 |
#define PUSH_IC_FRAME() \ |
| 448 |
ctx.error = PBIResult::Error; \ |
| 449 |
PUSH_EXIT_FRAME_OR_RET(IC_ERROR_SENTINEL(), ctx.sp()) |
| 450 |
#define PUSH_FALLBACK_IC_FRAME() \ |
| 451 |
ctx.error = PBIResult::Error; \ |
| 452 |
PUSH_EXIT_FRAME_OR_RET(IC_ERROR_SENTINEL(), sp) |
| 453 |
#define PUSH_EXIT_FRAME() \ |
| 454 |
frame->interpreterPC() = pc; \ |
| 455 |
SYNCSP(); \ |
| 456 |
PUSH_EXIT_FRAME_OR_RET(PBIResult::Error, sp) |
| 457 |
|
| 458 |
/* |
| 459 |
* ----------------------------------------------- |
| 460 |
* IC Interpreter |
| 461 |
* ----------------------------------------------- |
| 462 |
*/ |
| 463 |
|
| 464 |
// Bundled state for passing to ICs, in order to reduce the number of |
| 465 |
// arguments and hence make the call more ABI-efficient. (On some |
| 466 |
// platforms, e.g. Wasm on Wasmtime on x86-64, we have as few as four |
| 467 |
// register arguments available before args go through the stack.) |
| 468 |
struct ICCtx { |
| 469 |
BaselineFrame* frame; |
| 470 |
VMFrameManager frameMgr; |
| 471 |
State& state; |
| 472 |
ICRegs icregs; |
| 473 |
Stack& stack; |
| 474 |
StackVal* sp_; |
| 475 |
PBIResult error; |
| 476 |
uint64_t arg2; |
| 477 |
|
| 478 |
ICCtx(JSContext* cx, BaselineFrame* frame_, State& state_, Stack& stack_) |
| 479 |
: frame(frame_), |
| 480 |
frameMgr(cx, frame_), |
| 481 |
state(state_), |
| 482 |
icregs(), |
| 483 |
stack(stack_), |
| 484 |
sp_(nullptr), |
| 485 |
error(PBIResult::Ok), |
| 486 |
arg2(0) {} |
| 487 |
|
| 488 |
StackVal* sp() { return sp_; } |
| 489 |
}; |
| 490 |
|
| 491 |
#define IC_ERROR_SENTINEL() (JS::MagicValue(JS_GENERIC_MAGIC).asRawBits()) |
| 492 |
|
| 493 |
// Universal signature for an IC stub function. |
| 494 |
typedef uint64_t (*ICStubFunc)(uint64_t arg0, uint64_t arg1, ICStub* stub, |
| 495 |
ICCtx& ctx); |
| 496 |
|
| 497 |
#define PBL_CALL_IC(jitcode, ctx, stubvalue, result, arg0, arg1, arg2value, \ |
| 498 |
hasarg2) \ |
| 499 |
do { \ |
| 500 |
ctx.arg2 = arg2value; \ |
| 501 |
ICStubFunc func = reinterpret_cast<ICStubFunc>(jitcode); \ |
| 502 |
result = func(arg0, arg1, stubvalue, ctx); \ |
| 503 |
} while (0) |
| 504 |
|
| 505 |
typedef PBIResult (*PBIFunc)(JSContext* cx_, State& state, Stack& stack, |
| 506 |
StackVal* sp, JSObject* envChain, Value* ret, |
| 507 |
jsbytecode* pc, ImmutableScriptData* isd, |
| 508 |
jsbytecode* restartEntryPC, |
| 509 |
BaselineFrame* restartFrame, |
| 510 |
StackVal* restartEntryFrame, |
| 511 |
PBIResult restartCode); |
| 512 |
|
| 513 |
static uint64_t CallNextIC(uint64_t arg0, uint64_t arg1, ICStub* stub, |
| 514 |
ICCtx& ctx); |
| 515 |
|
| 516 |
static double DoubleMinMax(bool isMax, double first, double second) { |
| 517 |
if (std::isnan(first) || std::isnan(second)) { |
| 518 |
return JS::GenericNaN(); |
| 519 |
} else if (first == 0 && second == 0) { |
| 520 |
// -0 and 0 compare as equal, but we have to distinguish |
| 521 |
// them here: min(-0, 0) = -0, max(-0, 0) = 0. |
| 522 |
bool firstPos = !std::signbit(first); |
| 523 |
bool secondPos = !std::signbit(second); |
| 524 |
bool sign = isMax ? (firstPos || secondPos) : (firstPos && secondPos); |
| 525 |
return sign ? 0.0 : -0.0; |
| 526 |
} else { |
| 527 |
return isMax ? ((first >= second) ? first : second) |
| 528 |
: ((first <= second) ? first : second); |
| 529 |
} |
| 530 |
} |
| 531 |
|
| 532 |
// Interpreter for CacheIR. |
| 533 |
uint64_t ICInterpretOps(uint64_t arg0, uint64_t arg1, ICStub* stub, |
| 534 |
ICCtx& ctx) { |
| 535 |
{ |
| 536 |
#define DECLARE_CACHEOP_CASE(name) __label__ cacheop_##name |
| 537 |
|
| 538 |
#ifdef ENABLE_COMPUTED_GOTO_DISPATCH |
| 539 |
|
| 540 |
# define CACHEOP_CASE(name) cacheop_##name : CACHEOP_TRACE(name) |
| 541 |
# define CACHEOP_CASE_FALLTHROUGH(name) CACHEOP_CASE(name) |
| 542 |
|
| 543 |
# define DISPATCH_CACHEOP() \ |
| 544 |
cacheop = cacheIRReader.readOp(); \ |
| 545 |
goto* addresses[long(cacheop)]; |
| 546 |
|
| 547 |
#else // ENABLE_COMPUTED_GOTO_DISPATCH |
| 548 |
|
| 549 |
# define CACHEOP_CASE(name) \ |
| 550 |
case CacheOp::name: \ |
| 551 |
cacheop_##name : CACHEOP_TRACE(name) |
| 552 |
# define CACHEOP_CASE_FALLTHROUGH(name) \ |
| 553 |
[[fallthrough]]; \ |
| 554 |
CACHEOP_CASE(name) |
| 555 |
|
| 556 |
# define DISPATCH_CACHEOP() \ |
| 557 |
cacheop = cacheIRReader.readOp(); \ |
| 558 |
goto dispatch; |
| 559 |
|
| 560 |
#endif // !ENABLE_COMPUTED_GOTO_DISPATCH |
| 561 |
|
| 562 |
#define READ_REG(index) ctx.icregs.icVals[(index)] |
| 563 |
#define READ_VALUE_REG(index) \ |
| 564 |
Value::fromRawBits(ctx.icregs.icVals[(index)] | ctx.icregs.icTags[(index)]) |
| 565 |
#define WRITE_REG(index, value, tag) \ |
| 566 |
do { \ |
| 567 |
ctx.icregs.icVals[(index)] = (value); \ |
| 568 |
ctx.icregs.icTags[(index)] = uint64_t(JSVAL_TAG_##tag) << JSVAL_TAG_SHIFT; \ |
| 569 |
} while (0) |
| 570 |
#define WRITE_VALUE_REG(index, value) \ |
| 571 |
do { \ |
| 572 |
ctx.icregs.icVals[(index)] = (value).asRawBits(); \ |
| 573 |
ctx.icregs.icTags[(index)] = 0; \ |
| 574 |
} while (0) |
| 575 |
|
| 576 |
DECLARE_CACHEOP_CASE(ReturnFromIC); |
| 577 |
DECLARE_CACHEOP_CASE(GuardToObject); |
| 578 |
DECLARE_CACHEOP_CASE(GuardIsNullOrUndefined); |
| 579 |
DECLARE_CACHEOP_CASE(GuardIsNull); |
| 580 |
DECLARE_CACHEOP_CASE(GuardIsUndefined); |
| 581 |
DECLARE_CACHEOP_CASE(GuardIsNotUninitializedLexical); |
| 582 |
DECLARE_CACHEOP_CASE(GuardToBoolean); |
| 583 |
DECLARE_CACHEOP_CASE(GuardToString); |
| 584 |
DECLARE_CACHEOP_CASE(GuardToSymbol); |
| 585 |
DECLARE_CACHEOP_CASE(GuardToBigInt); |
| 586 |
DECLARE_CACHEOP_CASE(GuardIsNumber); |
| 587 |
DECLARE_CACHEOP_CASE(GuardToInt32); |
| 588 |
DECLARE_CACHEOP_CASE(GuardToNonGCThing); |
| 589 |
DECLARE_CACHEOP_CASE(GuardBooleanToInt32); |
| 590 |
DECLARE_CACHEOP_CASE(GuardToInt32Index); |
| 591 |
DECLARE_CACHEOP_CASE(Int32ToIntPtr); |
| 592 |
DECLARE_CACHEOP_CASE(GuardToInt32ModUint32); |
| 593 |
DECLARE_CACHEOP_CASE(GuardNonDoubleType); |
| 594 |
DECLARE_CACHEOP_CASE(GuardShape); |
| 595 |
DECLARE_CACHEOP_CASE(GuardFuse); |
| 596 |
DECLARE_CACHEOP_CASE(GuardProto); |
| 597 |
DECLARE_CACHEOP_CASE(GuardNullProto); |
| 598 |
DECLARE_CACHEOP_CASE(GuardClass); |
| 599 |
DECLARE_CACHEOP_CASE(GuardAnyClass); |
| 600 |
DECLARE_CACHEOP_CASE(GuardGlobalGeneration); |
| 601 |
DECLARE_CACHEOP_CASE(HasClassResult); |
| 602 |
DECLARE_CACHEOP_CASE(GuardCompartment); |
| 603 |
DECLARE_CACHEOP_CASE(GuardIsExtensible); |
| 604 |
DECLARE_CACHEOP_CASE(GuardIsNativeObject); |
| 605 |
DECLARE_CACHEOP_CASE(GuardIsProxy); |
| 606 |
DECLARE_CACHEOP_CASE(GuardIsNotProxy); |
| 607 |
DECLARE_CACHEOP_CASE(GuardIsNotArrayBufferMaybeShared); |
| 608 |
DECLARE_CACHEOP_CASE(GuardIsTypedArray); |
| 609 |
DECLARE_CACHEOP_CASE(GuardHasProxyHandler); |
| 610 |
DECLARE_CACHEOP_CASE(GuardIsNotDOMProxy); |
| 611 |
DECLARE_CACHEOP_CASE(GuardSpecificObject); |
| 612 |
DECLARE_CACHEOP_CASE(GuardObjectIdentity); |
| 613 |
DECLARE_CACHEOP_CASE(GuardSpecificFunction); |
| 614 |
DECLARE_CACHEOP_CASE(GuardFunctionScript); |
| 615 |
DECLARE_CACHEOP_CASE(GuardSpecificAtom); |
| 616 |
DECLARE_CACHEOP_CASE(GuardSpecificSymbol); |
| 617 |
DECLARE_CACHEOP_CASE(GuardSpecificInt32); |
| 618 |
DECLARE_CACHEOP_CASE(GuardNoDenseElements); |
| 619 |
DECLARE_CACHEOP_CASE(GuardStringToIndex); |
| 620 |
DECLARE_CACHEOP_CASE(GuardStringToInt32); |
| 621 |
DECLARE_CACHEOP_CASE(GuardStringToNumber); |
| 622 |
DECLARE_CACHEOP_CASE(BooleanToNumber); |
| 623 |
DECLARE_CACHEOP_CASE(GuardHasGetterSetter); |
| 624 |
DECLARE_CACHEOP_CASE(GuardInt32IsNonNegative); |
| 625 |
DECLARE_CACHEOP_CASE(GuardDynamicSlotIsSpecificObject); |
| 626 |
DECLARE_CACHEOP_CASE(GuardDynamicSlotIsNotObject); |
| 627 |
DECLARE_CACHEOP_CASE(GuardFixedSlotValue); |
| 628 |
DECLARE_CACHEOP_CASE(GuardDynamicSlotValue); |
| 629 |
DECLARE_CACHEOP_CASE(LoadFixedSlot); |
| 630 |
DECLARE_CACHEOP_CASE(LoadDynamicSlot); |
| 631 |
DECLARE_CACHEOP_CASE(GuardNoAllocationMetadataBuilder); |
| 632 |
DECLARE_CACHEOP_CASE(GuardFunctionHasJitEntry); |
| 633 |
DECLARE_CACHEOP_CASE(GuardFunctionHasNoJitEntry); |
| 634 |
DECLARE_CACHEOP_CASE(GuardFunctionIsNonBuiltinCtor); |
| 635 |
DECLARE_CACHEOP_CASE(GuardFunctionIsConstructor); |
| 636 |
DECLARE_CACHEOP_CASE(GuardNotClassConstructor); |
| 637 |
DECLARE_CACHEOP_CASE(GuardArrayIsPacked); |
| 638 |
DECLARE_CACHEOP_CASE(GuardArgumentsObjectFlags); |
| 639 |
DECLARE_CACHEOP_CASE(LoadObject); |
| 640 |
DECLARE_CACHEOP_CASE(LoadProtoObject); |
| 641 |
DECLARE_CACHEOP_CASE(LoadProto); |
| 642 |
DECLARE_CACHEOP_CASE(LoadEnclosingEnvironment); |
| 643 |
DECLARE_CACHEOP_CASE(LoadWrapperTarget); |
| 644 |
DECLARE_CACHEOP_CASE(LoadValueTag); |
| 645 |
DECLARE_CACHEOP_CASE(LoadArgumentFixedSlot); |
| 646 |
DECLARE_CACHEOP_CASE(LoadArgumentDynamicSlot); |
| 647 |
DECLARE_CACHEOP_CASE(TruncateDoubleToUInt32); |
| 648 |
DECLARE_CACHEOP_CASE(MegamorphicLoadSlotResult); |
| 649 |
DECLARE_CACHEOP_CASE(MegamorphicLoadSlotByValueResult); |
| 650 |
DECLARE_CACHEOP_CASE(MegamorphicSetElement); |
| 651 |
DECLARE_CACHEOP_CASE(StoreFixedSlot); |
| 652 |
DECLARE_CACHEOP_CASE(StoreDynamicSlot); |
| 653 |
DECLARE_CACHEOP_CASE(AddAndStoreFixedSlot); |
| 654 |
DECLARE_CACHEOP_CASE(AddAndStoreDynamicSlot); |
| 655 |
DECLARE_CACHEOP_CASE(AllocateAndStoreDynamicSlot); |
| 656 |
DECLARE_CACHEOP_CASE(StoreDenseElement); |
| 657 |
DECLARE_CACHEOP_CASE(StoreDenseElementHole); |
| 658 |
DECLARE_CACHEOP_CASE(ArrayPush); |
| 659 |
DECLARE_CACHEOP_CASE(IsObjectResult); |
| 660 |
DECLARE_CACHEOP_CASE(Int32MinMax); |
| 661 |
DECLARE_CACHEOP_CASE(StoreTypedArrayElement); |
| 662 |
DECLARE_CACHEOP_CASE(CallInt32ToString); |
| 663 |
DECLARE_CACHEOP_CASE(CallScriptedFunction); |
| 664 |
DECLARE_CACHEOP_CASE(CallNativeFunction); |
| 665 |
DECLARE_CACHEOP_CASE(MetaScriptedThisShape); |
| 666 |
DECLARE_CACHEOP_CASE(LoadFixedSlotResult); |
| 667 |
DECLARE_CACHEOP_CASE(LoadDynamicSlotResult); |
| 668 |
DECLARE_CACHEOP_CASE(LoadDenseElementResult); |
| 669 |
DECLARE_CACHEOP_CASE(LoadInt32ArrayLengthResult); |
| 670 |
DECLARE_CACHEOP_CASE(LoadInt32ArrayLength); |
| 671 |
DECLARE_CACHEOP_CASE(LoadArgumentsObjectArgResult); |
| 672 |
DECLARE_CACHEOP_CASE(LinearizeForCharAccess); |
| 673 |
DECLARE_CACHEOP_CASE(LoadStringCharResult); |
| 674 |
DECLARE_CACHEOP_CASE(LoadStringCharCodeResult); |
| 675 |
DECLARE_CACHEOP_CASE(LoadStringLengthResult); |
| 676 |
DECLARE_CACHEOP_CASE(LoadObjectResult); |
| 677 |
DECLARE_CACHEOP_CASE(LoadStringResult); |
| 678 |
DECLARE_CACHEOP_CASE(LoadSymbolResult); |
| 679 |
DECLARE_CACHEOP_CASE(LoadInt32Result); |
| 680 |
DECLARE_CACHEOP_CASE(LoadDoubleResult); |
| 681 |
DECLARE_CACHEOP_CASE(LoadBigIntResult); |
| 682 |
DECLARE_CACHEOP_CASE(LoadBooleanResult); |
| 683 |
DECLARE_CACHEOP_CASE(LoadInt32Constant); |
| 684 |
DECLARE_CACHEOP_CASE(LoadConstantStringResult); |
| 685 |
DECLARE_CACHEOP_CASE(Int32AddResult); |
| 686 |
DECLARE_CACHEOP_CASE(Int32SubResult); |
| 687 |
DECLARE_CACHEOP_CASE(Int32MulResult); |
| 688 |
DECLARE_CACHEOP_CASE(Int32DivResult); |
| 689 |
DECLARE_CACHEOP_CASE(Int32ModResult); |
| 690 |
DECLARE_CACHEOP_CASE(Int32BitOrResult); |
| 691 |
DECLARE_CACHEOP_CASE(Int32BitXorResult); |
| 692 |
DECLARE_CACHEOP_CASE(Int32BitAndResult); |
| 693 |
DECLARE_CACHEOP_CASE(Int32PowResult); |
| 694 |
DECLARE_CACHEOP_CASE(Int32IncResult); |
| 695 |
DECLARE_CACHEOP_CASE(LoadInt32TruthyResult); |
| 696 |
DECLARE_CACHEOP_CASE(LoadStringTruthyResult); |
| 697 |
DECLARE_CACHEOP_CASE(LoadObjectTruthyResult); |
| 698 |
DECLARE_CACHEOP_CASE(LoadValueResult); |
| 699 |
DECLARE_CACHEOP_CASE(LoadOperandResult); |
| 700 |
DECLARE_CACHEOP_CASE(ConcatStringsResult); |
| 701 |
DECLARE_CACHEOP_CASE(CompareStringResult); |
| 702 |
DECLARE_CACHEOP_CASE(CompareInt32Result); |
| 703 |
DECLARE_CACHEOP_CASE(CompareNullUndefinedResult); |
| 704 |
DECLARE_CACHEOP_CASE(AssertPropertyLookup); |
| 705 |
DECLARE_CACHEOP_CASE(GuardIsFixedLengthTypedArray); |
| 706 |
DECLARE_CACHEOP_CASE(GuardIndexIsNotDenseElement); |
| 707 |
DECLARE_CACHEOP_CASE(LoadFixedSlotTypedResult); |
| 708 |
DECLARE_CACHEOP_CASE(LoadDenseElementHoleResult); |
| 709 |
DECLARE_CACHEOP_CASE(LoadDenseElementExistsResult); |
| 710 |
DECLARE_CACHEOP_CASE(LoadTypedArrayElementExistsResult); |
| 711 |
DECLARE_CACHEOP_CASE(LoadDenseElementHoleExistsResult); |
| 712 |
DECLARE_CACHEOP_CASE(LoadTypedArrayElementResult); |
| 713 |
DECLARE_CACHEOP_CASE(RegExpFlagResult); |
| 714 |
DECLARE_CACHEOP_CASE(GuardNumberToIntPtrIndex); |
| 715 |
DECLARE_CACHEOP_CASE(CallRegExpMatcherResult); |
| 716 |
DECLARE_CACHEOP_CASE(CallRegExpSearcherResult); |
| 717 |
DECLARE_CACHEOP_CASE(RegExpSearcherLastLimitResult); |
| 718 |
DECLARE_CACHEOP_CASE(RegExpHasCaptureGroupsResult); |
| 719 |
DECLARE_CACHEOP_CASE(RegExpBuiltinExecMatchResult); |
| 720 |
DECLARE_CACHEOP_CASE(RegExpBuiltinExecTestResult); |
| 721 |
DECLARE_CACHEOP_CASE(CallSubstringKernelResult); |
| 722 |
DECLARE_CACHEOP_CASE(StringReplaceStringResult); |
| 723 |
DECLARE_CACHEOP_CASE(StringSplitStringResult); |
| 724 |
DECLARE_CACHEOP_CASE(GetFirstDollarIndexResult); |
| 725 |
DECLARE_CACHEOP_CASE(StringToAtom); |
| 726 |
DECLARE_CACHEOP_CASE(GuardTagNotEqual); |
| 727 |
DECLARE_CACHEOP_CASE(IdToStringOrSymbol); |
| 728 |
DECLARE_CACHEOP_CASE(MegamorphicStoreSlot); |
| 729 |
DECLARE_CACHEOP_CASE(MegamorphicHasPropResult); |
| 730 |
DECLARE_CACHEOP_CASE(ObjectToIteratorResult); |
| 731 |
DECLARE_CACHEOP_CASE(ArrayJoinResult); |
| 732 |
DECLARE_CACHEOP_CASE(ObjectKeysResult); |
| 733 |
DECLARE_CACHEOP_CASE(PackedArrayPopResult); |
| 734 |
DECLARE_CACHEOP_CASE(PackedArrayShiftResult); |
| 735 |
DECLARE_CACHEOP_CASE(PackedArraySliceResult); |
| 736 |
DECLARE_CACHEOP_CASE(IsArrayResult); |
| 737 |
DECLARE_CACHEOP_CASE(IsPackedArrayResult); |
| 738 |
DECLARE_CACHEOP_CASE(IsCallableResult); |
| 739 |
DECLARE_CACHEOP_CASE(IsConstructorResult); |
| 740 |
DECLARE_CACHEOP_CASE(IsCrossRealmArrayConstructorResult); |
| 741 |
DECLARE_CACHEOP_CASE(IsTypedArrayResult); |
| 742 |
DECLARE_CACHEOP_CASE(IsTypedArrayConstructorResult); |
| 743 |
DECLARE_CACHEOP_CASE(ArrayBufferViewByteOffsetInt32Result); |
| 744 |
DECLARE_CACHEOP_CASE(ArrayBufferViewByteOffsetDoubleResult); |
| 745 |
DECLARE_CACHEOP_CASE(TypedArrayByteLengthInt32Result); |
| 746 |
DECLARE_CACHEOP_CASE(TypedArrayByteLengthDoubleResult); |
| 747 |
DECLARE_CACHEOP_CASE(TypedArrayElementSizeResult); |
| 748 |
DECLARE_CACHEOP_CASE(NewStringIteratorResult); |
| 749 |
DECLARE_CACHEOP_CASE(NewRegExpStringIteratorResult); |
| 750 |
DECLARE_CACHEOP_CASE(ObjectCreateResult); |
| 751 |
DECLARE_CACHEOP_CASE(NewArrayFromLengthResult); |
| 752 |
DECLARE_CACHEOP_CASE(NewTypedArrayFromArrayBufferResult); |
| 753 |
DECLARE_CACHEOP_CASE(NewTypedArrayFromArrayResult); |
| 754 |
DECLARE_CACHEOP_CASE(NewTypedArrayFromLengthResult); |
| 755 |
DECLARE_CACHEOP_CASE(StringFromCharCodeResult); |
| 756 |
DECLARE_CACHEOP_CASE(StringFromCodePointResult); |
| 757 |
DECLARE_CACHEOP_CASE(StringIncludesResult); |
| 758 |
DECLARE_CACHEOP_CASE(StringIndexOfResult); |
| 759 |
DECLARE_CACHEOP_CASE(StringLastIndexOfResult); |
| 760 |
DECLARE_CACHEOP_CASE(StringStartsWithResult); |
| 761 |
DECLARE_CACHEOP_CASE(StringEndsWithResult); |
| 762 |
DECLARE_CACHEOP_CASE(StringToLowerCaseResult); |
| 763 |
DECLARE_CACHEOP_CASE(StringToUpperCaseResult); |
| 764 |
DECLARE_CACHEOP_CASE(StringTrimResult); |
| 765 |
DECLARE_CACHEOP_CASE(StringTrimStartResult); |
| 766 |
DECLARE_CACHEOP_CASE(StringTrimEndResult); |
| 767 |
DECLARE_CACHEOP_CASE(MathAbsInt32Result); |
| 768 |
DECLARE_CACHEOP_CASE(MathAbsNumberResult); |
| 769 |
DECLARE_CACHEOP_CASE(MathClz32Result); |
| 770 |
DECLARE_CACHEOP_CASE(MathSignInt32Result); |
| 771 |
DECLARE_CACHEOP_CASE(MathSignNumberResult); |
| 772 |
DECLARE_CACHEOP_CASE(MathSignNumberToInt32Result); |
| 773 |
DECLARE_CACHEOP_CASE(MathImulResult); |
| 774 |
DECLARE_CACHEOP_CASE(MathSqrtNumberResult); |
| 775 |
DECLARE_CACHEOP_CASE(MathFRoundNumberResult); |
| 776 |
DECLARE_CACHEOP_CASE(MathRandomResult); |
| 777 |
DECLARE_CACHEOP_CASE(MathHypot2NumberResult); |
| 778 |
DECLARE_CACHEOP_CASE(MathHypot3NumberResult); |
| 779 |
DECLARE_CACHEOP_CASE(MathHypot4NumberResult); |
| 780 |
DECLARE_CACHEOP_CASE(MathAtan2NumberResult); |
| 781 |
DECLARE_CACHEOP_CASE(MathFloorNumberResult); |
| 782 |
DECLARE_CACHEOP_CASE(MathCeilNumberResult); |
| 783 |
DECLARE_CACHEOP_CASE(MathTruncNumberResult); |
| 784 |
DECLARE_CACHEOP_CASE(MathCeilToInt32Result); |
| 785 |
DECLARE_CACHEOP_CASE(MathFloorToInt32Result); |
| 786 |
DECLARE_CACHEOP_CASE(MathTruncToInt32Result); |
| 787 |
DECLARE_CACHEOP_CASE(MathRoundToInt32Result); |
| 788 |
DECLARE_CACHEOP_CASE(NumberMinMax); |
| 789 |
DECLARE_CACHEOP_CASE(Int32MinMaxArrayResult); |
| 790 |
DECLARE_CACHEOP_CASE(NumberMinMaxArrayResult); |
| 791 |
DECLARE_CACHEOP_CASE(MathFunctionNumberResult); |
| 792 |
DECLARE_CACHEOP_CASE(NumberParseIntResult); |
| 793 |
DECLARE_CACHEOP_CASE(DoubleParseIntResult); |
| 794 |
DECLARE_CACHEOP_CASE(ObjectToStringResult); |
| 795 |
DECLARE_CACHEOP_CASE(CallNativeSetter); |
| 796 |
DECLARE_CACHEOP_CASE(CallSetArrayLength); |
| 797 |
DECLARE_CACHEOP_CASE(CallNumberToString); |
| 798 |
DECLARE_CACHEOP_CASE(Int32ToStringWithBaseResult); |
| 799 |
DECLARE_CACHEOP_CASE(BooleanToString); |
| 800 |
DECLARE_CACHEOP_CASE(BindFunctionResult); |
| 801 |
DECLARE_CACHEOP_CASE(SpecializedBindFunctionResult); |
| 802 |
DECLARE_CACHEOP_CASE(CallGetSparseElementResult); |
| 803 |
DECLARE_CACHEOP_CASE(LoadArgumentsObjectLengthResult); |
| 804 |
DECLARE_CACHEOP_CASE(LoadArgumentsObjectLength); |
| 805 |
DECLARE_CACHEOP_CASE(LoadBoundFunctionNumArgs); |
| 806 |
DECLARE_CACHEOP_CASE(LoadBoundFunctionTarget); |
| 807 |
DECLARE_CACHEOP_CASE(LoadArrayBufferByteLengthInt32Result); |
| 808 |
DECLARE_CACHEOP_CASE(LoadArrayBufferByteLengthDoubleResult); |
| 809 |
DECLARE_CACHEOP_CASE(LinearizeForCodePointAccess); |
| 810 |
DECLARE_CACHEOP_CASE(LoadArrayBufferViewLengthInt32Result); |
| 811 |
DECLARE_CACHEOP_CASE(LoadArrayBufferViewLengthDoubleResult); |
| 812 |
DECLARE_CACHEOP_CASE(LoadStringAtResult); |
| 813 |
DECLARE_CACHEOP_CASE(LoadStringCodePointResult); |
| 814 |
DECLARE_CACHEOP_CASE(CallNativeGetterResult); |
| 815 |
DECLARE_CACHEOP_CASE(LoadUndefinedResult); |
| 816 |
DECLARE_CACHEOP_CASE(LoadDoubleConstant); |
| 817 |
DECLARE_CACHEOP_CASE(LoadBooleanConstant); |
| 818 |
DECLARE_CACHEOP_CASE(LoadUndefined); |
| 819 |
DECLARE_CACHEOP_CASE(LoadConstantString); |
| 820 |
DECLARE_CACHEOP_CASE(LoadInstanceOfObjectResult); |
| 821 |
DECLARE_CACHEOP_CASE(LoadTypeOfObjectResult); |
| 822 |
DECLARE_CACHEOP_CASE(DoubleAddResult); |
| 823 |
DECLARE_CACHEOP_CASE(DoubleSubResult); |
| 824 |
DECLARE_CACHEOP_CASE(DoubleMulResult); |
| 825 |
DECLARE_CACHEOP_CASE(DoubleDivResult); |
| 826 |
DECLARE_CACHEOP_CASE(DoubleModResult); |
| 827 |
DECLARE_CACHEOP_CASE(DoublePowResult); |
| 828 |
DECLARE_CACHEOP_CASE(Int32LeftShiftResult); |
| 829 |
DECLARE_CACHEOP_CASE(Int32RightShiftResult); |
| 830 |
DECLARE_CACHEOP_CASE(Int32URightShiftResult); |
| 831 |
DECLARE_CACHEOP_CASE(Int32NotResult); |
| 832 |
DECLARE_CACHEOP_CASE(LoadDoubleTruthyResult); |
| 833 |
DECLARE_CACHEOP_CASE(NewPlainObjectResult); |
| 834 |
DECLARE_CACHEOP_CASE(NewArrayObjectResult); |
| 835 |
DECLARE_CACHEOP_CASE(CompareObjectResult); |
| 836 |
DECLARE_CACHEOP_CASE(CompareSymbolResult); |
| 837 |
DECLARE_CACHEOP_CASE(CompareDoubleResult); |
| 838 |
DECLARE_CACHEOP_CASE(IndirectTruncateInt32Result); |
| 839 |
DECLARE_CACHEOP_CASE(CallScriptedSetter); |
| 840 |
DECLARE_CACHEOP_CASE(CallBoundScriptedFunction); |
| 841 |
DECLARE_CACHEOP_CASE(CallScriptedGetterResult); |
| 842 |
|
| 843 |
// Define the computed-goto table regardless of dispatch strategy so |
| 844 |
// we don't get unused-label errors. (We need some of the labels |
| 845 |
// even without this for the predict-next mechanism, so we can't |
| 846 |
// conditionally elide labels either.) |
| 847 |
static const void* const addresses[long(CacheOp::NumOpcodes)] = { |
| 848 |
#define OP(name, ...) &&cacheop_##name, |
| 849 |
CACHE_IR_OPS(OP) |
| 850 |
#undef OP |
| 851 |
}; |
| 852 |
(void)addresses; |
| 853 |
|
| 854 |
#define CACHEOP_TRACE(name) \ |
| 855 |
TRACE_PRINTF("cacheop (frame %p stub %p): " #name "\n", ctx.frame, cstub); |
| 856 |
|
| 857 |
#define FAIL_IC() goto next_ic; |
| 858 |
|
| 859 |
// We set a fixed bound on the number of icVals which is smaller than what IC |
| 860 |
// generators may use. As a result we can't evaluate an IC if it defines too |
| 861 |
// many values. Note that we don't need to check this when reading from icVals |
| 862 |
// because we should have bailed out before the earlier write which defined the |
| 863 |
// same value. Similarly, we don't need to check writes to locations which we've |
| 864 |
// just read from. |
| 865 |
#define BOUNDSCHECK(resultId) \ |
| 866 |
if (resultId.id() >= ICRegs::kMaxICVals) FAIL_IC(); |
| 867 |
|
| 868 |
#define PREDICT_NEXT(name) \ |
| 869 |
if (cacheIRReader.peekOp() == CacheOp::name) { \ |
| 870 |
cacheIRReader.readOp(); \ |
| 871 |
cacheop = CacheOp::name; \ |
| 872 |
goto cacheop_##name; \ |
| 873 |
} |
| 874 |
|
| 875 |
#define PREDICT_RETURN() \ |
| 876 |
if (cacheIRReader.peekOp() == CacheOp::ReturnFromIC) { \ |
| 877 |
TRACE_PRINTF("stub successful, predicted return\n"); \ |
| 878 |
return retValue; \ |
| 879 |
} |
| 880 |
|
| 881 |
ICCacheIRStub* cstub = stub->toCacheIRStub(); |
| 882 |
const CacheIRStubInfo* stubInfo = cstub->stubInfo(); |
| 883 |
CacheIRReader cacheIRReader(stubInfo); |
| 884 |
uint64_t retValue = 0; |
| 885 |
CacheOp cacheop; |
| 886 |
|
| 887 |
WRITE_VALUE_REG(0, Value::fromRawBits(arg0)); |
| 888 |
WRITE_VALUE_REG(1, Value::fromRawBits(arg1)); |
| 889 |
WRITE_VALUE_REG(2, Value::fromRawBits(ctx.arg2)); |
| 890 |
|
| 891 |
DISPATCH_CACHEOP(); |
| 892 |
|
| 893 |
#ifndef ENABLE_COMPUTED_GOTO_DISPATCH |
| 894 |
dispatch: |
| 895 |
switch (cacheop) |
| 896 |
#endif |
| 897 |
{ |
| 898 |
|
| 899 |
CACHEOP_CASE(ReturnFromIC) { |
| 900 |
TRACE_PRINTF("stub successful!\n"); |
| 901 |
return retValue; |
| 902 |
} |
| 903 |
|
| 904 |
CACHEOP_CASE(GuardToObject) { |
| 905 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 906 |
Value v = READ_VALUE_REG(inputId.id()); |
| 907 |
TRACE_PRINTF("GuardToObject: icVal %" PRIx64 "\n", |
| 908 |
READ_REG(inputId.id())); |
| 909 |
if (!v.isObject()) { |
| 910 |
FAIL_IC(); |
| 911 |
} |
| 912 |
WRITE_REG(inputId.id(), reinterpret_cast<uint64_t>(&v.toObject()), |
| 913 |
OBJECT); |
| 914 |
PREDICT_NEXT(GuardShape); |
| 915 |
PREDICT_NEXT(GuardSpecificFunction); |
| 916 |
DISPATCH_CACHEOP(); |
| 917 |
} |
| 918 |
|
| 919 |
CACHEOP_CASE(GuardIsNullOrUndefined) { |
| 920 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 921 |
Value v = READ_VALUE_REG(inputId.id()); |
| 922 |
if (!v.isNullOrUndefined()) { |
| 923 |
FAIL_IC(); |
| 924 |
} |
| 925 |
DISPATCH_CACHEOP(); |
| 926 |
} |
| 927 |
|
| 928 |
CACHEOP_CASE(GuardIsNull) { |
| 929 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 930 |
Value v = READ_VALUE_REG(inputId.id()); |
| 931 |
if (!v.isNull()) { |
| 932 |
FAIL_IC(); |
| 933 |
} |
| 934 |
DISPATCH_CACHEOP(); |
| 935 |
} |
| 936 |
|
| 937 |
CACHEOP_CASE(GuardIsUndefined) { |
| 938 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 939 |
Value v = READ_VALUE_REG(inputId.id()); |
| 940 |
if (!v.isUndefined()) { |
| 941 |
FAIL_IC(); |
| 942 |
} |
| 943 |
DISPATCH_CACHEOP(); |
| 944 |
} |
| 945 |
|
| 946 |
CACHEOP_CASE(GuardIsNotUninitializedLexical) { |
| 947 |
ValOperandId valId = cacheIRReader.valOperandId(); |
| 948 |
Value val = READ_VALUE_REG(valId.id()); |
| 949 |
if (val == MagicValue(JS_UNINITIALIZED_LEXICAL)) { |
| 950 |
FAIL_IC(); |
| 951 |
} |
| 952 |
DISPATCH_CACHEOP(); |
| 953 |
} |
| 954 |
|
| 955 |
CACHEOP_CASE(GuardToBoolean) { |
| 956 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 957 |
Value v = READ_VALUE_REG(inputId.id()); |
| 958 |
if (!v.isBoolean()) { |
| 959 |
FAIL_IC(); |
| 960 |
} |
| 961 |
WRITE_REG(inputId.id(), v.toBoolean() ? 1 : 0, BOOLEAN); |
| 962 |
DISPATCH_CACHEOP(); |
| 963 |
} |
| 964 |
|
| 965 |
CACHEOP_CASE(GuardToString) { |
| 966 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 967 |
Value v = READ_VALUE_REG(inputId.id()); |
| 968 |
if (!v.isString()) { |
| 969 |
FAIL_IC(); |
| 970 |
} |
| 971 |
WRITE_REG(inputId.id(), reinterpret_cast<uint64_t>(v.toString()), |
| 972 |
STRING); |
| 973 |
PREDICT_NEXT(GuardToString); |
| 974 |
DISPATCH_CACHEOP(); |
| 975 |
} |
| 976 |
|
| 977 |
CACHEOP_CASE(GuardToSymbol) { |
| 978 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 979 |
Value v = READ_VALUE_REG(inputId.id()); |
| 980 |
if (!v.isSymbol()) { |
| 981 |
FAIL_IC(); |
| 982 |
} |
| 983 |
WRITE_REG(inputId.id(), reinterpret_cast<uint64_t>(v.toSymbol()), |
| 984 |
SYMBOL); |
| 985 |
PREDICT_NEXT(GuardSpecificSymbol); |
| 986 |
DISPATCH_CACHEOP(); |
| 987 |
} |
| 988 |
|
| 989 |
CACHEOP_CASE(GuardToBigInt) { |
| 990 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 991 |
Value v = READ_VALUE_REG(inputId.id()); |
| 992 |
if (!v.isBigInt()) { |
| 993 |
FAIL_IC(); |
| 994 |
} |
| 995 |
WRITE_REG(inputId.id(), reinterpret_cast<uint64_t>(v.toBigInt()), |
| 996 |
BIGINT); |
| 997 |
DISPATCH_CACHEOP(); |
| 998 |
} |
| 999 |
|
| 1000 |
CACHEOP_CASE(GuardIsNumber) { |
| 1001 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 1002 |
Value v = READ_VALUE_REG(inputId.id()); |
| 1003 |
if (!v.isNumber()) { |
| 1004 |
FAIL_IC(); |
| 1005 |
} |
| 1006 |
DISPATCH_CACHEOP(); |
| 1007 |
} |
| 1008 |
|
| 1009 |
CACHEOP_CASE(GuardToInt32) { |
| 1010 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 1011 |
Value v = READ_VALUE_REG(inputId.id()); |
| 1012 |
TRACE_PRINTF("GuardToInt32 (%d): icVal %" PRIx64 "\n", inputId.id(), |
| 1013 |
READ_REG(inputId.id())); |
| 1014 |
if (!v.isInt32()) { |
| 1015 |
FAIL_IC(); |
| 1016 |
} |
| 1017 |
// N.B.: we don't need to unbox because the low 32 bits are |
| 1018 |
// already the int32 itself, and we are careful when using |
| 1019 |
// `Int32Operand`s to only use those bits. |
| 1020 |
|
| 1021 |
PREDICT_NEXT(GuardToInt32); |
| 1022 |
DISPATCH_CACHEOP(); |
| 1023 |
} |
| 1024 |
|
| 1025 |
CACHEOP_CASE(GuardToNonGCThing) { |
| 1026 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 1027 |
Value input = READ_VALUE_REG(inputId.id()); |
| 1028 |
if (input.isGCThing()) { |
| 1029 |
FAIL_IC(); |
| 1030 |
} |
| 1031 |
DISPATCH_CACHEOP(); |
| 1032 |
} |
| 1033 |
|
| 1034 |
CACHEOP_CASE(GuardBooleanToInt32) { |
| 1035 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 1036 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 1037 |
BOUNDSCHECK(resultId); |
| 1038 |
Value v = READ_VALUE_REG(inputId.id()); |
| 1039 |
if (!v.isBoolean()) { |
| 1040 |
FAIL_IC(); |
| 1041 |
} |
| 1042 |
WRITE_REG(resultId.id(), v.toBoolean() ? 1 : 0, INT32); |
| 1043 |
DISPATCH_CACHEOP(); |
| 1044 |
} |
| 1045 |
|
| 1046 |
CACHEOP_CASE(GuardToInt32Index) { |
| 1047 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 1048 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 1049 |
BOUNDSCHECK(resultId); |
| 1050 |
Value val = READ_VALUE_REG(inputId.id()); |
| 1051 |
if (val.isInt32()) { |
| 1052 |
WRITE_REG(resultId.id(), val.toInt32(), INT32); |
| 1053 |
DISPATCH_CACHEOP(); |
| 1054 |
} else if (val.isDouble()) { |
| 1055 |
double doubleVal = val.toDouble(); |
| 1056 |
if (int32_t(doubleVal) == doubleVal) { |
| 1057 |
WRITE_REG(resultId.id(), int32_t(doubleVal), INT32); |
| 1058 |
DISPATCH_CACHEOP(); |
| 1059 |
} |
| 1060 |
} |
| 1061 |
FAIL_IC(); |
| 1062 |
} |
| 1063 |
|
| 1064 |
CACHEOP_CASE(Int32ToIntPtr) { |
| 1065 |
Int32OperandId inputId = cacheIRReader.int32OperandId(); |
| 1066 |
IntPtrOperandId resultId = cacheIRReader.intPtrOperandId(); |
| 1067 |
BOUNDSCHECK(resultId); |
| 1068 |
int32_t input = int32_t(READ_REG(inputId.id())); |
| 1069 |
// Note that this must sign-extend to pointer width: |
| 1070 |
WRITE_REG(resultId.id(), intptr_t(input), OBJECT); |
| 1071 |
DISPATCH_CACHEOP(); |
| 1072 |
} |
| 1073 |
|
| 1074 |
CACHEOP_CASE(GuardToInt32ModUint32) { |
| 1075 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 1076 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 1077 |
BOUNDSCHECK(resultId); |
| 1078 |
Value input = READ_VALUE_REG(inputId.id()); |
| 1079 |
if (input.isInt32()) { |
| 1080 |
WRITE_REG(resultId.id(), input.toInt32(), INT32); |
| 1081 |
DISPATCH_CACHEOP(); |
| 1082 |
} else if (input.isDouble()) { |
| 1083 |
double doubleVal = input.toDouble(); |
| 1084 |
// Accept any double that fits in an int64_t but truncate the top 32 |
| 1085 |
// bits. |
| 1086 |
if (doubleVal >= double(INT64_MIN) && |
| 1087 |
doubleVal <= double(INT64_MAX)) { |
| 1088 |
WRITE_REG(resultId.id(), int64_t(doubleVal), INT32); |
| 1089 |
DISPATCH_CACHEOP(); |
| 1090 |
} |
| 1091 |
} |
| 1092 |
FAIL_IC(); |
| 1093 |
} |
| 1094 |
|
| 1095 |
CACHEOP_CASE(GuardNonDoubleType) { |
| 1096 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 1097 |
ValueType type = cacheIRReader.valueType(); |
| 1098 |
Value val = READ_VALUE_REG(inputId.id()); |
| 1099 |
switch (type) { |
| 1100 |
case ValueType::String: |
| 1101 |
if (!val.isString()) { |
| 1102 |
FAIL_IC(); |
| 1103 |
} |
| 1104 |
break; |
| 1105 |
case ValueType::Symbol: |
| 1106 |
if (!val.isSymbol()) { |
| 1107 |
FAIL_IC(); |
| 1108 |
} |
| 1109 |
break; |
| 1110 |
case ValueType::BigInt: |
| 1111 |
if (!val.isBigInt()) { |
| 1112 |
FAIL_IC(); |
| 1113 |
} |
| 1114 |
break; |
| 1115 |
case ValueType::Int32: |
| 1116 |
if (!val.isInt32()) { |
| 1117 |
FAIL_IC(); |
| 1118 |
} |
| 1119 |
break; |
| 1120 |
case ValueType::Boolean: |
| 1121 |
if (!val.isBoolean()) { |
| 1122 |
FAIL_IC(); |
| 1123 |
} |
| 1124 |
break; |
| 1125 |
case ValueType::Undefined: |
| 1126 |
if (!val.isUndefined()) { |
| 1127 |
FAIL_IC(); |
| 1128 |
} |
| 1129 |
break; |
| 1130 |
case ValueType::Null: |
| 1131 |
if (!val.isNull()) { |
| 1132 |
FAIL_IC(); |
| 1133 |
} |
| 1134 |
break; |
| 1135 |
default: |
| 1136 |
MOZ_CRASH("Unexpected type"); |
| 1137 |
} |
| 1138 |
DISPATCH_CACHEOP(); |
| 1139 |
} |
| 1140 |
|
| 1141 |
CACHEOP_CASE(GuardShape) { |
| 1142 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1143 |
uint32_t shapeOffset = cacheIRReader.stubOffset(); |
| 1144 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1145 |
uintptr_t expectedShape = stubInfo->getStubRawWord(cstub, shapeOffset); |
| 1146 |
if (reinterpret_cast<uintptr_t>(obj->shape()) != expectedShape) { |
| 1147 |
FAIL_IC(); |
| 1148 |
} |
| 1149 |
DISPATCH_CACHEOP(); |
| 1150 |
} |
| 1151 |
|
| 1152 |
CACHEOP_CASE(GuardFuse) { |
| 1153 |
RealmFuses::FuseIndex fuseIndex = cacheIRReader.realmFuseIndex(); |
| 1154 |
if (!ctx.frameMgr.cxForLocalUseOnly() |
| 1155 |
->realm() |
| 1156 |
->realmFuses.getFuseByIndex(fuseIndex) |
| 1157 |
->intact()) { |
| 1158 |
FAIL_IC(); |
| 1159 |
} |
| 1160 |
DISPATCH_CACHEOP(); |
| 1161 |
} |
| 1162 |
|
| 1163 |
CACHEOP_CASE(GuardProto) { |
| 1164 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1165 |
uint32_t protoOffset = cacheIRReader.stubOffset(); |
| 1166 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1167 |
JSObject* proto = reinterpret_cast<JSObject*>( |
| 1168 |
stubInfo->getStubRawWord(cstub, protoOffset)); |
| 1169 |
if (obj->staticPrototype() != proto) { |
| 1170 |
FAIL_IC(); |
| 1171 |
} |
| 1172 |
PREDICT_NEXT(LoadProto); |
| 1173 |
DISPATCH_CACHEOP(); |
| 1174 |
} |
| 1175 |
|
| 1176 |
CACHEOP_CASE(GuardNullProto) { |
| 1177 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1178 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1179 |
if (obj->taggedProto().raw()) { |
| 1180 |
FAIL_IC(); |
| 1181 |
} |
| 1182 |
DISPATCH_CACHEOP(); |
| 1183 |
} |
| 1184 |
|
| 1185 |
CACHEOP_CASE(GuardClass) { |
| 1186 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1187 |
GuardClassKind kind = cacheIRReader.guardClassKind(); |
| 1188 |
JSObject* object = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1189 |
switch (kind) { |
| 1190 |
case GuardClassKind::Array: |
| 1191 |
if (object->getClass() != &ArrayObject::class_) { |
| 1192 |
FAIL_IC(); |
| 1193 |
} |
| 1194 |
break; |
| 1195 |
case GuardClassKind::PlainObject: |
| 1196 |
if (object->getClass() != &PlainObject::class_) { |
| 1197 |
FAIL_IC(); |
| 1198 |
} |
| 1199 |
break; |
| 1200 |
case GuardClassKind::FixedLengthArrayBuffer: |
| 1201 |
if (object->getClass() != &FixedLengthArrayBufferObject::class_) { |
| 1202 |
FAIL_IC(); |
| 1203 |
} |
| 1204 |
break; |
| 1205 |
case GuardClassKind::ResizableArrayBuffer: |
| 1206 |
if (object->getClass() != &ResizableArrayBufferObject::class_) { |
| 1207 |
FAIL_IC(); |
| 1208 |
} |
| 1209 |
break; |
| 1210 |
case GuardClassKind::FixedLengthSharedArrayBuffer: |
| 1211 |
if (object->getClass() != |
| 1212 |
&FixedLengthSharedArrayBufferObject::class_) { |
| 1213 |
FAIL_IC(); |
| 1214 |
} |
| 1215 |
break; |
| 1216 |
case GuardClassKind::GrowableSharedArrayBuffer: |
| 1217 |
if (object->getClass() != |
| 1218 |
&GrowableSharedArrayBufferObject::class_) { |
| 1219 |
FAIL_IC(); |
| 1220 |
} |
| 1221 |
break; |
| 1222 |
case GuardClassKind::FixedLengthDataView: |
| 1223 |
if (object->getClass() != &FixedLengthDataViewObject::class_) { |
| 1224 |
FAIL_IC(); |
| 1225 |
} |
| 1226 |
break; |
| 1227 |
case GuardClassKind::ResizableDataView: |
| 1228 |
if (object->getClass() != &ResizableDataViewObject::class_) { |
| 1229 |
FAIL_IC(); |
| 1230 |
} |
| 1231 |
break; |
| 1232 |
case GuardClassKind::MappedArguments: |
| 1233 |
if (object->getClass() != &MappedArgumentsObject::class_) { |
| 1234 |
FAIL_IC(); |
| 1235 |
} |
| 1236 |
break; |
| 1237 |
case GuardClassKind::UnmappedArguments: |
| 1238 |
if (object->getClass() != &UnmappedArgumentsObject::class_) { |
| 1239 |
FAIL_IC(); |
| 1240 |
} |
| 1241 |
break; |
| 1242 |
case GuardClassKind::WindowProxy: |
| 1243 |
if (object->getClass() != ctx.frameMgr.cxForLocalUseOnly() |
| 1244 |
->runtime() |
| 1245 |
->maybeWindowProxyClass()) { |
| 1246 |
FAIL_IC(); |
| 1247 |
} |
| 1248 |
break; |
| 1249 |
case GuardClassKind::JSFunction: |
| 1250 |
if (!object->is<JSFunction>()) { |
| 1251 |
FAIL_IC(); |
| 1252 |
} |
| 1253 |
break; |
| 1254 |
case GuardClassKind::Set: |
| 1255 |
if (object->getClass() != &SetObject::class_) { |
| 1256 |
FAIL_IC(); |
| 1257 |
} |
| 1258 |
break; |
| 1259 |
case GuardClassKind::Map: |
| 1260 |
if (object->getClass() != &MapObject::class_) { |
| 1261 |
FAIL_IC(); |
| 1262 |
} |
| 1263 |
break; |
| 1264 |
case GuardClassKind::BoundFunction: |
| 1265 |
if (object->getClass() != &BoundFunctionObject::class_) { |
| 1266 |
FAIL_IC(); |
| 1267 |
} |
| 1268 |
break; |
| 1269 |
case GuardClassKind::Date: |
| 1270 |
if (object->getClass() != &DateObject::class_) { |
| 1271 |
FAIL_IC(); |
| 1272 |
} |
| 1273 |
break; |
| 1274 |
} |
| 1275 |
DISPATCH_CACHEOP(); |
| 1276 |
} |
| 1277 |
|
| 1278 |
CACHEOP_CASE(GuardAnyClass) { |
| 1279 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1280 |
uint32_t claspOffset = cacheIRReader.stubOffset(); |
| 1281 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1282 |
JSClass* clasp = reinterpret_cast<JSClass*>( |
| 1283 |
stubInfo->getStubRawWord(cstub, claspOffset)); |
| 1284 |
if (obj->getClass() != clasp) { |
| 1285 |
FAIL_IC(); |
| 1286 |
} |
| 1287 |
DISPATCH_CACHEOP(); |
| 1288 |
} |
| 1289 |
|
| 1290 |
CACHEOP_CASE(GuardGlobalGeneration) { |
| 1291 |
uint32_t expectedOffset = cacheIRReader.stubOffset(); |
| 1292 |
uint32_t generationAddrOffset = cacheIRReader.stubOffset(); |
| 1293 |
uint32_t expected = stubInfo->getStubRawInt32(cstub, expectedOffset); |
| 1294 |
uint32_t* generationAddr = reinterpret_cast<uint32_t*>( |
| 1295 |
stubInfo->getStubRawWord(cstub, generationAddrOffset)); |
| 1296 |
if (*generationAddr != expected) { |
| 1297 |
FAIL_IC(); |
| 1298 |
} |
| 1299 |
DISPATCH_CACHEOP(); |
| 1300 |
} |
| 1301 |
|
| 1302 |
CACHEOP_CASE(HasClassResult) { |
| 1303 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1304 |
uint32_t claspOffset = cacheIRReader.stubOffset(); |
| 1305 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1306 |
JSClass* clasp = reinterpret_cast<JSClass*>( |
| 1307 |
stubInfo->getStubRawWord(cstub, claspOffset)); |
| 1308 |
retValue = BooleanValue(obj->getClass() == clasp).asRawBits(); |
| 1309 |
PREDICT_RETURN(); |
| 1310 |
DISPATCH_CACHEOP(); |
| 1311 |
} |
| 1312 |
|
| 1313 |
CACHEOP_CASE(GuardCompartment) { |
| 1314 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1315 |
uint32_t globalOffset = cacheIRReader.stubOffset(); |
| 1316 |
uint32_t compartmentOffset = cacheIRReader.stubOffset(); |
| 1317 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1318 |
JSObject* global = reinterpret_cast<JSObject*>( |
| 1319 |
stubInfo->getStubRawWord(cstub, globalOffset)); |
| 1320 |
JS::Compartment* compartment = reinterpret_cast<JS::Compartment*>( |
| 1321 |
stubInfo->getStubRawWord(cstub, compartmentOffset)); |
| 1322 |
if (IsDeadProxyObject(global)) { |
| 1323 |
FAIL_IC(); |
| 1324 |
} |
| 1325 |
if (obj->compartment() != compartment) { |
| 1326 |
FAIL_IC(); |
| 1327 |
} |
| 1328 |
DISPATCH_CACHEOP(); |
| 1329 |
} |
| 1330 |
|
| 1331 |
CACHEOP_CASE(GuardIsExtensible) { |
| 1332 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1333 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1334 |
if (obj->nonProxyIsExtensible()) { |
| 1335 |
FAIL_IC(); |
| 1336 |
} |
| 1337 |
DISPATCH_CACHEOP(); |
| 1338 |
} |
| 1339 |
|
| 1340 |
CACHEOP_CASE(GuardIsNativeObject) { |
| 1341 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1342 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1343 |
if (!obj->is<NativeObject>()) { |
| 1344 |
FAIL_IC(); |
| 1345 |
} |
| 1346 |
DISPATCH_CACHEOP(); |
| 1347 |
} |
| 1348 |
|
| 1349 |
CACHEOP_CASE(GuardIsProxy) { |
| 1350 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1351 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1352 |
if (!obj->is<ProxyObject>()) { |
| 1353 |
FAIL_IC(); |
| 1354 |
} |
| 1355 |
DISPATCH_CACHEOP(); |
| 1356 |
} |
| 1357 |
|
| 1358 |
CACHEOP_CASE(GuardIsNotProxy) { |
| 1359 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1360 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1361 |
if (obj->is<ProxyObject>()) { |
| 1362 |
FAIL_IC(); |
| 1363 |
} |
| 1364 |
DISPATCH_CACHEOP(); |
| 1365 |
} |
| 1366 |
|
| 1367 |
CACHEOP_CASE(GuardIsNotArrayBufferMaybeShared) { |
| 1368 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1369 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1370 |
const JSClass* clasp = obj->getClass(); |
| 1371 |
if (clasp == &FixedLengthArrayBufferObject::class_ || |
| 1372 |
clasp == &FixedLengthSharedArrayBufferObject::class_ || |
| 1373 |
clasp == &ResizableArrayBufferObject::class_ || |
| 1374 |
clasp == &GrowableSharedArrayBufferObject::class_) { |
| 1375 |
FAIL_IC(); |
| 1376 |
} |
| 1377 |
DISPATCH_CACHEOP(); |
| 1378 |
} |
| 1379 |
|
| 1380 |
CACHEOP_CASE(GuardIsTypedArray) { |
| 1381 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1382 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1383 |
if (!IsTypedArrayClass(obj->getClass())) { |
| 1384 |
FAIL_IC(); |
| 1385 |
} |
| 1386 |
DISPATCH_CACHEOP(); |
| 1387 |
} |
| 1388 |
|
| 1389 |
CACHEOP_CASE(GuardIsFixedLengthTypedArray) { |
| 1390 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1391 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1392 |
if (!IsFixedLengthTypedArrayClass(obj->getClass())) { |
| 1393 |
FAIL_IC(); |
| 1394 |
} |
| 1395 |
DISPATCH_CACHEOP(); |
| 1396 |
} |
| 1397 |
|
| 1398 |
CACHEOP_CASE(GuardHasProxyHandler) { |
| 1399 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1400 |
uint32_t handlerOffset = cacheIRReader.stubOffset(); |
| 1401 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1402 |
BaseProxyHandler* handler = reinterpret_cast<BaseProxyHandler*>( |
| 1403 |
stubInfo->getStubRawWord(cstub, handlerOffset)); |
| 1404 |
if (obj->as<ProxyObject>().handler() != handler) { |
| 1405 |
FAIL_IC(); |
| 1406 |
} |
| 1407 |
DISPATCH_CACHEOP(); |
| 1408 |
} |
| 1409 |
|
| 1410 |
CACHEOP_CASE(GuardIsNotDOMProxy) { |
| 1411 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1412 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1413 |
if (obj->as<ProxyObject>().handler()->family() == |
| 1414 |
GetDOMProxyHandlerFamily()) { |
| 1415 |
FAIL_IC(); |
| 1416 |
} |
| 1417 |
DISPATCH_CACHEOP(); |
| 1418 |
} |
| 1419 |
|
| 1420 |
CACHEOP_CASE(GuardSpecificObject) { |
| 1421 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1422 |
uint32_t expectedOffset = cacheIRReader.stubOffset(); |
| 1423 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1424 |
JSObject* expected = reinterpret_cast<JSObject*>( |
| 1425 |
stubInfo->getStubRawWord(cstub, expectedOffset)); |
| 1426 |
if (obj != expected) { |
| 1427 |
FAIL_IC(); |
| 1428 |
} |
| 1429 |
DISPATCH_CACHEOP(); |
| 1430 |
} |
| 1431 |
|
| 1432 |
CACHEOP_CASE(GuardObjectIdentity) { |
| 1433 |
ObjOperandId obj1Id = cacheIRReader.objOperandId(); |
| 1434 |
ObjOperandId obj2Id = cacheIRReader.objOperandId(); |
| 1435 |
JSObject* obj1 = reinterpret_cast<JSObject*>(READ_REG(obj1Id.id())); |
| 1436 |
JSObject* obj2 = reinterpret_cast<JSObject*>(READ_REG(obj2Id.id())); |
| 1437 |
if (obj1 != obj2) { |
| 1438 |
FAIL_IC(); |
| 1439 |
} |
| 1440 |
DISPATCH_CACHEOP(); |
| 1441 |
} |
| 1442 |
|
| 1443 |
CACHEOP_CASE(GuardSpecificFunction) { |
| 1444 |
ObjOperandId funId = cacheIRReader.objOperandId(); |
| 1445 |
uint32_t expectedOffset = cacheIRReader.stubOffset(); |
| 1446 |
uint32_t nargsAndFlagsOffset = cacheIRReader.stubOffset(); |
| 1447 |
(void)nargsAndFlagsOffset; // Unused. |
| 1448 |
uintptr_t expected = stubInfo->getStubRawWord(cstub, expectedOffset); |
| 1449 |
if (expected != READ_REG(funId.id())) { |
| 1450 |
FAIL_IC(); |
| 1451 |
} |
| 1452 |
PREDICT_NEXT(LoadArgumentFixedSlot); |
| 1453 |
DISPATCH_CACHEOP(); |
| 1454 |
} |
| 1455 |
|
| 1456 |
CACHEOP_CASE(GuardFunctionScript) { |
| 1457 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1458 |
uint32_t expectedOffset = cacheIRReader.stubOffset(); |
| 1459 |
uint32_t nargsAndFlagsOffset = cacheIRReader.stubOffset(); |
| 1460 |
JSFunction* fun = reinterpret_cast<JSFunction*>(READ_REG(objId.id())); |
| 1461 |
BaseScript* expected = reinterpret_cast<BaseScript*>( |
| 1462 |
stubInfo->getStubRawWord(cstub, expectedOffset)); |
| 1463 |
(void)nargsAndFlagsOffset; |
| 1464 |
|
| 1465 |
if (!fun->hasBaseScript() || fun->baseScript() != expected) { |
| 1466 |
FAIL_IC(); |
| 1467 |
} |
| 1468 |
|
| 1469 |
PREDICT_NEXT(CallScriptedFunction); |
| 1470 |
DISPATCH_CACHEOP(); |
| 1471 |
} |
| 1472 |
|
| 1473 |
CACHEOP_CASE(GuardSpecificAtom) { |
| 1474 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 1475 |
uint32_t expectedOffset = cacheIRReader.stubOffset(); |
| 1476 |
uintptr_t expected = stubInfo->getStubRawWord(cstub, expectedOffset); |
| 1477 |
if (expected != READ_REG(strId.id())) { |
| 1478 |
// TODO: BaselineCacheIRCompiler also checks for equal strings |
| 1479 |
FAIL_IC(); |
| 1480 |
} |
| 1481 |
DISPATCH_CACHEOP(); |
| 1482 |
} |
| 1483 |
|
| 1484 |
CACHEOP_CASE(GuardSpecificSymbol) { |
| 1485 |
SymbolOperandId symId = cacheIRReader.symbolOperandId(); |
| 1486 |
uint32_t expectedOffset = cacheIRReader.stubOffset(); |
| 1487 |
uintptr_t expected = stubInfo->getStubRawWord(cstub, expectedOffset); |
| 1488 |
if (expected != READ_REG(symId.id())) { |
| 1489 |
FAIL_IC(); |
| 1490 |
} |
| 1491 |
DISPATCH_CACHEOP(); |
| 1492 |
} |
| 1493 |
|
| 1494 |
CACHEOP_CASE(GuardSpecificInt32) { |
| 1495 |
Int32OperandId numId = cacheIRReader.int32OperandId(); |
| 1496 |
int32_t expected = cacheIRReader.int32Immediate(); |
| 1497 |
if (expected != int32_t(READ_REG(numId.id()))) { |
| 1498 |
FAIL_IC(); |
| 1499 |
} |
| 1500 |
DISPATCH_CACHEOP(); |
| 1501 |
} |
| 1502 |
|
| 1503 |
CACHEOP_CASE(GuardNoDenseElements) { |
| 1504 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1505 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1506 |
if (obj->as<NativeObject>().getDenseInitializedLength() != 0) { |
| 1507 |
FAIL_IC(); |
| 1508 |
} |
| 1509 |
DISPATCH_CACHEOP(); |
| 1510 |
} |
| 1511 |
|
| 1512 |
CACHEOP_CASE(GuardStringToIndex) { |
| 1513 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 1514 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 1515 |
BOUNDSCHECK(resultId); |
| 1516 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 1517 |
int32_t result; |
| 1518 |
if (str->hasIndexValue()) { |
| 1519 |
uint32_t index = str->getIndexValue(); |
| 1520 |
MOZ_ASSERT(index <= INT32_MAX); |
| 1521 |
result = index; |
| 1522 |
} else { |
| 1523 |
result = GetIndexFromString(str); |
| 1524 |
if (result < 0) { |
| 1525 |
FAIL_IC(); |
| 1526 |
} |
| 1527 |
} |
| 1528 |
WRITE_REG(resultId.id(), result, INT32); |
| 1529 |
DISPATCH_CACHEOP(); |
| 1530 |
} |
| 1531 |
|
| 1532 |
CACHEOP_CASE(GuardStringToInt32) { |
| 1533 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 1534 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 1535 |
BOUNDSCHECK(resultId); |
| 1536 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 1537 |
int32_t result; |
| 1538 |
// Use indexed value as fast path if possible. |
| 1539 |
if (str->hasIndexValue()) { |
| 1540 |
uint32_t index = str->getIndexValue(); |
| 1541 |
MOZ_ASSERT(index <= INT32_MAX); |
| 1542 |
result = index; |
| 1543 |
} else { |
| 1544 |
if (!GetInt32FromStringPure(ctx.frameMgr.cxForLocalUseOnly(), str, |
| 1545 |
&result)) { |
| 1546 |
FAIL_IC(); |
| 1547 |
} |
| 1548 |
} |
| 1549 |
WRITE_REG(resultId.id(), result, INT32); |
| 1550 |
DISPATCH_CACHEOP(); |
| 1551 |
} |
| 1552 |
|
| 1553 |
CACHEOP_CASE(GuardStringToNumber) { |
| 1554 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 1555 |
NumberOperandId resultId = cacheIRReader.numberOperandId(); |
| 1556 |
BOUNDSCHECK(resultId); |
| 1557 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 1558 |
Value result; |
| 1559 |
// Use indexed value as fast path if possible. |
| 1560 |
if (str->hasIndexValue()) { |
| 1561 |
uint32_t index = str->getIndexValue(); |
| 1562 |
MOZ_ASSERT(index <= INT32_MAX); |
| 1563 |
result = Int32Value(index); |
| 1564 |
} else { |
| 1565 |
double value; |
| 1566 |
if (!StringToNumberPure(ctx.frameMgr.cxForLocalUseOnly(), str, |
| 1567 |
&value)) { |
| 1568 |
FAIL_IC(); |
| 1569 |
} |
| 1570 |
result = DoubleValue(value); |
| 1571 |
} |
| 1572 |
WRITE_VALUE_REG(resultId.id(), result); |
| 1573 |
DISPATCH_CACHEOP(); |
| 1574 |
} |
| 1575 |
|
| 1576 |
CACHEOP_CASE(BooleanToNumber) { |
| 1577 |
BooleanOperandId booleanId = cacheIRReader.booleanOperandId(); |
| 1578 |
NumberOperandId resultId = cacheIRReader.numberOperandId(); |
| 1579 |
BOUNDSCHECK(resultId); |
| 1580 |
uint64_t boolean = READ_REG(booleanId.id()); |
| 1581 |
MOZ_ASSERT((boolean & ~1) == 0); |
| 1582 |
WRITE_VALUE_REG(resultId.id(), Int32Value(boolean)); |
| 1583 |
DISPATCH_CACHEOP(); |
| 1584 |
} |
| 1585 |
|
| 1586 |
CACHEOP_CASE(GuardHasGetterSetter) { |
| 1587 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1588 |
uint32_t idOffset = cacheIRReader.stubOffset(); |
| 1589 |
uint32_t getterSetterOffset = cacheIRReader.stubOffset(); |
| 1590 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1591 |
jsid id = jsid::fromRawBits(stubInfo->getStubRawWord(cstub, idOffset)); |
| 1592 |
GetterSetter* getterSetter = reinterpret_cast<GetterSetter*>( |
| 1593 |
stubInfo->getStubRawWord(cstub, getterSetterOffset)); |
| 1594 |
if (!ObjectHasGetterSetterPure(ctx.frameMgr.cxForLocalUseOnly(), obj, |
| 1595 |
id, getterSetter)) { |
| 1596 |
FAIL_IC(); |
| 1597 |
} |
| 1598 |
DISPATCH_CACHEOP(); |
| 1599 |
} |
| 1600 |
|
| 1601 |
CACHEOP_CASE(GuardInt32IsNonNegative) { |
| 1602 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 1603 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 1604 |
if (index < 0) { |
| 1605 |
FAIL_IC(); |
| 1606 |
} |
| 1607 |
DISPATCH_CACHEOP(); |
| 1608 |
} |
| 1609 |
|
| 1610 |
CACHEOP_CASE(GuardDynamicSlotIsSpecificObject) { |
| 1611 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1612 |
ObjOperandId expectedId = cacheIRReader.objOperandId(); |
| 1613 |
uint32_t slotOffset = cacheIRReader.stubOffset(); |
| 1614 |
JSObject* expected = |
| 1615 |
reinterpret_cast<JSObject*>(READ_REG(expectedId.id())); |
| 1616 |
uintptr_t slot = stubInfo->getStubRawInt32(cstub, slotOffset); |
| 1617 |
NativeObject* nobj = |
| 1618 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 1619 |
HeapSlot* slots = nobj->getSlotsUnchecked(); |
| 1620 |
// Note that unlike similar opcodes, GuardDynamicSlotIsSpecificObject |
| 1621 |
// takes a slot index rather than a byte offset. |
| 1622 |
Value actual = slots[slot]; |
| 1623 |
if (actual != ObjectValue(*expected)) { |
| 1624 |
FAIL_IC(); |
| 1625 |
} |
| 1626 |
DISPATCH_CACHEOP(); |
| 1627 |
} |
| 1628 |
|
| 1629 |
CACHEOP_CASE(GuardDynamicSlotIsNotObject) { |
| 1630 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1631 |
uint32_t slotOffset = cacheIRReader.stubOffset(); |
| 1632 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1633 |
uint32_t slot = stubInfo->getStubRawInt32(cstub, slotOffset); |
| 1634 |
NativeObject* nobj = &obj->as<NativeObject>(); |
| 1635 |
HeapSlot* slots = nobj->getSlotsUnchecked(); |
| 1636 |
// Note that unlike similar opcodes, GuardDynamicSlotIsNotObject takes a |
| 1637 |
// slot index rather than a byte offset. |
| 1638 |
Value actual = slots[slot]; |
| 1639 |
if (actual.isObject()) { |
| 1640 |
FAIL_IC(); |
| 1641 |
} |
| 1642 |
DISPATCH_CACHEOP(); |
| 1643 |
} |
| 1644 |
|
| 1645 |
CACHEOP_CASE(GuardFixedSlotValue) { |
| 1646 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1647 |
uint32_t offsetOffset = cacheIRReader.stubOffset(); |
| 1648 |
uint32_t valOffset = cacheIRReader.stubOffset(); |
| 1649 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1650 |
uint32_t offset = stubInfo->getStubRawInt32(cstub, offsetOffset); |
| 1651 |
Value val = |
| 1652 |
Value::fromRawBits(stubInfo->getStubRawInt64(cstub, valOffset)); |
| 1653 |
GCPtr<Value>* slot = reinterpret_cast<GCPtr<Value>*>( |
| 1654 |
reinterpret_cast<uintptr_t>(obj) + offset); |
| 1655 |
Value actual = slot->get(); |
| 1656 |
if (actual != val) { |
| 1657 |
FAIL_IC(); |
| 1658 |
} |
| 1659 |
DISPATCH_CACHEOP(); |
| 1660 |
} |
| 1661 |
|
| 1662 |
CACHEOP_CASE(GuardDynamicSlotValue) { |
| 1663 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1664 |
uint32_t offsetOffset = cacheIRReader.stubOffset(); |
| 1665 |
uint32_t valOffset = cacheIRReader.stubOffset(); |
| 1666 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1667 |
uint32_t offset = stubInfo->getStubRawInt32(cstub, offsetOffset); |
| 1668 |
Value val = |
| 1669 |
Value::fromRawBits(stubInfo->getStubRawInt64(cstub, valOffset)); |
| 1670 |
NativeObject* nobj = &obj->as<NativeObject>(); |
| 1671 |
HeapSlot* slots = nobj->getSlotsUnchecked(); |
| 1672 |
Value actual = slots[offset / sizeof(Value)]; |
| 1673 |
if (actual != val) { |
| 1674 |
FAIL_IC(); |
| 1675 |
} |
| 1676 |
DISPATCH_CACHEOP(); |
| 1677 |
} |
| 1678 |
|
| 1679 |
CACHEOP_CASE(LoadFixedSlot) { |
| 1680 |
ValOperandId resultId = cacheIRReader.valOperandId(); |
| 1681 |
BOUNDSCHECK(resultId); |
| 1682 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1683 |
uint32_t offsetOffset = cacheIRReader.stubOffset(); |
| 1684 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1685 |
uint32_t offset = stubInfo->getStubRawInt32(cstub, offsetOffset); |
| 1686 |
GCPtr<Value>* slot = reinterpret_cast<GCPtr<Value>*>( |
| 1687 |
reinterpret_cast<uintptr_t>(obj) + offset); |
| 1688 |
Value actual = slot->get(); |
| 1689 |
WRITE_VALUE_REG(resultId.id(), actual); |
| 1690 |
DISPATCH_CACHEOP(); |
| 1691 |
} |
| 1692 |
|
| 1693 |
CACHEOP_CASE(LoadDynamicSlot) { |
| 1694 |
ValOperandId resultId = cacheIRReader.valOperandId(); |
| 1695 |
BOUNDSCHECK(resultId); |
| 1696 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1697 |
uint32_t slotOffset = cacheIRReader.stubOffset(); |
| 1698 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1699 |
uint32_t slot = stubInfo->getStubRawInt32(cstub, slotOffset); |
| 1700 |
NativeObject* nobj = &obj->as<NativeObject>(); |
| 1701 |
HeapSlot* slots = nobj->getSlotsUnchecked(); |
| 1702 |
// Note that unlike similar opcodes, LoadDynamicSlot takes a slot index |
| 1703 |
// rather than a byte offset. |
| 1704 |
Value actual = slots[slot]; |
| 1705 |
WRITE_VALUE_REG(resultId.id(), actual); |
| 1706 |
DISPATCH_CACHEOP(); |
| 1707 |
} |
| 1708 |
|
| 1709 |
CACHEOP_CASE(GuardNoAllocationMetadataBuilder) { |
| 1710 |
uint32_t builderAddrOffset = cacheIRReader.stubOffset(); |
| 1711 |
uintptr_t builderAddr = |
| 1712 |
stubInfo->getStubRawWord(cstub, builderAddrOffset); |
| 1713 |
if (*reinterpret_cast<uintptr_t*>(builderAddr) != 0) { |
| 1714 |
FAIL_IC(); |
| 1715 |
} |
| 1716 |
DISPATCH_CACHEOP(); |
| 1717 |
} |
| 1718 |
|
| 1719 |
CACHEOP_CASE(GuardFunctionHasJitEntry) { |
| 1720 |
ObjOperandId funId = cacheIRReader.objOperandId(); |
| 1721 |
JSObject* fun = reinterpret_cast<JSObject*>(READ_REG(funId.id())); |
| 1722 |
uint16_t flags = FunctionFlags::HasJitEntryFlags(); |
| 1723 |
if (!fun->as<JSFunction>().flags().hasFlags(flags)) { |
| 1724 |
FAIL_IC(); |
| 1725 |
} |
| 1726 |
DISPATCH_CACHEOP(); |
| 1727 |
} |
| 1728 |
|
| 1729 |
CACHEOP_CASE(GuardFunctionHasNoJitEntry) { |
| 1730 |
ObjOperandId funId = cacheIRReader.objOperandId(); |
| 1731 |
JSObject* fun = reinterpret_cast<JSObject*>(READ_REG(funId.id())); |
| 1732 |
uint16_t flags = FunctionFlags::HasJitEntryFlags(); |
| 1733 |
if (fun->as<JSFunction>().flags().hasFlags(flags)) { |
| 1734 |
FAIL_IC(); |
| 1735 |
} |
| 1736 |
DISPATCH_CACHEOP(); |
| 1737 |
} |
| 1738 |
|
| 1739 |
CACHEOP_CASE(GuardFunctionIsNonBuiltinCtor) { |
| 1740 |
ObjOperandId funId = cacheIRReader.objOperandId(); |
| 1741 |
JSObject* fun = reinterpret_cast<JSObject*>(READ_REG(funId.id())); |
| 1742 |
if (!fun->as<JSFunction>().isNonBuiltinConstructor()) { |
| 1743 |
FAIL_IC(); |
| 1744 |
} |
| 1745 |
DISPATCH_CACHEOP(); |
| 1746 |
} |
| 1747 |
|
| 1748 |
CACHEOP_CASE(GuardFunctionIsConstructor) { |
| 1749 |
ObjOperandId funId = cacheIRReader.objOperandId(); |
| 1750 |
JSObject* fun = reinterpret_cast<JSObject*>(READ_REG(funId.id())); |
| 1751 |
if (!fun->as<JSFunction>().isConstructor()) { |
| 1752 |
FAIL_IC(); |
| 1753 |
} |
| 1754 |
DISPATCH_CACHEOP(); |
| 1755 |
} |
| 1756 |
|
| 1757 |
CACHEOP_CASE(GuardNotClassConstructor) { |
| 1758 |
ObjOperandId funId = cacheIRReader.objOperandId(); |
| 1759 |
JSObject* fun = reinterpret_cast<JSObject*>(READ_REG(funId.id())); |
| 1760 |
if (fun->as<JSFunction>().isClassConstructor()) { |
| 1761 |
FAIL_IC(); |
| 1762 |
} |
| 1763 |
DISPATCH_CACHEOP(); |
| 1764 |
} |
| 1765 |
|
| 1766 |
CACHEOP_CASE(GuardArrayIsPacked) { |
| 1767 |
ObjOperandId arrayId = cacheIRReader.objOperandId(); |
| 1768 |
JSObject* array = reinterpret_cast<JSObject*>(READ_REG(arrayId.id())); |
| 1769 |
if (!IsPackedArray(array)) { |
| 1770 |
FAIL_IC(); |
| 1771 |
} |
| 1772 |
DISPATCH_CACHEOP(); |
| 1773 |
} |
| 1774 |
|
| 1775 |
CACHEOP_CASE(GuardArgumentsObjectFlags) { |
| 1776 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1777 |
uint8_t flags = cacheIRReader.readByte(); |
| 1778 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1779 |
if (obj->as<ArgumentsObject>().hasFlags(flags)) { |
| 1780 |
FAIL_IC(); |
| 1781 |
} |
| 1782 |
DISPATCH_CACHEOP(); |
| 1783 |
} |
| 1784 |
|
| 1785 |
CACHEOP_CASE(LoadObject) { |
| 1786 |
ObjOperandId resultId = cacheIRReader.objOperandId(); |
| 1787 |
BOUNDSCHECK(resultId); |
| 1788 |
uint32_t objOffset = cacheIRReader.stubOffset(); |
| 1789 |
intptr_t obj = stubInfo->getStubRawWord(cstub, objOffset); |
| 1790 |
WRITE_REG(resultId.id(), obj, OBJECT); |
| 1791 |
PREDICT_NEXT(GuardShape); |
| 1792 |
DISPATCH_CACHEOP(); |
| 1793 |
} |
| 1794 |
|
| 1795 |
CACHEOP_CASE(LoadProtoObject) { |
| 1796 |
ObjOperandId resultId = cacheIRReader.objOperandId(); |
| 1797 |
BOUNDSCHECK(resultId); |
| 1798 |
uint32_t protoObjOffset = cacheIRReader.stubOffset(); |
| 1799 |
ObjOperandId receiverObjId = cacheIRReader.objOperandId(); |
| 1800 |
(void)receiverObjId; |
| 1801 |
intptr_t obj = stubInfo->getStubRawWord(cstub, protoObjOffset); |
| 1802 |
WRITE_REG(resultId.id(), obj, OBJECT); |
| 1803 |
PREDICT_NEXT(GuardShape); |
| 1804 |
DISPATCH_CACHEOP(); |
| 1805 |
} |
| 1806 |
|
| 1807 |
CACHEOP_CASE(LoadProto) { |
| 1808 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1809 |
ObjOperandId resultId = cacheIRReader.objOperandId(); |
| 1810 |
BOUNDSCHECK(resultId); |
| 1811 |
NativeObject* nobj = |
| 1812 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 1813 |
WRITE_REG(resultId.id(), |
| 1814 |
reinterpret_cast<uint64_t>(nobj->staticPrototype()), OBJECT); |
| 1815 |
DISPATCH_CACHEOP(); |
| 1816 |
} |
| 1817 |
|
| 1818 |
CACHEOP_CASE(LoadEnclosingEnvironment) { |
| 1819 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1820 |
ObjOperandId resultId = cacheIRReader.objOperandId(); |
| 1821 |
BOUNDSCHECK(resultId); |
| 1822 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1823 |
JSObject* env = &obj->as<EnvironmentObject>().enclosingEnvironment(); |
| 1824 |
WRITE_REG(resultId.id(), reinterpret_cast<uint64_t>(env), OBJECT); |
| 1825 |
DISPATCH_CACHEOP(); |
| 1826 |
} |
| 1827 |
|
| 1828 |
CACHEOP_CASE(LoadWrapperTarget) { |
| 1829 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1830 |
ObjOperandId resultId = cacheIRReader.objOperandId(); |
| 1831 |
bool fallible = cacheIRReader.readBool(); |
| 1832 |
BOUNDSCHECK(resultId); |
| 1833 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1834 |
JSObject* target = obj->as<ProxyObject>().private_().toObjectOrNull(); |
| 1835 |
if (fallible && !target) { |
| 1836 |
FAIL_IC(); |
| 1837 |
} |
| 1838 |
WRITE_REG(resultId.id(), reinterpret_cast<uintptr_t>(target), OBJECT); |
| 1839 |
DISPATCH_CACHEOP(); |
| 1840 |
} |
| 1841 |
|
| 1842 |
CACHEOP_CASE(LoadValueTag) { |
| 1843 |
ValOperandId valId = cacheIRReader.valOperandId(); |
| 1844 |
ValueTagOperandId resultId = cacheIRReader.valueTagOperandId(); |
| 1845 |
BOUNDSCHECK(resultId); |
| 1846 |
Value val = READ_VALUE_REG(valId.id()); |
| 1847 |
WRITE_REG(resultId.id(), val.asRawBits() >> JSVAL_TAG_SHIFT, INT32); |
| 1848 |
DISPATCH_CACHEOP(); |
| 1849 |
} |
| 1850 |
|
| 1851 |
CACHEOP_CASE(LoadArgumentFixedSlot) { |
| 1852 |
ValOperandId resultId = cacheIRReader.valOperandId(); |
| 1853 |
BOUNDSCHECK(resultId); |
| 1854 |
uint8_t slotIndex = cacheIRReader.readByte(); |
| 1855 |
StackVal* sp = ctx.sp(); |
| 1856 |
Value val = sp[slotIndex].asValue(); |
| 1857 |
TRACE_PRINTF(" -> slot %d: val %" PRIx64 "\n", int(slotIndex), |
| 1858 |
val.asRawBits()); |
| 1859 |
WRITE_VALUE_REG(resultId.id(), val); |
| 1860 |
DISPATCH_CACHEOP(); |
| 1861 |
} |
| 1862 |
|
| 1863 |
CACHEOP_CASE(LoadArgumentDynamicSlot) { |
| 1864 |
ValOperandId resultId = cacheIRReader.valOperandId(); |
| 1865 |
BOUNDSCHECK(resultId); |
| 1866 |
Int32OperandId argcId = cacheIRReader.int32OperandId(); |
| 1867 |
uint8_t slotIndex = cacheIRReader.readByte(); |
| 1868 |
int32_t argc = int32_t(READ_REG(argcId.id())); |
| 1869 |
StackVal* sp = ctx.sp(); |
| 1870 |
Value val = sp[slotIndex + argc].asValue(); |
| 1871 |
WRITE_VALUE_REG(resultId.id(), val); |
| 1872 |
DISPATCH_CACHEOP(); |
| 1873 |
} |
| 1874 |
|
| 1875 |
CACHEOP_CASE(TruncateDoubleToUInt32) { |
| 1876 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 1877 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 1878 |
BOUNDSCHECK(resultId); |
| 1879 |
Value input = READ_VALUE_REG(inputId.id()); |
| 1880 |
WRITE_REG(resultId.id(), JS::ToInt32(input.toNumber()), INT32); |
| 1881 |
DISPATCH_CACHEOP(); |
| 1882 |
} |
| 1883 |
|
| 1884 |
CACHEOP_CASE(MegamorphicLoadSlotResult) { |
| 1885 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1886 |
uint32_t nameOffset = cacheIRReader.stubOffset(); |
| 1887 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1888 |
jsid name = |
| 1889 |
jsid::fromRawBits(stubInfo->getStubRawWord(cstub, nameOffset)); |
| 1890 |
if (!obj->shape()->isNative()) { |
| 1891 |
FAIL_IC(); |
| 1892 |
} |
| 1893 |
Value result; |
| 1894 |
if (!GetNativeDataPropertyPureWithCacheLookup( |
| 1895 |
ctx.frameMgr.cxForLocalUseOnly(), obj, name, nullptr, |
| 1896 |
&result)) { |
| 1897 |
FAIL_IC(); |
| 1898 |
} |
| 1899 |
retValue = result.asRawBits(); |
| 1900 |
DISPATCH_CACHEOP(); |
| 1901 |
} |
| 1902 |
|
| 1903 |
CACHEOP_CASE(MegamorphicLoadSlotByValueResult) { |
| 1904 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1905 |
ValOperandId idId = cacheIRReader.valOperandId(); |
| 1906 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1907 |
Value id = READ_VALUE_REG(idId.id()); |
| 1908 |
if (!obj->shape()->isNative()) { |
| 1909 |
FAIL_IC(); |
| 1910 |
} |
| 1911 |
Value values[2] = {id}; |
| 1912 |
if (!GetNativeDataPropertyByValuePure(ctx.frameMgr.cxForLocalUseOnly(), |
| 1913 |
obj, nullptr, values)) { |
| 1914 |
FAIL_IC(); |
| 1915 |
} |
| 1916 |
retValue = values[1].asRawBits(); |
| 1917 |
DISPATCH_CACHEOP(); |
| 1918 |
} |
| 1919 |
|
| 1920 |
CACHEOP_CASE(MegamorphicSetElement) { |
| 1921 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1922 |
ValOperandId idId = cacheIRReader.valOperandId(); |
| 1923 |
ValOperandId rhsId = cacheIRReader.valOperandId(); |
| 1924 |
bool strict = cacheIRReader.readBool(); |
| 1925 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1926 |
Value id = READ_VALUE_REG(idId.id()); |
| 1927 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 1928 |
{ |
| 1929 |
PUSH_IC_FRAME(); |
| 1930 |
ReservedRooted<JSObject*> obj0(&ctx.state.obj0, obj); |
| 1931 |
ReservedRooted<Value> value0(&ctx.state.value0, id); |
| 1932 |
ReservedRooted<Value> value1(&ctx.state.value1, rhs); |
| 1933 |
if (!SetElementMegamorphic<false>(cx, obj0, value0, value1, strict)) { |
| 1934 |
ctx.error = PBIResult::Error; |
| 1935 |
return IC_ERROR_SENTINEL(); |
| 1936 |
} |
| 1937 |
} |
| 1938 |
DISPATCH_CACHEOP(); |
| 1939 |
} |
| 1940 |
|
| 1941 |
CACHEOP_CASE(StoreFixedSlot) { |
| 1942 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1943 |
uint32_t offsetOffset = cacheIRReader.stubOffset(); |
| 1944 |
ValOperandId rhsId = cacheIRReader.valOperandId(); |
| 1945 |
uintptr_t offset = stubInfo->getStubRawInt32(cstub, offsetOffset); |
| 1946 |
NativeObject* nobj = |
| 1947 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 1948 |
GCPtr<Value>* slot = reinterpret_cast<GCPtr<Value>*>( |
| 1949 |
reinterpret_cast<uintptr_t>(nobj) + offset); |
| 1950 |
Value val = READ_VALUE_REG(rhsId.id()); |
| 1951 |
slot->set(val); |
| 1952 |
PREDICT_RETURN(); |
| 1953 |
DISPATCH_CACHEOP(); |
| 1954 |
} |
| 1955 |
|
| 1956 |
CACHEOP_CASE(StoreDynamicSlot) { |
| 1957 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1958 |
uint32_t offsetOffset = cacheIRReader.stubOffset(); |
| 1959 |
ValOperandId rhsId = cacheIRReader.valOperandId(); |
| 1960 |
uint32_t offset = stubInfo->getStubRawInt32(cstub, offsetOffset); |
| 1961 |
NativeObject* nobj = |
| 1962 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 1963 |
HeapSlot* slots = nobj->getSlotsUnchecked(); |
| 1964 |
Value val = READ_VALUE_REG(rhsId.id()); |
| 1965 |
size_t dynSlot = offset / sizeof(Value); |
| 1966 |
size_t slot = dynSlot + nobj->numFixedSlots(); |
| 1967 |
slots[dynSlot].set(nobj, HeapSlot::Slot, slot, val); |
| 1968 |
PREDICT_RETURN(); |
| 1969 |
DISPATCH_CACHEOP(); |
| 1970 |
} |
| 1971 |
|
| 1972 |
CACHEOP_CASE(AddAndStoreFixedSlot) { |
| 1973 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1974 |
uint32_t offsetOffset = cacheIRReader.stubOffset(); |
| 1975 |
ValOperandId rhsId = cacheIRReader.valOperandId(); |
| 1976 |
uint32_t newShapeOffset = cacheIRReader.stubOffset(); |
| 1977 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1978 |
int32_t offset = stubInfo->getStubRawInt32(cstub, offsetOffset); |
| 1979 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 1980 |
Shape* newShape = reinterpret_cast<Shape*>( |
| 1981 |
stubInfo->getStubRawWord(cstub, newShapeOffset)); |
| 1982 |
obj->setShape(newShape); |
| 1983 |
GCPtr<Value>* slot = reinterpret_cast<GCPtr<Value>*>( |
| 1984 |
reinterpret_cast<uintptr_t>(obj) + offset); |
| 1985 |
slot->init(rhs); |
| 1986 |
PREDICT_RETURN(); |
| 1987 |
DISPATCH_CACHEOP(); |
| 1988 |
} |
| 1989 |
|
| 1990 |
CACHEOP_CASE(AddAndStoreDynamicSlot) { |
| 1991 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 1992 |
uint32_t offsetOffset = cacheIRReader.stubOffset(); |
| 1993 |
ValOperandId rhsId = cacheIRReader.valOperandId(); |
| 1994 |
uint32_t newShapeOffset = cacheIRReader.stubOffset(); |
| 1995 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 1996 |
int32_t offset = stubInfo->getStubRawInt32(cstub, offsetOffset); |
| 1997 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 1998 |
Shape* newShape = reinterpret_cast<Shape*>( |
| 1999 |
stubInfo->getStubRawWord(cstub, newShapeOffset)); |
| 2000 |
NativeObject* nobj = &obj->as<NativeObject>(); |
| 2001 |
obj->setShape(newShape); |
| 2002 |
HeapSlot* slots = nobj->getSlotsUnchecked(); |
| 2003 |
size_t dynSlot = offset / sizeof(Value); |
| 2004 |
size_t slot = dynSlot + nobj->numFixedSlots(); |
| 2005 |
slots[dynSlot].init(nobj, HeapSlot::Slot, slot, rhs); |
| 2006 |
PREDICT_RETURN(); |
| 2007 |
DISPATCH_CACHEOP(); |
| 2008 |
} |
| 2009 |
|
| 2010 |
CACHEOP_CASE(AllocateAndStoreDynamicSlot) { |
| 2011 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2012 |
uint32_t offsetOffset = cacheIRReader.stubOffset(); |
| 2013 |
ValOperandId rhsId = cacheIRReader.valOperandId(); |
| 2014 |
uint32_t newShapeOffset = cacheIRReader.stubOffset(); |
| 2015 |
uint32_t numNewSlotsOffset = cacheIRReader.stubOffset(); |
| 2016 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 2017 |
int32_t offset = stubInfo->getStubRawInt32(cstub, offsetOffset); |
| 2018 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 2019 |
Shape* newShape = reinterpret_cast<Shape*>( |
| 2020 |
stubInfo->getStubRawWord(cstub, newShapeOffset)); |
| 2021 |
int32_t numNewSlots = |
| 2022 |
stubInfo->getStubRawInt32(cstub, numNewSlotsOffset); |
| 2023 |
NativeObject* nobj = &obj->as<NativeObject>(); |
| 2024 |
// We have to (re)allocate dynamic slots. Do this first, as it's the |
| 2025 |
// only fallible operation here. Note that growSlotsPure is fallible but |
| 2026 |
// does not GC. Otherwise this is the same as AddAndStoreDynamicSlot |
| 2027 |
// above. |
| 2028 |
if (!NativeObject::growSlotsPure(ctx.frameMgr.cxForLocalUseOnly(), nobj, |
| 2029 |
numNewSlots)) { |
| 2030 |
FAIL_IC(); |
| 2031 |
} |
| 2032 |
obj->setShape(newShape); |
| 2033 |
HeapSlot* slots = nobj->getSlotsUnchecked(); |
| 2034 |
size_t dynSlot = offset / sizeof(Value); |
| 2035 |
size_t slot = dynSlot + nobj->numFixedSlots(); |
| 2036 |
slots[dynSlot].init(nobj, HeapSlot::Slot, slot, rhs); |
| 2037 |
PREDICT_RETURN(); |
| 2038 |
DISPATCH_CACHEOP(); |
| 2039 |
} |
| 2040 |
|
| 2041 |
CACHEOP_CASE(StoreDenseElement) { |
| 2042 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2043 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2044 |
ValOperandId rhsId = cacheIRReader.valOperandId(); |
| 2045 |
NativeObject* nobj = |
| 2046 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 2047 |
ObjectElements* elems = nobj->getElementsHeader(); |
| 2048 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 2049 |
if (index < 0 || uint32_t(index) >= nobj->getDenseInitializedLength()) { |
| 2050 |
FAIL_IC(); |
| 2051 |
} |
| 2052 |
HeapSlot* slot = &elems->elements()[index]; |
| 2053 |
if (slot->get().isMagic()) { |
| 2054 |
FAIL_IC(); |
| 2055 |
} |
| 2056 |
Value val = READ_VALUE_REG(rhsId.id()); |
| 2057 |
slot->set(nobj, HeapSlot::Element, index + elems->numShiftedElements(), |
| 2058 |
val); |
| 2059 |
PREDICT_RETURN(); |
| 2060 |
DISPATCH_CACHEOP(); |
| 2061 |
} |
| 2062 |
|
| 2063 |
CACHEOP_CASE(StoreDenseElementHole) { |
| 2064 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2065 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2066 |
ValOperandId rhsId = cacheIRReader.valOperandId(); |
| 2067 |
bool handleAdd = cacheIRReader.readBool(); |
| 2068 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 2069 |
uint32_t index = uint32_t(READ_REG(indexId.id())); |
| 2070 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 2071 |
NativeObject* nobj = &obj->as<NativeObject>(); |
| 2072 |
uint32_t initLength = nobj->getDenseInitializedLength(); |
| 2073 |
if (index < initLength) { |
| 2074 |
nobj->setDenseElement(index, rhs); |
| 2075 |
} else if (!handleAdd || index > initLength) { |
| 2076 |
FAIL_IC(); |
| 2077 |
} else { |
| 2078 |
if (index >= nobj->getDenseCapacity()) { |
| 2079 |
if (!NativeObject::addDenseElementPure( |
| 2080 |
ctx.frameMgr.cxForLocalUseOnly(), nobj)) { |
| 2081 |
FAIL_IC(); |
| 2082 |
} |
| 2083 |
} |
| 2084 |
nobj->setDenseInitializedLength(initLength + 1); |
| 2085 |
|
| 2086 |
// Baseline always updates the length field by directly accessing its |
| 2087 |
// offset in ObjectElements. If the object is not an ArrayObject then |
| 2088 |
// this field is never read, so it's okay to skip the update here in |
| 2089 |
// that case. |
| 2090 |
if (nobj->is<ArrayObject>()) { |
| 2091 |
ArrayObject* aobj = &nobj->as<ArrayObject>(); |
| 2092 |
uint32_t len = aobj->length(); |
| 2093 |
if (len <= index) { |
| 2094 |
aobj->setLength(ctx.frameMgr.cxForLocalUseOnly(), len + 1); |
| 2095 |
} |
| 2096 |
} |
| 2097 |
|
| 2098 |
nobj->initDenseElement(index, rhs); |
| 2099 |
} |
| 2100 |
PREDICT_RETURN(); |
| 2101 |
DISPATCH_CACHEOP(); |
| 2102 |
} |
| 2103 |
|
| 2104 |
CACHEOP_CASE(ArrayPush) { |
| 2105 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2106 |
ValOperandId rhsId = cacheIRReader.valOperandId(); |
| 2107 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 2108 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 2109 |
ArrayObject* aobj = &obj->as<ArrayObject>(); |
| 2110 |
uint32_t initLength = aobj->getDenseInitializedLength(); |
| 2111 |
if (aobj->length() != initLength) { |
| 2112 |
FAIL_IC(); |
| 2113 |
} |
| 2114 |
if (initLength >= aobj->getDenseCapacity()) { |
| 2115 |
if (!NativeObject::addDenseElementPure( |
| 2116 |
ctx.frameMgr.cxForLocalUseOnly(), aobj)) { |
| 2117 |
FAIL_IC(); |
| 2118 |
} |
| 2119 |
} |
| 2120 |
aobj->setDenseInitializedLength(initLength + 1); |
| 2121 |
aobj->setLengthToInitializedLength(); |
| 2122 |
aobj->initDenseElement(initLength, rhs); |
| 2123 |
retValue = Int32Value(initLength + 1).asRawBits(); |
| 2124 |
PREDICT_RETURN(); |
| 2125 |
DISPATCH_CACHEOP(); |
| 2126 |
} |
| 2127 |
|
| 2128 |
CACHEOP_CASE(IsObjectResult) { |
| 2129 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 2130 |
Value val = READ_VALUE_REG(inputId.id()); |
| 2131 |
retValue = BooleanValue(val.isObject()).asRawBits(); |
| 2132 |
PREDICT_RETURN(); |
| 2133 |
DISPATCH_CACHEOP(); |
| 2134 |
} |
| 2135 |
|
| 2136 |
CACHEOP_CASE(Int32MinMax) { |
| 2137 |
bool isMax = cacheIRReader.readBool(); |
| 2138 |
Int32OperandId firstId = cacheIRReader.int32OperandId(); |
| 2139 |
Int32OperandId secondId = cacheIRReader.int32OperandId(); |
| 2140 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 2141 |
BOUNDSCHECK(resultId); |
| 2142 |
int32_t lhs = int32_t(READ_REG(firstId.id())); |
| 2143 |
int32_t rhs = int32_t(READ_REG(secondId.id())); |
| 2144 |
int32_t result = ((lhs > rhs) ^ isMax) ? rhs : lhs; |
| 2145 |
WRITE_REG(resultId.id(), result, INT32); |
| 2146 |
DISPATCH_CACHEOP(); |
| 2147 |
} |
| 2148 |
|
| 2149 |
CACHEOP_CASE(StoreTypedArrayElement) { |
| 2150 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2151 |
Scalar::Type elementType = cacheIRReader.scalarType(); |
| 2152 |
IntPtrOperandId indexId = cacheIRReader.intPtrOperandId(); |
| 2153 |
uint32_t rhsId = cacheIRReader.rawOperandId(); |
| 2154 |
bool handleOOB = cacheIRReader.readBool(); |
| 2155 |
ArrayBufferViewKind kind = cacheIRReader.arrayBufferViewKind(); |
| 2156 |
(void)kind; |
| 2157 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 2158 |
uintptr_t index = uintptr_t(READ_REG(indexId.id())); |
| 2159 |
uint64_t rhs = READ_REG(rhsId); |
| 2160 |
if (obj->as<TypedArrayObject>().length().isNothing()) { |
| 2161 |
FAIL_IC(); |
| 2162 |
} |
| 2163 |
if (index >= obj->as<TypedArrayObject>().length().value()) { |
| 2164 |
if (!handleOOB) { |
| 2165 |
FAIL_IC(); |
| 2166 |
} |
| 2167 |
} else { |
| 2168 |
Value v; |
| 2169 |
switch (elementType) { |
| 2170 |
case Scalar::Int8: |
| 2171 |
case Scalar::Uint8: |
| 2172 |
case Scalar::Int16: |
| 2173 |
case Scalar::Uint16: |
| 2174 |
case Scalar::Int32: |
| 2175 |
case Scalar::Uint32: |
| 2176 |
case Scalar::Uint8Clamped: |
| 2177 |
v = Int32Value(rhs); |
| 2178 |
break; |
| 2179 |
|
| 2180 |
case Scalar::Float16: |
| 2181 |
case Scalar::Float32: |
| 2182 |
case Scalar::Float64: |
| 2183 |
v = Value::fromRawBits(rhs); |
| 2184 |
MOZ_ASSERT(v.isNumber()); |
| 2185 |
break; |
| 2186 |
|
| 2187 |
case Scalar::BigInt64: |
| 2188 |
case Scalar::BigUint64: |
| 2189 |
v = BigIntValue(reinterpret_cast<JS::BigInt*>(rhs)); |
| 2190 |
break; |
| 2191 |
|
| 2192 |
case Scalar::MaxTypedArrayViewType: |
| 2193 |
case Scalar::Int64: |
| 2194 |
case Scalar::Simd128: |
| 2195 |
MOZ_CRASH("Unsupported TypedArray type"); |
| 2196 |
} |
| 2197 |
|
| 2198 |
// SetTypedArrayElement doesn't do anything that can actually GC or |
| 2199 |
// need a new context when the value can only be Int32, Double, or |
| 2200 |
// BigInt, as the above switch statement enforces. |
| 2201 |
FakeRooted<TypedArrayObject*> obj0(nullptr, |
| 2202 |
&obj->as<TypedArrayObject>()); |
| 2203 |
FakeRooted<Value> value0(nullptr, v); |
| 2204 |
ObjectOpResult result; |
| 2205 |
MOZ_ASSERT(elementType == obj0->type()); |
| 2206 |
MOZ_ALWAYS_TRUE(SetTypedArrayElement(ctx.frameMgr.cxForLocalUseOnly(), |
| 2207 |
obj0, index, value0, result)); |
| 2208 |
MOZ_ALWAYS_TRUE(result.ok()); |
| 2209 |
} |
| 2210 |
DISPATCH_CACHEOP(); |
| 2211 |
} |
| 2212 |
|
| 2213 |
CACHEOP_CASE(LoadTypedArrayElementExistsResult) { |
| 2214 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2215 |
IntPtrOperandId indexId = cacheIRReader.intPtrOperandId(); |
| 2216 |
ArrayBufferViewKind kind = cacheIRReader.arrayBufferViewKind(); |
| 2217 |
(void)kind; |
| 2218 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 2219 |
uintptr_t index = uintptr_t(READ_REG(indexId.id())); |
| 2220 |
if (obj->as<TypedArrayObject>().length().isNothing()) { |
| 2221 |
FAIL_IC(); |
| 2222 |
} |
| 2223 |
retValue = |
| 2224 |
BooleanValue(index < obj->as<TypedArrayObject>().length().value()) |
| 2225 |
.asRawBits(); |
| 2226 |
DISPATCH_CACHEOP(); |
| 2227 |
} |
| 2228 |
|
| 2229 |
CACHEOP_CASE(LoadTypedArrayElementResult) { |
| 2230 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2231 |
IntPtrOperandId indexId = cacheIRReader.intPtrOperandId(); |
| 2232 |
Scalar::Type elementType = cacheIRReader.scalarType(); |
| 2233 |
bool handleOOB = cacheIRReader.readBool(); |
| 2234 |
bool forceDoubleForUint32 = cacheIRReader.readBool(); |
| 2235 |
ArrayBufferViewKind kind = cacheIRReader.arrayBufferViewKind(); |
| 2236 |
(void)kind; |
| 2237 |
(void)elementType; |
| 2238 |
(void)handleOOB; |
| 2239 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 2240 |
uintptr_t index = uintptr_t(READ_REG(indexId.id())); |
| 2241 |
if (obj->as<TypedArrayObject>().length().isNothing()) { |
| 2242 |
FAIL_IC(); |
| 2243 |
} |
| 2244 |
if (index >= obj->as<TypedArrayObject>().length().value()) { |
| 2245 |
FAIL_IC(); |
| 2246 |
} |
| 2247 |
Value v; |
| 2248 |
if (!obj->as<TypedArrayObject>().getElementPure(index, &v)) { |
| 2249 |
FAIL_IC(); |
| 2250 |
} |
| 2251 |
if (forceDoubleForUint32) { |
| 2252 |
if (v.isInt32()) { |
| 2253 |
v.setNumber(v.toInt32()); |
| 2254 |
} |
| 2255 |
} |
| 2256 |
retValue = v.asRawBits(); |
| 2257 |
PREDICT_RETURN(); |
| 2258 |
DISPATCH_CACHEOP(); |
| 2259 |
} |
| 2260 |
|
| 2261 |
CACHEOP_CASE(CallInt32ToString) { |
| 2262 |
Int32OperandId inputId = cacheIRReader.int32OperandId(); |
| 2263 |
StringOperandId resultId = cacheIRReader.stringOperandId(); |
| 2264 |
BOUNDSCHECK(resultId); |
| 2265 |
int32_t input = int32_t(READ_REG(inputId.id())); |
| 2266 |
JSLinearString* str = |
| 2267 |
Int32ToStringPure(ctx.frameMgr.cxForLocalUseOnly(), input); |
| 2268 |
if (str) { |
| 2269 |
WRITE_REG(resultId.id(), reinterpret_cast<uintptr_t>(str), STRING); |
| 2270 |
} else { |
| 2271 |
FAIL_IC(); |
| 2272 |
} |
| 2273 |
DISPATCH_CACHEOP(); |
| 2274 |
} |
| 2275 |
|
| 2276 |
CACHEOP_CASE(CallScriptedFunction) |
| 2277 |
CACHEOP_CASE_FALLTHROUGH(CallNativeFunction) { |
| 2278 |
bool isNative = cacheop == CacheOp::CallNativeFunction; |
| 2279 |
TRACE_PRINTF("CallScriptedFunction / CallNativeFunction (native: %d)\n", |
| 2280 |
isNative); |
| 2281 |
ObjOperandId calleeId = cacheIRReader.objOperandId(); |
| 2282 |
Int32OperandId argcId = cacheIRReader.int32OperandId(); |
| 2283 |
CallFlags flags = cacheIRReader.callFlags(); |
| 2284 |
uint32_t argcFixed = cacheIRReader.uint32Immediate(); |
| 2285 |
bool ignoresRv = false; |
| 2286 |
if (isNative) { |
| 2287 |
ignoresRv = cacheIRReader.readBool(); |
| 2288 |
} |
| 2289 |
|
| 2290 |
TRACE_PRINTF("isConstructing = %d needsUninitializedThis = %d\n", |
| 2291 |
int(flags.isConstructing()), |
| 2292 |
int(flags.needsUninitializedThis())); |
| 2293 |
|
| 2294 |
JSFunction* callee = |
| 2295 |
reinterpret_cast<JSFunction*>(READ_REG(calleeId.id())); |
| 2296 |
uint32_t argc = uint32_t(READ_REG(argcId.id())); |
| 2297 |
(void)argcFixed; |
| 2298 |
|
| 2299 |
if (!isNative) { |
| 2300 |
if (!callee->hasBaseScript() || |
| 2301 |
!callee->baseScript()->hasBytecode() || |
| 2302 |
!callee->baseScript()->hasJitScript()) { |
| 2303 |
FAIL_IC(); |
| 2304 |
} |
| 2305 |
} |
| 2306 |
|
| 2307 |
// For now, fail any different-realm cases. |
| 2308 |
if (!flags.isSameRealm()) { |
| 2309 |
TRACE_PRINTF("failing: not same realm\n"); |
| 2310 |
FAIL_IC(); |
| 2311 |
} |
| 2312 |
// And support only "standard" arg formats. |
| 2313 |
if (flags.getArgFormat() != CallFlags::Standard) { |
| 2314 |
TRACE_PRINTF("failing: not standard arg format\n"); |
| 2315 |
FAIL_IC(); |
| 2316 |
} |
| 2317 |
|
| 2318 |
// Fail constructing on a non-constructor callee. |
| 2319 |
if (flags.isConstructing() && !callee->isConstructor()) { |
| 2320 |
TRACE_PRINTF("failing: constructing a non-constructor\n"); |
| 2321 |
FAIL_IC(); |
| 2322 |
} |
| 2323 |
|
| 2324 |
// Handle arg-underflow (but only for scripted targets). |
| 2325 |
uint32_t undefArgs = (!isNative && (argc < callee->nargs())) |
| 2326 |
? (callee->nargs() - argc) |
| 2327 |
: 0; |
| 2328 |
uint32_t extra = 1 + flags.isConstructing() + isNative; |
| 2329 |
uint32_t totalArgs = argc + undefArgs + extra; |
| 2330 |
StackVal* origArgs = ctx.sp(); |
| 2331 |
|
| 2332 |
{ |
| 2333 |
PUSH_IC_FRAME(); |
| 2334 |
|
| 2335 |
if (!ctx.stack.check(sp, sizeof(StackVal) * (totalArgs + 6))) { |
| 2336 |
ReportOverRecursed(ctx.frameMgr.cxForLocalUseOnly()); |
| 2337 |
ctx.error = PBIResult::Error; |
| 2338 |
return IC_ERROR_SENTINEL(); |
| 2339 |
} |
| 2340 |
|
| 2341 |
// Create `this` if we are constructing and this is a |
| 2342 |
// scripted function. |
| 2343 |
Value thisVal; |
| 2344 |
// Force JIT scripts to stick around, so we don't have to |
| 2345 |
// fail the IC after GC'ing. This is critical, because |
| 2346 |
// `stub` is not rooted (we don't have a BaselineStub frame |
| 2347 |
// in PBL, only an exit frame directly below a baseline |
| 2348 |
// function frame), so we cannot fall back to the next stub |
| 2349 |
// once we pass this point. |
| 2350 |
AutoKeepJitScripts keepJitScripts(cx); |
| 2351 |
if (flags.isConstructing() && !isNative) { |
| 2352 |
if (flags.needsUninitializedThis()) { |
| 2353 |
thisVal = MagicValue(JS_UNINITIALIZED_LEXICAL); |
| 2354 |
} else { |
| 2355 |
ReservedRooted<JSObject*> calleeObj(&ctx.state.obj0, callee); |
| 2356 |
ReservedRooted<JSObject*> newTargetRooted( |
| 2357 |
&ctx.state.obj1, &origArgs[0].asValue().toObject()); |
| 2358 |
ReservedRooted<Value> result(&ctx.state.value0, |
| 2359 |
MagicValue(JS_IS_CONSTRUCTING)); |
| 2360 |
HandleFunction fun = calleeObj.as<JSFunction>(); |
| 2361 |
if (!js::CreateThis(cx, fun, newTargetRooted, GenericObject, |
| 2362 |
&result)) { |
| 2363 |
ctx.error = PBIResult::Error; |
| 2364 |
return IC_ERROR_SENTINEL(); |
| 2365 |
} |
| 2366 |
thisVal = result; |
| 2367 |
// `callee` may have moved. |
| 2368 |
callee = &calleeObj->as<JSFunction>(); |
| 2369 |
} |
| 2370 |
} |
| 2371 |
// This will not be an Exit frame but a BaselineStub frame, so |
| 2372 |
// replace the ExitFrameType with the ICStub pointer. |
| 2373 |
POPNNATIVE(1); |
| 2374 |
PUSHNATIVE(StackValNative(cstub)); |
| 2375 |
|
| 2376 |
// `origArgs` is (in index order, i.e. increasing address order) |
| 2377 |
// - normal, scripted: arg[argc-1] ... arg[0] thisv |
| 2378 |
// - ctor, scripted: newTarget arg[argc-1] ... arg[0] thisv |
| 2379 |
// - normal, native: arg[argc-1] ... arg[0] thisv callee |
| 2380 |
// - ctor, native: newTarget arg[argc-1] ... arg[0] thisv callee |
| 2381 |
// |
| 2382 |
// and we need to push them in reverse order -- from sp |
| 2383 |
// upward (in increasing address order) -- with args filled |
| 2384 |
// in with `undefined` if fewer than the number of formals. |
| 2385 |
|
| 2386 |
// Push args: newTarget if constructing, extra undef's added |
| 2387 |
// if underflow, then original args, and `callee` if |
| 2388 |
// native. Replace `this` if constructing. |
| 2389 |
if (flags.isConstructing()) { |
| 2390 |
PUSH(origArgs[0]); |
| 2391 |
origArgs++; |
| 2392 |
} |
| 2393 |
for (uint32_t i = 0; i < undefArgs; i++) { |
| 2394 |
PUSH(StackVal(UndefinedValue())); |
| 2395 |
} |
| 2396 |
for (uint32_t i = 0; i < argc + 1 + isNative; i++) { |
| 2397 |
PUSH(origArgs[i]); |
| 2398 |
} |
| 2399 |
if (flags.isConstructing() && !isNative) { |
| 2400 |
sp[0] = StackVal(thisVal); |
| 2401 |
} |
| 2402 |
Value* args = reinterpret_cast<Value*>(sp); |
| 2403 |
|
| 2404 |
if (isNative) { |
| 2405 |
PUSHNATIVE(StackValNative(argc)); |
| 2406 |
PUSHNATIVE( |
| 2407 |
StackValNative(MakeFrameDescriptor(FrameType::BaselineStub))); |
| 2408 |
|
| 2409 |
// We *also* need an exit frame (the native baseline |
| 2410 |
// execution would invoke a trampoline here). |
| 2411 |
StackVal* trampolinePrevFP = ctx.stack.fp; |
| 2412 |
PUSHNATIVE(StackValNative(nullptr)); // fake return address. |
| 2413 |
PUSHNATIVE(StackValNative(ctx.stack.fp)); |
| 2414 |
ctx.stack.fp = sp; |
| 2415 |
PUSHNATIVE(StackValNative( |
| 2416 |
uint32_t(flags.isConstructing() ? ExitFrameType::ConstructNative |
| 2417 |
: ExitFrameType::CallNative))); |
| 2418 |
cx.getCx()->activation()->asJit()->setJSExitFP( |
| 2419 |
reinterpret_cast<uint8_t*>(ctx.stack.fp)); |
| 2420 |
cx.getCx()->portableBaselineStack().top = |
| 2421 |
reinterpret_cast<void*>(sp); |
| 2422 |
|
| 2423 |
JSNative native = ignoresRv |
| 2424 |
? callee->jitInfo()->ignoresReturnValueMethod |
| 2425 |
: callee->native(); |
| 2426 |
bool success = native(cx, argc, args); |
| 2427 |
|
| 2428 |
ctx.stack.fp = trampolinePrevFP; |
| 2429 |
POPNNATIVE(4); |
| 2430 |
|
| 2431 |
if (!success) { |
| 2432 |
ctx.error = PBIResult::Error; |
| 2433 |
return IC_ERROR_SENTINEL(); |
| 2434 |
} |
| 2435 |
retValue = args[0].asRawBits(); |
| 2436 |
} else { |
| 2437 |
TRACE_PRINTF("pushing callee: %p\n", callee); |
| 2438 |
PUSHNATIVE( |
| 2439 |
StackValNative(CalleeToToken(callee, flags.isConstructing()))); |
| 2440 |
|
| 2441 |
PUSHNATIVE(StackValNative( |
| 2442 |
MakeFrameDescriptorForJitCall(FrameType::BaselineStub, argc))); |
| 2443 |
|
| 2444 |
JSScript* script = callee->nonLazyScript(); |
| 2445 |
jsbytecode* pc = script->code(); |
| 2446 |
ImmutableScriptData* isd = script->immutableScriptData(); |
| 2447 |
PBIResult result; |
| 2448 |
Value ret; |
| 2449 |
result = PortableBaselineInterpret<false, kHybridICsInterp>( |
| 2450 |
cx, ctx.state, ctx.stack, sp, |
| 2451 |
/* envChain = */ nullptr, &ret, pc, isd, nullptr, nullptr, |
| 2452 |
nullptr, PBIResult::Ok); |
| 2453 |
if (result != PBIResult::Ok) { |
| 2454 |
ctx.error = result; |
| 2455 |
return IC_ERROR_SENTINEL(); |
| 2456 |
} |
| 2457 |
if (flags.isConstructing() && !ret.isObject()) { |
| 2458 |
ret = args[0]; |
| 2459 |
} |
| 2460 |
retValue = ret.asRawBits(); |
| 2461 |
} |
| 2462 |
} |
| 2463 |
|
| 2464 |
PREDICT_RETURN(); |
| 2465 |
DISPATCH_CACHEOP(); |
| 2466 |
} |
| 2467 |
|
| 2468 |
CACHEOP_CASE(CallScriptedGetterResult) |
| 2469 |
CACHEOP_CASE_FALLTHROUGH(CallScriptedSetter) { |
| 2470 |
bool isSetter = cacheop == CacheOp::CallScriptedSetter; |
| 2471 |
ObjOperandId receiverId = cacheIRReader.objOperandId(); |
| 2472 |
uint32_t getterSetterOffset = cacheIRReader.stubOffset(); |
| 2473 |
ValOperandId rhsId = |
| 2474 |
isSetter ? cacheIRReader.valOperandId() : ValOperandId(); |
| 2475 |
bool sameRealm = cacheIRReader.readBool(); |
| 2476 |
uint32_t nargsAndFlagsOffset = cacheIRReader.stubOffset(); |
| 2477 |
(void)nargsAndFlagsOffset; |
| 2478 |
|
| 2479 |
Value receiver = isSetter ? ObjectValue(*reinterpret_cast<JSObject*>( |
| 2480 |
READ_REG(receiverId.id()))) |
| 2481 |
: READ_VALUE_REG(receiverId.id()); |
| 2482 |
JSFunction* callee = reinterpret_cast<JSFunction*>( |
| 2483 |
stubInfo->getStubRawWord(cstub, getterSetterOffset)); |
| 2484 |
Value rhs = isSetter ? READ_VALUE_REG(rhsId.id()) : UndefinedValue(); |
| 2485 |
|
| 2486 |
if (!sameRealm) { |
| 2487 |
FAIL_IC(); |
| 2488 |
} |
| 2489 |
|
| 2490 |
if (!callee->hasBaseScript() || !callee->baseScript()->hasBytecode() || |
| 2491 |
!callee->baseScript()->hasJitScript()) { |
| 2492 |
FAIL_IC(); |
| 2493 |
} |
| 2494 |
|
| 2495 |
// For now, fail any arg-underflow case. |
| 2496 |
if (callee->nargs() != isSetter ? 1 : 0) { |
| 2497 |
TRACE_PRINTF( |
| 2498 |
"failing: getter/setter does not have exactly 0/1 arg (has %d " |
| 2499 |
"instead)\n", |
| 2500 |
int(callee->nargs())); |
| 2501 |
FAIL_IC(); |
| 2502 |
} |
| 2503 |
|
| 2504 |
{ |
| 2505 |
PUSH_IC_FRAME(); |
| 2506 |
|
| 2507 |
if (!ctx.stack.check(sp, sizeof(StackVal) * 8)) { |
| 2508 |
ReportOverRecursed(ctx.frameMgr.cxForLocalUseOnly()); |
| 2509 |
ctx.error = PBIResult::Error; |
| 2510 |
return IC_ERROR_SENTINEL(); |
| 2511 |
} |
| 2512 |
|
| 2513 |
// This will not be an Exit frame but a BaselineStub frame, so |
| 2514 |
// replace the ExitFrameType with the ICStub pointer. |
| 2515 |
POPNNATIVE(1); |
| 2516 |
PUSHNATIVE(StackValNative(cstub)); |
| 2517 |
|
| 2518 |
if (isSetter) { |
| 2519 |
// Push arg: value. |
| 2520 |
PUSH(StackVal(rhs)); |
| 2521 |
} |
| 2522 |
TRACE_PRINTF("pushing receiver: %" PRIx64 "\n", receiver.asRawBits()); |
| 2523 |
// Push thisv: receiver. |
| 2524 |
PUSH(StackVal(receiver)); |
| 2525 |
|
| 2526 |
TRACE_PRINTF("pushing callee: %p\n", callee); |
| 2527 |
PUSHNATIVE(StackValNative( |
| 2528 |
CalleeToToken(callee, /* isConstructing = */ false))); |
| 2529 |
|
| 2530 |
PUSHNATIVE(StackValNative(MakeFrameDescriptorForJitCall( |
| 2531 |
FrameType::BaselineStub, /* argc = */ isSetter ? 1 : 0))); |
| 2532 |
|
| 2533 |
JSScript* script = callee->nonLazyScript(); |
| 2534 |
jsbytecode* pc = script->code(); |
| 2535 |
ImmutableScriptData* isd = script->immutableScriptData(); |
| 2536 |
PBIResult result; |
| 2537 |
Value ret; |
| 2538 |
result = PortableBaselineInterpret<false, kHybridICsInterp>( |
| 2539 |
cx, ctx.state, ctx.stack, sp, /* envChain = */ nullptr, &ret, pc, |
| 2540 |
isd, nullptr, nullptr, nullptr, PBIResult::Ok); |
| 2541 |
if (result != PBIResult::Ok) { |
| 2542 |
ctx.error = result; |
| 2543 |
return IC_ERROR_SENTINEL(); |
| 2544 |
} |
| 2545 |
retValue = ret.asRawBits(); |
| 2546 |
} |
| 2547 |
|
| 2548 |
PREDICT_RETURN(); |
| 2549 |
DISPATCH_CACHEOP(); |
| 2550 |
} |
| 2551 |
|
| 2552 |
CACHEOP_CASE(CallBoundScriptedFunction) { |
| 2553 |
ObjOperandId calleeId = cacheIRReader.objOperandId(); |
| 2554 |
ObjOperandId targetId = cacheIRReader.objOperandId(); |
| 2555 |
Int32OperandId argcId = cacheIRReader.int32OperandId(); |
| 2556 |
CallFlags flags = cacheIRReader.callFlags(); |
| 2557 |
uint32_t numBoundArgs = cacheIRReader.uint32Immediate(); |
| 2558 |
|
| 2559 |
BoundFunctionObject* boundFunc = |
| 2560 |
reinterpret_cast<BoundFunctionObject*>(READ_REG(calleeId.id())); |
| 2561 |
JSFunction* callee = &boundFunc->getTarget()->as<JSFunction>(); |
| 2562 |
uint32_t argc = uint32_t(READ_REG(argcId.id())); |
| 2563 |
(void)targetId; |
| 2564 |
|
| 2565 |
if (!callee->hasBaseScript() || !callee->baseScript()->hasBytecode() || |
| 2566 |
!callee->baseScript()->hasJitScript()) { |
| 2567 |
FAIL_IC(); |
| 2568 |
} |
| 2569 |
|
| 2570 |
// For now, fail any constructing or different-realm cases. |
| 2571 |
if (flags.isConstructing()) { |
| 2572 |
TRACE_PRINTF("failing: constructing\n"); |
| 2573 |
FAIL_IC(); |
| 2574 |
} |
| 2575 |
if (!flags.isSameRealm()) { |
| 2576 |
TRACE_PRINTF("failing: not same realm\n"); |
| 2577 |
FAIL_IC(); |
| 2578 |
} |
| 2579 |
// And support only "standard" arg formats. |
| 2580 |
if (flags.getArgFormat() != CallFlags::Standard) { |
| 2581 |
TRACE_PRINTF("failing: not standard arg format\n"); |
| 2582 |
FAIL_IC(); |
| 2583 |
} |
| 2584 |
|
| 2585 |
uint32_t totalArgs = numBoundArgs + argc; |
| 2586 |
|
| 2587 |
// For now, fail any arg-underflow case. |
| 2588 |
if (totalArgs < callee->nargs()) { |
| 2589 |
TRACE_PRINTF("failing: too few args\n"); |
| 2590 |
FAIL_IC(); |
| 2591 |
} |
| 2592 |
|
| 2593 |
StackVal* origArgs = ctx.sp(); |
| 2594 |
|
| 2595 |
{ |
| 2596 |
PUSH_IC_FRAME(); |
| 2597 |
|
| 2598 |
if (!ctx.stack.check(sp, sizeof(StackVal) * (totalArgs + 6))) { |
| 2599 |
ReportOverRecursed(ctx.frameMgr.cxForLocalUseOnly()); |
| 2600 |
ctx.error = PBIResult::Error; |
| 2601 |
return IC_ERROR_SENTINEL(); |
| 2602 |
} |
| 2603 |
|
| 2604 |
// This will not be an Exit frame but a BaselineStub frame, so |
| 2605 |
// replace the ExitFrameType with the ICStub pointer. |
| 2606 |
POPNNATIVE(1); |
| 2607 |
PUSHNATIVE(StackValNative(cstub)); |
| 2608 |
|
| 2609 |
// Push args. |
| 2610 |
for (uint32_t i = 0; i < argc; i++) { |
| 2611 |
PUSH(origArgs[i]); |
| 2612 |
} |
| 2613 |
// Push bound args. |
| 2614 |
for (uint32_t i = 0; i < numBoundArgs; i++) { |
| 2615 |
PUSH(StackVal(boundFunc->getBoundArg(numBoundArgs - 1 - i))); |
| 2616 |
} |
| 2617 |
// Push bound `this`. |
| 2618 |
PUSH(StackVal(boundFunc->getBoundThis())); |
| 2619 |
|
| 2620 |
TRACE_PRINTF("pushing callee: %p\n", callee); |
| 2621 |
PUSHNATIVE(StackValNative( |
| 2622 |
CalleeToToken(callee, /* isConstructing = */ false))); |
| 2623 |
|
| 2624 |
PUSHNATIVE(StackValNative(MakeFrameDescriptorForJitCall( |
| 2625 |
FrameType::BaselineStub, totalArgs))); |
| 2626 |
|
| 2627 |
JSScript* script = callee->nonLazyScript(); |
| 2628 |
jsbytecode* pc = script->code(); |
| 2629 |
ImmutableScriptData* isd = script->immutableScriptData(); |
| 2630 |
PBIResult result; |
| 2631 |
Value ret; |
| 2632 |
result = PortableBaselineInterpret<false, kHybridICsInterp>( |
| 2633 |
cx, ctx.state, ctx.stack, sp, /* envChain = */ nullptr, &ret, pc, |
| 2634 |
isd, nullptr, nullptr, nullptr, PBIResult::Ok); |
| 2635 |
if (result != PBIResult::Ok) { |
| 2636 |
ctx.error = result; |
| 2637 |
return IC_ERROR_SENTINEL(); |
| 2638 |
} |
| 2639 |
retValue = ret.asRawBits(); |
| 2640 |
} |
| 2641 |
|
| 2642 |
PREDICT_RETURN(); |
| 2643 |
DISPATCH_CACHEOP(); |
| 2644 |
} |
| 2645 |
|
| 2646 |
CACHEOP_CASE(MetaScriptedThisShape) { |
| 2647 |
uint32_t thisShapeOffset = cacheIRReader.stubOffset(); |
| 2648 |
// This op is only metadata for the Warp Transpiler and should be |
| 2649 |
// ignored. |
| 2650 |
(void)thisShapeOffset; |
| 2651 |
PREDICT_NEXT(CallScriptedFunction); |
| 2652 |
DISPATCH_CACHEOP(); |
| 2653 |
} |
| 2654 |
|
| 2655 |
CACHEOP_CASE(LoadFixedSlotResult) |
| 2656 |
CACHEOP_CASE_FALLTHROUGH(LoadFixedSlotTypedResult) { |
| 2657 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2658 |
uint32_t offsetOffset = cacheIRReader.stubOffset(); |
| 2659 |
if (cacheop == CacheOp::LoadFixedSlotTypedResult) { |
| 2660 |
// Type is unused here. |
| 2661 |
(void)cacheIRReader.valueType(); |
| 2662 |
} |
| 2663 |
uintptr_t offset = stubInfo->getStubRawInt32(cstub, offsetOffset); |
| 2664 |
NativeObject* nobj = |
| 2665 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 2666 |
Value* slot = reinterpret_cast<Value*>( |
| 2667 |
reinterpret_cast<uintptr_t>(nobj) + offset); |
| 2668 |
TRACE_PRINTF( |
| 2669 |
"LoadFixedSlotResult: obj %p offsetOffset %d offset %d slotPtr %p " |
| 2670 |
"slot %" PRIx64 "\n", |
| 2671 |
nobj, int(offsetOffset), int(offset), slot, slot->asRawBits()); |
| 2672 |
retValue = slot->asRawBits(); |
| 2673 |
PREDICT_RETURN(); |
| 2674 |
DISPATCH_CACHEOP(); |
| 2675 |
} |
| 2676 |
|
| 2677 |
CACHEOP_CASE(LoadDynamicSlotResult) { |
| 2678 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2679 |
uint32_t offsetOffset = cacheIRReader.stubOffset(); |
| 2680 |
uintptr_t offset = stubInfo->getStubRawInt32(cstub, offsetOffset); |
| 2681 |
NativeObject* nobj = |
| 2682 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 2683 |
HeapSlot* slots = nobj->getSlotsUnchecked(); |
| 2684 |
retValue = slots[offset / sizeof(Value)].get().asRawBits(); |
| 2685 |
PREDICT_RETURN(); |
| 2686 |
DISPATCH_CACHEOP(); |
| 2687 |
} |
| 2688 |
|
| 2689 |
CACHEOP_CASE(LoadDenseElementResult) { |
| 2690 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2691 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2692 |
NativeObject* nobj = |
| 2693 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 2694 |
ObjectElements* elems = nobj->getElementsHeader(); |
| 2695 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 2696 |
if (index < 0 || uint32_t(index) >= nobj->getDenseInitializedLength()) { |
| 2697 |
FAIL_IC(); |
| 2698 |
} |
| 2699 |
HeapSlot* slot = &elems->elements()[index]; |
| 2700 |
Value val = slot->get(); |
| 2701 |
if (val.isMagic()) { |
| 2702 |
FAIL_IC(); |
| 2703 |
} |
| 2704 |
retValue = val.asRawBits(); |
| 2705 |
PREDICT_RETURN(); |
| 2706 |
DISPATCH_CACHEOP(); |
| 2707 |
} |
| 2708 |
|
| 2709 |
CACHEOP_CASE(LoadDenseElementHoleResult) { |
| 2710 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2711 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2712 |
NativeObject* nobj = |
| 2713 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 2714 |
ObjectElements* elems = nobj->getElementsHeader(); |
| 2715 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 2716 |
if (index < 0 || uint32_t(index) >= nobj->getDenseInitializedLength()) { |
| 2717 |
FAIL_IC(); |
| 2718 |
} |
| 2719 |
HeapSlot* slot = &elems->elements()[index]; |
| 2720 |
Value val = slot->get(); |
| 2721 |
if (val.isMagic()) { |
| 2722 |
val.setUndefined(); |
| 2723 |
} |
| 2724 |
retValue = val.asRawBits(); |
| 2725 |
PREDICT_RETURN(); |
| 2726 |
DISPATCH_CACHEOP(); |
| 2727 |
} |
| 2728 |
|
| 2729 |
CACHEOP_CASE(LoadDenseElementExistsResult) { |
| 2730 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2731 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2732 |
NativeObject* nobj = |
| 2733 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 2734 |
ObjectElements* elems = nobj->getElementsHeader(); |
| 2735 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 2736 |
if (index < 0 || uint32_t(index) >= nobj->getDenseInitializedLength()) { |
| 2737 |
FAIL_IC(); |
| 2738 |
} |
| 2739 |
HeapSlot* slot = &elems->elements()[index]; |
| 2740 |
Value val = slot->get(); |
| 2741 |
if (val.isMagic()) { |
| 2742 |
FAIL_IC(); |
| 2743 |
} |
| 2744 |
retValue = BooleanValue(true).asRawBits(); |
| 2745 |
PREDICT_RETURN(); |
| 2746 |
DISPATCH_CACHEOP(); |
| 2747 |
} |
| 2748 |
|
| 2749 |
CACHEOP_CASE(LoadDenseElementHoleExistsResult) { |
| 2750 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2751 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2752 |
NativeObject* nobj = |
| 2753 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 2754 |
ObjectElements* elems = nobj->getElementsHeader(); |
| 2755 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 2756 |
if (index < 0 || uint32_t(index) >= nobj->getDenseInitializedLength()) { |
| 2757 |
retValue = BooleanValue(false).asRawBits(); |
| 2758 |
} else { |
| 2759 |
HeapSlot* slot = &elems->elements()[index]; |
| 2760 |
Value val = slot->get(); |
| 2761 |
retValue = BooleanValue(!val.isMagic()).asRawBits(); |
| 2762 |
} |
| 2763 |
PREDICT_RETURN(); |
| 2764 |
DISPATCH_CACHEOP(); |
| 2765 |
} |
| 2766 |
|
| 2767 |
CACHEOP_CASE(GuardIndexIsNotDenseElement) { |
| 2768 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2769 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2770 |
NativeObject* nobj = |
| 2771 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 2772 |
ObjectElements* elems = nobj->getElementsHeader(); |
| 2773 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 2774 |
if (index < 0 || uint32_t(index) >= nobj->getDenseInitializedLength()) { |
| 2775 |
// OK -- not in the dense index range. |
| 2776 |
} else { |
| 2777 |
HeapSlot* slot = &elems->elements()[index]; |
| 2778 |
Value val = slot->get(); |
| 2779 |
if (!val.isMagic()) { |
| 2780 |
// Not a magic value -- not the hole, so guard fails. |
| 2781 |
FAIL_IC(); |
| 2782 |
} |
| 2783 |
} |
| 2784 |
DISPATCH_CACHEOP(); |
| 2785 |
} |
| 2786 |
|
| 2787 |
CACHEOP_CASE(LoadInt32ArrayLengthResult) { |
| 2788 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2789 |
ArrayObject* aobj = |
| 2790 |
reinterpret_cast<ArrayObject*>(READ_REG(objId.id())); |
| 2791 |
uint32_t length = aobj->length(); |
| 2792 |
if (length > uint32_t(INT32_MAX)) { |
| 2793 |
FAIL_IC(); |
| 2794 |
} |
| 2795 |
retValue = Int32Value(length).asRawBits(); |
| 2796 |
PREDICT_RETURN(); |
| 2797 |
DISPATCH_CACHEOP(); |
| 2798 |
} |
| 2799 |
|
| 2800 |
CACHEOP_CASE(LoadInt32ArrayLength) { |
| 2801 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2802 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 2803 |
BOUNDSCHECK(resultId); |
| 2804 |
ArrayObject* aobj = |
| 2805 |
reinterpret_cast<ArrayObject*>(READ_REG(objId.id())); |
| 2806 |
uint32_t length = aobj->length(); |
| 2807 |
if (length > uint32_t(INT32_MAX)) { |
| 2808 |
FAIL_IC(); |
| 2809 |
} |
| 2810 |
WRITE_REG(resultId.id(), length, INT32); |
| 2811 |
DISPATCH_CACHEOP(); |
| 2812 |
} |
| 2813 |
|
| 2814 |
CACHEOP_CASE(LoadArrayBufferByteLengthInt32Result) { |
| 2815 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2816 |
ArrayBufferObject* abo = |
| 2817 |
reinterpret_cast<ArrayBufferObject*>(READ_REG(objId.id())); |
| 2818 |
size_t len = abo->byteLength(); |
| 2819 |
if (len > size_t(INT32_MAX)) { |
| 2820 |
FAIL_IC(); |
| 2821 |
} |
| 2822 |
retValue = Int32Value(int32_t(len)).asRawBits(); |
| 2823 |
PREDICT_RETURN(); |
| 2824 |
DISPATCH_CACHEOP(); |
| 2825 |
} |
| 2826 |
|
| 2827 |
CACHEOP_CASE(LoadArrayBufferByteLengthDoubleResult) { |
| 2828 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2829 |
ArrayBufferObject* abo = |
| 2830 |
reinterpret_cast<ArrayBufferObject*>(READ_REG(objId.id())); |
| 2831 |
size_t len = abo->byteLength(); |
| 2832 |
retValue = DoubleValue(double(len)).asRawBits(); |
| 2833 |
PREDICT_RETURN(); |
| 2834 |
DISPATCH_CACHEOP(); |
| 2835 |
} |
| 2836 |
|
| 2837 |
CACHEOP_CASE(LoadArrayBufferViewLengthInt32Result) { |
| 2838 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2839 |
ArrayBufferViewObject* abvo = |
| 2840 |
reinterpret_cast<ArrayBufferViewObject*>(READ_REG(objId.id())); |
| 2841 |
size_t len = size_t( |
| 2842 |
abvo->getFixedSlot(ArrayBufferViewObject::LENGTH_SLOT).toPrivate()); |
| 2843 |
if (len > size_t(INT32_MAX)) { |
| 2844 |
FAIL_IC(); |
| 2845 |
} |
| 2846 |
retValue = Int32Value(int32_t(len)).asRawBits(); |
| 2847 |
PREDICT_RETURN(); |
| 2848 |
DISPATCH_CACHEOP(); |
| 2849 |
} |
| 2850 |
|
| 2851 |
CACHEOP_CASE(LoadArrayBufferViewLengthDoubleResult) { |
| 2852 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2853 |
ArrayBufferViewObject* abvo = |
| 2854 |
reinterpret_cast<ArrayBufferViewObject*>(READ_REG(objId.id())); |
| 2855 |
size_t len = size_t( |
| 2856 |
abvo->getFixedSlot(ArrayBufferViewObject::LENGTH_SLOT).toPrivate()); |
| 2857 |
retValue = DoubleValue(double(len)).asRawBits(); |
| 2858 |
PREDICT_RETURN(); |
| 2859 |
DISPATCH_CACHEOP(); |
| 2860 |
} |
| 2861 |
|
| 2862 |
CACHEOP_CASE(LoadArgumentsObjectArgResult) { |
| 2863 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 2864 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2865 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 2866 |
uint32_t index = uint32_t(READ_REG(indexId.id())); |
| 2867 |
ArgumentsObject* args = &obj->as<ArgumentsObject>(); |
| 2868 |
if (index >= args->initialLength() || args->hasOverriddenElement()) { |
| 2869 |
FAIL_IC(); |
| 2870 |
} |
| 2871 |
if (args->argIsForwarded(index)) { |
| 2872 |
FAIL_IC(); |
| 2873 |
} |
| 2874 |
retValue = args->arg(index).asRawBits(); |
| 2875 |
DISPATCH_CACHEOP(); |
| 2876 |
} |
| 2877 |
|
| 2878 |
CACHEOP_CASE(LinearizeForCharAccess) { |
| 2879 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 2880 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2881 |
StringOperandId resultId = cacheIRReader.stringOperandId(); |
| 2882 |
BOUNDSCHECK(resultId); |
| 2883 |
JSString* str = reinterpret_cast<JSLinearString*>(READ_REG(strId.id())); |
| 2884 |
(void)indexId; |
| 2885 |
|
| 2886 |
WRITE_REG(resultId.id(), reinterpret_cast<uintptr_t>(str), STRING); |
| 2887 |
if (str->isRope()) { |
| 2888 |
PUSH_IC_FRAME(); |
| 2889 |
JSLinearString* result = LinearizeForCharAccess(cx, str); |
| 2890 |
if (!result) { |
| 2891 |
ctx.error = PBIResult::Error; |
| 2892 |
return IC_ERROR_SENTINEL(); |
| 2893 |
} |
| 2894 |
WRITE_REG(resultId.id(), reinterpret_cast<uintptr_t>(result), STRING); |
| 2895 |
} |
| 2896 |
PREDICT_NEXT(LoadStringCharResult); |
| 2897 |
DISPATCH_CACHEOP(); |
| 2898 |
} |
| 2899 |
|
| 2900 |
CACHEOP_CASE(LinearizeForCodePointAccess) { |
| 2901 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 2902 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2903 |
StringOperandId resultId = cacheIRReader.stringOperandId(); |
| 2904 |
BOUNDSCHECK(resultId); |
| 2905 |
JSString* str = reinterpret_cast<JSLinearString*>(READ_REG(strId.id())); |
| 2906 |
(void)indexId; |
| 2907 |
|
| 2908 |
WRITE_REG(resultId.id(), reinterpret_cast<uintptr_t>(str), STRING); |
| 2909 |
if (str->isRope()) { |
| 2910 |
PUSH_IC_FRAME(); |
| 2911 |
JSLinearString* result = LinearizeForCharAccess(cx, str); |
| 2912 |
if (!result) { |
| 2913 |
ctx.error = PBIResult::Error; |
| 2914 |
return IC_ERROR_SENTINEL(); |
| 2915 |
} |
| 2916 |
WRITE_REG(resultId.id(), reinterpret_cast<uintptr_t>(result), STRING); |
| 2917 |
} |
| 2918 |
PREDICT_NEXT(LoadStringCodePointResult); |
| 2919 |
DISPATCH_CACHEOP(); |
| 2920 |
} |
| 2921 |
|
| 2922 |
CACHEOP_CASE(LoadStringCharResult) |
| 2923 |
CACHEOP_CASE_FALLTHROUGH(LoadStringAtResult) { |
| 2924 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 2925 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2926 |
bool handleOOB = cacheIRReader.readBool(); |
| 2927 |
|
| 2928 |
JSString* str = reinterpret_cast<JSLinearString*>(READ_REG(strId.id())); |
| 2929 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 2930 |
JSString* result = nullptr; |
| 2931 |
if (index < 0 || size_t(index) >= str->length()) { |
| 2932 |
if (handleOOB) { |
| 2933 |
if (cacheop == CacheOp::LoadStringCharResult) { |
| 2934 |
// Return an empty string. |
| 2935 |
retValue = |
| 2936 |
StringValue(ctx.frameMgr.cxForLocalUseOnly()->names().empty_) |
| 2937 |
.asRawBits(); |
| 2938 |
} else { |
| 2939 |
// Return `undefined`. |
| 2940 |
retValue = UndefinedValue().asRawBits(); |
| 2941 |
} |
| 2942 |
} else { |
| 2943 |
FAIL_IC(); |
| 2944 |
} |
| 2945 |
} else { |
| 2946 |
char16_t c; |
| 2947 |
// Guaranteed to always work because this CacheIR op is |
| 2948 |
// always preceded by LinearizeForCharAccess. |
| 2949 |
MOZ_ALWAYS_TRUE(str->getChar(/* cx = */ nullptr, index, &c)); |
| 2950 |
StaticStrings& sstr = |
| 2951 |
ctx.frameMgr.cxForLocalUseOnly()->staticStrings(); |
| 2952 |
if (sstr.hasUnit(c)) { |
| 2953 |
result = sstr.getUnit(c); |
| 2954 |
} else { |
| 2955 |
PUSH_IC_FRAME(); |
| 2956 |
result = StringFromCharCode(cx, c); |
| 2957 |
if (!result) { |
| 2958 |
ctx.error = PBIResult::Error; |
| 2959 |
return IC_ERROR_SENTINEL(); |
| 2960 |
} |
| 2961 |
} |
| 2962 |
retValue = StringValue(result).asRawBits(); |
| 2963 |
} |
| 2964 |
PREDICT_RETURN(); |
| 2965 |
DISPATCH_CACHEOP(); |
| 2966 |
} |
| 2967 |
|
| 2968 |
CACHEOP_CASE(LoadStringCharCodeResult) { |
| 2969 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 2970 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2971 |
bool handleOOB = cacheIRReader.readBool(); |
| 2972 |
|
| 2973 |
JSString* str = reinterpret_cast<JSLinearString*>(READ_REG(strId.id())); |
| 2974 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 2975 |
Value result; |
| 2976 |
if (index < 0 || size_t(index) >= str->length()) { |
| 2977 |
if (handleOOB) { |
| 2978 |
// Return NaN. |
| 2979 |
result = JS::NaNValue(); |
| 2980 |
} else { |
| 2981 |
FAIL_IC(); |
| 2982 |
} |
| 2983 |
} else { |
| 2984 |
char16_t c; |
| 2985 |
// Guaranteed to always work because this CacheIR op is |
| 2986 |
// always preceded by LinearizeForCharAccess. |
| 2987 |
MOZ_ALWAYS_TRUE(str->getChar(/* cx = */ nullptr, index, &c)); |
| 2988 |
result = Int32Value(c); |
| 2989 |
} |
| 2990 |
retValue = result.asRawBits(); |
| 2991 |
PREDICT_RETURN(); |
| 2992 |
DISPATCH_CACHEOP(); |
| 2993 |
} |
| 2994 |
|
| 2995 |
CACHEOP_CASE(LoadStringCodePointResult) { |
| 2996 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 2997 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 2998 |
bool handleOOB = cacheIRReader.readBool(); |
| 2999 |
|
| 3000 |
JSString* str = reinterpret_cast<JSLinearString*>(READ_REG(strId.id())); |
| 3001 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 3002 |
Value result; |
| 3003 |
if (index < 0 || size_t(index) >= str->length()) { |
| 3004 |
if (handleOOB) { |
| 3005 |
// Return undefined. |
| 3006 |
result = UndefinedValue(); |
| 3007 |
} else { |
| 3008 |
FAIL_IC(); |
| 3009 |
} |
| 3010 |
} else { |
| 3011 |
char32_t c; |
| 3012 |
// Guaranteed to be always work because this CacheIR op is |
| 3013 |
// always preceded by LinearizeForCharAccess. |
| 3014 |
MOZ_ALWAYS_TRUE(str->getCodePoint(/* cx = */ nullptr, index, &c)); |
| 3015 |
result = Int32Value(c); |
| 3016 |
} |
| 3017 |
retValue = result.asRawBits(); |
| 3018 |
PREDICT_RETURN(); |
| 3019 |
DISPATCH_CACHEOP(); |
| 3020 |
} |
| 3021 |
|
| 3022 |
CACHEOP_CASE(LoadStringLengthResult) { |
| 3023 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 3024 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 3025 |
size_t length = str->length(); |
| 3026 |
if (length > size_t(INT32_MAX)) { |
| 3027 |
FAIL_IC(); |
| 3028 |
} |
| 3029 |
retValue = Int32Value(length).asRawBits(); |
| 3030 |
PREDICT_RETURN(); |
| 3031 |
DISPATCH_CACHEOP(); |
| 3032 |
} |
| 3033 |
|
| 3034 |
CACHEOP_CASE(LoadObjectResult) { |
| 3035 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 3036 |
retValue = |
| 3037 |
ObjectValue(*reinterpret_cast<JSObject*>(READ_REG(objId.id()))) |
| 3038 |
.asRawBits(); |
| 3039 |
PREDICT_RETURN(); |
| 3040 |
DISPATCH_CACHEOP(); |
| 3041 |
} |
| 3042 |
|
| 3043 |
CACHEOP_CASE(LoadStringResult) { |
| 3044 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 3045 |
retValue = |
| 3046 |
StringValue(reinterpret_cast<JSString*>(READ_REG(strId.id()))) |
| 3047 |
.asRawBits(); |
| 3048 |
PREDICT_RETURN(); |
| 3049 |
DISPATCH_CACHEOP(); |
| 3050 |
} |
| 3051 |
|
| 3052 |
CACHEOP_CASE(LoadSymbolResult) { |
| 3053 |
SymbolOperandId symId = cacheIRReader.symbolOperandId(); |
| 3054 |
retValue = |
| 3055 |
SymbolValue(reinterpret_cast<JS::Symbol*>(READ_REG(symId.id()))) |
| 3056 |
.asRawBits(); |
| 3057 |
PREDICT_RETURN(); |
| 3058 |
DISPATCH_CACHEOP(); |
| 3059 |
} |
| 3060 |
|
| 3061 |
CACHEOP_CASE(LoadInt32Result) { |
| 3062 |
Int32OperandId valId = cacheIRReader.int32OperandId(); |
| 3063 |
retValue = Int32Value(READ_REG(valId.id())).asRawBits(); |
| 3064 |
PREDICT_RETURN(); |
| 3065 |
DISPATCH_CACHEOP(); |
| 3066 |
} |
| 3067 |
|
| 3068 |
CACHEOP_CASE(LoadDoubleResult) { |
| 3069 |
NumberOperandId valId = cacheIRReader.numberOperandId(); |
| 3070 |
Value val = READ_VALUE_REG(valId.id()); |
| 3071 |
if (val.isInt32()) { |
| 3072 |
val = DoubleValue(val.toInt32()); |
| 3073 |
} |
| 3074 |
retValue = val.asRawBits(); |
| 3075 |
PREDICT_RETURN(); |
| 3076 |
DISPATCH_CACHEOP(); |
| 3077 |
} |
| 3078 |
|
| 3079 |
CACHEOP_CASE(LoadBigIntResult) { |
| 3080 |
BigIntOperandId valId = cacheIRReader.bigIntOperandId(); |
| 3081 |
retValue = |
| 3082 |
BigIntValue(reinterpret_cast<JS::BigInt*>(READ_REG(valId.id()))) |
| 3083 |
.asRawBits(); |
| 3084 |
PREDICT_RETURN(); |
| 3085 |
DISPATCH_CACHEOP(); |
| 3086 |
} |
| 3087 |
|
| 3088 |
CACHEOP_CASE(LoadBooleanResult) { |
| 3089 |
bool val = cacheIRReader.readBool(); |
| 3090 |
retValue = BooleanValue(val).asRawBits(); |
| 3091 |
PREDICT_RETURN(); |
| 3092 |
DISPATCH_CACHEOP(); |
| 3093 |
} |
| 3094 |
|
| 3095 |
CACHEOP_CASE(LoadInt32Constant) { |
| 3096 |
uint32_t valOffset = cacheIRReader.stubOffset(); |
| 3097 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 3098 |
BOUNDSCHECK(resultId); |
| 3099 |
uint32_t value = stubInfo->getStubRawInt32(cstub, valOffset); |
| 3100 |
WRITE_REG(resultId.id(), value, INT32); |
| 3101 |
DISPATCH_CACHEOP(); |
| 3102 |
} |
| 3103 |
|
| 3104 |
CACHEOP_CASE(LoadConstantStringResult) { |
| 3105 |
uint32_t strOffset = cacheIRReader.stubOffset(); |
| 3106 |
JSString* str = reinterpret_cast<JSString*>( |
| 3107 |
stubInfo->getStubRawWord(cstub, strOffset)); |
| 3108 |
retValue = StringValue(str).asRawBits(); |
| 3109 |
PREDICT_RETURN(); |
| 3110 |
DISPATCH_CACHEOP(); |
| 3111 |
} |
| 3112 |
|
| 3113 |
CACHEOP_CASE(DoubleAddResult) { |
| 3114 |
NumberOperandId lhsId = cacheIRReader.numberOperandId(); |
| 3115 |
NumberOperandId rhsId = cacheIRReader.numberOperandId(); |
| 3116 |
Value lhs = READ_VALUE_REG(lhsId.id()); |
| 3117 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 3118 |
retValue = DoubleValue(lhs.toNumber() + rhs.toNumber()).asRawBits(); |
| 3119 |
PREDICT_RETURN(); |
| 3120 |
DISPATCH_CACHEOP(); |
| 3121 |
} |
| 3122 |
|
| 3123 |
CACHEOP_CASE(DoubleSubResult) { |
| 3124 |
NumberOperandId lhsId = cacheIRReader.numberOperandId(); |
| 3125 |
NumberOperandId rhsId = cacheIRReader.numberOperandId(); |
| 3126 |
Value lhs = READ_VALUE_REG(lhsId.id()); |
| 3127 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 3128 |
retValue = DoubleValue(lhs.toNumber() - rhs.toNumber()).asRawBits(); |
| 3129 |
PREDICT_RETURN(); |
| 3130 |
DISPATCH_CACHEOP(); |
| 3131 |
} |
| 3132 |
|
| 3133 |
CACHEOP_CASE(DoubleMulResult) { |
| 3134 |
NumberOperandId lhsId = cacheIRReader.numberOperandId(); |
| 3135 |
NumberOperandId rhsId = cacheIRReader.numberOperandId(); |
| 3136 |
Value lhs = READ_VALUE_REG(lhsId.id()); |
| 3137 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 3138 |
retValue = DoubleValue(lhs.toNumber() * rhs.toNumber()).asRawBits(); |
| 3139 |
PREDICT_RETURN(); |
| 3140 |
DISPATCH_CACHEOP(); |
| 3141 |
} |
| 3142 |
|
| 3143 |
CACHEOP_CASE(DoubleDivResult) { |
| 3144 |
NumberOperandId lhsId = cacheIRReader.numberOperandId(); |
| 3145 |
NumberOperandId rhsId = cacheIRReader.numberOperandId(); |
| 3146 |
Value lhs = READ_VALUE_REG(lhsId.id()); |
| 3147 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 3148 |
retValue = |
| 3149 |
DoubleValue(NumberDiv(lhs.toNumber(), rhs.toNumber())).asRawBits(); |
| 3150 |
PREDICT_RETURN(); |
| 3151 |
DISPATCH_CACHEOP(); |
| 3152 |
} |
| 3153 |
|
| 3154 |
CACHEOP_CASE(DoubleModResult) { |
| 3155 |
NumberOperandId lhsId = cacheIRReader.numberOperandId(); |
| 3156 |
NumberOperandId rhsId = cacheIRReader.numberOperandId(); |
| 3157 |
Value lhs = READ_VALUE_REG(lhsId.id()); |
| 3158 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 3159 |
retValue = |
| 3160 |
DoubleValue(NumberMod(lhs.toNumber(), rhs.toNumber())).asRawBits(); |
| 3161 |
PREDICT_RETURN(); |
| 3162 |
DISPATCH_CACHEOP(); |
| 3163 |
} |
| 3164 |
|
| 3165 |
CACHEOP_CASE(DoublePowResult) { |
| 3166 |
NumberOperandId lhsId = cacheIRReader.numberOperandId(); |
| 3167 |
NumberOperandId rhsId = cacheIRReader.numberOperandId(); |
| 3168 |
Value lhs = READ_VALUE_REG(lhsId.id()); |
| 3169 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 3170 |
retValue = |
| 3171 |
DoubleValue(ecmaPow(lhs.toNumber(), rhs.toNumber())).asRawBits(); |
| 3172 |
PREDICT_RETURN(); |
| 3173 |
DISPATCH_CACHEOP(); |
| 3174 |
} |
| 3175 |
|
| 3176 |
#define INT32_OP(name, op, extra_check) \ |
| 3177 |
CACHEOP_CASE(Int32##name##Result) { \ |
| 3178 |
Int32OperandId lhsId = cacheIRReader.int32OperandId(); \ |
| 3179 |
Int32OperandId rhsId = cacheIRReader.int32OperandId(); \ |
| 3180 |
int64_t lhs = int64_t(int32_t(READ_REG(lhsId.id()))); \ |
| 3181 |
int64_t rhs = int64_t(int32_t(READ_REG(rhsId.id()))); \ |
| 3182 |
extra_check; \ |
| 3183 |
int64_t result = lhs op rhs; \ |
| 3184 |
if (result < INT32_MIN || result > INT32_MAX) { \ |
| 3185 |
FAIL_IC(); \ |
| 3186 |
} \ |
| 3187 |
retValue = Int32Value(int32_t(result)).asRawBits(); \ |
| 3188 |
PREDICT_RETURN(); \ |
| 3189 |
DISPATCH_CACHEOP(); \ |
| 3190 |
} |
| 3191 |
|
| 3192 |
// clang-format off |
| 3193 |
INT32_OP(Add, +, {}); |
| 3194 |
INT32_OP(Sub, -, {}); |
| 3195 |
// clang-format on |
| 3196 |
INT32_OP(Mul, *, { |
| 3197 |
if (rhs * lhs == 0 && ((rhs < 0) ^ (lhs < 0))) { |
| 3198 |
FAIL_IC(); |
| 3199 |
} |
| 3200 |
}); |
| 3201 |
INT32_OP(Div, /, { |
| 3202 |
if (rhs == 0 || (lhs == INT32_MIN && rhs == -1)) { |
| 3203 |
FAIL_IC(); |
| 3204 |
} |
| 3205 |
if (lhs == 0 && rhs < 0) { |
| 3206 |
FAIL_IC(); |
| 3207 |
} |
| 3208 |
if (lhs % rhs != 0) { |
| 3209 |
FAIL_IC(); |
| 3210 |
} |
| 3211 |
}); |
| 3212 |
INT32_OP(Mod, %, { |
| 3213 |
if (rhs == 0 || (lhs == INT32_MIN && rhs == -1)) { |
| 3214 |
FAIL_IC(); |
| 3215 |
} |
| 3216 |
if (lhs % rhs == 0 && lhs < 0) { |
| 3217 |
FAIL_IC(); |
| 3218 |
} |
| 3219 |
}); |
| 3220 |
// clang-format off |
| 3221 |
INT32_OP(BitOr, |, {}); |
| 3222 |
INT32_OP(BitXor, ^, {}); |
| 3223 |
INT32_OP(BitAnd, &, {}); |
| 3224 |
// clang-format on |
| 3225 |
|
| 3226 |
CACHEOP_CASE(Int32PowResult) { |
| 3227 |
Int32OperandId lhsId = cacheIRReader.int32OperandId(); |
| 3228 |
Int32OperandId rhsId = cacheIRReader.int32OperandId(); |
| 3229 |
int64_t lhs = int64_t(int32_t(READ_REG(lhsId.id()))); |
| 3230 |
uint64_t rhs = uint64_t(int32_t(READ_REG(rhsId.id()))); |
| 3231 |
int64_t result; |
| 3232 |
|
| 3233 |
if (lhs == 1) { |
| 3234 |
result = 1; |
| 3235 |
} else if (rhs >= uint64_t(INT64_MIN)) { |
| 3236 |
FAIL_IC(); |
| 3237 |
} else { |
| 3238 |
result = 1; |
| 3239 |
int64_t runningSquare = lhs; |
| 3240 |
while (rhs) { |
| 3241 |
if (rhs & 1) { |
| 3242 |
result *= runningSquare; |
| 3243 |
if (result > int64_t(INT32_MAX)) { |
| 3244 |
FAIL_IC(); |
| 3245 |
} |
| 3246 |
} |
| 3247 |
rhs >>= 1; |
| 3248 |
if (rhs == 0) { |
| 3249 |
break; |
| 3250 |
} |
| 3251 |
runningSquare *= runningSquare; |
| 3252 |
if (runningSquare > int64_t(INT32_MAX)) { |
| 3253 |
FAIL_IC(); |
| 3254 |
} |
| 3255 |
} |
| 3256 |
} |
| 3257 |
|
| 3258 |
retValue = Int32Value(int32_t(result)).asRawBits(); |
| 3259 |
PREDICT_RETURN(); |
| 3260 |
DISPATCH_CACHEOP(); |
| 3261 |
} |
| 3262 |
|
| 3263 |
CACHEOP_CASE(Int32IncResult) { |
| 3264 |
Int32OperandId inputId = cacheIRReader.int32OperandId(); |
| 3265 |
int64_t value = int64_t(int32_t(READ_REG(inputId.id()))); |
| 3266 |
value++; |
| 3267 |
if (value > INT32_MAX) { |
| 3268 |
FAIL_IC(); |
| 3269 |
} |
| 3270 |
retValue = Int32Value(int32_t(value)).asRawBits(); |
| 3271 |
PREDICT_RETURN(); |
| 3272 |
DISPATCH_CACHEOP(); |
| 3273 |
} |
| 3274 |
|
| 3275 |
CACHEOP_CASE(Int32LeftShiftResult) { |
| 3276 |
Int32OperandId lhsId = cacheIRReader.int32OperandId(); |
| 3277 |
Int32OperandId rhsId = cacheIRReader.int32OperandId(); |
| 3278 |
int32_t lhs = int32_t(READ_REG(lhsId.id())); |
| 3279 |
int32_t rhs = int32_t(READ_REG(rhsId.id())); |
| 3280 |
int32_t result = lhs << (rhs & 0x1F); |
| 3281 |
retValue = Int32Value(result).asRawBits(); |
| 3282 |
PREDICT_RETURN(); |
| 3283 |
DISPATCH_CACHEOP(); |
| 3284 |
} |
| 3285 |
|
| 3286 |
CACHEOP_CASE(Int32RightShiftResult) { |
| 3287 |
Int32OperandId lhsId = cacheIRReader.int32OperandId(); |
| 3288 |
Int32OperandId rhsId = cacheIRReader.int32OperandId(); |
| 3289 |
int32_t lhs = int32_t(READ_REG(lhsId.id())); |
| 3290 |
int32_t rhs = int32_t(READ_REG(rhsId.id())); |
| 3291 |
int32_t result = lhs >> (rhs & 0x1F); |
| 3292 |
retValue = Int32Value(result).asRawBits(); |
| 3293 |
PREDICT_RETURN(); |
| 3294 |
DISPATCH_CACHEOP(); |
| 3295 |
} |
| 3296 |
|
| 3297 |
CACHEOP_CASE(Int32URightShiftResult) { |
| 3298 |
Int32OperandId lhsId = cacheIRReader.int32OperandId(); |
| 3299 |
Int32OperandId rhsId = cacheIRReader.int32OperandId(); |
| 3300 |
bool forceDouble = cacheIRReader.readBool(); |
| 3301 |
(void)forceDouble; |
| 3302 |
uint32_t lhs = uint32_t(READ_REG(lhsId.id())); |
| 3303 |
int32_t rhs = int32_t(READ_REG(rhsId.id())); |
| 3304 |
uint32_t result = lhs >> (rhs & 0x1F); |
| 3305 |
retValue = (result >= 0x80000000) |
| 3306 |
? DoubleValue(double(result)).asRawBits() |
| 3307 |
: Int32Value(int32_t(result)).asRawBits(); |
| 3308 |
PREDICT_RETURN(); |
| 3309 |
DISPATCH_CACHEOP(); |
| 3310 |
} |
| 3311 |
|
| 3312 |
CACHEOP_CASE(Int32NotResult) { |
| 3313 |
Int32OperandId inputId = cacheIRReader.int32OperandId(); |
| 3314 |
int32_t input = int32_t(READ_REG(inputId.id())); |
| 3315 |
retValue = Int32Value(~input).asRawBits(); |
| 3316 |
PREDICT_RETURN(); |
| 3317 |
DISPATCH_CACHEOP(); |
| 3318 |
} |
| 3319 |
|
| 3320 |
CACHEOP_CASE(LoadInt32TruthyResult) { |
| 3321 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 3322 |
int32_t val = int32_t(READ_REG(inputId.id())); |
| 3323 |
retValue = BooleanValue(val != 0).asRawBits(); |
| 3324 |
PREDICT_RETURN(); |
| 3325 |
DISPATCH_CACHEOP(); |
| 3326 |
} |
| 3327 |
|
| 3328 |
CACHEOP_CASE(LoadDoubleTruthyResult) { |
| 3329 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3330 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3331 |
// NaN is falsy, not truthy. |
| 3332 |
retValue = BooleanValue(input != 0.0 && !std::isnan(input)).asRawBits(); |
| 3333 |
PREDICT_RETURN(); |
| 3334 |
DISPATCH_CACHEOP(); |
| 3335 |
} |
| 3336 |
|
| 3337 |
CACHEOP_CASE(LoadStringTruthyResult) { |
| 3338 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 3339 |
JSString* str = reinterpret_cast<JSLinearString*>(READ_REG(strId.id())); |
| 3340 |
retValue = BooleanValue(str->length() > 0).asRawBits(); |
| 3341 |
PREDICT_RETURN(); |
| 3342 |
DISPATCH_CACHEOP(); |
| 3343 |
} |
| 3344 |
|
| 3345 |
CACHEOP_CASE(LoadObjectTruthyResult) { |
| 3346 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 3347 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 3348 |
const JSClass* cls = obj->getClass(); |
| 3349 |
if (cls->isProxyObject()) { |
| 3350 |
FAIL_IC(); |
| 3351 |
} |
| 3352 |
retValue = BooleanValue(!cls->emulatesUndefined()).asRawBits(); |
| 3353 |
PREDICT_RETURN(); |
| 3354 |
DISPATCH_CACHEOP(); |
| 3355 |
} |
| 3356 |
|
| 3357 |
CACHEOP_CASE(LoadValueResult) { |
| 3358 |
uint32_t valOffset = cacheIRReader.stubOffset(); |
| 3359 |
retValue = stubInfo->getStubRawInt64(cstub, valOffset); |
| 3360 |
PREDICT_RETURN(); |
| 3361 |
DISPATCH_CACHEOP(); |
| 3362 |
} |
| 3363 |
|
| 3364 |
CACHEOP_CASE(LoadOperandResult) { |
| 3365 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 3366 |
retValue = READ_REG(inputId.id()); |
| 3367 |
PREDICT_RETURN(); |
| 3368 |
DISPATCH_CACHEOP(); |
| 3369 |
} |
| 3370 |
|
| 3371 |
CACHEOP_CASE(ConcatStringsResult) { |
| 3372 |
StringOperandId lhsId = cacheIRReader.stringOperandId(); |
| 3373 |
StringOperandId rhsId = cacheIRReader.stringOperandId(); |
| 3374 |
{ |
| 3375 |
PUSH_IC_FRAME(); |
| 3376 |
ReservedRooted<JSString*> lhs( |
| 3377 |
&ctx.state.str0, |
| 3378 |
reinterpret_cast<JSString*>(READ_REG(lhsId.id()))); |
| 3379 |
ReservedRooted<JSString*> rhs( |
| 3380 |
&ctx.state.str1, |
| 3381 |
reinterpret_cast<JSString*>(READ_REG(rhsId.id()))); |
| 3382 |
JSString* result = |
| 3383 |
ConcatStrings<CanGC>(ctx.frameMgr.cxForLocalUseOnly(), lhs, rhs); |
| 3384 |
if (result) { |
| 3385 |
retValue = StringValue(result).asRawBits(); |
| 3386 |
} else { |
| 3387 |
ctx.error = PBIResult::Error; |
| 3388 |
return IC_ERROR_SENTINEL(); |
| 3389 |
} |
| 3390 |
} |
| 3391 |
PREDICT_RETURN(); |
| 3392 |
DISPATCH_CACHEOP(); |
| 3393 |
} |
| 3394 |
|
| 3395 |
CACHEOP_CASE(CompareStringResult) { |
| 3396 |
JSOp op = cacheIRReader.jsop(); |
| 3397 |
StringOperandId lhsId = cacheIRReader.stringOperandId(); |
| 3398 |
StringOperandId rhsId = cacheIRReader.stringOperandId(); |
| 3399 |
{ |
| 3400 |
PUSH_IC_FRAME(); |
| 3401 |
ReservedRooted<JSString*> lhs( |
| 3402 |
&ctx.state.str0, |
| 3403 |
reinterpret_cast<JSString*>(READ_REG(lhsId.id()))); |
| 3404 |
ReservedRooted<JSString*> rhs( |
| 3405 |
&ctx.state.str1, |
| 3406 |
reinterpret_cast<JSString*>(READ_REG(rhsId.id()))); |
| 3407 |
bool result; |
| 3408 |
if (lhs == rhs) { |
| 3409 |
// If operands point to the same instance, the strings are trivially |
| 3410 |
// equal. |
| 3411 |
result = op == JSOp::Eq || op == JSOp::StrictEq || op == JSOp::Le || |
| 3412 |
op == JSOp::Ge; |
| 3413 |
} else { |
| 3414 |
switch (op) { |
| 3415 |
case JSOp::Eq: |
| 3416 |
case JSOp::StrictEq: |
| 3417 |
if (lhs->isAtom() && rhs->isAtom()) { |
| 3418 |
result = false; |
| 3419 |
break; |
| 3420 |
} |
| 3421 |
if (lhs->length() != rhs->length()) { |
| 3422 |
result = false; |
| 3423 |
break; |
| 3424 |
} |
| 3425 |
if (!StringsEqual<EqualityKind::Equal>(cx, lhs, rhs, &result)) { |
| 3426 |
ctx.error = PBIResult::Error; |
| 3427 |
return IC_ERROR_SENTINEL(); |
| 3428 |
} |
| 3429 |
break; |
| 3430 |
case JSOp::Ne: |
| 3431 |
case JSOp::StrictNe: |
| 3432 |
if (lhs->isAtom() && rhs->isAtom()) { |
| 3433 |
result = true; |
| 3434 |
break; |
| 3435 |
} |
| 3436 |
if (lhs->length() != rhs->length()) { |
| 3437 |
result = true; |
| 3438 |
break; |
| 3439 |
} |
| 3440 |
if (!StringsEqual<EqualityKind::NotEqual>(cx, lhs, rhs, |
| 3441 |
&result)) { |
| 3442 |
ctx.error = PBIResult::Error; |
| 3443 |
return IC_ERROR_SENTINEL(); |
| 3444 |
} |
| 3445 |
break; |
| 3446 |
case JSOp::Lt: |
| 3447 |
if (!StringsCompare<ComparisonKind::LessThan>(cx, lhs, rhs, |
| 3448 |
&result)) { |
| 3449 |
ctx.error = PBIResult::Error; |
| 3450 |
return IC_ERROR_SENTINEL(); |
| 3451 |
} |
| 3452 |
break; |
| 3453 |
case JSOp::Ge: |
| 3454 |
if (!StringsCompare<ComparisonKind::GreaterThanOrEqual>( |
| 3455 |
cx, lhs, rhs, &result)) { |
| 3456 |
ctx.error = PBIResult::Error; |
| 3457 |
return IC_ERROR_SENTINEL(); |
| 3458 |
} |
| 3459 |
break; |
| 3460 |
case JSOp::Le: |
| 3461 |
if (!StringsCompare<ComparisonKind::GreaterThanOrEqual>( |
| 3462 |
cx, /* N.B. swapped order */ rhs, lhs, &result)) { |
| 3463 |
ctx.error = PBIResult::Error; |
| 3464 |
return IC_ERROR_SENTINEL(); |
| 3465 |
} |
| 3466 |
break; |
| 3467 |
case JSOp::Gt: |
| 3468 |
if (!StringsCompare<ComparisonKind::LessThan>( |
| 3469 |
cx, /* N.B. swapped order */ rhs, lhs, &result)) { |
| 3470 |
ctx.error = PBIResult::Error; |
| 3471 |
return IC_ERROR_SENTINEL(); |
| 3472 |
} |
| 3473 |
break; |
| 3474 |
default: |
| 3475 |
MOZ_CRASH("bad opcode"); |
| 3476 |
} |
| 3477 |
} |
| 3478 |
retValue = BooleanValue(result).asRawBits(); |
| 3479 |
} |
| 3480 |
PREDICT_RETURN(); |
| 3481 |
DISPATCH_CACHEOP(); |
| 3482 |
} |
| 3483 |
|
| 3484 |
CACHEOP_CASE(CompareInt32Result) { |
| 3485 |
JSOp op = cacheIRReader.jsop(); |
| 3486 |
Int32OperandId lhsId = cacheIRReader.int32OperandId(); |
| 3487 |
Int32OperandId rhsId = cacheIRReader.int32OperandId(); |
| 3488 |
int64_t lhs = int64_t(int32_t(READ_REG(lhsId.id()))); |
| 3489 |
int64_t rhs = int64_t(int32_t(READ_REG(rhsId.id()))); |
| 3490 |
TRACE_PRINTF("lhs (%d) = %" PRIi64 " rhs (%d) = %" PRIi64 "\n", |
| 3491 |
lhsId.id(), lhs, rhsId.id(), rhs); |
| 3492 |
bool result; |
| 3493 |
switch (op) { |
| 3494 |
case JSOp::Eq: |
| 3495 |
case JSOp::StrictEq: |
| 3496 |
result = lhs == rhs; |
| 3497 |
break; |
| 3498 |
case JSOp::Ne: |
| 3499 |
case JSOp::StrictNe: |
| 3500 |
result = lhs != rhs; |
| 3501 |
break; |
| 3502 |
case JSOp::Lt: |
| 3503 |
result = lhs < rhs; |
| 3504 |
break; |
| 3505 |
case JSOp::Le: |
| 3506 |
result = lhs <= rhs; |
| 3507 |
break; |
| 3508 |
case JSOp::Gt: |
| 3509 |
result = lhs > rhs; |
| 3510 |
break; |
| 3511 |
case JSOp::Ge: |
| 3512 |
result = lhs >= rhs; |
| 3513 |
break; |
| 3514 |
default: |
| 3515 |
MOZ_CRASH("Unexpected opcode"); |
| 3516 |
} |
| 3517 |
retValue = BooleanValue(result).asRawBits(); |
| 3518 |
PREDICT_RETURN(); |
| 3519 |
DISPATCH_CACHEOP(); |
| 3520 |
} |
| 3521 |
|
| 3522 |
CACHEOP_CASE(CompareDoubleResult) { |
| 3523 |
JSOp op = cacheIRReader.jsop(); |
| 3524 |
NumberOperandId lhsId = cacheIRReader.numberOperandId(); |
| 3525 |
NumberOperandId rhsId = cacheIRReader.numberOperandId(); |
| 3526 |
double lhs = READ_VALUE_REG(lhsId.id()).toNumber(); |
| 3527 |
double rhs = READ_VALUE_REG(rhsId.id()).toNumber(); |
| 3528 |
bool result; |
| 3529 |
switch (op) { |
| 3530 |
case JSOp::Eq: |
| 3531 |
case JSOp::StrictEq: |
| 3532 |
result = lhs == rhs; |
| 3533 |
break; |
| 3534 |
case JSOp::Ne: |
| 3535 |
case JSOp::StrictNe: |
| 3536 |
result = lhs != rhs; |
| 3537 |
break; |
| 3538 |
case JSOp::Lt: |
| 3539 |
result = lhs < rhs; |
| 3540 |
break; |
| 3541 |
case JSOp::Le: |
| 3542 |
result = lhs <= rhs; |
| 3543 |
break; |
| 3544 |
case JSOp::Gt: |
| 3545 |
result = lhs > rhs; |
| 3546 |
break; |
| 3547 |
case JSOp::Ge: |
| 3548 |
result = lhs >= rhs; |
| 3549 |
break; |
| 3550 |
default: |
| 3551 |
MOZ_CRASH("Unexpected opcode"); |
| 3552 |
} |
| 3553 |
retValue = BooleanValue(result).asRawBits(); |
| 3554 |
PREDICT_RETURN(); |
| 3555 |
DISPATCH_CACHEOP(); |
| 3556 |
} |
| 3557 |
|
| 3558 |
CACHEOP_CASE(CompareNullUndefinedResult) { |
| 3559 |
JSOp op = cacheIRReader.jsop(); |
| 3560 |
bool isUndefined = cacheIRReader.readBool(); |
| 3561 |
ValOperandId inputId = cacheIRReader.valOperandId(); |
| 3562 |
Value val = READ_VALUE_REG(inputId.id()); |
| 3563 |
if (val.isObject() && val.toObject().getClass()->isProxyObject()) { |
| 3564 |
FAIL_IC(); |
| 3565 |
} |
| 3566 |
|
| 3567 |
bool result; |
| 3568 |
switch (op) { |
| 3569 |
case JSOp::Eq: |
| 3570 |
result = val.isUndefined() || val.isNull() || |
| 3571 |
(val.isObject() && |
| 3572 |
val.toObject().getClass()->emulatesUndefined()); |
| 3573 |
break; |
| 3574 |
case JSOp::Ne: |
| 3575 |
result = !(val.isUndefined() || val.isNull() || |
| 3576 |
(val.isObject() && |
| 3577 |
val.toObject().getClass()->emulatesUndefined())); |
| 3578 |
break; |
| 3579 |
case JSOp::StrictEq: |
| 3580 |
result = isUndefined ? val.isUndefined() : val.isNull(); |
| 3581 |
break; |
| 3582 |
case JSOp::StrictNe: |
| 3583 |
result = !(isUndefined ? val.isUndefined() : val.isNull()); |
| 3584 |
break; |
| 3585 |
default: |
| 3586 |
MOZ_CRASH("bad opcode"); |
| 3587 |
} |
| 3588 |
retValue = BooleanValue(result).asRawBits(); |
| 3589 |
PREDICT_RETURN(); |
| 3590 |
DISPATCH_CACHEOP(); |
| 3591 |
} |
| 3592 |
|
| 3593 |
CACHEOP_CASE(CompareObjectResult) { |
| 3594 |
JSOp op = cacheIRReader.jsop(); |
| 3595 |
ObjOperandId lhsId = cacheIRReader.objOperandId(); |
| 3596 |
ObjOperandId rhsId = cacheIRReader.objOperandId(); |
| 3597 |
(void)op; |
| 3598 |
JSObject* lhs = reinterpret_cast<JSObject*>(READ_REG(lhsId.id())); |
| 3599 |
JSObject* rhs = reinterpret_cast<JSObject*>(READ_REG(rhsId.id())); |
| 3600 |
switch (op) { |
| 3601 |
case JSOp::Eq: |
| 3602 |
case JSOp::StrictEq: |
| 3603 |
retValue = BooleanValue(lhs == rhs).asRawBits(); |
| 3604 |
break; |
| 3605 |
case JSOp::Ne: |
| 3606 |
case JSOp::StrictNe: |
| 3607 |
retValue = BooleanValue(lhs != rhs).asRawBits(); |
| 3608 |
break; |
| 3609 |
default: |
| 3610 |
FAIL_IC(); |
| 3611 |
} |
| 3612 |
PREDICT_RETURN(); |
| 3613 |
DISPATCH_CACHEOP(); |
| 3614 |
} |
| 3615 |
|
| 3616 |
CACHEOP_CASE(CompareSymbolResult) { |
| 3617 |
JSOp op = cacheIRReader.jsop(); |
| 3618 |
SymbolOperandId lhsId = cacheIRReader.symbolOperandId(); |
| 3619 |
SymbolOperandId rhsId = cacheIRReader.symbolOperandId(); |
| 3620 |
(void)op; |
| 3621 |
JS::Symbol* lhs = reinterpret_cast<JS::Symbol*>(READ_REG(lhsId.id())); |
| 3622 |
JS::Symbol* rhs = reinterpret_cast<JS::Symbol*>(READ_REG(rhsId.id())); |
| 3623 |
switch (op) { |
| 3624 |
case JSOp::Eq: |
| 3625 |
case JSOp::StrictEq: |
| 3626 |
retValue = BooleanValue(lhs == rhs).asRawBits(); |
| 3627 |
break; |
| 3628 |
case JSOp::Ne: |
| 3629 |
case JSOp::StrictNe: |
| 3630 |
retValue = BooleanValue(lhs != rhs).asRawBits(); |
| 3631 |
break; |
| 3632 |
default: |
| 3633 |
FAIL_IC(); |
| 3634 |
} |
| 3635 |
PREDICT_RETURN(); |
| 3636 |
DISPATCH_CACHEOP(); |
| 3637 |
} |
| 3638 |
|
| 3639 |
CACHEOP_CASE(AssertPropertyLookup) { |
| 3640 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 3641 |
uint32_t idOffset = cacheIRReader.stubOffset(); |
| 3642 |
uint32_t slotOffset = cacheIRReader.stubOffset(); |
| 3643 |
// Debug-only assertion; we can ignore. |
| 3644 |
(void)objId; |
| 3645 |
(void)idOffset; |
| 3646 |
(void)slotOffset; |
| 3647 |
DISPATCH_CACHEOP(); |
| 3648 |
} |
| 3649 |
|
| 3650 |
CACHEOP_CASE(MathSqrtNumberResult) { |
| 3651 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3652 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3653 |
retValue = NumberValue(sqrt(input)).asRawBits(); |
| 3654 |
PREDICT_RETURN(); |
| 3655 |
DISPATCH_CACHEOP(); |
| 3656 |
} |
| 3657 |
|
| 3658 |
CACHEOP_CASE(MathAbsInt32Result) { |
| 3659 |
Int32OperandId inputId = cacheIRReader.int32OperandId(); |
| 3660 |
int32_t input = int32_t(READ_REG(inputId.id())); |
| 3661 |
if (input == INT32_MIN) { |
| 3662 |
FAIL_IC(); |
| 3663 |
} |
| 3664 |
if (input < 0) { |
| 3665 |
input = -input; |
| 3666 |
} |
| 3667 |
retValue = Int32Value(input).asRawBits(); |
| 3668 |
PREDICT_RETURN(); |
| 3669 |
DISPATCH_CACHEOP(); |
| 3670 |
} |
| 3671 |
|
| 3672 |
CACHEOP_CASE(MathAbsNumberResult) { |
| 3673 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3674 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3675 |
retValue = DoubleValue(fabs(input)).asRawBits(); |
| 3676 |
PREDICT_RETURN(); |
| 3677 |
DISPATCH_CACHEOP(); |
| 3678 |
} |
| 3679 |
|
| 3680 |
CACHEOP_CASE(MathClz32Result) { |
| 3681 |
Int32OperandId inputId = cacheIRReader.int32OperandId(); |
| 3682 |
int32_t input = int32_t(READ_REG(inputId.id())); |
| 3683 |
int32_t result = |
| 3684 |
(input == 0) ? 32 : mozilla::CountLeadingZeroes32(input); |
| 3685 |
retValue = Int32Value(result).asRawBits(); |
| 3686 |
PREDICT_RETURN(); |
| 3687 |
DISPATCH_CACHEOP(); |
| 3688 |
} |
| 3689 |
|
| 3690 |
CACHEOP_CASE(MathSignInt32Result) { |
| 3691 |
Int32OperandId inputId = cacheIRReader.int32OperandId(); |
| 3692 |
int32_t input = int32_t(READ_REG(inputId.id())); |
| 3693 |
int32_t result = (input == 0) ? 0 : ((input > 0) ? 1 : -1); |
| 3694 |
retValue = Int32Value(result).asRawBits(); |
| 3695 |
PREDICT_RETURN(); |
| 3696 |
DISPATCH_CACHEOP(); |
| 3697 |
} |
| 3698 |
|
| 3699 |
CACHEOP_CASE(MathSignNumberResult) { |
| 3700 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3701 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3702 |
double result = 0; |
| 3703 |
if (std::isnan(input)) { |
| 3704 |
result = JS::GenericNaN(); |
| 3705 |
} else if (input == 0 && std::signbit(input)) { |
| 3706 |
result = -0.0; |
| 3707 |
} else if (input == 0) { |
| 3708 |
result = 0; |
| 3709 |
} else if (input > 0) { |
| 3710 |
result = 1; |
| 3711 |
} else { |
| 3712 |
result = -1; |
| 3713 |
} |
| 3714 |
retValue = DoubleValue(result).asRawBits(); |
| 3715 |
PREDICT_RETURN(); |
| 3716 |
DISPATCH_CACHEOP(); |
| 3717 |
} |
| 3718 |
|
| 3719 |
CACHEOP_CASE(MathSignNumberToInt32Result) { |
| 3720 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3721 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3722 |
int32_t result = 0; |
| 3723 |
if (std::isnan(input) || (input == 0.0 && std::signbit(input))) { |
| 3724 |
FAIL_IC(); |
| 3725 |
} else if (input == 0) { |
| 3726 |
result = 0; |
| 3727 |
} else if (input > 0) { |
| 3728 |
result = 1; |
| 3729 |
} else { |
| 3730 |
result = -1; |
| 3731 |
} |
| 3732 |
retValue = Int32Value(result).asRawBits(); |
| 3733 |
PREDICT_RETURN(); |
| 3734 |
DISPATCH_CACHEOP(); |
| 3735 |
} |
| 3736 |
|
| 3737 |
CACHEOP_CASE(MathImulResult) { |
| 3738 |
Int32OperandId lhsId = cacheIRReader.int32OperandId(); |
| 3739 |
Int32OperandId rhsId = cacheIRReader.int32OperandId(); |
| 3740 |
int32_t lhs = int32_t(READ_REG(lhsId.id())); |
| 3741 |
int32_t rhs = int32_t(READ_REG(rhsId.id())); |
| 3742 |
int32_t result = lhs * rhs; |
| 3743 |
retValue = Int32Value(result).asRawBits(); |
| 3744 |
PREDICT_RETURN(); |
| 3745 |
DISPATCH_CACHEOP(); |
| 3746 |
} |
| 3747 |
|
| 3748 |
CACHEOP_CASE(MathFRoundNumberResult) { |
| 3749 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3750 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3751 |
retValue = DoubleValue(double(float(input))).asRawBits(); |
| 3752 |
PREDICT_RETURN(); |
| 3753 |
DISPATCH_CACHEOP(); |
| 3754 |
} |
| 3755 |
|
| 3756 |
CACHEOP_CASE(MathRandomResult) { |
| 3757 |
uint32_t rngOffset = cacheIRReader.stubOffset(); |
| 3758 |
auto* rng = reinterpret_cast<mozilla::non_crypto::XorShift128PlusRNG*>( |
| 3759 |
stubInfo->getStubRawWord(cstub, rngOffset)); |
| 3760 |
retValue = DoubleValue(rng->nextDouble()).asRawBits(); |
| 3761 |
PREDICT_RETURN(); |
| 3762 |
DISPATCH_CACHEOP(); |
| 3763 |
} |
| 3764 |
|
| 3765 |
CACHEOP_CASE(MathHypot2NumberResult) { |
| 3766 |
NumberOperandId firstId = cacheIRReader.numberOperandId(); |
| 3767 |
double first = READ_VALUE_REG(firstId.id()).toNumber(); |
| 3768 |
NumberOperandId secondId = cacheIRReader.numberOperandId(); |
| 3769 |
double second = READ_VALUE_REG(secondId.id()).toNumber(); |
| 3770 |
retValue = DoubleValue(ecmaHypot(first, second)).asRawBits(); |
| 3771 |
PREDICT_RETURN(); |
| 3772 |
DISPATCH_CACHEOP(); |
| 3773 |
} |
| 3774 |
|
| 3775 |
CACHEOP_CASE(MathHypot3NumberResult) { |
| 3776 |
NumberOperandId firstId = cacheIRReader.numberOperandId(); |
| 3777 |
double first = READ_VALUE_REG(firstId.id()).toNumber(); |
| 3778 |
NumberOperandId secondId = cacheIRReader.numberOperandId(); |
| 3779 |
double second = READ_VALUE_REG(secondId.id()).toNumber(); |
| 3780 |
NumberOperandId thirdId = cacheIRReader.numberOperandId(); |
| 3781 |
double third = READ_VALUE_REG(thirdId.id()).toNumber(); |
| 3782 |
retValue = DoubleValue(hypot3(first, second, third)).asRawBits(); |
| 3783 |
PREDICT_RETURN(); |
| 3784 |
DISPATCH_CACHEOP(); |
| 3785 |
} |
| 3786 |
|
| 3787 |
CACHEOP_CASE(MathHypot4NumberResult) { |
| 3788 |
NumberOperandId firstId = cacheIRReader.numberOperandId(); |
| 3789 |
double first = READ_VALUE_REG(firstId.id()).toNumber(); |
| 3790 |
NumberOperandId secondId = cacheIRReader.numberOperandId(); |
| 3791 |
double second = READ_VALUE_REG(secondId.id()).toNumber(); |
| 3792 |
NumberOperandId thirdId = cacheIRReader.numberOperandId(); |
| 3793 |
double third = READ_VALUE_REG(thirdId.id()).toNumber(); |
| 3794 |
NumberOperandId fourthId = cacheIRReader.numberOperandId(); |
| 3795 |
double fourth = READ_VALUE_REG(fourthId.id()).toNumber(); |
| 3796 |
retValue = |
| 3797 |
DoubleValue(hypot4(first, second, third, fourth)).asRawBits(); |
| 3798 |
PREDICT_RETURN(); |
| 3799 |
DISPATCH_CACHEOP(); |
| 3800 |
} |
| 3801 |
|
| 3802 |
CACHEOP_CASE(MathAtan2NumberResult) { |
| 3803 |
NumberOperandId lhsId = cacheIRReader.numberOperandId(); |
| 3804 |
double lhs = READ_VALUE_REG(lhsId.id()).toNumber(); |
| 3805 |
NumberOperandId rhsId = cacheIRReader.numberOperandId(); |
| 3806 |
double rhs = READ_VALUE_REG(rhsId.id()).toNumber(); |
| 3807 |
retValue = DoubleValue(ecmaAtan2(lhs, rhs)).asRawBits(); |
| 3808 |
PREDICT_RETURN(); |
| 3809 |
DISPATCH_CACHEOP(); |
| 3810 |
} |
| 3811 |
|
| 3812 |
CACHEOP_CASE(MathFloorNumberResult) { |
| 3813 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3814 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3815 |
double result = fdlibm_floor(input); |
| 3816 |
retValue = DoubleValue(result).asRawBits(); |
| 3817 |
PREDICT_RETURN(); |
| 3818 |
DISPATCH_CACHEOP(); |
| 3819 |
} |
| 3820 |
|
| 3821 |
CACHEOP_CASE(MathCeilNumberResult) { |
| 3822 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3823 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3824 |
double result = fdlibm_ceil(input); |
| 3825 |
retValue = DoubleValue(result).asRawBits(); |
| 3826 |
PREDICT_RETURN(); |
| 3827 |
DISPATCH_CACHEOP(); |
| 3828 |
} |
| 3829 |
|
| 3830 |
CACHEOP_CASE(MathTruncNumberResult) { |
| 3831 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3832 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3833 |
double result = fdlibm_trunc(input); |
| 3834 |
retValue = DoubleValue(result).asRawBits(); |
| 3835 |
PREDICT_RETURN(); |
| 3836 |
DISPATCH_CACHEOP(); |
| 3837 |
} |
| 3838 |
|
| 3839 |
CACHEOP_CASE(MathFloorToInt32Result) { |
| 3840 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3841 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3842 |
if (input == 0.0 && std::signbit(input)) { |
| 3843 |
FAIL_IC(); |
| 3844 |
} |
| 3845 |
double result = fdlibm_floor(input); |
| 3846 |
int32_t intResult = int32_t(result); |
| 3847 |
if (double(intResult) != result) { |
| 3848 |
FAIL_IC(); |
| 3849 |
} |
| 3850 |
retValue = Int32Value(intResult).asRawBits(); |
| 3851 |
PREDICT_RETURN(); |
| 3852 |
DISPATCH_CACHEOP(); |
| 3853 |
} |
| 3854 |
|
| 3855 |
CACHEOP_CASE(MathCeilToInt32Result) { |
| 3856 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3857 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3858 |
if (input > -1.0 && std::signbit(input)) { |
| 3859 |
FAIL_IC(); |
| 3860 |
} |
| 3861 |
double result = fdlibm_ceil(input); |
| 3862 |
int32_t intResult = int32_t(result); |
| 3863 |
if (double(intResult) != result) { |
| 3864 |
FAIL_IC(); |
| 3865 |
} |
| 3866 |
retValue = Int32Value(intResult).asRawBits(); |
| 3867 |
PREDICT_RETURN(); |
| 3868 |
DISPATCH_CACHEOP(); |
| 3869 |
} |
| 3870 |
|
| 3871 |
CACHEOP_CASE(MathTruncToInt32Result) { |
| 3872 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3873 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3874 |
if (input == 0.0 && std::signbit(input)) { |
| 3875 |
FAIL_IC(); |
| 3876 |
} |
| 3877 |
double result = fdlibm_trunc(input); |
| 3878 |
int32_t intResult = int32_t(result); |
| 3879 |
if (double(intResult) != result) { |
| 3880 |
FAIL_IC(); |
| 3881 |
} |
| 3882 |
retValue = Int32Value(intResult).asRawBits(); |
| 3883 |
PREDICT_RETURN(); |
| 3884 |
DISPATCH_CACHEOP(); |
| 3885 |
} |
| 3886 |
|
| 3887 |
CACHEOP_CASE(MathRoundToInt32Result) { |
| 3888 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3889 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3890 |
if (input == 0.0 && std::signbit(input)) { |
| 3891 |
FAIL_IC(); |
| 3892 |
} |
| 3893 |
int32_t intResult = int32_t(input); |
| 3894 |
if (double(intResult) != input) { |
| 3895 |
FAIL_IC(); |
| 3896 |
} |
| 3897 |
retValue = Int32Value(intResult).asRawBits(); |
| 3898 |
PREDICT_RETURN(); |
| 3899 |
DISPATCH_CACHEOP(); |
| 3900 |
} |
| 3901 |
|
| 3902 |
CACHEOP_CASE(NumberMinMax) { |
| 3903 |
bool isMax = cacheIRReader.readBool(); |
| 3904 |
NumberOperandId firstId = cacheIRReader.numberOperandId(); |
| 3905 |
NumberOperandId secondId = cacheIRReader.numberOperandId(); |
| 3906 |
NumberOperandId resultId = cacheIRReader.numberOperandId(); |
| 3907 |
BOUNDSCHECK(resultId); |
| 3908 |
double first = READ_VALUE_REG(firstId.id()).toNumber(); |
| 3909 |
double second = READ_VALUE_REG(secondId.id()).toNumber(); |
| 3910 |
double result = DoubleMinMax(isMax, first, second); |
| 3911 |
WRITE_VALUE_REG(resultId.id(), DoubleValue(result)); |
| 3912 |
DISPATCH_CACHEOP(); |
| 3913 |
} |
| 3914 |
|
| 3915 |
CACHEOP_CASE(Int32MinMaxArrayResult) { |
| 3916 |
ObjOperandId arrayId = cacheIRReader.objOperandId(); |
| 3917 |
bool isMax = cacheIRReader.readBool(); |
| 3918 |
// ICs that use this opcode depend on implicit unboxing due to |
| 3919 |
// type-overload on ObjOperandId when a value is loaded |
| 3920 |
// directly from an argument slot. We explicitly unbox here. |
| 3921 |
NativeObject* nobj = reinterpret_cast<NativeObject*>( |
| 3922 |
&READ_VALUE_REG(arrayId.id()).toObject()); |
| 3923 |
uint32_t len = nobj->getDenseInitializedLength(); |
| 3924 |
if (len == 0) { |
| 3925 |
FAIL_IC(); |
| 3926 |
} |
| 3927 |
ObjectElements* elems = nobj->getElementsHeader(); |
| 3928 |
int32_t accum = 0; |
| 3929 |
for (uint32_t i = 0; i < len; i++) { |
| 3930 |
HeapSlot* slot = &elems->elements()[i]; |
| 3931 |
Value val = slot->get(); |
| 3932 |
if (!val.isInt32()) { |
| 3933 |
FAIL_IC(); |
| 3934 |
} |
| 3935 |
int32_t valInt = val.toInt32(); |
| 3936 |
if (i > 0) { |
| 3937 |
accum = isMax ? ((valInt > accum) ? valInt : accum) |
| 3938 |
: ((valInt < accum) ? valInt : accum); |
| 3939 |
} else { |
| 3940 |
accum = valInt; |
| 3941 |
} |
| 3942 |
} |
| 3943 |
retValue = Int32Value(accum).asRawBits(); |
| 3944 |
PREDICT_RETURN(); |
| 3945 |
DISPATCH_CACHEOP(); |
| 3946 |
} |
| 3947 |
|
| 3948 |
CACHEOP_CASE(NumberMinMaxArrayResult) { |
| 3949 |
ObjOperandId arrayId = cacheIRReader.objOperandId(); |
| 3950 |
bool isMax = cacheIRReader.readBool(); |
| 3951 |
// ICs that use this opcode depend on implicit unboxing due to |
| 3952 |
// type-overload on ObjOperandId when a value is loaded |
| 3953 |
// directly from an argument slot. We explicitly unbox here. |
| 3954 |
NativeObject* nobj = reinterpret_cast<NativeObject*>( |
| 3955 |
&READ_VALUE_REG(arrayId.id()).toObject()); |
| 3956 |
uint32_t len = nobj->getDenseInitializedLength(); |
| 3957 |
if (len == 0) { |
| 3958 |
FAIL_IC(); |
| 3959 |
} |
| 3960 |
ObjectElements* elems = nobj->getElementsHeader(); |
| 3961 |
double accum = 0; |
| 3962 |
for (uint32_t i = 0; i < len; i++) { |
| 3963 |
HeapSlot* slot = &elems->elements()[i]; |
| 3964 |
Value val = slot->get(); |
| 3965 |
if (!val.isNumber()) { |
| 3966 |
FAIL_IC(); |
| 3967 |
} |
| 3968 |
double valDouble = val.toNumber(); |
| 3969 |
if (i > 0) { |
| 3970 |
accum = DoubleMinMax(isMax, accum, valDouble); |
| 3971 |
} else { |
| 3972 |
accum = valDouble; |
| 3973 |
} |
| 3974 |
} |
| 3975 |
retValue = DoubleValue(accum).asRawBits(); |
| 3976 |
PREDICT_RETURN(); |
| 3977 |
DISPATCH_CACHEOP(); |
| 3978 |
} |
| 3979 |
|
| 3980 |
CACHEOP_CASE(MathFunctionNumberResult) { |
| 3981 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 3982 |
UnaryMathFunction fun = cacheIRReader.unaryMathFunction(); |
| 3983 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 3984 |
auto funPtr = GetUnaryMathFunctionPtr(fun); |
| 3985 |
retValue = DoubleValue(funPtr(input)).asRawBits(); |
| 3986 |
PREDICT_RETURN(); |
| 3987 |
DISPATCH_CACHEOP(); |
| 3988 |
} |
| 3989 |
|
| 3990 |
CACHEOP_CASE(NumberParseIntResult) { |
| 3991 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 3992 |
Int32OperandId radixId = cacheIRReader.int32OperandId(); |
| 3993 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 3994 |
int32_t radix = int32_t(READ_REG(radixId.id())); |
| 3995 |
{ |
| 3996 |
PUSH_IC_FRAME(); |
| 3997 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 3998 |
ReservedRooted<Value> result(&ctx.state.value0); |
| 3999 |
if (!NumberParseInt(cx, str0, radix, &result)) { |
| 4000 |
ctx.error = PBIResult::Error; |
| 4001 |
return IC_ERROR_SENTINEL(); |
| 4002 |
} |
| 4003 |
retValue = result.asRawBits(); |
| 4004 |
} |
| 4005 |
PREDICT_RETURN(); |
| 4006 |
DISPATCH_CACHEOP(); |
| 4007 |
} |
| 4008 |
|
| 4009 |
CACHEOP_CASE(DoubleParseIntResult) { |
| 4010 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 4011 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 4012 |
if (std::isnan(input)) { |
| 4013 |
FAIL_IC(); |
| 4014 |
} |
| 4015 |
int32_t result = int32_t(input); |
| 4016 |
if (double(result) != input) { |
| 4017 |
FAIL_IC(); |
| 4018 |
} |
| 4019 |
retValue = Int32Value(result).asRawBits(); |
| 4020 |
PREDICT_RETURN(); |
| 4021 |
DISPATCH_CACHEOP(); |
| 4022 |
} |
| 4023 |
|
| 4024 |
CACHEOP_CASE(GuardTagNotEqual) { |
| 4025 |
ValueTagOperandId lhsId = cacheIRReader.valueTagOperandId(); |
| 4026 |
ValueTagOperandId rhsId = cacheIRReader.valueTagOperandId(); |
| 4027 |
int32_t lhs = int32_t(READ_REG(lhsId.id())); |
| 4028 |
int32_t rhs = int32_t(READ_REG(rhsId.id())); |
| 4029 |
if (lhs == rhs) { |
| 4030 |
FAIL_IC(); |
| 4031 |
} |
| 4032 |
if (JSValueTag(lhs) <= JSVAL_TAG_INT32 || |
| 4033 |
JSValueTag(rhs) <= JSVAL_TAG_INT32) { |
| 4034 |
FAIL_IC(); |
| 4035 |
} |
| 4036 |
DISPATCH_CACHEOP(); |
| 4037 |
} |
| 4038 |
|
| 4039 |
CACHEOP_CASE(GuardNumberToIntPtrIndex) { |
| 4040 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 4041 |
bool supportOOB = cacheIRReader.readBool(); |
| 4042 |
(void)supportOOB; |
| 4043 |
IntPtrOperandId resultId = cacheIRReader.intPtrOperandId(); |
| 4044 |
BOUNDSCHECK(resultId); |
| 4045 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 4046 |
// For simplicity, support only uint32 range for now. This |
| 4047 |
// covers 32-bit and 64-bit systems. |
| 4048 |
if (input < 0.0 || input >= (uint64_t(1) << 32)) { |
| 4049 |
FAIL_IC(); |
| 4050 |
} |
| 4051 |
uintptr_t result = static_cast<uintptr_t>(input); |
| 4052 |
// Convert back and compare to detect rounded fractional |
| 4053 |
// parts. |
| 4054 |
if (static_cast<double>(result) != input) { |
| 4055 |
FAIL_IC(); |
| 4056 |
} |
| 4057 |
WRITE_REG(resultId.id(), uint64_t(result), OBJECT); |
| 4058 |
DISPATCH_CACHEOP(); |
| 4059 |
} |
| 4060 |
|
| 4061 |
CACHEOP_CASE(LoadTypeOfObjectResult) { |
| 4062 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4063 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 4064 |
const JSClass* cls = obj->getClass(); |
| 4065 |
if (cls->isProxyObject()) { |
| 4066 |
FAIL_IC(); |
| 4067 |
} |
| 4068 |
if (obj->is<JSFunction>()) { |
| 4069 |
retValue = |
| 4070 |
StringValue(ctx.frameMgr.cxForLocalUseOnly()->names().function) |
| 4071 |
.asRawBits(); |
| 4072 |
} else if (cls->emulatesUndefined()) { |
| 4073 |
retValue = |
| 4074 |
StringValue(ctx.frameMgr.cxForLocalUseOnly()->names().undefined) |
| 4075 |
.asRawBits(); |
| 4076 |
} else { |
| 4077 |
retValue = |
| 4078 |
StringValue(ctx.frameMgr.cxForLocalUseOnly()->names().object) |
| 4079 |
.asRawBits(); |
| 4080 |
} |
| 4081 |
PREDICT_RETURN(); |
| 4082 |
DISPATCH_CACHEOP(); |
| 4083 |
} |
| 4084 |
|
| 4085 |
CACHEOP_CASE(PackedArrayPopResult) { |
| 4086 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4087 |
ArrayObject* aobj = |
| 4088 |
reinterpret_cast<ArrayObject*>(READ_REG(objId.id())); |
| 4089 |
ObjectElements* elements = aobj->getElementsHeader(); |
| 4090 |
if (!elements->isPacked() || elements->hasNonwritableArrayLength() || |
| 4091 |
elements->isNotExtensible() || elements->maybeInIteration()) { |
| 4092 |
FAIL_IC(); |
| 4093 |
} |
| 4094 |
size_t len = aobj->length(); |
| 4095 |
if (len != aobj->getDenseInitializedLength()) { |
| 4096 |
FAIL_IC(); |
| 4097 |
} |
| 4098 |
if (len == 0) { |
| 4099 |
retValue = UndefinedValue().asRawBits(); |
| 4100 |
} else { |
| 4101 |
HeapSlot* slot = &elements->elements()[len - 1]; |
| 4102 |
retValue = slot->get().asRawBits(); |
| 4103 |
len--; |
| 4104 |
aobj->setDenseInitializedLength(len); |
| 4105 |
aobj->setLengthToInitializedLength(); |
| 4106 |
} |
| 4107 |
PREDICT_RETURN(); |
| 4108 |
DISPATCH_CACHEOP(); |
| 4109 |
} |
| 4110 |
|
| 4111 |
CACHEOP_CASE(PackedArrayShiftResult) { |
| 4112 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4113 |
ArrayObject* aobj = |
| 4114 |
reinterpret_cast<ArrayObject*>(READ_REG(objId.id())); |
| 4115 |
ObjectElements* elements = aobj->getElementsHeader(); |
| 4116 |
if (!elements->isPacked() || elements->hasNonwritableArrayLength() || |
| 4117 |
elements->isNotExtensible() || elements->maybeInIteration()) { |
| 4118 |
FAIL_IC(); |
| 4119 |
} |
| 4120 |
size_t len = aobj->length(); |
| 4121 |
if (len != aobj->getDenseInitializedLength()) { |
| 4122 |
FAIL_IC(); |
| 4123 |
} |
| 4124 |
if (len == 0) { |
| 4125 |
retValue = UndefinedValue().asRawBits(); |
| 4126 |
} else { |
| 4127 |
HeapSlot* slot = &elements->elements()[0]; |
| 4128 |
retValue = slot->get().asRawBits(); |
| 4129 |
ArrayShiftMoveElements(aobj); |
| 4130 |
} |
| 4131 |
PREDICT_RETURN(); |
| 4132 |
DISPATCH_CACHEOP(); |
| 4133 |
} |
| 4134 |
|
| 4135 |
CACHEOP_CASE(PackedArraySliceResult) { |
| 4136 |
uint32_t templateObjectOffset = cacheIRReader.stubOffset(); |
| 4137 |
ObjOperandId arrayId = cacheIRReader.objOperandId(); |
| 4138 |
Int32OperandId beginId = cacheIRReader.int32OperandId(); |
| 4139 |
Int32OperandId endId = cacheIRReader.int32OperandId(); |
| 4140 |
(void)templateObjectOffset; |
| 4141 |
ArrayObject* aobj = |
| 4142 |
reinterpret_cast<ArrayObject*>(READ_REG(arrayId.id())); |
| 4143 |
int32_t begin = int32_t(READ_REG(beginId.id())); |
| 4144 |
int32_t end = int32_t(READ_REG(endId.id())); |
| 4145 |
if (!aobj->getElementsHeader()->isPacked()) { |
| 4146 |
FAIL_IC(); |
| 4147 |
} |
| 4148 |
{ |
| 4149 |
PUSH_IC_FRAME(); |
| 4150 |
ReservedRooted<JSObject*> arr(&ctx.state.obj0, aobj); |
| 4151 |
JSObject* ret = ArraySliceDense(cx, arr, begin, end, nullptr); |
| 4152 |
if (!ret) { |
| 4153 |
FAIL_IC(); |
| 4154 |
} |
| 4155 |
retValue = ObjectValue(*ret).asRawBits(); |
| 4156 |
} |
| 4157 |
PREDICT_RETURN(); |
| 4158 |
DISPATCH_CACHEOP(); |
| 4159 |
} |
| 4160 |
|
| 4161 |
CACHEOP_CASE(IsPackedArrayResult) { |
| 4162 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4163 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 4164 |
if (!obj->is<ArrayObject>()) { |
| 4165 |
retValue = BooleanValue(false).asRawBits(); |
| 4166 |
PREDICT_RETURN(); |
| 4167 |
DISPATCH_CACHEOP(); |
| 4168 |
} |
| 4169 |
ArrayObject* aobj = |
| 4170 |
reinterpret_cast<ArrayObject*>(READ_REG(objId.id())); |
| 4171 |
if (aobj->length() != aobj->getDenseInitializedLength()) { |
| 4172 |
retValue = BooleanValue(false).asRawBits(); |
| 4173 |
PREDICT_RETURN(); |
| 4174 |
DISPATCH_CACHEOP(); |
| 4175 |
} |
| 4176 |
retValue = BooleanValue(aobj->denseElementsArePacked()).asRawBits(); |
| 4177 |
PREDICT_RETURN(); |
| 4178 |
DISPATCH_CACHEOP(); |
| 4179 |
} |
| 4180 |
|
| 4181 |
CACHEOP_CASE(LoadArgumentsObjectLengthResult) { |
| 4182 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4183 |
ArgumentsObject* obj = |
| 4184 |
reinterpret_cast<ArgumentsObject*>(READ_REG(objId.id())); |
| 4185 |
if (obj->hasOverriddenLength()) { |
| 4186 |
FAIL_IC(); |
| 4187 |
} |
| 4188 |
retValue = Int32Value(obj->initialLength()).asRawBits(); |
| 4189 |
PREDICT_RETURN(); |
| 4190 |
DISPATCH_CACHEOP(); |
| 4191 |
} |
| 4192 |
|
| 4193 |
CACHEOP_CASE(LoadArgumentsObjectLength) { |
| 4194 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4195 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 4196 |
BOUNDSCHECK(resultId); |
| 4197 |
ArgumentsObject* obj = |
| 4198 |
reinterpret_cast<ArgumentsObject*>(READ_REG(objId.id())); |
| 4199 |
if (obj->hasOverriddenLength()) { |
| 4200 |
FAIL_IC(); |
| 4201 |
} |
| 4202 |
WRITE_REG(resultId.id(), obj->initialLength(), INT32); |
| 4203 |
DISPATCH_CACHEOP(); |
| 4204 |
} |
| 4205 |
|
| 4206 |
CACHEOP_CASE(ObjectToIteratorResult) { |
| 4207 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4208 |
uint32_t enumeratorsAddr = cacheIRReader.stubOffset(); |
| 4209 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 4210 |
(void)enumeratorsAddr; |
| 4211 |
{ |
| 4212 |
PUSH_IC_FRAME(); |
| 4213 |
ReservedRooted<JSObject*> rootedObj(&ctx.state.obj0, obj); |
| 4214 |
auto* iter = GetIterator(cx, rootedObj); |
| 4215 |
if (!iter) { |
| 4216 |
ctx.error = PBIResult::Error; |
| 4217 |
return IC_ERROR_SENTINEL(); |
| 4218 |
} |
| 4219 |
retValue = ObjectValue(*iter).asRawBits(); |
| 4220 |
} |
| 4221 |
PREDICT_RETURN(); |
| 4222 |
DISPATCH_CACHEOP(); |
| 4223 |
} |
| 4224 |
|
| 4225 |
CACHEOP_CASE(LoadUndefinedResult) { |
| 4226 |
retValue = UndefinedValue().asRawBits(); |
| 4227 |
PREDICT_RETURN(); |
| 4228 |
DISPATCH_CACHEOP(); |
| 4229 |
} |
| 4230 |
|
| 4231 |
CACHEOP_CASE(LoadDoubleConstant) { |
| 4232 |
uint32_t valOffset = cacheIRReader.stubOffset(); |
| 4233 |
NumberOperandId resultId = cacheIRReader.numberOperandId(); |
| 4234 |
BOUNDSCHECK(resultId); |
| 4235 |
WRITE_VALUE_REG( |
| 4236 |
resultId.id(), |
| 4237 |
Value::fromRawBits(stubInfo->getStubRawInt64(cstub, valOffset))); |
| 4238 |
DISPATCH_CACHEOP(); |
| 4239 |
} |
| 4240 |
|
| 4241 |
CACHEOP_CASE(LoadBooleanConstant) { |
| 4242 |
bool val = cacheIRReader.readBool(); |
| 4243 |
BooleanOperandId resultId = cacheIRReader.booleanOperandId(); |
| 4244 |
BOUNDSCHECK(resultId); |
| 4245 |
WRITE_REG(resultId.id(), val ? 1 : 0, BOOLEAN); |
| 4246 |
DISPATCH_CACHEOP(); |
| 4247 |
} |
| 4248 |
|
| 4249 |
CACHEOP_CASE(LoadUndefined) { |
| 4250 |
ValOperandId resultId = cacheIRReader.numberOperandId(); |
| 4251 |
BOUNDSCHECK(resultId); |
| 4252 |
WRITE_VALUE_REG(resultId.id(), UndefinedValue()); |
| 4253 |
DISPATCH_CACHEOP(); |
| 4254 |
} |
| 4255 |
|
| 4256 |
CACHEOP_CASE(LoadConstantString) { |
| 4257 |
uint32_t valOffset = cacheIRReader.stubOffset(); |
| 4258 |
StringOperandId resultId = cacheIRReader.stringOperandId(); |
| 4259 |
BOUNDSCHECK(resultId); |
| 4260 |
JSString* str = reinterpret_cast<JSString*>( |
| 4261 |
stubInfo->getStubRawWord(cstub, valOffset)); |
| 4262 |
WRITE_REG(resultId.id(), reinterpret_cast<uint64_t>(str), STRING); |
| 4263 |
DISPATCH_CACHEOP(); |
| 4264 |
} |
| 4265 |
|
| 4266 |
CACHEOP_CASE(NewPlainObjectResult) { |
| 4267 |
uint32_t numFixedSlots = cacheIRReader.uint32Immediate(); |
| 4268 |
uint32_t numDynamicSlots = cacheIRReader.uint32Immediate(); |
| 4269 |
gc::AllocKind allocKind = cacheIRReader.allocKind(); |
| 4270 |
uint32_t shapeOffset = cacheIRReader.stubOffset(); |
| 4271 |
uint32_t siteOffset = cacheIRReader.stubOffset(); |
| 4272 |
(void)numFixedSlots; |
| 4273 |
(void)numDynamicSlots; |
| 4274 |
SharedShape* shape = reinterpret_cast<SharedShape*>( |
| 4275 |
stubInfo->getStubRawWord(cstub, shapeOffset)); |
| 4276 |
gc::AllocSite* site = reinterpret_cast<gc::AllocSite*>( |
| 4277 |
stubInfo->getStubRawWord(cstub, siteOffset)); |
| 4278 |
{ |
| 4279 |
PUSH_IC_FRAME(); |
| 4280 |
Rooted<SharedShape*> rootedShape(cx, shape); |
| 4281 |
auto* result = |
| 4282 |
NewPlainObjectBaselineFallback(cx, rootedShape, allocKind, site); |
| 4283 |
if (!result) { |
| 4284 |
ctx.error = PBIResult::Error; |
| 4285 |
return IC_ERROR_SENTINEL(); |
| 4286 |
} |
| 4287 |
retValue = ObjectValue(*result).asRawBits(); |
| 4288 |
} |
| 4289 |
PREDICT_RETURN(); |
| 4290 |
DISPATCH_CACHEOP(); |
| 4291 |
} |
| 4292 |
|
| 4293 |
CACHEOP_CASE(NewArrayObjectResult) { |
| 4294 |
uint32_t arrayLength = cacheIRReader.uint32Immediate(); |
| 4295 |
uint32_t shapeOffset = cacheIRReader.stubOffset(); |
| 4296 |
uint32_t siteOffset = cacheIRReader.stubOffset(); |
| 4297 |
(void)shapeOffset; |
| 4298 |
gc::AllocSite* site = reinterpret_cast<gc::AllocSite*>( |
| 4299 |
stubInfo->getStubRawWord(cstub, siteOffset)); |
| 4300 |
gc::AllocKind allocKind = GuessArrayGCKind(arrayLength); |
| 4301 |
MOZ_ASSERT(gc::GetObjectFinalizeKind(&ArrayObject::class_) == |
| 4302 |
gc::FinalizeKind::None); |
| 4303 |
MOZ_ASSERT(!IsFinalizedKind(allocKind)); |
| 4304 |
{ |
| 4305 |
PUSH_IC_FRAME(); |
| 4306 |
auto* result = |
| 4307 |
NewArrayObjectBaselineFallback(cx, arrayLength, allocKind, site); |
| 4308 |
if (!result) { |
| 4309 |
ctx.error = PBIResult::Error; |
| 4310 |
return IC_ERROR_SENTINEL(); |
| 4311 |
} |
| 4312 |
retValue = ObjectValue(*result).asRawBits(); |
| 4313 |
} |
| 4314 |
PREDICT_RETURN(); |
| 4315 |
DISPATCH_CACHEOP(); |
| 4316 |
} |
| 4317 |
|
| 4318 |
CACHEOP_CASE(NewArrayFromLengthResult) { |
| 4319 |
uint32_t templateObjectOffset = cacheIRReader.stubOffset(); |
| 4320 |
Int32OperandId lengthId = cacheIRReader.int32OperandId(); |
| 4321 |
uint32_t siteOffset = cacheIRReader.stubOffset(); |
| 4322 |
ArrayObject* templateObject = reinterpret_cast<ArrayObject*>( |
| 4323 |
stubInfo->getStubRawWord(cstub, templateObjectOffset)); |
| 4324 |
gc::AllocSite* site = reinterpret_cast<gc::AllocSite*>( |
| 4325 |
stubInfo->getStubRawWord(cstub, siteOffset)); |
| 4326 |
int32_t length = int32_t(READ_REG(lengthId.id())); |
| 4327 |
{ |
| 4328 |
PUSH_IC_FRAME(); |
| 4329 |
Rooted<ArrayObject*> templateObjectRooted(cx, templateObject); |
| 4330 |
auto* result = |
| 4331 |
ArrayConstructorOneArg(cx, templateObjectRooted, length, site); |
| 4332 |
if (!result) { |
| 4333 |
ctx.error = PBIResult::Error; |
| 4334 |
return IC_ERROR_SENTINEL(); |
| 4335 |
} |
| 4336 |
retValue = ObjectValue(*result).asRawBits(); |
| 4337 |
} |
| 4338 |
PREDICT_RETURN(); |
| 4339 |
DISPATCH_CACHEOP(); |
| 4340 |
} |
| 4341 |
|
| 4342 |
CACHEOP_CASE(NewTypedArrayFromLengthResult) { |
| 4343 |
uint32_t templateObjectOffset = cacheIRReader.stubOffset(); |
| 4344 |
Int32OperandId lengthId = cacheIRReader.int32OperandId(); |
| 4345 |
TypedArrayObject* templateObject = reinterpret_cast<TypedArrayObject*>( |
| 4346 |
stubInfo->getStubRawWord(cstub, templateObjectOffset)); |
| 4347 |
int32_t length = int32_t(READ_REG(lengthId.id())); |
| 4348 |
{ |
| 4349 |
PUSH_IC_FRAME(); |
| 4350 |
ReservedRooted<JSObject*> templateObjectRooted(&ctx.state.obj0, |
| 4351 |
templateObject); |
| 4352 |
auto* result = NewTypedArrayWithTemplateAndLength( |
| 4353 |
cx, templateObjectRooted, length); |
| 4354 |
if (!result) { |
| 4355 |
ctx.error = PBIResult::Error; |
| 4356 |
return IC_ERROR_SENTINEL(); |
| 4357 |
} |
| 4358 |
retValue = ObjectValue(*result).asRawBits(); |
| 4359 |
} |
| 4360 |
PREDICT_RETURN(); |
| 4361 |
DISPATCH_CACHEOP(); |
| 4362 |
} |
| 4363 |
|
| 4364 |
CACHEOP_CASE(NewTypedArrayFromArrayBufferResult) { |
| 4365 |
uint32_t templateObjectOffset = cacheIRReader.stubOffset(); |
| 4366 |
ObjOperandId bufferId = cacheIRReader.objOperandId(); |
| 4367 |
ValOperandId byteOffsetId = cacheIRReader.valOperandId(); |
| 4368 |
ValOperandId lengthId = cacheIRReader.valOperandId(); |
| 4369 |
TypedArrayObject* templateObject = reinterpret_cast<TypedArrayObject*>( |
| 4370 |
stubInfo->getStubRawWord(cstub, templateObjectOffset)); |
| 4371 |
JSObject* buffer = reinterpret_cast<JSObject*>(READ_REG(bufferId.id())); |
| 4372 |
Value byteOffset = READ_VALUE_REG(byteOffsetId.id()); |
| 4373 |
Value length = READ_VALUE_REG(lengthId.id()); |
| 4374 |
{ |
| 4375 |
PUSH_IC_FRAME(); |
| 4376 |
ReservedRooted<JSObject*> templateObjectRooted(&ctx.state.obj0, |
| 4377 |
templateObject); |
| 4378 |
ReservedRooted<JSObject*> bufferRooted(&ctx.state.obj1, buffer); |
| 4379 |
ReservedRooted<Value> byteOffsetRooted(&ctx.state.value0, byteOffset); |
| 4380 |
ReservedRooted<Value> lengthRooted(&ctx.state.value1, length); |
| 4381 |
auto* result = NewTypedArrayWithTemplateAndBuffer( |
| 4382 |
cx, templateObjectRooted, bufferRooted, byteOffsetRooted, |
| 4383 |
lengthRooted); |
| 4384 |
if (!result) { |
| 4385 |
ctx.error = PBIResult::Error; |
| 4386 |
return IC_ERROR_SENTINEL(); |
| 4387 |
} |
| 4388 |
retValue = ObjectValue(*result).asRawBits(); |
| 4389 |
} |
| 4390 |
PREDICT_RETURN(); |
| 4391 |
DISPATCH_CACHEOP(); |
| 4392 |
} |
| 4393 |
|
| 4394 |
CACHEOP_CASE(NewTypedArrayFromArrayResult) { |
| 4395 |
uint32_t templateObjectOffset = cacheIRReader.stubOffset(); |
| 4396 |
ObjOperandId arrayId = cacheIRReader.objOperandId(); |
| 4397 |
TypedArrayObject* templateObject = reinterpret_cast<TypedArrayObject*>( |
| 4398 |
stubInfo->getStubRawWord(cstub, templateObjectOffset)); |
| 4399 |
JSObject* array = reinterpret_cast<JSObject*>(READ_REG(arrayId.id())); |
| 4400 |
{ |
| 4401 |
PUSH_IC_FRAME(); |
| 4402 |
ReservedRooted<JSObject*> templateObjectRooted(&ctx.state.obj0, |
| 4403 |
templateObject); |
| 4404 |
ReservedRooted<JSObject*> arrayRooted(&ctx.state.obj1, array); |
| 4405 |
auto* result = NewTypedArrayWithTemplateAndArray( |
| 4406 |
cx, templateObjectRooted, arrayRooted); |
| 4407 |
if (!result) { |
| 4408 |
ctx.error = PBIResult::Error; |
| 4409 |
return IC_ERROR_SENTINEL(); |
| 4410 |
} |
| 4411 |
retValue = ObjectValue(*result).asRawBits(); |
| 4412 |
} |
| 4413 |
PREDICT_RETURN(); |
| 4414 |
DISPATCH_CACHEOP(); |
| 4415 |
} |
| 4416 |
|
| 4417 |
CACHEOP_CASE(ObjectToStringResult) { |
| 4418 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4419 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 4420 |
{ |
| 4421 |
PUSH_IC_FRAME(); |
| 4422 |
auto* result = ObjectClassToString(cx, obj); |
| 4423 |
if (!result) { |
| 4424 |
FAIL_IC(); |
| 4425 |
} |
| 4426 |
retValue = StringValue(result).asRawBits(); |
| 4427 |
} |
| 4428 |
PREDICT_RETURN(); |
| 4429 |
DISPATCH_CACHEOP(); |
| 4430 |
} |
| 4431 |
|
| 4432 |
CACHEOP_CASE(CallNativeGetterResult) { |
| 4433 |
ValOperandId receiverId = cacheIRReader.valOperandId(); |
| 4434 |
uint32_t getterOffset = cacheIRReader.stubOffset(); |
| 4435 |
bool sameRealm = cacheIRReader.readBool(); |
| 4436 |
uint32_t nargsAndFlagsOffset = cacheIRReader.stubOffset(); |
| 4437 |
(void)sameRealm; |
| 4438 |
(void)nargsAndFlagsOffset; |
| 4439 |
Value receiver = READ_VALUE_REG(receiverId.id()); |
| 4440 |
JSFunction* getter = reinterpret_cast<JSFunction*>( |
| 4441 |
stubInfo->getStubRawWord(cstub, getterOffset)); |
| 4442 |
{ |
| 4443 |
PUSH_IC_FRAME(); |
| 4444 |
ReservedRooted<JSFunction*> getterRooted(&ctx.state.fun0, getter); |
| 4445 |
ReservedRooted<Value> receiverRooted(&ctx.state.value0, receiver); |
| 4446 |
ReservedRooted<Value> resultRooted(&ctx.state.value1); |
| 4447 |
if (!CallNativeGetter(cx, getterRooted, receiverRooted, |
| 4448 |
&resultRooted)) { |
| 4449 |
ctx.error = PBIResult::Error; |
| 4450 |
return IC_ERROR_SENTINEL(); |
| 4451 |
} |
| 4452 |
retValue = resultRooted.asRawBits(); |
| 4453 |
} |
| 4454 |
PREDICT_RETURN(); |
| 4455 |
DISPATCH_CACHEOP(); |
| 4456 |
} |
| 4457 |
|
| 4458 |
CACHEOP_CASE(CallNativeSetter) { |
| 4459 |
ValOperandId receiverId = cacheIRReader.valOperandId(); |
| 4460 |
uint32_t setterOffset = cacheIRReader.stubOffset(); |
| 4461 |
ObjOperandId rhsId = cacheIRReader.objOperandId(); |
| 4462 |
bool sameRealm = cacheIRReader.readBool(); |
| 4463 |
uint32_t nargsAndFlagsOffset = cacheIRReader.stubOffset(); |
| 4464 |
(void)sameRealm; |
| 4465 |
(void)nargsAndFlagsOffset; |
| 4466 |
JSObject* receiver = |
| 4467 |
reinterpret_cast<JSObject*>(READ_REG(receiverId.id())); |
| 4468 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 4469 |
JSFunction* setter = reinterpret_cast<JSFunction*>( |
| 4470 |
stubInfo->getStubRawWord(cstub, setterOffset)); |
| 4471 |
{ |
| 4472 |
PUSH_IC_FRAME(); |
| 4473 |
ReservedRooted<JSFunction*> setterRooted(&ctx.state.fun0, setter); |
| 4474 |
ReservedRooted<JSObject*> receiverRooted(&ctx.state.obj0, receiver); |
| 4475 |
ReservedRooted<Value> rhsRooted(&ctx.state.value1, rhs); |
| 4476 |
if (!CallNativeSetter(cx, setterRooted, receiverRooted, rhsRooted)) { |
| 4477 |
ctx.error = PBIResult::Error; |
| 4478 |
return IC_ERROR_SENTINEL(); |
| 4479 |
} |
| 4480 |
} |
| 4481 |
PREDICT_RETURN(); |
| 4482 |
DISPATCH_CACHEOP(); |
| 4483 |
} |
| 4484 |
|
| 4485 |
CACHEOP_CASE(LoadInstanceOfObjectResult) { |
| 4486 |
ValOperandId lhsId = cacheIRReader.valOperandId(); |
| 4487 |
ObjOperandId protoId = cacheIRReader.objOperandId(); |
| 4488 |
Value lhs = READ_VALUE_REG(lhsId.id()); |
| 4489 |
JSObject* rhsProto = |
| 4490 |
reinterpret_cast<JSObject*>(READ_REG(protoId.id())); |
| 4491 |
if (!lhs.isObject()) { |
| 4492 |
retValue = BooleanValue(false).asRawBits(); |
| 4493 |
PREDICT_RETURN(); |
| 4494 |
DISPATCH_CACHEOP(); |
| 4495 |
} |
| 4496 |
|
| 4497 |
JSObject* lhsObj = &lhs.toObject(); |
| 4498 |
bool result = false; |
| 4499 |
while (true) { |
| 4500 |
TaggedProto proto = lhsObj->taggedProto(); |
| 4501 |
if (proto.isDynamic()) { |
| 4502 |
FAIL_IC(); |
| 4503 |
} |
| 4504 |
JSObject* protoObj = proto.toObjectOrNull(); |
| 4505 |
if (!protoObj) { |
| 4506 |
result = false; |
| 4507 |
break; |
| 4508 |
} |
| 4509 |
if (protoObj == rhsProto) { |
| 4510 |
result = true; |
| 4511 |
break; |
| 4512 |
} |
| 4513 |
lhsObj = protoObj; |
| 4514 |
} |
| 4515 |
retValue = BooleanValue(result).asRawBits(); |
| 4516 |
PREDICT_RETURN(); |
| 4517 |
DISPATCH_CACHEOP(); |
| 4518 |
} |
| 4519 |
|
| 4520 |
CACHEOP_CASE(StringFromCharCodeResult) { |
| 4521 |
Int32OperandId codeId = cacheIRReader.int32OperandId(); |
| 4522 |
uint32_t code = uint32_t(READ_REG(codeId.id())); |
| 4523 |
StaticStrings& sstr = ctx.frameMgr.cxForLocalUseOnly()->staticStrings(); |
| 4524 |
if (sstr.hasUnit(code)) { |
| 4525 |
retValue = StringValue(sstr.getUnit(code)).asRawBits(); |
| 4526 |
} else { |
| 4527 |
PUSH_IC_FRAME(); |
| 4528 |
auto* result = StringFromCharCode(cx, code); |
| 4529 |
if (!result) { |
| 4530 |
FAIL_IC(); |
| 4531 |
} |
| 4532 |
retValue = StringValue(result).asRawBits(); |
| 4533 |
} |
| 4534 |
PREDICT_RETURN(); |
| 4535 |
DISPATCH_CACHEOP(); |
| 4536 |
} |
| 4537 |
|
| 4538 |
CACHEOP_CASE(StringFromCodePointResult) { |
| 4539 |
Int32OperandId codeId = cacheIRReader.int32OperandId(); |
| 4540 |
uint32_t code = uint32_t(READ_REG(codeId.id())); |
| 4541 |
if (code > unicode::NonBMPMax) { |
| 4542 |
FAIL_IC(); |
| 4543 |
} |
| 4544 |
StaticStrings& sstr = ctx.frameMgr.cxForLocalUseOnly()->staticStrings(); |
| 4545 |
if (sstr.hasUnit(code)) { |
| 4546 |
retValue = StringValue(sstr.getUnit(code)).asRawBits(); |
| 4547 |
} else { |
| 4548 |
PUSH_IC_FRAME(); |
| 4549 |
auto* result = StringFromCodePoint(cx, code); |
| 4550 |
if (!result) { |
| 4551 |
FAIL_IC(); |
| 4552 |
} |
| 4553 |
retValue = StringValue(result).asRawBits(); |
| 4554 |
} |
| 4555 |
PREDICT_RETURN(); |
| 4556 |
DISPATCH_CACHEOP(); |
| 4557 |
} |
| 4558 |
|
| 4559 |
CACHEOP_CASE(StringIncludesResult) { |
| 4560 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4561 |
StringOperandId searchStrId = cacheIRReader.stringOperandId(); |
| 4562 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4563 |
JSString* searchStr = |
| 4564 |
reinterpret_cast<JSString*>(READ_REG(searchStrId.id())); |
| 4565 |
{ |
| 4566 |
PUSH_IC_FRAME(); |
| 4567 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4568 |
ReservedRooted<JSString*> str1(&ctx.state.str1, searchStr); |
| 4569 |
bool result = false; |
| 4570 |
if (!StringIncludes(cx, str0, str1, &result)) { |
| 4571 |
ctx.error = PBIResult::Error; |
| 4572 |
return IC_ERROR_SENTINEL(); |
| 4573 |
} |
| 4574 |
retValue = BooleanValue(result).asRawBits(); |
| 4575 |
} |
| 4576 |
PREDICT_RETURN(); |
| 4577 |
DISPATCH_CACHEOP(); |
| 4578 |
} |
| 4579 |
|
| 4580 |
CACHEOP_CASE(StringIndexOfResult) { |
| 4581 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4582 |
StringOperandId searchStrId = cacheIRReader.stringOperandId(); |
| 4583 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4584 |
JSString* searchStr = |
| 4585 |
reinterpret_cast<JSString*>(READ_REG(searchStrId.id())); |
| 4586 |
{ |
| 4587 |
PUSH_IC_FRAME(); |
| 4588 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4589 |
ReservedRooted<JSString*> str1(&ctx.state.str1, searchStr); |
| 4590 |
int32_t result = 0; |
| 4591 |
if (!StringIndexOf(cx, str0, str1, &result)) { |
| 4592 |
ctx.error = PBIResult::Error; |
| 4593 |
return IC_ERROR_SENTINEL(); |
| 4594 |
} |
| 4595 |
retValue = Int32Value(result).asRawBits(); |
| 4596 |
} |
| 4597 |
PREDICT_RETURN(); |
| 4598 |
DISPATCH_CACHEOP(); |
| 4599 |
} |
| 4600 |
|
| 4601 |
CACHEOP_CASE(StringLastIndexOfResult) { |
| 4602 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4603 |
StringOperandId searchStrId = cacheIRReader.stringOperandId(); |
| 4604 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4605 |
JSString* searchStr = |
| 4606 |
reinterpret_cast<JSString*>(READ_REG(searchStrId.id())); |
| 4607 |
{ |
| 4608 |
PUSH_IC_FRAME(); |
| 4609 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4610 |
ReservedRooted<JSString*> str1(&ctx.state.str1, searchStr); |
| 4611 |
int32_t result = 0; |
| 4612 |
if (!StringLastIndexOf(cx, str0, str1, &result)) { |
| 4613 |
ctx.error = PBIResult::Error; |
| 4614 |
return IC_ERROR_SENTINEL(); |
| 4615 |
} |
| 4616 |
retValue = Int32Value(result).asRawBits(); |
| 4617 |
} |
| 4618 |
PREDICT_RETURN(); |
| 4619 |
DISPATCH_CACHEOP(); |
| 4620 |
} |
| 4621 |
|
| 4622 |
CACHEOP_CASE(StringStartsWithResult) { |
| 4623 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4624 |
StringOperandId searchStrId = cacheIRReader.stringOperandId(); |
| 4625 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4626 |
JSString* searchStr = |
| 4627 |
reinterpret_cast<JSString*>(READ_REG(searchStrId.id())); |
| 4628 |
{ |
| 4629 |
PUSH_IC_FRAME(); |
| 4630 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4631 |
ReservedRooted<JSString*> str1(&ctx.state.str1, searchStr); |
| 4632 |
bool result = false; |
| 4633 |
if (!StringStartsWith(cx, str0, str1, &result)) { |
| 4634 |
ctx.error = PBIResult::Error; |
| 4635 |
return IC_ERROR_SENTINEL(); |
| 4636 |
} |
| 4637 |
retValue = BooleanValue(result).asRawBits(); |
| 4638 |
} |
| 4639 |
PREDICT_RETURN(); |
| 4640 |
DISPATCH_CACHEOP(); |
| 4641 |
} |
| 4642 |
|
| 4643 |
CACHEOP_CASE(StringEndsWithResult) { |
| 4644 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4645 |
StringOperandId searchStrId = cacheIRReader.stringOperandId(); |
| 4646 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4647 |
JSString* searchStr = |
| 4648 |
reinterpret_cast<JSString*>(READ_REG(searchStrId.id())); |
| 4649 |
{ |
| 4650 |
PUSH_IC_FRAME(); |
| 4651 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4652 |
ReservedRooted<JSString*> str1(&ctx.state.str1, searchStr); |
| 4653 |
bool result = false; |
| 4654 |
if (!StringEndsWith(cx, str0, str1, &result)) { |
| 4655 |
ctx.error = PBIResult::Error; |
| 4656 |
return IC_ERROR_SENTINEL(); |
| 4657 |
} |
| 4658 |
retValue = BooleanValue(result).asRawBits(); |
| 4659 |
} |
| 4660 |
PREDICT_RETURN(); |
| 4661 |
DISPATCH_CACHEOP(); |
| 4662 |
} |
| 4663 |
|
| 4664 |
CACHEOP_CASE(StringToLowerCaseResult) { |
| 4665 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4666 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4667 |
{ |
| 4668 |
PUSH_IC_FRAME(); |
| 4669 |
auto* result = StringToLowerCase(cx, str); |
| 4670 |
if (!result) { |
| 4671 |
ctx.error = PBIResult::Error; |
| 4672 |
return IC_ERROR_SENTINEL(); |
| 4673 |
} |
| 4674 |
retValue = StringValue(result).asRawBits(); |
| 4675 |
} |
| 4676 |
PREDICT_RETURN(); |
| 4677 |
DISPATCH_CACHEOP(); |
| 4678 |
} |
| 4679 |
|
| 4680 |
CACHEOP_CASE(StringToUpperCaseResult) { |
| 4681 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4682 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4683 |
{ |
| 4684 |
PUSH_IC_FRAME(); |
| 4685 |
auto* result = StringToUpperCase(cx, str); |
| 4686 |
if (!result) { |
| 4687 |
ctx.error = PBIResult::Error; |
| 4688 |
return IC_ERROR_SENTINEL(); |
| 4689 |
} |
| 4690 |
retValue = StringValue(result).asRawBits(); |
| 4691 |
} |
| 4692 |
PREDICT_RETURN(); |
| 4693 |
DISPATCH_CACHEOP(); |
| 4694 |
} |
| 4695 |
|
| 4696 |
CACHEOP_CASE(StringTrimResult) { |
| 4697 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4698 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4699 |
{ |
| 4700 |
PUSH_IC_FRAME(); |
| 4701 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4702 |
auto* result = StringTrim(cx, str0); |
| 4703 |
if (!result) { |
| 4704 |
ctx.error = PBIResult::Error; |
| 4705 |
return IC_ERROR_SENTINEL(); |
| 4706 |
} |
| 4707 |
retValue = StringValue(result).asRawBits(); |
| 4708 |
} |
| 4709 |
PREDICT_RETURN(); |
| 4710 |
DISPATCH_CACHEOP(); |
| 4711 |
} |
| 4712 |
|
| 4713 |
CACHEOP_CASE(StringTrimStartResult) { |
| 4714 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4715 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4716 |
{ |
| 4717 |
PUSH_IC_FRAME(); |
| 4718 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4719 |
auto* result = StringTrimStart(cx, str0); |
| 4720 |
if (!result) { |
| 4721 |
ctx.error = PBIResult::Error; |
| 4722 |
return IC_ERROR_SENTINEL(); |
| 4723 |
} |
| 4724 |
retValue = StringValue(result).asRawBits(); |
| 4725 |
} |
| 4726 |
PREDICT_RETURN(); |
| 4727 |
DISPATCH_CACHEOP(); |
| 4728 |
} |
| 4729 |
|
| 4730 |
CACHEOP_CASE(StringTrimEndResult) { |
| 4731 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4732 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4733 |
{ |
| 4734 |
PUSH_IC_FRAME(); |
| 4735 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4736 |
auto* result = StringTrimEnd(cx, str0); |
| 4737 |
if (!result) { |
| 4738 |
ctx.error = PBIResult::Error; |
| 4739 |
return IC_ERROR_SENTINEL(); |
| 4740 |
} |
| 4741 |
retValue = StringValue(result).asRawBits(); |
| 4742 |
} |
| 4743 |
PREDICT_RETURN(); |
| 4744 |
DISPATCH_CACHEOP(); |
| 4745 |
} |
| 4746 |
|
| 4747 |
CACHEOP_CASE(CallSubstringKernelResult) { |
| 4748 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4749 |
Int32OperandId beginId = cacheIRReader.int32OperandId(); |
| 4750 |
Int32OperandId lengthId = cacheIRReader.int32OperandId(); |
| 4751 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4752 |
int32_t begin = int32_t(READ_REG(beginId.id())); |
| 4753 |
int32_t length = int32_t(READ_REG(lengthId.id())); |
| 4754 |
{ |
| 4755 |
PUSH_IC_FRAME(); |
| 4756 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4757 |
auto* result = SubstringKernel(cx, str0, begin, length); |
| 4758 |
if (!result) { |
| 4759 |
ctx.error = PBIResult::Error; |
| 4760 |
return IC_ERROR_SENTINEL(); |
| 4761 |
} |
| 4762 |
retValue = StringValue(result).asRawBits(); |
| 4763 |
} |
| 4764 |
PREDICT_RETURN(); |
| 4765 |
DISPATCH_CACHEOP(); |
| 4766 |
} |
| 4767 |
|
| 4768 |
CACHEOP_CASE(StringReplaceStringResult) { |
| 4769 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4770 |
StringOperandId patternId = cacheIRReader.stringOperandId(); |
| 4771 |
StringOperandId replacementId = cacheIRReader.stringOperandId(); |
| 4772 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4773 |
JSString* pattern = |
| 4774 |
reinterpret_cast<JSString*>(READ_REG(patternId.id())); |
| 4775 |
JSString* replacement = |
| 4776 |
reinterpret_cast<JSString*>(READ_REG(replacementId.id())); |
| 4777 |
{ |
| 4778 |
PUSH_IC_FRAME(); |
| 4779 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4780 |
ReservedRooted<JSString*> str1(&ctx.state.str1, pattern); |
| 4781 |
ReservedRooted<JSString*> str2(&ctx.state.str2, replacement); |
| 4782 |
auto* result = StringReplace(cx, str0, str1, str2); |
| 4783 |
if (!result) { |
| 4784 |
ctx.error = PBIResult::Error; |
| 4785 |
return IC_ERROR_SENTINEL(); |
| 4786 |
} |
| 4787 |
retValue = StringValue(result).asRawBits(); |
| 4788 |
} |
| 4789 |
PREDICT_RETURN(); |
| 4790 |
DISPATCH_CACHEOP(); |
| 4791 |
} |
| 4792 |
|
| 4793 |
CACHEOP_CASE(StringSplitStringResult) { |
| 4794 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4795 |
StringOperandId separatorId = cacheIRReader.stringOperandId(); |
| 4796 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4797 |
JSString* separator = |
| 4798 |
reinterpret_cast<JSString*>(READ_REG(separatorId.id())); |
| 4799 |
{ |
| 4800 |
PUSH_IC_FRAME(); |
| 4801 |
ReservedRooted<JSString*> str0(&ctx.state.str0, str); |
| 4802 |
ReservedRooted<JSString*> str1(&ctx.state.str1, separator); |
| 4803 |
auto* result = StringSplitString(cx, str0, str1, INT32_MAX); |
| 4804 |
if (!result) { |
| 4805 |
ctx.error = PBIResult::Error; |
| 4806 |
return IC_ERROR_SENTINEL(); |
| 4807 |
} |
| 4808 |
retValue = ObjectValue(*result).asRawBits(); |
| 4809 |
} |
| 4810 |
PREDICT_RETURN(); |
| 4811 |
DISPATCH_CACHEOP(); |
| 4812 |
} |
| 4813 |
|
| 4814 |
CACHEOP_CASE(StringToAtom) { |
| 4815 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 4816 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 4817 |
JSAtom* result = |
| 4818 |
AtomizeStringNoGC(ctx.frameMgr.cxForLocalUseOnly(), str); |
| 4819 |
if (!result) { |
| 4820 |
FAIL_IC(); |
| 4821 |
} |
| 4822 |
WRITE_REG(strId.id(), reinterpret_cast<uint64_t>(result), STRING); |
| 4823 |
DISPATCH_CACHEOP(); |
| 4824 |
} |
| 4825 |
|
| 4826 |
CACHEOP_CASE(IdToStringOrSymbol) { |
| 4827 |
ValOperandId resultId = cacheIRReader.valOperandId(); |
| 4828 |
ValOperandId idId = cacheIRReader.valOperandId(); |
| 4829 |
BOUNDSCHECK(resultId); |
| 4830 |
Value id = READ_VALUE_REG(idId.id()); |
| 4831 |
if (id.isString() || id.isSymbol()) { |
| 4832 |
WRITE_VALUE_REG(resultId.id(), id); |
| 4833 |
} else if (id.isInt32()) { |
| 4834 |
int32_t idInt = id.toInt32(); |
| 4835 |
StaticStrings& sstr = |
| 4836 |
ctx.frameMgr.cxForLocalUseOnly()->staticStrings(); |
| 4837 |
if (sstr.hasInt(idInt)) { |
| 4838 |
WRITE_VALUE_REG(resultId.id(), StringValue(sstr.getInt(idInt))); |
| 4839 |
} else { |
| 4840 |
PUSH_IC_FRAME(); |
| 4841 |
auto* result = Int32ToStringPure(cx, idInt); |
| 4842 |
if (!result) { |
| 4843 |
ctx.error = PBIResult::Error; |
| 4844 |
return IC_ERROR_SENTINEL(); |
| 4845 |
} |
| 4846 |
WRITE_VALUE_REG(resultId.id(), StringValue(result)); |
| 4847 |
} |
| 4848 |
} else { |
| 4849 |
FAIL_IC(); |
| 4850 |
} |
| 4851 |
DISPATCH_CACHEOP(); |
| 4852 |
} |
| 4853 |
|
| 4854 |
CACHEOP_CASE(NewStringIteratorResult) { |
| 4855 |
uint32_t templateObjectOffset = cacheIRReader.stubOffset(); |
| 4856 |
(void)templateObjectOffset; |
| 4857 |
{ |
| 4858 |
PUSH_IC_FRAME(); |
| 4859 |
auto* result = NewStringIterator(cx); |
| 4860 |
if (!result) { |
| 4861 |
ctx.error = PBIResult::Error; |
| 4862 |
return IC_ERROR_SENTINEL(); |
| 4863 |
} |
| 4864 |
retValue = ObjectValue(*result).asRawBits(); |
| 4865 |
} |
| 4866 |
PREDICT_RETURN(); |
| 4867 |
DISPATCH_CACHEOP(); |
| 4868 |
} |
| 4869 |
|
| 4870 |
CACHEOP_CASE(IsArrayResult) { |
| 4871 |
ValOperandId valId = cacheIRReader.valOperandId(); |
| 4872 |
Value val = READ_VALUE_REG(valId.id()); |
| 4873 |
if (!val.isObject()) { |
| 4874 |
retValue = BooleanValue(false).asRawBits(); |
| 4875 |
} else { |
| 4876 |
JSObject* obj = &val.toObject(); |
| 4877 |
if (obj->getClass()->isProxyObject()) { |
| 4878 |
FAIL_IC(); |
| 4879 |
} |
| 4880 |
retValue = BooleanValue(obj->is<ArrayObject>()).asRawBits(); |
| 4881 |
} |
| 4882 |
PREDICT_RETURN(); |
| 4883 |
DISPATCH_CACHEOP(); |
| 4884 |
} |
| 4885 |
|
| 4886 |
CACHEOP_CASE(IsCallableResult) { |
| 4887 |
ValOperandId valId = cacheIRReader.valOperandId(); |
| 4888 |
Value val = READ_VALUE_REG(valId.id()); |
| 4889 |
if (!val.isObject()) { |
| 4890 |
retValue = BooleanValue(false).asRawBits(); |
| 4891 |
} else { |
| 4892 |
JSObject* obj = &val.toObject(); |
| 4893 |
if (obj->getClass()->isProxyObject()) { |
| 4894 |
FAIL_IC(); |
| 4895 |
} |
| 4896 |
bool callable = |
| 4897 |
obj->is<JSFunction>() || obj->getClass()->getCall() != nullptr; |
| 4898 |
retValue = BooleanValue(callable).asRawBits(); |
| 4899 |
} |
| 4900 |
PREDICT_RETURN(); |
| 4901 |
DISPATCH_CACHEOP(); |
| 4902 |
} |
| 4903 |
|
| 4904 |
CACHEOP_CASE(IsConstructorResult) { |
| 4905 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4906 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 4907 |
bool ctor = obj->isConstructor(); |
| 4908 |
retValue = BooleanValue(ctor).asRawBits(); |
| 4909 |
PREDICT_RETURN(); |
| 4910 |
DISPATCH_CACHEOP(); |
| 4911 |
} |
| 4912 |
|
| 4913 |
CACHEOP_CASE(IsCrossRealmArrayConstructorResult) { |
| 4914 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4915 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 4916 |
bool result = |
| 4917 |
obj->shape()->realm() != |
| 4918 |
ctx.frameMgr.cxForLocalUseOnly()->realm() && |
| 4919 |
obj->is<JSFunction>() && obj->as<JSFunction>().isNativeFun() && |
| 4920 |
obj->as<JSFunction>().nativeUnchecked() == &js::ArrayConstructor; |
| 4921 |
retValue = BooleanValue(result).asRawBits(); |
| 4922 |
PREDICT_RETURN(); |
| 4923 |
DISPATCH_CACHEOP(); |
| 4924 |
} |
| 4925 |
|
| 4926 |
CACHEOP_CASE(IsTypedArrayResult) { |
| 4927 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4928 |
bool isPossiblyWrapped = cacheIRReader.readBool(); |
| 4929 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 4930 |
if (IsTypedArrayClass(obj->getClass())) { |
| 4931 |
retValue = BooleanValue(true).asRawBits(); |
| 4932 |
} else if (isPossiblyWrapped && obj->is<WrapperObject>()) { |
| 4933 |
PUSH_IC_FRAME(); |
| 4934 |
bool result; |
| 4935 |
if (!IsPossiblyWrappedTypedArray(cx, obj, &result)) { |
| 4936 |
ctx.error = PBIResult::Error; |
| 4937 |
return IC_ERROR_SENTINEL(); |
| 4938 |
} |
| 4939 |
retValue = BooleanValue(result).asRawBits(); |
| 4940 |
} else { |
| 4941 |
retValue = BooleanValue(false).asRawBits(); |
| 4942 |
} |
| 4943 |
PREDICT_RETURN(); |
| 4944 |
DISPATCH_CACHEOP(); |
| 4945 |
} |
| 4946 |
|
| 4947 |
CACHEOP_CASE(IsTypedArrayConstructorResult) { |
| 4948 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4949 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 4950 |
retValue = BooleanValue(IsTypedArrayConstructor(obj)).asRawBits(); |
| 4951 |
PREDICT_RETURN(); |
| 4952 |
DISPATCH_CACHEOP(); |
| 4953 |
} |
| 4954 |
|
| 4955 |
CACHEOP_CASE(ArrayBufferViewByteOffsetInt32Result) { |
| 4956 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4957 |
ArrayBufferViewObject* abvo = |
| 4958 |
reinterpret_cast<ArrayBufferViewObject*>(READ_REG(objId.id())); |
| 4959 |
size_t byteOffset = |
| 4960 |
size_t(abvo->getFixedSlot(ArrayBufferViewObject::BYTEOFFSET_SLOT) |
| 4961 |
.toPrivate()); |
| 4962 |
if (byteOffset > size_t(INT32_MAX)) { |
| 4963 |
FAIL_IC(); |
| 4964 |
} |
| 4965 |
retValue = Int32Value(int32_t(byteOffset)).asRawBits(); |
| 4966 |
PREDICT_RETURN(); |
| 4967 |
DISPATCH_CACHEOP(); |
| 4968 |
} |
| 4969 |
|
| 4970 |
CACHEOP_CASE(ArrayBufferViewByteOffsetDoubleResult) { |
| 4971 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4972 |
ArrayBufferViewObject* abvo = |
| 4973 |
reinterpret_cast<ArrayBufferViewObject*>(READ_REG(objId.id())); |
| 4974 |
size_t byteOffset = |
| 4975 |
size_t(abvo->getFixedSlot(ArrayBufferViewObject::BYTEOFFSET_SLOT) |
| 4976 |
.toPrivate()); |
| 4977 |
retValue = DoubleValue(double(byteOffset)).asRawBits(); |
| 4978 |
PREDICT_RETURN(); |
| 4979 |
DISPATCH_CACHEOP(); |
| 4980 |
} |
| 4981 |
|
| 4982 |
CACHEOP_CASE(TypedArrayByteLengthInt32Result) { |
| 4983 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 4984 |
TypedArrayObject* tao = |
| 4985 |
reinterpret_cast<TypedArrayObject*>(READ_REG(objId.id())); |
| 4986 |
if (!tao->length()) { |
| 4987 |
FAIL_IC(); |
| 4988 |
} |
| 4989 |
size_t length = *tao->length() * tao->bytesPerElement(); |
| 4990 |
if (length > size_t(INT32_MAX)) { |
| 4991 |
FAIL_IC(); |
| 4992 |
} |
| 4993 |
retValue = Int32Value(int32_t(length)).asRawBits(); |
| 4994 |
PREDICT_RETURN(); |
| 4995 |
DISPATCH_CACHEOP(); |
| 4996 |
} |
| 4997 |
|
| 4998 |
CACHEOP_CASE(TypedArrayByteLengthDoubleResult) { |
| 4999 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 5000 |
TypedArrayObject* tao = |
| 5001 |
reinterpret_cast<TypedArrayObject*>(READ_REG(objId.id())); |
| 5002 |
if (!tao->length()) { |
| 5003 |
FAIL_IC(); |
| 5004 |
} |
| 5005 |
size_t length = *tao->length() * tao->bytesPerElement(); |
| 5006 |
retValue = DoubleValue(double(length)).asRawBits(); |
| 5007 |
PREDICT_RETURN(); |
| 5008 |
DISPATCH_CACHEOP(); |
| 5009 |
} |
| 5010 |
|
| 5011 |
CACHEOP_CASE(TypedArrayElementSizeResult) { |
| 5012 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 5013 |
TypedArrayObject* tao = |
| 5014 |
reinterpret_cast<TypedArrayObject*>(READ_REG(objId.id())); |
| 5015 |
retValue = Int32Value(int32_t(tao->bytesPerElement())).asRawBits(); |
| 5016 |
PREDICT_RETURN(); |
| 5017 |
DISPATCH_CACHEOP(); |
| 5018 |
} |
| 5019 |
|
| 5020 |
CACHEOP_CASE(MegamorphicStoreSlot) { |
| 5021 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 5022 |
uint32_t nameOffset = cacheIRReader.stubOffset(); |
| 5023 |
ValOperandId valId = cacheIRReader.valOperandId(); |
| 5024 |
bool strict = cacheIRReader.readBool(); |
| 5025 |
|
| 5026 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 5027 |
jsid id = |
| 5028 |
jsid::fromRawBits(stubInfo->getStubRawWord(cstub, nameOffset)); |
| 5029 |
Value val = READ_VALUE_REG(valId.id()); |
| 5030 |
|
| 5031 |
{ |
| 5032 |
PUSH_IC_FRAME(); |
| 5033 |
ReservedRooted<JSObject*> objRooted(&ctx.state.obj0, obj); |
| 5034 |
ReservedRooted<jsid> idRooted(&ctx.state.id0, id); |
| 5035 |
ReservedRooted<Value> valRooted(&ctx.state.value0, val); |
| 5036 |
if (!SetPropertyMegamorphic<false>(cx, objRooted, idRooted, valRooted, |
| 5037 |
strict)) { |
| 5038 |
ctx.error = PBIResult::Error; |
| 5039 |
return IC_ERROR_SENTINEL(); |
| 5040 |
} |
| 5041 |
} |
| 5042 |
|
| 5043 |
PREDICT_RETURN(); |
| 5044 |
DISPATCH_CACHEOP(); |
| 5045 |
} |
| 5046 |
|
| 5047 |
CACHEOP_CASE(MegamorphicHasPropResult) { |
| 5048 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 5049 |
ValOperandId valId = cacheIRReader.valOperandId(); |
| 5050 |
bool hasOwn = cacheIRReader.readBool(); |
| 5051 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 5052 |
if (!obj->is<NativeObject>()) { |
| 5053 |
FAIL_IC(); |
| 5054 |
} |
| 5055 |
Value val[2] = {READ_VALUE_REG(valId.id()), UndefinedValue()}; |
| 5056 |
{ |
| 5057 |
PUSH_IC_FRAME(); |
| 5058 |
bool ok = |
| 5059 |
hasOwn |
| 5060 |
? HasNativeDataPropertyPure<true>(cx, obj, nullptr, &val[0]) |
| 5061 |
: HasNativeDataPropertyPure<false>(cx, obj, nullptr, &val[0]); |
| 5062 |
if (!ok) { |
| 5063 |
FAIL_IC(); |
| 5064 |
} |
| 5065 |
retValue = val[1].asRawBits(); |
| 5066 |
} |
| 5067 |
PREDICT_RETURN(); |
| 5068 |
DISPATCH_CACHEOP(); |
| 5069 |
} |
| 5070 |
|
| 5071 |
CACHEOP_CASE(ArrayJoinResult) { |
| 5072 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 5073 |
StringOperandId sepId = cacheIRReader.stringOperandId(); |
| 5074 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 5075 |
JSString* sep = reinterpret_cast<JSString*>(READ_REG(sepId.id())); |
| 5076 |
{ |
| 5077 |
PUSH_IC_FRAME(); |
| 5078 |
ReservedRooted<JSObject*> obj0(&ctx.state.obj0, obj); |
| 5079 |
ReservedRooted<JSString*> str0(&ctx.state.str0, sep); |
| 5080 |
auto* result = ArrayJoin(cx, obj0, str0); |
| 5081 |
if (!result) { |
| 5082 |
ctx.error = PBIResult::Error; |
| 5083 |
return IC_ERROR_SENTINEL(); |
| 5084 |
} |
| 5085 |
retValue = StringValue(result).asRawBits(); |
| 5086 |
} |
| 5087 |
PREDICT_RETURN(); |
| 5088 |
DISPATCH_CACHEOP(); |
| 5089 |
} |
| 5090 |
|
| 5091 |
CACHEOP_CASE(CallSetArrayLength) { |
| 5092 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 5093 |
bool strict = cacheIRReader.readBool(); |
| 5094 |
ValOperandId rhsId = cacheIRReader.valOperandId(); |
| 5095 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 5096 |
Value rhs = READ_VALUE_REG(rhsId.id()); |
| 5097 |
{ |
| 5098 |
PUSH_IC_FRAME(); |
| 5099 |
ReservedRooted<JSObject*> obj0(&ctx.state.obj0, obj); |
| 5100 |
ReservedRooted<Value> value0(&ctx.state.value0, rhs); |
| 5101 |
if (!SetArrayLength(cx, obj0, value0, strict)) { |
| 5102 |
ctx.error = PBIResult::Error; |
| 5103 |
return IC_ERROR_SENTINEL(); |
| 5104 |
} |
| 5105 |
} |
| 5106 |
PREDICT_RETURN(); |
| 5107 |
DISPATCH_CACHEOP(); |
| 5108 |
} |
| 5109 |
|
| 5110 |
CACHEOP_CASE(ObjectKeysResult) { |
| 5111 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 5112 |
JSObject* obj = reinterpret_cast<JSObject*>(READ_REG(objId.id())); |
| 5113 |
{ |
| 5114 |
PUSH_IC_FRAME(); |
| 5115 |
ReservedRooted<JSObject*> obj0(&ctx.state.obj0, obj); |
| 5116 |
auto* result = ObjectKeys(cx, obj0); |
| 5117 |
if (!result) { |
| 5118 |
ctx.error = PBIResult::Error; |
| 5119 |
return IC_ERROR_SENTINEL(); |
| 5120 |
} |
| 5121 |
retValue = ObjectValue(*result).asRawBits(); |
| 5122 |
} |
| 5123 |
PREDICT_RETURN(); |
| 5124 |
DISPATCH_CACHEOP(); |
| 5125 |
} |
| 5126 |
|
| 5127 |
CACHEOP_CASE(ObjectCreateResult) { |
| 5128 |
uint32_t templateOffset = cacheIRReader.stubOffset(); |
| 5129 |
PlainObject* templateObj = reinterpret_cast<PlainObject*>( |
| 5130 |
stubInfo->getStubRawWord(cstub, templateOffset)); |
| 5131 |
{ |
| 5132 |
PUSH_IC_FRAME(); |
| 5133 |
Rooted<PlainObject*> templateRooted(cx, templateObj); |
| 5134 |
auto* result = ObjectCreateWithTemplate(cx, templateRooted); |
| 5135 |
if (!result) { |
| 5136 |
ctx.error = PBIResult::Error; |
| 5137 |
return IC_ERROR_SENTINEL(); |
| 5138 |
} |
| 5139 |
retValue = ObjectValue(*result).asRawBits(); |
| 5140 |
} |
| 5141 |
PREDICT_RETURN(); |
| 5142 |
DISPATCH_CACHEOP(); |
| 5143 |
} |
| 5144 |
|
| 5145 |
CACHEOP_CASE(CallNumberToString) { |
| 5146 |
NumberOperandId inputId = cacheIRReader.numberOperandId(); |
| 5147 |
StringOperandId resultId = cacheIRReader.stringOperandId(); |
| 5148 |
BOUNDSCHECK(resultId); |
| 5149 |
double input = READ_VALUE_REG(inputId.id()).toNumber(); |
| 5150 |
{ |
| 5151 |
PUSH_IC_FRAME(); |
| 5152 |
auto* result = NumberToStringPure(cx, input); |
| 5153 |
if (!result) { |
| 5154 |
FAIL_IC(); |
| 5155 |
} |
| 5156 |
WRITE_REG(resultId.id(), reinterpret_cast<uint64_t>(result), STRING); |
| 5157 |
} |
| 5158 |
PREDICT_RETURN(); |
| 5159 |
DISPATCH_CACHEOP(); |
| 5160 |
} |
| 5161 |
|
| 5162 |
CACHEOP_CASE(Int32ToStringWithBaseResult) { |
| 5163 |
Int32OperandId inputId = cacheIRReader.int32OperandId(); |
| 5164 |
Int32OperandId baseId = cacheIRReader.int32OperandId(); |
| 5165 |
int32_t input = int32_t(READ_REG(inputId.id())); |
| 5166 |
int32_t base = int32_t(READ_REG(baseId.id())); |
| 5167 |
if (base < 2 || base > 36) { |
| 5168 |
FAIL_IC(); |
| 5169 |
} |
| 5170 |
{ |
| 5171 |
PUSH_IC_FRAME(); |
| 5172 |
auto* result = Int32ToStringWithBase<CanGC>(cx, input, base, true); |
| 5173 |
if (!result) { |
| 5174 |
ctx.error = PBIResult::Error; |
| 5175 |
return IC_ERROR_SENTINEL(); |
| 5176 |
} |
| 5177 |
retValue = StringValue(result).asRawBits(); |
| 5178 |
} |
| 5179 |
PREDICT_RETURN(); |
| 5180 |
DISPATCH_CACHEOP(); |
| 5181 |
} |
| 5182 |
|
| 5183 |
CACHEOP_CASE(BooleanToString) { |
| 5184 |
BooleanOperandId inputId = cacheIRReader.booleanOperandId(); |
| 5185 |
StringOperandId resultId = cacheIRReader.stringOperandId(); |
| 5186 |
BOUNDSCHECK(resultId); |
| 5187 |
bool input = READ_REG(inputId.id()) != 0; |
| 5188 |
auto& names = ctx.frameMgr.cxForLocalUseOnly()->names(); |
| 5189 |
JSString* result = input ? names.true_ : names.false_; |
| 5190 |
WRITE_REG(resultId.id(), reinterpret_cast<uint64_t>(result), STRING); |
| 5191 |
DISPATCH_CACHEOP(); |
| 5192 |
} |
| 5193 |
|
| 5194 |
CACHEOP_CASE(IndirectTruncateInt32Result) { |
| 5195 |
Int32OperandId valId = cacheIRReader.int32OperandId(); |
| 5196 |
int32_t value = int32_t(READ_REG(valId.id())); |
| 5197 |
retValue = Int32Value(value).asRawBits(); |
| 5198 |
PREDICT_RETURN(); |
| 5199 |
DISPATCH_CACHEOP(); |
| 5200 |
} |
| 5201 |
|
| 5202 |
CACHEOP_CASE(GetFirstDollarIndexResult) { |
| 5203 |
StringOperandId strId = cacheIRReader.stringOperandId(); |
| 5204 |
JSString* str = reinterpret_cast<JSString*>(READ_REG(strId.id())); |
| 5205 |
int32_t result = 0; |
| 5206 |
{ |
| 5207 |
PUSH_IC_FRAME(); |
| 5208 |
if (!GetFirstDollarIndexRaw(cx, str, &result)) { |
| 5209 |
ctx.error = PBIResult::Error; |
| 5210 |
return IC_ERROR_SENTINEL(); |
| 5211 |
} |
| 5212 |
retValue = Int32Value(result).asRawBits(); |
| 5213 |
} |
| 5214 |
PREDICT_RETURN(); |
| 5215 |
DISPATCH_CACHEOP(); |
| 5216 |
} |
| 5217 |
|
| 5218 |
CACHEOP_CASE(LoadBoundFunctionNumArgs) { |
| 5219 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 5220 |
Int32OperandId resultId = cacheIRReader.int32OperandId(); |
| 5221 |
BOUNDSCHECK(resultId); |
| 5222 |
BoundFunctionObject* obj = |
| 5223 |
reinterpret_cast<BoundFunctionObject*>(READ_REG(objId.id())); |
| 5224 |
WRITE_REG(resultId.id(), obj->numBoundArgs(), INT32); |
| 5225 |
DISPATCH_CACHEOP(); |
| 5226 |
} |
| 5227 |
|
| 5228 |
CACHEOP_CASE(LoadBoundFunctionTarget) { |
| 5229 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 5230 |
ObjOperandId resultId = cacheIRReader.objOperandId(); |
| 5231 |
BOUNDSCHECK(resultId); |
| 5232 |
BoundFunctionObject* obj = |
| 5233 |
reinterpret_cast<BoundFunctionObject*>(READ_REG(objId.id())); |
| 5234 |
WRITE_REG(resultId.id(), reinterpret_cast<uint64_t>(obj->getTarget()), |
| 5235 |
OBJECT); |
| 5236 |
DISPATCH_CACHEOP(); |
| 5237 |
} |
| 5238 |
|
| 5239 |
CACHEOP_CASE(BindFunctionResult) |
| 5240 |
CACHEOP_CASE_FALLTHROUGH(SpecializedBindFunctionResult) { |
| 5241 |
ObjOperandId targetId = cacheIRReader.objOperandId(); |
| 5242 |
uint32_t argc = cacheIRReader.uint32Immediate(); |
| 5243 |
uint32_t templateObjectOffset = cacheIRReader.stubOffset(); |
| 5244 |
|
| 5245 |
JSObject* target = reinterpret_cast<JSObject*>(READ_REG(targetId.id())); |
| 5246 |
BoundFunctionObject* templateObject = |
| 5247 |
(cacheop == CacheOp::SpecializedBindFunctionResult) |
| 5248 |
? reinterpret_cast<BoundFunctionObject*>( |
| 5249 |
stubInfo->getStubRawWord(cstub, templateObjectOffset)) |
| 5250 |
: nullptr; |
| 5251 |
|
| 5252 |
StackVal* origArgs = ctx.sp(); |
| 5253 |
{ |
| 5254 |
PUSH_IC_FRAME(); |
| 5255 |
|
| 5256 |
for (uint32_t i = 0; i < argc; i++) { |
| 5257 |
PUSH(origArgs[i]); |
| 5258 |
} |
| 5259 |
Value* args = reinterpret_cast<Value*>(sp); |
| 5260 |
|
| 5261 |
ReservedRooted<JSObject*> targetRooted(&ctx.state.obj0, target); |
| 5262 |
BoundFunctionObject* result; |
| 5263 |
if (cacheop == CacheOp::BindFunctionResult) { |
| 5264 |
result = BoundFunctionObject::functionBindImpl(cx, targetRooted, |
| 5265 |
args, argc, nullptr); |
| 5266 |
} else { |
| 5267 |
Rooted<BoundFunctionObject*> templateObjectRooted(cx, |
| 5268 |
templateObject); |
| 5269 |
result = BoundFunctionObject::functionBindSpecializedBaseline( |
| 5270 |
cx, targetRooted, args, argc, templateObjectRooted); |
| 5271 |
} |
| 5272 |
if (!result) { |
| 5273 |
ctx.error = PBIResult::Error; |
| 5274 |
return IC_ERROR_SENTINEL(); |
| 5275 |
} |
| 5276 |
|
| 5277 |
retValue = ObjectValue(*result).asRawBits(); |
| 5278 |
} |
| 5279 |
PREDICT_RETURN(); |
| 5280 |
DISPATCH_CACHEOP(); |
| 5281 |
} |
| 5282 |
|
| 5283 |
CACHEOP_CASE(CallRegExpMatcherResult) |
| 5284 |
CACHEOP_CASE_FALLTHROUGH(CallRegExpSearcherResult) { |
| 5285 |
ObjOperandId regexpId = cacheIRReader.objOperandId(); |
| 5286 |
StringOperandId inputId = cacheIRReader.stringOperandId(); |
| 5287 |
Int32OperandId lastIndexId = cacheIRReader.int32OperandId(); |
| 5288 |
uint32_t stubOffset = cacheIRReader.stubOffset(); |
| 5289 |
|
| 5290 |
JSObject* regexp = reinterpret_cast<JSObject*>(READ_REG(regexpId.id())); |
| 5291 |
JSString* input = reinterpret_cast<JSString*>(READ_REG(inputId.id())); |
| 5292 |
int32_t lastIndex = int32_t(READ_REG(lastIndexId.id())); |
| 5293 |
(void)stubOffset; |
| 5294 |
|
| 5295 |
{ |
| 5296 |
PUSH_IC_FRAME(); |
| 5297 |
ReservedRooted<JSObject*> regexpRooted(&ctx.state.obj0, regexp); |
| 5298 |
ReservedRooted<JSString*> inputRooted(&ctx.state.str0, input); |
| 5299 |
|
| 5300 |
if (cacheop == CacheOp::CallRegExpMatcherResult) { |
| 5301 |
ReservedRooted<Value> result(&ctx.state.value0, UndefinedValue()); |
| 5302 |
if (!RegExpMatcherRaw(cx, regexpRooted, inputRooted, lastIndex, |
| 5303 |
nullptr, &result)) { |
| 5304 |
ctx.error = PBIResult::Error; |
| 5305 |
return IC_ERROR_SENTINEL(); |
| 5306 |
} |
| 5307 |
retValue = result.asRawBits(); |
| 5308 |
} else { |
| 5309 |
int32_t result = 0; |
| 5310 |
if (!RegExpSearcherRaw(cx, regexpRooted, inputRooted, lastIndex, |
| 5311 |
nullptr, &result)) { |
| 5312 |
ctx.error = PBIResult::Error; |
| 5313 |
return IC_ERROR_SENTINEL(); |
| 5314 |
} |
| 5315 |
retValue = Int32Value(result).asRawBits(); |
| 5316 |
} |
| 5317 |
} |
| 5318 |
PREDICT_RETURN(); |
| 5319 |
DISPATCH_CACHEOP(); |
| 5320 |
} |
| 5321 |
|
| 5322 |
CACHEOP_CASE(RegExpSearcherLastLimitResult) { |
| 5323 |
uint32_t lastLimit = |
| 5324 |
ctx.frameMgr.cxForLocalUseOnly()->regExpSearcherLastLimit; |
| 5325 |
retValue = Int32Value(lastLimit).asRawBits(); |
| 5326 |
PREDICT_RETURN(); |
| 5327 |
DISPATCH_CACHEOP(); |
| 5328 |
} |
| 5329 |
|
| 5330 |
CACHEOP_CASE(RegExpHasCaptureGroupsResult) { |
| 5331 |
ObjOperandId regexpId = cacheIRReader.objOperandId(); |
| 5332 |
StringOperandId inputId = cacheIRReader.stringOperandId(); |
| 5333 |
RegExpObject* regexp = |
| 5334 |
reinterpret_cast<RegExpObject*>(READ_REG(regexpId.id())); |
| 5335 |
JSString* input = reinterpret_cast<JSString*>(READ_REG(inputId.id())); |
| 5336 |
{ |
| 5337 |
PUSH_IC_FRAME(); |
| 5338 |
Rooted<RegExpObject*> regexpRooted(cx, regexp); |
| 5339 |
ReservedRooted<JSString*> inputRooted(&ctx.state.str0, input); |
| 5340 |
bool result = false; |
| 5341 |
if (!RegExpHasCaptureGroups(cx, regexpRooted, inputRooted, &result)) { |
| 5342 |
ctx.error = PBIResult::Error; |
| 5343 |
return IC_ERROR_SENTINEL(); |
| 5344 |
} |
| 5345 |
retValue = BooleanValue(result).asRawBits(); |
| 5346 |
} |
| 5347 |
PREDICT_RETURN(); |
| 5348 |
DISPATCH_CACHEOP(); |
| 5349 |
} |
| 5350 |
|
| 5351 |
CACHEOP_CASE(RegExpBuiltinExecMatchResult) { |
| 5352 |
ObjOperandId regexpId = cacheIRReader.objOperandId(); |
| 5353 |
StringOperandId inputId = cacheIRReader.stringOperandId(); |
| 5354 |
uint32_t stubOffset = cacheIRReader.stubOffset(); |
| 5355 |
|
| 5356 |
RegExpObject* regexp = |
| 5357 |
reinterpret_cast<RegExpObject*>(READ_REG(regexpId.id())); |
| 5358 |
JSString* input = reinterpret_cast<JSString*>(READ_REG(inputId.id())); |
| 5359 |
(void)stubOffset; |
| 5360 |
|
| 5361 |
{ |
| 5362 |
PUSH_IC_FRAME(); |
| 5363 |
Rooted<RegExpObject*> regexpRooted(cx, regexp); |
| 5364 |
ReservedRooted<JSString*> inputRooted(&ctx.state.str0, input); |
| 5365 |
ReservedRooted<Value> output(&ctx.state.value0, UndefinedValue()); |
| 5366 |
if (!RegExpBuiltinExecMatchFromJit(cx, regexpRooted, inputRooted, |
| 5367 |
nullptr, &output)) { |
| 5368 |
ctx.error = PBIResult::Error; |
| 5369 |
return IC_ERROR_SENTINEL(); |
| 5370 |
} |
| 5371 |
retValue = output.asRawBits(); |
| 5372 |
} |
| 5373 |
PREDICT_RETURN(); |
| 5374 |
DISPATCH_CACHEOP(); |
| 5375 |
} |
| 5376 |
|
| 5377 |
CACHEOP_CASE(RegExpBuiltinExecTestResult) { |
| 5378 |
ObjOperandId regexpId = cacheIRReader.objOperandId(); |
| 5379 |
StringOperandId inputId = cacheIRReader.stringOperandId(); |
| 5380 |
uint32_t stubOffset = cacheIRReader.stubOffset(); |
| 5381 |
|
| 5382 |
RegExpObject* regexp = |
| 5383 |
reinterpret_cast<RegExpObject*>(READ_REG(regexpId.id())); |
| 5384 |
JSString* input = reinterpret_cast<JSString*>(READ_REG(inputId.id())); |
| 5385 |
(void)stubOffset; |
| 5386 |
|
| 5387 |
{ |
| 5388 |
PUSH_IC_FRAME(); |
| 5389 |
Rooted<RegExpObject*> regexpRooted(cx, regexp); |
| 5390 |
ReservedRooted<JSString*> inputRooted(&ctx.state.str0, input); |
| 5391 |
bool result = false; |
| 5392 |
if (!RegExpBuiltinExecTestFromJit(cx, regexpRooted, inputRooted, |
| 5393 |
&result)) { |
| 5394 |
ctx.error = PBIResult::Error; |
| 5395 |
return IC_ERROR_SENTINEL(); |
| 5396 |
} |
| 5397 |
retValue = BooleanValue(result).asRawBits(); |
| 5398 |
} |
| 5399 |
PREDICT_RETURN(); |
| 5400 |
DISPATCH_CACHEOP(); |
| 5401 |
} |
| 5402 |
|
| 5403 |
CACHEOP_CASE(RegExpFlagResult) { |
| 5404 |
ObjOperandId regexpId = cacheIRReader.objOperandId(); |
| 5405 |
uint32_t flagsMask = cacheIRReader.uint32Immediate(); |
| 5406 |
RegExpObject* regexp = |
| 5407 |
reinterpret_cast<RegExpObject*>(READ_REG(regexpId.id())); |
| 5408 |
JS::RegExpFlags flags = regexp->getFlags(); |
| 5409 |
retValue = BooleanValue((uint32_t(flags.value()) & flagsMask) != 0) |
| 5410 |
.asRawBits(); |
| 5411 |
PREDICT_RETURN(); |
| 5412 |
DISPATCH_CACHEOP(); |
| 5413 |
} |
| 5414 |
|
| 5415 |
CACHEOP_CASE(NewRegExpStringIteratorResult) { |
| 5416 |
uint32_t templateObjectOffset = cacheIRReader.stubOffset(); |
| 5417 |
(void)templateObjectOffset; |
| 5418 |
{ |
| 5419 |
PUSH_IC_FRAME(); |
| 5420 |
auto* result = NewRegExpStringIterator(cx); |
| 5421 |
if (!result) { |
| 5422 |
ctx.error = PBIResult::Error; |
| 5423 |
return IC_ERROR_SENTINEL(); |
| 5424 |
} |
| 5425 |
retValue = ObjectValue(*result).asRawBits(); |
| 5426 |
} |
| 5427 |
PREDICT_RETURN(); |
| 5428 |
DISPATCH_CACHEOP(); |
| 5429 |
} |
| 5430 |
|
| 5431 |
CACHEOP_CASE(CallGetSparseElementResult) { |
| 5432 |
ObjOperandId objId = cacheIRReader.objOperandId(); |
| 5433 |
Int32OperandId indexId = cacheIRReader.int32OperandId(); |
| 5434 |
NativeObject* nobj = |
| 5435 |
reinterpret_cast<NativeObject*>(READ_REG(objId.id())); |
| 5436 |
int32_t index = int32_t(READ_REG(indexId.id())); |
| 5437 |
{ |
| 5438 |
PUSH_IC_FRAME(); |
| 5439 |
Rooted<NativeObject*> nobjRooted(cx, nobj); |
| 5440 |
ReservedRooted<Value> result(&ctx.state.value0, UndefinedValue()); |
| 5441 |
if (!GetSparseElementHelper(cx, nobjRooted, index, &result)) { |
| 5442 |
ctx.error = PBIResult::Error; |
| 5443 |
return IC_ERROR_SENTINEL(); |
| 5444 |
} |
| 5445 |
retValue = result.asRawBits(); |
| 5446 |
} |
| 5447 |
PREDICT_RETURN(); |
| 5448 |
DISPATCH_CACHEOP(); |
| 5449 |
} |
| 5450 |
|
| 5451 |
#undef PREDICT_NEXT |
| 5452 |
|
| 5453 |
#ifndef ENABLE_COMPUTED_GOTO_DISPATCH |
| 5454 |
default: |
| 5455 |
TRACE_PRINTF("unknown CacheOp\n"); |
| 5456 |
FAIL_IC(); |
| 5457 |
#endif |
| 5458 |
} |
| 5459 |
} |
| 5460 |
|
| 5461 |
#define CACHEOP_UNIMPL(name, ...) \ |
| 5462 |
cacheop_##name : __attribute__((unused)); \ |
| 5463 |
TRACE_PRINTF("unknown CacheOp: " #name "\n"); \ |
| 5464 |
FAIL_IC(); |
| 5465 |
CACHE_IR_OPS(CACHEOP_UNIMPL) |
| 5466 |
#undef CACHEOP_UNIMPL |
| 5467 |
|
| 5468 |
next_ic: |
| 5469 |
TRACE_PRINTF("IC failed; next IC\n"); |
| 5470 |
return CallNextIC(arg0, arg1, stub, ctx); |
| 5471 |
} |
| 5472 |
|
| 5473 |
static MOZ_NEVER_INLINE uint64_t CallNextIC(uint64_t arg0, uint64_t arg1, |
| 5474 |
ICStub* stub, ICCtx& ctx) { |
| 5475 |
stub = stub->maybeNext(); |
| 5476 |
MOZ_ASSERT(stub); |
| 5477 |
uint64_t result; |
| 5478 |
PBL_CALL_IC(stub->rawJitCode(), ctx, stub, result, arg0, arg1, ctx.arg2, |
| 5479 |
true); |
| 5480 |
return result; |
| 5481 |
} |
| 5482 |
|
| 5483 |
/* |
| 5484 |
* ----------------------------------------------- |
| 5485 |
* IC callsite logic, and fallback stubs |
| 5486 |
* ----------------------------------------------- |
| 5487 |
*/ |
| 5488 |
|
| 5489 |
#define DEFINE_IC(kind, arity, fallback_body) \ |
| 5490 |
static uint64_t MOZ_NEVER_INLINE IC##kind##Fallback( \ |
| 5491 |
uint64_t arg0, uint64_t arg1, ICStub* stub, ICCtx& ctx) { \ |
| 5492 |
uint64_t retValue = 0; \ |
| 5493 |
uint64_t arg2 = ctx.arg2; \ |
| 5494 |
(void)arg2; \ |
| 5495 |
ICFallbackStub* fallback = stub->toFallbackStub(); \ |
| 5496 |
StackVal* sp = ctx.sp(); \ |
| 5497 |
fallback_body; \ |
| 5498 |
retValue = ctx.state.res.asRawBits(); \ |
| 5499 |
ctx.state.res = UndefinedValue(); \ |
| 5500 |
return retValue; \ |
| 5501 |
error: \ |
| 5502 |
ctx.error = PBIResult::Error; \ |
| 5503 |
return IC_ERROR_SENTINEL(); \ |
| 5504 |
} |
| 5505 |
|
| 5506 |
#define DEFINE_IC_ALIAS(kind, target) \ |
| 5507 |
static uint64_t MOZ_NEVER_INLINE IC##kind##Fallback( \ |
| 5508 |
uint64_t arg0, uint64_t arg1, ICStub* stub, ICCtx& ctx) { \ |
| 5509 |
return IC##target##Fallback(arg0, arg1, stub, ctx); \ |
| 5510 |
} |
| 5511 |
|
| 5512 |
#define IC_LOAD_VAL(state_elem, index) \ |
| 5513 |
ReservedRooted<Value> state_elem(&ctx.state.state_elem, \ |
| 5514 |
Value::fromRawBits(arg##index)) |
| 5515 |
#define IC_LOAD_OBJ(state_elem, index) \ |
| 5516 |
ReservedRooted<JSObject*> state_elem( \ |
| 5517 |
&ctx.state.state_elem, reinterpret_cast<JSObject*>(arg##index)) |
| 5518 |
|
| 5519 |
DEFINE_IC(TypeOf, 1, { |
| 5520 |
IC_LOAD_VAL(value0, 0); |
| 5521 |
PUSH_FALLBACK_IC_FRAME(); |
| 5522 |
if (!DoTypeOfFallback(cx, ctx.frame, fallback, value0, &ctx.state.res)) { |
| 5523 |
goto error; |
| 5524 |
} |
| 5525 |
}); |
| 5526 |
|
| 5527 |
DEFINE_IC(TypeOfEq, 1, { |
| 5528 |
IC_LOAD_VAL(value0, 0); |
| 5529 |
PUSH_FALLBACK_IC_FRAME(); |
| 5530 |
if (!DoTypeOfEqFallback(cx, ctx.frame, fallback, value0, &ctx.state.res)) { |
| 5531 |
goto error; |
| 5532 |
} |
| 5533 |
}); |
| 5534 |
|
| 5535 |
DEFINE_IC(GetName, 1, { |
| 5536 |
IC_LOAD_OBJ(obj0, 0); |
| 5537 |
PUSH_FALLBACK_IC_FRAME(); |
| 5538 |
if (!DoGetNameFallback(cx, ctx.frame, fallback, obj0, &ctx.state.res)) { |
| 5539 |
goto error; |
| 5540 |
} |
| 5541 |
}); |
| 5542 |
|
| 5543 |
DEFINE_IC(Call, 1, { |
| 5544 |
uint32_t argc = uint32_t(arg0); |
| 5545 |
uint32_t totalArgs = |
| 5546 |
argc + ctx.icregs.extraArgs; // this, callee, (constructing?), func args |
| 5547 |
Value* args = reinterpret_cast<Value*>(&sp[0]); |
| 5548 |
TRACE_PRINTF("Call fallback: argc %d totalArgs %d args %p\n", argc, totalArgs, |
| 5549 |
args); |
| 5550 |
// Reverse values on the stack. |
| 5551 |
std::reverse(args, args + totalArgs); |
| 5552 |
{ |
| 5553 |
PUSH_FALLBACK_IC_FRAME(); |
| 5554 |
if (!DoCallFallback(cx, ctx.frame, fallback, argc, args, &ctx.state.res)) { |
| 5555 |
std::reverse(args, args + totalArgs); |
| 5556 |
goto error; |
| 5557 |
} |
| 5558 |
} |
| 5559 |
}); |
| 5560 |
|
| 5561 |
DEFINE_IC_ALIAS(CallConstructing, Call); |
| 5562 |
|
| 5563 |
DEFINE_IC(SpreadCall, 1, { |
| 5564 |
uint32_t argc = uint32_t(arg0); |
| 5565 |
uint32_t totalArgs = |
| 5566 |
argc + ctx.icregs.extraArgs; // this, callee, (constructing?), func args |
| 5567 |
Value* args = reinterpret_cast<Value*>(&sp[0]); |
| 5568 |
TRACE_PRINTF("Call fallback: argc %d totalArgs %d args %p\n", argc, totalArgs, |
| 5569 |
args); |
| 5570 |
// Reverse values on the stack. |
| 5571 |
std::reverse(args, args + totalArgs); |
| 5572 |
{ |
| 5573 |
PUSH_FALLBACK_IC_FRAME(); |
| 5574 |
if (!DoSpreadCallFallback(cx, ctx.frame, fallback, args, &ctx.state.res)) { |
| 5575 |
std::reverse(args, args + totalArgs); |
| 5576 |
goto error; |
| 5577 |
} |
| 5578 |
} |
| 5579 |
}); |
| 5580 |
|
| 5581 |
DEFINE_IC_ALIAS(SpreadCallConstructing, SpreadCall); |
| 5582 |
|
| 5583 |
DEFINE_IC(UnaryArith, 1, { |
| 5584 |
IC_LOAD_VAL(value0, 0); |
| 5585 |
PUSH_FALLBACK_IC_FRAME(); |
| 5586 |
if (!DoUnaryArithFallback(cx, ctx.frame, fallback, value0, &ctx.state.res)) { |
| 5587 |
goto error; |
| 5588 |
} |
| 5589 |
}); |
| 5590 |
|
| 5591 |
DEFINE_IC(BinaryArith, 2, { |
| 5592 |
IC_LOAD_VAL(value0, 0); |
| 5593 |
IC_LOAD_VAL(value1, 1); |
| 5594 |
PUSH_FALLBACK_IC_FRAME(); |
| 5595 |
if (!DoBinaryArithFallback(cx, ctx.frame, fallback, value0, value1, |
| 5596 |
&ctx.state.res)) { |
| 5597 |
goto error; |
| 5598 |
} |
| 5599 |
}); |
| 5600 |
|
| 5601 |
DEFINE_IC(ToBool, 1, { |
| 5602 |
IC_LOAD_VAL(value0, 0); |
| 5603 |
PUSH_FALLBACK_IC_FRAME(); |
| 5604 |
if (!DoToBoolFallback(cx, ctx.frame, fallback, value0, &ctx.state.res)) { |
| 5605 |
goto error; |
| 5606 |
} |
| 5607 |
}); |
| 5608 |
|
| 5609 |
DEFINE_IC(Compare, 2, { |
| 5610 |
IC_LOAD_VAL(value0, 0); |
| 5611 |
IC_LOAD_VAL(value1, 1); |
| 5612 |
PUSH_FALLBACK_IC_FRAME(); |
| 5613 |
if (!DoCompareFallback(cx, ctx.frame, fallback, value0, value1, |
| 5614 |
&ctx.state.res)) { |
| 5615 |
goto error; |
| 5616 |
} |
| 5617 |
}); |
| 5618 |
|
| 5619 |
DEFINE_IC(InstanceOf, 2, { |
| 5620 |
IC_LOAD_VAL(value0, 0); |
| 5621 |
IC_LOAD_VAL(value1, 1); |
| 5622 |
PUSH_FALLBACK_IC_FRAME(); |
| 5623 |
if (!DoInstanceOfFallback(cx, ctx.frame, fallback, value0, value1, |
| 5624 |
&ctx.state.res)) { |
| 5625 |
goto error; |
| 5626 |
} |
| 5627 |
}); |
| 5628 |
|
| 5629 |
DEFINE_IC(In, 2, { |
| 5630 |
IC_LOAD_VAL(value0, 0); |
| 5631 |
IC_LOAD_VAL(value1, 1); |
| 5632 |
PUSH_FALLBACK_IC_FRAME(); |
| 5633 |
if (!DoInFallback(cx, ctx.frame, fallback, value0, value1, &ctx.state.res)) { |
| 5634 |
goto error; |
| 5635 |
} |
| 5636 |
}); |
| 5637 |
|
| 5638 |
DEFINE_IC(BindName, 1, { |
| 5639 |
IC_LOAD_OBJ(obj0, 0); |
| 5640 |
PUSH_FALLBACK_IC_FRAME(); |
| 5641 |
if (!DoBindNameFallback(cx, ctx.frame, fallback, obj0, &ctx.state.res)) { |
| 5642 |
goto error; |
| 5643 |
} |
| 5644 |
}); |
| 5645 |
|
| 5646 |
DEFINE_IC(SetProp, 2, { |
| 5647 |
IC_LOAD_VAL(value0, 0); |
| 5648 |
IC_LOAD_VAL(value1, 1); |
| 5649 |
PUSH_FALLBACK_IC_FRAME(); |
| 5650 |
if (!DoSetPropFallback(cx, ctx.frame, fallback, nullptr, value0, value1)) { |
| 5651 |
goto error; |
| 5652 |
} |
| 5653 |
}); |
| 5654 |
|
| 5655 |
DEFINE_IC(NewObject, 0, { |
| 5656 |
PUSH_FALLBACK_IC_FRAME(); |
| 5657 |
if (!DoNewObjectFallback(cx, ctx.frame, fallback, &ctx.state.res)) { |
| 5658 |
goto error; |
| 5659 |
} |
| 5660 |
}); |
| 5661 |
|
| 5662 |
DEFINE_IC(GetProp, 1, { |
| 5663 |
IC_LOAD_VAL(value0, 0); |
| 5664 |
PUSH_FALLBACK_IC_FRAME(); |
| 5665 |
if (!DoGetPropFallback(cx, ctx.frame, fallback, &value0, &ctx.state.res)) { |
| 5666 |
goto error; |
| 5667 |
} |
| 5668 |
}); |
| 5669 |
|
| 5670 |
DEFINE_IC(GetPropSuper, 2, { |
| 5671 |
IC_LOAD_VAL(value0, 1); |
| 5672 |
IC_LOAD_VAL(value1, 0); |
| 5673 |
PUSH_FALLBACK_IC_FRAME(); |
| 5674 |
if (!DoGetPropSuperFallback(cx, ctx.frame, fallback, value0, &value1, |
| 5675 |
&ctx.state.res)) { |
| 5676 |
goto error; |
| 5677 |
} |
| 5678 |
}); |
| 5679 |
|
| 5680 |
DEFINE_IC(GetElem, 2, { |
| 5681 |
IC_LOAD_VAL(value0, 0); |
| 5682 |
IC_LOAD_VAL(value1, 1); |
| 5683 |
PUSH_FALLBACK_IC_FRAME(); |
| 5684 |
if (!DoGetElemFallback(cx, ctx.frame, fallback, value0, value1, |
| 5685 |
&ctx.state.res)) { |
| 5686 |
goto error; |
| 5687 |
} |
| 5688 |
}); |
| 5689 |
|
| 5690 |
DEFINE_IC(GetElemSuper, 3, { |
| 5691 |
IC_LOAD_VAL(value0, 0); // receiver |
| 5692 |
IC_LOAD_VAL(value1, 1); // obj (lhs) |
| 5693 |
IC_LOAD_VAL(value2, 2); // key (rhs) |
| 5694 |
PUSH_FALLBACK_IC_FRAME(); |
| 5695 |
if (!DoGetElemSuperFallback(cx, ctx.frame, fallback, value1, value2, value0, |
| 5696 |
&ctx.state.res)) { |
| 5697 |
goto error; |
| 5698 |
} |
| 5699 |
}); |
| 5700 |
|
| 5701 |
DEFINE_IC(GetImport, 0, { |
| 5702 |
PUSH_FALLBACK_IC_FRAME(); |
| 5703 |
if (!DoGetImportFallback(cx, ctx.frame, fallback, &ctx.state.res)) { |
| 5704 |
goto error; |
| 5705 |
} |
| 5706 |
}); |
| 5707 |
|
| 5708 |
DEFINE_IC(NewArray, 0, { |
| 5709 |
PUSH_FALLBACK_IC_FRAME(); |
| 5710 |
if (!DoNewArrayFallback(cx, ctx.frame, fallback, &ctx.state.res)) { |
| 5711 |
goto error; |
| 5712 |
} |
| 5713 |
}); |
| 5714 |
|
| 5715 |
DEFINE_IC(Lambda, 0, { |
| 5716 |
PUSH_FALLBACK_IC_FRAME(); |
| 5717 |
if (!DoLambdaFallback(cx, ctx.frame, fallback, &ctx.state.res)) { |
| 5718 |
goto error; |
| 5719 |
} |
| 5720 |
}); |
| 5721 |
|
| 5722 |
DEFINE_IC(LazyConstant, 0, { |
| 5723 |
PUSH_FALLBACK_IC_FRAME(); |
| 5724 |
if (!DoLazyConstantFallback(cx, ctx.frame, fallback, &ctx.state.res)) { |
| 5725 |
goto error; |
| 5726 |
} |
| 5727 |
}); |
| 5728 |
|
| 5729 |
DEFINE_IC(SetElem, 3, { |
| 5730 |
IC_LOAD_VAL(value0, 0); |
| 5731 |
IC_LOAD_VAL(value1, 1); |
| 5732 |
IC_LOAD_VAL(value2, 2); |
| 5733 |
PUSH_FALLBACK_IC_FRAME(); |
| 5734 |
if (!DoSetElemFallback(cx, ctx.frame, fallback, nullptr, value0, value1, |
| 5735 |
value2)) { |
| 5736 |
goto error; |
| 5737 |
} |
| 5738 |
}); |
| 5739 |
|
| 5740 |
DEFINE_IC(HasOwn, 2, { |
| 5741 |
IC_LOAD_VAL(value0, 0); |
| 5742 |
IC_LOAD_VAL(value1, 1); |
| 5743 |
PUSH_FALLBACK_IC_FRAME(); |
| 5744 |
if (!DoHasOwnFallback(cx, ctx.frame, fallback, value0, value1, |
| 5745 |
&ctx.state.res)) { |
| 5746 |
goto error; |
| 5747 |
} |
| 5748 |
}); |
| 5749 |
|
| 5750 |
DEFINE_IC(CheckPrivateField, 2, { |
| 5751 |
IC_LOAD_VAL(value0, 0); |
| 5752 |
IC_LOAD_VAL(value1, 1); |
| 5753 |
PUSH_FALLBACK_IC_FRAME(); |
| 5754 |
if (!DoCheckPrivateFieldFallback(cx, ctx.frame, fallback, value0, value1, |
| 5755 |
&ctx.state.res)) { |
| 5756 |
goto error; |
| 5757 |
} |
| 5758 |
}); |
| 5759 |
|
| 5760 |
DEFINE_IC(GetIterator, 1, { |
| 5761 |
IC_LOAD_VAL(value0, 0); |
| 5762 |
PUSH_FALLBACK_IC_FRAME(); |
| 5763 |
if (!DoGetIteratorFallback(cx, ctx.frame, fallback, value0, &ctx.state.res)) { |
| 5764 |
goto error; |
| 5765 |
} |
| 5766 |
}); |
| 5767 |
|
| 5768 |
DEFINE_IC(ToPropertyKey, 1, { |
| 5769 |
IC_LOAD_VAL(value0, 0); |
| 5770 |
PUSH_FALLBACK_IC_FRAME(); |
| 5771 |
if (!DoToPropertyKeyFallback(cx, ctx.frame, fallback, value0, |
| 5772 |
&ctx.state.res)) { |
| 5773 |
goto error; |
| 5774 |
} |
| 5775 |
}); |
| 5776 |
|
| 5777 |
DEFINE_IC(OptimizeSpreadCall, 1, { |
| 5778 |
IC_LOAD_VAL(value0, 0); |
| 5779 |
PUSH_FALLBACK_IC_FRAME(); |
| 5780 |
if (!DoOptimizeSpreadCallFallback(cx, ctx.frame, fallback, value0, |
| 5781 |
&ctx.state.res)) { |
| 5782 |
goto error; |
| 5783 |
} |
| 5784 |
}); |
| 5785 |
|
| 5786 |
DEFINE_IC(OptimizeGetIterator, 1, { |
| 5787 |
IC_LOAD_VAL(value0, 0); |
| 5788 |
PUSH_FALLBACK_IC_FRAME(); |
| 5789 |
if (!DoOptimizeGetIteratorFallback(cx, ctx.frame, fallback, value0, |
| 5790 |
&ctx.state.res)) { |
| 5791 |
goto error; |
| 5792 |
} |
| 5793 |
}); |
| 5794 |
|
| 5795 |
DEFINE_IC(Rest, 0, { |
| 5796 |
PUSH_FALLBACK_IC_FRAME(); |
| 5797 |
if (!DoRestFallback(cx, ctx.frame, fallback, &ctx.state.res)) { |
| 5798 |
goto error; |
| 5799 |
} |
| 5800 |
}); |
| 5801 |
|
| 5802 |
DEFINE_IC(CloseIter, 1, { |
| 5803 |
IC_LOAD_OBJ(obj0, 0); |
| 5804 |
PUSH_FALLBACK_IC_FRAME(); |
| 5805 |
if (!DoCloseIterFallback(cx, ctx.frame, fallback, obj0)) { |
| 5806 |
goto error; |
| 5807 |
} |
| 5808 |
}); |
| 5809 |
|
| 5810 |
uint8_t* GetPortableFallbackStub(BaselineICFallbackKind kind) { |
| 5811 |
switch (kind) { |
| 5812 |
#define _(ty) \ |
| 5813 |
case BaselineICFallbackKind::ty: \ |
| 5814 |
return reinterpret_cast<uint8_t*>(&IC##ty##Fallback); |
| 5815 |
IC_BASELINE_FALLBACK_CODE_KIND_LIST(_) |
| 5816 |
#undef _ |
| 5817 |
case BaselineICFallbackKind::Count: |
| 5818 |
MOZ_CRASH("Invalid kind"); |
| 5819 |
} |
| 5820 |
} |
| 5821 |
|
| 5822 |
uint8_t* GetICInterpreter() { |
| 5823 |
return reinterpret_cast<uint8_t*>(&ICInterpretOps); |
| 5824 |
} |
| 5825 |
|
| 5826 |
/* |
| 5827 |
* ----------------------------------------------- |
| 5828 |
* Main JSOp interpreter |
| 5829 |
* ----------------------------------------------- |
| 5830 |
*/ |
| 5831 |
|
| 5832 |
static EnvironmentObject& getEnvironmentFromCoordinate( |
| 5833 |
BaselineFrame* frame, EnvironmentCoordinate ec) { |
| 5834 |
JSObject* env = frame->environmentChain(); |
| 5835 |
for (unsigned i = ec.hops(); i; i--) { |
| 5836 |
if (env->is<EnvironmentObject>()) { |
| 5837 |
env = &env->as<EnvironmentObject>().enclosingEnvironment(); |
| 5838 |
} else { |
| 5839 |
MOZ_ASSERT(env->is<DebugEnvironmentProxy>()); |
| 5840 |
env = &env->as<DebugEnvironmentProxy>().enclosingEnvironment(); |
| 5841 |
} |
| 5842 |
} |
| 5843 |
return env->is<EnvironmentObject>() |
| 5844 |
? env->as<EnvironmentObject>() |
| 5845 |
: env->as<DebugEnvironmentProxy>().environment(); |
| 5846 |
} |
| 5847 |
|
| 5848 |
#ifndef __wasi__ |
| 5849 |
# define DEBUG_CHECK() \ |
| 5850 |
if (frame->isDebuggee()) { \ |
| 5851 |
TRACE_PRINTF( \ |
| 5852 |
"Debug check: frame is debuggee, checking for debug script\n"); \ |
| 5853 |
if (frame->script()->hasDebugScript()) { \ |
| 5854 |
goto debug; \ |
| 5855 |
} \ |
| 5856 |
} |
| 5857 |
#else |
| 5858 |
# define DEBUG_CHECK() |
| 5859 |
#endif |
| 5860 |
|
| 5861 |
#define LABEL(op) (&&label_##op) |
| 5862 |
#ifdef ENABLE_COMPUTED_GOTO_DISPATCH |
| 5863 |
# define CASE(op) label_##op: |
| 5864 |
# define DISPATCH() \ |
| 5865 |
DEBUG_CHECK(); \ |
| 5866 |
goto* addresses[*pc] |
| 5867 |
#else |
| 5868 |
# define CASE(op) label_##op : case JSOp::op: |
| 5869 |
# define DISPATCH() \ |
| 5870 |
DEBUG_CHECK(); \ |
| 5871 |
goto dispatch |
| 5872 |
#endif |
| 5873 |
|
| 5874 |
#define ADVANCE(delta) pc += (delta); |
| 5875 |
#define ADVANCE_AND_DISPATCH(delta) \ |
| 5876 |
ADVANCE(delta); \ |
| 5877 |
DISPATCH(); |
| 5878 |
|
| 5879 |
#define END_OP(op) ADVANCE_AND_DISPATCH(JSOpLength_##op); |
| 5880 |
|
| 5881 |
#define VIRTPUSH(value) PUSH(value) |
| 5882 |
#define VIRTPOP() POP() |
| 5883 |
#define VIRTSP(index) sp[(index)] |
| 5884 |
#define VIRTSPWRITE(index, value) sp[(index)] = (value) |
| 5885 |
#define SYNCSP() |
| 5886 |
#define SETLOCAL(i, value) frame->unaliasedLocal(i) = value |
| 5887 |
#define GETLOCAL(i) frame->unaliasedLocal(i) |
| 5888 |
|
| 5889 |
#define IC_SET_ARG_FROM_STACK(index, stack_index) \ |
| 5890 |
ic_arg##index = sp[(stack_index)].asUInt64(); |
| 5891 |
#define IC_POP_ARG(index) ic_arg##index = (*sp++).asUInt64(); |
| 5892 |
#define IC_SET_VAL_ARG(index, expr) ic_arg##index = (expr).asRawBits(); |
| 5893 |
#define IC_SET_OBJ_ARG(index, expr) \ |
| 5894 |
ic_arg##index = reinterpret_cast<uint64_t>(expr); |
| 5895 |
#define IC_ZERO_ARG(index) ic_arg##index = 0; |
| 5896 |
#define IC_PUSH_RESULT() VIRTPUSH(StackVal(ic_ret)); |
| 5897 |
|
| 5898 |
#if !defined(TRACE_INTERP) |
| 5899 |
# define PREDICT_NEXT(op) \ |
| 5900 |
if (JSOp(*pc) == JSOp::op) { \ |
| 5901 |
DEBUG_CHECK(); \ |
| 5902 |
goto label_##op; \ |
| 5903 |
} |
| 5904 |
#else |
| 5905 |
# define PREDICT_NEXT(op) |
| 5906 |
#endif |
| 5907 |
|
| 5908 |
#ifdef ENABLE_COVERAGE |
| 5909 |
# define COUNT_COVERAGE_PC(PC) \ |
| 5910 |
if (frame->script()->hasScriptCounts()) { \ |
| 5911 |
PCCounts* counts = frame->script()->maybeGetPCCounts(PC); \ |
| 5912 |
MOZ_ASSERT(counts); \ |
| 5913 |
counts->numExec()++; \ |
| 5914 |
} |
| 5915 |
# define COUNT_COVERAGE_MAIN() \ |
| 5916 |
{ \ |
| 5917 |
jsbytecode* main = frame->script()->main(); \ |
| 5918 |
if (!BytecodeIsJumpTarget(JSOp(*main))) COUNT_COVERAGE_PC(main); \ |
| 5919 |
} |
| 5920 |
#else |
| 5921 |
# define COUNT_COVERAGE_PC(PC) ; |
| 5922 |
# define COUNT_COVERAGE_MAIN() ; |
| 5923 |
#endif |
| 5924 |
|
| 5925 |
#define NEXT_IC() icEntry++ |
| 5926 |
|
| 5927 |
#define INVOKE_IC(kind, hasarg2) \ |
| 5928 |
ctx.sp_ = sp; \ |
| 5929 |
frame->interpreterPC() = pc; \ |
| 5930 |
frame->interpreterICEntry() = icEntry; \ |
| 5931 |
SYNCSP(); \ |
| 5932 |
PBL_CALL_IC(icEntry->firstStub()->rawJitCode(), ctx, icEntry->firstStub(), \ |
| 5933 |
ic_ret, ic_arg0, ic_arg1, ic_arg2, hasarg2); \ |
| 5934 |
if (ic_ret == IC_ERROR_SENTINEL()) { \ |
| 5935 |
ic_result = ctx.error; \ |
| 5936 |
goto ic_fail; \ |
| 5937 |
} \ |
| 5938 |
NEXT_IC(); |
| 5939 |
|
| 5940 |
#define INVOKE_IC_AND_PUSH(kind, hasarg2) \ |
| 5941 |
INVOKE_IC(kind, hasarg2); \ |
| 5942 |
VIRTPUSH(StackVal(ic_ret)); |
| 5943 |
|
| 5944 |
#define VIRTPOPN(n) \ |
| 5945 |
SYNCSP(); \ |
| 5946 |
POPN(n); |
| 5947 |
|
| 5948 |
#define SPHANDLE(index) \ |
| 5949 |
({ \ |
| 5950 |
SYNCSP(); \ |
| 5951 |
Stack::handle(&sp[(index)]); \ |
| 5952 |
}) |
| 5953 |
#define SPHANDLEMUT(index) \ |
| 5954 |
({ \ |
| 5955 |
SYNCSP(); \ |
| 5956 |
Stack::handleMut(&sp[(index)]); \ |
| 5957 |
}) |
| 5958 |
|
| 5959 |
template <bool IsRestart, bool HybridICs> |
| 5960 |
PBIResult PortableBaselineInterpret( |
| 5961 |
JSContext* cx_, State& state, Stack& stack, StackVal* sp, |
| 5962 |
JSObject* envChain, Value* ret, jsbytecode* pc, ImmutableScriptData* isd, |
| 5963 |
jsbytecode* restartEntryPC, BaselineFrame* restartFrame, |
| 5964 |
StackVal* restartEntryFrame, PBIResult restartCode) { |
| 5965 |
#define RESTART(code) \ |
| 5966 |
if (!IsRestart) { \ |
| 5967 |
TRACE_PRINTF("Restarting (code %d sp %p fp %p)\n", int(code), sp, \ |
| 5968 |
ctx.stack.fp); \ |
| 5969 |
SYNCSP(); \ |
| 5970 |
restartCode = code; \ |
| 5971 |
goto restart; \ |
| 5972 |
} |
| 5973 |
|
| 5974 |
#define GOTO_ERROR() \ |
| 5975 |
do { \ |
| 5976 |
SYNCSP(); \ |
| 5977 |
RESTART(PBIResult::Error); \ |
| 5978 |
goto error; \ |
| 5979 |
} while (0) |
| 5980 |
|
| 5981 |
// Update local state when we switch to a new script with a new PC. |
| 5982 |
#define RESET_PC(new_pc, new_script) \ |
| 5983 |
pc = new_pc; \ |
| 5984 |
entryPC = new_script->code(); \ |
| 5985 |
isd = new_script->immutableScriptData(); \ |
| 5986 |
icEntries = frame->icScript()->icEntries(); \ |
| 5987 |
icEntry = frame->interpreterICEntry(); \ |
| 5988 |
argsObjAliasesFormals = frame->script()->argsObjAliasesFormals(); \ |
| 5989 |
resumeOffsets = isd->resumeOffsets().data(); |
| 5990 |
|
| 5991 |
#define OPCODE_LABEL(op, ...) LABEL(op), |
| 5992 |
#define TRAILING_LABEL(v) LABEL(default), |
| 5993 |
|
| 5994 |
static const void* const addresses[EnableInterruptsPseudoOpcode + 1] = { |
| 5995 |
FOR_EACH_OPCODE(OPCODE_LABEL) |
| 5996 |
FOR_EACH_TRAILING_UNUSED_OPCODE(TRAILING_LABEL)}; |
| 5997 |
|
| 5998 |
#undef OPCODE_LABEL |
| 5999 |
#undef TRAILING_LABEL |
| 6000 |
|
| 6001 |
BaselineFrame* frame = restartFrame; |
| 6002 |
StackVal* entryFrame = restartEntryFrame; |
| 6003 |
jsbytecode* entryPC = restartEntryPC; |
| 6004 |
|
| 6005 |
if (!IsRestart) { |
| 6006 |
PUSHNATIVE(StackValNative(nullptr)); // Fake return address. |
| 6007 |
frame = stack.pushFrame(sp, cx_, envChain); |
| 6008 |
MOZ_ASSERT(frame); // safety: stack margin. |
| 6009 |
sp = reinterpret_cast<StackVal*>(frame); |
| 6010 |
// Save the entry frame so that when unwinding, we know when to |
| 6011 |
// return from this C++ frame. |
| 6012 |
entryFrame = sp; |
| 6013 |
// Save the entry PC so that we can compute offsets locally. |
| 6014 |
entryPC = pc; |
| 6015 |
} |
| 6016 |
|
| 6017 |
bool from_unwind = false; |
| 6018 |
uint32_t nfixed = frame->script()->nfixed(); |
| 6019 |
bool argsObjAliasesFormals = frame->script()->argsObjAliasesFormals(); |
| 6020 |
|
| 6021 |
PBIResult ic_result = PBIResult::Ok; |
| 6022 |
uint64_t ic_arg0 = 0, ic_arg1 = 0, ic_arg2 = 0, ic_ret = 0; |
| 6023 |
|
| 6024 |
ICCtx ctx(cx_, frame, state, stack); |
| 6025 |
auto* icEntries = frame->icScript()->icEntries(); |
| 6026 |
auto* icEntry = icEntries; |
| 6027 |
const uint32_t* resumeOffsets = isd->resumeOffsets().data(); |
| 6028 |
|
| 6029 |
if (IsRestart) { |
| 6030 |
ic_result = restartCode; |
| 6031 |
TRACE_PRINTF( |
| 6032 |
"Enter from restart: sp = %p ctx.stack.fp = %p ctx.frame = %p\n", sp, |
| 6033 |
ctx.stack.fp, ctx.frame); |
| 6034 |
goto ic_fail; |
| 6035 |
} else { |
| 6036 |
AutoCheckRecursionLimit recursion(ctx.frameMgr.cxForLocalUseOnly()); |
| 6037 |
if (!recursion.checkDontReport(ctx.frameMgr.cxForLocalUseOnly())) { |
| 6038 |
PUSH_EXIT_FRAME(); |
| 6039 |
ReportOverRecursed(ctx.frameMgr.cxForLocalUseOnly()); |
| 6040 |
return PBIResult::Error; |
| 6041 |
} |
| 6042 |
} |
| 6043 |
|
| 6044 |
// Check max stack depth once, so we don't need to check it |
| 6045 |
// otherwise below for ordinary stack-manipulation opcodes (just for |
| 6046 |
// exit frames). |
| 6047 |
if (!ctx.stack.check(sp, sizeof(StackVal) * frame->script()->nslots())) { |
| 6048 |
PUSH_EXIT_FRAME(); |
| 6049 |
ReportOverRecursed(ctx.frameMgr.cxForLocalUseOnly()); |
| 6050 |
return PBIResult::Error; |
| 6051 |
} |
| 6052 |
|
| 6053 |
SYNCSP(); |
| 6054 |
sp -= nfixed; |
| 6055 |
for (uint32_t i = 0; i < nfixed; i++) { |
| 6056 |
sp[i] = StackVal(UndefinedValue()); |
| 6057 |
} |
| 6058 |
ret->setUndefined(); |
| 6059 |
|
| 6060 |
// Check if we are being debugged, and set a flag in the frame if so. This |
| 6061 |
// flag must be set before calling InitFunctionEnvironmentObjects. |
| 6062 |
if (frame->script()->isDebuggee()) { |
| 6063 |
TRACE_PRINTF("Script is debuggee\n"); |
| 6064 |
frame->setIsDebuggee(); |
| 6065 |
} |
| 6066 |
|
| 6067 |
if (CalleeTokenIsFunction(frame->calleeToken())) { |
| 6068 |
JSFunction* func = CalleeTokenToFunction(frame->calleeToken()); |
| 6069 |
frame->setEnvironmentChain(func->environment()); |
| 6070 |
if (func->needsFunctionEnvironmentObjects()) { |
| 6071 |
PUSH_EXIT_FRAME(); |
| 6072 |
if (!js::InitFunctionEnvironmentObjects(cx, frame)) { |
| 6073 |
GOTO_ERROR(); |
| 6074 |
} |
| 6075 |
TRACE_PRINTF("callee is func %p; created environment object: %p\n", func, |
| 6076 |
frame->environmentChain()); |
| 6077 |
} |
| 6078 |
} |
| 6079 |
|
| 6080 |
// The debug prologue can't run until the function environment is set up. |
| 6081 |
if (frame->script()->isDebuggee()) { |
| 6082 |
PUSH_EXIT_FRAME(); |
| 6083 |
if (!DebugPrologue(cx, frame)) { |
| 6084 |
GOTO_ERROR(); |
| 6085 |
} |
| 6086 |
} |
| 6087 |
|
| 6088 |
if (!frame->script()->hasScriptCounts()) { |
| 6089 |
if (ctx.frameMgr.cxForLocalUseOnly()->realm()->collectCoverageForDebug()) { |
| 6090 |
PUSH_EXIT_FRAME(); |
| 6091 |
if (!frame->script()->initScriptCounts(cx)) { |
| 6092 |
GOTO_ERROR(); |
| 6093 |
} |
| 6094 |
} |
| 6095 |
} |
| 6096 |
COUNT_COVERAGE_MAIN(); |
| 6097 |
|
| 6098 |
#ifdef ENABLE_INTERRUPT_CHECKS |
| 6099 |
if (ctx.frameMgr.cxForLocalUseOnly()->hasAnyPendingInterrupt()) { |
| 6100 |
PUSH_EXIT_FRAME(); |
| 6101 |
if (!InterruptCheck(cx)) { |
| 6102 |
GOTO_ERROR(); |
| 6103 |
} |
| 6104 |
} |
| 6105 |
#endif |
| 6106 |
|
| 6107 |
TRACE_PRINTF("Entering: sp = %p fp = %p frame = %p, script = %p, pc = %p\n", |
| 6108 |
sp, ctx.stack.fp, frame, frame->script(), pc); |
| 6109 |
TRACE_PRINTF("nslots = %d nfixed = %d\n", int(frame->script()->nslots()), |
| 6110 |
int(frame->script()->nfixed())); |
| 6111 |
|
| 6112 |
while (true) { |
| 6113 |
DEBUG_CHECK(); |
| 6114 |
|
| 6115 |
#if !defined(ENABLE_COMPUTED_GOTO_DISPATCH) || !defined(__wasi__) |
| 6116 |
dispatch: |
| 6117 |
#endif |
| 6118 |
|
| 6119 |
#ifdef TRACE_INTERP |
| 6120 |
{ |
| 6121 |
JSOp op = JSOp(*pc); |
| 6122 |
printf("sp[0] = %" PRIx64 " sp[1] = %" PRIx64 " sp[2] = %" PRIx64 "\n", |
| 6123 |
sp[0].asUInt64(), sp[1].asUInt64(), sp[2].asUInt64()); |
| 6124 |
printf("script = %p pc = %p: %s (ic %d entry %p) pending = %d\n", |
| 6125 |
frame->script(), pc, CodeName(op), (int)(icEntry - icEntries), |
| 6126 |
icEntry, ctx.frameMgr.cxForLocalUseOnly()->isExceptionPending()); |
| 6127 |
printf("sp = %p fp = %p\n", sp, ctx.stack.fp); |
| 6128 |
printf("TOS tag: %d\n", int(sp[0].asValue().asRawBits() >> 47)); |
| 6129 |
fflush(stdout); |
| 6130 |
} |
| 6131 |
#endif |
| 6132 |
|
| 6133 |
#ifdef ENABLE_COMPUTED_GOTO_DISPATCH |
| 6134 |
goto* addresses[*pc]; |
| 6135 |
#else |
| 6136 |
(void)addresses; // Avoid unused-local error. We keep the table |
| 6137 |
// itself to avoid warnings (see note in IC |
| 6138 |
// interpreter above). |
| 6139 |
switch (JSOp(*pc)) |
| 6140 |
#endif |
| 6141 |
{ |
| 6142 |
CASE(Nop) { END_OP(Nop); } |
| 6143 |
CASE(NopIsAssignOp) { END_OP(NopIsAssignOp); } |
| 6144 |
CASE(Undefined) { |
| 6145 |
VIRTPUSH(StackVal(UndefinedValue())); |
| 6146 |
END_OP(Undefined); |
| 6147 |
} |
| 6148 |
CASE(Null) { |
| 6149 |
VIRTPUSH(StackVal(NullValue())); |
| 6150 |
END_OP(Null); |
| 6151 |
} |
| 6152 |
CASE(False) { |
| 6153 |
VIRTPUSH(StackVal(BooleanValue(false))); |
| 6154 |
END_OP(False); |
| 6155 |
} |
| 6156 |
CASE(True) { |
| 6157 |
VIRTPUSH(StackVal(BooleanValue(true))); |
| 6158 |
END_OP(True); |
| 6159 |
} |
| 6160 |
CASE(Int32) { |
| 6161 |
VIRTPUSH(StackVal(Int32Value(GET_INT32(pc)))); |
| 6162 |
END_OP(Int32); |
| 6163 |
} |
| 6164 |
CASE(Zero) { |
| 6165 |
VIRTPUSH(StackVal(Int32Value(0))); |
| 6166 |
END_OP(Zero); |
| 6167 |
} |
| 6168 |
CASE(One) { |
| 6169 |
VIRTPUSH(StackVal(Int32Value(1))); |
| 6170 |
END_OP(One); |
| 6171 |
} |
| 6172 |
CASE(Int8) { |
| 6173 |
VIRTPUSH(StackVal(Int32Value(GET_INT8(pc)))); |
| 6174 |
END_OP(Int8); |
| 6175 |
} |
| 6176 |
CASE(Uint16) { |
| 6177 |
VIRTPUSH(StackVal(Int32Value(GET_UINT16(pc)))); |
| 6178 |
END_OP(Uint16); |
| 6179 |
} |
| 6180 |
CASE(Uint24) { |
| 6181 |
VIRTPUSH(StackVal(Int32Value(GET_UINT24(pc)))); |
| 6182 |
END_OP(Uint24); |
| 6183 |
} |
| 6184 |
CASE(Double) { |
| 6185 |
VIRTPUSH(StackVal(GET_INLINE_VALUE(pc))); |
| 6186 |
END_OP(Double); |
| 6187 |
} |
| 6188 |
CASE(BigInt) { |
| 6189 |
VIRTPUSH(StackVal(JS::BigIntValue(frame->script()->getBigInt(pc)))); |
| 6190 |
END_OP(BigInt); |
| 6191 |
} |
| 6192 |
CASE(String) { |
| 6193 |
VIRTPUSH(StackVal(StringValue(frame->script()->getString(pc)))); |
| 6194 |
END_OP(String); |
| 6195 |
} |
| 6196 |
CASE(Symbol) { |
| 6197 |
VIRTPUSH(StackVal(SymbolValue( |
| 6198 |
ctx.frameMgr.cxForLocalUseOnly()->wellKnownSymbols().get( |
| 6199 |
GET_UINT8(pc))))); |
| 6200 |
END_OP(Symbol); |
| 6201 |
} |
| 6202 |
CASE(Void) { |
| 6203 |
VIRTSPWRITE(0, StackVal(JS::UndefinedValue())); |
| 6204 |
END_OP(Void); |
| 6205 |
} |
| 6206 |
|
| 6207 |
CASE(Typeof) |
| 6208 |
CASE(TypeofExpr) { |
| 6209 |
static_assert(JSOpLength_Typeof == JSOpLength_TypeofExpr); |
| 6210 |
if (HybridICs) { |
| 6211 |
SYNCSP(); |
| 6212 |
VIRTSPWRITE( |
| 6213 |
0, |
| 6214 |
StackVal(StringValue(TypeOfOperation( |
| 6215 |
SPHANDLE(0), ctx.frameMgr.cxForLocalUseOnly()->runtime())))); |
| 6216 |
NEXT_IC(); |
| 6217 |
} else { |
| 6218 |
IC_POP_ARG(0); |
| 6219 |
IC_ZERO_ARG(1); |
| 6220 |
IC_ZERO_ARG(2); |
| 6221 |
INVOKE_IC_AND_PUSH(TypeOf, false); |
| 6222 |
} |
| 6223 |
END_OP(Typeof); |
| 6224 |
} |
| 6225 |
|
| 6226 |
CASE(TypeofEq) { |
| 6227 |
if (HybridICs) { |
| 6228 |
TypeofEqOperand operand = |
| 6229 |
TypeofEqOperand::fromRawValue(GET_UINT8(pc)); |
| 6230 |
bool result = js::TypeOfValue(SPHANDLE(0)) == operand.type(); |
| 6231 |
if (operand.compareOp() == JSOp::Ne) { |
| 6232 |
result = !result; |
| 6233 |
} |
| 6234 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6235 |
NEXT_IC(); |
| 6236 |
} else { |
| 6237 |
IC_POP_ARG(0); |
| 6238 |
IC_ZERO_ARG(1); |
| 6239 |
IC_ZERO_ARG(2); |
| 6240 |
INVOKE_IC_AND_PUSH(TypeOfEq, false); |
| 6241 |
} |
| 6242 |
END_OP(TypeofEq); |
| 6243 |
} |
| 6244 |
|
| 6245 |
CASE(Pos) { |
| 6246 |
if (VIRTSP(0).asValue().isNumber()) { |
| 6247 |
// Nothing! |
| 6248 |
NEXT_IC(); |
| 6249 |
END_OP(Pos); |
| 6250 |
} else { |
| 6251 |
goto generic_unary; |
| 6252 |
} |
| 6253 |
} |
| 6254 |
CASE(Neg) { |
| 6255 |
Value v = VIRTSP(0).asValue(); |
| 6256 |
if (v.isInt32()) { |
| 6257 |
int32_t i = v.toInt32(); |
| 6258 |
if (i != 0 && i != INT32_MIN) { |
| 6259 |
VIRTSPWRITE(0, StackVal(Int32Value(-i))); |
| 6260 |
NEXT_IC(); |
| 6261 |
END_OP(Neg); |
| 6262 |
} |
| 6263 |
} |
| 6264 |
if (v.isNumber()) { |
| 6265 |
VIRTSPWRITE(0, StackVal(NumberValue(-v.toNumber()))); |
| 6266 |
NEXT_IC(); |
| 6267 |
END_OP(Neg); |
| 6268 |
} |
| 6269 |
goto generic_unary; |
| 6270 |
} |
| 6271 |
|
| 6272 |
CASE(Inc) { |
| 6273 |
Value v = VIRTSP(0).asValue(); |
| 6274 |
if (v.isInt32()) { |
| 6275 |
int32_t i = v.toInt32(); |
| 6276 |
if (i != INT32_MAX) { |
| 6277 |
VIRTSPWRITE(0, StackVal(Int32Value(i + 1))); |
| 6278 |
NEXT_IC(); |
| 6279 |
END_OP(Inc); |
| 6280 |
} |
| 6281 |
} |
| 6282 |
if (v.isNumber()) { |
| 6283 |
VIRTSPWRITE(0, StackVal(NumberValue(v.toNumber() + 1))); |
| 6284 |
NEXT_IC(); |
| 6285 |
END_OP(Inc); |
| 6286 |
} |
| 6287 |
goto generic_unary; |
| 6288 |
} |
| 6289 |
CASE(Dec) { |
| 6290 |
Value v = VIRTSP(0).asValue(); |
| 6291 |
if (v.isInt32()) { |
| 6292 |
int32_t i = v.toInt32(); |
| 6293 |
if (i != INT32_MIN) { |
| 6294 |
VIRTSPWRITE(0, StackVal(Int32Value(i - 1))); |
| 6295 |
NEXT_IC(); |
| 6296 |
END_OP(Dec); |
| 6297 |
} |
| 6298 |
} |
| 6299 |
if (v.isNumber()) { |
| 6300 |
VIRTSPWRITE(0, StackVal(NumberValue(v.toNumber() - 1))); |
| 6301 |
NEXT_IC(); |
| 6302 |
END_OP(Dec); |
| 6303 |
} |
| 6304 |
goto generic_unary; |
| 6305 |
} |
| 6306 |
|
| 6307 |
CASE(BitNot) { |
| 6308 |
Value v = VIRTSP(0).asValue(); |
| 6309 |
if (v.isInt32()) { |
| 6310 |
int32_t i = v.toInt32(); |
| 6311 |
VIRTSPWRITE(0, StackVal(Int32Value(~i))); |
| 6312 |
NEXT_IC(); |
| 6313 |
END_OP(Inc); |
| 6314 |
} |
| 6315 |
goto generic_unary; |
| 6316 |
} |
| 6317 |
|
| 6318 |
CASE(ToNumeric) { |
| 6319 |
if (VIRTSP(0).asValue().isNumeric()) { |
| 6320 |
NEXT_IC(); |
| 6321 |
} else if (HybridICs) { |
| 6322 |
SYNCSP(); |
| 6323 |
MutableHandleValue val = SPHANDLEMUT(0); |
| 6324 |
PUSH_EXIT_FRAME(); |
| 6325 |
if (!ToNumeric(cx, val)) { |
| 6326 |
GOTO_ERROR(); |
| 6327 |
} |
| 6328 |
NEXT_IC(); |
| 6329 |
} else { |
| 6330 |
goto generic_unary; |
| 6331 |
} |
| 6332 |
END_OP(ToNumeric); |
| 6333 |
} |
| 6334 |
|
| 6335 |
generic_unary:; |
| 6336 |
{ |
| 6337 |
static_assert(JSOpLength_Pos == JSOpLength_Neg); |
| 6338 |
static_assert(JSOpLength_Pos == JSOpLength_BitNot); |
| 6339 |
static_assert(JSOpLength_Pos == JSOpLength_Inc); |
| 6340 |
static_assert(JSOpLength_Pos == JSOpLength_Dec); |
| 6341 |
static_assert(JSOpLength_Pos == JSOpLength_ToNumeric); |
| 6342 |
IC_POP_ARG(0); |
| 6343 |
IC_ZERO_ARG(1); |
| 6344 |
IC_ZERO_ARG(2); |
| 6345 |
INVOKE_IC_AND_PUSH(UnaryArith, false); |
| 6346 |
END_OP(Pos); |
| 6347 |
} |
| 6348 |
|
| 6349 |
CASE(Not) { |
| 6350 |
Value v = VIRTSP(0).asValue(); |
| 6351 |
if (v.isBoolean()) { |
| 6352 |
VIRTSPWRITE(0, StackVal(BooleanValue(!v.toBoolean()))); |
| 6353 |
NEXT_IC(); |
| 6354 |
} else if (HybridICs) { |
| 6355 |
SYNCSP(); |
| 6356 |
VIRTSPWRITE(0, StackVal(BooleanValue(!ToBoolean(SPHANDLE(0))))); |
| 6357 |
NEXT_IC(); |
| 6358 |
} else { |
| 6359 |
IC_POP_ARG(0); |
| 6360 |
IC_ZERO_ARG(1); |
| 6361 |
IC_ZERO_ARG(2); |
| 6362 |
INVOKE_IC(ToBool, false); |
| 6363 |
VIRTPUSH( |
| 6364 |
StackVal(BooleanValue(!Value::fromRawBits(ic_ret).toBoolean()))); |
| 6365 |
} |
| 6366 |
END_OP(Not); |
| 6367 |
} |
| 6368 |
|
| 6369 |
CASE(And) { |
| 6370 |
bool result; |
| 6371 |
Value v = VIRTSP(0).asValue(); |
| 6372 |
if (v.isBoolean()) { |
| 6373 |
result = v.toBoolean(); |
| 6374 |
NEXT_IC(); |
| 6375 |
} else if (HybridICs) { |
| 6376 |
result = ToBoolean(SPHANDLE(0)); |
| 6377 |
NEXT_IC(); |
| 6378 |
} else { |
| 6379 |
IC_SET_ARG_FROM_STACK(0, 0); |
| 6380 |
IC_ZERO_ARG(1); |
| 6381 |
IC_ZERO_ARG(2); |
| 6382 |
INVOKE_IC(ToBool, false); |
| 6383 |
result = Value::fromRawBits(ic_ret).toBoolean(); |
| 6384 |
} |
| 6385 |
int32_t jumpOffset = GET_JUMP_OFFSET(pc); |
| 6386 |
if (!result) { |
| 6387 |
ADVANCE(jumpOffset); |
| 6388 |
PREDICT_NEXT(JumpTarget); |
| 6389 |
PREDICT_NEXT(LoopHead); |
| 6390 |
} else { |
| 6391 |
ADVANCE(JSOpLength_And); |
| 6392 |
} |
| 6393 |
DISPATCH(); |
| 6394 |
} |
| 6395 |
CASE(Or) { |
| 6396 |
bool result; |
| 6397 |
Value v = VIRTSP(0).asValue(); |
| 6398 |
if (v.isBoolean()) { |
| 6399 |
result = v.toBoolean(); |
| 6400 |
NEXT_IC(); |
| 6401 |
} else if (HybridICs) { |
| 6402 |
result = ToBoolean(SPHANDLE(0)); |
| 6403 |
NEXT_IC(); |
| 6404 |
} else { |
| 6405 |
IC_SET_ARG_FROM_STACK(0, 0); |
| 6406 |
IC_ZERO_ARG(1); |
| 6407 |
IC_ZERO_ARG(2); |
| 6408 |
INVOKE_IC(ToBool, false); |
| 6409 |
result = Value::fromRawBits(ic_ret).toBoolean(); |
| 6410 |
} |
| 6411 |
int32_t jumpOffset = GET_JUMP_OFFSET(pc); |
| 6412 |
if (result) { |
| 6413 |
ADVANCE(jumpOffset); |
| 6414 |
PREDICT_NEXT(JumpTarget); |
| 6415 |
PREDICT_NEXT(LoopHead); |
| 6416 |
} else { |
| 6417 |
ADVANCE(JSOpLength_Or); |
| 6418 |
} |
| 6419 |
DISPATCH(); |
| 6420 |
} |
| 6421 |
CASE(JumpIfTrue) { |
| 6422 |
bool result; |
| 6423 |
Value v = VIRTSP(0).asValue(); |
| 6424 |
if (v.isBoolean()) { |
| 6425 |
result = v.toBoolean(); |
| 6426 |
VIRTPOP(); |
| 6427 |
NEXT_IC(); |
| 6428 |
} else if (HybridICs) { |
| 6429 |
result = ToBoolean(SPHANDLE(0)); |
| 6430 |
VIRTPOP(); |
| 6431 |
NEXT_IC(); |
| 6432 |
} else { |
| 6433 |
IC_POP_ARG(0); |
| 6434 |
IC_ZERO_ARG(1); |
| 6435 |
IC_ZERO_ARG(2); |
| 6436 |
INVOKE_IC(ToBool, false); |
| 6437 |
result = Value::fromRawBits(ic_ret).toBoolean(); |
| 6438 |
} |
| 6439 |
int32_t jumpOffset = GET_JUMP_OFFSET(pc); |
| 6440 |
if (result) { |
| 6441 |
ADVANCE(jumpOffset); |
| 6442 |
PREDICT_NEXT(JumpTarget); |
| 6443 |
PREDICT_NEXT(LoopHead); |
| 6444 |
} else { |
| 6445 |
ADVANCE(JSOpLength_JumpIfTrue); |
| 6446 |
} |
| 6447 |
DISPATCH(); |
| 6448 |
} |
| 6449 |
CASE(JumpIfFalse) { |
| 6450 |
bool result; |
| 6451 |
Value v = VIRTSP(0).asValue(); |
| 6452 |
if (v.isBoolean()) { |
| 6453 |
result = v.toBoolean(); |
| 6454 |
VIRTPOP(); |
| 6455 |
NEXT_IC(); |
| 6456 |
} else if (HybridICs) { |
| 6457 |
result = ToBoolean(SPHANDLE(0)); |
| 6458 |
VIRTPOP(); |
| 6459 |
NEXT_IC(); |
| 6460 |
} else { |
| 6461 |
IC_POP_ARG(0); |
| 6462 |
IC_ZERO_ARG(1); |
| 6463 |
IC_ZERO_ARG(2); |
| 6464 |
INVOKE_IC(ToBool, false); |
| 6465 |
result = Value::fromRawBits(ic_ret).toBoolean(); |
| 6466 |
} |
| 6467 |
int32_t jumpOffset = GET_JUMP_OFFSET(pc); |
| 6468 |
if (!result) { |
| 6469 |
ADVANCE(jumpOffset); |
| 6470 |
PREDICT_NEXT(JumpTarget); |
| 6471 |
PREDICT_NEXT(LoopHead); |
| 6472 |
} else { |
| 6473 |
ADVANCE(JSOpLength_JumpIfFalse); |
| 6474 |
} |
| 6475 |
DISPATCH(); |
| 6476 |
} |
| 6477 |
|
| 6478 |
CASE(Add) { |
| 6479 |
if (HybridICs) { |
| 6480 |
Value v0 = VIRTSP(0).asValue(); |
| 6481 |
Value v1 = VIRTSP(1).asValue(); |
| 6482 |
if (v0.isInt32() && v1.isInt32()) { |
| 6483 |
int64_t lhs = v1.toInt32(); |
| 6484 |
int64_t rhs = v0.toInt32(); |
| 6485 |
int64_t result = lhs + rhs; |
| 6486 |
if (result >= int64_t(INT32_MIN) && result <= int64_t(INT32_MAX)) { |
| 6487 |
VIRTPOP(); |
| 6488 |
VIRTSPWRITE(0, StackVal(Int32Value(int32_t(result)))); |
| 6489 |
NEXT_IC(); |
| 6490 |
END_OP(Add); |
| 6491 |
} |
| 6492 |
} |
| 6493 |
if (v0.isNumber() && v1.isNumber()) { |
| 6494 |
double lhs = v1.toNumber(); |
| 6495 |
double rhs = v0.toNumber(); |
| 6496 |
VIRTPOP(); |
| 6497 |
VIRTSPWRITE(0, StackVal(NumberValue(lhs + rhs))); |
| 6498 |
NEXT_IC(); |
| 6499 |
END_OP(Add); |
| 6500 |
} |
| 6501 |
|
| 6502 |
MutableHandleValue lhs = SPHANDLEMUT(1); |
| 6503 |
MutableHandleValue rhs = SPHANDLEMUT(0); |
| 6504 |
MutableHandleValue result = SPHANDLEMUT(1); |
| 6505 |
{ |
| 6506 |
PUSH_EXIT_FRAME(); |
| 6507 |
if (!AddOperation(cx, lhs, rhs, result)) { |
| 6508 |
GOTO_ERROR(); |
| 6509 |
} |
| 6510 |
} |
| 6511 |
VIRTPOP(); |
| 6512 |
NEXT_IC(); |
| 6513 |
END_OP(Add); |
| 6514 |
} |
| 6515 |
goto generic_binary; |
| 6516 |
} |
| 6517 |
|
| 6518 |
CASE(Sub) { |
| 6519 |
if (HybridICs) { |
| 6520 |
Value v0 = VIRTSP(0).asValue(); |
| 6521 |
Value v1 = VIRTSP(1).asValue(); |
| 6522 |
if (v0.isInt32() && v1.isInt32()) { |
| 6523 |
int64_t lhs = v1.toInt32(); |
| 6524 |
int64_t rhs = v0.toInt32(); |
| 6525 |
int64_t result = lhs - rhs; |
| 6526 |
if (result >= int64_t(INT32_MIN) && result <= int64_t(INT32_MAX)) { |
| 6527 |
VIRTPOP(); |
| 6528 |
VIRTSPWRITE(0, StackVal(Int32Value(int32_t(result)))); |
| 6529 |
NEXT_IC(); |
| 6530 |
END_OP(Sub); |
| 6531 |
} |
| 6532 |
} |
| 6533 |
if (v0.isNumber() && v1.isNumber()) { |
| 6534 |
double lhs = v1.toNumber(); |
| 6535 |
double rhs = v0.toNumber(); |
| 6536 |
VIRTPOP(); |
| 6537 |
VIRTSPWRITE(0, StackVal(NumberValue(lhs - rhs))); |
| 6538 |
NEXT_IC(); |
| 6539 |
END_OP(Add); |
| 6540 |
} |
| 6541 |
|
| 6542 |
MutableHandleValue lhs = SPHANDLEMUT(1); |
| 6543 |
MutableHandleValue rhs = SPHANDLEMUT(0); |
| 6544 |
MutableHandleValue result = SPHANDLEMUT(1); |
| 6545 |
{ |
| 6546 |
PUSH_EXIT_FRAME(); |
| 6547 |
if (!SubOperation(cx, lhs, rhs, result)) { |
| 6548 |
GOTO_ERROR(); |
| 6549 |
} |
| 6550 |
} |
| 6551 |
VIRTPOP(); |
| 6552 |
NEXT_IC(); |
| 6553 |
END_OP(Sub); |
| 6554 |
} |
| 6555 |
goto generic_binary; |
| 6556 |
} |
| 6557 |
|
| 6558 |
CASE(Mul) { |
| 6559 |
if (HybridICs) { |
| 6560 |
Value v0 = VIRTSP(0).asValue(); |
| 6561 |
Value v1 = VIRTSP(1).asValue(); |
| 6562 |
if (v0.isInt32() && v1.isInt32()) { |
| 6563 |
int64_t lhs = v1.toInt32(); |
| 6564 |
int64_t rhs = v0.toInt32(); |
| 6565 |
int64_t product = lhs * rhs; |
| 6566 |
if (product >= int64_t(INT32_MIN) && |
| 6567 |
product <= int64_t(INT32_MAX) && |
| 6568 |
(product != 0 || !((lhs < 0) ^ (rhs < 0)))) { |
| 6569 |
VIRTPOP(); |
| 6570 |
VIRTSPWRITE(0, StackVal(Int32Value(int32_t(product)))); |
| 6571 |
NEXT_IC(); |
| 6572 |
END_OP(Mul); |
| 6573 |
} |
| 6574 |
} |
| 6575 |
if (v0.isNumber() && v1.isNumber()) { |
| 6576 |
double lhs = v1.toNumber(); |
| 6577 |
double rhs = v0.toNumber(); |
| 6578 |
VIRTPOP(); |
| 6579 |
VIRTSPWRITE(0, StackVal(NumberValue(lhs * rhs))); |
| 6580 |
NEXT_IC(); |
| 6581 |
END_OP(Mul); |
| 6582 |
} |
| 6583 |
|
| 6584 |
MutableHandleValue lhs = SPHANDLEMUT(1); |
| 6585 |
MutableHandleValue rhs = SPHANDLEMUT(0); |
| 6586 |
MutableHandleValue result = SPHANDLEMUT(1); |
| 6587 |
{ |
| 6588 |
PUSH_EXIT_FRAME(); |
| 6589 |
if (!MulOperation(cx, lhs, rhs, result)) { |
| 6590 |
GOTO_ERROR(); |
| 6591 |
} |
| 6592 |
} |
| 6593 |
VIRTPOP(); |
| 6594 |
NEXT_IC(); |
| 6595 |
END_OP(Mul); |
| 6596 |
} |
| 6597 |
goto generic_binary; |
| 6598 |
} |
| 6599 |
CASE(Div) { |
| 6600 |
if (HybridICs) { |
| 6601 |
Value v0 = VIRTSP(0).asValue(); |
| 6602 |
Value v1 = VIRTSP(1).asValue(); |
| 6603 |
if (v0.isNumber() && v1.isNumber()) { |
| 6604 |
double lhs = v1.toNumber(); |
| 6605 |
double rhs = v0.toNumber(); |
| 6606 |
VIRTPOP(); |
| 6607 |
VIRTSPWRITE(0, StackVal(NumberValue(NumberDiv(lhs, rhs)))); |
| 6608 |
NEXT_IC(); |
| 6609 |
END_OP(Div); |
| 6610 |
} |
| 6611 |
|
| 6612 |
MutableHandleValue lhs = SPHANDLEMUT(1); |
| 6613 |
MutableHandleValue rhs = SPHANDLEMUT(0); |
| 6614 |
MutableHandleValue result = SPHANDLEMUT(1); |
| 6615 |
{ |
| 6616 |
PUSH_EXIT_FRAME(); |
| 6617 |
if (!DivOperation(cx, lhs, rhs, result)) { |
| 6618 |
GOTO_ERROR(); |
| 6619 |
} |
| 6620 |
} |
| 6621 |
VIRTPOP(); |
| 6622 |
NEXT_IC(); |
| 6623 |
END_OP(Div); |
| 6624 |
} |
| 6625 |
goto generic_binary; |
| 6626 |
} |
| 6627 |
CASE(Mod) { |
| 6628 |
if (HybridICs) { |
| 6629 |
Value v0 = VIRTSP(0).asValue(); |
| 6630 |
Value v1 = VIRTSP(1).asValue(); |
| 6631 |
if (v0.isInt32() && v1.isInt32()) { |
| 6632 |
int64_t lhs = v1.toInt32(); |
| 6633 |
int64_t rhs = v0.toInt32(); |
| 6634 |
if (lhs > 0 && rhs > 0) { |
| 6635 |
int64_t mod = lhs % rhs; |
| 6636 |
VIRTPOP(); |
| 6637 |
VIRTSPWRITE(0, StackVal(Int32Value(int32_t(mod)))); |
| 6638 |
NEXT_IC(); |
| 6639 |
END_OP(Mod); |
| 6640 |
} |
| 6641 |
} |
| 6642 |
if (v0.isNumber() && v1.isNumber()) { |
| 6643 |
double lhs = v1.toNumber(); |
| 6644 |
double rhs = v0.toNumber(); |
| 6645 |
VIRTPOP(); |
| 6646 |
VIRTSPWRITE(0, StackVal(DoubleValue(NumberMod(lhs, rhs)))); |
| 6647 |
NEXT_IC(); |
| 6648 |
END_OP(Mod); |
| 6649 |
} |
| 6650 |
|
| 6651 |
MutableHandleValue lhs = SPHANDLEMUT(1); |
| 6652 |
MutableHandleValue rhs = SPHANDLEMUT(0); |
| 6653 |
MutableHandleValue result = SPHANDLEMUT(1); |
| 6654 |
{ |
| 6655 |
PUSH_EXIT_FRAME(); |
| 6656 |
if (!ModOperation(cx, lhs, rhs, result)) { |
| 6657 |
GOTO_ERROR(); |
| 6658 |
} |
| 6659 |
} |
| 6660 |
VIRTPOP(); |
| 6661 |
NEXT_IC(); |
| 6662 |
END_OP(Mod); |
| 6663 |
} |
| 6664 |
goto generic_binary; |
| 6665 |
} |
| 6666 |
CASE(Pow) { |
| 6667 |
if (HybridICs) { |
| 6668 |
Value v0 = VIRTSP(0).asValue(); |
| 6669 |
Value v1 = VIRTSP(1).asValue(); |
| 6670 |
if (v0.isNumber() && v1.isNumber()) { |
| 6671 |
double lhs = v1.toNumber(); |
| 6672 |
double rhs = v0.toNumber(); |
| 6673 |
VIRTPOP(); |
| 6674 |
VIRTSPWRITE(0, StackVal(NumberValue(ecmaPow(lhs, rhs)))); |
| 6675 |
NEXT_IC(); |
| 6676 |
END_OP(Pow); |
| 6677 |
} |
| 6678 |
|
| 6679 |
MutableHandleValue lhs = SPHANDLEMUT(1); |
| 6680 |
MutableHandleValue rhs = SPHANDLEMUT(0); |
| 6681 |
MutableHandleValue result = SPHANDLEMUT(1); |
| 6682 |
{ |
| 6683 |
PUSH_EXIT_FRAME(); |
| 6684 |
if (!PowOperation(cx, lhs, rhs, result)) { |
| 6685 |
GOTO_ERROR(); |
| 6686 |
} |
| 6687 |
} |
| 6688 |
VIRTPOP(); |
| 6689 |
NEXT_IC(); |
| 6690 |
END_OP(Pow); |
| 6691 |
} |
| 6692 |
goto generic_binary; |
| 6693 |
} |
| 6694 |
CASE(BitOr) { |
| 6695 |
if (HybridICs) { |
| 6696 |
Value v0 = VIRTSP(0).asValue(); |
| 6697 |
Value v1 = VIRTSP(1).asValue(); |
| 6698 |
if (v0.isInt32() && v1.isInt32()) { |
| 6699 |
int32_t lhs = v1.toInt32(); |
| 6700 |
int32_t rhs = v0.toInt32(); |
| 6701 |
VIRTPOP(); |
| 6702 |
VIRTSPWRITE(0, StackVal(Int32Value(lhs | rhs))); |
| 6703 |
NEXT_IC(); |
| 6704 |
END_OP(BitOr); |
| 6705 |
} |
| 6706 |
} |
| 6707 |
goto generic_binary; |
| 6708 |
} |
| 6709 |
CASE(BitAnd) { |
| 6710 |
if (HybridICs) { |
| 6711 |
Value v0 = VIRTSP(0).asValue(); |
| 6712 |
Value v1 = VIRTSP(1).asValue(); |
| 6713 |
if (v0.isInt32() && v1.isInt32()) { |
| 6714 |
int32_t lhs = v1.toInt32(); |
| 6715 |
int32_t rhs = v0.toInt32(); |
| 6716 |
VIRTPOP(); |
| 6717 |
VIRTSPWRITE(0, StackVal(Int32Value(lhs & rhs))); |
| 6718 |
NEXT_IC(); |
| 6719 |
END_OP(BitAnd); |
| 6720 |
} |
| 6721 |
} |
| 6722 |
goto generic_binary; |
| 6723 |
} |
| 6724 |
CASE(BitXor) { |
| 6725 |
if (HybridICs) { |
| 6726 |
Value v0 = VIRTSP(0).asValue(); |
| 6727 |
Value v1 = VIRTSP(1).asValue(); |
| 6728 |
if (v0.isInt32() && v1.isInt32()) { |
| 6729 |
int32_t lhs = v1.toInt32(); |
| 6730 |
int32_t rhs = v0.toInt32(); |
| 6731 |
VIRTPOP(); |
| 6732 |
VIRTSPWRITE(0, StackVal(Int32Value(lhs ^ rhs))); |
| 6733 |
NEXT_IC(); |
| 6734 |
END_OP(BitXor); |
| 6735 |
} |
| 6736 |
} |
| 6737 |
goto generic_binary; |
| 6738 |
} |
| 6739 |
CASE(Lsh) { |
| 6740 |
if (HybridICs) { |
| 6741 |
Value v0 = VIRTSP(0).asValue(); |
| 6742 |
Value v1 = VIRTSP(1).asValue(); |
| 6743 |
if (v0.isInt32() && v1.isInt32()) { |
| 6744 |
// Unsigned to avoid undefined behavior on left-shift overflow |
| 6745 |
// (see comment in BitLshOperation in Interpreter.cpp). |
| 6746 |
uint32_t lhs = uint32_t(v1.toInt32()); |
| 6747 |
uint32_t rhs = uint32_t(v0.toInt32()); |
| 6748 |
VIRTPOP(); |
| 6749 |
rhs &= 31; |
| 6750 |
VIRTSPWRITE(0, StackVal(Int32Value(int32_t(lhs << rhs)))); |
| 6751 |
NEXT_IC(); |
| 6752 |
END_OP(Lsh); |
| 6753 |
} |
| 6754 |
} |
| 6755 |
goto generic_binary; |
| 6756 |
} |
| 6757 |
CASE(Rsh) { |
| 6758 |
if (HybridICs) { |
| 6759 |
Value v0 = VIRTSP(0).asValue(); |
| 6760 |
Value v1 = VIRTSP(1).asValue(); |
| 6761 |
if (v0.isInt32() && v1.isInt32()) { |
| 6762 |
int32_t lhs = v1.toInt32(); |
| 6763 |
int32_t rhs = v0.toInt32(); |
| 6764 |
VIRTPOP(); |
| 6765 |
rhs &= 31; |
| 6766 |
VIRTSPWRITE(0, StackVal(Int32Value(lhs >> rhs))); |
| 6767 |
NEXT_IC(); |
| 6768 |
END_OP(Rsh); |
| 6769 |
} |
| 6770 |
} |
| 6771 |
goto generic_binary; |
| 6772 |
} |
| 6773 |
CASE(Ursh) { |
| 6774 |
if (HybridICs) { |
| 6775 |
Value v0 = VIRTSP(0).asValue(); |
| 6776 |
Value v1 = VIRTSP(1).asValue(); |
| 6777 |
if (v0.isInt32() && v1.isInt32()) { |
| 6778 |
uint32_t lhs = uint32_t(v1.toInt32()); |
| 6779 |
int32_t rhs = v0.toInt32(); |
| 6780 |
VIRTPOP(); |
| 6781 |
rhs &= 31; |
| 6782 |
uint32_t result = lhs >> rhs; |
| 6783 |
StackVal stackResult(0); |
| 6784 |
if (result <= uint32_t(INT32_MAX)) { |
| 6785 |
stackResult = StackVal(Int32Value(int32_t(result))); |
| 6786 |
} else { |
| 6787 |
stackResult = StackVal(NumberValue(double(result))); |
| 6788 |
} |
| 6789 |
VIRTSPWRITE(0, stackResult); |
| 6790 |
NEXT_IC(); |
| 6791 |
END_OP(Ursh); |
| 6792 |
} |
| 6793 |
} |
| 6794 |
goto generic_binary; |
| 6795 |
} |
| 6796 |
|
| 6797 |
generic_binary:; |
| 6798 |
{ |
| 6799 |
static_assert(JSOpLength_BitOr == JSOpLength_BitXor); |
| 6800 |
static_assert(JSOpLength_BitOr == JSOpLength_BitAnd); |
| 6801 |
static_assert(JSOpLength_BitOr == JSOpLength_Lsh); |
| 6802 |
static_assert(JSOpLength_BitOr == JSOpLength_Rsh); |
| 6803 |
static_assert(JSOpLength_BitOr == JSOpLength_Ursh); |
| 6804 |
static_assert(JSOpLength_BitOr == JSOpLength_Add); |
| 6805 |
static_assert(JSOpLength_BitOr == JSOpLength_Sub); |
| 6806 |
static_assert(JSOpLength_BitOr == JSOpLength_Mul); |
| 6807 |
static_assert(JSOpLength_BitOr == JSOpLength_Div); |
| 6808 |
static_assert(JSOpLength_BitOr == JSOpLength_Mod); |
| 6809 |
static_assert(JSOpLength_BitOr == JSOpLength_Pow); |
| 6810 |
IC_POP_ARG(1); |
| 6811 |
IC_POP_ARG(0); |
| 6812 |
IC_ZERO_ARG(2); |
| 6813 |
INVOKE_IC_AND_PUSH(BinaryArith, false); |
| 6814 |
END_OP(Div); |
| 6815 |
} |
| 6816 |
|
| 6817 |
CASE(Eq) { |
| 6818 |
if (HybridICs) { |
| 6819 |
Value v0 = VIRTSP(0).asValue(); |
| 6820 |
Value v1 = VIRTSP(1).asValue(); |
| 6821 |
if (v0.isInt32() && v1.isInt32()) { |
| 6822 |
bool result = v0.toInt32() == v1.toInt32(); |
| 6823 |
VIRTPOP(); |
| 6824 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6825 |
NEXT_IC(); |
| 6826 |
END_OP(Eq); |
| 6827 |
} |
| 6828 |
if (v0.isNumber() && v1.isNumber()) { |
| 6829 |
double lhs = v1.toNumber(); |
| 6830 |
double rhs = v0.toNumber(); |
| 6831 |
bool result = lhs == rhs; |
| 6832 |
VIRTPOP(); |
| 6833 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6834 |
NEXT_IC(); |
| 6835 |
END_OP(Eq); |
| 6836 |
} |
| 6837 |
if (v0.isNumber() && v1.isNumber()) { |
| 6838 |
bool result = v0.toNumber() == v1.toNumber(); |
| 6839 |
VIRTPOP(); |
| 6840 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6841 |
NEXT_IC(); |
| 6842 |
END_OP(Eq); |
| 6843 |
} |
| 6844 |
} |
| 6845 |
goto generic_cmp; |
| 6846 |
} |
| 6847 |
|
| 6848 |
CASE(Ne) { |
| 6849 |
if (HybridICs) { |
| 6850 |
Value v0 = VIRTSP(0).asValue(); |
| 6851 |
Value v1 = VIRTSP(1).asValue(); |
| 6852 |
if (v0.isInt32() && v1.isInt32()) { |
| 6853 |
bool result = v0.toInt32() != v1.toInt32(); |
| 6854 |
VIRTPOP(); |
| 6855 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6856 |
NEXT_IC(); |
| 6857 |
END_OP(Ne); |
| 6858 |
} |
| 6859 |
if (v0.isNumber() && v1.isNumber()) { |
| 6860 |
double lhs = v1.toNumber(); |
| 6861 |
double rhs = v0.toNumber(); |
| 6862 |
bool result = lhs != rhs; |
| 6863 |
VIRTPOP(); |
| 6864 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6865 |
NEXT_IC(); |
| 6866 |
END_OP(Ne); |
| 6867 |
} |
| 6868 |
if (v0.isNumber() && v1.isNumber()) { |
| 6869 |
bool result = v0.toNumber() != v1.toNumber(); |
| 6870 |
VIRTPOP(); |
| 6871 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6872 |
NEXT_IC(); |
| 6873 |
END_OP(Eq); |
| 6874 |
} |
| 6875 |
} |
| 6876 |
goto generic_cmp; |
| 6877 |
} |
| 6878 |
|
| 6879 |
CASE(Lt) { |
| 6880 |
if (HybridICs) { |
| 6881 |
Value v0 = VIRTSP(0).asValue(); |
| 6882 |
Value v1 = VIRTSP(1).asValue(); |
| 6883 |
if (v0.isInt32() && v1.isInt32()) { |
| 6884 |
bool result = v1.toInt32() < v0.toInt32(); |
| 6885 |
VIRTPOP(); |
| 6886 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6887 |
NEXT_IC(); |
| 6888 |
END_OP(Lt); |
| 6889 |
} |
| 6890 |
if (v0.isNumber() && v1.isNumber()) { |
| 6891 |
double lhs = v1.toNumber(); |
| 6892 |
double rhs = v0.toNumber(); |
| 6893 |
bool result = lhs < rhs; |
| 6894 |
if (std::isnan(lhs) || std::isnan(rhs)) { |
| 6895 |
result = false; |
| 6896 |
} |
| 6897 |
VIRTPOP(); |
| 6898 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6899 |
NEXT_IC(); |
| 6900 |
END_OP(Lt); |
| 6901 |
} |
| 6902 |
} |
| 6903 |
goto generic_cmp; |
| 6904 |
} |
| 6905 |
CASE(Le) { |
| 6906 |
if (HybridICs) { |
| 6907 |
Value v0 = VIRTSP(0).asValue(); |
| 6908 |
Value v1 = VIRTSP(1).asValue(); |
| 6909 |
if (v0.isInt32() && v1.isInt32()) { |
| 6910 |
bool result = v1.toInt32() <= v0.toInt32(); |
| 6911 |
VIRTPOP(); |
| 6912 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6913 |
NEXT_IC(); |
| 6914 |
END_OP(Le); |
| 6915 |
} |
| 6916 |
if (v0.isNumber() && v1.isNumber()) { |
| 6917 |
double lhs = v1.toNumber(); |
| 6918 |
double rhs = v0.toNumber(); |
| 6919 |
bool result = lhs <= rhs; |
| 6920 |
if (std::isnan(lhs) || std::isnan(rhs)) { |
| 6921 |
result = false; |
| 6922 |
} |
| 6923 |
VIRTPOP(); |
| 6924 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6925 |
NEXT_IC(); |
| 6926 |
END_OP(Le); |
| 6927 |
} |
| 6928 |
} |
| 6929 |
goto generic_cmp; |
| 6930 |
} |
| 6931 |
CASE(Gt) { |
| 6932 |
if (HybridICs) { |
| 6933 |
Value v0 = VIRTSP(0).asValue(); |
| 6934 |
Value v1 = VIRTSP(1).asValue(); |
| 6935 |
if (v0.isInt32() && v1.isInt32()) { |
| 6936 |
bool result = v1.toInt32() > v0.toInt32(); |
| 6937 |
VIRTPOP(); |
| 6938 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6939 |
NEXT_IC(); |
| 6940 |
END_OP(Gt); |
| 6941 |
} |
| 6942 |
if (v0.isNumber() && v1.isNumber()) { |
| 6943 |
double lhs = v1.toNumber(); |
| 6944 |
double rhs = v0.toNumber(); |
| 6945 |
bool result = lhs > rhs; |
| 6946 |
if (std::isnan(lhs) || std::isnan(rhs)) { |
| 6947 |
result = false; |
| 6948 |
} |
| 6949 |
VIRTPOP(); |
| 6950 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6951 |
NEXT_IC(); |
| 6952 |
END_OP(Gt); |
| 6953 |
} |
| 6954 |
} |
| 6955 |
goto generic_cmp; |
| 6956 |
} |
| 6957 |
CASE(Ge) { |
| 6958 |
if (HybridICs) { |
| 6959 |
Value v0 = VIRTSP(0).asValue(); |
| 6960 |
Value v1 = VIRTSP(1).asValue(); |
| 6961 |
if (v0.isInt32() && v1.isInt32()) { |
| 6962 |
bool result = v1.toInt32() >= v0.toInt32(); |
| 6963 |
VIRTPOP(); |
| 6964 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6965 |
NEXT_IC(); |
| 6966 |
END_OP(Ge); |
| 6967 |
} |
| 6968 |
if (v0.isNumber() && v1.isNumber()) { |
| 6969 |
double lhs = v1.toNumber(); |
| 6970 |
double rhs = v0.toNumber(); |
| 6971 |
bool result = lhs >= rhs; |
| 6972 |
if (std::isnan(lhs) || std::isnan(rhs)) { |
| 6973 |
result = false; |
| 6974 |
} |
| 6975 |
VIRTPOP(); |
| 6976 |
VIRTSPWRITE(0, StackVal(BooleanValue(result))); |
| 6977 |
NEXT_IC(); |
| 6978 |
END_OP(Ge); |
| 6979 |
} |
| 6980 |
} |
| 6981 |
goto generic_cmp; |
| 6982 |
} |
| 6983 |
|
| 6984 |
CASE(StrictEq) |
| 6985 |
CASE(StrictNe) { |
| 6986 |
if (HybridICs) { |
| 6987 |
Value v0 = VIRTSP(0).asValue(); |
| 6988 |
Value v1 = VIRTSP(1).asValue(); |
| 6989 |
bool result; |
| 6990 |
HandleValue lval = SPHANDLE(1); |
| 6991 |
HandleValue rval = SPHANDLE(0); |
| 6992 |
if (v0.isString() && v1.isString()) { |
| 6993 |
PUSH_EXIT_FRAME(); |
| 6994 |
if (!js::StrictlyEqual(cx, lval, rval, &result)) { |
| 6995 |
GOTO_ERROR(); |
| 6996 |
} |
| 6997 |
} else { |
| 6998 |
if (!js::StrictlyEqual(nullptr, lval, rval, &result)) { |
| 6999 |
GOTO_ERROR(); |
| 7000 |
} |
| 7001 |
} |
| 7002 |
VIRTPOP(); |
| 7003 |
VIRTSPWRITE(0, |
| 7004 |
StackVal(BooleanValue( |
| 7005 |
(JSOp(*pc) == JSOp::StrictEq) ? result : !result))); |
| 7006 |
NEXT_IC(); |
| 7007 |
END_OP(StrictEq); |
| 7008 |
} else { |
| 7009 |
goto generic_cmp; |
| 7010 |
} |
| 7011 |
} |
| 7012 |
|
| 7013 |
generic_cmp:; |
| 7014 |
{ |
| 7015 |
static_assert(JSOpLength_Eq == JSOpLength_Ne); |
| 7016 |
static_assert(JSOpLength_Eq == JSOpLength_StrictEq); |
| 7017 |
static_assert(JSOpLength_Eq == JSOpLength_StrictNe); |
| 7018 |
static_assert(JSOpLength_Eq == JSOpLength_Lt); |
| 7019 |
static_assert(JSOpLength_Eq == JSOpLength_Gt); |
| 7020 |
static_assert(JSOpLength_Eq == JSOpLength_Le); |
| 7021 |
static_assert(JSOpLength_Eq == JSOpLength_Ge); |
| 7022 |
IC_POP_ARG(1); |
| 7023 |
IC_POP_ARG(0); |
| 7024 |
IC_ZERO_ARG(2); |
| 7025 |
INVOKE_IC_AND_PUSH(Compare, false); |
| 7026 |
END_OP(Eq); |
| 7027 |
} |
| 7028 |
|
| 7029 |
CASE(StrictConstantNe) |
| 7030 |
CASE(StrictConstantEq) { |
| 7031 |
JSOp op = JSOp(*pc); |
| 7032 |
uint16_t operand = GET_UINT16(pc); |
| 7033 |
{ |
| 7034 |
ReservedRooted<JS::Value> val(&state.value0, VIRTPOP().asValue()); |
| 7035 |
bool result; |
| 7036 |
{ |
| 7037 |
PUSH_EXIT_FRAME(); |
| 7038 |
if (!js::ConstantStrictEqual(cx, val, operand, &result)) { |
| 7039 |
GOTO_ERROR(); |
| 7040 |
} |
| 7041 |
} |
| 7042 |
VIRTPUSH(StackVal( |
| 7043 |
BooleanValue(op == JSOp::StrictConstantEq ? result : !result))); |
| 7044 |
} |
| 7045 |
END_OP(StrictConstantEq); |
| 7046 |
} |
| 7047 |
|
| 7048 |
CASE(Instanceof) { |
| 7049 |
IC_POP_ARG(1); |
| 7050 |
IC_POP_ARG(0); |
| 7051 |
IC_ZERO_ARG(2); |
| 7052 |
INVOKE_IC_AND_PUSH(InstanceOf, false); |
| 7053 |
END_OP(Instanceof); |
| 7054 |
} |
| 7055 |
|
| 7056 |
CASE(In) { |
| 7057 |
IC_POP_ARG(1); |
| 7058 |
IC_POP_ARG(0); |
| 7059 |
IC_ZERO_ARG(2); |
| 7060 |
INVOKE_IC_AND_PUSH(In, false); |
| 7061 |
END_OP(In); |
| 7062 |
} |
| 7063 |
|
| 7064 |
CASE(ToPropertyKey) { |
| 7065 |
IC_POP_ARG(0); |
| 7066 |
IC_ZERO_ARG(1); |
| 7067 |
IC_ZERO_ARG(2); |
| 7068 |
INVOKE_IC_AND_PUSH(ToPropertyKey, false); |
| 7069 |
END_OP(ToPropertyKey); |
| 7070 |
} |
| 7071 |
|
| 7072 |
CASE(ToString) { |
| 7073 |
if (VIRTSP(0).asValue().isString()) { |
| 7074 |
END_OP(ToString); |
| 7075 |
} |
| 7076 |
{ |
| 7077 |
ReservedRooted<Value> value0(&state.value0, VIRTPOP().asValue()); |
| 7078 |
if (JSString* result = ToStringSlow<NoGC>( |
| 7079 |
ctx.frameMgr.cxForLocalUseOnly(), value0)) { |
| 7080 |
VIRTPUSH(StackVal(StringValue(result))); |
| 7081 |
} else { |
| 7082 |
{ |
| 7083 |
PUSH_EXIT_FRAME(); |
| 7084 |
result = ToString<CanGC>(cx, value0); |
| 7085 |
if (!result) { |
| 7086 |
GOTO_ERROR(); |
| 7087 |
} |
| 7088 |
} |
| 7089 |
VIRTPUSH(StackVal(StringValue(result))); |
| 7090 |
} |
| 7091 |
} |
| 7092 |
END_OP(ToString); |
| 7093 |
} |
| 7094 |
|
| 7095 |
CASE(IsNullOrUndefined) { |
| 7096 |
Value v = VIRTSP(0).asValue(); |
| 7097 |
bool result = v.isNull() || v.isUndefined(); |
| 7098 |
VIRTPUSH(StackVal(BooleanValue(result))); |
| 7099 |
END_OP(IsNullOrUndefined); |
| 7100 |
} |
| 7101 |
|
| 7102 |
CASE(GlobalThis) { |
| 7103 |
VIRTPUSH(StackVal(ObjectValue(*ctx.frameMgr.cxForLocalUseOnly() |
| 7104 |
->global() |
| 7105 |
->lexicalEnvironment() |
| 7106 |
.thisObject()))); |
| 7107 |
END_OP(GlobalThis); |
| 7108 |
} |
| 7109 |
|
| 7110 |
CASE(NonSyntacticGlobalThis) { |
| 7111 |
{ |
| 7112 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 7113 |
frame->environmentChain()); |
| 7114 |
ReservedRooted<Value> value0(&state.value0); |
| 7115 |
{ |
| 7116 |
PUSH_EXIT_FRAME(); |
| 7117 |
js::GetNonSyntacticGlobalThis(cx, obj0, &value0); |
| 7118 |
} |
| 7119 |
VIRTPUSH(StackVal(value0)); |
| 7120 |
} |
| 7121 |
END_OP(NonSyntacticGlobalThis); |
| 7122 |
} |
| 7123 |
|
| 7124 |
CASE(NewTarget) { |
| 7125 |
VIRTPUSH(StackVal(frame->newTarget())); |
| 7126 |
END_OP(NewTarget); |
| 7127 |
} |
| 7128 |
|
| 7129 |
CASE(DynamicImport) { |
| 7130 |
{ |
| 7131 |
ReservedRooted<Value> value0(&state.value0, |
| 7132 |
VIRTPOP().asValue()); // options |
| 7133 |
ReservedRooted<Value> value1(&state.value1, |
| 7134 |
VIRTPOP().asValue()); // specifier |
| 7135 |
JSObject* promise; |
| 7136 |
{ |
| 7137 |
PUSH_EXIT_FRAME(); |
| 7138 |
ReservedRooted<JSScript*> script0(&state.script0, frame->script()); |
| 7139 |
promise = StartDynamicModuleImport(cx, script0, value1, value0); |
| 7140 |
if (!promise) { |
| 7141 |
GOTO_ERROR(); |
| 7142 |
} |
| 7143 |
} |
| 7144 |
VIRTPUSH(StackVal(ObjectValue(*promise))); |
| 7145 |
} |
| 7146 |
END_OP(DynamicImport); |
| 7147 |
} |
| 7148 |
|
| 7149 |
CASE(ImportMeta) { |
| 7150 |
IC_ZERO_ARG(0); |
| 7151 |
IC_ZERO_ARG(1); |
| 7152 |
IC_ZERO_ARG(2); |
| 7153 |
INVOKE_IC_AND_PUSH(LazyConstant, false); |
| 7154 |
END_OP(ImportMeta); |
| 7155 |
} |
| 7156 |
|
| 7157 |
CASE(NewInit) { |
| 7158 |
if (HybridICs) { |
| 7159 |
JSObject* obj; |
| 7160 |
{ |
| 7161 |
PUSH_EXIT_FRAME(); |
| 7162 |
ReservedRooted<JSScript*> script0(&state.script0, frame->script()); |
| 7163 |
obj = NewObjectOperation(cx, script0, pc); |
| 7164 |
if (!obj) { |
| 7165 |
GOTO_ERROR(); |
| 7166 |
} |
| 7167 |
} |
| 7168 |
VIRTPUSH(StackVal(ObjectValue(*obj))); |
| 7169 |
NEXT_IC(); |
| 7170 |
END_OP(NewInit); |
| 7171 |
} else { |
| 7172 |
IC_ZERO_ARG(0); |
| 7173 |
IC_ZERO_ARG(1); |
| 7174 |
IC_ZERO_ARG(2); |
| 7175 |
INVOKE_IC_AND_PUSH(NewObject, false); |
| 7176 |
END_OP(NewInit); |
| 7177 |
} |
| 7178 |
} |
| 7179 |
CASE(NewObject) { |
| 7180 |
if (HybridICs) { |
| 7181 |
JSObject* obj; |
| 7182 |
{ |
| 7183 |
PUSH_EXIT_FRAME(); |
| 7184 |
ReservedRooted<JSScript*> script0(&state.script0, frame->script()); |
| 7185 |
obj = NewObjectOperation(cx, script0, pc); |
| 7186 |
if (!obj) { |
| 7187 |
GOTO_ERROR(); |
| 7188 |
} |
| 7189 |
} |
| 7190 |
VIRTPUSH(StackVal(ObjectValue(*obj))); |
| 7191 |
NEXT_IC(); |
| 7192 |
END_OP(NewObject); |
| 7193 |
} else { |
| 7194 |
IC_ZERO_ARG(0); |
| 7195 |
IC_ZERO_ARG(1); |
| 7196 |
IC_ZERO_ARG(2); |
| 7197 |
INVOKE_IC_AND_PUSH(NewObject, false); |
| 7198 |
END_OP(NewObject); |
| 7199 |
} |
| 7200 |
} |
| 7201 |
CASE(Object) { |
| 7202 |
VIRTPUSH(StackVal(ObjectValue(*frame->script()->getObject(pc)))); |
| 7203 |
END_OP(Object); |
| 7204 |
} |
| 7205 |
CASE(ObjWithProto) { |
| 7206 |
{ |
| 7207 |
ReservedRooted<Value> value0(&state.value0, VIRTSP(0).asValue()); |
| 7208 |
JSObject* obj; |
| 7209 |
{ |
| 7210 |
PUSH_EXIT_FRAME(); |
| 7211 |
obj = ObjectWithProtoOperation(cx, value0); |
| 7212 |
if (!obj) { |
| 7213 |
GOTO_ERROR(); |
| 7214 |
} |
| 7215 |
} |
| 7216 |
VIRTSPWRITE(0, StackVal(ObjectValue(*obj))); |
| 7217 |
} |
| 7218 |
END_OP(ObjWithProto); |
| 7219 |
} |
| 7220 |
|
| 7221 |
CASE(InitElem) |
| 7222 |
CASE(InitHiddenElem) |
| 7223 |
CASE(InitLockedElem) |
| 7224 |
CASE(InitElemInc) |
| 7225 |
CASE(SetElem) |
| 7226 |
CASE(StrictSetElem) { |
| 7227 |
static_assert(JSOpLength_InitElem == JSOpLength_InitHiddenElem); |
| 7228 |
static_assert(JSOpLength_InitElem == JSOpLength_InitLockedElem); |
| 7229 |
static_assert(JSOpLength_InitElem == JSOpLength_InitElemInc); |
| 7230 |
static_assert(JSOpLength_InitElem == JSOpLength_SetElem); |
| 7231 |
static_assert(JSOpLength_InitElem == JSOpLength_StrictSetElem); |
| 7232 |
StackVal val = VIRTSP(0); |
| 7233 |
IC_POP_ARG(2); |
| 7234 |
IC_POP_ARG(1); |
| 7235 |
IC_SET_ARG_FROM_STACK(0, 0); |
| 7236 |
if (JSOp(*pc) == JSOp::SetElem || JSOp(*pc) == JSOp::StrictSetElem) { |
| 7237 |
VIRTSPWRITE(0, val); |
| 7238 |
} |
| 7239 |
INVOKE_IC(SetElem, true); |
| 7240 |
if (JSOp(*pc) == JSOp::InitElemInc) { |
| 7241 |
VIRTPUSH( |
| 7242 |
StackVal(Int32Value(Value::fromRawBits(ic_arg1).toInt32() + 1))); |
| 7243 |
} |
| 7244 |
END_OP(InitElem); |
| 7245 |
} |
| 7246 |
|
| 7247 |
CASE(InitPropGetter) |
| 7248 |
CASE(InitHiddenPropGetter) |
| 7249 |
CASE(InitPropSetter) |
| 7250 |
CASE(InitHiddenPropSetter) { |
| 7251 |
static_assert(JSOpLength_InitPropGetter == |
| 7252 |
JSOpLength_InitHiddenPropGetter); |
| 7253 |
static_assert(JSOpLength_InitPropGetter == JSOpLength_InitPropSetter); |
| 7254 |
static_assert(JSOpLength_InitPropGetter == |
| 7255 |
JSOpLength_InitHiddenPropSetter); |
| 7256 |
{ |
| 7257 |
ReservedRooted<JSObject*> obj1( |
| 7258 |
&state.obj1, |
| 7259 |
&VIRTPOP().asValue().toObject()); // val |
| 7260 |
ReservedRooted<JSObject*> obj0( |
| 7261 |
&state.obj0, |
| 7262 |
&VIRTSP(0).asValue().toObject()); // obj; leave on stack |
| 7263 |
ReservedRooted<PropertyName*> name0(&state.name0, |
| 7264 |
frame->script()->getName(pc)); |
| 7265 |
{ |
| 7266 |
PUSH_EXIT_FRAME(); |
| 7267 |
if (!InitPropGetterSetterOperation(cx, pc, obj0, name0, obj1)) { |
| 7268 |
GOTO_ERROR(); |
| 7269 |
} |
| 7270 |
} |
| 7271 |
} |
| 7272 |
END_OP(InitPropGetter); |
| 7273 |
} |
| 7274 |
|
| 7275 |
CASE(InitElemGetter) |
| 7276 |
CASE(InitHiddenElemGetter) |
| 7277 |
CASE(InitElemSetter) |
| 7278 |
CASE(InitHiddenElemSetter) { |
| 7279 |
static_assert(JSOpLength_InitElemGetter == |
| 7280 |
JSOpLength_InitHiddenElemGetter); |
| 7281 |
static_assert(JSOpLength_InitElemGetter == JSOpLength_InitElemSetter); |
| 7282 |
static_assert(JSOpLength_InitElemGetter == |
| 7283 |
JSOpLength_InitHiddenElemSetter); |
| 7284 |
{ |
| 7285 |
ReservedRooted<JSObject*> obj1( |
| 7286 |
&state.obj1, |
| 7287 |
&VIRTPOP().asValue().toObject()); // val |
| 7288 |
ReservedRooted<Value> value0(&state.value0, |
| 7289 |
VIRTPOP().asValue()); // idval |
| 7290 |
ReservedRooted<JSObject*> obj0( |
| 7291 |
&state.obj0, |
| 7292 |
&VIRTSP(0).asValue().toObject()); // obj; leave on stack |
| 7293 |
{ |
| 7294 |
PUSH_EXIT_FRAME(); |
| 7295 |
if (!InitElemGetterSetterOperation(cx, pc, obj0, value0, obj1)) { |
| 7296 |
GOTO_ERROR(); |
| 7297 |
} |
| 7298 |
} |
| 7299 |
} |
| 7300 |
END_OP(InitElemGetter); |
| 7301 |
} |
| 7302 |
|
| 7303 |
CASE(GetProp) |
| 7304 |
CASE(GetBoundName) { |
| 7305 |
static_assert(JSOpLength_GetProp == JSOpLength_GetBoundName); |
| 7306 |
IC_POP_ARG(0); |
| 7307 |
IC_ZERO_ARG(1); |
| 7308 |
IC_ZERO_ARG(2); |
| 7309 |
INVOKE_IC_AND_PUSH(GetProp, false); |
| 7310 |
END_OP(GetProp); |
| 7311 |
} |
| 7312 |
CASE(GetPropSuper) { |
| 7313 |
IC_POP_ARG(0); |
| 7314 |
IC_POP_ARG(1); |
| 7315 |
IC_ZERO_ARG(2); |
| 7316 |
INVOKE_IC_AND_PUSH(GetPropSuper, false); |
| 7317 |
END_OP(GetPropSuper); |
| 7318 |
} |
| 7319 |
|
| 7320 |
CASE(GetElem) { |
| 7321 |
if (HybridICs && VIRTSP(1).asValue().isString()) { |
| 7322 |
HandleValue lhs = SPHANDLE(1); |
| 7323 |
HandleValue rhs = SPHANDLE(0); |
| 7324 |
uint32_t index; |
| 7325 |
if (IsDefinitelyIndex(rhs, &index)) { |
| 7326 |
JSString* str = lhs.toString(); |
| 7327 |
if (index < str->length() && str->isLinear()) { |
| 7328 |
JSLinearString* linear = &str->asLinear(); |
| 7329 |
char16_t c = linear->latin1OrTwoByteChar(index); |
| 7330 |
StaticStrings& sstr = |
| 7331 |
ctx.frameMgr.cxForLocalUseOnly()->staticStrings(); |
| 7332 |
if (sstr.hasUnit(c)) { |
| 7333 |
VIRTPOP(); |
| 7334 |
VIRTSPWRITE(0, StackVal(StringValue(sstr.getUnit(c)))); |
| 7335 |
NEXT_IC(); |
| 7336 |
END_OP(GetElem); |
| 7337 |
} |
| 7338 |
} |
| 7339 |
} |
| 7340 |
} |
| 7341 |
|
| 7342 |
IC_POP_ARG(1); |
| 7343 |
IC_POP_ARG(0); |
| 7344 |
IC_ZERO_ARG(2); |
| 7345 |
INVOKE_IC_AND_PUSH(GetElem, false); |
| 7346 |
END_OP(GetElem); |
| 7347 |
} |
| 7348 |
|
| 7349 |
CASE(GetElemSuper) { |
| 7350 |
// N.B.: second and third args are out of order! See the saga at |
| 7351 |
// https://bugzilla.mozilla.org/show_bug.cgi?id=1709328; this is |
| 7352 |
// an echo of that issue. |
| 7353 |
IC_POP_ARG(1); |
| 7354 |
IC_POP_ARG(2); |
| 7355 |
IC_POP_ARG(0); |
| 7356 |
INVOKE_IC_AND_PUSH(GetElemSuper, true); |
| 7357 |
END_OP(GetElemSuper); |
| 7358 |
} |
| 7359 |
|
| 7360 |
CASE(DelProp) { |
| 7361 |
{ |
| 7362 |
ReservedRooted<Value> value0(&state.value0, VIRTPOP().asValue()); |
| 7363 |
ReservedRooted<PropertyName*> name0(&state.name0, |
| 7364 |
frame->script()->getName(pc)); |
| 7365 |
bool res = false; |
| 7366 |
{ |
| 7367 |
PUSH_EXIT_FRAME(); |
| 7368 |
if (!DelPropOperation<false>(cx, value0, name0, &res)) { |
| 7369 |
GOTO_ERROR(); |
| 7370 |
} |
| 7371 |
} |
| 7372 |
VIRTPUSH(StackVal(BooleanValue(res))); |
| 7373 |
} |
| 7374 |
END_OP(DelProp); |
| 7375 |
} |
| 7376 |
CASE(StrictDelProp) { |
| 7377 |
{ |
| 7378 |
ReservedRooted<Value> value0(&state.value0, VIRTPOP().asValue()); |
| 7379 |
ReservedRooted<PropertyName*> name0(&state.name0, |
| 7380 |
frame->script()->getName(pc)); |
| 7381 |
bool res = false; |
| 7382 |
{ |
| 7383 |
PUSH_EXIT_FRAME(); |
| 7384 |
if (!DelPropOperation<true>(cx, value0, name0, &res)) { |
| 7385 |
GOTO_ERROR(); |
| 7386 |
} |
| 7387 |
} |
| 7388 |
VIRTPUSH(StackVal(BooleanValue(res))); |
| 7389 |
} |
| 7390 |
END_OP(StrictDelProp); |
| 7391 |
} |
| 7392 |
CASE(DelElem) { |
| 7393 |
{ |
| 7394 |
ReservedRooted<Value> value1(&state.value1, VIRTPOP().asValue()); |
| 7395 |
ReservedRooted<Value> value0(&state.value0, VIRTPOP().asValue()); |
| 7396 |
bool res = false; |
| 7397 |
{ |
| 7398 |
PUSH_EXIT_FRAME(); |
| 7399 |
if (!DelElemOperation<false>(cx, value0, value1, &res)) { |
| 7400 |
GOTO_ERROR(); |
| 7401 |
} |
| 7402 |
} |
| 7403 |
VIRTPUSH(StackVal(BooleanValue(res))); |
| 7404 |
} |
| 7405 |
END_OP(DelElem); |
| 7406 |
} |
| 7407 |
CASE(StrictDelElem) { |
| 7408 |
{ |
| 7409 |
ReservedRooted<Value> value1(&state.value1, VIRTPOP().asValue()); |
| 7410 |
ReservedRooted<Value> value0(&state.value0, VIRTPOP().asValue()); |
| 7411 |
bool res = false; |
| 7412 |
{ |
| 7413 |
PUSH_EXIT_FRAME(); |
| 7414 |
if (!DelElemOperation<true>(cx, value0, value1, &res)) { |
| 7415 |
GOTO_ERROR(); |
| 7416 |
} |
| 7417 |
} |
| 7418 |
VIRTPUSH(StackVal(BooleanValue(res))); |
| 7419 |
} |
| 7420 |
END_OP(StrictDelElem); |
| 7421 |
} |
| 7422 |
|
| 7423 |
CASE(HasOwn) { |
| 7424 |
IC_POP_ARG(1); |
| 7425 |
IC_POP_ARG(0); |
| 7426 |
IC_ZERO_ARG(2); |
| 7427 |
INVOKE_IC_AND_PUSH(HasOwn, false); |
| 7428 |
END_OP(HasOwn); |
| 7429 |
} |
| 7430 |
|
| 7431 |
CASE(CheckPrivateField) { |
| 7432 |
IC_SET_ARG_FROM_STACK(1, 0); |
| 7433 |
IC_SET_ARG_FROM_STACK(0, 1); |
| 7434 |
IC_ZERO_ARG(2); |
| 7435 |
INVOKE_IC_AND_PUSH(CheckPrivateField, false); |
| 7436 |
END_OP(CheckPrivateField); |
| 7437 |
} |
| 7438 |
|
| 7439 |
CASE(NewPrivateName) { |
| 7440 |
{ |
| 7441 |
ReservedRooted<JSAtom*> atom0(&state.atom0, |
| 7442 |
frame->script()->getAtom(pc)); |
| 7443 |
JS::Symbol* symbol; |
| 7444 |
{ |
| 7445 |
PUSH_EXIT_FRAME(); |
| 7446 |
symbol = NewPrivateName(cx, atom0); |
| 7447 |
if (!symbol) { |
| 7448 |
GOTO_ERROR(); |
| 7449 |
} |
| 7450 |
} |
| 7451 |
VIRTPUSH(StackVal(SymbolValue(symbol))); |
| 7452 |
} |
| 7453 |
END_OP(NewPrivateName); |
| 7454 |
} |
| 7455 |
|
| 7456 |
CASE(SuperBase) { |
| 7457 |
JSFunction& superEnvFunc = |
| 7458 |
VIRTPOP().asValue().toObject().as<JSFunction>(); |
| 7459 |
MOZ_ASSERT(superEnvFunc.allowSuperProperty()); |
| 7460 |
MOZ_ASSERT(superEnvFunc.baseScript()->needsHomeObject()); |
| 7461 |
const Value& homeObjVal = superEnvFunc.getExtendedSlot( |
| 7462 |
FunctionExtended::METHOD_HOMEOBJECT_SLOT); |
| 7463 |
|
| 7464 |
JSObject* homeObj = &homeObjVal.toObject(); |
| 7465 |
JSObject* superBase = HomeObjectSuperBase(homeObj); |
| 7466 |
|
| 7467 |
VIRTPUSH(StackVal(ObjectOrNullValue(superBase))); |
| 7468 |
END_OP(SuperBase); |
| 7469 |
} |
| 7470 |
|
| 7471 |
CASE(SetPropSuper) |
| 7472 |
CASE(StrictSetPropSuper) { |
| 7473 |
// stack signature: receiver, lval, rval => rval |
| 7474 |
static_assert(JSOpLength_SetPropSuper == JSOpLength_StrictSetPropSuper); |
| 7475 |
bool strict = JSOp(*pc) == JSOp::StrictSetPropSuper; |
| 7476 |
{ |
| 7477 |
ReservedRooted<Value> value2(&state.value2, |
| 7478 |
VIRTPOP().asValue()); // rval |
| 7479 |
ReservedRooted<Value> value1(&state.value1, |
| 7480 |
VIRTPOP().asValue()); // lval |
| 7481 |
ReservedRooted<Value> value0(&state.value0, |
| 7482 |
VIRTPOP().asValue()); // recevier |
| 7483 |
ReservedRooted<PropertyName*> name0(&state.name0, |
| 7484 |
frame->script()->getName(pc)); |
| 7485 |
{ |
| 7486 |
PUSH_EXIT_FRAME(); |
| 7487 |
// SetPropertySuper(cx, lval, receiver, name, rval, strict) |
| 7488 |
// (N.B.: lval and receiver are transposed!) |
| 7489 |
if (!SetPropertySuper(cx, value1, value0, name0, value2, strict)) { |
| 7490 |
GOTO_ERROR(); |
| 7491 |
} |
| 7492 |
} |
| 7493 |
VIRTPUSH(StackVal(value2)); |
| 7494 |
} |
| 7495 |
END_OP(SetPropSuper); |
| 7496 |
} |
| 7497 |
|
| 7498 |
CASE(SetElemSuper) |
| 7499 |
CASE(StrictSetElemSuper) { |
| 7500 |
// stack signature: receiver, key, lval, rval => rval |
| 7501 |
static_assert(JSOpLength_SetElemSuper == JSOpLength_StrictSetElemSuper); |
| 7502 |
bool strict = JSOp(*pc) == JSOp::StrictSetElemSuper; |
| 7503 |
{ |
| 7504 |
ReservedRooted<Value> value3(&state.value3, |
| 7505 |
VIRTPOP().asValue()); // rval |
| 7506 |
ReservedRooted<Value> value2(&state.value2, |
| 7507 |
VIRTPOP().asValue()); // lval |
| 7508 |
ReservedRooted<Value> value1(&state.value1, |
| 7509 |
VIRTPOP().asValue()); // index |
| 7510 |
ReservedRooted<Value> value0(&state.value0, |
| 7511 |
VIRTPOP().asValue()); // receiver |
| 7512 |
{ |
| 7513 |
PUSH_EXIT_FRAME(); |
| 7514 |
// SetElementSuper(cx, lval, receiver, index, rval, strict) |
| 7515 |
// (N.B.: lval, receiver and index are rotated!) |
| 7516 |
if (!SetElementSuper(cx, value2, value0, value1, value3, strict)) { |
| 7517 |
GOTO_ERROR(); |
| 7518 |
} |
| 7519 |
} |
| 7520 |
VIRTPUSH(StackVal(value3)); // value |
| 7521 |
} |
| 7522 |
END_OP(SetElemSuper); |
| 7523 |
} |
| 7524 |
|
| 7525 |
CASE(Iter) { |
| 7526 |
IC_POP_ARG(0); |
| 7527 |
IC_ZERO_ARG(1); |
| 7528 |
IC_ZERO_ARG(2); |
| 7529 |
INVOKE_IC_AND_PUSH(GetIterator, false); |
| 7530 |
END_OP(Iter); |
| 7531 |
} |
| 7532 |
|
| 7533 |
CASE(MoreIter) { |
| 7534 |
// iter => iter, name |
| 7535 |
Value v = IteratorMore(&VIRTSP(0).asValue().toObject()); |
| 7536 |
VIRTPUSH(StackVal(v)); |
| 7537 |
END_OP(MoreIter); |
| 7538 |
} |
| 7539 |
|
| 7540 |
CASE(IsNoIter) { |
| 7541 |
// iter => iter, bool |
| 7542 |
bool result = VIRTSP(0).asValue().isMagic(JS_NO_ITER_VALUE); |
| 7543 |
VIRTPUSH(StackVal(BooleanValue(result))); |
| 7544 |
END_OP(IsNoIter); |
| 7545 |
} |
| 7546 |
|
| 7547 |
CASE(EndIter) { |
| 7548 |
// iter, interval => |
| 7549 |
VIRTPOP(); |
| 7550 |
CloseIterator(&VIRTPOP().asValue().toObject()); |
| 7551 |
END_OP(EndIter); |
| 7552 |
} |
| 7553 |
|
| 7554 |
CASE(CloseIter) { |
| 7555 |
IC_SET_OBJ_ARG(0, &VIRTPOP().asValue().toObject()); |
| 7556 |
IC_ZERO_ARG(1); |
| 7557 |
IC_ZERO_ARG(2); |
| 7558 |
INVOKE_IC(CloseIter, false); |
| 7559 |
END_OP(CloseIter); |
| 7560 |
} |
| 7561 |
|
| 7562 |
CASE(CheckIsObj) { |
| 7563 |
if (!VIRTSP(0).asValue().isObject()) { |
| 7564 |
PUSH_EXIT_FRAME(); |
| 7565 |
MOZ_ALWAYS_FALSE( |
| 7566 |
js::ThrowCheckIsObject(cx, js::CheckIsObjectKind(GET_UINT8(pc)))); |
| 7567 |
/* abandon frame; error handler will re-establish sp */ |
| 7568 |
GOTO_ERROR(); |
| 7569 |
} |
| 7570 |
END_OP(CheckIsObj); |
| 7571 |
} |
| 7572 |
|
| 7573 |
CASE(CheckObjCoercible) { |
| 7574 |
{ |
| 7575 |
ReservedRooted<Value> value0(&state.value0, VIRTSP(0).asValue()); |
| 7576 |
if (value0.isNullOrUndefined()) { |
| 7577 |
PUSH_EXIT_FRAME(); |
| 7578 |
MOZ_ALWAYS_FALSE(ThrowObjectCoercible(cx, value0)); |
| 7579 |
/* abandon frame; error handler will re-establish sp */ |
| 7580 |
GOTO_ERROR(); |
| 7581 |
} |
| 7582 |
} |
| 7583 |
END_OP(CheckObjCoercible); |
| 7584 |
} |
| 7585 |
|
| 7586 |
CASE(ToAsyncIter) { |
| 7587 |
// iter, next => asynciter |
| 7588 |
{ |
| 7589 |
ReservedRooted<Value> value0(&state.value0, |
| 7590 |
VIRTPOP().asValue()); // next |
| 7591 |
ReservedRooted<JSObject*> obj0( |
| 7592 |
&state.obj0, |
| 7593 |
&VIRTPOP().asValue().toObject()); // iter |
| 7594 |
JSObject* result; |
| 7595 |
{ |
| 7596 |
PUSH_EXIT_FRAME(); |
| 7597 |
result = CreateAsyncFromSyncIterator(cx, obj0, value0); |
| 7598 |
if (!result) { |
| 7599 |
GOTO_ERROR(); |
| 7600 |
} |
| 7601 |
} |
| 7602 |
VIRTPUSH(StackVal(ObjectValue(*result))); |
| 7603 |
} |
| 7604 |
END_OP(ToAsyncIter); |
| 7605 |
} |
| 7606 |
|
| 7607 |
CASE(MutateProto) { |
| 7608 |
// obj, protoVal => obj |
| 7609 |
{ |
| 7610 |
ReservedRooted<Value> value0(&state.value0, VIRTPOP().asValue()); |
| 7611 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 7612 |
&VIRTSP(0).asValue().toObject()); |
| 7613 |
{ |
| 7614 |
PUSH_EXIT_FRAME(); |
| 7615 |
if (!MutatePrototype(cx, obj0.as<PlainObject>(), value0)) { |
| 7616 |
GOTO_ERROR(); |
| 7617 |
} |
| 7618 |
} |
| 7619 |
} |
| 7620 |
END_OP(MutateProto); |
| 7621 |
} |
| 7622 |
|
| 7623 |
CASE(NewArray) { |
| 7624 |
if (HybridICs) { |
| 7625 |
ArrayObject* obj; |
| 7626 |
{ |
| 7627 |
PUSH_EXIT_FRAME(); |
| 7628 |
uint32_t length = GET_UINT32(pc); |
| 7629 |
obj = NewArrayOperation(cx, length); |
| 7630 |
if (!obj) { |
| 7631 |
GOTO_ERROR(); |
| 7632 |
} |
| 7633 |
} |
| 7634 |
VIRTPUSH(StackVal(ObjectValue(*obj))); |
| 7635 |
NEXT_IC(); |
| 7636 |
END_OP(NewArray); |
| 7637 |
} else { |
| 7638 |
IC_ZERO_ARG(0); |
| 7639 |
IC_ZERO_ARG(1); |
| 7640 |
IC_ZERO_ARG(2); |
| 7641 |
INVOKE_IC_AND_PUSH(NewArray, false); |
| 7642 |
END_OP(NewArray); |
| 7643 |
} |
| 7644 |
} |
| 7645 |
|
| 7646 |
CASE(InitElemArray) { |
| 7647 |
// array, val => array |
| 7648 |
{ |
| 7649 |
ReservedRooted<Value> value0(&state.value0, VIRTPOP().asValue()); |
| 7650 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 7651 |
&VIRTSP(0).asValue().toObject()); |
| 7652 |
{ |
| 7653 |
PUSH_EXIT_FRAME(); |
| 7654 |
InitElemArrayOperation(cx, pc, obj0.as<ArrayObject>(), value0); |
| 7655 |
} |
| 7656 |
} |
| 7657 |
END_OP(InitElemArray); |
| 7658 |
} |
| 7659 |
|
| 7660 |
CASE(Hole) { |
| 7661 |
VIRTPUSH(StackVal(MagicValue(JS_ELEMENTS_HOLE))); |
| 7662 |
END_OP(Hole); |
| 7663 |
} |
| 7664 |
|
| 7665 |
CASE(RegExp) { |
| 7666 |
JSObject* obj; |
| 7667 |
{ |
| 7668 |
PUSH_EXIT_FRAME(); |
| 7669 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 7670 |
frame->script()->getRegExp(pc)); |
| 7671 |
obj = CloneRegExpObject(cx, obj0.as<RegExpObject>()); |
| 7672 |
if (!obj) { |
| 7673 |
GOTO_ERROR(); |
| 7674 |
} |
| 7675 |
} |
| 7676 |
VIRTPUSH(StackVal(ObjectValue(*obj))); |
| 7677 |
END_OP(RegExp); |
| 7678 |
} |
| 7679 |
|
| 7680 |
CASE(Lambda) { |
| 7681 |
if (HybridICs) { |
| 7682 |
JSObject* clone; |
| 7683 |
{ |
| 7684 |
PUSH_EXIT_FRAME(); |
| 7685 |
ReservedRooted<JSFunction*> fun0(&state.fun0, |
| 7686 |
frame->script()->getFunction(pc)); |
| 7687 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 7688 |
frame->environmentChain()); |
| 7689 |
clone = Lambda(cx, fun0, obj0); |
| 7690 |
if (!clone) { |
| 7691 |
GOTO_ERROR(); |
| 7692 |
} |
| 7693 |
} |
| 7694 |
VIRTPUSH(StackVal(ObjectValue(*clone))); |
| 7695 |
NEXT_IC(); |
| 7696 |
END_OP(Lambda); |
| 7697 |
} else { |
| 7698 |
IC_ZERO_ARG(0); |
| 7699 |
IC_ZERO_ARG(1); |
| 7700 |
IC_ZERO_ARG(2); |
| 7701 |
INVOKE_IC_AND_PUSH(Lambda, false); |
| 7702 |
END_OP(Lambda); |
| 7703 |
} |
| 7704 |
} |
| 7705 |
|
| 7706 |
CASE(SetFunName) { |
| 7707 |
// fun, name => fun |
| 7708 |
{ |
| 7709 |
ReservedRooted<Value> value0(&state.value0, |
| 7710 |
VIRTPOP().asValue()); // name |
| 7711 |
ReservedRooted<JSFunction*> fun0( |
| 7712 |
&state.fun0, &VIRTSP(0).asValue().toObject().as<JSFunction>()); |
| 7713 |
FunctionPrefixKind prefixKind = FunctionPrefixKind(GET_UINT8(pc)); |
| 7714 |
{ |
| 7715 |
PUSH_EXIT_FRAME(); |
| 7716 |
if (!SetFunctionName(cx, fun0, value0, prefixKind)) { |
| 7717 |
GOTO_ERROR(); |
| 7718 |
} |
| 7719 |
} |
| 7720 |
} |
| 7721 |
END_OP(SetFunName); |
| 7722 |
} |
| 7723 |
|
| 7724 |
CASE(InitHomeObject) { |
| 7725 |
// fun, homeObject => fun |
| 7726 |
{ |
| 7727 |
ReservedRooted<JSObject*> obj0( |
| 7728 |
&state.obj0, &VIRTPOP().asValue().toObject()); // homeObject |
| 7729 |
ReservedRooted<JSFunction*> fun0( |
| 7730 |
&state.fun0, &VIRTSP(0).asValue().toObject().as<JSFunction>()); |
| 7731 |
MOZ_ASSERT(fun0->allowSuperProperty()); |
| 7732 |
MOZ_ASSERT(obj0->is<PlainObject>() || obj0->is<JSFunction>()); |
| 7733 |
fun0->setExtendedSlot(FunctionExtended::METHOD_HOMEOBJECT_SLOT, |
| 7734 |
ObjectValue(*obj0)); |
| 7735 |
} |
| 7736 |
END_OP(InitHomeObject); |
| 7737 |
} |
| 7738 |
|
| 7739 |
CASE(CheckClassHeritage) { |
| 7740 |
{ |
| 7741 |
ReservedRooted<Value> value0(&state.value0, VIRTSP(0).asValue()); |
| 7742 |
{ |
| 7743 |
PUSH_EXIT_FRAME(); |
| 7744 |
if (!CheckClassHeritageOperation(cx, value0)) { |
| 7745 |
GOTO_ERROR(); |
| 7746 |
} |
| 7747 |
} |
| 7748 |
} |
| 7749 |
END_OP(CheckClassHeritage); |
| 7750 |
} |
| 7751 |
|
| 7752 |
CASE(FunWithProto) { |
| 7753 |
// proto => obj |
| 7754 |
{ |
| 7755 |
ReservedRooted<JSObject*> obj0( |
| 7756 |
&state.obj0, |
| 7757 |
&VIRTPOP().asValue().toObject()); // proto |
| 7758 |
ReservedRooted<JSObject*> obj1(&state.obj1, |
| 7759 |
frame->environmentChain()); |
| 7760 |
ReservedRooted<JSFunction*> fun0(&state.fun0, |
| 7761 |
frame->script()->getFunction(pc)); |
| 7762 |
JSObject* obj; |
| 7763 |
{ |
| 7764 |
PUSH_EXIT_FRAME(); |
| 7765 |
obj = FunWithProtoOperation(cx, fun0, obj1, obj0); |
| 7766 |
if (!obj) { |
| 7767 |
GOTO_ERROR(); |
| 7768 |
} |
| 7769 |
} |
| 7770 |
VIRTPUSH(StackVal(ObjectValue(*obj))); |
| 7771 |
} |
| 7772 |
END_OP(FunWithProto); |
| 7773 |
} |
| 7774 |
|
| 7775 |
CASE(BuiltinObject) { |
| 7776 |
IC_ZERO_ARG(0); |
| 7777 |
IC_ZERO_ARG(1); |
| 7778 |
IC_ZERO_ARG(2); |
| 7779 |
INVOKE_IC_AND_PUSH(LazyConstant, false); |
| 7780 |
END_OP(BuiltinObject); |
| 7781 |
} |
| 7782 |
|
| 7783 |
CASE(Call) |
| 7784 |
CASE(CallIgnoresRv) |
| 7785 |
CASE(CallContent) |
| 7786 |
CASE(CallIter) |
| 7787 |
CASE(CallContentIter) |
| 7788 |
CASE(Eval) |
| 7789 |
CASE(StrictEval) |
| 7790 |
CASE(SuperCall) |
| 7791 |
CASE(New) |
| 7792 |
CASE(NewContent) { |
| 7793 |
static_assert(JSOpLength_Call == JSOpLength_CallIgnoresRv); |
| 7794 |
static_assert(JSOpLength_Call == JSOpLength_CallContent); |
| 7795 |
static_assert(JSOpLength_Call == JSOpLength_CallIter); |
| 7796 |
static_assert(JSOpLength_Call == JSOpLength_CallContentIter); |
| 7797 |
static_assert(JSOpLength_Call == JSOpLength_Eval); |
| 7798 |
static_assert(JSOpLength_Call == JSOpLength_StrictEval); |
| 7799 |
static_assert(JSOpLength_Call == JSOpLength_SuperCall); |
| 7800 |
static_assert(JSOpLength_Call == JSOpLength_New); |
| 7801 |
static_assert(JSOpLength_Call == JSOpLength_NewContent); |
| 7802 |
JSOp op = JSOp(*pc); |
| 7803 |
bool constructing = (op == JSOp::New || op == JSOp::NewContent || |
| 7804 |
op == JSOp::SuperCall); |
| 7805 |
uint32_t argc = GET_ARGC(pc); |
| 7806 |
do { |
| 7807 |
{ |
| 7808 |
// CallArgsFromSp would be called with |
| 7809 |
// - numValues = argc + 2 + constructing |
| 7810 |
// - stackSlots = argc + constructing |
| 7811 |
// - sp = vp + numValues |
| 7812 |
// CallArgs::create then gets |
| 7813 |
// - argc_ = stackSlots - constructing = argc |
| 7814 |
// - argv_ = sp - stackSlots = vp + 2 |
| 7815 |
// our arguments are in reverse order compared to what CallArgs |
| 7816 |
// expects so we should subtract any array subscripts from (sp + |
| 7817 |
// stackSlots - 1) |
| 7818 |
StackVal* firstArg = sp + argc + constructing - 1; |
| 7819 |
|
| 7820 |
// callee is argv_[-2] -> sp + argc + constructing + 1 |
| 7821 |
// this is argv_[-1] -> sp + argc + constructing |
| 7822 |
// newTarget is argv_[argc_] -> sp + constructing - 1 |
| 7823 |
// but this/newTarget are only used when constructing is 1 so we can |
| 7824 |
// simplify this is argv_[-1] -> sp + argc + 1 newTarget is |
| 7825 |
// argv_[argc_] -> sp |
| 7826 |
|
| 7827 |
HandleValue callee = Stack::handle(firstArg + 2); |
| 7828 |
if (!callee.isObject() || !callee.toObject().is<JSFunction>()) { |
| 7829 |
TRACE_PRINTF("missed fastpath: not a function\n"); |
| 7830 |
break; |
| 7831 |
} |
| 7832 |
ReservedRooted<JSFunction*> func( |
| 7833 |
&state.fun0, &callee.toObject().as<JSFunction>()); |
| 7834 |
if (!func->hasBaseScript() || !func->isInterpreted()) { |
| 7835 |
TRACE_PRINTF("missed fastpath: not an interpreted script\n"); |
| 7836 |
break; |
| 7837 |
} |
| 7838 |
if (!constructing && func->isClassConstructor()) { |
| 7839 |
TRACE_PRINTF( |
| 7840 |
"missed fastpath: constructor called without `new`\n"); |
| 7841 |
break; |
| 7842 |
} |
| 7843 |
if (constructing && !func->isConstructor()) { |
| 7844 |
TRACE_PRINTF( |
| 7845 |
"missed fastpath: constructing with a non-constructor\n"); |
| 7846 |
break; |
| 7847 |
} |
| 7848 |
if (!func->baseScript()->hasBytecode()) { |
| 7849 |
TRACE_PRINTF("missed fastpath: no bytecode\n"); |
| 7850 |
break; |
| 7851 |
} |
| 7852 |
ReservedRooted<JSScript*> calleeScript( |
| 7853 |
&state.script0, func->baseScript()->asJSScript()); |
| 7854 |
if (!calleeScript->hasJitScript()) { |
| 7855 |
TRACE_PRINTF("missed fastpath: no jit-script\n"); |
| 7856 |
break; |
| 7857 |
} |
| 7858 |
if (ctx.frameMgr.cxForLocalUseOnly()->realm() != |
| 7859 |
calleeScript->realm()) { |
| 7860 |
TRACE_PRINTF("missed fastpath: mismatched realm\n"); |
| 7861 |
break; |
| 7862 |
} |
| 7863 |
if (argc < func->nargs()) { |
| 7864 |
TRACE_PRINTF("missed fastpath: not enough arguments\n"); |
| 7865 |
break; |
| 7866 |
} |
| 7867 |
|
| 7868 |
// Fast-path: function, interpreted, has JitScript, same realm, no |
| 7869 |
// argument underflow. |
| 7870 |
|
| 7871 |
// Include newTarget in the args if it exists; exclude callee |
| 7872 |
uint32_t totalArgs = argc + 1 + constructing; |
| 7873 |
StackVal* origArgs = sp; |
| 7874 |
|
| 7875 |
TRACE_PRINTF( |
| 7876 |
"Call fastpath: argc = %d origArgs = %p callee = %" PRIx64 "\n", |
| 7877 |
argc, origArgs, callee.get().asRawBits()); |
| 7878 |
|
| 7879 |
if (!ctx.stack.check(sp, sizeof(StackVal) * (totalArgs + 3))) { |
| 7880 |
TRACE_PRINTF("missed fastpath: would cause stack overrun\n"); |
| 7881 |
break; |
| 7882 |
} |
| 7883 |
|
| 7884 |
if (constructing) { |
| 7885 |
MutableHandleValue thisv = Stack::handleMut(firstArg + 1); |
| 7886 |
if (!thisv.isObject()) { |
| 7887 |
HandleValue newTarget = Stack::handle(firstArg - argc); |
| 7888 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 7889 |
&newTarget.toObject()); |
| 7890 |
|
| 7891 |
PUSH_EXIT_FRAME(); |
| 7892 |
// CreateThis might discard the JitScript but we're counting on |
| 7893 |
// it continuing to exist while we evaluate the fastpath. |
| 7894 |
AutoKeepJitScripts keepJitScript(cx); |
| 7895 |
if (!CreateThis(cx, func, obj0, GenericObject, thisv)) { |
| 7896 |
GOTO_ERROR(); |
| 7897 |
} |
| 7898 |
|
| 7899 |
TRACE_PRINTF("created %" PRIx64 "\n", thisv.get().asRawBits()); |
| 7900 |
} |
| 7901 |
} |
| 7902 |
|
| 7903 |
// 0. Save current PC and interpreter IC pointer in |
| 7904 |
// current frame, so we can retrieve them later. |
| 7905 |
frame->interpreterPC() = pc; |
| 7906 |
frame->interpreterICEntry() = icEntry; |
| 7907 |
|
| 7908 |
// 1. Push a baseline stub frame. Don't use the frame manager |
| 7909 |
// -- we don't want the frame to be auto-freed when we leave |
| 7910 |
// this scope, and we don't want to shadow `sp`. |
| 7911 |
StackVal* exitFP = ctx.stack.pushExitFrame(sp, frame); |
| 7912 |
MOZ_ASSERT(exitFP); // safety: stack margin. |
| 7913 |
sp = exitFP; |
| 7914 |
TRACE_PRINTF("exit frame at %p\n", exitFP); |
| 7915 |
|
| 7916 |
// 2. Modify exit code to nullptr (this is where ICStubReg is |
| 7917 |
// normally saved; the tracing code can skip if null). |
| 7918 |
PUSHNATIVE(StackValNative(nullptr)); |
| 7919 |
|
| 7920 |
// 3. Push args in proper order (they are reversed in our |
| 7921 |
// downward-growth stack compared to what the calling |
| 7922 |
// convention expects). |
| 7923 |
for (uint32_t i = 0; i < totalArgs; i++) { |
| 7924 |
VIRTPUSH(origArgs[i]); |
| 7925 |
} |
| 7926 |
|
| 7927 |
// 4. Push inter-frame content: callee token, descriptor for |
| 7928 |
// above. |
| 7929 |
PUSHNATIVE(StackValNative(CalleeToToken(func, constructing))); |
| 7930 |
PUSHNATIVE(StackValNative( |
| 7931 |
MakeFrameDescriptorForJitCall(FrameType::BaselineStub, argc))); |
| 7932 |
|
| 7933 |
// 5. Push fake return address, set script, push baseline frame. |
| 7934 |
PUSHNATIVE(StackValNative(nullptr)); |
| 7935 |
BaselineFrame* newFrame = |
| 7936 |
ctx.stack.pushFrame(sp, ctx.frameMgr.cxForLocalUseOnly(), |
| 7937 |
/* envChain = */ func->environment()); |
| 7938 |
MOZ_ASSERT(newFrame); // safety: stack margin. |
| 7939 |
TRACE_PRINTF("callee frame at %p\n", newFrame); |
| 7940 |
frame = newFrame; |
| 7941 |
ctx.frameMgr.switchToFrame(frame); |
| 7942 |
ctx.frame = frame; |
| 7943 |
// 6. Set up PC and SP for callee. |
| 7944 |
sp = reinterpret_cast<StackVal*>(frame); |
| 7945 |
RESET_PC(calleeScript->code(), calleeScript); |
| 7946 |
// 7. Check callee stack space for max stack depth. |
| 7947 |
if (!stack.check(sp, sizeof(StackVal) * calleeScript->nslots())) { |
| 7948 |
PUSH_EXIT_FRAME(); |
| 7949 |
ReportOverRecursed(ctx.frameMgr.cxForLocalUseOnly()); |
| 7950 |
GOTO_ERROR(); |
| 7951 |
} |
| 7952 |
// 8. Push local slots, and set return value to `undefined` by |
| 7953 |
// default. |
| 7954 |
uint32_t nfixed = calleeScript->nfixed(); |
| 7955 |
for (uint32_t i = 0; i < nfixed; i++) { |
| 7956 |
VIRTPUSH(StackVal(UndefinedValue())); |
| 7957 |
} |
| 7958 |
ret->setUndefined(); |
| 7959 |
// 9. Initialize environment objects. |
| 7960 |
if (func->needsFunctionEnvironmentObjects()) { |
| 7961 |
PUSH_EXIT_FRAME(); |
| 7962 |
if (!js::InitFunctionEnvironmentObjects(cx, frame)) { |
| 7963 |
GOTO_ERROR(); |
| 7964 |
} |
| 7965 |
} |
| 7966 |
// 10. Set debug flag, if appropriate. |
| 7967 |
if (frame->script()->isDebuggee()) { |
| 7968 |
TRACE_PRINTF("Script is debuggee\n"); |
| 7969 |
frame->setIsDebuggee(); |
| 7970 |
|
| 7971 |
PUSH_EXIT_FRAME(); |
| 7972 |
if (!DebugPrologue(cx, frame)) { |
| 7973 |
GOTO_ERROR(); |
| 7974 |
} |
| 7975 |
} |
| 7976 |
// 11. Check for interrupts. |
| 7977 |
#ifdef ENABLE_INTERRUPT_CHECKS |
| 7978 |
if (ctx.frameMgr.cxForLocalUseOnly()->hasAnyPendingInterrupt()) { |
| 7979 |
PUSH_EXIT_FRAME(); |
| 7980 |
if (!InterruptCheck(cx)) { |
| 7981 |
GOTO_ERROR(); |
| 7982 |
} |
| 7983 |
} |
| 7984 |
#endif |
| 7985 |
// 12. Initialize coverage tables, if needed. |
| 7986 |
if (!frame->script()->hasScriptCounts()) { |
| 7987 |
if (ctx.frameMgr.cxForLocalUseOnly() |
| 7988 |
->realm() |
| 7989 |
->collectCoverageForDebug()) { |
| 7990 |
PUSH_EXIT_FRAME(); |
| 7991 |
if (!frame->script()->initScriptCounts(cx)) { |
| 7992 |
GOTO_ERROR(); |
| 7993 |
} |
| 7994 |
} |
| 7995 |
} |
| 7996 |
COUNT_COVERAGE_MAIN(); |
| 7997 |
} |
| 7998 |
|
| 7999 |
// Everything is switched to callee context now -- dispatch! |
| 8000 |
DISPATCH(); |
| 8001 |
} while (0); |
| 8002 |
|
| 8003 |
// Slow path: use the IC! |
| 8004 |
ic_arg0 = argc; |
| 8005 |
ctx.icregs.extraArgs = 2 + constructing; |
| 8006 |
INVOKE_IC(Call, false); |
| 8007 |
VIRTPOPN(argc + 2 + constructing); |
| 8008 |
VIRTPUSH(StackVal(Value::fromRawBits(ic_ret))); |
| 8009 |
END_OP(Call); |
| 8010 |
} |
| 8011 |
|
| 8012 |
CASE(SpreadCall) |
| 8013 |
CASE(SpreadEval) |
| 8014 |
CASE(StrictSpreadEval) { |
| 8015 |
static_assert(JSOpLength_SpreadCall == JSOpLength_SpreadEval); |
| 8016 |
static_assert(JSOpLength_SpreadCall == JSOpLength_StrictSpreadEval); |
| 8017 |
ic_arg0 = 1; |
| 8018 |
IC_ZERO_ARG(1); |
| 8019 |
IC_ZERO_ARG(2); |
| 8020 |
ctx.icregs.extraArgs = 2; |
| 8021 |
INVOKE_IC(SpreadCall, false); |
| 8022 |
VIRTPOPN(3); |
| 8023 |
VIRTPUSH(StackVal(Value::fromRawBits(ic_ret))); |
| 8024 |
END_OP(SpreadCall); |
| 8025 |
} |
| 8026 |
|
| 8027 |
CASE(SpreadSuperCall) |
| 8028 |
CASE(SpreadNew) { |
| 8029 |
static_assert(JSOpLength_SpreadSuperCall == JSOpLength_SpreadNew); |
| 8030 |
ic_arg0 = 1; |
| 8031 |
ctx.icregs.extraArgs = 3; |
| 8032 |
INVOKE_IC(SpreadCall, false); |
| 8033 |
VIRTPOPN(4); |
| 8034 |
VIRTPUSH(StackVal(Value::fromRawBits(ic_ret))); |
| 8035 |
END_OP(SpreadSuperCall); |
| 8036 |
} |
| 8037 |
|
| 8038 |
CASE(OptimizeSpreadCall) { |
| 8039 |
IC_POP_ARG(0); |
| 8040 |
IC_ZERO_ARG(1); |
| 8041 |
IC_ZERO_ARG(2); |
| 8042 |
INVOKE_IC_AND_PUSH(OptimizeSpreadCall, false); |
| 8043 |
END_OP(OptimizeSpreadCall); |
| 8044 |
} |
| 8045 |
|
| 8046 |
CASE(OptimizeGetIterator) { |
| 8047 |
IC_POP_ARG(0); |
| 8048 |
IC_ZERO_ARG(1); |
| 8049 |
IC_ZERO_ARG(2); |
| 8050 |
INVOKE_IC_AND_PUSH(OptimizeGetIterator, false); |
| 8051 |
END_OP(OptimizeGetIterator); |
| 8052 |
} |
| 8053 |
|
| 8054 |
CASE(ImplicitThis) { |
| 8055 |
{ |
| 8056 |
ReservedRooted<JSObject*> env(&state.obj0, |
| 8057 |
&VIRTSP(0).asValue().toObject()); |
| 8058 |
VIRTPOP(); |
| 8059 |
PUSH_EXIT_FRAME(); |
| 8060 |
ImplicitThisOperation(cx, env, &state.res); |
| 8061 |
} |
| 8062 |
VIRTPUSH(StackVal(state.res)); |
| 8063 |
state.res.setUndefined(); |
| 8064 |
END_OP(ImplicitThis); |
| 8065 |
} |
| 8066 |
|
| 8067 |
CASE(CallSiteObj) { |
| 8068 |
JSObject* cso = frame->script()->getObject(pc); |
| 8069 |
MOZ_ASSERT(!cso->as<ArrayObject>().isExtensible()); |
| 8070 |
MOZ_ASSERT(cso->as<ArrayObject>().containsPure( |
| 8071 |
ctx.frameMgr.cxForLocalUseOnly()->names().raw)); |
| 8072 |
VIRTPUSH(StackVal(ObjectValue(*cso))); |
| 8073 |
END_OP(CallSiteObj); |
| 8074 |
} |
| 8075 |
|
| 8076 |
CASE(IsConstructing) { |
| 8077 |
VIRTPUSH(StackVal(MagicValue(JS_IS_CONSTRUCTING))); |
| 8078 |
END_OP(IsConstructing); |
| 8079 |
} |
| 8080 |
|
| 8081 |
CASE(SuperFun) { |
| 8082 |
JSObject* superEnvFunc = &VIRTPOP().asValue().toObject(); |
| 8083 |
JSObject* superFun = SuperFunOperation(superEnvFunc); |
| 8084 |
VIRTPUSH(StackVal(ObjectOrNullValue(superFun))); |
| 8085 |
END_OP(SuperFun); |
| 8086 |
} |
| 8087 |
|
| 8088 |
CASE(CheckThis) { |
| 8089 |
if (VIRTSP(0).asValue().isMagic(JS_UNINITIALIZED_LEXICAL)) { |
| 8090 |
PUSH_EXIT_FRAME(); |
| 8091 |
MOZ_ALWAYS_FALSE(ThrowUninitializedThis(cx)); |
| 8092 |
GOTO_ERROR(); |
| 8093 |
} |
| 8094 |
END_OP(CheckThis); |
| 8095 |
} |
| 8096 |
|
| 8097 |
CASE(CheckThisReinit) { |
| 8098 |
if (!VIRTSP(0).asValue().isMagic(JS_UNINITIALIZED_LEXICAL)) { |
| 8099 |
PUSH_EXIT_FRAME(); |
| 8100 |
MOZ_ALWAYS_FALSE(ThrowInitializedThis(cx)); |
| 8101 |
GOTO_ERROR(); |
| 8102 |
} |
| 8103 |
END_OP(CheckThisReinit); |
| 8104 |
} |
| 8105 |
|
| 8106 |
CASE(Generator) { |
| 8107 |
JSObject* generator; |
| 8108 |
{ |
| 8109 |
PUSH_EXIT_FRAME(); |
| 8110 |
generator = CreateGeneratorFromFrame(cx, frame); |
| 8111 |
if (!generator) { |
| 8112 |
GOTO_ERROR(); |
| 8113 |
} |
| 8114 |
} |
| 8115 |
VIRTPUSH(StackVal(ObjectValue(*generator))); |
| 8116 |
END_OP(Generator); |
| 8117 |
} |
| 8118 |
|
| 8119 |
CASE(InitialYield) { |
| 8120 |
// gen => rval, gen, resumeKind |
| 8121 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 8122 |
&VIRTSP(0).asValue().toObject()); |
| 8123 |
uint32_t frameSize = ctx.stack.frameSize(sp, frame); |
| 8124 |
{ |
| 8125 |
PUSH_EXIT_FRAME(); |
| 8126 |
if (!NormalSuspend(cx, obj0, frame, frameSize, pc)) { |
| 8127 |
GOTO_ERROR(); |
| 8128 |
} |
| 8129 |
} |
| 8130 |
frame->setReturnValue(VIRTSP(0).asValue()); |
| 8131 |
goto do_return; |
| 8132 |
} |
| 8133 |
|
| 8134 |
CASE(Await) |
| 8135 |
CASE(Yield) { |
| 8136 |
// rval1, gen => rval2, gen, resumeKind |
| 8137 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 8138 |
&VIRTPOP().asValue().toObject()); |
| 8139 |
uint32_t frameSize = ctx.stack.frameSize(sp, frame); |
| 8140 |
{ |
| 8141 |
PUSH_EXIT_FRAME(); |
| 8142 |
if (!NormalSuspend(cx, obj0, frame, frameSize, pc)) { |
| 8143 |
GOTO_ERROR(); |
| 8144 |
} |
| 8145 |
} |
| 8146 |
frame->setReturnValue(VIRTSP(0).asValue()); |
| 8147 |
goto do_return; |
| 8148 |
} |
| 8149 |
|
| 8150 |
CASE(FinalYieldRval) { |
| 8151 |
// gen => |
| 8152 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 8153 |
&VIRTPOP().asValue().toObject()); |
| 8154 |
{ |
| 8155 |
PUSH_EXIT_FRAME(); |
| 8156 |
if (!FinalSuspend(cx, obj0, pc)) { |
| 8157 |
GOTO_ERROR(); |
| 8158 |
} |
| 8159 |
} |
| 8160 |
goto do_return; |
| 8161 |
} |
| 8162 |
|
| 8163 |
CASE(IsGenClosing) { |
| 8164 |
bool result = VIRTSP(0).asValue() == MagicValue(JS_GENERATOR_CLOSING); |
| 8165 |
VIRTPUSH(StackVal(BooleanValue(result))); |
| 8166 |
END_OP(IsGenClosing); |
| 8167 |
} |
| 8168 |
|
| 8169 |
CASE(AsyncAwait) { |
| 8170 |
// value, gen => promise |
| 8171 |
JSObject* promise; |
| 8172 |
{ |
| 8173 |
ReservedRooted<JSObject*> obj0( |
| 8174 |
&state.obj0, |
| 8175 |
&VIRTPOP().asValue().toObject()); // gen |
| 8176 |
ReservedRooted<Value> value0(&state.value0, |
| 8177 |
VIRTPOP().asValue()); // value |
| 8178 |
PUSH_EXIT_FRAME(); |
| 8179 |
promise = AsyncFunctionAwait( |
| 8180 |
cx, obj0.as<AsyncFunctionGeneratorObject>(), value0); |
| 8181 |
if (!promise) { |
| 8182 |
GOTO_ERROR(); |
| 8183 |
} |
| 8184 |
} |
| 8185 |
VIRTPUSH(StackVal(ObjectValue(*promise))); |
| 8186 |
END_OP(AsyncAwait); |
| 8187 |
} |
| 8188 |
|
| 8189 |
CASE(AsyncResolve) { |
| 8190 |
// value, gen => promise |
| 8191 |
JSObject* promise; |
| 8192 |
{ |
| 8193 |
ReservedRooted<JSObject*> obj0( |
| 8194 |
&state.obj0, |
| 8195 |
&VIRTPOP().asValue().toObject()); // gen |
| 8196 |
ReservedRooted<Value> value0(&state.value0, |
| 8197 |
VIRTPOP().asValue()); // value |
| 8198 |
PUSH_EXIT_FRAME(); |
| 8199 |
promise = AsyncFunctionResolve( |
| 8200 |
cx, obj0.as<AsyncFunctionGeneratorObject>(), value0); |
| 8201 |
if (!promise) { |
| 8202 |
GOTO_ERROR(); |
| 8203 |
} |
| 8204 |
} |
| 8205 |
VIRTPUSH(StackVal(ObjectValue(*promise))); |
| 8206 |
END_OP(AsyncResolve); |
| 8207 |
} |
| 8208 |
|
| 8209 |
CASE(AsyncReject) { |
| 8210 |
// reason, gen => promise |
| 8211 |
JSObject* promise; |
| 8212 |
{ |
| 8213 |
ReservedRooted<JSObject*> obj0( |
| 8214 |
&state.obj0, |
| 8215 |
&VIRTPOP().asValue().toObject()); // gen |
| 8216 |
ReservedRooted<Value> value0(&state.value0, |
| 8217 |
VIRTPOP().asValue()); // stack |
| 8218 |
ReservedRooted<Value> value1(&state.value1, |
| 8219 |
VIRTPOP().asValue()); // reason |
| 8220 |
PUSH_EXIT_FRAME(); |
| 8221 |
promise = AsyncFunctionReject( |
| 8222 |
cx, obj0.as<AsyncFunctionGeneratorObject>(), value1, value0); |
| 8223 |
if (!promise) { |
| 8224 |
GOTO_ERROR(); |
| 8225 |
} |
| 8226 |
} |
| 8227 |
VIRTPUSH(StackVal(ObjectValue(*promise))); |
| 8228 |
END_OP(AsyncReject); |
| 8229 |
} |
| 8230 |
|
| 8231 |
CASE(CanSkipAwait) { |
| 8232 |
// value => value, can_skip |
| 8233 |
bool result = false; |
| 8234 |
{ |
| 8235 |
ReservedRooted<Value> value0(&state.value0, VIRTSP(0).asValue()); |
| 8236 |
PUSH_EXIT_FRAME(); |
| 8237 |
if (!CanSkipAwait(cx, value0, &result)) { |
| 8238 |
GOTO_ERROR(); |
| 8239 |
} |
| 8240 |
} |
| 8241 |
VIRTPUSH(StackVal(BooleanValue(result))); |
| 8242 |
END_OP(CanSkipAwait); |
| 8243 |
} |
| 8244 |
|
| 8245 |
CASE(MaybeExtractAwaitValue) { |
| 8246 |
// value, can_skip => value_or_resolved, can_skip |
| 8247 |
{ |
| 8248 |
Value can_skip = VIRTPOP().asValue(); |
| 8249 |
ReservedRooted<Value> value0(&state.value0, |
| 8250 |
VIRTPOP().asValue()); // value |
| 8251 |
if (can_skip.toBoolean()) { |
| 8252 |
PUSH_EXIT_FRAME(); |
| 8253 |
if (!ExtractAwaitValue(cx, value0, &value0)) { |
| 8254 |
GOTO_ERROR(); |
| 8255 |
} |
| 8256 |
} |
| 8257 |
VIRTPUSH(StackVal(value0)); |
| 8258 |
VIRTPUSH(StackVal(can_skip)); |
| 8259 |
} |
| 8260 |
END_OP(MaybeExtractAwaitValue); |
| 8261 |
} |
| 8262 |
|
| 8263 |
CASE(ResumeKind) { |
| 8264 |
GeneratorResumeKind resumeKind = ResumeKindFromPC(pc); |
| 8265 |
VIRTPUSH(StackVal(Int32Value(int32_t(resumeKind)))); |
| 8266 |
END_OP(ResumeKind); |
| 8267 |
} |
| 8268 |
|
| 8269 |
CASE(CheckResumeKind) { |
| 8270 |
// rval, gen, resumeKind => rval |
| 8271 |
{ |
| 8272 |
GeneratorResumeKind resumeKind = |
| 8273 |
IntToResumeKind(VIRTPOP().asValue().toInt32()); |
| 8274 |
ReservedRooted<JSObject*> obj0( |
| 8275 |
&state.obj0, |
| 8276 |
&VIRTPOP().asValue().toObject()); // gen |
| 8277 |
ReservedRooted<Value> value0(&state.value0, |
| 8278 |
VIRTSP(0).asValue()); // rval |
| 8279 |
if (resumeKind != GeneratorResumeKind::Next) { |
| 8280 |
PUSH_EXIT_FRAME(); |
| 8281 |
MOZ_ALWAYS_FALSE(GeneratorThrowOrReturn( |
| 8282 |
cx, frame, obj0.as<AbstractGeneratorObject>(), value0, |
| 8283 |
resumeKind)); |
| 8284 |
GOTO_ERROR(); |
| 8285 |
} |
| 8286 |
} |
| 8287 |
END_OP(CheckResumeKind); |
| 8288 |
} |
| 8289 |
|
| 8290 |
CASE(Resume) { |
| 8291 |
SYNCSP(); |
| 8292 |
Value gen = VIRTSP(2).asValue(); |
| 8293 |
Value* callerSP = reinterpret_cast<Value*>(sp); |
| 8294 |
{ |
| 8295 |
ReservedRooted<Value> value0(&state.value0); |
| 8296 |
ReservedRooted<JSObject*> obj0(&state.obj0, &gen.toObject()); |
| 8297 |
{ |
| 8298 |
PUSH_EXIT_FRAME(); |
| 8299 |
TRACE_PRINTF("Going to C++ interp for Resume\n"); |
| 8300 |
if (!InterpretResume(cx, obj0, callerSP, &value0)) { |
| 8301 |
GOTO_ERROR(); |
| 8302 |
} |
| 8303 |
} |
| 8304 |
VIRTPOPN(2); |
| 8305 |
VIRTSPWRITE(0, StackVal(value0)); |
| 8306 |
} |
| 8307 |
END_OP(Resume); |
| 8308 |
} |
| 8309 |
|
| 8310 |
CASE(JumpTarget) { |
| 8311 |
int32_t icIndex = GET_INT32(pc); |
| 8312 |
icEntry = icEntries + icIndex; |
| 8313 |
COUNT_COVERAGE_PC(pc); |
| 8314 |
END_OP(JumpTarget); |
| 8315 |
} |
| 8316 |
CASE(LoopHead) { |
| 8317 |
int32_t icIndex = GET_INT32(pc); |
| 8318 |
icEntry = icEntries + icIndex; |
| 8319 |
#ifdef ENABLE_INTERRUPT_CHECKS |
| 8320 |
if (ctx.frameMgr.cxForLocalUseOnly()->hasAnyPendingInterrupt()) { |
| 8321 |
PUSH_EXIT_FRAME(); |
| 8322 |
if (!InterruptCheck(cx)) { |
| 8323 |
GOTO_ERROR(); |
| 8324 |
} |
| 8325 |
} |
| 8326 |
#endif |
| 8327 |
COUNT_COVERAGE_PC(pc); |
| 8328 |
END_OP(LoopHead); |
| 8329 |
} |
| 8330 |
CASE(AfterYield) { |
| 8331 |
int32_t icIndex = GET_INT32(pc); |
| 8332 |
icEntry = icEntries + icIndex; |
| 8333 |
if (frame->script()->isDebuggee()) { |
| 8334 |
TRACE_PRINTF("doing DebugAfterYield\n"); |
| 8335 |
PUSH_EXIT_FRAME(); |
| 8336 |
ReservedRooted<JSScript*> script0(&state.script0, frame->script()); |
| 8337 |
if (DebugAPI::hasAnyBreakpointsOrStepMode(script0) && |
| 8338 |
!HandleDebugTrap(cx, frame, pc)) { |
| 8339 |
TRACE_PRINTF("HandleDebugTrap returned error\n"); |
| 8340 |
GOTO_ERROR(); |
| 8341 |
} |
| 8342 |
if (!DebugAfterYield(cx, frame)) { |
| 8343 |
TRACE_PRINTF("DebugAfterYield returned error\n"); |
| 8344 |
GOTO_ERROR(); |
| 8345 |
} |
| 8346 |
} |
| 8347 |
COUNT_COVERAGE_PC(pc); |
| 8348 |
END_OP(AfterYield); |
| 8349 |
} |
| 8350 |
|
| 8351 |
CASE(Goto) { |
| 8352 |
ADVANCE(GET_JUMP_OFFSET(pc)); |
| 8353 |
PREDICT_NEXT(JumpTarget); |
| 8354 |
PREDICT_NEXT(LoopHead); |
| 8355 |
DISPATCH(); |
| 8356 |
} |
| 8357 |
|
| 8358 |
CASE(Coalesce) { |
| 8359 |
if (!VIRTSP(0).asValue().isNullOrUndefined()) { |
| 8360 |
ADVANCE(GET_JUMP_OFFSET(pc)); |
| 8361 |
DISPATCH(); |
| 8362 |
} else { |
| 8363 |
END_OP(Coalesce); |
| 8364 |
} |
| 8365 |
} |
| 8366 |
|
| 8367 |
CASE(Case) { |
| 8368 |
bool cond = VIRTPOP().asValue().toBoolean(); |
| 8369 |
if (cond) { |
| 8370 |
VIRTPOP(); |
| 8371 |
ADVANCE(GET_JUMP_OFFSET(pc)); |
| 8372 |
DISPATCH(); |
| 8373 |
} else { |
| 8374 |
END_OP(Case); |
| 8375 |
} |
| 8376 |
} |
| 8377 |
|
| 8378 |
CASE(Default) { |
| 8379 |
VIRTPOP(); |
| 8380 |
ADVANCE(GET_JUMP_OFFSET(pc)); |
| 8381 |
DISPATCH(); |
| 8382 |
} |
| 8383 |
|
| 8384 |
CASE(TableSwitch) { |
| 8385 |
int32_t len = GET_JUMP_OFFSET(pc); |
| 8386 |
int32_t low = GET_JUMP_OFFSET(pc + 1 * JUMP_OFFSET_LEN); |
| 8387 |
int32_t high = GET_JUMP_OFFSET(pc + 2 * JUMP_OFFSET_LEN); |
| 8388 |
Value v = VIRTPOP().asValue(); |
| 8389 |
int32_t i = 0; |
| 8390 |
if (v.isInt32()) { |
| 8391 |
i = v.toInt32(); |
| 8392 |
} else if (!v.isDouble() || |
| 8393 |
!mozilla::NumberEqualsInt32(v.toDouble(), &i)) { |
| 8394 |
ADVANCE(len); |
| 8395 |
DISPATCH(); |
| 8396 |
} |
| 8397 |
|
| 8398 |
if (i >= low && i <= high) { |
| 8399 |
uint32_t idx = uint32_t(i) - uint32_t(low); |
| 8400 |
uint32_t firstResumeIndex = GET_RESUMEINDEX(pc + 3 * JUMP_OFFSET_LEN); |
| 8401 |
pc = entryPC + resumeOffsets[firstResumeIndex + idx]; |
| 8402 |
DISPATCH(); |
| 8403 |
} |
| 8404 |
ADVANCE(len); |
| 8405 |
DISPATCH(); |
| 8406 |
} |
| 8407 |
|
| 8408 |
CASE(Return) { |
| 8409 |
frame->setReturnValue(VIRTPOP().asValue()); |
| 8410 |
goto do_return; |
| 8411 |
} |
| 8412 |
|
| 8413 |
CASE(GetRval) { |
| 8414 |
VIRTPUSH(StackVal(frame->returnValue())); |
| 8415 |
END_OP(GetRval); |
| 8416 |
} |
| 8417 |
|
| 8418 |
CASE(SetRval) { |
| 8419 |
frame->setReturnValue(VIRTPOP().asValue()); |
| 8420 |
END_OP(SetRval); |
| 8421 |
} |
| 8422 |
|
| 8423 |
do_return: |
| 8424 |
CASE(RetRval) { |
| 8425 |
SYNCSP(); |
| 8426 |
bool ok = true; |
| 8427 |
if (frame->isDebuggee() && !from_unwind) { |
| 8428 |
TRACE_PRINTF("doing DebugEpilogueOnBaselineReturn\n"); |
| 8429 |
PUSH_EXIT_FRAME(); |
| 8430 |
ok = DebugEpilogueOnBaselineReturn(cx, frame, pc); |
| 8431 |
} |
| 8432 |
from_unwind = false; |
| 8433 |
|
| 8434 |
uint32_t argc = frame->numActualArgs(); |
| 8435 |
sp = ctx.stack.popFrame(); |
| 8436 |
|
| 8437 |
// If FP is higher than the entry frame now, return; otherwise, |
| 8438 |
// do an inline state update. |
| 8439 |
if (stack.fp > entryFrame) { |
| 8440 |
*ret = frame->returnValue(); |
| 8441 |
TRACE_PRINTF("ret = %" PRIx64 "\n", ret->asRawBits()); |
| 8442 |
return ok ? PBIResult::Ok : PBIResult::Error; |
| 8443 |
} else { |
| 8444 |
TRACE_PRINTF("Return fastpath\n"); |
| 8445 |
Value ret = frame->returnValue(); |
| 8446 |
TRACE_PRINTF("ret = %" PRIx64 "\n", ret.asRawBits()); |
| 8447 |
|
| 8448 |
// Pop exit frame as well. |
| 8449 |
sp = ctx.stack.popFrame(); |
| 8450 |
// Pop fake return address and descriptor. |
| 8451 |
POPNNATIVE(2); |
| 8452 |
|
| 8453 |
// Set PC, frame, and current script. |
| 8454 |
frame = reinterpret_cast<BaselineFrame*>( |
| 8455 |
reinterpret_cast<uintptr_t>(stack.fp) - BaselineFrame::Size()); |
| 8456 |
TRACE_PRINTF(" sp -> %p, fp -> %p, frame -> %p\n", sp, ctx.stack.fp, |
| 8457 |
frame); |
| 8458 |
ctx.frameMgr.switchToFrame(frame); |
| 8459 |
ctx.frame = frame; |
| 8460 |
RESET_PC(frame->interpreterPC(), frame->script()); |
| 8461 |
|
| 8462 |
// Adjust caller's stack to complete the call op that PC still points |
| 8463 |
// to in that frame (pop args, push return value). |
| 8464 |
JSOp op = JSOp(*pc); |
| 8465 |
bool constructing = (op == JSOp::New || op == JSOp::NewContent || |
| 8466 |
op == JSOp::SuperCall); |
| 8467 |
// Fix-up return value; EnterJit would do this if we hadn't bypassed |
| 8468 |
// it. |
| 8469 |
if (constructing && ret.isPrimitive()) { |
| 8470 |
ret = sp[argc + constructing].asValue(); |
| 8471 |
TRACE_PRINTF("updated ret = %" PRIx64 "\n", ret.asRawBits()); |
| 8472 |
} |
| 8473 |
// Pop args -- this is 1 more than how many are pushed in the |
| 8474 |
// `totalArgs` count during the call fastpath because it includes |
| 8475 |
// the callee. |
| 8476 |
VIRTPOPN(argc + 2 + constructing); |
| 8477 |
// Push return value. |
| 8478 |
VIRTPUSH(StackVal(ret)); |
| 8479 |
|
| 8480 |
if (!ok) { |
| 8481 |
GOTO_ERROR(); |
| 8482 |
} |
| 8483 |
|
| 8484 |
// Advance past call instruction, and advance past IC. |
| 8485 |
NEXT_IC(); |
| 8486 |
ADVANCE(JSOpLength_Call); |
| 8487 |
|
| 8488 |
DISPATCH(); |
| 8489 |
} |
| 8490 |
} |
| 8491 |
|
| 8492 |
CASE(CheckReturn) { |
| 8493 |
Value thisval = VIRTPOP().asValue(); |
| 8494 |
// inlined version of frame->checkReturn(thisval, result) |
| 8495 |
// (js/src/vm/Stack.cpp). |
| 8496 |
HandleValue retVal = frame->returnValue(); |
| 8497 |
if (retVal.isObject()) { |
| 8498 |
VIRTPUSH(StackVal(retVal)); |
| 8499 |
} else if (!retVal.isUndefined()) { |
| 8500 |
PUSH_EXIT_FRAME(); |
| 8501 |
MOZ_ALWAYS_FALSE(ReportValueError(cx, JSMSG_BAD_DERIVED_RETURN, |
| 8502 |
JSDVG_IGNORE_STACK, retVal, |
| 8503 |
nullptr)); |
| 8504 |
GOTO_ERROR(); |
| 8505 |
} else if (thisval.isMagic(JS_UNINITIALIZED_LEXICAL)) { |
| 8506 |
PUSH_EXIT_FRAME(); |
| 8507 |
MOZ_ALWAYS_FALSE(ThrowUninitializedThis(cx)); |
| 8508 |
GOTO_ERROR(); |
| 8509 |
} else { |
| 8510 |
VIRTPUSH(StackVal(thisval)); |
| 8511 |
} |
| 8512 |
END_OP(CheckReturn); |
| 8513 |
} |
| 8514 |
|
| 8515 |
CASE(Throw) { |
| 8516 |
{ |
| 8517 |
ReservedRooted<Value> value0(&state.value0, VIRTPOP().asValue()); |
| 8518 |
PUSH_EXIT_FRAME(); |
| 8519 |
MOZ_ALWAYS_FALSE(ThrowOperation(cx, value0)); |
| 8520 |
GOTO_ERROR(); |
| 8521 |
} |
| 8522 |
END_OP(Throw); |
| 8523 |
} |
| 8524 |
|
| 8525 |
CASE(ThrowWithStack) { |
| 8526 |
{ |
| 8527 |
ReservedRooted<Value> value0(&state.value0, VIRTPOP().asValue()); |
| 8528 |
ReservedRooted<Value> value1(&state.value1, VIRTPOP().asValue()); |
| 8529 |
PUSH_EXIT_FRAME(); |
| 8530 |
MOZ_ALWAYS_FALSE(ThrowWithStackOperation(cx, value1, value0)); |
| 8531 |
GOTO_ERROR(); |
| 8532 |
} |
| 8533 |
END_OP(ThrowWithStack); |
| 8534 |
} |
| 8535 |
|
| 8536 |
CASE(ThrowMsg) { |
| 8537 |
{ |
| 8538 |
PUSH_EXIT_FRAME(); |
| 8539 |
MOZ_ALWAYS_FALSE(ThrowMsgOperation(cx, GET_UINT8(pc))); |
| 8540 |
GOTO_ERROR(); |
| 8541 |
} |
| 8542 |
END_OP(ThrowMsg); |
| 8543 |
} |
| 8544 |
|
| 8545 |
CASE(ThrowSetConst) { |
| 8546 |
{ |
| 8547 |
PUSH_EXIT_FRAME(); |
| 8548 |
ReservedRooted<JSScript*> script0(&state.script0, frame->script()); |
| 8549 |
ReportRuntimeLexicalError(cx, JSMSG_BAD_CONST_ASSIGN, script0, pc); |
| 8550 |
GOTO_ERROR(); |
| 8551 |
} |
| 8552 |
END_OP(ThrowSetConst); |
| 8553 |
} |
| 8554 |
|
| 8555 |
CASE(Try) |
| 8556 |
CASE(TryDestructuring) { |
| 8557 |
static_assert(JSOpLength_Try == JSOpLength_TryDestructuring); |
| 8558 |
END_OP(Try); |
| 8559 |
} |
| 8560 |
|
| 8561 |
CASE(Exception) { |
| 8562 |
{ |
| 8563 |
PUSH_EXIT_FRAME(); |
| 8564 |
if (!GetAndClearException(cx, &state.res)) { |
| 8565 |
GOTO_ERROR(); |
| 8566 |
} |
| 8567 |
} |
| 8568 |
VIRTPUSH(StackVal(state.res)); |
| 8569 |
state.res.setUndefined(); |
| 8570 |
END_OP(Exception); |
| 8571 |
} |
| 8572 |
|
| 8573 |
CASE(ExceptionAndStack) { |
| 8574 |
{ |
| 8575 |
ReservedRooted<Value> value0(&state.value0); |
| 8576 |
{ |
| 8577 |
PUSH_EXIT_FRAME(); |
| 8578 |
if (!cx.getCx()->getPendingExceptionStack(&value0)) { |
| 8579 |
GOTO_ERROR(); |
| 8580 |
} |
| 8581 |
if (!GetAndClearException(cx, &state.res)) { |
| 8582 |
GOTO_ERROR(); |
| 8583 |
} |
| 8584 |
} |
| 8585 |
VIRTPUSH(StackVal(state.res)); |
| 8586 |
VIRTPUSH(StackVal(value0)); |
| 8587 |
state.res.setUndefined(); |
| 8588 |
} |
| 8589 |
END_OP(ExceptionAndStack); |
| 8590 |
} |
| 8591 |
|
| 8592 |
CASE(Finally) { |
| 8593 |
#ifdef ENABLE_INTERRUPT_CHECKS |
| 8594 |
if (ctx.frameMgr.cxForLocalUseOnly()->hasAnyPendingInterrupt()) { |
| 8595 |
PUSH_EXIT_FRAME(); |
| 8596 |
if (!InterruptCheck(cx)) { |
| 8597 |
GOTO_ERROR(); |
| 8598 |
} |
| 8599 |
} |
| 8600 |
#endif |
| 8601 |
END_OP(Finally); |
| 8602 |
} |
| 8603 |
|
| 8604 |
CASE(Uninitialized) { |
| 8605 |
VIRTPUSH(StackVal(MagicValue(JS_UNINITIALIZED_LEXICAL))); |
| 8606 |
END_OP(Uninitialized); |
| 8607 |
} |
| 8608 |
CASE(InitLexical) { |
| 8609 |
uint32_t i = GET_LOCALNO(pc); |
| 8610 |
frame->unaliasedLocal(i) = VIRTSP(0).asValue(); |
| 8611 |
END_OP(InitLexical); |
| 8612 |
} |
| 8613 |
|
| 8614 |
CASE(InitAliasedLexical) { |
| 8615 |
EnvironmentCoordinate ec = EnvironmentCoordinate(pc); |
| 8616 |
EnvironmentObject& obj = getEnvironmentFromCoordinate(frame, ec); |
| 8617 |
obj.setAliasedBinding(ec, VIRTSP(0).asValue()); |
| 8618 |
END_OP(InitAliasedLexical); |
| 8619 |
} |
| 8620 |
CASE(CheckLexical) { |
| 8621 |
if (VIRTSP(0).asValue().isMagic(JS_UNINITIALIZED_LEXICAL)) { |
| 8622 |
PUSH_EXIT_FRAME(); |
| 8623 |
ReservedRooted<JSScript*> script0(&state.script0, frame->script()); |
| 8624 |
ReportRuntimeLexicalError(cx, JSMSG_UNINITIALIZED_LEXICAL, script0, |
| 8625 |
pc); |
| 8626 |
GOTO_ERROR(); |
| 8627 |
} |
| 8628 |
END_OP(CheckLexical); |
| 8629 |
} |
| 8630 |
CASE(CheckAliasedLexical) { |
| 8631 |
if (VIRTSP(0).asValue().isMagic(JS_UNINITIALIZED_LEXICAL)) { |
| 8632 |
PUSH_EXIT_FRAME(); |
| 8633 |
ReservedRooted<JSScript*> script0(&state.script0, frame->script()); |
| 8634 |
ReportRuntimeLexicalError(cx, JSMSG_UNINITIALIZED_LEXICAL, script0, |
| 8635 |
pc); |
| 8636 |
GOTO_ERROR(); |
| 8637 |
} |
| 8638 |
END_OP(CheckAliasedLexical); |
| 8639 |
} |
| 8640 |
|
| 8641 |
CASE(BindUnqualifiedGName) { |
| 8642 |
IC_SET_OBJ_ARG( |
| 8643 |
0, |
| 8644 |
&ctx.frameMgr.cxForLocalUseOnly()->global()->lexicalEnvironment()); |
| 8645 |
IC_ZERO_ARG(1); |
| 8646 |
IC_ZERO_ARG(2); |
| 8647 |
INVOKE_IC_AND_PUSH(BindName, false); |
| 8648 |
END_OP(BindUnqualifiedGName); |
| 8649 |
} |
| 8650 |
CASE(BindName) { |
| 8651 |
IC_SET_OBJ_ARG(0, frame->environmentChain()); |
| 8652 |
IC_ZERO_ARG(1); |
| 8653 |
IC_ZERO_ARG(2); |
| 8654 |
INVOKE_IC_AND_PUSH(BindName, false); |
| 8655 |
END_OP(BindName); |
| 8656 |
} |
| 8657 |
CASE(BindUnqualifiedName) { |
| 8658 |
IC_SET_OBJ_ARG(0, frame->environmentChain()); |
| 8659 |
IC_ZERO_ARG(1); |
| 8660 |
IC_ZERO_ARG(2); |
| 8661 |
INVOKE_IC_AND_PUSH(BindName, false); |
| 8662 |
END_OP(BindUnqualifiedName); |
| 8663 |
} |
| 8664 |
CASE(GetGName) { |
| 8665 |
IC_SET_OBJ_ARG( |
| 8666 |
0, |
| 8667 |
&ctx.frameMgr.cxForLocalUseOnly()->global()->lexicalEnvironment()); |
| 8668 |
IC_ZERO_ARG(1); |
| 8669 |
IC_ZERO_ARG(2); |
| 8670 |
INVOKE_IC_AND_PUSH(GetName, false); |
| 8671 |
END_OP(GetGName); |
| 8672 |
} |
| 8673 |
CASE(GetName) { |
| 8674 |
IC_SET_OBJ_ARG(0, frame->environmentChain()); |
| 8675 |
IC_ZERO_ARG(1); |
| 8676 |
IC_ZERO_ARG(2); |
| 8677 |
INVOKE_IC_AND_PUSH(GetName, false); |
| 8678 |
END_OP(GetName); |
| 8679 |
} |
| 8680 |
|
| 8681 |
CASE(GetArg) { |
| 8682 |
unsigned i = GET_ARGNO(pc); |
| 8683 |
if (argsObjAliasesFormals) { |
| 8684 |
VIRTPUSH(StackVal(frame->argsObj().arg(i))); |
| 8685 |
} else { |
| 8686 |
VIRTPUSH(StackVal(frame->argv()[i])); |
| 8687 |
} |
| 8688 |
END_OP(GetArg); |
| 8689 |
} |
| 8690 |
|
| 8691 |
CASE(GetFrameArg) { |
| 8692 |
uint32_t i = GET_ARGNO(pc); |
| 8693 |
VIRTPUSH(StackVal(frame->argv()[i])); |
| 8694 |
END_OP(GetFrameArg); |
| 8695 |
} |
| 8696 |
|
| 8697 |
CASE(GetLocal) { |
| 8698 |
uint32_t i = GET_LOCALNO(pc); |
| 8699 |
TRACE_PRINTF(" -> local: %d\n", int(i)); |
| 8700 |
VIRTPUSH(StackVal(GETLOCAL(i))); |
| 8701 |
END_OP(GetLocal); |
| 8702 |
} |
| 8703 |
|
| 8704 |
CASE(ArgumentsLength) { |
| 8705 |
VIRTPUSH(StackVal(Int32Value(frame->numActualArgs()))); |
| 8706 |
END_OP(ArgumentsLength); |
| 8707 |
} |
| 8708 |
|
| 8709 |
CASE(GetActualArg) { |
| 8710 |
MOZ_ASSERT(!frame->script()->needsArgsObj()); |
| 8711 |
uint32_t index = VIRTSP(0).asValue().toInt32(); |
| 8712 |
VIRTSPWRITE(0, StackVal(frame->unaliasedActual(index))); |
| 8713 |
END_OP(GetActualArg); |
| 8714 |
} |
| 8715 |
|
| 8716 |
CASE(GetAliasedVar) |
| 8717 |
CASE(GetAliasedDebugVar) { |
| 8718 |
static_assert(JSOpLength_GetAliasedVar == |
| 8719 |
JSOpLength_GetAliasedDebugVar); |
| 8720 |
EnvironmentCoordinate ec = EnvironmentCoordinate(pc); |
| 8721 |
EnvironmentObject& obj = getEnvironmentFromCoordinate(frame, ec); |
| 8722 |
VIRTPUSH(StackVal(obj.aliasedBinding(ec))); |
| 8723 |
END_OP(GetAliasedVar); |
| 8724 |
} |
| 8725 |
|
| 8726 |
CASE(GetImport) { |
| 8727 |
IC_ZERO_ARG(0); |
| 8728 |
IC_ZERO_ARG(1); |
| 8729 |
IC_ZERO_ARG(2); |
| 8730 |
INVOKE_IC_AND_PUSH(GetImport, false); |
| 8731 |
END_OP(GetImport); |
| 8732 |
} |
| 8733 |
|
| 8734 |
CASE(GetIntrinsic) { |
| 8735 |
IC_ZERO_ARG(0); |
| 8736 |
IC_ZERO_ARG(1); |
| 8737 |
IC_ZERO_ARG(2); |
| 8738 |
INVOKE_IC_AND_PUSH(LazyConstant, false); |
| 8739 |
END_OP(GetIntrinsic); |
| 8740 |
} |
| 8741 |
|
| 8742 |
CASE(Callee) { |
| 8743 |
VIRTPUSH(StackVal(frame->calleev())); |
| 8744 |
END_OP(Callee); |
| 8745 |
} |
| 8746 |
|
| 8747 |
CASE(EnvCallee) { |
| 8748 |
uint8_t numHops = GET_UINT8(pc); |
| 8749 |
JSObject* env = &frame->environmentChain()->as<EnvironmentObject>(); |
| 8750 |
for (unsigned i = 0; i < numHops; i++) { |
| 8751 |
env = &env->as<EnvironmentObject>().enclosingEnvironment(); |
| 8752 |
} |
| 8753 |
VIRTPUSH(StackVal(ObjectValue(env->as<CallObject>().callee()))); |
| 8754 |
END_OP(EnvCallee); |
| 8755 |
} |
| 8756 |
|
| 8757 |
CASE(SetProp) |
| 8758 |
CASE(StrictSetProp) |
| 8759 |
CASE(SetName) |
| 8760 |
CASE(StrictSetName) |
| 8761 |
CASE(SetGName) |
| 8762 |
CASE(StrictSetGName) { |
| 8763 |
static_assert(JSOpLength_SetProp == JSOpLength_StrictSetProp); |
| 8764 |
static_assert(JSOpLength_SetProp == JSOpLength_SetName); |
| 8765 |
static_assert(JSOpLength_SetProp == JSOpLength_StrictSetName); |
| 8766 |
static_assert(JSOpLength_SetProp == JSOpLength_SetGName); |
| 8767 |
static_assert(JSOpLength_SetProp == JSOpLength_StrictSetGName); |
| 8768 |
IC_POP_ARG(1); |
| 8769 |
IC_POP_ARG(0); |
| 8770 |
IC_ZERO_ARG(2); |
| 8771 |
VIRTPUSH(StackVal(ic_arg1)); |
| 8772 |
INVOKE_IC(SetProp, false); |
| 8773 |
END_OP(SetProp); |
| 8774 |
} |
| 8775 |
|
| 8776 |
CASE(InitProp) |
| 8777 |
CASE(InitHiddenProp) |
| 8778 |
CASE(InitLockedProp) { |
| 8779 |
static_assert(JSOpLength_InitProp == JSOpLength_InitHiddenProp); |
| 8780 |
static_assert(JSOpLength_InitProp == JSOpLength_InitLockedProp); |
| 8781 |
IC_POP_ARG(1); |
| 8782 |
IC_SET_ARG_FROM_STACK(0, 0); |
| 8783 |
IC_ZERO_ARG(2); |
| 8784 |
INVOKE_IC(SetProp, false); |
| 8785 |
END_OP(InitProp); |
| 8786 |
} |
| 8787 |
CASE(InitGLexical) { |
| 8788 |
IC_SET_ARG_FROM_STACK(1, 0); |
| 8789 |
IC_SET_OBJ_ARG( |
| 8790 |
0, |
| 8791 |
&ctx.frameMgr.cxForLocalUseOnly()->global()->lexicalEnvironment()); |
| 8792 |
IC_ZERO_ARG(2); |
| 8793 |
INVOKE_IC(SetProp, false); |
| 8794 |
END_OP(InitGLexical); |
| 8795 |
} |
| 8796 |
|
| 8797 |
CASE(SetArg) { |
| 8798 |
unsigned i = GET_ARGNO(pc); |
| 8799 |
if (argsObjAliasesFormals) { |
| 8800 |
frame->argsObj().setArg(i, VIRTSP(0).asValue()); |
| 8801 |
} else { |
| 8802 |
frame->argv()[i] = VIRTSP(0).asValue(); |
| 8803 |
} |
| 8804 |
END_OP(SetArg); |
| 8805 |
} |
| 8806 |
|
| 8807 |
CASE(SetLocal) { |
| 8808 |
uint32_t i = GET_LOCALNO(pc); |
| 8809 |
TRACE_PRINTF(" -> local: %d\n", int(i)); |
| 8810 |
SETLOCAL(i, VIRTSP(0).asValue()); |
| 8811 |
END_OP(SetLocal); |
| 8812 |
} |
| 8813 |
|
| 8814 |
CASE(SetAliasedVar) { |
| 8815 |
EnvironmentCoordinate ec = EnvironmentCoordinate(pc); |
| 8816 |
EnvironmentObject& obj = getEnvironmentFromCoordinate(frame, ec); |
| 8817 |
MOZ_ASSERT(!IsUninitializedLexical(obj.aliasedBinding(ec))); |
| 8818 |
obj.setAliasedBinding(ec, VIRTSP(0).asValue()); |
| 8819 |
END_OP(SetAliasedVar); |
| 8820 |
} |
| 8821 |
|
| 8822 |
CASE(SetIntrinsic) { |
| 8823 |
{ |
| 8824 |
ReservedRooted<Value> value0(&state.value0, VIRTSP(0).asValue()); |
| 8825 |
ReservedRooted<JSScript*> script0(&state.script0, frame->script()); |
| 8826 |
{ |
| 8827 |
PUSH_EXIT_FRAME(); |
| 8828 |
if (!SetIntrinsicOperation(cx, script0, pc, value0)) { |
| 8829 |
GOTO_ERROR(); |
| 8830 |
} |
| 8831 |
} |
| 8832 |
} |
| 8833 |
END_OP(SetIntrinsic); |
| 8834 |
} |
| 8835 |
|
| 8836 |
CASE(PushLexicalEnv) { |
| 8837 |
{ |
| 8838 |
ReservedRooted<Scope*> scope0(&state.scope0, |
| 8839 |
frame->script()->getScope(pc)); |
| 8840 |
{ |
| 8841 |
PUSH_EXIT_FRAME(); |
| 8842 |
if (!frame->pushLexicalEnvironment(cx, scope0.as<LexicalScope>())) { |
| 8843 |
GOTO_ERROR(); |
| 8844 |
} |
| 8845 |
} |
| 8846 |
} |
| 8847 |
END_OP(PushLexicalEnv); |
| 8848 |
} |
| 8849 |
CASE(PopLexicalEnv) { |
| 8850 |
if (frame->isDebuggee()) { |
| 8851 |
TRACE_PRINTF("doing DebugLeaveThenPopLexicalEnv\n"); |
| 8852 |
PUSH_EXIT_FRAME(); |
| 8853 |
if (!DebugLeaveThenPopLexicalEnv(cx, frame, pc)) { |
| 8854 |
GOTO_ERROR(); |
| 8855 |
} |
| 8856 |
} else { |
| 8857 |
frame->popOffEnvironmentChain<LexicalEnvironmentObject>(); |
| 8858 |
} |
| 8859 |
END_OP(PopLexicalEnv); |
| 8860 |
} |
| 8861 |
CASE(DebugLeaveLexicalEnv) { |
| 8862 |
if (frame->isDebuggee()) { |
| 8863 |
TRACE_PRINTF("doing DebugLeaveLexicalEnv\n"); |
| 8864 |
PUSH_EXIT_FRAME(); |
| 8865 |
if (!DebugLeaveLexicalEnv(cx, frame, pc)) { |
| 8866 |
GOTO_ERROR(); |
| 8867 |
} |
| 8868 |
} |
| 8869 |
END_OP(DebugLeaveLexicalEnv); |
| 8870 |
} |
| 8871 |
|
| 8872 |
CASE(RecreateLexicalEnv) { |
| 8873 |
{ |
| 8874 |
PUSH_EXIT_FRAME(); |
| 8875 |
if (frame->isDebuggee()) { |
| 8876 |
TRACE_PRINTF("doing DebuggeeRecreateLexicalEnv\n"); |
| 8877 |
if (!DebuggeeRecreateLexicalEnv(cx, frame, pc)) { |
| 8878 |
GOTO_ERROR(); |
| 8879 |
} |
| 8880 |
} else { |
| 8881 |
if (!frame->recreateLexicalEnvironment<false>(cx)) { |
| 8882 |
GOTO_ERROR(); |
| 8883 |
} |
| 8884 |
} |
| 8885 |
} |
| 8886 |
END_OP(RecreateLexicalEnv); |
| 8887 |
} |
| 8888 |
|
| 8889 |
CASE(FreshenLexicalEnv) { |
| 8890 |
{ |
| 8891 |
PUSH_EXIT_FRAME(); |
| 8892 |
if (frame->isDebuggee()) { |
| 8893 |
TRACE_PRINTF("doing DebuggeeFreshenLexicalEnv\n"); |
| 8894 |
if (!DebuggeeFreshenLexicalEnv(cx, frame, pc)) { |
| 8895 |
GOTO_ERROR(); |
| 8896 |
} |
| 8897 |
} else { |
| 8898 |
if (!frame->freshenLexicalEnvironment<false>(cx)) { |
| 8899 |
GOTO_ERROR(); |
| 8900 |
} |
| 8901 |
} |
| 8902 |
} |
| 8903 |
END_OP(FreshenLexicalEnv); |
| 8904 |
} |
| 8905 |
CASE(PushClassBodyEnv) { |
| 8906 |
{ |
| 8907 |
ReservedRooted<Scope*> scope0(&state.scope0, |
| 8908 |
frame->script()->getScope(pc)); |
| 8909 |
PUSH_EXIT_FRAME(); |
| 8910 |
if (!frame->pushClassBodyEnvironment(cx, |
| 8911 |
scope0.as<ClassBodyScope>())) { |
| 8912 |
GOTO_ERROR(); |
| 8913 |
} |
| 8914 |
} |
| 8915 |
END_OP(PushClassBodyEnv); |
| 8916 |
} |
| 8917 |
CASE(PushVarEnv) { |
| 8918 |
{ |
| 8919 |
ReservedRooted<Scope*> scope0(&state.scope0, |
| 8920 |
frame->script()->getScope(pc)); |
| 8921 |
PUSH_EXIT_FRAME(); |
| 8922 |
if (!frame->pushVarEnvironment(cx, scope0)) { |
| 8923 |
GOTO_ERROR(); |
| 8924 |
} |
| 8925 |
} |
| 8926 |
END_OP(PushVarEnv); |
| 8927 |
} |
| 8928 |
CASE(EnterWith) { |
| 8929 |
{ |
| 8930 |
ReservedRooted<Scope*> scope0(&state.scope0, |
| 8931 |
frame->script()->getScope(pc)); |
| 8932 |
ReservedRooted<Value> value0(&state.value0, VIRTPOP().asValue()); |
| 8933 |
PUSH_EXIT_FRAME(); |
| 8934 |
if (!EnterWithOperation(cx, frame, value0, scope0.as<WithScope>())) { |
| 8935 |
GOTO_ERROR(); |
| 8936 |
} |
| 8937 |
} |
| 8938 |
END_OP(EnterWith); |
| 8939 |
} |
| 8940 |
CASE(LeaveWith) { |
| 8941 |
frame->popOffEnvironmentChain<WithEnvironmentObject>(); |
| 8942 |
END_OP(LeaveWith); |
| 8943 |
} |
| 8944 |
#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT |
| 8945 |
CASE(AddDisposable) { |
| 8946 |
{ |
| 8947 |
ReservedRooted<JSObject*> env(&state.obj0, frame->environmentChain()); |
| 8948 |
|
| 8949 |
ReservedRooted<JS::Value> needsClosure(&state.value0, |
| 8950 |
VIRTPOP().asValue()); |
| 8951 |
ReservedRooted<JS::Value> method(&state.value1, VIRTPOP().asValue()); |
| 8952 |
ReservedRooted<JS::Value> val(&state.value2, VIRTPOP().asValue()); |
| 8953 |
UsingHint hint = UsingHint(GET_UINT8(pc)); |
| 8954 |
PUSH_EXIT_FRAME(); |
| 8955 |
if (!AddDisposableResourceToCapability( |
| 8956 |
cx, env, val, method, needsClosure.toBoolean(), hint)) { |
| 8957 |
GOTO_ERROR(); |
| 8958 |
} |
| 8959 |
} |
| 8960 |
END_OP(AddDisposable); |
| 8961 |
} |
| 8962 |
|
| 8963 |
CASE(TakeDisposeCapability) { |
| 8964 |
{ |
| 8965 |
ReservedRooted<JSObject*> env(&state.obj0, frame->environmentChain()); |
| 8966 |
JS::Value maybeDisposables = |
| 8967 |
env->as<DisposableEnvironmentObject>().getDisposables(); |
| 8968 |
|
| 8969 |
MOZ_ASSERT(maybeDisposables.isObject() || |
| 8970 |
maybeDisposables.isUndefined()); |
| 8971 |
|
| 8972 |
if (maybeDisposables.isUndefined()) { |
| 8973 |
VIRTPUSH(StackVal(UndefinedValue())); |
| 8974 |
} else { |
| 8975 |
VIRTPUSH(StackVal(maybeDisposables)); |
| 8976 |
env->as<DisposableEnvironmentObject>().clearDisposables(); |
| 8977 |
} |
| 8978 |
} |
| 8979 |
END_OP(TakeDisposeCapability); |
| 8980 |
} |
| 8981 |
|
| 8982 |
CASE(CreateSuppressedError) { |
| 8983 |
ErrorObject* errorObj; |
| 8984 |
{ |
| 8985 |
ReservedRooted<JS::Value> error(&state.value0, VIRTPOP().asValue()); |
| 8986 |
ReservedRooted<JS::Value> suppressed(&state.value1, |
| 8987 |
VIRTPOP().asValue()); |
| 8988 |
PUSH_EXIT_FRAME(); |
| 8989 |
errorObj = CreateSuppressedError(cx, error, suppressed); |
| 8990 |
if (!errorObj) { |
| 8991 |
GOTO_ERROR(); |
| 8992 |
} |
| 8993 |
} |
| 8994 |
VIRTPUSH(StackVal(ObjectValue(*errorObj))); |
| 8995 |
END_OP(CreateSuppressedError); |
| 8996 |
} |
| 8997 |
#endif |
| 8998 |
CASE(BindVar) { |
| 8999 |
JSObject* varObj; |
| 9000 |
{ |
| 9001 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 9002 |
frame->environmentChain()); |
| 9003 |
PUSH_EXIT_FRAME(); |
| 9004 |
varObj = BindVarOperation(cx, obj0); |
| 9005 |
} |
| 9006 |
VIRTPUSH(StackVal(ObjectValue(*varObj))); |
| 9007 |
END_OP(BindVar); |
| 9008 |
} |
| 9009 |
|
| 9010 |
CASE(GlobalOrEvalDeclInstantiation) { |
| 9011 |
GCThingIndex lastFun = GET_GCTHING_INDEX(pc); |
| 9012 |
{ |
| 9013 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 9014 |
frame->environmentChain()); |
| 9015 |
ReservedRooted<JSScript*> script0(&state.script0, frame->script()); |
| 9016 |
PUSH_EXIT_FRAME(); |
| 9017 |
if (!GlobalOrEvalDeclInstantiation(cx, obj0, script0, lastFun)) { |
| 9018 |
GOTO_ERROR(); |
| 9019 |
} |
| 9020 |
} |
| 9021 |
END_OP(GlobalOrEvalDeclInstantiation); |
| 9022 |
} |
| 9023 |
|
| 9024 |
CASE(DelName) { |
| 9025 |
{ |
| 9026 |
ReservedRooted<PropertyName*> name0(&state.name0, |
| 9027 |
frame->script()->getName(pc)); |
| 9028 |
ReservedRooted<JSObject*> obj0(&state.obj0, |
| 9029 |
frame->environmentChain()); |
| 9030 |
PUSH_EXIT_FRAME(); |
| 9031 |
if (!DeleteNameOperation(cx, name0, obj0, &state.res)) { |
| 9032 |
GOTO_ERROR(); |
| 9033 |
} |
| 9034 |
} |
| 9035 |
VIRTPUSH(StackVal(state.res)); |
| 9036 |
state.res.setUndefined(); |
| 9037 |
END_OP(DelName); |
| 9038 |
} |
| 9039 |
|
| 9040 |
CASE(Arguments) { |
| 9041 |
{ |
| 9042 |
PUSH_EXIT_FRAME(); |
| 9043 |
if (!NewArgumentsObject(cx, frame, &state.res)) { |
| 9044 |
GOTO_ERROR(); |
| 9045 |
} |
| 9046 |
} |
| 9047 |
VIRTPUSH(StackVal(state.res)); |
| 9048 |
state.res.setUndefined(); |
| 9049 |
END_OP(Arguments); |
| 9050 |
} |
| 9051 |
|
| 9052 |
CASE(Rest) { |
| 9053 |
IC_ZERO_ARG(0); |
| 9054 |
IC_ZERO_ARG(1); |
| 9055 |
IC_ZERO_ARG(2); |
| 9056 |
INVOKE_IC_AND_PUSH(Rest, false); |
| 9057 |
END_OP(Rest); |
| 9058 |
} |
| 9059 |
|
| 9060 |
CASE(FunctionThis) { |
| 9061 |
{ |
| 9062 |
PUSH_EXIT_FRAME(); |
| 9063 |
if (!js::GetFunctionThis(cx, frame, &state.res)) { |
| 9064 |
GOTO_ERROR(); |
| 9065 |
} |
| 9066 |
} |
| 9067 |
VIRTPUSH(StackVal(state.res)); |
| 9068 |
state.res.setUndefined(); |
| 9069 |
END_OP(FunctionThis); |
| 9070 |
} |
| 9071 |
|
| 9072 |
CASE(Pop) { |
| 9073 |
VIRTPOP(); |
| 9074 |
END_OP(Pop); |
| 9075 |
} |
| 9076 |
CASE(PopN) { |
| 9077 |
SYNCSP(); |
| 9078 |
uint32_t n = GET_UINT16(pc); |
| 9079 |
VIRTPOPN(n); |
| 9080 |
END_OP(PopN); |
| 9081 |
} |
| 9082 |
CASE(Dup) { |
| 9083 |
StackVal value = VIRTSP(0); |
| 9084 |
VIRTPUSH(value); |
| 9085 |
END_OP(Dup); |
| 9086 |
} |
| 9087 |
CASE(Dup2) { |
| 9088 |
StackVal value1 = VIRTSP(0); |
| 9089 |
StackVal value2 = VIRTSP(1); |
| 9090 |
VIRTPUSH(value2); |
| 9091 |
VIRTPUSH(value1); |
| 9092 |
END_OP(Dup2); |
| 9093 |
} |
| 9094 |
CASE(DupAt) { |
| 9095 |
unsigned i = GET_UINT24(pc); |
| 9096 |
StackVal value = VIRTSP(i); |
| 9097 |
VIRTPUSH(value); |
| 9098 |
END_OP(DupAt); |
| 9099 |
} |
| 9100 |
CASE(Swap) { |
| 9101 |
StackVal v0 = VIRTSP(0); |
| 9102 |
StackVal v1 = VIRTSP(1); |
| 9103 |
VIRTSPWRITE(0, v1); |
| 9104 |
VIRTSPWRITE(1, v0); |
| 9105 |
END_OP(Swap); |
| 9106 |
} |
| 9107 |
CASE(Pick) { |
| 9108 |
unsigned i = GET_UINT8(pc); |
| 9109 |
SYNCSP(); |
| 9110 |
StackVal tmp = sp[i]; |
| 9111 |
memmove(&sp[1], &sp[0], sizeof(StackVal) * i); |
| 9112 |
VIRTSPWRITE(0, tmp); |
| 9113 |
END_OP(Pick); |
| 9114 |
} |
| 9115 |
CASE(Unpick) { |
| 9116 |
unsigned i = GET_UINT8(pc); |
| 9117 |
StackVal tmp = VIRTSP(0); |
| 9118 |
SYNCSP(); |
| 9119 |
memmove(&sp[0], &sp[1], sizeof(StackVal) * i); |
| 9120 |
sp[i] = tmp; |
| 9121 |
END_OP(Unpick); |
| 9122 |
} |
| 9123 |
CASE(DebugCheckSelfHosted) { |
| 9124 |
HandleValue val = SPHANDLE(0); |
| 9125 |
{ |
| 9126 |
PUSH_EXIT_FRAME(); |
| 9127 |
if (!Debug_CheckSelfHosted(cx, val)) { |
| 9128 |
GOTO_ERROR(); |
| 9129 |
} |
| 9130 |
} |
| 9131 |
END_OP(DebugCheckSelfHosted); |
| 9132 |
} |
| 9133 |
CASE(Lineno) { END_OP(Lineno); } |
| 9134 |
CASE(NopDestructuring) { END_OP(NopDestructuring); } |
| 9135 |
CASE(ForceInterpreter) { END_OP(ForceInterpreter); } |
| 9136 |
CASE(Debugger) { |
| 9137 |
{ |
| 9138 |
PUSH_EXIT_FRAME(); |
| 9139 |
if (!OnDebuggerStatement(cx, frame)) { |
| 9140 |
GOTO_ERROR(); |
| 9141 |
} |
| 9142 |
} |
| 9143 |
END_OP(Debugger); |
| 9144 |
} |
| 9145 |
|
| 9146 |
label_default: |
| 9147 |
#ifndef ENABLE_COMPUTED_GOTO_DISPATCH |
| 9148 |
default: |
| 9149 |
#endif |
| 9150 |
MOZ_CRASH("Bad opcode"); |
| 9151 |
} |
| 9152 |
} |
| 9153 |
|
| 9154 |
restart: |
| 9155 |
// This is a `goto` target so that we exit any on-stack exit frames |
| 9156 |
// before restarting, to match previous behavior. |
| 9157 |
return PortableBaselineInterpret<true, HybridICs>( |
| 9158 |
ctx.frameMgr.cxForLocalUseOnly(), ctx.state, ctx.stack, sp, envChain, ret, |
| 9159 |
pc, isd, entryPC, frame, entryFrame, restartCode); |
| 9160 |
|
| 9161 |
error: |
| 9162 |
TRACE_PRINTF("HandleException: frame %p\n", frame); |
| 9163 |
{ |
| 9164 |
ResumeFromException rfe; |
| 9165 |
{ |
| 9166 |
PUSH_EXIT_FRAME(); |
| 9167 |
HandleException(&rfe); |
| 9168 |
} |
| 9169 |
|
| 9170 |
switch (rfe.kind) { |
| 9171 |
case ExceptionResumeKind::EntryFrame: |
| 9172 |
TRACE_PRINTF(" -> Return from entry frame\n"); |
| 9173 |
frame->setReturnValue(MagicValue(JS_ION_ERROR)); |
| 9174 |
ctx.stack.fp = reinterpret_cast<StackVal*>(rfe.framePointer); |
| 9175 |
ctx.stack.unwindingSP = reinterpret_cast<StackVal*>(rfe.stackPointer); |
| 9176 |
ctx.stack.unwindingFP = reinterpret_cast<StackVal*>(rfe.framePointer); |
| 9177 |
goto unwind_error; |
| 9178 |
case ExceptionResumeKind::Catch: |
| 9179 |
RESET_PC(frame->interpreterPC(), frame->script()); |
| 9180 |
ctx.stack.fp = reinterpret_cast<StackVal*>(rfe.framePointer); |
| 9181 |
ctx.stack.unwindingSP = reinterpret_cast<StackVal*>(rfe.stackPointer); |
| 9182 |
ctx.stack.unwindingFP = reinterpret_cast<StackVal*>(rfe.framePointer); |
| 9183 |
TRACE_PRINTF(" -> catch to pc %p\n", pc); |
| 9184 |
goto unwind; |
| 9185 |
case ExceptionResumeKind::Finally: |
| 9186 |
RESET_PC(frame->interpreterPC(), frame->script()); |
| 9187 |
ctx.stack.fp = reinterpret_cast<StackVal*>(rfe.framePointer); |
| 9188 |
sp = reinterpret_cast<StackVal*>(rfe.stackPointer); |
| 9189 |
TRACE_PRINTF(" -> finally to pc %p\n", pc); |
| 9190 |
VIRTPUSH(StackVal(rfe.exception)); |
| 9191 |
VIRTPUSH(StackVal(rfe.exceptionStack)); |
| 9192 |
VIRTPUSH(StackVal(BooleanValue(true))); |
| 9193 |
ctx.stack.unwindingSP = sp; |
| 9194 |
ctx.stack.unwindingFP = ctx.stack.fp; |
| 9195 |
goto unwind; |
| 9196 |
case ExceptionResumeKind::ForcedReturnBaseline: |
| 9197 |
RESET_PC(frame->interpreterPC(), frame->script()); |
| 9198 |
ctx.stack.fp = reinterpret_cast<StackVal*>(rfe.framePointer); |
| 9199 |
ctx.stack.unwindingSP = reinterpret_cast<StackVal*>(rfe.stackPointer); |
| 9200 |
ctx.stack.unwindingFP = reinterpret_cast<StackVal*>(rfe.framePointer); |
| 9201 |
TRACE_PRINTF(" -> forced return\n"); |
| 9202 |
goto unwind_ret; |
| 9203 |
case ExceptionResumeKind::ForcedReturnIon: |
| 9204 |
MOZ_CRASH( |
| 9205 |
"Unexpected ForcedReturnIon exception-resume kind in Portable " |
| 9206 |
"Baseline"); |
| 9207 |
case ExceptionResumeKind::Bailout: |
| 9208 |
MOZ_CRASH( |
| 9209 |
"Unexpected Bailout exception-resume kind in Portable Baseline"); |
| 9210 |
case ExceptionResumeKind::WasmInterpEntry: |
| 9211 |
MOZ_CRASH( |
| 9212 |
"Unexpected WasmInterpEntry exception-resume kind in Portable " |
| 9213 |
"Baseline"); |
| 9214 |
case ExceptionResumeKind::WasmCatch: |
| 9215 |
MOZ_CRASH( |
| 9216 |
"Unexpected WasmCatch exception-resume kind in Portable " |
| 9217 |
"Baseline"); |
| 9218 |
} |
| 9219 |
} |
| 9220 |
|
| 9221 |
DISPATCH(); |
| 9222 |
|
| 9223 |
ic_fail: |
| 9224 |
RESTART(ic_result); |
| 9225 |
switch (ic_result) { |
| 9226 |
case PBIResult::Ok: |
| 9227 |
MOZ_CRASH("Unreachable: ic_result must be an error if we reach ic_fail"); |
| 9228 |
case PBIResult::Error: |
| 9229 |
goto error; |
| 9230 |
case PBIResult::Unwind: |
| 9231 |
goto unwind; |
| 9232 |
case PBIResult::UnwindError: |
| 9233 |
goto unwind_error; |
| 9234 |
case PBIResult::UnwindRet: |
| 9235 |
goto unwind_ret; |
| 9236 |
} |
| 9237 |
|
| 9238 |
unwind: |
| 9239 |
TRACE_PRINTF("unwind: fp = %p entryFrame = %p\n", ctx.stack.fp, entryFrame); |
| 9240 |
if (reinterpret_cast<uintptr_t>(ctx.stack.unwindingFP) > |
| 9241 |
reinterpret_cast<uintptr_t>(entryFrame) + BaselineFrame::Size()) { |
| 9242 |
TRACE_PRINTF(" -> returning\n"); |
| 9243 |
return PBIResult::Unwind; |
| 9244 |
} |
| 9245 |
sp = ctx.stack.unwindingSP; |
| 9246 |
ctx.stack.fp = ctx.stack.unwindingFP; |
| 9247 |
frame = reinterpret_cast<BaselineFrame*>( |
| 9248 |
reinterpret_cast<uintptr_t>(ctx.stack.fp) - BaselineFrame::Size()); |
| 9249 |
TRACE_PRINTF(" -> setting sp to %p, frame to %p\n", sp, frame); |
| 9250 |
ctx.frameMgr.switchToFrame(frame); |
| 9251 |
ctx.frame = frame; |
| 9252 |
RESET_PC(frame->interpreterPC(), frame->script()); |
| 9253 |
DISPATCH(); |
| 9254 |
unwind_error: |
| 9255 |
TRACE_PRINTF("unwind_error: fp = %p entryFrame = %p\n", ctx.stack.fp, |
| 9256 |
entryFrame); |
| 9257 |
if (reinterpret_cast<uintptr_t>(ctx.stack.unwindingFP) > |
| 9258 |
reinterpret_cast<uintptr_t>(entryFrame) + BaselineFrame::Size()) { |
| 9259 |
return PBIResult::UnwindError; |
| 9260 |
} |
| 9261 |
if (reinterpret_cast<uintptr_t>(ctx.stack.unwindingFP) == |
| 9262 |
reinterpret_cast<uintptr_t>(entryFrame) + BaselineFrame::Size()) { |
| 9263 |
return PBIResult::Error; |
| 9264 |
} |
| 9265 |
sp = ctx.stack.unwindingSP; |
| 9266 |
ctx.stack.fp = ctx.stack.unwindingFP; |
| 9267 |
frame = reinterpret_cast<BaselineFrame*>( |
| 9268 |
reinterpret_cast<uintptr_t>(ctx.stack.fp) - BaselineFrame::Size()); |
| 9269 |
TRACE_PRINTF(" -> setting sp to %p, frame to %p\n", sp, frame); |
| 9270 |
ctx.frameMgr.switchToFrame(frame); |
| 9271 |
ctx.frame = frame; |
| 9272 |
RESET_PC(frame->interpreterPC(), frame->script()); |
| 9273 |
goto error; |
| 9274 |
unwind_ret: |
| 9275 |
TRACE_PRINTF("unwind_ret: fp = %p entryFrame = %p\n", ctx.stack.fp, |
| 9276 |
entryFrame); |
| 9277 |
if (reinterpret_cast<uintptr_t>(ctx.stack.unwindingFP) > |
| 9278 |
reinterpret_cast<uintptr_t>(entryFrame) + BaselineFrame::Size()) { |
| 9279 |
return PBIResult::UnwindRet; |
| 9280 |
} |
| 9281 |
if (reinterpret_cast<uintptr_t>(ctx.stack.unwindingFP) == |
| 9282 |
reinterpret_cast<uintptr_t>(entryFrame) + BaselineFrame::Size()) { |
| 9283 |
*ret = frame->returnValue(); |
| 9284 |
return PBIResult::Ok; |
| 9285 |
} |
| 9286 |
sp = ctx.stack.unwindingSP; |
| 9287 |
ctx.stack.fp = ctx.stack.unwindingFP; |
| 9288 |
frame = reinterpret_cast<BaselineFrame*>( |
| 9289 |
reinterpret_cast<uintptr_t>(ctx.stack.fp) - BaselineFrame::Size()); |
| 9290 |
TRACE_PRINTF(" -> setting sp to %p, frame to %p\n", sp, frame); |
| 9291 |
ctx.frameMgr.switchToFrame(frame); |
| 9292 |
ctx.frame = frame; |
| 9293 |
RESET_PC(frame->interpreterPC(), frame->script()); |
| 9294 |
from_unwind = true; |
| 9295 |
goto do_return; |
| 9296 |
|
| 9297 |
#ifndef __wasi__ |
| 9298 |
debug:; |
| 9299 |
{ |
| 9300 |
TRACE_PRINTF("hit debug point\n"); |
| 9301 |
PUSH_EXIT_FRAME(); |
| 9302 |
if (!HandleDebugTrap(cx, frame, pc)) { |
| 9303 |
TRACE_PRINTF("HandleDebugTrap returned error\n"); |
| 9304 |
goto error; |
| 9305 |
} |
| 9306 |
RESET_PC(frame->interpreterPC(), frame->script()); |
| 9307 |
TRACE_PRINTF("HandleDebugTrap done\n"); |
| 9308 |
} |
| 9309 |
goto dispatch; |
| 9310 |
#endif |
| 9311 |
} |
| 9312 |
|
| 9313 |
/* |
| 9314 |
* ----------------------------------------------- |
| 9315 |
* Entry point |
| 9316 |
* ----------------------------------------------- |
| 9317 |
*/ |
| 9318 |
|
| 9319 |
bool PortableBaselineTrampoline(JSContext* cx, size_t argc, Value* argv, |
| 9320 |
size_t numFormals, size_t numActuals, |
| 9321 |
CalleeToken calleeToken, JSObject* envChain, |
| 9322 |
Value* result) { |
| 9323 |
State state(cx); |
| 9324 |
Stack stack(cx->portableBaselineStack()); |
| 9325 |
StackVal* sp = stack.top; |
| 9326 |
|
| 9327 |
TRACE_PRINTF("Trampoline: calleeToken %p env %p\n", calleeToken, envChain); |
| 9328 |
|
| 9329 |
// Expected stack frame: |
| 9330 |
// - argN |
| 9331 |
// - ... |
| 9332 |
// - arg1 |
| 9333 |
// - this |
| 9334 |
// - calleeToken |
| 9335 |
// - descriptor |
| 9336 |
// - "return address" (nullptr for top frame) |
| 9337 |
|
| 9338 |
// `argc` is the number of args *including* `this` (`N + 1` |
| 9339 |
// above). `numFormals` is the minimum `N`; if less, we need to push |
| 9340 |
// `UndefinedValue`s above. We need to pass an argc (including |
| 9341 |
// `this`) accoundint for the extra undefs in the descriptor's argc. |
| 9342 |
// |
| 9343 |
// If constructing, there is an additional `newTarget` at the end. |
| 9344 |
// |
| 9345 |
// Note that `callee`, which is in the stack signature for a `Call` |
| 9346 |
// JSOp, does *not* appear in this count: it is separately passed in |
| 9347 |
// the `calleeToken`. |
| 9348 |
|
| 9349 |
bool constructing = CalleeTokenIsConstructing(calleeToken); |
| 9350 |
size_t numCalleeActuals = std::max(numActuals, numFormals); |
| 9351 |
size_t numUndefs = numCalleeActuals - numActuals; |
| 9352 |
|
| 9353 |
// N.B.: we already checked the stack in |
| 9354 |
// PortableBaselineInterpreterStackCheck; we don't do it here |
| 9355 |
// because we can't push an exit frame if we don't have an entry |
| 9356 |
// frame, and we need a full activation to produce the backtrace |
| 9357 |
// from ReportOverRecursed. |
| 9358 |
|
| 9359 |
if (constructing) { |
| 9360 |
PUSH(StackVal(argv[argc])); |
| 9361 |
} |
| 9362 |
for (size_t i = 0; i < numUndefs; i++) { |
| 9363 |
PUSH(StackVal(UndefinedValue())); |
| 9364 |
} |
| 9365 |
for (size_t i = 0; i < argc; i++) { |
| 9366 |
PUSH(StackVal(argv[argc - 1 - i])); |
| 9367 |
} |
| 9368 |
PUSHNATIVE(StackValNative(calleeToken)); |
| 9369 |
PUSHNATIVE(StackValNative( |
| 9370 |
MakeFrameDescriptorForJitCall(FrameType::CppToJSJit, numActuals))); |
| 9371 |
|
| 9372 |
JSScript* script = ScriptFromCalleeToken(calleeToken); |
| 9373 |
jsbytecode* pc = script->code(); |
| 9374 |
ImmutableScriptData* isd = script->immutableScriptData(); |
| 9375 |
PBIResult ret; |
| 9376 |
ret = PortableBaselineInterpret<false, kHybridICsInterp>( |
| 9377 |
cx, state, stack, sp, envChain, result, pc, isd, nullptr, nullptr, |
| 9378 |
nullptr, PBIResult::Ok); |
| 9379 |
switch (ret) { |
| 9380 |
case PBIResult::Ok: |
| 9381 |
case PBIResult::UnwindRet: |
| 9382 |
TRACE_PRINTF("PBI returned Ok/UnwindRet with result %" PRIx64 "\n", |
| 9383 |
result->asRawBits()); |
| 9384 |
break; |
| 9385 |
case PBIResult::Error: |
| 9386 |
case PBIResult::UnwindError: |
| 9387 |
TRACE_PRINTF("PBI returned Error/UnwindError\n"); |
| 9388 |
return false; |
| 9389 |
case PBIResult::Unwind: |
| 9390 |
MOZ_CRASH("Should not unwind out of top / entry frame"); |
| 9391 |
} |
| 9392 |
|
| 9393 |
return true; |
| 9394 |
} |
| 9395 |
|
| 9396 |
MethodStatus CanEnterPortableBaselineInterpreter(JSContext* cx, |
| 9397 |
RunState& state) { |
| 9398 |
if (!JitOptions.portableBaselineInterpreter) { |
| 9399 |
return MethodStatus::Method_CantCompile; |
| 9400 |
} |
| 9401 |
if (state.script()->hasJitScript()) { |
| 9402 |
return MethodStatus::Method_Compiled; |
| 9403 |
} |
| 9404 |
if (state.script()->hasForceInterpreterOp()) { |
| 9405 |
return MethodStatus::Method_CantCompile; |
| 9406 |
} |
| 9407 |
if (state.script()->isAsync() || state.script()->isGenerator()) { |
| 9408 |
return MethodStatus::Method_CantCompile; |
| 9409 |
} |
| 9410 |
if (cx->runtime()->geckoProfiler().enabled()) { |
| 9411 |
return MethodStatus::Method_CantCompile; |
| 9412 |
} |
| 9413 |
|
| 9414 |
if (state.isInvoke()) { |
| 9415 |
InvokeState& invoke = *state.asInvoke(); |
| 9416 |
if (TooManyActualArguments(invoke.args().length())) { |
| 9417 |
return MethodStatus::Method_CantCompile; |
| 9418 |
} |
| 9419 |
} else { |
| 9420 |
if (state.asExecute()->isDebuggerEval()) { |
| 9421 |
return MethodStatus::Method_CantCompile; |
| 9422 |
} |
| 9423 |
} |
| 9424 |
if (state.script()->getWarmUpCount() <= |
| 9425 |
JitOptions.portableBaselineInterpreterWarmUpThreshold) { |
| 9426 |
return MethodStatus::Method_Skipped; |
| 9427 |
} |
| 9428 |
if (!cx->zone()->ensureJitZoneExists(cx)) { |
| 9429 |
return MethodStatus::Method_Error; |
| 9430 |
} |
| 9431 |
|
| 9432 |
AutoKeepJitScripts keepJitScript(cx); |
| 9433 |
if (!state.script()->ensureHasJitScript(cx, keepJitScript)) { |
| 9434 |
return MethodStatus::Method_Error; |
| 9435 |
} |
| 9436 |
state.script()->updateJitCodeRaw(cx->runtime()); |
| 9437 |
return MethodStatus::Method_Compiled; |
| 9438 |
} |
| 9439 |
|
| 9440 |
bool PortablebaselineInterpreterStackCheck(JSContext* cx, RunState& state, |
| 9441 |
size_t numActualArgs) { |
| 9442 |
auto& pbs = cx->portableBaselineStack(); |
| 9443 |
StackVal* base = reinterpret_cast<StackVal*>(pbs.base); |
| 9444 |
StackVal* top = reinterpret_cast<StackVal*>(pbs.top); |
| 9445 |
ssize_t margin = kStackMargin / sizeof(StackVal); |
| 9446 |
ssize_t needed = numActualArgs + state.script()->nslots() + margin; |
| 9447 |
return (top - base) >= needed; |
| 9448 |
} |
| 9449 |
|
| 9450 |
} // namespace pbl |
| 9451 |
} // namespace js |