1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ecmascript/compiler/access_object_stub_builder.h"
17 #include "ecmascript/compiler/baseline/baseline_stubs.h"
18 #include "ecmascript/compiler/baseline/baseline_stubs-inl.h"
19 #include "ecmascript/compiler/call_stub_builder.h"
20 #include "ecmascript/compiler/new_object_stub_builder.h"
21 #include "ecmascript/compiler/operations_stub_builder.h"
22 #include "ecmascript/compiler/profiler_stub_builder.h"
23 #include "ecmascript/dfx/vm_thread_control.h"
24 #include "ecmascript/interpreter/interpreter.h"
25
26 namespace panda::ecmascript::kungfu {
27 using namespace panda::ecmascript;
28 static constexpr uint32_t ONE_BYTE_SIZE = 8;
29 static constexpr uint32_t TWO_BYTE_SIZE = 16;
30 static constexpr uint32_t THREE_BYTE_SIZE = 24;
31 static constexpr uint32_t ONE_BYTE_ALL_ONE = 0xFF;
32 static constexpr uint32_t TWO_BYTE_ALL_ONE = 0xFFFF;
33
34 #define PARAM_INDEX(opcode, param) static_cast<size_t>(opcode##CallSignature::ParameterIndex::param)
35
36 #define METHOD_ENTRY_ENV_DEFINED(func) \
37 GateRef isDebugModeOffset = IntPtr(JSThread::GlueData::GetIsDebugModeOffset(env->Is32Bit())); \
38 GateRef isDebugMode = LoadPrimitive(VariableType::BOOL(), glue, isDebugModeOffset); \
39 Label isDebugModeTrue(env); \
40 Label isDebugModeFalse(env); \
41 BRANCH(isDebugMode, &isDebugModeTrue, &isDebugModeFalse); \
42 Bind(&isDebugModeTrue); \
43 { \
44 CallRuntime(glue, RTSTUB_ID(MethodEntry), { func }); \
45 Jump(&isDebugModeFalse); \
46 } \
47 Bind(&isDebugModeFalse)
48
49 #define UPDATE_HOTNESS(func, callback) \
50 varHotnessCounter = Int32Add(offset, *varHotnessCounter); \
51 BRANCH(Int32LessThan(*varHotnessCounter, Int32(0)), &slowPath, &dispatch); \
52 Bind(&slowPath); \
53 { \
54 GateRef iVecOffset = IntPtr(JSThread::GlueData::GetInterruptVectorOffset(env->IsArch32Bit())); \
55 GateRef interruptsFlag = LoadPrimitive(VariableType::INT8(), glue, iVecOffset); \
56 varHotnessCounter = Int32(EcmaInterpreter::METHOD_HOTNESS_THRESHOLD); \
57 Label initialized(env); \
58 Label callRuntime(env); \
59 BRANCH(BitOr(TaggedIsUndefined(*varProfileTypeInfo), \
60 Int8Equal(interruptsFlag, Int8(VmThreadControl::VM_NEED_SUSPENSION))), \
61 &callRuntime, &initialized); \
62 Bind(&callRuntime); \
63 if (!(callback).IsEmpty()) { \
64 varProfileTypeInfo = CallRuntime(glue, RTSTUB_ID(UpdateHotnessCounterWithProf), { func }); \
65 } else { \
66 varProfileTypeInfo = CallRuntime(glue, RTSTUB_ID(UpdateHotnessCounter), { func }); \
67 } \
68 Label handleException(env); \
69 Label noException(env); \
70 BRANCH(HasPendingException(glue), &handleException, &noException); \
71 Bind(&handleException); \
72 { \
73 DISPATCH_LAST(); \
74 Return(); \
75 } \
76 Bind(&noException); \
77 { \
78 Jump(&dispatch); \
79 } \
80 Bind(&initialized); \
81 (callback).TryDump(); \
82 (callback).TryJitCompile(); \
83 Jump(&dispatch); \
84 } \
85 Bind(&dispatch);
86
87 enum ActualNumArgsOfCall : uint8_t { CALLARG0 = 0, CALLARG1, CALLARGS2, CALLARGS3 };
88
89 CallSignature BaselineStubCSigns::callSigns_[BaselineStubCSigns::NUM_OF_STUBS];
90
91 #define CHECK_EXCEPTION(res) \
92 CheckException(glue, sp, res)
93
94 #define CHECK_EXCEPTION_RETURN(res) \
95 CheckExceptionReturn(glue, sp, res)
96
97 #define CHECK_EXCEPTION_WITH_JUMP(res, jump) \
98 CheckExceptionWithJump(glue, sp, res, acc, jump)
99
100 #define CHECK_EXCEPTION_WITH_JUMP_RETURN(res, jump) \
101 CheckExceptionWithJumpAndReturn(glue, sp, res, acc, jump)
102
103 #define CHECK_EXCEPTION_WITH_ACC(res) \
104 CheckExceptionWithVar(glue, sp, res, acc)
105
106 #define CHECK_EXCEPTION_WITH_VARACC(res) \
107 CheckExceptionWithVar(glue, sp, res, *varAcc)
108
109 #define CHECK_PENDING_EXCEPTION(res) \
110 CheckPendingException(glue, sp, res, acc)
111
112 #define INT_PTR(opcode) \
113 IntPtr(BytecodeInstruction::Size(BytecodeInstruction::Opcode::opcode))
114
115 #define METHOD_ENTRY(func) \
116 auto env = GetEnvironment(); \
117 METHOD_ENTRY_ENV_DEFINED(func)
118
119 #define METHOD_EXIT() \
120 auto debugModeOffset = JSThread::GlueData::GetIsDebugModeOffset(env->Is32Bit()); \
121 auto tracingOffset = JSThread::GlueData::GetIsTracingOffset(env->Is32Bit()); \
122 Label NeedCallRuntimeTrue(env); \
123 Label NeedCallRuntimeFalse(env); \
124 Branch(LogicOrBuilder(env) \
125 .Or(LoadPrimitive(VariableType::BOOL(), glue, IntPtr(debugModeOffset))) \
126 .Or(LoadPrimitive(VariableType::BOOL(), glue, IntPtr(tracingOffset))) \
127 .Done(), &NeedCallRuntimeTrue, &NeedCallRuntimeFalse); \
128 Bind(&NeedCallRuntimeTrue); \
129 { \
130 CallRuntime(glue, RTSTUB_ID(MethodExit), {}); \
131 Jump(&NeedCallRuntimeFalse); \
132 } \
133 Bind(&NeedCallRuntimeFalse)
134
135 #define DISPATCH(opcode) DISPATCH_BAK(OFFSET, INT_PTR(opcode))
136 #define DISPATCH_BAK(TYPE, ...) DISPATCH_##TYPE(__VA_ARGS__)
137 #define DISPATCH_LAST() \
138 DispatchLast(glue, sp, acc) \
139
140 #define DISPATCH_LAST_WITH_ACC() \
141 DispatchLast(glue, sp, acc) \
142
143 #define DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineBianryOP) \
144 GateRef glue = PtrArgument(PARAM_INDEX(BaselineBianryOP, GLUE)); \
145 GateRef sp = PtrArgument(PARAM_INDEX(BaselineBianryOP, SP)); \
146 GateRef left = TaggedArgument(PARAM_INDEX(BaselineBianryOP, LEFT)); \
147 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineBianryOP, SLOT_ID)); \
148 \
149 GateRef frame = GetFrame(sp); \
150 GateRef acc = GetAccFromFrame(glue, frame); \
151 GateRef func = GetFunctionFromFrame(glue, frame); \
152 GateRef profileTypeInfo = GetProfileTypeInfoFromFunction(glue, func); \
153 \
154 ProfileOperation callback( \
155 [this, glue, func, slotId, profileTypeInfo](const std::initializer_list<GateRef> &values, \
156 OperationType type) { \
157 ProfilerStubBuilder profiler(this, GetGlobalEnv(glue)); \
158 profiler.PGOProfiler(glue, func, profileTypeInfo, slotId, values, type); \
159 }, nullptr)
160
161 #define DEFINE_SINGLEOP_PARAM_AND_PROFILE_CALLBACK(BaselineBianryOP) \
162 GateRef glue = PtrArgument(PARAM_INDEX(BaselineBianryOP, GLUE)); \
163 GateRef sp = PtrArgument(PARAM_INDEX(BaselineBianryOP, SP)); \
164 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineBianryOP, SLOT_ID)); \
165 \
166 GateRef frame = GetFrame(sp); \
167 GateRef acc = GetAccFromFrame(glue, frame); \
168 GateRef func = GetFunctionFromFrame(glue, frame); \
169 GateRef profileTypeInfo = GetProfileTypeInfoFromFunction(glue, func); \
170 \
171 ProfileOperation callback( \
172 [this, glue, func, slotId, profileTypeInfo](const std::initializer_list<GateRef> &values, \
173 OperationType type) { \
174 ProfilerStubBuilder profiler(this, GetGlobalEnv(glue)); \
175 profiler.PGOProfiler(glue, func, profileTypeInfo, slotId, values, type); \
176 }, nullptr)
177
178
179 #define DEFINE_PROFILE_CALLBACK(glue, sp, slotId) \
180 GateRef frame = GetFrame(sp); \
181 GateRef curFunc = GetFunctionFromFrame(glue, frame); \
182 GateRef profileTypeInfo = GetProfileTypeInfoFromFunction(glue, curFunc); \
183 ProfileOperation callback( \
184 [this, glue, curFunc, slotId, profileTypeInfo](const std::initializer_list<GateRef> &values, \
185 OperationType type) { \
186 ProfilerStubBuilder profiler(this, GetGlobalEnv(glue)); \
187 profiler.PGOProfiler(glue, curFunc, profileTypeInfo, slotId, values, type); \
188 }, nullptr)
189
190 #define DEFINE_BY_NAME(newIc) \
191 DEFVARIABLE(holder, VariableType::JS_ANY(), receiver); \
192 Label icPath(env); \
193 Label whichPath(env); \
194 Label slowPath(env); \
195 Label exit(env); \
196 Label isEcmaObj(env); \
197 /*hclass hit -> ic path*/ \
198 Label tryGetHclass(env); \
199 Label firstValueHeapObject(env); \
200 Label hclassNotHit(env); \
201 BRANCH(IsEcmaObject(glue, receiver), &isEcmaObj, &slowPath); \
202 Bind(&isEcmaObj); \
203 BRANCH(TaggedIsUndefined(profileTypeInfo), &hclassNotHit, &tryGetHclass); \
204 Bind(&tryGetHclass); \
205 { \
206 GateRef firstValue = GetValueFromTaggedArray(glue, profileTypeInfo, slotId); \
207 BRANCH(TaggedIsHeapObject(firstValue), &firstValueHeapObject, &hclassNotHit); \
208 Bind(&firstValueHeapObject); \
209 GateRef hclass = LoadHClass(glue, *holder); \
210 BRANCH(Equal(LoadObjectFromWeakRef(firstValue), hclass), &whichPath, &hclassNotHit); \
211 } \
212 Bind(&hclassNotHit); \
213 /* found entry -> slow path*/ \
214 Label loopHead(env); \
215 Label loopEnd(env); \
216 Label loopExit(env); \
217 Jump(&loopHead); \
218 LoopBegin(&loopHead); \
219 { \
220 GateRef hclass = LoadHClass(glue, *holder); \
221 GateRef jsType = GetObjectType(hclass); \
222 Label findProperty(env); \
223 BRANCH(IsSpecialIndexedObj(jsType), &slowPath, &findProperty); \
224 Bind(&findProperty); \
225 Label isDicMode(env); \
226 Label notDicMode(env); \
227 BRANCH(IsDictionaryModeByHClass(hclass), &isDicMode, ¬DicMode); \
228 Bind(&isDicMode); \
229 { \
230 GateRef array = GetPropertiesArray(glue, *holder); \
231 GateRef entry = FindEntryFromHashTable<NameDictionary>(glue, array, propKey); \
232 BRANCH(Int32NotEqual(entry, Int32(-1)), &slowPath, &loopExit); \
233 } \
234 Bind(¬DicMode); \
235 { \
236 GateRef layOutInfo = GetLayoutFromHClass(glue, hclass); \
237 GateRef propsNum = GetNumberOfPropsFromHClass(hclass); \
238 GateRef entry = FindElementWithCache(glue, layOutInfo, hclass, propKey, propsNum); \
239 BRANCH(Int32NotEqual(entry, Int32(-1)), &slowPath, &loopExit); \
240 } \
241 Bind(&loopExit); \
242 { \
243 holder = GetPrototypeFromHClass(glue, LoadHClass(glue, *holder)); \
244 BRANCH(TaggedIsHeapObject(*holder), &loopEnd, &whichPath); \
245 } \
246 Bind(&loopEnd); \
247 LoopEndWithCheckSafePoint(&loopHead, env, glue); \
248 } \
249 Bind(&whichPath); \
250 { \
251 BRANCH(newIc, &icPath, &slowPath); \
252 } \
253 Bind(&icPath); \
254 { \
255 /* IC do the same thing as stobjbyname */ \
256 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue)); \
257 StringIdInfo stringIdInfo(constpool, stringId); \
258 result = builder.StoreObjByName(glue, receiver, 0, stringIdInfo, acc, profileTypeInfo, slotId, callback); \
259 Jump(&exit); \
260 } \
261 Bind(&slowPath); \
262 { \
263 SetCurrentGlobalEnv(GetGlobalEnv(glue)); \
264 result = DefineField(glue, receiver, propKey, acc); \
265 Jump(&exit); \
266 } \
267 Bind(&exit)
268
Initialize()269 void BaselineStubCSigns::Initialize()
270 {
271 #define INIT_SIGNATURES(name) \
272 name##CallSignature::Initialize(&callSigns_[name]); \
273 callSigns_[name].SetID(name); \
274 callSigns_[name].SetName(std::string("BaselineStub_") + #name); \
275 callSigns_[name].SetConstructor( \
276 [](void* env) { \
277 return static_cast<void*>( \
278 new name##StubBuilder(&callSigns_[name], static_cast<Environment*>(env))); \
279 });
280
281 BASELINE_STUB_ID_LIST(INIT_SIGNATURES)
282 #undef INIT_SIGNATURES
283 }
284
GetCSigns(std::vector<const CallSignature * > & outCSigns)285 void BaselineStubCSigns::GetCSigns(std::vector<const CallSignature*>& outCSigns)
286 {
287 for (size_t i = 0; i < NUM_OF_STUBS; i++) {
288 outCSigns.push_back(&callSigns_[i]);
289 }
290 }
291
GenerateCircuit()292 void BaselineTryLdGLobalByNameImm8ID16StubBuilder::GenerateCircuit()
293 {
294 GateRef glue = PtrArgument(PARAM_INDEX(BaselineTryLdGLobalByNameImm8ID16, GLUE));
295 GateRef sp = PtrArgument(PARAM_INDEX(BaselineTryLdGLobalByNameImm8ID16, SP));
296 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineTryLdGLobalByNameImm8ID16, STRING_ID));
297 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineTryLdGLobalByNameImm8ID16, SLOT_ID));
298 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
299
300 GateRef acc = GetAccFromFrame(glue, frame);
301 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
302 GateRef method = GetMethodFromFunction(glue, curFunc);
303 GateRef constpool = GetConstpoolFromMethod(glue, method);
304 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
305 StringIdInfo info(constpool, stringId);
306 GateRef result = builder.TryLoadGlobalByName(glue, 0, info, profileTypeInfo, slotId, callback);
307 CHECK_EXCEPTION_WITH_VARACC(result);
308 }
309
GenerateCircuit()310 void BaselineCallArg1Imm8V8StubBuilder::GenerateCircuit()
311 {
312 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallArg1Imm8V8, GLUE));
313 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallArg1Imm8V8, SP));
314 GateRef arg0No = Int32Argument(PARAM_INDEX(BaselineCallArg1Imm8V8, ARG0));
315 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallArg1Imm8V8, SLOT_ID));
316
317 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
318 GateRef curMethod = GetMethodFromFunction(glue, curFunc);
319 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
320 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
321 GateRef a0Value = GetVregValue(glue, sp, ZExtInt32ToPtr(arg0No));
322 GateRef actualNumArgs = Int32(ActualNumArgsOfCall::CALLARG1);
323 GateRef acc = GetAccFromFrame(glue, frame);
324 METHOD_ENTRY(acc);
325 Label noNeedCheckException(env);
326 Label exit(env);
327 GateRef jumpSize = INT_PTR(CALLARG1_IMM8_V8);
328 JSCallArgs callArgs(JSCallMode::CALL_ARG1);
329 callArgs.callArgs = { a0Value, 0, 0 };
330 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
331 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
332 Bind(&exit);
333 CHECK_PENDING_EXCEPTION(*result);
334 Bind(&noNeedCheckException);
335 Return(*result);
336 }
337
GenerateCircuit()338 void BaselineStToGlobalRecordImm16ID16StubBuilder::GenerateCircuit()
339 {
340 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStToGlobalRecordImm16ID16, GLUE));
341 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStToGlobalRecordImm16ID16, SP));
342 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineStToGlobalRecordImm16ID16, ACC));
343 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStToGlobalRecordImm16ID16, STRING_ID));
344
345 GateRef frame = GetFrame(sp);
346 GateRef func = GetFunctionFromFrame(glue, frame);
347 GateRef method = GetMethodFromFunction(glue, func);
348 GateRef constpool = GetConstpoolFromMethod(glue, method);
349 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
350 GateRef result = CallRuntime(glue, RTSTUB_ID(StGlobalRecord),
351 { propKey, acc, TaggedFalse() });
352 CHECK_EXCEPTION_RETURN(result);
353 }
354
GenerateCircuit()355 void BaselineLdaStrID16StubBuilder::GenerateCircuit()
356 {
357 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdaStrID16, GLUE));
358 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdaStrID16, SP));
359 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineLdaStrID16, STRING_ID));
360
361 GateRef func = GetFunctionFromFrame(glue, GetFrame(sp));
362 GateRef method = GetMethodFromFunction(glue, func);
363 GateRef constpool = GetConstpoolFromMethod(glue, method);
364 GateRef result = GetStringFromConstPool(glue, constpool, stringId);
365 Return(result);
366 }
367
GenerateCircuit()368 void BaselineLdsymbolStubBuilder::GenerateCircuit()
369 {
370 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdsymbol, GLUE));
371 GateRef globalEnv = GetGlobalEnv(glue);
372 GateRef result = GetGlobalEnvValue(VariableType::JS_POINTER(), glue, globalEnv, GlobalEnv::SYMBOL_FUNCTION_INDEX);
373
374 Return(result);
375 }
376
GenerateCircuit()377 void BaselineLdglobalStubBuilder::GenerateCircuit()
378 {
379 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdglobal, GLUE));
380 GateRef globalEnv = GetGlobalEnv(glue);
381 GateRef result = GetGlobalObject(glue, globalEnv);
382
383 Return(result);
384 }
385
GenerateCircuit()386 void BaselinePoplexenvStubBuilder::GenerateCircuit()
387 {
388 GateRef glue = PtrArgument(PARAM_INDEX(BaselinePoplexenv, GLUE));
389 GateRef sp = PtrArgument(PARAM_INDEX(BaselinePoplexenv, SP));
390
391 GateRef state = GetFrame(sp);
392 GateRef currentLexEnv = GetEnvFromFrame(glue, state);
393 GateRef parentLexEnv = GetParentEnv(glue, currentLexEnv);
394 SetEnvToFrame(glue, state, parentLexEnv);
395 Return();
396 }
397
GenerateCircuit()398 void BaselineGetunmappedargsStubBuilder::GenerateCircuit()
399 {
400 GateRef glue = PtrArgument(PARAM_INDEX(BaselineGetunmappedargs, GLUE));
401 GateRef sp = PtrArgument(PARAM_INDEX(BaselineGetunmappedargs, SP));
402 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineGetunmappedargs, ACC));
403
404 DEFVARIABLE(argumentsList, VariableType::JS_ANY(), Hole());
405 DEFVARIABLE(argumentsObj, VariableType::JS_ANY(), Hole());
406 auto env = GetEnvironment();
407 GateRef startIdxAndNumArgs = GetStartIdxAndNumArgs(glue, sp, Int32(0));
408 // 32: high 32 bits = startIdx, low 32 bits = numArgs
409 GateRef startIdx = TruncInt64ToInt32(Int64LSR(startIdxAndNumArgs, Int64(32)));
410 GateRef numArgs = TruncInt64ToInt32(startIdxAndNumArgs);
411
412 Label newArgumentsObj(env);
413 Label checkException(env);
414 Label dispatch(env);
415 Label slowPath(env);
416 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
417 newBuilder.SetParameters(glue, 0);
418 Label afterArgumentsList(env);
419 newBuilder.NewArgumentsList(&argumentsList, &afterArgumentsList, sp, startIdx, numArgs);
420 Bind(&afterArgumentsList);
421 Branch(TaggedIsException(*argumentsList), &slowPath, &newArgumentsObj);
422 Bind(&newArgumentsObj);
423 Label afterArgumentsObj(env);
424 newBuilder.NewArgumentsObj(&argumentsObj, &afterArgumentsObj, *argumentsList, numArgs);
425 Bind(&afterArgumentsObj);
426 Branch(TaggedIsException(*argumentsObj), &slowPath, &checkException);
427 Bind(&checkException);
428 Branch(HasPendingException(glue), &slowPath, &dispatch);
429 Bind(&dispatch);
430 {
431 Return(*argumentsObj);
432 }
433
434 Bind(&slowPath);
435 {
436 GateRef res = CallRuntime(glue, RTSTUB_ID(GetUnmapedArgs), {});
437 CHECK_EXCEPTION_WITH_ACC(res);
438 }
439 }
440
GenerateCircuit()441 void BaselineAsyncfunctionenterStubBuilder::GenerateCircuit()
442 {
443 GateRef glue = PtrArgument(PARAM_INDEX(BaselineAsyncfunctionenter, GLUE));
444 GateRef sp = PtrArgument(PARAM_INDEX(BaselineAsyncfunctionenter, SP));
445
446 GateRef result = CallRuntime(glue, RTSTUB_ID(AsyncFunctionEnter), {});
447
448 CHECK_EXCEPTION_RETURN(result);
449 }
450
GenerateCircuit()451 void BaselineCreateasyncgeneratorobjV8StubBuilder::GenerateCircuit()
452 {
453 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreateasyncgeneratorobjV8, GLUE));
454 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreateasyncgeneratorobjV8, SP));
455 GateRef genFunc = TaggedArgument(PARAM_INDEX(BaselineCreateasyncgeneratorobjV8, GEN_FUNC));
456
457 auto env = GetEnvironment();
458 GateRef result = CallRuntime(glue, RTSTUB_ID(CreateAsyncGeneratorObj), { genFunc });
459 Label isException(env);
460 Label notException(env);
461 Branch(TaggedIsException(result), &isException, ¬Exception);
462 Bind(&isException);
463 {
464 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
465 DISPATCH_LAST();
466 Return(result);
467 }
468 Bind(¬Exception);
469 Return(result);
470 }
471
GenerateCircuit()472 void BaselineDebuggerStubBuilder::GenerateCircuit()
473 {
474 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDebugger, GLUE));
475
476 CallRuntime(glue, RTSTUB_ID(NotifyDebuggerStatement), {});
477 Return();
478 }
479
GenerateCircuit()480 void BaselineGetpropiteratorStubBuilder::GenerateCircuit()
481 {
482 GateRef glue = PtrArgument(PARAM_INDEX(BaselineGetpropiterator, GLUE));
483 GateRef sp = PtrArgument(PARAM_INDEX(BaselineGetpropiterator, SP));
484 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineGetpropiterator, ACC));
485
486 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
487 GateRef result = newBuilder.EnumerateObjectProperties(glue, acc);
488 CHECK_EXCEPTION_RETURN(result);
489 }
490
GenerateCircuit()491 void BaselineGetiteratorImm8StubBuilder::GenerateCircuit()
492 {
493 GateRef glue = PtrArgument(PARAM_INDEX(BaselineGetiteratorImm8, GLUE));
494 GateRef sp = PtrArgument(PARAM_INDEX(BaselineGetiteratorImm8, SP));
495 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineGetiteratorImm8, SLOT_ID));
496 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
497
498 GateRef acc = GetAccFromFrame(glue, frame);
499 SetCurrentGlobalEnv(GetGlobalEnv(glue));
500 GateRef res = GetIterator(glue, acc, callback);
501
502 CHECK_PENDING_EXCEPTION(res);
503 }
504
GenerateCircuit()505 void BaselineGetiteratorImm16StubBuilder::GenerateCircuit()
506 {
507 GateRef glue = PtrArgument(PARAM_INDEX(BaselineGetiteratorImm16, GLUE));
508 GateRef sp = PtrArgument(PARAM_INDEX(BaselineGetiteratorImm16, SP));
509 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineGetiteratorImm16, SLOT_ID));
510 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
511
512 GateRef acc = GetAccFromFrame(glue, frame);
513 SetCurrentGlobalEnv(GetGlobalEnv(glue));
514 GateRef res = GetIterator(glue, acc, callback);
515
516 CHECK_PENDING_EXCEPTION(res);
517 }
518
GenerateCircuit()519 void BaselineCloseiteratorImm8V8StubBuilder::GenerateCircuit()
520 {
521 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCloseiteratorImm8V8, GLUE));
522 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCloseiteratorImm8V8, SP));
523 GateRef iter = TaggedArgument(PARAM_INDEX(BaselineCloseiteratorImm8V8, ITER));
524
525 GateRef frame = GetFrame(sp);
526 GateRef acc = GetAccFromFrame(glue, frame);
527 GateRef result = CallRuntime(glue, RTSTUB_ID(CloseIterator), { iter });
528 CHECK_EXCEPTION_WITH_ACC(result);
529 }
530
GenerateCircuit()531 void BaselineCloseiteratorImm16V8StubBuilder::GenerateCircuit()
532 {
533 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCloseiteratorImm16V8, GLUE));
534 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCloseiteratorImm16V8, SP));
535 GateRef iter = TaggedArgument(PARAM_INDEX(BaselineCloseiteratorImm16V8, ITER));
536
537 GateRef frame = GetFrame(sp);
538 GateRef acc = GetAccFromFrame(glue, frame);
539 GateRef result = CallRuntime(glue, RTSTUB_ID(CloseIterator), { iter });
540 CHECK_EXCEPTION_WITH_ACC(result);
541 }
542
GenerateCircuit()543 void BaselineAsyncgeneratorresolveV8V8V8StubBuilder::GenerateCircuit()
544 {
545 GateRef glue = PtrArgument(PARAM_INDEX(BaselineAsyncgeneratorresolveV8V8V8, GLUE));
546 GateRef sp = PtrArgument(PARAM_INDEX(BaselineAsyncgeneratorresolveV8V8V8, SP));
547 GateRef offset = Int32Argument(PARAM_INDEX(BaselineAsyncgeneratorresolveV8V8V8, OFFSET));
548 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineAsyncgeneratorresolveV8V8V8, V0));
549 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineAsyncgeneratorresolveV8V8V8, V1));
550 GateRef v2 = Int32Argument(PARAM_INDEX(BaselineAsyncgeneratorresolveV8V8V8, V2));
551
552 GateRef frame = GetFrame(sp);
553 GateRef curMethod = GetMethodFromFunction(glue, GetFunctionFromFrame(glue, frame));
554 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
555 GateRef constpool = GetConstpoolFromMethod(glue, curMethod);
556 GateRef profileTypeInfo = GetProfileTypeInfoFromFunction(glue, GetFunctionFromFrame(glue, frame));
557 GateRef acc = GetAccFromFrame(glue, frame);
558 ProfileOperation callback;
559
560 GateRef asyncGenerator = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
561 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
562 GateRef flag = GetVregValue(glue, sp, ZExtInt8ToPtr(v2));
563
564 auto env = GetEnvironment();
565 METHOD_EXIT();
566 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
567 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
568 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
569 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
570 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
571 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
572
573 Label isBaselineBuiltinFrame(env);
574 Label notBaselineBuiltinFrame(env);
575 Label pcEqualNullptr(env);
576 Label pcNotEqualNullptr(env);
577 Label pcEqualBaseline(env);
578 Label pcNotEqualBaseline(env);
579 Label updateHotness(env);
580 Label isStable(env);
581 Label tryContinue(env);
582 Label dispatch(env);
583 Label slowPath(env);
584
585 GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncGeneratorResolve),
586 { asyncGenerator, value, flag });
587 Label isException(env);
588 Label notException(env);
589 Branch(TaggedIsException(res), &isException, ¬Exception);
590 Bind(&isException);
591 {
592 DISPATCH_LAST();
593 Return();
594 }
595 Bind(¬Exception);
596 Branch(TaggedIsUndefined(*varProfileTypeInfo), &updateHotness, &isStable);
597 Bind(&isStable);
598 {
599 Branch(ProfilerStubBuilder(env).IsProfileTypeInfoDumped(*varProfileTypeInfo, callback), &tryContinue,
600 &updateHotness);
601 }
602 Bind(&updateHotness);
603 {
604 GateRef function = GetFunctionFromFrame(glue, frame);
605 GateRef thisMethod = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
606 UPDATE_HOTNESS(*varSp, callback);
607 SetHotnessCounter(glue, thisMethod, *varHotnessCounter);
608 Jump(&tryContinue);
609 }
610
611 Bind(&tryContinue);
612 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
613 GateRef curFunc = GetFunctionFromFrame(glue, frame);
614 CallNGCRuntime(glue, RTSTUB_ID(EndCallTimer), { glue, curFunc });
615 #endif
616 GateRef currentSp = *varSp;
617 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), frame,
618 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
619
620 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
621 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
622 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
623 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
624 Bind(&isBaselineBuiltinFrame);
625 {
626 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
627 Jump(¬BaselineBuiltinFrame);
628 }
629 Bind(¬BaselineBuiltinFrame);
630 prevState = GetFrame(*varSp);
631 GateRef varPc = GetPcFromFrame(*prevState);
632 Branch(IntPtrEqual(varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
633 Bind(&pcEqualNullptr);
634 {
635 GateRef result = CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { res, *varSp, currentSp });
636 (void) result;
637 Return();
638 }
639 Bind(&pcNotEqualNullptr);
640 BRANCH(IntPtrEqual(varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
641 Bind(&pcEqualBaseline);
642 {
643 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturnBaseline), { glue, res, *varSp, currentSp });
644 Return();
645 }
646 Bind(&pcNotEqualBaseline);
647 {
648 GateRef function = GetFunctionFromFrame(glue, *prevState);
649 GateRef thisMethod = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
650 varConstpool = GetConstpoolFromMethod(glue, thisMethod);
651 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
652 varHotnessCounter = GetHotnessCounterFromMethod(thisMethod);
653 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
654 GateRef result = CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
655 { glue, currentSp, varPc, *varConstpool, *varProfileTypeInfo,
656 res, *varHotnessCounter, jumpSize });
657 (void) result;
658 Return();
659 }
660 }
661
GenerateCircuit()662 void BaselineCreateemptyobjectStubBuilder::GenerateCircuit()
663 {
664 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreateemptyobject, GLUE));
665 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreateemptyobject, SP));
666 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCreateemptyobject, SLOT_ID));
667 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
668
669 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
670 GateRef result = newBuilder.CreateEmptyObject(glue);
671 Return(result);
672 }
673
GenerateCircuit()674 void BaselineCreateemptyarrayImm8StubBuilder::GenerateCircuit()
675 {
676 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreateemptyarrayImm8, GLUE));
677 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreateemptyarrayImm8, SP));
678 GateRef traceId = Int32Argument(PARAM_INDEX(BaselineCreateemptyarrayImm8, TRACE_ID));
679 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCreateemptyarrayImm8, SLOT_ID));
680
681 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
682 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
683 GateRef result = newBuilder.CreateEmptyArray(glue, curFunc, { 0, traceId, false },
684 profileTypeInfo, slotId, callback);
685 Return(result);
686 }
687
GenerateCircuit()688 void BaselineCreateemptyarrayImm16StubBuilder::GenerateCircuit()
689 {
690 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreateemptyarrayImm16, GLUE));
691 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreateemptyarrayImm16, SP));
692 GateRef traceId = Int32Argument(PARAM_INDEX(BaselineCreateemptyarrayImm16, TRACE_ID));
693 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCreateemptyarrayImm16, SLOTID));
694
695 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
696
697 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
698 GateRef result =
699 newBuilder.CreateEmptyArray(glue, curFunc, { 0, traceId, false }, profileTypeInfo, slotId, callback);
700 Return(result);
701 }
702
GenerateCircuit()703 void BaselineCreategeneratorobjV8StubBuilder::GenerateCircuit()
704 {
705 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreategeneratorobjV8, GLUE));
706 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreategeneratorobjV8, SP));
707 GateRef genFunc = TaggedArgument(PARAM_INDEX(BaselineCreategeneratorobjV8, GEN_FUNC));
708
709 GateRef frame = GetFrame(sp);
710 GateRef acc = GetAccFromFrame(glue, frame);
711 GateRef result = CallRuntime(glue, RTSTUB_ID(CreateGeneratorObj), { genFunc });
712 CHECK_EXCEPTION_WITH_ACC(result);
713 }
714
GenerateCircuit()715 void BaselineCreateiterresultobjV8V8StubBuilder::GenerateCircuit()
716 {
717 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreateiterresultobjV8V8, GLUE));
718 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreateiterresultobjV8V8, SP));
719 GateRef value = TaggedArgument(PARAM_INDEX(BaselineCreateiterresultobjV8V8, VALUE));
720 GateRef flag = TaggedArgument(PARAM_INDEX(BaselineCreateiterresultobjV8V8, FLAG));
721
722 GateRef frame = GetFrame(sp);
723 GateRef acc = GetAccFromFrame(glue, frame);
724 GateRef result = CallRuntime(glue, RTSTUB_ID(CreateIterResultObj), { value, flag });
725 CHECK_EXCEPTION_WITH_ACC(result);
726 }
727
GenerateCircuit()728 void BaselineCreateobjectwithexcludedkeysImm8V8V8StubBuilder::GenerateCircuit()
729 {
730 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreateobjectwithexcludedkeysImm8V8V8, GLUE));
731 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreateobjectwithexcludedkeysImm8V8V8, SP));
732 GateRef numKeys = Int32Argument(PARAM_INDEX(BaselineCreateobjectwithexcludedkeysImm8V8V8, NUMKEYS));
733 GateRef obj = TaggedArgument(PARAM_INDEX(BaselineCreateobjectwithexcludedkeysImm8V8V8, OBJ));
734 GateRef firstArgRegIdx =
735 Int32Argument(PARAM_INDEX(BaselineCreateobjectwithexcludedkeysImm8V8V8, FIRST_ARG_REG_IDX));
736
737 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
738 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateObjectWithExcludedKeys),
739 { Int16ToTaggedInt(numKeys), obj, Int16ToTaggedInt(firstArgRegIdx) });
740 CHECK_EXCEPTION_WITH_ACC(res);
741 }
742
GenerateCircuit()743 void BaselineCallthis0Imm8V8StubBuilder::GenerateCircuit()
744 {
745 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallthis0Imm8V8, GLUE));
746 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallthis0Imm8V8, SP));
747 GateRef thisValueNo = Int32Argument(PARAM_INDEX(BaselineCallthis0Imm8V8, THIS_VALUE_NO));
748 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallthis0Imm8V8, SLOT_ID));
749 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
750 GateRef thisValue = GetVregValue(glue, sp, ZExtInt32ToPtr(thisValueNo));
751 GateRef acc = GetAccFromFrame(glue, frame);
752 GateRef curMethod = GetMethodFromFunction(glue, curFunc);
753 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
754
755 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
756 METHOD_ENTRY(acc);
757 Label noNeedCheckException(env);
758 Label exit(env);
759 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARG0);
760 GateRef jumpSize = INT_PTR(CALLTHIS0_IMM8_V8);
761 JSCallArgs callArgs(JSCallMode::CALL_THIS_ARG0);
762 callArgs.callArgsWithThis = { 0, 0, 0, thisValue };
763 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
764 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
765 Bind(&exit);
766 CHECK_PENDING_EXCEPTION(*result);
767 Bind(&noNeedCheckException);
768 Return(*result);
769 }
770
GenerateCircuit()771 void BaselineCreatearraywithbufferImm8Id16StubBuilder::GenerateCircuit()
772 {
773 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreatearraywithbufferImm8Id16, GLUE));
774 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreatearraywithbufferImm8Id16, SP));
775 GateRef traceId = Int32Argument(PARAM_INDEX(BaselineCreatearraywithbufferImm8Id16, TRACE_ID));
776 GateRef imm = Int32Argument(PARAM_INDEX(BaselineCreatearraywithbufferImm8Id16, IMM));
777 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCreatearraywithbufferImm8Id16, SLOTID));
778
779 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
780 GateRef acc = GetAccFromFrame(glue, frame);
781 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
782 GateRef res = newBuilder.CreateArrayWithBuffer(
783 glue, imm, curFunc, { 0, traceId, false }, profileTypeInfo, slotId, callback);
784 CHECK_EXCEPTION_WITH_ACC(res);
785 }
786
GenerateCircuit()787 void BaselineCreatearraywithbufferImm16Id16StubBuilder::GenerateCircuit()
788 {
789 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreatearraywithbufferImm16Id16, GLUE));
790 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreatearraywithbufferImm16Id16, SP));
791 GateRef traceId = Int32Argument(PARAM_INDEX(BaselineCreatearraywithbufferImm16Id16, TRACE_ID));
792 GateRef imm = Int32Argument(PARAM_INDEX(BaselineCreatearraywithbufferImm16Id16, IMM));
793 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCreatearraywithbufferImm16Id16, SLOTID));
794 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
795
796 GateRef acc = GetAccFromFrame(glue, frame);
797 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
798 GateRef res = newBuilder.CreateArrayWithBuffer(
799 glue, imm, curFunc, { 0, traceId, false }, profileTypeInfo, slotId, callback);
800 CHECK_EXCEPTION_WITH_ACC(res);
801 }
802
GenerateCircuit()803 void BaselineCallthis1Imm8V8V8StubBuilder::GenerateCircuit()
804 {
805 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallthis1Imm8V8V8, GLUE));
806 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallthis1Imm8V8V8, SP));
807 GateRef thisValueId = Int32Argument(PARAM_INDEX(BaselineCallthis1Imm8V8V8, THIS_VALUE_ID));
808 GateRef a0ValueId = Int32Argument(PARAM_INDEX(BaselineCallthis1Imm8V8V8, A0_VALUE_ID));
809 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallthis1Imm8V8V8, SLOT_ID));
810 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
811 GateRef thisValue = GetVregValue(glue, sp, ZExtInt32ToPtr(thisValueId));
812 GateRef a0Value = GetVregValue(glue, sp, ZExtInt32ToPtr(a0ValueId));
813 GateRef curMethod = GetMethodFromFunction(glue, curFunc);
814 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
815
816 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
817 GateRef acc = GetAccFromFrame(glue, frame);
818 METHOD_ENTRY(acc);
819 Label noNeedCheckException(env);
820 Label exit(env);
821 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARG1);
822 GateRef jumpSize = INT_PTR(CALLTHIS1_IMM8_V8_V8);
823 JSCallArgs callArgs(JSCallMode::CALL_THIS_ARG1);
824 callArgs.callArgsWithThis = { a0Value, 0, 0, thisValue };
825 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
826 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
827 Bind(&exit);
828 CHECK_PENDING_EXCEPTION(*result);
829 Bind(&noNeedCheckException);
830 Return(*result);
831 }
832
GenerateCircuit()833 void BaselineCallthis2Imm8V8V8V8StubBuilder::GenerateCircuit()
834 {
835 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallthis2Imm8V8V8V8, GLUE));
836 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallthis2Imm8V8V8V8, SP));
837 GateRef thisValueId = Int32Argument(PARAM_INDEX(BaselineCallthis2Imm8V8V8V8, THIS_VALUE_ID));
838 GateRef a0ValueId = Int32Argument(PARAM_INDEX(BaselineCallthis2Imm8V8V8V8, A0_VALUE_ID));
839 GateRef a1ValueId = Int32Argument(PARAM_INDEX(BaselineCallthis2Imm8V8V8V8, A1_VALUE_ID));
840 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallthis2Imm8V8V8V8, SLOT_ID));
841 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
842
843 GateRef a0Value = GetVregValue(glue, sp, ZExtInt32ToPtr(a0ValueId));
844 GateRef a1Value = GetVregValue(glue, sp, ZExtInt32ToPtr(a1ValueId));
845 GateRef thisValue = GetVregValue(glue, sp, ZExtInt32ToPtr(thisValueId));
846 GateRef curMethod = GetMethodFromFunction(glue, curFunc);
847 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
848
849 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
850 GateRef acc = GetAccFromFrame(glue, frame);
851 METHOD_ENTRY(acc);
852 Label noNeedCheckException(env);
853 Label exit(env);
854 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARGS2);
855 GateRef jumpSize = INT_PTR(CALLTHIS2_IMM8_V8_V8_V8);
856 JSCallArgs callArgs(JSCallMode::CALL_THIS_ARG2);
857 callArgs.callArgsWithThis = { a0Value, a1Value, 0, thisValue };
858 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
859 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
860 Bind(&exit);
861 CHECK_PENDING_EXCEPTION(*result);
862 Bind(&noNeedCheckException);
863 Return(*result);
864 }
865
GenerateCircuit()866 void BaselineCreateobjectwithbufferImm8Id16StubBuilder::GenerateCircuit()
867 {
868 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreateobjectwithbufferImm8Id16, GLUE));
869 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreateobjectwithbufferImm8Id16, SP));
870 GateRef imm = Int32Argument(PARAM_INDEX(BaselineCreateobjectwithbufferImm8Id16, IMM));
871 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCreateobjectwithbufferImm8Id16, SLOT_ID));
872 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
873 GateRef acc = GetAccFromFrame(glue, frame);
874 GateRef method = GetMethodFromFunction(glue, curFunc);
875 GateRef constpool = GetConstpoolFromMethod(glue, method);
876 GateRef currentEnv = GetEnvFromFrame(glue, frame);
877 GateRef module = GetModuleFromFunction(glue, curFunc);
878 GateRef result = GetObjectLiteralFromConstPool(glue, constpool, imm, module);
879 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
880 GateRef res = newBuilder.CreateObjectHavingMethod(glue, result, currentEnv);
881 callback.ProfileCreateObject(res);
882 CHECK_EXCEPTION_WITH_ACC(res);
883 }
884
GenerateCircuit()885 void BaselineCreateobjectwithbufferImm16Id16StubBuilder::GenerateCircuit()
886 {
887 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreateobjectwithbufferImm16Id16, GLUE));
888 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreateobjectwithbufferImm16Id16, SP));
889 GateRef imm = Int32Argument(PARAM_INDEX(BaselineCreateobjectwithbufferImm16Id16, IMM));
890 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCreateobjectwithbufferImm16Id16, SLOT_ID));
891 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
892
893 GateRef acc = GetAccFromFrame(glue, frame);
894 GateRef method = GetMethodFromFunction(glue, curFunc);
895 GateRef constpool = GetConstpoolFromMethod(glue, method);
896 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
897 GateRef module = GetModuleFromFunction(glue, curFunc);
898 GateRef result = GetObjectLiteralFromConstPool(glue, constpool, imm, module);
899 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
900 GateRef res = newBuilder.CreateObjectHavingMethod(glue, result, currentEnv);
901 callback.ProfileCreateObject(res);
902 CHECK_EXCEPTION_WITH_ACC(res);
903 }
904
GenerateCircuit()905 void BaselineCreateregexpwithliteralImm8Id16Imm8StubBuilder::GenerateCircuit()
906 {
907 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreateregexpwithliteralImm8Id16Imm8, GLUE));
908 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreateregexpwithliteralImm8Id16Imm8, SP));
909 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineCreateregexpwithliteralImm8Id16Imm8, STRING_ID));
910 GateRef flags = Int32Argument(PARAM_INDEX(BaselineCreateregexpwithliteralImm8Id16Imm8, FLAGS));
911
912 GateRef frame = GetFrame(sp);
913 GateRef acc = GetAccFromFrame(glue, frame);
914 GateRef func = GetFunctionFromFrame(glue, frame);
915 GateRef method = GetMethodFromFunction(glue, func);
916 GateRef constpool = GetConstpoolFromMethod(glue, method);
917 GateRef pattern = GetStringFromConstPool(glue, constpool, stringId);
918 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateRegExpWithLiteral),
919 { pattern, Int8ToTaggedInt(flags) });
920 CHECK_EXCEPTION_WITH_ACC(res);
921 }
922
GenerateCircuit()923 void BaselineCreateregexpwithliteralImm16Id16Imm8StubBuilder::GenerateCircuit()
924 {
925 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCreateregexpwithliteralImm16Id16Imm8, GLUE));
926 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCreateregexpwithliteralImm16Id16Imm8, SP));
927 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineCreateregexpwithliteralImm16Id16Imm8, STRING_ID));
928 GateRef flags = Int32Argument(PARAM_INDEX(BaselineCreateregexpwithliteralImm16Id16Imm8, FLAGS));
929
930 GateRef frame = GetFrame(sp);
931 GateRef acc = GetAccFromFrame(glue, frame);
932 GateRef func = GetFunctionFromFrame(glue, frame);
933 GateRef method = GetMethodFromFunction(glue, func);
934 GateRef constpool = GetConstpoolFromMethod(glue, method);
935 GateRef pattern = GetStringFromConstPool(glue, constpool, stringId);
936 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateRegExpWithLiteral),
937 { pattern, Int8ToTaggedInt(flags) });
938 CHECK_EXCEPTION_WITH_ACC(res);
939 }
940
GenerateCircuit()941 void BaselineNewobjapplyImm8V8StubBuilder::GenerateCircuit()
942 {
943 GateRef glue = PtrArgument(PARAM_INDEX(BaselineNewobjapplyImm8V8, GLUE));
944 GateRef sp = PtrArgument(PARAM_INDEX(BaselineNewobjapplyImm8V8, SP));
945 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineNewobjapplyImm8V8, ACC));
946 GateRef func = TaggedArgument(PARAM_INDEX(BaselineNewobjapplyImm8V8, FUNC));
947
948 GateRef result = CallRuntime(glue, RTSTUB_ID(NewObjApply), { func, acc }); // acc is array
949 CHECK_EXCEPTION_WITH_ACC(result);
950 }
951
GenerateCircuit()952 void BaselineNewobjapplyImm16V8StubBuilder::GenerateCircuit()
953 {
954 GateRef glue = PtrArgument(PARAM_INDEX(BaselineNewobjapplyImm16V8, GLUE));
955 GateRef sp = PtrArgument(PARAM_INDEX(BaselineNewobjapplyImm16V8, SP));
956 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineNewobjapplyImm16V8, ACC));
957 GateRef func = TaggedArgument(PARAM_INDEX(BaselineNewobjapplyImm16V8, FUNC));
958
959 GateRef result = CallRuntime(glue, RTSTUB_ID(NewObjApply), { func, acc }); // acc is array
960 CHECK_EXCEPTION_WITH_ACC(result);
961 }
962
GenerateCircuit()963 void BaselineNewlexenvImm8StubBuilder::GenerateCircuit()
964 {
965 GateRef glue = PtrArgument(PARAM_INDEX(BaselineNewlexenvImm8, GLUE));
966 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineNewlexenvImm8, ACC));
967 GateRef numVars = Int32Argument(PARAM_INDEX(BaselineNewlexenvImm8, NUM_VARS));
968 GateRef sp = PtrArgument(PARAM_INDEX(BaselineNewlexenvImm8, SP));
969 auto parent = GetEnvFromFrame(glue, GetFrame(sp));
970
971 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
972 auto env = GetEnvironment();
973
974 NewObjectStubBuilder newBuilder(this);
975 newBuilder.SetParameters(glue, 0);
976 Label afterNew(env);
977 newBuilder.NewLexicalEnv(&result, &afterNew, numVars, parent);
978 Bind(&afterNew);
979 Label notException(env);
980 CHECK_EXCEPTION_WITH_JUMP_RETURN(*result, ¬Exception);
981 Bind(¬Exception);
982 SetEnvToFrame(glue, GetFrame(sp), *result);
983 Return(*result);
984 }
985
GenerateCircuit()986 void BaselineNewlexenvwithnameImm8Id16StubBuilder::GenerateCircuit()
987 {
988 GateRef glue = PtrArgument(PARAM_INDEX(BaselineNewlexenvwithnameImm8Id16, GLUE));
989 GateRef sp = PtrArgument(PARAM_INDEX(BaselineNewlexenvwithnameImm8Id16, SP));
990 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineNewlexenvwithnameImm8Id16, ACC));
991 GateRef numVars = Int32Argument(PARAM_INDEX(BaselineNewlexenvwithnameImm8Id16, NUM_VARS));
992 GateRef scopeId = Int32Argument(PARAM_INDEX(BaselineNewlexenvwithnameImm8Id16, SCOPEID));
993
994 auto env = GetEnvironment();
995 GateRef res = CallRuntime(glue, RTSTUB_ID(NewLexicalEnvWithName),
996 { Int16ToTaggedInt(numVars), Int16ToTaggedInt(scopeId) });
997 Label notException(env);
998 CHECK_EXCEPTION_WITH_JUMP_RETURN(res, ¬Exception);
999 Bind(¬Exception);
1000 GateRef state = GetFrame(sp);
1001 SetEnvToFrame(glue, state, res);
1002 Return(res);
1003 }
1004
GenerateCircuit()1005 void BaselineAdd2Imm8V8StubBuilder::GenerateCircuit()
1006 {
1007 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineAdd2Imm8V8);
1008 OperationsStubBuilder builder(this, GetGlobalEnv(glue));
1009 GateRef result = builder.Add(glue, left, acc, callback);
1010 CHECK_EXCEPTION_WITH_ACC(result);
1011 }
1012
GenerateCircuit()1013 void BaselineSub2Imm8V8StubBuilder::GenerateCircuit()
1014 {
1015 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineSub2Imm8V8);
1016 OperationsStubBuilder builder(this, GetGlobalEnv(glue));
1017 GateRef result = builder.Sub(glue, left, acc, callback);
1018 CHECK_EXCEPTION_WITH_ACC(result);
1019 }
1020
GenerateCircuit()1021 void BaselineMul2Imm8V8StubBuilder::GenerateCircuit()
1022 {
1023 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineMul2Imm8V8);
1024 OperationsStubBuilder builder(this, GetGlobalEnv(glue));
1025 GateRef result = builder.Mul(glue, left, acc, callback);
1026 CHECK_EXCEPTION_WITH_ACC(result);
1027 }
1028
GenerateCircuit()1029 void BaselineDiv2Imm8V8StubBuilder::GenerateCircuit()
1030 {
1031 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineDiv2Imm8V8);
1032 OperationsStubBuilder builder(this);
1033 GateRef result = builder.Div(glue, left, acc, callback);
1034 CHECK_EXCEPTION_WITH_ACC(result);
1035 }
1036
GenerateCircuit()1037 void BaselineMod2Imm8V8StubBuilder::GenerateCircuit()
1038 {
1039 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineMod2Imm8V8);
1040 OperationsStubBuilder builder(this);
1041 GateRef result = builder.Mod(glue, left, acc, callback);
1042 CHECK_EXCEPTION_WITH_ACC(result);
1043 }
1044
GenerateCircuit()1045 void BaselineEqImm8V8StubBuilder::GenerateCircuit()
1046 {
1047 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineEqImm8V8);
1048 OperationsStubBuilder builder(this, GetGlobalEnv(glue));
1049 GateRef result = builder.Equal(glue, left, acc, callback);
1050 CHECK_EXCEPTION_WITH_ACC(result);
1051 }
1052
GenerateCircuit()1053 void BaselineNoteqImm8V8StubBuilder::GenerateCircuit()
1054 {
1055 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineNoteqImm8V8);
1056 OperationsStubBuilder builder(this, GetGlobalEnv(glue));
1057 GateRef result = builder.NotEqual(glue, left, acc, callback);
1058 CHECK_EXCEPTION_WITH_ACC(result);
1059 }
1060
GenerateCircuit()1061 void BaselineLessImm8V8StubBuilder::GenerateCircuit()
1062 {
1063 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineLessImm8V8);
1064 OperationsStubBuilder builder(this);
1065 GateRef result = builder.Less(glue, left, acc, callback);
1066 CHECK_EXCEPTION_WITH_ACC(result);
1067 }
1068
GenerateCircuit()1069 void BaselineLesseqImm8V8StubBuilder::GenerateCircuit()
1070 {
1071 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineLesseqImm8V8);
1072 OperationsStubBuilder builder(this);
1073 GateRef result = builder.LessEq(glue, left, acc, callback);
1074 CHECK_EXCEPTION_WITH_ACC(result);
1075 }
1076
GenerateCircuit()1077 void BaselineGreaterImm8V8StubBuilder::GenerateCircuit()
1078 {
1079 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineGreaterImm8V8);
1080 OperationsStubBuilder builder(this);
1081 GateRef result = builder.Greater(glue, left, acc, callback);
1082 CHECK_EXCEPTION_WITH_ACC(result);
1083 }
1084
GenerateCircuit()1085 void BaselineGreatereqImm8V8StubBuilder::GenerateCircuit()
1086 {
1087 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineGreatereqImm8V8);
1088 OperationsStubBuilder builder(this);
1089 GateRef result = builder.GreaterEq(glue, left, acc, callback);
1090 CHECK_EXCEPTION_WITH_ACC(result);
1091 }
1092
GenerateCircuit()1093 void BaselineShl2Imm8V8StubBuilder::GenerateCircuit()
1094 {
1095 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineShl2Imm8V8);
1096 OperationsStubBuilder builder(this);
1097 GateRef result = builder.Shl(glue, left, acc, callback);
1098 CHECK_EXCEPTION_WITH_ACC(result);
1099 }
1100
GenerateCircuit()1101 void BaselineShr2Imm8V8StubBuilder::GenerateCircuit()
1102 {
1103 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineShr2Imm8V8);
1104 OperationsStubBuilder builder(this);
1105 GateRef result = builder.Shr(glue, left, acc, callback);
1106 CHECK_EXCEPTION_WITH_ACC(result);
1107 }
1108
GenerateCircuit()1109 void BaselineAshr2Imm8V8StubBuilder::GenerateCircuit()
1110 {
1111 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineAshr2Imm8V8);
1112 OperationsStubBuilder builder(this);
1113 GateRef result = builder.Ashr(glue, left, acc, callback);
1114 CHECK_EXCEPTION_WITH_ACC(result);
1115 }
1116
GenerateCircuit()1117 void BaselineAnd2Imm8V8StubBuilder::GenerateCircuit()
1118 {
1119 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineAnd2Imm8V8);
1120 OperationsStubBuilder builder(this);
1121 GateRef result = builder.And(glue, left, acc, callback);
1122 CHECK_EXCEPTION_WITH_ACC(result);
1123 }
1124
GenerateCircuit()1125 void BaselineOr2Imm8V8StubBuilder::GenerateCircuit()
1126 {
1127 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineOr2Imm8V8);
1128 OperationsStubBuilder builder(this);
1129 GateRef result = builder.Or(glue, left, acc, callback);
1130 CHECK_EXCEPTION_WITH_ACC(result);
1131 }
1132
GenerateCircuit()1133 void BaselineXor2Imm8V8StubBuilder::GenerateCircuit()
1134 {
1135 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineXor2Imm8V8);
1136 OperationsStubBuilder builder(this);
1137 GateRef result = builder.Xor(glue, left, acc, callback);
1138 CHECK_EXCEPTION_WITH_ACC(result);
1139 }
1140
GenerateCircuit()1141 void BaselineExpImm8V8StubBuilder::GenerateCircuit()
1142 {
1143 GateRef glue = PtrArgument(PARAM_INDEX(BaselineExpImm8V8, GLUE));
1144 GateRef sp = PtrArgument(PARAM_INDEX(BaselineExpImm8V8, SP));
1145 GateRef base = TaggedArgument(PARAM_INDEX(BaselineExpImm8V8, BASE));
1146 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
1147
1148 GateRef result = CallRuntime(glue, RTSTUB_ID(Exp), { base, acc });
1149 CHECK_EXCEPTION_WITH_ACC(result);
1150 }
1151
GenerateCircuit()1152 void BaselineTypeofImm8StubBuilder::GenerateCircuit()
1153 {
1154 GateRef glue = PtrArgument(PARAM_INDEX(BaselineTypeofImm8, GLUE));
1155 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineTypeofImm8, ACC));
1156
1157 GateRef result = FastTypeOf(glue, acc);
1158 Return(result);
1159 }
1160
GenerateCircuit()1161 void BaselineTypeofImm16StubBuilder::GenerateCircuit()
1162 {
1163 GateRef glue = PtrArgument(PARAM_INDEX(BaselineTypeofImm16, GLUE));
1164 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineTypeofImm16, ACC));
1165
1166 GateRef result = FastTypeOf(glue, acc);
1167 Return(result);
1168 }
1169
GenerateCircuit()1170 void BaselineTonumberImm8StubBuilder::GenerateCircuit()
1171 {
1172 GateRef glue = PtrArgument(PARAM_INDEX(BaselineTonumberImm8, GLUE));
1173 GateRef sp = PtrArgument(PARAM_INDEX(BaselineTonumberImm8, SP));
1174 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineTonumberImm8, ACC));
1175
1176 auto env = GetEnvironment();
1177 Label valueIsNumber(env);
1178 Label valueNotNumber(env);
1179 Branch(TaggedIsNumber(acc), &valueIsNumber, &valueNotNumber);
1180 Bind(&valueIsNumber);
1181 {
1182 Return(acc);
1183 }
1184 Bind(&valueNotNumber);
1185 {
1186 GateRef result = CallRuntime(glue, RTSTUB_ID(ToNumber), { acc });
1187 CHECK_EXCEPTION_RETURN(result);
1188 }
1189 }
1190
GenerateCircuit()1191 void BaselineTonumericImm8StubBuilder::GenerateCircuit()
1192 {
1193 GateRef glue = PtrArgument(PARAM_INDEX(BaselineTonumericImm8, GLUE));
1194 GateRef sp = PtrArgument(PARAM_INDEX(BaselineTonumericImm8, SP));
1195 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineTonumericImm8, ACC));
1196
1197 auto env = GetEnvironment();
1198 Label valueIsNumeric(env);
1199 Label valueNotNumeric(env);
1200 Branch(TaggedIsNumeric(glue, acc), &valueIsNumeric, &valueNotNumeric);
1201 Bind(&valueIsNumeric);
1202 {
1203 Return(acc);
1204 }
1205 Bind(&valueNotNumeric);
1206 {
1207 GateRef result = CallRuntime(glue, RTSTUB_ID(ToNumeric), { acc });
1208 CHECK_EXCEPTION_RETURN(result);
1209 }
1210 }
1211
GenerateCircuit()1212 void BaselineNegImm8StubBuilder::GenerateCircuit()
1213 {
1214 DEFINE_SINGLEOP_PARAM_AND_PROFILE_CALLBACK(BaselineNegImm8);
1215 OperationsStubBuilder builder(this);
1216 GateRef result = builder.Neg(glue, acc, callback);
1217 CHECK_EXCEPTION_WITH_ACC(result);
1218 }
1219
GenerateCircuit()1220 void BaselineNotImm8StubBuilder::GenerateCircuit()
1221 {
1222 DEFINE_SINGLEOP_PARAM_AND_PROFILE_CALLBACK(BaselineNotImm8);
1223 OperationsStubBuilder builder(this);
1224 GateRef result = builder.Not(glue, acc, callback);
1225 CHECK_EXCEPTION_WITH_ACC(result);
1226 }
1227
GenerateCircuit()1228 void BaselineIncImm8StubBuilder::GenerateCircuit()
1229 {
1230 DEFINE_SINGLEOP_PARAM_AND_PROFILE_CALLBACK(BaselineIncImm8);
1231 OperationsStubBuilder builder(this);
1232 GateRef result = builder.Inc(glue, acc, callback);
1233 CHECK_EXCEPTION_WITH_ACC(result);
1234 }
1235
GenerateCircuit()1236 void BaselineDecImm8StubBuilder::GenerateCircuit()
1237 {
1238 DEFINE_SINGLEOP_PARAM_AND_PROFILE_CALLBACK(BaselineDecImm8);
1239 OperationsStubBuilder builder(this);
1240 GateRef result = builder.Dec(glue, acc, callback);
1241 CHECK_EXCEPTION_WITH_ACC(result);
1242 }
1243
GenerateCircuit()1244 void BaselineIsinImm8V8StubBuilder::GenerateCircuit()
1245 {
1246 GateRef glue = PtrArgument(PARAM_INDEX(BaselineIsinImm8V8, GLUE));
1247 GateRef sp = PtrArgument(PARAM_INDEX(BaselineIsinImm8V8, SP));
1248 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineIsinImm8V8, ACC));
1249 GateRef prop = TaggedArgument(PARAM_INDEX(BaselineIsinImm8V8, PROP));
1250 SetCurrentGlobalEnv(GetGlobalEnv(glue));
1251
1252 #if ENABLE_NEXT_OPTIMIZATION
1253 GateRef result = IsIn(glue, prop, acc); // acc is obj
1254 #else
1255 GateRef result = CallRuntime(glue, RTSTUB_ID(IsIn), { prop, acc }); // acc is obj
1256 #endif
1257 CHECK_EXCEPTION_WITH_ACC(result);
1258 }
1259
GenerateCircuit()1260 void BaselineInstanceofImm8V8StubBuilder::GenerateCircuit()
1261 {
1262 GateRef glue = PtrArgument(PARAM_INDEX(BaselineInstanceofImm8V8, GLUE));
1263 GateRef sp = PtrArgument(PARAM_INDEX(BaselineInstanceofImm8V8, SP));
1264 GateRef objId = Int32Argument(PARAM_INDEX(BaselineInstanceofImm8V8, OBJ_ID));
1265 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineInstanceofImm8V8, SLOTID));
1266 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1267
1268 GateRef obj = GetVregValue(glue, sp, ZExtInt32ToPtr(objId));
1269 GateRef acc = GetAccFromFrame(glue, frame);
1270 SetCurrentGlobalEnv(GetGlobalEnv(glue));
1271 GateRef result = InstanceOf(glue, obj, acc, profileTypeInfo, slotId, callback);
1272 CHECK_PENDING_EXCEPTION(result);
1273 }
1274
GenerateCircuit()1275 void BaselineStrictnoteqImm8V8StubBuilder::GenerateCircuit()
1276 {
1277 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineStrictnoteqImm8V8);
1278 OperationsStubBuilder builder(this, GetGlobalEnv(glue));
1279 GateRef result = builder.StrictNotEqual(glue, left, acc, callback);
1280 Return(result);
1281 }
1282
GenerateCircuit()1283 void BaselineStricteqImm8V8StubBuilder::GenerateCircuit()
1284 {
1285 DEFINE_BINARYOP_PARAM_AND_PROFILE_CALLBACK(BaselineStricteqImm8V8);
1286 OperationsStubBuilder builder(this, GetGlobalEnv(glue));
1287 GateRef result = builder.StrictEqual(glue, left, acc, callback);
1288 Return(result);
1289 }
1290
GenerateCircuit()1291 void BaselineIstrueStubBuilder::GenerateCircuit()
1292 {
1293 GateRef glue = PtrArgument(PARAM_INDEX(BaselineIstrue, GLUE));
1294 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineIstrue, ACC));
1295
1296 GateRef result = FastToBooleanBaseline(glue, acc, true);
1297 Return(result);
1298 }
1299
GenerateCircuit()1300 void BaselineCallRuntimeIstruePrefImm8StubBuilder::GenerateCircuit()
1301 {
1302 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeIstruePrefImm8, GLUE));
1303 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeIstruePrefImm8, SP));
1304 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineCallRuntimeIstruePrefImm8, ACC));
1305 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallRuntimeIstruePrefImm8, SLOT_ID));
1306 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1307
1308 GateRef result = FastToBooleanWithProfileBaseline(glue, acc, callback, true);
1309 Return(result);
1310 }
1311
GenerateCircuit()1312 void BaselineIsfalseStubBuilder::GenerateCircuit()
1313 {
1314 GateRef glue = PtrArgument(PARAM_INDEX(BaselineIsfalse, GLUE));
1315 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineIsfalse, ACC));
1316
1317 GateRef result = FastToBooleanBaseline(glue, acc, false);
1318 Return(result);
1319 }
1320
GenerateCircuit()1321 void BaselineCallRuntimeIsfalsePrefImm8StubBuilder::GenerateCircuit()
1322 {
1323 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeIsfalsePrefImm8, GLUE));
1324 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeIsfalsePrefImm8, SP));
1325 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineCallRuntimeIsfalsePrefImm8, ACC));
1326 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallRuntimeIsfalsePrefImm8, SLOT_ID));
1327 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1328
1329 GateRef result = FastToBooleanWithProfileBaseline(glue, acc, callback, false);
1330 Return(result);
1331 }
1332
1333
GenerateCircuit()1334 void BaselineCallthis3Imm8V8V8V8V8StubBuilder::GenerateCircuit()
1335 {
1336 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallthis3Imm8V8V8V8V8, GLUE));
1337 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallthis3Imm8V8V8V8V8, SP));
1338 GateRef thisValueId = Int32Argument(PARAM_INDEX(BaselineCallthis3Imm8V8V8V8V8, THIS_VALUE_ID));
1339 GateRef argIds = Int32Argument(PARAM_INDEX(BaselineCallthis3Imm8V8V8V8V8, ARG_IDS));
1340 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallthis3Imm8V8V8V8V8, SLOT_ID));
1341
1342 GateRef arg0Id = Int32And(argIds, Int32(ONE_BYTE_ALL_ONE));
1343 GateRef arg1Id = Int32And(Int32LSR(argIds, Int32(ONE_BYTE_SIZE)), Int32(ONE_BYTE_ALL_ONE));
1344 GateRef arg2Id = Int32And(Int32LSR(argIds, Int32(TWO_BYTE_SIZE)), Int32(ONE_BYTE_ALL_ONE));
1345
1346 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1347
1348 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARGS3);
1349
1350 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
1351
1352 GateRef acc = GetAccFromFrame(glue, frame);
1353 GateRef curMethod = GetMethodFromFunction(glue, curFunc);
1354 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
1355 METHOD_ENTRY(acc);
1356 GateRef a0Value = GetVregValue(glue, sp, ZExtInt32ToPtr(arg0Id));
1357 GateRef a1Value = GetVregValue(glue, sp, ZExtInt32ToPtr(arg1Id));
1358 GateRef a2Value = GetVregValue(glue, sp, ZExtInt32ToPtr(arg2Id));
1359 GateRef thisValue = GetVregValue(glue, sp, ZExtInt32ToPtr(thisValueId));
1360 Label noNeedCheckException(env);
1361 Label exit(env);
1362 GateRef jumpSize = INT_PTR(CALLTHIS3_IMM8_V8_V8_V8_V8);
1363 JSCallArgs callArgs(JSCallMode::CALL_THIS_ARG3);
1364 callArgs.callArgsWithThis = { a0Value, a1Value, a2Value, thisValue };
1365 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
1366 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
1367 Bind(&exit);
1368 CHECK_PENDING_EXCEPTION(*result);
1369 Bind(&noNeedCheckException);
1370 Return(*result);
1371 }
1372
GenerateCircuit()1373 void BaselineCallthisrangeImm8Imm8V8StubBuilder::GenerateCircuit()
1374 {
1375 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallthisrangeImm8Imm8V8, GLUE));
1376 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallthisrangeImm8Imm8V8, SP));
1377 GateRef actualNumArgs = Int32Argument(PARAM_INDEX(BaselineCallthisrangeImm8Imm8V8, ACTUAL_NUM_ARGS));
1378 GateRef thisReg = Int32Argument(PARAM_INDEX(BaselineCallthisrangeImm8Imm8V8, THIS_REG));
1379 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallthisrangeImm8Imm8V8, SLOT_ID));
1380 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1381 GateRef curMethod = GetMethodFromFunction(glue, curFunc);
1382 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
1383 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
1384
1385 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
1386 GateRef acc = GetAccFromFrame(glue, frame);
1387 METHOD_ENTRY(acc);
1388 Label noNeedCheckException(env);
1389 Label exit(env);
1390 GateRef thisValue = GetVregValue(glue, sp, ZExtInt8ToPtr(thisReg));
1391 GateRef argv = PtrAdd(sp, PtrMul(PtrAdd(ZExtInt8ToPtr(thisReg), IntPtr(1)), IntPtr(8)));
1392 GateRef jumpSize = INT_PTR(CALLTHISRANGE_IMM8_IMM8_V8);
1393 JSCallArgs callArgs(JSCallMode::CALL_THIS_WITH_ARGV);
1394 callArgs.callArgvWithThis = { numArgs, argv, thisValue };
1395 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
1396 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
1397 Bind(&exit);
1398 CHECK_PENDING_EXCEPTION(*result);
1399 Bind(&noNeedCheckException);
1400 Return(*result);
1401 }
1402
GenerateCircuit()1403 void BaselineSupercallthisrangeImm8Imm8V8StubBuilder::GenerateCircuit()
1404 {
1405 GateRef glue = PtrArgument(PARAM_INDEX(BaselineSupercallthisrangeImm8Imm8V8, GLUE));
1406 GateRef sp = PtrArgument(PARAM_INDEX(BaselineSupercallthisrangeImm8Imm8V8, SP));
1407 GateRef range = Int32Argument(PARAM_INDEX(BaselineSupercallthisrangeImm8Imm8V8, RANGE));
1408 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineSupercallthisrangeImm8Imm8V8, V0));
1409 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineSupercallthisrangeImm8Imm8V8, HOTNESS_COUNTER));
1410 ProfileOperation callback;
1411
1412 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
1413 DEFVARIABLE(thisObj, VariableType::JS_ANY(), Undefined());
1414 auto env = GetEnvironment();
1415 GateRef actualNumArgs = ZExtInt16ToInt32(range);
1416 GateRef frame = GetFrame(sp);
1417 GateRef thisFunc = GetFunctionFromFrame(glue, frame);
1418 GateRef newTarget = GetNewTarget(glue, sp);
1419 GateRef superCtor = GetPrototype(glue, thisFunc);
1420
1421 Label ctorIsHeapObject(env);
1422 Label ctorIsJSFunction(env);
1423 Label ctorIsConstructor(env);
1424 Label fastPath(env);
1425 Label slowPath(env);
1426 Label checkResult(env);
1427 Label threadCheck(env);
1428 Label dispatch(env);
1429 Label ctorIsBase(env);
1430 Label ctorNotBase(env);
1431 Label isException(env);
1432 Label noNeedCheckException(env);
1433 Label exit(env);
1434
1435 Branch(TaggedIsHeapObject(superCtor), &ctorIsHeapObject, &slowPath);
1436 Bind(&ctorIsHeapObject);
1437 Branch(IsJSFunction(glue, superCtor), &ctorIsJSFunction, &slowPath);
1438 Bind(&ctorIsJSFunction);
1439 Branch(IsConstructor(glue, superCtor), &ctorIsConstructor, &slowPath);
1440 Bind(&ctorIsConstructor);
1441 Branch(TaggedIsUndefined(newTarget), &slowPath, &fastPath);
1442 Bind(&fastPath);
1443 {
1444 Branch(IsBase(glue, superCtor), &ctorIsBase, &ctorNotBase);
1445 Bind(&ctorIsBase);
1446 {
1447 NewObjectStubBuilder newBuilder(this);
1448 thisObj = newBuilder.FastSuperAllocateThis(glue, superCtor, newTarget);
1449 Branch(HasPendingException(glue), &isException, &ctorNotBase);
1450 }
1451 Bind(&ctorNotBase);
1452 {
1453 // skip function
1454 GateRef argv = PtrAdd(sp, PtrMul(ZExtInt16ToPtr(v0), IntPtr(JSTaggedValue::TaggedTypeSize())));
1455 GateRef jumpSize = IntPtr(-BytecodeInstruction::Size(BytecodeInstruction::Format::IMM8_IMM8_V8));
1456 METHOD_ENTRY_ENV_DEFINED(superCtor);
1457 JSCallArgs callArgs(JSCallMode::SUPER_CALL_WITH_ARGV);
1458 callArgs.superCallArgs = {
1459 thisFunc, Int16ToTaggedInt(v0), ZExtInt32ToPtr(actualNumArgs), argv, *thisObj, newTarget
1460 };
1461 CallStubBuilder callBuilder(this, glue, superCtor, actualNumArgs, jumpSize, &res, hotnessCounter, callArgs,
1462 callback);
1463 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
1464 Bind(&exit);
1465 Jump(&threadCheck);
1466 }
1467 }
1468 Bind(&slowPath);
1469 {
1470 res = CallRuntime(glue, RTSTUB_ID(SuperCall),
1471 { thisFunc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) });
1472 Jump(&checkResult);
1473 }
1474 Bind(&checkResult);
1475 {
1476 Branch(TaggedIsException(*res), &isException, &dispatch);
1477 }
1478 Bind(&threadCheck);
1479 {
1480 Branch(HasPendingException(glue), &isException, &dispatch);
1481 }
1482 Bind(&isException);
1483 {
1484 GateRef acc = GetAccFromFrame(glue, frame);
1485 DISPATCH_LAST();
1486 Return(acc);
1487 }
1488 Bind(&dispatch);
1489 Return(*res);
1490 Bind(&noNeedCheckException);
1491 Return(*res);
1492 }
1493
GenerateCircuit()1494 void BaselineSupercallarrowrangeImm8Imm8V8StubBuilder::GenerateCircuit()
1495 {
1496 GateRef glue = PtrArgument(PARAM_INDEX(BaselineSupercallarrowrangeImm8Imm8V8, GLUE));
1497 GateRef sp = PtrArgument(PARAM_INDEX(BaselineSupercallarrowrangeImm8Imm8V8, SP));
1498 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineSupercallarrowrangeImm8Imm8V8, ACC));
1499 GateRef range = Int32Argument(PARAM_INDEX(BaselineSupercallarrowrangeImm8Imm8V8, RANGE));
1500 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineSupercallarrowrangeImm8Imm8V8, V0));
1501
1502 GateRef res = CallRuntime(glue, RTSTUB_ID(SuperCall),
1503 { acc, Int16ToTaggedInt(v0), Int8ToTaggedInt(range) });
1504 CHECK_EXCEPTION_WITH_ACC(res);
1505 }
1506
GenerateCircuit()1507 void BaselineDefinefuncImm8Id16Imm8StubBuilder::GenerateCircuit()
1508 {
1509 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDefinefuncImm8Id16Imm8, GLUE));
1510 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDefinefuncImm8Id16Imm8, SP));
1511 GateRef methodId = Int32Argument(PARAM_INDEX(BaselineDefinefuncImm8Id16Imm8, METHODID));
1512 GateRef length = Int32Argument(PARAM_INDEX(BaselineDefinefuncImm8Id16Imm8, LENGTH));
1513 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineDefinefuncImm8Id16Imm8, SLOT_ID));
1514
1515 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1516 GateRef method = GetMethodFromFunction(glue, curFunc);
1517 GateRef constpool = GetConstpoolFromMethod(glue, method);
1518
1519 auto env = GetEnvironment();
1520 GateRef acc = GetAccFromFrame(glue, frame);
1521 SetCurrentGlobalEnv(GetGlobalEnv(glue));
1522 GateRef result = DefineFunc(glue, constpool, methodId);
1523 Label notException(env);
1524 CHECK_EXCEPTION_WITH_JUMP_RETURN(result, ¬Exception);
1525 Bind(¬Exception);
1526 {
1527 SetLengthToFunction(glue, result, length);
1528 GateRef envHandle = GetEnvFromFrame(glue, frame);
1529 SetLexicalEnvToFunction(glue, result, envHandle);
1530 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
1531 SetModuleToFunction(glue, result, GetModuleFromFunction(glue, currentFunc));
1532 SetHomeObjectToFunction(glue, result, GetHomeObjectFromFunction(glue, currentFunc));
1533 callback.ProfileDefineClass(result);
1534 Return(result);
1535 }
1536 }
1537
GenerateCircuit()1538 void BaselineDefinefuncImm16Id16Imm8StubBuilder::GenerateCircuit()
1539 {
1540 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDefinefuncImm16Id16Imm8, GLUE));
1541 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDefinefuncImm16Id16Imm8, SP));
1542 GateRef methodId = Int32Argument(PARAM_INDEX(BaselineDefinefuncImm16Id16Imm8, METHODID));
1543 GateRef length = Int32Argument(PARAM_INDEX(BaselineDefinefuncImm16Id16Imm8, LENGTH));
1544 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineDefinefuncImm16Id16Imm8, SLOT_ID));
1545 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1546
1547 GateRef method = GetMethodFromFunction(glue, curFunc);
1548 GateRef constpool = GetConstpoolFromMethod(glue, method);
1549 auto env = GetEnvironment();
1550 GateRef acc = GetAccFromFrame(glue, frame);
1551
1552 SetCurrentGlobalEnv(GetGlobalEnv(glue));
1553 GateRef result = DefineFunc(glue, constpool, methodId);
1554 Label notException(env);
1555 CHECK_EXCEPTION_WITH_JUMP_RETURN(result, ¬Exception);
1556 Bind(¬Exception);
1557 {
1558 SetLengthToFunction(glue, result, length);
1559 GateRef envHandle = GetEnvFromFrame(glue, frame);
1560 SetLexicalEnvToFunction(glue, result, envHandle);
1561 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
1562 SetModuleToFunction(glue, result, GetModuleFromFunction(glue, currentFunc));
1563 SetHomeObjectToFunction(glue, result, GetHomeObjectFromFunction(glue, currentFunc));
1564 callback.ProfileDefineClass(result);
1565 Return(result);
1566 }
1567 }
1568
GenerateCircuit()1569 void BaselineDefinemethodImm8Id16Imm8StubBuilder::GenerateCircuit()
1570 {
1571 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDefinemethodImm8Id16Imm8, GLUE));
1572 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDefinemethodImm8Id16Imm8, ACC));
1573 GateRef methodId = Int32Argument(PARAM_INDEX(BaselineDefinemethodImm8Id16Imm8, METHODID));
1574 GateRef length = Int32Argument(PARAM_INDEX(BaselineDefinemethodImm8Id16Imm8, LENGTH));
1575 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDefinemethodImm8Id16Imm8, SP));
1576 ProfileOperation callback;
1577
1578 GateRef func = GetFunctionFromFrame(glue, GetFrame(sp));
1579 GateRef method = GetMethodFromFunction(glue, func);
1580 GateRef constpool = GetConstpoolFromMethod(glue, method);
1581 auto env = GetEnvironment();
1582 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1583 GateRef lexEnv = GetEnvFromFrame(glue, GetFrame(sp));
1584 DEFVARIABLE(result, VariableType::JS_POINTER(),
1585 GetMethodFromConstPool(glue, constpool, methodId));
1586 result = CallRuntime(glue, RTSTUB_ID(DefineMethod), { *result, acc, Int8ToTaggedInt(length),
1587 lexEnv, GetModule(glue, sp) });
1588 Label notException(env);
1589 CHECK_EXCEPTION_WITH_JUMP_RETURN(*result, ¬Exception);
1590 Bind(¬Exception);
1591 Return(*result);
1592 }
1593
GenerateCircuit()1594 void BaselineDefinemethodImm16Id16Imm8StubBuilder::GenerateCircuit()
1595 {
1596 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDefinemethodImm16Id16Imm8, GLUE));
1597 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDefinemethodImm16Id16Imm8, ACC));
1598 GateRef methodId = Int32Argument(PARAM_INDEX(BaselineDefinemethodImm16Id16Imm8, METHODID));
1599 GateRef length = Int32Argument(PARAM_INDEX(BaselineDefinemethodImm16Id16Imm8, LENGTH));
1600 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDefinemethodImm16Id16Imm8, SP));
1601 ProfileOperation callback;
1602
1603 GateRef func = GetFunctionFromFrame(glue, GetFrame(sp));
1604 GateRef method = GetMethodFromFunction(glue, func);
1605 GateRef constpool = GetConstpoolFromMethod(glue, method);
1606 auto env = GetEnvironment();
1607 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1608 GateRef lexEnv = GetEnvFromFrame(glue, GetFrame(sp));
1609 DEFVARIABLE(result, VariableType::JS_POINTER(),
1610 GetMethodFromConstPool(glue, constpool, methodId));
1611 result = CallRuntime(glue, RTSTUB_ID(DefineMethod), { *result, acc, Int8ToTaggedInt(length),
1612 lexEnv, GetModule(glue, sp) });
1613 Label notException(env);
1614 CHECK_EXCEPTION_WITH_JUMP_RETURN(*result, ¬Exception);
1615 Bind(¬Exception);
1616 Return(*result);
1617 }
1618
GenerateCircuit()1619 void BaselineCallarg0Imm8StubBuilder::GenerateCircuit()
1620 {
1621 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallarg0Imm8, GLUE));
1622 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallarg0Imm8, SP));
1623 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallarg0Imm8, SLOT_ID));
1624 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1625
1626 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
1627 GateRef acc = GetAccFromFrame(glue, frame);
1628 METHOD_ENTRY(acc);
1629 Label noNeedCheckException(env);
1630 Label exit(env);
1631 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARG0);
1632 GateRef jumpSize = INT_PTR(CALLARG0_IMM8);
1633 GateRef curMethod = GetMethodFromFunction(glue, curFunc);
1634 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
1635 JSCallArgs callArgs(JSCallMode::CALL_ARG0);
1636 callArgs.callArgs = { 0, 0, 0 };
1637 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
1638 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
1639 Bind(&exit);
1640 CHECK_PENDING_EXCEPTION(*result);
1641 Bind(&noNeedCheckException);
1642 Return(*result);
1643 }
1644
GenerateCircuit()1645 void BaselineCallRuntimeSupercallforwardallargsPrefV8StubBuilder::GenerateCircuit()
1646 {
1647 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeSupercallforwardallargsPrefV8, GLUE));
1648 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeSupercallforwardallargsPrefV8, SP));
1649 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineCallRuntimeSupercallforwardallargsPrefV8, V0));
1650 GateRef thisFunc = GetVregValue(glue, sp, ZExtInt32ToPtr(v0));
1651
1652 GateRef frame = GetFrame(sp);
1653 GateRef acc = GetAccFromFrame(glue, frame);
1654 GateRef res = CallRuntime(glue, RTSTUB_ID(SuperCallForwardAllArgs), { thisFunc });
1655 CHECK_PENDING_EXCEPTION(res); // CheckPendingException(glue, sp, res, acc)
1656 }
1657
GenerateCircuit()1658 void BaselineSupercallspreadImm8V8StubBuilder::GenerateCircuit()
1659 {
1660 GateRef glue = PtrArgument(PARAM_INDEX(BaselineSupercallspreadImm8V8, GLUE));
1661 GateRef sp = PtrArgument(PARAM_INDEX(BaselineSupercallspreadImm8V8, SP));
1662 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineSupercallspreadImm8V8, ACC));
1663 GateRef array = TaggedArgument(PARAM_INDEX(BaselineSupercallspreadImm8V8, ARRARY));
1664 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineSupercallspreadImm8V8, HOTNESS_COUNTER));
1665 ProfileOperation callback;
1666
1667 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
1668 DEFVARIABLE(thisObj, VariableType::JS_ANY(), Undefined());
1669 auto env = GetEnvironment();
1670 GateRef newTarget = GetNewTarget(glue, sp);
1671 GateRef superCtor = GetPrototype(glue, acc);
1672
1673 Label dispatch(env);
1674 Label normalPath(env);
1675 Label slowPath(env);
1676 Label ctorIsJSFunction(env);
1677 Label ctorIsBase(env);
1678 Label ctorNotBase(env);
1679 Label ctorIsHeapObject(env);
1680 Label ctorIsConstructor(env);
1681 Label threadCheck(env);
1682 Label isException(env);
1683 Label noNeedCheckException(env);
1684 Label exit(env);
1685
1686 Branch(TaggedIsHeapObject(superCtor), &ctorIsHeapObject, &slowPath);
1687 Bind(&ctorIsHeapObject);
1688 Branch(IsJSFunction(glue, superCtor), &ctorIsJSFunction, &slowPath);
1689 Bind(&ctorIsJSFunction);
1690 Branch(IsConstructor(glue, superCtor), &ctorIsConstructor, &slowPath);
1691 Bind(&ctorIsConstructor);
1692 Branch(TaggedIsUndefined(newTarget), &slowPath, &normalPath);
1693 Bind(&normalPath);
1694 {
1695 Branch(IsBase(glue, superCtor), &ctorIsBase, &ctorNotBase);
1696 Bind(&ctorIsBase);
1697 {
1698 NewObjectStubBuilder objBuilder(this);
1699 thisObj = objBuilder.FastSuperAllocateThis(glue, superCtor, newTarget);
1700 Branch(HasPendingException(glue), &isException, &ctorNotBase);
1701 }
1702 Bind(&ctorNotBase);
1703 {
1704 GateRef argvLen = LoadPrimitive(VariableType::INT32(), array, IntPtr(JSArray::LENGTH_OFFSET));
1705 SetCurrentGlobalEnv(GetGlobalEnv(glue));
1706 GateRef srcElements = GetCallSpreadArgs(glue, array, callback);
1707 GateRef jumpSize = IntPtr(-BytecodeInstruction::Size(BytecodeInstruction::Format::IMM8_V8));
1708 METHOD_ENTRY_ENV_DEFINED(superCtor);
1709 GateRef elementsPtr = PtrAdd(srcElements, IntPtr(TaggedArray::DATA_OFFSET));
1710 JSCallArgs callArgs(JSCallMode::SUPER_CALL_SPREAD_WITH_ARGV);
1711 callArgs.superCallArgs = { acc, array, ZExtInt32ToPtr(argvLen), elementsPtr, *thisObj, newTarget };
1712 CallStubBuilder callBuilder(this, glue, superCtor, argvLen, jumpSize, &res, hotnessCounter, callArgs,
1713 callback);
1714 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
1715 Bind(&exit);
1716 Jump(&threadCheck);
1717 }
1718 }
1719 Bind(&slowPath);
1720 {
1721 res = CallRuntime(glue, RTSTUB_ID(SuperCallSpread), { acc, array });
1722 Jump(&threadCheck);
1723 }
1724 Bind(&threadCheck);
1725 {
1726 GateRef resVal = *res;
1727 GateRef isError = LogicAndBuilder(env).And(TaggedIsException(resVal)).And(HasPendingException(glue)).Done();
1728 Branch(isError, &isException, &dispatch);
1729 }
1730 Bind(&isException);
1731 {
1732 DISPATCH_LAST();
1733 Return(acc);
1734 }
1735 Bind(&dispatch);
1736 Return(*res);
1737 Bind(&noNeedCheckException);
1738 Return(*res);
1739 }
1740
GenerateCircuit()1741 void BaselineApplyImm8V8V8StubBuilder::GenerateCircuit()
1742 {
1743 GateRef glue = PtrArgument(PARAM_INDEX(BaselineApplyImm8V8V8, GLUE));
1744 GateRef sp = PtrArgument(PARAM_INDEX(BaselineApplyImm8V8V8, SP));
1745 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineApplyImm8V8V8, ACC));
1746 GateRef obj = TaggedArgument(PARAM_INDEX(BaselineApplyImm8V8V8, OBJ));
1747 GateRef array = TaggedArgument(PARAM_INDEX(BaselineApplyImm8V8V8, ARRARY));
1748
1749 GateRef res = CallRuntime(glue, RTSTUB_ID(CallSpread), { acc, obj, array });
1750 CHECK_PENDING_EXCEPTION(res);
1751 }
1752
GenerateCircuit()1753 void BaselineCallargs2Imm8V8V8StubBuilder::GenerateCircuit()
1754 {
1755 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallargs2Imm8V8V8, GLUE));
1756 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallargs2Imm8V8V8, SP));
1757 GateRef arg0No = Int32Argument(PARAM_INDEX(BaselineCallargs2Imm8V8V8, ARG0_NO));
1758 GateRef arg1No = Int32Argument(PARAM_INDEX(BaselineCallargs2Imm8V8V8, ARG1_NO));
1759 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallargs2Imm8V8V8, SLOT_ID));
1760 GateRef a0Value = GetVregValue(glue, sp, ZExtInt32ToPtr(arg0No));
1761 GateRef a1Value = GetVregValue(glue, sp, ZExtInt32ToPtr(arg1No));
1762 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1763
1764 GateRef acc = GetAccFromFrame(glue, frame);
1765 GateRef curMethod = GetMethodFromFunction(glue, curFunc);
1766 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
1767
1768 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
1769 METHOD_ENTRY(acc);
1770 Label noNeedCheckException(env);
1771 Label exit(env);
1772 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARGS2);
1773 GateRef jumpSize = INT_PTR(CALLARGS2_IMM8_V8_V8);
1774 JSCallArgs callArgs(JSCallMode::CALL_ARG2);
1775 callArgs.callArgs = { a0Value, a1Value, 0 };
1776 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
1777 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
1778 Bind(&exit);
1779 CHECK_PENDING_EXCEPTION(*result);
1780 Bind(&noNeedCheckException);
1781 Return(*result);
1782 }
1783
GenerateCircuit()1784 void BaselineCallargs3Imm8V8V8V8StubBuilder::GenerateCircuit()
1785 {
1786 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallargs3Imm8V8V8V8, GLUE));
1787 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallargs3Imm8V8V8V8, SP));
1788 GateRef arg0No = Int32Argument(PARAM_INDEX(BaselineCallargs3Imm8V8V8V8, ARG0_NO));
1789 GateRef arg1No = Int32Argument(PARAM_INDEX(BaselineCallargs3Imm8V8V8V8, ARG1_NO));
1790 GateRef arg2No = Int32Argument(PARAM_INDEX(BaselineCallargs3Imm8V8V8V8, ARG2_NO));
1791 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallargs3Imm8V8V8V8, SLOT_ID));
1792
1793 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1794 GateRef curMethod = GetMethodFromFunction(glue, curFunc);
1795 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
1796 GateRef arg0Value = GetVregValue(glue, sp, ZExtInt32ToPtr(arg0No));
1797 GateRef arg1Value = GetVregValue(glue, sp, ZExtInt32ToPtr(arg1No));
1798 GateRef arg2Value = GetVregValue(glue, sp, ZExtInt32ToPtr(arg2No));
1799 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
1800 GateRef acc = GetAccFromFrame(glue, frame);
1801 METHOD_ENTRY(acc);
1802 Label noNeedCheckException(env);
1803 Label exit(env);
1804 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARGS3);
1805 GateRef jumpSize = INT_PTR(CALLARGS3_IMM8_V8_V8_V8);
1806 JSCallArgs callArgs(JSCallMode::CALL_ARG3);
1807 callArgs.callArgs = { arg0Value, arg1Value, arg2Value };
1808 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
1809 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
1810 Bind(&exit);
1811 CHECK_PENDING_EXCEPTION(*result);
1812 Bind(&noNeedCheckException);
1813 Return(*result);
1814 }
1815
GenerateCircuit()1816 void BaselineCallrangeImm8Imm8V8StubBuilder::GenerateCircuit()
1817 {
1818 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallrangeImm8Imm8V8, GLUE));
1819 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallrangeImm8Imm8V8, SP));
1820 GateRef actualNumArgs = Int32Argument(PARAM_INDEX(BaselineCallrangeImm8Imm8V8, ACTUAL_NUM_ARGS));
1821 GateRef argStart = Int32Argument(PARAM_INDEX(BaselineCallrangeImm8Imm8V8, ARG_START));
1822 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallrangeImm8Imm8V8, SLOT_ID));
1823 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1824
1825 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
1826 GateRef acc = GetAccFromFrame(glue, frame);
1827 GateRef curMethod = GetMethodFromJSFunctionOrProxy(glue, curFunc);
1828 GateRef hotnessCounter = GetHotnessCounterFromMethod(curMethod);
1829 METHOD_ENTRY(acc);
1830 Label noNeedCheckException(env);
1831 Label exit(env);
1832 GateRef argv = PtrAdd(sp, PtrMul(ZExtInt32ToPtr(argStart), IntPtr(8)));
1833 GateRef jumpSize = INT_PTR(CALLRANGE_IMM8_IMM8_V8);
1834 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
1835 JSCallArgs callArgs(JSCallMode::CALL_WITH_ARGV);
1836 callArgs.callArgv = { numArgs, argv };
1837 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
1838 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
1839 Bind(&exit);
1840 CHECK_PENDING_EXCEPTION(*result);
1841 Bind(&noNeedCheckException);
1842 Return(*result);
1843 }
1844
GenerateCircuit()1845 void BaselineLdexternalmodulevarImm8StubBuilder::GenerateCircuit()
1846 {
1847 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdexternalmodulevarImm8, GLUE));
1848 GateRef index = Int32Argument(PARAM_INDEX(BaselineLdexternalmodulevarImm8, INDEX));
1849
1850 GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(LdExternalModuleVarByIndex), { Int8ToTaggedInt(index) });
1851 Return(moduleRef);
1852 }
1853
GenerateCircuit()1854 void BaselineLdthisbynameImm8Id16StubBuilder::GenerateCircuit()
1855 {
1856 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdthisbynameImm8Id16, GLUE));
1857 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdthisbynameImm8Id16, SP));
1858 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineLdthisbynameImm8Id16, STRING_ID));
1859 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdthisbynameImm8Id16, SLOT_ID));
1860 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1861
1862 GateRef method = GetMethodFromFunction(glue, curFunc);
1863 GateRef constpool = GetConstpoolFromMethod(glue, method);
1864 GateRef receiver = GetThisFromFrame(glue, frame);
1865
1866 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
1867 StringIdInfo stringIdInfo(constpool, stringId);
1868 GateRef result = builder.LoadObjByName(glue, receiver, 0, stringIdInfo, profileTypeInfo, slotId, callback);
1869 CHECK_EXCEPTION_RETURN(result);
1870 }
1871
GenerateCircuit()1872 void BaselineDefinegettersetterbyvalueV8V8V8V8StubBuilder::GenerateCircuit()
1873 {
1874 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDefinegettersetterbyvalueV8V8V8V8, GLUE));
1875 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDefinegettersetterbyvalueV8V8V8V8, SP));
1876 GateRef offset = Int32Argument(PARAM_INDEX(BaselineDefinegettersetterbyvalueV8V8V8V8, OFFSET));
1877 GateRef vregIds = Int32Argument(PARAM_INDEX(BaselineDefinegettersetterbyvalueV8V8V8V8, VREG_IDS));
1878
1879 GateRef objectVregId = Int32And(vregIds, Int32(ONE_BYTE_ALL_ONE));
1880 GateRef propkeyVregId = Int32And(Int32LSR(vregIds, Int32(ONE_BYTE_SIZE)), Int32(ONE_BYTE_ALL_ONE));
1881 GateRef getterVregId = Int32And(Int32LSR(vregIds, Int32(TWO_BYTE_SIZE)), Int32(ONE_BYTE_ALL_ONE));
1882 GateRef setterVregId = Int32And(Int32LSR(vregIds, Int32(THREE_BYTE_SIZE)), Int32(ONE_BYTE_ALL_ONE));
1883
1884 GateRef obj = GetVregValue(glue, sp, ZExtInt32ToPtr(objectVregId));
1885 GateRef prop = GetVregValue(glue, sp, ZExtInt32ToPtr(propkeyVregId));
1886 GateRef getter = GetVregValue(glue, sp, ZExtInt32ToPtr(getterVregId));
1887 GateRef setter = GetVregValue(glue, sp, ZExtInt32ToPtr(setterVregId));
1888
1889 GateRef frame = GetFrame(sp);
1890 GateRef acc = GetAccFromFrame(glue, frame);
1891
1892 GateRef func = GetFunctionFromFrame(glue, frame);
1893 GateRef offsetPtr = TaggedPtrToTaggedIntPtr(IntPtr(offset));
1894 GateRef res = CallRuntime(glue, RTSTUB_ID(DefineGetterSetterByValue),
1895 { obj, prop, getter, setter, acc, func, offsetPtr }); // acc is flag
1896 CHECK_EXCEPTION_WITH_ACC(res);
1897 }
1898
GenerateCircuit()1899 void BaselineLdthisbynameImm16Id16StubBuilder::GenerateCircuit()
1900 {
1901 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdthisbynameImm16Id16, GLUE));
1902 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdthisbynameImm16Id16, SP));
1903 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineLdthisbynameImm16Id16, STRING_ID));
1904 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdthisbynameImm16Id16, SLOT_ID));
1905 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1906
1907 GateRef method = GetMethodFromFunction(glue, curFunc);
1908 GateRef constpool = GetConstpoolFromMethod(glue, method);
1909 GateRef receiver = GetThisFromFrame(glue, frame);
1910
1911 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
1912 StringIdInfo stringIdInfo(constpool, stringId);
1913 GateRef result = builder.LoadObjByName(glue, receiver, 0, stringIdInfo, profileTypeInfo, slotId, callback);
1914 CHECK_EXCEPTION_RETURN(result);
1915 }
1916
GenerateCircuit()1917 void BaselineStthisbynameImm8Id16StubBuilder::GenerateCircuit()
1918 {
1919 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStthisbynameImm8Id16, GLUE));
1920 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStthisbynameImm8Id16, SP));
1921 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStthisbynameImm8Id16, STRING_ID));
1922 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStthisbynameImm8Id16, SLOT_ID));
1923
1924 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1925 GateRef method = GetMethodFromFunction(glue, curFunc);
1926 GateRef constpool = GetConstpoolFromMethod(glue, method);
1927 GateRef acc = GetAccFromFrame(glue, frame);
1928 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
1929 GateRef receiver = GetThisFromFrame(glue, frame);
1930 StringIdInfo stringIdInfo(constpool, stringId);
1931 GateRef result =
1932 builder.StoreObjByName(glue, receiver, 0, stringIdInfo, acc, profileTypeInfo, slotId, callback);
1933 CHECK_EXCEPTION(result);
1934 }
1935
GenerateCircuit()1936 void BaselineStthisbynameImm16Id16StubBuilder::GenerateCircuit()
1937 {
1938 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStthisbynameImm16Id16, GLUE));
1939 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStthisbynameImm16Id16, SP));
1940 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStthisbynameImm16Id16, STRING_ID));
1941 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStthisbynameImm16Id16, SLOT_ID));
1942 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1943
1944 GateRef method = GetMethodFromFunction(glue, curFunc);
1945 GateRef constpool = GetConstpoolFromMethod(glue, method);
1946 GateRef acc = GetAccFromFrame(glue, frame);
1947 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
1948 GateRef receiver = GetThisFromFrame(glue, frame);
1949 StringIdInfo stringIdInfo(constpool, stringId);
1950 GateRef result = builder.StoreObjByName(glue, receiver, 0, stringIdInfo, acc, profileTypeInfo, slotId, callback);
1951 CHECK_EXCEPTION(result);
1952 }
1953
GenerateCircuit()1954 void BaselineLdthisbyvalueImm8StubBuilder::GenerateCircuit()
1955 {
1956 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdthisbyvalueImm8, GLUE));
1957 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdthisbyvalueImm8, SP));
1958 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdthisbyvalueImm8, SLOT_ID));
1959 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1960
1961 GateRef acc = GetAccFromFrame(glue, frame);
1962
1963 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
1964 GateRef receiver = GetThisFromFrame(glue, frame);
1965 GateRef result = builder.LoadObjByValue(glue, receiver, acc, profileTypeInfo, slotId, callback);
1966 CHECK_EXCEPTION_RETURN(result);
1967 }
1968
GenerateCircuit()1969 void BaselineLdthisbyvalueImm16StubBuilder::GenerateCircuit()
1970 {
1971 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdthisbyvalueImm16, GLUE));
1972 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdthisbyvalueImm16, SP));
1973 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdthisbyvalueImm16, SLOT_ID));
1974 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1975
1976 GateRef acc = GetAccFromFrame(glue, frame);
1977
1978 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
1979 GateRef receiver = GetThisFromFrame(glue, frame);
1980 GateRef result = builder.LoadObjByValue(glue, receiver, acc, profileTypeInfo, slotId, callback);
1981 CHECK_EXCEPTION_RETURN(result);
1982 }
1983
GenerateCircuit()1984 void BaselineStthisbyvalueImm8V8StubBuilder::GenerateCircuit()
1985 {
1986 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStthisbyvalueImm8V8, GLUE));
1987 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStthisbyvalueImm8V8, SP));
1988 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStthisbyvalueImm8V8, SLOT_ID));
1989 GateRef propKey = TaggedArgument(PARAM_INDEX(BaselineStthisbyvalueImm8V8, PROP_KEY));
1990 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
1991
1992 GateRef acc = GetAccFromFrame(glue, frame);
1993 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
1994 GateRef receiver = GetThisFromFrame(glue, frame);
1995 GateRef result = builder.StoreObjByValue(glue, receiver, propKey, acc, profileTypeInfo, slotId, callback);
1996 CHECK_EXCEPTION(result);
1997 }
1998
GenerateCircuit()1999 void BaselineStthisbyvalueImm16V8StubBuilder::GenerateCircuit()
2000 {
2001 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStthisbyvalueImm16V8, GLUE));
2002 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStthisbyvalueImm16V8, SP));
2003 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStthisbyvalueImm16V8, SLOT_ID));
2004 GateRef propKey = TaggedArgument(PARAM_INDEX(BaselineStthisbyvalueImm16V8, PROP_KEY));
2005 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2006
2007 GateRef acc = GetAccFromFrame(glue, frame);
2008 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2009 GateRef receiver = GetThisFromFrame(glue, frame);
2010 GateRef result = builder.StoreObjByValue(glue, receiver, propKey, acc, profileTypeInfo, slotId, callback);
2011 CHECK_EXCEPTION(result);
2012 }
2013
GenerateCircuit()2014 void BaselineDynamicimportStubBuilder::GenerateCircuit()
2015 {
2016 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDynamicimport, GLUE));
2017 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDynamicimport, SP));
2018
2019 GateRef frame = GetFrame(sp);
2020 GateRef acc = GetAccFromFrame(glue, frame);
2021 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
2022 GateRef res = CallRuntime(glue, RTSTUB_ID(DynamicImport), { acc, currentFunc });
2023 CHECK_EXCEPTION_WITH_ACC(res);
2024 }
2025
GenerateCircuit()2026 void BaselineDefineclasswithbufferImm8Id16Id16Imm16V8StubBuilder::GenerateCircuit()
2027 {
2028 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDefineclasswithbufferImm8Id16Id16Imm16V8, GLUE));
2029 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDefineclasswithbufferImm8Id16Id16Imm16V8, SP));
2030 GateRef methodId = Int32Argument(PARAM_INDEX(BaselineDefineclasswithbufferImm8Id16Id16Imm16V8, METHOD_ID));
2031 GateRef literalId = Int32Argument(PARAM_INDEX(BaselineDefineclasswithbufferImm8Id16Id16Imm16V8, LITERRAL_ID));
2032 GateRef length = Int32Argument(PARAM_INDEX(BaselineDefineclasswithbufferImm8Id16Id16Imm16V8, LENGTH));
2033 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDefineclasswithbufferImm8Id16Id16Imm16V8, V0));
2034 ProfileOperation callback;
2035 GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2036
2037 GateRef frame = GetFrame(sp);
2038 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
2039 GateRef method = GetMethodFromFunction(glue, currentFunc);
2040 GateRef constpool = GetConstpoolFromMethod(glue, method);
2041
2042 auto env = GetEnvironment();
2043 GateRef lexicalEnv = GetEnvFromFrame(glue, frame);
2044 GateRef module = GetModuleFromFunction(glue, currentFunc);
2045 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateClassWithBuffer),
2046 { proto, lexicalEnv, constpool,
2047 Int16ToTaggedInt(methodId),
2048 Int16ToTaggedInt(literalId), module,
2049 Int16ToTaggedInt(length)});
2050
2051 Label isException(env);
2052 Label isNotException(env);
2053 Branch(TaggedIsException(res), &isException, &isNotException);
2054 Bind(&isException);
2055 {
2056 GateRef acc = GetAccFromFrame(glue, frame);
2057 DISPATCH_LAST_WITH_ACC();
2058 Return(acc);
2059 }
2060 Bind(&isNotException);
2061 callback.ProfileDefineClass(res);
2062 Return(res);
2063 }
2064
GenerateCircuit()2065 void BaselineDefineclasswithbufferImm16Id16Id16Imm16V8StubBuilder::GenerateCircuit()
2066 {
2067 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDefineclasswithbufferImm16Id16Id16Imm16V8, GLUE));
2068 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDefineclasswithbufferImm16Id16Id16Imm16V8, SP));
2069 GateRef methodLiteralId =
2070 Int32Argument(PARAM_INDEX(BaselineDefineclasswithbufferImm16Id16Id16Imm16V8, METHOD_LITERIAL_ID));
2071 GateRef lengthAndProtoId =
2072 Int32Argument(PARAM_INDEX(BaselineDefineclasswithbufferImm16Id16Id16Imm16V8, COUNT_SUPERCLASS_ID));
2073 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineDefineclasswithbufferImm16Id16Id16Imm16V8, SLOT_ID));
2074 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2075
2076 GateRef methodId = Int32And(methodLiteralId, Int32(TWO_BYTE_ALL_ONE));
2077 GateRef literalId = Int32And(Int32LSR(methodLiteralId, Int32(TWO_BYTE_SIZE)), Int32(TWO_BYTE_ALL_ONE));
2078 GateRef length = Int32And(lengthAndProtoId, Int32(TWO_BYTE_SIZE));
2079 GateRef protoVregId = Int32And(Int32LSR(lengthAndProtoId, Int32(TWO_BYTE_SIZE)), Int32(TWO_BYTE_ALL_ONE));
2080 GateRef proto = GetVregValue(glue, sp, ZExtInt32ToPtr(protoVregId));
2081
2082 GateRef method = GetMethodFromFunction(glue, curFunc);
2083 GateRef constpool = GetConstpoolFromMethod(glue, method);
2084 auto env = GetEnvironment();
2085 GateRef lexicalEnv = GetEnvFromFrame(glue, frame);
2086 GateRef module = GetModuleFromFunction(glue, curFunc);
2087 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateClassWithBuffer),
2088 { proto, lexicalEnv, constpool,
2089 IntToTaggedInt(methodId),
2090 IntToTaggedInt(literalId), module,
2091 IntToTaggedInt(length)});
2092 Label isException(env);
2093 Label isNotException(env);
2094 Branch(TaggedIsException(res), &isException, &isNotException);
2095 Bind(&isException);
2096 {
2097 GateRef acc = GetAccFromFrame(glue, frame);
2098 DISPATCH_LAST_WITH_ACC();
2099 Return(res);
2100 }
2101 Bind(&isNotException);
2102 callback.ProfileDefineClass(res);
2103 Return(res);
2104 }
2105
GenerateCircuit()2106 void BaselineResumegeneratorStubBuilder::GenerateCircuit()
2107 {
2108 GateRef glue = PtrArgument(PARAM_INDEX(BaselineResumegenerator, GLUE));
2109 GateRef sp = PtrArgument(PARAM_INDEX(BaselineResumegenerator, SP));
2110 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineResumegenerator, ACC));
2111 (void) sp;
2112 (void) glue;
2113
2114 auto env = GetEnvironment();
2115 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
2116
2117 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
2118 GateRef frame = GetFrame(sp);
2119 GateRef curFunc = GetFunctionFromFrame(glue, frame);
2120 CallNGCRuntime(glue, RTSTUB_ID(StartCallTimer), { glue, curFunc, False() });
2121 #endif
2122 Label isAsyncGeneratorObj(env);
2123 Label notAsyncGeneratorObj(env);
2124 Label dispatch(env);
2125 Branch(TaggedIsAsyncGeneratorObject(glue, acc), &isAsyncGeneratorObj, ¬AsyncGeneratorObj);
2126 Bind(&isAsyncGeneratorObj);
2127 {
2128 GateRef resumeResultOffset = IntPtr(JSAsyncGeneratorObject::GENERATOR_RESUME_RESULT_OFFSET);
2129 varAcc = Load(VariableType::JS_ANY(), glue, acc, resumeResultOffset);
2130 Jump(&dispatch);
2131 }
2132 Bind(¬AsyncGeneratorObj);
2133 {
2134 GateRef resumeResultOffset = IntPtr(JSGeneratorObject::GENERATOR_RESUME_RESULT_OFFSET);
2135 varAcc = Load(VariableType::JS_ANY(), glue, acc, resumeResultOffset);
2136 Jump(&dispatch);
2137 }
2138 Bind(&dispatch);
2139 Return(*varAcc);
2140 }
2141
GenerateCircuit()2142 void BaselineGetresumemodStubBuilder::GenerateCircuit()
2143 {
2144 GateRef glue = PtrArgument(PARAM_INDEX(BaselineGetresumemod, GLUE));
2145 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineGetresumemod, ACC));
2146 auto env = GetEnvironment();
2147 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
2148
2149 Label isAsyncGeneratorObj(env);
2150 Label notAsyncGeneratorObj(env);
2151 Label dispatch(env);
2152 Branch(TaggedIsAsyncGeneratorObject(glue, acc), &isAsyncGeneratorObj, ¬AsyncGeneratorObj);
2153 Bind(&isAsyncGeneratorObj);
2154 {
2155 varAcc = IntToTaggedPtr(GetResumeModeFromAsyncGeneratorObject(acc));
2156 Jump(&dispatch);
2157 }
2158 Bind(¬AsyncGeneratorObj);
2159 {
2160 varAcc = IntToTaggedPtr(GetResumeModeFromGeneratorObject(acc));
2161 Jump(&dispatch);
2162 }
2163 Bind(&dispatch);
2164 Return(*varAcc);
2165 }
2166
GenerateCircuit()2167 void BaselineGettemplateobjectImm8StubBuilder::GenerateCircuit()
2168 {
2169 GateRef glue = PtrArgument(PARAM_INDEX(BaselineGettemplateobjectImm8, GLUE));
2170 GateRef sp = PtrArgument(PARAM_INDEX(BaselineGettemplateobjectImm8, SP));
2171 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineGettemplateobjectImm8, ACC));
2172
2173 GateRef result = CallRuntime(glue, RTSTUB_ID(GetTemplateObject), { acc });
2174 CHECK_EXCEPTION_WITH_ACC(result);
2175 }
2176
GenerateCircuit()2177 void BaselineGettemplateobjectImm16StubBuilder::GenerateCircuit()
2178 {
2179 GateRef glue = PtrArgument(PARAM_INDEX(BaselineGettemplateobjectImm16, GLUE));
2180 GateRef sp = PtrArgument(PARAM_INDEX(BaselineGettemplateobjectImm16, SP));
2181 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineGettemplateobjectImm16, ACC));
2182
2183 GateRef literal = acc;
2184 GateRef result = CallRuntime(glue, RTSTUB_ID(GetTemplateObject), { literal });
2185 CHECK_EXCEPTION_WITH_ACC(result);
2186 }
2187
GenerateCircuit()2188 void BaselineGetnextpropnameV8StubBuilder::GenerateCircuit()
2189 {
2190 GateRef glue = PtrArgument(PARAM_INDEX(BaselineGetnextpropnameV8, GLUE));
2191 GateRef sp = PtrArgument(PARAM_INDEX(BaselineGetnextpropnameV8, SP));
2192 GateRef iter = TaggedArgument(PARAM_INDEX(BaselineGetnextpropnameV8, ITER));
2193
2194 GateRef frame = GetFrame(sp);
2195 GateRef acc = GetAccFromFrame(glue, frame);
2196 GateRef result = NextInternal(glue, iter);
2197 CHECK_EXCEPTION_WITH_ACC(result);
2198 }
2199
GenerateCircuit()2200 void BaselineSetobjectwithprotoImm8V8StubBuilder::GenerateCircuit()
2201 {
2202 GateRef glue = PtrArgument(PARAM_INDEX(BaselineSetobjectwithprotoImm8V8, GLUE));
2203 GateRef sp = PtrArgument(PARAM_INDEX(BaselineSetobjectwithprotoImm8V8, SP));
2204 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineSetobjectwithprotoImm8V8, ACC));
2205 GateRef proto = TaggedArgument(PARAM_INDEX(BaselineSetobjectwithprotoImm8V8, PROTO));
2206
2207 auto env = GetEnvironment();
2208
2209 GateRef result = CallRuntime(glue, RTSTUB_ID(SetObjectWithProto), { proto, acc });
2210 Label notException(env);
2211 CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception);
2212 Bind(¬Exception);
2213 Return();
2214 }
2215
GenerateCircuit()2216 void BaselineDelobjpropV8StubBuilder::GenerateCircuit()
2217 {
2218 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDelobjpropV8, GLUE));
2219 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDelobjpropV8, SP));
2220 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDelobjpropV8, ACC));
2221 GateRef obj = TaggedArgument(PARAM_INDEX(BaselineDelobjpropV8, OBJ));
2222
2223 SetCurrentGlobalEnv(GetGlobalEnv(glue));
2224 GateRef result = DeletePropertyOrThrow(glue, obj, acc);
2225 CHECK_EXCEPTION_WITH_ACC(result);
2226 }
2227
GenerateCircuit()2228 void BaselineAsyncfunctionawaituncaughtV8StubBuilder::GenerateCircuit()
2229 {
2230 GateRef glue = PtrArgument(PARAM_INDEX(BaselineAsyncfunctionawaituncaughtV8, GLUE));
2231 GateRef sp = PtrArgument(PARAM_INDEX(BaselineAsyncfunctionawaituncaughtV8, SP));
2232 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineAsyncfunctionawaituncaughtV8, ACC));
2233 GateRef asyncFuncObj = TaggedArgument(PARAM_INDEX(BaselineAsyncfunctionawaituncaughtV8, ASYNC_FUNC_OBJ));
2234
2235 GateRef result = CallRuntime(glue, RTSTUB_ID(AsyncFunctionAwaitUncaught), { asyncFuncObj, acc });
2236 CHECK_EXCEPTION_WITH_ACC(result);
2237 }
2238
GenerateCircuit()2239 void BaselineCopydatapropertiesV8StubBuilder::GenerateCircuit()
2240 {
2241 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCopydatapropertiesV8, GLUE));
2242 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCopydatapropertiesV8, SP));
2243 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineCopydatapropertiesV8, ACC));
2244 GateRef dst = TaggedArgument(PARAM_INDEX(BaselineCopydatapropertiesV8, DST));
2245
2246 GateRef result = CallRuntime(glue, RTSTUB_ID(CopyDataProperties), { dst, acc });
2247 CHECK_EXCEPTION_WITH_ACC(result);
2248 }
2249
GenerateCircuit()2250 void BaselineStarrayspreadV8V8StubBuilder::GenerateCircuit()
2251 {
2252 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStarrayspreadV8V8, GLUE));
2253 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStarrayspreadV8V8, SP));
2254 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineStarrayspreadV8V8, ACC));
2255 GateRef dst = TaggedArgument(PARAM_INDEX(BaselineStarrayspreadV8V8, DST));
2256 GateRef index = TaggedArgument(PARAM_INDEX(BaselineStarrayspreadV8V8, INDEX));
2257
2258 GateRef result = CallRuntime(glue, RTSTUB_ID(StArraySpread), { dst, index, acc }); // acc is res
2259 CHECK_EXCEPTION_WITH_ACC(result);
2260 }
2261
GenerateCircuit()2262 void BaselineSetobjectwithprotoImm16V8StubBuilder::GenerateCircuit()
2263 {
2264 GateRef glue = PtrArgument(PARAM_INDEX(BaselineSetobjectwithprotoImm16V8, GLUE));
2265 GateRef sp = PtrArgument(PARAM_INDEX(BaselineSetobjectwithprotoImm16V8, SP));
2266 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineSetobjectwithprotoImm16V8, ACC));
2267 GateRef proto = TaggedArgument(PARAM_INDEX(BaselineSetobjectwithprotoImm16V8, PROTO));
2268
2269 auto env = GetEnvironment();
2270
2271 GateRef result = CallRuntime(glue, RTSTUB_ID(SetObjectWithProto), { proto, acc });
2272 Label notException(env);
2273 CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception);
2274 Bind(¬Exception);
2275 Return();
2276 }
2277
GenerateCircuit()2278 void BaselineLdobjbyvalueImm8V8StubBuilder::GenerateCircuit()
2279 {
2280 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdobjbyvalueImm8V8, GLUE));
2281 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdobjbyvalueImm8V8, SP));
2282 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineLdobjbyvalueImm8V8, RECEIVER));
2283 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdobjbyvalueImm8V8, SLOTID));
2284 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2285
2286 GateRef acc = GetAccFromFrame(glue, frame);
2287 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2288 GateRef result = builder.LoadObjByValue(glue, receiver, acc, profileTypeInfo, slotId, callback);
2289 CHECK_EXCEPTION_RETURN(result);
2290 }
2291
GenerateCircuit()2292 void BaselineLdobjbyvalueImm16V8StubBuilder::GenerateCircuit()
2293 {
2294 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdobjbyvalueImm16V8, GLUE));
2295 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdobjbyvalueImm16V8, SP));
2296 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineLdobjbyvalueImm16V8, RECEIVER));
2297 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdobjbyvalueImm16V8, SLOTID));
2298 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2299
2300 GateRef acc = GetAccFromFrame(glue, frame);
2301 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2302 GateRef result = builder.LoadObjByValue(glue, receiver, acc, profileTypeInfo, slotId, callback);
2303 CHECK_EXCEPTION_RETURN(result);
2304 }
2305
GenerateCircuit()2306 void BaselineStobjbyvalueImm8V8V8StubBuilder::GenerateCircuit()
2307 {
2308 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStobjbyvalueImm8V8V8, GLUE));
2309 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStobjbyvalueImm8V8V8, SP));
2310 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStobjbyvalueImm8V8V8, RECEIVER));
2311 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStobjbyvalueImm8V8V8, SLOTID));
2312 GateRef propKey = TaggedArgument(PARAM_INDEX(BaselineStobjbyvalueImm8V8V8, PROP_KEY));
2313 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2314
2315 GateRef acc = GetAccFromFrame(glue, frame);
2316 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2317 GateRef result = builder.StoreObjByValue(glue, receiver, propKey, acc, profileTypeInfo, slotId, callback);
2318 CHECK_EXCEPTION(result);
2319 }
2320
GenerateCircuit()2321 void BaselineStobjbyvalueImm16V8V8StubBuilder::GenerateCircuit()
2322 {
2323 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStobjbyvalueImm16V8V8, GLUE));
2324 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStobjbyvalueImm16V8V8, SP));
2325 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStobjbyvalueImm16V8V8, RECEIVER));
2326 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStobjbyvalueImm16V8V8, SLOTID));
2327 GateRef propKey = TaggedArgument(PARAM_INDEX(BaselineStobjbyvalueImm16V8V8, PROP_KEY));
2328 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2329
2330 GateRef acc = GetAccFromFrame(glue, frame);
2331 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2332 GateRef result = builder.StoreObjByValue(glue, receiver, propKey, acc, profileTypeInfo, slotId, callback);
2333 CHECK_EXCEPTION(result);
2334 }
2335
GenerateCircuit()2336 void BaselineStownbyvalueImm8V8V8StubBuilder::GenerateCircuit()
2337 {
2338 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStownbyvalueImm8V8V8, GLUE));
2339 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStownbyvalueImm8V8V8, SP));
2340 GateRef receiverId = Int32Argument(PARAM_INDEX(BaselineStownbyvalueImm8V8V8, RECEIVER_ID));
2341 GateRef propKeyId = Int32Argument(PARAM_INDEX(BaselineStownbyvalueImm8V8V8, PROP_KEY_ID));
2342 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStownbyvalueImm8V8V8, SLOT_ID));
2343 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2344
2345 GateRef receiver = GetVregValue(glue, sp, ZExtInt32ToPtr(receiverId));
2346 GateRef propKey = GetVregValue(glue, sp, ZExtInt32ToPtr(propKeyId));
2347 GateRef acc = GetAccFromFrame(glue, frame);
2348
2349 auto env = GetEnvironment();
2350 Label isHeapObject(env);
2351 Label slowPath(env);
2352 Branch(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath);
2353 Bind(&isHeapObject);
2354 Label notClassConstructor(env);
2355 Branch(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
2356 Bind(¬ClassConstructor);
2357 Label notClassPrototype(env);
2358 Branch(IsClassPrototype(glue, receiver), &slowPath, ¬ClassPrototype);
2359 Bind(¬ClassPrototype);
2360 {
2361 // fast path
2362 SetCurrentGlobalEnv(GetGlobalEnv(glue));
2363 GateRef result = SetPropertyByValue(glue, receiver, propKey, acc, true, callback); // acc is value
2364 Label notHole(env);
2365 Branch(TaggedIsHole(result), &slowPath, ¬Hole);
2366 Bind(¬Hole);
2367 CHECK_EXCEPTION(result);
2368 }
2369 Bind(&slowPath);
2370 {
2371 GateRef result = CallRuntime(glue, RTSTUB_ID(StOwnByValue), { receiver, propKey, acc });
2372 CHECK_EXCEPTION(result);
2373 }
2374 }
2375
GenerateCircuit()2376 void BaselineStownbyvalueImm16V8V8StubBuilder::GenerateCircuit()
2377 {
2378 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStownbyvalueImm16V8V8, GLUE));
2379 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStownbyvalueImm16V8V8, SP));
2380 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStownbyvalueImm16V8V8, RECEIVER));
2381 GateRef propKey = TaggedArgument(PARAM_INDEX(BaselineStownbyvalueImm16V8V8, PROP_KEY));
2382 GateRef slotId = TaggedArgument(PARAM_INDEX(BaselineStownbyvalueImm16V8V8, SLOT_ID));
2383 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2384
2385 GateRef acc = GetAccFromFrame(glue, frame);
2386 auto env = GetEnvironment();
2387 Label isHeapObject(env);
2388 Label slowPath(env);
2389 Branch(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath);
2390 Bind(&isHeapObject);
2391 Label notClassConstructor(env);
2392 Branch(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
2393 Bind(¬ClassConstructor);
2394 Label notClassPrototype(env);
2395 Branch(IsClassPrototype(glue, receiver), &slowPath, ¬ClassPrototype);
2396 Bind(¬ClassPrototype);
2397 {
2398 // fast path
2399 SetCurrentGlobalEnv(GetGlobalEnv(glue));
2400 GateRef result = SetPropertyByValue(glue, receiver, propKey, acc, true, callback); // acc is value
2401 Label notHole(env);
2402 Branch(TaggedIsHole(result), &slowPath, ¬Hole);
2403 Bind(¬Hole);
2404 CHECK_EXCEPTION(result);
2405 }
2406 Bind(&slowPath);
2407 {
2408 GateRef result = CallRuntime(glue, RTSTUB_ID(StOwnByValue), { receiver, propKey, acc });
2409 CHECK_EXCEPTION(result);
2410 }
2411 }
2412
GenerateCircuit()2413 void BaselineLdsuperbyvalueImm8V8StubBuilder::GenerateCircuit()
2414 {
2415 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdsuperbyvalueImm8V8, GLUE));
2416 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdsuperbyvalueImm8V8, SP));
2417 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineLdsuperbyvalueImm8V8, ACC));
2418 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineLdsuperbyvalueImm8V8, RECEIVER));
2419
2420 GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { receiver, acc }); // sp for thisFunc
2421 CHECK_EXCEPTION_WITH_ACC(result);
2422 }
2423
GenerateCircuit()2424 void BaselineLdsuperbyvalueImm16V8StubBuilder::GenerateCircuit()
2425 {
2426 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdsuperbyvalueImm16V8, GLUE));
2427 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdsuperbyvalueImm16V8, SP));
2428 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineLdsuperbyvalueImm16V8, ACC));
2429 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineLdsuperbyvalueImm16V8, RECEIVER));
2430
2431 GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { receiver, acc }); // sp for thisFunc
2432 CHECK_EXCEPTION_WITH_ACC(result);
2433 }
2434
GenerateCircuit()2435 void BaselineStsuperbyvalueImm8V8V8StubBuilder::GenerateCircuit()
2436 {
2437 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStsuperbyvalueImm8V8V8, GLUE));
2438 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStsuperbyvalueImm8V8V8, SP));
2439 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStsuperbyvalueImm8V8V8, RECEIVER));
2440 GateRef propKey = TaggedArgument(PARAM_INDEX(BaselineStsuperbyvalueImm8V8V8, PROP_KEY));
2441 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
2442 ProfileOperation callback;
2443
2444 // acc is value, sp for thisFunc
2445 GateRef result = CallRuntime(glue, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc });
2446 CHECK_EXCEPTION(result);
2447 }
2448
GenerateCircuit()2449 void BaselineStsuperbyvalueImm16V8V8StubBuilder::GenerateCircuit()
2450 {
2451 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStsuperbyvalueImm16V8V8, GLUE));
2452 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStsuperbyvalueImm16V8V8, SP));
2453 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStsuperbyvalueImm16V8V8, RECEIVER));
2454 GateRef propKey = TaggedArgument(PARAM_INDEX(BaselineStsuperbyvalueImm16V8V8, PROP_KEY));
2455 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
2456 ProfileOperation callback;
2457
2458 // acc is value, sp for thisFunc
2459 GateRef result = CallRuntime(glue, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc });
2460 CHECK_EXCEPTION(result);
2461 }
2462
GenerateCircuit()2463 void BaselineLdobjbyindexImm8Imm16StubBuilder::GenerateCircuit()
2464 {
2465 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdobjbyindexImm8Imm16, GLUE));
2466 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdobjbyindexImm8Imm16, SP));
2467 GateRef index = Int32Argument(PARAM_INDEX(BaselineLdobjbyindexImm8Imm16, INDEX));
2468 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdobjbyindexImm8Imm16, SLOT_ID));
2469 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2470
2471 auto env = GetEnvironment();
2472 GateRef acc = GetAccFromFrame(glue, frame);
2473 Label fastPath(env);
2474 Label slowPath(env);
2475 Branch(TaggedIsHeapObject(acc), &fastPath, &slowPath);
2476 Bind(&fastPath);
2477 {
2478 SetCurrentGlobalEnv(GetGlobalEnv(glue));
2479 GateRef result = GetPropertyByIndex(glue, acc, index, callback);
2480 Label notHole(env);
2481 Branch(TaggedIsHole(result), &slowPath, ¬Hole);
2482 Bind(¬Hole);
2483 CHECK_EXCEPTION_WITH_ACC(result);
2484 }
2485 Bind(&slowPath);
2486 {
2487 GateRef result = CallRuntime(glue, RTSTUB_ID(LdObjByIndex),
2488 { acc, IntToTaggedInt(index), TaggedFalse(), Undefined() });
2489 CHECK_EXCEPTION_WITH_ACC(result);
2490 }
2491 }
2492
GenerateCircuit()2493 void BaselineLdobjbyindexImm16Imm16StubBuilder::GenerateCircuit()
2494 {
2495 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdobjbyindexImm16Imm16, GLUE));
2496 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdobjbyindexImm16Imm16, SP));
2497 GateRef index = Int32Argument(PARAM_INDEX(BaselineLdobjbyindexImm16Imm16, INDEX));
2498 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdobjbyindexImm16Imm16, SLOT_ID));
2499 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2500
2501 auto env = GetEnvironment();
2502 GateRef acc = GetAccFromFrame(glue, frame);
2503 Label fastPath(env);
2504 Label slowPath(env);
2505 Branch(TaggedIsHeapObject(acc), &fastPath, &slowPath);
2506 Bind(&fastPath);
2507 {
2508 SetCurrentGlobalEnv(GetGlobalEnv(glue));
2509 GateRef result = GetPropertyByIndex(glue, acc, index, callback);
2510 Label notHole(env);
2511 Branch(TaggedIsHole(result), &slowPath, ¬Hole);
2512 Bind(¬Hole);
2513 CHECK_EXCEPTION_WITH_ACC(result);
2514 }
2515 Bind(&slowPath);
2516 {
2517 GateRef result = CallRuntime(glue, RTSTUB_ID(LdObjByIndex),
2518 { acc, IntToTaggedInt(index), TaggedFalse(), Undefined() });
2519 CHECK_EXCEPTION_WITH_ACC(result);
2520 }
2521 }
2522
GenerateCircuit()2523 void BaselineStobjbyindexImm8V8Imm16StubBuilder::GenerateCircuit()
2524 {
2525 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStobjbyindexImm8V8Imm16, GLUE));
2526 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStobjbyindexImm8V8Imm16, SP));
2527 GateRef receiver = Int32Argument(PARAM_INDEX(BaselineStobjbyindexImm8V8Imm16, RECEIVER));
2528 GateRef index = Int32Argument(PARAM_INDEX(BaselineStobjbyindexImm8V8Imm16, INDEX));
2529 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
2530
2531 auto env = GetEnvironment();
2532 Label fastPath(env);
2533 Label slowPath(env);
2534 Branch(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
2535 Bind(&fastPath);
2536 {
2537 SetCurrentGlobalEnv(GetGlobalEnv(glue));
2538 GateRef result = SetPropertyByIndex(glue, receiver, index, acc, false);
2539 Label notHole(env);
2540 Branch(TaggedIsHole(result), &slowPath, ¬Hole);
2541 Bind(¬Hole);
2542 CHECK_EXCEPTION(result);
2543 }
2544 Bind(&slowPath);
2545 {
2546 GateRef result = CallRuntime(glue, RTSTUB_ID(StObjByIndex),
2547 { receiver, IntToTaggedInt(index), acc });
2548 CHECK_EXCEPTION(result);
2549 }
2550 }
2551
GenerateCircuit()2552 void BaselineStobjbyindexImm16V8Imm16StubBuilder::GenerateCircuit()
2553 {
2554 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStobjbyindexImm16V8Imm16, GLUE));
2555 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStobjbyindexImm16V8Imm16, SP));
2556 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStobjbyindexImm16V8Imm16, RECEIVER));
2557 GateRef index = Int32Argument(PARAM_INDEX(BaselineStobjbyindexImm16V8Imm16, INDEX));
2558 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStobjbyindexImm16V8Imm16, SLOT_ID));
2559 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2560 GateRef acc = GetAccFromFrame(glue, frame);
2561 auto env = GetEnvironment();
2562 Label fastPath(env);
2563 Label slowPath(env);
2564 Branch(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
2565 Bind(&fastPath);
2566 {
2567 SetCurrentGlobalEnv(GetGlobalEnv(glue));
2568 GateRef result = SetPropertyByIndex(glue, receiver, index, acc, false);
2569 Label notHole(env);
2570 Branch(TaggedIsHole(result), &slowPath, ¬Hole);
2571 Bind(¬Hole);
2572 CHECK_EXCEPTION(result);
2573 }
2574 Bind(&slowPath);
2575 {
2576 GateRef result = CallRuntime(glue, RTSTUB_ID(StObjByIndex),
2577 { receiver, IntToTaggedInt(index), acc });
2578 CHECK_EXCEPTION(result);
2579 }
2580 }
2581
GenerateCircuit()2582 void BaselineStownbyindexImm8V8Imm16StubBuilder::GenerateCircuit()
2583 {
2584 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStownbyindexImm8V8Imm16, GLUE));
2585 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStownbyindexImm8V8Imm16, SP));
2586 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStownbyindexImm8V8Imm16, RECEIVER));
2587 GateRef index = Int32Argument(PARAM_INDEX(BaselineStownbyindexImm8V8Imm16, INDEX));
2588 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStownbyindexImm8V8Imm16, SLOTID));
2589 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2590 GateRef acc = GetAccFromFrame(glue, frame);
2591
2592 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2593 GateRef result = builder.StoreOwnByIndex(
2594 glue, receiver, index, acc, profileTypeInfo, slotId, callback);
2595 CHECK_EXCEPTION(result);
2596 }
2597
GenerateCircuit()2598 void BaselineStownbyindexImm16V8Imm16StubBuilder::GenerateCircuit()
2599 {
2600 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStownbyindexImm16V8Imm16, GLUE));
2601 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStownbyindexImm16V8Imm16, SP));
2602 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStownbyindexImm16V8Imm16, RECEIVER));
2603 GateRef index = Int32Argument(PARAM_INDEX(BaselineStownbyindexImm16V8Imm16, INDEX));
2604 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStownbyindexImm16V8Imm16, SLOTID));
2605 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2606
2607 GateRef acc = GetAccFromFrame(glue, frame);
2608 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2609 GateRef result = builder.StoreOwnByIndex(glue, receiver, index, acc, profileTypeInfo, slotId, callback);
2610 CHECK_EXCEPTION(result);
2611 }
2612
GenerateCircuit()2613 void BaselineAsyncfunctionresolveV8StubBuilder::GenerateCircuit()
2614 {
2615 GateRef glue = PtrArgument(PARAM_INDEX(BaselineAsyncfunctionresolveV8, GLUE));
2616 GateRef sp = PtrArgument(PARAM_INDEX(BaselineAsyncfunctionresolveV8, SP));
2617 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineAsyncfunctionresolveV8, ACC));
2618 GateRef asyncFuncObj = TaggedArgument(PARAM_INDEX(BaselineAsyncfunctionresolveV8, ASYNC_FUNC_OBJ));
2619
2620 GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncFunctionResolveOrReject),
2621 { asyncFuncObj, acc, TaggedTrue() });
2622 CHECK_EXCEPTION_WITH_ACC(res);
2623 }
2624
GenerateCircuit()2625 void BaselineAsyncfunctionrejectV8StubBuilder::GenerateCircuit()
2626 {
2627 GateRef glue = PtrArgument(PARAM_INDEX(BaselineAsyncfunctionrejectV8, GLUE));
2628 GateRef sp = PtrArgument(PARAM_INDEX(BaselineAsyncfunctionrejectV8, SP));
2629 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineAsyncfunctionrejectV8, ACC));
2630 GateRef asyncFuncObj = TaggedArgument(PARAM_INDEX(BaselineAsyncfunctionrejectV8, ASYNC_FUNC_OBJ));
2631
2632 GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncFunctionResolveOrReject),
2633 { asyncFuncObj, acc, TaggedFalse() });
2634 CHECK_EXCEPTION_WITH_ACC(res);
2635 }
2636
GenerateCircuit()2637 void BaselineCopyrestargsImm8StubBuilder::GenerateCircuit()
2638 {
2639 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCopyrestargsImm8, GLUE));
2640 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCopyrestargsImm8, SP));
2641 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineCopyrestargsImm8, ACC));
2642 GateRef restIdx = Int32Argument(PARAM_INDEX(BaselineCopyrestargsImm8, REST_IDX));
2643
2644 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
2645 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
2646 auto env = GetEnvironment();
2647 GateRef startIdxAndNumArgs = GetStartIdxAndNumArgs(glue, sp, restIdx);
2648 GateRef startIdx = TruncInt64ToInt32(Int64LSR(startIdxAndNumArgs, Int64(32)));
2649 GateRef numArgs = TruncInt64ToInt32(startIdxAndNumArgs);
2650 Label dispatch(env);
2651 Label slowPath(env);
2652 GateRef globalEnv = GetGlobalEnv(glue);
2653 auto arrayFunc = GetGlobalEnvValue(VariableType::JS_ANY(), glue, globalEnv, GlobalEnv::ARRAY_FUNCTION_INDEX);
2654 GateRef intialHClass = Load(VariableType::JS_ANY(), glue, arrayFunc, IntPtr(JSFunction::PROTO_OR_DYNCLASS_OFFSET));
2655 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
2656 newBuilder.SetParameters(glue, 0);
2657 res = newBuilder.NewJSArrayWithSize(intialHClass, numArgs);
2658 GateRef lengthOffset = IntPtr(JSArray::LENGTH_OFFSET);
2659 Store(VariableType::INT32(), glue, *res, lengthOffset, TruncInt64ToInt32(numArgs));
2660 GateRef accessor = GetGlobalConstantValue(VariableType::JS_ANY(), glue, ConstantIndex::ARRAY_LENGTH_ACCESSOR);
2661 SetPropertyInlinedProps(glue, *res, intialHClass, accessor, Int32(JSArray::LENGTH_INLINE_PROPERTY_INDEX));
2662 SetExtensibleToBitfield(glue, *res, true);
2663 Label setArgumentsBegin(env);
2664 Label setArgumentsAgain(env);
2665 Label setArgumentsEnd(env);
2666 GateRef elements = GetElementsArray(glue, *res);
2667 Branch(Int32UnsignedLessThan(*i, numArgs), &setArgumentsBegin, &setArgumentsEnd);
2668 LoopBegin(&setArgumentsBegin);
2669 {
2670 GateRef idx = ZExtInt32ToPtr(Int32Add(startIdx, *i));
2671 GateRef receiver = Load(VariableType::JS_ANY(), glue, sp, PtrMul(IntPtr(sizeof(JSTaggedType)), idx));
2672 SetValueToTaggedArray(VariableType::JS_ANY(), glue, elements, *i, receiver);
2673 i = Int32Add(*i, Int32(1));
2674 Branch(Int32UnsignedLessThan(*i, numArgs), &setArgumentsAgain, &setArgumentsEnd);
2675 Bind(&setArgumentsAgain);
2676 }
2677 LoopEnd(&setArgumentsBegin);
2678 Bind(&setArgumentsEnd);
2679 Branch(HasPendingException(glue), &slowPath, &dispatch);
2680 Bind(&dispatch);
2681 {
2682 Return(*res);
2683 }
2684
2685 Bind(&slowPath);
2686 {
2687 GateRef result2 = CallRuntime(glue, RTSTUB_ID(CopyRestArgs), { IntToTaggedInt(restIdx) });
2688 CHECK_EXCEPTION_WITH_ACC(result2);
2689 }
2690 }
2691
GenerateCircuit()2692 void BaselineLdlexvarImm4Imm4StubBuilder::GenerateCircuit()
2693 {
2694 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdlexvarImm4Imm4, GLUE));
2695 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdlexvarImm4Imm4, SP));
2696 GateRef level = Int32Argument(PARAM_INDEX(BaselineLdlexvarImm4Imm4, LEVEL));
2697 GateRef slot = Int32Argument(PARAM_INDEX(BaselineLdlexvarImm4Imm4, SLOT));
2698
2699 auto env = GetEnvironment();
2700 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, GetFrame(sp)));
2701 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
2702
2703 Label loopHead(env);
2704 Label loopEnd(env);
2705 Label afterLoop(env);
2706 Branch(Int32LessThan(*i, level), &loopHead, &afterLoop);
2707 LoopBegin(&loopHead);
2708 currentEnv = GetParentEnv(glue, *currentEnv);
2709 i = Int32Add(*i, Int32(1));
2710 Branch(Int32LessThan(*i, level), &loopEnd, &afterLoop);
2711 Bind(&loopEnd);
2712 LoopEnd(&loopHead);
2713 Bind(&afterLoop);
2714 GateRef variable = GetPropertiesFromLexicalEnv(glue, *currentEnv, slot);
2715 Return(variable);
2716 }
2717
GenerateCircuit()2718 void BaselineStlexvarImm4Imm4StubBuilder::GenerateCircuit()
2719 {
2720 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStlexvarImm4Imm4, GLUE));
2721 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStlexvarImm4Imm4, SP));
2722 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineStlexvarImm4Imm4, ACC));
2723 GateRef level = Int32Argument(PARAM_INDEX(BaselineStlexvarImm4Imm4, LEVEL));
2724 GateRef slot = Int32Argument(PARAM_INDEX(BaselineStlexvarImm4Imm4, SLOT));
2725
2726 auto env = GetEnvironment();
2727 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, GetFrame(sp)));
2728 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
2729
2730 Label loopHead(env);
2731 Label loopEnd(env);
2732 Label afterLoop(env);
2733 Branch(Int32LessThan(*i, level), &loopHead, &afterLoop);
2734 LoopBegin(&loopHead);
2735 currentEnv = GetParentEnv(glue, *currentEnv);
2736 i = Int32Add(*i, Int32(1));
2737 Branch(Int32LessThan(*i, level), &loopEnd, &afterLoop);
2738 Bind(&loopEnd);
2739 LoopEnd(&loopHead);
2740 Bind(&afterLoop);
2741 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, acc);
2742 Return();
2743 }
2744
GenerateCircuit()2745 void BaselineGetmodulenamespaceImm8StubBuilder::GenerateCircuit()
2746 {
2747 GateRef glue = PtrArgument(PARAM_INDEX(BaselineGetmodulenamespaceImm8, GLUE));
2748 GateRef index = Int32Argument(PARAM_INDEX(BaselineGetmodulenamespaceImm8, INDEX));
2749
2750 GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(GetModuleNamespaceByIndex), { IntToTaggedInt(index) });
2751 Return(moduleRef);
2752 }
2753
GenerateCircuit()2754 void BaselineStmodulevarImm8StubBuilder::GenerateCircuit()
2755 {
2756 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStmodulevarImm8, GLUE));
2757 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineStmodulevarImm8, ACC));
2758 GateRef index = Int32Argument(PARAM_INDEX(BaselineStmodulevarImm8, INDEX));
2759
2760 CallRuntime(glue, RTSTUB_ID(StModuleVarByIndex), { IntToTaggedInt(index), acc });
2761 Return();
2762 }
2763
GenerateCircuit()2764 void BaselineTryldglobalbynameImm16Id16StubBuilder::GenerateCircuit()
2765 {
2766 GateRef glue = PtrArgument(PARAM_INDEX(BaselineTryldglobalbynameImm16Id16, GLUE));
2767 GateRef sp = PtrArgument(PARAM_INDEX(BaselineTryldglobalbynameImm16Id16, SP));
2768 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineTryldglobalbynameImm16Id16, SLOTID));
2769 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineTryldglobalbynameImm16Id16, STRING_ID));
2770 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2771
2772 GateRef acc = GetAccFromFrame(glue, frame);
2773 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
2774 GateRef method = GetMethodFromFunction(glue, curFunc);
2775 GateRef constpool = GetConstpoolFromMethod(glue, method);
2776 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2777 StringIdInfo info(constpool, stringId);
2778 GateRef result = builder.TryLoadGlobalByName(glue, 0, info, profileTypeInfo, slotId, callback);
2779 CHECK_EXCEPTION_WITH_VARACC(result);
2780 }
2781
GenerateCircuit()2782 void BaselineTrystglobalbynameImm8Id16StubBuilder::GenerateCircuit()
2783 {
2784 GateRef glue = PtrArgument(PARAM_INDEX(BaselineTrystglobalbynameImm8Id16, GLUE));
2785 GateRef sp = PtrArgument(PARAM_INDEX(BaselineTrystglobalbynameImm8Id16, SP));
2786 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineTrystglobalbynameImm8Id16, STRING_ID));
2787 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineTrystglobalbynameImm8Id16, SLOTID));
2788 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2789
2790 GateRef method = GetMethodFromFunction(glue, curFunc);
2791 GateRef constpool = GetConstpoolFromMethod(glue, method);
2792 GateRef acc = GetAccFromFrame(glue, frame);
2793 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2794 StringIdInfo info(constpool, stringId);
2795 GateRef result = builder.TryStoreGlobalByName(glue, 0, info, acc, profileTypeInfo, slotId, callback);
2796 CHECK_EXCEPTION(result);
2797 }
2798
GenerateCircuit()2799 void BaselineTrystglobalbynameImm16Id16StubBuilder::GenerateCircuit()
2800 {
2801 GateRef glue = PtrArgument(PARAM_INDEX(BaselineTrystglobalbynameImm16Id16, GLUE));
2802 GateRef sp = PtrArgument(PARAM_INDEX(BaselineTrystglobalbynameImm16Id16, SP));
2803 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineTrystglobalbynameImm16Id16, SLOTID));
2804 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineTrystglobalbynameImm16Id16, STRING_ID));
2805 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2806
2807 GateRef method = GetMethodFromFunction(glue, curFunc);
2808 GateRef constpool = GetConstpoolFromMethod(glue, method);
2809 GateRef acc = GetAccFromFrame(glue, frame);
2810 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2811 StringIdInfo info(constpool, stringId);
2812 GateRef result = builder.TryStoreGlobalByName(glue, 0, info, acc, profileTypeInfo, slotId, callback);
2813 CHECK_EXCEPTION(result);
2814 }
2815
GenerateCircuit()2816 void BaselineLdglobalvarImm16Id16StubBuilder::GenerateCircuit()
2817 {
2818 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdglobalvarImm16Id16, GLUE));
2819 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdglobalvarImm16Id16, SP));
2820 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdglobalvarImm16Id16, SLOTID));
2821 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineLdglobalvarImm16Id16, STRING_ID));
2822 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2823
2824 GateRef acc = GetAccFromFrame(glue, frame);
2825 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
2826 GateRef method = GetMethodFromFunction(glue, curFunc);
2827 GateRef constpool = GetConstpoolFromMethod(glue, method);
2828 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2829 StringIdInfo info(constpool, stringId);
2830 GateRef result = builder.LoadGlobalVar(glue, 0, info, profileTypeInfo, slotId, callback);
2831 CHECK_EXCEPTION_WITH_VARACC(result);
2832 }
2833
GenerateCircuit()2834 void BaselineStglobalvarImm16Id16StubBuilder::GenerateCircuit()
2835 {
2836 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStglobalvarImm16Id16, GLUE));
2837 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStglobalvarImm16Id16, SP));
2838 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineStglobalvarImm16Id16, ACC));
2839 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStglobalvarImm16Id16, SLOTID));
2840 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStglobalvarImm16Id16, STRING_ID));
2841 GateRef profileTypeInfo = GetProfileTypeInfoFromFunction(glue, GetFunctionFromFrame(glue, GetFrame(sp)));
2842 ProfileOperation callback;
2843
2844 GateRef frame = GetFrame(sp);
2845 GateRef func = GetFunctionFromFrame(glue, frame);
2846 GateRef method = GetMethodFromFunction(glue, func);
2847 GateRef constpool = GetConstpoolFromMethod(glue, method);
2848 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2849 StringIdInfo info(constpool, stringId);
2850 GateRef result = builder.StoreGlobalVar(glue, 0, info, acc, profileTypeInfo, slotId);
2851 CHECK_EXCEPTION(result);
2852 }
2853
GenerateCircuit()2854 void BaselineLdobjbynameImm8Id16StubBuilder::GenerateCircuit()
2855 {
2856 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdobjbynameImm8Id16, GLUE));
2857 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdobjbynameImm8Id16, SP));
2858 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdobjbynameImm8Id16, SLOTID));
2859 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineLdobjbynameImm8Id16, STRING_ID));
2860 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2861
2862 GateRef method = GetMethodFromFunction(glue, curFunc);
2863 GateRef constpool = GetConstpoolFromMethod(glue, method);
2864 GateRef receiver = GetAccFromFrame(glue, frame);
2865 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2866 StringIdInfo stringIdInfo(constpool, stringId);
2867 GateRef result = builder.LoadObjByName(glue, receiver, 0, stringIdInfo, profileTypeInfo, slotId, callback);
2868 CHECK_EXCEPTION_RETURN(result);
2869 }
2870
GenerateCircuit()2871 void BaselineLdobjbynameImm16Id16StubBuilder::GenerateCircuit()
2872 {
2873 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdobjbynameImm16Id16, GLUE));
2874 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdobjbynameImm16Id16, SP));
2875 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineLdobjbynameImm16Id16, SLOTID));
2876 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineLdobjbynameImm16Id16, STRING_ID));
2877 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2878
2879 GateRef method = GetMethodFromFunction(glue, curFunc);
2880 GateRef constpool = GetConstpoolFromMethod(glue, method);
2881 GateRef acc = GetAccFromFrame(glue, frame);
2882 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2883 StringIdInfo stringIdInfo(constpool, stringId);
2884 GateRef result = builder.LoadObjByName(glue, acc, 0, stringIdInfo, profileTypeInfo,
2885 slotId, callback);
2886 CHECK_EXCEPTION_RETURN(result);
2887 }
2888
GenerateCircuit()2889 void BaselineStobjbynameImm8Id16V8StubBuilder::GenerateCircuit()
2890 {
2891 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStobjbynameImm8Id16V8, GLUE));
2892 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStobjbynameImm8Id16V8, SP));
2893 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStobjbynameImm8Id16V8, SLOTID));
2894 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStobjbynameImm8Id16V8, STRING_ID));
2895 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStobjbynameImm8Id16V8, RECEIVER));
2896 ProfileOperation callback;
2897
2898 GateRef frame = GetFrame(sp);
2899 GateRef func = GetFunctionFromFrame(glue, frame);
2900 GateRef method = GetMethodFromFunction(glue, func);
2901 GateRef constpool = GetConstpoolFromMethod(glue, method);
2902 GateRef acc = GetAccFromFrame(glue, frame);
2903 GateRef profileTypeInfo = GetProfileTypeInfoFromFunction(glue, func);
2904
2905 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2906 StringIdInfo stringIdInfo(constpool, stringId);
2907 GateRef result =
2908 builder.StoreObjByName(glue, receiver, 0, stringIdInfo, acc, profileTypeInfo, slotId, callback);
2909 CHECK_EXCEPTION(result);
2910 }
2911
GenerateCircuit()2912 void BaselineStobjbynameImm16Id16V8StubBuilder::GenerateCircuit()
2913 {
2914 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStobjbynameImm16Id16V8, GLUE));
2915 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStobjbynameImm16Id16V8, SP));
2916 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStobjbynameImm16Id16V8, SLOTID));
2917 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStobjbynameImm16Id16V8, STRING_ID));
2918 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStobjbynameImm16Id16V8, RECEIVER));
2919 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2920
2921 GateRef method = GetMethodFromFunction(glue, curFunc);
2922 GateRef constpool = GetConstpoolFromMethod(glue, method);
2923 GateRef acc = GetAccFromFrame(glue, frame);
2924 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
2925 StringIdInfo stringIdInfo(constpool, stringId);
2926 GateRef result = builder.StoreObjByName(glue, receiver, 0, stringIdInfo, acc, profileTypeInfo,
2927 slotId, callback);
2928 CHECK_EXCEPTION(result);
2929 }
2930
GenerateCircuit()2931 void BaselineStownbynameImm8Id16V8StubBuilder::GenerateCircuit()
2932 {
2933 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStownbynameImm8Id16V8, GLUE));
2934 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStownbynameImm8Id16V8, SP));
2935 GateRef receiverId = Int32Argument(PARAM_INDEX(BaselineStownbynameImm8Id16V8, RECEIVER_ID));
2936 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStownbynameImm8Id16V8, STRING_ID));
2937 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStownbynameImm8Id16V8, SLOT_ID));
2938 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2939
2940 GateRef method = GetMethodFromFunction(glue, curFunc);
2941 GateRef constpool = GetConstpoolFromMethod(glue, method);
2942 GateRef receiver = GetVregValue(glue, sp, ZExtInt32ToPtr(receiverId));
2943 GateRef acc = GetAccFromFrame(glue, frame);
2944 auto env = GetEnvironment();
2945 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
2946 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
2947 Label checkResult(env);
2948
2949 Label isJSObject(env);
2950 Label slowPath(env);
2951 Branch(IsJSObject(glue, receiver), &isJSObject, &slowPath);
2952 Bind(&isJSObject);
2953 {
2954 Label notClassConstructor(env);
2955 Branch(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
2956 Bind(¬ClassConstructor);
2957 {
2958 Label fastPath(env);
2959 Branch(IsClassPrototype(glue, receiver), &slowPath, &fastPath);
2960 Bind(&fastPath);
2961 {
2962 SetCurrentGlobalEnv(GetGlobalEnv(glue));
2963 result = SetPropertyByName(glue, receiver, propKey, acc, true, True(), callback);
2964 Branch(TaggedIsHole(*result), &slowPath, &checkResult);
2965 }
2966 }
2967 }
2968 Bind(&slowPath);
2969 {
2970 result = CallRuntime(glue, RTSTUB_ID(StOwnByName), { receiver, propKey, acc });
2971 Jump(&checkResult);
2972 }
2973 Bind(&checkResult);
2974 {
2975 CHECK_EXCEPTION(*result);
2976 }
2977 }
2978
GenerateCircuit()2979 void BaselineStownbynameImm16Id16V8StubBuilder::GenerateCircuit()
2980 {
2981 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStownbynameImm16Id16V8, GLUE));
2982 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStownbynameImm16Id16V8, SP));
2983 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStownbynameImm16Id16V8, RECEIVER));
2984 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStownbynameImm16Id16V8, STRING_ID));
2985 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStownbynameImm16Id16V8, SLOT_ID));
2986 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
2987
2988 GateRef acc = GetAccFromFrame(glue, frame);
2989 GateRef method = GetMethodFromFunction(glue, curFunc);
2990 GateRef constpool = GetConstpoolFromMethod(glue, method);
2991 auto env = GetEnvironment();
2992 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
2993 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
2994 Label checkResult(env);
2995
2996 Label isJSObject(env);
2997 Label slowPath(env);
2998 Branch(IsJSObject(glue, receiver), &isJSObject, &slowPath);
2999 Bind(&isJSObject);
3000 {
3001 Label notClassConstructor(env);
3002 Branch(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
3003 Bind(¬ClassConstructor);
3004 {
3005 Label fastPath(env);
3006 Branch(IsClassPrototype(glue, receiver), &slowPath, &fastPath);
3007 Bind(&fastPath);
3008 {
3009 SetCurrentGlobalEnv(GetGlobalEnv(glue));
3010 result = SetPropertyByName(glue, receiver, propKey, acc, true, True(), callback);
3011 Branch(TaggedIsHole(*result), &slowPath, &checkResult);
3012 }
3013 }
3014 }
3015 Bind(&slowPath);
3016 {
3017 result = CallRuntime(glue, RTSTUB_ID(StOwnByName), { receiver, propKey, acc });
3018 Jump(&checkResult);
3019 }
3020 Bind(&checkResult);
3021 {
3022 CHECK_EXCEPTION(*result);
3023 }
3024 }
3025
GenerateCircuit()3026 void BaselineLdsuperbynameImm8Id16StubBuilder::GenerateCircuit()
3027 {
3028 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdsuperbynameImm8Id16, GLUE));
3029 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdsuperbynameImm8Id16, SP));
3030 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineLdsuperbynameImm8Id16, STRING_ID));
3031
3032 GateRef frame = GetFrame(sp);
3033 GateRef acc = GetAccFromFrame(glue, frame);
3034 GateRef func = GetFunctionFromFrame(glue, frame);
3035 GateRef method = GetMethodFromFunction(glue, func);
3036 GateRef constpool = GetConstpoolFromMethod(glue, method);
3037 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
3038 GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { acc, propKey });
3039 CHECK_EXCEPTION_RETURN(result);
3040 }
3041
GenerateCircuit()3042 void BaselineLdsuperbynameImm16Id16StubBuilder::GenerateCircuit()
3043 {
3044 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdsuperbynameImm16Id16, GLUE));
3045 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdsuperbynameImm16Id16, SP));
3046 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineLdsuperbynameImm16Id16, STRING_ID));
3047
3048 GateRef frame = GetFrame(sp);
3049 GateRef acc = GetAccFromFrame(glue, frame);
3050 GateRef func = GetFunctionFromFrame(glue, frame);
3051 GateRef method = GetMethodFromFunction(glue, func);
3052 GateRef constpool = GetConstpoolFromMethod(glue, method);
3053 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
3054 GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { acc, propKey });
3055 CHECK_EXCEPTION_RETURN(result);
3056 }
3057
GenerateCircuit()3058 void BaselineStsuperbynameImm8Id16V8StubBuilder::GenerateCircuit()
3059 {
3060 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStsuperbynameImm8Id16V8, GLUE));
3061 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStsuperbynameImm8Id16V8, SP));
3062 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineStsuperbynameImm8Id16V8, ACC));
3063 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStsuperbynameImm8Id16V8, RECEIVER));
3064 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStsuperbynameImm8Id16V8, STRING_ID));
3065 ProfileOperation callback;
3066
3067 GateRef func = GetFunctionFromFrame(glue, GetFrame(sp));
3068 GateRef method = GetMethodFromFunction(glue, func);
3069 GateRef constpool = GetConstpoolFromMethod(glue, method);
3070 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
3071 GateRef result = CallRuntime(glue, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc });
3072 CHECK_EXCEPTION(result);
3073 }
3074
GenerateCircuit()3075 void BaselineStsuperbynameImm16Id16V8StubBuilder::GenerateCircuit()
3076 {
3077 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStsuperbynameImm16Id16V8, GLUE));
3078 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStsuperbynameImm16Id16V8, SP));
3079 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineStsuperbynameImm16Id16V8, ACC));
3080 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStsuperbynameImm16Id16V8, RECEIVER));
3081 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStsuperbynameImm16Id16V8, STRING_ID));
3082 ProfileOperation callback;
3083
3084 GateRef func = GetFunctionFromFrame(glue, GetFrame(sp));
3085 GateRef method = GetMethodFromFunction(glue, func);
3086 GateRef constpool = GetConstpoolFromMethod(glue, method);
3087 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
3088 GateRef result = CallRuntime(glue, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc });
3089 CHECK_EXCEPTION(result);
3090 }
3091
GenerateCircuit()3092 void BaselineLdlocalmodulevarImm8StubBuilder::GenerateCircuit()
3093 {
3094 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdlocalmodulevarImm8, GLUE));
3095 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdlocalmodulevarImm8, SP));
3096 GateRef index = Int32Argument(PARAM_INDEX(BaselineLdlocalmodulevarImm8, INDEX));
3097 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
3098
3099 GateRef module = GetModuleFromFunction(glue, currentFunc);
3100 GateRef moduleRef = Loadlocalmodulevar(glue, index, module);
3101 Return(moduleRef);
3102 }
3103
GenerateCircuit()3104 void BaselineStconsttoglobalrecordImm16Id16StubBuilder::GenerateCircuit()
3105 {
3106 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStconsttoglobalrecordImm16Id16, GLUE));
3107 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStconsttoglobalrecordImm16Id16, SP));
3108 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineStconsttoglobalrecordImm16Id16, ACC));
3109 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStconsttoglobalrecordImm16Id16, STRING_ID));
3110
3111 GateRef func = GetFunctionFromFrame(glue, GetFrame(sp));
3112 GateRef method = GetMethodFromFunction(glue, func);
3113 GateRef constpool = GetConstpoolFromMethod(glue, method);
3114 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
3115 GateRef result = CallRuntime(glue, RTSTUB_ID(StGlobalRecord),
3116 { propKey, acc, TaggedTrue() });
3117 CHECK_EXCEPTION(result);
3118 }
3119
GenerateCircuit()3120 void BaselineStownbyvaluewithnamesetImm8V8V8StubBuilder::GenerateCircuit()
3121 {
3122 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStownbyvaluewithnamesetImm8V8V8, GLUE));
3123 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStownbyvaluewithnamesetImm8V8V8, SP));
3124 GateRef receiverId = Int32Argument(PARAM_INDEX(BaselineStownbyvaluewithnamesetImm8V8V8, RECEIVER_ID));
3125 GateRef propKeyId = Int32Argument(PARAM_INDEX(BaselineStownbyvaluewithnamesetImm8V8V8, PROP_KEY_ID));
3126 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStownbyvaluewithnamesetImm8V8V8, SLOT_ID));
3127 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
3128 GateRef receiver = GetVregValue(glue, sp, ZExtInt32ToPtr(receiverId));
3129 GateRef propKey = GetVregValue(glue, sp, ZExtInt32ToPtr(propKeyId));
3130 GateRef acc = GetAccFromFrame(glue, frame);
3131
3132 auto env = GetEnvironment();
3133 Label isHeapObject(env);
3134 Label slowPath(env);
3135 Label notClassConstructor(env);
3136 Label notClassPrototype(env);
3137 Label notHole(env);
3138 Label notException(env);
3139 Label notException1(env);
3140 Branch(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath);
3141 Bind(&isHeapObject);
3142 {
3143 Branch(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
3144 Bind(¬ClassConstructor);
3145 {
3146 Branch(IsClassPrototype(glue, receiver), &slowPath, ¬ClassPrototype);
3147 Bind(¬ClassPrototype);
3148 {
3149 SetCurrentGlobalEnv(GetGlobalEnv(glue));
3150 GateRef res = SetPropertyByValue(glue, receiver, propKey, acc, true, callback);
3151 Branch(TaggedIsHole(res), &slowPath, ¬Hole);
3152 Bind(¬Hole);
3153 {
3154 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
3155 Bind(¬Exception);
3156 CallRuntime(glue, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey });
3157 Return();
3158 }
3159 }
3160 }
3161 }
3162 Bind(&slowPath);
3163 {
3164 GateRef res = CallRuntime(glue, RTSTUB_ID(StOwnByValueWithNameSet), { receiver, propKey, acc });
3165 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1);
3166 Bind(¬Exception1);
3167 Return();
3168 }
3169 }
3170
GenerateCircuit()3171 void BaselineStownbyvaluewithnamesetImm16V8V8StubBuilder::GenerateCircuit()
3172 {
3173 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStownbyvaluewithnamesetImm16V8V8, GLUE));
3174 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStownbyvaluewithnamesetImm16V8V8, SP));
3175 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStownbyvaluewithnamesetImm16V8V8, RECEIVER));
3176 GateRef propKey = TaggedArgument(PARAM_INDEX(BaselineStownbyvaluewithnamesetImm16V8V8, PROP_KEY));
3177 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStownbyvaluewithnamesetImm16V8V8, SLOT_ID));
3178 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
3179
3180 GateRef acc = GetAccFromFrame(glue, frame);
3181 auto env = GetEnvironment();
3182 Label isHeapObject(env);
3183 Label slowPath(env);
3184 Label notClassConstructor(env);
3185 Label notClassPrototype(env);
3186 Label notHole(env);
3187 Label notException(env);
3188 Label notException1(env);
3189 Branch(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath);
3190 Bind(&isHeapObject);
3191 {
3192 Branch(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
3193 Bind(¬ClassConstructor);
3194 {
3195 Branch(IsClassPrototype(glue, receiver), &slowPath, ¬ClassPrototype);
3196 Bind(¬ClassPrototype);
3197 {
3198 SetCurrentGlobalEnv(GetGlobalEnv(glue));
3199 GateRef res = SetPropertyByValue(glue, receiver, propKey, acc, true, callback);
3200 Branch(TaggedIsHole(res), &slowPath, ¬Hole);
3201 Bind(¬Hole);
3202 {
3203 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
3204 Bind(¬Exception);
3205 CallRuntime(glue, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey });
3206 Return();
3207 }
3208 }
3209 }
3210 }
3211 Bind(&slowPath);
3212 {
3213 GateRef res = CallRuntime(glue, RTSTUB_ID(StOwnByValueWithNameSet), { receiver, propKey, acc });
3214 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1);
3215 Bind(¬Exception1);
3216 Return();
3217 }
3218 }
3219
GenerateCircuit()3220 void BaselineStownbynamewithnamesetImm8Id16V8StubBuilder::GenerateCircuit()
3221 {
3222 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStownbynamewithnamesetImm8Id16V8, GLUE));
3223 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStownbynamewithnamesetImm8Id16V8, SP));
3224 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStownbynamewithnamesetImm8Id16V8, STRING_ID));
3225 GateRef receiverId = Int32Argument(PARAM_INDEX(BaselineStownbynamewithnamesetImm8Id16V8, RECEIVER_ID));
3226 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStownbynamewithnamesetImm8Id16V8, SLOT_ID));
3227 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
3228
3229 GateRef method = GetMethodFromFunction(glue, curFunc);
3230 GateRef constpool = GetConstpoolFromMethod(glue, method);
3231 GateRef receiver = GetVregValue(glue, sp, ZExtInt32ToPtr(receiverId));
3232 GateRef acc = GetAccFromFrame(glue, frame);
3233 auto env = GetEnvironment();
3234 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
3235 Label isJSObject(env);
3236 Label notJSObject(env);
3237 Label notClassConstructor(env);
3238 Label notClassPrototype(env);
3239 Label notHole(env);
3240 Label notException(env);
3241 Label notException1(env);
3242 Branch(IsJSObject(glue, receiver), &isJSObject, ¬JSObject);
3243 Bind(&isJSObject);
3244 {
3245 Branch(IsClassConstructor(glue, receiver), ¬JSObject, ¬ClassConstructor);
3246 Bind(¬ClassConstructor);
3247 {
3248 Branch(IsClassPrototype(glue, receiver), ¬JSObject, ¬ClassPrototype);
3249 Bind(¬ClassPrototype);
3250 {
3251 SetCurrentGlobalEnv(GetGlobalEnv(glue));
3252 GateRef res = SetPropertyByName(glue, receiver, propKey, acc, true, True(), callback);
3253 Branch(TaggedIsHole(res), ¬JSObject, ¬Hole);
3254 Bind(¬Hole);
3255 {
3256 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
3257 Bind(¬Exception);
3258 CallRuntime(glue, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey });
3259 Return();
3260 }
3261 }
3262 }
3263 }
3264 Bind(¬JSObject);
3265 {
3266 GateRef res = CallRuntime(glue, RTSTUB_ID(StOwnByNameWithNameSet), { receiver, propKey, acc });
3267 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1);
3268 Bind(¬Exception1);
3269 Return();
3270 }
3271 }
3272
GenerateCircuit()3273 void BaselineStownbynamewithnamesetImm16Id16V8StubBuilder::GenerateCircuit()
3274 {
3275 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStownbynamewithnamesetImm16Id16V8, GLUE));
3276 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStownbynamewithnamesetImm16Id16V8, SP));
3277 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineStownbynamewithnamesetImm16Id16V8, STRING_ID));
3278 GateRef receiver = TaggedArgument(PARAM_INDEX(BaselineStownbynamewithnamesetImm16Id16V8, RECEIVER));
3279 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineStownbynamewithnamesetImm16Id16V8, SLOT_ID));
3280 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
3281
3282 GateRef acc = GetAccFromFrame(glue, frame);
3283 GateRef method = GetMethodFromFunction(glue, curFunc);
3284 GateRef constpool = GetConstpoolFromMethod(glue, method);
3285 auto env = GetEnvironment();
3286 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
3287 Label isJSObject(env);
3288 Label notJSObject(env);
3289 Label notClassConstructor(env);
3290 Label notClassPrototype(env);
3291 Label notHole(env);
3292 Label notException(env);
3293 Label notException1(env);
3294 Branch(IsJSObject(glue, receiver), &isJSObject, ¬JSObject);
3295 Bind(&isJSObject);
3296 {
3297 Branch(IsClassConstructor(glue, receiver), ¬JSObject, ¬ClassConstructor);
3298 Bind(¬ClassConstructor);
3299 {
3300 Branch(IsClassPrototype(glue, receiver), ¬JSObject, ¬ClassPrototype);
3301 Bind(¬ClassPrototype);
3302 {
3303 SetCurrentGlobalEnv(GetGlobalEnv(glue));
3304 GateRef res = SetPropertyByName(glue, receiver, propKey, acc, true, True(), callback);
3305 Branch(TaggedIsHole(res), ¬JSObject, ¬Hole);
3306 Bind(¬Hole);
3307 {
3308 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
3309 Bind(¬Exception);
3310 CallRuntime(glue, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey });
3311 Return();
3312 }
3313 }
3314 }
3315 }
3316 Bind(¬JSObject);
3317 {
3318 GateRef res = CallRuntime(glue, RTSTUB_ID(StOwnByNameWithNameSet), { receiver, propKey, acc });
3319 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1);
3320 Bind(¬Exception1);
3321 Return();
3322 }
3323 }
3324
GenerateCircuit()3325 void BaselineLdbigintId16StubBuilder::GenerateCircuit()
3326 {
3327 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdbigintId16, GLUE));
3328 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdbigintId16, SP));
3329 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineLdbigintId16, STRING_ID));
3330
3331 GateRef frame = GetFrame(sp);
3332 GateRef acc = GetAccFromFrame(glue, frame);
3333 GateRef func = GetFunctionFromFrame(glue, frame);
3334 GateRef method = GetMethodFromFunction(glue, func);
3335 GateRef constpool = GetConstpoolFromMethod(glue, method);
3336 GateRef numberBigInt = GetStringFromConstPool(glue, constpool, stringId);
3337 GateRef res = CallRuntime(glue, RTSTUB_ID(LdBigInt), { numberBigInt });
3338 CHECK_EXCEPTION_WITH_ACC(res);
3339 }
3340
GenerateCircuit()3341 void BaselineFldaiImm64StubBuilder::GenerateCircuit()
3342 {
3343 GateRef imm = CastInt64ToFloat64(Int64Argument(PARAM_INDEX(BaselineFldaiImm64, IMM)));
3344
3345 GateRef result = DoubleToTaggedDoublePtr(imm);
3346 Return(result);
3347 }
3348
GenerateCircuit()3349 void BaselineReturnStubBuilder::GenerateCircuit()
3350 {
3351 GateRef glue = PtrArgument(PARAM_INDEX(BaselineReturn, GLUE));
3352 GateRef sp = PtrArgument(PARAM_INDEX(BaselineReturn, SP));
3353 GateRef curPcOffset = Int32Argument(PARAM_INDEX(BaselineReturn, OFFSET));
3354
3355 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
3356 GateRef frame = GetFrame(*varSp);
3357 GateRef acc = GetAccFromFrame(glue, frame);
3358
3359 auto env = GetEnvironment();
3360 GateRef pc = GetPcFromFrame(frame);
3361 GateRef curFunction = GetFunctionFromFrame(glue, frame);
3362 GateRef curMethod =
3363 Load(VariableType::JS_ANY(), glue, curFunction, IntPtr(JSFunctionBase::METHOD_OFFSET));
3364 GateRef constpool =
3365 Load(VariableType::JS_POINTER(), glue, curMethod, IntPtr(Method::CONSTANT_POOL_OFFSET));
3366 GateRef raw =
3367 Load(VariableType::JS_POINTER(), glue, curFunction, IntPtr(JSFunction::RAW_PROFILE_TYPE_INFO_OFFSET));
3368 GateRef profileTypeInfo =
3369 Load(VariableType::JS_POINTER(), glue, raw, IntPtr(ProfileTypeInfoCell::VALUE_OFFSET));
3370 GateRef hotnessCounter =
3371 LoadPrimitive(VariableType::INT32(), curMethod, IntPtr(Method::LITERAL_INFO_OFFSET));
3372 ProfileOperation callback;
3373
3374 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
3375 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
3376 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
3377 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
3378 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
3379
3380 Label isBaselineBuiltinFrame(env);
3381 Label notBaselineBuiltinFrame(env);
3382 Label pcEqualNullptr(env);
3383 Label pcNotEqualNullptr(env);
3384 Label pcEqualBaseline(env);
3385 Label pcNotEqualBaseline(env);
3386 Label updateHotness(env);
3387 Label isStable(env);
3388 Label tryContinue(env);
3389 Label dispatch(env);
3390 Label slowPath(env);
3391
3392 BRANCH(TaggedIsUndefined(*varProfileTypeInfo), &updateHotness, &isStable);
3393 Bind(&isStable);
3394 {
3395 GateRef varProfileTypeInfoVal = *varProfileTypeInfo;
3396 GateRef isProfileDumpedAndJitCompiled = LogicAndBuilder(env)
3397 .And(ProfilerStubBuilder(env).IsCompiledOrTryCompile(
3398 glue, GetFunctionFromFrame(glue, frame), varProfileTypeInfoVal, callback, pc))
3399 .And(ProfilerStubBuilder(env).IsProfileTypeInfoDumped(varProfileTypeInfoVal, callback))
3400 .Done();
3401 BRANCH(isProfileDumpedAndJitCompiled, &tryContinue, &updateHotness);
3402 }
3403 Bind(&updateHotness);
3404 {
3405 GateRef offset = Int32Not(curPcOffset);
3406 UPDATE_HOTNESS(*varSp, callback);
3407 SetHotnessCounter(glue, curMethod, *varHotnessCounter);
3408 Jump(&tryContinue);
3409 }
3410
3411 Bind(&tryContinue);
3412
3413 GateRef currentSp = *varSp;
3414 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), frame,
3415 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
3416
3417 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
3418 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
3419 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
3420 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
3421 Bind(&isBaselineBuiltinFrame);
3422 {
3423 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
3424 Jump(¬BaselineBuiltinFrame);
3425 }
3426 Bind(¬BaselineBuiltinFrame);
3427 prevState = GetFrame(*varSp);
3428 varPc = GetPcFromFrame(*prevState);
3429 Branch(IntPtrEqual(*varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
3430 Bind(&pcEqualNullptr);
3431 {
3432 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { acc, *varSp, currentSp });
3433 Return();
3434 }
3435 Bind(&pcNotEqualNullptr);
3436 BRANCH(IntPtrEqual(*varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
3437 Bind(&pcEqualBaseline);
3438 {
3439 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
3440 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturnBaseline), { glue, acc, *varSp, currentSp, jumpSize });
3441 Return();
3442 }
3443 Bind(&pcNotEqualBaseline);
3444 {
3445 GateRef function = GetFunctionFromFrame(glue, *prevState);
3446 GateRef method = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
3447 varConstpool = GetConstpoolFromMethod(glue, method);
3448 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
3449 varHotnessCounter = GetHotnessCounterFromMethod(method);
3450 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
3451 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
3452 { glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
3453 acc, *varHotnessCounter, jumpSize });
3454 Return();
3455 }
3456 }
3457
GenerateCircuit()3458 void BaselineLdlexvarImm8Imm8StubBuilder::GenerateCircuit()
3459 {
3460 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdlexvarImm8Imm8, GLUE));
3461 GateRef level = Int32Argument(PARAM_INDEX(BaselineLdlexvarImm8Imm8, LEVEL));
3462 GateRef slot = Int32Argument(PARAM_INDEX(BaselineLdlexvarImm8Imm8, SLOT));
3463 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdlexvarImm8Imm8, SP));
3464
3465 auto env = GetEnvironment();
3466 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, GetFrame(sp)));
3467 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
3468
3469 Label loopHead(env);
3470 Label loopEnd(env);
3471 Label afterLoop(env);
3472 Branch(Int32LessThan(*i, level), &loopHead, &afterLoop);
3473 LoopBegin(&loopHead);
3474 currentEnv = GetParentEnv(glue, *currentEnv);
3475 i = Int32Add(*i, Int32(1));
3476 Branch(Int32LessThan(*i, level), &loopEnd, &afterLoop);
3477 Bind(&loopEnd);
3478 LoopEnd(&loopHead);
3479 Bind(&afterLoop);
3480 GateRef variable = GetPropertiesFromLexicalEnv(glue, *currentEnv, slot);
3481 Return(variable);
3482 }
3483
GenerateCircuit()3484 void BaselineStlexvarImm8Imm8StubBuilder::GenerateCircuit()
3485 {
3486 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStlexvarImm8Imm8, GLUE));
3487 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineStlexvarImm8Imm8, ACC));
3488 GateRef level = Int32Argument(PARAM_INDEX(BaselineStlexvarImm8Imm8, LEVEL));
3489 GateRef slot = Int32Argument(PARAM_INDEX(BaselineStlexvarImm8Imm8, SLOT));
3490 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStlexvarImm8Imm8, SP));
3491
3492 auto env = GetEnvironment();
3493 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, GetFrame(sp)));
3494 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
3495
3496 Label loopHead(env);
3497 Label loopEnd(env);
3498 Label afterLoop(env);
3499 Branch(Int32LessThan(*i, level), &loopHead, &afterLoop);
3500 LoopBegin(&loopHead);
3501 currentEnv = GetParentEnv(glue, *currentEnv);
3502 i = Int32Add(*i, Int32(1));
3503 Branch(Int32LessThan(*i, level), &loopEnd, &afterLoop);
3504 Bind(&loopEnd);
3505 LoopEnd(&loopHead);
3506 Bind(&afterLoop);
3507 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, acc);
3508 Return();
3509 }
3510
3511 // GLUE
GenerateCircuit()3512 void BaselineJnstricteqV8Imm16StubBuilder::GenerateCircuit()
3513 {
3514 Return();
3515 }
3516
GenerateCircuit()3517 void BaselineAsyncgeneratorrejectV8StubBuilder::GenerateCircuit()
3518 {
3519 GateRef glue = PtrArgument(PARAM_INDEX(BaselineAsyncgeneratorrejectV8, GLUE));
3520 GateRef sp = PtrArgument(PARAM_INDEX(BaselineAsyncgeneratorrejectV8, SP));
3521 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineAsyncgeneratorrejectV8, ACC));
3522 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineAsyncgeneratorrejectV8, V0));
3523 GateRef asyncGenerator = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3524
3525 GateRef result = CallRuntime(glue, RTSTUB_ID(AsyncGeneratorReject),
3526 { asyncGenerator, acc });
3527 CHECK_EXCEPTION_RETURN(result);
3528 }
3529
GenerateCircuit()3530 void BaselineSetgeneratorstateImm8StubBuilder::GenerateCircuit()
3531 {
3532 GateRef glue = PtrArgument(PARAM_INDEX(BaselineSetgeneratorstateImm8, GLUE));
3533 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineSetgeneratorstateImm8, ACC));
3534 GateRef index = Int32Argument(PARAM_INDEX(BaselineSetgeneratorstateImm8, INDEX));
3535
3536 CallRuntime(glue, RTSTUB_ID(SetGeneratorState), { acc, IntToTaggedInt(index) });
3537 Return();
3538 }
3539
GenerateCircuit()3540 void BaselineGetasynciteratorImm8StubBuilder::GenerateCircuit()
3541 {
3542 GateRef glue = PtrArgument(PARAM_INDEX(BaselineGetasynciteratorImm8, GLUE));
3543 GateRef sp = PtrArgument(PARAM_INDEX(BaselineGetasynciteratorImm8, SP));
3544 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineGetasynciteratorImm8, ACC));
3545
3546 GateRef res = CallRuntime(glue, RTSTUB_ID(GetAsyncIterator), { acc });
3547 CHECK_PENDING_EXCEPTION(res);
3548 }
3549
GenerateCircuit()3550 void BaselineLdPrivatePropertyImm8Imm16Imm16StubBuilder::GenerateCircuit()
3551 {
3552 GateRef glue = PtrArgument(PARAM_INDEX(BaselineLdPrivatePropertyImm8Imm16Imm16, GLUE));
3553 GateRef sp = PtrArgument(PARAM_INDEX(BaselineLdPrivatePropertyImm8Imm16Imm16, SP));
3554 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineLdPrivatePropertyImm8Imm16Imm16, ACC));
3555 GateRef levelIndex = Int32Argument(PARAM_INDEX(BaselineLdPrivatePropertyImm8Imm16Imm16, INDEX0));
3556 GateRef slotIndex = Int32Argument(PARAM_INDEX(BaselineLdPrivatePropertyImm8Imm16Imm16, INDEX1));
3557 GateRef lexicalEnv = TaggedPointerArgument(PARAM_INDEX(BaselineLdPrivatePropertyImm8Imm16Imm16, ENV));
3558
3559 GateRef res = CallRuntime(glue, RTSTUB_ID(LdPrivateProperty), {lexicalEnv,
3560 IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), acc}); // acc as obj
3561 CHECK_EXCEPTION_WITH_ACC(res);
3562 }
3563
GenerateCircuit()3564 void BaselineStPrivatePropertyImm8Imm16Imm16V8StubBuilder::GenerateCircuit()
3565 {
3566 GateRef glue = PtrArgument(PARAM_INDEX(BaselineStPrivatePropertyImm8Imm16Imm16V8, GLUE));
3567 GateRef sp = PtrArgument(PARAM_INDEX(BaselineStPrivatePropertyImm8Imm16Imm16V8, SP));
3568 GateRef levelIndex = Int32Argument(PARAM_INDEX(BaselineStPrivatePropertyImm8Imm16Imm16V8, INDEX0));
3569 GateRef slotIndex = Int32Argument(PARAM_INDEX(BaselineStPrivatePropertyImm8Imm16Imm16V8, INDEX1));
3570 GateRef index3 = Int32Argument(PARAM_INDEX(BaselineStPrivatePropertyImm8Imm16Imm16V8, INDEX2));
3571 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(index3));
3572
3573 GateRef frame = GetFrame(sp);
3574 GateRef acc = GetAccFromFrame(glue, frame);
3575 GateRef lexicalEnv = GetEnvFromFrame(glue, frame);
3576
3577 GateRef res = CallRuntime(glue, RTSTUB_ID(StPrivateProperty), {lexicalEnv,
3578 IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), obj, acc}); // acc as value
3579 CHECK_EXCEPTION_WITH_ACC(res);
3580 }
3581
GenerateCircuit()3582 void BaselineTestInImm8Imm16Imm16StubBuilder::GenerateCircuit()
3583 {
3584 GateRef glue = PtrArgument(PARAM_INDEX(BaselineTestInImm8Imm16Imm16, GLUE));
3585 GateRef sp = PtrArgument(PARAM_INDEX(BaselineTestInImm8Imm16Imm16, SP));
3586 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineTestInImm8Imm16Imm16, ACC));
3587 GateRef levelIndex = Int32Argument(PARAM_INDEX(BaselineTestInImm8Imm16Imm16, INDEX0));
3588 GateRef slotIndex = Int32Argument(PARAM_INDEX(BaselineTestInImm8Imm16Imm16, INDEX1));
3589 GateRef lexicalEnv = TaggedPointerArgument(PARAM_INDEX(BaselineTestInImm8Imm16Imm16, ENV));
3590
3591 GateRef res = CallRuntime(glue, RTSTUB_ID(TestIn), {lexicalEnv,
3592 IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), acc}); // acc as obj
3593 CHECK_EXCEPTION_WITH_ACC(res);
3594 }
3595
GenerateCircuit()3596 void BaselineDeprecatedLdlexenvPrefNoneStubBuilder::GenerateCircuit()
3597 {
3598 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdlexenvPrefNone, GLUE));
3599 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdlexenvPrefNone, SP));
3600 GateRef state = GetFrame(sp);
3601
3602 GateRef env = GetEnvFromFrame(glue, state);
3603 Return(env);
3604 }
3605
GenerateCircuit()3606 void BaselineWideCreateobjectwithexcludedkeysPrefImm16V8V8StubBuilder::GenerateCircuit()
3607 {
3608 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideCreateobjectwithexcludedkeysPrefImm16V8V8, GLUE));
3609 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideCreateobjectwithexcludedkeysPrefImm16V8V8, SP));
3610 GateRef numKeys = Int32Argument(PARAM_INDEX(BaselineWideCreateobjectwithexcludedkeysPrefImm16V8V8, V0));
3611 GateRef objId = Int32Argument(PARAM_INDEX(BaselineWideCreateobjectwithexcludedkeysPrefImm16V8V8, V1));
3612 GateRef firstArgRegIdx = Int32Argument(PARAM_INDEX(BaselineWideCreateobjectwithexcludedkeysPrefImm16V8V8, V2));
3613
3614 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
3615 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(objId));
3616 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateObjectWithExcludedKeys),
3617 { Int16ToTaggedInt(numKeys), obj, Int16ToTaggedInt(firstArgRegIdx) });
3618 CHECK_EXCEPTION_WITH_ACC(res);
3619 }
3620
GenerateCircuit()3621 void BaselineThrowPrefNoneStubBuilder::GenerateCircuit()
3622 {
3623 GateRef glue = PtrArgument(PARAM_INDEX(BaselineThrowPrefNone, GLUE));
3624 GateRef sp = PtrArgument(PARAM_INDEX(BaselineThrowPrefNone, SP));
3625 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineThrowPrefNone, ACC));
3626
3627 CallRuntime(glue, RTSTUB_ID(Throw), { acc });
3628 DISPATCH_LAST();
3629 Return();
3630 }
3631
GenerateCircuit()3632 void BaselineDeprecatedPoplexenvPrefNoneStubBuilder::GenerateCircuit()
3633 {
3634 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedPoplexenvPrefNone, GLUE));
3635 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedPoplexenvPrefNone, SP));
3636
3637 GateRef state = GetFrame(sp);
3638 GateRef currentLexEnv = GetEnvFromFrame(glue, state);
3639 GateRef parentLexEnv = GetParentEnv(glue, currentLexEnv);
3640 SetEnvToFrame(glue, state, parentLexEnv);
3641 Return();
3642 }
3643
GenerateCircuit()3644 void BaselineWideNewobjrangePrefImm16V8StubBuilder::GenerateCircuit()
3645 {
3646 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideNewobjrangePrefImm16V8, GLUE));
3647 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideNewobjrangePrefImm16V8, SP));
3648 GateRef numArgs = Int32Argument(PARAM_INDEX(BaselineWideNewobjrangePrefImm16V8, NUM_ARGS));
3649 GateRef firstArgRegIdx = Int32Argument(PARAM_INDEX(BaselineWideNewobjrangePrefImm16V8, IDX));
3650 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineWideNewobjrangePrefImm16V8, HOTNESS_COUNTER));
3651 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineWideNewobjrangePrefImm16V8, SLOT_ID));
3652 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
3653 GateRef acc = GetAccFromFrame(glue, frame);
3654 GateRef firstArgOffset = Int16(1);
3655 GateRef ctor = GetVregValue(glue, sp, ZExtInt16ToPtr(firstArgRegIdx));
3656
3657 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
3658 DEFVARIABLE(thisObj, VariableType::JS_ANY(), Undefined());
3659 auto env = GetEnvironment();
3660 GateRef actualNumArgs = ZExtInt16ToInt32(Int16Sub(numArgs, firstArgOffset));
3661
3662 Label ctorIsHeapObject(env);
3663 Label ctorIsJSFunction(env);
3664 Label fastPath(env);
3665 Label slowPath(env);
3666 Label checkResult(env);
3667 Label threadCheck(env);
3668 Label dispatch(env);
3669 Label ctorIsBase(env);
3670 Label ctorNotBase(env);
3671 Label isException(env);
3672 Label noNeedCheckException(env);
3673 Label exit(env);
3674
3675 Branch(TaggedIsHeapObject(ctor), &ctorIsHeapObject, &slowPath);
3676 Bind(&ctorIsHeapObject);
3677 Branch(IsJSFunction(glue, ctor), &ctorIsJSFunction, &slowPath);
3678 Bind(&ctorIsJSFunction);
3679 Branch(IsConstructor(glue, ctor), &fastPath, &slowPath);
3680 Bind(&fastPath);
3681 {
3682 Branch(IsBase(glue, ctor), &ctorIsBase, &ctorNotBase);
3683 Bind(&ctorIsBase);
3684 {
3685 NewObjectStubBuilder newBuilder(this);
3686 thisObj = newBuilder.FastNewThisObject(glue, ctor);
3687 Branch(HasPendingException(glue), &isException, &ctorNotBase);
3688 }
3689 Bind(&ctorNotBase);
3690 {
3691 GateRef argv = PtrAdd(sp,
3692 PtrMul(PtrAdd(firstArgRegIdx, firstArgOffset), IntPtr(8))); // 8: skip function
3693 GateRef jumpSize = IntPtr(-BytecodeInstruction::Size(BytecodeInstruction::Format::PREF_IMM16_V8));
3694 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_CONSTRUCTOR_WITH_ARGV);
3695 callArgs.callConstructorArgs = { ZExtInt32ToPtr(actualNumArgs), argv, *thisObj };
3696 CallStubBuilder callBuilder(this, glue, ctor, actualNumArgs, jumpSize, &res, hotnessCounter, callArgs,
3697 callback);
3698 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
3699 Bind(&exit);
3700 Jump(&threadCheck);
3701 }
3702 }
3703 Bind(&slowPath);
3704 {
3705 GateRef firstArgIdx = Int16Add(firstArgRegIdx, firstArgOffset);
3706 GateRef length = Int16Sub(numArgs, firstArgOffset);
3707 res = CallRuntime(glue, RTSTUB_ID(NewObjRange),
3708 { ctor, ctor, Int16ToTaggedInt(firstArgIdx), Int16ToTaggedInt(length) });
3709 Jump(&checkResult);
3710 }
3711 Bind(&checkResult);
3712 {
3713 Branch(TaggedIsException(*res), &isException, &dispatch);
3714 }
3715 Bind(&threadCheck);
3716 {
3717 Branch(HasPendingException(glue), &isException, &dispatch);
3718 }
3719 Bind(&isException);
3720 {
3721 DISPATCH_LAST();
3722 Return(acc);
3723 }
3724 Bind(&dispatch);
3725 Return(*res);
3726 Bind(&noNeedCheckException);
3727 Return(*res);
3728 }
3729
GenerateCircuit()3730 void BaselineThrowNotexistsPrefNoneStubBuilder::GenerateCircuit()
3731 {
3732 GateRef glue = PtrArgument(PARAM_INDEX(BaselineThrowNotexistsPrefNone, GLUE));
3733 GateRef sp = PtrArgument(PARAM_INDEX(BaselineThrowNotexistsPrefNone, SP));
3734
3735 GateRef frame = GetFrame(sp);
3736 GateRef acc = GetAccFromFrame(glue, frame);
3737 CallRuntime(glue, RTSTUB_ID(ThrowThrowNotExists), {});
3738 DISPATCH_LAST();
3739 Return();
3740 }
3741
GenerateCircuit()3742 void BaselineDeprecatedGetiteratornextPrefV8V8StubBuilder::GenerateCircuit()
3743 {
3744 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedGetiteratornextPrefV8V8, GLUE));
3745 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedGetiteratornextPrefV8V8, SP));
3746 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedGetiteratornextPrefV8V8, V0));
3747 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedGetiteratornextPrefV8V8, V1));
3748 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3749 GateRef method = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
3750
3751 GateRef frame = GetFrame(sp);
3752 GateRef acc = GetAccFromFrame(glue, frame);
3753 GateRef result = CallRuntime(glue, RTSTUB_ID(GetIteratorNext), { obj, method });
3754 CHECK_EXCEPTION_WITH_ACC(result);
3755 }
3756
GenerateCircuit()3757 void BaselineWideNewlexenvPrefImm16StubBuilder::GenerateCircuit()
3758 {
3759 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideNewlexenvPrefImm16, GLUE));
3760 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideNewlexenvPrefImm16, SP));
3761 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineWideNewlexenvPrefImm16, ACC));
3762 GateRef numVars = Int32Argument(PARAM_INDEX(BaselineWideNewlexenvPrefImm16, NUM_VARS));
3763 GateRef state = GetFrame(sp);
3764
3765 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
3766 auto env = GetEnvironment();
3767 auto parent = GetEnvFromFrame(glue, state);
3768 NewObjectStubBuilder newBuilder(this);
3769 newBuilder.SetParameters(glue, 0);
3770 Label afterNew(env);
3771 newBuilder.NewLexicalEnv(&result, &afterNew, numVars, parent);
3772 Bind(&afterNew);
3773 Label notException(env);
3774 CHECK_EXCEPTION_WITH_JUMP_RETURN(*result, ¬Exception);
3775 Bind(¬Exception);
3776 SetEnvToFrame(glue, state, *result);
3777 Return(*result);
3778 }
3779
GenerateCircuit()3780 void BaselineThrowPatternnoncoerciblePrefNoneStubBuilder::GenerateCircuit()
3781 {
3782 GateRef glue = PtrArgument(PARAM_INDEX(BaselineThrowPatternnoncoerciblePrefNone, GLUE));
3783 GateRef sp = PtrArgument(PARAM_INDEX(BaselineThrowPatternnoncoerciblePrefNone, SP));
3784
3785 GateRef frame = GetFrame(sp);
3786 GateRef acc = GetAccFromFrame(glue, frame);
3787 CallRuntime(glue, RTSTUB_ID(ThrowPatternNonCoercible), {});
3788 DISPATCH_LAST();
3789 Return();
3790 }
3791
GenerateCircuit()3792 void BaselineDeprecatedCreatearraywithbufferPrefImm16StubBuilder::GenerateCircuit()
3793 {
3794 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCreatearraywithbufferPrefImm16, GLUE));
3795 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCreatearraywithbufferPrefImm16, SP));
3796 GateRef immI16 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCreatearraywithbufferPrefImm16, IMM_I16));
3797 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineDeprecatedCreatearraywithbufferPrefImm16, SLOT_ID));
3798 GateRef profileTypeInfo =
3799 TaggedPointerArgument(PARAM_INDEX(BaselineDeprecatedCreatearraywithbufferPrefImm16, PROFILE_TYPE_INFO));
3800 GateRef pc = PtrArgument(PARAM_INDEX(BaselineDeprecatedCreatearraywithbufferPrefImm16, PC));
3801 GateRef imm = ZExtInt16ToInt32(immI16);
3802
3803 GateRef frame = GetFrame(sp);
3804 GateRef acc = GetAccFromFrame(glue, frame);
3805 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
3806 ProfileOperation callback;
3807 NewObjectStubBuilder newBuilder(this, GetGlobalEnv(glue));
3808 GateRef res = newBuilder.CreateArrayWithBuffer(
3809 glue, imm, currentFunc, { pc, 0, true }, profileTypeInfo, slotId, callback);
3810 CHECK_EXCEPTION_WITH_ACC(res);
3811 }
3812
GenerateCircuit()3813 void BaselineWideNewlexenvwithnamePrefImm16Id16StubBuilder::GenerateCircuit()
3814 {
3815 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideNewlexenvwithnamePrefImm16Id16, GLUE));
3816 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideNewlexenvwithnamePrefImm16Id16, SP));
3817 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineWideNewlexenvwithnamePrefImm16Id16, ACC));
3818 GateRef numVars = Int32Argument(PARAM_INDEX(BaselineWideNewlexenvwithnamePrefImm16Id16, NUM_VARS));
3819 GateRef scopeId = Int32Argument(PARAM_INDEX(BaselineWideNewlexenvwithnamePrefImm16Id16, SCOPE_ID));
3820
3821 auto env = GetEnvironment();
3822 GateRef res = CallRuntime(glue, RTSTUB_ID(NewLexicalEnvWithName),
3823 { Int16ToTaggedInt(numVars), Int16ToTaggedInt(scopeId) });
3824 Label notException(env);
3825 CHECK_EXCEPTION_WITH_JUMP_RETURN(res, ¬Exception);
3826 Bind(¬Exception);
3827 GateRef state = GetFrame(sp);
3828 SetEnvToFrame(glue, state, res);
3829 Return(res);
3830 }
3831
GenerateCircuit()3832 void BaselineThrowDeletesuperpropertyPrefNoneStubBuilder::GenerateCircuit()
3833 {
3834 GateRef glue = PtrArgument(PARAM_INDEX(BaselineThrowDeletesuperpropertyPrefNone, GLUE));
3835 GateRef sp = PtrArgument(PARAM_INDEX(BaselineThrowDeletesuperpropertyPrefNone, SP));
3836
3837 GateRef frame = GetFrame(sp);
3838 GateRef acc = GetAccFromFrame(glue, frame);
3839 CallRuntime(glue, RTSTUB_ID(ThrowDeleteSuperProperty), {});
3840 DISPATCH_LAST();
3841 Return();
3842 }
3843
GenerateCircuit()3844 void BaselineDeprecatedCreateobjectwithbufferPrefImm16StubBuilder::GenerateCircuit()
3845 {
3846 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCreateobjectwithbufferPrefImm16, GLUE));
3847 GateRef immI16 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCreateobjectwithbufferPrefImm16, IMM_I16));
3848 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCreateobjectwithbufferPrefImm16, SP));
3849 GateRef imm = ZExtInt16ToInt32(immI16);
3850
3851 GateRef frame = GetFrame(sp);
3852 GateRef acc = GetAccFromFrame(glue, frame);
3853 GateRef func = GetFunctionFromFrame(glue, frame);
3854 GateRef method = GetMethodFromFunction(glue, func);
3855 GateRef constpool = GetConstpoolFromMethod(glue, method);
3856 GateRef module = GetModuleFromFunction(glue, func);
3857 GateRef result = GetObjectLiteralFromConstPool(glue, constpool, imm, module);
3858 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateObjectWithBuffer), { result });
3859 CHECK_EXCEPTION_WITH_ACC(res);
3860 }
3861
3862 // GLUE, SP, NUM_ARGS, FIRST_ARG_REG_IDX
GenerateCircuit()3863 void BaselineNewobjrangeImm8Imm8V8StubBuilder::GenerateCircuit()
3864 {
3865 GateRef glue = PtrArgument(PARAM_INDEX(BaselineNewobjrangeImm8Imm8V8, GLUE));
3866 GateRef sp = PtrArgument(PARAM_INDEX(BaselineNewobjrangeImm8Imm8V8, SP));
3867 GateRef numArgs = Int32Argument(PARAM_INDEX(BaselineNewobjrangeImm8Imm8V8, NUM_ARGS));
3868 GateRef firstArgRegIdx = Int32Argument(PARAM_INDEX(BaselineNewobjrangeImm8Imm8V8, FIRST_ARG_REG_IDX));
3869 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineNewobjrangeImm8Imm8V8, SLOT_ID));
3870 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
3871 GateRef acc = GetAccFromFrame(glue, frame);
3872 GateRef method = GetMethodFromFunction(glue, curFunc);
3873 GateRef hotnessCounter = GetHotnessCounterFromMethod(method);
3874
3875 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
3876 DEFVARIABLE(thisObj, VariableType::JS_ANY(), Undefined());
3877 auto env = GetEnvironment();
3878 GateRef firstArgOffset = Int32(1);
3879 GateRef ctor = GetVregValue(glue, sp, ZExtInt32ToPtr(firstArgRegIdx));
3880 GateRef actualNumArgs = Int32Sub(numArgs, firstArgOffset);
3881
3882 Label ctorIsHeapObject(env);
3883 Label ctorIsJSFunction(env);
3884 Label fastPath(env);
3885 Label slowPath(env);
3886 Label checkResult(env);
3887 Label threadCheck(env);
3888 Label dispatch(env);
3889 Label ctorIsBase(env);
3890 Label ctorNotBase(env);
3891 Label isException(env);
3892 Label noNeedCheckException(env);
3893 Label exit(env);
3894
3895 Branch(TaggedIsHeapObject(ctor), &ctorIsHeapObject, &slowPath);
3896 Bind(&ctorIsHeapObject);
3897 Branch(IsJSFunction(glue, ctor), &ctorIsJSFunction, &slowPath);
3898 Bind(&ctorIsJSFunction);
3899 Branch(IsConstructor(glue, ctor), &fastPath, &slowPath);
3900 Bind(&fastPath);
3901 {
3902 Branch(IsBase(glue, ctor), &ctorIsBase, &ctorNotBase);
3903 Bind(&ctorIsBase);
3904 {
3905 NewObjectStubBuilder newBuilder(this);
3906 thisObj = newBuilder.FastNewThisObject(glue, ctor);
3907 Branch(HasPendingException(glue), &isException, &ctorNotBase);
3908 }
3909 Bind(&ctorNotBase);
3910 {
3911 GateRef argv = PtrAdd(sp, PtrMul(
3912 PtrAdd(firstArgRegIdx, firstArgOffset), IntPtr(8))); // 8: skip function
3913 GateRef jumpSize = IntPtr(-BytecodeInstruction::Size(BytecodeInstruction::Format::IMM8_IMM8_V8));
3914 METHOD_ENTRY_ENV_DEFINED(ctor);
3915 JSCallArgs callArgs(JSCallMode::CALL_CONSTRUCTOR_WITH_ARGV);
3916 callArgs.callConstructorArgs = { ZExtInt32ToPtr(actualNumArgs), argv, *thisObj };
3917 CallStubBuilder callBuilder(this, glue, ctor, actualNumArgs, jumpSize, &res, hotnessCounter, callArgs,
3918 callback);
3919 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
3920 Bind(&exit);
3921 Jump(&threadCheck);
3922 }
3923 }
3924 Bind(&slowPath);
3925 {
3926 GateRef firstArgIdx = Int32Add(firstArgRegIdx, firstArgOffset);
3927 GateRef length = Int32Sub(numArgs, firstArgOffset);
3928 res = CallRuntime(glue, RTSTUB_ID(NewObjRange),
3929 { ctor, ctor, IntToTaggedInt(firstArgIdx), IntToTaggedInt(length) });
3930 Jump(&checkResult);
3931 }
3932 Bind(&checkResult);
3933 {
3934 Branch(TaggedIsException(*res), &isException, &dispatch);
3935 }
3936 Bind(&threadCheck);
3937 {
3938 Branch(HasPendingException(glue), &isException, &dispatch);
3939 }
3940 Bind(&isException);
3941 {
3942 DISPATCH_LAST();
3943 Return(acc);
3944 }
3945 Bind(&dispatch);
3946 Return(*res);
3947 Bind(&noNeedCheckException);
3948 Return(*res);
3949 }
3950
3951 // GLUE, SP, NUM_ARGS, FIRST_ARG_REG_IDX
GenerateCircuit()3952 void BaselineNewobjrangeImm16Imm8V8StubBuilder::GenerateCircuit()
3953 {
3954 GateRef glue = PtrArgument(PARAM_INDEX(BaselineNewobjrangeImm16Imm8V8, GLUE));
3955 GateRef sp = PtrArgument(PARAM_INDEX(BaselineNewobjrangeImm16Imm8V8, SP));
3956 GateRef numArgs = Int32Argument(PARAM_INDEX(BaselineNewobjrangeImm16Imm8V8, NUM_ARGS));
3957 GateRef firstArgRegIdx = Int32Argument(PARAM_INDEX(BaselineNewobjrangeImm16Imm8V8, FIRST_ARG_REG_IDX));
3958 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineNewobjrangeImm16Imm8V8, SLOT_ID));
3959 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
3960
3961 GateRef acc = GetAccFromFrame(glue, frame);
3962 GateRef method = GetMethodFromFunction(glue, curFunc);
3963 GateRef hotnessCounter = GetHotnessCounterFromMethod(method);
3964
3965 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
3966 DEFVARIABLE(thisObj, VariableType::JS_ANY(), Undefined());
3967 auto env = GetEnvironment();
3968 GateRef firstArgOffset = Int16(1);
3969 GateRef ctor = GetVregValue(glue, sp, ZExtInt16ToPtr(firstArgRegIdx));
3970 GateRef actualNumArgs = ZExtInt16ToInt32(Int16Sub(numArgs, firstArgOffset));
3971
3972 Label ctorIsHeapObject(env);
3973 Label ctorIsJSFunction(env);
3974 Label fastPath(env);
3975 Label slowPath(env);
3976 Label checkResult(env);
3977 Label threadCheck(env);
3978 Label dispatch(env);
3979 Label ctorIsBase(env);
3980 Label ctorNotBase(env);
3981 Label isException(env);
3982 Label noNeedCheckException(env);
3983 Label exit(env);
3984
3985 Branch(TaggedIsHeapObject(ctor), &ctorIsHeapObject, &slowPath);
3986 Bind(&ctorIsHeapObject);
3987 Branch(IsJSFunction(glue, ctor), &ctorIsJSFunction, &slowPath);
3988 Bind(&ctorIsJSFunction);
3989 Branch(IsConstructor(glue, ctor), &fastPath, &slowPath);
3990 Bind(&fastPath);
3991 {
3992 Branch(IsBase(glue, ctor), &ctorIsBase, &ctorNotBase);
3993 Bind(&ctorIsBase);
3994 {
3995 NewObjectStubBuilder newBuilder(this);
3996 thisObj = newBuilder.FastNewThisObject(glue, ctor);
3997 Branch(HasPendingException(glue), &isException, &ctorNotBase);
3998 }
3999 Bind(&ctorNotBase);
4000 {
4001 GateRef argv = PtrAdd(sp, PtrMul(
4002 PtrAdd(firstArgRegIdx, firstArgOffset), IntPtr(8))); // 8: skip function
4003 GateRef jumpSize = IntPtr(-BytecodeInstruction::Size(BytecodeInstruction::Format::IMM16_IMM8_V8));
4004 METHOD_ENTRY_ENV_DEFINED(ctor);
4005 JSCallArgs callArgs(JSCallMode::CALL_CONSTRUCTOR_WITH_ARGV);
4006 callArgs.callConstructorArgs = { ZExtInt32ToPtr(actualNumArgs), argv, *thisObj };
4007 CallStubBuilder callBuilder(this, glue, ctor, actualNumArgs, jumpSize, &res, hotnessCounter, callArgs,
4008 callback);
4009 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
4010 Bind(&exit);
4011 Jump(&threadCheck);
4012 }
4013 }
4014 Bind(&slowPath);
4015 {
4016 GateRef firstArgIdx = Int16Add(firstArgRegIdx, firstArgOffset);
4017 GateRef length = Int16Sub(numArgs, firstArgOffset);
4018 res = CallRuntime(glue, RTSTUB_ID(NewObjRange),
4019 { ctor, ctor, Int16ToTaggedInt(firstArgIdx), Int16ToTaggedInt(length) });
4020 Jump(&checkResult);
4021 }
4022 Bind(&checkResult);
4023 {
4024 Branch(TaggedIsException(*res), &isException, &dispatch);
4025 }
4026 Bind(&threadCheck);
4027 {
4028 Branch(HasPendingException(glue), &isException, &dispatch);
4029 }
4030 Bind(&isException);
4031 {
4032 DISPATCH_LAST();
4033 Return(acc);
4034 }
4035 Bind(&dispatch);
4036 Return(*res);
4037 Bind(&noNeedCheckException);
4038 Return(*res);
4039 }
4040
4041 // GLUE, SP, ACC, ACTUAL_NUM_ARGS, VREG_ID, HOTNESS_COUNTER
GenerateCircuit()4042 void BaselineWideCallrangePrefImm16V8StubBuilder::GenerateCircuit()
4043 {
4044 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideCallrangePrefImm16V8, GLUE));
4045 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideCallrangePrefImm16V8, SP));
4046 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineWideCallrangePrefImm16V8, ACC));
4047 GateRef actualNumArgs = Int32Argument(PARAM_INDEX(BaselineWideCallrangePrefImm16V8, ACTUAL_NUM_ARGS));
4048 GateRef vregId = Int32Argument(PARAM_INDEX(BaselineWideCallrangePrefImm16V8, VREG_ID));
4049 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineWideCallrangePrefImm16V8, HOTNESS_COUNTER));
4050 ProfileOperation callback;
4051 GateRef argv = PtrAdd(sp, PtrMul(ZExtInt8ToPtr(vregId), IntPtr(8))); // 8: byteSize
4052
4053 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
4054 METHOD_ENTRY(acc);
4055 Label noNeedCheckException(env);
4056 Label exit(env);
4057 GateRef jumpSize = INT_PTR(WIDE_CALLRANGE_PREF_IMM16_V8);
4058 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
4059 JSCallArgs callArgs(JSCallMode::CALL_WITH_ARGV);
4060 callArgs.callArgv = { numArgs, argv };
4061 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
4062 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
4063 Bind(&exit);
4064 CHECK_PENDING_EXCEPTION(*result);
4065 Bind(&noNeedCheckException);
4066 Return(*result);
4067 }
4068
GenerateCircuit()4069 void BaselineThrowConstassignmentPrefV8StubBuilder::GenerateCircuit()
4070 {
4071 GateRef glue = PtrArgument(PARAM_INDEX(BaselineThrowConstassignmentPrefV8, GLUE));
4072 GateRef sp = PtrArgument(PARAM_INDEX(BaselineThrowConstassignmentPrefV8, SP));
4073 GateRef v0 = TaggedArgument(PARAM_INDEX(BaselineThrowConstassignmentPrefV8, V0));
4074
4075 GateRef frame = GetFrame(sp);
4076 GateRef acc = GetAccFromFrame(glue, frame);
4077 CallRuntime(glue, RTSTUB_ID(ThrowConstAssignment), { v0 });
4078 DISPATCH_LAST();
4079 Return();
4080 }
4081
GenerateCircuit()4082 void BaselineDeprecatedTonumberPrefV8StubBuilder::GenerateCircuit()
4083 {
4084 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedTonumberPrefV8, GLUE));
4085 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedTonumberPrefV8, SP));
4086 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedTonumberPrefV8, V0));
4087 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4088
4089 auto env = GetEnvironment();
4090 Label valueIsNumber(env);
4091 Label valueNotNumber(env);
4092 Branch(TaggedIsNumber(value), &valueIsNumber, &valueNotNumber);
4093 Bind(&valueIsNumber);
4094 {
4095 Return(value);
4096 }
4097 Bind(&valueNotNumber);
4098 {
4099 GateRef result = CallRuntime(glue, RTSTUB_ID(ToNumber), { value });
4100 CHECK_EXCEPTION_RETURN(result);
4101 }
4102 }
4103
GenerateCircuit()4104 void BaselineWideCallthisrangePrefImm16V8StubBuilder::GenerateCircuit()
4105 {
4106 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideCallthisrangePrefImm16V8, GLUE));
4107 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideCallthisrangePrefImm16V8, SP));
4108 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineWideCallthisrangePrefImm16V8, ACC));
4109 GateRef actualNumArgs = Int32Argument(PARAM_INDEX(BaselineWideCallthisrangePrefImm16V8, ACTUAL_NUM_ARGS));
4110 GateRef vregId = Int32Argument(PARAM_INDEX(BaselineWideCallthisrangePrefImm16V8, VREG_ID));
4111 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineWideCallthisrangePrefImm16V8, HOTNESS_COUNTER));
4112
4113 GateRef thisReg = ZExtInt8ToPtr(vregId);
4114 GateRef thisValue = GetVregValue(glue, sp, thisReg);
4115 GateRef argv = PtrAdd(sp, PtrMul(
4116 PtrAdd(thisReg, IntPtr(1)), IntPtr(8))); // 1: skip this
4117 ProfileOperation callback;
4118
4119 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
4120 METHOD_ENTRY(acc);
4121 Label noNeedCheckException(env);
4122 Label exit(env);
4123 GateRef jumpSize = INT_PTR(WIDE_CALLTHISRANGE_PREF_IMM16_V8);
4124 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
4125 JSCallArgs callArgs(JSCallMode::CALL_THIS_WITH_ARGV);
4126 callArgs.callArgvWithThis = { numArgs, argv, thisValue };
4127 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
4128 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
4129 Bind(&exit);
4130 CHECK_PENDING_EXCEPTION(*result);
4131 Bind(&noNeedCheckException);
4132 Return(*result);
4133 }
4134
GenerateCircuit()4135 void BaselineThrowIfnotobjectPrefV8StubBuilder::GenerateCircuit()
4136 {
4137 GateRef glue = PtrArgument(PARAM_INDEX(BaselineThrowIfnotobjectPrefV8, GLUE));
4138 GateRef sp = PtrArgument(PARAM_INDEX(BaselineThrowIfnotobjectPrefV8, SP));
4139 GateRef v0 = TaggedArgument(PARAM_INDEX(BaselineThrowIfnotobjectPrefV8, V0));
4140
4141 auto env = GetEnvironment();
4142 GateRef frame = GetFrame(sp);
4143 GateRef acc = GetAccFromFrame(glue, frame);
4144 Label isEcmaObject(env);
4145 Label notEcmaObject(env);
4146 Label isHeapObject(env);
4147 Branch(TaggedIsHeapObject(v0), &isHeapObject, ¬EcmaObject);
4148 Bind(&isHeapObject);
4149 Branch(TaggedObjectIsEcmaObject(glue, v0), &isEcmaObject, ¬EcmaObject);
4150 Bind(&isEcmaObject);
4151 {
4152 Return();
4153 }
4154 Bind(¬EcmaObject);
4155 CallRuntime(glue, RTSTUB_ID(ThrowIfNotObject), {});
4156 DISPATCH_LAST();
4157 Return();
4158 }
4159
GenerateCircuit()4160 void BaselineDeprecatedTonumericPrefV8StubBuilder::GenerateCircuit()
4161 {
4162 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedTonumericPrefV8, GLUE));
4163 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedTonumericPrefV8, SP));
4164 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedTonumericPrefV8, V0));
4165 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4166
4167 auto env = GetEnvironment();
4168 Label valueIsNumeric(env);
4169 Label valueNotNumeric(env);
4170 Branch(TaggedIsNumeric(glue, value), &valueIsNumeric, &valueNotNumeric);
4171 Bind(&valueIsNumeric);
4172 {
4173 Return(value);
4174 }
4175 Bind(&valueNotNumeric);
4176 {
4177 GateRef result = CallRuntime(glue, RTSTUB_ID(ToNumeric), { value });
4178 CHECK_EXCEPTION_RETURN(result);
4179 }
4180 }
4181
GenerateCircuit()4182 void BaselineWideSupercallthisrangePrefImm16V8StubBuilder::GenerateCircuit()
4183 {
4184 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideSupercallthisrangePrefImm16V8, GLUE));
4185 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideSupercallthisrangePrefImm16V8, SP));
4186 GateRef range = Int32Argument(PARAM_INDEX(BaselineWideSupercallthisrangePrefImm16V8, RANGE));
4187 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineWideSupercallthisrangePrefImm16V8, V0));
4188
4189 GateRef frame = GetFrame(sp);
4190 GateRef acc = GetAccFromFrame(glue, frame);
4191 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
4192 GateRef res = CallRuntime(glue, RTSTUB_ID(SuperCall),
4193 { currentFunc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) });
4194 CHECK_EXCEPTION_WITH_ACC(res);
4195 }
4196
GenerateCircuit()4197 void BaselineThrowUndefinedifholePrefV8V8StubBuilder::GenerateCircuit()
4198 {
4199 GateRef glue = PtrArgument(PARAM_INDEX(BaselineThrowUndefinedifholePrefV8V8, GLUE));
4200 GateRef sp = PtrArgument(PARAM_INDEX(BaselineThrowUndefinedifholePrefV8V8, SP));
4201 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineThrowUndefinedifholePrefV8V8, V0));
4202 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineThrowUndefinedifholePrefV8V8, V1));
4203
4204 GateRef hole = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4205 auto env = GetEnvironment();
4206 GateRef frame = GetFrame(sp);
4207 GateRef acc = GetAccFromFrame(glue, frame);
4208 Label isHole(env);
4209 Label notHole(env);
4210 Branch(TaggedIsHole(hole), &isHole, ¬Hole);
4211 Bind(¬Hole);
4212 {
4213 Return();
4214 }
4215 Bind(&isHole);
4216 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
4217 CallRuntime(glue, RTSTUB_ID(ThrowUndefinedIfHole), { obj });
4218 DISPATCH_LAST();
4219 Return();
4220 }
4221
GenerateCircuit()4222 void BaselineThrowUndefinedifholewithnamePrefId16StubBuilder::GenerateCircuit()
4223 {
4224 GateRef glue = PtrArgument(PARAM_INDEX(BaselineThrowUndefinedifholewithnamePrefId16, GLUE));
4225 GateRef sp = PtrArgument(PARAM_INDEX(BaselineThrowUndefinedifholewithnamePrefId16, SP));
4226 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineThrowUndefinedifholewithnamePrefId16, STRING_ID));
4227
4228 GateRef frame = GetFrame(sp);
4229 GateRef acc = GetAccFromFrame(glue, frame);
4230 GateRef func = GetFunctionFromFrame(glue, frame);
4231 GateRef method = GetMethodFromFunction(glue, func);
4232 GateRef constpool = GetConstpoolFromMethod(glue, method);
4233 auto env = GetEnvironment();
4234 Label isHole(env);
4235 Label notHole(env);
4236 Branch(TaggedIsHole(acc), &isHole, ¬Hole);
4237 Bind(¬Hole);
4238 {
4239 Return();
4240 }
4241 Bind(&isHole);
4242 GateRef str = GetStringFromConstPool(glue, constpool, stringId);
4243 CallRuntime(glue, RTSTUB_ID(ThrowUndefinedIfHole), { str });
4244 DISPATCH_LAST();
4245 Return();
4246 }
4247
GenerateCircuit()4248 void BaselineDeprecatedNegPrefV8StubBuilder::GenerateCircuit()
4249 {
4250 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedNegPrefV8, GLUE));
4251 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedNegPrefV8, SP));
4252 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedNegPrefV8, V0));
4253 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4254
4255 GateRef frame = GetFrame(sp);
4256 GateRef acc = GetAccFromFrame(glue, frame);
4257 OperationsStubBuilder builder(this);
4258 GateRef result = builder.Neg(glue, value);
4259 CHECK_EXCEPTION_WITH_ACC(result);
4260 }
4261
GenerateCircuit()4262 void BaselineWideSupercallarrowrangePrefImm16V8StubBuilder::GenerateCircuit()
4263 {
4264 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideSupercallarrowrangePrefImm16V8, GLUE));
4265 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideSupercallarrowrangePrefImm16V8, SP));
4266 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineWideSupercallarrowrangePrefImm16V8, ACC));
4267 GateRef range = Int32Argument(PARAM_INDEX(BaselineWideSupercallarrowrangePrefImm16V8, RANGE));
4268 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineWideSupercallarrowrangePrefImm16V8, V0));
4269
4270 GateRef res = CallRuntime(glue, RTSTUB_ID(SuperCall),
4271 { acc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) });
4272 CHECK_EXCEPTION_WITH_ACC(res);
4273 }
4274
GenerateCircuit()4275 void BaselineThrowIfsupernotcorrectcallPrefImm8StubBuilder::GenerateCircuit()
4276 {
4277 GateRef glue = PtrArgument(PARAM_INDEX(BaselineThrowIfsupernotcorrectcallPrefImm8, GLUE));
4278 GateRef sp = PtrArgument(PARAM_INDEX(BaselineThrowIfsupernotcorrectcallPrefImm8, SP));
4279 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineThrowIfsupernotcorrectcallPrefImm8, ACC));
4280 GateRef imm = Int32Argument(PARAM_INDEX(BaselineThrowIfsupernotcorrectcallPrefImm8, IMM));
4281
4282 GateRef res = CallRuntime(glue, RTSTUB_ID(ThrowIfSuperNotCorrectCall),
4283 { Int8ToTaggedInt(imm), acc }); // acc is thisValue
4284 CHECK_EXCEPTION(res);
4285 }
4286
GenerateCircuit()4287 void BaselineDeprecatedNotPrefV8StubBuilder::GenerateCircuit()
4288 {
4289 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedNotPrefV8, GLUE));
4290 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedNotPrefV8, SP));
4291 GateRef index = Int32Argument(PARAM_INDEX(BaselineDeprecatedNotPrefV8, INDEX));
4292 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(index));
4293
4294 GateRef frame = GetFrame(sp);
4295 GateRef acc = GetAccFromFrame(glue, frame);
4296 OperationsStubBuilder builder(this);
4297 GateRef result = builder.Not(glue, value);
4298 CHECK_EXCEPTION_WITH_ACC(result);
4299 }
4300
GenerateCircuit()4301 void BaselineWideLdobjbyindexPrefImm32StubBuilder::GenerateCircuit()
4302 {
4303 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideLdobjbyindexPrefImm32, GLUE));
4304 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideLdobjbyindexPrefImm32, SP));
4305 GateRef index = Int32Argument(PARAM_INDEX(BaselineWideLdobjbyindexPrefImm32, INDEX));
4306 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineWideLdobjbyindexPrefImm32, SLOT_ID));
4307 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
4308
4309 auto env = GetEnvironment();
4310 GateRef acc = GetAccFromFrame(glue, frame);
4311 Label fastPath(env);
4312 Label slowPath(env);
4313 Branch(TaggedIsHeapObject(acc), &fastPath, &slowPath);
4314 Bind(&fastPath);
4315 {
4316 SetCurrentGlobalEnv(GetGlobalEnv(glue));
4317 GateRef result = GetPropertyByIndex(glue, acc, index, callback);
4318 Label notHole(env);
4319 Branch(TaggedIsHole(result), &slowPath, ¬Hole);
4320 Bind(¬Hole);
4321 CHECK_EXCEPTION_WITH_ACC(result);
4322 }
4323 Bind(&slowPath);
4324 {
4325 GateRef result = CallRuntime(glue, RTSTUB_ID(LdObjByIndex),
4326 { acc, IntToTaggedInt(index), TaggedFalse(), Undefined() });
4327 CHECK_EXCEPTION_WITH_ACC(result);
4328 }
4329 }
4330
GenerateCircuit()4331 void BaselineThrowIfsupernotcorrectcallPrefImm16StubBuilder::GenerateCircuit()
4332 {
4333 GateRef glue = PtrArgument(PARAM_INDEX(BaselineThrowIfsupernotcorrectcallPrefImm16, GLUE));
4334 GateRef sp = PtrArgument(PARAM_INDEX(BaselineThrowIfsupernotcorrectcallPrefImm16, SP));
4335 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineThrowIfsupernotcorrectcallPrefImm16, ACC));
4336 GateRef imm = Int32Argument(PARAM_INDEX(BaselineThrowIfsupernotcorrectcallPrefImm16, IMM));
4337
4338 GateRef res = CallRuntime(glue, RTSTUB_ID(ThrowIfSuperNotCorrectCall),
4339 { Int16ToTaggedInt(imm), acc }); // acc is thisValue
4340 CHECK_EXCEPTION(res);
4341 }
4342
GenerateCircuit()4343 void BaselineDeprecatedIncPrefV8StubBuilder::GenerateCircuit()
4344 {
4345 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedIncPrefV8, GLUE));
4346 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedIncPrefV8, SP));
4347 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedIncPrefV8, V0));
4348 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4349
4350 GateRef frame = GetFrame(sp);
4351 GateRef acc = GetAccFromFrame(glue, frame);
4352 OperationsStubBuilder builder(this);
4353 GateRef result = builder.Inc(glue, value);
4354 CHECK_EXCEPTION_WITH_ACC(result);
4355 }
4356
GenerateCircuit()4357 void BaselineWideStobjbyindexPrefV8Imm32StubBuilder::GenerateCircuit()
4358 {
4359 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideStobjbyindexPrefV8Imm32, GLUE));
4360 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideStobjbyindexPrefV8Imm32, SP));
4361 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineWideStobjbyindexPrefV8Imm32, V0));
4362 GateRef index = Int32Argument(PARAM_INDEX(BaselineWideStobjbyindexPrefV8Imm32, INDEX));
4363 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineWideStobjbyindexPrefV8Imm32, SLOT_ID));
4364 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
4365
4366 GateRef receiver = GetVregValue(glue, sp, ZExtInt32ToPtr(v0));
4367 GateRef acc = GetAccFromFrame(glue, frame);
4368 auto env = GetEnvironment();
4369 Label fastPath(env);
4370 Label slowPath(env);
4371 Branch(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
4372 Bind(&fastPath);
4373 {
4374 SetCurrentGlobalEnv(GetGlobalEnv(glue));
4375 GateRef result = SetPropertyByIndex(glue, receiver, index, acc, false);
4376 Label notHole(env);
4377 Branch(TaggedIsHole(result), &slowPath, ¬Hole);
4378 Bind(¬Hole);
4379 CHECK_EXCEPTION(result);
4380 }
4381 Bind(&slowPath);
4382 {
4383 GateRef result = CallRuntime(glue, RTSTUB_ID(StObjByIndex),
4384 { receiver, IntToTaggedInt(index), acc });
4385 CHECK_EXCEPTION(result);
4386 }
4387 }
4388
GenerateCircuit()4389 void BaselineDeprecatedDecPrefV8StubBuilder::GenerateCircuit()
4390 {
4391 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedDecPrefV8, GLUE));
4392 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedDecPrefV8, SP));
4393 GateRef index = Int32Argument(PARAM_INDEX(BaselineDeprecatedDecPrefV8, INDEX));
4394 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(index));
4395
4396 GateRef frame = GetFrame(sp);
4397 GateRef acc = GetAccFromFrame(glue, frame);
4398 OperationsStubBuilder builder(this);
4399 GateRef result = builder.Dec(glue, value);
4400 CHECK_EXCEPTION_WITH_ACC(result);
4401 }
4402
GenerateCircuit()4403 void BaselineWideStownbyindexPrefV8Imm32StubBuilder::GenerateCircuit()
4404 {
4405 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideStownbyindexPrefV8Imm32, GLUE));
4406 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideStownbyindexPrefV8Imm32, SP));
4407 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineWideStownbyindexPrefV8Imm32, V0));
4408 GateRef index = Int32Argument(PARAM_INDEX(BaselineWideStownbyindexPrefV8Imm32, INDEX));
4409 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineWideStownbyindexPrefV8Imm32, SLOT_ID));
4410 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
4411 GateRef acc = GetAccFromFrame(glue, frame);
4412 GateRef receiver = GetVregValue(glue, sp, ZExtInt32ToPtr(v0));
4413
4414 auto env = GetEnvironment();
4415 Label isHeapObject(env);
4416 Label slowPath(env);
4417 Branch(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath);
4418 Bind(&isHeapObject);
4419 Label notClassConstructor(env);
4420 Branch(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
4421 Bind(¬ClassConstructor);
4422 Label notClassPrototype(env);
4423 Branch(IsClassPrototype(glue, receiver), &slowPath, ¬ClassPrototype);
4424 Bind(¬ClassPrototype);
4425 {
4426 // fast path
4427 SetCurrentGlobalEnv(GetGlobalEnv(glue));
4428 GateRef result = SetPropertyByIndex(glue, receiver, index, acc, true); // acc is value
4429 Label notHole(env);
4430 Branch(TaggedIsHole(result), &slowPath, ¬Hole);
4431 Bind(¬Hole);
4432 CHECK_EXCEPTION(result);
4433 }
4434 Bind(&slowPath);
4435 {
4436 GateRef result = CallRuntime(glue, RTSTUB_ID(StOwnByIndex),
4437 { receiver, IntToTaggedInt(index), acc });
4438 CHECK_EXCEPTION(result);
4439 }
4440 }
4441
GenerateCircuit()4442 void BaselineDeprecatedCallarg0PrefV8StubBuilder::GenerateCircuit()
4443 {
4444 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallarg0PrefV8, GLUE));
4445 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallarg0PrefV8, SP));
4446 GateRef funcReg = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallarg0PrefV8, FUNC_REG));
4447 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallarg0PrefV8, HOTNESS_COUNTER));
4448 ProfileOperation callback;
4449 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(funcReg));
4450 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
4451
4452 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
4453 auto env = GetEnvironment();
4454 Label noNeedCheckException(env);
4455 Label exit(env);
4456 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARG0);
4457 GateRef jumpSize = INT_PTR(DEPRECATED_CALLARG0_PREF_V8);
4458 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_ARG0);
4459 callArgs.callArgs = { 0, 0, 0 };
4460 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
4461 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
4462 Bind(&exit);
4463 CHECK_PENDING_EXCEPTION(*result);
4464 Bind(&noNeedCheckException);
4465 Return(*result);
4466 }
4467
GenerateCircuit()4468 void BaselineWideCopyrestargsPrefImm16StubBuilder::GenerateCircuit()
4469 {
4470 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideCopyrestargsPrefImm16, GLUE));
4471 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideCopyrestargsPrefImm16, SP));
4472 GateRef restIdx = Int32Argument(PARAM_INDEX(BaselineWideCopyrestargsPrefImm16, INDEX));
4473
4474 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
4475 GateRef res = CallRuntime(glue, RTSTUB_ID(CopyRestArgs), { IntToTaggedInt(restIdx) });
4476 CHECK_EXCEPTION_WITH_ACC(res);
4477 }
4478
GenerateCircuit()4479 void BaselineDeprecatedCallarg1PrefV8V8StubBuilder::GenerateCircuit()
4480 {
4481 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallarg1PrefV8V8, GLUE));
4482 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallarg1PrefV8V8, SP));
4483 GateRef funcReg = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallarg1PrefV8V8, FUNC_REG));
4484 GateRef a0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallarg1PrefV8V8, A0));
4485 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallarg1PrefV8V8, HOTNESS_COUNTER));
4486 ProfileOperation callback;
4487 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4488 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(funcReg));
4489 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
4490
4491 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
4492 auto env = GetEnvironment();
4493 Label noNeedCheckException(env);
4494 Label exit(env);
4495 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARG1);
4496 GateRef jumpSize = INT_PTR(DEPRECATED_CALLARG1_PREF_V8_V8);
4497 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_ARG1);
4498 callArgs.callArgs = { a0Value, 0, 0 };
4499 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
4500 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
4501 Bind(&exit);
4502 CHECK_PENDING_EXCEPTION(*result);
4503 Bind(&noNeedCheckException);
4504 Return(*result);
4505 }
4506
GenerateCircuit()4507 void BaselineWideLdlexvarPrefImm16Imm16StubBuilder::GenerateCircuit()
4508 {
4509 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideLdlexvarPrefImm16Imm16, GLUE));
4510 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideLdlexvarPrefImm16Imm16, SP));
4511 GateRef level = Int32Argument(PARAM_INDEX(BaselineWideLdlexvarPrefImm16Imm16, LEVEL));
4512 GateRef slot = Int32Argument(PARAM_INDEX(BaselineWideLdlexvarPrefImm16Imm16, SLOT));
4513
4514 GateRef state = GetFrame(sp);
4515 auto env = GetEnvironment();
4516 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
4517 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
4518
4519 Label loopHead(env);
4520 Label loopEnd(env);
4521 Label afterLoop(env);
4522 Branch(Int32LessThan(*i, level), &loopHead, &afterLoop);
4523 LoopBegin(&loopHead);
4524 currentEnv = GetParentEnv(glue, *currentEnv);
4525 i = Int32Add(*i, Int32(1));
4526 Branch(Int32LessThan(*i, level), &loopEnd, &afterLoop);
4527 Bind(&loopEnd);
4528 LoopEnd(&loopHead);
4529 Bind(&afterLoop);
4530 GateRef variable = GetPropertiesFromLexicalEnv(glue, *currentEnv, slot);
4531 Return(variable);
4532 }
4533
GenerateCircuit()4534 void BaselineDeprecatedCallargs2PrefV8V8V8StubBuilder::GenerateCircuit()
4535 {
4536 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallargs2PrefV8V8V8, GLUE));
4537 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallargs2PrefV8V8V8, SP));
4538 GateRef funcReg = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallargs2PrefV8V8V8, FUNC_REG));
4539 GateRef a0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallargs2PrefV8V8V8, A0));
4540 GateRef a1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallargs2PrefV8V8V8, A1));
4541 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallargs2PrefV8V8V8, HOTNESS_COUNTER));
4542 ProfileOperation callback;
4543 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(funcReg));
4544 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4545 GateRef a1Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a1));
4546 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
4547
4548 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
4549 auto env = GetEnvironment();
4550 Label noNeedCheckException(env);
4551 Label exit(env);
4552 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARGS2);
4553 GateRef jumpSize = INT_PTR(DEPRECATED_CALLARGS2_PREF_V8_V8_V8);
4554 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_ARG2);
4555 callArgs.callArgs = { a0Value, a1Value, 0 };
4556 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
4557 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
4558 Bind(&exit);
4559 CHECK_PENDING_EXCEPTION(*result);
4560 Bind(&noNeedCheckException);
4561 Return(*result);
4562 }
4563
GenerateCircuit()4564 void BaselineWideStlexvarPrefImm16Imm16StubBuilder::GenerateCircuit()
4565 {
4566 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideStlexvarPrefImm16Imm16, GLUE));
4567 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideStlexvarPrefImm16Imm16, SP));
4568 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineWideStlexvarPrefImm16Imm16, ACC));
4569 GateRef level = Int32Argument(PARAM_INDEX(BaselineWideStlexvarPrefImm16Imm16, LEVEL));
4570 GateRef slot = Int32Argument(PARAM_INDEX(BaselineWideStlexvarPrefImm16Imm16, SLOT));
4571
4572 GateRef state = GetFrame(sp);
4573 auto env = GetEnvironment();
4574 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
4575 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
4576
4577 Label loopHead(env);
4578 Label loopEnd(env);
4579 Label afterLoop(env);
4580 Branch(Int32LessThan(*i, level), &loopHead, &afterLoop);
4581 LoopBegin(&loopHead);
4582 currentEnv = GetParentEnv(glue, *currentEnv);
4583 i = Int32Add(*i, Int32(1));
4584 Branch(Int32LessThan(*i, level), &loopEnd, &afterLoop);
4585 Bind(&loopEnd);
4586 LoopEnd(&loopHead);
4587 Bind(&afterLoop);
4588 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, acc);
4589 Return();
4590 }
4591
GenerateCircuit()4592 void BaselineDeprecatedCallargs3PrefV8V8V8V8StubBuilder::GenerateCircuit()
4593 {
4594 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallargs3PrefV8V8V8V8, GLUE));
4595 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallargs3PrefV8V8V8V8, SP));
4596 GateRef funcReg = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallargs3PrefV8V8V8V8, FUNC_REG));
4597 GateRef a0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallargs3PrefV8V8V8V8, A0));
4598 GateRef a1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallargs3PrefV8V8V8V8, A1));
4599 GateRef a2 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallargs3PrefV8V8V8V8, A2));
4600 ProfileOperation callback;
4601 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(funcReg));
4602 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4603 GateRef a1Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a1));
4604 GateRef a2Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a2));
4605
4606 GateRef method = GetMethodFromFunction(glue, GetFunctionFromFrame(glue, GetFrame(sp)));
4607 GateRef hotnessCounter = GetHotnessCounterFromMethod(method);
4608 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
4609
4610 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
4611 auto env = GetEnvironment();
4612 Label noNeedCheckException(env);
4613 Label exit(env);
4614 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARGS3);
4615 GateRef jumpSize = INT_PTR(DEPRECATED_CALLARGS3_PREF_V8_V8_V8_V8);
4616 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_ARG3);
4617 callArgs.callArgs = { a0Value, a1Value, a2Value };
4618 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
4619 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
4620 Bind(&exit);
4621 CHECK_PENDING_EXCEPTION(*result);
4622 Bind(&noNeedCheckException);
4623 Return(*result);
4624 }
4625
GenerateCircuit()4626 void BaselineWideGetmodulenamespacePrefImm16StubBuilder::GenerateCircuit()
4627 {
4628 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideGetmodulenamespacePrefImm16, GLUE));
4629 GateRef index = Int32Argument(PARAM_INDEX(BaselineWideGetmodulenamespacePrefImm16, INDEX));
4630
4631 GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(GetModuleNamespaceByIndex), { Int16ToTaggedInt(index) });
4632 Return(moduleRef);
4633 }
4634
GenerateCircuit()4635 void BaselineDeprecatedCallrangePrefImm16V8StubBuilder::GenerateCircuit()
4636 {
4637 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallrangePrefImm16V8, GLUE));
4638 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallrangePrefImm16V8, SP));
4639 GateRef actualNumArgs = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallrangePrefImm16V8, INDEX));
4640 GateRef funcReg = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallrangePrefImm16V8, FUNC_REG));
4641 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallrangePrefImm16V8, HOTNESS_COUNTER));
4642 ProfileOperation callback;
4643 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(funcReg));
4644 GateRef argv = PtrAdd(sp, PtrMul(
4645 PtrAdd(ZExtInt8ToPtr(funcReg), IntPtr(1)), IntPtr(8))); // 1: skip function
4646 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
4647
4648 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
4649 auto env = GetEnvironment();
4650 Label noNeedCheckException(env);
4651 Label exit(env);
4652 GateRef jumpSize = INT_PTR(DEPRECATED_CALLRANGE_PREF_IMM16_V8);
4653 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
4654 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_WITH_ARGV);
4655 callArgs.callArgv = { numArgs, argv };
4656 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
4657 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
4658 Bind(&exit);
4659 CHECK_PENDING_EXCEPTION(*result);
4660 Bind(&noNeedCheckException);
4661 Return(*result);
4662 }
4663
GenerateCircuit()4664 void BaselineWideStmodulevarPrefImm16StubBuilder::GenerateCircuit()
4665 {
4666 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideStmodulevarPrefImm16, GLUE));
4667 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineWideStmodulevarPrefImm16, ACC));
4668 GateRef index = Int32Argument(PARAM_INDEX(BaselineWideStmodulevarPrefImm16, INDEX));
4669
4670 CallRuntime(glue, RTSTUB_ID(StModuleVarByIndex), { Int16ToTaggedInt(index), acc });
4671 Return();
4672 }
4673
GenerateCircuit()4674 void BaselineDeprecatedCallspreadPrefV8V8V8StubBuilder::GenerateCircuit()
4675 {
4676 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallspreadPrefV8V8V8, GLUE));
4677 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallspreadPrefV8V8V8, SP));
4678 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallspreadPrefV8V8V8, V0));
4679 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallspreadPrefV8V8V8, V1));
4680 GateRef v2 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallspreadPrefV8V8V8, V2));
4681
4682 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4683 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
4684 GateRef array = GetVregValue(glue, sp, ZExtInt8ToPtr(v2));
4685
4686 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
4687 GateRef res = CallRuntime(glue, RTSTUB_ID(CallSpread), { func, obj, array });
4688 CHECK_PENDING_EXCEPTION(res);
4689 }
4690
GenerateCircuit()4691 void BaselineWideLdlocalmodulevarPrefImm16StubBuilder::GenerateCircuit()
4692 {
4693 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideLdlocalmodulevarPrefImm16, GLUE));
4694 GateRef index = Int32Argument(PARAM_INDEX(BaselineWideLdlocalmodulevarPrefImm16, INDEX));
4695
4696 GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(LdLocalModuleVarByIndex), { Int16ToTaggedInt(index) });
4697
4698 Return(moduleRef);
4699 }
4700
GenerateCircuit()4701 void BaselineDeprecatedCallthisrangePrefImm16V8StubBuilder::GenerateCircuit()
4702 {
4703 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallthisrangePrefImm16V8, GLUE));
4704 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCallthisrangePrefImm16V8, SP));
4705 GateRef index = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallthisrangePrefImm16V8, INDEX));
4706 GateRef funcReg = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallthisrangePrefImm16V8, FUNC_REG));
4707 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineDeprecatedCallthisrangePrefImm16V8, HOTNESS_COUNTER));
4708 ProfileOperation callback;
4709 funcReg = ZExtInt8ToPtr(funcReg);
4710 GateRef func = GetVregValue(glue, sp, funcReg);
4711 GateRef thisValue = GetVregValue(glue, sp, PtrAdd(funcReg, IntPtr(1)));
4712 GateRef argv = PtrAdd(sp, PtrMul(
4713 PtrAdd(funcReg, IntPtr(2)), IntPtr(8))); // 2: skip function&this
4714 GateRef acc = GetAccFromFrame(glue, GetFrame(sp));
4715
4716 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
4717 auto env = GetEnvironment();
4718 Label noNeedCheckException(env);
4719 Label exit(env);
4720 GateRef actualNumArgs = Int32Sub(index, Int32(1)); // 1: exclude this
4721 GateRef jumpSize = INT_PTR(DEPRECATED_CALLTHISRANGE_PREF_IMM16_V8);
4722 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
4723 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_THIS_WITH_ARGV);
4724 callArgs.callArgvWithThis = { numArgs, argv, thisValue };
4725 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
4726 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
4727 Bind(&exit);
4728 CHECK_PENDING_EXCEPTION(*result);
4729 Bind(&noNeedCheckException);
4730 Return(*result);
4731 }
4732
GenerateCircuit()4733 void BaselineWideLdexternalmodulevarPrefImm16StubBuilder::GenerateCircuit()
4734 {
4735 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideLdexternalmodulevarPrefImm16, GLUE));
4736 GateRef index = Int32Argument(PARAM_INDEX(BaselineWideLdexternalmodulevarPrefImm16, INDEX));
4737
4738 GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(LdExternalModuleVarByIndex), { Int16ToTaggedInt(index) });
4739 Return(moduleRef);
4740 }
4741
4742 // GLUE, SP, METHOD_ID, LITERAL_ID, LENGTH, VREG_IDS
GenerateCircuit()4743 void BaselineDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8StubBuilder::GenerateCircuit()
4744 {
4745 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8, GLUE));
4746 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8, SP));
4747 GateRef methodId = Int32Argument(
4748 PARAM_INDEX(BaselineDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8, METHOD_ID));
4749 GateRef literalId = Int32Argument(
4750 PARAM_INDEX(BaselineDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8, LITERAL_ID));
4751 GateRef length = Int32Argument(
4752 PARAM_INDEX(BaselineDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8, LENGTH));
4753 GateRef vregIds = Int32Argument(
4754 PARAM_INDEX(BaselineDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8, VREG_IDS));
4755
4756 GateRef vRegId0 = Int32And(vregIds, Int32(ONE_BYTE_ALL_ONE));
4757 GateRef vregId1 = Int32And(Int32LSR(vregIds, Int32(ONE_BYTE_SIZE)), Int32(ONE_BYTE_ALL_ONE));
4758
4759 GateRef frame = GetFrame(sp);
4760 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
4761 GateRef method = GetMethodFromFunction(glue, currentFunc);
4762 GateRef constpool = GetConstpoolFromMethod(glue, method);
4763 GateRef lexicalEnv = GetVregValue(glue, sp, ZExtInt32ToPtr(vRegId0));
4764 GateRef proto = GetVregValue(glue, sp, ZExtInt32ToPtr(vregId1));
4765
4766 GateRef acc = GetAccFromFrame(glue, frame);
4767 auto env = GetEnvironment();
4768 GateRef module = GetModuleFromFunction(glue, currentFunc);
4769 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateClassWithBuffer),
4770 { proto, lexicalEnv, constpool,
4771 IntToTaggedInt(methodId),
4772 IntToTaggedInt(literalId), module,
4773 IntToTaggedInt(length)});
4774
4775 Label isException(env);
4776 Label isNotException(env);
4777 Branch(TaggedIsException(res), &isException, &isNotException);
4778 Bind(&isException);
4779 {
4780 DISPATCH_LAST_WITH_ACC();
4781 Return(res);
4782 }
4783 Bind(&isNotException);
4784 Return(res);
4785 }
4786
GenerateCircuit()4787 void BaselineWideLdpatchvarPrefImm16StubBuilder::GenerateCircuit()
4788 {
4789 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideLdpatchvarPrefImm16, GLUE));
4790 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideLdpatchvarPrefImm16, SP));
4791 GateRef index = Int32Argument(PARAM_INDEX(BaselineWideLdpatchvarPrefImm16, INDEX));
4792
4793 GateRef result = CallRuntime(glue, RTSTUB_ID(LdPatchVar), { Int16ToTaggedInt(index) });
4794 CHECK_EXCEPTION_RETURN(result);
4795 }
4796
GenerateCircuit()4797 void BaselineDeprecatedResumegeneratorPrefV8StubBuilder::GenerateCircuit()
4798 {
4799 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedResumegeneratorPrefV8, GLUE));
4800 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedResumegeneratorPrefV8, SP));
4801 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDeprecatedResumegeneratorPrefV8, ACC));
4802 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedResumegeneratorPrefV8, V0));
4803 (void)glue;
4804 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4805
4806 auto env = GetEnvironment();
4807 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4808 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
4809 GateRef curFunc = GetFunctionFromFrame(glue, GetFrame(sp));
4810 CallNGCRuntime(glue, RTSTUB_ID(StartCallTimer), { glue, curFunc, False() });
4811 #endif
4812
4813 Label isAsyncGeneratorObj(env);
4814 Label notAsyncGeneratorObj(env);
4815 Label dispatch(env);
4816 Branch(TaggedIsAsyncGeneratorObject(glue, obj), &isAsyncGeneratorObj, ¬AsyncGeneratorObj);
4817 Bind(&isAsyncGeneratorObj);
4818 {
4819 GateRef resumeResultOffset = IntPtr(JSAsyncGeneratorObject::GENERATOR_RESUME_RESULT_OFFSET);
4820 varAcc = Load(VariableType::JS_ANY(), glue, obj, resumeResultOffset);
4821 Jump(&dispatch);
4822 }
4823 Bind(¬AsyncGeneratorObj);
4824 {
4825 GateRef resumeResultOffset = IntPtr(JSGeneratorObject::GENERATOR_RESUME_RESULT_OFFSET);
4826 varAcc = Load(VariableType::JS_ANY(), glue, obj, resumeResultOffset);
4827 Jump(&dispatch);
4828 }
4829 Bind(&dispatch);
4830 Return(*varAcc);
4831 }
4832
GenerateCircuit()4833 void BaselineWideStpatchvarPrefImm16StubBuilder::GenerateCircuit()
4834 {
4835 GateRef glue = PtrArgument(PARAM_INDEX(BaselineWideStpatchvarPrefImm16, GLUE));
4836 GateRef sp = PtrArgument(PARAM_INDEX(BaselineWideStpatchvarPrefImm16, SP));
4837 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineWideStpatchvarPrefImm16, ACC));
4838 GateRef index = Int32Argument(PARAM_INDEX(BaselineWideStpatchvarPrefImm16, INDEX));
4839
4840 GateRef result = CallRuntime(glue, RTSTUB_ID(StPatchVar), { Int16ToTaggedInt(index), acc });
4841 CHECK_EXCEPTION(result);
4842 }
4843
GenerateCircuit()4844 void BaselineDeprecatedGetresumemodePrefV8StubBuilder::GenerateCircuit()
4845 {
4846 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedGetresumemodePrefV8, GLUE));
4847 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedGetresumemodePrefV8, SP));
4848 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDeprecatedGetresumemodePrefV8, ACC));
4849 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedGetresumemodePrefV8, V0));
4850 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4851
4852 auto env = GetEnvironment();
4853 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4854
4855 Label isAsyncGeneratorObj(env);
4856 Label notAsyncGeneratorObj(env);
4857 Label dispatch(env);
4858 Branch(TaggedIsAsyncGeneratorObject(glue, obj), &isAsyncGeneratorObj, ¬AsyncGeneratorObj);
4859 Bind(&isAsyncGeneratorObj);
4860 {
4861 varAcc = IntToTaggedPtr(GetResumeModeFromAsyncGeneratorObject(obj));
4862 Jump(&dispatch);
4863 }
4864 Bind(¬AsyncGeneratorObj);
4865 {
4866 varAcc = IntToTaggedPtr(GetResumeModeFromGeneratorObject(obj));
4867 Jump(&dispatch);
4868 }
4869 Bind(&dispatch);
4870 Return(*varAcc);
4871 }
4872
GenerateCircuit()4873 void BaselineDeprecatedGettemplateobjectPrefV8StubBuilder::GenerateCircuit()
4874 {
4875 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedGettemplateobjectPrefV8, GLUE));
4876 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedGettemplateobjectPrefV8, SP));
4877 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedGettemplateobjectPrefV8, V0));
4878 GateRef literal = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4879
4880 GateRef frame = GetFrame(sp);
4881 GateRef acc = GetAccFromFrame(glue, frame);
4882 GateRef result = CallRuntime(glue, RTSTUB_ID(GetTemplateObject), { literal });
4883 CHECK_EXCEPTION_WITH_ACC(result);
4884 }
4885
GenerateCircuit()4886 void BaselineDeprecatedDelobjpropPrefV8V8StubBuilder::GenerateCircuit()
4887 {
4888 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedDelobjpropPrefV8V8, GLUE));
4889 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedDelobjpropPrefV8V8, SP));
4890 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedDelobjpropPrefV8V8, V0));
4891 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedDelobjpropPrefV8V8, V1));
4892
4893 GateRef frame = GetFrame(sp);
4894 GateRef acc = GetAccFromFrame(glue, frame);
4895 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4896 GateRef prop = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
4897
4898 GateRef result = CallRuntime(glue, RTSTUB_ID(DelObjProp), { obj, prop });
4899 CHECK_EXCEPTION_WITH_ACC(result);
4900 }
4901
4902 // GLUE, SP, PC, V0, V1
GenerateCircuit()4903 void BaselineDeprecatedSuspendgeneratorPrefV8V8StubBuilder::GenerateCircuit()
4904 {
4905 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedSuspendgeneratorPrefV8V8, GLUE));
4906 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedSuspendgeneratorPrefV8V8, SP));
4907 GateRef curPcOffset = Int32Argument(PARAM_INDEX(BaselineDeprecatedSuspendgeneratorPrefV8V8, OFFSET));
4908 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedSuspendgeneratorPrefV8V8, V0));
4909 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedSuspendgeneratorPrefV8V8, V1));
4910 ProfileOperation callback;
4911
4912 GateRef frame = GetFrame(sp);
4913 GateRef func = GetFunctionFromFrame(glue, frame);
4914 GateRef method = GetMethodFromFunction(glue, func);
4915 GateRef constpool = GetConstpoolFromMethod(glue, method);
4916 GateRef acc = GetAccFromFrame(glue, frame);
4917 GateRef hotnessCounter = GetHotnessCounterFromMethod(method);
4918 GateRef profileTypeInfo = GetProfileTypeInfoFromFunction(glue, func);
4919
4920 auto env = GetEnvironment();
4921 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
4922 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
4923 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
4924 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
4925 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4926 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
4927 GateRef genObj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4928 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
4929
4930 Label isBaselineBuiltinFrame(env);
4931 Label notBaselineBuiltinFrame(env);
4932 Label pcEqualNullptr(env);
4933 Label pcNotEqualNullptr(env);
4934 Label pcEqualBaseline(env);
4935 Label pcNotEqualBaseline(env);
4936 Label updateHotness(env);
4937 Label isStable(env);
4938 Label tryContinue(env);
4939 Label dispatch(env);
4940 Label slowPath(env);
4941
4942 GateRef res = CallRuntime(glue, RTSTUB_ID(SuspendGenerator), { genObj, value });
4943 Label isException(env);
4944 Label notException(env);
4945 Branch(TaggedIsException(res), &isException, ¬Exception);
4946 Bind(&isException);
4947 {
4948 DISPATCH_LAST();
4949 Return();
4950 }
4951 Bind(¬Exception);
4952 varAcc = res;
4953 Branch(TaggedIsUndefined(*varProfileTypeInfo), &updateHotness, &isStable);
4954 Bind(&isStable);
4955 {
4956 Branch(ProfilerStubBuilder(env).IsProfileTypeInfoDumped(*varProfileTypeInfo, callback), &tryContinue,
4957 &updateHotness);
4958 }
4959 Bind(&updateHotness);
4960 {
4961 GateRef offset = Int32Not(curPcOffset);
4962 UPDATE_HOTNESS(*varSp, callback);
4963 SetHotnessCounter(glue, method, *varHotnessCounter);
4964 Jump(&tryContinue);
4965 }
4966
4967 Bind(&tryContinue);
4968 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
4969 GateRef curFunc = GetFunctionFromFrame(glue, frame);
4970 CallNGCRuntime(glue, RTSTUB_ID(EndCallTimer), { glue, curFunc });
4971 #endif
4972 GateRef currentSp = *varSp;
4973 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), frame,
4974 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
4975 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
4976 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
4977 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
4978 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
4979 Bind(&isBaselineBuiltinFrame);
4980 {
4981 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
4982 Jump(¬BaselineBuiltinFrame);
4983 }
4984 Bind(¬BaselineBuiltinFrame);
4985 prevState = GetFrame(*varSp);
4986 GateRef varPc = GetPcFromFrame(*prevState);
4987 Branch(IntPtrEqual(varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
4988 Bind(&pcEqualNullptr);
4989 {
4990 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { currentSp });
4991 Return();
4992 }
4993 Bind(&pcNotEqualNullptr);
4994 BRANCH(IntPtrEqual(varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
4995 Bind(&pcEqualBaseline);
4996 {
4997 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturnBaseline), { glue, *varAcc, *varSp, currentSp });
4998 Return();
4999 }
5000 Bind(&pcNotEqualBaseline);
5001 {
5002 GateRef function = GetFunctionFromFrame(glue, *prevState);
5003 GateRef prevMethod = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
5004 varConstpool = GetConstpoolFromMethod(glue, prevMethod);
5005 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
5006 varHotnessCounter = GetHotnessCounterFromMethod(prevMethod);
5007 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
5008 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
5009 { glue, currentSp, varPc, *varConstpool, *varProfileTypeInfo,
5010 *varAcc, *varHotnessCounter, jumpSize });
5011 Return();
5012 }
5013 }
5014
GenerateCircuit()5015 void BaselineDeprecatedAsyncfunctionawaituncaughtPrefV8V8StubBuilder::GenerateCircuit()
5016 {
5017 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionawaituncaughtPrefV8V8, GLUE));
5018 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionawaituncaughtPrefV8V8, SP));
5019 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionawaituncaughtPrefV8V8, V0));
5020 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionawaituncaughtPrefV8V8, V1));
5021 GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5022 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
5023
5024 GateRef frame = GetFrame(sp);
5025 GateRef acc = GetAccFromFrame(glue, frame);
5026 GateRef result = CallRuntime(glue, RTSTUB_ID(AsyncFunctionAwaitUncaught), { asyncFuncObj, value });
5027 CHECK_EXCEPTION_WITH_ACC(result);
5028 }
5029
GenerateCircuit()5030 void BaselineDeprecatedCopydatapropertiesPrefV8V8StubBuilder::GenerateCircuit()
5031 {
5032 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCopydatapropertiesPrefV8V8, GLUE));
5033 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCopydatapropertiesPrefV8V8, SP));
5034 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCopydatapropertiesPrefV8V8, V0));
5035 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCopydatapropertiesPrefV8V8, V1));
5036 GateRef dst = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5037 GateRef src = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
5038
5039 GateRef frame = GetFrame(sp);
5040 GateRef acc = GetAccFromFrame(glue, frame);
5041 GateRef result = CallRuntime(glue, RTSTUB_ID(CopyDataProperties), { dst, src });
5042 CHECK_EXCEPTION_WITH_ACC(result);
5043 }
5044
GenerateCircuit()5045 void BaselineDeprecatedSetobjectwithprotoPrefV8V8StubBuilder::GenerateCircuit()
5046 {
5047 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedSetobjectwithprotoPrefV8V8, GLUE));
5048 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedSetobjectwithprotoPrefV8V8, SP));
5049 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDeprecatedSetobjectwithprotoPrefV8V8, ACC));
5050 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedSetobjectwithprotoPrefV8V8, V0));
5051 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedSetobjectwithprotoPrefV8V8, V1));
5052
5053 GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5054 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
5055
5056 auto env = GetEnvironment();
5057 GateRef result = CallRuntime(glue, RTSTUB_ID(SetObjectWithProto), { proto, obj });
5058 Label notException(env);
5059 CHECK_EXCEPTION_WITH_JUMP_RETURN(result, ¬Exception);
5060 Bind(¬Exception);
5061 Return(result);
5062 }
5063
GenerateCircuit()5064 void BaselineDeprecatedLdobjbyvaluePrefV8V8StubBuilder::GenerateCircuit()
5065 {
5066 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdobjbyvaluePrefV8V8, GLUE));
5067 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdobjbyvaluePrefV8V8, SP));
5068 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdobjbyvaluePrefV8V8, V0));
5069 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdobjbyvaluePrefV8V8, V1));
5070 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5071 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
5072
5073 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
5074 GateRef result = builder.DeprecatedLoadObjByValue(glue, receiver, propKey);
5075 CHECK_EXCEPTION_RETURN(result);
5076 }
5077
GenerateCircuit()5078 void BaselineDeprecatedLdsuperbyvaluePrefV8V8StubBuilder::GenerateCircuit()
5079 {
5080 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdsuperbyvaluePrefV8V8, GLUE));
5081 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdsuperbyvaluePrefV8V8, SP));
5082 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdsuperbyvaluePrefV8V8, V0));
5083 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdsuperbyvaluePrefV8V8, V1));
5084
5085 GateRef frame = GetFrame(sp);
5086 GateRef acc = GetAccFromFrame(glue, frame);
5087 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5088 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
5089
5090 GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { receiver, propKey }); // sp for thisFunc
5091 CHECK_EXCEPTION_WITH_ACC(result);
5092 }
5093
GenerateCircuit()5094 void BaselineDeprecatedLdobjbyindexPrefV8Imm32StubBuilder::GenerateCircuit()
5095 {
5096 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdobjbyindexPrefV8Imm32, GLUE));
5097 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdobjbyindexPrefV8Imm32, SP));
5098 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdobjbyindexPrefV8Imm32, V0));
5099 GateRef index = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdobjbyindexPrefV8Imm32, INDEX));
5100 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5101
5102 GateRef frame = GetFrame(sp);
5103 GateRef acc = GetAccFromFrame(glue, frame);
5104 auto env = GetEnvironment();
5105 Label fastPath(env);
5106 Label slowPath(env);
5107 Branch(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
5108 Bind(&fastPath);
5109 {
5110 ProfileOperation callback;
5111 SetCurrentGlobalEnv(GetGlobalEnv(glue));
5112 GateRef result = GetPropertyByIndex(glue, receiver, index, callback);
5113 Label notHole(env);
5114 Branch(TaggedIsHole(result), &slowPath, ¬Hole);
5115 Bind(¬Hole);
5116 CHECK_EXCEPTION_WITH_ACC(result);
5117 }
5118 Bind(&slowPath);
5119 {
5120 GateRef result = CallRuntime(glue, RTSTUB_ID(LdObjByIndex),
5121 { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() });
5122 CHECK_EXCEPTION_WITH_ACC(result);
5123 }
5124 }
5125
GenerateCircuit()5126 void BaselineDeprecatedAsyncfunctionresolvePrefV8V8V8StubBuilder::GenerateCircuit()
5127 {
5128 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionresolvePrefV8V8V8, GLUE));
5129 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionresolvePrefV8V8V8, SP));
5130 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionresolvePrefV8V8V8, V0));
5131 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionresolvePrefV8V8V8, V1));
5132
5133 GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5134 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
5135
5136 GateRef frame = GetFrame(sp);
5137 GateRef acc = GetAccFromFrame(glue, frame);
5138 GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncFunctionResolveOrReject),
5139 { asyncFuncObj, value, TaggedTrue() });
5140 CHECK_EXCEPTION_WITH_ACC(res);
5141 }
5142
GenerateCircuit()5143 void BaselineDeprecatedAsyncfunctionrejectPrefV8V8V8StubBuilder::GenerateCircuit()
5144 {
5145 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionrejectPrefV8V8V8, GLUE));
5146 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionrejectPrefV8V8V8, SP));
5147 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionrejectPrefV8V8V8, V0));
5148 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineDeprecatedAsyncfunctionrejectPrefV8V8V8, V1));
5149
5150 GateRef frame = GetFrame(sp);
5151 GateRef acc = GetAccFromFrame(glue, frame);
5152 GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5153 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
5154 GateRef res = CallRuntime(glue, RTSTUB_ID(AsyncFunctionResolveOrReject),
5155 { asyncFuncObj, value, TaggedFalse() });
5156 CHECK_EXCEPTION_WITH_ACC(res);
5157 }
5158
GenerateCircuit()5159 void BaselineDeprecatedStlexvarPrefImm4Imm4V8StubBuilder::GenerateCircuit()
5160 {
5161 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm4Imm4V8, GLUE));
5162 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm4Imm4V8, SP));
5163 GateRef level = Int32Argument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm4Imm4V8, LEVEL));
5164 GateRef slot = Int32Argument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm4Imm4V8, SLOT));
5165 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm4Imm4V8, V0));
5166
5167 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5168 GateRef state = GetFrame(sp);
5169
5170 auto env = GetEnvironment();
5171 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
5172 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
5173
5174 Label loopHead(env);
5175 Label loopEnd(env);
5176 Label afterLoop(env);
5177 Branch(Int32LessThan(*i, level), &loopHead, &afterLoop);
5178 LoopBegin(&loopHead);
5179 currentEnv = GetParentEnv(glue, *currentEnv);
5180 i = Int32Add(*i, Int32(1));
5181 Branch(Int32LessThan(*i, level), &loopEnd, &afterLoop);
5182 Bind(&loopEnd);
5183 LoopEnd(&loopHead);
5184 Bind(&afterLoop);
5185 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, value);
5186 Return();
5187 }
5188
GenerateCircuit()5189 void BaselineDeprecatedStlexvarPrefImm8Imm8V8StubBuilder::GenerateCircuit()
5190 {
5191 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm8Imm8V8, GLUE));
5192 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm8Imm8V8, SP));
5193 GateRef level = Int32Argument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm8Imm8V8, LEVEL));
5194 GateRef slot = Int32Argument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm8Imm8V8, SLOT));
5195 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm8Imm8V8, V0));
5196
5197 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5198 GateRef state = GetFrame(sp);
5199
5200 auto env = GetEnvironment();
5201 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
5202 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
5203
5204 Label loopHead(env);
5205 Label loopEnd(env);
5206 Label afterLoop(env);
5207 Branch(Int32LessThan(*i, level), &loopHead, &afterLoop);
5208 LoopBegin(&loopHead);
5209 currentEnv = GetParentEnv(glue, *currentEnv);
5210 i = Int32Add(*i, Int32(1));
5211 Branch(Int32LessThan(*i, level), &loopEnd, &afterLoop);
5212 Bind(&loopEnd);
5213 LoopEnd(&loopHead);
5214 Bind(&afterLoop);
5215 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, value);
5216 Return();
5217 }
5218
GenerateCircuit()5219 void BaselineDeprecatedStlexvarPrefImm16Imm16V8StubBuilder::GenerateCircuit()
5220 {
5221 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm16Imm16V8, GLUE));
5222 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm16Imm16V8, SP));
5223 GateRef level = Int32Argument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm16Imm16V8, LEVEL));
5224 GateRef slot = Int32Argument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm16Imm16V8, SLOT));
5225 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedStlexvarPrefImm16Imm16V8, V0));
5226
5227 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5228 GateRef state = GetFrame(sp);
5229 auto env = GetEnvironment();
5230 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
5231 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
5232
5233 Label loopHead(env);
5234 Label loopEnd(env);
5235 Label afterLoop(env);
5236 Branch(Int32LessThan(*i, level), &loopHead, &afterLoop);
5237 LoopBegin(&loopHead);
5238 currentEnv = GetParentEnv(glue, *currentEnv);
5239 i = Int32Add(*i, Int32(1));
5240 Branch(Int32LessThan(*i, level), &loopEnd, &afterLoop);
5241 Bind(&loopEnd);
5242 LoopEnd(&loopHead);
5243 Bind(&afterLoop);
5244 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, value);
5245 Return();
5246 }
5247
GenerateCircuit()5248 void BaselineDeprecatedGetmodulenamespacePrefId32StubBuilder::GenerateCircuit()
5249 {
5250 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedGetmodulenamespacePrefId32, GLUE));
5251 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineDeprecatedGetmodulenamespacePrefId32, STRING_ID));
5252 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedGetmodulenamespacePrefId32, SP));
5253
5254 GateRef func = GetFunctionFromFrame(glue, GetFrame(sp));
5255 GateRef method = GetMethodFromFunction(glue, func);
5256 GateRef constpool = GetConstpoolFromMethod(glue, method);
5257 GateRef prop = GetStringFromConstPool(glue, constpool, stringId);
5258 GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(GetModuleNamespace), { prop });
5259 Return(moduleRef);
5260 }
5261
GenerateCircuit()5262 void BaselineDeprecatedStmodulevarPrefId32StubBuilder::GenerateCircuit()
5263 {
5264 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedStmodulevarPrefId32, GLUE));
5265 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDeprecatedStmodulevarPrefId32, ACC));
5266 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineDeprecatedStmodulevarPrefId32, STRING_ID));
5267 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedStmodulevarPrefId32, SP));
5268
5269 GateRef func = GetFunctionFromFrame(glue, GetFrame(sp));
5270 GateRef method = GetMethodFromFunction(glue, func);
5271 GateRef constpool = GetConstpoolFromMethod(glue, method);
5272 GateRef prop = GetStringFromConstPool(glue, constpool, stringId);
5273
5274 CallRuntime(glue, RTSTUB_ID(StModuleVar), { prop, acc });
5275 Return();
5276 }
5277
GenerateCircuit()5278 void BaselineDeprecatedLdobjbynamePrefId32V8StubBuilder::GenerateCircuit()
5279 {
5280 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdobjbynamePrefId32V8, GLUE));
5281 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdobjbynamePrefId32V8, SP));
5282 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdobjbynamePrefId32V8, V0));
5283 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdobjbynamePrefId32V8, STRING_ID));
5284
5285 GateRef frame = GetFrame(sp);
5286 GateRef func = GetFunctionFromFrame(glue, frame);
5287 GateRef method = GetMethodFromFunction(glue, func);
5288 GateRef constpool = GetConstpoolFromMethod(glue, method);
5289 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5290 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
5291 AccessObjectStubBuilder builder(this, GetGlobalEnv(glue));
5292 GateRef result = builder.DeprecatedLoadObjByName(glue, receiver, propKey);
5293 CHECK_EXCEPTION_RETURN(result);
5294 }
5295
GenerateCircuit()5296 void BaselineDeprecatedLdsuperbynamePrefId32V8StubBuilder::GenerateCircuit()
5297 {
5298 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdsuperbynamePrefId32V8, GLUE));
5299 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdsuperbynamePrefId32V8, SP));
5300 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdsuperbynamePrefId32V8, STRING_ID));
5301 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdsuperbynamePrefId32V8, V0));
5302
5303 GateRef frame = GetFrame(sp);
5304 GateRef func = GetFunctionFromFrame(glue, frame);
5305 GateRef method = GetMethodFromFunction(glue, func);
5306 GateRef constpool = GetConstpoolFromMethod(glue, method);
5307 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5308 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
5309 GateRef result = CallRuntime(glue, RTSTUB_ID(LdSuperByValue), { receiver, propKey });
5310 CHECK_EXCEPTION_RETURN(result);
5311 }
5312
GenerateCircuit()5313 void BaselineDeprecatedLdmodulevarPrefId32Imm8StubBuilder::GenerateCircuit()
5314 {
5315 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdmodulevarPrefId32Imm8, GLUE));
5316 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdmodulevarPrefId32Imm8, STRING_ID));
5317 GateRef flagI8 = Int32Argument(PARAM_INDEX(BaselineDeprecatedLdmodulevarPrefId32Imm8, FLAG_I8));
5318 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdmodulevarPrefId32Imm8, SP));
5319 GateRef flag = ZExtInt8ToInt32(flagI8);
5320
5321 GateRef func = GetFunctionFromFrame(glue, GetFrame(sp));
5322 GateRef method = GetMethodFromFunction(glue, func);
5323 GateRef constpool = GetConstpoolFromMethod(glue, method);
5324 GateRef key = GetStringFromConstPool(glue, constpool, stringId);
5325 GateRef moduleRef = CallRuntime(glue, RTSTUB_ID(LdModuleVar), { key, IntToTaggedInt(flag) });
5326 Return(moduleRef);
5327 }
5328
GenerateCircuit()5329 void BaselineDeprecatedStconsttoglobalrecordPrefId32StubBuilder::GenerateCircuit()
5330 {
5331 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedStconsttoglobalrecordPrefId32, GLUE));
5332 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDeprecatedStconsttoglobalrecordPrefId32, ACC));
5333 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineDeprecatedStconsttoglobalrecordPrefId32, STRING_ID));
5334 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedStconsttoglobalrecordPrefId32, SP));
5335
5336 GateRef frame = GetFrame(sp);
5337 GateRef func = GetFunctionFromFrame(glue, frame);
5338 GateRef method = GetMethodFromFunction(glue, func);
5339 GateRef constpool = GetConstpoolFromMethod(glue, method);
5340 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
5341 GateRef result = CallRuntime(glue, RTSTUB_ID(StGlobalRecord),
5342 { propKey, acc, TaggedTrue() });
5343 CHECK_EXCEPTION_RETURN(result);
5344 }
5345
GenerateCircuit()5346 void BaselineDeprecatedStlettoglobalrecordPrefId32StubBuilder::GenerateCircuit()
5347 {
5348 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedStlettoglobalrecordPrefId32, GLUE));
5349 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDeprecatedStlettoglobalrecordPrefId32, ACC));
5350 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineDeprecatedStlettoglobalrecordPrefId32, STRING_ID));
5351 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedStlettoglobalrecordPrefId32, SP));
5352
5353 GateRef frame = GetFrame(sp);
5354 GateRef func = GetFunctionFromFrame(glue, frame);
5355 GateRef method = GetMethodFromFunction(glue, func);
5356 GateRef constpool = GetConstpoolFromMethod(glue, method);
5357 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
5358 GateRef result = CallRuntime(glue, RTSTUB_ID(StGlobalRecord),
5359 { propKey, acc, TaggedFalse() });
5360 CHECK_EXCEPTION_RETURN(result);
5361 }
5362
GenerateCircuit()5363 void BaselineDeprecatedStclasstoglobalrecordPrefId32StubBuilder::GenerateCircuit()
5364 {
5365 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedStclasstoglobalrecordPrefId32, GLUE));
5366 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDeprecatedStclasstoglobalrecordPrefId32, ACC));
5367 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineDeprecatedStclasstoglobalrecordPrefId32, STRING_ID));
5368 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedStclasstoglobalrecordPrefId32, SP));
5369
5370 GateRef frame = GetFrame(sp);
5371 GateRef func = GetFunctionFromFrame(glue, frame);
5372 GateRef method = GetMethodFromFunction(glue, func);
5373 GateRef constpool = GetConstpoolFromMethod(glue, method);
5374 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
5375 GateRef result = CallRuntime(glue, RTSTUB_ID(StGlobalRecord),
5376 { propKey, acc, TaggedFalse() });
5377 CHECK_EXCEPTION_RETURN(result);
5378 }
5379
5380 // SP
GenerateCircuit()5381 void BaselineDeprecatedLdhomeobjectPrefNoneStubBuilder::GenerateCircuit()
5382 {
5383 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdhomeobjectPrefNone, GLUE));
5384 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedLdhomeobjectPrefNone, SP));
5385
5386 GateRef state = GetFunctionFromFrame(glue, GetFrame(sp));
5387 GateRef result = GetHomeObjectFromJSFunction(glue, state);
5388 Return(result);
5389 }
5390
GenerateCircuit()5391 void BaselineDeprecatedCreateobjecthavingmethodPrefImm16StubBuilder::GenerateCircuit()
5392 {
5393 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedCreateobjecthavingmethodPrefImm16, GLUE));
5394 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDeprecatedCreateobjecthavingmethodPrefImm16, ACC));
5395 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedCreateobjecthavingmethodPrefImm16, SP));
5396 GateRef immI16 = Int32Argument(PARAM_INDEX(BaselineDeprecatedCreateobjecthavingmethodPrefImm16, IMM_I16));
5397 GateRef imm = ZExtInt16ToInt32(immI16);
5398
5399 GateRef func = GetFunctionFromFrame(glue, GetFrame(sp));
5400 GateRef method = GetMethodFromFunction(glue, func);
5401 GateRef constpool = GetConstpoolFromMethod(glue, method);
5402 GateRef module = GetModuleFromFunction(glue, func);
5403 GateRef result = GetObjectLiteralFromConstPool(glue, constpool, imm, module);
5404 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateObjectHavingMethod), { result, acc });
5405 CHECK_EXCEPTION_WITH_ACC(res);
5406 }
5407
GenerateCircuit()5408 void BaselineDeprecatedDynamicimportPrefV8StubBuilder::GenerateCircuit()
5409 {
5410 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDeprecatedDynamicimportPrefV8, GLUE));
5411 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDeprecatedDynamicimportPrefV8, SP));
5412 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineDeprecatedDynamicimportPrefV8, ACC));
5413 GateRef specifier = TaggedArgument(PARAM_INDEX(BaselineDeprecatedDynamicimportPrefV8, VREG));
5414
5415 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
5416 GateRef res = CallRuntime(glue, RTSTUB_ID(DynamicImport), { specifier, currentFunc });
5417 CHECK_EXCEPTION_WITH_ACC(res);
5418 }
5419
GenerateCircuit()5420 void BaselineCallRuntimeNotifyConcurrentResultPrefNoneStubBuilder::GenerateCircuit()
5421 {
5422 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeNotifyConcurrentResultPrefNone, GLUE));
5423 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeNotifyConcurrentResultPrefNone, SP));
5424 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineCallRuntimeNotifyConcurrentResultPrefNone, ACC));
5425
5426 GateRef funcObj = GetFunctionFromFrame(glue, GetFrame(sp));
5427 CallRuntime(glue, RTSTUB_ID(NotifyConcurrentResult), {acc, funcObj});
5428 Return();
5429 }
5430
5431 // GLUE, SP, SLOT_ID, STRING_ID, V0
GenerateCircuit()5432 void BaselineDefineFieldByNameImm8Id16V8StubBuilder::GenerateCircuit()
5433 {
5434 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDefineFieldByNameImm8Id16V8, GLUE));
5435 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDefineFieldByNameImm8Id16V8, SP));
5436 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineDefineFieldByNameImm8Id16V8, SLOT_ID));
5437 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineDefineFieldByNameImm8Id16V8, STRING_ID));
5438 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDefineFieldByNameImm8Id16V8, V0));
5439
5440 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
5441 GateRef acc = GetAccFromFrame(glue, frame);
5442 GateRef method = GetMethodFromFunction(glue, curFunc);
5443 GateRef constpool = GetConstpoolFromMethod(glue, method);
5444 GateRef receiver = GetVregValue(glue, sp, ZExtInt32ToPtr(v0));
5445
5446 auto env = GetEnvironment();
5447 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
5448 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
5449 DEFINE_BY_NAME(Boolean(false));
5450 CHECK_EXCEPTION_WITH_ACC(*result);
5451 }
5452
5453
5454 // GLUE, SP, SLOT_ID, STRING_ID, V0
GenerateCircuit()5455 void BaselineDefinePropertyByNameImm8Id16V8StubBuilder::GenerateCircuit()
5456 {
5457 GateRef glue = PtrArgument(PARAM_INDEX(BaselineDefinePropertyByNameImm8Id16V8, GLUE));
5458 GateRef sp = PtrArgument(PARAM_INDEX(BaselineDefinePropertyByNameImm8Id16V8, SP));
5459 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineDefinePropertyByNameImm8Id16V8, SLOT_ID));
5460 GateRef stringId = Int32Argument(PARAM_INDEX(BaselineDefinePropertyByNameImm8Id16V8, STRING_ID));
5461 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineDefinePropertyByNameImm8Id16V8, V0));
5462
5463 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
5464 GateRef acc = GetAccFromFrame(glue, frame);
5465 GateRef method = GetMethodFromFunction(glue, curFunc);
5466 GateRef constpool = GetConstpoolFromMethod(glue, method);
5467 GateRef receiver = GetVregValue(glue, sp, ZExtInt32ToPtr(v0));
5468
5469 auto env = GetEnvironment();
5470 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
5471 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
5472 DEFINE_BY_NAME(Boolean(true));
5473 CHECK_EXCEPTION_WITH_ACC(*result);
5474 }
5475
GenerateCircuit()5476 void BaselineCallRuntimeDefineFieldByValuePrefImm8V8V8StubBuilder::GenerateCircuit()
5477 {
5478 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeDefineFieldByValuePrefImm8V8V8, GLUE));
5479 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeDefineFieldByValuePrefImm8V8V8, SP));
5480 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineCallRuntimeDefineFieldByValuePrefImm8V8V8, ACC));
5481 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineCallRuntimeDefineFieldByValuePrefImm8V8V8, V0));
5482 GateRef v1 = Int32Argument(PARAM_INDEX(BaselineCallRuntimeDefineFieldByValuePrefImm8V8V8, V1));
5483 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
5484 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5485
5486 SetCurrentGlobalEnv(GetGlobalEnv(glue));
5487 GateRef res = DefineField(glue, obj, propKey, acc);
5488 CHECK_EXCEPTION_WITH_ACC(res);
5489 }
5490
GenerateCircuit()5491 void BaselineCallRuntimeDefineFieldByIndexPrefImm8Imm32V8StubBuilder::GenerateCircuit()
5492 {
5493 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeDefineFieldByIndexPrefImm8Imm32V8, GLUE));
5494 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeDefineFieldByIndexPrefImm8Imm32V8, SP));
5495 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineCallRuntimeDefineFieldByIndexPrefImm8Imm32V8, ACC));
5496 GateRef index = Int32Argument(PARAM_INDEX(BaselineCallRuntimeDefineFieldByIndexPrefImm8Imm32V8, INDEX));
5497 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineCallRuntimeDefineFieldByIndexPrefImm8Imm32V8, V0));
5498
5499 GateRef propKey = IntToTaggedPtr(index);
5500 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5501 SetCurrentGlobalEnv(GetGlobalEnv(glue));
5502 GateRef res = DefineField(glue, obj, propKey, acc);
5503 CHECK_EXCEPTION_WITH_ACC(res);
5504 }
5505
GenerateCircuit()5506 void BaselineCallRuntimeToPropertyKeyPrefNoneStubBuilder::GenerateCircuit()
5507 {
5508 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeToPropertyKeyPrefNone, GLUE));
5509 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeToPropertyKeyPrefNone, SP));
5510 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineCallRuntimeToPropertyKeyPrefNone, ACC));
5511
5512 GateRef res = CallRuntime(glue, RTSTUB_ID(ToPropertyKey), { acc });
5513 CHECK_EXCEPTION_WITH_ACC(res);
5514 }
5515
5516 // GLUE, SP, COUNT, LITERAL_ID
GenerateCircuit()5517 void BaselineCallRuntimeCreatePrivatePropertyPrefImm16Id16StubBuilder::GenerateCircuit()
5518 {
5519 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeCreatePrivatePropertyPrefImm16Id16, GLUE));
5520 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeCreatePrivatePropertyPrefImm16Id16, SP));
5521 GateRef count = Int32Argument(PARAM_INDEX(BaselineCallRuntimeCreatePrivatePropertyPrefImm16Id16, COUNT));
5522 GateRef literalId = Int32Argument(PARAM_INDEX(BaselineCallRuntimeCreatePrivatePropertyPrefImm16Id16, LITERAL_ID));
5523
5524 GateRef frame = GetFrame(sp);
5525 GateRef acc = GetAccFromFrame(glue, frame);
5526 GateRef func = GetFunctionFromFrame(glue, frame);
5527 GateRef method = GetMethodFromFunction(glue, func);
5528 GateRef constpool = GetConstpoolFromMethod(glue, method);
5529 GateRef lexicalEnv = GetEnvFromFrame(glue, frame);
5530 GateRef module = GetModuleFromFunction(glue, func);
5531 GateRef res = CallRuntime(glue, RTSTUB_ID(CreatePrivateProperty), {lexicalEnv,
5532 IntToTaggedInt(count), constpool, IntToTaggedInt(literalId), module});
5533 CHECK_EXCEPTION_WITH_ACC(res);
5534 }
5535
5536 // GLUE, SP, ACC, LEVEL_INDEX, SLOT_INDEX, V0
GenerateCircuit()5537 void BaselineCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8StubBuilder::GenerateCircuit()
5538 {
5539 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8, GLUE));
5540 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8, SP));
5541 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8, ACC));
5542 GateRef levelIndex =
5543 Int32Argument(PARAM_INDEX(BaselineCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8, LEVEL_INDEX));
5544 GateRef slotIndex =
5545 Int32Argument(PARAM_INDEX(BaselineCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8, SLOT_INDEX));
5546 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8, V0));
5547
5548 GateRef lexicalEnv = GetEnvFromFrame(glue, GetFrame(sp));
5549 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5550
5551 GateRef res = CallRuntime(glue, RTSTUB_ID(DefinePrivateProperty), {lexicalEnv,
5552 IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), obj, acc}); // acc as value
5553 CHECK_EXCEPTION_WITH_ACC(res);
5554 }
5555
GenerateCircuit()5556 void BaselineCallRuntimeCallInitPrefImm8V8StubBuilder::GenerateCircuit()
5557 {
5558 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeCallInitPrefImm8V8, GLUE));
5559 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeCallInitPrefImm8V8, SP));
5560 GateRef acc = TaggedArgument(PARAM_INDEX(BaselineCallRuntimeCallInitPrefImm8V8, ACC));
5561 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineCallRuntimeCallInitPrefImm8V8, V0));
5562 GateRef hotnessCounter = Int32Argument(PARAM_INDEX(BaselineCallRuntimeCallInitPrefImm8V8, HOTNESS_COUNTER));
5563 GateRef slotId = Int32Argument(PARAM_INDEX(BaselineCallRuntimeCallInitPrefImm8V8, SLOT_ID));
5564 GateRef thisValue = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5565
5566 DEFINE_PROFILE_CALLBACK(glue, sp, slotId);
5567 DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
5568 // same as callthis0
5569 GateRef actualNumArgs = Int32(EcmaInterpreter::ActualNumArgsOfCall::CALLARG0);
5570 METHOD_ENTRY(acc);
5571 Label noNeedCheckException(env);
5572 Label exit(env);
5573 GateRef jumpSize = INT_PTR(CALLRUNTIME_CALLINIT_PREF_IMM8_V8);
5574 JSCallArgs callArgs(JSCallMode::CALL_THIS_ARG0);
5575 callArgs.callArgsWithThis = { 0, 0, 0, thisValue };
5576 CallStubBuilder callBuilder(this, glue, acc, actualNumArgs, jumpSize, &result, hotnessCounter, callArgs, callback);
5577 callBuilder.JSCallDispatchForBaseline(&exit, &noNeedCheckException);
5578 Bind(&exit);
5579 CHECK_PENDING_EXCEPTION(*result);
5580 Bind(&noNeedCheckException);
5581 Return(*result);
5582 }
5583
5584 // GLUE, SP, METHOD_ID, LITERAL_ID, LENGTH, V0
GenerateCircuit()5585 void BaselineCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8StubBuilder::GenerateCircuit()
5586 {
5587 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8, GLUE));
5588 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8, SP));
5589 GateRef methodId = Int32Argument(
5590 PARAM_INDEX(BaselineCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8, METHOD_ID));
5591 GateRef literalId = Int32Argument(
5592 PARAM_INDEX(BaselineCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8, LITERAL_ID));
5593 GateRef length = Int32Argument(
5594 PARAM_INDEX(BaselineCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8, LENGTH));
5595 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8, V0));
5596
5597 GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5598 GateRef frame = GetFrame(sp);
5599 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
5600
5601 auto env = GetEnvironment();
5602 GateRef module = GetModuleFromFunction(glue, currentFunc);
5603 // remove constpool in args
5604 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateSharedClass),
5605 { proto,
5606 Int16ToTaggedInt(methodId),
5607 Int16ToTaggedInt(literalId),
5608 Int16ToTaggedInt(length), module });
5609
5610 Label isException(env);
5611 Label isNotException(env);
5612 BRANCH(TaggedIsException(res), &isException, &isNotException);
5613 Bind(&isException);
5614 {
5615 GateRef acc = GetAccFromFrame(glue, frame);
5616 DISPATCH_LAST_WITH_ACC();
5617 Return(res);
5618 }
5619 Bind(&isNotException);
5620 Return(res);
5621 }
5622
GenerateCircuit()5623 void BaselineCallRuntimeLdSendableClassPrefImm16StubBuilder::GenerateCircuit()
5624 {
5625 GateRef glue = PtrArgument(PARAM_INDEX(BaselineCallRuntimeLdSendableClassPrefImm16, GLUE));
5626 GateRef sp = PtrArgument(PARAM_INDEX(BaselineCallRuntimeLdSendableClassPrefImm16, SP));
5627 GateRef level = Int32Argument(PARAM_INDEX(BaselineCallRuntimeLdSendableClassPrefImm16, LEVEL));
5628 GateRef lexEnv = GetEnvFromFrame(glue, GetFrame(sp));
5629
5630 GateRef result = CallRuntime(glue, RTSTUB_ID(LdSendableClass), { lexEnv, Int16ToTaggedInt(level) });
5631 Return(result);
5632 }
5633
GenerateCircuit()5634 void BaselineReturnundefinedStubBuilder::GenerateCircuit()
5635 {
5636 GateRef glue = PtrArgument(PARAM_INDEX(BaselineReturnundefined, GLUE));
5637 GateRef sp = PtrArgument(PARAM_INDEX(BaselineReturnundefined, SP));
5638 GateRef curPcOffset = Int32Argument(PARAM_INDEX(BaselineReturnundefined, OFFSET));
5639
5640 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
5641 GateRef frame = GetFrame(sp);
5642 GateRef acc = GetAccFromFrame(glue, frame);
5643
5644 auto env = GetEnvironment();
5645 GateRef pc = GetPcFromFrame(frame);
5646 GateRef curFunction = GetFunctionFromFrame(glue, frame);
5647 GateRef curMethod =
5648 Load(VariableType::JS_ANY(), glue, curFunction, IntPtr(JSFunctionBase::METHOD_OFFSET));
5649 GateRef constpool =
5650 Load(VariableType::JS_POINTER(), glue, curMethod, IntPtr(Method::CONSTANT_POOL_OFFSET));
5651 GateRef raw =
5652 Load(VariableType::JS_POINTER(), glue, curFunction, IntPtr(JSFunction::RAW_PROFILE_TYPE_INFO_OFFSET));
5653 GateRef profileTypeInfo =
5654 Load(VariableType::JS_POINTER(), glue, raw, IntPtr(ProfileTypeInfoCell::VALUE_OFFSET));
5655 GateRef hotnessCounter =
5656 LoadPrimitive(VariableType::INT16(), curMethod, IntPtr(Method::LITERAL_INFO_OFFSET));
5657 ProfileOperation callback;
5658
5659 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
5660 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
5661 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
5662 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
5663 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5664 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
5665
5666 Label isBaselineBuiltinFrame(env);
5667 Label notBaselineBuiltinFrame(env);
5668 Label pcEqualNullptr(env);
5669 Label pcNotEqualNullptr(env);
5670 Label pcEqualBaseline(env);
5671 Label pcNotEqualBaseline(env);
5672 Label updateHotness(env);
5673 Label isStable(env);
5674 Label tryContinue(env);
5675 Label dispatch(env);
5676 Label slowPath(env);
5677
5678 BRANCH(TaggedIsUndefined(*varProfileTypeInfo), &updateHotness, &isStable);
5679 Bind(&isStable);
5680 {
5681 GateRef varProfileTypeInfoVal = *varProfileTypeInfo;
5682 GateRef isProfileDumpedAndJitCompiled = LogicAndBuilder(env)
5683 .And(ProfilerStubBuilder(env).IsCompiledOrTryCompile(
5684 glue, GetFunctionFromFrame(glue, frame), varProfileTypeInfoVal, callback, pc))
5685 .And(ProfilerStubBuilder(env).IsProfileTypeInfoDumped(varProfileTypeInfoVal, callback))
5686 .Done();
5687 BRANCH(isProfileDumpedAndJitCompiled, &tryContinue, &updateHotness);
5688 }
5689 Bind(&updateHotness);
5690 {
5691 GateRef offset = Int32Not(curPcOffset);
5692 UPDATE_HOTNESS(*varSp, callback);
5693 SetHotnessCounter(glue, curMethod, *varHotnessCounter);
5694 Jump(&tryContinue);
5695 }
5696 Bind(&tryContinue);
5697 GateRef currentSp = *varSp;
5698 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), frame,
5699 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
5700
5701 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
5702 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
5703 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
5704 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
5705 Bind(&isBaselineBuiltinFrame);
5706 {
5707 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
5708 Jump(¬BaselineBuiltinFrame);
5709 }
5710 Bind(¬BaselineBuiltinFrame);
5711 prevState = GetFrame(*varSp);
5712 varPc = GetPcFromFrame(*prevState);
5713 varAcc = Undefined();
5714 Branch(IntPtrEqual(*varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
5715 Bind(&pcEqualNullptr);
5716 {
5717 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { *varAcc, *varSp, currentSp });
5718 Return();
5719 }
5720 Bind(&pcNotEqualNullptr);
5721 BRANCH(IntPtrEqual(*varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
5722 Bind(&pcEqualBaseline);
5723 {
5724 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
5725 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturnBaseline), { glue, *varAcc, *varSp, currentSp, jumpSize });
5726 Return();
5727 }
5728 Bind(&pcNotEqualBaseline);
5729 {
5730 GateRef function = GetFunctionFromFrame(glue, *prevState);
5731 GateRef method = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
5732 varConstpool = GetConstpoolFromMethod(glue, method);
5733 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
5734 varHotnessCounter = GetHotnessCounterFromMethod(method);
5735 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
5736 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
5737 { glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
5738 *varAcc, *varHotnessCounter, jumpSize });
5739 Return();
5740 }
5741 }
5742
GenerateCircuit()5743 void BaselineSuspendgeneratorV8StubBuilder::GenerateCircuit()
5744 {
5745 GateRef glue = PtrArgument(PARAM_INDEX(BaselineSuspendgeneratorV8, GLUE));
5746 GateRef sp = PtrArgument(PARAM_INDEX(BaselineSuspendgeneratorV8, SP));
5747 GateRef curPcOffset = PtrArgument(PARAM_INDEX(BaselineSuspendgeneratorV8, OFFSET));
5748 GateRef v0 = Int32Argument(PARAM_INDEX(BaselineSuspendgeneratorV8, V0));
5749 ProfileOperation callback;
5750
5751 GateRef frame = GetFrame(sp);
5752 GateRef func = GetFunctionFromFrame(glue, frame);
5753 GateRef method = GetMethodFromFunction(glue, func);
5754 GateRef constpool = GetConstpoolFromMethod(glue, method);
5755 GateRef acc = GetAccFromFrame(glue, frame);
5756 GateRef hotnessCounter = GetHotnessCounterFromMethod(method);
5757 GateRef profileTypeInfo = GetProfileTypeInfoFromFunction(glue, func);
5758
5759 auto env = GetEnvironment();
5760 METHOD_EXIT();
5761 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
5762 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
5763 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
5764 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
5765 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5766 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
5767
5768 Label isBaselineBuiltinFrame(env);
5769 Label notBaselineBuiltinFrame(env);
5770 Label pcEqualNullptr(env);
5771 Label pcNotEqualNullptr(env);
5772 Label pcEqualBaseline(env);
5773 Label pcNotEqualBaseline(env);
5774 Label updateHotness(env);
5775 Label isStable(env);
5776 Label tryContinue(env);
5777 Label dispatch(env);
5778 Label slowPath(env);
5779
5780 GateRef genObj = GetVregValue(glue, sp, ZExtInt32ToPtr(v0));
5781 GateRef value = *varAcc;
5782 GateRef res = CallRuntime(glue, RTSTUB_ID(SuspendGenerator), { genObj, value });
5783 Label isException(env);
5784 Label notException(env);
5785 BRANCH(TaggedIsException(res), &isException, ¬Exception);
5786 Bind(&isException);
5787 {
5788 DISPATCH_LAST();
5789 Return();
5790 }
5791 Bind(¬Exception);
5792 varAcc = res;
5793 BRANCH(TaggedIsUndefined(*varProfileTypeInfo), &updateHotness, &isStable);
5794 Bind(&isStable);
5795 {
5796 BRANCH(ProfilerStubBuilder(env).IsProfileTypeInfoDumped(*varProfileTypeInfo, callback), &tryContinue,
5797 &updateHotness);
5798 }
5799 Bind(&updateHotness);
5800 {
5801 GateRef offset = Int32Not(curPcOffset);
5802 UPDATE_HOTNESS(*varSp, callback);
5803 SetHotnessCounter(glue, method, *varHotnessCounter);
5804 Jump(&tryContinue);
5805 }
5806
5807 Bind(&tryContinue);
5808 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
5809 GateRef curFunc = GetFunctionFromFrame(glue, frame);
5810 CallNGCRuntime(glue, RTSTUB_ID(EndCallTimer), { glue, curFunc });
5811 #endif
5812 GateRef currentSp = *varSp;
5813 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), frame,
5814 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
5815
5816 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
5817 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
5818 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
5819 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
5820 Bind(&isBaselineBuiltinFrame);
5821 {
5822 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
5823 Jump(¬BaselineBuiltinFrame);
5824 }
5825 Bind(¬BaselineBuiltinFrame);
5826 prevState = GetFrame(*varSp);
5827 GateRef varPc = GetPcFromFrame(*prevState);
5828 BRANCH(IntPtrEqual(varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
5829 Bind(&pcEqualNullptr);
5830 {
5831 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { *varAcc, *varSp, currentSp });
5832 Return();
5833 }
5834 Bind(&pcNotEqualNullptr);
5835 BRANCH(IntPtrEqual(varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
5836 Bind(&pcEqualBaseline);
5837 {
5838 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
5839 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturnBaseline), { glue, *varAcc, *varSp, currentSp, jumpSize });
5840 Return();
5841 }
5842 Bind(&pcNotEqualBaseline);
5843 {
5844 GateRef function = GetFunctionFromFrame(glue, *prevState);
5845 GateRef prevMethod = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
5846 varConstpool = GetConstpoolFromMethod(glue, prevMethod);
5847 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
5848 varHotnessCounter = GetHotnessCounterFromMethod(prevMethod);
5849 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
5850 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
5851 { glue, currentSp, varPc, *varConstpool, *varProfileTypeInfo,
5852 *varAcc, *varHotnessCounter, jumpSize });
5853 Return();
5854 }
5855 }
5856
5857 // interpreter helper handler
GenerateCircuit()5858 void BaselineExceptionHandlerStubBuilder::GenerateCircuit()
5859 {
5860 GateRef glue = PtrArgument(PARAM_INDEX(BaselineExceptionHandler, GLUE));
5861 GateRef sp = PtrArgument(PARAM_INDEX(BaselineExceptionHandler, SP));
5862 GateRef acc = PtrArgument(PARAM_INDEX(BaselineExceptionHandler, ACC));
5863
5864 GateRef frame = GetFrame(sp);
5865 GateRef func = GetFunctionFromFrame(glue, frame);
5866 GateRef profileTypeInfo = GetProfileTypeInfoFromFunction(glue, func);
5867 GateRef method = GetMethodFromFunction(glue, func);
5868 GateRef hotnessCounter = GetHotnessCounterFromMethod(method);
5869 GateRef constpool = GetConstpoolFromMethod(glue, method);
5870
5871 auto env = GetEnvironment();
5872 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), IntPtr(0));
5873 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
5874 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
5875 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
5876 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5877 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
5878
5879 Label pcIsInvalid(env);
5880 Label pcNotInvalid(env);
5881 GateRef exceptionOffset = IntPtr(JSThread::GlueData::GetExceptionOffset(env->IsArch32Bit()));
5882 GateRef exception = Load(VariableType::JS_ANY(), glue, glue, exceptionOffset);
5883 varPc = TaggedCastToIntPtr(CallRuntime(glue, RTSTUB_ID(UpFrame), {}));
5884 varSp = GetCurrentFrame(glue);
5885 Branch(IntPtrEqual(*varPc, IntPtr(0)), &pcIsInvalid, &pcNotInvalid);
5886 Bind(&pcIsInvalid);
5887 {
5888 CallNGCRuntime(glue, RTSTUB_ID(ResumeUncaughtFrameAndReturn), { glue, *varSp, *varAcc });
5889 Return();
5890 }
5891 Bind(&pcNotInvalid);
5892 {
5893 varAcc = exception;
5894 // clear exception
5895 Store(VariableType::INT64(), glue, glue, exceptionOffset, Hole());
5896 GateRef function = GetFunctionFromFrame(glue, GetFrame(*varSp));
5897 GateRef thisMethod = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
5898 varConstpool = GetConstpoolFromMethod(glue, thisMethod);
5899 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
5900 varHotnessCounter = GetHotnessCounterFromMethod(thisMethod);
5901 CallNGCRuntime(glue, RTSTUB_ID(ResumeCaughtFrameAndDispatch), {
5902 glue, *varSp, *varPc, *varConstpool,
5903 *varProfileTypeInfo, *varAcc, *varHotnessCounter});
5904 Return();
5905 }
5906 }
5907
GenerateCircuit()5908 void BaselineUpdateHotnessStubBuilder::GenerateCircuit()
5909 {
5910 GateRef glue = PtrArgument(PARAM_INDEX(BaselineUpdateHotness, GLUE));
5911 GateRef sp = PtrArgument(PARAM_INDEX(BaselineUpdateHotness, SP));
5912 GateRef offset = Int32Argument(PARAM_INDEX(BaselineUpdateHotness, OFFSET));
5913
5914 GateRef frame = GetFrame(sp);
5915 GateRef func = GetFunctionFromFrame(glue, frame);
5916 GateRef method = GetMethodFromFunction(glue, func);
5917 GateRef hotnessCounter = GetHotnessCounterFromMethod(method);
5918 GateRef profileTypeInfo = GetProfileTypeInfoFromFunction(glue, func);
5919 GateRef acc = GetAccFromFrame(glue, frame);
5920
5921 auto env = GetEnvironment();
5922 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_ANY(), profileTypeInfo);
5923 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
5924
5925 varHotnessCounter = Int32Add(offset, *varHotnessCounter);
5926 Label slowPath(env);
5927 Label exitLabel(env);
5928 BRANCH(Int32LessThan(*varHotnessCounter, Int32(0)), &slowPath, &exitLabel);
5929 Bind(&slowPath);
5930 {
5931 GateRef iVecOffset = IntPtr(JSThread::GlueData::GetInterruptVectorOffset(env->IsArch32Bit()));
5932 GateRef interruptsFlag = LoadPrimitive(VariableType::INT8(), glue, iVecOffset);
5933 varHotnessCounter = Int32(EcmaInterpreter::METHOD_HOTNESS_THRESHOLD);
5934 Label initialized(env);
5935 Label callRuntime(env);
5936 BRANCH(BitOr(TaggedIsUndefined(*varProfileTypeInfo),
5937 Int8Equal(interruptsFlag, Int8(VmThreadControl::VM_NEED_SUSPENSION))),
5938 &callRuntime, &initialized);
5939 Bind(&callRuntime);
5940 varProfileTypeInfo = CallRuntime(glue, RTSTUB_ID(UpdateHotnessCounterWithProf), { func });
5941
5942 Label handleException(env);
5943 BRANCH(HasPendingException(glue), &handleException, &exitLabel);
5944 Bind(&handleException);
5945 {
5946 DISPATCH_LAST();
5947 Return();
5948 }
5949 Bind(&initialized);
5950 ProfilerStubBuilder profiler(this);
5951 profiler.TryJitCompile(glue, { offset, 0, false }, func, profileTypeInfo);
5952 Jump(&exitLabel);
5953 }
5954 Bind(&exitLabel);
5955 SetHotnessCounter(glue, method, *varHotnessCounter);
5956 Return();
5957 }
5958 #undef UPDATE_HOTNESS
5959 #undef PARAM_INDEX
5960 #undef DISPATCH_LAST
5961 #undef DISPATCH_LAST_WITH_ACC
5962 } // namespace panda::ecmascript::kungfu
5963