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

Side by Side Diff: src/objects.h

Issue 28311: Flattened the representation of compiled RegExp data. (Closed)
Patch Set: ... and it lints. Created 11 years, 9 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 unified diff | Download patch
OLDNEW
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 2921 matching lines...) Expand 10 before | Expand all | Expand 10 after
2932 2932
2933 // Layout description. 2933 // Layout description.
2934 static const int kValueOffset = JSObject::kHeaderSize; 2934 static const int kValueOffset = JSObject::kHeaderSize;
2935 static const int kSize = kValueOffset + kPointerSize; 2935 static const int kSize = kValueOffset + kPointerSize;
2936 2936
2937 private: 2937 private:
2938 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue); 2938 DISALLOW_IMPLICIT_CONSTRUCTORS(JSValue);
2939 }; 2939 };
2940 2940
2941 // Regular expressions 2941 // Regular expressions
2942 // The regular expression holds a single reference to a FixedArray in
2943 // the kDataOffset field.
2944 // The FixedArray contains the following data:
2945 // - tag : type of regexp implementation (not compiled yet, atom or irregexp)
2946 // - reference to the original source string
2947 // - reference to the original flag string
2948 // If it is an atom regexp
2949 // - a reference to a literal string to search for
2950 // If it is an irregexp regexp:
2951 // - a reference to code for ASCII inputs (bytecode or compiled).
2952 // - a reference to code for UC16 inputs (bytecode or compiled).
2953 // - max number of registers used by irregexp implementations.
2954 // - number of capture registers (output values) of the regexp.
2942 class JSRegExp: public JSObject { 2955 class JSRegExp: public JSObject {
2943 public: 2956 public:
2944 // Meaning of Type: 2957 // Meaning of Type:
2945 // NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet. 2958 // NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet.
2946 // ATOM: A simple string to match against using an indexOf operation. 2959 // ATOM: A simple string to match against using an indexOf operation.
2947 // IRREGEXP: Compiled with Irregexp. 2960 // IRREGEXP: Compiled with Irregexp.
2948 // IRREGEXP_NATIVE: Compiled to native code with Irregexp. 2961 // IRREGEXP_NATIVE: Compiled to native code with Irregexp.
2949 enum Type { NOT_COMPILED, ATOM, IRREGEXP }; 2962 enum Type { NOT_COMPILED, ATOM, IRREGEXP };
2950 enum Flag { NONE = 0, GLOBAL = 1, IGNORE_CASE = 2, MULTILINE = 4 }; 2963 enum Flag { NONE = 0, GLOBAL = 1, IGNORE_CASE = 2, MULTILINE = 4 };
2951 2964
2952 class Flags { 2965 class Flags {
2953 public: 2966 public:
2954 explicit Flags(uint32_t value) : value_(value) { } 2967 explicit Flags(uint32_t value) : value_(value) { }
2955 bool is_global() { return (value_ & GLOBAL) != 0; } 2968 bool is_global() { return (value_ & GLOBAL) != 0; }
2956 bool is_ignore_case() { return (value_ & IGNORE_CASE) != 0; } 2969 bool is_ignore_case() { return (value_ & IGNORE_CASE) != 0; }
2957 bool is_multiline() { return (value_ & MULTILINE) != 0; } 2970 bool is_multiline() { return (value_ & MULTILINE) != 0; }
2958 uint32_t value() { return value_; } 2971 uint32_t value() { return value_; }
2959 private: 2972 private:
2960 uint32_t value_; 2973 uint32_t value_;
2961 }; 2974 };
2962 2975
2963 DECL_ACCESSORS(data, Object) 2976 DECL_ACCESSORS(data, Object)
2964 2977
2965 inline Type TypeTag(); 2978 inline Type TypeTag();
2966 inline Flags GetFlags(); 2979 inline Flags GetFlags();
2967 inline String* Pattern(); 2980 inline String* Pattern();
2968 inline Object* DataAt(int index); 2981 inline Object* DataAt(int index);
2982 // Set implementation data after the object has been prepared.
2983 inline void SetDataAt(int index, Object* value);
2969 2984
2970 static inline JSRegExp* cast(Object* obj); 2985 static inline JSRegExp* cast(Object* obj);
2971 2986
2972 // Dispatched behavior. 2987 // Dispatched behavior.
2973 #ifdef DEBUG 2988 #ifdef DEBUG
2974 void JSRegExpVerify(); 2989 void JSRegExpVerify();
2975 #endif 2990 #endif
2976 2991
2977 static const int kDataOffset = JSObject::kHeaderSize; 2992 static const int kDataOffset = JSObject::kHeaderSize;
2978 static const int kSize = kDataOffset + kIntSize; 2993 static const int kSize = kDataOffset + kIntSize;
2979 2994
2995 // Indices in the data array.
2980 static const int kTagIndex = 0; 2996 static const int kTagIndex = 0;
2981 static const int kSourceIndex = kTagIndex + 1; 2997 static const int kSourceIndex = kTagIndex + 1;
2982 static const int kFlagsIndex = kSourceIndex + 1; 2998 static const int kFlagsIndex = kSourceIndex + 1;
2983 // These two are the same since the same entry is shared for 2999 static const int kDataIndex = kFlagsIndex + 1;
2984 // different purposes in different types of regexps. 3000 // The data fields are used in different ways depending on the
2985 static const int kAtomPatternIndex = kFlagsIndex + 1; 3001 // value of the tag.
2986 static const int kIrregexpDataIndex = kFlagsIndex + 1; 3002 // Atom regexps (literal strings).
2987 static const int kDataSize = kAtomPatternIndex + 1; 3003 static const int kAtomPatternIndex = kDataIndex;
3004
3005 static const int kAtomDataSize = kAtomPatternIndex + 1;
3006
3007 // Irregexp compiled code or bytecode for ASCII.
3008 static const int kIrregexpASCIICodeIndex = kDataIndex;
3009 // Irregexp compiled code or bytecode for UC16.
3010 static const int kIrregexpUC16CodeIndex = kDataIndex + 1;
3011 // Maximal number of registers used by either ASCII or UC16.
3012 // Only used to check that there is enough stack space
3013 static const int kIrregexpMaxRegisterCountIndex = kDataIndex + 2;
3014 // Number of captures in the compiled regexp.
3015 static const int kIrregexpCaptureCountIndex = kDataIndex + 3;
3016
3017 static const int kIrregexpDataSize = kIrregexpCaptureCountIndex + 1;
2988 }; 3018 };
2989 3019
2990 3020
2991 class CompilationCacheTable: public HashTable<0, 2> { 3021 class CompilationCacheTable: public HashTable<0, 2> {
2992 public: 3022 public:
2993 // Find cached value for a string key, otherwise return null. 3023 // Find cached value for a string key, otherwise return null.
2994 Object* Lookup(String* src); 3024 Object* Lookup(String* src);
2995 Object* LookupEval(String* src, Context* context); 3025 Object* LookupEval(String* src, Context* context);
2996 Object* LookupRegExp(String* source, JSRegExp::Flags flags); 3026 Object* LookupRegExp(String* source, JSRegExp::Flags flags);
2997 Object* Put(String* src, Object* value); 3027 Object* Put(String* src, Object* value);
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
4242 } else { 4272 } else {
4243 value &= ~(1 << bit_position); 4273 value &= ~(1 << bit_position);
4244 } 4274 }
4245 return value; 4275 return value;
4246 } 4276 }
4247 }; 4277 };
4248 4278
4249 } } // namespace v8::internal 4279 } } // namespace v8::internal
4250 4280
4251 #endif // V8_OBJECTS_H_ 4281 #endif // V8_OBJECTS_H_
OLDNEW
« src/jsregexp.cc ('K') | « src/jsregexp.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698