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

Side by Side Diff: src/deoptimizer.h

Issue 21055011: First implementation of allocation elimination in Hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Created 7 years, 4 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/arm/lithium-codegen-arm.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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 double value() const { return val_; } 70 double value() const { return val_; }
71 71
72 private: 72 private:
73 Address slot_address_; 73 Address slot_address_;
74 double val_; 74 double val_;
75 }; 75 };
76 76
77 77
78 class ObjectMaterializationDescriptor BASE_EMBEDDED { 78 class ObjectMaterializationDescriptor BASE_EMBEDDED {
79 public: 79 public:
80 ObjectMaterializationDescriptor(Address slot_address, int length) 80 ObjectMaterializationDescriptor(
81 : slot_address_(slot_address), object_length_(length) { } 81 Address slot_address, int frame, int length, int duplicate, bool is_args)
82 : slot_address_(slot_address),
83 jsframe_index_(frame),
84 object_length_(length),
85 duplicate_object_(duplicate),
86 is_arguments_(is_args) { }
82 87
83 Address slot_address() const { return slot_address_; } 88 Address slot_address() const { return slot_address_; }
89 int jsframe_index() const { return jsframe_index_; }
84 int object_length() const { return object_length_; } 90 int object_length() const { return object_length_; }
91 int duplicate_object() const { return duplicate_object_; }
92 bool is_arguments() const { return is_arguments_; }
93
94 // Only used for allocated receivers in DoComputeConstructStubFrame.
95 void patch_slot_address(intptr_t slot) {
96 slot_address_ = reinterpret_cast<Address>(slot);
97 }
85 98
86 private: 99 private:
87 Address slot_address_; 100 Address slot_address_;
101 int jsframe_index_;
88 int object_length_; 102 int object_length_;
103 int duplicate_object_;
104 bool is_arguments_;
89 }; 105 };
90 106
91 107
92 class OptimizedFunctionVisitor BASE_EMBEDDED { 108 class OptimizedFunctionVisitor BASE_EMBEDDED {
93 public: 109 public:
94 virtual ~OptimizedFunctionVisitor() {} 110 virtual ~OptimizedFunctionVisitor() {}
95 111
96 // Function which is called before iteration of any optimized functions 112 // Function which is called before iteration of any optimized functions
97 // from given native context. 113 // from given native context.
98 virtual void EnterContext(Context* context) = 0; 114 virtual void EnterContext(Context* context) = 0;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 int frame_index); 381 int frame_index);
366 void DoComputeConstructStubFrame(TranslationIterator* iterator, 382 void DoComputeConstructStubFrame(TranslationIterator* iterator,
367 int frame_index); 383 int frame_index);
368 void DoComputeAccessorStubFrame(TranslationIterator* iterator, 384 void DoComputeAccessorStubFrame(TranslationIterator* iterator,
369 int frame_index, 385 int frame_index,
370 bool is_setter_stub_frame); 386 bool is_setter_stub_frame);
371 void DoComputeCompiledStubFrame(TranslationIterator* iterator, 387 void DoComputeCompiledStubFrame(TranslationIterator* iterator,
372 int frame_index); 388 int frame_index);
373 389
374 void DoTranslateObject(TranslationIterator* iterator, 390 void DoTranslateObject(TranslationIterator* iterator,
375 int object_opcode, 391 int object_index,
376 int field_index); 392 int field_index);
377 393
378 enum DeoptimizerTranslatedValueType { 394 enum DeoptimizerTranslatedValueType {
379 TRANSLATED_VALUE_IS_NATIVE, 395 TRANSLATED_VALUE_IS_NATIVE,
380 TRANSLATED_VALUE_IS_TAGGED 396 TRANSLATED_VALUE_IS_TAGGED
381 }; 397 };
382 398
383 void DoTranslateCommand(TranslationIterator* iterator, 399 void DoTranslateCommand(TranslationIterator* iterator,
384 int frame_index, 400 int frame_index,
385 unsigned output_offset, 401 unsigned output_offset,
386 DeoptimizerTranslatedValueType value_type = TRANSLATED_VALUE_IS_TAGGED); 402 DeoptimizerTranslatedValueType value_type = TRANSLATED_VALUE_IS_TAGGED);
387 403
388 // Translate a command for OSR. Updates the input offset to be used for 404 // Translate a command for OSR. Updates the input offset to be used for
389 // the next command. Returns false if translation of the command failed 405 // the next command. Returns false if translation of the command failed
390 // (e.g., a number conversion failed) and may or may not have updated the 406 // (e.g., a number conversion failed) and may or may not have updated the
391 // input offset. 407 // input offset.
392 bool DoOsrTranslateCommand(TranslationIterator* iterator, 408 bool DoOsrTranslateCommand(TranslationIterator* iterator,
393 int* input_offset); 409 int* input_offset);
394 410
395 unsigned ComputeInputFrameSize() const; 411 unsigned ComputeInputFrameSize() const;
396 unsigned ComputeFixedSize(JSFunction* function) const; 412 unsigned ComputeFixedSize(JSFunction* function) const;
397 413
398 unsigned ComputeIncomingArgumentSize(JSFunction* function) const; 414 unsigned ComputeIncomingArgumentSize(JSFunction* function) const;
399 unsigned ComputeOutgoingArgumentSize() const; 415 unsigned ComputeOutgoingArgumentSize() const;
400 416
401 Object* ComputeLiteral(int index) const; 417 Object* ComputeLiteral(int index) const;
402 418
403 void AddObjectStart(intptr_t slot_address, int argc); 419 void AddObjectStart(intptr_t slot_address, int argc, bool is_arguments);
420 void AddObjectDuplication(intptr_t slot, int object_index);
404 void AddObjectTaggedValue(intptr_t value); 421 void AddObjectTaggedValue(intptr_t value);
405 void AddObjectDoubleValue(double value); 422 void AddObjectDoubleValue(double value);
406 void AddDoubleValue(intptr_t slot_address, double value); 423 void AddDoubleValue(intptr_t slot_address, double value);
407 424
425 bool ArgumentsObjectIsAdapted(int object_index) {
426 ObjectMaterializationDescriptor desc = deferred_objects_.at(object_index);
427 int reverse_jsframe_index = jsframe_count_ - desc.jsframe_index() - 1;
428 return jsframe_has_adapted_arguments_[reverse_jsframe_index];
429 }
430
431 Handle<JSFunction> ArgumentsObjectFunction(int object_index) {
432 ObjectMaterializationDescriptor desc = deferred_objects_.at(object_index);
433 int reverse_jsframe_index = jsframe_count_ - desc.jsframe_index() - 1;
434 return jsframe_functions_[reverse_jsframe_index];
435 }
436
437 // Helper function for heap object materialization.
438 Handle<Object> MaterializeNextHeapObject();
439 Handle<Object> MaterializeNextValue();
440
408 static void GenerateDeoptimizationEntries( 441 static void GenerateDeoptimizationEntries(
409 MacroAssembler* masm, int count, BailoutType type); 442 MacroAssembler* masm, int count, BailoutType type);
410 443
411 // Weak handle callback for deoptimizing code objects. 444 // Weak handle callback for deoptimizing code objects.
412 static void HandleWeakDeoptimizedCode(v8::Isolate* isolate, 445 static void HandleWeakDeoptimizedCode(v8::Isolate* isolate,
413 v8::Persistent<v8::Value>* obj, 446 v8::Persistent<v8::Value>* obj,
414 void* data); 447 void* data);
415 448
416 // Deoptimize the given code and add to appropriate deoptimization lists. 449 // Deoptimize the given code and add to appropriate deoptimization lists.
417 static void DeoptimizeCode(Isolate* isolate, Code* code); 450 static void DeoptimizeCode(Isolate* isolate, Code* code);
(...skipping 30 matching lines...) Expand all
448 481
449 // Input frame description. 482 // Input frame description.
450 FrameDescription* input_; 483 FrameDescription* input_;
451 // Number of output frames. 484 // Number of output frames.
452 int output_count_; 485 int output_count_;
453 // Number of output js frames. 486 // Number of output js frames.
454 int jsframe_count_; 487 int jsframe_count_;
455 // Array of output frame descriptions. 488 // Array of output frame descriptions.
456 FrameDescription** output_; 489 FrameDescription** output_;
457 490
491 // Deferred values to be materialized.
458 List<Object*> deferred_objects_tagged_values_; 492 List<Object*> deferred_objects_tagged_values_;
459 List<double> deferred_objects_double_values_; 493 List<double> deferred_objects_double_values_;
460 List<ObjectMaterializationDescriptor> deferred_objects_; 494 List<ObjectMaterializationDescriptor> deferred_objects_;
461 List<HeapNumberMaterializationDescriptor> deferred_heap_numbers_; 495 List<HeapNumberMaterializationDescriptor> deferred_heap_numbers_;
496
497 // Output frame information. Only used during heap object materialization.
498 List<Handle<JSFunction> > jsframe_functions_;
499 List<bool> jsframe_has_adapted_arguments_;
500
501 // Materialized objects. Only used during heap object materialization.
502 List<Handle<Object> >* materialized_values_;
503 List<Handle<Object> >* materialized_objects_;
504 int materialization_value_index_;
505 int materialization_object_index_;
506
462 #ifdef DEBUG 507 #ifdef DEBUG
463 DisallowHeapAllocation* disallow_heap_allocation_; 508 DisallowHeapAllocation* disallow_heap_allocation_;
464 #endif // DEBUG 509 #endif // DEBUG
465 510
466 bool trace_; 511 bool trace_;
467 512
468 static const int table_entry_size_; 513 static const int table_entry_size_;
469 514
470 friend class FrameDescription; 515 friend class FrameDescription;
471 friend class DeoptimizingCodeListNode; 516 friend class DeoptimizingCodeListNode;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 class Translation BASE_EMBEDDED { 750 class Translation BASE_EMBEDDED {
706 public: 751 public:
707 enum Opcode { 752 enum Opcode {
708 BEGIN, 753 BEGIN,
709 JS_FRAME, 754 JS_FRAME,
710 CONSTRUCT_STUB_FRAME, 755 CONSTRUCT_STUB_FRAME,
711 GETTER_STUB_FRAME, 756 GETTER_STUB_FRAME,
712 SETTER_STUB_FRAME, 757 SETTER_STUB_FRAME,
713 ARGUMENTS_ADAPTOR_FRAME, 758 ARGUMENTS_ADAPTOR_FRAME,
714 COMPILED_STUB_FRAME, 759 COMPILED_STUB_FRAME,
760 DUPLICATED_OBJECT,
715 ARGUMENTS_OBJECT, 761 ARGUMENTS_OBJECT,
762 CAPTURED_OBJECT,
716 REGISTER, 763 REGISTER,
717 INT32_REGISTER, 764 INT32_REGISTER,
718 UINT32_REGISTER, 765 UINT32_REGISTER,
719 DOUBLE_REGISTER, 766 DOUBLE_REGISTER,
720 STACK_SLOT, 767 STACK_SLOT,
721 INT32_STACK_SLOT, 768 INT32_STACK_SLOT,
722 UINT32_STACK_SLOT, 769 UINT32_STACK_SLOT,
723 DOUBLE_STACK_SLOT, 770 DOUBLE_STACK_SLOT,
724 LITERAL 771 LITERAL
725 }; 772 };
(...skipping 11 matching lines...) Expand all
737 int index() const { return index_; } 784 int index() const { return index_; }
738 785
739 // Commands. 786 // Commands.
740 void BeginJSFrame(BailoutId node_id, int literal_id, unsigned height); 787 void BeginJSFrame(BailoutId node_id, int literal_id, unsigned height);
741 void BeginCompiledStubFrame(); 788 void BeginCompiledStubFrame();
742 void BeginArgumentsAdaptorFrame(int literal_id, unsigned height); 789 void BeginArgumentsAdaptorFrame(int literal_id, unsigned height);
743 void BeginConstructStubFrame(int literal_id, unsigned height); 790 void BeginConstructStubFrame(int literal_id, unsigned height);
744 void BeginGetterStubFrame(int literal_id); 791 void BeginGetterStubFrame(int literal_id);
745 void BeginSetterStubFrame(int literal_id); 792 void BeginSetterStubFrame(int literal_id);
746 void BeginArgumentsObject(int args_length); 793 void BeginArgumentsObject(int args_length);
794 void BeginCapturedObject(int length);
795 void DuplicateObject(int object_index);
747 void StoreRegister(Register reg); 796 void StoreRegister(Register reg);
748 void StoreInt32Register(Register reg); 797 void StoreInt32Register(Register reg);
749 void StoreUint32Register(Register reg); 798 void StoreUint32Register(Register reg);
750 void StoreDoubleRegister(DoubleRegister reg); 799 void StoreDoubleRegister(DoubleRegister reg);
751 void StoreStackSlot(int index); 800 void StoreStackSlot(int index);
752 void StoreInt32StackSlot(int index); 801 void StoreInt32StackSlot(int index);
753 void StoreUint32StackSlot(int index); 802 void StoreUint32StackSlot(int index);
754 void StoreDoubleStackSlot(int index); 803 void StoreDoubleStackSlot(int index);
755 void StoreLiteral(int literal_id); 804 void StoreLiteral(int literal_id);
756 void StoreArgumentsObject(bool args_known, int args_index, int args_length); 805 void StoreArgumentsObject(bool args_known, int args_index, int args_length);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 Object** expression_stack_; 1003 Object** expression_stack_;
955 int source_position_; 1004 int source_position_;
956 1005
957 friend class Deoptimizer; 1006 friend class Deoptimizer;
958 }; 1007 };
959 #endif 1008 #endif
960 1009
961 } } // namespace v8::internal 1010 } } // namespace v8::internal
962 1011
963 #endif // V8_DEOPTIMIZER_H_ 1012 #endif // V8_DEOPTIMIZER_H_
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/deoptimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698