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

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

Issue 1102523003: Implement a 'trial parse' step, that will abort pre-parsing excessively (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use a seperate 'hint' bit for "to be executed once" code aging. Created 5 years, 7 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
« no previous file with comments | « src/scanner-character-streams.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/scanner-character-streams.h" 7 #include "src/scanner-character-streams.h"
8 8
9 #include "include/v8.h" 9 #include "include/v8.h"
10 #include "src/handles.h" 10 #include "src/handles.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 return BufferSeekForward(delta); 123 return BufferSeekForward(delta);
124 } 124 }
125 125
126 126
127 // ---------------------------------------------------------------------------- 127 // ----------------------------------------------------------------------------
128 // GenericStringUtf16CharacterStream 128 // GenericStringUtf16CharacterStream
129 129
130 130
131 GenericStringUtf16CharacterStream::GenericStringUtf16CharacterStream( 131 GenericStringUtf16CharacterStream::GenericStringUtf16CharacterStream(
132 Handle<String> data, size_t start_position, size_t end_position) 132 Handle<String> data, size_t start_position, size_t end_position)
133 : string_(data), length_(end_position) { 133 : string_(data), length_(end_position), bookmark_(kNoBookmark) {
134 DCHECK(end_position >= start_position); 134 DCHECK(end_position >= start_position);
135 pos_ = start_position; 135 pos_ = start_position;
136 } 136 }
137 137
138 138
139 GenericStringUtf16CharacterStream::~GenericStringUtf16CharacterStream() { } 139 GenericStringUtf16CharacterStream::~GenericStringUtf16CharacterStream() { }
140 140
141 141
142 bool GenericStringUtf16CharacterStream::SetBookmark() {
143 bookmark_ = pos_;
144 return true;
145 }
146
147
148 void GenericStringUtf16CharacterStream::ResetToBookmark() {
149 DCHECK(bookmark_ != kNoBookmark);
150 pos_ = bookmark_;
151 buffer_cursor_ = buffer_;
152 buffer_end_ = buffer_ + FillBuffer(pos_);
153 }
154
155
142 size_t GenericStringUtf16CharacterStream::BufferSeekForward(size_t delta) { 156 size_t GenericStringUtf16CharacterStream::BufferSeekForward(size_t delta) {
143 size_t old_pos = pos_; 157 size_t old_pos = pos_;
144 pos_ = Min(pos_ + delta, length_); 158 pos_ = Min(pos_ + delta, length_);
145 ReadBlock(); 159 ReadBlock();
146 return pos_ - old_pos; 160 return pos_ - old_pos;
147 } 161 }
148 162
149 163
150 size_t GenericStringUtf16CharacterStream::FillBuffer(size_t from_pos) { 164 size_t GenericStringUtf16CharacterStream::FillBuffer(size_t from_pos) {
151 if (from_pos >= length_) return 0; 165 if (from_pos >= length_) return 0;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 454 }
441 455
442 456
443 // ---------------------------------------------------------------------------- 457 // ----------------------------------------------------------------------------
444 // ExternalTwoByteStringUtf16CharacterStream 458 // ExternalTwoByteStringUtf16CharacterStream
445 459
446 ExternalTwoByteStringUtf16CharacterStream:: 460 ExternalTwoByteStringUtf16CharacterStream::
447 ~ExternalTwoByteStringUtf16CharacterStream() { } 461 ~ExternalTwoByteStringUtf16CharacterStream() { }
448 462
449 463
450 ExternalTwoByteStringUtf16CharacterStream 464 ExternalTwoByteStringUtf16CharacterStream::
451 ::ExternalTwoByteStringUtf16CharacterStream( 465 ExternalTwoByteStringUtf16CharacterStream(
452 Handle<ExternalTwoByteString> data, 466 Handle<ExternalTwoByteString> data, int start_position,
453 int start_position,
454 int end_position) 467 int end_position)
455 : Utf16CharacterStream(), 468 : Utf16CharacterStream(),
456 source_(data), 469 source_(data),
457 raw_data_(data->GetTwoByteData(start_position)) { 470 raw_data_(data->GetTwoByteData(start_position)),
471 bookmark_(kNoBookmark) {
458 buffer_cursor_ = raw_data_, 472 buffer_cursor_ = raw_data_,
459 buffer_end_ = raw_data_ + (end_position - start_position); 473 buffer_end_ = raw_data_ + (end_position - start_position);
460 pos_ = start_position; 474 pos_ = start_position;
461 } 475 }
462 476
477
478 bool ExternalTwoByteStringUtf16CharacterStream::SetBookmark() {
479 bookmark_ = pos_;
480 return true;
481 }
482
483
484 void ExternalTwoByteStringUtf16CharacterStream::ResetToBookmark() {
485 DCHECK(bookmark_ != kNoBookmark);
486 pos_ = bookmark_;
487 buffer_cursor_ = raw_data_ + bookmark_;
488 }
463 } } // namespace v8::internal 489 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scanner-character-streams.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698