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

Side by Side Diff: runtime/vm/object.h

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 unified diff | Download patch
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 RUNTIME_VM_OBJECT_H_ 5 #ifndef RUNTIME_VM_OBJECT_H_
6 #define RUNTIME_VM_OBJECT_H_ 6 #define RUNTIME_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 2197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2208 void Reparent(const Class& new_cls) const; 2208 void Reparent(const Class& new_cls) const;
2209 void ZeroEdgeCounters() const; 2209 void ZeroEdgeCounters() const;
2210 2210
2211 RawClass* Owner() const; 2211 RawClass* Owner() const;
2212 RawClass* origin() const; 2212 RawClass* origin() const;
2213 RawScript* script() const; 2213 RawScript* script() const;
2214 RawObject* RawOwner() const { return raw_ptr()->owner_; } 2214 RawObject* RawOwner() const { return raw_ptr()->owner_; }
2215 2215
2216 RawRegExp* regexp() const; 2216 RawRegExp* regexp() const;
2217 intptr_t string_specialization_cid() const; 2217 intptr_t string_specialization_cid() const;
2218 bool is_sticky_specialization() const;
2218 void SetRegExpData(const RegExp& regexp, 2219 void SetRegExpData(const RegExp& regexp,
2219 intptr_t string_specialization_cid) const; 2220 intptr_t string_specialization_cid,
2221 bool sticky) const;
2220 2222
2221 RawString* native_name() const; 2223 RawString* native_name() const;
2222 void set_native_name(const String& name) const; 2224 void set_native_name(const String& name) const;
2223 2225
2224 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } 2226 RawAbstractType* result_type() const { return raw_ptr()->result_type_; }
2225 void set_result_type(const AbstractType& value) const; 2227 void set_result_type(const AbstractType& value) const;
2226 2228
2227 RawAbstractType* ParameterTypeAt(intptr_t index) const; 2229 RawAbstractType* ParameterTypeAt(intptr_t index) const;
2228 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; 2230 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const;
2229 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; } 2231 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; }
(...skipping 6210 matching lines...) Expand 10 before | Expand all | Expand 10 after
8440 bool is_ignore_case() const { return (flags() & kIgnoreCase); } 8442 bool is_ignore_case() const { return (flags() & kIgnoreCase); }
8441 bool is_multi_line() const { return (flags() & kMultiLine); } 8443 bool is_multi_line() const { return (flags() & kMultiLine); }
8442 8444
8443 intptr_t num_registers() const { return raw_ptr()->num_registers_; } 8445 intptr_t num_registers() const { return raw_ptr()->num_registers_; }
8444 8446
8445 RawString* pattern() const { return raw_ptr()->pattern_; } 8447 RawString* pattern() const { return raw_ptr()->pattern_; }
8446 RawSmi* num_bracket_expressions() const { 8448 RawSmi* num_bracket_expressions() const {
8447 return raw_ptr()->num_bracket_expressions_; 8449 return raw_ptr()->num_bracket_expressions_;
8448 } 8450 }
8449 8451
8450 RawTypedData* bytecode(bool is_one_byte) const { 8452 RawTypedData* bytecode(bool is_one_byte, bool sticky) const {
8451 return is_one_byte ? raw_ptr()->one_byte_bytecode_ 8453 if (sticky) {
8452 : raw_ptr()->two_byte_bytecode_; 8454 return is_one_byte ? raw_ptr()->one_byte_sticky_.bytecode_
8455 : raw_ptr()->two_byte_sticky_.bytecode_;
8456 } else {
8457 return is_one_byte ? raw_ptr()->one_byte_.bytecode_
8458 : raw_ptr()->two_byte_.bytecode_;
8459 }
8453 } 8460 }
8454 8461
8455 static intptr_t function_offset(intptr_t cid) { 8462 static intptr_t function_offset(intptr_t cid, bool sticky) {
8456 switch (cid) { 8463 if (sticky) {
8457 case kOneByteStringCid: 8464 switch (cid) {
8458 return OFFSET_OF(RawRegExp, one_byte_function_); 8465 case kOneByteStringCid:
8459 case kTwoByteStringCid: 8466 return OFFSET_OF(RawRegExp, one_byte_sticky_.function_);
8460 return OFFSET_OF(RawRegExp, two_byte_function_); 8467 case kTwoByteStringCid:
8461 case kExternalOneByteStringCid: 8468 return OFFSET_OF(RawRegExp, two_byte_sticky_.function_);
8462 return OFFSET_OF(RawRegExp, external_one_byte_function_); 8469 case kExternalOneByteStringCid:
8463 case kExternalTwoByteStringCid: 8470 return OFFSET_OF(RawRegExp, external_one_byte_sticky_function_);
8464 return OFFSET_OF(RawRegExp, external_two_byte_function_); 8471 case kExternalTwoByteStringCid:
8472 return OFFSET_OF(RawRegExp, external_two_byte_sticky_function_);
8473 }
8474 } else {
8475 switch (cid) {
8476 case kOneByteStringCid:
8477 return OFFSET_OF(RawRegExp, one_byte_.function_);
8478 case kTwoByteStringCid:
8479 return OFFSET_OF(RawRegExp, two_byte_.function_);
8480 case kExternalOneByteStringCid:
8481 return OFFSET_OF(RawRegExp, external_one_byte_function_);
8482 case kExternalTwoByteStringCid:
8483 return OFFSET_OF(RawRegExp, external_two_byte_function_);
8484 }
8465 } 8485 }
8466 8486
8467 UNREACHABLE(); 8487 UNREACHABLE();
8468 return -1; 8488 return -1;
8469 } 8489 }
8470 8490
8471 RawFunction** FunctionAddr(intptr_t cid) const { 8491 RawFunction** FunctionAddr(intptr_t cid, bool sticky) const {
8472 return reinterpret_cast<RawFunction**>( 8492 return reinterpret_cast<RawFunction**>(
8473 FieldAddrAtOffset(function_offset(cid))); 8493 FieldAddrAtOffset(function_offset(cid, sticky)));
8474 } 8494 }
8475 8495
8476 RawFunction* function(intptr_t cid) const { return *FunctionAddr(cid); } 8496 RawFunction* function(intptr_t cid, bool sticky) const {
8497 return *FunctionAddr(cid, sticky);
8498 }
8477 8499
8478 void set_pattern(const String& pattern) const; 8500 void set_pattern(const String& pattern) const;
8479 void set_function(intptr_t cid, const Function& value) const; 8501 void set_function(intptr_t cid, bool sticky, const Function& value) const;
8480 void set_bytecode(bool is_one_byte, const TypedData& bytecode) const; 8502 void set_bytecode(bool is_one_byte,
8503 bool sticky,
8504 const TypedData& bytecode) const;
8481 8505
8482 void set_num_bracket_expressions(intptr_t value) const; 8506 void set_num_bracket_expressions(intptr_t value) const;
8483 void set_is_global() const { set_flags(flags() | kGlobal); } 8507 void set_is_global() const { set_flags(flags() | kGlobal); }
8484 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } 8508 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); }
8485 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } 8509 void set_is_multi_line() const { set_flags(flags() | kMultiLine); }
8486 void set_is_simple() const { set_type(kSimple); } 8510 void set_is_simple() const { set_type(kSimple); }
8487 void set_is_complex() const { set_type(kComplex); } 8511 void set_is_complex() const { set_type(kComplex); }
8488 void set_num_registers(intptr_t value) const { 8512 void set_num_registers(intptr_t value) const {
8489 StoreNonPointer(&raw_ptr()->num_registers_, value); 8513 StoreNonPointer(&raw_ptr()->num_registers_, value);
8490 } 8514 }
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
8832 8856
8833 inline void TypeArguments::SetHash(intptr_t value) const { 8857 inline void TypeArguments::SetHash(intptr_t value) const {
8834 // This is only safe because we create a new Smi, which does not cause 8858 // This is only safe because we create a new Smi, which does not cause
8835 // heap allocation. 8859 // heap allocation.
8836 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8860 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
8837 } 8861 }
8838 8862
8839 } // namespace dart 8863 } // namespace dart
8840 8864
8841 #endif // RUNTIME_VM_OBJECT_H_ 8865 #endif // RUNTIME_VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698