V8 Project
jsregexp-inl.h
Go to the documentation of this file.
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 
6 #ifndef V8_JSREGEXP_INL_H_
7 #define V8_JSREGEXP_INL_H_
8 
9 #include "src/allocation.h"
10 #include "src/handles.h"
11 #include "src/heap/heap.h"
12 #include "src/jsregexp.h"
13 #include "src/objects.h"
14 
15 namespace v8 {
16 namespace internal {
17 
18 
19 RegExpImpl::GlobalCache::~GlobalCache() {
20  // Deallocate the register array if we allocated it in the constructor
21  // (as opposed to using the existing jsregexp_static_offsets_vector).
24  }
25 }
26 
27 
28 int32_t* RegExpImpl::GlobalCache::FetchNext() {
29  current_match_index_++;
30  if (current_match_index_ >= num_matches_) {
31  // Current batch of results exhausted.
32  // Fail if last batch was not even fully filled.
33  if (num_matches_ < max_matches_) {
34  num_matches_ = 0; // Signal failed match.
35  return NULL;
36  }
37 
38  int32_t* last_match =
39  &register_array_[(current_match_index_ - 1) * registers_per_match_];
40  int last_end_index = last_match[1];
41 
42  if (regexp_->TypeTag() == JSRegExp::ATOM) {
43  num_matches_ = RegExpImpl::AtomExecRaw(regexp_,
44  subject_,
45  last_end_index,
46  register_array_,
47  register_array_size_);
48  } else {
49  int last_start_index = last_match[0];
50  if (last_start_index == last_end_index) last_end_index++;
51  if (last_end_index > subject_->length()) {
52  num_matches_ = 0; // Signal failed match.
53  return NULL;
54  }
55  num_matches_ = RegExpImpl::IrregexpExecRaw(regexp_,
56  subject_,
57  last_end_index,
58  register_array_,
59  register_array_size_);
60  }
61 
62  if (num_matches_ <= 0) return NULL;
63  current_match_index_ = 0;
64  return register_array_;
65  } else {
66  return &register_array_[current_match_index_ * registers_per_match_];
67  }
68 }
69 
70 
71 int32_t* RegExpImpl::GlobalCache::LastSuccessfulMatch() {
72  int index = current_match_index_ * registers_per_match_;
73  if (num_matches_ == 0) {
74  // After a failed match we shift back by one result.
75  index -= registers_per_match_;
76  }
77  return &register_array_[index];
78 }
79 
80 
81 } } // namespace v8::internal
82 
83 #endif // V8_JSREGEXP_INL_H_
static const int kJSRegexpStaticOffsetsVectorSize
Definition: isolate.h:984
static int AtomExecRaw(Handle< JSRegExp > regexp, Handle< String > subject, int index, int32_t *output, int output_size)
Definition: jsregexp.cc:270
static int IrregexpExecRaw(Handle< JSRegExp > regexp, Handle< String > subject, int index, int32_t *output, int output_size)
Definition: jsregexp.cc:526
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
int int32_t
Definition: unicode.cc:24
void DeleteArray(T *array)
Definition: allocation.h:68
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20