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 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 bool HasInstantiatedSignature() const; | 1658 bool HasInstantiatedSignature() const; |
1659 | 1659 |
1660 // Build a string of the form 'T, {b: B, c: C} representing the user | 1660 // Build a string of the form 'T, {b: B, c: C} representing the user |
1661 // visible formal parameters of the function. | 1661 // visible formal parameters of the function. |
1662 RawString* UserVisibleFormalParameters() const; | 1662 RawString* UserVisibleFormalParameters() const; |
1663 | 1663 |
1664 RawClass* Owner() const; | 1664 RawClass* Owner() const; |
1665 RawClass* origin() const; | 1665 RawClass* origin() const; |
1666 RawScript* script() const; | 1666 RawScript* script() const; |
1667 | 1667 |
| 1668 void set_regexp(const JSRegExp& value) const; |
| 1669 RawJSRegExp* regexp() const; |
| 1670 |
| 1671 // Set and get the class id this function is specialized for. Only set for |
| 1672 // irregexp functions. |
| 1673 void set_regexp_cid(intptr_t regexp_cid) { |
| 1674 raw_ptr()->regexp_cid_ = regexp_cid; |
| 1675 } |
| 1676 intptr_t regexp_cid() const { |
| 1677 return raw_ptr()->regexp_cid_; |
| 1678 } |
| 1679 |
1668 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } | 1680 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } |
1669 void set_result_type(const AbstractType& value) const; | 1681 void set_result_type(const AbstractType& value) const; |
1670 | 1682 |
1671 RawAbstractType* ParameterTypeAt(intptr_t index) const; | 1683 RawAbstractType* ParameterTypeAt(intptr_t index) const; |
1672 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; | 1684 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; |
1673 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; } | 1685 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; } |
1674 void set_parameter_types(const Array& value) const; | 1686 void set_parameter_types(const Array& value) const; |
1675 | 1687 |
1676 // Parameter names are valid for all valid parameter indices, and are not | 1688 // Parameter names are valid for all valid parameter indices, and are not |
1677 // limited to named optional parameters. | 1689 // limited to named optional parameters. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 } | 1798 } |
1787 switch (kind()) { | 1799 switch (kind()) { |
1788 case RawFunction::kRegularFunction: | 1800 case RawFunction::kRegularFunction: |
1789 case RawFunction::kGetterFunction: | 1801 case RawFunction::kGetterFunction: |
1790 case RawFunction::kSetterFunction: | 1802 case RawFunction::kSetterFunction: |
1791 case RawFunction::kImplicitGetter: | 1803 case RawFunction::kImplicitGetter: |
1792 case RawFunction::kImplicitSetter: | 1804 case RawFunction::kImplicitSetter: |
1793 case RawFunction::kMethodExtractor: | 1805 case RawFunction::kMethodExtractor: |
1794 case RawFunction::kNoSuchMethodDispatcher: | 1806 case RawFunction::kNoSuchMethodDispatcher: |
1795 case RawFunction::kInvokeFieldDispatcher: | 1807 case RawFunction::kInvokeFieldDispatcher: |
| 1808 case RawFunction::kIrregexpFunction: |
1796 return true; | 1809 return true; |
1797 case RawFunction::kClosureFunction: | 1810 case RawFunction::kClosureFunction: |
1798 case RawFunction::kConstructor: | 1811 case RawFunction::kConstructor: |
1799 case RawFunction::kImplicitStaticFinalGetter: | 1812 case RawFunction::kImplicitStaticFinalGetter: |
1800 return false; | 1813 return false; |
1801 default: | 1814 default: |
1802 UNREACHABLE(); | 1815 UNREACHABLE(); |
1803 return false; | 1816 return false; |
1804 } | 1817 } |
1805 } | 1818 } |
1806 bool IsStaticFunction() const { | 1819 bool IsStaticFunction() const { |
1807 if (!is_static()) { | 1820 if (!is_static()) { |
1808 return false; | 1821 return false; |
1809 } | 1822 } |
1810 switch (kind()) { | 1823 switch (kind()) { |
1811 case RawFunction::kRegularFunction: | 1824 case RawFunction::kRegularFunction: |
1812 case RawFunction::kGetterFunction: | 1825 case RawFunction::kGetterFunction: |
1813 case RawFunction::kSetterFunction: | 1826 case RawFunction::kSetterFunction: |
1814 case RawFunction::kImplicitGetter: | 1827 case RawFunction::kImplicitGetter: |
1815 case RawFunction::kImplicitSetter: | 1828 case RawFunction::kImplicitSetter: |
1816 case RawFunction::kImplicitStaticFinalGetter: | 1829 case RawFunction::kImplicitStaticFinalGetter: |
| 1830 case RawFunction::kIrregexpFunction: |
1817 return true; | 1831 return true; |
1818 case RawFunction::kClosureFunction: | 1832 case RawFunction::kClosureFunction: |
1819 case RawFunction::kConstructor: | 1833 case RawFunction::kConstructor: |
1820 return false; | 1834 return false; |
1821 default: | 1835 default: |
1822 UNREACHABLE(); | 1836 UNREACHABLE(); |
1823 return false; | 1837 return false; |
1824 } | 1838 } |
1825 } | 1839 } |
1826 bool IsInFactoryScope() const; | 1840 bool IsInFactoryScope() const; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 bool IsImplicitSetterFunction() const { | 2062 bool IsImplicitSetterFunction() const { |
2049 return kind() == RawFunction::kImplicitSetter; | 2063 return kind() == RawFunction::kImplicitSetter; |
2050 } | 2064 } |
2051 | 2065 |
2052 // Returns true if this function represents a (possibly implicit) closure | 2066 // Returns true if this function represents a (possibly implicit) closure |
2053 // function. | 2067 // function. |
2054 bool IsClosureFunction() const { | 2068 bool IsClosureFunction() const { |
2055 return kind() == RawFunction::kClosureFunction; | 2069 return kind() == RawFunction::kClosureFunction; |
2056 } | 2070 } |
2057 | 2071 |
| 2072 // Returns true if this function represents a generated irregexp function. |
| 2073 bool IsIrregexpFunction() const { |
| 2074 return kind() == RawFunction::kIrregexpFunction; |
| 2075 } |
| 2076 |
2058 // Returns true if this function represents an implicit closure function. | 2077 // Returns true if this function represents an implicit closure function. |
2059 bool IsImplicitClosureFunction() const; | 2078 bool IsImplicitClosureFunction() const; |
2060 | 2079 |
2061 // Returns true if this function represents a non implicit closure function. | 2080 // Returns true if this function represents a non implicit closure function. |
2062 bool IsNonImplicitClosureFunction() const { | 2081 bool IsNonImplicitClosureFunction() const { |
2063 return IsClosureFunction() && !IsImplicitClosureFunction(); | 2082 return IsClosureFunction() && !IsImplicitClosureFunction(); |
2064 } | 2083 } |
2065 | 2084 |
2066 // Returns true if this function represents an implicit static closure | 2085 // Returns true if this function represents an implicit static closure |
2067 // function. | 2086 // function. |
(...skipping 2457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4525 static intptr_t NextFieldOffset() { | 4544 static intptr_t NextFieldOffset() { |
4526 return sizeof(RawInstance); | 4545 return sizeof(RawInstance); |
4527 } | 4546 } |
4528 | 4547 |
4529 // TODO(iposva): Determine if this gets in the way of Smi. | 4548 // TODO(iposva): Determine if this gets in the way of Smi. |
4530 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); | 4549 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); |
4531 friend class ByteBuffer; | 4550 friend class ByteBuffer; |
4532 friend class Class; | 4551 friend class Class; |
4533 friend class Closure; | 4552 friend class Closure; |
4534 friend class DeferredObject; | 4553 friend class DeferredObject; |
| 4554 friend class JSRegExp; |
4535 friend class SnapshotWriter; | 4555 friend class SnapshotWriter; |
4536 friend class StubCode; | 4556 friend class StubCode; |
4537 friend class TypedDataView; | 4557 friend class TypedDataView; |
4538 }; | 4558 }; |
4539 | 4559 |
4540 | 4560 |
4541 class LibraryPrefix : public Instance { | 4561 class LibraryPrefix : public Instance { |
4542 public: | 4562 public: |
4543 RawString* name() const { return raw_ptr()->name_; } | 4563 RawString* name() const { return raw_ptr()->name_; } |
4544 virtual RawString* DictionaryName() const { return name(); } | 4564 virtual RawString* DictionaryName() const { return name(); } |
(...skipping 2648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7193 | 7213 |
7194 bool is_initialized() const { return (type() != kUnitialized); } | 7214 bool is_initialized() const { return (type() != kUnitialized); } |
7195 bool is_simple() const { return (type() == kSimple); } | 7215 bool is_simple() const { return (type() == kSimple); } |
7196 bool is_complex() const { return (type() == kComplex); } | 7216 bool is_complex() const { return (type() == kComplex); } |
7197 | 7217 |
7198 bool is_global() const { return (flags() & kGlobal); } | 7218 bool is_global() const { return (flags() & kGlobal); } |
7199 bool is_ignore_case() const { return (flags() & kIgnoreCase); } | 7219 bool is_ignore_case() const { return (flags() & kIgnoreCase); } |
7200 bool is_multi_line() const { return (flags() & kMultiLine); } | 7220 bool is_multi_line() const { return (flags() & kMultiLine); } |
7201 | 7221 |
7202 RawString* pattern() const { return raw_ptr()->pattern_; } | 7222 RawString* pattern() const { return raw_ptr()->pattern_; } |
| 7223 |
7203 RawSmi* num_bracket_expressions() const { | 7224 RawSmi* num_bracket_expressions() const { |
7204 return raw_ptr()->num_bracket_expressions_; | 7225 return raw_ptr()->num_bracket_expressions_; |
7205 } | 7226 } |
7206 | 7227 |
| 7228 static intptr_t function_offset(intptr_t cid) { |
| 7229 switch (cid) { |
| 7230 case kOneByteStringCid: |
| 7231 return OFFSET_OF(RawJSRegExp, one_byte_function_); |
| 7232 case kTwoByteStringCid: |
| 7233 return OFFSET_OF(RawJSRegExp, two_byte_function_); |
| 7234 case kExternalOneByteStringCid: |
| 7235 return OFFSET_OF(RawJSRegExp, external_one_byte_function_); |
| 7236 case kExternalTwoByteStringCid: |
| 7237 return OFFSET_OF(RawJSRegExp, external_two_byte_function_); |
| 7238 } |
| 7239 |
| 7240 UNREACHABLE(); |
| 7241 return -1; |
| 7242 } |
| 7243 |
| 7244 RawFunction** FunctionAddr(intptr_t cid) const { |
| 7245 return reinterpret_cast<RawFunction**>( |
| 7246 FieldAddrAtOffset(function_offset(cid))); |
| 7247 } |
| 7248 |
| 7249 RawFunction* function(intptr_t cid) const { |
| 7250 return *FunctionAddr(cid); |
| 7251 } |
| 7252 |
7207 void set_pattern(const String& pattern) const; | 7253 void set_pattern(const String& pattern) const; |
| 7254 void set_function(intptr_t cid, const Function& value); |
| 7255 void set_sample_subject(intptr_t cid, const String& value) const; |
| 7256 |
7208 void set_num_bracket_expressions(intptr_t value) const; | 7257 void set_num_bracket_expressions(intptr_t value) const; |
7209 void set_is_global() const { set_flags(flags() | kGlobal); } | 7258 void set_is_global() const { set_flags(flags() | kGlobal); } |
7210 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } | 7259 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } |
7211 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } | 7260 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } |
7212 void set_is_simple() const { set_type(kSimple); } | 7261 void set_is_simple() const { set_type(kSimple); } |
7213 void set_is_complex() const { set_type(kComplex); } | 7262 void set_is_complex() const { set_type(kComplex); } |
7214 | 7263 |
7215 void* GetDataStartAddress() const; | 7264 void* GetDataStartAddress() const; |
7216 static RawJSRegExp* FromDataStartAddress(void* data); | 7265 static RawJSRegExp* FromDataStartAddress(void* data); |
7217 const char* Flags() const; | 7266 const char* Flags() const; |
7218 | 7267 |
7219 virtual bool CanonicalizeEquals(const Instance& other) const; | 7268 virtual bool CanonicalizeEquals(const Instance& other) const; |
7220 | 7269 |
7221 static const intptr_t kBytesPerElement = 1; | 7270 static const intptr_t kBytesPerElement = 1; |
7222 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 7271 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
7223 | 7272 |
7224 static intptr_t InstanceSize() { | 7273 static intptr_t InstanceSize() { |
7225 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); | 7274 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); |
| 7275 #ifdef USE_JSCRE |
7226 return 0; | 7276 return 0; |
| 7277 #else |
| 7278 return RoundedAllocationSize(sizeof(RawJSRegExp)); |
| 7279 #endif |
7227 } | 7280 } |
7228 | 7281 |
7229 static intptr_t InstanceSize(intptr_t len) { | 7282 static intptr_t InstanceSize(intptr_t len) { |
7230 ASSERT(0 <= len && len <= kMaxElements); | 7283 ASSERT(0 <= len && len <= kMaxElements); |
7231 return RoundedAllocationSize( | 7284 return RoundedAllocationSize( |
7232 sizeof(RawJSRegExp) + (len * kBytesPerElement)); | 7285 sizeof(RawJSRegExp) + (len * kBytesPerElement)); |
7233 } | 7286 } |
7234 | 7287 |
7235 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); | 7288 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); |
7236 | 7289 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7513 | 7566 |
7514 | 7567 |
7515 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7568 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7516 intptr_t index) { | 7569 intptr_t index) { |
7517 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7570 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7518 } | 7571 } |
7519 | 7572 |
7520 } // namespace dart | 7573 } // namespace dart |
7521 | 7574 |
7522 #endif // VM_OBJECT_H_ | 7575 #endif // VM_OBJECT_H_ |
OLD | NEW |