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

Side by Side Diff: src/deoptimizer.h

Issue 103243005: Captured arguments object materialization (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed code review comments Created 6 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
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,
danno 2014/01/28 15:44:34 Perhaps a short comment for these is warranted?
Jarin 2014/01/28 19:52:30 Done.
793 DUPLICATE_OBJECT
787 }; 794 };
788 795
789 SlotRef() 796 SlotRef()
790 : addr_(NULL), representation_(UNKNOWN) { } 797 : addr_(NULL), representation_(UNKNOWN) { }
791 798
792 SlotRef(Address addr, SlotRepresentation representation) 799 SlotRef(Address addr, SlotRepresentation representation)
793 : addr_(addr), representation_(representation) { } 800 : addr_(addr), representation_(representation) { }
794 801
795 SlotRef(Isolate* isolate, Object* literal) 802 SlotRef(Isolate* isolate, Object* literal)
796 : literal_(literal, isolate), representation_(LITERAL) { } 803 : literal_(literal, isolate), representation_(LITERAL) { }
797 804
798 Handle<Object> GetValue(Isolate* isolate) { 805 static SlotRef NewDeferredObject(int length) {
799 switch (representation_) { 806 SlotRef slot;
800 case TAGGED: 807 slot.representation_ = DEFERRED_OBJECT;
801 return Handle<Object>(Memory::Object_at(addr_), isolate); 808 slot.deferred_object_length_ = length;
802 809 return slot;
803 case INT32: {
804 int value = Memory::int32_at(addr_);
805 if (Smi::IsValid(value)) {
806 return Handle<Object>(Smi::FromInt(value), isolate);
807 } else {
808 return isolate->factory()->NewNumberFromInt(value);
809 }
810 }
811
812 case UINT32: {
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
821 case DOUBLE: {
822 double value = read_double_value(addr_);
823 return isolate->factory()->NewNumber(value);
824 }
825
826 case LITERAL:
827 return literal_;
828
829 default:
830 UNREACHABLE();
831 return Handle<Object>::null();
832 }
833 } 810 }
834 811
835 static Vector<SlotRef> ComputeSlotMappingForArguments( 812 SlotRepresentation Representation() { return representation_; }
836 JavaScriptFrame* frame, 813
837 int inlined_frame_index, 814 static SlotRef NewDuplicateObject(int id) {
838 int formal_parameter_count); 815 SlotRef slot;
816 slot.representation_ = DUPLICATE_OBJECT;
817 slot.duplicate_object_id_ = id;
818 return slot;
819 }
820
821 int DeferredObjectLength() { return deferred_object_length_; }
822
823 int DuplicateObjectId() { return duplicate_object_id_; }
824
825 Handle<Object> GetValue(Isolate* isolate);
839 826
840 private: 827 private:
841 Address addr_; 828 Address addr_;
842 Handle<Object> literal_; 829 Handle<Object> literal_;
843 SlotRepresentation representation_; 830 SlotRepresentation representation_;
831 int deferred_object_length_;
832 int duplicate_object_id_;
833 };
834
835 class SlotRefValueBuilder BASE_EMBEDDED {
836 public:
837 SlotRefValueBuilder(
838 JavaScriptFrame* frame,
839 int inlined_frame_index,
840 int formal_parameter_count);
841
842 void Prepare(Isolate* isolate);
843 Handle<Object> GetNext(Isolate* isolate, int level);
844 void Finish(Isolate* isolate);
845
846 int args_length() { return args_length_; }
847
848 private:
849 List<Handle<Object> > materialized_objects_;
850 Handle<FixedArray> previously_materialized_objects_;
851 int prev_materialized_count_;
852 Address stack_frame_id_;
853 List<SlotRef> slot_refs_;
854 int current_slot_;
855 int args_length_;
856 int first_slot_index_;
857
858 static SlotRef ComputeSlotForNextArgument(
859 Translation::Opcode opcode,
860 TranslationIterator* iterator,
861 DeoptimizationInputData* data,
862 JavaScriptFrame* frame);
863
864 Handle<Object> GetPreviouslyMaterialized(Isolate* isolate, int length);
844 865
845 static Address SlotAddress(JavaScriptFrame* frame, int slot_index) { 866 static Address SlotAddress(JavaScriptFrame* frame, int slot_index) {
846 if (slot_index >= 0) { 867 if (slot_index >= 0) {
847 const int offset = JavaScriptFrameConstants::kLocal0Offset; 868 const int offset = JavaScriptFrameConstants::kLocal0Offset;
848 return frame->fp() + offset - (slot_index * kPointerSize); 869 return frame->fp() + offset - (slot_index * kPointerSize);
849 } else { 870 } else {
850 const int offset = JavaScriptFrameConstants::kLastParameterOffset; 871 const int offset = JavaScriptFrameConstants::kLastParameterOffset;
851 return frame->fp() + offset - ((slot_index + 1) * kPointerSize); 872 return frame->fp() + offset - ((slot_index + 1) * kPointerSize);
852 } 873 }
853 } 874 }
854 875
855 static SlotRef ComputeSlotForNextArgument(TranslationIterator* iterator, 876 Handle<Object> GetDeferredObject(Isolate* isolate);
856 DeoptimizationInputData* data, 877 };
857 JavaScriptFrame* frame);
858 878
859 static void ComputeSlotsForArguments( 879 class MaterializedObjectStore {
860 Vector<SlotRef>* args_slots, 880 public:
861 TranslationIterator* iterator, 881 explicit MaterializedObjectStore(Isolate* isolate) : isolate_(isolate) {
862 DeoptimizationInputData* data, 882 }
863 JavaScriptFrame* frame); 883
884 Handle<FixedArray> Get(Address fp);
885 void Set(Address fp, Handle<FixedArray> materialized_objects);
886 void Remove(Address fp);
887
888 private:
889 Isolate* isolate() { return isolate_; }
890 Handle<FixedArray> GetStackEntries();
891 Handle<FixedArray> EnsureStackEntries(int size);
892
893 int StackIdToIndex(Address fp);
894
895 Isolate* isolate_;
896 List<Address> frame_fps_;
864 }; 897 };
865 898
866 899
867 #ifdef ENABLE_DEBUGGER_SUPPORT 900 #ifdef ENABLE_DEBUGGER_SUPPORT
868 // Class used to represent an unoptimized frame when the debugger 901 // Class used to represent an unoptimized frame when the debugger
869 // needs to inspect a frame that is part of an optimized frame. The 902 // 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 903 // 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. 904 // by the debugger frame information is copied to an object of this type.
872 // Represents parameters in unadapted form so their number might mismatch 905 // Represents parameters in unadapted form so their number might mismatch
873 // formal parameter count. 906 // formal parameter count.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 Object** expression_stack_; 969 Object** expression_stack_;
937 int source_position_; 970 int source_position_;
938 971
939 friend class Deoptimizer; 972 friend class Deoptimizer;
940 }; 973 };
941 #endif 974 #endif
942 975
943 } } // namespace v8::internal 976 } } // namespace v8::internal
944 977
945 #endif // V8_DEOPTIMIZER_H_ 978 #endif // V8_DEOPTIMIZER_H_
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/deoptimizer.cc » ('j') | src/deoptimizer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698