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

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

Issue 141363005: A64: Synchronize with r15204. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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
« no previous file with comments | « test/cctest/test-types.cc ('k') | test/mjsunit/allocation-site-info.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 for (Object* o = array_buffer->weak_first_array(); 78 for (Object* o = array_buffer->weak_first_array();
79 !o->IsUndefined(); 79 !o->IsUndefined();
80 o = JSTypedArray::cast(o)->weak_next()) { 80 o = JSTypedArray::cast(o)->weak_next()) {
81 if (ta == o) return true; 81 if (ta == o) return true;
82 } 82 }
83 return false; 83 return false;
84 } 84 }
85 85
86 86
87 TEST(WeakArrayBuffersFromApi) { 87 TEST(WeakArrayBuffersFromApi) {
88 i::FLAG_stress_compaction = false;
88 v8::V8::Initialize(); 89 v8::V8::Initialize();
89 LocalContext context; 90 LocalContext context;
90 Isolate* isolate = GetIsolateFrom(&context); 91 Isolate* isolate = GetIsolateFrom(&context);
91 92
92 CHECK_EQ(0, CountArrayBuffersInWeakList(isolate->heap())); 93 CHECK_EQ(0, CountArrayBuffersInWeakList(isolate->heap()));
93 { 94 {
94 v8::HandleScope s1(context->GetIsolate()); 95 v8::HandleScope s1(context->GetIsolate());
95 v8::Handle<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::New(256); 96 v8::Handle<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::New(256);
96 { 97 {
97 v8::HandleScope s2(context->GetIsolate()); 98 v8::HandleScope s2(context->GetIsolate());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // validate correct state of array buffer weak list. 131 // validate correct state of array buffer weak list.
131 CHECK_EQ(0, CountArrayBuffersInWeakList(isolate->heap())); 132 CHECK_EQ(0, CountArrayBuffersInWeakList(isolate->heap()));
132 { 133 {
133 v8::HandleScope scope(context->GetIsolate()); 134 v8::HandleScope scope(context->GetIsolate());
134 135
135 { 136 {
136 v8::HandleScope s1(context->GetIsolate()); 137 v8::HandleScope s1(context->GetIsolate());
137 CompileRun("var ab1 = new ArrayBuffer(256);" 138 CompileRun("var ab1 = new ArrayBuffer(256);"
138 "var ab2 = new ArrayBuffer(256);" 139 "var ab2 = new ArrayBuffer(256);"
139 "var ab3 = new ArrayBuffer(256);"); 140 "var ab3 = new ArrayBuffer(256);");
140 v8::Handle<v8::ArrayBuffer> ab1( 141 v8::Handle<v8::ArrayBuffer> ab1 =
141 v8::ArrayBuffer::Cast(*CompileRun("ab1"))); 142 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab1"));
142 v8::Handle<v8::ArrayBuffer> ab2( 143 v8::Handle<v8::ArrayBuffer> ab2 =
143 v8::ArrayBuffer::Cast(*CompileRun("ab2"))); 144 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab2"));
144 v8::Handle<v8::ArrayBuffer> ab3( 145 v8::Handle<v8::ArrayBuffer> ab3 =
145 v8::ArrayBuffer::Cast(*CompileRun("ab3"))); 146 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab3"));
146 147
147 CHECK_EQ(3, CountArrayBuffersInWeakList(isolate->heap())); 148 CHECK_EQ(3, CountArrayBuffersInWeakList(isolate->heap()));
148 CHECK(HasArrayBufferInWeakList(isolate->heap(), 149 CHECK(HasArrayBufferInWeakList(isolate->heap(),
149 *v8::Utils::OpenHandle(*ab1))); 150 *v8::Utils::OpenHandle(*ab1)));
150 CHECK(HasArrayBufferInWeakList(isolate->heap(), 151 CHECK(HasArrayBufferInWeakList(isolate->heap(),
151 *v8::Utils::OpenHandle(*ab2))); 152 *v8::Utils::OpenHandle(*ab2)));
152 CHECK(HasArrayBufferInWeakList(isolate->heap(), 153 CHECK(HasArrayBufferInWeakList(isolate->heap(),
153 *v8::Utils::OpenHandle(*ab3))); 154 *v8::Utils::OpenHandle(*ab3)));
154 } 155 }
155 156
156 i::ScopedVector<char> source(1024); 157 i::ScopedVector<char> source(1024);
157 i::OS::SNPrintF(source, "ab%d = null;", i); 158 i::OS::SNPrintF(source, "ab%d = null;", i);
158 CompileRun(source.start()); 159 CompileRun(source.start());
159 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 160 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
160 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 161 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
161 162
162 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap())); 163 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap()));
163 164
164 { 165 {
165 v8::HandleScope s2(context->GetIsolate()); 166 v8::HandleScope s2(context->GetIsolate());
166 for (int j = 1; j <= 3; j++) { 167 for (int j = 1; j <= 3; j++) {
167 if (j == i) continue; 168 if (j == i) continue;
168 i::OS::SNPrintF(source, "ab%d", j); 169 i::OS::SNPrintF(source, "ab%d", j);
169 v8::Handle<v8::ArrayBuffer> ab( 170 v8::Handle<v8::ArrayBuffer> ab =
170 v8::ArrayBuffer::Cast(*CompileRun(source.start()))); 171 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun(source.start()));
171 CHECK(HasArrayBufferInWeakList(isolate->heap(), 172 CHECK(HasArrayBufferInWeakList(isolate->heap(),
172 *v8::Utils::OpenHandle(*ab))); 173 *v8::Utils::OpenHandle(*ab)));
173 } 174 }
174 } 175 }
175 176
176 CompileRun("ab1 = null; ab2 = null; ab3 = null;"); 177 CompileRun("ab1 = null; ab2 = null; ab3 = null;");
177 } 178 }
178 179
179 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 180 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
180 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 181 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 279
279 { 280 {
280 v8::HandleScope s1(context->GetIsolate()); 281 v8::HandleScope s1(context->GetIsolate());
281 i::OS::SNPrintF(source, 282 i::OS::SNPrintF(source,
282 "var ta1 = new %s(ab);" 283 "var ta1 = new %s(ab);"
283 "var ta2 = new %s(ab);" 284 "var ta2 = new %s(ab);"
284 "var ta3 = new %s(ab)", 285 "var ta3 = new %s(ab)",
285 constructor, constructor, constructor); 286 constructor, constructor, constructor);
286 287
287 CompileRun(source.start()); 288 CompileRun(source.start());
288 v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab"))); 289 v8::Handle<v8::ArrayBuffer> ab =
289 v8::Handle<TypedArray> ta1(TypedArray::Cast(*CompileRun("ta1"))); 290 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
290 v8::Handle<TypedArray> ta2(TypedArray::Cast(*CompileRun("ta2"))); 291 v8::Handle<TypedArray> ta1 =
291 v8::Handle<TypedArray> ta3(TypedArray::Cast(*CompileRun("ta3"))); 292 v8::Handle<TypedArray>::Cast(CompileRun("ta1"));
293 v8::Handle<TypedArray> ta2 =
294 v8::Handle<TypedArray>::Cast(CompileRun("ta2"));
295 v8::Handle<TypedArray> ta3 =
296 v8::Handle<TypedArray>::Cast(CompileRun("ta3"));
292 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap())); 297 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()));
293 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); 298 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
294 CHECK_EQ(3, CountTypedArrays(*iab)); 299 CHECK_EQ(3, CountTypedArrays(*iab));
295 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta1))); 300 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta1)));
296 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta2))); 301 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta2)));
297 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta3))); 302 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta3)));
298 } 303 }
299 304
300 i::OS::SNPrintF(source, "ta%d = null;", i); 305 i::OS::SNPrintF(source, "ta%d = null;", i);
301 CompileRun(source.start()); 306 CompileRun(source.start());
302 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 307 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
303 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 308 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
304 309
305 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap())); 310 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()));
306 311
307 { 312 {
308 v8::HandleScope s2(context->GetIsolate()); 313 v8::HandleScope s2(context->GetIsolate());
309 v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab"))); 314 v8::Handle<v8::ArrayBuffer> ab =
315 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
310 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); 316 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
311 CHECK_EQ(2, CountTypedArrays(*iab)); 317 CHECK_EQ(2, CountTypedArrays(*iab));
312 for (int j = 1; j <= 3; j++) { 318 for (int j = 1; j <= 3; j++) {
313 if (j == i) continue; 319 if (j == i) continue;
314 i::OS::SNPrintF(source, "ta%d", j); 320 i::OS::SNPrintF(source, "ta%d", j);
315 v8::Handle<TypedArray> ta( 321 v8::Handle<TypedArray> ta =
316 TypedArray::Cast(*CompileRun(source.start()))); 322 v8::Handle<TypedArray>::Cast(CompileRun(source.start()));
317 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta))); 323 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta)));
318 } 324 }
319 } 325 }
320 326
321 CompileRun("ta1 = null; ta2 = null; ta3 = null;"); 327 CompileRun("ta1 = null; ta2 = null; ta3 = null;");
322 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 328 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
323 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 329 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
324 330
325 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap())); 331 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()));
326 332
327 { 333 {
328 v8::HandleScope s3(context->GetIsolate()); 334 v8::HandleScope s3(context->GetIsolate());
329 v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab"))); 335 v8::Handle<v8::ArrayBuffer> ab =
336 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
330 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); 337 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
331 CHECK_EQ(0, CountTypedArrays(*iab)); 338 CHECK_EQ(0, CountTypedArrays(*iab));
332 } 339 }
333 } 340 }
334 } 341 }
335 342
336 343
337 TEST(Uint8ArrayFromScript) { 344 TEST(Uint8ArrayFromScript) {
338 TestTypedArrayFromScript<v8::Uint8Array>("Uint8Array"); 345 TestTypedArrayFromScript<v8::Uint8Array>("Uint8Array");
339 } 346 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 378
372 TEST(Float64ArrayFromScript) { 379 TEST(Float64ArrayFromScript) {
373 TestTypedArrayFromScript<v8::Float64Array>("Float64Array"); 380 TestTypedArrayFromScript<v8::Float64Array>("Float64Array");
374 } 381 }
375 382
376 383
377 TEST(Uint8ClampedArrayFromScript) { 384 TEST(Uint8ClampedArrayFromScript) {
378 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray"); 385 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray");
379 } 386 }
380 387
OLDNEW
« no previous file with comments | « test/cctest/test-types.cc ('k') | test/mjsunit/allocation-site-info.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698