| 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 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 bool HasInstantiatedSignature() const; | 1727 bool HasInstantiatedSignature() const; |
| 1728 | 1728 |
| 1729 // Build a string of the form 'T, {b: B, c: C} representing the user | 1729 // Build a string of the form 'T, {b: B, c: C} representing the user |
| 1730 // visible formal parameters of the function. | 1730 // visible formal parameters of the function. |
| 1731 RawString* UserVisibleFormalParameters() const; | 1731 RawString* UserVisibleFormalParameters() const; |
| 1732 | 1732 |
| 1733 RawClass* Owner() const; | 1733 RawClass* Owner() const; |
| 1734 RawClass* origin() const; | 1734 RawClass* origin() const; |
| 1735 RawScript* script() const; | 1735 RawScript* script() const; |
| 1736 | 1736 |
| 1737 void set_regexp(const JSRegExp& value) const; |
| 1738 RawJSRegExp* regexp() const; |
| 1739 |
| 1740 // Get and set the class id this function is specialized for. Only set for |
| 1741 // irregexp functions. |
| 1742 intptr_t regexp_cid() const { return raw_ptr()->regexp_cid_; } |
| 1743 void set_regexp_cid(intptr_t regexp_cid) const; |
| 1744 |
| 1737 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } | 1745 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } |
| 1738 void set_result_type(const AbstractType& value) const; | 1746 void set_result_type(const AbstractType& value) const; |
| 1739 | 1747 |
| 1740 RawAbstractType* ParameterTypeAt(intptr_t index) const; | 1748 RawAbstractType* ParameterTypeAt(intptr_t index) const; |
| 1741 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; | 1749 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; |
| 1742 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; } | 1750 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; } |
| 1743 void set_parameter_types(const Array& value) const; | 1751 void set_parameter_types(const Array& value) const; |
| 1744 | 1752 |
| 1745 // Parameter names are valid for all valid parameter indices, and are not | 1753 // Parameter names are valid for all valid parameter indices, and are not |
| 1746 // limited to named optional parameters. | 1754 // limited to named optional parameters. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 case RawFunction::kSetterFunction: | 1864 case RawFunction::kSetterFunction: |
| 1857 case RawFunction::kImplicitGetter: | 1865 case RawFunction::kImplicitGetter: |
| 1858 case RawFunction::kImplicitSetter: | 1866 case RawFunction::kImplicitSetter: |
| 1859 case RawFunction::kMethodExtractor: | 1867 case RawFunction::kMethodExtractor: |
| 1860 case RawFunction::kNoSuchMethodDispatcher: | 1868 case RawFunction::kNoSuchMethodDispatcher: |
| 1861 case RawFunction::kInvokeFieldDispatcher: | 1869 case RawFunction::kInvokeFieldDispatcher: |
| 1862 return true; | 1870 return true; |
| 1863 case RawFunction::kClosureFunction: | 1871 case RawFunction::kClosureFunction: |
| 1864 case RawFunction::kConstructor: | 1872 case RawFunction::kConstructor: |
| 1865 case RawFunction::kImplicitStaticFinalGetter: | 1873 case RawFunction::kImplicitStaticFinalGetter: |
| 1874 case RawFunction::kIrregexpFunction: |
| 1866 return false; | 1875 return false; |
| 1867 default: | 1876 default: |
| 1868 UNREACHABLE(); | 1877 UNREACHABLE(); |
| 1869 return false; | 1878 return false; |
| 1870 } | 1879 } |
| 1871 } | 1880 } |
| 1872 bool IsStaticFunction() const { | 1881 bool IsStaticFunction() const { |
| 1873 if (!is_static()) { | 1882 if (!is_static()) { |
| 1874 return false; | 1883 return false; |
| 1875 } | 1884 } |
| 1876 switch (kind()) { | 1885 switch (kind()) { |
| 1877 case RawFunction::kRegularFunction: | 1886 case RawFunction::kRegularFunction: |
| 1878 case RawFunction::kGetterFunction: | 1887 case RawFunction::kGetterFunction: |
| 1879 case RawFunction::kSetterFunction: | 1888 case RawFunction::kSetterFunction: |
| 1880 case RawFunction::kImplicitGetter: | 1889 case RawFunction::kImplicitGetter: |
| 1881 case RawFunction::kImplicitSetter: | 1890 case RawFunction::kImplicitSetter: |
| 1882 case RawFunction::kImplicitStaticFinalGetter: | 1891 case RawFunction::kImplicitStaticFinalGetter: |
| 1892 case RawFunction::kIrregexpFunction: |
| 1883 return true; | 1893 return true; |
| 1884 case RawFunction::kClosureFunction: | 1894 case RawFunction::kClosureFunction: |
| 1885 case RawFunction::kConstructor: | 1895 case RawFunction::kConstructor: |
| 1886 return false; | 1896 return false; |
| 1887 default: | 1897 default: |
| 1888 UNREACHABLE(); | 1898 UNREACHABLE(); |
| 1889 return false; | 1899 return false; |
| 1890 } | 1900 } |
| 1891 } | 1901 } |
| 1892 bool IsInFactoryScope() const; | 1902 bool IsInFactoryScope() const; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2067 bool IsImplicitSetterFunction() const { | 2077 bool IsImplicitSetterFunction() const { |
| 2068 return kind() == RawFunction::kImplicitSetter; | 2078 return kind() == RawFunction::kImplicitSetter; |
| 2069 } | 2079 } |
| 2070 | 2080 |
| 2071 // Returns true if this function represents a (possibly implicit) closure | 2081 // Returns true if this function represents a (possibly implicit) closure |
| 2072 // function. | 2082 // function. |
| 2073 bool IsClosureFunction() const { | 2083 bool IsClosureFunction() const { |
| 2074 return kind() == RawFunction::kClosureFunction; | 2084 return kind() == RawFunction::kClosureFunction; |
| 2075 } | 2085 } |
| 2076 | 2086 |
| 2087 // Returns true if this function represents a generated irregexp function. |
| 2088 bool IsIrregexpFunction() const { |
| 2089 return kind() == RawFunction::kIrregexpFunction; |
| 2090 } |
| 2091 |
| 2077 // Returns true if this function represents an implicit closure function. | 2092 // Returns true if this function represents an implicit closure function. |
| 2078 bool IsImplicitClosureFunction() const; | 2093 bool IsImplicitClosureFunction() const; |
| 2079 | 2094 |
| 2080 // Returns true if this function represents a non implicit closure function. | 2095 // Returns true if this function represents a non implicit closure function. |
| 2081 bool IsNonImplicitClosureFunction() const { | 2096 bool IsNonImplicitClosureFunction() const { |
| 2082 return IsClosureFunction() && !IsImplicitClosureFunction(); | 2097 return IsClosureFunction() && !IsImplicitClosureFunction(); |
| 2083 } | 2098 } |
| 2084 | 2099 |
| 2085 // Returns true if this function represents an implicit static closure | 2100 // Returns true if this function represents an implicit static closure |
| 2086 // function. | 2101 // function. |
| (...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4554 static intptr_t NextFieldOffset() { | 4569 static intptr_t NextFieldOffset() { |
| 4555 return sizeof(RawInstance); | 4570 return sizeof(RawInstance); |
| 4556 } | 4571 } |
| 4557 | 4572 |
| 4558 // TODO(iposva): Determine if this gets in the way of Smi. | 4573 // TODO(iposva): Determine if this gets in the way of Smi. |
| 4559 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); | 4574 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); |
| 4560 friend class ByteBuffer; | 4575 friend class ByteBuffer; |
| 4561 friend class Class; | 4576 friend class Class; |
| 4562 friend class Closure; | 4577 friend class Closure; |
| 4563 friend class DeferredObject; | 4578 friend class DeferredObject; |
| 4579 friend class JSRegExp; |
| 4564 friend class SnapshotWriter; | 4580 friend class SnapshotWriter; |
| 4565 friend class StubCode; | 4581 friend class StubCode; |
| 4566 friend class TypedDataView; | 4582 friend class TypedDataView; |
| 4567 }; | 4583 }; |
| 4568 | 4584 |
| 4569 | 4585 |
| 4570 class LibraryPrefix : public Instance { | 4586 class LibraryPrefix : public Instance { |
| 4571 public: | 4587 public: |
| 4572 RawString* name() const { return raw_ptr()->name_; } | 4588 RawString* name() const { return raw_ptr()->name_; } |
| 4573 virtual RawString* DictionaryName() const { return name(); } | 4589 virtual RawString* DictionaryName() const { return name(); } |
| (...skipping 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7231 | 7247 |
| 7232 bool is_initialized() const { return (type() != kUnitialized); } | 7248 bool is_initialized() const { return (type() != kUnitialized); } |
| 7233 bool is_simple() const { return (type() == kSimple); } | 7249 bool is_simple() const { return (type() == kSimple); } |
| 7234 bool is_complex() const { return (type() == kComplex); } | 7250 bool is_complex() const { return (type() == kComplex); } |
| 7235 | 7251 |
| 7236 bool is_global() const { return (flags() & kGlobal); } | 7252 bool is_global() const { return (flags() & kGlobal); } |
| 7237 bool is_ignore_case() const { return (flags() & kIgnoreCase); } | 7253 bool is_ignore_case() const { return (flags() & kIgnoreCase); } |
| 7238 bool is_multi_line() const { return (flags() & kMultiLine); } | 7254 bool is_multi_line() const { return (flags() & kMultiLine); } |
| 7239 | 7255 |
| 7240 RawString* pattern() const { return raw_ptr()->pattern_; } | 7256 RawString* pattern() const { return raw_ptr()->pattern_; } |
| 7257 |
| 7241 RawSmi* num_bracket_expressions() const { | 7258 RawSmi* num_bracket_expressions() const { |
| 7242 return raw_ptr()->num_bracket_expressions_; | 7259 return raw_ptr()->num_bracket_expressions_; |
| 7243 } | 7260 } |
| 7244 | 7261 |
| 7262 static intptr_t function_offset(intptr_t cid) { |
| 7263 switch (cid) { |
| 7264 case kOneByteStringCid: |
| 7265 return OFFSET_OF(RawJSRegExp, one_byte_function_); |
| 7266 case kTwoByteStringCid: |
| 7267 return OFFSET_OF(RawJSRegExp, two_byte_function_); |
| 7268 case kExternalOneByteStringCid: |
| 7269 return OFFSET_OF(RawJSRegExp, external_one_byte_function_); |
| 7270 case kExternalTwoByteStringCid: |
| 7271 return OFFSET_OF(RawJSRegExp, external_two_byte_function_); |
| 7272 } |
| 7273 |
| 7274 UNREACHABLE(); |
| 7275 return -1; |
| 7276 } |
| 7277 |
| 7278 RawFunction** FunctionAddr(intptr_t cid) const { |
| 7279 return reinterpret_cast<RawFunction**>( |
| 7280 FieldAddrAtOffset(function_offset(cid))); |
| 7281 } |
| 7282 |
| 7283 RawFunction* function(intptr_t cid) const { |
| 7284 return *FunctionAddr(cid); |
| 7285 } |
| 7286 |
| 7245 void set_pattern(const String& pattern) const; | 7287 void set_pattern(const String& pattern) const; |
| 7288 void set_function(intptr_t cid, const Function& value) const; |
| 7289 |
| 7246 void set_num_bracket_expressions(intptr_t value) const; | 7290 void set_num_bracket_expressions(intptr_t value) const; |
| 7247 void set_is_global() const { set_flags(flags() | kGlobal); } | 7291 void set_is_global() const { set_flags(flags() | kGlobal); } |
| 7248 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } | 7292 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } |
| 7249 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } | 7293 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } |
| 7250 void set_is_simple() const { set_type(kSimple); } | 7294 void set_is_simple() const { set_type(kSimple); } |
| 7251 void set_is_complex() const { set_type(kComplex); } | 7295 void set_is_complex() const { set_type(kComplex); } |
| 7252 | 7296 |
| 7253 void* GetDataStartAddress() const; | 7297 void* GetDataStartAddress() const; |
| 7254 static RawJSRegExp* FromDataStartAddress(void* data); | 7298 static RawJSRegExp* FromDataStartAddress(void* data); |
| 7255 const char* Flags() const; | 7299 const char* Flags() const; |
| 7256 | 7300 |
| 7257 virtual bool CanonicalizeEquals(const Instance& other) const; | 7301 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 7258 | 7302 |
| 7259 static const intptr_t kBytesPerElement = 1; | 7303 static const intptr_t kBytesPerElement = 1; |
| 7260 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 7304 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 7261 | 7305 |
| 7262 static intptr_t InstanceSize() { | 7306 static intptr_t InstanceSize() { |
| 7263 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); | 7307 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); |
| 7308 #ifdef USE_JSCRE |
| 7264 return 0; | 7309 return 0; |
| 7310 #else |
| 7311 return RoundedAllocationSize(sizeof(RawJSRegExp)); |
| 7312 #endif |
| 7265 } | 7313 } |
| 7266 | 7314 |
| 7267 static intptr_t InstanceSize(intptr_t len) { | 7315 static intptr_t InstanceSize(intptr_t len) { |
| 7268 ASSERT(0 <= len && len <= kMaxElements); | 7316 ASSERT(0 <= len && len <= kMaxElements); |
| 7269 return RoundedAllocationSize( | 7317 return RoundedAllocationSize( |
| 7270 sizeof(RawJSRegExp) + (len * kBytesPerElement)); | 7318 sizeof(RawJSRegExp) + (len * kBytesPerElement)); |
| 7271 } | 7319 } |
| 7272 | 7320 |
| 7273 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); | 7321 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); |
| 7274 | 7322 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7551 | 7599 |
| 7552 | 7600 |
| 7553 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7601 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 7554 intptr_t index) { | 7602 intptr_t index) { |
| 7555 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7603 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 7556 } | 7604 } |
| 7557 | 7605 |
| 7558 } // namespace dart | 7606 } // namespace dart |
| 7559 | 7607 |
| 7560 #endif // VM_OBJECT_H_ | 7608 #endif // VM_OBJECT_H_ |
| OLD | NEW |