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

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

Issue 9265004: Support inlining at call-sites with mismatched number of arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 11 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 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (FLAG_trace_osr) { 430 if (FLAG_trace_osr) {
431 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", 431 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ",
432 ok ? "finished" : "aborted", 432 ok ? "finished" : "aborted",
433 reinterpret_cast<intptr_t>(function)); 433 reinterpret_cast<intptr_t>(function));
434 function->PrintName(); 434 function->PrintName();
435 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc()); 435 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc());
436 } 436 }
437 } 437 }
438 438
439 439
440 void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator,
441 int frame_index) {
442 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
443 unsigned height = iterator->Next();
444 unsigned height_in_bytes = height * kPointerSize;
445 if (FLAG_trace_deopt) {
446 PrintF(" translating arguments adaptor => height=%d\n", height_in_bytes);
447 }
448
449 unsigned fixed_frame_size = 5 * kPointerSize;
450 unsigned input_frame_size = input_->GetFrameSize();
451 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
452
453 // Allocate and store the output frame description.
454 FrameDescription* output_frame =
455 new(output_frame_size) FrameDescription(output_frame_size, function);
456 #ifdef DEBUG
457 output_frame->SetKind(Code::BUILTIN);
458 #endif
459
460 // Arguments adaptor can not be topmost or bottommost.
461 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
462 ASSERT(output_[frame_index] == NULL);
463 output_[frame_index] = output_frame;
464
465 // The top address for the bottommost output frame can be computed from
466 // the input frame pointer and the output frame's height. For all
467 // subsequent output frames, it can be computed from the previous one's
468 // top address and the current frame's size.
469 uint32_t top_address;
470 top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
471 output_frame->SetTop(top_address);
472
473 // Compute the incoming parameter translation.
474 int parameter_count = height;
475 unsigned output_offset = output_frame_size;
476 unsigned input_offset = input_frame_size;
477 for (int i = 0; i < parameter_count; ++i) {
478 output_offset -= kPointerSize;
479 DoTranslateCommand(iterator, frame_index, output_offset);
480 }
481 input_offset -= (parameter_count * kPointerSize);
482
483 // Compute caller's PC
484 output_offset -= kPointerSize;
485 input_offset -= kPointerSize;
486 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
487 output_frame->SetFrameSlot(output_offset, callers_pc);
488 if (FLAG_trace_deopt) {
489 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n",
490 top_address + output_offset, output_offset, callers_pc);
491 }
492
493 // Compute caller's FP
494 output_offset -= kPointerSize;
495 input_offset -= kPointerSize;
496 intptr_t value = output_[frame_index - 1]->GetFp();
497 output_frame->SetFrameSlot(output_offset, value);
498 intptr_t fp_value = top_address + output_offset;
499 output_frame->SetFp(fp_value);
500 if (FLAG_trace_deopt) {
501 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
502 fp_value, output_offset, value);
503 }
504
505 // For the bottommost output frame the context can be gotten from the input
506 // frame. For all subsequent output frames it can be gotten from the function
507 // so long as we don't inline functions that need local contexts.
508 output_offset -= kPointerSize;
509 input_offset -= kPointerSize;
510 intptr_t context = reinterpret_cast<intptr_t>(
511 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
512 output_frame->SetFrameSlot(output_offset, context);
513 if (FLAG_trace_deopt) {
514 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context (adaptor sentinel)\n",
515 top_address + output_offset, output_offset, context);
516 }
517
518 // The function was mentioned explicitly in the ARGUMENTS_ADAPTOR_FRAME.
519 output_offset -= kPointerSize;
520 input_offset -= kPointerSize;
521 value = reinterpret_cast<intptr_t>(function);
522 output_frame->SetFrameSlot(output_offset, value);
523 if (FLAG_trace_deopt) {
524 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function\n",
525 top_address + output_offset, output_offset, value);
526 }
527
528 // Number of incomming arguments.
529 output_offset -= kPointerSize;
530 input_offset -= kPointerSize;
531 value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1));
532 output_frame->SetFrameSlot(output_offset, value);
533 if (FLAG_trace_deopt) {
534 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; argc (%d)\n",
535 top_address + output_offset, output_offset, value, height - 1);
536 }
537
538 ASSERT(0 == output_offset);
539
540 Builtins* builtins = isolate_->builtins();
541 Code* adaptor_trampoline =
542 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
543 uint32_t pc = reinterpret_cast<uint32_t>(
544 adaptor_trampoline->instruction_start() +
545 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value());
546 output_frame->SetPc(pc);
547 }
548
549
440 void Deoptimizer::DoComputeFrame(TranslationIterator* iterator, 550 void Deoptimizer::DoComputeFrame(TranslationIterator* iterator,
441 int frame_index) { 551 int frame_index) {
442 // Read the ast node id, function, and frame height for this output frame.
443 Translation::Opcode opcode =
444 static_cast<Translation::Opcode>(iterator->Next());
445 USE(opcode);
446 ASSERT(Translation::FRAME == opcode);
447 int node_id = iterator->Next(); 552 int node_id = iterator->Next();
448 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); 553 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
449 unsigned height = iterator->Next(); 554 unsigned height = iterator->Next();
450 unsigned height_in_bytes = height * kPointerSize; 555 unsigned height_in_bytes = height * kPointerSize;
451 if (FLAG_trace_deopt) { 556 if (FLAG_trace_deopt) {
452 PrintF(" translating "); 557 PrintF(" translating ");
453 function->PrintName(); 558 function->PrintName();
454 PrintF(" => node=%d, height=%d\n", node_id, height_in_bytes); 559 PrintF(" => node=%d, height=%d\n", node_id, height_in_bytes);
455 } 560 }
456 561
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 926 }
822 __ bind(&done); 927 __ bind(&done);
823 } 928 }
824 929
825 #undef __ 930 #undef __
826 931
827 932
828 } } // namespace v8::internal 933 } } // namespace v8::internal
829 934
830 #endif // V8_TARGET_ARCH_IA32 935 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698