@@ -109,38 +109,27 @@ void BaselineAssembler::JumpIfNotSmi(Register value, Label* target,
109
109
}
110
110
111
111
void BaselineAssembler::CallBuiltin (Builtin builtin) {
112
- if (masm ()->options ().short_builtin_calls ) {
113
- __ CallBuiltin (builtin);
114
- } else {
115
- ASM_CODE_COMMENT_STRING (masm_,
116
- __ CommentForOffHeapTrampoline (" call" , builtin));
117
- Register temp = t6;
118
- __ LoadEntryFromBuiltin (builtin, temp);
119
- __ Call (temp);
120
- }
112
+ ASM_CODE_COMMENT_STRING (masm_,
113
+ __ CommentForOffHeapTrampoline (" call" , builtin));
114
+ Register temp = t6;
115
+ __ LoadEntryFromBuiltin (builtin, temp);
116
+ __ Call (temp);
121
117
}
122
118
123
119
void BaselineAssembler::TailCallBuiltin (Builtin builtin) {
124
- if (masm ()->options ().short_builtin_calls ) {
125
- // Generate pc-relative jump.
126
- __ TailCallBuiltin (builtin);
127
- } else {
128
- ASM_CODE_COMMENT_STRING (
129
- masm_, __ CommentForOffHeapTrampoline (" tail call" , builtin));
130
- // t6 be used for function call in RISCV64
131
- // For example 'jalr t6' or 'jal t6'
132
- Register temp = t6;
133
- __ LoadEntryFromBuiltin (builtin, temp);
134
- __ Jump (temp);
135
- }
120
+ ASM_CODE_COMMENT_STRING (masm_,
121
+ __ CommentForOffHeapTrampoline (" tail call" , builtin));
122
+ Register temp = t6;
123
+ __ LoadEntryFromBuiltin (builtin, temp);
124
+ __ Jump (temp);
136
125
}
137
126
138
127
void BaselineAssembler::TestAndBranch (Register value, int mask, Condition cc,
139
128
Label* target, Label::Distance) {
140
129
ScratchRegisterScope temps (this );
141
130
Register tmp = temps.AcquireScratch ();
142
131
__ And (tmp, value, Operand (mask));
143
- __ Branch (target, AsMasmCondition (cc), tmp, Operand (mask ));
132
+ __ Branch (target, AsMasmCondition (cc), tmp, Operand (zero_reg ));
144
133
}
145
134
146
135
void BaselineAssembler::JumpIf (Condition cc, Register lhs, const Operand& rhs,
@@ -161,6 +150,11 @@ void BaselineAssembler::JumpIfInstanceType(Condition cc, Register map,
161
150
Label* target, Label::Distance) {
162
151
ScratchRegisterScope temps (this );
163
152
Register type = temps.AcquireScratch ();
153
+ if (FLAG_debug_code) {
154
+ __ AssertNotSmi (map);
155
+ __ GetObjectType (map, type, type);
156
+ __ Assert (eq, AbortReason::kUnexpectedValue , type, Operand (MAP_TYPE));
157
+ }
164
158
__ Ld (type, FieldMemOperand (map, Map::kInstanceTypeOffset ));
165
159
__ Branch (target, AsMasmCondition (cc), type, Operand (instance_type));
166
160
}
@@ -182,44 +176,28 @@ void BaselineAssembler::JumpIfSmi(Condition cc, Register value, Smi smi,
182
176
}
183
177
void BaselineAssembler::JumpIfSmi (Condition cc, Register lhs, Register rhs,
184
178
Label* target, Label::Distance) {
185
- ScratchRegisterScope temps (this );
186
- Register temp = temps.AcquireScratch ();
179
+ // todo: compress pointer
187
180
__ AssertSmi (lhs);
188
181
__ AssertSmi (rhs);
189
- if (COMPRESS_POINTERS_BOOL) {
190
- __ Sub32 (temp, lhs, rhs);
191
- } else {
192
- __ Sub64 (temp, lhs, rhs);
193
- }
194
- __ Branch (target, AsMasmCondition (cc), temp, Operand (zero_reg));
182
+ __ Branch (target, AsMasmCondition (cc), lhs, Operand (rhs));
195
183
}
196
184
void BaselineAssembler::JumpIfTagged (Condition cc, Register value,
197
185
MemOperand operand, Label* target,
198
186
Label::Distance) {
187
+ // todo: compress pointer
199
188
ScratchRegisterScope temps (this );
200
- Register tmp1 = temps.AcquireScratch ();
201
- Register tmp2 = temps.AcquireScratch ();
202
- __ Ld (tmp1, operand);
203
- if (COMPRESS_POINTERS_BOOL) {
204
- __ Sub32 (tmp2, value, tmp1);
205
- } else {
206
- __ Sub64 (tmp2, value, tmp1);
207
- }
208
- __ Branch (target, AsMasmCondition (cc), tmp2, Operand (zero_reg));
189
+ Register scratch = temps.AcquireScratch ();
190
+ __ Ld (scratch, operand);
191
+ __ Branch (target, AsMasmCondition (cc), value, Operand (scratch));
209
192
}
210
193
void BaselineAssembler::JumpIfTagged (Condition cc, MemOperand operand,
211
194
Register value, Label* target,
212
195
Label::Distance) {
196
+ // todo: compress pointer
213
197
ScratchRegisterScope temps (this );
214
- Register tmp1 = temps.AcquireScratch ();
215
- Register tmp2 = temps.AcquireScratch ();
216
- __ Ld (tmp1, operand);
217
- if (COMPRESS_POINTERS_BOOL) {
218
- __ Sub32 (tmp2, tmp1, value);
219
- } else {
220
- __ Sub64 (tmp2, tmp1, value);
221
- }
222
- __ Branch (target, AsMasmCondition (cc), tmp2, Operand (zero_reg));
198
+ Register scratch = temps.AcquireScratch ();
199
+ __ Ld (scratch, operand);
200
+ __ Branch (target, AsMasmCondition (cc), scratch, Operand (value));
223
201
}
224
202
void BaselineAssembler::JumpIfByte (Condition cc, Register value, int32_t byte,
225
203
Label* target, Label::Distance) {
@@ -267,137 +245,51 @@ inline Register ToRegister(BaselineAssembler* basm,
267
245
return reg;
268
246
}
269
247
270
- template <typename ... Args>
271
- struct CountPushHelper ;
272
- template <>
273
- struct CountPushHelper <> {
274
- static int Count () { return 0 ; }
275
- };
276
- template <typename Arg, typename ... Args>
277
- struct CountPushHelper <Arg, Args...> {
278
- static int Count (Arg arg, Args... args) {
279
- return 1 + CountPushHelper<Args...>::Count (args...);
280
- }
281
- };
282
- template <typename ... Args>
283
- struct CountPushHelper <interpreter::RegisterList, Args...> {
284
- static int Count (interpreter::RegisterList list, Args... args) {
285
- return list.register_count () + CountPushHelper<Args...>::Count (args...);
286
- }
287
- };
288
-
289
248
template <typename ... Args>
290
249
struct PushAllHelper ;
291
- template <typename ... Args>
292
- void PushAll (BaselineAssembler* basm, Args... args) {
293
- PushAllHelper<Args...>::Push (basm, args...);
294
- }
295
- template <typename ... Args>
296
- void PushAllReverse (BaselineAssembler* basm, Args... args) {
297
- PushAllHelper<Args...>::PushReverse (basm, args...);
298
- }
299
-
300
250
template <>
301
251
struct PushAllHelper <> {
302
- static void Push (BaselineAssembler* basm) {}
303
- static void PushReverse (BaselineAssembler* basm) {}
252
+ static int Push (BaselineAssembler* basm) { return 0 ; }
253
+ static int PushReverse (BaselineAssembler* basm) { return 0 ; }
304
254
};
305
-
306
- inline void PushSingle (MacroAssembler* masm, RootIndex source) {
307
- masm->PushRoot (source);
308
- }
309
- inline void PushSingle (MacroAssembler* masm, Register reg) { masm->Push (reg); }
310
-
311
- inline void PushSingle (MacroAssembler* masm, Smi value) { masm->Push (value); }
312
- inline void PushSingle (MacroAssembler* masm, Handle <HeapObject> object) {
313
- masm->Push (object);
314
- }
315
- inline void PushSingle (MacroAssembler* masm, int32_t immediate) {
316
- masm->li (kScratchReg , (int64_t )(immediate));
317
- PushSingle (masm, kScratchReg );
318
- }
319
-
320
- inline void PushSingle (MacroAssembler* masm, TaggedIndex value) {
321
- masm->li (kScratchReg , static_cast <int64_t >(value.ptr ()));
322
- PushSingle (masm, kScratchReg );
323
- }
324
- inline void PushSingle (MacroAssembler* masm, MemOperand operand) {
325
- masm->Ld (kScratchReg , operand);
326
- PushSingle (masm, kScratchReg );
327
- }
328
- inline void PushSingle (MacroAssembler* masm, interpreter::Register source) {
329
- return PushSingle (masm, BaselineAssembler::RegisterFrameOperand (source));
330
- }
331
-
332
255
template <typename Arg>
333
256
struct PushAllHelper <Arg> {
334
- static void Push (BaselineAssembler* basm, Arg arg) {
335
- PushSingle (basm->masm (), arg);
257
+ static int Push (BaselineAssembler* basm, Arg arg) {
258
+ BaselineAssembler::ScratchRegisterScope scope (basm);
259
+ basm->masm ()->Push (ToRegister (basm, &scope, arg));
260
+ return 1 ;
336
261
}
337
- static void PushReverse (BaselineAssembler* basm, Arg arg) {
338
- // Push the padding register to round up the amount of values pushed.
262
+ static int PushReverse (BaselineAssembler* basm, Arg arg) {
339
263
return Push (basm, arg);
340
264
}
341
265
};
342
- template <typename Arg1, typename Arg2, typename ... Args>
343
- struct PushAllHelper <Arg1, Arg2, Args...> {
344
- static void Push (BaselineAssembler* basm, Arg1 arg1, Arg2 arg2,
345
- Args... args) {
346
- {
347
- BaselineAssembler::ScratchRegisterScope scope (basm);
348
- basm->masm ()->Push (ToRegister (basm, &scope, arg1),
349
- ToRegister (basm, &scope, arg2));
350
- }
351
- PushAll (basm, args...);
352
- }
353
- static void PushReverse (BaselineAssembler* basm, Arg1 arg1, Arg2 arg2,
354
- Args... args) {
355
- PushAllReverse (basm, args...);
356
- {
357
- BaselineAssembler::ScratchRegisterScope scope (basm);
358
- basm->masm ()->Push (ToRegister (basm, &scope, arg2),
359
- ToRegister (basm, &scope, arg1));
360
- }
361
- }
362
- };
363
- // Currently RegisterLists are always be the last argument, so we don't
364
- // specialize for the case where they're not. We do still specialise for the
365
- // aligned and unaligned cases.
366
- template <typename Arg>
367
- struct PushAllHelper <Arg, interpreter::RegisterList> {
368
- static void Push (BaselineAssembler* basm, Arg arg,
369
- interpreter::RegisterList list) {
370
- DCHECK_EQ (list.register_count () % 2 , 1 );
371
- PushAll (basm, arg, list[0 ], list.PopLeft ());
266
+ template <typename Arg, typename ... Args>
267
+ struct PushAllHelper <Arg, Args...> {
268
+ static int Push (BaselineAssembler* basm, Arg arg, Args... args) {
269
+ PushAllHelper<Arg>::Push (basm, arg);
270
+ return 1 + PushAllHelper<Args...>::Push (basm, args...);
372
271
}
373
- static void PushReverse (BaselineAssembler* basm, Arg arg,
374
- interpreter::RegisterList list) {
375
- if (list.register_count () == 0 ) {
376
- PushAllReverse (basm, arg);
377
- } else {
378
- PushAllReverse (basm, arg, list[0 ], list.PopLeft ());
379
- }
272
+ static int PushReverse (BaselineAssembler* basm, Arg arg, Args... args) {
273
+ int nargs = PushAllHelper<Args...>::PushReverse (basm, args...);
274
+ PushAllHelper<Arg>::Push (basm, arg);
275
+ return nargs + 1 ;
380
276
}
381
277
};
382
278
template <>
383
279
struct PushAllHelper <interpreter::RegisterList> {
384
- static void Push (BaselineAssembler* basm, interpreter::RegisterList list) {
385
- DCHECK_EQ (list.register_count () % 2 , 0 );
386
- for (int reg_index = 0 ; reg_index < list.register_count (); reg_index += 2 ) {
387
- PushAll (basm, list[reg_index], list[reg_index + 1 ]);
280
+ static int Push (BaselineAssembler* basm, interpreter::RegisterList list) {
281
+ for (int reg_index = 0 ; reg_index < list.register_count (); ++reg_index) {
282
+ PushAllHelper<interpreter::Register>::Push (basm, list[reg_index]);
388
283
}
284
+ return list.register_count ();
389
285
}
390
- static void PushReverse (BaselineAssembler* basm,
391
- interpreter::RegisterList list) {
392
- int reg_index = list.register_count () - 1 ;
393
- if (reg_index % 2 == 0 ) {
394
- // Push the padding register to round up the amount of values pushed.
395
- PushAllReverse (basm, list[reg_index]);
396
- reg_index--;
397
- }
398
- for (; reg_index >= 1 ; reg_index -= 2 ) {
399
- PushAllReverse (basm, list[reg_index - 1 ], list[reg_index]);
286
+ static int PushReverse (BaselineAssembler* basm,
287
+ interpreter::RegisterList list) {
288
+ for (int reg_index = list.register_count () - 1 ; reg_index >= 0 ;
289
+ --reg_index) {
290
+ PushAllHelper<interpreter::Register>::Push (basm, list[reg_index]);
400
291
}
292
+ return list.register_count ();
401
293
}
402
294
};
403
295
@@ -414,10 +306,9 @@ struct PopAllHelper<Register> {
414
306
}
415
307
};
416
308
template <typename ... T>
417
- struct PopAllHelper <Register, Register, T...> {
418
- static void Pop (BaselineAssembler* basm, Register reg1, Register reg2,
419
- T... tail) {
420
- basm->masm ()->Pop (reg1, reg2);
309
+ struct PopAllHelper <Register, T...> {
310
+ static void Pop (BaselineAssembler* basm, Register reg, T... tail) {
311
+ PopAllHelper<Register>::Pop (basm, reg);
421
312
PopAllHelper<T...>::Pop (basm, tail...);
422
313
}
423
314
};
@@ -426,20 +317,12 @@ struct PopAllHelper<Register, Register, T...> {
426
317
427
318
template <typename ... T>
428
319
int BaselineAssembler::Push (T... vals) {
429
- // We have to count the pushes first, to decide whether to add padding before
430
- // the first push.
431
- int push_count = detail::CountPushHelper<T...>::Count (vals...);
432
- if (push_count % 2 == 0 ) {
433
- detail::PushAll (this , vals...);
434
- } else {
435
- detail::PushAll (this , vals...);
436
- }
437
- return push_count;
320
+ return detail::PushAllHelper<T...>::Push (this , vals...);
438
321
}
439
322
440
323
template <typename ... T>
441
324
void BaselineAssembler::PushReverse (T... vals) {
442
- detail::PushAllReverse (this , vals...);
325
+ detail::PushAllHelper<T...>:: PushReverse (this , vals...);
443
326
}
444
327
445
328
template <typename ... T>
@@ -461,7 +344,7 @@ void BaselineAssembler::LoadTaggedAnyField(Register output, Register source,
461
344
}
462
345
void BaselineAssembler::LoadByteField (Register output, Register source,
463
346
int offset) {
464
- __ Ld (output, FieldMemOperand (source, offset));
347
+ __ Lb (output, FieldMemOperand (source, offset));
465
348
}
466
349
void BaselineAssembler::StoreTaggedSignedField (Register target, int offset,
467
350
Smi value) {
@@ -495,11 +378,11 @@ void BaselineAssembler::AddToInterruptBudgetAndJumpIfNotExceeded(
495
378
JSFunction::kFeedbackCellOffset );
496
379
497
380
Register interrupt_budget = scratch_scope.AcquireScratch ();
498
- __ Ld (interrupt_budget,
381
+ __ Lw (interrupt_budget,
499
382
FieldMemOperand (feedback_cell, FeedbackCell::kInterruptBudgetOffset ));
500
383
// Remember to set flags as part of the add!
501
- __ Add64 (interrupt_budget, interrupt_budget, weight);
502
- __ Sd (interrupt_budget,
384
+ __ Add32 (interrupt_budget, interrupt_budget, weight);
385
+ __ Sw (interrupt_budget,
503
386
FieldMemOperand (feedback_cell, FeedbackCell::kInterruptBudgetOffset ));
504
387
if (skip_interrupt_label) {
505
388
DCHECK_LT (weight, 0 );
@@ -517,11 +400,11 @@ void BaselineAssembler::AddToInterruptBudgetAndJumpIfNotExceeded(
517
400
JSFunction::kFeedbackCellOffset );
518
401
519
402
Register interrupt_budget = scratch_scope.AcquireScratch ();
520
- __ Ld (interrupt_budget,
403
+ __ Lw (interrupt_budget,
521
404
FieldMemOperand (feedback_cell, FeedbackCell::kInterruptBudgetOffset ));
522
405
// Remember to set flags as part of the add!
523
- __ Add64 (interrupt_budget, interrupt_budget, weight);
524
- __ Sd (interrupt_budget,
406
+ __ Add32 (interrupt_budget, interrupt_budget, weight);
407
+ __ Sw (interrupt_budget,
525
408
FieldMemOperand (feedback_cell, FeedbackCell::kInterruptBudgetOffset ));
526
409
if (skip_interrupt_label)
527
410
__ Branch (skip_interrupt_label, ge, interrupt_budget, Operand (weight));
@@ -556,20 +439,19 @@ void BaselineAssembler::Switch(Register reg, int case_value_base,
556
439
int32_t Hi20 = (((int32_t )imm64 + 0x800 ) >> 12 );
557
440
int32_t Lo12 = (int32_t )imm64 << 20 >> 20 ;
558
441
__ auipc (temp, Hi20); // Read PC + Hi20 into t6
559
- __ lui (temp, Lo12); // jump PC + Hi20 + Lo12
442
+ __ addi (temp, temp, Lo12); // jump PC + Hi20 + Lo12
560
443
561
- int entry_size_log2 = 2 ;
562
- Register temp2 = scope.AcquireScratch ();
563
- __ CalcScaledAddress (temp2, temp, reg, entry_size_log2);
444
+ int entry_size_log2 = 3 ;
445
+ __ CalcScaledAddress (temp, temp, reg, entry_size_log2);
564
446
__ Jump (temp);
565
447
{
566
448
TurboAssembler::BlockTrampolinePoolScope (masm ());
567
- __ BlockTrampolinePoolFor (num_labels * kInstrSize );
449
+ __ BlockTrampolinePoolFor (num_labels * kInstrSize * 2 );
568
450
__ bind (&table);
569
451
for (int i = 0 ; i < num_labels; ++i) {
570
- __ Branch (labels[i]);
452
+ __ BranchLong (labels[i]);
571
453
}
572
- DCHECK_EQ (num_labels * kInstrSize , __ InstructionsGeneratedSince (&table));
454
+ DCHECK_EQ (num_labels * 2 , __ InstructionsGeneratedSince (&table));
573
455
__ bind (&fallthrough);
574
456
}
575
457
}
@@ -598,7 +480,7 @@ void BaselineAssembler::EmitReturn(MacroAssembler* masm) {
598
480
__ masm ()->Push (kJSFunctionRegister );
599
481
__ CallRuntime (Runtime::kBytecodeBudgetInterruptFromBytecode , 1 );
600
482
601
- __ masm ()->Pop (kInterpreterAccumulatorRegister , params_size );
483
+ __ masm ()->Pop (params_size, kInterpreterAccumulatorRegister );
602
484
__ masm ()->SmiUntag (params_size);
603
485
604
486
__ Bind (&skip_interrupt_label);
0 commit comments