JITPropertyAccess.cpp 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796
  1. /*
  2. * Copyright (C) 2008, 2009 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. #include "config.h"
  26. #if ENABLE(JIT)
  27. #if !(ENABLE(DETACHED_JIT) && !BUILDING_DETACHED_JIT)
  28. #include "JIT.h"
  29. #include "CodeBlock.h"
  30. #include "GCAwareJITStubRoutine.h"
  31. #include "GetterSetter.h"
  32. #include "Interpreter.h"
  33. #include "JITInlines.h"
  34. #include "JITStubCall.h"
  35. #include "JITStubEntries.h"
  36. #include "JSArray.h"
  37. #include "JSFunction.h"
  38. #include "JSPropertyNameIterator.h"
  39. #include "JSVariableObject.h"
  40. #include "LinkBuffer.h"
  41. #include "RepatchBuffer.h"
  42. #include "ResultType.h"
  43. #include "SamplingTool.h"
  44. #include <wtf/StringPrintStream.h>
  45. #ifndef NDEBUG
  46. #include <stdio.h>
  47. #endif
  48. using namespace std;
  49. namespace JSC {
  50. #if USE(JSVALUE64)
  51. JIT::CodeRef JIT::stringGetByValStubGenerator(VM* vm)
  52. {
  53. JSInterfaceJIT jit;
  54. JumpList failures;
  55. failures.append(jit.branchPtr(NotEqual, Address(regT0, JSCell::structureOffset()), TrustedImmPtr(vm->stringStructure.get())));
  56. // Load string length to regT2, and start the process of loading the data pointer into regT0
  57. jit.load32(Address(regT0, ThunkHelpers::jsStringLengthOffset()), regT2);
  58. jit.loadPtr(Address(regT0, ThunkHelpers::jsStringValueOffset()), regT0);
  59. failures.append(jit.branchTest32(Zero, regT0));
  60. // Do an unsigned compare to simultaneously filter negative indices as well as indices that are too large
  61. failures.append(jit.branch32(AboveOrEqual, regT1, regT2));
  62. // Load the character
  63. JumpList is16Bit;
  64. JumpList cont8Bit;
  65. // Load the string flags
  66. jit.loadPtr(Address(regT0, StringImpl::flagsOffset()), regT2);
  67. jit.loadPtr(Address(regT0, StringImpl::dataOffset()), regT0);
  68. is16Bit.append(jit.branchTest32(Zero, regT2, TrustedImm32(StringImpl::flagIs8Bit())));
  69. jit.load8(BaseIndex(regT0, regT1, TimesOne, 0), regT0);
  70. cont8Bit.append(jit.jump());
  71. is16Bit.link(&jit);
  72. jit.load16(BaseIndex(regT0, regT1, TimesTwo, 0), regT0);
  73. cont8Bit.link(&jit);
  74. failures.append(jit.branch32(AboveOrEqual, regT0, TrustedImm32(0x100)));
  75. jit.move(TrustedImmPtr(vm->smallStrings.singleCharacterStrings()), regT1);
  76. jit.loadPtr(BaseIndex(regT1, regT0, ScalePtr, 0), regT0);
  77. jit.ret();
  78. failures.link(&jit);
  79. jit.move(TrustedImm32(0), regT0);
  80. jit.ret();
  81. LinkBuffer patchBuffer(*vm, &jit, GLOBAL_THUNK_ID);
  82. return FINALIZE_CODE(patchBuffer, ("String get_by_val stub"));
  83. }
  84. void JIT::emit_op_get_by_val(Instruction* currentInstruction)
  85. {
  86. unsigned dst = currentInstruction[1].u.operand;
  87. unsigned base = currentInstruction[2].u.operand;
  88. unsigned property = currentInstruction[3].u.operand;
  89. ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
  90. emitGetVirtualRegisters(base, regT0, property, regT1);
  91. emitJumpSlowCaseIfNotImmediateInteger(regT1);
  92. // This is technically incorrect - we're zero-extending an int32. On the hot path this doesn't matter.
  93. // We check the value as if it was a uint32 against the m_vectorLength - which will always fail if
  94. // number was signed since m_vectorLength is always less than intmax (since the total allocation
  95. // size is always less than 4Gb). As such zero extending wil have been correct (and extending the value
  96. // to 64-bits is necessary since it's used in the address calculation. We zero extend rather than sign
  97. // extending since it makes it easier to re-tag the value in the slow case.
  98. zeroExtend32ToPtr(regT1, regT1);
  99. emitJumpSlowCaseIfNotJSCell(regT0, base);
  100. loadPtr(Address(regT0, JSCell::structureOffset()), regT2);
  101. emitArrayProfilingSite(regT2, regT3, profile);
  102. and32(TrustedImm32(IndexingShapeMask), regT2);
  103. PatchableJump badType;
  104. JumpList slowCases;
  105. JITArrayMode mode = chooseArrayMode(profile);
  106. switch (mode) {
  107. case JITInt32:
  108. slowCases = emitInt32GetByVal(currentInstruction, badType);
  109. break;
  110. case JITDouble:
  111. slowCases = emitDoubleGetByVal(currentInstruction, badType);
  112. break;
  113. case JITContiguous:
  114. slowCases = emitContiguousGetByVal(currentInstruction, badType);
  115. break;
  116. case JITArrayStorage:
  117. slowCases = emitArrayStorageGetByVal(currentInstruction, badType);
  118. break;
  119. default:
  120. CRASH();
  121. break;
  122. }
  123. addSlowCase(badType);
  124. addSlowCase(slowCases);
  125. Label done = label();
  126. #if !ASSERT_DISABLED
  127. Jump resultOK = branchTest64(NonZero, regT0);
  128. breakpoint();
  129. resultOK.link(this);
  130. #endif
  131. emitValueProfilingSite();
  132. emitPutVirtualRegister(dst);
  133. m_byValCompilationInfo.append(ByValCompilationInfo(m_bytecodeOffset, badType, mode, done));
  134. }
  135. JIT::JumpList JIT::emitDoubleGetByVal(Instruction*, PatchableJump& badType)
  136. {
  137. JumpList slowCases;
  138. badType = patchableBranch32(NotEqual, regT2, TrustedImm32(DoubleShape));
  139. loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
  140. slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfPublicLength())));
  141. loadDouble(BaseIndex(regT2, regT1, TimesEight), fpRegT0);
  142. slowCases.append(branchDouble(DoubleNotEqualOrUnordered, fpRegT0, fpRegT0));
  143. moveDoubleTo64(fpRegT0, regT0);
  144. sub64(tagTypeNumberRegister, regT0);
  145. return slowCases;
  146. }
  147. JIT::JumpList JIT::emitContiguousGetByVal(Instruction*, PatchableJump& badType, IndexingType expectedShape)
  148. {
  149. JumpList slowCases;
  150. badType = patchableBranch32(NotEqual, regT2, TrustedImm32(expectedShape));
  151. loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
  152. slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfPublicLength())));
  153. load64(BaseIndex(regT2, regT1, TimesEight), regT0);
  154. slowCases.append(branchTest64(Zero, regT0));
  155. return slowCases;
  156. }
  157. JIT::JumpList JIT::emitArrayStorageGetByVal(Instruction*, PatchableJump& badType)
  158. {
  159. JumpList slowCases;
  160. add32(TrustedImm32(-ArrayStorageShape), regT2, regT3);
  161. badType = patchableBranch32(Above, regT3, TrustedImm32(SlowPutArrayStorageShape - ArrayStorageShape));
  162. loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
  163. slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, ArrayStorage::vectorLengthOffset())));
  164. load64(BaseIndex(regT2, regT1, TimesEight, ArrayStorage::vectorOffset()), regT0);
  165. slowCases.append(branchTest64(Zero, regT0));
  166. return slowCases;
  167. }
  168. void JIT::emitSlow_op_get_by_val(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
  169. {
  170. unsigned dst = currentInstruction[1].u.operand;
  171. unsigned base = currentInstruction[2].u.operand;
  172. unsigned property = currentInstruction[3].u.operand;
  173. ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
  174. linkSlowCase(iter); // property int32 check
  175. linkSlowCaseIfNotJSCell(iter, base); // base cell check
  176. Jump nonCell = jump();
  177. linkSlowCase(iter); // base array check
  178. Jump notString = branchPtr(NotEqual, Address(regT0, JSCell::structureOffset()), TrustedImmPtr(m_vm->stringStructure.get()));
  179. emitNakedCall(CodeLocationLabel(m_vm->getCTIStub(stringGetByValStubGenerator).code()));
  180. Jump failed = branchTest64(Zero, regT0);
  181. emitPutVirtualRegister(dst, regT0);
  182. emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_get_by_val));
  183. failed.link(this);
  184. notString.link(this);
  185. nonCell.link(this);
  186. Jump skipProfiling = jump();
  187. linkSlowCase(iter); // vector length check
  188. linkSlowCase(iter); // empty value
  189. emitArrayProfileOutOfBoundsSpecialCase(profile);
  190. skipProfiling.link(this);
  191. Label slowPath = label();
  192. JITStubCall stubCall(this, cti_op_get_by_val);
  193. stubCall.addArgument(base, regT2);
  194. stubCall.addArgument(property, regT2);
  195. Call call = stubCall.call(dst);
  196. m_byValCompilationInfo[m_byValInstructionIndex].slowPathTarget = slowPath;
  197. m_byValCompilationInfo[m_byValInstructionIndex].returnAddress = call;
  198. m_byValInstructionIndex++;
  199. emitValueProfilingSite();
  200. }
  201. void JIT::compileGetDirectOffset(RegisterID base, RegisterID result, RegisterID offset, RegisterID scratch, FinalObjectMode finalObjectMode)
  202. {
  203. ASSERT(sizeof(JSValue) == 8);
  204. if (finalObjectMode == MayBeFinal) {
  205. Jump isInline = branch32(LessThan, offset, TrustedImm32(firstOutOfLineOffset));
  206. loadPtr(Address(base, JSObject::butterflyOffset()), scratch);
  207. neg32(offset);
  208. Jump done = jump();
  209. isInline.link(this);
  210. addPtr(TrustedImm32(JSObject::offsetOfInlineStorage() - (firstOutOfLineOffset - 2) * sizeof(EncodedJSValue)), base, scratch);
  211. done.link(this);
  212. } else {
  213. #if !ASSERT_DISABLED
  214. Jump isOutOfLine = branch32(GreaterThanOrEqual, offset, TrustedImm32(firstOutOfLineOffset));
  215. breakpoint();
  216. isOutOfLine.link(this);
  217. #endif
  218. loadPtr(Address(base, JSObject::butterflyOffset()), scratch);
  219. neg32(offset);
  220. }
  221. signExtend32ToPtr(offset, offset);
  222. load64(BaseIndex(scratch, offset, TimesEight, (firstOutOfLineOffset - 2) * sizeof(EncodedJSValue)), result);
  223. }
  224. void JIT::emit_op_get_by_pname(Instruction* currentInstruction)
  225. {
  226. unsigned dst = currentInstruction[1].u.operand;
  227. unsigned base = currentInstruction[2].u.operand;
  228. unsigned property = currentInstruction[3].u.operand;
  229. unsigned expected = currentInstruction[4].u.operand;
  230. unsigned iter = currentInstruction[5].u.operand;
  231. unsigned i = currentInstruction[6].u.operand;
  232. emitGetVirtualRegister(property, regT0);
  233. addSlowCase(branch64(NotEqual, regT0, addressFor(expected)));
  234. emitGetVirtualRegisters(base, regT0, iter, regT1);
  235. emitJumpSlowCaseIfNotJSCell(regT0, base);
  236. // Test base's structure
  237. loadPtr(Address(regT0, JSCell::structureOffset()), regT2);
  238. addSlowCase(branchPtr(NotEqual, regT2, Address(regT1, OBJECT_OFFSETOF(JSPropertyNameIterator, m_cachedStructure))));
  239. load32(addressFor(i), regT3);
  240. sub32(TrustedImm32(1), regT3);
  241. addSlowCase(branch32(AboveOrEqual, regT3, Address(regT1, OBJECT_OFFSETOF(JSPropertyNameIterator, m_numCacheableSlots))));
  242. Jump inlineProperty = branch32(Below, regT3, Address(regT1, OBJECT_OFFSETOF(JSPropertyNameIterator, m_cachedStructureInlineCapacity)));
  243. add32(TrustedImm32(firstOutOfLineOffset), regT3);
  244. sub32(Address(regT1, OBJECT_OFFSETOF(JSPropertyNameIterator, m_cachedStructureInlineCapacity)), regT3);
  245. inlineProperty.link(this);
  246. compileGetDirectOffset(regT0, regT0, regT3, regT1);
  247. emitPutVirtualRegister(dst, regT0);
  248. }
  249. void JIT::emitSlow_op_get_by_pname(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
  250. {
  251. unsigned dst = currentInstruction[1].u.operand;
  252. unsigned base = currentInstruction[2].u.operand;
  253. unsigned property = currentInstruction[3].u.operand;
  254. linkSlowCase(iter);
  255. linkSlowCaseIfNotJSCell(iter, base);
  256. linkSlowCase(iter);
  257. linkSlowCase(iter);
  258. JITStubCall stubCall(this, cti_op_get_by_val_generic);
  259. stubCall.addArgument(base, regT2);
  260. stubCall.addArgument(property, regT2);
  261. stubCall.call(dst);
  262. }
  263. void JIT::emit_op_put_by_val(Instruction* currentInstruction)
  264. {
  265. unsigned base = currentInstruction[1].u.operand;
  266. unsigned property = currentInstruction[2].u.operand;
  267. ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
  268. emitGetVirtualRegisters(base, regT0, property, regT1);
  269. emitJumpSlowCaseIfNotImmediateInteger(regT1);
  270. // See comment in op_get_by_val.
  271. zeroExtend32ToPtr(regT1, regT1);
  272. emitJumpSlowCaseIfNotJSCell(regT0, base);
  273. loadPtr(Address(regT0, JSCell::structureOffset()), regT2);
  274. emitArrayProfilingSite(regT2, regT3, profile);
  275. and32(TrustedImm32(IndexingShapeMask), regT2);
  276. PatchableJump badType;
  277. JumpList slowCases;
  278. JITArrayMode mode = chooseArrayMode(profile);
  279. switch (mode) {
  280. case JITInt32:
  281. slowCases = emitInt32PutByVal(currentInstruction, badType);
  282. break;
  283. case JITDouble:
  284. slowCases = emitDoublePutByVal(currentInstruction, badType);
  285. break;
  286. case JITContiguous:
  287. slowCases = emitContiguousPutByVal(currentInstruction, badType);
  288. break;
  289. case JITArrayStorage:
  290. slowCases = emitArrayStoragePutByVal(currentInstruction, badType);
  291. break;
  292. default:
  293. CRASH();
  294. break;
  295. }
  296. addSlowCase(badType);
  297. addSlowCase(slowCases);
  298. Label done = label();
  299. m_byValCompilationInfo.append(ByValCompilationInfo(m_bytecodeOffset, badType, mode, done));
  300. emitWriteBarrier(regT0, regT3, regT1, regT3, ShouldFilterImmediates, WriteBarrierForPropertyAccess);
  301. }
  302. JIT::JumpList JIT::emitGenericContiguousPutByVal(Instruction* currentInstruction, PatchableJump& badType, IndexingType indexingShape)
  303. {
  304. unsigned value = currentInstruction[3].u.operand;
  305. ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
  306. JumpList slowCases;
  307. badType = patchableBranch32(NotEqual, regT2, TrustedImm32(indexingShape));
  308. loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
  309. Jump outOfBounds = branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfPublicLength()));
  310. Label storeResult = label();
  311. emitGetVirtualRegister(value, regT3);
  312. switch (indexingShape) {
  313. case Int32Shape:
  314. slowCases.append(emitJumpIfNotImmediateInteger(regT3));
  315. store64(regT3, BaseIndex(regT2, regT1, TimesEight));
  316. break;
  317. case DoubleShape: {
  318. Jump notInt = emitJumpIfNotImmediateInteger(regT3);
  319. convertInt32ToDouble(regT3, fpRegT0);
  320. Jump ready = jump();
  321. notInt.link(this);
  322. add64(tagTypeNumberRegister, regT3);
  323. move64ToDouble(regT3, fpRegT0);
  324. slowCases.append(branchDouble(DoubleNotEqualOrUnordered, fpRegT0, fpRegT0));
  325. ready.link(this);
  326. storeDouble(fpRegT0, BaseIndex(regT2, regT1, TimesEight));
  327. break;
  328. }
  329. case ContiguousShape:
  330. store64(regT3, BaseIndex(regT2, regT1, TimesEight));
  331. break;
  332. default:
  333. CRASH();
  334. break;
  335. }
  336. Jump done = jump();
  337. outOfBounds.link(this);
  338. slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, Butterfly::offsetOfVectorLength())));
  339. emitArrayProfileStoreToHoleSpecialCase(profile);
  340. add32(TrustedImm32(1), regT1, regT3);
  341. store32(regT3, Address(regT2, Butterfly::offsetOfPublicLength()));
  342. jump().linkTo(storeResult, this);
  343. done.link(this);
  344. return slowCases;
  345. }
  346. JIT::JumpList JIT::emitArrayStoragePutByVal(Instruction* currentInstruction, PatchableJump& badType)
  347. {
  348. unsigned value = currentInstruction[3].u.operand;
  349. ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
  350. JumpList slowCases;
  351. badType = patchableBranch32(NotEqual, regT2, TrustedImm32(ArrayStorageShape));
  352. loadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
  353. slowCases.append(branch32(AboveOrEqual, regT1, Address(regT2, ArrayStorage::vectorLengthOffset())));
  354. Jump empty = branchTest64(Zero, BaseIndex(regT2, regT1, TimesEight, OBJECT_OFFSETOF(ArrayStorage, m_vector[0])));
  355. Label storeResult(this);
  356. emitGetVirtualRegister(value, regT3);
  357. store64(regT3, BaseIndex(regT2, regT1, TimesEight, OBJECT_OFFSETOF(ArrayStorage, m_vector[0])));
  358. Jump end = jump();
  359. empty.link(this);
  360. emitArrayProfileStoreToHoleSpecialCase(profile);
  361. add32(TrustedImm32(1), Address(regT2, ArrayStorage::numValuesInVectorOffset()));
  362. branch32(Below, regT1, Address(regT2, ArrayStorage::lengthOffset())).linkTo(storeResult, this);
  363. add32(TrustedImm32(1), regT1);
  364. store32(regT1, Address(regT2, ArrayStorage::lengthOffset()));
  365. sub32(TrustedImm32(1), regT1);
  366. jump().linkTo(storeResult, this);
  367. end.link(this);
  368. return slowCases;
  369. }
  370. void JIT::emitSlow_op_put_by_val(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
  371. {
  372. unsigned base = currentInstruction[1].u.operand;
  373. unsigned property = currentInstruction[2].u.operand;
  374. unsigned value = currentInstruction[3].u.operand;
  375. ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
  376. linkSlowCase(iter); // property int32 check
  377. linkSlowCaseIfNotJSCell(iter, base); // base cell check
  378. linkSlowCase(iter); // base not array check
  379. JITArrayMode mode = chooseArrayMode(profile);
  380. switch (mode) {
  381. case JITInt32:
  382. case JITDouble:
  383. linkSlowCase(iter); // value type check
  384. break;
  385. default:
  386. break;
  387. }
  388. Jump skipProfiling = jump();
  389. linkSlowCase(iter); // out of bounds
  390. emitArrayProfileOutOfBoundsSpecialCase(profile);
  391. skipProfiling.link(this);
  392. Label slowPath = label();
  393. JITStubCall stubPutByValCall(this, cti_op_put_by_val);
  394. stubPutByValCall.addArgument(regT0);
  395. stubPutByValCall.addArgument(property, regT2);
  396. stubPutByValCall.addArgument(value, regT2);
  397. Call call = stubPutByValCall.call();
  398. m_byValCompilationInfo[m_byValInstructionIndex].slowPathTarget = slowPath;
  399. m_byValCompilationInfo[m_byValInstructionIndex].returnAddress = call;
  400. m_byValInstructionIndex++;
  401. }
  402. void JIT::emit_op_put_by_index(Instruction* currentInstruction)
  403. {
  404. JITStubCall stubCall(this, cti_op_put_by_index);
  405. stubCall.addArgument(currentInstruction[1].u.operand, regT2);
  406. stubCall.addArgument(TrustedImm32(currentInstruction[2].u.operand));
  407. stubCall.addArgument(currentInstruction[3].u.operand, regT2);
  408. stubCall.call();
  409. }
  410. void JIT::emit_op_put_getter_setter(Instruction* currentInstruction)
  411. {
  412. JITStubCall stubCall(this, cti_op_put_getter_setter);
  413. stubCall.addArgument(currentInstruction[1].u.operand, regT2);
  414. stubCall.addArgument(TrustedImmPtr(&m_codeBlock->identifier(currentInstruction[2].u.operand)));
  415. stubCall.addArgument(currentInstruction[3].u.operand, regT2);
  416. stubCall.addArgument(currentInstruction[4].u.operand, regT2);
  417. stubCall.call();
  418. }
  419. void JIT::emit_op_del_by_id(Instruction* currentInstruction)
  420. {
  421. JITStubCall stubCall(this, cti_op_del_by_id);
  422. stubCall.addArgument(currentInstruction[2].u.operand, regT2);
  423. stubCall.addArgument(TrustedImmPtr(&m_codeBlock->identifier(currentInstruction[3].u.operand)));
  424. stubCall.call(currentInstruction[1].u.operand);
  425. }
  426. void JIT::emit_op_get_by_id(Instruction* currentInstruction)
  427. {
  428. unsigned resultVReg = currentInstruction[1].u.operand;
  429. unsigned baseVReg = currentInstruction[2].u.operand;
  430. Identifier* ident = &(m_codeBlock->identifier(currentInstruction[3].u.operand));
  431. emitGetVirtualRegister(baseVReg, regT0);
  432. compileGetByIdHotPath(baseVReg, ident);
  433. emitValueProfilingSite();
  434. emitPutVirtualRegister(resultVReg);
  435. }
  436. void JIT::compileGetByIdHotPath(int baseVReg, Identifier* ident)
  437. {
  438. // As for put_by_id, get_by_id requires the offset of the Structure and the offset of the access to be patched.
  439. // Additionally, for get_by_id we need patch the offset of the branch to the slow case (we patch this to jump
  440. // to array-length / prototype access tranpolines, and finally we also the the property-map access offset as a label
  441. // to jump back to if one of these trampolies finds a match.
  442. emitJumpSlowCaseIfNotJSCell(regT0, baseVReg);
  443. if (*ident == m_vm->propertyNames->length && shouldEmitProfiling()) {
  444. loadPtr(Address(regT0, JSCell::structureOffset()), regT1);
  445. emitArrayProfilingSiteForBytecodeIndex(regT1, regT2, m_bytecodeOffset);
  446. }
  447. BEGIN_UNINTERRUPTED_SEQUENCE(sequenceGetByIdHotPath);
  448. Label hotPathBegin(this);
  449. DataLabelPtr structureToCompare;
  450. PatchableJump structureCheck = patchableBranchPtrWithPatch(NotEqual, Address(regT0, JSCell::structureOffset()), structureToCompare, TrustedImmPtr(reinterpret_cast<void*>(patchGetByIdDefaultStructure)));
  451. addSlowCase(structureCheck);
  452. ConvertibleLoadLabel propertyStorageLoad = convertibleLoadPtr(Address(regT0, JSObject::butterflyOffset()), regT0);
  453. DataLabelCompact displacementLabel = load64WithCompactAddressOffsetPatch(Address(regT0, patchGetByIdDefaultOffset), regT0);
  454. Label putResult(this);
  455. END_UNINTERRUPTED_SEQUENCE(sequenceGetByIdHotPath);
  456. m_propertyAccessCompilationInfo.append(PropertyStubCompilationInfo(PropertyStubGetById, m_bytecodeOffset, hotPathBegin, structureToCompare, structureCheck, propertyStorageLoad, displacementLabel, putResult));
  457. }
  458. void JIT::emitSlow_op_get_by_id(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
  459. {
  460. unsigned resultVReg = currentInstruction[1].u.operand;
  461. unsigned baseVReg = currentInstruction[2].u.operand;
  462. Identifier* ident = &(m_codeBlock->identifier(currentInstruction[3].u.operand));
  463. compileGetByIdSlowCase(resultVReg, baseVReg, ident, iter);
  464. emitValueProfilingSite();
  465. }
  466. void JIT::compileGetByIdSlowCase(int resultVReg, int baseVReg, Identifier* ident, Vector<SlowCaseEntry>::iterator& iter)
  467. {
  468. // As for the hot path of get_by_id, above, we ensure that we can use an architecture specific offset
  469. // so that we only need track one pointer into the slow case code - we track a pointer to the location
  470. // of the call (which we can use to look up the patch information), but should a array-length or
  471. // prototype access trampoline fail we want to bail out back to here. To do so we can subtract back
  472. // the distance from the call to the head of the slow case.
  473. linkSlowCaseIfNotJSCell(iter, baseVReg);
  474. linkSlowCase(iter);
  475. BEGIN_UNINTERRUPTED_SEQUENCE(sequenceGetByIdSlowCase);
  476. Label coldPathBegin(this);
  477. JITStubCall stubCall(this, cti_op_get_by_id);
  478. stubCall.addArgument(regT0);
  479. stubCall.addArgument(TrustedImmPtr(ident));
  480. Call call = stubCall.call(resultVReg);
  481. END_UNINTERRUPTED_SEQUENCE(sequenceGetByIdSlowCase);
  482. // Track the location of the call; this will be used to recover patch information.
  483. m_propertyAccessCompilationInfo[m_propertyAccessInstructionIndex++].slowCaseInfo(PropertyStubGetById, coldPathBegin, call);
  484. }
  485. void JIT::emit_op_put_by_id(Instruction* currentInstruction)
  486. {
  487. unsigned baseVReg = currentInstruction[1].u.operand;
  488. unsigned valueVReg = currentInstruction[3].u.operand;
  489. // In order to be able to patch both the Structure, and the object offset, we store one pointer,
  490. // to just after the arguments have been loaded into registers 'hotPathBegin', and we generate code
  491. // such that the Structure & offset are always at the same distance from this.
  492. emitGetVirtualRegisters(baseVReg, regT0, valueVReg, regT1);
  493. // Jump to a slow case if either the base object is an immediate, or if the Structure does not match.
  494. emitJumpSlowCaseIfNotJSCell(regT0, baseVReg);
  495. BEGIN_UNINTERRUPTED_SEQUENCE(sequencePutById);
  496. Label hotPathBegin(this);
  497. // It is important that the following instruction plants a 32bit immediate, in order that it can be patched over.
  498. DataLabelPtr structureToCompare;
  499. addSlowCase(branchPtrWithPatch(NotEqual, Address(regT0, JSCell::structureOffset()), structureToCompare, TrustedImmPtr(reinterpret_cast<void*>(patchGetByIdDefaultStructure))));
  500. ConvertibleLoadLabel propertyStorageLoad = convertibleLoadPtr(Address(regT0, JSObject::butterflyOffset()), regT2);
  501. DataLabel32 displacementLabel = store64WithAddressOffsetPatch(regT1, Address(regT2, patchPutByIdDefaultOffset));
  502. END_UNINTERRUPTED_SEQUENCE(sequencePutById);
  503. emitWriteBarrier(regT0, regT1, regT2, regT3, ShouldFilterImmediates, WriteBarrierForPropertyAccess);
  504. m_propertyAccessCompilationInfo.append(PropertyStubCompilationInfo(PropertyStubPutById, m_bytecodeOffset, hotPathBegin, structureToCompare, propertyStorageLoad, displacementLabel));
  505. }
  506. void JIT::emitSlow_op_put_by_id(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
  507. {
  508. unsigned baseVReg = currentInstruction[1].u.operand;
  509. Identifier* ident = &(m_codeBlock->identifier(currentInstruction[2].u.operand));
  510. unsigned direct = currentInstruction[8].u.operand;
  511. linkSlowCaseIfNotJSCell(iter, baseVReg);
  512. linkSlowCase(iter);
  513. JITStubCall stubCall(this, direct ? cti_op_put_by_id_direct : cti_op_put_by_id);
  514. stubCall.addArgument(regT0);
  515. stubCall.addArgument(TrustedImmPtr(ident));
  516. stubCall.addArgument(regT1);
  517. move(regT0, nonArgGPR1);
  518. Call call = stubCall.call();
  519. // Track the location of the call; this will be used to recover patch information.
  520. m_propertyAccessCompilationInfo[m_propertyAccessInstructionIndex++].slowCaseInfo(PropertyStubPutById, call);
  521. }
  522. // Compile a store into an object's property storage. May overwrite the
  523. // value in objectReg.
  524. void JIT::compilePutDirectOffset(RegisterID base, RegisterID value, PropertyOffset cachedOffset)
  525. {
  526. if (isInlineOffset(cachedOffset)) {
  527. store64(value, Address(base, JSObject::offsetOfInlineStorage() + sizeof(JSValue) * offsetInInlineStorage(cachedOffset)));
  528. return;
  529. }
  530. loadPtr(Address(base, JSObject::butterflyOffset()), base);
  531. store64(value, Address(base, sizeof(JSValue) * offsetInButterfly(cachedOffset)));
  532. }
  533. // Compile a load from an object's property storage. May overwrite base.
  534. void JIT::compileGetDirectOffset(RegisterID base, RegisterID result, PropertyOffset cachedOffset)
  535. {
  536. if (isInlineOffset(cachedOffset)) {
  537. load64(Address(base, JSObject::offsetOfInlineStorage() + sizeof(JSValue) * offsetInInlineStorage(cachedOffset)), result);
  538. return;
  539. }
  540. loadPtr(Address(base, JSObject::butterflyOffset()), result);
  541. load64(Address(result, sizeof(JSValue) * offsetInButterfly(cachedOffset)), result);
  542. }
  543. void JIT::compileGetDirectOffset(JSObject* base, RegisterID result, PropertyOffset cachedOffset)
  544. {
  545. if (isInlineOffset(cachedOffset)) {
  546. load64(base->locationForOffset(cachedOffset), result);
  547. return;
  548. }
  549. loadPtr(base->butterflyAddress(), result);
  550. load64(Address(result, offsetInButterfly(cachedOffset) * sizeof(WriteBarrier<Unknown>)), result);
  551. }
  552. void JIT::privateCompilePutByIdTransition(StructureStubInfo* stubInfo, Structure* oldStructure, Structure* newStructure, PropertyOffset cachedOffset, StructureChain* chain, ReturnAddressPtr returnAddress, bool direct)
  553. {
  554. move(nonArgGPR1, regT0);
  555. JumpList failureCases;
  556. // Check eax is an object of the right Structure.
  557. failureCases.append(emitJumpIfNotJSCell(regT0));
  558. failureCases.append(branchPtr(NotEqual, Address(regT0, JSCell::structureOffset()), TrustedImmPtr(oldStructure)));
  559. testPrototype(oldStructure->storedPrototype(), failureCases, stubInfo);
  560. ASSERT(oldStructure->storedPrototype().isNull() || oldStructure->storedPrototype().asCell()->structure() == chain->head()->get());
  561. // ecx = baseObject->m_structure
  562. if (!direct) {
  563. for (WriteBarrier<Structure>* it = chain->head(); *it; ++it) {
  564. ASSERT((*it)->storedPrototype().isNull() || (*it)->storedPrototype().asCell()->structure() == it[1].get());
  565. testPrototype((*it)->storedPrototype(), failureCases, stubInfo);
  566. }
  567. }
  568. // If we succeed in all of our checks, and the code was optimizable, then make sure we
  569. // decrement the rare case counter.
  570. #if ENABLE(VALUE_PROFILER)
  571. if (m_codeBlock->canCompileWithDFG() >= DFG::MayInline) {
  572. sub32(
  573. TrustedImm32(1),
  574. AbsoluteAddress(&m_codeBlock->rareCaseProfileForBytecodeOffset(stubInfo->bytecodeIndex)->m_counter));
  575. }
  576. #endif
  577. // emit a call only if storage realloc is needed
  578. bool willNeedStorageRealloc = oldStructure->outOfLineCapacity() != newStructure->outOfLineCapacity();
  579. if (willNeedStorageRealloc) {
  580. // This trampoline was called to like a JIT stub; before we can can call again we need to
  581. // remove the return address from the stack, to prevent the stack from becoming misaligned.
  582. preserveReturnAddressAfterCall(regT3);
  583. JITStubCall stubCall(this, cti_op_put_by_id_transition_realloc);
  584. stubCall.skipArgument(); // base
  585. stubCall.skipArgument(); // ident
  586. stubCall.skipArgument(); // value
  587. stubCall.addArgument(TrustedImm32(oldStructure->outOfLineCapacity()));
  588. stubCall.addArgument(TrustedImmPtr(newStructure));
  589. stubCall.call(regT0);
  590. emitGetJITStubArg(2, regT1);
  591. restoreReturnAddressBeforeReturn(regT3);
  592. }
  593. // Planting the new structure triggers the write barrier so we need
  594. // an unconditional barrier here.
  595. emitWriteBarrier(regT0, regT1, regT2, regT3, UnconditionalWriteBarrier, WriteBarrierForPropertyAccess);
  596. ASSERT(newStructure->classInfo() == oldStructure->classInfo());
  597. storePtr(TrustedImmPtr(newStructure), Address(regT0, JSCell::structureOffset()));
  598. compilePutDirectOffset(regT0, regT1, cachedOffset);
  599. ret();
  600. ASSERT(!failureCases.empty());
  601. failureCases.link(this);
  602. restoreArgumentReferenceForTrampoline();
  603. Call failureCall = tailRecursiveCall();
  604. LinkBuffer patchBuffer(*m_vm, this, m_codeBlock);
  605. patchBuffer.link(failureCall, FunctionPtr(direct ? cti_op_put_by_id_direct_fail : cti_op_put_by_id_fail));
  606. if (willNeedStorageRealloc) {
  607. ASSERT(m_calls.size() == 1);
  608. patchBuffer.link(m_calls[0].from, FunctionPtr(cti_op_put_by_id_transition_realloc));
  609. }
  610. stubInfo->stubRoutine = createJITStubRoutine(
  611. FINALIZE_CODE(
  612. patchBuffer,
  613. ("Baseline put_by_id transition for %s, return point %p",
  614. toCString(*m_codeBlock).data(), returnAddress.value())),
  615. *m_vm,
  616. m_codeBlock->ownerExecutable(),
  617. willNeedStorageRealloc,
  618. newStructure);
  619. RepatchBuffer repatchBuffer(m_codeBlock);
  620. repatchBuffer.relinkCallerToTrampoline(returnAddress, CodeLocationLabel(stubInfo->stubRoutine->code().code()));
  621. }
  622. void JIT::patchGetByIdSelf(CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, PropertyOffset cachedOffset, ReturnAddressPtr returnAddress)
  623. {
  624. RepatchBuffer repatchBuffer(codeBlock);
  625. // We don't want to patch more than once - in future go to cti_op_get_by_id_generic.
  626. // Should probably go to cti_op_get_by_id_fail, but that doesn't do anything interesting right now.
  627. repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(cti_op_get_by_id_self_fail));
  628. // Patch the offset into the propoerty map to load from, then patch the Structure to look for.
  629. repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabelPtrAtOffset(stubInfo->patch.baseline.u.get.structureToCompare), structure);
  630. repatchBuffer.setLoadInstructionIsActive(stubInfo->hotPathBegin.convertibleLoadAtOffset(stubInfo->patch.baseline.u.get.propertyStorageLoad), isOutOfLineOffset(cachedOffset));
  631. repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabelCompactAtOffset(stubInfo->patch.baseline.u.get.displacementLabel), offsetRelativeToPatchedStorage(cachedOffset));
  632. }
  633. void JIT::patchPutByIdReplace(CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, PropertyOffset cachedOffset, ReturnAddressPtr returnAddress, bool direct)
  634. {
  635. RepatchBuffer repatchBuffer(codeBlock);
  636. // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
  637. // Should probably go to cti_op_put_by_id_fail, but that doesn't do anything interesting right now.
  638. repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(direct ? cti_op_put_by_id_direct_generic : cti_op_put_by_id_generic));
  639. // Patch the offset into the propoerty map to load from, then patch the Structure to look for.
  640. repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabelPtrAtOffset(stubInfo->patch.baseline.u.put.structureToCompare), structure);
  641. repatchBuffer.setLoadInstructionIsActive(stubInfo->hotPathBegin.convertibleLoadAtOffset(stubInfo->patch.baseline.u.put.propertyStorageLoad), isOutOfLineOffset(cachedOffset));
  642. repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabel32AtOffset(stubInfo->patch.baseline.u.put.displacementLabel), offsetRelativeToPatchedStorage(cachedOffset));
  643. }
  644. void JIT::privateCompilePatchGetArrayLength(ReturnAddressPtr returnAddress)
  645. {
  646. StructureStubInfo* stubInfo = &m_codeBlock->getStubInfo(returnAddress);
  647. // Check eax is an array
  648. loadPtr(Address(regT0, JSCell::structureOffset()), regT2);
  649. Jump failureCases1 = branchTest32(Zero, regT2, TrustedImm32(IsArray));
  650. Jump failureCases2 = branchTest32(Zero, regT2, TrustedImm32(IndexingShapeMask));
  651. // Checks out okay! - get the length from the storage
  652. loadPtr(Address(regT0, JSObject::butterflyOffset()), regT3);
  653. load32(Address(regT3, ArrayStorage::lengthOffset()), regT2);
  654. Jump failureCases3 = branch32(LessThan, regT2, TrustedImm32(0));
  655. emitFastArithIntToImmNoCheck(regT2, regT0);
  656. Jump success = jump();
  657. LinkBuffer patchBuffer(*m_vm, this, m_codeBlock);
  658. // Use the patch information to link the failure cases back to the original slow case routine.
  659. CodeLocationLabel slowCaseBegin = stubInfo->callReturnLocation.labelAtOffset(-stubInfo->patch.baseline.u.get.coldPathBegin);
  660. patchBuffer.link(failureCases1, slowCaseBegin);
  661. patchBuffer.link(failureCases2, slowCaseBegin);
  662. patchBuffer.link(failureCases3, slowCaseBegin);
  663. // On success return back to the hot patch code, at a point it will perform the store to dest for us.
  664. patchBuffer.link(success, stubInfo->hotPathBegin.labelAtOffset(stubInfo->patch.baseline.u.get.putResult));
  665. // Track the stub we have created so that it will be deleted later.
  666. stubInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
  667. patchBuffer,
  668. ("Basline JIT get_by_id array length stub for %s, return point %p",
  669. toCString(*m_codeBlock).data(),
  670. stubInfo->hotPathBegin.labelAtOffset(
  671. stubInfo->patch.baseline.u.get.putResult).executableAddress()));
  672. // Finally patch the jump to slow case back in the hot path to jump here instead.
  673. CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(stubInfo->patch.baseline.u.get.structureCheck);
  674. RepatchBuffer repatchBuffer(m_codeBlock);
  675. repatchBuffer.relink(jumpLocation, CodeLocationLabel(stubInfo->stubRoutine->code().code()));
  676. // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
  677. repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(cti_op_get_by_id_array_fail));
  678. }
  679. void JIT::privateCompileGetByIdProto(StructureStubInfo* stubInfo, Structure* structure, Structure* prototypeStructure, const Identifier& ident, const PropertySlot& slot, PropertyOffset cachedOffset, ReturnAddressPtr returnAddress, CallFrame* callFrame)
  680. {
  681. // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a Structure that is
  682. // referencing the prototype object - let's speculatively load it's table nice and early!)
  683. JSObject* protoObject = asObject(structure->prototypeForLookup(callFrame));
  684. // Check eax is an object of the right Structure.
  685. Jump failureCases1 = checkStructure(regT0, structure);
  686. // Check the prototype object's Structure had not changed.
  687. Jump failureCases2 = addStructureTransitionCheck(protoObject, prototypeStructure, stubInfo, regT3);
  688. bool needsStubLink = false;
  689. // Checks out okay!
  690. if (slot.cachedPropertyType() == PropertySlot::Getter) {
  691. needsStubLink = true;
  692. compileGetDirectOffset(protoObject, regT1, cachedOffset);
  693. JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
  694. stubCall.addArgument(regT1);
  695. stubCall.addArgument(regT0);
  696. stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
  697. stubCall.call();
  698. } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
  699. needsStubLink = true;
  700. JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
  701. stubCall.addArgument(TrustedImmPtr(protoObject));
  702. stubCall.addArgument(TrustedImmPtr(FunctionPtr(slot.customGetter()).executableAddress()));
  703. stubCall.addArgument(TrustedImmPtr(const_cast<Identifier*>(&ident)));
  704. stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
  705. stubCall.call();
  706. } else
  707. compileGetDirectOffset(protoObject, regT0, cachedOffset);
  708. Jump success = jump();
  709. LinkBuffer patchBuffer(*m_vm, this, m_codeBlock);
  710. // Use the patch information to link the failure cases back to the original slow case routine.
  711. CodeLocationLabel slowCaseBegin = stubInfo->callReturnLocation.labelAtOffset(-stubInfo->patch.baseline.u.get.coldPathBegin);
  712. patchBuffer.link(failureCases1, slowCaseBegin);
  713. if (failureCases2.isSet())
  714. patchBuffer.link(failureCases2, slowCaseBegin);
  715. // On success return back to the hot patch code, at a point it will perform the store to dest for us.
  716. patchBuffer.link(success, stubInfo->hotPathBegin.labelAtOffset(stubInfo->patch.baseline.u.get.putResult));
  717. if (needsStubLink) {
  718. for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) {
  719. if (iter->to)
  720. patchBuffer.link(iter->from, FunctionPtr(iter->to));
  721. }
  722. }
  723. // Track the stub we have created so that it will be deleted later.
  724. stubInfo->stubRoutine = createJITStubRoutine(
  725. FINALIZE_CODE(
  726. patchBuffer,
  727. ("Baseline JIT get_by_id proto stub for %s, return point %p",
  728. toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset(
  729. stubInfo->patch.baseline.u.get.putResult).executableAddress())),
  730. *m_vm,
  731. m_codeBlock->ownerExecutable(),
  732. needsStubLink);
  733. // Finally patch the jump to slow case back in the hot path to jump here instead.
  734. CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(stubInfo->patch.baseline.u.get.structureCheck);
  735. RepatchBuffer repatchBuffer(m_codeBlock);
  736. repatchBuffer.relink(jumpLocation, CodeLocationLabel(stubInfo->stubRoutine->code().code()));
  737. // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
  738. repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(cti_op_get_by_id_proto_list));
  739. }
  740. void JIT::privateCompileGetByIdSelfList(StructureStubInfo* stubInfo, PolymorphicAccessStructureList* polymorphicStructures, int currentIndex, Structure* structure, const Identifier& ident, const PropertySlot& slot, PropertyOffset cachedOffset)
  741. {
  742. Jump failureCase = checkStructure(regT0, structure);
  743. bool needsStubLink = false;
  744. bool isDirect = false;
  745. if (slot.cachedPropertyType() == PropertySlot::Getter) {
  746. needsStubLink = true;
  747. compileGetDirectOffset(regT0, regT1, cachedOffset);
  748. JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
  749. stubCall.addArgument(regT1);
  750. stubCall.addArgument(regT0);
  751. stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
  752. stubCall.call();
  753. } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
  754. needsStubLink = true;
  755. JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
  756. stubCall.addArgument(regT0);
  757. stubCall.addArgument(TrustedImmPtr(FunctionPtr(slot.customGetter()).executableAddress()));
  758. stubCall.addArgument(TrustedImmPtr(const_cast<Identifier*>(&ident)));
  759. stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
  760. stubCall.call();
  761. } else {
  762. isDirect = true;
  763. compileGetDirectOffset(regT0, regT0, cachedOffset);
  764. }
  765. Jump success = jump();
  766. LinkBuffer patchBuffer(*m_vm, this, m_codeBlock);
  767. if (needsStubLink) {
  768. for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) {
  769. if (iter->to)
  770. patchBuffer.link(iter->from, FunctionPtr(iter->to));
  771. }
  772. }
  773. // Use the patch information to link the failure cases back to the original slow case routine.
  774. CodeLocationLabel lastProtoBegin = CodeLocationLabel(JITStubRoutine::asCodePtr(polymorphicStructures->list[currentIndex - 1].stubRoutine));
  775. if (!lastProtoBegin)
  776. lastProtoBegin = stubInfo->callReturnLocation.labelAtOffset(-stubInfo->patch.baseline.u.get.coldPathBegin);
  777. patchBuffer.link(failureCase, lastProtoBegin);
  778. // On success return back to the hot patch code, at a point it will perform the store to dest for us.
  779. patchBuffer.link(success, stubInfo->hotPathBegin.labelAtOffset(stubInfo->patch.baseline.u.get.putResult));
  780. RefPtr<JITStubRoutine> stubCode = createJITStubRoutine(
  781. FINALIZE_CODE(
  782. patchBuffer,
  783. ("Baseline JIT get_by_id list stub for %s, return point %p",
  784. toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset(
  785. stubInfo->patch.baseline.u.get.putResult).executableAddress())),
  786. *m_vm,
  787. m_codeBlock->ownerExecutable(),
  788. needsStubLink);
  789. polymorphicStructures->list[currentIndex].set(*m_vm, m_codeBlock->ownerExecutable(), stubCode, structure, isDirect);
  790. // Finally patch the jump to slow case back in the hot path to jump here instead.
  791. CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(stubInfo->patch.baseline.u.get.structureCheck);
  792. RepatchBuffer repatchBuffer(m_codeBlock);
  793. repatchBuffer.relink(jumpLocation, CodeLocationLabel(stubCode->code().code()));
  794. }
  795. void JIT::privateCompileGetByIdProtoList(StructureStubInfo* stubInfo, PolymorphicAccessStructureList* prototypeStructures, int currentIndex, Structure* structure, Structure* prototypeStructure, const Identifier& ident, const PropertySlot& slot, PropertyOffset cachedOffset, CallFrame* callFrame)
  796. {
  797. // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a Structure that is
  798. // referencing the prototype object - let's speculatively load it's table nice and early!)
  799. JSObject* protoObject = asObject(structure->prototypeForLookup(callFrame));
  800. // Check eax is an object of the right Structure.
  801. Jump failureCases1 = checkStructure(regT0, structure);
  802. // Check the prototype object's Structure had not changed.
  803. Jump failureCases2 = addStructureTransitionCheck(protoObject, prototypeStructure, stubInfo, regT3);
  804. // Checks out okay!
  805. bool needsStubLink = false;
  806. bool isDirect = false;
  807. if (slot.cachedPropertyType() == PropertySlot::Getter) {
  808. needsStubLink = true;
  809. compileGetDirectOffset(protoObject, regT1, cachedOffset);
  810. JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
  811. stubCall.addArgument(regT1);
  812. stubCall.addArgument(regT0);
  813. stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
  814. stubCall.call();
  815. } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
  816. needsStubLink = true;
  817. JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
  818. stubCall.addArgument(TrustedImmPtr(protoObject));
  819. stubCall.addArgument(TrustedImmPtr(FunctionPtr(slot.customGetter()).executableAddress()));
  820. stubCall.addArgument(TrustedImmPtr(const_cast<Identifier*>(&ident)));
  821. stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
  822. stubCall.call();
  823. } else {
  824. isDirect = true;
  825. compileGetDirectOffset(protoObject, regT0, cachedOffset);
  826. }
  827. Jump success = jump();
  828. LinkBuffer patchBuffer(*m_vm, this, m_codeBlock);
  829. if (needsStubLink) {
  830. for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) {
  831. if (iter->to)
  832. patchBuffer.link(iter->from, FunctionPtr(iter->to));
  833. }
  834. }
  835. // Use the patch information to link the failure cases back to the original slow case routine.
  836. CodeLocationLabel lastProtoBegin = CodeLocationLabel(JITStubRoutine::asCodePtr(prototypeStructures->list[currentIndex - 1].stubRoutine));
  837. patchBuffer.link(failureCases1, lastProtoBegin);
  838. if (failureCases2.isSet())
  839. patchBuffer.link(failureCases2, lastProtoBegin);
  840. // On success return back to the hot patch code, at a point it will perform the store to dest for us.
  841. patchBuffer.link(success, stubInfo->hotPathBegin.labelAtOffset(stubInfo->patch.baseline.u.get.putResult));
  842. RefPtr<JITStubRoutine> stubCode = createJITStubRoutine(
  843. FINALIZE_CODE(
  844. patchBuffer,
  845. ("Baseline JIT get_by_id proto list stub for %s, return point %p",
  846. toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset(
  847. stubInfo->patch.baseline.u.get.putResult).executableAddress())),
  848. *m_vm,
  849. m_codeBlock->ownerExecutable(),
  850. needsStubLink);
  851. prototypeStructures->list[currentIndex].set(*m_vm, m_codeBlock->ownerExecutable(), stubCode, structure, prototypeStructure, isDirect);
  852. // Finally patch the jump to slow case back in the hot path to jump here instead.
  853. CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(stubInfo->patch.baseline.u.get.structureCheck);
  854. RepatchBuffer repatchBuffer(m_codeBlock);
  855. repatchBuffer.relink(jumpLocation, CodeLocationLabel(stubCode->code().code()));
  856. }
  857. void JIT::privateCompileGetByIdChainList(StructureStubInfo* stubInfo, PolymorphicAccessStructureList* prototypeStructures, int currentIndex, Structure* structure, StructureChain* chain, size_t count, const Identifier& ident, const PropertySlot& slot, PropertyOffset cachedOffset, CallFrame* callFrame)
  858. {
  859. ASSERT(count);
  860. JumpList bucketsOfFail;
  861. // Check eax is an object of the right Structure.
  862. Jump baseObjectCheck = checkStructure(regT0, structure);
  863. bucketsOfFail.append(baseObjectCheck);
  864. Structure* currStructure = structure;
  865. WriteBarrier<Structure>* it = chain->head();
  866. JSObject* protoObject = 0;
  867. for (unsigned i = 0; i < count; ++i, ++it) {
  868. protoObject = asObject(currStructure->prototypeForLookup(callFrame));
  869. currStructure = it->get();
  870. testPrototype(protoObject, bucketsOfFail, stubInfo);
  871. }
  872. ASSERT(protoObject);
  873. bool needsStubLink = false;
  874. bool isDirect = false;
  875. if (slot.cachedPropertyType() == PropertySlot::Getter) {
  876. needsStubLink = true;
  877. compileGetDirectOffset(protoObject, regT1, cachedOffset);
  878. JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
  879. stubCall.addArgument(regT1);
  880. stubCall.addArgument(regT0);
  881. stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
  882. stubCall.call();
  883. } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
  884. needsStubLink = true;
  885. JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
  886. stubCall.addArgument(TrustedImmPtr(protoObject));
  887. stubCall.addArgument(TrustedImmPtr(FunctionPtr(slot.customGetter()).executableAddress()));
  888. stubCall.addArgument(TrustedImmPtr(const_cast<Identifier*>(&ident)));
  889. stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
  890. stubCall.call();
  891. } else {
  892. isDirect = true;
  893. compileGetDirectOffset(protoObject, regT0, cachedOffset);
  894. }
  895. Jump success = jump();
  896. LinkBuffer patchBuffer(*m_vm, this, m_codeBlock);
  897. if (needsStubLink) {
  898. for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) {
  899. if (iter->to)
  900. patchBuffer.link(iter->from, FunctionPtr(iter->to));
  901. }
  902. }
  903. // Use the patch information to link the failure cases back to the original slow case routine.
  904. CodeLocationLabel lastProtoBegin = CodeLocationLabel(JITStubRoutine::asCodePtr(prototypeStructures->list[currentIndex - 1].stubRoutine));
  905. patchBuffer.link(bucketsOfFail, lastProtoBegin);
  906. // On success return back to the hot patch code, at a point it will perform the store to dest for us.
  907. patchBuffer.link(success, stubInfo->hotPathBegin.labelAtOffset(stubInfo->patch.baseline.u.get.putResult));
  908. RefPtr<JITStubRoutine> stubRoutine = createJITStubRoutine(
  909. FINALIZE_CODE(
  910. patchBuffer,
  911. ("Baseline JIT get_by_id chain list stub for %s, return point %p",
  912. toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset(
  913. stubInfo->patch.baseline.u.get.putResult).executableAddress())),
  914. *m_vm,
  915. m_codeBlock->ownerExecutable(),
  916. needsStubLink);
  917. // Track the stub we have created so that it will be deleted later.
  918. prototypeStructures->list[currentIndex].set(callFrame->vm(), m_codeBlock->ownerExecutable(), stubRoutine, structure, chain, isDirect);
  919. // Finally patch the jump to slow case back in the hot path to jump here instead.
  920. CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(stubInfo->patch.baseline.u.get.structureCheck);
  921. RepatchBuffer repatchBuffer(m_codeBlock);
  922. repatchBuffer.relink(jumpLocation, CodeLocationLabel(stubRoutine->code().code()));
  923. }
  924. void JIT::privateCompileGetByIdChain(StructureStubInfo* stubInfo, Structure* structure, StructureChain* chain, size_t count, const Identifier& ident, const PropertySlot& slot, PropertyOffset cachedOffset, ReturnAddressPtr returnAddress, CallFrame* callFrame)
  925. {
  926. ASSERT(count);
  927. JumpList bucketsOfFail;
  928. // Check eax is an object of the right Structure.
  929. bucketsOfFail.append(checkStructure(regT0, structure));
  930. Structure* currStructure = structure;
  931. WriteBarrier<Structure>* it = chain->head();
  932. JSObject* protoObject = 0;
  933. for (unsigned i = 0; i < count; ++i, ++it) {
  934. protoObject = asObject(currStructure->prototypeForLookup(callFrame));
  935. currStructure = it->get();
  936. testPrototype(protoObject, bucketsOfFail, stubInfo);
  937. }
  938. ASSERT(protoObject);
  939. bool needsStubLink = false;
  940. if (slot.cachedPropertyType() == PropertySlot::Getter) {
  941. needsStubLink = true;
  942. compileGetDirectOffset(protoObject, regT1, cachedOffset);
  943. JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
  944. stubCall.addArgument(regT1);
  945. stubCall.addArgument(regT0);
  946. stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
  947. stubCall.call();
  948. } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
  949. needsStubLink = true;
  950. JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
  951. stubCall.addArgument(TrustedImmPtr(protoObject));
  952. stubCall.addArgument(TrustedImmPtr(FunctionPtr(slot.customGetter()).executableAddress()));
  953. stubCall.addArgument(TrustedImmPtr(const_cast<Identifier*>(&ident)));
  954. stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
  955. stubCall.call();
  956. } else
  957. compileGetDirectOffset(protoObject, regT0, cachedOffset);
  958. Jump success = jump();
  959. LinkBuffer patchBuffer(*m_vm, this, m_codeBlock);
  960. if (needsStubLink) {
  961. for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) {
  962. if (iter->to)
  963. patchBuffer.link(iter->from, FunctionPtr(iter->to));
  964. }
  965. }
  966. // Use the patch information to link the failure cases back to the original slow case routine.
  967. patchBuffer.link(bucketsOfFail, stubInfo->callReturnLocation.labelAtOffset(-stubInfo->patch.baseline.u.get.coldPathBegin));
  968. // On success return back to the hot patch code, at a point it will perform the store to dest for us.
  969. patchBuffer.link(success, stubInfo->hotPathBegin.labelAtOffset(stubInfo->patch.baseline.u.get.putResult));
  970. // Track the stub we have created so that it will be deleted later.
  971. RefPtr<JITStubRoutine> stubRoutine = createJITStubRoutine(
  972. FINALIZE_CODE(
  973. patchBuffer,
  974. ("Baseline JIT get_by_id chain stub for %s, return point %p",
  975. toCString(*m_codeBlock).data(), stubInfo->hotPathBegin.labelAtOffset(
  976. stubInfo->patch.baseline.u.get.putResult).executableAddress())),
  977. *m_vm,
  978. m_codeBlock->ownerExecutable(),
  979. needsStubLink);
  980. stubInfo->stubRoutine = stubRoutine;
  981. // Finally patch the jump to slow case back in the hot path to jump here instead.
  982. CodeLocationJump jumpLocation = stubInfo->hotPathBegin.jumpAtOffset(stubInfo->patch.baseline.u.get.structureCheck);
  983. RepatchBuffer repatchBuffer(m_codeBlock);
  984. repatchBuffer.relink(jumpLocation, CodeLocationLabel(stubRoutine->code().code()));
  985. // We don't want to patch more than once - in future go to cti_op_put_by_id_generic.
  986. repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(cti_op_get_by_id_proto_list));
  987. }
  988. void JIT::emit_op_get_scoped_var(Instruction* currentInstruction)
  989. {
  990. int skip = currentInstruction[3].u.operand;
  991. emitGetFromCallFrameHeaderPtr(JSStack::ScopeChain, regT0);
  992. bool checkTopLevel = m_codeBlock->codeType() == FunctionCode && m_codeBlock->needsFullScopeChain();
  993. ASSERT(skip || !checkTopLevel);
  994. if (checkTopLevel && skip--) {
  995. Jump activationNotCreated;
  996. if (checkTopLevel)
  997. activationNotCreated = branchTestPtr(Zero, addressFor(m_codeBlock->activationRegister()));
  998. loadPtr(Address(regT0, JSScope::offsetOfNext()), regT0);
  999. activationNotCreated.link(this);
  1000. }
  1001. while (skip--)
  1002. loadPtr(Address(regT0, JSScope::offsetOfNext()), regT0);
  1003. loadPtr(Address(regT0, JSVariableObject::offsetOfRegisters()), regT0);
  1004. loadPtr(Address(regT0, currentInstruction[2].u.operand * sizeof(Register)), regT0);
  1005. emitValueProfilingSite();
  1006. emitPutVirtualRegister(currentInstruction[1].u.operand);
  1007. }
  1008. void JIT::emit_op_put_scoped_var(Instruction* currentInstruction)
  1009. {
  1010. int skip = currentInstruction[2].u.operand;
  1011. emitGetVirtualRegister(currentInstruction[3].u.operand, regT0);
  1012. emitGetFromCallFrameHeaderPtr(JSStack::ScopeChain, regT1);
  1013. bool checkTopLevel = m_codeBlock->codeType() == FunctionCode && m_codeBlock->needsFullScopeChain();
  1014. ASSERT(skip || !checkTopLevel);
  1015. if (checkTopLevel && skip--) {
  1016. Jump activationNotCreated;
  1017. if (checkTopLevel)
  1018. activationNotCreated = branchTestPtr(Zero, addressFor(m_codeBlock->activationRegister()));
  1019. loadPtr(Address(regT1, JSScope::offsetOfNext()), regT1);
  1020. activationNotCreated.link(this);
  1021. }
  1022. while (skip--)
  1023. loadPtr(Address(regT1, JSScope::offsetOfNext()), regT1);
  1024. emitWriteBarrier(regT1, regT0, regT2, regT3, ShouldFilterImmediates, WriteBarrierForVariableAccess);
  1025. loadPtr(Address(regT1, JSVariableObject::offsetOfRegisters()), regT1);
  1026. storePtr(regT0, Address(regT1, currentInstruction[1].u.operand * sizeof(Register)));
  1027. }
  1028. void JIT::emit_op_init_global_const(Instruction* currentInstruction)
  1029. {
  1030. JSGlobalObject* globalObject = m_codeBlock->globalObject();
  1031. emitGetVirtualRegister(currentInstruction[2].u.operand, regT0);
  1032. store64(regT0, currentInstruction[1].u.registerPointer);
  1033. if (Heap::isWriteBarrierEnabled())
  1034. emitWriteBarrier(globalObject, regT0, regT2, ShouldFilterImmediates, WriteBarrierForVariableAccess);
  1035. }
  1036. void JIT::emit_op_init_global_const_check(Instruction* currentInstruction)
  1037. {
  1038. emitGetVirtualRegister(currentInstruction[2].u.operand, regT0);
  1039. addSlowCase(branchTest8(NonZero, AbsoluteAddress(currentInstruction[3].u.predicatePointer)));
  1040. JSGlobalObject* globalObject = m_codeBlock->globalObject();
  1041. store64(regT0, currentInstruction[1].u.registerPointer);
  1042. if (Heap::isWriteBarrierEnabled())
  1043. emitWriteBarrier(globalObject, regT0, regT2, ShouldFilterImmediates, WriteBarrierForVariableAccess);
  1044. }
  1045. void JIT::emitSlow_op_init_global_const_check(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
  1046. {
  1047. linkSlowCase(iter);
  1048. JITStubCall stubCall(this, cti_op_init_global_const_check);
  1049. stubCall.addArgument(regT0);
  1050. stubCall.addArgument(TrustedImm32(currentInstruction[4].u.operand));
  1051. stubCall.call();
  1052. }
  1053. void JIT::resetPatchGetById(RepatchBuffer& repatchBuffer, StructureStubInfo* stubInfo)
  1054. {
  1055. repatchBuffer.relink(stubInfo->callReturnLocation, cti_op_get_by_id);
  1056. repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabelPtrAtOffset(stubInfo->patch.baseline.u.get.structureToCompare), reinterpret_cast<void*>(unusedPointer));
  1057. repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabelCompactAtOffset(stubInfo->patch.baseline.u.get.displacementLabel), 0);
  1058. repatchBuffer.relink(stubInfo->hotPathBegin.jumpAtOffset(stubInfo->patch.baseline.u.get.structureCheck), stubInfo->callReturnLocation.labelAtOffset(-stubInfo->patch.baseline.u.get.coldPathBegin));
  1059. }
  1060. void JIT::resetPatchPutById(RepatchBuffer& repatchBuffer, StructureStubInfo* stubInfo)
  1061. {
  1062. if (isDirectPutById(stubInfo))
  1063. repatchBuffer.relink(stubInfo->callReturnLocation, cti_op_put_by_id_direct);
  1064. else
  1065. repatchBuffer.relink(stubInfo->callReturnLocation, cti_op_put_by_id);
  1066. repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabelPtrAtOffset(stubInfo->patch.baseline.u.put.structureToCompare), reinterpret_cast<void*>(unusedPointer));
  1067. repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabel32AtOffset(stubInfo->patch.baseline.u.put.displacementLabel), 0);
  1068. }
  1069. #endif // USE(JSVALUE64)
  1070. void JIT::emitWriteBarrier(RegisterID owner, RegisterID value, RegisterID scratch, RegisterID scratch2, WriteBarrierMode mode, WriteBarrierUseKind useKind)
  1071. {
  1072. UNUSED_PARAM(owner);
  1073. UNUSED_PARAM(scratch);
  1074. UNUSED_PARAM(scratch2);
  1075. UNUSED_PARAM(useKind);
  1076. UNUSED_PARAM(value);
  1077. UNUSED_PARAM(mode);
  1078. ASSERT(owner != scratch);
  1079. ASSERT(owner != scratch2);
  1080. #if ENABLE(WRITE_BARRIER_PROFILING)
  1081. emitCount(WriteBarrierCounters::jitCounterFor(useKind));
  1082. #endif
  1083. }
  1084. void JIT::emitWriteBarrier(JSCell* owner, RegisterID value, RegisterID scratch, WriteBarrierMode mode, WriteBarrierUseKind useKind)
  1085. {
  1086. UNUSED_PARAM(owner);
  1087. UNUSED_PARAM(scratch);
  1088. UNUSED_PARAM(useKind);
  1089. UNUSED_PARAM(value);
  1090. UNUSED_PARAM(mode);
  1091. #if ENABLE(WRITE_BARRIER_PROFILING)
  1092. emitCount(WriteBarrierCounters::jitCounterFor(useKind));
  1093. #endif
  1094. }
  1095. JIT::Jump JIT::addStructureTransitionCheck(JSCell* object, Structure* structure, StructureStubInfo* stubInfo, RegisterID scratch)
  1096. {
  1097. if (object->structure() == structure && structure->transitionWatchpointSetIsStillValid()) {
  1098. structure->addTransitionWatchpoint(stubInfo->addWatchpoint(m_codeBlock));
  1099. #if !ASSERT_DISABLED
  1100. move(TrustedImmPtr(object), scratch);
  1101. Jump ok = branchPtr(Equal, Address(scratch, JSCell::structureOffset()), TrustedImmPtr(structure));
  1102. breakpoint();
  1103. ok.link(this);
  1104. #endif
  1105. Jump result; // Returning an unset jump this way because otherwise VC++ would complain.
  1106. return result;
  1107. }
  1108. move(TrustedImmPtr(object), scratch);
  1109. return branchPtr(NotEqual, Address(scratch, JSCell::structureOffset()), TrustedImmPtr(structure));
  1110. }
  1111. void JIT::addStructureTransitionCheck(JSCell* object, Structure* structure, StructureStubInfo* stubInfo, JumpList& failureCases, RegisterID scratch)
  1112. {
  1113. Jump failureCase = addStructureTransitionCheck(object, structure, stubInfo, scratch);
  1114. if (!failureCase.isSet())
  1115. return;
  1116. failureCases.append(failureCase);
  1117. }
  1118. void JIT::testPrototype(JSValue prototype, JumpList& failureCases, StructureStubInfo* stubInfo)
  1119. {
  1120. if (prototype.isNull())
  1121. return;
  1122. ASSERT(prototype.isCell());
  1123. addStructureTransitionCheck(prototype.asCell(), prototype.asCell()->structure(), stubInfo, failureCases, regT3);
  1124. }
  1125. bool JIT::isDirectPutById(StructureStubInfo* stubInfo)
  1126. {
  1127. switch (stubInfo->accessType) {
  1128. case access_put_by_id_transition_normal:
  1129. return false;
  1130. case access_put_by_id_transition_direct:
  1131. return true;
  1132. case access_put_by_id_replace:
  1133. case access_put_by_id_generic: {
  1134. void* oldCall = MacroAssembler::readCallTarget(stubInfo->callReturnLocation).executableAddress();
  1135. if (oldCall == bitwise_cast<void*>(cti_op_put_by_id_direct)
  1136. || oldCall == bitwise_cast<void*>(cti_op_put_by_id_direct_generic)
  1137. || oldCall == bitwise_cast<void*>(cti_op_put_by_id_direct_fail))
  1138. return true;
  1139. ASSERT(oldCall == bitwise_cast<void*>(cti_op_put_by_id)
  1140. || oldCall == bitwise_cast<void*>(cti_op_put_by_id_generic)
  1141. || oldCall == bitwise_cast<void*>(cti_op_put_by_id_fail));
  1142. return false;
  1143. }
  1144. default:
  1145. RELEASE_ASSERT_NOT_REACHED();
  1146. return false;
  1147. }
  1148. }
  1149. void JIT::privateCompileGetByVal(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
  1150. {
  1151. Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
  1152. PatchableJump badType;
  1153. JumpList slowCases;
  1154. switch (arrayMode) {
  1155. case JITInt32:
  1156. slowCases = emitInt32GetByVal(currentInstruction, badType);
  1157. break;
  1158. case JITDouble:
  1159. slowCases = emitDoubleGetByVal(currentInstruction, badType);
  1160. break;
  1161. case JITContiguous:
  1162. slowCases = emitContiguousGetByVal(currentInstruction, badType);
  1163. break;
  1164. case JITArrayStorage:
  1165. slowCases = emitArrayStorageGetByVal(currentInstruction, badType);
  1166. break;
  1167. case JITInt8Array:
  1168. slowCases = emitIntTypedArrayGetByVal(currentInstruction, badType, m_vm->int8ArrayDescriptor(), 1, SignedTypedArray);
  1169. break;
  1170. case JITInt16Array:
  1171. slowCases = emitIntTypedArrayGetByVal(currentInstruction, badType, m_vm->int16ArrayDescriptor(), 2, SignedTypedArray);
  1172. break;
  1173. case JITInt32Array:
  1174. slowCases = emitIntTypedArrayGetByVal(currentInstruction, badType, m_vm->int32ArrayDescriptor(), 4, SignedTypedArray);
  1175. break;
  1176. case JITUint8Array:
  1177. slowCases = emitIntTypedArrayGetByVal(currentInstruction, badType, m_vm->uint8ArrayDescriptor(), 1, UnsignedTypedArray);
  1178. break;
  1179. case JITUint8ClampedArray:
  1180. slowCases = emitIntTypedArrayGetByVal(currentInstruction, badType, m_vm->uint8ClampedArrayDescriptor(), 1, UnsignedTypedArray);
  1181. break;
  1182. case JITUint16Array:
  1183. slowCases = emitIntTypedArrayGetByVal(currentInstruction, badType, m_vm->uint16ArrayDescriptor(), 2, UnsignedTypedArray);
  1184. break;
  1185. case JITUint32Array:
  1186. slowCases = emitIntTypedArrayGetByVal(currentInstruction, badType, m_vm->uint32ArrayDescriptor(), 4, UnsignedTypedArray);
  1187. break;
  1188. case JITFloat32Array:
  1189. slowCases = emitFloatTypedArrayGetByVal(currentInstruction, badType, m_vm->float32ArrayDescriptor(), 4);
  1190. break;
  1191. case JITFloat64Array:
  1192. slowCases = emitFloatTypedArrayGetByVal(currentInstruction, badType, m_vm->float64ArrayDescriptor(), 8);
  1193. break;
  1194. default:
  1195. CRASH();
  1196. }
  1197. Jump done = jump();
  1198. LinkBuffer patchBuffer(*m_vm, this, m_codeBlock);
  1199. patchBuffer.link(badType, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
  1200. patchBuffer.link(slowCases, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
  1201. patchBuffer.link(done, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
  1202. byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
  1203. patchBuffer,
  1204. ("Baseline get_by_val stub for %s, return point %p", toCString(*m_codeBlock).data(), returnAddress.value()));
  1205. RepatchBuffer repatchBuffer(m_codeBlock);
  1206. repatchBuffer.relink(byValInfo->badTypeJump, CodeLocationLabel(byValInfo->stubRoutine->code().code()));
  1207. repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(cti_op_get_by_val_generic));
  1208. }
  1209. void JIT::privateCompilePutByVal(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
  1210. {
  1211. Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
  1212. PatchableJump badType;
  1213. JumpList slowCases;
  1214. switch (arrayMode) {
  1215. case JITInt32:
  1216. slowCases = emitInt32PutByVal(currentInstruction, badType);
  1217. break;
  1218. case JITDouble:
  1219. slowCases = emitDoublePutByVal(currentInstruction, badType);
  1220. break;
  1221. case JITContiguous:
  1222. slowCases = emitContiguousPutByVal(currentInstruction, badType);
  1223. break;
  1224. case JITArrayStorage:
  1225. slowCases = emitArrayStoragePutByVal(currentInstruction, badType);
  1226. break;
  1227. case JITInt8Array:
  1228. slowCases = emitIntTypedArrayPutByVal(currentInstruction, badType, m_vm->int8ArrayDescriptor(), 1, SignedTypedArray, TruncateRounding);
  1229. break;
  1230. case JITInt16Array:
  1231. slowCases = emitIntTypedArrayPutByVal(currentInstruction, badType, m_vm->int16ArrayDescriptor(), 2, SignedTypedArray, TruncateRounding);
  1232. break;
  1233. case JITInt32Array:
  1234. slowCases = emitIntTypedArrayPutByVal(currentInstruction, badType, m_vm->int32ArrayDescriptor(), 4, SignedTypedArray, TruncateRounding);
  1235. break;
  1236. case JITUint8Array:
  1237. slowCases = emitIntTypedArrayPutByVal(currentInstruction, badType, m_vm->uint8ArrayDescriptor(), 1, UnsignedTypedArray, TruncateRounding);
  1238. break;
  1239. case JITUint8ClampedArray:
  1240. slowCases = emitIntTypedArrayPutByVal(currentInstruction, badType, m_vm->uint8ClampedArrayDescriptor(), 1, UnsignedTypedArray, ClampRounding);
  1241. break;
  1242. case JITUint16Array:
  1243. slowCases = emitIntTypedArrayPutByVal(currentInstruction, badType, m_vm->uint16ArrayDescriptor(), 2, UnsignedTypedArray, TruncateRounding);
  1244. break;
  1245. case JITUint32Array:
  1246. slowCases = emitIntTypedArrayPutByVal(currentInstruction, badType, m_vm->uint32ArrayDescriptor(), 4, UnsignedTypedArray, TruncateRounding);
  1247. break;
  1248. case JITFloat32Array:
  1249. slowCases = emitFloatTypedArrayPutByVal(currentInstruction, badType, m_vm->float32ArrayDescriptor(), 4);
  1250. break;
  1251. case JITFloat64Array:
  1252. slowCases = emitFloatTypedArrayPutByVal(currentInstruction, badType, m_vm->float64ArrayDescriptor(), 8);
  1253. break;
  1254. default:
  1255. CRASH();
  1256. break;
  1257. }
  1258. Jump done = jump();
  1259. LinkBuffer patchBuffer(*m_vm, this, m_codeBlock);
  1260. patchBuffer.link(badType, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
  1261. patchBuffer.link(slowCases, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(returnAddress.value())).labelAtOffset(byValInfo->returnAddressToSlowPath));
  1262. patchBuffer.link(done, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone));
  1263. byValInfo->stubRoutine = FINALIZE_CODE_FOR_STUB(
  1264. patchBuffer,
  1265. ("Baseline put_by_val stub for %s, return point %p", toCString(*m_codeBlock).data(), returnAddress.value()));
  1266. RepatchBuffer repatchBuffer(m_codeBlock);
  1267. repatchBuffer.relink(byValInfo->badTypeJump, CodeLocationLabel(byValInfo->stubRoutine->code().code()));
  1268. repatchBuffer.relinkCallerToFunction(returnAddress, FunctionPtr(cti_op_put_by_val_generic));
  1269. }
  1270. JIT::JumpList JIT::emitIntTypedArrayGetByVal(Instruction*, PatchableJump& badType, const TypedArrayDescriptor& descriptor, size_t elementSize, TypedArraySignedness signedness)
  1271. {
  1272. // The best way to test the array type is to use the classInfo. We need to do so without
  1273. // clobbering the register that holds the indexing type, base, and property.
  1274. #if USE(JSVALUE64)
  1275. RegisterID base = regT0;
  1276. RegisterID property = regT1;
  1277. RegisterID resultPayload = regT0;
  1278. RegisterID scratch = regT3;
  1279. #else
  1280. RegisterID base = regT0;
  1281. RegisterID property = regT2;
  1282. RegisterID resultPayload = regT0;
  1283. RegisterID resultTag = regT1;
  1284. RegisterID scratch = regT3;
  1285. #endif
  1286. JumpList slowCases;
  1287. loadPtr(Address(base, JSCell::structureOffset()), scratch);
  1288. badType = patchableBranchPtr(NotEqual, Address(scratch, Structure::classInfoOffset()), TrustedImmPtr(descriptor.m_classInfo));
  1289. slowCases.append(branch32(AboveOrEqual, property, Address(base, descriptor.m_lengthOffset)));
  1290. loadPtr(Address(base, descriptor.m_storageOffset), base);
  1291. switch (elementSize) {
  1292. case 1:
  1293. if (signedness == SignedTypedArray)
  1294. load8Signed(BaseIndex(base, property, TimesOne), resultPayload);
  1295. else
  1296. load8(BaseIndex(base, property, TimesOne), resultPayload);
  1297. break;
  1298. case 2:
  1299. if (signedness == SignedTypedArray)
  1300. load16Signed(BaseIndex(base, property, TimesTwo), resultPayload);
  1301. else
  1302. load16(BaseIndex(base, property, TimesTwo), resultPayload);
  1303. break;
  1304. case 4:
  1305. load32(BaseIndex(base, property, TimesFour), resultPayload);
  1306. break;
  1307. default:
  1308. CRASH();
  1309. }
  1310. Jump done;
  1311. if (elementSize == 4 && signedness == UnsignedTypedArray) {
  1312. Jump canBeInt = branch32(GreaterThanOrEqual, resultPayload, TrustedImm32(0));
  1313. convertInt32ToDouble(resultPayload, fpRegT0);
  1314. DEFINE_REMOTE_VAR_PTR(double, twoToThe32);
  1315. addDouble(AbsoluteAddress(REMOTE_VAR_PTR(twoToThe32)), fpRegT0);
  1316. #if USE(JSVALUE64)
  1317. moveDoubleTo64(fpRegT0, resultPayload);
  1318. sub64(tagTypeNumberRegister, resultPayload);
  1319. #else
  1320. moveDoubleToInts(fpRegT0, resultPayload, resultTag);
  1321. #endif
  1322. done = jump();
  1323. canBeInt.link(this);
  1324. }
  1325. #if USE(JSVALUE64)
  1326. or64(tagTypeNumberRegister, resultPayload);
  1327. #else
  1328. move(TrustedImm32(JSValue::Int32Tag), resultTag);
  1329. #endif
  1330. if (done.isSet())
  1331. done.link(this);
  1332. return slowCases;
  1333. }
  1334. JIT::JumpList JIT::emitFloatTypedArrayGetByVal(Instruction*, PatchableJump& badType, const TypedArrayDescriptor& descriptor, size_t elementSize)
  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. JumpList slowCases;
  1349. loadPtr(Address(base, JSCell::structureOffset()), scratch);
  1350. badType = patchableBranchPtr(NotEqual, Address(scratch, Structure::classInfoOffset()), TrustedImmPtr(descriptor.m_classInfo));
  1351. slowCases.append(branch32(AboveOrEqual, property, Address(base, descriptor.m_lengthOffset)));
  1352. loadPtr(Address(base, descriptor.m_storageOffset), base);
  1353. switch (elementSize) {
  1354. case 4:
  1355. loadFloat(BaseIndex(base, property, TimesFour), fpRegT0);
  1356. convertFloatToDouble(fpRegT0, fpRegT0);
  1357. break;
  1358. case 8: {
  1359. loadDouble(BaseIndex(base, property, TimesEight), fpRegT0);
  1360. break;
  1361. }
  1362. default:
  1363. CRASH();
  1364. }
  1365. Jump notNaN = branchDouble(DoubleEqual, fpRegT0, fpRegT0);
  1366. #if 0 // moved to JITStubEntries.cpp
  1367. static const double NaN = QNaN;
  1368. #endif
  1369. DEFINE_REMOTE_VAR_PTR(double, NaN);
  1370. loadDouble(REMOTE_VAR_PTR(NaN), fpRegT0);
  1371. notNaN.link(this);
  1372. #if USE(JSVALUE64)
  1373. moveDoubleTo64(fpRegT0, resultPayload);
  1374. sub64(tagTypeNumberRegister, resultPayload);
  1375. #else
  1376. moveDoubleToInts(fpRegT0, resultPayload, resultTag);
  1377. #endif
  1378. return slowCases;
  1379. }
  1380. JIT::JumpList JIT::emitIntTypedArrayPutByVal(Instruction* currentInstruction, PatchableJump& badType, const TypedArrayDescriptor& descriptor, size_t elementSize, TypedArraySignedness signedness, TypedArrayRounding rounding)
  1381. {
  1382. unsigned value = currentInstruction[3].u.operand;
  1383. #if USE(JSVALUE64)
  1384. RegisterID base = regT0;
  1385. RegisterID property = regT1;
  1386. RegisterID earlyScratch = regT3;
  1387. RegisterID lateScratch = regT2;
  1388. #else
  1389. RegisterID base = regT0;
  1390. RegisterID property = regT2;
  1391. RegisterID earlyScratch = regT3;
  1392. RegisterID lateScratch = regT1;
  1393. #endif
  1394. JumpList slowCases;
  1395. loadPtr(Address(base, JSCell::structureOffset()), earlyScratch);
  1396. badType = patchableBranchPtr(NotEqual, Address(earlyScratch, Structure::classInfoOffset()), TrustedImmPtr(descriptor.m_classInfo));
  1397. slowCases.append(branch32(AboveOrEqual, property, Address(base, descriptor.m_lengthOffset)));
  1398. #if USE(JSVALUE64)
  1399. emitGetVirtualRegister(value, earlyScratch);
  1400. slowCases.append(emitJumpIfNotImmediateInteger(earlyScratch));
  1401. #else
  1402. emitLoad(value, lateScratch, earlyScratch);
  1403. slowCases.append(branch32(NotEqual, lateScratch, TrustedImm32(JSValue::Int32Tag)));
  1404. #endif
  1405. // We would be loading this into base as in get_by_val, except that the slow
  1406. // path expects the base to be unclobbered.
  1407. loadPtr(Address(base, descriptor.m_storageOffset), lateScratch);
  1408. if (rounding == ClampRounding) {
  1409. ASSERT(elementSize == 1);
  1410. ASSERT_UNUSED(signedness, signedness = UnsignedTypedArray);
  1411. Jump inBounds = branch32(BelowOrEqual, earlyScratch, TrustedImm32(0xff));
  1412. Jump tooBig = branch32(GreaterThan, earlyScratch, TrustedImm32(0xff));
  1413. xor32(earlyScratch, earlyScratch);
  1414. Jump clamped = jump();
  1415. tooBig.link(this);
  1416. move(TrustedImm32(0xff), earlyScratch);
  1417. clamped.link(this);
  1418. inBounds.link(this);
  1419. }
  1420. switch (elementSize) {
  1421. case 1:
  1422. store8(earlyScratch, BaseIndex(lateScratch, property, TimesOne));
  1423. break;
  1424. case 2:
  1425. store16(earlyScratch, BaseIndex(lateScratch, property, TimesTwo));
  1426. break;
  1427. case 4:
  1428. store32(earlyScratch, BaseIndex(lateScratch, property, TimesFour));
  1429. break;
  1430. default:
  1431. CRASH();
  1432. }
  1433. return slowCases;
  1434. }
  1435. JIT::JumpList JIT::emitFloatTypedArrayPutByVal(Instruction* currentInstruction, PatchableJump& badType, const TypedArrayDescriptor& descriptor, size_t elementSize)
  1436. {
  1437. unsigned value = currentInstruction[3].u.operand;
  1438. #if USE(JSVALUE64)
  1439. RegisterID base = regT0;
  1440. RegisterID property = regT1;
  1441. RegisterID earlyScratch = regT3;
  1442. RegisterID lateScratch = regT2;
  1443. #else
  1444. RegisterID base = regT0;
  1445. RegisterID property = regT2;
  1446. RegisterID earlyScratch = regT3;
  1447. RegisterID lateScratch = regT1;
  1448. #endif
  1449. JumpList slowCases;
  1450. loadPtr(Address(base, JSCell::structureOffset()), earlyScratch);
  1451. badType = patchableBranchPtr(NotEqual, Address(earlyScratch, Structure::classInfoOffset()), TrustedImmPtr(descriptor.m_classInfo));
  1452. slowCases.append(branch32(AboveOrEqual, property, Address(base, descriptor.m_lengthOffset)));
  1453. #if USE(JSVALUE64)
  1454. emitGetVirtualRegister(value, earlyScratch);
  1455. Jump doubleCase = emitJumpIfNotImmediateInteger(earlyScratch);
  1456. convertInt32ToDouble(earlyScratch, fpRegT0);
  1457. Jump ready = jump();
  1458. doubleCase.link(this);
  1459. slowCases.append(emitJumpIfNotImmediateNumber(earlyScratch));
  1460. add64(tagTypeNumberRegister, earlyScratch);
  1461. move64ToDouble(earlyScratch, fpRegT0);
  1462. ready.link(this);
  1463. #else
  1464. emitLoad(value, lateScratch, earlyScratch);
  1465. Jump doubleCase = branch32(NotEqual, lateScratch, TrustedImm32(JSValue::Int32Tag));
  1466. convertInt32ToDouble(earlyScratch, fpRegT0);
  1467. Jump ready = jump();
  1468. doubleCase.link(this);
  1469. slowCases.append(branch32(Above, lateScratch, TrustedImm32(JSValue::LowestTag)));
  1470. moveIntsToDouble(earlyScratch, lateScratch, fpRegT0, fpRegT1);
  1471. ready.link(this);
  1472. #endif
  1473. // We would be loading this into base as in get_by_val, except that the slow
  1474. // path expects the base to be unclobbered.
  1475. loadPtr(Address(base, descriptor.m_storageOffset), lateScratch);
  1476. switch (elementSize) {
  1477. case 4:
  1478. convertDoubleToFloat(fpRegT0, fpRegT0);
  1479. storeFloat(fpRegT0, BaseIndex(lateScratch, property, TimesFour));
  1480. break;
  1481. case 8:
  1482. storeDouble(fpRegT0, BaseIndex(lateScratch, property, TimesEight));
  1483. break;
  1484. default:
  1485. CRASH();
  1486. }
  1487. return slowCases;
  1488. }
  1489. } // namespace JSC
  1490. #endif // #if !(ENABLE(DETACHED_JIT) && !BUILDING_DETACHED_JIT)
  1491. #endif // ENABLE(JIT)