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.h

Issue 249103002: StringTable::LookupKey() and all callers handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review notes Created 6 years, 8 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/mark-compact.cc ('k') | src/objects.cc » ('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 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 3875 matching lines...) Expand 10 before | Expand all | Expand 10 after
3886 public: 3886 public:
3887 // Returns whether the other object matches this key. 3887 // Returns whether the other object matches this key.
3888 virtual bool IsMatch(Object* other) = 0; 3888 virtual bool IsMatch(Object* other) = 0;
3889 // Returns the hash value for this key. 3889 // Returns the hash value for this key.
3890 virtual uint32_t Hash() = 0; 3890 virtual uint32_t Hash() = 0;
3891 // Returns the hash value for object. 3891 // Returns the hash value for object.
3892 virtual uint32_t HashForObject(Object* key) = 0; 3892 virtual uint32_t HashForObject(Object* key) = 0;
3893 // Returns the key object for storing into the hash table. 3893 // Returns the key object for storing into the hash table.
3894 // If allocations fails a failure object is returned. 3894 // If allocations fails a failure object is returned.
3895 MUST_USE_RESULT virtual MaybeObject* AsObject(Heap* heap) = 0; 3895 MUST_USE_RESULT virtual MaybeObject* AsObject(Heap* heap) = 0;
3896 // TODO(ishell): This should eventually replace AsObject().
3897 inline Handle<Object> AsHandle(Isolate* isolate);
3896 // Required. 3898 // Required.
3897 virtual ~HashTableKey() {} 3899 virtual ~HashTableKey() {}
3898 }; 3900 };
3899 3901
3900 3902
3901 class StringTableShape : public BaseShape<HashTableKey*> { 3903 class StringTableShape : public BaseShape<HashTableKey*> {
3902 public: 3904 public:
3903 static inline bool IsMatch(HashTableKey* key, Object* value) { 3905 static inline bool IsMatch(HashTableKey* key, Object* value) {
3904 return key->IsMatch(value); 3906 return key->IsMatch(value);
3905 } 3907 }
(...skipping 17 matching lines...) Expand all
3923 // StringTable. 3925 // StringTable.
3924 // 3926 //
3925 // No special elements in the prefix and the element size is 1 3927 // No special elements in the prefix and the element size is 1
3926 // because only the string itself (the key) needs to be stored. 3928 // because only the string itself (the key) needs to be stored.
3927 // TODO(ishell): Make StringTable a singleton class and move 3929 // TODO(ishell): Make StringTable a singleton class and move
3928 // Heap::InternalizeStringXX() methods here. 3930 // Heap::InternalizeStringXX() methods here.
3929 class StringTable: public HashTable<StringTable, 3931 class StringTable: public HashTable<StringTable,
3930 StringTableShape, 3932 StringTableShape,
3931 HashTableKey*> { 3933 HashTableKey*> {
3932 public: 3934 public:
3933 // Find string in the string table. If it is not there yet, it is 3935 // Find string in the string table. If it is not there yet, it is
3934 // added. The return value is the string table which might have 3936 // added. The return value is the string found.
3935 // been enlarged. If the return value is not a failure, the string 3937 static Handle<String> LookupString(Isolate* isolate, Handle<String> key);
3936 // pointer *s is set to the string found. 3938 static Handle<String> LookupKey(Isolate* isolate, HashTableKey* key);
3937 MUST_USE_RESULT MaybeObject* LookupString(String* key, Object** s);
3938 MUST_USE_RESULT MaybeObject* LookupKey(HashTableKey* key, Object** s);
3939 3939
3940 // Looks up a string that is equal to the given string and returns 3940 // Looks up a string that is equal to the given string and returns
3941 // true if it is found, assigning the string to the given output 3941 // true if it is found, assigning the string to the given output
3942 // parameter. 3942 // parameter.
3943 bool LookupStringIfExists(String* str, String** result); 3943 bool LookupStringIfExists(String* str, String** result);
3944 bool LookupTwoCharsStringIfExists(uint16_t c1, uint16_t c2, String** result); 3944 bool LookupTwoCharsStringIfExists(uint16_t c1, uint16_t c2, String** result);
3945 3945
3946 // Casting. 3946 // Casting.
3947 static inline StringTable* cast(Object* obj); 3947 static inline StringTable* cast(Object* obj);
3948 3948
(...skipping 5269 matching lines...) Expand 10 before | Expand all | Expand 10 after
9218 9218
9219 // Maximum number of characters to consider when trying to convert a string 9219 // Maximum number of characters to consider when trying to convert a string
9220 // value into an array index. 9220 // value into an array index.
9221 static const int kMaxArrayIndexSize = 10; 9221 static const int kMaxArrayIndexSize = 10;
9222 STATIC_CHECK(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits)); 9222 STATIC_CHECK(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits));
9223 9223
9224 // Max char codes. 9224 // Max char codes.
9225 static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar; 9225 static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar;
9226 static const uint32_t kMaxOneByteCharCodeU = unibrow::Latin1::kMaxChar; 9226 static const uint32_t kMaxOneByteCharCodeU = unibrow::Latin1::kMaxChar;
9227 static const int kMaxUtf16CodeUnit = 0xffff; 9227 static const int kMaxUtf16CodeUnit = 0xffff;
9228 static const uint32_t kMaxUtf16CodeUnitU = kMaxUtf16CodeUnit;
9228 9229
9229 // Value of hash field containing computed hash equal to zero. 9230 // Value of hash field containing computed hash equal to zero.
9230 static const int kEmptyStringHash = kIsNotArrayIndexMask; 9231 static const int kEmptyStringHash = kIsNotArrayIndexMask;
9231 9232
9232 // Maximal string length. 9233 // Maximal string length.
9233 static const int kMaxLength = (1 << 28) - 16; 9234 static const int kMaxLength = (1 << 28) - 16;
9234 9235
9235 // Max length for computing hash. For strings longer than this limit the 9236 // Max length for computing hash. For strings longer than this limit the
9236 // string length is used as the hash value. 9237 // string length is used as the hash value.
9237 static const int kMaxHashCalcLength = 16383; 9238 static const int kMaxHashCalcLength = 16383;
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
11284 } else { 11285 } else {
11285 value &= ~(1 << bit_position); 11286 value &= ~(1 << bit_position);
11286 } 11287 }
11287 return value; 11288 return value;
11288 } 11289 }
11289 }; 11290 };
11290 11291
11291 } } // namespace v8::internal 11292 } } // namespace v8::internal
11292 11293
11293 #endif // V8_OBJECTS_H_ 11294 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698