Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: runtime/vm/object.h

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Missed a TODO. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 } 1795 }
1784 switch (kind()) { 1796 switch (kind()) {
1785 case RawFunction::kRegularFunction: 1797 case RawFunction::kRegularFunction:
1786 case RawFunction::kGetterFunction: 1798 case RawFunction::kGetterFunction:
1787 case RawFunction::kSetterFunction: 1799 case RawFunction::kSetterFunction:
1788 case RawFunction::kImplicitGetter: 1800 case RawFunction::kImplicitGetter:
1789 case RawFunction::kImplicitSetter: 1801 case RawFunction::kImplicitSetter:
1790 case RawFunction::kMethodExtractor: 1802 case RawFunction::kMethodExtractor:
1791 case RawFunction::kNoSuchMethodDispatcher: 1803 case RawFunction::kNoSuchMethodDispatcher:
1792 case RawFunction::kInvokeFieldDispatcher: 1804 case RawFunction::kInvokeFieldDispatcher:
1805 case RawFunction::kIrregexpFunction:
1793 return true; 1806 return true;
1794 case RawFunction::kClosureFunction: 1807 case RawFunction::kClosureFunction:
1795 case RawFunction::kConstructor: 1808 case RawFunction::kConstructor:
1796 case RawFunction::kImplicitStaticFinalGetter: 1809 case RawFunction::kImplicitStaticFinalGetter:
1797 return false; 1810 return false;
1798 default: 1811 default:
1799 UNREACHABLE(); 1812 UNREACHABLE();
1800 return false; 1813 return false;
1801 } 1814 }
1802 } 1815 }
1803 bool IsStaticFunction() const { 1816 bool IsStaticFunction() const {
1804 if (!is_static()) { 1817 if (!is_static()) {
1805 return false; 1818 return false;
1806 } 1819 }
1807 switch (kind()) { 1820 switch (kind()) {
1808 case RawFunction::kRegularFunction: 1821 case RawFunction::kRegularFunction:
1809 case RawFunction::kGetterFunction: 1822 case RawFunction::kGetterFunction:
1810 case RawFunction::kSetterFunction: 1823 case RawFunction::kSetterFunction:
1811 case RawFunction::kImplicitGetter: 1824 case RawFunction::kImplicitGetter:
1812 case RawFunction::kImplicitSetter: 1825 case RawFunction::kImplicitSetter:
1813 case RawFunction::kImplicitStaticFinalGetter: 1826 case RawFunction::kImplicitStaticFinalGetter:
1827 case RawFunction::kIrregexpFunction:
Ivan Posva 2014/10/10 06:35:54 These two are contradictory. How can a irregexp fu
jgruber1 2014/10/10 09:29:44 Done.
1814 return true; 1828 return true;
1815 case RawFunction::kClosureFunction: 1829 case RawFunction::kClosureFunction:
1816 case RawFunction::kConstructor: 1830 case RawFunction::kConstructor:
1817 return false; 1831 return false;
1818 default: 1832 default:
1819 UNREACHABLE(); 1833 UNREACHABLE();
1820 return false; 1834 return false;
1821 } 1835 }
1822 } 1836 }
1823 bool IsInFactoryScope() const; 1837 bool IsInFactoryScope() const;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 bool IsImplicitSetterFunction() const { 2012 bool IsImplicitSetterFunction() const {
1999 return kind() == RawFunction::kImplicitSetter; 2013 return kind() == RawFunction::kImplicitSetter;
2000 } 2014 }
2001 2015
2002 // Returns true if this function represents a (possibly implicit) closure 2016 // Returns true if this function represents a (possibly implicit) closure
2003 // function. 2017 // function.
2004 bool IsClosureFunction() const { 2018 bool IsClosureFunction() const {
2005 return kind() == RawFunction::kClosureFunction; 2019 return kind() == RawFunction::kClosureFunction;
2006 } 2020 }
2007 2021
2022 // Returns true if this function represents a generated irregexp function.
2023 bool IsIrregexpFunction() const {
2024 return kind() == RawFunction::kIrregexpFunction;
2025 }
2026
2008 // Returns true if this function represents an implicit closure function. 2027 // Returns true if this function represents an implicit closure function.
2009 bool IsImplicitClosureFunction() const; 2028 bool IsImplicitClosureFunction() const;
2010 2029
2011 // Returns true if this function represents a non implicit closure function. 2030 // Returns true if this function represents a non implicit closure function.
2012 bool IsNonImplicitClosureFunction() const { 2031 bool IsNonImplicitClosureFunction() const {
2013 return IsClosureFunction() && !IsImplicitClosureFunction(); 2032 return IsClosureFunction() && !IsImplicitClosureFunction();
2014 } 2033 }
2015 2034
2016 // Returns true if this function represents an implicit static closure 2035 // Returns true if this function represents an implicit static closure
2017 // function. 2036 // function.
(...skipping 2463 matching lines...) Expand 10 before | Expand all | Expand 10 after
4481 static intptr_t NextFieldOffset() { 4500 static intptr_t NextFieldOffset() {
4482 return sizeof(RawInstance); 4501 return sizeof(RawInstance);
4483 } 4502 }
4484 4503
4485 // TODO(iposva): Determine if this gets in the way of Smi. 4504 // TODO(iposva): Determine if this gets in the way of Smi.
4486 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); 4505 HEAP_OBJECT_IMPLEMENTATION(Instance, Object);
4487 friend class ByteBuffer; 4506 friend class ByteBuffer;
4488 friend class Class; 4507 friend class Class;
4489 friend class Closure; 4508 friend class Closure;
4490 friend class DeferredObject; 4509 friend class DeferredObject;
4510 friend class JSRegExp;
4491 friend class SnapshotWriter; 4511 friend class SnapshotWriter;
4492 friend class StubCode; 4512 friend class StubCode;
4493 friend class TypedDataView; 4513 friend class TypedDataView;
4494 }; 4514 };
4495 4515
4496 4516
4497 class LibraryPrefix : public Instance { 4517 class LibraryPrefix : public Instance {
4498 public: 4518 public:
4499 RawString* name() const { return raw_ptr()->name_; } 4519 RawString* name() const { return raw_ptr()->name_; }
4500 virtual RawString* DictionaryName() const { return name(); } 4520 virtual RawString* DictionaryName() const { return name(); }
(...skipping 2648 matching lines...) Expand 10 before | Expand all | Expand 10 after
7149 7169
7150 bool is_initialized() const { return (type() != kUnitialized); } 7170 bool is_initialized() const { return (type() != kUnitialized); }
7151 bool is_simple() const { return (type() == kSimple); } 7171 bool is_simple() const { return (type() == kSimple); }
7152 bool is_complex() const { return (type() == kComplex); } 7172 bool is_complex() const { return (type() == kComplex); }
7153 7173
7154 bool is_global() const { return (flags() & kGlobal); } 7174 bool is_global() const { return (flags() & kGlobal); }
7155 bool is_ignore_case() const { return (flags() & kIgnoreCase); } 7175 bool is_ignore_case() const { return (flags() & kIgnoreCase); }
7156 bool is_multi_line() const { return (flags() & kMultiLine); } 7176 bool is_multi_line() const { return (flags() & kMultiLine); }
7157 7177
7158 RawString* pattern() const { return raw_ptr()->pattern_; } 7178 RawString* pattern() const { return raw_ptr()->pattern_; }
7179
7159 RawSmi* num_bracket_expressions() const { 7180 RawSmi* num_bracket_expressions() const {
7160 return raw_ptr()->num_bracket_expressions_; 7181 return raw_ptr()->num_bracket_expressions_;
7161 } 7182 }
7162 7183
7184 static intptr_t function_offset(intptr_t cid) {
7185 switch (cid) {
7186 case kOneByteStringCid:
7187 return OFFSET_OF(RawJSRegExp, one_byte_function_);
7188 case kTwoByteStringCid:
7189 return OFFSET_OF(RawJSRegExp, two_byte_function_);
7190 case kExternalOneByteStringCid:
7191 return OFFSET_OF(RawJSRegExp, external_one_byte_function_);
7192 case kExternalTwoByteStringCid:
7193 return OFFSET_OF(RawJSRegExp, external_two_byte_function_);
7194 }
7195
7196 UNREACHABLE();
7197 return -1;
7198 }
7199
7200 RawFunction** FunctionAddr(intptr_t cid) const {
7201 return reinterpret_cast<RawFunction**>(
7202 FieldAddrAtOffset(function_offset(cid)));
7203 }
7204
7205 RawFunction* function(intptr_t cid) const {
7206 return *FunctionAddr(cid);
7207 }
7208
7163 void set_pattern(const String& pattern) const; 7209 void set_pattern(const String& pattern) const;
7210 void set_function(intptr_t cid, const Function& value);
7211
7164 void set_num_bracket_expressions(intptr_t value) const; 7212 void set_num_bracket_expressions(intptr_t value) const;
7165 void set_is_global() const { set_flags(flags() | kGlobal); } 7213 void set_is_global() const { set_flags(flags() | kGlobal); }
7166 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } 7214 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); }
7167 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } 7215 void set_is_multi_line() const { set_flags(flags() | kMultiLine); }
7168 void set_is_simple() const { set_type(kSimple); } 7216 void set_is_simple() const { set_type(kSimple); }
7169 void set_is_complex() const { set_type(kComplex); } 7217 void set_is_complex() const { set_type(kComplex); }
7170 7218
7171 void* GetDataStartAddress() const; 7219 void* GetDataStartAddress() const;
7172 static RawJSRegExp* FromDataStartAddress(void* data); 7220 static RawJSRegExp* FromDataStartAddress(void* data);
7173 const char* Flags() const; 7221 const char* Flags() const;
7174 7222
7175 virtual bool CanonicalizeEquals(const Instance& other) const; 7223 virtual bool CanonicalizeEquals(const Instance& other) const;
7176 7224
7177 static const intptr_t kBytesPerElement = 1; 7225 static const intptr_t kBytesPerElement = 1;
7178 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 7226 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
7179 7227
7180 static intptr_t InstanceSize() { 7228 static intptr_t InstanceSize() {
7181 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); 7229 ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data));
7230 #ifdef USE_JSCRE
7182 return 0; 7231 return 0;
7232 #else
7233 return RoundedAllocationSize(sizeof(RawJSRegExp));
7234 #endif
7183 } 7235 }
7184 7236
7185 static intptr_t InstanceSize(intptr_t len) { 7237 static intptr_t InstanceSize(intptr_t len) {
7186 ASSERT(0 <= len && len <= kMaxElements); 7238 ASSERT(0 <= len && len <= kMaxElements);
7187 return RoundedAllocationSize( 7239 return RoundedAllocationSize(
7188 sizeof(RawJSRegExp) + (len * kBytesPerElement)); 7240 sizeof(RawJSRegExp) + (len * kBytesPerElement));
7189 } 7241 }
7190 7242
7191 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); 7243 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew);
7192 7244
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
7469 7521
7470 7522
7471 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7523 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7472 intptr_t index) { 7524 intptr_t index) {
7473 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7525 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7474 } 7526 }
7475 7527
7476 } // namespace dart 7528 } // namespace dart
7477 7529
7478 #endif // VM_OBJECT_H_ 7530 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698