objects.h splitting: Move RegExpMatchInfo.

BUG=v8:5402

Review-Url: https://codereview.chromium.org/2642353002
Cr-Commit-Position: refs/heads/master@{#42552}
This commit is contained in:
marja 2017-01-20 05:01:55 -08:00 committed by Commit bot
parent 09525c8f90
commit 7366d8954c
8 changed files with 83 additions and 51 deletions

View File

@ -1573,6 +1573,7 @@ v8_source_set("v8_base") {
"src/objects/module-info.h", "src/objects/module-info.h",
"src/objects/object-macros-undef.h", "src/objects/object-macros-undef.h",
"src/objects/object-macros.h", "src/objects/object-macros.h",
"src/objects/regexp-match-info.h",
"src/objects/scope-info.cc", "src/objects/scope-info.cc",
"src/objects/scope-info.h", "src/objects/scope-info.h",
"src/ostreams.cc", "src/ostreams.cc",

View File

@ -7,6 +7,7 @@
#include "src/contexts.h" #include "src/contexts.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects/regexp-match-info.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {

View File

@ -11,6 +11,7 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class RegExpMatchInfo;
enum ContextLookupFlags { enum ContextLookupFlags {
FOLLOW_CONTEXT_CHAIN = 1 << 0, FOLLOW_CONTEXT_CHAIN = 1 << 0,

View File

@ -31,6 +31,7 @@
#include "src/lookup.h" #include "src/lookup.h"
#include "src/objects.h" #include "src/objects.h"
#include "src/objects/module-info.h" #include "src/objects/module-info.h"
#include "src/objects/regexp-match-info.h"
#include "src/objects/scope-info.h" #include "src/objects/scope-info.h"
#include "src/property.h" #include "src/property.h"
#include "src/prototype.h" #include "src/prototype.h"

View File

@ -3060,57 +3060,6 @@ class ArrayList : public FixedArray {
DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayList); DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayList);
}; };
// The property RegExpMatchInfo includes the matchIndices
// array of the last successful regexp match (an array of start/end index
// pairs for the match and all the captured substrings), the invariant is
// that there are at least two capture indices. The array also contains
// the subject string for the last successful match.
// After creation the result must be treated as a FixedArray in all regards.
class V8_EXPORT_PRIVATE RegExpMatchInfo : NON_EXPORTED_BASE(public FixedArray) {
public:
// Returns the number of captures, which is defined as the length of the
// matchIndices objects of the last match. matchIndices contains two indices
// for each capture (including the match itself), i.e. 2 * #captures + 2.
inline int NumberOfCaptureRegisters();
inline void SetNumberOfCaptureRegisters(int value);
// Returns the subject string of the last match.
inline String* LastSubject();
inline void SetLastSubject(String* value);
// Like LastSubject, but modifiable by the user.
inline Object* LastInput();
inline void SetLastInput(Object* value);
// Returns the i'th capture index, 0 <= i < NumberOfCaptures(). Capture(0) and
// Capture(1) determine the start- and endpoint of the match itself.
inline int Capture(int i);
inline void SetCapture(int i, int value);
// Reserves space for captures.
static Handle<RegExpMatchInfo> ReserveCaptures(
Handle<RegExpMatchInfo> match_info, int capture_count);
DECLARE_CAST(RegExpMatchInfo)
static const int kNumberOfCapturesIndex = 0;
static const int kLastSubjectIndex = 1;
static const int kLastInputIndex = 2;
static const int kFirstCaptureIndex = 3;
static const int kLastMatchOverhead = kFirstCaptureIndex;
static const int kNumberOfCapturesOffset = FixedArray::kHeaderSize;
static const int kLastSubjectOffset = kNumberOfCapturesOffset + kPointerSize;
static const int kLastInputOffset = kLastSubjectOffset + kPointerSize;
static const int kFirstCaptureOffset = kLastInputOffset + kPointerSize;
// Every match info is guaranteed to have enough space to store two captures.
static const int kInitialCaptureIndices = 2;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(RegExpMatchInfo);
};
#define FRAME_ARRAY_FIELD_LIST(V) \ #define FRAME_ARRAY_FIELD_LIST(V) \
V(WasmInstance, Object) \ V(WasmInstance, Object) \
V(WasmFunctionIndex, Smi) \ V(WasmFunctionIndex, Smi) \

View File

@ -0,0 +1,76 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_OBJECTS_REGEXP_MATCH_INFO_H_
#define V8_OBJECTS_REGEXP_MATCH_INFO_H_
#include "src/base/compiler-specific.h"
#include "src/objects.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
class Object;
class String;
// The property RegExpMatchInfo includes the matchIndices
// array of the last successful regexp match (an array of start/end index
// pairs for the match and all the captured substrings), the invariant is
// that there are at least two capture indices. The array also contains
// the subject string for the last successful match.
// After creation the result must be treated as a FixedArray in all regards.
class V8_EXPORT_PRIVATE RegExpMatchInfo : NON_EXPORTED_BASE(public FixedArray) {
public:
// Returns the number of captures, which is defined as the length of the
// matchIndices objects of the last match. matchIndices contains two indices
// for each capture (including the match itself), i.e. 2 * #captures + 2.
inline int NumberOfCaptureRegisters();
inline void SetNumberOfCaptureRegisters(int value);
// Returns the subject string of the last match.
inline String* LastSubject();
inline void SetLastSubject(String* value);
// Like LastSubject, but modifiable by the user.
inline Object* LastInput();
inline void SetLastInput(Object* value);
// Returns the i'th capture index, 0 <= i < NumberOfCaptures(). Capture(0) and
// Capture(1) determine the start- and endpoint of the match itself.
inline int Capture(int i);
inline void SetCapture(int i, int value);
// Reserves space for captures.
static Handle<RegExpMatchInfo> ReserveCaptures(
Handle<RegExpMatchInfo> match_info, int capture_count);
DECLARE_CAST(RegExpMatchInfo)
static const int kNumberOfCapturesIndex = 0;
static const int kLastSubjectIndex = 1;
static const int kLastInputIndex = 2;
static const int kFirstCaptureIndex = 3;
static const int kLastMatchOverhead = kFirstCaptureIndex;
static const int kNumberOfCapturesOffset = FixedArray::kHeaderSize;
static const int kLastSubjectOffset = kNumberOfCapturesOffset + kPointerSize;
static const int kLastInputOffset = kLastSubjectOffset + kPointerSize;
static const int kFirstCaptureOffset = kLastInputOffset + kPointerSize;
// Every match info is guaranteed to have enough space to store two captures.
static const int kInitialCaptureIndices = 2;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(RegExpMatchInfo);
};
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_REGEXP_MATCH_INFO_H_

View File

@ -10,6 +10,8 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class RegExpMatchInfo;
// Helper methods for C++ regexp builtins. // Helper methods for C++ regexp builtins.
class RegExpUtils : public AllStatic { class RegExpUtils : public AllStatic {
public: public:

View File

@ -1082,6 +1082,7 @@
'objects/module-info.h', 'objects/module-info.h',
'objects/object-macros.h', 'objects/object-macros.h',
'objects/object-macros-undef.h', 'objects/object-macros-undef.h',
'objects/regexp-match-info.h',
'objects/scope-info.cc', 'objects/scope-info.cc',
'objects/scope-info.h', 'objects/scope-info.h',
'ostreams.cc', 'ostreams.cc',