| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // validate correct state of array buffer weak list. | 130 // validate correct state of array buffer weak list. |
| 131 CHECK_EQ(0, CountArrayBuffersInWeakList(isolate->heap())); | 131 CHECK_EQ(0, CountArrayBuffersInWeakList(isolate->heap())); |
| 132 { | 132 { |
| 133 v8::HandleScope scope(context->GetIsolate()); | 133 v8::HandleScope scope(context->GetIsolate()); |
| 134 | 134 |
| 135 { | 135 { |
| 136 v8::HandleScope s1(context->GetIsolate()); | 136 v8::HandleScope s1(context->GetIsolate()); |
| 137 CompileRun("var ab1 = new ArrayBuffer(256);" | 137 CompileRun("var ab1 = new ArrayBuffer(256);" |
| 138 "var ab2 = new ArrayBuffer(256);" | 138 "var ab2 = new ArrayBuffer(256);" |
| 139 "var ab3 = new ArrayBuffer(256);"); | 139 "var ab3 = new ArrayBuffer(256);"); |
| 140 v8::Handle<v8::ArrayBuffer> ab1( | 140 v8::Handle<v8::ArrayBuffer> ab1 = |
| 141 v8::ArrayBuffer::Cast(*CompileRun("ab1"))); | 141 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab1")); |
| 142 v8::Handle<v8::ArrayBuffer> ab2( | 142 v8::Handle<v8::ArrayBuffer> ab2 = |
| 143 v8::ArrayBuffer::Cast(*CompileRun("ab2"))); | 143 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab2")); |
| 144 v8::Handle<v8::ArrayBuffer> ab3( | 144 v8::Handle<v8::ArrayBuffer> ab3 = |
| 145 v8::ArrayBuffer::Cast(*CompileRun("ab3"))); | 145 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab3")); |
| 146 | 146 |
| 147 CHECK_EQ(3, CountArrayBuffersInWeakList(isolate->heap())); | 147 CHECK_EQ(3, CountArrayBuffersInWeakList(isolate->heap())); |
| 148 CHECK(HasArrayBufferInWeakList(isolate->heap(), | 148 CHECK(HasArrayBufferInWeakList(isolate->heap(), |
| 149 *v8::Utils::OpenHandle(*ab1))); | 149 *v8::Utils::OpenHandle(*ab1))); |
| 150 CHECK(HasArrayBufferInWeakList(isolate->heap(), | 150 CHECK(HasArrayBufferInWeakList(isolate->heap(), |
| 151 *v8::Utils::OpenHandle(*ab2))); | 151 *v8::Utils::OpenHandle(*ab2))); |
| 152 CHECK(HasArrayBufferInWeakList(isolate->heap(), | 152 CHECK(HasArrayBufferInWeakList(isolate->heap(), |
| 153 *v8::Utils::OpenHandle(*ab3))); | 153 *v8::Utils::OpenHandle(*ab3))); |
| 154 } | 154 } |
| 155 | 155 |
| 156 i::ScopedVector<char> source(1024); | 156 i::ScopedVector<char> source(1024); |
| 157 i::OS::SNPrintF(source, "ab%d = null;", i); | 157 i::OS::SNPrintF(source, "ab%d = null;", i); |
| 158 CompileRun(source.start()); | 158 CompileRun(source.start()); |
| 159 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 159 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 160 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 160 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 161 | 161 |
| 162 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap())); | 162 CHECK_EQ(2, CountArrayBuffersInWeakList(isolate->heap())); |
| 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::OS::SNPrintF(source, "ab%d", j); |
| 169 v8::Handle<v8::ArrayBuffer> ab( | 169 v8::Handle<v8::ArrayBuffer> ab = |
| 170 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 |
| 179 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 179 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 180 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 180 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 { | 279 { |
| 280 v8::HandleScope s1(context->GetIsolate()); | 280 v8::HandleScope s1(context->GetIsolate()); |
| 281 i::OS::SNPrintF(source, | 281 i::OS::SNPrintF(source, |
| 282 "var ta1 = new %s(ab);" | 282 "var ta1 = new %s(ab);" |
| 283 "var ta2 = new %s(ab);" | 283 "var ta2 = new %s(ab);" |
| 284 "var ta3 = new %s(ab)", | 284 "var ta3 = new %s(ab)", |
| 285 constructor, constructor, constructor); | 285 constructor, constructor, constructor); |
| 286 | 286 |
| 287 CompileRun(source.start()); | 287 CompileRun(source.start()); |
| 288 v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab"))); | 288 v8::Handle<v8::ArrayBuffer> ab = |
| 289 v8::Handle<TypedArray> ta1(TypedArray::Cast(*CompileRun("ta1"))); | 289 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab")); |
| 290 v8::Handle<TypedArray> ta2(TypedArray::Cast(*CompileRun("ta2"))); | 290 v8::Handle<TypedArray> ta1 = |
| 291 v8::Handle<TypedArray> ta3(TypedArray::Cast(*CompileRun("ta3"))); | 291 v8::Handle<TypedArray>::Cast(CompileRun("ta1")); |
| 292 v8::Handle<TypedArray> ta2 = |
| 293 v8::Handle<TypedArray>::Cast(CompileRun("ta2")); |
| 294 v8::Handle<TypedArray> ta3 = |
| 295 v8::Handle<TypedArray>::Cast(CompileRun("ta3")); |
| 292 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap())); | 296 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap())); |
| 293 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); | 297 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); |
| 294 CHECK_EQ(3, CountTypedArrays(*iab)); | 298 CHECK_EQ(3, CountTypedArrays(*iab)); |
| 295 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta1))); | 299 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta1))); |
| 296 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta2))); | 300 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta2))); |
| 297 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta3))); | 301 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta3))); |
| 298 } | 302 } |
| 299 | 303 |
| 300 i::OS::SNPrintF(source, "ta%d = null;", i); | 304 i::OS::SNPrintF(source, "ta%d = null;", i); |
| 301 CompileRun(source.start()); | 305 CompileRun(source.start()); |
| 302 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 306 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 303 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 307 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 304 | 308 |
| 305 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap())); | 309 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap())); |
| 306 | 310 |
| 307 { | 311 { |
| 308 v8::HandleScope s2(context->GetIsolate()); | 312 v8::HandleScope s2(context->GetIsolate()); |
| 309 v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab"))); | 313 v8::Handle<v8::ArrayBuffer> ab = |
| 314 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab")); |
| 310 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); | 315 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); |
| 311 CHECK_EQ(2, CountTypedArrays(*iab)); | 316 CHECK_EQ(2, CountTypedArrays(*iab)); |
| 312 for (int j = 1; j <= 3; j++) { | 317 for (int j = 1; j <= 3; j++) { |
| 313 if (j == i) continue; | 318 if (j == i) continue; |
| 314 i::OS::SNPrintF(source, "ta%d", j); | 319 i::OS::SNPrintF(source, "ta%d", j); |
| 315 v8::Handle<TypedArray> ta( | 320 v8::Handle<TypedArray> ta = |
| 316 TypedArray::Cast(*CompileRun(source.start()))); | 321 v8::Handle<TypedArray>::Cast(CompileRun(source.start())); |
| 317 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta))); | 322 CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta))); |
| 318 } | 323 } |
| 319 } | 324 } |
| 320 | 325 |
| 321 CompileRun("ta1 = null; ta2 = null; ta3 = null;"); | 326 CompileRun("ta1 = null; ta2 = null; ta3 = null;"); |
| 322 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 327 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 323 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 328 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 324 | 329 |
| 325 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap())); | 330 CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap())); |
| 326 | 331 |
| 327 { | 332 { |
| 328 v8::HandleScope s3(context->GetIsolate()); | 333 v8::HandleScope s3(context->GetIsolate()); |
| 329 v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab"))); | 334 v8::Handle<v8::ArrayBuffer> ab = |
| 335 v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab")); |
| 330 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); | 336 Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab); |
| 331 CHECK_EQ(0, CountTypedArrays(*iab)); | 337 CHECK_EQ(0, CountTypedArrays(*iab)); |
| 332 } | 338 } |
| 333 } | 339 } |
| 334 } | 340 } |
| 335 | 341 |
| 336 | 342 |
| 337 TEST(Uint8ArrayFromScript) { | 343 TEST(Uint8ArrayFromScript) { |
| 338 TestTypedArrayFromScript<v8::Uint8Array>("Uint8Array"); | 344 TestTypedArrayFromScript<v8::Uint8Array>("Uint8Array"); |
| 339 } | 345 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 377 |
| 372 TEST(Float64ArrayFromScript) { | 378 TEST(Float64ArrayFromScript) { |
| 373 TestTypedArrayFromScript<v8::Float64Array>("Float64Array"); | 379 TestTypedArrayFromScript<v8::Float64Array>("Float64Array"); |
| 374 } | 380 } |
| 375 | 381 |
| 376 | 382 |
| 377 TEST(Uint8ClampedArrayFromScript) { | 383 TEST(Uint8ClampedArrayFromScript) { |
| 378 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray"); | 384 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray"); |
| 379 } | 385 } |
| 380 | 386 |
| OLD | NEW |