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

Side by Side Diff: src/objects-inl.h

Issue 140913009: Experimental lexer: fix internalization and allocation of literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: minor fixes 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
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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 : SequentialStringKey<uint8_t>(str, seed) { } 492 : SequentialStringKey<uint8_t>(str, seed) { }
493 493
494 virtual bool IsMatch(Object* string) { 494 virtual bool IsMatch(Object* string) {
495 return String::cast(string)->IsOneByteEqualTo(string_); 495 return String::cast(string)->IsOneByteEqualTo(string_);
496 } 496 }
497 497
498 virtual MaybeObject* AsObject(Heap* heap); 498 virtual MaybeObject* AsObject(Heap* heap);
499 }; 499 };
500 500
501 501
502 class SubStringOneByteStringKey : public HashTableKey { 502 template<class Char>
503 class SubStringKey : public HashTableKey {
503 public: 504 public:
504 explicit SubStringOneByteStringKey(Handle<SeqOneByteString> string, 505 SubStringKey(Handle<String> string, int from, int length)
505 int from,
506 int length)
507 : string_(string), from_(from), length_(length) { } 506 : string_(string), from_(from), length_(length) { }
508 507
509 virtual uint32_t Hash() { 508 virtual uint32_t Hash() {
510 ASSERT(length_ >= 0); 509 ASSERT(length_ >= 0);
511 ASSERT(from_ + length_ <= string_->length()); 510 ASSERT(from_ + length_ <= string_->length());
512 uint8_t* chars = string_->GetChars() + from_; 511 const Char* chars = GetChars() + from_;
513 hash_field_ = StringHasher::HashSequentialString( 512 hash_field_ = StringHasher::HashSequentialString(
514 chars, length_, string_->GetHeap()->HashSeed()); 513 chars, length_, string_->GetHeap()->HashSeed());
515 uint32_t result = hash_field_ >> String::kHashShift; 514 uint32_t result = hash_field_ >> String::kHashShift;
516 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. 515 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed.
517 return result; 516 return result;
518 } 517 }
519 518
520
521 virtual uint32_t HashForObject(Object* other) { 519 virtual uint32_t HashForObject(Object* other) {
522 return String::cast(other)->Hash(); 520 return String::cast(other)->Hash();
523 } 521 }
524 522
525 virtual bool IsMatch(Object* string) { 523 virtual bool IsMatch(Object* string);
526 Vector<const uint8_t> chars(string_->GetChars() + from_, length_);
527 return String::cast(string)->IsOneByteEqualTo(chars);
528 }
529
530 virtual MaybeObject* AsObject(Heap* heap); 524 virtual MaybeObject* AsObject(Heap* heap);
531 525
532 private: 526 private:
533 Handle<SeqOneByteString> string_; 527 const Char* GetChars();
528
529 Handle<String> string_;
534 int from_; 530 int from_;
535 int length_; 531 int length_;
536 uint32_t hash_field_; 532 uint32_t hash_field_;
537 }; 533 };
538 534
539 535
540 class TwoByteStringKey : public SequentialStringKey<uc16> { 536 class TwoByteStringKey : public SequentialStringKey<uc16> {
541 public: 537 public:
542 explicit TwoByteStringKey(Vector<const uc16> str, uint32_t seed) 538 explicit TwoByteStringKey(Vector<const uc16> str, uint32_t seed)
543 : SequentialStringKey<uc16>(str, seed) { } 539 : SequentialStringKey<uc16>(str, seed) { }
(...skipping 6250 matching lines...) Expand 10 before | Expand all | Expand 10 after
6794 #undef READ_UINT32_FIELD 6790 #undef READ_UINT32_FIELD
6795 #undef WRITE_UINT32_FIELD 6791 #undef WRITE_UINT32_FIELD
6796 #undef READ_SHORT_FIELD 6792 #undef READ_SHORT_FIELD
6797 #undef WRITE_SHORT_FIELD 6793 #undef WRITE_SHORT_FIELD
6798 #undef READ_BYTE_FIELD 6794 #undef READ_BYTE_FIELD
6799 #undef WRITE_BYTE_FIELD 6795 #undef WRITE_BYTE_FIELD
6800 6796
6801 } } // namespace v8::internal 6797 } } // namespace v8::internal
6802 6798
6803 #endif // V8_OBJECTS_INL_H_ 6799 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/lexer/experimental-scanner.cc ('K') | « src/objects.cc ('k') | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698