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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
| 28 // TODO(jochen): Remove this after the setting is turned on globally. |
| 29 #define V8_IMMINENT_DEPRECATION_WARNINGS |
| 30 |
28 #include "src/global-handles.h" | 31 #include "src/global-handles.h" |
29 | 32 |
30 #include "test/cctest/cctest.h" | 33 #include "test/cctest/cctest.h" |
31 | 34 |
32 using namespace v8::internal; | 35 using namespace v8::internal; |
33 using v8::UniqueId; | 36 using v8::UniqueId; |
34 | 37 |
35 | 38 |
36 static List<Object*> skippable_objects; | 39 static List<Object*> skippable_objects; |
37 static List<Object*> can_skip_called_objects; | 40 static List<Object*> can_skip_called_objects; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // Create a number of handles that will not be on a block boundary | 333 // Create a number of handles that will not be on a block boundary |
331 const int kArrayLength = 2048-1; | 334 const int kArrayLength = 2048-1; |
332 int indices[kArrayLength]; | 335 int indices[kArrayLength]; |
333 v8::Eternal<v8::Value> eternals[kArrayLength]; | 336 v8::Eternal<v8::Value> eternals[kArrayLength]; |
334 | 337 |
335 CHECK_EQ(0, eternal_handles->NumberOfHandles()); | 338 CHECK_EQ(0, eternal_handles->NumberOfHandles()); |
336 for (int i = 0; i < kArrayLength; i++) { | 339 for (int i = 0; i < kArrayLength; i++) { |
337 indices[i] = -1; | 340 indices[i] = -1; |
338 HandleScope scope(isolate); | 341 HandleScope scope(isolate); |
339 v8::Local<v8::Object> object = v8::Object::New(v8_isolate); | 342 v8::Local<v8::Object> object = v8::Object::New(v8_isolate); |
340 object->Set(i, v8::Integer::New(v8_isolate, i)); | 343 object->Set(v8_isolate->GetCurrentContext(), i, |
| 344 v8::Integer::New(v8_isolate, i)) |
| 345 .FromJust(); |
341 // Create with internal api | 346 // Create with internal api |
342 eternal_handles->Create( | 347 eternal_handles->Create( |
343 isolate, *v8::Utils::OpenHandle(*object), &indices[i]); | 348 isolate, *v8::Utils::OpenHandle(*object), &indices[i]); |
344 // Create with external api | 349 // Create with external api |
345 CHECK(eternals[i].IsEmpty()); | 350 CHECK(eternals[i].IsEmpty()); |
346 eternals[i].Set(v8_isolate, object); | 351 eternals[i].Set(v8_isolate, object); |
347 CHECK(!eternals[i].IsEmpty()); | 352 CHECK(!eternals[i].IsEmpty()); |
348 } | 353 } |
349 | 354 |
350 isolate->heap()->CollectAllAvailableGarbage(); | 355 isolate->heap()->CollectAllAvailableGarbage(); |
351 | 356 |
352 for (int i = 0; i < kArrayLength; i++) { | 357 for (int i = 0; i < kArrayLength; i++) { |
353 for (int j = 0; j < 2; j++) { | 358 for (int j = 0; j < 2; j++) { |
354 HandleScope scope(isolate); | 359 HandleScope scope(isolate); |
355 v8::Local<v8::Value> local; | 360 v8::Local<v8::Value> local; |
356 if (j == 0) { | 361 if (j == 0) { |
357 // Test internal api | 362 // Test internal api |
358 local = v8::Utils::ToLocal(eternal_handles->Get(indices[i])); | 363 local = v8::Utils::ToLocal(eternal_handles->Get(indices[i])); |
359 } else { | 364 } else { |
360 // Test external api | 365 // Test external api |
361 local = eternals[i].Get(v8_isolate); | 366 local = eternals[i].Get(v8_isolate); |
362 } | 367 } |
363 v8::Local<v8::Object> object = v8::Handle<v8::Object>::Cast(local); | 368 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(local); |
364 v8::Local<v8::Value> value = object->Get(i); | 369 v8::Local<v8::Value> value = |
| 370 object->Get(v8_isolate->GetCurrentContext(), i).ToLocalChecked(); |
365 CHECK(value->IsInt32()); | 371 CHECK(value->IsInt32()); |
366 CHECK_EQ(i, value->Int32Value()); | 372 CHECK_EQ(i, |
| 373 value->Int32Value(v8_isolate->GetCurrentContext()).FromJust()); |
367 } | 374 } |
368 } | 375 } |
369 | 376 |
370 CHECK_EQ(2*kArrayLength, eternal_handles->NumberOfHandles()); | 377 CHECK_EQ(2*kArrayLength, eternal_handles->NumberOfHandles()); |
371 | 378 |
372 // Create an eternal via the constructor | 379 // Create an eternal via the constructor |
373 { | 380 { |
374 HandleScope scope(isolate); | 381 HandleScope scope(isolate); |
375 v8::Local<v8::Object> object = v8::Object::New(v8_isolate); | 382 v8::Local<v8::Object> object = v8::Object::New(v8_isolate); |
376 v8::Eternal<v8::Object> eternal(v8_isolate, object); | 383 v8::Eternal<v8::Object> eternal(v8_isolate, object); |
(...skipping 13 matching lines...) Expand all Loading... |
390 v8::Local<v8::Object> o = v8::Object::New(isolate); | 397 v8::Local<v8::Object> o = v8::Object::New(isolate); |
391 CHECK(!o.IsEmpty()); | 398 CHECK(!o.IsEmpty()); |
392 v8::Persistent<v8::Object> p(isolate, o); | 399 v8::Persistent<v8::Object> p(isolate, o); |
393 CHECK(o == p.Get(isolate)); | 400 CHECK(o == p.Get(isolate)); |
394 CHECK(v8::Local<v8::Object>::New(isolate, p) == p.Get(isolate)); | 401 CHECK(v8::Local<v8::Object>::New(isolate, p) == p.Get(isolate)); |
395 | 402 |
396 v8::Global<v8::Object> g(isolate, o); | 403 v8::Global<v8::Object> g(isolate, o); |
397 CHECK(o == g.Get(isolate)); | 404 CHECK(o == g.Get(isolate)); |
398 CHECK(v8::Local<v8::Object>::New(isolate, g) == g.Get(isolate)); | 405 CHECK(v8::Local<v8::Object>::New(isolate, g) == g.Get(isolate)); |
399 } | 406 } |
OLD | NEW |