| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 // Defined when linking against shared lib on Windows. | 6 // Defined when linking against shared lib on Windows. |
| 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) | 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) |
| 8 #define V8_SHARED | 8 #define V8_SHARED |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 counters_in_use_ = 0; | 670 counters_in_use_ = 0; |
| 671 } | 671 } |
| 672 | 672 |
| 673 | 673 |
| 674 Counter* CounterCollection::GetNextCounter() { | 674 Counter* CounterCollection::GetNextCounter() { |
| 675 if (counters_in_use_ == kMaxCounters) return NULL; | 675 if (counters_in_use_ == kMaxCounters) return NULL; |
| 676 return &counters_[counters_in_use_++]; | 676 return &counters_[counters_in_use_++]; |
| 677 } | 677 } |
| 678 | 678 |
| 679 | 679 |
| 680 void Shell::MapCounters(const char* name) { | 680 void Shell::MapCounters(v8::Isolate* isolate, const char* name) { |
| 681 counters_file_ = base::OS::MemoryMappedFile::create( | 681 counters_file_ = base::OS::MemoryMappedFile::create( |
| 682 name, sizeof(CounterCollection), &local_counters_); | 682 name, sizeof(CounterCollection), &local_counters_); |
| 683 void* memory = (counters_file_ == NULL) ? | 683 void* memory = (counters_file_ == NULL) ? |
| 684 NULL : counters_file_->memory(); | 684 NULL : counters_file_->memory(); |
| 685 if (memory == NULL) { | 685 if (memory == NULL) { |
| 686 printf("Could not map counters file %s\n", name); | 686 printf("Could not map counters file %s\n", name); |
| 687 Exit(1); | 687 Exit(1); |
| 688 } | 688 } |
| 689 counters_ = static_cast<CounterCollection*>(memory); | 689 counters_ = static_cast<CounterCollection*>(memory); |
| 690 V8::SetCounterFunction(LookupCounter); | 690 isolate->SetCounterFunction(LookupCounter); |
| 691 V8::SetCreateHistogramFunction(CreateHistogram); | 691 isolate->SetCreateHistogramFunction(CreateHistogram); |
| 692 V8::SetAddHistogramSampleFunction(AddHistogramSample); | 692 isolate->SetAddHistogramSampleFunction(AddHistogramSample); |
| 693 } | 693 } |
| 694 | 694 |
| 695 | 695 |
| 696 int CounterMap::Hash(const char* name) { | 696 int CounterMap::Hash(const char* name) { |
| 697 int h = 0; | 697 int h = 0; |
| 698 int c; | 698 int c; |
| 699 while ((c = *name++) != 0) { | 699 while ((c = *name++) != 0) { |
| 700 h += h << 5; | 700 h += h << 5; |
| 701 h += c; | 701 h += c; |
| 702 } | 702 } |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 if (bz2_result != BZ_OK) { | 890 if (bz2_result != BZ_OK) { |
| 891 fprintf(stderr, "bzip error code: %d\n", bz2_result); | 891 fprintf(stderr, "bzip error code: %d\n", bz2_result); |
| 892 Exit(1); | 892 Exit(1); |
| 893 } | 893 } |
| 894 #endif | 894 #endif |
| 895 | 895 |
| 896 #ifndef V8_SHARED | 896 #ifndef V8_SHARED |
| 897 Shell::counter_map_ = new CounterMap(); | 897 Shell::counter_map_ = new CounterMap(); |
| 898 // Set up counters | 898 // Set up counters |
| 899 if (i::StrLength(i::FLAG_map_counters) != 0) | 899 if (i::StrLength(i::FLAG_map_counters) != 0) |
| 900 MapCounters(i::FLAG_map_counters); | 900 MapCounters(isolate, i::FLAG_map_counters); |
| 901 if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) { | 901 if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) { |
| 902 V8::SetCounterFunction(LookupCounter); | 902 V8::SetCounterFunction(LookupCounter); |
| 903 V8::SetCreateHistogramFunction(CreateHistogram); | 903 V8::SetCreateHistogramFunction(CreateHistogram); |
| 904 V8::SetAddHistogramSampleFunction(AddHistogramSample); | 904 V8::SetAddHistogramSampleFunction(AddHistogramSample); |
| 905 } | 905 } |
| 906 #endif // !V8_SHARED | 906 #endif // !V8_SHARED |
| 907 } | 907 } |
| 908 | 908 |
| 909 | 909 |
| 910 void Shell::InitializeDebugger(Isolate* isolate) { | 910 void Shell::InitializeDebugger(Isolate* isolate) { |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 } | 1638 } |
| 1639 | 1639 |
| 1640 } // namespace v8 | 1640 } // namespace v8 |
| 1641 | 1641 |
| 1642 | 1642 |
| 1643 #ifndef GOOGLE3 | 1643 #ifndef GOOGLE3 |
| 1644 int main(int argc, char* argv[]) { | 1644 int main(int argc, char* argv[]) { |
| 1645 return v8::Shell::Main(argc, argv); | 1645 return v8::Shell::Main(argc, argv); |
| 1646 } | 1646 } |
| 1647 #endif | 1647 #endif |
| OLD | NEW |