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 7319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7330 DECLARE_VERIFIER(Symbol) | 7330 DECLARE_VERIFIER(Symbol) |
7331 | 7331 |
7332 // Layout description. | 7332 // Layout description. |
7333 static const int kSize = Name::kSize; | 7333 static const int kSize = Name::kSize; |
7334 | 7334 |
7335 private: | 7335 private: |
7336 DISALLOW_IMPLICIT_CONSTRUCTORS(Symbol); | 7336 DISALLOW_IMPLICIT_CONSTRUCTORS(Symbol); |
7337 }; | 7337 }; |
7338 | 7338 |
7339 | 7339 |
| 7340 class ConsString; |
| 7341 |
7340 // The String abstract class captures JavaScript string values: | 7342 // The String abstract class captures JavaScript string values: |
7341 // | 7343 // |
7342 // Ecma-262: | 7344 // Ecma-262: |
7343 // 4.3.16 String Value | 7345 // 4.3.16 String Value |
7344 // A string value is a member of the type String and is a finite | 7346 // A string value is a member of the type String and is a finite |
7345 // ordered sequence of zero or more 16-bit unsigned integer values. | 7347 // ordered sequence of zero or more 16-bit unsigned integer values. |
7346 // | 7348 // |
7347 // All string values have a length field. | 7349 // All string values have a length field. |
7348 class String: public Name { | 7350 class String: public Name { |
7349 public: | 7351 public: |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7608 if (*chars > kMaxOneByteCharCodeU) return static_cast<int>(chars - start); | 7610 if (*chars > kMaxOneByteCharCodeU) return static_cast<int>(chars - start); |
7609 ++chars; | 7611 ++chars; |
7610 } | 7612 } |
7611 return static_cast<int>(chars - start); | 7613 return static_cast<int>(chars - start); |
7612 } | 7614 } |
7613 | 7615 |
7614 static inline bool IsOneByte(const uc16* chars, int length) { | 7616 static inline bool IsOneByte(const uc16* chars, int length) { |
7615 return NonOneByteStart(chars, length) >= length; | 7617 return NonOneByteStart(chars, length) >= length; |
7616 } | 7618 } |
7617 | 7619 |
| 7620 // TODO(dcarney): Replace all instances of this with VisitFlat. |
7618 template<class Visitor, class ConsOp> | 7621 template<class Visitor, class ConsOp> |
7619 static inline void Visit(String* string, | 7622 static inline void Visit(String* string, |
7620 unsigned offset, | 7623 unsigned offset, |
7621 Visitor& visitor, | 7624 Visitor& visitor, |
7622 ConsOp& cons_op, | 7625 ConsOp& cons_op, |
7623 int32_t type, | 7626 int32_t type, |
7624 unsigned length); | 7627 unsigned length); |
7625 | 7628 |
| 7629 template<class Visitor> |
| 7630 static inline ConsString* VisitFlat(Visitor* visitor, |
| 7631 String* string, |
| 7632 int offset, |
| 7633 int length, |
| 7634 int32_t type); |
| 7635 |
| 7636 template<class Visitor> |
| 7637 static inline ConsString* VisitFlat(Visitor* visitor, |
| 7638 String* string, |
| 7639 int offset = 0) { |
| 7640 int32_t type = string->map()->instance_type(); |
| 7641 return VisitFlat(visitor, string, offset, string->length(), type); |
| 7642 } |
| 7643 |
7626 private: | 7644 private: |
7627 friend class Name; | 7645 friend class Name; |
7628 | 7646 |
7629 // Try to flatten the top level ConsString that is hiding behind this | 7647 // Try to flatten the top level ConsString that is hiding behind this |
7630 // string. This is a no-op unless the string is a ConsString. Flatten | 7648 // string. This is a no-op unless the string is a ConsString. Flatten |
7631 // mutates the ConsString and might return a failure. | 7649 // mutates the ConsString and might return a failure. |
7632 MUST_USE_RESULT MaybeObject* SlowTryFlatten(PretenureFlag pretenure); | 7650 MUST_USE_RESULT MaybeObject* SlowTryFlatten(PretenureFlag pretenure); |
7633 | 7651 |
7634 // Slow case of String::Equals. This implementation works on any strings | 7652 // Slow case of String::Equals. This implementation works on any strings |
7635 // but it is most efficient on strings that are almost flat. | 7653 // but it is most efficient on strings that are almost flat. |
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9094 } else { | 9112 } else { |
9095 value &= ~(1 << bit_position); | 9113 value &= ~(1 << bit_position); |
9096 } | 9114 } |
9097 return value; | 9115 return value; |
9098 } | 9116 } |
9099 }; | 9117 }; |
9100 | 9118 |
9101 } } // namespace v8::internal | 9119 } } // namespace v8::internal |
9102 | 9120 |
9103 #endif // V8_OBJECTS_H_ | 9121 #endif // V8_OBJECTS_H_ |
OLD | NEW |