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 13 matching lines...) Expand all Loading... |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "mips/lithium-codegen-mips.h" | 30 #include "mips/lithium-codegen-mips.h" |
31 #include "mips/lithium-gap-resolver-mips.h" | 31 #include "mips/lithium-gap-resolver-mips.h" |
32 #include "code-stubs.h" | 32 #include "code-stubs.h" |
33 #include "stub-cache.h" | 33 #include "stub-cache.h" |
| 34 #include "hydrogen-osr.h" |
34 | 35 |
35 namespace v8 { | 36 namespace v8 { |
36 namespace internal { | 37 namespace internal { |
37 | 38 |
38 | 39 |
39 class SafepointGenerator V8_FINAL : public CallWrapper { | 40 class SafepointGenerator V8_FINAL : public CallWrapper { |
40 public: | 41 public: |
41 SafepointGenerator(LCodeGen* codegen, | 42 SafepointGenerator(LCodeGen* codegen, |
42 LPointerMap* pointers, | 43 LPointerMap* pointers, |
43 Safepoint::DeoptMode mode) | 44 Safepoint::DeoptMode mode) |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 241 } |
241 | 242 |
242 // Trace the call. | 243 // Trace the call. |
243 if (FLAG_trace && info()->IsOptimizing()) { | 244 if (FLAG_trace && info()->IsOptimizing()) { |
244 __ CallRuntime(Runtime::kTraceEnter, 0); | 245 __ CallRuntime(Runtime::kTraceEnter, 0); |
245 } | 246 } |
246 return !is_aborted(); | 247 return !is_aborted(); |
247 } | 248 } |
248 | 249 |
249 | 250 |
| 251 void LCodeGen::GenerateOsrPrologue() { |
| 252 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
| 253 // are none, at the OSR entrypoint instruction. |
| 254 if (osr_pc_offset_ >= 0) return; |
| 255 |
| 256 osr_pc_offset_ = masm()->pc_offset(); |
| 257 |
| 258 // Adjust the frame size, subsuming the unoptimized frame into the |
| 259 // optimized frame. |
| 260 int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); |
| 261 ASSERT(slots >= 0); |
| 262 __ Subu(sp, sp, Operand(slots * kPointerSize)); |
| 263 } |
| 264 |
| 265 |
250 bool LCodeGen::GenerateBody() { | 266 bool LCodeGen::GenerateBody() { |
251 ASSERT(is_generating()); | 267 ASSERT(is_generating()); |
252 bool emit_instructions = true; | 268 bool emit_instructions = true; |
253 for (current_instruction_ = 0; | 269 for (current_instruction_ = 0; |
254 !is_aborted() && current_instruction_ < instructions_->length(); | 270 !is_aborted() && current_instruction_ < instructions_->length(); |
255 current_instruction_++) { | 271 current_instruction_++) { |
256 LInstruction* instr = instructions_->at(current_instruction_); | 272 LInstruction* instr = instructions_->at(current_instruction_); |
257 | 273 |
258 // Don't emit code for basic blocks with a replacement. | 274 // Don't emit code for basic blocks with a replacement. |
259 if (instr->IsLabel()) { | 275 if (instr->IsLabel()) { |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 1080 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
1065 break; | 1081 break; |
1066 } | 1082 } |
1067 default: | 1083 default: |
1068 UNREACHABLE(); | 1084 UNREACHABLE(); |
1069 } | 1085 } |
1070 } | 1086 } |
1071 | 1087 |
1072 | 1088 |
1073 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 1089 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
1074 // Record the address of the first unknown OSR value as the place to enter. | 1090 GenerateOsrPrologue(); |
1075 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
1076 } | 1091 } |
1077 | 1092 |
1078 | 1093 |
1079 void LCodeGen::DoModI(LModI* instr) { | 1094 void LCodeGen::DoModI(LModI* instr) { |
1080 HMod* hmod = instr->hydrogen(); | 1095 HMod* hmod = instr->hydrogen(); |
1081 HValue* left = hmod->left(); | 1096 HValue* left = hmod->left(); |
1082 HValue* right = hmod->right(); | 1097 HValue* right = hmod->right(); |
1083 if (hmod->HasPowerOf2Divisor()) { | 1098 if (hmod->HasPowerOf2Divisor()) { |
1084 const Register left_reg = ToRegister(instr->left()); | 1099 const Register left_reg = ToRegister(instr->left()); |
1085 const Register result_reg = ToRegister(instr->result()); | 1100 const Register result_reg = ToRegister(instr->result()); |
(...skipping 4588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5674 // This is a pseudo-instruction that ensures that the environment here is | 5689 // This is a pseudo-instruction that ensures that the environment here is |
5675 // properly registered for deoptimization and records the assembler's PC | 5690 // properly registered for deoptimization and records the assembler's PC |
5676 // offset. | 5691 // offset. |
5677 LEnvironment* environment = instr->environment(); | 5692 LEnvironment* environment = instr->environment(); |
5678 | 5693 |
5679 // If the environment were already registered, we would have no way of | 5694 // If the environment were already registered, we would have no way of |
5680 // backpatching it with the spill slot operands. | 5695 // backpatching it with the spill slot operands. |
5681 ASSERT(!environment->HasBeenRegistered()); | 5696 ASSERT(!environment->HasBeenRegistered()); |
5682 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 5697 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
5683 | 5698 |
5684 // Normally we record the first unknown OSR value as the entrypoint to the OSR | 5699 GenerateOsrPrologue(); |
5685 // code, but if there were none, record the entrypoint here. | |
5686 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
5687 } | 5700 } |
5688 | 5701 |
5689 | 5702 |
5690 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { | 5703 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { |
5691 Register result = ToRegister(instr->result()); | 5704 Register result = ToRegister(instr->result()); |
5692 Register object = ToRegister(instr->object()); | 5705 Register object = ToRegister(instr->object()); |
5693 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 5706 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
5694 DeoptimizeIf(eq, instr->environment(), object, Operand(at)); | 5707 DeoptimizeIf(eq, instr->environment(), object, Operand(at)); |
5695 | 5708 |
5696 Register null_value = t1; | 5709 Register null_value = t1; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5775 __ Subu(scratch, result, scratch); | 5788 __ Subu(scratch, result, scratch); |
5776 __ lw(result, FieldMemOperand(scratch, | 5789 __ lw(result, FieldMemOperand(scratch, |
5777 FixedArray::kHeaderSize - kPointerSize)); | 5790 FixedArray::kHeaderSize - kPointerSize)); |
5778 __ bind(&done); | 5791 __ bind(&done); |
5779 } | 5792 } |
5780 | 5793 |
5781 | 5794 |
5782 #undef __ | 5795 #undef __ |
5783 | 5796 |
5784 } } // namespace v8::internal | 5797 } } // namespace v8::internal |
OLD | NEW |