OLD | NEW |
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 CHECK_EQ(3, CountArrayBuffersInWeakList(isolate->heap()) - start); | 148 CHECK_EQ(3, CountArrayBuffersInWeakList(isolate->heap()) - start); |
149 CHECK(HasArrayBufferInWeakList(isolate->heap(), | 149 CHECK(HasArrayBufferInWeakList(isolate->heap(), |
150 *v8::Utils::OpenHandle(*ab1))); | 150 *v8::Utils::OpenHandle(*ab1))); |
151 CHECK(HasArrayBufferInWeakList(isolate->heap(), | 151 CHECK(HasArrayBufferInWeakList(isolate->heap(), |
152 *v8::Utils::OpenHandle(*ab2))); | 152 *v8::Utils::OpenHandle(*ab2))); |
153 CHECK(HasArrayBufferInWeakList(isolate->heap(), | 153 CHECK(HasArrayBufferInWeakList(isolate->heap(), |
154 *v8::Utils::OpenHandle(*ab3))); | 154 *v8::Utils::OpenHandle(*ab3))); |
155 } | 155 } |
156 | 156 |
157 i::ScopedVector<char> source(1024); | 157 i::ScopedVector<char> source(1024); |
158 i::OS::SNPrintF(source, "ab%d = null;", i); | 158 i::SNPrintF(source, "ab%d = null;", i); |
159 CompileRun(source.start()); | 159 CompileRun(source.start()); |
160 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 160 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
161 | 161 |
162 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap()) - start); | 162 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap()) - start); |
163 | 163 |
164 { | 164 { |
165 v8::HandleScope s2(context->GetIsolate()); | 165 v8::HandleScope s2(context->GetIsolate()); |
166 for (int j = 1; j <= 3; j++) { | 166 for (int j = 1; j <= 3; j++) { |
167 if (j == i) continue; | 167 if (j == i) continue; |
168 i::OS::SNPrintF(source, "ab%d", j); | 168 i::SNPrintF(source, "ab%d", j); |
169 v8::Handle<v8::ArrayBuffer> ab = | 169 v8::Handle<v8::ArrayBuffer> ab = |
170 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun(source.start())); | 170 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun(source.start())); |
171 CHECK(HasArrayBufferInWeakList(isolate->heap(), | 171 CHECK(HasArrayBufferInWeakList(isolate->heap(), |
172 *v8::Utils::OpenHandle(*ab))); | 172 *v8::Utils::OpenHandle(*ab))); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 CompileRun("ab1 = null; ab2 = null; ab3 = null;"); | 176 CompileRun("ab1 = null; ab2 = null; ab3 = null;"); |
177 } | 177 } |
178 | 178 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 for (int i = 1; i <= 3; i++) { | 275 for (int i = 1; i <= 3; i++) { |
276 // Create 3 typed arrays, make i-th of them garbage, | 276 // Create 3 typed arrays, make i-th of them garbage, |
277 // validate correct state of typed array weak list. | 277 // validate correct state of typed array weak list. |
278 v8::HandleScope s0(context->GetIsolate()); | 278 v8::HandleScope s0(context->GetIsolate()); |
279 i::ScopedVector<char> source(2048); | 279 i::ScopedVector<char> source(2048); |
280 | 280 |
281 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); | 281 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); |
282 | 282 |
283 { | 283 { |
284 v8::HandleScope s1(context->GetIsolate()); | 284 v8::HandleScope s1(context->GetIsolate()); |
285 i::OS::SNPrintF(source, | 285 i::SNPrintF(source, |
286 "var ta1 = new %s(ab);" | 286 "var ta1 = new %s(ab);" |
287 "var ta2 = new %s(ab);" | 287 "var ta2 = new %s(ab);" |
288 "var ta3 = new %s(ab)", | 288 "var ta3 = new %s(ab)", |
289 constructor, constructor, constructor); | 289 constructor, constructor, constructor); |
290 | 290 |
291 CompileRun(source.start()); | 291 CompileRun(source.start()); |
292 v8::Handle<v8::ArrayBuffer> ab = | 292 v8::Handle<v8::ArrayBuffer> ab = |
293 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab")); | 293 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab")); |
294 v8::Handle<TypedArray> ta1 = | 294 v8::Handle<TypedArray> ta1 = |
295 v8::Handle<TypedArray>::Cast(CompileRun("ta1")); | 295 v8::Handle<TypedArray>::Cast(CompileRun("ta1")); |
296 v8::Handle<TypedArray> ta2 = | 296 v8::Handle<TypedArray> ta2 = |
297 v8::Handle<TypedArray>::Cast(CompileRun("ta2")); | 297 v8::Handle<TypedArray>::Cast(CompileRun("ta2")); |
298 v8::Handle<TypedArray> ta3 = | 298 v8::Handle<TypedArray> ta3 = |
299 v8::Handle<TypedArray>::Cast(CompileRun("ta3")); | 299 v8::Handle<TypedArray>::Cast(CompileRun("ta3")); |
300 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); | 300 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); |
301 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); | 301 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); |
302 CHECK_EQ(3, CountViews(*iab)); | 302 CHECK_EQ(3, CountViews(*iab)); |
303 CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta1))); | 303 CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta1))); |
304 CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta2))); | 304 CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta2))); |
305 CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta3))); | 305 CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta3))); |
306 } | 306 } |
307 | 307 |
308 i::OS::SNPrintF(source, "ta%d = null;", i); | 308 i::SNPrintF(source, "ta%d = null;", i); |
309 CompileRun(source.start()); | 309 CompileRun(source.start()); |
310 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 310 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
311 | 311 |
312 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); | 312 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); |
313 | 313 |
314 { | 314 { |
315 v8::HandleScope s2(context->GetIsolate()); | 315 v8::HandleScope s2(context->GetIsolate()); |
316 v8::Handle<v8::ArrayBuffer> ab = | 316 v8::Handle<v8::ArrayBuffer> ab = |
317 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab")); | 317 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab")); |
318 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); | 318 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); |
319 CHECK_EQ(2, CountViews(*iab)); | 319 CHECK_EQ(2, CountViews(*iab)); |
320 for (int j = 1; j <= 3; j++) { | 320 for (int j = 1; j <= 3; j++) { |
321 if (j == i) continue; | 321 if (j == i) continue; |
322 i::OS::SNPrintF(source, "ta%d", j); | 322 i::SNPrintF(source, "ta%d", j); |
323 v8::Handle<TypedArray> ta = | 323 v8::Handle<TypedArray> ta = |
324 v8::Handle<TypedArray>::Cast(CompileRun(source.start())); | 324 v8::Handle<TypedArray>::Cast(CompileRun(source.start())); |
325 CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta))); | 325 CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta))); |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 CompileRun("ta1 = null; ta2 = null; ta3 = null;"); | 329 CompileRun("ta1 = null; ta2 = null; ta3 = null;"); |
330 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 330 isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
331 | 331 |
332 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); | 332 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 383 |
384 | 384 |
385 TEST(Uint8ClampedArrayFromScript) { | 385 TEST(Uint8ClampedArrayFromScript) { |
386 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray"); | 386 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray"); |
387 } | 387 } |
388 | 388 |
389 | 389 |
390 TEST(DataViewFromScript) { | 390 TEST(DataViewFromScript) { |
391 TestTypedArrayFromScript<v8::DataView>("DataView"); | 391 TestTypedArrayFromScript<v8::DataView>("DataView"); |
392 } | 392 } |
OLD | NEW |