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

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: Port remaining V8 regexp tests and fix exposed bugs. 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;
Florian Schneider 2014/10/01 17:04:15 I think you can use the kind-specific data_ field
jgruber1 2014/10/03 18:59:54 data_ now stores the RawJSRegExp pointer, and I re
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 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
3500 V(UnaryOp) \ 3517 V(UnaryOp) \
3501 V(UnboxInteger) \ 3518 V(UnboxInteger) \
3502 V(CheckClass) \ 3519 V(CheckClass) \
3503 V(HoistedCheckClass) \ 3520 V(HoistedCheckClass) \
3504 V(CheckSmi) \ 3521 V(CheckSmi) \
3505 V(CheckArrayBound) \ 3522 V(CheckArrayBound) \
3506 V(AtCall) \ 3523 V(AtCall) \
3507 V(DoubleToSmi) \ 3524 V(DoubleToSmi) \
3508 V(Int32Load) \ 3525 V(Int32Load) \
3509 V(Uint32Load) \ 3526 V(Uint32Load) \
3527 V(CodeUnitsLoad) \
Florian Schneider 2014/10/01 17:04:15 No need, since I don't see any deoptimizations in
jgruber1 2014/10/03 18:59:54 Done.
3510 V(GuardField) \ 3528 V(GuardField) \
3511 V(TestCids) \ 3529 V(TestCids) \
3512 V(NumReasons) \ 3530 V(NumReasons) \
3513 3531
3514 enum DeoptReasonId { 3532 enum DeoptReasonId {
3515 #define DEFINE_ENUM_LIST(name) kDeopt##name, 3533 #define DEFINE_ENUM_LIST(name) kDeopt##name,
3516 DEOPT_REASONS(DEFINE_ENUM_LIST) 3534 DEOPT_REASONS(DEFINE_ENUM_LIST)
3517 #undef DEFINE_ENUM_LIST 3535 #undef DEFINE_ENUM_LIST
3518 }; 3536 };
3519 3537
(...skipping 3641 matching lines...) Expand 10 before | Expand all | Expand 10 after
7161 7179
7162 bool is_initialized() const { return (type() != kUnitialized); } 7180 bool is_initialized() const { return (type() != kUnitialized); }
7163 bool is_simple() const { return (type() == kSimple); } 7181 bool is_simple() const { return (type() == kSimple); }
7164 bool is_complex() const { return (type() == kComplex); } 7182 bool is_complex() const { return (type() == kComplex); }
7165 7183
7166 bool is_global() const { return (flags() & kGlobal); } 7184 bool is_global() const { return (flags() & kGlobal); }
7167 bool is_ignore_case() const { return (flags() & kIgnoreCase); } 7185 bool is_ignore_case() const { return (flags() & kIgnoreCase); }
7168 bool is_multi_line() const { return (flags() & kMultiLine); } 7186 bool is_multi_line() const { return (flags() & kMultiLine); }
7169 7187
7170 RawString* pattern() const { return raw_ptr()->pattern_; } 7188 RawString* pattern() const { return raw_ptr()->pattern_; }
7189
7190 static intptr_t subject_offset(intptr_t cid) {
7191 switch (cid) {
7192 case kOneByteStringCid: return OFFSET_OF(RawJSRegExp, one_byte_subject_);
7193 case kTwoByteStringCid: return OFFSET_OF(RawJSRegExp, two_byte_subject_);
7194 case kExternalOneByteStringCid:
7195 return OFFSET_OF(RawJSRegExp, external_one_byte_subject_);
7196 case kExternalTwoByteStringCid:
7197 return OFFSET_OF(RawJSRegExp, external_two_byte_subject_);
7198 }
7199
7200 UNREACHABLE();
7201 return -1;
7202 }
7203 RawString* sample_subject(intptr_t cid) const {
7204 switch (cid) {
7205 case kOneByteStringCid: return raw_ptr()->one_byte_subject_;
7206 case kTwoByteStringCid: return raw_ptr()->two_byte_subject_;
7207 case kExternalOneByteStringCid:
7208 return raw_ptr()->external_one_byte_subject_;
7209 case kExternalTwoByteStringCid:
7210 return raw_ptr()->external_two_byte_subject_;
7211 }
7212
7213 UNREACHABLE();
7214 return String::null();
7215 }
7216
7171 RawSmi* num_bracket_expressions() const { 7217 RawSmi* num_bracket_expressions() const {
7172 return raw_ptr()->num_bracket_expressions_; 7218 return raw_ptr()->num_bracket_expressions_;
7173 } 7219 }
7174 7220
7221 static intptr_t function_offset(intptr_t cid) {
7222 switch (cid) {
7223 case kOneByteStringCid: return OFFSET_OF(RawJSRegExp, one_byte_function_);
7224 case kTwoByteStringCid: return OFFSET_OF(RawJSRegExp, two_byte_function_);
7225 case kExternalOneByteStringCid:
7226 return OFFSET_OF(RawJSRegExp, external_one_byte_function_);
7227 case kExternalTwoByteStringCid:
7228 return OFFSET_OF(RawJSRegExp, external_two_byte_function_);
7229 }
7230
7231 UNREACHABLE();
7232 return -1;
7233 }
7234
7235 RawFunction* function(intptr_t cid) const {
7236 switch (cid) {
7237 case kOneByteStringCid: return raw_ptr()->one_byte_function_;
7238 case kTwoByteStringCid: return raw_ptr()->two_byte_function_;
7239 case kExternalOneByteStringCid:
7240 return raw_ptr()->external_one_byte_function_;
7241 case kExternalTwoByteStringCid:
7242 return raw_ptr()->external_two_byte_function_;
7243 }
7244
7245 UNREACHABLE();
7246 return Function::null();
7247 }
7248
7175 void set_pattern(const String& pattern) const; 7249 void set_pattern(const String& pattern) const;
7250 void set_function(intptr_t cid, const Function& value);
7251 void set_sample_subject(intptr_t cid, const String& value) const;
7252
7176 void set_num_bracket_expressions(intptr_t value) const; 7253 void set_num_bracket_expressions(intptr_t value) const;
7177 void set_is_global() const { set_flags(flags() | kGlobal); } 7254 void set_is_global() const { set_flags(flags() | kGlobal); }
7178 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } 7255 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); }
7179 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } 7256 void set_is_multi_line() const { set_flags(flags() | kMultiLine); }
7180 void set_is_simple() const { set_type(kSimple); } 7257 void set_is_simple() const { set_type(kSimple); }
7181 void set_is_complex() const { set_type(kComplex); } 7258 void set_is_complex() const { set_type(kComplex); }
7182 7259
7183 void* GetDataStartAddress() const; 7260 void* GetDataStartAddress() const;
7184 static RawJSRegExp* FromDataStartAddress(void* data); 7261 static RawJSRegExp* FromDataStartAddress(void* data);
7185 const char* Flags() const; 7262 const char* Flags() const;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
7478 7555
7479 7556
7480 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7557 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7481 intptr_t index) { 7558 intptr_t index) {
7482 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7559 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7483 } 7560 }
7484 7561
7485 } // namespace dart 7562 } // namespace dart
7486 7563
7487 #endif // VM_OBJECT_H_ 7564 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698