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

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

Issue 2493002: - Remove [static] from methods in Zone and associated helpers. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 10 years, 6 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
« src/zone-inl.h ('K') | « test/cctest/test-regexp.cc ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 buf[j] = gen() % 128; 106 buf[j] = gen() % 128;
107 } 107 }
108 building_blocks[i] = 108 building_blocks[i] =
109 Factory::NewStringFromAscii(Vector<const char>(buf, len)); 109 Factory::NewStringFromAscii(Vector<const char>(buf, len));
110 for (int j = 0; j < len; j++) { 110 for (int j = 0; j < len; j++) {
111 CHECK_EQ(buf[j], building_blocks[i]->Get(j)); 111 CHECK_EQ(buf[j], building_blocks[i]->Get(j));
112 } 112 }
113 break; 113 break;
114 } 114 }
115 case 2: { 115 case 2: {
116 uc16* buf = Zone::NewArray<uc16>(len); 116 uc16* buf = ZONE->NewArray<uc16>(len);
117 for (int j = 0; j < len; j++) { 117 for (int j = 0; j < len; j++) {
118 buf[j] = gen() % 65536; 118 buf[j] = gen() % 65536;
119 } 119 }
120 Resource* resource = new Resource(Vector<const uc16>(buf, len)); 120 Resource* resource = new Resource(Vector<const uc16>(buf, len));
121 building_blocks[i] = Factory::NewExternalStringFromTwoByte(resource); 121 building_blocks[i] = Factory::NewExternalStringFromTwoByte(resource);
122 for (int j = 0; j < len; j++) { 122 for (int j = 0; j < len; j++) {
123 CHECK_EQ(buf[j], building_blocks[i]->Get(j)); 123 CHECK_EQ(buf[j], building_blocks[i]->Get(j));
124 } 124 }
125 break; 125 break;
126 } 126 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 CHECK_GT(kMaxLength, i::String::kMinNonFlatLength); 358 CHECK_GT(kMaxLength, i::String::kMinNonFlatLength);
359 359
360 // Allocate two JavaScript arrays for holding short strings. 360 // Allocate two JavaScript arrays for holding short strings.
361 v8::Handle<v8::Array> ascii_external_strings = 361 v8::Handle<v8::Array> ascii_external_strings =
362 v8::Array::New(kMaxLength + 1); 362 v8::Array::New(kMaxLength + 1);
363 v8::Handle<v8::Array> non_ascii_external_strings = 363 v8::Handle<v8::Array> non_ascii_external_strings =
364 v8::Array::New(kMaxLength + 1); 364 v8::Array::New(kMaxLength + 1);
365 365
366 // Generate short ascii and non-ascii external strings. 366 // Generate short ascii and non-ascii external strings.
367 for (int i = 0; i <= kMaxLength; i++) { 367 for (int i = 0; i <= kMaxLength; i++) {
368 char* ascii = Zone::NewArray<char>(i + 1); 368 char* ascii = ZONE->NewArray<char>(i + 1);
369 for (int j = 0; j < i; j++) { 369 for (int j = 0; j < i; j++) {
370 ascii[j] = 'a'; 370 ascii[j] = 'a';
371 } 371 }
372 // Terminating '\0' is left out on purpose. It is not required for external 372 // Terminating '\0' is left out on purpose. It is not required for external
373 // string data. 373 // string data.
374 AsciiResource* ascii_resource = 374 AsciiResource* ascii_resource =
375 new AsciiResource(Vector<const char>(ascii, i)); 375 new AsciiResource(Vector<const char>(ascii, i));
376 v8::Local<v8::String> ascii_external_string = 376 v8::Local<v8::String> ascii_external_string =
377 v8::String::NewExternal(ascii_resource); 377 v8::String::NewExternal(ascii_resource);
378 378
379 ascii_external_strings->Set(v8::Integer::New(i), ascii_external_string); 379 ascii_external_strings->Set(v8::Integer::New(i), ascii_external_string);
380 uc16* non_ascii = Zone::NewArray<uc16>(i + 1); 380 uc16* non_ascii = ZONE->NewArray<uc16>(i + 1);
381 for (int j = 0; j < i; j++) { 381 for (int j = 0; j < i; j++) {
382 non_ascii[j] = 0x1234; 382 non_ascii[j] = 0x1234;
383 } 383 }
384 // Terminating '\0' is left out on purpose. It is not required for external 384 // Terminating '\0' is left out on purpose. It is not required for external
385 // string data. 385 // string data.
386 Resource* resource = new Resource(Vector<const uc16>(non_ascii, i)); 386 Resource* resource = new Resource(Vector<const uc16>(non_ascii, i));
387 v8::Local<v8::String> non_ascii_external_string = 387 v8::Local<v8::String> non_ascii_external_string =
388 v8::String::NewExternal(resource); 388 v8::String::NewExternal(resource);
389 non_ascii_external_strings->Set(v8::Integer::New(i), 389 non_ascii_external_strings->Set(v8::Integer::New(i),
390 non_ascii_external_string); 390 non_ascii_external_string);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 " if (non_ascii[i] !=" 426 " if (non_ascii[i] !="
427 " (non_ascii[j] + external_non_ascii[i - j])) return 12;" 427 " (non_ascii[j] + external_non_ascii[i - j])) return 12;"
428 " }" 428 " }"
429 " }" 429 " }"
430 " return 0;" 430 " return 0;"
431 "};" 431 "};"
432 "test()"; 432 "test()";
433 CHECK_EQ(0, 433 CHECK_EQ(0,
434 v8::Script::Compile(v8::String::New(source))->Run()->Int32Value()); 434 v8::Script::Compile(v8::String::New(source))->Run()->Int32Value());
435 } 435 }
OLDNEW
« src/zone-inl.h ('K') | « test/cctest/test-regexp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698