Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests for heap profiler | 3 // Tests for heap profiler |
| 4 | 4 |
| 5 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "cctest.h" | 7 #include "cctest.h" |
| 8 #include "heap-profiler.h" | 8 #include "heap-profiler.h" |
| 9 #include "snapshot.h" | 9 #include "snapshot.h" |
| 10 #include "utils-inl.h" | 10 #include "utils-inl.h" |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 "Constructor4", i::V8HeapExplorer::GetConstructorName(*js_obj4))); | 1016 "Constructor4", i::V8HeapExplorer::GetConstructorName(*js_obj4))); |
| 1017 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>(); | 1017 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>(); |
| 1018 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5); | 1018 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5); |
| 1019 CHECK_EQ(0, StringCmp( | 1019 CHECK_EQ(0, StringCmp( |
| 1020 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5))); | 1020 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5))); |
| 1021 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>(); | 1021 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>(); |
| 1022 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6); | 1022 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6); |
| 1023 CHECK_EQ(0, StringCmp( | 1023 CHECK_EQ(0, StringCmp( |
| 1024 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6))); | 1024 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6))); |
| 1025 } | 1025 } |
| 1026 | |
| 1027 TEST(FastCaseGetter) { | |
| 1028 v8::HandleScope scope; | |
| 1029 LocalContext env; | |
| 1030 | |
| 1031 CompileRun("var obj1 = {};\n" | |
| 1032 "obj1.__defineGetter__('propWithGetter', function Y() { return 42; });\n" | |
|
mnaganov (inactive)
2011/11/11 22:47:46
80 chars
| |
| 1033 "obj1.__defineSetter__('propWithSetter', function Z(value) { return this.value_ = value; });\n"); | |
| 1034 const v8::HeapSnapshot* snapshot = | |
| 1035 v8::HeapProfiler::TakeSnapshot(v8_str("fastCaseGetter")); | |
| 1036 | |
| 1037 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); | |
| 1038 CHECK_NE(NULL, global); | |
| 1039 const v8::HeapGraphNode* obj1 = | |
| 1040 GetProperty(global, v8::HeapGraphEdge::kShortcut, "obj1"); | |
| 1041 CHECK_NE(NULL, obj1); | |
| 1042 const v8::HeapGraphNode* getterFunction = | |
| 1043 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get_propWithGetter"); | |
| 1044 CHECK_NE(NULL, getterFunction); | |
| 1045 const v8::HeapGraphNode* setterFunction = | |
| 1046 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set_propWithSetter"); | |
| 1047 CHECK_NE(NULL, setterFunction); | |
| 1048 } | |
| OLD | NEW |