OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/arm/macro-assembler-arm.h" | 7 #include "src/arm/macro-assembler-arm.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 __ cmp(offset, i.InputImmediate(1)); \ | 349 __ cmp(offset, i.InputImmediate(1)); \ |
350 } \ | 350 } \ |
351 auto value = i.InputRegister(2); \ | 351 auto value = i.InputRegister(2); \ |
352 __ asm_instr(value, i.InputOffset(3), lo); \ | 352 __ asm_instr(value, i.InputOffset(3), lo); \ |
353 DCHECK_EQ(LeaveCC, i.OutputSBit()); \ | 353 DCHECK_EQ(LeaveCC, i.OutputSBit()); \ |
354 } while (0) | 354 } while (0) |
355 | 355 |
356 | 356 |
357 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { | 357 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
358 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 358 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
359 int stack_slots = frame()->GetSpillSlotCount(); | 359 int spill_slots = frame()->GetSpillSlotCount(); |
360 if (descriptor->IsJSFunctionCall() || stack_slots > 0) { | 360 bool has_frame = descriptor->IsJSFunctionCall() || spill_slots > 0; |
361 __ LeaveFrame(StackFrame::MANUAL); | 361 if (has_frame) { |
362 } | 362 if (stack_param_delta != 0) { |
Jarin
2015/11/20 10:56:09
Is the special casing for the stack_parameter_delt
danno
2015/11/20 14:43:23
No, but the code is more compact. For simplicity I
| |
363 if (stack_param_delta < 0) { | 363 int total_discarded_slots = frame()->GetTotalFrameSlotCount(); |
364 int offset = -stack_param_delta * kPointerSize; | 364 // Leave the PC and saved frame pointer on the stack. |
365 __ add(sp, sp, Operand(offset)); | 365 total_discarded_slots -= |
366 StandardFrameConstants::kFixedFrameSizeFromFp / kPointerSize; | |
367 // Discard only slots that won't be used by new parameters. | |
368 total_discarded_slots -= stack_param_delta; | |
369 if (total_discarded_slots > 0) { | |
370 __ add(sp, sp, Operand(total_discarded_slots * kPointerSize)); | |
371 } | |
372 } else { | |
373 __ mov(sp, fp); | |
374 } | |
375 if (FLAG_enable_embedded_constant_pool) { | |
376 __ ldm(ia_w, sp, pp.bit() | fp.bit() | lr.bit()); | |
377 } else { | |
378 __ ldm(ia_w, sp, fp.bit() | lr.bit()); | |
379 } | |
366 } | 380 } |
367 } | 381 } |
368 | 382 |
383 | |
384 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { | |
385 if (stack_param_delta > 0) { | |
386 int total_discarded_slots = frame()->GetTotalFrameSlotCount(); | |
387 // Leave the PC and saved frame pointer on the stack. | |
388 total_discarded_slots -= | |
389 StandardFrameConstants::kFixedFrameSizeFromFp / kPointerSize; | |
390 // Discard only slots that won't be used by new parameters. | |
391 total_discarded_slots -= stack_param_delta; | |
Jarin
2015/11/20 10:56:09
The calculation of total_discarded_slots is repeat
danno
2015/11/20 14:43:23
Done.
| |
392 if (total_discarded_slots < 0) { | |
393 __ sub(sp, sp, Operand(-total_discarded_slots * kPointerSize)); | |
394 } | |
395 } | |
396 } | |
397 | |
369 | 398 |
370 // Assembles an instruction after register allocation, producing machine code. | 399 // Assembles an instruction after register allocation, producing machine code. |
371 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 400 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
372 ArmOperandConverter i(this, instr); | 401 ArmOperandConverter i(this, instr); |
373 | 402 |
374 masm()->MaybeCheckConstPool(); | 403 masm()->MaybeCheckConstPool(); |
375 | 404 |
376 switch (ArchOpcodeField::decode(instr->opcode())) { | 405 switch (ArchOpcodeField::decode(instr->opcode())) { |
377 case kArchCallCodeObject: { | 406 case kArchCallCodeObject: { |
378 EnsureSpaceForLazyDeopt(); | 407 EnsureSpaceForLazyDeopt(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 case kArchLazyBailout: { | 464 case kArchLazyBailout: { |
436 EnsureSpaceForLazyDeopt(); | 465 EnsureSpaceForLazyDeopt(); |
437 RecordCallPosition(instr); | 466 RecordCallPosition(instr); |
438 break; | 467 break; |
439 } | 468 } |
440 case kArchPrepareCallCFunction: { | 469 case kArchPrepareCallCFunction: { |
441 int const num_parameters = MiscField::decode(instr->opcode()); | 470 int const num_parameters = MiscField::decode(instr->opcode()); |
442 __ PrepareCallCFunction(num_parameters, kScratchReg); | 471 __ PrepareCallCFunction(num_parameters, kScratchReg); |
443 break; | 472 break; |
444 } | 473 } |
474 case kArchPrepareTailCall: | |
475 AssemblePrepareTailCall(i.InputInt32(instr->InputCount() - 1)); | |
476 break; | |
445 case kArchCallCFunction: { | 477 case kArchCallCFunction: { |
446 int const num_parameters = MiscField::decode(instr->opcode()); | 478 int const num_parameters = MiscField::decode(instr->opcode()); |
447 if (instr->InputAt(0)->IsImmediate()) { | 479 if (instr->InputAt(0)->IsImmediate()) { |
448 ExternalReference ref = i.InputExternalReference(0); | 480 ExternalReference ref = i.InputExternalReference(0); |
449 __ CallCFunction(ref, num_parameters); | 481 __ CallCFunction(ref, num_parameters); |
450 } else { | 482 } else { |
451 Register func = i.InputRegister(0); | 483 Register func = i.InputRegister(0); |
452 __ CallCFunction(func, num_parameters); | 484 __ CallCFunction(func, num_parameters); |
453 } | 485 } |
454 break; | 486 break; |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1336 padding_size -= v8::internal::Assembler::kInstrSize; | 1368 padding_size -= v8::internal::Assembler::kInstrSize; |
1337 } | 1369 } |
1338 } | 1370 } |
1339 } | 1371 } |
1340 | 1372 |
1341 #undef __ | 1373 #undef __ |
1342 | 1374 |
1343 } // namespace compiler | 1375 } // namespace compiler |
1344 } // namespace internal | 1376 } // namespace internal |
1345 } // namespace v8 | 1377 } // namespace v8 |
OLD | NEW |