OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 return weakmap; | 53 return weakmap; |
54 } | 54 } |
55 | 55 |
56 static int NumberOfWeakCalls = 0; | 56 static int NumberOfWeakCalls = 0; |
57 static void WeakPointerCallback( | 57 static void WeakPointerCallback( |
58 const v8::WeakCallbackData<v8::Value, void>& data) { | 58 const v8::WeakCallbackData<v8::Value, void>& data) { |
59 std::pair<v8::Persistent<v8::Value>*, int>* p = | 59 std::pair<v8::Persistent<v8::Value>*, int>* p = |
60 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( | 60 reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( |
61 data.GetParameter()); | 61 data.GetParameter()); |
62 DCHECK_EQ(1234, p->second); | 62 CHECK_EQ(1234, p->second); |
63 NumberOfWeakCalls++; | 63 NumberOfWeakCalls++; |
64 p->first->Reset(); | 64 p->first->Reset(); |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 TEST(Weakness) { | 68 TEST(Weakness) { |
69 FLAG_incremental_marking = false; | 69 FLAG_incremental_marking = false; |
70 LocalContext context; | 70 LocalContext context; |
71 Isolate* isolate = GetIsolateFrom(&context); | 71 Isolate* isolate = GetIsolateFrom(&context); |
72 Factory* factory = isolate->factory(); | 72 Factory* factory = isolate->factory(); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 { | 260 { |
261 HandleScope scope(isolate); | 261 HandleScope scope(isolate); |
262 AllocateJSWeakMap(isolate); | 262 AllocateJSWeakMap(isolate); |
263 SimulateIncrementalMarking(heap); | 263 SimulateIncrementalMarking(heap); |
264 } | 264 } |
265 // The weak map is marked black here but leaving the handle scope will make | 265 // The weak map is marked black here but leaving the handle scope will make |
266 // the object unreachable. Aborting incremental marking will clear all the | 266 // the object unreachable. Aborting incremental marking will clear all the |
267 // marking bits which makes the weak map garbage. | 267 // marking bits which makes the weak map garbage. |
268 heap->CollectAllGarbage(); | 268 heap->CollectAllGarbage(); |
269 } | 269 } |
OLD | NEW |