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

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

Issue 22715004: Version 3.20.15 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Add TypedArray API and correctness patches r16033 and r16084 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 | « test/cctest/test-cpu-profiler.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 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::Local<v8::Object> object = v8::Object::New();
334 object->Set(i, v8::Integer::New(i, v8_isolate));
335 if (i % 2 == 0) {
336 // Create with internal api
337 indices[i] = eternals->Create(isolate, *v8::Utils::OpenHandle(*object));
338 } else {
339 // Create with external api
340 indices[i] = object.Eternalize(v8_isolate);
341 }
342 }
343
344 isolate->heap()->CollectAllAvailableGarbage();
345
346 for (int i = 0; i < kArrayLength; i++) {
347 for (int j = 0; j < 2; j++) {
348 HandleScope scope(isolate);
349 v8::Local<v8::Object> object;
350 if (j == 0) {
351 // Test internal api
352 v8::Local<v8::Value> local =
353 v8::Utils::ToLocal(eternals->Get(indices[i]));
354 object = v8::Handle<v8::Object>::Cast(local);
355 } else {
356 // Test external api
357 object = v8::Local<v8::Object>::GetEternal(v8_isolate, indices[i]);
358 }
359 v8::Local<v8::Value> value = object->Get(i);
360 CHECK(value->IsInt32());
361 CHECK_EQ(i, value->Int32Value());
362 }
363 }
364
365 CHECK_EQ(kArrayLength, eternals->NumberOfHandles());
366 }
367
OLDNEW
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698