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

Side by Side Diff: test/cctest/test-strings.cc

Issue 11593007: Replace the use CharacterStreams in Heap::AllocateSymbolInternal and String::ComputeHash (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: issues addressed Created 8 years 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
« no previous file with comments | « src/unicode.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 2
3 // Check that we can traverse very deep stacks of ConsStrings using 3 // Check that we can traverse very deep stacks of ConsStrings using
4 // StringInputBuffer. Check that Get(int) works on very deep stacks 4 // StringInputBuffer. Check that Get(int) works on very deep stacks
5 // of ConsStrings. These operations may not be very fast, but they 5 // of ConsStrings. These operations may not be very fast, but they
6 // should be possible without getting errors due to too deep recursion. 6 // should be possible without getting errors due to too deep recursion.
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "v8.h" 10 #include "v8.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 if (cons_string->IsConsString()) { 338 if (cons_string->IsConsString()) {
339 return AccumulateStats(ConsString::cast(*cons_string), stats); 339 return AccumulateStats(ConsString::cast(*cons_string), stats);
340 } 340 }
341 // This string got flattened by gc. 341 // This string got flattened by gc.
342 stats->chars_ += cons_string->length(); 342 stats->chars_ += cons_string->length();
343 } 343 }
344 344
345 345
346 void AccumulateStatsWithOperator( 346 void AccumulateStatsWithOperator(
347 ConsString* cons_string, ConsStringStats* stats) { 347 ConsString* cons_string, ConsStringStats* stats) {
348 // Init op. 348 unsigned offset = 0;
349 int32_t type = cons_string->map()->instance_type();
350 unsigned length = static_cast<unsigned>(cons_string->length());
349 ConsStringIteratorOp op; 351 ConsStringIteratorOp op;
350 op.Reset(); 352 String* string = op.Operate(cons_string, &offset, &type, &length);
351 // Use response for initial search and on blown stack. 353 CHECK(string != NULL);
352 ConsStringIteratorOp::ContinueResponse response;
353 response.string_ = cons_string;
354 response.offset_ = 0;
355 response.type_ = cons_string->map()->instance_type();
356 response.length_ = (uint32_t) cons_string->length();
357 while (true) { 354 while (true) {
358 String* string = op.Operate(ConsString::cast(response.string_), 355 ASSERT(!string->IsConsString());
359 &response.offset_, 356 // Accumulate stats.
360 &response.type_, 357 stats->leaves_++;
361 &response.length_); 358 stats->chars_ += string->length();
362 CHECK(string != NULL); 359 // Check for completion.
363 while (true) { 360 bool keep_going_fast_check = op.HasMore();
364 // Accumulate stats. 361 string = op.ContinueOperation(&type, &length);
365 stats->leaves_++; 362 if (string == NULL) return;
366 stats->chars_ += string->length(); 363 // Verify no false positives for fast check.
367 // Check for completion. 364 CHECK(keep_going_fast_check);
368 bool keep_going_fast_check = op.HasMore(); 365 }
369 bool keep_going = op.ContinueOperation(&response);
370 if (!keep_going) return;
371 // Verify no false positives for fast check.
372 CHECK(keep_going_fast_check);
373 CHECK(response.string_ != NULL);
374 // Blew stack. Restart outer loop.
375 if (response.string_->IsConsString()) break;
376 string = response.string_;
377 }
378 };
379 } 366 }
380 367
381 368
382 void VerifyConsString(Handle<String> root, ConsStringGenerationData* data) { 369 void VerifyConsString(Handle<String> root, ConsStringGenerationData* data) {
383 // Verify basic data. 370 // Verify basic data.
384 CHECK(root->IsConsString()); 371 CHECK(root->IsConsString());
385 CHECK((unsigned)root->length() == data->stats_.chars_); 372 CHECK((unsigned)root->length() == data->stats_.chars_);
386 // Recursive verify. 373 // Recursive verify.
387 ConsStringStats stats; 374 ConsStringStats stats;
388 AccumulateStats(ConsString::cast(*root), &stats); 375 AccumulateStats(ConsString::cast(*root), &stats);
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 1281
1295 v8::Local<v8::String> expected = v8_str("ascii\x80only\x80string\x80"); 1282 v8::Local<v8::String> expected = v8_str("ascii\x80only\x80string\x80");
1296 CHECK(expected->Equals(result)); 1283 CHECK(expected->Equals(result));
1297 } 1284 }
1298 1285
1299 1286
1300 TEST(IsAscii) { 1287 TEST(IsAscii) {
1301 CHECK(String::IsAscii(static_cast<char*>(NULL), 0)); 1288 CHECK(String::IsAscii(static_cast<char*>(NULL), 0));
1302 CHECK(String::IsAscii(static_cast<uc16*>(NULL), 0)); 1289 CHECK(String::IsAscii(static_cast<uc16*>(NULL), 0));
1303 } 1290 }
OLDNEW
« no previous file with comments | « src/unicode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698