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

Side by Side Diff: src/deoptimizer.cc

Issue 11637036: Refactoring only: Extracted a method for finding optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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 | « no previous file | no next file » | 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 470 }
471 #endif 471 #endif
472 } 472 }
473 473
474 474
475 void Deoptimizer::ComputeOutputFrames(Deoptimizer* deoptimizer) { 475 void Deoptimizer::ComputeOutputFrames(Deoptimizer* deoptimizer) {
476 deoptimizer->DoComputeOutputFrames(); 476 deoptimizer->DoComputeOutputFrames();
477 } 477 }
478 478
479 479
480 static Code* FindOptimizedCode(Isolate* isolate,
481 JSFunction* function,
482 Deoptimizer::BailoutType type,
483 Address from,
484 Code* optimized_code) {
485 switch (type) {
486 case Deoptimizer::EAGER:
487 ASSERT(from == NULL);
488 return function->code();
489 case Deoptimizer::LAZY: {
490 Code* compiled_code =
491 isolate->deoptimizer_data()->FindDeoptimizingCode(from);
492 return (compiled_code == NULL)
493 ? static_cast<Code*>(isolate->heap()->FindCodeObject(from))
494 : compiled_code;
495 }
496 case Deoptimizer::OSR: {
497 // The function has already been optimized and we're transitioning
498 // from the unoptimized shared version to the optimized one in the
499 // function. The return address (from) points to unoptimized code.
500 Code* compiled_code = function->code();
501 ASSERT(compiled_code->kind() == Code::OPTIMIZED_FUNCTION);
502 ASSERT(!compiled_code->contains(from));
503 return compiled_code;
504 }
505 case Deoptimizer::DEBUGGER:
506 ASSERT(optimized_code->contains(from));
507 return optimized_code;
508 }
509 UNREACHABLE();
510 return NULL;
511 }
512
513
480 Deoptimizer::Deoptimizer(Isolate* isolate, 514 Deoptimizer::Deoptimizer(Isolate* isolate,
481 JSFunction* function, 515 JSFunction* function,
482 BailoutType type, 516 BailoutType type,
483 unsigned bailout_id, 517 unsigned bailout_id,
484 Address from, 518 Address from,
485 int fp_to_sp_delta, 519 int fp_to_sp_delta,
486 Code* optimized_code) 520 Code* optimized_code)
487 : isolate_(isolate), 521 : isolate_(isolate),
488 function_(function), 522 function_(function),
489 bailout_id_(bailout_id), 523 bailout_id_(bailout_id),
(...skipping 28 matching lines...) Expand all
518 fp_to_sp_delta - (2 * kPointerSize)); 552 fp_to_sp_delta - (2 * kPointerSize));
519 } 553 }
520 // For COMPILED_STUBs called from builtins, the function pointer 554 // For COMPILED_STUBs called from builtins, the function pointer
521 // is a SMI indicating an internal frame. 555 // is a SMI indicating an internal frame.
522 if (function->IsSmi()) { 556 if (function->IsSmi()) {
523 function = NULL; 557 function = NULL;
524 } 558 }
525 if (function != NULL && function->IsOptimized()) { 559 if (function != NULL && function->IsOptimized()) {
526 function->shared()->increment_deopt_count(); 560 function->shared()->increment_deopt_count();
527 } 561 }
528 // Find the optimized code. 562 compiled_code_ =
529 if (type == EAGER) { 563 FindOptimizedCode(isolate, function, type, from, optimized_code);
530 ASSERT(from == NULL); 564 if (FLAG_trace_deopt && type == EAGER) {
531 compiled_code_ = function_->code(); 565 compiled_code_->PrintDeoptLocation(bailout_id);
532 if (FLAG_trace_deopt) compiled_code_->PrintDeoptLocation(bailout_id);
533 } else if (type == LAZY) {
534 compiled_code_ = isolate->deoptimizer_data()->FindDeoptimizingCode(from);
535 if (compiled_code_ == NULL) {
536 compiled_code_ =
537 static_cast<Code*>(isolate->heap()->FindCodeObject(from));
538 }
539 ASSERT(compiled_code_ != NULL);
540 } else if (type == OSR) {
541 // The function has already been optimized and we're transitioning
542 // from the unoptimized shared version to the optimized one in the
543 // function. The return address (from) points to unoptimized code.
544 compiled_code_ = function_->code();
545 ASSERT(compiled_code_->kind() == Code::OPTIMIZED_FUNCTION);
546 ASSERT(!compiled_code_->contains(from));
547 } else if (type == DEBUGGER) {
548 compiled_code_ = optimized_code;
549 ASSERT(compiled_code_->contains(from));
550 } 566 }
551 ASSERT(HEAP->allow_allocation(false)); 567 ASSERT(HEAP->allow_allocation(false));
552 unsigned size = ComputeInputFrameSize(); 568 unsigned size = ComputeInputFrameSize();
553 input_ = new(size) FrameDescription(size, function); 569 input_ = new(size) FrameDescription(size, function);
554 input_->SetFrameType(StackFrame::JAVA_SCRIPT); 570 input_->SetFrameType(StackFrame::JAVA_SCRIPT);
555 } 571 }
556 572
557 573
558 Deoptimizer::~Deoptimizer() { 574 Deoptimizer::~Deoptimizer() {
559 ASSERT(input_ == NULL && output_ == NULL); 575 ASSERT(input_ == NULL && output_ == NULL);
(...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 2087
2072 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { 2088 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) {
2073 v->VisitPointer(BitCast<Object**>(&function_)); 2089 v->VisitPointer(BitCast<Object**>(&function_));
2074 v->VisitPointers(parameters_, parameters_ + parameters_count_); 2090 v->VisitPointers(parameters_, parameters_ + parameters_count_);
2075 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); 2091 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_);
2076 } 2092 }
2077 2093
2078 #endif // ENABLE_DEBUGGER_SUPPORT 2094 #endif // ENABLE_DEBUGGER_SUPPORT
2079 2095
2080 } } // namespace v8::internal 2096 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698