OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/deoptimizer.h" | 5 #include "src/deoptimizer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 output_frame->SetCallerConstantPool(output_offset, value); | 935 output_frame->SetCallerConstantPool(output_offset, value); |
936 DebugPrintOutputSlot(value, frame_index, output_offset, | 936 DebugPrintOutputSlot(value, frame_index, output_offset, |
937 "caller's constant_pool\n"); | 937 "caller's constant_pool\n"); |
938 } | 938 } |
939 | 939 |
940 // For the bottommost output frame the context can be gotten from the input | 940 // For the bottommost output frame the context can be gotten from the input |
941 // frame. For all subsequent output frames it can be gotten from the function | 941 // frame. For all subsequent output frames it can be gotten from the function |
942 // so long as we don't inline functions that need local contexts. | 942 // so long as we don't inline functions that need local contexts. |
943 output_offset -= kPointerSize; | 943 output_offset -= kPointerSize; |
944 | 944 |
945 TranslatedFrame::iterator context_pos = value_iterator; | |
946 int context_input_index = input_index; | |
947 // When deoptimizing into a catch block, we need to take the context | 945 // When deoptimizing into a catch block, we need to take the context |
948 // from just above the top of the operand stack (we push the context | 946 // from just above the top of the operand stack (we push the context |
949 // at the entry of the try block). | 947 // at the entry of the try block). |
| 948 TranslatedFrame::iterator context_pos = value_iterator; |
| 949 int context_input_index = input_index; |
950 if (goto_catch_handler) { | 950 if (goto_catch_handler) { |
951 for (unsigned i = 0; i < height + 1; ++i) { | 951 for (unsigned i = 0; i < height + 1; ++i) { |
952 context_pos++; | 952 context_pos++; |
953 context_input_index++; | 953 context_input_index++; |
954 } | 954 } |
955 } | 955 } |
956 // Read the context from the translations. | 956 // Read the context from the translations. |
957 Object* context = context_pos->GetRawValue(); | 957 Object* context = context_pos->GetRawValue(); |
958 if (context->IsUndefined(isolate_)) { | 958 if (context->IsUndefined(isolate_)) { |
959 // If the context was optimized away, just use the context from | 959 // If the context was optimized away, just use the context from |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 value = output_[frame_index - 1]->GetConstantPool(); | 1166 value = output_[frame_index - 1]->GetConstantPool(); |
1167 } | 1167 } |
1168 output_frame->SetCallerConstantPool(output_offset, value); | 1168 output_frame->SetCallerConstantPool(output_offset, value); |
1169 DebugPrintOutputSlot(value, frame_index, output_offset, | 1169 DebugPrintOutputSlot(value, frame_index, output_offset, |
1170 "caller's constant_pool\n"); | 1170 "caller's constant_pool\n"); |
1171 } | 1171 } |
1172 | 1172 |
1173 // For the bottommost output frame the context can be gotten from the input | 1173 // For the bottommost output frame the context can be gotten from the input |
1174 // frame. For all subsequent output frames it can be gotten from the function | 1174 // frame. For all subsequent output frames it can be gotten from the function |
1175 // so long as we don't inline functions that need local contexts. | 1175 // so long as we don't inline functions that need local contexts. |
1176 Register context_reg = InterpretedFrame::context_register(); | |
1177 output_offset -= kPointerSize; | 1176 output_offset -= kPointerSize; |
1178 | 1177 |
1179 // When deoptimizing into a catch block, we need to take the context | 1178 // When deoptimizing into a catch block, we need to take the context |
1180 // from a register that was specified in the handler table. | 1179 // from a register that was specified in the handler table. |
1181 TranslatedFrame::iterator context_pos = value_iterator; | 1180 TranslatedFrame::iterator context_pos = value_iterator; |
1182 int context_input_index = input_index; | 1181 int context_input_index = input_index; |
1183 if (goto_catch_handler) { | 1182 if (goto_catch_handler) { |
1184 // Skip to the translated value of the register specified | 1183 // Skip to the translated value of the register specified |
1185 // in the handler table. | 1184 // in the handler table. |
1186 for (int i = 0; i < catch_handler_data_ + 1; ++i) { | 1185 for (int i = 0; i < catch_handler_data_ + 1; ++i) { |
1187 context_pos++; | 1186 context_pos++; |
1188 context_input_index++; | 1187 context_input_index++; |
1189 } | 1188 } |
1190 } | 1189 } |
1191 // Read the context from the translations. | 1190 // Read the context from the translations. |
1192 Object* context = context_pos->GetRawValue(); | 1191 Object* context = context_pos->GetRawValue(); |
1193 // The context should not be a placeholder for a materialized object. | |
1194 CHECK(context != isolate_->heap()->arguments_marker()); | |
1195 value = reinterpret_cast<intptr_t>(context); | 1192 value = reinterpret_cast<intptr_t>(context); |
1196 output_frame->SetContext(value); | 1193 output_frame->SetContext(value); |
1197 if (is_topmost) output_frame->SetRegister(context_reg.code(), value); | 1194 if (is_topmost) { |
| 1195 Register context_reg = InterpretedFrame::context_register(); |
| 1196 output_frame->SetRegister(context_reg.code(), value); |
| 1197 } |
1198 WriteValueToOutput(context, context_input_index, frame_index, output_offset, | 1198 WriteValueToOutput(context, context_input_index, frame_index, output_offset, |
1199 "context "); | 1199 "context "); |
| 1200 if (context == isolate_->heap()->arguments_marker()) { |
| 1201 Address output_address = |
| 1202 reinterpret_cast<Address>(output_[frame_index]->GetTop()) + |
| 1203 output_offset; |
| 1204 values_to_materialize_.push_back({output_address, context_pos}); |
| 1205 } |
1200 value_iterator++; | 1206 value_iterator++; |
1201 input_index++; | 1207 input_index++; |
1202 | 1208 |
1203 // The function was mentioned explicitly in the BEGIN_FRAME. | 1209 // The function was mentioned explicitly in the BEGIN_FRAME. |
1204 output_offset -= kPointerSize; | 1210 output_offset -= kPointerSize; |
1205 value = reinterpret_cast<intptr_t>(function); | 1211 value = reinterpret_cast<intptr_t>(function); |
1206 WriteValueToOutput(function, 0, frame_index, output_offset, "function "); | 1212 WriteValueToOutput(function, 0, frame_index, output_offset, "function "); |
1207 | 1213 |
1208 // The new.target slot is only used during function activiation which is | 1214 // The new.target slot is only used during function activiation which is |
1209 // before the first deopt point, so should never be needed. Just set it to | 1215 // before the first deopt point, so should never be needed. Just set it to |
(...skipping 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3998 CHECK(value_info->IsMaterializedObject()); | 4004 CHECK(value_info->IsMaterializedObject()); |
3999 | 4005 |
4000 value_info->value_ = | 4006 value_info->value_ = |
4001 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 4007 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
4002 } | 4008 } |
4003 } | 4009 } |
4004 } | 4010 } |
4005 | 4011 |
4006 } // namespace internal | 4012 } // namespace internal |
4007 } // namespace v8 | 4013 } // namespace v8 |
OLD | NEW |