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

Side by Side Diff: test/cctest/test-weaktypedarrays.cc

Issue 16641003: Unify processing of weak lists in heap.cc (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 7 years, 6 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
« src/heap.cc ('K') | « src/serialize.cc ('k') | no next file » | 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 26 matching lines...) Expand all
37 using namespace v8::internal; 37 using namespace v8::internal;
38 38
39 static Isolate* GetIsolateFrom(LocalContext* context) { 39 static Isolate* GetIsolateFrom(LocalContext* context) {
40 return reinterpret_cast<Isolate*>((*context)->GetIsolate()); 40 return reinterpret_cast<Isolate*>((*context)->GetIsolate());
41 } 41 }
42 42
43 43
44 static int CountArrayBuffersInWeakList(Heap* heap) { 44 static int CountArrayBuffersInWeakList(Heap* heap) {
45 int count = 0; 45 int count = 0;
46 for (Object* o = heap->array_buffers_list(); 46 for (Object* o = heap->array_buffers_list();
47 o != Smi::FromInt(0); 47 !o->IsUndefined();
48 o = JSArrayBuffer::cast(o)->weak_next()) { 48 o = JSArrayBuffer::cast(o)->weak_next()) {
49 count++; 49 count++;
50 } 50 }
51 return count; 51 return count;
52 } 52 }
53 53
54 54
55 static bool HasArrayBufferInWeakList(Heap* heap, JSArrayBuffer* ab) { 55 static bool HasArrayBufferInWeakList(Heap* heap, JSArrayBuffer* ab) {
56 for (Object* o = heap->array_buffers_list(); 56 for (Object* o = heap->array_buffers_list();
57 o != Smi::FromInt(0); 57 !o->IsUndefined();
58 o = JSArrayBuffer::cast(o)->weak_next()) { 58 o = JSArrayBuffer::cast(o)->weak_next()) {
59 if (ab == o) return true; 59 if (ab == o) return true;
60 } 60 }
61 return false; 61 return false;
62 } 62 }
63 63
64 64
65 static int CountTypedArrays(JSArrayBuffer* array_buffer) { 65 static int CountTypedArrays(JSArrayBuffer* array_buffer) {
66 int count = 0; 66 int count = 0;
67 for (Object* o = array_buffer->weak_first_array(); 67 for (Object* o = array_buffer->weak_first_array();
68 o != Smi::FromInt(0); 68 !o->IsUndefined();
69 o = JSTypedArray::cast(o)->weak_next()) { 69 o = JSTypedArray::cast(o)->weak_next()) {
70 count++; 70 count++;
71 } 71 }
72 72
73 return count; 73 return count;
74 } 74 }
75 75
76 static bool HasTypedArrayInWeakList(JSArrayBuffer* array_buffer, 76 static bool HasTypedArrayInWeakList(JSArrayBuffer* array_buffer,
77 JSTypedArray* ta) { 77 JSTypedArray* ta) {
78 for (Object* o = array_buffer->weak_first_array(); 78 for (Object* o = array_buffer->weak_first_array();
79 o != Smi::FromInt(0); 79 !o->IsUndefined();
80 o = JSTypedArray::cast(o)->weak_next()) { 80 o = JSTypedArray::cast(o)->weak_next()) {
81 if (ta == o) return true; 81 if (ta == o) return true;
82 } 82 }
83 return false; 83 return false;
84 } 84 }
85 85
86 86
87 TEST(WeakArrayBuffersFromApi) { 87 TEST(WeakArrayBuffersFromApi) {
88 v8::V8::Initialize(); 88 v8::V8::Initialize();
89 LocalContext context; 89 LocalContext context;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 371
372 TEST(Float64ArrayFromScript) { 372 TEST(Float64ArrayFromScript) {
373 TestTypedArrayFromScript<v8::Float64Array>("Float64Array"); 373 TestTypedArrayFromScript<v8::Float64Array>("Float64Array");
374 } 374 }
375 375
376 376
377 TEST(Uint8ClampedArrayFromScript) { 377 TEST(Uint8ClampedArrayFromScript) {
378 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray"); 378 TestTypedArrayFromScript<v8::Uint8ClampedArray>("Uint8ClampedArray");
379 } 379 }
380 380
OLDNEW
« src/heap.cc ('K') | « src/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698