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

Unified Diff: runtime/vm/object.cc

Issue 2510783002: VM: Optimize RegExp.matchAsPrefix(...) by generating a sticky RegExp specialization. (Closed)
Patch Set: Done Created 4 years, 1 month 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 2d92205554635666901ee1a3882c8cc812ab28f3..bdf7f975ebf38847b53f5210fe5c28c21d55e578 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -5696,21 +5696,36 @@ RawRegExp* Function::regexp() const {
}
+class StickySpecialization : public BitField<intptr_t, bool, 0, 1> {};
+class StringSpecializationCid
+ : public BitField<intptr_t, intptr_t, 1, RawObject::kClassIdTagSize> {};
+
+
intptr_t Function::string_specialization_cid() const {
ASSERT(kind() == RawFunction::kIrregexpFunction);
const Array& pair = Array::Cast(Object::Handle(raw_ptr()->data_));
- return Smi::Value(Smi::RawCast(pair.At(1)));
+ return StringSpecializationCid::decode(Smi::Value(Smi::RawCast(pair.At(1))));
+}
+
+
+bool Function::is_sticky_specialization() const {
+ ASSERT(kind() == RawFunction::kIrregexpFunction);
+ const Array& pair = Array::Cast(Object::Handle(raw_ptr()->data_));
+ return StickySpecialization::decode(Smi::Value(Smi::RawCast(pair.At(1))));
}
void Function::SetRegExpData(const RegExp& regexp,
- intptr_t string_specialization_cid) const {
+ intptr_t string_specialization_cid,
+ bool sticky) const {
ASSERT(kind() == RawFunction::kIrregexpFunction);
ASSERT(RawObject::IsStringClassId(string_specialization_cid));
ASSERT(raw_ptr()->data_ == Object::null());
const Array& pair = Array::Handle(Array::New(2, Heap::kOld));
pair.SetAt(0, regexp);
- pair.SetAt(1, Smi::Handle(Smi::New(string_specialization_cid)));
+ pair.SetAt(1, Smi::Handle(Smi::New(StickySpecialization::encode(sticky) |
+ StringSpecializationCid::encode(
+ string_specialization_cid))));
set_data(pair);
}
@@ -22392,16 +22407,28 @@ void RegExp::set_pattern(const String& pattern) const {
}
-void RegExp::set_function(intptr_t cid, const Function& value) const {
- StorePointer(FunctionAddr(cid), value.raw());
+void RegExp::set_function(intptr_t cid,
+ bool sticky,
+ const Function& value) const {
+ StorePointer(FunctionAddr(cid, sticky), value.raw());
}
-void RegExp::set_bytecode(bool is_one_byte, const TypedData& bytecode) const {
- if (is_one_byte) {
- StorePointer(&raw_ptr()->one_byte_bytecode_, bytecode.raw());
+void RegExp::set_bytecode(bool is_one_byte,
+ bool sticky,
+ const TypedData& bytecode) const {
+ if (sticky) {
+ if (is_one_byte) {
+ StorePointer(&raw_ptr()->one_byte_sticky_.bytecode_, bytecode.raw());
+ } else {
+ StorePointer(&raw_ptr()->two_byte_sticky_.bytecode_, bytecode.raw());
+ }
} else {
- StorePointer(&raw_ptr()->two_byte_bytecode_, bytecode.raw());
+ if (is_one_byte) {
+ StorePointer(&raw_ptr()->one_byte_.bytecode_, bytecode.raw());
+ } else {
+ StorePointer(&raw_ptr()->two_byte_.bytecode_, bytecode.raw());
+ }
}
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698