LLIntSlowPaths.cpp 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661
  1. /*
  2. * Copyright (C) 2011, 2012, 2013 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. #include "LLIntSlowPaths.h"
  27. #if ENABLE(LLINT)
  28. #include "Arguments.h"
  29. #include "ArrayConstructor.h"
  30. #include "CallFrame.h"
  31. #include "CommonSlowPaths.h"
  32. #include "GetterSetter.h"
  33. #include "HostCallReturnValue.h"
  34. #include "Interpreter.h"
  35. #include "JIT.h"
  36. #include "JITDriver.h"
  37. #include "JSActivation.h"
  38. #include "JSCJSValue.h"
  39. #include "JSGlobalObjectFunctions.h"
  40. #include "JSNameScope.h"
  41. #include "JSPropertyNameIterator.h"
  42. #include "JSString.h"
  43. #include "JSWithScope.h"
  44. #include "LLIntCommon.h"
  45. #include "LLIntExceptions.h"
  46. #include "LowLevelInterpreter.h"
  47. #include "ObjectConstructor.h"
  48. #include "Operations.h"
  49. #include "StructureRareDataInlines.h"
  50. #include <wtf/StringPrintStream.h>
  51. namespace JSC { namespace LLInt {
  52. #define LLINT_BEGIN_NO_SET_PC() \
  53. VM& vm = exec->vm(); \
  54. NativeCallFrameTracer tracer(&vm, exec)
  55. #ifndef NDEBUG
  56. #define LLINT_SET_PC_FOR_STUBS() do { \
  57. exec->codeBlock()->bytecodeOffset(pc); \
  58. exec->setCurrentVPC(pc + 1); \
  59. } while (false)
  60. #else
  61. #define LLINT_SET_PC_FOR_STUBS() do { \
  62. exec->setCurrentVPC(pc + 1); \
  63. } while (false)
  64. #endif
  65. #define LLINT_BEGIN() \
  66. LLINT_BEGIN_NO_SET_PC(); \
  67. LLINT_SET_PC_FOR_STUBS()
  68. #define LLINT_OP(index) (exec->uncheckedR(pc[index].u.operand))
  69. #define LLINT_OP_C(index) (exec->r(pc[index].u.operand))
  70. #define LLINT_RETURN_TWO(first, second) do { \
  71. return encodeResult(first, second); \
  72. } while (false)
  73. #define LLINT_END_IMPL() LLINT_RETURN_TWO(pc, exec)
  74. #define LLINT_THROW(exceptionToThrow) do { \
  75. vm.exception = (exceptionToThrow); \
  76. pc = returnToThrow(exec, pc); \
  77. LLINT_END_IMPL(); \
  78. } while (false)
  79. #define LLINT_CHECK_EXCEPTION() do { \
  80. if (UNLIKELY(vm.exception)) { \
  81. pc = returnToThrow(exec, pc); \
  82. LLINT_END_IMPL(); \
  83. } \
  84. } while (false)
  85. #define LLINT_END() do { \
  86. LLINT_CHECK_EXCEPTION(); \
  87. LLINT_END_IMPL(); \
  88. } while (false)
  89. #define LLINT_BRANCH(opcode, condition) do { \
  90. bool __b_condition = (condition); \
  91. LLINT_CHECK_EXCEPTION(); \
  92. if (__b_condition) \
  93. pc += pc[OPCODE_LENGTH(opcode) - 1].u.operand; \
  94. else \
  95. pc += OPCODE_LENGTH(opcode); \
  96. LLINT_END_IMPL(); \
  97. } while (false)
  98. #define LLINT_RETURN(value) do { \
  99. JSValue __r_returnValue = (value); \
  100. LLINT_CHECK_EXCEPTION(); \
  101. LLINT_OP(1) = __r_returnValue; \
  102. LLINT_END_IMPL(); \
  103. } while (false)
  104. #define LLINT_RETURN_WITH_PC_ADJUSTMENT(value, pcAdjustment) do { \
  105. JSValue __r_returnValue = (value); \
  106. LLINT_CHECK_EXCEPTION(); \
  107. LLINT_OP(1) = __r_returnValue; \
  108. pc += (pcAdjustment); \
  109. LLINT_END_IMPL(); \
  110. } while (false)
  111. #if ENABLE(VALUE_PROFILER)
  112. #define LLINT_RETURN_PROFILED(opcode, value) do { \
  113. JSValue __rp_returnValue = (value); \
  114. LLINT_CHECK_EXCEPTION(); \
  115. LLINT_OP(1) = __rp_returnValue; \
  116. LLINT_PROFILE_VALUE(opcode, __rp_returnValue); \
  117. LLINT_END_IMPL(); \
  118. } while (false)
  119. #define LLINT_PROFILE_VALUE(opcode, value) do { \
  120. pc[OPCODE_LENGTH(opcode) - 1].u.profile->m_buckets[0] = \
  121. JSValue::encode(value); \
  122. } while (false)
  123. #else // ENABLE(VALUE_PROFILER)
  124. #define LLINT_RETURN_PROFILED(opcode, value) LLINT_RETURN(value)
  125. #define LLINT_RETURN_WITH_PC_ADJUSTMENT(value, pcAdjustment) do { \
  126. #define LLINT_PROFILE_VALUE(opcode, value) do { } while (false)
  127. #endif // ENABLE(VALUE_PROFILER)
  128. #define LLINT_CALL_END_IMPL(exec, callTarget) LLINT_RETURN_TWO((callTarget), (exec))
  129. #define LLINT_CALL_THROW(exec, pc, exceptionToThrow) do { \
  130. ExecState* __ct_exec = (exec); \
  131. Instruction* __ct_pc = (pc); \
  132. vm.exception = (exceptionToThrow); \
  133. LLINT_CALL_END_IMPL(__ct_exec, callToThrow(__ct_exec, __ct_pc)); \
  134. } while (false)
  135. #define LLINT_CALL_CHECK_EXCEPTION(exec, pc) do { \
  136. ExecState* __cce_exec = (exec); \
  137. Instruction* __cce_pc = (pc); \
  138. if (UNLIKELY(vm.exception)) \
  139. LLINT_CALL_END_IMPL(__cce_exec, callToThrow(__cce_exec, __cce_pc)); \
  140. } while (false)
  141. #define LLINT_CALL_RETURN(exec, pc, callTarget) do { \
  142. ExecState* __cr_exec = (exec); \
  143. Instruction* __cr_pc = (pc); \
  144. void* __cr_callTarget = (callTarget); \
  145. LLINT_CALL_CHECK_EXCEPTION(__cr_exec->callerFrame(), __cr_pc); \
  146. LLINT_CALL_END_IMPL(__cr_exec, __cr_callTarget); \
  147. } while (false)
  148. extern "C" SlowPathReturnType llint_trace_operand(ExecState* exec, Instruction* pc, int fromWhere, int operand)
  149. {
  150. LLINT_BEGIN();
  151. dataLogF("%p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d\n",
  152. exec->codeBlock(),
  153. exec,
  154. static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
  155. exec->vm().interpreter->getOpcodeID(pc[0].u.opcode),
  156. fromWhere,
  157. operand,
  158. pc[operand].u.operand);
  159. LLINT_END();
  160. }
  161. extern "C" SlowPathReturnType llint_trace_value(ExecState* exec, Instruction* pc, int fromWhere, int operand)
  162. {
  163. JSValue value = LLINT_OP_C(operand).jsValue();
  164. union {
  165. struct {
  166. uint32_t tag;
  167. uint32_t payload;
  168. } bits;
  169. EncodedJSValue asValue;
  170. } u;
  171. u.asValue = JSValue::encode(value);
  172. dataLogF(
  173. "%p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d: %08x:%08x: %s\n",
  174. exec->codeBlock(),
  175. exec,
  176. static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
  177. exec->vm().interpreter->getOpcodeID(pc[0].u.opcode),
  178. fromWhere,
  179. operand,
  180. pc[operand].u.operand,
  181. u.bits.tag,
  182. u.bits.payload,
  183. toCString(value).data());
  184. LLINT_END_IMPL();
  185. }
  186. LLINT_SLOW_PATH_DECL(trace_prologue)
  187. {
  188. dataLogF("%p / %p: in prologue.\n", exec->codeBlock(), exec);
  189. LLINT_END_IMPL();
  190. }
  191. static void traceFunctionPrologue(ExecState* exec, const char* comment, CodeSpecializationKind kind)
  192. {
  193. JSFunction* callee = jsCast<JSFunction*>(exec->callee());
  194. FunctionExecutable* executable = callee->jsExecutable();
  195. CodeBlock* codeBlock = &executable->generatedBytecodeFor(kind);
  196. dataLogF("%p / %p: in %s of function %p, executable %p; numVars = %u, numParameters = %u, numCalleeRegisters = %u, caller = %p.\n",
  197. codeBlock, exec, comment, callee, executable,
  198. codeBlock->m_numVars, codeBlock->numParameters(), codeBlock->m_numCalleeRegisters,
  199. exec->callerFrame());
  200. }
  201. LLINT_SLOW_PATH_DECL(trace_prologue_function_for_call)
  202. {
  203. traceFunctionPrologue(exec, "call prologue", CodeForCall);
  204. LLINT_END_IMPL();
  205. }
  206. LLINT_SLOW_PATH_DECL(trace_prologue_function_for_construct)
  207. {
  208. traceFunctionPrologue(exec, "construct prologue", CodeForConstruct);
  209. LLINT_END_IMPL();
  210. }
  211. LLINT_SLOW_PATH_DECL(trace_arityCheck_for_call)
  212. {
  213. traceFunctionPrologue(exec, "call arity check", CodeForCall);
  214. LLINT_END_IMPL();
  215. }
  216. LLINT_SLOW_PATH_DECL(trace_arityCheck_for_construct)
  217. {
  218. traceFunctionPrologue(exec, "construct arity check", CodeForConstruct);
  219. LLINT_END_IMPL();
  220. }
  221. LLINT_SLOW_PATH_DECL(trace)
  222. {
  223. dataLogF("%p / %p: executing bc#%zu, %s, scope %p\n",
  224. exec->codeBlock(),
  225. exec,
  226. static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
  227. opcodeNames[exec->vm().interpreter->getOpcodeID(pc[0].u.opcode)],
  228. exec->scope());
  229. if (exec->vm().interpreter->getOpcodeID(pc[0].u.opcode) == op_ret) {
  230. dataLogF("Will be returning to %p\n", exec->returnPC().value());
  231. dataLogF("The new cfr will be %p\n", exec->callerFrame());
  232. }
  233. LLINT_END_IMPL();
  234. }
  235. LLINT_SLOW_PATH_DECL(special_trace)
  236. {
  237. dataLogF("%p / %p: executing special case bc#%zu, op#%u, return PC is %p\n",
  238. exec->codeBlock(),
  239. exec,
  240. static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
  241. exec->vm().interpreter->getOpcodeID(pc[0].u.opcode),
  242. exec->returnPC().value());
  243. LLINT_END_IMPL();
  244. }
  245. #if ENABLE(JIT)
  246. inline bool shouldJIT(ExecState* exec)
  247. {
  248. // You can modify this to turn off JITting without rebuilding the world.
  249. return exec->vm().canUseJIT();
  250. }
  251. // Returns true if we should try to OSR.
  252. inline bool jitCompileAndSetHeuristics(CodeBlock* codeBlock, ExecState* exec)
  253. {
  254. codeBlock->updateAllValueProfilePredictions();
  255. if (!codeBlock->checkIfJITThresholdReached()) {
  256. #if ENABLE(JIT_VERBOSE_OSR)
  257. dataLogF(" JIT threshold should be lifted.\n");
  258. #endif
  259. return false;
  260. }
  261. CodeBlock::JITCompilationResult result = codeBlock->jitCompile(exec);
  262. switch (result) {
  263. case CodeBlock::AlreadyCompiled:
  264. #if ENABLE(JIT_VERBOSE_OSR)
  265. dataLogF(" Code was already compiled.\n");
  266. #endif
  267. codeBlock->jitSoon();
  268. return true;
  269. case CodeBlock::CouldNotCompile:
  270. #if ENABLE(JIT_VERBOSE_OSR)
  271. dataLogF(" JIT compilation failed.\n");
  272. #endif
  273. codeBlock->dontJITAnytimeSoon();
  274. return false;
  275. case CodeBlock::CompiledSuccessfully:
  276. #if ENABLE(JIT_VERBOSE_OSR)
  277. dataLogF(" JIT compilation successful.\n");
  278. #endif
  279. codeBlock->jitSoon();
  280. return true;
  281. }
  282. RELEASE_ASSERT_NOT_REACHED();
  283. return false;
  284. }
  285. enum EntryKind { Prologue, ArityCheck };
  286. static SlowPathReturnType entryOSR(ExecState* exec, Instruction*, CodeBlock* codeBlock, const char *name, EntryKind kind)
  287. {
  288. #if ENABLE(JIT_VERBOSE_OSR)
  289. dataLog(*codeBlock, ": Entered ", name, " with executeCounter = ", codeBlock->llintExecuteCounter(), "\n");
  290. #else
  291. UNUSED_PARAM(name);
  292. #endif
  293. if (!shouldJIT(exec)) {
  294. codeBlock->dontJITAnytimeSoon();
  295. LLINT_RETURN_TWO(0, exec);
  296. }
  297. if (!jitCompileAndSetHeuristics(codeBlock, exec))
  298. LLINT_RETURN_TWO(0, exec);
  299. if (kind == Prologue)
  300. LLINT_RETURN_TWO(codeBlock->getJITCode().executableAddressAtOffset(0), exec);
  301. ASSERT(kind == ArityCheck);
  302. LLINT_RETURN_TWO(codeBlock->getJITCodeWithArityCheck().executableAddress(), exec);
  303. }
  304. LLINT_SLOW_PATH_DECL(entry_osr)
  305. {
  306. return entryOSR(exec, pc, exec->codeBlock(), "entry_osr", Prologue);
  307. }
  308. LLINT_SLOW_PATH_DECL(entry_osr_function_for_call)
  309. {
  310. return entryOSR(exec, pc, &jsCast<JSFunction*>(exec->callee())->jsExecutable()->generatedBytecodeFor(CodeForCall), "entry_osr_function_for_call", Prologue);
  311. }
  312. LLINT_SLOW_PATH_DECL(entry_osr_function_for_construct)
  313. {
  314. return entryOSR(exec, pc, &jsCast<JSFunction*>(exec->callee())->jsExecutable()->generatedBytecodeFor(CodeForConstruct), "entry_osr_function_for_construct", Prologue);
  315. }
  316. LLINT_SLOW_PATH_DECL(entry_osr_function_for_call_arityCheck)
  317. {
  318. return entryOSR(exec, pc, &jsCast<JSFunction*>(exec->callee())->jsExecutable()->generatedBytecodeFor(CodeForCall), "entry_osr_function_for_call_arityCheck", ArityCheck);
  319. }
  320. LLINT_SLOW_PATH_DECL(entry_osr_function_for_construct_arityCheck)
  321. {
  322. return entryOSR(exec, pc, &jsCast<JSFunction*>(exec->callee())->jsExecutable()->generatedBytecodeFor(CodeForConstruct), "entry_osr_function_for_construct_arityCheck", ArityCheck);
  323. }
  324. LLINT_SLOW_PATH_DECL(loop_osr)
  325. {
  326. CodeBlock* codeBlock = exec->codeBlock();
  327. #if ENABLE(JIT_VERBOSE_OSR)
  328. dataLog(*codeBlock, ": Entered loop_osr with executeCounter = ", codeBlock->llintExecuteCounter(), "\n");
  329. #endif
  330. if (!shouldJIT(exec)) {
  331. codeBlock->dontJITAnytimeSoon();
  332. LLINT_RETURN_TWO(0, exec);
  333. }
  334. if (!jitCompileAndSetHeuristics(codeBlock, exec))
  335. LLINT_RETURN_TWO(0, exec);
  336. ASSERT(codeBlock->getJITType() == JITCode::BaselineJIT);
  337. Vector<BytecodeAndMachineOffset> map;
  338. codeBlock->jitCodeMap()->decode(map);
  339. BytecodeAndMachineOffset* mapping = binarySearch<BytecodeAndMachineOffset, unsigned>(map, map.size(), pc - codeBlock->instructions().begin(), BytecodeAndMachineOffset::getBytecodeIndex);
  340. ASSERT(mapping);
  341. ASSERT(mapping->m_bytecodeIndex == static_cast<unsigned>(pc - codeBlock->instructions().begin()));
  342. void* jumpTarget = codeBlock->getJITCode().executableAddressAtOffset(mapping->m_machineCodeOffset);
  343. ASSERT(jumpTarget);
  344. LLINT_RETURN_TWO(jumpTarget, exec);
  345. }
  346. LLINT_SLOW_PATH_DECL(replace)
  347. {
  348. CodeBlock* codeBlock = exec->codeBlock();
  349. #if ENABLE(JIT_VERBOSE_OSR)
  350. dataLog(*codeBlock, ": Entered replace with executeCounter = ", codeBlock->llintExecuteCounter(), "\n");
  351. #endif
  352. if (shouldJIT(exec))
  353. jitCompileAndSetHeuristics(codeBlock, exec);
  354. else
  355. codeBlock->dontJITAnytimeSoon();
  356. LLINT_END_IMPL();
  357. }
  358. #endif // ENABLE(JIT)
  359. LLINT_SLOW_PATH_DECL(stack_check)
  360. {
  361. LLINT_BEGIN();
  362. #if LLINT_SLOW_PATH_TRACING
  363. dataLogF("Checking stack height with exec = %p.\n", exec);
  364. dataLogF("CodeBlock = %p.\n", exec->codeBlock());
  365. dataLogF("Num callee registers = %u.\n", exec->codeBlock()->m_numCalleeRegisters);
  366. dataLogF("Num vars = %u.\n", exec->codeBlock()->m_numVars);
  367. dataLogF("Current end is at %p.\n", exec->vm().interpreter->stack().end());
  368. #endif
  369. ASSERT(&exec->registers()[exec->codeBlock()->m_numCalleeRegisters] > exec->vm().interpreter->stack().end());
  370. if (UNLIKELY(!vm.interpreter->stack().grow(&exec->registers()[exec->codeBlock()->m_numCalleeRegisters]))) {
  371. ReturnAddressPtr returnPC = exec->returnPC();
  372. exec = exec->callerFrame();
  373. vm.exception = createStackOverflowError(exec);
  374. interpreterThrowInCaller(exec, returnPC);
  375. pc = returnToThrowForThrownException(exec);
  376. }
  377. LLINT_END_IMPL();
  378. }
  379. LLINT_SLOW_PATH_DECL(slow_path_call_arityCheck)
  380. {
  381. LLINT_BEGIN();
  382. ExecState* newExec = CommonSlowPaths::arityCheckFor(exec, &vm.interpreter->stack(), CodeForCall);
  383. if (!newExec) {
  384. ReturnAddressPtr returnPC = exec->returnPC();
  385. exec = exec->callerFrame();
  386. vm.exception = createStackOverflowError(exec);
  387. interpreterThrowInCaller(exec, returnPC);
  388. LLINT_RETURN_TWO(bitwise_cast<void*>(static_cast<uintptr_t>(1)), exec);
  389. }
  390. LLINT_RETURN_TWO(0, newExec);
  391. }
  392. LLINT_SLOW_PATH_DECL(slow_path_construct_arityCheck)
  393. {
  394. LLINT_BEGIN();
  395. ExecState* newExec = CommonSlowPaths::arityCheckFor(exec, &vm.interpreter->stack(), CodeForConstruct);
  396. if (!newExec) {
  397. ReturnAddressPtr returnPC = exec->returnPC();
  398. exec = exec->callerFrame();
  399. vm.exception = createStackOverflowError(exec);
  400. interpreterThrowInCaller(exec, returnPC);
  401. LLINT_RETURN_TWO(bitwise_cast<void*>(static_cast<uintptr_t>(1)), exec);
  402. }
  403. LLINT_RETURN_TWO(0, newExec);
  404. }
  405. LLINT_SLOW_PATH_DECL(slow_path_create_activation)
  406. {
  407. LLINT_BEGIN();
  408. #if LLINT_SLOW_PATH_TRACING
  409. dataLogF("Creating an activation, exec = %p!\n", exec);
  410. #endif
  411. JSActivation* activation = JSActivation::create(vm, exec, exec->codeBlock());
  412. exec->setScope(activation);
  413. LLINT_RETURN(JSValue(activation));
  414. }
  415. LLINT_SLOW_PATH_DECL(slow_path_create_arguments)
  416. {
  417. LLINT_BEGIN();
  418. JSValue arguments = JSValue(Arguments::create(vm, exec));
  419. LLINT_CHECK_EXCEPTION();
  420. exec->uncheckedR(pc[1].u.operand) = arguments;
  421. exec->uncheckedR(unmodifiedArgumentsRegister(pc[1].u.operand)) = arguments;
  422. LLINT_END();
  423. }
  424. LLINT_SLOW_PATH_DECL(slow_path_create_this)
  425. {
  426. LLINT_BEGIN();
  427. JSFunction* constructor = jsCast<JSFunction*>(LLINT_OP(2).jsValue().asCell());
  428. #if !ASSERT_DISABLED
  429. ConstructData constructData;
  430. ASSERT(constructor->methodTable()->getConstructData(constructor, constructData) == ConstructTypeJS);
  431. #endif
  432. size_t inlineCapacity = pc[3].u.operand;
  433. Structure* structure = constructor->allocationProfile(exec, inlineCapacity)->structure();
  434. LLINT_RETURN(constructEmptyObject(exec, structure));
  435. }
  436. LLINT_SLOW_PATH_DECL(slow_path_convert_this)
  437. {
  438. LLINT_BEGIN();
  439. JSValue v1 = LLINT_OP(1).jsValue();
  440. ASSERT(v1.isPrimitive());
  441. #if ENABLE(VALUE_PROFILER)
  442. pc[OPCODE_LENGTH(op_convert_this) - 1].u.profile->m_buckets[0] =
  443. JSValue::encode(v1.structureOrUndefined());
  444. #endif
  445. LLINT_RETURN(v1.toThisObject(exec));
  446. }
  447. LLINT_SLOW_PATH_DECL(slow_path_new_object)
  448. {
  449. LLINT_BEGIN();
  450. LLINT_RETURN(constructEmptyObject(exec, pc[3].u.objectAllocationProfile->structure()));
  451. }
  452. LLINT_SLOW_PATH_DECL(slow_path_new_array)
  453. {
  454. LLINT_BEGIN();
  455. LLINT_RETURN(constructArray(exec, pc[4].u.arrayAllocationProfile, bitwise_cast<JSValue*>(&LLINT_OP(2)), pc[3].u.operand));
  456. }
  457. LLINT_SLOW_PATH_DECL(slow_path_new_array_with_size)
  458. {
  459. LLINT_BEGIN();
  460. LLINT_RETURN(constructArrayWithSizeQuirk(exec, pc[3].u.arrayAllocationProfile, exec->lexicalGlobalObject(), LLINT_OP_C(2).jsValue()));
  461. }
  462. LLINT_SLOW_PATH_DECL(slow_path_new_array_buffer)
  463. {
  464. LLINT_BEGIN();
  465. LLINT_RETURN(constructArray(exec, pc[4].u.arrayAllocationProfile, exec->codeBlock()->constantBuffer(pc[2].u.operand), pc[3].u.operand));
  466. }
  467. LLINT_SLOW_PATH_DECL(slow_path_new_regexp)
  468. {
  469. LLINT_BEGIN();
  470. RegExp* regExp = exec->codeBlock()->regexp(pc[2].u.operand);
  471. if (!regExp->isValid())
  472. LLINT_THROW(createSyntaxError(exec, "Invalid flag supplied to RegExp constructor."));
  473. LLINT_RETURN(RegExpObject::create(vm, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regExp));
  474. }
  475. LLINT_SLOW_PATH_DECL(slow_path_not)
  476. {
  477. LLINT_BEGIN();
  478. LLINT_RETURN(jsBoolean(!LLINT_OP_C(2).jsValue().toBoolean(exec)));
  479. }
  480. LLINT_SLOW_PATH_DECL(slow_path_eq)
  481. {
  482. LLINT_BEGIN();
  483. LLINT_RETURN(jsBoolean(JSValue::equal(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(3).jsValue())));
  484. }
  485. LLINT_SLOW_PATH_DECL(slow_path_neq)
  486. {
  487. LLINT_BEGIN();
  488. LLINT_RETURN(jsBoolean(!JSValue::equal(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(3).jsValue())));
  489. }
  490. LLINT_SLOW_PATH_DECL(slow_path_stricteq)
  491. {
  492. LLINT_BEGIN();
  493. LLINT_RETURN(jsBoolean(JSValue::strictEqual(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(3).jsValue())));
  494. }
  495. LLINT_SLOW_PATH_DECL(slow_path_nstricteq)
  496. {
  497. LLINT_BEGIN();
  498. LLINT_RETURN(jsBoolean(!JSValue::strictEqual(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(3).jsValue())));
  499. }
  500. LLINT_SLOW_PATH_DECL(slow_path_less)
  501. {
  502. LLINT_BEGIN();
  503. LLINT_RETURN(jsBoolean(jsLess<true>(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(3).jsValue())));
  504. }
  505. LLINT_SLOW_PATH_DECL(slow_path_lesseq)
  506. {
  507. LLINT_BEGIN();
  508. LLINT_RETURN(jsBoolean(jsLessEq<true>(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(3).jsValue())));
  509. }
  510. LLINT_SLOW_PATH_DECL(slow_path_greater)
  511. {
  512. LLINT_BEGIN();
  513. LLINT_RETURN(jsBoolean(jsLess<false>(exec, LLINT_OP_C(3).jsValue(), LLINT_OP_C(2).jsValue())));
  514. }
  515. LLINT_SLOW_PATH_DECL(slow_path_greatereq)
  516. {
  517. LLINT_BEGIN();
  518. LLINT_RETURN(jsBoolean(jsLessEq<false>(exec, LLINT_OP_C(3).jsValue(), LLINT_OP_C(2).jsValue())));
  519. }
  520. LLINT_SLOW_PATH_DECL(slow_path_pre_inc)
  521. {
  522. LLINT_BEGIN();
  523. LLINT_RETURN(jsNumber(LLINT_OP(1).jsValue().toNumber(exec) + 1));
  524. }
  525. LLINT_SLOW_PATH_DECL(slow_path_pre_dec)
  526. {
  527. LLINT_BEGIN();
  528. LLINT_RETURN(jsNumber(LLINT_OP(1).jsValue().toNumber(exec) - 1));
  529. }
  530. LLINT_SLOW_PATH_DECL(slow_path_to_number)
  531. {
  532. LLINT_BEGIN();
  533. LLINT_RETURN(jsNumber(LLINT_OP_C(2).jsValue().toNumber(exec)));
  534. }
  535. LLINT_SLOW_PATH_DECL(slow_path_negate)
  536. {
  537. LLINT_BEGIN();
  538. LLINT_RETURN(jsNumber(-LLINT_OP_C(2).jsValue().toNumber(exec)));
  539. }
  540. LLINT_SLOW_PATH_DECL(slow_path_add)
  541. {
  542. LLINT_BEGIN();
  543. JSValue v1 = LLINT_OP_C(2).jsValue();
  544. JSValue v2 = LLINT_OP_C(3).jsValue();
  545. #if LLINT_SLOW_PATH_TRACING
  546. dataLog("Trying to add ", v1, " to ", v2, ".\n");
  547. #endif
  548. if (v1.isString() && !v2.isObject())
  549. LLINT_RETURN(jsString(exec, asString(v1), v2.toString(exec)));
  550. if (v1.isNumber() && v2.isNumber())
  551. LLINT_RETURN(jsNumber(v1.asNumber() + v2.asNumber()));
  552. LLINT_RETURN(jsAddSlowCase(exec, v1, v2));
  553. }
  554. // The following arithmetic and bitwise operations need to be sure to run
  555. // toNumber() on their operands in order. (A call to toNumber() is idempotent
  556. // if an exception is already set on the ExecState.)
  557. LLINT_SLOW_PATH_DECL(slow_path_mul)
  558. {
  559. LLINT_BEGIN();
  560. double a = LLINT_OP_C(2).jsValue().toNumber(exec);
  561. double b = LLINT_OP_C(3).jsValue().toNumber(exec);
  562. LLINT_RETURN(jsNumber(a * b));
  563. }
  564. LLINT_SLOW_PATH_DECL(slow_path_sub)
  565. {
  566. LLINT_BEGIN();
  567. double a = LLINT_OP_C(2).jsValue().toNumber(exec);
  568. double b = LLINT_OP_C(3).jsValue().toNumber(exec);
  569. LLINT_RETURN(jsNumber(a - b));
  570. }
  571. LLINT_SLOW_PATH_DECL(slow_path_div)
  572. {
  573. LLINT_BEGIN();
  574. double a = LLINT_OP_C(2).jsValue().toNumber(exec);
  575. double b = LLINT_OP_C(3).jsValue().toNumber(exec);
  576. LLINT_RETURN(jsNumber(a / b));
  577. }
  578. LLINT_SLOW_PATH_DECL(slow_path_mod)
  579. {
  580. LLINT_BEGIN();
  581. double a = LLINT_OP_C(2).jsValue().toNumber(exec);
  582. double b = LLINT_OP_C(3).jsValue().toNumber(exec);
  583. LLINT_RETURN(jsNumber(fmod(a, b)));
  584. }
  585. LLINT_SLOW_PATH_DECL(slow_path_lshift)
  586. {
  587. LLINT_BEGIN();
  588. int32_t a = LLINT_OP_C(2).jsValue().toInt32(exec);
  589. uint32_t b = LLINT_OP_C(3).jsValue().toUInt32(exec);
  590. LLINT_RETURN(jsNumber(a << (b & 31)));
  591. }
  592. LLINT_SLOW_PATH_DECL(slow_path_rshift)
  593. {
  594. LLINT_BEGIN();
  595. int32_t a = LLINT_OP_C(2).jsValue().toInt32(exec);
  596. uint32_t b = LLINT_OP_C(3).jsValue().toUInt32(exec);
  597. LLINT_RETURN(jsNumber(a >> (b & 31)));
  598. }
  599. LLINT_SLOW_PATH_DECL(slow_path_urshift)
  600. {
  601. LLINT_BEGIN();
  602. uint32_t a = LLINT_OP_C(2).jsValue().toUInt32(exec);
  603. uint32_t b = LLINT_OP_C(3).jsValue().toUInt32(exec);
  604. LLINT_RETURN(jsNumber(a >> (b & 31)));
  605. }
  606. LLINT_SLOW_PATH_DECL(slow_path_bitand)
  607. {
  608. LLINT_BEGIN();
  609. int32_t a = LLINT_OP_C(2).jsValue().toInt32(exec);
  610. int32_t b = LLINT_OP_C(3).jsValue().toInt32(exec);
  611. LLINT_RETURN(jsNumber(a & b));
  612. }
  613. LLINT_SLOW_PATH_DECL(slow_path_bitor)
  614. {
  615. LLINT_BEGIN();
  616. int32_t a = LLINT_OP_C(2).jsValue().toInt32(exec);
  617. int32_t b = LLINT_OP_C(3).jsValue().toInt32(exec);
  618. LLINT_RETURN(jsNumber(a | b));
  619. }
  620. LLINT_SLOW_PATH_DECL(slow_path_bitxor)
  621. {
  622. LLINT_BEGIN();
  623. int32_t a = LLINT_OP_C(2).jsValue().toInt32(exec);
  624. int32_t b = LLINT_OP_C(3).jsValue().toInt32(exec);
  625. LLINT_RETURN(jsNumber(a ^ b));
  626. }
  627. LLINT_SLOW_PATH_DECL(slow_path_check_has_instance)
  628. {
  629. LLINT_BEGIN();
  630. JSValue value = LLINT_OP_C(2).jsValue();
  631. JSValue baseVal = LLINT_OP_C(3).jsValue();
  632. if (baseVal.isObject()) {
  633. JSObject* baseObject = asObject(baseVal);
  634. ASSERT(!baseObject->structure()->typeInfo().implementsDefaultHasInstance());
  635. if (baseObject->structure()->typeInfo().implementsHasInstance()) {
  636. JSValue result = jsBoolean(baseObject->methodTable()->customHasInstance(baseObject, exec, value));
  637. LLINT_RETURN_WITH_PC_ADJUSTMENT(result, pc[4].u.operand);
  638. }
  639. }
  640. LLINT_THROW(createInvalidParamError(exec, "instanceof", baseVal));
  641. }
  642. LLINT_SLOW_PATH_DECL(slow_path_instanceof)
  643. {
  644. LLINT_BEGIN();
  645. JSValue value = LLINT_OP_C(2).jsValue();
  646. JSValue proto = LLINT_OP_C(3).jsValue();
  647. ASSERT(!value.isObject() || !proto.isObject());
  648. LLINT_RETURN(jsBoolean(JSObject::defaultHasInstance(exec, value, proto)));
  649. }
  650. LLINT_SLOW_PATH_DECL(slow_path_typeof)
  651. {
  652. LLINT_BEGIN();
  653. LLINT_RETURN(jsTypeStringForValue(exec, LLINT_OP_C(2).jsValue()));
  654. }
  655. LLINT_SLOW_PATH_DECL(slow_path_is_object)
  656. {
  657. LLINT_BEGIN();
  658. LLINT_RETURN(jsBoolean(jsIsObjectType(exec, LLINT_OP_C(2).jsValue())));
  659. }
  660. LLINT_SLOW_PATH_DECL(slow_path_is_function)
  661. {
  662. LLINT_BEGIN();
  663. LLINT_RETURN(jsBoolean(jsIsFunctionType(LLINT_OP_C(2).jsValue())));
  664. }
  665. LLINT_SLOW_PATH_DECL(slow_path_in)
  666. {
  667. LLINT_BEGIN();
  668. LLINT_RETURN(jsBoolean(CommonSlowPaths::opIn(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(3).jsValue())));
  669. }
  670. LLINT_SLOW_PATH_DECL(slow_path_resolve)
  671. {
  672. LLINT_BEGIN();
  673. Identifier ident = exec->codeBlock()->identifier(pc[2].u.operand);
  674. ResolveOperations* operations = pc[3].u.resolveOperations;
  675. JSValue result = JSScope::resolve(exec, ident, operations);
  676. ASSERT(operations->size());
  677. if (operations->isEmpty())
  678. LLINT_RETURN_PROFILED(op_resolve, result);
  679. switch (operations->data()[0].m_operation) {
  680. case ResolveOperation::GetAndReturnGlobalProperty:
  681. pc[0].u.opcode = LLInt::getOpcode(llint_op_resolve_global_property);
  682. break;
  683. case ResolveOperation::GetAndReturnGlobalVar:
  684. pc[0].u.opcode = LLInt::getOpcode(llint_op_resolve_global_var);
  685. break;
  686. case ResolveOperation::SkipTopScopeNode:
  687. pc[0].u.opcode = LLInt::getOpcode(llint_op_resolve_scoped_var_with_top_scope_check);
  688. break;
  689. case ResolveOperation::SkipScopes:
  690. if (operations->data()[0].m_scopesToSkip)
  691. pc[0].u.opcode = LLInt::getOpcode(llint_op_resolve_scoped_var);
  692. else
  693. pc[0].u.opcode = LLInt::getOpcode(llint_op_resolve_scoped_var_on_top_scope);
  694. break;
  695. default:
  696. break;
  697. }
  698. LLINT_RETURN_PROFILED(op_resolve, result);
  699. }
  700. LLINT_SLOW_PATH_DECL(slow_path_put_to_base)
  701. {
  702. LLINT_BEGIN();
  703. PutToBaseOperation* operation = pc[4].u.putToBaseOperation;
  704. JSScope::resolvePut(exec, LLINT_OP_C(1).jsValue(), exec->codeBlock()->identifier(pc[2].u.operand), LLINT_OP_C(3).jsValue(), operation);
  705. switch (operation->m_kind) {
  706. case PutToBaseOperation::VariablePut:
  707. pc[0].u.opcode = LLInt::getOpcode(llint_op_put_to_base_variable);
  708. break;
  709. default:
  710. break;
  711. }
  712. LLINT_END();
  713. }
  714. LLINT_SLOW_PATH_DECL(slow_path_resolve_base)
  715. {
  716. LLINT_BEGIN();
  717. Identifier& ident = exec->codeBlock()->identifier(pc[2].u.operand);
  718. ResolveOperations* operations = pc[4].u.resolveOperations;
  719. JSValue result;
  720. if (pc[3].u.operand) {
  721. result = JSScope::resolveBase(exec, ident, true, operations, pc[5].u.putToBaseOperation);
  722. if (!result)
  723. LLINT_THROW(vm.exception);
  724. } else
  725. result = JSScope::resolveBase(exec, ident, false, operations, pc[5].u.putToBaseOperation);
  726. ASSERT(operations->size());
  727. if (operations->isEmpty()) {
  728. LLINT_PROFILE_VALUE(op_resolve_base, result);
  729. LLINT_RETURN(result);
  730. }
  731. switch (operations->data()[0].m_operation) {
  732. case ResolveOperation::ReturnGlobalObjectAsBase:
  733. pc[0].u.opcode = LLInt::getOpcode(llint_op_resolve_base_to_global);
  734. break;
  735. case ResolveOperation::SkipTopScopeNode:
  736. pc[0].u.opcode = LLInt::getOpcode(llint_op_resolve_base_to_scope_with_top_scope_check);
  737. break;
  738. case ResolveOperation::SkipScopes:
  739. pc[0].u.opcode = LLInt::getOpcode(llint_op_resolve_base_to_scope);
  740. break;
  741. default:
  742. break;
  743. }
  744. LLINT_PROFILE_VALUE(op_resolve_base, result);
  745. LLINT_RETURN(result);
  746. }
  747. LLINT_SLOW_PATH_DECL(slow_path_resolve_with_base)
  748. {
  749. LLINT_BEGIN();
  750. ResolveOperations* operations = pc[4].u.resolveOperations;
  751. JSValue result = JSScope::resolveWithBase(exec, exec->codeBlock()->identifier(pc[3].u.operand), &LLINT_OP(1), operations, pc[5].u.putToBaseOperation);
  752. LLINT_CHECK_EXCEPTION();
  753. LLINT_OP(2) = result;
  754. LLINT_PROFILE_VALUE(op_resolve_with_base, result);
  755. LLINT_END();
  756. }
  757. LLINT_SLOW_PATH_DECL(slow_path_resolve_with_this)
  758. {
  759. LLINT_BEGIN();
  760. ResolveOperations* operations = pc[4].u.resolveOperations;
  761. JSValue result = JSScope::resolveWithThis(exec, exec->codeBlock()->identifier(pc[3].u.operand), &LLINT_OP(1), operations);
  762. LLINT_CHECK_EXCEPTION();
  763. LLINT_OP(2) = result;
  764. LLINT_PROFILE_VALUE(op_resolve_with_this, result);
  765. LLINT_END();
  766. }
  767. LLINT_SLOW_PATH_DECL(slow_path_init_global_const_check)
  768. {
  769. LLINT_BEGIN();
  770. CodeBlock* codeBlock = exec->codeBlock();
  771. symbolTablePut(codeBlock->globalObject(), exec, codeBlock->identifier(pc[4].u.operand), LLINT_OP_C(2).jsValue(), true);
  772. LLINT_END();
  773. }
  774. LLINT_SLOW_PATH_DECL(slow_path_get_by_id)
  775. {
  776. LLINT_BEGIN();
  777. CodeBlock* codeBlock = exec->codeBlock();
  778. Identifier& ident = codeBlock->identifier(pc[3].u.operand);
  779. JSValue baseValue = LLINT_OP_C(2).jsValue();
  780. PropertySlot slot(baseValue);
  781. JSValue result = baseValue.get(exec, ident, slot);
  782. LLINT_CHECK_EXCEPTION();
  783. LLINT_OP(1) = result;
  784. if (!LLINT_ALWAYS_ACCESS_SLOW
  785. && baseValue.isCell()
  786. && slot.isCacheable()
  787. && slot.slotBase() == baseValue
  788. && slot.cachedPropertyType() == PropertySlot::Value) {
  789. JSCell* baseCell = baseValue.asCell();
  790. Structure* structure = baseCell->structure();
  791. if (!structure->isUncacheableDictionary()
  792. && !structure->typeInfo().prohibitsPropertyCaching()) {
  793. pc[4].u.structure.set(
  794. vm, codeBlock->ownerExecutable(), structure);
  795. if (isInlineOffset(slot.cachedOffset())) {
  796. pc[0].u.opcode = LLInt::getOpcode(llint_op_get_by_id);
  797. pc[5].u.operand = offsetInInlineStorage(slot.cachedOffset()) * sizeof(JSValue) + JSObject::offsetOfInlineStorage();
  798. } else {
  799. pc[0].u.opcode = LLInt::getOpcode(llint_op_get_by_id_out_of_line);
  800. pc[5].u.operand = offsetInButterfly(slot.cachedOffset()) * sizeof(JSValue);
  801. }
  802. }
  803. }
  804. if (!LLINT_ALWAYS_ACCESS_SLOW
  805. && isJSArray(baseValue)
  806. && ident == exec->propertyNames().length) {
  807. pc[0].u.opcode = LLInt::getOpcode(llint_op_get_array_length);
  808. #if ENABLE(VALUE_PROFILER)
  809. ArrayProfile* arrayProfile = codeBlock->getOrAddArrayProfile(pc - codeBlock->instructions().begin());
  810. arrayProfile->observeStructure(baseValue.asCell()->structure());
  811. pc[4].u.arrayProfile = arrayProfile;
  812. #endif
  813. }
  814. #if ENABLE(VALUE_PROFILER)
  815. pc[OPCODE_LENGTH(op_get_by_id) - 1].u.profile->m_buckets[0] = JSValue::encode(result);
  816. #endif
  817. LLINT_END();
  818. }
  819. LLINT_SLOW_PATH_DECL(slow_path_get_arguments_length)
  820. {
  821. LLINT_BEGIN();
  822. CodeBlock* codeBlock = exec->codeBlock();
  823. Identifier& ident = codeBlock->identifier(pc[3].u.operand);
  824. JSValue baseValue = LLINT_OP(2).jsValue();
  825. PropertySlot slot(baseValue);
  826. LLINT_RETURN(baseValue.get(exec, ident, slot));
  827. }
  828. LLINT_SLOW_PATH_DECL(slow_path_put_by_id)
  829. {
  830. LLINT_BEGIN();
  831. CodeBlock* codeBlock = exec->codeBlock();
  832. Identifier& ident = codeBlock->identifier(pc[2].u.operand);
  833. JSValue baseValue = LLINT_OP_C(1).jsValue();
  834. PutPropertySlot slot(codeBlock->isStrictMode());
  835. if (pc[8].u.operand)
  836. asObject(baseValue)->putDirect(vm, ident, LLINT_OP_C(3).jsValue(), slot);
  837. else
  838. baseValue.put(exec, ident, LLINT_OP_C(3).jsValue(), slot);
  839. LLINT_CHECK_EXCEPTION();
  840. if (!LLINT_ALWAYS_ACCESS_SLOW
  841. && baseValue.isCell()
  842. && slot.isCacheable()) {
  843. JSCell* baseCell = baseValue.asCell();
  844. Structure* structure = baseCell->structure();
  845. if (!structure->isUncacheableDictionary()
  846. && !structure->typeInfo().prohibitsPropertyCaching()
  847. && baseCell == slot.base()) {
  848. if (slot.type() == PutPropertySlot::NewProperty) {
  849. if (!structure->isDictionary() && structure->previousID()->outOfLineCapacity() == structure->outOfLineCapacity()) {
  850. ASSERT(structure->previousID()->transitionWatchpointSetHasBeenInvalidated());
  851. // This is needed because some of the methods we call
  852. // below may GC.
  853. pc[0].u.opcode = LLInt::getOpcode(llint_op_put_by_id);
  854. if (normalizePrototypeChain(exec, baseCell) != InvalidPrototypeChain) {
  855. ASSERT(structure->previousID()->isObject());
  856. pc[4].u.structure.set(
  857. vm, codeBlock->ownerExecutable(), structure->previousID());
  858. if (isInlineOffset(slot.cachedOffset()))
  859. pc[5].u.operand = offsetInInlineStorage(slot.cachedOffset()) * sizeof(JSValue) + JSObject::offsetOfInlineStorage();
  860. else
  861. pc[5].u.operand = offsetInButterfly(slot.cachedOffset()) * sizeof(JSValue);
  862. pc[6].u.structure.set(
  863. vm, codeBlock->ownerExecutable(), structure);
  864. StructureChain* chain = structure->prototypeChain(exec);
  865. ASSERT(chain);
  866. pc[7].u.structureChain.set(
  867. vm, codeBlock->ownerExecutable(), chain);
  868. if (pc[8].u.operand) {
  869. if (isInlineOffset(slot.cachedOffset()))
  870. pc[0].u.opcode = LLInt::getOpcode(llint_op_put_by_id_transition_direct);
  871. else
  872. pc[0].u.opcode = LLInt::getOpcode(llint_op_put_by_id_transition_direct_out_of_line);
  873. } else {
  874. if (isInlineOffset(slot.cachedOffset()))
  875. pc[0].u.opcode = LLInt::getOpcode(llint_op_put_by_id_transition_normal);
  876. else
  877. pc[0].u.opcode = LLInt::getOpcode(llint_op_put_by_id_transition_normal_out_of_line);
  878. }
  879. }
  880. }
  881. } else {
  882. pc[4].u.structure.set(
  883. vm, codeBlock->ownerExecutable(), structure);
  884. if (isInlineOffset(slot.cachedOffset())) {
  885. pc[0].u.opcode = LLInt::getOpcode(llint_op_put_by_id);
  886. pc[5].u.operand = offsetInInlineStorage(slot.cachedOffset()) * sizeof(JSValue) + JSObject::offsetOfInlineStorage();
  887. } else {
  888. pc[0].u.opcode = LLInt::getOpcode(llint_op_put_by_id_out_of_line);
  889. pc[5].u.operand = offsetInButterfly(slot.cachedOffset()) * sizeof(JSValue);
  890. }
  891. }
  892. }
  893. }
  894. LLINT_END();
  895. }
  896. LLINT_SLOW_PATH_DECL(slow_path_del_by_id)
  897. {
  898. LLINT_BEGIN();
  899. CodeBlock* codeBlock = exec->codeBlock();
  900. JSObject* baseObject = LLINT_OP_C(2).jsValue().toObject(exec);
  901. bool couldDelete = baseObject->methodTable()->deleteProperty(baseObject, exec, codeBlock->identifier(pc[3].u.operand));
  902. LLINT_CHECK_EXCEPTION();
  903. if (!couldDelete && codeBlock->isStrictMode())
  904. LLINT_THROW(createTypeError(exec, "Unable to delete property."));
  905. LLINT_RETURN(jsBoolean(couldDelete));
  906. }
  907. inline JSValue getByVal(ExecState* exec, JSValue baseValue, JSValue subscript)
  908. {
  909. if (LIKELY(baseValue.isCell() && subscript.isString())) {
  910. if (JSValue result = baseValue.asCell()->fastGetOwnProperty(exec, asString(subscript)->value(exec)))
  911. return result;
  912. }
  913. if (subscript.isUInt32()) {
  914. uint32_t i = subscript.asUInt32();
  915. if (isJSString(baseValue) && asString(baseValue)->canGetIndex(i))
  916. return asString(baseValue)->getIndex(exec, i);
  917. return baseValue.get(exec, i);
  918. }
  919. if (isName(subscript))
  920. return baseValue.get(exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
  921. Identifier property(exec, subscript.toString(exec)->value(exec));
  922. return baseValue.get(exec, property);
  923. }
  924. LLINT_SLOW_PATH_DECL(slow_path_get_by_val)
  925. {
  926. LLINT_BEGIN();
  927. LLINT_RETURN_PROFILED(op_get_by_val, getByVal(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(3).jsValue()));
  928. }
  929. LLINT_SLOW_PATH_DECL(slow_path_get_argument_by_val)
  930. {
  931. LLINT_BEGIN();
  932. JSValue arguments = LLINT_OP(2).jsValue();
  933. if (!arguments) {
  934. arguments = Arguments::create(vm, exec);
  935. LLINT_CHECK_EXCEPTION();
  936. LLINT_OP(2) = arguments;
  937. exec->uncheckedR(unmodifiedArgumentsRegister(pc[2].u.operand)) = arguments;
  938. }
  939. LLINT_RETURN_PROFILED(op_get_argument_by_val, getByVal(exec, arguments, LLINT_OP_C(3).jsValue()));
  940. }
  941. LLINT_SLOW_PATH_DECL(slow_path_get_by_pname)
  942. {
  943. LLINT_BEGIN();
  944. LLINT_RETURN(getByVal(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(3).jsValue()));
  945. }
  946. LLINT_SLOW_PATH_DECL(slow_path_put_by_val)
  947. {
  948. LLINT_BEGIN();
  949. JSValue baseValue = LLINT_OP_C(1).jsValue();
  950. JSValue subscript = LLINT_OP_C(2).jsValue();
  951. JSValue value = LLINT_OP_C(3).jsValue();
  952. if (LIKELY(subscript.isUInt32())) {
  953. uint32_t i = subscript.asUInt32();
  954. if (baseValue.isObject()) {
  955. JSObject* object = asObject(baseValue);
  956. if (object->canSetIndexQuickly(i))
  957. object->setIndexQuickly(vm, i, value);
  958. else
  959. object->methodTable()->putByIndex(object, exec, i, value, exec->codeBlock()->isStrictMode());
  960. LLINT_END();
  961. }
  962. baseValue.putByIndex(exec, i, value, exec->codeBlock()->isStrictMode());
  963. LLINT_END();
  964. }
  965. if (isName(subscript)) {
  966. PutPropertySlot slot(exec->codeBlock()->isStrictMode());
  967. baseValue.put(exec, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
  968. LLINT_END();
  969. }
  970. Identifier property(exec, subscript.toString(exec)->value(exec));
  971. LLINT_CHECK_EXCEPTION();
  972. PutPropertySlot slot(exec->codeBlock()->isStrictMode());
  973. baseValue.put(exec, property, value, slot);
  974. LLINT_END();
  975. }
  976. LLINT_SLOW_PATH_DECL(slow_path_del_by_val)
  977. {
  978. LLINT_BEGIN();
  979. JSValue baseValue = LLINT_OP_C(2).jsValue();
  980. JSObject* baseObject = baseValue.toObject(exec);
  981. JSValue subscript = LLINT_OP_C(3).jsValue();
  982. bool couldDelete;
  983. uint32_t i;
  984. if (subscript.getUInt32(i))
  985. couldDelete = baseObject->methodTable()->deletePropertyByIndex(baseObject, exec, i);
  986. else if (isName(subscript))
  987. couldDelete = baseObject->methodTable()->deleteProperty(baseObject, exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
  988. else {
  989. LLINT_CHECK_EXCEPTION();
  990. Identifier property(exec, subscript.toString(exec)->value(exec));
  991. LLINT_CHECK_EXCEPTION();
  992. couldDelete = baseObject->methodTable()->deleteProperty(baseObject, exec, property);
  993. }
  994. if (!couldDelete && exec->codeBlock()->isStrictMode())
  995. LLINT_THROW(createTypeError(exec, "Unable to delete property."));
  996. LLINT_RETURN(jsBoolean(couldDelete));
  997. }
  998. LLINT_SLOW_PATH_DECL(slow_path_put_by_index)
  999. {
  1000. LLINT_BEGIN();
  1001. JSValue arrayValue = LLINT_OP_C(1).jsValue();
  1002. ASSERT(isJSArray(arrayValue));
  1003. asArray(arrayValue)->putDirectIndex(exec, pc[2].u.operand, LLINT_OP_C(3).jsValue());
  1004. LLINT_END();
  1005. }
  1006. LLINT_SLOW_PATH_DECL(slow_path_put_getter_setter)
  1007. {
  1008. LLINT_BEGIN();
  1009. ASSERT(LLINT_OP(1).jsValue().isObject());
  1010. JSObject* baseObj = asObject(LLINT_OP(1).jsValue());
  1011. GetterSetter* accessor = GetterSetter::create(exec);
  1012. LLINT_CHECK_EXCEPTION();
  1013. JSValue getter = LLINT_OP(3).jsValue();
  1014. JSValue setter = LLINT_OP(4).jsValue();
  1015. ASSERT(getter.isObject() || getter.isUndefined());
  1016. ASSERT(setter.isObject() || setter.isUndefined());
  1017. ASSERT(getter.isObject() || setter.isObject());
  1018. if (!getter.isUndefined())
  1019. accessor->setGetter(vm, asObject(getter));
  1020. if (!setter.isUndefined())
  1021. accessor->setSetter(vm, asObject(setter));
  1022. baseObj->putDirectAccessor(
  1023. exec,
  1024. exec->codeBlock()->identifier(pc[2].u.operand),
  1025. accessor, Accessor);
  1026. LLINT_END();
  1027. }
  1028. LLINT_SLOW_PATH_DECL(slow_path_jtrue)
  1029. {
  1030. LLINT_BEGIN();
  1031. LLINT_BRANCH(op_jtrue, LLINT_OP_C(1).jsValue().toBoolean(exec));
  1032. }
  1033. LLINT_SLOW_PATH_DECL(slow_path_jfalse)
  1034. {
  1035. LLINT_BEGIN();
  1036. LLINT_BRANCH(op_jfalse, !LLINT_OP_C(1).jsValue().toBoolean(exec));
  1037. }
  1038. LLINT_SLOW_PATH_DECL(slow_path_jless)
  1039. {
  1040. LLINT_BEGIN();
  1041. LLINT_BRANCH(op_jless, jsLess<true>(exec, LLINT_OP_C(1).jsValue(), LLINT_OP_C(2).jsValue()));
  1042. }
  1043. LLINT_SLOW_PATH_DECL(slow_path_jnless)
  1044. {
  1045. LLINT_BEGIN();
  1046. LLINT_BRANCH(op_jnless, !jsLess<true>(exec, LLINT_OP_C(1).jsValue(), LLINT_OP_C(2).jsValue()));
  1047. }
  1048. LLINT_SLOW_PATH_DECL(slow_path_jgreater)
  1049. {
  1050. LLINT_BEGIN();
  1051. LLINT_BRANCH(op_jgreater, jsLess<false>(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(1).jsValue()));
  1052. }
  1053. LLINT_SLOW_PATH_DECL(slow_path_jngreater)
  1054. {
  1055. LLINT_BEGIN();
  1056. LLINT_BRANCH(op_jngreater, !jsLess<false>(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(1).jsValue()));
  1057. }
  1058. LLINT_SLOW_PATH_DECL(slow_path_jlesseq)
  1059. {
  1060. LLINT_BEGIN();
  1061. LLINT_BRANCH(op_jlesseq, jsLessEq<true>(exec, LLINT_OP_C(1).jsValue(), LLINT_OP_C(2).jsValue()));
  1062. }
  1063. LLINT_SLOW_PATH_DECL(slow_path_jnlesseq)
  1064. {
  1065. LLINT_BEGIN();
  1066. LLINT_BRANCH(op_jnlesseq, !jsLessEq<true>(exec, LLINT_OP_C(1).jsValue(), LLINT_OP_C(2).jsValue()));
  1067. }
  1068. LLINT_SLOW_PATH_DECL(slow_path_jgreatereq)
  1069. {
  1070. LLINT_BEGIN();
  1071. LLINT_BRANCH(op_jgreatereq, jsLessEq<false>(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(1).jsValue()));
  1072. }
  1073. LLINT_SLOW_PATH_DECL(slow_path_jngreatereq)
  1074. {
  1075. LLINT_BEGIN();
  1076. LLINT_BRANCH(op_jngreatereq, !jsLessEq<false>(exec, LLINT_OP_C(2).jsValue(), LLINT_OP_C(1).jsValue()));
  1077. }
  1078. LLINT_SLOW_PATH_DECL(slow_path_switch_imm)
  1079. {
  1080. LLINT_BEGIN();
  1081. JSValue scrutinee = LLINT_OP_C(3).jsValue();
  1082. ASSERT(scrutinee.isDouble());
  1083. double value = scrutinee.asDouble();
  1084. int32_t intValue = static_cast<int32_t>(value);
  1085. int defaultOffset = pc[2].u.operand;
  1086. if (value == intValue) {
  1087. CodeBlock* codeBlock = exec->codeBlock();
  1088. pc += codeBlock->immediateSwitchJumpTable(pc[1].u.operand).offsetForValue(intValue, defaultOffset);
  1089. } else
  1090. pc += defaultOffset;
  1091. LLINT_END();
  1092. }
  1093. LLINT_SLOW_PATH_DECL(slow_path_switch_char)
  1094. {
  1095. LLINT_BEGIN();
  1096. JSValue scrutinee = LLINT_OP_C(3).jsValue();
  1097. ASSERT(scrutinee.isString());
  1098. JSString* string = asString(scrutinee);
  1099. ASSERT(string->length() == 1);
  1100. int defaultOffset = pc[2].u.operand;
  1101. StringImpl* impl = string->value(exec).impl();
  1102. CodeBlock* codeBlock = exec->codeBlock();
  1103. pc += codeBlock->characterSwitchJumpTable(pc[1].u.operand).offsetForValue((*impl)[0], defaultOffset);
  1104. LLINT_END();
  1105. }
  1106. LLINT_SLOW_PATH_DECL(slow_path_switch_string)
  1107. {
  1108. LLINT_BEGIN();
  1109. JSValue scrutinee = LLINT_OP_C(3).jsValue();
  1110. int defaultOffset = pc[2].u.operand;
  1111. if (!scrutinee.isString())
  1112. pc += defaultOffset;
  1113. else {
  1114. CodeBlock* codeBlock = exec->codeBlock();
  1115. pc += codeBlock->stringSwitchJumpTable(pc[1].u.operand).offsetForValue(asString(scrutinee)->value(exec).impl(), defaultOffset);
  1116. }
  1117. LLINT_END();
  1118. }
  1119. LLINT_SLOW_PATH_DECL(slow_path_new_func)
  1120. {
  1121. LLINT_BEGIN();
  1122. CodeBlock* codeBlock = exec->codeBlock();
  1123. ASSERT(codeBlock->codeType() != FunctionCode
  1124. || !codeBlock->needsFullScopeChain()
  1125. || exec->uncheckedR(codeBlock->activationRegister()).jsValue());
  1126. #if LLINT_SLOW_PATH_TRACING
  1127. dataLogF("Creating function!\n");
  1128. #endif
  1129. LLINT_RETURN(JSFunction::create(exec, codeBlock->functionDecl(pc[2].u.operand), exec->scope()));
  1130. }
  1131. LLINT_SLOW_PATH_DECL(slow_path_new_func_exp)
  1132. {
  1133. LLINT_BEGIN();
  1134. CodeBlock* codeBlock = exec->codeBlock();
  1135. FunctionExecutable* function = codeBlock->functionExpr(pc[2].u.operand);
  1136. JSFunction* func = JSFunction::create(exec, function, exec->scope());
  1137. LLINT_RETURN(func);
  1138. }
  1139. static SlowPathReturnType handleHostCall(ExecState* execCallee, Instruction* pc, JSValue callee, CodeSpecializationKind kind)
  1140. {
  1141. ExecState* exec = execCallee->callerFrame();
  1142. VM& vm = exec->vm();
  1143. execCallee->setScope(exec->scope());
  1144. execCallee->setCodeBlock(0);
  1145. execCallee->clearReturnPC();
  1146. if (kind == CodeForCall) {
  1147. CallData callData;
  1148. CallType callType = getCallData(callee, callData);
  1149. ASSERT(callType != CallTypeJS);
  1150. if (callType == CallTypeHost) {
  1151. NativeCallFrameTracer tracer(&vm, execCallee);
  1152. execCallee->setCallee(asObject(callee));
  1153. vm.hostCallReturnValue = JSValue::decode(callData.native.function(execCallee));
  1154. LLINT_CALL_RETURN(execCallee, pc, LLInt::getCodePtr(getHostCallReturnValue));
  1155. }
  1156. #if LLINT_SLOW_PATH_TRACING
  1157. dataLog("Call callee is not a function: ", callee, "\n");
  1158. #endif
  1159. ASSERT(callType == CallTypeNone);
  1160. LLINT_CALL_THROW(exec, pc, createNotAFunctionError(exec, callee));
  1161. }
  1162. ASSERT(kind == CodeForConstruct);
  1163. ConstructData constructData;
  1164. ConstructType constructType = getConstructData(callee, constructData);
  1165. ASSERT(constructType != ConstructTypeJS);
  1166. if (constructType == ConstructTypeHost) {
  1167. NativeCallFrameTracer tracer(&vm, execCallee);
  1168. execCallee->setCallee(asObject(callee));
  1169. vm.hostCallReturnValue = JSValue::decode(constructData.native.function(execCallee));
  1170. LLINT_CALL_RETURN(execCallee, pc, LLInt::getCodePtr(getHostCallReturnValue));
  1171. }
  1172. #if LLINT_SLOW_PATH_TRACING
  1173. dataLog("Constructor callee is not a function: ", callee, "\n");
  1174. #endif
  1175. ASSERT(constructType == ConstructTypeNone);
  1176. LLINT_CALL_THROW(exec, pc, createNotAConstructorError(exec, callee));
  1177. }
  1178. inline SlowPathReturnType setUpCall(ExecState* execCallee, Instruction* pc, CodeSpecializationKind kind, JSValue calleeAsValue, LLIntCallLinkInfo* callLinkInfo = 0)
  1179. {
  1180. #if LLINT_SLOW_PATH_TRACING
  1181. dataLogF("Performing call with recorded PC = %p\n", execCallee->callerFrame()->currentVPC());
  1182. #endif
  1183. JSCell* calleeAsFunctionCell = getJSFunction(calleeAsValue);
  1184. if (!calleeAsFunctionCell)
  1185. return handleHostCall(execCallee, pc, calleeAsValue, kind);
  1186. JSFunction* callee = jsCast<JSFunction*>(calleeAsFunctionCell);
  1187. JSScope* scope = callee->scopeUnchecked();
  1188. VM& vm = *scope->vm();
  1189. execCallee->setScope(scope);
  1190. ExecutableBase* executable = callee->executable();
  1191. MacroAssemblerCodePtr codePtr;
  1192. CodeBlock* codeBlock = 0;
  1193. if (executable->isHostFunction())
  1194. codePtr = executable->hostCodeEntryFor(kind);
  1195. else {
  1196. FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
  1197. JSObject* error = functionExecutable->compileFor(execCallee, callee->scope(), kind);
  1198. if (error)
  1199. LLINT_CALL_THROW(execCallee->callerFrame(), pc, error);
  1200. codeBlock = &functionExecutable->generatedBytecodeFor(kind);
  1201. ASSERT(codeBlock);
  1202. if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()))
  1203. codePtr = functionExecutable->jsCodeWithArityCheckEntryFor(kind);
  1204. else
  1205. codePtr = functionExecutable->jsCodeEntryFor(kind);
  1206. }
  1207. if (!LLINT_ALWAYS_ACCESS_SLOW && callLinkInfo) {
  1208. if (callLinkInfo->isOnList())
  1209. callLinkInfo->remove();
  1210. ExecState* execCaller = execCallee->callerFrame();
  1211. callLinkInfo->callee.set(vm, execCaller->codeBlock()->ownerExecutable(), callee);
  1212. callLinkInfo->lastSeenCallee.set(vm, execCaller->codeBlock()->ownerExecutable(), callee);
  1213. callLinkInfo->machineCodeTarget = codePtr;
  1214. if (codeBlock)
  1215. codeBlock->linkIncomingCall(callLinkInfo);
  1216. }
  1217. LLINT_CALL_RETURN(execCallee, pc, codePtr.executableAddress());
  1218. }
  1219. inline SlowPathReturnType genericCall(ExecState* exec, Instruction* pc, CodeSpecializationKind kind)
  1220. {
  1221. // This needs to:
  1222. // - Set up a call frame.
  1223. // - Figure out what to call and compile it if necessary.
  1224. // - If possible, link the call's inline cache.
  1225. // - Return a tuple of machine code address to call and the new call frame.
  1226. JSValue calleeAsValue = LLINT_OP_C(1).jsValue();
  1227. ExecState* execCallee = exec + pc[3].u.operand;
  1228. execCallee->setArgumentCountIncludingThis(pc[2].u.operand);
  1229. execCallee->uncheckedR(JSStack::Callee) = calleeAsValue;
  1230. execCallee->setCallerFrame(exec);
  1231. ASSERT(pc[4].u.callLinkInfo);
  1232. return setUpCall(execCallee, pc, kind, calleeAsValue, pc[4].u.callLinkInfo);
  1233. }
  1234. LLINT_SLOW_PATH_DECL(slow_path_call)
  1235. {
  1236. LLINT_BEGIN_NO_SET_PC();
  1237. return genericCall(exec, pc, CodeForCall);
  1238. }
  1239. LLINT_SLOW_PATH_DECL(slow_path_construct)
  1240. {
  1241. LLINT_BEGIN_NO_SET_PC();
  1242. return genericCall(exec, pc, CodeForConstruct);
  1243. }
  1244. LLINT_SLOW_PATH_DECL(slow_path_call_varargs)
  1245. {
  1246. LLINT_BEGIN();
  1247. // This needs to:
  1248. // - Set up a call frame while respecting the variable arguments.
  1249. // - Figure out what to call and compile it if necessary.
  1250. // - Return a tuple of machine code address to call and the new call frame.
  1251. JSValue calleeAsValue = LLINT_OP_C(1).jsValue();
  1252. ExecState* execCallee = loadVarargs(
  1253. exec, &vm.interpreter->stack(),
  1254. LLINT_OP_C(2).jsValue(), LLINT_OP_C(3).jsValue(), pc[4].u.operand);
  1255. LLINT_CALL_CHECK_EXCEPTION(exec, pc);
  1256. execCallee->uncheckedR(JSStack::Callee) = calleeAsValue;
  1257. execCallee->setCallerFrame(exec);
  1258. exec->setCurrentVPC(pc + OPCODE_LENGTH(op_call_varargs));
  1259. return setUpCall(execCallee, pc, CodeForCall, calleeAsValue);
  1260. }
  1261. LLINT_SLOW_PATH_DECL(slow_path_call_eval)
  1262. {
  1263. LLINT_BEGIN_NO_SET_PC();
  1264. JSValue calleeAsValue = LLINT_OP(1).jsValue();
  1265. ExecState* execCallee = exec + pc[3].u.operand;
  1266. execCallee->setArgumentCountIncludingThis(pc[2].u.operand);
  1267. execCallee->setCallerFrame(exec);
  1268. execCallee->uncheckedR(JSStack::Callee) = calleeAsValue;
  1269. execCallee->setScope(exec->scope());
  1270. execCallee->setReturnPC(LLInt::getCodePtr(llint_generic_return_point));
  1271. execCallee->setCodeBlock(0);
  1272. exec->setCurrentVPC(pc + OPCODE_LENGTH(op_call_eval));
  1273. if (!isHostFunction(calleeAsValue, globalFuncEval))
  1274. return setUpCall(execCallee, pc, CodeForCall, calleeAsValue);
  1275. vm.hostCallReturnValue = eval(execCallee);
  1276. LLINT_CALL_RETURN(execCallee, pc, LLInt::getCodePtr(getHostCallReturnValue));
  1277. }
  1278. LLINT_SLOW_PATH_DECL(slow_path_tear_off_activation)
  1279. {
  1280. LLINT_BEGIN();
  1281. ASSERT(exec->codeBlock()->needsFullScopeChain());
  1282. jsCast<JSActivation*>(LLINT_OP(1).jsValue())->tearOff(vm);
  1283. LLINT_END();
  1284. }
  1285. LLINT_SLOW_PATH_DECL(slow_path_tear_off_arguments)
  1286. {
  1287. LLINT_BEGIN();
  1288. ASSERT(exec->codeBlock()->usesArguments());
  1289. Arguments* arguments = jsCast<Arguments*>(exec->uncheckedR(unmodifiedArgumentsRegister(pc[1].u.operand)).jsValue());
  1290. if (JSValue activationValue = LLINT_OP_C(2).jsValue())
  1291. arguments->didTearOffActivation(exec, jsCast<JSActivation*>(activationValue));
  1292. else
  1293. arguments->tearOff(exec);
  1294. LLINT_END();
  1295. }
  1296. LLINT_SLOW_PATH_DECL(slow_path_strcat)
  1297. {
  1298. LLINT_BEGIN();
  1299. LLINT_RETURN(jsString(exec, &LLINT_OP(2), pc[3].u.operand));
  1300. }
  1301. LLINT_SLOW_PATH_DECL(slow_path_to_primitive)
  1302. {
  1303. LLINT_BEGIN();
  1304. LLINT_RETURN(LLINT_OP_C(2).jsValue().toPrimitive(exec));
  1305. }
  1306. LLINT_SLOW_PATH_DECL(slow_path_get_pnames)
  1307. {
  1308. LLINT_BEGIN();
  1309. JSValue v = LLINT_OP(2).jsValue();
  1310. if (v.isUndefinedOrNull()) {
  1311. pc += pc[5].u.operand;
  1312. LLINT_END();
  1313. }
  1314. JSObject* o = v.toObject(exec);
  1315. Structure* structure = o->structure();
  1316. JSPropertyNameIterator* jsPropertyNameIterator = structure->enumerationCache();
  1317. if (!jsPropertyNameIterator || jsPropertyNameIterator->cachedPrototypeChain() != structure->prototypeChain(exec))
  1318. jsPropertyNameIterator = JSPropertyNameIterator::create(exec, o);
  1319. LLINT_OP(1) = JSValue(jsPropertyNameIterator);
  1320. LLINT_OP(2) = JSValue(o);
  1321. LLINT_OP(3) = Register::withInt(0);
  1322. LLINT_OP(4) = Register::withInt(jsPropertyNameIterator->size());
  1323. pc += OPCODE_LENGTH(op_get_pnames);
  1324. LLINT_END();
  1325. }
  1326. LLINT_SLOW_PATH_DECL(slow_path_next_pname)
  1327. {
  1328. LLINT_BEGIN();
  1329. JSObject* base = asObject(LLINT_OP(2).jsValue());
  1330. JSString* property = asString(LLINT_OP(1).jsValue());
  1331. if (base->hasProperty(exec, Identifier(exec, property->value(exec)))) {
  1332. // Go to target.
  1333. pc += pc[6].u.operand;
  1334. } // Else, don't change the PC, so the interpreter will reloop.
  1335. LLINT_END();
  1336. }
  1337. LLINT_SLOW_PATH_DECL(slow_path_push_with_scope)
  1338. {
  1339. LLINT_BEGIN();
  1340. JSValue v = LLINT_OP_C(1).jsValue();
  1341. JSObject* o = v.toObject(exec);
  1342. LLINT_CHECK_EXCEPTION();
  1343. exec->setScope(JSWithScope::create(exec, o));
  1344. LLINT_END();
  1345. }
  1346. LLINT_SLOW_PATH_DECL(slow_path_pop_scope)
  1347. {
  1348. LLINT_BEGIN();
  1349. exec->setScope(exec->scope()->next());
  1350. LLINT_END();
  1351. }
  1352. LLINT_SLOW_PATH_DECL(slow_path_push_name_scope)
  1353. {
  1354. LLINT_BEGIN();
  1355. CodeBlock* codeBlock = exec->codeBlock();
  1356. JSNameScope* scope = JSNameScope::create(exec, codeBlock->identifier(pc[1].u.operand), LLINT_OP(2).jsValue(), pc[3].u.operand);
  1357. exec->setScope(scope);
  1358. LLINT_END();
  1359. }
  1360. LLINT_SLOW_PATH_DECL(slow_path_throw)
  1361. {
  1362. LLINT_BEGIN();
  1363. LLINT_THROW(LLINT_OP_C(1).jsValue());
  1364. }
  1365. LLINT_SLOW_PATH_DECL(slow_path_throw_static_error)
  1366. {
  1367. LLINT_BEGIN();
  1368. if (pc[2].u.operand)
  1369. LLINT_THROW(createReferenceError(exec, LLINT_OP_C(1).jsValue().toString(exec)->value(exec)));
  1370. else
  1371. LLINT_THROW(createTypeError(exec, LLINT_OP_C(1).jsValue().toString(exec)->value(exec)));
  1372. }
  1373. LLINT_SLOW_PATH_DECL(slow_path_handle_watchdog_timer)
  1374. {
  1375. LLINT_BEGIN_NO_SET_PC();
  1376. if (UNLIKELY(vm.watchdog.didFire(exec)))
  1377. LLINT_THROW(createTerminatedExecutionException(&vm));
  1378. LLINT_RETURN_TWO(0, exec);
  1379. }
  1380. LLINT_SLOW_PATH_DECL(slow_path_debug)
  1381. {
  1382. LLINT_BEGIN();
  1383. int debugHookID = pc[1].u.operand;
  1384. int firstLine = pc[2].u.operand;
  1385. int lastLine = pc[3].u.operand;
  1386. int column = pc[4].u.operand;
  1387. vm.interpreter->debug(exec, static_cast<DebugHookID>(debugHookID), firstLine, lastLine, column);
  1388. LLINT_END();
  1389. }
  1390. LLINT_SLOW_PATH_DECL(slow_path_profile_will_call)
  1391. {
  1392. LLINT_BEGIN();
  1393. if (LegacyProfiler* profiler = vm.enabledProfiler())
  1394. profiler->willExecute(exec, LLINT_OP(1).jsValue());
  1395. LLINT_END();
  1396. }
  1397. LLINT_SLOW_PATH_DECL(slow_path_profile_did_call)
  1398. {
  1399. LLINT_BEGIN();
  1400. if (LegacyProfiler* profiler = vm.enabledProfiler())
  1401. profiler->didExecute(exec, LLINT_OP(1).jsValue());
  1402. LLINT_END();
  1403. }
  1404. LLINT_SLOW_PATH_DECL(throw_from_native_call)
  1405. {
  1406. LLINT_BEGIN();
  1407. ASSERT(vm.exception);
  1408. LLINT_END();
  1409. }
  1410. } } // namespace JSC::LLInt
  1411. #endif // ENABLE(LLINT)