| 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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 isolate_ = (*env)->GetIsolate(); | 1197 isolate_ = (*env)->GetIsolate(); |
| 1195 for (int i = 0; i < kObjectsCount; i++) { | 1198 for (int i = 0; i < kObjectsCount; i++) { |
| 1196 objects_[i] = | 1199 objects_[i] = |
| 1197 v8::Persistent<v8::Object>::New(isolate_, v8::Object::New()); | 1200 v8::Persistent<v8::Object>::New(isolate_, v8::Object::New()); |
| 1198 } | 1201 } |
| 1199 (*env)->Global()->Set(v8_str("root_object"), objects_[0]); | 1202 (*env)->Global()->Set(v8_str("root_object"), |
| 1203 v8::Local<v8::Value>::New(isolate_, objects_[0])); |
| 1200 } | 1204 } |
| 1201 ~GraphWithImplicitRefs() { | 1205 ~GraphWithImplicitRefs() { |
| 1202 instance_ = NULL; | 1206 instance_ = NULL; |
| 1203 } | 1207 } |
| 1204 | 1208 |
| 1205 static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) { | 1209 static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) { |
| 1206 instance_->AddImplicitReferences(); | 1210 instance_->AddImplicitReferences(); |
| 1207 } | 1211 } |
| 1208 | 1212 |
| 1209 private: | 1213 private: |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 // Check all the objects have got their names. | 1775 // Check all the objects have got their names. |
| 1772 // ... well check just every 8th because otherwise it's too slow in debug. | 1776 // ... well check just every 8th because otherwise it's too slow in debug. |
| 1773 for (int i = 0; i < num_objects - 1; i += 8) { | 1777 for (int i = 0; i < num_objects - 1; i += 8) { |
| 1774 i::EmbeddedVector<char, 100> var_name; | 1778 i::EmbeddedVector<char, 100> var_name; |
| 1775 i::OS::SNPrintF(var_name, "f_%d", i); | 1779 i::OS::SNPrintF(var_name, "f_%d", i); |
| 1776 const v8::HeapGraphNode* f_object = GetProperty( | 1780 const v8::HeapGraphNode* f_object = GetProperty( |
| 1777 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); | 1781 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); |
| 1778 CHECK_NE(NULL, f_object); | 1782 CHECK_NE(NULL, f_object); |
| 1779 } | 1783 } |
| 1780 } | 1784 } |
| OLD | NEW |