Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: src/objects.cc

Issue 140913009: Experimental lexer: fix internalization and allocation of literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Add comments Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/lexer/experimental-scanner.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 13988 matching lines...) Expand 10 before | Expand all | Expand 10 after
13999 Smi* flags_; 13999 Smi* flags_;
14000 }; 14000 };
14001 14001
14002 14002
14003 MaybeObject* OneByteStringKey::AsObject(Heap* heap) { 14003 MaybeObject* OneByteStringKey::AsObject(Heap* heap) {
14004 if (hash_field_ == 0) Hash(); 14004 if (hash_field_ == 0) Hash();
14005 return heap->AllocateOneByteInternalizedString(string_, hash_field_); 14005 return heap->AllocateOneByteInternalizedString(string_, hash_field_);
14006 } 14006 }
14007 14007
14008 14008
14009 MaybeObject* SubStringOneByteStringKey::AsObject(Heap* heap) {
14010 if (hash_field_ == 0) Hash();
14011 Vector<const uint8_t> chars(string_->GetChars() + from_, length_);
14012 return heap->AllocateOneByteInternalizedString(chars, hash_field_);
14013 }
14014
14015
14016 MaybeObject* TwoByteStringKey::AsObject(Heap* heap) { 14009 MaybeObject* TwoByteStringKey::AsObject(Heap* heap) {
14017 if (hash_field_ == 0) Hash(); 14010 if (hash_field_ == 0) Hash();
14018 return heap->AllocateTwoByteInternalizedString(string_, hash_field_); 14011 return heap->AllocateTwoByteInternalizedString(string_, hash_field_);
14019 } 14012 }
14020 14013
14021 14014
14015 template<>
14016 const uint8_t* SubStringKey<uint8_t>::GetChars() {
14017 return string_->IsSeqOneByteString()
14018 ? SeqOneByteString::cast(*string_)->GetChars()
14019 : ExternalAsciiString::cast(*string_)->GetChars();
14020 }
14021
14022
14023 template<>
14024 const uint16_t* SubStringKey<uint16_t>::GetChars() {
14025 return string_->IsSeqTwoByteString()
14026 ? SeqTwoByteString::cast(*string_)->GetChars()
14027 : ExternalTwoByteString::cast(*string_)->GetChars();
14028 }
14029
14030
14031 template<>
14032 MaybeObject* SubStringKey<uint8_t>::AsObject(Heap* heap) {
14033 if (hash_field_ == 0) Hash();
14034 Vector<const uint8_t> chars(GetChars() + from_, length_);
14035 return heap->AllocateOneByteInternalizedString(chars, hash_field_);
14036 }
14037
14038
14039 template<>
14040 MaybeObject* SubStringKey<uint16_t>::AsObject(
14041 Heap* heap) {
14042 if (hash_field_ == 0) Hash();
14043 Vector<const uint16_t> chars(GetChars() + from_, length_);
14044 return heap->AllocateTwoByteInternalizedString(chars, hash_field_);
14045 }
14046
14047
14048 template<>
14049 bool SubStringKey<uint8_t>::IsMatch(Object* string) {
14050 Vector<const uint8_t> chars(GetChars() + from_, length_);
14051 return String::cast(string)->IsOneByteEqualTo(chars);
14052 }
14053
14054
14055 template<>
14056 bool SubStringKey<uint16_t>::IsMatch(Object* string) {
14057 Vector<const uint16_t> chars(GetChars() + from_, length_);
14058 return String::cast(string)->IsTwoByteEqualTo(chars);
14059 }
14060
14061
14062 template class SubStringKey<uint8_t>;
14063 template class SubStringKey<uint16_t>;
14064
14065
14022 // InternalizedStringKey carries a string/internalized-string object as key. 14066 // InternalizedStringKey carries a string/internalized-string object as key.
14023 class InternalizedStringKey : public HashTableKey { 14067 class InternalizedStringKey : public HashTableKey {
14024 public: 14068 public:
14025 explicit InternalizedStringKey(String* string) 14069 explicit InternalizedStringKey(String* string)
14026 : string_(string) { } 14070 : string_(string) { }
14027 14071
14028 bool IsMatch(Object* string) { 14072 bool IsMatch(Object* string) {
14029 return String::cast(string)->Equals(string_); 14073 return String::cast(string)->Equals(string_);
14030 } 14074 }
14031 14075
(...skipping 2578 matching lines...) Expand 10 before | Expand all | Expand 10 after
16610 #define ERROR_MESSAGES_TEXTS(C, T) T, 16654 #define ERROR_MESSAGES_TEXTS(C, T) T,
16611 static const char* error_messages_[] = { 16655 static const char* error_messages_[] = {
16612 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16656 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16613 }; 16657 };
16614 #undef ERROR_MESSAGES_TEXTS 16658 #undef ERROR_MESSAGES_TEXTS
16615 return error_messages_[reason]; 16659 return error_messages_[reason];
16616 } 16660 }
16617 16661
16618 16662
16619 } } // namespace v8::internal 16663 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lexer/experimental-scanner.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698