OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 7499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7510 } | 7510 } |
7511 | 7511 |
7512 static inline bool IsAscii(const uc16* chars, int length) { | 7512 static inline bool IsAscii(const uc16* chars, int length) { |
7513 return NonAsciiStart(chars, length) >= length; | 7513 return NonAsciiStart(chars, length) >= length; |
7514 } | 7514 } |
7515 | 7515 |
7516 template<class Visitor, class ConsOp> | 7516 template<class Visitor, class ConsOp> |
7517 static inline void Visit(String* string, | 7517 static inline void Visit(String* string, |
7518 unsigned offset, | 7518 unsigned offset, |
7519 Visitor& visitor, | 7519 Visitor& visitor, |
7520 ConsOp& consOp, | 7520 ConsOp& cons_op, |
7521 int32_t type, | 7521 int32_t type, |
7522 unsigned length); | 7522 unsigned length); |
7523 | 7523 |
7524 protected: | 7524 protected: |
7525 class ReadBlockBuffer { | 7525 class ReadBlockBuffer { |
7526 public: | 7526 public: |
7527 ReadBlockBuffer(unibrow::byte* util_buffer_, | 7527 ReadBlockBuffer(unibrow::byte* util_buffer_, |
7528 unsigned cursor_, | 7528 unsigned cursor_, |
7529 unsigned capacity_, | 7529 unsigned capacity_, |
7530 unsigned remaining_) : | 7530 unsigned remaining_) : |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7981 // Note: this class is not GC-safe. | 7981 // Note: this class is not GC-safe. |
7982 class ConsStringIteratorOp { | 7982 class ConsStringIteratorOp { |
7983 public: | 7983 public: |
7984 struct ContinueResponse { | 7984 struct ContinueResponse { |
7985 String* string_; | 7985 String* string_; |
7986 unsigned offset_; | 7986 unsigned offset_; |
7987 unsigned length_; | 7987 unsigned length_; |
7988 int32_t type_; | 7988 int32_t type_; |
7989 }; | 7989 }; |
7990 inline ConsStringIteratorOp() {} | 7990 inline ConsStringIteratorOp() {} |
7991 String* Operate(ConsString* consString, unsigned* outerOffset, | 7991 String* Operate(ConsString* cons_string, unsigned* offset_out, |
7992 int32_t* typeOut, unsigned* lengthOut); | 7992 int32_t* type_out, unsigned* length_out); |
7993 inline bool ContinueOperation(ContinueResponse* response); | 7993 inline bool ContinueOperation(ContinueResponse* response); |
7994 inline void Reset(); | 7994 inline void Reset(); |
7995 inline bool HasMore(); | 7995 inline bool HasMore(); |
7996 | 7996 |
7997 private: | 7997 private: |
7998 // TODO(dcarney): Templatize this out for different stack sizes. | 7998 // TODO(dcarney): Templatize this out for different stack sizes. |
7999 static const unsigned kStackSize = 32; | 7999 static const unsigned kStackSize = 32; |
8000 // Use a mask instead of doing modulo operations for stack wrapping. | 8000 // Use a mask instead of doing modulo operations for stack wrapping. |
8001 static const unsigned kDepthMask = kStackSize-1; | 8001 static const unsigned kDepthMask = kStackSize-1; |
8002 STATIC_ASSERT(IS_POWER_OF_TWO(kStackSize)); | 8002 STATIC_ASSERT(IS_POWER_OF_TWO(kStackSize)); |
8003 static inline unsigned OffsetForDepth(unsigned depth); | 8003 static inline unsigned OffsetForDepth(unsigned depth); |
8004 static inline uint32_t MaskForDepth(unsigned depth); | |
8005 | 8004 |
8006 inline void ClearRightDescent(); | |
8007 inline void SetRightDescent(); | |
8008 inline void PushLeft(ConsString* string); | 8005 inline void PushLeft(ConsString* string); |
8009 inline void PushRight(ConsString* string, int32_t type); | 8006 inline void PushRight(ConsString* string); |
8010 inline void AdjustMaximumDepth(); | 8007 inline void AdjustMaximumDepth(); |
8011 inline void Pop(); | 8008 inline void Pop(); |
8012 inline void ResetStack(); | 8009 String* NextLeaf(bool* blew_stack, int32_t* type_out, unsigned* length_out); |
8013 String* NextLeaf(bool* blewStack, int32_t* typeOut); | |
8014 | 8010 |
8015 unsigned depth_; | 8011 unsigned depth_; |
8016 unsigned maximum_depth_; | 8012 unsigned maximum_depth_; |
8017 uint32_t trace_; | 8013 // Stack must always contain only frames for which right traversal |
| 8014 // has not yet been performed. |
8018 ConsString* frames_[kStackSize]; | 8015 ConsString* frames_[kStackSize]; |
8019 unsigned consumed_; | 8016 unsigned consumed_; |
8020 ConsString* root_; | 8017 ConsString* root_; |
8021 int32_t root_type_; | 8018 int32_t root_type_; |
8022 unsigned root_length_; | 8019 unsigned root_length_; |
8023 DISALLOW_COPY_AND_ASSIGN(ConsStringIteratorOp); | 8020 DISALLOW_COPY_AND_ASSIGN(ConsStringIteratorOp); |
8024 }; | 8021 }; |
8025 | 8022 |
8026 | 8023 |
8027 // Note: this class is not GC-safe. | 8024 // Note: this class is not GC-safe. |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9089 } else { | 9086 } else { |
9090 value &= ~(1 << bit_position); | 9087 value &= ~(1 << bit_position); |
9091 } | 9088 } |
9092 return value; | 9089 return value; |
9093 } | 9090 } |
9094 }; | 9091 }; |
9095 | 9092 |
9096 } } // namespace v8::internal | 9093 } } // namespace v8::internal |
9097 | 9094 |
9098 #endif // V8_OBJECTS_H_ | 9095 #endif // V8_OBJECTS_H_ |
OLD | NEW |