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

Side by Side Diff: src/mips/deoptimizer-mips.cc

Issue 12756002: MIPS: 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
« no previous file with comments | « no previous file | src/mips/frames-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (FLAG_trace_osr) { 342 if (FLAG_trace_osr) {
343 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", 343 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ",
344 ok ? "finished" : "aborted", 344 ok ? "finished" : "aborted",
345 reinterpret_cast<intptr_t>(function_)); 345 reinterpret_cast<intptr_t>(function_));
346 function_->PrintName(); 346 function_->PrintName();
347 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc()); 347 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc());
348 } 348 }
349 } 349 }
350 350
351 351
352 void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
353 int frame_index) {
354 //
355 // FROM TO
356 // | .... | | .... |
357 // +-------------------------+ +-------------------------+
358 // | JSFunction continuation | | JSFunction continuation |
359 // +-------------------------+ +-------------------------+
360 // | | saved frame (fp) | | saved frame (fp) |
361 // | +=========================+<-fp +=========================+<-fp
362 // | | JSFunction context | | JSFunction context |
363 // v +-------------------------+ +-------------------------|
364 // | COMPILED_STUB marker | | STUB_FAILURE marker |
365 // +-------------------------+ +-------------------------+
366 // | | | caller args.arguments_ |
367 // | ... | +-------------------------+
368 // | | | caller args.length_ |
369 // |-------------------------|<-sp +-------------------------+
370 // | caller args pointer |
371 // +-------------------------+
372 // | caller stack param 1 |
373 // parameters in registers +-------------------------+
374 // and spilled to stack | .... |
375 // +-------------------------+
376 // | caller stack param n |
377 // +-------------------------+<-sp
378 // s0-s1 = number of parameters
379 // s2 = failure handler address
380 // fp = saved frame
381 // cp = JSFunction context
382 //
383
384 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
385 int major_key = compiled_code_->major_key();
386 CodeStubInterfaceDescriptor* descriptor =
387 isolate_->code_stub_interface_descriptor(major_key);
388
389 // The output frame must have room for all pushed register parameters
390 // and the standard stack frame slots. Include space for an argument
391 // object to the callee and optionally the space to pass the argument
392 // object to the stub failure handler.
393 int height_in_bytes = kPointerSize * descriptor->register_param_count_ +
394 sizeof(Arguments) + kPointerSize;
395 int fixed_frame_size = StandardFrameConstants::kFixedFrameSize;
396 int input_frame_size = input_->GetFrameSize();
397 int output_frame_size = height_in_bytes + fixed_frame_size;
398 if (trace_) {
399 PrintF(" translating %s => StubFailureTrampolineStub, height=%d\n",
400 CodeStub::MajorName(static_cast<CodeStub::Major>(major_key), false),
401 height_in_bytes);
402 }
403
404 // The stub failure trampoline is a single frame.
405
406 FrameDescription* output_frame =
407 new(output_frame_size) FrameDescription(output_frame_size, NULL);
408 output_frame->SetFrameType(StackFrame::STUB_FAILURE_TRAMPOLINE);
409 ASSERT(frame_index == 0);
410 output_[frame_index] = output_frame;
411 // The top address for the output frame can be computed from the input
412 // frame pointer and the output frame's height. Subtract space for the
413 // context and function slots.
414 intptr_t top_address = input_->GetRegister(fp.code()) - (2 * kPointerSize) -
415 height_in_bytes;
416 output_frame->SetTop(top_address);
417
418 // Read caller's PC (JSFunction continuation) from the input frame.
419 intptr_t input_frame_offset = input_frame_size - kPointerSize;
420 intptr_t output_frame_offset = output_frame_size - kPointerSize;
421 intptr_t value = input_->GetFrameSlot(input_frame_offset);
422 output_frame->SetFrameSlot(output_frame_offset, value);
423 if (trace_) {
424 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n",
425 top_address + output_frame_offset, output_frame_offset, value);
426 }
427
428 // Read caller's FP from the input frame, and set this frame's FP.
429 input_frame_offset -= kPointerSize;
430 value = input_->GetFrameSlot(input_frame_offset);
431 output_frame_offset -= kPointerSize;
432 output_frame->SetFrameSlot(output_frame_offset, value);
433 intptr_t frame_ptr = input_->GetRegister(fp.code());
434 output_frame->SetRegister(fp.code(), frame_ptr);
435 output_frame->SetFp(frame_ptr);
436 if (trace_) {
437 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
438 top_address + output_frame_offset, output_frame_offset, value);
439 }
440
441 // The context can be gotten from the input frame.
442 input_frame_offset -= kPointerSize;
443 value = input_->GetFrameSlot(input_frame_offset);
444 output_frame->SetRegister(cp.code(), value);
445 output_frame_offset -= kPointerSize;
446 output_frame->SetFrameSlot(output_frame_offset, value);
447 if (trace_) {
448 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n",
449 top_address + output_frame_offset, output_frame_offset, value);
450 }
451
452 // A marker value is used in place of the function.
453 output_frame_offset -= kPointerSize;
454 value = reinterpret_cast<intptr_t>(
455 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE));
456 output_frame->SetFrameSlot(output_frame_offset, value);
457 if (trace_) {
458 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function (stub fail sentinel)\n",
459 top_address + output_frame_offset, output_frame_offset, value);
460 }
461
462 int caller_arg_count = 0;
463 if (descriptor->stack_parameter_count_ != NULL) {
464 caller_arg_count =
465 input_->GetRegister(descriptor->stack_parameter_count_->code());
466 }
467
468 // Build the Arguments object for the caller's parameters and a pointer to it.
469 output_frame_offset -= kPointerSize;
470 value = frame_ptr + StandardFrameConstants::kCallerSPOffset +
471 (caller_arg_count - 1) * kPointerSize;
472 output_frame->SetFrameSlot(output_frame_offset, value);
473 if (trace_) {
474 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; args.arguments\n",
475 top_address + output_frame_offset, output_frame_offset, value);
476 }
477
478 output_frame_offset -= kPointerSize;
479 value = caller_arg_count;
480 output_frame->SetFrameSlot(output_frame_offset, value);
481 if (trace_) {
482 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; args.length\n",
483 top_address + output_frame_offset, output_frame_offset, value);
484 }
485
486 output_frame_offset -= kPointerSize;
487 value = frame_ptr - (output_frame_size - output_frame_offset) -
488 StandardFrameConstants::kMarkerOffset + kPointerSize;
489 output_frame->SetFrameSlot(output_frame_offset, value);
490 if (trace_) {
491 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; args*\n",
492 top_address + output_frame_offset, output_frame_offset, value);
493 }
494
495 // Copy the register parameters to the failure frame.
496 for (int i = 0; i < descriptor->register_param_count_; ++i) {
497 output_frame_offset -= kPointerSize;
498 DoTranslateCommand(iterator, 0, output_frame_offset);
499 }
500
501 ASSERT(0 == output_frame_offset);
502
503 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) {
504 double double_value = input_->GetDoubleRegister(i);
505 output_frame->SetDoubleRegister(i, double_value);
506 }
507
508 ApiFunction function(descriptor->deoptimization_handler_);
509 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_);
510 intptr_t handler = reinterpret_cast<intptr_t>(xref.address());
511 int params = descriptor->register_param_count_;
512 if (descriptor->stack_parameter_count_ != NULL) {
513 params++;
514 }
515 output_frame->SetRegister(s0.code(), params);
516 output_frame->SetRegister(s1.code(), (params - 1) * kPointerSize);
517 output_frame->SetRegister(s2.code(), handler);
518
519 // Compute this frame's PC, state, and continuation.
520 Code* trampoline = NULL;
521 int extra = descriptor->extra_expression_stack_count_;
522 StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_);
523 ASSERT(trampoline != NULL);
524 output_frame->SetPc(reinterpret_cast<intptr_t>(
525 trampoline->instruction_start()));
526 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
527 Code* notify_failure =
528 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
529 output_frame->SetContinuation(
530 reinterpret_cast<intptr_t>(notify_failure->entry()));
531 }
532
533
534 // This code is very similar to ia32/arm code, but relies on register names 352 // This code is very similar to ia32/arm code, but relies on register names
535 // (fp, sp) and how the frame is laid out. 353 // (fp, sp) and how the frame is laid out.
536 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, 354 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
537 int frame_index) { 355 int frame_index) {
538 // Read the ast node id, function, and frame height for this output frame. 356 // Read the ast node id, function, and frame height for this output frame.
539 BailoutId node_id = BailoutId(iterator->Next()); 357 BailoutId node_id = BailoutId(iterator->Next());
540 JSFunction* function; 358 JSFunction* function;
541 if (frame_index != 0) { 359 if (frame_index != 0) {
542 function = JSFunction::cast(ComputeLiteral(iterator->Next())); 360 function = JSFunction::cast(ComputeLiteral(iterator->Next()));
543 } else { 361 } else {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 input_->SetDoubleRegister(i, 0.0); 536 input_->SetDoubleRegister(i, 0.0);
719 } 537 }
720 538
721 // Fill the frame content from the actual data on the frame. 539 // Fill the frame content from the actual data on the frame.
722 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { 540 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) {
723 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); 541 input_->SetFrameSlot(i, Memory::uint32_at(tos + i));
724 } 542 }
725 } 543 }
726 544
727 545
546 void Deoptimizer::SetPlatformCompiledStubRegisters(
547 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) {
548 ApiFunction function(descriptor->deoptimization_handler_);
549 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_);
550 intptr_t handler = reinterpret_cast<intptr_t>(xref.address());
551 int params = descriptor->register_param_count_;
552 if (descriptor->stack_parameter_count_ != NULL) {
553 params++;
554 }
555 output_frame->SetRegister(s0.code(), params);
556 output_frame->SetRegister(s1.code(), (params - 1) * kPointerSize);
557 output_frame->SetRegister(s2.code(), handler);
558 }
559
560
561 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
562 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) {
563 double double_value = input_->GetDoubleRegister(i);
564 output_frame->SetDoubleRegister(i, double_value);
565 }
566 }
567
568
728 #define __ masm()-> 569 #define __ masm()->
729 570
730 571
731 // This code tries to be close to ia32 code so that any changes can be 572 // This code tries to be close to ia32 code so that any changes can be
732 // easily ported. 573 // easily ported.
733 void Deoptimizer::EntryGenerator::Generate() { 574 void Deoptimizer::EntryGenerator::Generate() {
734 GeneratePrologue(); 575 GeneratePrologue();
735 576
736 Isolate* isolate = masm()->isolate(); 577 Isolate* isolate = masm()->isolate();
737 578
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 } 830 }
990 831
991 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start), 832 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start),
992 count() * table_entry_size_); 833 count() * table_entry_size_);
993 } 834 }
994 835
995 #undef __ 836 #undef __
996 837
997 838
998 } } // namespace v8::internal 839 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/mips/frames-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698