Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: src/deoptimizer.cc

Issue 12379045: Unify deoptimizer for stub failure trampoline frames. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 1167
1168 Smi* offset = is_setter_stub_frame ? 1168 Smi* offset = is_setter_stub_frame ?
1169 isolate_->heap()->setter_stub_deopt_pc_offset() : 1169 isolate_->heap()->setter_stub_deopt_pc_offset() :
1170 isolate_->heap()->getter_stub_deopt_pc_offset(); 1170 isolate_->heap()->getter_stub_deopt_pc_offset();
1171 intptr_t pc = reinterpret_cast<intptr_t>( 1171 intptr_t pc = reinterpret_cast<intptr_t>(
1172 accessor_stub->instruction_start() + offset->value()); 1172 accessor_stub->instruction_start() + offset->value());
1173 output_frame->SetPc(pc); 1173 output_frame->SetPc(pc);
1174 } 1174 }
1175 1175
1176 1176
1177 void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
1178 int frame_index) {
1179 //
1180 // FROM TO
1181 // | .... | | .... |
1182 // +-------------------------+ +-------------------------+
1183 // | JSFunction continuation | | JSFunction continuation |
1184 // +-------------------------+ +-------------------------+
1185 // | | saved frame (FP) | | saved frame (FP) |
1186 // | +=========================+<-fpreg +=========================+<-fpreg
1187 // | | JSFunction context | | JSFunction context |
1188 // v +-------------------------+ +-------------------------|
1189 // | COMPILED_STUB marker | | STUB_FAILURE marker |
1190 // +-------------------------+ +-------------------------+
1191 // | | | caller args.arguments_ |
1192 // | ... | +-------------------------+
1193 // | | | caller args.length_ |
1194 // |-------------------------|<-spreg +-------------------------+
1195 // | caller args pointer |
1196 // +-------------------------+
1197 // | caller stack param 1 |
1198 // parameters in registers +-------------------------+
1199 // and spilled to stack | .... |
1200 // +-------------------------+
1201 // | caller stack param n |
1202 // +-------------------------+<-spreg
1203 // reg = number of parameters
1204 // reg = failure handler address
1205 // reg = saved frame
1206 // reg = JSFunction context
1207 //
1208
1209 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
1210 int major_key = compiled_code_->major_key();
1211 CodeStubInterfaceDescriptor* descriptor =
1212 isolate_->code_stub_interface_descriptor(major_key);
1213
1214 // The output frame must have room for all pushed register parameters
1215 // and the standard stack frame slots. Include space for an argument
1216 // object to the callee and optionally the space to pass the argument
1217 // object to the stub failure handler.
1218 int height_in_bytes = kPointerSize * descriptor->register_param_count_ +
1219 sizeof(Arguments) + kPointerSize;
1220 int fixed_frame_size = StandardFrameConstants::kFixedFrameSize;
1221 int input_frame_size = input_->GetFrameSize();
1222 int output_frame_size = height_in_bytes + fixed_frame_size;
1223 if (trace_) {
1224 PrintF(" translating %s => StubFailureTrampolineStub, height=%d\n",
1225 CodeStub::MajorName(static_cast<CodeStub::Major>(major_key), false),
1226 height_in_bytes);
1227 }
1228
1229 // The stub failure trampoline is a single frame.
1230 FrameDescription* output_frame =
1231 new(output_frame_size) FrameDescription(output_frame_size, NULL);
1232 output_frame->SetFrameType(StackFrame::STUB_FAILURE_TRAMPOLINE);
1233 ASSERT(frame_index == 0);
1234 output_[frame_index] = output_frame;
1235
1236 // The top address for the output frame can be computed from the input
1237 // frame pointer and the output frame's height. Subtract space for the
1238 // context and function slots.
1239 Register fp_reg = StubFailureTrampolineFrame::fp_register();
1240 intptr_t top_address = input_->GetRegister(fp_reg.code()) -
1241 (2 * kPointerSize) - height_in_bytes;
1242 output_frame->SetTop(top_address);
1243
1244 // Read caller's PC (JSFunction continuation) from the input frame.
1245 unsigned input_frame_offset = input_frame_size - kPointerSize;
1246 unsigned output_frame_offset = output_frame_size - kPointerSize;
1247 intptr_t value = input_->GetFrameSlot(input_frame_offset);
1248 output_frame->SetFrameSlot(output_frame_offset, value);
1249 if (trace_) {
1250 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1251 V8PRIxPTR " ; caller's pc\n",
1252 top_address + output_frame_offset, output_frame_offset, value);
1253 }
1254
1255 // Read caller's FP from the input frame, and set this frame's FP.
1256 input_frame_offset -= kPointerSize;
1257 value = input_->GetFrameSlot(input_frame_offset);
1258 output_frame_offset -= kPointerSize;
1259 output_frame->SetFrameSlot(output_frame_offset, value);
1260 intptr_t frame_ptr = input_->GetRegister(fp_reg.code());
1261 output_frame->SetRegister(fp_reg.code(), frame_ptr);
1262 output_frame->SetFp(frame_ptr);
1263 if (trace_) {
1264 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1265 V8PRIxPTR " ; caller's fp\n",
1266 top_address + output_frame_offset, output_frame_offset, value);
1267 }
1268
1269 // The context can be gotten from the input frame.
1270 Register context_reg = StubFailureTrampolineFrame::context_register();
1271 input_frame_offset -= kPointerSize;
1272 value = input_->GetFrameSlot(input_frame_offset);
1273 output_frame->SetRegister(context_reg.code(), value);
1274 output_frame_offset -= kPointerSize;
1275 output_frame->SetFrameSlot(output_frame_offset, value);
1276 if (trace_) {
1277 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1278 V8PRIxPTR " ; context\n",
1279 top_address + output_frame_offset, output_frame_offset, value);
1280 }
1281
1282 // A marker value is used in place of the function.
1283 output_frame_offset -= kPointerSize;
1284 value = reinterpret_cast<intptr_t>(
1285 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE));
1286 output_frame->SetFrameSlot(output_frame_offset, value);
1287 if (trace_) {
1288 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1289 V8PRIxPTR " ; function (stub failure sentinel)\n",
1290 top_address + output_frame_offset, output_frame_offset, value);
1291 }
1292
1293 intptr_t caller_arg_count = 0;
1294 if (descriptor->stack_parameter_count_ != NULL) {
1295 caller_arg_count =
1296 input_->GetRegister(descriptor->stack_parameter_count_->code());
1297 }
1298
1299 // Build the Arguments object for the caller's parameters and a pointer to it.
1300 output_frame_offset -= kPointerSize;
1301 value = frame_ptr + StandardFrameConstants::kCallerSPOffset +
1302 (caller_arg_count - 1) * kPointerSize;
1303 output_frame->SetFrameSlot(output_frame_offset, value);
1304 if (trace_) {
1305 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1306 V8PRIxPTR " ; args.arguments\n",
1307 top_address + output_frame_offset, output_frame_offset, value);
1308 }
1309
1310 output_frame_offset -= kPointerSize;
1311 value = caller_arg_count;
1312 output_frame->SetFrameSlot(output_frame_offset, value);
1313 if (trace_) {
1314 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1315 V8PRIxPTR " ; args.length\n",
1316 top_address + output_frame_offset, output_frame_offset, value);
1317 }
1318
1319 output_frame_offset -= kPointerSize;
1320 value = frame_ptr - (output_frame_size - output_frame_offset) -
1321 StandardFrameConstants::kMarkerOffset + kPointerSize;
1322 output_frame->SetFrameSlot(output_frame_offset, value);
1323 if (trace_) {
1324 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1325 V8PRIxPTR " ; args*\n",
1326 top_address + output_frame_offset, output_frame_offset, value);
1327 }
1328
1329 // Copy the register parameters to the failure frame.
1330 for (int i = 0; i < descriptor->register_param_count_; ++i) {
1331 output_frame_offset -= kPointerSize;
1332 DoTranslateCommand(iterator, 0, output_frame_offset);
1333 }
1334
1335 ASSERT(0 == output_frame_offset);
1336
1337 // Copy the double registers from the input into the output frame.
1338 CopyDoubleRegisters(output_frame);
1339
1340 // Fill registers containing handler and number of parameters.
1341 FillStubFailureTrampolineFrame(output_frame, descriptor);
1342
1343 // Compute this frame's PC, state, and continuation.
1344 Code* trampoline = NULL;
1345 int extra = descriptor->extra_expression_stack_count_;
1346 StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_);
1347 ASSERT(trampoline != NULL);
1348 output_frame->SetPc(reinterpret_cast<intptr_t>(
1349 trampoline->instruction_start()));
1350 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
1351 Code* notify_failure =
1352 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
1353 output_frame->SetContinuation(
1354 reinterpret_cast<intptr_t>(notify_failure->entry()));
1355 }
1356
1357
1177 void Deoptimizer::MaterializeHeapObjects(JavaScriptFrameIterator* it) { 1358 void Deoptimizer::MaterializeHeapObjects(JavaScriptFrameIterator* it) {
1178 ASSERT_NE(DEBUGGER, bailout_type_); 1359 ASSERT_NE(DEBUGGER, bailout_type_);
1179 1360
1180 // Handlify all argument object values before triggering any allocation. 1361 // Handlify all argument object values before triggering any allocation.
1181 List<Handle<Object> > values(deferred_arguments_objects_values_.length()); 1362 List<Handle<Object> > values(deferred_arguments_objects_values_.length());
1182 for (int i = 0; i < deferred_arguments_objects_values_.length(); ++i) { 1363 for (int i = 0; i < deferred_arguments_objects_values_.length(); ++i) {
1183 values.Add(Handle<Object>(deferred_arguments_objects_values_[i], 1364 values.Add(Handle<Object>(deferred_arguments_objects_values_[i],
1184 isolate_)); 1365 isolate_));
1185 } 1366 }
1186 1367
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2499 2680
2500 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { 2681 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) {
2501 v->VisitPointer(BitCast<Object**>(&function_)); 2682 v->VisitPointer(BitCast<Object**>(&function_));
2502 v->VisitPointers(parameters_, parameters_ + parameters_count_); 2683 v->VisitPointers(parameters_, parameters_ + parameters_count_);
2503 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); 2684 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_);
2504 } 2685 }
2505 2686
2506 #endif // ENABLE_DEBUGGER_SUPPORT 2687 #endif // ENABLE_DEBUGGER_SUPPORT
2507 2688
2508 } } // namespace v8::internal 2689 } } // namespace v8::internal
OLDNEW
« src/arm/frames-arm.cc ('K') | « src/deoptimizer.h ('k') | src/frames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698