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

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

Issue 804993002: Internalize strings being stored into uninitialized property cells (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comment Created 6 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
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/regress/regress-1757.js » ('j') | 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 // 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 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 TEST(JSONStringifySliceMadeExternal) { 1017 TEST(JSONStringifySliceMadeExternal) {
1018 CcTest::InitializeVM(); 1018 CcTest::InitializeVM();
1019 // Create a sliced string from a one-byte string. The latter is turned 1019 // Create a sliced string from a one-byte string. The latter is turned
1020 // into a two-byte external string. Check that JSON.stringify works. 1020 // into a two-byte external string. Check that JSON.stringify works.
1021 v8::HandleScope handle_scope(CcTest::isolate()); 1021 v8::HandleScope handle_scope(CcTest::isolate());
1022 v8::Handle<v8::String> underlying = 1022 v8::Handle<v8::String> underlying =
1023 CompileRun( 1023 CompileRun(
1024 "var underlying = 'abcdefghijklmnopqrstuvwxyz';" 1024 "var underlying = 'abcdefghijklmnopqrstuvwxyz';"
1025 "underlying")->ToString(CcTest::isolate()); 1025 "underlying")->ToString(CcTest::isolate());
1026 v8::Handle<v8::String> slice = CompileRun( 1026 v8::Handle<v8::String> slice = CompileRun(
1027 "var slice = underlying.slice(1);" 1027 "var slice = '';"
1028 "slice = underlying.slice(1);"
1028 "slice")->ToString(CcTest::isolate()); 1029 "slice")->ToString(CcTest::isolate());
1029 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); 1030 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString());
1030 CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString()); 1031 CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString());
1031 1032
1032 int length = underlying->Length(); 1033 int length = underlying->Length();
1033 uc16* two_byte = NewArray<uc16>(length + 1); 1034 uc16* two_byte = NewArray<uc16>(length + 1);
1034 underlying->Write(two_byte); 1035 underlying->Write(two_byte);
1035 Resource* resource = new Resource(two_byte, length); 1036 Resource* resource = new Resource(two_byte, length);
1036 CHECK(underlying->MakeExternal(resource)); 1037 CHECK(underlying->MakeExternal(resource));
1037 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); 1038 CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString());
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1177
1177 TEST(SliceFromSlice) { 1178 TEST(SliceFromSlice) {
1178 // This tests whether a slice that contains the entire parent string 1179 // This tests whether a slice that contains the entire parent string
1179 // actually creates a new string (it should not). 1180 // actually creates a new string (it should not).
1180 FLAG_string_slices = true; 1181 FLAG_string_slices = true;
1181 CcTest::InitializeVM(); 1182 CcTest::InitializeVM();
1182 v8::HandleScope scope(CcTest::isolate()); 1183 v8::HandleScope scope(CcTest::isolate());
1183 v8::Local<v8::Value> result; 1184 v8::Local<v8::Value> result;
1184 Handle<String> string; 1185 Handle<String> string;
1185 const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';"; 1186 const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';";
1186 const char* slice = "var slice = str.slice(1,-1); slice"; 1187 const char* slice = "var slice = ''; slice = str.slice(1,-1); slice";
1187 const char* slice_from_slice = "slice.slice(1,-1);"; 1188 const char* slice_from_slice = "slice.slice(1,-1);";
1188 1189
1189 CompileRun(init); 1190 CompileRun(init);
1190 result = CompileRun(slice); 1191 result = CompileRun(slice);
1191 CHECK(result->IsString()); 1192 CHECK(result->IsString());
1192 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 1193 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
1193 CHECK(string->IsSlicedString()); 1194 CHECK(string->IsSlicedString());
1194 CHECK(SlicedString::cast(*string)->parent()->IsSeqString()); 1195 CHECK(SlicedString::cast(*string)->parent()->IsSeqString());
1195 CHECK_EQ("bcdefghijklmnopqrstuvwxy", string->ToCString().get()); 1196 CHECK_EQ("bcdefghijklmnopqrstuvwxy", string->ToCString().get());
1196 1197
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 CHECK(isolate->has_pending_exception()); \ 1450 CHECK(isolate->has_pending_exception()); \
1450 isolate->clear_pending_exception(); \ 1451 isolate->clear_pending_exception(); \
1451 dummy.Dispose(); \ 1452 dummy.Dispose(); \
1452 } 1453 }
1453 1454
1454 INVALID_STRING_TEST(NewStringFromAscii, char) 1455 INVALID_STRING_TEST(NewStringFromAscii, char)
1455 INVALID_STRING_TEST(NewStringFromUtf8, char) 1456 INVALID_STRING_TEST(NewStringFromUtf8, char)
1456 INVALID_STRING_TEST(NewStringFromOneByte, uint8_t) 1457 INVALID_STRING_TEST(NewStringFromOneByte, uint8_t)
1457 1458
1458 #undef INVALID_STRING_TEST 1459 #undef INVALID_STRING_TEST
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/regress/regress-1757.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698