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