1 | /* |
2 | * Copyright (C) 2011-2019 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | #include "LLIntSlowPaths.h" |
28 | |
29 | #include "ArrayConstructor.h" |
30 | #include "CallFrame.h" |
31 | #include "CommonSlowPaths.h" |
32 | #include "Error.h" |
33 | #include "ErrorHandlingScope.h" |
34 | #include "EvalCodeBlock.h" |
35 | #include "Exception.h" |
36 | #include "ExceptionFuzz.h" |
37 | #include "ExecutableBaseInlines.h" |
38 | #include "FrameTracers.h" |
39 | #include "FunctionCodeBlock.h" |
40 | #include "FunctionWhitelist.h" |
41 | #include "GetterSetter.h" |
42 | #include "HostCallReturnValue.h" |
43 | #include "InterpreterInlines.h" |
44 | #include "IteratorOperations.h" |
45 | #include "JIT.h" |
46 | #include "JITExceptions.h" |
47 | #include "JITWorklist.h" |
48 | #include "JSAsyncFunction.h" |
49 | #include "JSAsyncGeneratorFunction.h" |
50 | #include "JSCInlines.h" |
51 | #include "JSCJSValue.h" |
52 | #include "JSGeneratorFunction.h" |
53 | #include "JSGlobalObjectFunctions.h" |
54 | #include "JSLexicalEnvironment.h" |
55 | #include "JSString.h" |
56 | #include "JSWithScope.h" |
57 | #include "LLIntCommon.h" |
58 | #include "LLIntData.h" |
59 | #include "LLIntExceptions.h" |
60 | #include "LLIntPrototypeLoadAdaptiveStructureWatchpoint.h" |
61 | #include "LowLevelInterpreter.h" |
62 | #include "ModuleProgramCodeBlock.h" |
63 | #include "ObjectConstructor.h" |
64 | #include "ObjectPropertyConditionSet.h" |
65 | #include "OpcodeInlines.h" |
66 | #include "ProgramCodeBlock.h" |
67 | #include "ProtoCallFrame.h" |
68 | #include "RegExpObject.h" |
69 | #include "ShadowChicken.h" |
70 | #include "StructureRareDataInlines.h" |
71 | #include "SuperSampler.h" |
72 | #include "VMInlines.h" |
73 | #include <wtf/NeverDestroyed.h> |
74 | #include <wtf/StringPrintStream.h> |
75 | |
76 | namespace JSC { namespace LLInt { |
77 | |
78 | #define LLINT_BEGIN_NO_SET_PC() \ |
79 | VM& vm = exec->vm(); \ |
80 | NativeCallFrameTracer tracer(&vm, exec); \ |
81 | auto throwScope = DECLARE_THROW_SCOPE(vm) |
82 | |
83 | #ifndef NDEBUG |
84 | #define LLINT_SET_PC_FOR_STUBS() do { \ |
85 | exec->codeBlock()->bytecodeOffset(pc); \ |
86 | exec->setCurrentVPC(pc); \ |
87 | } while (false) |
88 | #else |
89 | #define LLINT_SET_PC_FOR_STUBS() do { \ |
90 | exec->setCurrentVPC(pc); \ |
91 | } while (false) |
92 | #endif |
93 | |
94 | #define LLINT_BEGIN() \ |
95 | LLINT_BEGIN_NO_SET_PC(); \ |
96 | LLINT_SET_PC_FOR_STUBS() |
97 | |
98 | inline JSValue getNonConstantOperand(ExecState* exec, const VirtualRegister& operand) { return exec->uncheckedR(operand.offset()).jsValue(); } |
99 | inline JSValue getOperand(ExecState* exec, const VirtualRegister& operand) { return exec->r(operand.offset()).jsValue(); } |
100 | |
101 | #define LLINT_RETURN_TWO(first, second) do { \ |
102 | return encodeResult(first, second); \ |
103 | } while (false) |
104 | |
105 | #define LLINT_END_IMPL() LLINT_RETURN_TWO(pc, 0) |
106 | |
107 | #define LLINT_THROW(exceptionToThrow) do { \ |
108 | throwException(exec, throwScope, exceptionToThrow); \ |
109 | pc = returnToThrow(exec); \ |
110 | LLINT_END_IMPL(); \ |
111 | } while (false) |
112 | |
113 | #define LLINT_CHECK_EXCEPTION() do { \ |
114 | doExceptionFuzzingIfEnabled(exec, throwScope, "LLIntSlowPaths", pc); \ |
115 | if (UNLIKELY(throwScope.exception())) { \ |
116 | pc = returnToThrow(exec); \ |
117 | LLINT_END_IMPL(); \ |
118 | } \ |
119 | } while (false) |
120 | |
121 | #define LLINT_END() do { \ |
122 | LLINT_CHECK_EXCEPTION(); \ |
123 | LLINT_END_IMPL(); \ |
124 | } while (false) |
125 | |
126 | #define JUMP_OFFSET(targetOffset) \ |
127 | ((targetOffset) ? (targetOffset) : exec->codeBlock()->outOfLineJumpOffset(pc)) |
128 | |
129 | #define JUMP_TO(target) do { \ |
130 | pc = reinterpret_cast<const Instruction*>(reinterpret_cast<const uint8_t*>(pc) + (target)); \ |
131 | } while (false) |
132 | |
133 | #define LLINT_BRANCH(condition) do { \ |
134 | bool __b_condition = (condition); \ |
135 | LLINT_CHECK_EXCEPTION(); \ |
136 | if (__b_condition) \ |
137 | JUMP_TO(JUMP_OFFSET(bytecode.m_targetLabel)); \ |
138 | else \ |
139 | JUMP_TO(pc->size()); \ |
140 | LLINT_END_IMPL(); \ |
141 | } while (false) |
142 | |
143 | #define LLINT_RETURN(value) do { \ |
144 | JSValue __r_returnValue = (value); \ |
145 | LLINT_CHECK_EXCEPTION(); \ |
146 | exec->uncheckedR(bytecode.m_dst) = __r_returnValue; \ |
147 | LLINT_END_IMPL(); \ |
148 | } while (false) |
149 | |
150 | #define LLINT_RETURN_PROFILED(value) do { \ |
151 | JSValue __rp_returnValue = (value); \ |
152 | LLINT_CHECK_EXCEPTION(); \ |
153 | exec->uncheckedR(bytecode.m_dst) = __rp_returnValue; \ |
154 | LLINT_PROFILE_VALUE(__rp_returnValue); \ |
155 | LLINT_END_IMPL(); \ |
156 | } while (false) |
157 | |
158 | #define LLINT_PROFILE_VALUE(value) do { \ |
159 | bytecode.metadata(exec).m_profile.m_buckets[0] = JSValue::encode(value); \ |
160 | } while (false) |
161 | |
162 | #define LLINT_CALL_END_IMPL(exec, callTarget, callTargetTag) \ |
163 | LLINT_RETURN_TWO(retagCodePtr((callTarget), callTargetTag, SlowPathPtrTag), (exec)) |
164 | |
165 | #define LLINT_CALL_THROW(exec, exceptionToThrow) do { \ |
166 | ExecState* __ct_exec = (exec); \ |
167 | throwException(__ct_exec, throwScope, exceptionToThrow); \ |
168 | LLINT_CALL_END_IMPL(0, callToThrow(__ct_exec), ExceptionHandlerPtrTag); \ |
169 | } while (false) |
170 | |
171 | #define LLINT_CALL_CHECK_EXCEPTION(exec, execCallee) do { \ |
172 | ExecState* __cce_exec = (exec); \ |
173 | ExecState* __cce_execCallee = (execCallee); \ |
174 | doExceptionFuzzingIfEnabled(__cce_exec, throwScope, "LLIntSlowPaths/call", nullptr); \ |
175 | if (UNLIKELY(throwScope.exception())) \ |
176 | LLINT_CALL_END_IMPL(0, callToThrow(__cce_execCallee), ExceptionHandlerPtrTag); \ |
177 | } while (false) |
178 | |
179 | #define LLINT_CALL_RETURN(exec, execCallee, callTarget, callTargetTag) do { \ |
180 | ExecState* __cr_exec = (exec); \ |
181 | ExecState* __cr_execCallee = (execCallee); \ |
182 | void* __cr_callTarget = (callTarget); \ |
183 | LLINT_CALL_CHECK_EXCEPTION(__cr_exec, __cr_execCallee); \ |
184 | LLINT_CALL_END_IMPL(__cr_execCallee, __cr_callTarget, callTargetTag); \ |
185 | } while (false) |
186 | |
187 | #define LLINT_RETURN_CALLEE_FRAME(execCallee) do { \ |
188 | ExecState* __rcf_exec = (execCallee); \ |
189 | LLINT_RETURN_TWO(pc, __rcf_exec); \ |
190 | } while (false) |
191 | |
192 | #if LLINT_TRACING |
193 | |
194 | template<typename... Types> |
195 | void slowPathLog(const Types&... values) |
196 | { |
197 | dataLogIf(Options::traceLLIntSlowPath(), values...); |
198 | } |
199 | |
200 | template<typename... Types> |
201 | void slowPathLn(const Types&... values) |
202 | { |
203 | dataLogLnIf(Options::traceLLIntSlowPath(), values...); |
204 | } |
205 | |
206 | template<typename... Types> |
207 | void slowPathLogF(const char* format, const Types&... values) |
208 | { |
209 | ALLOW_NONLITERAL_FORMAT_BEGIN |
210 | IGNORE_WARNINGS_BEGIN("format-security" ) |
211 | if (Options::traceLLIntSlowPath()) |
212 | dataLogF(format, values...); |
213 | IGNORE_WARNINGS_END |
214 | ALLOW_NONLITERAL_FORMAT_END |
215 | } |
216 | |
217 | #else // not LLINT_TRACING |
218 | |
219 | template<typename... Types> void slowPathLog(const Types&...) { } |
220 | template<typename... Types> void slowPathLogLn(const Types&...) { } |
221 | template<typename... Types> void slowPathLogF(const char*, const Types&...) { } |
222 | |
223 | #endif // LLINT_TRACING |
224 | |
225 | extern "C" SlowPathReturnType llint_trace_operand(ExecState* exec, const Instruction* pc, int fromWhere, int operand) |
226 | { |
227 | if (!Options::traceLLIntExecution()) |
228 | LLINT_END_IMPL(); |
229 | |
230 | LLINT_BEGIN(); |
231 | dataLogF( |
232 | "<%p> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d\n" , |
233 | &Thread::current(), |
234 | exec->codeBlock(), |
235 | exec, |
236 | static_cast<intptr_t>(exec->codeBlock()->bytecodeOffset(pc)), |
237 | pc->opcodeID(), |
238 | fromWhere, |
239 | operand); |
240 | LLINT_END(); |
241 | } |
242 | |
243 | extern "C" SlowPathReturnType llint_trace_value(ExecState* exec, const Instruction* pc, int fromWhere, VirtualRegister operand) |
244 | { |
245 | if (!Options::traceLLIntExecution()) |
246 | LLINT_END_IMPL(); |
247 | |
248 | JSValue value = getOperand(exec, operand); |
249 | union { |
250 | struct { |
251 | uint32_t tag; |
252 | uint32_t payload; |
253 | } bits; |
254 | EncodedJSValue asValue; |
255 | } u; |
256 | u.asValue = JSValue::encode(value); |
257 | dataLogF( |
258 | "<%p> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %08x:%08x: %s\n" , |
259 | &Thread::current(), |
260 | exec->codeBlock(), |
261 | exec, |
262 | static_cast<intptr_t>(exec->codeBlock()->bytecodeOffset(pc)), |
263 | pc->opcodeID(), |
264 | fromWhere, |
265 | operand.offset(), |
266 | u.bits.tag, |
267 | u.bits.payload, |
268 | toCString(value).data()); |
269 | LLINT_END_IMPL(); |
270 | } |
271 | |
272 | LLINT_SLOW_PATH_DECL(trace_prologue) |
273 | { |
274 | if (!Options::traceLLIntExecution()) |
275 | LLINT_END_IMPL(); |
276 | |
277 | dataLogF("<%p> %p / %p: in prologue of " , &Thread::current(), exec->codeBlock(), exec); |
278 | dataLog(exec->codeBlock(), "\n" ); |
279 | LLINT_END_IMPL(); |
280 | } |
281 | |
282 | static void traceFunctionPrologue(ExecState* exec, const char* , CodeSpecializationKind kind) |
283 | { |
284 | if (!Options::traceLLIntExecution()) |
285 | return; |
286 | |
287 | JSFunction* callee = jsCast<JSFunction*>(exec->jsCallee()); |
288 | FunctionExecutable* executable = callee->jsExecutable(); |
289 | CodeBlock* codeBlock = executable->codeBlockFor(kind); |
290 | dataLogF("<%p> %p / %p: in %s of " , &Thread::current(), codeBlock, exec, comment); |
291 | dataLog(codeBlock); |
292 | dataLogF(" function %p, executable %p; numVars = %u, numParameters = %u, numCalleeLocals = %u, caller = %p.\n" , |
293 | callee, executable, codeBlock->numVars(), codeBlock->numParameters(), codeBlock->numCalleeLocals(), exec->callerFrame()); |
294 | } |
295 | |
296 | LLINT_SLOW_PATH_DECL(trace_prologue_function_for_call) |
297 | { |
298 | traceFunctionPrologue(exec, "call prologue" , CodeForCall); |
299 | LLINT_END_IMPL(); |
300 | } |
301 | |
302 | LLINT_SLOW_PATH_DECL(trace_prologue_function_for_construct) |
303 | { |
304 | traceFunctionPrologue(exec, "construct prologue" , CodeForConstruct); |
305 | LLINT_END_IMPL(); |
306 | } |
307 | |
308 | LLINT_SLOW_PATH_DECL(trace_arityCheck_for_call) |
309 | { |
310 | traceFunctionPrologue(exec, "call arity check" , CodeForCall); |
311 | LLINT_END_IMPL(); |
312 | } |
313 | |
314 | LLINT_SLOW_PATH_DECL(trace_arityCheck_for_construct) |
315 | { |
316 | traceFunctionPrologue(exec, "construct arity check" , CodeForConstruct); |
317 | LLINT_END_IMPL(); |
318 | } |
319 | |
320 | LLINT_SLOW_PATH_DECL(trace) |
321 | { |
322 | if (!Options::traceLLIntExecution()) |
323 | LLINT_END_IMPL(); |
324 | |
325 | OpcodeID opcodeID = pc->opcodeID(); |
326 | dataLogF("<%p> %p / %p: executing bc#%zu, %s, pc = %p\n" , |
327 | &Thread::current(), |
328 | exec->codeBlock(), |
329 | exec, |
330 | static_cast<intptr_t>(exec->codeBlock()->bytecodeOffset(pc)), |
331 | pc->name(), |
332 | pc); |
333 | if (opcodeID == op_enter) { |
334 | dataLogF("Frame will eventually return to %p\n" , exec->returnPC().value()); |
335 | *removeCodePtrTag<volatile char*>(exec->returnPC().value()); |
336 | } |
337 | if (opcodeID == op_ret) { |
338 | dataLogF("Will be returning to %p\n" , exec->returnPC().value()); |
339 | dataLogF("The new cfr will be %p\n" , exec->callerFrame()); |
340 | } |
341 | LLINT_END_IMPL(); |
342 | } |
343 | |
344 | enum EntryKind { Prologue, ArityCheck }; |
345 | |
346 | #if ENABLE(JIT) |
347 | static FunctionWhitelist& ensureGlobalJITWhitelist() |
348 | { |
349 | static LazyNeverDestroyed<FunctionWhitelist> baselineWhitelist; |
350 | static std::once_flag initializeWhitelistFlag; |
351 | std::call_once(initializeWhitelistFlag, [] { |
352 | const char* functionWhitelistFile = Options::jitWhitelist(); |
353 | baselineWhitelist.construct(functionWhitelistFile); |
354 | }); |
355 | return baselineWhitelist; |
356 | } |
357 | |
358 | inline bool shouldJIT(CodeBlock* codeBlock) |
359 | { |
360 | if (!Options::bytecodeRangeToJITCompile().isInRange(codeBlock->instructionsSize()) |
361 | || !ensureGlobalJITWhitelist().contains(codeBlock)) |
362 | return false; |
363 | |
364 | return VM::canUseJIT() && Options::useBaselineJIT(); |
365 | } |
366 | |
367 | // Returns true if we should try to OSR. |
368 | inline bool jitCompileAndSetHeuristics(CodeBlock* codeBlock, ExecState* exec, unsigned loopOSREntryBytecodeOffset = 0) |
369 | { |
370 | VM& vm = exec->vm(); |
371 | DeferGCForAWhile deferGC(vm.heap); // My callers don't set top callframe, so we don't want to GC here at all. |
372 | ASSERT(VM::canUseJIT()); |
373 | |
374 | codeBlock->updateAllValueProfilePredictions(); |
375 | |
376 | if (!codeBlock->checkIfJITThresholdReached()) { |
377 | CODEBLOCK_LOG_EVENT(codeBlock, "delayJITCompile" , ("threshold not reached, counter = " , codeBlock->llintExecuteCounter())); |
378 | if (Options::verboseOSR()) |
379 | dataLogF(" JIT threshold should be lifted.\n" ); |
380 | return false; |
381 | } |
382 | |
383 | JITWorklist::ensureGlobalWorklist().poll(vm); |
384 | |
385 | switch (codeBlock->jitType()) { |
386 | case JITType::BaselineJIT: { |
387 | if (Options::verboseOSR()) |
388 | dataLogF(" Code was already compiled.\n" ); |
389 | codeBlock->jitSoon(); |
390 | return true; |
391 | } |
392 | case JITType::InterpreterThunk: { |
393 | JITWorklist::ensureGlobalWorklist().compileLater(codeBlock, loopOSREntryBytecodeOffset); |
394 | return codeBlock->jitType() == JITType::BaselineJIT; |
395 | } |
396 | default: |
397 | dataLog("Unexpected code block in LLInt: " , *codeBlock, "\n" ); |
398 | RELEASE_ASSERT_NOT_REACHED(); |
399 | return false; |
400 | } |
401 | } |
402 | |
403 | static SlowPathReturnType entryOSR(ExecState* exec, const Instruction*, CodeBlock* codeBlock, const char *name, EntryKind kind) |
404 | { |
405 | if (Options::verboseOSR()) { |
406 | dataLog( |
407 | *codeBlock, ": Entered " , name, " with executeCounter = " , |
408 | codeBlock->llintExecuteCounter(), "\n" ); |
409 | } |
410 | |
411 | if (!shouldJIT(codeBlock)) { |
412 | codeBlock->dontJITAnytimeSoon(); |
413 | LLINT_RETURN_TWO(0, 0); |
414 | } |
415 | if (!jitCompileAndSetHeuristics(codeBlock, exec)) |
416 | LLINT_RETURN_TWO(0, 0); |
417 | |
418 | CODEBLOCK_LOG_EVENT(codeBlock, "OSR entry" , ("in prologue" )); |
419 | |
420 | if (kind == Prologue) |
421 | LLINT_RETURN_TWO(codeBlock->jitCode()->executableAddress(), 0); |
422 | ASSERT(kind == ArityCheck); |
423 | LLINT_RETURN_TWO(codeBlock->jitCode()->addressForCall(MustCheckArity).executableAddress(), 0); |
424 | } |
425 | #else // ENABLE(JIT) |
426 | static SlowPathReturnType entryOSR(ExecState* exec, const Instruction*, CodeBlock* codeBlock, const char*, EntryKind) |
427 | { |
428 | codeBlock->dontJITAnytimeSoon(); |
429 | LLINT_RETURN_TWO(0, exec); |
430 | } |
431 | #endif // ENABLE(JIT) |
432 | |
433 | LLINT_SLOW_PATH_DECL(entry_osr) |
434 | { |
435 | return entryOSR(exec, pc, exec->codeBlock(), "entry_osr" , Prologue); |
436 | } |
437 | |
438 | LLINT_SLOW_PATH_DECL(entry_osr_function_for_call) |
439 | { |
440 | return entryOSR(exec, pc, jsCast<JSFunction*>(exec->jsCallee())->jsExecutable()->codeBlockForCall(), "entry_osr_function_for_call" , Prologue); |
441 | } |
442 | |
443 | LLINT_SLOW_PATH_DECL(entry_osr_function_for_construct) |
444 | { |
445 | return entryOSR(exec, pc, jsCast<JSFunction*>(exec->jsCallee())->jsExecutable()->codeBlockForConstruct(), "entry_osr_function_for_construct" , Prologue); |
446 | } |
447 | |
448 | LLINT_SLOW_PATH_DECL(entry_osr_function_for_call_arityCheck) |
449 | { |
450 | return entryOSR(exec, pc, jsCast<JSFunction*>(exec->jsCallee())->jsExecutable()->codeBlockForCall(), "entry_osr_function_for_call_arityCheck" , ArityCheck); |
451 | } |
452 | |
453 | LLINT_SLOW_PATH_DECL(entry_osr_function_for_construct_arityCheck) |
454 | { |
455 | return entryOSR(exec, pc, jsCast<JSFunction*>(exec->jsCallee())->jsExecutable()->codeBlockForConstruct(), "entry_osr_function_for_construct_arityCheck" , ArityCheck); |
456 | } |
457 | |
458 | LLINT_SLOW_PATH_DECL(loop_osr) |
459 | { |
460 | LLINT_BEGIN_NO_SET_PC(); |
461 | UNUSED_PARAM(throwScope); |
462 | CodeBlock* codeBlock = exec->codeBlock(); |
463 | |
464 | #if ENABLE(JIT) |
465 | if (Options::verboseOSR()) { |
466 | dataLog( |
467 | *codeBlock, ": Entered loop_osr with executeCounter = " , |
468 | codeBlock->llintExecuteCounter(), "\n" ); |
469 | } |
470 | |
471 | unsigned loopOSREntryBytecodeOffset = codeBlock->bytecodeOffset(pc); |
472 | |
473 | if (!shouldJIT(codeBlock)) { |
474 | codeBlock->dontJITAnytimeSoon(); |
475 | LLINT_RETURN_TWO(0, 0); |
476 | } |
477 | |
478 | if (!jitCompileAndSetHeuristics(codeBlock, exec, loopOSREntryBytecodeOffset)) |
479 | LLINT_RETURN_TWO(0, 0); |
480 | |
481 | CODEBLOCK_LOG_EVENT(codeBlock, "osrEntry" , ("at bc#" , loopOSREntryBytecodeOffset)); |
482 | |
483 | ASSERT(codeBlock->jitType() == JITType::BaselineJIT); |
484 | |
485 | const JITCodeMap& codeMap = codeBlock->jitCodeMap(); |
486 | CodeLocationLabel<JSEntryPtrTag> codeLocation = codeMap.find(loopOSREntryBytecodeOffset); |
487 | ASSERT(codeLocation); |
488 | |
489 | void* jumpTarget = codeLocation.executableAddress(); |
490 | ASSERT(jumpTarget); |
491 | |
492 | LLINT_RETURN_TWO(jumpTarget, exec->topOfFrame()); |
493 | #else // ENABLE(JIT) |
494 | UNUSED_PARAM(pc); |
495 | codeBlock->dontJITAnytimeSoon(); |
496 | LLINT_RETURN_TWO(0, 0); |
497 | #endif // ENABLE(JIT) |
498 | } |
499 | |
500 | LLINT_SLOW_PATH_DECL(replace) |
501 | { |
502 | LLINT_BEGIN_NO_SET_PC(); |
503 | UNUSED_PARAM(throwScope); |
504 | CodeBlock* codeBlock = exec->codeBlock(); |
505 | |
506 | #if ENABLE(JIT) |
507 | if (Options::verboseOSR()) { |
508 | dataLog( |
509 | *codeBlock, ": Entered replace with executeCounter = " , |
510 | codeBlock->llintExecuteCounter(), "\n" ); |
511 | } |
512 | |
513 | if (shouldJIT(codeBlock)) |
514 | jitCompileAndSetHeuristics(codeBlock, exec); |
515 | else |
516 | codeBlock->dontJITAnytimeSoon(); |
517 | LLINT_END_IMPL(); |
518 | #else // ENABLE(JIT) |
519 | codeBlock->dontJITAnytimeSoon(); |
520 | LLINT_END_IMPL(); |
521 | #endif // ENABLE(JIT) |
522 | } |
523 | |
524 | LLINT_SLOW_PATH_DECL(stack_check) |
525 | { |
526 | VM& vm = exec->vm(); |
527 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
528 | |
529 | // It's ok to create the NativeCallFrameTracer here before we |
530 | // convertToStackOverflowFrame() because this function is always called |
531 | // after the frame has been propulated with a proper CodeBlock and callee. |
532 | NativeCallFrameTracer tracer(&vm, exec); |
533 | |
534 | LLINT_SET_PC_FOR_STUBS(); |
535 | |
536 | CodeBlock* codeBlock = exec->codeBlock(); |
537 | slowPathLogF("Checking stack height with exec = %p.\n" , exec); |
538 | slowPathLog("CodeBlock = " , codeBlock, "\n" ); |
539 | if (codeBlock) { |
540 | slowPathLogF("Num callee registers = %u.\n" , codeBlock->numCalleeLocals()); |
541 | slowPathLogF("Num vars = %u.\n" , codeBlock->numVars()); |
542 | } |
543 | slowPathLogF("Current OS stack end is at %p.\n" , vm.softStackLimit()); |
544 | #if ENABLE(C_LOOP) |
545 | slowPathLogF("Current C Loop stack end is at %p.\n" , vm.cloopStackLimit()); |
546 | #endif |
547 | |
548 | // If the stack check succeeds and we don't need to throw the error, then |
549 | // we'll return 0 instead. The prologue will check for a non-zero value |
550 | // when determining whether to set the callFrame or not. |
551 | |
552 | // For JIT enabled builds which uses the C stack, the stack is not growable. |
553 | // Hence, if we get here, then we know a stack overflow is imminent. So, just |
554 | // throw the StackOverflowError unconditionally. |
555 | #if ENABLE(C_LOOP) |
556 | Register* topOfFrame = exec->topOfFrame(); |
557 | if (LIKELY(topOfFrame < reinterpret_cast<Register*>(exec))) { |
558 | ASSERT(!vm.interpreter->cloopStack().containsAddress(topOfFrame)); |
559 | if (LIKELY(vm.ensureStackCapacityFor(topOfFrame))) |
560 | LLINT_RETURN_TWO(pc, 0); |
561 | } |
562 | #endif |
563 | |
564 | exec->convertToStackOverflowFrame(vm, codeBlock); |
565 | ErrorHandlingScope errorScope(vm); |
566 | throwStackOverflowError(exec, throwScope); |
567 | pc = returnToThrow(exec); |
568 | LLINT_RETURN_TWO(pc, exec); |
569 | } |
570 | |
571 | LLINT_SLOW_PATH_DECL(slow_path_new_object) |
572 | { |
573 | LLINT_BEGIN(); |
574 | auto bytecode = pc->as<OpNewObject>(); |
575 | auto& metadata = bytecode.metadata(exec); |
576 | LLINT_RETURN(constructEmptyObject(exec, metadata.m_objectAllocationProfile.structure())); |
577 | } |
578 | |
579 | LLINT_SLOW_PATH_DECL(slow_path_new_array) |
580 | { |
581 | LLINT_BEGIN(); |
582 | auto bytecode = pc->as<OpNewArray>(); |
583 | auto& metadata = bytecode.metadata(exec); |
584 | LLINT_RETURN(constructArrayNegativeIndexed(exec, &metadata.m_arrayAllocationProfile, bitwise_cast<JSValue*>(&exec->uncheckedR(bytecode.m_argv)), bytecode.m_argc)); |
585 | } |
586 | |
587 | LLINT_SLOW_PATH_DECL(slow_path_new_array_with_size) |
588 | { |
589 | LLINT_BEGIN(); |
590 | auto bytecode = pc->as<OpNewArrayWithSize>(); |
591 | auto& metadata = bytecode.metadata(exec); |
592 | LLINT_RETURN(constructArrayWithSizeQuirk(exec, &metadata.m_arrayAllocationProfile, exec->lexicalGlobalObject(), getOperand(exec, bytecode.m_length))); |
593 | } |
594 | |
595 | LLINT_SLOW_PATH_DECL(slow_path_new_regexp) |
596 | { |
597 | LLINT_BEGIN(); |
598 | auto bytecode = pc->as<OpNewRegexp>(); |
599 | RegExp* regExp = jsCast<RegExp*>(getOperand(exec, bytecode.m_regexp)); |
600 | ASSERT(regExp->isValid()); |
601 | LLINT_RETURN(RegExpObject::create(vm, exec->lexicalGlobalObject()->regExpStructure(), regExp)); |
602 | } |
603 | |
604 | LLINT_SLOW_PATH_DECL(slow_path_instanceof) |
605 | { |
606 | LLINT_BEGIN(); |
607 | auto bytecode = pc->as<OpInstanceof>(); |
608 | JSValue value = getOperand(exec, bytecode.m_value); |
609 | JSValue proto = getOperand(exec, bytecode.m_prototype); |
610 | LLINT_RETURN(jsBoolean(JSObject::defaultHasInstance(exec, value, proto))); |
611 | } |
612 | |
613 | LLINT_SLOW_PATH_DECL(slow_path_instanceof_custom) |
614 | { |
615 | LLINT_BEGIN(); |
616 | |
617 | auto bytecode = pc->as<OpInstanceofCustom>(); |
618 | JSValue value = getOperand(exec, bytecode.m_value); |
619 | JSValue constructor = getOperand(exec, bytecode.m_constructor); |
620 | JSValue hasInstanceValue = getOperand(exec, bytecode.m_hasInstanceValue); |
621 | |
622 | ASSERT(constructor.isObject()); |
623 | ASSERT(hasInstanceValue != exec->lexicalGlobalObject()->functionProtoHasInstanceSymbolFunction() || !constructor.getObject()->structure(vm)->typeInfo().implementsDefaultHasInstance()); |
624 | |
625 | JSValue result = jsBoolean(constructor.getObject()->hasInstance(exec, value, hasInstanceValue)); |
626 | LLINT_RETURN(result); |
627 | } |
628 | |
629 | LLINT_SLOW_PATH_DECL(slow_path_try_get_by_id) |
630 | { |
631 | LLINT_BEGIN(); |
632 | auto bytecode = pc->as<OpTryGetById>(); |
633 | CodeBlock* codeBlock = exec->codeBlock(); |
634 | const Identifier& ident = codeBlock->identifier(bytecode.m_property); |
635 | JSValue baseValue = getOperand(exec, bytecode.m_base); |
636 | PropertySlot slot(baseValue, PropertySlot::PropertySlot::InternalMethodType::VMInquiry); |
637 | |
638 | baseValue.getPropertySlot(exec, ident, slot); |
639 | JSValue result = slot.getPureResult(); |
640 | |
641 | LLINT_RETURN_PROFILED(result); |
642 | } |
643 | |
644 | LLINT_SLOW_PATH_DECL(slow_path_get_by_id_direct) |
645 | { |
646 | LLINT_BEGIN(); |
647 | auto bytecode = pc->as<OpGetByIdDirect>(); |
648 | CodeBlock* codeBlock = exec->codeBlock(); |
649 | const Identifier& ident = codeBlock->identifier(bytecode.m_property); |
650 | JSValue baseValue = getOperand(exec, bytecode.m_base); |
651 | PropertySlot slot(baseValue, PropertySlot::PropertySlot::InternalMethodType::GetOwnProperty); |
652 | |
653 | bool found = baseValue.getOwnPropertySlot(exec, ident, slot); |
654 | LLINT_CHECK_EXCEPTION(); |
655 | JSValue result = found ? slot.getValue(exec, ident) : jsUndefined(); |
656 | LLINT_CHECK_EXCEPTION(); |
657 | |
658 | if (!LLINT_ALWAYS_ACCESS_SLOW && slot.isCacheable()) { |
659 | auto& metadata = bytecode.metadata(exec); |
660 | { |
661 | StructureID oldStructureID = metadata.m_structureID; |
662 | if (oldStructureID) { |
663 | Structure* a = vm.heap.structureIDTable().get(oldStructureID); |
664 | Structure* b = baseValue.asCell()->structure(vm); |
665 | |
666 | if (Structure::shouldConvertToPolyProto(a, b)) { |
667 | ASSERT(a->rareData()->sharedPolyProtoWatchpoint().get() == b->rareData()->sharedPolyProtoWatchpoint().get()); |
668 | a->rareData()->sharedPolyProtoWatchpoint()->invalidate(vm, StringFireDetail("Detected poly proto opportunity." )); |
669 | } |
670 | } |
671 | } |
672 | |
673 | JSCell* baseCell = baseValue.asCell(); |
674 | Structure* structure = baseCell->structure(vm); |
675 | if (slot.isValue()) { |
676 | // Start out by clearing out the old cache. |
677 | metadata.m_structureID = 0; |
678 | metadata.m_offset = 0; |
679 | |
680 | if (structure->propertyAccessesAreCacheable() |
681 | && !structure->needImpurePropertyWatchpoint()) { |
682 | vm.heap.writeBarrier(codeBlock); |
683 | |
684 | ConcurrentJSLocker locker(codeBlock->m_lock); |
685 | |
686 | metadata.m_structureID = structure->id(); |
687 | metadata.m_offset = slot.cachedOffset(); |
688 | } |
689 | } |
690 | } |
691 | |
692 | LLINT_RETURN_PROFILED(result); |
693 | } |
694 | |
695 | |
696 | static void setupGetByIdPrototypeCache(ExecState* exec, VM& vm, const Instruction* pc, OpGetById::Metadata& metadata, JSCell* baseCell, PropertySlot& slot, const Identifier& ident) |
697 | { |
698 | CodeBlock* codeBlock = exec->codeBlock(); |
699 | Structure* structure = baseCell->structure(vm); |
700 | |
701 | if (structure->typeInfo().prohibitsPropertyCaching()) |
702 | return; |
703 | |
704 | if (structure->needImpurePropertyWatchpoint()) |
705 | return; |
706 | |
707 | if (structure->isDictionary()) { |
708 | if (structure->hasBeenFlattenedBefore()) |
709 | return; |
710 | structure->flattenDictionaryStructure(vm, jsCast<JSObject*>(baseCell)); |
711 | } |
712 | |
713 | ObjectPropertyConditionSet conditions; |
714 | if (slot.isUnset()) |
715 | conditions = generateConditionsForPropertyMiss(vm, codeBlock, exec, structure, ident.impl()); |
716 | else |
717 | conditions = generateConditionsForPrototypePropertyHit(vm, codeBlock, exec, structure, slot.slotBase(), ident.impl()); |
718 | |
719 | if (!conditions.isValid()) |
720 | return; |
721 | |
722 | unsigned bytecodeOffset = codeBlock->bytecodeOffset(pc); |
723 | PropertyOffset offset = invalidOffset; |
724 | CodeBlock::StructureWatchpointMap& watchpointMap = codeBlock->llintGetByIdWatchpointMap(); |
725 | Vector<LLIntPrototypeLoadAdaptiveStructureWatchpoint> watchpoints; |
726 | watchpoints.reserveInitialCapacity(conditions.size()); |
727 | for (ObjectPropertyCondition condition : conditions) { |
728 | if (!condition.isWatchable()) |
729 | return; |
730 | if (condition.condition().kind() == PropertyCondition::Presence) |
731 | offset = condition.condition().offset(); |
732 | watchpoints.uncheckedConstructAndAppend(codeBlock, condition, bytecodeOffset); |
733 | watchpoints.last().install(vm); |
734 | } |
735 | |
736 | ASSERT((offset == invalidOffset) == slot.isUnset()); |
737 | auto result = watchpointMap.add(std::make_tuple(structure->id(), bytecodeOffset), WTFMove(watchpoints)); |
738 | ASSERT_UNUSED(result, result.isNewEntry); |
739 | |
740 | ConcurrentJSLocker locker(codeBlock->m_lock); |
741 | |
742 | if (slot.isUnset()) { |
743 | metadata.m_modeMetadata.setUnsetMode(structure); |
744 | return; |
745 | } |
746 | ASSERT(slot.isValue()); |
747 | |
748 | metadata.m_modeMetadata.setProtoLoadMode(structure, offset, slot.slotBase()); |
749 | } |
750 | |
751 | |
752 | LLINT_SLOW_PATH_DECL(slow_path_get_by_id) |
753 | { |
754 | LLINT_BEGIN(); |
755 | auto bytecode = pc->as<OpGetById>(); |
756 | auto& metadata = bytecode.metadata(exec); |
757 | CodeBlock* codeBlock = exec->codeBlock(); |
758 | const Identifier& ident = codeBlock->identifier(bytecode.m_property); |
759 | JSValue baseValue = getOperand(exec, bytecode.m_base); |
760 | PropertySlot slot(baseValue, PropertySlot::PropertySlot::InternalMethodType::Get); |
761 | |
762 | JSValue result = baseValue.get(exec, ident, slot); |
763 | LLINT_CHECK_EXCEPTION(); |
764 | exec->uncheckedR(bytecode.m_dst) = result; |
765 | |
766 | if (!LLINT_ALWAYS_ACCESS_SLOW |
767 | && baseValue.isCell() |
768 | && slot.isCacheable()) { |
769 | { |
770 | StructureID oldStructureID; |
771 | switch (metadata.m_modeMetadata.mode) { |
772 | case GetByIdMode::Default: |
773 | oldStructureID = metadata.m_modeMetadata.defaultMode.structureID; |
774 | break; |
775 | case GetByIdMode::Unset: |
776 | oldStructureID = metadata.m_modeMetadata.unsetMode.structureID; |
777 | break; |
778 | case GetByIdMode::ProtoLoad: |
779 | oldStructureID = metadata.m_modeMetadata.protoLoadMode.structureID; |
780 | break; |
781 | default: |
782 | oldStructureID = 0; |
783 | } |
784 | if (oldStructureID) { |
785 | Structure* a = vm.heap.structureIDTable().get(oldStructureID); |
786 | Structure* b = baseValue.asCell()->structure(vm); |
787 | |
788 | if (Structure::shouldConvertToPolyProto(a, b)) { |
789 | ASSERT(a->rareData()->sharedPolyProtoWatchpoint().get() == b->rareData()->sharedPolyProtoWatchpoint().get()); |
790 | a->rareData()->sharedPolyProtoWatchpoint()->invalidate(vm, StringFireDetail("Detected poly proto opportunity." )); |
791 | } |
792 | } |
793 | } |
794 | |
795 | JSCell* baseCell = baseValue.asCell(); |
796 | Structure* structure = baseCell->structure(vm); |
797 | if (slot.isValue() && slot.slotBase() == baseValue) { |
798 | ConcurrentJSLocker locker(codeBlock->m_lock); |
799 | |
800 | // Start out by clearing out the old cache. |
801 | metadata.m_modeMetadata.clearToDefaultModeWithoutCache(); |
802 | |
803 | // Prevent the prototype cache from ever happening. |
804 | metadata.m_modeMetadata.hitCountForLLIntCaching = 0; |
805 | |
806 | if (structure->propertyAccessesAreCacheable() |
807 | && !structure->needImpurePropertyWatchpoint()) { |
808 | vm.heap.writeBarrier(codeBlock); |
809 | |
810 | metadata.m_modeMetadata.defaultMode.structureID = structure->id(); |
811 | metadata.m_modeMetadata.defaultMode.cachedOffset = slot.cachedOffset(); |
812 | } |
813 | } else if (UNLIKELY(metadata.m_modeMetadata.hitCountForLLIntCaching && (slot.isValue() || slot.isUnset()))) { |
814 | ASSERT(slot.slotBase() != baseValue); |
815 | |
816 | if (!(--metadata.m_modeMetadata.hitCountForLLIntCaching)) |
817 | setupGetByIdPrototypeCache(exec, vm, pc, metadata, baseCell, slot, ident); |
818 | } |
819 | } else if (!LLINT_ALWAYS_ACCESS_SLOW |
820 | && isJSArray(baseValue) |
821 | && ident == vm.propertyNames->length) { |
822 | ConcurrentJSLocker locker(codeBlock->m_lock); |
823 | metadata.m_modeMetadata.setArrayLengthMode(); |
824 | metadata.m_modeMetadata.arrayLengthMode.arrayProfile.observeStructure(baseValue.asCell()->structure(vm)); |
825 | } |
826 | |
827 | LLINT_PROFILE_VALUE(result); |
828 | LLINT_END(); |
829 | } |
830 | |
831 | LLINT_SLOW_PATH_DECL(slow_path_put_by_id) |
832 | { |
833 | LLINT_BEGIN(); |
834 | auto bytecode = pc->as<OpPutById>(); |
835 | auto& metadata = bytecode.metadata(exec); |
836 | CodeBlock* codeBlock = exec->codeBlock(); |
837 | const Identifier& ident = codeBlock->identifier(bytecode.m_property); |
838 | |
839 | JSValue baseValue = getOperand(exec, bytecode.m_base); |
840 | PutPropertySlot slot(baseValue, codeBlock->isStrictMode(), codeBlock->putByIdContext()); |
841 | if (bytecode.m_flags & PutByIdIsDirect) |
842 | CommonSlowPaths::putDirectWithReify(vm, exec, asObject(baseValue), ident, getOperand(exec, bytecode.m_value), slot); |
843 | else |
844 | baseValue.putInline(exec, ident, getOperand(exec, bytecode.m_value), slot); |
845 | LLINT_CHECK_EXCEPTION(); |
846 | |
847 | if (!LLINT_ALWAYS_ACCESS_SLOW |
848 | && baseValue.isCell() |
849 | && slot.isCacheablePut()) { |
850 | |
851 | { |
852 | StructureID oldStructureID = metadata.m_oldStructureID; |
853 | if (oldStructureID) { |
854 | Structure* a = vm.heap.structureIDTable().get(oldStructureID); |
855 | Structure* b = baseValue.asCell()->structure(vm); |
856 | if (slot.type() == PutPropertySlot::NewProperty) |
857 | b = b->previousID(); |
858 | |
859 | if (Structure::shouldConvertToPolyProto(a, b)) { |
860 | a->rareData()->sharedPolyProtoWatchpoint()->invalidate(vm, StringFireDetail("Detected poly proto opportunity." )); |
861 | b->rareData()->sharedPolyProtoWatchpoint()->invalidate(vm, StringFireDetail("Detected poly proto opportunity." )); |
862 | } |
863 | } |
864 | } |
865 | |
866 | // Start out by clearing out the old cache. |
867 | metadata.m_oldStructureID = 0; |
868 | metadata.m_offset = 0; |
869 | metadata.m_newStructureID = 0; |
870 | metadata.m_structureChain.clear(); |
871 | |
872 | JSCell* baseCell = baseValue.asCell(); |
873 | Structure* structure = baseCell->structure(vm); |
874 | |
875 | if (!structure->isUncacheableDictionary() |
876 | && !structure->typeInfo().prohibitsPropertyCaching() |
877 | && baseCell == slot.base()) { |
878 | |
879 | vm.heap.writeBarrier(codeBlock); |
880 | |
881 | if (slot.type() == PutPropertySlot::NewProperty) { |
882 | GCSafeConcurrentJSLocker locker(codeBlock->m_lock, vm.heap); |
883 | |
884 | if (!structure->isDictionary() && structure->previousID()->outOfLineCapacity() == structure->outOfLineCapacity()) { |
885 | ASSERT(structure->previousID()->transitionWatchpointSetHasBeenInvalidated()); |
886 | |
887 | bool sawPolyProto = false; |
888 | auto result = normalizePrototypeChain(exec, baseCell, sawPolyProto); |
889 | if (result != InvalidPrototypeChain && !sawPolyProto) { |
890 | ASSERT(structure->previousID()->isObject()); |
891 | metadata.m_oldStructureID = structure->previousID()->id(); |
892 | metadata.m_offset = slot.cachedOffset(); |
893 | metadata.m_newStructureID = structure->id(); |
894 | if (!(bytecode.m_flags & PutByIdIsDirect)) { |
895 | StructureChain* chain = structure->prototypeChain(exec, asObject(baseCell)); |
896 | ASSERT(chain); |
897 | metadata.m_structureChain.set(vm, codeBlock, chain); |
898 | } |
899 | } |
900 | } |
901 | } else { |
902 | structure->didCachePropertyReplacement(vm, slot.cachedOffset()); |
903 | metadata.m_oldStructureID = structure->id(); |
904 | metadata.m_offset = slot.cachedOffset(); |
905 | } |
906 | } |
907 | } |
908 | |
909 | LLINT_END(); |
910 | } |
911 | |
912 | LLINT_SLOW_PATH_DECL(slow_path_del_by_id) |
913 | { |
914 | LLINT_BEGIN(); |
915 | auto bytecode = pc->as<OpDelById>(); |
916 | CodeBlock* codeBlock = exec->codeBlock(); |
917 | JSObject* baseObject = getOperand(exec, bytecode.m_base).toObject(exec); |
918 | LLINT_CHECK_EXCEPTION(); |
919 | bool couldDelete = baseObject->methodTable(vm)->deleteProperty(baseObject, exec, codeBlock->identifier(bytecode.m_property)); |
920 | LLINT_CHECK_EXCEPTION(); |
921 | if (!couldDelete && codeBlock->isStrictMode()) |
922 | LLINT_THROW(createTypeError(exec, UnableToDeletePropertyError)); |
923 | LLINT_RETURN(jsBoolean(couldDelete)); |
924 | } |
925 | |
926 | static ALWAYS_INLINE JSValue getByVal(VM& vm, ExecState* exec, OpGetByVal bytecode) |
927 | { |
928 | JSValue baseValue = getOperand(exec, bytecode.m_base); |
929 | JSValue subscript = getOperand(exec, bytecode.m_property); |
930 | auto scope = DECLARE_THROW_SCOPE(vm); |
931 | |
932 | if (LIKELY(baseValue.isCell() && subscript.isString())) { |
933 | Structure& structure = *baseValue.asCell()->structure(vm); |
934 | if (JSCell::canUseFastGetOwnProperty(structure)) { |
935 | RefPtr<AtomStringImpl> existingAtomString = asString(subscript)->toExistingAtomString(exec); |
936 | RETURN_IF_EXCEPTION(scope, JSValue()); |
937 | if (existingAtomString) { |
938 | if (JSValue result = baseValue.asCell()->fastGetOwnProperty(vm, structure, existingAtomString.get())) |
939 | return result; |
940 | } |
941 | } |
942 | } |
943 | |
944 | if (subscript.isUInt32()) { |
945 | uint32_t i = subscript.asUInt32(); |
946 | auto& metadata = bytecode.metadata(exec); |
947 | ArrayProfile* arrayProfile = &metadata.m_arrayProfile; |
948 | |
949 | if (isJSString(baseValue)) { |
950 | if (asString(baseValue)->canGetIndex(i)) { |
951 | scope.release(); |
952 | return asString(baseValue)->getIndex(exec, i); |
953 | } |
954 | arrayProfile->setOutOfBounds(); |
955 | } else if (baseValue.isObject()) { |
956 | JSObject* object = asObject(baseValue); |
957 | if (object->canGetIndexQuickly(i)) |
958 | return object->getIndexQuickly(i); |
959 | |
960 | bool skipMarkingOutOfBounds = false; |
961 | |
962 | if (object->indexingType() == ArrayWithContiguous && i < object->butterfly()->publicLength()) { |
963 | // FIXME: expand this to ArrayStorage, Int32, and maybe Double: |
964 | // https://bugs.webkit.org/show_bug.cgi?id=182940 |
965 | auto* globalObject = object->globalObject(vm); |
966 | skipMarkingOutOfBounds = globalObject->isOriginalArrayStructure(object->structure(vm)) && globalObject->arrayPrototypeChainIsSane(); |
967 | } |
968 | |
969 | if (!skipMarkingOutOfBounds && !CommonSlowPaths::canAccessArgumentIndexQuickly(*object, i)) |
970 | arrayProfile->setOutOfBounds(); |
971 | } |
972 | |
973 | scope.release(); |
974 | return baseValue.get(exec, i); |
975 | } |
976 | |
977 | baseValue.requireObjectCoercible(exec); |
978 | RETURN_IF_EXCEPTION(scope, JSValue()); |
979 | auto property = subscript.toPropertyKey(exec); |
980 | RETURN_IF_EXCEPTION(scope, JSValue()); |
981 | scope.release(); |
982 | return baseValue.get(exec, property); |
983 | } |
984 | |
985 | LLINT_SLOW_PATH_DECL(slow_path_get_by_val) |
986 | { |
987 | LLINT_BEGIN(); |
988 | auto bytecode = pc->as<OpGetByVal>(); |
989 | LLINT_RETURN_PROFILED(getByVal(vm, exec, bytecode)); |
990 | } |
991 | |
992 | LLINT_SLOW_PATH_DECL(slow_path_put_by_val) |
993 | { |
994 | LLINT_BEGIN(); |
995 | |
996 | auto bytecode = pc->as<OpPutByVal>(); |
997 | JSValue baseValue = getOperand(exec, bytecode.m_base); |
998 | JSValue subscript = getOperand(exec, bytecode.m_property); |
999 | JSValue value = getOperand(exec, bytecode.m_value); |
1000 | bool isStrictMode = exec->codeBlock()->isStrictMode(); |
1001 | |
1002 | if (LIKELY(subscript.isUInt32())) { |
1003 | uint32_t i = subscript.asUInt32(); |
1004 | if (baseValue.isObject()) { |
1005 | JSObject* object = asObject(baseValue); |
1006 | if (object->canSetIndexQuickly(i)) |
1007 | object->setIndexQuickly(vm, i, value); |
1008 | else |
1009 | object->methodTable(vm)->putByIndex(object, exec, i, value, isStrictMode); |
1010 | LLINT_END(); |
1011 | } |
1012 | baseValue.putByIndex(exec, i, value, isStrictMode); |
1013 | LLINT_END(); |
1014 | } |
1015 | |
1016 | auto property = subscript.toPropertyKey(exec); |
1017 | LLINT_CHECK_EXCEPTION(); |
1018 | PutPropertySlot slot(baseValue, isStrictMode); |
1019 | baseValue.put(exec, property, value, slot); |
1020 | LLINT_END(); |
1021 | } |
1022 | |
1023 | LLINT_SLOW_PATH_DECL(slow_path_put_by_val_direct) |
1024 | { |
1025 | LLINT_BEGIN(); |
1026 | |
1027 | auto bytecode = pc->as<OpPutByValDirect>(); |
1028 | JSValue baseValue = getOperand(exec, bytecode.m_base); |
1029 | JSValue subscript = getOperand(exec, bytecode.m_property); |
1030 | JSValue value = getOperand(exec, bytecode.m_value); |
1031 | RELEASE_ASSERT(baseValue.isObject()); |
1032 | JSObject* baseObject = asObject(baseValue); |
1033 | bool isStrictMode = exec->codeBlock()->isStrictMode(); |
1034 | if (LIKELY(subscript.isUInt32())) { |
1035 | // Despite its name, JSValue::isUInt32 will return true only for positive boxed int32_t; all those values are valid array indices. |
1036 | ASSERT(isIndex(subscript.asUInt32())); |
1037 | baseObject->putDirectIndex(exec, subscript.asUInt32(), value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow); |
1038 | LLINT_END(); |
1039 | } |
1040 | |
1041 | if (subscript.isDouble()) { |
1042 | double subscriptAsDouble = subscript.asDouble(); |
1043 | uint32_t subscriptAsUInt32 = static_cast<uint32_t>(subscriptAsDouble); |
1044 | if (subscriptAsDouble == subscriptAsUInt32 && isIndex(subscriptAsUInt32)) { |
1045 | baseObject->putDirectIndex(exec, subscriptAsUInt32, value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow); |
1046 | LLINT_END(); |
1047 | } |
1048 | } |
1049 | |
1050 | // Don't put to an object if toString threw an exception. |
1051 | auto property = subscript.toPropertyKey(exec); |
1052 | if (UNLIKELY(throwScope.exception())) |
1053 | LLINT_END(); |
1054 | |
1055 | if (Optional<uint32_t> index = parseIndex(property)) |
1056 | baseObject->putDirectIndex(exec, index.value(), value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow); |
1057 | else { |
1058 | PutPropertySlot slot(baseObject, isStrictMode); |
1059 | CommonSlowPaths::putDirectWithReify(vm, exec, baseObject, property, value, slot); |
1060 | } |
1061 | LLINT_END(); |
1062 | } |
1063 | |
1064 | LLINT_SLOW_PATH_DECL(slow_path_del_by_val) |
1065 | { |
1066 | LLINT_BEGIN(); |
1067 | auto bytecode = pc->as<OpDelByVal>(); |
1068 | JSValue baseValue = getOperand(exec, bytecode.m_base); |
1069 | JSObject* baseObject = baseValue.toObject(exec); |
1070 | LLINT_CHECK_EXCEPTION(); |
1071 | |
1072 | JSValue subscript = getOperand(exec, bytecode.m_property); |
1073 | |
1074 | bool couldDelete; |
1075 | |
1076 | uint32_t i; |
1077 | if (subscript.getUInt32(i)) |
1078 | couldDelete = baseObject->methodTable(vm)->deletePropertyByIndex(baseObject, exec, i); |
1079 | else { |
1080 | LLINT_CHECK_EXCEPTION(); |
1081 | auto property = subscript.toPropertyKey(exec); |
1082 | LLINT_CHECK_EXCEPTION(); |
1083 | couldDelete = baseObject->methodTable(vm)->deleteProperty(baseObject, exec, property); |
1084 | } |
1085 | LLINT_CHECK_EXCEPTION(); |
1086 | |
1087 | if (!couldDelete && exec->codeBlock()->isStrictMode()) |
1088 | LLINT_THROW(createTypeError(exec, UnableToDeletePropertyError)); |
1089 | |
1090 | LLINT_RETURN(jsBoolean(couldDelete)); |
1091 | } |
1092 | |
1093 | LLINT_SLOW_PATH_DECL(slow_path_put_getter_by_id) |
1094 | { |
1095 | LLINT_BEGIN(); |
1096 | auto bytecode = pc->as<OpPutGetterById>(); |
1097 | ASSERT(getNonConstantOperand(exec, bytecode.m_base).isObject()); |
1098 | JSObject* baseObj = asObject(getNonConstantOperand(exec, bytecode.m_base)); |
1099 | |
1100 | unsigned options = bytecode.m_attributes; |
1101 | |
1102 | JSValue getter = getNonConstantOperand(exec, bytecode.m_accessor); |
1103 | ASSERT(getter.isObject()); |
1104 | |
1105 | baseObj->putGetter(exec, exec->codeBlock()->identifier(bytecode.m_property), asObject(getter), options); |
1106 | LLINT_END(); |
1107 | } |
1108 | |
1109 | LLINT_SLOW_PATH_DECL(slow_path_put_setter_by_id) |
1110 | { |
1111 | LLINT_BEGIN(); |
1112 | auto bytecode = pc->as<OpPutSetterById>(); |
1113 | ASSERT(getNonConstantOperand(exec, bytecode.m_base).isObject()); |
1114 | JSObject* baseObj = asObject(getNonConstantOperand(exec, bytecode.m_base)); |
1115 | |
1116 | unsigned options = bytecode.m_attributes; |
1117 | |
1118 | JSValue setter = getNonConstantOperand(exec, bytecode.m_accessor); |
1119 | ASSERT(setter.isObject()); |
1120 | |
1121 | baseObj->putSetter(exec, exec->codeBlock()->identifier(bytecode.m_property), asObject(setter), options); |
1122 | LLINT_END(); |
1123 | } |
1124 | |
1125 | LLINT_SLOW_PATH_DECL(slow_path_put_getter_setter_by_id) |
1126 | { |
1127 | LLINT_BEGIN(); |
1128 | auto bytecode = pc->as<OpPutGetterSetterById>(); |
1129 | ASSERT(getNonConstantOperand(exec, bytecode.m_base).isObject()); |
1130 | JSObject* baseObject = asObject(getNonConstantOperand(exec, bytecode.m_base)); |
1131 | |
1132 | JSValue getter = getNonConstantOperand(exec, bytecode.m_getter); |
1133 | JSValue setter = getNonConstantOperand(exec, bytecode.m_setter); |
1134 | ASSERT(getter.isObject() || setter.isObject()); |
1135 | GetterSetter* accessor = GetterSetter::create(vm, exec->lexicalGlobalObject(), getter, setter); |
1136 | |
1137 | CommonSlowPaths::putDirectAccessorWithReify(vm, exec, baseObject, exec->codeBlock()->identifier(bytecode.m_property), accessor, bytecode.m_attributes); |
1138 | LLINT_END(); |
1139 | } |
1140 | |
1141 | LLINT_SLOW_PATH_DECL(slow_path_put_getter_by_val) |
1142 | { |
1143 | LLINT_BEGIN(); |
1144 | auto bytecode = pc->as<OpPutGetterByVal>(); |
1145 | ASSERT(getNonConstantOperand(exec, bytecode.m_base).isObject()); |
1146 | JSObject* baseObj = asObject(getNonConstantOperand(exec, bytecode.m_base)); |
1147 | JSValue subscript = getOperand(exec, bytecode.m_property); |
1148 | |
1149 | unsigned options = bytecode.m_attributes; |
1150 | |
1151 | JSValue getter = getNonConstantOperand(exec, bytecode.m_accessor); |
1152 | ASSERT(getter.isObject()); |
1153 | |
1154 | auto property = subscript.toPropertyKey(exec); |
1155 | LLINT_CHECK_EXCEPTION(); |
1156 | |
1157 | baseObj->putGetter(exec, property, asObject(getter), options); |
1158 | LLINT_END(); |
1159 | } |
1160 | |
1161 | LLINT_SLOW_PATH_DECL(slow_path_put_setter_by_val) |
1162 | { |
1163 | LLINT_BEGIN(); |
1164 | auto bytecode = pc->as<OpPutSetterByVal>(); |
1165 | ASSERT(getNonConstantOperand(exec, bytecode.m_base).isObject()); |
1166 | JSObject* baseObj = asObject(getNonConstantOperand(exec, bytecode.m_base)); |
1167 | JSValue subscript = getOperand(exec, bytecode.m_property); |
1168 | |
1169 | unsigned options = bytecode.m_attributes; |
1170 | |
1171 | JSValue setter = getNonConstantOperand(exec, bytecode.m_accessor); |
1172 | ASSERT(setter.isObject()); |
1173 | |
1174 | auto property = subscript.toPropertyKey(exec); |
1175 | LLINT_CHECK_EXCEPTION(); |
1176 | |
1177 | baseObj->putSetter(exec, property, asObject(setter), options); |
1178 | LLINT_END(); |
1179 | } |
1180 | |
1181 | LLINT_SLOW_PATH_DECL(slow_path_jtrue) |
1182 | { |
1183 | LLINT_BEGIN(); |
1184 | auto bytecode = pc->as<OpJtrue>(); |
1185 | LLINT_BRANCH(getOperand(exec, bytecode.m_condition).toBoolean(exec)); |
1186 | } |
1187 | |
1188 | LLINT_SLOW_PATH_DECL(slow_path_jfalse) |
1189 | { |
1190 | LLINT_BEGIN(); |
1191 | auto bytecode = pc->as<OpJfalse>(); |
1192 | LLINT_BRANCH(!getOperand(exec, bytecode.m_condition).toBoolean(exec)); |
1193 | } |
1194 | |
1195 | LLINT_SLOW_PATH_DECL(slow_path_jless) |
1196 | { |
1197 | LLINT_BEGIN(); |
1198 | auto bytecode = pc->as<OpJless>(); |
1199 | LLINT_BRANCH(jsLess<true>(exec, getOperand(exec, bytecode.m_lhs), getOperand(exec, bytecode.m_rhs))); |
1200 | } |
1201 | |
1202 | LLINT_SLOW_PATH_DECL(slow_path_jnless) |
1203 | { |
1204 | LLINT_BEGIN(); |
1205 | auto bytecode = pc->as<OpJnless>(); |
1206 | LLINT_BRANCH(!jsLess<true>(exec, getOperand(exec, bytecode.m_lhs), getOperand(exec, bytecode.m_rhs))); |
1207 | } |
1208 | |
1209 | LLINT_SLOW_PATH_DECL(slow_path_jgreater) |
1210 | { |
1211 | LLINT_BEGIN(); |
1212 | auto bytecode = pc->as<OpJgreater>(); |
1213 | LLINT_BRANCH(jsLess<false>(exec, getOperand(exec, bytecode.m_rhs), getOperand(exec, bytecode.m_lhs))); |
1214 | } |
1215 | |
1216 | LLINT_SLOW_PATH_DECL(slow_path_jngreater) |
1217 | { |
1218 | LLINT_BEGIN(); |
1219 | auto bytecode = pc->as<OpJngreater>(); |
1220 | LLINT_BRANCH(!jsLess<false>(exec, getOperand(exec, bytecode.m_rhs), getOperand(exec, bytecode.m_lhs))); |
1221 | } |
1222 | |
1223 | LLINT_SLOW_PATH_DECL(slow_path_jlesseq) |
1224 | { |
1225 | LLINT_BEGIN(); |
1226 | auto bytecode = pc->as<OpJlesseq>(); |
1227 | LLINT_BRANCH(jsLessEq<true>(exec, getOperand(exec, bytecode.m_lhs), getOperand(exec, bytecode.m_rhs))); |
1228 | } |
1229 | |
1230 | LLINT_SLOW_PATH_DECL(slow_path_jnlesseq) |
1231 | { |
1232 | LLINT_BEGIN(); |
1233 | auto bytecode = pc->as<OpJnlesseq>(); |
1234 | LLINT_BRANCH(!jsLessEq<true>(exec, getOperand(exec, bytecode.m_lhs), getOperand(exec, bytecode.m_rhs))); |
1235 | } |
1236 | |
1237 | LLINT_SLOW_PATH_DECL(slow_path_jgreatereq) |
1238 | { |
1239 | LLINT_BEGIN(); |
1240 | auto bytecode = pc->as<OpJgreatereq>(); |
1241 | LLINT_BRANCH(jsLessEq<false>(exec, getOperand(exec, bytecode.m_rhs), getOperand(exec, bytecode.m_lhs))); |
1242 | } |
1243 | |
1244 | LLINT_SLOW_PATH_DECL(slow_path_jngreatereq) |
1245 | { |
1246 | LLINT_BEGIN(); |
1247 | auto bytecode = pc->as<OpJngreatereq>(); |
1248 | LLINT_BRANCH(!jsLessEq<false>(exec, getOperand(exec, bytecode.m_rhs), getOperand(exec, bytecode.m_lhs))); |
1249 | } |
1250 | |
1251 | LLINT_SLOW_PATH_DECL(slow_path_jeq) |
1252 | { |
1253 | LLINT_BEGIN(); |
1254 | auto bytecode = pc->as<OpJeq>(); |
1255 | LLINT_BRANCH(JSValue::equal(exec, getOperand(exec, bytecode.m_lhs), getOperand(exec, bytecode.m_rhs))); |
1256 | } |
1257 | |
1258 | LLINT_SLOW_PATH_DECL(slow_path_jneq) |
1259 | { |
1260 | LLINT_BEGIN(); |
1261 | auto bytecode = pc->as<OpJneq>(); |
1262 | LLINT_BRANCH(!JSValue::equal(exec, getOperand(exec, bytecode.m_lhs), getOperand(exec, bytecode.m_rhs))); |
1263 | } |
1264 | |
1265 | LLINT_SLOW_PATH_DECL(slow_path_jstricteq) |
1266 | { |
1267 | LLINT_BEGIN(); |
1268 | auto bytecode = pc->as<OpJstricteq>(); |
1269 | LLINT_BRANCH(JSValue::strictEqual(exec, getOperand(exec, bytecode.m_lhs), getOperand(exec, bytecode.m_rhs))); |
1270 | } |
1271 | |
1272 | LLINT_SLOW_PATH_DECL(slow_path_jnstricteq) |
1273 | { |
1274 | LLINT_BEGIN(); |
1275 | auto bytecode = pc->as<OpJnstricteq>(); |
1276 | LLINT_BRANCH(!JSValue::strictEqual(exec, getOperand(exec, bytecode.m_lhs), getOperand(exec, bytecode.m_rhs))); |
1277 | } |
1278 | |
1279 | LLINT_SLOW_PATH_DECL(slow_path_switch_imm) |
1280 | { |
1281 | LLINT_BEGIN(); |
1282 | auto bytecode = pc->as<OpSwitchImm>(); |
1283 | JSValue scrutinee = getOperand(exec, bytecode.m_scrutinee); |
1284 | ASSERT(scrutinee.isDouble()); |
1285 | double value = scrutinee.asDouble(); |
1286 | int32_t intValue = static_cast<int32_t>(value); |
1287 | int defaultOffset = JUMP_OFFSET(bytecode.m_defaultOffset); |
1288 | if (value == intValue) { |
1289 | CodeBlock* codeBlock = exec->codeBlock(); |
1290 | JUMP_TO(codeBlock->switchJumpTable(bytecode.m_tableIndex).offsetForValue(intValue, defaultOffset)); |
1291 | } else |
1292 | JUMP_TO(defaultOffset); |
1293 | LLINT_END(); |
1294 | } |
1295 | |
1296 | LLINT_SLOW_PATH_DECL(slow_path_switch_char) |
1297 | { |
1298 | LLINT_BEGIN(); |
1299 | auto bytecode = pc->as<OpSwitchChar>(); |
1300 | JSValue scrutinee = getOperand(exec, bytecode.m_scrutinee); |
1301 | ASSERT(scrutinee.isString()); |
1302 | JSString* string = asString(scrutinee); |
1303 | ASSERT(string->length() == 1); |
1304 | int defaultOffset = JUMP_OFFSET(bytecode.m_defaultOffset); |
1305 | StringImpl* impl = string->value(exec).impl(); |
1306 | CodeBlock* codeBlock = exec->codeBlock(); |
1307 | JUMP_TO(codeBlock->switchJumpTable(bytecode.m_tableIndex).offsetForValue((*impl)[0], defaultOffset)); |
1308 | LLINT_END(); |
1309 | } |
1310 | |
1311 | LLINT_SLOW_PATH_DECL(slow_path_switch_string) |
1312 | { |
1313 | LLINT_BEGIN(); |
1314 | auto bytecode = pc->as<OpSwitchString>(); |
1315 | JSValue scrutinee = getOperand(exec, bytecode.m_scrutinee); |
1316 | int defaultOffset = JUMP_OFFSET(bytecode.m_defaultOffset); |
1317 | if (!scrutinee.isString()) |
1318 | JUMP_TO(defaultOffset); |
1319 | else { |
1320 | CodeBlock* codeBlock = exec->codeBlock(); |
1321 | JUMP_TO(codeBlock->stringSwitchJumpTable(bytecode.m_tableIndex).offsetForValue(asString(scrutinee)->value(exec).impl(), defaultOffset)); |
1322 | } |
1323 | LLINT_END(); |
1324 | } |
1325 | |
1326 | LLINT_SLOW_PATH_DECL(slow_path_new_func) |
1327 | { |
1328 | LLINT_BEGIN(); |
1329 | auto bytecode = pc->as<OpNewFunc>(); |
1330 | CodeBlock* codeBlock = exec->codeBlock(); |
1331 | JSScope* scope = exec->uncheckedR(bytecode.m_scope).Register::scope(); |
1332 | slowPathLogF("Creating function!\n" ); |
1333 | LLINT_RETURN(JSFunction::create(vm, codeBlock->functionDecl(bytecode.m_functionDecl), scope)); |
1334 | } |
1335 | |
1336 | LLINT_SLOW_PATH_DECL(slow_path_new_generator_func) |
1337 | { |
1338 | LLINT_BEGIN(); |
1339 | auto bytecode = pc->as<OpNewGeneratorFunc>(); |
1340 | CodeBlock* codeBlock = exec->codeBlock(); |
1341 | JSScope* scope = exec->uncheckedR(bytecode.m_scope).Register::scope(); |
1342 | slowPathLogF("Creating function!\n" ); |
1343 | LLINT_RETURN(JSGeneratorFunction::create(vm, codeBlock->functionDecl(bytecode.m_functionDecl), scope)); |
1344 | } |
1345 | |
1346 | LLINT_SLOW_PATH_DECL(slow_path_new_async_func) |
1347 | { |
1348 | LLINT_BEGIN(); |
1349 | auto bytecode = pc->as<OpNewAsyncFunc>(); |
1350 | CodeBlock* codeBlock = exec->codeBlock(); |
1351 | JSScope* scope = exec->uncheckedR(bytecode.m_scope).Register::scope(); |
1352 | slowPathLogF("Creating async function!\n" ); |
1353 | LLINT_RETURN(JSAsyncFunction::create(vm, codeBlock->functionDecl(bytecode.m_functionDecl), scope)); |
1354 | } |
1355 | |
1356 | LLINT_SLOW_PATH_DECL(slow_path_new_async_generator_func) |
1357 | { |
1358 | LLINT_BEGIN(); |
1359 | auto bytecode = pc->as<OpNewAsyncGeneratorFunc>(); |
1360 | CodeBlock* codeBlock = exec->codeBlock(); |
1361 | JSScope* scope = exec->uncheckedR(bytecode.m_scope).Register::scope(); |
1362 | slowPathLogF("Creating async generator function!\n" ); |
1363 | LLINT_RETURN(JSAsyncGeneratorFunction::create(vm, codeBlock->functionDecl(bytecode.m_functionDecl), scope)); |
1364 | } |
1365 | |
1366 | LLINT_SLOW_PATH_DECL(slow_path_new_func_exp) |
1367 | { |
1368 | LLINT_BEGIN(); |
1369 | |
1370 | auto bytecode = pc->as<OpNewFuncExp>(); |
1371 | CodeBlock* codeBlock = exec->codeBlock(); |
1372 | JSScope* scope = exec->uncheckedR(bytecode.m_scope).Register::scope(); |
1373 | FunctionExecutable* executable = codeBlock->functionExpr(bytecode.m_functionDecl); |
1374 | |
1375 | LLINT_RETURN(JSFunction::create(vm, executable, scope)); |
1376 | } |
1377 | |
1378 | LLINT_SLOW_PATH_DECL(slow_path_new_generator_func_exp) |
1379 | { |
1380 | LLINT_BEGIN(); |
1381 | |
1382 | auto bytecode = pc->as<OpNewGeneratorFuncExp>(); |
1383 | CodeBlock* codeBlock = exec->codeBlock(); |
1384 | JSScope* scope = exec->uncheckedR(bytecode.m_scope).Register::scope(); |
1385 | FunctionExecutable* executable = codeBlock->functionExpr(bytecode.m_functionDecl); |
1386 | |
1387 | LLINT_RETURN(JSGeneratorFunction::create(vm, executable, scope)); |
1388 | } |
1389 | |
1390 | LLINT_SLOW_PATH_DECL(slow_path_new_async_func_exp) |
1391 | { |
1392 | LLINT_BEGIN(); |
1393 | |
1394 | auto bytecode = pc->as<OpNewAsyncFuncExp>(); |
1395 | CodeBlock* codeBlock = exec->codeBlock(); |
1396 | JSScope* scope = exec->uncheckedR(bytecode.m_scope).Register::scope(); |
1397 | FunctionExecutable* executable = codeBlock->functionExpr(bytecode.m_functionDecl); |
1398 | |
1399 | LLINT_RETURN(JSAsyncFunction::create(vm, executable, scope)); |
1400 | } |
1401 | |
1402 | LLINT_SLOW_PATH_DECL(slow_path_new_async_generator_func_exp) |
1403 | { |
1404 | LLINT_BEGIN(); |
1405 | |
1406 | auto bytecode = pc->as<OpNewAsyncGeneratorFuncExp>(); |
1407 | CodeBlock* codeBlock = exec->codeBlock(); |
1408 | JSScope* scope = exec->uncheckedR(bytecode.m_scope).Register::scope(); |
1409 | FunctionExecutable* executable = codeBlock->functionExpr(bytecode.m_functionDecl); |
1410 | |
1411 | LLINT_RETURN(JSAsyncGeneratorFunction::create(vm, executable, scope)); |
1412 | } |
1413 | |
1414 | LLINT_SLOW_PATH_DECL(slow_path_set_function_name) |
1415 | { |
1416 | LLINT_BEGIN(); |
1417 | auto bytecode = pc->as<OpSetFunctionName>(); |
1418 | JSFunction* func = jsCast<JSFunction*>(getNonConstantOperand(exec, bytecode.m_function)); |
1419 | JSValue name = getOperand(exec, bytecode.m_name); |
1420 | func->setFunctionName(exec, name); |
1421 | LLINT_END(); |
1422 | } |
1423 | |
1424 | static SlowPathReturnType handleHostCall(ExecState* execCallee, JSValue callee, CodeSpecializationKind kind) |
1425 | { |
1426 | slowPathLog("Performing host call.\n" ); |
1427 | |
1428 | ExecState* exec = execCallee->callerFrame(); |
1429 | VM& vm = exec->vm(); |
1430 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
1431 | |
1432 | execCallee->setCodeBlock(0); |
1433 | execCallee->clearReturnPC(); |
1434 | |
1435 | if (kind == CodeForCall) { |
1436 | CallData callData; |
1437 | CallType callType = getCallData(vm, callee, callData); |
1438 | |
1439 | ASSERT(callType != CallType::JS); |
1440 | |
1441 | if (callType == CallType::Host) { |
1442 | NativeCallFrameTracer tracer(&vm, execCallee); |
1443 | execCallee->setCallee(asObject(callee)); |
1444 | vm.hostCallReturnValue = JSValue::decode(callData.native.function(execCallee)); |
1445 | LLINT_CALL_RETURN(execCallee, execCallee, LLInt::getCodePtr(getHostCallReturnValue), CFunctionPtrTag); |
1446 | } |
1447 | |
1448 | slowPathLog("Call callee is not a function: " , callee, "\n" ); |
1449 | |
1450 | ASSERT(callType == CallType::None); |
1451 | LLINT_CALL_THROW(exec, createNotAFunctionError(exec, callee)); |
1452 | } |
1453 | |
1454 | ASSERT(kind == CodeForConstruct); |
1455 | |
1456 | ConstructData constructData; |
1457 | ConstructType constructType = getConstructData(vm, callee, constructData); |
1458 | |
1459 | ASSERT(constructType != ConstructType::JS); |
1460 | |
1461 | if (constructType == ConstructType::Host) { |
1462 | NativeCallFrameTracer tracer(&vm, execCallee); |
1463 | execCallee->setCallee(asObject(callee)); |
1464 | vm.hostCallReturnValue = JSValue::decode(constructData.native.function(execCallee)); |
1465 | LLINT_CALL_RETURN(execCallee, execCallee, LLInt::getCodePtr(getHostCallReturnValue), CFunctionPtrTag); |
1466 | } |
1467 | |
1468 | slowPathLog("Constructor callee is not a function: " , callee, "\n" ); |
1469 | |
1470 | ASSERT(constructType == ConstructType::None); |
1471 | LLINT_CALL_THROW(exec, createNotAConstructorError(exec, callee)); |
1472 | } |
1473 | |
1474 | inline SlowPathReturnType setUpCall(ExecState* execCallee, CodeSpecializationKind kind, JSValue calleeAsValue, LLIntCallLinkInfo* callLinkInfo = nullptr) |
1475 | { |
1476 | ExecState* exec = execCallee->callerFrame(); |
1477 | VM& vm = exec->vm(); |
1478 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
1479 | |
1480 | slowPathLogF("Performing call with recorded PC = %p\n" , exec->currentVPC()); |
1481 | |
1482 | JSCell* calleeAsFunctionCell = getJSFunction(calleeAsValue); |
1483 | if (!calleeAsFunctionCell) { |
1484 | if (auto* internalFunction = jsDynamicCast<InternalFunction*>(vm, calleeAsValue)) { |
1485 | MacroAssemblerCodePtr<JSEntryPtrTag> codePtr = vm.getCTIInternalFunctionTrampolineFor(kind); |
1486 | ASSERT(!!codePtr); |
1487 | |
1488 | if (!LLINT_ALWAYS_ACCESS_SLOW && callLinkInfo) { |
1489 | CodeBlock* callerCodeBlock = exec->codeBlock(); |
1490 | |
1491 | ConcurrentJSLocker locker(callerCodeBlock->m_lock); |
1492 | callLinkInfo->link(vm, callerCodeBlock, internalFunction, codePtr); |
1493 | } |
1494 | |
1495 | assertIsTaggedWith(codePtr.executableAddress(), JSEntryPtrTag); |
1496 | LLINT_CALL_RETURN(exec, execCallee, codePtr.executableAddress(), JSEntryPtrTag); |
1497 | } |
1498 | RELEASE_AND_RETURN(throwScope, handleHostCall(execCallee, calleeAsValue, kind)); |
1499 | } |
1500 | JSFunction* callee = jsCast<JSFunction*>(calleeAsFunctionCell); |
1501 | JSScope* scope = callee->scopeUnchecked(); |
1502 | ExecutableBase* executable = callee->executable(); |
1503 | |
1504 | MacroAssemblerCodePtr<JSEntryPtrTag> codePtr; |
1505 | CodeBlock* codeBlock = 0; |
1506 | if (executable->isHostFunction()) |
1507 | codePtr = executable->entrypointFor(kind, MustCheckArity); |
1508 | else { |
1509 | FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable); |
1510 | |
1511 | if (!isCall(kind) && functionExecutable->constructAbility() == ConstructAbility::CannotConstruct) |
1512 | LLINT_CALL_THROW(exec, createNotAConstructorError(exec, callee)); |
1513 | |
1514 | CodeBlock** codeBlockSlot = execCallee->addressOfCodeBlock(); |
1515 | Exception* error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, callee, scope, kind, *codeBlockSlot); |
1516 | EXCEPTION_ASSERT(throwScope.exception() == error); |
1517 | if (UNLIKELY(error)) |
1518 | LLINT_CALL_THROW(exec, error); |
1519 | codeBlock = *codeBlockSlot; |
1520 | ASSERT(codeBlock); |
1521 | ArityCheckMode arity; |
1522 | if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters())) |
1523 | arity = MustCheckArity; |
1524 | else |
1525 | arity = ArityCheckNotRequired; |
1526 | codePtr = functionExecutable->entrypointFor(kind, arity); |
1527 | } |
1528 | |
1529 | ASSERT(!!codePtr); |
1530 | |
1531 | if (!LLINT_ALWAYS_ACCESS_SLOW && callLinkInfo) { |
1532 | CodeBlock* callerCodeBlock = exec->codeBlock(); |
1533 | |
1534 | ConcurrentJSLocker locker(callerCodeBlock->m_lock); |
1535 | callLinkInfo->link(vm, callerCodeBlock, callee, codePtr); |
1536 | if (codeBlock) |
1537 | codeBlock->linkIncomingCall(exec, callLinkInfo); |
1538 | } |
1539 | |
1540 | assertIsTaggedWith(codePtr.executableAddress(), JSEntryPtrTag); |
1541 | LLINT_CALL_RETURN(exec, execCallee, codePtr.executableAddress(), JSEntryPtrTag); |
1542 | } |
1543 | |
1544 | template<typename Op> |
1545 | inline SlowPathReturnType genericCall(ExecState* exec, Op&& bytecode, CodeSpecializationKind kind) |
1546 | { |
1547 | // This needs to: |
1548 | // - Set up a call frame. |
1549 | // - Figure out what to call and compile it if necessary. |
1550 | // - If possible, link the call's inline cache. |
1551 | // - Return a tuple of machine code address to call and the new call frame. |
1552 | |
1553 | JSValue calleeAsValue = getOperand(exec, bytecode.m_callee); |
1554 | |
1555 | ExecState* execCallee = exec - bytecode.m_argv; |
1556 | |
1557 | execCallee->setArgumentCountIncludingThis(bytecode.m_argc); |
1558 | execCallee->uncheckedR(CallFrameSlot::callee) = calleeAsValue; |
1559 | execCallee->setCallerFrame(exec); |
1560 | |
1561 | auto& metadata = bytecode.metadata(exec); |
1562 | return setUpCall(execCallee, kind, calleeAsValue, &metadata.m_callLinkInfo); |
1563 | } |
1564 | |
1565 | LLINT_SLOW_PATH_DECL(slow_path_call) |
1566 | { |
1567 | LLINT_BEGIN_NO_SET_PC(); |
1568 | RELEASE_AND_RETURN(throwScope, genericCall(exec, pc->as<OpCall>(), CodeForCall)); |
1569 | } |
1570 | |
1571 | LLINT_SLOW_PATH_DECL(slow_path_tail_call) |
1572 | { |
1573 | LLINT_BEGIN_NO_SET_PC(); |
1574 | RELEASE_AND_RETURN(throwScope, genericCall(exec, pc->as<OpTailCall>(), CodeForCall)); |
1575 | } |
1576 | |
1577 | LLINT_SLOW_PATH_DECL(slow_path_construct) |
1578 | { |
1579 | LLINT_BEGIN_NO_SET_PC(); |
1580 | RELEASE_AND_RETURN(throwScope, genericCall(exec, pc->as<OpConstruct>(), CodeForConstruct)); |
1581 | } |
1582 | |
1583 | LLINT_SLOW_PATH_DECL(slow_path_size_frame_for_varargs) |
1584 | { |
1585 | LLINT_BEGIN(); |
1586 | // This needs to: |
1587 | // - Set up a call frame while respecting the variable arguments. |
1588 | |
1589 | unsigned numUsedStackSlots; |
1590 | JSValue arguments; |
1591 | int firstVarArg; |
1592 | switch (pc->opcodeID()) { |
1593 | case op_call_varargs: { |
1594 | auto bytecode = pc->as<OpCallVarargs>(); |
1595 | numUsedStackSlots = -bytecode.m_firstFree.offset(); |
1596 | arguments = getOperand(exec, bytecode.m_arguments); |
1597 | firstVarArg = bytecode.m_firstVarArg; |
1598 | break; |
1599 | } |
1600 | case op_tail_call_varargs: { |
1601 | auto bytecode = pc->as<OpTailCallVarargs>(); |
1602 | numUsedStackSlots = -bytecode.m_firstFree.offset(); |
1603 | arguments = getOperand(exec, bytecode.m_arguments); |
1604 | firstVarArg = bytecode.m_firstVarArg; |
1605 | break; |
1606 | } |
1607 | case op_construct_varargs: { |
1608 | auto bytecode = pc->as<OpConstructVarargs>(); |
1609 | numUsedStackSlots = -bytecode.m_firstFree.offset(); |
1610 | arguments = getOperand(exec, bytecode.m_arguments); |
1611 | firstVarArg = bytecode.m_firstVarArg; |
1612 | break; |
1613 | } |
1614 | default: |
1615 | RELEASE_ASSERT_NOT_REACHED(); |
1616 | } |
1617 | unsigned length = sizeFrameForVarargs(exec, vm, arguments, numUsedStackSlots, firstVarArg); |
1618 | LLINT_CALL_CHECK_EXCEPTION(exec, exec); |
1619 | |
1620 | ExecState* execCallee = calleeFrameForVarargs(exec, numUsedStackSlots, length + 1); |
1621 | vm.varargsLength = length; |
1622 | vm.newCallFrameReturnValue = execCallee; |
1623 | |
1624 | LLINT_RETURN_CALLEE_FRAME(execCallee); |
1625 | } |
1626 | |
1627 | LLINT_SLOW_PATH_DECL(slow_path_size_frame_for_forward_arguments) |
1628 | { |
1629 | LLINT_BEGIN(); |
1630 | // This needs to: |
1631 | // - Set up a call frame with the same arguments as the current frame. |
1632 | |
1633 | auto bytecode = pc->as<OpTailCallForwardArguments>(); |
1634 | unsigned numUsedStackSlots = -bytecode.m_firstFree.offset(); |
1635 | |
1636 | unsigned arguments = sizeFrameForForwardArguments(exec, vm, numUsedStackSlots); |
1637 | LLINT_CALL_CHECK_EXCEPTION(exec, exec); |
1638 | |
1639 | ExecState* execCallee = calleeFrameForVarargs(exec, numUsedStackSlots, arguments + 1); |
1640 | |
1641 | vm.varargsLength = arguments; |
1642 | vm.newCallFrameReturnValue = execCallee; |
1643 | |
1644 | LLINT_RETURN_CALLEE_FRAME(execCallee); |
1645 | } |
1646 | |
1647 | enum class SetArgumentsWith { |
1648 | Object, |
1649 | CurrentArguments |
1650 | }; |
1651 | |
1652 | template<typename Op> |
1653 | inline SlowPathReturnType varargsSetup(ExecState* exec, const Instruction* pc, CodeSpecializationKind kind, SetArgumentsWith set) |
1654 | { |
1655 | LLINT_BEGIN_NO_SET_PC(); |
1656 | // This needs to: |
1657 | // - Figure out what to call and compile it if necessary. |
1658 | // - Return a tuple of machine code address to call and the new call frame. |
1659 | |
1660 | auto bytecode = pc->as<Op>(); |
1661 | JSValue calleeAsValue = getOperand(exec, bytecode.m_callee); |
1662 | |
1663 | ExecState* execCallee = vm.newCallFrameReturnValue; |
1664 | |
1665 | if (set == SetArgumentsWith::Object) { |
1666 | setupVarargsFrameAndSetThis(exec, execCallee, getOperand(exec, bytecode.m_thisValue), getOperand(exec, bytecode.m_arguments), bytecode.m_firstVarArg, vm.varargsLength); |
1667 | LLINT_CALL_CHECK_EXCEPTION(exec, exec); |
1668 | } else |
1669 | setupForwardArgumentsFrameAndSetThis(exec, execCallee, getOperand(exec, bytecode.m_thisValue), vm.varargsLength); |
1670 | |
1671 | execCallee->setCallerFrame(exec); |
1672 | execCallee->uncheckedR(CallFrameSlot::callee) = calleeAsValue; |
1673 | exec->setCurrentVPC(pc); |
1674 | |
1675 | RELEASE_AND_RETURN(throwScope, setUpCall(execCallee, kind, calleeAsValue)); |
1676 | } |
1677 | |
1678 | LLINT_SLOW_PATH_DECL(slow_path_call_varargs) |
1679 | { |
1680 | return varargsSetup<OpCallVarargs>(exec, pc, CodeForCall, SetArgumentsWith::Object); |
1681 | } |
1682 | |
1683 | LLINT_SLOW_PATH_DECL(slow_path_tail_call_varargs) |
1684 | { |
1685 | return varargsSetup<OpTailCallVarargs>(exec, pc, CodeForCall, SetArgumentsWith::Object); |
1686 | } |
1687 | |
1688 | LLINT_SLOW_PATH_DECL(slow_path_tail_call_forward_arguments) |
1689 | { |
1690 | return varargsSetup<OpTailCallForwardArguments>(exec, pc, CodeForCall, SetArgumentsWith::CurrentArguments); |
1691 | } |
1692 | |
1693 | LLINT_SLOW_PATH_DECL(slow_path_construct_varargs) |
1694 | { |
1695 | return varargsSetup<OpConstructVarargs>(exec, pc, CodeForConstruct, SetArgumentsWith::Object); |
1696 | } |
1697 | |
1698 | inline SlowPathReturnType commonCallEval(ExecState* exec, const Instruction* pc, MacroAssemblerCodePtr<JSEntryPtrTag> returnPoint) |
1699 | { |
1700 | LLINT_BEGIN_NO_SET_PC(); |
1701 | auto bytecode = pc->as<OpCallEval>(); |
1702 | JSValue calleeAsValue = getNonConstantOperand(exec, bytecode.m_callee); |
1703 | |
1704 | ExecState* execCallee = exec - bytecode.m_argv; |
1705 | |
1706 | execCallee->setArgumentCountIncludingThis(bytecode.m_argc); |
1707 | execCallee->setCallerFrame(exec); |
1708 | execCallee->uncheckedR(CallFrameSlot::callee) = calleeAsValue; |
1709 | execCallee->setReturnPC(returnPoint.executableAddress()); |
1710 | execCallee->setCodeBlock(0); |
1711 | exec->setCurrentVPC(pc); |
1712 | |
1713 | if (!isHostFunction(calleeAsValue, globalFuncEval)) |
1714 | RELEASE_AND_RETURN(throwScope, setUpCall(execCallee, CodeForCall, calleeAsValue)); |
1715 | |
1716 | vm.hostCallReturnValue = eval(execCallee); |
1717 | LLINT_CALL_RETURN(exec, execCallee, LLInt::getCodePtr(getHostCallReturnValue), CFunctionPtrTag); |
1718 | } |
1719 | |
1720 | LLINT_SLOW_PATH_DECL(slow_path_call_eval) |
1721 | { |
1722 | return commonCallEval(exec, pc, LLInt::getCodePtr<JSEntryPtrTag>(llint_generic_return_point)); |
1723 | } |
1724 | |
1725 | LLINT_SLOW_PATH_DECL(slow_path_call_eval_wide16) |
1726 | { |
1727 | return commonCallEval(exec, pc, LLInt::getWide16CodePtr<JSEntryPtrTag>(llint_generic_return_point)); |
1728 | } |
1729 | |
1730 | LLINT_SLOW_PATH_DECL(slow_path_call_eval_wide32) |
1731 | { |
1732 | return commonCallEval(exec, pc, LLInt::getWide32CodePtr<JSEntryPtrTag>(llint_generic_return_point)); |
1733 | } |
1734 | |
1735 | LLINT_SLOW_PATH_DECL(slow_path_strcat) |
1736 | { |
1737 | LLINT_BEGIN(); |
1738 | auto bytecode = pc->as<OpStrcat>(); |
1739 | LLINT_RETURN(jsStringFromRegisterArray(exec, &exec->uncheckedR(bytecode.m_src), bytecode.m_count)); |
1740 | } |
1741 | |
1742 | LLINT_SLOW_PATH_DECL(slow_path_to_primitive) |
1743 | { |
1744 | LLINT_BEGIN(); |
1745 | auto bytecode = pc->as<OpToPrimitive>(); |
1746 | LLINT_RETURN(getOperand(exec, bytecode.m_src).toPrimitive(exec)); |
1747 | } |
1748 | |
1749 | LLINT_SLOW_PATH_DECL(slow_path_throw) |
1750 | { |
1751 | LLINT_BEGIN(); |
1752 | auto bytecode = pc->as<OpThrow>(); |
1753 | LLINT_THROW(getOperand(exec, bytecode.m_value)); |
1754 | } |
1755 | |
1756 | LLINT_SLOW_PATH_DECL(slow_path_handle_traps) |
1757 | { |
1758 | LLINT_BEGIN_NO_SET_PC(); |
1759 | ASSERT(vm.needTrapHandling()); |
1760 | vm.handleTraps(exec); |
1761 | UNUSED_PARAM(pc); |
1762 | LLINT_RETURN_TWO(throwScope.exception(), exec); |
1763 | } |
1764 | |
1765 | LLINT_SLOW_PATH_DECL(slow_path_debug) |
1766 | { |
1767 | LLINT_BEGIN(); |
1768 | auto bytecode = pc->as<OpDebug>(); |
1769 | vm.interpreter->debug(exec, bytecode.m_debugHookType); |
1770 | |
1771 | LLINT_END(); |
1772 | } |
1773 | |
1774 | LLINT_SLOW_PATH_DECL(slow_path_handle_exception) |
1775 | { |
1776 | LLINT_BEGIN_NO_SET_PC(); |
1777 | UNUSED_PARAM(throwScope); |
1778 | genericUnwind(&vm, exec); |
1779 | LLINT_END_IMPL(); |
1780 | } |
1781 | |
1782 | LLINT_SLOW_PATH_DECL(slow_path_get_from_scope) |
1783 | { |
1784 | LLINT_BEGIN(); |
1785 | auto bytecode = pc->as<OpGetFromScope>(); |
1786 | auto& metadata = bytecode.metadata(exec); |
1787 | const Identifier& ident = exec->codeBlock()->identifier(bytecode.m_var); |
1788 | JSObject* scope = jsCast<JSObject*>(getNonConstantOperand(exec, bytecode.m_scope)); |
1789 | |
1790 | // ModuleVar is always converted to ClosureVar for get_from_scope. |
1791 | ASSERT(metadata.m_getPutInfo.resolveType() != ModuleVar); |
1792 | |
1793 | LLINT_RETURN(scope->getPropertySlot(exec, ident, [&] (bool found, PropertySlot& slot) -> JSValue { |
1794 | if (!found) { |
1795 | if (metadata.m_getPutInfo.resolveMode() == ThrowIfNotFound) |
1796 | return throwException(exec, throwScope, createUndefinedVariableError(exec, ident)); |
1797 | return jsUndefined(); |
1798 | } |
1799 | |
1800 | JSValue result = JSValue(); |
1801 | if (scope->isGlobalLexicalEnvironment()) { |
1802 | // When we can't statically prove we need a TDZ check, we must perform the check on the slow path. |
1803 | result = slot.getValue(exec, ident); |
1804 | if (result == jsTDZValue()) |
1805 | return throwException(exec, throwScope, createTDZError(exec)); |
1806 | } |
1807 | |
1808 | CommonSlowPaths::tryCacheGetFromScopeGlobal(exec, vm, bytecode, scope, slot, ident); |
1809 | |
1810 | if (!result) |
1811 | return slot.getValue(exec, ident); |
1812 | return result; |
1813 | })); |
1814 | } |
1815 | |
1816 | LLINT_SLOW_PATH_DECL(slow_path_put_to_scope) |
1817 | { |
1818 | LLINT_BEGIN(); |
1819 | |
1820 | auto bytecode = pc->as<OpPutToScope>(); |
1821 | auto& metadata = bytecode.metadata(exec); |
1822 | CodeBlock* codeBlock = exec->codeBlock(); |
1823 | const Identifier& ident = codeBlock->identifier(bytecode.m_var); |
1824 | JSObject* scope = jsCast<JSObject*>(getNonConstantOperand(exec, bytecode.m_scope)); |
1825 | JSValue value = getOperand(exec, bytecode.m_value); |
1826 | if (metadata.m_getPutInfo.resolveType() == LocalClosureVar) { |
1827 | JSLexicalEnvironment* environment = jsCast<JSLexicalEnvironment*>(scope); |
1828 | environment->variableAt(ScopeOffset(metadata.m_operand)).set(vm, environment, value); |
1829 | |
1830 | // Have to do this *after* the write, because if this puts the set into IsWatched, then we need |
1831 | // to have already changed the value of the variable. Otherwise we might watch and constant-fold |
1832 | // to the Undefined value from before the assignment. |
1833 | if (metadata.m_watchpointSet) |
1834 | metadata.m_watchpointSet->touch(vm, "Executed op_put_scope<LocalClosureVar>" ); |
1835 | LLINT_END(); |
1836 | } |
1837 | |
1838 | bool hasProperty = scope->hasProperty(exec, ident); |
1839 | LLINT_CHECK_EXCEPTION(); |
1840 | if (hasProperty |
1841 | && scope->isGlobalLexicalEnvironment() |
1842 | && !isInitialization(metadata.m_getPutInfo.initializationMode())) { |
1843 | // When we can't statically prove we need a TDZ check, we must perform the check on the slow path. |
1844 | PropertySlot slot(scope, PropertySlot::InternalMethodType::Get); |
1845 | JSGlobalLexicalEnvironment::getOwnPropertySlot(scope, exec, ident, slot); |
1846 | if (slot.getValue(exec, ident) == jsTDZValue()) |
1847 | LLINT_THROW(createTDZError(exec)); |
1848 | } |
1849 | |
1850 | if (metadata.m_getPutInfo.resolveMode() == ThrowIfNotFound && !hasProperty) |
1851 | LLINT_THROW(createUndefinedVariableError(exec, ident)); |
1852 | |
1853 | PutPropertySlot slot(scope, codeBlock->isStrictMode(), PutPropertySlot::UnknownContext, isInitialization(metadata.m_getPutInfo.initializationMode())); |
1854 | scope->methodTable(vm)->put(scope, exec, ident, value, slot); |
1855 | |
1856 | CommonSlowPaths::tryCachePutToScopeGlobal(exec, codeBlock, bytecode, scope, slot, ident); |
1857 | |
1858 | LLINT_END(); |
1859 | } |
1860 | |
1861 | LLINT_SLOW_PATH_DECL(slow_path_check_if_exception_is_uncatchable_and_notify_profiler) |
1862 | { |
1863 | LLINT_BEGIN(); |
1864 | RELEASE_ASSERT(!!throwScope.exception()); |
1865 | |
1866 | if (isTerminatedExecutionException(vm, throwScope.exception())) |
1867 | LLINT_RETURN_TWO(pc, bitwise_cast<void*>(static_cast<uintptr_t>(1))); |
1868 | LLINT_RETURN_TWO(pc, 0); |
1869 | } |
1870 | |
1871 | LLINT_SLOW_PATH_DECL(slow_path_log_shadow_chicken_prologue) |
1872 | { |
1873 | LLINT_BEGIN(); |
1874 | |
1875 | auto bytecode = pc->as<OpLogShadowChickenPrologue>(); |
1876 | JSScope* scope = exec->uncheckedR(bytecode.m_scope).Register::scope(); |
1877 | ShadowChicken* shadowChicken = vm.shadowChicken(); |
1878 | RELEASE_ASSERT(shadowChicken); |
1879 | shadowChicken->log(vm, exec, ShadowChicken::Packet::prologue(exec->jsCallee(), exec, exec->callerFrame(), scope)); |
1880 | |
1881 | LLINT_END(); |
1882 | } |
1883 | |
1884 | LLINT_SLOW_PATH_DECL(slow_path_log_shadow_chicken_tail) |
1885 | { |
1886 | LLINT_BEGIN(); |
1887 | |
1888 | auto bytecode = pc->as<OpLogShadowChickenTail>(); |
1889 | JSValue thisValue = getNonConstantOperand(exec, bytecode.m_thisValue); |
1890 | JSScope* scope = exec->uncheckedR(bytecode.m_scope).Register::scope(); |
1891 | |
1892 | #if USE(JSVALUE64) |
1893 | CallSiteIndex callSiteIndex(exec->codeBlock()->bytecodeOffset(pc)); |
1894 | #else |
1895 | CallSiteIndex callSiteIndex(pc); |
1896 | #endif |
1897 | ShadowChicken* shadowChicken = vm.shadowChicken(); |
1898 | RELEASE_ASSERT(shadowChicken); |
1899 | shadowChicken->log(vm, exec, ShadowChicken::Packet::tail(exec, thisValue, scope, exec->codeBlock(), callSiteIndex)); |
1900 | |
1901 | LLINT_END(); |
1902 | } |
1903 | |
1904 | LLINT_SLOW_PATH_DECL(slow_path_profile_catch) |
1905 | { |
1906 | LLINT_BEGIN(); |
1907 | |
1908 | exec->codeBlock()->ensureCatchLivenessIsComputedForBytecodeOffset(exec->bytecodeOffset()); |
1909 | |
1910 | auto bytecode = pc->as<OpCatch>(); |
1911 | auto& metadata = bytecode.metadata(exec); |
1912 | metadata.m_buffer->forEach([&] (ValueProfileAndOperand& profile) { |
1913 | profile.m_buckets[0] = JSValue::encode(exec->uncheckedR(profile.m_operand).jsValue()); |
1914 | }); |
1915 | |
1916 | LLINT_END(); |
1917 | } |
1918 | |
1919 | LLINT_SLOW_PATH_DECL(slow_path_super_sampler_begin) |
1920 | { |
1921 | // FIXME: It seems like we should be able to do this in asm but llint doesn't seem to like global variables. |
1922 | // See: https://bugs.webkit.org/show_bug.cgi?id=179438 |
1923 | UNUSED_PARAM(exec); |
1924 | g_superSamplerCount++; |
1925 | LLINT_END_IMPL(); |
1926 | } |
1927 | |
1928 | LLINT_SLOW_PATH_DECL(slow_path_super_sampler_end) |
1929 | { |
1930 | // FIXME: It seems like we should be able to do this in asm but llint doesn't seem to like global variables. |
1931 | // See: https://bugs.webkit.org/show_bug.cgi?id=179438 |
1932 | UNUSED_PARAM(exec); |
1933 | g_superSamplerCount--; |
1934 | LLINT_END_IMPL(); |
1935 | } |
1936 | |
1937 | LLINT_SLOW_PATH_DECL(slow_path_out_of_line_jump_target) |
1938 | { |
1939 | CodeBlock* codeBlock = exec->codeBlock(); |
1940 | pc = codeBlock->outOfLineJumpTarget(pc); |
1941 | LLINT_END_IMPL(); |
1942 | } |
1943 | |
1944 | extern "C" SlowPathReturnType llint_throw_stack_overflow_error(VM* vm, ProtoCallFrame* protoFrame) |
1945 | { |
1946 | ExecState* exec = vm->topCallFrame; |
1947 | auto scope = DECLARE_THROW_SCOPE(*vm); |
1948 | |
1949 | if (!exec) |
1950 | exec = protoFrame->callee()->globalObject(*vm)->globalExec(); |
1951 | throwStackOverflowError(exec, scope); |
1952 | return encodeResult(0, 0); |
1953 | } |
1954 | |
1955 | #if ENABLE(C_LOOP) |
1956 | extern "C" SlowPathReturnType llint_stack_check_at_vm_entry(VM* vm, Register* newTopOfStack) |
1957 | { |
1958 | bool success = vm->ensureStackCapacityFor(newTopOfStack); |
1959 | return encodeResult(reinterpret_cast<void*>(success), 0); |
1960 | } |
1961 | #endif |
1962 | |
1963 | extern "C" void llint_write_barrier_slow(ExecState* exec, JSCell* cell) |
1964 | { |
1965 | VM& vm = exec->vm(); |
1966 | vm.heap.writeBarrier(cell); |
1967 | } |
1968 | |
1969 | extern "C" NO_RETURN_DUE_TO_CRASH void llint_crash() |
1970 | { |
1971 | CRASH(); |
1972 | } |
1973 | |
1974 | } } // namespace JSC::LLInt |
1975 | |