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

Side by Side Diff: src/heap/objects-visiting-inl.h

Issue 1482363002: [heap] JSFunction::context always points to valid context. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« 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 // 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 #ifndef V8_OBJECTS_VISITING_INL_H_ 5 #ifndef V8_OBJECTS_VISITING_INL_H_
6 #define V8_OBJECTS_VISITING_INL_H_ 6 #define V8_OBJECTS_VISITING_INL_H_
7 7
8 #include "src/heap/array-buffer-tracker.h" 8 #include "src/heap/array-buffer-tracker.h"
9 #include "src/heap/objects-visiting.h" 9 #include "src/heap/objects-visiting.h"
10 #include "src/ic/ic-state.h" 10 #include "src/ic/ic-state.h"
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 FixedArray* const literals = data->LiteralArray(); 596 FixedArray* const literals = data->LiteralArray();
597 int const inlined_count = data->InlinedFunctionCount()->value(); 597 int const inlined_count = data->InlinedFunctionCount()->value();
598 for (int i = 0; i < inlined_count; ++i) { 598 for (int i = 0; i < inlined_count; ++i) {
599 StaticVisitor::MarkObject( 599 StaticVisitor::MarkObject(
600 heap, SharedFunctionInfo::cast(literals->get(i))->code()); 600 heap, SharedFunctionInfo::cast(literals->get(i))->code());
601 } 601 }
602 } 602 }
603 } 603 }
604 604
605 605
606 inline static bool HasValidNonBuiltinContext(JSFunction* function) {
607 return function->context()->IsContext() && !function->shared()->IsBuiltin();
608 }
609
610
611 inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) { 606 inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) {
612 Object* undefined = heap->undefined_value(); 607 Object* undefined = heap->undefined_value();
613 return (info->script() != undefined) && 608 return (info->script() != undefined) &&
614 (reinterpret_cast<Script*>(info->script())->source() != undefined); 609 (reinterpret_cast<Script*>(info->script())->source() != undefined);
615 } 610 }
616 611
617 612
618 template <typename StaticVisitor> 613 template <typename StaticVisitor>
619 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable(Heap* heap, 614 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable(Heap* heap,
620 JSFunction* function) { 615 JSFunction* function) {
621 SharedFunctionInfo* shared_info = function->shared(); 616 SharedFunctionInfo* shared_info = function->shared();
622 617
623 // Code is either on stack, in compilation cache or referenced 618 // Code is either on stack, in compilation cache or referenced
624 // by optimized version of function. 619 // by optimized version of function.
625 MarkBit code_mark = Marking::MarkBitFrom(function->code()); 620 MarkBit code_mark = Marking::MarkBitFrom(function->code());
626 if (Marking::IsBlackOrGrey(code_mark)) { 621 if (Marking::IsBlackOrGrey(code_mark)) {
627 return false; 622 return false;
628 } 623 }
629 624
630 // The function must have a valid context and not be a builtin.
631 if (!HasValidNonBuiltinContext(function)) {
632 return false;
633 }
634
635 // We do not (yet) flush code for optimized functions. 625 // We do not (yet) flush code for optimized functions.
636 if (function->code() != shared_info->code()) { 626 if (function->code() != shared_info->code()) {
637 return false; 627 return false;
638 } 628 }
639 629
640 // Check age of optimized code. 630 // Check age of optimized code.
641 if (FLAG_age_code && !function->code()->IsOld()) { 631 if (FLAG_age_code && !function->code()->IsOld()) {
642 return false; 632 return false;
643 } 633 }
644 634
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 // if there are still live activations (generator objects) on the heap. 672 // if there are still live activations (generator objects) on the heap.
683 if (shared_info->is_generator()) { 673 if (shared_info->is_generator()) {
684 return false; 674 return false;
685 } 675 }
686 676
687 // If this is a full script wrapped in a function we do not flush the code. 677 // If this is a full script wrapped in a function we do not flush the code.
688 if (shared_info->is_toplevel()) { 678 if (shared_info->is_toplevel()) {
689 return false; 679 return false;
690 } 680 }
691 681
682 // The function must not be a builtin.
683 if (shared_info->IsBuiltin()) {
684 return false;
685 }
686
692 // If this is a function initialized with %SetCode then the one-to-one 687 // If this is a function initialized with %SetCode then the one-to-one
693 // relation between SharedFunctionInfo and Code is broken. 688 // relation between SharedFunctionInfo and Code is broken.
694 if (shared_info->dont_flush()) { 689 if (shared_info->dont_flush()) {
695 return false; 690 return false;
696 } 691 }
697 692
698 // Check age of code. If code aging is disabled we never flush. 693 // Check age of code. If code aging is disabled we never flush.
699 if (!FLAG_age_code || !shared_info->code()->IsOld()) { 694 if (!FLAG_age_code || !shared_info->code()->IsOld()) {
700 return false; 695 return false;
701 } 696 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, 747 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode,
753 void> JSFunctionWeakCodeBodyVisitor; 748 void> JSFunctionWeakCodeBodyVisitor;
754 JSFunctionWeakCodeBodyVisitor::Visit(map, object); 749 JSFunctionWeakCodeBodyVisitor::Visit(map, object);
755 } 750 }
756 751
757 752
758 } // namespace internal 753 } // namespace internal
759 } // namespace v8 754 } // namespace v8
760 755
761 #endif // V8_OBJECTS_VISITING_INL_H_ 756 #endif // V8_OBJECTS_VISITING_INL_H_
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