| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a | 
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef RUNTIME_VM_OBJECT_H_ | 5 #ifndef RUNTIME_VM_OBJECT_H_ | 
| 6 #define RUNTIME_VM_OBJECT_H_ | 6 #define RUNTIME_VM_OBJECT_H_ | 
| 7 | 7 | 
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" | 
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" | 
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" | 
| (...skipping 4383 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4394   static intptr_t InstanceSize() { | 4394   static intptr_t InstanceSize() { | 
| 4395     ASSERT(sizeof(RawCodeSourceMap) == | 4395     ASSERT(sizeof(RawCodeSourceMap) == | 
| 4396            OFFSET_OF_RETURNED_VALUE(RawCodeSourceMap, data)); | 4396            OFFSET_OF_RETURNED_VALUE(RawCodeSourceMap, data)); | 
| 4397     return 0; | 4397     return 0; | 
| 4398   } | 4398   } | 
| 4399   static intptr_t InstanceSize(intptr_t len) { | 4399   static intptr_t InstanceSize(intptr_t len) { | 
| 4400     ASSERT(0 <= len && len <= kMaxElements); | 4400     ASSERT(0 <= len && len <= kMaxElements); | 
| 4401     return RoundedAllocationSize(sizeof(RawCodeSourceMap) + len); | 4401     return RoundedAllocationSize(sizeof(RawCodeSourceMap) + len); | 
| 4402   } | 4402   } | 
| 4403 | 4403 | 
| 4404   static RawCodeSourceMap* New(GrowableArray<uint8_t>* delta_encoded_data); | 4404   static RawCodeSourceMap* New(intptr_t length); | 
|  | 4405 | 
|  | 4406   intptr_t Length() const { return raw_ptr()->length_; } | 
|  | 4407   uint8_t* Data() const { | 
|  | 4408     return UnsafeMutableNonPointer(&raw_ptr()->data()[0]); | 
|  | 4409   } | 
| 4405 | 4410 | 
| 4406   void PrintToJSONObject(JSONObject* jsobj, bool ref) const; | 4411   void PrintToJSONObject(JSONObject* jsobj, bool ref) const; | 
| 4407 | 4412 | 
| 4408   // Encode integer in SLEB128 format. |  | 
| 4409   static void EncodeInteger(GrowableArray<uint8_t>* data, intptr_t value); |  | 
| 4410 |  | 
| 4411   // Decode SLEB128 encoded integer. Update byte_index to the next integer. |  | 
| 4412   intptr_t DecodeInteger(intptr_t* byte_index) const; |  | 
| 4413 |  | 
| 4414   TokenPosition TokenPositionForPCOffset(uword pc_offset) const; |  | 
| 4415   RawFunction* FunctionForPCOffset(const Code& code, |  | 
| 4416                                    const Function& function, |  | 
| 4417                                    uword pc_offset) const; |  | 
| 4418   RawScript* ScriptForPCOffset(const Code& code, |  | 
| 4419                                const Function& function, |  | 
| 4420                                uword pc_offset) const; |  | 
| 4421 |  | 
| 4422   static void Dump(const CodeSourceMap& code_source_map, |  | 
| 4423                    const Code& code, |  | 
| 4424                    const Function& function); |  | 
| 4425 |  | 
| 4426   class Iterator : ValueObject { |  | 
| 4427    public: |  | 
| 4428     explicit Iterator(const CodeSourceMap& code_source_map) |  | 
| 4429         : code_source_map_(code_source_map), |  | 
| 4430           byte_index_(0), |  | 
| 4431           cur_pc_offset_(0), |  | 
| 4432           cur_token_pos_(0) {} |  | 
| 4433 |  | 
| 4434     bool MoveNext() { |  | 
| 4435       // Moves to the next record. |  | 
| 4436       while (byte_index_ < code_source_map_.Length()) { |  | 
| 4437         cur_pc_offset_ += code_source_map_.DecodeInteger(&byte_index_); |  | 
| 4438         cur_token_pos_ += code_source_map_.DecodeInteger(&byte_index_); |  | 
| 4439 |  | 
| 4440         return true; |  | 
| 4441       } |  | 
| 4442       return false; |  | 
| 4443     } |  | 
| 4444 |  | 
| 4445     uword PcOffset() const { return cur_pc_offset_; } |  | 
| 4446     TokenPosition TokenPos() const { return TokenPosition(cur_token_pos_); } |  | 
| 4447 |  | 
| 4448    private: |  | 
| 4449     friend class CodeSourceMap; |  | 
| 4450 |  | 
| 4451     const CodeSourceMap& code_source_map_; |  | 
| 4452     intptr_t byte_index_; |  | 
| 4453 |  | 
| 4454     intptr_t cur_pc_offset_; |  | 
| 4455     intptr_t cur_token_pos_; |  | 
| 4456   }; |  | 
| 4457 |  | 
| 4458  private: | 4413  private: | 
| 4459   static RawCodeSourceMap* New(intptr_t length); |  | 
| 4460 |  | 
| 4461   intptr_t Length() const; |  | 
| 4462   void SetLength(intptr_t value) const; | 4414   void SetLength(intptr_t value) const; | 
| 4463   void CopyData(GrowableArray<uint8_t>* data); |  | 
| 4464 | 4415 | 
| 4465   FINAL_HEAP_OBJECT_IMPLEMENTATION(CodeSourceMap, Object); | 4416   FINAL_HEAP_OBJECT_IMPLEMENTATION(CodeSourceMap, Object); | 
| 4466   friend class Class; | 4417   friend class Class; | 
| 4467   friend class Object; | 4418   friend class Object; | 
| 4468 }; | 4419 }; | 
| 4469 | 4420 | 
| 4470 | 4421 | 
| 4471 class StackMap : public Object { | 4422 class StackMap : public Object { | 
| 4472  public: | 4423  public: | 
| 4473   static const intptr_t kNoMaximum = -1; | 4424   static const intptr_t kNoMaximum = -1; | 
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4723 #else | 4674 #else | 
| 4724     ASSERT(code_source_map.IsOld()); | 4675     ASSERT(code_source_map.IsOld()); | 
| 4725     StorePointer(&raw_ptr()->code_source_map_, code_source_map.raw()); | 4676     StorePointer(&raw_ptr()->code_source_map_, code_source_map.raw()); | 
| 4726 #endif | 4677 #endif | 
| 4727   } | 4678   } | 
| 4728 | 4679 | 
| 4729   // Used during reloading (see object_reload.cc). Calls Reset on all ICDatas | 4680   // Used during reloading (see object_reload.cc). Calls Reset on all ICDatas | 
| 4730   // that are embedded inside the Code object. | 4681   // that are embedded inside the Code object. | 
| 4731   void ResetICDatas(Zone* zone) const; | 4682   void ResetICDatas(Zone* zone) const; | 
| 4732 | 4683 | 
| 4733   TokenPosition GetTokenPositionAt(intptr_t offset) const; |  | 
| 4734 |  | 
| 4735   // Array of DeoptInfo objects. | 4684   // Array of DeoptInfo objects. | 
| 4736   RawArray* deopt_info_array() const { | 4685   RawArray* deopt_info_array() const { | 
| 4737 #if defined(DART_PRECOMPILED_RUNTIME) | 4686 #if defined(DART_PRECOMPILED_RUNTIME) | 
| 4738     UNREACHABLE(); | 4687     UNREACHABLE(); | 
| 4739     return NULL; | 4688     return NULL; | 
| 4740 #else | 4689 #else | 
| 4741     return raw_ptr()->deopt_info_array_; | 4690     return raw_ptr()->deopt_info_array_; | 
| 4742 #endif | 4691 #endif | 
| 4743   } | 4692   } | 
| 4744   void set_deopt_info_array(const Array& array) const; | 4693   void set_deopt_info_array(const Array& array) const; | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4819     return NULL; | 4768     return NULL; | 
| 4820 #else | 4769 #else | 
| 4821     return raw_ptr()->return_address_metadata_; | 4770     return raw_ptr()->return_address_metadata_; | 
| 4822 #endif | 4771 #endif | 
| 4823   } | 4772   } | 
| 4824   // Sets |return_address_metadata|. | 4773   // Sets |return_address_metadata|. | 
| 4825   void SetPrologueOffset(intptr_t offset) const; | 4774   void SetPrologueOffset(intptr_t offset) const; | 
| 4826   // Returns -1 if no prologue offset is available. | 4775   // Returns -1 if no prologue offset is available. | 
| 4827   intptr_t GetPrologueOffset() const; | 4776   intptr_t GetPrologueOffset() const; | 
| 4828 | 4777 | 
| 4829   enum InlinedIntervalEntries { | 4778   RawArray* inlined_id_to_function() const; | 
| 4830     kInlIntStart = 0, | 4779   void set_inlined_id_to_function(const Array& value) const; | 
| 4831     kInlIntInliningId = 1, |  | 
| 4832     kInlIntNumEntries = 2, |  | 
| 4833   }; |  | 
| 4834 | 4780 | 
| 4835   RawArray* GetInlinedIntervals() const; | 4781   // Provides the call stack at the given pc offset, with the top-of-stack in | 
| 4836   void SetInlinedIntervals(const Array& value) const; | 4782   // the last element and the root function (this) as the first element, along | 
|  | 4783   // with the corresponding source positions. Note the token position for each | 
|  | 4784   // function except the top-of-stack is the position of the call to the next | 
|  | 4785   // function. The stack will be empty if we lack the metadata to produce it, | 
|  | 4786   // which happens for stub code. | 
|  | 4787   void GetInlinedFunctionsAt( | 
|  | 4788       intptr_t pc_offset, | 
|  | 4789       GrowableArray<const Function*>* functions, | 
|  | 4790       GrowableArray<TokenPosition>* token_positions) const; | 
| 4837 | 4791 | 
| 4838   RawArray* GetInlinedIdToFunction() const; | 4792   NOT_IN_PRODUCT(void PrintJSONInlineIntervals(JSONObject* object) const); | 
| 4839   void SetInlinedIdToFunction(const Array& value) const; | 4793   void DumpInlineIntervals() const; | 
| 4840 | 4794   void DumpSourcePositions() const; | 
| 4841   RawArray* GetInlinedIdToTokenPos() const; |  | 
| 4842   void SetInlinedIdToTokenPos(const Array& value) const; |  | 
| 4843 |  | 
| 4844   RawArray* GetInlinedCallerIdMap() const; |  | 
| 4845   void SetInlinedCallerIdMap(const Array& value) const; |  | 
| 4846 |  | 
| 4847   // If |token_positions| is not NULL it will be populated with the token |  | 
| 4848   // positions of the inlined calls. |  | 
| 4849   void GetInlinedFunctionsAt( |  | 
| 4850       intptr_t offset, |  | 
| 4851       GrowableArray<Function*>* fs, |  | 
| 4852       GrowableArray<TokenPosition>* token_positions = NULL) const; |  | 
| 4853 |  | 
| 4854   void DumpInlinedIntervals() const; |  | 
| 4855 | 4795 | 
| 4856   RawLocalVarDescriptors* var_descriptors() const { | 4796   RawLocalVarDescriptors* var_descriptors() const { | 
| 4857 #if defined(DART_PRECOMPILED_RUNTIME) | 4797 #if defined(DART_PRECOMPILED_RUNTIME) | 
| 4858     UNREACHABLE(); | 4798     UNREACHABLE(); | 
| 4859     return NULL; | 4799     return NULL; | 
| 4860 #else | 4800 #else | 
| 4861     return raw_ptr()->var_descriptors_; | 4801     return raw_ptr()->var_descriptors_; | 
| 4862 #endif | 4802 #endif | 
| 4863   } | 4803   } | 
| 4864   void set_var_descriptors(const LocalVarDescriptors& value) const { | 4804   void set_var_descriptors(const LocalVarDescriptors& value) const { | 
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5029     ASSERT(index >= 0); | 4969     ASSERT(index >= 0); | 
| 5030     ASSERT(index < pointer_offsets_length()); | 4970     ASSERT(index < pointer_offsets_length()); | 
| 5031     // TODO(iposva): Unit test is missing for this functionality. | 4971     // TODO(iposva): Unit test is missing for this functionality. | 
| 5032     return &UnsafeMutableNonPointer(raw_ptr()->data())[index]; | 4972     return &UnsafeMutableNonPointer(raw_ptr()->data())[index]; | 
| 5033   } | 4973   } | 
| 5034   void SetPointerOffsetAt(int index, int32_t offset_in_instructions) { | 4974   void SetPointerOffsetAt(int index, int32_t offset_in_instructions) { | 
| 5035     NoSafepointScope no_safepoint; | 4975     NoSafepointScope no_safepoint; | 
| 5036     *PointerOffsetAddrAt(index) = offset_in_instructions; | 4976     *PointerOffsetAddrAt(index) = offset_in_instructions; | 
| 5037   } | 4977   } | 
| 5038 | 4978 | 
| 5039   // Currently slow, as it searches linearly through inlined_intervals(). |  | 
| 5040   intptr_t GetCallerId(intptr_t inlined_id) const; |  | 
| 5041 |  | 
| 5042   intptr_t BinarySearchInSCallTable(uword pc) const; | 4979   intptr_t BinarySearchInSCallTable(uword pc) const; | 
| 5043   static RawCode* LookupCodeInIsolate(Isolate* isolate, uword pc); | 4980   static RawCode* LookupCodeInIsolate(Isolate* isolate, uword pc); | 
| 5044 | 4981 | 
| 5045   // New is a private method as RawInstruction and RawCode objects should | 4982   // New is a private method as RawInstruction and RawCode objects should | 
| 5046   // only be created using the Code::FinalizeCode method. This method creates | 4983   // only be created using the Code::FinalizeCode method. This method creates | 
| 5047   // the RawInstruction and RawCode objects, sets up the pointer offsets | 4984   // the RawInstruction and RawCode objects, sets up the pointer offsets | 
| 5048   // and links the two in a GC safe manner. | 4985   // and links the two in a GC safe manner. | 
| 5049   static RawCode* New(intptr_t pointer_offsets_length); | 4986   static RawCode* New(intptr_t pointer_offsets_length); | 
| 5050 | 4987 | 
| 5051   FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object); | 4988   FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object); | 
| (...skipping 3904 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 8956 | 8893 | 
| 8957 inline void TypeArguments::SetHash(intptr_t value) const { | 8894 inline void TypeArguments::SetHash(intptr_t value) const { | 
| 8958   // This is only safe because we create a new Smi, which does not cause | 8895   // This is only safe because we create a new Smi, which does not cause | 
| 8959   // heap allocation. | 8896   // heap allocation. | 
| 8960   StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 8897   StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 
| 8961 } | 8898 } | 
| 8962 | 8899 | 
| 8963 }  // namespace dart | 8900 }  // namespace dart | 
| 8964 | 8901 | 
| 8965 #endif  // RUNTIME_VM_OBJECT_H_ | 8902 #endif  // RUNTIME_VM_OBJECT_H_ | 
| OLD | NEW | 
|---|