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

Side by Side Diff: test/cctest/test-global-handles.cc

Issue 151163005: A64: Synchronize with r16356. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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-disasm-x64.cc ('k') | test/cctest/test-heap.cc » ('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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 reinterpret_cast<HeapObject**>(g2s1.location())); 314 reinterpret_cast<HeapObject**>(g2s1.location()));
315 ASSERT(implicit_refs->at(1)->length == 1); 315 ASSERT(implicit_refs->at(1)->length == 1);
316 ASSERT(implicit_refs->at(1)->children[0] == g2c1.location()); 316 ASSERT(implicit_refs->at(1)->children[0] == g2c1.location());
317 } 317 }
318 318
319 319
320 TEST(EternalHandles) { 320 TEST(EternalHandles) {
321 CcTest::InitializeVM(); 321 CcTest::InitializeVM();
322 Isolate* isolate = Isolate::Current(); 322 Isolate* isolate = Isolate::Current();
323 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 323 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
324 EternalHandles* eternals = isolate->eternal_handles(); 324 EternalHandles* eternal_handles = isolate->eternal_handles();
325 325
326 // Create a number of handles that will not be on a block boundary 326 // Create a number of handles that will not be on a block boundary
327 const int kArrayLength = 2048-1; 327 const int kArrayLength = 2048-1;
328 int indices[kArrayLength]; 328 int indices[kArrayLength];
329 v8::Eternal<v8::Value> eternals[kArrayLength];
329 330
330 CHECK_EQ(0, eternals->NumberOfHandles()); 331 CHECK_EQ(0, eternal_handles->NumberOfHandles());
331 for (int i = 0; i < kArrayLength; i++) { 332 for (int i = 0; i < kArrayLength; i++) {
333 indices[i] = -1;
332 HandleScope scope(isolate); 334 HandleScope scope(isolate);
333 v8::Local<v8::Object> object = v8::Object::New(); 335 v8::Local<v8::Object> object = v8::Object::New();
334 object->Set(i, v8::Integer::New(i, v8_isolate)); 336 object->Set(i, v8::Integer::New(i, v8_isolate));
335 if (i % 2 == 0) { 337 // Create with internal api
336 // Create with internal api 338 eternal_handles->Create(
337 indices[i] = eternals->Create(isolate, *v8::Utils::OpenHandle(*object)); 339 isolate, *v8::Utils::OpenHandle(*object), &indices[i]);
338 } else { 340 // Create with external api
339 // Create with external api 341 CHECK(!eternals[i].IsEmpty());
340 indices[i] = object.Eternalize(v8_isolate); 342 eternals[i].Set(v8_isolate, object);
341 } 343 CHECK(eternals[i].IsEmpty());
342 } 344 }
343 345
344 isolate->heap()->CollectAllAvailableGarbage(); 346 isolate->heap()->CollectAllAvailableGarbage();
345 347
346 for (int i = 0; i < kArrayLength; i++) { 348 for (int i = 0; i < kArrayLength; i++) {
347 for (int j = 0; j < 2; j++) { 349 for (int j = 0; j < 2; j++) {
348 HandleScope scope(isolate); 350 HandleScope scope(isolate);
349 v8::Local<v8::Object> object; 351 v8::Local<v8::Value> local;
350 if (j == 0) { 352 if (j == 0) {
351 // Test internal api 353 // Test internal api
352 v8::Local<v8::Value> local = 354 local = v8::Utils::ToLocal(eternal_handles->Get(indices[i]));
353 v8::Utils::ToLocal(eternals->Get(indices[i]));
354 object = v8::Handle<v8::Object>::Cast(local);
355 } else { 355 } else {
356 // Test external api 356 // Test external api
357 object = v8::Local<v8::Object>::GetEternal(v8_isolate, indices[i]); 357 local = eternals[i].Get(v8_isolate);
358 } 358 }
359 v8::Local<v8::Object> object = v8::Handle<v8::Object>::Cast(local);
359 v8::Local<v8::Value> value = object->Get(i); 360 v8::Local<v8::Value> value = object->Get(i);
360 CHECK(value->IsInt32()); 361 CHECK(value->IsInt32());
361 CHECK_EQ(i, value->Int32Value()); 362 CHECK_EQ(i, value->Int32Value());
362 } 363 }
363 } 364 }
364 365
365 CHECK_EQ(kArrayLength, eternals->NumberOfHandles()); 366 CHECK_EQ(2*kArrayLength, eternal_handles->NumberOfHandles());
367
368 // Create an eternal via the constructor
369 {
370 HandleScope scope(isolate);
371 v8::Local<v8::Object> object = v8::Object::New();
372 v8::Eternal<v8::Object> eternal(v8_isolate, object);
373 CHECK(eternal.IsEmpty());
374 CHECK(object == eternal.Get(v8_isolate));
375 }
376
377 CHECK_EQ(2*kArrayLength + 1, eternal_handles->NumberOfHandles());
366 } 378 }
OLDNEW
« no previous file with comments | « test/cctest/test-disasm-x64.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698