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/x64/codegen-x64.cc

Issue 160446: X64: enable stack sampling in profiler. (Closed)
Patch Set: Created 11 years, 4 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/x64/codegen-x64.h ('k') | test/cctest/SConscript » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 3403 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 Result left = frame_->Pop(); 3414 Result left = frame_->Pop();
3415 right.ToRegister(); 3415 right.ToRegister();
3416 left.ToRegister(); 3416 left.ToRegister();
3417 __ cmpq(right.reg(), left.reg()); 3417 __ cmpq(right.reg(), left.reg());
3418 right.Unuse(); 3418 right.Unuse();
3419 left.Unuse(); 3419 left.Unuse();
3420 destination()->Split(equal); 3420 destination()->Split(equal);
3421 } 3421 }
3422 3422
3423 3423
3424 void CodeGenerator::GenerateGetFramePointer(ZoneList<Expression*>* args) {
3425 ASSERT(args->length() == 0);
3426 ASSERT(kSmiTag == 0); // RBP value is aligned, so it should look like Smi.
3427 Result rbp_as_smi = allocator_->Allocate();
3428 ASSERT(rbp_as_smi.is_valid());
3429 __ movq(rbp_as_smi.reg(), rbp);
3430 frame_->Push(&rbp_as_smi);
3431 }
3432
3433
3424 void CodeGenerator::GenerateRandomPositiveSmi(ZoneList<Expression*>* args) { 3434 void CodeGenerator::GenerateRandomPositiveSmi(ZoneList<Expression*>* args) {
3425 ASSERT(args->length() == 0); 3435 ASSERT(args->length() == 0);
3426 frame_->SpillAll(); 3436 frame_->SpillAll();
3427 3437
3428 // Make sure the frame is aligned like the OS expects. 3438 // Make sure the frame is aligned like the OS expects.
3429 static const int kFrameAlignment = OS::ActivationFrameAlignment(); 3439 static const int kFrameAlignment = OS::ActivationFrameAlignment();
3430 if (kFrameAlignment > 0) { 3440 if (kFrameAlignment > 0) {
3431 ASSERT(IsPowerOf2(kFrameAlignment)); 3441 ASSERT(IsPowerOf2(kFrameAlignment));
3432 __ movq(rbx, rsp); // Save in AMD-64 abi callee-saved register. 3442 __ movq(rbx, rsp); // Save in AMD-64 abi callee-saved register.
3433 __ and_(rsp, Immediate(-kFrameAlignment)); 3443 __ and_(rsp, Immediate(-kFrameAlignment));
(...skipping 3129 matching lines...) Expand 10 before | Expand all | Expand 10 after
6563 GenerateThrowOutOfMemory(masm); 6573 GenerateThrowOutOfMemory(masm);
6564 // control flow for generated will not return. 6574 // control flow for generated will not return.
6565 6575
6566 __ bind(&throw_normal_exception); 6576 __ bind(&throw_normal_exception);
6567 GenerateThrowTOS(masm); 6577 GenerateThrowTOS(masm);
6568 } 6578 }
6569 6579
6570 6580
6571 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { 6581 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
6572 Label invoke, exit; 6582 Label invoke, exit;
6583 #ifdef ENABLE_LOGGING_AND_PROFILING
6584 Label not_outermost_js, not_outermost_js_2;
6585 #endif
6573 6586
6574 // Setup frame. 6587 // Setup frame.
6575 __ push(rbp); 6588 __ push(rbp);
6576 __ movq(rbp, rsp); 6589 __ movq(rbp, rsp);
6577 6590
6578 // Save callee-saved registers (X64 calling conventions). 6591 // Save callee-saved registers (X64 calling conventions).
6579 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; 6592 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY;
6580 // Push something that is not an arguments adaptor. 6593 // Push something that is not an arguments adaptor.
6581 __ push(Immediate(ArgumentsAdaptorFrame::NON_SENTINEL)); 6594 __ push(Immediate(ArgumentsAdaptorFrame::NON_SENTINEL));
6582 __ push(Immediate(Smi::FromInt(marker))); // @ function offset 6595 __ push(Immediate(Smi::FromInt(marker))); // @ function offset
6583 __ push(r12); 6596 __ push(r12);
6584 __ push(r13); 6597 __ push(r13);
6585 __ push(r14); 6598 __ push(r14);
6586 __ push(r15); 6599 __ push(r15);
6587 __ push(rdi); 6600 __ push(rdi);
6588 __ push(rsi); 6601 __ push(rsi);
6589 __ push(rbx); 6602 __ push(rbx);
6590 // TODO(X64): Push XMM6-XMM15 (low 64 bits) as well, or make them 6603 // TODO(X64): Push XMM6-XMM15 (low 64 bits) as well, or make them
6591 // callee-save in JS code as well. 6604 // callee-save in JS code as well.
6592 6605
6593 // Save copies of the top frame descriptor on the stack. 6606 // Save copies of the top frame descriptor on the stack.
6594 ExternalReference c_entry_fp(Top::k_c_entry_fp_address); 6607 ExternalReference c_entry_fp(Top::k_c_entry_fp_address);
6595 __ load_rax(c_entry_fp); 6608 __ load_rax(c_entry_fp);
6596 __ push(rax); 6609 __ push(rax);
6597 6610
6611 #ifdef ENABLE_LOGGING_AND_PROFILING
6612 // If this is the outermost JS call, set js_entry_sp value.
6613 ExternalReference js_entry_sp(Top::k_js_entry_sp_address);
6614 __ load_rax(js_entry_sp);
6615 __ testq(rax, rax);
6616 __ j(NegateCondition(zero), &not_outermost_js);
William Hesse 2009/07/31 10:00:12 What is the difference between not_zero and Negate
Mikhail Naganov 2009/07/31 11:06:05 Thanks. I rarely touch code generation, so I'm not
6617 __ movq(rax, rbp);
6618 __ store_rax(js_entry_sp);
6619 __ bind(&not_outermost_js);
6620 #endif
6621
6598 // Call a faked try-block that does the invoke. 6622 // Call a faked try-block that does the invoke.
6599 __ call(&invoke); 6623 __ call(&invoke);
6600 6624
6601 // Caught exception: Store result (exception) in the pending 6625 // Caught exception: Store result (exception) in the pending
6602 // exception field in the JSEnv and return a failure sentinel. 6626 // exception field in the JSEnv and return a failure sentinel.
6603 ExternalReference pending_exception(Top::k_pending_exception_address); 6627 ExternalReference pending_exception(Top::k_pending_exception_address);
6604 __ store_rax(pending_exception); 6628 __ store_rax(pending_exception);
6605 __ movq(rax, Failure::Exception(), RelocInfo::NONE); 6629 __ movq(rax, Failure::Exception(), RelocInfo::NONE);
6606 __ jmp(&exit); 6630 __ jmp(&exit);
6607 6631
(...skipping 22 matching lines...) Expand all
6630 } 6654 }
6631 __ lea(kScratchRegister, FieldOperand(rax, Code::kHeaderSize)); 6655 __ lea(kScratchRegister, FieldOperand(rax, Code::kHeaderSize));
6632 __ call(kScratchRegister); 6656 __ call(kScratchRegister);
6633 6657
6634 // Unlink this frame from the handler chain. 6658 // Unlink this frame from the handler chain.
6635 __ movq(kScratchRegister, ExternalReference(Top::k_handler_address)); 6659 __ movq(kScratchRegister, ExternalReference(Top::k_handler_address));
6636 __ pop(Operand(kScratchRegister, 0)); 6660 __ pop(Operand(kScratchRegister, 0));
6637 // Pop next_sp. 6661 // Pop next_sp.
6638 __ addq(rsp, Immediate(StackHandlerConstants::kSize - kPointerSize)); 6662 __ addq(rsp, Immediate(StackHandlerConstants::kSize - kPointerSize));
6639 6663
6664 #ifdef ENABLE_LOGGING_AND_PROFILING
6665 // If current EBP value is the same as js_entry_sp value, it means that
6666 // the current function is the outermost.
6667 __ movq(kScratchRegister, js_entry_sp);
6668 __ cmpq(rbp, Operand(kScratchRegister, 0));
6669 __ j(NegateCondition(equal), &not_outermost_js_2);
6670 __ movq(Operand(kScratchRegister, 0), Immediate(0));
6671 __ bind(&not_outermost_js_2);
6672 #endif
6673
6640 // Restore the top frame descriptor from the stack. 6674 // Restore the top frame descriptor from the stack.
6641 __ bind(&exit); 6675 __ bind(&exit);
6642 __ movq(kScratchRegister, ExternalReference(Top::k_c_entry_fp_address)); 6676 __ movq(kScratchRegister, ExternalReference(Top::k_c_entry_fp_address));
6643 __ pop(Operand(kScratchRegister, 0)); 6677 __ pop(Operand(kScratchRegister, 0));
6644 6678
6645 // Restore callee-saved registers (X64 conventions). 6679 // Restore callee-saved registers (X64 conventions).
6646 __ pop(rbx); 6680 __ pop(rbx);
6647 __ pop(rsi); 6681 __ pop(rsi);
6648 __ pop(rdi); 6682 __ pop(rdi);
6649 __ pop(r15); 6683 __ pop(r15);
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
7221 int CompareStub::MinorKey() { 7255 int CompareStub::MinorKey() {
7222 // Encode the two parameters in a unique 16 bit value. 7256 // Encode the two parameters in a unique 16 bit value.
7223 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); 7257 ASSERT(static_cast<unsigned>(cc_) < (1 << 15));
7224 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); 7258 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0);
7225 } 7259 }
7226 7260
7227 7261
7228 #undef __ 7262 #undef __
7229 7263
7230 } } // namespace v8::internal 7264 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/codegen-x64.h ('k') | test/cctest/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698