OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
11 #include "src/assert-scope.h" | 11 #include "src/assert-scope.h" |
12 #include "src/bailout-reason.h" | 12 #include "src/bailout-reason.h" |
13 #include "src/base/bits.h" | 13 #include "src/base/bits.h" |
| 14 #include "src/base/flags.h" |
14 #include "src/base/smart-pointers.h" | 15 #include "src/base/smart-pointers.h" |
15 #include "src/builtins.h" | 16 #include "src/builtins.h" |
16 #include "src/checks.h" | 17 #include "src/checks.h" |
17 #include "src/elements-kind.h" | 18 #include "src/elements-kind.h" |
18 #include "src/field-index.h" | 19 #include "src/field-index.h" |
19 #include "src/flags.h" | 20 #include "src/flags.h" |
20 #include "src/list.h" | 21 #include "src/list.h" |
21 #include "src/property-details.h" | 22 #include "src/property-details.h" |
22 #include "src/unicode.h" | 23 #include "src/unicode.h" |
23 #include "src/unicode-decoder.h" | 24 #include "src/unicode-decoder.h" |
(...skipping 7649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7673 // - reference to the original flag string | 7674 // - reference to the original flag string |
7674 // If it is an atom regexp | 7675 // If it is an atom regexp |
7675 // - a reference to a literal string to search for | 7676 // - a reference to a literal string to search for |
7676 // If it is an irregexp regexp: | 7677 // If it is an irregexp regexp: |
7677 // - a reference to code for Latin1 inputs (bytecode or compiled), or a smi | 7678 // - a reference to code for Latin1 inputs (bytecode or compiled), or a smi |
7678 // used for tracking the last usage (used for code flushing). | 7679 // used for tracking the last usage (used for code flushing). |
7679 // - a reference to code for UC16 inputs (bytecode or compiled), or a smi | 7680 // - a reference to code for UC16 inputs (bytecode or compiled), or a smi |
7680 // used for tracking the last usage (used for code flushing).. | 7681 // used for tracking the last usage (used for code flushing).. |
7681 // - max number of registers used by irregexp implementations. | 7682 // - max number of registers used by irregexp implementations. |
7682 // - number of capture registers (output values) of the regexp. | 7683 // - number of capture registers (output values) of the regexp. |
7683 class JSRegExp: public JSObject { | 7684 class JSRegExp final : public JSObject { |
7684 public: | 7685 public: |
7685 // Meaning of Type: | 7686 // Meaning of Type: |
7686 // NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet. | 7687 // NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet. |
7687 // ATOM: A simple string to match against using an indexOf operation. | 7688 // ATOM: A simple string to match against using an indexOf operation. |
7688 // IRREGEXP: Compiled with Irregexp. | 7689 // IRREGEXP: Compiled with Irregexp. |
7689 // IRREGEXP_NATIVE: Compiled to native code with Irregexp. | 7690 // IRREGEXP_NATIVE: Compiled to native code with Irregexp. |
7690 enum Type { NOT_COMPILED, ATOM, IRREGEXP }; | 7691 enum Type { NOT_COMPILED, ATOM, IRREGEXP }; |
7691 enum Flag { | 7692 enum Flag { |
7692 NONE = 0, | 7693 kNone = 0, |
7693 GLOBAL = 1, | 7694 kGlobal = 1 << 0, |
7694 IGNORE_CASE = 2, | 7695 kIgnoreCase = 1 << 1, |
7695 MULTILINE = 4, | 7696 kMultiline = 1 << 2, |
7696 STICKY = 8, | 7697 kSticky = 1 << 3, |
7697 UNICODE_ESCAPES = 16 | 7698 kUnicode = 1 << 4, |
7698 }; | 7699 }; |
7699 | 7700 typedef base::Flags<Flag> Flags; |
7700 class Flags { | |
7701 public: | |
7702 explicit Flags(uint32_t value) : value_(value) { } | |
7703 bool is_global() { return (value_ & GLOBAL) != 0; } | |
7704 bool is_ignore_case() { return (value_ & IGNORE_CASE) != 0; } | |
7705 bool is_multiline() { return (value_ & MULTILINE) != 0; } | |
7706 bool is_sticky() { return (value_ & STICKY) != 0; } | |
7707 bool is_unicode() { return (value_ & UNICODE_ESCAPES) != 0; } | |
7708 uint32_t value() { return value_; } | |
7709 private: | |
7710 uint32_t value_; | |
7711 }; | |
7712 | 7701 |
7713 DECL_ACCESSORS(data, Object) | 7702 DECL_ACCESSORS(data, Object) |
7714 DECL_ACCESSORS(flags, Object) | 7703 DECL_ACCESSORS(flags, Object) |
7715 DECL_ACCESSORS(source, Object) | 7704 DECL_ACCESSORS(source, Object) |
7716 | 7705 |
| 7706 static MaybeHandle<JSRegExp> New(Handle<String> source, Flags flags); |
7717 static MaybeHandle<JSRegExp> New(Handle<String> source, Handle<String> flags); | 7707 static MaybeHandle<JSRegExp> New(Handle<String> source, Handle<String> flags); |
7718 static Handle<JSRegExp> Copy(Handle<JSRegExp> regexp); | 7708 static Handle<JSRegExp> Copy(Handle<JSRegExp> regexp); |
7719 | 7709 |
7720 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp, | 7710 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp, |
| 7711 Handle<String> source, Flags flags); |
| 7712 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp, |
7721 Handle<String> source, | 7713 Handle<String> source, |
7722 Handle<String> flags_string); | 7714 Handle<String> flags_string); |
7723 | 7715 |
7724 inline Type TypeTag(); | 7716 inline Type TypeTag(); |
7725 inline int CaptureCount(); | 7717 inline int CaptureCount(); |
7726 inline Flags GetFlags(); | 7718 inline Flags GetFlags(); |
7727 inline String* Pattern(); | 7719 inline String* Pattern(); |
7728 inline Object* DataAt(int index); | 7720 inline Object* DataAt(int index); |
7729 // Set implementation data after the object has been prepared. | 7721 // Set implementation data after the object has been prepared. |
7730 inline void SetDataAt(int index, Object* value); | 7722 inline void SetDataAt(int index, Object* value); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7812 // The compilation error value for the regexp code object. The real error | 7804 // The compilation error value for the regexp code object. The real error |
7813 // object is in the saved code field. | 7805 // object is in the saved code field. |
7814 static const int kCompilationErrorValue = -2; | 7806 static const int kCompilationErrorValue = -2; |
7815 | 7807 |
7816 // When we store the sweep generation at which we moved the code from the | 7808 // When we store the sweep generation at which we moved the code from the |
7817 // code index to the saved code index we mask it of to be in the [0:255] | 7809 // code index to the saved code index we mask it of to be in the [0:255] |
7818 // range. | 7810 // range. |
7819 static const int kCodeAgeMask = 0xff; | 7811 static const int kCodeAgeMask = 0xff; |
7820 }; | 7812 }; |
7821 | 7813 |
| 7814 DEFINE_OPERATORS_FOR_FLAGS(JSRegExp::Flags) |
| 7815 |
7822 | 7816 |
7823 class CompilationCacheShape : public BaseShape<HashTableKey*> { | 7817 class CompilationCacheShape : public BaseShape<HashTableKey*> { |
7824 public: | 7818 public: |
7825 static inline bool IsMatch(HashTableKey* key, Object* value) { | 7819 static inline bool IsMatch(HashTableKey* key, Object* value) { |
7826 return key->IsMatch(value); | 7820 return key->IsMatch(value); |
7827 } | 7821 } |
7828 | 7822 |
7829 static inline uint32_t Hash(HashTableKey* key) { | 7823 static inline uint32_t Hash(HashTableKey* key) { |
7830 return key->Hash(); | 7824 return key->Hash(); |
7831 } | 7825 } |
(...skipping 2907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10739 } | 10733 } |
10740 return value; | 10734 return value; |
10741 } | 10735 } |
10742 }; | 10736 }; |
10743 | 10737 |
10744 | 10738 |
10745 } // NOLINT, false-positive due to second-order macros. | 10739 } // NOLINT, false-positive due to second-order macros. |
10746 } // NOLINT, false-positive due to second-order macros. | 10740 } // NOLINT, false-positive due to second-order macros. |
10747 | 10741 |
10748 #endif // V8_OBJECTS_H_ | 10742 #endif // V8_OBJECTS_H_ |
OLD | NEW |