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 #include "src/arm/lithium-codegen-arm.h" | 7 #include "src/arm/lithium-codegen-arm.h" |
8 #include "src/arm/lithium-gap-resolver-arm.h" | 8 #include "src/arm/lithium-gap-resolver-arm.h" |
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 312 |
313 bool LCodeGen::GenerateJumpTable() { | 313 bool LCodeGen::GenerateJumpTable() { |
314 // Check that the jump table is accessible from everywhere in the function | 314 // Check that the jump table is accessible from everywhere in the function |
315 // code, i.e. that offsets to the table can be encoded in the 24bit signed | 315 // code, i.e. that offsets to the table can be encoded in the 24bit signed |
316 // immediate of a branch instruction. | 316 // immediate of a branch instruction. |
317 // To simplify we consider the code size from the first instruction to the | 317 // To simplify we consider the code size from the first instruction to the |
318 // end of the jump table. We also don't consider the pc load delta. | 318 // end of the jump table. We also don't consider the pc load delta. |
319 // Each entry in the jump table generates one instruction and inlines one | 319 // Each entry in the jump table generates one instruction and inlines one |
320 // 32bit data after it. | 320 // 32bit data after it. |
321 if (!is_int24((masm()->pc_offset() / Assembler::kInstrSize) + | 321 if (!is_int24((masm()->pc_offset() / Assembler::kInstrSize) + |
322 deopt_jump_table_.length() * 7)) { | 322 jump_table_.length() * 7)) { |
323 Abort(kGeneratedCodeIsTooLarge); | 323 Abort(kGeneratedCodeIsTooLarge); |
324 } | 324 } |
325 | 325 |
326 if (deopt_jump_table_.length() > 0) { | 326 if (jump_table_.length() > 0) { |
327 Label needs_frame, call_deopt_entry; | 327 Label needs_frame, call_deopt_entry; |
328 | 328 |
329 Comment(";;; -------------------- Jump table --------------------"); | 329 Comment(";;; -------------------- Jump table --------------------"); |
330 Address base = deopt_jump_table_[0].address; | 330 Address base = jump_table_[0].address; |
331 | 331 |
332 Register entry_offset = scratch0(); | 332 Register entry_offset = scratch0(); |
333 | 333 |
334 int length = deopt_jump_table_.length(); | 334 int length = jump_table_.length(); |
335 for (int i = 0; i < length; i++) { | 335 for (int i = 0; i < length; i++) { |
336 Deoptimizer::JumpTableEntry* table_entry = &deopt_jump_table_[i]; | 336 Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i]; |
337 __ bind(&table_entry->label); | 337 __ bind(&table_entry->label); |
338 | 338 |
339 Deoptimizer::BailoutType type = table_entry->bailout_type; | 339 DCHECK_EQ(jump_table_[0].bailout_type, table_entry->bailout_type); |
340 DCHECK(type == deopt_jump_table_[0].bailout_type); | |
341 Address entry = table_entry->address; | 340 Address entry = table_entry->address; |
342 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); | |
343 DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id); | |
344 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); | |
345 DeoptComment(table_entry->reason); | 341 DeoptComment(table_entry->reason); |
346 | 342 |
347 // Second-level deopt table entries are contiguous and small, so instead | 343 // Second-level deopt table entries are contiguous and small, so instead |
348 // of loading the full, absolute address of each one, load an immediate | 344 // of loading the full, absolute address of each one, load an immediate |
349 // offset which will be added to the base address later. | 345 // offset which will be added to the base address later. |
350 __ mov(entry_offset, Operand(entry - base)); | 346 __ mov(entry_offset, Operand(entry - base)); |
351 | 347 |
352 if (table_entry->needs_frame) { | 348 if (table_entry->needs_frame) { |
353 DCHECK(!info()->saves_caller_doubles()); | 349 DCHECK(!info()->saves_caller_doubles()); |
354 if (needs_frame.is_bound()) { | 350 if (needs_frame.is_bound()) { |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 Deoptimizer::Reason reason(instr->hydrogen_value()->position().raw(), | 898 Deoptimizer::Reason reason(instr->hydrogen_value()->position().raw(), |
903 instr->Mnemonic(), detail); | 899 instr->Mnemonic(), detail); |
904 DCHECK(info()->IsStub() || frame_is_built_); | 900 DCHECK(info()->IsStub() || frame_is_built_); |
905 // Go through jump table if we need to handle condition, build frame, or | 901 // Go through jump table if we need to handle condition, build frame, or |
906 // restore caller doubles. | 902 // restore caller doubles. |
907 if (condition == al && frame_is_built_ && | 903 if (condition == al && frame_is_built_ && |
908 !info()->saves_caller_doubles()) { | 904 !info()->saves_caller_doubles()) { |
909 DeoptComment(reason); | 905 DeoptComment(reason); |
910 __ Call(entry, RelocInfo::RUNTIME_ENTRY); | 906 __ Call(entry, RelocInfo::RUNTIME_ENTRY); |
911 } else { | 907 } else { |
| 908 Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type, |
| 909 !frame_is_built_); |
912 // We often have several deopts to the same entry, reuse the last | 910 // We often have several deopts to the same entry, reuse the last |
913 // jump entry if this is the case. | 911 // jump entry if this is the case. |
914 if (deopt_jump_table_.is_empty() || | 912 if (jump_table_.is_empty() || |
915 (deopt_jump_table_.last().address != entry) || | 913 !table_entry.IsEquivalentTo(jump_table_.last())) { |
916 (deopt_jump_table_.last().bailout_type != bailout_type) || | 914 jump_table_.Add(table_entry, zone()); |
917 (deopt_jump_table_.last().needs_frame != !frame_is_built_)) { | |
918 Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type, | |
919 !frame_is_built_); | |
920 deopt_jump_table_.Add(table_entry, zone()); | |
921 } | 915 } |
922 __ b(condition, &deopt_jump_table_.last().label); | 916 __ b(condition, &jump_table_.last().label); |
923 } | 917 } |
924 } | 918 } |
925 | 919 |
926 | 920 |
927 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr, | 921 void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr, |
928 const char* detail) { | 922 const char* detail) { |
929 Deoptimizer::BailoutType bailout_type = info()->IsStub() | 923 Deoptimizer::BailoutType bailout_type = info()->IsStub() |
930 ? Deoptimizer::LAZY | 924 ? Deoptimizer::LAZY |
931 : Deoptimizer::EAGER; | 925 : Deoptimizer::EAGER; |
932 DeoptimizeIf(condition, instr, detail, bailout_type); | 926 DeoptimizeIf(condition, instr, detail, bailout_type); |
(...skipping 4975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5908 __ Push(scope_info); | 5902 __ Push(scope_info); |
5909 __ push(ToRegister(instr->function())); | 5903 __ push(ToRegister(instr->function())); |
5910 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5904 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5911 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5905 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5912 } | 5906 } |
5913 | 5907 |
5914 | 5908 |
5915 #undef __ | 5909 #undef __ |
5916 | 5910 |
5917 } } // namespace v8::internal | 5911 } } // namespace v8::internal |
OLD | NEW |