| 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 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "bootstrapper.h" | |
| 31 #include "debug.h" | |
| 32 #include "isolate.h" | 30 #include "isolate.h" |
| 33 #include "serialize.h" | 31 #include "serialize.h" |
| 34 #include "simulator.h" | |
| 35 #include "stub-cache.h" | |
| 36 #include "heap-profiler.h" | |
| 37 #include "oprofile-agent.h" | |
| 38 #include "log.h" | |
| 39 | 32 |
| 40 namespace v8 { | 33 namespace v8 { |
| 41 namespace internal { | 34 namespace internal { |
| 42 | 35 |
| 43 bool V8::is_running_ = false; | 36 bool V8::is_running_ = false; |
| 44 bool V8::has_been_setup_ = false; | 37 bool V8::has_been_setup_ = false; |
| 45 bool V8::has_been_disposed_ = false; | 38 bool V8::has_been_disposed_ = false; |
| 46 bool V8::has_fatal_error_ = false; | 39 bool V8::has_fatal_error_ = false; |
| 40 bool V8::use_crankshaft_ = true; |
| 47 | 41 |
| 48 | 42 |
| 49 bool V8::Initialize(Deserializer* des) { | 43 bool V8::Initialize(Deserializer* des) { |
| 50 // The current thread may not yet had entered an isolate to run. | 44 // The current thread may not yet had entered an isolate to run. |
| 51 // Note the Isolate::Current() may be non-null because for various | 45 // Note the Isolate::Current() may be non-null because for various |
| 52 // initialization purposes an initializing thread may be assigned an isolate | 46 // initialization purposes an initializing thread may be assigned an isolate |
| 53 // but not actually enter it. | 47 // but not actually enter it. |
| 54 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { | 48 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { |
| 55 i::Isolate::EnterDefaultIsolate(); | 49 i::Isolate::EnterDefaultIsolate(); |
| 56 } | 50 } |
| 57 | 51 |
| 58 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); | 52 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); |
| 59 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id() == | 53 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id() == |
| 60 i::Thread::GetThreadLocalInt(i::Isolate::thread_id_key())); | 54 i::Thread::GetThreadLocalInt(i::Isolate::thread_id_key())); |
| 61 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == | 55 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == |
| 62 i::Isolate::Current()); | 56 i::Isolate::Current()); |
| 63 | 57 |
| 58 if (IsDead()) return false; |
| 59 |
| 64 Isolate* isolate = Isolate::Current(); | 60 Isolate* isolate = Isolate::Current(); |
| 65 if (isolate->IsDefaultIsolate()) { | 61 if (isolate->IsInitialized()) return true; |
| 66 if (has_been_disposed_ || has_fatal_error_) return false; | |
| 67 if (IsRunning()) return true; | |
| 68 | 62 |
| 69 is_running_ = true; | 63 use_crankshaft_ = FLAG_crankshaft; |
| 70 has_been_setup_ = true; | 64 // Peephole optimization might interfere with deoptimization. |
| 71 has_fatal_error_ = false; | 65 FLAG_peephole_optimization = !use_crankshaft_; |
| 72 has_been_disposed_ = false; | 66 |
| 73 } else { | 67 is_running_ = true; |
| 74 if (isolate->IsInitialized()) return true; | 68 has_been_setup_ = true; |
| 75 } | 69 has_fatal_error_ = false; |
| 70 has_been_disposed_ = false; |
| 76 | 71 |
| 77 return isolate->Init(des); | 72 return isolate->Init(des); |
| 78 } | 73 } |
| 79 | 74 |
| 80 | 75 |
| 81 void V8::SetFatalError() { | 76 void V8::SetFatalError() { |
| 82 is_running_ = false; | 77 is_running_ = false; |
| 83 has_fatal_error_ = true; | 78 has_fatal_error_ = true; |
| 84 } | 79 } |
| 85 | 80 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | 169 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
| 175 const double binary_million = 1048576.0; | 170 const double binary_million = 1048576.0; |
| 176 r->double_value = binary_million; | 171 r->double_value = binary_million; |
| 177 r->uint64_t_value |= random_bits; | 172 r->uint64_t_value |= random_bits; |
| 178 r->double_value -= binary_million; | 173 r->double_value -= binary_million; |
| 179 | 174 |
| 180 return heap_number; | 175 return heap_number; |
| 181 } | 176 } |
| 182 | 177 |
| 183 } } // namespace v8::internal | 178 } } // namespace v8::internal |
| OLD | NEW |