OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4917 __ Call(finally_entry_); | 4917 __ Call(finally_entry_); |
4918 | 4918 |
4919 *stack_depth = 0; | 4919 *stack_depth = 0; |
4920 *context_length = 0; | 4920 *context_length = 0; |
4921 return previous_; | 4921 return previous_; |
4922 } | 4922 } |
4923 | 4923 |
4924 | 4924 |
4925 #undef __ | 4925 #undef __ |
4926 | 4926 |
| 4927 |
| 4928 // This structure comes from FullCodeGenerator::EmitBackEdgeBookkeeping. |
| 4929 // The back edge bookkeeping code matches the pattern: |
| 4930 // |
| 4931 // sltu at, sp, t0 / slt at, a3, zero_reg (in case of count based interrupts) |
| 4932 // beq at, zero_reg, ok |
| 4933 // lui t9, <interrupt stub address> upper |
| 4934 // ori t9, <interrupt stub address> lower |
| 4935 // jalr t9 |
| 4936 // nop |
| 4937 // ok-label ----- pc_after points here |
| 4938 // |
| 4939 // We patch the code to the following form: |
| 4940 // |
| 4941 // addiu at, zero_reg, 1 |
| 4942 // beq at, zero_reg, ok ;; Not changed |
| 4943 // lui t9, <on-stack replacement address> upper |
| 4944 // ori t9, <on-stack replacement address> lower |
| 4945 // jalr t9 ;; Not changed |
| 4946 // nop ;; Not changed |
| 4947 // ok-label ----- pc_after points here |
| 4948 |
| 4949 void BackEdgeTable::PatchAt(Code* unoptimized_code, |
| 4950 Address pc_after, |
| 4951 Code* replacement_code) { |
| 4952 static const int kInstrSize = Assembler::kInstrSize; |
| 4953 // Replace the sltu instruction with load-imm 1 to at, so beq is not taken. |
| 4954 CodePatcher patcher(pc_after - 6 * kInstrSize, 1); |
| 4955 patcher.masm()->addiu(at, zero_reg, 1); |
| 4956 // Replace the stack check address in the load-immediate (lui/ori pair) |
| 4957 // with the entry address of the replacement code. |
| 4958 Assembler::set_target_address_at(pc_after - 4 * kInstrSize, |
| 4959 replacement_code->entry()); |
| 4960 |
| 4961 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
| 4962 unoptimized_code, pc_after - 4 * kInstrSize, replacement_code); |
| 4963 } |
| 4964 |
| 4965 |
| 4966 void BackEdgeTable::RevertAt(Code* unoptimized_code, |
| 4967 Address pc_after, |
| 4968 Code* interrupt_code) { |
| 4969 static const int kInstrSize = Assembler::kInstrSize; |
| 4970 // Restore the sltu instruction so beq can be taken again. |
| 4971 CodePatcher patcher(pc_after - 6 * kInstrSize, 1); |
| 4972 patcher.masm()->slt(at, a3, zero_reg); |
| 4973 // Restore the original call address. |
| 4974 Assembler::set_target_address_at(pc_after - 4 * kInstrSize, |
| 4975 interrupt_code->entry()); |
| 4976 |
| 4977 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
| 4978 unoptimized_code, pc_after - 4 * kInstrSize, interrupt_code); |
| 4979 } |
| 4980 |
| 4981 |
| 4982 #ifdef DEBUG |
| 4983 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( |
| 4984 Isolate* isolate, |
| 4985 Code* unoptimized_code, |
| 4986 Address pc_after) { |
| 4987 static const int kInstrSize = Assembler::kInstrSize; |
| 4988 ASSERT(Assembler::IsBeq(Assembler::instr_at(pc_after - 5 * kInstrSize))); |
| 4989 if (Assembler::IsAddImmediate( |
| 4990 Assembler::instr_at(pc_after - 6 * kInstrSize))) { |
| 4991 Code* osr_builtin = |
| 4992 isolate->builtins()->builtin(Builtins::kOnStackReplacement); |
| 4993 ASSERT(reinterpret_cast<uint32_t>( |
| 4994 Assembler::target_address_at(pc_after - 4 * kInstrSize)) == |
| 4995 reinterpret_cast<uint32_t>(osr_builtin->entry())); |
| 4996 return ON_STACK_REPLACEMENT; |
| 4997 } else { |
| 4998 // Get the interrupt stub code object to match against from cache. |
| 4999 Code* interrupt_builtin = |
| 5000 isolate->builtins()->builtin(Builtins::kInterruptCheck); |
| 5001 ASSERT(reinterpret_cast<uint32_t>( |
| 5002 Assembler::target_address_at(pc_after - 4 * kInstrSize)) == |
| 5003 reinterpret_cast<uint32_t>(interrupt_builtin->entry())); |
| 5004 return INTERRUPT; |
| 5005 } |
| 5006 } |
| 5007 #endif // DEBUG |
| 5008 |
| 5009 |
4927 } } // namespace v8::internal | 5010 } } // namespace v8::internal |
4928 | 5011 |
4929 #endif // V8_TARGET_ARCH_MIPS | 5012 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |