| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 // object to the callee and optionally the space to pass the argument | 1460 // object to the callee and optionally the space to pass the argument |
| 1459 // object to the stub failure handler. | 1461 // object to the stub failure handler. |
| 1460 ASSERT(descriptor->register_param_count_ >= 0); | 1462 ASSERT(descriptor->register_param_count_ >= 0); |
| 1461 int height_in_bytes = kPointerSize * descriptor->register_param_count_ + | 1463 int height_in_bytes = kPointerSize * descriptor->register_param_count_ + |
| 1462 sizeof(Arguments) + kPointerSize; | 1464 sizeof(Arguments) + kPointerSize; |
| 1463 int fixed_frame_size = StandardFrameConstants::kFixedFrameSize; | 1465 int fixed_frame_size = StandardFrameConstants::kFixedFrameSize; |
| 1464 int input_frame_size = input_->GetFrameSize(); | 1466 int input_frame_size = input_->GetFrameSize(); |
| 1465 int output_frame_size = height_in_bytes + fixed_frame_size; | 1467 int output_frame_size = height_in_bytes + fixed_frame_size; |
| 1466 if (trace_scope_ != NULL) { | 1468 if (trace_scope_ != NULL) { |
| 1467 PrintF(trace_scope_->file(), | 1469 PrintF(trace_scope_->file(), |
| 1468 " translating %s => StubFailureTrampolineStub, height=%d\n", | 1470 " translating %s => StubFailure%sTrampolineStub, height=%d\n", |
| 1469 CodeStub::MajorName(static_cast<CodeStub::Major>(major_key), false), | 1471 CodeStub::MajorName(static_cast<CodeStub::Major>(major_key), false), |
| 1472 descriptor->HasTailCallContinuation() ? "TailCall" : "", |
| 1470 height_in_bytes); | 1473 height_in_bytes); |
| 1471 } | 1474 } |
| 1472 | 1475 |
| 1473 // The stub failure trampoline is a single frame. | 1476 // The stub failure trampoline is a single frame. |
| 1474 FrameDescription* output_frame = | 1477 FrameDescription* output_frame = |
| 1475 new(output_frame_size) FrameDescription(output_frame_size, NULL); | 1478 new(output_frame_size) FrameDescription(output_frame_size, NULL); |
| 1476 output_frame->SetFrameType(StackFrame::STUB_FAILURE_TRAMPOLINE); | 1479 output_frame->SetFrameType(StackFrame::STUB_FAILURE_TRAMPOLINE); |
| 1477 ASSERT(frame_index == 0); | 1480 ASSERT(frame_index == 0); |
| 1478 output_[frame_index] = output_frame; | 1481 output_[frame_index] = output_frame; |
| 1479 | 1482 |
| 1480 // 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 |
| 1481 // 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 |
| 1482 // context and function slots. | 1485 // context and function slots. |
| 1483 Register fp_reg = StubFailureTrampolineFrame::fp_register(); | 1486 Register fp_reg = StubFailureTrampolineFrame::fp_register(); |
| 1484 intptr_t top_address = input_->GetRegister(fp_reg.code()) - | 1487 intptr_t top_address = input_->GetRegister(fp_reg.code()) - |
| 1485 (2 * kPointerSize) - height_in_bytes; | 1488 StandardFrameConstants::kFixedFrameSizeFromFp - height_in_bytes; |
| 1486 output_frame->SetTop(top_address); | 1489 output_frame->SetTop(top_address); |
| 1487 | 1490 |
| 1488 // Read caller's PC (JSFunction continuation) from the input frame. | 1491 // Read caller's PC (JSFunction continuation) from the input frame. |
| 1489 unsigned input_frame_offset = input_frame_size - kPCOnStackSize; | 1492 unsigned input_frame_offset = input_frame_size - kPCOnStackSize; |
| 1490 unsigned output_frame_offset = output_frame_size - kFPOnStackSize; | 1493 unsigned output_frame_offset = output_frame_size - kFPOnStackSize; |
| 1491 intptr_t value = input_->GetFrameSlot(input_frame_offset); | 1494 intptr_t value = input_->GetFrameSlot(input_frame_offset); |
| 1492 output_frame->SetCallerPc(output_frame_offset, value); | 1495 output_frame->SetCallerPc(output_frame_offset, value); |
| 1493 if (trace_scope_ != NULL) { | 1496 if (trace_scope_ != NULL) { |
| 1494 PrintF(trace_scope_->file(), | 1497 PrintF(trace_scope_->file(), |
| 1495 " 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | 1498 " 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 value = reinterpret_cast<intptr_t>( | 1534 value = reinterpret_cast<intptr_t>( |
| 1532 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); | 1535 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); |
| 1533 output_frame->SetFrameSlot(output_frame_offset, value); | 1536 output_frame->SetFrameSlot(output_frame_offset, value); |
| 1534 if (trace_scope_ != NULL) { | 1537 if (trace_scope_ != NULL) { |
| 1535 PrintF(trace_scope_->file(), | 1538 PrintF(trace_scope_->file(), |
| 1536 " 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | 1539 " 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" |
| 1537 V8PRIxPTR " ; function (stub failure sentinel)\n", | 1540 V8PRIxPTR " ; function (stub failure sentinel)\n", |
| 1538 top_address + output_frame_offset, output_frame_offset, value); | 1541 top_address + output_frame_offset, output_frame_offset, value); |
| 1539 } | 1542 } |
| 1540 | 1543 |
| 1541 intptr_t caller_arg_count = 0; | 1544 intptr_t caller_arg_count = descriptor->HasTailCallContinuation() |
| 1545 ? compiled_code_->arguments_count() + 1 : 0; |
| 1542 bool arg_count_known = !descriptor->stack_parameter_count_.is_valid(); | 1546 bool arg_count_known = !descriptor->stack_parameter_count_.is_valid(); |
| 1543 | 1547 |
| 1544 // Build the Arguments object for the caller's parameters and a pointer to it. | 1548 // Build the Arguments object for the caller's parameters and a pointer to it. |
| 1545 output_frame_offset -= kPointerSize; | 1549 output_frame_offset -= kPointerSize; |
| 1546 int args_arguments_offset = output_frame_offset; | 1550 int args_arguments_offset = output_frame_offset; |
| 1547 intptr_t the_hole = reinterpret_cast<intptr_t>( | 1551 intptr_t the_hole = reinterpret_cast<intptr_t>( |
| 1548 isolate_->heap()->the_hole_value()); | 1552 isolate_->heap()->the_hole_value()); |
| 1549 if (arg_count_known) { | 1553 if (arg_count_known) { |
| 1550 value = frame_ptr + StandardFrameConstants::kCallerSPOffset + | 1554 value = frame_ptr + StandardFrameConstants::kCallerSPOffset + |
| 1551 (caller_arg_count - 1) * kPointerSize; | 1555 (caller_arg_count - 1) * kPointerSize; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 } | 1631 } |
| 1628 | 1632 |
| 1629 // Copy the double registers from the input into the output frame. | 1633 // Copy the double registers from the input into the output frame. |
| 1630 CopyDoubleRegisters(output_frame); | 1634 CopyDoubleRegisters(output_frame); |
| 1631 | 1635 |
| 1632 // Fill registers containing handler and number of parameters. | 1636 // Fill registers containing handler and number of parameters. |
| 1633 SetPlatformCompiledStubRegisters(output_frame, descriptor); | 1637 SetPlatformCompiledStubRegisters(output_frame, descriptor); |
| 1634 | 1638 |
| 1635 // Compute this frame's PC, state, and continuation. | 1639 // Compute this frame's PC, state, and continuation. |
| 1636 Code* trampoline = NULL; | 1640 Code* trampoline = NULL; |
| 1637 StubFunctionMode function_mode = descriptor->function_mode_; | 1641 if (descriptor->HasTailCallContinuation()) { |
| 1638 StubFailureTrampolineStub(function_mode).FindCodeInCache(&trampoline, | 1642 StubFailureTailCallTrampolineStub().FindCodeInCache(&trampoline, isolate_); |
| 1639 isolate_); | 1643 } else { |
| 1644 StubFunctionMode function_mode = descriptor->function_mode_; |
| 1645 StubFailureTrampolineStub(function_mode).FindCodeInCache(&trampoline, |
| 1646 isolate_); |
| 1647 } |
| 1640 ASSERT(trampoline != NULL); | 1648 ASSERT(trampoline != NULL); |
| 1641 output_frame->SetPc(reinterpret_cast<intptr_t>( | 1649 output_frame->SetPc(reinterpret_cast<intptr_t>( |
| 1642 trampoline->instruction_start())); | 1650 trampoline->instruction_start())); |
| 1643 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); | 1651 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); |
| 1644 Code* notify_failure = | 1652 Code* notify_failure = NotifyStubFailureBuiltin(); |
| 1645 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); | |
| 1646 output_frame->SetContinuation( | 1653 output_frame->SetContinuation( |
| 1647 reinterpret_cast<intptr_t>(notify_failure->entry())); | 1654 reinterpret_cast<intptr_t>(notify_failure->entry())); |
| 1648 } | 1655 } |
| 1649 | 1656 |
| 1650 | 1657 |
| 1651 Handle<Object> Deoptimizer::MaterializeNextHeapObject() { | 1658 Handle<Object> Deoptimizer::MaterializeNextHeapObject() { |
| 1652 int object_index = materialization_object_index_++; | 1659 int object_index = materialization_object_index_++; |
| 1653 ObjectMaterializationDescriptor desc = deferred_objects_[object_index]; | 1660 ObjectMaterializationDescriptor desc = deferred_objects_[object_index]; |
| 1654 const int length = desc.object_length(); | 1661 const int length = desc.object_length(); |
| 1655 | 1662 |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2441 } | 2448 } |
| 2442 return; | 2449 return; |
| 2443 } | 2450 } |
| 2444 } | 2451 } |
| 2445 } | 2452 } |
| 2446 | 2453 |
| 2447 | 2454 |
| 2448 unsigned Deoptimizer::ComputeInputFrameSize() const { | 2455 unsigned Deoptimizer::ComputeInputFrameSize() const { |
| 2449 unsigned fixed_size = ComputeFixedSize(function_); | 2456 unsigned fixed_size = ComputeFixedSize(function_); |
| 2450 // The fp-to-sp delta already takes the context and the function | 2457 // The fp-to-sp delta already takes the context and the function |
| 2451 // into account so we have to avoid double counting them (-2). | 2458 // into account so we have to avoid double counting them. |
| 2452 unsigned result = fixed_size + fp_to_sp_delta_ - (2 * kPointerSize); | 2459 unsigned result = fixed_size + fp_to_sp_delta_ - |
| 2460 StandardFrameConstants::kFixedFrameSizeFromFp; |
| 2453 #ifdef DEBUG | 2461 #ifdef DEBUG |
| 2454 if (compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) { | 2462 if (compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) { |
| 2455 unsigned stack_slots = compiled_code_->stack_slots(); | 2463 unsigned stack_slots = compiled_code_->stack_slots(); |
| 2456 unsigned outgoing_size = ComputeOutgoingArgumentSize(); | 2464 unsigned outgoing_size = ComputeOutgoingArgumentSize(); |
| 2457 ASSERT(result == fixed_size + (stack_slots * kPointerSize) + outgoing_size); | 2465 ASSERT(result == fixed_size + (stack_slots * kPointerSize) + outgoing_size); |
| 2458 } | 2466 } |
| 2459 #endif | 2467 #endif |
| 2460 return result; | 2468 return result; |
| 2461 } | 2469 } |
| 2462 | 2470 |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3046 | 3054 |
| 3047 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 3055 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
| 3048 v->VisitPointer(BitCast<Object**>(&function_)); | 3056 v->VisitPointer(BitCast<Object**>(&function_)); |
| 3049 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 3057 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
| 3050 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 3058 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
| 3051 } | 3059 } |
| 3052 | 3060 |
| 3053 #endif // ENABLE_DEBUGGER_SUPPORT | 3061 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3054 | 3062 |
| 3055 } } // namespace v8::internal | 3063 } } // namespace v8::internal |
| OLD | NEW |