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 2466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4553 static intptr_t NextFieldOffset() { | 4568 static intptr_t NextFieldOffset() { |
4554 return sizeof(RawInstance); | 4569 return sizeof(RawInstance); |
4555 } | 4570 } |
4556 | 4571 |
4557 // TODO(iposva): Determine if this gets in the way of Smi. | 4572 // TODO(iposva): Determine if this gets in the way of Smi. |
4558 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); | 4573 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); |
4559 friend class ByteBuffer; | 4574 friend class ByteBuffer; |
4560 friend class Class; | 4575 friend class Class; |
4561 friend class Closure; | 4576 friend class Closure; |
4562 friend class DeferredObject; | 4577 friend class DeferredObject; |
| 4578 friend class JSRegExp; |
4563 friend class SnapshotWriter; | 4579 friend class SnapshotWriter; |
4564 friend class StubCode; | 4580 friend class StubCode; |
4565 friend class TypedDataView; | 4581 friend class TypedDataView; |
4566 }; | 4582 }; |
4567 | 4583 |
4568 | 4584 |
4569 class LibraryPrefix : public Instance { | 4585 class LibraryPrefix : public Instance { |
4570 public: | 4586 public: |
4571 RawString* name() const { return raw_ptr()->name_; } | 4587 RawString* name() const { return raw_ptr()->name_; } |
4572 virtual RawString* DictionaryName() const { return name(); } | 4588 virtual RawString* DictionaryName() const { return name(); } |
(...skipping 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7230 | 7246 |
7231 bool is_initialized() const { return (type() != kUnitialized); } | 7247 bool is_initialized() const { return (type() != kUnitialized); } |
7232 bool is_simple() const { return (type() == kSimple); } | 7248 bool is_simple() const { return (type() == kSimple); } |
7233 bool is_complex() const { return (type() == kComplex); } | 7249 bool is_complex() const { return (type() == kComplex); } |
7234 | 7250 |
7235 bool is_global() const { return (flags() & kGlobal); } | 7251 bool is_global() const { return (flags() & kGlobal); } |
7236 bool is_ignore_case() const { return (flags() & kIgnoreCase); } | 7252 bool is_ignore_case() const { return (flags() & kIgnoreCase); } |
7237 bool is_multi_line() const { return (flags() & kMultiLine); } | 7253 bool is_multi_line() const { return (flags() & kMultiLine); } |
7238 | 7254 |
7239 RawString* pattern() const { return raw_ptr()->pattern_; } | 7255 RawString* pattern() const { return raw_ptr()->pattern_; } |
| 7256 |
7240 RawSmi* num_bracket_expressions() const { | 7257 RawSmi* num_bracket_expressions() const { |
7241 return raw_ptr()->num_bracket_expressions_; | 7258 return raw_ptr()->num_bracket_expressions_; |
7242 } | 7259 } |
7243 | 7260 |
| 7261 static intptr_t function_offset(intptr_t cid) { |
| 7262 switch (cid) { |
| 7263 case kOneByteStringCid: |
| 7264 return OFFSET_OF(RawJSRegExp, one_byte_function_); |
| 7265 case kTwoByteStringCid: |
| 7266 return OFFSET_OF(RawJSRegExp, two_byte_function_); |
| 7267 case kExternalOneByteStringCid: |
| 7268 return OFFSET_OF(RawJSRegExp, external_one_byte_function_); |
| 7269 case kExternalTwoByteStringCid: |
| 7270 return OFFSET_OF(RawJSRegExp, external_two_byte_function_); |
| 7271 } |
| 7272 |
| 7273 UNREACHABLE(); |
| 7274 return -1; |
| 7275 } |
| 7276 |
| 7277 RawFunction** FunctionAddr(intptr_t cid) const { |
| 7278 return reinterpret_cast<RawFunction**>( |
| 7279 FieldAddrAtOffset(function_offset(cid))); |
| 7280 } |
| 7281 |
| 7282 RawFunction* function(intptr_t cid) const { |
| 7283 return *FunctionAddr(cid); |
| 7284 } |
| 7285 |
7244 void set_pattern(const String& pattern) const; | 7286 void set_pattern(const String& pattern) const; |
| 7287 void set_function(intptr_t cid, const Function& value) const; |
| 7288 |
7245 void set_num_bracket_expressions(intptr_t value) const; | 7289 void set_num_bracket_expressions(intptr_t value) const; |
7246 void set_is_global() const { set_flags(flags() | kGlobal); } | 7290 void set_is_global() const { set_flags(flags() | kGlobal); } |
7247 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } | 7291 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } |
7248 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } | 7292 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } |
7249 void set_is_simple() const { set_type(kSimple); } | 7293 void set_is_simple() const { set_type(kSimple); } |
7250 void set_is_complex() const { set_type(kComplex); } | 7294 void set_is_complex() const { set_type(kComplex); } |
7251 | 7295 |
7252 void* GetDataStartAddress() const; | 7296 void* GetDataStartAddress() const; |
7253 static RawJSRegExp* FromDataStartAddress(void* data); | 7297 static RawJSRegExp* FromDataStartAddress(void* data); |
7254 const char* Flags() const; | 7298 const char* Flags() const; |
7255 | 7299 |
7256 virtual bool CanonicalizeEquals(const Instance& other) const; | 7300 virtual bool CanonicalizeEquals(const Instance& other) const; |
7257 | 7301 |
7258 static const intptr_t kBytesPerElement = 1; | 7302 static const intptr_t kBytesPerElement = 1; |
7259 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 7303 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
7260 | 7304 |
7261 static intptr_t InstanceSize() { | 7305 static intptr_t InstanceSize() { |
7262 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); | 7306 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); |
| 7307 #ifdef USE_JSCRE |
7263 return 0; | 7308 return 0; |
| 7309 #else |
| 7310 return RoundedAllocationSize(sizeof(RawJSRegExp)); |
| 7311 #endif |
7264 } | 7312 } |
7265 | 7313 |
7266 static intptr_t InstanceSize(intptr_t len) { | 7314 static intptr_t InstanceSize(intptr_t len) { |
7267 ASSERT(0 <= len && len <= kMaxElements); | 7315 ASSERT(0 <= len && len <= kMaxElements); |
7268 return RoundedAllocationSize( | 7316 return RoundedAllocationSize( |
7269 sizeof(RawJSRegExp) + (len * kBytesPerElement)); | 7317 sizeof(RawJSRegExp) + (len * kBytesPerElement)); |
7270 } | 7318 } |
7271 | 7319 |
7272 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); | 7320 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); |
7273 | 7321 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7550 | 7598 |
7551 | 7599 |
7552 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7600 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7553 intptr_t index) { | 7601 intptr_t index) { |
7554 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7602 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7555 } | 7603 } |
7556 | 7604 |
7557 } // namespace dart | 7605 } // namespace dart |
7558 | 7606 |
7559 #endif // VM_OBJECT_H_ | 7607 #endif // VM_OBJECT_H_ |
OLD | NEW |