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 7308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7319 DECLARE_VERIFIER(Symbol) | 7319 DECLARE_VERIFIER(Symbol) |
7320 | 7320 |
7321 // Layout description. | 7321 // Layout description. |
7322 static const int kSize = Name::kSize; | 7322 static const int kSize = Name::kSize; |
7323 | 7323 |
7324 private: | 7324 private: |
7325 DISALLOW_IMPLICIT_CONSTRUCTORS(Symbol); | 7325 DISALLOW_IMPLICIT_CONSTRUCTORS(Symbol); |
7326 }; | 7326 }; |
7327 | 7327 |
7328 | 7328 |
| 7329 class ConsString; |
| 7330 |
7329 // The String abstract class captures JavaScript string values: | 7331 // The String abstract class captures JavaScript string values: |
7330 // | 7332 // |
7331 // Ecma-262: | 7333 // Ecma-262: |
7332 // 4.3.16 String Value | 7334 // 4.3.16 String Value |
7333 // A string value is a member of the type String and is a finite | 7335 // A string value is a member of the type String and is a finite |
7334 // ordered sequence of zero or more 16-bit unsigned integer values. | 7336 // ordered sequence of zero or more 16-bit unsigned integer values. |
7335 // | 7337 // |
7336 // All string values have a length field. | 7338 // All string values have a length field. |
7337 class String: public Name { | 7339 class String: public Name { |
7338 public: | 7340 public: |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7597 if (*chars > kMaxOneByteCharCodeU) return static_cast<int>(chars - start); | 7599 if (*chars > kMaxOneByteCharCodeU) return static_cast<int>(chars - start); |
7598 ++chars; | 7600 ++chars; |
7599 } | 7601 } |
7600 return static_cast<int>(chars - start); | 7602 return static_cast<int>(chars - start); |
7601 } | 7603 } |
7602 | 7604 |
7603 static inline bool IsOneByte(const uc16* chars, int length) { | 7605 static inline bool IsOneByte(const uc16* chars, int length) { |
7604 return NonOneByteStart(chars, length) >= length; | 7606 return NonOneByteStart(chars, length) >= length; |
7605 } | 7607 } |
7606 | 7608 |
| 7609 // TODO(dcarney): Replace all instances of this with VisitFlat. |
7607 template<class Visitor, class ConsOp> | 7610 template<class Visitor, class ConsOp> |
7608 static inline void Visit(String* string, | 7611 static inline void Visit(String* string, |
7609 unsigned offset, | 7612 unsigned offset, |
7610 Visitor& visitor, | 7613 Visitor& visitor, |
7611 ConsOp& cons_op, | 7614 ConsOp& cons_op, |
7612 int32_t type, | 7615 int32_t type, |
7613 unsigned length); | 7616 unsigned length); |
7614 | 7617 |
| 7618 template<class Visitor> |
| 7619 static inline ConsString* VisitFlat(Visitor* visitor, |
| 7620 String* string, |
| 7621 int offset, |
| 7622 int length, |
| 7623 int32_t type); |
| 7624 |
| 7625 template<class Visitor> |
| 7626 static inline ConsString* VisitFlat(Visitor* visitor, |
| 7627 String* string, |
| 7628 int offset = 0) { |
| 7629 int32_t type = string->map()->instance_type(); |
| 7630 return VisitFlat(visitor, string, offset, string->length(), type); |
| 7631 } |
| 7632 |
7615 private: | 7633 private: |
7616 friend class Name; | 7634 friend class Name; |
7617 | 7635 |
7618 // Try to flatten the top level ConsString that is hiding behind this | 7636 // Try to flatten the top level ConsString that is hiding behind this |
7619 // string. This is a no-op unless the string is a ConsString. Flatten | 7637 // string. This is a no-op unless the string is a ConsString. Flatten |
7620 // mutates the ConsString and might return a failure. | 7638 // mutates the ConsString and might return a failure. |
7621 MUST_USE_RESULT MaybeObject* SlowTryFlatten(PretenureFlag pretenure); | 7639 MUST_USE_RESULT MaybeObject* SlowTryFlatten(PretenureFlag pretenure); |
7622 | 7640 |
7623 // Slow case of String::Equals. This implementation works on any strings | 7641 // Slow case of String::Equals. This implementation works on any strings |
7624 // but it is most efficient on strings that are almost flat. | 7642 // but it is most efficient on strings that are almost flat. |
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9083 } else { | 9101 } else { |
9084 value &= ~(1 << bit_position); | 9102 value &= ~(1 << bit_position); |
9085 } | 9103 } |
9086 return value; | 9104 return value; |
9087 } | 9105 } |
9088 }; | 9106 }; |
9089 | 9107 |
9090 } } // namespace v8::internal | 9108 } } // namespace v8::internal |
9091 | 9109 |
9092 #endif // V8_OBJECTS_H_ | 9110 #endif // V8_OBJECTS_H_ |
OLD | NEW |