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 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 Handle<String> error; | 1417 Handle<String> error; |
1418 int capture_count; | 1418 int capture_count; |
1419 }; | 1419 }; |
1420 | 1420 |
1421 | 1421 |
1422 class RegExpEngine: public AllStatic { | 1422 class RegExpEngine: public AllStatic { |
1423 public: | 1423 public: |
1424 struct CompilationResult { | 1424 struct CompilationResult { |
1425 explicit CompilationResult(const char* error_message) | 1425 explicit CompilationResult(const char* error_message) |
1426 : error_message(error_message), | 1426 : error_message(error_message), |
1427 code(Heap::the_hole_value()), | 1427 code(HEAP->the_hole_value()), |
1428 num_registers(0) {} | 1428 num_registers(0) {} |
1429 CompilationResult(Object* code, int registers) | 1429 CompilationResult(Object* code, int registers) |
1430 : error_message(NULL), | 1430 : error_message(NULL), |
1431 code(code), | 1431 code(code), |
1432 num_registers(registers) {} | 1432 num_registers(registers) {} |
1433 const char* error_message; | 1433 const char* error_message; |
1434 Object* code; | 1434 Object* code; |
1435 int num_registers; | 1435 int num_registers; |
1436 }; | 1436 }; |
1437 | 1437 |
1438 static CompilationResult Compile(RegExpCompileData* input, | 1438 static CompilationResult Compile(RegExpCompileData* input, |
1439 bool ignore_case, | 1439 bool ignore_case, |
1440 bool multiline, | 1440 bool multiline, |
1441 Handle<String> pattern, | 1441 Handle<String> pattern, |
1442 bool is_ascii); | 1442 bool is_ascii); |
1443 | 1443 |
1444 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); | 1444 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); |
1445 }; | 1445 }; |
1446 | 1446 |
1447 | 1447 |
1448 class OffsetsVector { | 1448 class OffsetsVector { |
1449 public: | 1449 public: |
1450 inline OffsetsVector(int num_registers) | 1450 inline OffsetsVector(int num_registers) |
1451 : offsets_vector_length_(num_registers) { | 1451 : offsets_vector_length_(num_registers) { |
1452 if (offsets_vector_length_ > kStaticOffsetsVectorSize) { | 1452 if (offsets_vector_length_ > Isolate::kJSRegexpStaticOffsetsVectorSize) { |
1453 vector_ = NewArray<int>(offsets_vector_length_); | 1453 vector_ = NewArray<int>(offsets_vector_length_); |
1454 } else { | 1454 } else { |
1455 vector_ = static_offsets_vector_; | 1455 vector_ = Isolate::Current()->jsregexp_static_offsets_vector(); |
1456 } | 1456 } |
1457 } | 1457 } |
1458 inline ~OffsetsVector() { | 1458 inline ~OffsetsVector() { |
1459 if (offsets_vector_length_ > kStaticOffsetsVectorSize) { | 1459 if (offsets_vector_length_ > Isolate::kJSRegexpStaticOffsetsVectorSize) { |
1460 DeleteArray(vector_); | 1460 DeleteArray(vector_); |
1461 vector_ = NULL; | 1461 vector_ = NULL; |
1462 } | 1462 } |
1463 } | 1463 } |
1464 inline int* vector() { return vector_; } | 1464 inline int* vector() { return vector_; } |
1465 inline int length() { return offsets_vector_length_; } | 1465 inline int length() { return offsets_vector_length_; } |
1466 | 1466 |
1467 static const int kStaticOffsetsVectorSize = 50; | 1467 static const int kStaticOffsetsVectorSize = 50; |
1468 | 1468 |
1469 private: | 1469 private: |
1470 static Address static_offsets_vector_address() { | 1470 static Address static_offsets_vector_address(Isolate* isolate) { |
1471 return reinterpret_cast<Address>(&static_offsets_vector_); | 1471 return reinterpret_cast<Address>(isolate->jsregexp_static_offsets_vector()); |
1472 } | 1472 } |
1473 | 1473 |
1474 int* vector_; | 1474 int* vector_; |
1475 int offsets_vector_length_; | 1475 int offsets_vector_length_; |
1476 static int static_offsets_vector_[kStaticOffsetsVectorSize]; | |
1477 | 1476 |
1478 friend class ExternalReference; | 1477 friend class ExternalReference; |
1479 }; | 1478 }; |
1480 | 1479 |
1481 | 1480 |
1482 } } // namespace v8::internal | 1481 } } // namespace v8::internal |
1483 | 1482 |
1484 #endif // V8_JSREGEXP_H_ | 1483 #endif // V8_JSREGEXP_H_ |
OLD | NEW |