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

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: Updated to current version 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 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 bool HasInstantiatedSignature() const; 1636 bool HasInstantiatedSignature() const;
1637 1637
1638 // Build a string of the form 'T, {b: B, c: C} representing the user 1638 // Build a string of the form 'T, {b: B, c: C} representing the user
1639 // visible formal parameters of the function. 1639 // visible formal parameters of the function.
1640 RawString* UserVisibleFormalParameters() const; 1640 RawString* UserVisibleFormalParameters() const;
1641 1641
1642 RawClass* Owner() const; 1642 RawClass* Owner() const;
1643 RawClass* origin() const; 1643 RawClass* origin() const;
1644 RawScript* script() const; 1644 RawScript* script() const;
1645 1645
1646 void set_regexp(const JSRegExp& value) const;
1647 RawJSRegExp* regexp() const { return raw_ptr()->regexp_; }
1648
1649 void set_regexp_specialization(intptr_t cid) {
1650 raw_ptr()->regexp_specialization_ = cid;
1651 }
1652 intptr_t regexp_specialization() const {
1653 return raw_ptr()->regexp_specialization_;
1654 }
1655
1646 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } 1656 RawAbstractType* result_type() const { return raw_ptr()->result_type_; }
1647 void set_result_type(const AbstractType& value) const; 1657 void set_result_type(const AbstractType& value) const;
1648 1658
1649 RawAbstractType* ParameterTypeAt(intptr_t index) const; 1659 RawAbstractType* ParameterTypeAt(intptr_t index) const;
1650 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; 1660 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const;
1651 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; } 1661 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; }
1652 void set_parameter_types(const Array& value) const; 1662 void set_parameter_types(const Array& value) const;
1653 1663
1654 // Parameter names are valid for all valid parameter indices, and are not 1664 // Parameter names are valid for all valid parameter indices, and are not
1655 // limited to named optional parameters. 1665 // limited to named optional parameters.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 } 1774 }
1765 switch (kind()) { 1775 switch (kind()) {
1766 case RawFunction::kRegularFunction: 1776 case RawFunction::kRegularFunction:
1767 case RawFunction::kGetterFunction: 1777 case RawFunction::kGetterFunction:
1768 case RawFunction::kSetterFunction: 1778 case RawFunction::kSetterFunction:
1769 case RawFunction::kImplicitGetter: 1779 case RawFunction::kImplicitGetter:
1770 case RawFunction::kImplicitSetter: 1780 case RawFunction::kImplicitSetter:
1771 case RawFunction::kMethodExtractor: 1781 case RawFunction::kMethodExtractor:
1772 case RawFunction::kNoSuchMethodDispatcher: 1782 case RawFunction::kNoSuchMethodDispatcher:
1773 case RawFunction::kInvokeFieldDispatcher: 1783 case RawFunction::kInvokeFieldDispatcher:
1784 case RawFunction::kIrregexpFunction:
1774 return true; 1785 return true;
1775 case RawFunction::kClosureFunction: 1786 case RawFunction::kClosureFunction:
1776 case RawFunction::kConstructor: 1787 case RawFunction::kConstructor:
1777 case RawFunction::kImplicitStaticFinalGetter: 1788 case RawFunction::kImplicitStaticFinalGetter:
1778 return false; 1789 return false;
1779 default: 1790 default:
1780 UNREACHABLE(); 1791 UNREACHABLE();
1781 return false; 1792 return false;
1782 } 1793 }
1783 } 1794 }
1784 bool IsStaticFunction() const { 1795 bool IsStaticFunction() const {
1785 if (!is_static()) { 1796 if (!is_static()) {
1786 return false; 1797 return false;
1787 } 1798 }
1788 switch (kind()) { 1799 switch (kind()) {
1789 case RawFunction::kRegularFunction: 1800 case RawFunction::kRegularFunction:
1790 case RawFunction::kGetterFunction: 1801 case RawFunction::kGetterFunction:
1791 case RawFunction::kSetterFunction: 1802 case RawFunction::kSetterFunction:
1792 case RawFunction::kImplicitGetter: 1803 case RawFunction::kImplicitGetter:
1793 case RawFunction::kImplicitSetter: 1804 case RawFunction::kImplicitSetter:
1794 case RawFunction::kImplicitStaticFinalGetter: 1805 case RawFunction::kImplicitStaticFinalGetter:
1806 case RawFunction::kIrregexpFunction:
1795 return true; 1807 return true;
1796 case RawFunction::kClosureFunction: 1808 case RawFunction::kClosureFunction:
1797 case RawFunction::kConstructor: 1809 case RawFunction::kConstructor:
1798 return false; 1810 return false;
1799 default: 1811 default:
1800 UNREACHABLE(); 1812 UNREACHABLE();
1801 return false; 1813 return false;
1802 } 1814 }
1803 } 1815 }
1804 bool IsInFactoryScope() const; 1816 bool IsInFactoryScope() const;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2024 bool IsImplicitSetterFunction() const { 2036 bool IsImplicitSetterFunction() const {
2025 return kind() == RawFunction::kImplicitSetter; 2037 return kind() == RawFunction::kImplicitSetter;
2026 } 2038 }
2027 2039
2028 // Returns true if this function represents a (possibly implicit) closure 2040 // Returns true if this function represents a (possibly implicit) closure
2029 // function. 2041 // function.
2030 bool IsClosureFunction() const { 2042 bool IsClosureFunction() const {
2031 return kind() == RawFunction::kClosureFunction; 2043 return kind() == RawFunction::kClosureFunction;
2032 } 2044 }
2033 2045
2046 // Returns true if this function represents a generated irregexp function.
2047 bool IsIrregexpFunction() const {
2048 return kind() == RawFunction::kIrregexpFunction;
2049 }
2050
2034 // Returns true if this function represents an implicit closure function. 2051 // Returns true if this function represents an implicit closure function.
2035 bool IsImplicitClosureFunction() const; 2052 bool IsImplicitClosureFunction() const;
2036 2053
2037 // Returns true if this function represents a non implicit closure function. 2054 // Returns true if this function represents a non implicit closure function.
2038 bool IsNonImplicitClosureFunction() const { 2055 bool IsNonImplicitClosureFunction() const {
2039 return IsClosureFunction() && !IsImplicitClosureFunction(); 2056 return IsClosureFunction() && !IsImplicitClosureFunction();
2040 } 2057 }
2041 2058
2042 // Returns true if this function represents an implicit static closure 2059 // Returns true if this function represents an implicit static closure
2043 // function. 2060 // function.
(...skipping 5117 matching lines...) Expand 10 before | Expand all | Expand 10 after
7161 7178
7162 bool is_initialized() const { return (type() != kUnitialized); } 7179 bool is_initialized() const { return (type() != kUnitialized); }
7163 bool is_simple() const { return (type() == kSimple); } 7180 bool is_simple() const { return (type() == kSimple); }
7164 bool is_complex() const { return (type() == kComplex); } 7181 bool is_complex() const { return (type() == kComplex); }
7165 7182
7166 bool is_global() const { return (flags() & kGlobal); } 7183 bool is_global() const { return (flags() & kGlobal); }
7167 bool is_ignore_case() const { return (flags() & kIgnoreCase); } 7184 bool is_ignore_case() const { return (flags() & kIgnoreCase); }
7168 bool is_multi_line() const { return (flags() & kMultiLine); } 7185 bool is_multi_line() const { return (flags() & kMultiLine); }
7169 7186
7170 RawString* pattern() const { return raw_ptr()->pattern_; } 7187 RawString* pattern() const { return raw_ptr()->pattern_; }
7188
7189 static intptr_t subject_offset(intptr_t cid) {
7190 switch (cid) {
7191 case kOneByteStringCid: return OFFSET_OF(RawJSRegExp, one_byte_subject_);
7192 case kTwoByteStringCid: return OFFSET_OF(RawJSRegExp, two_byte_subject_);
7193 case kExternalOneByteStringCid:
7194 return OFFSET_OF(RawJSRegExp, external_one_byte_subject_);
7195 case kExternalTwoByteStringCid:
7196 return OFFSET_OF(RawJSRegExp, external_two_byte_subject_);
7197 }
7198
7199 UNREACHABLE();
7200 return -1;
7201 }
7202 RawString* sample_subject(intptr_t cid) const {
7203 switch (cid) {
7204 case kOneByteStringCid: return raw_ptr()->one_byte_subject_;
7205 case kTwoByteStringCid: return raw_ptr()->two_byte_subject_;
7206 case kExternalOneByteStringCid:
7207 return raw_ptr()->external_one_byte_subject_;
7208 case kExternalTwoByteStringCid:
7209 return raw_ptr()->external_two_byte_subject_;
7210 }
7211
7212 UNREACHABLE();
7213 return String::null();
7214 }
7215
7171 RawSmi* num_bracket_expressions() const { 7216 RawSmi* num_bracket_expressions() const {
7172 return raw_ptr()->num_bracket_expressions_; 7217 return raw_ptr()->num_bracket_expressions_;
7173 } 7218 }
7174 7219
7220 static intptr_t function_offset(intptr_t cid) {
7221 switch (cid) {
7222 case kOneByteStringCid: return OFFSET_OF(RawJSRegExp, one_byte_function_);
7223 case kTwoByteStringCid: return OFFSET_OF(RawJSRegExp, two_byte_function_);
7224 case kExternalOneByteStringCid:
7225 return OFFSET_OF(RawJSRegExp, external_one_byte_function_);
7226 case kExternalTwoByteStringCid:
7227 return OFFSET_OF(RawJSRegExp, external_two_byte_function_);
7228 }
7229
7230 UNREACHABLE();
7231 return -1;
7232 }
7233 RawFunction* one_byte_function() const {
7234 return raw_ptr()->one_byte_function_;
7235 }
7236
7237 RawFunction* two_byte_function() const {
7238 return raw_ptr()->two_byte_function_;
7239 }
7240
7175 void set_pattern(const String& pattern) const; 7241 void set_pattern(const String& pattern) const;
7242 void set_function(intptr_t cid, const Function& value);
7243 void set_sample_subject(intptr_t cid, const String& value) const;
7244
7176 void set_num_bracket_expressions(intptr_t value) const; 7245 void set_num_bracket_expressions(intptr_t value) const;
7177 void set_is_global() const { set_flags(flags() | kGlobal); } 7246 void set_is_global() const { set_flags(flags() | kGlobal); }
7178 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } 7247 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); }
7179 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } 7248 void set_is_multi_line() const { set_flags(flags() | kMultiLine); }
7180 void set_is_simple() const { set_type(kSimple); } 7249 void set_is_simple() const { set_type(kSimple); }
7181 void set_is_complex() const { set_type(kComplex); } 7250 void set_is_complex() const { set_type(kComplex); }
7182 7251
7183 void* GetDataStartAddress() const; 7252 void* GetDataStartAddress() const;
7184 static RawJSRegExp* FromDataStartAddress(void* data); 7253 static RawJSRegExp* FromDataStartAddress(void* data);
7185 const char* Flags() const; 7254 const char* Flags() const;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
7478 7547
7479 7548
7480 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7549 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7481 intptr_t index) { 7550 intptr_t index) {
7482 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7551 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7483 } 7552 }
7484 7553
7485 } // namespace dart 7554 } // namespace dart
7486 7555
7487 #endif // VM_OBJECT_H_ 7556 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698