| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 // Locate the deoptimization point in the code. As we are at a call the | 175 // Locate the deoptimization point in the code. As we are at a call the |
| 176 // return address must be at a place in the code with deoptimization support. | 176 // return address must be at a place in the code with deoptimization support. |
| 177 SafepointEntry safepoint_entry = code->GetSafepointEntry(frame->pc()); | 177 SafepointEntry safepoint_entry = code->GetSafepointEntry(frame->pc()); |
| 178 int deoptimization_index = safepoint_entry.deoptimization_index(); | 178 int deoptimization_index = safepoint_entry.deoptimization_index(); |
| 179 ASSERT(deoptimization_index != Safepoint::kNoDeoptimizationIndex); | 179 ASSERT(deoptimization_index != Safepoint::kNoDeoptimizationIndex); |
| 180 | 180 |
| 181 // Always use the actual stack slots when calculating the fp to sp | 181 // Always use the actual stack slots when calculating the fp to sp |
| 182 // delta adding two for the function and context. | 182 // delta adding two for the function and context. |
| 183 unsigned stack_slots = code->stack_slots(); | 183 unsigned stack_slots = code->stack_slots(); |
| 184 unsigned fp_to_sp_delta = ((stack_slots + 2) * kPointerSize); | 184 unsigned fp_to_sp_delta = (stack_slots * kPointerSize) + |
| 185 StandardFrameConstants::kFixedFrameSizeFromFp; |
| 185 | 186 |
| 186 Deoptimizer* deoptimizer = new Deoptimizer(isolate, | 187 Deoptimizer* deoptimizer = new Deoptimizer(isolate, |
| 187 function, | 188 function, |
| 188 Deoptimizer::DEBUGGER, | 189 Deoptimizer::DEBUGGER, |
| 189 deoptimization_index, | 190 deoptimization_index, |
| 190 frame->pc(), | 191 frame->pc(), |
| 191 fp_to_sp_delta, | 192 fp_to_sp_delta, |
| 192 code); | 193 code); |
| 193 Address tos = frame->fp() - fp_to_sp_delta; | 194 Address tos = frame->fp() - fp_to_sp_delta; |
| 194 deoptimizer->FillInputFrame(tos, frame); | 195 deoptimizer->FillInputFrame(tos, frame); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 // top address and the current frame's size. | 884 // top address and the current frame's size. |
| 884 Register fp_reg = JavaScriptFrame::fp_register(); | 885 Register fp_reg = JavaScriptFrame::fp_register(); |
| 885 intptr_t top_address; | 886 intptr_t top_address; |
| 886 if (is_bottommost) { | 887 if (is_bottommost) { |
| 887 // Determine whether the input frame contains alignment padding. | 888 // Determine whether the input frame contains alignment padding. |
| 888 has_alignment_padding_ = HasAlignmentPadding(function) ? 1 : 0; | 889 has_alignment_padding_ = HasAlignmentPadding(function) ? 1 : 0; |
| 889 // 2 = context and function in the frame. | 890 // 2 = context and function in the frame. |
| 890 // If the optimized frame had alignment padding, adjust the frame pointer | 891 // If the optimized frame had alignment padding, adjust the frame pointer |
| 891 // to point to the new position of the old frame pointer after padding | 892 // to point to the new position of the old frame pointer after padding |
| 892 // is removed. Subtract 2 * kPointerSize for the context and function slots. | 893 // is removed. Subtract 2 * kPointerSize for the context and function slots. |
| 893 top_address = input_->GetRegister(fp_reg.code()) - (2 * kPointerSize) - | 894 top_address = input_->GetRegister(fp_reg.code()) - |
| 895 StandardFrameConstants::kFixedFrameSizeFromFp - |
| 894 height_in_bytes + has_alignment_padding_ * kPointerSize; | 896 height_in_bytes + has_alignment_padding_ * kPointerSize; |
| 895 } else { | 897 } else { |
| 896 top_address = output_[frame_index - 1]->GetTop() - output_frame_size; | 898 top_address = output_[frame_index - 1]->GetTop() - output_frame_size; |
| 897 } | 899 } |
| 898 output_frame->SetTop(top_address); | 900 output_frame->SetTop(top_address); |
| 899 | 901 |
| 900 // Compute the incoming parameter translation. | 902 // Compute the incoming parameter translation. |
| 901 int parameter_count = function->shared()->formal_parameter_count() + 1; | 903 int parameter_count = function->shared()->formal_parameter_count() + 1; |
| 902 unsigned output_offset = output_frame_size; | 904 unsigned output_offset = output_frame_size; |
| 903 unsigned input_offset = input_frame_size; | 905 unsigned input_offset = input_frame_size; |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 // registers by the LoadIC/StoreIC, so they don't belong to the output stack | 1298 // registers by the LoadIC/StoreIC, so they don't belong to the output stack |
| 1297 // frame. This means that we have to use a height of 0. | 1299 // frame. This means that we have to use a height of 0. |
| 1298 unsigned height = 0; | 1300 unsigned height = 0; |
| 1299 unsigned height_in_bytes = height * kPointerSize; | 1301 unsigned height_in_bytes = height * kPointerSize; |
| 1300 const char* kind = is_setter_stub_frame ? "setter" : "getter"; | 1302 const char* kind = is_setter_stub_frame ? "setter" : "getter"; |
| 1301 if (trace_scope_ != NULL) { | 1303 if (trace_scope_ != NULL) { |
| 1302 PrintF(trace_scope_->file(), | 1304 PrintF(trace_scope_->file(), |
| 1303 " translating %s stub => height=%u\n", kind, height_in_bytes); | 1305 " translating %s stub => height=%u\n", kind, height_in_bytes); |
| 1304 } | 1306 } |
| 1305 | 1307 |
| 1306 // We need 1 stack entry for the return address + 4 stack entries from | 1308 // We need 1 stack entry for the return address and enough entries for the |
| 1307 // StackFrame::INTERNAL (FP, context, frame type, code object, see | 1309 // StackFrame::INTERNAL (FP, context, frame type and code object - see |
| 1308 // MacroAssembler::EnterFrame). For a setter stub frame we need one additional | 1310 // MacroAssembler::EnterFrame). For a setter stub frame we need one additional |
| 1309 // entry for the implicit return value, see | 1311 // entry for the implicit return value, see |
| 1310 // StoreStubCompiler::CompileStoreViaSetter. | 1312 // StoreStubCompiler::CompileStoreViaSetter. |
| 1311 unsigned fixed_frame_entries = (kPCOnStackSize / kPointerSize) + | 1313 unsigned fixed_frame_entries = |
| 1312 (kFPOnStackSize / kPointerSize) + 3 + | 1314 (StandardFrameConstants::kFixedFrameSize / kPointerSize) + 1 + |
| 1313 (is_setter_stub_frame ? 1 : 0); | 1315 (is_setter_stub_frame ? 1 : 0); |
| 1314 unsigned fixed_frame_size = fixed_frame_entries * kPointerSize; | 1316 unsigned fixed_frame_size = fixed_frame_entries * kPointerSize; |
| 1315 unsigned output_frame_size = height_in_bytes + fixed_frame_size; | 1317 unsigned output_frame_size = height_in_bytes + fixed_frame_size; |
| 1316 | 1318 |
| 1317 // Allocate and store the output frame description. | 1319 // Allocate and store the output frame description. |
| 1318 FrameDescription* output_frame = | 1320 FrameDescription* output_frame = |
| 1319 new(output_frame_size) FrameDescription(output_frame_size, accessor); | 1321 new(output_frame_size) FrameDescription(output_frame_size, accessor); |
| 1320 output_frame->SetFrameType(StackFrame::INTERNAL); | 1322 output_frame->SetFrameType(StackFrame::INTERNAL); |
| 1321 | 1323 |
| 1322 // A frame for an accessor stub can not be the topmost or bottommost one. | 1324 // A frame for an accessor stub can not be the topmost or bottommost one. |
| 1323 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); | 1325 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 new(output_frame_size) FrameDescription(output_frame_size, NULL); | 1478 new(output_frame_size) FrameDescription(output_frame_size, NULL); |
| 1477 output_frame->SetFrameType(StackFrame::STUB_FAILURE_TRAMPOLINE); | 1479 output_frame->SetFrameType(StackFrame::STUB_FAILURE_TRAMPOLINE); |
| 1478 ASSERT(frame_index == 0); | 1480 ASSERT(frame_index == 0); |
| 1479 output_[frame_index] = output_frame; | 1481 output_[frame_index] = output_frame; |
| 1480 | 1482 |
| 1481 // The top address for the output frame can be computed from the input | 1483 // The top address for the output frame can be computed from the input |
| 1482 // frame pointer and the output frame's height. Subtract space for the | 1484 // frame pointer and the output frame's height. Subtract space for the |
| 1483 // context and function slots. | 1485 // context and function slots. |
| 1484 Register fp_reg = StubFailureTrampolineFrame::fp_register(); | 1486 Register fp_reg = StubFailureTrampolineFrame::fp_register(); |
| 1485 intptr_t top_address = input_->GetRegister(fp_reg.code()) - | 1487 intptr_t top_address = input_->GetRegister(fp_reg.code()) - |
| 1486 (2 * kPointerSize) - height_in_bytes; | 1488 StandardFrameConstants::kFixedFrameSizeFromFp - height_in_bytes; |
| 1487 output_frame->SetTop(top_address); | 1489 output_frame->SetTop(top_address); |
| 1488 | 1490 |
| 1489 // Read caller's PC (JSFunction continuation) from the input frame. | 1491 // Read caller's PC (JSFunction continuation) from the input frame. |
| 1490 unsigned input_frame_offset = input_frame_size - kPCOnStackSize; | 1492 unsigned input_frame_offset = input_frame_size - kPCOnStackSize; |
| 1491 unsigned output_frame_offset = output_frame_size - kFPOnStackSize; | 1493 unsigned output_frame_offset = output_frame_size - kFPOnStackSize; |
| 1492 intptr_t value = input_->GetFrameSlot(input_frame_offset); | 1494 intptr_t value = input_->GetFrameSlot(input_frame_offset); |
| 1493 output_frame->SetCallerPc(output_frame_offset, value); | 1495 output_frame->SetCallerPc(output_frame_offset, value); |
| 1494 if (trace_scope_ != NULL) { | 1496 if (trace_scope_ != NULL) { |
| 1495 PrintF(trace_scope_->file(), | 1497 PrintF(trace_scope_->file(), |
| 1496 " 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | 1498 " 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2447 } | 2449 } |
| 2448 return; | 2450 return; |
| 2449 } | 2451 } |
| 2450 } | 2452 } |
| 2451 } | 2453 } |
| 2452 | 2454 |
| 2453 | 2455 |
| 2454 unsigned Deoptimizer::ComputeInputFrameSize() const { | 2456 unsigned Deoptimizer::ComputeInputFrameSize() const { |
| 2455 unsigned fixed_size = ComputeFixedSize(function_); | 2457 unsigned fixed_size = ComputeFixedSize(function_); |
| 2456 // The fp-to-sp delta already takes the context and the function | 2458 // The fp-to-sp delta already takes the context and the function |
| 2457 // into account so we have to avoid double counting them (-2). | 2459 // into account so we have to avoid double counting them. |
| 2458 unsigned result = fixed_size + fp_to_sp_delta_ - (2 * kPointerSize); | 2460 unsigned result = fixed_size + fp_to_sp_delta_ - |
| 2461 StandardFrameConstants::kFixedFrameSizeFromFp; |
| 2459 #ifdef DEBUG | 2462 #ifdef DEBUG |
| 2460 if (compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) { | 2463 if (compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) { |
| 2461 unsigned stack_slots = compiled_code_->stack_slots(); | 2464 unsigned stack_slots = compiled_code_->stack_slots(); |
| 2462 unsigned outgoing_size = ComputeOutgoingArgumentSize(); | 2465 unsigned outgoing_size = ComputeOutgoingArgumentSize(); |
| 2463 ASSERT(result == fixed_size + (stack_slots * kPointerSize) + outgoing_size); | 2466 ASSERT(result == fixed_size + (stack_slots * kPointerSize) + outgoing_size); |
| 2464 } | 2467 } |
| 2465 #endif | 2468 #endif |
| 2466 return result; | 2469 return result; |
| 2467 } | 2470 } |
| 2468 | 2471 |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3052 | 3055 |
| 3053 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 3056 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
| 3054 v->VisitPointer(BitCast<Object**>(&function_)); | 3057 v->VisitPointer(BitCast<Object**>(&function_)); |
| 3055 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 3058 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
| 3056 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 3059 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
| 3057 } | 3060 } |
| 3058 | 3061 |
| 3059 #endif // ENABLE_DEBUGGER_SUPPORT | 3062 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3060 | 3063 |
| 3061 } } // namespace v8::internal | 3064 } } // namespace v8::internal |
| OLD | NEW |