| OLD | NEW |
| 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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 } | 701 } |
| 702 | 702 |
| 703 | 703 |
| 704 template<class Char> | 704 template<class Char> |
| 705 Handle<String> Lexer<Char>::AllocateInternalizedString( | 705 Handle<String> Lexer<Char>::AllocateInternalizedString( |
| 706 Isolate* isolate) { | 706 Isolate* isolate) { |
| 707 Factory* factory = isolate->factory(); | 707 Factory* factory = isolate->factory(); |
| 708 LiteralDesc* literal = current_literal_; | 708 LiteralDesc* literal = current_literal_; |
| 709 const TokenDesc& token = current_; | 709 const TokenDesc& token = current_; |
| 710 // TODO(dcarney): handle utf8 directly. | 710 // TODO(dcarney): handle utf8 directly. |
| 711 if (source_handle_.is_null() || MustBeInBuffer(token)) { | 711 if (source_handle_.is_null() || MustBeInBufferForAllocation(token)) { |
| 712 EnsureLiteralIsValid(token, literal); | 712 EnsureLiteralIsValid(token, literal); |
| 713 return literal->is_one_byte() ? | 713 return literal->is_one_byte() ? |
| 714 factory->InternalizeOneByteString(literal->one_byte_string()) : | 714 factory->InternalizeOneByteString(literal->one_byte_string()) : |
| 715 factory->InternalizeTwoByteString(literal->two_byte_string()); | 715 factory->InternalizeTwoByteString(literal->two_byte_string()); |
| 716 } | 716 } |
| 717 int offset = 0, length = 0; | 717 int offset = 0, length = 0; |
| 718 LiteralOffsetAndLength<Char>(buffer_, token, &offset, &length); | 718 LiteralOffsetAndLength<Char>(buffer_, token, &offset, &length); |
| 719 if (sizeof(Char) == 1) { | 719 if (sizeof(Char) == 1) { |
| 720 SubStringKey<uint8_t> key(source_handle_, offset, length); | 720 SubStringKey<uint8_t> key(source_handle_, offset, length); |
| 721 return factory->InternalizeStringWithKey(&key); | 721 return factory->InternalizeStringWithKey(&key); |
| 722 } else { | 722 } else { |
| 723 SubStringKey<uint16_t> key(source_handle_, offset, length); | 723 SubStringKey<uint16_t> key(source_handle_, offset, length); |
| 724 return factory->InternalizeStringWithKey(&key); | 724 return factory->InternalizeStringWithKey(&key); |
| 725 } | 725 } |
| 726 } | 726 } |
| 727 | 727 |
| 728 | 728 |
| 729 template<class Char> | 729 template<class Char> |
| 730 Handle<String> Lexer<Char>::AllocateNextLiteralString(Isolate* isolate, | 730 Handle<String> Lexer<Char>::AllocateNextLiteralString(Isolate* isolate, |
| 731 PretenureFlag tenured) { | 731 PretenureFlag tenured) { |
| 732 Factory* factory = isolate->factory(); | 732 Factory* factory = isolate->factory(); |
| 733 LiteralDesc* literal = next_literal_; | 733 LiteralDesc* literal = next_literal_; |
| 734 const TokenDesc& token = next_; | 734 const TokenDesc& token = next_; |
| 735 // TODO(dcarney): handle utf8 directly. | 735 // TODO(dcarney): handle utf8 directly. |
| 736 if (source_handle_.is_null() || MustBeInBuffer(token)) { | 736 if (source_handle_.is_null() || MustBeInBufferForAllocation(token)) { |
| 737 EnsureLiteralIsValid(token, literal); | 737 EnsureLiteralIsValid(token, literal); |
| 738 return literal->is_one_byte() ? | 738 return literal->is_one_byte() ? |
| 739 factory->NewStringFromOneByte(literal->one_byte_string(), tenured) : | 739 factory->NewStringFromOneByte(literal->one_byte_string(), tenured) : |
| 740 factory->NewStringFromTwoByte( | 740 factory->NewStringFromTwoByte( |
| 741 literal->two_byte_string(), false, tenured); | 741 literal->two_byte_string(), false, tenured); |
| 742 } | 742 } |
| 743 int offset = 0, length = 0; | 743 int offset = 0, length = 0; |
| 744 LiteralOffsetAndLength<Char>(buffer_, token, &offset, &length); | 744 LiteralOffsetAndLength<Char>(buffer_, token, &offset, &length); |
| 745 return factory->NewSubString(source_handle_, offset, offset + length); | 745 return factory->NewSubString(source_handle_, offset, offset + length); |
| 746 } | 746 } |
| 747 | 747 |
| 748 | 748 |
| 749 template class Lexer<uint8_t>; | 749 template class Lexer<uint8_t>; |
| 750 template class Lexer<uint16_t>; | 750 template class Lexer<uint16_t>; |
| 751 template class Lexer<int8_t>; | 751 template class Lexer<int8_t>; |
| 752 | 752 |
| 753 } } // v8::internal | 753 } } // v8::internal |
| OLD | NEW |