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