OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
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 of logging functions from log.h | 28 // Tests of logging functions from log.h |
29 | 29 |
| 30 #define V8_DISABLE_DEPRECATIONS 1 |
30 #ifdef __linux__ | 31 #ifdef __linux__ |
31 #include <pthread.h> | 32 #include <pthread.h> |
32 #include <signal.h> | 33 #include <signal.h> |
33 #include <unistd.h> | 34 #include <unistd.h> |
34 #include <cmath> | 35 #include <cmath> |
35 #endif // __linux__ | 36 #endif // __linux__ |
36 | 37 |
37 #include "v8.h" | 38 #include "v8.h" |
38 #include "log.h" | 39 #include "log.h" |
39 #include "log-utils.h" | 40 #include "log-utils.h" |
40 #include "cpu-profiler.h" | 41 #include "cpu-profiler.h" |
41 #include "natives.h" | 42 #include "natives.h" |
42 #include "v8threads.h" | 43 #include "v8threads.h" |
43 #include "v8utils.h" | 44 #include "v8utils.h" |
44 #include "cctest.h" | 45 #include "cctest.h" |
45 #include "vm-state-inl.h" | 46 #include "vm-state-inl.h" |
| 47 #undef V8_DISABLE_DEPRECATIONS |
46 | 48 |
47 using v8::internal::Address; | 49 using v8::internal::Address; |
48 using v8::internal::EmbeddedVector; | 50 using v8::internal::EmbeddedVector; |
49 using v8::internal::Logger; | 51 using v8::internal::Logger; |
50 using v8::internal::StrLength; | 52 using v8::internal::StrLength; |
51 | 53 |
52 namespace { | 54 namespace { |
53 | 55 |
54 | 56 |
55 class ScopedLoggerInitializer { | 57 class ScopedLoggerInitializer { |
56 public: | 58 public: |
57 explicit ScopedLoggerInitializer(bool prof_lazy) | 59 explicit ScopedLoggerInitializer(bool prof_lazy) |
58 : saved_log_(i::FLAG_log), | 60 : saved_log_(i::FLAG_log), |
59 saved_prof_lazy_(i::FLAG_prof_lazy), | 61 saved_prof_lazy_(i::FLAG_prof_lazy), |
60 saved_prof_(i::FLAG_prof), | 62 saved_prof_(i::FLAG_prof), |
61 saved_prof_auto_(i::FLAG_prof_auto), | |
62 temp_file_(NULL), | 63 temp_file_(NULL), |
63 // Need to run this prior to creating the scope. | 64 // Need to run this prior to creating the scope. |
64 trick_to_run_init_flags_(init_flags_(prof_lazy)), | 65 trick_to_run_init_flags_(init_flags_(prof_lazy)), |
65 scope_(v8::Isolate::GetCurrent()), | 66 scope_(v8::Isolate::GetCurrent()), |
66 env_(v8::Context::New(v8::Isolate::GetCurrent())), | 67 env_(v8::Context::New(v8::Isolate::GetCurrent())), |
67 logger_(i::Isolate::Current()->logger()) { | 68 logger_(i::Isolate::Current()->logger()) { |
68 env_->Enter(); | 69 env_->Enter(); |
69 } | 70 } |
70 | 71 |
71 ~ScopedLoggerInitializer() { | 72 ~ScopedLoggerInitializer() { |
72 env_->Exit(); | 73 env_->Exit(); |
73 logger_->TearDown(); | 74 logger_->TearDown(); |
74 if (temp_file_ != NULL) fclose(temp_file_); | 75 if (temp_file_ != NULL) fclose(temp_file_); |
75 i::FLAG_prof_lazy = saved_prof_lazy_; | 76 i::FLAG_prof_lazy = saved_prof_lazy_; |
76 i::FLAG_prof = saved_prof_; | 77 i::FLAG_prof = saved_prof_; |
77 i::FLAG_prof_auto = saved_prof_auto_; | |
78 i::FLAG_log = saved_log_; | 78 i::FLAG_log = saved_log_; |
79 } | 79 } |
80 | 80 |
81 v8::Handle<v8::Context>& env() { return env_; } | 81 v8::Handle<v8::Context>& env() { return env_; } |
82 | 82 |
83 Logger* logger() { return logger_; } | 83 Logger* logger() { return logger_; } |
84 | 84 |
85 FILE* StopLoggingGetTempFile() { | 85 FILE* StopLoggingGetTempFile() { |
86 temp_file_ = logger_->TearDown(); | 86 temp_file_ = logger_->TearDown(); |
87 CHECK_NE(NULL, temp_file_); | 87 CHECK_NE(NULL, temp_file_); |
88 fflush(temp_file_); | 88 fflush(temp_file_); |
89 rewind(temp_file_); | 89 rewind(temp_file_); |
90 return temp_file_; | 90 return temp_file_; |
91 } | 91 } |
92 | 92 |
93 private: | 93 private: |
94 static bool init_flags_(bool prof_lazy) { | 94 static bool init_flags_(bool prof_lazy) { |
95 i::FLAG_log = true; | 95 i::FLAG_log = true; |
96 i::FLAG_prof = true; | 96 i::FLAG_prof = true; |
97 i::FLAG_prof_lazy = prof_lazy; | 97 i::FLAG_prof_lazy = prof_lazy; |
98 i::FLAG_prof_auto = false; | |
99 i::FLAG_logfile = i::Log::kLogToTemporaryFile; | 98 i::FLAG_logfile = i::Log::kLogToTemporaryFile; |
100 return prof_lazy; | 99 return prof_lazy; |
101 } | 100 } |
102 | 101 |
103 const bool saved_log_; | 102 const bool saved_log_; |
104 const bool saved_prof_lazy_; | 103 const bool saved_prof_lazy_; |
105 const bool saved_prof_; | 104 const bool saved_prof_; |
106 const bool saved_prof_auto_; | |
107 FILE* temp_file_; | 105 FILE* temp_file_; |
108 const bool trick_to_run_init_flags_; | 106 const bool trick_to_run_init_flags_; |
109 v8::HandleScope scope_; | 107 v8::HandleScope scope_; |
110 v8::Handle<v8::Context> env_; | 108 v8::Handle<v8::Context> env_; |
111 Logger* logger_; | 109 Logger* logger_; |
112 | 110 |
113 DISALLOW_COPY_AND_ASSIGN(ScopedLoggerInitializer); | 111 DISALLOW_COPY_AND_ASSIGN(ScopedLoggerInitializer); |
114 }; | 112 }; |
115 | 113 |
116 } // namespace | 114 } // namespace |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 v8::Local<v8::String> s = result->ToString(); | 559 v8::Local<v8::String> s = result->ToString(); |
562 i::ScopedVector<char> data(s->Utf8Length() + 1); | 560 i::ScopedVector<char> data(s->Utf8Length() + 1); |
563 CHECK_NE(NULL, data.start()); | 561 CHECK_NE(NULL, data.start()); |
564 s->WriteUtf8(data.start()); | 562 s->WriteUtf8(data.start()); |
565 printf("%s\n", data.start()); | 563 printf("%s\n", data.start()); |
566 // Make sure that our output is written prior crash due to CHECK failure. | 564 // Make sure that our output is written prior crash due to CHECK failure. |
567 fflush(stdout); | 565 fflush(stdout); |
568 CHECK(false); | 566 CHECK(false); |
569 } | 567 } |
570 } | 568 } |
OLD | NEW |