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

Side by Side Diff: src/jsregexp.h

Issue 40290: Experimental: Merge 1395:1441 from bleeding_edge branch to the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/global/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « src/heap.cc ('k') | src/jsregexp.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 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // generic data and choice of implementation - as well as what 52 // generic data and choice of implementation - as well as what
53 // the implementation wants to store in the data field. 53 // the implementation wants to store in the data field.
54 static Handle<Object> Compile(Handle<JSRegExp> re, 54 static Handle<Object> Compile(Handle<JSRegExp> re,
55 Handle<String> pattern, 55 Handle<String> pattern,
56 Handle<String> flags); 56 Handle<String> flags);
57 57
58 // See ECMA-262 section 15.10.6.2. 58 // See ECMA-262 section 15.10.6.2.
59 // This function calls the garbage collector if necessary. 59 // This function calls the garbage collector if necessary.
60 static Handle<Object> Exec(Handle<JSRegExp> regexp, 60 static Handle<Object> Exec(Handle<JSRegExp> regexp,
61 Handle<String> subject, 61 Handle<String> subject,
62 int index, 62 Handle<Object> index);
63 Handle<JSArray> lastMatchInfo);
64 63
65 // Call RegExp.prototyp.exec(string) in a loop. 64 // Call RegExp.prototyp.exec(string) in a loop.
66 // Used by String.prototype.match and String.prototype.replace. 65 // Used by String.prototype.match and String.prototype.replace.
67 // This function calls the garbage collector if necessary. 66 // This function calls the garbage collector if necessary.
68 static Handle<Object> ExecGlobal(Handle<JSRegExp> regexp, 67 static Handle<Object> ExecGlobal(Handle<JSRegExp> regexp,
69 Handle<String> subject, 68 Handle<String> subject);
70 Handle<JSArray> lastMatchInfo);
71 69
72 // Prepares a JSRegExp object with Irregexp-specific data. 70 // Prepares a JSRegExp object with Irregexp-specific data.
73 static Handle<Object> IrregexpPrepare(Handle<JSRegExp> re, 71 static Handle<Object> IrregexpPrepare(Handle<JSRegExp> re,
74 Handle<String> pattern, 72 Handle<String> pattern,
75 JSRegExp::Flags flags); 73 JSRegExp::Flags flags);
76 74
77 75
78 static Handle<Object> AtomCompile(Handle<JSRegExp> re, 76 static Handle<Object> AtomCompile(Handle<JSRegExp> re,
79 Handle<String> pattern, 77 Handle<String> pattern,
80 JSRegExp::Flags flags, 78 JSRegExp::Flags flags,
81 Handle<String> match_pattern); 79 Handle<String> match_pattern);
82 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, 80 static Handle<Object> AtomExec(Handle<JSRegExp> regexp,
83 Handle<String> subject, 81 Handle<String> subject,
84 int index, 82 Handle<Object> index);
85 Handle<JSArray> lastMatchInfo);
86 83
87 static Handle<Object> AtomExecGlobal(Handle<JSRegExp> regexp, 84 static Handle<Object> AtomExecGlobal(Handle<JSRegExp> regexp,
88 Handle<String> subject, 85 Handle<String> subject);
89 Handle<JSArray> lastMatchInfo);
90 86
91 // Execute an Irregexp bytecode pattern. 87 // Execute an Irregexp bytecode pattern.
92 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp, 88 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp,
93 Handle<String> subject, 89 Handle<String> subject,
94 int index, 90 Handle<Object> index);
95 Handle<JSArray> lastMatchInfo);
96 91
97 static Handle<Object> IrregexpExecGlobal(Handle<JSRegExp> regexp, 92 static Handle<Object> IrregexpExecGlobal(Handle<JSRegExp> regexp,
98 Handle<String> subject, 93 Handle<String> subject);
99 Handle<JSArray> lastMatchInfo);
100 94
101 static void NewSpaceCollectionPrologue(); 95 static void NewSpaceCollectionPrologue();
102 static void OldSpaceCollectionPrologue(); 96 static void OldSpaceCollectionPrologue();
103 97
104 // Converts a source string to a 16 bit flat string. The string 98 // Converts a source string to a 16 bit flat string. The string
105 // will be either sequential or it will be a SlicedString backed 99 // will be either sequential or it will be a SlicedString backed
106 // by a flat string. 100 // by a flat string.
107 static Handle<String> StringToTwoByte(Handle<String> pattern); 101 static Handle<String> StringToTwoByte(Handle<String> pattern);
108 static Handle<String> CachedStringToTwoByte(Handle<String> pattern); 102 static Handle<String> CachedStringToTwoByte(Handle<String> pattern);
109 103
110 static const int kIrregexpImplementationIndex = 0; 104 static const int kIrregexpImplementationIndex = 0;
111 static const int kIrregexpNumberOfCapturesIndex = 1; 105 static const int kIrregexpNumberOfCapturesIndex = 1;
112 static const int kIrregexpNumberOfRegistersIndex = 2; 106 static const int kIrregexpNumberOfRegistersIndex = 2;
113 static const int kIrregexpCodeIndex = 3; 107 static const int kIrregexpCodeIndex = 3;
114 static const int kIrregexpDataLength = 4; 108 static const int kIrregexpDataLength = 4;
115 109
116 // Offsets in the lastMatchInfo array.
117 static const int kLastCaptureCount = 0;
118 static const int kLastSubject = 1;
119 static const int kLastInput = 2;
120 static const int kFirstCapture = 1;
121 static const int kLastMatchOverhead = 3;
122 static int GetCapture(FixedArray* array, int index) {
123 return Smi::cast(array->get(index + kFirstCapture))->value();
124 }
125 static void SetLastCaptureCount(FixedArray* array, int to) {
126 array->set(kLastCaptureCount, Smi::FromInt(to));
127 }
128 static void SetLastSubject(FixedArray* array, String* to) {
129 int capture_count = GetLastCaptureCount(array);
130 array->set(capture_count + kLastSubject, to);
131 }
132 static void SetLastInput(FixedArray* array, String* to) {
133 int capture_count = GetLastCaptureCount(array);
134 array->set(capture_count + kLastInput, to);
135 }
136 static void SetCapture(FixedArray* array, int index, int to) {
137 array->set(index + kFirstCapture, Smi::FromInt(to));
138 }
139
140 private: 110 private:
141 static String* last_ascii_string_; 111 static String* last_ascii_string_;
142 static String* two_byte_cached_string_; 112 static String* two_byte_cached_string_;
143 113
144 static int IrregexpNumberOfCaptures(Handle<FixedArray> re); 114 static int IrregexpNumberOfCaptures(Handle<FixedArray> re);
145 static int IrregexpNumberOfRegisters(Handle<FixedArray> re); 115 static int IrregexpNumberOfRegisters(Handle<FixedArray> re);
146 static Handle<ByteArray> IrregexpByteCode(Handle<FixedArray> re); 116 static Handle<ByteArray> IrregexpByteCode(Handle<FixedArray> re);
147 static Handle<Code> IrregexpNativeCode(Handle<FixedArray> re); 117 static Handle<Code> IrregexpNativeCode(Handle<FixedArray> re);
148 118
149 // On a successful match, the result is a JSArray containing 119 // On a successful match, the result is a JSArray containing
150 // captured positions. On a failure, the result is the null value. 120 // captured positions. On a failure, the result is the null value.
151 // Returns an empty handle in case of an exception. 121 // Returns an empty handle in case of an exception.
152 static Handle<Object> IrregexpExecOnce(Handle<FixedArray> regexp, 122 static Handle<Object> IrregexpExecOnce(Handle<FixedArray> regexp,
153 int num_captures, 123 int num_captures,
154 Handle<JSArray> lastMatchInfo,
155 Handle<String> subject16, 124 Handle<String> subject16,
156 int previous_index, 125 int previous_index,
157 int* ovector, 126 int* ovector,
158 int ovector_length); 127 int ovector_length);
159 128
160 // Set the subject cache. The previous string buffer is not deleted, so the 129 // Set the subject cache. The previous string buffer is not deleted, so the
161 // caller should ensure that it doesn't leak. 130 // caller should ensure that it doesn't leak.
162 static void SetSubjectCache(String* subject, 131 static void SetSubjectCache(String* subject,
163 char* utf8_subject, 132 char* utf8_subject,
164 int uft8_length, 133 int uft8_length,
165 int character_position, 134 int character_position,
166 int utf8_position); 135 int utf8_position);
167 136
168 // Used to access the lastMatchInfo array.
169 static int GetLastCaptureCount(FixedArray* array) {
170 return Smi::cast(array->get(kLastCaptureCount))->value();
171 }
172 // A one element cache of the last utf8_subject string and its length. The 137 // A one element cache of the last utf8_subject string and its length. The
173 // subject JS String object is cached in the heap. We also cache a 138 // subject JS String object is cached in the heap. We also cache a
174 // translation between position and utf8 position. 139 // translation between position and utf8 position.
175 static char* utf8_subject_cache_; 140 static char* utf8_subject_cache_;
176 static int utf8_length_cache_; 141 static int utf8_length_cache_;
177 static int utf8_position_; 142 static int utf8_position_;
178 static int character_position_; 143 static int character_position_;
179 }; 144 };
180 145
181 146
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 Handle<String> pattern, 1325 Handle<String> pattern,
1361 bool is_ascii); 1326 bool is_ascii);
1362 1327
1363 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); 1328 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case);
1364 }; 1329 };
1365 1330
1366 1331
1367 } } // namespace v8::internal 1332 } } // namespace v8::internal
1368 1333
1369 #endif // V8_JSREGEXP_H_ 1334 #endif // V8_JSREGEXP_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698