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

Unified Diff: src/objects-inl.h

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 89ac974e89e27b4c2e4c5a0b34ae5153cc3084f6..e2414d290046927d3d3f4a7e13d3b09e0311d5df 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -533,21 +533,17 @@ class OneByteStringKey : public SequentialStringKey<uint8_t> {
};
-template<class Char>
-class SubStringKey : public HashTableKey {
+class SeqOneByteSubStringKey : public HashTableKey {
public:
- SubStringKey(Handle<String> string, int from, int length)
+ SeqOneByteSubStringKey(Handle<SeqOneByteString> string, int from, int length)
: string_(string), from_(from), length_(length) {
- if (string_->IsSlicedString()) {
- string_ = Handle<String>(Unslice(*string_, &from_));
- }
- DCHECK(string_->IsSeqString() || string->IsExternalString());
+ DCHECK(string_->IsSeqOneByteString());
}
virtual uint32_t Hash() V8_OVERRIDE {
DCHECK(length_ >= 0);
DCHECK(from_ + length_ <= string_->length());
- const Char* chars = GetChars() + from_;
+ const uint8_t* chars = string_->GetChars() + from_;
hash_field_ = StringHasher::HashSequentialString(
chars, length_, string_->GetHeap()->HashSeed());
uint32_t result = hash_field_ >> String::kHashShift;
@@ -563,17 +559,7 @@ class SubStringKey : public HashTableKey {
virtual Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE;
private:
- const Char* GetChars();
- String* Unslice(String* string, int* offset) {
- while (string->IsSlicedString()) {
- SlicedString* sliced = SlicedString::cast(string);
- *offset += sliced->offset();
- string = sliced->parent();
- }
- return string;
- }
-
- Handle<String> string_;
+ Handle<SeqOneByteString> string_;
int from_;
int length_;
uint32_t hash_field_;
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698