| 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_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 357 } |
| 358 } | 358 } |
| 359 | 359 |
| 360 | 360 |
| 361 bool LCodeGen::GenerateJumpTable() { | 361 bool LCodeGen::GenerateJumpTable() { |
| 362 Label needs_frame; | 362 Label needs_frame; |
| 363 if (jump_table_.length() > 0) { | 363 if (jump_table_.length() > 0) { |
| 364 Comment(";;; -------------------- Jump table --------------------"); | 364 Comment(";;; -------------------- Jump table --------------------"); |
| 365 } | 365 } |
| 366 for (int i = 0; i < jump_table_.length(); i++) { | 366 for (int i = 0; i < jump_table_.length(); i++) { |
| 367 __ bind(&jump_table_[i].label); | 367 Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i]; |
| 368 Address entry = jump_table_[i].address; | 368 __ bind(&table_entry->label); |
| 369 Deoptimizer::BailoutType type = jump_table_[i].bailout_type; | 369 Address entry = table_entry->address; |
| 370 Deoptimizer::BailoutType type = table_entry->bailout_type; |
| 370 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); | 371 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); |
| 371 if (id == Deoptimizer::kNotDeoptimizationEntry) { | 372 if (id == Deoptimizer::kNotDeoptimizationEntry) { |
| 372 Comment(";;; jump table entry %d.", i); | 373 Comment(";;; jump table entry %d.", i); |
| 373 } else { | 374 } else { |
| 374 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); | 375 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); |
| 375 } | 376 } |
| 376 if (jump_table_[i].needs_frame) { | 377 DeoptComment(table_entry->mnemonic, table_entry->reason); |
| 378 if (table_entry->needs_frame) { |
| 377 DCHECK(!info()->saves_caller_doubles()); | 379 DCHECK(!info()->saves_caller_doubles()); |
| 378 __ push(Immediate(ExternalReference::ForDeoptEntry(entry))); | 380 __ push(Immediate(ExternalReference::ForDeoptEntry(entry))); |
| 379 if (needs_frame.is_bound()) { | 381 if (needs_frame.is_bound()) { |
| 380 __ jmp(&needs_frame); | 382 __ jmp(&needs_frame); |
| 381 } else { | 383 } else { |
| 382 __ bind(&needs_frame); | 384 __ bind(&needs_frame); |
| 383 __ push(MemOperand(ebp, StandardFrameConstants::kContextOffset)); | 385 __ push(MemOperand(ebp, StandardFrameConstants::kContextOffset)); |
| 384 // This variant of deopt can only be used with stubs. Since we don't | 386 // This variant of deopt can only be used with stubs. Since we don't |
| 385 // have a function pointer to install in the stack frame that we're | 387 // have a function pointer to install in the stack frame that we're |
| 386 // building, install a special marker there instead. | 388 // building, install a special marker there instead. |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 int pc_offset = masm()->pc_offset(); | 1003 int pc_offset = masm()->pc_offset(); |
| 1002 environment->Register(deoptimization_index, | 1004 environment->Register(deoptimization_index, |
| 1003 translation.index(), | 1005 translation.index(), |
| 1004 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 1006 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
| 1005 deoptimizations_.Add(environment, zone()); | 1007 deoptimizations_.Add(environment, zone()); |
| 1006 } | 1008 } |
| 1007 } | 1009 } |
| 1008 | 1010 |
| 1009 | 1011 |
| 1010 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, | 1012 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, |
| 1013 const char* reason, |
| 1011 Deoptimizer::BailoutType bailout_type) { | 1014 Deoptimizer::BailoutType bailout_type) { |
| 1012 LEnvironment* environment = instr->environment(); | 1015 LEnvironment* environment = instr->environment(); |
| 1013 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 1016 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
| 1014 DCHECK(environment->HasBeenRegistered()); | 1017 DCHECK(environment->HasBeenRegistered()); |
| 1015 int id = environment->deoptimization_index(); | 1018 int id = environment->deoptimization_index(); |
| 1016 DCHECK(info()->IsOptimizing() || info()->IsStub()); | 1019 DCHECK(info()->IsOptimizing() || info()->IsStub()); |
| 1017 Address entry = | 1020 Address entry = |
| 1018 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); | 1021 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); |
| 1019 if (entry == NULL) { | 1022 if (entry == NULL) { |
| 1020 Abort(kBailoutWasNotPrepared); | 1023 Abort(kBailoutWasNotPrepared); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 | 1058 |
| 1056 if (info()->ShouldTrapOnDeopt()) { | 1059 if (info()->ShouldTrapOnDeopt()) { |
| 1057 Label done; | 1060 Label done; |
| 1058 if (cc != no_condition) __ j(NegateCondition(cc), &done, Label::kNear); | 1061 if (cc != no_condition) __ j(NegateCondition(cc), &done, Label::kNear); |
| 1059 __ int3(); | 1062 __ int3(); |
| 1060 __ bind(&done); | 1063 __ bind(&done); |
| 1061 } | 1064 } |
| 1062 | 1065 |
| 1063 DCHECK(info()->IsStub() || frame_is_built_); | 1066 DCHECK(info()->IsStub() || frame_is_built_); |
| 1064 if (cc == no_condition && frame_is_built_) { | 1067 if (cc == no_condition && frame_is_built_) { |
| 1068 DeoptComment(instr->Mnemonic(), reason); |
| 1065 __ call(entry, RelocInfo::RUNTIME_ENTRY); | 1069 __ call(entry, RelocInfo::RUNTIME_ENTRY); |
| 1066 } else { | 1070 } else { |
| 1067 // We often have several deopts to the same entry, reuse the last | 1071 // We often have several deopts to the same entry, reuse the last |
| 1068 // jump entry if this is the case. | 1072 // jump entry if this is the case. |
| 1069 if (jump_table_.is_empty() || | 1073 if (jump_table_.is_empty() || |
| 1070 jump_table_.last().address != entry || | 1074 jump_table_.last().address != entry || |
| 1071 jump_table_.last().needs_frame != !frame_is_built_ || | 1075 jump_table_.last().needs_frame != !frame_is_built_ || |
| 1072 jump_table_.last().bailout_type != bailout_type) { | 1076 jump_table_.last().bailout_type != bailout_type) { |
| 1073 Deoptimizer::JumpTableEntry table_entry(entry, | 1077 Deoptimizer::JumpTableEntry table_entry(entry, instr->Mnemonic(), reason, |
| 1074 bailout_type, | 1078 bailout_type, !frame_is_built_); |
| 1075 !frame_is_built_); | |
| 1076 jump_table_.Add(table_entry, zone()); | 1079 jump_table_.Add(table_entry, zone()); |
| 1077 } | 1080 } |
| 1078 if (cc == no_condition) { | 1081 if (cc == no_condition) { |
| 1079 __ jmp(&jump_table_.last().label); | 1082 __ jmp(&jump_table_.last().label); |
| 1080 } else { | 1083 } else { |
| 1081 __ j(cc, &jump_table_.last().label); | 1084 __ j(cc, &jump_table_.last().label); |
| 1082 } | 1085 } |
| 1083 } | 1086 } |
| 1084 } | 1087 } |
| 1085 | 1088 |
| 1086 | 1089 |
| 1087 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr) { | 1090 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, |
| 1091 const char* reason) { |
| 1088 Deoptimizer::BailoutType bailout_type = info()->IsStub() | 1092 Deoptimizer::BailoutType bailout_type = info()->IsStub() |
| 1089 ? Deoptimizer::LAZY | 1093 ? Deoptimizer::LAZY |
| 1090 : Deoptimizer::EAGER; | 1094 : Deoptimizer::EAGER; |
| 1091 DeoptimizeIf(cc, instr, bailout_type); | 1095 DeoptimizeIf(cc, instr, reason, bailout_type); |
| 1092 } | 1096 } |
| 1093 | 1097 |
| 1094 | 1098 |
| 1095 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { | 1099 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { |
| 1096 int length = deoptimizations_.length(); | 1100 int length = deoptimizations_.length(); |
| 1097 if (length == 0) return; | 1101 if (length == 0) return; |
| 1098 Handle<DeoptimizationInputData> data = | 1102 Handle<DeoptimizationInputData> data = |
| 1099 DeoptimizationInputData::New(isolate(), length, TENURED); | 1103 DeoptimizationInputData::New(isolate(), length, TENURED); |
| 1100 | 1104 |
| 1101 Handle<ByteArray> translations = | 1105 Handle<ByteArray> translations = |
| (...skipping 4419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5521 | 5525 |
| 5522 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { | 5526 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { |
| 5523 Deoptimizer::BailoutType type = instr->hydrogen()->type(); | 5527 Deoptimizer::BailoutType type = instr->hydrogen()->type(); |
| 5524 // TODO(danno): Stubs expect all deopts to be lazy for historical reasons (the | 5528 // TODO(danno): Stubs expect all deopts to be lazy for historical reasons (the |
| 5525 // needed return address), even though the implementation of LAZY and EAGER is | 5529 // needed return address), even though the implementation of LAZY and EAGER is |
| 5526 // now identical. When LAZY is eventually completely folded into EAGER, remove | 5530 // now identical. When LAZY is eventually completely folded into EAGER, remove |
| 5527 // the special case below. | 5531 // the special case below. |
| 5528 if (info()->IsStub() && type == Deoptimizer::EAGER) { | 5532 if (info()->IsStub() && type == Deoptimizer::EAGER) { |
| 5529 type = Deoptimizer::LAZY; | 5533 type = Deoptimizer::LAZY; |
| 5530 } | 5534 } |
| 5531 Comment(";;; deoptimize: %s", instr->hydrogen()->reason()); | 5535 DeoptimizeIf(no_condition, instr, instr->hydrogen()->reason(), type); |
| 5532 DeoptimizeIf(no_condition, instr, type); | |
| 5533 } | 5536 } |
| 5534 | 5537 |
| 5535 | 5538 |
| 5536 void LCodeGen::DoDummy(LDummy* instr) { | 5539 void LCodeGen::DoDummy(LDummy* instr) { |
| 5537 // Nothing to see here, move on! | 5540 // Nothing to see here, move on! |
| 5538 } | 5541 } |
| 5539 | 5542 |
| 5540 | 5543 |
| 5541 void LCodeGen::DoDummyUse(LDummyUse* instr) { | 5544 void LCodeGen::DoDummyUse(LDummyUse* instr) { |
| 5542 // Nothing to see here, move on! | 5545 // Nothing to see here, move on! |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5770 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5773 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 5771 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5774 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 5772 } | 5775 } |
| 5773 | 5776 |
| 5774 | 5777 |
| 5775 #undef __ | 5778 #undef __ |
| 5776 | 5779 |
| 5777 } } // namespace v8::internal | 5780 } } // namespace v8::internal |
| 5778 | 5781 |
| 5779 #endif // V8_TARGET_ARCH_X87 | 5782 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |