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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 477 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
478 EternalHandles* eternals = isolate->eternal_handles(); | 478 EternalHandles* eternals = isolate->eternal_handles(); |
479 | 479 |
480 // Create a number of handles that will not be on a block boundary | 480 // Create a number of handles that will not be on a block boundary |
481 const int kArrayLength = 2048-1; | 481 const int kArrayLength = 2048-1; |
482 int indices[kArrayLength]; | 482 int indices[kArrayLength]; |
483 | 483 |
484 CHECK_EQ(0, eternals->NumberOfHandles()); | 484 CHECK_EQ(0, eternals->NumberOfHandles()); |
485 for (int i = 0; i < kArrayLength; i++) { | 485 for (int i = 0; i < kArrayLength; i++) { |
486 HandleScope scope(isolate); | 486 HandleScope scope(isolate); |
487 v8::Handle<v8::Object> object = v8::Object::New(); | 487 v8::Local<v8::Object> object = v8::Object::New(); |
488 object->Set(i, v8::Integer::New(i, v8_isolate)); | 488 object->Set(i, v8::Integer::New(i, v8_isolate)); |
489 indices[i] = eternals->Create(isolate, *v8::Utils::OpenHandle(*object)); | 489 if (i % 2 == 0) { |
| 490 // Create with internal api |
| 491 indices[i] = eternals->Create(isolate, *v8::Utils::OpenHandle(*object)); |
| 492 } else { |
| 493 // Create with external api |
| 494 indices[i] = object.Eternalize(v8_isolate); |
| 495 } |
490 } | 496 } |
491 | 497 |
492 isolate->heap()->CollectAllAvailableGarbage(); | 498 isolate->heap()->CollectAllAvailableGarbage(); |
493 | 499 |
494 for (int i = 0; i < kArrayLength; i++) { | 500 for (int i = 0; i < kArrayLength; i++) { |
495 HandleScope scope(isolate); | 501 for (int j = 0; j < 2; j++) { |
496 v8::Handle<v8::Value> local = | 502 HandleScope scope(isolate); |
497 v8::Utils::ToLocal(eternals->Get(indices[i])); | 503 v8::Local<v8::Object> object; |
498 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(local); | 504 if (j == 0) { |
499 v8::Handle<v8::Value> value = object->Get(i); | 505 // Test internal api |
500 CHECK(value->IsInt32()); | 506 v8::Local<v8::Value> local = |
501 CHECK_EQ(i, value->Int32Value()); | 507 v8::Utils::ToLocal(eternals->Get(indices[i])); |
| 508 object = v8::Handle<v8::Object>::Cast(local); |
| 509 } else { |
| 510 // Test external api |
| 511 object = v8::Local<v8::Object>::GetEternal(v8_isolate, indices[i]); |
| 512 } |
| 513 v8::Local<v8::Value> value = object->Get(i); |
| 514 CHECK(value->IsInt32()); |
| 515 CHECK_EQ(i, value->Int32Value()); |
| 516 } |
502 } | 517 } |
503 | 518 |
504 CHECK_EQ(kArrayLength, eternals->NumberOfHandles()); | 519 CHECK_EQ(kArrayLength, eternals->NumberOfHandles()); |
505 } | 520 } |
506 | 521 |
OLD | NEW |