| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 3483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3494 } | 3494 } |
| 3495 default: | 3495 default: |
| 3496 break; | 3496 break; |
| 3497 } | 3497 } |
| 3498 | 3498 |
| 3499 UNREACHABLE(); | 3499 UNREACHABLE(); |
| 3500 return 0; | 3500 return 0; |
| 3501 } | 3501 } |
| 3502 | 3502 |
| 3503 | 3503 |
| 3504 FlatStringReader* FlatStringReader::top_ = NULL; |
| 3505 |
| 3506 |
| 3507 FlatStringReader::FlatStringReader(Handle<String> str) |
| 3508 : str_(str.location()), |
| 3509 length_(str->length()), |
| 3510 prev_(top_) { |
| 3511 top_ = this; |
| 3512 RefreshState(); |
| 3513 } |
| 3514 |
| 3515 |
| 3516 FlatStringReader::FlatStringReader(Vector<const char> input) |
| 3517 : str_(NULL), |
| 3518 is_ascii_(true), |
| 3519 length_(input.length()), |
| 3520 start_(input.start()), |
| 3521 prev_(top_) { |
| 3522 top_ = this; |
| 3523 } |
| 3524 |
| 3525 |
| 3526 FlatStringReader::~FlatStringReader() { |
| 3527 ASSERT_EQ(top_, this); |
| 3528 top_ = prev_; |
| 3529 } |
| 3530 |
| 3531 |
| 3532 void FlatStringReader::RefreshState() { |
| 3533 if (str_ == NULL) return; |
| 3534 Handle<String> str(str_); |
| 3535 StringShape shape(*str); |
| 3536 ASSERT(str->IsFlat(shape)); |
| 3537 is_ascii_ = shape.IsAsciiRepresentation(); |
| 3538 if (is_ascii_) { |
| 3539 start_ = str->ToAsciiVector().start(); |
| 3540 } else { |
| 3541 start_ = str->ToUC16Vector().start(); |
| 3542 } |
| 3543 } |
| 3544 |
| 3545 |
| 3546 void FlatStringReader::PostGarbageCollectionProcessing() { |
| 3547 FlatStringReader* current = top_; |
| 3548 while (current != NULL) { |
| 3549 current->RefreshState(); |
| 3550 current = current->prev_; |
| 3551 } |
| 3552 } |
| 3553 |
| 3554 |
| 3504 void StringInputBuffer::Seek(unsigned pos) { | 3555 void StringInputBuffer::Seek(unsigned pos) { |
| 3505 Reset(pos, input_); | 3556 Reset(pos, input_); |
| 3506 } | 3557 } |
| 3507 | 3558 |
| 3508 | 3559 |
| 3509 void SafeStringInputBuffer::Seek(unsigned pos) { | 3560 void SafeStringInputBuffer::Seek(unsigned pos) { |
| 3510 Reset(pos, input_); | 3561 Reset(pos, input_); |
| 3511 } | 3562 } |
| 3512 | 3563 |
| 3513 | 3564 |
| (...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5738 | 5789 |
| 5739 bool IsStringKey() { return true; } | 5790 bool IsStringKey() { return true; } |
| 5740 | 5791 |
| 5741 String* string_; | 5792 String* string_; |
| 5742 }; | 5793 }; |
| 5743 | 5794 |
| 5744 // RegExpKey carries the source and flags of a regular expression as key. | 5795 // RegExpKey carries the source and flags of a regular expression as key. |
| 5745 class RegExpKey : public HashTableKey { | 5796 class RegExpKey : public HashTableKey { |
| 5746 public: | 5797 public: |
| 5747 RegExpKey(String* string, JSRegExp::Flags flags) | 5798 RegExpKey(String* string, JSRegExp::Flags flags) |
| 5748 : string_(string), | 5799 : string_(string), |
| 5749 flags_(Smi::FromInt(flags.value())) { } | 5800 flags_(Smi::FromInt(flags.value())) { } |
| 5750 | 5801 |
| 5751 bool IsMatch(Object* obj) { | 5802 bool IsMatch(Object* obj) { |
| 5752 FixedArray* val = FixedArray::cast(obj); | 5803 FixedArray* val = FixedArray::cast(obj); |
| 5753 return string_->Equals(String::cast(val->get(JSRegExp::kSourceIndex))) | 5804 return string_->Equals(String::cast(val->get(JSRegExp::kSourceIndex))) |
| 5754 && (flags_ == val->get(JSRegExp::kFlagsIndex)); | 5805 && (flags_ == val->get(JSRegExp::kFlagsIndex)); |
| 5755 } | 5806 } |
| 5756 | 5807 |
| 5757 uint32_t Hash() { return RegExpHash(string_, flags_); } | 5808 uint32_t Hash() { return RegExpHash(string_, flags_); } |
| 5758 | 5809 |
| 5759 HashFunction GetHashFunction() { return RegExpObjectHash; } | 5810 HashFunction GetHashFunction() { return RegExpObjectHash; } |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6130 | 6181 |
| 6131 private: | 6182 private: |
| 6132 FixedArray* symbols_; | 6183 FixedArray* symbols_; |
| 6133 }; | 6184 }; |
| 6134 | 6185 |
| 6135 | 6186 |
| 6136 // MapNameKeys are used as keys in lookup caches. | 6187 // MapNameKeys are used as keys in lookup caches. |
| 6137 class MapNameKey : public HashTableKey { | 6188 class MapNameKey : public HashTableKey { |
| 6138 public: | 6189 public: |
| 6139 MapNameKey(Map* map, String* name) | 6190 MapNameKey(Map* map, String* name) |
| 6140 : map_(map), name_(name) { } | 6191 : map_(map), name_(name) { } |
| 6141 | 6192 |
| 6142 bool IsMatch(Object* other) { | 6193 bool IsMatch(Object* other) { |
| 6143 if (!other->IsFixedArray()) return false; | 6194 if (!other->IsFixedArray()) return false; |
| 6144 FixedArray* pair = FixedArray::cast(other); | 6195 FixedArray* pair = FixedArray::cast(other); |
| 6145 Map* map = Map::cast(pair->get(0)); | 6196 Map* map = Map::cast(pair->get(0)); |
| 6146 if (map != map_) return false; | 6197 if (map != map_) return false; |
| 6147 String* name = String::cast(pair->get(1)); | 6198 String* name = String::cast(pair->get(1)); |
| 6148 return name->Equals(name_); | 6199 return name->Equals(name_); |
| 6149 } | 6200 } |
| 6150 | 6201 |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6903 // No break point. | 6954 // No break point. |
| 6904 if (break_point_objects()->IsUndefined()) return 0; | 6955 if (break_point_objects()->IsUndefined()) return 0; |
| 6905 // Single beak point. | 6956 // Single beak point. |
| 6906 if (!break_point_objects()->IsFixedArray()) return 1; | 6957 if (!break_point_objects()->IsFixedArray()) return 1; |
| 6907 // Multiple break points. | 6958 // Multiple break points. |
| 6908 return FixedArray::cast(break_point_objects())->length(); | 6959 return FixedArray::cast(break_point_objects())->length(); |
| 6909 } | 6960 } |
| 6910 | 6961 |
| 6911 | 6962 |
| 6912 } } // namespace v8::internal | 6963 } } // namespace v8::internal |
| OLD | NEW |