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 VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define 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 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 kGeneralized = 1 << 1 | 1834 kGeneralized = 1 << 1 |
1835 }; | 1835 }; |
1836 | 1836 |
1837 bool HasDeoptReasons() const { return DeoptReasons() != 0; } | 1837 bool HasDeoptReasons() const { return DeoptReasons() != 0; } |
1838 uint32_t DeoptReasons() const; | 1838 uint32_t DeoptReasons() const; |
1839 void SetDeoptReasons(uint32_t reasons) const; | 1839 void SetDeoptReasons(uint32_t reasons) const; |
1840 | 1840 |
1841 bool HasDeoptReason(ICData::DeoptReasonId reason) const; | 1841 bool HasDeoptReason(ICData::DeoptReasonId reason) const; |
1842 void AddDeoptReason(ICData::DeoptReasonId reason) const; | 1842 void AddDeoptReason(ICData::DeoptReasonId reason) const; |
1843 | 1843 |
1844 bool IssuedJSWarning() const; | |
1845 void SetIssuedJSWarning() const; | |
1846 | |
1847 // Return true if the target function of this IC data may check for (and | |
1848 // possibly issue) a Javascript compatibility warning. | |
1849 bool MayCheckForJSWarning() const; | |
1850 | |
1851 intptr_t NumberOfChecks() const; | 1844 intptr_t NumberOfChecks() const; |
1852 | 1845 |
1853 // Discounts any checks with usage of zero. | 1846 // Discounts any checks with usage of zero. |
1854 intptr_t NumberOfUsedChecks() const; | 1847 intptr_t NumberOfUsedChecks() const; |
1855 | 1848 |
1856 static intptr_t InstanceSize() { | 1849 static intptr_t InstanceSize() { |
1857 return RoundedAllocationSize(sizeof(RawICData)); | 1850 return RoundedAllocationSize(sizeof(RawICData)); |
1858 } | 1851 } |
1859 | 1852 |
1860 static intptr_t target_name_offset() { | 1853 static intptr_t target_name_offset() { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 case kUint32Range: | 2022 case kUint32Range: |
2030 return "uint32"; | 2023 return "uint32"; |
2031 case kInt64Range: | 2024 case kInt64Range: |
2032 return "int64"; | 2025 return "int64"; |
2033 default: | 2026 default: |
2034 UNREACHABLE(); | 2027 UNREACHABLE(); |
2035 return "?"; | 2028 return "?"; |
2036 } | 2029 } |
2037 } | 2030 } |
2038 | 2031 |
2039 // It is only meaningful to interptret range feedback stored in the ICData | 2032 // It is only meaningful to interpret range feedback stored in the ICData |
2040 // when all checks are Mint or Smi. | 2033 // when all checks are Mint or Smi. |
2041 bool HasRangeFeedback() const; | 2034 bool HasRangeFeedback() const; |
2042 RangeFeedback DecodeRangeFeedbackAt(intptr_t idx) const; | 2035 RangeFeedback DecodeRangeFeedbackAt(intptr_t idx) const; |
2043 | 2036 |
2044 void PrintToJSONArray(const JSONArray& jsarray, | 2037 void PrintToJSONArray(const JSONArray& jsarray, |
2045 TokenPosition token_pos, | 2038 TokenPosition token_pos, |
2046 bool is_static_call) const; | 2039 bool is_static_call) const; |
2047 void PrintToJSONArrayNew(const JSONArray& jsarray, | 2040 void PrintToJSONArrayNew(const JSONArray& jsarray, |
2048 TokenPosition token_pos, | 2041 TokenPosition token_pos, |
2049 bool is_static_call) const; | 2042 bool is_static_call) const; |
(...skipping 18 matching lines...) Expand all Loading... |
2068 void set_deopt_id(intptr_t value) const; | 2061 void set_deopt_id(intptr_t value) const; |
2069 void SetNumArgsTested(intptr_t value) const; | 2062 void SetNumArgsTested(intptr_t value) const; |
2070 void set_ic_data_array(const Array& value) const; | 2063 void set_ic_data_array(const Array& value) const; |
2071 void set_state_bits(uint32_t bits) const; | 2064 void set_state_bits(uint32_t bits) const; |
2072 | 2065 |
2073 enum { | 2066 enum { |
2074 kNumArgsTestedPos = 0, | 2067 kNumArgsTestedPos = 0, |
2075 kNumArgsTestedSize = 2, | 2068 kNumArgsTestedSize = 2, |
2076 kDeoptReasonPos = kNumArgsTestedPos + kNumArgsTestedSize, | 2069 kDeoptReasonPos = kNumArgsTestedPos + kNumArgsTestedSize, |
2077 kDeoptReasonSize = kLastRecordedDeoptReason + 1, | 2070 kDeoptReasonSize = kLastRecordedDeoptReason + 1, |
2078 kIssuedJSWarningBit = kDeoptReasonPos + kDeoptReasonSize, | 2071 kRangeFeedbackPos = kDeoptReasonPos + kDeoptReasonSize, |
2079 kRangeFeedbackPos = kIssuedJSWarningBit + 1, | |
2080 kRangeFeedbackSize = kBitsPerRangeFeedback * kRangeFeedbackSlots | 2072 kRangeFeedbackSize = kBitsPerRangeFeedback * kRangeFeedbackSlots |
2081 }; | 2073 }; |
2082 | 2074 |
2083 class NumArgsTestedBits : public BitField<uint32_t, | 2075 class NumArgsTestedBits : public BitField<uint32_t, |
2084 uint32_t, | 2076 uint32_t, |
2085 kNumArgsTestedPos, | 2077 kNumArgsTestedPos, |
2086 kNumArgsTestedSize> {}; | 2078 kNumArgsTestedSize> {}; |
2087 class DeoptReasonBits : public BitField<uint32_t, | 2079 class DeoptReasonBits : public BitField<uint32_t, |
2088 uint32_t, | 2080 uint32_t, |
2089 ICData::kDeoptReasonPos, | 2081 ICData::kDeoptReasonPos, |
2090 ICData::kDeoptReasonSize> {}; | 2082 ICData::kDeoptReasonSize> {}; |
2091 class IssuedJSWarningBit : | |
2092 public BitField<uint32_t, bool, kIssuedJSWarningBit, 1> {}; | |
2093 class RangeFeedbackBits : public BitField<uint32_t, | 2083 class RangeFeedbackBits : public BitField<uint32_t, |
2094 uint32_t, | 2084 uint32_t, |
2095 ICData::kRangeFeedbackPos, | 2085 ICData::kRangeFeedbackPos, |
2096 ICData::kRangeFeedbackSize> {}; | 2086 ICData::kRangeFeedbackSize> {}; |
2097 | 2087 |
2098 #if defined(DEBUG) | 2088 #if defined(DEBUG) |
2099 // Used in asserts to verify that a check is not added twice. | 2089 // Used in asserts to verify that a check is not added twice. |
2100 bool HasCheck(const GrowableArray<intptr_t>& cids) const; | 2090 bool HasCheck(const GrowableArray<intptr_t>& cids) const; |
2101 #endif // DEBUG | 2091 #endif // DEBUG |
2102 | 2092 |
(...skipping 3857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5960 | 5950 |
5961 class Integer : public Number { | 5951 class Integer : public Number { |
5962 public: | 5952 public: |
5963 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); | 5953 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); |
5964 static RawInteger* NewFromUint64(uint64_t value, | 5954 static RawInteger* NewFromUint64(uint64_t value, |
5965 Heap::Space space = Heap::kNew); | 5955 Heap::Space space = Heap::kNew); |
5966 | 5956 |
5967 // Returns a canonical Integer object allocated in the old gen space. | 5957 // Returns a canonical Integer object allocated in the old gen space. |
5968 static RawInteger* NewCanonical(const String& str); | 5958 static RawInteger* NewCanonical(const String& str); |
5969 | 5959 |
5970 // Do not throw JavascriptIntegerOverflow if 'silent' is true. | 5960 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); |
5971 static RawInteger* New(int64_t value, | |
5972 Heap::Space space = Heap::kNew, | |
5973 const bool silent = false); | |
5974 | 5961 |
5975 virtual bool OperatorEquals(const Instance& other) const { | 5962 virtual bool OperatorEquals(const Instance& other) const { |
5976 return Equals(other); | 5963 return Equals(other); |
5977 } | 5964 } |
5978 virtual bool CanonicalizeEquals(const Instance& other) const { | 5965 virtual bool CanonicalizeEquals(const Instance& other) const { |
5979 return Equals(other); | 5966 return Equals(other); |
5980 } | 5967 } |
5981 virtual bool Equals(const Instance& other) const; | 5968 virtual bool Equals(const Instance& other) const; |
5982 | 5969 |
5983 virtual RawObject* HashCode() const { return raw(); } | 5970 virtual RawObject* HashCode() const { return raw(); } |
(...skipping 17 matching lines...) Expand all Loading... |
6001 RawInteger* AsValidInteger() const; | 5988 RawInteger* AsValidInteger() const; |
6002 | 5989 |
6003 // Returns null to indicate that a bigint operation is required. | 5990 // Returns null to indicate that a bigint operation is required. |
6004 RawInteger* ArithmeticOp(Token::Kind operation, | 5991 RawInteger* ArithmeticOp(Token::Kind operation, |
6005 const Integer& other, | 5992 const Integer& other, |
6006 Heap::Space space = Heap::kNew) const; | 5993 Heap::Space space = Heap::kNew) const; |
6007 RawInteger* BitOp(Token::Kind operation, | 5994 RawInteger* BitOp(Token::Kind operation, |
6008 const Integer& other, | 5995 const Integer& other, |
6009 Heap::Space space = Heap::kNew) const; | 5996 Heap::Space space = Heap::kNew) const; |
6010 | 5997 |
6011 // Returns true if the Integer does not fit in a Javascript integer. | |
6012 bool CheckJavascriptIntegerOverflow() const; | |
6013 | |
6014 private: | 5998 private: |
6015 OBJECT_IMPLEMENTATION(Integer, Number); | 5999 OBJECT_IMPLEMENTATION(Integer, Number); |
6016 friend class Class; | 6000 friend class Class; |
6017 }; | 6001 }; |
6018 | 6002 |
6019 | 6003 |
6020 class Smi : public Integer { | 6004 class Smi : public Integer { |
6021 public: | 6005 public: |
6022 static const intptr_t kBits = kSmiBits; | 6006 static const intptr_t kBits = kSmiBits; |
6023 static const intptr_t kMaxValue = kSmiMax; | 6007 static const intptr_t kMaxValue = kSmiMax; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6060 static intptr_t RawValue(intptr_t value) { | 6044 static intptr_t RawValue(intptr_t value) { |
6061 return reinterpret_cast<intptr_t>(New(value)); | 6045 return reinterpret_cast<intptr_t>(New(value)); |
6062 } | 6046 } |
6063 | 6047 |
6064 static bool IsValid(int64_t value) { | 6048 static bool IsValid(int64_t value) { |
6065 return (value >= kMinValue) && (value <= kMaxValue); | 6049 return (value >= kMinValue) && (value <= kMaxValue); |
6066 } | 6050 } |
6067 | 6051 |
6068 RawInteger* ShiftOp(Token::Kind kind, | 6052 RawInteger* ShiftOp(Token::Kind kind, |
6069 const Smi& other, | 6053 const Smi& other, |
6070 Heap::Space space = Heap::kNew, | 6054 Heap::Space space = Heap::kNew) const; |
6071 const bool silent = false) const; | |
6072 | 6055 |
6073 void operator=(RawSmi* value) { | 6056 void operator=(RawSmi* value) { |
6074 raw_ = value; | 6057 raw_ = value; |
6075 CHECK_HANDLE(); | 6058 CHECK_HANDLE(); |
6076 } | 6059 } |
6077 void operator^=(RawObject* value) { | 6060 void operator^=(RawObject* value) { |
6078 raw_ = value; | 6061 raw_ = value; |
6079 CHECK_HANDLE(); | 6062 CHECK_HANDLE(); |
6080 } | 6063 } |
6081 | 6064 |
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8447 | 8430 |
8448 | 8431 |
8449 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8432 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
8450 intptr_t index) { | 8433 intptr_t index) { |
8451 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8434 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
8452 } | 8435 } |
8453 | 8436 |
8454 } // namespace dart | 8437 } // namespace dart |
8455 | 8438 |
8456 #endif // VM_OBJECT_H_ | 8439 #endif // VM_OBJECT_H_ |
OLD | NEW |