Index: runtime/vm/object.h |
diff --git a/runtime/vm/object.h b/runtime/vm/object.h |
index 7e5ba3a83b9d88e5cb6a334a387545284d49119d..a46c121a7cf3bb579d20d4398589daf6731c8887 100644 |
--- a/runtime/vm/object.h |
+++ b/runtime/vm/object.h |
@@ -25,6 +25,8 @@ |
namespace dart { |
+DECLARE_FLAG(bool, use_jscre); |
+ |
// Forward declarations. |
#define DEFINE_FORWARD_DECLARATION(clazz) \ |
class clazz; |
@@ -1725,6 +1727,14 @@ class Function : public Object { |
RawClass* origin() const; |
RawScript* script() const; |
+ void set_regexp(const JSRegExp& value) const; |
+ RawJSRegExp* regexp() const; |
+ |
+ // Get and set the class id this function is specialized for. Only set for |
+ // irregexp functions. |
+ intptr_t regexp_cid() const { return raw_ptr()->regexp_cid_; } |
+ void set_regexp_cid(intptr_t regexp_cid) const; |
+ |
RawAbstractType* result_type() const { return raw_ptr()->result_type_; } |
void set_result_type(const AbstractType& value) const; |
@@ -1854,6 +1864,7 @@ class Function : public Object { |
case RawFunction::kClosureFunction: |
case RawFunction::kConstructor: |
case RawFunction::kImplicitStaticFinalGetter: |
+ case RawFunction::kIrregexpFunction: |
return false; |
default: |
UNREACHABLE(); |
@@ -1871,6 +1882,7 @@ class Function : public Object { |
case RawFunction::kImplicitGetter: |
case RawFunction::kImplicitSetter: |
case RawFunction::kImplicitStaticFinalGetter: |
+ case RawFunction::kIrregexpFunction: |
return true; |
case RawFunction::kClosureFunction: |
case RawFunction::kConstructor: |
@@ -2065,6 +2077,11 @@ class Function : public Object { |
return kind() == RawFunction::kClosureFunction; |
} |
+ // Returns true if this function represents a generated irregexp function. |
+ bool IsIrregexpFunction() const { |
+ return kind() == RawFunction::kIrregexpFunction; |
+ } |
+ |
// Returns true if this function represents an implicit closure function. |
bool IsImplicitClosureFunction() const; |
@@ -4548,6 +4565,7 @@ class Instance : public Object { |
friend class Class; |
friend class Closure; |
friend class DeferredObject; |
+ friend class JSRegExp; |
friend class SnapshotWriter; |
friend class StubCode; |
friend class TypedDataView; |
@@ -7225,7 +7243,34 @@ class JSRegExp : public Instance { |
return raw_ptr()->num_bracket_expressions_; |
} |
+ static intptr_t function_offset(intptr_t cid) { |
+ switch (cid) { |
+ case kOneByteStringCid: |
+ return OFFSET_OF(RawJSRegExp, one_byte_function_); |
+ case kTwoByteStringCid: |
+ return OFFSET_OF(RawJSRegExp, two_byte_function_); |
+ case kExternalOneByteStringCid: |
+ return OFFSET_OF(RawJSRegExp, external_one_byte_function_); |
+ case kExternalTwoByteStringCid: |
+ return OFFSET_OF(RawJSRegExp, external_two_byte_function_); |
+ } |
+ |
+ UNREACHABLE(); |
+ return -1; |
+ } |
+ |
+ RawFunction** FunctionAddr(intptr_t cid) const { |
+ return reinterpret_cast<RawFunction**>( |
+ FieldAddrAtOffset(function_offset(cid))); |
+ } |
+ |
+ RawFunction* function(intptr_t cid) const { |
+ return *FunctionAddr(cid); |
+ } |
+ |
void set_pattern(const String& pattern) const; |
+ void set_function(intptr_t cid, const Function& value) const; |
+ |
void set_num_bracket_expressions(intptr_t value) const; |
void set_is_global() const { set_flags(flags() | kGlobal); } |
void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } |
@@ -7244,7 +7289,10 @@ class JSRegExp : public Instance { |
static intptr_t InstanceSize() { |
ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data)); |
- return 0; |
+ if (FLAG_use_jscre) { |
+ return 0; |
+ } |
+ return RoundedAllocationSize(sizeof(RawJSRegExp)); |
} |
static intptr_t InstanceSize(intptr_t len) { |