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

Side by Side Diff: src/deoptimizer.h

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/debug-agent.cc ('k') | src/deoptimizer.cc » ('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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // Array of output frame descriptions. 428 // Array of output frame descriptions.
429 FrameDescription** output_; 429 FrameDescription** output_;
430 430
431 // Deferred values to be materialized. 431 // Deferred values to be materialized.
432 List<Object*> deferred_objects_tagged_values_; 432 List<Object*> deferred_objects_tagged_values_;
433 List<HeapNumberMaterializationDescriptor<int> > 433 List<HeapNumberMaterializationDescriptor<int> >
434 deferred_objects_double_values_; 434 deferred_objects_double_values_;
435 List<ObjectMaterializationDescriptor> deferred_objects_; 435 List<ObjectMaterializationDescriptor> deferred_objects_;
436 List<HeapNumberMaterializationDescriptor<Address> > deferred_heap_numbers_; 436 List<HeapNumberMaterializationDescriptor<Address> > deferred_heap_numbers_;
437 437
438 // Key for lookup of previously materialized objects
439 Address stack_fp_;
440 Handle<FixedArray> previously_materialized_objects_;
441 int prev_materialized_count_;
442
438 // Output frame information. Only used during heap object materialization. 443 // Output frame information. Only used during heap object materialization.
439 List<Handle<JSFunction> > jsframe_functions_; 444 List<Handle<JSFunction> > jsframe_functions_;
440 List<bool> jsframe_has_adapted_arguments_; 445 List<bool> jsframe_has_adapted_arguments_;
441 446
442 // Materialized objects. Only used during heap object materialization. 447 // Materialized objects. Only used during heap object materialization.
443 List<Handle<Object> >* materialized_values_; 448 List<Handle<Object> >* materialized_values_;
444 List<Handle<Object> >* materialized_objects_; 449 List<Handle<Object> >* materialized_objects_;
445 int materialization_value_index_; 450 int materialization_value_index_;
446 int materialization_object_index_; 451 int materialization_object_index_;
447 452
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 781
777 782
778 class SlotRef BASE_EMBEDDED { 783 class SlotRef BASE_EMBEDDED {
779 public: 784 public:
780 enum SlotRepresentation { 785 enum SlotRepresentation {
781 UNKNOWN, 786 UNKNOWN,
782 TAGGED, 787 TAGGED,
783 INT32, 788 INT32,
784 UINT32, 789 UINT32,
785 DOUBLE, 790 DOUBLE,
786 LITERAL 791 LITERAL,
792 DEFERRED_OBJECT, // Object captured by the escape analysis.
793 // The number of nested objects can be obtained
794 // with the DeferredObjectLength() method
795 // (the SlotRefs of the nested objects follow
796 // this SlotRef in the depth-first order.)
797 DUPLICATE_OBJECT, // Duplicated object of a deferred object.
798 ARGUMENTS_OBJECT // Arguments object - only used to keep indexing
799 // in sync, it should not be materialized.
787 }; 800 };
788 801
789 SlotRef() 802 SlotRef()
790 : addr_(NULL), representation_(UNKNOWN) { } 803 : addr_(NULL), representation_(UNKNOWN) { }
791 804
792 SlotRef(Address addr, SlotRepresentation representation) 805 SlotRef(Address addr, SlotRepresentation representation)
793 : addr_(addr), representation_(representation) { } 806 : addr_(addr), representation_(representation) { }
794 807
795 SlotRef(Isolate* isolate, Object* literal) 808 SlotRef(Isolate* isolate, Object* literal)
796 : literal_(literal, isolate), representation_(LITERAL) { } 809 : literal_(literal, isolate), representation_(LITERAL) { }
797 810
798 Handle<Object> GetValue(Isolate* isolate) { 811 static SlotRef NewArgumentsObject(int length) {
799 switch (representation_) { 812 SlotRef slot;
800 case TAGGED: 813 slot.representation_ = ARGUMENTS_OBJECT;
801 return Handle<Object>(Memory::Object_at(addr_), isolate); 814 slot.deferred_object_length_ = length;
815 return slot;
816 }
802 817
803 case INT32: { 818 static SlotRef NewDeferredObject(int length) {
804 int value = Memory::int32_at(addr_); 819 SlotRef slot;
805 if (Smi::IsValid(value)) { 820 slot.representation_ = DEFERRED_OBJECT;
806 return Handle<Object>(Smi::FromInt(value), isolate); 821 slot.deferred_object_length_ = length;
807 } else { 822 return slot;
808 return isolate->factory()->NewNumberFromInt(value); 823 }
809 }
810 }
811 824
812 case UINT32: { 825 SlotRepresentation Representation() { return representation_; }
813 uint32_t value = Memory::uint32_at(addr_);
814 if (value <= static_cast<uint32_t>(Smi::kMaxValue)) {
815 return Handle<Object>(Smi::FromInt(static_cast<int>(value)), isolate);
816 } else {
817 return isolate->factory()->NewNumber(static_cast<double>(value));
818 }
819 }
820 826
821 case DOUBLE: { 827 static SlotRef NewDuplicateObject(int id) {
822 double value = read_double_value(addr_); 828 SlotRef slot;
823 return isolate->factory()->NewNumber(value); 829 slot.representation_ = DUPLICATE_OBJECT;
824 } 830 slot.duplicate_object_id_ = id;
831 return slot;
832 }
825 833
826 case LITERAL: 834 int GetChildrenCount() {
827 return literal_; 835 if (representation_ == DEFERRED_OBJECT ||
828 836 representation_ == ARGUMENTS_OBJECT) {
829 default: 837 return deferred_object_length_;
830 UNREACHABLE(); 838 } else {
831 return Handle<Object>::null(); 839 return 0;
832 } 840 }
833 } 841 }
834 842
835 static Vector<SlotRef> ComputeSlotMappingForArguments( 843 int DuplicateObjectId() { return duplicate_object_id_; }
836 JavaScriptFrame* frame, 844
837 int inlined_frame_index, 845 Handle<Object> GetValue(Isolate* isolate);
838 int formal_parameter_count);
839 846
840 private: 847 private:
841 Address addr_; 848 Address addr_;
842 Handle<Object> literal_; 849 Handle<Object> literal_;
843 SlotRepresentation representation_; 850 SlotRepresentation representation_;
851 int deferred_object_length_;
852 int duplicate_object_id_;
853 };
854
855 class SlotRefValueBuilder BASE_EMBEDDED {
856 public:
857 SlotRefValueBuilder(
858 JavaScriptFrame* frame,
859 int inlined_frame_index,
860 int formal_parameter_count);
861
862 void Prepare(Isolate* isolate);
863 Handle<Object> GetNext(Isolate* isolate, int level);
864 void Finish(Isolate* isolate);
865
866 int args_length() { return args_length_; }
867
868 private:
869 List<Handle<Object> > materialized_objects_;
870 Handle<FixedArray> previously_materialized_objects_;
871 int prev_materialized_count_;
872 Address stack_frame_id_;
873 List<SlotRef> slot_refs_;
874 int current_slot_;
875 int args_length_;
876 int first_slot_index_;
877
878 static SlotRef ComputeSlotForNextArgument(
879 Translation::Opcode opcode,
880 TranslationIterator* iterator,
881 DeoptimizationInputData* data,
882 JavaScriptFrame* frame);
883
884 Handle<Object> GetPreviouslyMaterialized(Isolate* isolate, int length);
844 885
845 static Address SlotAddress(JavaScriptFrame* frame, int slot_index) { 886 static Address SlotAddress(JavaScriptFrame* frame, int slot_index) {
846 if (slot_index >= 0) { 887 if (slot_index >= 0) {
847 const int offset = JavaScriptFrameConstants::kLocal0Offset; 888 const int offset = JavaScriptFrameConstants::kLocal0Offset;
848 return frame->fp() + offset - (slot_index * kPointerSize); 889 return frame->fp() + offset - (slot_index * kPointerSize);
849 } else { 890 } else {
850 const int offset = JavaScriptFrameConstants::kLastParameterOffset; 891 const int offset = JavaScriptFrameConstants::kLastParameterOffset;
851 return frame->fp() + offset - ((slot_index + 1) * kPointerSize); 892 return frame->fp() + offset - ((slot_index + 1) * kPointerSize);
852 } 893 }
853 } 894 }
854 895
855 static SlotRef ComputeSlotForNextArgument(TranslationIterator* iterator, 896 Handle<Object> GetDeferredObject(Isolate* isolate);
856 DeoptimizationInputData* data, 897 };
857 JavaScriptFrame* frame);
858 898
859 static void ComputeSlotsForArguments( 899 class MaterializedObjectStore {
860 Vector<SlotRef>* args_slots, 900 public:
861 TranslationIterator* iterator, 901 explicit MaterializedObjectStore(Isolate* isolate) : isolate_(isolate) {
862 DeoptimizationInputData* data, 902 }
863 JavaScriptFrame* frame); 903
904 Handle<FixedArray> Get(Address fp);
905 void Set(Address fp, Handle<FixedArray> materialized_objects);
906 void Remove(Address fp);
907
908 private:
909 Isolate* isolate() { return isolate_; }
910 Handle<FixedArray> GetStackEntries();
911 Handle<FixedArray> EnsureStackEntries(int size);
912
913 int StackIdToIndex(Address fp);
914
915 Isolate* isolate_;
916 List<Address> frame_fps_;
864 }; 917 };
865 918
866 919
867 #ifdef ENABLE_DEBUGGER_SUPPORT 920 #ifdef ENABLE_DEBUGGER_SUPPORT
868 // Class used to represent an unoptimized frame when the debugger 921 // Class used to represent an unoptimized frame when the debugger
869 // needs to inspect a frame that is part of an optimized frame. The 922 // needs to inspect a frame that is part of an optimized frame. The
870 // internally used FrameDescription objects are not GC safe so for use 923 // internally used FrameDescription objects are not GC safe so for use
871 // by the debugger frame information is copied to an object of this type. 924 // by the debugger frame information is copied to an object of this type.
872 // Represents parameters in unadapted form so their number might mismatch 925 // Represents parameters in unadapted form so their number might mismatch
873 // formal parameter count. 926 // formal parameter count.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 Object** expression_stack_; 989 Object** expression_stack_;
937 int source_position_; 990 int source_position_;
938 991
939 friend class Deoptimizer; 992 friend class Deoptimizer;
940 }; 993 };
941 #endif 994 #endif
942 995
943 } } // namespace v8::internal 996 } } // namespace v8::internal
944 997
945 #endif // V8_DEOPTIMIZER_H_ 998 #endif // V8_DEOPTIMIZER_H_
OLDNEW
« no previous file with comments | « src/debug-agent.cc ('k') | src/deoptimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698