CallLinkInfo inside StructureStubInfo should not use polymorphic stubs
[WebKit-https.git] / Source / JavaScriptCore / jit / JITPropertyAccess.cpp
1 /*
2  * Copyright (C) 2008, 2009, 2014, 2015 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
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.
12  *
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. 
24  */
25
26 #include "config.h"
27
28 #if ENABLE(JIT)
29 #include "JIT.h"
30
31 #include "CodeBlock.h"
32 #include "DirectArguments.h"
33 #include "GCAwareJITStubRoutine.h"
34 #include "GetterSetter.h"
35 #include "Interpreter.h"
36 #include "JITInlines.h"
37 #include "JSArray.h"
38 #include "JSEnvironmentRecord.h"
39 #include "JSFunction.h"
40 #include "LinkBuffer.h"
41 #include "ResultType.h"
42 #include "SamplingTool.h"
43 #include "ScopedArguments.h"
44 #include "ScopedArgumentsTable.h"
45 #include "SlowPathCall.h"
46 #include <wtf/StringPrintStream.h>
47
48
49 namespace JSC {
50 #if USE(JSVALUE64)
51
52 JIT::CodeRef JIT::stringGetByValStubGenerator(VM* vm)
53 {
54     JSInterfaceJIT jit(vm);
55     JumpList failures;
56     failures.append(jit.branchStructure(
57         NotEqual, 
58         Address(regT0, JSCell::structureIDOffset()), 
59         vm->stringStructure.get()));
60
61     // Load string length to regT2, and start the process of loading the data pointer into regT0
62     jit.load32(Address(regT0, ThunkHelpers::jsStringLengthOffset()), regT2);
63     jit.loadPtr(Address(regT0, ThunkHelpers::jsStringValueOffset()), regT0);
64     failures.append(jit.branchTest32(Zero, regT0));
65
66     // Do an unsigned compare to simultaneously filter negative indices as well as indices that are too large
67     failures.append(jit.branch32(AboveOrEqual, regT1, regT2));
68     
69     // Load the character
70     JumpList is16Bit;
71     JumpList cont8Bit;
72     // Load the string flags
73     jit.loadPtr(Address(regT0, StringImpl::flagsOffset()), regT2);
74     jit.loadPtr(Address(regT0, StringImpl::dataOffset()), regT0);
75     is16Bit.append(jit.branchTest32(Zero, regT2, TrustedImm32(StringImpl::flagIs8Bit())));
76     jit.load8(BaseIndex(regT0, regT1, TimesOne, 0), regT0);
77     cont8Bit.append(jit.jump());
78     is16Bit.link(&jit);
79     jit.load16(BaseIndex(regT0, regT1, TimesTwo, 0), regT0);
80     cont8Bit.link(&jit);
81
82     failures.append(jit.branch32(AboveOrEqual, regT0, TrustedImm32(0x100)));
83     jit.move(TrustedImmPtr(vm->smallStrings.singleCharacterStrings()), regT1);
84     jit.loadPtr(BaseIndex(regT1, regT0, ScalePtr, 0), regT0);
85     jit.ret();
86     
87     failures.link(&jit);
88     jit.move(TrustedImm32(0), regT0);
89     jit.ret();
90     
91     LinkBuffer patchBuffer(*vm, jit, GLOBAL_THUNK_ID);
92     return FINALIZE_CODE(patchBuffer, ("String get_by_val stub"));
93 }
94
95 void JIT::emit_op_get_by_val(Instruction* currentInstruction)
96 {
97     int dst = currentInstruction[1].u.operand;
98     int base = currentInstruction[2].u.operand;
99     int property = currentInstruction[3].u.operand;
100     ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
101     ByValInfo* byValInfo = m_codeBlock->addByValInfo();
102
103     emitGetVirtualRegisters(base, regT0, property, regT1);
104
105     emitJumpSlowCaseIfNotJSCell(regT0, base);
106
107     PatchableJump notIndex = emitPatchableJumpIfNotImmediateInteger(regT1);
108     addSlowCase(notIndex);
109
110     // This is technically incorrect - we're zero-extending an int32.  On the hot path this doesn't matter.
111     // We check the value as if it was a uint32 against the m_vectorLength - which will always fail if
112     // number was signed since m_vectorLength is always less than intmax (since the total allocation
113     // size is always less than 4Gb).  As such zero extending will have been correct (and extending the value
114     // to 64-bits is necessary since it's used in the address calculation).  We zero extend rather than sign
115     // extending since it makes it easier to re-tag the value in the slow case.
116     zeroExtend32ToPtr(regT1, regT1);
117
118     emitArrayProfilingSiteWithCell(regT0, regT2, profile);
119     and32(TrustedImm32(IndexingShapeMask), regT2);
120
121     PatchableJump badType;
122     JumpList slowCases;
123
124     JITArrayMode mode = chooseArrayMode(profile);
125     switch (mode) {
126     case JITInt32:
127         slowCases = emitInt32GetByVal(currentInstruction, badType);
128         break;
129     case JITDouble:
130         slowCases = emitDoubleGetByVal(currentInstruction, badType);
131         break;
132     case JITContiguous:
133         slowCases = emitContiguousGetByVal(currentInstruction, badType);
134         break;
135     case JITArrayStorage:
136         slowCases = emitArrayStorageGetByVal(currentInstruction, badType);
137         break;
138     default:
139         CRASH();
140         break;
141     }
142     
143     addSlowCase(badType);
144     addSlowCase(slowCases);
145     
146     Label done = label();
147     
148     if (!ASSERT_DISABLED) {
149         Jump resultOK = branchTest64(NonZero, regT0);
150         abortWithReason(JITGetByValResultIsNotEmpty);
151         resultOK.link(this);
152     }
153
154     emitValueProfilingSite();
155     emitPutVirtualRegister(dst);
156
157     Label nextHotPath = label();
158
159     m_byValCompilationInfo.append(ByValCompilationInfo(byValInfo, m_bytecodeOffset, notIndex, badType, mode, profile, done, nextHotPath));
160 }
161
162 JIT::JumpList JIT::emitDoubleLoad(Instruction*, PatchableJump& badType)
163 {
164     JumpList slowCases;
165     
166     badType = patchableBranch32(NotEqual, regT2, TrustedImm32(DoubleShape));
167     loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
168     slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfPublicLength())));
169     loadDouble(BaseIndex(regT2, regT1, TimesEight), fpRegT0);
170     slowCases.append(branchDouble(DoubleNotEqualOrUnordered, fpRegT0, fpRegT0));
171     
172     return slowCases;
173 }
174
175 JIT::JumpList JIT::emitContiguousLoad(Instruction*, PatchableJump& badType, IndexingType expectedShape)
176 {
177     JumpList slowCases;
178     
179     badType = patchableBranch32(NotEqual, regT2, TrustedImm32(expectedShape));
180     loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
181     slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfPublicLength())));
182     load64(BaseIndex(regT2, regT1, TimesEight), regT0);
183     slowCases.append(branchTest64(Zero, regT0));
184     
185     return slowCases;
186 }
187
188 JIT::JumpList JIT::emitArrayStorageLoad(Instruction*, PatchableJump& badType)
189 {
190     JumpList slowCases;
191
192     add32(TrustedImm32(-ArrayStorageShape), regT2, regT3);
193     badType = patchableBranch32(Above, regT3, TrustedImm32(SlowPutArrayStorageShape - ArrayStorageShape));
194
195     loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
196     slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, ArrayStorage::vectorLengthOffset())));
197
198     load64(BaseIndex(regT2, regT1, TimesEight, ArrayStorage::vectorOffset()), regT0);
199     slowCases.append(branchTest64(Zero, regT0));
200     
201     return slowCases;
202 }
203
204 JITGetByIdGenerator JIT::emitGetByValWithCachedId(Instruction* currentInstruction, const Identifier& propertyName, Jump& fastDoneCase, Jump& slowDoneCase, JumpList& slowCases)
205 {
206     // base: regT0
207     // property: regT1
208     // scratch: regT3
209
210     int dst = currentInstruction[1].u.operand;
211
212     slowCases.append(emitJumpIfNotJSCell(regT1));
213     emitIdentifierCheck(regT1, regT3, propertyName, slowCases);
214
215     JITGetByIdGenerator gen(
216         m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::specialRegisters(),
217         JSValueRegs(regT0), JSValueRegs(regT0), DontSpill);
218     gen.generateFastPath(*this);
219
220     fastDoneCase = jump();
221
222     Label coldPathBegin = label();
223     gen.slowPathJump().link(this);
224
225     Call call = callOperation(WithProfile, operationGetByIdOptimize, dst, gen.stubInfo(), regT0, propertyName.impl());
226     gen.reportSlowPathCall(coldPathBegin, call);
227     slowDoneCase = jump();
228
229     return gen;
230 }
231
232 void JIT::emitSlow_op_get_by_val(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
233 {
234     int dst = currentInstruction[1].u.operand;
235     int base = currentInstruction[2].u.operand;
236     int property = currentInstruction[3].u.operand;
237     ByValInfo* byValInfo = m_byValCompilationInfo[m_byValInstructionIndex].byValInfo;
238     
239     linkSlowCaseIfNotJSCell(iter, base); // base cell check
240     linkSlowCase(iter); // property int32 check
241     Jump nonCell = jump();
242     linkSlowCase(iter); // base array check
243     Jump notString = branchStructure(NotEqual, 
244         Address(regT0, JSCell::structureIDOffset()), 
245         m_vm->stringStructure.get());
246     emitNakedCall(CodeLocationLabel(m_vm->getCTIStub(stringGetByValStubGenerator).code()));
247     Jump failed = branchTest64(Zero, regT0);
248     emitPutVirtualRegister(dst, regT0);
249     emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_get_by_val));
250     failed.link(this);
251     notString.link(this);
252     nonCell.link(this);
253     
254     linkSlowCase(iter); // vector length check
255     linkSlowCase(iter); // empty value
256     
257     Label slowPath = label();
258     
259     emitGetVirtualRegister(base, regT0);
260     emitGetVirtualRegister(property, regT1);
261     Call call = callOperation(operationGetByValOptimize, dst, regT0, regT1, byValInfo);
262
263     m_byValCompilationInfo[m_byValInstructionIndex].slowPathTarget = slowPath;
264     m_byValCompilationInfo[m_byValInstructionIndex].returnAddress = call;
265     m_byValInstructionIndex++;
266
267     emitValueProfilingSite();
268 }
269
270 void JIT::compileGetDirectOffset(RegisterID base, RegisterID result, RegisterID offset, RegisterID scratch, FinalObjectMode finalObjectMode)
271 {
272     ASSERT(sizeof(JSValue) == 8);
273     
274     if (finalObjectMode == MayBeFinal) {
275         Jump isInline = branch32(LessThan, offset, TrustedImm32(firstOutOfLineOffset));
276         loadPtr(Address(base, JSObject::butterflyOffset()), scratch);
277         neg32(offset);
278         Jump done = jump();
279         isInline.link(this);
280         addPtr(TrustedImm32(JSObject::offsetOfInlineStorage() - (firstOutOfLineOffset - 2) * sizeof(EncodedJSValue)), base, scratch);
281         done.link(this);
282     } else {
283         if (!ASSERT_DISABLED) {
284             Jump isOutOfLine = branch32(GreaterThanOrEqual, offset, TrustedImm32(firstOutOfLineOffset));
285             abortWithReason(JITOffsetIsNotOutOfLine);
286             isOutOfLine.link(this);
287         }
288         loadPtr(Address(base, JSObject::butterflyOffset()), scratch);
289         neg32(offset);
290     }
291     signExtend32ToPtr(offset, offset);
292     load64(BaseIndex(scratch, offset, TimesEight, (firstOutOfLineOffset - 2) * sizeof(EncodedJSValue)), result);
293 }
294
295 void JIT::emit_op_put_by_val(Instruction* currentInstruction)
296 {
297     int base = currentInstruction[1].u.operand;
298     int property = currentInstruction[2].u.operand;
299     ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
300     ByValInfo* byValInfo = m_codeBlock->addByValInfo();
301
302     emitGetVirtualRegisters(base, regT0, property, regT1);
303     emitJumpSlowCaseIfNotJSCell(regT0, base);
304     PatchableJump notIndex = emitPatchableJumpIfNotImmediateInteger(regT1);
305     addSlowCase(notIndex);
306     // See comment in op_get_by_val.
307     zeroExtend32ToPtr(regT1, regT1);
308     emitArrayProfilingSiteWithCell(regT0, regT2, profile);
309     and32(TrustedImm32(IndexingShapeMask), regT2);
310     
311     PatchableJump badType;
312     JumpList slowCases;
313     
314     JITArrayMode mode = chooseArrayMode(profile);
315     switch (mode) {
316     case JITInt32:
317         slowCases = emitInt32PutByVal(currentInstruction, badType);
318         break;
319     case JITDouble:
320         slowCases = emitDoublePutByVal(currentInstruction, badType);
321         break;
322     case JITContiguous:
323         slowCases = emitContiguousPutByVal(currentInstruction, badType);
324         break;
325     case JITArrayStorage:
326         slowCases = emitArrayStoragePutByVal(currentInstruction, badType);
327         break;
328     default:
329         CRASH();
330         break;
331     }
332     
333     addSlowCase(badType);
334     addSlowCase(slowCases);
335     
336     Label done = label();
337     
338     m_byValCompilationInfo.append(ByValCompilationInfo(byValInfo, m_bytecodeOffset, notIndex, badType, mode, profile, done, done));
339 }
340
341 JIT::JumpList JIT::emitGenericContiguousPutByVal(Instruction* currentInstruction, PatchableJump& badType, IndexingType indexingShape)
342 {
343     int value = currentInstruction[3].u.operand;
344     ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
345     
346     JumpList slowCases;
347
348     badType = patchableBranch32(NotEqual, regT2, TrustedImm32(indexingShape));
349     
350     loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
351     Jump outOfBounds = branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfPublicLength()));
352
353     Label storeResult = label();
354     emitGetVirtualRegister(value, regT3);
355     switch (indexingShape) {
356     case Int32Shape:
357         slowCases.append(emitJumpIfNotImmediateInteger(regT3));
358         store64(regT3, BaseIndex(regT2, regT1, TimesEight));
359         break;
360     case DoubleShape: {
361         Jump notInt = emitJumpIfNotImmediateInteger(regT3);
362         convertInt32ToDouble(regT3, fpRegT0);
363         Jump ready = jump();
364         notInt.link(this);
365         add64(tagTypeNumberRegister, regT3);
366         move64ToDouble(regT3, fpRegT0);
367         slowCases.append(branchDouble(DoubleNotEqualOrUnordered, fpRegT0, fpRegT0));
368         ready.link(this);
369         storeDouble(fpRegT0, BaseIndex(regT2, regT1, TimesEight));
370         break;
371     }
372     case ContiguousShape:
373         store64(regT3, BaseIndex(regT2, regT1, TimesEight));
374         emitWriteBarrier(currentInstruction[1].u.operand, value, ShouldFilterValue);
375         break;
376     default:
377         CRASH();
378         break;
379     }
380     
381     Jump done = jump();
382     outOfBounds.link(this);
383     
384     slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfVectorLength())));
385     
386     emitArrayProfileStoreToHoleSpecialCase(profile);
387     
388     add32(TrustedImm32(1), regT1, regT3);
389     store32(regT3, Address(regT2, Butterfly::offsetOfPublicLength()));
390     jump().linkTo(storeResult, this);
391     
392     done.link(this);
393     
394     return slowCases;
395 }
396
397 JIT::JumpList JIT::emitArrayStoragePutByVal(Instruction* currentInstruction, PatchableJump& badType)
398 {
399     int value = currentInstruction[3].u.operand;
400     ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
401     
402     JumpList slowCases;
403     
404     badType = patchableBranch32(NotEqual, regT2, TrustedImm32(ArrayStorageShape));
405     loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
406     slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, ArrayStorage::vectorLengthOffset())));
407
408     Jump empty = branchTest64(Zero, BaseIndex(regT2, regT1, TimesEight, OBJECT_OFFSETOF(ArrayStorage, m_vector[0])));
409
410     Label storeResult(this);
411     emitGetVirtualRegister(value, regT3);
412     store64(regT3, BaseIndex(regT2, regT1, TimesEight, OBJECT_OFFSETOF(ArrayStorage, m_vector[0])));
413     emitWriteBarrier(currentInstruction[1].u.operand, value, ShouldFilterValue);
414     Jump end = jump();
415     
416     empty.link(this);
417     emitArrayProfileStoreToHoleSpecialCase(profile);
418     add32(TrustedImm32(1), Address(regT2, ArrayStorage::numValuesInVectorOffset()));
419     branch32(Below, regT1, Address(regT2, ArrayStorage::lengthOffset())).linkTo(storeResult, this);
420
421     add32(TrustedImm32(1), regT1);
422     store32(regT1, Address(regT2, ArrayStorage::lengthOffset()));
423     sub32(TrustedImm32(1), regT1);
424     jump().linkTo(storeResult, this);
425
426     end.link(this);
427     
428     return slowCases;
429 }
430
431 JITPutByIdGenerator JIT::emitPutByValWithCachedId(Instruction* currentInstruction, PutKind putKind, const Identifier& propertyName, JumpList& doneCases, JumpList& slowCases)
432 {
433     // base: regT0
434     // property: regT1
435     // scratch: regT2
436
437     int base = currentInstruction[1].u.operand;
438     int value = currentInstruction[3].u.operand;
439
440     slowCases.append(emitJumpIfNotJSCell(regT1));
441     emitIdentifierCheck(regT1, regT1, propertyName, slowCases);
442
443     // Write barrier breaks the registers. So after issuing the write barrier,
444     // reload the registers.
445     emitWriteBarrier(base, value, ShouldFilterValue);
446     emitGetVirtualRegisters(base, regT0, value, regT1);
447
448     JITPutByIdGenerator gen(
449         m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::specialRegisters(),
450         JSValueRegs(regT0), JSValueRegs(regT1), regT2, DontSpill, m_codeBlock->ecmaMode(), putKind);
451     gen.generateFastPath(*this);
452     doneCases.append(jump());
453
454     Label coldPathBegin = label();
455     gen.slowPathJump().link(this);
456
457     Call call = callOperation(gen.slowPathFunction(), gen.stubInfo(), regT1, regT0, propertyName.impl());
458     gen.reportSlowPathCall(coldPathBegin, call);
459     doneCases.append(jump());
460
461     return gen;
462 }
463
464 void JIT::emitSlow_op_put_by_val(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
465 {
466     int base = currentInstruction[1].u.operand;
467     int property = currentInstruction[2].u.operand;
468     int value = currentInstruction[3].u.operand;
469     ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
470     ByValInfo* byValInfo = m_byValCompilationInfo[m_byValInstructionIndex].byValInfo;
471
472     linkSlowCaseIfNotJSCell(iter, base); // base cell check
473     linkSlowCase(iter); // property int32 check
474     linkSlowCase(iter); // base not array check
475     
476     JITArrayMode mode = chooseArrayMode(profile);
477     switch (mode) {
478     case JITInt32:
479     case JITDouble:
480         linkSlowCase(iter); // value type check
481         break;
482     default:
483         break;
484     }
485     
486     Jump skipProfiling = jump();
487     linkSlowCase(iter); // out of bounds
488     emitArrayProfileOutOfBoundsSpecialCase(profile);
489     skipProfiling.link(this);
490     
491     Label slowPath = label();
492
493     emitGetVirtualRegister(base, regT0);
494     emitGetVirtualRegister(property, regT1);
495     emitGetVirtualRegister(value, regT2);
496     bool isDirect = m_interpreter->getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct;
497     Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, regT0, regT1, regT2, byValInfo);
498
499     m_byValCompilationInfo[m_byValInstructionIndex].slowPathTarget = slowPath;
500     m_byValCompilationInfo[m_byValInstructionIndex].returnAddress = call;
501     m_byValInstructionIndex++;
502 }
503
504 void JIT::emit_op_put_by_index(Instruction* currentInstruction)
505 {
506     emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
507     emitGetVirtualRegister(currentInstruction[3].u.operand, regT1);
508     callOperation(operationPutByIndex, regT0, currentInstruction[2].u.operand, regT1);
509 }
510
511 void JIT::emit_op_put_getter_by_id(Instruction* currentInstruction)
512 {
513     emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
514     int32_t options = currentInstruction[3].u.operand;
515     emitGetVirtualRegister(currentInstruction[4].u.operand, regT1);
516     callOperation(operationPutGetterById, regT0, &m_codeBlock->identifier(currentInstruction[2].u.operand), options, regT1);
517 }
518
519 void JIT::emit_op_put_setter_by_id(Instruction* currentInstruction)
520 {
521     emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
522     int32_t options = currentInstruction[3].u.operand;
523     emitGetVirtualRegister(currentInstruction[4].u.operand, regT1);
524     callOperation(operationPutSetterById, regT0, &m_codeBlock->identifier(currentInstruction[2].u.operand), options, regT1);
525 }
526
527 void JIT::emit_op_put_getter_setter(Instruction* currentInstruction)
528 {
529     emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
530     int32_t attribute = currentInstruction[3].u.operand;
531     emitGetVirtualRegister(currentInstruction[4].u.operand, regT1);
532     emitGetVirtualRegister(currentInstruction[5].u.operand, regT2);
533     callOperation(operationPutGetterSetter, regT0, &m_codeBlock->identifier(currentInstruction[2].u.operand), attribute, regT1, regT2);
534 }
535
536 void JIT::emit_op_del_by_id(Instruction* currentInstruction)
537 {
538     int dst = currentInstruction[1].u.operand;
539     int base = currentInstruction[2].u.operand;
540     int property = currentInstruction[3].u.operand;
541     emitGetVirtualRegister(base, regT0);
542     callOperation(operationDeleteById, dst, regT0, &m_codeBlock->identifier(property));
543 }
544
545 void JIT::emit_op_get_by_id(Instruction* currentInstruction)
546 {
547     int resultVReg = currentInstruction[1].u.operand;
548     int baseVReg = currentInstruction[2].u.operand;
549     const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[3].u.operand));
550
551     emitGetVirtualRegister(baseVReg, regT0);
552     
553     emitJumpSlowCaseIfNotJSCell(regT0, baseVReg);
554     
555     if (*ident == m_vm->propertyNames->length && shouldEmitProfiling())
556         emitArrayProfilingSiteForBytecodeIndexWithCell(regT0, regT1, m_bytecodeOffset);
557
558     JITGetByIdGenerator gen(
559         m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::specialRegisters(),
560         JSValueRegs(regT0), JSValueRegs(regT0), DontSpill);
561     gen.generateFastPath(*this);
562     addSlowCase(gen.slowPathJump());
563     m_getByIds.append(gen);
564
565     emitValueProfilingSite();
566     emitPutVirtualRegister(resultVReg);
567     assertStackPointerOffset();
568 }
569
570 void JIT::emitSlow_op_get_by_id(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
571 {
572     int resultVReg = currentInstruction[1].u.operand;
573     int baseVReg = currentInstruction[2].u.operand;
574     const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[3].u.operand));
575
576     linkSlowCaseIfNotJSCell(iter, baseVReg);
577     linkSlowCase(iter);
578
579     JITGetByIdGenerator& gen = m_getByIds[m_getByIdIndex++];
580     
581     Label coldPathBegin = label();
582     
583     Call call = callOperation(WithProfile, operationGetByIdOptimize, resultVReg, gen.stubInfo(), regT0, ident->impl());
584
585     gen.reportSlowPathCall(coldPathBegin, call);
586 }
587
588 void JIT::emit_op_put_by_id(Instruction* currentInstruction)
589 {
590     int baseVReg = currentInstruction[1].u.operand;
591     int valueVReg = currentInstruction[3].u.operand;
592     unsigned direct = currentInstruction[8].u.operand;
593
594     emitWriteBarrier(baseVReg, valueVReg, ShouldFilterBase);
595
596     // In order to be able to patch both the Structure, and the object offset, we store one pointer,
597     // to just after the arguments have been loaded into registers 'hotPathBegin', and we generate code
598     // such that the Structure & offset are always at the same distance from this.
599
600     emitGetVirtualRegisters(baseVReg, regT0, valueVReg, regT1);
601
602     // Jump to a slow case if either the base object is an immediate, or if the Structure does not match.
603     emitJumpSlowCaseIfNotJSCell(regT0, baseVReg);
604
605     JITPutByIdGenerator gen(
606         m_codeBlock, CodeOrigin(m_bytecodeOffset), CallSiteIndex(m_bytecodeOffset), RegisterSet::specialRegisters(),
607         JSValueRegs(regT0), JSValueRegs(regT1), regT2, DontSpill, m_codeBlock->ecmaMode(),
608         direct ? Direct : NotDirect);
609     
610     gen.generateFastPath(*this);
611     addSlowCase(gen.slowPathJump());
612     
613     m_putByIds.append(gen);
614 }
615
616 void JIT::emitSlow_op_put_by_id(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
617 {
618     int baseVReg = currentInstruction[1].u.operand;
619     const Identifier* ident = &(m_codeBlock->identifier(currentInstruction[2].u.operand));
620
621     linkSlowCaseIfNotJSCell(iter, baseVReg);
622     linkSlowCase(iter);
623
624     Label coldPathBegin(this);
625     
626     JITPutByIdGenerator& gen = m_putByIds[m_putByIdIndex++];
627
628     Call call = callOperation(
629         gen.slowPathFunction(), gen.stubInfo(), regT1, regT0, ident->impl());
630
631     gen.reportSlowPathCall(coldPathBegin, call);
632 }
633
634 // Compile a store into an object's property storage.  May overwrite the
635 // value in objectReg.
636 void JIT::compilePutDirectOffset(RegisterID base, RegisterID value, PropertyOffset cachedOffset)
637 {
638     if (isInlineOffset(cachedOffset)) {
639         store64(value, Address(base, JSObject::offsetOfInlineStorage() + sizeof(JSValue) * offsetInInlineStorage(cachedOffset)));
640         return;
641     }
642     
643     loadPtr(Address(base, JSObject::butterflyOffset()), base);
644     store64(value, Address(base, sizeof(JSValue) * offsetInButterfly(cachedOffset)));
645 }
646
647 // Compile a load from an object's property storage.  May overwrite base.
648 void JIT::compileGetDirectOffset(RegisterID base, RegisterID result, PropertyOffset cachedOffset)
649 {
650     if (isInlineOffset(cachedOffset)) {
651         load64(Address(base, JSObject::offsetOfInlineStorage() + sizeof(JSValue) * offsetInInlineStorage(cachedOffset)), result);
652         return;
653     }
654     
655     loadPtr(Address(base, JSObject::butterflyOffset()), result);
656     load64(Address(result, sizeof(JSValue) * offsetInButterfly(cachedOffset)), result);
657 }
658
659 void JIT::compileGetDirectOffset(JSObject* base, RegisterID result, PropertyOffset cachedOffset)
660 {
661     if (isInlineOffset(cachedOffset)) {
662         load64(base->locationForOffset(cachedOffset), result);
663         return;
664     }
665     
666     loadPtr(base->butterflyAddress(), result);
667     load64(Address(result, offsetInButterfly(cachedOffset) * sizeof(WriteBarrier<Unknown>)), result);
668 }
669
670 void JIT::emitVarInjectionCheck(bool needsVarInjectionChecks)
671 {
672     if (!needsVarInjectionChecks)
673         return;
674     addSlowCase(branch8(Equal, AbsoluteAddress(m_codeBlock->globalObject()->varInjectionWatchpoint()->addressOfState()), TrustedImm32(IsInvalidated)));
675 }
676
677 void JIT::emitResolveClosure(int dst, int scope, bool needsVarInjectionChecks, unsigned depth)
678 {
679     emitVarInjectionCheck(needsVarInjectionChecks);
680     emitGetVirtualRegister(scope, regT0);
681     for (unsigned i = 0; i < depth; ++i)
682         loadPtr(Address(regT0, JSScope::offsetOfNext()), regT0);
683     emitPutVirtualRegister(dst);
684 }
685
686 void JIT::emit_op_resolve_scope(Instruction* currentInstruction)
687 {
688     int dst = currentInstruction[1].u.operand;
689     int scope = currentInstruction[2].u.operand;
690     ResolveType resolveType = static_cast<ResolveType>(currentInstruction[4].u.operand);
691     unsigned depth = currentInstruction[5].u.operand;
692
693     switch (resolveType) {
694     case GlobalProperty:
695     case GlobalVar:
696     case GlobalPropertyWithVarInjectionChecks:
697     case GlobalVarWithVarInjectionChecks:
698     case GlobalLexicalVar:
699     case GlobalLexicalVarWithVarInjectionChecks: {
700         JSScope* constantScope = JSScope::constantScopeForCodeBlock(resolveType, m_codeBlock);
701         RELEASE_ASSERT(constantScope);
702         RELEASE_ASSERT(static_cast<JSScope*>(currentInstruction[6].u.pointer) == constantScope);
703         emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
704         move(TrustedImmPtr(constantScope), regT0);
705         emitPutVirtualRegister(dst);
706         break;
707     }
708     case ClosureVar:
709     case ClosureVarWithVarInjectionChecks:
710         emitResolveClosure(dst, scope, needsVarInjectionChecks(resolveType), depth);
711         break;
712     case ModuleVar:
713         move(TrustedImmPtr(currentInstruction[6].u.jsCell.get()), regT0);
714         emitPutVirtualRegister(dst);
715         break;
716     case UnresolvedProperty:
717     case UnresolvedPropertyWithVarInjectionChecks:
718     case Dynamic:
719         addSlowCase(jump());
720         break;
721     case LocalClosureVar:
722         RELEASE_ASSERT_NOT_REACHED();
723     }
724 }
725
726 void JIT::emitSlow_op_resolve_scope(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
727 {
728     ResolveType resolveType = static_cast<ResolveType>(currentInstruction[4].u.operand);
729     if (resolveType == GlobalProperty || resolveType == GlobalVar || resolveType == ClosureVar || resolveType == GlobalLexicalVar || resolveType == ModuleVar)
730         return;
731
732
733     linkSlowCase(iter);
734     JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_resolve_scope);
735     slowPathCall.call();
736 }
737
738 void JIT::emitLoadWithStructureCheck(int scope, Structure** structureSlot)
739 {
740     emitGetVirtualRegister(scope, regT0);
741     loadPtr(structureSlot, regT1);
742     addSlowCase(branchTestPtr(Zero, regT1));
743     load32(Address(regT1, Structure::structureIDOffset()), regT1);
744     addSlowCase(branch32(NotEqual, Address(regT0, JSCell::structureIDOffset()), regT1));
745 }
746
747 void JIT::emitGetGlobalProperty(uintptr_t* operandSlot)
748 {
749     load32(operandSlot, regT1);
750     compileGetDirectOffset(regT0, regT0, regT1, regT2, KnownNotFinal);
751 }
752
753 void JIT::emitGetVarFromPointer(uintptr_t operand, GPRReg reg)
754 {
755     loadPtr(reinterpret_cast<void*>(operand), reg);
756 }
757
758 void JIT::emitGetClosureVar(int scope, uintptr_t operand)
759 {
760     emitGetVirtualRegister(scope, regT0);
761     loadPtr(Address(regT0, JSEnvironmentRecord::offsetOfVariables() + operand * sizeof(Register)), regT0);
762 }
763
764 void JIT::emit_op_get_from_scope(Instruction* currentInstruction)
765 {
766     int dst = currentInstruction[1].u.operand;
767     int scope = currentInstruction[2].u.operand;
768     ResolveType resolveType = GetPutInfo(currentInstruction[4].u.operand).resolveType();
769     Structure** structureSlot = currentInstruction[5].u.structure.slot();
770     uintptr_t* operandSlot = reinterpret_cast<uintptr_t*>(&currentInstruction[6].u.pointer);
771
772     switch (resolveType) {
773     case GlobalProperty:
774     case GlobalPropertyWithVarInjectionChecks:
775         emitLoadWithStructureCheck(scope, structureSlot); // Structure check covers var injection.
776         emitGetGlobalProperty(operandSlot);
777         break;
778     case GlobalVar:
779     case GlobalVarWithVarInjectionChecks:
780     case GlobalLexicalVar:
781     case GlobalLexicalVarWithVarInjectionChecks:
782         emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
783         emitGetVarFromPointer(*operandSlot, regT0);
784         if (resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks) // TDZ check.
785             addSlowCase(branchTest64(Zero, regT0));
786         break;
787     case ClosureVar:
788     case ClosureVarWithVarInjectionChecks:
789         emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
790         emitGetClosureVar(scope, *operandSlot);
791         break;
792     case UnresolvedProperty:
793     case UnresolvedPropertyWithVarInjectionChecks:
794     case Dynamic:
795         addSlowCase(jump());
796         break;
797     case ModuleVar:
798     case LocalClosureVar:
799         RELEASE_ASSERT_NOT_REACHED();
800     }
801     emitPutVirtualRegister(dst);
802     emitValueProfilingSite();
803 }
804
805 void JIT::emitSlow_op_get_from_scope(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
806 {
807     int dst = currentInstruction[1].u.operand;
808     ResolveType resolveType = GetPutInfo(currentInstruction[4].u.operand).resolveType();
809
810     if (resolveType == GlobalVar || resolveType == ClosureVar)
811         return;
812
813     if (resolveType == GlobalProperty || resolveType == GlobalPropertyWithVarInjectionChecks)
814         linkSlowCase(iter);
815
816     if (resolveType == GlobalLexicalVarWithVarInjectionChecks) // Var injections check.
817         linkSlowCase(iter);
818
819     linkSlowCase(iter);
820
821     callOperation(WithProfile, operationGetFromScope, dst, currentInstruction);
822 }
823
824 void JIT::emitPutGlobalProperty(uintptr_t* operandSlot, int value)
825 {
826     emitGetVirtualRegister(value, regT2);
827
828     loadPtr(Address(regT0, JSObject::butterflyOffset()), regT0);
829     loadPtr(operandSlot, regT1);
830     negPtr(regT1);
831     storePtr(regT2, BaseIndex(regT0, regT1, TimesEight, (firstOutOfLineOffset - 2) * sizeof(EncodedJSValue)));
832 }
833
834 void JIT::emitPutGlobalVariable(uintptr_t operand, int value, WatchpointSet* set)
835 {
836     emitGetVirtualRegister(value, regT0);
837     emitNotifyWrite(set);
838     storePtr(regT0, reinterpret_cast<void*>(operand));
839 }
840
841 void JIT::emitPutClosureVar(int scope, uintptr_t operand, int value, WatchpointSet* set)
842 {
843     emitGetVirtualRegister(value, regT1);
844     emitGetVirtualRegister(scope, regT0);
845     emitNotifyWrite(set);
846     storePtr(regT1, Address(regT0, JSEnvironmentRecord::offsetOfVariables() + operand * sizeof(Register)));
847 }
848
849 void JIT::emit_op_put_to_scope(Instruction* currentInstruction)
850 {
851     int scope = currentInstruction[1].u.operand;
852     int value = currentInstruction[3].u.operand;
853     GetPutInfo getPutInfo = GetPutInfo(currentInstruction[4].u.operand);
854     ResolveType resolveType = getPutInfo.resolveType();
855     Structure** structureSlot = currentInstruction[5].u.structure.slot();
856     uintptr_t* operandSlot = reinterpret_cast<uintptr_t*>(&currentInstruction[6].u.pointer);
857
858     switch (resolveType) {
859     case GlobalProperty:
860     case GlobalPropertyWithVarInjectionChecks:
861         emitWriteBarrier(m_codeBlock->globalObject(), value, ShouldFilterValue);
862         emitLoadWithStructureCheck(scope, structureSlot); // Structure check covers var injection.
863         emitPutGlobalProperty(operandSlot, value);
864         break;
865     case GlobalVar:
866     case GlobalVarWithVarInjectionChecks:
867     case GlobalLexicalVar:
868     case GlobalLexicalVarWithVarInjectionChecks: {
869         JSScope* constantScope = JSScope::constantScopeForCodeBlock(resolveType, m_codeBlock);
870         RELEASE_ASSERT(constantScope);
871         emitWriteBarrier(constantScope, value, ShouldFilterValue);
872         emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
873         if (getPutInfo.initializationMode() != Initialization && (resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks)) {
874             // We need to do a TDZ check here because we can't always prove we need to emit TDZ checks statically.
875             emitGetVarFromPointer(*operandSlot, regT0);
876             addSlowCase(branchTest64(Zero, regT0));
877         }
878
879         emitPutGlobalVariable(*operandSlot, value, currentInstruction[5].u.watchpointSet);
880         break;
881     }
882     case LocalClosureVar:
883     case ClosureVar:
884     case ClosureVarWithVarInjectionChecks:
885         emitWriteBarrier(scope, value, ShouldFilterValue);
886         emitVarInjectionCheck(needsVarInjectionChecks(resolveType));
887         emitPutClosureVar(scope, *operandSlot, value, currentInstruction[5].u.watchpointSet);
888         break;
889     case UnresolvedProperty:
890     case UnresolvedPropertyWithVarInjectionChecks:
891     case ModuleVar:
892     case Dynamic:
893         addSlowCase(jump());
894         break;
895     }
896 }
897
898 void JIT::emitSlow_op_put_to_scope(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
899 {
900     GetPutInfo getPutInfo = GetPutInfo(currentInstruction[4].u.operand);
901     ResolveType resolveType = getPutInfo.resolveType();
902     unsigned linkCount = 0;
903     if (resolveType != GlobalVar && resolveType != ClosureVar && resolveType != LocalClosureVar && resolveType != GlobalLexicalVar)
904         linkCount++;
905     if ((resolveType == GlobalVar || resolveType == GlobalVarWithVarInjectionChecks 
906          || resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks 
907          || resolveType == LocalClosureVar)
908         && currentInstruction[5].u.watchpointSet->state() != IsInvalidated)
909         linkCount++;
910     if (resolveType == GlobalProperty || resolveType == GlobalPropertyWithVarInjectionChecks)
911         linkCount++;
912     if (getPutInfo.initializationMode() != Initialization && (resolveType == GlobalLexicalVar || resolveType == GlobalLexicalVarWithVarInjectionChecks)) // TDZ check.
913         linkCount++;
914     if (!linkCount)
915         return;
916     while (linkCount--)
917         linkSlowCase(iter);
918
919     if (resolveType == ModuleVar) {
920         JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_throw_strict_mode_readonly_property_write_error);
921         slowPathCall.call();
922     } else
923         callOperation(operationPutToScope, currentInstruction);
924 }
925
926 void JIT::emit_op_get_from_arguments(Instruction* currentInstruction)
927 {
928     int dst = currentInstruction[1].u.operand;
929     int arguments = currentInstruction[2].u.operand;
930     int index = currentInstruction[3].u.operand;
931     
932     emitGetVirtualRegister(arguments, regT0);
933     load64(Address(regT0, DirectArguments::storageOffset() + index * sizeof(WriteBarrier<Unknown>)), regT0);
934     emitValueProfilingSite();
935     emitPutVirtualRegister(dst);
936 }
937
938 void JIT::emit_op_put_to_arguments(Instruction* currentInstruction)
939 {
940     int arguments = currentInstruction[1].u.operand;
941     int index = currentInstruction[2].u.operand;
942     int value = currentInstruction[3].u.operand;
943     
944     emitWriteBarrier(arguments, value, ShouldFilterValue);
945     
946     emitGetVirtualRegister(arguments, regT0);
947     emitGetVirtualRegister(value, regT1);
948     store64(regT1, Address(regT0, DirectArguments::storageOffset() + index * sizeof(WriteBarrier<Unknown>)));
949 }
950
951 #endif // USE(JSVALUE64)
952
953 #if USE(JSVALUE64)
954 void JIT::emitWriteBarrier(unsigned owner, unsigned value, WriteBarrierMode mode)
955 {
956 #if ENABLE(GGC)
957     Jump valueNotCell;
958     if (mode == ShouldFilterValue || mode == ShouldFilterBaseAndValue) {
959         emitGetVirtualRegister(value, regT0);
960         valueNotCell = branchTest64(NonZero, regT0, tagMaskRegister);
961     }
962     
963     emitGetVirtualRegister(owner, regT0);
964     Jump ownerNotCell;
965     if (mode == ShouldFilterBaseAndValue || mode == ShouldFilterBase)
966         ownerNotCell = branchTest64(NonZero, regT0, tagMaskRegister);
967
968     Jump ownerIsRememberedOrInEden = jumpIfIsRememberedOrInEden(regT0);
969     callOperation(operationUnconditionalWriteBarrier, regT0);
970     ownerIsRememberedOrInEden.link(this);
971
972     if (mode == ShouldFilterBaseAndValue || mode == ShouldFilterBase)
973         ownerNotCell.link(this);
974     if (mode == ShouldFilterValue || mode == ShouldFilterBaseAndValue) 
975         valueNotCell.link(this);
976 #else
977     UNUSED_PARAM(owner);
978     UNUSED_PARAM(value);
979     UNUSED_PARAM(mode);
980 #endif
981 }
982
983 void JIT::emitWriteBarrier(JSCell* owner, unsigned value, WriteBarrierMode mode)
984 {
985 #if ENABLE(GGC)
986     emitGetVirtualRegister(value, regT0);
987     Jump valueNotCell;
988     if (mode == ShouldFilterValue)
989         valueNotCell = branchTest64(NonZero, regT0, tagMaskRegister);
990
991     emitWriteBarrier(owner);
992
993     if (mode == ShouldFilterValue) 
994         valueNotCell.link(this);
995 #else
996     UNUSED_PARAM(owner);
997     UNUSED_PARAM(value);
998     UNUSED_PARAM(mode);
999 #endif
1000 }
1001
1002 #else // USE(JSVALUE64)
1003
1004 void JIT::emitWriteBarrier(unsigned owner, unsigned value, WriteBarrierMode mode)
1005 {
1006 #if ENABLE(GGC)
1007     Jump valueNotCell;
1008     if (mode == ShouldFilterValue || mode == ShouldFilterBaseAndValue) {
1009         emitLoadTag(value, regT0);
1010         valueNotCell = branch32(NotEqual, regT0, TrustedImm32(JSValue::CellTag));
1011     }
1012     
1013     emitLoad(owner, regT0, regT1);
1014     Jump ownerNotCell;
1015     if (mode == ShouldFilterBase || mode == ShouldFilterBaseAndValue)
1016         ownerNotCell = branch32(NotEqual, regT0, TrustedImm32(JSValue::CellTag));
1017
1018     Jump ownerIsRememberedOrInEden = jumpIfIsRememberedOrInEden(regT1);
1019     callOperation(operationUnconditionalWriteBarrier, regT1);
1020     ownerIsRememberedOrInEden.link(this);
1021
1022     if (mode == ShouldFilterBase || mode == ShouldFilterBaseAndValue)
1023         ownerNotCell.link(this);
1024     if (mode == ShouldFilterValue || mode == ShouldFilterBaseAndValue) 
1025         valueNotCell.link(this);
1026 #else
1027     UNUSED_PARAM(owner);
1028     UNUSED_PARAM(value);
1029     UNUSED_PARAM(mode);
1030 #endif
1031 }
1032
1033 void JIT::emitWriteBarrier(JSCell* owner, unsigned value, WriteBarrierMode mode)
1034 {
1035 #if ENABLE(GGC)
1036     Jump valueNotCell;
1037     if (mode == ShouldFilterValue) {
1038         emitLoadTag(value, regT0);
1039         valueNotCell = branch32(NotEqual, regT0, TrustedImm32(JSValue::CellTag));
1040     }
1041
1042     emitWriteBarrier(owner);
1043
1044     if (mode == ShouldFilterValue) 
1045         valueNotCell.link(this);
1046 #else
1047     UNUSED_PARAM(owner);
1048     UNUSED_PARAM(value);
1049     UNUSED_PARAM(mode);
1050 #endif
1051 }
1052
1053 #endif // USE(JSVALUE64)
1054
1055 void JIT::emitWriteBarrier(JSCell* owner)
1056 {
1057 #if ENABLE(GGC)
1058     if (!MarkedBlock::blockFor(owner)->isMarked(owner)) {
1059         Jump ownerIsRememberedOrInEden = jumpIfIsRememberedOrInEden(owner);
1060         callOperation(operationUnconditionalWriteBarrier, owner);
1061         ownerIsRememberedOrInEden.link(this);
1062     } else
1063         callOperation(operationUnconditionalWriteBarrier, owner);
1064 #else
1065     UNUSED_PARAM(owner);
1066 #endif // ENABLE(GGC)
1067 }
1068
1069 void JIT::emitIdentifierCheck(RegisterID cell, RegisterID scratch, const Identifier& propertyName, JumpList& slowCases)
1070 {
1071     if (propertyName.isSymbol()) {
1072         slowCases.append(branchStructure(NotEqual, Address(cell, JSCell::structureIDOffset()), m_vm->symbolStructure.get()));
1073         loadPtr(Address(cell, Symbol::offsetOfPrivateName()), scratch);
1074     } else {
1075         slowCases.append(branchStructure(NotEqual, Address(cell, JSCell::structureIDOffset()), m_vm->stringStructure.get()));
1076         loadPtr(Address(cell, JSString::offsetOfValue()), scratch);
1077     }
1078     slowCases.append(branchPtr(NotEqual, scratch, TrustedImmPtr(propertyName.impl())));
1079 }
1080
1081 void JIT::privateCompileGetByVal(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
1082 {
1083     Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
1084     
1085     PatchableJump badType;
1086     JumpList slowCases;
1087     
1088     switch (arrayMode) {
1089     case JITInt32:
1090         slowCases = emitInt32GetByVal(currentInstruction, badType);
1091         break;
1092     case JITDouble:
1093         slowCases = emitDoubleGetByVal(currentInstruction, badType);
1094         break;
1095     case JITContiguous:
1096         slowCases = emitContiguousGetByVal(currentInstruction, badType);
1097         break;
1098     case JITArrayStorage:
1099         slowCases = emitArrayStorageGetByVal(currentInstruction, badType);
1100         break;
1101     case JITDirectArguments:
1102         slowCases = emitDirectArgumentsGetByVal(currentInstruction, badType);
1103         break;
1104     case JITScopedArguments:
1105         slowCases = emitScopedArgumentsGetByVal(currentInstruction, badType);
1106         break;
1107     default:
1108         TypedArrayType type = typedArrayTypeForJITArrayMode(arrayMode);
1109         if (isInt(type))
1110             slowCases = emitIntTypedArrayGetByVal(currentInstruction, badType, type);
1111         else 
1112             slowCases = emitFloatTypedArrayGetByVal(currentInstruction, badType, type);
1113         break;
1114     }
1115     
1116     Jump done = jump();
1117
1118     LinkBuffer patchBuffer(*m_vm, *this, m_codeBlock);
1119     
1120     patchBuffer.link(badType, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1121     patchBuffer.link(slowCases, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1122     
1123     patchBuffer.link(done, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
1124     
1125     byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
1126         m_codeBlock, patchBuffer,
1127         ("Baseline get_by_val stub for %s, return point %p", toCString(*m_codeBlock).data(), returnAddress.value()));
1128     
1129     MacroAssembler::repatchJump(byValInfo->badTypeJump, CodeLocationLabel(byValInfo->stubRoutine->code().code()));
1130     MacroAssembler::repatchCall(CodeLocationCall(MacroAssemblerCodePtr(returnAddress)), FunctionPtr(operationGetByValGeneric));
1131 }
1132
1133 void JIT::privateCompileGetByValWithCachedId(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, const Identifier& propertyName)
1134 {
1135     Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
1136
1137     Jump fastDoneCase;
1138     Jump slowDoneCase;
1139     JumpList slowCases;
1140
1141     JITGetByIdGenerator gen = emitGetByValWithCachedId(currentInstruction, propertyName, fastDoneCase, slowDoneCase, slowCases);
1142
1143     ConcurrentJITLocker locker(m_codeBlock->m_lock);
1144     LinkBuffer patchBuffer(*m_vm, *this, m_codeBlock);
1145     patchBuffer.link(slowCases, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1146     patchBuffer.link(fastDoneCase, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
1147     patchBuffer.link(slowDoneCase, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToNextHotPath));
1148
1149     for (const auto& callSite : m_calls) {
1150         if (callSite.to)
1151             patchBuffer.link(callSite.from, FunctionPtr(callSite.to));
1152     }
1153     gen.finalize(patchBuffer);
1154
1155     byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
1156         m_codeBlock, patchBuffer,
1157         ("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()));
1158     byValInfo->stubInfo = gen.stubInfo();
1159
1160     MacroAssembler::repatchJump(byValInfo->notIndexJump, CodeLocationLabel(byValInfo->stubRoutine->code().code()));
1161     MacroAssembler::repatchCall(CodeLocationCall(MacroAssemblerCodePtr(returnAddress)), FunctionPtr(operationGetByValGeneric));
1162 }
1163
1164 void JIT::privateCompilePutByVal(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
1165 {
1166     Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
1167     
1168     PatchableJump badType;
1169     JumpList slowCases;
1170
1171 #if ENABLE(GGC)
1172     bool needsLinkForWriteBarrier = false;
1173 #endif
1174
1175     switch (arrayMode) {
1176     case JITInt32:
1177         slowCases = emitInt32PutByVal(currentInstruction, badType);
1178         break;
1179     case JITDouble:
1180         slowCases = emitDoublePutByVal(currentInstruction, badType);
1181         break;
1182     case JITContiguous:
1183         slowCases = emitContiguousPutByVal(currentInstruction, badType);
1184 #if ENABLE(GGC)
1185         needsLinkForWriteBarrier = true;
1186 #endif
1187         break;
1188     case JITArrayStorage:
1189         slowCases = emitArrayStoragePutByVal(currentInstruction, badType);
1190 #if ENABLE(GGC)
1191         needsLinkForWriteBarrier = true;
1192 #endif
1193         break;
1194     default:
1195         TypedArrayType type = typedArrayTypeForJITArrayMode(arrayMode);
1196         if (isInt(type))
1197             slowCases = emitIntTypedArrayPutByVal(currentInstruction, badType, type);
1198         else 
1199             slowCases = emitFloatTypedArrayPutByVal(currentInstruction, badType, type);
1200         break;
1201     }
1202     
1203     Jump done = jump();
1204
1205     LinkBuffer patchBuffer(*m_vm, *this, m_codeBlock);
1206     patchBuffer.link(badType, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1207     patchBuffer.link(slowCases, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1208     patchBuffer.link(done, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
1209 #if ENABLE(GGC)
1210     if (needsLinkForWriteBarrier) {
1211         ASSERT(m_calls.last().to == operationUnconditionalWriteBarrier);
1212         patchBuffer.link(m_calls.last().from, operationUnconditionalWriteBarrier);
1213     }
1214 #endif
1215     
1216     bool isDirect = m_interpreter->getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct;
1217     if (!isDirect) {
1218         byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
1219             m_codeBlock, patchBuffer,
1220             ("Baseline put_by_val stub for %s, return point %p", toCString(*m_codeBlock).data(), returnAddress.value()));
1221         
1222     } else {
1223         byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
1224             m_codeBlock, patchBuffer,
1225             ("Baseline put_by_val_direct stub for %s, return point %p", toCString(*m_codeBlock).data(), returnAddress.value()));
1226     }
1227     MacroAssembler::repatchJump(byValInfo->badTypeJump, CodeLocationLabel(byValInfo->stubRoutine->code().code()));
1228     MacroAssembler::repatchCall(CodeLocationCall(MacroAssemblerCodePtr(returnAddress)), FunctionPtr(isDirect ? operationDirectPutByValGeneric : operationPutByValGeneric));
1229 }
1230
1231 void JIT::privateCompilePutByValWithCachedId(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, PutKind putKind, const Identifier& propertyName)
1232 {
1233     Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
1234
1235     JumpList doneCases;
1236     JumpList slowCases;
1237
1238     JITPutByIdGenerator gen = emitPutByValWithCachedId(currentInstruction, putKind, propertyName, doneCases, slowCases);
1239
1240     ConcurrentJITLocker locker(m_codeBlock->m_lock);
1241     LinkBuffer patchBuffer(*m_vm, *this, m_codeBlock);
1242     patchBuffer.link(slowCases, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
1243     patchBuffer.link(doneCases, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
1244     for (const auto& callSite : m_calls) {
1245         if (callSite.to)
1246             patchBuffer.link(callSite.from, FunctionPtr(callSite.to));
1247     }
1248     gen.finalize(patchBuffer);
1249
1250     byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
1251         m_codeBlock, patchBuffer,
1252         ("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()));
1253     byValInfo->stubInfo = gen.stubInfo();
1254
1255     MacroAssembler::repatchJump(byValInfo->notIndexJump, CodeLocationLabel(byValInfo->stubRoutine->code().code()));
1256     MacroAssembler::repatchCall(CodeLocationCall(MacroAssemblerCodePtr(returnAddress)), FunctionPtr(putKind == Direct ? operationDirectPutByValGeneric : operationPutByValGeneric));
1257 }
1258
1259
1260 JIT::JumpList JIT::emitDirectArgumentsGetByVal(Instruction*, PatchableJump& badType)
1261 {
1262     JumpList slowCases;
1263     
1264 #if USE(JSVALUE64)
1265     RegisterID base = regT0;
1266     RegisterID property = regT1;
1267     JSValueRegs result = JSValueRegs(regT0);
1268     RegisterID scratch = regT3;
1269 #else
1270     RegisterID base = regT0;
1271     RegisterID property = regT2;
1272     JSValueRegs result = JSValueRegs(regT1, regT0);
1273     RegisterID scratch = regT3;
1274 #endif
1275
1276     load8(Address(base, JSCell::typeInfoTypeOffset()), scratch);
1277     badType = patchableBranch32(NotEqual, scratch, TrustedImm32(DirectArgumentsType));
1278     
1279     slowCases.append(branch32(AboveOrEqual, property, Address(base, DirectArguments::offsetOfLength())));
1280     slowCases.append(branchTestPtr(NonZero, Address(base, DirectArguments::offsetOfOverrides())));
1281     
1282     zeroExtend32ToPtr(property, scratch);
1283     loadValue(BaseIndex(base, scratch, TimesEight, DirectArguments::storageOffset()), result);
1284     
1285     return slowCases;
1286 }
1287
1288 JIT::JumpList JIT::emitScopedArgumentsGetByVal(Instruction*, PatchableJump& badType)
1289 {
1290     JumpList slowCases;
1291     
1292 #if USE(JSVALUE64)
1293     RegisterID base = regT0;
1294     RegisterID property = regT1;
1295     JSValueRegs result = JSValueRegs(regT0);
1296     RegisterID scratch = regT3;
1297     RegisterID scratch2 = regT4;
1298 #else
1299     RegisterID base = regT0;
1300     RegisterID property = regT2;
1301     JSValueRegs result = JSValueRegs(regT1, regT0);
1302     RegisterID scratch = regT3;
1303     RegisterID scratch2 = regT4;
1304 #endif
1305
1306     load8(Address(base, JSCell::typeInfoTypeOffset()), scratch);
1307     badType = patchableBranch32(NotEqual, scratch, TrustedImm32(ScopedArgumentsType));
1308     slowCases.append(branch32(AboveOrEqual, property, Address(base, ScopedArguments::offsetOfTotalLength())));
1309     
1310     loadPtr(Address(base, ScopedArguments::offsetOfTable()), scratch);
1311     load32(Address(scratch, ScopedArgumentsTable::offsetOfLength()), scratch2);
1312     Jump overflowCase = branch32(AboveOrEqual, property, scratch2);
1313     loadPtr(Address(base, ScopedArguments::offsetOfScope()), scratch2);
1314     loadPtr(Address(scratch, ScopedArgumentsTable::offsetOfArguments()), scratch);
1315     load32(BaseIndex(scratch, property, TimesFour), scratch);
1316     slowCases.append(branch32(Equal, scratch, TrustedImm32(ScopeOffset::invalidOffset)));
1317     loadValue(BaseIndex(scratch2, scratch, TimesEight, JSEnvironmentRecord::offsetOfVariables()), result);
1318     Jump done = jump();
1319     overflowCase.link(this);
1320     sub32(property, scratch2);
1321     neg32(scratch2);
1322     loadValue(BaseIndex(base, scratch2, TimesEight, ScopedArguments::overflowStorageOffset()), result);
1323     slowCases.append(branchIfEmpty(result));
1324     done.link(this);
1325     
1326     return slowCases;
1327 }
1328
1329 JIT::JumpList JIT::emitIntTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType type)
1330 {
1331     ASSERT(isInt(type));
1332     
1333     // The best way to test the array type is to use the classInfo. We need to do so without
1334     // clobbering the register that holds the indexing type, base, and property.
1335
1336 #if USE(JSVALUE64)
1337     RegisterID base = regT0;
1338     RegisterID property = regT1;
1339     RegisterID resultPayload = regT0;
1340     RegisterID scratch = regT3;
1341 #else
1342     RegisterID base = regT0;
1343     RegisterID property = regT2;
1344     RegisterID resultPayload = regT0;
1345     RegisterID resultTag = regT1;
1346     RegisterID scratch = regT3;
1347 #endif
1348     
1349     JumpList slowCases;
1350     
1351     load8(Address(base, JSCell::typeInfoTypeOffset()), scratch);
1352     badType = patchableBranch32(NotEqual, scratch, TrustedImm32(typeForTypedArrayType(type)));
1353     slowCases.append(branch32(AboveOrEqual, property, Address(base, JSArrayBufferView::offsetOfLength())));
1354     loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), base);
1355     
1356     switch (elementSize(type)) {
1357     case 1:
1358         if (isSigned(type))
1359             load8SignedExtendTo32(BaseIndex(base, property, TimesOne), resultPayload);
1360         else
1361             load8(BaseIndex(base, property, TimesOne), resultPayload);
1362         break;
1363     case 2:
1364         if (isSigned(type))
1365             load16SignedExtendTo32(BaseIndex(base, property, TimesTwo), resultPayload);
1366         else
1367             load16(BaseIndex(base, property, TimesTwo), resultPayload);
1368         break;
1369     case 4:
1370         load32(BaseIndex(base, property, TimesFour), resultPayload);
1371         break;
1372     default:
1373         CRASH();
1374     }
1375     
1376     Jump done;
1377     if (type == TypeUint32) {
1378         Jump canBeInt = branch32(GreaterThanOrEqual, resultPayload, TrustedImm32(0));
1379         
1380         convertInt32ToDouble(resultPayload, fpRegT0);
1381         addDouble(AbsoluteAddress(&twoToThe32), fpRegT0);
1382 #if USE(JSVALUE64)
1383         moveDoubleTo64(fpRegT0, resultPayload);
1384         sub64(tagTypeNumberRegister, resultPayload);
1385 #else
1386         moveDoubleToInts(fpRegT0, resultPayload, resultTag);
1387 #endif
1388         
1389         done = jump();
1390         canBeInt.link(this);
1391     }
1392
1393 #if USE(JSVALUE64)
1394     or64(tagTypeNumberRegister, resultPayload);
1395 #else
1396     move(TrustedImm32(JSValue::Int32Tag), resultTag);
1397 #endif
1398     if (done.isSet())
1399         done.link(this);
1400     return slowCases;
1401 }
1402
1403 JIT::JumpList JIT::emitFloatTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType type)
1404 {
1405     ASSERT(isFloat(type));
1406     
1407 #if USE(JSVALUE64)
1408     RegisterID base = regT0;
1409     RegisterID property = regT1;
1410     RegisterID resultPayload = regT0;
1411     RegisterID scratch = regT3;
1412 #else
1413     RegisterID base = regT0;
1414     RegisterID property = regT2;
1415     RegisterID resultPayload = regT0;
1416     RegisterID resultTag = regT1;
1417     RegisterID scratch = regT3;
1418 #endif
1419     
1420     JumpList slowCases;
1421
1422     load8(Address(base, JSCell::typeInfoTypeOffset()), scratch);
1423     badType = patchableBranch32(NotEqual, scratch, TrustedImm32(typeForTypedArrayType(type)));
1424     slowCases.append(branch32(AboveOrEqual, property, Address(base, JSArrayBufferView::offsetOfLength())));
1425     loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), base);
1426     
1427     switch (elementSize(type)) {
1428     case 4:
1429         loadFloat(BaseIndex(base, property, TimesFour), fpRegT0);
1430         convertFloatToDouble(fpRegT0, fpRegT0);
1431         break;
1432     case 8: {
1433         loadDouble(BaseIndex(base, property, TimesEight), fpRegT0);
1434         break;
1435     }
1436     default:
1437         CRASH();
1438     }
1439     
1440     Jump notNaN = branchDouble(DoubleEqual, fpRegT0, fpRegT0);
1441     static const double NaN = PNaN;
1442     loadDouble(TrustedImmPtr(&NaN), fpRegT0);
1443     notNaN.link(this);
1444     
1445 #if USE(JSVALUE64)
1446     moveDoubleTo64(fpRegT0, resultPayload);
1447     sub64(tagTypeNumberRegister, resultPayload);
1448 #else
1449     moveDoubleToInts(fpRegT0, resultPayload, resultTag);
1450 #endif
1451     return slowCases;    
1452 }
1453
1454 JIT::JumpList JIT::emitIntTypedArrayPutByVal(Instruction* currentInstruction, PatchableJump& badType, TypedArrayType type)
1455 {
1456     ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
1457     ASSERT(isInt(type));
1458     
1459     int value = currentInstruction[3].u.operand;
1460
1461 #if USE(JSVALUE64)
1462     RegisterID base = regT0;
1463     RegisterID property = regT1;
1464     RegisterID earlyScratch = regT3;
1465     RegisterID lateScratch = regT2;
1466 #else
1467     RegisterID base = regT0;
1468     RegisterID property = regT2;
1469     RegisterID earlyScratch = regT3;
1470     RegisterID lateScratch = regT1;
1471 #endif
1472     
1473     JumpList slowCases;
1474     
1475     load8(Address(base, JSCell::typeInfoTypeOffset()), earlyScratch);
1476     badType = patchableBranch32(NotEqual, earlyScratch, TrustedImm32(typeForTypedArrayType(type)));
1477     Jump inBounds = branch32(Below, property, Address(base, JSArrayBufferView::offsetOfLength()));
1478     emitArrayProfileOutOfBoundsSpecialCase(profile);
1479     Jump done = jump();
1480     inBounds.link(this);
1481     
1482 #if USE(JSVALUE64)
1483     emitGetVirtualRegister(value, earlyScratch);
1484     slowCases.append(emitJumpIfNotImmediateInteger(earlyScratch));
1485 #else
1486     emitLoad(value, lateScratch, earlyScratch);
1487     slowCases.append(branch32(NotEqual, lateScratch, TrustedImm32(JSValue::Int32Tag)));
1488 #endif
1489     
1490     // We would be loading this into base as in get_by_val, except that the slow
1491     // path expects the base to be unclobbered.
1492     loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), lateScratch);
1493     
1494     if (isClamped(type)) {
1495         ASSERT(elementSize(type) == 1);
1496         ASSERT(!isSigned(type));
1497         Jump inBounds = branch32(BelowOrEqual, earlyScratch, TrustedImm32(0xff));
1498         Jump tooBig = branch32(GreaterThan, earlyScratch, TrustedImm32(0xff));
1499         xor32(earlyScratch, earlyScratch);
1500         Jump clamped = jump();
1501         tooBig.link(this);
1502         move(TrustedImm32(0xff), earlyScratch);
1503         clamped.link(this);
1504         inBounds.link(this);
1505     }
1506     
1507     switch (elementSize(type)) {
1508     case 1:
1509         store8(earlyScratch, BaseIndex(lateScratch, property, TimesOne));
1510         break;
1511     case 2:
1512         store16(earlyScratch, BaseIndex(lateScratch, property, TimesTwo));
1513         break;
1514     case 4:
1515         store32(earlyScratch, BaseIndex(lateScratch, property, TimesFour));
1516         break;
1517     default:
1518         CRASH();
1519     }
1520     
1521     done.link(this);
1522     
1523     return slowCases;
1524 }
1525
1526 JIT::JumpList JIT::emitFloatTypedArrayPutByVal(Instruction* currentInstruction, PatchableJump& badType, TypedArrayType type)
1527 {
1528     ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
1529     ASSERT(isFloat(type));
1530     
1531     int value = currentInstruction[3].u.operand;
1532
1533 #if USE(JSVALUE64)
1534     RegisterID base = regT0;
1535     RegisterID property = regT1;
1536     RegisterID earlyScratch = regT3;
1537     RegisterID lateScratch = regT2;
1538 #else
1539     RegisterID base = regT0;
1540     RegisterID property = regT2;
1541     RegisterID earlyScratch = regT3;
1542     RegisterID lateScratch = regT1;
1543 #endif
1544     
1545     JumpList slowCases;
1546     
1547     load8(Address(base, JSCell::typeInfoTypeOffset()), earlyScratch);
1548     badType = patchableBranch32(NotEqual, earlyScratch, TrustedImm32(typeForTypedArrayType(type)));
1549     Jump inBounds = branch32(Below, property, Address(base, JSArrayBufferView::offsetOfLength()));
1550     emitArrayProfileOutOfBoundsSpecialCase(profile);
1551     Jump done = jump();
1552     inBounds.link(this);
1553     
1554 #if USE(JSVALUE64)
1555     emitGetVirtualRegister(value, earlyScratch);
1556     Jump doubleCase = emitJumpIfNotImmediateInteger(earlyScratch);
1557     convertInt32ToDouble(earlyScratch, fpRegT0);
1558     Jump ready = jump();
1559     doubleCase.link(this);
1560     slowCases.append(emitJumpIfNotImmediateNumber(earlyScratch));
1561     add64(tagTypeNumberRegister, earlyScratch);
1562     move64ToDouble(earlyScratch, fpRegT0);
1563     ready.link(this);
1564 #else
1565     emitLoad(value, lateScratch, earlyScratch);
1566     Jump doubleCase = branch32(NotEqual, lateScratch, TrustedImm32(JSValue::Int32Tag));
1567     convertInt32ToDouble(earlyScratch, fpRegT0);
1568     Jump ready = jump();
1569     doubleCase.link(this);
1570     slowCases.append(branch32(Above, lateScratch, TrustedImm32(JSValue::LowestTag)));
1571     moveIntsToDouble(earlyScratch, lateScratch, fpRegT0, fpRegT1);
1572     ready.link(this);
1573 #endif
1574     
1575     // We would be loading this into base as in get_by_val, except that the slow
1576     // path expects the base to be unclobbered.
1577     loadPtr(Address(base, JSArrayBufferView::offsetOfVector()), lateScratch);
1578     
1579     switch (elementSize(type)) {
1580     case 4:
1581         convertDoubleToFloat(fpRegT0, fpRegT0);
1582         storeFloat(fpRegT0, BaseIndex(lateScratch, property, TimesFour));
1583         break;
1584     case 8:
1585         storeDouble(fpRegT0, BaseIndex(lateScratch, property, TimesEight));
1586         break;
1587     default:
1588         CRASH();
1589     }
1590     
1591     done.link(this);
1592     
1593     return slowCases;
1594 }
1595
1596 } // namespace JSC
1597
1598 #endif // ENABLE(JIT)