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 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 RawObject* Evaluate(const String& expr, | 1353 RawObject* Evaluate(const String& expr, |
1354 const Array& param_names, | 1354 const Array& param_names, |
1355 const Array& param_values) const; | 1355 const Array& param_values) const; |
1356 | 1356 |
1357 RawError* EnsureIsFinalized(Thread* thread) const; | 1357 RawError* EnsureIsFinalized(Thread* thread) const; |
1358 | 1358 |
1359 // Allocate a class used for VM internal objects. | 1359 // Allocate a class used for VM internal objects. |
1360 template <class FakeObject> static RawClass* New(); | 1360 template <class FakeObject> static RawClass* New(); |
1361 | 1361 |
1362 // Allocate instance classes. | 1362 // Allocate instance classes. |
1363 static RawClass* New(const String& name, | 1363 static RawClass* New(const Library& lib, |
| 1364 const String& name, |
1364 const Script& script, | 1365 const Script& script, |
1365 TokenPosition token_pos); | 1366 TokenPosition token_pos); |
1366 static RawClass* NewNativeWrapper(const Library& library, | 1367 static RawClass* NewNativeWrapper(const Library& library, |
1367 const String& name, | 1368 const String& name, |
1368 int num_fields); | 1369 int num_fields); |
1369 | 1370 |
1370 // Allocate the raw string classes. | 1371 // Allocate the raw string classes. |
1371 static RawClass* NewStringClass(intptr_t class_id); | 1372 static RawClass* NewStringClass(intptr_t class_id); |
1372 | 1373 |
1373 // Allocate the raw TypedData classes. | 1374 // Allocate the raw TypedData classes. |
1374 static RawClass* NewTypedDataClass(intptr_t class_id); | 1375 static RawClass* NewTypedDataClass(intptr_t class_id); |
1375 | 1376 |
1376 // Allocate the raw TypedDataView classes. | 1377 // Allocate the raw TypedDataView classes. |
1377 static RawClass* NewTypedDataViewClass(intptr_t class_id); | 1378 static RawClass* NewTypedDataViewClass(intptr_t class_id); |
1378 | 1379 |
1379 // Allocate the raw ExternalTypedData classes. | 1380 // Allocate the raw ExternalTypedData classes. |
1380 static RawClass* NewExternalTypedDataClass(intptr_t class_id); | 1381 static RawClass* NewExternalTypedDataClass(intptr_t class_id); |
1381 | 1382 |
1382 // Register code that has used CHA for optimization. | 1383 // Register code that has used CHA for optimization. |
1383 // TODO(srdjan): Also register kind of CHA optimization (e.g.: leaf class, | 1384 // TODO(srdjan): Also register kind of CHA optimization (e.g.: leaf class, |
1384 // leaf method, ...). | 1385 // leaf method, ...). |
1385 void RegisterCHACode(const Code& code); | 1386 void RegisterCHACode(const Code& code); |
1386 | 1387 |
1387 void DisableCHAOptimizedCode(const Class& subclass); | 1388 void DisableCHAOptimizedCode(const Class& subclass); |
1388 | 1389 |
| 1390 void DisableAllCHAOptimizedCode(); |
| 1391 |
1389 // Return the list of code objects that were compiled using CHA of this class. | 1392 // Return the list of code objects that were compiled using CHA of this class. |
1390 // These code objects will be invalidated if new subclasses of this class | 1393 // These code objects will be invalidated if new subclasses of this class |
1391 // are finalized. | 1394 // are finalized. |
1392 RawArray* dependent_code() const { return raw_ptr()->dependent_code_; } | 1395 RawArray* dependent_code() const { return raw_ptr()->dependent_code_; } |
1393 void set_dependent_code(const Array& array) const; | 1396 void set_dependent_code(const Array& array) const; |
1394 | 1397 |
1395 bool TraceAllocation(Isolate* isolate) const; | 1398 bool TraceAllocation(Isolate* isolate) const; |
1396 void SetTraceAllocation(bool trace_allocation) const; | 1399 void SetTraceAllocation(bool trace_allocation) const; |
1397 | 1400 |
1398 bool ValidatePostFinalizePatch(const Class& orig_class, Error* error) const; | 1401 bool ValidatePostFinalizePatch(const Class& orig_class, Error* error) const; |
| 1402 void ReplaceEnum(const Class& old_enum) const; |
| 1403 void CopyStaticFieldValues(const Class& old_cls) const; |
| 1404 void PatchFieldsAndFunctions() const; |
| 1405 void CopyCanonicalConstants(const Class& old_cls) const; |
| 1406 void CopyCanonicalTypes(const Class& old_cls) const; |
| 1407 bool CanReload(const Class& replacement) const; |
1399 | 1408 |
1400 private: | 1409 private: |
| 1410 template <class FakeObject> static RawClass* NewCommon(intptr_t index); |
| 1411 |
1401 enum MemberKind { | 1412 enum MemberKind { |
1402 kAny = 0, | 1413 kAny = 0, |
1403 kStatic, | 1414 kStatic, |
1404 kInstance, | 1415 kInstance, |
1405 kInstanceAllowAbstract, | 1416 kInstanceAllowAbstract, |
1406 kConstructor, | 1417 kConstructor, |
1407 kFactory, | 1418 kFactory, |
1408 }; | 1419 }; |
1409 enum StateBits { | 1420 enum StateBits { |
1410 kConstBit = 0, | 1421 kConstBit = 0, |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 RawArray* arguments_descriptor() const { | 1831 RawArray* arguments_descriptor() const { |
1821 return raw_ptr()->args_descriptor_; | 1832 return raw_ptr()->args_descriptor_; |
1822 } | 1833 } |
1823 | 1834 |
1824 intptr_t NumArgsTested() const; | 1835 intptr_t NumArgsTested() const; |
1825 | 1836 |
1826 intptr_t deopt_id() const { | 1837 intptr_t deopt_id() const { |
1827 return raw_ptr()->deopt_id_; | 1838 return raw_ptr()->deopt_id_; |
1828 } | 1839 } |
1829 | 1840 |
| 1841 bool IsImmutable() const; |
| 1842 |
| 1843 void Reset(bool is_static_call) const; |
| 1844 void ResetData() const; |
| 1845 |
1830 // Note: only deopts with reasons before Unknown in this list are recorded in | 1846 // Note: only deopts with reasons before Unknown in this list are recorded in |
1831 // the ICData. All other reasons are used purely for informational messages | 1847 // the ICData. All other reasons are used purely for informational messages |
1832 // printed during deoptimization itself. | 1848 // printed during deoptimization itself. |
1833 #define DEOPT_REASONS(V) \ | 1849 #define DEOPT_REASONS(V) \ |
1834 V(BinarySmiOp) \ | 1850 V(BinarySmiOp) \ |
1835 V(BinaryMintOp) \ | 1851 V(BinaryMintOp) \ |
1836 V(DoubleToSmi) \ | 1852 V(DoubleToSmi) \ |
1837 V(CheckSmi) \ | 1853 V(CheckSmi) \ |
1838 V(Unknown) \ | 1854 V(Unknown) \ |
1839 V(PolymorphicInstanceCallTestFail) \ | 1855 V(PolymorphicInstanceCallTestFail) \ |
(...skipping 25 matching lines...) Expand all Loading... |
1865 kGeneralized = 1 << 1 | 1881 kGeneralized = 1 << 1 |
1866 }; | 1882 }; |
1867 | 1883 |
1868 bool HasDeoptReasons() const { return DeoptReasons() != 0; } | 1884 bool HasDeoptReasons() const { return DeoptReasons() != 0; } |
1869 uint32_t DeoptReasons() const; | 1885 uint32_t DeoptReasons() const; |
1870 void SetDeoptReasons(uint32_t reasons) const; | 1886 void SetDeoptReasons(uint32_t reasons) const; |
1871 | 1887 |
1872 bool HasDeoptReason(ICData::DeoptReasonId reason) const; | 1888 bool HasDeoptReason(ICData::DeoptReasonId reason) const; |
1873 void AddDeoptReason(ICData::DeoptReasonId reason) const; | 1889 void AddDeoptReason(ICData::DeoptReasonId reason) const; |
1874 | 1890 |
| 1891 // The length of the array. This includes all sentinel entries including |
| 1892 // the final one. |
| 1893 intptr_t Length() const; |
| 1894 |
1875 intptr_t NumberOfChecks() const; | 1895 intptr_t NumberOfChecks() const; |
1876 | 1896 |
1877 // Discounts any checks with usage of zero. | 1897 // Discounts any checks with usage of zero. |
1878 intptr_t NumberOfUsedChecks() const; | 1898 intptr_t NumberOfUsedChecks() const; |
1879 | 1899 |
1880 static intptr_t InstanceSize() { | 1900 static intptr_t InstanceSize() { |
1881 return RoundedAllocationSize(sizeof(RawICData)); | 1901 return RoundedAllocationSize(sizeof(RawICData)); |
1882 } | 1902 } |
1883 | 1903 |
1884 static intptr_t target_name_offset() { | 1904 static intptr_t target_name_offset() { |
(...skipping 17 matching lines...) Expand all Loading... |
1902 } | 1922 } |
1903 | 1923 |
1904 static intptr_t ic_data_offset() { | 1924 static intptr_t ic_data_offset() { |
1905 return OFFSET_OF(RawICData, ic_data_); | 1925 return OFFSET_OF(RawICData, ic_data_); |
1906 } | 1926 } |
1907 | 1927 |
1908 static intptr_t owner_offset() { | 1928 static intptr_t owner_offset() { |
1909 return OFFSET_OF(RawICData, owner_); | 1929 return OFFSET_OF(RawICData, owner_); |
1910 } | 1930 } |
1911 | 1931 |
| 1932 // Replaces entry |index| with the sentinel. |
| 1933 void WriteSentinelAt(intptr_t index) const; |
| 1934 |
| 1935 // Clears the count for entry |index|. |
| 1936 void ClearCountAt(intptr_t index) const; |
| 1937 |
| 1938 // Clear all entries with the sentinel value (but will preserve initial |
| 1939 // smi smi checks). |
| 1940 void ClearWithSentinel() const; |
| 1941 |
| 1942 // Clear all entries with the sentinel value and reset the first entry |
| 1943 // with the dummy target entry. |
| 1944 void ClearAndSetStaticTarget(const Function& func) const; |
| 1945 |
| 1946 // Returns the first index that should be used to for a new entry. Will |
| 1947 // grow the array if necessary. |
| 1948 RawArray* FindFreeIndex(intptr_t* index) const; |
| 1949 |
| 1950 void DebugDump() const; |
| 1951 void ValidateSentinelLocations() const; |
| 1952 |
| 1953 // Returns true if this is a two arg smi operation. |
| 1954 bool AddSmiSmiCheckForFastSmiStubs() const; |
| 1955 |
1912 // Used for unoptimized static calls when no class-ids are checked. | 1956 // Used for unoptimized static calls when no class-ids are checked. |
1913 void AddTarget(const Function& target) const; | 1957 void AddTarget(const Function& target) const; |
1914 | 1958 |
1915 // Adding checks. | 1959 // Adding checks. |
1916 | 1960 |
1917 // Adds one more class test to ICData. Length of 'classes' must be equal to | 1961 // Adds one more class test to ICData. Length of 'classes' must be equal to |
1918 // the number of arguments tested. Use only for num_args_tested > 1. | 1962 // the number of arguments tested. Use only for num_args_tested > 1. |
1919 void AddCheck(const GrowableArray<intptr_t>& class_ids, | 1963 void AddCheck(const GrowableArray<intptr_t>& class_ids, |
1920 const Function& target) const; | 1964 const Function& target) const; |
1921 // Adds sorted so that Smi is the first class-id. Use only for | 1965 // Adds sorted so that Smi is the first class-id. Use only for |
1922 // num_args_tested == 1. | 1966 // num_args_tested == 1. |
1923 void AddReceiverCheck(intptr_t receiver_class_id, | 1967 void AddReceiverCheck(intptr_t receiver_class_id, |
1924 const Function& target, | 1968 const Function& target, |
1925 intptr_t count = 1) const; | 1969 intptr_t count = 1) const; |
1926 | 1970 |
| 1971 // Does entry |index| contain the sentinel value? |
| 1972 bool IsSentinelAt(intptr_t index) const; |
| 1973 |
1927 // Retrieving checks. | 1974 // Retrieving checks. |
1928 | 1975 |
1929 void GetCheckAt(intptr_t index, | 1976 void GetCheckAt(intptr_t index, |
1930 GrowableArray<intptr_t>* class_ids, | 1977 GrowableArray<intptr_t>* class_ids, |
1931 Function* target) const; | 1978 Function* target) const; |
1932 void GetClassIdsAt(intptr_t index, GrowableArray<intptr_t>* class_ids) const; | 1979 void GetClassIdsAt(intptr_t index, GrowableArray<intptr_t>* class_ids) const; |
1933 | 1980 |
1934 // Only for 'num_args_checked == 1'. | 1981 // Only for 'num_args_checked == 1'. |
1935 void GetOneClassCheckAt(intptr_t index, | 1982 void GetOneClassCheckAt(intptr_t index, |
1936 intptr_t* class_id, | 1983 intptr_t* class_id, |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 } | 2263 } |
2217 | 2264 |
2218 // Returns true if the signature of this function is instantiated, i.e. if it | 2265 // Returns true if the signature of this function is instantiated, i.e. if it |
2219 // does not involve generic parameter types or generic result type. | 2266 // does not involve generic parameter types or generic result type. |
2220 bool HasInstantiatedSignature() const; | 2267 bool HasInstantiatedSignature() const; |
2221 | 2268 |
2222 // Build a string of the form 'T, {B b, C c}' representing the user | 2269 // Build a string of the form 'T, {B b, C c}' representing the user |
2223 // visible formal parameters of the function. | 2270 // visible formal parameters of the function. |
2224 RawString* UserVisibleFormalParameters() const; | 2271 RawString* UserVisibleFormalParameters() const; |
2225 | 2272 |
| 2273 // Reloading support: |
| 2274 void Reparent(const Class& new_cls) const; |
| 2275 void ZeroEdgeCounters() const; |
| 2276 void FillICDataWithSentinels(const Code& code) const; |
| 2277 |
2226 RawClass* Owner() const; | 2278 RawClass* Owner() const; |
2227 RawClass* origin() const; | 2279 RawClass* origin() const; |
2228 RawScript* script() const; | 2280 RawScript* script() const; |
2229 RawObject* RawOwner() const { return raw_ptr()->owner_; } | 2281 RawObject* RawOwner() const { return raw_ptr()->owner_; } |
2230 | 2282 |
2231 RawRegExp* regexp() const; | 2283 RawRegExp* regexp() const; |
2232 intptr_t string_specialization_cid() const; | 2284 intptr_t string_specialization_cid() const; |
2233 void SetRegExpData(const RegExp& regexp, | 2285 void SetRegExpData(const RegExp& regexp, |
2234 intptr_t string_specialization_cid) const; | 2286 intptr_t string_specialization_cid) const; |
2235 | 2287 |
(...skipping 18 matching lines...) Expand all Loading... |
2254 // Not thread-safe; must be called in the main thread. | 2306 // Not thread-safe; must be called in the main thread. |
2255 // Sets function's code and code's function. | 2307 // Sets function's code and code's function. |
2256 void InstallOptimizedCode(const Code& code, bool is_osr) const; | 2308 void InstallOptimizedCode(const Code& code, bool is_osr) const; |
2257 void AttachCode(const Code& value) const; | 2309 void AttachCode(const Code& value) const; |
2258 void SetInstructions(const Code& value) const; | 2310 void SetInstructions(const Code& value) const; |
2259 void ClearCode() const; | 2311 void ClearCode() const; |
2260 | 2312 |
2261 // Disables optimized code and switches to unoptimized code. | 2313 // Disables optimized code and switches to unoptimized code. |
2262 void SwitchToUnoptimizedCode() const; | 2314 void SwitchToUnoptimizedCode() const; |
2263 | 2315 |
| 2316 // Disables optimized code and switches to unoptimized code (or the lazy |
| 2317 // compilation stub). |
| 2318 void SwitchToLazyCompiledUnoptimizedCode() const; |
| 2319 |
| 2320 // Compiles unoptimized code (if necessary) and attaches it to the function. |
| 2321 void EnsureHasCompiledUnoptimizedCode() const; |
| 2322 |
2264 // Return the most recently compiled and installed code for this function. | 2323 // Return the most recently compiled and installed code for this function. |
2265 // It is not the only Code object that points to this function. | 2324 // It is not the only Code object that points to this function. |
2266 RawCode* CurrentCode() const { | 2325 RawCode* CurrentCode() const { |
2267 return raw_ptr()->code_; | 2326 return raw_ptr()->code_; |
2268 } | 2327 } |
2269 | 2328 |
2270 RawCode* unoptimized_code() const { return raw_ptr()->unoptimized_code_; } | 2329 RawCode* unoptimized_code() const { return raw_ptr()->unoptimized_code_; } |
2271 void set_unoptimized_code(const Code& value) const; | 2330 void set_unoptimized_code(const Code& value) const; |
2272 bool HasCode() const; | 2331 bool HasCode() const; |
2273 | 2332 |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3181 static RawString* SetterName(const String& field_name); | 3240 static RawString* SetterName(const String& field_name); |
3182 static RawString* SetterSymbol(const String& field_name); | 3241 static RawString* SetterSymbol(const String& field_name); |
3183 // Returns String::null() if setter symbol does not exist. | 3242 // Returns String::null() if setter symbol does not exist. |
3184 static RawString* LookupSetterSymbol(const String& field_name); | 3243 static RawString* LookupSetterSymbol(const String& field_name); |
3185 static RawString* NameFromGetter(const String& getter_name); | 3244 static RawString* NameFromGetter(const String& getter_name); |
3186 static RawString* NameFromSetter(const String& setter_name); | 3245 static RawString* NameFromSetter(const String& setter_name); |
3187 static bool IsGetterName(const String& function_name); | 3246 static bool IsGetterName(const String& function_name); |
3188 static bool IsSetterName(const String& function_name); | 3247 static bool IsSetterName(const String& function_name); |
3189 | 3248 |
3190 private: | 3249 private: |
| 3250 static void InitializeNew(const Field& result, |
| 3251 const String& name, |
| 3252 bool is_static, |
| 3253 bool is_final, |
| 3254 bool is_const, |
| 3255 bool is_reflectable, |
| 3256 const Object& owner, |
| 3257 TokenPosition token_pos); |
3191 friend class StoreInstanceFieldInstr; // Generated code access to bit field. | 3258 friend class StoreInstanceFieldInstr; // Generated code access to bit field. |
3192 | 3259 |
3193 enum { | 3260 enum { |
3194 kConstBit = 0, | 3261 kConstBit = 0, |
3195 kStaticBit, | 3262 kStaticBit, |
3196 kFinalBit, | 3263 kFinalBit, |
3197 kHasInitializerBit, | 3264 kHasInitializerBit, |
3198 kUnboxingCandidateBit, | 3265 kUnboxingCandidateBit, |
3199 kReflectableBit, | 3266 kReflectableBit, |
3200 kDoubleInitializedBit, | 3267 kDoubleInitializedBit, |
3201 }; | 3268 }; |
3202 class ConstBit : public BitField<uint8_t, bool, kConstBit, 1> {}; | 3269 class ConstBit : public BitField<uint8_t, bool, kConstBit, 1> {}; |
3203 class StaticBit : public BitField<uint8_t, bool, kStaticBit, 1> {}; | 3270 class StaticBit : public BitField<uint8_t, bool, kStaticBit, 1> {}; |
3204 class FinalBit : public BitField<uint8_t, bool, kFinalBit, 1> {}; | 3271 class FinalBit : public BitField<uint8_t, bool, kFinalBit, 1> {}; |
3205 class HasInitializerBit : | 3272 class HasInitializerBit : |
3206 public BitField<uint8_t, bool, kHasInitializerBit, 1> {}; | 3273 public BitField<uint8_t, bool, kHasInitializerBit, 1> {}; |
3207 class UnboxingCandidateBit : | 3274 class UnboxingCandidateBit : |
3208 public BitField<uint8_t, bool, kUnboxingCandidateBit, 1> {}; | 3275 public BitField<uint8_t, bool, kUnboxingCandidateBit, 1> {}; |
3209 class ReflectableBit : public BitField<uint8_t, bool, kReflectableBit, 1> {}; | 3276 class ReflectableBit : public BitField<uint8_t, bool, kReflectableBit, 1> {}; |
3210 class DoubleInitializedBit : | 3277 class DoubleInitializedBit : |
3211 public BitField<uint8_t, bool, kDoubleInitializedBit, 1> {}; | 3278 public BitField<uint8_t, bool, kDoubleInitializedBit, 1> {}; |
3212 | 3279 |
3213 // Update guarded cid and guarded length for this field. Returns true, if | 3280 // Update guarded cid and guarded length for this field. Returns true, if |
3214 // deoptimization of dependent code is required. | 3281 // deoptimization of dependent code is required. |
3215 bool UpdateGuardedCidAndLength(const Object& value) const; | 3282 bool UpdateGuardedCidAndLength(const Object& value) const; |
3216 | 3283 |
| 3284 // Force this field's guard to be dynamic and deoptimize dependent code. |
| 3285 void ForceDynamicGuardedCidAndLength() const; |
| 3286 |
3217 void set_name(const String& value) const; | 3287 void set_name(const String& value) const; |
3218 void set_is_static(bool is_static) const { | 3288 void set_is_static(bool is_static) const { |
3219 set_kind_bits(StaticBit::update(is_static, raw_ptr()->kind_bits_)); | 3289 set_kind_bits(StaticBit::update(is_static, raw_ptr()->kind_bits_)); |
3220 } | 3290 } |
3221 void set_is_final(bool is_final) const { | 3291 void set_is_final(bool is_final) const { |
3222 set_kind_bits(FinalBit::update(is_final, raw_ptr()->kind_bits_)); | 3292 set_kind_bits(FinalBit::update(is_final, raw_ptr()->kind_bits_)); |
3223 } | 3293 } |
3224 void set_is_const(bool value) const { | 3294 void set_is_const(bool value) const { |
3225 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_)); | 3295 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_)); |
3226 } | 3296 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3370 RawString* Source() const; | 3440 RawString* Source() const; |
3371 RawString* GenerateSource() const; // Generates source code from Tokenstream. | 3441 RawString* GenerateSource() const; // Generates source code from Tokenstream. |
3372 RawGrowableObjectArray* GenerateLineNumberArray() const; | 3442 RawGrowableObjectArray* GenerateLineNumberArray() const; |
3373 RawScript::Kind kind() const { | 3443 RawScript::Kind kind() const { |
3374 return static_cast<RawScript::Kind>(raw_ptr()->kind_); | 3444 return static_cast<RawScript::Kind>(raw_ptr()->kind_); |
3375 } | 3445 } |
3376 const char* GetKindAsCString() const; | 3446 const char* GetKindAsCString() const; |
3377 intptr_t line_offset() const { return raw_ptr()->line_offset_; } | 3447 intptr_t line_offset() const { return raw_ptr()->line_offset_; } |
3378 intptr_t col_offset() const { return raw_ptr()->col_offset_; } | 3448 intptr_t col_offset() const { return raw_ptr()->col_offset_; } |
3379 | 3449 |
| 3450 // The load time in milliseconds since epoch. |
| 3451 int64_t load_timestamp() const { return raw_ptr()->load_timestamp_; } |
| 3452 |
3380 RawTokenStream* tokens() const { return raw_ptr()->tokens_; } | 3453 RawTokenStream* tokens() const { return raw_ptr()->tokens_; } |
3381 | 3454 |
3382 void Tokenize(const String& private_key, | 3455 void Tokenize(const String& private_key, |
3383 bool use_shared_tokens = true) const; | 3456 bool use_shared_tokens = true) const; |
3384 | 3457 |
3385 RawLibrary* FindLibrary() const; | 3458 RawLibrary* FindLibrary() const; |
3386 RawString* GetLine(intptr_t line_number, | 3459 RawString* GetLine(intptr_t line_number, |
3387 Heap::Space space = Heap::kNew) const; | 3460 Heap::Space space = Heap::kNew) const; |
3388 RawString* GetSnippet(intptr_t from_line, | 3461 RawString* GetSnippet(intptr_t from_line, |
3389 intptr_t from_column, | 3462 intptr_t from_column, |
(...skipping 20 matching lines...) Expand all Loading... |
3410 } | 3483 } |
3411 | 3484 |
3412 static RawScript* New(const String& url, | 3485 static RawScript* New(const String& url, |
3413 const String& source, | 3486 const String& source, |
3414 RawScript::Kind kind); | 3487 RawScript::Kind kind); |
3415 | 3488 |
3416 private: | 3489 private: |
3417 void set_url(const String& value) const; | 3490 void set_url(const String& value) const; |
3418 void set_source(const String& value) const; | 3491 void set_source(const String& value) const; |
3419 void set_kind(RawScript::Kind value) const; | 3492 void set_kind(RawScript::Kind value) const; |
| 3493 void set_load_timestamp(int64_t value) const; |
3420 void set_tokens(const TokenStream& value) const; | 3494 void set_tokens(const TokenStream& value) const; |
3421 | 3495 |
3422 static RawScript* New(); | 3496 static RawScript* New(); |
3423 | 3497 |
3424 FINAL_HEAP_OBJECT_IMPLEMENTATION(Script, Object); | 3498 FINAL_HEAP_OBJECT_IMPLEMENTATION(Script, Object); |
3425 friend class Class; | 3499 friend class Class; |
3426 }; | 3500 }; |
3427 | 3501 |
3428 | 3502 |
3429 class DictionaryIterator : public ValueObject { | 3503 class DictionaryIterator : public ValueObject { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3699 const char* class_name, | 3773 const char* class_name, |
3700 const char* function_name); | 3774 const char* function_name); |
3701 | 3775 |
3702 // Character used to indicate a private identifier. | 3776 // Character used to indicate a private identifier. |
3703 static const char kPrivateIdentifierStart = '_'; | 3777 static const char kPrivateIdentifierStart = '_'; |
3704 | 3778 |
3705 // Character used to separate private identifiers from | 3779 // Character used to separate private identifiers from |
3706 // the library-specific key. | 3780 // the library-specific key. |
3707 static const char kPrivateKeySeparator = '@'; | 3781 static const char kPrivateKeySeparator = '@'; |
3708 | 3782 |
| 3783 bool CanReload(const Library& replacement) const; |
| 3784 |
3709 private: | 3785 private: |
3710 static const int kInitialImportsCapacity = 4; | 3786 static const int kInitialImportsCapacity = 4; |
3711 static const int kImportsCapacityIncrement = 8; | 3787 static const int kImportsCapacityIncrement = 8; |
3712 | 3788 |
3713 static RawLibrary* New(); | 3789 static RawLibrary* New(); |
3714 | 3790 |
3715 void set_num_imports(intptr_t value) const; | 3791 void set_num_imports(intptr_t value) const; |
3716 bool HasExports() const; | 3792 bool HasExports() const; |
3717 RawArray* loaded_scripts() const { return raw_ptr()->loaded_scripts_; } | 3793 RawArray* loaded_scripts() const { return raw_ptr()->loaded_scripts_; } |
3718 RawGrowableObjectArray* metadata() const { return raw_ptr()->metadata_; } | 3794 RawGrowableObjectArray* metadata() const { return raw_ptr()->metadata_; } |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5375 virtual bool IsBeingFinalized() const; | 5451 virtual bool IsBeingFinalized() const; |
5376 virtual void SetIsBeingFinalized() const; | 5452 virtual void SetIsBeingFinalized() const; |
5377 virtual bool IsMalformed() const; | 5453 virtual bool IsMalformed() const; |
5378 virtual bool IsMalbounded() const; | 5454 virtual bool IsMalbounded() const; |
5379 virtual bool IsMalformedOrMalbounded() const; | 5455 virtual bool IsMalformedOrMalbounded() const; |
5380 virtual RawLanguageError* error() const; | 5456 virtual RawLanguageError* error() const; |
5381 virtual void set_error(const LanguageError& value) const; | 5457 virtual void set_error(const LanguageError& value) const; |
5382 virtual bool IsResolved() const; | 5458 virtual bool IsResolved() const; |
5383 virtual void SetIsResolved() const; | 5459 virtual void SetIsResolved() const; |
5384 virtual bool HasResolvedTypeClass() const; | 5460 virtual bool HasResolvedTypeClass() const; |
| 5461 virtual classid_t type_class_id() const; |
5385 virtual RawClass* type_class() const; | 5462 virtual RawClass* type_class() const; |
5386 virtual RawUnresolvedClass* unresolved_class() const; | 5463 virtual RawUnresolvedClass* unresolved_class() const; |
5387 virtual RawTypeArguments* arguments() const; | 5464 virtual RawTypeArguments* arguments() const; |
5388 virtual void set_arguments(const TypeArguments& value) const; | 5465 virtual void set_arguments(const TypeArguments& value) const; |
5389 virtual TokenPosition token_pos() const; | 5466 virtual TokenPosition token_pos() const; |
5390 virtual bool IsInstantiated(TrailPtr trail = NULL) const; | 5467 virtual bool IsInstantiated(TrailPtr trail = NULL) const; |
5391 virtual bool CanonicalizeEquals(const Instance& other) const { | 5468 virtual bool CanonicalizeEquals(const Instance& other) const { |
5392 return Equals(other); | 5469 return Equals(other); |
5393 } | 5470 } |
5394 virtual bool Equals(const Instance& other) const { | 5471 virtual bool Equals(const Instance& other) const { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5563 | 5640 |
5564 // A Type consists of a class, possibly parameterized with type | 5641 // A Type consists of a class, possibly parameterized with type |
5565 // arguments. Example: C<T1, T2>. | 5642 // arguments. Example: C<T1, T2>. |
5566 // An unresolved class is a String specifying the class name. | 5643 // An unresolved class is a String specifying the class name. |
5567 // | 5644 // |
5568 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as | 5645 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as |
5569 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not | 5646 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not |
5570 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'. | 5647 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'. |
5571 class Type : public AbstractType { | 5648 class Type : public AbstractType { |
5572 public: | 5649 public: |
5573 static intptr_t type_class_offset() { | 5650 static intptr_t type_class_id_offset() { |
5574 return OFFSET_OF(RawType, type_class_); | 5651 return OFFSET_OF(RawType, type_class_id_); |
5575 } | 5652 } |
5576 virtual bool IsFinalized() const { | 5653 virtual bool IsFinalized() const { |
5577 return | 5654 return |
5578 (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) || | 5655 (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) || |
5579 (raw_ptr()->type_state_ == RawType::kFinalizedUninstantiated); | 5656 (raw_ptr()->type_state_ == RawType::kFinalizedUninstantiated); |
5580 } | 5657 } |
5581 virtual void SetIsFinalized() const; | 5658 virtual void SetIsFinalized() const; |
5582 void ResetIsFinalized() const; // Ignore current state and set again. | 5659 void ResetIsFinalized() const; // Ignore current state and set again. |
5583 virtual bool IsBeingFinalized() const { | 5660 virtual bool IsBeingFinalized() const { |
5584 return raw_ptr()->type_state_ == RawType::kBeingFinalized; | 5661 return raw_ptr()->type_state_ == RawType::kBeingFinalized; |
5585 } | 5662 } |
5586 virtual void SetIsBeingFinalized() const; | 5663 virtual void SetIsBeingFinalized() const; |
5587 virtual bool IsMalformed() const; | 5664 virtual bool IsMalformed() const; |
5588 virtual bool IsMalbounded() const; | 5665 virtual bool IsMalbounded() const; |
5589 virtual bool IsMalformedOrMalbounded() const; | 5666 virtual bool IsMalformedOrMalbounded() const; |
5590 virtual RawLanguageError* error() const; | 5667 virtual RawLanguageError* error() const; |
5591 virtual void set_error(const LanguageError& value) const; | 5668 virtual void set_error(const LanguageError& value) const; |
5592 virtual bool IsResolved() const { | 5669 virtual bool IsResolved() const { |
5593 return raw_ptr()->type_state_ >= RawType::kResolved; | 5670 return raw_ptr()->type_state_ >= RawType::kResolved; |
5594 } | 5671 } |
5595 virtual void SetIsResolved() const; | 5672 virtual void SetIsResolved() const; |
5596 virtual bool HasResolvedTypeClass() const; // Own type class resolved. | 5673 virtual bool HasResolvedTypeClass() const; // Own type class resolved. |
| 5674 virtual classid_t type_class_id() const; |
5597 virtual RawClass* type_class() const; | 5675 virtual RawClass* type_class() const; |
5598 void set_type_class(const Object& value) const; | 5676 void set_type_class(const Class& value) const; |
| 5677 void set_unresolved_class(const Object& value) const; |
5599 virtual RawUnresolvedClass* unresolved_class() const; | 5678 virtual RawUnresolvedClass* unresolved_class() const; |
5600 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; } | 5679 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; } |
5601 virtual void set_arguments(const TypeArguments& value) const; | 5680 virtual void set_arguments(const TypeArguments& value) const; |
5602 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } | 5681 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } |
5603 virtual bool IsInstantiated(TrailPtr trail = NULL) const; | 5682 virtual bool IsInstantiated(TrailPtr trail = NULL) const; |
5604 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 5683 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
5605 virtual bool IsRecursive() const; | 5684 virtual bool IsRecursive() const; |
5606 // If signature is not null, this type represents a function type. | 5685 // If signature is not null, this type represents a function type. |
5607 RawFunction* signature() const; | 5686 RawFunction* signature() const; |
5608 void set_signature(const Function& value) const; | 5687 void set_signature(const Function& value) const; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5779 ASSERT(raw_ptr()->type_state_ != RawTypeParameter::kFinalizedInstantiated); | 5858 ASSERT(raw_ptr()->type_state_ != RawTypeParameter::kFinalizedInstantiated); |
5780 return raw_ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated; | 5859 return raw_ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated; |
5781 } | 5860 } |
5782 virtual void SetIsFinalized() const; | 5861 virtual void SetIsFinalized() const; |
5783 virtual bool IsBeingFinalized() const { return false; } | 5862 virtual bool IsBeingFinalized() const { return false; } |
5784 virtual bool IsMalformed() const { return false; } | 5863 virtual bool IsMalformed() const { return false; } |
5785 virtual bool IsMalbounded() const { return false; } | 5864 virtual bool IsMalbounded() const { return false; } |
5786 virtual bool IsMalformedOrMalbounded() const { return false; } | 5865 virtual bool IsMalformedOrMalbounded() const { return false; } |
5787 virtual bool IsResolved() const { return true; } | 5866 virtual bool IsResolved() const { return true; } |
5788 virtual bool HasResolvedTypeClass() const { return false; } | 5867 virtual bool HasResolvedTypeClass() const { return false; } |
5789 RawClass* parameterized_class() const { | 5868 classid_t parameterized_class_id() const; |
5790 return raw_ptr()->parameterized_class_; | 5869 RawClass* parameterized_class() const; |
5791 } | |
5792 RawString* name() const { return raw_ptr()->name_; } | 5870 RawString* name() const { return raw_ptr()->name_; } |
5793 intptr_t index() const { return raw_ptr()->index_; } | 5871 intptr_t index() const { return raw_ptr()->index_; } |
5794 void set_index(intptr_t value) const; | 5872 void set_index(intptr_t value) const; |
5795 RawAbstractType* bound() const { return raw_ptr()->bound_; } | 5873 RawAbstractType* bound() const { return raw_ptr()->bound_; } |
5796 void set_bound(const AbstractType& value) const; | 5874 void set_bound(const AbstractType& value) const; |
5797 // Returns true if bounded_type is below upper_bound, otherwise return false | 5875 // Returns true if bounded_type is below upper_bound, otherwise return false |
5798 // and set bound_error if both bounded_type and upper_bound are instantiated. | 5876 // and set bound_error if both bounded_type and upper_bound are instantiated. |
5799 // If one or both are not instantiated, returning false only means that the | 5877 // If one or both are not instantiated, returning false only means that the |
5800 // bound cannot be checked yet and this is not an error. | 5878 // bound cannot be checked yet and this is not an error. |
5801 bool CheckBound(const AbstractType& bounded_type, | 5879 bool CheckBound(const AbstractType& bounded_type, |
(...skipping 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8524 | 8602 |
8525 | 8603 |
8526 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8604 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
8527 intptr_t index) { | 8605 intptr_t index) { |
8528 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8606 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
8529 } | 8607 } |
8530 | 8608 |
8531 } // namespace dart | 8609 } // namespace dart |
8532 | 8610 |
8533 #endif // VM_OBJECT_H_ | 8611 #endif // VM_OBJECT_H_ |
OLD | NEW |