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

Side by Side Diff: src/full-codegen/mips/full-codegen-mips.cc

Issue 1670133002: [es6] Further fixing of tail Calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tail call tracing added Created 4 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_MIPS 5 #if V8_TARGET_ARCH_MIPS
6 6
7 // Note on Mips implementation: 7 // Note on Mips implementation:
8 // 8 //
9 // The result_register() for mips is the 'v0' register, which is defined 9 // The result_register() for mips is the 'v0' register, which is defined
10 // by the ABI to contain function return values. However, the first 10 // by the ABI to contain function return values. However, the first
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 EmitProfilingCounterReset(); 407 EmitProfilingCounterReset();
408 408
409 __ bind(&ok); 409 __ bind(&ok);
410 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); 410 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS);
411 // Record a mapping of the OSR id to this PC. This is used if the OSR 411 // Record a mapping of the OSR id to this PC. This is used if the OSR
412 // entry becomes the target of a bailout. We don't expect it to be, but 412 // entry becomes the target of a bailout. We don't expect it to be, but
413 // we want it to work if it is. 413 // we want it to work if it is.
414 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); 414 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS);
415 } 415 }
416 416
417 void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence(
418 bool is_tail_call) {
419 // Pretend that the exit is a backwards jump to the entry.
420 int weight = 1;
421 if (info_->ShouldSelfOptimize()) {
422 weight = FLAG_interrupt_budget / FLAG_self_opt_count;
423 } else {
424 int distance = masm_->pc_offset();
425 weight = Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier));
426 }
427 EmitProfilingCounterDecrement(weight);
428 Label ok;
429 __ Branch(&ok, ge, a3, Operand(zero_reg));
430 // Don't need to save result register if we are going to do a tail call.
431 if (!is_tail_call) {
432 __ push(v0);
433 }
434 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET);
435 if (!is_tail_call) {
436 __ pop(v0);
437 }
438 EmitProfilingCounterReset();
439 __ bind(&ok);
440 }
417 441
418 void FullCodeGenerator::EmitReturnSequence() { 442 void FullCodeGenerator::EmitReturnSequence() {
419 Comment cmnt(masm_, "[ Return sequence"); 443 Comment cmnt(masm_, "[ Return sequence");
420 if (return_label_.is_bound()) { 444 if (return_label_.is_bound()) {
421 __ Branch(&return_label_); 445 __ Branch(&return_label_);
422 } else { 446 } else {
423 __ bind(&return_label_); 447 __ bind(&return_label_);
424 if (FLAG_trace) { 448 if (FLAG_trace) {
425 // Push the return value on the stack as the parameter. 449 // Push the return value on the stack as the parameter.
426 // Runtime::TraceExit returns its parameter in v0. 450 // Runtime::TraceExit returns its parameter in v0.
427 __ push(v0); 451 __ push(v0);
428 __ CallRuntime(Runtime::kTraceExit); 452 __ CallRuntime(Runtime::kTraceExit);
429 } 453 }
430 // Pretend that the exit is a backwards jump to the entry. 454 EmitProfilingCounterHandlingForReturnSequence(false);
431 int weight = 1;
432 if (info_->ShouldSelfOptimize()) {
433 weight = FLAG_interrupt_budget / FLAG_self_opt_count;
434 } else {
435 int distance = masm_->pc_offset();
436 weight = Min(kMaxBackEdgeWeight,
437 Max(1, distance / kCodeSizeMultiplier));
438 }
439 EmitProfilingCounterDecrement(weight);
440 Label ok;
441 __ Branch(&ok, ge, a3, Operand(zero_reg));
442 __ push(v0);
443 __ Call(isolate()->builtins()->InterruptCheck(),
444 RelocInfo::CODE_TARGET);
445 __ pop(v0);
446 EmitProfilingCounterReset();
447 __ bind(&ok);
448 455
449 // Make sure that the constant pool is not emitted inside of the return 456 // Make sure that the constant pool is not emitted inside of the return
450 // sequence. 457 // sequence.
451 { Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); 458 { Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_);
452 // Here we use masm_-> instead of the __ macro to avoid the code coverage 459 // Here we use masm_-> instead of the __ macro to avoid the code coverage
453 // tool from instrumenting as we rely on the code size here. 460 // tool from instrumenting as we rely on the code size here.
454 int32_t arg_count = info_->scope()->num_parameters() + 1; 461 int32_t arg_count = info_->scope()->num_parameters() + 1;
455 int32_t sp_delta = arg_count * kPointerSize; 462 int32_t sp_delta = arg_count * kPointerSize;
456 SetReturnPosition(literal()); 463 SetReturnPosition(literal());
457 masm_->mov(sp, fp); 464 masm_->mov(sp, fp);
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2734 // Load the arguments. 2741 // Load the arguments.
2735 ZoneList<Expression*>* args = expr->arguments(); 2742 ZoneList<Expression*>* args = expr->arguments();
2736 int arg_count = args->length(); 2743 int arg_count = args->length();
2737 for (int i = 0; i < arg_count; i++) { 2744 for (int i = 0; i < arg_count; i++) {
2738 VisitForStackValue(args->at(i)); 2745 VisitForStackValue(args->at(i));
2739 } 2746 }
2740 2747
2741 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); 2748 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
2742 // Record source position of the IC call. 2749 // Record source position of the IC call.
2743 SetCallPosition(expr); 2750 SetCallPosition(expr);
2751 if (expr->tail_call_mode() == TailCallMode::kAllow) {
2752 if (FLAG_trace) {
2753 __ CallRuntime(Runtime::kTraceTailCall);
2754 }
2755 // Update profiling counters before the tail call since we will
2756 // not return to this function.
2757 EmitProfilingCounterHandlingForReturnSequence(true);
2758 }
2744 Handle<Code> ic = 2759 Handle<Code> ic =
2745 CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode()) 2760 CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode())
2746 .code(); 2761 .code();
2747 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackICSlot()))); 2762 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackICSlot())));
2748 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); 2763 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
2749 // Don't assign a type feedback id to the IC, since type feedback is provided 2764 // Don't assign a type feedback id to the IC, since type feedback is provided
2750 // by the vector above. 2765 // by the vector above.
2751 CallIC(ic); 2766 CallIC(ic);
2752 2767
2753 RecordJSReturnSite(expr); 2768 RecordJSReturnSite(expr);
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
4668 reinterpret_cast<uint32_t>( 4683 reinterpret_cast<uint32_t>(
4669 isolate->builtins()->OsrAfterStackCheck()->entry())); 4684 isolate->builtins()->OsrAfterStackCheck()->entry()));
4670 return OSR_AFTER_STACK_CHECK; 4685 return OSR_AFTER_STACK_CHECK;
4671 } 4686 }
4672 4687
4673 4688
4674 } // namespace internal 4689 } // namespace internal
4675 } // namespace v8 4690 } // namespace v8
4676 4691
4677 #endif // V8_TARGET_ARCH_MIPS 4692 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/full-codegen/ia32/full-codegen-ia32.cc ('k') | src/full-codegen/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698