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

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

Issue 21133006: introduce eternal handles (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: returns handles, added tests Created 7 years, 4 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 | « src/serialize.cc ('k') | tools/v8heapconst.py » ('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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 ASSERT(implicit_refs->at(0)->parent == 308 ASSERT(implicit_refs->at(0)->parent ==
309 reinterpret_cast<HeapObject**>(g1s1.location())); 309 reinterpret_cast<HeapObject**>(g1s1.location()));
310 ASSERT(implicit_refs->at(0)->length == 2); 310 ASSERT(implicit_refs->at(0)->length == 2);
311 ASSERT(implicit_refs->at(0)->children[0] == g1c1.location()); 311 ASSERT(implicit_refs->at(0)->children[0] == g1c1.location());
312 ASSERT(implicit_refs->at(0)->children[1] == g1c2.location()); 312 ASSERT(implicit_refs->at(0)->children[1] == g1c2.location());
313 ASSERT(implicit_refs->at(1)->parent == 313 ASSERT(implicit_refs->at(1)->parent ==
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
319
320 TEST(EternalHandles) {
321 CcTest::InitializeVM();
322 Isolate* isolate = Isolate::Current();
323 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
324 EternalHandles* eternals = isolate->eternal_handles();
325
326 // Create a number of handles that will not be on a block boundary
327 const int kArrayLength = 2048-1;
328 int indices[kArrayLength];
329
330 CHECK_EQ(0, eternals->NumberOfHandles());
331 for (int i = 0; i < kArrayLength; i++) {
332 HandleScope scope(isolate);
333 v8::Handle<v8::Object> object = v8::Object::New();
334 object->Set(i, v8::Integer::New(i, v8_isolate));
335 indices[i] = eternals->Create(isolate, *v8::Utils::OpenHandle(*object));
336 }
337
338 isolate->heap()->CollectAllAvailableGarbage();
339
340 for (int i = 0; i < kArrayLength; i++) {
341 HandleScope scope(isolate);
342 v8::Handle<v8::Value> local = v8::Utils::ToLocal(eternals->Get(i));
343 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(local);
344 v8::Handle<v8::Value> value = object->Get(i);
345 CHECK(value->IsInt32());
346 CHECK_EQ(i, value->Int32Value());
347 }
348
349 CHECK_EQ(kArrayLength, eternals->NumberOfHandles());
350 }
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | tools/v8heapconst.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698