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 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 // | 27 // |
28 // Tests for heap profiler | 28 // Tests for heap profiler |
29 | 29 |
30 #include <ctype.h> | 30 #include <ctype.h> |
31 | 31 |
| 32 // TODO(dcarney): remove |
| 33 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT |
| 34 |
32 #include "v8.h" | 35 #include "v8.h" |
33 | 36 |
34 #include "cctest.h" | 37 #include "cctest.h" |
35 #include "hashmap.h" | 38 #include "hashmap.h" |
36 #include "heap-profiler.h" | 39 #include "heap-profiler.h" |
37 #include "snapshot.h" | 40 #include "snapshot.h" |
38 #include "debug.h" | 41 #include "debug.h" |
39 #include "utils-inl.h" | 42 #include "utils-inl.h" |
40 #include "../include/v8-profiler.h" | 43 #include "../include/v8-profiler.h" |
41 | 44 |
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 class GraphWithImplicitRefs { | 1191 class GraphWithImplicitRefs { |
1189 public: | 1192 public: |
1190 static const int kObjectsCount = 4; | 1193 static const int kObjectsCount = 4; |
1191 explicit GraphWithImplicitRefs(LocalContext* env) { | 1194 explicit GraphWithImplicitRefs(LocalContext* env) { |
1192 CHECK_EQ(NULL, instance_); | 1195 CHECK_EQ(NULL, instance_); |
1193 instance_ = this; | 1196 instance_ = this; |
1194 v8::Isolate* isolate = (*env)->GetIsolate(); | 1197 v8::Isolate* isolate = (*env)->GetIsolate(); |
1195 for (int i = 0; i < kObjectsCount; i++) { | 1198 for (int i = 0; i < kObjectsCount; i++) { |
1196 objects_[i] = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); | 1199 objects_[i] = v8::Persistent<v8::Object>::New(isolate, v8::Object::New()); |
1197 } | 1200 } |
1198 (*env)->Global()->Set(v8_str("root_object"), objects_[0]); | 1201 (*env)->Global()->Set(v8_str("root_object"), |
| 1202 v8::Local<v8::Value>::New(isolate, objects_[0])); |
1199 } | 1203 } |
1200 ~GraphWithImplicitRefs() { | 1204 ~GraphWithImplicitRefs() { |
1201 instance_ = NULL; | 1205 instance_ = NULL; |
1202 } | 1206 } |
1203 | 1207 |
1204 static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) { | 1208 static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) { |
1205 instance_->AddImplicitReferences(); | 1209 instance_->AddImplicitReferences(); |
1206 } | 1210 } |
1207 | 1211 |
1208 private: | 1212 private: |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 // Check all the objects have got their names. | 1769 // Check all the objects have got their names. |
1766 // ... well check just every 8th because otherwise it's too slow in debug. | 1770 // ... well check just every 8th because otherwise it's too slow in debug. |
1767 for (int i = 0; i < num_objects - 1; i += 8) { | 1771 for (int i = 0; i < num_objects - 1; i += 8) { |
1768 i::EmbeddedVector<char, 100> var_name; | 1772 i::EmbeddedVector<char, 100> var_name; |
1769 i::OS::SNPrintF(var_name, "f_%d", i); | 1773 i::OS::SNPrintF(var_name, "f_%d", i); |
1770 const v8::HeapGraphNode* f_object = GetProperty( | 1774 const v8::HeapGraphNode* f_object = GetProperty( |
1771 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); | 1775 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); |
1772 CHECK_NE(NULL, f_object); | 1776 CHECK_NE(NULL, f_object); |
1773 } | 1777 } |
1774 } | 1778 } |
OLD | NEW |