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

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

Issue 13818013: Merged r13798, r13802, r13803, r13804, r13805, r14100 into 3.17 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.17
Patch Set: Created 7 years, 8 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 | « src/mips/code-stubs-mips.cc ('k') | src/mips/full-codegen-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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 Builtins* builtins = isolate_->builtins(); 438 Builtins* builtins = isolate_->builtins();
439 Code* adaptor_trampoline = 439 Code* adaptor_trampoline =
440 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); 440 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
441 uint32_t pc = reinterpret_cast<uint32_t>( 441 uint32_t pc = reinterpret_cast<uint32_t>(
442 adaptor_trampoline->instruction_start() + 442 adaptor_trampoline->instruction_start() +
443 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); 443 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value());
444 output_frame->SetPc(pc); 444 output_frame->SetPc(pc);
445 } 445 }
446 446
447 447
448 void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, 448 void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
449 int frame_index) { 449 int frame_index) {
450 // 450 //
451 // FROM TO 451 // FROM TO
452 // | .... | | .... | 452 // | .... | | .... |
453 // +-------------------------+ +-------------------------+ 453 // +-------------------------+ +-------------------------+
454 // | JSFunction continuation | | JSFunction continuation | 454 // | JSFunction continuation | | JSFunction continuation |
455 // +-------------------------+ +-------------------------+ 455 // +-------------------------+ +-------------------------+
456 // | | saved frame (fp) | | saved frame (fp) | 456 // | | saved frame (fp) | | saved frame (fp) |
457 // | +=========================+<-fp +=========================+<-fp 457 // | +=========================+<-fp +=========================+<-fp
458 // | | JSFunction context | | JSFunction context | 458 // | | JSFunction context | | JSFunction context |
459 // v +-------------------------+ +-------------------------| 459 // v +-------------------------+ +-------------------------|
460 // | COMPILED_STUB marker | | STUB_FAILURE marker | 460 // | COMPILED_STUB marker | | STUB_FAILURE marker |
461 // +-------------------------+ +-------------------------+ 461 // +-------------------------+ +-------------------------+
462 // | | | caller args.length_ | 462 // | | | caller args.arguments_ |
463 // | ... | +-------------------------+ 463 // | ... | +-------------------------+
464 // | | | caller args.arguments_ | 464 // | | | caller args.length_ |
465 // |-------------------------|<-sp +-------------------------+ 465 // |-------------------------|<-sp +-------------------------+
466 // | caller args pointer | 466 // | caller args pointer |
467 // +-------------------------+ 467 // +-------------------------+
468 // | caller stack param 1 | 468 // | caller stack param 1 |
469 // parameters in registers +-------------------------+ 469 // parameters in registers +-------------------------+
470 // and spilled to stack | .... | 470 // and spilled to stack | .... |
471 // +-------------------------+ 471 // +-------------------------+
472 // | caller stack param n | 472 // | caller stack param n |
473 // +-------------------------+<-sp 473 // +-------------------------+<-sp
474 // s0-s1 = number of parameters 474 // s0-s1 = number of parameters
475 // s2 = failure handler address 475 // s2 = failure handler address
476 // fp = saved frame 476 // fp = saved frame
477 // cp = JSFunction context 477 // cp = JSFunction context
478 // 478 //
479 479
480 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); 480 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
481 int major_key = compiled_code_->major_key(); 481 int major_key = compiled_code_->major_key();
482 CodeStubInterfaceDescriptor* descriptor = 482 CodeStubInterfaceDescriptor* descriptor =
483 isolate_->code_stub_interface_descriptor(major_key); 483 isolate_->code_stub_interface_descriptor(major_key);
484 484
485 // The output frame must have room for all pushed register parameters 485 // The output frame must have room for all pushed register parameters
486 // and the standard stack frame slots. 486 // and the standard stack frame slots. Include space for an argument
487 int output_frame_size = StandardFrameConstants::kFixedFrameSize + 487 // object to the callee and optionally the space to pass the argument
488 kPointerSize * descriptor->register_param_count_; 488 // object to the stub failure handler.
489 int height_in_bytes = kPointerSize * descriptor->register_param_count_ +
490 sizeof(Arguments) + kPointerSize;
491 int fixed_frame_size = StandardFrameConstants::kFixedFrameSize;
492 int input_frame_size = input_->GetFrameSize();
493 int output_frame_size = height_in_bytes + fixed_frame_size;
494 if (trace_) {
495 PrintF(" translating %s => StubFailureTrampolineStub, height=%d\n",
496 CodeStub::MajorName(static_cast<CodeStub::Major>(major_key), false),
497 height_in_bytes);
498 }
489 499
490 // Include space for an argument object to the callee and optionally 500 // The stub failure trampoline is a single frame.
491 // the space to pass the argument object to the stub failure handler.
492 output_frame_size += sizeof(Arguments) + kPointerSize;
493 501
494 FrameDescription* output_frame = 502 FrameDescription* output_frame =
495 new(output_frame_size) FrameDescription(output_frame_size, 0); 503 new(output_frame_size) FrameDescription(output_frame_size, NULL);
504 output_frame->SetFrameType(StackFrame::STUB_FAILURE_TRAMPOLINE);
496 ASSERT(frame_index == 0); 505 ASSERT(frame_index == 0);
497 output_[frame_index] = output_frame; 506 output_[frame_index] = output_frame;
498 Code* notify_failure = 507 // The top address for the output frame can be computed from the input
499 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); 508 // frame pointer and the output frame's height. Subtract space for the
500 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); 509 // context and function slots.
501 output_frame->SetContinuation( 510 intptr_t top_address = input_->GetRegister(fp.code()) - (2 * kPointerSize) -
502 reinterpret_cast<intptr_t>(notify_failure->entry())); 511 height_in_bytes;
512 output_frame->SetTop(top_address);
503 513
504 Code* trampoline = NULL; 514 // Read caller's PC (JSFunction continuation) from the input frame.
505 int extra = descriptor->extra_expression_stack_count_;
506 StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_);
507 ASSERT(trampoline != NULL);
508 output_frame->SetPc(reinterpret_cast<intptr_t>(
509 trampoline->instruction_start()));
510 unsigned input_frame_size = input_->GetFrameSize();
511
512 intptr_t frame_ptr = input_->GetRegister(fp.code());
513
514 // JSFunction continuation
515 intptr_t input_frame_offset = input_frame_size - kPointerSize; 515 intptr_t input_frame_offset = input_frame_size - kPointerSize;
516 intptr_t output_frame_offset = output_frame_size - kPointerSize; 516 intptr_t output_frame_offset = output_frame_size - kPointerSize;
517 intptr_t value = input_->GetFrameSlot(input_frame_offset); 517 intptr_t value = input_->GetFrameSlot(input_frame_offset);
518 output_frame->SetFrameSlot(output_frame_offset, value); 518 output_frame->SetFrameSlot(output_frame_offset, value);
519 if (trace_) {
520 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n",
521 top_address + output_frame_offset, output_frame_offset, value);
522 }
519 523
520 // saved frame ptr 524 // Read caller's FP from the input frame, and set this frame's FP.
521 input_frame_offset -= kPointerSize; 525 input_frame_offset -= kPointerSize;
522 value = input_->GetFrameSlot(input_frame_offset); 526 value = input_->GetFrameSlot(input_frame_offset);
523 output_frame_offset -= kPointerSize; 527 output_frame_offset -= kPointerSize;
524 output_frame->SetFrameSlot(output_frame_offset, value); 528 output_frame->SetFrameSlot(output_frame_offset, value);
529 intptr_t frame_ptr = input_->GetRegister(fp.code());
530 output_frame->SetRegister(fp.code(), frame_ptr);
531 output_frame->SetFp(frame_ptr);
532 if (trace_) {
533 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
534 top_address + output_frame_offset, output_frame_offset, value);
535 }
525 536
526 // Restore context 537 // The context can be gotten from the input frame.
527 input_frame_offset -= kPointerSize; 538 input_frame_offset -= kPointerSize;
528 value = input_->GetFrameSlot(input_frame_offset); 539 value = input_->GetFrameSlot(input_frame_offset);
529 output_frame->SetRegister(cp.code(), value); 540 output_frame->SetRegister(cp.code(), value);
530 output_frame_offset -= kPointerSize; 541 output_frame_offset -= kPointerSize;
531 output_frame->SetFrameSlot(output_frame_offset, value); 542 output_frame->SetFrameSlot(output_frame_offset, value);
543 if (trace_) {
544 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n",
545 top_address + output_frame_offset, output_frame_offset, value);
546 }
532 547
533 // Internal frame markers 548 // A marker value is used in place of the function.
534 output_frame_offset -= kPointerSize; 549 output_frame_offset -= kPointerSize;
535 value = reinterpret_cast<intptr_t>( 550 value = reinterpret_cast<intptr_t>(
536 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); 551 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE));
537 output_frame->SetFrameSlot(output_frame_offset, value); 552 output_frame->SetFrameSlot(output_frame_offset, value);
553 if (trace_) {
554 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function (stub fail sentinel)\n",
555 top_address + output_frame_offset, output_frame_offset, value);
556 }
538 557
539 int caller_arg_count = 0; 558 int caller_arg_count = 0;
540 if (descriptor->stack_parameter_count_ != NULL) { 559 if (descriptor->stack_parameter_count_ != NULL) {
541 caller_arg_count = 560 caller_arg_count =
542 input_->GetRegister(descriptor->stack_parameter_count_->code()); 561 input_->GetRegister(descriptor->stack_parameter_count_->code());
543 } 562 }
544 563
545 // Build the Arguments object for the caller's parameters and a pointer to it. 564 // Build the Arguments object for the caller's parameters and a pointer to it.
546 output_frame_offset -= kPointerSize; 565 output_frame_offset -= kPointerSize;
547 value = frame_ptr + StandardFrameConstants::kCallerSPOffset + 566 value = frame_ptr + StandardFrameConstants::kCallerSPOffset +
548 (caller_arg_count - 1) * kPointerSize; 567 (caller_arg_count - 1) * kPointerSize;
549 output_frame->SetFrameSlot(output_frame_offset, value); 568 output_frame->SetFrameSlot(output_frame_offset, value);
569 if (trace_) {
570 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; args.arguments\n",
571 top_address + output_frame_offset, output_frame_offset, value);
572 }
550 573
574 output_frame_offset -= kPointerSize;
575 value = caller_arg_count;
551 output_frame->SetFrameSlot(output_frame_offset, value); 576 output_frame->SetFrameSlot(output_frame_offset, value);
577 if (trace_) {
578 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; args.length\n",
579 top_address + output_frame_offset, output_frame_offset, value);
580 }
581
552 output_frame_offset -= kPointerSize; 582 output_frame_offset -= kPointerSize;
553 output_frame->SetFrameSlot(output_frame_offset, caller_arg_count);
554
555 value = frame_ptr - (output_frame_size - output_frame_offset) - 583 value = frame_ptr - (output_frame_size - output_frame_offset) -
556 StandardFrameConstants::kMarkerOffset; 584 StandardFrameConstants::kMarkerOffset + kPointerSize;
557 output_frame_offset -= kPointerSize;
558 output_frame->SetFrameSlot(output_frame_offset, value); 585 output_frame->SetFrameSlot(output_frame_offset, value);
586 if (trace_) {
587 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; args*\n",
588 top_address + output_frame_offset, output_frame_offset, value);
589 }
559 590
560 // Copy the register parameters to the failure frame. 591 // Copy the register parameters to the failure frame.
561 for (int i = 0; i < descriptor->register_param_count_; ++i) { 592 for (int i = 0; i < descriptor->register_param_count_; ++i) {
562 output_frame_offset -= kPointerSize; 593 output_frame_offset -= kPointerSize;
563 DoTranslateCommand(iterator, 0, output_frame_offset); 594 DoTranslateCommand(iterator, 0, output_frame_offset);
564 } 595 }
565 596
597 ASSERT(0 == output_frame_offset);
598
566 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) { 599 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) {
567 double double_value = input_->GetDoubleRegister(i); 600 double double_value = input_->GetDoubleRegister(i);
568 output_frame->SetDoubleRegister(i, double_value); 601 output_frame->SetDoubleRegister(i, double_value);
569 } 602 }
570 603
571 output_frame->SetRegister(fp.code(), frame_ptr);
572 output_frame->SetFp(frame_ptr);
573
574 ApiFunction function(descriptor->deoptimization_handler_); 604 ApiFunction function(descriptor->deoptimization_handler_);
575 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_); 605 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_);
576 intptr_t handler = reinterpret_cast<intptr_t>(xref.address()); 606 intptr_t handler = reinterpret_cast<intptr_t>(xref.address());
577 int params = descriptor->register_param_count_; 607 int params = descriptor->register_param_count_;
578 if (descriptor->stack_parameter_count_ != NULL) { 608 if (descriptor->stack_parameter_count_ != NULL) {
579 params++; 609 params++;
580 } 610 }
581 output_frame->SetRegister(s0.code(), params); 611 output_frame->SetRegister(s0.code(), params);
582 output_frame->SetRegister(s1.code(), (params - 1) * kPointerSize); 612 output_frame->SetRegister(s1.code(), (params - 1) * kPointerSize);
583 output_frame->SetRegister(s2.code(), handler); 613 output_frame->SetRegister(s2.code(), handler);
614
615 // Compute this frame's PC, state, and continuation.
616 Code* trampoline = NULL;
617 int extra = descriptor->extra_expression_stack_count_;
618 StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_);
619 ASSERT(trampoline != NULL);
620 output_frame->SetPc(reinterpret_cast<intptr_t>(
621 trampoline->instruction_start()));
622 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
623 Code* notify_failure =
624 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
625 output_frame->SetContinuation(
626 reinterpret_cast<intptr_t>(notify_failure->entry()));
584 } 627 }
585 628
586 629
587 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, 630 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator,
588 int frame_index) { 631 int frame_index) {
589 Builtins* builtins = isolate_->builtins(); 632 Builtins* builtins = isolate_->builtins();
590 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); 633 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric);
591 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); 634 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
592 unsigned height = iterator->Next(); 635 unsigned height = iterator->Next();
593 unsigned height_in_bytes = height * kPointerSize; 636 unsigned height_in_bytes = height * kPointerSize;
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 } 1325 }
1283 1326
1284 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start), 1327 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start),
1285 count() * table_entry_size_); 1328 count() * table_entry_size_);
1286 } 1329 }
1287 1330
1288 #undef __ 1331 #undef __
1289 1332
1290 1333
1291 } } // namespace v8::internal 1334 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698