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

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

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

Powered by Google App Engine
This is Rietveld 408576698