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

Side by Side Diff: src/jsregexp.h

Issue 521028: Direct call to native RegExp code from JavaScript (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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/ia32/simulator-ia32.h ('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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 // Execute an Irregexp bytecode pattern. 95 // Execute an Irregexp bytecode pattern.
96 // On a successful match, the result is a JSArray containing 96 // On a successful match, the result is a JSArray containing
97 // captured positions. On a failure, the result is the null value. 97 // captured positions. On a failure, the result is the null value.
98 // Returns an empty handle in case of an exception. 98 // Returns an empty handle in case of an exception.
99 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp, 99 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp,
100 Handle<String> subject, 100 Handle<String> subject,
101 int index, 101 int index,
102 Handle<JSArray> lastMatchInfo); 102 Handle<JSArray> lastMatchInfo);
103 103
104 // Offsets in the lastMatchInfo array. 104 // Array index in the lastMatchInfo array.
105 static const int kLastCaptureCount = 0; 105 static const int kLastCaptureCount = 0;
106 static const int kLastSubject = 1; 106 static const int kLastSubject = 1;
107 static const int kLastInput = 2; 107 static const int kLastInput = 2;
108 static const int kFirstCapture = 3; 108 static const int kFirstCapture = 3;
109 static const int kLastMatchOverhead = 3; 109 static const int kLastMatchOverhead = 3;
110 110
111 // Direct offset into the lastMatchInfo array.
112 static const int kLastCaptureCountOffset =
113 FixedArray::kHeaderSize + kLastCaptureCount * kPointerSize;
114 static const int kLastSubjectOffset =
115 FixedArray::kHeaderSize + kLastSubject * kPointerSize;
116 static const int kLastInputOffset =
117 FixedArray::kHeaderSize + kLastInput * kPointerSize;
118 static const int kFirstCaptureOffset =
119 FixedArray::kHeaderSize + kFirstCapture * kPointerSize;
120
111 // Used to access the lastMatchInfo array. 121 // Used to access the lastMatchInfo array.
112 static int GetCapture(FixedArray* array, int index) { 122 static int GetCapture(FixedArray* array, int index) {
113 return Smi::cast(array->get(index + kFirstCapture))->value(); 123 return Smi::cast(array->get(index + kFirstCapture))->value();
114 } 124 }
115 125
116 static void SetLastCaptureCount(FixedArray* array, int to) { 126 static void SetLastCaptureCount(FixedArray* array, int to) {
117 array->set(kLastCaptureCount, Smi::FromInt(to)); 127 array->set(kLastCaptureCount, Smi::FromInt(to));
118 } 128 }
119 129
120 static void SetLastSubject(FixedArray* array, String* to) { 130 static void SetLastSubject(FixedArray* array, String* to) {
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 static CompilationResult Compile(RegExpCompileData* input, 1279 static CompilationResult Compile(RegExpCompileData* input,
1270 bool ignore_case, 1280 bool ignore_case,
1271 bool multiline, 1281 bool multiline,
1272 Handle<String> pattern, 1282 Handle<String> pattern,
1273 bool is_ascii); 1283 bool is_ascii);
1274 1284
1275 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); 1285 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case);
1276 }; 1286 };
1277 1287
1278 1288
1289 class OffsetsVector {
1290 public:
1291 inline OffsetsVector(int num_registers)
1292 : offsets_vector_length_(num_registers) {
1293 if (offsets_vector_length_ > kStaticOffsetsVectorSize) {
1294 vector_ = NewArray<int>(offsets_vector_length_);
1295 } else {
1296 vector_ = static_offsets_vector_;
1297 }
1298 }
1299 inline ~OffsetsVector() {
1300 if (offsets_vector_length_ > kStaticOffsetsVectorSize) {
1301 DeleteArray(vector_);
1302 vector_ = NULL;
1303 }
1304 }
1305 inline int* vector() { return vector_; }
1306 inline int length() { return offsets_vector_length_; }
1307
1308 static const int kStaticOffsetsVectorSize = 50;
1309
1310 private:
1311 static Address static_offsets_vector_address() {
1312 return reinterpret_cast<Address>(&static_offsets_vector_);
1313 }
1314
1315 int* vector_;
1316 int offsets_vector_length_;
1317 static int static_offsets_vector_[kStaticOffsetsVectorSize];
1318
1319 friend class ExternalReference;
1320 };
1321
1322
1279 } } // namespace v8::internal 1323 } } // namespace v8::internal
1280 1324
1281 #endif // V8_JSREGEXP_H_ 1325 #endif // V8_JSREGEXP_H_
OLDNEW
« no previous file with comments | « src/ia32/simulator-ia32.h ('k') | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698