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

Side by Side Diff: src/full-codegen/mips64/full-codegen-mips64.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
« no previous file with comments | « src/full-codegen/mips/full-codegen-mips.cc ('k') | src/full-codegen/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 // 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_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
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 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2745 // Load the arguments. 2752 // Load the arguments.
2746 ZoneList<Expression*>* args = expr->arguments(); 2753 ZoneList<Expression*>* args = expr->arguments();
2747 int arg_count = args->length(); 2754 int arg_count = args->length();
2748 for (int i = 0; i < arg_count; i++) { 2755 for (int i = 0; i < arg_count; i++) {
2749 VisitForStackValue(args->at(i)); 2756 VisitForStackValue(args->at(i));
2750 } 2757 }
2751 2758
2752 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); 2759 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
2753 // Record source position of the IC call. 2760 // Record source position of the IC call.
2754 SetCallPosition(expr); 2761 SetCallPosition(expr);
2762 if (expr->tail_call_mode() == TailCallMode::kAllow) {
2763 if (FLAG_trace) {
2764 __ CallRuntime(Runtime::kTraceTailCall);
2765 }
2766 // Update profiling counters before the tail call since we will
2767 // not return to this function.
2768 EmitProfilingCounterHandlingForReturnSequence(true);
2769 }
2755 Handle<Code> ic = 2770 Handle<Code> ic =
2756 CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode()) 2771 CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode())
2757 .code(); 2772 .code();
2758 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackICSlot()))); 2773 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackICSlot())));
2759 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); 2774 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
2760 // Don't assign a type feedback id to the IC, since type feedback is provided 2775 // Don't assign a type feedback id to the IC, since type feedback is provided
2761 // by the vector above. 2776 // by the vector above.
2762 CallIC(ic); 2777 CallIC(ic);
2763 RecordJSReturnSite(expr); 2778 RecordJSReturnSite(expr);
2764 // Restore context register. 2779 // Restore context register.
(...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after
4687 reinterpret_cast<uint64_t>( 4702 reinterpret_cast<uint64_t>(
4688 isolate->builtins()->OsrAfterStackCheck()->entry())); 4703 isolate->builtins()->OsrAfterStackCheck()->entry()));
4689 return OSR_AFTER_STACK_CHECK; 4704 return OSR_AFTER_STACK_CHECK;
4690 } 4705 }
4691 4706
4692 4707
4693 } // namespace internal 4708 } // namespace internal
4694 } // namespace v8 4709 } // namespace v8
4695 4710
4696 #endif // V8_TARGET_ARCH_MIPS64 4711 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/full-codegen/mips/full-codegen-mips.cc ('k') | src/full-codegen/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698