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

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

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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 300 }
301 301
302 302
303 // ---------------------------------------------------------------------------- 303 // ----------------------------------------------------------------------------
304 // ExternalTwoByteStringUtf16CharacterStream 304 // ExternalTwoByteStringUtf16CharacterStream
305 305
306 ExternalTwoByteStringUtf16CharacterStream:: 306 ExternalTwoByteStringUtf16CharacterStream::
307 ~ExternalTwoByteStringUtf16CharacterStream() { } 307 ~ExternalTwoByteStringUtf16CharacterStream() { }
308 308
309 309
310 ExternalTwoByteStringUtf16CharacterStream 310 ExternalTwoByteStringUtf16CharacterStream::
311 ::ExternalTwoByteStringUtf16CharacterStream( 311 ExternalTwoByteStringUtf16CharacterStream(const uint16_t* raw_data,
312 Handle<ExternalTwoByteString> data, 312 int start_position,
313 int start_position, 313 int end_position)
314 int end_position) 314 : Utf16CharacterStream(), raw_data_(raw_data + start_position) {
315 : Utf16CharacterStream(), 315 buffer_cursor_ = raw_data_;
316 source_(data),
317 raw_data_(data->GetTwoByteData(start_position)) {
318 buffer_cursor_ = raw_data_,
319 buffer_end_ = raw_data_ + (end_position - start_position); 316 buffer_end_ = raw_data_ + (end_position - start_position);
320 pos_ = start_position; 317 pos_ = start_position;
321 } 318 }
322 319
320
321 // ----------------------------------------------------------------------------
322 // ExternalOneByteStringUtf16CharacterStream
323
324 ExternalOneByteStringUtf16CharacterStream::
325 ExternalOneByteStringUtf16CharacterStream(const uint8_t* raw_data,
326 int start_position,
327 int end_position)
328 : raw_data_(raw_data + start_position),
329 length_(end_position) {
330 pos_ = start_position;
331 }
332
333
334 ExternalOneByteStringUtf16CharacterStream::
335 ~ExternalOneByteStringUtf16CharacterStream() {}
336
337
338 unsigned ExternalOneByteStringUtf16CharacterStream::BufferSeekForward(
339 unsigned delta) {
340 unsigned old_pos = pos_;
341 pos_ = Min(pos_ + delta, length_);
342 ReadBlock();
343 return pos_ - old_pos;
344 }
345
346
347 unsigned ExternalOneByteStringUtf16CharacterStream::FillBuffer(
348 unsigned from_pos, unsigned length) {
349 if (from_pos >= length_) return 0;
350 if (from_pos + length > length_) {
351 length = length_ - from_pos;
352 }
353 CopyChars(buffer_, raw_data_ + from_pos, length);
354 return length;
355 }
356
357
323 } } // namespace v8::internal 358 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698