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

Side by Side Diff: src/frames.cc

Issue 9401019: Support for return-address rewriting profilers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add inline specifier for ResolveReturnAddressLocation. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « src/frames.h ('k') | src/v8.h » ('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 // 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 23 matching lines...) Expand all
34 #include "mark-compact.h" 34 #include "mark-compact.h"
35 #include "safepoint-table.h" 35 #include "safepoint-table.h"
36 #include "scopeinfo.h" 36 #include "scopeinfo.h"
37 #include "string-stream.h" 37 #include "string-stream.h"
38 38
39 #include "allocation-inl.h" 39 #include "allocation-inl.h"
40 40
41 namespace v8 { 41 namespace v8 {
42 namespace internal { 42 namespace internal {
43 43
44
45 static ReturnAddressLocationResolver return_address_location_resolver = NULL;
46
47
48 // Resolves pc_address through the resolution address function if one is set.
49 static inline Address* ResolveReturnAddressLocation(Address* pc_address) {
50 if (return_address_location_resolver == NULL) {
51 return pc_address;
52 } else {
53 return reinterpret_cast<Address*>(
54 return_address_location_resolver(
55 reinterpret_cast<uintptr_t>(pc_address)));
56 }
57 }
58
59
44 // Iterator that supports traversing the stack handlers of a 60 // Iterator that supports traversing the stack handlers of a
45 // particular frame. Needs to know the top of the handler chain. 61 // particular frame. Needs to know the top of the handler chain.
46 class StackHandlerIterator BASE_EMBEDDED { 62 class StackHandlerIterator BASE_EMBEDDED {
47 public: 63 public:
48 StackHandlerIterator(const StackFrame* frame, StackHandler* handler) 64 StackHandlerIterator(const StackFrame* frame, StackHandler* handler)
49 : limit_(frame->fp()), handler_(handler) { 65 : limit_(frame->fp()), handler_(handler) {
50 // Make sure the handler has already been unwound to this frame. 66 // Make sure the handler has already been unwound to this frame.
51 ASSERT(frame->sp() <= handler->address()); 67 ASSERT(frame->sp() <= handler->address());
52 } 68 }
53 69
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 StackFrame::Type type; 164 StackFrame::Type type;
149 if (thread_ != NULL) { 165 if (thread_ != NULL) {
150 type = ExitFrame::GetStateForFramePointer( 166 type = ExitFrame::GetStateForFramePointer(
151 Isolate::c_entry_fp(thread_), &state); 167 Isolate::c_entry_fp(thread_), &state);
152 handler_ = StackHandler::FromAddress( 168 handler_ = StackHandler::FromAddress(
153 Isolate::handler(thread_)); 169 Isolate::handler(thread_));
154 } else { 170 } else {
155 ASSERT(fp_ != NULL); 171 ASSERT(fp_ != NULL);
156 state.fp = fp_; 172 state.fp = fp_;
157 state.sp = sp_; 173 state.sp = sp_;
158 state.pc_address = 174 state.pc_address = ResolveReturnAddressLocation(
159 reinterpret_cast<Address*>(StandardFrame::ComputePCAddress(fp_)); 175 reinterpret_cast<Address*>(StandardFrame::ComputePCAddress(fp_)));
160 type = StackFrame::ComputeType(isolate(), &state); 176 type = StackFrame::ComputeType(isolate(), &state);
161 } 177 }
162 if (SingletonFor(type) == NULL) return; 178 if (SingletonFor(type) == NULL) return;
163 frame_ = SingletonFor(type, &state); 179 frame_ = SingletonFor(type, &state);
164 } 180 }
165 181
166 182
167 StackFrame* StackFrameIterator::SingletonFor(StackFrame::Type type, 183 StackFrame* StackFrameIterator::SingletonFor(StackFrame::Type type,
168 StackFrame::State* state) { 184 StackFrame::State* state) {
169 if (type == StackFrame::NONE) return NULL; 185 if (type == StackFrame::NONE) return NULL;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 Object* code = holder; 423 Object* code = holder;
408 v->VisitPointer(&code); 424 v->VisitPointer(&code);
409 if (code != holder) { 425 if (code != holder) {
410 holder = reinterpret_cast<Code*>(code); 426 holder = reinterpret_cast<Code*>(code);
411 pc = holder->instruction_start() + pc_offset; 427 pc = holder->instruction_start() + pc_offset;
412 *pc_address = pc; 428 *pc_address = pc;
413 } 429 }
414 } 430 }
415 431
416 432
433 void StackFrame::SetReturnAddressLocationResolver(
434 ReturnAddressLocationResolver resolver) {
435 ASSERT(return_address_location_resolver == NULL);
436 return_address_location_resolver = resolver;
437 }
438
439
417 StackFrame::Type StackFrame::ComputeType(Isolate* isolate, State* state) { 440 StackFrame::Type StackFrame::ComputeType(Isolate* isolate, State* state) {
418 ASSERT(state->fp != NULL); 441 ASSERT(state->fp != NULL);
419 if (StandardFrame::IsArgumentsAdaptorFrame(state->fp)) { 442 if (StandardFrame::IsArgumentsAdaptorFrame(state->fp)) {
420 return ARGUMENTS_ADAPTOR; 443 return ARGUMENTS_ADAPTOR;
421 } 444 }
422 // The marker and function offsets overlap. If the marker isn't a 445 // The marker and function offsets overlap. If the marker isn't a
423 // smi then the frame is a JavaScript frame -- and the marker is 446 // smi then the frame is a JavaScript frame -- and the marker is
424 // really the function. 447 // really the function.
425 const int offset = StandardFrameConstants::kMarkerOffset; 448 const int offset = StandardFrameConstants::kMarkerOffset;
426 Object* marker = Memory::Object_at(state->fp + offset); 449 Object* marker = Memory::Object_at(state->fp + offset);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 504
482 Code* ExitFrame::unchecked_code() const { 505 Code* ExitFrame::unchecked_code() const {
483 return reinterpret_cast<Code*>(code_slot()); 506 return reinterpret_cast<Code*>(code_slot());
484 } 507 }
485 508
486 509
487 void ExitFrame::ComputeCallerState(State* state) const { 510 void ExitFrame::ComputeCallerState(State* state) const {
488 // Set up the caller state. 511 // Set up the caller state.
489 state->sp = caller_sp(); 512 state->sp = caller_sp();
490 state->fp = Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset); 513 state->fp = Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset);
491 state->pc_address 514 state->pc_address = ResolveReturnAddressLocation(
492 = reinterpret_cast<Address*>(fp() + ExitFrameConstants::kCallerPCOffset); 515 reinterpret_cast<Address*>(fp() + ExitFrameConstants::kCallerPCOffset));
493 } 516 }
494 517
495 518
496 void ExitFrame::SetCallerFp(Address caller_fp) { 519 void ExitFrame::SetCallerFp(Address caller_fp) {
497 Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset) = caller_fp; 520 Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset) = caller_fp;
498 } 521 }
499 522
500 523
501 void ExitFrame::Iterate(ObjectVisitor* v) const { 524 void ExitFrame::Iterate(ObjectVisitor* v) const {
502 // The arguments are traversed as part of the expression stack of 525 // The arguments are traversed as part of the expression stack of
(...skipping 13 matching lines...) Expand all
516 Address sp = ComputeStackPointer(fp); 539 Address sp = ComputeStackPointer(fp);
517 FillState(fp, sp, state); 540 FillState(fp, sp, state);
518 ASSERT(*state->pc_address != NULL); 541 ASSERT(*state->pc_address != NULL);
519 return EXIT; 542 return EXIT;
520 } 543 }
521 544
522 545
523 void ExitFrame::FillState(Address fp, Address sp, State* state) { 546 void ExitFrame::FillState(Address fp, Address sp, State* state) {
524 state->sp = sp; 547 state->sp = sp;
525 state->fp = fp; 548 state->fp = fp;
526 state->pc_address = reinterpret_cast<Address*>(sp - 1 * kPointerSize); 549 state->pc_address = ResolveReturnAddressLocation(
550 reinterpret_cast<Address*>(sp - 1 * kPointerSize));
527 } 551 }
528 552
529 553
530 Address StandardFrame::GetExpressionAddress(int n) const { 554 Address StandardFrame::GetExpressionAddress(int n) const {
531 const int offset = StandardFrameConstants::kExpressionsOffset; 555 const int offset = StandardFrameConstants::kExpressionsOffset;
532 return fp() + offset - n * kPointerSize; 556 return fp() + offset - n * kPointerSize;
533 } 557 }
534 558
535 559
536 Object* StandardFrame::GetExpression(Address fp, int index) { 560 Object* StandardFrame::GetExpression(Address fp, int index) {
(...skipping 14 matching lines...) Expand all
551 Address limit = sp(); 575 Address limit = sp();
552 ASSERT(base >= limit); // stack grows downwards 576 ASSERT(base >= limit); // stack grows downwards
553 // Include register-allocated locals in number of expressions. 577 // Include register-allocated locals in number of expressions.
554 return static_cast<int>((base - limit) / kPointerSize); 578 return static_cast<int>((base - limit) / kPointerSize);
555 } 579 }
556 580
557 581
558 void StandardFrame::ComputeCallerState(State* state) const { 582 void StandardFrame::ComputeCallerState(State* state) const {
559 state->sp = caller_sp(); 583 state->sp = caller_sp();
560 state->fp = caller_fp(); 584 state->fp = caller_fp();
561 state->pc_address = reinterpret_cast<Address*>(ComputePCAddress(fp())); 585 state->pc_address = ResolveReturnAddressLocation(
586 reinterpret_cast<Address*>(ComputePCAddress(fp())));
562 } 587 }
563 588
564 589
565 void StandardFrame::SetCallerFp(Address caller_fp) { 590 void StandardFrame::SetCallerFp(Address caller_fp) {
566 Memory::Address_at(fp() + StandardFrameConstants::kCallerFPOffset) = 591 Memory::Address_at(fp() + StandardFrameConstants::kCallerFPOffset) =
567 caller_fp; 592 caller_fp;
568 } 593 }
569 594
570 595
571 bool StandardFrame::IsExpressionInsideHandler(int n) const { 596 bool StandardFrame::IsExpressionInsideHandler(int n) const {
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 ZoneList<StackFrame*> list(10); 1415 ZoneList<StackFrame*> list(10);
1391 for (StackFrameIterator it; !it.done(); it.Advance()) { 1416 for (StackFrameIterator it; !it.done(); it.Advance()) {
1392 StackFrame* frame = AllocateFrameCopy(it.frame()); 1417 StackFrame* frame = AllocateFrameCopy(it.frame());
1393 list.Add(frame); 1418 list.Add(frame);
1394 } 1419 }
1395 return list.ToVector(); 1420 return list.ToVector();
1396 } 1421 }
1397 1422
1398 1423
1399 } } // namespace v8::internal 1424 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/frames.h ('k') | src/v8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698