| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 2948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2959 | 2959 |
| 2960 // Layout description. | 2960 // Layout description. |
| 2961 static const int kValueOffset = JSObject::kHeaderSize; | 2961 static const int kValueOffset = JSObject::kHeaderSize; |
| 2962 static const int kSize = kValueOffset + kPointerSize; | 2962 static const int kSize = kValueOffset + kPointerSize; |
| 2963 | 2963 |
| 2964 private: | 2964 private: |
| 2965 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue); | 2965 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue); |
| 2966 }; | 2966 }; |
| 2967 | 2967 |
| 2968 // Regular expressions | 2968 // Regular expressions |
| 2969 // The regular expression holds a single reference to a FixedArray in |
| 2970 // the kDataOffset field. |
| 2971 // The FixedArray contains the following data: |
| 2972 // - tag : type of regexp implementation (not compiled yet, atom or irregexp) |
| 2973 // - reference to the original source string |
| 2974 // - reference to the original flag string |
| 2975 // If it is an atom regexp |
| 2976 // - a reference to a literal string to search for |
| 2977 // If it is an irregexp regexp: |
| 2978 // - a reference to code for ASCII inputs (bytecode or compiled). |
| 2979 // - a reference to code for UC16 inputs (bytecode or compiled). |
| 2980 // - max number of registers used by irregexp implementations. |
| 2981 // - number of capture registers (output values) of the regexp. |
| 2969 class JSRegExp: public JSObject { | 2982 class JSRegExp: public JSObject { |
| 2970 public: | 2983 public: |
| 2971 // Meaning of Type: | 2984 // Meaning of Type: |
| 2972 // NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet. | 2985 // NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet. |
| 2973 // ATOM: A simple string to match against using an indexOf operation. | 2986 // ATOM: A simple string to match against using an indexOf operation. |
| 2974 // IRREGEXP: Compiled with Irregexp. | 2987 // IRREGEXP: Compiled with Irregexp. |
| 2975 // IRREGEXP_NATIVE: Compiled to native code with Irregexp. | 2988 // IRREGEXP_NATIVE: Compiled to native code with Irregexp. |
| 2976 enum Type { NOT_COMPILED, ATOM, IRREGEXP }; | 2989 enum Type { NOT_COMPILED, ATOM, IRREGEXP }; |
| 2977 enum Flag { NONE = 0, GLOBAL = 1, IGNORE_CASE = 2, MULTILINE = 4 }; | 2990 enum Flag { NONE = 0, GLOBAL = 1, IGNORE_CASE = 2, MULTILINE = 4 }; |
| 2978 | 2991 |
| 2979 class Flags { | 2992 class Flags { |
| 2980 public: | 2993 public: |
| 2981 explicit Flags(uint32_t value) : value_(value) { } | 2994 explicit Flags(uint32_t value) : value_(value) { } |
| 2982 bool is_global() { return (value_ & GLOBAL) != 0; } | 2995 bool is_global() { return (value_ & GLOBAL) != 0; } |
| 2983 bool is_ignore_case() { return (value_ & IGNORE_CASE) != 0; } | 2996 bool is_ignore_case() { return (value_ & IGNORE_CASE) != 0; } |
| 2984 bool is_multiline() { return (value_ & MULTILINE) != 0; } | 2997 bool is_multiline() { return (value_ & MULTILINE) != 0; } |
| 2985 uint32_t value() { return value_; } | 2998 uint32_t value() { return value_; } |
| 2986 private: | 2999 private: |
| 2987 uint32_t value_; | 3000 uint32_t value_; |
| 2988 }; | 3001 }; |
| 2989 | 3002 |
| 2990 DECL_ACCESSORS(data, Object) | 3003 DECL_ACCESSORS(data, Object) |
| 2991 | 3004 |
| 2992 inline Type TypeTag(); | 3005 inline Type TypeTag(); |
| 2993 inline Flags GetFlags(); | 3006 inline Flags GetFlags(); |
| 2994 inline String* Pattern(); | 3007 inline String* Pattern(); |
| 2995 inline Object* DataAt(int index); | 3008 inline Object* DataAt(int index); |
| 3009 // Set implementation data after the object has been prepared. |
| 3010 inline void SetDataAt(int index, Object* value); |
| 2996 | 3011 |
| 2997 static inline JSRegExp* cast(Object* obj); | 3012 static inline JSRegExp* cast(Object* obj); |
| 2998 | 3013 |
| 2999 // Dispatched behavior. | 3014 // Dispatched behavior. |
| 3000 #ifdef DEBUG | 3015 #ifdef DEBUG |
| 3001 void JSRegExpVerify(); | 3016 void JSRegExpVerify(); |
| 3002 #endif | 3017 #endif |
| 3003 | 3018 |
| 3004 static const int kDataOffset = JSObject::kHeaderSize; | 3019 static const int kDataOffset = JSObject::kHeaderSize; |
| 3005 static const int kSize = kDataOffset + kIntSize; | 3020 static const int kSize = kDataOffset + kIntSize; |
| 3006 | 3021 |
| 3022 // Indices in the data array. |
| 3007 static const int kTagIndex = 0; | 3023 static const int kTagIndex = 0; |
| 3008 static const int kSourceIndex = kTagIndex + 1; | 3024 static const int kSourceIndex = kTagIndex + 1; |
| 3009 static const int kFlagsIndex = kSourceIndex + 1; | 3025 static const int kFlagsIndex = kSourceIndex + 1; |
| 3010 // These two are the same since the same entry is shared for | 3026 static const int kDataIndex = kFlagsIndex + 1; |
| 3011 // different purposes in different types of regexps. | 3027 // The data fields are used in different ways depending on the |
| 3012 static const int kAtomPatternIndex = kFlagsIndex + 1; | 3028 // value of the tag. |
| 3013 static const int kIrregexpDataIndex = kFlagsIndex + 1; | 3029 // Atom regexps (literal strings). |
| 3014 static const int kDataSize = kAtomPatternIndex + 1; | 3030 static const int kAtomPatternIndex = kDataIndex; |
| 3031 |
| 3032 static const int kAtomDataSize = kAtomPatternIndex + 1; |
| 3033 |
| 3034 // Irregexp compiled code or bytecode for ASCII. |
| 3035 static const int kIrregexpASCIICodeIndex = kDataIndex; |
| 3036 // Irregexp compiled code or bytecode for UC16. |
| 3037 static const int kIrregexpUC16CodeIndex = kDataIndex + 1; |
| 3038 // Maximal number of registers used by either ASCII or UC16. |
| 3039 // Only used to check that there is enough stack space |
| 3040 static const int kIrregexpMaxRegisterCountIndex = kDataIndex + 2; |
| 3041 // Number of captures in the compiled regexp. |
| 3042 static const int kIrregexpCaptureCountIndex = kDataIndex + 3; |
| 3043 |
| 3044 static const int kIrregexpDataSize = kIrregexpCaptureCountIndex + 1; |
| 3015 }; | 3045 }; |
| 3016 | 3046 |
| 3017 | 3047 |
| 3018 class CompilationCacheTable: public HashTable<0, 2> { | 3048 class CompilationCacheTable: public HashTable<0, 2> { |
| 3019 public: | 3049 public: |
| 3020 // Find cached value for a string key, otherwise return null. | 3050 // Find cached value for a string key, otherwise return null. |
| 3021 Object* Lookup(String* src); | 3051 Object* Lookup(String* src); |
| 3022 Object* LookupEval(String* src, Context* context); | 3052 Object* LookupEval(String* src, Context* context); |
| 3023 Object* LookupRegExp(String* source, JSRegExp::Flags flags); | 3053 Object* LookupRegExp(String* source, JSRegExp::Flags flags); |
| 3024 Object* Put(String* src, Object* value); | 3054 Object* Put(String* src, Object* value); |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3799 | 3829 |
| 3800 // Set the content of the array to the content of storage. | 3830 // Set the content of the array to the content of storage. |
| 3801 inline void SetContent(FixedArray* storage); | 3831 inline void SetContent(FixedArray* storage); |
| 3802 | 3832 |
| 3803 // Support for sorting | 3833 // Support for sorting |
| 3804 Object* RemoveHoles(); | 3834 Object* RemoveHoles(); |
| 3805 | 3835 |
| 3806 // Casting. | 3836 // Casting. |
| 3807 static inline JSArray* cast(Object* obj); | 3837 static inline JSArray* cast(Object* obj); |
| 3808 | 3838 |
| 3839 // Uses handles. Ensures that the fixed array backing the JSArray has at |
| 3840 // least the stated size. |
| 3841 void EnsureSize(int minimum_size_of_backing_fixed_array); |
| 3842 |
| 3809 // Dispatched behavior. | 3843 // Dispatched behavior. |
| 3810 #ifdef DEBUG | 3844 #ifdef DEBUG |
| 3811 void JSArrayPrint(); | 3845 void JSArrayPrint(); |
| 3812 void JSArrayVerify(); | 3846 void JSArrayVerify(); |
| 3813 #endif | 3847 #endif |
| 3814 | 3848 |
| 3815 // Layout description. | 3849 // Layout description. |
| 3816 static const int kLengthOffset = JSObject::kHeaderSize; | 3850 static const int kLengthOffset = JSObject::kHeaderSize; |
| 3817 static const int kSize = kLengthOffset + kPointerSize; | 3851 static const int kSize = kLengthOffset + kPointerSize; |
| 3818 | 3852 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4265 } else { | 4299 } else { |
| 4266 value &= ~(1 << bit_position); | 4300 value &= ~(1 << bit_position); |
| 4267 } | 4301 } |
| 4268 return value; | 4302 return value; |
| 4269 } | 4303 } |
| 4270 }; | 4304 }; |
| 4271 | 4305 |
| 4272 } } // namespace v8::internal | 4306 } } // namespace v8::internal |
| 4273 | 4307 |
| 4274 #endif // V8_OBJECTS_H_ | 4308 #endif // V8_OBJECTS_H_ |
| OLD | NEW |