| Index: src/objects.h
|
| diff --git a/src/objects.h b/src/objects.h
|
| index 0ce8f977c758efd981456abf558411363567a731..86042acc048030b4589436c7aada28b0c84c9ae5 100644
|
| --- a/src/objects.h
|
| +++ b/src/objects.h
|
| @@ -9209,29 +9209,10 @@ class String: public Name {
|
| return NonOneByteStart(chars, length) >= length;
|
| }
|
|
|
| - // TODO(dcarney): Replace all instances of this with VisitFlat.
|
| - template<class Visitor, class ConsOp>
|
| - static inline void Visit(String* string,
|
| - unsigned offset,
|
| - Visitor& visitor,
|
| - ConsOp& cons_op,
|
| - int32_t type,
|
| - unsigned length);
|
| -
|
| - template<class Visitor>
|
| - static inline ConsString* VisitFlat(Visitor* visitor,
|
| - String* string,
|
| - int offset,
|
| - int length,
|
| - int32_t type);
|
| -
|
| template<class Visitor>
|
| static inline ConsString* VisitFlat(Visitor* visitor,
|
| String* string,
|
| - int offset = 0) {
|
| - int32_t type = string->map()->instance_type();
|
| - return VisitFlat(visitor, string, offset, string->length(), type);
|
| - }
|
| + int offset = 0);
|
|
|
| static Handle<FixedArray> CalculateLineEnds(Handle<String> string,
|
| bool include_ending_line);
|
| @@ -9617,57 +9598,63 @@ class ConsStringNullOp {
|
| // This maintains an off-stack representation of the stack frames required
|
| // to traverse a ConsString, allowing an entirely iterative and restartable
|
| // traversal of the entire string
|
| -// Note: this class is not GC-safe.
|
| class ConsStringIteratorOp {
|
| public:
|
| inline ConsStringIteratorOp() {}
|
| - String* Operate(String* string,
|
| - unsigned* offset_out,
|
| - int32_t* type_out,
|
| - unsigned* length_out);
|
| - inline String* ContinueOperation(int32_t* type_out, unsigned* length_out);
|
| - inline void Reset();
|
| - inline bool HasMore();
|
| + inline ConsStringIteratorOp(ConsString* cons_string, int offset = 0) {
|
| + Reset(cons_string, offset);
|
| + }
|
| + inline void Reset(ConsString* cons_string, int offset = 0) {
|
| + depth_ = 0;
|
| + // Next will always return NULL.
|
| + if (cons_string == NULL) return;
|
| + Initialize(cons_string, offset);
|
| + }
|
| + // Returns NULL when complete.
|
| + inline String* Next(int* offset_out) {
|
| + *offset_out = 0;
|
| + if (depth_ == 0) return NULL;
|
| + return Continue(offset_out);
|
| + }
|
|
|
| private:
|
| - // TODO(dcarney): Templatize this out for different stack sizes.
|
| - static const unsigned kStackSize = 32;
|
| + static const int kStackSize = 32;
|
| // Use a mask instead of doing modulo operations for stack wrapping.
|
| - static const unsigned kDepthMask = kStackSize-1;
|
| + static const int kDepthMask = kStackSize-1;
|
| STATIC_ASSERT(IS_POWER_OF_TWO(kStackSize));
|
| - static inline unsigned OffsetForDepth(unsigned depth);
|
| + static inline int OffsetForDepth(int depth);
|
|
|
| inline void PushLeft(ConsString* string);
|
| inline void PushRight(ConsString* string);
|
| inline void AdjustMaximumDepth();
|
| inline void Pop();
|
| - String* NextLeaf(bool* blew_stack, int32_t* type_out, unsigned* length_out);
|
| - String* Search(unsigned* offset_out,
|
| - int32_t* type_out,
|
| - unsigned* length_out);
|
| + inline bool StackBlown() { return maximum_depth_ - depth_ == kStackSize; }
|
| + void Initialize(ConsString* cons_string, int offset);
|
| + String* Continue(int* offset_out);
|
| + String* NextLeaf(bool* blew_stack);
|
| + String* Search(int* offset_out);
|
|
|
| - unsigned depth_;
|
| - unsigned maximum_depth_;
|
| // Stack must always contain only frames for which right traversal
|
| // has not yet been performed.
|
| ConsString* frames_[kStackSize];
|
| - unsigned consumed_;
|
| ConsString* root_;
|
| + int depth_;
|
| + int maximum_depth_;
|
| + int consumed_;
|
| DISALLOW_COPY_AND_ASSIGN(ConsStringIteratorOp);
|
| };
|
|
|
|
|
| -// Note: this class is not GC-safe.
|
| class StringCharacterStream {
|
| public:
|
| inline StringCharacterStream(String* string,
|
| ConsStringIteratorOp* op,
|
| - unsigned offset = 0);
|
| + int offset = 0);
|
| inline uint16_t GetNext();
|
| inline bool HasMore();
|
| - inline void Reset(String* string, unsigned offset = 0);
|
| - inline void VisitOneByteString(const uint8_t* chars, unsigned length);
|
| - inline void VisitTwoByteString(const uint16_t* chars, unsigned length);
|
| + inline void Reset(String* string, int offset = 0);
|
| + inline void VisitOneByteString(const uint8_t* chars, int length);
|
| + inline void VisitTwoByteString(const uint16_t* chars, int length);
|
|
|
| private:
|
| bool is_one_byte_;
|
|
|