OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/ast/scopes.h" | 7 #include "src/ast/scopes.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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, | 420 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
421 scratch3, ReturnAddressState::kOnStack, scratch_count); | 421 scratch3, ReturnAddressState::kOnStack, scratch_count); |
422 __ pop(scratch3); | 422 __ pop(scratch3); |
423 __ pop(scratch2); | 423 __ pop(scratch2); |
424 __ pop(scratch1); | 424 __ pop(scratch1); |
425 | 425 |
426 __ bind(&done); | 426 __ bind(&done); |
427 } | 427 } |
428 | 428 |
429 // Assembles an instruction after register allocation, producing machine code. | 429 // Assembles an instruction after register allocation, producing machine code. |
430 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 430 CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| 431 Instruction* instr) { |
431 IA32OperandConverter i(this, instr); | 432 IA32OperandConverter i(this, instr); |
432 InstructionCode opcode = instr->opcode(); | 433 InstructionCode opcode = instr->opcode(); |
433 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); | 434 ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); |
434 switch (arch_opcode) { | 435 switch (arch_opcode) { |
435 case kArchCallCodeObject: { | 436 case kArchCallCodeObject: { |
436 EnsureSpaceForLazyDeopt(); | 437 EnsureSpaceForLazyDeopt(); |
437 if (HasImmediateInput(instr, 0)) { | 438 if (HasImmediateInput(instr, 0)) { |
438 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 439 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
439 __ call(code, RelocInfo::CODE_TARGET); | 440 __ call(code, RelocInfo::CODE_TARGET); |
440 } else { | 441 } else { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 break; | 540 break; |
540 case kArchNop: | 541 case kArchNop: |
541 case kArchThrowTerminator: | 542 case kArchThrowTerminator: |
542 // don't emit code for nops. | 543 // don't emit code for nops. |
543 break; | 544 break; |
544 case kArchDeoptimize: { | 545 case kArchDeoptimize: { |
545 int deopt_state_id = | 546 int deopt_state_id = |
546 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); | 547 BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); |
547 Deoptimizer::BailoutType bailout_type = | 548 Deoptimizer::BailoutType bailout_type = |
548 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); | 549 Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); |
549 AssembleDeoptimizerCall(deopt_state_id, bailout_type); | 550 CodeGenResult result = |
| 551 AssembleDeoptimizerCall(deopt_state_id, bailout_type); |
| 552 if (result != kSuccess) return result; |
550 break; | 553 break; |
551 } | 554 } |
552 case kArchRet: | 555 case kArchRet: |
553 AssembleReturn(); | 556 AssembleReturn(); |
554 break; | 557 break; |
555 case kArchStackPointer: | 558 case kArchStackPointer: |
556 __ mov(i.OutputRegister(), esp); | 559 __ mov(i.OutputRegister(), esp); |
557 break; | 560 break; |
558 case kArchFramePointer: | 561 case kArchFramePointer: |
559 __ mov(i.OutputRegister(), ebp); | 562 __ mov(i.OutputRegister(), ebp); |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 UNREACHABLE(); // currently unsupported checked int64 load/store. | 1327 UNREACHABLE(); // currently unsupported checked int64 load/store. |
1325 break; | 1328 break; |
1326 case kAtomicLoadInt8: | 1329 case kAtomicLoadInt8: |
1327 case kAtomicLoadUint8: | 1330 case kAtomicLoadUint8: |
1328 case kAtomicLoadInt16: | 1331 case kAtomicLoadInt16: |
1329 case kAtomicLoadUint16: | 1332 case kAtomicLoadUint16: |
1330 case kAtomicLoadWord32: | 1333 case kAtomicLoadWord32: |
1331 UNREACHABLE(); // Won't be generated by instruction selector. | 1334 UNREACHABLE(); // Won't be generated by instruction selector. |
1332 break; | 1335 break; |
1333 } | 1336 } |
| 1337 return kSuccess; |
1334 } // NOLINT(readability/fn_size) | 1338 } // NOLINT(readability/fn_size) |
1335 | 1339 |
1336 | 1340 |
1337 // Assembles a branch after an instruction. | 1341 // Assembles a branch after an instruction. |
1338 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 1342 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
1339 IA32OperandConverter i(this, instr); | 1343 IA32OperandConverter i(this, instr); |
1340 Label::Distance flabel_distance = | 1344 Label::Distance flabel_distance = |
1341 branch->fallthru ? Label::kNear : Label::kFar; | 1345 branch->fallthru ? Label::kNear : Label::kFar; |
1342 Label* tlabel = branch->true_label; | 1346 Label* tlabel = branch->true_label; |
1343 Label* flabel = branch->false_label; | 1347 Label* flabel = branch->false_label; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 Label** cases = zone()->NewArray<Label*>(case_count); | 1501 Label** cases = zone()->NewArray<Label*>(case_count); |
1498 for (size_t index = 0; index < case_count; ++index) { | 1502 for (size_t index = 0; index < case_count; ++index) { |
1499 cases[index] = GetLabel(i.InputRpo(index + 2)); | 1503 cases[index] = GetLabel(i.InputRpo(index + 2)); |
1500 } | 1504 } |
1501 Label* const table = AddJumpTable(cases, case_count); | 1505 Label* const table = AddJumpTable(cases, case_count); |
1502 __ cmp(input, Immediate(case_count)); | 1506 __ cmp(input, Immediate(case_count)); |
1503 __ j(above_equal, GetLabel(i.InputRpo(1))); | 1507 __ j(above_equal, GetLabel(i.InputRpo(1))); |
1504 __ jmp(Operand::JumpTable(input, times_4, table)); | 1508 __ jmp(Operand::JumpTable(input, times_4, table)); |
1505 } | 1509 } |
1506 | 1510 |
1507 | 1511 CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall( |
1508 void CodeGenerator::AssembleDeoptimizerCall( | |
1509 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { | 1512 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { |
1510 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( | 1513 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
1511 isolate(), deoptimization_id, bailout_type); | 1514 isolate(), deoptimization_id, bailout_type); |
| 1515 if (deopt_entry == nullptr) return kTooManyDeoptimizationBailouts; |
1512 __ call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1516 __ call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
| 1517 return kSuccess; |
1513 } | 1518 } |
1514 | 1519 |
1515 | 1520 |
1516 // The calling convention for JSFunctions on IA32 passes arguments on the | 1521 // The calling convention for JSFunctions on IA32 passes arguments on the |
1517 // stack and the JSFunction and context in EDI and ESI, respectively, thus | 1522 // stack and the JSFunction and context in EDI and ESI, respectively, thus |
1518 // the steps of the call look as follows: | 1523 // the steps of the call look as follows: |
1519 | 1524 |
1520 // --{ before the call instruction }-------------------------------------------- | 1525 // --{ before the call instruction }-------------------------------------------- |
1521 // | caller frame | | 1526 // | caller frame | |
1522 // ^ esp ^ ebp | 1527 // ^ esp ^ ebp |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1930 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 1935 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
1931 __ Nop(padding_size); | 1936 __ Nop(padding_size); |
1932 } | 1937 } |
1933 } | 1938 } |
1934 | 1939 |
1935 #undef __ | 1940 #undef __ |
1936 | 1941 |
1937 } // namespace compiler | 1942 } // namespace compiler |
1938 } // namespace internal | 1943 } // namespace internal |
1939 } // namespace v8 | 1944 } // namespace v8 |
OLD | NEW |