| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 376 |
| 377 void LCodeGen::GenerateBodyInstructionPost(LInstruction* instr) { } | 377 void LCodeGen::GenerateBodyInstructionPost(LInstruction* instr) { } |
| 378 | 378 |
| 379 | 379 |
| 380 bool LCodeGen::GenerateJumpTable() { | 380 bool LCodeGen::GenerateJumpTable() { |
| 381 Label needs_frame; | 381 Label needs_frame; |
| 382 if (jump_table_.length() > 0) { | 382 if (jump_table_.length() > 0) { |
| 383 Comment(";;; -------------------- Jump table --------------------"); | 383 Comment(";;; -------------------- Jump table --------------------"); |
| 384 } | 384 } |
| 385 for (int i = 0; i < jump_table_.length(); i++) { | 385 for (int i = 0; i < jump_table_.length(); i++) { |
| 386 __ bind(&jump_table_[i].label); | 386 Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i]; |
| 387 Address entry = jump_table_[i].address; | 387 __ bind(&table_entry->label); |
| 388 Deoptimizer::BailoutType type = jump_table_[i].bailout_type; | 388 Address entry = table_entry->address; |
| 389 Deoptimizer::BailoutType type = table_entry->bailout_type; |
| 389 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); | 390 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); |
| 390 if (id == Deoptimizer::kNotDeoptimizationEntry) { | 391 if (id == Deoptimizer::kNotDeoptimizationEntry) { |
| 391 Comment(";;; jump table entry %d.", i); | 392 Comment(";;; jump table entry %d.", i); |
| 392 } else { | 393 } else { |
| 393 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); | 394 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); |
| 394 } | 395 } |
| 395 if (jump_table_[i].needs_frame) { | 396 DeoptComment(table_entry->mnemonic, table_entry->reason); |
| 397 if (table_entry->needs_frame) { |
| 396 DCHECK(!info()->saves_caller_doubles()); | 398 DCHECK(!info()->saves_caller_doubles()); |
| 397 __ push(Immediate(ExternalReference::ForDeoptEntry(entry))); | 399 __ push(Immediate(ExternalReference::ForDeoptEntry(entry))); |
| 398 if (needs_frame.is_bound()) { | 400 if (needs_frame.is_bound()) { |
| 399 __ jmp(&needs_frame); | 401 __ jmp(&needs_frame); |
| 400 } else { | 402 } else { |
| 401 __ bind(&needs_frame); | 403 __ bind(&needs_frame); |
| 402 __ push(MemOperand(ebp, StandardFrameConstants::kContextOffset)); | 404 __ push(MemOperand(ebp, StandardFrameConstants::kContextOffset)); |
| 403 // This variant of deopt can only be used with stubs. Since we don't | 405 // This variant of deopt can only be used with stubs. Since we don't |
| 404 // have a function pointer to install in the stack frame that we're | 406 // have a function pointer to install in the stack frame that we're |
| 405 // building, install a special marker there instead. | 407 // building, install a special marker there instead. |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 int pc_offset = masm()->pc_offset(); | 821 int pc_offset = masm()->pc_offset(); |
| 820 environment->Register(deoptimization_index, | 822 environment->Register(deoptimization_index, |
| 821 translation.index(), | 823 translation.index(), |
| 822 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 824 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
| 823 deoptimizations_.Add(environment, zone()); | 825 deoptimizations_.Add(environment, zone()); |
| 824 } | 826 } |
| 825 } | 827 } |
| 826 | 828 |
| 827 | 829 |
| 828 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, | 830 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, |
| 831 const char* reason, |
| 829 Deoptimizer::BailoutType bailout_type) { | 832 Deoptimizer::BailoutType bailout_type) { |
| 830 LEnvironment* environment = instr->environment(); | 833 LEnvironment* environment = instr->environment(); |
| 831 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 834 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
| 832 DCHECK(environment->HasBeenRegistered()); | 835 DCHECK(environment->HasBeenRegistered()); |
| 833 int id = environment->deoptimization_index(); | 836 int id = environment->deoptimization_index(); |
| 834 DCHECK(info()->IsOptimizing() || info()->IsStub()); | 837 DCHECK(info()->IsOptimizing() || info()->IsStub()); |
| 835 Address entry = | 838 Address entry = |
| 836 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); | 839 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); |
| 837 if (entry == NULL) { | 840 if (entry == NULL) { |
| 838 Abort(kBailoutWasNotPrepared); | 841 Abort(kBailoutWasNotPrepared); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 862 | 865 |
| 863 if (info()->ShouldTrapOnDeopt()) { | 866 if (info()->ShouldTrapOnDeopt()) { |
| 864 Label done; | 867 Label done; |
| 865 if (cc != no_condition) __ j(NegateCondition(cc), &done, Label::kNear); | 868 if (cc != no_condition) __ j(NegateCondition(cc), &done, Label::kNear); |
| 866 __ int3(); | 869 __ int3(); |
| 867 __ bind(&done); | 870 __ bind(&done); |
| 868 } | 871 } |
| 869 | 872 |
| 870 DCHECK(info()->IsStub() || frame_is_built_); | 873 DCHECK(info()->IsStub() || frame_is_built_); |
| 871 if (cc == no_condition && frame_is_built_) { | 874 if (cc == no_condition && frame_is_built_) { |
| 875 DeoptComment(instr->Mnemonic(), reason); |
| 872 __ call(entry, RelocInfo::RUNTIME_ENTRY); | 876 __ call(entry, RelocInfo::RUNTIME_ENTRY); |
| 873 } else { | 877 } else { |
| 874 // We often have several deopts to the same entry, reuse the last | 878 // We often have several deopts to the same entry, reuse the last |
| 875 // jump entry if this is the case. | 879 // jump entry if this is the case. |
| 876 if (jump_table_.is_empty() || | 880 if (jump_table_.is_empty() || |
| 877 jump_table_.last().address != entry || | 881 jump_table_.last().address != entry || |
| 878 jump_table_.last().needs_frame != !frame_is_built_ || | 882 jump_table_.last().needs_frame != !frame_is_built_ || |
| 879 jump_table_.last().bailout_type != bailout_type) { | 883 jump_table_.last().bailout_type != bailout_type) { |
| 880 Deoptimizer::JumpTableEntry table_entry(entry, | 884 Deoptimizer::JumpTableEntry table_entry(entry, instr->Mnemonic(), reason, |
| 881 bailout_type, | 885 bailout_type, !frame_is_built_); |
| 882 !frame_is_built_); | |
| 883 jump_table_.Add(table_entry, zone()); | 886 jump_table_.Add(table_entry, zone()); |
| 884 } | 887 } |
| 885 if (cc == no_condition) { | 888 if (cc == no_condition) { |
| 886 __ jmp(&jump_table_.last().label); | 889 __ jmp(&jump_table_.last().label); |
| 887 } else { | 890 } else { |
| 888 __ j(cc, &jump_table_.last().label); | 891 __ j(cc, &jump_table_.last().label); |
| 889 } | 892 } |
| 890 } | 893 } |
| 891 } | 894 } |
| 892 | 895 |
| 893 | 896 |
| 894 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr) { | 897 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, |
| 898 const char* reason) { |
| 895 Deoptimizer::BailoutType bailout_type = info()->IsStub() | 899 Deoptimizer::BailoutType bailout_type = info()->IsStub() |
| 896 ? Deoptimizer::LAZY | 900 ? Deoptimizer::LAZY |
| 897 : Deoptimizer::EAGER; | 901 : Deoptimizer::EAGER; |
| 898 DeoptimizeIf(cc, instr, bailout_type); | 902 DeoptimizeIf(cc, instr, reason, bailout_type); |
| 899 } | 903 } |
| 900 | 904 |
| 901 | 905 |
| 902 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { | 906 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { |
| 903 int length = deoptimizations_.length(); | 907 int length = deoptimizations_.length(); |
| 904 if (length == 0) return; | 908 if (length == 0) return; |
| 905 Handle<DeoptimizationInputData> data = | 909 Handle<DeoptimizationInputData> data = |
| 906 DeoptimizationInputData::New(isolate(), length, TENURED); | 910 DeoptimizationInputData::New(isolate(), length, TENURED); |
| 907 | 911 |
| 908 Handle<ByteArray> translations = | 912 Handle<ByteArray> translations = |
| (...skipping 4547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5456 | 5460 |
| 5457 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { | 5461 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { |
| 5458 Deoptimizer::BailoutType type = instr->hydrogen()->type(); | 5462 Deoptimizer::BailoutType type = instr->hydrogen()->type(); |
| 5459 // TODO(danno): Stubs expect all deopts to be lazy for historical reasons (the | 5463 // TODO(danno): Stubs expect all deopts to be lazy for historical reasons (the |
| 5460 // needed return address), even though the implementation of LAZY and EAGER is | 5464 // needed return address), even though the implementation of LAZY and EAGER is |
| 5461 // now identical. When LAZY is eventually completely folded into EAGER, remove | 5465 // now identical. When LAZY is eventually completely folded into EAGER, remove |
| 5462 // the special case below. | 5466 // the special case below. |
| 5463 if (info()->IsStub() && type == Deoptimizer::EAGER) { | 5467 if (info()->IsStub() && type == Deoptimizer::EAGER) { |
| 5464 type = Deoptimizer::LAZY; | 5468 type = Deoptimizer::LAZY; |
| 5465 } | 5469 } |
| 5466 Comment(";;; deoptimize: %s", instr->hydrogen()->reason()); | 5470 DeoptimizeIf(no_condition, instr, instr->hydrogen()->reason(), type); |
| 5467 DeoptimizeIf(no_condition, instr, type); | |
| 5468 } | 5471 } |
| 5469 | 5472 |
| 5470 | 5473 |
| 5471 void LCodeGen::DoDummy(LDummy* instr) { | 5474 void LCodeGen::DoDummy(LDummy* instr) { |
| 5472 // Nothing to see here, move on! | 5475 // Nothing to see here, move on! |
| 5473 } | 5476 } |
| 5474 | 5477 |
| 5475 | 5478 |
| 5476 void LCodeGen::DoDummyUse(LDummyUse* instr) { | 5479 void LCodeGen::DoDummyUse(LDummyUse* instr) { |
| 5477 // Nothing to see here, move on! | 5480 // Nothing to see here, move on! |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5702 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5705 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 5703 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5706 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 5704 } | 5707 } |
| 5705 | 5708 |
| 5706 | 5709 |
| 5707 #undef __ | 5710 #undef __ |
| 5708 | 5711 |
| 5709 } } // namespace v8::internal | 5712 } } // namespace v8::internal |
| 5710 | 5713 |
| 5711 #endif // V8_TARGET_ARCH_IA32 | 5714 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |