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

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

Issue 12093089: Support pass-through of stub caller arguments (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ARM port Created 7 years, 10 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 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // | .... | | .... | 459 // | .... | | .... |
460 // +-------------------------+ +-------------------------+ 460 // +-------------------------+ +-------------------------+
461 // | JSFunction continuation | | JSFunction continuation | 461 // | JSFunction continuation | | JSFunction continuation |
462 // +-------------------------+ +-------------------------+ 462 // +-------------------------+ +-------------------------+
463 // | | saved frame (fp) | | saved frame (fp) | 463 // | | saved frame (fp) | | saved frame (fp) |
464 // | +=========================+<-fp +=========================+<-fp 464 // | +=========================+<-fp +=========================+<-fp
465 // | | JSFunction context | | JSFunction context | 465 // | | JSFunction context | | JSFunction context |
466 // v +-------------------------+ +-------------------------| 466 // v +-------------------------+ +-------------------------|
467 // | COMPILED_STUB marker | | STUB_FAILURE marker | 467 // | COMPILED_STUB marker | | STUB_FAILURE marker |
468 // +-------------------------+ +-------------------------+ 468 // +-------------------------+ +-------------------------+
469 // | | | stub parameter 1 | 469 // | | | caller args.length_ |
470 // | ... | +-------------------------+ 470 // | ... | +-------------------------+
471 // | | | ... | 471 // | | | caller args.arguments_ |
472 // |-------------------------|<-sp +-------------------------+ 472 // |-------------------------|<-sp +-------------------------+
473 // | stub parameter n | 473 // | caller args pointer |
474 // parameters in registers +-------------------------+<-sp 474 // +-------------------------+
475 // and spilled to stack r0 = number of parameters 475 // | caller stack param 1 |
476 // parameters in registers +-------------------------+
477 // and spilled to stack | .... |
478 // +-------------------------+
479 // | caller stack param n |
480 // +-------------------------+<-sp
481 // r0 = number of parameters
476 // r1 = failure handler address 482 // r1 = failure handler address
477 // fp = saved frame 483 // fp = saved frame
478 // cp = JSFunction context 484 // cp = JSFunction context
479 // 485 //
480 486
481 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); 487 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
482 int major_key = compiled_code_->major_key(); 488 int major_key = compiled_code_->major_key();
483 CodeStubInterfaceDescriptor* descriptor = 489 CodeStubInterfaceDescriptor* descriptor =
484 isolate_->code_stub_interface_descriptor(major_key); 490 isolate_->code_stub_interface_descriptor(major_key);
485 491
492 // The output frame must have room for all pushed register parameters
493 // and the standard stack frame slots.
486 int output_frame_size = StandardFrameConstants::kFixedFrameSize + 494 int output_frame_size = StandardFrameConstants::kFixedFrameSize +
487 kPointerSize * descriptor->register_param_count_; 495 kPointerSize * descriptor->register_param_count_;
488 496
497 // Include space for an argument object to the callee and optionally
498 // the space to pass the argument object to the stub failure handler.
499 output_frame_size += sizeof(Arguments) + kPointerSize;
500
489 FrameDescription* output_frame = 501 FrameDescription* output_frame =
490 new(output_frame_size) FrameDescription(output_frame_size, 0); 502 new(output_frame_size) FrameDescription(output_frame_size, 0);
491 ASSERT(frame_index == 0); 503 ASSERT(frame_index == 0);
492 output_[frame_index] = output_frame; 504 output_[frame_index] = output_frame;
493 Code* notify_failure = 505 Code* notify_failure =
494 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); 506 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
495 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); 507 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
496 output_frame->SetContinuation( 508 output_frame->SetContinuation(
497 reinterpret_cast<intptr_t>(notify_failure->entry())); 509 reinterpret_cast<intptr_t>(notify_failure->entry()));
498 510
499 Code* trampoline = NULL; 511 Code* trampoline = NULL;
500 StubFailureTrampolineStub().FindCodeInCache(&trampoline, isolate_); 512 int extra = descriptor->extra_expression_stack_count_;
513 StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_);
501 ASSERT(trampoline != NULL); 514 ASSERT(trampoline != NULL);
502 output_frame->SetPc(reinterpret_cast<intptr_t>( 515 output_frame->SetPc(reinterpret_cast<intptr_t>(
503 trampoline->instruction_start())); 516 trampoline->instruction_start()));
504 unsigned input_frame_size = input_->GetFrameSize(); 517 unsigned input_frame_size = input_->GetFrameSize();
505 518
519 intptr_t frame_ptr = input_->GetRegister(fp.code());
520
506 // JSFunction continuation 521 // JSFunction continuation
507 intptr_t input_frame_offset = input_frame_size - kPointerSize; 522 intptr_t input_frame_offset = input_frame_size - kPointerSize;
508 intptr_t output_frame_offset = output_frame_size - kPointerSize; 523 intptr_t output_frame_offset = output_frame_size - kPointerSize;
509 intptr_t value = input_->GetFrameSlot(input_frame_offset); 524 intptr_t value = input_->GetFrameSlot(input_frame_offset);
510 output_frame->SetFrameSlot(output_frame_offset, value); 525 output_frame->SetFrameSlot(output_frame_offset, value);
511 526
512 // saved frame ptr 527 // saved frame ptr
513 input_frame_offset -= kPointerSize; 528 input_frame_offset -= kPointerSize;
514 value = input_->GetFrameSlot(input_frame_offset); 529 value = input_->GetFrameSlot(input_frame_offset);
515 output_frame_offset -= kPointerSize; 530 output_frame_offset -= kPointerSize;
516 output_frame->SetFrameSlot(output_frame_offset, value); 531 output_frame->SetFrameSlot(output_frame_offset, value);
517 532
518 // Restore context 533 // Restore context
519 input_frame_offset -= kPointerSize; 534 input_frame_offset -= kPointerSize;
520 value = input_->GetFrameSlot(input_frame_offset); 535 value = input_->GetFrameSlot(input_frame_offset);
521 output_frame->SetRegister(cp.code(), value); 536 output_frame->SetRegister(cp.code(), value);
522 output_frame_offset -= kPointerSize; 537 output_frame_offset -= kPointerSize;
523 output_frame->SetFrameSlot(output_frame_offset, value); 538 output_frame->SetFrameSlot(output_frame_offset, value);
524 539
525 // Internal frame markers 540 // Internal frame markers
526 output_frame_offset -= kPointerSize; 541 output_frame_offset -= kPointerSize;
527 value = reinterpret_cast<intptr_t>( 542 value = reinterpret_cast<intptr_t>(
528 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); 543 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE));
529 output_frame->SetFrameSlot(output_frame_offset, value); 544 output_frame->SetFrameSlot(output_frame_offset, value);
530 545
546 int caller_arg_count = 0;
547 if (descriptor->stack_parameter_count_ != NULL) {
548 caller_arg_count =
549 input_->GetRegister(descriptor->stack_parameter_count_->code());
550 }
551
552 // Build the Arguments object for the caller's parameters and a pointer to it.
553 output_frame_offset -= kPointerSize;
554 value = frame_ptr + StandardFrameConstants::kCallerSPOffset +
555 (caller_arg_count - 1) * kPointerSize;
556 output_frame->SetFrameSlot(output_frame_offset, value);
557
558 output_frame->SetFrameSlot(output_frame_offset, value);
559 output_frame_offset -= kPointerSize;
560 output_frame->SetFrameSlot(output_frame_offset, caller_arg_count);
561
562 value = frame_ptr - (output_frame_size - output_frame_offset) -
563 StandardFrameConstants::kMarkerOffset;
564 output_frame_offset -= kPointerSize;
565 output_frame->SetFrameSlot(output_frame_offset, value);
566
567 // Copy the register parameters to the failure frame.
531 for (int i = 0; i < descriptor->register_param_count_; ++i) { 568 for (int i = 0; i < descriptor->register_param_count_; ++i) {
532 output_frame_offset -= kPointerSize; 569 output_frame_offset -= kPointerSize;
533 DoTranslateCommand(iterator, 0, output_frame_offset); 570 DoTranslateCommand(iterator, 0, output_frame_offset);
534 } 571 }
535 572
536 value = input_->GetRegister(fp.code()); 573 output_frame->SetRegister(fp.code(), frame_ptr);
537 output_frame->SetRegister(fp.code(), value); 574 output_frame->SetFp(frame_ptr);
538 output_frame->SetFp(value);
539 575
540 ApiFunction function(descriptor->deoptimization_handler_); 576 ApiFunction function(descriptor->deoptimization_handler_);
541 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_); 577 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_);
542 intptr_t handler = reinterpret_cast<intptr_t>(xref.address()); 578 intptr_t handler = reinterpret_cast<intptr_t>(xref.address());
543 output_frame->SetRegister(r0.code(), descriptor->register_param_count_); 579 int params = descriptor->register_param_count_;
580 if (descriptor->stack_parameter_count_ != NULL) {
581 params++;
582 }
583 output_frame->SetRegister(r0.code(), params);
544 output_frame->SetRegister(r1.code(), handler); 584 output_frame->SetRegister(r1.code(), handler);
545 } 585 }
546 586
547 587
548 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, 588 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator,
549 int frame_index) { 589 int frame_index) {
550 Builtins* builtins = isolate_->builtins(); 590 Builtins* builtins = isolate_->builtins();
551 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); 591 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric);
552 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); 592 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
553 unsigned height = iterator->Next(); 593 unsigned height = iterator->Next();
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 __ push(ip); 1266 __ push(ip);
1227 __ b(&done); 1267 __ b(&done);
1228 ASSERT(masm()->pc_offset() - start == table_entry_size_); 1268 ASSERT(masm()->pc_offset() - start == table_entry_size_);
1229 } 1269 }
1230 __ bind(&done); 1270 __ bind(&done);
1231 } 1271 }
1232 1272
1233 #undef __ 1273 #undef __
1234 1274
1235 } } // namespace v8::internal 1275 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/arm/lithium-arm.cc » ('j') | src/frames.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698