| OLD | NEW |
| 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_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 EmitProfilingCounterReset(); | 376 EmitProfilingCounterReset(); |
| 377 | 377 |
| 378 __ bind(&ok); | 378 __ bind(&ok); |
| 379 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 379 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); |
| 380 // Record a mapping of the OSR id to this PC. This is used if the OSR | 380 // Record a mapping of the OSR id to this PC. This is used if the OSR |
| 381 // entry becomes the target of a bailout. We don't expect it to be, but | 381 // entry becomes the target of a bailout. We don't expect it to be, but |
| 382 // we want it to work if it is. | 382 // we want it to work if it is. |
| 383 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); | 383 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence( |
| 387 bool is_tail_call) { |
| 388 // Pretend that the exit is a backwards jump to the entry. |
| 389 int weight = 1; |
| 390 if (info_->ShouldSelfOptimize()) { |
| 391 weight = FLAG_interrupt_budget / FLAG_self_opt_count; |
| 392 } else { |
| 393 int distance = masm_->pc_offset(); |
| 394 weight = Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier)); |
| 395 } |
| 396 EmitProfilingCounterDecrement(weight); |
| 397 Label ok; |
| 398 __ j(positive, &ok, Label::kNear); |
| 399 // Don't need to save result register if we are going to do a tail call. |
| 400 if (!is_tail_call) { |
| 401 __ push(eax); |
| 402 } |
| 403 __ call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); |
| 404 if (!is_tail_call) { |
| 405 __ pop(eax); |
| 406 } |
| 407 EmitProfilingCounterReset(); |
| 408 __ bind(&ok); |
| 409 } |
| 386 | 410 |
| 387 void FullCodeGenerator::EmitReturnSequence() { | 411 void FullCodeGenerator::EmitReturnSequence() { |
| 388 Comment cmnt(masm_, "[ Return sequence"); | 412 Comment cmnt(masm_, "[ Return sequence"); |
| 389 if (return_label_.is_bound()) { | 413 if (return_label_.is_bound()) { |
| 390 __ jmp(&return_label_); | 414 __ jmp(&return_label_); |
| 391 } else { | 415 } else { |
| 392 // Common return label | 416 // Common return label |
| 393 __ bind(&return_label_); | 417 __ bind(&return_label_); |
| 394 if (FLAG_trace) { | 418 if (FLAG_trace) { |
| 395 __ push(eax); | 419 __ push(eax); |
| 396 __ CallRuntime(Runtime::kTraceExit); | 420 __ CallRuntime(Runtime::kTraceExit); |
| 397 } | 421 } |
| 398 // Pretend that the exit is a backwards jump to the entry. | 422 EmitProfilingCounterHandlingForReturnSequence(false); |
| 399 int weight = 1; | |
| 400 if (info_->ShouldSelfOptimize()) { | |
| 401 weight = FLAG_interrupt_budget / FLAG_self_opt_count; | |
| 402 } else { | |
| 403 int distance = masm_->pc_offset(); | |
| 404 weight = Min(kMaxBackEdgeWeight, | |
| 405 Max(1, distance / kCodeSizeMultiplier)); | |
| 406 } | |
| 407 EmitProfilingCounterDecrement(weight); | |
| 408 Label ok; | |
| 409 __ j(positive, &ok, Label::kNear); | |
| 410 __ push(eax); | |
| 411 __ call(isolate()->builtins()->InterruptCheck(), | |
| 412 RelocInfo::CODE_TARGET); | |
| 413 __ pop(eax); | |
| 414 EmitProfilingCounterReset(); | |
| 415 __ bind(&ok); | |
| 416 | 423 |
| 417 SetReturnPosition(literal()); | 424 SetReturnPosition(literal()); |
| 418 __ leave(); | 425 __ leave(); |
| 419 | 426 |
| 420 int arg_count = info_->scope()->num_parameters() + 1; | 427 int arg_count = info_->scope()->num_parameters() + 1; |
| 421 int arguments_bytes = arg_count * kPointerSize; | 428 int arguments_bytes = arg_count * kPointerSize; |
| 422 __ Ret(arguments_bytes, ecx); | 429 __ Ret(arguments_bytes, ecx); |
| 423 } | 430 } |
| 424 } | 431 } |
| 425 | 432 |
| (...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2622 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { | 2629 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { |
| 2623 // Load the arguments. | 2630 // Load the arguments. |
| 2624 ZoneList<Expression*>* args = expr->arguments(); | 2631 ZoneList<Expression*>* args = expr->arguments(); |
| 2625 int arg_count = args->length(); | 2632 int arg_count = args->length(); |
| 2626 for (int i = 0; i < arg_count; i++) { | 2633 for (int i = 0; i < arg_count; i++) { |
| 2627 VisitForStackValue(args->at(i)); | 2634 VisitForStackValue(args->at(i)); |
| 2628 } | 2635 } |
| 2629 | 2636 |
| 2630 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); | 2637 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); |
| 2631 SetCallPosition(expr); | 2638 SetCallPosition(expr); |
| 2639 if (expr->tail_call_mode() == TailCallMode::kAllow) { |
| 2640 if (FLAG_trace) { |
| 2641 __ CallRuntime(Runtime::kTraceTailCall); |
| 2642 } |
| 2643 // Update profiling counters before the tail call since we will |
| 2644 // not return to this function. |
| 2645 EmitProfilingCounterHandlingForReturnSequence(true); |
| 2646 } |
| 2632 Handle<Code> ic = | 2647 Handle<Code> ic = |
| 2633 CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode()) | 2648 CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode()) |
| 2634 .code(); | 2649 .code(); |
| 2635 __ Move(edx, Immediate(SmiFromSlot(expr->CallFeedbackICSlot()))); | 2650 __ Move(edx, Immediate(SmiFromSlot(expr->CallFeedbackICSlot()))); |
| 2636 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2651 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
| 2637 // Don't assign a type feedback id to the IC, since type feedback is provided | 2652 // Don't assign a type feedback id to the IC, since type feedback is provided |
| 2638 // by the vector above. | 2653 // by the vector above. |
| 2639 CallIC(ic); | 2654 CallIC(ic); |
| 2640 | 2655 |
| 2641 RecordJSReturnSite(expr); | 2656 RecordJSReturnSite(expr); |
| (...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4459 Assembler::target_address_at(call_target_address, | 4474 Assembler::target_address_at(call_target_address, |
| 4460 unoptimized_code)); | 4475 unoptimized_code)); |
| 4461 return OSR_AFTER_STACK_CHECK; | 4476 return OSR_AFTER_STACK_CHECK; |
| 4462 } | 4477 } |
| 4463 | 4478 |
| 4464 | 4479 |
| 4465 } // namespace internal | 4480 } // namespace internal |
| 4466 } // namespace v8 | 4481 } // namespace v8 |
| 4467 | 4482 |
| 4468 #endif // V8_TARGET_ARCH_X87 | 4483 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |