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

Side by Side Diff: src/scanner-character-streams.h

Issue 214883002: Two-threaded parser (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: code review (svenpanne) 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 const byte* raw_data_; 90 const byte* raw_data_;
91 unsigned raw_data_length_; // Measured in bytes, not characters. 91 unsigned raw_data_length_; // Measured in bytes, not characters.
92 unsigned raw_data_pos_; 92 unsigned raw_data_pos_;
93 // The character position of the character at raw_data[raw_data_pos_]. 93 // The character position of the character at raw_data[raw_data_pos_].
94 // Not necessarily the same as pos_. 94 // Not necessarily the same as pos_.
95 unsigned raw_character_position_; 95 unsigned raw_character_position_;
96 }; 96 };
97 97
98 98
99 // UTF16 buffer to read characters from an external string. 99 // UTF16 buffer to read characters from an external two byte (UTF-16)
100 // string. The caller is responsible for keeping the memory alive.
100 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream { 101 class ExternalTwoByteStringUtf16CharacterStream: public Utf16CharacterStream {
101 public: 102 public:
102 ExternalTwoByteStringUtf16CharacterStream(Handle<ExternalTwoByteString> data, 103 ExternalTwoByteStringUtf16CharacterStream(const uint16_t* raw_data,
103 int start_position, 104 int start_position,
104 int end_position); 105 int end_position);
105 virtual ~ExternalTwoByteStringUtf16CharacterStream(); 106 virtual ~ExternalTwoByteStringUtf16CharacterStream();
106 107
107 virtual void PushBack(uc32 character) { 108 virtual void PushBack(uc32 character) {
108 ASSERT(buffer_cursor_ > raw_data_); 109 ASSERT(buffer_cursor_ > raw_data_);
109 buffer_cursor_--; 110 buffer_cursor_--;
110 pos_--; 111 pos_--;
111 } 112 }
112 113
113 protected: 114 protected:
114 virtual unsigned SlowSeekForward(unsigned delta) { 115 virtual unsigned SlowSeekForward(unsigned delta) {
115 // Fast case always handles seeking. 116 // Fast case always handles seeking.
116 return 0; 117 return 0;
117 } 118 }
118 virtual bool ReadBlock() { 119 virtual bool ReadBlock() {
119 // Entire string is read at start. 120 // Entire string is read at start.
120 return false; 121 return false;
121 } 122 }
122 Handle<ExternalTwoByteString> source_;
123 const uc16* raw_data_; // Pointer to the actual array of characters. 123 const uc16* raw_data_; // Pointer to the actual array of characters.
124 }; 124 };
125 125
126
127 // UTF16 buffer to read characters from an external one byte (latin1)
128 // string. Note that "ascii" in ExternalAsciiString is actually latin1. The
129 // caller is responsible for keeping the memory alive.
130 class ExternalOneByteStringUtf16CharacterStream
131 : public BufferedUtf16CharacterStream {
132 public:
133 ExternalOneByteStringUtf16CharacterStream(const uint8_t* raw_data,
134 int start_position,
135 int end_position);
136 virtual ~ExternalOneByteStringUtf16CharacterStream();
137
138 protected:
139 virtual unsigned BufferSeekForward(unsigned delta);
140 virtual unsigned FillBuffer(unsigned position, unsigned length);
141
142 const uint8_t* raw_data_; // Pointer to the actual array of characters.
143 unsigned length_;
144 };
145
126 } } // namespace v8::internal 146 } } // namespace v8::internal
127 147
128 #endif // V8_SCANNER_CHARACTER_STREAMS_H_ 148 #endif // V8_SCANNER_CHARACTER_STREAMS_H_
OLDNEW
« src/parser-thread.cc ('K') | « src/preparser.cc ('k') | src/scanner-character-streams.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698