| 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" |
| 11 #include "vm/json_stream.h" | 11 #include "vm/json_stream.h" |
| 12 #include "vm/bitmap.h" | 12 #include "vm/bitmap.h" |
| 13 #include "vm/dart.h" | 13 #include "vm/dart.h" |
| 14 #include "vm/globals.h" | 14 #include "vm/globals.h" |
| 15 #include "vm/handles.h" | 15 #include "vm/handles.h" |
| 16 #include "vm/heap.h" | 16 #include "vm/heap.h" |
| 17 #include "vm/isolate.h" | 17 #include "vm/isolate.h" |
| 18 #include "vm/method_recognizer.h" | 18 #include "vm/method_recognizer.h" |
| 19 #include "vm/os.h" | 19 #include "vm/os.h" |
| 20 #include "vm/raw_object.h" | 20 #include "vm/raw_object.h" |
| 21 #include "vm/report.h" | 21 #include "vm/report.h" |
| 22 #include "vm/scanner.h" | 22 #include "vm/scanner.h" |
| 23 #include "vm/tags.h" | 23 #include "vm/tags.h" |
| 24 #include "vm/verified_memory.h" | 24 #include "vm/verified_memory.h" |
| 25 | 25 |
| 26 namespace dart { | 26 namespace dart { |
| 27 | 27 |
| 28 DECLARE_FLAG(bool, use_jscre); | |
| 29 | |
| 30 // Forward declarations. | 28 // Forward declarations. |
| 31 #define DEFINE_FORWARD_DECLARATION(clazz) \ | 29 #define DEFINE_FORWARD_DECLARATION(clazz) \ |
| 32 class clazz; | 30 class clazz; |
| 33 CLASS_LIST(DEFINE_FORWARD_DECLARATION) | 31 CLASS_LIST(DEFINE_FORWARD_DECLARATION) |
| 34 #undef DEFINE_FORWARD_DECLARATION | 32 #undef DEFINE_FORWARD_DECLARATION |
| 35 class Api; | 33 class Api; |
| 36 class ArgumentsDescriptor; | 34 class ArgumentsDescriptor; |
| 37 class Assembler; | 35 class Assembler; |
| 38 class Closure; | 36 class Closure; |
| 39 class Code; | 37 class Code; |
| (...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1720 bool HasInstantiatedSignature() const; | 1718 bool HasInstantiatedSignature() const; |
| 1721 | 1719 |
| 1722 // Build a string of the form 'T, {b: B, c: C} representing the user | 1720 // Build a string of the form 'T, {b: B, c: C} representing the user |
| 1723 // visible formal parameters of the function. | 1721 // visible formal parameters of the function. |
| 1724 RawString* UserVisibleFormalParameters() const; | 1722 RawString* UserVisibleFormalParameters() const; |
| 1725 | 1723 |
| 1726 RawClass* Owner() const; | 1724 RawClass* Owner() const; |
| 1727 RawClass* origin() const; | 1725 RawClass* origin() const; |
| 1728 RawScript* script() const; | 1726 RawScript* script() const; |
| 1729 | 1727 |
| 1730 void set_regexp(const JSRegExp& value) const; | |
| 1731 RawJSRegExp* regexp() const; | |
| 1732 | |
| 1733 // Get and set the class id this function is specialized for. Only set for | |
| 1734 // irregexp functions. | |
| 1735 intptr_t regexp_cid() const { return raw_ptr()->regexp_cid_; } | |
| 1736 void set_regexp_cid(intptr_t regexp_cid) const; | |
| 1737 | |
| 1738 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } | 1728 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } |
| 1739 void set_result_type(const AbstractType& value) const; | 1729 void set_result_type(const AbstractType& value) const; |
| 1740 | 1730 |
| 1741 RawAbstractType* ParameterTypeAt(intptr_t index) const; | 1731 RawAbstractType* ParameterTypeAt(intptr_t index) const; |
| 1742 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; | 1732 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; |
| 1743 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; } | 1733 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; } |
| 1744 void set_parameter_types(const Array& value) const; | 1734 void set_parameter_types(const Array& value) const; |
| 1745 | 1735 |
| 1746 // Parameter names are valid for all valid parameter indices, and are not | 1736 // Parameter names are valid for all valid parameter indices, and are not |
| 1747 // limited to named optional parameters. | 1737 // limited to named optional parameters. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 case RawFunction::kSetterFunction: | 1847 case RawFunction::kSetterFunction: |
| 1858 case RawFunction::kImplicitGetter: | 1848 case RawFunction::kImplicitGetter: |
| 1859 case RawFunction::kImplicitSetter: | 1849 case RawFunction::kImplicitSetter: |
| 1860 case RawFunction::kMethodExtractor: | 1850 case RawFunction::kMethodExtractor: |
| 1861 case RawFunction::kNoSuchMethodDispatcher: | 1851 case RawFunction::kNoSuchMethodDispatcher: |
| 1862 case RawFunction::kInvokeFieldDispatcher: | 1852 case RawFunction::kInvokeFieldDispatcher: |
| 1863 return true; | 1853 return true; |
| 1864 case RawFunction::kClosureFunction: | 1854 case RawFunction::kClosureFunction: |
| 1865 case RawFunction::kConstructor: | 1855 case RawFunction::kConstructor: |
| 1866 case RawFunction::kImplicitStaticFinalGetter: | 1856 case RawFunction::kImplicitStaticFinalGetter: |
| 1867 case RawFunction::kIrregexpFunction: | |
| 1868 return false; | 1857 return false; |
| 1869 default: | 1858 default: |
| 1870 UNREACHABLE(); | 1859 UNREACHABLE(); |
| 1871 return false; | 1860 return false; |
| 1872 } | 1861 } |
| 1873 } | 1862 } |
| 1874 bool IsStaticFunction() const { | 1863 bool IsStaticFunction() const { |
| 1875 if (!is_static()) { | 1864 if (!is_static()) { |
| 1876 return false; | 1865 return false; |
| 1877 } | 1866 } |
| 1878 switch (kind()) { | 1867 switch (kind()) { |
| 1879 case RawFunction::kRegularFunction: | 1868 case RawFunction::kRegularFunction: |
| 1880 case RawFunction::kGetterFunction: | 1869 case RawFunction::kGetterFunction: |
| 1881 case RawFunction::kSetterFunction: | 1870 case RawFunction::kSetterFunction: |
| 1882 case RawFunction::kImplicitGetter: | 1871 case RawFunction::kImplicitGetter: |
| 1883 case RawFunction::kImplicitSetter: | 1872 case RawFunction::kImplicitSetter: |
| 1884 case RawFunction::kImplicitStaticFinalGetter: | 1873 case RawFunction::kImplicitStaticFinalGetter: |
| 1885 case RawFunction::kIrregexpFunction: | |
| 1886 return true; | 1874 return true; |
| 1887 case RawFunction::kClosureFunction: | 1875 case RawFunction::kClosureFunction: |
| 1888 case RawFunction::kConstructor: | 1876 case RawFunction::kConstructor: |
| 1889 return false; | 1877 return false; |
| 1890 default: | 1878 default: |
| 1891 UNREACHABLE(); | 1879 UNREACHABLE(); |
| 1892 return false; | 1880 return false; |
| 1893 } | 1881 } |
| 1894 } | 1882 } |
| 1895 bool IsInFactoryScope() const; | 1883 bool IsInFactoryScope() const; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2070 bool IsImplicitSetterFunction() const { | 2058 bool IsImplicitSetterFunction() const { |
| 2071 return kind() == RawFunction::kImplicitSetter; | 2059 return kind() == RawFunction::kImplicitSetter; |
| 2072 } | 2060 } |
| 2073 | 2061 |
| 2074 // Returns true if this function represents a (possibly implicit) closure | 2062 // Returns true if this function represents a (possibly implicit) closure |
| 2075 // function. | 2063 // function. |
| 2076 bool IsClosureFunction() const { | 2064 bool IsClosureFunction() const { |
| 2077 return kind() == RawFunction::kClosureFunction; | 2065 return kind() == RawFunction::kClosureFunction; |
| 2078 } | 2066 } |
| 2079 | 2067 |
| 2080 // Returns true if this function represents a generated irregexp function. | |
| 2081 bool IsIrregexpFunction() const { | |
| 2082 return kind() == RawFunction::kIrregexpFunction; | |
| 2083 } | |
| 2084 | |
| 2085 // Returns true if this function represents an implicit closure function. | 2068 // Returns true if this function represents an implicit closure function. |
| 2086 bool IsImplicitClosureFunction() const; | 2069 bool IsImplicitClosureFunction() const; |
| 2087 | 2070 |
| 2088 // Returns true if this function represents a non implicit closure function. | 2071 // Returns true if this function represents a non implicit closure function. |
| 2089 bool IsNonImplicitClosureFunction() const { | 2072 bool IsNonImplicitClosureFunction() const { |
| 2090 return IsClosureFunction() && !IsImplicitClosureFunction(); | 2073 return IsClosureFunction() && !IsImplicitClosureFunction(); |
| 2091 } | 2074 } |
| 2092 | 2075 |
| 2093 // Returns true if this function represents an implicit static closure | 2076 // Returns true if this function represents an implicit static closure |
| 2094 // function. | 2077 // function. |
| (...skipping 2463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4558 static intptr_t NextFieldOffset() { | 4541 static intptr_t NextFieldOffset() { |
| 4559 return sizeof(RawInstance); | 4542 return sizeof(RawInstance); |
| 4560 } | 4543 } |
| 4561 | 4544 |
| 4562 // TODO(iposva): Determine if this gets in the way of Smi. | 4545 // TODO(iposva): Determine if this gets in the way of Smi. |
| 4563 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); | 4546 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); |
| 4564 friend class ByteBuffer; | 4547 friend class ByteBuffer; |
| 4565 friend class Class; | 4548 friend class Class; |
| 4566 friend class Closure; | 4549 friend class Closure; |
| 4567 friend class DeferredObject; | 4550 friend class DeferredObject; |
| 4568 friend class JSRegExp; | |
| 4569 friend class SnapshotWriter; | 4551 friend class SnapshotWriter; |
| 4570 friend class StubCode; | 4552 friend class StubCode; |
| 4571 friend class TypedDataView; | 4553 friend class TypedDataView; |
| 4572 }; | 4554 }; |
| 4573 | 4555 |
| 4574 | 4556 |
| 4575 class LibraryPrefix : public Instance { | 4557 class LibraryPrefix : public Instance { |
| 4576 public: | 4558 public: |
| 4577 RawString* name() const { return raw_ptr()->name_; } | 4559 RawString* name() const { return raw_ptr()->name_; } |
| 4578 virtual RawString* DictionaryName() const { return name(); } | 4560 virtual RawString* DictionaryName() const { return name(); } |
| (...skipping 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7236 | 7218 |
| 7237 bool is_global() const { return (flags() & kGlobal); } | 7219 bool is_global() const { return (flags() & kGlobal); } |
| 7238 bool is_ignore_case() const { return (flags() & kIgnoreCase); } | 7220 bool is_ignore_case() const { return (flags() & kIgnoreCase); } |
| 7239 bool is_multi_line() const { return (flags() & kMultiLine); } | 7221 bool is_multi_line() const { return (flags() & kMultiLine); } |
| 7240 | 7222 |
| 7241 RawString* pattern() const { return raw_ptr()->pattern_; } | 7223 RawString* pattern() const { return raw_ptr()->pattern_; } |
| 7242 RawSmi* num_bracket_expressions() const { | 7224 RawSmi* num_bracket_expressions() const { |
| 7243 return raw_ptr()->num_bracket_expressions_; | 7225 return raw_ptr()->num_bracket_expressions_; |
| 7244 } | 7226 } |
| 7245 | 7227 |
| 7246 static intptr_t function_offset(intptr_t cid) { | |
| 7247 switch (cid) { | |
| 7248 case kOneByteStringCid: | |
| 7249 return OFFSET_OF(RawJSRegExp, one_byte_function_); | |
| 7250 case kTwoByteStringCid: | |
| 7251 return OFFSET_OF(RawJSRegExp, two_byte_function_); | |
| 7252 case kExternalOneByteStringCid: | |
| 7253 return OFFSET_OF(RawJSRegExp, external_one_byte_function_); | |
| 7254 case kExternalTwoByteStringCid: | |
| 7255 return OFFSET_OF(RawJSRegExp, external_two_byte_function_); | |
| 7256 } | |
| 7257 | |
| 7258 UNREACHABLE(); | |
| 7259 return -1; | |
| 7260 } | |
| 7261 | |
| 7262 RawFunction** FunctionAddr(intptr_t cid) const { | |
| 7263 return reinterpret_cast<RawFunction**>( | |
| 7264 FieldAddrAtOffset(function_offset(cid))); | |
| 7265 } | |
| 7266 | |
| 7267 RawFunction* function(intptr_t cid) const { | |
| 7268 return *FunctionAddr(cid); | |
| 7269 } | |
| 7270 | |
| 7271 void set_pattern(const String& pattern) const; | 7228 void set_pattern(const String& pattern) const; |
| 7272 void set_function(intptr_t cid, const Function& value) const; | |
| 7273 | |
| 7274 void set_num_bracket_expressions(intptr_t value) const; | 7229 void set_num_bracket_expressions(intptr_t value) const; |
| 7275 void set_is_global() const { set_flags(flags() | kGlobal); } | 7230 void set_is_global() const { set_flags(flags() | kGlobal); } |
| 7276 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } | 7231 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } |
| 7277 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } | 7232 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } |
| 7278 void set_is_simple() const { set_type(kSimple); } | 7233 void set_is_simple() const { set_type(kSimple); } |
| 7279 void set_is_complex() const { set_type(kComplex); } | 7234 void set_is_complex() const { set_type(kComplex); } |
| 7280 | 7235 |
| 7281 void* GetDataStartAddress() const; | 7236 void* GetDataStartAddress() const; |
| 7282 static RawJSRegExp* FromDataStartAddress(void* data); | 7237 static RawJSRegExp* FromDataStartAddress(void* data); |
| 7283 const char* Flags() const; | 7238 const char* Flags() const; |
| 7284 | 7239 |
| 7285 virtual bool CanonicalizeEquals(const Instance& other) const; | 7240 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 7286 | 7241 |
| 7287 static const intptr_t kBytesPerElement = 1; | 7242 static const intptr_t kBytesPerElement = 1; |
| 7288 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 7243 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 7289 | 7244 |
| 7290 static intptr_t InstanceSize() { | 7245 static intptr_t InstanceSize() { |
| 7291 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); | 7246 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); |
| 7292 if (FLAG_use_jscre) { | 7247 return 0; |
| 7293 return 0; | |
| 7294 } | |
| 7295 return RoundedAllocationSize(sizeof(RawJSRegExp)); | |
| 7296 } | 7248 } |
| 7297 | 7249 |
| 7298 static intptr_t InstanceSize(intptr_t len) { | 7250 static intptr_t InstanceSize(intptr_t len) { |
| 7299 ASSERT(0 <= len && len <= kMaxElements); | 7251 ASSERT(0 <= len && len <= kMaxElements); |
| 7300 return RoundedAllocationSize( | 7252 return RoundedAllocationSize( |
| 7301 sizeof(RawJSRegExp) + (len * kBytesPerElement)); | 7253 sizeof(RawJSRegExp) + (len * kBytesPerElement)); |
| 7302 } | 7254 } |
| 7303 | 7255 |
| 7304 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); | 7256 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); |
| 7305 | 7257 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7582 | 7534 |
| 7583 | 7535 |
| 7584 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7536 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 7585 intptr_t index) { | 7537 intptr_t index) { |
| 7586 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7538 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 7587 } | 7539 } |
| 7588 | 7540 |
| 7589 } // namespace dart | 7541 } // namespace dart |
| 7590 | 7542 |
| 7591 #endif // VM_OBJECT_H_ | 7543 #endif // VM_OBJECT_H_ |
| OLD | NEW |