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

Side by Side Diff: src/objects.cc

Issue 484703002: Make internalized string parser in JSON.parse GC-safe (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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/factory.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 13876 matching lines...) Expand 10 before | Expand all | Expand 10 after
13887 return isolate->factory()->NewOneByteInternalizedString(string_, hash_field_); 13887 return isolate->factory()->NewOneByteInternalizedString(string_, hash_field_);
13888 } 13888 }
13889 13889
13890 13890
13891 Handle<Object> TwoByteStringKey::AsHandle(Isolate* isolate) { 13891 Handle<Object> TwoByteStringKey::AsHandle(Isolate* isolate) {
13892 if (hash_field_ == 0) Hash(); 13892 if (hash_field_ == 0) Hash();
13893 return isolate->factory()->NewTwoByteInternalizedString(string_, hash_field_); 13893 return isolate->factory()->NewTwoByteInternalizedString(string_, hash_field_);
13894 } 13894 }
13895 13895
13896 13896
13897 template<> 13897 Handle<Object> SeqOneByteSubStringKey::AsHandle(Isolate* isolate) {
13898 const uint8_t* SubStringKey<uint8_t>::GetChars() { 13898 if (hash_field_ == 0) Hash();
13899 return string_->IsSeqOneByteString() 13899 return isolate->factory()->NewOneByteInternalizedSubString(
13900 ? SeqOneByteString::cast(*string_)->GetChars() 13900 string_, from_, length_, hash_field_);
13901 : ExternalAsciiString::cast(*string_)->GetChars();
13902 } 13901 }
13903 13902
13904 13903
13905 template<> 13904 bool SeqOneByteSubStringKey::IsMatch(Object* string) {
13906 const uint16_t* SubStringKey<uint16_t>::GetChars() { 13905 Vector<const uint8_t> chars(string_->GetChars() + from_, length_);
13907 return string_->IsSeqTwoByteString()
13908 ? SeqTwoByteString::cast(*string_)->GetChars()
13909 : ExternalTwoByteString::cast(*string_)->GetChars();
13910 }
13911
13912
13913 template<>
13914 Handle<Object> SubStringKey<uint8_t>::AsHandle(Isolate* isolate) {
13915 if (hash_field_ == 0) Hash();
13916 Vector<const uint8_t> chars(GetChars() + from_, length_);
13917 return isolate->factory()->NewOneByteInternalizedString(chars, hash_field_);
13918 }
13919
13920
13921 template<>
13922 Handle<Object> SubStringKey<uint16_t>::AsHandle(Isolate* isolate) {
13923 if (hash_field_ == 0) Hash();
13924 Vector<const uint16_t> chars(GetChars() + from_, length_);
13925 return isolate->factory()->NewTwoByteInternalizedString(chars, hash_field_);
13926 }
13927
13928
13929 template<>
13930 bool SubStringKey<uint8_t>::IsMatch(Object* string) {
13931 Vector<const uint8_t> chars(GetChars() + from_, length_);
13932 return String::cast(string)->IsOneByteEqualTo(chars); 13906 return String::cast(string)->IsOneByteEqualTo(chars);
13933 } 13907 }
13934 13908
13935 13909
13936 template<>
13937 bool SubStringKey<uint16_t>::IsMatch(Object* string) {
13938 Vector<const uint16_t> chars(GetChars() + from_, length_);
13939 return String::cast(string)->IsTwoByteEqualTo(chars);
13940 }
13941
13942
13943 template class SubStringKey<uint8_t>;
13944 template class SubStringKey<uint16_t>;
13945
13946
13947 // InternalizedStringKey carries a string/internalized-string object as key. 13910 // InternalizedStringKey carries a string/internalized-string object as key.
13948 class InternalizedStringKey : public HashTableKey { 13911 class InternalizedStringKey : public HashTableKey {
13949 public: 13912 public:
13950 explicit InternalizedStringKey(Handle<String> string) 13913 explicit InternalizedStringKey(Handle<String> string)
13951 : string_(string) { } 13914 : string_(string) { }
13952 13915
13953 virtual bool IsMatch(Object* string) V8_OVERRIDE { 13916 virtual bool IsMatch(Object* string) V8_OVERRIDE {
13954 return String::cast(string)->Equals(*string_); 13917 return String::cast(string)->Equals(*string_);
13955 } 13918 }
13956 13919
(...skipping 2687 matching lines...) Expand 10 before | Expand all | Expand 10 after
16644 #define ERROR_MESSAGES_TEXTS(C, T) T, 16607 #define ERROR_MESSAGES_TEXTS(C, T) T,
16645 static const char* error_messages_[] = { 16608 static const char* error_messages_[] = {
16646 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16609 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16647 }; 16610 };
16648 #undef ERROR_MESSAGES_TEXTS 16611 #undef ERROR_MESSAGES_TEXTS
16649 return error_messages_[reason]; 16612 return error_messages_[reason];
16650 } 16613 }
16651 16614
16652 16615
16653 } } // namespace v8::internal 16616 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698