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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index b36df2610cc2295dc7fb17d6464a1525f8ee546e..df068d8c7bbbd5512b9be73fd8348222d5597199 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1665,6 +1665,18 @@ class Function : public Object {
RawClass* origin() const;
RawScript* script() const;
+ void set_regexp(const JSRegExp& value) const;
+ RawJSRegExp* regexp() const;
+
+ // Set and get the class id this function is specialized for. Only set for
+ // irregexp functions.
+ void set_regexp_cid(intptr_t regexp_cid) {
+ raw_ptr()->regexp_cid_ = regexp_cid;
+ }
+ intptr_t regexp_cid() const {
+ return raw_ptr()->regexp_cid_;
+ }
+
RawAbstractType* result_type() const { return raw_ptr()->result_type_; }
void set_result_type(const AbstractType& value) const;
@@ -1790,6 +1802,7 @@ class Function : public Object {
case RawFunction::kMethodExtractor:
case RawFunction::kNoSuchMethodDispatcher:
case RawFunction::kInvokeFieldDispatcher:
+ case RawFunction::kIrregexpFunction:
return true;
case RawFunction::kClosureFunction:
case RawFunction::kConstructor:
@@ -1811,6 +1824,7 @@ class Function : public Object {
case RawFunction::kImplicitGetter:
case RawFunction::kImplicitSetter:
case RawFunction::kImplicitStaticFinalGetter:
+ 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.
return true;
case RawFunction::kClosureFunction:
case RawFunction::kConstructor:
@@ -2005,6 +2019,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;
@@ -4488,6 +4507,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;
@@ -7156,11 +7176,39 @@ class JSRegExp : public Instance {
bool is_multi_line() const { return (flags() & kMultiLine); }
RawString* pattern() const { return raw_ptr()->pattern_; }
+
RawSmi* num_bracket_expressions() const {
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);
+
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); }
@@ -7179,7 +7227,11 @@ class JSRegExp : public Instance {
static intptr_t InstanceSize() {
ASSERT(sizeof(RawJSRegExp) == OFFSET_OF_RETURNED_VALUE(RawJSRegExp, data));
+#ifdef USE_JSCRE
return 0;
+#else
+ return RoundedAllocationSize(sizeof(RawJSRegExp));
+#endif
}
static intptr_t InstanceSize(intptr_t len) {

Powered by Google App Engine
This is Rietveld 408576698