2 * Copyright (C) 2008-2018 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "CodeBlock.h"
32 #include "DirectArguments.h"
33 #include "GCAwareJITStubRoutine.h"
34 #include "GetterSetter.h"
35 #include "InterpreterInlines.h"
36 #include "JITInlines.h"
38 #include "JSFunction.h"
39 #include "JSLexicalEnvironment.h"
40 #include "LinkBuffer.h"
41 #include "ResultType.h"
42 #include "ScopedArguments.h"
43 #include "ScopedArgumentsTable.h"
44 #include "SlowPathCall.h"
45 #include "StructureStubInfo.h"
46 #include <wtf/ScopedLambda.h>
47 #include <wtf/StringPrintStream.h>
53 JIT::CodeRef<JITThunkPtrTag> JIT::stringGetByValStubGenerator(VM* vm)
55 JSInterfaceJIT jit(vm);
57 jit.tagReturnAddress();
58 failures.append(jit.branchStructure(
60 Address(regT0, JSCell::structureIDOffset()),
61 vm->stringStructure.get()));
63 // Load string length to regT2, and start the process of loading the data pointer into regT0
64 jit.load32(Address(regT0, ThunkHelpers::jsStringLengthOffset()), regT2);
65 jit.loadPtr(Address(regT0, ThunkHelpers::jsStringValueOffset()), regT0);
66 failures.append(jit.branchTest32(Zero, regT0));
68 // Do an unsigned compare to simultaneously filter negative indices as well as indices that are too large
69 failures.append(jit.branch32(AboveOrEqual, regT1, regT2));
74 // Load the string flags
75 jit.loadPtr(Address(regT0, StringImpl::flagsOffset()), regT2);
76 jit.loadPtr(Address(regT0, StringImpl::dataOffset()), regT0);
77 is16Bit.append(jit.branchTest32(Zero, regT2, TrustedImm32(StringImpl::flagIs8Bit())));
78 jit.load8(BaseIndex(regT0, regT1, TimesOne, 0), regT0);
79 cont8Bit.append(jit.jump());
81 jit.load16(BaseIndex(regT0, regT1, TimesTwo, 0), regT0);
84 failures.append(jit.branch32(AboveOrEqual, regT0, TrustedImm32(0x100)));
85 jit.move(TrustedImmPtr(vm->smallStrings.singleCharacterStrings()), regT1);
86 jit.loadPtr(BaseIndex(regT1, regT0, ScalePtr, 0), regT0);
90 jit.move(TrustedImm32(0), regT0);
93 LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
94 return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "String get_by_val stub");
97 void JIT::emit_op_get_by_val(Instruction* currentInstruction)
99 int dst = currentInstruction[1].u.operand;
100 int base = currentInstruction[2].u.operand;
101 int property = currentInstruction[3].u.operand;
102 ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
103 ByValInfo* byValInfo = m_codeBlock->addByValInfo();
105 emitGetVirtualRegister(base, regT0);
106 bool propertyNameIsIntegerConstant = isOperandConstantInt(property);
107 if (propertyNameIsIntegerConstant)
108 move(Imm32(getOperandConstantInt(property)), regT1);
110 emitGetVirtualRegister(property, regT1);
112 emitJumpSlowCaseIfNotJSCell(regT0, base);
114 PatchableJump notIndex;
115 if (!propertyNameIsIntegerConstant) {
116 notIndex = emitPatchableJumpIfNotInt(regT1);
117 addSlowCase(notIndex);
119 // This is technically incorrect - we're zero-extending an int32. On the hot path this doesn't matter.
120 // We check the value as if it was a uint32 against the m_vectorLength - which will always fail if
121 // number was signed since m_vectorLength is always less than intmax (since the total allocation
122 // size is always less than 4Gb). As such zero extending will have been correct (and extending the value
123 // to 64-bits is necessary since it's used in the address calculation). We zero extend rather than sign
124 // extending since it makes it easier to re-tag the value in the slow case.
125 zeroExtend32ToPtr(regT1, regT1);
128 emitArrayProfilingSiteWithCell(regT0, regT2, profile);
129 and32(TrustedImm32(IndexingShapeMask), regT2);
131 PatchableJump badType;
134 JITArrayMode mode = chooseArrayMode(profile);
137 slowCases = emitInt32GetByVal(currentInstruction, badType);
140 slowCases = emitDoubleGetByVal(currentInstruction, badType);
143 slowCases = emitContiguousGetByVal(currentInstruction, badType);
145 case JITArrayStorage:
146 slowCases = emitArrayStorageGetByVal(currentInstruction, badType);
153 addSlowCase(badType);
154 addSlowCase(slowCases);
156 Label done = label();
158 if (!ASSERT_DISABLED) {
159 Jump resultOK = branchTest64(NonZero, regT0);
160 abortWithReason(JITGetByValResultIsNotEmpty);
164 emitValueProfilingSite();
165 emitPutVirtualRegister(dst);
167 Label nextHotPath = label();
169 m_byValCompilationInfo.append(ByValCompilationInfo(byValInfo, m_bytecodeOffset, notIndex, badType, mode, profile, done, nextHotPath));
172 JIT::JumpList JIT::emitDoubleLoad(Instruction*, PatchableJump& badType)
176 badType = patchableBranch32(NotEqual, regT2, TrustedImm32(DoubleShape));
177 loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
178 slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfPublicLength())));
179 loadDouble(BaseIndex(regT2, regT1, TimesEight), fpRegT0);
180 slowCases.append(branchDouble(DoubleNotEqualOrUnordered, fpRegT0, fpRegT0));
185 JIT::JumpList JIT::emitContiguousLoad(Instruction*, PatchableJump& badType, IndexingType expectedShape)
189 badType = patchableBranch32(NotEqual, regT2, TrustedImm32(expectedShape));
190 loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
191 slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfPublicLength())));
192 load64(BaseIndex(regT2, regT1, TimesEight), regT0);
193 slowCases.append(branchTest64(Zero, regT0));
198 JIT::JumpList JIT::emitArrayStorageLoad(Instruction*, PatchableJump& badType)
202 add32(TrustedImm32(-ArrayStorageShape), regT2, regT3);
203 badType = patchableBranch32(Above, regT3, TrustedImm32(SlowPutArrayStorageShape - ArrayStorageShape));
205 loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
206 slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, ArrayStorage::vectorLengthOffset())));
208 load64(BaseIndex(regT2, regT1, TimesEight, ArrayStorage::vectorOffset()), regT0);
209 slowCases.append(branchTest64(Zero, regT0));
214 JITGetByIdGenerator JIT::emitGetByValWithCachedId(ByValInfo* byValInfo, Instruction* currentInstruction, const Identifier& propertyName, Jump& fastDoneCase, Jump& slowDoneCase, JumpList& slowCases)
220 int dst = currentInstruction[1].u.operand;
222 slowCases.append(emitJumpIfNotJSCell(regT1));
223 emitByValIdentifierCheck(byValInfo, regT1, regT3, propertyName, slowCases);
225 JITGetByIdGenerator gen(
226 m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::stubUnavailableRegisters(),
227 propertyName.impl(), JSValueRegs(regT0), JSValueRegs(regT0), AccessType::Get);
228 gen.generateFastPath(*this);
230 fastDoneCase = jump();
232 Label coldPathBegin = label();
233 gen.slowPathJump().link(this);
235 Call call = callOperationWithProfile(operationGetByIdOptimize, dst, gen.stubInfo(), regT0, propertyName.impl());
236 gen.reportSlowPathCall(coldPathBegin, call);
237 slowDoneCase = jump();
242 void JIT::emitSlow_op_get_by_val(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
244 int dst = currentInstruction[1].u.operand;
245 int base = currentInstruction[2].u.operand;
246 int property = currentInstruction[3].u.operand;
247 ByValInfo* byValInfo = m_byValCompilationInfo[m_byValInstructionIndex].byValInfo;
249 linkSlowCaseIfNotJSCell(iter, base); // base cell check
251 if (!isOperandConstantInt(property))
252 linkSlowCase(iter); // property int32 check
253 Jump nonCell = jump();
254 linkSlowCase(iter); // base array check
255 Jump notString = branchStructure(NotEqual,
256 Address(regT0, JSCell::structureIDOffset()),
257 m_vm->stringStructure.get());
258 emitNakedCall(CodeLocationLabel<NoPtrTag>(m_vm->getCTIStub(stringGetByValStubGenerator).retaggedCode<NoPtrTag>()));
259 Jump failed = branchTest64(Zero, regT0);
260 emitPutVirtualRegister(dst, regT0);
261 emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_get_by_val));
263 notString.link(this);
266 linkSlowCase(iter); // vector length check
267 linkSlowCase(iter); // empty value
269 Label slowPath = label();
271 emitGetVirtualRegister(base, regT0);
272 emitGetVirtualRegister(property, regT1);
273 Call call = callOperation(operationGetByValOptimize, dst, regT0, regT1, byValInfo);
275 m_byValCompilationInfo[m_byValInstructionIndex].slowPathTarget = slowPath;
276 m_byValCompilationInfo[m_byValInstructionIndex].returnAddress = call;
277 m_byValInstructionIndex++;
279 emitValueProfilingSite();
282 void JIT::emit_op_put_by_val(Instruction* currentInstruction)
284 int base = currentInstruction[1].u.operand;
285 int property = currentInstruction[2].u.operand;
286 ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
287 ByValInfo* byValInfo = m_codeBlock->addByValInfo();
289 emitGetVirtualRegister(base, regT0);
290 bool propertyNameIsIntegerConstant = isOperandConstantInt(property);
291 if (propertyNameIsIntegerConstant)
292 move(Imm32(getOperandConstantInt(property)), regT1);
294 emitGetVirtualRegister(property, regT1);
296 emitJumpSlowCaseIfNotJSCell(regT0, base);
297 PatchableJump notIndex;
298 if (!propertyNameIsIntegerConstant) {
299 notIndex = emitPatchableJumpIfNotInt(regT1);
300 addSlowCase(notIndex);
301 // See comment in op_get_by_val.
302 zeroExtend32ToPtr(regT1, regT1);
304 emitArrayProfilingSiteWithCell(regT0, regT2, profile);
305 and32(TrustedImm32(IndexingShapeMask), regT2);
307 PatchableJump badType;
310 JITArrayMode mode = chooseArrayMode(profile);
313 slowCases = emitInt32PutByVal(currentInstruction, badType);
316 slowCases = emitDoublePutByVal(currentInstruction, badType);
319 slowCases = emitContiguousPutByVal(currentInstruction, badType);
321 case JITArrayStorage:
322 slowCases = emitArrayStoragePutByVal(currentInstruction, badType);
329 addSlowCase(badType);
330 addSlowCase(slowCases);
332 Label done = label();
334 m_byValCompilationInfo.append(ByValCompilationInfo(byValInfo, m_bytecodeOffset, notIndex, badType, mode, profile, done, done));
337 JIT::JumpList JIT::emitGenericContiguousPutByVal(Instruction* currentInstruction, PatchableJump& badType, IndexingType indexingShape)
339 int value = currentInstruction[3].u.operand;
340 ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
344 badType = patchableBranch32(NotEqual, regT2, TrustedImm32(indexingShape));
346 loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
347 Jump outOfBounds = branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfPublicLength()));
349 Label storeResult = label();
350 emitGetVirtualRegister(value, regT3);
351 switch (indexingShape) {
353 slowCases.append(emitJumpIfNotInt(regT3));
354 store64(regT3, BaseIndex(regT2, regT1, TimesEight));
357 Jump notInt = emitJumpIfNotInt(regT3);
358 convertInt32ToDouble(regT3, fpRegT0);
361 add64(tagTypeNumberRegister, regT3);
362 move64ToDouble(regT3, fpRegT0);
363 slowCases.append(branchDouble(DoubleNotEqualOrUnordered, fpRegT0, fpRegT0));
365 storeDouble(fpRegT0, BaseIndex(regT2, regT1, TimesEight));
368 case ContiguousShape:
369 store64(regT3, BaseIndex(regT2, regT1, TimesEight));
370 emitWriteBarrier(currentInstruction[1].u.operand, value, ShouldFilterValue);
378 outOfBounds.link(this);
380 slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfVectorLength())));
382 emitArrayProfileStoreToHoleSpecialCase(profile);
384 add32(TrustedImm32(1), regT1, regT3);
385 store32(regT3, Address(regT2, Butterfly::offsetOfPublicLength()));
386 jump().linkTo(storeResult, this);
393 JIT::JumpList JIT::emitArrayStoragePutByVal(Instruction* currentInstruction, PatchableJump& badType)
395 int value = currentInstruction[3].u.operand;
396 ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
400 badType = patchableBranch32(NotEqual, regT2, TrustedImm32(ArrayStorageShape));
401 loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
402 slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, ArrayStorage::vectorLengthOffset())));
404 Jump empty = branchTest64(Zero, BaseIndex(regT2, regT1, TimesEight, ArrayStorage::vectorOffset()));
406 Label storeResult(this);
407 emitGetVirtualRegister(value, regT3);
408 store64(regT3, BaseIndex(regT2, regT1, TimesEight, ArrayStorage::vectorOffset()));
409 emitWriteBarrier(currentInstruction[1].u.operand, value, ShouldFilterValue);
413 emitArrayProfileStoreToHoleSpecialCase(profile);
414 add32(TrustedImm32(1), Address(regT2, ArrayStorage::numValuesInVectorOffset()));
415 branch32(Below, regT1, Address(regT2, ArrayStorage::lengthOffset())).linkTo(storeResult, this);
417 add32(TrustedImm32(1), regT1);
418 store32(regT1, Address(regT2, ArrayStorage::lengthOffset()));
419 sub32(TrustedImm32(1), regT1);
420 jump().linkTo(storeResult, this);
427 JITPutByIdGenerator JIT::emitPutByValWithCachedId(ByValInfo* byValInfo, Instruction* currentInstruction, PutKind putKind, const Identifier& propertyName, JumpList& doneCases, JumpList& slowCases)
433 int base = currentInstruction[1].u.operand;
434 int value = currentInstruction[3].u.operand;
436 slowCases.append(emitJumpIfNotJSCell(regT1));
437 emitByValIdentifierCheck(byValInfo, regT1, regT1, propertyName, slowCases);
439 // Write barrier breaks the registers. So after issuing the write barrier,
440 // reload the registers.
441 emitGetVirtualRegisters(base, regT0, value, regT1);
443 JITPutByIdGenerator gen(
444 m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::stubUnavailableRegisters(),
445 JSValueRegs(regT0), JSValueRegs(regT1), regT2, m_codeBlock->ecmaMode(), putKind);
446 gen.generateFastPath(*this);
447 emitWriteBarrier(base, value, ShouldFilterBase);
448 doneCases.append(jump());
450 Label coldPathBegin = label();
451 gen.slowPathJump().link(this);
453 Call call = callOperation(gen.slowPathFunction(), gen.stubInfo(), regT1, regT0, propertyName.impl());
454 gen.reportSlowPathCall(coldPathBegin, call);
455 doneCases.append(jump());
460 void JIT::emitSlow_op_put_by_val(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
462 int base = currentInstruction[1].u.operand;
463 int property = currentInstruction[2].u.operand;
464 int value = currentInstruction[3].u.operand;
465 JITArrayMode mode = m_byValCompilationInfo[m_byValInstructionIndex].arrayMode;
466 ByValInfo* byValInfo = m_byValCompilationInfo[m_byValInstructionIndex].byValInfo;
468 linkSlowCaseIfNotJSCell(iter, base); // base cell check
469 if (!isOperandConstantInt(property))
470 linkSlowCase(iter); // property int32 check
471 linkSlowCase(iter); // base not array check
473 linkSlowCase(iter); // out of bounds
478 linkSlowCase(iter); // value type check
484 Label slowPath = label();
486 emitGetVirtualRegister(base, regT0);
487 emitGetVirtualRegister(property, regT1);
488 emitGetVirtualRegister(value, regT2);
489 bool isDirect = Interpreter::getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct;
490 Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, regT0, regT1, regT2, byValInfo);
492 m_byValCompilationInfo[m_byValInstructionIndex].slowPathTarget = slowPath;
493 m_byValCompilationInfo[m_byValInstructionIndex].returnAddress = call;
494 m_byValInstructionIndex++;
497 void JIT::emit_op_put_getter_by_id(Instruction* currentInstruction)
499 emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
500 int32_t options = currentInstruction[3].u.operand;
501 emitGetVirtualRegister(currentInstruction[4].u.operand, regT1);
502 callOperation(operationPutGetterById, regT0, m_codeBlock->identifier(currentInstruction[2].u.operand).impl(), options, regT1);
505 void JIT::emit_op_put_setter_by_id(Instruction* currentInstruction)
507 emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
508 int32_t options = currentInstruction[3].u.operand;
509 emitGetVirtualRegister(currentInstruction[4].u.operand, regT1);
510 callOperation(operationPutSetterById, regT0, m_codeBlock->identifier(currentInstruction[2].u.operand).impl(), options, regT1);
513 void JIT::emit_op_put_getter_setter_by_id(Instruction* currentInstruction)
515 emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
516 int32_t attribute = currentInstruction[3].u.operand;
517 emitGetVirtualRegister(currentInstruction[4].u.operand, regT1);
518 emitGetVirtualRegister(currentInstruction[5].u.operand, regT2);
519 callOperation(operationPutGetterSetter, regT0, m_codeBlock->identifier(currentInstruction[2].u.operand).impl(), attribute, regT1, regT2);
522 void JIT::emit_op_put_getter_by_val(Instruction* currentInstruction)
524 emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
525 emitGetVirtualRegister(currentInstruction[2].u.operand, regT1);
526 int32_t attributes = currentInstruction[3].u.operand;
527 emitGetVirtualRegister(currentInstruction[4].u.operand, regT2);
528 callOperation(operationPutGetterByVal, regT0, regT1, attributes, regT2);
531 void JIT::emit_op_put_setter_by_val(Instruction* currentInstruction)
533 emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
534 emitGetVirtualRegister(currentInstruction[2].u.operand, regT1);
535 int32_t attributes = currentInstruction[3].u.operand;
536 emitGetVirtualRegister(currentInstruction[4].u.operand, regT2);
537 callOperation(operationPutSetterByVal, regT0, regT1, attributes, regT2);
540 void JIT::emit_op_del_by_id(Instruction* currentInstruction)
542 int dst = currentInstruction[1].u.operand;
543 int base = currentInstruction[2].u.operand;
544 int property = currentInstruction[3].u.operand;
545 emitGetVirtualRegister(base, regT0);
546 callOperation(operationDeleteByIdJSResult, dst, regT0, m_codeBlock->identifier(property).impl());
549 void JIT::emit_op_del_by_val(Instruction* currentInstruction)
551 int dst = currentInstruction[1].u.operand;
552 int base = currentInstruction[2].u.operand;
553 int property = currentInstruction[3].u.operand;
554 emitGetVirtualRegister(base, regT0);
555 emitGetVirtualRegister(property, regT1);
556 callOperation(operationDeleteByValJSResult, dst, regT0, regT1);
559 void JIT::emit_op_try_get_by_id(Instruction* currentInstruction)
561 int resultVReg = currentInstruction[1].u.operand;
562 int baseVReg = currentInstruction[2].u.operand;
563 const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[3].u.operand));
565 emitGetVirtualRegister(baseVReg, regT0);
567 emitJumpSlowCaseIfNotJSCell(regT0, baseVReg);
569 JITGetByIdGenerator gen(
570 m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::stubUnavailableRegisters(),
571 ident->impl(), JSValueRegs(regT0), JSValueRegs(regT0), AccessType::TryGet);
572 gen.generateFastPath(*this);
573 addSlowCase(gen.slowPathJump());
574 m_getByIds.append(gen);
576 emitValueProfilingSite();
577 emitPutVirtualRegister(resultVReg);
580 void JIT::emitSlow_op_try_get_by_id(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
582 linkAllSlowCases(iter);
584 int resultVReg = currentInstruction[1].u.operand;
585 const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[3].u.operand));
587 JITGetByIdGenerator& gen = m_getByIds[m_getByIdIndex++];
589 Label coldPathBegin = label();
591 Call call = callOperation(operationTryGetByIdOptimize, resultVReg, gen.stubInfo(), regT0, ident->impl());
593 gen.reportSlowPathCall(coldPathBegin, call);
596 void JIT::emit_op_get_by_id_direct(Instruction* currentInstruction)
598 int resultVReg = currentInstruction[1].u.operand;
599 int baseVReg = currentInstruction[2].u.operand;
600 const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[3].u.operand));
602 emitGetVirtualRegister(baseVReg, regT0);
604 emitJumpSlowCaseIfNotJSCell(regT0, baseVReg);
606 JITGetByIdGenerator gen(
607 m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::stubUnavailableRegisters(),
608 ident->impl(), JSValueRegs(regT0), JSValueRegs(regT0), AccessType::GetDirect);
609 gen.generateFastPath(*this);
610 addSlowCase(gen.slowPathJump());
611 m_getByIds.append(gen);
613 emitValueProfilingSite();
614 emitPutVirtualRegister(resultVReg);
617 void JIT::emitSlow_op_get_by_id_direct(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
619 linkAllSlowCases(iter);
621 int resultVReg = currentInstruction[1].u.operand;
622 const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[3].u.operand));
624 JITGetByIdGenerator& gen = m_getByIds[m_getByIdIndex++];
626 Label coldPathBegin = label();
628 Call call = callOperationWithProfile(operationGetByIdDirectOptimize, resultVReg, gen.stubInfo(), regT0, ident->impl());
630 gen.reportSlowPathCall(coldPathBegin, call);
633 void JIT::emit_op_get_by_id(Instruction* currentInstruction)
635 int resultVReg = currentInstruction[1].u.operand;
636 int baseVReg = currentInstruction[2].u.operand;
637 const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[3].u.operand));
639 emitGetVirtualRegister(baseVReg, regT0);
641 emitJumpSlowCaseIfNotJSCell(regT0, baseVReg);
643 if (*ident == m_vm->propertyNames->length && shouldEmitProfiling())
644 emitArrayProfilingSiteForBytecodeIndexWithCell(regT0, regT1, m_bytecodeOffset);
646 JITGetByIdGenerator gen(
647 m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::stubUnavailableRegisters(),
648 ident->impl(), JSValueRegs(regT0), JSValueRegs(regT0), AccessType::Get);
649 gen.generateFastPath(*this);
650 addSlowCase(gen.slowPathJump());
651 m_getByIds.append(gen);
653 emitValueProfilingSite();
654 emitPutVirtualRegister(resultVReg);
657 void JIT::emit_op_get_by_id_with_this(Instruction* currentInstruction)
659 int resultVReg = currentInstruction[1].u.operand;
660 int baseVReg = currentInstruction[2].u.operand;
661 int thisVReg = currentInstruction[3].u.operand;
662 const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[4].u.operand));
664 emitGetVirtualRegister(baseVReg, regT0);
665 emitGetVirtualRegister(thisVReg, regT1);
666 emitJumpSlowCaseIfNotJSCell(regT0, baseVReg);
667 emitJumpSlowCaseIfNotJSCell(regT1, thisVReg);
669 JITGetByIdWithThisGenerator gen(
670 m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::stubUnavailableRegisters(),
671 ident->impl(), JSValueRegs(regT0), JSValueRegs(regT0), JSValueRegs(regT1), AccessType::GetWithThis);
672 gen.generateFastPath(*this);
673 addSlowCase(gen.slowPathJump());
674 m_getByIdsWithThis.append(gen);
676 emitValueProfilingSite();
677 emitPutVirtualRegister(resultVReg);
680 void JIT::emitSlow_op_get_by_id(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
682 linkAllSlowCases(iter);
684 int resultVReg = currentInstruction[1].u.operand;
685 const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[3].u.operand));
687 JITGetByIdGenerator& gen = m_getByIds[m_getByIdIndex++];
689 Label coldPathBegin = label();
691 Call call = callOperationWithProfile(operationGetByIdOptimize, resultVReg, gen.stubInfo(), regT0, ident->impl());
693 gen.reportSlowPathCall(coldPathBegin, call);
696 void JIT::emitSlow_op_get_by_id_with_this(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
698 linkAllSlowCases(iter);
700 int resultVReg = currentInstruction[1].u.operand;
701 const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[4].u.operand));
703 JITGetByIdWithThisGenerator& gen = m_getByIdsWithThis[m_getByIdWithThisIndex++];
705 Label coldPathBegin = label();
707 Call call = callOperationWithProfile(operationGetByIdWithThisOptimize, resultVReg, gen.stubInfo(), regT0, regT1, ident->impl());
709 gen.reportSlowPathCall(coldPathBegin, call);
712 void JIT::emit_op_put_by_id(Instruction* currentInstruction)
714 int baseVReg = currentInstruction[1].u.operand;
715 int valueVReg = currentInstruction[3].u.operand;
716 unsigned direct = currentInstruction[8].u.putByIdFlags & PutByIdIsDirect;
718 // In order to be able to patch both the Structure, and the object offset, we store one pointer,
719 // to just after the arguments have been loaded into registers 'hotPathBegin', and we generate code
720 // such that the Structure & offset are always at the same distance from this.
722 emitGetVirtualRegisters(baseVReg, regT0, valueVReg, regT1);
724 emitJumpSlowCaseIfNotJSCell(regT0, baseVReg);
726 JITPutByIdGenerator gen(
727 m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::stubUnavailableRegisters(),
728 JSValueRegs(regT0), JSValueRegs(regT1), regT2, m_codeBlock->ecmaMode(),
729 direct ? Direct : NotDirect);
731 gen.generateFastPath(*this);
732 addSlowCase(gen.slowPathJump());
734 emitWriteBarrier(baseVReg, valueVReg, ShouldFilterBase);
736 m_putByIds.append(gen);
739 void JIT::emitSlow_op_put_by_id(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
741 linkAllSlowCases(iter);
743 const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[2].u.operand));
745 Label coldPathBegin(this);
747 JITPutByIdGenerator& gen = m_putByIds[m_putByIdIndex++];
749 Call call = callOperation(gen.slowPathFunction(), gen.stubInfo(), regT1, regT0, ident->impl());
751 gen.reportSlowPathCall(coldPathBegin, call);
754 void JIT::emitVarInjectionCheck(bool needsVarInjectionChecks)
756 if (!needsVarInjectionChecks)
758 addSlowCase(branch8(Equal, AbsoluteAddress(m_codeBlock->globalObject()->varInjectionWatchpoint()->addressOfState()), TrustedImm32(IsInvalidated)));
761 void JIT::emitResolveClosure(int dst, int scope, bool needsVarInjectionChecks, unsigned depth)
763 emitVarInjectionCheck(needsVarInjectionChecks);
764 emitGetVirtualRegister(scope, regT0);
765 for (unsigned i = 0; i < depth; ++i)
766 loadPtr(Address(regT0, JSScope::offsetOfNext()), regT0);
767 emitPutVirtualRegister(dst);
770 void JIT::emit_op_resolve_scope(Instruction* currentInstruction)
772 int dst = currentInstruction[1].u.operand;
773 int scope = currentInstruction[2].u.operand;
774 ResolveType resolveType = static_cast<ResolveType>(copiedInstruction(currentInstruction)[4].u.operand);
775 unsigned depth = currentInstruction[5].u.operand;
777 auto emitCode = [&] (ResolveType resolveType) {
778 switch (resolveType) {
781 case GlobalPropertyWithVarInjectionChecks:
782 case GlobalVarWithVarInjectionChecks:
783 case GlobalLexicalVar:
784 case GlobalLexicalVarWithVarInjectionChecks: {
785 JSScope* constantScope = JSScope::constantScopeForCodeBlock(resolveType, m_codeBlock);
786 RELEASE_ASSERT(constantScope);
787 emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
788 move(TrustedImmPtr(constantScope), regT0);
789 emitPutVirtualRegister(dst);
793 case ClosureVarWithVarInjectionChecks:
794 emitResolveClosure(dst, scope, needsVarInjectionChecks(resolveType), depth);
797 move(TrustedImmPtr(currentInstruction[6].u.jsCell.get()), regT0);
798 emitPutVirtualRegister(dst);
803 case LocalClosureVar:
804 case UnresolvedProperty:
805 case UnresolvedPropertyWithVarInjectionChecks:
806 RELEASE_ASSERT_NOT_REACHED();
810 switch (resolveType) {
811 case UnresolvedProperty:
812 case UnresolvedPropertyWithVarInjectionChecks: {
814 load32(¤tInstruction[4], regT0);
816 Jump notGlobalProperty = branch32(NotEqual, regT0, TrustedImm32(GlobalProperty));
817 emitCode(GlobalProperty);
818 skipToEnd.append(jump());
819 notGlobalProperty.link(this);
821 Jump notGlobalPropertyWithVarInjections = branch32(NotEqual, regT0, TrustedImm32(GlobalPropertyWithVarInjectionChecks));
822 emitCode(GlobalPropertyWithVarInjectionChecks);
823 skipToEnd.append(jump());
824 notGlobalPropertyWithVarInjections.link(this);
826 Jump notGlobalLexicalVar = branch32(NotEqual, regT0, TrustedImm32(GlobalLexicalVar));
827 emitCode(GlobalLexicalVar);
828 skipToEnd.append(jump());
829 notGlobalLexicalVar.link(this);
831 Jump notGlobalLexicalVarWithVarInjections = branch32(NotEqual, regT0, TrustedImm32(GlobalLexicalVarWithVarInjectionChecks));
832 emitCode(GlobalLexicalVarWithVarInjectionChecks);
833 skipToEnd.append(jump());
834 notGlobalLexicalVarWithVarInjections.link(this);
837 skipToEnd.link(this);
842 emitCode(resolveType);
847 void JIT::emitLoadWithStructureCheck(int scope, Structure** structureSlot)
849 loadPtr(structureSlot, regT1);
850 emitGetVirtualRegister(scope, regT0);
851 addSlowCase(branchTestPtr(Zero, regT1));
852 load32(Address(regT1, Structure::structureIDOffset()), regT1);
853 addSlowCase(branch32(NotEqual, Address(regT0, JSCell::structureIDOffset()), regT1));
856 void JIT::emitGetVarFromPointer(JSValue* operand, GPRReg reg)
858 loadPtr(operand, reg);
861 void JIT::emitGetVarFromIndirectPointer(JSValue** operand, GPRReg reg)
863 loadPtr(operand, reg);
867 void JIT::emitGetClosureVar(int scope, uintptr_t operand)
869 emitGetVirtualRegister(scope, regT0);
870 loadPtr(Address(regT0, JSLexicalEnvironment::offsetOfVariables() + operand * sizeof(Register)), regT0);
873 void JIT::emit_op_get_from_scope(Instruction* currentInstruction)
875 int dst = currentInstruction[1].u.operand;
876 int scope = currentInstruction[2].u.operand;
877 ResolveType resolveType = GetPutInfo(copiedInstruction(currentInstruction)[4].u.operand).resolveType();
878 Structure** structureSlot = currentInstruction[5].u.structure.slot();
879 uintptr_t* operandSlot = reinterpret_cast<uintptr_t*>(¤tInstruction[6].u.pointer);
881 auto emitCode = [&] (ResolveType resolveType, bool indirectLoadForOperand) {
882 switch (resolveType) {
884 case GlobalPropertyWithVarInjectionChecks: {
885 emitLoadWithStructureCheck(scope, structureSlot); // Structure check covers var injection since we don't cache structures for anything but the GlobalObject. Additionally, resolve_scope handles checking for the var injection.
887 GPRReg result = regT0;
888 GPRReg offset = regT1;
889 GPRReg scratch = regT2;
891 jitAssert(scopedLambda<Jump(void)>([&] () -> Jump {
892 return branchPtr(Equal, base, TrustedImmPtr(m_codeBlock->globalObject()));
895 load32(operandSlot, offset);
896 if (!ASSERT_DISABLED) {
897 Jump isOutOfLine = branch32(GreaterThanOrEqual, offset, TrustedImm32(firstOutOfLineOffset));
898 abortWithReason(JITOffsetIsNotOutOfLine);
899 isOutOfLine.link(this);
901 loadPtr(Address(base, JSObject::butterflyOffset()), scratch);
903 signExtend32ToPtr(offset, offset);
904 load64(BaseIndex(scratch, offset, TimesEight, (firstOutOfLineOffset - 2) * sizeof(EncodedJSValue)), result);
908 case GlobalVarWithVarInjectionChecks:
909 case GlobalLexicalVar:
910 case GlobalLexicalVarWithVarInjectionChecks:
911 emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
912 if (indirectLoadForOperand)
913 emitGetVarFromIndirectPointer(bitwise_cast<JSValue**>(operandSlot), regT0);
915 emitGetVarFromPointer(bitwise_cast<JSValue*>(*operandSlot), regT0);
916 if (resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks) // TDZ check.
917 addSlowCase(branchTest64(Zero, regT0));
920 case ClosureVarWithVarInjectionChecks:
921 emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
922 emitGetClosureVar(scope, *operandSlot);
927 case LocalClosureVar:
929 case UnresolvedProperty:
930 case UnresolvedPropertyWithVarInjectionChecks:
931 RELEASE_ASSERT_NOT_REACHED();
935 switch (resolveType) {
936 case UnresolvedProperty:
937 case UnresolvedPropertyWithVarInjectionChecks: {
939 load32(¤tInstruction[4], regT0);
940 and32(TrustedImm32(GetPutInfo::typeBits), regT0); // Load ResolveType into T0
942 Jump isGlobalProperty = branch32(Equal, regT0, TrustedImm32(GlobalProperty));
943 Jump notGlobalPropertyWithVarInjections = branch32(NotEqual, regT0, TrustedImm32(GlobalPropertyWithVarInjectionChecks));
944 isGlobalProperty.link(this);
945 emitCode(GlobalProperty, false);
946 skipToEnd.append(jump());
947 notGlobalPropertyWithVarInjections.link(this);
949 Jump notGlobalLexicalVar = branch32(NotEqual, regT0, TrustedImm32(GlobalLexicalVar));
950 emitCode(GlobalLexicalVar, true);
951 skipToEnd.append(jump());
952 notGlobalLexicalVar.link(this);
954 Jump notGlobalLexicalVarWithVarInjections = branch32(NotEqual, regT0, TrustedImm32(GlobalLexicalVarWithVarInjectionChecks));
955 emitCode(GlobalLexicalVarWithVarInjectionChecks, true);
956 skipToEnd.append(jump());
957 notGlobalLexicalVarWithVarInjections.link(this);
961 skipToEnd.link(this);
966 emitCode(resolveType, false);
969 emitPutVirtualRegister(dst);
970 emitValueProfilingSite();
973 void JIT::emitSlow_op_get_from_scope(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
975 linkAllSlowCases(iter);
977 int dst = currentInstruction[1].u.operand;
978 callOperationWithProfile(operationGetFromScope, dst, currentInstruction);
981 void JIT::emitPutGlobalVariable(JSValue* operand, int value, WatchpointSet* set)
983 emitGetVirtualRegister(value, regT0);
984 emitNotifyWrite(set);
985 storePtr(regT0, operand);
987 void JIT::emitPutGlobalVariableIndirect(JSValue** addressOfOperand, int value, WatchpointSet** indirectWatchpointSet)
989 emitGetVirtualRegister(value, regT0);
990 loadPtr(indirectWatchpointSet, regT1);
991 emitNotifyWrite(regT1);
992 loadPtr(addressOfOperand, regT1);
993 storePtr(regT0, regT1);
996 void JIT::emitPutClosureVar(int scope, uintptr_t operand, int value, WatchpointSet* set)
998 emitGetVirtualRegister(value, regT1);
999 emitGetVirtualRegister(scope, regT0);
1000 emitNotifyWrite(set);
1001 storePtr(regT1, Address(regT0, JSLexicalEnvironment::offsetOfVariables() + operand * sizeof(Register)));
1004 void JIT::emit_op_put_to_scope(Instruction* currentInstruction)
1006 int scope = currentInstruction[1].u.operand;
1007 int value = currentInstruction[3].u.operand;
1008 GetPutInfo getPutInfo = GetPutInfo(copiedInstruction(currentInstruction)[4].u.operand);
1009 ResolveType resolveType = getPutInfo.resolveType();
1010 Structure** structureSlot = currentInstruction[5].u.structure.slot();
1011 uintptr_t* operandSlot = reinterpret_cast<uintptr_t*>(¤tInstruction[6].u.pointer);
1013 auto emitCode = [&] (ResolveType resolveType, bool indirectLoadForOperand) {
1014 switch (resolveType) {
1015 case GlobalProperty:
1016 case GlobalPropertyWithVarInjectionChecks: {
1017 emitLoadWithStructureCheck(scope, structureSlot); // Structure check covers var injection since we don't cache structures for anything but the GlobalObject. Additionally, resolve_scope handles checking for the var injection.
1018 emitGetVirtualRegister(value, regT2);
1020 jitAssert(scopedLambda<Jump(void)>([&] () -> Jump {
1021 return branchPtr(Equal, regT0, TrustedImmPtr(m_codeBlock->globalObject()));
1024 loadPtr(Address(regT0, JSObject::butterflyOffset()), regT0);
1025 loadPtr(operandSlot, regT1);
1027 storePtr(regT2, BaseIndex(regT0, regT1, TimesEight, (firstOutOfLineOffset - 2) * sizeof(EncodedJSValue)));
1028 emitWriteBarrier(m_codeBlock->globalObject(), value, ShouldFilterValue);
1032 case GlobalVarWithVarInjectionChecks:
1033 case GlobalLexicalVar:
1034 case GlobalLexicalVarWithVarInjectionChecks: {
1035 JSScope* constantScope = JSScope::constantScopeForCodeBlock(resolveType, m_codeBlock);
1036 RELEASE_ASSERT(constantScope);
1037 emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
1038 if (!isInitialization(getPutInfo.initializationMode()) && (resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks)) {
1039 // We need to do a TDZ check here because we can't always prove we need to emit TDZ checks statically.
1040 if (indirectLoadForOperand)
1041 emitGetVarFromIndirectPointer(bitwise_cast<JSValue**>(operandSlot), regT0);
1043 emitGetVarFromPointer(bitwise_cast<JSValue*>(*operandSlot), regT0);
1044 addSlowCase(branchTest64(Zero, regT0));
1046 if (indirectLoadForOperand)
1047 emitPutGlobalVariableIndirect(bitwise_cast<JSValue**>(operandSlot), value, bitwise_cast<WatchpointSet**>(¤tInstruction[5]));
1049 emitPutGlobalVariable(bitwise_cast<JSValue*>(*operandSlot), value, currentInstruction[5].u.watchpointSet);
1050 emitWriteBarrier(constantScope, value, ShouldFilterValue);
1053 case LocalClosureVar:
1055 case ClosureVarWithVarInjectionChecks:
1056 emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
1057 emitPutClosureVar(scope, *operandSlot, value, currentInstruction[5].u.watchpointSet);
1058 emitWriteBarrier(scope, value, ShouldFilterValue);
1062 addSlowCase(jump());
1064 case UnresolvedProperty:
1065 case UnresolvedPropertyWithVarInjectionChecks:
1066 RELEASE_ASSERT_NOT_REACHED();
1071 switch (resolveType) {
1072 case UnresolvedProperty:
1073 case UnresolvedPropertyWithVarInjectionChecks: {
1075 load32(¤tInstruction[4], regT0);
1076 and32(TrustedImm32(GetPutInfo::typeBits), regT0); // Load ResolveType into T0
1078 Jump isGlobalProperty = branch32(Equal, regT0, TrustedImm32(GlobalProperty));
1079 Jump notGlobalPropertyWithVarInjections = branch32(NotEqual, regT0, TrustedImm32(GlobalPropertyWithVarInjectionChecks));
1080 isGlobalProperty.link(this);
1081 emitCode(GlobalProperty, false);
1082 skipToEnd.append(jump());
1083 notGlobalPropertyWithVarInjections.link(this);
1085 Jump notGlobalLexicalVar = branch32(NotEqual, regT0, TrustedImm32(GlobalLexicalVar));
1086 emitCode(GlobalLexicalVar, true);
1087 skipToEnd.append(jump());
1088 notGlobalLexicalVar.link(this);
1090 Jump notGlobalLexicalVarWithVarInjections = branch32(NotEqual, regT0, TrustedImm32(GlobalLexicalVarWithVarInjectionChecks));
1091 emitCode(GlobalLexicalVarWithVarInjectionChecks, true);
1092 skipToEnd.append(jump());
1093 notGlobalLexicalVarWithVarInjections.link(this);
1095 addSlowCase(jump());
1097 skipToEnd.link(this);
1102 emitCode(resolveType, false);
1107 void JIT::emitSlow_op_put_to_scope(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
1109 linkAllSlowCases(iter);
1111 GetPutInfo getPutInfo = GetPutInfo(copiedInstruction(currentInstruction)[4].u.operand);
1112 ResolveType resolveType = getPutInfo.resolveType();
1113 if (resolveType == ModuleVar) {
1114 JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_throw_strict_mode_readonly_property_write_error);
1115 slowPathCall.call();
1117 callOperation(operationPutToScope, currentInstruction);
1120 void JIT::emit_op_get_from_arguments(Instruction* currentInstruction)
1122 int dst = currentInstruction[1].u.operand;
1123 int arguments = currentInstruction[2].u.operand;
1124 int index = currentInstruction[3].u.operand;
1126 emitGetVirtualRegister(arguments, regT0);
1127 load64(Address(regT0, DirectArguments::storageOffset() + index * sizeof(WriteBarrier<Unknown>)), regT0);
1128 emitValueProfilingSite();
1129 emitPutVirtualRegister(dst);
1132 void JIT::emit_op_put_to_arguments(Instruction* currentInstruction)
1134 int arguments = currentInstruction[1].u.operand;
1135 int index = currentInstruction[2].u.operand;
1136 int value = currentInstruction[3].u.operand;
1138 emitGetVirtualRegister(arguments, regT0);
1139 emitGetVirtualRegister(value, regT1);
1140 store64(regT1, Address(regT0, DirectArguments::storageOffset() + index * sizeof(WriteBarrier<Unknown>)));
1142 emitWriteBarrier(arguments, value, ShouldFilterValue);
1145 #endif // USE(JSVALUE64)
1148 void JIT::emitWriteBarrier(unsigned owner, unsigned value, WriteBarrierMode mode)
1151 if (mode == ShouldFilterValue || mode == ShouldFilterBaseAndValue) {
1152 emitGetVirtualRegister(value, regT0);
1153 valueNotCell = branchTest64(NonZero, regT0, tagMaskRegister);
1156 emitGetVirtualRegister(owner, regT0);
1158 if (mode == ShouldFilterBaseAndValue || mode == ShouldFilterBase)
1159 ownerNotCell = branchTest64(NonZero, regT0, tagMaskRegister);
1161 Jump ownerIsRememberedOrInEden = barrierBranch(*vm(), regT0, regT1);
1162 callOperation(operationWriteBarrierSlowPath, regT0);
1163 ownerIsRememberedOrInEden.link(this);
1165 if (mode == ShouldFilterBaseAndValue || mode == ShouldFilterBase)
1166 ownerNotCell.link(this);
1167 if (mode == ShouldFilterValue || mode == ShouldFilterBaseAndValue)
1168 valueNotCell.link(this);
1171 void JIT::emitWriteBarrier(JSCell* owner, unsigned value, WriteBarrierMode mode)
1173 emitGetVirtualRegister(value, regT0);
1175 if (mode == ShouldFilterValue)
1176 valueNotCell = branchTest64(NonZero, regT0, tagMaskRegister);
1178 emitWriteBarrier(owner);
1180 if (mode == ShouldFilterValue)
1181 valueNotCell.link(this);
1184 #else // USE(JSVALUE64)
1186 void JIT::emitWriteBarrier(unsigned owner, unsigned value, WriteBarrierMode mode)
1189 if (mode == ShouldFilterValue || mode == ShouldFilterBaseAndValue) {
1190 emitLoadTag(value, regT0);
1191 valueNotCell = branch32(NotEqual, regT0, TrustedImm32(JSValue::CellTag));
1194 emitLoad(owner, regT0, regT1);
1196 if (mode == ShouldFilterBase || mode == ShouldFilterBaseAndValue)
1197 ownerNotCell = branch32(NotEqual, regT0, TrustedImm32(JSValue::CellTag));
1199 Jump ownerIsRememberedOrInEden = barrierBranch(*vm(), regT1, regT2);
1200 callOperation(operationWriteBarrierSlowPath, regT1);
1201 ownerIsRememberedOrInEden.link(this);
1203 if (mode == ShouldFilterBase || mode == ShouldFilterBaseAndValue)
1204 ownerNotCell.link(this);
1205 if (mode == ShouldFilterValue || mode == ShouldFilterBaseAndValue)
1206 valueNotCell.link(this);
1209 void JIT::emitWriteBarrier(JSCell* owner, unsigned value, WriteBarrierMode mode)
1212 if (mode == ShouldFilterValue) {
1213 emitLoadTag(value, regT0);
1214 valueNotCell = branch32(NotEqual, regT0, TrustedImm32(JSValue::CellTag));
1217 emitWriteBarrier(owner);
1219 if (mode == ShouldFilterValue)
1220 valueNotCell.link(this);
1223 #endif // USE(JSVALUE64)
1225 void JIT::emitWriteBarrier(JSCell* owner)
1227 Jump ownerIsRememberedOrInEden = barrierBranch(*vm(), owner, regT0);
1228 callOperation(operationWriteBarrierSlowPath, owner);
1229 ownerIsRememberedOrInEden.link(this);
1232 void JIT::emitByValIdentifierCheck(ByValInfo* byValInfo, RegisterID cell, RegisterID scratch, const Identifier& propertyName, JumpList& slowCases)
1234 if (propertyName.isSymbol())
1235 slowCases.append(branchPtr(NotEqual, cell, TrustedImmPtr(byValInfo->cachedSymbol.get())));
1237 slowCases.append(branchStructure(NotEqual, Address(cell, JSCell::structureIDOffset()), m_vm->stringStructure.get()));
1238 loadPtr(Address(cell, JSString::offsetOfValue()), scratch);
1239 slowCases.append(branchPtr(NotEqual, scratch, TrustedImmPtr(propertyName.impl())));
1243 void JIT::privateCompileGetByVal(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
1245 Instruction* currentInstruction = &m_codeBlock->instructions()[byValInfo->bytecodeIndex];
1247 PatchableJump badType;
1250 switch (arrayMode) {
1252 slowCases = emitInt32GetByVal(currentInstruction, badType);
1255 slowCases = emitDoubleGetByVal(currentInstruction, badType);
1258 slowCases = emitContiguousGetByVal(currentInstruction, badType);
1260 case JITArrayStorage:
1261 slowCases = emitArrayStorageGetByVal(currentInstruction, badType);
1263 case JITDirectArguments:
1264 slowCases = emitDirectArgumentsGetByVal(currentInstruction, badType);
1266 case JITScopedArguments:
1267 slowCases = emitScopedArgumentsGetByVal(currentInstruction, badType);
1270 TypedArrayType type = typedArrayTypeForJITArrayMode(arrayMode);
1272 slowCases = emitIntTypedArrayGetByVal(currentInstruction, badType, type);
1274 slowCases = emitFloatTypedArrayGetByVal(currentInstruction, badType, type);
1280 LinkBuffer patchBuffer(*this, m_codeBlock);
1282 patchBuffer.link(badType, CodeLocationLabel<NoPtrTag>(MacroAssemblerCodePtr<NoPtrTag>::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1283 patchBuffer.link(slowCases, CodeLocationLabel<NoPtrTag>(MacroAssemblerCodePtr<NoPtrTag>::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1285 patchBuffer.link(done, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
1287 byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
1288 m_codeBlock, patchBuffer, JITStubRoutinePtrTag,
1289 "Baseline get_by_val stub for %s, return point %p", toCString(*m_codeBlock).data(), returnAddress.value());
1291 MacroAssembler::repatchJump(byValInfo->badTypeJump, CodeLocationLabel<JITStubRoutinePtrTag>(byValInfo->stubRoutine->code().code()));
1292 MacroAssembler::repatchCall(CodeLocationCall<NoPtrTag>(MacroAssemblerCodePtr<NoPtrTag>(returnAddress)), FunctionPtr<OperationPtrTag>(operationGetByValGeneric));
1295 void JIT::privateCompileGetByValWithCachedId(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, const Identifier& propertyName)
1297 Instruction* currentInstruction = &m_codeBlock->instructions()[byValInfo->bytecodeIndex];
1303 JITGetByIdGenerator gen = emitGetByValWithCachedId(byValInfo, currentInstruction, propertyName, fastDoneCase, slowDoneCase, slowCases);
1305 ConcurrentJSLocker locker(m_codeBlock->m_lock);
1306 LinkBuffer patchBuffer(*this, m_codeBlock);
1307 patchBuffer.link(slowCases, CodeLocationLabel<NoPtrTag>(MacroAssemblerCodePtr<NoPtrTag>::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1308 patchBuffer.link(fastDoneCase, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
1309 patchBuffer.link(slowDoneCase, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToNextHotPath));
1310 if (!m_exceptionChecks.empty())
1311 patchBuffer.link(m_exceptionChecks, byValInfo->exceptionHandler);
1313 for (const auto& callSite : m_calls) {
1314 if (callSite.callee)
1315 patchBuffer.link(callSite.from, callSite.callee);
1317 gen.finalize(patchBuffer);
1319 byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
1320 m_codeBlock, patchBuffer, JITStubRoutinePtrTag,
1321 "Baseline get_by_val with cached property name '%s' stub for %s, return point %p", propertyName.impl()->utf8().data(), toCString(*m_codeBlock).data(), returnAddress.value());
1322 byValInfo->stubInfo = gen.stubInfo();
1324 MacroAssembler::repatchJump(byValInfo->notIndexJump, CodeLocationLabel<JITStubRoutinePtrTag>(byValInfo->stubRoutine->code().code()));
1325 MacroAssembler::repatchCall(CodeLocationCall<NoPtrTag>(MacroAssemblerCodePtr<NoPtrTag>(returnAddress)), FunctionPtr<OperationPtrTag>(operationGetByValGeneric));
1328 void JIT::privateCompilePutByVal(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
1330 Instruction* currentInstruction = &m_codeBlock->instructions()[byValInfo->bytecodeIndex];
1332 PatchableJump badType;
1335 bool needsLinkForWriteBarrier = false;
1337 switch (arrayMode) {
1339 slowCases = emitInt32PutByVal(currentInstruction, badType);
1342 slowCases = emitDoublePutByVal(currentInstruction, badType);
1345 slowCases = emitContiguousPutByVal(currentInstruction, badType);
1346 needsLinkForWriteBarrier = true;
1348 case JITArrayStorage:
1349 slowCases = emitArrayStoragePutByVal(currentInstruction, badType);
1350 needsLinkForWriteBarrier = true;
1353 TypedArrayType type = typedArrayTypeForJITArrayMode(arrayMode);
1355 slowCases = emitIntTypedArrayPutByVal(currentInstruction, badType, type);
1357 slowCases = emitFloatTypedArrayPutByVal(currentInstruction, badType, type);
1363 LinkBuffer patchBuffer(*this, m_codeBlock);
1364 patchBuffer.link(badType, CodeLocationLabel<NoPtrTag>(MacroAssemblerCodePtr<NoPtrTag>::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1365 patchBuffer.link(slowCases, CodeLocationLabel<NoPtrTag>(MacroAssemblerCodePtr<NoPtrTag>::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1366 patchBuffer.link(done, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
1367 if (needsLinkForWriteBarrier) {
1368 ASSERT(removeCodePtrTag(m_calls.last().callee.executableAddress()) == removeCodePtrTag(operationWriteBarrierSlowPath));
1369 patchBuffer.link(m_calls.last().from, m_calls.last().callee);
1372 bool isDirect = Interpreter::getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct;
1374 byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
1375 m_codeBlock, patchBuffer, JITStubRoutinePtrTag,
1376 "Baseline put_by_val stub for %s, return point %p", toCString(*m_codeBlock).data(), returnAddress.value());
1379 byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
1380 m_codeBlock, patchBuffer, JITStubRoutinePtrTag,
1381 "Baseline put_by_val_direct stub for %s, return point %p", toCString(*m_codeBlock).data(), returnAddress.value());
1383 MacroAssembler::repatchJump(byValInfo->badTypeJump, CodeLocationLabel<JITStubRoutinePtrTag>(byValInfo->stubRoutine->code().code()));
1384 MacroAssembler::repatchCall(CodeLocationCall<NoPtrTag>(MacroAssemblerCodePtr<NoPtrTag>(returnAddress)), FunctionPtr<OperationPtrTag>(isDirect ? operationDirectPutByValGeneric : operationPutByValGeneric));
1387 void JIT::privateCompilePutByValWithCachedId(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, PutKind putKind, const Identifier& propertyName)
1389 Instruction* currentInstruction = &m_codeBlock->instructions()[byValInfo->bytecodeIndex];
1394 JITPutByIdGenerator gen = emitPutByValWithCachedId(byValInfo, currentInstruction, putKind, propertyName, doneCases, slowCases);
1396 ConcurrentJSLocker locker(m_codeBlock->m_lock);
1397 LinkBuffer patchBuffer(*this, m_codeBlock);
1398 patchBuffer.link(slowCases, CodeLocationLabel<NoPtrTag>(MacroAssemblerCodePtr<NoPtrTag>::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1399 patchBuffer.link(doneCases, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
1400 if (!m_exceptionChecks.empty())
1401 patchBuffer.link(m_exceptionChecks, byValInfo->exceptionHandler);
1403 for (const auto& callSite : m_calls) {
1404 if (callSite.callee)
1405 patchBuffer.link(callSite.from, callSite.callee);
1407 gen.finalize(patchBuffer);
1409 byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
1410 m_codeBlock, patchBuffer, JITStubRoutinePtrTag,
1411 "Baseline put_by_val%s with cached property name '%s' stub for %s, return point %p", (putKind == Direct) ? "_direct" : "", propertyName.impl()->utf8().data(), toCString(*m_codeBlock).data(), returnAddress.value());
1412 byValInfo->stubInfo = gen.stubInfo();
1414 MacroAssembler::repatchJump(byValInfo->notIndexJump, CodeLocationLabel<JITStubRoutinePtrTag>(byValInfo->stubRoutine->code().code()));
1415 MacroAssembler::repatchCall(CodeLocationCall<NoPtrTag>(MacroAssemblerCodePtr<NoPtrTag>(returnAddress)), FunctionPtr<OperationPtrTag>(putKind == Direct ? operationDirectPutByValGeneric : operationPutByValGeneric));
1419 JIT::JumpList JIT::emitDirectArgumentsGetByVal(Instruction*, PatchableJump& badType)
1424 RegisterID base = regT0;
1425 RegisterID property = regT1;
1426 JSValueRegs result = JSValueRegs(regT0);
1427 RegisterID scratch = regT3;
1428 RegisterID scratch2 = regT4;
1430 RegisterID base = regT0;
1431 RegisterID property = regT2;
1432 JSValueRegs result = JSValueRegs(regT1, regT0);
1433 RegisterID scratch = regT3;
1434 RegisterID scratch2 = regT4;
1437 load8(Address(base, JSCell::typeInfoTypeOffset()), scratch);
1438 badType = patchableBranch32(NotEqual, scratch, TrustedImm32(DirectArgumentsType));
1440 load32(Address(base, DirectArguments::offsetOfLength()), scratch2);
1441 slowCases.append(branch32(AboveOrEqual, property, scratch2));
1442 slowCases.append(branchTestPtr(NonZero, Address(base, DirectArguments::offsetOfMappedArguments())));
1444 loadValue(BaseIndex(base, property, TimesEight, DirectArguments::storageOffset()), result);
1449 JIT::JumpList JIT::emitScopedArgumentsGetByVal(Instruction*, PatchableJump& badType)
1454 RegisterID base = regT0;
1455 RegisterID property = regT1;
1456 JSValueRegs result = JSValueRegs(regT0);
1457 RegisterID scratch = regT3;
1458 RegisterID scratch2 = regT4;
1459 RegisterID scratch3 = regT5;
1461 RegisterID base = regT0;
1462 RegisterID property = regT2;
1463 JSValueRegs result = JSValueRegs(regT1, regT0);
1464 RegisterID scratch = regT3;
1465 RegisterID scratch2 = regT4;
1466 RegisterID scratch3 = regT5;
1469 load8(Address(base, JSCell::typeInfoTypeOffset()), scratch);
1470 badType = patchableBranch32(NotEqual, scratch, TrustedImm32(ScopedArgumentsType));
1471 loadPtr(Address(base, ScopedArguments::offsetOfStorage()), scratch3);
1472 xorPtr(TrustedImmPtr(ScopedArgumentsPoison::key()), scratch3);
1473 slowCases.append(branch32(AboveOrEqual, property, Address(scratch3, ScopedArguments::offsetOfTotalLengthInStorage())));
1475 loadPtr(Address(base, ScopedArguments::offsetOfTable()), scratch);
1476 xorPtr(TrustedImmPtr(ScopedArgumentsPoison::key()), scratch);
1477 load32(Address(scratch, ScopedArgumentsTable::offsetOfLength()), scratch2);
1478 Jump overflowCase = branch32(AboveOrEqual, property, scratch2);
1479 loadPtr(Address(base, ScopedArguments::offsetOfScope()), scratch2);
1480 xorPtr(TrustedImmPtr(ScopedArgumentsPoison::key()), scratch2);
1481 loadPtr(Address(scratch, ScopedArgumentsTable::offsetOfArguments()), scratch);
1482 load32(BaseIndex(scratch, property, TimesFour), scratch);
1483 slowCases.append(branch32(Equal, scratch, TrustedImm32(ScopeOffset::invalidOffset)));
1484 loadValue(BaseIndex(scratch2, scratch, TimesEight, JSLexicalEnvironment::offsetOfVariables()), result);
1486 overflowCase.link(this);
1487 sub32(property, scratch2);
1489 loadValue(BaseIndex(scratch3, scratch2, TimesEight), result);
1490 slowCases.append(branchIfEmpty(result));
1493 load32(Address(scratch3, ScopedArguments::offsetOfTotalLengthInStorage()), scratch);
1494 emitPreparePreciseIndexMask32(property, scratch, scratch2);
1495 andPtr(scratch2, result.payloadGPR());
1500 JIT::JumpList JIT::emitIntTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType type)
1502 ASSERT(isInt(type));
1504 // The best way to test the array type is to use the classInfo. We need to do so without
1505 // clobbering the register that holds the indexing type, base, and property.
1508 RegisterID base = regT0;
1509 RegisterID property = regT1;
1510 RegisterID resultPayload = regT0;
1511 RegisterID scratch = regT3;
1512 RegisterID scratch2 = regT4;
1514 RegisterID base = regT0;
1515 RegisterID property = regT2;
1516 RegisterID resultPayload = regT0;
1517 RegisterID resultTag = regT1;
1518 RegisterID scratch = regT3;
1519 RegisterID scratch2 = regT4;
1524 load8(Address(base, JSCell::typeInfoTypeOffset()), scratch);
1525 badType = patchableBranch32(NotEqual, scratch, TrustedImm32(typeForTypedArrayType(type)));
1526 slowCases.append(branch32(AboveOrEqual, property, Address(base, JSArrayBufferView::offsetOfLength())));
1527 loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), scratch);
1528 cageConditionally(Gigacage::Primitive, scratch, scratch2);
1530 switch (elementSize(type)) {
1532 if (JSC::isSigned(type))
1533 load8SignedExtendTo32(BaseIndex(scratch, property, TimesOne), resultPayload);
1535 load8(BaseIndex(scratch, property, TimesOne), resultPayload);
1538 if (JSC::isSigned(type))
1539 load16SignedExtendTo32(BaseIndex(scratch, property, TimesTwo), resultPayload);
1541 load16(BaseIndex(scratch, property, TimesTwo), resultPayload);
1544 load32(BaseIndex(scratch, property, TimesFour), resultPayload);
1551 if (type == TypeUint32) {
1552 Jump canBeInt = branch32(GreaterThanOrEqual, resultPayload, TrustedImm32(0));
1554 convertInt32ToDouble(resultPayload, fpRegT0);
1555 addDouble(AbsoluteAddress(&twoToThe32), fpRegT0);
1557 moveDoubleTo64(fpRegT0, resultPayload);
1558 sub64(tagTypeNumberRegister, resultPayload);
1560 moveDoubleToInts(fpRegT0, resultPayload, resultTag);
1564 canBeInt.link(this);
1568 or64(tagTypeNumberRegister, resultPayload);
1570 move(TrustedImm32(JSValue::Int32Tag), resultTag);
1577 JIT::JumpList JIT::emitFloatTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType type)
1579 ASSERT(isFloat(type));
1582 RegisterID base = regT0;
1583 RegisterID property = regT1;
1584 RegisterID resultPayload = regT0;
1585 RegisterID scratch = regT3;
1586 RegisterID scratch2 = regT4;
1588 RegisterID base = regT0;
1589 RegisterID property = regT2;
1590 RegisterID resultPayload = regT0;
1591 RegisterID resultTag = regT1;
1592 RegisterID scratch = regT3;
1593 RegisterID scratch2 = regT4;
1598 load8(Address(base, JSCell::typeInfoTypeOffset()), scratch);
1599 badType = patchableBranch32(NotEqual, scratch, TrustedImm32(typeForTypedArrayType(type)));
1600 slowCases.append(branch32(AboveOrEqual, property, Address(base, JSArrayBufferView::offsetOfLength())));
1601 loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), scratch);
1602 cageConditionally(Gigacage::Primitive, scratch, scratch2);
1604 switch (elementSize(type)) {
1606 loadFloat(BaseIndex(scratch, property, TimesFour), fpRegT0);
1607 convertFloatToDouble(fpRegT0, fpRegT0);
1610 loadDouble(BaseIndex(scratch, property, TimesEight), fpRegT0);
1617 Jump notNaN = branchDouble(DoubleEqual, fpRegT0, fpRegT0);
1618 static const double NaN = PNaN;
1619 loadDouble(TrustedImmPtr(&NaN), fpRegT0);
1623 moveDoubleTo64(fpRegT0, resultPayload);
1624 sub64(tagTypeNumberRegister, resultPayload);
1626 moveDoubleToInts(fpRegT0, resultPayload, resultTag);
1631 JIT::JumpList JIT::emitIntTypedArrayPutByVal(Instruction* currentInstruction, PatchableJump& badType, TypedArrayType type)
1633 ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
1634 ASSERT(isInt(type));
1636 int value = currentInstruction[3].u.operand;
1639 RegisterID base = regT0;
1640 RegisterID property = regT1;
1641 RegisterID earlyScratch = regT3;
1642 RegisterID lateScratch = regT2;
1643 RegisterID lateScratch2 = regT4;
1645 RegisterID base = regT0;
1646 RegisterID property = regT2;
1647 RegisterID earlyScratch = regT3;
1648 RegisterID lateScratch = regT1;
1649 RegisterID lateScratch2 = regT4;
1654 load8(Address(base, JSCell::typeInfoTypeOffset()), earlyScratch);
1655 badType = patchableBranch32(NotEqual, earlyScratch, TrustedImm32(typeForTypedArrayType(type)));
1656 Jump inBounds = branch32(Below, property, Address(base, JSArrayBufferView::offsetOfLength()));
1657 emitArrayProfileOutOfBoundsSpecialCase(profile);
1658 slowCases.append(jump());
1659 inBounds.link(this);
1662 emitGetVirtualRegister(value, earlyScratch);
1663 slowCases.append(emitJumpIfNotInt(earlyScratch));
1665 emitLoad(value, lateScratch, earlyScratch);
1666 slowCases.append(branch32(NotEqual, lateScratch, TrustedImm32(JSValue::Int32Tag)));
1669 // We would be loading this into base as in get_by_val, except that the slow
1670 // path expects the base to be unclobbered.
1671 loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), lateScratch);
1672 cageConditionally(Gigacage::Primitive, lateScratch, lateScratch2);
1674 if (isClamped(type)) {
1675 ASSERT(elementSize(type) == 1);
1676 ASSERT(!JSC::isSigned(type));
1677 Jump inBounds = branch32(BelowOrEqual, earlyScratch, TrustedImm32(0xff));
1678 Jump tooBig = branch32(GreaterThan, earlyScratch, TrustedImm32(0xff));
1679 xor32(earlyScratch, earlyScratch);
1680 Jump clamped = jump();
1682 move(TrustedImm32(0xff), earlyScratch);
1684 inBounds.link(this);
1687 switch (elementSize(type)) {
1689 store8(earlyScratch, BaseIndex(lateScratch, property, TimesOne));
1692 store16(earlyScratch, BaseIndex(lateScratch, property, TimesTwo));
1695 store32(earlyScratch, BaseIndex(lateScratch, property, TimesFour));
1704 JIT::JumpList JIT::emitFloatTypedArrayPutByVal(Instruction* currentInstruction, PatchableJump& badType, TypedArrayType type)
1706 ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
1707 ASSERT(isFloat(type));
1709 int value = currentInstruction[3].u.operand;
1712 RegisterID base = regT0;
1713 RegisterID property = regT1;
1714 RegisterID earlyScratch = regT3;
1715 RegisterID lateScratch = regT2;
1716 RegisterID lateScratch2 = regT4;
1718 RegisterID base = regT0;
1719 RegisterID property = regT2;
1720 RegisterID earlyScratch = regT3;
1721 RegisterID lateScratch = regT1;
1722 RegisterID lateScratch2 = regT4;
1727 load8(Address(base, JSCell::typeInfoTypeOffset()), earlyScratch);
1728 badType = patchableBranch32(NotEqual, earlyScratch, TrustedImm32(typeForTypedArrayType(type)));
1729 Jump inBounds = branch32(Below, property, Address(base, JSArrayBufferView::offsetOfLength()));
1730 emitArrayProfileOutOfBoundsSpecialCase(profile);
1731 slowCases.append(jump());
1732 inBounds.link(this);
1735 emitGetVirtualRegister(value, earlyScratch);
1736 Jump doubleCase = emitJumpIfNotInt(earlyScratch);
1737 convertInt32ToDouble(earlyScratch, fpRegT0);
1738 Jump ready = jump();
1739 doubleCase.link(this);
1740 slowCases.append(emitJumpIfNotNumber(earlyScratch));
1741 add64(tagTypeNumberRegister, earlyScratch);
1742 move64ToDouble(earlyScratch, fpRegT0);
1745 emitLoad(value, lateScratch, earlyScratch);
1746 Jump doubleCase = branch32(NotEqual, lateScratch, TrustedImm32(JSValue::Int32Tag));
1747 convertInt32ToDouble(earlyScratch, fpRegT0);
1748 Jump ready = jump();
1749 doubleCase.link(this);
1750 slowCases.append(branch32(Above, lateScratch, TrustedImm32(JSValue::LowestTag)));
1751 moveIntsToDouble(earlyScratch, lateScratch, fpRegT0, fpRegT1);
1755 // We would be loading this into base as in get_by_val, except that the slow
1756 // path expects the base to be unclobbered.
1757 loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), lateScratch);
1758 cageConditionally(Gigacage::Primitive, lateScratch, lateScratch2);
1760 switch (elementSize(type)) {
1762 convertDoubleToFloat(fpRegT0, fpRegT0);
1763 storeFloat(fpRegT0, BaseIndex(lateScratch, property, TimesFour));
1766 storeDouble(fpRegT0, BaseIndex(lateScratch, property, TimesEight));
1777 #endif // ENABLE(JIT)