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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 v8::HandleScope scope(isolate); | 434 v8::HandleScope scope(isolate); |
435 v8::Local<v8::ObjectTemplate> global_template = | 435 v8::Local<v8::ObjectTemplate> global_template = |
436 v8::ObjectTemplate::New(isolate); | 436 v8::ObjectTemplate::New(isolate); |
437 global_template->SetInternalFieldCount(1); | 437 global_template->SetInternalFieldCount(1); |
438 LocalContext env(NULL, global_template); | 438 LocalContext env(NULL, global_template); |
439 v8::Handle<v8::Object> global_proxy = env->Global(); | 439 v8::Handle<v8::Object> global_proxy = env->Global(); |
440 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); | 440 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); |
441 CHECK_EQ(1, global->InternalFieldCount()); | 441 CHECK_EQ(1, global->InternalFieldCount()); |
442 | 442 |
443 i::Factory* factory = CcTest::i_isolate()->factory(); | 443 i::Factory* factory = CcTest::i_isolate()->factory(); |
444 i::Handle<i::String> first = factory->NewStringFromStaticAscii("0123456789"); | 444 i::Handle<i::String> first = factory->NewStringFromStaticChars("0123456789"); |
445 i::Handle<i::String> second = factory->NewStringFromStaticAscii("0123456789"); | 445 i::Handle<i::String> second = factory->NewStringFromStaticChars("0123456789"); |
446 i::Handle<i::String> cons_string = | 446 i::Handle<i::String> cons_string = |
447 factory->NewConsString(first, second).ToHandleChecked(); | 447 factory->NewConsString(first, second).ToHandleChecked(); |
448 | 448 |
449 global->SetInternalField(0, v8::ToApiHandle<v8::String>(cons_string)); | 449 global->SetInternalField(0, v8::ToApiHandle<v8::String>(cons_string)); |
450 | 450 |
451 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); | 451 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); |
452 const v8::HeapSnapshot* snapshot = | 452 const v8::HeapSnapshot* snapshot = |
453 heap_profiler->TakeHeapSnapshot(v8_str("cons_strings")); | 453 heap_profiler->TakeHeapSnapshot(v8_str("cons_strings")); |
454 CHECK(ValidateSnapshot(snapshot)); | 454 CHECK(ValidateSnapshot(snapshot)); |
455 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); | 455 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 void WriteTo(i::Vector<char> dest) { buffer_.WriteTo(dest); } | 868 void WriteTo(i::Vector<char> dest) { buffer_.WriteTo(dest); } |
869 int eos_signaled() { return eos_signaled_; } | 869 int eos_signaled() { return eos_signaled_; } |
870 int size() { return buffer_.size(); } | 870 int size() { return buffer_.size(); } |
871 | 871 |
872 private: | 872 private: |
873 i::Collector<char> buffer_; | 873 i::Collector<char> buffer_; |
874 int eos_signaled_; | 874 int eos_signaled_; |
875 int abort_countdown_; | 875 int abort_countdown_; |
876 }; | 876 }; |
877 | 877 |
878 class AsciiResource: public v8::String::ExternalAsciiStringResource { | 878 class OneByteResource : public v8::String::ExternalOneByteStringResource { |
879 public: | 879 public: |
880 explicit AsciiResource(i::Vector<char> string): data_(string.start()) { | 880 explicit OneByteResource(i::Vector<char> string) : data_(string.start()) { |
881 length_ = string.length(); | 881 length_ = string.length(); |
882 } | 882 } |
883 virtual const char* data() const { return data_; } | 883 virtual const char* data() const { return data_; } |
884 virtual size_t length() const { return length_; } | 884 virtual size_t length() const { return length_; } |
885 private: | 885 private: |
886 const char* data_; | 886 const char* data_; |
887 size_t length_; | 887 size_t length_; |
888 }; | 888 }; |
889 | 889 |
890 } // namespace | 890 } // namespace |
(...skipping 15 matching lines...) Expand all Loading... |
906 CHECK(ValidateSnapshot(snapshot)); | 906 CHECK(ValidateSnapshot(snapshot)); |
907 | 907 |
908 TestJSONStream stream; | 908 TestJSONStream stream; |
909 snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON); | 909 snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON); |
910 CHECK_GT(stream.size(), 0); | 910 CHECK_GT(stream.size(), 0); |
911 CHECK_EQ(1, stream.eos_signaled()); | 911 CHECK_EQ(1, stream.eos_signaled()); |
912 i::ScopedVector<char> json(stream.size()); | 912 i::ScopedVector<char> json(stream.size()); |
913 stream.WriteTo(json); | 913 stream.WriteTo(json); |
914 | 914 |
915 // Verify that snapshot string is valid JSON. | 915 // Verify that snapshot string is valid JSON. |
916 AsciiResource* json_res = new AsciiResource(json); | 916 OneByteResource* json_res = new OneByteResource(json); |
917 v8::Local<v8::String> json_string = | 917 v8::Local<v8::String> json_string = |
918 v8::String::NewExternal(env->GetIsolate(), json_res); | 918 v8::String::NewExternal(env->GetIsolate(), json_res); |
919 env->Global()->Set(v8_str("json_snapshot"), json_string); | 919 env->Global()->Set(v8_str("json_snapshot"), json_string); |
920 v8::Local<v8::Value> snapshot_parse_result = CompileRun( | 920 v8::Local<v8::Value> snapshot_parse_result = CompileRun( |
921 "var parsed = JSON.parse(json_snapshot); true;"); | 921 "var parsed = JSON.parse(json_snapshot); true;"); |
922 CHECK(!snapshot_parse_result.IsEmpty()); | 922 CHECK(!snapshot_parse_result.IsEmpty()); |
923 | 923 |
924 // Verify that snapshot object has required fields. | 924 // Verify that snapshot object has required fields. |
925 v8::Local<v8::Object> parsed_snapshot = | 925 v8::Local<v8::Object> parsed_snapshot = |
926 env->Global()->Get(v8_str("parsed"))->ToObject(); | 926 env->Global()->Get(v8_str("parsed"))->ToObject(); |
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2647 | 2647 |
2648 | 2648 |
2649 TEST(BoxObject) { | 2649 TEST(BoxObject) { |
2650 v8::Isolate* isolate = CcTest::isolate(); | 2650 v8::Isolate* isolate = CcTest::isolate(); |
2651 v8::HandleScope scope(isolate); | 2651 v8::HandleScope scope(isolate); |
2652 LocalContext env; | 2652 LocalContext env; |
2653 v8::Handle<v8::Object> global_proxy = env->Global(); | 2653 v8::Handle<v8::Object> global_proxy = env->Global(); |
2654 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); | 2654 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); |
2655 | 2655 |
2656 i::Factory* factory = CcTest::i_isolate()->factory(); | 2656 i::Factory* factory = CcTest::i_isolate()->factory(); |
2657 i::Handle<i::String> string = factory->NewStringFromStaticAscii("string"); | 2657 i::Handle<i::String> string = factory->NewStringFromStaticChars("string"); |
2658 i::Handle<i::Object> box = factory->NewBox(string); | 2658 i::Handle<i::Object> box = factory->NewBox(string); |
2659 global->Set(0, v8::ToApiHandle<v8::Object>(box)); | 2659 global->Set(0, v8::ToApiHandle<v8::Object>(box)); |
2660 | 2660 |
2661 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); | 2661 v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); |
2662 const v8::HeapSnapshot* snapshot = | 2662 const v8::HeapSnapshot* snapshot = |
2663 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); | 2663 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); |
2664 CHECK(ValidateSnapshot(snapshot)); | 2664 CHECK(ValidateSnapshot(snapshot)); |
2665 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); | 2665 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); |
2666 const v8::HeapGraphNode* box_node = | 2666 const v8::HeapGraphNode* box_node = |
2667 GetProperty(global_node, v8::HeapGraphEdge::kElement, "0"); | 2667 GetProperty(global_node, v8::HeapGraphEdge::kElement, "0"); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2760 map.AddRange(ToAddress(0x180), 0x80, 6U); | 2760 map.AddRange(ToAddress(0x180), 0x80, 6U); |
2761 map.AddRange(ToAddress(0x180), 0x80, 7U); | 2761 map.AddRange(ToAddress(0x180), 0x80, 7U); |
2762 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); | 2762 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); |
2763 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); | 2763 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); |
2764 CHECK_EQ(3, static_cast<int>(map.size())); | 2764 CHECK_EQ(3, static_cast<int>(map.size())); |
2765 | 2765 |
2766 map.Clear(); | 2766 map.Clear(); |
2767 CHECK_EQ(0, static_cast<int>(map.size())); | 2767 CHECK_EQ(0, static_cast<int>(map.size())); |
2768 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); | 2768 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); |
2769 } | 2769 } |
OLD | NEW |