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 | 24 |
25 namespace dart { | 25 namespace dart { |
26 | 26 |
| 27 DECLARE_FLAG(bool, use_jscre); |
| 28 |
27 // Forward declarations. | 29 // Forward declarations. |
28 #define DEFINE_FORWARD_DECLARATION(clazz) \ | 30 #define DEFINE_FORWARD_DECLARATION(clazz) \ |
29 class clazz; | 31 class clazz; |
30 CLASS_LIST(DEFINE_FORWARD_DECLARATION) | 32 CLASS_LIST(DEFINE_FORWARD_DECLARATION) |
31 #undef DEFINE_FORWARD_DECLARATION | 33 #undef DEFINE_FORWARD_DECLARATION |
32 class Api; | 34 class Api; |
33 class ArgumentsDescriptor; | 35 class ArgumentsDescriptor; |
34 class Assembler; | 36 class Assembler; |
35 class Closure; | 37 class Closure; |
36 class Code; | 38 class Code; |
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 bool HasInstantiatedSignature() const; | 1729 bool HasInstantiatedSignature() const; |
1728 | 1730 |
1729 // Build a string of the form 'T, {b: B, c: C} representing the user | 1731 // Build a string of the form 'T, {b: B, c: C} representing the user |
1730 // visible formal parameters of the function. | 1732 // visible formal parameters of the function. |
1731 RawString* UserVisibleFormalParameters() const; | 1733 RawString* UserVisibleFormalParameters() const; |
1732 | 1734 |
1733 RawClass* Owner() const; | 1735 RawClass* Owner() const; |
1734 RawClass* origin() const; | 1736 RawClass* origin() const; |
1735 RawScript* script() const; | 1737 RawScript* script() const; |
1736 | 1738 |
| 1739 void set_regexp(const JSRegExp& value) const; |
| 1740 RawJSRegExp* regexp() const; |
| 1741 |
| 1742 // Get and set the class id this function is specialized for. Only set for |
| 1743 // irregexp functions. |
| 1744 intptr_t regexp_cid() const { return raw_ptr()->regexp_cid_; } |
| 1745 void set_regexp_cid(intptr_t regexp_cid) const; |
| 1746 |
1737 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } | 1747 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } |
1738 void set_result_type(const AbstractType& value) const; | 1748 void set_result_type(const AbstractType& value) const; |
1739 | 1749 |
1740 RawAbstractType* ParameterTypeAt(intptr_t index) const; | 1750 RawAbstractType* ParameterTypeAt(intptr_t index) const; |
1741 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; | 1751 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; |
1742 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; } | 1752 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; } |
1743 void set_parameter_types(const Array& value) const; | 1753 void set_parameter_types(const Array& value) const; |
1744 | 1754 |
1745 // Parameter names are valid for all valid parameter indices, and are not | 1755 // Parameter names are valid for all valid parameter indices, and are not |
1746 // limited to named optional parameters. | 1756 // limited to named optional parameters. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1856 case RawFunction::kSetterFunction: | 1866 case RawFunction::kSetterFunction: |
1857 case RawFunction::kImplicitGetter: | 1867 case RawFunction::kImplicitGetter: |
1858 case RawFunction::kImplicitSetter: | 1868 case RawFunction::kImplicitSetter: |
1859 case RawFunction::kMethodExtractor: | 1869 case RawFunction::kMethodExtractor: |
1860 case RawFunction::kNoSuchMethodDispatcher: | 1870 case RawFunction::kNoSuchMethodDispatcher: |
1861 case RawFunction::kInvokeFieldDispatcher: | 1871 case RawFunction::kInvokeFieldDispatcher: |
1862 return true; | 1872 return true; |
1863 case RawFunction::kClosureFunction: | 1873 case RawFunction::kClosureFunction: |
1864 case RawFunction::kConstructor: | 1874 case RawFunction::kConstructor: |
1865 case RawFunction::kImplicitStaticFinalGetter: | 1875 case RawFunction::kImplicitStaticFinalGetter: |
| 1876 case RawFunction::kIrregexpFunction: |
1866 return false; | 1877 return false; |
1867 default: | 1878 default: |
1868 UNREACHABLE(); | 1879 UNREACHABLE(); |
1869 return false; | 1880 return false; |
1870 } | 1881 } |
1871 } | 1882 } |
1872 bool IsStaticFunction() const { | 1883 bool IsStaticFunction() const { |
1873 if (!is_static()) { | 1884 if (!is_static()) { |
1874 return false; | 1885 return false; |
1875 } | 1886 } |
1876 switch (kind()) { | 1887 switch (kind()) { |
1877 case RawFunction::kRegularFunction: | 1888 case RawFunction::kRegularFunction: |
1878 case RawFunction::kGetterFunction: | 1889 case RawFunction::kGetterFunction: |
1879 case RawFunction::kSetterFunction: | 1890 case RawFunction::kSetterFunction: |
1880 case RawFunction::kImplicitGetter: | 1891 case RawFunction::kImplicitGetter: |
1881 case RawFunction::kImplicitSetter: | 1892 case RawFunction::kImplicitSetter: |
1882 case RawFunction::kImplicitStaticFinalGetter: | 1893 case RawFunction::kImplicitStaticFinalGetter: |
| 1894 case RawFunction::kIrregexpFunction: |
1883 return true; | 1895 return true; |
1884 case RawFunction::kClosureFunction: | 1896 case RawFunction::kClosureFunction: |
1885 case RawFunction::kConstructor: | 1897 case RawFunction::kConstructor: |
1886 return false; | 1898 return false; |
1887 default: | 1899 default: |
1888 UNREACHABLE(); | 1900 UNREACHABLE(); |
1889 return false; | 1901 return false; |
1890 } | 1902 } |
1891 } | 1903 } |
1892 bool IsInFactoryScope() const; | 1904 bool IsInFactoryScope() const; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2067 bool IsImplicitSetterFunction() const { | 2079 bool IsImplicitSetterFunction() const { |
2068 return kind() == RawFunction::kImplicitSetter; | 2080 return kind() == RawFunction::kImplicitSetter; |
2069 } | 2081 } |
2070 | 2082 |
2071 // Returns true if this function represents a (possibly implicit) closure | 2083 // Returns true if this function represents a (possibly implicit) closure |
2072 // function. | 2084 // function. |
2073 bool IsClosureFunction() const { | 2085 bool IsClosureFunction() const { |
2074 return kind() == RawFunction::kClosureFunction; | 2086 return kind() == RawFunction::kClosureFunction; |
2075 } | 2087 } |
2076 | 2088 |
| 2089 // Returns true if this function represents a generated irregexp function. |
| 2090 bool IsIrregexpFunction() const { |
| 2091 return kind() == RawFunction::kIrregexpFunction; |
| 2092 } |
| 2093 |
2077 // Returns true if this function represents an implicit closure function. | 2094 // Returns true if this function represents an implicit closure function. |
2078 bool IsImplicitClosureFunction() const; | 2095 bool IsImplicitClosureFunction() const; |
2079 | 2096 |
2080 // Returns true if this function represents a non implicit closure function. | 2097 // Returns true if this function represents a non implicit closure function. |
2081 bool IsNonImplicitClosureFunction() const { | 2098 bool IsNonImplicitClosureFunction() const { |
2082 return IsClosureFunction() && !IsImplicitClosureFunction(); | 2099 return IsClosureFunction() && !IsImplicitClosureFunction(); |
2083 } | 2100 } |
2084 | 2101 |
2085 // Returns true if this function represents an implicit static closure | 2102 // Returns true if this function represents an implicit static closure |
2086 // function. | 2103 // function. |
(...skipping 2466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4553 static intptr_t NextFieldOffset() { | 4570 static intptr_t NextFieldOffset() { |
4554 return sizeof(RawInstance); | 4571 return sizeof(RawInstance); |
4555 } | 4572 } |
4556 | 4573 |
4557 // TODO(iposva): Determine if this gets in the way of Smi. | 4574 // TODO(iposva): Determine if this gets in the way of Smi. |
4558 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); | 4575 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); |
4559 friend class ByteBuffer; | 4576 friend class ByteBuffer; |
4560 friend class Class; | 4577 friend class Class; |
4561 friend class Closure; | 4578 friend class Closure; |
4562 friend class DeferredObject; | 4579 friend class DeferredObject; |
| 4580 friend class JSRegExp; |
4563 friend class SnapshotWriter; | 4581 friend class SnapshotWriter; |
4564 friend class StubCode; | 4582 friend class StubCode; |
4565 friend class TypedDataView; | 4583 friend class TypedDataView; |
4566 }; | 4584 }; |
4567 | 4585 |
4568 | 4586 |
4569 class LibraryPrefix : public Instance { | 4587 class LibraryPrefix : public Instance { |
4570 public: | 4588 public: |
4571 RawString* name() const { return raw_ptr()->name_; } | 4589 RawString* name() const { return raw_ptr()->name_; } |
4572 virtual RawString* DictionaryName() const { return name(); } | 4590 virtual RawString* DictionaryName() const { return name(); } |
(...skipping 2661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7234 | 7252 |
7235 bool is_global() const { return (flags() & kGlobal); } | 7253 bool is_global() const { return (flags() & kGlobal); } |
7236 bool is_ignore_case() const { return (flags() & kIgnoreCase); } | 7254 bool is_ignore_case() const { return (flags() & kIgnoreCase); } |
7237 bool is_multi_line() const { return (flags() & kMultiLine); } | 7255 bool is_multi_line() const { return (flags() & kMultiLine); } |
7238 | 7256 |
7239 RawString* pattern() const { return raw_ptr()->pattern_; } | 7257 RawString* pattern() const { return raw_ptr()->pattern_; } |
7240 RawSmi* num_bracket_expressions() const { | 7258 RawSmi* num_bracket_expressions() const { |
7241 return raw_ptr()->num_bracket_expressions_; | 7259 return raw_ptr()->num_bracket_expressions_; |
7242 } | 7260 } |
7243 | 7261 |
| 7262 static intptr_t function_offset(intptr_t cid) { |
| 7263 switch (cid) { |
| 7264 case kOneByteStringCid: |
| 7265 return OFFSET_OF(RawJSRegExp, one_byte_function_); |
| 7266 case kTwoByteStringCid: |
| 7267 return OFFSET_OF(RawJSRegExp, two_byte_function_); |
| 7268 case kExternalOneByteStringCid: |
| 7269 return OFFSET_OF(RawJSRegExp, external_one_byte_function_); |
| 7270 case kExternalTwoByteStringCid: |
| 7271 return OFFSET_OF(RawJSRegExp, external_two_byte_function_); |
| 7272 } |
| 7273 |
| 7274 UNREACHABLE(); |
| 7275 return -1; |
| 7276 } |
| 7277 |
| 7278 RawFunction** FunctionAddr(intptr_t cid) const { |
| 7279 return reinterpret_cast<RawFunction**>( |
| 7280 FieldAddrAtOffset(function_offset(cid))); |
| 7281 } |
| 7282 |
| 7283 RawFunction* function(intptr_t cid) const { |
| 7284 return *FunctionAddr(cid); |
| 7285 } |
| 7286 |
7244 void set_pattern(const String& pattern) const; | 7287 void set_pattern(const String& pattern) const; |
| 7288 void set_function(intptr_t cid, const Function& value) const; |
| 7289 |
7245 void set_num_bracket_expressions(intptr_t value) const; | 7290 void set_num_bracket_expressions(intptr_t value) const; |
7246 void set_is_global() const { set_flags(flags() | kGlobal); } | 7291 void set_is_global() const { set_flags(flags() | kGlobal); } |
7247 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } | 7292 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } |
7248 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } | 7293 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } |
7249 void set_is_simple() const { set_type(kSimple); } | 7294 void set_is_simple() const { set_type(kSimple); } |
7250 void set_is_complex() const { set_type(kComplex); } | 7295 void set_is_complex() const { set_type(kComplex); } |
7251 | 7296 |
7252 void* GetDataStartAddress() const; | 7297 void* GetDataStartAddress() const; |
7253 static RawJSRegExp* FromDataStartAddress(void* data); | 7298 static RawJSRegExp* FromDataStartAddress(void* data); |
7254 const char* Flags() const; | 7299 const char* Flags() const; |
7255 | 7300 |
7256 virtual bool CanonicalizeEquals(const Instance& other) const; | 7301 virtual bool CanonicalizeEquals(const Instance& other) const; |
7257 | 7302 |
7258 static const intptr_t kBytesPerElement = 1; | 7303 static const intptr_t kBytesPerElement = 1; |
7259 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 7304 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
7260 | 7305 |
7261 static intptr_t InstanceSize() { | 7306 static intptr_t InstanceSize() { |
7262 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); | 7307 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); |
7263 return 0; | 7308 if (FLAG_use_jscre) { |
| 7309 return 0; |
| 7310 } |
| 7311 return RoundedAllocationSize(sizeof(RawJSRegExp)); |
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 |